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>();
233 // Fill the property map
235 johnWayneMap.put(PersonJAXBSchema.DISPLAY_NAME_COMPUTED, "false");
236 johnWayneMap.put(PersonJAXBSchema.DISPLAY_NAME, "John Wayne");
238 johnWayneMap.put(PersonJAXBSchema.FORE_NAME, TEST_FORE_NAME);
239 johnWayneMap.put(PersonJAXBSchema.SUR_NAME, TEST_SUR_NAME);
240 johnWayneMap.put(PersonJAXBSchema.GENDER, "male");
241 johnWayneMap.put(PersonJAXBSchema.BIRTH_DATE, TEST_BIRTH_DATE);
242 johnWayneMap.put(PersonJAXBSchema.BIRTH_PLACE, "Winterset, Iowa");
243 johnWayneMap.put(PersonJAXBSchema.DEATH_DATE, TEST_DEATH_DATE);
244 johnWayneMap.put(PersonJAXBSchema.BIO_NOTE, "born Marion Robert Morrison and better" +
245 "known by his stage name John Wayne, was an American film actor, director " +
246 "and producer. He epitomized rugged masculinity and has become an enduring " +
247 "American icon. He is famous for his distinctive voice, walk and height. " +
248 "He was also known for his conservative political views and his support in " +
249 "the 1950s for anti-communist positions.");
250 MultipartOutput multipart =
251 PersonAuthorityClientUtils.createPersonInstance(vcsid, refName, johnWayneMap,
252 client.getItemCommonPartName() );
255 ClientResponse<Response> res = client.createItem(vcsid, multipart);
257 int statusCode = res.getStatus();
258 // Check the status code of the response: does it match
259 // the expected response(s)?
260 if(logger.isDebugEnabled()){
261 logger.debug(testName + ": status = " + statusCode);
263 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
264 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
265 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
267 newID = PersonAuthorityClientUtils.extractId(res);
269 res.releaseConnection();
272 // Store the ID returned from the first item resource created
273 // for additional tests below.
274 if (knownItemResourceId == null){
275 knownItemResourceId = newID;
276 if (logger.isDebugEnabled()) {
277 logger.debug(testName + ": knownItemResourceId=" + knownItemResourceId);
281 // Store the IDs from any item resources created
282 // by tests, along with the IDs of their parents, so these items
283 // can be deleted after all tests have been run.
284 allItemResourceIdsCreated.put(newID, vcsid);
290 * Creates the contact.
292 * @param testName the test name
294 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
295 groups = {"create"}, dependsOnMethods = {"createItem"})
296 public void createContact(String testName) {
297 setupCreate(testName);
298 String newID = createContactInItem(knownResourceId, knownItemResourceId);
302 * Creates the contact in item.
304 * @param parentcsid the parentcsid
305 * @param itemcsid the itemcsid
308 private String createContactInItem(String parentcsid, String itemcsid) {
310 final String testName = "createContactInItem";
311 setupCreate(testName);
312 if(logger.isDebugEnabled()){
313 logger.debug(testName + ":...");
316 // Submit the request to the service and store the response.
317 PersonAuthorityClient client = new PersonAuthorityClient();
318 String identifier = createIdentifier();
319 MultipartOutput multipart =
320 ContactClientUtils.createContactInstance(parentcsid,
321 itemcsid, identifier, new ContactClient().getCommonPartName());
324 ClientResponse<Response> res =
325 client.createContact(parentcsid, itemcsid, multipart);
327 int statusCode = res.getStatus();
328 // Check the status code of the response: does it match
329 // the expected response(s)?
330 if(logger.isDebugEnabled()){
331 logger.debug(testName + ": status = " + statusCode);
333 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
334 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
335 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
337 newID = PersonAuthorityClientUtils.extractId(res);
339 res.releaseConnection();
342 // Store the ID returned from the first contact resource created
343 // for additional tests below.
344 if (knownContactResourceId == null){
345 knownContactResourceId = newID;
346 if (logger.isDebugEnabled()) {
347 logger.debug(testName + ": knownContactResourceId=" + knownContactResourceId);
351 // Store the IDs from any contact resources created
352 // by tests, along with the IDs of their parent items,
353 // so these items can be deleted after all tests have been run.
354 allContactResourceIdsCreated.put(newID, itemcsid);
361 // Placeholders until the three tests below can be uncommented.
362 // See Issue CSPACE-401.
364 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
367 public void createWithEmptyEntityBody(String testName) throws Exception {
368 //Should this really be empty?
372 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
375 public void createWithMalformedXml(String testName) throws Exception {
376 //Should this really be empty?
380 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
383 public void createWithWrongXmlSchema(String testName) throws Exception {
384 //Should this really be empty?
389 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
390 groups = {"create"}, dependsOnMethods = {"create", "testSubmitRequest"})
391 public void createWithEmptyEntityBody(String testName) throws Exception {
394 setupCreateWithEmptyEntityBody(testName);
396 // Submit the request to the service and store the response.
397 String method = REQUEST_TYPE.httpMethodName();
398 String url = getServiceRootURL();
399 String mediaType = MediaType.APPLICATION_XML;
400 final String entity = "";
401 int statusCode = submitRequest(method, url, mediaType, entity);
403 // Check the status code of the response: does it match
404 // the expected response(s)?
405 if(logger.isDebugEnabled()) {
406 logger.debug(testName + ": url=" + url +
407 " status=" + statusCode);
409 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
410 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
411 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
415 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
416 groups = {"create"}, dependsOnMethods = {"create", "testSubmitRequest"})
417 public void createWithMalformedXml(String testName) throws Exception {
420 setupCreateWithMalformedXml(testName);
422 // Submit the request to the service and store the response.
423 String method = REQUEST_TYPE.httpMethodName();
424 String url = getServiceRootURL();
425 String mediaType = MediaType.APPLICATION_XML;
426 final String entity = MALFORMED_XML_DATA; // Constant from base class.
427 int statusCode = submitRequest(method, url, mediaType, entity);
429 // Check the status code of the response: does it match
430 // the expected response(s)?
431 if(logger.isDebugEnabled()){
432 logger.debug(testName + ": url=" + url +
433 " status=" + statusCode);
435 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
436 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
437 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
441 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
442 groups = {"create"}, dependsOnMethods = {"create", "testSubmitRequest"})
443 public void createWithWrongXmlSchema(String testName) throws Exception {
446 setupCreateWithWrongXmlSchema(testName);
448 // Submit the request to the service and store the response.
449 String method = REQUEST_TYPE.httpMethodName();
450 String url = getServiceRootURL();
451 String mediaType = MediaType.APPLICATION_XML;
452 final String entity = WRONG_XML_SCHEMA_DATA;
453 int statusCode = submitRequest(method, url, mediaType, entity);
455 // Check the status code of the response: does it match
456 // the expected response(s)?
457 if(logger.isDebugEnabled()){
458 logger.debug(testName + ": url=" + url +
459 " status=" + statusCode);
461 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
462 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
463 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
467 // ---------------------------------------------------------------
468 // CRUD tests : CREATE LIST tests
469 // ---------------------------------------------------------------
472 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
475 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
476 groups = {"createList"}, dependsOnGroups = {"create"})
477 public void createList(String testName) throws Exception {
478 for (int i = 0; i < nItemsToCreateInList; i++) {
484 * Creates the item list.
486 * @param testName the test name
487 * @throws Exception the exception
489 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
490 groups = {"createList"}, dependsOnMethods = {"createList"})
491 public void createItemList(String testName) throws Exception {
492 // Add items to the initially-created, known parent record.
493 for (int j = 0; j < nItemsToCreateInList; j++) {
494 createItem(testName);
499 * Creates the contact list.
501 * @param testName the test name
502 * @throws Exception the exception
504 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
505 groups = {"createList"}, dependsOnMethods = {"createItemList"})
506 public void createContactList(String testName) throws Exception {
507 // Add contacts to the initially-created, known item record.
508 for (int j = 0; j < nItemsToCreateInList; j++) {
509 createContact(testName);
513 // ---------------------------------------------------------------
514 // CRUD tests : READ tests
515 // ---------------------------------------------------------------
518 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
521 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
522 groups = {"read"}, dependsOnGroups = {"create"})
523 public void read(String testName) throws Exception {
528 // Submit the request to the service and store the response.
529 PersonAuthorityClient client = new PersonAuthorityClient();
530 ClientResponse<MultipartInput> res = client.read(knownResourceId);
532 int statusCode = res.getStatus();
533 // Check the status code of the response: does it match
534 // the expected response(s)?
535 if(logger.isDebugEnabled()){
536 logger.debug(testName + ": status = " + statusCode);
538 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
539 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
540 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
541 //FIXME: remove the following try catch once Aron fixes signatures
543 MultipartInput input = (MultipartInput) res.getEntity();
544 PersonauthoritiesCommon personAuthority = (PersonauthoritiesCommon) extractPart(input,
545 client.getCommonPartName(), PersonauthoritiesCommon.class);
546 Assert.assertNotNull(personAuthority);
547 } catch (Exception e) {
548 throw new RuntimeException(e);
551 res.releaseConnection();
558 * @param testName the test name
559 * @throws Exception the exception
561 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
562 groups = {"read"}, dependsOnGroups = {"create"})
563 public void readByName(String testName) throws Exception {
568 // Submit the request to the service and store the response.
569 PersonAuthorityClient client = new PersonAuthorityClient();
570 ClientResponse<MultipartInput> res = client.readByName(knownResourceDisplayName);
572 int statusCode = res.getStatus();
573 // Check the status code of the response: does it match
574 // the expected response(s)?
575 if(logger.isDebugEnabled()){
576 logger.debug(testName + ": status = " + statusCode);
578 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
579 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
580 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
581 //FIXME: remove the following try catch once Aron fixes signatures
583 MultipartInput input = (MultipartInput) res.getEntity();
584 PersonauthoritiesCommon personAuthority = (PersonauthoritiesCommon) extractPart(input,
585 client.getCommonPartName(), PersonauthoritiesCommon.class);
586 Assert.assertNotNull(personAuthority);
587 } catch (Exception e) {
588 throw new RuntimeException(e);
591 res.releaseConnection();
596 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
597 groups = {"read"}, dependsOnMethods = {"read"})
598 public void readByName(String testName) throws Exception {
603 // Submit the request to the service and store the response.
604 ClientResponse<MultipartInput> res = client.read(knownResourceId);
605 int statusCode = res.getStatus();
607 // Check the status code of the response: does it match
608 // the expected response(s)?
609 if(logger.isDebugEnabled()){
610 logger.debug(testName + ": status = " + statusCode);
612 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
613 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
614 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
615 //FIXME: remove the following try catch once Aron fixes signatures
617 MultipartInput input = (MultipartInput) res.getEntity();
618 PersonauthoritiesCommon personAuthority = (PersonauthoritiesCommon) extractPart(input,
619 client.getCommonPartName(), PersonauthoritiesCommon.class);
620 Assert.assertNotNull(personAuthority);
621 } catch (Exception e) {
622 throw new RuntimeException(e);
630 * @param testName the test name
631 * @throws Exception the exception
633 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
634 groups = {"read"}, dependsOnMethods = {"read"})
635 public void readItem(String testName) throws Exception {
639 // Submit the request to the service and store the response.
640 PersonAuthorityClient client = new PersonAuthorityClient();
641 ClientResponse<MultipartInput> res = client.readItem(knownResourceId, knownItemResourceId);
643 int statusCode = res.getStatus();
645 // Check the status code of the response: does it match
646 // the expected response(s)?
647 if(logger.isDebugEnabled()){
648 logger.debug(testName + ": status = " + statusCode);
650 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
651 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
652 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
654 // Check whether we've received a person.
655 MultipartInput input = (MultipartInput) res.getEntity();
656 PersonsCommon person = (PersonsCommon) extractPart(input,
657 client.getItemCommonPartName(), PersonsCommon.class);
658 Assert.assertNotNull(person);
659 boolean showFull = true;
660 if(showFull && logger.isDebugEnabled()){
661 logger.debug(testName + ": returned payload:");
662 logger.debug(objectAsXmlString(person, PersonsCommon.class));
664 Assert.assertEquals(person.getInAuthority(), knownResourceId);
666 res.releaseConnection();
671 * Verify item display name.
673 * @param testName the test name
674 * @throws Exception the exception
676 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
677 dependsOnMethods = {"readItem", "updateItem"})
678 public void verifyItemDisplayName(String testName) throws Exception {
680 setupUpdate(testName);
682 // Submit the request to the service and store the response.
683 PersonAuthorityClient client = new PersonAuthorityClient();
684 MultipartInput input =null;
685 ClientResponse<MultipartInput> res = client.readItem(knownResourceId, knownItemResourceId);
687 int statusCode = res.getStatus();
689 // Check the status code of the response: does it match
690 // the expected response(s)?
691 if(logger.isDebugEnabled()){
692 logger.debug(testName + ": status = " + statusCode);
694 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
695 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
696 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
698 // Check whether person has expected displayName.
699 input = (MultipartInput) res.getEntity();
701 res.releaseConnection();
704 PersonsCommon person = (PersonsCommon) extractPart(input,
705 client.getItemCommonPartName(), PersonsCommon.class);
706 Assert.assertNotNull(person);
707 String displayName = person.getDisplayName();
708 // Make sure displayName matches computed form
709 String expectedDisplayName =
710 PersonAuthorityClientUtils.prepareDefaultDisplayName(
711 TEST_FORE_NAME, null, TEST_SUR_NAME,
712 TEST_BIRTH_DATE, TEST_DEATH_DATE);
713 Assert.assertNotNull(displayName, expectedDisplayName);
715 // Update the shortName and verify the computed name is updated.
716 person.setCsid(null);
717 person.setDisplayNameComputed(true);
718 person.setForeName("updated-" + TEST_FORE_NAME);
719 expectedDisplayName =
720 PersonAuthorityClientUtils.prepareDefaultDisplayName(
721 "updated-" + TEST_FORE_NAME, null, TEST_SUR_NAME,
722 TEST_BIRTH_DATE, TEST_DEATH_DATE);
724 // Submit the updated resource to the service and store the response.
725 MultipartOutput output = new MultipartOutput();
726 OutputPart commonPart = output.addPart(person, MediaType.APPLICATION_XML_TYPE);
727 commonPart.getHeaders().add("label", client.getItemCommonPartName());
728 res = client.updateItem(knownResourceId, knownItemResourceId, output);
730 int statusCode = res.getStatus();
732 // Check the status code of the response: does it match the expected response(s)?
733 if(logger.isDebugEnabled()){
734 logger.debug("updateItem: status = " + statusCode);
736 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
737 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
738 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
740 // Retrieve the updated resource and verify that its contents exist.
741 input = (MultipartInput) res.getEntity();
743 res.releaseConnection();
746 PersonsCommon updatedPerson =
747 (PersonsCommon) extractPart(input,
748 client.getItemCommonPartName(), PersonsCommon.class);
749 Assert.assertNotNull(updatedPerson);
751 // Verify that the updated resource received the correct data.
752 Assert.assertEquals(updatedPerson.getForeName(), person.getForeName(),
753 "Updated ForeName in Person did not match submitted data.");
754 // Verify that the updated resource computes the right displayName.
755 Assert.assertEquals(updatedPerson.getDisplayName(), expectedDisplayName,
756 "Updated ForeName in Person not reflected in computed DisplayName.");
758 // Now Update the displayName, not computed and verify the computed name is overriden.
759 person.setDisplayNameComputed(false);
760 expectedDisplayName = "TestName";
761 person.setDisplayName(expectedDisplayName);
763 // Submit the updated resource to the service and store the response.
764 output = new MultipartOutput();
765 commonPart = output.addPart(person, MediaType.APPLICATION_XML_TYPE);
766 commonPart.getHeaders().add("label", client.getItemCommonPartName());
767 res = client.updateItem(knownResourceId, knownItemResourceId, output);
769 int statusCode = res.getStatus();
771 // Check the status code of the response: does it match the expected response(s)?
772 if(logger.isDebugEnabled()){
773 logger.debug("updateItem: status = " + statusCode);
775 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
776 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
777 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
779 // Retrieve the updated resource and verify that its contents exist.
780 input = (MultipartInput) res.getEntity();
782 res.releaseConnection();
786 (PersonsCommon) extractPart(input,
787 client.getItemCommonPartName(), PersonsCommon.class);
788 Assert.assertNotNull(updatedPerson);
790 // Verify that the updated resource received the correct data.
791 Assert.assertEquals(updatedPerson.isDisplayNameComputed(), false,
792 "Updated displayNameComputed in Person did not match submitted data.");
793 // Verify that the updated resource computes the right displayName.
794 Assert.assertEquals(updatedPerson.getDisplayName(),
796 "Updated DisplayName (not computed) in Person not stored.");
800 * Verify illegal item display name.
802 * @param testName the test name
803 * @throws Exception the exception
805 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
806 dependsOnMethods = {"verifyItemDisplayName"})
807 public void verifyIllegalItemDisplayName(String testName) throws Exception {
810 setupUpdateWithWrongXmlSchema(testName);
812 // Submit the request to the service and store the response.
813 PersonAuthorityClient client = new PersonAuthorityClient();
814 MultipartInput input = null;
815 ClientResponse<MultipartInput> res = client.readItem(knownResourceId, knownItemResourceId);
817 int statusCode = res.getStatus();
819 // Check the status code of the response: does it match
820 // the expected response(s)?
821 if(logger.isDebugEnabled()){
822 logger.debug(testName + ": status = " + statusCode);
824 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
825 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
826 Assert.assertEquals(statusCode, Response.Status.OK.getStatusCode());
828 // Check whether Person has expected displayName.
829 input = (MultipartInput) res.getEntity();
831 res.releaseConnection();
834 PersonsCommon person = (PersonsCommon) extractPart(input,
835 client.getItemCommonPartName(), PersonsCommon.class);
836 Assert.assertNotNull(person);
837 // Try to Update with computed false and no displayName
838 person.setDisplayNameComputed(false);
839 person.setDisplayName(null);
841 // Submit the updated resource to the service and store the response.
842 MultipartOutput output = new MultipartOutput();
843 OutputPart commonPart = output.addPart(person, MediaType.APPLICATION_XML_TYPE);
844 commonPart.getHeaders().add("label", client.getItemCommonPartName());
845 res = client.updateItem(knownResourceId, knownItemResourceId, output);
847 int statusCode = res.getStatus();
849 // Check the status code of the response: does it match the expected response(s)?
850 if(logger.isDebugEnabled()){
851 logger.debug("updateItem: status = " + statusCode);
853 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
854 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
855 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
857 res.releaseConnection();
864 * @param testName the test name
865 * @throws Exception the exception
867 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
868 groups = {"read"}, dependsOnMethods = {"readItem"})
869 public void readContact(String testName) throws Exception {
873 // Submit the request to the service and store the response.
874 PersonAuthorityClient client = new PersonAuthorityClient();
875 MultipartInput input = null;
876 ClientResponse<MultipartInput> res =
877 client.readContact(knownResourceId, knownItemResourceId,
878 knownContactResourceId);
880 int statusCode = res.getStatus();
882 // Check the status code of the response: does it match
883 // the expected response(s)?
884 if(logger.isDebugEnabled()){
885 logger.debug(testName + ": status = " + statusCode);
887 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
888 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
889 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
891 // Check whether we've received a contact.
892 input = (MultipartInput) res.getEntity();
894 res.releaseConnection();
897 ContactsCommon contact = (ContactsCommon) extractPart(input,
898 new ContactClient().getCommonPartName(), ContactsCommon.class);
899 Assert.assertNotNull(contact);
900 boolean showFull = true;
901 if(showFull && logger.isDebugEnabled()){
902 logger.debug(testName + ": returned payload:");
903 logger.debug(objectAsXmlString(contact, ContactsCommon.class));
905 Assert.assertEquals(contact.getInAuthority(), knownResourceId);
906 Assert.assertEquals(contact.getInItem(), knownItemResourceId);
912 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
915 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
916 groups = {"read"}, dependsOnMethods = {"read"})
917 public void readNonExistent(String testName) {
920 setupReadNonExistent(testName);
922 // Submit the request to the service and store the response.
923 PersonAuthorityClient client = new PersonAuthorityClient();
924 ClientResponse<MultipartInput> res = client.read(NON_EXISTENT_ID);
926 int statusCode = res.getStatus();
927 // Check the status code of the response: does it match
928 // the expected response(s)?
929 if(logger.isDebugEnabled()){
930 logger.debug(testName + ": status = " + statusCode);
932 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
933 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
934 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
936 res.releaseConnection();
941 * Read item non existent.
943 * @param testName the test name
945 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
946 groups = {"read"}, dependsOnMethods = {"readItem"})
947 public void readItemNonExistent(String testName) {
950 setupReadNonExistent(testName);
952 // Submit the request to the service and store the response.
953 PersonAuthorityClient client = new PersonAuthorityClient();
954 ClientResponse<MultipartInput> res = client.readItem(knownResourceId, NON_EXISTENT_ID);
956 int statusCode = res.getStatus();
958 // Check the status code of the response: does it match
959 // the expected response(s)?
960 if(logger.isDebugEnabled()){
961 logger.debug(testName + ": status = " + statusCode);
963 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
964 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
965 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
967 res.releaseConnection();
972 * Read contact non existent.
974 * @param testName the test name
976 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
977 groups = {"read"}, dependsOnMethods = {"readContact"})
978 public void readContactNonExistent(String testName) {
981 setupReadNonExistent(testName);
983 // Submit the request to the service and store the response.
984 PersonAuthorityClient client = new PersonAuthorityClient();
985 ClientResponse<MultipartInput> res =
986 client.readContact(knownResourceId, knownItemResourceId, NON_EXISTENT_ID);
988 int statusCode = res.getStatus();
990 // Check the status code of the response: does it match
991 // the expected response(s)?
992 if(logger.isDebugEnabled()){
993 logger.debug(testName + ": status = " + statusCode);
995 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
996 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
997 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
999 res.releaseConnection();
1003 // ---------------------------------------------------------------
1004 // CRUD tests : READ_LIST tests
1005 // ---------------------------------------------------------------
1009 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
1012 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1013 groups = {"readList"}, dependsOnGroups = {"createList", "read"})
1014 public void readList(String testName) throws Exception {
1017 setupReadList(testName);
1019 // Submit the request to the service and store the response.
1020 PersonAuthorityClient client = new PersonAuthorityClient();
1021 PersonauthoritiesCommonList list = null;
1022 ClientResponse<PersonauthoritiesCommonList> res = client.readList();
1024 int statusCode = res.getStatus();
1026 // Check the status code of the response: does it match
1027 // the expected response(s)?
1028 if(logger.isDebugEnabled()){
1029 logger.debug(testName + ": status = " + statusCode);
1031 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1032 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1033 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1035 list = res.getEntity();
1037 res.releaseConnection();
1040 // Optionally output additional data about list members for debugging.
1041 boolean iterateThroughList = false;
1042 if (iterateThroughList && logger.isDebugEnabled()) {
1043 List<PersonauthoritiesCommonList.PersonauthorityListItem> items =
1044 list.getPersonauthorityListItem();
1046 for (PersonauthoritiesCommonList.PersonauthorityListItem item : items) {
1047 String csid = item.getCsid();
1048 logger.debug(testName + ": list-item[" + i + "] csid=" +
1050 logger.debug(testName + ": list-item[" + i + "] displayName=" +
1051 item.getDisplayName());
1052 logger.debug(testName + ": list-item[" + i + "] URI=" +
1054 readItemList(csid, null);
1063 @Test(groups = {"readList"}, dependsOnMethods = {"readList"})
1064 public void readItemList() {
1065 readItemList(knownResourceId, null);
1069 * Read item list by authority name.
1071 @Test(groups = {"readList"}, dependsOnMethods = {"readItemList"})
1072 public void readItemListByAuthorityName() {
1073 readItemList(null, knownResourceDisplayName);
1079 * @param vcsid the vcsid
1080 * @param name the name
1082 private void readItemList(String vcsid, String name) {
1084 final String testName = "readItemList";
1087 setupReadList(testName);
1089 // Submit the request to the service and store the response.
1090 PersonAuthorityClient client = new PersonAuthorityClient();
1091 ClientResponse<PersonsCommonList> res = null;
1093 res = client.readItemList(vcsid);
1094 } else if (name!= null) {
1095 res = client.readItemListForNamedAuthority(name);
1097 Assert.fail("readItemList passed null csid and name!");
1099 PersonsCommonList list = null;
1101 int statusCode = res.getStatus();
1103 // Check the status code of the response: does it match
1104 // the expected response(s)?
1105 if(logger.isDebugEnabled()){
1106 logger.debug(testName + ": status = " + statusCode);
1108 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1109 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1110 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1112 list = res.getEntity();
1114 res.releaseConnection();
1117 List<PersonsCommonList.PersonListItem> items =
1118 list.getPersonListItem();
1119 int nItemsReturned = items.size();
1120 // There will be one item created, associated with a
1121 // known parent resource, by the createItem test.
1123 // In addition, there will be 'nItemsToCreateInList'
1124 // additional items created by the createItemList test,
1125 // all associated with the same parent resource.
1126 int nExpectedItems = nItemsToCreateInList + 1;
1127 if(logger.isDebugEnabled()){
1128 logger.debug(testName + ": Expected "
1129 + nExpectedItems +" items; got: "+nItemsReturned);
1131 Assert.assertEquals(nItemsReturned, nExpectedItems);
1134 for (PersonsCommonList.PersonListItem item : items) {
1135 Assert.assertTrue((null != item.getRefName()), "Item refName is null!");
1136 Assert.assertTrue((null != item.getDisplayName()), "Item displayName is null!");
1137 // Optionally output additional data about list members for debugging.
1138 boolean showDetails = true;
1139 if (showDetails && logger.isDebugEnabled()) {
1140 logger.debug(" " + testName + ": list-item[" + i + "] csid=" +
1142 logger.debug(" " + testName + ": list-item[" + i + "] refName=" +
1144 logger.debug(" " + testName + ": list-item[" + i + "] displayName=" +
1145 item.getDisplayName());
1146 logger.debug(" " + testName + ": list-item[" + i + "] URI=" +
1154 * Read contact list.
1156 @Test(groups = {"readList"}, dependsOnMethods = {"readItemList"})
1157 public void readContactList() {
1158 readContactList(knownResourceId, knownItemResourceId);
1162 * Read contact list.
1164 * @param parentcsid the parentcsid
1165 * @param itemcsid the itemcsid
1167 private void readContactList(String parentcsid, String itemcsid) {
1168 final String testName = "readContactList";
1171 setupReadList(testName);
1173 // Submit the request to the service and store the response.
1174 PersonAuthorityClient client = new PersonAuthorityClient();
1175 ContactsCommonList list = null;
1176 ClientResponse<ContactsCommonList> res =
1177 client.readContactList(parentcsid, itemcsid);
1179 int statusCode = res.getStatus();
1181 // Check the status code of the response: does it match
1182 // the expected response(s)?
1183 if(logger.isDebugEnabled()){
1184 logger.debug(testName + ": status = " + statusCode);
1186 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1187 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1188 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1190 list = res.getEntity();
1192 res.releaseConnection();
1195 List<ContactsCommonList.ContactListItem> listitems =
1196 list.getContactListItem();
1197 int nItemsReturned = listitems.size();
1198 // There will be one item created, associated with a
1199 // known parent resource, by the createItem test.
1201 // In addition, there will be 'nItemsToCreateInList'
1202 // additional items created by the createItemList test,
1203 // all associated with the same parent resource.
1204 int nExpectedItems = nItemsToCreateInList + 1;
1205 if(logger.isDebugEnabled()){
1206 logger.debug(testName + ": Expected "
1207 + nExpectedItems +" items; got: "+nItemsReturned);
1209 Assert.assertEquals(nItemsReturned, nExpectedItems);
1212 for (ContactsCommonList.ContactListItem listitem : listitems) {
1213 // Optionally output additional data about list members for debugging.
1214 boolean showDetails = false;
1215 if (showDetails && logger.isDebugEnabled()) {
1216 logger.debug(" " + testName + ": list-item[" + i + "] csid=" +
1217 listitem.getCsid());
1218 logger.debug(" " + testName + ": list-item[" + i + "] addressPlace=" +
1219 listitem.getAddressPlace());
1220 logger.debug(" " + testName + ": list-item[" + i + "] URI=" +
1230 // ---------------------------------------------------------------
1231 // CRUD tests : UPDATE tests
1232 // ---------------------------------------------------------------
1235 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
1238 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1239 groups = {"update"}, dependsOnGroups = {"read", "readList"})
1240 public void update(String testName) throws Exception {
1243 setupUpdate(testName);
1245 // Retrieve the contents of a resource to update.
1246 PersonAuthorityClient client = new PersonAuthorityClient();
1247 MultipartInput input = null;
1248 ClientResponse<MultipartInput> res = client.read(knownResourceId);
1250 if(logger.isDebugEnabled()){
1251 logger.debug(testName + ": read status = " + res.getStatus());
1253 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
1255 if(logger.isDebugEnabled()){
1256 logger.debug("got PersonAuthority to update with ID: " + knownResourceId);
1258 input = res.getEntity();
1260 res.releaseConnection();
1263 PersonauthoritiesCommon personAuthority = (PersonauthoritiesCommon) extractPart(input,
1264 client.getCommonPartName(), PersonauthoritiesCommon.class);
1265 Assert.assertNotNull(personAuthority);
1267 // Update the contents of this resource.
1268 personAuthority.setDisplayName("updated-" + personAuthority.getDisplayName());
1269 personAuthority.setVocabType("updated-" + personAuthority.getVocabType());
1270 if(logger.isDebugEnabled()){
1271 logger.debug("to be updated PersonAuthority");
1272 logger.debug(objectAsXmlString(personAuthority, PersonauthoritiesCommon.class));
1275 // Submit the updated resource to the service and store the response.
1276 MultipartOutput output = new MultipartOutput();
1277 OutputPart commonPart = output.addPart(personAuthority, MediaType.APPLICATION_XML_TYPE);
1278 commonPart.getHeaders().add("label", client.getCommonPartName());
1279 res = client.update(knownResourceId, output);
1281 int statusCode = res.getStatus();
1283 // Check the status code of the response: does it match the expected response(s)?
1284 if(logger.isDebugEnabled()){
1285 logger.debug(testName + ": status = " + statusCode);
1287 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1288 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1289 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1291 // Retrieve the updated resource and verify that its contents exist.
1292 input = (MultipartInput) res.getEntity();
1294 res.releaseConnection();
1297 PersonauthoritiesCommon updatedPersonAuthority =
1298 (PersonauthoritiesCommon) extractPart(input,
1299 client.getCommonPartName(), PersonauthoritiesCommon.class);
1300 Assert.assertNotNull(updatedPersonAuthority);
1302 // Verify that the updated resource received the correct data.
1303 Assert.assertEquals(updatedPersonAuthority.getDisplayName(),
1304 personAuthority.getDisplayName(),
1305 "Data in updated object did not match submitted data.");
1311 * @param testName the test name
1312 * @throws Exception the exception
1314 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1315 groups = {"update"}, dependsOnMethods = {"update"})
1316 public void updateItem(String testName) throws Exception {
1319 setupUpdate(testName);
1321 // Retrieve the contents of a resource to update.
1322 PersonAuthorityClient client = new PersonAuthorityClient();
1323 MultipartInput input = null;
1324 ClientResponse<MultipartInput> res =
1325 client.readItem(knownResourceId, knownItemResourceId);
1327 if(logger.isDebugEnabled()){
1328 logger.debug(testName + ": read status = " + res.getStatus());
1330 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
1332 if(logger.isDebugEnabled()){
1333 logger.debug("got Person to update with ID: " +
1334 knownItemResourceId +
1335 " in PersonAuthority: " + knownResourceId );
1337 input = res.getEntity();
1339 res.releaseConnection();
1342 PersonsCommon person = (PersonsCommon) extractPart(input,
1343 client.getItemCommonPartName(), PersonsCommon.class);
1344 Assert.assertNotNull(person);
1346 // Update the contents of this resource.
1347 person.setCsid(null);
1348 person.setForeName("updated-" + person.getForeName());
1349 if(logger.isDebugEnabled()){
1350 logger.debug("to be updated Person");
1351 logger.debug(objectAsXmlString(person,
1352 PersonsCommon.class));
1355 // Submit the updated resource to the service and store the response.
1356 MultipartOutput output = new MultipartOutput();
1357 OutputPart commonPart = output.addPart(person, MediaType.APPLICATION_XML_TYPE);
1358 commonPart.getHeaders().add("label", client.getItemCommonPartName());
1359 res = client.updateItem(knownResourceId, knownItemResourceId, output);
1361 int statusCode = res.getStatus();
1363 // Check the status code of the response: does it match the expected response(s)?
1364 if(logger.isDebugEnabled()){
1365 logger.debug(testName + ": status = " + statusCode);
1367 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1368 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1369 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1371 // Retrieve the updated resource and verify that its contents exist.
1372 input = (MultipartInput) res.getEntity();
1374 res.releaseConnection();
1377 PersonsCommon updatedPerson =
1378 (PersonsCommon) extractPart(input,
1379 client.getItemCommonPartName(), PersonsCommon.class);
1380 Assert.assertNotNull(updatedPerson);
1382 // Verify that the updated resource received the correct data.
1383 Assert.assertEquals(updatedPerson.getForeName(),
1384 person.getForeName(),
1385 "Data in updated Person did not match submitted data.");
1391 * @param testName the test name
1392 * @throws Exception the exception
1394 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1395 groups = {"update"}, dependsOnMethods = {"updateItem"})
1396 public void updateContact(String testName) throws Exception {
1398 setupUpdate(testName);
1400 // Retrieve the contents of a resource to update.
1401 PersonAuthorityClient client = new PersonAuthorityClient();
1402 MultipartInput input = null;
1403 ClientResponse<MultipartInput> res =
1404 client.readContact(knownResourceId, knownItemResourceId, knownContactResourceId);
1406 if(logger.isDebugEnabled()){
1407 logger.debug(testName + ": read status = " + res.getStatus());
1409 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
1411 if(logger.isDebugEnabled()){
1412 logger.debug("got Contact to update with ID: " +
1413 knownContactResourceId +
1414 " in item: " + knownItemResourceId +
1415 " in parent: " + knownResourceId );
1417 input = res.getEntity();
1419 res.releaseConnection();
1422 ContactsCommon contact = (ContactsCommon) extractPart(input,
1423 new ContactClient().getCommonPartName(), ContactsCommon.class);
1424 Assert.assertNotNull(contact);
1426 // Update the contents of this resource.
1427 contact.setAddressPlace("updated-" + contact.getAddressPlace());
1428 if(logger.isDebugEnabled()){
1429 logger.debug("to be updated Contact");
1430 logger.debug(objectAsXmlString(contact,
1431 ContactsCommon.class));
1434 // Submit the updated resource to the service and store the response.
1435 MultipartOutput output = new MultipartOutput();
1436 OutputPart commonPart = output.addPart(contact, MediaType.APPLICATION_XML_TYPE);
1437 commonPart.getHeaders().add("label", new ContactClient().getCommonPartName());
1438 res = client.updateContact(knownResourceId, knownItemResourceId, knownContactResourceId, output);
1440 int statusCode = res.getStatus();
1442 // Check the status code of the response: does it match the expected response(s)?
1443 if(logger.isDebugEnabled()){
1444 logger.debug(testName + ": status = " + statusCode);
1446 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1447 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1448 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1450 // Retrieve the updated resource and verify that its contents exist.
1451 input = (MultipartInput) res.getEntity();
1453 res.releaseConnection();
1455 ContactsCommon updatedContact =
1456 (ContactsCommon) extractPart(input,
1457 new ContactClient().getCommonPartName(), ContactsCommon.class);
1458 Assert.assertNotNull(updatedContact);
1460 // Verify that the updated resource received the correct data.
1461 Assert.assertEquals(updatedContact.getAddressPlace(),
1462 contact.getAddressPlace(),
1463 "Data in updated Contact did not match submitted data.");
1467 // Placeholders until the three tests below can be uncommented.
1468 // See Issue CSPACE-401.
1470 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
1473 public void updateWithEmptyEntityBody(String testName) throws Exception {
1474 //Should this really be empty?
1478 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
1481 public void updateWithMalformedXml(String testName) throws Exception {
1482 //Should this really be empty?
1486 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
1489 public void updateWithWrongXmlSchema(String testName) throws Exception {
1490 //Should this really be empty?
1495 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
1496 groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
1497 public void updateWithEmptyEntityBody(String testName) throws Exception {
1500 setupUpdateWithEmptyEntityBody(testName);
1502 // Submit the request to the service and store the response.
1503 String method = REQUEST_TYPE.httpMethodName();
1504 String url = getResourceURL(knownResourceId);
1505 String mediaType = MediaType.APPLICATION_XML;
1506 final String entity = "";
1507 int statusCode = submitRequest(method, url, mediaType, entity);
1509 // Check the status code of the response: does it match
1510 // the expected response(s)?
1511 if(logger.isDebugEnabled()){
1512 logger.debug(testName + ": url=" + url +
1513 " status=" + statusCode);
1515 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1516 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1517 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1521 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
1522 groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
1523 public void updateWithMalformedXml(String testName) throws Exception {
1526 setupUpdateWithMalformedXml(testName);
1528 // Submit the request to the service and store the response.
1529 String method = REQUEST_TYPE.httpMethodName();
1530 String url = getResourceURL(knownResourceId);
1531 String mediaType = MediaType.APPLICATION_XML;
1532 final String entity = MALFORMED_XML_DATA;
1533 int statusCode = submitRequest(method, url, mediaType, entity);
1535 // Check the status code of the response: does it match
1536 // the expected response(s)?
1537 if(logger.isDebugEnabled()){
1538 logger.debug(testName + ": url=" + url +
1539 " status=" + statusCode);
1541 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1542 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1543 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1547 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
1548 groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
1549 public void updateWithWrongXmlSchema(String testName) throws Exception {
1552 setupUpdateWithWrongXmlSchema(testName);
1554 // Submit the request to the service and store the response.
1555 String method = REQUEST_TYPE.httpMethodName();
1556 String url = getResourceURL(knownResourceId);
1557 String mediaType = MediaType.APPLICATION_XML;
1558 final String entity = WRONG_XML_SCHEMA_DATA;
1559 int statusCode = submitRequest(method, url, mediaType, entity);
1561 // Check the status code of the response: does it match
1562 // the expected response(s)?
1563 if(logger.isDebugEnabled()){
1564 logger.debug("updateWithWrongXmlSchema: url=" + url +
1565 " status=" + statusCode);
1567 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1568 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1569 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1574 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
1577 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1578 groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
1579 public void updateNonExistent(String testName) throws Exception {
1582 setupUpdateNonExistent(testName);
1584 // Submit the request to the service and store the response.
1585 // Note: The ID(s) used when creating the request payload may be arbitrary.
1586 // The only relevant ID may be the one used in update(), below.
1587 PersonAuthorityClient client = new PersonAuthorityClient();
1588 String displayName = "displayName-NON_EXISTENT_ID";
1589 String fullRefName = PersonAuthorityClientUtils.createPersonAuthRefName(displayName, true);
1590 MultipartOutput multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance(
1591 displayName, fullRefName, client.getCommonPartName());
1592 ClientResponse<MultipartInput> res =
1593 client.update(NON_EXISTENT_ID, multipart);
1595 int statusCode = res.getStatus();
1597 // Check the status code of the response: does it match
1598 // the expected response(s)?
1599 if(logger.isDebugEnabled()){
1600 logger.debug(testName + ": status = " + statusCode);
1602 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1603 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1604 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1606 res.releaseConnection();
1611 * Update non existent item.
1613 * @param testName the test name
1614 * @throws Exception the exception
1616 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1617 groups = {"update"}, dependsOnMethods = {"updateItem", "testItemSubmitRequest"})
1618 public void updateNonExistentItem(String testName) throws Exception {
1621 setupUpdateNonExistent(testName);
1623 // Submit the request to the service and store the response.
1624 // Note: The ID used in this 'create' call may be arbitrary.
1625 // The only relevant ID may be the one used in update(), below.
1626 PersonAuthorityClient client = new PersonAuthorityClient();
1627 Map<String, String> nonexMap = new HashMap<String,String>();
1628 nonexMap.put(PersonJAXBSchema.FORE_NAME, "John");
1629 nonexMap.put(PersonJAXBSchema.SUR_NAME, "Wayne");
1630 nonexMap.put(PersonJAXBSchema.GENDER, "male");
1631 MultipartOutput multipart =
1632 PersonAuthorityClientUtils.createPersonInstance(NON_EXISTENT_ID,
1633 PersonAuthorityClientUtils.createPersonRefName(NON_EXISTENT_ID, NON_EXISTENT_ID, true), nonexMap,
1634 client.getItemCommonPartName() );
1635 ClientResponse<MultipartInput> res =
1636 client.updateItem(knownResourceId, NON_EXISTENT_ID, multipart);
1638 int statusCode = res.getStatus();
1640 // Check the status code of the response: does it match
1641 // the expected response(s)?
1642 if(logger.isDebugEnabled()){
1643 logger.debug(testName + ": status = " + statusCode);
1645 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1646 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1647 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1649 res.releaseConnection();
1654 * Update non existent contact.
1656 * @param testName the test name
1657 * @throws Exception the exception
1659 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1660 groups = {"update"}, dependsOnMethods = {"updateContact", "testContactSubmitRequest"})
1661 public void updateNonExistentContact(String testName) throws Exception {
1662 // Currently a no-op test
1665 // ---------------------------------------------------------------
1666 // CRUD tests : DELETE tests
1667 // ---------------------------------------------------------------
1670 // Note: delete sub-resources in ascending hierarchical order,
1671 // before deleting their parents.
1676 * @param testName the test name
1677 * @throws Exception the exception
1679 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1680 groups = {"delete"}, dependsOnGroups = {"create", "read", "readList", "update"})
1681 public void deleteContact(String testName) throws Exception {
1684 setupDelete(testName);
1686 if(logger.isDebugEnabled()){
1687 logger.debug("parentcsid =" + knownResourceId +
1688 " itemcsid = " + knownItemResourceId +
1689 " csid = " + knownContactResourceId);
1692 // Submit the request to the service and store the response.
1693 PersonAuthorityClient client = new PersonAuthorityClient();
1694 ClientResponse<Response> res =
1695 client.deleteContact(knownResourceId, knownItemResourceId, knownContactResourceId);
1696 int statusCode = res.getStatus();
1697 res.releaseConnection();
1699 // Check the status code of the response: does it match
1700 // the expected response(s)?
1701 if(logger.isDebugEnabled()){
1702 logger.debug(testName + ": status = " + statusCode);
1704 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1705 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1706 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1712 * @param testName the test name
1713 * @throws Exception the exception
1715 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1716 groups = {"delete"}, dependsOnMethods = {"deleteContact"})
1717 public void deleteItem(String testName) throws Exception {
1720 setupDelete(testName);
1722 if(logger.isDebugEnabled()){
1723 logger.debug("parentcsid =" + knownResourceId +
1724 " itemcsid = " + knownItemResourceId);
1727 // Submit the request to the service and store the response.
1728 PersonAuthorityClient client = new PersonAuthorityClient();
1729 ClientResponse<Response> res = client.deleteItem(knownResourceId, knownItemResourceId);
1730 int statusCode = res.getStatus();
1731 res.releaseConnection();
1733 // Check the status code of the response: does it match
1734 // the expected response(s)?
1735 if(logger.isDebugEnabled()){
1736 logger.debug(testName + ": status = " + statusCode);
1738 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1739 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1740 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1744 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
1747 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1748 groups = {"delete"}, dependsOnMethods = {"deleteItem"})
1749 public void delete(String testName) throws Exception {
1752 setupDelete(testName);
1754 if(logger.isDebugEnabled()){
1755 logger.debug("parentcsid =" + knownResourceId);
1758 // Submit the request to the service and store the response.
1759 PersonAuthorityClient client = new PersonAuthorityClient();
1760 ClientResponse<Response> res = client.delete(knownResourceId);
1761 int statusCode = res.getStatus();
1762 res.releaseConnection();
1764 // Check the status code of the response: does it match
1765 // the expected response(s)?
1766 if(logger.isDebugEnabled()){
1767 logger.debug(testName + ": status = " + statusCode);
1769 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1770 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1771 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1776 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
1779 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1780 groups = {"delete"}, dependsOnMethods = {"delete"})
1781 public void deleteNonExistent(String testName) throws Exception {
1784 setupDeleteNonExistent(testName);
1786 // Submit the request to the service and store the response.
1787 PersonAuthorityClient client = new PersonAuthorityClient();
1788 ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
1789 int statusCode = res.getStatus();
1790 res.releaseConnection();
1792 // Check the status code of the response: does it match
1793 // the expected response(s)?
1794 if(logger.isDebugEnabled()){
1795 logger.debug(testName + ": status = " + statusCode);
1797 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1798 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1799 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1803 * Delete non existent item.
1805 * @param testName the test name
1807 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1808 groups = {"delete"}, dependsOnMethods = {"deleteItem"})
1809 public void deleteNonExistentItem(String testName) {
1812 setupDeleteNonExistent(testName);
1814 // Submit the request to the service and store the response.
1815 PersonAuthorityClient client = new PersonAuthorityClient();
1816 ClientResponse<Response> res = client.deleteItem(knownResourceId, NON_EXISTENT_ID);
1817 int statusCode = res.getStatus();
1818 res.releaseConnection();
1820 // Check the status code of the response: does it match
1821 // the expected response(s)?
1822 if(logger.isDebugEnabled()){
1823 logger.debug(testName + ": status = " + statusCode);
1825 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1826 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1827 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1831 * Delete non existent contact.
1833 * @param testName the test name
1835 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1836 groups = {"delete"}, dependsOnMethods = {"deleteContact"})
1837 public void deleteNonExistentContact(String testName) {
1840 setupDeleteNonExistent(testName);
1842 // Submit the request to the service and store the response.
1843 PersonAuthorityClient client = new PersonAuthorityClient();
1844 ClientResponse<Response> res =
1845 client.deleteContact(knownResourceId, knownItemResourceId, NON_EXISTENT_ID);
1846 int statusCode = res.getStatus();
1847 res.releaseConnection();
1849 // Check the status code of the response: does it match
1850 // the expected response(s)?
1851 if(logger.isDebugEnabled()){
1852 logger.debug(testName + ": status = " + statusCode);
1854 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1855 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1856 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1859 // ---------------------------------------------------------------
1860 // Utility tests : tests of code used in tests above
1861 // ---------------------------------------------------------------
1863 * Tests the code for manually submitting data that is used by several
1864 * of the methods above.
1866 @Test(dependsOnMethods = {"create", "read"})
1867 public void testSubmitRequest() {
1869 // Expected status code: 200 OK
1870 final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
1872 // Submit the request to the service and store the response.
1873 String method = ServiceRequestType.READ.httpMethodName();
1874 String url = getResourceURL(knownResourceId);
1875 int statusCode = submitRequest(method, url);
1877 // Check the status code of the response: does it match
1878 // the expected response(s)?
1879 if(logger.isDebugEnabled()){
1880 logger.debug("testSubmitRequest: url=" + url +
1881 " status=" + statusCode);
1883 Assert.assertEquals(statusCode, EXPECTED_STATUS);
1888 * Test item submit request.
1890 @Test(dependsOnMethods = {"createItem", "readItem", "testSubmitRequest"})
1891 public void testItemSubmitRequest() {
1893 // Expected status code: 200 OK
1894 final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
1896 // Submit the request to the service and store the response.
1897 String method = ServiceRequestType.READ.httpMethodName();
1898 String url = getItemResourceURL(knownResourceId, knownItemResourceId);
1899 int statusCode = submitRequest(method, url);
1901 // Check the status code of the response: does it match
1902 // the expected response(s)?
1903 if(logger.isDebugEnabled()){
1904 logger.debug("testItemSubmitRequest: url=" + url +
1905 " status=" + statusCode);
1907 Assert.assertEquals(statusCode, EXPECTED_STATUS);
1912 * Test contact submit request.
1914 @Test(dependsOnMethods = {"createContact", "readContact", "testItemSubmitRequest"})
1915 public void testContactSubmitRequest() {
1917 // Expected status code: 200 OK
1918 final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
1920 // Submit the request to the service and store the response.
1921 String method = ServiceRequestType.READ.httpMethodName();
1922 String url = getContactResourceURL(knownResourceId,
1923 knownItemResourceId, knownContactResourceId);
1924 int statusCode = submitRequest(method, url);
1926 // Check the status code of the response: does it match
1927 // the expected response(s)?
1928 if(logger.isDebugEnabled()){
1929 logger.debug("testItemSubmitRequest: url=" + url +
1930 " status=" + statusCode);
1932 Assert.assertEquals(statusCode, EXPECTED_STATUS);
1937 // ---------------------------------------------------------------
1938 // Cleanup of resources created during testing
1939 // ---------------------------------------------------------------
1942 * Deletes all resources created by tests, after all tests have been run.
1944 * This cleanup method will always be run, even if one or more tests fail.
1945 * For this reason, it attempts to remove all resources created
1946 * at any point during testing, even if some of those resources
1947 * may be expected to be deleted by certain tests.
1950 @AfterClass(alwaysRun=true)
1952 public void cleanUp() {
1953 String noTest = System.getProperty("noTestCleanup");
1954 if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
1955 if (logger.isDebugEnabled()) {
1956 logger.debug("Skipping Cleanup phase ...");
1960 if (logger.isDebugEnabled()) {
1961 logger.debug("Cleaning up temporary resources created for testing ...");
1963 String parentResourceId;
1964 String itemResourceId;
1965 String contactResourceId;
1966 // Clean up contact resources.
1967 PersonAuthorityClient client = new PersonAuthorityClient();
1968 parentResourceId = knownResourceId;
1969 for (Map.Entry<String, String> entry : allContactResourceIdsCreated.entrySet()) {
1970 contactResourceId = entry.getKey();
1971 itemResourceId = entry.getValue();
1972 // Note: Any non-success responses from the delete operation
1973 // below are ignored and not reported.
1974 ClientResponse<Response> res =
1975 client.deleteContact(parentResourceId, itemResourceId, contactResourceId);
1976 res.releaseConnection();
1978 // Clean up item resources.
1979 for (Map.Entry<String, String> entry : allItemResourceIdsCreated.entrySet()) {
1980 itemResourceId = entry.getKey();
1981 parentResourceId = entry.getValue();
1982 // Note: Any non-success responses from the delete operation
1983 // below are ignored and not reported.
1984 ClientResponse<Response> res =
1985 client.deleteItem(parentResourceId, itemResourceId);
1986 res.releaseConnection();
1988 // Clean up parent resources.
1992 // ---------------------------------------------------------------
1993 // Utility methods used by tests above
1994 // ---------------------------------------------------------------
1996 * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
1999 public String getServicePathComponent() {
2000 return SERVICE_PATH_COMPONENT;
2004 * Gets the item service path component.
2006 * @return the item service path component
2008 public String getItemServicePathComponent() {
2009 return ITEM_SERVICE_PATH_COMPONENT;
2013 * Gets the contact service path component.
2015 * @return the contact service path component
2017 public String getContactServicePathComponent() {
2018 return CONTACT_SERVICE_PATH_COMPONENT;
2022 * Returns the root URL for the item service.
2024 * This URL consists of a base URL for all services, followed by
2025 * a path component for the owning parent, followed by the
2026 * path component for the items.
2028 * @param parentResourceIdentifier An identifier (such as a UUID) for the
2029 * parent authority resource of the relevant item resource.
2031 * @return The root URL for the item service.
2033 protected String getItemServiceRootURL(String parentResourceIdentifier) {
2034 return getResourceURL(parentResourceIdentifier) + "/" + getItemServicePathComponent();
2038 * Returns the URL of a specific item resource managed by a service, and
2039 * designated by an identifier (such as a universally unique ID, or UUID).
2041 * @param parentResourceIdentifier An identifier (such as a UUID) for the
2042 * parent authority resource of the relevant item resource.
2044 * @param itemResourceIdentifier An identifier (such as a UUID) for an
2047 * @return The URL of a specific item resource managed by a service.
2049 protected String getItemResourceURL(String parentResourceIdentifier, String itemResourceIdentifier) {
2050 return getItemServiceRootURL(parentResourceIdentifier) + "/" + itemResourceIdentifier;
2055 * Returns the root URL for the contact service.
2057 * This URL consists of a base URL for all services, followed by
2058 * a path component for the owning authority, followed by the
2059 * path component for the owning item, followed by the path component
2060 * for the contact service.
2062 * @param parentResourceIdentifier An identifier (such as a UUID) for the
2063 * parent authority resource of the relevant item resource.
2065 * @param itemResourceIdentifier An identifier (such as a UUID) for an
2068 * @return The root URL for the contact service.
2070 protected String getContactServiceRootURL(String parentResourceIdentifier,
2071 String itemResourceIdentifier) {
2072 return getItemResourceURL(parentResourceIdentifier, itemResourceIdentifier) + "/" +
2073 getContactServicePathComponent();
2077 * Returns the URL of a specific contact resource managed by a service, and
2078 * designated by an identifier (such as a universally unique ID, or UUID).
2080 * @param parentResourceIdentifier An identifier (such as a UUID) for the
2081 * parent resource of the relevant item resource.
2083 * @param resourceIdentifier An identifier (such as a UUID) for an
2086 * @return The URL of a specific resource managed by a service.
2088 protected String getContactResourceURL(String parentResourceIdentifier,
2089 String itemResourceIdentifier, String contactResourceIdentifier) {
2090 return getContactServiceRootURL(parentResourceIdentifier,
2091 itemResourceIdentifier) + "/" + contactResourceIdentifier;