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