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