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 ClientResponse<ContactsCommonList> res =
1154 client.readContactList(parentcsid, itemcsid);
1155 ContactsCommonList list = res.getEntity();
1156 int statusCode = res.getStatus();
1158 // Check the status code of the response: does it match
1159 // the expected response(s)?
1160 if(logger.isDebugEnabled()){
1161 logger.debug(testName + ": status = " + statusCode);
1163 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1164 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1165 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1167 List<ContactsCommonList.ContactListItem> listitems =
1168 list.getContactListItem();
1169 int nItemsReturned = listitems.size();
1170 // There will be one item created, associated with a
1171 // known parent resource, by the createItem test.
1173 // In addition, there will be 'nItemsToCreateInList'
1174 // additional items created by the createItemList test,
1175 // all associated with the same parent resource.
1176 int nExpectedItems = nItemsToCreateInList + 1;
1177 if(logger.isDebugEnabled()){
1178 logger.debug(testName + ": Expected "
1179 + nExpectedItems +" items; got: "+nItemsReturned);
1181 Assert.assertEquals(nItemsReturned, nExpectedItems);
1184 for (ContactsCommonList.ContactListItem listitem : listitems) {
1185 // Optionally output additional data about list members for debugging.
1186 boolean showDetails = false;
1187 if (showDetails && logger.isDebugEnabled()) {
1188 logger.debug(" " + testName + ": list-item[" + i + "] csid=" +
1189 listitem.getCsid());
1190 logger.debug(" " + testName + ": list-item[" + i + "] addressPlace=" +
1191 listitem.getAddressPlace());
1192 logger.debug(" " + testName + ": list-item[" + i + "] URI=" +
1202 // ---------------------------------------------------------------
1203 // CRUD tests : UPDATE tests
1204 // ---------------------------------------------------------------
1207 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
1210 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1211 groups = {"update"}, dependsOnGroups = {"read", "readList"})
1212 public void update(String testName) throws Exception {
1214 if (logger.isDebugEnabled()) {
1215 logger.debug(testBanner(testName, CLASS_NAME));
1220 // Retrieve the contents of a resource to update.
1221 OrgAuthorityClient client = new OrgAuthorityClient();
1222 ClientResponse<MultipartInput> res =
1223 client.read(knownResourceId);
1224 if(logger.isDebugEnabled()){
1225 logger.debug(testName + ": read status = " + res.getStatus());
1227 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
1229 if(logger.isDebugEnabled()){
1230 logger.debug("got OrgAuthority to update with ID: " + knownResourceId);
1232 MultipartInput input = (MultipartInput) res.getEntity();
1233 OrgauthoritiesCommon orgAuthority = (OrgauthoritiesCommon) extractPart(input,
1234 client.getCommonPartName(), OrgauthoritiesCommon.class);
1235 Assert.assertNotNull(orgAuthority);
1237 // Update the contents of this resource.
1238 orgAuthority.setDisplayName("updated-" + orgAuthority.getDisplayName());
1239 orgAuthority.setVocabType("updated-" + orgAuthority.getVocabType());
1240 if(logger.isDebugEnabled()){
1241 logger.debug("to be updated OrgAuthority");
1242 logger.debug(objectAsXmlString(orgAuthority, OrgauthoritiesCommon.class));
1245 // Submit the updated resource to the service and store the response.
1246 MultipartOutput output = new MultipartOutput();
1247 OutputPart commonPart = output.addPart(orgAuthority, MediaType.APPLICATION_XML_TYPE);
1248 commonPart.getHeaders().add("label", client.getCommonPartName());
1249 res = client.update(knownResourceId, output);
1250 int statusCode = res.getStatus();
1252 // Check the status code of the response: does it match the expected response(s)?
1253 if(logger.isDebugEnabled()){
1254 logger.debug(testName + ": status = " + statusCode);
1256 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1257 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1258 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1260 // Retrieve the updated resource and verify that its contents exist.
1261 input = (MultipartInput) res.getEntity();
1262 OrgauthoritiesCommon updatedOrgAuthority =
1263 (OrgauthoritiesCommon) extractPart(input,
1264 client.getCommonPartName(), OrgauthoritiesCommon.class);
1265 Assert.assertNotNull(updatedOrgAuthority);
1267 // Verify that the updated resource received the correct data.
1268 Assert.assertEquals(updatedOrgAuthority.getDisplayName(),
1269 orgAuthority.getDisplayName(),
1270 "Data in updated object did not match submitted data.");
1276 * @param testName the test name
1277 * @throws Exception the exception
1279 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1280 groups = {"update"}, dependsOnMethods = {"update"})
1281 public void updateItem(String testName) throws Exception {
1283 if (logger.isDebugEnabled()) {
1284 logger.debug(testBanner(testName, CLASS_NAME));
1289 // Retrieve the contents of a resource to update.
1290 OrgAuthorityClient client = new OrgAuthorityClient();
1291 ClientResponse<MultipartInput> res =
1292 client.readItem(knownResourceId, knownItemResourceId);
1293 if(logger.isDebugEnabled()){
1294 logger.debug(testName + ": read status = " + res.getStatus());
1296 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
1298 if(logger.isDebugEnabled()){
1299 logger.debug("got Organization to update with ID: " +
1300 knownItemResourceId +
1301 " in OrgAuthority: " + knownResourceId );
1303 MultipartInput input = (MultipartInput) res.getEntity();
1304 OrganizationsCommon organization = (OrganizationsCommon) extractPart(input,
1305 client.getItemCommonPartName(), OrganizationsCommon.class);
1306 Assert.assertNotNull(organization);
1308 // Update the contents of this resource.
1309 organization.setCsid(null);
1310 organization.setShortName("updated-" + organization.getShortName());
1311 if(logger.isDebugEnabled()){
1312 logger.debug("to be updated Organization");
1313 logger.debug(objectAsXmlString(organization,
1314 OrganizationsCommon.class));
1317 // Submit the updated resource to the service and store the response.
1318 MultipartOutput output = new MultipartOutput();
1319 OutputPart commonPart = output.addPart(organization, MediaType.APPLICATION_XML_TYPE);
1320 commonPart.getHeaders().add("label", client.getItemCommonPartName());
1321 res = client.updateItem(knownResourceId, knownItemResourceId, output);
1322 int statusCode = res.getStatus();
1324 // Check the status code of the response: does it match the expected response(s)?
1325 if(logger.isDebugEnabled()){
1326 logger.debug(testName + ": status = " + statusCode);
1328 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1329 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1330 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1332 // Retrieve the updated resource and verify that its contents exist.
1333 input = (MultipartInput) res.getEntity();
1334 OrganizationsCommon updatedOrganization =
1335 (OrganizationsCommon) extractPart(input,
1336 client.getItemCommonPartName(), OrganizationsCommon.class);
1337 Assert.assertNotNull(updatedOrganization);
1339 // Verify that the updated resource received the correct data.
1340 Assert.assertEquals(updatedOrganization.getShortName(),
1341 organization.getShortName(),
1342 "Data in updated Organization did not match submitted data.");
1348 * @param testName the test name
1349 * @throws Exception the exception
1351 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1352 groups = {"update"}, dependsOnMethods = {"updateItem"})
1353 public void updateContact(String testName) throws Exception {
1355 if (logger.isDebugEnabled()) {
1356 logger.debug(testBanner(testName, CLASS_NAME));
1361 // Retrieve the contents of a resource to update.
1362 OrgAuthorityClient client = new OrgAuthorityClient();
1363 ClientResponse<MultipartInput> res =
1364 client.readContact(knownResourceId, knownItemResourceId, knownContactResourceId);
1365 if(logger.isDebugEnabled()){
1366 logger.debug(testName + ": read status = " + res.getStatus());
1368 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
1370 if(logger.isDebugEnabled()){
1371 logger.debug("got Contact to update with ID: " +
1372 knownContactResourceId +
1373 " in item: " + knownItemResourceId +
1374 " in parent: " + knownResourceId );
1376 MultipartInput input = (MultipartInput) res.getEntity();
1377 ContactsCommon contact = (ContactsCommon) extractPart(input,
1378 new ContactClient().getCommonPartName(), ContactsCommon.class);
1379 Assert.assertNotNull(contact);
1381 // Update the contents of this resource.
1382 contact.setAddressPlace("updated-" + contact.getAddressPlace());
1383 if(logger.isDebugEnabled()){
1384 logger.debug("to be updated Contact");
1385 logger.debug(objectAsXmlString(contact,
1386 ContactsCommon.class));
1389 // Submit the updated resource to the service and store the response.
1390 MultipartOutput output = new MultipartOutput();
1391 OutputPart commonPart = output.addPart(contact, MediaType.APPLICATION_XML_TYPE);
1392 commonPart.getHeaders().add("label", new ContactClient().getCommonPartName());
1393 res = client.updateContact(knownResourceId, knownItemResourceId, knownContactResourceId, output);
1394 int statusCode = res.getStatus();
1396 // Check the status code of the response: does it match the expected response(s)?
1397 if(logger.isDebugEnabled()){
1398 logger.debug(testName + ": status = " + statusCode);
1400 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1401 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1402 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1404 // Retrieve the updated resource and verify that its contents exist.
1405 input = (MultipartInput) res.getEntity();
1406 ContactsCommon updatedContact =
1407 (ContactsCommon) extractPart(input,
1408 new ContactClient().getCommonPartName(), ContactsCommon.class);
1409 Assert.assertNotNull(updatedContact);
1411 // Verify that the updated resource received the correct data.
1412 Assert.assertEquals(updatedContact.getAddressPlace(),
1413 contact.getAddressPlace(),
1414 "Data in updated Contact did not match submitted data.");
1418 // Placeholders until the three tests below can be uncommented.
1419 // See Issue CSPACE-401.
1421 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
1424 public void updateWithEmptyEntityBody(String testName) throws Exception {
1425 //Should this really be empty?
1429 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
1432 public void updateWithMalformedXml(String testName) throws Exception {
1433 //Should this really be empty?
1437 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
1440 public void updateWithWrongXmlSchema(String testName) throws Exception {
1441 //Should this really be empty?
1446 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
1447 groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
1448 public void updateWithEmptyEntityBody(String testName) throws Exception {
1450 if (logger.isDebugEnabled()) {
1451 logger.debug(testBanner(testName, CLASS_NAME));
1454 setupUpdateWithEmptyEntityBody();
1456 // Submit the request to the service and store the response.
1457 String method = REQUEST_TYPE.httpMethodName();
1458 String url = getResourceURL(knownResourceId);
1459 String mediaType = MediaType.APPLICATION_XML;
1460 final String entity = "";
1461 int statusCode = submitRequest(method, url, mediaType, entity);
1463 // Check the status code of the response: does it match
1464 // the expected response(s)?
1465 if(logger.isDebugEnabled()){
1466 logger.debug(testName + ": url=" + url +
1467 " status=" + statusCode);
1469 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1470 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1471 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1475 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
1476 groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
1477 public void updateWithMalformedXml(String testName) throws Exception {
1479 if (logger.isDebugEnabled()) {
1480 logger.debug(testBanner(testName, CLASS_NAME));
1483 setupUpdateWithMalformedXml();
1485 // Submit the request to the service and store the response.
1486 String method = REQUEST_TYPE.httpMethodName();
1487 String url = getResourceURL(knownResourceId);
1488 String mediaType = MediaType.APPLICATION_XML;
1489 final String entity = MALFORMED_XML_DATA;
1490 int statusCode = submitRequest(method, url, mediaType, entity);
1492 // Check the status code of the response: does it match
1493 // the expected response(s)?
1494 if(logger.isDebugEnabled()){
1495 logger.debug(testName + ": url=" + url +
1496 " status=" + statusCode);
1498 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1499 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1500 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1504 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
1505 groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
1506 public void updateWithWrongXmlSchema(String testName) throws Exception {
1509 setupUpdateWithWrongXmlSchema(testName, logger);
1511 // Submit the request to the service and store the response.
1512 String method = REQUEST_TYPE.httpMethodName();
1513 String url = getResourceURL(knownResourceId);
1514 String mediaType = MediaType.APPLICATION_XML;
1515 final String entity = WRONG_XML_SCHEMA_DATA;
1516 int statusCode = submitRequest(method, url, mediaType, entity);
1518 // Check the status code of the response: does it match
1519 // the expected response(s)?
1520 if(logger.isDebugEnabled()){
1521 logger.debug("updateWithWrongXmlSchema: url=" + url +
1522 " status=" + statusCode);
1524 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1525 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1526 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1531 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
1534 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1535 groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
1536 public void updateNonExistent(String testName) throws Exception {
1538 if (logger.isDebugEnabled()) {
1539 logger.debug(testBanner(testName, CLASS_NAME));
1542 setupUpdateNonExistent();
1544 // Submit the request to the service and store the response.
1545 // Note: The ID used in this 'create' call may be arbitrary.
1546 // The only relevant ID may be the one used in update(), below.
1547 OrgAuthorityClient client = new OrgAuthorityClient();
1548 MultipartOutput multipart = createOrgAuthorityInstance(NON_EXISTENT_ID);
1549 ClientResponse<MultipartInput> res =
1550 client.update(NON_EXISTENT_ID, multipart);
1551 int statusCode = res.getStatus();
1553 // Check the status code of the response: does it match
1554 // the expected response(s)?
1555 if(logger.isDebugEnabled()){
1556 logger.debug(testName + ": status = " + statusCode);
1558 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1559 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1560 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1564 * Update non existent item.
1566 * @param testName the test name
1567 * @throws Exception the exception
1569 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1570 groups = {"update"}, dependsOnMethods = {"updateItem", "testItemSubmitRequest"})
1571 public void updateNonExistentItem(String testName) throws Exception {
1573 if (logger.isDebugEnabled()) {
1574 logger.debug(testBanner(testName, CLASS_NAME));
1577 setupUpdateNonExistent();
1579 // Submit the request to the service and store the response.
1580 // Note: The ID(s) used when creating the request payload may be arbitrary.
1581 // The only relevant ID may be the one used in update(), below.
1582 OrgAuthorityClient client = new OrgAuthorityClient();
1583 Map<String, String> nonexOrgMap = new HashMap<String,String>();
1584 nonexOrgMap.put(OrganizationJAXBSchema.SHORT_NAME, "Non-existent");
1585 String refName = OrgAuthorityClientUtils.createOrganizationRefName(knownResourceRefName, NON_EXISTENT_ID, true);
1586 MultipartOutput multipart =
1587 OrgAuthorityClientUtils.createOrganizationInstance(
1588 NON_EXISTENT_ID, refName,
1589 nonexOrgMap, client.getItemCommonPartName() );
1590 ClientResponse<MultipartInput> res =
1591 client.updateItem(knownResourceId, NON_EXISTENT_ID, multipart);
1592 int statusCode = res.getStatus();
1594 // Check the status code of the response: does it match
1595 // the expected response(s)?
1596 if(logger.isDebugEnabled()){
1597 logger.debug(testName + ": status = " + statusCode);
1599 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1600 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1601 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1605 * Update non existent contact.
1607 * @param testName the test name
1608 * @throws Exception the exception
1610 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1611 groups = {"update"}, dependsOnMethods = {"updateContact", "testContactSubmitRequest"})
1612 public void updateNonExistentContact(String testName) throws Exception {
1613 // Currently a no-op test
1616 // ---------------------------------------------------------------
1617 // CRUD tests : DELETE tests
1618 // ---------------------------------------------------------------
1621 // Note: delete sub-resources in ascending hierarchical order,
1622 // before deleting their parents.
1627 * @param testName the test name
1628 * @throws Exception the exception
1630 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1631 groups = {"delete"}, dependsOnGroups = {"create", "read", "readList", "update"})
1632 public void deleteContact(String testName) throws Exception {
1634 if (logger.isDebugEnabled()) {
1635 logger.debug(testBanner(testName, CLASS_NAME));
1640 if(logger.isDebugEnabled()){
1641 logger.debug("parentcsid =" + knownResourceId +
1642 " itemcsid = " + knownItemResourceId +
1643 " csid = " + knownContactResourceId);
1646 // Submit the request to the service and store the response.
1647 OrgAuthorityClient client = new OrgAuthorityClient();
1648 ClientResponse<Response> res =
1649 client.deleteContact(knownResourceId, knownItemResourceId, knownContactResourceId);
1650 int statusCode = res.getStatus();
1652 // Check the status code of the response: does it match
1653 // the expected response(s)?
1654 if(logger.isDebugEnabled()){
1655 logger.debug(testName + ": status = " + statusCode);
1657 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1658 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1659 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1665 * @param testName the test name
1666 * @throws Exception the exception
1668 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1669 groups = {"delete"}, dependsOnMethods = {"deleteContact"})
1670 public void deleteItem(String testName) throws Exception {
1672 if (logger.isDebugEnabled()) {
1673 logger.debug(testBanner(testName, CLASS_NAME));
1678 if(logger.isDebugEnabled()){
1679 logger.debug("parentcsid =" + knownResourceId +
1680 " itemcsid = " + knownItemResourceId);
1683 // Submit the request to the service and store the response.
1684 OrgAuthorityClient client = new OrgAuthorityClient();
1685 ClientResponse<Response> res = client.deleteItem(knownResourceId, knownItemResourceId);
1686 int statusCode = res.getStatus();
1688 // Check the status code of the response: does it match
1689 // the expected response(s)?
1690 if(logger.isDebugEnabled()){
1691 logger.debug(testName + ": status = " + statusCode);
1693 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1694 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1695 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1699 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
1702 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1703 groups = {"delete"}, dependsOnMethods = {"deleteItem"})
1704 public void delete(String testName) throws Exception {
1706 if (logger.isDebugEnabled()) {
1707 logger.debug(testBanner(testName, CLASS_NAME));
1712 if(logger.isDebugEnabled()){
1713 logger.debug("parentcsid =" + knownResourceId);
1716 // Submit the request to the service and store the response.
1717 OrgAuthorityClient client = new OrgAuthorityClient();
1718 ClientResponse<Response> res = client.delete(knownResourceId);
1719 int statusCode = res.getStatus();
1721 // Check the status code of the response: does it match
1722 // the expected response(s)?
1723 if(logger.isDebugEnabled()){
1724 logger.debug(testName + ": status = " + statusCode);
1726 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1727 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1728 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1733 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
1736 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1737 groups = {"delete"}, dependsOnMethods = {"delete"})
1738 public void deleteNonExistent(String testName) throws Exception {
1740 if (logger.isDebugEnabled()) {
1741 logger.debug(testBanner(testName, CLASS_NAME));
1744 setupDeleteNonExistent();
1746 // Submit the request to the service and store the response.
1747 OrgAuthorityClient client = new OrgAuthorityClient();
1748 ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
1749 int statusCode = res.getStatus();
1751 // Check the status code of the response: does it match
1752 // the expected response(s)?
1753 if(logger.isDebugEnabled()){
1754 logger.debug(testName + ": status = " + statusCode);
1756 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1757 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1758 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1762 * Delete non existent item.
1764 * @param testName the test name
1766 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1767 groups = {"delete"}, dependsOnMethods = {"deleteItem"})
1768 public void deleteNonExistentItem(String testName) {
1770 if (logger.isDebugEnabled()) {
1771 logger.debug(testBanner(testName, CLASS_NAME));
1774 setupDeleteNonExistent();
1776 // Submit the request to the service and store the response.
1777 OrgAuthorityClient client = new OrgAuthorityClient();
1778 ClientResponse<Response> res = client.deleteItem(knownResourceId, NON_EXISTENT_ID);
1779 int statusCode = res.getStatus();
1781 // Check the status code of the response: does it match
1782 // the expected response(s)?
1783 if(logger.isDebugEnabled()){
1784 logger.debug(testName + ": status = " + statusCode);
1786 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1787 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1788 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1792 * Delete non existent contact.
1794 * @param testName the test name
1796 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1797 groups = {"delete"}, dependsOnMethods = {"deleteContact"})
1798 public void deleteNonExistentContact(String testName) {
1800 if (logger.isDebugEnabled()) {
1801 logger.debug(testBanner(testName, CLASS_NAME));
1804 setupDeleteNonExistent();
1806 // Submit the request to the service and store the response.
1807 OrgAuthorityClient client = new OrgAuthorityClient();
1808 ClientResponse<Response> res =
1809 client.deleteContact(knownResourceId, knownItemResourceId, NON_EXISTENT_ID);
1810 int statusCode = res.getStatus();
1812 // Check the status code of the response: does it match
1813 // the expected response(s)?
1814 if(logger.isDebugEnabled()){
1815 logger.debug(testName + ": status = " + statusCode);
1817 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1818 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1819 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1822 // ---------------------------------------------------------------
1823 // Utility tests : tests of code used in tests above
1824 // ---------------------------------------------------------------
1826 * Tests the code for manually submitting data that is used by several
1827 * of the methods above.
1829 @Test(dependsOnMethods = {"create", "read"})
1830 public void testSubmitRequest() {
1832 // Expected status code: 200 OK
1833 final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
1835 // Submit the request to the service and store the response.
1836 String method = ServiceRequestType.READ.httpMethodName();
1837 String url = getResourceURL(knownResourceId);
1838 int statusCode = submitRequest(method, url);
1840 // Check the status code of the response: does it match
1841 // the expected response(s)?
1842 if(logger.isDebugEnabled()){
1843 logger.debug("testSubmitRequest: url=" + url +
1844 " status=" + statusCode);
1846 Assert.assertEquals(statusCode, EXPECTED_STATUS);
1851 * Test item submit request.
1853 @Test(dependsOnMethods = {"createItem", "readItem", "testSubmitRequest"})
1854 public void testItemSubmitRequest() {
1856 // Expected status code: 200 OK
1857 final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
1859 // Submit the request to the service and store the response.
1860 String method = ServiceRequestType.READ.httpMethodName();
1861 String url = getItemResourceURL(knownResourceId, knownItemResourceId);
1862 int statusCode = submitRequest(method, url);
1864 // Check the status code of the response: does it match
1865 // the expected response(s)?
1866 if(logger.isDebugEnabled()){
1867 logger.debug("testItemSubmitRequest: url=" + url +
1868 " status=" + statusCode);
1870 Assert.assertEquals(statusCode, EXPECTED_STATUS);
1875 * Test contact submit request.
1877 @Test(dependsOnMethods = {"createContact", "readContact", "testItemSubmitRequest"})
1878 public void testContactSubmitRequest() {
1880 // Expected status code: 200 OK
1881 final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
1883 // Submit the request to the service and store the response.
1884 String method = ServiceRequestType.READ.httpMethodName();
1885 String url = getContactResourceURL(knownResourceId,
1886 knownItemResourceId, knownContactResourceId);
1887 int statusCode = submitRequest(method, url);
1889 // Check the status code of the response: does it match
1890 // the expected response(s)?
1891 if(logger.isDebugEnabled()){
1892 logger.debug("testItemSubmitRequest: url=" + url +
1893 " status=" + statusCode);
1895 Assert.assertEquals(statusCode, EXPECTED_STATUS);
1900 // ---------------------------------------------------------------
1901 // Cleanup of resources created during testing
1902 // ---------------------------------------------------------------
1905 * Deletes all resources created by tests, after all tests have been run.
1907 * This cleanup method will always be run, even if one or more tests fail.
1908 * For this reason, it attempts to remove all resources created
1909 * at any point during testing, even if some of those resources
1910 * may be expected to be deleted by certain tests.
1913 @AfterClass(alwaysRun=true)
1915 public void cleanUp() {
1916 String noTest = System.getProperty("noTestCleanup");
1917 if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
1918 if (logger.isDebugEnabled()) {
1919 logger.debug("Skipping Cleanup phase ...");
1923 if (logger.isDebugEnabled()) {
1924 logger.debug("Cleaning up temporary resources created for testing ...");
1927 String parentResourceId;
1928 String itemResourceId;
1929 String contactResourceId;
1930 // Clean up contact resources.
1931 parentResourceId = knownResourceId;
1932 OrgAuthorityClient client = new OrgAuthorityClient();
1933 for (Map.Entry<String, String> entry : allContactResourceIdsCreated.entrySet()) {
1934 contactResourceId = entry.getKey();
1935 itemResourceId = entry.getValue();
1936 // Note: Any non-success responses from the delete operation
1937 // below are ignored and not reported.
1938 ClientResponse<Response> res =
1939 client.deleteContact(parentResourceId, itemResourceId, contactResourceId);
1940 res.releaseConnection();
1942 // Clean up item resources.
1943 for (Map.Entry<String, String> entry : allItemResourceIdsCreated.entrySet()) {
1944 itemResourceId = entry.getKey();
1945 parentResourceId = entry.getValue();
1946 // Note: Any non-success responses from the delete operation
1947 // below are ignored and not reported.
1948 ClientResponse<Response> res =
1949 client.deleteItem(parentResourceId, itemResourceId);
1950 res.releaseConnection();
1952 // Clean up parent resources.
1957 // ---------------------------------------------------------------
1958 // Utility methods used by tests above
1959 // ---------------------------------------------------------------
1961 * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
1964 public String getServicePathComponent() {
1965 return SERVICE_PATH_COMPONENT;
1969 * Gets the item service path component.
1971 * @return the item service path component
1973 public String getItemServicePathComponent() {
1974 return ITEM_SERVICE_PATH_COMPONENT;
1978 * Gets the contact service path component.
1980 * @return the contact service path component
1982 public String getContactServicePathComponent() {
1983 return CONTACT_SERVICE_PATH_COMPONENT;
1987 * Returns the root URL for the item service.
1989 * This URL consists of a base URL for all services, followed by
1990 * a path component for the owning parent, followed by the
1991 * path component for the items.
1993 * @param parentResourceIdentifier An identifier (such as a UUID) for the
1994 * parent authority resource of the relevant item resource.
1996 * @return The root URL for the item service.
1998 protected String getItemServiceRootURL(String parentResourceIdentifier) {
1999 return getResourceURL(parentResourceIdentifier) + "/" + getItemServicePathComponent();
2003 * Returns the URL of a specific item resource managed by a service, and
2004 * designated by an identifier (such as a universally unique ID, or UUID).
2006 * @param parentResourceIdentifier An identifier (such as a UUID) for the
2007 * parent authority resource of the relevant item resource.
2009 * @param itemResourceIdentifier An identifier (such as a UUID) for an
2012 * @return The URL of a specific item resource managed by a service.
2014 protected String getItemResourceURL(String parentResourceIdentifier, String itemResourceIdentifier) {
2015 return getItemServiceRootURL(parentResourceIdentifier) + "/" + itemResourceIdentifier;
2020 * Returns the root URL for the contact service.
2022 * This URL consists of a base URL for all services, followed by
2023 * a path component for the owning authority, followed by the
2024 * path component for the owning item, followed by the path component
2025 * for the contact service.
2027 * @param parentResourceIdentifier An identifier (such as a UUID) for the
2028 * parent authority resource of the relevant item resource.
2030 * @param itemResourceIdentifier An identifier (such as a UUID) for an
2033 * @return The root URL for the contact service.
2035 protected String getContactServiceRootURL(String parentResourceIdentifier,
2036 String itemResourceIdentifier) {
2037 return getItemResourceURL(parentResourceIdentifier, itemResourceIdentifier) + "/" +
2038 getContactServicePathComponent();
2042 * Returns the URL of a specific contact resource managed by a service, and
2043 * designated by an identifier (such as a universally unique ID, or UUID).
2045 * @param parentResourceIdentifier An identifier (such as a UUID) for the
2046 * parent resource of the relevant item resource.
2048 * @param resourceIdentifier An identifier (such as a UUID) for an
2051 * @return The URL of a specific resource managed by a service.
2053 protected String getContactResourceURL(String parentResourceIdentifier,
2054 String itemResourceIdentifier, String contactResourceIdentifier) {
2055 return getContactServiceRootURL(parentResourceIdentifier,
2056 itemResourceIdentifier) + "/" + contactResourceIdentifier;
2060 * Creates the org authority instance.
2062 * @param identifier the identifier
2063 * @return the multipart output
2065 private MultipartOutput createOrgAuthorityInstance(String identifier) {
2066 String displayName = "displayName-" + identifier;
2067 String refName = OrgAuthorityClientUtils.createOrgAuthRefName(displayName, true);
2068 return OrgAuthorityClientUtils.createOrgAuthorityInstance(
2069 displayName, refName,
2070 new OrgAuthorityClient().getCommonPartName());