2 * This document is a part of the source code and related artifacts
3 * for CollectionSpace, an open source collections management system
4 * for museums and related institutions:
6 * http://www.collectionspace.org
7 * http://wiki.collectionspace.org
9 * Copyright (c)) 2009 Regents of the University of California
11 * Licensed under the Educational Community License (ECL), Version 2.0.
12 * You may not use this file except in compliance with this License.
14 * You may obtain a copy of the ECL 2.0 License at
15 * https://source.collectionspace.org/collection-space/LICENSE.txt
17 * Unless required by applicable law or agreed to in writing, software
18 * distributed under the License is distributed on an "AS IS" BASIS,
19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 * See the License for the specific language governing permissions and
21 * limitations under the License.
23 package org.collectionspace.services.client.test;
25 import java.util.HashMap;
26 import java.util.List;
28 import javax.ws.rs.core.MediaType;
29 import javax.ws.rs.core.Response;
31 import org.collectionspace.services.OrganizationJAXBSchema;
32 import org.collectionspace.services.client.CollectionSpaceClient;
33 import org.collectionspace.services.client.ContactClient;
34 import org.collectionspace.services.client.ContactClientUtils;
35 import org.collectionspace.services.contact.ContactsCommon;
36 import org.collectionspace.services.contact.ContactsCommonList;
37 import org.collectionspace.services.client.OrgAuthorityClient;
38 import org.collectionspace.services.client.OrgAuthorityClientUtils;
39 import org.collectionspace.services.jaxb.AbstractCommonList;
40 import org.collectionspace.services.organization.OrgauthoritiesCommon;
41 import org.collectionspace.services.organization.OrgauthoritiesCommonList;
42 import org.collectionspace.services.organization.OrganizationsCommon;
43 import org.collectionspace.services.organization.OrganizationsCommonList;
45 import org.jboss.resteasy.client.ClientResponse;
46 import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
47 import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
48 import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
49 import org.slf4j.Logger;
50 import org.slf4j.LoggerFactory;
51 import org.testng.Assert;
52 import org.testng.annotations.AfterClass;
53 import org.testng.annotations.Test;
56 * OrgAuthorityServiceTest, carries out tests against a
57 * deployed and running OrgAuthority Service.
59 * $LastChangedRevision: 753 $
60 * $LastChangedDate: 2009-09-23 11:03:36 -0700 (Wed, 23 Sep 2009) $
62 public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
65 private final String CLASS_NAME = OrgAuthorityServiceTest.class.getName();
66 private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
68 // Instance variables specific to this test.
69 /** The service path component. */
70 final String SERVICE_PATH_COMPONENT = "orgauthorities";
72 /** The item service path component. */
73 final String ITEM_SERVICE_PATH_COMPONENT = "items";
75 /** The contact service path component. */
76 final String CONTACT_SERVICE_PATH_COMPONENT = "contacts";
78 /** The test organization shortname. */
79 private final String TEST_ORG_SHORTNAME = "Test Org";
81 /** The test organization founding place. */
82 private final String TEST_ORG_FOUNDING_PLACE = "Anytown, USA";
84 /** The known resource id. */
85 private String knownResourceId = null;
87 /** The known resource display name. */
88 private String knownResourceDisplayName = null;
90 /** The known resource ref name. */
91 private String knownResourceRefName = null;
93 /** The known item resource id. */
94 private String knownItemResourceId = null;
96 /** The known contact resource id. */
97 private String knownContactResourceId = null;
99 /** The n items to create in list. */
100 private int nItemsToCreateInList = 3;
102 /** The all item resource ids created. */
103 private Map<String, String> allItemResourceIdsCreated =
104 new HashMap<String, String>();
106 /** The all contact resource ids created. */
107 private Map<String, String> allContactResourceIdsCreated =
108 new HashMap<String, String>();
111 * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
114 protected CollectionSpaceClient getClientInstance() {
115 return new OrgAuthorityClient();
119 * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
122 protected AbstractCommonList getAbstractCommonList(
123 ClientResponse<AbstractCommonList> response) {
124 return response.getEntity(OrganizationsCommonList.class);
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,
137 public void create(String testName) throws Exception {
139 if (logger.isDebugEnabled()) {
140 logger.debug(testBanner(testName, CLASS_NAME));
142 // Perform setup, such as initializing the type of service request
143 // (e.g. CREATE, DELETE), its valid and expected status codes, and
144 // its associated HTTP method name (e.g. POST, DELETE).
147 // Submit the request to the service and store the response.
148 OrgAuthorityClient client = new OrgAuthorityClient();
149 String identifier = createIdentifier();
150 String displayName = "displayName-" + identifier;
151 String refName = OrgAuthorityClientUtils.createOrgAuthRefName(displayName, true);
152 MultipartOutput multipart =
153 OrgAuthorityClientUtils.createOrgAuthorityInstance(
154 displayName, refName, client.getCommonPartName());
157 ClientResponse<Response> res = client.create(multipart);
159 int statusCode = res.getStatus();
161 // Check the status code of the response: does it match
162 // the expected response(s)?
165 // Does it fall within the set of valid status codes?
166 // Does it exactly match the expected status code?
167 if(logger.isDebugEnabled()){
168 logger.debug(testName + ": status = " + statusCode);
170 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
171 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
172 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
174 // Store the refname from the first resource created
175 // for additional tests below.
176 knownResourceRefName = refName;
178 newID = OrgAuthorityClientUtils.extractId(res);
180 res.releaseConnection();
183 // Store the ID returned from the first resource created
184 // for additional tests below.
185 if (knownResourceId == null){
186 knownResourceId = newID;
187 knownResourceDisplayName = displayName;
188 if (logger.isDebugEnabled()) {
189 logger.debug(testName + ": knownResourceId=" + knownResourceId);
192 // Store the IDs from every resource created by tests,
193 // so they can be deleted after tests have been run.
194 allResourceIdsCreated.add(newID);
200 * @param testName the test name
202 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
203 groups = {"create"}, dependsOnMethods = {"create"})
204 public void createItem(String testName) {
206 String newID = createItemInAuthority(knownResourceId, knownResourceRefName);
210 * Creates the item in authority.
212 * @param vcsid the vcsid
213 * @param authRefName the auth ref name
216 private String createItemInAuthority(String vcsid, String authRefName) {
218 final String testName = "createItemInAuthority";
219 if(logger.isDebugEnabled()){
220 logger.debug(testName + ":...");
223 // Submit the request to the service and store the response.
224 OrgAuthorityClient client = new OrgAuthorityClient();
225 String identifier = createIdentifier();
226 String refName = OrgAuthorityClientUtils.createOrganizationRefName(knownResourceRefName, identifier, true);
227 Map<String, String> testOrgMap = new HashMap<String,String>();
228 testOrgMap.put(OrganizationJAXBSchema.SHORT_NAME, TEST_ORG_SHORTNAME);
229 testOrgMap.put(OrganizationJAXBSchema.LONG_NAME, "The real official test organization");
230 testOrgMap.put(OrganizationJAXBSchema.CONTACT_NAME, "joe@test.org");
231 testOrgMap.put(OrganizationJAXBSchema.FOUNDING_DATE, "May 26, 1907");
232 testOrgMap.put(OrganizationJAXBSchema.FOUNDING_PLACE, TEST_ORG_FOUNDING_PLACE);
233 testOrgMap.put(OrganizationJAXBSchema.FUNCTION, "For testing");
234 String newID = OrgAuthorityClientUtils.createItemInAuthority(
235 vcsid, authRefName, testOrgMap, client);
236 // Store the ID returned from the first item resource created
237 // for additional tests below.
238 if (knownItemResourceId == null){
239 knownItemResourceId = newID;
240 if (logger.isDebugEnabled()) {
241 logger.debug(testName + ": knownItemResourceId=" + knownItemResourceId);
245 // Store the IDs from any item resources created
246 // by tests, along with the IDs of their parents, so these items
247 // can be deleted after all tests have been run.
248 allItemResourceIdsCreated.put(newID, vcsid);
254 * Creates the contact.
256 * @param testName the test name
258 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
259 groups = {"create"}, dependsOnMethods = {"createItem"})
260 public void createContact(String testName) {
262 String newID = createContactInItem(knownResourceId, knownItemResourceId);
266 * Creates the contact in item.
268 * @param parentcsid the parentcsid
269 * @param itemcsid the itemcsid
272 private String createContactInItem(String parentcsid, String itemcsid) {
274 final String testName = "createContactInItem";
275 if (logger.isDebugEnabled()) {
276 logger.debug(testBanner(testName, CLASS_NAME));
280 // Submit the request to the service and store the response.
281 OrgAuthorityClient client = new OrgAuthorityClient();
282 String identifier = createIdentifier();
283 MultipartOutput multipart =
284 ContactClientUtils.createContactInstance(parentcsid,
285 itemcsid, identifier, new ContactClient().getCommonPartName());
288 ClientResponse<Response> res =
289 client.createContact(parentcsid, itemcsid, multipart);
291 int statusCode = res.getStatus();
292 // Check the status code of the response: does it match
293 // the expected response(s)?
294 if(logger.isDebugEnabled()){
295 logger.debug(testName + ": status = " + statusCode);
297 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
298 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
299 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
301 newID = OrgAuthorityClientUtils.extractId(res);
303 res.releaseConnection();
306 // Store the ID returned from the first contact resource created
307 // for additional tests below.
308 if (knownContactResourceId == null){
309 knownContactResourceId = newID;
310 if (logger.isDebugEnabled()) {
311 logger.debug(testName + ": knownContactResourceId=" + knownContactResourceId);
315 // Store the IDs from any contact resources created
316 // by tests, along with the IDs of their parent items,
317 // so these items can be deleted after all tests have been run.
318 allContactResourceIdsCreated.put(newID, itemcsid);
325 // Placeholders until the three tests below can be uncommented.
326 // See Issue CSPACE-401.
328 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
331 public void createWithEmptyEntityBody(String testName) throws Exception {
332 //Should this really be empty?
336 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
339 public void createWithMalformedXml(String testName) throws Exception {
340 //Should this really be empty?
344 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
347 public void createWithWrongXmlSchema(String testName) throws Exception {
348 //Should this really be empty?
353 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
354 groups = {"create"}, dependsOnMethods = {"create", "testSubmitRequest"})
355 public void createWithEmptyEntityBody(String testName) throws Exception {
357 if (logger.isDebugEnabled()) {
358 logger.debug(testBanner(testName, CLASS_NAME));
361 setupCreateWithEmptyEntityBody();
363 // Submit the request to the service and store the response.
364 String method = REQUEST_TYPE.httpMethodName();
365 String url = getServiceRootURL();
366 String mediaType = MediaType.APPLICATION_XML;
367 final String entity = "";
368 int statusCode = submitRequest(method, url, mediaType, entity);
370 // Check the status code of the response: does it match
371 // the expected response(s)?
372 if(logger.isDebugEnabled()) {
373 logger.debug(testName + ": url=" + url +
374 " status=" + statusCode);
376 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
377 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
378 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
382 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
383 groups = {"create"}, dependsOnMethods = {"create", "testSubmitRequest"})
384 public void createWithMalformedXml(String testName) throws Exception {
386 if (logger.isDebugEnabled()) {
387 logger.debug(testBanner(testName, CLASS_NAME));
390 setupCreateWithMalformedXml();
392 // Submit the request to the service and store the response.
393 String method = REQUEST_TYPE.httpMethodName();
394 String url = getServiceRootURL();
395 String mediaType = MediaType.APPLICATION_XML;
396 final String entity = MALFORMED_XML_DATA; // Constant from base class.
397 int statusCode = submitRequest(method, url, mediaType, entity);
399 // Check the status code of the response: does it match
400 // the expected response(s)?
401 if(logger.isDebugEnabled()){
402 logger.debug(testName + ": url=" + url +
403 " status=" + statusCode);
405 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
406 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
407 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
411 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
412 groups = {"create"}, dependsOnMethods = {"create", "testSubmitRequest"})
413 public void createWithWrongXmlSchema(String testName) throws Exception {
415 if (logger.isDebugEnabled()) {
416 logger.debug(testBanner(testName, CLASS_NAME));
419 setupCreateWithWrongXmlSchema();
421 // Submit the request to the service and store the response.
422 String method = REQUEST_TYPE.httpMethodName();
423 String url = getServiceRootURL();
424 String mediaType = MediaType.APPLICATION_XML;
425 final String entity = WRONG_XML_SCHEMA_DATA;
426 int statusCode = submitRequest(method, url, mediaType, entity);
428 // Check the status code of the response: does it match
429 // the expected response(s)?
430 if(logger.isDebugEnabled()){
431 logger.debug(testName + ": url=" + url +
432 " status=" + statusCode);
434 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
435 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
436 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
440 // ---------------------------------------------------------------
441 // CRUD tests : CREATE LIST tests
442 // ---------------------------------------------------------------
445 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
448 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
449 groups = {"createList"}, dependsOnGroups = {"create"})
450 public void createList(String testName) throws Exception {
451 for (int i = 0; i < nItemsToCreateInList; i++) {
457 * Creates the item list.
459 * @param testName the test name
460 * @throws Exception the exception
462 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
463 groups = {"createList"}, dependsOnMethods = {"createList"})
464 public void createItemList(String testName) throws Exception {
465 // Add items to the initially-created, known parent record.
466 for (int j = 0; j < nItemsToCreateInList; j++) {
467 createItem(testName);
472 * Creates the contact list.
474 * @param testName the test name
475 * @throws Exception the exception
477 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
478 groups = {"createList"}, dependsOnMethods = {"createItemList"})
479 public void createContactList(String testName) throws Exception {
480 // Add contacts to the initially-created, known item record.
481 for (int j = 0; j < nItemsToCreateInList; j++) {
482 createContact(testName);
486 // ---------------------------------------------------------------
487 // CRUD tests : READ tests
488 // ---------------------------------------------------------------
491 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
494 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
495 groups = {"read"}, dependsOnGroups = {"create"})
496 public void read(String testName) throws Exception {
498 if (logger.isDebugEnabled()) {
499 logger.debug(testBanner(testName, CLASS_NAME));
504 // Submit the request to the service and store the response.
505 OrgAuthorityClient client = new OrgAuthorityClient();
506 ClientResponse<MultipartInput> res = client.read(knownResourceId);
508 int statusCode = res.getStatus();
510 // Check the status code of the response: does it match
511 // the expected response(s)?
512 if(logger.isDebugEnabled()){
513 logger.debug(testName + ": status = " + statusCode);
515 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
516 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
517 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
518 //FIXME: remove the following try catch once Aron fixes signatures
520 MultipartInput input = (MultipartInput) res.getEntity();
521 OrgauthoritiesCommon orgAuthority = (OrgauthoritiesCommon) extractPart(input,
522 client.getCommonPartName(), OrgauthoritiesCommon.class);
523 Assert.assertNotNull(orgAuthority);
524 } catch (Exception e) {
525 throw new RuntimeException(e);
528 res.releaseConnection();
535 * @param testName the test name
536 * @throws Exception the exception
538 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
539 groups = {"read"}, dependsOnGroups = {"create"})
540 public void readByName(String testName) throws Exception {
542 if (logger.isDebugEnabled()) {
543 logger.debug(testBanner(testName, CLASS_NAME));
548 // Submit the request to the service and store the response.
549 OrgAuthorityClient client = new OrgAuthorityClient();
550 ClientResponse<MultipartInput> res = client.readByName(knownResourceDisplayName);
552 int statusCode = res.getStatus();
554 // Check the status code of the response: does it match
555 // the expected response(s)?
556 if(logger.isDebugEnabled()){
557 logger.debug(testName + ": status = " + statusCode);
559 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
560 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
561 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
562 //FIXME: remove the following try catch once Aron fixes signatures
564 MultipartInput input = (MultipartInput) res.getEntity();
565 OrgauthoritiesCommon orgAuthority = (OrgauthoritiesCommon) extractPart(input,
566 new OrgAuthorityClient().getCommonPartName(), OrgauthoritiesCommon.class);
567 Assert.assertNotNull(orgAuthority);
568 } catch (Exception e) {
569 throw new RuntimeException(e);
572 res.releaseConnection();
577 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
578 groups = {"read"}, dependsOnMethods = {"read"})
579 public void readByName(String testName) throws Exception {
581 if (logger.isDebugEnabled()) {
582 logger.debug(testBanner(testName, CLASS_NAME));
587 // Submit the request to the service and store the response.
588 ClientResponse<MultipartInput> res = client.read(knownResourceId);
589 int statusCode = res.getStatus();
591 // Check the status code of the response: does it match
592 // the expected response(s)?
593 if(logger.isDebugEnabled()){
594 logger.debug(testName + ": status = " + statusCode);
596 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
597 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
598 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
599 //FIXME: remove the following try catch once Aron fixes signatures
601 MultipartInput input = (MultipartInput) res.getEntity();
602 OrgauthoritiesCommon orgAuthority = (OrgauthoritiesCommon) extractPart(input,
603 client.getCommonPartName(), OrgauthoritiesCommon.class);
604 Assert.assertNotNull(orgAuthority);
605 } catch (Exception e) {
606 throw new RuntimeException(e);
614 * @param testName the test name
615 * @throws Exception the exception
617 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
618 groups = {"read"}, dependsOnMethods = {"read"})
619 public void readItem(String testName) throws Exception {
621 if (logger.isDebugEnabled()) {
622 logger.debug(testBanner(testName, CLASS_NAME));
627 // Submit the request to the service and store the response.
628 OrgAuthorityClient client = new OrgAuthorityClient();
629 ClientResponse<MultipartInput> res = client.readItem(knownResourceId, knownItemResourceId);
631 int statusCode = res.getStatus();
633 // Check the status code of the response: does it match
634 // the expected response(s)?
635 if(logger.isDebugEnabled()){
636 logger.debug(testName + ": status = " + statusCode);
638 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
639 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
640 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
642 // Check whether we've received a organization.
643 MultipartInput input = (MultipartInput) res.getEntity();
644 OrganizationsCommon organization = (OrganizationsCommon) extractPart(input,
645 client.getItemCommonPartName(), OrganizationsCommon.class);
646 Assert.assertNotNull(organization);
647 boolean showFull = true;
648 if(showFull && logger.isDebugEnabled()){
649 logger.debug(testName + ": returned payload:");
650 logger.debug(objectAsXmlString(organization,
651 OrganizationsCommon.class));
653 Assert.assertEquals(organization.getInAuthority(), knownResourceId);
655 res.releaseConnection();
660 * Verify item display name.
662 * @param testName the test name
663 * @throws Exception the exception
665 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
666 dependsOnMethods = {"readItem", "updateItem"})
667 public void verifyItemDisplayName(String testName) throws Exception {
669 if (logger.isDebugEnabled()) {
670 logger.debug(testBanner(testName, CLASS_NAME));
675 // Submit the request to the service and store the response.
676 OrgAuthorityClient client = new OrgAuthorityClient();
677 MultipartInput input = null;
678 ClientResponse<MultipartInput> res = client.readItem(knownResourceId, knownItemResourceId);
680 int statusCode = res.getStatus();
682 // Check the status code of the response: does it match
683 // the expected response(s)?
684 if(logger.isDebugEnabled()){
685 logger.debug(testName + ": status = " + statusCode);
687 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
688 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
689 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
691 // Check whether organization has expected displayName.
692 input = res.getEntity();
694 res.releaseConnection();
697 OrganizationsCommon organization = (OrganizationsCommon) extractPart(input,
698 client.getItemCommonPartName(), OrganizationsCommon.class);
699 Assert.assertNotNull(organization);
700 String displayName = organization.getDisplayName();
701 // Make sure displayName matches computed form
702 String expectedDisplayName =
703 OrgAuthorityClientUtils.prepareDefaultDisplayName(
704 TEST_ORG_SHORTNAME, TEST_ORG_FOUNDING_PLACE);
705 Assert.assertNotNull(displayName, expectedDisplayName);
707 // Update the shortName and verify the computed name is updated.
708 organization.setCsid(null);
709 organization.setDisplayNameComputed(true);
710 organization.setShortName("updated-" + TEST_ORG_SHORTNAME);
711 expectedDisplayName =
712 OrgAuthorityClientUtils.prepareDefaultDisplayName(
713 "updated-" + TEST_ORG_SHORTNAME, TEST_ORG_FOUNDING_PLACE);
715 // Submit the updated resource to the service and store the response.
716 MultipartOutput output = new MultipartOutput();
717 OutputPart commonPart = output.addPart(organization, MediaType.APPLICATION_XML_TYPE);
718 commonPart.getHeaders().add("label", client.getItemCommonPartName());
719 res = client.updateItem(knownResourceId, knownItemResourceId, output);
721 int statusCode = res.getStatus();
723 // Check the status code of the response: does it match the expected response(s)?
724 if(logger.isDebugEnabled()){
725 logger.debug("updateItem: status = " + statusCode);
727 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
728 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
729 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
731 // Retrieve the updated resource and verify that its contents exist.
732 input = (MultipartInput) res.getEntity();
734 res.releaseConnection();
737 OrganizationsCommon updatedOrganization =
738 (OrganizationsCommon) extractPart(input,
739 client.getItemCommonPartName(), OrganizationsCommon.class);
740 Assert.assertNotNull(updatedOrganization);
742 // Verify that the updated resource received the correct data.
743 Assert.assertEquals(updatedOrganization.getShortName(), organization.getShortName(),
744 "Updated ShortName in Organization did not match submitted data.");
745 // Verify that the updated resource computes the right displayName.
746 Assert.assertEquals(updatedOrganization.getDisplayName(), expectedDisplayName,
747 "Updated ShortName in Organization not reflected in computed DisplayName.");
749 // Now Update the displayName, not computed and verify the computed name is overriden.
750 organization.setDisplayNameComputed(false);
751 expectedDisplayName = "TestName";
752 organization.setDisplayName(expectedDisplayName);
754 // Submit the updated resource to the service and store the response.
755 output = new MultipartOutput();
756 commonPart = output.addPart(organization, MediaType.APPLICATION_XML_TYPE);
757 commonPart.getHeaders().add("label", client.getItemCommonPartName());
758 res = client.updateItem(knownResourceId, knownItemResourceId, output);
760 int statusCode = res.getStatus();
762 // Check the status code of the response: does it match the expected response(s)?
763 if(logger.isDebugEnabled()){
764 logger.debug("updateItem: status = " + statusCode);
766 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
767 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
768 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
770 // Retrieve the updated resource and verify that its contents exist.
771 input = (MultipartInput) res.getEntity();
773 res.releaseConnection();
776 updatedOrganization =
777 (OrganizationsCommon) extractPart(input,
778 client.getItemCommonPartName(), OrganizationsCommon.class);
779 Assert.assertNotNull(updatedOrganization);
781 // Verify that the updated resource received the correct data.
782 Assert.assertEquals(updatedOrganization.isDisplayNameComputed(), false,
783 "Updated displayNameComputed in Organization did not match submitted data.");
784 // Verify that the updated resource computes the right displayName.
785 Assert.assertEquals(updatedOrganization.getDisplayName(),
787 "Updated DisplayName (not computed) in Organization not stored.");
791 * Verify illegal item display name.
793 * @param testName the test name
794 * @throws Exception the exception
796 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
797 dependsOnMethods = {"verifyItemDisplayName"})
798 public void verifyIllegalItemDisplayName(String testName) throws Exception {
800 if (logger.isDebugEnabled()) {
801 logger.debug(testBanner(testName, CLASS_NAME));
804 testSetup(STATUS_BAD_REQUEST, ServiceRequestType.UPDATE);
805 // setupUpdateWithWrongXmlSchema(testName, logger);
807 // Submit the request to the service and store the response.
808 OrgAuthorityClient client = new OrgAuthorityClient();
809 ClientResponse<MultipartInput> res = client.readItem(knownResourceId, knownItemResourceId);
810 int statusCode = res.getStatus();
812 // Check the status code of the response: does it match
813 // the expected response(s)?
814 if(logger.isDebugEnabled()){
815 logger.debug(testName + ": status = " + statusCode);
817 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
818 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
819 Assert.assertEquals(statusCode, Response.Status.OK.getStatusCode());
821 // Check whether organization has expected displayName.
822 MultipartInput input = (MultipartInput) res.getEntity();
823 OrganizationsCommon organization = (OrganizationsCommon) extractPart(input,
824 client.getItemCommonPartName(), OrganizationsCommon.class);
825 Assert.assertNotNull(organization);
826 // Try to Update with computed false and no displayName
827 organization.setDisplayNameComputed(false);
828 organization.setDisplayName(null);
830 // Submit the updated resource to the service and store the response.
831 MultipartOutput output = new MultipartOutput();
832 OutputPart commonPart = output.addPart(organization, MediaType.APPLICATION_XML_TYPE);
833 commonPart.getHeaders().add("label", client.getItemCommonPartName());
834 res = client.updateItem(knownResourceId, knownItemResourceId, output);
835 statusCode = res.getStatus();
837 // Check the status code of the response: does it match the expected response(s)?
838 if(logger.isDebugEnabled()){
839 logger.debug("updateItem: status = " + statusCode);
841 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
842 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
843 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
849 * @param testName the test name
850 * @throws Exception the exception
852 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
853 groups = {"read"}, dependsOnMethods = {"readItem"})
854 public void readContact(String testName) throws Exception {
856 if (logger.isDebugEnabled()) {
857 logger.debug(testBanner(testName, CLASS_NAME));
862 // Submit the request to the service and store the response.
863 OrgAuthorityClient client = new OrgAuthorityClient();
864 ClientResponse<MultipartInput> res =
865 client.readContact(knownResourceId, knownItemResourceId,
866 knownContactResourceId);
867 int statusCode = res.getStatus();
869 // Check the status code of the response: does it match
870 // the expected response(s)?
871 if(logger.isDebugEnabled()){
872 logger.debug(testName + ": status = " + statusCode);
874 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
875 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
876 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
878 // Check whether we've received a contact.
879 MultipartInput input = (MultipartInput) res.getEntity();
880 ContactsCommon contact = (ContactsCommon) extractPart(input,
881 new ContactClient().getCommonPartName(), ContactsCommon.class);
882 Assert.assertNotNull(contact);
883 boolean showFull = true;
884 if(showFull && logger.isDebugEnabled()){
885 logger.debug(testName + ": returned payload:");
886 logger.debug(objectAsXmlString(contact, ContactsCommon.class));
888 Assert.assertEquals(contact.getInAuthority(), knownResourceId);
889 Assert.assertEquals(contact.getInItem(), knownItemResourceId);
895 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
898 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
899 groups = {"read"}, dependsOnMethods = {"read"})
900 public void readNonExistent(String testName) {
902 if (logger.isDebugEnabled()) {
903 logger.debug(testBanner(testName, CLASS_NAME));
906 setupReadNonExistent();
908 // Submit the request to the service and store the response.
909 OrgAuthorityClient client = new OrgAuthorityClient();
910 ClientResponse<MultipartInput> res = client.read(NON_EXISTENT_ID);
911 int statusCode = res.getStatus();
913 // Check the status code of the response: does it match
914 // the expected response(s)?
915 if(logger.isDebugEnabled()){
916 logger.debug(testName + ": status = " + statusCode);
918 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
919 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
920 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
924 * Read item non existent.
926 * @param testName the test name
928 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
929 groups = {"read"}, dependsOnMethods = {"readItem"})
930 public void readItemNonExistent(String testName) {
932 if (logger.isDebugEnabled()) {
933 logger.debug(testBanner(testName, CLASS_NAME));
936 setupReadNonExistent();
938 // Submit the request to the service and store the response.
939 OrgAuthorityClient client = new OrgAuthorityClient();
940 ClientResponse<MultipartInput> res = client.readItem(knownResourceId, NON_EXISTENT_ID);
941 int statusCode = res.getStatus();
943 // Check the status code of the response: does it match
944 // the expected response(s)?
945 if(logger.isDebugEnabled()){
946 logger.debug(testName + ": status = " + statusCode);
948 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
949 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
950 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
954 * Read contact non existent.
956 * @param testName the test name
958 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
959 groups = {"read"}, dependsOnMethods = {"readContact"})
960 public void readContactNonExistent(String testName) {
962 if (logger.isDebugEnabled()) {
963 logger.debug(testBanner(testName, CLASS_NAME));
966 setupReadNonExistent();
968 // Submit the request to the service and store the response.
969 OrgAuthorityClient client = new OrgAuthorityClient();
970 ClientResponse<MultipartInput> res =
971 client.readContact(knownResourceId, knownItemResourceId, NON_EXISTENT_ID);
972 int statusCode = res.getStatus();
974 // Check the status code of the response: does it match
975 // the expected response(s)?
976 if(logger.isDebugEnabled()){
977 logger.debug(testName + ": status = " + statusCode);
979 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
980 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
981 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
984 // ---------------------------------------------------------------
985 // CRUD tests : READ_LIST tests
986 // ---------------------------------------------------------------
990 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
993 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
994 groups = {"readList"}, dependsOnGroups = {"createList", "read"})
995 public void readList(String testName) throws Exception {
997 if (logger.isDebugEnabled()) {
998 logger.debug(testBanner(testName, CLASS_NAME));
1003 // Submit the request to the service and store the response.
1004 OrgAuthorityClient client = new OrgAuthorityClient();
1005 ClientResponse<OrgauthoritiesCommonList> res = client.readList();
1006 OrgauthoritiesCommonList list = res.getEntity();
1007 int statusCode = res.getStatus();
1009 // Check the status code of the response: does it match
1010 // the expected response(s)?
1011 if(logger.isDebugEnabled()){
1012 logger.debug(testName + ": status = " + statusCode);
1014 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1015 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1016 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1018 // Optionally output additional data about list members for debugging.
1019 boolean iterateThroughList = false;
1020 if (iterateThroughList && logger.isDebugEnabled()) {
1021 List<OrgauthoritiesCommonList.OrgauthorityListItem> items =
1022 list.getOrgauthorityListItem();
1024 for (OrgauthoritiesCommonList.OrgauthorityListItem item : items) {
1025 String csid = item.getCsid();
1026 logger.debug(testName + ": list-item[" + i + "] csid=" +
1028 logger.debug(testName + ": list-item[" + i + "] displayName=" +
1029 item.getDisplayName());
1030 logger.debug(testName + ": list-item[" + i + "] URI=" +
1032 readItemList(csid, null);
1041 @Test(groups = {"readList"}, dependsOnMethods = {"readList"})
1042 public void readItemList() {
1043 readItemList(knownResourceId, null);
1047 * Read item list by authority name.
1049 @Test(groups = {"readList"}, dependsOnMethods = {"readItemList"})
1050 public void readItemListByAuthorityName() {
1051 readItemList(null, knownResourceDisplayName);
1057 * @param vcsid the vcsid
1058 * @param name the name
1060 private void readItemList(String vcsid, String name) {
1062 final String testName = "readItemList";
1064 if (logger.isDebugEnabled()) {
1065 logger.debug(testBanner(testName, CLASS_NAME));
1070 // Submit the request to the service and store the response.
1071 OrgAuthorityClient client = new OrgAuthorityClient();
1072 ClientResponse<OrganizationsCommonList> res = null;
1074 res = client.readItemList(vcsid);
1075 } else if(name!= null) {
1076 res = client.readItemListForNamedAuthority(name);
1078 Assert.fail("readItemList passed null csid and name!");
1080 OrganizationsCommonList list = res.getEntity();
1081 int statusCode = res.getStatus();
1083 // Check the status code of the response: does it match
1084 // the expected response(s)?
1085 if(logger.isDebugEnabled()){
1086 logger.debug(testName + ": status = " + statusCode);
1088 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1089 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1090 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1092 List<OrganizationsCommonList.OrganizationListItem> items =
1093 list.getOrganizationListItem();
1094 int nItemsReturned = items.size();
1095 // There will be one item created, associated with a
1096 // known parent resource, by the createItem test.
1098 // In addition, there will be 'nItemsToCreateInList'
1099 // additional items created by the createItemList test,
1100 // all associated with the same parent resource.
1101 int nExpectedItems = nItemsToCreateInList + 1;
1102 if(logger.isDebugEnabled()){
1103 logger.debug(testName + ": Expected "
1104 + nExpectedItems +" items; got: "+nItemsReturned);
1106 Assert.assertEquals(nItemsReturned, nExpectedItems);
1109 for (OrganizationsCommonList.OrganizationListItem item : items) {
1110 Assert.assertTrue((null != item.getRefName()), "Item refName is null!");
1111 Assert.assertTrue((null != item.getDisplayName()), "Item displayName is null!");
1112 // Optionally output additional data about list members for debugging.
1113 boolean showDetails = true;
1114 if (showDetails && logger.isDebugEnabled()) {
1115 logger.debug(" " + testName + ": list-item[" + i + "] csid=" +
1117 logger.debug(" " + testName + ": list-item[" + i + "] refName=" +
1119 logger.debug(" " + testName + ": list-item[" + i + "] displayName=" +
1120 item.getDisplayName());
1121 logger.debug(" " + testName + ": list-item[" + i + "] URI=" +
1129 * Read contact list.
1131 @Test(groups = {"readList"}, dependsOnMethods = {"readItemList"})
1132 public void readContactList() {
1133 readContactList(knownResourceId, knownItemResourceId);
1137 * Read contact list.
1139 * @param parentcsid the parentcsid
1140 * @param itemcsid the itemcsid
1142 private void readContactList(String parentcsid, String itemcsid) {
1143 final String testName = "readContactList";
1145 if (logger.isDebugEnabled()) {
1146 logger.debug(testBanner(testName, CLASS_NAME));
1151 // Submit the request to the service and store the response.
1152 OrgAuthorityClient client = new OrgAuthorityClient();
1153 ContactsCommonList list = null;
1154 ClientResponse<ContactsCommonList> res =
1155 client.readContactList(parentcsid, itemcsid);
1156 list = res.getEntity();
1157 int statusCode = res.getStatus();
1159 // Check the status code of the response: does it match
1160 // the expected response(s)?
1161 if(logger.isDebugEnabled()){
1162 logger.debug(testName + ": status = " + statusCode);
1164 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1165 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1166 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1168 List<ContactsCommonList.ContactListItem> listitems =
1169 list.getContactListItem();
1170 int nItemsReturned = listitems.size();
1171 // There will be one item created, associated with a
1172 // known parent resource, by the createItem test.
1174 // In addition, there will be 'nItemsToCreateInList'
1175 // additional items created by the createItemList test,
1176 // all associated with the same parent resource.
1177 int nExpectedItems = nItemsToCreateInList + 1;
1178 if(logger.isDebugEnabled()){
1179 logger.debug(testName + ": Expected "
1180 + nExpectedItems +" items; got: "+nItemsReturned);
1182 Assert.assertEquals(nItemsReturned, nExpectedItems);
1185 for (ContactsCommonList.ContactListItem listitem : listitems) {
1186 // Optionally output additional data about list members for debugging.
1187 boolean showDetails = false;
1188 if (showDetails && logger.isDebugEnabled()) {
1189 logger.debug(" " + testName + ": list-item[" + i + "] csid=" +
1190 listitem.getCsid());
1191 logger.debug(" " + testName + ": list-item[" + i + "] addressPlace=" +
1192 listitem.getAddressPlace());
1193 logger.debug(" " + testName + ": list-item[" + i + "] URI=" +
1203 // ---------------------------------------------------------------
1204 // CRUD tests : UPDATE tests
1205 // ---------------------------------------------------------------
1208 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
1211 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1212 groups = {"update"}, dependsOnGroups = {"read", "readList"})
1213 public void update(String testName) throws Exception {
1215 if (logger.isDebugEnabled()) {
1216 logger.debug(testBanner(testName, CLASS_NAME));
1221 // Retrieve the contents of a resource to update.
1222 OrgAuthorityClient client = new OrgAuthorityClient();
1223 ClientResponse<MultipartInput> res =
1224 client.read(knownResourceId);
1225 if(logger.isDebugEnabled()){
1226 logger.debug(testName + ": read status = " + res.getStatus());
1228 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
1230 if(logger.isDebugEnabled()){
1231 logger.debug("got OrgAuthority to update with ID: " + knownResourceId);
1233 MultipartInput input = (MultipartInput) res.getEntity();
1234 OrgauthoritiesCommon orgAuthority = (OrgauthoritiesCommon) extractPart(input,
1235 client.getCommonPartName(), OrgauthoritiesCommon.class);
1236 Assert.assertNotNull(orgAuthority);
1238 // Update the contents of this resource.
1239 orgAuthority.setDisplayName("updated-" + orgAuthority.getDisplayName());
1240 orgAuthority.setVocabType("updated-" + orgAuthority.getVocabType());
1241 if(logger.isDebugEnabled()){
1242 logger.debug("to be updated OrgAuthority");
1243 logger.debug(objectAsXmlString(orgAuthority, OrgauthoritiesCommon.class));
1246 // Submit the updated resource to the service and store the response.
1247 MultipartOutput output = new MultipartOutput();
1248 OutputPart commonPart = output.addPart(orgAuthority, MediaType.APPLICATION_XML_TYPE);
1249 commonPart.getHeaders().add("label", client.getCommonPartName());
1250 res = client.update(knownResourceId, output);
1251 int statusCode = res.getStatus();
1253 // Check the status code of the response: does it match the expected response(s)?
1254 if(logger.isDebugEnabled()){
1255 logger.debug(testName + ": status = " + statusCode);
1257 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1258 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1259 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1261 // Retrieve the updated resource and verify that its contents exist.
1262 input = (MultipartInput) res.getEntity();
1263 OrgauthoritiesCommon updatedOrgAuthority =
1264 (OrgauthoritiesCommon) extractPart(input,
1265 client.getCommonPartName(), OrgauthoritiesCommon.class);
1266 Assert.assertNotNull(updatedOrgAuthority);
1268 // Verify that the updated resource received the correct data.
1269 Assert.assertEquals(updatedOrgAuthority.getDisplayName(),
1270 orgAuthority.getDisplayName(),
1271 "Data in updated object did not match submitted data.");
1277 * @param testName the test name
1278 * @throws Exception the exception
1280 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1281 groups = {"update"}, dependsOnMethods = {"update"})
1282 public void updateItem(String testName) throws Exception {
1284 if (logger.isDebugEnabled()) {
1285 logger.debug(testBanner(testName, CLASS_NAME));
1290 // Retrieve the contents of a resource to update.
1291 OrgAuthorityClient client = new OrgAuthorityClient();
1292 ClientResponse<MultipartInput> res =
1293 client.readItem(knownResourceId, knownItemResourceId);
1294 if(logger.isDebugEnabled()){
1295 logger.debug(testName + ": read status = " + res.getStatus());
1297 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
1299 if(logger.isDebugEnabled()){
1300 logger.debug("got Organization to update with ID: " +
1301 knownItemResourceId +
1302 " in OrgAuthority: " + knownResourceId );
1304 MultipartInput input = (MultipartInput) res.getEntity();
1305 OrganizationsCommon organization = (OrganizationsCommon) extractPart(input,
1306 client.getItemCommonPartName(), OrganizationsCommon.class);
1307 Assert.assertNotNull(organization);
1309 // Update the contents of this resource.
1310 organization.setCsid(null);
1311 organization.setShortName("updated-" + organization.getShortName());
1312 if(logger.isDebugEnabled()){
1313 logger.debug("to be updated Organization");
1314 logger.debug(objectAsXmlString(organization,
1315 OrganizationsCommon.class));
1318 // Submit the updated resource to the service and store the response.
1319 MultipartOutput output = new MultipartOutput();
1320 OutputPart commonPart = output.addPart(organization, MediaType.APPLICATION_XML_TYPE);
1321 commonPart.getHeaders().add("label", client.getItemCommonPartName());
1322 res = client.updateItem(knownResourceId, knownItemResourceId, output);
1323 int statusCode = res.getStatus();
1325 // Check the status code of the response: does it match the expected response(s)?
1326 if(logger.isDebugEnabled()){
1327 logger.debug(testName + ": status = " + statusCode);
1329 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1330 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1331 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1333 // Retrieve the updated resource and verify that its contents exist.
1334 input = (MultipartInput) res.getEntity();
1335 OrganizationsCommon updatedOrganization =
1336 (OrganizationsCommon) extractPart(input,
1337 client.getItemCommonPartName(), OrganizationsCommon.class);
1338 Assert.assertNotNull(updatedOrganization);
1340 // Verify that the updated resource received the correct data.
1341 Assert.assertEquals(updatedOrganization.getShortName(),
1342 organization.getShortName(),
1343 "Data in updated Organization did not match submitted data.");
1349 * @param testName the test name
1350 * @throws Exception the exception
1352 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1353 groups = {"update"}, dependsOnMethods = {"updateItem"})
1354 public void updateContact(String testName) throws Exception {
1356 if (logger.isDebugEnabled()) {
1357 logger.debug(testBanner(testName, CLASS_NAME));
1362 // Retrieve the contents of a resource to update.
1363 OrgAuthorityClient client = new OrgAuthorityClient();
1364 ClientResponse<MultipartInput> res =
1365 client.readContact(knownResourceId, knownItemResourceId, knownContactResourceId);
1366 if(logger.isDebugEnabled()){
1367 logger.debug(testName + ": read status = " + res.getStatus());
1369 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
1371 if(logger.isDebugEnabled()){
1372 logger.debug("got Contact to update with ID: " +
1373 knownContactResourceId +
1374 " in item: " + knownItemResourceId +
1375 " in parent: " + knownResourceId );
1377 MultipartInput input = (MultipartInput) res.getEntity();
1378 ContactsCommon contact = (ContactsCommon) extractPart(input,
1379 new ContactClient().getCommonPartName(), ContactsCommon.class);
1380 Assert.assertNotNull(contact);
1382 // Update the contents of this resource.
1383 contact.setAddressPlace("updated-" + contact.getAddressPlace());
1384 if(logger.isDebugEnabled()){
1385 logger.debug("to be updated Contact");
1386 logger.debug(objectAsXmlString(contact,
1387 ContactsCommon.class));
1390 // Submit the updated resource to the service and store the response.
1391 MultipartOutput output = new MultipartOutput();
1392 OutputPart commonPart = output.addPart(contact, MediaType.APPLICATION_XML_TYPE);
1393 commonPart.getHeaders().add("label", new ContactClient().getCommonPartName());
1394 res = client.updateContact(knownResourceId, knownItemResourceId, knownContactResourceId, output);
1395 int statusCode = res.getStatus();
1397 // Check the status code of the response: does it match the expected response(s)?
1398 if(logger.isDebugEnabled()){
1399 logger.debug(testName + ": status = " + statusCode);
1401 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1402 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1403 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1405 // Retrieve the updated resource and verify that its contents exist.
1406 input = (MultipartInput) res.getEntity();
1407 ContactsCommon updatedContact =
1408 (ContactsCommon) extractPart(input,
1409 new ContactClient().getCommonPartName(), ContactsCommon.class);
1410 Assert.assertNotNull(updatedContact);
1412 // Verify that the updated resource received the correct data.
1413 Assert.assertEquals(updatedContact.getAddressPlace(),
1414 contact.getAddressPlace(),
1415 "Data in updated Contact did not match submitted data.");
1419 // Placeholders until the three tests below can be uncommented.
1420 // See Issue CSPACE-401.
1422 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
1425 public void updateWithEmptyEntityBody(String testName) throws Exception {
1426 //Should this really be empty?
1430 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
1433 public void updateWithMalformedXml(String testName) throws Exception {
1434 //Should this really be empty?
1438 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
1441 public void updateWithWrongXmlSchema(String testName) throws Exception {
1442 //Should this really be empty?
1447 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
1448 groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
1449 public void updateWithEmptyEntityBody(String testName) throws Exception {
1451 if (logger.isDebugEnabled()) {
1452 logger.debug(testBanner(testName, CLASS_NAME));
1455 setupUpdateWithEmptyEntityBody();
1457 // Submit the request to the service and store the response.
1458 String method = REQUEST_TYPE.httpMethodName();
1459 String url = getResourceURL(knownResourceId);
1460 String mediaType = MediaType.APPLICATION_XML;
1461 final String entity = "";
1462 int statusCode = submitRequest(method, url, mediaType, entity);
1464 // Check the status code of the response: does it match
1465 // the expected response(s)?
1466 if(logger.isDebugEnabled()){
1467 logger.debug(testName + ": url=" + url +
1468 " status=" + statusCode);
1470 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1471 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1472 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1476 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
1477 groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
1478 public void updateWithMalformedXml(String testName) throws Exception {
1480 if (logger.isDebugEnabled()) {
1481 logger.debug(testBanner(testName, CLASS_NAME));
1484 setupUpdateWithMalformedXml();
1486 // Submit the request to the service and store the response.
1487 String method = REQUEST_TYPE.httpMethodName();
1488 String url = getResourceURL(knownResourceId);
1489 String mediaType = MediaType.APPLICATION_XML;
1490 final String entity = MALFORMED_XML_DATA;
1491 int statusCode = submitRequest(method, url, mediaType, entity);
1493 // Check the status code of the response: does it match
1494 // the expected response(s)?
1495 if(logger.isDebugEnabled()){
1496 logger.debug(testName + ": url=" + url +
1497 " status=" + statusCode);
1499 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1500 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1501 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1505 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
1506 groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
1507 public void updateWithWrongXmlSchema(String testName) throws Exception {
1510 setupUpdateWithWrongXmlSchema(testName, logger);
1512 // Submit the request to the service and store the response.
1513 String method = REQUEST_TYPE.httpMethodName();
1514 String url = getResourceURL(knownResourceId);
1515 String mediaType = MediaType.APPLICATION_XML;
1516 final String entity = WRONG_XML_SCHEMA_DATA;
1517 int statusCode = submitRequest(method, url, mediaType, entity);
1519 // Check the status code of the response: does it match
1520 // the expected response(s)?
1521 if(logger.isDebugEnabled()){
1522 logger.debug("updateWithWrongXmlSchema: url=" + url +
1523 " status=" + statusCode);
1525 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1526 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1527 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1532 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
1535 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1536 groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
1537 public void updateNonExistent(String testName) throws Exception {
1539 if (logger.isDebugEnabled()) {
1540 logger.debug(testBanner(testName, CLASS_NAME));
1543 setupUpdateNonExistent();
1545 // Submit the request to the service and store the response.
1546 // Note: The ID used in this 'create' call may be arbitrary.
1547 // The only relevant ID may be the one used in update(), below.
1548 OrgAuthorityClient client = new OrgAuthorityClient();
1549 MultipartOutput multipart = createOrgAuthorityInstance(NON_EXISTENT_ID);
1550 ClientResponse<MultipartInput> res =
1551 client.update(NON_EXISTENT_ID, multipart);
1552 int statusCode = res.getStatus();
1554 // Check the status code of the response: does it match
1555 // the expected response(s)?
1556 if(logger.isDebugEnabled()){
1557 logger.debug(testName + ": status = " + statusCode);
1559 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1560 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1561 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1565 * Update non existent item.
1567 * @param testName the test name
1568 * @throws Exception the exception
1570 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1571 groups = {"update"}, dependsOnMethods = {"updateItem", "testItemSubmitRequest"})
1572 public void updateNonExistentItem(String testName) throws Exception {
1574 if (logger.isDebugEnabled()) {
1575 logger.debug(testBanner(testName, CLASS_NAME));
1578 setupUpdateNonExistent();
1580 // Submit the request to the service and store the response.
1581 // Note: The ID(s) used when creating the request payload may be arbitrary.
1582 // The only relevant ID may be the one used in update(), below.
1583 OrgAuthorityClient client = new OrgAuthorityClient();
1584 Map<String, String> nonexOrgMap = new HashMap<String,String>();
1585 nonexOrgMap.put(OrganizationJAXBSchema.SHORT_NAME, "Non-existent");
1586 String refName = OrgAuthorityClientUtils.createOrganizationRefName(knownResourceRefName, NON_EXISTENT_ID, true);
1587 MultipartOutput multipart =
1588 OrgAuthorityClientUtils.createOrganizationInstance(
1589 NON_EXISTENT_ID, refName,
1590 nonexOrgMap, client.getItemCommonPartName() );
1591 ClientResponse<MultipartInput> res =
1592 client.updateItem(knownResourceId, NON_EXISTENT_ID, multipart);
1593 int statusCode = res.getStatus();
1595 // Check the status code of the response: does it match
1596 // the expected response(s)?
1597 if(logger.isDebugEnabled()){
1598 logger.debug(testName + ": status = " + statusCode);
1600 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1601 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1602 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1606 * Update non existent contact.
1608 * @param testName the test name
1609 * @throws Exception the exception
1611 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1612 groups = {"update"}, dependsOnMethods = {"updateContact", "testContactSubmitRequest"})
1613 public void updateNonExistentContact(String testName) throws Exception {
1614 // Currently a no-op test
1617 // ---------------------------------------------------------------
1618 // CRUD tests : DELETE tests
1619 // ---------------------------------------------------------------
1622 // Note: delete sub-resources in ascending hierarchical order,
1623 // before deleting their parents.
1628 * @param testName the test name
1629 * @throws Exception the exception
1631 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1632 groups = {"delete"}, dependsOnGroups = {"create", "read", "readList", "update"})
1633 public void deleteContact(String testName) throws Exception {
1635 if (logger.isDebugEnabled()) {
1636 logger.debug(testBanner(testName, CLASS_NAME));
1641 if(logger.isDebugEnabled()){
1642 logger.debug("parentcsid =" + knownResourceId +
1643 " itemcsid = " + knownItemResourceId +
1644 " csid = " + knownContactResourceId);
1647 // Submit the request to the service and store the response.
1648 OrgAuthorityClient client = new OrgAuthorityClient();
1649 ClientResponse<Response> res =
1650 client.deleteContact(knownResourceId, knownItemResourceId, knownContactResourceId);
1651 int statusCode = res.getStatus();
1653 // Check the status code of the response: does it match
1654 // the expected response(s)?
1655 if(logger.isDebugEnabled()){
1656 logger.debug(testName + ": status = " + statusCode);
1658 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1659 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1660 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1666 * @param testName the test name
1667 * @throws Exception the exception
1669 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1670 groups = {"delete"}, dependsOnMethods = {"deleteContact"})
1671 public void deleteItem(String testName) throws Exception {
1673 if (logger.isDebugEnabled()) {
1674 logger.debug(testBanner(testName, CLASS_NAME));
1679 if(logger.isDebugEnabled()){
1680 logger.debug("parentcsid =" + knownResourceId +
1681 " itemcsid = " + knownItemResourceId);
1684 // Submit the request to the service and store the response.
1685 OrgAuthorityClient client = new OrgAuthorityClient();
1686 ClientResponse<Response> res = client.deleteItem(knownResourceId, knownItemResourceId);
1687 int statusCode = res.getStatus();
1689 // Check the status code of the response: does it match
1690 // the expected response(s)?
1691 if(logger.isDebugEnabled()){
1692 logger.debug(testName + ": status = " + statusCode);
1694 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1695 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1696 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1700 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
1703 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1704 groups = {"delete"}, dependsOnMethods = {"deleteItem"})
1705 public void delete(String testName) throws Exception {
1707 if (logger.isDebugEnabled()) {
1708 logger.debug(testBanner(testName, CLASS_NAME));
1713 if(logger.isDebugEnabled()){
1714 logger.debug("parentcsid =" + knownResourceId);
1717 // Submit the request to the service and store the response.
1718 OrgAuthorityClient client = new OrgAuthorityClient();
1719 ClientResponse<Response> res = client.delete(knownResourceId);
1720 int statusCode = res.getStatus();
1722 // Check the status code of the response: does it match
1723 // the expected response(s)?
1724 if(logger.isDebugEnabled()){
1725 logger.debug(testName + ": status = " + statusCode);
1727 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1728 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1729 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1734 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
1737 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1738 groups = {"delete"}, dependsOnMethods = {"delete"})
1739 public void deleteNonExistent(String testName) throws Exception {
1741 if (logger.isDebugEnabled()) {
1742 logger.debug(testBanner(testName, CLASS_NAME));
1745 setupDeleteNonExistent();
1747 // Submit the request to the service and store the response.
1748 OrgAuthorityClient client = new OrgAuthorityClient();
1749 ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
1750 int statusCode = res.getStatus();
1752 // Check the status code of the response: does it match
1753 // the expected response(s)?
1754 if(logger.isDebugEnabled()){
1755 logger.debug(testName + ": status = " + statusCode);
1757 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1758 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1759 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1763 * Delete non existent item.
1765 * @param testName the test name
1767 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1768 groups = {"delete"}, dependsOnMethods = {"deleteItem"})
1769 public void deleteNonExistentItem(String testName) {
1771 if (logger.isDebugEnabled()) {
1772 logger.debug(testBanner(testName, CLASS_NAME));
1775 setupDeleteNonExistent();
1777 // Submit the request to the service and store the response.
1778 OrgAuthorityClient client = new OrgAuthorityClient();
1779 ClientResponse<Response> res = client.deleteItem(knownResourceId, NON_EXISTENT_ID);
1780 int statusCode = res.getStatus();
1782 // Check the status code of the response: does it match
1783 // the expected response(s)?
1784 if(logger.isDebugEnabled()){
1785 logger.debug(testName + ": status = " + statusCode);
1787 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1788 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1789 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1793 * Delete non existent contact.
1795 * @param testName the test name
1797 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1798 groups = {"delete"}, dependsOnMethods = {"deleteContact"})
1799 public void deleteNonExistentContact(String testName) {
1801 if (logger.isDebugEnabled()) {
1802 logger.debug(testBanner(testName, CLASS_NAME));
1805 setupDeleteNonExistent();
1807 // Submit the request to the service and store the response.
1808 OrgAuthorityClient client = new OrgAuthorityClient();
1809 ClientResponse<Response> res =
1810 client.deleteContact(knownResourceId, knownItemResourceId, NON_EXISTENT_ID);
1811 int statusCode = res.getStatus();
1813 // Check the status code of the response: does it match
1814 // the expected response(s)?
1815 if(logger.isDebugEnabled()){
1816 logger.debug(testName + ": status = " + statusCode);
1818 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1819 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1820 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1823 // ---------------------------------------------------------------
1824 // Utility tests : tests of code used in tests above
1825 // ---------------------------------------------------------------
1827 * Tests the code for manually submitting data that is used by several
1828 * of the methods above.
1830 @Test(dependsOnMethods = {"create", "read"})
1831 public void testSubmitRequest() {
1833 // Expected status code: 200 OK
1834 final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
1836 // Submit the request to the service and store the response.
1837 String method = ServiceRequestType.READ.httpMethodName();
1838 String url = getResourceURL(knownResourceId);
1839 int statusCode = submitRequest(method, url);
1841 // Check the status code of the response: does it match
1842 // the expected response(s)?
1843 if(logger.isDebugEnabled()){
1844 logger.debug("testSubmitRequest: url=" + url +
1845 " status=" + statusCode);
1847 Assert.assertEquals(statusCode, EXPECTED_STATUS);
1852 * Test item submit request.
1854 @Test(dependsOnMethods = {"createItem", "readItem", "testSubmitRequest"})
1855 public void testItemSubmitRequest() {
1857 // Expected status code: 200 OK
1858 final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
1860 // Submit the request to the service and store the response.
1861 String method = ServiceRequestType.READ.httpMethodName();
1862 String url = getItemResourceURL(knownResourceId, knownItemResourceId);
1863 int statusCode = submitRequest(method, url);
1865 // Check the status code of the response: does it match
1866 // the expected response(s)?
1867 if(logger.isDebugEnabled()){
1868 logger.debug("testItemSubmitRequest: url=" + url +
1869 " status=" + statusCode);
1871 Assert.assertEquals(statusCode, EXPECTED_STATUS);
1876 * Test contact submit request.
1878 @Test(dependsOnMethods = {"createContact", "readContact", "testItemSubmitRequest"})
1879 public void testContactSubmitRequest() {
1881 // Expected status code: 200 OK
1882 final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
1884 // Submit the request to the service and store the response.
1885 String method = ServiceRequestType.READ.httpMethodName();
1886 String url = getContactResourceURL(knownResourceId,
1887 knownItemResourceId, knownContactResourceId);
1888 int statusCode = submitRequest(method, url);
1890 // Check the status code of the response: does it match
1891 // the expected response(s)?
1892 if(logger.isDebugEnabled()){
1893 logger.debug("testItemSubmitRequest: url=" + url +
1894 " status=" + statusCode);
1896 Assert.assertEquals(statusCode, EXPECTED_STATUS);
1901 // ---------------------------------------------------------------
1902 // Cleanup of resources created during testing
1903 // ---------------------------------------------------------------
1906 * Deletes all resources created by tests, after all tests have been run.
1908 * This cleanup method will always be run, even if one or more tests fail.
1909 * For this reason, it attempts to remove all resources created
1910 * at any point during testing, even if some of those resources
1911 * may be expected to be deleted by certain tests.
1914 @AfterClass(alwaysRun=true)
1916 public void cleanUp() {
1917 String noTest = System.getProperty("noTestCleanup");
1918 if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
1919 if (logger.isDebugEnabled()) {
1920 logger.debug("Skipping Cleanup phase ...");
1924 if (logger.isDebugEnabled()) {
1925 logger.debug("Cleaning up temporary resources created for testing ...");
1928 String parentResourceId;
1929 String itemResourceId;
1930 String contactResourceId;
1931 // Clean up contact resources.
1932 parentResourceId = knownResourceId;
1933 OrgAuthorityClient client = new OrgAuthorityClient();
1934 for (Map.Entry<String, String> entry : allContactResourceIdsCreated.entrySet()) {
1935 contactResourceId = entry.getKey();
1936 itemResourceId = entry.getValue();
1937 // Note: Any non-success responses from the delete operation
1938 // below are ignored and not reported.
1939 ClientResponse<Response> res =
1940 client.deleteContact(parentResourceId, itemResourceId, contactResourceId);
1941 res.releaseConnection();
1943 // Clean up item resources.
1944 for (Map.Entry<String, String> entry : allItemResourceIdsCreated.entrySet()) {
1945 itemResourceId = entry.getKey();
1946 parentResourceId = entry.getValue();
1947 // Note: Any non-success responses from the delete operation
1948 // below are ignored and not reported.
1949 ClientResponse<Response> res =
1950 client.deleteItem(parentResourceId, itemResourceId);
1951 res.releaseConnection();
1953 // Clean up parent resources.
1958 // ---------------------------------------------------------------
1959 // Utility methods used by tests above
1960 // ---------------------------------------------------------------
1962 * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
1965 public String getServicePathComponent() {
1966 return SERVICE_PATH_COMPONENT;
1970 * Gets the item service path component.
1972 * @return the item service path component
1974 public String getItemServicePathComponent() {
1975 return ITEM_SERVICE_PATH_COMPONENT;
1979 * Gets the contact service path component.
1981 * @return the contact service path component
1983 public String getContactServicePathComponent() {
1984 return CONTACT_SERVICE_PATH_COMPONENT;
1988 * Returns the root URL for the item service.
1990 * This URL consists of a base URL for all services, followed by
1991 * a path component for the owning parent, followed by the
1992 * path component for the items.
1994 * @param parentResourceIdentifier An identifier (such as a UUID) for the
1995 * parent authority resource of the relevant item resource.
1997 * @return The root URL for the item service.
1999 protected String getItemServiceRootURL(String parentResourceIdentifier) {
2000 return getResourceURL(parentResourceIdentifier) + "/" + getItemServicePathComponent();
2004 * Returns the URL of a specific item resource managed by a service, and
2005 * designated by an identifier (such as a universally unique ID, or UUID).
2007 * @param parentResourceIdentifier An identifier (such as a UUID) for the
2008 * parent authority resource of the relevant item resource.
2010 * @param itemResourceIdentifier An identifier (such as a UUID) for an
2013 * @return The URL of a specific item resource managed by a service.
2015 protected String getItemResourceURL(String parentResourceIdentifier, String itemResourceIdentifier) {
2016 return getItemServiceRootURL(parentResourceIdentifier) + "/" + itemResourceIdentifier;
2021 * Returns the root URL for the contact service.
2023 * This URL consists of a base URL for all services, followed by
2024 * a path component for the owning authority, followed by the
2025 * path component for the owning item, followed by the path component
2026 * for the contact service.
2028 * @param parentResourceIdentifier An identifier (such as a UUID) for the
2029 * parent authority resource of the relevant item resource.
2031 * @param itemResourceIdentifier An identifier (such as a UUID) for an
2034 * @return The root URL for the contact service.
2036 protected String getContactServiceRootURL(String parentResourceIdentifier,
2037 String itemResourceIdentifier) {
2038 return getItemResourceURL(parentResourceIdentifier, itemResourceIdentifier) + "/" +
2039 getContactServicePathComponent();
2043 * Returns the URL of a specific contact resource managed by a service, and
2044 * designated by an identifier (such as a universally unique ID, or UUID).
2046 * @param parentResourceIdentifier An identifier (such as a UUID) for the
2047 * parent resource of the relevant item resource.
2049 * @param resourceIdentifier An identifier (such as a UUID) for an
2052 * @return The URL of a specific resource managed by a service.
2054 protected String getContactResourceURL(String parentResourceIdentifier,
2055 String itemResourceIdentifier, String contactResourceIdentifier) {
2056 return getContactServiceRootURL(parentResourceIdentifier,
2057 itemResourceIdentifier) + "/" + contactResourceIdentifier;
2061 * Creates the org authority instance.
2063 * @param identifier the identifier
2064 * @return the multipart output
2066 private MultipartOutput createOrgAuthorityInstance(String identifier) {
2067 String displayName = "displayName-" + identifier;
2068 String refName = OrgAuthorityClientUtils.createOrgAuthRefName(displayName, true);
2069 return OrgAuthorityClientUtils.createOrgAuthorityInstance(
2070 displayName, refName,
2071 new OrgAuthorityClient().getCommonPartName());