]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
468c223a83167611bff40bf95b07bd2a74c75618
[tmp/jakarta-migration.git] /
1 /**
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:
5  *
6  * http://www.collectionspace.org
7  * http://wiki.collectionspace.org
8  *
9  * Copyright © 2009 Regents of the University of California
10  *
11  * Licensed under the Educational Community License (ECL), Version 2.0.
12  * You may not use this file except in compliance with this License.
13  *
14  * You may obtain a copy of the ECL 2.0 License at
15  * https://source.collectionspace.org/collection-space/LICENSE.txt
16  *
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.
22  */
23 package org.collectionspace.services.client.test;
24
25 import java.util.ArrayList;
26 import java.util.HashMap;
27 import java.util.List;
28 import java.util.Map;
29
30 import javax.ws.rs.core.MediaType;
31 import javax.ws.rs.core.Response;
32
33 import org.collectionspace.services.OrganizationJAXBSchema;
34 import org.collectionspace.services.PersonJAXBSchema;
35 import org.collectionspace.services.client.CollectionObjectClient;
36 import org.collectionspace.services.client.CollectionSpaceClient;
37 import org.collectionspace.services.client.OrgAuthorityClient;
38 import org.collectionspace.services.client.OrgAuthorityClientUtils;
39 import org.collectionspace.services.client.PersonAuthorityClient;
40 import org.collectionspace.services.client.PersonAuthorityClientUtils;
41 import org.collectionspace.services.common.authorityref.AuthorityRefList;
42 import org.collectionspace.services.collectionobject.AssocEventOrganizationList;
43 import org.collectionspace.services.collectionobject.AssocEventPersonList;
44 import org.collectionspace.services.collectionobject.AssocOrganizationList;
45 import org.collectionspace.services.collectionobject.AssocPersonList;
46 import org.collectionspace.services.collectionobject.CollectionobjectsCommon;
47 import org.collectionspace.services.collectionobject.ContentOrganizationList;
48 import org.collectionspace.services.collectionobject.ContentPersonList;
49 import org.collectionspace.services.collectionobject.FieldCollectionSourceList;
50 import org.collectionspace.services.collectionobject.FieldCollectorList;
51 import org.collectionspace.services.collectionobject.OwnerList;
52 import org.collectionspace.services.jaxb.AbstractCommonList;
53
54 import org.jboss.resteasy.client.ClientResponse;
55
56 import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
57 import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
58 import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
59 import org.testng.Assert;
60 import org.testng.annotations.AfterClass;
61 import org.testng.annotations.Test;
62
63 import org.slf4j.Logger;
64 import org.slf4j.LoggerFactory;
65
66 /**
67  * CollectionObjectAuthRefsTest, carries out tests against a
68  * deployed and running CollectionObject Service.
69  *
70  * $LastChangedRevision: 1327 $
71  * $LastChangedDate: 2010-02-12 10:35:11 -0800 (Fri, 12 Feb 2010) $
72  */
73 public class CollectionObjectAuthRefsTest extends BaseServiceTest {
74
75    /** The logger. */
76     private final String CLASS_NAME = CollectionObjectAuthRefsTest.class.getName();
77     private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
78
79     // Instance variables specific to this test.
80     /** The service path component. */
81     final String SERVICE_PATH_COMPONENT = "collectionobjects";
82     
83     /** The person authority name. */
84     final String PERSON_AUTHORITY_NAME = "TestPersonAuth";
85     final String PERSON_AUTHORITY_NAME_DISPLAY = "TestPersonAuth_DisplayName";
86
87     /** The organization authority name. */
88     final String ORG_AUTHORITY_NAME = "TestOrgAuth";
89     
90     /** The known resource id. */
91     private String knownResourceId = null;
92     
93     /** The collection object ids created. */
94     private List<String> collectionObjectIdsCreated = new ArrayList<String>();
95     
96     /** The person ids created. */
97     private List<String> personIdsCreated = new ArrayList<String>();
98     
99     /** The person authority csid and refName. */
100     private String personAuthCSID = null; 
101     private String personAuthRefName = null;
102     
103     /** The organization ids created. */
104     private List<String> orgIdsCreated = new ArrayList<String>();
105
106     /** The org authority csid and refName. */
107     private String orgAuthCSID = null;
108     private String orgAuthRefName = null;
109     
110     private String contentOrganizationRefName = null;
111     private String contentPersonRefName = null;
112     private String contentInscriberRefName = null;
113     private String descriptionInscriberRefName = null;
114     private String objectProductionPersonRefName = null;
115     private String objectProductionOrganizationRefName = null;
116     private String assocEventOrganizationRefName = null;
117     private String assocEventPersonRefName = null;
118     private String assocOrganizationRefName = null;
119     private String assocPersonRefName = null;
120     private String ownerRefName = null;
121     private String fieldCollectionSourceRefName = null;
122     private String fieldCollectorRefName = null;
123
124     public String toString(){
125         String result = "CollectionObjectauthRefsTest: "
126                         + "\r\npersonAuthCSID: "+personAuthCSID
127                         + "\r\npersonAuthRefName: "+personAuthRefName
128                         + "\r\norgAuthCSID: "+orgAuthCSID
129                         + "\r\norgAuthRefName: "+orgAuthRefName
130                         + "\r\n"
131                         + "\r\n contentOrganizationRefName: "+contentOrganizationRefName
132                         + "\r\n contentPersonRefName: "+contentPersonRefName
133                         + "\r\n contentInscriberRefName: "+contentInscriberRefName
134                         + "\r\n descriptionInscriberRefName: "+descriptionInscriberRefName
135                         + "\r\n objectProductionPersonRefName: "+objectProductionPersonRefName
136                         + "\r\n objectProductionOrganizationRefName: "+objectProductionOrganizationRefName
137                         + "\r\n assocEventOrganizationRefName: "+assocEventOrganizationRefName
138                         + "\r\n assocEventPersonRefName: "+assocEventPersonRefName
139                         + "\r\n assocOrganizationRefName: "+assocOrganizationRefName
140                         + "\r\n assocPersonRefName: "+assocPersonRefName
141                         + "\r\n ownerRefName: "+ownerRefName
142                         + "\r\n fieldCollectionSourceRefName: "+fieldCollectionSourceRefName
143                         + "\r\n fieldCollectorRefName: "+fieldCollectorRefName;
144         StringBuffer buff = new StringBuffer();
145
146         return result;
147     }
148
149     /** The number of authority references expected. */
150     private final int NUM_AUTH_REFS_EXPECTED = 13;
151
152     /* (non-Javadoc)
153      * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
154      */
155     @Override
156     protected CollectionSpaceClient getClientInstance() {
157         throw new UnsupportedOperationException(); //method not supported (or needed) in this test class
158     }
159     
160     /* (non-Javadoc)
161      * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
162      */
163     @Override
164         protected AbstractCommonList getAbstractCommonList(
165                         ClientResponse<AbstractCommonList> response) {
166         throw new UnsupportedOperationException(); //method not supported (or needed) in this test class
167     }
168
169     // ---------------------------------------------------------------
170     // CRUD tests : CREATE tests
171     // ---------------------------------------------------------------
172     // Success outcomes
173     /**
174      * Creates the with auth refs.
175      *
176      * @param testName the test name
177      * @throws Exception the exception
178      */
179     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class)
180     public void createWithAuthRefs(String testName) throws Exception {
181
182         if (logger.isDebugEnabled()) {
183             logger.debug(testBanner(testName, CLASS_NAME));
184         }
185         testSetup(STATUS_CREATED, ServiceRequestType.CREATE);
186         
187         // Create all the person refs and entities
188         createPersonRefs();
189
190         // Create all the organization refs and entities
191         createOrganizationRefs();
192
193         // Create an object record payload, containing
194         // authority reference values in a number of its fields
195         String identifier = createIdentifier();
196         MultipartOutput multipart =
197             createCollectionObjectInstance(
198                 "Obj Title",
199                 "ObjNum" + "-" + identifier,
200                 contentOrganizationRefName,
201                 contentPersonRefName,
202                 contentInscriberRefName,
203                 descriptionInscriberRefName,
204                 objectProductionPersonRefName,
205                 objectProductionOrganizationRefName,
206                 assocEventOrganizationRefName,
207                 assocEventPersonRefName,
208                 assocOrganizationRefName,
209                 assocPersonRefName,
210                 ownerRefName,
211                 fieldCollectionSourceRefName,
212                 fieldCollectorRefName
213             );
214
215         // Submit the request to the service and store the response.
216         CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
217         ClientResponse<Response> res = collectionObjectClient.create(multipart);
218
219         int statusCode = res.getStatus();
220
221         // Check the status code of the response: does it match
222         // the expected response(s)?
223         //
224         // Specifically:
225         // Does it fall within the set of valid status codes?
226         // Does it exactly match the expected status code?
227         if(logger.isDebugEnabled()){
228             logger.debug(testName + ": status = " + statusCode);
229         }
230         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
231                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
232         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
233
234         // Store the ID returned from the first resource created
235         // for additional tests below.
236         if (knownResourceId == null){
237             knownResourceId = extractId(res);
238             if (logger.isDebugEnabled()) {
239                 logger.debug(testName + ": knownResourceId=" + knownResourceId);
240             }
241         }
242         
243         // Store the IDs from every resource created by tests,
244         // so they can be deleted after tests have been run.
245         collectionObjectIdsCreated.add(extractId(res));
246     }
247
248     /**
249      * Creates a Person Authority.
250      *
251      * @param displayName the display name of the authority
252      * @param shortIdentifier the short identifier for the authority
253      */
254     private void createPersonAuthority(String displayName, String shortIdentifier) {
255         testSetup(STATUS_CREATED, ServiceRequestType.CREATE);
256         PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
257         MultipartOutput multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance(
258                         displayName, shortIdentifier, personAuthClient.getCommonPartName());
259         ClientResponse<Response> res = personAuthClient.create(multipart);
260         int statusCode = res.getStatus();
261
262         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
263                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
264         Assert.assertEquals(statusCode, STATUS_CREATED);
265         personAuthCSID = extractId(res);
266         personAuthRefName = PersonAuthorityClientUtils.getAuthorityRefName(personAuthCSID, null);
267     }
268
269     /**
270      * Creates a person item.
271      *
272      * @param firstName the person's first name
273      * @param surName the person's surname
274      * @param shortIdentifier the short identifier for the item
275      * @return the CSID of the newly-created person record
276      */
277     protected String createPerson(String firstName, String surName, String shortIdentifier ) {
278         Map<String, String> personInfo = new HashMap<String,String>();
279         personInfo.put(PersonJAXBSchema.FORE_NAME, firstName);
280         personInfo.put(PersonJAXBSchema.SUR_NAME, surName);
281         personInfo.put(PersonJAXBSchema.SHORT_IDENTIFIER, shortIdentifier);
282         PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
283         MultipartOutput multipart =
284                 PersonAuthorityClientUtils.createPersonInstance(personAuthCSID,
285                                 personAuthRefName, personInfo, personAuthClient.getItemCommonPartName());
286         ClientResponse<Response> res = personAuthClient.createItem(personAuthCSID, multipart);
287         int statusCode = res.getStatus();
288
289         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
290                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
291         Assert.assertEquals(statusCode, STATUS_CREATED);
292         return extractId(res);
293     }
294
295     /**
296      * Creates multiple Person items within a Person Authority,
297      * and stores the refNames referring to each.
298      */
299     protected void createPersonRefs(){
300
301         createPersonAuthority(PERSON_AUTHORITY_NAME_DISPLAY, PERSON_AUTHORITY_NAME);
302
303         String csid = "";
304         
305         csid = createPerson("Connie", "ContactPerson", "connieContactPerson");
306         contentPersonRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
307         personIdsCreated.add(csid);
308         
309         csid = createPerson("Ingrid", "ContentInscriber", "ingridContentInscriber");
310         contentInscriberRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
311         personIdsCreated.add(csid);
312
313         csid = createPerson("Pacifico", "ProductionPerson", "pacificoProductionPerson");
314         objectProductionPersonRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
315         personIdsCreated.add(csid);
316
317         csid = createPerson("Dessie", "DescriptionInscriber", "dessieDescriptionInscriber");
318         descriptionInscriberRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
319         personIdsCreated.add(csid);
320
321         csid = createPerson("Asok", "AssociatedEventPerson", "asokAssociatedEventPerson");
322         assocEventPersonRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
323         personIdsCreated.add(csid);
324         
325         csid = createPerson("Andrew", "AssociatedPerson", "andrewAssociatedPerson");
326         assocPersonRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
327         personIdsCreated.add(csid);
328
329         csid = createPerson("Owen", "Owner", "owenOwner");
330         ownerRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
331         personIdsCreated.add(csid);
332
333         csid = createPerson("Sally", "Field-CollectionSource", "sallyFieldCollectionSource");
334         fieldCollectionSourceRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
335         personIdsCreated.add(csid);
336
337         csid = createPerson("Fred", "Lector", "fredLector");
338         fieldCollectorRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
339         personIdsCreated.add(csid);
340     }
341     
342     /**
343      * Creates an organization authority.
344      *
345      * @param displayName the display name of the authority
346      * @param shortIdentifier the short identifier for the authority
347      */
348     private void createOrgAuthority(String displayName, String shortIdentifier) {
349         testSetup(STATUS_CREATED, ServiceRequestType.CREATE);
350         OrgAuthorityClient orgAuthClient = new OrgAuthorityClient();
351         MultipartOutput multipart = OrgAuthorityClientUtils.createOrgAuthorityInstance(
352                         displayName, shortIdentifier, orgAuthClient.getCommonPartName());
353         ClientResponse<Response> res = orgAuthClient.create(multipart);
354         int statusCode = res.getStatus();
355
356         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
357                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
358         Assert.assertEquals(statusCode, STATUS_CREATED);
359         orgAuthCSID = extractId(res);
360         orgAuthRefName = OrgAuthorityClientUtils.getAuthorityRefName(orgAuthCSID, null);
361     }
362
363     /**
364      * Creates an organization item.
365      *
366      * @param shortName the organization's short name
367      * @param foundingPlace the organization's founding place
368      * @param shortIdentifier the short identifier for the item
369      * @return the CSID of the newly-created organization record
370      */
371     protected String createOrganization(String shortName, String foundingPlace, String shortIdentifier ) {
372         Map<String, String> orgInfo = new HashMap<String,String>();
373         orgInfo.put(OrganizationJAXBSchema.SHORT_NAME, shortName);
374         orgInfo.put(OrganizationJAXBSchema.FOUNDING_PLACE, foundingPlace);
375         orgInfo.put(OrganizationJAXBSchema.SHORT_IDENTIFIER, shortIdentifier);
376         OrgAuthorityClient orgAuthClient = new OrgAuthorityClient();
377         MultipartOutput multipart =
378                 OrgAuthorityClientUtils.createOrganizationInstance(
379                                 orgAuthRefName, orgInfo, orgAuthClient.getItemCommonPartName());
380         ClientResponse<Response> res = orgAuthClient.createItem(orgAuthCSID, multipart);
381         int statusCode = res.getStatus();
382
383         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
384                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
385         Assert.assertEquals(statusCode, STATUS_CREATED);
386         return extractId(res);
387     }
388     
389    /**
390      * Creates multiple Organization items within an Organization Authority,
391      * and stores the refNames referring to each.
392      */
393     private void createOrganizationRefs() {
394
395         createOrgAuthority(ORG_AUTHORITY_NAME, ORG_AUTHORITY_NAME);
396
397         String csid = "";
398
399         csid = createOrganization("Content Org", "Content Org Town", "contentOrg");
400         contentOrganizationRefName = OrgAuthorityClientUtils.getOrgRefName(orgAuthCSID, csid, null);
401         orgIdsCreated.add(csid);
402
403         csid = createOrganization("Production Org", "Production Org Town", "productionOrg");
404         objectProductionOrganizationRefName = OrgAuthorityClientUtils.getOrgRefName(orgAuthCSID, csid, null);
405         orgIdsCreated.add(csid);
406
407         csid = createOrganization("Associated Event Org", "Associated Event Org City", "associatedEventOrg");
408         assocEventOrganizationRefName = OrgAuthorityClientUtils.getOrgRefName(orgAuthCSID, csid, null);
409         orgIdsCreated.add(csid);
410
411         csid = createOrganization("Associated Org", "Associated Org City", "associatedOrg");
412         assocOrganizationRefName = OrgAuthorityClientUtils.getOrgRefName(orgAuthCSID, csid, null);
413         orgIdsCreated.add(csid);
414     }
415
416
417     // Success outcomes
418     /**
419      * Read and check auth refs.
420      *
421      * @param testName the test name
422      * @throws Exception the exception
423      */
424     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
425         dependsOnMethods = {"createWithAuthRefs"})
426     public void readAndCheckAuthRefs(String testName) throws Exception {
427
428         if (logger.isDebugEnabled()) {
429             logger.debug(testBanner(testName, CLASS_NAME));
430         }
431         // Perform setup.
432         testSetup(STATUS_OK, ServiceRequestType.READ);
433
434         // Submit the request to the service and store the response.
435         CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
436         ClientResponse<MultipartInput> res = collectionObjectClient.read(knownResourceId);
437         int statusCode = res.getStatus();
438
439         // Check the status code of the response: does it match
440         // the expected response(s)?
441         if(logger.isDebugEnabled()){
442             logger.debug(testName + ".read: status = " + statusCode);
443         }
444         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
445                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
446         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
447
448         MultipartInput input = (MultipartInput) res.getEntity();
449         CollectionobjectsCommon collectionObject = (CollectionobjectsCommon) extractPart(input,
450                         collectionObjectClient.getCommonPartName(), CollectionobjectsCommon.class);
451         Assert.assertNotNull(collectionObject);
452
453         // Get all of the auth refs and check that the expected number is returned
454         ClientResponse<AuthorityRefList> res2 = collectionObjectClient.getAuthorityRefs(knownResourceId);
455         statusCode = res2.getStatus();
456         
457         if(logger.isDebugEnabled()){
458             logger.debug(testName + ".getAuthorityRefs: status = " + statusCode);
459         }
460         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
461                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
462         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
463         AuthorityRefList list = res2.getEntity();
464         
465         List<AuthorityRefList.AuthorityRefItem> items = list.getAuthorityRefItem();
466         int numAuthRefsFound = items.size();
467         if(logger.isDebugEnabled()){
468             logger.debug("Expected " + NUM_AUTH_REFS_EXPECTED +
469                 " authority references, found " + numAuthRefsFound);
470         }
471         Assert.assertEquals(numAuthRefsFound, NUM_AUTH_REFS_EXPECTED,
472             "Did not find all expected authority references! " +
473             "Expected " + NUM_AUTH_REFS_EXPECTED + ", found " + numAuthRefsFound);
474                
475         // Check a sample of one or more person authority ref fields
476         Assert.assertEquals(collectionObject.getInscriptionContentInscriber(), contentInscriberRefName);
477         Assert.assertEquals(collectionObject.getAssocPersons().getAssocPerson().get(0), assocPersonRefName);
478         Assert.assertEquals(collectionObject.getOwners().getOwner().get(0), ownerRefName);
479         Assert.assertEquals(collectionObject.getFieldCollectionSources().getFieldCollectionSource().get(0), fieldCollectionSourceRefName);
480
481         // Check a sample of one or more organization authority ref fields
482         Assert.assertEquals(collectionObject.getContentOrganizations().getContentOrganization().get(0), contentOrganizationRefName);
483         Assert.assertEquals(collectionObject.getAssocEventOrganizations().getAssocEventOrganization().get(0), assocEventOrganizationRefName);
484
485         // Optionally output additional data about list members for debugging.
486         logger.info(this.toString());
487         boolean iterateThroughList = true;
488         if(iterateThroughList && logger.isDebugEnabled()){;
489             int i = 0;
490             for(AuthorityRefList.AuthorityRefItem item : items){
491                 logger.debug(testName + ": list-item[" + i + "] Field:" +
492                                 item.getSourceField() + " =" +
493                         " item display name = " + item.getAuthDisplayName() +
494                         " auth display name = " + item.getItemDisplayName());
495                 logger.debug(testName + ": list-item[" + i + "] refName=" +
496                         item.getRefName());
497                 logger.debug(testName + ": list-item[" + i + "] URI=" +
498                         item.getUri());
499                 i++;
500             }
501         }
502     }
503
504
505     // ---------------------------------------------------------------
506     // Cleanup of resources created during testing
507     // ---------------------------------------------------------------
508
509     /**
510      * Deletes all resources created by tests, after all tests have been run.
511      *
512      * This cleanup method will always be run, even if one or more tests fail.
513      * For this reason, it attempts to remove all resources created
514      * at any point during testing, even if some of those resources
515      * may be expected to be deleted by certain tests.
516      */
517     @AfterClass(alwaysRun=true)
518     public void cleanUp() {
519         String noTest = System.getProperty("noTestCleanup");
520         if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
521             if (logger.isDebugEnabled()) {
522                 logger.debug("Skipping Cleanup phase ...");
523             }
524             return;
525         }
526         if (logger.isDebugEnabled()) {
527             logger.debug("Cleaning up temporary resources created for testing ...");
528         }
529         CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
530         for (String resourceId : collectionObjectIdsCreated) {
531             // Note: Any non-success responses are ignored and not reported.
532             collectionObjectClient.delete(resourceId).releaseConnection();
533         }
534         // Note: Any non-success response is ignored and not reported.
535         PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
536         // Delete persons before PersonAuth
537         for (String resourceId : personIdsCreated) {
538             // Note: Any non-success responses are ignored and not reported.
539             personAuthClient.deleteItem(personAuthCSID, resourceId).releaseConnection();
540         }
541         personAuthClient.delete(personAuthCSID).releaseConnection();
542         // Note: Any non-success response is ignored and not reported.
543         OrgAuthorityClient orgAuthClient = new OrgAuthorityClient();
544         // Delete organizations before OrgAuth
545         for (String resourceId : orgIdsCreated) {
546             // Note: Any non-success responses are ignored and not reported.
547             orgAuthClient.deleteItem(orgAuthCSID, resourceId).releaseConnection();
548         }
549         orgAuthClient.delete(orgAuthCSID).releaseConnection();
550     }
551
552     // ---------------------------------------------------------------
553     // Utility methods used by tests above
554     // ---------------------------------------------------------------
555     /* (non-Javadoc)
556      * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
557      */
558     @Override
559     public String getServicePathComponent() {
560         return SERVICE_PATH_COMPONENT;
561     }
562
563    /**
564     * Creates the collection object instance.
565     *
566     * @param title the title
567     * @param objNum the obj num
568     * @param contentOrganization the content organization
569     * @param contentPeople the content people
570     * @param contentPerson the content person
571     * @param inscriber the inscriber
572     * @return the multipart output
573     */
574    private MultipartOutput createCollectionObjectInstance(
575                 String title,
576                 String objNum,
577                 String contentOrganization,
578                 String contentPerson,
579                 String contentInscriber,
580                 String descriptionInscriber,
581                 String objectProductionPerson,
582                 String objectProductionOrganization,
583                 String assocEventOrganization,
584                 String assocEventPerson,
585                 String assocOrganization,
586                 String assocPerson,
587                 String owner,
588                 String fieldCollectionSource,
589                 String fieldCollector ) {
590         CollectionobjectsCommon collectionObject = new CollectionobjectsCommon();
591         collectionObject.setTitle(title);
592         collectionObject.setObjectNumber(objNum);
593         collectionObject.setInscriptionContentInscriber(contentInscriber);
594         collectionObject.setInscriptionDescriptionInscriber(descriptionInscriber);
595         collectionObject.setObjectProductionPerson(objectProductionPerson);
596         collectionObject.setObjectProductionOrganization(objectProductionOrganization);
597
598         ContentOrganizationList contentOrganizationList = new ContentOrganizationList();
599         List<String> contentOrganizations = contentOrganizationList.getContentOrganization();
600         contentOrganizations.add(contentOrganization);
601         collectionObject.setContentOrganizations(contentOrganizationList);
602
603         ContentPersonList contentPersonList = new ContentPersonList();
604         List<String> contentPersons = contentPersonList.getContentPerson();
605         contentPersons.add(contentPerson);
606         collectionObject.setContentPersons(contentPersonList);
607
608         AssocEventOrganizationList assocEventOrganizationList = new AssocEventOrganizationList();
609         List<String> assocEventOrganizations = assocEventOrganizationList.getAssocEventOrganization();
610         assocEventOrganizations.add(assocEventOrganization);
611         collectionObject.setAssocEventOrganizations(assocEventOrganizationList);
612
613         AssocEventPersonList assocEventPersonList = new AssocEventPersonList();
614         List<String> assocEventPersons = assocEventPersonList.getAssocEventPerson();
615         assocEventPersons.add(assocEventPerson);
616         collectionObject.setAssocEventPersons(assocEventPersonList);
617
618         AssocOrganizationList assocOrganizationList = new AssocOrganizationList();
619         List<String> assocOrganizations = assocOrganizationList.getAssocOrganization();
620         assocOrganizations.add(assocOrganization);
621         collectionObject.setAssocOrganizations(assocOrganizationList);
622
623         AssocPersonList assocPersonList = new AssocPersonList();
624         List<String> assocPersons = assocPersonList.getAssocPerson();
625         assocPersons.add(assocPerson);
626         collectionObject.setAssocPersons(assocPersonList);
627         
628         OwnerList ownerList = new OwnerList();
629         List<String> owners = ownerList.getOwner();
630         owners.add(owner);
631         collectionObject.setOwners(ownerList);
632         
633         FieldCollectionSourceList fieldCollectionSourceList = new FieldCollectionSourceList();
634         List<String> fieldCollectionSources = fieldCollectionSourceList.getFieldCollectionSource();
635         fieldCollectionSources.add(fieldCollectionSource);
636         collectionObject.setFieldCollectionSources(fieldCollectionSourceList);
637         
638         FieldCollectorList FieldCollectorList = new FieldCollectorList();
639         List<String> fieldCollectors = FieldCollectorList.getFieldCollector();
640         fieldCollectors.add(fieldCollector);
641         collectionObject.setFieldCollectors(FieldCollectorList);
642
643         MultipartOutput multipart = new MultipartOutput();
644         OutputPart commonPart =
645             multipart.addPart(collectionObject, MediaType.APPLICATION_XML_TYPE);
646         commonPart.getHeaders().add("label", new CollectionObjectClient().getCommonPartName());
647
648         if(logger.isDebugEnabled()){
649             logger.debug("to be created, collectionObject common");
650             logger.debug(objectAsXmlString(collectionObject, CollectionobjectsCommon.class));
651         }
652
653         return multipart;
654     }
655
656 }