From bad794c52538e8251b5194a10e635729402b8e15 Mon Sep 17 00:00:00 2001 From: Aron Roberts Date: Wed, 24 Mar 2010 00:02:40 +0000 Subject: [PATCH] CSPACE-1248: Allow values of multivalued, repeatable elements to be null or empty. --- .../test/CollectionObjectServiceTest.java | 21 ++++++++++++------- .../common/document/DocumentUtils.java | 9 +++++--- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java b/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java index fdd7ed3eb..92e472986 100644 --- a/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java +++ b/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java @@ -121,35 +121,40 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { * Tests to diagnose and verify the fixed status of CSPACE-1026, * "Whitespace at certain points in payload cause failure" */ - @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class) + @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, + dependsOnMethods = {"create", "testSubmitRequest"}) public void createFromXmlCambridge(String testName) throws Exception { String newId = createFromXmlFile(testName, "./test-data/testCambridge.xml", true); testSubmitRequest(newId); } - @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class) + @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, + dependsOnMethods = {"create", "testSubmitRequest"}) public void createFromXmlRFWS1(String testName) throws Exception { String newId = createFromXmlFile(testName, "./target/test-classes/test-data/repfield_whitesp1.xml", false); testSubmitRequest(newId); } - @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class) + @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, + dependsOnMethods = {"create", "testSubmitRequest"}) public void createFromXmlRFWS2(String testName) throws Exception { String newId = createFromXmlFile(testName, "./target/test-classes/test-data/repfield_whitesp2.xml", false); testSubmitRequest(newId); } - @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class) + @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, + dependsOnMethods = {"create", "testSubmitRequest"}) public void createFromXmlRFWS3(String testName) throws Exception { String newId = createFromXmlFile(testName, "./target/test-classes/test-data/repfield_whitesp3.xml", false); testSubmitRequest(newId); } - @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class) + @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, + dependsOnMethods = {"create", "testSubmitRequest"}) public void createFromXmlRFWS4(String testName) throws Exception { String newId = createFromXmlFile(testName, "./target/test-classes/test-data/repfield_whitesp4.xml", false); @@ -162,7 +167,8 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { * fields, which contain null values, can be successfully created * but an error occurs on trying to retrieve those records). */ - @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class) + @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, + dependsOnMethods = {"create", "testSubmitRequest"}) public void createWithNullValueRepeatableField(String testName) throws Exception { String newId = createFromXmlFile(testName, "./target/test-classes/test-data/repfield_null1.xml", false); @@ -170,8 +176,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { logger.debug("Successfully created record with null value repeatable field."); logger.debug("Attempting to retrieve just-created record ..."); } - // This test will fail until CSPACE-1248 is fixed: - // testSubmitRequest(newId); + testSubmitRequest(newId); } /* (non-Javadoc) diff --git a/services/common/src/main/java/org/collectionspace/services/common/document/DocumentUtils.java b/services/common/src/main/java/org/collectionspace/services/common/document/DocumentUtils.java index 32658cf42..6b81435db 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/document/DocumentUtils.java +++ b/services/common/src/main/java/org/collectionspace/services/common/document/DocumentUtils.java @@ -268,7 +268,7 @@ public class DocumentUtils { } /** - * unqualify given value. if the given input value is not qualified, throw exception + * unqualify given value. * input of otherNumber|urn:org.collectionspace.id:24082390 would be unqualified * as name=otherNumber and value=urn:org.collectionspace.id:24082390 * @param input @@ -282,9 +282,12 @@ public class DocumentUtils { if (tokens == 2) { nv.name = stz.nextToken(); nv.value = stz.nextToken(); + // Allow null or empty values + } else if (tokens == 1) { + nv.name = stz.nextToken(); + nv.value = ""; } else { - throw new IllegalStateException("Found multi valued element " + input - + " without qualification"); + throw new IllegalStateException("Unexpected format for multi valued element: " + input); } return nv; } -- 2.47.3