]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
6e8c33e3be580f127ab0f074b063b3e504668db3
[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                 Response workflowResponse = dimensionClient.updateWorkflowWithTransition(
191                                 dimensionCsid1, WorkflowClient.WORKFLOWTRANSITION_LOCK);
192             System.out.println("Locked dimension record with CSID=" + dimensionCsid1);
193             
194             // Finally, try to delete the relationship
195             
196             // Try to delete the relationship -should fail because we don't allow delete if one of the sides is locked.
197             response = relationClient.delete(relationCsid1);
198             try {
199                     Assert.assertEquals(response.getStatus(), Response.Status.BAD_REQUEST.getStatusCode());
200             } finally {
201                 response.close();
202             }
203             
204             // Also, try to soft-delete.  This should also fail.
205                 workflowResponse = dimensionClient.updateWorkflowWithTransition(dimensionCsid1, WorkflowClient.WORKFLOWTRANSITION_DELETE);
206             System.out.println("Locked dimension record with CSID=" + dimensionCsid1);
207         }
208         
209         @Test void createCollectionObjectRelationshipToManyDimensions() {
210                 //
211                 // First create a CollectionObject
212                 //
213                 CollectionobjectsCommon co = new CollectionobjectsCommon();
214                 fillCollectionObject(co, createIdentifier());           
215                 PoxPayloadOut multipart = new PoxPayloadOut(CollectionObjectClient.SERVICE_PAYLOAD_NAME);
216                 PayloadOutputPart commonPart = multipart.addPart(collectionObjectClient.getCommonPartName(), co);
217                 
218                 // Make the create call and check the response
219                 Response response = collectionObjectClient.create(multipart);
220                 String collectionObjectCsid = null;
221                 try {
222                         Assert.assertEquals(response.getStatus(), Response.Status.CREATED
223                                         .getStatusCode());
224                         collectionObjectCsid = extractId(response);
225                 } finally {
226                         response.close();
227                 }
228                 
229                 //Next, create the first of three Dimension records to relate the collection object record
230             multipart = this.createDimensionInstance(createIdentifier());
231             // Make the call to create and check the response
232             response = dimensionClient.create(multipart);
233             String dimensionCsid1 = null;
234             try {
235                     Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
236                     dimensionCsid1 = extractId(response);
237             } finally {
238                 response.close();
239             }
240             
241                 //Next, create a the second Dimension record
242             multipart = this.createDimensionInstance(createIdentifier());
243             // Make the call to create and check the response
244             response = dimensionClient.create(multipart);
245             String dimensionCsid2 = null;
246             try {
247                     Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
248                     dimensionCsid2 = extractId(response);
249             } finally {
250                 response.close();
251             }
252             
253                 //Next, create a the 3rd Dimension record
254             multipart = this.createDimensionInstance(createIdentifier());
255             // Make the call to create and check the response
256             response = dimensionClient.create(multipart);
257             String dimensionCsid3 = null;
258             try {
259                     Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
260                     dimensionCsid3 = extractId(response);
261             } finally {
262                 response.close();
263             }
264             
265             // Relate the entities, by creating a new relation object
266             RelationsCommon relation = new RelationsCommon();
267             fillRelation(relation,
268                         collectionObjectCsid, CollectionobjectsCommon.class.getSimpleName(), // the subject of the relationship
269                         dimensionCsid1, DimensionsCommon.class.getSimpleName(), // the object of the relationship
270                         "collectionobject-dimension");
271             // Create the part and fill it with the relation object
272             multipart = new PoxPayloadOut(RelationClient.SERVICE_PAYLOAD_NAME);
273             commonPart = multipart.addPart(relationClient.getCommonPartName(), relation);
274             // Create the relationship
275             response = relationClient.create(multipart);
276             String relationCsid1 = null;
277             try {
278                     Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
279                     relationCsid1 = extractId(response);
280             } finally {
281                 response.close();
282             }
283             // Wait 1 second and create the second relationship
284             try {
285                         Thread.sleep(1001);
286                 } catch (InterruptedException e) {
287                         // TODO Auto-generated catch block
288                         e.printStackTrace();
289                 }
290             relation = new RelationsCommon();
291             fillRelation(relation,
292                         collectionObjectCsid, CollectionobjectsCommon.class.getSimpleName(), // the subject of the relationship
293                         dimensionCsid2, DimensionsCommon.class.getSimpleName(), // the object of the relationship
294                         "collectionobject-dimension");
295             // Create the part and fill it with the relation object
296             multipart = new PoxPayloadOut(RelationClient.SERVICE_PAYLOAD_NAME);
297             commonPart = multipart.addPart(relationClient.getCommonPartName(), relation);
298             // Create the relationship
299             response = relationClient.create(multipart);
300             @SuppressWarnings("unused")
301                 String relationCsid2 = null;
302             try {
303                     Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
304                     relationCsid2 = extractId(response);
305             } finally {
306                 response.close();
307             }
308             // Wait 1 second and create the 3rd relationship
309             try {
310                         Thread.sleep(1001);
311                 } catch (InterruptedException e) {
312                         // TODO Auto-generated catch block
313                         e.printStackTrace();
314                 }
315             relation = new RelationsCommon();
316             fillRelation(relation,
317                         collectionObjectCsid, CollectionobjectsCommon.class.getSimpleName(), // the subject of the relationship
318                         dimensionCsid3, DimensionsCommon.class.getSimpleName(), // the object of the relationship
319                         "collectionobject-dimension");
320             // Create the part and fill it with the relation object
321             multipart = new PoxPayloadOut(RelationClient.SERVICE_PAYLOAD_NAME);
322             commonPart = multipart.addPart(relationClient.getCommonPartName(), relation);
323             // Create the relationship
324             response = relationClient.create(multipart);
325             @SuppressWarnings("unused")
326                 String relationCsid3 = null;
327             try {
328                     Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
329                     relationCsid3 = extractId(response);
330             } finally {
331                 response.close();
332             }               
333         }    
334         
335         @Test void releteCollectionObjectToLockedDimension() {
336                 //
337                 // First create a CollectionObject
338                 //
339                 CollectionobjectsCommon co = new CollectionobjectsCommon();
340                 fillCollectionObject(co, createIdentifier());
341                 
342                 // Next, create a part object
343                 PoxPayloadOut multipart = new PoxPayloadOut(CollectionObjectClient.SERVICE_PAYLOAD_NAME);
344                 PayloadOutputPart commonPart = multipart.addPart(co, MediaType.APPLICATION_XML_TYPE);
345                 commonPart.setLabel(collectionObjectClient.getCommonPartName());
346                 
347                 // Make the create call and check the response
348                 Response response = collectionObjectClient.create(multipart);
349                 String collectionObjectCsid = null;
350                 try {
351                         Assert.assertEquals(response.getStatus(), Response.Status.CREATED
352                                         .getStatusCode());
353                         collectionObjectCsid = extractId(response);
354                 } finally {
355                         response.close();
356                 }
357                 
358                 //Next, create a Dimension record to relate the collection object to
359             multipart = this.createDimensionInstance(createIdentifier());
360             // Make the call to create and check the response
361             response = dimensionClient.create(multipart);
362             String dimensionCsid = null;
363             try {
364                     Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
365                     dimensionCsid = extractId(response);
366             } finally {
367                 response.close();
368             }
369             
370             @SuppressWarnings("unused")
371             Response workflowResponse = dimensionClient.updateWorkflowWithTransition(dimensionCsid, 
372                                 WorkflowClient.WORKFLOWTRANSITION_LOCK);
373             workflowResponse.close();
374             System.out.println("Locked dimension record with CSID=" + dimensionCsid);
375             
376             // Lastly, relate the two entities, by creating a new relation object
377             RelationsCommon relation = new RelationsCommon();
378             fillRelation(relation, collectionObjectCsid, CollectionobjectsCommon.class.getSimpleName(),
379                         dimensionCsid, DimensionsCommon.class.getSimpleName(),
380                         "collectionobject-dimension");
381             // Create the part and fill it with the relation object
382             multipart = new PoxPayloadOut(RelationClient.SERVICE_PAYLOAD_NAME);
383             commonPart = multipart.addPart(relation, MediaType.APPLICATION_XML_TYPE);
384             commonPart.setLabel(relationClient.getCommonPartName());
385
386             // Make the call to crate
387             Response relationresponse = relationClient.create(multipart);
388                 String relationCsid = null;
389             try {
390                     Assert.assertEquals(relationresponse.getStatus(), Response.Status.BAD_REQUEST.getStatusCode());
391                     relationCsid = extractId(response);
392             } finally {
393                 relationresponse.close();
394             }
395         }
396         
397         @Test
398         public void relateCollectionObjectToIntake() {
399                 //
400                 // First create a CollectionObject
401                 //
402                 CollectionobjectsCommon co = new CollectionobjectsCommon();
403                 fillCollectionObject(co, createIdentifier());
404                 
405                 // Next, create a part object
406                 PoxPayloadOut multipart = new PoxPayloadOut(CollectionObjectClient.SERVICE_PAYLOAD_NAME);
407                 PayloadOutputPart commonPart = multipart.addPart(co, MediaType.APPLICATION_XML_TYPE);
408                 commonPart.setLabel(collectionObjectClient.getCommonPartName());
409                 
410                 // Make the create call and check the response
411                 Response response = collectionObjectClient.create(multipart);
412                 String collectionObjectCsid = null;
413                 try {
414                         Assert.assertEquals(response.getStatus(), Response.Status.CREATED
415                                         .getStatusCode());
416                         collectionObjectCsid = extractId(response);
417                 } finally {
418                         response.close();
419                 }
420             
421             
422             // Next, create an Intake object
423             IntakesCommon intake = new IntakesCommon();
424             fillIntake(intake, createIdentifier());
425             // Create the a part object
426             multipart = new PoxPayloadOut(IntakeClient.SERVICE_PAYLOAD_NAME);
427             commonPart = multipart.addPart(intake, MediaType.APPLICATION_XML_TYPE);
428             commonPart.setLabel(intakeClient.getCommonPartName());
429
430             // Make the call to create and check the response
431             response = intakeClient.create(multipart);
432             String intakeCsid = null;
433             try {
434                     Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
435                     intakeCsid = extractId(response);
436             } finally {
437                 response.close();
438             }
439             
440             // Lastly, relate the two entities, by creating a new relation object
441             RelationsCommon relation = new RelationsCommon();
442             fillRelation(relation, collectionObjectCsid, CollectionobjectsCommon.class.getSimpleName(),
443                         intakeCsid, IntakesCommon.class.getSimpleName(),
444                         RelationshipType.COLLECTIONOBJECT_INTAKE.toString());
445             // Create the part and fill it with the relation object
446             multipart = new PoxPayloadOut(RelationClient.SERVICE_PAYLOAD_NAME);
447             commonPart = multipart.addPart(relation, MediaType.APPLICATION_XML_TYPE);
448             commonPart.setLabel(relationClient.getCommonPartName());
449
450             // Make the call to crate
451             response = relationClient.create(multipart);
452             String relationCsid = null;
453             try {
454                     Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
455                     relationCsid = extractId(response);
456             } finally {
457                 response.close();
458             }
459             
460             //
461             // Now try to retrieve the Intake record of the CollectionObject.
462             //
463             String predicate = RelationshipType.COLLECTIONOBJECT_INTAKE.toString();
464             ClientResponse<RelationsCommonList> resultResponse = relationClient.readList(
465                         collectionObjectCsid,
466                         null, //CollectionobjectsCommon.class.getSimpleName(),
467                         predicate,
468                         intakeCsid,
469                         null ); //IntakesCommon.class.getSimpleName());
470         RelationsCommonList relationList = null;
471             try {
472                 Assert.assertEquals(resultResponse.getStatus(), Response.Status.OK.getStatusCode());
473                 relationList = resultResponse.getEntity();
474             } finally {
475                 resultResponse.close();
476             }
477             
478             //
479             // Each relation returned in the list needs to match what we
480             // requested.
481             //
482         List<RelationsCommonList.RelationListItem> relationListItems = relationList.getRelationListItem();
483         Assert.assertFalse(relationListItems.isEmpty());
484         
485         int i = 0;
486         RelationsCommon resultRelation = null;
487         for(RelationsCommonList.RelationListItem listItem : relationListItems){
488                 
489                 String foundCsid = listItem.getCsid();
490                 Response multiPartResponse = null;
491                 try {
492                         multiPartResponse = relationClient.read(foundCsid);
493                         int responseStatus = multiPartResponse.getStatus();
494                         Assert.assertEquals(responseStatus, Response.Status.OK.getStatusCode());
495                         PoxPayloadIn input = new PoxPayloadIn((String)multiPartResponse.getEntity());
496                         resultRelation = (RelationsCommon) extractPart(input,
497                                         relationClient.getCommonPartName(),
498                                         RelationsCommon.class);
499                 } catch (Exception e) {
500                         e.printStackTrace();
501                 } finally {
502                         multiPartResponse.close();
503                 }
504                 
505                 Assert.assertEquals(resultRelation.getSubjectCsid(), collectionObjectCsid);
506                 Assert.assertEquals(resultRelation.getRelationshipType(), RelationshipType.COLLECTIONOBJECT_INTAKE.toString());
507                 Assert.assertEquals(resultRelation.getObjectCsid(), intakeCsid);
508             System.out.println();
509                 i++;            
510         }
511         }
512         
513         @Test
514         public void relateCollectionObjectsToIntake() {
515                 relateCollectionObjectsToIntake(OBJECTS_TO_INTAKE);
516         }
517
518         private void relateCollectionObjectsToIntake(int numberOfObjects) {
519                 
520                 //
521                 // First create a list of CollectionObjects
522                 //
523                 CollectionobjectsCommon co = new CollectionobjectsCommon();
524                 ArrayList<String>collectionObjectIDList = new ArrayList<String>(numberOfObjects);
525                 for (int i = 0; i < numberOfObjects; i++) {
526                         fillCollectionObject(co, createIdentifier());
527                         
528                         // Next, create a part object
529                         PoxPayloadOut multipart = new PoxPayloadOut(CollectionObjectClient.SERVICE_PAYLOAD_NAME);
530                         PayloadOutputPart commonPart = multipart.addPart(co, MediaType.APPLICATION_XML_TYPE);
531                         commonPart.setLabel(collectionObjectClient.getCommonPartName());
532                         
533                         // Make the create call and check the response
534                         Response response = collectionObjectClient.create(multipart);
535                         String collectionObjectCsid = null;
536                         try {
537                                 Assert.assertEquals(response.getStatus(), Response.Status.CREATED
538                                                 .getStatusCode());
539                                 collectionObjectCsid = extractId(response);
540                                 collectionObjectIDList.add(collectionObjectCsid);
541                         } finally {
542                                 response.close();
543                         }
544                 }
545             
546             
547             // Next, create an Intake object
548             IntakesCommon intake = new IntakesCommon();
549             fillIntake(intake, createIdentifier());
550             // Create the a part object
551             PoxPayloadOut multipart = new PoxPayloadOut(IntakeClient.SERVICE_PAYLOAD_NAME);
552             PayloadOutputPart commonPart = multipart.addPart(intake, MediaType.APPLICATION_XML_TYPE);
553             commonPart.setLabel(intakeClient.getCommonPartName());
554
555             // Make the call to create and check the response
556             Response response = intakeClient.create(multipart);
557             String intakeCsid = null;
558             try {
559                     Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
560                     intakeCsid = extractId(response);
561             } finally {
562                 response.close();
563             }
564             
565             // Lastly, relate the two entities, by creating a new relation object
566             RelationsCommon relation = new RelationsCommon();
567             for (String collectionObjectCsid : collectionObjectIDList) {
568                     fillRelation(relation,
569                                 intakeCsid, IntakesCommon.class.getSimpleName(), //subject
570                                 collectionObjectCsid, CollectionobjectsCommon.class.getSimpleName(), //object                           
571                                 RelationshipType.COLLECTIONOBJECT_INTAKE.toString()); //predicate
572                     // Create the part and fill it with the relation object
573                     multipart = new PoxPayloadOut(RelationClient.SERVICE_PAYLOAD_NAME);
574                     commonPart = multipart.addPart(relation, MediaType.APPLICATION_XML_TYPE);
575                     commonPart.setLabel(relationClient.getCommonPartName());
576         
577                     // Make the call to crate
578                     response = relationClient.create(multipart);
579                     String relationCsid = null;
580                     try {
581                             Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
582                             relationCsid = extractId(response);
583                     } finally {
584                         response.close();
585                     }
586             }
587             
588             //
589             // Now try to retrieve the Intake record of the CollectionObject.
590             //
591             String predicate = RelationshipType.COLLECTIONOBJECT_INTAKE.toString();
592                 RelationsCommonList relationList = null;
593             for (String collectionObjectCsid : collectionObjectIDList) {
594                     ClientResponse<RelationsCommonList> resultResponse = relationClient.readList(
595                                 intakeCsid,
596                                 null, //IntakesCommon.class.getSimpleName(), //subject
597                                 predicate,
598                                 collectionObjectCsid,
599                                 null); //CollectionobjectsCommon.class.getSimpleName()); //object
600
601                     try {
602                         Assert.assertEquals(resultResponse.getStatus(), Response.Status.OK.getStatusCode());
603                         relationList = resultResponse.getEntity();
604                     } finally {
605                         resultResponse.close();
606                     }
607             
608                     //
609                     // Each relation returned in the list needs to match what we
610                     // requested.
611                     //
612                 List<RelationsCommonList.RelationListItem> relationListItems = relationList.getRelationListItem();
613                 Assert.assertFalse(relationListItems.isEmpty());
614                 
615                 int i = 0;
616                 RelationsCommon resultRelation = null;
617                 for(RelationsCommonList.RelationListItem listItem : relationListItems){
618                         String foundCsid = listItem.getCsid();
619                         Response multiPartResponse = null;
620                         try {
621                                 multiPartResponse = relationClient.read(foundCsid);
622                                 int responseStatus = multiPartResponse.getStatus();
623                                 Assert.assertEquals(responseStatus, Response.Status.OK.getStatusCode());
624                                 PoxPayloadIn input = new PoxPayloadIn((String)multiPartResponse.getEntity());
625                                 resultRelation = (RelationsCommon) extractPart(input,
626                                                 relationClient.getCommonPartName(),
627                                                 RelationsCommon.class);
628                         } catch (Exception e) {
629                                 e.printStackTrace();
630                         } finally {
631                                 multiPartResponse.close();
632                         }
633         
634                         Assert.assertEquals(resultRelation.getSubjectCsid(), intakeCsid);
635                         Assert.assertEquals(resultRelation.getRelationshipType(), RelationshipType.COLLECTIONOBJECT_INTAKE.toString());
636                         Assert.assertEquals(resultRelation.getObjectCsid(), collectionObjectCsid);
637                         System.out.println();
638                         i++;            
639                 }
640             }
641         }
642         
643
644         /*
645          * Private Methods
646          */
647
648 }