Search in sources :

Example 16 with RestCoreAPI

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));
}
Also used : UserModel(org.alfresco.utility.model.UserModel) EventResult(org.alfresco.bm.event.EventResult) UserData(org.alfresco.bm.user.UserData) RestCoreAPI(org.alfresco.rest.requests.coreAPI.RestCoreAPI) People(org.alfresco.rest.requests.People) Event(org.alfresco.bm.event.Event) DBObject(com.mongodb.DBObject) Test(org.junit.Test)

Aggregations

RestCoreAPI (org.alfresco.rest.requests.coreAPI.RestCoreAPI)16 EventResult (org.alfresco.bm.event.EventResult)15 Test (org.junit.Test)15 SiteData (org.alfresco.bm.site.SiteData)11 Node (org.alfresco.rest.requests.Node)10 Site (org.alfresco.rest.requests.Site)10 StopWatch (org.apache.commons.lang3.time.StopWatch)10 RestWrapper (org.alfresco.rest.core.RestWrapper)9 RestNodeModelsCollection (org.alfresco.rest.model.RestNodeModelsCollection)8 RestPaginationModel (org.alfresco.rest.model.RestPaginationModel)8 RestSiteContainerModel (org.alfresco.rest.model.RestSiteContainerModel)8 RestSiteModel (org.alfresco.rest.model.RestSiteModel)8 RepoTestModel (org.alfresco.utility.model.RepoTestModel)8 NodesBuilder (org.alfresco.rest.model.builder.NodesBuilder)7 NodeDetail (org.alfresco.rest.model.builder.NodesBuilder.NodeDetail)7 RestNodeModel (org.alfresco.rest.model.RestNodeModel)6 People (org.alfresco.rest.requests.People)5 DBObject (com.mongodb.DBObject)4 Event (org.alfresco.bm.event.Event)4 UserData (org.alfresco.bm.user.UserData)4