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