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.ArrayList;
26 import java.util.HashMap;
27 import java.util.List;
29 import javax.ws.rs.core.MediaType;
30 import javax.ws.rs.core.Response;
32 import org.collectionspace.services.LocationJAXBSchema;
33 import org.collectionspace.services.client.CollectionSpaceClient;
34 import org.collectionspace.services.client.ContactClient;
35 import org.collectionspace.services.client.ContactClientUtils;
36 import org.collectionspace.services.contact.ContactsCommon;
37 import org.collectionspace.services.contact.ContactsCommonList;
38 import org.collectionspace.services.client.LocationAuthorityClient;
39 import org.collectionspace.services.client.LocationAuthorityClientUtils;
40 import org.collectionspace.services.jaxb.AbstractCommonList;
41 import org.collectionspace.services.location.LocationauthoritiesCommon;
42 import org.collectionspace.services.location.LocationauthoritiesCommonList;
43 import org.collectionspace.services.location.LocationsCommon;
44 import org.collectionspace.services.location.LocationsCommonList;
45 import org.jboss.resteasy.client.ClientResponse;
46 import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
47 import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
48 import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
49 import org.slf4j.Logger;
50 import org.slf4j.LoggerFactory;
51 import org.testng.Assert;
52 import org.testng.annotations.AfterClass;
53 import org.testng.annotations.Test;
56 * LocationAuthorityServiceTest, carries out tests against a
57 * deployed and running LocationAuthority Service.
59 * $LastChangedRevision: 753 $
60 * $LastChangedDate: 2009-09-23 11:03:36 -0700 (Wed, 23 Sep 2009) $
62 public class LocationAuthorityServiceTest extends AbstractServiceTestImpl {
65 private final String CLASS_NAME = LocationAuthorityServiceTest.class.getName();
66 private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
68 // Instance variables specific to this test.
70 /** The SERVICE path component. */
71 final String SERVICE_PATH_COMPONENT = "locationauthorities";
73 /** The ITEM service path component. */
74 final String ITEM_SERVICE_PATH_COMPONENT = "items";
76 /** The CONTACT service path component. */
77 final String CONTACT_SERVICE_PATH_COMPONENT = "contacts";
80 final String TEST_NAME = "Shelf 1";
82 /** The TEST conditionNote. */
83 final String TEST_CONDITION_NOTE = "Basically clean";
85 /** The TEST death date. */
86 final String TEST_CONDITION_NOTE_DATE = "June 11, 1979";
88 /** The TEST securityNote. */
89 final String TEST_SECURITY_NOTE = "Kind of safe";
91 /** The TEST location type. */
92 // TODO Make loc type be a controlled vocab term.
93 final String TEST_LOCATION_TYPE = "Shelf";
95 /** The TEST location type. */
96 // TODO Make status type be a controlled vocab term.
97 final String TEST_STATUS = "Approved";
99 /** The known resource id. */
100 private String knownResourceId = null;
102 /** The known resource display name. */
103 private String knownResourceDisplayName = null;
105 /** The known resource ref name. */
106 private String knownResourceRefName = null;
108 /** The known locationType ref name. */
109 private String knownLocationTypeRefName = null;
111 /** The known item resource id. */
112 private String knownItemResourceId = null;
114 /** The known contact resource id. */
115 private String knownContactResourceId = null;
117 /** The n items to create in list. */
118 private int nItemsToCreateInList = 3;
120 /** The all resource ids created. */
121 private List<String> allResourceIdsCreated = new ArrayList<String>();
123 /** The all item resource ids created. */
124 private Map<String, String> allItemResourceIdsCreated =
125 new HashMap<String, String>();
128 * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
131 protected CollectionSpaceClient getClientInstance() {
132 return new LocationAuthorityClient();
136 * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
139 protected AbstractCommonList getAbstractCommonList(
140 ClientResponse<AbstractCommonList> response) {
141 return response.getEntity(LocationsCommonList.class);
144 // ---------------------------------------------------------------
145 // CRUD tests : CREATE tests
146 // ---------------------------------------------------------------
149 * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
152 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
154 public void create(String testName) throws Exception {
156 if (logger.isDebugEnabled()) {
157 logger.debug(testBanner(testName, CLASS_NAME));
159 // Perform setup, such as initializing the type of service request
160 // (e.g. CREATE, DELETE), its valid and expected status codes, and
161 // its associated HTTP method name (e.g. POST, DELETE).
164 // Submit the request to the service and store the response.
165 LocationAuthorityClient client = new LocationAuthorityClient();
166 String identifier = createIdentifier();
167 String displayName = "displayName-" + identifier;
168 String baseRefName = LocationAuthorityClientUtils.createLocationAuthRefName(displayName, false);
169 String fullRefName = LocationAuthorityClientUtils.createLocationAuthRefName(displayName, true);
170 MultipartOutput multipart =
171 LocationAuthorityClientUtils.createLocationAuthorityInstance(
172 displayName, fullRefName, client.getCommonPartName());
173 ClientResponse<Response> res = client.create(multipart);
174 int statusCode = res.getStatus();
176 // Check the status code of the response: does it match
177 // the expected response(s)?
180 // Does it fall within the set of valid status codes?
181 // Does it exactly match the expected status code?
182 if(logger.isDebugEnabled()){
183 logger.debug(testName + ": status = " + statusCode);
185 Assert.assertTrue(this.REQUEST_TYPE.isValidStatusCode(statusCode),
186 invalidStatusCodeMessage(this.REQUEST_TYPE, statusCode));
187 Assert.assertEquals(statusCode, this.EXPECTED_STATUS_CODE);
189 // Store the refname from the first resource created
190 // for additional tests below.
191 knownResourceRefName = baseRefName;
193 String newID = LocationAuthorityClientUtils.extractId(res);
194 // Store the ID returned from the first resource created
195 // for additional tests below.
196 if (knownResourceId == null){
197 knownResourceId = newID;
198 knownResourceDisplayName = displayName;
199 if (logger.isDebugEnabled()) {
200 logger.debug(testName + ": knownResourceId=" + knownResourceId);
203 // Store the IDs from every resource created by tests,
204 // so they can be deleted after tests have been run.
205 allResourceIdsCreated.add(newID);
211 * @param testName the test name
213 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
214 groups = {"create"}, dependsOnMethods = {"create"})
215 public void createItem(String testName) {
216 if(logger.isDebugEnabled()){
217 logger.debug(testBanner(testName, CLASS_NAME));
220 String newID = createItemInAuthority(knownResourceId, knownResourceRefName);
224 * Creates the item in authority.
226 * @param vcsid the vcsid
227 * @param authRefName the auth ref name
230 private String createItemInAuthority(String vcsid, String authRefName) {
232 final String testName = "createItemInAuthority";
233 if(logger.isDebugEnabled()){
234 logger.debug(testBanner(testName, CLASS_NAME));
237 // Submit the request to the service and store the response.
238 LocationAuthorityClient client = new LocationAuthorityClient();
239 String identifier = createIdentifier();
240 String refName = LocationAuthorityClientUtils.createLocationRefName(authRefName, TEST_NAME, true);
241 Map<String, String> shelf1Map = new HashMap<String,String>();
242 // TODO Make loc type and status be controlled vocabs.
243 shelf1Map.put(LocationJAXBSchema.NAME, TEST_NAME);
244 shelf1Map.put(LocationJAXBSchema.CONDITION_NOTE, TEST_CONDITION_NOTE);
245 shelf1Map.put(LocationJAXBSchema.CONDITION_NOTE_DATE, TEST_CONDITION_NOTE_DATE);
246 shelf1Map.put(LocationJAXBSchema.SECURITY_NOTE, TEST_SECURITY_NOTE);
247 shelf1Map.put(LocationJAXBSchema.LOCATION_TYPE, TEST_LOCATION_TYPE);
248 shelf1Map.put(LocationJAXBSchema.STATUS, TEST_STATUS);
249 MultipartOutput multipart =
250 LocationAuthorityClientUtils.createLocationInstance(vcsid, refName, shelf1Map,
251 client.getItemCommonPartName() );
252 ClientResponse<Response> res = client.createItem(vcsid, multipart);
253 int statusCode = res.getStatus();
254 String newID = LocationAuthorityClientUtils.extractId(res);
256 // Check the status code of the response: does it match
257 // the expected response(s)?
258 if(logger.isDebugEnabled()){
259 logger.debug(testName + ": status = " + statusCode);
261 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
262 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
263 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
265 // Store the ID returned from the first item resource created
266 // for additional tests below.
267 if (knownItemResourceId == null){
268 knownItemResourceId = newID;
269 if (logger.isDebugEnabled()) {
270 logger.debug(testName + ": knownItemResourceId=" + knownItemResourceId);
274 // Store the IDs from any item resources created
275 // by tests, along with the IDs of their parents, so these items
276 // can be deleted after all tests have been run.
277 allItemResourceIdsCreated.put(newID, vcsid);
286 // Placeholders until the three tests below can be uncommented.
287 // See Issue CSPACE-401.
289 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
292 public void createWithEmptyEntityBody(String testName) throws Exception {
296 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
299 public void createWithMalformedXml(String testName) throws Exception {
303 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
306 public void createWithWrongXmlSchema(String testName) throws Exception {
310 // ---------------------------------------------------------------
311 // CRUD tests : CREATE LIST tests
312 // ---------------------------------------------------------------
315 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
318 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
319 groups = {"createList"}, dependsOnGroups = {"create"})
320 public void createList(String testName) throws Exception {
321 for (int i = 0; i < nItemsToCreateInList; i++) {
327 * Creates the item list.
329 * @param testName the test name
330 * @throws Exception the exception
332 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
333 groups = {"createList"}, dependsOnMethods = {"createList"})
334 public void createItemList(String testName) throws Exception {
335 // Add items to the initially-created, known parent record.
336 for (int j = 0; j < nItemsToCreateInList; j++) {
337 createItem(testName);
341 // ---------------------------------------------------------------
342 // CRUD tests : READ tests
343 // ---------------------------------------------------------------
346 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
349 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
350 groups = {"read"}, dependsOnGroups = {"create"})
351 public void read(String testName) throws Exception {
353 if (logger.isDebugEnabled()) {
354 logger.debug(testBanner(testName, CLASS_NAME));
359 // Submit the request to the service and store the response.
360 LocationAuthorityClient client = new LocationAuthorityClient();
361 ClientResponse<MultipartInput> res = client.read(knownResourceId);
362 int statusCode = res.getStatus();
364 // Check the status code of the response: does it match
365 // the expected response(s)?
366 if(logger.isDebugEnabled()){
367 logger.debug(testName + ": status = " + statusCode);
369 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
370 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
371 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
372 //FIXME: remove the following try catch once Aron fixes signatures
374 MultipartInput input = (MultipartInput) res.getEntity();
375 LocationauthoritiesCommon locationAuthority = (LocationauthoritiesCommon) extractPart(input,
376 client.getCommonPartName(), LocationauthoritiesCommon.class);
377 Assert.assertNotNull(locationAuthority);
378 } catch (Exception e) {
379 throw new RuntimeException(e);
386 * @param testName the test name
387 * @throws Exception the exception
389 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
390 groups = {"read"}, dependsOnGroups = {"create"})
391 public void readByName(String testName) throws Exception {
393 if (logger.isDebugEnabled()) {
394 logger.debug(testBanner(testName, CLASS_NAME));
399 // Submit the request to the service and store the response.
400 LocationAuthorityClient client = new LocationAuthorityClient();
401 ClientResponse<MultipartInput> res = client.readByName(knownResourceDisplayName);
402 int statusCode = res.getStatus();
404 // Check the status code of the response: does it match
405 // the expected response(s)?
406 if(logger.isDebugEnabled()){
407 logger.debug(testName + ": status = " + statusCode);
409 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
410 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
411 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
412 //FIXME: remove the following try catch once Aron fixes signatures
414 MultipartInput input = (MultipartInput) res.getEntity();
415 LocationauthoritiesCommon locationAuthority = (LocationauthoritiesCommon) extractPart(input,
416 client.getCommonPartName(), LocationauthoritiesCommon.class);
417 Assert.assertNotNull(locationAuthority);
418 } catch (Exception e) {
419 throw new RuntimeException(e);
427 * @param testName the test name
428 * @throws Exception the exception
430 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
431 groups = {"read"}, dependsOnMethods = {"read"})
432 public void readItem(String testName) throws Exception {
434 if (logger.isDebugEnabled()) {
435 logger.debug(testBanner(testName, CLASS_NAME));
440 // Submit the request to the service and store the response.
441 LocationAuthorityClient client = new LocationAuthorityClient();
442 ClientResponse<MultipartInput> res = client.readItem(knownResourceId, knownItemResourceId);
443 int statusCode = res.getStatus();
445 // Check the status code of the response: does it match
446 // the expected response(s)?
447 if(logger.isDebugEnabled()){
448 logger.debug(testName + ": status = " + statusCode);
450 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
451 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
452 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
454 // Check whether we've received a location.
455 MultipartInput input = (MultipartInput) res.getEntity();
456 LocationsCommon location = (LocationsCommon) extractPart(input,
457 client.getItemCommonPartName(), LocationsCommon.class);
458 Assert.assertNotNull(location);
459 boolean showFull = true;
460 if(showFull && logger.isDebugEnabled()){
461 logger.debug(testName + ": returned payload:");
462 logger.debug(objectAsXmlString(location, LocationsCommon.class));
464 Assert.assertEquals(location.getInAuthority(), knownResourceId);
469 * Verify item display name.
471 * @param testName the test name
472 * @throws Exception the exception
474 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
475 dependsOnMethods = {"readItem", "updateItem"})
476 public void verifyItemDisplayName(String testName) throws Exception {
478 if (logger.isDebugEnabled()) {
479 logger.debug(testBanner(testName, CLASS_NAME));
484 // Submit the request to the service and store the response.
485 LocationAuthorityClient client = new LocationAuthorityClient();
486 ClientResponse<MultipartInput> res = client.readItem(knownResourceId, knownItemResourceId);
487 int statusCode = res.getStatus();
489 // Check the status code of the response: does it match
490 // the expected response(s)?
491 if(logger.isDebugEnabled()){
492 logger.debug(testName + ": status = " + statusCode);
494 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
495 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
496 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
498 // Check whether location has expected displayName.
499 MultipartInput input = (MultipartInput) res.getEntity();
500 LocationsCommon location = (LocationsCommon) extractPart(input,
501 client.getItemCommonPartName(), LocationsCommon.class);
502 Assert.assertNotNull(location);
503 String displayName = location.getDisplayName();
504 // Make sure displayName matches computed form
505 String expectedDisplayName =
506 LocationAuthorityClientUtils.prepareDefaultDisplayName(TEST_NAME);
507 Assert.assertNotNull(displayName, expectedDisplayName);
509 // Update the shortName and verify the computed name is updated.
510 location.setCsid(null);
511 location.setDisplayNameComputed(true);
512 location.setName("updated-" + TEST_NAME);
513 expectedDisplayName =
514 LocationAuthorityClientUtils.prepareDefaultDisplayName("updated-" + TEST_NAME);
516 // Submit the updated resource to the service and store the response.
517 MultipartOutput output = new MultipartOutput();
518 OutputPart commonPart = output.addPart(location, MediaType.APPLICATION_XML_TYPE);
519 commonPart.getHeaders().add("label", client.getItemCommonPartName());
520 res = client.updateItem(knownResourceId, knownItemResourceId, output);
521 statusCode = res.getStatus();
523 // Check the status code of the response: does it match the expected response(s)?
524 if(logger.isDebugEnabled()){
525 logger.debug("updateItem: status = " + statusCode);
527 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
528 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
529 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
531 // Retrieve the updated resource and verify that its contents exist.
532 input = (MultipartInput) res.getEntity();
533 LocationsCommon updatedLocation =
534 (LocationsCommon) extractPart(input,
535 client.getItemCommonPartName(), LocationsCommon.class);
536 Assert.assertNotNull(updatedLocation);
538 // Verify that the updated resource received the correct data.
539 Assert.assertEquals(updatedLocation.getName(), location.getName(),
540 "Updated ForeName in Location did not match submitted data.");
541 // Verify that the updated resource computes the right displayName.
542 Assert.assertEquals(updatedLocation.getDisplayName(), expectedDisplayName,
543 "Updated ForeName in Location not reflected in computed DisplayName.");
545 // Now Update the displayName, not computed and verify the computed name is overriden.
546 location.setDisplayNameComputed(false);
547 expectedDisplayName = "TestName";
548 location.setDisplayName(expectedDisplayName);
550 // Submit the updated resource to the service and store the response.
551 output = new MultipartOutput();
552 commonPart = output.addPart(location, MediaType.APPLICATION_XML_TYPE);
553 commonPart.getHeaders().add("label", client.getItemCommonPartName());
554 res = client.updateItem(knownResourceId, knownItemResourceId, output);
555 statusCode = res.getStatus();
557 // Check the status code of the response: does it match the expected response(s)?
558 if(logger.isDebugEnabled()){
559 logger.debug("updateItem: status = " + statusCode);
561 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
562 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
563 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
565 // Retrieve the updated resource and verify that its contents exist.
566 input = (MultipartInput) res.getEntity();
568 (LocationsCommon) extractPart(input,
569 client.getItemCommonPartName(), LocationsCommon.class);
570 Assert.assertNotNull(updatedLocation);
572 // Verify that the updated resource received the correct data.
573 Assert.assertEquals(updatedLocation.isDisplayNameComputed(), false,
574 "Updated displayNameComputed in Location did not match submitted data.");
575 // Verify that the updated resource computes the right displayName.
576 Assert.assertEquals(updatedLocation.getDisplayName(),
578 "Updated DisplayName (not computed) in Location not stored.");
582 * Verify illegal item display name.
584 * @param testName the test name
585 * @throws Exception the exception
587 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
588 dependsOnMethods = {"verifyItemDisplayName"})
589 public void verifyIllegalItemDisplayName(String testName) throws Exception {
591 if (logger.isDebugEnabled()) {
592 logger.debug(testBanner(testName, CLASS_NAME));
595 // FIXME: create a setup configuration for this operation.
596 setupUpdateWithWrongXmlSchema();
598 // Submit the request to the service and store the response.
599 LocationAuthorityClient client = new LocationAuthorityClient();
600 ClientResponse<MultipartInput> res = client.readItem(knownResourceId, knownItemResourceId);
601 int statusCode = res.getStatus();
603 // Check the status code of the response: does it match
604 // the expected response(s)?
605 if(logger.isDebugEnabled()){
606 logger.debug(testName + ": status = " + statusCode);
608 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
609 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
610 Assert.assertEquals(statusCode, Response.Status.OK.getStatusCode());
612 // Check whether Location has expected displayName.
613 MultipartInput input = (MultipartInput) res.getEntity();
614 LocationsCommon location = (LocationsCommon) extractPart(input,
615 client.getItemCommonPartName(), LocationsCommon.class);
616 Assert.assertNotNull(location);
617 // Try to Update with computed false and no displayName
618 location.setDisplayNameComputed(false);
619 location.setDisplayName(null);
621 // Submit the updated resource to the service and store the response.
622 MultipartOutput output = new MultipartOutput();
623 OutputPart commonPart = output.addPart(location, MediaType.APPLICATION_XML_TYPE);
624 commonPart.getHeaders().add("label", client.getItemCommonPartName());
625 res = client.updateItem(knownResourceId, knownItemResourceId, output);
626 statusCode = res.getStatus();
628 // Check the status code of the response: does it match the expected response(s)?
629 if(logger.isDebugEnabled()){
630 logger.debug("updateItem: status = " + statusCode);
632 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
633 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
634 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
640 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
643 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
644 groups = {"read"}, dependsOnMethods = {"read"})
645 public void readNonExistent(String testName) {
647 if (logger.isDebugEnabled()) {
648 logger.debug(testBanner(testName, CLASS_NAME));
651 setupReadNonExistent();
653 // Submit the request to the service and store the response.
654 LocationAuthorityClient client = new LocationAuthorityClient();
655 ClientResponse<MultipartInput> res = client.read(NON_EXISTENT_ID);
656 int statusCode = res.getStatus();
658 // Check the status code of the response: does it match
659 // the expected response(s)?
660 if(logger.isDebugEnabled()){
661 logger.debug(testName + ": status = " + statusCode);
663 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
664 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
665 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
669 * Read item non existent.
671 * @param testName the test name
673 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
674 groups = {"read"}, dependsOnMethods = {"readItem"})
675 public void readItemNonExistent(String testName) {
677 if (logger.isDebugEnabled()) {
678 logger.debug(testBanner(testName, CLASS_NAME));
681 setupReadNonExistent();
683 // Submit the request to the service and store the response.
684 LocationAuthorityClient client = new LocationAuthorityClient();
685 ClientResponse<MultipartInput> res = client.readItem(knownResourceId, NON_EXISTENT_ID);
686 int statusCode = res.getStatus();
688 // Check the status code of the response: does it match
689 // the expected response(s)?
690 if(logger.isDebugEnabled()){
691 logger.debug(testName + ": status = " + statusCode);
693 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
694 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
695 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
699 // ---------------------------------------------------------------
700 // CRUD tests : READ_LIST tests
701 // ---------------------------------------------------------------
705 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
708 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
709 groups = {"readList"}, dependsOnGroups = {"createList", "read"})
710 public void readList(String testName) throws Exception {
712 if (logger.isDebugEnabled()) {
713 logger.debug(testBanner(testName, CLASS_NAME));
718 // Submit the request to the service and store the response.
719 LocationAuthorityClient client = new LocationAuthorityClient();
720 ClientResponse<LocationauthoritiesCommonList> res = client.readList();
721 LocationauthoritiesCommonList list = res.getEntity();
722 int statusCode = res.getStatus();
724 // Check the status code of the response: does it match
725 // the expected response(s)?
726 if(logger.isDebugEnabled()){
727 logger.debug(testName + ": status = " + statusCode);
729 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
730 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
731 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
733 // Optionally output additional data about list members for debugging.
734 boolean iterateThroughList = false;
735 if (iterateThroughList && logger.isDebugEnabled()) {
736 List<LocationauthoritiesCommonList.LocationauthorityListItem> items =
737 list.getLocationauthorityListItem();
739 for (LocationauthoritiesCommonList.LocationauthorityListItem item : items) {
740 String csid = item.getCsid();
741 logger.debug(testName + ": list-item[" + i + "] csid=" +
743 logger.debug(testName + ": list-item[" + i + "] displayName=" +
744 item.getDisplayName());
745 logger.debug(testName + ": list-item[" + i + "] URI=" +
747 readItemList(csid, null);
756 @Test(groups = {"readList"}, dependsOnMethods = {"readList"})
757 public void readItemList() {
758 String testName = "readItemList";
759 if (logger.isDebugEnabled()) {
760 logger.debug(testBanner(testName, CLASS_NAME));
762 readItemList(knownResourceId, null);
766 * Read item list by authority name.
768 @Test(groups = {"readList"}, dependsOnMethods = {"readItemList"})
769 public void readItemListByAuthorityName() {
770 String testName = "readItemListByAuthorityName";
771 if (logger.isDebugEnabled()) {
772 logger.debug(testBanner(testName, CLASS_NAME));
774 readItemList(null, knownResourceDisplayName);
780 * @param vcsid the vcsid
781 * @param name the name
783 private void readItemList(String vcsid, String name) {
785 String testName = "readItemList";
790 // Submit the request to the service and store the response.
791 LocationAuthorityClient client = new LocationAuthorityClient();
792 ClientResponse<LocationsCommonList> res = null;
794 res = client.readItemList(vcsid);
795 } else if(name!= null) {
796 res = client.readItemListForNamedAuthority(name);
798 Assert.fail("readItemList passed null csid and name!");
800 LocationsCommonList list = res.getEntity();
801 int statusCode = res.getStatus();
803 // Check the status code of the response: does it match
804 // the expected response(s)?
805 if(logger.isDebugEnabled()){
806 logger.debug(testName + ": status = " + statusCode);
808 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
809 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
810 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
812 List<LocationsCommonList.LocationListItem> items =
813 list.getLocationListItem();
814 int nItemsReturned = items.size();
815 // There will be one item created, associated with a
816 // known parent resource, by the createItem test.
818 // In addition, there will be 'nItemsToCreateInList'
819 // additional items created by the createItemList test,
820 // all associated with the same parent resource.
821 int nExpectedItems = nItemsToCreateInList + 1;
822 if(logger.isDebugEnabled()){
823 logger.debug(testName + ": Expected "
824 + nExpectedItems +" items; got: "+nItemsReturned);
826 Assert.assertEquals(nItemsReturned, nExpectedItems);
829 for (LocationsCommonList.LocationListItem item : items) {
830 Assert.assertTrue((null != item.getRefName()), "Item refName is null!");
831 Assert.assertTrue((null != item.getDisplayName()), "Item displayName is null!");
832 // Optionally output additional data about list members for debugging.
833 boolean showDetails = true;
834 if (showDetails && logger.isDebugEnabled()) {
835 logger.debug(" " + testName + ": list-item[" + i + "] csid=" +
837 logger.debug(" " + testName + ": list-item[" + i + "] refName=" +
839 logger.debug(" " + testName + ": list-item[" + i + "] displayName=" +
840 item.getDisplayName());
841 logger.debug(" " + testName + ": list-item[" + i + "] URI=" +
852 // ---------------------------------------------------------------
853 // CRUD tests : UPDATE tests
854 // ---------------------------------------------------------------
857 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
860 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
861 groups = {"update"}, dependsOnGroups = {"read", "readList"})
862 public void update(String testName) throws Exception {
864 if (logger.isDebugEnabled()) {
865 logger.debug(testBanner(testName, CLASS_NAME));
870 // Retrieve the contents of a resource to update.
871 LocationAuthorityClient client = new LocationAuthorityClient();
872 ClientResponse<MultipartInput> res =
873 client.read(knownResourceId);
874 if(logger.isDebugEnabled()){
875 logger.debug(testName + ": read status = " + res.getStatus());
877 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
879 if(logger.isDebugEnabled()){
880 logger.debug("got LocationAuthority to update with ID: " + knownResourceId);
882 MultipartInput input = (MultipartInput) res.getEntity();
883 LocationauthoritiesCommon locationAuthority = (LocationauthoritiesCommon) extractPart(input,
884 client.getCommonPartName(), LocationauthoritiesCommon.class);
885 Assert.assertNotNull(locationAuthority);
887 // Update the contents of this resource.
888 locationAuthority.setDisplayName("updated-" + locationAuthority.getDisplayName());
889 locationAuthority.setVocabType("updated-" + locationAuthority.getVocabType());
890 if(logger.isDebugEnabled()){
891 logger.debug("to be updated LocationAuthority");
892 logger.debug(objectAsXmlString(locationAuthority, LocationauthoritiesCommon.class));
895 // Submit the updated resource to the service and store the response.
896 MultipartOutput output = new MultipartOutput();
897 OutputPart commonPart = output.addPart(locationAuthority, MediaType.APPLICATION_XML_TYPE);
898 commonPart.getHeaders().add("label", client.getCommonPartName());
899 res = client.update(knownResourceId, output);
900 int statusCode = res.getStatus();
902 // Check the status code of the response: does it match the expected response(s)?
903 if(logger.isDebugEnabled()){
904 logger.debug(testName + ": status = " + statusCode);
906 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
907 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
908 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
910 // Retrieve the updated resource and verify that its contents exist.
911 input = (MultipartInput) res.getEntity();
912 LocationauthoritiesCommon updatedLocationAuthority =
913 (LocationauthoritiesCommon) extractPart(input,
914 client.getCommonPartName(), LocationauthoritiesCommon.class);
915 Assert.assertNotNull(updatedLocationAuthority);
917 // Verify that the updated resource received the correct data.
918 Assert.assertEquals(updatedLocationAuthority.getDisplayName(),
919 locationAuthority.getDisplayName(),
920 "Data in updated object did not match submitted data.");
926 * @param testName the test name
927 * @throws Exception the exception
929 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
930 groups = {"update"}, dependsOnMethods = {"update"})
931 public void updateItem(String testName) throws Exception {
933 if (logger.isDebugEnabled()) {
934 logger.debug(testBanner(testName, CLASS_NAME));
939 // Retrieve the contents of a resource to update.
940 LocationAuthorityClient client = new LocationAuthorityClient();
941 ClientResponse<MultipartInput> res =
942 client.readItem(knownResourceId, knownItemResourceId);
943 if(logger.isDebugEnabled()){
944 logger.debug(testName + ": read status = " + res.getStatus());
946 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
948 if(logger.isDebugEnabled()){
949 logger.debug("got Location to update with ID: " +
950 knownItemResourceId +
951 " in LocationAuthority: " + knownResourceId );
953 MultipartInput input = (MultipartInput) res.getEntity();
954 LocationsCommon location = (LocationsCommon) extractPart(input,
955 client.getItemCommonPartName(), LocationsCommon.class);
956 Assert.assertNotNull(location);
958 // Update the contents of this resource.
959 location.setCsid(null);
960 location.setName("updated-" + location.getName());
961 if(logger.isDebugEnabled()){
962 logger.debug("to be updated Location");
963 logger.debug(objectAsXmlString(location,
964 LocationsCommon.class));
967 // Submit the updated resource to the service and store the response.
968 MultipartOutput output = new MultipartOutput();
969 OutputPart commonPart = output.addPart(location, MediaType.APPLICATION_XML_TYPE);
970 commonPart.getHeaders().add("label", client.getItemCommonPartName());
971 res = client.updateItem(knownResourceId, knownItemResourceId, output);
972 int statusCode = res.getStatus();
974 // Check the status code of the response: does it match the expected response(s)?
975 if(logger.isDebugEnabled()){
976 logger.debug(testName + ": status = " + statusCode);
978 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
979 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
980 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
982 // Retrieve the updated resource and verify that its contents exist.
983 input = (MultipartInput) res.getEntity();
984 LocationsCommon updatedLocation =
985 (LocationsCommon) extractPart(input,
986 client.getItemCommonPartName(), LocationsCommon.class);
987 Assert.assertNotNull(updatedLocation);
989 // Verify that the updated resource received the correct data.
990 Assert.assertEquals(updatedLocation.getName(), location.getName(),
991 "Data in updated Location did not match submitted data.");
995 // Placeholders until the three tests below can be uncommented.
996 // See Issue CSPACE-401.
998 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
1001 public void updateWithEmptyEntityBody(String testName) throws Exception {
1005 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
1008 public void updateWithMalformedXml(String testName) throws Exception {
1012 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
1015 public void updateWithWrongXmlSchema(String testName) throws Exception {
1020 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
1023 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1024 groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
1025 public void updateNonExistent(String testName) throws Exception {
1027 if (logger.isDebugEnabled()) {
1028 logger.debug(testBanner(testName, CLASS_NAME));
1031 setupUpdateNonExistent();
1033 // Submit the request to the service and store the response.
1034 // Note: The ID(s) used when creating the request payload may be arbitrary.
1035 // The only relevant ID may be the one used in update(), below.
1036 LocationAuthorityClient client = new LocationAuthorityClient();
1037 String displayName = "displayName-NON_EXISTENT_ID";
1038 String fullRefName = LocationAuthorityClientUtils.createLocationAuthRefName(displayName, true);
1039 MultipartOutput multipart = LocationAuthorityClientUtils.createLocationAuthorityInstance(
1040 displayName, fullRefName, client.getCommonPartName());
1041 ClientResponse<MultipartInput> res =
1042 client.update(NON_EXISTENT_ID, multipart);
1043 int statusCode = res.getStatus();
1045 // Check the status code of the response: does it match
1046 // the expected response(s)?
1047 if(logger.isDebugEnabled()){
1048 logger.debug(testName + ": status = " + statusCode);
1050 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1051 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1052 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1056 * Update non existent item.
1058 * @param testName the test name
1059 * @throws Exception the exception
1061 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1062 groups = {"update"}, dependsOnMethods = {"updateItem", "testItemSubmitRequest"})
1063 public void updateNonExistentItem(String testName) throws Exception {
1065 if (logger.isDebugEnabled()) {
1066 logger.debug(testBanner(testName, CLASS_NAME));
1069 setupUpdateNonExistent();
1071 // Submit the request to the service and store the response.
1072 // Note: The ID used in this 'create' call may be arbitrary.
1073 // The only relevant ID may be the one used in update(), below.
1074 LocationAuthorityClient client = new LocationAuthorityClient();
1075 Map<String, String> nonexMap = new HashMap<String,String>();
1076 nonexMap.put(LocationJAXBSchema.NAME, TEST_NAME);
1077 nonexMap.put(LocationJAXBSchema.LOCATION_TYPE, TEST_LOCATION_TYPE);
1078 nonexMap.put(LocationJAXBSchema.STATUS, TEST_STATUS);
1079 MultipartOutput multipart =
1080 LocationAuthorityClientUtils.createLocationInstance(NON_EXISTENT_ID,
1081 LocationAuthorityClientUtils.createLocationRefName(NON_EXISTENT_ID, NON_EXISTENT_ID, true), nonexMap,
1082 client.getItemCommonPartName() );
1083 ClientResponse<MultipartInput> res =
1084 client.updateItem(knownResourceId, NON_EXISTENT_ID, multipart);
1085 int statusCode = res.getStatus();
1087 // Check the status code of the response: does it match
1088 // the expected response(s)?
1089 if(logger.isDebugEnabled()){
1090 logger.debug(testName + ": status = " + statusCode);
1092 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1093 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1094 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1097 // ---------------------------------------------------------------
1098 // CRUD tests : DELETE tests
1099 // ---------------------------------------------------------------
1102 // Note: delete sub-resources in ascending hierarchical order,
1103 // before deleting their parents.
1108 * @param testName the test name
1109 * @throws Exception the exception
1111 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1112 //groups = {"delete"}, dependsOnGroups = {"create", "read", "readList", "readListByPartialTerm", "update"})
1113 groups = {"delete"}, dependsOnGroups = {"create", "read", "readList", "update"})
1114 public void deleteItem(String testName) throws Exception {
1116 if (logger.isDebugEnabled()) {
1117 logger.debug(testBanner(testName, CLASS_NAME));
1122 if(logger.isDebugEnabled()){
1123 logger.debug("parentcsid =" + knownResourceId +
1124 " itemcsid = " + knownItemResourceId);
1127 // Submit the request to the service and store the response.
1128 LocationAuthorityClient client = new LocationAuthorityClient();
1129 ClientResponse<Response> res = client.deleteItem(knownResourceId, knownItemResourceId);
1130 int statusCode = res.getStatus();
1132 // Check the status code of the response: does it match
1133 // the expected response(s)?
1134 if(logger.isDebugEnabled()){
1135 logger.debug(testName + ": status = " + statusCode);
1137 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1138 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1139 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1143 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
1146 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1147 groups = {"delete"}, dependsOnMethods = {"deleteItem"})
1148 public void delete(String testName) throws Exception {
1150 if (logger.isDebugEnabled()) {
1151 logger.debug(testBanner(testName, CLASS_NAME));
1156 if(logger.isDebugEnabled()){
1157 logger.debug("parentcsid =" + knownResourceId);
1160 // Submit the request to the service and store the response.
1161 LocationAuthorityClient client = new LocationAuthorityClient();
1162 ClientResponse<Response> res = client.delete(knownResourceId);
1163 int statusCode = res.getStatus();
1165 // Check the status code of the response: does it match
1166 // the expected response(s)?
1167 if(logger.isDebugEnabled()){
1168 logger.debug(testName + ": status = " + statusCode);
1170 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1171 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1172 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1177 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
1180 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1181 groups = {"delete"}, dependsOnMethods = {"delete"})
1182 public void deleteNonExistent(String testName) throws Exception {
1184 if (logger.isDebugEnabled()) {
1185 logger.debug(testBanner(testName, CLASS_NAME));
1188 setupDeleteNonExistent();
1190 // Submit the request to the service and store the response.
1191 LocationAuthorityClient client = new LocationAuthorityClient();
1192 ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
1193 int statusCode = res.getStatus();
1195 // Check the status code of the response: does it match
1196 // the expected response(s)?
1197 if(logger.isDebugEnabled()){
1198 logger.debug(testName + ": status = " + statusCode);
1200 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1201 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1202 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1206 * Delete non existent item.
1208 * @param testName the test name
1210 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1211 groups = {"delete"}, dependsOnMethods = {"deleteItem"})
1212 public void deleteNonExistentItem(String testName) {
1214 if (logger.isDebugEnabled()) {
1215 logger.debug(testBanner(testName, CLASS_NAME));
1218 setupDeleteNonExistent();
1220 // Submit the request to the service and store the response.
1221 LocationAuthorityClient client = new LocationAuthorityClient();
1222 ClientResponse<Response> res = client.deleteItem(knownResourceId, NON_EXISTENT_ID);
1223 int statusCode = res.getStatus();
1225 // Check the status code of the response: does it match
1226 // the expected response(s)?
1227 if(logger.isDebugEnabled()){
1228 logger.debug(testName + ": status = " + statusCode);
1230 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1231 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1232 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1235 // ---------------------------------------------------------------
1236 // Utility tests : tests of code used in tests above
1237 // ---------------------------------------------------------------
1239 * Tests the code for manually submitting data that is used by several
1240 * of the methods above.
1242 @Test(dependsOnMethods = {"create", "read"})
1243 public void testSubmitRequest() {
1245 // Expected status code: 200 OK
1246 final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
1248 // Submit the request to the service and store the response.
1249 String method = ServiceRequestType.READ.httpMethodName();
1250 String url = getResourceURL(knownResourceId);
1251 int statusCode = submitRequest(method, url);
1253 // Check the status code of the response: does it match
1254 // the expected response(s)?
1255 if(logger.isDebugEnabled()){
1256 logger.debug("testSubmitRequest: url=" + url +
1257 " status=" + statusCode);
1259 Assert.assertEquals(statusCode, EXPECTED_STATUS);
1264 * Test item submit request.
1266 @Test(dependsOnMethods = {"createItem", "readItem", "testSubmitRequest"})
1267 public void testItemSubmitRequest() {
1269 // Expected status code: 200 OK
1270 final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
1272 // Submit the request to the service and store the response.
1273 String method = ServiceRequestType.READ.httpMethodName();
1274 String url = getItemResourceURL(knownResourceId, knownItemResourceId);
1275 int statusCode = submitRequest(method, url);
1277 // Check the status code of the response: does it match
1278 // the expected response(s)?
1279 if(logger.isDebugEnabled()){
1280 logger.debug("testItemSubmitRequest: url=" + url +
1281 " status=" + statusCode);
1283 Assert.assertEquals(statusCode, EXPECTED_STATUS);
1287 // ---------------------------------------------------------------
1288 // Cleanup of resources created during testing
1289 // ---------------------------------------------------------------
1292 * Deletes all resources created by tests, after all tests have been run.
1294 * This cleanup method will always be run, even if one or more tests fail.
1295 * For this reason, it attempts to remove all resources created
1296 * at any point during testing, even if some of those resources
1297 * may be expected to be deleted by certain tests.
1300 @AfterClass(alwaysRun=true)
1301 public void cleanUp() {
1302 String noTest = System.getProperty("noTestCleanup");
1303 if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
1304 if (logger.isDebugEnabled()) {
1305 logger.debug("Skipping Cleanup phase ...");
1309 if (logger.isDebugEnabled()) {
1310 logger.debug("Cleaning up temporary resources created for testing ...");
1312 String parentResourceId;
1313 String itemResourceId;
1314 // Clean up contact resources.
1315 LocationAuthorityClient client = new LocationAuthorityClient();
1316 parentResourceId = knownResourceId;
1317 // Clean up item resources.
1318 for (Map.Entry<String, String> entry : allItemResourceIdsCreated.entrySet()) {
1319 itemResourceId = entry.getKey();
1320 parentResourceId = entry.getValue();
1321 // Note: Any non-success responses from the delete operation
1322 // below are ignored and not reported.
1323 ClientResponse<Response> res =
1324 client.deleteItem(parentResourceId, itemResourceId);
1326 // Clean up parent resources.
1327 for (String resourceId : allResourceIdsCreated) {
1328 // Note: Any non-success responses from the delete operation
1329 // below are ignored and not reported.
1330 ClientResponse<Response> res = client.delete(resourceId);
1334 // ---------------------------------------------------------------
1335 // Utility methods used by tests above
1336 // ---------------------------------------------------------------
1338 * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
1341 public String getServicePathComponent() {
1342 return SERVICE_PATH_COMPONENT;
1346 * Gets the item service path component.
1348 * @return the item service path component
1350 public String getItemServicePathComponent() {
1351 return ITEM_SERVICE_PATH_COMPONENT;
1355 * Returns the root URL for the item service.
1357 * This URL consists of a base URL for all services, followed by
1358 * a path component for the owning parent, followed by the
1359 * path component for the items.
1361 * @param parentResourceIdentifier An identifier (such as a UUID) for the
1362 * parent authority resource of the relevant item resource.
1364 * @return The root URL for the item service.
1366 protected String getItemServiceRootURL(String parentResourceIdentifier) {
1367 return getResourceURL(parentResourceIdentifier) + "/" + getItemServicePathComponent();
1371 * Returns the URL of a specific item resource managed by a service, and
1372 * designated by an identifier (such as a universally unique ID, or UUID).
1374 * @param parentResourceIdentifier An identifier (such as a UUID) for the
1375 * parent authority resource of the relevant item resource.
1377 * @param itemResourceIdentifier An identifier (such as a UUID) for an
1380 * @return The URL of a specific item resource managed by a service.
1382 protected String getItemResourceURL(String parentResourceIdentifier, String itemResourceIdentifier) {
1383 return getItemServiceRootURL(parentResourceIdentifier) + "/" + itemResourceIdentifier;