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.HashMap;
26 import java.util.List;
28 import javax.ws.rs.core.MediaType;
29 import javax.ws.rs.core.Response;
31 import org.collectionspace.services.PersonJAXBSchema;
32 import org.collectionspace.services.client.CollectionSpaceClient;
33 import org.collectionspace.services.client.ContactClient;
34 import org.collectionspace.services.client.ContactClientUtils;
35 import org.collectionspace.services.contact.ContactsCommon;
36 import org.collectionspace.services.contact.ContactsCommonList;
37 import org.collectionspace.services.client.PersonAuthorityClient;
38 import org.collectionspace.services.client.PersonAuthorityClientUtils;
39 import org.collectionspace.services.jaxb.AbstractCommonList;
40 import org.collectionspace.services.person.PersonauthoritiesCommon;
41 import org.collectionspace.services.person.PersonauthoritiesCommonList;
42 import org.collectionspace.services.person.PersonsCommon;
43 import org.collectionspace.services.person.PersonsCommonList;
44 import org.jboss.resteasy.client.ClientResponse;
45 import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
46 import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
47 import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
48 import org.slf4j.Logger;
49 import org.slf4j.LoggerFactory;
50 import org.testng.Assert;
51 import org.testng.annotations.AfterClass;
52 import org.testng.annotations.Test;
55 * PersonAuthorityServiceTest, carries out tests against a
56 * deployed and running PersonAuthority Service.
58 * $LastChangedRevision: 753 $
59 * $LastChangedDate: 2009-09-23 11:03:36 -0700 (Wed, 23 Sep 2009) $
61 public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
64 private final Logger logger =
65 LoggerFactory.getLogger(PersonAuthorityServiceTest.class);
67 // Instance variables specific to this test.
68 /** The SERVIC e_ pat h_ component. */
69 final String SERVICE_PATH_COMPONENT = "personauthorities";
71 /** The ITE m_ servic e_ pat h_ component. */
72 final String ITEM_SERVICE_PATH_COMPONENT = "items";
74 /** The CONTAC t_ servic e_ pat h_ component. */
75 final String CONTACT_SERVICE_PATH_COMPONENT = "contacts";
77 /** The TES t_ for e_ name. */
78 final String TEST_FORE_NAME = "John";
80 /** The TES t_ middl e_ name. */
81 final String TEST_MIDDLE_NAME = null;
83 /** The TES t_ su r_ name. */
84 final String TEST_SUR_NAME = "Wayne";
86 /** The TES t_ birt h_ date. */
87 final String TEST_BIRTH_DATE = "May 26, 1907";
89 /** The TES t_ deat h_ date. */
90 final String TEST_DEATH_DATE = "June 11, 1979";
92 /** The known resource id. */
93 private String knownResourceId = null;
95 /** The known resource display name. */
96 private String knownResourceDisplayName = null;
98 /** The known resource ref name. */
99 private String knownResourceRefName = null;
101 /** The known item resource id. */
102 private String knownItemResourceId = null;
104 /** The known contact resource id. */
105 private String knownContactResourceId = null;
107 /** The n items to create in list. */
108 private int nItemsToCreateInList = 3;
110 /** The all item resource ids created. */
111 private Map<String, String> allItemResourceIdsCreated =
112 new HashMap<String, String>();
114 /** The all contact resource ids created. */
115 private Map<String, String> allContactResourceIdsCreated =
116 new HashMap<String, String>();
119 * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
122 protected CollectionSpaceClient getClientInstance() {
123 return new PersonAuthorityClient();
127 * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
130 protected AbstractCommonList getAbstractCommonList(
131 ClientResponse<AbstractCommonList> response) {
132 return response.getEntity(PersonsCommonList.class);
135 // ---------------------------------------------------------------
136 // CRUD tests : CREATE tests
137 // ---------------------------------------------------------------
140 * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
143 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
145 public void create(String testName) throws Exception {
147 // Perform setup, such as initializing the type of service request
148 // (e.g. CREATE, DELETE), its valid and expected status codes, and
149 // its associated HTTP method name (e.g. POST, DELETE).
150 setupCreate(testName);
152 // Submit the request to the service and store the response.
153 PersonAuthorityClient client = new PersonAuthorityClient();
154 String identifier = createIdentifier();
155 String displayName = "displayName-" + identifier;
156 String baseRefName = PersonAuthorityClientUtils.createPersonAuthRefName(displayName, false);
157 String fullRefName = PersonAuthorityClientUtils.createPersonAuthRefName(displayName, true);
158 MultipartOutput multipart =
159 PersonAuthorityClientUtils.createPersonAuthorityInstance(
160 displayName, fullRefName, client.getCommonPartName());
163 ClientResponse<Response> res = client.create(multipart);
165 int statusCode = res.getStatus();
167 // Check the status code of the response: does it match
168 // the expected response(s)?
171 // Does it fall within the set of valid status codes?
172 // Does it exactly match the expected status code?
173 if(logger.isDebugEnabled()){
174 logger.debug(testName + ": status = " + statusCode);
176 Assert.assertTrue(this.REQUEST_TYPE.isValidStatusCode(statusCode),
177 invalidStatusCodeMessage(this.REQUEST_TYPE, statusCode));
178 Assert.assertEquals(statusCode, this.EXPECTED_STATUS_CODE);
180 newID = PersonAuthorityClientUtils.extractId(res);
182 res.releaseConnection();
184 // Store the refname from the first resource created
185 // for additional tests below.
186 knownResourceRefName = baseRefName;
187 // Store the ID returned from the first resource created
188 // for additional tests below.
189 if (knownResourceId == null){
190 knownResourceId = newID;
191 knownResourceDisplayName = displayName;
192 if (logger.isDebugEnabled()) {
193 logger.debug(testName + ": knownResourceId=" + knownResourceId);
196 // Store the IDs from every resource created by tests,
197 // so they can be deleted after tests have been run.
198 allResourceIdsCreated.add(newID);
204 * @param testName the test name
206 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
207 groups = {"create"}, dependsOnMethods = {"create"})
208 public void createItem(String testName) {
209 setupCreate(testName);
210 String newID = createItemInAuthority(knownResourceId, knownResourceRefName);
214 * Creates the item in authority.
216 * @param vcsid the vcsid
217 * @param authRefName the auth ref name
220 private String createItemInAuthority(String vcsid, String authRefName) {
222 final String testName = "createItemInAuthority";
223 if(logger.isDebugEnabled()){
224 logger.debug(testName + ":...");
227 // Submit the request to the service and store the response.
228 PersonAuthorityClient client = new PersonAuthorityClient();
229 String identifier = createIdentifier();
230 String refName = PersonAuthorityClientUtils.createPersonRefName(authRefName, "John Wayne", true);
231 Map<String, String> johnWayneMap = new HashMap<String,String>();
232 johnWayneMap.put(PersonJAXBSchema.FORE_NAME, TEST_FORE_NAME);
233 johnWayneMap.put(PersonJAXBSchema.SUR_NAME, TEST_SUR_NAME);
234 johnWayneMap.put(PersonJAXBSchema.GENDER, "male");
235 johnWayneMap.put(PersonJAXBSchema.BIRTH_DATE, TEST_BIRTH_DATE);
236 johnWayneMap.put(PersonJAXBSchema.BIRTH_PLACE, "Winterset, Iowa");
237 johnWayneMap.put(PersonJAXBSchema.DEATH_DATE, TEST_DEATH_DATE);
238 johnWayneMap.put(PersonJAXBSchema.BIO_NOTE, "born Marion Robert Morrison and better" +
239 "known by his stage name John Wayne, was an American film actor, director " +
240 "and producer. He epitomized rugged masculinity and has become an enduring " +
241 "American icon. He is famous for his distinctive voice, walk and height. " +
242 "He was also known for his conservative political views and his support in " +
243 "the 1950s for anti-communist positions.");
244 MultipartOutput multipart =
245 PersonAuthorityClientUtils.createPersonInstance(vcsid, refName, johnWayneMap,
246 client.getItemCommonPartName() );
249 ClientResponse<Response> res = client.createItem(vcsid, multipart);
251 int statusCode = res.getStatus();
252 // Check the status code of the response: does it match
253 // the expected response(s)?
254 if(logger.isDebugEnabled()){
255 logger.debug(testName + ": status = " + statusCode);
257 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
258 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
259 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
261 newID = PersonAuthorityClientUtils.extractId(res);
263 res.releaseConnection();
266 // Store the ID returned from the first item resource created
267 // for additional tests below.
268 if (knownItemResourceId == null){
269 knownItemResourceId = newID;
270 if (logger.isDebugEnabled()) {
271 logger.debug(testName + ": knownItemResourceId=" + knownItemResourceId);
275 // Store the IDs from any item resources created
276 // by tests, along with the IDs of their parents, so these items
277 // can be deleted after all tests have been run.
278 allItemResourceIdsCreated.put(newID, vcsid);
284 * Creates the contact.
286 * @param testName the test name
288 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
289 groups = {"create"}, dependsOnMethods = {"createItem"})
290 public void createContact(String testName) {
291 setupCreate(testName);
292 String newID = createContactInItem(knownResourceId, knownItemResourceId);
296 * Creates the contact in item.
298 * @param parentcsid the parentcsid
299 * @param itemcsid the itemcsid
302 private String createContactInItem(String parentcsid, String itemcsid) {
304 final String testName = "createContactInItem";
305 setupCreate(testName);
306 if(logger.isDebugEnabled()){
307 logger.debug(testName + ":...");
310 // Submit the request to the service and store the response.
311 PersonAuthorityClient client = new PersonAuthorityClient();
312 String identifier = createIdentifier();
313 MultipartOutput multipart =
314 ContactClientUtils.createContactInstance(parentcsid,
315 itemcsid, identifier, new ContactClient().getCommonPartName());
318 ClientResponse<Response> res =
319 client.createContact(parentcsid, itemcsid, multipart);
321 int statusCode = res.getStatus();
322 // Check the status code of the response: does it match
323 // the expected response(s)?
324 if(logger.isDebugEnabled()){
325 logger.debug(testName + ": status = " + statusCode);
327 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
328 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
329 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
331 newID = PersonAuthorityClientUtils.extractId(res);
333 res.releaseConnection();
336 // Store the ID returned from the first contact resource created
337 // for additional tests below.
338 if (knownContactResourceId == null){
339 knownContactResourceId = newID;
340 if (logger.isDebugEnabled()) {
341 logger.debug(testName + ": knownContactResourceId=" + knownContactResourceId);
345 // Store the IDs from any contact resources created
346 // by tests, along with the IDs of their parent items,
347 // so these items can be deleted after all tests have been run.
348 allContactResourceIdsCreated.put(newID, itemcsid);
355 // Placeholders until the three tests below can be uncommented.
356 // See Issue CSPACE-401.
358 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
361 public void createWithEmptyEntityBody(String testName) throws Exception {
362 //Should this really be empty?
366 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
369 public void createWithMalformedXml(String testName) throws Exception {
370 //Should this really be empty?
374 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
377 public void createWithWrongXmlSchema(String testName) throws Exception {
378 //Should this really be empty?
383 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
384 groups = {"create"}, dependsOnMethods = {"create", "testSubmitRequest"})
385 public void createWithEmptyEntityBody(String testName) throws Exception {
388 setupCreateWithEmptyEntityBody(testName);
390 // Submit the request to the service and store the response.
391 String method = REQUEST_TYPE.httpMethodName();
392 String url = getServiceRootURL();
393 String mediaType = MediaType.APPLICATION_XML;
394 final String entity = "";
395 int statusCode = submitRequest(method, url, mediaType, entity);
397 // Check the status code of the response: does it match
398 // the expected response(s)?
399 if(logger.isDebugEnabled()) {
400 logger.debug(testName + ": url=" + url +
401 " status=" + statusCode);
403 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
404 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
405 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
409 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
410 groups = {"create"}, dependsOnMethods = {"create", "testSubmitRequest"})
411 public void createWithMalformedXml(String testName) throws Exception {
414 setupCreateWithMalformedXml(testName);
416 // Submit the request to the service and store the response.
417 String method = REQUEST_TYPE.httpMethodName();
418 String url = getServiceRootURL();
419 String mediaType = MediaType.APPLICATION_XML;
420 final String entity = MALFORMED_XML_DATA; // Constant from base class.
421 int statusCode = submitRequest(method, url, mediaType, entity);
423 // Check the status code of the response: does it match
424 // the expected response(s)?
425 if(logger.isDebugEnabled()){
426 logger.debug(testName + ": url=" + url +
427 " status=" + statusCode);
429 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
430 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
431 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
435 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
436 groups = {"create"}, dependsOnMethods = {"create", "testSubmitRequest"})
437 public void createWithWrongXmlSchema(String testName) throws Exception {
440 setupCreateWithWrongXmlSchema(testName);
442 // Submit the request to the service and store the response.
443 String method = REQUEST_TYPE.httpMethodName();
444 String url = getServiceRootURL();
445 String mediaType = MediaType.APPLICATION_XML;
446 final String entity = WRONG_XML_SCHEMA_DATA;
447 int statusCode = submitRequest(method, url, mediaType, entity);
449 // Check the status code of the response: does it match
450 // the expected response(s)?
451 if(logger.isDebugEnabled()){
452 logger.debug(testName + ": url=" + url +
453 " status=" + statusCode);
455 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
456 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
457 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
461 // ---------------------------------------------------------------
462 // CRUD tests : CREATE LIST tests
463 // ---------------------------------------------------------------
466 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
469 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
470 groups = {"createList"}, dependsOnGroups = {"create"})
471 public void createList(String testName) throws Exception {
472 for (int i = 0; i < nItemsToCreateInList; i++) {
478 * Creates the item list.
480 * @param testName the test name
481 * @throws Exception the exception
483 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
484 groups = {"createList"}, dependsOnMethods = {"createList"})
485 public void createItemList(String testName) throws Exception {
486 // Add items to the initially-created, known parent record.
487 for (int j = 0; j < nItemsToCreateInList; j++) {
488 createItem(testName);
493 * Creates the contact list.
495 * @param testName the test name
496 * @throws Exception the exception
498 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
499 groups = {"createList"}, dependsOnMethods = {"createItemList"})
500 public void createContactList(String testName) throws Exception {
501 // Add contacts to the initially-created, known item record.
502 for (int j = 0; j < nItemsToCreateInList; j++) {
503 createContact(testName);
507 // ---------------------------------------------------------------
508 // CRUD tests : READ tests
509 // ---------------------------------------------------------------
512 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
515 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
516 groups = {"read"}, dependsOnGroups = {"create"})
517 public void read(String testName) throws Exception {
522 // Submit the request to the service and store the response.
523 PersonAuthorityClient client = new PersonAuthorityClient();
524 ClientResponse<MultipartInput> res = client.read(knownResourceId);
526 int statusCode = res.getStatus();
527 // Check the status code of the response: does it match
528 // the expected response(s)?
529 if(logger.isDebugEnabled()){
530 logger.debug(testName + ": status = " + statusCode);
532 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
533 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
534 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
535 //FIXME: remove the following try catch once Aron fixes signatures
537 MultipartInput input = (MultipartInput) res.getEntity();
538 PersonauthoritiesCommon personAuthority = (PersonauthoritiesCommon) extractPart(input,
539 client.getCommonPartName(), PersonauthoritiesCommon.class);
540 Assert.assertNotNull(personAuthority);
541 } catch (Exception e) {
542 throw new RuntimeException(e);
545 res.releaseConnection();
552 * @param testName the test name
553 * @throws Exception the exception
555 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
556 groups = {"read"}, dependsOnGroups = {"create"})
557 public void readByName(String testName) throws Exception {
562 // Submit the request to the service and store the response.
563 PersonAuthorityClient client = new PersonAuthorityClient();
564 ClientResponse<MultipartInput> res = client.readByName(knownResourceDisplayName);
566 int statusCode = res.getStatus();
567 // Check the status code of the response: does it match
568 // the expected response(s)?
569 if(logger.isDebugEnabled()){
570 logger.debug(testName + ": status = " + statusCode);
572 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
573 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
574 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
575 //FIXME: remove the following try catch once Aron fixes signatures
577 MultipartInput input = (MultipartInput) res.getEntity();
578 PersonauthoritiesCommon personAuthority = (PersonauthoritiesCommon) extractPart(input,
579 client.getCommonPartName(), PersonauthoritiesCommon.class);
580 Assert.assertNotNull(personAuthority);
581 } catch (Exception e) {
582 throw new RuntimeException(e);
585 res.releaseConnection();
590 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
591 groups = {"read"}, dependsOnMethods = {"read"})
592 public void readByName(String testName) throws Exception {
597 // Submit the request to the service and store the response.
598 ClientResponse<MultipartInput> res = client.read(knownResourceId);
599 int statusCode = res.getStatus();
601 // Check the status code of the response: does it match
602 // the expected response(s)?
603 if(logger.isDebugEnabled()){
604 logger.debug(testName + ": status = " + statusCode);
606 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
607 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
608 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
609 //FIXME: remove the following try catch once Aron fixes signatures
611 MultipartInput input = (MultipartInput) res.getEntity();
612 PersonauthoritiesCommon personAuthority = (PersonauthoritiesCommon) extractPart(input,
613 client.getCommonPartName(), PersonauthoritiesCommon.class);
614 Assert.assertNotNull(personAuthority);
615 } catch (Exception e) {
616 throw new RuntimeException(e);
624 * @param testName the test name
625 * @throws Exception the exception
627 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
628 groups = {"read"}, dependsOnMethods = {"read"})
629 public void readItem(String testName) throws Exception {
633 // Submit the request to the service and store the response.
634 PersonAuthorityClient client = new PersonAuthorityClient();
635 ClientResponse<MultipartInput> res = client.readItem(knownResourceId, knownItemResourceId);
637 int statusCode = res.getStatus();
639 // Check the status code of the response: does it match
640 // the expected response(s)?
641 if(logger.isDebugEnabled()){
642 logger.debug(testName + ": status = " + statusCode);
644 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
645 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
646 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
648 // Check whether we've received a person.
649 MultipartInput input = (MultipartInput) res.getEntity();
650 PersonsCommon person = (PersonsCommon) extractPart(input,
651 client.getItemCommonPartName(), PersonsCommon.class);
652 Assert.assertNotNull(person);
653 boolean showFull = true;
654 if(showFull && logger.isDebugEnabled()){
655 logger.debug(testName + ": returned payload:");
656 logger.debug(objectAsXmlString(person, PersonsCommon.class));
658 Assert.assertEquals(person.getInAuthority(), knownResourceId);
660 res.releaseConnection();
665 * Verify item display name.
667 * @param testName the test name
668 * @throws Exception the exception
670 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
671 dependsOnMethods = {"readItem", "updateItem"})
672 public void verifyItemDisplayName(String testName) throws Exception {
674 setupUpdate(testName);
676 // Submit the request to the service and store the response.
677 PersonAuthorityClient client = new PersonAuthorityClient();
678 MultipartInput input =null;
679 ClientResponse<MultipartInput> res = client.readItem(knownResourceId, knownItemResourceId);
681 int statusCode = res.getStatus();
683 // Check the status code of the response: does it match
684 // the expected response(s)?
685 if(logger.isDebugEnabled()){
686 logger.debug(testName + ": status = " + statusCode);
688 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
689 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
690 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
692 // Check whether person has expected displayName.
693 input = (MultipartInput) res.getEntity();
695 res.releaseConnection();
698 PersonsCommon person = (PersonsCommon) extractPart(input,
699 client.getItemCommonPartName(), PersonsCommon.class);
700 Assert.assertNotNull(person);
701 String displayName = person.getDisplayName();
702 // Make sure displayName matches computed form
703 String expectedDisplayName =
704 PersonAuthorityClientUtils.prepareDefaultDisplayName(
705 TEST_FORE_NAME, null, TEST_SUR_NAME,
706 TEST_BIRTH_DATE, TEST_DEATH_DATE);
707 Assert.assertNotNull(displayName, expectedDisplayName);
709 // Update the shortName and verify the computed name is updated.
710 person.setCsid(null);
711 person.setDisplayNameComputed(true);
712 person.setForeName("updated-" + TEST_FORE_NAME);
713 expectedDisplayName =
714 PersonAuthorityClientUtils.prepareDefaultDisplayName(
715 "updated-" + TEST_FORE_NAME, null, TEST_SUR_NAME,
716 TEST_BIRTH_DATE, TEST_DEATH_DATE);
718 // Submit the updated resource to the service and store the response.
719 MultipartOutput output = new MultipartOutput();
720 OutputPart commonPart = output.addPart(person, MediaType.APPLICATION_XML_TYPE);
721 commonPart.getHeaders().add("label", client.getItemCommonPartName());
722 res = client.updateItem(knownResourceId, knownItemResourceId, output);
724 int statusCode = res.getStatus();
726 // Check the status code of the response: does it match the expected response(s)?
727 if(logger.isDebugEnabled()){
728 logger.debug("updateItem: status = " + statusCode);
730 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
731 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
732 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
734 // Retrieve the updated resource and verify that its contents exist.
735 input = (MultipartInput) res.getEntity();
737 res.releaseConnection();
740 PersonsCommon updatedPerson =
741 (PersonsCommon) extractPart(input,
742 client.getItemCommonPartName(), PersonsCommon.class);
743 Assert.assertNotNull(updatedPerson);
745 // Verify that the updated resource received the correct data.
746 Assert.assertEquals(updatedPerson.getForeName(), person.getForeName(),
747 "Updated ForeName in Person did not match submitted data.");
748 // Verify that the updated resource computes the right displayName.
749 Assert.assertEquals(updatedPerson.getDisplayName(), expectedDisplayName,
750 "Updated ForeName in Person not reflected in computed DisplayName.");
752 // Now Update the displayName, not computed and verify the computed name is overriden.
753 person.setDisplayNameComputed(false);
754 expectedDisplayName = "TestName";
755 person.setDisplayName(expectedDisplayName);
757 // Submit the updated resource to the service and store the response.
758 output = new MultipartOutput();
759 commonPart = output.addPart(person, MediaType.APPLICATION_XML_TYPE);
760 commonPart.getHeaders().add("label", client.getItemCommonPartName());
761 res = client.updateItem(knownResourceId, knownItemResourceId, output);
763 int statusCode = res.getStatus();
765 // Check the status code of the response: does it match the expected response(s)?
766 if(logger.isDebugEnabled()){
767 logger.debug("updateItem: status = " + statusCode);
769 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
770 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
771 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
773 // Retrieve the updated resource and verify that its contents exist.
774 input = (MultipartInput) res.getEntity();
776 res.releaseConnection();
780 (PersonsCommon) extractPart(input,
781 client.getItemCommonPartName(), PersonsCommon.class);
782 Assert.assertNotNull(updatedPerson);
784 // Verify that the updated resource received the correct data.
785 Assert.assertEquals(updatedPerson.isDisplayNameComputed(), false,
786 "Updated displayNameComputed in Person did not match submitted data.");
787 // Verify that the updated resource computes the right displayName.
788 Assert.assertEquals(updatedPerson.getDisplayName(),
790 "Updated DisplayName (not computed) in Person not stored.");
794 * Verify illegal item display name.
796 * @param testName the test name
797 * @throws Exception the exception
799 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
800 dependsOnMethods = {"verifyItemDisplayName"})
801 public void verifyIllegalItemDisplayName(String testName) throws Exception {
804 setupUpdateWithWrongXmlSchema(testName);
806 // Submit the request to the service and store the response.
807 PersonAuthorityClient client = new PersonAuthorityClient();
808 MultipartInput input = null;
809 ClientResponse<MultipartInput> res = client.readItem(knownResourceId, knownItemResourceId);
811 int statusCode = res.getStatus();
813 // Check the status code of the response: does it match
814 // the expected response(s)?
815 if(logger.isDebugEnabled()){
816 logger.debug(testName + ": status = " + statusCode);
818 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
819 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
820 Assert.assertEquals(statusCode, Response.Status.OK.getStatusCode());
822 // Check whether Person has expected displayName.
823 input = (MultipartInput) res.getEntity();
825 res.releaseConnection();
828 PersonsCommon person = (PersonsCommon) extractPart(input,
829 client.getItemCommonPartName(), PersonsCommon.class);
830 Assert.assertNotNull(person);
831 // Try to Update with computed false and no displayName
832 person.setDisplayNameComputed(false);
833 person.setDisplayName(null);
835 // Submit the updated resource to the service and store the response.
836 MultipartOutput output = new MultipartOutput();
837 OutputPart commonPart = output.addPart(person, MediaType.APPLICATION_XML_TYPE);
838 commonPart.getHeaders().add("label", client.getItemCommonPartName());
839 res = client.updateItem(knownResourceId, knownItemResourceId, output);
841 int statusCode = res.getStatus();
843 // Check the status code of the response: does it match the expected response(s)?
844 if(logger.isDebugEnabled()){
845 logger.debug("updateItem: status = " + statusCode);
847 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
848 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
849 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
851 res.releaseConnection();
858 * @param testName the test name
859 * @throws Exception the exception
861 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
862 groups = {"read"}, dependsOnMethods = {"readItem"})
863 public void readContact(String testName) throws Exception {
867 // Submit the request to the service and store the response.
868 PersonAuthorityClient client = new PersonAuthorityClient();
869 MultipartInput input = null;
870 ClientResponse<MultipartInput> res =
871 client.readContact(knownResourceId, knownItemResourceId,
872 knownContactResourceId);
874 int statusCode = res.getStatus();
876 // Check the status code of the response: does it match
877 // the expected response(s)?
878 if(logger.isDebugEnabled()){
879 logger.debug(testName + ": status = " + statusCode);
881 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
882 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
883 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
885 // Check whether we've received a contact.
886 input = (MultipartInput) res.getEntity();
888 res.releaseConnection();
891 ContactsCommon contact = (ContactsCommon) extractPart(input,
892 new ContactClient().getCommonPartName(), ContactsCommon.class);
893 Assert.assertNotNull(contact);
894 boolean showFull = true;
895 if(showFull && logger.isDebugEnabled()){
896 logger.debug(testName + ": returned payload:");
897 logger.debug(objectAsXmlString(contact, ContactsCommon.class));
899 Assert.assertEquals(contact.getInAuthority(), knownResourceId);
900 Assert.assertEquals(contact.getInItem(), knownItemResourceId);
906 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
909 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
910 groups = {"read"}, dependsOnMethods = {"read"})
911 public void readNonExistent(String testName) {
914 setupReadNonExistent(testName);
916 // Submit the request to the service and store the response.
917 PersonAuthorityClient client = new PersonAuthorityClient();
918 ClientResponse<MultipartInput> res = client.read(NON_EXISTENT_ID);
920 int statusCode = res.getStatus();
921 // Check the status code of the response: does it match
922 // the expected response(s)?
923 if(logger.isDebugEnabled()){
924 logger.debug(testName + ": status = " + statusCode);
926 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
927 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
928 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
930 res.releaseConnection();
935 * Read item non existent.
937 * @param testName the test name
939 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
940 groups = {"read"}, dependsOnMethods = {"readItem"})
941 public void readItemNonExistent(String testName) {
944 setupReadNonExistent(testName);
946 // Submit the request to the service and store the response.
947 PersonAuthorityClient client = new PersonAuthorityClient();
948 ClientResponse<MultipartInput> res = client.readItem(knownResourceId, NON_EXISTENT_ID);
950 int statusCode = res.getStatus();
952 // Check the status code of the response: does it match
953 // the expected response(s)?
954 if(logger.isDebugEnabled()){
955 logger.debug(testName + ": status = " + statusCode);
957 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
958 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
959 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
961 res.releaseConnection();
966 * Read contact non existent.
968 * @param testName the test name
970 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
971 groups = {"read"}, dependsOnMethods = {"readContact"})
972 public void readContactNonExistent(String testName) {
975 setupReadNonExistent(testName);
977 // Submit the request to the service and store the response.
978 PersonAuthorityClient client = new PersonAuthorityClient();
979 ClientResponse<MultipartInput> res =
980 client.readContact(knownResourceId, knownItemResourceId, NON_EXISTENT_ID);
982 int statusCode = res.getStatus();
984 // Check the status code of the response: does it match
985 // the expected response(s)?
986 if(logger.isDebugEnabled()){
987 logger.debug(testName + ": status = " + statusCode);
989 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
990 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
991 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
993 res.releaseConnection();
997 // ---------------------------------------------------------------
998 // CRUD tests : READ_LIST tests
999 // ---------------------------------------------------------------
1003 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
1006 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1007 groups = {"readList"}, dependsOnGroups = {"createList", "read"})
1008 public void readList(String testName) throws Exception {
1011 setupReadList(testName);
1013 // Submit the request to the service and store the response.
1014 PersonAuthorityClient client = new PersonAuthorityClient();
1015 PersonauthoritiesCommonList list = null;
1016 ClientResponse<PersonauthoritiesCommonList> res = client.readList();
1018 int statusCode = res.getStatus();
1020 // Check the status code of the response: does it match
1021 // the expected response(s)?
1022 if(logger.isDebugEnabled()){
1023 logger.debug(testName + ": status = " + statusCode);
1025 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1026 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1027 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1029 list = res.getEntity();
1031 res.releaseConnection();
1034 // Optionally output additional data about list members for debugging.
1035 boolean iterateThroughList = false;
1036 if (iterateThroughList && logger.isDebugEnabled()) {
1037 List<PersonauthoritiesCommonList.PersonauthorityListItem> items =
1038 list.getPersonauthorityListItem();
1040 for (PersonauthoritiesCommonList.PersonauthorityListItem item : items) {
1041 String csid = item.getCsid();
1042 logger.debug(testName + ": list-item[" + i + "] csid=" +
1044 logger.debug(testName + ": list-item[" + i + "] displayName=" +
1045 item.getDisplayName());
1046 logger.debug(testName + ": list-item[" + i + "] URI=" +
1048 readItemList(csid, null);
1057 @Test(groups = {"readList"}, dependsOnMethods = {"readList"})
1058 public void readItemList() {
1059 readItemList(knownResourceId, null);
1063 * Read item list by authority name.
1065 @Test(groups = {"readList"}, dependsOnMethods = {"readItemList"})
1066 public void readItemListByAuthorityName() {
1067 readItemList(null, knownResourceDisplayName);
1073 * @param vcsid the vcsid
1074 * @param name the name
1076 private void readItemList(String vcsid, String name) {
1078 final String testName = "readItemList";
1081 setupReadList(testName);
1083 // Submit the request to the service and store the response.
1084 PersonAuthorityClient client = new PersonAuthorityClient();
1085 ClientResponse<PersonsCommonList> res = null;
1087 res = client.readItemList(vcsid);
1088 } else if (name!= null) {
1089 res = client.readItemListForNamedAuthority(name);
1091 Assert.fail("readItemList passed null csid and name!");
1093 PersonsCommonList list = null;
1095 int statusCode = res.getStatus();
1097 // Check the status code of the response: does it match
1098 // the expected response(s)?
1099 if(logger.isDebugEnabled()){
1100 logger.debug(testName + ": status = " + statusCode);
1102 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1103 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1104 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1106 list = res.getEntity();
1108 res.releaseConnection();
1111 List<PersonsCommonList.PersonListItem> items =
1112 list.getPersonListItem();
1113 int nItemsReturned = items.size();
1114 // There will be one item created, associated with a
1115 // known parent resource, by the createItem test.
1117 // In addition, there will be 'nItemsToCreateInList'
1118 // additional items created by the createItemList test,
1119 // all associated with the same parent resource.
1120 int nExpectedItems = nItemsToCreateInList + 1;
1121 if(logger.isDebugEnabled()){
1122 logger.debug(testName + ": Expected "
1123 + nExpectedItems +" items; got: "+nItemsReturned);
1125 Assert.assertEquals(nItemsReturned, nExpectedItems);
1128 for (PersonsCommonList.PersonListItem item : items) {
1129 Assert.assertTrue((null != item.getRefName()), "Item refName is null!");
1130 Assert.assertTrue((null != item.getDisplayName()), "Item displayName is null!");
1131 // Optionally output additional data about list members for debugging.
1132 boolean showDetails = true;
1133 if (showDetails && logger.isDebugEnabled()) {
1134 logger.debug(" " + testName + ": list-item[" + i + "] csid=" +
1136 logger.debug(" " + testName + ": list-item[" + i + "] refName=" +
1138 logger.debug(" " + testName + ": list-item[" + i + "] displayName=" +
1139 item.getDisplayName());
1140 logger.debug(" " + testName + ": list-item[" + i + "] URI=" +
1148 * Read contact list.
1150 @Test(groups = {"readList"}, dependsOnMethods = {"readItemList"})
1151 public void readContactList() {
1152 readContactList(knownResourceId, knownItemResourceId);
1156 * Read contact list.
1158 * @param parentcsid the parentcsid
1159 * @param itemcsid the itemcsid
1161 private void readContactList(String parentcsid, String itemcsid) {
1162 final String testName = "readContactList";
1165 setupReadList(testName);
1167 // Submit the request to the service and store the response.
1168 PersonAuthorityClient client = new PersonAuthorityClient();
1169 ContactsCommonList list = null;
1170 ClientResponse<ContactsCommonList> res =
1171 client.readContactList(parentcsid, itemcsid);
1173 int statusCode = res.getStatus();
1175 // Check the status code of the response: does it match
1176 // the expected response(s)?
1177 if(logger.isDebugEnabled()){
1178 logger.debug(testName + ": status = " + statusCode);
1180 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1181 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1182 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1184 list = res.getEntity();
1186 res.releaseConnection();
1189 List<ContactsCommonList.ContactListItem> listitems =
1190 list.getContactListItem();
1191 int nItemsReturned = listitems.size();
1192 // There will be one item created, associated with a
1193 // known parent resource, by the createItem test.
1195 // In addition, there will be 'nItemsToCreateInList'
1196 // additional items created by the createItemList test,
1197 // all associated with the same parent resource.
1198 int nExpectedItems = nItemsToCreateInList + 1;
1199 if(logger.isDebugEnabled()){
1200 logger.debug(testName + ": Expected "
1201 + nExpectedItems +" items; got: "+nItemsReturned);
1203 Assert.assertEquals(nItemsReturned, nExpectedItems);
1206 for (ContactsCommonList.ContactListItem listitem : listitems) {
1207 // Optionally output additional data about list members for debugging.
1208 boolean showDetails = false;
1209 if (showDetails && logger.isDebugEnabled()) {
1210 logger.debug(" " + testName + ": list-item[" + i + "] csid=" +
1211 listitem.getCsid());
1212 logger.debug(" " + testName + ": list-item[" + i + "] addressPlace=" +
1213 listitem.getAddressPlace());
1214 logger.debug(" " + testName + ": list-item[" + i + "] URI=" +
1224 // ---------------------------------------------------------------
1225 // CRUD tests : UPDATE tests
1226 // ---------------------------------------------------------------
1229 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
1232 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1233 groups = {"update"}, dependsOnGroups = {"read", "readList"})
1234 public void update(String testName) throws Exception {
1237 setupUpdate(testName);
1239 // Retrieve the contents of a resource to update.
1240 PersonAuthorityClient client = new PersonAuthorityClient();
1241 MultipartInput input = null;
1242 ClientResponse<MultipartInput> res = client.read(knownResourceId);
1244 if(logger.isDebugEnabled()){
1245 logger.debug(testName + ": read status = " + res.getStatus());
1247 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
1249 if(logger.isDebugEnabled()){
1250 logger.debug("got PersonAuthority to update with ID: " + knownResourceId);
1252 input = res.getEntity();
1254 res.releaseConnection();
1257 PersonauthoritiesCommon personAuthority = (PersonauthoritiesCommon) extractPart(input,
1258 client.getCommonPartName(), PersonauthoritiesCommon.class);
1259 Assert.assertNotNull(personAuthority);
1261 // Update the contents of this resource.
1262 personAuthority.setDisplayName("updated-" + personAuthority.getDisplayName());
1263 personAuthority.setVocabType("updated-" + personAuthority.getVocabType());
1264 if(logger.isDebugEnabled()){
1265 logger.debug("to be updated PersonAuthority");
1266 logger.debug(objectAsXmlString(personAuthority, PersonauthoritiesCommon.class));
1269 // Submit the updated resource to the service and store the response.
1270 MultipartOutput output = new MultipartOutput();
1271 OutputPart commonPart = output.addPart(personAuthority, MediaType.APPLICATION_XML_TYPE);
1272 commonPart.getHeaders().add("label", client.getCommonPartName());
1273 res = client.update(knownResourceId, output);
1275 int statusCode = res.getStatus();
1277 // Check the status code of the response: does it match the expected response(s)?
1278 if(logger.isDebugEnabled()){
1279 logger.debug(testName + ": status = " + statusCode);
1281 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1282 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1283 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1285 // Retrieve the updated resource and verify that its contents exist.
1286 input = (MultipartInput) res.getEntity();
1288 res.releaseConnection();
1291 PersonauthoritiesCommon updatedPersonAuthority =
1292 (PersonauthoritiesCommon) extractPart(input,
1293 client.getCommonPartName(), PersonauthoritiesCommon.class);
1294 Assert.assertNotNull(updatedPersonAuthority);
1296 // Verify that the updated resource received the correct data.
1297 Assert.assertEquals(updatedPersonAuthority.getDisplayName(),
1298 personAuthority.getDisplayName(),
1299 "Data in updated object did not match submitted data.");
1305 * @param testName the test name
1306 * @throws Exception the exception
1308 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1309 groups = {"update"}, dependsOnMethods = {"update"})
1310 public void updateItem(String testName) throws Exception {
1313 setupUpdate(testName);
1315 // Retrieve the contents of a resource to update.
1316 PersonAuthorityClient client = new PersonAuthorityClient();
1317 MultipartInput input = null;
1318 ClientResponse<MultipartInput> res =
1319 client.readItem(knownResourceId, knownItemResourceId);
1321 if(logger.isDebugEnabled()){
1322 logger.debug(testName + ": read status = " + res.getStatus());
1324 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
1326 if(logger.isDebugEnabled()){
1327 logger.debug("got Person to update with ID: " +
1328 knownItemResourceId +
1329 " in PersonAuthority: " + knownResourceId );
1331 input = res.getEntity();
1333 res.releaseConnection();
1336 PersonsCommon person = (PersonsCommon) extractPart(input,
1337 client.getItemCommonPartName(), PersonsCommon.class);
1338 Assert.assertNotNull(person);
1340 // Update the contents of this resource.
1341 person.setCsid(null);
1342 person.setForeName("updated-" + person.getForeName());
1343 if(logger.isDebugEnabled()){
1344 logger.debug("to be updated Person");
1345 logger.debug(objectAsXmlString(person,
1346 PersonsCommon.class));
1349 // Submit the updated resource to the service and store the response.
1350 MultipartOutput output = new MultipartOutput();
1351 OutputPart commonPart = output.addPart(person, MediaType.APPLICATION_XML_TYPE);
1352 commonPart.getHeaders().add("label", client.getItemCommonPartName());
1353 res = client.updateItem(knownResourceId, knownItemResourceId, output);
1355 int statusCode = res.getStatus();
1357 // Check the status code of the response: does it match the expected response(s)?
1358 if(logger.isDebugEnabled()){
1359 logger.debug(testName + ": status = " + statusCode);
1361 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1362 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1363 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1365 // Retrieve the updated resource and verify that its contents exist.
1366 input = (MultipartInput) res.getEntity();
1368 res.releaseConnection();
1371 PersonsCommon updatedPerson =
1372 (PersonsCommon) extractPart(input,
1373 client.getItemCommonPartName(), PersonsCommon.class);
1374 Assert.assertNotNull(updatedPerson);
1376 // Verify that the updated resource received the correct data.
1377 Assert.assertEquals(updatedPerson.getForeName(),
1378 person.getForeName(),
1379 "Data in updated Person did not match submitted data.");
1385 * @param testName the test name
1386 * @throws Exception the exception
1388 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1389 groups = {"update"}, dependsOnMethods = {"updateItem"})
1390 public void updateContact(String testName) throws Exception {
1392 setupUpdate(testName);
1394 // Retrieve the contents of a resource to update.
1395 PersonAuthorityClient client = new PersonAuthorityClient();
1396 MultipartInput input = null;
1397 ClientResponse<MultipartInput> res =
1398 client.readContact(knownResourceId, knownItemResourceId, knownContactResourceId);
1400 if(logger.isDebugEnabled()){
1401 logger.debug(testName + ": read status = " + res.getStatus());
1403 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
1405 if(logger.isDebugEnabled()){
1406 logger.debug("got Contact to update with ID: " +
1407 knownContactResourceId +
1408 " in item: " + knownItemResourceId +
1409 " in parent: " + knownResourceId );
1411 input = res.getEntity();
1413 res.releaseConnection();
1416 ContactsCommon contact = (ContactsCommon) extractPart(input,
1417 new ContactClient().getCommonPartName(), ContactsCommon.class);
1418 Assert.assertNotNull(contact);
1420 // Update the contents of this resource.
1421 contact.setAddressPlace("updated-" + contact.getAddressPlace());
1422 if(logger.isDebugEnabled()){
1423 logger.debug("to be updated Contact");
1424 logger.debug(objectAsXmlString(contact,
1425 ContactsCommon.class));
1428 // Submit the updated resource to the service and store the response.
1429 MultipartOutput output = new MultipartOutput();
1430 OutputPart commonPart = output.addPart(contact, MediaType.APPLICATION_XML_TYPE);
1431 commonPart.getHeaders().add("label", new ContactClient().getCommonPartName());
1432 res = client.updateContact(knownResourceId, knownItemResourceId, knownContactResourceId, output);
1434 int statusCode = res.getStatus();
1436 // Check the status code of the response: does it match the expected response(s)?
1437 if(logger.isDebugEnabled()){
1438 logger.debug(testName + ": status = " + statusCode);
1440 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1441 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1442 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1444 // Retrieve the updated resource and verify that its contents exist.
1445 input = (MultipartInput) res.getEntity();
1447 res.releaseConnection();
1449 ContactsCommon updatedContact =
1450 (ContactsCommon) extractPart(input,
1451 new ContactClient().getCommonPartName(), ContactsCommon.class);
1452 Assert.assertNotNull(updatedContact);
1454 // Verify that the updated resource received the correct data.
1455 Assert.assertEquals(updatedContact.getAddressPlace(),
1456 contact.getAddressPlace(),
1457 "Data in updated Contact did not match submitted data.");
1461 // Placeholders until the three tests below can be uncommented.
1462 // See Issue CSPACE-401.
1464 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
1467 public void updateWithEmptyEntityBody(String testName) throws Exception {
1468 //Should this really be empty?
1472 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
1475 public void updateWithMalformedXml(String testName) throws Exception {
1476 //Should this really be empty?
1480 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
1483 public void updateWithWrongXmlSchema(String testName) throws Exception {
1484 //Should this really be empty?
1489 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
1490 groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
1491 public void updateWithEmptyEntityBody(String testName) throws Exception {
1494 setupUpdateWithEmptyEntityBody(testName);
1496 // Submit the request to the service and store the response.
1497 String method = REQUEST_TYPE.httpMethodName();
1498 String url = getResourceURL(knownResourceId);
1499 String mediaType = MediaType.APPLICATION_XML;
1500 final String entity = "";
1501 int statusCode = submitRequest(method, url, mediaType, entity);
1503 // Check the status code of the response: does it match
1504 // the expected response(s)?
1505 if(logger.isDebugEnabled()){
1506 logger.debug(testName + ": url=" + url +
1507 " status=" + statusCode);
1509 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1510 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1511 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1515 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
1516 groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
1517 public void updateWithMalformedXml(String testName) throws Exception {
1520 setupUpdateWithMalformedXml(testName);
1522 // Submit the request to the service and store the response.
1523 String method = REQUEST_TYPE.httpMethodName();
1524 String url = getResourceURL(knownResourceId);
1525 String mediaType = MediaType.APPLICATION_XML;
1526 final String entity = MALFORMED_XML_DATA;
1527 int statusCode = submitRequest(method, url, mediaType, entity);
1529 // Check the status code of the response: does it match
1530 // the expected response(s)?
1531 if(logger.isDebugEnabled()){
1532 logger.debug(testName + ": url=" + url +
1533 " status=" + statusCode);
1535 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1536 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1537 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1541 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
1542 groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
1543 public void updateWithWrongXmlSchema(String testName) throws Exception {
1546 setupUpdateWithWrongXmlSchema(testName);
1548 // Submit the request to the service and store the response.
1549 String method = REQUEST_TYPE.httpMethodName();
1550 String url = getResourceURL(knownResourceId);
1551 String mediaType = MediaType.APPLICATION_XML;
1552 final String entity = WRONG_XML_SCHEMA_DATA;
1553 int statusCode = submitRequest(method, url, mediaType, entity);
1555 // Check the status code of the response: does it match
1556 // the expected response(s)?
1557 if(logger.isDebugEnabled()){
1558 logger.debug("updateWithWrongXmlSchema: url=" + url +
1559 " status=" + statusCode);
1561 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1562 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1563 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1568 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
1571 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1572 groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
1573 public void updateNonExistent(String testName) throws Exception {
1576 setupUpdateNonExistent(testName);
1578 // Submit the request to the service and store the response.
1579 // Note: The ID(s) used when creating the request payload may be arbitrary.
1580 // The only relevant ID may be the one used in update(), below.
1581 PersonAuthorityClient client = new PersonAuthorityClient();
1582 String displayName = "displayName-NON_EXISTENT_ID";
1583 String fullRefName = PersonAuthorityClientUtils.createPersonAuthRefName(displayName, true);
1584 MultipartOutput multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance(
1585 displayName, fullRefName, client.getCommonPartName());
1586 ClientResponse<MultipartInput> res =
1587 client.update(NON_EXISTENT_ID, multipart);
1589 int statusCode = res.getStatus();
1591 // Check the status code of the response: does it match
1592 // the expected response(s)?
1593 if(logger.isDebugEnabled()){
1594 logger.debug(testName + ": status = " + statusCode);
1596 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1597 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1598 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1600 res.releaseConnection();
1605 * Update non existent item.
1607 * @param testName the test name
1608 * @throws Exception the exception
1610 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1611 groups = {"update"}, dependsOnMethods = {"updateItem", "testItemSubmitRequest"})
1612 public void updateNonExistentItem(String testName) throws Exception {
1615 setupUpdateNonExistent(testName);
1617 // Submit the request to the service and store the response.
1618 // Note: The ID used in this 'create' call may be arbitrary.
1619 // The only relevant ID may be the one used in update(), below.
1620 PersonAuthorityClient client = new PersonAuthorityClient();
1621 Map<String, String> nonexMap = new HashMap<String,String>();
1622 nonexMap.put(PersonJAXBSchema.FORE_NAME, "John");
1623 nonexMap.put(PersonJAXBSchema.SUR_NAME, "Wayne");
1624 nonexMap.put(PersonJAXBSchema.GENDER, "male");
1625 MultipartOutput multipart =
1626 PersonAuthorityClientUtils.createPersonInstance(NON_EXISTENT_ID,
1627 PersonAuthorityClientUtils.createPersonRefName(NON_EXISTENT_ID, NON_EXISTENT_ID, true), nonexMap,
1628 client.getItemCommonPartName() );
1629 ClientResponse<MultipartInput> res =
1630 client.updateItem(knownResourceId, NON_EXISTENT_ID, multipart);
1632 int statusCode = res.getStatus();
1634 // Check the status code of the response: does it match
1635 // the expected response(s)?
1636 if(logger.isDebugEnabled()){
1637 logger.debug(testName + ": status = " + statusCode);
1639 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1640 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1641 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1643 res.releaseConnection();
1648 * Update non existent contact.
1650 * @param testName the test name
1651 * @throws Exception the exception
1653 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1654 groups = {"update"}, dependsOnMethods = {"updateContact", "testContactSubmitRequest"})
1655 public void updateNonExistentContact(String testName) throws Exception {
1656 // Currently a no-op test
1659 // ---------------------------------------------------------------
1660 // CRUD tests : DELETE tests
1661 // ---------------------------------------------------------------
1664 // Note: delete sub-resources in ascending hierarchical order,
1665 // before deleting their parents.
1670 * @param testName the test name
1671 * @throws Exception the exception
1673 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1674 groups = {"delete"}, dependsOnGroups = {"create", "read", "readList", "update"})
1675 public void deleteContact(String testName) throws Exception {
1678 setupDelete(testName);
1680 if(logger.isDebugEnabled()){
1681 logger.debug("parentcsid =" + knownResourceId +
1682 " itemcsid = " + knownItemResourceId +
1683 " csid = " + knownContactResourceId);
1686 // Submit the request to the service and store the response.
1687 PersonAuthorityClient client = new PersonAuthorityClient();
1688 ClientResponse<Response> res =
1689 client.deleteContact(knownResourceId, knownItemResourceId, knownContactResourceId);
1690 int statusCode = res.getStatus();
1691 res.releaseConnection();
1693 // Check the status code of the response: does it match
1694 // the expected response(s)?
1695 if(logger.isDebugEnabled()){
1696 logger.debug(testName + ": status = " + statusCode);
1698 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1699 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1700 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1706 * @param testName the test name
1707 * @throws Exception the exception
1709 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1710 groups = {"delete"}, dependsOnMethods = {"deleteContact"})
1711 public void deleteItem(String testName) throws Exception {
1714 setupDelete(testName);
1716 if(logger.isDebugEnabled()){
1717 logger.debug("parentcsid =" + knownResourceId +
1718 " itemcsid = " + knownItemResourceId);
1721 // Submit the request to the service and store the response.
1722 PersonAuthorityClient client = new PersonAuthorityClient();
1723 ClientResponse<Response> res = client.deleteItem(knownResourceId, knownItemResourceId);
1724 int statusCode = res.getStatus();
1725 res.releaseConnection();
1727 // Check the status code of the response: does it match
1728 // the expected response(s)?
1729 if(logger.isDebugEnabled()){
1730 logger.debug(testName + ": status = " + statusCode);
1732 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1733 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1734 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1738 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
1741 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1742 groups = {"delete"}, dependsOnMethods = {"deleteItem"})
1743 public void delete(String testName) throws Exception {
1746 setupDelete(testName);
1748 if(logger.isDebugEnabled()){
1749 logger.debug("parentcsid =" + knownResourceId);
1752 // Submit the request to the service and store the response.
1753 PersonAuthorityClient client = new PersonAuthorityClient();
1754 ClientResponse<Response> res = client.delete(knownResourceId);
1755 int statusCode = res.getStatus();
1756 res.releaseConnection();
1758 // Check the status code of the response: does it match
1759 // the expected response(s)?
1760 if(logger.isDebugEnabled()){
1761 logger.debug(testName + ": status = " + statusCode);
1763 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1764 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1765 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1770 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
1773 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1774 groups = {"delete"}, dependsOnMethods = {"delete"})
1775 public void deleteNonExistent(String testName) throws Exception {
1778 setupDeleteNonExistent(testName);
1780 // Submit the request to the service and store the response.
1781 PersonAuthorityClient client = new PersonAuthorityClient();
1782 ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
1783 int statusCode = res.getStatus();
1784 res.releaseConnection();
1786 // Check the status code of the response: does it match
1787 // the expected response(s)?
1788 if(logger.isDebugEnabled()){
1789 logger.debug(testName + ": status = " + statusCode);
1791 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1792 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1793 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1797 * Delete non existent item.
1799 * @param testName the test name
1801 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1802 groups = {"delete"}, dependsOnMethods = {"deleteItem"})
1803 public void deleteNonExistentItem(String testName) {
1806 setupDeleteNonExistent(testName);
1808 // Submit the request to the service and store the response.
1809 PersonAuthorityClient client = new PersonAuthorityClient();
1810 ClientResponse<Response> res = client.deleteItem(knownResourceId, NON_EXISTENT_ID);
1811 int statusCode = res.getStatus();
1812 res.releaseConnection();
1814 // Check the status code of the response: does it match
1815 // the expected response(s)?
1816 if(logger.isDebugEnabled()){
1817 logger.debug(testName + ": status = " + statusCode);
1819 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1820 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1821 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1825 * Delete non existent contact.
1827 * @param testName the test name
1829 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1830 groups = {"delete"}, dependsOnMethods = {"deleteContact"})
1831 public void deleteNonExistentContact(String testName) {
1834 setupDeleteNonExistent(testName);
1836 // Submit the request to the service and store the response.
1837 PersonAuthorityClient client = new PersonAuthorityClient();
1838 ClientResponse<Response> res =
1839 client.deleteContact(knownResourceId, knownItemResourceId, NON_EXISTENT_ID);
1840 int statusCode = res.getStatus();
1841 res.releaseConnection();
1843 // Check the status code of the response: does it match
1844 // the expected response(s)?
1845 if(logger.isDebugEnabled()){
1846 logger.debug(testName + ": status = " + statusCode);
1848 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1849 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1850 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1853 // ---------------------------------------------------------------
1854 // Utility tests : tests of code used in tests above
1855 // ---------------------------------------------------------------
1857 * Tests the code for manually submitting data that is used by several
1858 * of the methods above.
1860 @Test(dependsOnMethods = {"create", "read"})
1861 public void testSubmitRequest() {
1863 // Expected status code: 200 OK
1864 final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
1866 // Submit the request to the service and store the response.
1867 String method = ServiceRequestType.READ.httpMethodName();
1868 String url = getResourceURL(knownResourceId);
1869 int statusCode = submitRequest(method, url);
1871 // Check the status code of the response: does it match
1872 // the expected response(s)?
1873 if(logger.isDebugEnabled()){
1874 logger.debug("testSubmitRequest: url=" + url +
1875 " status=" + statusCode);
1877 Assert.assertEquals(statusCode, EXPECTED_STATUS);
1882 * Test item submit request.
1884 @Test(dependsOnMethods = {"createItem", "readItem", "testSubmitRequest"})
1885 public void testItemSubmitRequest() {
1887 // Expected status code: 200 OK
1888 final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
1890 // Submit the request to the service and store the response.
1891 String method = ServiceRequestType.READ.httpMethodName();
1892 String url = getItemResourceURL(knownResourceId, knownItemResourceId);
1893 int statusCode = submitRequest(method, url);
1895 // Check the status code of the response: does it match
1896 // the expected response(s)?
1897 if(logger.isDebugEnabled()){
1898 logger.debug("testItemSubmitRequest: url=" + url +
1899 " status=" + statusCode);
1901 Assert.assertEquals(statusCode, EXPECTED_STATUS);
1906 * Test contact submit request.
1908 @Test(dependsOnMethods = {"createContact", "readContact", "testItemSubmitRequest"})
1909 public void testContactSubmitRequest() {
1911 // Expected status code: 200 OK
1912 final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
1914 // Submit the request to the service and store the response.
1915 String method = ServiceRequestType.READ.httpMethodName();
1916 String url = getContactResourceURL(knownResourceId,
1917 knownItemResourceId, knownContactResourceId);
1918 int statusCode = submitRequest(method, url);
1920 // Check the status code of the response: does it match
1921 // the expected response(s)?
1922 if(logger.isDebugEnabled()){
1923 logger.debug("testItemSubmitRequest: url=" + url +
1924 " status=" + statusCode);
1926 Assert.assertEquals(statusCode, EXPECTED_STATUS);
1931 // ---------------------------------------------------------------
1932 // Cleanup of resources created during testing
1933 // ---------------------------------------------------------------
1936 * Deletes all resources created by tests, after all tests have been run.
1938 * This cleanup method will always be run, even if one or more tests fail.
1939 * For this reason, it attempts to remove all resources created
1940 * at any point during testing, even if some of those resources
1941 * may be expected to be deleted by certain tests.
1944 @AfterClass(alwaysRun=true)
1946 public void cleanUp() {
1947 String noTest = System.getProperty("noTestCleanup");
1948 if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
1949 if (logger.isDebugEnabled()) {
1950 logger.debug("Skipping Cleanup phase ...");
1954 if (logger.isDebugEnabled()) {
1955 logger.debug("Cleaning up temporary resources created for testing ...");
1957 String parentResourceId;
1958 String itemResourceId;
1959 String contactResourceId;
1960 // Clean up contact resources.
1961 PersonAuthorityClient client = new PersonAuthorityClient();
1962 parentResourceId = knownResourceId;
1963 for (Map.Entry<String, String> entry : allContactResourceIdsCreated.entrySet()) {
1964 contactResourceId = entry.getKey();
1965 itemResourceId = entry.getValue();
1966 // Note: Any non-success responses from the delete operation
1967 // below are ignored and not reported.
1968 ClientResponse<Response> res =
1969 client.deleteContact(parentResourceId, itemResourceId, contactResourceId);
1970 res.releaseConnection();
1972 // Clean up item resources.
1973 for (Map.Entry<String, String> entry : allItemResourceIdsCreated.entrySet()) {
1974 itemResourceId = entry.getKey();
1975 parentResourceId = entry.getValue();
1976 // Note: Any non-success responses from the delete operation
1977 // below are ignored and not reported.
1978 ClientResponse<Response> res =
1979 client.deleteItem(parentResourceId, itemResourceId);
1980 res.releaseConnection();
1982 // Clean up parent resources.
1986 // ---------------------------------------------------------------
1987 // Utility methods used by tests above
1988 // ---------------------------------------------------------------
1990 * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
1993 public String getServicePathComponent() {
1994 return SERVICE_PATH_COMPONENT;
1998 * Gets the item service path component.
2000 * @return the item service path component
2002 public String getItemServicePathComponent() {
2003 return ITEM_SERVICE_PATH_COMPONENT;
2007 * Gets the contact service path component.
2009 * @return the contact service path component
2011 public String getContactServicePathComponent() {
2012 return CONTACT_SERVICE_PATH_COMPONENT;
2016 * Returns the root URL for the item service.
2018 * This URL consists of a base URL for all services, followed by
2019 * a path component for the owning parent, followed by the
2020 * path component for the items.
2022 * @param parentResourceIdentifier An identifier (such as a UUID) for the
2023 * parent authority resource of the relevant item resource.
2025 * @return The root URL for the item service.
2027 protected String getItemServiceRootURL(String parentResourceIdentifier) {
2028 return getResourceURL(parentResourceIdentifier) + "/" + getItemServicePathComponent();
2032 * Returns the URL of a specific item resource managed by a service, and
2033 * designated by an identifier (such as a universally unique ID, or UUID).
2035 * @param parentResourceIdentifier An identifier (such as a UUID) for the
2036 * parent authority resource of the relevant item resource.
2038 * @param itemResourceIdentifier An identifier (such as a UUID) for an
2041 * @return The URL of a specific item resource managed by a service.
2043 protected String getItemResourceURL(String parentResourceIdentifier, String itemResourceIdentifier) {
2044 return getItemServiceRootURL(parentResourceIdentifier) + "/" + itemResourceIdentifier;
2049 * Returns the root URL for the contact service.
2051 * This URL consists of a base URL for all services, followed by
2052 * a path component for the owning authority, followed by the
2053 * path component for the owning item, followed by the path component
2054 * for the contact service.
2056 * @param parentResourceIdentifier An identifier (such as a UUID) for the
2057 * parent authority resource of the relevant item resource.
2059 * @param itemResourceIdentifier An identifier (such as a UUID) for an
2062 * @return The root URL for the contact service.
2064 protected String getContactServiceRootURL(String parentResourceIdentifier,
2065 String itemResourceIdentifier) {
2066 return getItemResourceURL(parentResourceIdentifier, itemResourceIdentifier) + "/" +
2067 getContactServicePathComponent();
2071 * Returns the URL of a specific contact resource managed by a service, and
2072 * designated by an identifier (such as a universally unique ID, or UUID).
2074 * @param parentResourceIdentifier An identifier (such as a UUID) for the
2075 * parent resource of the relevant item resource.
2077 * @param resourceIdentifier An identifier (such as a UUID) for an
2080 * @return The URL of a specific resource managed by a service.
2082 protected String getContactResourceURL(String parentResourceIdentifier,
2083 String itemResourceIdentifier, String contactResourceIdentifier) {
2084 return getContactServiceRootURL(parentResourceIdentifier,
2085 itemResourceIdentifier) + "/" + contactResourceIdentifier;