use of org.alfresco.rest.requests.coreAPI.RestCoreAPI in project records-management by Alfresco.
the class PrepareRMSiteUnitTest method testCreateRMSiteWhenRMSiteDoesNotExistAndNotLoadedInDb.
@Test
public void testCreateRMSiteWhenRMSiteDoesNotExistAndNotLoadedInDb() throws Exception {
String username = "bob";
String password = "secret";
prepareRMSite.setUsername(username);
prepareRMSite.setPassword(password);
when(mockedRestAPIFactory.getRMSiteAPI(any(UserModel.class))).thenReturn(mockedRMSiteAPI);
when(mockedRMSiteAPI.existsRMSite()).thenReturn(false);
People mockedPeople = mock(People.class);
RestCoreAPI mockedCoreAPI = mock(RestCoreAPI.class);
when(mockedCoreAPI.usingAuthUser()).thenReturn(mockedPeople);
when(mockedRestCoreAPI.withCoreAPI()).thenReturn(mockedCoreAPI);
when(mockedRestCoreAPI.getStatusCode()).thenReturn(HttpStatus.OK.toString());
EventResult result = prepareRMSite.processEvent(null);
ArgumentCaptor<UserData> userData = forClass(UserData.class);
verify(mockedUserDataService).createNewUser(userData.capture());
// Check events
assertEquals(true, result.isSuccess());
List<Event> events = result.getNextEvents();
assertEquals(1, events.size());
Event event = events.get(0);
assertEquals(DEFAULT_EVENT_NAME_RM_SITE_PREPARED, event.getName());
DBObject data = (DBObject) event.getData();
notNull(data);
assertEquals(RM_SITE_ID, (String) data.get(FIELD_SITE_ID));
assertEquals(username, (String) data.get(FIELD_SITE_MANAGER_NAME));
assertEquals(password, (String) data.get(FIELD_SITE_MANAGER_PASSWORD));
assertEquals(null, (String) data.get(FIELD_ONLY_DB_LOAD));
}
Aggregations