xmlconv 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemtest +0 -0
- data/History.txt +6 -0
- data/LICENSE +339 -0
- data/README.txt +29 -0
- data/Rakefile +37 -0
- data/bin/admin +68 -0
- data/bin/xmlconvd +38 -0
- data/data/grammar/i2.grammar +73 -0
- data/lib/xmlconv/config.rb +61 -0
- data/lib/xmlconv/custom/lookandfeel.rb +50 -0
- data/lib/xmlconv/i2/address.rb +35 -0
- data/lib/xmlconv/i2/date.rb +41 -0
- data/lib/xmlconv/i2/document.rb +27 -0
- data/lib/xmlconv/i2/header.rb +32 -0
- data/lib/xmlconv/i2/order.rb +61 -0
- data/lib/xmlconv/i2/parser.rb +23 -0
- data/lib/xmlconv/i2/position.rb +45 -0
- data/lib/xmlconv/i2/record.rb +11 -0
- data/lib/xmlconv/model/address.rb +20 -0
- data/lib/xmlconv/model/agreement.rb +10 -0
- data/lib/xmlconv/model/bdd.rb +37 -0
- data/lib/xmlconv/model/bsr.rb +16 -0
- data/lib/xmlconv/model/delivery.rb +15 -0
- data/lib/xmlconv/model/delivery_item.rb +24 -0
- data/lib/xmlconv/model/document.rb +25 -0
- data/lib/xmlconv/model/freetext_container.rb +26 -0
- data/lib/xmlconv/model/id_container.rb +22 -0
- data/lib/xmlconv/model/invoice.rb +18 -0
- data/lib/xmlconv/model/invoice_item.rb +11 -0
- data/lib/xmlconv/model/item.rb +19 -0
- data/lib/xmlconv/model/item_container.rb +15 -0
- data/lib/xmlconv/model/name.rb +27 -0
- data/lib/xmlconv/model/part_info.rb +10 -0
- data/lib/xmlconv/model/part_info_container.rb +15 -0
- data/lib/xmlconv/model/party.rb +20 -0
- data/lib/xmlconv/model/party_container.rb +20 -0
- data/lib/xmlconv/model/price.rb +10 -0
- data/lib/xmlconv/model/price_container.rb +18 -0
- data/lib/xmlconv/model/transaction.rb +28 -0
- data/lib/xmlconv/state/global.rb +28 -0
- data/lib/xmlconv/state/global_predefine.rb +11 -0
- data/lib/xmlconv/state/login.rb +39 -0
- data/lib/xmlconv/state/transaction.rb +13 -0
- data/lib/xmlconv/state/transactions.rb +130 -0
- data/lib/xmlconv/util/application.rb +142 -0
- data/lib/xmlconv/util/autoload.rb +35 -0
- data/lib/xmlconv/util/destination.rb +249 -0
- data/lib/xmlconv/util/invoicer.rb +71 -0
- data/lib/xmlconv/util/known_user.rb +16 -0
- data/lib/xmlconv/util/mail.rb +31 -0
- data/lib/xmlconv/util/polling_manager.rb +198 -0
- data/lib/xmlconv/util/session.rb +23 -0
- data/lib/xmlconv/util/transaction.rb +133 -0
- data/lib/xmlconv/util/validator.rb +20 -0
- data/lib/xmlconv/view/foot.rb +27 -0
- data/lib/xmlconv/view/head.rb +13 -0
- data/lib/xmlconv/view/login.rb +36 -0
- data/lib/xmlconv/view/navigation.rb +30 -0
- data/lib/xmlconv/view/navigationlink.rb +21 -0
- data/lib/xmlconv/view/pager.rb +73 -0
- data/lib/xmlconv/view/preformatted.rb +54 -0
- data/lib/xmlconv/view/template.rb +17 -0
- data/lib/xmlconv/view/transaction.rb +42 -0
- data/lib/xmlconv/view/transactions.rb +90 -0
- data/lib/xmlconv.rb +3 -0
- data/test/config.rb +12 -0
- data/test/mock.rb +149 -0
- data/test/suite.rb +16 -0
- data/test/test_i2/address.rb +88 -0
- data/test/test_i2/date.rb +50 -0
- data/test/test_i2/document.rb +62 -0
- data/test/test_i2/header.rb +39 -0
- data/test/test_i2/order.rb +94 -0
- data/test/test_i2/parser.rb +312 -0
- data/test/test_i2/position.rb +65 -0
- data/test/test_model/address.rb +35 -0
- data/test/test_model/agreement.rb +22 -0
- data/test/test_model/bdd.rb +55 -0
- data/test/test_model/bsr.rb +38 -0
- data/test/test_model/delivery.rb +79 -0
- data/test/test_model/delivery_item.rb +52 -0
- data/test/test_model/freetext_container.rb +45 -0
- data/test/test_model/invoice.rb +65 -0
- data/test/test_model/invoice_item.rb +41 -0
- data/test/test_model/name.rb +57 -0
- data/test/test_model/part_info.rb +24 -0
- data/test/test_model/party.rb +96 -0
- data/test/test_model/price.rb +24 -0
- data/test/test_util/application.rb +168 -0
- data/test/test_util/destination.rb +415 -0
- data/test/test_util/invoicer.rb +42 -0
- data/test/test_util/polling_manager.rb +299 -0
- data/test/test_util/transaction.rb +130 -0
- metadata +178 -0
@@ -0,0 +1,312 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# I2::TestParser -- xmlconv2 -- 28.06.2004 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
$: << File.expand_path('..', File.dirname(__FILE__))
|
5
|
+
$: << File.expand_path('../../lib', File.dirname(__FILE__))
|
6
|
+
|
7
|
+
require 'test/unit'
|
8
|
+
require 'xmlconv/i2/parser'
|
9
|
+
require 'config'
|
10
|
+
|
11
|
+
module XmlConv
|
12
|
+
module I2
|
13
|
+
class TestParser < Test::Unit::TestCase
|
14
|
+
def setup
|
15
|
+
XmlConv::CONFIG.grammar_dir = File.expand_path('../../data/grammar',
|
16
|
+
File.dirname(__FILE__))
|
17
|
+
@parser = XmlConv::I2.cached_parser
|
18
|
+
end
|
19
|
+
def test_parser_class
|
20
|
+
assert_instance_of(GeneralizedLrParser, @parser)
|
21
|
+
end
|
22
|
+
def test_parse_header
|
23
|
+
src = <<-EOS
|
24
|
+
"00" "Sender Identification" "Recipient Identification"
|
25
|
+
"20040628" "1159" "CONFIRM" "1"
|
26
|
+
EOS
|
27
|
+
ast = @parser.parse(src)
|
28
|
+
assert_instance_of(SyntaxTree, ast)
|
29
|
+
assert_instance_of(ArrayNode, ast.records)
|
30
|
+
header = ast.records.first
|
31
|
+
assert_instance_of(SyntaxTree, header)
|
32
|
+
assert_equal('Header', header.name)
|
33
|
+
rtype = header.rtype
|
34
|
+
assert_instance_of(SyntaxTree, rtype)
|
35
|
+
assert_equal('00', rtype.value)
|
36
|
+
sender = header.sender
|
37
|
+
assert_instance_of(SyntaxTree, sender)
|
38
|
+
assert_equal('Sender Identification', sender.value)
|
39
|
+
recipient = header.recipient
|
40
|
+
assert_instance_of(SyntaxTree, recipient)
|
41
|
+
assert_equal('Recipient Identification', recipient.value)
|
42
|
+
date = header.date
|
43
|
+
assert_instance_of(SyntaxTree, date)
|
44
|
+
assert_equal('20040628', date.value)
|
45
|
+
time = header.time
|
46
|
+
assert_instance_of(SyntaxTree, time)
|
47
|
+
assert_equal('1159', time.value)
|
48
|
+
mtype = header.mtype
|
49
|
+
assert_instance_of(SyntaxTree, mtype)
|
50
|
+
assert_equal('CONFIRM', mtype.value)
|
51
|
+
test = header.test
|
52
|
+
assert_instance_of(SyntaxTree, test)
|
53
|
+
assert_equal('1', test.value)
|
54
|
+
end
|
55
|
+
def test_parse_incomplete_header
|
56
|
+
src = <<-EOS
|
57
|
+
"00" "" "" "" "" "" ""
|
58
|
+
EOS
|
59
|
+
ast = nil
|
60
|
+
assert_nothing_raised {
|
61
|
+
ast = @parser.parse(src)
|
62
|
+
}
|
63
|
+
header = ast.records.first
|
64
|
+
assert_equal('Header', header.name)
|
65
|
+
end
|
66
|
+
def test_parse_commission
|
67
|
+
# commented fields are not in the current version
|
68
|
+
src = <<-EOS
|
69
|
+
"01" "456" "Receipt-Number" "20040627" "Order Number"
|
70
|
+
"Commission Number" "OC" "Employee"
|
71
|
+
EOS
|
72
|
+
ast = @parser.parse(src)
|
73
|
+
assert_instance_of(SyntaxTree, ast)
|
74
|
+
comm = ast.records.first
|
75
|
+
assert_instance_of(SyntaxTree, comm)
|
76
|
+
assert_equal('Commission', comm.name)
|
77
|
+
assert_equal('01', comm.rtype.value)
|
78
|
+
assert_equal('456', comm.btype.value)
|
79
|
+
assert_equal('Receipt-Number', comm.receipt.value)
|
80
|
+
assert_equal('20040627', comm.rdate.value)
|
81
|
+
#assert_equal('20040629', comm.ddate.value)
|
82
|
+
assert_equal('Order Number', comm.reference.value)
|
83
|
+
assert_equal('Commission Number', comm.commission.value)
|
84
|
+
assert_equal('OC', comm.contact.value)
|
85
|
+
assert_equal('Employee', comm.employee.value)
|
86
|
+
#assert_equal('TE', comm.medium.value)
|
87
|
+
#assert_equal('0041 1 350 85 87', comm.number.value)
|
88
|
+
end
|
89
|
+
def test_parse_incomplete_commission
|
90
|
+
src = <<-EOS
|
91
|
+
"01" "" "" "" "" "" "" ""
|
92
|
+
EOS
|
93
|
+
ast = nil
|
94
|
+
assert_nothing_raised {
|
95
|
+
ast = @parser.parse(src)
|
96
|
+
}
|
97
|
+
comm = ast.records.first
|
98
|
+
assert_equal('Commission', comm.name)
|
99
|
+
end
|
100
|
+
def test_parse_address
|
101
|
+
src = <<-EOS
|
102
|
+
"02" "BY" "Name1" "Name2" "Street" "City" "AddressCode" "Country"
|
103
|
+
EOS
|
104
|
+
ast = @parser.parse(src)
|
105
|
+
assert_instance_of(SyntaxTree, ast)
|
106
|
+
addr = ast.records.first
|
107
|
+
assert_instance_of(SyntaxTree, addr)
|
108
|
+
assert_equal('Address', addr.name)
|
109
|
+
assert_equal('02', addr.rtype.value)
|
110
|
+
assert_equal('BY', addr.atype.value)
|
111
|
+
assert_equal('Name1', addr.name1.value)
|
112
|
+
assert_equal('Name2', addr.name2.value)
|
113
|
+
assert_equal('Street', addr.street.value)
|
114
|
+
assert_equal('City', addr.city.value)
|
115
|
+
assert_equal('AddressCode', addr.code.value)
|
116
|
+
assert_equal('Country', addr.country.value)
|
117
|
+
end
|
118
|
+
def test_parse_incomplete_address
|
119
|
+
src = <<-EOS
|
120
|
+
"02" "" "" "" "" "" "" ""
|
121
|
+
EOS
|
122
|
+
ast = nil
|
123
|
+
assert_nothing_raised {
|
124
|
+
ast = @parser.parse(src)
|
125
|
+
}
|
126
|
+
addr = ast.records.first
|
127
|
+
assert_equal('Address', addr.name)
|
128
|
+
end
|
129
|
+
def test_parse_header_text
|
130
|
+
src = <<-EOS
|
131
|
+
"05" "A single Header-Text"
|
132
|
+
EOS
|
133
|
+
ast = @parser.parse(src)
|
134
|
+
assert_instance_of(SyntaxTree, ast)
|
135
|
+
text = ast.records.first
|
136
|
+
assert_instance_of(SyntaxTree, text)
|
137
|
+
assert_equal('HeaderText', text.name)
|
138
|
+
assert_equal('05', text.rtype.value)
|
139
|
+
assert_equal('A single Header-Text', text.text.value)
|
140
|
+
end
|
141
|
+
def test_parse_incomplete_header_text
|
142
|
+
src = <<-EOS
|
143
|
+
"05" ""
|
144
|
+
EOS
|
145
|
+
ast = nil
|
146
|
+
assert_nothing_raised {
|
147
|
+
ast = @parser.parse(src)
|
148
|
+
}
|
149
|
+
text = ast.records.first
|
150
|
+
assert_equal('HeaderText', text.name)
|
151
|
+
end
|
152
|
+
def test_parse_position__delivery
|
153
|
+
src = <<-EOS
|
154
|
+
"10" "PositionNr" "EAN13" "IdBuyer"
|
155
|
+
"Quantity" "DeliveryDate" "PriceNetto" "PriceNetto * Quantity" "Discount"
|
156
|
+
"Discount * Quantity" "Special Discount" "Special Discount * Quantity"
|
157
|
+
"PriceBrutto" "PriceBrutto * Quantity"
|
158
|
+
EOS
|
159
|
+
# commented fields are not in the current version
|
160
|
+
ast = @parser.parse(src)
|
161
|
+
assert_instance_of(SyntaxTree, ast)
|
162
|
+
position = ast.records.first
|
163
|
+
assert_instance_of(SyntaxTree, position)
|
164
|
+
assert_equal('Position', position.name)
|
165
|
+
assert_equal('10', position.rtype.value)
|
166
|
+
assert_equal('PositionNr', position.lineno.value)
|
167
|
+
assert_equal('EAN13', position.eancode.value)
|
168
|
+
#assert_equal('IdSeller', position.sellercode.value)
|
169
|
+
assert_equal('IdBuyer', position.buyercode.value)
|
170
|
+
#assert_equal('Description 1', position.description1.value)
|
171
|
+
#assert_equal('Description 2', position.description2.value)
|
172
|
+
assert_equal('Quantity', position.qty.value)
|
173
|
+
#assert_equal('Commission', position.commission.value)
|
174
|
+
assert_equal('DeliveryDate', position.ddate.value)
|
175
|
+
#assert_equal('QuantityUnit', position.qtyunit.value)
|
176
|
+
#assert_equal('PriceUnit', position.priceunit.value)
|
177
|
+
assert_equal('PriceNetto', position.pricenettopce.value)
|
178
|
+
assert_equal('PriceNetto * Quantity', position.pricenetto.value)
|
179
|
+
assert_equal('Discount', position.discountpce.value)
|
180
|
+
assert_equal('Discount * Quantity', position.discount.value)
|
181
|
+
assert_equal('Special Discount', position.extradiscountpce.value)
|
182
|
+
assert_equal('Special Discount * Quantity', position.extradiscount.value)
|
183
|
+
assert_equal('PriceBrutto', position.pricebruttopce.value)
|
184
|
+
assert_equal('PriceBrutto * Quantity', position.pricebrutto.value)
|
185
|
+
#assert_equal('VAT', position.vat.value)
|
186
|
+
#assert_equal('OriginCountry', position.origin.value)
|
187
|
+
#assert_equal('Customs', position.customs.value)
|
188
|
+
end
|
189
|
+
def test_parse_position__invoice
|
190
|
+
src = <<-EOS
|
191
|
+
"10" "PositionNr" "EAN13" "IdBuyer"
|
192
|
+
"Quantity" "PriceNetto" "PriceNetto * Quantity" "Discount"
|
193
|
+
"Discount * Quantity" "Special Discount" "Special Discount * Quantity"
|
194
|
+
"PriceBrutto" "PriceBrutto * Quantity" "OriginCountry" "Customs"
|
195
|
+
EOS
|
196
|
+
# commented fields are not in the current version
|
197
|
+
ast = @parser.parse(src)
|
198
|
+
assert_instance_of(SyntaxTree, ast)
|
199
|
+
position = ast.records.first
|
200
|
+
assert_instance_of(SyntaxTree, position)
|
201
|
+
assert_equal('Position', position.name)
|
202
|
+
assert_equal('10', position.rtype.value)
|
203
|
+
assert_equal('PositionNr', position.lineno.value)
|
204
|
+
assert_equal('EAN13', position.eancode.value)
|
205
|
+
#assert_equal('IdSeller', position.sellercode.value)
|
206
|
+
assert_equal('IdBuyer', position.buyercode.value)
|
207
|
+
#assert_equal('Description 1', position.description1.value)
|
208
|
+
#assert_equal('Description 2', position.description2.value)
|
209
|
+
assert_equal('Quantity', position.qty.value)
|
210
|
+
#assert_equal('Commission', position.commission.value)
|
211
|
+
#assert_equal('DeliveryDate', position.ddate.value)
|
212
|
+
#assert_equal('QuantityUnit', position.qtyunit.value)
|
213
|
+
#assert_equal('PriceUnit', position.priceunit.value)
|
214
|
+
assert_equal('PriceNetto', position.pricenettopce.value)
|
215
|
+
assert_equal('PriceNetto * Quantity', position.pricenetto.value)
|
216
|
+
assert_equal('Discount', position.discountpce.value)
|
217
|
+
assert_equal('Discount * Quantity', position.discount.value)
|
218
|
+
assert_equal('Special Discount', position.extradiscountpce.value)
|
219
|
+
assert_equal('Special Discount * Quantity', position.extradiscount.value)
|
220
|
+
assert_equal('PriceBrutto', position.pricebruttopce.value)
|
221
|
+
assert_equal('PriceBrutto * Quantity', position.pricebrutto.value)
|
222
|
+
#assert_equal('VAT', position.vat.value)
|
223
|
+
assert_equal('OriginCountry', position.origin.value)
|
224
|
+
assert_equal('Customs', position.customs.value)
|
225
|
+
end
|
226
|
+
def test_parse_incomplete_position
|
227
|
+
src = <<-EOS
|
228
|
+
"10" "" "" "" "" "" "" "" "" "" "" "" "" ""
|
229
|
+
EOS
|
230
|
+
ast = nil
|
231
|
+
assert_nothing_raised {
|
232
|
+
ast = @parser.parse(src)
|
233
|
+
}
|
234
|
+
position = ast.records.first
|
235
|
+
assert_instance_of(SyntaxTree, position)
|
236
|
+
assert_equal('Position', position.name)
|
237
|
+
end
|
238
|
+
def test_parse_position_text
|
239
|
+
src = <<-EOS
|
240
|
+
"15" "A single Position-Text"
|
241
|
+
EOS
|
242
|
+
ast = @parser.parse(src)
|
243
|
+
assert_instance_of(SyntaxTree, ast)
|
244
|
+
text = ast.records.first
|
245
|
+
assert_instance_of(SyntaxTree, text)
|
246
|
+
assert_equal('PositionText', text.name)
|
247
|
+
assert_equal('15', text.rtype.value)
|
248
|
+
assert_equal('A single Position-Text', text.text.value)
|
249
|
+
end
|
250
|
+
def test_parse_incomplete_position_text
|
251
|
+
src = <<-EOS
|
252
|
+
"15" ""
|
253
|
+
EOS
|
254
|
+
ast = nil
|
255
|
+
assert_nothing_raised {
|
256
|
+
ast = @parser.parse(src)
|
257
|
+
}
|
258
|
+
text = ast.records.first
|
259
|
+
assert_equal('PositionText', text.name)
|
260
|
+
end
|
261
|
+
def test_parse_total
|
262
|
+
src = <<-EOS
|
263
|
+
"90" "Price Netto" "VAT %" "VAT Amount" "Price Brutto" "Agreement"
|
264
|
+
EOS
|
265
|
+
ast = @parser.parse(src)
|
266
|
+
assert_instance_of(SyntaxTree, ast)
|
267
|
+
total = ast.records.first
|
268
|
+
assert_instance_of(SyntaxTree, total)
|
269
|
+
assert_equal('Footer', total.name)
|
270
|
+
assert_equal('90', total.rtype.value)
|
271
|
+
assert_equal('Price Netto', total.pricenetto.value)
|
272
|
+
assert_equal('VAT %', total.vatpercent.value)
|
273
|
+
assert_equal('VAT Amount', total.vatamount.value)
|
274
|
+
assert_equal('Price Brutto', total.pricebrutto.value)
|
275
|
+
assert_equal('Agreement', total.agreement.value)
|
276
|
+
end
|
277
|
+
def test_parse_incomplete_total
|
278
|
+
src = <<-EOS
|
279
|
+
"90" "" "" "" "" ""
|
280
|
+
EOS
|
281
|
+
ast = nil
|
282
|
+
assert_nothing_raised {
|
283
|
+
ast = @parser.parse(src)
|
284
|
+
}
|
285
|
+
total = ast.records.first
|
286
|
+
assert_equal('Footer', total.name)
|
287
|
+
end
|
288
|
+
def test_parse
|
289
|
+
src = <<-EOS
|
290
|
+
"00" "Plica" "Winterhalter&Fenner" "20040630" "1621" "INVOIC" "0"
|
291
|
+
"01" "000" "00112327" "20040630" "PLVH-087/PLVH-087627" "D-473010 L" "OC" "SAD"
|
292
|
+
"02" "SE" "PLICA AG ***** TEST *********" "" "ZUERCHERSTRASSE 350" "FRAUENFELD" "8500" "CH"
|
293
|
+
"02" "CU" "WINTERHALTER + FENNER AG" "" "BIRGISTRASSE 10" "WALLISELLEN" "8304" "CH"
|
294
|
+
"02" "EP" "RUSSO GIOVANNI" "" "" "" "" ""
|
295
|
+
"02" "BY" "WINTERHALTER + FENNER AG" "" "BIRGISTRASSE 10" "WALLISELLEN" "8304" "CH"
|
296
|
+
"02" "DP" "WINTERHALTER + FENNER AG" "FILIALE LITTAU" "GROSSMATTE 11 / POSTFACH" "LITTAU" "6014" "CH"
|
297
|
+
"10" "5" "" "121.763.703" "10" "0" "0" "0" "0" "0" "0" "0" "0" "" ""
|
298
|
+
"10" "10" "" "125.001.309" "600" "115" "690" "21.85" "131.1" "0" "0" "93.15" "558.9" "CZ" "Z08151515"
|
299
|
+
"10" "15" "" "125.001.509" "60" "275" "165" "27.5" "16.5" "0" "0" "247.5" "148.5" "" ""
|
300
|
+
"10" "20" "" "125.091.409" "180" "420" "756" "0" "0" "0" "0" "420" "756" "" ""
|
301
|
+
"10" "25" "" "125.293.400" "50" "371" "185.5" "129.9" "64.95" "0" "0" "241.1" "120.55" "" ""
|
302
|
+
"10" "30" "" "125.293.600" "100" "773" "773" "270.55" "270.55" "0" "0" "502.45" "502.45" "" ""
|
303
|
+
"10" "90" "" "125.293.700" "100" "1082" "1082" "378.7" "378.7" "0" "0" "703.3" "703.3" "" ""
|
304
|
+
"90" "2789.7" "7.60" "212" "3001.7" "10 Tage 3%, 30 Tage 2%, 60 Tage netto"
|
305
|
+
EOS
|
306
|
+
assert_nothing_raised {
|
307
|
+
@parser.parse(src)
|
308
|
+
}
|
309
|
+
end
|
310
|
+
end
|
311
|
+
end
|
312
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# I2::TestPosition -- xmlconv2 -- 02.06.2004 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
$: << File.dirname(__FILE__)
|
5
|
+
$: << File.expand_path('../../lib', File.dirname(__FILE__))
|
6
|
+
|
7
|
+
require 'test/unit'
|
8
|
+
require 'xmlconv/i2/position'
|
9
|
+
require 'mock'
|
10
|
+
|
11
|
+
module XmlConv
|
12
|
+
module I2
|
13
|
+
class TestPosition < Test::Unit::TestCase
|
14
|
+
class ToSMock < Mock
|
15
|
+
def is_a?(klass)
|
16
|
+
true
|
17
|
+
end
|
18
|
+
def to_s
|
19
|
+
true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
def setup
|
23
|
+
@position = Position.new
|
24
|
+
end
|
25
|
+
def test_attr_accessors
|
26
|
+
assert_respond_to(@position, :number)
|
27
|
+
assert_respond_to(@position, :number=)
|
28
|
+
assert_respond_to(@position, :article_ean)
|
29
|
+
assert_respond_to(@position, :article_ean=)
|
30
|
+
assert_respond_to(@position, :qty)
|
31
|
+
assert_respond_to(@position, :qty=)
|
32
|
+
assert_respond_to(@position, :delivery_date)
|
33
|
+
assert_respond_to(@position, :delivery_date=)
|
34
|
+
end
|
35
|
+
def test_to_s
|
36
|
+
@position.number = '12345'
|
37
|
+
@position.article_ean = '7654321098765'
|
38
|
+
@position.qty = 123
|
39
|
+
date = ToSMock.new('Date')
|
40
|
+
date.__next(:code=) {}
|
41
|
+
@position.delivery_date = date
|
42
|
+
date.__next(:is_a?) { |klass|
|
43
|
+
assert_equal(I2::Date, klass)
|
44
|
+
true
|
45
|
+
}
|
46
|
+
date.__next(:to_s) { "540:A Date\n" }
|
47
|
+
expected = <<-EOS
|
48
|
+
500:12345
|
49
|
+
501:7654321098765
|
50
|
+
520:123
|
51
|
+
540:A Date
|
52
|
+
EOS
|
53
|
+
assert_equal(expected, @position.to_s)
|
54
|
+
end
|
55
|
+
def test_delivery_date_writer
|
56
|
+
date = Mock.new('DeliveryDate')
|
57
|
+
date.__next(:code=) { |code|
|
58
|
+
assert_equal(:delivery, code)
|
59
|
+
}
|
60
|
+
@position.delivery_date = date
|
61
|
+
date.__verify
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# TestAddress -- xmlconv2 -- 01.06.2004 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
$: << File.dirname(__FILE__)
|
5
|
+
$: << File.expand_path('../../lib', File.dirname(__FILE__))
|
6
|
+
|
7
|
+
require 'test/unit'
|
8
|
+
require 'xmlconv/model/address'
|
9
|
+
|
10
|
+
module XmlConv
|
11
|
+
module Model
|
12
|
+
class TestAddress < Test::Unit::TestCase
|
13
|
+
def setup
|
14
|
+
@address = Address.new
|
15
|
+
end
|
16
|
+
def test_attr_accessors
|
17
|
+
assert_respond_to(@address, :city)
|
18
|
+
assert_respond_to(@address, :city=)
|
19
|
+
assert_respond_to(@address, :zip_code)
|
20
|
+
assert_respond_to(@address, :zip_code=)
|
21
|
+
assert_respond_to(@address, :country)
|
22
|
+
assert_respond_to(@address, :country=)
|
23
|
+
end
|
24
|
+
def test_attr_readers
|
25
|
+
assert_respond_to(@address, :lines)
|
26
|
+
end
|
27
|
+
def test_add_line
|
28
|
+
@address.add_line('line 1')
|
29
|
+
assert_equal(['line 1'], @address.lines)
|
30
|
+
@address.add_line('line 2')
|
31
|
+
assert_equal(['line 1', 'line 2'], @address.lines)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# TestAgreement -- xmlconv2 -- 22.06.2004 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
$: << File.dirname(__FILE__)
|
5
|
+
$: << File.expand_path('../../lib', File.dirname(__FILE__))
|
6
|
+
|
7
|
+
require 'test/unit'
|
8
|
+
require 'xmlconv/model/agreement'
|
9
|
+
|
10
|
+
module XmlConv
|
11
|
+
module Model
|
12
|
+
class TestAgreement < Test::Unit::TestCase
|
13
|
+
def setup
|
14
|
+
@agreement = Agreement.new
|
15
|
+
end
|
16
|
+
def test_attr_accessors
|
17
|
+
assert_respond_to(@agreement, :terms_cond)
|
18
|
+
assert_respond_to(@agreement, :terms_cond=)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# TestBdd -- xmlconv2 -- 01.06.2004 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
$: << File.dirname(__FILE__)
|
5
|
+
$: << File.expand_path('../../lib', File.dirname(__FILE__))
|
6
|
+
|
7
|
+
require 'test/unit'
|
8
|
+
require 'xmlconv/model/bdd'
|
9
|
+
require 'flexmock'
|
10
|
+
|
11
|
+
module XmlConv
|
12
|
+
module Model
|
13
|
+
class TestBdd < Test::Unit::TestCase
|
14
|
+
def setup
|
15
|
+
@bdd = Bdd.new
|
16
|
+
end
|
17
|
+
def test_attr_accessors
|
18
|
+
assert_respond_to(@bdd, :bsr)
|
19
|
+
assert_respond_to(@bdd, :bsr=)
|
20
|
+
end
|
21
|
+
def test_attr_readers
|
22
|
+
assert_respond_to(@bdd, :deliveries)
|
23
|
+
assert_respond_to(@bdd, :invoices)
|
24
|
+
end
|
25
|
+
def test_add_delivery
|
26
|
+
delivery = FlexMock.new('Delivery')
|
27
|
+
assert_equal([], @bdd.deliveries)
|
28
|
+
@bdd.add_delivery(delivery)
|
29
|
+
assert_equal([delivery], @bdd.deliveries)
|
30
|
+
end
|
31
|
+
def test_add_invoice
|
32
|
+
invoice = FlexMock.new('Invoice')
|
33
|
+
assert_equal([], @bdd.invoices)
|
34
|
+
@bdd.add_invoice(invoice)
|
35
|
+
assert_equal([invoice], @bdd.invoices)
|
36
|
+
end
|
37
|
+
def test_invoiced_amount
|
38
|
+
assert_equal(0, @bdd.invoiced_amount)
|
39
|
+
invoice = FlexMock.new
|
40
|
+
price = FlexMock.new
|
41
|
+
@bdd.invoices.push(invoice, invoice)
|
42
|
+
invoice.should_receive(:get_price)\
|
43
|
+
.times(4).and_return { |purpose|
|
44
|
+
assert_equal('SummePositionen', purpose)
|
45
|
+
price
|
46
|
+
}
|
47
|
+
price.should_receive(:amount)\
|
48
|
+
.times(1).and_return { '123.45' }
|
49
|
+
assert_equal(246.90, @bdd.invoiced_amount)
|
50
|
+
@bdd.deliveries.push(invoice)
|
51
|
+
assert_equal(246.90, @bdd.invoiced_amount)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# TestBsr -- xmlconv2 -- 01.06.2004 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
$: << File.dirname(__FILE__)
|
5
|
+
$: << File.expand_path('../../lib', File.dirname(__FILE__))
|
6
|
+
|
7
|
+
require 'test/unit'
|
8
|
+
require 'xmlconv/model/bsr'
|
9
|
+
require 'mock'
|
10
|
+
|
11
|
+
module XmlConv
|
12
|
+
module Model
|
13
|
+
class TestBsr < Test::Unit::TestCase
|
14
|
+
def setup
|
15
|
+
@bsr = Bsr.new
|
16
|
+
end
|
17
|
+
def test_attr_readers
|
18
|
+
assert_respond_to(@bsr, :parties)
|
19
|
+
end
|
20
|
+
def test_attr_accessors
|
21
|
+
assert_respond_to(@bsr, :timestamp)
|
22
|
+
assert_respond_to(@bsr, :timestamp=)
|
23
|
+
assert_respond_to(@bsr, :noun)
|
24
|
+
assert_respond_to(@bsr, :noun=)
|
25
|
+
assert_respond_to(@bsr, :verb)
|
26
|
+
assert_respond_to(@bsr, :verb=)
|
27
|
+
end
|
28
|
+
def test_bsr_id
|
29
|
+
party = Mock.new('Party')
|
30
|
+
party.__next(:role) { 'Customer' }
|
31
|
+
party.__next(:party_id) { 'id_string' }
|
32
|
+
@bsr.add_party(party)
|
33
|
+
assert_equal('id_string', @bsr.bsr_id)
|
34
|
+
party.__verify
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# TestDelivery -- xmlconv2 -- 01.06.2004 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
$: << File.expand_path('..', File.dirname(__FILE__))
|
5
|
+
$: << File.expand_path('../../lib', File.dirname(__FILE__))
|
6
|
+
|
7
|
+
require 'test/unit'
|
8
|
+
require 'xmlconv/model/delivery'
|
9
|
+
require 'mock'
|
10
|
+
|
11
|
+
module XmlConv
|
12
|
+
module Model
|
13
|
+
class TestDelivery < Test::Unit::TestCase
|
14
|
+
def setup
|
15
|
+
@delivery = Delivery.new
|
16
|
+
end
|
17
|
+
def test_attr_accessors
|
18
|
+
assert_respond_to(@delivery, :customer)
|
19
|
+
assert_respond_to(@delivery, :customer=)
|
20
|
+
assert_respond_to(@delivery, :bsr)
|
21
|
+
assert_respond_to(@delivery, :bsr=)
|
22
|
+
assert_respond_to(@delivery, :agreement)
|
23
|
+
assert_respond_to(@delivery, :agreement=)
|
24
|
+
assert_respond_to(@delivery, :free_text)
|
25
|
+
assert_respond_to(@delivery, :free_text=)
|
26
|
+
assert_respond_to(@delivery, :status)
|
27
|
+
assert_respond_to(@delivery, :status=)
|
28
|
+
assert_respond_to(@delivery, :status_date)
|
29
|
+
assert_respond_to(@delivery, :status_date=)
|
30
|
+
end
|
31
|
+
def test_attr_readers
|
32
|
+
assert_respond_to(@delivery, :items)
|
33
|
+
assert_respond_to(@delivery, :parties)
|
34
|
+
assert_respond_to(@delivery, :ids)
|
35
|
+
assert_respond_to(@delivery, :customer_id)
|
36
|
+
assert_respond_to(@delivery, :prices)
|
37
|
+
end
|
38
|
+
def test_add_free_text
|
39
|
+
assert_respond_to(@delivery, :add_free_text)
|
40
|
+
end
|
41
|
+
def test_bsr_id
|
42
|
+
bsr = Mock.new('BSR')
|
43
|
+
bsr.__next(:bsr_id) { 'id_string' }
|
44
|
+
assert_nil(@delivery.bsr_id)
|
45
|
+
@delivery.bsr = bsr
|
46
|
+
assert_equal('id_string', @delivery.bsr_id)
|
47
|
+
bsr.__verify
|
48
|
+
end
|
49
|
+
def test_add_party__customer
|
50
|
+
party = Mock.new('Customer')
|
51
|
+
party.__next(:role) { 'Customer' }
|
52
|
+
@delivery.add_party(party)
|
53
|
+
assert_equal(party, @delivery.customer)
|
54
|
+
assert_equal([party], @delivery.parties)
|
55
|
+
party.__verify
|
56
|
+
end
|
57
|
+
def test_add_party__seller
|
58
|
+
party = Mock.new('Seller')
|
59
|
+
party.__next(:role) { 'Seller' }
|
60
|
+
@delivery.add_party(party)
|
61
|
+
assert_equal(party, @delivery.seller)
|
62
|
+
assert_equal([party], @delivery.parties)
|
63
|
+
party.__verify
|
64
|
+
end
|
65
|
+
def test_add_item
|
66
|
+
item = Mock.new
|
67
|
+
@delivery.add_item(item)
|
68
|
+
assert_equal([item], @delivery.items)
|
69
|
+
item.__verify
|
70
|
+
end
|
71
|
+
def test_add_price
|
72
|
+
assert_equal([], @delivery.prices)
|
73
|
+
price = Mock.new('BruttoPreis')
|
74
|
+
@delivery.add_price(price)
|
75
|
+
assert_equal([price], @delivery.prices)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# TestDeliveryItem -- xmlconv2 -- 01.06.2004 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
$: << File.expand_path('..', File.dirname(__FILE__))
|
5
|
+
$: << File.expand_path('../../lib', File.dirname(__FILE__))
|
6
|
+
|
7
|
+
require 'test/unit'
|
8
|
+
require 'xmlconv/model/delivery_item'
|
9
|
+
require 'mock'
|
10
|
+
|
11
|
+
module XmlConv
|
12
|
+
module Model
|
13
|
+
class TestDeliveryItem < Test::Unit::TestCase
|
14
|
+
def setup
|
15
|
+
@item = DeliveryItem.new
|
16
|
+
end
|
17
|
+
def test_attr_accessors
|
18
|
+
assert_respond_to(@item, :line_no)
|
19
|
+
assert_respond_to(@item, :line_no=)
|
20
|
+
assert_respond_to(@item, :qty)
|
21
|
+
assert_respond_to(@item, :qty=)
|
22
|
+
assert_respond_to(@item, :delivery_date)
|
23
|
+
assert_respond_to(@item, :delivery_date=)
|
24
|
+
end
|
25
|
+
def test_attr_readers
|
26
|
+
assert_respond_to(@item, :ids)
|
27
|
+
assert_respond_to(@item, :et_nummer_id)
|
28
|
+
assert_respond_to(@item, :prices)
|
29
|
+
assert_respond_to(@item, :free_text)
|
30
|
+
assert_respond_to(@item, :part_infos)
|
31
|
+
end
|
32
|
+
def test_add_id
|
33
|
+
assert_equal({}, @item.ids)
|
34
|
+
@item.add_id('ET-NUMMER', 'et_number')
|
35
|
+
assert_equal('et_number', @item.et_nummer_id)
|
36
|
+
assert_equal({'ET-NUMMER' => 'et_number'}, @item.ids)
|
37
|
+
end
|
38
|
+
def test_add_price
|
39
|
+
assert_equal([], @item.prices)
|
40
|
+
price = Mock.new('BruttoPreis')
|
41
|
+
@item.add_price(price)
|
42
|
+
assert_equal([price], @item.prices)
|
43
|
+
end
|
44
|
+
def test_add_part_info
|
45
|
+
info = Mock.new('PartInfo')
|
46
|
+
assert_equal([], @item.part_infos)
|
47
|
+
@item.add_part_info(info)
|
48
|
+
assert_equal([info], @item.part_infos)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|