mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
RM-4199: finalised unit tests for RMSiteEntityResource started on unit
tests for RMSitesImpl, made some minor fixes
This commit is contained in:
@@ -62,7 +62,7 @@ public class RMSite extends Site
|
|||||||
this.title = site.getTitle();
|
this.title = site.getTitle();
|
||||||
this.description = site.getDescription();
|
this.description = site.getDescription();
|
||||||
this.visibility = site.getVisibility();
|
this.visibility = site.getVisibility();
|
||||||
this.role = getRole();
|
this.role = site.getRole();
|
||||||
this.compliance = compliance;
|
this.compliance = compliance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -38,7 +38,6 @@ import org.alfresco.rest.framework.resource.parameters.Parameters;
|
|||||||
import org.alfresco.rm.rest.api.RMSites;
|
import org.alfresco.rm.rest.api.RMSites;
|
||||||
import org.alfresco.rm.rest.api.model.RMSite;
|
import org.alfresco.rm.rest.api.model.RMSite;
|
||||||
import org.alfresco.rm.rest.api.model.SiteUpdate;
|
import org.alfresco.rm.rest.api.model.SiteUpdate;
|
||||||
import org.alfresco.service.cmr.site.SiteVisibility;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RM Site operations
|
* RM Site operations
|
||||||
@@ -120,7 +119,7 @@ public class RMSiteEntityResource implements EntityResourceAction.Delete, Entity
|
|||||||
// Bind valid fields to a SiteUpdate instance.
|
// Bind valid fields to a SiteUpdate instance.
|
||||||
final String title = site.getTitle();
|
final String title = site.getTitle();
|
||||||
final String description = site.getDescription();
|
final String description = site.getDescription();
|
||||||
SiteUpdate update = new SiteUpdate(title, description, SiteVisibility.PUBLIC);
|
SiteUpdate update = new SiteUpdate(title, description, null);
|
||||||
|
|
||||||
return sites.updateRMSite(siteId, update, parameters);
|
return sites.updateRMSite(siteId, update, parameters);
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,177 @@
|
|||||||
|
/*
|
||||||
|
* #%L
|
||||||
|
* Alfresco Records Management Module
|
||||||
|
* %%
|
||||||
|
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
||||||
|
* %%
|
||||||
|
* This file is part of the Alfresco software.
|
||||||
|
* -
|
||||||
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
|
* the paid license agreement will prevail. Otherwise, the software is
|
||||||
|
* provided under the following open source license terms:
|
||||||
|
* -
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
* -
|
||||||
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
* -
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
* #L%
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.alfresco.rm.rest.api.impl;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.mockito.Mockito.any;
|
||||||
|
import static org.mockito.Mockito.eq;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.never;
|
||||||
|
import static org.mockito.Mockito.times;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.test.util.AlfMock;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest;
|
||||||
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
|
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||||
|
import org.alfresco.rm.rest.api.model.RMSite;
|
||||||
|
import org.alfresco.rm.rest.api.model.RMSiteCompliance;
|
||||||
|
import org.alfresco.rm.rest.api.model.SiteUpdate;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.alfresco.service.cmr.site.SiteInfo;
|
||||||
|
import org.alfresco.service.cmr.site.SiteService;
|
||||||
|
import org.alfresco.service.cmr.site.SiteVisibility;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.mockito.ArgumentCaptor;
|
||||||
|
import org.mockito.InjectMocks;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.MockitoAnnotations;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unit Test class for RMSitesImpl.
|
||||||
|
*
|
||||||
|
* @author Silviu Dinuta
|
||||||
|
* @since 2.6
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class RMSitesImplUnitTest extends BaseUnitTest
|
||||||
|
{
|
||||||
|
private static final String RM_SITE_TITLE_AFTER_UPDATE = "Updated Title";
|
||||||
|
private static final String RM_SITE_DESCRIPTION_AFTER_UPDATE = "Updated Description";
|
||||||
|
private static final String RM_SITE_ID = "rm";
|
||||||
|
private static final String RM_SITE_MANAGER_ROLE = "SiteManager";
|
||||||
|
private static final String RM_SITE_TITLE = "RM Site Title";
|
||||||
|
private static final String RM_SITE_DESCRIPTION = "RM Site Description";
|
||||||
|
@InjectMocks
|
||||||
|
private RMSitesImpl rmSitesImpl;
|
||||||
|
@Mock
|
||||||
|
private SiteService mockedSiteService;
|
||||||
|
@Mock
|
||||||
|
AuthenticationUtil mockAuthenticationUtil;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void before()
|
||||||
|
{
|
||||||
|
MockitoAnnotations.initMocks(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void createRMSite() throws Exception
|
||||||
|
{
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateRMSite() 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)
|
||||||
|
.thenReturn(RM_SITE_DESCRIPTION_AFTER_UPDATE);
|
||||||
|
when(mockedSiteInfo.getTitle()).thenReturn(RM_SITE_TITLE)
|
||||||
|
.thenReturn(RM_SITE_TITLE_AFTER_UPDATE);
|
||||||
|
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);
|
||||||
|
|
||||||
|
SiteUpdate mockedSiteUpdate= mock(SiteUpdate.class);
|
||||||
|
when(mockedSiteUpdate.getDescription()).thenReturn(RM_SITE_DESCRIPTION_AFTER_UPDATE);
|
||||||
|
when(mockedSiteUpdate.getTitle()).thenReturn(RM_SITE_TITLE_AFTER_UPDATE);
|
||||||
|
when(mockedSiteUpdate.getVisibility()).thenReturn(null);
|
||||||
|
|
||||||
|
Parameters mockedParameters = mock(Parameters.class);
|
||||||
|
RMSite updatedRMSite = rmSitesImpl.updateRMSite(siteId, mockedSiteUpdate, mockedParameters);
|
||||||
|
|
||||||
|
ArgumentCaptor<String> titleCaptor = ArgumentCaptor.forClass(String.class);
|
||||||
|
verify(mockedSiteInfo, times(1)).setTitle(titleCaptor.capture());
|
||||||
|
ArgumentCaptor<String> descriptionCaptor = ArgumentCaptor.forClass(String.class);
|
||||||
|
verify(mockedSiteInfo, times(1)).setDescription(descriptionCaptor.capture());
|
||||||
|
verify(mockedSiteInfo, never()).setVisibility(any(SiteVisibility.class));
|
||||||
|
|
||||||
|
verify(mockedSiteService, times(1)).updateSite(any(SiteInfo.class));
|
||||||
|
|
||||||
|
assertEquals(RM_SITE_TITLE_AFTER_UPDATE, titleCaptor.getValue());
|
||||||
|
assertEquals(RM_SITE_DESCRIPTION_AFTER_UPDATE, descriptionCaptor.getValue());
|
||||||
|
|
||||||
|
assertEquals(RMSiteCompliance.STANDARD, updatedRMSite.getCompliance());
|
||||||
|
assertEquals(RM_SITE_MANAGER_ROLE, updatedRMSite.getRole());
|
||||||
|
assertEquals(siteId, updatedRMSite.getId());
|
||||||
|
assertEquals(siteNodeRef.getId(), updatedRMSite.getGuid());
|
||||||
|
assertEquals(RM_SITE_DESCRIPTION_AFTER_UPDATE, updatedRMSite.getDescription());
|
||||||
|
assertEquals(RM_SITE_TITLE_AFTER_UPDATE, updatedRMSite.getTitle());
|
||||||
|
assertEquals(SiteVisibility.PUBLIC, updatedRMSite.getVisibility());
|
||||||
|
}
|
||||||
|
|
||||||
|
@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());
|
||||||
|
}
|
||||||
|
}
|
@@ -29,20 +29,30 @@ package org.alfresco.rm.rest.api.sites;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
|
import java.security.InvalidParameterException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest;
|
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest;
|
||||||
|
import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
|
||||||
|
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||||
import org.alfresco.rest.framework.resource.parameters.Params;
|
import org.alfresco.rest.framework.resource.parameters.Params;
|
||||||
import org.alfresco.rm.rest.api.RMSites;
|
import org.alfresco.rm.rest.api.RMSites;
|
||||||
import org.alfresco.rm.rest.api.model.RMSite;
|
import org.alfresco.rm.rest.api.model.RMSite;
|
||||||
import org.alfresco.rm.rest.api.model.RMSiteCompliance;
|
import org.alfresco.rm.rest.api.model.RMSiteCompliance;
|
||||||
|
import org.alfresco.rm.rest.api.model.SiteUpdate;
|
||||||
|
import org.alfresco.service.cmr.site.SiteVisibility;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.mockito.InjectMocks;
|
import org.mockito.InjectMocks;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
|
|
||||||
|
import static org.mockito.Matchers.any;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.never;
|
||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
@@ -55,6 +65,16 @@ import static org.mockito.Mockito.when;
|
|||||||
*/
|
*/
|
||||||
public class RMSiteEntityResourceUnitTest extends BaseUnitTest
|
public class RMSiteEntityResourceUnitTest extends BaseUnitTest
|
||||||
{
|
{
|
||||||
|
private static final String NON_RM_SITE_ID = "not_rm";
|
||||||
|
|
||||||
|
private static final String PERMANENT_PARAMETER = "permanent";
|
||||||
|
|
||||||
|
private static final String RM_SITE_ID = "rm";
|
||||||
|
|
||||||
|
private static final String RM_SITE_DESCRIPTION = "RM Site Description";
|
||||||
|
|
||||||
|
private static final String RM_SITE_TITLE = "RM Site Title";
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private RMSites mockedRMSites;
|
private RMSites mockedRMSites;
|
||||||
|
|
||||||
@@ -70,46 +90,231 @@ public class RMSiteEntityResourceUnitTest extends BaseUnitTest
|
|||||||
@Test
|
@Test
|
||||||
public void create() throws Exception
|
public void create() throws Exception
|
||||||
{
|
{
|
||||||
RMSite rmSite = createRMSite();
|
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>();
|
List<RMSite> entity = new ArrayList<RMSite>();
|
||||||
Params parameters = Params.valueOf(null, null, null, rmSite, null);
|
Params parameters = mock(Params.class);
|
||||||
entity.add(rmSite);
|
entity.add(rmSite);
|
||||||
when(mockedRMSites.createRMSite(rmSite, parameters)).thenReturn(rmSite);
|
when(mockedRMSites.createRMSite(rmSite, parameters)).thenReturn(rmSite);
|
||||||
List<RMSite> createdRMSites = rmSiteEntityResource.create(entity, parameters);
|
List<RMSite> createdRMSites = rmSiteEntityResource.create(entity, parameters);
|
||||||
|
|
||||||
|
verify(mockedRMSites, times(1)).createRMSite(rmSite, parameters);
|
||||||
|
|
||||||
assertEquals("Created sites size should be 1.", 1, createdRMSites.size());
|
assertEquals("Created sites size should be 1.", 1, createdRMSites.size());
|
||||||
assertNotNull(createdRMSites.get(0));
|
assertNotNull(createdRMSites.get(0));
|
||||||
assertEquals(rmSite, createdRMSites.get(0));
|
assertEquals(rmSite, createdRMSites.get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void delete() throws Exception
|
public void happyPathDelete() throws Exception
|
||||||
{
|
{
|
||||||
String siteId = "rm";
|
String siteId = RM_SITE_ID;
|
||||||
Params parameters = Params.valueOf(siteId, null, null, null, null);
|
Params parameters = mock(Params.class);
|
||||||
|
when(parameters.getParameter(PERMANENT_PARAMETER)).thenReturn(null);
|
||||||
rmSiteEntityResource.delete(siteId, parameters);
|
rmSiteEntityResource.delete(siteId, parameters);
|
||||||
verify(mockedRMSites, times(1)).deleteSite(siteId, parameters);
|
verify(mockedRMSites, times(1)).deleteSite(siteId, parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void get() throws Exception
|
public void deleteNonRMSite() throws Exception
|
||||||
{
|
{
|
||||||
|
String siteId = NON_RM_SITE_ID;
|
||||||
|
Params parameters = mock(Params.class);
|
||||||
|
when(parameters.getParameter(PERMANENT_PARAMETER)).thenReturn(null);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
rmSiteEntityResource.delete(siteId, parameters);
|
||||||
|
fail("Expected ecxeption as siteId was different than rm");
|
||||||
|
}
|
||||||
|
catch(InvalidParameterException ex)
|
||||||
|
{
|
||||||
|
assertEquals("The Deletion is supported only for siteId = rm.", ex.getMessage());
|
||||||
|
}
|
||||||
|
verify(mockedRMSites, never()).deleteSite(siteId, parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void update() throws Exception
|
public void deleteRMSiteWithPermanentParam() throws Exception
|
||||||
{
|
{
|
||||||
|
String siteId = RM_SITE_ID;
|
||||||
|
Params parameters = mock(Params.class);
|
||||||
|
when(parameters.getParameter(PERMANENT_PARAMETER)).thenReturn("true");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
rmSiteEntityResource.delete(siteId, parameters);
|
||||||
|
fail("Expected ecxeption as parameter permanent was present in the request.");
|
||||||
|
}
|
||||||
|
catch(InvalidArgumentException ex)
|
||||||
|
{
|
||||||
|
assertEquals("DELETE does not support parameter: permanent", ex.getMsgId());
|
||||||
|
}
|
||||||
|
verify(mockedRMSites, never()).deleteSite(siteId, parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
private RMSite createRMSite()
|
@Test
|
||||||
|
public void happyPathGet() throws Exception
|
||||||
{
|
{
|
||||||
RMSite rmSite = new RMSite();
|
String siteId = RM_SITE_ID;
|
||||||
|
Params parameters = mock(Params.class);
|
||||||
|
rmSiteEntityResource.readById(siteId, parameters);
|
||||||
|
verify(mockedRMSites, times(1)).getRMSite(siteId);
|
||||||
|
}
|
||||||
|
|
||||||
rmSite.setTitle("RM Site Title");
|
@Test
|
||||||
rmSite.setId("rm");
|
public void getNonRMSite() throws Exception
|
||||||
rmSite.setDescription("RM Site Description");
|
{
|
||||||
rmSite.setCompliance(RMSiteCompliance.STANDARD);
|
String siteId = NON_RM_SITE_ID;
|
||||||
return rmSite;
|
Params parameters = mock(Params.class);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
rmSiteEntityResource.readById(siteId, parameters);
|
||||||
|
fail("Expected ecxeption as siteId was different than rm");
|
||||||
|
}
|
||||||
|
catch(InvalidParameterException ex)
|
||||||
|
{
|
||||||
|
assertEquals("GET is supported only for siteId = rm.", ex.getMessage());
|
||||||
|
}
|
||||||
|
verify(mockedRMSites, never()).getRMSite(siteId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@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));
|
||||||
|
}
|
||||||
|
|
||||||
|
@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));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateRMSiteId() 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.setId("newSiteID");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
rmSiteEntityResource.update(siteId, site, parameters);
|
||||||
|
fail("Expected ecxeption as rm site id cannot be changed.");
|
||||||
|
}
|
||||||
|
catch(InvalidArgumentException ex)
|
||||||
|
{
|
||||||
|
assertEquals("Site update does not support field: id", ex.getMsgId());
|
||||||
|
}
|
||||||
|
verify(mockedRMSites, never()).updateRMSite(any(String.class), any(SiteUpdate.class), any(Parameters.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@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));
|
||||||
|
}
|
||||||
|
|
||||||
|
@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));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateRMSiteCompliance() 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.setCompliance(RMSiteCompliance.STANDARD);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
rmSiteEntityResource.update(siteId, site, parameters);
|
||||||
|
fail("Expected ecxeption as rm site compliance cannot be changed.");
|
||||||
|
}
|
||||||
|
catch(InvalidArgumentException ex)
|
||||||
|
{
|
||||||
|
assertEquals("Site update does not support field: compliance", ex.getMsgId());
|
||||||
|
}
|
||||||
|
verify(mockedRMSites, never()).updateRMSite(any(String.class), any(SiteUpdate.class), any(Parameters.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateRMSiteVisibility() 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.setVisibility(SiteVisibility.PRIVATE);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
rmSiteEntityResource.update(siteId, site, parameters);
|
||||||
|
fail("Expected ecxeption as rm site visibility cannot be changed.");
|
||||||
|
}
|
||||||
|
catch(InvalidArgumentException ex)
|
||||||
|
{
|
||||||
|
assertEquals("Site update does not support field: visibility", ex.getMsgId());
|
||||||
|
}
|
||||||
|
verify(mockedRMSites, never()).updateRMSite(any(String.class), any(SiteUpdate.class), any(Parameters.class));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user