View Javadoc
1   package org.kuali.ole;
2   
3   import org.kuali.ole.pojo.edi.*;
4   
5   import java.util.Arrays;
6   
7   /**
8    * Created by IntelliJ IDEA.
9    * User: palanivel
10   * Date: 3/7/12
11   * Time: 8:05 PM
12   * To change this template use File | Settings | File Templates.
13   */
14  public class EDIOrderFixture {
15  
16      public SenderAndReceiver createSenderAndReceiver(Class clazz) {
17          SenderAndReceiver senderAndReceiver = null;
18          try {
19              senderAndReceiver = (SenderAndReceiver) clazz.newInstance();
20          } catch (InstantiationException e) {
21              throw new RuntimeException("SenderAndReceiver creation failed. class = " + clazz);
22          } catch (IllegalAccessException e) {
23              throw new RuntimeException("SenderAndReceiver creation failed. class = " + clazz);
24          }
25          senderAndReceiver.setSendersAndReceiversConstant(SendersAndReceiverFixture.SendersAndReceiversConstant.
26                  createSenderAndReceiverConstant(SendersAndReceiversConstant.class));
27          senderAndReceiver.setSenderInformation(SendersAndReceiverFixture.SenderInformation.
28                  createSenderInformation(SenderInformation.class));
29          senderAndReceiver.setReceiverInformation(SendersAndReceiverFixture.ReceiverInformation.
30                  createReceiverInformation(ReceiverInformation.class));
31          senderAndReceiver.setSchedule(SendersAndReceiverFixture.Schedule.
32                  createSchedule(Schedule.class));
33          senderAndReceiver.setInterChangeControlReference(SendersAndReceiverFixture.InterchangeControlReference.
34                  createInterchangeControlReference());
35  
36          return senderAndReceiver;
37      }
38  
39      public MessageHeader createMessageHeader(Class clazz) {
40          MessageHeader messageHeader = null;
41          try {
42              messageHeader = (MessageHeader) clazz.newInstance();
43          } catch (InstantiationException e) {
44              throw new RuntimeException("MessageHeader creation failed. class = " + clazz);
45          } catch (IllegalAccessException e) {
46              throw new RuntimeException("MessageHeader creation failed. class = " + clazz);
47          }
48          messageHeader.setMesssageTypeInformation(MessageHeaderFixture.MesssageTypeInformation.
49                  createMesssageTypeInformation(MesssageTypeInformation.class));
50          messageHeader.setInterchangeControlReference(MessageHeaderFixture.InterChangeControlRef.
51                  createInterchangeControlReference());
52  
53          return messageHeader;
54      }
55  
56      public Message createMessage(Class clazz) {
57          Message message = null;
58          try {
59              message = (Message) clazz.newInstance();
60          } catch (InstantiationException e) {
61              throw new RuntimeException("Message creation failed. class = " + clazz);
62          } catch (IllegalAccessException e) {
63              throw new RuntimeException("Message creation failed. class = " + clazz);
64          }
65          message.setMessageBeginning(MessageFixture.MessageBeginning.
66                  createMessageBeginningPojo(MessageBeginning.class));
67          message.setMessageCreationInformation(MessageFixture.MessageCreationInformation.
68                  createMessageCreationInformationPojo(MessageCreationInformation.class));
69          message.setBuyerPartyQualifier(MessageFixture.BuyerPartyQualifier.
70                  createBuyerPartyQualifierPojo(BuyerPartyQualifier.class));
71          message.setMessageReference(MessageFixture.MessageReference.
72                  createMessageReferencePojo(MessageReference.class));
73          message.setSupplierPartyQualifier(MessageFixture.SupplierPartyQualifier.
74                  createSupplierPartyQualifierPojo(SupplierPartyQualifier.class));
75          message.setCurrencyDetails(MessageFixture.CurrencyDetails.
76                  createCurrencyDetailsPojo(CurrencyDetails.class));
77  
78          return message;
79      }
80  
81      public LineItemOrder createLineItemOrder(Class clazz) {
82          LineItemOrder lineItemOrder = null;
83          try {
84              lineItemOrder = (LineItemOrder) clazz.newInstance();
85          } catch (InstantiationException e) {
86              throw new RuntimeException("LineItemOrder creation failed. class = " + clazz);
87          } catch (IllegalAccessException e) {
88              throw new RuntimeException("LineItemOrder creation failed. class = " + clazz);
89          }
90          lineItemOrder.addLineItem(LineItemOrderFixture.LINEITEM.createLineItemPojo(LineItem.class));
91          lineItemOrder.addProductFunction(LineItemOrderFixture.PRODUCTFUNCTION.createProductFunctionPojo(ProductFunction.class));
92          lineItemOrder.addItemDescription(LineItemOrderFixture.ITEMDESCRIPTION.createItemDescriptionPojo(ItemDescription.class));
93          lineItemOrder.addQuantityInformation(LineItemOrderFixture.QUANTITYINFORMATION.createQuantityInformationPojo(QuantityInformation.class));
94          lineItemOrder.addPriceInformation(LineItemOrderFixture.PRICEINFORMATION.createPriceInformationPojo(PriceInformation.class));
95          lineItemOrder.addBuyerReferenceInformation(LineItemOrderFixture.REFERENCEINFORMATION.createBuyerReferenceInformationPojo(BuyerReferenceInformation.class));
96          lineItemOrder.addSupplierReferenceInformation(LineItemOrderFixture.SUPPLIERSREFERENCEINFORMATION.createSupplierReferenceInformationPojo(SupplierReferenceInformation.class));
97          lineItemOrder.addFundNumberReference(LineItemOrderFixture.FUNDNUMBERREFERENCE.createFundNumberReferencePojo(FundNumberReference.class));
98          lineItemOrder.addTransportStageQualifier(LineItemOrderFixture.TRANSPORTSTAGEQUALIFIER.createTransportStageQualifierPojo(TransportStageQualifier.class));
99          return lineItemOrder;
100     }
101 
102     public Summary createSummaryOrder(Class clazz) {
103         Summary summary = null;
104         try {
105             summary = (Summary) clazz.newInstance();
106         } catch (InstantiationException e) {
107             throw new RuntimeException("Summary creation failed. class = " + clazz);
108         } catch (IllegalAccessException e) {
109             throw new RuntimeException("Summary creation failed. class = " + clazz);
110         }
111         summary.setSummarySection(SummaryFixture.SUMMARYSECTION.createSummarySectionPojo(SummarySection.class));
112         summary.addControlInfomation(SummaryFixture.CONTROLINFORMATION.createControlInfomationPojo(ControlInfomation.class));
113         summary.setUntSummary(SummaryFixture.UNT.createUNTSummaryPojo(UNTSummary.class));
114         return summary;
115     }
116 }
117 
118