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;
33 //import org.collectionspace.services.client.AbstractServiceClientImpl;
34 import org.collectionspace.services.client.CollectionObjectClient;
35 import org.collectionspace.services.client.CollectionObjectFactory;
36 import org.collectionspace.services.client.CollectionSpaceClient;
37 import org.collectionspace.services.client.PayloadOutputPart;
38 import org.collectionspace.services.client.PoxPayloadOut;
39 import org.collectionspace.services.collectionobject.BriefDescriptionList;
40 import org.collectionspace.services.collectionobject.CollectionobjectsCommon;
41 import org.collectionspace.services.collectionobject.domain.naturalhistory.CollectionobjectsNaturalhistory;
42 import org.collectionspace.services.collectionobject.DimensionSubGroup;
43 import org.collectionspace.services.collectionobject.DimensionSubGroupList;
44 import org.collectionspace.services.collectionobject.MeasuredPartGroup;
45 import org.collectionspace.services.collectionobject.MeasuredPartGroupList;
46 import org.collectionspace.services.collectionobject.ObjectNameGroup;
47 import org.collectionspace.services.collectionobject.ObjectNameList;
48 import org.collectionspace.services.collectionobject.OtherNumberList;
49 import org.collectionspace.services.collectionobject.OtherNumber;
50 import org.collectionspace.services.collectionobject.ResponsibleDepartmentList;
51 import org.collectionspace.services.collectionobject.TitleGroup;
52 import org.collectionspace.services.collectionobject.TitleGroupList;
53 import org.collectionspace.services.jaxb.AbstractCommonList;
55 import org.testng.Assert;
56 import org.testng.annotations.Test;
57 import org.slf4j.Logger;
58 import org.slf4j.LoggerFactory;
61 * CollectionObjectServiceTest, carries out tests against a
62 * deployed and running CollectionObject Service.
64 * $LastChangedRevision$
67 public class CollectionObjectServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonList, CollectionobjectsCommon> {
70 private final String CLASS_NAME = CollectionObjectServiceTest.class.getName();
71 private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
73 private final String OBJECT_NAME_VALUE = "an object name";
74 private final BigInteger AGE_VALUE = new BigInteger("55");
75 private final String MEASURED_PART = "light box frame";
76 private final BigDecimal DIMENSION_VALUE_LENGTH = new BigDecimal("0.009");
77 private final BigDecimal DIMENSION_VALUE_WIDTH = new BigDecimal("3087.56");
78 private final String UPDATED_MEASUREMENT_UNIT = "Angstroms";
79 private final String UTF8_DATA_SAMPLE = "Audiorecording album cover signed by Lech "
80 + "Wa" + '\u0142' + '\u0119' + "sa";
83 // * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
86 // protected String getServicePathComponent() {
87 // return new CollectionObjectClient().getServicePathComponent();
91 protected String getServiceName() {
92 return CollectionObjectClient.SERVICE_NAME;
96 * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
99 protected CollectionSpaceClient getClientInstance() {
100 return new CollectionObjectClient();
104 protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
105 return new CollectionObjectClient(clientPropertiesFilename);
108 // ---------------------------------------------------------------
109 // CRUD tests : CREATE tests
110 // ---------------------------------------------------------------
111 // Expected success outcomes
114 * For convenience and terseness, this test method is the base of the test execution dependency chain. Other test methods may
115 * refer to this method in their @Test annotation declarations.
118 @Test(dataProvider = "testName",
120 "org.collectionspace.services.client.test.AbstractServiceTestImpl.baseCRUDTests"})
121 public void CRUDTests(String testName) {
122 // Do nothing. Simply here to for a TestNG execution order for our tests
126 * Tests to diagnose and verify the fixed status of CSPACE-1026,
127 * "Whitespace at certain points in payload cause failure"
131 * Creates the from xml cambridge.
133 * @param testName the test name
134 * @throws Exception the exception
136 @Test(dataProvider = "testName",
137 dependsOnMethods = {"CRUDTests"})
138 public void createFromXmlCambridge(String testName) throws Exception {
140 createFromXmlFile(testName, "./test-data/testCambridge.xml", true);
141 testSubmitRequest(newId);
145 * Tests to diagnose and fix CSPACE-2242.
147 * This is a bug identified in release 0.8 in which value instances of a
148 * repeatable field are not stored when the first value instance of that
152 // Verify that record creation occurs successfully when the first value instance
153 // of a single, repeatable String scalar field is non-blank.
154 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
155 dependsOnMethods = {"CRUDTests"}, groups = {"cspace2242group"})
156 public void createFromXmlNonBlankFirstValueInstance(String testName) throws Exception {
158 createFromXmlFile(testName, "./test-data/cspace-2242-first-value-instance-nonblank.xml", true);
159 CollectionobjectsCommon collectionObject = readCollectionObjectCommonPart(newId);
160 // Verify that at least one value instance of the repeatable field was successfully persisted.
161 BriefDescriptionList descriptionList = collectionObject.getBriefDescriptions();
162 List<String> descriptions = descriptionList.getBriefDescription();
163 Assert.assertTrue(descriptions.size() > 0);
166 // Verify that record creation occurs successfully when the first value instance
167 // of a single, repeatable String scalar field is blank.
168 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
169 dependsOnMethods = {"CRUDTests"}, groups = {"cspace2242group"})
170 public void createFromXmlBlankFirstValueInstance(String testName) throws Exception {
172 createFromXmlFile(testName, "./test-data/cspace-2242-first-value-instance-blank.xml", true);
173 CollectionobjectsCommon collectionObject = readCollectionObjectCommonPart(newId);
174 // Verify that at least one value instance of the repeatable field was successfully persisted.
175 BriefDescriptionList descriptionList = collectionObject.getBriefDescriptions();
176 List<String> descriptions = descriptionList.getBriefDescription();
177 Assert.assertTrue(descriptions.size() > 0);
180 // Verify that values are preserved when enclosed in double quote marks.
181 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
182 dependsOnMethods = {"CRUDTests"}, groups = {"cspace3237group"})
183 public void doubleQuotesEnclosingFieldContents(String testName) throws Exception {
185 createFromXmlFile(testName, "./test-data/cspace-3237-double-quotes.xml", true);
186 CollectionobjectsCommon collectionObject = readCollectionObjectCommonPart(newId);
188 Assert.assertTrue(collectionObject.getDistinguishingFeatures().matches("^\\\".+?\\\"$"));
190 BriefDescriptionList descriptionList = collectionObject.getBriefDescriptions();
191 List<String> descriptions = descriptionList.getBriefDescription();
192 Assert.assertTrue(descriptions.size() > 0);
193 Assert.assertNotNull(descriptions.get(0));
194 Assert.assertTrue(descriptions.get(0).matches("^\\\".+?\\\"$"));
196 if (logger.isDebugEnabled()) {
197 logger.debug(objectAsXmlString(collectionObject,
198 CollectionobjectsCommon.class));
203 * Creates the from xml rfw s1.
205 * @param testName the test name
206 * @throws Exception the exception
208 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
209 dependsOnMethods = {"CRUDTests"})
210 public void createFromXmlRFWS1(String testName) throws Exception {
211 String testDataDir = System.getProperty("test-data.fileName");
213 //createFromXmlFile(testName, "./target/test-classes/test-data/repfield_whitesp1.xml", false);
214 createFromXmlFile(testName, testDataDir + "/repfield_whitesp1.xml", false);
215 testSubmitRequest(newId);
219 * Creates the from xml rfw s2.
221 * @param testName the test name
222 * @throws Exception the exception
224 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
225 dependsOnMethods = {"CRUDTests"})
226 public void createFromXmlRFWS2(String testName) throws Exception {
227 String testDataDir = System.getProperty("test-data.fileName");
229 //createFromXmlFile(testName, "./target/test-classes/test-data/repfield_whitesp2.xml", false);
230 createFromXmlFile(testName, testDataDir + "/repfield_whitesp2.xml", false);
231 testSubmitRequest(newId);
235 * Creates the from xml rfw s3.
237 * @param testName the test name
238 * @throws Exception the exception
240 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
241 dependsOnMethods = {"CRUDTests"})
242 public void createFromXmlRFWS3(String testName) throws Exception {
243 String testDataDir = System.getProperty("test-data.fileName");
245 //createFromXmlFile(testName, "./target/test-classes/test-data/repfield_whitesp3.xml", false);
246 createFromXmlFile(testName, testDataDir + "/repfield_whitesp3.xml", false);
247 testSubmitRequest(newId);
251 * Creates the from xml rfw s4.
253 * @param testName the test name
254 * @throws Exception the exception
256 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
257 dependsOnMethods = {"CRUDTests"})
258 public void createFromXmlRFWS4(String testName) throws Exception {
259 String testDataDir = System.getProperty("test-data.fileName");
261 createFromXmlFile(testName, testDataDir + "/repfield_whitesp4.xml", false);
262 testSubmitRequest(newId);
266 * Tests to diagnose and verify the fixed status of CSPACE-1248,
267 * "Wedged records created!" (i.e. records with child repeatable
268 * fields, which contain null values, can be successfully created
269 * but an error occurs on trying to retrieve those records).
273 * Creates a CollectionObject resource with a null value repeatable field.
275 * @param testName the test name
276 * @throws Exception the exception
278 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
279 dependsOnMethods = {"CRUDTests"})
280 public void createWithNullValueRepeatableField(String testName) throws Exception {
281 String testDataDir = System.getProperty("test-data.fileName");
283 createFromXmlFile(testName, testDataDir + "/repfield_null1.xml", false);
284 if (logger.isDebugEnabled()) {
285 logger.debug("Successfully created record with null value repeatable field.");
286 logger.debug("Attempting to retrieve just-created record ...");
288 testSubmitRequest(newId);
292 * Creates a CollectionObject resource, one of whose fields contains
293 * non-Latin 1 Unicode UTF-8 characters.
295 * @param testName the test name
296 * @throws Exception the exception
298 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
299 dependsOnMethods = {"CRUDTests"}, groups={"utf8-create"})
300 public void createWithUTF8Data(String testName) throws Exception {
301 String testDataDir = System.getProperty("test-data.fileName");
303 createFromXmlFile(testName, testDataDir + "/cspace-2779-utf-8-create.xml", false);
304 if (logger.isDebugEnabled()) {
305 logger.debug("Created record with UTF-8 chars in payload.");
306 logger.debug("Attempting to retrieve just-created record ...");
308 CollectionobjectsCommon collectionObject = readCollectionObjectCommonPart(newId);
309 String distinguishingFeatures = collectionObject.getDistinguishingFeatures();
310 if (logger.isDebugEnabled()) {
311 logger.debug("Sent distinguishingFeatures: " + UTF8_DATA_SAMPLE);
312 logger.debug("Received distinguishingFeatures: " + distinguishingFeatures);
314 Assert.assertTrue(distinguishingFeatures.equals(UTF8_DATA_SAMPLE));
318 // Placeholders until the three tests below can be uncommented.
319 // See Issue CSPACE-401.
321 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
324 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
325 public void createWithEmptyEntityBody(String testName) throws Exception {
326 //FIXME: Should this test really be empty?
330 * Test how the service handles XML that is not well formed,
331 * when sent in the payload of a Create request.
333 * @param testName The name of this test method. This name is supplied
334 * automatically, via reflection, by a TestNG 'data provider' in
338 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
339 public void createWithMalformedXml(String testName) throws Exception {
340 //FIXME: Should this test really be empty?
344 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
347 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
348 public void createWithWrongXmlSchema(String testName) throws Exception {
349 //FIXME: Should this test really be empty?
355 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
356 dependsOnMethods = {"create", "testSubmitRequest"})
357 public void createWithEmptyEntityBody(String testName) throwsException {
359 if (logger.isDebugEnabled()) {
360 logger.debug(testBanner(testName, CLASS_NAME));
363 setupCreateWithEmptyEntityBody();
365 // Submit the request to the service and store the response.
366 String method = REQUEST_TYPE.httpMethodName();
367 String url = getServiceRootURL();
368 String mediaType = MediaType.APPLICATION_XML;
369 final String entity = "";
370 int statusCode = submitRequest(method, url, mediaType, entity);
372 // Check the status code of the response: does it match
373 // the expected response(s)?
374 if(logger.isDebugEnabled()){
375 logger.debug(testName + ": url=" + url +
376 " status=" + statusCode);
378 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
379 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
380 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
384 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
385 dependsOnMethods = {"create", "testSubmitRequest"})
386 public void createWithMalformedXml(String testName) throws Exception {
388 if (logger.isDebugEnabled()) {
389 logger.debug(testBanner(testName, CLASS_NAME));
392 setupCreateWithMalformedXml();
394 // Submit the request to the service and store the response.
395 String method = REQUEST_TYPE.httpMethodName();
396 String url = getServiceRootURL();
397 String mediaType = MediaType.APPLICATION_XML;
398 final String entity = MALFORMED_XML_DATA; // Constant from base class.
399 int statusCode = submitRequest(method, url, mediaType, entity);
401 // Check the status code of the response: does it match
402 // the expected response(s)?
403 if(logger.isDebugEnabled()){
404 logger.debug(testName + ": url=" + url +
405 " status=" + statusCode);
407 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
408 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
409 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
413 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
414 dependsOnMethods = {"create", "testSubmitRequest"})
415 public void createWithWrongXmlSchema(String testName) throws Exception {
417 if (logger.isDebugEnabled()) {
418 logger.debug(testBanner(testName, CLASS_NAME));
421 setupCreateWithWrongXmlSchema();
423 // Submit the request to the service and store the response.
424 String method = REQUEST_TYPE.httpMethodName();
425 String url = getServiceRootURL();
426 String mediaType = MediaType.APPLICATION_XML;
427 final String entity = WRONG_XML_SCHEMA_DATA;
428 int statusCode = submitRequest(method, url, mediaType, entity);
430 // Check the status code of the response: does it match
431 // the expected response(s)?
432 if(logger.isDebugEnabled()){
433 logger.debug(testName + ": url=" + url +
434 " status=" + statusCode);
436 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
437 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
438 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
443 * Test how the service handles, in a Create request, payloads
444 * containing null values (or, in the case of String fields,
445 * empty String values) in one or more fields which must be
446 * present and are required to contain non-empty values.
448 * This is a test of code and/or configuration in the service's
449 * validation routine(s).
451 * @param testName The name of this test method. This name is supplied
452 * automatically, via reflection, by a TestNG 'data provider' in
456 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
457 public void createWithRequiredValuesNullOrEmpty(String testName) throws Exception {
460 // Build a payload with invalid content, by omitting a
461 // field (objectNumber) which must be present, and in which
462 // a non-empty value is required, as enforced by the service's
463 // validation routine(s).
464 CollectionobjectsCommon collectionObject = new CollectionobjectsCommon();
466 TitleGroupList titleGroupList = new TitleGroupList();
467 List<TitleGroup> titleGroups = titleGroupList.getTitleGroup();
468 TitleGroup titleGroup = new TitleGroup();
469 titleGroup.setTitle("a title");
470 titleGroups.add(titleGroup);
471 collectionObject.setTitleGroupList(titleGroupList);
473 ObjectNameList objNameList = new ObjectNameList();
474 List<ObjectNameGroup> objNameGroups = objNameList.getObjectNameGroup();
475 ObjectNameGroup objectNameGroup = new ObjectNameGroup();
476 objectNameGroup.setObjectName("an object name");
477 objNameGroups.add(objectNameGroup);
478 collectionObject.setObjectNameList(objNameList);
480 // Submit the request to the service and store the response.
481 CollectionObjectClient client = new CollectionObjectClient();
482 PoxPayloadOut multipart =
483 createCollectionObjectInstance(client.getCommonPartName(), collectionObject, null);
484 Response res = client.create(multipart);
486 int statusCode = res.getStatus();
487 // Read the response and verify that the create attempt failed.
488 if (logger.isDebugEnabled()) {
489 logger.debug(testName + ": status = " + statusCode);
491 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
492 invalidStatusCodeMessage(testRequestType, statusCode));
493 Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
498 // FIXME: Consider splitting off the following into its own test method.
500 // Build a payload with invalid content, by setting a value to the
501 // empty String, in a field (objectNumber) that requires a non-empty
502 // value, as enforced by the service's validation routine(s).
503 collectionObject = new CollectionobjectsCommon();
504 collectionObject.setObjectNumber("");
505 collectionObject.setDistinguishingFeatures("Distinguishing features.");
507 objNameList = new ObjectNameList();
508 objNameGroups = objNameList.getObjectNameGroup();
509 objectNameGroup = new ObjectNameGroup();
510 objectNameGroup.setObjectName(OBJECT_NAME_VALUE);
511 objNameGroups.add(objectNameGroup);
512 collectionObject.setObjectNameList(objNameList);
514 // Submit the request to the service and store the response.
515 multipart = createCollectionObjectInstance(client.getCommonPartName(), collectionObject, null);
516 res = client.create(multipart);
518 int statusCode = res.getStatus();
520 // Read the response and verify that the create attempt failed.
521 if (logger.isDebugEnabled()) {
522 logger.debug(testName + ": status = " + statusCode);
524 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
525 invalidStatusCodeMessage(testRequestType, statusCode));
526 Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
535 * @param testName the test name
537 * @return the client response
539 private Response updateRetrieve(String testName, String id) {
541 CollectionObjectClient client = new CollectionObjectClient();
542 Response res = client.read(knownResourceId);
543 int statusCode = res.getStatus();
544 // Check the status code of the response: does it match
545 // the expected response(s)?
546 if (logger.isDebugEnabled()) {
547 logger.debug(testName + ": read status = " + statusCode);
549 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
550 invalidStatusCodeMessage(testRequestType, statusCode));
551 Assert.assertEquals(statusCode, testExpectedStatusCode);
552 if(logger.isDebugEnabled()){
553 logger.debug("got object to update with ID: " + knownResourceId);
562 * @param testName the test name
564 * @return the client response
566 private Response updateSend(String testName, String id,
567 CollectionobjectsCommon collectionObjectCommon) {
569 PoxPayloadOut output = new PoxPayloadOut(CollectionObjectClient.SERVICE_PAYLOAD_NAME);
570 PayloadOutputPart commonPart = output.addPart(collectionObjectCommon, MediaType.APPLICATION_XML_TYPE);
571 CollectionObjectClient client = new CollectionObjectClient();
572 commonPart.setLabel(client.getCommonPartName());
574 Response res = client.update(knownResourceId, output);
575 int statusCode = res.getStatus();
576 // Check the status code of the response: does it match
577 // the expected response(s)?
578 if (logger.isDebugEnabled()) {
579 logger.debug(testName + ": read status = " + statusCode);
581 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
582 invalidStatusCodeMessage(testRequestType, statusCode));
583 Assert.assertEquals(statusCode, testExpectedStatusCode);
585 return res; // Calling needs to make sure they call res.close();
589 // Placeholders until the three tests below can be uncommented.
590 // See Issue CSPACE-401.
592 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
595 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
596 dependsOnMethods = {"CRUDTests"})
597 public void updateWithEmptyEntityBody(String testName) throws Exception {
598 //FIXME: Should this test really be empty?
602 * Test how the service handles XML that is not well formed,
603 * when sent in the payload of an Update request.
605 * @param testName The name of this test method. This name is supplied
606 * automatically, via reflection, by a TestNG 'data provider' in
610 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
611 dependsOnMethods = {"CRUDTests"})
612 public void updateWithMalformedXml(String testName) throws Exception {
613 //FIXME: Should this test really be empty?
617 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
620 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
621 dependsOnMethods = {"CRUDTests"})
622 public void updateWithWrongXmlSchema(String testName) throws Exception {
623 //FIXME: Should this test really be empty?
628 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
629 dependsOnMethods = {"create", "update", "testSubmitRequest"})
630 public void updateWithEmptyEntityBody(String testName) throws Exception {
632 if (logger.isDebugEnabled()) {
633 logger.debug(testBanner(testName, CLASS_NAME));
636 setupUpdateWithEmptyEntityBody();
638 // Submit the request to the service and store the response.
639 String method = REQUEST_TYPE.httpMethodName();
640 String url = getResourceURL(knownResourceId);
641 String mediaType = MediaType.APPLICATION_XML;
642 final String entity = "";
643 int statusCode = submitRequest(method, url, mediaType, entity);
645 // Check the status code of the response: does it match
646 // the expected response(s)?
647 if(logger.isDebugEnabled()){
648 logger.debug(testName + ": url=" + url +
649 " status=" + statusCode);
651 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
652 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
653 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
657 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
658 dependsOnMethods = {"create", "update", "testSubmitRequest"})
659 public void updateWithMalformedXml() throws Exception {
661 if (logger.isDebugEnabled()) {
662 logger.debug(testBanner(testName, CLASS_NAME));
665 setupUpdateWithMalformedXml();
667 // Submit the request to the service and store the response.
668 String method = REQUEST_TYPE.httpMethodName();
669 String url = getResourceURL(knownResourceId);
670 final String entity = MALFORMED_XML_DATA;
671 String mediaType = MediaType.APPLICATION_XML;
672 int statusCode = submitRequest(method, url, mediaType, entity);
674 // Check the status code of the response: does it match
675 // the expected response(s)?
676 if(logger.isDebugEnabled()){
677 logger.debug(testName + ": url=" + url +
678 " status=" + statusCode);
680 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
681 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
682 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
686 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
687 dependsOnMethods = {"create", "update", "testSubmitRequest"})
688 public void updateWithWrongXmlSchema(String testName) throws Exception {
690 if (logger.isDebugEnabled()) {
691 logger.debug(testBanner(testName, CLASS_NAME));
694 setupUpdateWithWrongXmlSchema();
696 // Submit the request to the service and store the response.
697 String method = REQUEST_TYPE.httpMethodName();
698 String url = getResourceURL(knownResourceId);
699 String mediaType = MediaType.APPLICATION_XML;
700 final String entity = WRONG_XML_SCHEMA_DATA;
701 int statusCode = submitRequest(method, url, mediaType, entity);
703 // Check the status code of the response: does it match
704 // the expected response(s)?
705 if(logger.isDebugEnabled()){
706 logger.debug(testName + ": url=" + url +
707 " status=" + statusCode);
709 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
710 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
711 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
716 public void updateNonExistent(String testName) throws Exception {
718 setupUpdateNonExistent();
720 // Submit the request to the service and store the response.
722 // Note: The ID used in this 'create' call may be arbitrary.
723 // The only relevant ID may be the one used in updateCollectionObject(), below.
724 CollectionObjectClient client = new CollectionObjectClient();
725 PoxPayloadOut multipart =
726 createInstance(client.getCommonPartName(), NON_EXISTENT_ID);
727 Response res = client.update(NON_EXISTENT_ID, multipart);
729 int statusCode = res.getStatus();
730 // Check the status code of the response: does it match
731 // the expected response(s)?
732 if (logger.isDebugEnabled()) {
733 logger.debug(testName + ": status = " + statusCode);
735 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
736 invalidStatusCodeMessage(testRequestType, statusCode));
737 Assert.assertEquals(statusCode, testExpectedStatusCode);
744 * Test how the service handles, in an Update request, payloads
745 * containing null values (or, in the case of String fields,
746 * empty String values) in one or more fields in which non-empty
747 * values are required.
749 * This is a test of code and/or configuration in the service's
750 * validation routine(s).
752 * @param testName The name of this test method. This name is supplied
753 * automatically, via reflection, by a TestNG 'data provider' in
757 // @Test(dataProvider = "testName", dependsOnMethods = {"CRUDTests"}) // REM - Disabled this test because of issues raised in CSPACE-6705
758 public void updateWithRequiredValuesNullOrEmpty(String testName) throws Exception {
759 // Read an existing record for updating.
760 Response res = updateRetrieve(testName, knownResourceId);
761 CollectionobjectsCommon collectionObjectCommon = null;
763 // Extract its common part.
764 collectionObjectCommon = extractCommonPartValue(res);
769 // Update the common part with invalid content, by setting a value to
770 // the empty String, in a field that requires a non-empty value,
771 // as enforced by the service's validation routine(s).
772 collectionObjectCommon.setObjectNumber("");
774 if (logger.isDebugEnabled()) {
775 logger.debug(testName + " updated object");
776 logger.debug(objectAsXmlString(collectionObjectCommon,
777 CollectionobjectsCommon.class));
780 // Submit the request to the service and store the response.
782 PoxPayloadOut output = new PoxPayloadOut(CollectionObjectClient.SERVICE_PAYLOAD_NAME);
783 CollectionObjectClient client = new CollectionObjectClient();
784 output.addPart(client.getCommonPartName(), collectionObjectCommon);
785 res = client.update(knownResourceId, output);
788 int statusCode = res.getStatus();
789 // Read the response and verify that the update attempt failed.
790 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
791 invalidStatusCodeMessage(testRequestType, statusCode));
792 Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
798 // ---------------------------------------------------------------
799 // CRUD tests : DELETE tests
800 // ---------------------------------------------------------------
804 public void delete(String testName) throws Exception {
806 // Create an object to delete, save the current 'knownResourceId' since we don't want to delete it yet
807 // and temporarily set it to the csid of the resource we just created.
809 String tempCsid = knownResourceId;
810 // the super.delete() method uses the knownResourceId member
811 knownResourceId = newCollectionObject(true);
814 super.delete(testName);
816 // reset the 'knownResourceId'
817 knownResourceId = tempCsid;
822 // Expected failure outcome tests
826 public void deleteNonExistent(String testName) throws Exception {
828 setupDeleteNonExistent();
830 // Submit the request to the service and store the response.
831 CollectionObjectClient client = new CollectionObjectClient();
832 Response res = client.delete(NON_EXISTENT_ID);
834 int statusCode = res.getStatus();
836 // Check the status code of the response: does it match
837 // the expected response(s)?
838 if (logger.isDebugEnabled()) {
839 logger.debug(testName + ": status = " + statusCode);
841 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
842 invalidStatusCodeMessage(testRequestType, statusCode));
843 Assert.assertEquals(statusCode, testExpectedStatusCode);
849 // ---------------------------------------------------------------
850 // Utility tests : tests of code used in tests above
851 // ---------------------------------------------------------------
854 * Tests the code for manually submitting data that is used by several
855 * of the methods above.
859 // ---------------------------------------------------------------
860 // Utility methods used by tests above
861 // ---------------------------------------------------------------
863 private Response newCollectionObject() {
864 Response result = null;
866 CollectionObjectClient client = new CollectionObjectClient();
867 String identifier = createIdentifier();
868 PoxPayloadOut multipart =
869 createInstance(client.getCommonPartName(), identifier);
870 result = client.create(multipart);
875 private String newCollectionObject(boolean assertStatus) {
876 String result = null;
878 Response res = newCollectionObject();
880 int statusCode = res.getStatus();
881 Assert.assertEquals(statusCode, STATUS_CREATED);
882 result = extractId(res);
891 protected PoxPayloadOut createInstance(String identifier) {
892 String commonPartName = CollectionObjectClient.SERVICE_COMMON_PART_NAME;
893 return createInstance(commonPartName, identifier);
897 * Creates the collection object instance.
899 * @param commonPartName the common part name
900 * @param identifier the identifier
901 * @return the multipart output
904 protected PoxPayloadOut createInstance(String commonPartName,
906 return createCollectionObjectInstance(commonPartName,
907 "objectNumber-" + identifier,
908 "objectName-" + identifier);
912 * Creates the collection object instance.
914 * @param commonPartName the common part name
915 * @param objectNumber the object number
916 * @param objectName the object name
917 * @return the multipart output
919 private PoxPayloadOut createCollectionObjectInstance(String commonPartName,
920 String objectNumber, String objectName) {
921 CollectionobjectsCommon collectionObject = new CollectionobjectsCommon();
924 collectionObject.setObjectNumber(objectNumber);
925 collectionObject.setAge(AGE_VALUE); //test for null string
927 // Repeatable structured groups
929 TitleGroupList titleGroupList = new TitleGroupList();
930 List<TitleGroup> titleGroups = titleGroupList.getTitleGroup();
931 Assert.assertNotNull(titleGroups);
932 TitleGroup titleGroup = new TitleGroup();
933 titleGroup.setTitle("a title");
934 titleGroups.add(titleGroup);
935 collectionObject.setTitleGroupList(titleGroupList);
937 ObjectNameList objNameList = new ObjectNameList();
938 List<ObjectNameGroup> objNameGroups = objNameList.getObjectNameGroup();
939 ObjectNameGroup objectNameGroup = new ObjectNameGroup();
940 objectNameGroup.setObjectName(OBJECT_NAME_VALUE);
941 objNameGroups.add(objectNameGroup);
942 collectionObject.setObjectNameList(objNameList);
944 MeasuredPartGroupList measuredPartGroupList = new MeasuredPartGroupList();
945 List<MeasuredPartGroup> measuredPartGroups = measuredPartGroupList.getMeasuredPartGroup();
946 Assert.assertNotNull(measuredPartGroups, "Measured part groups are null");
947 MeasuredPartGroup measuredPartGroup = new MeasuredPartGroup();
948 measuredPartGroup.setMeasuredPart(MEASURED_PART);
950 DimensionSubGroupList dimensionSubGroupList = new DimensionSubGroupList();
951 List<DimensionSubGroup> dimensionSubGroups = dimensionSubGroupList.getDimensionSubGroup();
952 Assert.assertNotNull(dimensionSubGroups, "Dimension subgroups are null");
954 DimensionSubGroup lengthDimension = new DimensionSubGroup();
955 lengthDimension.setDimension("length");
956 lengthDimension.setValue(DIMENSION_VALUE_LENGTH);
957 lengthDimension.setMeasurementUnit("cm");
958 dimensionSubGroups.add(lengthDimension);
960 DimensionSubGroup widthDimension = new DimensionSubGroup();
961 widthDimension.setDimension("width");
962 widthDimension.setValue(DIMENSION_VALUE_WIDTH);
963 widthDimension.setMeasurementUnit("m");
964 widthDimension.setValueQualifier(""); // test empty string
965 dimensionSubGroups.add(widthDimension);
967 measuredPartGroup.setDimensionSubGroupList(dimensionSubGroupList);
968 measuredPartGroups.add(measuredPartGroup);
969 collectionObject.setMeasuredPartGroupList(measuredPartGroupList);
971 // Repeatable scalar fields
973 BriefDescriptionList descriptionList = new BriefDescriptionList();
974 List<String> descriptions = descriptionList.getBriefDescription();
975 descriptions.add("Papier mache bird cow mask with horns, "
976 + "painted red with black and yellow spots. "
977 + "Puerto Rico. ca. 8" high, 6" wide, projects 10" (with horns).");
978 descriptions.add("Acrylic rabbit mask with wings, "
979 + "painted red with green and aquamarine spots. "
980 + "Puerto Rico. ca. 8" high, 6" wide, projects 10" (with wings).");
981 collectionObject.setBriefDescriptions(descriptionList);
983 ResponsibleDepartmentList deptList = new ResponsibleDepartmentList();
984 List<String> depts = deptList.getResponsibleDepartment();
985 // @TODO Use properly formatted refNames for representative departments
986 // in this example test record. The following are mere placeholders.
987 depts.add("urn:org.collectionspace.services.department:Registrar");
988 depts.add("urn:org.walkerart.department:Fine Art");
989 collectionObject.setResponsibleDepartments(deptList);
991 OtherNumberList otherNumList = new OtherNumberList();
992 List<OtherNumber> otherNumbers = otherNumList.getOtherNumber();
993 OtherNumber otherNumber1 = new OtherNumber();
994 otherNumber1.setNumberValue("101." + objectName);
995 otherNumber1.setNumberType("integer");
996 otherNumbers.add(otherNumber1);
997 OtherNumber otherNumber2 = new OtherNumber();
998 otherNumber2.setNumberValue("101.502.23.456." + objectName);
999 otherNumber2.setNumberType("ipaddress");
1000 otherNumbers.add(otherNumber2);
1001 collectionObject.setOtherNumberList(otherNumList);
1003 // Add instances of fields from an extension schema
1005 CollectionobjectsNaturalhistory conh = new CollectionobjectsNaturalhistory();
1006 // Laramie20110524 removed for build: conh.setNhString("test-string");
1007 // Laramie20110524 removed for build: conh.setNhInt(999);
1008 // Laramie20110524 removed for build: conh.setNhLong(9999);
1010 PoxPayloadOut multipart = createCollectionObjectInstance(commonPartName, collectionObject, conh);
1015 * Creates the collection object instance.
1017 * @param commonPartName the common part name
1018 * @param collectionObject the collection object
1019 * @param conh the conh
1020 * @return the multipart output
1022 private PoxPayloadOut createCollectionObjectInstance(String commonPartName,
1023 CollectionobjectsCommon collectionObject, CollectionobjectsNaturalhistory conh) {
1025 PoxPayloadOut multipart = CollectionObjectFactory.createCollectionObjectInstance(
1026 commonPartName, collectionObject, getNHPartName(), conh);
1027 if (logger.isDebugEnabled()) {
1028 logger.debug("to be created, collectionobject common");
1029 logger.debug(objectAsXmlString(collectionObject,
1030 CollectionobjectsCommon.class));
1034 if (logger.isDebugEnabled()) {
1035 logger.debug("to be created, collectionobject nhistory");
1036 logger.debug(objectAsXmlString(conh,
1037 CollectionobjectsNaturalhistory.class));
1045 * createCollectionObjectInstanceFromXml uses JAXB unmarshaller to retrieve
1046 * collectionobject from given file
1047 * @param commonPartName
1048 * @param commonPartFileName
1052 private PoxPayloadOut createCollectionObjectInstanceFromXml(String testName, String commonPartName,
1053 String commonPartFileName) throws Exception {
1055 CollectionobjectsCommon collectionObject =
1056 (CollectionobjectsCommon) getObjectFromFile(CollectionobjectsCommon.class,
1057 commonPartFileName);
1058 PoxPayloadOut multipart = new PoxPayloadOut(CollectionObjectClient.SERVICE_PAYLOAD_NAME);
1059 PayloadOutputPart commonPart = multipart.addPart(collectionObject,
1060 MediaType.APPLICATION_XML_TYPE);
1061 CollectionObjectClient client = new CollectionObjectClient();
1062 commonPart.setLabel(client.getCommonPartName());
1064 if (logger.isDebugEnabled()) {
1065 logger.debug(testName + " to be created, collectionobject common");
1066 logger.debug(objectAsXmlString(collectionObject,
1067 CollectionobjectsCommon.class));
1074 * createCollectionObjectInstanceFromRawXml uses stringified collectionobject
1075 * retrieve from given file
1076 * @param commonPartName
1077 * @param commonPartFileName
1081 private PoxPayloadOut createCollectionObjectInstanceFromRawXml(String testName, String commonPartName,
1082 String commonPartFileName) throws Exception {
1084 PoxPayloadOut multipart = new PoxPayloadOut(CollectionObjectClient.SERVICE_PAYLOAD_NAME);
1085 String stringObject = getXmlDocumentAsString(commonPartFileName);
1086 if (logger.isDebugEnabled()) {
1087 logger.debug(testName + " to be created, collectionobject common " + "\n" + stringObject);
1089 PayloadOutputPart commonPart = multipart.addPart(commonPartName, stringObject);
1090 // commonPart.setLabel(commonPartName);
1096 * Gets the nH part name.
1098 * @return the nH part name
1100 private String getNHPartName() {
1101 return "collectionobjects_naturalhistory";
1105 * Creates the from xml file.
1107 * @param testName the test name
1108 * @param fileName the file name
1109 * @param useJaxb the use jaxb
1110 * @return the string
1111 * @throws Exception the exception
1113 private String createFromXmlFile(String testName, String fileName, boolean useJaxb) throws Exception {
1117 PoxPayloadOut multipart = null;
1119 CollectionObjectClient client = new CollectionObjectClient();
1121 multipart = createCollectionObjectInstanceFromXml(testName,
1122 client.getCommonPartName(), fileName);
1124 multipart = createCollectionObjectInstanceFromRawXml(testName,
1125 client.getCommonPartName(), fileName);
1128 Response res = client.create(multipart);
1129 String newId = null;
1131 int statusCode = res.getStatus();
1132 if (logger.isDebugEnabled()) {
1133 logger.debug(testName + ": status = " + statusCode);
1135 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
1136 invalidStatusCodeMessage(testRequestType, statusCode));
1137 Assert.assertEquals(statusCode, testExpectedStatusCode);
1138 newId = extractId(res);
1139 allResourceIdsCreated.add(newId);
1147 // FIXME: This duplicates code in read(), and should be consolidated.
1148 // This is an expedient to support reading and verifying the contents
1149 // of resources that have been created from test data XML files.
1150 private CollectionobjectsCommon readCollectionObjectCommonPart(String csid)
1153 String testName = "readCollectionObjectCommonPart";
1157 // Submit the request to the service and store the response.
1158 CollectionObjectClient client = new CollectionObjectClient();
1159 Response res = client.read(csid);
1160 CollectionobjectsCommon collectionObject = null;
1162 int statusCode = res.getStatus();
1164 // Check the status code of the response: does it match
1165 // the expected response(s)?
1166 if (logger.isDebugEnabled()) {
1167 logger.debug(testName + ": status = " + statusCode);
1169 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
1170 invalidStatusCodeMessage(testRequestType, statusCode));
1171 Assert.assertEquals(statusCode, testExpectedStatusCode);
1173 // Extract the common part.
1174 collectionObject = extractCommonPartValue(res);
1175 Assert.assertNotNull(collectionObject);
1180 return collectionObject;
1184 protected String getServicePathComponent() {
1185 // TODO Auto-generated method stub
1186 return CollectionObjectClient.SERVICE_PATH_COMPONENT;
1190 protected CollectionobjectsCommon updateInstance(CollectionobjectsCommon collectionObjectCommon) {
1191 collectionObjectCommon.setObjectNumber("updated-" + collectionObjectCommon.getObjectNumber());
1193 // Change the object name in the first value instance in the
1194 // object name repeatable group.
1195 ObjectNameList objNameList = collectionObjectCommon.getObjectNameList();
1196 List<ObjectNameGroup> objNameGroups = objNameList.getObjectNameGroup();
1197 Assert.assertNotNull(objNameGroups);
1198 Assert.assertTrue(objNameGroups.size() >= 1);
1199 String objectName = objNameGroups.get(0).getObjectName();
1200 Assert.assertEquals(objectName, OBJECT_NAME_VALUE);
1201 String updatedObjectName = "updated-" + objectName;
1202 objNameGroups.get(0).setObjectName(updatedObjectName);
1203 collectionObjectCommon.setObjectNameList(objNameList);
1205 // Replace the existing value instances in the dimensions repeatable group
1206 // with entirely new value instances, also changing the number of such instances.
1207 MeasuredPartGroupList measuredPartGroupList = collectionObjectCommon.getMeasuredPartGroupList();
1208 Assert.assertNotNull(measuredPartGroupList);
1209 List<MeasuredPartGroup> measuredPartGroups = measuredPartGroupList.getMeasuredPartGroup();
1210 Assert.assertNotNull(measuredPartGroups);
1211 Assert.assertTrue(measuredPartGroups.size() > 0);
1212 MeasuredPartGroup mpGroup = measuredPartGroups.get(0);
1213 Assert.assertNotNull(mpGroup.getMeasuredPart());
1215 DimensionSubGroupList dimensionSubGroupList = mpGroup.getDimensionSubGroupList();
1216 Assert.assertNotNull(dimensionSubGroupList);
1217 List<DimensionSubGroup> dimensionSubGroups = dimensionSubGroupList.getDimensionSubGroup();
1218 Assert.assertNotNull(dimensionSubGroups);
1219 int originalDimensionSubGroupSize = dimensionSubGroups.size();
1220 Assert.assertTrue(dimensionSubGroups.size() > 0);
1221 dimensionSubGroups.clear();
1223 DimensionSubGroup heightDimension = new DimensionSubGroup();
1224 heightDimension.setDimension("height");
1225 heightDimension.setMeasurementUnit(UPDATED_MEASUREMENT_UNIT);
1226 dimensionSubGroups.add(heightDimension);
1228 int updatedDimensionGroupSize = dimensionSubGroups.size();
1229 Assert.assertTrue(updatedDimensionGroupSize > 0);
1230 Assert.assertTrue(updatedDimensionGroupSize != originalDimensionSubGroupSize);
1232 collectionObjectCommon.setMeasuredPartGroupList(measuredPartGroupList);
1234 return collectionObjectCommon;
1238 protected void compareReadInstances(CollectionobjectsCommon original,
1239 CollectionobjectsCommon fromRead) throws Exception {
1240 // Verify the number and contents of values in repeatable fields,
1241 // as created in the instance record used for testing.
1242 MeasuredPartGroupList measuredPartGroupList = fromRead.getMeasuredPartGroupList();
1243 Assert.assertNotNull(measuredPartGroupList, "Measured part group list was null");
1244 List<MeasuredPartGroup> measuredPartGroups = measuredPartGroupList.getMeasuredPartGroup();
1245 Assert.assertNotNull(measuredPartGroups, "Measured part groups were null");
1246 Assert.assertTrue(measuredPartGroups.size() > 0, "No measured part groups were returned");
1247 MeasuredPartGroup mpGroup = measuredPartGroups.get(0);
1248 Assert.assertNotNull(mpGroup.getMeasuredPart(), "Measured part was null");
1249 Assert.assertEquals(mpGroup.getMeasuredPart(), MEASURED_PART,
1250 "Measured part value returned didn't match expected value");
1252 DimensionSubGroupList dimensionSubGroupList = mpGroup.getDimensionSubGroupList();
1253 Assert.assertNotNull(dimensionSubGroupList, "Dimension subgroup list was null");
1254 List<DimensionSubGroup> dimensionSubGroups = dimensionSubGroupList.getDimensionSubGroup();
1255 Assert.assertNotNull(dimensionSubGroups, "Dimension subgroups were null");
1256 Assert.assertTrue(dimensionSubGroups.size() > 0, "No dimension subgroups were returned");
1257 DimensionSubGroup lengthDimension = dimensionSubGroups.get(0);
1258 Assert.assertNotNull(lengthDimension, "Length dimension was null");
1259 Assert.assertTrue(lengthDimension.getValue().compareTo(DIMENSION_VALUE_LENGTH) == 0,
1260 "Dimension length value returned didn't match expected value");
1264 protected void compareUpdatedInstances(CollectionobjectsCommon original,
1265 CollectionobjectsCommon updated) throws Exception {
1267 ObjectNameList objNameList = updated.getObjectNameList();
1268 Assert.assertNotNull(objNameList);
1269 List<ObjectNameGroup> objNameGroups = objNameList.getObjectNameGroup();
1270 Assert.assertNotNull(objNameGroups);
1271 Assert.assertTrue(objNameGroups.size() >= 1);
1272 Assert.assertEquals(original.getObjectNameList().getObjectNameGroup().get(0).getObjectName(),
1273 objNameGroups.get(0).getObjectName(),
1274 "Data in updated object did not match submitted data.");
1276 // Get the dimension group size of the original
1278 MeasuredPartGroupList measuredPartGroupList = original.getMeasuredPartGroupList();
1279 List<MeasuredPartGroup> measuredPartGroups = measuredPartGroupList.getMeasuredPartGroup();
1280 MeasuredPartGroup mpGroup = measuredPartGroups.get(0);
1281 DimensionSubGroupList dimensionSubGroupList = mpGroup.getDimensionSubGroupList();
1282 List<DimensionSubGroup> dimensionSubGroups = dimensionSubGroupList.getDimensionSubGroup();
1283 int updatedDimensionGroupSize = dimensionSubGroups.size();
1285 // Now get the dimension group size of the updated
1287 measuredPartGroupList = updated.getMeasuredPartGroupList();
1288 Assert.assertNotNull(measuredPartGroupList);
1289 measuredPartGroups = measuredPartGroupList.getMeasuredPartGroup();
1290 Assert.assertNotNull(measuredPartGroups);
1291 Assert.assertTrue(measuredPartGroups.size() > 0);
1292 mpGroup = measuredPartGroups.get(0);
1293 Assert.assertNotNull(mpGroup.getMeasuredPart());
1294 dimensionSubGroupList = mpGroup.getDimensionSubGroupList();
1295 Assert.assertNotNull(dimensionSubGroupList);
1296 dimensionSubGroups = dimensionSubGroupList.getDimensionSubGroup();
1297 Assert.assertNotNull(dimensionSubGroups);
1298 Assert.assertTrue(dimensionSubGroups.size() == updatedDimensionGroupSize);
1300 Assert.assertEquals(UPDATED_MEASUREMENT_UNIT,
1301 dimensionSubGroups.get(0).getMeasurementUnit(),
1302 "Data in updated object did not match submitted data.");