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