]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
a647eee74b175b1007c1717f57c26ae1564a7223
[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 permissions and
21  * limitations under the License.
22  */
23 package org.collectionspace.services.client.test;
24
25 import java.util.List;
26 import javax.ws.rs.core.MediaType;
27 import javax.ws.rs.core.Response;
28
29 //import org.collectionspace.services.client.AbstractServiceClientImpl;
30 import org.collectionspace.services.client.CollectionObjectClient;
31 import org.collectionspace.services.client.CollectionObjectFactory;
32 import org.collectionspace.services.client.CollectionSpaceClient;
33 import org.collectionspace.services.collectionobject.BriefDescriptionList;
34 import org.collectionspace.services.collectionobject.CollectionobjectsCommon;
35 import org.collectionspace.services.collectionobject.domain.naturalhistory.CollectionobjectsNaturalhistory;
36 import org.collectionspace.services.collectionobject.CollectionobjectsCommonList;
37 import org.collectionspace.services.collectionobject.ResponsibleDepartmentList;
38 import org.collectionspace.services.collectionobject.OtherNumber;
39 import org.collectionspace.services.collectionobject.OtherNumberList;
40
41 import org.collectionspace.services.jaxb.AbstractCommonList;
42
43 import org.jboss.resteasy.client.ClientResponse;
44 import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
45 import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
46 import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
47 import org.testng.Assert;
48 import org.testng.annotations.Test;
49
50 import org.slf4j.Logger;
51 import org.slf4j.LoggerFactory;
52
53 /**
54  * CollectionObjectServiceTest, carries out tests against a
55  * deployed and running CollectionObject Service.
56  *
57  * $LastChangedRevision$
58  * $LastChangedDate$
59  */
60 public class CollectionObjectServiceTest extends AbstractServiceTestImpl {
61
62     /** The logger. */
63     private final String CLASS_NAME = CollectionObjectServiceTest.class.getName();
64     private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
65     
66     // Instance variables specific to this test.
67     /** The known resource id. */
68     private String knownResourceId = null;
69
70     /* (non-Javadoc)
71      * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
72      */
73     @Override
74     protected String getServicePathComponent() {
75         return new CollectionObjectClient().getServicePathComponent();
76     }
77     
78     /* (non-Javadoc)
79      * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
80      */
81     @Override
82     protected CollectionSpaceClient getClientInstance() {
83         return new CollectionObjectClient();
84     }
85     
86     /* (non-Javadoc)
87      * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
88      */
89     @Override
90         protected AbstractCommonList getAbstractCommonList(
91                         ClientResponse<AbstractCommonList> response) {
92         return response.getEntity(CollectionobjectsCommonList.class);
93     }
94  
95     // ---------------------------------------------------------------
96     // CRUD tests : CREATE tests
97     // ---------------------------------------------------------------
98     // Success outcomes
99     /* (non-Javadoc)
100      * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
101      */
102     @Override
103     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
104     public void create(String testName) throws Exception {
105
106         if (logger.isDebugEnabled()) {
107             logger.debug(testBanner(testName, CLASS_NAME));
108         }
109         // Perform setup, such as initializing the type of service request
110         // (e.g. CREATE, DELETE), its valid and expected status codes, and
111         // its associated HTTP method name (e.g. POST, DELETE).
112         setupCreate();
113
114         // Submit the request to the service and store the response.
115         CollectionObjectClient client = new CollectionObjectClient();
116         String identifier = createIdentifier();
117         MultipartOutput multipart =
118                 createCollectionObjectInstance(client.getCommonPartName(), identifier);
119         ClientResponse<Response> res = client.create(multipart);
120         int statusCode = res.getStatus();
121
122         // Check the status code of the response: does it match
123         // the expected response(s)?
124         //
125         // Specifically:
126         // Does it fall within the set of valid status codes?
127         // Does it exactly match the expected status code?
128         if (logger.isDebugEnabled()) {
129             logger.debug(testName + ": status = " + statusCode);
130         }
131         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
132                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
133         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
134
135         // Store the ID returned from the first resource created
136         // for additional tests below.
137         if (knownResourceId == null) {
138             knownResourceId = extractId(res);
139             if (logger.isDebugEnabled()) {
140                 logger.debug(testName + ": knownResourceId=" + knownResourceId);
141             }
142         }
143
144         // Store the IDs from every resource created by tests,
145         // so they can be deleted after tests have been run.
146         allResourceIdsCreated.add(extractId(res));
147     }
148
149
150     /*
151      * Tests to diagnose and verify the fixed status of CSPACE-1026,
152      * "Whitespace at certain points in payload cause failure"
153      */
154     /**
155      * Creates the from xml cambridge.
156      *
157      * @param testName the test name
158      * @throws Exception the exception
159      */
160     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
161         dependsOnMethods = {"create", "testSubmitRequest"})
162     public void createFromXmlCambridge(String testName) throws Exception {
163         String newId =
164             createFromXmlFile(testName, "./test-data/testCambridge.xml", true);
165         testSubmitRequest(newId);
166     }
167
168     /**
169      * Creates the from xml rfw s1.
170      *
171      * @param testName the test name
172      * @throws Exception the exception
173      */
174     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
175         dependsOnMethods = {"create", "testSubmitRequest"})
176     public void createFromXmlRFWS1(String testName) throws Exception {
177         String testDataDir = System.getProperty("test-data.fileName");
178         String newId =
179             //createFromXmlFile(testName, "./target/test-classes/test-data/repfield_whitesp1.xml", false);
180                 createFromXmlFile(testName, testDataDir + "/repfield_whitesp1.xml", false);
181         testSubmitRequest(newId);
182     }
183
184     /**
185      * Creates the from xml rfw s2.
186      *
187      * @param testName the test name
188      * @throws Exception the exception
189      */
190     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
191         dependsOnMethods = {"create", "testSubmitRequest"})
192     public void createFromXmlRFWS2(String testName) throws Exception {
193         String testDataDir = System.getProperty("test-data.fileName");
194         String newId =
195             //createFromXmlFile(testName, "./target/test-classes/test-data/repfield_whitesp2.xml", false);
196                 createFromXmlFile(testName, testDataDir + "/repfield_whitesp2.xml", false);
197         testSubmitRequest(newId);
198     }
199
200     /**
201      * Creates the from xml rfw s3.
202      *
203      * @param testName the test name
204      * @throws Exception the exception
205      */
206     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
207         dependsOnMethods = {"create", "testSubmitRequest"})
208     public void createFromXmlRFWS3(String testName) throws Exception {
209         String testDataDir = System.getProperty("test-data.fileName");
210         String newId =
211             //createFromXmlFile(testName, "./target/test-classes/test-data/repfield_whitesp3.xml", false);
212                 createFromXmlFile(testName, testDataDir + "/repfield_whitesp3.xml", false);
213         testSubmitRequest(newId);
214     }
215
216     /**
217      * Creates the from xml rfw s4.
218      *
219      * @param testName the test name
220      * @throws Exception the exception
221      */
222     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
223         dependsOnMethods = {"create", "testSubmitRequest"})
224     public void createFromXmlRFWS4(String testName) throws Exception {
225         String testDataDir = System.getProperty("test-data.fileName");
226         String newId =
227             createFromXmlFile(testName, testDataDir + "/repfield_whitesp4.xml", false);
228         testSubmitRequest(newId);
229     }
230
231     /*
232      * Tests to diagnose and verify the fixed status of CSPACE-1248,
233      * "Wedged records created!" (i.e. records with child repeatable
234      * fields, which contain null values, can be successfully created
235      * but an error occurs on trying to retrieve those records).
236      */
237     /**
238      * Creates the with null value repeatable field.
239      *
240      * @param testName the test name
241      * @throws Exception the exception
242      */
243     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
244         dependsOnMethods = {"create", "testSubmitRequest"})
245     public void createWithNullValueRepeatableField(String testName) throws Exception {
246         String testDataDir = System.getProperty("test-data.fileName");
247         String newId =
248             createFromXmlFile(testName, testDataDir + "/repfield_null1.xml", false);
249         if (logger.isDebugEnabled()) {
250             logger.debug("Successfully created record with null value repeatable field.");
251             logger.debug("Attempting to retrieve just-created record ...");
252         }
253         testSubmitRequest(newId);
254     }
255     
256     /* (non-Javadoc)
257      * @see org.collectionspace.services.client.test.ServiceTest#createList()
258      */
259     @Override
260     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
261     dependsOnMethods = {"create"})
262     public void createList(String testName) throws Exception {
263         this.createPaginatedList(testName, DEFAULT_LIST_SIZE);
264     }
265
266     // Failure outcomes
267     // Placeholders until the three tests below can be uncommented.
268     // See Issue CSPACE-401.
269     /* (non-Javadoc)
270      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
271      */
272     @Override
273     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
274     public void createWithEmptyEntityBody(String testName) throws Exception {
275         //FIXME: Should this test really be empty?
276     }
277
278    /**
279     * Test how the service handles XML that is not well formed,
280     * when sent in the payload of a Create request.
281     *
282     * @param testName  The name of this test method.  This name is supplied
283     *     automatically, via reflection, by a TestNG 'data provider' in
284     *     a base class.
285     */
286     @Override
287     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
288     public void createWithMalformedXml(String testName) throws Exception {
289     }
290
291     /* (non-Javadoc)
292      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
293      */
294     @Override
295     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
296     public void createWithWrongXmlSchema(String testName) throws Exception {
297         //FIXME: Should this test really be empty?
298     }
299
300
301 /*
302     @Override
303     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
304     dependsOnMethods = {"create", "testSubmitRequest"})
305     public void createWithEmptyEntityBody(String testName) throwsException {
306
307         if (logger.isDebugEnabled()) {
308             logger.debug(testBanner(testName, CLASS_NAME));
309         }
310         // Perform setup.
311         setupCreateWithEmptyEntityBody();
312
313         // Submit the request to the service and store the response.
314         String method = REQUEST_TYPE.httpMethodName();
315         String url = getServiceRootURL();
316         String mediaType = MediaType.APPLICATION_XML;
317         final String entity = "";
318         int statusCode = submitRequest(method, url, mediaType, entity);
319
320         // Check the status code of the response: does it match
321         // the expected response(s)?
322         if(logger.isDebugEnabled()){
323         logger.debug(testName + ": url=" + url +
324         " status=" + statusCode);
325         }
326         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
327         invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
328         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
329     }
330
331     @Override
332     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
333     dependsOnMethods = {"create", "testSubmitRequest"})
334     public void createWithMalformedXml(String testName) throws Exception {
335
336         if (logger.isDebugEnabled()) {
337             logger.debug(testBanner(testName, CLASS_NAME));
338         }
339         // Perform setup.
340         setupCreateWithMalformedXml();
341
342         // Submit the request to the service and store the response.
343         String method = REQUEST_TYPE.httpMethodName();
344         String url = getServiceRootURL();
345         String mediaType = MediaType.APPLICATION_XML;
346         final String entity = MALFORMED_XML_DATA; // Constant from base class.
347         int statusCode = submitRequest(method, url, mediaType, entity);
348
349         // Check the status code of the response: does it match
350         // the expected response(s)?
351         if(logger.isDebugEnabled()){
352         logger.debug(testName + ": url=" + url +
353         " status=" + statusCode);
354         }
355         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
356         invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
357         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
358     }
359
360     @Override
361     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
362     dependsOnMethods = {"create", "testSubmitRequest"})
363     public void createWithWrongXmlSchema(String testName) throws Exception {
364
365         if (logger.isDebugEnabled()) {
366             logger.debug(testBanner(testName, CLASS_NAME));
367         }
368         // Perform setup.
369         setupCreateWithWrongXmlSchema();
370
371         // Submit the request to the service and store the response.
372         String method = REQUEST_TYPE.httpMethodName();
373         String url = getServiceRootURL();
374         String mediaType = MediaType.APPLICATION_XML;
375         final String entity = WRONG_XML_SCHEMA_DATA;
376         int statusCode = submitRequest(method, url, mediaType, entity);
377
378         // Check the status code of the response: does it match
379         // the expected response(s)?
380         if(logger.isDebugEnabled()){
381         logger.debug(testName + ": url=" + url +
382         " status=" + statusCode);
383         }
384         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
385         invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
386         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
387     }
388 */
389
390    /**
391     * Test how the service handles, in a Create request, payloads
392     * containing null values (or, in the case of String fields,
393     * empty String values) in one or more fields which must be
394     * present and are required to contain non-empty values.
395     *
396     * This is a test of code and/or configuration in the service's
397     * validation routine(s).
398     *
399     * @param testName  The name of this test method.  This name is supplied
400     *     automatically, via reflection, by a TestNG 'data provider' in
401     *     a base class.
402     * @throws Exception 
403     */
404     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
405     public void createWithRequiredValuesNullOrEmpty(String testName) throws Exception {
406         if (logger.isDebugEnabled()) {
407             logger.debug(testBanner(testName, CLASS_NAME));
408         }
409         setupCreate();
410
411         // Build a payload with invalid content, by omitting a
412         // field (objectNumber) which must be present, and in which
413         // a non-empty value is required, as enforced by the service's
414         // validation routine(s).
415         CollectionobjectsCommon collectionObject = new CollectionobjectsCommon();
416         collectionObject.setTitle("atitle");
417         collectionObject.setObjectName("some name");
418
419         // Submit the request to the service and store the response.
420         CollectionObjectClient client = new CollectionObjectClient();
421         MultipartOutput multipart =
422                 createCollectionObjectInstance(client.getCommonPartName(), collectionObject, null);
423         ClientResponse<Response> res = client.create(multipart);
424         int statusCode = res.getStatus();
425
426         // Read the response and verify that the create attempt failed.
427         if (logger.isDebugEnabled()) {
428             logger.debug(testName + ": status = " + statusCode);
429         }
430         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
431                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
432         Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
433
434         // FIXME: Consider splitting off the following into its own test method.
435         
436         // Build a payload with invalid content, by setting a value to the
437         // empty String, in a field that requires a non-empty value,
438         // as enforced by the service's validation routine(s).
439         collectionObject = new CollectionobjectsCommon();
440         collectionObject.setTitle("atitle");
441         collectionObject.setObjectName("some name");
442         collectionObject.setObjectNumber("");
443
444         // Submit the request to the service and store the response.
445         multipart =
446             createCollectionObjectInstance(client.getCommonPartName(), collectionObject, null);
447         res = client.create(multipart);
448         statusCode = res.getStatus();
449
450         // Read the response and verify that the create attempt failed.
451         if (logger.isDebugEnabled()) {
452             logger.debug(testName + ": status = " + statusCode);
453         }
454         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
455                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
456         Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
457
458     }
459
460
461     // ---------------------------------------------------------------
462     // CRUD tests : READ tests
463     // ---------------------------------------------------------------
464     // Success outcomes
465     /* (non-Javadoc)
466      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
467      */
468     @Override
469     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
470     dependsOnMethods = {"create"})
471     public void read(String testName) throws Exception {
472
473         if (logger.isDebugEnabled()) {
474             logger.debug(testBanner(testName, CLASS_NAME));
475         }
476         // Perform setup.
477         setupRead();
478
479         // Submit the request to the service and store the response.
480         CollectionObjectClient client = new CollectionObjectClient();
481         ClientResponse<MultipartInput> res = client.read(knownResourceId);
482         int statusCode = res.getStatus();
483
484         // Check the status code of the response: does it match
485         // the expected response(s)?
486         if (logger.isDebugEnabled()) {
487             logger.debug(testName + ": status = " + statusCode);
488         }
489         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
490                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
491         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
492
493         MultipartInput input = (MultipartInput) res.getEntity();
494
495         if (logger.isDebugEnabled()) {
496             logger.debug(testName + ": Reading Common part ...");
497         }
498         CollectionobjectsCommon collectionObject =
499                 (CollectionobjectsCommon) extractPart(input,
500                 client.getCommonPartName(), CollectionobjectsCommon.class);
501         Assert.assertNotNull(collectionObject);
502
503         if (logger.isDebugEnabled()) {
504             logger.debug(testName + ": Reading Natural History part ...");
505         }
506         CollectionobjectsNaturalhistory conh =
507                 (CollectionobjectsNaturalhistory) extractPart(input,
508                 getNHPartName(), CollectionobjectsNaturalhistory.class);
509         Assert.assertNotNull(conh);
510     }
511
512     // Failure outcomes
513     /* (non-Javadoc)
514      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
515      */
516     @Override
517     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
518     dependsOnMethods = {"read"})
519     public void readNonExistent(String testName) throws Exception {
520
521         if (logger.isDebugEnabled()) {
522             logger.debug(testBanner(testName, CLASS_NAME));
523         }
524         // Perform setup.
525         setupReadNonExistent();
526
527         // Submit the request to the service and store the response.
528         CollectionObjectClient client = new CollectionObjectClient();
529         ClientResponse<MultipartInput> res = client.read(NON_EXISTENT_ID);
530         int statusCode = res.getStatus();
531
532         // Check the status code of the response: does it match
533         // the expected response(s)?
534         if (logger.isDebugEnabled()) {
535             logger.debug(testName + ": status = " + statusCode);
536         }
537         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
538                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
539         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
540     }
541
542     
543     // ---------------------------------------------------------------
544     // CRUD tests : READ_LIST tests
545     // ---------------------------------------------------------------
546     // Success outcomes
547     /* (non-Javadoc)
548      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
549      */
550     @Override
551     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
552     dependsOnMethods = {"createList", "read"})
553     public void readList(String testName) throws Exception {
554
555         if (logger.isDebugEnabled()) {
556             logger.debug(testBanner(testName, CLASS_NAME));
557         }
558         // Perform setup.
559         setupReadList();
560
561         // Submit the request to the service and store the response.
562         CollectionObjectClient client = new CollectionObjectClient();
563         ClientResponse<CollectionobjectsCommonList> res = client.readList();
564         CollectionobjectsCommonList list = res.getEntity();
565         int statusCode = res.getStatus();
566
567         // Check the status code of the response: does it match
568         // the expected response(s)?
569         if (logger.isDebugEnabled()) {
570             logger.debug(testName + ": status = " + statusCode);
571         }
572         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
573                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
574         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
575
576         // Optionally output additional data about list members for debugging.
577         boolean iterateThroughList = false;
578         if (iterateThroughList && logger.isDebugEnabled()) {
579             List<CollectionobjectsCommonList.CollectionObjectListItem> items =
580                     list.getCollectionObjectListItem();
581             int i = 0;
582
583             for (CollectionobjectsCommonList.CollectionObjectListItem item : items) {
584                 logger.debug(testName + ": list-item[" + i + "] csid="
585                         + item.getCsid());
586                 logger.debug(testName + ": list-item[" + i + "] objectNumber="
587                         + item.getObjectNumber());
588                 logger.debug(testName + ": list-item[" + i + "] URI="
589                         + item.getUri());
590                 i++;
591
592             }
593         }
594     }
595
596     // Failure outcomes
597     // None at present.
598     // ---------------------------------------------------------------
599     // CRUD tests : UPDATE tests
600     // ---------------------------------------------------------------
601     // Success outcomes
602     /* (non-Javadoc)
603      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
604      */
605     @Override
606     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
607     dependsOnMethods = {"read"})
608     public void update(String testName) throws Exception {
609
610         if (logger.isDebugEnabled()) {
611             logger.debug(testBanner(testName, CLASS_NAME));
612         }
613         // Perform setup.
614         setupUpdate();
615
616         // Read an existing resource that will be updated.
617         ClientResponse<MultipartInput> res = updateRetrieve(testName, knownResourceId);
618
619         // Extract its common part.
620         CollectionObjectClient client = new CollectionObjectClient();
621         MultipartInput input = (MultipartInput) res.getEntity();
622         CollectionobjectsCommon collectionObject =
623                 (CollectionobjectsCommon) extractPart(input,
624                 client.getCommonPartName(), CollectionobjectsCommon.class);
625         Assert.assertNotNull(collectionObject);
626
627         // Change the content of one or more fields in the common part.
628         collectionObject.setObjectNumber("updated-" + collectionObject.getObjectNumber());
629         collectionObject.setObjectName("updated-" + collectionObject.getObjectName());
630         if (logger.isDebugEnabled()) {
631             logger.debug("sparse update that will be sent in update request:");
632             logger.debug(objectAsXmlString(collectionObject,
633                     CollectionobjectsCommon.class));
634         }
635
636         // Send the changed resource to be updated.
637         res = updateSend(testName, knownResourceId, collectionObject);
638         int statusCode = res.getStatus();
639         // Check the status code of the response: does it match the expected response(s)?
640         if (logger.isDebugEnabled()) {
641             logger.debug(testName + ": status = " + statusCode);
642         }
643         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
644                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
645         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
646
647         // Read the response and verify that the resource was correctly updated.
648         input = (MultipartInput) res.getEntity();
649         CollectionobjectsCommon updatedCollectionObject =
650                 (CollectionobjectsCommon) extractPart(input,
651                 client.getCommonPartName(), CollectionobjectsCommon.class);
652         Assert.assertNotNull(updatedCollectionObject);
653         Assert.assertEquals(updatedCollectionObject.getObjectName(),
654                 collectionObject.getObjectName(),
655                 "Data in updated object did not match submitted data.");
656
657     }
658
659     /**
660      * Update retrieve.
661      *
662      * @param testName the test name
663      * @param id the id
664      * @return the client response
665      */
666     private ClientResponse<MultipartInput> updateRetrieve(String testName, String id) {
667         final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
668         CollectionObjectClient client = new CollectionObjectClient();
669         ClientResponse<MultipartInput> res = client.read(id);
670         if (logger.isDebugEnabled()) {
671             logger.debug("read in updateRetrieve for " + testName + " status = " + res.getStatus());
672         }
673         Assert.assertEquals(res.getStatus(), EXPECTED_STATUS);
674         if (logger.isDebugEnabled()) {
675             logger.debug("got object to updateRetrieve for " + testName + " with ID: " + id);
676         }
677         return res;
678     }
679
680     /**
681      * Update send.
682      *
683      * @param testName the test name
684      * @param id the id
685      * @param collectionObject the collection object
686      * @return the client response
687      */
688     private ClientResponse<MultipartInput> updateSend(String testName, String id,
689             CollectionobjectsCommon collectionObject) {
690         MultipartOutput output = new MultipartOutput();
691         OutputPart commonPart = output.addPart(collectionObject, MediaType.APPLICATION_XML_TYPE);
692         CollectionObjectClient client = new CollectionObjectClient();
693         commonPart.getHeaders().add("label", client.getCommonPartName());
694         ClientResponse<MultipartInput> res = client.update(knownResourceId, output);
695         return res;
696     }
697
698     // Failure outcomes
699     // Placeholders until the three tests below can be uncommented.
700     // See Issue CSPACE-401.
701     /* (non-Javadoc)
702      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
703      */
704     @Override
705     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
706     dependsOnMethods = {"read"})
707     public void updateWithEmptyEntityBody(String testName) throws Exception {
708         //FIXME: Should this test really be empty?
709     }
710
711    /**
712     * Test how the service handles XML that is not well formed,
713     * when sent in the payload of an Update request.
714     *
715     * @param testName  The name of this test method.  This name is supplied
716     *     automatically, via reflection, by a TestNG 'data provider' in
717     *     a base class.
718     */
719     @Override
720     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
721     dependsOnMethods = {"read"})
722     public void updateWithMalformedXml(String testName) throws Exception {
723         //FIXME: Should this test really be empty?
724     }
725
726     /* (non-Javadoc)
727      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
728      */
729     @Override
730     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
731     dependsOnMethods = {"read"})
732     public void updateWithWrongXmlSchema(String testName) throws Exception {
733         //FIXME: Should this test really be empty?
734     }
735
736 /*
737     @Override
738     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
739     dependsOnMethods = {"create", "update", "testSubmitRequest"})
740     public void updateWithEmptyEntityBody(String testName) throws Exception {
741
742         if (logger.isDebugEnabled()) {
743             logger.debug(testBanner(testName, CLASS_NAME));
744         }
745         // Perform setup.
746         setupUpdateWithEmptyEntityBody();
747
748         // Submit the request to the service and store the response.
749         String method = REQUEST_TYPE.httpMethodName();
750         String url = getResourceURL(knownResourceId);
751         String mediaType = MediaType.APPLICATION_XML;
752         final String entity = "";
753         int statusCode = submitRequest(method, url, mediaType, entity);
754
755         // Check the status code of the response: does it match
756         // the expected response(s)?
757         if(logger.isDebugEnabled()){
758         logger.debug(testName + ": url=" + url +
759         " status=" + statusCode);
760         }
761         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
762         invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
763         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
764     }
765
766     @Override
767     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
768     dependsOnMethods = {"create", "update", "testSubmitRequest"})
769     public void updateWithMalformedXml() throws Exception {
770
771         if (logger.isDebugEnabled()) {
772             logger.debug(testBanner(testName, CLASS_NAME));
773         }
774         // Perform setup.
775         setupUpdateWithMalformedXml();
776
777         // Submit the request to the service and store the response.
778         String method = REQUEST_TYPE.httpMethodName();
779         String url = getResourceURL(knownResourceId);
780         final String entity = MALFORMED_XML_DATA;
781         String mediaType = MediaType.APPLICATION_XML;
782         int statusCode = submitRequest(method, url, mediaType, entity);
783
784         // Check the status code of the response: does it match
785         // the expected response(s)?
786         if(logger.isDebugEnabled()){
787         logger.debug(testName + ": url=" + url +
788         " status=" + statusCode);
789         }
790         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
791         invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
792         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
793     }
794
795     @Override
796     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
797     dependsOnMethods = {"create", "update", "testSubmitRequest"})
798     public void updateWithWrongXmlSchema(String testName) throws Exception {
799
800         if (logger.isDebugEnabled()) {
801             logger.debug(testBanner(testName, CLASS_NAME));
802         }
803         // Perform setup.
804         setupUpdateWithWrongXmlSchema();
805
806         // Submit the request to the service and store the response.
807         String method = REQUEST_TYPE.httpMethodName();
808         String url = getResourceURL(knownResourceId);
809         String mediaType = MediaType.APPLICATION_XML;
810         final String entity = WRONG_XML_SCHEMA_DATA;
811         int statusCode = submitRequest(method, url, mediaType, entity);
812
813         // Check the status code of the response: does it match
814         // the expected response(s)?
815         if(logger.isDebugEnabled()){
816         logger.debug(testName + ": url=" + url +
817         " status=" + statusCode);
818         }
819         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
820         invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
821         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
822     }
823 */
824
825     /* (non-Javadoc)
826  * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
827  */
828 @Override
829     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
830     dependsOnMethods = {"update", "testSubmitRequest"})
831     public void updateNonExistent(String testName) throws Exception {
832
833         if (logger.isDebugEnabled()) {
834             logger.debug(testBanner(testName, CLASS_NAME));
835         }
836         // Perform setup.
837         setupUpdateNonExistent();
838
839         // Submit the request to the service and store the response.
840         //
841         // Note: The ID used in this 'create' call may be arbitrary.
842         // The only relevant ID may be the one used in updateCollectionObject(), below.
843         CollectionObjectClient client = new CollectionObjectClient();
844         MultipartOutput multipart =
845                 createCollectionObjectInstance(client.getCommonPartName(),
846                 NON_EXISTENT_ID);
847         ClientResponse<MultipartInput> res =
848                 client.update(NON_EXISTENT_ID, multipart);
849         int statusCode = res.getStatus();
850
851         // Check the status code of the response: does it match
852         // the expected response(s)?
853         if (logger.isDebugEnabled()) {
854             logger.debug(testName + ": status = " + statusCode);
855         }
856         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
857                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
858         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
859     }
860
861    /**
862     * Test how the service handles, in an Update request, payloads
863     * containing null values (or, in the case of String fields,
864     * empty String values) in one or more fields in which non-empty
865     * values are required.
866     *
867     * This is a test of code and/or configuration in the service's
868     * validation routine(s).
869     *
870     * @param testName  The name of this test method.  This name is supplied
871     *     automatically, via reflection, by a TestNG 'data provider' in
872     *     a base class.
873  * @throws Exception 
874     */
875     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
876     dependsOnMethods = {"read"})
877     public void updateWithRequiredValuesNullOrEmpty(String testName) throws Exception {
878   
879         if (logger.isDebugEnabled()) {
880             logger.debug(testBanner(testName, CLASS_NAME));
881         }
882         // Perform setup.
883         setupUpdate();
884         if (logger.isDebugEnabled()) {
885             logger.debug(testName + " got object to update with ID: " + knownResourceId);
886         }
887
888         // Read an existing record for updating.
889         ClientResponse<MultipartInput> res = updateRetrieve(testName, knownResourceId);
890
891         CollectionObjectClient client = new CollectionObjectClient();
892         MultipartInput input = (MultipartInput) res.getEntity();
893         CollectionobjectsCommon collectionObject =
894                 (CollectionobjectsCommon) extractPart(input,
895                 client.getCommonPartName(), CollectionobjectsCommon.class);
896         Assert.assertNotNull(collectionObject);
897
898         // Update with invalid content, by setting a value to the
899         // empty String, in a field that requires a non-empty value,
900         // as enforced by the service's validation routine(s).
901         collectionObject.setObjectNumber("");
902
903         if (logger.isDebugEnabled()) {
904             logger.debug(testName + " updated object");
905             logger.debug(objectAsXmlString(collectionObject,
906                     CollectionobjectsCommon.class));
907         }
908
909         // Submit the request to the service and store the response.
910         res = updateSend(testName, knownResourceId, collectionObject);
911         int statusCode = res.getStatus();
912
913         // Read the response and verify that the update attempt failed.
914         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
915                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
916         Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
917
918     }
919
920     // ---------------------------------------------------------------
921     // CRUD tests : DELETE tests
922     // ---------------------------------------------------------------
923     // Success outcomes
924     /* (non-Javadoc)
925      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
926      */
927     @Override
928     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
929     dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"})
930     public void delete(String testName) throws Exception {
931
932         if (logger.isDebugEnabled()) {
933             logger.debug(testBanner(testName, CLASS_NAME));
934         }
935         // Perform setup.
936         setupDelete();
937
938         // Submit the request to the service and store the response.
939         CollectionObjectClient client = new CollectionObjectClient();
940         ClientResponse<Response> res = client.delete(knownResourceId);
941         int statusCode = res.getStatus();
942
943         // Check the status code of the response: does it match
944         // the expected response(s)?
945         if (logger.isDebugEnabled()) {
946             logger.debug(testName + ": status = " + statusCode);
947         }
948         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
949                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
950         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
951     }
952
953     // Failure outcomes
954     /* (non-Javadoc)
955      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
956      */
957     @Override
958     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
959     dependsOnMethods = {"delete"})
960     public void deleteNonExistent(String testName) throws Exception {
961
962         if (logger.isDebugEnabled()) {
963             logger.debug(testBanner(testName, CLASS_NAME));
964         }
965         // Perform setup.
966         setupDeleteNonExistent();
967
968         // Submit the request to the service and store the response.
969         CollectionObjectClient client = new CollectionObjectClient();
970         ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
971         int statusCode = res.getStatus();
972
973         // Check the status code of the response: does it match
974         // the expected response(s)?
975         if (logger.isDebugEnabled()) {
976             logger.debug(testName + ": status = " + statusCode);
977         }
978         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
979                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
980         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
981     }
982
983     // ---------------------------------------------------------------
984     // Utility tests : tests of code used in tests above
985     // ---------------------------------------------------------------
986     /**
987      * Tests the code for manually submitting data that is used by several
988      * of the methods above.
989      * @throws Exception 
990      */
991
992     @Test(dependsOnMethods = {"create", "read"})
993     public void testSubmitRequest() throws Exception {
994         testSubmitRequest(knownResourceId);
995     }
996
997     /**
998      * Test submit request.
999      *
1000      * @param resourceId the resource id
1001      * @throws Exception the exception
1002      */
1003     private void testSubmitRequest(String resourceId) throws Exception {
1004
1005         // Expected status code: 200 OK
1006         final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
1007
1008         // Submit the request to the service and store the response.
1009         String method = ServiceRequestType.READ.httpMethodName();
1010         String url = getResourceURL(resourceId);
1011         int statusCode = submitRequest(method, url);
1012
1013         // Check the status code of the response: does it match
1014         // the expected response(s)?
1015         if (logger.isDebugEnabled()) {
1016             logger.debug("testSubmitRequest: url=" + url
1017                     + " status=" + statusCode);
1018         }
1019         Assert.assertEquals(statusCode, EXPECTED_STATUS);
1020
1021     }
1022
1023     // ---------------------------------------------------------------
1024     // Utility methods used by tests above
1025     // ---------------------------------------------------------------
1026     /**
1027      * Creates the collection object instance.
1028      *
1029      * @param commonPartName the common part name
1030      * @param identifier the identifier
1031      * @return the multipart output
1032      */
1033     private MultipartOutput createCollectionObjectInstance(String commonPartName,
1034             String identifier) {
1035         return createCollectionObjectInstance(commonPartName,
1036                 "objectNumber-" + identifier,
1037                 "objectName-" + identifier);
1038     }
1039
1040     /**
1041      * Creates the collection object instance.
1042      *
1043      * @param commonPartName the common part name
1044      * @param objectNumber the object number
1045      * @param objectName the object name
1046      * @return the multipart output
1047      */
1048     private MultipartOutput createCollectionObjectInstance(String commonPartName,
1049             String objectNumber, String objectName) {
1050         CollectionobjectsCommon collectionObject = new CollectionobjectsCommon();
1051
1052         BriefDescriptionList descriptionList = new BriefDescriptionList();
1053         List<String> descriptions = descriptionList.getBriefDescription();
1054         descriptions.add("Papier mache bird cow mask with horns, "
1055                 + "painted red with black and yellow spots. "
1056                 + "Puerto Rico. ca. 8&quot; high, 6&quot; wide, projects 10&quot; (with horns).");
1057         descriptions.add("Papier mache bird cow mask with horns, "
1058                 + "painted red with black and yellow spots. "
1059                 + "Puerto Rico. ca. 8&quot; high, 6&quot; wide, projects 10&quot; (with horns).");
1060
1061         ResponsibleDepartmentList deptList = new ResponsibleDepartmentList();
1062         List<String> depts = deptList.getResponsibleDepartment();
1063         // @TODO Use properly formatted refNames for representative departments
1064         // in this example test record. The following are mere placeholders.
1065         depts.add("urn:org.collectionspace.services.department:Registrar");
1066         depts.add("urn:org.walkerart.department:Fine Art");
1067
1068         OtherNumberList otherNumList = new OtherNumberList();
1069         List<OtherNumber> otherNumbers = otherNumList.getOtherNumber();
1070         
1071         OtherNumber otherNumber1 = new OtherNumber();        
1072         otherNumber1.setNumberValue("101." + objectName);
1073         otherNumber1.setNumberType("integer");
1074         otherNumbers.add(otherNumber1);
1075         
1076         OtherNumber otherNumber2 = new OtherNumber();
1077         otherNumber2.setNumberValue("101.502.23.456." + objectName);
1078         otherNumber2.setNumberType("ipaddress");
1079         otherNumbers.add(otherNumber2);        
1080         
1081         //FIXME: Title does not need to be set.
1082         collectionObject.setTitle("atitle");
1083         collectionObject.setResponsibleDepartments(deptList);
1084         collectionObject.setObjectNumber(objectNumber);
1085         
1086         collectionObject.setOtherNumberList(otherNumList);
1087
1088         // FIXME this can be removed when the repeatable other number list
1089         // is supported by the application layers
1090         collectionObject.setOtherNumber("urn:org.walkerart.id:123");
1091         
1092         collectionObject.setObjectName(objectName);
1093         collectionObject.setAge(""); //test for null string
1094         collectionObject.setBriefDescriptions(descriptionList);
1095
1096         CollectionobjectsNaturalhistory conh = new CollectionobjectsNaturalhistory();
1097         conh.setNhString("test-string");
1098         conh.setNhInt(999);
1099         conh.setNhLong(9999);
1100
1101
1102         MultipartOutput multipart = createCollectionObjectInstance(commonPartName, collectionObject, conh);
1103         return multipart;
1104     }
1105
1106     /**
1107      * Creates the collection object instance.
1108      *
1109      * @param commonPartName the common part name
1110      * @param collectionObject the collection object
1111      * @param conh the conh
1112      * @return the multipart output
1113      */
1114     private MultipartOutput createCollectionObjectInstance(String commonPartName,
1115             CollectionobjectsCommon collectionObject, CollectionobjectsNaturalhistory conh) {
1116
1117         MultipartOutput multipart = CollectionObjectFactory.createCollectionObjectInstance(
1118                 commonPartName, collectionObject, getNHPartName(), conh);
1119         if (logger.isDebugEnabled()) {
1120             logger.debug("to be created, collectionobject common");
1121             logger.debug(objectAsXmlString(collectionObject,
1122                     CollectionobjectsCommon.class));
1123         }
1124
1125         if (conh != null) {
1126             if (logger.isDebugEnabled()) {
1127                 logger.debug("to be created, collectionobject nhistory");
1128                 logger.debug(objectAsXmlString(conh,
1129                         CollectionobjectsNaturalhistory.class));
1130             }
1131         }
1132         return multipart;
1133
1134     }
1135
1136     /**
1137      * createCollectionObjectInstanceFromXml uses JAXB unmarshaller to retrieve
1138      * collectionobject from given file
1139      * @param commonPartName
1140      * @param commonPartFileName
1141      * @return
1142      * @throws Exception
1143      */
1144     private MultipartOutput createCollectionObjectInstanceFromXml(String testName, String commonPartName,
1145             String commonPartFileName) throws Exception {
1146
1147         CollectionobjectsCommon collectionObject =
1148                 (CollectionobjectsCommon) getObjectFromFile(CollectionobjectsCommon.class,
1149                 commonPartFileName);
1150         MultipartOutput multipart = new MultipartOutput();
1151         OutputPart commonPart = multipart.addPart(collectionObject,
1152                 MediaType.APPLICATION_XML_TYPE);
1153         commonPart.getHeaders().add("label", commonPartName);
1154
1155         if (logger.isDebugEnabled()) {
1156             logger.debug(testName + " to be created, collectionobject common");
1157             logger.debug(objectAsXmlString(collectionObject,
1158                     CollectionobjectsCommon.class));
1159         }
1160         return multipart;
1161
1162     }
1163
1164     /**
1165      * createCollectionObjectInstanceFromRawXml uses stringified collectionobject
1166      * retrieve from given file
1167      * @param commonPartName
1168      * @param commonPartFileName
1169      * @return
1170      * @throws Exception
1171      */
1172     private MultipartOutput createCollectionObjectInstanceFromRawXml(String testName, String commonPartName,
1173             String commonPartFileName) throws Exception {
1174
1175         MultipartOutput multipart = new MultipartOutput();
1176         String stringObject = getXmlDocumentAsString(commonPartFileName);
1177         if (logger.isDebugEnabled()) {
1178             logger.debug(testName + " to be created, collectionobject common " + "\n" + stringObject);
1179         }
1180         OutputPart commonPart = multipart.addPart(stringObject,
1181                 MediaType.APPLICATION_XML_TYPE);
1182         commonPart.getHeaders().add("label", commonPartName);
1183
1184         return multipart;
1185
1186     }
1187
1188     /**
1189      * Gets the nH part name.
1190      *
1191      * @return the nH part name
1192      */
1193     private String getNHPartName() {
1194         return "collectionobjects_naturalhistory";
1195     }
1196
1197     /**
1198      * Creates the from xml file.
1199      *
1200      * @param testName the test name
1201      * @param fileName the file name
1202      * @param useJaxb the use jaxb
1203      * @return the string
1204      * @throws Exception the exception
1205      */
1206     private String createFromXmlFile(String testName, String fileName, boolean useJaxb) throws Exception {
1207   
1208         // Perform setup.
1209         setupCreate();
1210
1211         MultipartOutput multipart = null;
1212
1213         CollectionObjectClient client = new CollectionObjectClient();
1214         if (useJaxb) {
1215             multipart = createCollectionObjectInstanceFromXml(testName,
1216                     client.getCommonPartName(), fileName);
1217         } else {
1218             multipart = createCollectionObjectInstanceFromRawXml(testName,
1219                     client.getCommonPartName(), fileName);
1220         }
1221         ClientResponse<Response> res = client.create(multipart);
1222         int statusCode = res.getStatus();
1223
1224         if (logger.isDebugEnabled()) {
1225             logger.debug(testName + ": status = " + statusCode);
1226         }
1227         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1228                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1229         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1230         String newId = extractId(res);
1231         allResourceIdsCreated.add(newId);
1232         return newId;
1233     }
1234 }