use of org.alfresco.rest.framework.resource.parameters.Parameters 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));
}
use of org.alfresco.rest.framework.resource.parameters.Parameters 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));
}
use of org.alfresco.rest.framework.resource.parameters.Parameters 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));
}
use of org.alfresco.rest.framework.resource.parameters.Parameters in project records-management by Alfresco.
the class RMSiteEntityResourceUnitTest method updateRMSiteGuid.
@Test
public void updateRMSiteGuid() throws Exception {
String siteId = RM_SITE_ID;
Params parameters = mock(Params.class);
RMSite site = new RMSite();
site.setTitle("New Title");
site.setDescription("New Description");
site.setGuid("newGUID");
try {
rmSiteEntityResource.update(siteId, site, parameters);
fail("Expected ecxeption as rm site guid cannot be changed.");
} catch (InvalidArgumentException ex) {
assertEquals("Site update does not support field: guid", ex.getMsgId());
}
verify(mockedRMSites, never()).updateRMSite(any(String.class), any(SiteUpdate.class), any(Parameters.class));
}
use of org.alfresco.rest.framework.resource.parameters.Parameters in project records-management by Alfresco.
the class RMSiteEntityResourceUnitTest method updateRMSiteRole.
@Test
public void updateRMSiteRole() throws Exception {
String siteId = RM_SITE_ID;
Params parameters = mock(Params.class);
RMSite site = new RMSite();
site.setTitle("New Title");
site.setDescription("New Description");
site.setRole("newRole");
try {
rmSiteEntityResource.update(siteId, site, parameters);
fail("Expected ecxeption as rm site role cannot be changed.");
} catch (InvalidArgumentException ex) {
assertEquals("Site update does not support field: role", ex.getMsgId());
}
verify(mockedRMSites, never()).updateRMSite(any(String.class), any(SiteUpdate.class), any(Parameters.class));
}
Aggregations