]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
81ce30976a1d7be5909ef78e9b17067f3c148300
[tmp/jakarta-migration.git] /
1 /**
2  * This document is a part of the source code and related artifacts
3  * for CollectionSpace, an open source collections management system
4  * for museums and related institutions:
5  *
6  * http://www.collectionspace.org
7  * http://wiki.collectionspace.org
8  *
9  * Copyright © 2009 Regents of the University of California
10  *
11  * Licensed under the Educational Community License (ECL), Version 2.0.
12  * You may not use this file except in compliance with this License.
13  *
14  * You may obtain a copy of the ECL 2.0 License at
15  * https://source.collectionspace.org/collection-space/LICENSE.txt
16  *
17  * Unless required by applicable law or agreed to in writing, software
18  * distributed under the License is distributed on an "AS IS" BASIS,
19  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20  * See the License for the specific language governing permissions and
21  * limitations under the License.
22  */
23 package org.collectionspace.services.client.test;
24
25 //import java.util.ArrayList;
26 import java.util.List;
27
28 import javax.ws.rs.core.Response;
29
30 import org.collectionspace.services.client.AbstractCommonListUtils;
31 import org.collectionspace.services.client.CollectionSpaceClient;
32 import org.collectionspace.services.client.ConditioncheckClient;
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.jaxb.AbstractCommonList;
39 import org.collectionspace.services.conditioncheck.ConditionchecksCommon;
40 import org.collectionspace.services.conditioncheck.HazardGroupList;
41 import org.collectionspace.services.conditioncheck.HazardGroup;
42
43 import org.testng.Assert;
44 import org.slf4j.Logger;
45 import org.slf4j.LoggerFactory;
46
47 /**
48  * ConditioncheckServiceTest, carries out tests against a
49  * deployed and running Conditioncheck (aka Condition Checks) Service.
50  */
51 public class ConditioncheckServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonList, ConditionchecksCommon> {
52
53     /** The logger. */
54     private final String CLASS_NAME = ConditioncheckServiceTest.class.getName();
55     private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
56     // Instance variables specific to this test.
57     /** The service path component. */
58     final String SERVICE_NAME = "conditionchecks";
59     final String SERVICE_PATH_COMPONENT = "conditionchecks";
60     private String CONDITIONCHECKER_REF_NAME =
61             "urn:cspace:org.collectionspace.demo:personauthorities:name(TestPersonAuth):item:name(HarryLender)'Harry Lender'";
62     private String CONDITIONCHECK_HAZARD = 
63             "urn:cspace:core.collectionspace.org:vocabularies:name(TestTermList):item:name(hazard1)'multi-dimensional'";
64     private String CONDITIONCHECK_HAZARD_NOTE = "Object needs to be extinguished occasionally.";
65     private final static String CURRENT_DATE_UTC =
66             GregorianCalendarDateTimeUtils.timestampUTC();
67
68     /* (non-Javadoc)
69      * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
70      */
71     @Override
72     protected CollectionSpaceClient getClientInstance() {
73         return new ConditioncheckClient();
74     }
75
76         @Override
77         protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
78         return new ConditioncheckClient(clientPropertiesFilename);
79         }
80
81     /* (non-Javadoc)
82      * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
83      */
84     @Override
85     protected AbstractCommonList getCommonList(Response response) {
86         return response.readEntity(AbstractCommonList.class);
87     }
88
89     // ---------------------------------------------------------------
90     // CRUD tests : CREATE tests
91     // ---------------------------------------------------------------
92     
93     // Success outcomes
94     
95     /* (non-Javadoc)
96      * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
97      */
98     @Override
99 //    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
100     public void create(String testName) throws Exception {
101         // Perform setup, such as initializing the type of service request
102         // (e.g. CREATE, DELETE), its valid and expected status codes, and
103         // its associated HTTP method name (e.g. POST, DELETE).
104         setupCreate();
105
106         // Submit the request to the service and store the response.
107         ConditioncheckClient client = new ConditioncheckClient();
108         String identifier = createIdentifier();
109         PoxPayloadOut multipart = createConditioncheckInstance(identifier);
110         String newID = null;
111         Response res = client.create(multipart);
112         try {
113             int statusCode = res.getStatus();
114
115             // Check the status code of the response: does it match
116             // the expected response(s)?
117             //
118             // Specifically:
119             // Does it fall within the set of valid status codes?
120             // Does it exactly match the expected status code?
121             if (logger.isDebugEnabled()) {
122                 logger.debug(testName + ": status = " + statusCode);
123             }
124             Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
125                     invalidStatusCodeMessage(testRequestType, statusCode));
126             Assert.assertEquals(statusCode, testExpectedStatusCode);
127
128             newID = extractId(res);
129         } finally {
130             if (res != null) {
131                 res.close();
132             }
133         }
134
135         // Store the ID returned from the first resource created
136         // for additional tests below.
137         if (knownResourceId == null) {
138             knownResourceId = newID;
139             if (logger.isDebugEnabled()) {
140                 logger.debug(testName + ": knownResourceId=" + knownResourceId);
141             }
142         }
143
144         // Store the IDs from every resource created by tests,
145         // so they can be deleted after tests have been run.
146         allResourceIdsCreated.add(newID);
147     }
148
149     /* (non-Javadoc)
150      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
151      */
152     @Override
153 //    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
154 //    dependsOnMethods = {"create"})
155     public void createList(String testName) throws Exception {
156         for (int i = 0; i < 3; i++) {
157             create(testName);
158         }
159     }
160
161
162     /*
163     @Override
164     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
165     dependsOnMethods = {"create", "testSubmitRequest"})
166     public void createWithEmptyEntityBody(String testName) throws Exception {
167     
168     if (logger.isDebugEnabled()) {
169     logger.debug(testBanner(testName, CLASS_NAME));
170     }
171     // Perform setup.
172     setupCreateWithEmptyEntityBody();
173     
174     // Submit the request to the service and store the response.
175     String method = REQUEST_TYPE.httpMethodName();
176     String url = getServiceRootURL();
177     String mediaType = MediaType.APPLICATION_XML;
178     final String entity = "";
179     int statusCode = submitRequest(method, url, mediaType, entity);
180     
181     // Check the status code of the response: does it match
182     // the expected response(s)?
183     if(logger.isDebugEnabled()){
184     logger.debug("createWithEmptyEntityBody url=" + url +
185     " status=" + statusCode);
186     }
187     Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
188     invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
189     Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
190     }
191     
192     @Override
193     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
194     dependsOnMethods = {"create", "testSubmitRequest"})
195     public void createWithMalformedXml(String testName) throws Exception {
196     
197     if (logger.isDebugEnabled()) {
198     logger.debug(testBanner(testName, CLASS_NAME));
199     }
200     // Perform setup.
201     setupCreateWithMalformedXml(testName, logger);
202     
203     // Submit the request to the service and store the response.
204     String method = REQUEST_TYPE.httpMethodName();
205     String url = getServiceRootURL();
206     String mediaType = MediaType.APPLICATION_XML;
207     final String entity = MALFORMED_XML_DATA; // Constant from base class.
208     int statusCode = submitRequest(method, url, mediaType, entity);
209     
210     // Check the status code of the response: does it match
211     // the expected response(s)?
212     if(logger.isDebugEnabled()){
213     logger.debug(testName + ": url=" + url +
214     " status=" + statusCode);
215     }
216     Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
217     invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
218     Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
219     }
220     
221     @Override
222     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
223     dependsOnMethods = {"create", "testSubmitRequest"})
224     public void createWithWrongXmlSchema(String testName) throws Exception {
225     
226     if (logger.isDebugEnabled()) {
227     logger.debug(testBanner(testName, CLASS_NAME));
228     }
229     // Perform setup.
230     setupCreateWithWrongXmlSchema(testName, logger);
231     
232     // Submit the request to the service and store the response.
233     String method = REQUEST_TYPE.httpMethodName();
234     String url = getServiceRootURL();
235     String mediaType = MediaType.APPLICATION_XML;
236     final String entity = WRONG_XML_SCHEMA_DATA;
237     int statusCode = submitRequest(method, url, mediaType, entity);
238     
239     // Check the status code of the response: does it match
240     // the expected response(s)?
241     if(logger.isDebugEnabled()){
242     logger.debug(testName + ": url=" + url +
243     " status=" + statusCode);
244     }
245     Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
246     invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
247     Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
248     }
249      */
250     
251     // ---------------------------------------------------------------
252     // CRUD tests : READ tests
253     // ---------------------------------------------------------------
254     
255     // Success outcomes
256     
257     /* (non-Javadoc)
258      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
259      */
260     @Override
261 //    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
262 //    dependsOnMethods = {"create"})
263     public void read(String testName) throws Exception {
264         // Perform setup.
265         setupRead();
266
267         // Submit the request to the service and store the response.
268         ConditioncheckClient client = new ConditioncheckClient();
269         Response res = client.read(knownResourceId);
270         PoxPayloadIn input = null;
271         try {
272             assertStatusCode(res, testName);
273             input = new PoxPayloadIn(res.readEntity(String.class));
274         } finally {
275             if (res != null) {
276                 res.close();
277             }
278         }
279
280         // Get the common part of the response and verify that it is not null.
281         PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName());
282         ConditionchecksCommon conditioncheckCommon = null;
283         if (payloadInputPart != null) {
284             conditioncheckCommon = (ConditionchecksCommon) payloadInputPart.getBody();
285         }
286         Assert.assertNotNull(conditioncheckCommon);
287
288         // Check selected fields.
289         HazardGroupList hazardGroupList = conditioncheckCommon.getHazardGroupList();
290         Assert.assertNotNull(hazardGroupList);
291         List<HazardGroup> hazardGroups = hazardGroupList.getHazardGroup();
292         Assert.assertNotNull(hazardGroups);
293         String hazard = hazardGroups.get(0).getHazard();
294         Assert.assertEquals(hazard, CONDITIONCHECK_HAZARD);
295         String hazardNote = hazardGroups.get(0).getHazardNote();
296         Assert.assertEquals(hazardNote, CONDITIONCHECK_HAZARD_NOTE);
297         String hazardDate = hazardGroups.get(0).getHazardDate();
298         Assert.assertEquals(hazardDate, CURRENT_DATE_UTC);
299         String conditionChecker = conditioncheckCommon.getConditionChecker();
300         Assert.assertEquals(conditionChecker, CONDITIONCHECKER_REF_NAME);
301
302         // Check the values of fields containing Unicode UTF-8 (non-Latin-1) characters.
303         String conditionCheckNote = conditioncheckCommon.getConditionCheckNote();
304
305         if (logger.isDebugEnabled()) {
306             logger.debug("UTF-8 data sent=" + getUTF8DataFragment() + "\n"
307                     + "UTF-8 data received=" + conditionCheckNote);
308         }
309
310         Assert.assertEquals(conditionCheckNote, getUTF8DataFragment(),
311                 "UTF-8 data retrieved '" + conditionCheckNote
312                 + "' does not match expected data '" + getUTF8DataFragment());
313     }
314
315     // Failure outcomes
316     
317     /* (non-Javadoc)
318      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
319      */
320     @Override
321 //    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
322 //    dependsOnMethods = {"read"})
323     public void readNonExistent(String testName) throws Exception {
324         // Perform setup.
325         setupReadNonExistent();
326
327         // Submit the request to the service and store the response.
328         ConditioncheckClient client = new ConditioncheckClient();
329         Response res = client.read(NON_EXISTENT_ID);
330         try {
331             int statusCode = res.getStatus();
332
333             // Check the status code of the response: does it match
334             // the expected response(s)?
335             if (logger.isDebugEnabled()) {
336                 logger.debug(testName + ": status = " + statusCode);
337             }
338             Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
339                     invalidStatusCodeMessage(testRequestType, statusCode));
340             Assert.assertEquals(statusCode, testExpectedStatusCode);
341         } finally {
342             if (res != null) {
343                 res.close();
344             }
345         }
346     }
347
348     // ---------------------------------------------------------------
349     // CRUD tests : READ_LIST tests
350     // ---------------------------------------------------------------
351     
352     // Success outcomes
353     
354     /* (non-Javadoc)
355      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
356      */
357     @Override
358 //    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
359 //    dependsOnMethods = {"createList", "read"})
360     public void readList(String testName) throws Exception {
361         // Perform setup.
362         setupReadList();
363
364         // Submit the request to the service and store the response.
365         AbstractCommonList list = null;
366         ConditioncheckClient client = new ConditioncheckClient();
367         Response res = client.readList();
368         assertStatusCode(res, testName);
369         try {
370             int statusCode = res.getStatus();
371
372             // Check the status code of the response: does it match
373             // the expected response(s)?
374             if (logger.isDebugEnabled()) {
375                 logger.debug(testName + ": status = " + statusCode);
376             }
377             Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
378                     invalidStatusCodeMessage(testRequestType, statusCode));
379             Assert.assertEquals(statusCode, testExpectedStatusCode);
380
381             list = res.readEntity(getCommonListType());
382         } finally {
383             if (res != null) {
384                 res.close();
385             }
386         }
387
388         // Optionally output additional data about list members for debugging.
389         boolean iterateThroughList = true;
390         if(iterateThroughList && logger.isDebugEnabled()){
391             AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
392         }
393
394     }
395
396     // Failure outcomes
397     // None at present.
398     
399     // ---------------------------------------------------------------
400     // CRUD tests : UPDATE tests
401     // ---------------------------------------------------------------
402     
403     // Success outcomes
404     
405     /* (non-Javadoc)
406      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
407      */
408     @Override
409 //    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
410 //    dependsOnMethods = {"read"})
411     public void update(String testName) throws Exception {
412         // Perform setup.
413         setupRead();
414
415         // Retrieve the contents of a resource to update.
416         ConditioncheckClient client = new ConditioncheckClient();
417         Response res = client.read(knownResourceId);
418         PoxPayloadIn input = null;
419         try {
420             assertStatusCode(res, testName);
421             input = new PoxPayloadIn(res.readEntity(String.class));
422             if (logger.isDebugEnabled()) {
423                 logger.debug("got object to update with ID: " + knownResourceId);
424             }
425         } finally {
426             if (res != null) {
427                 res.close();
428             }
429         }
430
431         // Extract the common part from the response.
432         PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName());
433         ConditionchecksCommon conditioncheckCommon = null;
434         if (payloadInputPart != null) {
435             conditioncheckCommon = (ConditionchecksCommon) payloadInputPart.getBody();
436         }
437         Assert.assertNotNull(conditioncheckCommon);
438
439         // Update the content of this resource.
440         conditioncheckCommon.setConditionCheckRefNumber("updated-" + conditioncheckCommon.getConditionCheckRefNumber());
441
442         String conditionCheckNote = conditioncheckCommon.getConditionCheckNote();
443         conditioncheckCommon.setConditionCheckNote("updated-conditionCheckNote-" + conditionCheckNote);
444
445         if (logger.isDebugEnabled()) {
446             logger.debug("to be updated object");
447             logger.debug(objectAsXmlString(conditioncheckCommon, ConditionchecksCommon.class));
448         }
449
450         setupUpdate();
451         
452         // Submit the updated common part in an update request to the service
453         // and store the response.
454         PoxPayloadOut output = new PoxPayloadOut(this.getServicePathComponent());
455         PayloadOutputPart commonPart = output.addPart(client.getCommonPartName(), conditioncheckCommon);
456         res = client.update(knownResourceId, output);
457         try {
458             assertStatusCode(res, testName);
459             int statusCode = res.getStatus();
460             // Check the status code of the response: does it match the expected response(s)?
461             if (logger.isDebugEnabled()) {
462                 logger.debug(testName + ": status = " + statusCode);
463             }
464             Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
465                     invalidStatusCodeMessage(testRequestType, statusCode));
466             Assert.assertEquals(statusCode, testExpectedStatusCode);
467             input = new PoxPayloadIn(res.readEntity(String.class));
468         } finally {
469             if (res != null) {
470                 res.close();
471             }
472         }
473
474         // Extract the updated common part from the response.
475         payloadInputPart = input.getPart(client.getCommonPartName());
476         ConditionchecksCommon updatedConditioncheckCommon = null;
477         if (payloadInputPart != null) {
478             updatedConditioncheckCommon = (ConditionchecksCommon) payloadInputPart.getBody();
479         }
480         Assert.assertNotNull(updatedConditioncheckCommon);
481
482         // Check selected fields in the updated common part.
483         Assert.assertEquals(updatedConditioncheckCommon.getConditionCheckRefNumber(),
484                 conditioncheckCommon.getConditionCheckRefNumber(),
485                 "Data in updated object did not match submitted data.");
486
487         // Check the values of fields containing Unicode UTF-8 (non-Latin-1) characters.
488         String originalConditionCheckNote = conditioncheckCommon.getConditionCheckNote();
489         String updatedConditionCheckNote = updatedConditioncheckCommon.getConditionCheckNote();
490         
491         Assert.assertEquals(updatedConditionCheckNote, originalConditionCheckNote,
492                 "Data in updated object did not match submitted data.");
493
494         if(logger.isDebugEnabled()){
495             logger.debug("UTF-8 data sent=" + originalConditionCheckNote + "\n"
496                     + "UTF-8 data received=" + updatedConditionCheckNote);
497         }
498         Assert.assertTrue(updatedConditionCheckNote.contains(getUTF8DataFragment()),
499                 "UTF-8 data retrieved '" + updatedConditionCheckNote
500                 + "' does not match expected data '" + getUTF8DataFragment());
501     }
502
503     @Override
504 //    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
505 //    dependsOnMethods = {"update", "testSubmitRequest"})
506     public void updateNonExistent(String testName) throws Exception {
507         // Perform setup.
508         setupUpdateNonExistent();
509
510         // Submit the request to the service and store the response.
511         // Note: The ID used in this 'create' call may be arbitrary.
512         // The only relevant ID may be the one used in update(), below.
513         ConditioncheckClient client = new ConditioncheckClient();
514         PoxPayloadOut multipart = createConditioncheckInstance(NON_EXISTENT_ID);
515         Response res = client.update(NON_EXISTENT_ID, multipart);
516         try {
517             int statusCode = res.getStatus();
518
519             // Check the status code of the response: does it match
520             // the expected response(s)?
521             if (logger.isDebugEnabled()) {
522                 logger.debug(testName + ": status = " + statusCode);
523             }
524             Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
525                     invalidStatusCodeMessage(testRequestType, statusCode));
526             Assert.assertEquals(statusCode, testExpectedStatusCode);
527         } finally {
528             if (res != null) {
529                 res.close();
530             }
531         }
532     }
533
534     // ---------------------------------------------------------------
535     // CRUD tests : DELETE tests
536     // ---------------------------------------------------------------
537     
538     // Success outcomes
539     
540     /* (non-Javadoc)
541      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
542      */
543     @Override
544 //    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
545 //    dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"})
546     public void delete(String testName) throws Exception {
547         // Perform setup.
548         setupDelete();
549
550         // Submit the request to the service and store the response.
551         ConditioncheckClient client = new ConditioncheckClient();
552         Response res = client.delete(knownResourceId);
553         try {
554             int statusCode = res.getStatus();
555
556             // Check the status code of the response: does it match
557             // the expected response(s)?
558             if (logger.isDebugEnabled()) {
559                 logger.debug(testName + ": status = " + statusCode);
560             }
561             Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
562                     invalidStatusCodeMessage(testRequestType, statusCode));
563             Assert.assertEquals(statusCode, testExpectedStatusCode);
564         } finally {
565             if (res != null) {
566                 res.close();
567             }
568         }
569     }
570
571     // Failure outcomes
572     
573     /* (non-Javadoc)
574      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
575      */
576     @Override
577 //    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
578 //    dependsOnMethods = {"delete"})
579     public void deleteNonExistent(String testName) throws Exception {
580         // Perform setup.
581         setupDeleteNonExistent();
582
583         // Submit the request to the service and store the response.
584         ConditioncheckClient client = new ConditioncheckClient();
585         Response res = client.delete(NON_EXISTENT_ID);
586         try {
587             int statusCode = res.getStatus();
588
589             // Check the status code of the response: does it match
590             // the expected response(s)?
591             if (logger.isDebugEnabled()) {
592                 logger.debug(testName + ": status = " + statusCode);
593             }
594             Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
595                     invalidStatusCodeMessage(testRequestType, statusCode));
596             Assert.assertEquals(statusCode, testExpectedStatusCode);
597         } finally {
598             if (res != null) {
599                 res.close();
600             }
601         }
602     }
603
604     // ---------------------------------------------------------------
605     // Utility tests : tests of code used in tests above
606     // ---------------------------------------------------------------
607     
608     /**
609      * Tests the code for manually submitting data that is used by several
610      * of the methods above.
611      */
612 //    @Test(dependsOnMethods = {"create", "read"})
613     public void testSubmitRequest() {
614
615         // Expected status code: 200 OK
616         final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
617
618         // Submit the request to the service and store the response.
619         String method = ServiceRequestType.READ.httpMethodName();
620         String url = getResourceURL(knownResourceId);
621         int statusCode = submitRequest(method, url);
622
623         // Check the status code of the response: does it match
624         // the expected response(s)?
625         if (logger.isDebugEnabled()) {
626             logger.debug("testSubmitRequest: url=" + url
627                     + " status=" + statusCode);
628         }
629         Assert.assertEquals(statusCode, EXPECTED_STATUS);
630
631     }
632
633     // ---------------------------------------------------------------
634     // Utility methods used by tests above
635     // ---------------------------------------------------------------
636     
637     @Override
638     public String getServiceName() {
639         return SERVICE_NAME;
640     }
641
642     /* (non-Javadoc)
643      * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
644      */
645     @Override
646     public String getServicePathComponent() {
647         return SERVICE_PATH_COMPONENT;
648     }
649
650     @Override
651     protected PoxPayloadOut createInstance(String identifier) {
652         return createConditioncheckInstance(identifier);
653     }
654
655     /**
656      * Creates the conditioncheck instance.
657      *
658      * @param identifier the identifier
659      * @return the multipart output
660      */
661     //private PoxPayloadOut createConditioncheckInstance(String identifier) {
662     //    return createConditioncheckInstance("conditionCheckRefNumber-" + identifier);
663     //}
664
665     /**
666      * Creates the conditioncheck instance.
667      *
668      * @param conditioncheckRefNumber the conditioncheck number
669      * @return the multipart output
670      */
671     private PoxPayloadOut createConditioncheckInstance(String conditionCheckRefNumber) {
672
673         ConditionchecksCommon conditioncheckCommon = new ConditionchecksCommon();
674         conditioncheckCommon.setConditionCheckRefNumber(conditionCheckRefNumber);
675         conditioncheckCommon.setConditionChecker(CONDITIONCHECKER_REF_NAME);
676         conditioncheckCommon.setConditionCheckNote(getUTF8DataFragment());
677
678         HazardGroupList hazardGroupList = new HazardGroupList();
679         List<HazardGroup> hazardGroups = hazardGroupList.getHazardGroup();
680         HazardGroup hazardGroup = new HazardGroup();
681         hazardGroup.setHazard(CONDITIONCHECK_HAZARD);
682         hazardGroup.setHazardDate(CURRENT_DATE_UTC);
683         hazardGroup.setHazardNote(CONDITIONCHECK_HAZARD_NOTE);
684         hazardGroups.add(hazardGroup);
685         conditioncheckCommon.setHazardGroupList(hazardGroupList);
686
687         PoxPayloadOut multipart = new PoxPayloadOut(this.getServicePathComponent());
688         PayloadOutputPart commonPart =
689                 multipart.addPart(new ConditioncheckClient().getCommonPartName(), conditioncheckCommon);
690
691         if (logger.isDebugEnabled()) {
692             logger.debug("to be created, conditioncheck common");
693             logger.debug(objectAsXmlString(conditioncheckCommon, ConditionchecksCommon.class));
694         }
695
696         return multipart;
697     }
698
699     @Override
700     public void CRUDTests(String testName) {
701         // TODO Auto-generated method stub
702         
703     }
704
705     @Override
706     protected PoxPayloadOut createInstance(String commonPartName,
707             String identifier) {
708         PoxPayloadOut result = createConditioncheckInstance(identifier);
709         return result;
710     }
711
712     @Override
713     protected ConditionchecksCommon updateInstance(ConditionchecksCommon commonPartObject) {
714         // TODO Auto-generated method stub
715         return null;
716     }
717
718     @Override
719     protected void compareUpdatedInstances(ConditionchecksCommon original,
720             ConditionchecksCommon updated) throws Exception {
721         // TODO Auto-generated method stub
722         
723     }
724 }