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 service path component. */
69 final String SERVICE_PATH_COMPONENT = "personauthorities";
71 /** The item service path component. */
72 final String ITEM_SERVICE_PATH_COMPONENT = "items";
74 /** The contact service path component. */
75 final String CONTACT_SERVICE_PATH_COMPONENT = "contacts";
77 /** The test forename. */
78 final String TEST_FORE_NAME = "John";
80 /** The test middle name. */
81 final String TEST_MIDDLE_NAME = null;
83 /** The test surname. */
84 final String TEST_SUR_NAME = "Wayne";
86 /** The test birthdate. */
87 final String TEST_BIRTH_DATE = "May 26, 1907";
89 /** The test death 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 resource ID of an item resource used for partial term matching tests.
105 private String knownItemPartialTermResourceId = null;
107 /** The known contact resource id. */
108 private String knownContactResourceId = null;
110 /** The n items to create in list. */
111 private int nItemsToCreateInList = 3;
113 /** The all item resource ids created. */
114 private Map<String, String> allItemResourceIdsCreated =
115 new HashMap<String, String>();
117 /** The all contact resource ids created. */
118 private Map<String, String> allContactResourceIdsCreated =
119 new HashMap<String, String>();
122 * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
125 protected CollectionSpaceClient getClientInstance() {
126 return new PersonAuthorityClient();
130 * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
133 protected AbstractCommonList getAbstractCommonList(
134 ClientResponse<AbstractCommonList> response) {
135 return response.getEntity(PersonsCommonList.class);
138 // ---------------------------------------------------------------
139 // CRUD tests : CREATE tests
140 // ---------------------------------------------------------------
143 * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
146 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
148 public void create(String testName) throws Exception {
150 // Perform setup, such as initializing the type of service request
151 // (e.g. CREATE, DELETE), its valid and expected status codes, and
152 // its associated HTTP method name (e.g. POST, DELETE).
153 setupCreate(testName);
155 // Submit the request to the service and store the response.
156 PersonAuthorityClient client = new PersonAuthorityClient();
157 String identifier = createIdentifier();
158 String displayName = "displayName-" + identifier;
159 String baseRefName = PersonAuthorityClientUtils.createPersonAuthRefName(displayName, false);
160 String fullRefName = PersonAuthorityClientUtils.createPersonAuthRefName(displayName, true);
161 MultipartOutput multipart =
162 PersonAuthorityClientUtils.createPersonAuthorityInstance(
163 displayName, fullRefName, client.getCommonPartName());
166 ClientResponse<Response> res = client.create(multipart);
168 int statusCode = res.getStatus();
170 // Check the status code of the response: does it match
171 // the expected response(s)?
174 // Does it fall within the set of valid status codes?
175 // Does it exactly match the expected status code?
176 if(logger.isDebugEnabled()){
177 logger.debug(testName + ": status = " + statusCode);
179 Assert.assertTrue(this.REQUEST_TYPE.isValidStatusCode(statusCode),
180 invalidStatusCodeMessage(this.REQUEST_TYPE, statusCode));
181 Assert.assertEquals(statusCode, this.EXPECTED_STATUS_CODE);
183 newID = PersonAuthorityClientUtils.extractId(res);
185 res.releaseConnection();
187 // Store the refname from the first resource created
188 // for additional tests below.
189 knownResourceRefName = baseRefName;
190 // Store the ID returned from the first resource created
191 // for additional tests below.
192 if (knownResourceId == null){
193 knownResourceId = newID;
194 knownResourceDisplayName = displayName;
195 if (logger.isDebugEnabled()) {
196 logger.debug(testName + ": knownResourceId=" + knownResourceId);
199 // Store the IDs from every resource created by tests,
200 // so they can be deleted after tests have been run.
201 allResourceIdsCreated.add(newID);
207 * @param testName the test name
209 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
210 groups = {"create"}, dependsOnMethods = {"create"})
211 public void createItem(String testName) {
212 setupCreate(testName);
213 String newID = createItemInAuthority(knownResourceId, knownResourceRefName);
217 * Creates the item in authority.
219 * @param vcsid the vcsid
220 * @param authRefName the auth ref name
223 private String createItemInAuthority(String vcsid, String authRefName) {
225 final String testName = "createItemInAuthority";
226 if(logger.isDebugEnabled()){
227 logger.debug(testName + ":...");
230 // Submit the request to the service and store the response.
231 PersonAuthorityClient client = new PersonAuthorityClient();
232 String refName = PersonAuthorityClientUtils.createPersonRefName(authRefName, "John Wayne", true);
233 Map<String, String> johnWayneMap = new HashMap<String,String>();
235 // Fill the property map
237 johnWayneMap.put(PersonJAXBSchema.DISPLAY_NAME_COMPUTED, "false");
238 johnWayneMap.put(PersonJAXBSchema.DISPLAY_NAME, "John Wayne");
240 johnWayneMap.put(PersonJAXBSchema.FORE_NAME, TEST_FORE_NAME);
241 johnWayneMap.put(PersonJAXBSchema.SUR_NAME, TEST_SUR_NAME);
242 johnWayneMap.put(PersonJAXBSchema.GENDER, "male");
243 johnWayneMap.put(PersonJAXBSchema.BIRTH_DATE, TEST_BIRTH_DATE);
244 johnWayneMap.put(PersonJAXBSchema.BIRTH_PLACE, "Winterset, Iowa");
245 johnWayneMap.put(PersonJAXBSchema.DEATH_DATE, TEST_DEATH_DATE);
246 johnWayneMap.put(PersonJAXBSchema.BIO_NOTE, "born Marion Robert Morrison and better" +
247 "known by his stage name John Wayne, was an American film actor, director " +
248 "and producer. He epitomized rugged masculinity and has become an enduring " +
249 "American icon. He is famous for his distinctive voice, walk and height. " +
250 "He was also known for his conservative political views and his support in " +
251 "the 1950s for anti-communist positions.");
252 MultipartOutput multipart =
253 PersonAuthorityClientUtils.createPersonInstance(vcsid, refName, johnWayneMap,
254 client.getItemCommonPartName() );
257 ClientResponse<Response> res = client.createItem(vcsid, multipart);
259 int statusCode = res.getStatus();
260 // Check the status code of the response: does it match
261 // the expected response(s)?
262 if(logger.isDebugEnabled()){
263 logger.debug(testName + ": status = " + statusCode);
265 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
266 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
267 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
269 newID = PersonAuthorityClientUtils.extractId(res);
271 res.releaseConnection();
274 // Store the ID returned from the first item resource created
275 // for additional tests below.
276 if (knownItemResourceId == null){
277 knownItemResourceId = newID;
278 if (logger.isDebugEnabled()) {
279 logger.debug(testName + ": knownItemResourceId=" + knownItemResourceId);
283 // Store the IDs from any item resources created
284 // by tests, along with the IDs of their parents, so these items
285 // can be deleted after all tests have been run.
286 allItemResourceIdsCreated.put(newID, vcsid);
292 * Creates the contact.
294 * @param testName the test name
296 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
297 groups = {"create"}, dependsOnMethods = {"createItem"})
298 public void createContact(String testName) {
299 setupCreate(testName);
300 String newID = createContactInItem(knownResourceId, knownItemResourceId);
304 * Creates the contact in item.
306 * @param parentcsid the parentcsid
307 * @param itemcsid the itemcsid
310 private String createContactInItem(String parentcsid, String itemcsid) {
312 final String testName = "createContactInItem";
313 setupCreate(testName);
314 if(logger.isDebugEnabled()){
315 logger.debug(testName + ":...");
318 // Submit the request to the service and store the response.
319 PersonAuthorityClient client = new PersonAuthorityClient();
320 String identifier = createIdentifier();
321 MultipartOutput multipart =
322 ContactClientUtils.createContactInstance(parentcsid,
323 itemcsid, identifier, new ContactClient().getCommonPartName());
326 ClientResponse<Response> res =
327 client.createContact(parentcsid, itemcsid, multipart);
329 int statusCode = res.getStatus();
330 // Check the status code of the response: does it match
331 // the expected response(s)?
332 if(logger.isDebugEnabled()){
333 logger.debug(testName + ": status = " + statusCode);
335 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
336 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
337 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
339 newID = PersonAuthorityClientUtils.extractId(res);
341 res.releaseConnection();
344 // Store the ID returned from the first contact resource created
345 // for additional tests below.
346 if (knownContactResourceId == null){
347 knownContactResourceId = newID;
348 if (logger.isDebugEnabled()) {
349 logger.debug(testName + ": knownContactResourceId=" + knownContactResourceId);
353 // Store the IDs from any contact resources created
354 // by tests, along with the IDs of their parent items,
355 // so these items can be deleted after all tests have been run.
356 allContactResourceIdsCreated.put(newID, itemcsid);
363 // Placeholders until the three tests below can be uncommented.
364 // See Issue CSPACE-401.
366 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
369 public void createWithEmptyEntityBody(String testName) throws Exception {
370 //Should this really be empty?
374 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
377 public void createWithMalformedXml(String testName) throws Exception {
378 //Should this really be empty?
382 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
385 public void createWithWrongXmlSchema(String testName) throws Exception {
386 //Should this really be empty?
391 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
392 groups = {"create"}, dependsOnMethods = {"create", "testSubmitRequest"})
393 public void createWithEmptyEntityBody(String testName) throws Exception {
396 setupCreateWithEmptyEntityBody(testName);
398 // Submit the request to the service and store the response.
399 String method = REQUEST_TYPE.httpMethodName();
400 String url = getServiceRootURL();
401 String mediaType = MediaType.APPLICATION_XML;
402 final String entity = "";
403 int statusCode = submitRequest(method, url, mediaType, entity);
405 // Check the status code of the response: does it match
406 // the expected response(s)?
407 if(logger.isDebugEnabled()) {
408 logger.debug(testName + ": url=" + url +
409 " status=" + statusCode);
411 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
412 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
413 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
417 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
418 groups = {"create"}, dependsOnMethods = {"create", "testSubmitRequest"})
419 public void createWithMalformedXml(String testName) throws Exception {
422 setupCreateWithMalformedXml(testName);
424 // Submit the request to the service and store the response.
425 String method = REQUEST_TYPE.httpMethodName();
426 String url = getServiceRootURL();
427 String mediaType = MediaType.APPLICATION_XML;
428 final String entity = MALFORMED_XML_DATA; // Constant from base class.
429 int statusCode = submitRequest(method, url, mediaType, entity);
431 // Check the status code of the response: does it match
432 // the expected response(s)?
433 if(logger.isDebugEnabled()){
434 logger.debug(testName + ": url=" + url +
435 " status=" + statusCode);
437 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
438 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
439 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
443 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
444 groups = {"create"}, dependsOnMethods = {"create", "testSubmitRequest"})
445 public void createWithWrongXmlSchema(String testName) throws Exception {
448 setupCreateWithWrongXmlSchema(testName);
450 // Submit the request to the service and store the response.
451 String method = REQUEST_TYPE.httpMethodName();
452 String url = getServiceRootURL();
453 String mediaType = MediaType.APPLICATION_XML;
454 final String entity = WRONG_XML_SCHEMA_DATA;
455 int statusCode = submitRequest(method, url, mediaType, entity);
457 // Check the status code of the response: does it match
458 // the expected response(s)?
459 if(logger.isDebugEnabled()){
460 logger.debug(testName + ": url=" + url +
461 " status=" + statusCode);
463 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
464 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
465 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
469 // ---------------------------------------------------------------
470 // CRUD tests : CREATE LIST tests
471 // ---------------------------------------------------------------
474 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
477 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
478 groups = {"createList"}, dependsOnGroups = {"create"})
479 public void createList(String testName) throws Exception {
480 for (int i = 0; i < nItemsToCreateInList; i++) {
486 * Creates the item list.
488 * @param testName the test name
489 * @throws Exception the exception
491 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
492 groups = {"createList"}, dependsOnMethods = {"createList"})
493 public void createItemList(String testName) throws Exception {
494 // Add items to the initially-created, known parent record.
495 for (int j = 0; j < nItemsToCreateInList; j++) {
496 createItem(testName);
501 * Creates the contact list.
503 * @param testName the test name
504 * @throws Exception the exception
506 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
507 groups = {"createList"}, dependsOnMethods = {"createItemList"})
508 public void createContactList(String testName) throws Exception {
509 // Add contacts to the initially-created, known item record.
510 for (int j = 0; j < nItemsToCreateInList; j++) {
511 createContact(testName);
515 // ---------------------------------------------------------------
516 // CRUD tests : READ tests
517 // ---------------------------------------------------------------
520 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
523 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
524 groups = {"read"}, dependsOnGroups = {"create"})
525 public void read(String testName) throws Exception {
530 // Submit the request to the service and store the response.
531 PersonAuthorityClient client = new PersonAuthorityClient();
532 ClientResponse<MultipartInput> res = client.read(knownResourceId);
534 int statusCode = res.getStatus();
535 // Check the status code of the response: does it match
536 // the expected response(s)?
537 if(logger.isDebugEnabled()){
538 logger.debug(testName + ": status = " + statusCode);
540 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
541 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
542 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
543 //FIXME: remove the following try catch once Aron fixes signatures
545 MultipartInput input = (MultipartInput) res.getEntity();
546 PersonauthoritiesCommon personAuthority = (PersonauthoritiesCommon) extractPart(input,
547 client.getCommonPartName(), PersonauthoritiesCommon.class);
548 Assert.assertNotNull(personAuthority);
549 } catch (Exception e) {
550 throw new RuntimeException(e);
553 res.releaseConnection();
560 * @param testName the test name
561 * @throws Exception the exception
563 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
564 groups = {"read"}, dependsOnGroups = {"create"})
565 public void readByName(String testName) throws Exception {
570 // Submit the request to the service and store the response.
571 PersonAuthorityClient client = new PersonAuthorityClient();
572 ClientResponse<MultipartInput> res = client.readByName(knownResourceDisplayName);
574 int statusCode = res.getStatus();
575 // Check the status code of the response: does it match
576 // the expected response(s)?
577 if(logger.isDebugEnabled()){
578 logger.debug(testName + ": status = " + statusCode);
580 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
581 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
582 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
583 //FIXME: remove the following try catch once Aron fixes signatures
585 MultipartInput input = (MultipartInput) res.getEntity();
586 PersonauthoritiesCommon personAuthority = (PersonauthoritiesCommon) extractPart(input,
587 client.getCommonPartName(), PersonauthoritiesCommon.class);
588 Assert.assertNotNull(personAuthority);
589 } catch (Exception e) {
590 throw new RuntimeException(e);
593 res.releaseConnection();
598 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
599 groups = {"read"}, dependsOnMethods = {"read"})
600 public void readByName(String testName) throws Exception {
605 // Submit the request to the service and store the response.
606 ClientResponse<MultipartInput> res = client.read(knownResourceId);
607 int statusCode = res.getStatus();
609 // Check the status code of the response: does it match
610 // the expected response(s)?
611 if(logger.isDebugEnabled()){
612 logger.debug(testName + ": status = " + statusCode);
614 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
615 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
616 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
617 //FIXME: remove the following try catch once Aron fixes signatures
619 MultipartInput input = (MultipartInput) res.getEntity();
620 PersonauthoritiesCommon personAuthority = (PersonauthoritiesCommon) extractPart(input,
621 client.getCommonPartName(), PersonauthoritiesCommon.class);
622 Assert.assertNotNull(personAuthority);
623 } catch (Exception e) {
624 throw new RuntimeException(e);
632 * @param testName the test name
633 * @throws Exception the exception
635 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
636 groups = {"read"}, dependsOnMethods = {"read"})
637 public void readItem(String testName) throws Exception {
641 // Submit the request to the service and store the response.
642 PersonAuthorityClient client = new PersonAuthorityClient();
643 ClientResponse<MultipartInput> res = client.readItem(knownResourceId, knownItemResourceId);
645 int statusCode = res.getStatus();
647 // Check the status code of the response: does it match
648 // the expected response(s)?
649 if(logger.isDebugEnabled()){
650 logger.debug(testName + ": status = " + statusCode);
652 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
653 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
654 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
656 // Check whether we've received a person.
657 MultipartInput input = (MultipartInput) res.getEntity();
658 PersonsCommon person = (PersonsCommon) extractPart(input,
659 client.getItemCommonPartName(), PersonsCommon.class);
660 Assert.assertNotNull(person);
661 boolean showFull = true;
662 if(showFull && logger.isDebugEnabled()){
663 logger.debug(testName + ": returned payload:");
664 logger.debug(objectAsXmlString(person, PersonsCommon.class));
666 Assert.assertEquals(person.getInAuthority(), knownResourceId);
668 res.releaseConnection();
673 * Verify item display name.
675 * @param testName the test name
676 * @throws Exception the exception
678 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
679 dependsOnMethods = {"readItem", "updateItem"})
680 public void verifyItemDisplayName(String testName) throws Exception {
682 setupUpdate(testName);
684 // Submit the request to the service and store the response.
685 PersonAuthorityClient client = new PersonAuthorityClient();
686 MultipartInput input =null;
687 ClientResponse<MultipartInput> res = client.readItem(knownResourceId, knownItemResourceId);
689 int statusCode = res.getStatus();
691 // Check the status code of the response: does it match
692 // the expected response(s)?
693 if(logger.isDebugEnabled()){
694 logger.debug(testName + ": status = " + statusCode);
696 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
697 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
698 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
700 // Check whether person has expected displayName.
701 input = (MultipartInput) res.getEntity();
703 res.releaseConnection();
706 PersonsCommon person = (PersonsCommon) extractPart(input,
707 client.getItemCommonPartName(), PersonsCommon.class);
708 Assert.assertNotNull(person);
709 String displayName = person.getDisplayName();
710 // Make sure displayName matches computed form
711 String expectedDisplayName =
712 PersonAuthorityClientUtils.prepareDefaultDisplayName(
713 TEST_FORE_NAME, null, TEST_SUR_NAME,
714 TEST_BIRTH_DATE, TEST_DEATH_DATE);
715 Assert.assertNotNull(displayName, expectedDisplayName);
717 // Update the shortName and verify the computed name is updated.
718 person.setCsid(null);
719 person.setDisplayNameComputed(true);
720 person.setForeName("updated-" + TEST_FORE_NAME);
721 expectedDisplayName =
722 PersonAuthorityClientUtils.prepareDefaultDisplayName(
723 "updated-" + TEST_FORE_NAME, null, TEST_SUR_NAME,
724 TEST_BIRTH_DATE, TEST_DEATH_DATE);
726 // Submit the updated resource to the service and store the response.
727 MultipartOutput output = new MultipartOutput();
728 OutputPart commonPart = output.addPart(person, MediaType.APPLICATION_XML_TYPE);
729 commonPart.getHeaders().add("label", client.getItemCommonPartName());
730 res = client.updateItem(knownResourceId, knownItemResourceId, output);
732 int statusCode = res.getStatus();
734 // Check the status code of the response: does it match the expected response(s)?
735 if(logger.isDebugEnabled()){
736 logger.debug("updateItem: status = " + statusCode);
738 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
739 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
740 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
742 // Retrieve the updated resource and verify that its contents exist.
743 input = (MultipartInput) res.getEntity();
745 res.releaseConnection();
748 PersonsCommon updatedPerson =
749 (PersonsCommon) extractPart(input,
750 client.getItemCommonPartName(), PersonsCommon.class);
751 Assert.assertNotNull(updatedPerson);
753 // Verify that the updated resource received the correct data.
754 Assert.assertEquals(updatedPerson.getForeName(), person.getForeName(),
755 "Updated ForeName in Person did not match submitted data.");
756 // Verify that the updated resource computes the right displayName.
757 Assert.assertEquals(updatedPerson.getDisplayName(), expectedDisplayName,
758 "Updated ForeName in Person not reflected in computed DisplayName.");
760 // Now Update the displayName, not computed and verify the computed name is overriden.
761 person.setDisplayNameComputed(false);
762 expectedDisplayName = "TestName";
763 person.setDisplayName(expectedDisplayName);
765 // Submit the updated resource to the service and store the response.
766 output = new MultipartOutput();
767 commonPart = output.addPart(person, MediaType.APPLICATION_XML_TYPE);
768 commonPart.getHeaders().add("label", client.getItemCommonPartName());
769 res = client.updateItem(knownResourceId, knownItemResourceId, output);
771 int statusCode = res.getStatus();
773 // Check the status code of the response: does it match the expected response(s)?
774 if(logger.isDebugEnabled()){
775 logger.debug("updateItem: status = " + statusCode);
777 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
778 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
779 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
781 // Retrieve the updated resource and verify that its contents exist.
782 input = (MultipartInput) res.getEntity();
784 res.releaseConnection();
788 (PersonsCommon) extractPart(input,
789 client.getItemCommonPartName(), PersonsCommon.class);
790 Assert.assertNotNull(updatedPerson);
792 // Verify that the updated resource received the correct data.
793 Assert.assertEquals(updatedPerson.isDisplayNameComputed(), false,
794 "Updated displayNameComputed in Person did not match submitted data.");
795 // Verify that the updated resource computes the right displayName.
796 Assert.assertEquals(updatedPerson.getDisplayName(),
798 "Updated DisplayName (not computed) in Person not stored.");
802 * Verify illegal item display name.
804 * @param testName the test name
805 * @throws Exception the exception
807 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
808 dependsOnMethods = {"verifyItemDisplayName"})
809 public void verifyIllegalItemDisplayName(String testName) throws Exception {
812 setupUpdateWithWrongXmlSchema(testName);
814 // Submit the request to the service and store the response.
815 PersonAuthorityClient client = new PersonAuthorityClient();
816 MultipartInput input = null;
817 ClientResponse<MultipartInput> res = client.readItem(knownResourceId, knownItemResourceId);
819 int statusCode = res.getStatus();
821 // Check the status code of the response: does it match
822 // the expected response(s)?
823 if(logger.isDebugEnabled()){
824 logger.debug(testName + ": status = " + statusCode);
826 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
827 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
828 Assert.assertEquals(statusCode, Response.Status.OK.getStatusCode());
830 // Check whether Person has expected displayName.
831 input = (MultipartInput) res.getEntity();
833 res.releaseConnection();
836 PersonsCommon person = (PersonsCommon) extractPart(input,
837 client.getItemCommonPartName(), PersonsCommon.class);
838 Assert.assertNotNull(person);
839 // Try to Update with computed false and no displayName
840 person.setDisplayNameComputed(false);
841 person.setDisplayName(null);
843 // Submit the updated resource to the service and store the response.
844 MultipartOutput output = new MultipartOutput();
845 OutputPart commonPart = output.addPart(person, MediaType.APPLICATION_XML_TYPE);
846 commonPart.getHeaders().add("label", client.getItemCommonPartName());
847 res = client.updateItem(knownResourceId, knownItemResourceId, output);
849 int statusCode = res.getStatus();
851 // Check the status code of the response: does it match the expected response(s)?
852 if(logger.isDebugEnabled()){
853 logger.debug("updateItem: status = " + statusCode);
855 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
856 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
857 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
859 res.releaseConnection();
866 * @param testName the test name
867 * @throws Exception the exception
869 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
870 groups = {"read"}, dependsOnMethods = {"readItem"})
871 public void readContact(String testName) throws Exception {
875 // Submit the request to the service and store the response.
876 PersonAuthorityClient client = new PersonAuthorityClient();
877 MultipartInput input = null;
878 ClientResponse<MultipartInput> res =
879 client.readContact(knownResourceId, knownItemResourceId,
880 knownContactResourceId);
882 int statusCode = res.getStatus();
884 // Check the status code of the response: does it match
885 // the expected response(s)?
886 if(logger.isDebugEnabled()){
887 logger.debug(testName + ": status = " + statusCode);
889 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
890 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
891 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
893 // Check whether we've received a contact.
894 input = (MultipartInput) res.getEntity();
896 res.releaseConnection();
899 ContactsCommon contact = (ContactsCommon) extractPart(input,
900 new ContactClient().getCommonPartName(), ContactsCommon.class);
901 Assert.assertNotNull(contact);
902 boolean showFull = true;
903 if(showFull && logger.isDebugEnabled()){
904 logger.debug(testName + ": returned payload:");
905 logger.debug(objectAsXmlString(contact, ContactsCommon.class));
907 Assert.assertEquals(contact.getInAuthority(), knownResourceId);
908 Assert.assertEquals(contact.getInItem(), knownItemResourceId);
914 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
917 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
918 groups = {"read"}, dependsOnMethods = {"read"})
919 public void readNonExistent(String testName) {
922 setupReadNonExistent(testName);
924 // Submit the request to the service and store the response.
925 PersonAuthorityClient client = new PersonAuthorityClient();
926 ClientResponse<MultipartInput> res = client.read(NON_EXISTENT_ID);
928 int statusCode = res.getStatus();
929 // Check the status code of the response: does it match
930 // the expected response(s)?
931 if(logger.isDebugEnabled()){
932 logger.debug(testName + ": status = " + statusCode);
934 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
935 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
936 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
938 res.releaseConnection();
943 * Read item non existent.
945 * @param testName the test name
947 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
948 groups = {"read"}, dependsOnMethods = {"readItem"})
949 public void readItemNonExistent(String testName) {
952 setupReadNonExistent(testName);
954 // Submit the request to the service and store the response.
955 PersonAuthorityClient client = new PersonAuthorityClient();
956 ClientResponse<MultipartInput> res = client.readItem(knownResourceId, NON_EXISTENT_ID);
958 int statusCode = res.getStatus();
960 // Check the status code of the response: does it match
961 // the expected response(s)?
962 if(logger.isDebugEnabled()){
963 logger.debug(testName + ": status = " + statusCode);
965 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
966 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
967 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
969 res.releaseConnection();
974 * Read contact non existent.
976 * @param testName the test name
978 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
979 groups = {"read"}, dependsOnMethods = {"readContact"})
980 public void readContactNonExistent(String testName) {
983 setupReadNonExistent(testName);
985 // Submit the request to the service and store the response.
986 PersonAuthorityClient client = new PersonAuthorityClient();
987 ClientResponse<MultipartInput> res =
988 client.readContact(knownResourceId, knownItemResourceId, NON_EXISTENT_ID);
990 int statusCode = res.getStatus();
992 // Check the status code of the response: does it match
993 // the expected response(s)?
994 if(logger.isDebugEnabled()){
995 logger.debug(testName + ": status = " + statusCode);
997 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
998 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
999 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1001 res.releaseConnection();
1005 // ---------------------------------------------------------------
1006 // CRUD tests : READ_LIST tests
1007 // ---------------------------------------------------------------
1011 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
1014 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1015 groups = {"readList"}, dependsOnGroups = {"createList", "read"})
1016 public void readList(String testName) throws Exception {
1019 setupReadList(testName);
1021 // Submit the request to the service and store the response.
1022 PersonAuthorityClient client = new PersonAuthorityClient();
1023 PersonauthoritiesCommonList list = null;
1024 ClientResponse<PersonauthoritiesCommonList> res = client.readList();
1026 int statusCode = res.getStatus();
1028 // Check the status code of the response: does it match
1029 // the expected response(s)?
1030 if(logger.isDebugEnabled()){
1031 logger.debug(testName + ": status = " + statusCode);
1033 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1034 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1035 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1037 list = res.getEntity();
1039 res.releaseConnection();
1042 // Optionally output additional data about list members for debugging.
1043 boolean iterateThroughList = false;
1044 if (iterateThroughList && logger.isDebugEnabled()) {
1045 List<PersonauthoritiesCommonList.PersonauthorityListItem> items =
1046 list.getPersonauthorityListItem();
1048 for (PersonauthoritiesCommonList.PersonauthorityListItem item : items) {
1049 String csid = item.getCsid();
1050 logger.debug(testName + ": list-item[" + i + "] csid=" +
1052 logger.debug(testName + ": list-item[" + i + "] displayName=" +
1053 item.getDisplayName());
1054 logger.debug(testName + ": list-item[" + i + "] URI=" +
1056 readItemList(csid, null);
1065 @Test(groups = {"readList"}, dependsOnMethods = {"readList"})
1066 public void readItemList() {
1067 readItemList(knownResourceId, null);
1071 * Read item list by authority name.
1073 @Test(groups = {"readList"}, dependsOnMethods = {"readItemList"})
1074 public void readItemListByAuthorityName() {
1075 readItemList(null, knownResourceDisplayName);
1081 * @param vcsid the vcsid
1082 * @param name the name
1084 private void readItemList(String vcsid, String name) {
1086 final String testName = "readItemList";
1089 setupReadList(testName);
1091 // Submit the request to the service and store the response.
1092 PersonAuthorityClient client = new PersonAuthorityClient();
1093 ClientResponse<PersonsCommonList> res = null;
1095 res = client.readItemList(vcsid);
1096 } else if (name!= null) {
1097 res = client.readItemListForNamedAuthority(name);
1099 Assert.fail("readItemList passed null csid and name!");
1101 PersonsCommonList list = null;
1103 int statusCode = res.getStatus();
1105 // Check the status code of the response: does it match
1106 // the expected response(s)?
1107 if(logger.isDebugEnabled()){
1108 logger.debug(testName + ": status = " + statusCode);
1110 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1111 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1112 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1114 list = res.getEntity();
1116 res.releaseConnection();
1119 List<PersonsCommonList.PersonListItem> items =
1120 list.getPersonListItem();
1121 int nItemsReturned = items.size();
1122 // There will be one item created, associated with a
1123 // known parent resource, by the createItem test.
1125 // In addition, there will be 'nItemsToCreateInList'
1126 // additional items created by the createItemList test,
1127 // all associated with the same parent resource.
1128 int nExpectedItems = nItemsToCreateInList + 1;
1129 if(logger.isDebugEnabled()){
1130 logger.debug(testName + ": Expected "
1131 + nExpectedItems +" items; got: "+nItemsReturned);
1133 Assert.assertEquals(nItemsReturned, nExpectedItems);
1136 for (PersonsCommonList.PersonListItem item : items) {
1137 Assert.assertTrue((null != item.getRefName()), "Item refName is null!");
1138 Assert.assertTrue((null != item.getDisplayName()), "Item displayName is null!");
1139 // Optionally output additional data about list members for debugging.
1140 boolean showDetails = true;
1141 if (showDetails && logger.isDebugEnabled()) {
1142 logger.debug(" " + testName + ": list-item[" + i + "] csid=" +
1144 logger.debug(" " + testName + ": list-item[" + i + "] refName=" +
1146 logger.debug(" " + testName + ": list-item[" + i + "] displayName=" +
1147 item.getDisplayName());
1148 logger.debug(" " + testName + ": list-item[" + i + "] URI=" +
1156 * Read contact list.
1158 @Test(groups = {"readList"}, dependsOnMethods = {"readItemList"})
1159 public void readContactList() {
1160 readContactList(knownResourceId, knownItemResourceId);
1164 * Read contact list.
1166 * @param parentcsid the parentcsid
1167 * @param itemcsid the itemcsid
1169 private void readContactList(String parentcsid, String itemcsid) {
1170 final String testName = "readContactList";
1173 setupReadList(testName);
1175 // Submit the request to the service and store the response.
1176 PersonAuthorityClient client = new PersonAuthorityClient();
1177 ContactsCommonList list = null;
1178 ClientResponse<ContactsCommonList> res =
1179 client.readContactList(parentcsid, itemcsid);
1181 int statusCode = res.getStatus();
1183 // Check the status code of the response: does it match
1184 // the expected response(s)?
1185 if(logger.isDebugEnabled()){
1186 logger.debug(testName + ": status = " + statusCode);
1188 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1189 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1190 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1192 list = res.getEntity();
1194 res.releaseConnection();
1197 List<ContactsCommonList.ContactListItem> listitems =
1198 list.getContactListItem();
1199 int nItemsReturned = listitems.size();
1200 // There will be one item created, associated with a
1201 // known parent resource, by the createItem test.
1203 // In addition, there will be 'nItemsToCreateInList'
1204 // additional items created by the createItemList test,
1205 // all associated with the same parent resource.
1206 int nExpectedItems = nItemsToCreateInList + 1;
1207 if(logger.isDebugEnabled()){
1208 logger.debug(testName + ": Expected "
1209 + nExpectedItems +" items; got: "+nItemsReturned);
1211 Assert.assertEquals(nItemsReturned, nExpectedItems);
1214 for (ContactsCommonList.ContactListItem listitem : listitems) {
1215 // Optionally output additional data about list members for debugging.
1216 boolean showDetails = false;
1217 if (showDetails && logger.isDebugEnabled()) {
1218 logger.debug(" " + testName + ": list-item[" + i + "] csid=" +
1219 listitem.getCsid());
1220 logger.debug(" " + testName + ": list-item[" + i + "] addressPlace=" +
1221 listitem.getAddressPlace());
1222 logger.debug(" " + testName + ": list-item[" + i + "] URI=" +
1231 // There are no failure outcome tests at present.
1233 // ---------------------------------------------------------------
1234 // CRUD tests : UPDATE tests
1235 // ---------------------------------------------------------------
1238 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
1241 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1242 groups = {"update"}, dependsOnGroups = {"read", "readList", "readListByPartialTerm"})
1243 public void update(String testName) throws Exception {
1246 setupUpdate(testName);
1248 // Retrieve the contents of a resource to update.
1249 PersonAuthorityClient client = new PersonAuthorityClient();
1250 MultipartInput input = null;
1251 ClientResponse<MultipartInput> res = client.read(knownResourceId);
1253 if(logger.isDebugEnabled()){
1254 logger.debug(testName + ": read status = " + res.getStatus());
1256 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
1258 if(logger.isDebugEnabled()){
1259 logger.debug("got PersonAuthority to update with ID: " + knownResourceId);
1261 input = res.getEntity();
1263 res.releaseConnection();
1266 PersonauthoritiesCommon personAuthority = (PersonauthoritiesCommon) extractPart(input,
1267 client.getCommonPartName(), PersonauthoritiesCommon.class);
1268 Assert.assertNotNull(personAuthority);
1270 // Update the contents of this resource.
1271 personAuthority.setDisplayName("updated-" + personAuthority.getDisplayName());
1272 personAuthority.setVocabType("updated-" + personAuthority.getVocabType());
1273 if(logger.isDebugEnabled()){
1274 logger.debug("to be updated PersonAuthority");
1275 logger.debug(objectAsXmlString(personAuthority, PersonauthoritiesCommon.class));
1278 // Submit the updated resource to the service and store the response.
1279 MultipartOutput output = new MultipartOutput();
1280 OutputPart commonPart = output.addPart(personAuthority, MediaType.APPLICATION_XML_TYPE);
1281 commonPart.getHeaders().add("label", client.getCommonPartName());
1282 res = client.update(knownResourceId, output);
1284 int statusCode = res.getStatus();
1286 // Check the status code of the response: does it match the expected response(s)?
1287 if(logger.isDebugEnabled()){
1288 logger.debug(testName + ": status = " + statusCode);
1290 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1291 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1292 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1294 // Retrieve the updated resource and verify that its contents exist.
1295 input = (MultipartInput) res.getEntity();
1297 res.releaseConnection();
1300 PersonauthoritiesCommon updatedPersonAuthority =
1301 (PersonauthoritiesCommon) extractPart(input,
1302 client.getCommonPartName(), PersonauthoritiesCommon.class);
1303 Assert.assertNotNull(updatedPersonAuthority);
1305 // Verify that the updated resource received the correct data.
1306 Assert.assertEquals(updatedPersonAuthority.getDisplayName(),
1307 personAuthority.getDisplayName(),
1308 "Data in updated object did not match submitted data.");
1314 * @param testName the test name
1315 * @throws Exception the exception
1317 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1318 groups = {"update"}, dependsOnMethods = {"update"})
1319 public void updateItem(String testName) throws Exception {
1322 setupUpdate(testName);
1324 // Retrieve the contents of a resource to update.
1325 PersonAuthorityClient client = new PersonAuthorityClient();
1326 MultipartInput input = null;
1327 ClientResponse<MultipartInput> res =
1328 client.readItem(knownResourceId, knownItemResourceId);
1330 if(logger.isDebugEnabled()){
1331 logger.debug(testName + ": read status = " + res.getStatus());
1333 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
1335 if(logger.isDebugEnabled()){
1336 logger.debug("got Person to update with ID: " +
1337 knownItemResourceId +
1338 " in PersonAuthority: " + knownResourceId );
1340 input = res.getEntity();
1342 res.releaseConnection();
1345 PersonsCommon person = (PersonsCommon) extractPart(input,
1346 client.getItemCommonPartName(), PersonsCommon.class);
1347 Assert.assertNotNull(person);
1349 if (logger.isDebugEnabled() == true) {
1350 logger.debug("About to update the following person...");
1351 logger.debug(objectAsXmlString(person, PersonsCommon.class));
1354 // Update the contents of this resource.
1355 person.setCsid(null);
1356 person.setForeName("updated-" + person.getForeName());
1357 if(logger.isDebugEnabled()){
1358 logger.debug("to be updated Person");
1359 logger.debug(objectAsXmlString(person,
1360 PersonsCommon.class));
1363 // Submit the updated resource to the service and store the response.
1364 MultipartOutput output = new MultipartOutput();
1365 OutputPart commonPart = output.addPart(person, MediaType.APPLICATION_XML_TYPE);
1366 commonPart.getHeaders().add("label", client.getItemCommonPartName());
1367 res = client.updateItem(knownResourceId, knownItemResourceId, output);
1369 int statusCode = res.getStatus();
1371 // Check the status code of the response: does it match the expected response(s)?
1372 if(logger.isDebugEnabled()){
1373 logger.debug(testName + ": status = " + statusCode);
1375 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1376 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1377 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1379 // Retrieve the updated resource and verify that its contents exist.
1380 input = (MultipartInput) res.getEntity();
1382 res.releaseConnection();
1385 PersonsCommon updatedPerson =
1386 (PersonsCommon) extractPart(input,
1387 client.getItemCommonPartName(), PersonsCommon.class);
1388 Assert.assertNotNull(updatedPerson);
1390 if (logger.isDebugEnabled() == true) {
1391 logger.debug("Updated to following person to:");
1392 logger.debug(objectAsXmlString(updatedPerson, PersonsCommon.class));
1395 // Verify that the updated resource received the correct data.
1396 Assert.assertEquals(updatedPerson.getForeName(),
1397 person.getForeName(),
1398 "Data in updated Person did not match submitted data.");
1404 * @param testName the test name
1405 * @throws Exception the exception
1407 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1408 groups = {"update"}, dependsOnMethods = {"updateItem"})
1409 public void updateContact(String testName) throws Exception {
1411 setupUpdate(testName);
1413 // Retrieve the contents of a resource to update.
1414 PersonAuthorityClient client = new PersonAuthorityClient();
1415 MultipartInput input = null;
1416 ClientResponse<MultipartInput> res =
1417 client.readContact(knownResourceId, knownItemResourceId, knownContactResourceId);
1419 if(logger.isDebugEnabled()){
1420 logger.debug(testName + ": read status = " + res.getStatus());
1422 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
1424 if(logger.isDebugEnabled()){
1425 logger.debug("got Contact to update with ID: " +
1426 knownContactResourceId +
1427 " in item: " + knownItemResourceId +
1428 " in parent: " + knownResourceId );
1430 input = res.getEntity();
1432 res.releaseConnection();
1435 ContactsCommon contact = (ContactsCommon) extractPart(input,
1436 new ContactClient().getCommonPartName(), ContactsCommon.class);
1437 Assert.assertNotNull(contact);
1439 // Update the contents of this resource.
1440 contact.setAddressPlace("updated-" + contact.getAddressPlace());
1441 if(logger.isDebugEnabled()){
1442 logger.debug("to be updated Contact");
1443 logger.debug(objectAsXmlString(contact,
1444 ContactsCommon.class));
1447 // Submit the updated resource to the service and store the response.
1448 MultipartOutput output = new MultipartOutput();
1449 OutputPart commonPart = output.addPart(contact, MediaType.APPLICATION_XML_TYPE);
1450 commonPart.getHeaders().add("label", new ContactClient().getCommonPartName());
1451 res = client.updateContact(knownResourceId, knownItemResourceId, knownContactResourceId, output);
1453 int statusCode = res.getStatus();
1455 // Check the status code of the response: does it match the expected response(s)?
1456 if(logger.isDebugEnabled()){
1457 logger.debug(testName + ": status = " + statusCode);
1459 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1460 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1461 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1463 // Retrieve the updated resource and verify that its contents exist.
1464 input = (MultipartInput) res.getEntity();
1466 res.releaseConnection();
1468 ContactsCommon updatedContact =
1469 (ContactsCommon) extractPart(input,
1470 new ContactClient().getCommonPartName(), ContactsCommon.class);
1471 Assert.assertNotNull(updatedContact);
1473 // Verify that the updated resource received the correct data.
1474 Assert.assertEquals(updatedContact.getAddressPlace(),
1475 contact.getAddressPlace(),
1476 "Data in updated Contact did not match submitted data.");
1480 // Placeholders until the three tests below can be uncommented.
1481 // See Issue CSPACE-401.
1483 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
1486 public void updateWithEmptyEntityBody(String testName) throws Exception {
1487 //Should this really be empty?
1491 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
1494 public void updateWithMalformedXml(String testName) throws Exception {
1495 //Should this really be empty?
1499 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
1502 public void updateWithWrongXmlSchema(String testName) throws Exception {
1503 //Should this really be empty?
1508 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
1509 groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
1510 public void updateWithEmptyEntityBody(String testName) throws Exception {
1513 setupUpdateWithEmptyEntityBody(testName);
1515 // Submit the request to the service and store the response.
1516 String method = REQUEST_TYPE.httpMethodName();
1517 String url = getResourceURL(knownResourceId);
1518 String mediaType = MediaType.APPLICATION_XML;
1519 final String entity = "";
1520 int statusCode = submitRequest(method, url, mediaType, entity);
1522 // Check the status code of the response: does it match
1523 // the expected response(s)?
1524 if(logger.isDebugEnabled()){
1525 logger.debug(testName + ": url=" + url +
1526 " status=" + statusCode);
1528 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1529 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1530 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1534 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
1535 groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
1536 public void updateWithMalformedXml(String testName) throws Exception {
1539 setupUpdateWithMalformedXml(testName);
1541 // Submit the request to the service and store the response.
1542 String method = REQUEST_TYPE.httpMethodName();
1543 String url = getResourceURL(knownResourceId);
1544 String mediaType = MediaType.APPLICATION_XML;
1545 final String entity = MALFORMED_XML_DATA;
1546 int statusCode = submitRequest(method, url, mediaType, entity);
1548 // Check the status code of the response: does it match
1549 // the expected response(s)?
1550 if(logger.isDebugEnabled()){
1551 logger.debug(testName + ": url=" + url +
1552 " status=" + statusCode);
1554 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1555 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1556 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1560 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
1561 groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
1562 public void updateWithWrongXmlSchema(String testName) throws Exception {
1565 setupUpdateWithWrongXmlSchema(testName);
1567 // Submit the request to the service and store the response.
1568 String method = REQUEST_TYPE.httpMethodName();
1569 String url = getResourceURL(knownResourceId);
1570 String mediaType = MediaType.APPLICATION_XML;
1571 final String entity = WRONG_XML_SCHEMA_DATA;
1572 int statusCode = submitRequest(method, url, mediaType, entity);
1574 // Check the status code of the response: does it match
1575 // the expected response(s)?
1576 if(logger.isDebugEnabled()){
1577 logger.debug("updateWithWrongXmlSchema: url=" + url +
1578 " status=" + statusCode);
1580 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1581 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1582 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1587 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
1590 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1591 groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
1592 public void updateNonExistent(String testName) throws Exception {
1595 setupUpdateNonExistent(testName);
1597 // Submit the request to the service and store the response.
1598 // Note: The ID(s) used when creating the request payload may be arbitrary.
1599 // The only relevant ID may be the one used in update(), below.
1600 PersonAuthorityClient client = new PersonAuthorityClient();
1601 String displayName = "displayName-NON_EXISTENT_ID";
1602 String fullRefName = PersonAuthorityClientUtils.createPersonAuthRefName(displayName, true);
1603 MultipartOutput multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance(
1604 displayName, fullRefName, client.getCommonPartName());
1605 ClientResponse<MultipartInput> res =
1606 client.update(NON_EXISTENT_ID, multipart);
1608 int statusCode = res.getStatus();
1610 // Check the status code of the response: does it match
1611 // the expected response(s)?
1612 if(logger.isDebugEnabled()){
1613 logger.debug(testName + ": status = " + statusCode);
1615 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1616 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1617 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1619 res.releaseConnection();
1624 * Update non existent item.
1626 * @param testName the test name
1627 * @throws Exception the exception
1629 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1630 groups = {"update"}, dependsOnMethods = {"updateItem", "testItemSubmitRequest"})
1631 public void updateNonExistentItem(String testName) throws Exception {
1634 setupUpdateNonExistent(testName);
1636 // Submit the request to the service and store the response.
1637 // Note: The ID used in this 'create' call may be arbitrary.
1638 // The only relevant ID may be the one used in update(), below.
1639 PersonAuthorityClient client = new PersonAuthorityClient();
1640 Map<String, String> nonexMap = new HashMap<String,String>();
1641 nonexMap.put(PersonJAXBSchema.FORE_NAME, "John");
1642 nonexMap.put(PersonJAXBSchema.SUR_NAME, "Wayne");
1643 nonexMap.put(PersonJAXBSchema.GENDER, "male");
1644 MultipartOutput multipart =
1645 PersonAuthorityClientUtils.createPersonInstance(NON_EXISTENT_ID,
1646 PersonAuthorityClientUtils.createPersonRefName(NON_EXISTENT_ID, NON_EXISTENT_ID, true), nonexMap,
1647 client.getItemCommonPartName() );
1648 ClientResponse<MultipartInput> res =
1649 client.updateItem(knownResourceId, NON_EXISTENT_ID, multipart);
1651 int statusCode = res.getStatus();
1653 // Check the status code of the response: does it match
1654 // the expected response(s)?
1655 if(logger.isDebugEnabled()){
1656 logger.debug(testName + ": status = " + statusCode);
1658 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1659 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1660 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1662 res.releaseConnection();
1667 * Update non existent contact.
1669 * @param testName the test name
1670 * @throws Exception the exception
1672 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1673 groups = {"update"}, dependsOnMethods = {"updateContact", "testContactSubmitRequest"})
1674 public void updateNonExistentContact(String testName) throws Exception {
1675 // Currently a no-op test
1678 // ---------------------------------------------------------------
1679 // CRUD tests : DELETE tests
1680 // ---------------------------------------------------------------
1683 // Note: delete sub-resources in ascending hierarchical order,
1684 // before deleting their parents.
1689 * @param testName the test name
1690 * @throws Exception the exception
1692 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1693 groups = {"delete"}, dependsOnGroups = {"create", "read", "readList", "readListByPartialTerm", "update"})
1694 public void deleteContact(String testName) throws Exception {
1697 setupDelete(testName);
1699 if(logger.isDebugEnabled()){
1700 logger.debug("parentcsid =" + knownResourceId +
1701 " itemcsid = " + knownItemResourceId +
1702 " csid = " + knownContactResourceId);
1705 // Submit the request to the service and store the response.
1706 PersonAuthorityClient client = new PersonAuthorityClient();
1707 ClientResponse<Response> res =
1708 client.deleteContact(knownResourceId, knownItemResourceId, knownContactResourceId);
1709 int statusCode = res.getStatus();
1710 res.releaseConnection();
1712 // Check the status code of the response: does it match
1713 // the expected response(s)?
1714 if(logger.isDebugEnabled()){
1715 logger.debug(testName + ": status = " + statusCode);
1717 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1718 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1719 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1725 * @param testName the test name
1726 * @throws Exception the exception
1728 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1729 groups = {"delete"}, dependsOnMethods = {"deleteContact"})
1730 public void deleteItem(String testName) throws Exception {
1733 setupDelete(testName);
1735 if(logger.isDebugEnabled()){
1736 logger.debug("parentcsid =" + knownResourceId +
1737 " itemcsid = " + knownItemResourceId);
1740 // Submit the request to the service and store the response.
1741 PersonAuthorityClient client = new PersonAuthorityClient();
1742 ClientResponse<Response> res = client.deleteItem(knownResourceId, knownItemResourceId);
1743 int statusCode = res.getStatus();
1744 res.releaseConnection();
1746 // Check the status code of the response: does it match
1747 // the expected response(s)?
1748 if(logger.isDebugEnabled()){
1749 logger.debug(testName + ": status = " + statusCode);
1751 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1752 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1753 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1757 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
1760 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1761 groups = {"delete"}, dependsOnMethods = {"deleteItem"})
1762 public void delete(String testName) throws Exception {
1765 setupDelete(testName);
1767 if(logger.isDebugEnabled()){
1768 logger.debug("parentcsid =" + knownResourceId);
1771 // Submit the request to the service and store the response.
1772 PersonAuthorityClient client = new PersonAuthorityClient();
1773 ClientResponse<Response> res = client.delete(knownResourceId);
1774 int statusCode = res.getStatus();
1775 res.releaseConnection();
1777 // Check the status code of the response: does it match
1778 // the expected response(s)?
1779 if(logger.isDebugEnabled()){
1780 logger.debug(testName + ": status = " + statusCode);
1782 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1783 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1784 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1789 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
1792 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1793 groups = {"delete"}, dependsOnMethods = {"delete"})
1794 public void deleteNonExistent(String testName) throws Exception {
1797 setupDeleteNonExistent(testName);
1799 // Submit the request to the service and store the response.
1800 PersonAuthorityClient client = new PersonAuthorityClient();
1801 ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
1802 int statusCode = res.getStatus();
1803 res.releaseConnection();
1805 // Check the status code of the response: does it match
1806 // the expected response(s)?
1807 if(logger.isDebugEnabled()){
1808 logger.debug(testName + ": status = " + statusCode);
1810 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1811 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1812 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1816 * Delete non existent item.
1818 * @param testName the test name
1820 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1821 groups = {"delete"}, dependsOnMethods = {"deleteItem"})
1822 public void deleteNonExistentItem(String testName) {
1825 setupDeleteNonExistent(testName);
1827 // Submit the request to the service and store the response.
1828 PersonAuthorityClient client = new PersonAuthorityClient();
1829 ClientResponse<Response> res = client.deleteItem(knownResourceId, NON_EXISTENT_ID);
1830 int statusCode = res.getStatus();
1831 res.releaseConnection();
1833 // Check the status code of the response: does it match
1834 // the expected response(s)?
1835 if(logger.isDebugEnabled()){
1836 logger.debug(testName + ": status = " + statusCode);
1838 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1839 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1840 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1844 * Delete non existent contact.
1846 * @param testName the test name
1848 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1849 groups = {"delete"}, dependsOnMethods = {"deleteContact"})
1850 public void deleteNonExistentContact(String testName) {
1853 setupDeleteNonExistent(testName);
1855 // Submit the request to the service and store the response.
1856 PersonAuthorityClient client = new PersonAuthorityClient();
1857 ClientResponse<Response> res =
1858 client.deleteContact(knownResourceId, knownItemResourceId, NON_EXISTENT_ID);
1859 int statusCode = res.getStatus();
1860 res.releaseConnection();
1862 // Check the status code of the response: does it match
1863 // the expected response(s)?
1864 if(logger.isDebugEnabled()){
1865 logger.debug(testName + ": status = " + statusCode);
1867 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1868 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1869 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1872 // ---------------------------------------------------------------
1873 // Utility tests : tests of code used in tests above
1874 // ---------------------------------------------------------------
1876 * Tests the code for manually submitting data that is used by several
1877 * of the methods above.
1879 @Test(dependsOnMethods = {"create", "read"})
1880 public void testSubmitRequest() {
1882 // Expected status code: 200 OK
1883 final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
1885 // Submit the request to the service and store the response.
1886 String method = ServiceRequestType.READ.httpMethodName();
1887 String url = getResourceURL(knownResourceId);
1888 int statusCode = submitRequest(method, url);
1890 // Check the status code of the response: does it match
1891 // the expected response(s)?
1892 if(logger.isDebugEnabled()){
1893 logger.debug("testSubmitRequest: url=" + url +
1894 " status=" + statusCode);
1896 Assert.assertEquals(statusCode, EXPECTED_STATUS);
1901 * Test item submit request.
1903 @Test(dependsOnMethods = {"createItem", "readItem", "testSubmitRequest"})
1904 public void testItemSubmitRequest() {
1906 // Expected status code: 200 OK
1907 final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
1909 // Submit the request to the service and store the response.
1910 String method = ServiceRequestType.READ.httpMethodName();
1911 String url = getItemResourceURL(knownResourceId, knownItemResourceId);
1912 int statusCode = submitRequest(method, url);
1914 // Check the status code of the response: does it match
1915 // the expected response(s)?
1916 if(logger.isDebugEnabled()){
1917 logger.debug("testItemSubmitRequest: url=" + url +
1918 " status=" + statusCode);
1920 Assert.assertEquals(statusCode, EXPECTED_STATUS);
1925 * Test contact submit request.
1927 @Test(dependsOnMethods = {"createContact", "readContact", "testItemSubmitRequest"})
1928 public void testContactSubmitRequest() {
1930 // Expected status code: 200 OK
1931 final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
1933 // Submit the request to the service and store the response.
1934 String method = ServiceRequestType.READ.httpMethodName();
1935 String url = getContactResourceURL(knownResourceId,
1936 knownItemResourceId, knownContactResourceId);
1937 int statusCode = submitRequest(method, url);
1939 // Check the status code of the response: does it match
1940 // the expected response(s)?
1941 if(logger.isDebugEnabled()){
1942 logger.debug("testItemSubmitRequest: url=" + url +
1943 " status=" + statusCode);
1945 Assert.assertEquals(statusCode, EXPECTED_STATUS);
1950 // ---------------------------------------------------------------
1951 // Cleanup of resources created during testing
1952 // ---------------------------------------------------------------
1955 * Deletes all resources created by tests, after all tests have been run.
1957 * This cleanup method will always be run, even if one or more tests fail.
1958 * For this reason, it attempts to remove all resources created
1959 * at any point during testing, even if some of those resources
1960 * may be expected to be deleted by certain tests.
1963 @AfterClass(alwaysRun=true)
1965 public void cleanUp() {
1966 String noTest = System.getProperty("noTestCleanup");
1967 if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
1968 if (logger.isDebugEnabled()) {
1969 logger.debug("Skipping Cleanup phase ...");
1973 if (logger.isDebugEnabled()) {
1974 logger.debug("Cleaning up temporary resources created for testing ...");
1976 String parentResourceId;
1977 String itemResourceId;
1978 String contactResourceId;
1979 // Clean up contact resources.
1980 PersonAuthorityClient client = new PersonAuthorityClient();
1981 parentResourceId = knownResourceId;
1982 for (Map.Entry<String, String> entry : allContactResourceIdsCreated.entrySet()) {
1983 contactResourceId = entry.getKey();
1984 itemResourceId = entry.getValue();
1985 // Note: Any non-success responses from the delete operation
1986 // below are ignored and not reported.
1987 ClientResponse<Response> res =
1988 client.deleteContact(parentResourceId, itemResourceId, contactResourceId);
1989 res.releaseConnection();
1991 // Clean up item resources.
1992 for (Map.Entry<String, String> entry : allItemResourceIdsCreated.entrySet()) {
1993 itemResourceId = entry.getKey();
1994 parentResourceId = entry.getValue();
1995 // Note: Any non-success responses from the delete operation
1996 // below are ignored and not reported.
1997 ClientResponse<Response> res =
1998 client.deleteItem(parentResourceId, itemResourceId);
1999 res.releaseConnection();
2001 // Clean up parent resources.
2005 // ---------------------------------------------------------------
2006 // Utility methods used by tests above
2007 // ---------------------------------------------------------------
2009 * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
2012 public String getServicePathComponent() {
2013 return SERVICE_PATH_COMPONENT;
2017 * Gets the item service path component.
2019 * @return the item service path component
2021 public String getItemServicePathComponent() {
2022 return ITEM_SERVICE_PATH_COMPONENT;
2026 * Gets the contact service path component.
2028 * @return the contact service path component
2030 public String getContactServicePathComponent() {
2031 return CONTACT_SERVICE_PATH_COMPONENT;
2035 * Returns the root URL for the item service.
2037 * This URL consists of a base URL for all services, followed by
2038 * a path component for the owning parent, followed by the
2039 * path component for the items.
2041 * @param parentResourceIdentifier An identifier (such as a UUID) for the
2042 * parent authority resource of the relevant item resource.
2044 * @return The root URL for the item service.
2046 protected String getItemServiceRootURL(String parentResourceIdentifier) {
2047 return getResourceURL(parentResourceIdentifier) + "/" + getItemServicePathComponent();
2051 * Returns the URL of a specific item resource managed by a service, and
2052 * designated by an identifier (such as a universally unique ID, or UUID).
2054 * @param parentResourceIdentifier An identifier (such as a UUID) for the
2055 * parent authority resource of the relevant item resource.
2057 * @param itemResourceIdentifier An identifier (such as a UUID) for an
2060 * @return The URL of a specific item resource managed by a service.
2062 protected String getItemResourceURL(String parentResourceIdentifier, String itemResourceIdentifier) {
2063 return getItemServiceRootURL(parentResourceIdentifier) + "/" + itemResourceIdentifier;
2068 * Returns the root URL for the contact service.
2070 * This URL consists of a base URL for all services, followed by
2071 * a path component for the owning authority, followed by the
2072 * path component for the owning item, followed by the path component
2073 * for the contact service.
2075 * @param parentResourceIdentifier An identifier (such as a UUID) for the
2076 * parent authority resource of the relevant item resource.
2078 * @param itemResourceIdentifier An identifier (such as a UUID) for an
2081 * @return The root URL for the contact service.
2083 protected String getContactServiceRootURL(String parentResourceIdentifier,
2084 String itemResourceIdentifier) {
2085 return getItemResourceURL(parentResourceIdentifier, itemResourceIdentifier) + "/" +
2086 getContactServicePathComponent();
2090 * Returns the URL of a specific contact resource managed by a service, and
2091 * designated by an identifier (such as a universally unique ID, or UUID).
2093 * @param parentResourceIdentifier An identifier (such as a UUID) for the
2094 * parent resource of the relevant item resource.
2096 * @param resourceIdentifier An identifier (such as a UUID) for an
2099 * @return The URL of a specific resource managed by a service.
2101 protected String getContactResourceURL(String parentResourceIdentifier,
2102 String itemResourceIdentifier, String contactResourceIdentifier) {
2103 return getContactServiceRootURL(parentResourceIdentifier,
2104 itemResourceIdentifier) + "/" + contactResourceIdentifier;