testSubmitRequest(newId);
}
+ /*
+ * Tests to diagnose and fix CSPACE-2242.
+ *
+ * This is a bug identified in release 0.8 in which value instances of a
+ * repeatable field are not stored when the first value instance of that
+ * field is blank.
+ */
+
+ // Verify that record creation occurs successfully when the first value instance
+ // of a single, repeatble String scalar field is non-blank.
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ dependsOnMethods = {"create", "testSubmitRequest"}, groups = {"cspace2242group"})
+ public void createFromXmlNonBlankFirstValueInstance(String testName) throws Exception {
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
+ }
+ String newId =
+ createFromXmlFile(testName, "./test-data/cspace-2242-first-value-instance-nonblank.xml", true);
+ CollectionobjectsCommon collectionObject = readCollectionObjectCommonPart(newId);
+ // Verify that at least one value instance of the repeatable field was successfully persisted.
+ BriefDescriptionList descriptionList = collectionObject.getBriefDescriptions();
+ List<String> descriptions = descriptionList.getBriefDescription();
+ Assert.assertTrue(descriptions.size() > 0);
+ }
+
+ // Verify that record creation occurs successfully when the first value instance
+ // of a single, repeatble String scalar field is blank.
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ dependsOnMethods = {"create", "testSubmitRequest"}, groups = {"cspace2242group"})
+ public void createFromXmlBlankFirstValueInstance(String testName) throws Exception {
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
+ }
+ String newId =
+ createFromXmlFile(testName, "./test-data/cspace-2242-first-value-instance-blank.xml", true);
+ CollectionobjectsCommon collectionObject = readCollectionObjectCommonPart(newId);
+ // Verify that at least one value instance of the repeatable field was successfully persisted.
+ BriefDescriptionList descriptionList = collectionObject.getBriefDescriptions();
+ List<String> descriptions = descriptionList.getBriefDescription();
+ // Assert.assertTrue(descriptions.size() > 0);
+ }
+
/**
* Creates the from xml rfw s1.
*
testSubmitRequest(newId);
}
- /*
- * Tests to diagnose and verify the fixed status of CSPACE-1248,
- * "Wedged records created!" (i.e. records with child repeatable
- * fields, which contain null values, can be successfully created
- * but an error occurs on trying to retrieve those records).
- */
+// /*
+// * Tests to diagnose and verify the fixed status of CSPACE-1248,
+// * "Wedged records created!" (i.e. records with child repeatable
+// * fields, which contain null values, can be successfully created
+// * but an error occurs on trying to retrieve those records).
+// */
/**
* Creates the with null value repeatable field.
*
allResourceIdsCreated.add(newId);
return newId;
}
+
+ // FIXME: This duplicates code in read(), and should be consolidated.
+ // This is an expedient to support reading and verifying the contents
+ // of resources that have been created from test data XML files.
+ private CollectionobjectsCommon readCollectionObjectCommonPart(String csid)
+ throws Exception {
+
+ String testName = "readCollectionObjectCommonPart";
+
+ setupRead();
+
+ // Submit the request to the service and store the response.
+ CollectionObjectClient client = new CollectionObjectClient();
+ ClientResponse<MultipartInput> res = client.read(csid);
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ MultipartInput input = (MultipartInput) res.getEntity();
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": Reading Common part ...");
+ }
+ CollectionobjectsCommon collectionObject =
+ (CollectionobjectsCommon) extractPart(input,
+ client.getCommonPartName(), CollectionobjectsCommon.class);
+ Assert.assertNotNull(collectionObject);
+
+ return collectionObject;
+ }
}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Document : cspace-2242-first-value-instance-blank.xml
+ Created on :
+ Author :
+ Description: Test data for http://issues.collectionspace.org/browse/CSPACE-2242
+-->
+
+<ns2:collectionobjects_common
+ xmlns:ns2="http://collectionspace.org/services/collectionobject"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://collectionspace.org/services/collectionobject http://services.collectionspace.org/collectionobject/collectionobjects_common.xsd">
+ <objectNumber>2</objectNumber>
+ <comments>description</comments>
+ <objectName>Left-handed screwdriver</objectName>
+ <title></title>
+ <briefDescriptions>
+ <!-- First value instance of this repeatable field is blank -->
+ <briefDescription></briefDescription>
+ <briefDescription></briefDescription>
+ <briefDescription>bob2</briefDescription>
+ </briefDescriptions>
+</ns2:collectionobjects_common>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Document : cspace-2242-first-value-instance-nonblank.xml
+ Created on :
+ Author :
+ Description: Test data for http://issues.collectionspace.org/browse/CSPACE-2242
+-->
+
+<ns2:collectionobjects_common
+ xmlns:ns2="http://collectionspace.org/services/collectionobject"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://collectionspace.org/services/collectionobject http://services.collectionspace.org/collectionobject/collectionobjects_common.xsd">
+ <objectNumber>2</objectNumber>
+ <comments>description</comments>
+ <objectName>Left-handed screwdriver</objectName>
+ <title></title>
+ <briefDescriptions>
+ <!-- First value instance of this repeatable field is non-blank -->
+ <briefDescription>data</briefDescription>
+ <briefDescription></briefDescription>
+ <briefDescription>bob2</briefDescription>
+ </briefDescriptions>
+</ns2:collectionobjects_common>