001package org.kuali.ole;
002
003
004import org.junit.Test;
005import org.kuali.ole.converter.OLEEDIConverter;
006import org.kuali.ole.docstore.xstream.FileUtil;
007import org.kuali.ole.pojo.edi.*;
008import org.kuali.ole.pojo.edi.MesssageTypeInformation;
009import org.slf4j.Logger;
010import org.slf4j.LoggerFactory;
011
012import java.io.File;
013import java.math.BigDecimal;
014import java.net.URL;
015import java.util.ArrayList;
016import java.util.Iterator;
017import java.util.List;
018
019import static junit.framework.Assert.assertNotNull;
020
021/**
022 * Created by IntelliJ IDEA.
023 * User: palanivel
024 * Date: 3/1/12
025 * Time: 3:01 PM
026 * To change this template use File | Settings | File Templates.
027 */
028public class OLEEDITranslator_UT {
029
030    protected static final Logger LOG = LoggerFactory.getLogger(OLEEDITranslator_UT.class);
031
032    /**
033     * This method is used to convert an Raw EDI file to XML.
034     *
035     * @throws Exception
036     */
037    @Test
038    public void testConvertEDIToXML() throws Exception {
039
040        OLEEDIConverter OLEEDITranslator = new OLEEDIConverter();
041        assertNotNull(OLEEDITranslator);
042        URL ediResource = getClass().getResource("iu.edi");
043        File ediFile = new File(ediResource.toURI());
044        String fileContent = new FileUtil().readFile(ediFile);
045
046        String javaResult = OLEEDITranslator.convertToXML(fileContent);
047        LOG.info(javaResult.toString());
048
049
050    }
051
052    /**
053     * This method is used to generate POJOS from XML.
054     *
055     * @throws Exception
056     */
057    @Test
058    public void testGenerateXMLToPojos() throws Exception {
059        OLEEDIConverter OLEEDITranslator = new OLEEDIConverter();
060        assertNotNull(OLEEDITranslator);
061        URL ediResource = getClass().getResource("iu.edi");
062        File ediFile = new File(ediResource.toURI());
063        String fileContent = new FileUtil().readFile(ediFile);
064        String xml = OLEEDITranslator.convertToXML(fileContent);
065
066        OLETranscationalRecordGenerator oleTranscationalRecordGenerator = new OLETranscationalRecordGenerator();
067        EDIOrders ediOrders = oleTranscationalRecordGenerator.fromXml(xml);
068
069        for (Iterator<EDIOrder> iterator = ediOrders.getOrders().iterator(); iterator.hasNext(); ) {
070            EDIOrder ediOrder = iterator.next();
071            LOG.info("==============Object Message Out=============");
072            LOG.info(ediOrder.getSenderAndReceiver().getSendersAndReceiversConstant().getCode());
073            LOG.info(ediOrder.getSenderAndReceiver().getSenderInformation().getSenderId());
074            LOG.info(ediOrder.getSenderAndReceiver().getReceiverInformation().getReceiverId());
075            LOG.info(ediOrder.getSenderAndReceiver().getSchedule().getPreparationDate());
076            LOG.info(ediOrder.getSenderAndReceiver().getInterChangeControlReference());
077            LOG.info("======================================\n\n");
078        }
079    }
080
081    /**
082     * This method is used to generate XML from POJOS.
083     *
084     * @throws Exception
085     */
086    @Test
087    public void testGeneratePojosToXML() throws Exception {
088        EDIOrder ediOrder = new EDIOrder();
089        EDIOrderFixture ediOrderFixture = new EDIOrderFixture();
090        SenderAndReceiver senderAndReceiver = ediOrderFixture.createSenderAndReceiver(SenderAndReceiver.class);
091        MessageHeader messageHeader = ediOrderFixture.createMessageHeader(MessageHeader.class);
092        Message message = ediOrderFixture.createMessage(Message.class);
093        LineItemOrder lineItemOrder = ediOrderFixture.createLineItemOrder(LineItemOrder.class);
094        Summary summary = ediOrderFixture.createSummaryOrder(Summary.class);
095        FreeTextNotes freeTextNotes = new FreeTextNotes();
096        OrderItem orderItem = new OrderItem();
097        Trailer trailer = new Trailer();
098        BuyerReferenceInformation buyerReferenceInformation = new BuyerReferenceInformation();
099        ControlInfomation controlInfomation = new ControlInfomation();
100        FundNumberReference fundNumberReference = new FundNumberReference();
101        BuyerLineItemReference buyerLineItemReference = new BuyerLineItemReference();
102        BuyerPartyQualifier buyerPartyQualifier = new BuyerPartyQualifier();
103        BuyerInformation buyerInformation = new BuyerInformation();
104        PartyDetails partyDetails = new PartyDetails();
105        ItemDescription itemDescription = new ItemDescription();
106
107        List<BuyerLineItemReference> buyerLineItemReferenceList = new ArrayList<BuyerLineItemReference>();
108
109        ediOrder.setSenderAndReceiver(senderAndReceiver);
110        ediOrder.setMessageHeader(messageHeader);
111        ediOrder.setMessage(message);
112        ediOrder.addLineItemOrder(lineItemOrder);
113        ediOrder.setSummary(summary);
114        OLETranscationalRecordGenerator oleTranscationalRecordGenerator = new OLETranscationalRecordGenerator();
115        assertNotNull(ediOrder);
116        String ediXml = oleTranscationalRecordGenerator.toXml(ediOrder);
117        LOG.info(ediXml);
118        freeTextNotes.setNoteLineItem("noteLineItem");
119        freeTextNotes.setNoteempty1("noteempty1");
120        freeTextNotes.setNoteempty2("noteempty2");
121        freeTextNotes.setNoteempty3("noteempty3");
122        assertNotNull(freeTextNotes.getNoteLineItem());
123        assertNotNull(freeTextNotes.getNoteempty1());
124        assertNotNull(freeTextNotes.getNoteempty2());
125        assertNotNull(freeTextNotes.getNoteempty3());
126        List<FreeTextNotes> freeTextNotesList = new ArrayList<FreeTextNotes>();
127        freeTextNotesList.add(freeTextNotes);
128
129        BigDecimal bigDecimal = new BigDecimal("12345.678");
130        orderItem.setPrice(bigDecimal);
131        orderItem.setProductId("123");
132        orderItem.setQuantity(2);
133        orderItem.setTitle("title");
134        assertNotNull(orderItem.getPrice());
135        assertNotNull(orderItem.getProductId());
136        assertNotNull(orderItem.getQuantity());
137        assertNotNull(orderItem.getTitle());
138        LOG.info(orderItem.toString());
139
140        trailer.setUnknown1("unknown1");
141        trailer.setUnknown2("unknown2");
142        assertNotNull(trailer.getUnknown1());
143        assertNotNull(trailer.getUnknown2());
144
145        buyerLineItemReference.setBuyersOrderLine("buyersorderline");
146        buyerLineItemReference.setOrderLineNumber("orderlinenumber");
147        buyerLineItemReferenceList.add(buyerLineItemReference);
148        assertNotNull(buyerLineItemReference.getBuyersOrderLine());
149        assertNotNull(buyerLineItemReference.getOrderLineNumber());
150
151        buyerInformation.setBuyerCodeIdentification("00");
152        buyerInformation.setBuyerCodeListAgency("001");
153        buyerInformation.setBuyerPartyIdentificationCode("0001");
154        assertNotNull(buyerInformation.getBuyerCodeIdentification());
155        assertNotNull(buyerInformation.getBuyerCodeListAgency());
156        assertNotNull(buyerInformation.getBuyerPartyIdentificationCode());
157
158        buyerPartyQualifier.setBuyer("buyer");
159        buyerPartyQualifier.setBuyerInformation(buyerInformation);
160        assertNotNull(buyerPartyQualifier.getBuyer());
161        assertNotNull(buyerPartyQualifier.getBuyerInformation());
162
163        partyDetails.setAdditionalPartyIdentification("0001");
164        partyDetails.setPartyName("party");
165        assertNotNull(partyDetails.getAdditionalPartyIdentification());
166        assertNotNull(partyDetails.getPartyName());
167
168        buyerReferenceInformation.setBuyerLineItemReference(buyerLineItemReferenceList);
169        assertNotNull(buyerReferenceInformation.getBuyerLineItemReference());
170        List<BuyerReferenceInformation> buyerReferenceInformationList = new ArrayList<BuyerReferenceInformation>();
171
172        itemDescription.setData("data");
173        itemDescription.setItemCharacteristicCode("a123");
174        itemDescription.setText("itemText");
175        assertNotNull(itemDescription.getData());
176        assertNotNull(itemDescription.getItemCharacteristicCode());
177        assertNotNull(itemDescription.getText());
178        List<ItemDescription> itemDescriptionList = new ArrayList<ItemDescription>();
179        itemDescriptionList.add(itemDescription);
180
181
182        SendersAndReceiversConstant sendersAndReceiversConstant = new SendersAndReceiversConstant();
183        sendersAndReceiversConstant.setCode("s00");
184        sendersAndReceiversConstant.setValue("123");
185        assertNotNull(sendersAndReceiversConstant.getCode());
186        assertNotNull(sendersAndReceiversConstant.getValue());
187
188        SenderInformation senderInformation = new SenderInformation();
189        senderInformation.setSenderId("012");
190        senderInformation.setSenderIdType("type");
191        assertNotNull(senderInformation.getSenderId());
192        assertNotNull(senderInformation.getSenderIdType());
193
194        Schedule schedule = new Schedule();
195        schedule.setPreparationDate("12-12-2-2012");
196        schedule.setPreparationTime("23:23:00");
197        assertNotNull(schedule.getPreparationDate());
198        assertNotNull(schedule.getPreparationTime());
199
200        ReceiverInformation receiverInformation = new ReceiverInformation();
201        receiverInformation.setReceiverId("r001");
202        receiverInformation.setReceiverIdType("typr");
203        assertNotNull(receiverInformation.getReceiverId());
204        assertNotNull(receiverInformation.getReceiverIdType());
205
206        SummarySection summarySection = new SummarySection();
207        summarySection.setSeparatorInformation("sepinfo");
208        assertNotNull(summarySection.getSeparatorInformation());
209
210        MessageReference messageReference = new MessageReference();
211        messageReference.setPartyDetails(partyDetails);
212        assertNotNull(messageReference.getPartyDetails());
213
214        MessageCreationInfoDetails messageCreationInfoDetails = new MessageCreationInfoDetails();
215        messageCreationInfoDetails.setMessageCreationInfoConstant("const");
216        messageCreationInfoDetails.setMessageCreationInfoDate("12-12-2012");
217        messageCreationInfoDetails.setMessageCreationInfoDateFormat("dd-mm-yyyy");
218        assertNotNull(messageCreationInfoDetails.getMessageCreationInfoConstant());
219        assertNotNull(messageCreationInfoDetails.getMessageCreationInfoDate());
220        assertNotNull(messageCreationInfoDetails.getMessageCreationInfoDateFormat());
221
222        MessageCreationInformation messageCreationInformation = new MessageCreationInformation();
223        messageCreationInformation.setMessageCreationInfoDetails(messageCreationInfoDetails);
224        assertNotNull(messageCreationInformation.getMessageCreationInfoDetails());
225
226        UNTSummary untSummary = new UNTSummary();
227        untSummary.setLinSegmentTotal("100");
228        untSummary.setSegmentNumber("10");
229        assertNotNull(untSummary.getLinSegmentTotal());
230        assertNotNull(untSummary.getSegmentNumber());
231
232        TransportStageQualifier transportStageQualifier = new TransportStageQualifier();
233        transportStageQualifier.setSurfaceMail("surfacemail");
234        transportStageQualifier.setTransportStageConstant("transportStageConstant");
235        assertNotNull(transportStageQualifier.getSurfaceMail());
236        assertNotNull(transportStageQualifier.getTransportStageConstant());
237        List<TransportStageQualifier> transportStageQualifierList = new ArrayList<TransportStageQualifier>();
238        transportStageQualifierList.add(transportStageQualifier);
239
240        SupplierLineItemReference supplierLineItemReference = new SupplierLineItemReference();
241        supplierLineItemReference.setSuppliersOrderLine("suppliersOrderLine");
242        supplierLineItemReference.setVendorReferenceNumber("v0012");
243        assertNotNull(supplierLineItemReference.getSuppliersOrderLine());
244        assertNotNull(supplierLineItemReference.getVendorReferenceNumber());
245
246        SupplierInformation supplierInformation = new SupplierInformation();
247        supplierInformation.setSupplierCodeIdentification("s023");
248        supplierInformation.setSupplierCodeListAgency("agency");
249        supplierInformation.setSupplierPartyIdentificationCode("p001");
250        assertNotNull(supplierInformation.getSupplierCodeIdentification());
251        assertNotNull(supplierInformation.getSupplierCodeListAgency());
252        assertNotNull(supplierInformation.getSupplierPartyIdentificationCode());
253
254        SupplierPartyQualifier supplierPartyQualifier = new SupplierPartyQualifier();
255        supplierPartyQualifier.setSupplier("ABC Vendors");
256        supplierPartyQualifier.setSupplierInformation(supplierInformation);
257        assertNotNull(supplierPartyQualifier.getSupplier());
258        assertNotNull(supplierPartyQualifier.getSupplierInformation());
259
260        LineItemArticleNumber lineItemArticleNumber = new LineItemArticleNumber();
261        lineItemArticleNumber.setLineItemIsbn("1234-324-2344");
262        lineItemArticleNumber.setLineItemNumberType("type");
263        assertNotNull(lineItemArticleNumber.getLineItemIsbn());
264        assertNotNull(lineItemArticleNumber.getLineItemNumberType());
265
266        List<LineItemArticleNumber> lineItemArticleNumberList = new ArrayList<LineItemArticleNumber>();
267        lineItemArticleNumberList.add(lineItemArticleNumber);
268
269        Qunatity qunatity = new Qunatity();
270        qunatity.setQuantity("3");
271        qunatity.setQuantityConstant("1");
272        assertNotNull(qunatity.getQuantity());
273        assertNotNull(qunatity.getQuantityConstant());
274
275        ProductArticleNumber productArticleNumber = new ProductArticleNumber();
276        productArticleNumber.setProductIsbn("123-1234-243");
277        productArticleNumber.setProductItemNumberType("type");
278        assertNotNull(productArticleNumber.getProductIsbn());
279        assertNotNull(productArticleNumber.getProductItemNumberType());
280
281        List<ProductArticleNumber> productArticleNumberList = new ArrayList<ProductArticleNumber>();
282        productArticleNumberList.add(productArticleNumber);
283
284        ItemPrice itemPrice = new ItemPrice();
285        itemPrice.setGrossPrice("23.34");
286        itemPrice.setPrice("23");
287        assertNotNull(itemPrice.getPrice());
288        assertNotNull(itemPrice.getGrossPrice());
289
290        LineItem lineItem = new LineItem();
291        lineItem.setItemNumberId("01");
292        lineItem.setSequenceNumber("1");
293        lineItem.setLineItemArticleNumber(lineItemArticleNumberList);
294        assertNotNull(lineItem.getItemNumberId());
295        assertNotNull(lineItem.getLineItemArticleNumber());
296        assertNotNull(lineItem.getSequenceNumber());
297        List<LineItem> lineItemList = new ArrayList<LineItem>();
298        lineItemList.add(lineItem);
299
300
301        ProductFunction productFunction = new ProductFunction();
302        productFunction.setProductArticleNumber(productArticleNumberList);
303        productFunction.setProductId("p001");
304        assertNotNull(productFunction.getProductArticleNumber());
305        assertNotNull(productFunction.getProductId());
306        List<ProductFunction> productFunctionList = new ArrayList<ProductFunction>();
307        productFunctionList.add(productFunction);
308
309        PriceInformation priceInformation = new PriceInformation();
310        List<ItemPrice> itemPriceList = new ArrayList<ItemPrice>();
311        itemPriceList.add(itemPrice);
312        priceInformation.setItemPrice(itemPriceList);
313        assertNotNull(priceInformation.getItemPrice());
314        List<PriceInformation> priceInformationList = new ArrayList<PriceInformation>();
315
316        QuantityInformation quantityInformation = new QuantityInformation();
317        List<Qunatity> qunatityList = new ArrayList<Qunatity>();
318        qunatityList.add(qunatity);
319        quantityInformation.setQunatity(qunatityList);
320        assertNotNull(quantityInformation.getQunatity());
321        List<QuantityInformation> quantityInformationList = new ArrayList<QuantityInformation>();
322        quantityInformationList.add(quantityInformation);
323
324        Control control = new Control();
325        control.setControlQualifier("qualifier");
326        control.setTotalQuantitySegments("12");
327        assertNotNull(control.getControlQualifier());
328        assertNotNull(control.getTotalQuantitySegments());
329
330
331        MessageBeginning messageBeginning = new MessageBeginning();
332        messageBeginning.setMessageBeginningCodeListAgency("messageBeginningCodeListAgency");
333        messageBeginning.setMessageBeginningInterchangeControlReference("messageBeginningInterchangeControlReference");
334        messageBeginning.setMessageBeginningOrder("messageBeginningOrder");
335        assertNotNull(messageBeginning.getMessageBeginningCodeListAgency());
336        assertNotNull(messageBeginning.getMessageBeginningInterchangeControlReference());
337        assertNotNull(messageBeginning.getMessageBeginningOrder());
338
339
340        CurrencyDetailsSupplierInformation currencyDetailsSupplierInformation = new CurrencyDetailsSupplierInformation();
341        currencyDetailsSupplierInformation.setCurrencyType("dollars");
342        currencyDetailsSupplierInformation.setDefaultCurrency("rupees");
343        currencyDetailsSupplierInformation.setOrderCurrency("orderCurrency");
344        assertNotNull(currencyDetailsSupplierInformation.getCurrencyType());
345        assertNotNull(currencyDetailsSupplierInformation.getDefaultCurrency());
346        assertNotNull(currencyDetailsSupplierInformation.getOrderCurrency());
347
348
349        List<Control> controlList = new ArrayList<Control>();
350        controlList.add(control);
351        controlInfomation.addControlField(control);
352        controlInfomation.setControl(controlList);
353        assertNotNull(controlInfomation.getControl());
354
355        CurrencyDetails currencyDetails = new CurrencyDetails();
356        currencyDetails.setCurrencyDetailsSupplierInformation(currencyDetailsSupplierInformation);
357        assertNotNull(currencyDetails.getCurrencyDetailsSupplierInformation());
358
359
360        BuyersFundNumberReference buyersFundNumberReference = new BuyersFundNumberReference();
361        buyersFundNumberReference.setBudgetNumber("123");
362        buyersFundNumberReference.setBuyersFundNumber("1");
363        assertNotNull(buyersFundNumberReference.getBudgetNumber());
364        assertNotNull(buyersFundNumberReference.getBuyersFundNumber());
365
366        SupplierReferenceInformation supplierReferenceInformation = new SupplierReferenceInformation();
367        List<SupplierLineItemReference> supplierLineItemReferenceList = new ArrayList<SupplierLineItemReference>();
368        supplierLineItemReferenceList.add(supplierLineItemReference);
369        supplierReferenceInformation.setSupplierLineItemReference(supplierLineItemReferenceList);
370        assertNotNull(supplierReferenceInformation.getSupplierLineItemReference());
371        List<SupplierReferenceInformation> supplierReferenceInformationList = new ArrayList<SupplierReferenceInformation>();
372        supplierReferenceInformationList.add(supplierReferenceInformation);
373
374
375        List<BuyersFundNumberReference> buyersFundNumberReferenceList = new ArrayList<BuyersFundNumberReference>();
376        buyersFundNumberReferenceList.add(buyersFundNumberReference);
377        fundNumberReference.setBuyersFundNumberReference(buyersFundNumberReferenceList);
378        assertNotNull(fundNumberReference.getBuyersFundNumberReference());
379        List<FundNumberReference> fundNumberReferenceList = new ArrayList<FundNumberReference>();
380        fundNumberReferenceList.add(fundNumberReference);
381
382        message.setBuyerPartyQualifier(buyerPartyQualifier);
383        message.setCurrencyDetails(currencyDetails);
384        message.setMessageBeginning(messageBeginning);
385        message.setMessageCreationInformation(messageCreationInformation);
386        message.setMessageReference(messageReference);
387        message.setSupplierPartyQualifier(supplierPartyQualifier);
388        assertNotNull(message.getBuyerPartyQualifier());
389        assertNotNull(message.getCurrencyDetails());
390        assertNotNull(message.getMessageBeginning());
391        assertNotNull(message.getMessageCreationInformation());
392        assertNotNull(message.getMessageReference());
393        assertNotNull(message.getSupplierPartyQualifier());
394
395
396        List<ControlInfomation> controlInfomationList = new ArrayList<ControlInfomation>();
397        controlInfomationList.add(controlInfomation);
398
399        summary.setControlInfomation(controlInfomationList);
400        summary.setSummarySection(summarySection);
401        summary.setUntSummary(untSummary);
402        assertNotNull(summary.getControlInfomation());
403        assertNotNull(summary.getSummarySection());
404        assertNotNull(summary.getUntSummary());
405
406        MesssageTypeInformation messageTypeInformation = new MesssageTypeInformation();
407        messageTypeInformation.setConstant1("const1");
408        messageTypeInformation.setConstant2("const2");
409        messageTypeInformation.setConstant3("const3");
410        messageTypeInformation.setConstant4("const4");
411        messageTypeInformation.setMessageTypeId("12");
412        assertNotNull(messageTypeInformation.getConstant1());
413        assertNotNull(messageTypeInformation.getConstant2());
414        assertNotNull(messageTypeInformation.getConstant3());
415        assertNotNull(messageTypeInformation.getConstant4());
416        assertNotNull(messageTypeInformation.getMessageTypeId());
417
418
419        messageHeader.setInterchangeControlReference("interchangeControlReference");
420        messageHeader.setMesssageTypeInformation(messageTypeInformation);
421        assertNotNull(messageHeader.getInterchangeControlReference());
422        assertNotNull(messageHeader.getMesssageTypeInformation());
423
424
425        lineItemOrder.setBuyerReferenceInformation(buyerReferenceInformationList);
426        lineItemOrder.setFundNumberReference(fundNumberReferenceList);
427        lineItemOrder.setItemDescriptionList(itemDescriptionList);
428        lineItemOrder.setNote(freeTextNotesList);
429        lineItemOrder.setPriceInformation(priceInformationList);
430        lineItemOrder.setProductFunction(productFunctionList);
431        lineItemOrder.setQuantityInformation(quantityInformationList);
432        lineItemOrder.setSupplierReferenceInformation(supplierReferenceInformationList);
433        lineItemOrder.setTransportStageQualifier(transportStageQualifierList);
434        lineItemOrder.setLineItem(lineItemList);
435        lineItemOrder.addNote(freeTextNotes);
436        assertNotNull(lineItemOrder.getBuyerReferenceInformation());
437        assertNotNull(lineItemOrder.getFundNumberReference());
438        assertNotNull(lineItemOrder.getItemDescriptionList());
439        assertNotNull(lineItemOrder.getLineItem());
440        assertNotNull(lineItemOrder.getNote());
441        assertNotNull(lineItemOrder.getPriceInformation());
442        assertNotNull(lineItemOrder.getQuantityInformation());
443        assertNotNull(lineItemOrder.getProductFunction());
444        assertNotNull(lineItemOrder.getQuantityInformation());
445        assertNotNull(lineItemOrder.getSupplierReferenceInformation());
446        assertNotNull(lineItemOrder.getTransportStageQualifier());
447        assertNotNull(lineItemOrder.getLineItem());
448
449        List<LineItemOrder> lineItemOrderList = new ArrayList<LineItemOrder>();
450        lineItemOrderList.add(lineItemOrder);
451        ediOrder.setLineItemOrder(lineItemOrderList);
452        ediOrder.setMessage(message);
453        ediOrder.setMessageHeader(messageHeader);
454        ediOrder.setSenderAndReceiver(senderAndReceiver);
455        ediOrder.setSeperators("seperators");
456        ediOrder.setSummary(summary);
457        ediOrder.setTrailer(trailer);
458        assertNotNull(ediOrder.getLineItemOrder());
459        assertNotNull(ediOrder.getMessage());
460        assertNotNull(ediOrder.getMessageHeader());
461        assertNotNull(ediOrder.getSenderAndReceiver());
462        assertNotNull(ediOrder.getSeperators());
463        assertNotNull(ediOrder.getSummary());
464        assertNotNull(ediOrder.getTrailer());
465
466
467    }
468
469    /**
470     * This method is used to generate SenderAndReceiverConstant POJO.
471     */
472    @Test
473    public void testGenerateSenderAndReceiverConstantPojo() {
474        SendersAndReceiversConstant sendersAndReceiversConstant = SendersAndReceiverFixture.SendersAndReceiversConstant.
475                createSenderAndReceiverConstant(SendersAndReceiversConstant.class);
476        assertNotNull(sendersAndReceiversConstant);
477    }
478
479    /**
480     * This method is used to generate SenderInformation POJO.
481     */
482    @Test
483    public void testGenerateSenderInformationPojo() {
484        SenderInformation senderInformation = SendersAndReceiverFixture.SenderInformation.
485                createSenderInformation(SenderInformation.class);
486        assertNotNull(senderInformation);
487    }
488
489    /**
490     * This method is used to generate ReceiverInformation POJO.
491     */
492    @Test
493    public void testGenerateReceiverInformationPojo() {
494        ReceiverInformation receiverInformation = SendersAndReceiverFixture.ReceiverInformation.
495                createReceiverInformation(ReceiverInformation.class);
496        assertNotNull(receiverInformation);
497    }
498
499    /**
500     * This method is used to generate Schedule POJO.
501     */
502    @Test
503    public void testGenerateSchedulePojo() {
504        Schedule schedule = SendersAndReceiverFixture.Schedule.
505                createSchedule(Schedule.class);
506        assertNotNull(schedule);
507    }
508
509    /**
510     * This method is used to generate SenderAndReceiver POJO.
511     */
512    @Test
513    public void testGenerateSenderAndReceiverPojo() {
514        EDIOrderFixture ediOrderFixture = new EDIOrderFixture();
515        SenderAndReceiver senderAndReceiver = ediOrderFixture.createSenderAndReceiver(SenderAndReceiver.class);
516        assertNotNull(senderAndReceiver);
517    }
518
519    /**
520     * This method is used to generate MessageTypeInformation POJO.
521     */
522    @Test
523    public void testGenerateMessageTypeInformationPojo() {
524        MesssageTypeInformation messsageTypeInformation = MessageHeaderFixture.MesssageTypeInformation.
525                createMesssageTypeInformation(MesssageTypeInformation.class);
526        assertNotNull(messsageTypeInformation);
527    }
528
529    /**
530     * This method is used to generate MessageHeader POJO.
531     */
532    @Test
533    public void testGenerateMessageHeaderPojo() {
534        EDIOrderFixture ediOrderFixture = new EDIOrderFixture();
535        MessageHeader messageHeader = ediOrderFixture.createMessageHeader(MessageHeader.class);
536        assertNotNull(messageHeader);
537    }
538
539    /**
540     * This method is used to generate MessageBeginning POJO.
541     */
542    @Test
543    public void testGenerateMessageBeginningPojo() {
544        MessageBeginning messageBeginning = MessageFixture.MessageBeginning.
545                createMessageBeginningPojo(MessageBeginning.class);
546        assertNotNull(messageBeginning);
547    }
548
549    /**
550     * This method is used to generate MessageCreationInformation POJO.
551     */
552    @Test
553    public void testGenerateMessageCreationInformationPojo() {
554        MessageCreationInformation messageCreationInformation = MessageFixture.MessageCreationInformation.
555                createMessageCreationInformationPojo(MessageCreationInformation.class);
556        assertNotNull(messageCreationInformation);
557    }
558
559    /**
560     * This method is used to generate BuyerPartyQualifier POJO.
561     */
562    @Test
563    public void testGenerateBuyerPartyQualifierPojo() {
564        BuyerPartyQualifier buyerPartyQualifier = MessageFixture.BuyerPartyQualifier.
565                createBuyerPartyQualifierPojo(BuyerPartyQualifier.class);
566        assertNotNull(buyerPartyQualifier);
567    }
568
569    /**
570     * This method is used to generate MessageReference POJO.
571     */
572    @Test
573    public void testGenerateMessageReferencePojo() {
574        MessageReference messageReference = MessageFixture.MessageReference.
575                createMessageReferencePojo(MessageReference.class);
576        assertNotNull(messageReference);
577    }
578
579    /**
580     * This method is used to generate SupplierPartyQualifier POJO.
581     */
582    @Test
583    public void testGenerateSupplierPartyQualifierPojo() {
584        SupplierPartyQualifier supplierPartyQualifier = MessageFixture.SupplierPartyQualifier.
585                createSupplierPartyQualifierPojo(SupplierPartyQualifier.class);
586        assertNotNull(supplierPartyQualifier);
587    }
588
589    /**
590     * This method is used to generate CurrencyDetails POJO.
591     */
592    @Test
593    public void testGenerateCurrencyDetailsPojo() {
594        CurrencyDetails currencyDetails = MessageFixture.CurrencyDetails.
595                createCurrencyDetailsPojo(CurrencyDetails.class);
596        assertNotNull(currencyDetails);
597    }
598
599    /**
600     * This method is used to generate Message POJO.
601     */
602    @Test
603    public void testGenerateMessagePojo() {
604        EDIOrderFixture ediOrderFixture = new EDIOrderFixture();
605        Message message = ediOrderFixture.createMessage(Message.class);
606        assertNotNull(message);
607    }
608
609
610    @Test
611    public void testGeneratePojosToXMLFromOrders() throws Exception {
612        EDIOrder ediOrder = new EDIOrder();
613        EDIOrderFixture ediOrderFixture = new EDIOrderFixture();
614        SenderAndReceiver senderAndReceiver = ediOrderFixture.createSenderAndReceiver(SenderAndReceiver.class);
615        MessageHeader messageHeader = ediOrderFixture.createMessageHeader(MessageHeader.class);
616        Message message = ediOrderFixture.createMessage(Message.class);
617        LineItemOrder lineItemOrder = ediOrderFixture.createLineItemOrder(LineItemOrder.class);
618        Summary summary = ediOrderFixture.createSummaryOrder(Summary.class);
619
620        ediOrder.setSenderAndReceiver(senderAndReceiver);
621        ediOrder.setMessageHeader(messageHeader);
622        ediOrder.setMessage(message);
623        ediOrder.addLineItemOrder(lineItemOrder);
624        ediOrder.setSummary(summary);
625
626        EDIOrder ediOrder1 = new EDIOrder();
627
628        SenderAndReceiver senderAndReceiver1 = new SenderAndReceiver();
629
630        MessageHeader messageHeader1 = new MessageHeader();
631        Message message1 = new Message();
632        LineItemOrder lineItemOrder1 = new LineItemOrder();
633        Summary summary1 = new Summary();
634
635        ediOrder1.setSenderAndReceiver(senderAndReceiver1);
636        ediOrder1.setMessageHeader(messageHeader1);
637        ediOrder1.setMessage(message1);
638        ediOrder1.addLineItemOrder(lineItemOrder1);
639        ediOrder1.setSummary(summary1);
640
641        List<EDIOrder> ediOrderList = new ArrayList<EDIOrder>();
642        ediOrderList.add(ediOrder);
643
644        ediOrderList.add(ediOrder1);
645
646        EDIOrders ediOrders = new EDIOrders();
647        ediOrders.setOrders(ediOrderList);
648
649
650        OLETranscationalRecordGenerator oleTranscationalRecordGenerator = new OLETranscationalRecordGenerator();
651        assertNotNull(ediOrder);
652        String ediXml = oleTranscationalRecordGenerator.toXml(ediOrders);
653        LOG.info(ediXml);
654        LOG.info(ediXml);
655    }
656
657
658    @Test
659    public void testGenerateXMLFromOrders() throws Exception {
660        URL resource = getClass().getResource("EDIOrders.xml");
661        String xmlContent = new FileUtil().readFile(new File(resource.toURI()));
662        OLETranscationalRecordGenerator oleTranscationalRecordGenerator = new OLETranscationalRecordGenerator();
663
664        EDIOrders eDIOrders = oleTranscationalRecordGenerator.fromXml(xmlContent);
665        assertNotNull(eDIOrders);
666
667        for (int i = 0; i < eDIOrders.getOrders().size(); i++) {
668            LOG.info(eDIOrders.getOrders().get(i).toString());
669        }
670
671
672    }
673
674}