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 (c) 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.AcquisitionClient;
30 import org.collectionspace.services.client.CollectionSpaceClient;
31 import org.collectionspace.services.jaxb.AbstractCommonList;
33 import org.collectionspace.services.acquisition.AcquisitionsCommon;
34 import org.collectionspace.services.acquisition.AcquisitionsCommonList;
35 import org.collectionspace.services.acquisition.AcquisitionSourceList;
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 * AcquisitionServiceTest, carries out tests against a
49 * deployed and running Acquisition Service.
51 * $LastChangedRevision: 621 $
52 * $LastChangedDate: 2009-09-02 16:49:01 -0700 (Wed, 02 Sep 2009) $
54 public class AcquisitionServiceTest extends AbstractServiceTestImpl {
57 private final String CLASS_NAME = AcquisitionServiceTest.class.getName();
58 private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
60 // Instance variables specific to this test.
61 /** The known resource id. */
62 private String knownResourceId = null;
65 * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
68 protected CollectionSpaceClient getClientInstance() {
69 return new AcquisitionClient();
73 * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
76 protected AbstractCommonList getAbstractCommonList(
77 ClientResponse<AbstractCommonList> response) {
78 return response.getEntity(AcquisitionsCommonList.class);
81 // ---------------------------------------------------------------
82 // CRUD tests : CREATE tests
83 // ---------------------------------------------------------------
86 * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
89 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class)
90 public void create(String testName) throws Exception {
92 if (logger.isDebugEnabled()) {
93 logger.debug(testBanner(testName, CLASS_NAME));
96 // Perform setup, such as initializing the type of service request
97 // (e.g. CREATE, DELETE), its valid and expected status codes, and
98 // its associated HTTP method name (e.g. POST, DELETE).
101 // Submit the request to the service and store the response.
102 String identifier = createIdentifier();
104 AcquisitionClient client = new AcquisitionClient();
105 MultipartOutput multipart = createAcquisitionInstance(identifier);
106 ClientResponse<Response> res = client.create(multipart);
108 int statusCode = res.getStatus();
110 // Check the status code of the response: does it match
111 // the expected response(s)?
114 // Does it fall within the set of valid status codes?
115 // Does it exactly match the expected status code?
116 if(logger.isDebugEnabled()){
117 logger.debug(testName + ": status = " + statusCode);
119 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
120 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
121 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
123 // Store the ID returned from the first resource created
124 // for additional tests below.
125 if (knownResourceId == null){
126 knownResourceId = extractId(res);
127 if (logger.isDebugEnabled()) {
128 logger.debug(testName + ": knownResourceId=" + knownResourceId);
132 // Store the IDs from every resource created by tests,
133 // so they can be deleted after tests have been run.
134 allResourceIdsCreated.add(extractId(res));
138 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
141 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
142 dependsOnMethods = {"create"})
143 public void createList(String testName) throws Exception {
144 for(int i = 0; i < 3; i++){
150 // Placeholders until the three tests below can be uncommented.
151 // See Issue CSPACE-401.
153 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
156 public void createWithEmptyEntityBody(String testName) throws Exception {
157 //Should this really be empty?
161 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
164 public void createWithMalformedXml(String testName) throws Exception {
165 //Should this really be empty?
169 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
172 public void createWithWrongXmlSchema(String testName) throws Exception {
173 //Should this really be empty?
178 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
179 dependsOnMethods = {"create", "testSubmitRequest"})
180 public void createWithMalformedXml(String testName) throws Exception {
182 if (logger.isDebugEnabled()) {
183 logger.debug(testBanner(testName, CLASS_NAME));
187 setupCreateWithMalformedXml();
189 // Submit the request to the service and store the response.
190 String method = REQUEST_TYPE.httpMethodName();
191 String url = getServiceRootURL();
192 final String entity = MALFORMED_XML_DATA; // Constant from base class.
193 int statusCode = submitRequest(method, url, entity);
195 // Check the status code of the response: does it match
196 // the expected response(s)?
197 if(logger.isDebugEnabled()){
198 logger.debug(testName + ": url=" + url +
199 " status=" + statusCode);
201 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
202 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
203 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
207 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
208 dependsOnMethods = {"create", "testSubmitRequest"})
209 public void createWithWrongXmlSchema(String testName) throws Exception {
211 if (logger.isDebugEnabled()) {
212 logger.debug(testBanner(testName, CLASS_NAME));
216 setupCreateWithWrongXmlSchema();
218 // Submit the request to the service and store the response.
219 String method = REQUEST_TYPE.httpMethodName();
220 String url = getServiceRootURL();
221 final String entity = WRONG_XML_SCHEMA_DATA;
222 int statusCode = submitRequest(method, url, entity);
224 // Check the status code of the response: does it match
225 // the expected response(s)?
226 if(logger.isDebugEnabled()){
227 logger.debug(testName + ": url=" + url +
228 " status=" + statusCode);
230 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
231 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
232 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
236 // ---------------------------------------------------------------
237 // CRUD tests : READ tests
238 // ---------------------------------------------------------------
241 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
244 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
245 dependsOnMethods = {"create"})
246 public void read(String testName) throws Exception {
248 if (logger.isDebugEnabled()) {
249 logger.debug(testBanner(testName, CLASS_NAME));
255 AcquisitionClient client = new AcquisitionClient();
257 // Submit the request to the service and store the response.
258 ClientResponse<MultipartInput> res = client.read(knownResourceId);
259 int statusCode = res.getStatus();
261 // Check the status code of the response: does it match
262 // the expected response(s)?
263 if(logger.isDebugEnabled()){
264 logger.debug(testName + ": status = " + statusCode);
266 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
267 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
268 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
270 MultipartInput input = (MultipartInput) res.getEntity();
271 AcquisitionsCommon acquisitionObject = (AcquisitionsCommon) extractPart(input,
272 client.getCommonPartName(), AcquisitionsCommon.class);
273 Assert.assertNotNull(acquisitionObject);
279 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
282 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
283 dependsOnMethods = {"read"})
284 public void readNonExistent(String testName) throws Exception {
286 if (logger.isDebugEnabled()) {
287 logger.debug(testBanner(testName, CLASS_NAME));
291 setupReadNonExistent();
293 // Submit the request to the service and store the response.
294 AcquisitionClient client = new AcquisitionClient();
295 ClientResponse<MultipartInput> res = client.read(NON_EXISTENT_ID);
296 int statusCode = res.getStatus();
298 // Check the status code of the response: does it match
299 // the expected response(s)?
300 if(logger.isDebugEnabled()){
301 logger.debug(testName + ": status = " + statusCode);
303 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
304 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
305 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
308 // ---------------------------------------------------------------
309 // CRUD tests : READ_LIST tests
310 // ---------------------------------------------------------------
313 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
316 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
317 dependsOnMethods = {"createList", "read"})
318 public void readList(String testName) throws Exception {
320 if (logger.isDebugEnabled()) {
321 logger.debug(testBanner(testName, CLASS_NAME));
327 // Submit the request to the service and store the response.
328 AcquisitionClient client = new AcquisitionClient();
329 ClientResponse<AcquisitionsCommonList> res = client.readList();
330 AcquisitionsCommonList list = res.getEntity();
331 int statusCode = res.getStatus();
333 // Check the status code of the response: does it match
334 // the expected response(s)?
335 if(logger.isDebugEnabled()){
336 logger.debug(testName + ": status = " + statusCode);
338 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
339 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
340 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
342 // Optionally output additional data about list members for debugging.
343 boolean iterateThroughList = false;
344 if(iterateThroughList && logger.isDebugEnabled()){
345 List<AcquisitionsCommonList.AcquisitionListItem> items =
346 list.getAcquisitionListItem();
348 for(AcquisitionsCommonList.AcquisitionListItem item : items){
349 logger.debug(testName + ": list-item[" + i + "] csid=" +
351 logger.debug(testName + ": list-item[" + i + "] objectNumber=" +
352 item.getAcquisitionReferenceNumber());
353 logger.debug(testName + ": list-item[" + i + "] acquisitionSources:");
354 AcquisitionSourceList acqSource = item.getAcquisitionSources();
355 for (String acquisitionSource : acqSource.getAcquisitionSource()) {
356 logger.debug("acquisitionSource=" + acquisitionSource);
358 logger.debug(testName + ": list-item[" + i + "] URI=" +
369 // ---------------------------------------------------------------
370 // CRUD tests : UPDATE tests
371 // ---------------------------------------------------------------
375 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
378 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
379 dependsOnMethods = {"read"})
380 public void update(String testName) throws Exception {
382 if (logger.isDebugEnabled()) {
383 logger.debug(testBanner(testName, CLASS_NAME));
389 // Retrieve the contents of a resource to update.
390 AcquisitionClient client = new AcquisitionClient();
391 ClientResponse<MultipartInput> res = client.read(knownResourceId);
392 if(logger.isDebugEnabled()){
393 logger.debug(testName + ": read status = " + res.getStatus());
395 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
397 if(logger.isDebugEnabled()){
398 logger.debug("got object to update with ID: " + knownResourceId);
400 MultipartInput input = (MultipartInput) res.getEntity();
402 AcquisitionsCommon acquisition = (AcquisitionsCommon) extractPart(input,
403 client.getCommonPartName(), AcquisitionsCommon.class);
404 Assert.assertNotNull(acquisition);
406 // Update the content of this resource.
407 acquisition.setAcquisitionReferenceNumber("updated-" + acquisition.getAcquisitionReferenceNumber());
408 if(logger.isDebugEnabled()){
409 logger.debug("updated object");
410 logger.debug(objectAsXmlString(acquisition, AcquisitionsCommon.class));
412 // Submit the request to the service and store the response.
413 MultipartOutput output = new MultipartOutput();
414 OutputPart commonPart = output.addPart(acquisition, MediaType.APPLICATION_XML_TYPE);
415 commonPart.getHeaders().add("label", client.getCommonPartName());
417 res = client.update(knownResourceId, output);
418 int statusCode = res.getStatus();
419 // Check the status code of the response: does it match the expected response(s)?
420 if(logger.isDebugEnabled()){
421 logger.debug(testName + ": status = " + statusCode);
423 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
424 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
425 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
428 input = (MultipartInput) res.getEntity();
429 AcquisitionsCommon updatedAcquisition =
430 (AcquisitionsCommon) extractPart(input,
431 client.getCommonPartName(), AcquisitionsCommon.class);
432 Assert.assertNotNull(updatedAcquisition);
434 Assert.assertEquals(updatedAcquisition.getAcquisitionReferenceNumber(),
435 acquisition.getAcquisitionReferenceNumber(),
436 "Data in updated object did not match submitted data.");
441 // Placeholders until the three tests below can be uncommented.
442 // See Issue CSPACE-401.
444 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
447 public void updateWithEmptyEntityBody(String testName) throws Exception {
448 //Should this really be empty?
452 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
455 public void updateWithMalformedXml(String testName) throws Exception {
456 //Should this really be empty?
460 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
463 public void updateWithWrongXmlSchema(String testName) throws Exception {
464 //Should this really be empty?
469 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
470 dependsOnMethods = {"create", "update", "testSubmitRequest"})
471 public void updateWithEmptyEntityBody(String testName) throws Exception {
473 if (logger.isDebugEnabled()) {
474 logger.debug(testBanner(testName, CLASS_NAME));
478 setupUpdateWithEmptyEntityBody();
480 // Submit the request to the service and store the response.
481 String method = REQUEST_TYPE.httpMethodName();
482 String url = getResourceURL(knownResourceId);
483 String mediaType = MediaType.APPLICATION_XML;
484 final String entity = "";
485 int statusCode = submitRequest(method, url, mediaType, entity);
487 // Check the status code of the response: does it match
488 // the expected response(s)?
489 if(logger.isDebugEnabled()){
490 (testName + ": url=" + url + " status=" + statusCode);
492 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
493 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
494 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
498 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
499 dependsOnMethods = {"create", "testSubmitRequest"})
500 public void createWithEmptyEntityBody(String testName) throws Exception {
502 if (logger.isDebugEnabled()) {
503 logger.debug(testBanner(testName, CLASS_NAME));
507 setupCreateWithEmptyEntityBody();
509 // Submit the request to the service and store the response.
510 String method = REQUEST_TYPE.httpMethodName();
511 String url = getServiceRootURL();
512 String mediaType = MediaType.APPLICATION_XML;
513 final String entity = "";
514 int statusCode = submitRequest(method, url, mediaType, entity);
516 // Check the status code of the response: does it match
517 // the expected response(s)?
518 if(logger.isDebugEnabled()){
519 logger.debug(testName + ": url=" + url +
520 " status=" + statusCode);
522 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
523 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
524 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
528 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
529 dependsOnMethods = {"create", "update", "testSubmitRequest"})
530 public void updateWithMalformedXml(String testName) throws Exception {
532 if (logger.isDebugEnabled()) {
533 logger.debug(testBanner(testName, CLASS_NAME));
537 setupUpdateWithMalformedXml();
539 // Submit the request to the service and store the response.
540 String method = REQUEST_TYPE.httpMethodName();
541 String url = getResourceURL(knownResourceId);
542 final String entity = MALFORMED_XML_DATA;
543 int statusCode = submitRequest(method, url, entity);
545 // Check the status code of the response: does it match
546 // the expected response(s)?
547 if(logger.isDebugEnabled()){
548 logger.debug(testName + ": url=" + url +
549 " status=" + statusCode);
551 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
552 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
553 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
557 @Test(dependsOnMethods = {"create", "update", "testSubmitRequest"})
558 public void updateWithWrongXmlSchema(String testName) {
560 if (logger.isDebugEnabled()) {
561 logger.debug(testBanner(testName, CLASS_NAME));
565 setupUpdateWithWrongXmlSchema();
567 // Submit the request to the service and store the response.
568 String method = REQUEST_TYPE.httpMethodName();
569 String url = getResourceURL(knownResourceId);
570 final String entity = WRONG_XML_SCHEMA_DATA;
571 int statusCode = submitRequest(method, url, entity);
573 // Check the status code of the response: does it match
574 // the expected response(s)?
575 if(logger.isDebugEnabled()){
576 logger.debug(testName + ": url=" + url +
577 " status=" + statusCode);
579 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
580 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
581 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
586 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
589 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
590 dependsOnMethods = {"update", "testSubmitRequest"})
591 public void updateNonExistent(String testName) throws Exception {
593 if (logger.isDebugEnabled()) {
594 logger.debug(testBanner(testName, CLASS_NAME));
598 setupUpdateNonExistent();
600 // Submit the request to the service and store the response.
601 // Note: The ID used in this 'create' call may be arbitrary.
602 // The only relevant ID may be the one used in update(), below.
603 AcquisitionClient client = new AcquisitionClient();
604 MultipartOutput multipart = createAcquisitionInstance(NON_EXISTENT_ID);
605 ClientResponse<MultipartInput> res =
606 client.update(NON_EXISTENT_ID, multipart);
607 int statusCode = res.getStatus();
609 // Check the status code of the response: does it match
610 // the expected response(s)?
611 if(logger.isDebugEnabled()){
612 logger.debug(testName + ": status = " + statusCode);
614 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
615 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
616 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
619 // ---------------------------------------------------------------
620 // CRUD tests : DELETE tests
621 // ---------------------------------------------------------------
624 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
627 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
628 dependsOnMethods = {"create", "read", "update"})
629 public void delete(String testName) throws Exception {
631 if (logger.isDebugEnabled()) {
632 logger.debug(testBanner(testName, CLASS_NAME));
638 // Submit the request to the service and store the response.
639 AcquisitionClient client = new AcquisitionClient();
640 ClientResponse<Response> res = client.delete(knownResourceId);
641 int statusCode = res.getStatus();
643 // Check the status code of the response: does it match
644 // the expected response(s)?
645 if(logger.isDebugEnabled()){
646 logger.debug(testName + ": status = " + statusCode);
648 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
649 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
650 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
655 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
658 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
659 dependsOnMethods = {"delete"})
660 public void deleteNonExistent(String testName) throws Exception {
662 if (logger.isDebugEnabled()) {
663 logger.debug(testBanner(testName, CLASS_NAME));
667 setupDeleteNonExistent();
669 // Submit the request to the service and store the response.
670 AcquisitionClient client = new AcquisitionClient();
671 ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
672 int statusCode = res.getStatus();
674 // Check the status code of the response: does it match
675 // the expected response(s)?
676 if(logger.isDebugEnabled()){
677 logger.debug(testName + ": status = " + statusCode);
679 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
680 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
681 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
684 // ---------------------------------------------------------------
685 // Utility tests : tests of code used in tests above
686 // ---------------------------------------------------------------
688 * Tests the code for manually submitting data that is used by several
689 * of the methods above.
693 @Test(dependsOnMethods = {"create", "read"})
694 public void testSubmitRequest() throws Exception {
699 // Submit the request to the service and store the response.
700 String method = ServiceRequestType.READ.httpMethodName();
701 String url = getResourceURL(knownResourceId);
702 int statusCode = submitRequest(method, url);
704 // Check the status code of the response: does it match
705 // the expected response(s)?
706 if(logger.isDebugEnabled()){
707 logger.debug("testSubmitRequest: url=" + url +
708 " status=" + statusCode);
710 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
714 // ---------------------------------------------------------------
715 // Utility methods used by tests above
716 // ---------------------------------------------------------------
718 * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
721 public String getServicePathComponent() {
722 return new AcquisitionClient().getServicePathComponent();
727 * Creates the acquisition instance.
729 * @param identifier the identifier
730 * @return the multipart output
732 private MultipartOutput createAcquisitionInstance(String identifier) {
733 AcquisitionsCommon acquisition = new AcquisitionsCommon();
734 acquisition.setAcquisitionReferenceNumber("acquisitionReferenceNumber-" + identifier);
735 AcquisitionSourceList acqSourcesList = new AcquisitionSourceList();
736 List<String> sources = acqSourcesList.getAcquisitionSource();
737 // @TODO Use properly formatted refNames for representative acquisition
738 // sources in this example test record. The following are mere placeholders.
739 sources.add("Donor Acquisition Source-" + identifier);
740 sources.add("Museum Acquisition Source-" + identifier);
741 acquisition.setAcquisitionSources(acqSourcesList);
742 MultipartOutput multipart = new MultipartOutput();
743 OutputPart commonPart = multipart.addPart(acquisition,
744 MediaType.APPLICATION_XML_TYPE);
745 commonPart.getHeaders().add("label", new AcquisitionClient().getCommonPartName());
747 if(logger.isDebugEnabled()){
748 logger.debug("to be created, acquisition common");
749 logger.debug(objectAsXmlString(acquisition, AcquisitionsCommon.class));