Search in sources :

Example 1 with RMSite

use of org.alfresco.rm.rest.api.model.RMSite in project records-management by Alfresco.

the class RMSitesImplUnitTest method createRMSiteWithSkipAddToFavouritesParameter.

@Test
public void createRMSiteWithSkipAddToFavouritesParameter() throws Exception {
    RMSite toCreate = new RMSite();
    toCreate.setTitle(RM_SITE_TITLE);
    toCreate.setDescription(RM_SITE_DESCRIPTION);
    // mocked SiteInfo
    SiteInfo mockedSiteInfo = mock(SiteInfo.class);
    NodeRef siteNodeRef = AlfMock.generateNodeRef(mockedNodeService);
    when(mockedSiteInfo.getShortName()).thenReturn(RM_SITE_ID);
    when(mockedSiteInfo.getNodeRef()).thenReturn(siteNodeRef);
    when(mockedSiteInfo.getDescription()).thenReturn(RM_SITE_DESCRIPTION);
    when(mockedSiteInfo.getTitle()).thenReturn(RM_SITE_TITLE);
    when(mockedSiteInfo.getVisibility()).thenReturn(SiteVisibility.PUBLIC);
    when(mockedSiteService.createSite(any(String.class), any(String.class), any(String.class), any(String.class), any(SiteVisibility.class), any(QName.class))).thenReturn(mockedSiteInfo);
    // mock Parameters
    Parameters mockedParameters = mock(Parameters.class);
    when(mockedParameters.getParameter(PARAM_SKIP_ADDTOFAVORITES)).thenReturn(Boolean.toString(true));
    // call createRMSite method
    rmSitesImpl.createRMSite(toCreate, mockedParameters);
    verify(mockedSiteService, times(1)).createSite(RM_SITE_PRESET, RM_SITE_ID, RM_SITE_TITLE, RM_SITE_DESCRIPTION, SiteVisibility.PUBLIC, RecordsManagementModel.TYPE_RM_SITE);
    verify(mockedImporterService, times(1)).importView(any(SiteImportPackageHandler.class), any(Location.class), any(ImporterBinding.class), eq(null));
    verify(mockedSiteService, times(1)).createContainer(RM_SITE_ID, SiteService.DOCUMENT_LIBRARY, ContentModel.TYPE_FOLDER, null);
    verify(mockedFavouritesService, never()).addFavourite(any(String.class), any(NodeRef.class));
}
Also used : ImporterBinding(org.alfresco.service.cmr.view.ImporterBinding) SiteInfo(org.alfresco.service.cmr.site.SiteInfo) NodeRef(org.alfresco.service.cmr.repository.NodeRef) RMSite(org.alfresco.rm.rest.api.model.RMSite) Parameters(org.alfresco.rest.framework.resource.parameters.Parameters) QName(org.alfresco.service.namespace.QName) SiteImportPackageHandler(org.alfresco.rest.api.impl.SiteImportPackageHandler) SiteVisibility(org.alfresco.service.cmr.site.SiteVisibility) Location(org.alfresco.service.cmr.view.Location) BaseUnitTest(org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest) Test(org.junit.Test)

Example 2 with RMSite

use of org.alfresco.rm.rest.api.model.RMSite in project records-management by Alfresco.

the class RMSitesImplUnitTest method getRMSite.

@Test
public void getRMSite() throws Exception {
    String siteId = RM_SITE_ID;
    SiteInfo mockedSiteInfo = mock(SiteInfo.class);
    NodeRef siteNodeRef = AlfMock.generateNodeRef(mockedNodeService);
    when(mockedSiteInfo.getShortName()).thenReturn(siteId);
    when(mockedSiteInfo.getNodeRef()).thenReturn(siteNodeRef);
    when(mockedSiteInfo.getDescription()).thenReturn(RM_SITE_DESCRIPTION);
    when(mockedSiteInfo.getTitle()).thenReturn(RM_SITE_TITLE);
    when(mockedSiteInfo.getVisibility()).thenReturn(SiteVisibility.PUBLIC);
    when(mockedNodeService.getType(siteNodeRef)).thenReturn(RecordsManagementModel.TYPE_RM_SITE);
    when(mockedSiteService.getSite(siteId)).thenReturn(mockedSiteInfo);
    when(mockedSiteService.getMembersRole(eq(siteId), any(String.class))).thenReturn(RM_SITE_MANAGER_ROLE);
    // STANDARD compliance
    RMSite rmSite = rmSitesImpl.getRMSite(siteId);
    assertEquals(RMSiteCompliance.STANDARD, rmSite.getCompliance());
    assertEquals(RM_SITE_MANAGER_ROLE, rmSite.getRole());
    assertEquals(siteId, rmSite.getId());
    assertEquals(siteNodeRef.getId(), rmSite.getGuid());
    assertEquals(RM_SITE_DESCRIPTION, rmSite.getDescription());
    assertEquals(RM_SITE_TITLE, rmSite.getTitle());
    assertEquals(SiteVisibility.PUBLIC, rmSite.getVisibility());
    // DOD5015 compliance
    when(mockedNodeService.getType(siteNodeRef)).thenReturn(DOD5015Model.TYPE_DOD_5015_SITE);
    rmSite = rmSitesImpl.getRMSite(siteId);
    assertEquals(RMSiteCompliance.DOD5015, rmSite.getCompliance());
    assertEquals(RM_SITE_MANAGER_ROLE, rmSite.getRole());
    assertEquals(siteId, rmSite.getId());
    assertEquals(siteNodeRef.getId(), rmSite.getGuid());
    assertEquals(RM_SITE_DESCRIPTION, rmSite.getDescription());
    assertEquals(RM_SITE_TITLE, rmSite.getTitle());
    assertEquals(SiteVisibility.PUBLIC, rmSite.getVisibility());
}
Also used : SiteInfo(org.alfresco.service.cmr.site.SiteInfo) NodeRef(org.alfresco.service.cmr.repository.NodeRef) RMSite(org.alfresco.rm.rest.api.model.RMSite) BaseUnitTest(org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest) Test(org.junit.Test)

Example 3 with RMSite

use of org.alfresco.rm.rest.api.model.RMSite in project records-management by Alfresco.

the class RMSiteEntityResourceUnitTest method happyPathUpdate.

@Test
public void happyPathUpdate() throws Exception {
    String siteId = RM_SITE_ID;
    Params parameters = mock(Params.class);
    RMSite site = new RMSite();
    site.setTitle("New Title");
    site.setDescription("New Description");
    rmSiteEntityResource.update(siteId, site, parameters);
    verify(mockedRMSites, times(1)).updateRMSite(any(String.class), any(SiteUpdate.class), any(Parameters.class));
}
Also used : RMSite(org.alfresco.rm.rest.api.model.RMSite) Parameters(org.alfresco.rest.framework.resource.parameters.Parameters) SiteUpdate(org.alfresco.rest.api.model.SiteUpdate) Params(org.alfresco.rest.framework.resource.parameters.Params) BaseUnitTest(org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest) Test(org.junit.Test)

Example 4 with RMSite

use of org.alfresco.rm.rest.api.model.RMSite in project records-management by Alfresco.

the class RMSiteEntityResourceUnitTest method updateNonRMSite.

@Test
public void updateNonRMSite() throws Exception {
    String siteId = NON_RM_SITE_ID;
    Params parameters = mock(Params.class);
    RMSite site = new RMSite();
    site.setTitle("New Title");
    site.setDescription("New Description");
    try {
        rmSiteEntityResource.update(siteId, site, parameters);
        fail("Expected ecxeption as siteId was different than rm");
    } catch (InvalidParameterException ex) {
        assertEquals("The Update is supported only for siteId = rm.", ex.getMessage());
    }
    verify(mockedRMSites, never()).updateRMSite(any(String.class), any(SiteUpdate.class), any(Parameters.class));
}
Also used : InvalidParameterException(java.security.InvalidParameterException) RMSite(org.alfresco.rm.rest.api.model.RMSite) Parameters(org.alfresco.rest.framework.resource.parameters.Parameters) SiteUpdate(org.alfresco.rest.api.model.SiteUpdate) Params(org.alfresco.rest.framework.resource.parameters.Params) BaseUnitTest(org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest) Test(org.junit.Test)

Example 5 with RMSite

use of org.alfresco.rm.rest.api.model.RMSite in project records-management by Alfresco.

the class RMSiteEntityResourceUnitTest method create.

@Test
public void create() throws Exception {
    RMSite rmSite = new RMSite();
    rmSite.setTitle(RM_SITE_TITLE);
    rmSite.setId(RM_SITE_ID);
    rmSite.setDescription(RM_SITE_DESCRIPTION);
    rmSite.setCompliance(RMSiteCompliance.STANDARD);
    List<RMSite> entity = new ArrayList<RMSite>();
    Params parameters = mock(Params.class);
    entity.add(rmSite);
    when(mockedRMSites.createRMSite(rmSite, parameters)).thenReturn(rmSite);
    List<RMSite> createdRMSites = rmSiteEntityResource.create(entity, parameters);
    verify(mockedRMSites, times(1)).createRMSite(rmSite, parameters);
    assertEquals("Created sites size should be 1.", 1, createdRMSites.size());
    assertNotNull(createdRMSites.get(0));
    assertEquals(rmSite, createdRMSites.get(0));
}
Also used : RMSite(org.alfresco.rm.rest.api.model.RMSite) ArrayList(java.util.ArrayList) Params(org.alfresco.rest.framework.resource.parameters.Params) BaseUnitTest(org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest) Test(org.junit.Test)

Aggregations

RMSite (org.alfresco.rm.rest.api.model.RMSite)17 BaseUnitTest (org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest)13 Test (org.junit.Test)13 Parameters (org.alfresco.rest.framework.resource.parameters.Parameters)11 SiteUpdate (org.alfresco.rest.api.model.SiteUpdate)8 Params (org.alfresco.rest.framework.resource.parameters.Params)8 SiteInfo (org.alfresco.service.cmr.site.SiteInfo)7 InvalidArgumentException (org.alfresco.rest.framework.core.exceptions.InvalidArgumentException)5 NodeRef (org.alfresco.service.cmr.repository.NodeRef)5 SiteVisibility (org.alfresco.service.cmr.site.SiteVisibility)4 SiteImportPackageHandler (org.alfresco.rest.api.impl.SiteImportPackageHandler)3 Site (org.alfresco.rest.api.model.Site)3 RMSiteCompliance (org.alfresco.rm.rest.api.model.RMSiteCompliance)3 ImporterBinding (org.alfresco.service.cmr.view.ImporterBinding)3 Location (org.alfresco.service.cmr.view.Location)3 QName (org.alfresco.service.namespace.QName)3 InvalidParameterException (java.security.InvalidParameterException)1 ArrayList (java.util.ArrayList)1 ActivityInfo (org.alfresco.service.cmr.activities.ActivityInfo)1