Search in sources :

Example 21 with SiteData

use of org.alfresco.bm.site.SiteData in project records-management by Alfresco.

the class RMBaseEventProcessorUnitTest method testGetUserWithNoRegisteredAdminRoleUser.

@Test(expected = IllegalStateException.class)
public void testGetUserWithNoRegisteredAdminRoleUser() throws Exception {
    String userName = "user1";
    Logger mockedLog = mock(Logger.class);
    SiteData mockedSiteData = mock(SiteData.class);
    when(mockedSiteDataService.getSite(PATH_SNIPPET_RM_SITE_ID)).thenReturn(mockedSiteData);
    SiteMemberData mockedSiteMemberData = mock(SiteMemberData.class);
    when(mockedSiteMemberData.getUsername()).thenReturn(userName);
    when(mockedSiteDataService.randomSiteMember(PATH_SNIPPET_RM_SITE_ID, DataCreationState.Created, null, RMRole.Administrator.toString())).thenReturn(mockedSiteMemberData);
    when(mockedUserDataService.findUserByUsername(userName)).thenReturn(null);
    testRMBaseEventProcessor.getRandomUser(mockedLog);
}
Also used : SiteData(org.alfresco.bm.site.SiteData) SiteMemberData(org.alfresco.bm.site.SiteMemberData) Logger(org.slf4j.Logger) Test(org.junit.Test)

Example 22 with SiteData

use of org.alfresco.bm.site.SiteData in project records-management by Alfresco.

the class RMBaseEventProcessorUnitTest method testGetUserSuccessfull.

@Test
public void testGetUserSuccessfull() throws Exception {
    String userName = "user1";
    Logger mockedLog = mock(Logger.class);
    SiteData mockedSiteData = mock(SiteData.class);
    when(mockedSiteDataService.getSite(PATH_SNIPPET_RM_SITE_ID)).thenReturn(mockedSiteData);
    SiteMemberData mockedSiteMemberData = mock(SiteMemberData.class);
    when(mockedSiteMemberData.getUsername()).thenReturn(userName);
    when(mockedSiteDataService.randomSiteMember(PATH_SNIPPET_RM_SITE_ID, DataCreationState.Created, null, RMRole.Administrator.toString())).thenReturn(mockedSiteMemberData);
    UserData mockedUserData = mock(UserData.class);
    when(mockedUserDataService.findUserByUsername(userName)).thenReturn(mockedUserData);
    UserData user = testRMBaseEventProcessor.getRandomUser(mockedLog);
    assertEquals(mockedUserData, user);
}
Also used : SiteData(org.alfresco.bm.site.SiteData) SiteMemberData(org.alfresco.bm.site.SiteMemberData) UserData(org.alfresco.bm.user.UserData) Logger(org.slf4j.Logger) Test(org.junit.Test)

Aggregations

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