From 95f6ae6f5696f9c22e43df20c98e51942317a8df Mon Sep 17 00:00:00 2001 From: Aron Roberts Date: Thu, 11 Nov 2010 06:30:30 +0000 Subject: [PATCH] CSPACE-2933: Added client tests for repeatable currentLocation group in Intake service records. Renamed outer element to currentLocationGroupList for naming consistency with other recent repeatability changes. --- .../main/resources/schemas/intakes_common.xsd | 4 +- .../client/test/IntakeServiceTest.java | 47 ++++++++++++++++++- .../src/main/resources/intakes-common.xsd | 4 +- 3 files changed, 49 insertions(+), 6 deletions(-) diff --git a/services/intake/3rdparty/nuxeo-platform-cs-intake/src/main/resources/schemas/intakes_common.xsd b/services/intake/3rdparty/nuxeo-platform-cs-intake/src/main/resources/schemas/intakes_common.xsd index 39ef60777..8f8b62f24 100644 --- a/services/intake/3rdparty/nuxeo-platform-cs-intake/src/main/resources/schemas/intakes_common.xsd +++ b/services/intake/3rdparty/nuxeo-platform-cs-intake/src/main/resources/schemas/intakes_common.xsd @@ -92,7 +92,7 @@ - + @@ -123,7 +123,7 @@ - + diff --git a/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeServiceTest.java b/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeServiceTest.java index cbce62640..f53896fec 100644 --- a/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeServiceTest.java +++ b/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeServiceTest.java @@ -30,6 +30,8 @@ import org.collectionspace.services.client.CollectionSpaceClient; import org.collectionspace.services.client.IntakeClient; import org.collectionspace.services.intake.EntryMethodList; import org.collectionspace.services.intake.FieldCollectionEventNameList; +import org.collectionspace.services.intake.CurrentLocationGroup; +import org.collectionspace.services.intake.CurrentLocationGroupList; import org.collectionspace.services.intake.IntakesCommon; import org.collectionspace.services.intake.IntakesCommonList; import org.collectionspace.services.jaxb.AbstractCommonList; @@ -313,6 +315,15 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { intake.getFieldCollectionEventNames().getFieldCollectionEventName(); Assert.assertTrue(fieldCollectionEventNames.size() > 0); Assert.assertNotNull(fieldCollectionEventNames.get(0)); + + CurrentLocationGroupList currentLocationGroupList = intake.getCurrentLocationGroupList(); + Assert.assertNotNull(currentLocationGroupList); + List currentLocationGroups = currentLocationGroupList.getCurrentLocationGroup(); + Assert.assertNotNull(currentLocationGroups); + Assert.assertTrue(currentLocationGroups.size() > 0); + CurrentLocationGroup currentLocationGroup = currentLocationGroups.get(0); + Assert.assertNotNull(currentLocationGroup); + Assert.assertNotNull(currentLocationGroup.getCurrentLocationNote()); } // Failure outcomes @@ -434,7 +445,6 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { client.getCommonPartName(), IntakesCommon.class); Assert.assertNotNull(intake); - // Update the content of this resource. // Update the content of this resource. intake.setEntryNumber("updated-" + intake.getEntryNumber()); intake.setEntryDate("updated-" + intake.getEntryDate()); @@ -442,6 +452,20 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { logger.debug("to be updated object"); logger.debug(objectAsXmlString(intake, IntakesCommon.class)); } + + CurrentLocationGroupList currentLocationGroupList = intake.getCurrentLocationGroupList(); + Assert.assertNotNull(currentLocationGroupList); + List currentLocationGroups = currentLocationGroupList.getCurrentLocationGroup(); + Assert.assertNotNull(currentLocationGroups); + Assert.assertTrue(currentLocationGroups.size() > 0); + CurrentLocationGroup currentLocationGroup = currentLocationGroups.get(0); + Assert.assertNotNull(currentLocationGroup); + String currentLocationNote = currentLocationGroup.getCurrentLocationNote(); + Assert.assertNotNull(currentLocationNote); + String updatedCurrentLocationNote = "updated-" + currentLocationNote; + currentLocationGroups.get(0).setCurrentLocationNote(updatedCurrentLocationNote); + intake.setCurrentLocationGroupList(currentLocationGroupList); + // Submit the request to the service and store the response. MultipartOutput output = new MultipartOutput(); OutputPart commonPart = output.addPart(intake, MediaType.APPLICATION_XML_TYPE); @@ -457,17 +481,27 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - input = (MultipartInput) res.getEntity(); IntakesCommon updatedIntake = (IntakesCommon) extractPart(input, client.getCommonPartName(), IntakesCommon.class); + Assert.assertNotNull(updatedIntake); Assert.assertEquals(updatedIntake.getEntryDate(), intake.getEntryDate(), "Data in updated object did not match submitted data."); + currentLocationGroupList = updatedIntake.getCurrentLocationGroupList(); + Assert.assertNotNull(currentLocationGroupList); + currentLocationGroups = currentLocationGroupList.getCurrentLocationGroup(); + Assert.assertNotNull(currentLocationGroups); + Assert.assertTrue(currentLocationGroups.size() > 0); + Assert.assertNotNull(currentLocationGroups.get(0)); + Assert.assertEquals(updatedCurrentLocationNote, + currentLocationGroups.get(0).getCurrentLocationNote(), + "Data in updated object did not match submitted data."); + } // Failure outcomes @@ -764,6 +798,15 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { eventNames.add("Field Collection Event Name-2"); intake.setFieldCollectionEventNames(eventNamesList); + CurrentLocationGroupList currentLocationGroupList = new CurrentLocationGroupList(); + List currentLocationGroups = currentLocationGroupList.getCurrentLocationGroup(); + CurrentLocationGroup currentLocationGroup = new CurrentLocationGroup(); + currentLocationGroup.setCurrentLocation("upstairs"); + currentLocationGroup.setCurrentLocationFitness("suitable"); + currentLocationGroup.setCurrentLocationNote("A most suitable location."); + currentLocationGroups.add(currentLocationGroup); + intake.setCurrentLocationGroupList(currentLocationGroupList); + MultipartOutput multipart = new MultipartOutput(); OutputPart commonPart = multipart.addPart(intake, MediaType.APPLICATION_XML_TYPE); diff --git a/services/intake/jaxb/src/main/resources/intakes-common.xsd b/services/intake/jaxb/src/main/resources/intakes-common.xsd index 4a8f70569..fe567f4bb 100644 --- a/services/intake/jaxb/src/main/resources/intakes-common.xsd +++ b/services/intake/jaxb/src/main/resources/intakes-common.xsd @@ -67,7 +67,7 @@ - + @@ -119,7 +119,7 @@ - + -- 2.47.3