]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
22eea86d83ebdd5b0022dc4812ddbe95582519ea
[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.collectionspace.services.client.CollectionObjectClient;
42 import org.collectionspace.services.client.DimensionClient;
43 import org.collectionspace.services.client.DimensionFactory;
44 import org.collectionspace.services.client.PayloadOutputPart;
45 import org.collectionspace.services.client.PoxPayloadIn;
46 import org.collectionspace.services.client.PoxPayloadOut;
47 import org.collectionspace.services.collectionobject.CollectionobjectsCommon;
48
49 import org.collectionspace.services.client.IntakeClient;
50 import org.collectionspace.services.intake.IntakesCommon;
51
52 import org.collectionspace.services.client.RelationClient;
53 import org.collectionspace.services.client.workflow.WorkflowClient;
54 import org.collectionspace.services.dimension.DimensionsCommon;
55 import org.collectionspace.services.relation.RelationsCommon;
56 import org.collectionspace.services.relation.RelationsCommonList;
57 import org.collectionspace.services.relation.RelationshipType;
58
59 /**
60  * A ServiceTest.
61  * 
62  * @version $Revision:$
63  */
64 public class RelationIntegrationTest extends CollectionSpaceIntegrationTest {
65
66         final Logger logger = LoggerFactory
67                         .getLogger(RelationIntegrationTest.class);
68         //
69         // Get clients for the CollectionSpace services
70         //
71         private CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
72         private RelationClient relationClient = new RelationClient();
73         private IntakeClient intakeClient = new IntakeClient();
74         private DimensionClient dimensionClient = new DimensionClient();
75         
76         private static final int OBJECTS_TO_INTAKE = 1;
77         
78         
79     /**
80      * Object as xml string.
81      *
82      * @param o the o
83      * @param clazz the clazz
84      * @return the string
85      */
86     static protected String objectAsXmlString(Object o, Class<?> clazz) {
87         StringWriter sw = new StringWriter();
88         try {
89             JAXBContext jc = JAXBContext.newInstance(clazz);
90             Marshaller m = jc.createMarshaller();
91             m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,
92                     Boolean.TRUE);
93             m.marshal(o, sw);
94         } catch (Exception e) {
95             e.printStackTrace();
96         }
97         return sw.toString();
98     }
99         
100     private PoxPayloadOut createDimensionInstance(String commonPartName, String dimensionType, String dimensionValue, String entryDate) {
101         DimensionsCommon dimensionsCommon = new DimensionsCommon();
102         dimensionsCommon.setDimension(dimensionType);
103         dimensionsCommon.setValue(new BigDecimal(dimensionValue));
104         dimensionsCommon.setValueDate(entryDate);
105         PoxPayloadOut multipart = DimensionFactory.createDimensionInstance(
106                 commonPartName, dimensionsCommon);
107
108         if (logger.isDebugEnabled()) {
109             logger.debug("to be created, dimension common");
110             logger.debug(objectAsXmlString(dimensionsCommon,
111                     DimensionsCommon.class));
112         }
113
114         return multipart;
115     }
116         
117     protected PoxPayloadOut createDimensionInstance(String identifier) {
118         DimensionClient client = new DimensionClient();
119         return createDimensionInstance(client.getCommonPartName(), identifier);
120     }
121     
122     /**
123      * Creates the dimension instance.
124      *
125      * @param identifier the identifier
126      * @return the multipart output
127      */
128     protected PoxPayloadOut createDimensionInstance(String commonPartName, String identifier) {
129         final String dimensionValue = Long.toString(System.currentTimeMillis());
130         
131         return createDimensionInstance(commonPartName, 
132                 "dimensionType-" + identifier,
133                 dimensionValue,
134                 "entryDate-" + identifier);
135     }
136     
137         @Test void deleteCollectionObjectRelationshipToLockedDimension() {
138                 // First create a CollectionObject
139                 CollectionobjectsCommon co = new CollectionobjectsCommon();
140                 fillCollectionObject(co, createIdentifier());           
141                 PoxPayloadOut multipart = new PoxPayloadOut(CollectionObjectClient.SERVICE_PAYLOAD_NAME);
142                 PayloadOutputPart commonPart = multipart.addPart(collectionObjectClient.getCommonPartName(), co);
143                 
144                 // Make the "create" call and check the response
145                 Response response = collectionObjectClient.create(multipart);
146                 String collectionObjectCsid = null;
147                 try {
148                         Assert.assertEquals(response.getStatus(), Response.Status.CREATED
149                                         .getStatusCode());
150                         collectionObjectCsid = extractId(response);
151                 } finally {
152                         response.close();
153                 }
154                 
155                 // Create a new dimension record
156             multipart = this.createDimensionInstance(createIdentifier());
157             // Make the call to create and check the response
158             response = dimensionClient.create(multipart);
159             String dimensionCsid1 = null;
160             try {
161                     Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
162                     dimensionCsid1 = extractId(response);
163             } finally {
164                 response.close();
165             }
166             
167             // Relate the entities, by creating a new relation object
168             RelationsCommon relation = new RelationsCommon();
169             fillRelation(relation, collectionObjectCsid, CollectionobjectsCommon.class.getSimpleName(),
170                         dimensionCsid1, DimensionsCommon.class.getSimpleName(),
171                         "collectionobject-dimension");
172             // Create the part and fill it with the relation object
173             multipart = new PoxPayloadOut(RelationClient.SERVICE_PAYLOAD_NAME);
174             commonPart = multipart.addPart(relationClient.getCommonPartName(), relation);
175             // Create the relationship
176             response = relationClient.create(multipart);
177             String relationCsid1 = null;
178             try {
179                     Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
180                     relationCsid1 = extractId(response);
181             } finally {
182                 response.close();
183             }       
184             
185             // Now lock the dimension record.
186             
187                 @SuppressWarnings("unused")
188                 Response workflowResponse = dimensionClient.updateWorkflowWithTransition(
189                                 dimensionCsid1, WorkflowClient.WORKFLOWTRANSITION_LOCK);
190             System.out.println("Locked dimension record with CSID=" + dimensionCsid1);
191             workflowResponse.close();
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             workflowResponse.close();
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             Response 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.readEntity(RelationsCommonList.class);
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(multiPartResponse.readEntity(String.class));
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                     Response 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.readEntity(RelationsCommonList.class);
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(multiPartResponse.readEntity(String.class));
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 }