]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
1eb2a74600b69b96b742f1ace8f0c76638ed5df9
[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.LoaninClient;
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.loanin.LenderGroup;
40 import org.collectionspace.services.loanin.LenderGroupList;
41 import org.collectionspace.services.loanin.LoansinCommon;
42
43 import org.testng.Assert;
44 import org.slf4j.Logger;
45 import org.slf4j.LoggerFactory;
46
47 /**
48  * LoaninServiceTest, carries out tests against a
49  * deployed and running Loanin (aka Loans In) Service.
50  *
51  * $LastChangedRevision$
52  * $LastChangedDate$
53  */
54 public class LoaninServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonList, LoansinCommon> {
55
56     /** The logger. */
57     private final String CLASS_NAME = LoaninServiceTest.class.getName();
58     private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
59     // Instance variables specific to this test.
60     /** The service path component. */
61     final String SERVICE_NAME = "loansin";
62     final String SERVICE_PATH_COMPONENT = "loansin";
63     private String LENDER_REF_NAME =
64             "urn:cspace:org.collectionspace.demo:personauthorities:name(TestPersonAuth):item:name(HarryLender)'Harry Lender'";
65     private final static String CURRENT_DATE_UTC =
66             GregorianCalendarDateTimeUtils.currentDateUTC();
67
68     /* (non-Javadoc)
69      * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
70      */
71     @Override
72     protected CollectionSpaceClient getClientInstance() {
73         return new LoaninClient();
74     }
75
76         @Override
77         protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
78         return new LoaninClient(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         LoaninClient client = new LoaninClient();
108         String identifier = createIdentifier();
109         PoxPayloadOut multipart = createLoaninInstance(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         LoaninClient client = new LoaninClient();
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         LoansinCommon loaninCommon = null;
283         if (payloadInputPart != null) {
284             loaninCommon = (LoansinCommon) payloadInputPart.getBody();
285         }
286         Assert.assertNotNull(loaninCommon);
287
288         // Check selected fields.
289         LenderGroupList lenderGroupList = loaninCommon.getLenderGroupList();
290         Assert.assertNotNull(lenderGroupList);
291         List<LenderGroup> lenderGroups = lenderGroupList.getLenderGroup();
292         Assert.assertNotNull(lenderGroups);
293         Assert.assertTrue(lenderGroups.size() > 0);
294         String lender = lenderGroups.get(0).getLender();
295         Assert.assertEquals(lender, LENDER_REF_NAME);
296
297         if (logger.isDebugEnabled()) {
298             logger.debug("UTF-8 data sent=" + getUTF8DataFragment() + "\n"
299                     + "UTF-8 data received=" + loaninCommon.getLoanInNote());
300         }
301
302         Assert.assertEquals(loaninCommon.getLoanInNote(), getUTF8DataFragment(),
303                 "UTF-8 data retrieved '" + loaninCommon.getLoanInNote()
304                 + "' does not match expected data '" + getUTF8DataFragment());
305     }
306
307     // Failure outcomes
308     
309     /* (non-Javadoc)
310      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
311      */
312     @Override
313 //    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
314 //    dependsOnMethods = {"read"})
315     public void readNonExistent(String testName) throws Exception {
316         // Perform setup.
317         setupReadNonExistent();
318
319         // Submit the request to the service and store the response.
320         LoaninClient client = new LoaninClient();
321         Response res = client.read(NON_EXISTENT_ID);
322         try {
323             int statusCode = res.getStatus();
324
325             // Check the status code of the response: does it match
326             // the expected response(s)?
327             if (logger.isDebugEnabled()) {
328                 logger.debug(testName + ": status = " + statusCode);
329             }
330             Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
331                     invalidStatusCodeMessage(testRequestType, statusCode));
332             Assert.assertEquals(statusCode, testExpectedStatusCode);
333         } finally {
334                 if (res != null) {
335                 res.close();
336             }
337         }
338     }
339
340     // ---------------------------------------------------------------
341     // CRUD tests : READ_LIST tests
342     // ---------------------------------------------------------------
343     
344     // Success outcomes
345     
346     /* (non-Javadoc)
347      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
348      */
349     @Override
350 //    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
351 //    dependsOnMethods = {"createList", "read"})
352     public void readList(String testName) throws Exception {
353         // Perform setup.
354         setupReadList();
355
356         // Submit the request to the service and store the response.
357         AbstractCommonList list = null;
358         LoaninClient client = new LoaninClient();
359         Response res = client.readList();
360         assertStatusCode(res, testName);
361         try {
362             int statusCode = res.getStatus();
363
364             // Check the status code of the response: does it match
365             // the expected response(s)?
366             if (logger.isDebugEnabled()) {
367                 logger.debug(testName + ": status = " + statusCode);
368             }
369             Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
370                     invalidStatusCodeMessage(testRequestType, statusCode));
371             Assert.assertEquals(statusCode, testExpectedStatusCode);
372
373             list = res.readEntity(getCommonListType());
374         } finally {
375                 if (res != null) {
376                 res.close();
377             }
378         }
379
380         // Optionally output additional data about list members for debugging.
381         boolean iterateThroughList = true;
382         if(iterateThroughList && logger.isDebugEnabled()){
383                 AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
384         }
385
386     }
387
388     // Failure outcomes
389     // None at present.
390     
391     // ---------------------------------------------------------------
392     // CRUD tests : UPDATE tests
393     // ---------------------------------------------------------------
394     
395     // Success outcomes
396     
397     /* (non-Javadoc)
398      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
399      */
400     @Override
401 //    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
402 //    dependsOnMethods = {"read"})
403     public void update(String testName) throws Exception {
404         // Perform setup.
405         setupRead();
406
407         // Retrieve the contents of a resource to update.
408         LoaninClient client = new LoaninClient();
409         Response res = client.read(knownResourceId);
410         PoxPayloadIn input = null;
411         try {
412                 assertStatusCode(res, testName);
413             input = new PoxPayloadIn(res.readEntity(String.class));
414                 if (logger.isDebugEnabled()) {
415                 logger.debug("got object to update with ID: " + knownResourceId);
416             }
417         } finally {
418                 if (res != null) {
419                 res.close();
420             }
421         }
422
423         // Extract the common part from the response.
424         PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName());
425         LoansinCommon loaninCommon = null;
426         if (payloadInputPart != null) {
427             loaninCommon = (LoansinCommon) payloadInputPart.getBody();
428         }
429         Assert.assertNotNull(loaninCommon);
430
431         // Update the content of this resource.
432         loaninCommon.setLoanInNumber("updated-" + loaninCommon.getLoanInNumber());
433         loaninCommon.setLoanInNote("updated-" + loaninCommon.getLoanInNote());
434         if (logger.isDebugEnabled()) {
435             logger.debug("to be updated object");
436             logger.debug(objectAsXmlString(loaninCommon, LoansinCommon.class));
437         }
438
439         setupUpdate();
440         
441         // Submit the updated common part in an update request to the service
442         // and store the response.
443         PoxPayloadOut output = new PoxPayloadOut(this.getServicePathComponent());
444         PayloadOutputPart commonPart = output.addPart(client.getCommonPartName(), loaninCommon);
445         res = client.update(knownResourceId, output);
446         try {
447                 assertStatusCode(res, testName);
448             int statusCode = res.getStatus();
449             // Check the status code of the response: does it match the expected response(s)?
450             if (logger.isDebugEnabled()) {
451                 logger.debug(testName + ": status = " + statusCode);
452             }
453             Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
454                     invalidStatusCodeMessage(testRequestType, statusCode));
455             Assert.assertEquals(statusCode, testExpectedStatusCode);
456             input = new PoxPayloadIn(res.readEntity(String.class));
457         } finally {
458                 if (res != null) {
459                 res.close();
460             }
461         }
462
463         // Extract the updated common part from the response.
464         payloadInputPart = input.getPart(client.getCommonPartName());
465         LoansinCommon updatedLoaninCommon = null;
466         if (payloadInputPart != null) {
467             updatedLoaninCommon = (LoansinCommon) payloadInputPart.getBody();
468         }
469         Assert.assertNotNull(updatedLoaninCommon);
470
471         // Check selected fields in the updated common part.
472         Assert.assertEquals(updatedLoaninCommon.getLoanInNumber(),
473                 loaninCommon.getLoanInNumber(),
474                 "Data in updated object did not match submitted data.");
475
476         if (logger.isDebugEnabled()) {
477             logger.debug("UTF-8 data sent=" + loaninCommon.getLoanInNote() + "\n"
478                     + "UTF-8 data received=" + updatedLoaninCommon.getLoanInNote());
479         }
480         Assert.assertTrue(updatedLoaninCommon.getLoanInNote().contains(getUTF8DataFragment()),
481                 "UTF-8 data retrieved '" + updatedLoaninCommon.getLoanInNote()
482                 + "' does not contain expected data '" + getUTF8DataFragment());
483         Assert.assertEquals(updatedLoaninCommon.getLoanInNote(),
484                 loaninCommon.getLoanInNote(),
485                 "Data in updated object did not match submitted data.");
486     }
487
488     @Override
489 //    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
490 //    dependsOnMethods = {"update", "testSubmitRequest"})
491     public void updateNonExistent(String testName) throws Exception {
492         // Perform setup.
493         setupUpdateNonExistent();
494
495         // Submit the request to the service and store the response.
496         // Note: The ID used in this 'create' call may be arbitrary.
497         // The only relevant ID may be the one used in update(), below.
498         LoaninClient client = new LoaninClient();
499         PoxPayloadOut multipart = createLoaninInstance(NON_EXISTENT_ID);
500         Response res = client.update(NON_EXISTENT_ID, multipart);
501         try {
502             int statusCode = res.getStatus();
503
504             // Check the status code of the response: does it match
505             // the expected response(s)?
506             if (logger.isDebugEnabled()) {
507                 logger.debug(testName + ": status = " + statusCode);
508             }
509             Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
510                     invalidStatusCodeMessage(testRequestType, statusCode));
511             Assert.assertEquals(statusCode, testExpectedStatusCode);
512         } finally {
513                 if (res != null) {
514                 res.close();
515             }
516         }
517     }
518
519     // ---------------------------------------------------------------
520     // CRUD tests : DELETE tests
521     // ---------------------------------------------------------------
522     
523     // Success outcomes
524     
525     /* (non-Javadoc)
526      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
527      */
528     @Override
529 //    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
530 //    dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"})
531     public void delete(String testName) throws Exception {
532         // Perform setup.
533         setupDelete();
534
535         // Submit the request to the service and store the response.
536         LoaninClient client = new LoaninClient();
537         Response res = client.delete(knownResourceId);
538         try {
539             int statusCode = res.getStatus();
540
541             // Check the status code of the response: does it match
542             // the expected response(s)?
543             if (logger.isDebugEnabled()) {
544                 logger.debug(testName + ": status = " + statusCode);
545             }
546             Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
547                     invalidStatusCodeMessage(testRequestType, statusCode));
548             Assert.assertEquals(statusCode, testExpectedStatusCode);
549         } finally {
550                 if (res != null) {
551                 res.close();
552             }
553         }
554     }
555
556     // Failure outcomes
557     
558     /* (non-Javadoc)
559      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
560      */
561     @Override
562 //    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
563 //    dependsOnMethods = {"delete"})
564     public void deleteNonExistent(String testName) throws Exception {
565         // Perform setup.
566         setupDeleteNonExistent();
567
568         // Submit the request to the service and store the response.
569         LoaninClient client = new LoaninClient();
570         Response res = client.delete(NON_EXISTENT_ID);
571         try {
572             int statusCode = res.getStatus();
573
574             // Check the status code of the response: does it match
575             // the expected response(s)?
576             if (logger.isDebugEnabled()) {
577                 logger.debug(testName + ": status = " + statusCode);
578             }
579             Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
580                     invalidStatusCodeMessage(testRequestType, statusCode));
581             Assert.assertEquals(statusCode, testExpectedStatusCode);
582         } finally {
583                 if (res != null) {
584                 res.close();
585             }
586         }
587     }
588
589     // ---------------------------------------------------------------
590     // Utility tests : tests of code used in tests above
591     // ---------------------------------------------------------------
592     
593     /**
594      * Tests the code for manually submitting data that is used by several
595      * of the methods above.
596      */
597 //    @Test(dependsOnMethods = {"create", "read"})
598     public void testSubmitRequest() {
599
600         // Expected status code: 200 OK
601         final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
602
603         // Submit the request to the service and store the response.
604         String method = ServiceRequestType.READ.httpMethodName();
605         String url = getResourceURL(knownResourceId);
606         int statusCode = submitRequest(method, url);
607
608         // Check the status code of the response: does it match
609         // the expected response(s)?
610         if (logger.isDebugEnabled()) {
611             logger.debug("testSubmitRequest: url=" + url
612                     + " status=" + statusCode);
613         }
614         Assert.assertEquals(statusCode, EXPECTED_STATUS);
615
616     }
617
618     // ---------------------------------------------------------------
619     // Utility methods used by tests above
620     // ---------------------------------------------------------------
621     
622     @Override
623     public String getServiceName() {
624         return SERVICE_NAME;
625     }
626
627     /* (non-Javadoc)
628      * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
629      */
630     @Override
631     public String getServicePathComponent() {
632         return SERVICE_PATH_COMPONENT;
633     }
634
635     @Override
636     protected PoxPayloadOut createInstance(String identifier) {
637         return createLoaninInstance(identifier);
638     }
639
640     /**
641      * Creates the loanin instance.
642      *
643      * @param identifier the identifier
644      * @return the multipart output
645      */
646     private PoxPayloadOut createLoaninInstance(String identifier) {
647         return createLoaninInstance(
648                 "loaninNumber-" + identifier,
649                 "returnDate-" + identifier);
650     }
651
652     /**
653      * Creates the loanin instance.
654      *
655      * @param loaninNumber the loanin number
656      * @param returnDate the return date
657      * @return the multipart output
658      */
659     private PoxPayloadOut createLoaninInstance(String loaninNumber,
660             String returnDate) {
661
662         LoansinCommon loaninCommon = new LoansinCommon();
663         loaninCommon.setLoanInNumber(loaninNumber);
664         loaninCommon.setLoanReturnDate(CURRENT_DATE_UTC);
665         LenderGroupList lenderGroupList = new LenderGroupList();
666         LenderGroup lenderGroup = new LenderGroup();
667         lenderGroup.setLender(LENDER_REF_NAME);
668         lenderGroupList.getLenderGroup().add(lenderGroup);
669         loaninCommon.setLenderGroupList(lenderGroupList);
670         loaninCommon.setLoanPurpose("For Surfboards of the 1960s exhibition.");
671         loaninCommon.setLoanInNote(getUTF8DataFragment());
672
673         PoxPayloadOut multipart = new PoxPayloadOut(this.getServicePathComponent());
674         PayloadOutputPart commonPart =
675                 multipart.addPart(new LoaninClient().getCommonPartName(), loaninCommon);
676
677         if (logger.isDebugEnabled()) {
678             logger.debug("to be created, loanin common");
679             logger.debug(objectAsXmlString(loaninCommon, LoansinCommon.class));
680         }
681
682         return multipart;
683     }
684
685         @Override
686         public void CRUDTests(String testName) {
687                 // TODO Auto-generated method stub
688                 
689         }
690
691         @Override
692         protected PoxPayloadOut createInstance(String commonPartName,
693                         String identifier) {
694         PoxPayloadOut result = createLoaninInstance(identifier);
695         return result;
696         }
697
698         @Override
699         protected LoansinCommon updateInstance(LoansinCommon commonPartObject) {
700                 // TODO Auto-generated method stub
701                 return null;
702         }
703
704         @Override
705         protected void compareUpdatedInstances(LoansinCommon original,
706                         LoansinCommon updated) throws Exception {
707                 // TODO Auto-generated method stub
708                 
709         }
710 }