]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
58829438036cc8f6c9176d5008e6172f46a2f6e6
[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 (c) 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.IntegrationTests.test;
24
25 import java.io.StringWriter;
26 import java.math.BigDecimal;
27 import java.util.ArrayList;
28 import java.util.List;
29
30 import javax.ws.rs.core.MediaType;
31 import javax.ws.rs.core.Response;
32 import javax.xml.bind.JAXBContext;
33 import javax.xml.bind.Marshaller;
34
35 import org.testng.Assert;
36 import org.testng.annotations.Test;
37
38 import org.slf4j.Logger;
39 import org.slf4j.LoggerFactory;
40
41 import org.jboss.resteasy.client.ClientResponse;
42
43 import org.collectionspace.services.client.CollectionObjectClient;
44 import org.collectionspace.services.client.DimensionClient;
45 import org.collectionspace.services.client.DimensionFactory;
46 import org.collectionspace.services.client.PayloadOutputPart;
47 import org.collectionspace.services.client.PoxPayloadIn;
48 import org.collectionspace.services.client.PoxPayloadOut;
49 import org.collectionspace.services.collectionobject.CollectionobjectsCommon;
50
51 import org.collectionspace.services.client.IntakeClient;
52 import org.collectionspace.services.intake.IntakesCommon;
53
54 import org.collectionspace.services.client.RelationClient;
55 import org.collectionspace.services.client.workflow.WorkflowClient;
56 import org.collectionspace.services.dimension.DimensionsCommon;
57 import org.collectionspace.services.relation.RelationsCommon;
58 import org.collectionspace.services.relation.RelationsCommonList;
59 import org.collectionspace.services.relation.RelationshipType;
60
61 /**
62  * A ServiceTest.
63  * 
64  * @version $Revision:$
65  */
66 public class RelationIntegrationTest extends CollectionSpaceIntegrationTest {
67
68         final Logger logger = LoggerFactory
69                         .getLogger(RelationIntegrationTest.class);
70         //
71         // Get clients for the CollectionSpace services
72         //
73         private CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
74         private RelationClient relationClient = new RelationClient();
75         private IntakeClient intakeClient = new IntakeClient();
76         private DimensionClient dimensionClient = new DimensionClient();
77         
78         private static final int OBJECTS_TO_INTAKE = 1;
79         
80         
81     /**
82      * Object as xml string.
83      *
84      * @param o the o
85      * @param clazz the clazz
86      * @return the string
87      */
88     static protected String objectAsXmlString(Object o, Class<?> clazz) {
89         StringWriter sw = new StringWriter();
90         try {
91             JAXBContext jc = JAXBContext.newInstance(clazz);
92             Marshaller m = jc.createMarshaller();
93             m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,
94                     Boolean.TRUE);
95             m.marshal(o, sw);
96         } catch (Exception e) {
97             e.printStackTrace();
98         }
99         return sw.toString();
100     }
101         
102     private PoxPayloadOut createDimensionInstance(String commonPartName, String dimensionType, String dimensionValue, String entryDate) {
103         DimensionsCommon dimensionsCommon = new DimensionsCommon();
104         dimensionsCommon.setDimension(dimensionType);
105         dimensionsCommon.setValue(new BigDecimal(dimensionValue));
106         dimensionsCommon.setValueDate(entryDate);
107         PoxPayloadOut multipart = DimensionFactory.createDimensionInstance(
108                 commonPartName, dimensionsCommon);
109
110         if (logger.isDebugEnabled()) {
111             logger.debug("to be created, dimension common");
112             logger.debug(objectAsXmlString(dimensionsCommon,
113                     DimensionsCommon.class));
114         }
115
116         return multipart;
117     }
118         
119     protected PoxPayloadOut createDimensionInstance(String identifier) {
120         DimensionClient client = new DimensionClient();
121         return createDimensionInstance(client.getCommonPartName(), identifier);
122     }
123     
124     /**
125      * Creates the dimension instance.
126      *
127      * @param identifier the identifier
128      * @return the multipart output
129      */
130     protected PoxPayloadOut createDimensionInstance(String commonPartName, String identifier) {
131         final String dimensionValue = Long.toString(System.currentTimeMillis());
132         
133         return createDimensionInstance(commonPartName, 
134                 "dimensionType-" + identifier,
135                 dimensionValue,
136                 "entryDate-" + identifier);
137     }
138     
139         @Test void deleteCollectionObjectRelationshipToLockedDimension() {
140                 // First create a CollectionObject
141                 CollectionobjectsCommon co = new CollectionobjectsCommon();
142                 fillCollectionObject(co, createIdentifier());           
143                 PoxPayloadOut multipart = new PoxPayloadOut(CollectionObjectClient.SERVICE_PAYLOAD_NAME);
144                 PayloadOutputPart commonPart = multipart.addPart(collectionObjectClient.getCommonPartName(), co);
145                 
146                 // Make the "create" call and check the response
147                 Response response = collectionObjectClient.create(multipart);
148                 String collectionObjectCsid = null;
149                 try {
150                         Assert.assertEquals(response.getStatus(), Response.Status.CREATED
151                                         .getStatusCode());
152                         collectionObjectCsid = extractId(response);
153                 } finally {
154                         response.close();
155                 }
156                 
157                 // Create a new dimension record
158             multipart = this.createDimensionInstance(createIdentifier());
159             // Make the call to create and check the response
160             response = dimensionClient.create(multipart);
161             String dimensionCsid1 = null;
162             try {
163                     Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
164                     dimensionCsid1 = extractId(response);
165             } finally {
166                 response.close();
167             }
168             
169             // Relate the entities, by creating a new relation object
170             RelationsCommon relation = new RelationsCommon();
171             fillRelation(relation, collectionObjectCsid, CollectionobjectsCommon.class.getSimpleName(),
172                         dimensionCsid1, DimensionsCommon.class.getSimpleName(),
173                         "collectionobject-dimension");
174             // Create the part and fill it with the relation object
175             multipart = new PoxPayloadOut(RelationClient.SERVICE_PAYLOAD_NAME);
176             commonPart = multipart.addPart(relationClient.getCommonPartName(), relation);
177             // Create the relationship
178             response = relationClient.create(multipart);
179             String relationCsid1 = null;
180             try {
181                     Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
182                     relationCsid1 = extractId(response);
183             } finally {
184                 response.close();
185             }       
186             
187             // Now lock the dimension record.
188             
189                 @SuppressWarnings("unused")
190                 ClientResponse<String> workflowResponse = dimensionClient.updateWorkflowWithTransition(dimensionCsid1, WorkflowClient.WORKFLOWTRANSITION_LOCK);
191             System.out.println("Locked dimension record with CSID=" + dimensionCsid1);
192             
193             // Finally, try to delete the relationship
194             
195             // Try to delete the relationship -should fail because we don't allow delete if one of the sides is locked.
196             response = relationClient.delete(relationCsid1);
197             try {
198                     Assert.assertEquals(response.getStatus(), Response.Status.BAD_REQUEST.getStatusCode());
199             } finally {
200                 response.close();
201             }
202             
203             // Also, try to soft-delete.  This should also fail.
204                 workflowResponse = dimensionClient.updateWorkflowWithTransition(dimensionCsid1, WorkflowClient.WORKFLOWTRANSITION_DELETE);
205             System.out.println("Locked dimension record with CSID=" + dimensionCsid1);
206         }
207         
208         @Test void createCollectionObjectRelationshipToManyDimensions() {
209                 //
210                 // First create a CollectionObject
211                 //
212                 CollectionobjectsCommon co = new CollectionobjectsCommon();
213                 fillCollectionObject(co, createIdentifier());           
214                 PoxPayloadOut multipart = new PoxPayloadOut(CollectionObjectClient.SERVICE_PAYLOAD_NAME);
215                 PayloadOutputPart commonPart = multipart.addPart(collectionObjectClient.getCommonPartName(), co);
216                 
217                 // Make the create call and check the response
218                 Response response = collectionObjectClient.create(multipart);
219                 String collectionObjectCsid = null;
220                 try {
221                         Assert.assertEquals(response.getStatus(), Response.Status.CREATED
222                                         .getStatusCode());
223                         collectionObjectCsid = extractId(response);
224                 } finally {
225                         response.close();
226                 }
227                 
228                 //Next, create the first of three Dimension records to relate the collection object record
229             multipart = this.createDimensionInstance(createIdentifier());
230             // Make the call to create and check the response
231             response = dimensionClient.create(multipart);
232             String dimensionCsid1 = null;
233             try {
234                     Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
235                     dimensionCsid1 = extractId(response);
236             } finally {
237                 response.close();
238             }
239             
240                 //Next, create a the second Dimension record
241             multipart = this.createDimensionInstance(createIdentifier());
242             // Make the call to create and check the response
243             response = dimensionClient.create(multipart);
244             String dimensionCsid2 = null;
245             try {
246                     Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
247                     dimensionCsid2 = extractId(response);
248             } finally {
249                 response.close();
250             }
251             
252                 //Next, create a the 3rd Dimension record
253             multipart = this.createDimensionInstance(createIdentifier());
254             // Make the call to create and check the response
255             response = dimensionClient.create(multipart);
256             String dimensionCsid3 = null;
257             try {
258                     Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
259                     dimensionCsid3 = extractId(response);
260             } finally {
261                 response.close();
262             }
263             
264             // Relate the entities, by creating a new relation object
265             RelationsCommon relation = new RelationsCommon();
266             fillRelation(relation,
267                         collectionObjectCsid, CollectionobjectsCommon.class.getSimpleName(), // the subject of the relationship
268                         dimensionCsid1, DimensionsCommon.class.getSimpleName(), // the object of the relationship
269                         "collectionobject-dimension");
270             // Create the part and fill it with the relation object
271             multipart = new PoxPayloadOut(RelationClient.SERVICE_PAYLOAD_NAME);
272             commonPart = multipart.addPart(relationClient.getCommonPartName(), relation);
273             // Create the relationship
274             response = relationClient.create(multipart);
275             String relationCsid1 = null;
276             try {
277                     Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
278                     relationCsid1 = extractId(response);
279             } finally {
280                 response.close();
281             }
282             // Wait 1 second and create the second relationship
283             try {
284                         Thread.sleep(1001);
285                 } catch (InterruptedException e) {
286                         // TODO Auto-generated catch block
287                         e.printStackTrace();
288                 }
289             relation = new RelationsCommon();
290             fillRelation(relation,
291                         collectionObjectCsid, CollectionobjectsCommon.class.getSimpleName(), // the subject of the relationship
292                         dimensionCsid2, DimensionsCommon.class.getSimpleName(), // the object of the relationship
293                         "collectionobject-dimension");
294             // Create the part and fill it with the relation object
295             multipart = new PoxPayloadOut(RelationClient.SERVICE_PAYLOAD_NAME);
296             commonPart = multipart.addPart(relationClient.getCommonPartName(), relation);
297             // Create the relationship
298             response = relationClient.create(multipart);
299             @SuppressWarnings("unused")
300                 String relationCsid2 = null;
301             try {
302                     Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
303                     relationCsid2 = extractId(response);
304             } finally {
305                 response.close();
306             }
307             // Wait 1 second and create the 3rd relationship
308             try {
309                         Thread.sleep(1001);
310                 } catch (InterruptedException e) {
311                         // TODO Auto-generated catch block
312                         e.printStackTrace();
313                 }
314             relation = new RelationsCommon();
315             fillRelation(relation,
316                         collectionObjectCsid, CollectionobjectsCommon.class.getSimpleName(), // the subject of the relationship
317                         dimensionCsid3, DimensionsCommon.class.getSimpleName(), // the object of the relationship
318                         "collectionobject-dimension");
319             // Create the part and fill it with the relation object
320             multipart = new PoxPayloadOut(RelationClient.SERVICE_PAYLOAD_NAME);
321             commonPart = multipart.addPart(relationClient.getCommonPartName(), relation);
322             // Create the relationship
323             response = relationClient.create(multipart);
324             @SuppressWarnings("unused")
325                 String relationCsid3 = null;
326             try {
327                     Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
328                     relationCsid3 = extractId(response);
329             } finally {
330                 response.close();
331             }               
332         }    
333         
334         @Test void releteCollectionObjectToLockedDimension() {
335                 //
336                 // First create a CollectionObject
337                 //
338                 CollectionobjectsCommon co = new CollectionobjectsCommon();
339                 fillCollectionObject(co, createIdentifier());
340                 
341                 // Next, create a part object
342                 PoxPayloadOut multipart = new PoxPayloadOut(CollectionObjectClient.SERVICE_PAYLOAD_NAME);
343                 PayloadOutputPart commonPart = multipart.addPart(co, MediaType.APPLICATION_XML_TYPE);
344                 commonPart.setLabel(collectionObjectClient.getCommonPartName());
345                 
346                 // Make the create call and check the response
347                 Response response = collectionObjectClient.create(multipart);
348                 String collectionObjectCsid = null;
349                 try {
350                         Assert.assertEquals(response.getStatus(), Response.Status.CREATED
351                                         .getStatusCode());
352                         collectionObjectCsid = extractId(response);
353                 } finally {
354                         response.close();
355                 }
356                 
357                 //Next, create a Dimension record to relate the collection object to
358             multipart = this.createDimensionInstance(createIdentifier());
359             // Make the call to create and check the response
360             response = dimensionClient.create(multipart);
361             String dimensionCsid = null;
362             try {
363                     Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
364                     dimensionCsid = extractId(response);
365             } finally {
366                 response.close();
367             }
368             
369             @SuppressWarnings("unused")
370                 ClientResponse<String> workflowResponse = dimensionClient.updateWorkflowWithTransition(dimensionCsid, WorkflowClient.WORKFLOWTRANSITION_LOCK);
371             System.out.println("Locked dimension record with CSID=" + dimensionCsid);
372             
373             // Lastly, relate the two entities, by creating a new relation object
374             RelationsCommon relation = new RelationsCommon();
375             fillRelation(relation, collectionObjectCsid, CollectionobjectsCommon.class.getSimpleName(),
376                         dimensionCsid, DimensionsCommon.class.getSimpleName(),
377                         "collectionobject-dimension");
378             // Create the part and fill it with the relation object
379             multipart = new PoxPayloadOut(RelationClient.SERVICE_PAYLOAD_NAME);
380             commonPart = multipart.addPart(relation, MediaType.APPLICATION_XML_TYPE);
381             commonPart.setLabel(relationClient.getCommonPartName());
382
383             // Make the call to crate
384             Response relationresponse = relationClient.create(multipart);
385                 String relationCsid = null;
386             try {
387                     Assert.assertEquals(relationresponse.getStatus(), Response.Status.BAD_REQUEST.getStatusCode());
388                     relationCsid = extractId(response);
389             } finally {
390                 relationresponse.close();
391             }
392         }
393         
394         @Test
395         public void relateCollectionObjectToIntake() {
396                 //
397                 // First create a CollectionObject
398                 //
399                 CollectionobjectsCommon co = new CollectionobjectsCommon();
400                 fillCollectionObject(co, createIdentifier());
401                 
402                 // Next, create a part object
403                 PoxPayloadOut multipart = new PoxPayloadOut(CollectionObjectClient.SERVICE_PAYLOAD_NAME);
404                 PayloadOutputPart commonPart = multipart.addPart(co, MediaType.APPLICATION_XML_TYPE);
405                 commonPart.setLabel(collectionObjectClient.getCommonPartName());
406                 
407                 // Make the create call and check the response
408                 Response response = collectionObjectClient.create(multipart);
409                 String collectionObjectCsid = null;
410                 try {
411                         Assert.assertEquals(response.getStatus(), Response.Status.CREATED
412                                         .getStatusCode());
413                         collectionObjectCsid = extractId(response);
414                 } finally {
415                         response.close();
416                 }
417             
418             
419             // Next, create an Intake object
420             IntakesCommon intake = new IntakesCommon();
421             fillIntake(intake, createIdentifier());
422             // Create the a part object
423             multipart = new PoxPayloadOut(IntakeClient.SERVICE_PAYLOAD_NAME);
424             commonPart = multipart.addPart(intake, MediaType.APPLICATION_XML_TYPE);
425             commonPart.setLabel(intakeClient.getCommonPartName());
426
427             // Make the call to create and check the response
428             response = intakeClient.create(multipart);
429             String intakeCsid = null;
430             try {
431                     Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
432                     intakeCsid = extractId(response);
433             } finally {
434                 response.close();
435             }
436             
437             // Lastly, relate the two entities, by creating a new relation object
438             RelationsCommon relation = new RelationsCommon();
439             fillRelation(relation, collectionObjectCsid, CollectionobjectsCommon.class.getSimpleName(),
440                         intakeCsid, IntakesCommon.class.getSimpleName(),
441                         RelationshipType.COLLECTIONOBJECT_INTAKE.toString());
442             // Create the part and fill it with the relation object
443             multipart = new PoxPayloadOut(RelationClient.SERVICE_PAYLOAD_NAME);
444             commonPart = multipart.addPart(relation, MediaType.APPLICATION_XML_TYPE);
445             commonPart.setLabel(relationClient.getCommonPartName());
446
447             // Make the call to crate
448             response = relationClient.create(multipart);
449             String relationCsid = null;
450             try {
451                     Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
452                     relationCsid = extractId(response);
453             } finally {
454                 response.close();
455             }
456             
457             //
458             // Now try to retrieve the Intake record of the CollectionObject.
459             //
460             String predicate = RelationshipType.COLLECTIONOBJECT_INTAKE.toString();
461             ClientResponse<RelationsCommonList> resultResponse = relationClient.readList(
462                         collectionObjectCsid,
463                         null, //CollectionobjectsCommon.class.getSimpleName(),
464                         predicate,
465                         intakeCsid,
466                         null ); //IntakesCommon.class.getSimpleName());
467         RelationsCommonList relationList = null;
468             try {
469                 Assert.assertEquals(resultResponse.getStatus(), Response.Status.OK.getStatusCode());
470                 relationList = resultResponse.getEntity();
471             } finally {
472                 resultResponse.close();
473             }
474             
475             //
476             // Each relation returned in the list needs to match what we
477             // requested.
478             //
479         List<RelationsCommonList.RelationListItem> relationListItems = relationList.getRelationListItem();
480         Assert.assertFalse(relationListItems.isEmpty());
481         
482         int i = 0;
483         RelationsCommon resultRelation = null;
484         for(RelationsCommonList.RelationListItem listItem : relationListItems){
485                 
486                 String foundCsid = listItem.getCsid();
487                 Response multiPartResponse = null;
488                 try {
489                         multiPartResponse = relationClient.read(foundCsid);
490                         int responseStatus = multiPartResponse.getStatus();
491                         Assert.assertEquals(responseStatus, Response.Status.OK.getStatusCode());
492                         PoxPayloadIn input = new PoxPayloadIn((String)multiPartResponse.getEntity());
493                         resultRelation = (RelationsCommon) extractPart(input,
494                                         relationClient.getCommonPartName(),
495                                         RelationsCommon.class);
496                 } catch (Exception e) {
497                         e.printStackTrace();
498                 } finally {
499                         multiPartResponse.close();
500                 }
501                 
502                 Assert.assertEquals(resultRelation.getSubjectCsid(), collectionObjectCsid);
503                 Assert.assertEquals(resultRelation.getRelationshipType(), RelationshipType.COLLECTIONOBJECT_INTAKE.toString());
504                 Assert.assertEquals(resultRelation.getObjectCsid(), intakeCsid);
505             System.out.println();
506                 i++;            
507         }
508         }
509         
510         @Test
511         public void relateCollectionObjectsToIntake() {
512                 relateCollectionObjectsToIntake(OBJECTS_TO_INTAKE);
513         }
514
515         private void relateCollectionObjectsToIntake(int numberOfObjects) {
516                 
517                 //
518                 // First create a list of CollectionObjects
519                 //
520                 CollectionobjectsCommon co = new CollectionobjectsCommon();
521                 ArrayList<String>collectionObjectIDList = new ArrayList<String>(numberOfObjects);
522                 for (int i = 0; i < numberOfObjects; i++) {
523                         fillCollectionObject(co, createIdentifier());
524                         
525                         // Next, create a part object
526                         PoxPayloadOut multipart = new PoxPayloadOut(CollectionObjectClient.SERVICE_PAYLOAD_NAME);
527                         PayloadOutputPart commonPart = multipart.addPart(co, MediaType.APPLICATION_XML_TYPE);
528                         commonPart.setLabel(collectionObjectClient.getCommonPartName());
529                         
530                         // Make the create call and check the response
531                         Response response = collectionObjectClient.create(multipart);
532                         String collectionObjectCsid = null;
533                         try {
534                                 Assert.assertEquals(response.getStatus(), Response.Status.CREATED
535                                                 .getStatusCode());
536                                 collectionObjectCsid = extractId(response);
537                                 collectionObjectIDList.add(collectionObjectCsid);
538                         } finally {
539                                 response.close();
540                         }
541                 }
542             
543             
544             // Next, create an Intake object
545             IntakesCommon intake = new IntakesCommon();
546             fillIntake(intake, createIdentifier());
547             // Create the a part object
548             PoxPayloadOut multipart = new PoxPayloadOut(IntakeClient.SERVICE_PAYLOAD_NAME);
549             PayloadOutputPart commonPart = multipart.addPart(intake, MediaType.APPLICATION_XML_TYPE);
550             commonPart.setLabel(intakeClient.getCommonPartName());
551
552             // Make the call to create and check the response
553             Response response = intakeClient.create(multipart);
554             String intakeCsid = null;
555             try {
556                     Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
557                     intakeCsid = extractId(response);
558             } finally {
559                 response.close();
560             }
561             
562             // Lastly, relate the two entities, by creating a new relation object
563             RelationsCommon relation = new RelationsCommon();
564             for (String collectionObjectCsid : collectionObjectIDList) {
565                     fillRelation(relation,
566                                 intakeCsid, IntakesCommon.class.getSimpleName(), //subject
567                                 collectionObjectCsid, CollectionobjectsCommon.class.getSimpleName(), //object                           
568                                 RelationshipType.COLLECTIONOBJECT_INTAKE.toString()); //predicate
569                     // Create the part and fill it with the relation object
570                     multipart = new PoxPayloadOut(RelationClient.SERVICE_PAYLOAD_NAME);
571                     commonPart = multipart.addPart(relation, MediaType.APPLICATION_XML_TYPE);
572                     commonPart.setLabel(relationClient.getCommonPartName());
573         
574                     // Make the call to crate
575                     response = relationClient.create(multipart);
576                     String relationCsid = null;
577                     try {
578                             Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
579                             relationCsid = extractId(response);
580                     } finally {
581                         response.close();
582                     }
583             }
584             
585             //
586             // Now try to retrieve the Intake record of the CollectionObject.
587             //
588             String predicate = RelationshipType.COLLECTIONOBJECT_INTAKE.toString();
589                 RelationsCommonList relationList = null;
590             for (String collectionObjectCsid : collectionObjectIDList) {
591                     ClientResponse<RelationsCommonList> resultResponse = relationClient.readList(
592                                 intakeCsid,
593                                 null, //IntakesCommon.class.getSimpleName(), //subject
594                                 predicate,
595                                 collectionObjectCsid,
596                                 null); //CollectionobjectsCommon.class.getSimpleName()); //object
597
598                     try {
599                         Assert.assertEquals(resultResponse.getStatus(), Response.Status.OK.getStatusCode());
600                         relationList = resultResponse.getEntity();
601                     } finally {
602                         resultResponse.close();
603                     }
604             
605                     //
606                     // Each relation returned in the list needs to match what we
607                     // requested.
608                     //
609                 List<RelationsCommonList.RelationListItem> relationListItems = relationList.getRelationListItem();
610                 Assert.assertFalse(relationListItems.isEmpty());
611                 
612                 int i = 0;
613                 RelationsCommon resultRelation = null;
614                 for(RelationsCommonList.RelationListItem listItem : relationListItems){
615                         String foundCsid = listItem.getCsid();
616                         Response multiPartResponse = null;
617                         try {
618                                 multiPartResponse = relationClient.read(foundCsid);
619                                 int responseStatus = multiPartResponse.getStatus();
620                                 Assert.assertEquals(responseStatus, Response.Status.OK.getStatusCode());
621                                 PoxPayloadIn input = new PoxPayloadIn((String)multiPartResponse.getEntity());
622                                 resultRelation = (RelationsCommon) extractPart(input,
623                                                 relationClient.getCommonPartName(),
624                                                 RelationsCommon.class);
625                         } catch (Exception e) {
626                                 e.printStackTrace();
627                         } finally {
628                                 multiPartResponse.close();
629                         }
630         
631                         Assert.assertEquals(resultRelation.getSubjectCsid(), intakeCsid);
632                         Assert.assertEquals(resultRelation.getRelationshipType(), RelationshipType.COLLECTIONOBJECT_INTAKE.toString());
633                         Assert.assertEquals(resultRelation.getObjectCsid(), collectionObjectCsid);
634                         System.out.println();
635                         i++;            
636                 }
637             }
638         }
639         
640
641         /*
642          * Private Methods
643          */
644
645 }