]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-2677: Services document framework (and Movement service, in which date fields...
authorAron Roberts <aron@socrates.berkeley.edu>
Mon, 23 Aug 2010 20:40:32 +0000 (20:40 +0000)
committerAron Roberts <aron@socrates.berkeley.edu>
Mon, 23 Aug 2010 20:40:32 +0000 (20:40 +0000)
services/common/src/main/java/org/collectionspace/services/common/document/DocumentUtils.java
services/movement/client/src/test/java/org/collectionspace/services/client/test/MovementServiceTest.java

index dbb5019f7e95247b7afd4dfd7d421334aa6fe73d..d4334cc342f68dc64c03ad3e7760a7b77c4c7369 100644 (file)
@@ -1111,19 +1111,24 @@ public class DocumentUtils {
                
                if (type.isSimpleType()) {
                         if (isDateType(type)) {
-                            // Dates or date/times in ISO 8601-based representations
-                            // directly supported by Nuxeo will be successfully decoded.
-                            result = type.decode(element.getText());
-                            // All other date or date/time values must first be converted
-                            // to a supported ISO 8601-based representation.
-                            if (result == null) {
-                                dateStr = DateTimeFormatUtils.toIso8601Timestamp(element.getText(),
-                                        ctx.getTenantId());
-                                if (dateStr != null) {
-                                    result = type.decode(dateStr);
-                                } else {
-                                    throw new IllegalArgumentException("Unrecognized date value '"
-                                            + element.getText() + "' in field '" + element.getName() + "'");
+                            String value = element.getText();
+                            if (value == null || value.trim().isEmpty()) {
+                                result = type.decode("");
+                            } else {
+                                // Dates or date/times in ISO 8601-based representations
+                                // directly supported by Nuxeo will be successfully decoded.
+                                result = type.decode(element.getText());
+                                // All other date or date/time values must first be converted
+                                // to a supported ISO 8601-based representation.
+                                if (result == null) {
+                                    dateStr = DateTimeFormatUtils.toIso8601Timestamp(element.getText(),
+                                            ctx.getTenantId());
+                                    if (dateStr != null) {
+                                        result = type.decode(dateStr);
+                                    } else {
+                                        throw new IllegalArgumentException("Unrecognized date value '"
+                                                + element.getText() + "' in field '" + element.getName() + "'");
+                                    }
                                 }
                             }
                         } else {
index e3e08fde638a578bf417e222e374c0c940c4401d..b8d2c9368bae34fc3ca529706c643dd0d9bbe6a8 100644 (file)
@@ -315,7 +315,7 @@ public class MovementServiceTest extends AbstractServiceTestImpl {
         }
         Assert.assertTrue(movement.getLocationDate().equals(TIMESTAMP_UTC));
         Assert.assertTrue(movement.getPlannedRemovalDate().equals(TIMESTAMP_UTC));
-        Assert.assertTrue(movement.getRemovalDate().equals(TIMESTAMP_UTC));
+        Assert.assertNull(movement.getRemovalDate());
     }
 
     // Failure outcomes
@@ -446,6 +446,10 @@ public class MovementServiceTest extends AbstractServiceTestImpl {
             logger.debug("to be updated object");
             logger.debug(objectAsXmlString(movement, MovementsCommon.class));
         }
+        String currentTimestamp = GregorianCalendarDateTimeUtils.timestampUTC();
+        movement.setPlannedRemovalDate(""); // Test deletion of existing date or date/time value
+        movement.setRemovalDate(currentTimestamp);
+
         // Submit the request to the service and store the response.
         MultipartOutput output = new MultipartOutput();
         OutputPart commonPart = output.addPart(movement, MediaType.APPLICATION_XML_TYPE);
@@ -461,16 +465,27 @@ public class MovementServiceTest extends AbstractServiceTestImpl {
                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
 
-
         input = (MultipartInput) res.getEntity();
         MovementsCommon updatedMovement =
                 (MovementsCommon) extractPart(input,
                         client.getCommonPartName(), MovementsCommon.class);
         Assert.assertNotNull(updatedMovement);
 
+        if(logger.isDebugEnabled()){
+            logger.debug("updated object");
+            logger.debug(objectAsXmlString(movement, MovementsCommon.class));
+        }
+
+        Assert.assertEquals(updatedMovement.getMovementReferenceNumber(),
+            movement.getMovementReferenceNumber(),
+            "Data in updated object did not match submitted data.");
         Assert.assertEquals(updatedMovement.getMovementNote(),
-                movement.getMovementNote(),
-                "Data in updated object did not match submitted data.");
+            movement.getMovementNote(),
+            "Data in updated object did not match submitted data.");
+        Assert.assertNull(updatedMovement.getPlannedRemovalDate());
+        Assert.assertEquals(updatedMovement.getRemovalDate(),
+            movement.getRemovalDate(),
+            "Data in updated object did not match submitted data.");
 
     }
 
@@ -763,7 +778,7 @@ public class MovementServiceTest extends AbstractServiceTestImpl {
         movement.setMovementNote("movementNote value");
         movement.setMovementReferenceNumber(movementReferenceNumber);
         movement.setPlannedRemovalDate(TIMESTAMP_UTC);
-        movement.setRemovalDate(TIMESTAMP_UTC);
+        movement.setRemovalDate(""); // Test empty date value
         movement.setReasonForMove("reasonForMove value");
         MultipartOutput multipart = new MultipartOutput();
         OutputPart commonPart =