2 * This document is a part of the source code and related artifacts
3 * for CollectionSpace, an open source collections management system
4 * for museums and related institutions:
6 * http://www.collectionspace.org
7 * http://wiki.collectionspace.org
9 * Copyright (c)) 2009 Regents of the University of California
11 * Licensed under the Educational Community License (ECL), Version 2.0.
12 * You may not use this file except in compliance with this License.
14 * You may obtain a copy of the ECL 2.0 License at
15 * https://source.collectionspace.org/collection-space/LICENSE.txt
17 * Unless required by applicable law or agreed to in writing, software
18 * distributed under the License is distributed on an "AS IS" BASIS,
19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 * See the License for the specific language governing permissions and
21 * limitations under the License.
23 package org.collectionspace.services.client.test;
25 import java.util.ArrayList;
26 import java.util.HashMap;
27 import java.util.List;
29 import javax.ws.rs.core.Response;
31 import org.collectionspace.services.client.AbstractCommonListUtils;
32 import org.collectionspace.services.client.AuthorityClient;
33 import org.collectionspace.services.client.CollectionSpaceClient;
34 import org.collectionspace.services.client.PayloadOutputPart;
35 import org.collectionspace.services.client.PoxPayloadIn;
36 import org.collectionspace.services.client.PoxPayloadOut;
38 import org.collectionspace.services.client.ContactClient;
39 import org.collectionspace.services.client.ContactClientUtils;
40 import org.collectionspace.services.contact.AddressGroup;
41 import org.collectionspace.services.contact.AddressGroupList;
42 import org.collectionspace.services.contact.ContactsCommon;
44 import org.collectionspace.services.client.PersonAuthorityClient;
45 import org.collectionspace.services.client.PersonAuthorityClientUtils;
46 import org.collectionspace.services.jaxb.AbstractCommonList;
47 import org.collectionspace.services.PersonJAXBSchema;
48 import org.collectionspace.services.person.PersonauthoritiesCommon;
49 import org.collectionspace.services.person.PersonsCommon;
51 import org.jboss.resteasy.client.ClientResponse;
52 //import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
53 import org.slf4j.Logger;
54 import org.slf4j.LoggerFactory;
55 import org.testng.Assert;
56 import org.testng.annotations.AfterClass;
57 import org.testng.annotations.Test;
60 * PersonAuthorityServiceTest, carries out tests against a
61 * deployed and running PersonAuthority Service.
63 * $LastChangedRevision: 753 $
64 * $LastChangedDate: 2009-09-23 11:03:36 -0700 (Wed, 23 Sep 2009) $
66 public class PersonAuthorityServiceTest extends AbstractAuthorityServiceTest<PersonauthoritiesCommon, PersonsCommon> { //FIXME: Test classes for Vocab, Person, Org, and Location should have a base class!
69 private final String CLASS_NAME = PersonAuthorityServiceTest.class.getName();
70 private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
71 private final String REFNAME = "refName";
72 private final String DISPLAYNAME = "displayName";
75 public String getServicePathComponent() {
76 return PersonAuthorityClient.SERVICE_PATH_COMPONENT;
80 protected String getServiceName() {
81 return PersonAuthorityClient.SERVICE_NAME;
84 public String getItemServicePathComponent() {
85 return AuthorityClient.ITEMS;
87 /** The test forename. */
88 final String TEST_FORE_NAME = "John";
89 /** The test middle name. */
90 final String TEST_MIDDLE_NAME = null;
91 /** The test surname. */
92 final String TEST_SUR_NAME = "Wayne";
93 /** The test birthdate. */
94 final String TEST_BIRTH_DATE = "May 26, 1907";
95 /** The test death date. */
96 final String TEST_DEATH_DATE = "June 11, 1979";
97 //private String knownResourceRefName = null;
98 private String knownItemResourceShortIdentifer = null;
99 // The resource ID of an item resource used for partial term matching tests.
100 private String knownItemPartialTermResourceId = null;
101 /** The known contact resource id. */
102 private String knownContactResourceId = null;
103 /** The all contact resource ids created. */
104 private Map<String, String> allContactResourceIdsCreated =
105 new HashMap<String, String>();
107 protected void setKnownResource(String id, String shortIdentifer,
109 knownResourceId = id;
110 knownResourceShortIdentifer = shortIdentifer;
111 //knownResourceRefName = refName;
114 protected void setKnownItemResource(String id, String shortIdentifer) {
115 knownItemResourceId = id;
116 knownItemResourceShortIdentifer = shortIdentifer;
120 * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
123 protected CollectionSpaceClient getClientInstance() {
124 return new PersonAuthorityClient();
127 // ---------------------------------------------------------------
128 // CRUD tests : CREATE tests
129 // ---------------------------------------------------------------
132 * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
135 // @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
136 // groups = {"create"})
137 public void create(String testName) throws Exception {
138 // Perform setup, such as initializing the type of service request
139 // (e.g. CREATE, DELETE), its valid and expected status codes, and
140 // its associated HTTP method name (e.g. POST, DELETE).
143 // Submit the request to the service and store the response.
144 PersonAuthorityClient client = new PersonAuthorityClient();
145 String shortId = createIdentifier();
146 String displayName = "displayName-" + shortId;
147 //String baseRefName = PersonAuthorityClientUtils.createPersonAuthRefName(shortId, null);
148 PoxPayloadOut multipart =
149 PersonAuthorityClientUtils.createPersonAuthorityInstance(
150 displayName, shortId, client.getCommonPartName());
153 ClientResponse<Response> res = client.create(multipart);
155 assertStatusCode(res, testName);
156 newID = extractId(res);
159 res.releaseConnection();
162 // Save values for additional tests
163 if (knownResourceId == null) {
164 setKnownResource(newID, shortId, null ); //baseRefName);
165 if (logger.isDebugEnabled()) {
166 logger.debug(testName + ": knownResourceId=" + knownResourceId);
169 // Store the IDs from every resource created by tests,
170 // so they can be deleted after tests have been run.
171 allResourceIdsCreated.add(newID);
175 protected PoxPayloadOut createInstance(String identifier) {
176 PersonAuthorityClient client = new PersonAuthorityClient();
177 String displayName = "displayName-" + identifier;
178 PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance(
179 displayName, identifier, client.getCommonPartName());
184 protected PoxPayloadOut createItemInstance(String parentCsid, String identifier) {
185 String headerLabel = new PersonAuthorityClient().getItemCommonPartName();
186 HashMap<String, String> personInfo = new HashMap<String, String>();
187 String shortId = "johnWayneTempActor";
188 personInfo.put(PersonJAXBSchema.DISPLAY_NAME_COMPUTED, "false");
189 personInfo.put(PersonJAXBSchema.DISPLAY_NAME, "John Wayne Temp");
190 personInfo.put(PersonJAXBSchema.SHORT_DISPLAY_NAME_COMPUTED, "false");
191 personInfo.put(PersonJAXBSchema.SHORT_DISPLAY_NAME, "JohnWayneTemp");
192 personInfo.put(PersonJAXBSchema.SHORT_IDENTIFIER, shortId);
194 return PersonAuthorityClientUtils.createPersonInstance(parentCsid, identifier, personInfo, headerLabel);
198 * Creates an item in an authority, using test data.
200 * @param vcsid the vcsid
201 * @param authRefName the auth ref name
205 protected String createItemInAuthority(String vcsid) {
207 final String testName = "createItemInAuthority";
208 if (logger.isDebugEnabled()) {
209 logger.debug(testName + ":" + vcsid + "...");
212 Map<String, String> johnWayneMap = new HashMap<String, String>();
214 // Fill the property map
216 String shortId = "johnWayneActor";
217 johnWayneMap.put(PersonJAXBSchema.DISPLAY_NAME_COMPUTED, "false");
218 johnWayneMap.put(PersonJAXBSchema.DISPLAY_NAME, "John Wayne");
219 johnWayneMap.put(PersonJAXBSchema.SHORT_DISPLAY_NAME_COMPUTED, "false");
220 johnWayneMap.put(PersonJAXBSchema.SHORT_DISPLAY_NAME, "JohnWayne");
221 johnWayneMap.put(PersonJAXBSchema.SHORT_IDENTIFIER, shortId);
223 johnWayneMap.put(PersonJAXBSchema.FORE_NAME, TEST_FORE_NAME);
224 johnWayneMap.put(PersonJAXBSchema.SUR_NAME, TEST_SUR_NAME);
225 johnWayneMap.put(PersonJAXBSchema.GENDER, "male");
226 johnWayneMap.put(PersonJAXBSchema.BIRTH_DATE, TEST_BIRTH_DATE);
227 johnWayneMap.put(PersonJAXBSchema.BIRTH_PLACE, "Winterset, Iowa");
228 johnWayneMap.put(PersonJAXBSchema.DEATH_DATE, TEST_DEATH_DATE);
229 johnWayneMap.put(PersonJAXBSchema.BIO_NOTE, "born Marion Robert Morrison and better"
230 + "known by his stage name John Wayne, was an American film actor, director "
231 + "and producer. He epitomized rugged masculinity and has become an enduring "
232 + "American icon. He is famous for his distinctive voice, walk and height. "
233 + "He was also known for his conservative political views and his support in "
234 + "the 1950s for anti-communist positions.");
236 Map<String, List<String>> johnWayneRepeatablesMap = new HashMap<String, List<String>>();
237 List<String> johnWayneGroups = new ArrayList<String>();
238 johnWayneGroups.add("Irish");
239 johnWayneGroups.add("Scottish");
240 johnWayneRepeatablesMap.put(PersonJAXBSchema.GROUPS, johnWayneGroups);
242 return createItemInAuthority(vcsid, null /*authRefName*/, shortId, johnWayneMap, johnWayneRepeatablesMap);
247 * Creates an item in an authority.
249 * @param vcsid the vcsid
250 * @param authRefName the auth ref name
251 * @param itemFieldProperties a set of properties specifying the values of fields.
252 * @param itemRepeatableFieldProperties a set of properties specifying the values of repeatable fields.
255 private String createItemInAuthority(String vcsid, String authRefName, String shortId,
256 Map itemFieldProperties, Map itemRepeatableFieldProperties) {
258 final String testName = "createItemInAuthority";
259 if (logger.isDebugEnabled()) {
260 logger.debug(testName + ":" + vcsid + "...");
263 // Submit the request to the service and store the response.
264 PersonAuthorityClient client = new PersonAuthorityClient();
265 PoxPayloadOut multipart =
266 PersonAuthorityClientUtils.createPersonInstance(vcsid, null /*authRefName*/, itemFieldProperties,
267 itemRepeatableFieldProperties, client.getItemCommonPartName());
269 ClientResponse<Response> res = client.createItem(vcsid, multipart);
272 assertStatusCode(res, testName);
273 newID = PersonAuthorityClientUtils.extractId(res);
276 res.releaseConnection();
280 // Store the ID returned from the first item resource created
281 // for additional tests below.
282 if (knownItemResourceId == null) {
283 setKnownItemResource(newID, shortId);
284 if (logger.isDebugEnabled()) {
285 logger.debug(testName + ": knownItemResourceId=" + knownItemResourceId);
288 if (logger.isDebugEnabled()) {
289 logger.debug(testName + " (created):" + vcsid + "/(" + newID + "," + shortId + ")");
292 // Store the IDs from any item resources created
293 // by tests, along with the IDs of their parents, so these items
294 // can be deleted after all tests have been run.
295 allResourceItemIdsCreated.put(newID, vcsid);
301 * Creates the contact.
303 * @param testName the test name
305 @Test(dataProvider = "testName", groups = {"create"},
306 dependsOnMethods = {"createItem"})
307 public void createContact(String testName) {
309 String newID = createContactInItem(knownResourceId, knownItemResourceId);
313 * Creates the contact in item.
315 * @param parentcsid the parentcsid
316 * @param itemcsid the itemcsid
319 private String createContactInItem(String parentcsid, String itemcsid) {
321 final String testName = "createContactInItem";
322 if (logger.isDebugEnabled()) {
323 logger.debug(testName + ":...");
325 // Submit the request to the service and store the response.
326 PersonAuthorityClient client = new PersonAuthorityClient();
327 String identifier = createIdentifier();
328 PoxPayloadOut multipart = ContactClientUtils.createContactInstance(parentcsid,
329 itemcsid, identifier, new ContactClient().getCommonPartName());
332 ClientResponse<Response> res =
333 client.createContact(parentcsid, itemcsid, multipart);
336 assertStatusCode(res, testName);
337 newID = PersonAuthorityClientUtils.extractId(res);
340 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);
362 * Attempts to create an authority with an short identifier that contains
363 * non-word characters.
365 * @param testName the test name
367 @Test(dataProvider = "testName", groups = {"create", "nonWordCharsInShortId"})
368 public void createWithShortIdNonWordChars(String testName) throws Exception {
369 testExpectedStatusCode = STATUS_BAD_REQUEST;
370 testRequestType = ServiceRequestType.CREATE;
371 testSetup(testExpectedStatusCode, testRequestType);
373 // Create the payload to be included in the body of the request
374 PersonAuthorityClient client = new PersonAuthorityClient();
375 String shortId = createIdentifier() + "*" + createIdentifier();
376 String displayName = "displayName-" + shortId;
377 PoxPayloadOut multipart =
378 PersonAuthorityClientUtils.createPersonAuthorityInstance(
379 displayName, shortId, client.getCommonPartName());
381 // Submit the request to the service and store the response.
382 ClientResponse<Response> res = client.create(multipart);
384 // Check the status code of the response: does it match
385 // the expected response(s)?
387 assertStatusCode(res, testName);
390 res.releaseConnection();
396 * Attempts to create an item with an short identifier that contains
397 * non-word characters.
399 * @param testName the test name
401 @Test(dataProvider = "testName", groups = {"create", "nonWordCharsInShortId"},
402 dependsOnMethods = {"org.collectionspace.services.client.test.AbstractServiceTestImpl.create"})
403 public void createItemWithShortIdNonWordChars(String testName) {
404 testExpectedStatusCode = STATUS_BAD_REQUEST;
405 testRequestType = ServiceRequestType.CREATE;
406 testSetup(testExpectedStatusCode, testRequestType);
408 PersonAuthorityClient client = new PersonAuthorityClient();
409 // Create the payload to be included in the body of the request
410 String shortId = "7-Eleven";
411 Map<String, String> fieldProperties = new HashMap<String, String>();
412 fieldProperties.put(PersonJAXBSchema.DISPLAY_NAME_COMPUTED, "false");
413 fieldProperties.put(PersonJAXBSchema.DISPLAY_NAME, shortId);
414 fieldProperties.put(PersonJAXBSchema.SHORT_DISPLAY_NAME_COMPUTED, "false");
415 fieldProperties.put(PersonJAXBSchema.SHORT_DISPLAY_NAME, shortId);
416 fieldProperties.put(PersonJAXBSchema.SHORT_IDENTIFIER, shortId);
417 final Map NULL_REPEATABLE_FIELD_PROPERTIES = null;
418 PoxPayloadOut multipart =
419 PersonAuthorityClientUtils.createPersonInstance(knownResourceId,
420 null /*knownResourceRefName*/, fieldProperties,
421 NULL_REPEATABLE_FIELD_PROPERTIES, client.getItemCommonPartName());
423 // Send the request and receive a response
424 ClientResponse<Response> res = client.createItem(knownResourceId, multipart);
425 // Check the status code of the response: does it match
426 // the expected response(s)?
428 assertStatusCode(res, testName);
431 res.releaseConnection();
436 // ---------------------------------------------------------------
437 // CRUD tests : CREATE LIST tests
438 // ---------------------------------------------------------------
441 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
444 // @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
445 // groups = {"createList"}, dependsOnGroups = {"create"})
446 public void createList(String testName) throws Exception {
447 for (int i = 0; i < nItemsToCreateInList; i++) {
453 * Creates the contact list.
455 * @param testName the test name
456 * @throws Exception the exception
458 @Test(dataProvider = "testName", groups = {"createList"},
459 dependsOnMethods = {"org.collectionspace.services.client.test.AbstractAuthorityServiceTest.createItemList"})
460 public void createContactList(String testName) throws Exception {
461 // Add contacts to the initially-created, known item record.
462 for (int j = 0; j < nItemsToCreateInList; j++) {
463 createContact(testName);
467 // ---------------------------------------------------------------
468 // CRUD tests : READ tests
469 // ---------------------------------------------------------------
472 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
475 // @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
476 // groups = {"read"}, dependsOnGroups = {"create"})
477 public void read(String testName) throws Exception {
478 readInternal(testName, knownResourceId, null);
484 * @param testName the test name
485 * @throws Exception the exception
488 // @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
489 // groups = {"read"}, dependsOnMethods = {"read"})
490 public void readByName(String testName) throws Exception {
491 readInternal(testName, null, knownResourceShortIdentifer);
494 protected void readInternal(String testName, String CSID, String shortId) {
495 // Submit the request to the service and store the response.
496 PersonAuthorityClient client = new PersonAuthorityClient();
497 ClientResponse<String> res = null;
500 res = client.read(CSID);
501 } else if (shortId != null) {
502 res = client.readByName(shortId);
504 Assert.fail("readInternal: Internal error. One of CSID or shortId must be non-null");
507 assertStatusCode(res, testName);
508 //FIXME: remove the following try catch once Aron fixes signatures
510 PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
511 PersonauthoritiesCommon personAuthority = (PersonauthoritiesCommon) extractPart(input,
512 client.getCommonPartName(), PersonauthoritiesCommon.class);
513 Assert.assertNotNull(personAuthority);
514 } catch (Exception e) {
515 throw new RuntimeException(e);
519 res.releaseConnection();
527 * @param testName the test name
528 * @throws Exception the exception
530 @Test(dataProvider = "testName", groups = {"readItem", "readNamedItemInNamedAuth"},
531 dependsOnMethods = {"readItemInNamedAuth"})
532 public void readNamedItem(String testName) throws Exception {
533 readItemInternal(testName, knownResourceId, null, null, knownItemResourceShortIdentifer);
537 * Read item in Named Auth.
539 * @param testName the test name
540 * @throws Exception the exception
542 @Test(dataProvider = "testName", groups = {"readItem"},
543 dependsOnMethods = {"readItem"})
544 public void readItemInNamedAuth(String testName) throws Exception {
545 readItemInternal(testName, null, knownResourceShortIdentifer, knownItemResourceId, null);
550 * Read Named item in Named Auth.
552 * @param testName the test name
553 * @throws Exception the exception
555 @Test(dataProvider = "testName", groups = {"readItem"},
556 dependsOnMethods = {"readNamedItem"})
557 public void readNamedItemInNamedAuth(String testName) throws Exception {
558 readItemInternal(testName, null, knownResourceShortIdentifer, null, knownItemResourceShortIdentifer);
561 protected void readItemInternal(String testName,
562 String authCSID, String authShortId, String itemCSID, String itemShortId)
565 if (logger.isDebugEnabled()) {
566 logger.debug("Reading:" + ((authCSID != null) ? authCSID : authShortId) + "/"
567 + ((itemCSID != null) ? authCSID : itemShortId));
570 // Submit the request to the service and store the response.
571 PersonAuthorityClient client = new PersonAuthorityClient();
573 ClientResponse<String> res = null;
574 if (authCSID != null) {
575 if (itemCSID != null) {
576 res = client.readItem(authCSID, itemCSID);
577 } else if (itemShortId != null) {
578 res = client.readNamedItem(authCSID, itemShortId);
580 Assert.fail("readInternal: Internal error. One of CSID or shortId must be non-null");
582 } else if (authShortId != null) {
583 if (itemCSID != null) {
584 res = client.readItemInNamedAuthority(authShortId, itemCSID);
585 } else if (itemShortId != null) {
586 res = client.readNamedItemInNamedAuthority(authShortId, itemShortId);
588 Assert.fail("readInternal: Internal error. One of CSID or shortId must be non-null");
591 Assert.fail("readInternal: Internal error. One of authCSID or authShortId must be non-null");
594 assertStatusCode(res, testName);
595 // Check whether we've received a person.
596 PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
597 PersonsCommon person = (PersonsCommon) extractPart(input,
598 client.getItemCommonPartName(), PersonsCommon.class);
599 Assert.assertNotNull(person);
600 boolean showFull = true;
601 if (showFull && logger.isDebugEnabled()) {
602 logger.debug(testName + ": returned payload:");
603 logger.debug(objectAsXmlString(person, PersonsCommon.class));
606 // Check that the person item is within the expected Person Authority.
607 Assert.assertEquals(person.getInAuthority(), knownResourceId);
609 // Verify the number and contents of values in a repeatable field,
610 // as created in the instance record used for testing.
611 List<String> groups = person.getGroups().getGroup();
612 Assert.assertTrue(groups.size() > 0);
613 Assert.assertNotNull(groups.get(0));
616 res.releaseConnection();
622 * Verify item display name.
624 * @param testName the test name
625 * @throws Exception the exception
627 @Test(dataProvider = "testName", groups = {"update"},
628 dependsOnMethods = {"org.collectionspace.services.client.test.AbstractAuthorityServiceTest.updateItem"})
629 public void verifyItemDisplayName(String testName) throws Exception {
633 // Submit the request to the service and store the response.
634 PersonAuthorityClient client = new PersonAuthorityClient();
635 PoxPayloadIn input = null;
636 ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
638 assertStatusCode(res, testName);
639 // Check whether person has expected displayName.
640 input = new PoxPayloadIn(res.getEntity());
643 res.releaseConnection();
647 PersonsCommon person = (PersonsCommon) extractPart(input,
648 client.getItemCommonPartName(), PersonsCommon.class);
649 Assert.assertNotNull(person);
650 // Check whether person has expected displayName.
651 // Make sure displayName matches computed form
652 String displayName = person.getDisplayName();
653 String expectedDisplayName =
654 PersonAuthorityClientUtils.prepareDefaultDisplayName(
655 TEST_FORE_NAME, null, TEST_SUR_NAME,
656 TEST_BIRTH_DATE, TEST_DEATH_DATE);
657 Assert.assertFalse(displayName.equals(expectedDisplayName));
659 // Make sure short displayName matches computed form
660 String shortDisplayName = person.getShortDisplayName();
661 String expectedShortDisplayName =
662 PersonAuthorityClientUtils.prepareDefaultDisplayName(
663 TEST_FORE_NAME, null, TEST_SUR_NAME, null, null);
664 Assert.assertFalse(expectedShortDisplayName.equals(shortDisplayName));
666 // Update the forename and verify the computed name is updated.
667 person.setCsid(null);
668 person.setDisplayNameComputed(true);
669 person.setShortDisplayNameComputed(true);
670 person.setForeName("updated-" + TEST_FORE_NAME);
671 expectedDisplayName =
672 PersonAuthorityClientUtils.prepareDefaultDisplayName(
673 "updated-" + TEST_FORE_NAME, null, TEST_SUR_NAME,
674 TEST_BIRTH_DATE, TEST_DEATH_DATE);
675 expectedShortDisplayName =
676 PersonAuthorityClientUtils.prepareDefaultDisplayName(
677 "updated-" + TEST_FORE_NAME, null, TEST_SUR_NAME, null, null);
679 // Submit the updated resource to the service and store the response.
680 PoxPayloadOut output = new PoxPayloadOut(PersonAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
681 PayloadOutputPart commonPart = output.addPart(client.getItemCommonPartName(), person);
682 res = client.updateItem(knownResourceId, knownItemResourceId, output);
684 assertStatusCode(res, testName);
685 // Retrieve the updated resource and verify that its contents exist.
686 input = new PoxPayloadIn(res.getEntity());
689 res.releaseConnection();
693 PersonsCommon updatedPerson =
694 (PersonsCommon) extractPart(input,
695 client.getItemCommonPartName(), PersonsCommon.class);
696 Assert.assertNotNull(updatedPerson);
698 // Verify that the updated resource received the correct data.
699 Assert.assertEquals(updatedPerson.getForeName(), person.getForeName(),
700 "Updated ForeName in Person did not match submitted data.");
701 // Verify that the updated resource computes the right displayName.
702 Assert.assertEquals(updatedPerson.getDisplayName(), expectedDisplayName,
703 "Updated ForeName in Person not reflected in computed DisplayName.");
704 // Verify that the updated resource computes the right displayName.
705 Assert.assertEquals(updatedPerson.getShortDisplayName(), expectedShortDisplayName,
706 "Updated ForeName in Person not reflected in computed ShortDisplayName.");
708 // Now Update the displayName, not computed and verify the computed name is overriden.
709 person.setDisplayNameComputed(false);
710 expectedDisplayName = "TestName";
711 person.setDisplayName(expectedDisplayName);
712 person.setShortDisplayNameComputed(false);
713 person.setShortDisplayName(expectedDisplayName);
715 // Submit the updated resource to the service and store the response.
716 output = new PoxPayloadOut(PersonAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
717 commonPart = output.addPart(client.getItemCommonPartName(), person);
718 res = client.updateItem(knownResourceId, knownItemResourceId, output);
720 assertStatusCode(res, testName);
721 // Retrieve the updated resource and verify that its contents exist.
722 input = new PoxPayloadIn(res.getEntity());
725 res.releaseConnection();
730 (PersonsCommon) extractPart(input,
731 client.getItemCommonPartName(), PersonsCommon.class);
732 Assert.assertNotNull(updatedPerson);
734 // Verify that the updated resource received the correct data.
735 Assert.assertEquals(updatedPerson.isDisplayNameComputed(), false,
736 "Updated displayNameComputed in Person did not match submitted data.");
737 // Verify that the updated resource computes the right displayName.
738 Assert.assertEquals(updatedPerson.getDisplayName(),
740 "Updated DisplayName (not computed) in Person not stored.");
741 // Verify that the updated resource received the correct data.
742 Assert.assertEquals(updatedPerson.isShortDisplayNameComputed(), false,
743 "Updated shortDisplayNameComputed in Person did not match submitted data.");
744 // Verify that the updated resource computes the right displayName.
745 Assert.assertEquals(updatedPerson.getShortDisplayName(),
747 "Updated ShortDisplayName (not computed) in Person not stored.");
751 * Verify illegal item display name.
753 * @param testName the test name
754 * @throws Exception the exception
756 @Test(dataProvider = "testName", groups = {"update"},
757 dependsOnMethods = {"verifyItemDisplayName"})
758 public void verifyIllegalItemDisplayName(String testName) throws Exception {
759 // Perform setup for read.
762 // Submit the request to the service and store the response.
763 PersonAuthorityClient client = new PersonAuthorityClient();
764 ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
765 PoxPayloadIn input = null;
767 assertStatusCode(res, testName);
768 input = new PoxPayloadIn(res.getEntity());
771 res.releaseConnection();
775 // Make an invalid UPDATE request -i.e., if we don't want the display name computed, then
776 // we need to supply one.
778 PersonsCommon person = (PersonsCommon) extractPart(input,
779 client.getItemCommonPartName(), PersonsCommon.class);
780 Assert.assertNotNull(person);
781 // Try to Update with computed false and no displayName
782 person.setDisplayNameComputed(false);
783 person.setDisplayName(null);
785 // Submit the updated resource to the service and store the response.
786 PoxPayloadOut output = new PoxPayloadOut(PersonAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
787 PayloadOutputPart commonPart = output.addPart(client.getItemCommonPartName(), person);
788 setupUpdateWithInvalidBody();
789 res = client.updateItem(knownResourceId, knownItemResourceId, output);
791 assertStatusCode(res, testName);
794 res.releaseConnection();
802 * @param testName the test name
803 * @throws Exception the exception
805 @Test(dataProvider = "testName", groups = {"readItem"},
806 dependsOnMethods = {"createContact", "org.collectionspace.services.client.test.AbstractAuthorityServiceTest.readItem"})
807 public void readContact(String testName) throws Exception {
811 // Submit the request to the service and store the response.
812 PersonAuthorityClient client = new PersonAuthorityClient();
813 PoxPayloadIn input = null;
814 ClientResponse<String> res =
815 client.readContact(knownResourceId, knownItemResourceId,
816 knownContactResourceId);
818 assertStatusCode(res, testName);
819 // Check whether we've received a contact.
820 input = new PoxPayloadIn(res.getEntity());
823 res.releaseConnection();
827 ContactsCommon contact = (ContactsCommon) extractPart(input,
828 new ContactClient().getCommonPartName(), ContactsCommon.class);
829 Assert.assertNotNull(contact);
830 boolean showFull = true;
831 if (showFull && logger.isDebugEnabled()) {
832 logger.debug(testName + ": returned payload:");
833 logger.debug(objectAsXmlString(contact, ContactsCommon.class));
835 Assert.assertEquals(contact.getInAuthority(), knownResourceId);
836 Assert.assertEquals(contact.getInItem(), knownItemResourceId);
841 * Read contact non existent.
843 * @param testName the test name
845 @Test(dataProvider = "testName", groups = {"readItem"},
846 dependsOnMethods = {"readContact"})
847 public void readContactNonExistent(String testName) {
849 setupReadNonExistent();
851 // Submit the request to the service and store the response.
852 PersonAuthorityClient client = new PersonAuthorityClient();
853 ClientResponse<String> res =
854 client.readContact(knownResourceId, knownItemResourceId, NON_EXISTENT_ID);
856 assertStatusCode(res, testName);
859 res.releaseConnection();
864 // ---------------------------------------------------------------
865 // CRUD tests : READ_LIST tests
866 // ---------------------------------------------------------------
872 // @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
873 // groups = {"readList"}, dependsOnMethods = {"readList"})
874 public void readItemList(String testName) {
875 readItemList(knownAuthorityWithItems, null, testName);
879 * Read item list by authority name.
882 // @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
883 // groups = {"readList"}, dependsOnMethods = {"readItemList"})
884 public void readItemListByName(String testName) {
885 readItemList(null, READITEMS_SHORT_IDENTIFIER, testName);
891 * @param vcsid the vcsid
892 * @param name the name
894 private void readItemList(String vcsid, String name, String testName) {
896 // Submit the request to the service and store the response.
897 PersonAuthorityClient client = new PersonAuthorityClient();
898 ClientResponse<AbstractCommonList> res = null;
900 res = client.readItemList(vcsid, null, null);
901 } else if (name != null) {
902 res = client.readItemListForNamedAuthority(name, null, null);
904 Assert.fail("readItemList passed null csid and name!");
906 AbstractCommonList list = null;
908 assertStatusCode(res, testName);
909 list = res.getEntity();
912 res.releaseConnection();
916 List<AbstractCommonList.ListItem> items = list.getListItem();
917 int nItemsReturned = items.size();
918 // There will be 'nItemsToCreateInList'
919 // items created by the createItemList test,
920 // all associated with the same parent resource.
921 int nExpectedItems = nItemsToCreateInList;
922 if (logger.isDebugEnabled()) {
923 logger.debug(testName + ": Expected "
924 + nExpectedItems + " items; got: " + nItemsReturned);
926 Assert.assertEquals(nItemsReturned, nExpectedItems);
928 for (AbstractCommonList.ListItem item : items) {
930 AbstractCommonListUtils.ListItemGetElementValue(item, REFNAME);
931 Assert.assertTrue((null != value), "Item refName is null!");
933 AbstractCommonListUtils.ListItemGetElementValue(item, DISPLAYNAME);
934 Assert.assertTrue((null != value), "Item displayName is null!");
936 if (logger.isTraceEnabled()) {
937 AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
944 @Test(groups = {"readList"},
945 dependsOnMethods = {"org.collectionspace.services.client.test.AbstractAuthorityServiceTest.readItemList"})
946 public void readContactList() {
947 readContactList(knownResourceId, knownItemResourceId);
953 * @param parentcsid the parentcsid
954 * @param itemcsid the itemcsid
956 private void readContactList(String parentcsid, String itemcsid) {
957 final String testName = "readContactList";
962 // Submit the request to the service and store the response.
963 PersonAuthorityClient client = new PersonAuthorityClient();
964 AbstractCommonList list = null;
965 ClientResponse<AbstractCommonList> res =
966 client.readContactList(parentcsid, itemcsid);
968 assertStatusCode(res, testName);
969 list = res.getEntity();
972 res.releaseConnection();
976 List<AbstractCommonList.ListItem> listitems =
978 int nItemsReturned = listitems.size();
979 // There will be one item created, associated with a
980 // known parent resource, by the createItem test.
982 // In addition, there will be 'nItemsToCreateInList'
983 // additional items created by the createItemList test,
984 // all associated with the same parent resource.
985 int nExpectedItems = nItemsToCreateInList + 1;
986 if (logger.isDebugEnabled()) {
987 logger.debug(testName + ": Expected "
988 + nExpectedItems + " items; got: " + nItemsReturned);
990 Assert.assertEquals(nItemsReturned, nExpectedItems);
992 // Optionally output additional data about list members for debugging.
993 boolean iterateThroughList = false;
994 if (iterateThroughList && logger.isDebugEnabled()) {
995 AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
1000 // There are no failure outcome tests at present.
1001 // ---------------------------------------------------------------
1002 // CRUD tests : UPDATE tests
1003 // ---------------------------------------------------------------
1006 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
1009 // @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
1010 // groups = {"update"}, dependsOnGroups = {"readItem", "readList"})
1011 public void update(String testName) throws Exception {
1012 // Retrieve the contents of a resource to update.
1013 PersonAuthorityClient client = new PersonAuthorityClient();
1014 PoxPayloadIn input = null;
1016 ClientResponse<String> res = client.read(knownResourceId);
1018 assertStatusCode(res, testName);
1019 if (logger.isDebugEnabled()) {
1020 logger.debug("got PersonAuthority to update with ID: " + knownResourceId);
1022 input = new PoxPayloadIn(res.getEntity());
1025 res.releaseConnection();
1029 PersonauthoritiesCommon personAuthority = (PersonauthoritiesCommon) extractPart(input,
1030 client.getCommonPartName(), PersonauthoritiesCommon.class);
1031 Assert.assertNotNull(personAuthority);
1033 // Update the contents of this resource.
1034 personAuthority.setDisplayName("updated-" + personAuthority.getDisplayName());
1035 personAuthority.setVocabType("updated-" + personAuthority.getVocabType());
1036 if (logger.isDebugEnabled()) {
1037 logger.debug("to be updated PersonAuthority");
1038 logger.debug(objectAsXmlString(personAuthority, PersonauthoritiesCommon.class));
1041 // Submit the updated resource to the service and store the response.
1042 PoxPayloadOut output = new PoxPayloadOut(PersonAuthorityClient.SERVICE_PAYLOAD_NAME);
1043 PayloadOutputPart commonPart = output.addPart(client.getCommonPartName(), personAuthority);
1045 res = client.update(knownResourceId, output);
1047 assertStatusCode(res, testName);
1048 // Retrieve the updated resource and verify that its contents exist.
1049 input = new PoxPayloadIn(res.getEntity());
1052 res.releaseConnection();
1056 PersonauthoritiesCommon updatedPersonAuthority =
1057 (PersonauthoritiesCommon) extractPart(input,
1058 client.getCommonPartName(), PersonauthoritiesCommon.class);
1059 Assert.assertNotNull(updatedPersonAuthority);
1061 // Verify that the updated resource received the correct data.
1062 Assert.assertEquals(updatedPersonAuthority.getDisplayName(),
1063 personAuthority.getDisplayName(),
1064 "Data in updated object did not match submitted data.");
1070 * @param testName the test name
1071 * @throws Exception the exception
1074 // @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
1075 // groups = {"update"}, dependsOnMethods = {"update"})
1076 public void updateItem(String testName) throws Exception {
1077 // Retrieve the contents of a resource to update.
1078 PersonAuthorityClient client = new PersonAuthorityClient();
1079 PoxPayloadIn input = null;
1081 ClientResponse<String> res =
1082 client.readItem(knownResourceId, knownItemResourceId);
1084 assertStatusCode(res, testName);
1085 if (logger.isDebugEnabled()) {
1086 logger.debug("got Person to update with ID: "
1087 + knownItemResourceId
1088 + " in PersonAuthority: " + knownResourceId);
1090 input = new PoxPayloadIn(res.getEntity());
1093 res.releaseConnection();
1097 PersonsCommon person = (PersonsCommon) extractPart(input,
1098 client.getItemCommonPartName(), PersonsCommon.class);
1099 Assert.assertNotNull(person);
1101 if (logger.isDebugEnabled() == true) {
1102 logger.debug("About to update the following person...");
1103 logger.debug(objectAsXmlString(person, PersonsCommon.class));
1106 // Update the contents of this resource.
1107 person.setCsid(null);
1108 person.setForeName("updated-" + person.getForeName());
1109 if (logger.isDebugEnabled()) {
1110 logger.debug("to be updated Person");
1111 logger.debug(objectAsXmlString(person,
1112 PersonsCommon.class));
1115 // Submit the updated resource to the service and store the response.
1116 PoxPayloadOut output = new PoxPayloadOut(PersonAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
1117 PayloadOutputPart commonPart = output.addPart(client.getItemCommonPartName(), person);
1119 res = client.updateItem(knownResourceId, knownItemResourceId, output);
1121 assertStatusCode(res, testName);
1122 // Retrieve the updated resource and verify that its contents exist.
1123 input = new PoxPayloadIn(res.getEntity());
1126 res.releaseConnection();
1130 PersonsCommon updatedPerson =
1131 (PersonsCommon) extractPart(input,
1132 client.getItemCommonPartName(), PersonsCommon.class);
1133 Assert.assertNotNull(updatedPerson);
1135 if (logger.isDebugEnabled() == true) {
1136 logger.debug("Updated to following person to:");
1137 logger.debug(objectAsXmlString(updatedPerson, PersonsCommon.class));
1140 // Verify that the updated resource received the correct data.
1141 Assert.assertEquals(updatedPerson.getForeName(),
1142 person.getForeName(),
1143 "Data in updated Person did not match submitted data.");
1149 * @param testName the test name
1150 * @throws Exception the exception
1152 @Test(dataProvider = "testName", groups = {"update"},
1153 dependsOnMethods = {"readContact", "testContactSubmitRequest",
1154 "org.collectionspace.services.client.test.AbstractAuthorityServiceTest.updateItem"})
1155 public void updateContact(String testName) throws Exception {
1156 String contactsCommonLabel = new ContactClient().getCommonPartName();
1158 // Retrieve the contents of a resource to update.
1159 PersonAuthorityClient client = new PersonAuthorityClient();
1160 PoxPayloadIn input = null;
1162 ClientResponse<String> res =
1163 client.readContact(knownResourceId, knownItemResourceId, knownContactResourceId);
1165 assertStatusCode(res, testName);
1166 if (logger.isDebugEnabled()) {
1167 logger.debug("got Contact to update with ID: "
1168 + knownContactResourceId
1169 + " in item: " + knownItemResourceId
1170 + " in parent: " + knownResourceId);
1172 input = new PoxPayloadIn(res.getEntity());
1175 res.releaseConnection();
1179 ContactsCommon contact = (ContactsCommon) extractPart(input,
1180 contactsCommonLabel, ContactsCommon.class);
1181 Assert.assertNotNull(contact);
1183 // Verify the contents of this resource
1184 AddressGroupList addressGroupList = contact.getAddressGroupList();
1185 Assert.assertNotNull(addressGroupList);
1186 List<AddressGroup> addressGroups = addressGroupList.getAddressGroup();
1187 Assert.assertNotNull(addressGroups);
1188 Assert.assertTrue(addressGroups.size() > 0);
1189 String addressPlace1 = addressGroups.get(0).getAddressPlace1();
1190 Assert.assertNotNull(addressPlace1);
1192 // Update the contents of this resource.
1193 addressGroups.get(0).setAddressPlace1("updated-" + addressPlace1);
1194 contact.setAddressGroupList(addressGroupList);
1195 if (logger.isDebugEnabled()) {
1196 logger.debug("to be updated Contact");
1197 logger.debug(objectAsXmlString(contact,
1198 ContactsCommon.class));
1201 // Submit the updated resource to the service and store the response.
1202 PoxPayloadOut output = new PoxPayloadOut(ContactClient.SERVICE_PAYLOAD_NAME);
1203 PayloadOutputPart commonPart = output.addPart(contactsCommonLabel, contact);
1205 res = client.updateContact(knownResourceId, knownItemResourceId, knownContactResourceId, output);
1207 assertStatusCode(res, testName);
1208 // Retrieve the updated resource and verify that its contents exist.
1209 input = new PoxPayloadIn(res.getEntity());;
1212 res.releaseConnection();
1215 ContactsCommon updatedContact = (ContactsCommon) extractPart(input,
1216 contactsCommonLabel, ContactsCommon.class);
1217 Assert.assertNotNull(updatedContact);
1219 // Verify that the updated resource received the correct data.
1220 Assert.assertEquals(updatedContact.getAddressGroupList().getAddressGroup().get(0).getAddressPlace1(),
1221 contact.getAddressGroupList().getAddressGroup().get(0).getAddressPlace1(),
1222 "Data in updated object did not match submitted data.");
1226 * Update non existent contact.
1228 * @param testName the test name
1229 * @throws Exception the exception
1231 @Test(dataProvider = "testName", groups = {"update"},
1232 dependsOnMethods = {"updateContact", "testContactSubmitRequest"})
1233 public void updateNonExistentContact(String testName) throws Exception {
1234 // Currently a no-op test
1237 // ---------------------------------------------------------------
1238 // CRUD tests : DELETE tests
1239 // ---------------------------------------------------------------
1241 // Note: delete sub-resources in ascending hierarchical order,
1242 // before deleting their parents.
1246 * @param testName the test name
1247 * @throws Exception the exception
1249 @Test(dataProvider = "testName", groups = {"delete"},
1250 dependsOnMethods = {"updateContact"})
1251 public void deleteContact(String testName) throws Exception {
1252 if (logger.isDebugEnabled()) {
1253 logger.debug("parentcsid =" + knownResourceId
1254 + " itemcsid = " + knownItemResourceId
1255 + " csid = " + knownContactResourceId);
1258 // Submit the request to the service and store the response.
1259 PersonAuthorityClient client = new PersonAuthorityClient();
1261 ClientResponse<Response> res =
1262 client.deleteContact(knownResourceId, knownItemResourceId, knownContactResourceId);
1264 assertStatusCode(res, testName);
1267 res.releaseConnection();
1273 public void delete(String testName) throws Exception {
1274 // Do nothing. See localDelete(). This ensure proper test order.
1277 @Test(dataProvider = "testName", dependsOnMethods = {"localDeleteItem"})
1278 public void localDelete(String testName) throws Exception {
1279 super.delete(testName);
1283 public void deleteItem(String testName) throws Exception {
1284 // Do nothing. We need to wait until after the test "localDelete" gets run. When it does,
1285 // its dependencies will get run first and then we can call the base class' delete method.
1288 @Test(dataProvider = "testName", groups = {"delete"},
1289 dependsOnMethods = {"verifyIllegalItemDisplayName", "testContactSubmitRequest", "deleteContact"})
1290 public void localDeleteItem(String testName) throws Exception {
1291 super.deleteItem(testName);
1295 * Delete non existent contact.
1297 * @param testName the test name
1299 @Test(dataProvider = "testName", groups = {"delete"},
1300 dependsOnMethods = {"deleteContact"})
1301 public void deleteNonExistentContact(String testName) {
1302 // Submit the request to the service and store the response.
1303 PersonAuthorityClient client = new PersonAuthorityClient();
1304 setupDeleteNonExistent();
1305 ClientResponse<Response> res =
1306 client.deleteContact(knownResourceId, knownItemResourceId, NON_EXISTENT_ID);
1308 assertStatusCode(res, testName);
1311 res.releaseConnection();
1317 * Test contact submit request.
1319 @Test(dataProvider = "testName",
1320 dependsOnMethods = {"createContact", "readContact", "testItemSubmitRequest"})
1321 public void testContactSubmitRequest(String testName) {
1323 // Expected status code: 200 OK
1324 final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
1326 // Submit the request to the service and store the response.
1327 String method = ServiceRequestType.READ.httpMethodName();
1328 String url = getContactResourceURL(knownResourceId,
1329 knownItemResourceId, knownContactResourceId);
1330 int statusCode = submitRequest(method, url);
1332 // Check the status code of the response: does it match
1333 // the expected response(s)?
1334 if (logger.isDebugEnabled()) {
1335 logger.debug("testContactSubmitRequest: url=" + url
1336 + " status=" + statusCode);
1338 Assert.assertEquals(statusCode, EXPECTED_STATUS);
1342 // ---------------------------------------------------------------
1343 // Cleanup of resources created during testing
1344 // ---------------------------------------------------------------
1346 * Deletes all resources created by tests, after all tests have been run.
1348 * This cleanup method will always be run, even if one or more tests fail.
1349 * For this reason, it attempts to remove all resources created
1350 * at any point during testing, even if some of those resources
1351 * may be expected to be deleted by certain tests.
1353 @AfterClass(alwaysRun = true)
1355 public void cleanUp() {
1356 String noTest = System.getProperty("noTestCleanup");
1357 if (Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
1358 if (logger.isDebugEnabled()) {
1359 logger.debug("Skipping Cleanup phase ...");
1363 if (logger.isDebugEnabled()) {
1364 logger.debug("Cleaning up temporary resources created for testing ...");
1366 String parentResourceId;
1367 String itemResourceId;
1368 String contactResourceId;
1369 // Clean up contact resources.
1370 PersonAuthorityClient client = new PersonAuthorityClient();
1371 parentResourceId = knownResourceId;
1372 for (Map.Entry<String, String> entry : allContactResourceIdsCreated.entrySet()) {
1373 contactResourceId = entry.getKey();
1374 itemResourceId = entry.getValue();
1375 // Note: Any non-success responses from the delete operation
1376 // below are ignored and not reported.
1377 ClientResponse<Response> res =
1378 client.deleteContact(parentResourceId, itemResourceId, contactResourceId);
1379 res.releaseConnection();
1381 // Clean up item resources.
1382 for (Map.Entry<String, String> entry : allResourceItemIdsCreated.entrySet()) {
1383 itemResourceId = entry.getKey();
1384 parentResourceId = entry.getValue();
1385 // Note: Any non-success responses from the delete operation
1386 // below are ignored and not reported.
1387 ClientResponse<Response> res =
1388 client.deleteItem(parentResourceId, itemResourceId);
1389 res.releaseConnection();
1391 // Clean up parent resources.
1395 // ---------------------------------------------------------------
1396 // Utility methods used by tests above
1397 // ---------------------------------------------------------------
1399 * Gets the contact service path component.
1401 * @return the contact service path component
1403 public String getContactServicePathComponent() {
1404 return ContactClient.SERVICE_PATH_COMPONENT;
1408 * Returns the root URL for the item service.
1410 * This URL consists of a base URL for all services, followed by
1411 * a path component for the owning parent, followed by the
1412 * path component for the items.
1414 * @param parentResourceIdentifier An identifier (such as a UUID) for the
1415 * parent authority resource of the relevant item resource.
1417 * @return The root URL for the item service.
1419 protected String getItemServiceRootURL(String parentResourceIdentifier) {
1420 return getResourceURL(parentResourceIdentifier) + "/" + getItemServicePathComponent();
1424 * Returns the URL of a specific item resource managed by a service, and
1425 * designated by an identifier (such as a universally unique ID, or UUID).
1427 * @param parentResourceIdentifier An identifier (such as a UUID) for the
1428 * parent authority resource of the relevant item resource.
1430 * @param itemResourceIdentifier An identifier (such as a UUID) for an
1433 * @return The URL of a specific item resource managed by a service.
1435 protected String getItemResourceURL(String parentResourceIdentifier, String itemResourceIdentifier) {
1436 return getItemServiceRootURL(parentResourceIdentifier) + "/" + itemResourceIdentifier;
1440 * Returns the root URL for the contact service.
1442 * This URL consists of a base URL for all services, followed by
1443 * a path component for the owning authority, followed by the
1444 * path component for the owning item, followed by the path component
1445 * for the contact service.
1447 * @param parentResourceIdentifier An identifier (such as a UUID) for the
1448 * parent authority resource of the relevant item resource.
1450 * @param itemResourceIdentifier An identifier (such as a UUID) for an
1453 * @return The root URL for the contact service.
1455 protected String getContactServiceRootURL(String parentResourceIdentifier,
1456 String itemResourceIdentifier) {
1457 return getItemResourceURL(parentResourceIdentifier, itemResourceIdentifier) + "/"
1458 + getContactServicePathComponent();
1462 * Returns the URL of a specific contact resource managed by a service, and
1463 * designated by an identifier (such as a universally unique ID, or UUID).
1465 * @param parentResourceIdentifier An identifier (such as a UUID) for the
1466 * parent resource of the relevant item resource.
1468 * @param resourceIdentifier An identifier (such as a UUID) for an
1471 * @return The URL of a specific resource managed by a service.
1473 protected String getContactResourceURL(String parentResourceIdentifier,
1474 String itemResourceIdentifier, String contactResourceIdentifier) {
1475 return getContactServiceRootURL(parentResourceIdentifier,
1476 itemResourceIdentifier) + "/" + contactResourceIdentifier;
1480 public void authorityTests(String testName) {
1481 // TODO Auto-generated method stub
1486 protected PersonsCommon updateItemInstance(PersonsCommon authorityItem) {
1487 // TODO Auto-generated method stub
1492 protected void compareUpdatedItemInstances(PersonsCommon original,
1493 PersonsCommon updated) throws Exception {
1494 // TODO Auto-generated method stub
1499 protected PoxPayloadOut createInstance(String commonPartName,
1500 String identifier) {
1501 String shortId = identifier;
1502 String displayName = "displayName-" + shortId;
1503 PoxPayloadOut result =
1504 PersonAuthorityClientUtils.createPersonAuthorityInstance(
1505 displayName, shortId, commonPartName);
1510 protected PoxPayloadOut createNonExistenceInstance(String commonPartName,
1511 String identifier) {
1512 String displayName = "displayName-NON_EXISTENT_ID";
1513 PoxPayloadOut result = PersonAuthorityClientUtils.createPersonAuthorityInstance(
1514 displayName, "NON_EXISTENT_SHORT_ID", commonPartName);
1518 protected PoxPayloadOut createNonExistenceItemInstance(String commonPartName, String identifier) {
1519 Map<String, String> nonexMap = new HashMap<String, String>();
1520 nonexMap.put(PersonJAXBSchema.SHORT_IDENTIFIER, "nonEX");
1521 nonexMap.put(PersonJAXBSchema.FORE_NAME, "John");
1522 nonexMap.put(PersonJAXBSchema.SUR_NAME, "Wayne");
1523 nonexMap.put(PersonJAXBSchema.GENDER, "male");
1524 Map<String, List<String>> nonexRepeatablesMap = new HashMap<String, List<String>>();
1525 PoxPayloadOut result =
1526 PersonAuthorityClientUtils.createPersonInstance(NON_EXISTENT_ID,
1527 null, //PersonAuthorityClientUtils.createPersonAuthRefName(NON_EXISTENT_ID, null),
1528 nonexMap, nonexRepeatablesMap, commonPartName);
1534 protected PersonauthoritiesCommon updateInstance(
1535 PersonauthoritiesCommon commonPartObject) {
1536 // TODO Auto-generated method stub
1541 protected void compareUpdatedInstances(PersonauthoritiesCommon original,
1542 PersonauthoritiesCommon updated) throws Exception {
1543 // TODO Auto-generated method stub
1547 protected void verifyReadItemInstance(PersonsCommon item) throws Exception {
1548 // Do nothing for now. Add more 'read' validation checks here if applicable.