List of usage examples for org.apache.commons.collections MapUtils putAll
public static Map putAll(Map map, Object[] array)
From source file:jp.eisbahn.oauth2.server.fetcher.accesstoken.impl.RequestParameterTest.java
private Request createRequestMock(String[] values) { Map<String, String> parameterMap = new HashMap<String, String>(); MapUtils.putAll(parameterMap, values); Request request = createMock(Request.class); expect(request.getParameterMap()).andReturn(parameterMap); replay(request);/*from w ww . j a va 2 s .c om*/ return request; }
From source file:info.novatec.inspectit.cmr.service.RegistrationServiceTest.java
/** * Test that the registration of the {@link MethodSensorTypeIdent} will be correct if properties * are provided.//ww w . j a v a2s . c o m * * @throws RemoteException * If {@link RemoteException} occurs. */ @SuppressWarnings("unchecked") @Test public void registerMethodSensorTypeWithSettings() throws RemoteException { final long methodSensorId = 30; long platformId = 1; String fqcName = "class"; String regEx = "myRegEx"; String regExTemplate = "myRegExTemplate"; Map<String, Object> settings = MapUtils.putAll(new HashMap<String, Object>(), new String[][] { { "regEx", regEx }, { "regExTemplate", regExTemplate } }); PlatformIdent platformIdent = new PlatformIdent(); when(platformIdentDao.load(platformId)).thenReturn(platformIdent); when(methodSensorTypeIdentDao.findByExample(eq(platformId), (MethodSensorTypeIdent) anyObject())) .thenReturn(Collections.<MethodSensorTypeIdent>emptyList()); Mockito.doAnswer(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { MethodSensorTypeIdent methodSensorIdent = (MethodSensorTypeIdent) invocation.getArguments()[0]; methodSensorIdent.setId(Long.valueOf(methodSensorId)); return null; } }).when(methodSensorTypeIdentDao).saveOrUpdate((MethodSensorTypeIdent) anyObject()); long registeredId = registrationService.registerMethodSensorTypeIdent(platformId, fqcName, settings); assertThat(registeredId, is(equalTo(methodSensorId))); ArgumentCaptor<MethodSensorTypeIdent> methodSensorArgument = ArgumentCaptor .forClass(MethodSensorTypeIdent.class); verify(methodSensorTypeIdentDao, times(1)).saveOrUpdate(methodSensorArgument.capture()); assertThat(methodSensorArgument.getValue().getSettings(), is(settings)); }
From source file:org.sventon.service.javahl.JavaHLRepositoryServiceTest.java
@Test public void testGetLogEntries() throws Exception { final Map<String, String> propMap = new HashMap<String, String>(); final ChangePath cp1 = mock(ChangePath.class); final ChangePath cp2 = mock(ChangePath.class); final ChangePath[] changePaths = { cp1, cp2 }; final int rev = 4711; final Date date = new Date(); final String dateString = DateUtil.formatISO8601(date); MapUtils.putAll(propMap, new String[][] { { "svn:author", "daAuthor" }, { "svn:date", dateString }, { "svn:log", "Added new text in my finest file" } }); when(cp1.getPath()).thenReturn("/trunk/src/main/da/path/myfile.txt"); when(cp1.getAction()).thenReturn('M'); when(cp1.getCopySrcPath()).thenReturn(null); when(cp1.getCopySrcRevision()).thenReturn(-1L); when(cp2.getPath()).thenReturn("/branches/lemontree/src/main/da/path/myfile.txt"); when(cp2.getAction()).thenReturn('A'); when(cp2.getCopySrcPath()).thenReturn(null); when(cp2.getCopySrcRevision()).thenReturn(-1L); when(connection.getRepositoryRootUrl()).thenReturn(new SVNURL("svn://myhost/repro")); // Yiks! We probably need to refactor this later... // Matching for SVNClient.logMessages() is also a little bit too loose. doAnswer(new Answer() { @Override//w ww . j av a 2s. c o m public Object answer(InvocationOnMock invocation) throws Throwable { Object[] args = invocation.getArguments(); final LogMessageCallback cb = (LogMessageCallback) args[8]; cb.singleMessage(changePaths, rev, propMap, false); return null; } }).when(client).logMessages(eq("svn://myhost/repro/da/path"), (Revision) any(), (RevisionRange[]) any(), eq(false), eq(false), eq(false), (String[]) any(), anyInt(), (LogMessageCallback) any()); final List<LogEntry> logEntries = service.getLogEntries(connection, null, 1, 100, "da/path", 100, false, false); // Verify number of LogEntries assertEquals(1, logEntries.size()); // Verify ChangePath final LogEntry logEntry = logEntries.get(0); final SortedSet<ChangedPath> changedPaths = logEntry.getChangedPaths(); assertEquals(2, changedPaths.size()); ChangedPath[] paths = new ChangedPath[2]; changedPaths.toArray(paths); assertEquals("/branches/lemontree/src/main/da/path/myfile.txt", paths[0].getPath()); assertEquals(ChangeType.ADDED, paths[0].getType()); assertEquals("/trunk/src/main/da/path/myfile.txt", paths[1].getPath()); assertEquals(ChangeType.MODIFIED, paths[1].getType()); //Verify Properties assertEquals("daAuthor", logEntry.getAuthor()); // TODO: check this! We fail because we're GMT+1&DLS and date is in UTC... //assertEquals(date, logEntry.getDate()); assertEquals("Added new text in my finest file", logEntry.getMessage()); assertEquals(4711, logEntry.getRevision()); }