/** * Obtains a String representation of a Nuxeo property value, where the latter is an opaque Object * that may or may not be directly convertible to a string. * * @param obj an Object containing a property value * @param docModel the document model associated with this property. * @param propertyPath a path to the property, such as a property name, XPath, etc. * @return a String representation of the Nuxeo property value. */ public static String propertyValueAsString( Object obj, DocumentModel docModel, String propertyPath) { if (obj == null) { return ""; } if (String.class.isAssignableFrom(obj.getClass())) { return (String) obj; } else { // Handle cases where a property value returned from the repository // can't be directly cast to a String. // // FIXME: This method provides specific, hard-coded formatting // for String representations of property values. We might want // to add the ability to specify these formats via configuration. // - ADR 2013-04-26 if (obj instanceof GregorianCalendar) { return GregorianCalendarDateTimeUtils.formatAsISO8601Date((GregorianCalendar) obj); } else if (obj instanceof Double) { return nuxeoDecimalValueToDecimalString(obj); } else { logger.warn( "Could not convert value of property " + propertyPath + " in document " + docModel.getPathAsString() + " to a String."); logger.warn( "This may be due to a new, as-yet-unhandled datatype returned from the repository"); return ""; } } }
@Override protected MovementsCommon updateInstance(MovementsCommon movementsCommon) { MovementsCommon result = new MovementsCommon(); result.setMovementReferenceNumber("updated-" + movementsCommon.getMovementReferenceNumber()); result.setMovementNote("updated movement note-" + movementsCommon.getMovementNote()); result.setNormalLocation(""); // Test deletion of existing // string value String currentTimestamp = GregorianCalendarDateTimeUtils.timestampUTC(); result.setPlannedRemovalDate(""); // Test deletion of existing // date or date/time value result.setRemovalDate(currentTimestamp); return result; }
/** * LoaninServiceTest, carries out tests against a deployed and running Loanin (aka Loans In) * Service. * * <p>$LastChangedRevision$ $LastChangedDate$ */ public class LoaninServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonList, LoansinCommon> { /** The logger. */ private final String CLASS_NAME = LoaninServiceTest.class.getName(); private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); // Instance variables specific to this test. /** The service path component. */ final String SERVICE_NAME = "loansin"; final String SERVICE_PATH_COMPONENT = "loansin"; private String LENDER_REF_NAME = "urn:cspace:org.collectionspace.demo:personauthorities:name(TestPersonAuth):item:name(HarryLender)'Harry Lender'"; private static final String CURRENT_DATE_UTC = GregorianCalendarDateTimeUtils.currentDateUTC(); /* (non-Javadoc) * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance() */ @Override protected CollectionSpaceClient getClientInstance() throws Exception { return new LoaninClient(); } @Override protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception { return new LoaninClient(clientPropertiesFilename); } /* (non-Javadoc) * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse) */ @Override protected AbstractCommonList getCommonList(Response response) { return response.readEntity(AbstractCommonList.class); } // --------------------------------------------------------------- // CRUD tests : CREATE tests // --------------------------------------------------------------- // Success outcomes /* (non-Javadoc) * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String) */ @Override // @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class) public void create(String testName) throws Exception { // Perform setup, such as initializing the type of service request // (e.g. CREATE, DELETE), its valid and expected status codes, and // its associated HTTP method name (e.g. POST, DELETE). setupCreate(); // Submit the request to the service and store the response. LoaninClient client = new LoaninClient(); String identifier = createIdentifier(); PoxPayloadOut multipart = createLoaninInstance(identifier); String newID = null; Response res = client.create(multipart); try { int statusCode = res.getStatus(); // Check the status code of the response: does it match // the expected response(s)? // // Specifically: // Does it fall within the set of valid status codes? // Does it exactly match the expected status code? if (logger.isDebugEnabled()) { logger.debug(testName + ": status = " + statusCode); } Assert.assertTrue( testRequestType.isValidStatusCode(statusCode), invalidStatusCodeMessage(testRequestType, statusCode)); Assert.assertEquals(statusCode, testExpectedStatusCode); newID = extractId(res); } finally { if (res != null) { res.close(); } } // Store the ID returned from the first resource created // for additional tests below. if (knownResourceId == null) { knownResourceId = newID; if (logger.isDebugEnabled()) { logger.debug(testName + ": knownResourceId=" + knownResourceId); } } // Store the IDs from every resource created by tests, // so they can be deleted after tests have been run. allResourceIdsCreated.add(newID); } /* (non-Javadoc) * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String) */ @Override // @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, // dependsOnMethods = {"create"}) public void createList(String testName) throws Exception { for (int i = 0; i < 3; i++) { create(testName); } } /* @Override @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, dependsOnMethods = {"create", "testSubmitRequest"}) public void createWithEmptyEntityBody(String testName) throws Exception { if (logger.isDebugEnabled()) { logger.debug(testBanner(testName, CLASS_NAME)); } // Perform setup. setupCreateWithEmptyEntityBody(); // Submit the request to the service and store the response. String method = REQUEST_TYPE.httpMethodName(); String url = getServiceRootURL(); String mediaType = MediaType.APPLICATION_XML; final String entity = ""; int statusCode = submitRequest(method, url, mediaType, entity); // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ logger.debug("createWithEmptyEntityBody url=" + url + " status=" + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, dependsOnMethods = {"create", "testSubmitRequest"}) public void createWithMalformedXml(String testName) throws Exception { if (logger.isDebugEnabled()) { logger.debug(testBanner(testName, CLASS_NAME)); } // Perform setup. setupCreateWithMalformedXml(testName, logger); // Submit the request to the service and store the response. String method = REQUEST_TYPE.httpMethodName(); String url = getServiceRootURL(); String mediaType = MediaType.APPLICATION_XML; final String entity = MALFORMED_XML_DATA; // Constant from base class. int statusCode = submitRequest(method, url, mediaType, entity); // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ logger.debug(testName + ": url=" + url + " status=" + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, dependsOnMethods = {"create", "testSubmitRequest"}) public void createWithWrongXmlSchema(String testName) throws Exception { if (logger.isDebugEnabled()) { logger.debug(testBanner(testName, CLASS_NAME)); } // Perform setup. setupCreateWithWrongXmlSchema(testName, logger); // Submit the request to the service and store the response. String method = REQUEST_TYPE.httpMethodName(); String url = getServiceRootURL(); String mediaType = MediaType.APPLICATION_XML; final String entity = WRONG_XML_SCHEMA_DATA; int statusCode = submitRequest(method, url, mediaType, entity); // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ logger.debug(testName + ": url=" + url + " status=" + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } */ // --------------------------------------------------------------- // CRUD tests : READ tests // --------------------------------------------------------------- // Success outcomes /* (non-Javadoc) * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String) */ @Override // @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, // dependsOnMethods = {"create"}) public void read(String testName) throws Exception { // Perform setup. setupRead(); // Submit the request to the service and store the response. LoaninClient client = new LoaninClient(); Response res = client.read(knownResourceId); PoxPayloadIn input = null; try { assertStatusCode(res, testName); input = new PoxPayloadIn(res.readEntity(String.class)); } finally { if (res != null) { res.close(); } } // Get the common part of the response and verify that it is not null. PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName()); LoansinCommon loaninCommon = null; if (payloadInputPart != null) { loaninCommon = (LoansinCommon) payloadInputPart.getBody(); } Assert.assertNotNull(loaninCommon); // Check selected fields. LenderGroupList lenderGroupList = loaninCommon.getLenderGroupList(); Assert.assertNotNull(lenderGroupList); List<LenderGroup> lenderGroups = lenderGroupList.getLenderGroup(); Assert.assertNotNull(lenderGroups); Assert.assertTrue(lenderGroups.size() > 0); String lender = lenderGroups.get(0).getLender(); Assert.assertEquals(lender, LENDER_REF_NAME); if (logger.isDebugEnabled()) { logger.debug( "UTF-8 data sent=" + getUTF8DataFragment() + "\n" + "UTF-8 data received=" + loaninCommon.getLoanInNote()); } Assert.assertEquals( loaninCommon.getLoanInNote(), getUTF8DataFragment(), "UTF-8 data retrieved '" + loaninCommon.getLoanInNote() + "' does not match expected data '" + getUTF8DataFragment()); } // Failure outcomes /* (non-Javadoc) * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String) */ @Override // @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, // dependsOnMethods = {"read"}) public void readNonExistent(String testName) throws Exception { // Perform setup. setupReadNonExistent(); // Submit the request to the service and store the response. LoaninClient client = new LoaninClient(); Response res = client.read(NON_EXISTENT_ID); try { 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( testRequestType.isValidStatusCode(statusCode), invalidStatusCodeMessage(testRequestType, statusCode)); Assert.assertEquals(statusCode, testExpectedStatusCode); } finally { if (res != null) { res.close(); } } } // --------------------------------------------------------------- // CRUD tests : READ_LIST tests // --------------------------------------------------------------- // Success outcomes /* (non-Javadoc) * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String) */ @Override // @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, // dependsOnMethods = {"createList", "read"}) public void readList(String testName) throws Exception { // Perform setup. setupReadList(); // Submit the request to the service and store the response. AbstractCommonList list = null; LoaninClient client = new LoaninClient(); Response res = client.readList(); assertStatusCode(res, testName); try { 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( testRequestType.isValidStatusCode(statusCode), invalidStatusCodeMessage(testRequestType, statusCode)); Assert.assertEquals(statusCode, testExpectedStatusCode); list = res.readEntity(getCommonListType()); } finally { if (res != null) { res.close(); } } // Optionally output additional data about list members for debugging. boolean iterateThroughList = true; if (iterateThroughList && logger.isDebugEnabled()) { AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName); } } // Failure outcomes // None at present. // --------------------------------------------------------------- // CRUD tests : UPDATE tests // --------------------------------------------------------------- // Success outcomes /* (non-Javadoc) * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String) */ @Override // @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, // dependsOnMethods = {"read"}) public void update(String testName) throws Exception { // Perform setup. setupRead(); // Retrieve the contents of a resource to update. LoaninClient client = new LoaninClient(); Response res = client.read(knownResourceId); PoxPayloadIn input = null; try { assertStatusCode(res, testName); input = new PoxPayloadIn(res.readEntity(String.class)); if (logger.isDebugEnabled()) { logger.debug("got object to update with ID: " + knownResourceId); } } finally { if (res != null) { res.close(); } } // Extract the common part from the response. PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName()); LoansinCommon loaninCommon = null; if (payloadInputPart != null) { loaninCommon = (LoansinCommon) payloadInputPart.getBody(); } Assert.assertNotNull(loaninCommon); // Update the content of this resource. loaninCommon.setLoanInNumber("updated-" + loaninCommon.getLoanInNumber()); loaninCommon.setLoanInNote("updated-" + loaninCommon.getLoanInNote()); if (logger.isDebugEnabled()) { logger.debug("to be updated object"); logger.debug(objectAsXmlString(loaninCommon, LoansinCommon.class)); } setupUpdate(); // Submit the updated common part in an update request to the service // and store the response. PoxPayloadOut output = new PoxPayloadOut(this.getServicePathComponent()); PayloadOutputPart commonPart = output.addPart(client.getCommonPartName(), loaninCommon); res = client.update(knownResourceId, output); try { assertStatusCode(res, testName); 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( testRequestType.isValidStatusCode(statusCode), invalidStatusCodeMessage(testRequestType, statusCode)); Assert.assertEquals(statusCode, testExpectedStatusCode); input = new PoxPayloadIn(res.readEntity(String.class)); } finally { if (res != null) { res.close(); } } // Extract the updated common part from the response. payloadInputPart = input.getPart(client.getCommonPartName()); LoansinCommon updatedLoaninCommon = null; if (payloadInputPart != null) { updatedLoaninCommon = (LoansinCommon) payloadInputPart.getBody(); } Assert.assertNotNull(updatedLoaninCommon); // Check selected fields in the updated common part. Assert.assertEquals( updatedLoaninCommon.getLoanInNumber(), loaninCommon.getLoanInNumber(), "Data in updated object did not match submitted data."); if (logger.isDebugEnabled()) { logger.debug( "UTF-8 data sent=" + loaninCommon.getLoanInNote() + "\n" + "UTF-8 data received=" + updatedLoaninCommon.getLoanInNote()); } Assert.assertTrue( updatedLoaninCommon.getLoanInNote().contains(getUTF8DataFragment()), "UTF-8 data retrieved '" + updatedLoaninCommon.getLoanInNote() + "' does not contain expected data '" + getUTF8DataFragment()); Assert.assertEquals( updatedLoaninCommon.getLoanInNote(), loaninCommon.getLoanInNote(), "Data in updated object did not match submitted data."); } @Override // @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, // dependsOnMethods = {"update", "testSubmitRequest"}) public void updateNonExistent(String testName) throws Exception { // Perform setup. setupUpdateNonExistent(); // Submit the request to the service and store the response. // Note: The ID used in this 'create' call may be arbitrary. // The only relevant ID may be the one used in update(), below. LoaninClient client = new LoaninClient(); PoxPayloadOut multipart = createLoaninInstance(NON_EXISTENT_ID); Response res = client.update(NON_EXISTENT_ID, multipart); try { 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( testRequestType.isValidStatusCode(statusCode), invalidStatusCodeMessage(testRequestType, statusCode)); Assert.assertEquals(statusCode, testExpectedStatusCode); } finally { if (res != null) { res.close(); } } } // --------------------------------------------------------------- // CRUD tests : DELETE tests // --------------------------------------------------------------- // Success outcomes /* (non-Javadoc) * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String) */ @Override // @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, // dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"}) public void delete(String testName) throws Exception { // Perform setup. setupDelete(); // Submit the request to the service and store the response. LoaninClient client = new LoaninClient(); Response res = client.delete(knownResourceId); try { 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( testRequestType.isValidStatusCode(statusCode), invalidStatusCodeMessage(testRequestType, statusCode)); Assert.assertEquals(statusCode, testExpectedStatusCode); } finally { if (res != null) { res.close(); } } } // Failure outcomes /* (non-Javadoc) * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String) */ @Override // @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, // dependsOnMethods = {"delete"}) public void deleteNonExistent(String testName) throws Exception { // Perform setup. setupDeleteNonExistent(); // Submit the request to the service and store the response. LoaninClient client = new LoaninClient(); Response res = client.delete(NON_EXISTENT_ID); try { 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( testRequestType.isValidStatusCode(statusCode), invalidStatusCodeMessage(testRequestType, statusCode)); Assert.assertEquals(statusCode, testExpectedStatusCode); } finally { if (res != null) { res.close(); } } } // --------------------------------------------------------------- // Utility tests : tests of code used in tests above // --------------------------------------------------------------- /** Tests the code for manually submitting data that is used by several of the methods above. */ // @Test(dependsOnMethods = {"create", "read"}) public void testSubmitRequest() { // Expected status code: 200 OK final int EXPECTED_STATUS = Response.Status.OK.getStatusCode(); // Submit the request to the service and store the response. String method = ServiceRequestType.READ.httpMethodName(); String url = getResourceURL(knownResourceId); int statusCode = submitRequest(method, url); // Check the status code of the response: does it match // the expected response(s)? if (logger.isDebugEnabled()) { logger.debug("testSubmitRequest: url=" + url + " status=" + statusCode); } Assert.assertEquals(statusCode, EXPECTED_STATUS); } // --------------------------------------------------------------- // Utility methods used by tests above // --------------------------------------------------------------- @Override public String getServiceName() { return SERVICE_NAME; } /* (non-Javadoc) * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent() */ @Override public String getServicePathComponent() { return SERVICE_PATH_COMPONENT; } @Override protected PoxPayloadOut createInstance(String identifier) throws Exception { return createLoaninInstance(identifier); } /** * Creates the loanin instance. * * @param identifier the identifier * @return the multipart output * @throws Exception */ private PoxPayloadOut createLoaninInstance(String identifier) throws Exception { return createLoaninInstance("loaninNumber-" + identifier, "returnDate-" + identifier); } /** * Creates the loanin instance. * * @param loaninNumber the loanin number * @param returnDate the return date * @return the multipart output * @throws Exception */ private PoxPayloadOut createLoaninInstance(String loaninNumber, String returnDate) throws Exception { LoansinCommon loaninCommon = new LoansinCommon(); loaninCommon.setLoanInNumber(loaninNumber); loaninCommon.setLoanReturnDate(CURRENT_DATE_UTC); LenderGroupList lenderGroupList = new LenderGroupList(); LenderGroup lenderGroup = new LenderGroup(); lenderGroup.setLender(LENDER_REF_NAME); lenderGroupList.getLenderGroup().add(lenderGroup); loaninCommon.setLenderGroupList(lenderGroupList); loaninCommon.setLoanPurpose("For Surfboards of the 1960s exhibition."); loaninCommon.setLoanInNote(getUTF8DataFragment()); PoxPayloadOut multipart = new PoxPayloadOut(this.getServicePathComponent()); PayloadOutputPart commonPart = multipart.addPart(new LoaninClient().getCommonPartName(), loaninCommon); if (logger.isDebugEnabled()) { logger.debug("to be created, loanin common"); logger.debug(objectAsXmlString(loaninCommon, LoansinCommon.class)); } return multipart; } @Override public void CRUDTests(String testName) { // TODO Auto-generated method stub } @Override protected PoxPayloadOut createInstance(String commonPartName, String identifier) throws Exception { PoxPayloadOut result = createLoaninInstance(identifier); return result; } @Override protected LoansinCommon updateInstance(LoansinCommon commonPartObject) { // TODO Auto-generated method stub return null; } @Override protected void compareUpdatedInstances(LoansinCommon original, LoansinCommon updated) throws Exception { // TODO Auto-generated method stub } }
/** * MovementServiceTest, carries out tests against a deployed and running Movement Service. * * <p>$LastChangedRevision$ $LastChangedDate: 2011-11-14 23:26:36 -0800 (Mon, 14 Nov 2011) $ */ public class MovementServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonList, MovementsCommon> { /** The logger. */ private final String CLASS_NAME = MovementServiceTest.class.getName(); private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); final String SERVICE_NAME = "movements"; final String SERVICE_PATH_COMPONENT = "movements"; private static final String TIMESTAMP_UTC = GregorianCalendarDateTimeUtils.timestampUTC(); /* * (non-Javadoc) * * @see * org.collectionspace.services.client.test.BaseServiceTest#getClientInstance * () */ @Override protected CollectionSpaceClient getClientInstance() { return new MovementClient(); } // --------------------------------------------------------------- // Utility methods used by tests above // --------------------------------------------------------------- @Override protected String getServiceName() { return SERVICE_NAME; } /* * (non-Javadoc) * * @see org.collectionspace.services.client.test.BaseServiceTest# * getServicePathComponent() */ @Override public String getServicePathComponent() { return SERVICE_PATH_COMPONENT; } /** * Creates the movement instance. * * @param identifier the identifier * @return the multipart output */ private PoxPayloadOut createMovementInstance(String identifier) { return createInstance("movementReferenceNumber-" + identifier); } @Override protected PoxPayloadOut createInstance(String commonPartName, String identifier) { PoxPayloadOut result = createMovementInstance(identifier); return result; } /** * Creates an instance of a Movement record for testing. * * @param movementReferenceNumber A movement reference number. * @return Multipart output suitable for use as a payload in a create or update request. */ @Override protected PoxPayloadOut createInstance(String movementReferenceNumber) { MovementsCommon movementCommon = new MovementsCommon(); // FIXME: Values of currentLocation, normalLocation, // and movementContact should be refNames. movementCommon.setCurrentLocation("currentLocation value"); movementCommon.setCurrentLocationFitness("currentLocationFitness value"); movementCommon.setCurrentLocationNote("currentLocationNote value"); movementCommon.setLocationDate(TIMESTAMP_UTC); movementCommon.setNormalLocation("normalLocation value"); movementCommon.setMovementContact("movementContact value"); MovementMethodsList movementMethodsList = new MovementMethodsList(); List<String> methods = movementMethodsList.getMovementMethod(); // @TODO Use properly formatted refNames for representative movement // methods in this example record. The values below are placeholders. String identifier = createIdentifier(); methods.add("First Movement Method-" + identifier); methods.add("Second Movement Method-" + identifier); movementCommon.setMovementMethods(movementMethodsList); movementCommon.setMovementNote(getUTF8DataFragment()); movementCommon.setMovementReferenceNumber(movementReferenceNumber); movementCommon.setPlannedRemovalDate(TIMESTAMP_UTC); movementCommon.setRemovalDate(""); // Test empty date value movementCommon.setReasonForMove("reasonForMove value"); PoxPayloadOut multipart = new PoxPayloadOut(this.getServicePathComponent()); PayloadOutputPart commonPart = multipart.addPart(new MovementClient().getCommonPartName(), movementCommon); if (logger.isDebugEnabled()) { logger.debug("to be created, movement common"); logger.debug(objectAsXmlString(movementCommon, MovementsCommon.class)); } return multipart; } @Override protected MovementsCommon updateInstance(MovementsCommon movementsCommon) { MovementsCommon result = new MovementsCommon(); result.setMovementReferenceNumber("updated-" + movementsCommon.getMovementReferenceNumber()); result.setMovementNote("updated movement note-" + movementsCommon.getMovementNote()); result.setNormalLocation(""); // Test deletion of existing // string value String currentTimestamp = GregorianCalendarDateTimeUtils.timestampUTC(); result.setPlannedRemovalDate(""); // Test deletion of existing // date or date/time value result.setRemovalDate(currentTimestamp); return result; } @Override protected void compareUpdatedInstances(MovementsCommon original, MovementsCommon updated) throws Exception { // By submitting an empty string in the update payload, the value of // this field // in the object created from the response payload will be null. Assert.assertNull( updated.getNormalLocation(), "Normal location in updated object did not match submitted data."); if (logger.isDebugEnabled()) { logger.debug("Normal location after update=|" + updated.getNormalLocation() + "|"); } Assert.assertEquals( updated.getMovementReferenceNumber(), original.getMovementReferenceNumber(), "Movement reference number in updated object did not match submitted data."); Assert.assertEquals( updated.getMovementNote(), original.getMovementNote(), "Movement note in updated object did not match submitted data."); Assert.assertNull(updated.getPlannedRemovalDate()); Assert.assertEquals( updated.getRemovalDate(), original.getRemovalDate(), "Removal date in updated object did not match submitted data."); if (logger.isDebugEnabled()) { logger.debug( "UTF-8 data sent=" + original.getMovementNote() + "\n" + "UTF-8 data received=" + updated.getMovementNote()); } Assert.assertTrue( updated.getMovementNote().contains(getUTF8DataFragment()), "UTF-8 data retrieved '" + updated.getMovementNote() + "' does not contain expected data '" + getUTF8DataFragment()); Assert.assertEquals( updated.getMovementNote(), original.getMovementNote(), "Movement note in updated object did not match submitted data."); } protected void compareReadInstances(MovementsCommon original, MovementsCommon fromRead) throws Exception { // Check the values of one or more date/time fields. if (logger.isDebugEnabled()) { logger.debug("locationDate=" + fromRead.getLocationDate()); logger.debug("TIMESTAMP_UTC=" + TIMESTAMP_UTC); } Assert.assertTrue(fromRead.getLocationDate().equals(TIMESTAMP_UTC)); Assert.assertTrue(fromRead.getPlannedRemovalDate().equals(TIMESTAMP_UTC)); Assert.assertNull(fromRead.getRemovalDate()); // Check the values of fields containing Unicode UTF-8 (non-Latin-1) // characters. if (logger.isDebugEnabled()) { logger.debug( "UTF-8 data sent=" + getUTF8DataFragment() + "\n" + "UTF-8 data received=" + fromRead.getMovementNote()); } Assert.assertEquals( fromRead.getMovementNote(), getUTF8DataFragment(), "UTF-8 data retrieved '" + fromRead.getMovementNote() + "' does not match expected data '" + getUTF8DataFragment()); } /* * For convenience and terseness, this test method is the base of the test * execution dependency chain. Other test methods may refer to this method * in their @Test annotation declarations. */ @Override @Test( dataProvider = "testName", dependsOnMethods = { "org.collectionspace.services.client.test.AbstractServiceTestImpl.baseCRUDTests" }) public void CRUDTests(String testName) { // TODO Auto-generated method stub } }