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 fails 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 } catch (AssertionError e) {
185 logger.trace(e.getLocalizedMessage());
189 // Verify that values are preserved when enclosed in double quote marks.
190 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
191 dependsOnMethods = {"CRUDTests"}, groups = {"cspace3237group"})
192 public void doubleQuotesEnclosingFieldContents(String testName) throws Exception {
194 createFromXmlFile(testName, "./test-data/cspace-3237-double-quotes.xml", true);
195 CollectionobjectsCommon collectionObject = readCollectionObjectCommonPart(newId);
197 Assert.assertTrue(collectionObject.getDistinguishingFeatures().matches("^\\\".+?\\\"$"));
199 BriefDescriptionList descriptionList = collectionObject.getBriefDescriptions();
200 List<String> descriptions = descriptionList.getBriefDescription();
201 Assert.assertTrue(descriptions.size() > 0);
202 Assert.assertNotNull(descriptions.get(0));
203 Assert.assertTrue(descriptions.get(0).matches("^\\\".+?\\\"$"));
205 if (logger.isDebugEnabled()) {
206 logger.debug(objectAsXmlString(collectionObject,
207 CollectionobjectsCommon.class));
212 * Creates the from xml rfw s1.
214 * @param testName the test name
215 * @throws Exception the exception
217 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
218 dependsOnMethods = {"CRUDTests"})
219 public void createFromXmlRFWS1(String testName) throws Exception {
220 String testDataDir = System.getProperty("test-data.fileName");
222 //createFromXmlFile(testName, "./target/test-classes/test-data/repfield_whitesp1.xml", false);
223 createFromXmlFile(testName, testDataDir + "/repfield_whitesp1.xml", false);
224 testSubmitRequest(newId);
228 * Creates the from xml rfw s2.
230 * @param testName the test name
231 * @throws Exception the exception
233 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
234 dependsOnMethods = {"CRUDTests"})
235 public void createFromXmlRFWS2(String testName) throws Exception {
236 String testDataDir = System.getProperty("test-data.fileName");
238 //createFromXmlFile(testName, "./target/test-classes/test-data/repfield_whitesp2.xml", false);
239 createFromXmlFile(testName, testDataDir + "/repfield_whitesp2.xml", false);
240 testSubmitRequest(newId);
244 * Creates the from xml rfw s3.
246 * @param testName the test name
247 * @throws Exception the exception
249 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
250 dependsOnMethods = {"CRUDTests"})
251 public void createFromXmlRFWS3(String testName) throws Exception {
252 String testDataDir = System.getProperty("test-data.fileName");
254 //createFromXmlFile(testName, "./target/test-classes/test-data/repfield_whitesp3.xml", false);
255 createFromXmlFile(testName, testDataDir + "/repfield_whitesp3.xml", false);
256 testSubmitRequest(newId);
260 * Creates the from xml rfw s4.
262 * @param testName the test name
263 * @throws Exception the exception
265 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
266 dependsOnMethods = {"CRUDTests"})
267 public void createFromXmlRFWS4(String testName) throws Exception {
268 String testDataDir = System.getProperty("test-data.fileName");
270 createFromXmlFile(testName, testDataDir + "/repfield_whitesp4.xml", false);
271 testSubmitRequest(newId);
275 * Tests to diagnose and verify the fixed status of CSPACE-1248,
276 * "Wedged records created!" (i.e. records with child repeatable
277 * fields, which contain null values, can be successfully created
278 * but an error occurs on trying to retrieve those records).
282 * Creates a CollectionObject resource with a null value repeatable field.
284 * @param testName the test name
285 * @throws Exception the exception
287 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
288 dependsOnMethods = {"CRUDTests"})
289 public void createWithNullValueRepeatableField(String testName) throws Exception {
290 String testDataDir = System.getProperty("test-data.fileName");
292 createFromXmlFile(testName, testDataDir + "/repfield_null1.xml", false);
293 if (logger.isDebugEnabled()) {
294 logger.debug("Successfully created record with null value repeatable field.");
295 logger.debug("Attempting to retrieve just-created record ...");
297 testSubmitRequest(newId);
301 * Creates a CollectionObject resource, one of whose fields contains
302 * non-Latin 1 Unicode UTF-8 characters.
304 * @param testName the test name
305 * @throws Exception the exception
307 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
308 dependsOnMethods = {"CRUDTests"}, groups={"utf8-create"})
309 public void createWithUTF8Data(String testName) throws Exception {
310 String testDataDir = System.getProperty("test-data.fileName");
312 createFromXmlFile(testName, testDataDir + "/cspace-2779-utf-8-create.xml", false);
313 if (logger.isDebugEnabled()) {
314 logger.debug("Created record with UTF-8 chars in payload.");
315 logger.debug("Attempting to retrieve just-created record ...");
317 CollectionobjectsCommon collectionObject = readCollectionObjectCommonPart(newId);
318 String distinguishingFeatures = collectionObject.getDistinguishingFeatures();
319 if (logger.isDebugEnabled()) {
320 logger.debug("Sent distinguishingFeatures: " + UTF8_DATA_SAMPLE);
321 logger.debug("Received distinguishingFeatures: " + distinguishingFeatures);
323 Assert.assertTrue(distinguishingFeatures.equals(UTF8_DATA_SAMPLE));
327 // Placeholders until the three tests below can be uncommented.
328 // See Issue CSPACE-401.
330 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
333 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
334 public void createWithEmptyEntityBody(String testName) throws Exception {
335 //FIXME: Should this test really be empty?
339 * Test how the service handles XML that is not well formed,
340 * when sent in the payload of a Create request.
342 * @param testName The name of this test method. This name is supplied
343 * automatically, via reflection, by a TestNG 'data provider' in
347 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
348 public void createWithMalformedXml(String testName) throws Exception {
349 //FIXME: Should this test really be empty?
353 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
356 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
357 public void createWithWrongXmlSchema(String testName) throws Exception {
358 //FIXME: Should this test really be empty?
364 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
365 dependsOnMethods = {"create", "testSubmitRequest"})
366 public void createWithEmptyEntityBody(String testName) throwsException {
368 if (logger.isDebugEnabled()) {
369 logger.debug(testBanner(testName, CLASS_NAME));
372 setupCreateWithEmptyEntityBody();
374 // Submit the request to the service and store the response.
375 String method = REQUEST_TYPE.httpMethodName();
376 String url = getServiceRootURL();
377 String mediaType = MediaType.APPLICATION_XML;
378 final String entity = "";
379 int statusCode = submitRequest(method, url, mediaType, entity);
381 // Check the status code of the response: does it match
382 // the expected response(s)?
383 if(logger.isDebugEnabled()){
384 logger.debug(testName + ": url=" + url +
385 " status=" + statusCode);
387 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
388 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
389 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
393 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
394 dependsOnMethods = {"create", "testSubmitRequest"})
395 public void createWithMalformedXml(String testName) throws Exception {
397 if (logger.isDebugEnabled()) {
398 logger.debug(testBanner(testName, CLASS_NAME));
401 setupCreateWithMalformedXml();
403 // Submit the request to the service and store the response.
404 String method = REQUEST_TYPE.httpMethodName();
405 String url = getServiceRootURL();
406 String mediaType = MediaType.APPLICATION_XML;
407 final String entity = MALFORMED_XML_DATA; // Constant from base class.
408 int statusCode = submitRequest(method, url, mediaType, entity);
410 // Check the status code of the response: does it match
411 // the expected response(s)?
412 if(logger.isDebugEnabled()){
413 logger.debug(testName + ": url=" + url +
414 " status=" + statusCode);
416 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
417 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
418 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
422 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
423 dependsOnMethods = {"create", "testSubmitRequest"})
424 public void createWithWrongXmlSchema(String testName) throws Exception {
426 if (logger.isDebugEnabled()) {
427 logger.debug(testBanner(testName, CLASS_NAME));
430 setupCreateWithWrongXmlSchema();
432 // Submit the request to the service and store the response.
433 String method = REQUEST_TYPE.httpMethodName();
434 String url = getServiceRootURL();
435 String mediaType = MediaType.APPLICATION_XML;
436 final String entity = WRONG_XML_SCHEMA_DATA;
437 int statusCode = submitRequest(method, url, mediaType, entity);
439 // Check the status code of the response: does it match
440 // the expected response(s)?
441 if(logger.isDebugEnabled()){
442 logger.debug(testName + ": url=" + url +
443 " status=" + statusCode);
445 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
446 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
447 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
452 * Test how the service handles, in a Create request, payloads
453 * containing null values (or, in the case of String fields,
454 * empty String values) in one or more fields which must be
455 * present and are required to contain non-empty values.
457 * This is a test of code and/or configuration in the service's
458 * validation routine(s).
460 * @param testName The name of this test method. This name is supplied
461 * automatically, via reflection, by a TestNG 'data provider' in
465 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
466 public void createWithRequiredValuesNullOrEmpty(String testName) throws Exception {
469 // Build a payload with invalid content, by omitting a
470 // field (objectNumber) which must be present, and in which
471 // a non-empty value is required, as enforced by the service's
472 // validation routine(s).
473 CollectionobjectsCommon collectionObject = new CollectionobjectsCommon();
475 TitleGroupList titleGroupList = new TitleGroupList();
476 List<TitleGroup> titleGroups = titleGroupList.getTitleGroup();
477 TitleGroup titleGroup = new TitleGroup();
478 titleGroup.setTitle("a title");
479 titleGroups.add(titleGroup);
480 collectionObject.setTitleGroupList(titleGroupList);
482 ObjectNameList objNameList = new ObjectNameList();
483 List<ObjectNameGroup> objNameGroups = objNameList.getObjectNameGroup();
484 ObjectNameGroup objectNameGroup = new ObjectNameGroup();
485 objectNameGroup.setObjectName("an object name");
486 objNameGroups.add(objectNameGroup);
487 collectionObject.setObjectNameList(objNameList);
489 // Submit the request to the service and store the response.
490 CollectionObjectClient client = new CollectionObjectClient();
491 PoxPayloadOut multipart =
492 createCollectionObjectInstance(client.getCommonPartName(), collectionObject, null);
493 Response res = client.create(multipart);
495 int statusCode = res.getStatus();
496 // Read the response and verify that the create attempt failed.
497 if (logger.isDebugEnabled()) {
498 logger.debug(testName + ": status = " + statusCode);
500 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
501 invalidStatusCodeMessage(testRequestType, statusCode));
502 Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
507 // FIXME: Consider splitting off the following into its own test method.
509 // Build a payload with invalid content, by setting a value to the
510 // empty String, in a field (objectNumber) that requires a non-empty
511 // value, as enforced by the service's validation routine(s).
512 collectionObject = new CollectionobjectsCommon();
513 collectionObject.setObjectNumber("");
514 collectionObject.setDistinguishingFeatures("Distinguishing features.");
516 objNameList = new ObjectNameList();
517 objNameGroups = objNameList.getObjectNameGroup();
518 objectNameGroup = new ObjectNameGroup();
519 objectNameGroup.setObjectName(OBJECT_NAME_VALUE);
520 objNameGroups.add(objectNameGroup);
521 collectionObject.setObjectNameList(objNameList);
523 // Submit the request to the service and store the response.
524 multipart = createCollectionObjectInstance(client.getCommonPartName(), collectionObject, null);
525 res = client.create(multipart);
527 int statusCode = res.getStatus();
529 // Read the response and verify that the create attempt failed.
530 if (logger.isDebugEnabled()) {
531 logger.debug(testName + ": status = " + statusCode);
533 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
534 invalidStatusCodeMessage(testRequestType, statusCode));
535 Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
544 * @param testName the test name
546 * @return the client response
549 private Response updateRetrieve(String testName, String id) throws Exception {
551 CollectionObjectClient client = new CollectionObjectClient();
552 Response res = client.read(knownResourceId);
553 int statusCode = res.getStatus();
554 // Check the status code of the response: does it match
555 // the expected response(s)?
556 if (logger.isDebugEnabled()) {
557 logger.debug(testName + ": read status = " + statusCode);
559 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
560 invalidStatusCodeMessage(testRequestType, statusCode));
561 Assert.assertEquals(statusCode, testExpectedStatusCode);
562 if(logger.isDebugEnabled()){
563 logger.debug("got object to update with ID: " + knownResourceId);
572 * @param testName the test name
574 * @return the client response
577 private Response updateSend(String testName, String id,
578 CollectionobjectsCommon collectionObjectCommon) throws Exception {
580 PoxPayloadOut output = new PoxPayloadOut(CollectionObjectClient.SERVICE_PAYLOAD_NAME);
581 PayloadOutputPart commonPart = output.addPart(collectionObjectCommon, MediaType.APPLICATION_XML_TYPE);
582 CollectionObjectClient client = new CollectionObjectClient();
583 commonPart.setLabel(client.getCommonPartName());
585 Response res = client.update(knownResourceId, output);
586 int statusCode = res.getStatus();
587 // Check the status code of the response: does it match
588 // the expected response(s)?
589 if (logger.isDebugEnabled()) {
590 logger.debug(testName + ": read status = " + statusCode);
592 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
593 invalidStatusCodeMessage(testRequestType, statusCode));
594 Assert.assertEquals(statusCode, testExpectedStatusCode);
596 return res; // Calling needs to make sure they call res.close();
600 // Placeholders until the three tests below can be uncommented.
601 // See Issue CSPACE-401.
603 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
606 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
607 dependsOnMethods = {"CRUDTests"})
608 public void updateWithEmptyEntityBody(String testName) throws Exception {
609 //FIXME: Should this test really be empty?
613 * Test how the service handles XML that is not well formed,
614 * when sent in the payload of an Update request.
616 * @param testName The name of this test method. This name is supplied
617 * automatically, via reflection, by a TestNG 'data provider' in
621 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
622 dependsOnMethods = {"CRUDTests"})
623 public void updateWithMalformedXml(String testName) throws Exception {
624 //FIXME: Should this test really be empty?
628 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
631 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
632 dependsOnMethods = {"CRUDTests"})
633 public void updateWithWrongXmlSchema(String testName) throws Exception {
634 //FIXME: Should this test really be empty?
639 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
640 dependsOnMethods = {"create", "update", "testSubmitRequest"})
641 public void updateWithEmptyEntityBody(String testName) throws Exception {
643 if (logger.isDebugEnabled()) {
644 logger.debug(testBanner(testName, CLASS_NAME));
647 setupUpdateWithEmptyEntityBody();
649 // Submit the request to the service and store the response.
650 String method = REQUEST_TYPE.httpMethodName();
651 String url = getResourceURL(knownResourceId);
652 String mediaType = MediaType.APPLICATION_XML;
653 final String entity = "";
654 int statusCode = submitRequest(method, url, mediaType, entity);
656 // Check the status code of the response: does it match
657 // the expected response(s)?
658 if(logger.isDebugEnabled()){
659 logger.debug(testName + ": url=" + url +
660 " status=" + statusCode);
662 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
663 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
664 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
668 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
669 dependsOnMethods = {"create", "update", "testSubmitRequest"})
670 public void updateWithMalformedXml() throws Exception {
672 if (logger.isDebugEnabled()) {
673 logger.debug(testBanner(testName, CLASS_NAME));
676 setupUpdateWithMalformedXml();
678 // Submit the request to the service and store the response.
679 String method = REQUEST_TYPE.httpMethodName();
680 String url = getResourceURL(knownResourceId);
681 final String entity = MALFORMED_XML_DATA;
682 String mediaType = MediaType.APPLICATION_XML;
683 int statusCode = submitRequest(method, url, mediaType, entity);
685 // Check the status code of the response: does it match
686 // the expected response(s)?
687 if(logger.isDebugEnabled()){
688 logger.debug(testName + ": url=" + url +
689 " status=" + statusCode);
691 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
692 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
693 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
697 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
698 dependsOnMethods = {"create", "update", "testSubmitRequest"})
699 public void updateWithWrongXmlSchema(String testName) throws Exception {
701 if (logger.isDebugEnabled()) {
702 logger.debug(testBanner(testName, CLASS_NAME));
705 setupUpdateWithWrongXmlSchema();
707 // Submit the request to the service and store the response.
708 String method = REQUEST_TYPE.httpMethodName();
709 String url = getResourceURL(knownResourceId);
710 String mediaType = MediaType.APPLICATION_XML;
711 final String entity = WRONG_XML_SCHEMA_DATA;
712 int statusCode = submitRequest(method, url, mediaType, entity);
714 // Check the status code of the response: does it match
715 // the expected response(s)?
716 if(logger.isDebugEnabled()){
717 logger.debug(testName + ": url=" + url +
718 " status=" + statusCode);
720 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
721 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
722 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
727 public void updateNonExistent(String testName) throws Exception {
729 setupUpdateNonExistent();
731 // Submit the request to the service and store the response.
733 // Note: The ID used in this 'create' call may be arbitrary.
734 // The only relevant ID may be the one used in updateCollectionObject(), below.
735 CollectionObjectClient client = new CollectionObjectClient();
736 PoxPayloadOut multipart =
737 createInstance(client.getCommonPartName(), NON_EXISTENT_ID);
738 Response res = client.update(NON_EXISTENT_ID, multipart);
740 int statusCode = res.getStatus();
741 // Check the status code of the response: does it match
742 // the expected response(s)?
743 if (logger.isDebugEnabled()) {
744 logger.debug(testName + ": status = " + statusCode);
746 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
747 invalidStatusCodeMessage(testRequestType, statusCode));
748 Assert.assertEquals(statusCode, testExpectedStatusCode);
755 * Test how the service handles, in an Update request, payloads
756 * containing null values (or, in the case of String fields,
757 * empty String values) in one or more fields in which non-empty
758 * values are required.
760 * This is a test of code and/or configuration in the service's
761 * validation routine(s).
763 * @param testName The name of this test method. This name is supplied
764 * automatically, via reflection, by a TestNG 'data provider' in
768 // @Test(dataProvider = "testName", dependsOnMethods = {"CRUDTests"}) // REM - Disabled this test because of issues raised in CSPACE-6705
769 public void updateWithRequiredValuesNullOrEmpty(String testName) throws Exception {
770 // Read an existing record for updating.
771 Response res = updateRetrieve(testName, knownResourceId);
772 CollectionobjectsCommon collectionObjectCommon = null;
774 // Extract its common part.
775 collectionObjectCommon = extractCommonPartValue(res);
780 // Update the common part with invalid content, by setting a value to
781 // the empty String, in a field that requires a non-empty value,
782 // as enforced by the service's validation routine(s).
783 collectionObjectCommon.setObjectNumber("");
785 if (logger.isDebugEnabled()) {
786 logger.debug(testName + " updated object");
787 logger.debug(objectAsXmlString(collectionObjectCommon,
788 CollectionobjectsCommon.class));
791 // Submit the request to the service and store the response.
793 PoxPayloadOut output = new PoxPayloadOut(CollectionObjectClient.SERVICE_PAYLOAD_NAME);
794 CollectionObjectClient client = new CollectionObjectClient();
795 output.addPart(client.getCommonPartName(), collectionObjectCommon);
796 res = client.update(knownResourceId, output);
799 int statusCode = res.getStatus();
800 // Read the response and verify that the update attempt failed.
801 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
802 invalidStatusCodeMessage(testRequestType, statusCode));
803 Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
809 // ---------------------------------------------------------------
810 // CRUD tests : DELETE tests
811 // ---------------------------------------------------------------
815 public void delete(String testName) throws Exception {
817 // Create an object to delete, save the current 'knownResourceId' since we don't want to delete it yet
818 // and temporarily set it to the csid of the resource we just created.
820 String tempCsid = knownResourceId;
821 // the super.delete() method uses the knownResourceId member
822 knownResourceId = newCollectionObject(true);
825 super.delete(testName);
827 // reset the 'knownResourceId'
828 knownResourceId = tempCsid;
833 // Expected failure outcome tests
837 public void deleteNonExistent(String testName) throws Exception {
839 setupDeleteNonExistent();
841 // Submit the request to the service and store the response.
842 CollectionObjectClient client = new CollectionObjectClient();
843 Response res = client.delete(NON_EXISTENT_ID);
845 int statusCode = res.getStatus();
847 // Check the status code of the response: does it match
848 // the expected response(s)?
849 if (logger.isDebugEnabled()) {
850 logger.debug(testName + ": status = " + statusCode);
852 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
853 invalidStatusCodeMessage(testRequestType, statusCode));
854 Assert.assertEquals(statusCode, testExpectedStatusCode);
860 // ---------------------------------------------------------------
861 // Utility tests : tests of code used in tests above
862 // ---------------------------------------------------------------
865 * Tests the code for manually submitting data that is used by several
866 * of the methods above.
870 // ---------------------------------------------------------------
871 // Utility methods used by tests above
872 // ---------------------------------------------------------------
874 private Response newCollectionObject() throws Exception {
875 Response result = null;
877 CollectionObjectClient client = new CollectionObjectClient();
878 String identifier = createIdentifier();
879 PoxPayloadOut multipart =
880 createInstance(client.getCommonPartName(), identifier);
881 result = client.create(multipart);
886 private String newCollectionObject(boolean assertStatus) throws Exception {
887 String result = null;
889 Response res = newCollectionObject();
891 int statusCode = res.getStatus();
892 Assert.assertEquals(statusCode, STATUS_CREATED);
893 result = extractId(res);
902 protected PoxPayloadOut createInstance(String identifier) {
903 String commonPartName = CollectionObjectClient.SERVICE_COMMON_PART_NAME;
904 return createInstance(commonPartName, identifier);
908 * Creates the collection object instance.
910 * @param commonPartName the common part name
911 * @param identifier the identifier
912 * @return the multipart output
915 protected PoxPayloadOut createInstance(String commonPartName,
917 return createCollectionObjectInstance(commonPartName,
918 "objectNumber-" + identifier,
919 "objectName-" + identifier);
923 * Creates the collection object instance.
925 * @param commonPartName the common part name
926 * @param objectNumber the object number
927 * @param objectName the object name
928 * @return the multipart output
930 private PoxPayloadOut createCollectionObjectInstance(String commonPartName,
931 String objectNumber, String objectName) {
932 CollectionobjectsCommon collectionObject = new CollectionobjectsCommon();
935 collectionObject.setObjectNumber(objectNumber);
936 collectionObject.setAge(AGE_VALUE); //test for null string
938 // Repeatable structured groups
940 TitleGroupList titleGroupList = new TitleGroupList();
941 List<TitleGroup> titleGroups = titleGroupList.getTitleGroup();
942 Assert.assertNotNull(titleGroups);
943 TitleGroup titleGroup = new TitleGroup();
944 titleGroup.setTitle("a title");
945 titleGroups.add(titleGroup);
946 collectionObject.setTitleGroupList(titleGroupList);
948 ObjectNameList objNameList = new ObjectNameList();
949 List<ObjectNameGroup> objNameGroups = objNameList.getObjectNameGroup();
950 ObjectNameGroup objectNameGroup = new ObjectNameGroup();
951 objectNameGroup.setObjectName(OBJECT_NAME_VALUE);
952 objNameGroups.add(objectNameGroup);
953 collectionObject.setObjectNameList(objNameList);
955 MeasuredPartGroupList measuredPartGroupList = new MeasuredPartGroupList();
956 List<MeasuredPartGroup> measuredPartGroups = measuredPartGroupList.getMeasuredPartGroup();
957 Assert.assertNotNull(measuredPartGroups, "Measured part groups are null");
958 MeasuredPartGroup measuredPartGroup = new MeasuredPartGroup();
959 measuredPartGroup.setMeasuredPart(MEASURED_PART);
961 DimensionSubGroupList dimensionSubGroupList = new DimensionSubGroupList();
962 List<DimensionSubGroup> dimensionSubGroups = dimensionSubGroupList.getDimensionSubGroup();
963 Assert.assertNotNull(dimensionSubGroups, "Dimension subgroups are null");
965 DimensionSubGroup lengthDimension = new DimensionSubGroup();
966 lengthDimension.setDimension("length");
967 lengthDimension.setValue(DIMENSION_VALUE_LENGTH);
968 lengthDimension.setMeasurementUnit("cm");
969 dimensionSubGroups.add(lengthDimension);
971 DimensionSubGroup widthDimension = new DimensionSubGroup();
972 widthDimension.setDimension("width");
973 widthDimension.setValue(DIMENSION_VALUE_WIDTH);
974 widthDimension.setMeasurementUnit("m");
975 widthDimension.setValueQualifier(""); // test empty string
976 dimensionSubGroups.add(widthDimension);
978 measuredPartGroup.setDimensionSubGroupList(dimensionSubGroupList);
979 measuredPartGroups.add(measuredPartGroup);
980 collectionObject.setMeasuredPartGroupList(measuredPartGroupList);
982 // Repeatable scalar fields
984 BriefDescriptionList descriptionList = new BriefDescriptionList();
985 List<String> descriptions = descriptionList.getBriefDescription();
986 descriptions.add("Papier mache bird cow mask with horns, "
987 + "painted red with black and yellow spots. "
988 + "Puerto Rico. ca. 8" high, 6" wide, projects 10" (with horns).");
989 descriptions.add("Acrylic rabbit mask with wings, "
990 + "painted red with green and aquamarine spots. "
991 + "Puerto Rico. ca. 8" high, 6" wide, projects 10" (with wings).");
992 collectionObject.setBriefDescriptions(descriptionList);
994 ResponsibleDepartmentList deptList = new ResponsibleDepartmentList();
995 List<String> depts = deptList.getResponsibleDepartment();
996 // @TODO Use properly formatted refNames for representative departments
997 // in this example test record. The following are mere placeholders.
998 depts.add("urn:org.collectionspace.services.department:Registrar");
999 depts.add("urn:org.walkerart.department:Fine Art");
1000 collectionObject.setResponsibleDepartments(deptList);
1002 OtherNumberList otherNumList = new OtherNumberList();
1003 List<OtherNumber> otherNumbers = otherNumList.getOtherNumber();
1004 OtherNumber otherNumber1 = new OtherNumber();
1005 otherNumber1.setNumberValue("101." + objectName);
1006 otherNumber1.setNumberType("integer");
1007 otherNumbers.add(otherNumber1);
1008 OtherNumber otherNumber2 = new OtherNumber();
1009 otherNumber2.setNumberValue("101.502.23.456." + objectName);
1010 otherNumber2.setNumberType("ipaddress");
1011 otherNumbers.add(otherNumber2);
1012 collectionObject.setOtherNumberList(otherNumList);
1014 // Add instances of fields from an extension schema
1016 CollectionobjectsNaturalhistory conh = new CollectionobjectsNaturalhistory();
1017 // Laramie20110524 removed for build: conh.setNhString("test-string");
1018 // Laramie20110524 removed for build: conh.setNhInt(999);
1019 // Laramie20110524 removed for build: conh.setNhLong(9999);
1021 PoxPayloadOut multipart = createCollectionObjectInstance(commonPartName, collectionObject, conh);
1026 * Creates the collection object instance.
1028 * @param commonPartName the common part name
1029 * @param collectionObject the collection object
1030 * @param conh the conh
1031 * @return the multipart output
1033 private PoxPayloadOut createCollectionObjectInstance(String commonPartName,
1034 CollectionobjectsCommon collectionObject, CollectionobjectsNaturalhistory conh) {
1036 PoxPayloadOut multipart = CollectionObjectFactory.createCollectionObjectInstance(
1037 commonPartName, collectionObject, getNHPartName(), conh);
1038 if (logger.isDebugEnabled()) {
1039 logger.debug("to be created, collectionobject common");
1040 logger.debug(objectAsXmlString(collectionObject,
1041 CollectionobjectsCommon.class));
1045 if (logger.isDebugEnabled()) {
1046 logger.debug("to be created, collectionobject nhistory");
1047 logger.debug(objectAsXmlString(conh,
1048 CollectionobjectsNaturalhistory.class));
1056 * createCollectionObjectInstanceFromXml uses JAXB unmarshaller to retrieve
1057 * collectionobject from given file
1058 * @param commonPartName
1059 * @param commonPartFileName
1063 private PoxPayloadOut createCollectionObjectInstanceFromXml(String testName, String commonPartName,
1064 String commonPartFileName) throws Exception {
1066 CollectionobjectsCommon collectionObject =
1067 (CollectionobjectsCommon) getObjectFromFile(CollectionobjectsCommon.class,
1068 commonPartFileName);
1069 PoxPayloadOut multipart = new PoxPayloadOut(CollectionObjectClient.SERVICE_PAYLOAD_NAME);
1070 PayloadOutputPart commonPart = multipart.addPart(collectionObject,
1071 MediaType.APPLICATION_XML_TYPE);
1072 CollectionObjectClient client = new CollectionObjectClient();
1073 commonPart.setLabel(client.getCommonPartName());
1075 if (logger.isDebugEnabled()) {
1076 logger.debug(testName + " to be created, collectionobject common");
1077 logger.debug(objectAsXmlString(collectionObject,
1078 CollectionobjectsCommon.class));
1085 * createCollectionObjectInstanceFromRawXml uses stringified collectionobject
1086 * retrieve from given file
1087 * @param commonPartName
1088 * @param commonPartFileName
1092 private PoxPayloadOut createCollectionObjectInstanceFromRawXml(String testName, String commonPartName,
1093 String commonPartFileName) throws Exception {
1095 PoxPayloadOut multipart = new PoxPayloadOut(CollectionObjectClient.SERVICE_PAYLOAD_NAME);
1096 String stringObject = getXmlDocumentAsString(commonPartFileName);
1097 if (logger.isDebugEnabled()) {
1098 logger.debug(testName + " to be created, collectionobject common " + "\n" + stringObject);
1100 PayloadOutputPart commonPart = multipart.addPart(commonPartName, stringObject);
1101 // commonPart.setLabel(commonPartName);
1107 * Gets the nH part name.
1109 * @return the nH part name
1111 private String getNHPartName() {
1112 return "collectionobjects_naturalhistory";
1116 * Creates the from xml file.
1118 * @param testName the test name
1119 * @param fileName the file name
1120 * @param useJaxb the use jaxb
1121 * @return the string
1122 * @throws Exception the exception
1124 private String createFromXmlFile(String testName, String fileName, boolean useJaxb) throws Exception {
1126 PoxPayloadOut multipart = null;
1128 CollectionObjectClient client = new CollectionObjectClient();
1130 multipart = createCollectionObjectInstanceFromXml(testName,
1131 client.getCommonPartName(), fileName);
1133 multipart = createCollectionObjectInstanceFromRawXml(testName,
1134 client.getCommonPartName(), fileName);
1137 Response res = client.create(multipart);
1138 String newId = null;
1140 int statusCode = res.getStatus();
1141 if (logger.isDebugEnabled()) {
1142 logger.debug(testName + ": status = " + statusCode);
1144 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
1145 invalidStatusCodeMessage(testRequestType, statusCode));
1146 Assert.assertEquals(statusCode, testExpectedStatusCode);
1147 newId = extractId(res);
1148 allResourceIdsCreated.add(newId);
1156 // FIXME: This duplicates code in read(), and should be consolidated.
1157 // This is an expedient to support reading and verifying the contents
1158 // of resources that have been created from test data XML files.
1159 private CollectionobjectsCommon readCollectionObjectCommonPart(String csid)
1162 String testName = "readCollectionObjectCommonPart";
1166 // Submit the request to the service and store the response.
1167 CollectionObjectClient client = new CollectionObjectClient();
1168 Response res = client.read(csid);
1169 CollectionobjectsCommon collectionObject = null;
1171 int statusCode = res.getStatus();
1173 // Check the status code of the response: does it match
1174 // the expected response(s)?
1175 if (logger.isDebugEnabled()) {
1176 logger.debug(testName + ": status = " + statusCode);
1178 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
1179 invalidStatusCodeMessage(testRequestType, statusCode));
1180 Assert.assertEquals(statusCode, testExpectedStatusCode);
1182 // Extract the common part.
1183 collectionObject = extractCommonPartValue(res);
1184 Assert.assertNotNull(collectionObject);
1189 return collectionObject;
1193 protected String getServicePathComponent() {
1194 // TODO Auto-generated method stub
1195 return CollectionObjectClient.SERVICE_PATH_COMPONENT;
1199 protected CollectionobjectsCommon updateInstance(CollectionobjectsCommon collectionObjectCommon) {
1200 collectionObjectCommon.setObjectNumber("updated-" + collectionObjectCommon.getObjectNumber());
1202 // Change the object name in the first value instance in the
1203 // object name repeatable group.
1204 ObjectNameList objNameList = collectionObjectCommon.getObjectNameList();
1205 List<ObjectNameGroup> objNameGroups = objNameList.getObjectNameGroup();
1206 Assert.assertNotNull(objNameGroups);
1207 Assert.assertTrue(objNameGroups.size() >= 1);
1208 String objectName = objNameGroups.get(0).getObjectName();
1209 Assert.assertEquals(objectName, OBJECT_NAME_VALUE);
1210 String updatedObjectName = "updated-" + objectName;
1211 objNameGroups.get(0).setObjectName(updatedObjectName);
1212 collectionObjectCommon.setObjectNameList(objNameList);
1214 // Replace the existing value instances in the dimensions repeatable group
1215 // with entirely new value instances, also changing the number of such instances.
1216 MeasuredPartGroupList measuredPartGroupList = collectionObjectCommon.getMeasuredPartGroupList();
1217 Assert.assertNotNull(measuredPartGroupList);
1218 List<MeasuredPartGroup> measuredPartGroups = measuredPartGroupList.getMeasuredPartGroup();
1219 Assert.assertNotNull(measuredPartGroups);
1220 Assert.assertTrue(measuredPartGroups.size() > 0);
1221 MeasuredPartGroup mpGroup = measuredPartGroups.get(0);
1222 Assert.assertNotNull(mpGroup.getMeasuredPart());
1224 DimensionSubGroupList dimensionSubGroupList = mpGroup.getDimensionSubGroupList();
1225 Assert.assertNotNull(dimensionSubGroupList);
1226 List<DimensionSubGroup> dimensionSubGroups = dimensionSubGroupList.getDimensionSubGroup();
1227 Assert.assertNotNull(dimensionSubGroups);
1228 int originalDimensionSubGroupSize = dimensionSubGroups.size();
1229 Assert.assertTrue(dimensionSubGroups.size() > 0);
1230 dimensionSubGroups.clear();
1232 DimensionSubGroup heightDimension = new DimensionSubGroup();
1233 heightDimension.setDimension("height");
1234 heightDimension.setMeasurementUnit(UPDATED_MEASUREMENT_UNIT);
1235 dimensionSubGroups.add(heightDimension);
1237 int updatedDimensionGroupSize = dimensionSubGroups.size();
1238 Assert.assertTrue(updatedDimensionGroupSize > 0);
1239 Assert.assertTrue(updatedDimensionGroupSize != originalDimensionSubGroupSize);
1241 collectionObjectCommon.setMeasuredPartGroupList(measuredPartGroupList);
1243 return collectionObjectCommon;
1247 protected void compareReadInstances(CollectionobjectsCommon original,
1248 CollectionobjectsCommon fromRead) throws Exception {
1249 // Verify the number and contents of values in repeatable fields,
1250 // as created in the instance record used for testing.
1251 MeasuredPartGroupList measuredPartGroupList = fromRead.getMeasuredPartGroupList();
1252 Assert.assertNotNull(measuredPartGroupList, "Measured part group list was null");
1253 List<MeasuredPartGroup> measuredPartGroups = measuredPartGroupList.getMeasuredPartGroup();
1254 Assert.assertNotNull(measuredPartGroups, "Measured part groups were null");
1255 Assert.assertTrue(measuredPartGroups.size() > 0, "No measured part groups were returned");
1256 MeasuredPartGroup mpGroup = measuredPartGroups.get(0);
1257 Assert.assertNotNull(mpGroup.getMeasuredPart(), "Measured part was null");
1258 Assert.assertEquals(mpGroup.getMeasuredPart(), MEASURED_PART,
1259 "Measured part value returned didn't match expected value");
1261 DimensionSubGroupList dimensionSubGroupList = mpGroup.getDimensionSubGroupList();
1262 Assert.assertNotNull(dimensionSubGroupList, "Dimension subgroup list was null");
1263 List<DimensionSubGroup> dimensionSubGroups = dimensionSubGroupList.getDimensionSubGroup();
1264 Assert.assertNotNull(dimensionSubGroups, "Dimension subgroups were null");
1265 Assert.assertTrue(dimensionSubGroups.size() > 0, "No dimension subgroups were returned");
1266 DimensionSubGroup lengthDimension = dimensionSubGroups.get(0);
1267 Assert.assertNotNull(lengthDimension, "Length dimension was null");
1268 Assert.assertTrue(lengthDimension.getValue().compareTo(DIMENSION_VALUE_LENGTH) == 0,
1269 "Dimension length value returned didn't match expected value");
1273 protected void compareUpdatedInstances(CollectionobjectsCommon original,
1274 CollectionobjectsCommon updated) throws Exception {
1276 ObjectNameList objNameList = updated.getObjectNameList();
1277 Assert.assertNotNull(objNameList);
1278 List<ObjectNameGroup> objNameGroups = objNameList.getObjectNameGroup();
1279 Assert.assertNotNull(objNameGroups);
1280 Assert.assertTrue(objNameGroups.size() >= 1);
1281 Assert.assertEquals(original.getObjectNameList().getObjectNameGroup().get(0).getObjectName(),
1282 objNameGroups.get(0).getObjectName(),
1283 "Data in updated object did not match submitted data.");
1285 // Get the dimension group size of the original
1287 MeasuredPartGroupList measuredPartGroupList = original.getMeasuredPartGroupList();
1288 List<MeasuredPartGroup> measuredPartGroups = measuredPartGroupList.getMeasuredPartGroup();
1289 MeasuredPartGroup mpGroup = measuredPartGroups.get(0);
1290 DimensionSubGroupList dimensionSubGroupList = mpGroup.getDimensionSubGroupList();
1291 List<DimensionSubGroup> dimensionSubGroups = dimensionSubGroupList.getDimensionSubGroup();
1292 int updatedDimensionGroupSize = dimensionSubGroups.size();
1294 // Now get the dimension group size of the updated
1296 measuredPartGroupList = updated.getMeasuredPartGroupList();
1297 Assert.assertNotNull(measuredPartGroupList);
1298 measuredPartGroups = measuredPartGroupList.getMeasuredPartGroup();
1299 Assert.assertNotNull(measuredPartGroups);
1300 Assert.assertTrue(measuredPartGroups.size() > 0);
1301 mpGroup = measuredPartGroups.get(0);
1302 Assert.assertNotNull(mpGroup.getMeasuredPart());
1303 dimensionSubGroupList = mpGroup.getDimensionSubGroupList();
1304 Assert.assertNotNull(dimensionSubGroupList);
1305 dimensionSubGroups = dimensionSubGroupList.getDimensionSubGroup();
1306 Assert.assertNotNull(dimensionSubGroups);
1307 Assert.assertTrue(dimensionSubGroups.size() == updatedDimensionGroupSize);
1309 Assert.assertEquals(UPDATED_MEASUREMENT_UNIT,
1310 dimensionSubGroups.get(0).getMeasurementUnit(),
1311 "Data in updated object did not match submitted data.");