]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
9bac78c9c60947d24d44d67db223ad3d267baae3
[tmp/jakarta-migration.git] /
1 /**
2  * This document is a part of the source code and related artifacts
3  * for CollectionSpace, an open source collections management system
4  * for museums and related institutions:
5  *
6  * http://www.collectionspace.org
7  * http://wiki.collectionspace.org
8  *
9  * Copyright © 2009 Regents of the University of California
10  *
11  * Licensed under the Educational Community License (ECL), Version 2.0.
12  * You may not use this file except in compliance with this License.
13  *
14  * You may obtain a copy of the ECL 2.0 License at
15  * https://source.collectionspace.org/collection-space/LICENSE.txt
16  *
17  * Unless required by applicable law or agreed to in writing, software
18  * distributed under the License is distributed on an "AS IS" BASIS,
19  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20  * See the License for the specific language governing permissions and
21  * limitations under the License.
22  */
23 package org.collectionspace.services.client.test;
24
25 import java.util.List;
26
27 import javax.ws.rs.core.MediaType;
28 import javax.ws.rs.core.Response;
29
30 import org.dom4j.Element;
31 import org.collectionspace.services.client.CollectionSpaceClient;
32 import org.collectionspace.services.client.IntakeClient;
33 import org.collectionspace.services.client.PayloadInputPart;
34 import org.collectionspace.services.client.PayloadOutputPart;
35 import org.collectionspace.services.client.PoxPayloadIn;
36 import org.collectionspace.services.client.PoxPayloadOut;
37 import org.collectionspace.services.common.api.GregorianCalendarDateTimeUtils;
38 import org.collectionspace.services.intake.EntryMethodList;
39 import org.collectionspace.services.intake.FieldCollectionEventNameList;
40 import org.collectionspace.services.intake.CurrentLocationGroup;
41 import org.collectionspace.services.intake.CurrentLocationGroupList;
42 import org.collectionspace.services.intake.IntakesCommon;
43 import org.collectionspace.services.jaxb.AbstractCommonList;
44 import org.testng.Assert;
45 import org.testng.annotations.Test;
46 import org.slf4j.Logger;
47 import org.slf4j.LoggerFactory;
48
49 // FIXME: http://issues.collectionspace.org/browse/CSPACE-1685
50 /**
51  * IntakeServiceTest, carries out tests against a
52  * deployed and running Intake Service.
53  *
54  * $LastChangedRevision$
55  * $LastChangedDate$
56  */
57 public class IntakeServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonList, IntakesCommon> {
58
59     /** The logger. */
60     private final String CLASS_NAME = IntakeServiceTest.class.getName();
61     private final Logger logger = LoggerFactory.getLogger(IntakeServiceTest.class);
62     private final static String CURRENT_DATE_UTC =
63             GregorianCalendarDateTimeUtils.currentDateUTC();
64
65     @Override
66     protected CollectionSpaceClient getClientInstance() throws Exception {
67         return new IntakeClient();
68     }
69
70         @Override
71         protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
72         return new IntakeClient(clientPropertiesFilename);
73         }
74
75     @Override
76     protected String getServiceName() {
77         return IntakeClient.SERVICE_NAME;
78     }
79
80     // ---------------------------------------------------------------
81     // CRUD tests : CREATE tests
82     // ---------------------------------------------------------------
83     
84     // See Issue CSPACE-401.
85     /* (non-Javadoc)
86      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
87      */
88     @Override
89     public void createWithEmptyEntityBody(String testName) throws Exception {
90         //Should this really be empty?
91     }
92
93     /* (non-Javadoc)
94      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
95      */
96     @Override
97     public void createWithMalformedXml(String testName) throws Exception {
98         //Should this really be empty?
99     }
100
101     /* (non-Javadoc)
102      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
103      */
104     @Override
105     public void createWithWrongXmlSchema(String testName) throws Exception {
106         //Should this really be empty?
107     }
108
109     /*
110     @Override
111     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
112     dependsOnMethods = {"create", "testSubmitRequest"})
113     public void createWithEmptyEntityBody(String testName) throws Exception {
114     
115     if (logger.isDebugEnabled()) {
116     logger.debug(testBanner(testName, CLASS_NAME));
117     }
118     // Perform setup.
119     setupCreateWithEmptyEntityBody();
120     
121     // Submit the request to the service and store the response.
122     String method = REQUEST_TYPE.httpMethodName();
123     String url = getServiceRootURL();
124     String mediaType = MediaType.APPLICATION_XML;
125     final String entity = "";
126     int statusCode = submitRequest(method, url, mediaType, entity);
127     
128     // Check the status code of the response: does it match
129     // the expected response(s)?
130     if(logger.isDebugEnabled()){
131     logger.debug("createWithEmptyEntityBody url=" + url +
132     " status=" + statusCode);
133     }
134     Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
135     invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
136     Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
137     }
138     
139     @Override
140     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
141     dependsOnMethods = {"create", "testSubmitRequest"})
142     public void createWithMalformedXml(String testName) throws Exception {
143     
144     if (logger.isDebugEnabled()) {
145     logger.debug(testBanner(testName, CLASS_NAME));
146     }
147     // Perform setup.
148     setupCreateWithMalformedXml();
149     
150     // Submit the request to the service and store the response.
151     String method = REQUEST_TYPE.httpMethodName();
152     String url = getServiceRootURL();
153     String mediaType = MediaType.APPLICATION_XML;
154     final String entity = MALFORMED_XML_DATA; // Constant from base class.
155     int statusCode = submitRequest(method, url, mediaType, entity);
156     
157     // Check the status code of the response: does it match
158     // the expected response(s)?
159     if(logger.isDebugEnabled()){
160     logger.debug(testName + ": url=" + url +
161     " status=" + statusCode);
162     }
163     Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
164     invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
165     Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
166     }
167     
168     @Override
169     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
170     dependsOnMethods = {"create", "testSubmitRequest"})
171     public void createWithWrongXmlSchema(String testName) throws Exception {
172     
173     if (logger.isDebugEnabled()) {
174     logger.debug(testBanner(testName, CLASS_NAME));
175     }
176     // Perform setup.
177     setupCreateWithWrongXmlSchema(testName, logger);
178     
179     // Submit the request to the service and store the response.
180     String method = REQUEST_TYPE.httpMethodName();
181     String url = getServiceRootURL();
182     String mediaType = MediaType.APPLICATION_XML;
183     final String entity = WRONG_XML_SCHEMA_DATA;
184     int statusCode = submitRequest(method, url, mediaType, entity);
185     
186     // Check the status code of the response: does it match
187     // the expected response(s)?
188     if(logger.isDebugEnabled()){
189     logger.debug(testName + ": url=" + url +
190     " status=" + statusCode);
191     }
192     Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
193     invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
194     Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
195     }
196      */
197     
198     // ---------------------------------------------------------------
199     // CRUD tests : READ tests
200     // ---------------------------------------------------------------
201     
202         protected void compareReadInstances(IntakesCommon original, IntakesCommon fromRead) throws Exception {
203         // Verify the number and contents of values in repeatable fields,
204         // as created in the instance record used for testing.
205         List<String> entryMethods =
206                         fromRead.getEntryMethods().getEntryMethod();
207         Assert.assertTrue(entryMethods.size() > 0);
208         Assert.assertNotNull(entryMethods.get(0));
209
210         List<String> fieldCollectionEventNames =
211                         fromRead.getFieldCollectionEventNames().getFieldCollectionEventName();
212         Assert.assertTrue(fieldCollectionEventNames.size() > 0);
213         Assert.assertNotNull(fieldCollectionEventNames.get(0));
214
215         CurrentLocationGroupList currentLocationGroupList = fromRead.getCurrentLocationGroupList();
216         Assert.assertNotNull(currentLocationGroupList);
217         List<CurrentLocationGroup> currentLocationGroups = currentLocationGroupList.getCurrentLocationGroup();
218         Assert.assertNotNull(currentLocationGroups);
219         Assert.assertTrue(currentLocationGroups.size() > 0);
220         CurrentLocationGroup currentLocationGroup = currentLocationGroups.get(0);
221         Assert.assertNotNull(currentLocationGroup);
222         Assert.assertNotNull(currentLocationGroup.getCurrentLocationNote());
223
224         // Check the values of fields containing Unicode UTF-8 (non-Latin-1) characters.
225         if (logger.isDebugEnabled()) {
226             logger.debug("UTF-8 data sent=" + getUTF8DataFragment() + "\n"
227                     + "UTF-8 data received=" + fromRead.getEntryNote());
228         }
229         Assert.assertEquals(fromRead.getEntryNote(), getUTF8DataFragment(),
230                 "UTF-8 data retrieved '" + fromRead.getEntryNote()
231                 + "' does not match expected data '" + getUTF8DataFragment());
232         }
233     
234     // Failure outcomes
235
236     @Override
237     public void delete(String testName) throws Exception {
238         // Do nothing because this test is not ready to delete the "knownResourceId".
239         // Instead, the method localDelete() will get called later in the dependency chain. The
240         // method localDelete() has a dependency on the test "verifyReadOnlyCoreFields".  Once the "verifyReadOnlyCoreFields"
241         // test is run, the localDelete() test/method will get run.  The localDelete() test/method in turn
242         // calls the inherited delete() test/method.
243     }
244     
245     @Test(dataProvider = "testName", dependsOnMethods = {"CRUDTests", "verifyReadOnlyCoreFields"})
246     public void localDelete(String testName) throws Exception {
247         // Because of issues with TestNG not allowing @Test annotations on on override methods,
248         // and because we want the "updateWrongUser" to run before the "delete" test, we need
249         // this method.  This method will call super.delete() after all the dependencies have been
250         // met.
251         super.delete(testName);
252     }
253
254     @Test(dataProvider = "testName", dependsOnMethods = {"CRUDTests"})
255     public void verifyReadOnlyCoreFields(String testName) throws Exception {
256         // TODO These should be in some core client utils
257         final String COLLECTIONSPACE_CORE_SCHEMA = "collectionspace_core";
258         final String COLLECTIONSPACE_CORE_TENANTID = "tenantId";
259         final String COLLECTIONSPACE_CORE_URI = "uri";
260         final String COLLECTIONSPACE_CORE_CREATED_AT = "createdAt";
261         final String COLLECTIONSPACE_CORE_UPDATED_AT = "updatedAt";
262         final String COLLECTIONSPACE_CORE_CREATED_BY = "createdBy";
263         final String COLLECTIONSPACE_CORE_UPDATED_BY = "updatedBy";
264
265         // Perform setup.
266         setupUpdate();
267
268         // Retrieve the contents of a resource to update.
269         IntakeClient client = new IntakeClient();
270         PoxPayloadIn input = null;
271         Response res = client.read(knownResourceId);
272         try {
273                 if (logger.isDebugEnabled()) {
274                     logger.debug(testName + ": read status = " + res.getStatus());
275                 }
276                 Assert.assertEquals(res.getStatus(), testExpectedStatusCode);
277         
278                 input = new PoxPayloadIn(res.readEntity(String.class));
279         } finally {
280                 res.close();
281         }
282         
283         PayloadInputPart payloadInputPart = input.getPart(COLLECTIONSPACE_CORE_SCHEMA);
284         Element coreAsElement = null;
285         if (payloadInputPart != null) {
286                 coreAsElement = payloadInputPart.getElementBody();
287         }
288         Assert.assertNotNull(coreAsElement);
289         if (logger.isDebugEnabled()) {
290             logger.debug("Core part before update:");
291             logger.debug(coreAsElement.asXML());
292         }
293
294         // Update the read-only elements
295         Element tenantId = coreAsElement.element(COLLECTIONSPACE_CORE_TENANTID);
296         String originalTenantId = tenantId.getText();
297         tenantId.setText("foo");
298         Element uri = coreAsElement.element(COLLECTIONSPACE_CORE_URI);
299         String originalUri = uri.getText();
300         uri.setText("foo");
301         Element createdAt = coreAsElement.element(COLLECTIONSPACE_CORE_CREATED_AT);
302         String originalCreatedAt = createdAt.getText();
303         String now = GregorianCalendarDateTimeUtils.timestampUTC();
304         if(originalCreatedAt.equalsIgnoreCase(now) && logger.isWarnEnabled()) {
305                         logger.warn("Cannot check createdAt read-only; too fast!");
306         }
307         createdAt.setText(now);
308         Element createdBy = coreAsElement.element(COLLECTIONSPACE_CORE_CREATED_BY);
309         String originalCreatedBy = createdBy.getText();
310         createdBy.setText("foo");
311         
312         if (logger.isDebugEnabled()) {
313             logger.debug("Core part to be updated:");
314             logger.debug(coreAsElement.asXML());
315         }
316
317         // Create an output payload to send to the service, and add the common part
318         PoxPayloadOut output = new PoxPayloadOut(this.getServicePathComponent());
319         PayloadOutputPart corePart = output.addPart(COLLECTIONSPACE_CORE_SCHEMA, coreAsElement);
320         
321         // Submit the request to the service and store the response.
322         res = client.update(knownResourceId, output);
323             try {
324                 int statusCode = res.getStatus();
325                 // Check the status code of the response: does it match the expected response(s)?
326                 if (logger.isDebugEnabled()) {
327                     logger.debug(testName + ": status = " + statusCode);
328                 }
329                 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
330                         invalidStatusCodeMessage(testRequestType, statusCode));
331                 Assert.assertEquals(statusCode, testExpectedStatusCode);
332         
333                 input = new PoxPayloadIn(res.readEntity(String.class));
334             } finally {
335                 res.close();
336             }
337                 
338         PayloadInputPart updatedCorePart = input.getPart(COLLECTIONSPACE_CORE_SCHEMA);
339         Element updatedCoreAsElement = null;
340         if (updatedCorePart != null) {
341                 updatedCoreAsElement = updatedCorePart.getElementBody();
342         }
343         Assert.assertNotNull(updatedCoreAsElement);
344         
345         tenantId = updatedCoreAsElement.element(COLLECTIONSPACE_CORE_TENANTID);
346         String updatedTenantId = tenantId.getText();
347         Assert.assertEquals(updatedTenantId, originalTenantId,
348                                 "CORE part TenantID was able to update!");
349         uri = updatedCoreAsElement.element(COLLECTIONSPACE_CORE_URI);
350         String updatedUri = uri.getText();
351         Assert.assertEquals(updatedUri, originalUri,
352                                 "CORE part URI was able to update!");
353         createdAt = updatedCoreAsElement.element(COLLECTIONSPACE_CORE_CREATED_AT);
354         String updatedCreatedAt = createdAt.getText();
355         Assert.assertEquals(updatedCreatedAt, originalCreatedAt,
356                                 "CORE part CreatedAt was able to update!");
357         createdBy = updatedCoreAsElement.element(COLLECTIONSPACE_CORE_CREATED_BY);
358         String updatedCreatedBy = createdBy.getText();
359         Assert.assertEquals(updatedCreatedBy, originalCreatedBy,
360                                 "CORE part CreatedBy was able to update!");
361
362     }
363
364     // Failure outcomes
365     // Placeholders until the three tests below can be uncommented.
366     
367     // See Issue CSPACE-401.
368     /* (non-Javadoc)
369      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
370      */
371     @Override
372     public void updateWithEmptyEntityBody(String testName) throws Exception {
373         //Should this really be empty?
374     }
375
376     /* (non-Javadoc)
377      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
378      */
379     @Override
380     public void updateWithMalformedXml(String testName) throws Exception {
381         //Should this really be empty?
382     }
383
384     /* (non-Javadoc)
385      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
386      */
387     @Override
388     public void updateWithWrongXmlSchema(String testName) throws Exception {
389         //Should this really be empty?
390     }
391
392     /*
393     @Override
394     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
395     dependsOnMethods = {"create", "update", "testSubmitRequest"})
396     public void updateWithEmptyEntityBody(String testName) throws Exception {
397     
398     if (logger.isDebugEnabled()) {
399     logger.debug(testBanner(testName, CLASS_NAME));
400     }
401     // Perform setup.
402     setupUpdateWithEmptyEntityBody();
403     
404     // Submit the request to the service and store the response.
405     String method = REQUEST_TYPE.httpMethodName();
406     String url = getResourceURL(knownResourceId);
407     String mediaType = MediaType.APPLICATION_XML;
408     final String entity = "";
409     int statusCode = submitRequest(method, url, mediaType, entity);
410     
411     // Check the status code of the response: does it match
412     // the expected response(s)?
413     if(logger.isDebugEnabled()){
414     logger.debug(testName + ": url=" + url +
415     " status=" + statusCode);
416     }
417     Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
418     invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
419     Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
420     }
421     
422     @Override
423     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
424     dependsOnMethods = {"create", "update", "testSubmitRequest"})
425     public void updateWithMalformedXml(String testName) throws Exception {
426     
427     if (logger.isDebugEnabled()) {
428     logger.debug(testBanner(testName, CLASS_NAME));
429     }
430     // Perform setup.
431     setupUpdateWithMalformedXml();
432     
433     // Submit the request to the service and store the response.
434     String method = REQUEST_TYPE.httpMethodName();
435     String url = getResourceURL(knownResourceId);
436     String mediaType = MediaType.APPLICATION_XML;
437     final String entity = MALFORMED_XML_DATA;
438     int statusCode = submitRequest(method, url, mediaType, entity);
439     
440     // Check the status code of the response: does it match
441     // the expected response(s)?
442     if(logger.isDebugEnabled()){
443     logger.debug(testName + ": url=" + url +
444     " status=" + statusCode);
445     }
446     Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
447     invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
448     Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
449     }
450     
451     @Override
452     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
453     dependsOnMethods = {"create", "update", "testSubmitRequest"})
454     public void updateWithWrongXmlSchema(String testName) throws Exception {
455     
456     if (logger.isDebugEnabled()) {
457     logger.debug(testBanner(testName, CLASS_NAME));
458     }
459     // Perform setup.
460     setupUpdateWithWrongXmlSchema();
461     
462     // Submit the request to the service and store the response.
463     String method = REQUEST_TYPE.httpMethodName();
464     String url = getResourceURL(knownResourceId);
465     String mediaType = MediaType.APPLICATION_XML;
466     final String entity = WRONG_XML_SCHEMA_DATA;
467     int statusCode = submitRequest(method, url, mediaType, entity);
468     
469     // Check the status code of the response: does it match
470     // the expected response(s)?
471     if(logger.isDebugEnabled()){
472     logger.debug(testName + ": url=" + url +
473     " status=" + statusCode);
474     }
475     Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
476     invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
477     Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
478     }
479      */
480
481     // ---------------------------------------------------------------
482     // Utility tests : tests of code used in tests above
483     // ---------------------------------------------------------------
484     
485     /* (non-Javadoc)
486      * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
487      */
488     @Override
489     public String getServicePathComponent() {
490         return IntakeClient.SERVICE_PATH_COMPONENT;
491     }
492
493     /**
494      * Creates the intake instance.
495      *
496      * @param identifier the identifier
497      * @return the multipart output
498      * @throws Exception 
499      */
500     @Override
501     protected PoxPayloadOut createInstance(String identifier) throws Exception {
502         return createIntakeInstance(
503                 "entryNumber-" + identifier,
504                 CURRENT_DATE_UTC,
505                 "depositor-" + identifier);
506     }
507
508     /**
509      * Creates the intake instance.
510      *
511      * @param entryNumber the entry number
512      * @param entryDate the entry date
513      * @param depositor the depositor
514      * @return the multipart output
515      * @throws Exception 
516      */
517     private PoxPayloadOut createIntakeInstance(String entryNumber,
518             String entryDate,
519             String depositor) throws Exception {
520         IntakesCommon intake = new IntakesCommon();
521         intake.setEntryNumber(entryNumber);
522         intake.setEntryDate(entryDate);
523         intake.setDepositor(depositor);
524
525         EntryMethodList entryMethodsList = new EntryMethodList();
526         List<String> entryMethods = entryMethodsList.getEntryMethod();
527         entryMethods.add("Left at doorstep");
528         entryMethods.add("Received via post");
529         intake.setEntryMethods(entryMethodsList);
530
531         FieldCollectionEventNameList eventNamesList = new FieldCollectionEventNameList();
532         List<String> eventNames = eventNamesList.getFieldCollectionEventName();
533         // FIXME Use properly formatted refNames for representative event names
534         // in this example test record. The following are mere placeholders.
535         eventNames.add("Field Collection Event Name-1");
536         eventNames.add("Field Collection Event Name-2");
537         intake.setFieldCollectionEventNames(eventNamesList);
538
539         CurrentLocationGroupList currentLocationGroupList = new CurrentLocationGroupList();
540         List<CurrentLocationGroup> currentLocationGroups = currentLocationGroupList.getCurrentLocationGroup();
541         CurrentLocationGroup currentLocationGroup = new CurrentLocationGroup();
542         currentLocationGroup.setCurrentLocation("upstairs");
543         currentLocationGroup.setCurrentLocationFitness("suitable");
544         currentLocationGroup.setCurrentLocationNote("A most suitable location.");
545         currentLocationGroups.add(currentLocationGroup);
546         intake.setCurrentLocationGroupList(currentLocationGroupList);
547
548         intake.setEntryNote(getUTF8DataFragment());
549
550         PoxPayloadOut multipart = new PoxPayloadOut(IntakeClient.SERVICE_PAYLOAD_NAME);
551         PayloadOutputPart commonPart =
552                 multipart.addPart(intake, MediaType.APPLICATION_XML_TYPE);
553         commonPart.setLabel(new IntakeClient().getCommonPartName());
554
555         if (logger.isDebugEnabled()) {
556             logger.debug("to be created, intake common");
557             logger.debug(objectAsXmlString(intake, IntakesCommon.class));
558         }
559
560         return multipart;
561     }
562
563         @Override
564         protected PoxPayloadOut createInstance(String commonPartName,
565                         String identifier) throws Exception {
566                 return this.createInstance(identifier);
567         }
568
569         @Override
570         protected IntakesCommon updateInstance(IntakesCommon intakesCommon) {
571                 IntakesCommon result = new IntakesCommon();
572                 
573                 result.setEntryNumber("updated-" + intakesCommon.getEntryNumber());
574                 result.setEntryNote(intakesCommon.getEntryNote());
575
576         CurrentLocationGroupList currentLocationGroupList = intakesCommon.getCurrentLocationGroupList();
577         Assert.assertNotNull(currentLocationGroupList);
578         List<CurrentLocationGroup> currentLocationGroups = currentLocationGroupList.getCurrentLocationGroup();
579         Assert.assertNotNull(currentLocationGroups);
580         Assert.assertTrue(currentLocationGroups.size() > 0);
581         CurrentLocationGroup currentLocationGroup = currentLocationGroups.get(0);
582         Assert.assertNotNull(currentLocationGroup);
583         String currentLocationNote = currentLocationGroup.getCurrentLocationNote();
584         Assert.assertNotNull(currentLocationNote);
585         String updatedCurrentLocationNote = "updated-" + currentLocationNote;
586         currentLocationGroups.get(0).setCurrentLocationNote(updatedCurrentLocationNote);
587         result.setCurrentLocationGroupList(currentLocationGroupList);
588         
589         return result;
590         }
591
592         @Override
593         protected void compareUpdatedInstances(IntakesCommon original,
594                         IntakesCommon updated) throws Exception {
595         Assert.assertEquals(updated.getEntryNumber(),
596                         original.getEntryNumber(),
597                 "Data in updated object did not match submitted data.");
598         
599         CurrentLocationGroupList currentLocationGroupList = updated.getCurrentLocationGroupList();
600         Assert.assertNotNull(currentLocationGroupList);
601         List<CurrentLocationGroup> currentLocationGroups = currentLocationGroupList.getCurrentLocationGroup();
602         Assert.assertNotNull(currentLocationGroups);
603         Assert.assertTrue(currentLocationGroups.size() > 0);
604         Assert.assertNotNull(currentLocationGroups.get(0));
605         
606         String updatedCurrentLocationNote = original.getCurrentLocationGroupList()
607                         .getCurrentLocationGroup().get(0).getCurrentLocationNote();
608         Assert.assertEquals(updatedCurrentLocationNote,
609                 currentLocationGroups.get(0).getCurrentLocationNote(),
610                 "Data in updated object did not match submitted data.");
611         
612         Assert.assertEquals(updated.getEntryNote(), original.getEntryNote(),
613                 "Data in updated object did not match submitted data.");
614         //
615         // UTF-8 Checks
616         //
617         if (logger.isDebugEnabled()) {
618             logger.debug("UTF-8 data sent=" + original.getEntryNote() + "\n"
619                     + "UTF-8 data received=" + updated.getEntryNote());
620         }
621         Assert.assertTrue(updated.getEntryNote().contains(getUTF8DataFragment()),
622                 "UTF-8 data retrieved '" + updated.getEntryNote()
623                 + "' does not contain expected data '" + getUTF8DataFragment());        
624         }
625
626     /*
627      * For convenience and terseness, this test method is the base of the test execution dependency chain.  Other test methods may
628      * refer to this method in their @Test annotation declarations.
629      */
630     @Override
631     @Test(dataProvider = "testName",
632                 dependsOnMethods = {
633                         "org.collectionspace.services.client.test.AbstractServiceTestImpl.baseCRUDTests"})    
634         public void CRUDTests(String testName) {
635                 // TODO Auto-generated method stub              
636         }
637 }