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";
79 final String TEST_NAME = "Shelf 1";
80 final String TEST_SHORTID = "shelf1";
81 final String TEST_CONDITION_NOTE = "Basically clean";
82 final String TEST_CONDITION_NOTE_DATE = "June 11, 1979";
83 final String TEST_SECURITY_NOTE = "Kind of safe";
84 // TODO Make loc type be a controlled vocab term.
85 final String TEST_LOCATION_TYPE = "Shelf";
86 // TODO Make status type be a controlled vocab term.
87 final String TEST_STATUS = "Approved";
89 /** The known resource id. */
90 private String knownResourceId = null;
91 private String knownResourceShortIdentifer = null;
92 private String knownResourceRefName = null;
93 private String knownLocationTypeRefName = null;
94 private String knownItemResourceId = null;
95 private String knownItemResourceShortIdentifer = null;
96 private String knownContactResourceId = null;
98 /** The n items to create in list. */
99 private int nItemsToCreateInList = 3;
101 /** The all resource ids created. */
102 private List<String> allResourceIdsCreated = new ArrayList<String>();
104 /** The all item resource ids created. */
105 private Map<String, String> allItemResourceIdsCreated =
106 new HashMap<String, String>();
108 protected void setKnownResource( String id, String shortIdentifer,
110 knownResourceId = id;
111 knownResourceShortIdentifer = shortIdentifer;
112 knownResourceRefName = refName;
115 protected void setKnownItemResource( String id, String shortIdentifer ) {
116 knownItemResourceId = id;
117 knownItemResourceShortIdentifer = shortIdentifer;
121 * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
124 protected CollectionSpaceClient getClientInstance() {
125 return new LocationAuthorityClient();
129 * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
132 protected AbstractCommonList getAbstractCommonList(
133 ClientResponse<AbstractCommonList> response) {
134 return response.getEntity(LocationsCommonList.class);
137 // ---------------------------------------------------------------
138 // CRUD tests : CREATE tests
139 // ---------------------------------------------------------------
142 * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
145 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
147 public void create(String testName) throws Exception {
149 if (logger.isDebugEnabled()) {
150 logger.debug(testBanner(testName, CLASS_NAME));
152 // Perform setup, such as initializing the type of service request
153 // (e.g. CREATE, DELETE), its valid and expected status codes, and
154 // its associated HTTP method name (e.g. POST, DELETE).
157 // Submit the request to the service and store the response.
158 LocationAuthorityClient client = new LocationAuthorityClient();
159 String shortId = createIdentifier();
160 String displayName = "displayName-" + shortId;
161 String baseRefName = LocationAuthorityClientUtils.createLocationAuthRefName(shortId, null);
162 MultipartOutput multipart =
163 LocationAuthorityClientUtils.createLocationAuthorityInstance(
164 displayName, shortId, client.getCommonPartName());
165 ClientResponse<Response> res = client.create(multipart);
166 int statusCode = res.getStatus();
168 // Check the status code of the response: does it match
169 // the expected response(s)?
172 // Does it fall within the set of valid status codes?
173 // Does it exactly match the expected status code?
174 if(logger.isDebugEnabled()){
175 logger.debug(testName + ": status = " + statusCode);
177 Assert.assertTrue(this.REQUEST_TYPE.isValidStatusCode(statusCode),
178 invalidStatusCodeMessage(this.REQUEST_TYPE, statusCode));
179 Assert.assertEquals(statusCode, this.EXPECTED_STATUS_CODE);
181 String newID = LocationAuthorityClientUtils.extractId(res);
182 // Store the ID returned from the first resource created
183 // for additional tests below.
184 if (knownResourceId == null){
185 setKnownResource( newID, shortId, baseRefName );
186 if (logger.isDebugEnabled()) {
187 logger.debug(testName + ": knownResourceId=" + knownResourceId);
190 // Store the IDs from every resource created by tests,
191 // so they can be deleted after tests have been run.
192 allResourceIdsCreated.add(newID);
198 * @param testName the test name
200 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
201 groups = {"create"}, dependsOnMethods = {"create"})
202 public void createItem(String testName) {
203 if(logger.isDebugEnabled()){
204 logger.debug(testBanner(testName, CLASS_NAME));
207 createItemInAuthority(knownResourceId, knownResourceRefName);
211 * Creates the item in authority.
213 * @param vcsid the vcsid
214 * @param authRefName the auth ref name
217 private String createItemInAuthority(String vcsid, String authRefName) {
219 final String testName = "createItemInAuthority("+vcsid+","+authRefName+")";
220 if(logger.isDebugEnabled()){
221 logger.debug(testBanner(testName, CLASS_NAME));
224 // Submit the request to the service and store the response.
225 LocationAuthorityClient client = new LocationAuthorityClient();
226 Map<String, String> shelf1Map = new HashMap<String,String>();
227 // TODO Make loc type and status be controlled vocabs.
228 shelf1Map.put(LocationJAXBSchema.NAME, TEST_NAME);
229 shelf1Map.put(LocationJAXBSchema.SHORT_IDENTIFIER, TEST_SHORTID);
230 shelf1Map.put(LocationJAXBSchema.CONDITION_NOTE, TEST_CONDITION_NOTE);
231 shelf1Map.put(LocationJAXBSchema.CONDITION_NOTE_DATE, TEST_CONDITION_NOTE_DATE);
232 shelf1Map.put(LocationJAXBSchema.SECURITY_NOTE, TEST_SECURITY_NOTE);
233 shelf1Map.put(LocationJAXBSchema.LOCATION_TYPE, TEST_LOCATION_TYPE);
234 shelf1Map.put(LocationJAXBSchema.STATUS, TEST_STATUS);
236 String newID = LocationAuthorityClientUtils.createItemInAuthority(vcsid,
237 authRefName, shelf1Map, client );
239 // Store the ID returned from the first item resource created
240 // for additional tests below.
241 if (knownItemResourceId == null){
242 setKnownItemResource(newID, TEST_SHORTID);
243 if (logger.isDebugEnabled()) {
244 logger.debug(testName + ": knownItemResourceId=" + newID);
248 // Store the IDs from any item resources created
249 // by tests, along with the IDs of their parents, so these items
250 // can be deleted after all tests have been run.
251 allItemResourceIdsCreated.put(newID, vcsid);
260 // Placeholders until the three tests below can be uncommented.
261 // See Issue CSPACE-401.
263 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
266 public void createWithEmptyEntityBody(String testName) throws Exception {
270 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
273 public void createWithMalformedXml(String testName) throws Exception {
277 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
280 public void createWithWrongXmlSchema(String testName) throws Exception {
284 // ---------------------------------------------------------------
285 // CRUD tests : CREATE LIST tests
286 // ---------------------------------------------------------------
289 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
292 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
293 groups = {"createList"}, dependsOnGroups = {"create"})
294 public void createList(String testName) throws Exception {
295 for (int i = 0; i < nItemsToCreateInList; i++) {
301 * Creates the item list.
303 * @param testName the test name
304 * @throws Exception the exception
306 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
307 groups = {"createList"}, dependsOnMethods = {"createList"})
308 public void createItemList(String testName) throws Exception {
309 // Add items to the initially-created, known parent record.
310 for (int j = 0; j < nItemsToCreateInList; j++) {
311 createItem(testName);
315 // ---------------------------------------------------------------
316 // CRUD tests : READ tests
317 // ---------------------------------------------------------------
320 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
323 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
324 groups = {"read"}, dependsOnGroups = {"create"})
325 public void read(String testName) throws Exception {
327 if (logger.isDebugEnabled()) {
328 logger.debug(testBanner(testName, CLASS_NAME));
333 // Submit the request to the service and store the response.
334 LocationAuthorityClient client = new LocationAuthorityClient();
335 ClientResponse<MultipartInput> res = client.read(knownResourceId);
336 int statusCode = res.getStatus();
338 // Check the status code of the response: does it match
339 // the expected response(s)?
340 if(logger.isDebugEnabled()){
341 logger.debug(testName + ": status = " + statusCode);
343 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
344 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
345 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
346 //FIXME: remove the following try catch once Aron fixes signatures
348 MultipartInput input = (MultipartInput) res.getEntity();
349 LocationauthoritiesCommon locationAuthority = (LocationauthoritiesCommon) extractPart(input,
350 client.getCommonPartName(), LocationauthoritiesCommon.class);
351 Assert.assertNotNull(locationAuthority);
352 } catch (Exception e) {
353 throw new RuntimeException(e);
360 * @param testName the test name
361 * @throws Exception the exception
363 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
364 groups = {"read"}, dependsOnGroups = {"create"})
365 public void readByName(String testName) throws Exception {
367 if (logger.isDebugEnabled()) {
368 logger.debug(testBanner(testName+"("+knownResourceShortIdentifer+")", CLASS_NAME));
373 // Submit the request to the service and store the response.
374 LocationAuthorityClient client = new LocationAuthorityClient();
375 ClientResponse<MultipartInput> res = client.readByName(knownResourceShortIdentifer);
376 int statusCode = res.getStatus();
378 // Check the status code of the response: does it match
379 // the expected response(s)?
380 if(logger.isDebugEnabled()){
381 logger.debug(testName + ": status = " + statusCode);
383 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
384 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
385 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
386 //FIXME: remove the following try catch once Aron fixes signatures
388 MultipartInput input = (MultipartInput) res.getEntity();
389 LocationauthoritiesCommon locationAuthority = (LocationauthoritiesCommon) extractPart(input,
390 client.getCommonPartName(), LocationauthoritiesCommon.class);
391 Assert.assertNotNull(locationAuthority);
392 } catch (Exception e) {
393 throw new RuntimeException(e);
401 * @param testName the test name
402 * @throws Exception the exception
404 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
405 groups = {"read"}, dependsOnMethods = {"read"})
406 public void readItem(String testName) throws Exception {
408 if (logger.isDebugEnabled()) {
409 logger.debug(testBanner(testName, CLASS_NAME));
414 // Submit the request to the service and store the response.
415 LocationAuthorityClient client = new LocationAuthorityClient();
416 ClientResponse<MultipartInput> res = client.readItem(knownResourceId, knownItemResourceId);
417 int statusCode = res.getStatus();
419 // Check the status code of the response: does it match
420 // the expected response(s)?
421 if(logger.isDebugEnabled()){
422 logger.debug(testName + ": status = " + statusCode);
424 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
425 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
426 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
428 // Check whether we've received a location.
429 MultipartInput input = (MultipartInput) res.getEntity();
430 LocationsCommon location = (LocationsCommon) extractPart(input,
431 client.getItemCommonPartName(), LocationsCommon.class);
432 Assert.assertNotNull(location);
433 boolean showFull = true;
434 if(showFull && logger.isDebugEnabled()){
435 logger.debug(testName + ": returned payload:");
436 logger.debug(objectAsXmlString(location, LocationsCommon.class));
438 Assert.assertEquals(location.getInAuthority(), knownResourceId);
443 * Verify item display name.
445 * @param testName the test name
446 * @throws Exception the exception
448 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
449 dependsOnMethods = {"readItem", "updateItem"})
450 public void verifyItemDisplayName(String testName) throws Exception {
452 if (logger.isDebugEnabled()) {
453 logger.debug(testBanner(testName, CLASS_NAME));
458 // Submit the request to the service and store the response.
459 LocationAuthorityClient client = new LocationAuthorityClient();
460 ClientResponse<MultipartInput> res = client.readItem(knownResourceId, knownItemResourceId);
461 int statusCode = res.getStatus();
463 // Check the status code of the response: does it match
464 // the expected response(s)?
465 if(logger.isDebugEnabled()){
466 logger.debug(testName + ": status = " + statusCode);
468 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
469 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
470 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
472 // Check whether location has expected displayName.
473 MultipartInput input = (MultipartInput) res.getEntity();
474 LocationsCommon location = (LocationsCommon) extractPart(input,
475 client.getItemCommonPartName(), LocationsCommon.class);
476 Assert.assertNotNull(location);
477 String displayName = location.getDisplayName();
478 // Make sure displayName matches computed form
479 String expectedDisplayName =
480 LocationAuthorityClientUtils.prepareDefaultDisplayName(TEST_NAME);
481 Assert.assertNotNull(displayName, expectedDisplayName);
483 // Update the shortName and verify the computed name is updated.
484 location.setCsid(null);
485 location.setDisplayNameComputed(true);
486 location.setName("updated-" + TEST_NAME);
487 expectedDisplayName =
488 LocationAuthorityClientUtils.prepareDefaultDisplayName("updated-" + TEST_NAME);
490 // Submit the updated resource to the service and store the response.
491 MultipartOutput output = new MultipartOutput();
492 OutputPart commonPart = output.addPart(location, MediaType.APPLICATION_XML_TYPE);
493 commonPart.getHeaders().add("label", client.getItemCommonPartName());
494 res = client.updateItem(knownResourceId, knownItemResourceId, output);
495 statusCode = res.getStatus();
497 // Check the status code of the response: does it match the expected response(s)?
498 if(logger.isDebugEnabled()){
499 logger.debug("updateItem: status = " + statusCode);
501 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
502 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
503 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
505 // Retrieve the updated resource and verify that its contents exist.
506 input = (MultipartInput) res.getEntity();
507 LocationsCommon updatedLocation =
508 (LocationsCommon) extractPart(input,
509 client.getItemCommonPartName(), LocationsCommon.class);
510 Assert.assertNotNull(updatedLocation);
512 // Verify that the updated resource received the correct data.
513 Assert.assertEquals(updatedLocation.getName(), location.getName(),
514 "Updated ForeName in Location did not match submitted data.");
515 // Verify that the updated resource computes the right displayName.
516 Assert.assertEquals(updatedLocation.getDisplayName(), expectedDisplayName,
517 "Updated ForeName in Location not reflected in computed DisplayName.");
519 // Now Update the displayName, not computed and verify the computed name is overriden.
520 location.setDisplayNameComputed(false);
521 expectedDisplayName = "TestName";
522 location.setDisplayName(expectedDisplayName);
524 // Submit the updated resource to the service and store the response.
525 output = new MultipartOutput();
526 commonPart = output.addPart(location, MediaType.APPLICATION_XML_TYPE);
527 commonPart.getHeaders().add("label", client.getItemCommonPartName());
528 res = client.updateItem(knownResourceId, knownItemResourceId, output);
529 statusCode = res.getStatus();
531 // Check the status code of the response: does it match the expected response(s)?
532 if(logger.isDebugEnabled()){
533 logger.debug("updateItem: status = " + statusCode);
535 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
536 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
537 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
539 // Retrieve the updated resource and verify that its contents exist.
540 input = (MultipartInput) res.getEntity();
542 (LocationsCommon) extractPart(input,
543 client.getItemCommonPartName(), LocationsCommon.class);
544 Assert.assertNotNull(updatedLocation);
546 // Verify that the updated resource received the correct data.
547 Assert.assertEquals(updatedLocation.isDisplayNameComputed(), false,
548 "Updated displayNameComputed in Location did not match submitted data.");
549 // Verify that the updated resource computes the right displayName.
550 Assert.assertEquals(updatedLocation.getDisplayName(),
552 "Updated DisplayName (not computed) in Location not stored.");
556 * Verify illegal item display name.
558 * @param testName the test name
559 * @throws Exception the exception
561 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
562 dependsOnMethods = {"verifyItemDisplayName"})
563 public void verifyIllegalItemDisplayName(String testName) throws Exception {
565 if (logger.isDebugEnabled()) {
566 logger.debug(testBanner(testName, CLASS_NAME));
569 // FIXME: create a setup configuration for this operation.
570 setupUpdateWithWrongXmlSchema();
572 // Submit the request to the service and store the response.
573 LocationAuthorityClient client = new LocationAuthorityClient();
574 ClientResponse<MultipartInput> res = client.readItem(knownResourceId, knownItemResourceId);
575 int statusCode = res.getStatus();
577 // Check the status code of the response: does it match
578 // the expected response(s)?
579 if(logger.isDebugEnabled()){
580 logger.debug(testName + ": status = " + statusCode);
582 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
583 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
584 Assert.assertEquals(statusCode, Response.Status.OK.getStatusCode());
586 // Check whether Location has expected displayName.
587 MultipartInput input = (MultipartInput) res.getEntity();
588 LocationsCommon location = (LocationsCommon) extractPart(input,
589 client.getItemCommonPartName(), LocationsCommon.class);
590 Assert.assertNotNull(location);
591 // Try to Update with computed false and no displayName
592 location.setDisplayNameComputed(false);
593 location.setDisplayName(null);
595 // Submit the updated resource to the service and store the response.
596 MultipartOutput output = new MultipartOutput();
597 OutputPart commonPart = output.addPart(location, MediaType.APPLICATION_XML_TYPE);
598 commonPart.getHeaders().add("label", client.getItemCommonPartName());
599 res = client.updateItem(knownResourceId, knownItemResourceId, output);
600 statusCode = res.getStatus();
602 // Check the status code of the response: does it match the expected response(s)?
603 if(logger.isDebugEnabled()){
604 logger.debug("updateItem: status = " + statusCode);
606 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
607 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
608 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
614 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
617 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
618 groups = {"read"}, dependsOnMethods = {"read"})
619 public void readNonExistent(String testName) {
621 if (logger.isDebugEnabled()) {
622 logger.debug(testBanner(testName, CLASS_NAME));
625 setupReadNonExistent();
627 // Submit the request to the service and store the response.
628 LocationAuthorityClient client = new LocationAuthorityClient();
629 ClientResponse<MultipartInput> res = client.read(NON_EXISTENT_ID);
630 int statusCode = res.getStatus();
632 // Check the status code of the response: does it match
633 // the expected response(s)?
634 if(logger.isDebugEnabled()){
635 logger.debug(testName + ": status = " + statusCode);
637 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
638 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
639 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
643 * Read item non existent.
645 * @param testName the test name
647 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
648 groups = {"read"}, dependsOnMethods = {"readItem"})
649 public void readItemNonExistent(String testName) {
651 if (logger.isDebugEnabled()) {
652 logger.debug(testBanner(testName, CLASS_NAME));
655 setupReadNonExistent();
657 // Submit the request to the service and store the response.
658 LocationAuthorityClient client = new LocationAuthorityClient();
659 ClientResponse<MultipartInput> res = client.readItem(knownResourceId, NON_EXISTENT_ID);
660 int statusCode = res.getStatus();
662 // Check the status code of the response: does it match
663 // the expected response(s)?
664 if(logger.isDebugEnabled()){
665 logger.debug(testName + ": status = " + statusCode);
667 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
668 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
669 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
673 // ---------------------------------------------------------------
674 // CRUD tests : READ_LIST tests
675 // ---------------------------------------------------------------
679 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
682 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
683 groups = {"readList"}, dependsOnGroups = {"createList", "read"})
684 public void readList(String testName) throws Exception {
686 if (logger.isDebugEnabled()) {
687 logger.debug(testBanner(testName, CLASS_NAME));
692 // Submit the request to the service and store the response.
693 LocationAuthorityClient client = new LocationAuthorityClient();
694 ClientResponse<LocationauthoritiesCommonList> res = client.readList();
695 LocationauthoritiesCommonList list = res.getEntity();
696 int statusCode = res.getStatus();
698 // Check the status code of the response: does it match
699 // the expected response(s)?
700 if(logger.isDebugEnabled()){
701 logger.debug(testName + ": status = " + statusCode);
703 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
704 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
705 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
707 // Optionally output additional data about list members for debugging.
708 boolean iterateThroughList = false;
709 if (iterateThroughList && logger.isDebugEnabled()) {
710 List<LocationauthoritiesCommonList.LocationauthorityListItem> items =
711 list.getLocationauthorityListItem();
713 for (LocationauthoritiesCommonList.LocationauthorityListItem item : items) {
714 String csid = item.getCsid();
715 logger.debug(testName + ": list-item[" + i + "] csid=" +
717 logger.debug(testName + ": list-item[" + i + "] displayName=" +
718 item.getDisplayName());
719 logger.debug(testName + ": list-item[" + i + "] URI=" +
721 readItemList(csid, null);
730 @Test(groups = {"readList"}, dependsOnMethods = {"readList"})
731 public void readItemList() {
732 String testName = "readItemList";
733 if (logger.isDebugEnabled()) {
734 logger.debug(testBanner(testName, CLASS_NAME));
736 readItemList(knownResourceId, null);
740 * Read item list by authority name.
742 @Test(groups = {"readList"}, dependsOnMethods = {"readItemList"})
743 public void readItemListByAuthorityName() {
744 String testName = "readItemListByAuthorityName";
745 if (logger.isDebugEnabled()) {
746 logger.debug(testBanner(testName, CLASS_NAME));
748 readItemList(null, knownResourceShortIdentifer);
754 * @param vcsid the vcsid
755 * @param name the name
757 private void readItemList(String vcsid, String shortId) {
759 String testName = "readItemList";
764 // Submit the request to the service and store the response.
765 LocationAuthorityClient client = new LocationAuthorityClient();
766 ClientResponse<LocationsCommonList> res = null;
768 res = client.readItemList(vcsid);
769 } else if(shortId!= null) {
770 res = client.readItemListForNamedAuthority(shortId);
772 Assert.fail("readItemList passed null csid and name!");
774 LocationsCommonList list = res.getEntity();
775 int statusCode = res.getStatus();
777 // Check the status code of the response: does it match
778 // the expected response(s)?
779 if(logger.isDebugEnabled()){
780 logger.debug(testName + ": status = " + statusCode);
782 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
783 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
784 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
786 List<LocationsCommonList.LocationListItem> items =
787 list.getLocationListItem();
788 int nItemsReturned = items.size();
789 // There will be one item created, associated with a
790 // known parent resource, by the createItem test.
792 // In addition, there will be 'nItemsToCreateInList'
793 // additional items created by the createItemList test,
794 // all associated with the same parent resource.
795 int nExpectedItems = nItemsToCreateInList + 1;
796 if(logger.isDebugEnabled()){
797 logger.debug(testName + ": Expected "
798 + nExpectedItems +" items; got: "+nItemsReturned);
800 Assert.assertEquals(nItemsReturned, nExpectedItems);
803 for (LocationsCommonList.LocationListItem item : items) {
804 Assert.assertTrue((null != item.getRefName()), "Item refName is null!");
805 Assert.assertTrue((null != item.getDisplayName()), "Item displayName is null!");
806 // Optionally output additional data about list members for debugging.
807 boolean showDetails = true;
808 if (showDetails && logger.isDebugEnabled()) {
809 logger.debug(" " + testName + ": list-item[" + i + "] csid=" +
811 logger.debug(" " + testName + ": list-item[" + i + "] refName=" +
813 logger.debug(" " + testName + ": list-item[" + i + "] displayName=" +
814 item.getDisplayName());
815 logger.debug(" " + testName + ": list-item[" + i + "] URI=" +
826 // ---------------------------------------------------------------
827 // CRUD tests : UPDATE tests
828 // ---------------------------------------------------------------
831 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
834 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
835 groups = {"update"}, dependsOnGroups = {"read", "readList"})
836 public void update(String testName) throws Exception {
838 if (logger.isDebugEnabled()) {
839 logger.debug(testBanner(testName, CLASS_NAME));
844 // Retrieve the contents of a resource to update.
845 LocationAuthorityClient client = new LocationAuthorityClient();
846 ClientResponse<MultipartInput> res =
847 client.read(knownResourceId);
848 if(logger.isDebugEnabled()){
849 logger.debug(testName + ": read status = " + res.getStatus());
851 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
853 if(logger.isDebugEnabled()){
854 logger.debug("got LocationAuthority to update with ID: " + knownResourceId);
856 MultipartInput input = (MultipartInput) res.getEntity();
857 LocationauthoritiesCommon locationAuthority = (LocationauthoritiesCommon) extractPart(input,
858 client.getCommonPartName(), LocationauthoritiesCommon.class);
859 Assert.assertNotNull(locationAuthority);
861 // Update the contents of this resource.
862 locationAuthority.setDisplayName("updated-" + locationAuthority.getDisplayName());
863 locationAuthority.setVocabType("updated-" + locationAuthority.getVocabType());
864 if(logger.isDebugEnabled()){
865 logger.debug("to be updated LocationAuthority");
866 logger.debug(objectAsXmlString(locationAuthority, LocationauthoritiesCommon.class));
869 // Submit the updated resource to the service and store the response.
870 MultipartOutput output = new MultipartOutput();
871 OutputPart commonPart = output.addPart(locationAuthority, MediaType.APPLICATION_XML_TYPE);
872 commonPart.getHeaders().add("label", client.getCommonPartName());
873 res = client.update(knownResourceId, output);
874 int statusCode = res.getStatus();
876 // Check the status code of the response: does it match the expected response(s)?
877 if(logger.isDebugEnabled()){
878 logger.debug(testName + ": status = " + statusCode);
880 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
881 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
882 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
884 // Retrieve the updated resource and verify that its contents exist.
885 input = (MultipartInput) res.getEntity();
886 LocationauthoritiesCommon updatedLocationAuthority =
887 (LocationauthoritiesCommon) extractPart(input,
888 client.getCommonPartName(), LocationauthoritiesCommon.class);
889 Assert.assertNotNull(updatedLocationAuthority);
891 // Verify that the updated resource received the correct data.
892 Assert.assertEquals(updatedLocationAuthority.getDisplayName(),
893 locationAuthority.getDisplayName(),
894 "Data in updated object did not match submitted data.");
900 * @param testName the test name
901 * @throws Exception the exception
903 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
904 groups = {"update"}, dependsOnMethods = {"update"})
905 public void updateItem(String testName) throws Exception {
907 if (logger.isDebugEnabled()) {
908 logger.debug(testBanner(testName, CLASS_NAME));
913 // Retrieve the contents of a resource to update.
914 LocationAuthorityClient client = new LocationAuthorityClient();
915 ClientResponse<MultipartInput> res =
916 client.readItem(knownResourceId, knownItemResourceId);
917 if(logger.isDebugEnabled()){
918 logger.debug(testName + ": read status = " + res.getStatus());
920 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
922 if(logger.isDebugEnabled()){
923 logger.debug("got Location to update with ID: " +
924 knownItemResourceId +
925 " in LocationAuthority: " + knownResourceId );
927 MultipartInput input = (MultipartInput) res.getEntity();
928 LocationsCommon location = (LocationsCommon) extractPart(input,
929 client.getItemCommonPartName(), LocationsCommon.class);
930 Assert.assertNotNull(location);
932 // Update the contents of this resource.
933 location.setCsid(null);
934 location.setName("updated-" + location.getName());
935 if(logger.isDebugEnabled()){
936 logger.debug("to be updated Location");
937 logger.debug(objectAsXmlString(location,
938 LocationsCommon.class));
941 // Submit the updated resource to the service and store the response.
942 MultipartOutput output = new MultipartOutput();
943 OutputPart commonPart = output.addPart(location, MediaType.APPLICATION_XML_TYPE);
944 commonPart.getHeaders().add("label", client.getItemCommonPartName());
945 res = client.updateItem(knownResourceId, knownItemResourceId, output);
946 int statusCode = res.getStatus();
948 // Check the status code of the response: does it match the expected response(s)?
949 if(logger.isDebugEnabled()){
950 logger.debug(testName + ": status = " + statusCode);
952 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
953 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
954 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
956 // Retrieve the updated resource and verify that its contents exist.
957 input = (MultipartInput) res.getEntity();
958 LocationsCommon updatedLocation =
959 (LocationsCommon) extractPart(input,
960 client.getItemCommonPartName(), LocationsCommon.class);
961 Assert.assertNotNull(updatedLocation);
963 // Verify that the updated resource received the correct data.
964 Assert.assertEquals(updatedLocation.getName(), location.getName(),
965 "Data in updated Location did not match submitted data.");
969 // Placeholders until the three tests below can be uncommented.
970 // See Issue CSPACE-401.
972 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
975 public void updateWithEmptyEntityBody(String testName) throws Exception {
979 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
982 public void updateWithMalformedXml(String testName) throws Exception {
986 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
989 public void updateWithWrongXmlSchema(String testName) throws Exception {
994 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
997 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
998 groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
999 public void updateNonExistent(String testName) throws Exception {
1001 if (logger.isDebugEnabled()) {
1002 logger.debug(testBanner(testName, CLASS_NAME));
1005 setupUpdateNonExistent();
1007 // Submit the request to the service and store the response.
1008 // Note: The ID(s) used when creating the request payload may be arbitrary.
1009 // The only relevant ID may be the one used in update(), below.
1010 LocationAuthorityClient client = new LocationAuthorityClient();
1011 String displayName = "displayName-NON_EXISTENT_ID";
1012 MultipartOutput multipart = LocationAuthorityClientUtils.createLocationAuthorityInstance(
1013 displayName, "nonEx", client.getCommonPartName());
1014 ClientResponse<MultipartInput> res =
1015 client.update(NON_EXISTENT_ID, multipart);
1016 int statusCode = res.getStatus();
1018 // Check the status code of the response: does it match
1019 // the expected response(s)?
1020 if(logger.isDebugEnabled()){
1021 logger.debug(testName + ": status = " + statusCode);
1023 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1024 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1025 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1029 * Update non existent item.
1031 * @param testName the test name
1032 * @throws Exception the exception
1034 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1035 groups = {"update"}, dependsOnMethods = {"updateItem", "testItemSubmitRequest"})
1036 public void updateNonExistentItem(String testName) throws Exception {
1038 if (logger.isDebugEnabled()) {
1039 logger.debug(testBanner(testName, CLASS_NAME));
1042 setupUpdateNonExistent();
1044 // Submit the request to the service and store the response.
1045 // Note: The ID used in this 'create' call may be arbitrary.
1046 // The only relevant ID may be the one used in update(), below.
1047 LocationAuthorityClient client = new LocationAuthorityClient();
1048 Map<String, String> nonexMap = new HashMap<String,String>();
1049 nonexMap.put(LocationJAXBSchema.NAME, TEST_NAME);
1050 nonexMap.put(LocationJAXBSchema.SHORT_IDENTIFIER, "nonEx");
1051 nonexMap.put(LocationJAXBSchema.LOCATION_TYPE, TEST_LOCATION_TYPE);
1052 nonexMap.put(LocationJAXBSchema.STATUS, TEST_STATUS);
1053 MultipartOutput multipart =
1054 LocationAuthorityClientUtils.createLocationInstance(NON_EXISTENT_ID,
1055 LocationAuthorityClientUtils.createLocationRefName(knownResourceRefName, "nonEx", "Non Existent"),
1056 nonexMap, client.getItemCommonPartName() );
1057 ClientResponse<MultipartInput> res =
1058 client.updateItem(knownResourceId, NON_EXISTENT_ID, multipart);
1059 int statusCode = res.getStatus();
1061 // Check the status code of the response: does it match
1062 // the expected response(s)?
1063 if(logger.isDebugEnabled()){
1064 logger.debug(testName + ": status = " + statusCode);
1066 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1067 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1068 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1071 // ---------------------------------------------------------------
1072 // CRUD tests : DELETE tests
1073 // ---------------------------------------------------------------
1076 // Note: delete sub-resources in ascending hierarchical order,
1077 // before deleting their parents.
1082 * @param testName the test name
1083 * @throws Exception the exception
1085 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1086 //groups = {"delete"}, dependsOnGroups = {"create", "read", "readList", "readListByPartialTerm", "update"})
1087 groups = {"delete"}, dependsOnGroups = {"create", "read", "readList", "update"})
1088 public void deleteItem(String testName) throws Exception {
1090 if (logger.isDebugEnabled()) {
1091 logger.debug(testBanner(testName, CLASS_NAME));
1096 if(logger.isDebugEnabled()){
1097 logger.debug("parentcsid =" + knownResourceId +
1098 " itemcsid = " + knownItemResourceId);
1101 // Submit the request to the service and store the response.
1102 LocationAuthorityClient client = new LocationAuthorityClient();
1103 ClientResponse<Response> res = client.deleteItem(knownResourceId, knownItemResourceId);
1104 int statusCode = res.getStatus();
1106 // Check the status code of the response: does it match
1107 // the expected response(s)?
1108 if(logger.isDebugEnabled()){
1109 logger.debug(testName + ": status = " + statusCode);
1111 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1112 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1113 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1117 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
1120 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1121 groups = {"delete"}, dependsOnMethods = {"deleteItem"})
1122 public void delete(String testName) throws Exception {
1124 if (logger.isDebugEnabled()) {
1125 logger.debug(testBanner(testName, CLASS_NAME));
1130 if(logger.isDebugEnabled()){
1131 logger.debug("parentcsid =" + knownResourceId);
1134 // Submit the request to the service and store the response.
1135 LocationAuthorityClient client = new LocationAuthorityClient();
1136 ClientResponse<Response> res = client.delete(knownResourceId);
1137 int statusCode = res.getStatus();
1139 // Check the status code of the response: does it match
1140 // the expected response(s)?
1141 if(logger.isDebugEnabled()){
1142 logger.debug(testName + ": status = " + statusCode);
1144 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1145 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1146 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1151 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
1154 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1155 groups = {"delete"}, dependsOnMethods = {"delete"})
1156 public void deleteNonExistent(String testName) throws Exception {
1158 if (logger.isDebugEnabled()) {
1159 logger.debug(testBanner(testName, CLASS_NAME));
1162 setupDeleteNonExistent();
1164 // Submit the request to the service and store the response.
1165 LocationAuthorityClient client = new LocationAuthorityClient();
1166 ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
1167 int statusCode = res.getStatus();
1169 // Check the status code of the response: does it match
1170 // the expected response(s)?
1171 if(logger.isDebugEnabled()){
1172 logger.debug(testName + ": status = " + statusCode);
1174 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1175 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1176 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1180 * Delete non existent item.
1182 * @param testName the test name
1184 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1185 groups = {"delete"}, dependsOnMethods = {"deleteItem"})
1186 public void deleteNonExistentItem(String testName) {
1188 if (logger.isDebugEnabled()) {
1189 logger.debug(testBanner(testName, CLASS_NAME));
1192 setupDeleteNonExistent();
1194 // Submit the request to the service and store the response.
1195 LocationAuthorityClient client = new LocationAuthorityClient();
1196 ClientResponse<Response> res = client.deleteItem(knownResourceId, NON_EXISTENT_ID);
1197 int statusCode = res.getStatus();
1199 // Check the status code of the response: does it match
1200 // the expected response(s)?
1201 if(logger.isDebugEnabled()){
1202 logger.debug(testName + ": status = " + statusCode);
1204 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1205 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1206 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1209 // ---------------------------------------------------------------
1210 // Utility tests : tests of code used in tests above
1211 // ---------------------------------------------------------------
1213 * Tests the code for manually submitting data that is used by several
1214 * of the methods above.
1216 @Test(dependsOnMethods = {"create", "read"})
1217 public void testSubmitRequest() {
1219 // Expected status code: 200 OK
1220 final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
1222 // Submit the request to the service and store the response.
1223 String method = ServiceRequestType.READ.httpMethodName();
1224 String url = getResourceURL(knownResourceId);
1225 int statusCode = submitRequest(method, url);
1227 // Check the status code of the response: does it match
1228 // the expected response(s)?
1229 if(logger.isDebugEnabled()){
1230 logger.debug("testSubmitRequest: url=" + url +
1231 " status=" + statusCode);
1233 Assert.assertEquals(statusCode, EXPECTED_STATUS);
1238 * Test item submit request.
1240 @Test(dependsOnMethods = {"createItem", "readItem", "testSubmitRequest"})
1241 public void testItemSubmitRequest() {
1243 // Expected status code: 200 OK
1244 final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
1246 // Submit the request to the service and store the response.
1247 String method = ServiceRequestType.READ.httpMethodName();
1248 String url = getItemResourceURL(knownResourceId, knownItemResourceId);
1249 int statusCode = submitRequest(method, url);
1251 // Check the status code of the response: does it match
1252 // the expected response(s)?
1253 if(logger.isDebugEnabled()){
1254 logger.debug("testItemSubmitRequest: url=" + url +
1255 " status=" + statusCode);
1257 Assert.assertEquals(statusCode, EXPECTED_STATUS);
1261 // ---------------------------------------------------------------
1262 // Cleanup of resources created during testing
1263 // ---------------------------------------------------------------
1266 * Deletes all resources created by tests, after all tests have been run.
1268 * This cleanup method will always be run, even if one or more tests fail.
1269 * For this reason, it attempts to remove all resources created
1270 * at any point during testing, even if some of those resources
1271 * may be expected to be deleted by certain tests.
1274 @AfterClass(alwaysRun=true)
1275 public void cleanUp() {
1276 String noTest = System.getProperty("noTestCleanup");
1277 if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
1278 if (logger.isDebugEnabled()) {
1279 logger.debug("Skipping Cleanup phase ...");
1283 if (logger.isDebugEnabled()) {
1284 logger.debug("Cleaning up temporary resources created for testing ...");
1286 String parentResourceId;
1287 String itemResourceId;
1288 // Clean up contact resources.
1289 LocationAuthorityClient client = new LocationAuthorityClient();
1290 parentResourceId = knownResourceId;
1291 // Clean up item resources.
1292 for (Map.Entry<String, String> entry : allItemResourceIdsCreated.entrySet()) {
1293 itemResourceId = entry.getKey();
1294 parentResourceId = entry.getValue();
1295 // Note: Any non-success responses from the delete operation
1296 // below are ignored and not reported.
1297 ClientResponse<Response> res =
1298 client.deleteItem(parentResourceId, itemResourceId);
1300 // Clean up parent resources.
1301 for (String resourceId : allResourceIdsCreated) {
1302 // Note: Any non-success responses from the delete operation
1303 // below are ignored and not reported.
1304 ClientResponse<Response> res = client.delete(resourceId);
1308 // ---------------------------------------------------------------
1309 // Utility methods used by tests above
1310 // ---------------------------------------------------------------
1312 * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
1315 public String getServicePathComponent() {
1316 return SERVICE_PATH_COMPONENT;
1320 * Gets the item service path component.
1322 * @return the item service path component
1324 public String getItemServicePathComponent() {
1325 return ITEM_SERVICE_PATH_COMPONENT;
1329 * Returns the root URL for the item service.
1331 * This URL consists of a base URL for all services, followed by
1332 * a path component for the owning parent, followed by the
1333 * path component for the items.
1335 * @param parentResourceIdentifier An identifier (such as a UUID) for the
1336 * parent authority resource of the relevant item resource.
1338 * @return The root URL for the item service.
1340 protected String getItemServiceRootURL(String parentResourceIdentifier) {
1341 return getResourceURL(parentResourceIdentifier) + "/" + getItemServicePathComponent();
1345 * Returns the URL of a specific item resource managed by a service, and
1346 * designated by an identifier (such as a universally unique ID, or UUID).
1348 * @param parentResourceIdentifier An identifier (such as a UUID) for the
1349 * parent authority resource of the relevant item resource.
1351 * @param itemResourceIdentifier An identifier (such as a UUID) for an
1354 * @return The URL of a specific item resource managed by a service.
1356 protected String getItemResourceURL(String parentResourceIdentifier, String itemResourceIdentifier) {
1357 return getItemServiceRootURL(parentResourceIdentifier) + "/" + itemResourceIdentifier;