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.common.vocabulary.AuthorityItemJAXBSchema;
49 import org.collectionspace.services.person.PersonauthoritiesCommon;
50 import org.collectionspace.services.person.PersonTermGroup;
51 import org.collectionspace.services.person.PersonTermGroupList;
52 import org.collectionspace.services.person.PersonsCommon;
54 import org.jboss.resteasy.client.ClientResponse;
55 //import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
56 import org.slf4j.Logger;
57 import org.slf4j.LoggerFactory;
58 import org.testng.Assert;
59 import org.testng.annotations.AfterClass;
60 import org.testng.annotations.Test;
63 * PersonAuthorityServiceTest, carries out tests against a
64 * deployed and running PersonAuthority Service.
66 * $LastChangedRevision: 753 $
67 * $LastChangedDate: 2009-09-23 11:03:36 -0700 (Wed, 23 Sep 2009) $
69 public class PersonAuthorityServiceTest extends AbstractAuthorityServiceTest<PersonauthoritiesCommon, PersonsCommon> { //FIXME: Test classes for Vocab, Person, Org, and Location should have a base class!
72 private final String CLASS_NAME = PersonAuthorityServiceTest.class.getName();
73 private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
76 public String getServicePathComponent() {
77 return PersonAuthorityClient.SERVICE_PATH_COMPONENT;
81 protected String getServiceName() {
82 return PersonAuthorityClient.SERVICE_NAME;
85 public String getItemServicePathComponent() {
86 return AuthorityClient.ITEMS;
88 /** The test forename. */
89 final String TEST_FORE_NAME = "John";
90 /** The test middle name. */
91 final String TEST_MIDDLE_NAME = null;
92 /** The test surname. */
93 final String TEST_SUR_NAME = "Wayne";
94 /** The test birthdate. */
95 final String TEST_BIRTH_DATE = "May 26, 1907";
96 /** The test death date. */
97 final String TEST_DEATH_DATE = "June 11, 1979";
98 //private String knownResourceRefName = null;
99 private String knownItemResourceShortIdentifer = null;
100 // The resource ID of an item resource used for partial term matching tests.
101 private String knownItemPartialTermResourceId = null;
102 /** The known contact resource id. */
103 private String knownContactResourceId = null;
104 /** The all contact resource ids created. */
105 private Map<String, String> allContactResourceIdsCreated =
106 new HashMap<String, String>();
108 protected void setKnownResource(String id, String shortIdentifer,
110 knownResourceId = id;
111 knownResourceShortIdentifer = shortIdentifer;
112 //knownResourceRefName = refName;
115 protected void setKnownItemResource(String id, String shortIdentifer) {
116 knownItemResourceId = id;
117 knownItemResourceShortIdentifer = shortIdentifer;
121 * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
124 protected CollectionSpaceClient getClientInstance() {
125 return new PersonAuthorityClient();
128 // ---------------------------------------------------------------
129 // CRUD tests : CREATE tests
130 // ---------------------------------------------------------------
133 * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
136 // @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
137 // groups = {"create"})
138 public void create(String testName) throws Exception {
139 // Perform setup, such as initializing the type of service request
140 // (e.g. CREATE, DELETE), its valid and expected status codes, and
141 // its associated HTTP method name (e.g. POST, DELETE).
144 // Submit the request to the service and store the response.
145 PersonAuthorityClient client = new PersonAuthorityClient();
146 String shortId = createIdentifier();
147 String displayName = "displayName-" + shortId;
148 //String baseRefName = PersonAuthorityClientUtils.createPersonAuthRefName(shortId, null);
149 PoxPayloadOut multipart =
150 PersonAuthorityClientUtils.createPersonAuthorityInstance(
151 displayName, shortId, client.getCommonPartName());
154 ClientResponse<Response> res = client.create(multipart);
156 assertStatusCode(res, testName);
157 newID = extractId(res);
160 res.releaseConnection();
163 // Save values for additional tests
164 if (knownResourceId == null) {
165 setKnownResource(newID, shortId, null ); //baseRefName);
166 if (logger.isDebugEnabled()) {
167 logger.debug(testName + ": knownResourceId=" + knownResourceId);
170 // Store the IDs from every resource created by tests,
171 // so they can be deleted after tests have been run.
172 allResourceIdsCreated.add(newID);
176 protected PoxPayloadOut createInstance(String identifier) {
177 PersonAuthorityClient client = new PersonAuthorityClient();
178 String displayName = "displayName-" + identifier;
179 PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance(
180 displayName, identifier, client.getCommonPartName());
185 protected PoxPayloadOut createItemInstance(String parentCsid, String identifier) {
186 String headerLabel = new PersonAuthorityClient().getItemCommonPartName();
188 HashMap<String, String> personInfo = new HashMap<String, String>();
189 String shortId = "johnWayneTempActor";
190 personInfo.put(PersonJAXBSchema.SHORT_IDENTIFIER, shortId);
192 List<PersonTermGroup> terms = new ArrayList<PersonTermGroup>();
193 PersonTermGroup term = new PersonTermGroup();
194 term.setTermDisplayName("John Wayne Temp");
195 term.setTermName("JohnWayneTemp");
198 return PersonAuthorityClientUtils.createPersonInstance(parentCsid, identifier, personInfo, terms, headerLabel);
202 * Creates an item in an authority, using test data.
204 * @param vcsid the vcsid
205 * @param authRefName the auth ref name
209 protected String createItemInAuthority(String vcsid) {
211 final String testName = "createItemInAuthority";
212 if (logger.isDebugEnabled()) {
213 logger.debug(testName + ":" + vcsid + "...");
216 Map<String, String> johnWayneMap = new HashMap<String, String>();
218 // Fill the property map
220 String shortId = "johnWayneActor";
221 johnWayneMap.put(PersonJAXBSchema.SHORT_IDENTIFIER, shortId);
222 johnWayneMap.put(PersonJAXBSchema.GENDER, "male");
223 johnWayneMap.put(PersonJAXBSchema.BIRTH_DATE, TEST_BIRTH_DATE);
224 johnWayneMap.put(PersonJAXBSchema.BIRTH_PLACE, "Winterset, Iowa");
225 johnWayneMap.put(PersonJAXBSchema.DEATH_DATE, TEST_DEATH_DATE);
226 johnWayneMap.put(PersonJAXBSchema.BIO_NOTE, "born Marion Robert Morrison and better"
227 + "known by his stage name John Wayne, was an American film actor, director "
228 + "and producer. He epitomized rugged masculinity and has become an enduring "
229 + "American icon. He is famous for his distinctive voice, walk and height. "
230 + "He was also known for his conservative political views and his support in "
231 + "the 1950s for anti-communist positions.");
233 List<PersonTermGroup> johnWayneTerms = new ArrayList<PersonTermGroup>();
234 PersonTermGroup term = new PersonTermGroup();
235 term.setTermDisplayName("John Wayne DisplayName");
236 term.setTermName("John Wayne");
237 term.setForeName(TEST_FORE_NAME);
238 term.setSurName(TEST_SUR_NAME);
239 johnWayneTerms.add(term);
241 Map<String, List<String>> johnWayneRepeatablesMap = new HashMap<String, List<String>>();
242 List<String> johnWayneGroups = new ArrayList<String>();
243 johnWayneGroups.add("Irish");
244 johnWayneGroups.add("Scottish");
245 johnWayneRepeatablesMap.put(PersonJAXBSchema.GROUPS, johnWayneGroups);
247 return createItemInAuthority(vcsid, null /*authRefName*/, shortId, johnWayneMap, johnWayneTerms, johnWayneRepeatablesMap);
252 * Creates an item in an authority.
254 * @param vcsid the vcsid
255 * @param authRefName the auth ref name
256 * @param itemFieldProperties a set of properties specifying the values of fields.
257 * @param itemRepeatableFieldProperties a set of properties specifying the values of repeatable fields.
260 private String createItemInAuthority(String vcsid, String authRefName, String shortId,
261 Map itemFieldProperties, List<PersonTermGroup> terms, Map itemRepeatableFieldProperties) {
263 final String testName = "createItemInAuthority";
264 if (logger.isDebugEnabled()) {
265 logger.debug(testName + ":" + vcsid + "...");
268 // Submit the request to the service and store the response.
269 PersonAuthorityClient client = new PersonAuthorityClient();
270 PoxPayloadOut multipart =
271 PersonAuthorityClientUtils.createPersonInstance(vcsid, null /*authRefName*/, itemFieldProperties,
272 terms, itemRepeatableFieldProperties, client.getItemCommonPartName());
274 ClientResponse<Response> res = client.createItem(vcsid, multipart);
277 assertStatusCode(res, testName);
278 newID = PersonAuthorityClientUtils.extractId(res);
281 res.releaseConnection();
285 // Store the ID returned from the first item resource created
286 // for additional tests below.
287 if (knownItemResourceId == null) {
288 setKnownItemResource(newID, shortId);
289 if (logger.isDebugEnabled()) {
290 logger.debug(testName + ": knownItemResourceId=" + knownItemResourceId);
293 if (logger.isDebugEnabled()) {
294 logger.debug(testName + " (created):" + vcsid + "/(" + newID + "," + shortId + ")");
297 // Store the IDs from any item resources created
298 // by tests, along with the IDs of their parents, so these items
299 // can be deleted after all tests have been run.
300 allResourceItemIdsCreated.put(newID, vcsid);
306 * Creates the contact.
308 * @param testName the test name
310 @Test(dataProvider = "testName", groups = {"create"},
311 dependsOnMethods = {"createItem"})
312 public void createContact(String testName) {
314 String newID = createContactInItem(knownResourceId, knownItemResourceId);
318 * Creates the contact in item.
320 * @param parentcsid the parentcsid
321 * @param itemcsid the itemcsid
324 private String createContactInItem(String parentcsid, String itemcsid) {
326 final String testName = "createContactInItem";
327 if (logger.isDebugEnabled()) {
328 logger.debug(testName + ":...");
330 // Submit the request to the service and store the response.
331 PersonAuthorityClient client = new PersonAuthorityClient();
332 String identifier = createIdentifier();
333 PoxPayloadOut multipart = ContactClientUtils.createContactInstance(parentcsid,
334 itemcsid, identifier, new ContactClient().getCommonPartName());
337 ClientResponse<Response> res =
338 client.createContact(parentcsid, itemcsid, multipart);
341 assertStatusCode(res, testName);
342 newID = PersonAuthorityClientUtils.extractId(res);
345 res.releaseConnection();
349 // Store the ID returned from the first contact resource created
350 // for additional tests below.
351 if (knownContactResourceId == null) {
352 knownContactResourceId = newID;
353 if (logger.isDebugEnabled()) {
354 logger.debug(testName + ": knownContactResourceId=" + knownContactResourceId);
358 // Store the IDs from any contact resources created
359 // by tests, along with the IDs of their parent items,
360 // so these items can be deleted after all tests have been run.
361 allContactResourceIdsCreated.put(newID, itemcsid);
367 * Attempts to create an authority with an short identifier that contains
368 * non-word characters.
370 * @param testName the test name
372 @Test(dataProvider = "testName", groups = {"create", "nonWordCharsInShortId"})
373 public void createWithShortIdNonWordChars(String testName) throws Exception {
374 testExpectedStatusCode = STATUS_BAD_REQUEST;
375 testRequestType = ServiceRequestType.CREATE;
376 testSetup(testExpectedStatusCode, testRequestType);
378 // Create the payload to be included in the body of the request
379 PersonAuthorityClient client = new PersonAuthorityClient();
380 String shortId = createIdentifier() + "*" + createIdentifier();
381 String displayName = "displayName-" + shortId;
382 PoxPayloadOut multipart =
383 PersonAuthorityClientUtils.createPersonAuthorityInstance(
384 displayName, shortId, client.getCommonPartName());
386 // Submit the request to the service and store the response.
387 ClientResponse<Response> res = client.create(multipart);
389 // Check the status code of the response: does it match
390 // the expected response(s)?
392 assertStatusCode(res, testName);
395 res.releaseConnection();
401 * Attempts to create an item with an short identifier that contains
402 * non-word characters.
404 * @param testName the test name
406 @Test(dataProvider = "testName", groups = {"create", "nonWordCharsInShortId"},
407 dependsOnMethods = {"org.collectionspace.services.client.test.AbstractServiceTestImpl.create"})
408 public void createItemWithShortIdNonWordChars(String testName) {
409 testExpectedStatusCode = STATUS_BAD_REQUEST;
410 testRequestType = ServiceRequestType.CREATE;
411 testSetup(testExpectedStatusCode, testRequestType);
413 PersonAuthorityClient client = new PersonAuthorityClient();
414 // Create the payload to be included in the body of the request
415 String shortId = "7-Eleven";
416 Map<String, String> fieldProperties = new HashMap<String, String>();
417 fieldProperties.put(PersonJAXBSchema.SHORT_IDENTIFIER, shortId);
419 List<PersonTermGroup> terms = new ArrayList<PersonTermGroup>();
420 PersonTermGroup term = new PersonTermGroup();
421 term.setTermDisplayName(shortId);
422 term.setTermName(shortId);
425 final Map NULL_REPEATABLE_FIELD_PROPERTIES = null;
426 PoxPayloadOut multipart =
427 PersonAuthorityClientUtils.createPersonInstance(knownResourceId,
428 null /*knownResourceRefName*/, fieldProperties, terms,
429 NULL_REPEATABLE_FIELD_PROPERTIES, client.getItemCommonPartName());
431 // Send the request and receive a response
432 ClientResponse<Response> res = client.createItem(knownResourceId, multipart);
433 // Check the status code of the response: does it match
434 // the expected response(s)?
436 assertStatusCode(res, testName);
439 res.releaseConnection();
444 // ---------------------------------------------------------------
445 // CRUD tests : CREATE LIST tests
446 // ---------------------------------------------------------------
449 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
452 // @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
453 // groups = {"createList"}, dependsOnGroups = {"create"})
454 public void createList(String testName) throws Exception {
455 for (int i = 0; i < nItemsToCreateInList; i++) {
461 * Creates the contact list.
463 * @param testName the test name
464 * @throws Exception the exception
466 @Test(dataProvider = "testName", groups = {"createList"},
467 dependsOnMethods = {"org.collectionspace.services.client.test.AbstractAuthorityServiceTest.createItemList"})
468 public void createContactList(String testName) throws Exception {
469 // Add contacts to the initially-created, known item record.
470 for (int j = 0; j < nItemsToCreateInList; j++) {
471 createContact(testName);
475 // ---------------------------------------------------------------
476 // CRUD tests : READ tests
477 // ---------------------------------------------------------------
480 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
483 // @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
484 // groups = {"read"}, dependsOnGroups = {"create"})
485 public void read(String testName) throws Exception {
486 readInternal(testName, knownResourceId, null);
492 * @param testName the test name
493 * @throws Exception the exception
496 // @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
497 // groups = {"read"}, dependsOnMethods = {"read"})
498 public void readByName(String testName) throws Exception {
499 readInternal(testName, null, knownResourceShortIdentifer);
502 protected void readInternal(String testName, String CSID, String shortId) {
503 // Submit the request to the service and store the response.
504 PersonAuthorityClient client = new PersonAuthorityClient();
505 ClientResponse<String> res = null;
508 res = client.read(CSID);
509 } else if (shortId != null) {
510 res = client.readByName(shortId);
512 Assert.fail("readInternal: Internal error. One of CSID or shortId must be non-null");
515 assertStatusCode(res, testName);
516 //FIXME: remove the following try catch once Aron fixes signatures
518 PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
519 PersonauthoritiesCommon personAuthority = (PersonauthoritiesCommon) extractPart(input,
520 client.getCommonPartName(), PersonauthoritiesCommon.class);
521 Assert.assertNotNull(personAuthority);
522 } catch (Exception e) {
523 throw new RuntimeException(e);
527 res.releaseConnection();
535 * @param testName the test name
536 * @throws Exception the exception
538 @Test(dataProvider = "testName", groups = {"readItem", "readNamedItemInNamedAuth"},
539 dependsOnMethods = {"readItemInNamedAuth"})
540 public void readNamedItem(String testName) throws Exception {
541 readItemInternal(testName, knownResourceId, null, null, knownItemResourceShortIdentifer);
545 * Read item in Named Auth.
547 * @param testName the test name
548 * @throws Exception the exception
550 @Test(dataProvider = "testName", groups = {"readItem"},
551 dependsOnMethods = {"readItem"})
552 public void readItemInNamedAuth(String testName) throws Exception {
553 readItemInternal(testName, null, knownResourceShortIdentifer, knownItemResourceId, null);
558 * Read Named item in Named Auth.
560 * @param testName the test name
561 * @throws Exception the exception
563 @Test(dataProvider = "testName", groups = {"readItem"},
564 dependsOnMethods = {"readNamedItem"})
565 public void readNamedItemInNamedAuth(String testName) throws Exception {
566 readItemInternal(testName, null, knownResourceShortIdentifer, null, knownItemResourceShortIdentifer);
569 protected void readItemInternal(String testName,
570 String authCSID, String authShortId, String itemCSID, String itemShortId)
573 if (logger.isDebugEnabled()) {
574 logger.debug("Reading:" + ((authCSID != null) ? authCSID : authShortId) + "/"
575 + ((itemCSID != null) ? authCSID : itemShortId));
578 // Submit the request to the service and store the response.
579 PersonAuthorityClient client = new PersonAuthorityClient();
581 ClientResponse<String> res = null;
582 if (authCSID != null) {
583 if (itemCSID != null) {
584 res = client.readItem(authCSID, itemCSID);
585 } else if (itemShortId != null) {
586 res = client.readNamedItem(authCSID, itemShortId);
588 Assert.fail("readInternal: Internal error. One of CSID or shortId must be non-null");
590 } else if (authShortId != null) {
591 if (itemCSID != null) {
592 res = client.readItemInNamedAuthority(authShortId, itemCSID);
593 } else if (itemShortId != null) {
594 res = client.readNamedItemInNamedAuthority(authShortId, itemShortId);
596 Assert.fail("readInternal: Internal error. One of CSID or shortId must be non-null");
599 Assert.fail("readInternal: Internal error. One of authCSID or authShortId must be non-null");
602 assertStatusCode(res, testName);
603 // Check whether we've received a person.
604 PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
605 PersonsCommon person = (PersonsCommon) extractPart(input,
606 client.getItemCommonPartName(), PersonsCommon.class);
607 Assert.assertNotNull(person);
608 boolean showFull = true;
609 if (showFull && logger.isDebugEnabled()) {
610 logger.debug(testName + ": returned payload:");
611 logger.debug(objectAsXmlString(person, PersonsCommon.class));
614 // Check that the person item is within the expected Person Authority.
615 Assert.assertEquals(person.getInAuthority(), knownResourceId);
617 // Verify the number and contents of values in a repeatable field,
618 // as created in the instance record used for testing.
619 List<String> groups = person.getGroups().getGroup();
620 Assert.assertTrue(groups.size() > 0);
621 Assert.assertNotNull(groups.get(0));
624 res.releaseConnection();
629 // Note: This test depends on server-side validation logic to require
630 // a non-null (and potentially, non-empty) displayname for each term,
631 // and will fail if that validation is not present.
634 * Verify illegal item display name.
636 * @param testName the test name
637 * @throws Exception the exception
639 @Test(dataProvider = "testName", groups = {"update"})
640 public void verifyIllegalItemDisplayName(String testName) throws Exception {
641 // Perform setup for read.
644 // Submit the request to the service and store the response.
645 PersonAuthorityClient client = new PersonAuthorityClient();
646 ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
647 PoxPayloadIn input = null;
649 assertStatusCode(res, testName);
650 input = new PoxPayloadIn(res.getEntity());
653 res.releaseConnection();
657 // Make an invalid UPDATE request, without a display name
659 PersonsCommon person = (PersonsCommon) extractPart(input,
660 client.getItemCommonPartName(), PersonsCommon.class);
661 Assert.assertNotNull(person);
662 // Try to Update with no displayName
663 PersonTermGroupList termList = person.getPersonTermGroupList();
664 Assert.assertNotNull(termList);
665 List<PersonTermGroup> terms = termList.getPersonTermGroup();
666 Assert.assertNotNull(terms);
667 Assert.assertTrue(terms.size() > 0);
668 terms.get(0).setTermDisplayName(null);
669 terms.get(0).setTermName(null);
671 // Submit the updated resource to the service and store the response.
672 PoxPayloadOut output = new PoxPayloadOut(PersonAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
673 PayloadOutputPart commonPart = output.addPart(client.getItemCommonPartName(), person);
674 setupUpdateWithInvalidBody();
675 res = client.updateItem(knownResourceId, knownItemResourceId, output);
677 assertStatusCode(res, testName);
680 res.releaseConnection();
688 * @param testName the test name
689 * @throws Exception the exception
691 @Test(dataProvider = "testName", groups = {"readItem"},
692 dependsOnMethods = {"createContact", "org.collectionspace.services.client.test.AbstractAuthorityServiceTest.readItem"})
693 public void readContact(String testName) throws Exception {
697 // Submit the request to the service and store the response.
698 PersonAuthorityClient client = new PersonAuthorityClient();
699 PoxPayloadIn input = null;
700 ClientResponse<String> res =
701 client.readContact(knownResourceId, knownItemResourceId,
702 knownContactResourceId);
704 assertStatusCode(res, testName);
705 // Check whether we've received a contact.
706 input = new PoxPayloadIn(res.getEntity());
709 res.releaseConnection();
713 ContactsCommon contact = (ContactsCommon) extractPart(input,
714 new ContactClient().getCommonPartName(), ContactsCommon.class);
715 Assert.assertNotNull(contact);
716 boolean showFull = true;
717 if (showFull && logger.isDebugEnabled()) {
718 logger.debug(testName + ": returned payload:");
719 logger.debug(objectAsXmlString(contact, ContactsCommon.class));
721 Assert.assertEquals(contact.getInAuthority(), knownResourceId);
722 Assert.assertEquals(contact.getInItem(), knownItemResourceId);
727 * Read contact non existent.
729 * @param testName the test name
731 @Test(dataProvider = "testName", groups = {"readItem"},
732 dependsOnMethods = {"readContact"})
733 public void readContactNonExistent(String testName) {
735 setupReadNonExistent();
737 // Submit the request to the service and store the response.
738 PersonAuthorityClient client = new PersonAuthorityClient();
739 ClientResponse<String> res =
740 client.readContact(knownResourceId, knownItemResourceId, NON_EXISTENT_ID);
742 assertStatusCode(res, testName);
745 res.releaseConnection();
750 // ---------------------------------------------------------------
751 // CRUD tests : READ_LIST tests
752 // ---------------------------------------------------------------
758 // @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
759 // groups = {"readList"}, dependsOnMethods = {"readList"})
760 public void readItemList(String testName) {
761 readItemList(knownAuthorityWithItems, null, testName);
765 * Read item list by authority name.
768 // @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
769 // groups = {"readList"}, dependsOnMethods = {"readItemList"})
770 public void readItemListByName(String testName) {
771 readItemList(null, READITEMS_SHORT_IDENTIFIER, testName);
777 * @param vcsid the vcsid
778 * @param name the name
780 private void readItemList(String vcsid, String name, String testName) {
782 // Submit the request to the service and store the response.
783 PersonAuthorityClient client = new PersonAuthorityClient();
784 ClientResponse<AbstractCommonList> res = null;
786 res = client.readItemList(vcsid, null, null);
787 } else if (name != null) {
788 res = client.readItemListForNamedAuthority(name, null, null);
790 Assert.fail("readItemList passed null csid and name!");
792 AbstractCommonList list = null;
794 assertStatusCode(res, testName);
795 list = res.getEntity();
798 res.releaseConnection();
802 List<AbstractCommonList.ListItem> items = list.getListItem();
803 int nItemsReturned = items.size();
804 // There will be 'nItemsToCreateInList'
805 // items created by the createItemList test,
806 // all associated with the same parent resource.
807 int nExpectedItems = nItemsToCreateInList;
808 if (logger.isDebugEnabled()) {
809 logger.debug(testName + ": Expected "
810 + nExpectedItems + " items; got: " + nItemsReturned);
812 Assert.assertEquals(nItemsReturned, nExpectedItems);
814 for (AbstractCommonList.ListItem item : items) {
816 AbstractCommonListUtils.ListItemGetElementValue(item, AuthorityItemJAXBSchema.REF_NAME);
817 Assert.assertTrue((null != value), "Item refName is null!");
819 // Per CSPACE-5132, lists items still return a field named displayName,
820 // not termDisplayName, for backward compatibility.
821 // (The format of list items will change significantly in CSPACE-5134.)
823 AbstractCommonListUtils.ListItemGetElementValue(item, AuthorityItemJAXBSchema.DISPLAY_NAME);
824 Assert.assertTrue((null != value), "Item displayName is null!");
826 if (logger.isTraceEnabled()) {
827 AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
834 @Test(groups = {"readList"},
835 dependsOnMethods = {"org.collectionspace.services.client.test.AbstractAuthorityServiceTest.readItemList"})
836 public void readContactList() {
837 readContactList(knownResourceId, knownItemResourceId);
843 * @param parentcsid the parentcsid
844 * @param itemcsid the itemcsid
846 private void readContactList(String parentcsid, String itemcsid) {
847 final String testName = "readContactList";
852 // Submit the request to the service and store the response.
853 PersonAuthorityClient client = new PersonAuthorityClient();
854 AbstractCommonList list = null;
855 ClientResponse<AbstractCommonList> res =
856 client.readContactList(parentcsid, itemcsid);
858 assertStatusCode(res, testName);
859 list = res.getEntity();
862 res.releaseConnection();
866 List<AbstractCommonList.ListItem> listitems =
868 int nItemsReturned = listitems.size();
869 // There will be one item created, associated with a
870 // known parent resource, by the createItem test.
872 // In addition, there will be 'nItemsToCreateInList'
873 // additional items created by the createItemList test,
874 // all associated with the same parent resource.
875 int nExpectedItems = nItemsToCreateInList + 1;
876 if (logger.isDebugEnabled()) {
877 logger.debug(testName + ": Expected "
878 + nExpectedItems + " items; got: " + nItemsReturned);
880 Assert.assertEquals(nItemsReturned, nExpectedItems);
882 // Optionally output additional data about list members for debugging.
883 boolean iterateThroughList = false;
884 if (iterateThroughList && logger.isDebugEnabled()) {
885 AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
890 // There are no failure outcome tests at present.
891 // ---------------------------------------------------------------
892 // CRUD tests : UPDATE tests
893 // ---------------------------------------------------------------
896 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
899 // @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
900 // groups = {"update"}, dependsOnGroups = {"readItem", "readList"})
901 public void update(String testName) throws Exception {
902 // Retrieve the contents of a resource to update.
903 PersonAuthorityClient client = new PersonAuthorityClient();
904 PoxPayloadIn input = null;
906 ClientResponse<String> res = client.read(knownResourceId);
908 assertStatusCode(res, testName);
909 if (logger.isDebugEnabled()) {
910 logger.debug("got PersonAuthority to update with ID: " + knownResourceId);
912 input = new PoxPayloadIn(res.getEntity());
915 res.releaseConnection();
919 PersonauthoritiesCommon personAuthority = (PersonauthoritiesCommon) extractPart(input,
920 client.getCommonPartName(), PersonauthoritiesCommon.class);
921 Assert.assertNotNull(personAuthority);
923 // Update the contents of this resource.
924 personAuthority.setDisplayName("updated-" + personAuthority.getDisplayName());
925 personAuthority.setVocabType("updated-" + personAuthority.getVocabType());
926 if (logger.isDebugEnabled()) {
927 logger.debug("to be updated PersonAuthority");
928 logger.debug(objectAsXmlString(personAuthority, PersonauthoritiesCommon.class));
931 // Submit the updated resource to the service and store the response.
932 PoxPayloadOut output = new PoxPayloadOut(PersonAuthorityClient.SERVICE_PAYLOAD_NAME);
933 PayloadOutputPart commonPart = output.addPart(client.getCommonPartName(), personAuthority);
935 res = client.update(knownResourceId, output);
937 assertStatusCode(res, testName);
938 // Retrieve the updated resource and verify that its contents exist.
939 input = new PoxPayloadIn(res.getEntity());
942 res.releaseConnection();
946 PersonauthoritiesCommon updatedPersonAuthority =
947 (PersonauthoritiesCommon) extractPart(input,
948 client.getCommonPartName(), PersonauthoritiesCommon.class);
949 Assert.assertNotNull(updatedPersonAuthority);
951 // Verify that the updated resource received the correct data.
952 Assert.assertEquals(updatedPersonAuthority.getDisplayName(),
953 personAuthority.getDisplayName(),
954 "Data in updated object did not match submitted data.");
960 * @param testName the test name
961 * @throws Exception the exception
964 // @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
965 // groups = {"update"}, dependsOnMethods = {"update"})
966 public void updateItem(String testName) throws Exception {
967 // Retrieve the contents of a resource to update.
968 PersonAuthorityClient client = new PersonAuthorityClient();
969 PoxPayloadIn input = null;
971 ClientResponse<String> res =
972 client.readItem(knownResourceId, knownItemResourceId);
974 assertStatusCode(res, testName);
975 if (logger.isDebugEnabled()) {
976 logger.debug("got Person to update with ID: "
977 + knownItemResourceId
978 + " in PersonAuthority: " + knownResourceId);
980 input = new PoxPayloadIn(res.getEntity());
983 res.releaseConnection();
987 PersonsCommon person = (PersonsCommon) extractPart(input,
988 client.getItemCommonPartName(), PersonsCommon.class);
989 Assert.assertNotNull(person);
991 if (logger.isDebugEnabled() == true) {
992 logger.debug("About to update the following person...");
993 logger.debug(objectAsXmlString(person, PersonsCommon.class));
996 // Update the contents of this resource.
997 person.setCsid(null);
998 PersonTermGroupList termList = person.getPersonTermGroupList();
999 Assert.assertNotNull(termList);
1000 List<PersonTermGroup> terms = termList.getPersonTermGroup();
1001 Assert.assertNotNull(terms);
1002 Assert.assertTrue(terms.size() > 0);
1003 String foreName = terms.get(0).getForeName();
1004 String updatedForeName = "updated-" + foreName;
1005 terms.get(0).setForeName(updatedForeName);
1006 if (logger.isDebugEnabled()) {
1007 logger.debug("to be updated Person");
1008 logger.debug(objectAsXmlString(person,
1009 PersonsCommon.class));
1012 // Submit the updated resource to the service and store the response.
1013 PoxPayloadOut output = new PoxPayloadOut(PersonAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
1014 PayloadOutputPart commonPart = output.addPart(client.getItemCommonPartName(), person);
1016 res = client.updateItem(knownResourceId, knownItemResourceId, output);
1018 assertStatusCode(res, testName);
1019 // Retrieve the updated resource and verify that its contents exist.
1020 input = new PoxPayloadIn(res.getEntity());
1023 res.releaseConnection();
1027 PersonsCommon updatedPerson =
1028 (PersonsCommon) extractPart(input,
1029 client.getItemCommonPartName(), PersonsCommon.class);
1030 Assert.assertNotNull(updatedPerson);
1032 if (logger.isDebugEnabled() == true) {
1033 logger.debug("Updated to following person to:");
1034 logger.debug(objectAsXmlString(updatedPerson, PersonsCommon.class));
1037 // Verify that the updated resource received the correct data.
1038 PersonTermGroupList updatedTermList = person.getPersonTermGroupList();
1039 Assert.assertNotNull(updatedTermList);
1040 List<PersonTermGroup> updatedTerms = termList.getPersonTermGroup();
1041 Assert.assertNotNull(updatedTerms);
1042 Assert.assertEquals(updatedTerms.get(0).getForeName(), updatedForeName,
1043 "Data in updated Person did not match submitted data.");
1049 * @param testName the test name
1050 * @throws Exception the exception
1052 @Test(dataProvider = "testName", groups = {"update"},
1053 dependsOnMethods = {"readContact", "testContactSubmitRequest",
1054 "org.collectionspace.services.client.test.AbstractAuthorityServiceTest.updateItem"})
1055 public void updateContact(String testName) throws Exception {
1056 String contactsCommonLabel = new ContactClient().getCommonPartName();
1058 // Retrieve the contents of a resource to update.
1059 PersonAuthorityClient client = new PersonAuthorityClient();
1060 PoxPayloadIn input = null;
1062 ClientResponse<String> res =
1063 client.readContact(knownResourceId, knownItemResourceId, knownContactResourceId);
1065 assertStatusCode(res, testName);
1066 if (logger.isDebugEnabled()) {
1067 logger.debug("got Contact to update with ID: "
1068 + knownContactResourceId
1069 + " in item: " + knownItemResourceId
1070 + " in parent: " + knownResourceId);
1072 input = new PoxPayloadIn(res.getEntity());
1075 res.releaseConnection();
1079 ContactsCommon contact = (ContactsCommon) extractPart(input,
1080 contactsCommonLabel, ContactsCommon.class);
1081 Assert.assertNotNull(contact);
1083 // Verify the contents of this resource
1084 AddressGroupList addressGroupList = contact.getAddressGroupList();
1085 Assert.assertNotNull(addressGroupList);
1086 List<AddressGroup> addressGroups = addressGroupList.getAddressGroup();
1087 Assert.assertNotNull(addressGroups);
1088 Assert.assertTrue(addressGroups.size() > 0);
1089 String addressPlace1 = addressGroups.get(0).getAddressPlace1();
1090 Assert.assertNotNull(addressPlace1);
1092 // Update the contents of this resource.
1093 addressGroups.get(0).setAddressPlace1("updated-" + addressPlace1);
1094 contact.setAddressGroupList(addressGroupList);
1095 if (logger.isDebugEnabled()) {
1096 logger.debug("to be updated Contact");
1097 logger.debug(objectAsXmlString(contact,
1098 ContactsCommon.class));
1101 // Submit the updated resource to the service and store the response.
1102 PoxPayloadOut output = new PoxPayloadOut(ContactClient.SERVICE_PAYLOAD_NAME);
1103 PayloadOutputPart commonPart = output.addPart(contactsCommonLabel, contact);
1105 res = client.updateContact(knownResourceId, knownItemResourceId, knownContactResourceId, output);
1107 assertStatusCode(res, testName);
1108 // Retrieve the updated resource and verify that its contents exist.
1109 input = new PoxPayloadIn(res.getEntity());;
1112 res.releaseConnection();
1115 ContactsCommon updatedContact = (ContactsCommon) extractPart(input,
1116 contactsCommonLabel, ContactsCommon.class);
1117 Assert.assertNotNull(updatedContact);
1119 // Verify that the updated resource received the correct data.
1120 Assert.assertEquals(updatedContact.getAddressGroupList().getAddressGroup().get(0).getAddressPlace1(),
1121 contact.getAddressGroupList().getAddressGroup().get(0).getAddressPlace1(),
1122 "Data in updated object did not match submitted data.");
1126 * Update non existent contact.
1128 * @param testName the test name
1129 * @throws Exception the exception
1131 @Test(dataProvider = "testName", groups = {"update"},
1132 dependsOnMethods = {"updateContact", "testContactSubmitRequest"})
1133 public void updateNonExistentContact(String testName) throws Exception {
1134 // Currently a no-op test
1137 // ---------------------------------------------------------------
1138 // CRUD tests : DELETE tests
1139 // ---------------------------------------------------------------
1141 // Note: delete sub-resources in ascending hierarchical order,
1142 // before deleting their parents.
1146 * @param testName the test name
1147 * @throws Exception the exception
1149 @Test(dataProvider = "testName", groups = {"delete"},
1150 dependsOnMethods = {"updateContact"})
1151 public void deleteContact(String testName) throws Exception {
1152 if (logger.isDebugEnabled()) {
1153 logger.debug("parentcsid =" + knownResourceId
1154 + " itemcsid = " + knownItemResourceId
1155 + " csid = " + knownContactResourceId);
1158 // Submit the request to the service and store the response.
1159 PersonAuthorityClient client = new PersonAuthorityClient();
1161 ClientResponse<Response> res =
1162 client.deleteContact(knownResourceId, knownItemResourceId, knownContactResourceId);
1164 assertStatusCode(res, testName);
1167 res.releaseConnection();
1173 public void delete(String testName) throws Exception {
1174 // Do nothing. See localDelete(). This ensure proper test order.
1177 @Test(dataProvider = "testName", dependsOnMethods = {"localDeleteItem"})
1178 public void localDelete(String testName) throws Exception {
1179 super.delete(testName);
1183 public void deleteItem(String testName) throws Exception {
1184 // Do nothing. We need to wait until after the test "localDelete" gets run. When it does,
1185 // its dependencies will get run first and then we can call the base class' delete method.
1188 @Test(dataProvider = "testName", groups = {"delete"},
1189 dependsOnMethods = {"verifyIllegalItemDisplayName", "testContactSubmitRequest", "deleteContact"})
1190 public void localDeleteItem(String testName) throws Exception {
1191 super.deleteItem(testName);
1195 * Delete non existent contact.
1197 * @param testName the test name
1199 @Test(dataProvider = "testName", groups = {"delete"},
1200 dependsOnMethods = {"deleteContact"})
1201 public void deleteNonExistentContact(String testName) {
1202 // Submit the request to the service and store the response.
1203 PersonAuthorityClient client = new PersonAuthorityClient();
1204 setupDeleteNonExistent();
1205 ClientResponse<Response> res =
1206 client.deleteContact(knownResourceId, knownItemResourceId, NON_EXISTENT_ID);
1208 assertStatusCode(res, testName);
1211 res.releaseConnection();
1217 * Test contact submit request.
1219 @Test(dataProvider = "testName",
1220 dependsOnMethods = {"createContact", "readContact", "testItemSubmitRequest"})
1221 public void testContactSubmitRequest(String testName) {
1223 // Expected status code: 200 OK
1224 final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
1226 // Submit the request to the service and store the response.
1227 String method = ServiceRequestType.READ.httpMethodName();
1228 String url = getContactResourceURL(knownResourceId,
1229 knownItemResourceId, knownContactResourceId);
1230 int statusCode = submitRequest(method, url);
1232 // Check the status code of the response: does it match
1233 // the expected response(s)?
1234 if (logger.isDebugEnabled()) {
1235 logger.debug("testContactSubmitRequest: url=" + url
1236 + " status=" + statusCode);
1238 Assert.assertEquals(statusCode, EXPECTED_STATUS);
1242 // ---------------------------------------------------------------
1243 // Cleanup of resources created during testing
1244 // ---------------------------------------------------------------
1246 * Deletes all resources created by tests, after all tests have been run.
1248 * This cleanup method will always be run, even if one or more tests fail.
1249 * For this reason, it attempts to remove all resources created
1250 * at any point during testing, even if some of those resources
1251 * may be expected to be deleted by certain tests.
1253 @AfterClass(alwaysRun = true)
1255 public void cleanUp() {
1256 String noTest = System.getProperty("noTestCleanup");
1257 if (Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
1258 if (logger.isDebugEnabled()) {
1259 logger.debug("Skipping Cleanup phase ...");
1263 if (logger.isDebugEnabled()) {
1264 logger.debug("Cleaning up temporary resources created for testing ...");
1266 String parentResourceId;
1267 String itemResourceId;
1268 String contactResourceId;
1269 // Clean up contact resources.
1270 PersonAuthorityClient client = new PersonAuthorityClient();
1271 parentResourceId = knownResourceId;
1272 for (Map.Entry<String, String> entry : allContactResourceIdsCreated.entrySet()) {
1273 contactResourceId = entry.getKey();
1274 itemResourceId = entry.getValue();
1275 // Note: Any non-success responses from the delete operation
1276 // below are ignored and not reported.
1277 ClientResponse<Response> res =
1278 client.deleteContact(parentResourceId, itemResourceId, contactResourceId);
1279 res.releaseConnection();
1281 // Clean up item resources.
1282 for (Map.Entry<String, String> entry : allResourceItemIdsCreated.entrySet()) {
1283 itemResourceId = entry.getKey();
1284 parentResourceId = entry.getValue();
1285 // Note: Any non-success responses from the delete operation
1286 // below are ignored and not reported.
1287 ClientResponse<Response> res =
1288 client.deleteItem(parentResourceId, itemResourceId);
1289 res.releaseConnection();
1291 // Clean up parent resources.
1295 // ---------------------------------------------------------------
1296 // Utility methods used by tests above
1297 // ---------------------------------------------------------------
1299 * Gets the contact service path component.
1301 * @return the contact service path component
1303 public String getContactServicePathComponent() {
1304 return ContactClient.SERVICE_PATH_COMPONENT;
1308 * Returns the root URL for the item service.
1310 * This URL consists of a base URL for all services, followed by
1311 * a path component for the owning parent, followed by the
1312 * path component for the items.
1314 * @param parentResourceIdentifier An identifier (such as a UUID) for the
1315 * parent authority resource of the relevant item resource.
1317 * @return The root URL for the item service.
1319 protected String getItemServiceRootURL(String parentResourceIdentifier) {
1320 return getResourceURL(parentResourceIdentifier) + "/" + getItemServicePathComponent();
1324 * Returns the URL of a specific item resource managed by a service, and
1325 * designated by an identifier (such as a universally unique ID, or UUID).
1327 * @param parentResourceIdentifier An identifier (such as a UUID) for the
1328 * parent authority resource of the relevant item resource.
1330 * @param itemResourceIdentifier An identifier (such as a UUID) for an
1333 * @return The URL of a specific item resource managed by a service.
1335 protected String getItemResourceURL(String parentResourceIdentifier, String itemResourceIdentifier) {
1336 return getItemServiceRootURL(parentResourceIdentifier) + "/" + itemResourceIdentifier;
1340 * Returns the root URL for the contact service.
1342 * This URL consists of a base URL for all services, followed by
1343 * a path component for the owning authority, followed by the
1344 * path component for the owning item, followed by the path component
1345 * for the contact service.
1347 * @param parentResourceIdentifier An identifier (such as a UUID) for the
1348 * parent authority resource of the relevant item resource.
1350 * @param itemResourceIdentifier An identifier (such as a UUID) for an
1353 * @return The root URL for the contact service.
1355 protected String getContactServiceRootURL(String parentResourceIdentifier,
1356 String itemResourceIdentifier) {
1357 return getItemResourceURL(parentResourceIdentifier, itemResourceIdentifier) + "/"
1358 + getContactServicePathComponent();
1362 * Returns the URL of a specific contact resource managed by a service, and
1363 * designated by an identifier (such as a universally unique ID, or UUID).
1365 * @param parentResourceIdentifier An identifier (such as a UUID) for the
1366 * parent resource of the relevant item resource.
1368 * @param resourceIdentifier An identifier (such as a UUID) for an
1371 * @return The URL of a specific resource managed by a service.
1373 protected String getContactResourceURL(String parentResourceIdentifier,
1374 String itemResourceIdentifier, String contactResourceIdentifier) {
1375 return getContactServiceRootURL(parentResourceIdentifier,
1376 itemResourceIdentifier) + "/" + contactResourceIdentifier;
1380 public void authorityTests(String testName) {
1381 // TODO Auto-generated method stub
1386 protected PersonsCommon updateItemInstance(PersonsCommon personsCommon) {
1388 PersonTermGroupList termList = personsCommon.getPersonTermGroupList();
1389 Assert.assertNotNull(termList);
1390 List<PersonTermGroup> terms = termList.getPersonTermGroup();
1391 Assert.assertNotNull(terms);
1392 Assert.assertTrue(terms.size() > 0);
1393 terms.get(0).setTermDisplayName("updated-" + terms.get(0).getTermDisplayName());
1394 terms.get(0).setTermName("updated-" + terms.get(0).getTermName());
1395 personsCommon.setPersonTermGroupList(termList);
1397 return personsCommon;
1401 protected void compareUpdatedItemInstances(PersonsCommon original,
1402 PersonsCommon updated) throws Exception {
1404 PersonTermGroupList originalTermList = original.getPersonTermGroupList();
1405 Assert.assertNotNull(originalTermList);
1406 List<PersonTermGroup> originalTerms = originalTermList.getPersonTermGroup();
1407 Assert.assertNotNull(originalTerms);
1408 Assert.assertTrue(originalTerms.size() > 0);
1410 PersonTermGroupList updatedTermList = updated.getPersonTermGroupList();
1411 Assert.assertNotNull(updatedTermList);
1412 List<PersonTermGroup> updatedTerms = updatedTermList.getPersonTermGroup();
1413 Assert.assertNotNull(updatedTerms);
1414 Assert.assertTrue(updatedTerms.size() > 0);
1416 Assert.assertEquals(updatedTerms.get(0).getTermDisplayName(),
1417 originalTerms.get(0).getTermDisplayName(),
1418 "Value in updated record did not match submitted data.");
1422 protected PoxPayloadOut createInstance(String commonPartName,
1423 String identifier) {
1424 String shortId = identifier;
1425 String displayName = "displayName-" + shortId;
1426 PoxPayloadOut result =
1427 PersonAuthorityClientUtils.createPersonAuthorityInstance(
1428 displayName, shortId, commonPartName);
1433 protected PoxPayloadOut createNonExistenceInstance(String commonPartName,
1434 String identifier) {
1435 String displayName = "displayName-NON_EXISTENT_ID";
1436 PoxPayloadOut result = PersonAuthorityClientUtils.createPersonAuthorityInstance(
1437 displayName, "NON_EXISTENT_SHORT_ID", commonPartName);
1441 protected PoxPayloadOut createNonExistenceItemInstance(String commonPartName, String identifier) {
1442 Map<String, String> nonexMap = new HashMap<String, String>();
1443 nonexMap.put(PersonJAXBSchema.SHORT_IDENTIFIER, "nonEX");
1444 nonexMap.put(PersonJAXBSchema.GENDER, "male");
1446 List<PersonTermGroup> terms = new ArrayList<PersonTermGroup>();
1447 PersonTermGroup term = new PersonTermGroup();
1448 term.setTermDisplayName("John Wayne");
1449 term.setTermName("John Wayne");
1450 term.setForeName("John");
1451 term.setSurName("Wayne");
1454 Map<String, List<String>> nonexRepeatablesMap = new HashMap<String, List<String>>();
1455 PoxPayloadOut result =
1456 PersonAuthorityClientUtils.createPersonInstance(NON_EXISTENT_ID,
1457 null, //PersonAuthorityClientUtils.createPersonAuthRefName(NON_EXISTENT_ID, null),
1458 nonexMap, terms, nonexRepeatablesMap, commonPartName);
1463 protected PersonauthoritiesCommon updateInstance(PersonauthoritiesCommon personauthoritiesCommon) {
1464 PersonauthoritiesCommon result = new PersonauthoritiesCommon();
1466 result.setDisplayName("updated-" + personauthoritiesCommon.getDisplayName());
1467 result.setVocabType("updated-" + personauthoritiesCommon.getVocabType());
1473 protected void compareUpdatedInstances(PersonauthoritiesCommon original,
1474 PersonauthoritiesCommon updated) throws Exception {
1475 // Verify that the updated resource received the correct data.
1476 Assert.assertEquals(updated.getDisplayName(),
1477 original.getDisplayName(),
1478 "Display name in updated object did not match submitted data.");
1482 protected void verifyReadItemInstance(PersonsCommon item) throws Exception {
1483 // Do nothing for now. Add more 'read' validation checks here if applicable.