]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
d0c8f260a5595c12c94b41283c9e69379406abc0
[tmp/jakarta-migration.git] /
1 /**
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:
5  *
6  * http://www.collectionspace.org
7  * http://wiki.collectionspace.org
8  *
9  * Copyright © 2009 Regents of the University of California
10  *
11  * Licensed under the Educational Community License (ECL), Version 2.0.
12  * You may not use this file except in compliance with this License.
13  *
14  * You may obtain a copy of the ECL 2.0 License at
15  * https://source.collectionspace.org/collection-space/LICENSE.txt
16  *
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 permRoles and
21  * limitations under the License.
22  */
23 package org.collectionspace.services.authorization.client.test;
24
25 import java.util.ArrayList;
26 import java.util.Collection;
27 import java.util.Hashtable;
28 import java.util.List;
29
30 import javax.ws.rs.core.Response;
31
32 import org.collectionspace.services.authorization.perms.EffectType;
33 import org.collectionspace.services.authorization.perms.Permission;
34 import org.collectionspace.services.authorization.perms.PermissionAction;
35 import org.collectionspace.services.authorization.PermissionRole;
36 import org.collectionspace.services.authorization.PermissionValue;
37 import org.collectionspace.services.authorization.Role;
38 import org.collectionspace.services.authorization.RoleValue;
39 import org.collectionspace.services.client.CollectionSpaceClient;
40 import org.collectionspace.services.client.PermissionClient;
41 import org.collectionspace.services.client.PermissionFactory;
42 import org.collectionspace.services.client.PermissionRoleClient;
43 import org.collectionspace.services.client.PermissionRoleFactory;
44 import org.collectionspace.services.client.RoleClient;
45 import org.collectionspace.services.client.RoleFactory;
46 import org.collectionspace.services.client.test.AbstractServiceTestImpl;
47 import org.testng.Assert;
48 import org.testng.annotations.Test;
49 import org.slf4j.Logger;
50 import org.slf4j.LoggerFactory;
51 import org.testng.annotations.AfterClass;
52 import org.testng.annotations.BeforeClass;
53
54 /**
55  * PermissionServiceTest, carries out tests against a
56  * deployed and running Permission, Role and PermissionRole Services.
57  * 
58  * $LastChangedRevision: 917 $
59  * $LastChangedDate: 2009-11-06 12:20:28 -0800 (Fri, 06 Nov 2009) $
60  */
61 public class PermissionRoleServiceTest extends AbstractServiceTestImpl<PermissionRole, PermissionRole,
62                 PermissionRole, PermissionRole> {
63
64     /** The Constant logger. */
65     private final static String CLASS_NAME = PermissionRoleServiceTest.class.getName();
66     private final static Logger logger = LoggerFactory.getLogger(CLASS_NAME);
67
68     // Instance variables specific to this test.
69     final private static String TEST_MARKER = "_PermissionRoleServiceTest";
70     final private static String TEST_SERVICE_NAME = "fakeservice";
71     final private static String NO_REL_SUFFIX = "-no-rel";
72     /** The perm values. */
73     private Hashtable<String, PermissionValue> permValues = new Hashtable<String, PermissionValue>();
74     /** The role values. */
75     private Hashtable<String, RoleValue> roleValues = new Hashtable<String, RoleValue>();
76     /*
77      * This method is called only by the parent class, AbstractServiceTestImpl
78      */
79
80     /* (non-Javadoc)
81      * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
82      */
83     @Override
84     protected String getServicePathComponent() throws Exception {
85         return new PermissionRoleClient().getServicePathComponent();
86     }
87     
88         @Override
89         protected String getServiceName() {
90         return PermissionClient.SERVICE_NAME; //Since we're a sub-resource of permission service return its name?
91         }
92         
93     /**
94      * The entity type expected from the JAX-RS Response object
95      */
96     public Class<PermissionRole> getEntityResponseType() {
97         return PermissionRole.class;
98     }
99         
100     /**
101      * Seed data.
102      * @throws Exception 
103      */
104     @BeforeClass(alwaysRun = true)
105     public void seedData() throws Exception {
106         String ra = TEST_SERVICE_NAME + TEST_MARKER;
107         String accPermId = createPermission(ra, EffectType.PERMIT);
108         PermissionValue pva = new PermissionValue();
109         pva.setResourceName(ra);
110         pva.setPermissionId(accPermId);
111         permValues.put(pva.getResourceName(), pva);
112
113         String rc = TEST_SERVICE_NAME + TEST_MARKER + NO_REL_SUFFIX;
114         String coPermId = createPermission(rc, EffectType.DENY);
115         PermissionValue pvc = new PermissionValue();
116         pvc.setResourceName(rc);
117         pvc.setPermissionId(coPermId);
118         permValues.put(pvc.getResourceName(), pvc);
119 //
120 //        String ri = "intakes";
121 //        String iPermId = createPermission(ri, EffectType.DENY);
122 //        PermissionValue pvi = new PermissionValue();
123 //        pvi.setResourceName(ri);
124 //        pvi.setPermissionId(iPermId);
125 //        permValues.put(pvi.getResourceName(), pvi);
126
127         String rn1 = "ROLE_CO1" + TEST_MARKER;
128         String r1RoleId = createRole(rn1);
129         RoleValue rv1 = new RoleValue();
130         rv1.setRoleId(r1RoleId);
131         rv1.setRoleName(rn1);
132         roleValues.put(rv1.getRoleName(), rv1);
133
134         String rn2 = "ROLE_CO2" + TEST_MARKER;
135         String r2RoleId = createRole(rn2);
136         RoleValue rv2 = new RoleValue();
137         rv2.setRoleId(r2RoleId);
138         rv2.setRoleName(rn2);
139         roleValues.put(rv2.getRoleName(), rv2);
140     }
141
142     /* (non-Javadoc)
143      * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
144      */
145     @Override
146     protected CollectionSpaceClient getClientInstance() throws Exception {
147         return new PermissionRoleClient();
148     }
149
150         @Override
151         protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
152         return new PermissionRoleClient(clientPropertiesFilename);
153         }
154
155     /* (non-Javadoc)
156      * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
157      */
158     @Override
159     protected PermissionRole getCommonList(Response response) {
160         //FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
161         throw new UnsupportedOperationException();
162     }
163
164     /* (non-Javadoc)
165      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readPaginatedList(java.lang.String)
166      */
167     @Override
168     public void readPaginatedList(String testName) throws Exception {
169         //FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
170     }
171     // ---------------------------------------------------------------
172     // CRUD tests : CREATE tests
173     // ---------------------------------------------------------------
174     // Success outcomes
175     /* (non-Javadoc)
176      * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
177      */
178
179     @Override
180 //    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
181     public void create(String testName) throws Exception {
182         // Perform setup, such as initializing the type of service request
183         // (e.g. CREATE, DELETE), its valid and expected status codes, and
184         // its associated HTTP method name (e.g. POST, DELETE).
185         setupCreate();
186
187         // Submit the request to the service and store the response.
188         PermissionValue pv = permValues.get(TEST_SERVICE_NAME + TEST_MARKER);
189         PermissionRole permRole = createPermissionRoleInstance(pv,
190                 roleValues.values(), true, true);
191         PermissionRoleClient client = new PermissionRoleClient();
192         
193         Response res = client.create(pv.getPermissionId(), permRole);
194         try {
195             int statusCode = res.getStatus();
196
197             if (logger.isDebugEnabled()) {
198                 logger.debug(testName + ": status = " + statusCode);
199             }
200             Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
201                     invalidStatusCodeMessage(testRequestType, statusCode));
202             Assert.assertEquals(statusCode, testExpectedStatusCode);
203             
204             knownResourceId = extractId(res); //This is meaningless in this test, see getKnowResourceId() method for details
205             if (logger.isDebugEnabled()) {
206                 logger.debug(testName + ": knownResourceId=" + knownResourceId);
207             }
208         } finally {
209             if (res != null) {
210                 res.close();
211             }
212         }
213     }
214
215     //to not cause uniqueness violation for permRole, createList is removed
216     /* (non-Javadoc)
217      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
218      */
219     @Override
220 //    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
221 //    dependsOnMethods = {"create"})
222     public void createList(String testName) throws Exception {
223         //Should this really be empty?
224     }
225
226     // Failure outcomes
227     // Placeholders until the three tests below can be uncommented.
228     // See Issue CSPACE-401.
229     /* (non-Javadoc)
230      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
231      */
232     @Override
233     public void createWithEmptyEntityBody(String testName) throws Exception {
234         //Should this really be empty?
235     }
236
237     /* (non-Javadoc)
238      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
239      */
240     @Override
241     public void createWithMalformedXml(String testName) throws Exception {
242         //Should this really be empty?
243     }
244
245     /* (non-Javadoc)
246      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
247      */
248     @Override
249     public void createWithWrongXmlSchema(String testName) throws Exception {
250         //Should this really be empty?
251     }
252
253     // ---------------------------------------------------------------
254     // CRUD tests : READ tests
255     // ---------------------------------------------------------------
256     // Success outcomes
257     /* (non-Javadoc)
258      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
259      */
260     @Override
261 //    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
262 //    dependsOnMethods = {"create"})
263     public void read(String testName) throws Exception {
264         // Perform setup.
265         setupRead();
266
267         // Submit the request to the service and store the response.
268         PermissionRoleClient client = new PermissionRoleClient();
269         Response res = client.read(
270                 permValues.get(TEST_SERVICE_NAME + TEST_MARKER).getPermissionId());
271         try {
272             int statusCode = res.getStatus();
273
274             // Check the status code of the response: does it match
275             // the expected response(s)?
276             if (logger.isDebugEnabled()) {
277                 logger.debug(testName + ": status = " + statusCode);
278             }
279             Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
280                     invalidStatusCodeMessage(testRequestType, statusCode));
281             Assert.assertEquals(statusCode, testExpectedStatusCode);
282
283             PermissionRole output = res.readEntity(PermissionRole.class);
284             Assert.assertNotNull(output);
285         } finally {
286             if (res != null) {
287                 res.close();
288             }
289         }
290
291     }
292
293     // Failure outcomes
294     /* (non-Javadoc)
295      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
296      */
297     @Override
298     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
299     public void readNonExistent(String testName) throws Exception {
300         // Perform setup.
301         setupReadNonExistent();
302
303         // Submit the request to the service and store the response.
304         PermissionRoleClient client = new PermissionRoleClient();
305         Response res = null;
306         try {
307             res = client.read(NON_EXISTENT_ID);
308             int statusCode = res.getStatus();
309
310             // Check the status code of the response: does it match
311             // the expected response(s)?
312             if (logger.isDebugEnabled()) {
313                 logger.debug(testName + ": status = " + statusCode);
314             }
315             Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
316                     invalidStatusCodeMessage(testRequestType, statusCode));
317             Assert.assertEquals(statusCode, testExpectedStatusCode);
318         } finally {
319             if (res != null) {
320                 res.close();
321             }
322         }
323     }
324
325     @Test(dataProvider = "testName",
326                 dependsOnMethods = {"CRUDTests"})
327     public void readNoRelationship(String testName) throws Exception {
328         // Perform setup.
329         setupRead();
330
331         // Submit the request to the service and store the response.
332         PermissionRoleClient client = new PermissionRoleClient();
333         Response res = null;
334         try {
335             res = client.read(
336                     permValues.get(TEST_SERVICE_NAME + TEST_MARKER + NO_REL_SUFFIX).getPermissionId());
337             // Check the status code of the response: does it match
338             // the expected response(s)?
339             assertStatusCode(res, testName);
340             PermissionRole output = res.readEntity(PermissionRole.class);
341
342             String sOutput = objectAsXmlString(output, PermissionRole.class);
343             if (logger.isDebugEnabled()) {
344                 logger.debug(testName + " received " + sOutput);
345             }
346         } finally {
347             if (res != null) {
348                 res.close();
349             }
350         }
351
352     }
353     // ---------------------------------------------------------------
354     // CRUD tests : READ_LIST tests
355     // ---------------------------------------------------------------
356     // Success outcomes
357     /* (non-Javadoc)
358      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
359      */
360
361     @Override
362 //    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
363 //    dependsOnMethods = {"createList", "read"})
364     public void readList(String testName) throws Exception {
365         //Should this really be empty?
366     }
367
368     // Failure outcomes
369     // None at present.
370     // ---------------------------------------------------------------
371     // CRUD tests : UPDATE tests
372     // ---------------------------------------------------------------
373     // Success outcomes
374     /* (non-Javadoc)
375      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
376      */
377     @Override
378 //    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
379 //    dependsOnMethods = {"read", "readList", "readNonExistent"})
380     public void update(String testName) throws Exception {
381         //Should this really be empty?
382     }
383
384     // Failure outcomes
385     // Placeholders until the three tests below can be uncommented.
386     // See Issue CSPACE-401.
387     /* (non-Javadoc)
388      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
389      */
390     @Override
391     public void updateWithEmptyEntityBody(String testName) throws Exception {
392         //Should this really be empty?
393     }
394
395     /* (non-Javadoc)
396      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
397      */
398     @Override
399     public void updateWithMalformedXml(String testName) throws Exception {
400         //Should this really be empty?
401     }
402
403     /* (non-Javadoc)
404      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
405      */
406     @Override
407     public void updateWithWrongXmlSchema(String testName) throws Exception {
408         //Should this really be empty?
409     }
410
411     /* (non-Javadoc)
412      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
413      */
414     @Override
415 //    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
416 //    dependsOnMethods = {"readNonExistent", "testSubmitRequest"})
417     public void updateNonExistent(String testName) throws Exception {
418         //Should this really be empty?
419     }
420
421     // ---------------------------------------------------------------
422     // CRUD tests : DELETE tests
423     // ---------------------------------------------------------------
424     // Success outcomes
425     /* (non-Javadoc)
426      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
427      */
428     @Override
429 //    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
430 //    dependsOnMethods = {"read"})
431     public void delete(String testName) throws Exception {
432         // Perform setup.
433         setupDelete();
434
435         //
436         //
437         //
438         PermissionRoleClient client = new PermissionRoleClient();
439         Response readResponse = client.read(
440                         permValues.get(TEST_SERVICE_NAME + TEST_MARKER).getPermissionId());
441         PermissionRole toDelete = null;
442         try {
443                 toDelete = readResponse.readEntity(PermissionRole.class);
444         } finally {
445                 readResponse.close();
446         }        
447
448         Response res = client.delete(
449                         toDelete.getPermission().get(0).getPermissionId(), toDelete);
450         try {
451             int statusCode = res.getStatus();
452             Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
453                     invalidStatusCodeMessage(testRequestType, statusCode));
454             Assert.assertEquals(statusCode, testExpectedStatusCode);
455         } finally {
456             if (res != null) {
457                 res.close();
458             }
459         }
460         
461         //
462         // recreate 'TEST_SERVICE_NAME + TEST_MARKER' account and roles
463         //
464         create(testName);
465         setupDelete();
466      
467         //
468         // Lookup a know permission, and delete all of its role relationships
469         //
470         readResponse = client.read(
471                         permValues.get(TEST_SERVICE_NAME + TEST_MARKER).getPermissionId());
472         toDelete = null;
473         try {
474                 toDelete = readResponse.readEntity(PermissionRole.class);
475         } finally {
476                 readResponse.close();
477         }
478
479         Response deleteRes = client.delete(toDelete.getPermission().get(0).getPermissionId());
480         try {
481             int statusCode = deleteRes.getStatus();
482             Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
483                     invalidStatusCodeMessage(testRequestType, statusCode));
484             Assert.assertEquals(statusCode, testExpectedStatusCode);
485         } finally {
486                 deleteRes.close();
487         }
488         
489     }
490
491     // Failure outcomes
492     /* (non-Javadoc)
493      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
494      */
495     @Override
496     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
497     public void deleteNonExistent(String testName) throws Exception {
498         //ignoring this test as the service side returns 200 now even if it does
499         //not find a record in the db
500     }
501     
502     // ---------------------------------------------------------------
503     // Search tests
504     // ---------------------------------------------------------------
505     
506     @Override
507     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
508     public void searchWorkflowDeleted(String testName) throws Exception {
509         // Fixme: null test for now, overriding test in base class
510     }
511
512     @Override
513     protected String getKnowResourceId() {
514         return permValues.get(TEST_SERVICE_NAME + TEST_MARKER).getPermissionId();
515     }
516     
517     // ---------------------------------------------------------------
518     // Utility methods used by tests above
519     // ---------------------------------------------------------------
520     /**
521      * create permRolerole instance
522      * @param pv permissionvalue
523      * @param rvs rolevalue array
524      * @param usePermId 
525      * @param useRoleId
526      * @return PermissionRole
527      */
528     public static PermissionRole createPermissionRoleInstance(PermissionValue pv,
529             Collection<RoleValue> rvs,
530             boolean usePermId,
531             boolean useRoleId) {
532
533         List<RoleValue> rvls = new ArrayList<RoleValue>();
534         rvls.addAll(rvs);
535         PermissionRole permRole = PermissionRoleFactory.createPermissionRoleInstance(
536                 pv, rvls, usePermId, useRoleId);
537         if (logger.isDebugEnabled()) {
538             logger.debug("to be created, permRole");
539             logger.debug(objectAsXmlString(permRole, PermissionRole.class));
540         }
541         return permRole;
542     }
543
544     /**
545      * Clean up.
546      * @throws Exception 
547      */
548     @AfterClass(alwaysRun = true)
549     @Override
550     public void cleanUp() throws Exception {
551         setupDelete();
552         String noTest = System.getProperty("noTestCleanup");
553         if (Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
554             if (logger.isDebugEnabled()) {
555                 logger.debug("Skipping Cleanup phase ...");
556             }
557             return;
558         }
559         if (logger.isDebugEnabled()) {
560             logger.debug("Cleaning up temporary resources created for testing ...");
561         }
562
563         for (PermissionValue pv : permValues.values()) {
564             deletePermission(pv.getPermissionId());
565         }
566         for (RoleValue rv : roleValues.values()) {
567             deleteRole(rv.getRoleId());
568         }
569     }
570
571     /**
572      * Creates the permission.
573      *
574      * @param resName the res name
575      * @param effect the effect
576      * @return the string
577      * @throws Exception 
578      */
579     private String createPermission(String resName, EffectType effect) throws Exception {
580         if (logger.isDebugEnabled()) {
581             logger.debug(getTestBanner("createPermission"));
582         }
583         setupCreate();
584         PermissionClient permClient = new PermissionClient();
585         List<PermissionAction> actions = PermissionFactory.createDefaultActions();
586         Permission permission = PermissionFactory.createPermissionInstance(resName,
587                 "default permissions for " + resName,
588                 actions, effect, true, true, true);
589         String id = null;
590         Response res = permClient.create(permission);
591         try {
592             int statusCode = res.getStatus();
593             if (logger.isDebugEnabled()) {
594                 logger.debug("createPermission: resName=" + resName
595                         + " status = " + statusCode);
596             }
597             Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
598                     invalidStatusCodeMessage(testRequestType, statusCode));
599             Assert.assertEquals(statusCode, testExpectedStatusCode);
600             id = extractId(res);
601         } finally {
602             if (res != null) {
603                 res.close();
604             }
605         }
606         return id;
607     }
608
609     /**
610      * Delete permission.
611      *
612      * @param permId the perm id
613      * @throws Exception 
614      */
615     private void deletePermission(String permId) throws Exception {
616         if (logger.isDebugEnabled()) {
617             logger.debug(getTestBanner("deletePermission"));
618         }
619         setupDelete();
620         PermissionClient permClient = new PermissionClient();
621         Response res = permClient.delete(permId);
622         try {
623             int statusCode = res.getStatus();
624             if (logger.isDebugEnabled()) {
625                 logger.debug("deletePermission: delete permission id="
626                         + permId + " status=" + statusCode);
627             }
628             Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
629                     invalidStatusCodeMessage(testRequestType, statusCode));
630             Assert.assertEquals(statusCode, testExpectedStatusCode);
631         } finally {
632             res.close();
633         }
634
635     }
636
637     /**
638      * Creates the role.
639      *
640      * @param roleName the role name
641      * @return the string
642      * @throws Exception 
643      */
644     private String createRole(String roleName) throws Exception {
645         if (logger.isDebugEnabled()) {
646             logger.debug(getTestBanner("createRole"));
647         }
648         setupCreate();
649         RoleClient roleClient = new RoleClient();
650
651         Role role = RoleFactory.createRoleInstance(roleName,
652                         roleName, //the display name
653                 "role for " + roleName, true, RoleFactory.EMPTY_PERMVALUE_LIST);
654         Response res = null;
655         String id = null;
656         try {
657             res = roleClient.create(role);
658             int statusCode = res.getStatus();
659             if (logger.isDebugEnabled()) {
660                 logger.debug("createRole: name=" + roleName
661                         + " status = " + statusCode);
662             }
663             Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
664                     invalidStatusCodeMessage(testRequestType, statusCode));
665             Assert.assertEquals(statusCode, testExpectedStatusCode);
666
667             id = extractId(res);
668         } finally {
669             res.close();
670         }
671         return id;
672     }
673
674     /**
675      * Delete role.
676      *
677      * @param roleId the role id
678      * @throws Exception 
679      */
680     private void deleteRole(String roleId) throws Exception {
681         if (logger.isDebugEnabled()) {
682             logger.debug(getTestBanner("deleteRole"));
683         }
684         setupDelete();
685         RoleClient roleClient = new RoleClient();
686         Response res = roleClient.delete(roleId);
687         try {
688             int statusCode = res.getStatus();
689             if (logger.isDebugEnabled()) {
690                 logger.debug("deleteRole: delete role id=" + roleId
691                         + " status=" + statusCode);
692             }
693             Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
694                     invalidStatusCodeMessage(testRequestType, statusCode));
695             Assert.assertEquals(statusCode, testExpectedStatusCode);
696         } finally {
697             res.close();
698         }
699     }
700
701         @Override
702         protected PermissionRole createInstance(String commonPartName,
703                         String identifier) {
704                 // TODO Auto-generated method stub
705                 return null;
706         }
707
708         @Override
709         protected PermissionRole updateInstance(PermissionRole commonPartObject) {
710                 // TODO Auto-generated method stub
711                 return null;
712         }
713
714         @Override
715         protected void compareUpdatedInstances(PermissionRole original,
716                         PermissionRole updated) throws Exception {
717                 // TODO Auto-generated method stub
718                 
719         }
720
721         @Override
722         protected Class<PermissionRole> getCommonListType() {
723                 return PermissionRole.class;
724         }
725
726     /*
727      * For convenience and terseness, this test method is the base of the test execution dependency chain.  Other test methods may
728      * refer to this method in their @Test annotation declarations.
729      */
730     @Override
731     @Test(dataProvider = "testName",
732                 dependsOnMethods = {
733                         "org.collectionspace.services.client.test.AbstractServiceTestImpl.baseCRUDTests"})    
734     public void CRUDTests(String testName) {
735         // Do nothing.  Simply here to for a TestNG execution order for our tests
736     }
737     
738         @Override
739         protected long getSizeOfList(PermissionRole list) {
740                 // TODO Auto-generated method stub
741                 throw new UnsupportedOperationException("Method getSizeOfList() is not implemented because this service does not support lists.");
742         }
743 }