xmlconv2 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. data/History.txt +6 -0
  2. data/LICENCE.txt +339 -0
  3. data/Manifest.txt +107 -0
  4. data/README.txt +25 -0
  5. data/Rakefile +28 -0
  6. data/bin/admin +65 -0
  7. data/bin/xmlconvd +19 -0
  8. data/data/grammar/i2.grammar +73 -0
  9. data/src/conversion/bdd_geh.rb +281 -0
  10. data/src/conversion/bdd_i2.rb +102 -0
  11. data/src/conversion/bdd_xml.rb +242 -0
  12. data/src/conversion/geh_bdd.rb +165 -0
  13. data/src/conversion/i2_bdd.rb +271 -0
  14. data/src/conversion/xml_bdd.rb +125 -0
  15. data/src/custom/lookandfeel.rb +47 -0
  16. data/src/i2/address.rb +33 -0
  17. data/src/i2/date.rb +37 -0
  18. data/src/i2/document.rb +26 -0
  19. data/src/i2/header.rb +24 -0
  20. data/src/i2/order.rb +44 -0
  21. data/src/i2/parser.rb +25 -0
  22. data/src/i2/position.rb +37 -0
  23. data/src/i2/record.rb +11 -0
  24. data/src/model/address.rb +20 -0
  25. data/src/model/agreement.rb +10 -0
  26. data/src/model/bdd.rb +26 -0
  27. data/src/model/bsr.rb +16 -0
  28. data/src/model/delivery.rb +15 -0
  29. data/src/model/delivery_item.rb +18 -0
  30. data/src/model/freetext_container.rb +26 -0
  31. data/src/model/id_container.rb +15 -0
  32. data/src/model/invoice.rb +18 -0
  33. data/src/model/invoice_item.rb +11 -0
  34. data/src/model/item.rb +19 -0
  35. data/src/model/item_container.rb +15 -0
  36. data/src/model/name.rb +27 -0
  37. data/src/model/part_info.rb +10 -0
  38. data/src/model/part_info_container.rb +15 -0
  39. data/src/model/party.rb +23 -0
  40. data/src/model/party_container.rb +20 -0
  41. data/src/model/price.rb +10 -0
  42. data/src/model/price_container.rb +18 -0
  43. data/src/model/transaction.rb +28 -0
  44. data/src/state/global.rb +28 -0
  45. data/src/state/global_predefine.rb +11 -0
  46. data/src/state/login.rb +38 -0
  47. data/src/state/transaction.rb +13 -0
  48. data/src/state/transactions.rb +130 -0
  49. data/src/util/application.rb +143 -0
  50. data/src/util/destination.rb +130 -0
  51. data/src/util/invoicer.rb +72 -0
  52. data/src/util/known_user.rb +16 -0
  53. data/src/util/polling_manager.rb +78 -0
  54. data/src/util/session.rb +23 -0
  55. data/src/util/transaction.rb +105 -0
  56. data/src/util/validator.rb +20 -0
  57. data/src/view/foot.rb +27 -0
  58. data/src/view/head.rb +13 -0
  59. data/src/view/login.rb +36 -0
  60. data/src/view/navigation.rb +30 -0
  61. data/src/view/navigationlink.rb +21 -0
  62. data/src/view/pager.rb +73 -0
  63. data/src/view/preformatted.rb +39 -0
  64. data/src/view/template.rb +17 -0
  65. data/src/view/transaction.rb +42 -0
  66. data/src/view/transactions.rb +90 -0
  67. data/test/mock.rb +149 -0
  68. data/test/suite.rb +16 -0
  69. data/test/test_conversion/bdd_geh.rb +533 -0
  70. data/test/test_conversion/bdd_i2.rb +314 -0
  71. data/test/test_conversion/bdd_xml.rb +556 -0
  72. data/test/test_conversion/geh_bdd.rb +372 -0
  73. data/test/test_conversion/i2_bdd.rb +804 -0
  74. data/test/test_conversion/xml_bdd.rb +203 -0
  75. data/test/test_i2/address.rb +88 -0
  76. data/test/test_i2/date.rb +49 -0
  77. data/test/test_i2/document.rb +62 -0
  78. data/test/test_i2/header.rb +39 -0
  79. data/test/test_i2/order.rb +94 -0
  80. data/test/test_i2/parser.rb +309 -0
  81. data/test/test_i2/position.rb +65 -0
  82. data/test/test_integration/geh_i2.rb +312 -0
  83. data/test/test_integration/i2_geh.rb +449 -0
  84. data/test/test_integration/i2_xml.rb +162 -0
  85. data/test/test_integration/xml_i2.rb +254 -0
  86. data/test/test_model/address.rb +35 -0
  87. data/test/test_model/agreement.rb +22 -0
  88. data/test/test_model/bdd.rb +55 -0
  89. data/test/test_model/bsr.rb +38 -0
  90. data/test/test_model/delivery.rb +79 -0
  91. data/test/test_model/delivery_item.rb +52 -0
  92. data/test/test_model/freetext_container.rb +45 -0
  93. data/test/test_model/invoice.rb +65 -0
  94. data/test/test_model/invoice_item.rb +41 -0
  95. data/test/test_model/name.rb +57 -0
  96. data/test/test_model/part_info.rb +24 -0
  97. data/test/test_model/party.rb +96 -0
  98. data/test/test_model/price.rb +24 -0
  99. data/test/test_util/application.rb +168 -0
  100. data/test/test_util/destination.rb +197 -0
  101. data/test/test_util/invoicer.rb +36 -0
  102. data/test/test_util/polling_manager.rb +111 -0
  103. data/test/test_util/transaction.rb +129 -0
  104. data/user-stories/UserStories_XmlConv2.txt +381 -0
  105. data/user-stories/doku/ABB.incoming.HTTP.invoice.xml +315 -0
  106. data/user-stories/doku/ABB.received.xml +259 -0
  107. data/user-stories/doku/BO_OrderProcessing.sxw +0 -0
  108. metadata +195 -0
@@ -0,0 +1,449 @@
1
+ #!/usr/bin/env ruby
2
+ # IntegrationTestI2Geh -- xmlconv2 -- 12.05.2006 -- hwyss@ywesee.com
3
+
4
+ $: << File.expand_path('..', File.dirname(__FILE__))
5
+ $: << File.expand_path('../../src', File.dirname(__FILE__))
6
+
7
+ require 'test/unit'
8
+ require 'util/transaction'
9
+ require 'util/destination'
10
+ require 'conversion/bdd_geh'
11
+ require 'conversion/i2_bdd'
12
+ require 'mock'
13
+
14
+ module XmlConv
15
+ module Util
16
+ class DestinationHttp < Destination
17
+ HTTP_CLASS = Mock.new('DestinationHttp::HTTP_CLASS')
18
+ end
19
+ end
20
+ module Integration
21
+ class TestI2Geh < Test::Unit::TestCase
22
+ def test_i2_xml_confirm
23
+ src = <<-EOS
24
+ "00" "Sender Identification" "Recipient Identification"
25
+ "20040628" "1159" "CONFIRM" "1"
26
+ "01" "456" "Receipt-Number" "20040627" "Order Number"
27
+ "Commission Number" "OC" "Employee"
28
+ "02" "BY" "Name1" "Name2" "Street" "City" "AddressCode" "Country"
29
+ "02" "SE" "Name1" "Name2" "Street" "City" "AddressCode" "Country"
30
+ "02" "DP" "Name1" "Name2" "Street" "City" "AddressCode" "Country"
31
+ "05" "A single Header-Text"
32
+ "05" "Another single Header-Text"
33
+ "10" "10" "EAN13" "IdBuyer" "2" "20040630"
34
+ "1" "2" "0.1" "0.2" "0.2" "0.4" "0.7" "1.4"
35
+ "10" "20" "EAN13" "IdBuyer" "2" "20040630"
36
+ "1" "2" "0.1" "0.2" "0.2" "0.4" "0.7" "1.4"
37
+ "10" "30" "EAN13" "IdBuyer" "2" "20040630"
38
+ "1" "2" "0.1" "0.2" "0.2" "0.4" "0.7" "1.4"
39
+ "90" "4.2" "7.6" "0.32" "4.52" "Agreement"
40
+ EOS
41
+ ast = Conversion::I2Bdd.parse(src)
42
+ bdd = Conversion::I2Bdd.convert(ast)
43
+ conversion = Conversion::BddGeh.convert(bdd)
44
+ assert_instance_of(Array, conversion)
45
+ assert_equal(1, conversion.size)
46
+ xml = conversion.first
47
+ assert_instance_of(REXML::Document, xml)
48
+ expected = <<-EOS
49
+ <?xml version='1.0' encoding='UTF-8'?>
50
+
51
+ <OrderResponse>
52
+ <OrderResponseHeader>
53
+ <OrderResponseNumber>
54
+ <BuyerOrderResponseNumber>Order Number</BuyerOrderResponseNumber>
55
+ </OrderResponseNumber>
56
+ <OrderReference>
57
+ <Reference>
58
+ <RefNum>Commission Number</RefNum>
59
+ </Reference>
60
+ </OrderReference>
61
+ <OrderResponseIssueDate>20040627000000</OrderResponseIssueDate>
62
+ <SellerParty>
63
+ <Party>
64
+ <PartyID>
65
+ <Identifier>
66
+ <Ident>663</Ident>
67
+ </Identifier>
68
+ </PartyID>
69
+ <NameAddress>
70
+ <Name1>Name1</Name1>
71
+ <Name2>Name2</Name2>
72
+ <Street>Street</Street>
73
+ <PostalCode>AddressCode</PostalCode>
74
+ <City>City</City>
75
+ </NameAddress>
76
+ </Party>
77
+ </SellerParty>
78
+ <BuyerParty>
79
+ <Party>
80
+ <NameAddress>
81
+ <Name1>Name1</Name1>
82
+ <Name2>Name2</Name2>
83
+ <Street>Street</Street>
84
+ <PostalCode>AddressCode</PostalCode>
85
+ <City>City</City>
86
+ </NameAddress>
87
+ <OrderContact>
88
+ <Contact>
89
+ <ContactName>Employee</ContactName>
90
+ </Contact>
91
+ </OrderContact>
92
+ </Party>
93
+ </BuyerParty>
94
+ <ShipToParty>
95
+ <Party>
96
+ <NameAddress>
97
+ <Name1>Name1</Name1>
98
+ <Name2>Name2</Name2>
99
+ <Street>Street</Street>
100
+ <PostalCode>AddressCode</PostalCode>
101
+ <City>City</City>
102
+ </NameAddress>
103
+ <OrderContact>
104
+ <Contact>
105
+ <ContactName>Employee</ContactName>
106
+ </Contact>
107
+ </OrderContact>
108
+ </Party>
109
+ </ShipToParty>
110
+ </OrderResponseHeader>
111
+ <OrderResponseDetail>
112
+ <ListOfOrderResponseItemDetail>
113
+ <OrderResponseItemDetail>
114
+ <BaseItemDetail>
115
+ <LineItemNum>
116
+ <BuyerLineItemNum>10</BuyerLineItemNum>
117
+ </LineItemNum>
118
+ <ItemIdentifiers>
119
+ <PartNumbers>
120
+ <BuyerPartNumber>
121
+ <PartNum>
122
+ <PartID>IdBuyer</PartID>
123
+ </PartNum>
124
+ </BuyerPartNumber>
125
+ <SellerPartNumber>
126
+ <PartNum>
127
+ <PartID>EAN13</PartID>
128
+ </PartNum>
129
+ </SellerPartNumber>
130
+ </PartNumbers>
131
+ </ItemIdentifiers>
132
+ <TotalQuantity>
133
+ <Quantity>
134
+ <QuantityValue>2</QuantityValue>
135
+ <UnitOfMeasurement>
136
+ <UOMCoded>EA</UOMCoded>
137
+ </UnitOfMeasurement>
138
+ </Quantity>
139
+ </TotalQuantity>
140
+ </BaseItemDetail>
141
+ <PricingDetail>
142
+ <ListOfPrice>
143
+ <Price>
144
+ <UnitPrice>
145
+ <Currency>
146
+ <CurrencyCoded>CHF</CurrencyCoded>
147
+ </Currency>
148
+ <UnitPriceValue>1.00</UnitPriceValue>
149
+ </UnitPrice>
150
+ </Price>
151
+ </ListOfPrice>
152
+ <TotalValue>
153
+ <MonetaryValue>
154
+ <MonetaryAmount>2.00</MonetaryAmount>
155
+ </MonetaryValue>
156
+ </TotalValue>
157
+ </PricingDetail>
158
+ <DeliveryDetail>
159
+ <ListOfScheduleLine>
160
+ <ScheduleLine>
161
+ <RequestedDeliveryDate>20040630</RequestedDeliveryDate>
162
+ </ScheduleLine>
163
+ </ListOfScheduleLine>
164
+ </DeliveryDetail>
165
+ </OrderResponseItemDetail>
166
+ <OrderResponseItemDetail>
167
+ <BaseItemDetail>
168
+ <LineItemNum>
169
+ <BuyerLineItemNum>20</BuyerLineItemNum>
170
+ </LineItemNum>
171
+ <ItemIdentifiers>
172
+ <PartNumbers>
173
+ <BuyerPartNumber>
174
+ <PartNum>
175
+ <PartID>IdBuyer</PartID>
176
+ </PartNum>
177
+ </BuyerPartNumber>
178
+ <SellerPartNumber>
179
+ <PartNum>
180
+ <PartID>EAN13</PartID>
181
+ </PartNum>
182
+ </SellerPartNumber>
183
+ </PartNumbers>
184
+ </ItemIdentifiers>
185
+ <TotalQuantity>
186
+ <Quantity>
187
+ <QuantityValue>2</QuantityValue>
188
+ <UnitOfMeasurement>
189
+ <UOMCoded>EA</UOMCoded>
190
+ </UnitOfMeasurement>
191
+ </Quantity>
192
+ </TotalQuantity>
193
+ </BaseItemDetail>
194
+ <PricingDetail>
195
+ <ListOfPrice>
196
+ <Price>
197
+ <UnitPrice>
198
+ <Currency>
199
+ <CurrencyCoded>CHF</CurrencyCoded>
200
+ </Currency>
201
+ <UnitPriceValue>1.00</UnitPriceValue>
202
+ </UnitPrice>
203
+ </Price>
204
+ </ListOfPrice>
205
+ <TotalValue>
206
+ <MonetaryValue>
207
+ <MonetaryAmount>2.00</MonetaryAmount>
208
+ </MonetaryValue>
209
+ </TotalValue>
210
+ </PricingDetail>
211
+ <DeliveryDetail>
212
+ <ListOfScheduleLine>
213
+ <ScheduleLine>
214
+ <RequestedDeliveryDate>20040630</RequestedDeliveryDate>
215
+ </ScheduleLine>
216
+ </ListOfScheduleLine>
217
+ </DeliveryDetail>
218
+ </OrderResponseItemDetail>
219
+ <OrderResponseItemDetail>
220
+ <BaseItemDetail>
221
+ <LineItemNum>
222
+ <BuyerLineItemNum>30</BuyerLineItemNum>
223
+ </LineItemNum>
224
+ <ItemIdentifiers>
225
+ <PartNumbers>
226
+ <BuyerPartNumber>
227
+ <PartNum>
228
+ <PartID>IdBuyer</PartID>
229
+ </PartNum>
230
+ </BuyerPartNumber>
231
+ <SellerPartNumber>
232
+ <PartNum>
233
+ <PartID>EAN13</PartID>
234
+ </PartNum>
235
+ </SellerPartNumber>
236
+ </PartNumbers>
237
+ </ItemIdentifiers>
238
+ <TotalQuantity>
239
+ <Quantity>
240
+ <QuantityValue>2</QuantityValue>
241
+ <UnitOfMeasurement>
242
+ <UOMCoded>EA</UOMCoded>
243
+ </UnitOfMeasurement>
244
+ </Quantity>
245
+ </TotalQuantity>
246
+ </BaseItemDetail>
247
+ <PricingDetail>
248
+ <ListOfPrice>
249
+ <Price>
250
+ <UnitPrice>
251
+ <Currency>
252
+ <CurrencyCoded>CHF</CurrencyCoded>
253
+ </Currency>
254
+ <UnitPriceValue>1.00</UnitPriceValue>
255
+ </UnitPrice>
256
+ </Price>
257
+ </ListOfPrice>
258
+ <TotalValue>
259
+ <MonetaryValue>
260
+ <MonetaryAmount>2.00</MonetaryAmount>
261
+ </MonetaryValue>
262
+ </TotalValue>
263
+ </PricingDetail>
264
+ <DeliveryDetail>
265
+ <ListOfScheduleLine>
266
+ <ScheduleLine>
267
+ <RequestedDeliveryDate>20040630</RequestedDeliveryDate>
268
+ </ScheduleLine>
269
+ </ListOfScheduleLine>
270
+ </DeliveryDetail>
271
+ </OrderResponseItemDetail>
272
+ </ListOfOrderResponseItemDetail>
273
+ </OrderResponseDetail>
274
+ </OrderResponse>
275
+
276
+ EOS
277
+ assert_equal(expected, xml.to_s(1))
278
+ end
279
+ def test_i2_xml_invoice
280
+ src = <<-EOS
281
+ "00" "Plica" "Electro LAN SA" "20060522" "2300" "INVOIC" "0"
282
+ "01" "000" "Receipt-Number" "20060522" "Order Number"
283
+ "Commission Number" "OC" "TP"
284
+ "02" "SE" "PLICA AG" "" "ZUERCHERSTRASSE 350" "FRAUENFELD" "8500" "CH"
285
+ "02" "CU" "ELECTRO LAN SA" "ARTICLE ELECTRIQUE EN GROS" "RUE DE TUNNEL 67-69" "NEUCH�TEL" "2000" "CH"
286
+ "02" "EP" "GIOVANNI RUSSO" "" "" "" "" ""
287
+ "02" "BY" "ELECTRO LAN SA" "ARTICLE ELECTRIQUE EN GROS" "RUE DE TUNNEL 67-69" "NEUCH�TEL" "2000" "CH"
288
+ "02" "DP" "ELECTRO LAN SA" "ARTICLE ELECTRIQUE EN GROS" "RUE DE TUNNEL 67-69" "NEUCH�TEL" "2000" "CH"
289
+ "10" "10" "" "125.954.300" "1" "86" "86" "25.8" "25.8" "0" "0" "60.2" "60.2" "" ""
290
+ "10" "20" "" "126.276.030" "30" "268" "80.4" "0" "0" "0" "0" "268" "80.4" "" ""
291
+ "90" "140.6" "7.61" "10.7" "151.3" "10 Tage 3%, 30 Tage 2%, 60 Tage netto"
292
+ EOS
293
+ ast = Conversion::I2Bdd.parse(src)
294
+ bdd = Conversion::I2Bdd.convert(ast)
295
+ conversion = Conversion::BddGeh.convert(bdd)
296
+ assert_instance_of(Array, conversion)
297
+ assert_equal(1, conversion.size)
298
+ xml = conversion.first
299
+ assert_instance_of(REXML::Document, xml)
300
+ expected = <<-EOS
301
+ <?xml version='1.0' encoding='UTF-8'?>
302
+
303
+ <Invoice>
304
+ <InvoiceHeader>
305
+ <InvoiceNumber>
306
+ <Reference>
307
+ <RefNum>Receipt-Number</RefNum>
308
+ </Reference>
309
+ </InvoiceNumber>
310
+ <InvoiceIssueDate>20060522000000</InvoiceIssueDate>
311
+ <InvoiceReferences>
312
+ <PurchaseOrderReference>
313
+ <PurchaseOrderNumber>
314
+ <Reference>
315
+ <RefNum>Commission Number</RefNum>
316
+ </Reference>
317
+ </PurchaseOrderNumber>
318
+ </PurchaseOrderReference>
319
+ </InvoiceReferences>
320
+ <SellerParty>
321
+ <Party>
322
+ <PartyID>
323
+ <Identifier>
324
+ <Ident>663</Ident>
325
+ </Identifier>
326
+ </PartyID>
327
+ <NameAddress>
328
+ <Name1>PLICA AG</Name1>
329
+ <Street>ZUERCHERSTRASSE 350</Street>
330
+ <PostalCode>8500</PostalCode>
331
+ <City>FRAUENFELD</City>
332
+ </NameAddress>
333
+ </Party>
334
+ </SellerParty>
335
+ </InvoiceHeader>
336
+ <InvoiceDetail>
337
+ <ListOfInvoiceItemDetail>
338
+ <InvoiceItemDetail>
339
+ <InvoiceBaseItemDetail>
340
+ <LineItemNum>
341
+ <BuyerLineItemNum>10</BuyerLineItemNum>
342
+ </LineItemNum>
343
+ <ItemIdentifiers>
344
+ <PartNumbers>
345
+ <BuyerPartNumber>
346
+ <PartNum>
347
+ <PartID>125.954.300</PartID>
348
+ </PartNum>
349
+ </BuyerPartNumber>
350
+ </PartNumbers>
351
+ </ItemIdentifiers>
352
+ <TotalQuantity>
353
+ <Quantity>
354
+ <QuantityValue>1</QuantityValue>
355
+ <UnitOfMeasurement>
356
+ <UOMCoded>EA</UOMCoded>
357
+ </UnitOfMeasurement>
358
+ </Quantity>
359
+ </TotalQuantity>
360
+ </InvoiceBaseItemDetail>
361
+ <InvoicePricingDetail>
362
+ <ListOfPrice>
363
+ <Price>
364
+ <UnitPrice>
365
+ <Currency>
366
+ <CurrencyCoded>CHF</CurrencyCoded>
367
+ </Currency>
368
+ <UnitPriceValue>86.00</UnitPriceValue>
369
+ </UnitPrice>
370
+ </Price>
371
+ </ListOfPrice>
372
+ <InvoiceCurrencyTotalValue>
373
+ <MonetaryValue>
374
+ <MonetaryAmount>86.00</MonetaryAmount>
375
+ </MonetaryValue>
376
+ </InvoiceCurrencyTotalValue>
377
+ </InvoicePricingDetail>
378
+ </InvoiceItemDetail>
379
+ <InvoiceItemDetail>
380
+ <InvoiceBaseItemDetail>
381
+ <LineItemNum>
382
+ <BuyerLineItemNum>20</BuyerLineItemNum>
383
+ </LineItemNum>
384
+ <ItemIdentifiers>
385
+ <PartNumbers>
386
+ <BuyerPartNumber>
387
+ <PartNum>
388
+ <PartID>126.276.030</PartID>
389
+ </PartNum>
390
+ </BuyerPartNumber>
391
+ </PartNumbers>
392
+ </ItemIdentifiers>
393
+ <TotalQuantity>
394
+ <Quantity>
395
+ <QuantityValue>30</QuantityValue>
396
+ <UnitOfMeasurement>
397
+ <UOMCoded>EA</UOMCoded>
398
+ </UnitOfMeasurement>
399
+ </Quantity>
400
+ </TotalQuantity>
401
+ </InvoiceBaseItemDetail>
402
+ <InvoicePricingDetail>
403
+ <ListOfPrice>
404
+ <Price>
405
+ <UnitPrice>
406
+ <Currency>
407
+ <CurrencyCoded>CHF</CurrencyCoded>
408
+ </Currency>
409
+ <UnitPriceValue>268.00</UnitPriceValue>
410
+ </UnitPrice>
411
+ </Price>
412
+ </ListOfPrice>
413
+ <InvoiceCurrencyTotalValue>
414
+ <MonetaryValue>
415
+ <MonetaryAmount>80.40</MonetaryAmount>
416
+ </MonetaryValue>
417
+ </InvoiceCurrencyTotalValue>
418
+ </InvoicePricingDetail>
419
+ </InvoiceItemDetail>
420
+ </ListOfInvoiceItemDetail>
421
+ </InvoiceDetail>
422
+ <InvoiceSummary>
423
+ <NumberOfLines>2</NumberOfLines>
424
+ <InvoiceTotals>
425
+ <NetValue>
426
+ <MonetaryValue>
427
+ <MonetaryAmount>140.60</MonetaryAmount>
428
+ </MonetaryValue>
429
+ </NetValue>
430
+ <TotalTax>
431
+ <MonetaryValue>
432
+ <MonetaryAmount>10.70</MonetaryAmount>
433
+ </MonetaryValue>
434
+ </TotalTax>
435
+ <TotalAmountPlusTax>
436
+ <MonetaryValue>
437
+ <MonetaryAmount>151.30</MonetaryAmount>
438
+ </MonetaryValue>
439
+ </TotalAmountPlusTax>
440
+ </InvoiceTotals>
441
+ </InvoiceSummary>
442
+ </Invoice>
443
+
444
+ EOS
445
+ assert_equal(expected, xml.to_s(1))
446
+ end
447
+ end
448
+ end
449
+ end
@@ -0,0 +1,162 @@
1
+ #!/usr/bin/env ruby
2
+ # IntegrationTestI2Xml -- xmlconv2 -- 30.06.2004 -- hwyss@ywesee.com
3
+
4
+ $: << File.expand_path('..', File.dirname(__FILE__))
5
+ $: << File.expand_path('../../src', File.dirname(__FILE__))
6
+
7
+ require 'test/unit'
8
+ require 'util/transaction'
9
+ require 'util/destination'
10
+ require 'conversion/bdd_xml'
11
+ require 'conversion/i2_bdd'
12
+ require 'mock'
13
+
14
+ module XmlConv
15
+ module Util
16
+ class DestinationHttp < Destination
17
+ HTTP_CLASS = Mock.new('DestinationHttp::HTTP_CLASS')
18
+ end
19
+ end
20
+ module Integration
21
+ class TestI2Xml < Test::Unit::TestCase
22
+ def test_i2_xml_confirm
23
+ src = <<-EOS
24
+ "00" "Sender Identification" "Recipient Identification"
25
+ "20040628" "1159" "CONFIRM" "1"
26
+ "01" "456" "Receipt-Number" "20040627" "Order Number"
27
+ "Commission Number" "OC" "Employee"
28
+ "02" "BY" "Name1" "Name2" "Street" "City" "AddressCode" "Country"
29
+ "02" "SE" "Name1" "Name2" "Street" "City" "AddressCode" "Country"
30
+ "02" "DP" "Name1" "Name2" "Street" "City" "AddressCode" "Country"
31
+ "05" "A single Header-Text"
32
+ "05" "Another single Header-Text"
33
+ "10" "10" "EAN13" "IdBuyer" "2" "20040630"
34
+ "1" "2" "0.1" "0.2" "0.2" "0.4" "0.7" "1.4"
35
+ "10" "10" "EAN13" "IdBuyer" "2" "20040630"
36
+ "1" "2" "0.1" "0.2" "0.2" "0.4" "0.7" "1.4"
37
+ "10" "10" "EAN13" "IdBuyer" "2" "20040630"
38
+ "1" "2" "0.1" "0.2" "0.2" "0.4" "0.7" "1.4"
39
+ "90" "4.2" "7.6" "0.32" "4.52" "Agreement"
40
+ EOS
41
+ ast = Conversion::I2Bdd.parse(src)
42
+ bdd = Conversion::I2Bdd.convert(ast)
43
+ xml = Conversion::BddXml.convert(bdd)
44
+ assert_instance_of(REXML::Document, xml)
45
+ expected = <<-EOS
46
+ <?xml version='1.0' encoding='UTF-8'?>
47
+
48
+ <!DOCTYPE BDD SYSTEM "ABB BDD.dtd">
49
+ <BDD>
50
+ <BSR>
51
+ <Timestamp Zone='+2'>20040628115900</Timestamp>
52
+ <Verb>Return</Verb>
53
+ <Noun>Status</Noun>
54
+ <Party Role='Customer' Version='2'>
55
+ <Name>Recipient Identification</Name>
56
+ </Party>
57
+ </BSR>
58
+ <Delivery>
59
+ <Status Date='20040627'>Confirmed</Status>
60
+ <DeliveryId Domain='Customer'>Commission Number</DeliveryId>
61
+ <DeliveryId Domain='ACC'>Order Number</DeliveryId>
62
+ <Party Role='Seller' Version='2'>
63
+ <Address>
64
+ <AddressLine>Name1</AddressLine>
65
+ <AddressLine>Name2</AddressLine>
66
+ <AddressLine>Street</AddressLine>
67
+ <City>City</City>
68
+ <ZipCode Domain='Country'>AddressCode</ZipCode>
69
+ </Address>
70
+ </Party>
71
+ <Party Role='Customer' Version='2'>
72
+ <Party Role='Employee' Version='2'>
73
+ <Name>Employee</Name>
74
+ </Party>
75
+ <Party Role='BillTo' Version='2'>
76
+ <Address>
77
+ <AddressLine>Name1</AddressLine>
78
+ <AddressLine>Name2</AddressLine>
79
+ <AddressLine>Street</AddressLine>
80
+ <City>City</City>
81
+ <ZipCode Domain='Country'>AddressCode</ZipCode>
82
+ </Address>
83
+ </Party>
84
+ <Party Role='ShipTo' Version='2'>
85
+ <Address>
86
+ <AddressLine>Name1</AddressLine>
87
+ <AddressLine>Name2</AddressLine>
88
+ <AddressLine>Street</AddressLine>
89
+ <City>City</City>
90
+ <ZipCode Domain='Country'>AddressCode</ZipCode>
91
+ </Address>
92
+ </Party>
93
+ </Party>
94
+ <DeliveryItem>
95
+ <LineNo>10</LineNo>
96
+ <PartId>
97
+ <IdentNo Domain='ET-Nummer'>IdBuyer</IdentNo>
98
+ <IdentNo Domain='EAN-Nummer'>EAN13</IdentNo>
99
+ </PartId>
100
+ <Qty>2</Qty>
101
+ <Price Purpose='NettoPreis'>1.00</Price>
102
+ <Price Purpose='NettoPreisME'>2.00</Price>
103
+ <Price Purpose='Grundrabatt'>0.10</Price>
104
+ <Price Purpose='GrundrabattME'>0.20</Price>
105
+ <Price Purpose='Sonderrabatt'>0.20</Price>
106
+ <Price Purpose='SonderrabattME'>0.40</Price>
107
+ <Price Purpose='BruttoPreis'>0.70</Price>
108
+ <Price Purpose='BruttoPreisME'>1.40</Price>
109
+ <DeliveryDate>20040630</DeliveryDate>
110
+ </DeliveryItem>
111
+ <DeliveryItem>
112
+ <LineNo>10</LineNo>
113
+ <PartId>
114
+ <IdentNo Domain='ET-Nummer'>IdBuyer</IdentNo>
115
+ <IdentNo Domain='EAN-Nummer'>EAN13</IdentNo>
116
+ </PartId>
117
+ <Qty>2</Qty>
118
+ <Price Purpose='NettoPreis'>1.00</Price>
119
+ <Price Purpose='NettoPreisME'>2.00</Price>
120
+ <Price Purpose='Grundrabatt'>0.10</Price>
121
+ <Price Purpose='GrundrabattME'>0.20</Price>
122
+ <Price Purpose='Sonderrabatt'>0.20</Price>
123
+ <Price Purpose='SonderrabattME'>0.40</Price>
124
+ <Price Purpose='BruttoPreis'>0.70</Price>
125
+ <Price Purpose='BruttoPreisME'>1.40</Price>
126
+ <DeliveryDate>20040630</DeliveryDate>
127
+ </DeliveryItem>
128
+ <DeliveryItem>
129
+ <LineNo>10</LineNo>
130
+ <PartId>
131
+ <IdentNo Domain='ET-Nummer'>IdBuyer</IdentNo>
132
+ <IdentNo Domain='EAN-Nummer'>EAN13</IdentNo>
133
+ </PartId>
134
+ <Qty>2</Qty>
135
+ <Price Purpose='NettoPreis'>1.00</Price>
136
+ <Price Purpose='NettoPreisME'>2.00</Price>
137
+ <Price Purpose='Grundrabatt'>0.10</Price>
138
+ <Price Purpose='GrundrabattME'>0.20</Price>
139
+ <Price Purpose='Sonderrabatt'>0.20</Price>
140
+ <Price Purpose='SonderrabattME'>0.40</Price>
141
+ <Price Purpose='BruttoPreis'>0.70</Price>
142
+ <Price Purpose='BruttoPreisME'>1.40</Price>
143
+ <DeliveryDate>20040630</DeliveryDate>
144
+ </DeliveryItem>
145
+ <Price Purpose='SummePositionen'>4.20</Price>
146
+ <Price Purpose='MehrwertsteuerPct'>7.60</Price>
147
+ <Price Purpose='Mehrwertsteuer'>0.32</Price>
148
+ <Price Purpose='Endbetrag'>4.52</Price>
149
+ <FreeText>A single Header-Text
150
+ Another single Header-Text</FreeText>
151
+ <Agreement>
152
+ <TermsCond>Agreement</TermsCond>
153
+ </Agreement>
154
+ </Delivery>
155
+ </BDD>
156
+
157
+ EOS
158
+ assert_equal(expected, xml.to_s(1))
159
+ end
160
+ end
161
+ end
162
+ end