2 * This document is a part of the source code and related artifacts
3 * for CollectionSpace, an open source collections management system
4 * for museums and related institutions:
6 * http://www.collectionspace.org
7 * http://wiki.collectionspace.org
9 * Copyright © 2009 Regents of the University of California
11 * Licensed under the Educational Community License (ECL), Version 2.0.
12 * You may not use this file except in compliance with this License.
14 * You may obtain a copy of the ECL 2.0 License at
15 * https://source.collectionspace.org/collection-space/LICENSE.txt
17 * Unless required by applicable law or agreed to in writing, software
18 * distributed under the License is distributed on an "AS IS" BASIS,
19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 * See the License for the specific language governing permissions and
21 * limitations under the License.
23 package org.collectionspace.services.client.test;
25 import java.math.BigDecimal;
26 import java.math.BigInteger;
27 import java.util.List;
29 import javax.ws.rs.core.MediaType;
30 import javax.ws.rs.core.Response;
45 //import org.collectionspace.services.client.AbstractServiceClientImpl;
46 import org.collectionspace.services.client.CollectionObjectClient;
47 import org.collectionspace.services.client.CollectionObjectFactory;
48 import org.collectionspace.services.client.CollectionSpaceClient;
49 import org.collectionspace.services.client.PayloadOutputPart;
50 import org.collectionspace.services.client.PoxPayloadOut;
51 import org.collectionspace.services.collectionobject.BriefDescriptionList;
52 import org.collectionspace.services.collectionobject.CollectionobjectsCommon;
53 import org.collectionspace.services.collectionobject.domain.naturalhistory.CollectionobjectsNaturalhistory;
54 import org.collectionspace.services.collectionobject.DimensionSubGroup;
55 import org.collectionspace.services.collectionobject.DimensionSubGroupList;
56 import org.collectionspace.services.collectionobject.MeasuredPartGroup;
57 import org.collectionspace.services.collectionobject.MeasuredPartGroupList;
58 import org.collectionspace.services.collectionobject.ObjectNameGroup;
59 import org.collectionspace.services.collectionobject.ObjectNameList;
60 import org.collectionspace.services.collectionobject.OtherNumberList;
61 import org.collectionspace.services.collectionobject.OtherNumber;
62 import org.collectionspace.services.collectionobject.ResponsibleDepartmentList;
63 import org.collectionspace.services.collectionobject.TitleGroup;
64 import org.collectionspace.services.collectionobject.TitleGroupList;
65 import org.collectionspace.services.jaxb.AbstractCommonList;
66 import org.testng.Assert;
67 import org.testng.annotations.Test;
68 import org.slf4j.Logger;
69 import org.slf4j.LoggerFactory;
72 * CollectionObjectServiceTest, carries out tests against a
73 * deployed and running CollectionObject Service.
75 * $LastChangedRevision$
78 public class CollectionObjectServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonList, CollectionobjectsCommon> {
81 private final String CLASS_NAME = CollectionObjectServiceTest.class.getName();
82 private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
84 private final String OBJECT_NAME_VALUE = "an object name";
85 private final BigInteger AGE_VALUE = new BigInteger("55");
86 private final String MEASURED_PART = "light box frame";
87 private final BigDecimal DIMENSION_VALUE_LENGTH = new BigDecimal("0.009");
88 private final BigDecimal DIMENSION_VALUE_WIDTH = new BigDecimal("3087.56");
89 private final String UPDATED_MEASUREMENT_UNIT = "Angstroms";
90 private final String UTF8_DATA_SAMPLE = "Audiorecording album cover signed by Lech "
91 + "Wa" + '\u0142' + '\u0119' + "sa";
94 // * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
97 // protected String getServicePathComponent() {
98 // return new CollectionObjectClient().getServicePathComponent();
102 protected String getServiceName() {
103 return CollectionObjectClient.SERVICE_NAME;
107 * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
110 protected CollectionSpaceClient getClientInstance() throws Exception {
111 return new CollectionObjectClient();
115 protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
116 return new CollectionObjectClient(clientPropertiesFilename);
119 // ---------------------------------------------------------------
120 // CRUD tests : CREATE tests
121 // ---------------------------------------------------------------
122 // Expected success outcomes
125 * For convenience and terseness, this test method is the base of the test execution dependency chain. Other test methods may
126 * refer to this method in their @Test annotation declarations.
129 @Test(dataProvider = "testName",
131 "org.collectionspace.services.client.test.AbstractServiceTestImpl.baseCRUDTests"})
132 public void CRUDTests(String testName) {
133 // Do nothing. Simply here to for a TestNG execution order for our tests
137 * Tests to diagnose and verify the fixed status of CSPACE-1026,
138 * "Whitespace at certain points in payload cause failure"
142 * Creates the from xml cambridge.
144 * @param testName the test name
145 * @throws Exception the exception
147 @Test(dataProvider = "testName",
148 dependsOnMethods = {"CRUDTests"})
149 public void createFromXmlCambridge(String testName) throws Exception {
151 createFromXmlFile(testName, "./test-data/testCambridge.xml", true);
152 testSubmitRequest(newId);
156 * Tests to diagnose and fix CSPACE-2242.
158 * This is a bug identified in release 0.8 in which value instances of a
159 * repeatable field are not stored when the first value instance of that
163 // Verify that record creation occurs successfully when the first value instance
164 // of a single, repeatable String scalar field is non-blank.
165 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
166 dependsOnMethods = {"CRUDTests"}, groups = {"cspace2242group"})
167 public void createFromXmlNonBlankFirstValueInstance(String testName) throws Exception {
169 createFromXmlFile(testName, "./test-data/cspace-2242-first-value-instance-nonblank.xml", true);
170 CollectionobjectsCommon collectionObject = readCollectionObjectCommonPart(newId);
171 // Verify that at least one value instance of the repeatable field was successfully persisted.
172 BriefDescriptionList descriptionList = collectionObject.getBriefDescriptions();
173 List<String> descriptions = descriptionList.getBriefDescription();
174 Assert.assertTrue(descriptions.size() > 0);
177 // Verify that record creation occurs successfully when the first value instance
178 // of a single, repeatable String scalar field is blank.
179 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
180 dependsOnMethods = {"CRUDTests"}, groups = {"cspace2242group"})
181 public void createFromXmlBlankFirstValueInstance(String testName) throws Exception {
183 createFromXmlFile(testName, "./test-data/cspace-2242-first-value-instance-blank.xml", true);
184 CollectionobjectsCommon collectionObject = readCollectionObjectCommonPart(newId);
185 // Verify that at least one value instance of the repeatable field was successfully persisted.
186 BriefDescriptionList descriptionList = collectionObject.getBriefDescriptions();
187 List<String> descriptions = descriptionList.getBriefDescription();
188 Assert.assertTrue(descriptions.size() > 0);
191 // Verify that values are preserved when enclosed in double quote marks.
192 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
193 dependsOnMethods = {"CRUDTests"}, groups = {"cspace3237group"})
194 public void doubleQuotesEnclosingFieldContents(String testName) throws Exception {
196 createFromXmlFile(testName, "./test-data/cspace-3237-double-quotes.xml", true);
197 CollectionobjectsCommon collectionObject = readCollectionObjectCommonPart(newId);
199 Assert.assertTrue(collectionObject.getDistinguishingFeatures().matches("^\\\".+?\\\"$"));
201 BriefDescriptionList descriptionList = collectionObject.getBriefDescriptions();
202 List<String> descriptions = descriptionList.getBriefDescription();
203 Assert.assertTrue(descriptions.size() > 0);
204 Assert.assertNotNull(descriptions.get(0));
205 Assert.assertTrue(descriptions.get(0).matches("^\\\".+?\\\"$"));
207 if (logger.isDebugEnabled()) {
208 logger.debug(objectAsXmlString(collectionObject,
209 CollectionobjectsCommon.class));
214 * Creates the from xml rfw s1.
216 * @param testName the test name
217 * @throws Exception the exception
219 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
220 dependsOnMethods = {"CRUDTests"})
221 public void createFromXmlRFWS1(String testName) throws Exception {
222 String testDataDir = System.getProperty("test-data.fileName");
224 //createFromXmlFile(testName, "./target/test-classes/test-data/repfield_whitesp1.xml", false);
225 createFromXmlFile(testName, testDataDir + "/repfield_whitesp1.xml", false);
226 testSubmitRequest(newId);
230 * Creates the from xml rfw s2.
232 * @param testName the test name
233 * @throws Exception the exception
235 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
236 dependsOnMethods = {"CRUDTests"})
237 public void createFromXmlRFWS2(String testName) throws Exception {
238 String testDataDir = System.getProperty("test-data.fileName");
240 //createFromXmlFile(testName, "./target/test-classes/test-data/repfield_whitesp2.xml", false);
241 createFromXmlFile(testName, testDataDir + "/repfield_whitesp2.xml", false);
242 testSubmitRequest(newId);
246 * Creates the from xml rfw s3.
248 * @param testName the test name
249 * @throws Exception the exception
251 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
252 dependsOnMethods = {"CRUDTests"})
253 public void createFromXmlRFWS3(String testName) throws Exception {
254 String testDataDir = System.getProperty("test-data.fileName");
256 //createFromXmlFile(testName, "./target/test-classes/test-data/repfield_whitesp3.xml", false);
257 createFromXmlFile(testName, testDataDir + "/repfield_whitesp3.xml", false);
258 testSubmitRequest(newId);
262 * Creates the from xml rfw s4.
264 * @param testName the test name
265 * @throws Exception the exception
267 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
268 dependsOnMethods = {"CRUDTests"})
269 public void createFromXmlRFWS4(String testName) throws Exception {
270 String testDataDir = System.getProperty("test-data.fileName");
272 createFromXmlFile(testName, testDataDir + "/repfield_whitesp4.xml", false);
273 testSubmitRequest(newId);
277 * Tests to diagnose and verify the fixed status of CSPACE-1248,
278 * "Wedged records created!" (i.e. records with child repeatable
279 * fields, which contain null values, can be successfully created
280 * but an error occurs on trying to retrieve those records).
284 * Creates a CollectionObject resource with a null value repeatable field.
286 * @param testName the test name
287 * @throws Exception the exception
289 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
290 dependsOnMethods = {"CRUDTests"})
291 public void createWithNullValueRepeatableField(String testName) throws Exception {
292 String testDataDir = System.getProperty("test-data.fileName");
294 createFromXmlFile(testName, testDataDir + "/repfield_null1.xml", false);
295 if (logger.isDebugEnabled()) {
296 logger.debug("Successfully created record with null value repeatable field.");
297 logger.debug("Attempting to retrieve just-created record ...");
299 testSubmitRequest(newId);
303 * Creates a CollectionObject resource, one of whose fields contains
304 * non-Latin 1 Unicode UTF-8 characters.
306 * @param testName the test name
307 * @throws Exception the exception
309 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
310 dependsOnMethods = {"CRUDTests"}, groups={"utf8-create"})
311 public void createWithUTF8Data(String testName) throws Exception {
312 String testDataDir = System.getProperty("test-data.fileName");
314 createFromXmlFile(testName, testDataDir + "/cspace-2779-utf-8-create.xml", false);
315 if (logger.isDebugEnabled()) {
316 logger.debug("Created record with UTF-8 chars in payload.");
317 logger.debug("Attempting to retrieve just-created record ...");
319 CollectionobjectsCommon collectionObject = readCollectionObjectCommonPart(newId);
320 String distinguishingFeatures = collectionObject.getDistinguishingFeatures();
321 if (logger.isDebugEnabled()) {
322 logger.debug("Sent distinguishingFeatures: " + UTF8_DATA_SAMPLE);
323 logger.debug("Received distinguishingFeatures: " + distinguishingFeatures);
325 Assert.assertTrue(distinguishingFeatures.equals(UTF8_DATA_SAMPLE));
329 // Placeholders until the three tests below can be uncommented.
330 // See Issue CSPACE-401.
332 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
335 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
336 public void createWithEmptyEntityBody(String testName) throws Exception {
337 //FIXME: Should this test really be empty?
341 * Test how the service handles XML that is not well formed,
342 * when sent in the payload of a Create request.
344 * @param testName The name of this test method. This name is supplied
345 * automatically, via reflection, by a TestNG 'data provider' in
349 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
350 public void createWithMalformedXml(String testName) throws Exception {
351 //FIXME: Should this test really be empty?
355 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
358 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
359 public void createWithWrongXmlSchema(String testName) throws Exception {
360 //FIXME: Should this test really be empty?
366 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
367 dependsOnMethods = {"create", "testSubmitRequest"})
368 public void createWithEmptyEntityBody(String testName) throwsException {
370 if (logger.isDebugEnabled()) {
371 logger.debug(testBanner(testName, CLASS_NAME));
374 setupCreateWithEmptyEntityBody();
376 // Submit the request to the service and store the response.
377 String method = REQUEST_TYPE.httpMethodName();
378 String url = getServiceRootURL();
379 String mediaType = MediaType.APPLICATION_XML;
380 final String entity = "";
381 int statusCode = submitRequest(method, url, mediaType, entity);
383 // Check the status code of the response: does it match
384 // the expected response(s)?
385 if(logger.isDebugEnabled()){
386 logger.debug(testName + ": url=" + url +
387 " status=" + statusCode);
389 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
390 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
391 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
395 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
396 dependsOnMethods = {"create", "testSubmitRequest"})
397 public void createWithMalformedXml(String testName) throws Exception {
399 if (logger.isDebugEnabled()) {
400 logger.debug(testBanner(testName, CLASS_NAME));
403 setupCreateWithMalformedXml();
405 // Submit the request to the service and store the response.
406 String method = REQUEST_TYPE.httpMethodName();
407 String url = getServiceRootURL();
408 String mediaType = MediaType.APPLICATION_XML;
409 final String entity = MALFORMED_XML_DATA; // Constant from base class.
410 int statusCode = submitRequest(method, url, mediaType, entity);
412 // Check the status code of the response: does it match
413 // the expected response(s)?
414 if(logger.isDebugEnabled()){
415 logger.debug(testName + ": url=" + url +
416 " status=" + statusCode);
418 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
419 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
420 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
424 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
425 dependsOnMethods = {"create", "testSubmitRequest"})
426 public void createWithWrongXmlSchema(String testName) throws Exception {
428 if (logger.isDebugEnabled()) {
429 logger.debug(testBanner(testName, CLASS_NAME));
432 setupCreateWithWrongXmlSchema();
434 // Submit the request to the service and store the response.
435 String method = REQUEST_TYPE.httpMethodName();
436 String url = getServiceRootURL();
437 String mediaType = MediaType.APPLICATION_XML;
438 final String entity = WRONG_XML_SCHEMA_DATA;
439 int statusCode = submitRequest(method, url, mediaType, entity);
441 // Check the status code of the response: does it match
442 // the expected response(s)?
443 if(logger.isDebugEnabled()){
444 logger.debug(testName + ": url=" + url +
445 " status=" + statusCode);
447 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
448 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
449 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
454 * Test how the service handles, in a Create request, payloads
455 * containing null values (or, in the case of String fields,
456 * empty String values) in one or more fields which must be
457 * present and are required to contain non-empty values.
459 * This is a test of code and/or configuration in the service's
460 * validation routine(s).
462 * @param testName The name of this test method. This name is supplied
463 * automatically, via reflection, by a TestNG 'data provider' in
467 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
468 public void createWithRequiredValuesNullOrEmpty(String testName) throws Exception {
471 // Build a payload with invalid content, by omitting a
472 // field (objectNumber) which must be present, and in which
473 // a non-empty value is required, as enforced by the service's
474 // validation routine(s).
475 CollectionobjectsCommon collectionObject = new CollectionobjectsCommon();
477 TitleGroupList titleGroupList = new TitleGroupList();
478 List<TitleGroup> titleGroups = titleGroupList.getTitleGroup();
479 TitleGroup titleGroup = new TitleGroup();
480 titleGroup.setTitle("a title");
481 titleGroups.add(titleGroup);
482 collectionObject.setTitleGroupList(titleGroupList);
484 ObjectNameList objNameList = new ObjectNameList();
485 List<ObjectNameGroup> objNameGroups = objNameList.getObjectNameGroup();
486 ObjectNameGroup objectNameGroup = new ObjectNameGroup();
487 objectNameGroup.setObjectName("an object name");
488 objNameGroups.add(objectNameGroup);
489 collectionObject.setObjectNameList(objNameList);
491 // Submit the request to the service and store the response.
492 CollectionObjectClient client = new CollectionObjectClient();
493 PoxPayloadOut multipart =
494 createCollectionObjectInstance(client.getCommonPartName(), collectionObject, null);
495 Response res = client.create(multipart);
497 int statusCode = res.getStatus();
498 // Read the response and verify that the create attempt failed.
499 if (logger.isDebugEnabled()) {
500 logger.debug(testName + ": status = " + statusCode);
502 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
503 invalidStatusCodeMessage(testRequestType, statusCode));
504 Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
509 // FIXME: Consider splitting off the following into its own test method.
511 // Build a payload with invalid content, by setting a value to the
512 // empty String, in a field (objectNumber) that requires a non-empty
513 // value, as enforced by the service's validation routine(s).
514 collectionObject = new CollectionobjectsCommon();
515 collectionObject.setObjectNumber("");
516 collectionObject.setDistinguishingFeatures("Distinguishing features.");
518 objNameList = new ObjectNameList();
519 objNameGroups = objNameList.getObjectNameGroup();
520 objectNameGroup = new ObjectNameGroup();
521 objectNameGroup.setObjectName(OBJECT_NAME_VALUE);
522 objNameGroups.add(objectNameGroup);
523 collectionObject.setObjectNameList(objNameList);
525 // Submit the request to the service and store the response.
526 multipart = createCollectionObjectInstance(client.getCommonPartName(), collectionObject, null);
527 res = client.create(multipart);
529 int statusCode = res.getStatus();
531 // Read the response and verify that the create attempt failed.
532 if (logger.isDebugEnabled()) {
533 logger.debug(testName + ": status = " + statusCode);
535 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
536 invalidStatusCodeMessage(testRequestType, statusCode));
537 Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
546 * @param testName the test name
548 * @return the client response
551 private Response updateRetrieve(String testName, String id) throws Exception {
553 CollectionObjectClient client = new CollectionObjectClient();
554 Response res = client.read(knownResourceId);
555 int statusCode = res.getStatus();
556 // Check the status code of the response: does it match
557 // the expected response(s)?
558 if (logger.isDebugEnabled()) {
559 logger.debug(testName + ": read status = " + statusCode);
561 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
562 invalidStatusCodeMessage(testRequestType, statusCode));
563 Assert.assertEquals(statusCode, testExpectedStatusCode);
564 if(logger.isDebugEnabled()){
565 logger.debug("got object to update with ID: " + knownResourceId);
574 * @param testName the test name
576 * @return the client response
579 private Response updateSend(String testName, String id,
580 CollectionobjectsCommon collectionObjectCommon) throws Exception {
582 PoxPayloadOut output = new PoxPayloadOut(CollectionObjectClient.SERVICE_PAYLOAD_NAME);
583 PayloadOutputPart commonPart = output.addPart(collectionObjectCommon, MediaType.APPLICATION_XML_TYPE);
584 CollectionObjectClient client = new CollectionObjectClient();
585 commonPart.setLabel(client.getCommonPartName());
587 Response res = client.update(knownResourceId, output);
588 int statusCode = res.getStatus();
589 // Check the status code of the response: does it match
590 // the expected response(s)?
591 if (logger.isDebugEnabled()) {
592 logger.debug(testName + ": read status = " + statusCode);
594 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
595 invalidStatusCodeMessage(testRequestType, statusCode));
596 Assert.assertEquals(statusCode, testExpectedStatusCode);
598 return res; // Calling needs to make sure they call res.close();
602 // Placeholders until the three tests below can be uncommented.
603 // See Issue CSPACE-401.
605 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
608 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
609 dependsOnMethods = {"CRUDTests"})
610 public void updateWithEmptyEntityBody(String testName) throws Exception {
611 //FIXME: Should this test really be empty?
615 * Test how the service handles XML that is not well formed,
616 * when sent in the payload of an Update request.
618 * @param testName The name of this test method. This name is supplied
619 * automatically, via reflection, by a TestNG 'data provider' in
623 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
624 dependsOnMethods = {"CRUDTests"})
625 public void updateWithMalformedXml(String testName) throws Exception {
626 //FIXME: Should this test really be empty?
630 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
633 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
634 dependsOnMethods = {"CRUDTests"})
635 public void updateWithWrongXmlSchema(String testName) throws Exception {
636 //FIXME: Should this test really be empty?
641 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
642 dependsOnMethods = {"create", "update", "testSubmitRequest"})
643 public void updateWithEmptyEntityBody(String testName) throws Exception {
645 if (logger.isDebugEnabled()) {
646 logger.debug(testBanner(testName, CLASS_NAME));
649 setupUpdateWithEmptyEntityBody();
651 // Submit the request to the service and store the response.
652 String method = REQUEST_TYPE.httpMethodName();
653 String url = getResourceURL(knownResourceId);
654 String mediaType = MediaType.APPLICATION_XML;
655 final String entity = "";
656 int statusCode = submitRequest(method, url, mediaType, entity);
658 // Check the status code of the response: does it match
659 // the expected response(s)?
660 if(logger.isDebugEnabled()){
661 logger.debug(testName + ": url=" + url +
662 " status=" + statusCode);
664 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
665 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
666 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
670 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
671 dependsOnMethods = {"create", "update", "testSubmitRequest"})
672 public void updateWithMalformedXml() throws Exception {
674 if (logger.isDebugEnabled()) {
675 logger.debug(testBanner(testName, CLASS_NAME));
678 setupUpdateWithMalformedXml();
680 // Submit the request to the service and store the response.
681 String method = REQUEST_TYPE.httpMethodName();
682 String url = getResourceURL(knownResourceId);
683 final String entity = MALFORMED_XML_DATA;
684 String mediaType = MediaType.APPLICATION_XML;
685 int statusCode = submitRequest(method, url, mediaType, entity);
687 // Check the status code of the response: does it match
688 // the expected response(s)?
689 if(logger.isDebugEnabled()){
690 logger.debug(testName + ": url=" + url +
691 " status=" + statusCode);
693 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
694 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
695 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
699 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
700 dependsOnMethods = {"create", "update", "testSubmitRequest"})
701 public void updateWithWrongXmlSchema(String testName) throws Exception {
703 if (logger.isDebugEnabled()) {
704 logger.debug(testBanner(testName, CLASS_NAME));
707 setupUpdateWithWrongXmlSchema();
709 // Submit the request to the service and store the response.
710 String method = REQUEST_TYPE.httpMethodName();
711 String url = getResourceURL(knownResourceId);
712 String mediaType = MediaType.APPLICATION_XML;
713 final String entity = WRONG_XML_SCHEMA_DATA;
714 int statusCode = submitRequest(method, url, mediaType, entity);
716 // Check the status code of the response: does it match
717 // the expected response(s)?
718 if(logger.isDebugEnabled()){
719 logger.debug(testName + ": url=" + url +
720 " status=" + statusCode);
722 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
723 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
724 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
729 public void updateNonExistent(String testName) throws Exception {
731 setupUpdateNonExistent();
733 // Submit the request to the service and store the response.
735 // Note: The ID used in this 'create' call may be arbitrary.
736 // The only relevant ID may be the one used in updateCollectionObject(), below.
737 CollectionObjectClient client = new CollectionObjectClient();
738 PoxPayloadOut multipart =
739 createInstance(client.getCommonPartName(), NON_EXISTENT_ID);
740 Response res = client.update(NON_EXISTENT_ID, multipart);
742 int statusCode = res.getStatus();
743 // Check the status code of the response: does it match
744 // the expected response(s)?
745 if (logger.isDebugEnabled()) {
746 logger.debug(testName + ": status = " + statusCode);
748 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
749 invalidStatusCodeMessage(testRequestType, statusCode));
750 Assert.assertEquals(statusCode, testExpectedStatusCode);
757 * Test how the service handles, in an Update request, payloads
758 * containing null values (or, in the case of String fields,
759 * empty String values) in one or more fields in which non-empty
760 * values are required.
762 * This is a test of code and/or configuration in the service's
763 * validation routine(s).
765 * @param testName The name of this test method. This name is supplied
766 * automatically, via reflection, by a TestNG 'data provider' in
770 // @Test(dataProvider = "testName", dependsOnMethods = {"CRUDTests"}) // REM - Disabled this test because of issues raised in CSPACE-6705
771 public void updateWithRequiredValuesNullOrEmpty(String testName) throws Exception {
772 // Read an existing record for updating.
773 Response res = updateRetrieve(testName, knownResourceId);
774 CollectionobjectsCommon collectionObjectCommon = null;
776 // Extract its common part.
777 collectionObjectCommon = extractCommonPartValue(res);
782 // Update the common part with invalid content, by setting a value to
783 // the empty String, in a field that requires a non-empty value,
784 // as enforced by the service's validation routine(s).
785 collectionObjectCommon.setObjectNumber("");
787 if (logger.isDebugEnabled()) {
788 logger.debug(testName + " updated object");
789 logger.debug(objectAsXmlString(collectionObjectCommon,
790 CollectionobjectsCommon.class));
793 // Submit the request to the service and store the response.
795 PoxPayloadOut output = new PoxPayloadOut(CollectionObjectClient.SERVICE_PAYLOAD_NAME);
796 CollectionObjectClient client = new CollectionObjectClient();
797 output.addPart(client.getCommonPartName(), collectionObjectCommon);
798 res = client.update(knownResourceId, output);
801 int statusCode = res.getStatus();
802 // Read the response and verify that the update attempt failed.
803 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
804 invalidStatusCodeMessage(testRequestType, statusCode));
805 Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
811 // ---------------------------------------------------------------
812 // CRUD tests : DELETE tests
813 // ---------------------------------------------------------------
817 public void delete(String testName) throws Exception {
819 // Create an object to delete, save the current 'knownResourceId' since we don't want to delete it yet
820 // and temporarily set it to the csid of the resource we just created.
822 String tempCsid = knownResourceId;
823 // the super.delete() method uses the knownResourceId member
824 knownResourceId = newCollectionObject(true);
827 super.delete(testName);
829 // reset the 'knownResourceId'
830 knownResourceId = tempCsid;
835 // Expected failure outcome tests
839 public void deleteNonExistent(String testName) throws Exception {
841 setupDeleteNonExistent();
843 // Submit the request to the service and store the response.
844 CollectionObjectClient client = new CollectionObjectClient();
845 Response res = client.delete(NON_EXISTENT_ID);
847 int statusCode = res.getStatus();
849 // Check the status code of the response: does it match
850 // the expected response(s)?
851 if (logger.isDebugEnabled()) {
852 logger.debug(testName + ": status = " + statusCode);
854 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
855 invalidStatusCodeMessage(testRequestType, statusCode));
856 Assert.assertEquals(statusCode, testExpectedStatusCode);
862 // ---------------------------------------------------------------
863 // Utility tests : tests of code used in tests above
864 // ---------------------------------------------------------------
867 * Tests the code for manually submitting data that is used by several
868 * of the methods above.
872 // ---------------------------------------------------------------
873 // Utility methods used by tests above
874 // ---------------------------------------------------------------
876 private Response newCollectionObject() throws Exception {
877 Response result = null;
879 CollectionObjectClient client = new CollectionObjectClient();
880 String identifier = createIdentifier();
881 PoxPayloadOut multipart =
882 createInstance(client.getCommonPartName(), identifier);
883 result = client.create(multipart);
888 private String newCollectionObject(boolean assertStatus) throws Exception {
889 String result = null;
891 Response res = newCollectionObject();
893 int statusCode = res.getStatus();
894 Assert.assertEquals(statusCode, STATUS_CREATED);
895 result = extractId(res);
904 protected PoxPayloadOut createInstance(String identifier) {
905 String commonPartName = CollectionObjectClient.SERVICE_COMMON_PART_NAME;
906 return createInstance(commonPartName, identifier);
910 * Creates the collection object instance.
912 * @param commonPartName the common part name
913 * @param identifier the identifier
914 * @return the multipart output
917 protected PoxPayloadOut createInstance(String commonPartName,
919 return createCollectionObjectInstance(commonPartName,
920 "objectNumber-" + identifier,
921 "objectName-" + identifier);
925 * Creates the collection object instance.
927 * @param commonPartName the common part name
928 * @param objectNumber the object number
929 * @param objectName the object name
930 * @return the multipart output
932 private PoxPayloadOut createCollectionObjectInstance(String commonPartName,
933 String objectNumber, String objectName) {
934 CollectionobjectsCommon collectionObject = new CollectionobjectsCommon();
937 collectionObject.setObjectNumber(objectNumber);
938 collectionObject.setAge(AGE_VALUE); //test for null string
940 // Repeatable structured groups
942 TitleGroupList titleGroupList = new TitleGroupList();
943 List<TitleGroup> titleGroups = titleGroupList.getTitleGroup();
944 Assert.assertNotNull(titleGroups);
945 TitleGroup titleGroup = new TitleGroup();
946 titleGroup.setTitle("a title");
947 titleGroups.add(titleGroup);
948 collectionObject.setTitleGroupList(titleGroupList);
950 ObjectNameList objNameList = new ObjectNameList();
951 List<ObjectNameGroup> objNameGroups = objNameList.getObjectNameGroup();
952 ObjectNameGroup objectNameGroup = new ObjectNameGroup();
953 objectNameGroup.setObjectName(OBJECT_NAME_VALUE);
954 objNameGroups.add(objectNameGroup);
955 collectionObject.setObjectNameList(objNameList);
957 MeasuredPartGroupList measuredPartGroupList = new MeasuredPartGroupList();
958 List<MeasuredPartGroup> measuredPartGroups = measuredPartGroupList.getMeasuredPartGroup();
959 Assert.assertNotNull(measuredPartGroups, "Measured part groups are null");
960 MeasuredPartGroup measuredPartGroup = new MeasuredPartGroup();
961 measuredPartGroup.setMeasuredPart(MEASURED_PART);
963 DimensionSubGroupList dimensionSubGroupList = new DimensionSubGroupList();
964 List<DimensionSubGroup> dimensionSubGroups = dimensionSubGroupList.getDimensionSubGroup();
965 Assert.assertNotNull(dimensionSubGroups, "Dimension subgroups are null");
967 DimensionSubGroup lengthDimension = new DimensionSubGroup();
968 lengthDimension.setDimension("length");
969 lengthDimension.setValue(DIMENSION_VALUE_LENGTH);
970 lengthDimension.setMeasurementUnit("cm");
971 dimensionSubGroups.add(lengthDimension);
973 DimensionSubGroup widthDimension = new DimensionSubGroup();
974 widthDimension.setDimension("width");
975 widthDimension.setValue(DIMENSION_VALUE_WIDTH);
976 widthDimension.setMeasurementUnit("m");
977 widthDimension.setValueQualifier(""); // test empty string
978 dimensionSubGroups.add(widthDimension);
980 measuredPartGroup.setDimensionSubGroupList(dimensionSubGroupList);
981 measuredPartGroups.add(measuredPartGroup);
982 collectionObject.setMeasuredPartGroupList(measuredPartGroupList);
984 // Repeatable scalar fields
986 BriefDescriptionList descriptionList = new BriefDescriptionList();
987 List<String> descriptions = descriptionList.getBriefDescription();
988 descriptions.add("Papier mache bird cow mask with horns, "
989 + "painted red with black and yellow spots. "
990 + "Puerto Rico. ca. 8" high, 6" wide, projects 10" (with horns).");
991 descriptions.add("Acrylic rabbit mask with wings, "
992 + "painted red with green and aquamarine spots. "
993 + "Puerto Rico. ca. 8" high, 6" wide, projects 10" (with wings).");
994 collectionObject.setBriefDescriptions(descriptionList);
996 ResponsibleDepartmentList deptList = new ResponsibleDepartmentList();
997 List<String> depts = deptList.getResponsibleDepartment();
998 // @TODO Use properly formatted refNames for representative departments
999 // in this example test record. The following are mere placeholders.
1000 depts.add("urn:org.collectionspace.services.department:Registrar");
1001 depts.add("urn:org.walkerart.department:Fine Art");
1002 collectionObject.setResponsibleDepartments(deptList);
1004 OtherNumberList otherNumList = new OtherNumberList();
1005 List<OtherNumber> otherNumbers = otherNumList.getOtherNumber();
1006 OtherNumber otherNumber1 = new OtherNumber();
1007 otherNumber1.setNumberValue("101." + objectName);
1008 otherNumber1.setNumberType("integer");
1009 otherNumbers.add(otherNumber1);
1010 OtherNumber otherNumber2 = new OtherNumber();
1011 otherNumber2.setNumberValue("101.502.23.456." + objectName);
1012 otherNumber2.setNumberType("ipaddress");
1013 otherNumbers.add(otherNumber2);
1014 collectionObject.setOtherNumberList(otherNumList);
1016 // Add instances of fields from an extension schema
1018 CollectionobjectsNaturalhistory conh = new CollectionobjectsNaturalhistory();
1019 // Laramie20110524 removed for build: conh.setNhString("test-string");
1020 // Laramie20110524 removed for build: conh.setNhInt(999);
1021 // Laramie20110524 removed for build: conh.setNhLong(9999);
1023 PoxPayloadOut multipart = createCollectionObjectInstance(commonPartName, collectionObject, conh);
1028 * Creates the collection object instance.
1030 * @param commonPartName the common part name
1031 * @param collectionObject the collection object
1032 * @param conh the conh
1033 * @return the multipart output
1035 private PoxPayloadOut createCollectionObjectInstance(String commonPartName,
1036 CollectionobjectsCommon collectionObject, CollectionobjectsNaturalhistory conh) {
1038 PoxPayloadOut multipart = CollectionObjectFactory.createCollectionObjectInstance(
1039 commonPartName, collectionObject, getNHPartName(), conh);
1040 if (logger.isDebugEnabled()) {
1041 logger.debug("to be created, collectionobject common");
1042 logger.debug(objectAsXmlString(collectionObject,
1043 CollectionobjectsCommon.class));
1047 if (logger.isDebugEnabled()) {
1048 logger.debug("to be created, collectionobject nhistory");
1049 logger.debug(objectAsXmlString(conh,
1050 CollectionobjectsNaturalhistory.class));
1058 * createCollectionObjectInstanceFromXml uses JAXB unmarshaller to retrieve
1059 * collectionobject from given file
1060 * @param commonPartName
1061 * @param commonPartFileName
1065 private PoxPayloadOut createCollectionObjectInstanceFromXml(String testName, String commonPartName,
1066 String commonPartFileName) throws Exception {
1068 CollectionobjectsCommon collectionObject =
1069 (CollectionobjectsCommon) getObjectFromFile(CollectionobjectsCommon.class,
1070 commonPartFileName);
1071 PoxPayloadOut multipart = new PoxPayloadOut(CollectionObjectClient.SERVICE_PAYLOAD_NAME);
1072 PayloadOutputPart commonPart = multipart.addPart(collectionObject,
1073 MediaType.APPLICATION_XML_TYPE);
1074 CollectionObjectClient client = new CollectionObjectClient();
1075 commonPart.setLabel(client.getCommonPartName());
1077 if (logger.isDebugEnabled()) {
1078 logger.debug(testName + " to be created, collectionobject common");
1079 logger.debug(objectAsXmlString(collectionObject,
1080 CollectionobjectsCommon.class));
1087 * createCollectionObjectInstanceFromRawXml uses stringified collectionobject
1088 * retrieve from given file
1089 * @param commonPartName
1090 * @param commonPartFileName
1094 private PoxPayloadOut createCollectionObjectInstanceFromRawXml(String testName, String commonPartName,
1095 String commonPartFileName) throws Exception {
1097 PoxPayloadOut multipart = new PoxPayloadOut(CollectionObjectClient.SERVICE_PAYLOAD_NAME);
1098 String stringObject = getXmlDocumentAsString(commonPartFileName);
1099 if (logger.isDebugEnabled()) {
1100 logger.debug(testName + " to be created, collectionobject common " + "\n" + stringObject);
1102 PayloadOutputPart commonPart = multipart.addPart(commonPartName, stringObject);
1103 // commonPart.setLabel(commonPartName);
1109 * Gets the nH part name.
1111 * @return the nH part name
1113 private String getNHPartName() {
1114 return "collectionobjects_naturalhistory";
1118 * Creates the from xml file.
1120 * @param testName the test name
1121 * @param fileName the file name
1122 * @param useJaxb the use jaxb
1123 * @return the string
1124 * @throws Exception the exception
1126 private String createFromXmlFile(String testName, String fileName, boolean useJaxb) throws Exception {
1130 PoxPayloadOut multipart = null;
1132 CollectionObjectClient client = new CollectionObjectClient();
1134 multipart = createCollectionObjectInstanceFromXml(testName,
1135 client.getCommonPartName(), fileName);
1137 multipart = createCollectionObjectInstanceFromRawXml(testName,
1138 client.getCommonPartName(), fileName);
1141 Response res = client.create(multipart);
1142 String newId = null;
1144 int statusCode = res.getStatus();
1145 if (logger.isDebugEnabled()) {
1146 logger.debug(testName + ": status = " + statusCode);
1148 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
1149 invalidStatusCodeMessage(testRequestType, statusCode));
1150 Assert.assertEquals(statusCode, testExpectedStatusCode);
1151 newId = extractId(res);
1152 allResourceIdsCreated.add(newId);
1160 // FIXME: This duplicates code in read(), and should be consolidated.
1161 // This is an expedient to support reading and verifying the contents
1162 // of resources that have been created from test data XML files.
1163 private CollectionobjectsCommon readCollectionObjectCommonPart(String csid)
1166 String testName = "readCollectionObjectCommonPart";
1170 // Submit the request to the service and store the response.
1171 CollectionObjectClient client = new CollectionObjectClient();
1172 Response res = client.read(csid);
1173 CollectionobjectsCommon collectionObject = null;
1175 int statusCode = res.getStatus();
1177 // Check the status code of the response: does it match
1178 // the expected response(s)?
1179 if (logger.isDebugEnabled()) {
1180 logger.debug(testName + ": status = " + statusCode);
1182 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
1183 invalidStatusCodeMessage(testRequestType, statusCode));
1184 Assert.assertEquals(statusCode, testExpectedStatusCode);
1186 // Extract the common part.
1187 collectionObject = extractCommonPartValue(res);
1188 Assert.assertNotNull(collectionObject);
1193 return collectionObject;
1197 protected String getServicePathComponent() {
1198 // TODO Auto-generated method stub
1199 return CollectionObjectClient.SERVICE_PATH_COMPONENT;
1203 protected CollectionobjectsCommon updateInstance(CollectionobjectsCommon collectionObjectCommon) {
1204 collectionObjectCommon.setObjectNumber("updated-" + collectionObjectCommon.getObjectNumber());
1206 // Change the object name in the first value instance in the
1207 // object name repeatable group.
1208 ObjectNameList objNameList = collectionObjectCommon.getObjectNameList();
1209 List<ObjectNameGroup> objNameGroups = objNameList.getObjectNameGroup();
1210 Assert.assertNotNull(objNameGroups);
1211 Assert.assertTrue(objNameGroups.size() >= 1);
1212 String objectName = objNameGroups.get(0).getObjectName();
1213 Assert.assertEquals(objectName, OBJECT_NAME_VALUE);
1214 String updatedObjectName = "updated-" + objectName;
1215 objNameGroups.get(0).setObjectName(updatedObjectName);
1216 collectionObjectCommon.setObjectNameList(objNameList);
1218 // Replace the existing value instances in the dimensions repeatable group
1219 // with entirely new value instances, also changing the number of such instances.
1220 MeasuredPartGroupList measuredPartGroupList = collectionObjectCommon.getMeasuredPartGroupList();
1221 Assert.assertNotNull(measuredPartGroupList);
1222 List<MeasuredPartGroup> measuredPartGroups = measuredPartGroupList.getMeasuredPartGroup();
1223 Assert.assertNotNull(measuredPartGroups);
1224 Assert.assertTrue(measuredPartGroups.size() > 0);
1225 MeasuredPartGroup mpGroup = measuredPartGroups.get(0);
1226 Assert.assertNotNull(mpGroup.getMeasuredPart());
1228 DimensionSubGroupList dimensionSubGroupList = mpGroup.getDimensionSubGroupList();
1229 Assert.assertNotNull(dimensionSubGroupList);
1230 List<DimensionSubGroup> dimensionSubGroups = dimensionSubGroupList.getDimensionSubGroup();
1231 Assert.assertNotNull(dimensionSubGroups);
1232 int originalDimensionSubGroupSize = dimensionSubGroups.size();
1233 Assert.assertTrue(dimensionSubGroups.size() > 0);
1234 dimensionSubGroups.clear();
1236 DimensionSubGroup heightDimension = new DimensionSubGroup();
1237 heightDimension.setDimension("height");
1238 heightDimension.setMeasurementUnit(UPDATED_MEASUREMENT_UNIT);
1239 dimensionSubGroups.add(heightDimension);
1241 int updatedDimensionGroupSize = dimensionSubGroups.size();
1242 Assert.assertTrue(updatedDimensionGroupSize > 0);
1243 Assert.assertTrue(updatedDimensionGroupSize != originalDimensionSubGroupSize);
1245 collectionObjectCommon.setMeasuredPartGroupList(measuredPartGroupList);
1247 return collectionObjectCommon;
1251 protected void compareReadInstances(CollectionobjectsCommon original,
1252 CollectionobjectsCommon fromRead) throws Exception {
1253 // Verify the number and contents of values in repeatable fields,
1254 // as created in the instance record used for testing.
1255 MeasuredPartGroupList measuredPartGroupList = fromRead.getMeasuredPartGroupList();
1256 Assert.assertNotNull(measuredPartGroupList, "Measured part group list was null");
1257 List<MeasuredPartGroup> measuredPartGroups = measuredPartGroupList.getMeasuredPartGroup();
1258 Assert.assertNotNull(measuredPartGroups, "Measured part groups were null");
1259 Assert.assertTrue(measuredPartGroups.size() > 0, "No measured part groups were returned");
1260 MeasuredPartGroup mpGroup = measuredPartGroups.get(0);
1261 Assert.assertNotNull(mpGroup.getMeasuredPart(), "Measured part was null");
1262 Assert.assertEquals(mpGroup.getMeasuredPart(), MEASURED_PART,
1263 "Measured part value returned didn't match expected value");
1265 DimensionSubGroupList dimensionSubGroupList = mpGroup.getDimensionSubGroupList();
1266 Assert.assertNotNull(dimensionSubGroupList, "Dimension subgroup list was null");
1267 List<DimensionSubGroup> dimensionSubGroups = dimensionSubGroupList.getDimensionSubGroup();
1268 Assert.assertNotNull(dimensionSubGroups, "Dimension subgroups were null");
1269 Assert.assertTrue(dimensionSubGroups.size() > 0, "No dimension subgroups were returned");
1270 DimensionSubGroup lengthDimension = dimensionSubGroups.get(0);
1271 Assert.assertNotNull(lengthDimension, "Length dimension was null");
1272 Assert.assertTrue(lengthDimension.getValue().compareTo(DIMENSION_VALUE_LENGTH) == 0,
1273 "Dimension length value returned didn't match expected value");
1277 protected void compareUpdatedInstances(CollectionobjectsCommon original,
1278 CollectionobjectsCommon updated) throws Exception {
1280 ObjectNameList objNameList = updated.getObjectNameList();
1281 Assert.assertNotNull(objNameList);
1282 List<ObjectNameGroup> objNameGroups = objNameList.getObjectNameGroup();
1283 Assert.assertNotNull(objNameGroups);
1284 Assert.assertTrue(objNameGroups.size() >= 1);
1285 Assert.assertEquals(original.getObjectNameList().getObjectNameGroup().get(0).getObjectName(),
1286 objNameGroups.get(0).getObjectName(),
1287 "Data in updated object did not match submitted data.");
1289 // Get the dimension group size of the original
1291 MeasuredPartGroupList measuredPartGroupList = original.getMeasuredPartGroupList();
1292 List<MeasuredPartGroup> measuredPartGroups = measuredPartGroupList.getMeasuredPartGroup();
1293 MeasuredPartGroup mpGroup = measuredPartGroups.get(0);
1294 DimensionSubGroupList dimensionSubGroupList = mpGroup.getDimensionSubGroupList();
1295 List<DimensionSubGroup> dimensionSubGroups = dimensionSubGroupList.getDimensionSubGroup();
1296 int updatedDimensionGroupSize = dimensionSubGroups.size();
1298 // Now get the dimension group size of the updated
1300 measuredPartGroupList = updated.getMeasuredPartGroupList();
1301 Assert.assertNotNull(measuredPartGroupList);
1302 measuredPartGroups = measuredPartGroupList.getMeasuredPartGroup();
1303 Assert.assertNotNull(measuredPartGroups);
1304 Assert.assertTrue(measuredPartGroups.size() > 0);
1305 mpGroup = measuredPartGroups.get(0);
1306 Assert.assertNotNull(mpGroup.getMeasuredPart());
1307 dimensionSubGroupList = mpGroup.getDimensionSubGroupList();
1308 Assert.assertNotNull(dimensionSubGroupList);
1309 dimensionSubGroups = dimensionSubGroupList.getDimensionSubGroup();
1310 Assert.assertNotNull(dimensionSubGroups);
1311 Assert.assertTrue(dimensionSubGroups.size() == updatedDimensionGroupSize);
1313 Assert.assertEquals(UPDATED_MEASUREMENT_UNIT,
1314 dimensionSubGroups.get(0).getMeasurementUnit(),
1315 "Data in updated object did not match submitted data.");