1 package org.kuali.ole;
2
3 import org.kuali.ole.pojo.edi.*;
4
5
6
7
8
9
10
11
12 public enum MessageFixture {
13 MessageBeginning("220",
14 "34",
15 "9", null, null
16 ),
17 MessageCreationInformation(
18 null, null, null, null, null
19 ),
20 BuyerPartyQualifier(
21 null, null, null, "BY", null
22 ),
23 MessageReference(
24 null, null, null, null, null
25 ),
26 SupplierPartyQualifier(
27 null, null, null, null, "SU"
28 ),
29 CurrencyDetails(
30 null, null, null, null, null
31 ),;
32
33
34 private String messageBeginningOrder;
35 private String messageBeginningInterchangeControlReference;
36 private String messageBeginningCodeListAgency;
37 private String buyer;
38 private String supplier;
39
40 private MessageFixture(String messageBeginningOrder, String messageBeginningInterchangeControlReference,
41 String messageBeginningCodeListAgency,
42 String buyer, String supplier) {
43 this.messageBeginningOrder = messageBeginningOrder;
44 this.messageBeginningInterchangeControlReference = messageBeginningInterchangeControlReference;
45 this.messageBeginningCodeListAgency = messageBeginningCodeListAgency;
46 this.buyer = buyer;
47 this.supplier = supplier;
48 }
49
50 public MessageBeginning createMessageBeginningPojo(Class clazz) {
51 MessageBeginning messageBeginning = null;
52 try {
53 messageBeginning = (MessageBeginning) clazz.newInstance();
54 } catch (InstantiationException e) {
55 throw new RuntimeException("MessageBeginning creation failed. class = " + clazz);
56 } catch (IllegalAccessException e) {
57 throw new RuntimeException("MessageBeginning creation failed. class = " + clazz);
58 }
59 messageBeginning.setMessageBeginningOrder(messageBeginningOrder);
60 messageBeginning.setMessageBeginningInterchangeControlReference(messageBeginningInterchangeControlReference);
61 messageBeginning.setMessageBeginningCodeListAgency(messageBeginningCodeListAgency);
62 return messageBeginning;
63 }
64
65 public MessageCreationInformation createMessageCreationInformationPojo(Class clazz) {
66 MessageCreationInformation messageCreationInformation = null;
67 try {
68 messageCreationInformation = (MessageCreationInformation) clazz.newInstance();
69 } catch (InstantiationException e) {
70 throw new RuntimeException("MessageCreationInformation creation failed. class = " + clazz);
71 } catch (IllegalAccessException e) {
72 throw new RuntimeException("MessageCreationInformation creation failed. class = " + clazz);
73 }
74
75 messageCreationInformation.setMessageCreationInfoDetails(MessageCreationInfoDetailsFixture.
76 MessageCreationInformation.createMessageCreationInfoDetails(MessageCreationInfoDetails.class));
77 return messageCreationInformation;
78 }
79
80 public BuyerPartyQualifier createBuyerPartyQualifierPojo(Class clazz) {
81 BuyerPartyQualifier buyerPartyQualifier = null;
82 try {
83 buyerPartyQualifier = (BuyerPartyQualifier) clazz.newInstance();
84 } catch (InstantiationException e) {
85 throw new RuntimeException("BuyerPartyQualifier creation failed. class = " + clazz);
86 } catch (IllegalAccessException e) {
87 throw new RuntimeException("BuyerPartyQualifier creation failed. class = " + clazz);
88 }
89 buyerPartyQualifier.setBuyer(buyer);
90 buyerPartyQualifier.setBuyerInformation(BuyerInformationFixture.
91 BuyerInformation.createBuyerInformation(BuyerInformation.class));
92 return buyerPartyQualifier;
93 }
94
95 public MessageReference createMessageReferencePojo(Class clazz) {
96 MessageReference messageReference = null;
97 try {
98 messageReference = (MessageReference) clazz.newInstance();
99 } catch (InstantiationException e) {
100 throw new RuntimeException("MessageReference creation failed. class = " + clazz);
101 } catch (IllegalAccessException e) {
102 throw new RuntimeException("MessageReference creation failed. class = " + clazz);
103 }
104 messageReference.setPartyDetails(PartyDetailsFixture.
105 PartyDetails.createPartyDetails(PartyDetails.class));
106 return messageReference;
107 }
108
109
110 public SupplierPartyQualifier createSupplierPartyQualifierPojo(Class clazz) {
111 SupplierPartyQualifier supplierPartyQualifier = null;
112 try {
113 supplierPartyQualifier = (SupplierPartyQualifier) clazz.newInstance();
114 } catch (InstantiationException e) {
115 throw new RuntimeException("SupplierPartyQualifier creation failed. class = " + clazz);
116 } catch (IllegalAccessException e) {
117 throw new RuntimeException("SupplierPartyQualifier creation failed. class = " + clazz);
118 }
119 supplierPartyQualifier.setSupplier(supplier);
120 supplierPartyQualifier.setSupplierInformation(SupplierInformationFixture.
121 SupplierInformation.createSupplierInformation(SupplierInformation.class));
122 return supplierPartyQualifier;
123 }
124
125 public CurrencyDetails createCurrencyDetailsPojo(Class clazz) {
126 CurrencyDetails currencyDetails = null;
127 try {
128 currencyDetails = (CurrencyDetails) clazz.newInstance();
129 } catch (InstantiationException e) {
130 throw new RuntimeException("CurrencyDetails creation failed. class = " + clazz);
131 } catch (IllegalAccessException e) {
132 throw new RuntimeException("CurrencyDetails creation failed. class = " + clazz);
133 }
134
135 currencyDetails.setCurrencyDetailsSupplierInformation(CurrencyDetailsSupplierInformationFixture.
136 CurrencyDetailsSupplierInformation.
137 createCurrencyDetailsSupplierInformation(CurrencyDetailsSupplierInformation.class));
138 return currencyDetails;
139 }
140 }