2 * This document is a part of the source code and related artifacts
3 * for CollectionSpace, an open source collections management system
4 * for museums and related institutions:
6 * http://www.collectionspace.org
7 * http://wiki.collectionspace.org
9 * Copyright © 2009 Regents of the University of California
11 * Licensed under the Educational Community License (ECL), Version 2.0.
12 * You may not use this file except in compliance with this License.
14 * You may obtain a copy of the ECL 2.0 License at
15 * https://source.collectionspace.org/collection-space/LICENSE.txt
17 * Unless required by applicable law or agreed to in writing, software
18 * distributed under the License is distributed on an "AS IS" BASIS,
19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 * See the License for the specific language governing permissions and
21 * limitations under the License.
23 package org.collectionspace.services.authorization.client.test;
25 //import java.util.ArrayList;
26 //import java.util.List;
27 import javax.ws.rs.core.Response;
29 import org.collectionspace.services.client.CollectionSpaceClient;
30 import org.collectionspace.services.client.RoleClient;
31 import org.collectionspace.services.authorization.Role;
32 import org.collectionspace.services.authorization.RolesList;
33 import org.collectionspace.services.client.RoleFactory;
34 import org.collectionspace.services.client.test.AbstractServiceTestImpl;
35 import org.jboss.resteasy.client.ClientResponse;
37 import org.testng.Assert;
38 import org.testng.annotations.Test;
40 import org.slf4j.Logger;
41 import org.slf4j.LoggerFactory;
44 * RoleServiceTest, carries out tests against a
45 * deployed and running Role Service.
47 * $LastChangedRevision: 917 $
48 * $LastChangedDate: 2009-11-06 12:20:28 -0800 (Fri, 06 Nov 2009) $
50 public class RoleServiceTest extends AbstractServiceTestImpl<RolesList, Role, Role, Role> {
53 private final static String CLASS_NAME = RoleServiceTest.class.getName();
54 private final static Logger logger = LoggerFactory.getLogger(CLASS_NAME);
56 // Instance variables specific to this test.
57 /** The known resource id. */
58 private String knownRoleName = "ROLE_USERS_MOCK-1";
59 private String knownRoleDisplayName = "ROLE_DISPLAYNAME_USERS_MOCK-1";
60 private String verifyResourceId = null;
61 private String verifyRoleName = "collections_manager_mock-1";
62 // private List<String> allResourceIdsCreated = new ArrayList<String>();
65 public String getServiceName() {
66 return RoleClient.SERVICE_NAME;
70 protected String getServicePathComponent() {
71 return new RoleClient().getServicePathComponent();
75 * The entity type expected from the JAX-RS Response object
77 public Class<Role> getEntityResponseType() {
82 * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
85 protected CollectionSpaceClient getClientInstance() {
86 return new RoleClient();
90 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readPaginatedList(java.lang.String)
93 public void readPaginatedList(String testName) throws Exception {
94 //FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
97 // ---------------------------------------------------------------
98 // CRUD tests : CREATE tests
99 // ---------------------------------------------------------------
103 public void create(String testName) throws Exception {
104 // Perform setup, such as initializing the type of service request
105 // (e.g. CREATE, DELETE), its valid and expected status codes, and
106 // its associated HTTP method name (e.g. POST, DELETE).
109 // Submit the request to the service and store the response.
110 RoleClient client = new RoleClient();
111 Role role = createRoleInstance(knownRoleName, "All users are required to be in this role",
113 ClientResponse<Response> res = client.create(role);
115 int statusCode = res.getStatus();
116 // Check the status code of the response: does it match
117 // the expected response(s)?
120 // Does it fall within the set of valid status codes?
121 // Does it exactly match the expected status code?
122 if (logger.isDebugEnabled()) {
123 logger.debug(testName + ": status = " + statusCode);
125 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
126 invalidStatusCodeMessage(testRequestType, statusCode));
127 Assert.assertEquals(statusCode, testExpectedStatusCode);
129 // Store the ID returned from this create operation
130 // for additional tests below.
131 knownResourceId = extractId(res);
132 //allResourceIdsCreated.add(knownResourceId);
133 if (logger.isDebugEnabled()) {
134 logger.debug(testName + ": knownResourceId=" + knownResourceId);
141 @Test(dataProvider = "testName",
142 dependsOnMethods = {"CRUDTests"})
143 public void createWithDisplayname(String testName) throws Exception {
144 // Perform setup, such as initializing the type of service request
145 // (e.g. CREATE, DELETE), its valid and expected status codes, and
146 // its associated HTTP method name (e.g. POST, DELETE).
149 // Submit the request to the service and store the response.
150 RoleClient client = new RoleClient();
151 Role role = createRoleInstance(knownRoleName + "_" + knownRoleDisplayName,
152 "all users are required to be in this role",
154 role.setDisplayName(knownRoleDisplayName);
155 ClientResponse<Response> res = client.create(role);
156 int statusCode = res.getStatus();
158 // Check the status code of the response: does it match
159 // the expected response(s)?
162 // Does it fall within the set of valid status codes?
163 // Does it exactly match the expected status code?
164 if (logger.isDebugEnabled()) {
165 logger.debug(testName + ": status = " + statusCode);
167 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
168 invalidStatusCodeMessage(testRequestType, statusCode));
169 Assert.assertEquals(statusCode, testExpectedStatusCode);
171 // Store the ID returned from this create operation
172 // for additional tests below.
173 String csid = extractId(res);
174 allResourceIdsCreated.add(csid);
175 if (logger.isDebugEnabled()) {
176 logger.debug(testName + ": csid=" + csid);
182 * Creates the for unique role.
184 * @param testName the test name
185 * @throws Exception the exception
187 @Test(dataProvider = "testName",
188 dependsOnMethods = {"CRUDTests"})
189 public void createForUniqueRole(String testName) throws Exception {
192 // Submit the request to the service and store the response.
193 RoleClient client = new RoleClient();
194 Role role = createRoleInstance(knownRoleName,
197 ClientResponse<Response> res = client.create(role);
198 int statusCode = res.getStatus();
200 if (logger.isDebugEnabled()) {
201 logger.debug(testName + ": Role with name \"" +
202 knownRoleName + "\" should already exist, so this request should fail.");
203 logger.debug(testName + ": status = " + statusCode);
204 logger.debug(testName + ": " + res);
206 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
207 invalidStatusCodeMessage(testRequestType, statusCode));
208 Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
212 * Creates the for unique display name of role.
214 * @param testName the test name
215 * @throws Exception the exception
217 @Test(dataProvider = "testName",
218 dependsOnMethods = {"createWithDisplayname"})
219 public void createForUniqueDisplayRole(String testName) throws Exception {
222 // Submit the request to the service and store the response.
223 RoleClient client = new RoleClient();
224 Role role = createRoleInstance(knownRoleName + System.currentTimeMillis(),
225 "role users with non-unique display name",
227 role.setDisplayName(knownRoleDisplayName);
228 ClientResponse<Response> res = client.create(role);
229 int statusCode = res.getStatus();
231 if (logger.isDebugEnabled()) {
232 logger.debug(testName + ": Role with name \"" +
233 knownRoleName + "\" should already exist, so this request should fail.");
234 logger.debug(testName + ": status = " + statusCode);
235 logger.debug(testName + ": " + res);
237 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
238 invalidStatusCodeMessage(testRequestType, statusCode));
239 if (statusCode != Response.Status.BAD_REQUEST.getStatusCode()) {
240 // If the test fails then we've just created a Role that we need to delete, so
241 // store the ID returned from this create operation.
242 String csid = extractId(res);
243 allResourceIdsCreated.add(csid);
244 if (logger.isDebugEnabled()) {
245 logger.debug(testName + ": csid=" + csid);
247 Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
252 * Creates the without role name.
254 * @param testName the test name
255 * @throws Exception the exception
257 @Test(dataProvider = "testName",
258 dependsOnMethods = {"CRUDTests"})
259 public void createWithoutRoleName(String testName) throws Exception {
262 // Submit the request to the service and store the response.
263 RoleClient client = new RoleClient();
264 Role role = createRoleInstance("",
267 ClientResponse<Response> res = client.create(role);
268 int statusCode = res.getStatus();
269 // Does it exactly match the expected status code?
270 if (logger.isDebugEnabled()) {
271 logger.debug(testName + ": status = " + statusCode);
273 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
274 invalidStatusCodeMessage(testRequestType, statusCode));
275 Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
278 //to not cause uniqueness violation for role, createList is removed
280 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
283 // @Test(dataProvider = "testName",
284 // dependsOnMethods = {"createWithDisplayname"})
285 public void createList(String testName) throws Exception {
288 // Submit the request to the service and store the response.
289 RoleClient client = new RoleClient();
290 //create a role with lowercase role name without role prefix
291 //the service should make it upper case and add the role prefix
292 Role role1 = createRoleInstance(verifyRoleName,
293 "collection manager",
295 ClientResponse<Response> res = client.create(role1);
296 int statusCode = res.getStatus();
297 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
298 invalidStatusCodeMessage(testRequestType, statusCode));
299 Assert.assertEquals(statusCode, testExpectedStatusCode);
300 verifyResourceId = extractId(res);
301 allResourceIdsCreated.add(verifyResourceId);
303 Role role2 = createRoleInstance("ROLE_COLLECTIONS_CURATOR_TEST",
304 "collections curator",
306 res = client.create(role2);
307 statusCode = res.getStatus();
308 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
309 invalidStatusCodeMessage(testRequestType, statusCode));
310 Assert.assertEquals(statusCode, testExpectedStatusCode);
311 Assert.assertEquals(statusCode, testExpectedStatusCode);
312 allResourceIdsCreated.add(extractId(res));
314 Role role3 = createRoleInstance("ROLE_MOVINGIMAGE_ADMIN_TEST",
315 "moving image admin",
317 res = client.create(role3);
318 statusCode = res.getStatus();
319 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
320 invalidStatusCodeMessage(testRequestType, statusCode));
321 Assert.assertEquals(statusCode, testExpectedStatusCode);
322 Assert.assertEquals(statusCode, testExpectedStatusCode);
323 allResourceIdsCreated.add(extractId(res));
327 // Placeholders until the three tests below can be uncommented.
328 // See Issue CSPACE-401.
330 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
333 public void createWithEmptyEntityBody(String testName) throws Exception {
334 //FIXME: Should this test really be empty? If so, please comment accordingly.
338 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
341 public void createWithMalformedXml(String testName) throws Exception {
342 //FIXME: Should this test really be empty? If so, please comment accordingly.
346 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
349 public void createWithWrongXmlSchema(String testName) throws Exception {
350 //FIXME: Should this test really be empty? If so, please comment accordingly.
353 // ---------------------------------------------------------------
354 // CRUD tests : READ tests
355 // ---------------------------------------------------------------
358 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
361 // @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
362 // dependsOnMethods = {"createForUniqueRole"})
363 public void read(String testName) throws Exception {
367 // Submit the request to the service and store the response.
368 RoleClient client = new RoleClient();
369 ClientResponse<Role> res = client.read(knownResourceId);
370 int statusCode = res.getStatus();
372 // Check the status code of the response: does it match
373 // the expected response(s)?
374 if (logger.isDebugEnabled()) {
375 logger.debug(testName + ": status = " + statusCode);
377 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
378 invalidStatusCodeMessage(testRequestType, statusCode));
379 Assert.assertEquals(statusCode, testExpectedStatusCode);
381 Role output = (Role) res.getEntity();
382 Assert.assertNotNull(output);
385 @Test(dataProvider = "testName",
386 dependsOnMethods = {"CRUDTests"})
387 public void readToVerify(String testName) throws Exception {
391 // Submit the request to the service and store the response.
392 RoleClient client = new RoleClient();
393 ClientResponse<Role> res = client.read(verifyResourceId);
395 int statusCode = res.getStatus();
397 // Check the status code of the response: does it match
398 // the expected response(s)?
399 if (logger.isDebugEnabled()) {
400 logger.debug(testName + ": status = " + statusCode);
402 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
403 invalidStatusCodeMessage(testRequestType, statusCode));
404 Assert.assertEquals(statusCode, testExpectedStatusCode);
406 Role output = (Role) res.getEntity();
407 Assert.assertNotNull(output);
409 //FIXME: Tenant ID of "1" should not be hard coded
410 String roleNameToVerify = "ROLE_" +
412 verifyRoleName.toUpperCase();
413 Assert.assertEquals(output.getRoleName(), roleNameToVerify,
414 "RoleName fix did not work!");
421 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
425 // @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
426 // dependsOnMethods = {"read"})
427 public void readNonExistent(String testName) throws Exception {
429 setupReadNonExistent();
431 // Submit the request to the service and store the response.
432 RoleClient client = new RoleClient();
433 ClientResponse<Role> res = client.read(NON_EXISTENT_ID);
435 int statusCode = res.getStatus();
436 // Check the status code of the response: does it match
437 // the expected response(s)?
438 if (logger.isDebugEnabled()) {
439 logger.debug(testName + ": status = " + statusCode);
441 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
442 invalidStatusCodeMessage(testRequestType, statusCode));
443 Assert.assertEquals(statusCode, testExpectedStatusCode);
449 // ---------------------------------------------------------------
450 // CRUD tests : READ_LIST tests
451 // ---------------------------------------------------------------
454 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
457 // @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
458 // dependsOnMethods = {"createList", "read"})
459 public void readList(String testName) throws Exception {
463 // Submit the request to the service and store the response.
464 RoleClient client = new RoleClient();
465 ClientResponse<RolesList> res = client.readList();
467 // Check the status code of the response: does it match
468 // the expected response(s)?
469 assertStatusCode(res, testName);
470 RolesList list = res.getEntity();
471 // Optionally output additional data about list members for debugging.
472 boolean iterateThroughList = true;
473 if (iterateThroughList && logger.isDebugEnabled()) {
474 printList(testName, list);
486 * @param testName the test name
487 * @throws Exception the exception
489 @Test(dataProvider = "testName",
490 dependsOnMethods = {"CRUDTests"})
491 public void searchRoleName(String testName) throws Exception {
495 // Submit the request to the service and store the response.
496 RoleClient client = new RoleClient();
497 ClientResponse<RolesList> res = client.readSearchList("movingImage");
499 assertStatusCode(res, testName);
500 RolesList list = res.getEntity();
501 int EXPECTED_ITEMS = 1;
502 if (logger.isDebugEnabled()) {
503 logger.debug(testName + ": received = " + list.getRole().size()
504 + " expected=" + EXPECTED_ITEMS);
506 Assert.assertEquals(EXPECTED_ITEMS, list.getRole().size());
507 // Optionally output additional data about list members for debugging.
508 boolean iterateThroughList = true;
509 if (iterateThroughList && logger.isDebugEnabled()) {
510 printList(testName, list);
521 // ---------------------------------------------------------------
522 // CRUD tests : UPDATE tests
523 // ---------------------------------------------------------------
526 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
529 // @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
530 // dependsOnMethods = {"read", "readList", "readNonExistent"})
531 public void update(String testName) throws Exception {
535 Role roleToUpdate = new Role();
536 roleToUpdate.setCsid(knownResourceId);
537 roleToUpdate.setRoleName(knownRoleName);
538 roleToUpdate.setDisplayName(knownRoleName);
540 // Update the content of this resource.
541 roleToUpdate.setDescription("updated role description");
542 if (logger.isDebugEnabled()) {
543 logger.debug("updated object");
544 org.collectionspace.services.authorization.ObjectFactory objectFactory = new org.collectionspace.services.authorization.ObjectFactory();
545 logger.debug(objectAsXmlString(objectFactory.createRole(roleToUpdate),
548 RoleClient client = new RoleClient();
549 // Submit the request to the service and store the response.
550 ClientResponse<Role> res = client.update(knownResourceId, roleToUpdate);
552 // Check the status code of the response: does it match the expected response(s)?
553 int statusCode = res.getStatus();
554 if (logger.isDebugEnabled()) {
555 logger.debug(testName + ": status = " + statusCode);
557 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
558 invalidStatusCodeMessage(testRequestType, statusCode));
559 Assert.assertEquals(statusCode, testExpectedStatusCode);
562 Role roleUpdated = (Role) res.getEntity();
563 Assert.assertNotNull(roleUpdated);
565 Assert.assertEquals(roleUpdated.getDescription(),
566 roleToUpdate.getDescription(),
567 "Data in updated object did not match submitted data.");
573 @Test(dataProvider = "testName",
574 dependsOnMethods = {"CRUDTests"})
575 public void verifyProtectionReadOnly(String testName) throws Exception {
576 // Setup to create a new role
578 Role role = createRoleInstance(knownRoleName+"_PT", "Just a temp", true);
579 role.setMetadataProtection(RoleClient.IMMUTABLE);
580 role.setPermsProtection(RoleClient.IMMUTABLE);
582 // Submit the create request to the service and store the response.
584 RoleClient client = new RoleClient();
585 ClientResponse<Response> res = client.create(role);
586 String testResourceId = null;
588 int statusCode = res.getStatus();
589 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
590 invalidStatusCodeMessage(testRequestType, statusCode));
591 Assert.assertEquals(statusCode, testExpectedStatusCode);
592 // Store the ID returned from this create operation
593 // for additional tests below.
594 testResourceId = extractId(res);
595 allResourceIdsCreated.add(testResourceId);
596 if (logger.isDebugEnabled()) {
597 logger.debug(testName + ": testResourceId=" + testResourceId);
603 // Next, read back the role we just created.
605 // Submit the request to the service and store the response.
606 ClientResponse<Role> roleRes = client.read(testResourceId);
608 int statusCode = roleRes.getStatus();
609 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
610 invalidStatusCodeMessage(testRequestType, statusCode));
611 Assert.assertEquals(statusCode, testExpectedStatusCode);
613 Role roleRead = (Role) roleRes.getEntity();
614 Assert.assertNotNull(roleRead);
615 String mdProtection = roleRead.getMetadataProtection();
616 String permsProtection = roleRead.getPermsProtection();
617 if (logger.isTraceEnabled()) {
618 logger.trace(testName + ": metadataProtection=" + mdProtection);
619 logger.trace(testName + ": permsProtection=" + permsProtection);
621 Assert.assertFalse(role.getMetadataProtection().equals(mdProtection),
622 "Role allowed create to set the metadata protection flag.");
623 Assert.assertFalse(role.getPermsProtection().equals(permsProtection),
624 "Role allowed create to set the perms protection flag.");
628 // Finally, update the role with changes and verify
631 Role roleToUpdate = createRoleInstance(knownRoleName+"_PT", "Just a temp", true);
632 roleToUpdate.setMetadataProtection(RoleClient.IMMUTABLE);
633 roleToUpdate.setPermsProtection(RoleClient.IMMUTABLE);
635 // Submit the request to the service and store the response.
636 roleRes = client.update(testResourceId, roleToUpdate);
638 // Check the status code of the response: does it match the expected response(s)?
639 int statusCode = roleRes.getStatus();
640 if (logger.isDebugEnabled()) {
641 logger.debug(testName + ": status = " + statusCode);
643 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
644 invalidStatusCodeMessage(testRequestType, statusCode));
645 Assert.assertEquals(statusCode, testExpectedStatusCode);
648 Role roleUpdated = (Role) roleRes.getEntity();
649 Assert.assertNotNull(roleUpdated);
650 if (logger.isDebugEnabled()) {
651 logger.debug(testName + "Updated role: ");
652 org.collectionspace.services.authorization.ObjectFactory objectFactory = new org.collectionspace.services.authorization.ObjectFactory();
653 logger.debug(objectAsXmlString(objectFactory.createRole(roleUpdated),
657 Assert.assertFalse(RoleClient.IMMUTABLE.equalsIgnoreCase(roleUpdated.getMetadataProtection()),
658 "Role allowed update of the metadata protection flag.");
659 Assert.assertFalse(RoleClient.IMMUTABLE.equalsIgnoreCase(roleUpdated.getPermsProtection()),
660 "Role allowed update of the perms protection flag.");
666 @Test(dataProvider = "testName",
667 dependsOnMethods = {"CRUDTests"})
668 public void updateNotAllowed(String testName) throws Exception {
673 Role roleToUpdate = new Role();
674 roleToUpdate.setCsid(knownResourceId);
675 // Update the content of this resource.
676 roleToUpdate.setRoleName("UPDATED-ROLE_USERS_TEST");
677 roleToUpdate.setDisplayName("UPDATED-ROLE_USERS_TEST");
678 if (logger.isDebugEnabled()) {
679 logger.debug("updated object");
680 org.collectionspace.services.authorization.ObjectFactory objectFactory = new org.collectionspace.services.authorization.ObjectFactory();
681 logger.debug(objectAsXmlString(objectFactory.createRole(roleToUpdate),
684 RoleClient client = new RoleClient();
685 // Submit the request to the service and store the response.
686 ClientResponse<Role> res = client.update(knownResourceId, roleToUpdate);
688 int statusCode = res.getStatus();
689 // Check the status code of the response: does it match the expected response(s)?
690 if (logger.isDebugEnabled()) {
691 logger.debug(testName + ": status = " + statusCode);
693 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
694 invalidStatusCodeMessage(testRequestType, statusCode));
695 Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
702 // Placeholders until the three tests below can be uncommented.
703 // See Issue CSPACE-401.
705 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
708 public void updateWithEmptyEntityBody(String testName) throws Exception {
709 //FIXME: Should this test really be empty? If so, please comment accordingly.
713 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
716 public void updateWithMalformedXml(String testName) throws Exception {
717 //FIXME: Should this test really be empty? If so, please comment accordingly.
721 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
724 public void updateWithWrongXmlSchema(String testName) throws Exception {
725 //FIXME: Should this test really be empty? If so, please comment accordingly.
729 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
733 // @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
734 // dependsOnMethods = {"readNonExistent", "testSubmitRequest"})
735 public void updateNonExistent(String testName) throws Exception {
737 setupUpdateNonExistent();
739 // Submit the request to the service and store the response.
741 // Note: The ID used in this 'create' call may be arbitrary.
742 // The only relevant ID may be the one used in updateRole(), below.
743 RoleClient client = new RoleClient();
744 Role role = createRoleInstance("ROLE_XXX",
747 ClientResponse<Role> res =
748 client.update(NON_EXISTENT_ID, role);
750 int statusCode = res.getStatus();
752 // Check the status code of the response: does it match
753 // the expected response(s)?
754 if (logger.isDebugEnabled()) {
755 logger.debug(testName + ": status = " + statusCode);
757 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
758 invalidStatusCodeMessage(testRequestType, statusCode));
759 Assert.assertEquals(statusCode, testExpectedStatusCode);
765 // ---------------------------------------------------------------
766 // CRUD tests : DELETE tests
767 // ---------------------------------------------------------------
770 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
773 public void delete(String testName) throws Exception {
774 // Do nothing since other tests like "updateNotAllowed" need the "known resource" that this test
775 // deletes. Once all those tests get run, the "localDelete" method will call the base class' delete
776 // method that will delete the "known resource".
779 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
780 dependsOnMethods = {"updateNotAllowed", "createForUniqueRole", "createForUniqueDisplayRole"})
781 public void localDelete(String testName) throws Exception {
782 super.delete(testName);
787 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
790 // @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
791 // dependsOnMethods = {"delete"})
792 public void deleteNonExistent(String testName) throws Exception {
794 setupDeleteNonExistent();
796 // Submit the request to the service and store the response.
797 RoleClient client = new RoleClient();
798 Response res = client.delete(NON_EXISTENT_ID);
800 int statusCode = res.getStatus();
802 // Check the status code of the response: does it match
803 // the expected response(s)?
804 if (logger.isDebugEnabled()) {
805 logger.debug(testName + ": status = " + statusCode);
807 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
808 invalidStatusCodeMessage(testRequestType, statusCode));
809 Assert.assertEquals(statusCode, testExpectedStatusCode);
815 // ---------------------------------------------------------------
817 // ---------------------------------------------------------------
820 // @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
821 public void searchWorkflowDeleted(String testName) throws Exception {
822 // Fixme: null test for now, overriding test in base class
825 // ---------------------------------------------------------------
826 // Utility tests : tests of code used in tests above
827 // ---------------------------------------------------------------
829 * Tests the code for manually submitting data that is used by several
830 * of the methods above.
834 // ---------------------------------------------------------------
835 // Utility methods used by tests above
836 // ---------------------------------------------------------------
838 * create role instance
844 public Role createRoleInstance(String roleName,
846 boolean useRoleName) {
848 Role role = RoleFactory.createRoleInstance(roleName,
849 roleName, //the display name
852 if (logger.isDebugEnabled()) {
853 logger.debug("to be created, role");
854 org.collectionspace.services.authorization.ObjectFactory objectFactory = new org.collectionspace.services.authorization.ObjectFactory();
855 logger.debug(objectAsXmlString(objectFactory.createRole(role),
865 * @param testName the test name
866 * @param list the list
869 protected void printList(String testName, RolesList list) {
870 for (Role role : list.getRole()) {
871 logger.debug(testName + " role csid=" + role.getCsid()
872 + " name=" + role.getRoleName()
873 + " desc=" + role.getDescription());
878 protected Role createInstance(String commonPartName, String identifier) {
879 // TODO Auto-generated method stub
884 protected Role updateInstance(Role commonPartObject) {
885 // TODO Auto-generated method stub
890 protected void compareUpdatedInstances(Role original, Role updated)
892 // TODO Auto-generated method stub
897 protected Class<RolesList> getCommonListType() {
898 // TODO Auto-generated method stub
903 * For convenience and terseness, this test method is the base of the test execution dependency chain. Other test methods may
904 * refer to this method in their @Test annotation declarations.
907 @Test(dataProvider = "testName",
909 "org.collectionspace.services.client.test.AbstractServiceTestImpl.baseCRUDTests"})
910 public void CRUDTests(String testName) {
911 // Do nothing. Simply here to for a TestNG execution order for our tests
915 protected long getSizeOfList(RolesList list) {
916 return list.getRole().size();