2 * This document is a part of the source code and related artifacts
3 * for CollectionSpace, an open source collections management system
4 * for museums and related institutions:
6 * http://www.collectionspace.org
7 * http://wiki.collectionspace.org
9 * Copyright © 2009 Regents of the University of California
11 * Licensed under the Educational Community License (ECL), Version 2.0.
12 * You may not use this file except in compliance with this License.
14 * You may obtain a copy of the ECL 2.0 License at
15 * https://source.collectionspace.org/collection-space/LICENSE.txt
17 * Unless required by applicable law or agreed to in writing, software
18 * distributed under the License is distributed on an "AS IS" BASIS,
19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 * See the License for the specific language governing permissions and
21 * limitations under the License.
23 package org.collectionspace.services.client.test;
25 import java.util.List;
26 import javax.ws.rs.core.MediaType;
27 import javax.ws.rs.core.Response;
29 import org.collectionspace.services.client.CollectionSpaceClient;
30 import org.collectionspace.services.client.MovementClient;
31 import org.collectionspace.services.jaxb.AbstractCommonList;
32 import org.collectionspace.services.movement.MovementsCommon;
33 import org.collectionspace.services.movement.MovementsCommonList;
34 import org.collectionspace.services.movement.MovementMethodsList;
36 import org.jboss.resteasy.client.ClientResponse;
38 import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
39 import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
40 import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
41 import org.testng.Assert;
42 import org.testng.annotations.Test;
44 import org.slf4j.Logger;
45 import org.slf4j.LoggerFactory;
48 * MovementServiceTest, carries out tests against a
49 * deployed and running Movement Service.
51 * $LastChangedRevision$
54 public class MovementServiceTest extends AbstractServiceTestImpl {
57 private final String CLASS_NAME = MovementServiceTest.class.getName();
58 private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
60 // Instance variables specific to this test.
61 /** The service path component. */
62 final String SERVICE_PATH_COMPONENT = "movements";
64 /** The known resource id. */
65 private String knownResourceId = null;
68 * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
71 protected CollectionSpaceClient getClientInstance() {
72 return new MovementClient();
76 * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
79 protected AbstractCommonList getAbstractCommonList(
80 ClientResponse<AbstractCommonList> response) {
81 return response.getEntity(MovementsCommonList.class);
84 // ---------------------------------------------------------------
85 // CRUD tests : CREATE tests
86 // ---------------------------------------------------------------
89 * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
92 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class)
93 public void create(String testName) throws Exception {
95 if (logger.isDebugEnabled()) {
96 logger.debug(testBanner(testName, CLASS_NAME));
98 // Perform setup, such as initializing the type of service request
99 // (e.g. CREATE, DELETE), its valid and expected status codes, and
100 // its associated HTTP method name (e.g. POST, DELETE).
103 // Submit the request to the service and store the response.
104 MovementClient client = new MovementClient();
105 String identifier = createIdentifier();
106 MultipartOutput multipart = createMovementInstance(identifier);
107 ClientResponse<Response> res = client.create(multipart);
109 int statusCode = res.getStatus();
111 // Check the status code of the response: does it match
112 // the expected response(s)?
115 // Does it fall within the set of valid status codes?
116 // Does it exactly match the expected status code?
117 if(logger.isDebugEnabled()){
118 logger.debug(testName + ": status = " + statusCode);
120 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
121 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
122 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
124 // Store the ID returned from the first resource created
125 // for additional tests below.
126 if (knownResourceId == null){
127 knownResourceId = extractId(res);
128 if (logger.isDebugEnabled()) {
129 logger.debug(testName + ": knownResourceId=" + knownResourceId);
133 // Store the IDs from every resource created by tests,
134 // so they can be deleted after tests have been run.
135 allResourceIdsCreated.add(extractId(res));
139 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
142 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
143 dependsOnMethods = {"create"})
144 public void createList(String testName) throws Exception {
145 for(int i = 0; i < 3; i++){
151 // Placeholders until the three tests below can be uncommented.
152 // See Issue CSPACE-401.
154 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
157 public void createWithEmptyEntityBody(String testName) throws Exception {
158 //Should this really be empty?
162 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
165 public void createWithMalformedXml(String testName) throws Exception {
166 //Should this really be empty?
170 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
173 public void createWithWrongXmlSchema(String testName) throws Exception {
174 //Should this really be empty?
179 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
180 dependsOnMethods = {"create", "testSubmitRequest"})
181 public void createWithEmptyEntityBody(String testName) throws Exception {
183 if (logger.isDebugEnabled()) {
184 logger.debug(testBanner(testName, CLASS_NAME));
187 setupCreateWithEmptyEntityBody();
189 // Submit the request to the service and store the response.
190 String method = REQUEST_TYPE.httpMethodName();
191 String url = getServiceRootURL();
192 String mediaType = MediaType.APPLICATION_XML;
193 final String entity = "";
194 int statusCode = submitRequest(method, url, mediaType, entity);
196 // Check the status code of the response: does it match
197 // the expected response(s)?
198 if(logger.isDebugEnabled()){
199 logger.debug("createWithEmptyEntityBody url=" + url +
200 " status=" + statusCode);
202 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
203 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
204 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
208 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
209 dependsOnMethods = {"create", "testSubmitRequest"})
210 public void createWithMalformedXml(String testName) throws Exception {
212 if (logger.isDebugEnabled()) {
213 logger.debug(testBanner(testName, CLASS_NAME));
216 setupCreateWithMalformedXml();
218 // Submit the request to the service and store the response.
219 String method = REQUEST_TYPE.httpMethodName();
220 String url = getServiceRootURL();
221 String mediaType = MediaType.APPLICATION_XML;
222 final String entity = MALFORMED_XML_DATA; // Constant from base class.
223 int statusCode = submitRequest(method, url, mediaType, entity);
225 // Check the status code of the response: does it match
226 // the expected response(s)?
227 if(logger.isDebugEnabled()){
228 logger.debug(testName + ": url=" + url +
229 " status=" + statusCode);
231 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
232 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
233 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
237 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
238 dependsOnMethods = {"create", "testSubmitRequest"})
239 public void createWithWrongXmlSchema(String testName) throws Exception {
241 if (logger.isDebugEnabled()) {
242 logger.debug(testBanner(testName, CLASS_NAME));
245 setupCreateWithWrongXmlSchema();
247 // Submit the request to the service and store the response.
248 String method = REQUEST_TYPE.httpMethodName();
249 String url = getServiceRootURL();
250 String mediaType = MediaType.APPLICATION_XML;
251 final String entity = WRONG_XML_SCHEMA_DATA;
252 int statusCode = submitRequest(method, url, mediaType, entity);
254 // Check the status code of the response: does it match
255 // the expected response(s)?
256 if(logger.isDebugEnabled()){
257 logger.debug(testName + ": url=" + url +
258 " status=" + statusCode);
260 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
261 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
262 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
266 // ---------------------------------------------------------------
267 // CRUD tests : READ tests
268 // ---------------------------------------------------------------
271 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
274 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
275 dependsOnMethods = {"create"})
276 public void read(String testName) throws Exception {
278 if (logger.isDebugEnabled()) {
279 logger.debug(testBanner(testName, CLASS_NAME));
284 // Submit the request to the service and store the response.
285 MovementClient client = new MovementClient();
286 ClientResponse<MultipartInput> res = client.read(knownResourceId);
287 int statusCode = res.getStatus();
289 // Check the status code of the response: does it match
290 // the expected response(s)?
291 if(logger.isDebugEnabled()){
292 logger.debug(testName + ": status = " + statusCode);
294 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
295 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
296 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
298 MultipartInput input = (MultipartInput) res.getEntity();
299 MovementsCommon movement = (MovementsCommon) extractPart(input,
300 client.getCommonPartName(), MovementsCommon.class);
301 Assert.assertNotNull(movement);
306 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
309 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
310 dependsOnMethods = {"read"})
311 public void readNonExistent(String testName) throws Exception {
313 if (logger.isDebugEnabled()) {
314 logger.debug(testBanner(testName, CLASS_NAME));
317 setupReadNonExistent();
319 // Submit the request to the service and store the response.
320 MovementClient client = new MovementClient();
321 ClientResponse<MultipartInput> res = client.read(NON_EXISTENT_ID);
322 int statusCode = res.getStatus();
324 // Check the status code of the response: does it match
325 // the expected response(s)?
326 if(logger.isDebugEnabled()){
327 logger.debug(testName + ": status = " + statusCode);
329 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
330 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
331 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
334 // ---------------------------------------------------------------
335 // CRUD tests : READ_LIST tests
336 // ---------------------------------------------------------------
339 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
342 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
343 dependsOnMethods = {"createList", "read"})
344 public void readList(String testName) throws Exception {
346 if (logger.isDebugEnabled()) {
347 logger.debug(testBanner(testName, CLASS_NAME));
352 // Submit the request to the service and store the response.
353 MovementClient client = new MovementClient();
354 ClientResponse<MovementsCommonList> res = client.readList();
355 MovementsCommonList list = res.getEntity();
356 int statusCode = res.getStatus();
358 // Check the status code of the response: does it match
359 // the expected response(s)?
360 if(logger.isDebugEnabled()){
361 logger.debug(testName + ": status = " + statusCode);
363 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
364 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
365 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
367 // Optionally output additional data about list members for debugging.
368 boolean iterateThroughList = false;
369 if(iterateThroughList && logger.isDebugEnabled()){
370 List<MovementsCommonList.MovementListItem> items =
371 list.getMovementListItem();
373 for(MovementsCommonList.MovementListItem item : items){
374 logger.debug(testName + ": list-item[" + i + "] csid=" +
376 logger.debug(testName + ": list-item[" + i + "] movementReferenceNumber=" +
377 item.getMovementReferenceNumber());
378 logger.debug(testName + ": list-item[" + i + "] URI=" +
388 // ---------------------------------------------------------------
389 // CRUD tests : UPDATE tests
390 // ---------------------------------------------------------------
393 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
396 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
397 dependsOnMethods = {"read"})
398 public void update(String testName) throws Exception {
400 if (logger.isDebugEnabled()) {
401 logger.debug(testBanner(testName, CLASS_NAME));
406 // Retrieve the contents of a resource to update.
407 MovementClient client = new MovementClient();
408 ClientResponse<MultipartInput> res =
409 client.read(knownResourceId);
410 if(logger.isDebugEnabled()){
411 logger.debug(testName + ": read status = " + res.getStatus());
413 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
415 if(logger.isDebugEnabled()){
416 logger.debug("got object to update with ID: " + knownResourceId);
418 MultipartInput input = (MultipartInput) res.getEntity();
419 MovementsCommon movement = (MovementsCommon) extractPart(input,
420 client.getCommonPartName(), MovementsCommon.class);
421 Assert.assertNotNull(movement);
423 // Update the content of this resource.
424 movement.setMovementReferenceNumber("updated-" + movement.getMovementReferenceNumber());
425 movement.setLocationDate("updated-" + movement.getLocationDate());
426 if(logger.isDebugEnabled()){
427 logger.debug("to be updated object");
428 logger.debug(objectAsXmlString(movement, MovementsCommon.class));
430 // Submit the request to the service and store the response.
431 MultipartOutput output = new MultipartOutput();
432 OutputPart commonPart = output.addPart(movement, MediaType.APPLICATION_XML_TYPE);
433 commonPart.getHeaders().add("label", client.getCommonPartName());
435 res = client.update(knownResourceId, output);
436 int statusCode = res.getStatus();
437 // Check the status code of the response: does it match the expected response(s)?
438 if(logger.isDebugEnabled()){
439 logger.debug(testName + ": status = " + statusCode);
441 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
442 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
443 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
446 input = (MultipartInput) res.getEntity();
447 MovementsCommon updatedMovement =
448 (MovementsCommon) extractPart(input,
449 client.getCommonPartName(), MovementsCommon.class);
450 Assert.assertNotNull(updatedMovement);
452 Assert.assertEquals(updatedMovement.getLocationDate(),
453 movement.getLocationDate(),
454 "Data in updated object did not match submitted data.");
459 // Placeholders until the three tests below can be uncommented.
460 // See Issue CSPACE-401.
462 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
465 public void updateWithEmptyEntityBody(String testName) throws Exception{
466 //Should this really be empty?
470 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
473 public void updateWithMalformedXml(String testName) throws Exception {
474 //Should this really be empty?
478 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
481 public void updateWithWrongXmlSchema(String testName) throws Exception {
482 //Should this really be empty?
487 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
488 dependsOnMethods = {"create", "update", "testSubmitRequest"})
489 public void updateWithEmptyEntityBody(String testName) throws Exception {
491 if (logger.isDebugEnabled()) {
492 logger.debug(testBanner(testName, CLASS_NAME));
495 setupUpdateWithEmptyEntityBody();
497 // Submit the request to the service and store the response.
498 String method = REQUEST_TYPE.httpMethodName();
499 String url = getResourceURL(knownResourceId);
500 String mediaType = MediaType.APPLICATION_XML;
501 final String entity = "";
502 int statusCode = submitRequest(method, url, mediaType, entity);
504 // Check the status code of the response: does it match
505 // the expected response(s)?
506 if(logger.isDebugEnabled()){
507 logger.debug(testName + ": url=" + url +
508 " status=" + statusCode);
510 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
511 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
512 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
516 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
517 dependsOnMethods = {"create", "update", "testSubmitRequest"})
518 public void updateWithMalformedXml(String testName) throws Exception {
520 if (logger.isDebugEnabled()) {
521 logger.debug(testBanner(testName, CLASS_NAME));
524 setupUpdateWithMalformedXml();
526 // Submit the request to the service and store the response.
527 String method = REQUEST_TYPE.httpMethodName();
528 String url = getResourceURL(knownResourceId);
529 String mediaType = MediaType.APPLICATION_XML;
530 final String entity = MALFORMED_XML_DATA;
531 int statusCode = submitRequest(method, url, mediaType, entity);
533 // Check the status code of the response: does it match
534 // the expected response(s)?
535 if(logger.isDebugEnabled()){
536 logger.debug(testName + ": url=" + url +
537 " status=" + statusCode);
539 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
540 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
541 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
545 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
546 dependsOnMethods = {"create", "update", "testSubmitRequest"})
547 public void updateWithWrongXmlSchema(String testName) throws Exception {
549 if (logger.isDebugEnabled()) {
550 logger.debug(testBanner(testName, CLASS_NAME));
553 setupUpdateWithWrongXmlSchema();
555 // Submit the request to the service and store the response.
556 String method = REQUEST_TYPE.httpMethodName();
557 String url = getResourceURL(knownResourceId);
558 String mediaType = MediaType.APPLICATION_XML;
559 final String entity = WRONG_XML_SCHEMA_DATA;
560 int statusCode = submitRequest(method, url, mediaType, entity);
562 // Check the status code of the response: does it match
563 // the expected response(s)?
564 if(logger.isDebugEnabled()){
565 logger.debug(testName + ": url=" + url +
566 " status=" + statusCode);
568 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
569 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
570 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
575 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
578 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
579 dependsOnMethods = {"update", "testSubmitRequest"})
580 public void updateNonExistent(String testName) throws Exception {
582 if (logger.isDebugEnabled()) {
583 logger.debug(testBanner(testName, CLASS_NAME));
586 setupUpdateNonExistent();
588 // Submit the request to the service and store the response.
589 // Note: The ID used in this 'create' call may be arbitrary.
590 // The only relevant ID may be the one used in update(), below.
591 MovementClient client = new MovementClient();
592 MultipartOutput multipart = createMovementInstance(NON_EXISTENT_ID);
593 ClientResponse<MultipartInput> res =
594 client.update(NON_EXISTENT_ID, multipart);
595 int statusCode = res.getStatus();
597 // Check the status code of the response: does it match
598 // the expected response(s)?
599 if(logger.isDebugEnabled()){
600 logger.debug(testName + ": status = " + statusCode);
602 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
603 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
604 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
607 // ---------------------------------------------------------------
608 // CRUD tests : DELETE tests
609 // ---------------------------------------------------------------
612 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
615 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
616 dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"})
617 public void delete(String testName) throws Exception {
619 if (logger.isDebugEnabled()) {
620 logger.debug(testBanner(testName, CLASS_NAME));
625 // Submit the request to the service and store the response.
626 MovementClient client = new MovementClient();
627 ClientResponse<Response> res = client.delete(knownResourceId);
628 int statusCode = res.getStatus();
630 // Check the status code of the response: does it match
631 // the expected response(s)?
632 if(logger.isDebugEnabled()){
633 logger.debug(testName + ": status = " + statusCode);
635 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
636 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
637 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
642 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
645 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
646 dependsOnMethods = {"delete"})
647 public void deleteNonExistent(String testName) throws Exception {
649 if (logger.isDebugEnabled()) {
650 logger.debug(testBanner(testName, CLASS_NAME));
653 setupDeleteNonExistent();
655 // Submit the request to the service and store the response.
656 MovementClient client = new MovementClient();
657 ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
658 int statusCode = res.getStatus();
660 // Check the status code of the response: does it match
661 // the expected response(s)?
662 if(logger.isDebugEnabled()){
663 logger.debug(testName + ": status = " + statusCode);
665 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
666 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
667 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
670 // ---------------------------------------------------------------
671 // Utility tests : tests of code used in tests above
672 // ---------------------------------------------------------------
674 * Tests the code for manually submitting data that is used by several
675 * of the methods above.
677 @Test(dependsOnMethods = {"create", "read"})
678 public void testSubmitRequest() {
680 // Expected status code: 200 OK
681 final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
683 // Submit the request to the service and store the response.
684 String method = ServiceRequestType.READ.httpMethodName();
685 String url = getResourceURL(knownResourceId);
686 int statusCode = submitRequest(method, url);
688 // Check the status code of the response: does it match
689 // the expected response(s)?
690 if(logger.isDebugEnabled()){
691 logger.debug("testSubmitRequest: url=" + url +
692 " status=" + statusCode);
694 Assert.assertEquals(statusCode, EXPECTED_STATUS);
698 // ---------------------------------------------------------------
699 // Utility methods used by tests above
700 // ---------------------------------------------------------------
702 * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
705 public String getServicePathComponent() {
706 return SERVICE_PATH_COMPONENT;
710 * Creates the movement instance.
712 * @param identifier the identifier
713 * @return the multipart output
715 private MultipartOutput createMovementInstance(String identifier) {
716 return createMovementInstance(
717 "movementReferenceNumber-" + identifier,
718 "locationDate-" + identifier);
722 * Creates an instance of a Movement record for testing.
724 * @param movementReferenceNumber A movement reference number.
725 * @param locationDate A location date.
726 * @return Multipart output suitable for use as a payload
727 * in a create or update request.
729 private MultipartOutput createMovementInstance(String movementReferenceNumber,
730 String locationDate) {
731 MovementsCommon movement = new MovementsCommon();
732 // FIXME: Values of currentLocation, normalLocation,
733 // and movementContact should be refNames.
734 movement.setCurrentLocation("currentLocation value");
735 movement.setCurrentLocationFitness("currentLocationFitness value");
736 movement.setCurrentLocationNote("currentLocationNote value");
737 movement.setLocationDate(locationDate);
738 movement.setNormalLocation("normalLocation value");
739 movement.setMovementContact("movementContact value");
740 MovementMethodsList movementMethodsList = new MovementMethodsList();
741 List<String> methods = movementMethodsList.getMovementMethod();
742 // @TODO Use properly formatted refNames for representative movement
743 // methods in this example record. The values below are placeholders.
744 String identifier = createIdentifier();
745 methods.add("First Movement Method-" + identifier);
746 methods.add("Second Movement Method-" + identifier);
747 movement.setMovementMethods(movementMethodsList);
748 movement.setMovementNote("movementNote value");
749 movement.setMovementReferenceNumber(movementReferenceNumber);
750 movement.setPlannedRemovalDate("plannedRemovalDate value");
751 movement.setRemovalDate("removalDate value");
752 movement.setReasonForMove("reasonForMove value");
753 MultipartOutput multipart = new MultipartOutput();
754 OutputPart commonPart =
755 multipart.addPart(movement, MediaType.APPLICATION_XML_TYPE);
756 commonPart.getHeaders().add("label", new MovementClient().getCommonPartName());
758 if(logger.isDebugEnabled()){
759 logger.debug("to be created, movement common");
760 logger.debug(objectAsXmlString(movement, MovementsCommon.class));