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