xmlconv2 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -0
- data/LICENCE.txt +339 -0
- data/Manifest.txt +107 -0
- data/README.txt +25 -0
- data/Rakefile +28 -0
- data/bin/admin +65 -0
- data/bin/xmlconvd +19 -0
- data/data/grammar/i2.grammar +73 -0
- data/src/conversion/bdd_geh.rb +281 -0
- data/src/conversion/bdd_i2.rb +102 -0
- data/src/conversion/bdd_xml.rb +242 -0
- data/src/conversion/geh_bdd.rb +165 -0
- data/src/conversion/i2_bdd.rb +271 -0
- data/src/conversion/xml_bdd.rb +125 -0
- data/src/custom/lookandfeel.rb +47 -0
- data/src/i2/address.rb +33 -0
- data/src/i2/date.rb +37 -0
- data/src/i2/document.rb +26 -0
- data/src/i2/header.rb +24 -0
- data/src/i2/order.rb +44 -0
- data/src/i2/parser.rb +25 -0
- data/src/i2/position.rb +37 -0
- data/src/i2/record.rb +11 -0
- data/src/model/address.rb +20 -0
- data/src/model/agreement.rb +10 -0
- data/src/model/bdd.rb +26 -0
- data/src/model/bsr.rb +16 -0
- data/src/model/delivery.rb +15 -0
- data/src/model/delivery_item.rb +18 -0
- data/src/model/freetext_container.rb +26 -0
- data/src/model/id_container.rb +15 -0
- data/src/model/invoice.rb +18 -0
- data/src/model/invoice_item.rb +11 -0
- data/src/model/item.rb +19 -0
- data/src/model/item_container.rb +15 -0
- data/src/model/name.rb +27 -0
- data/src/model/part_info.rb +10 -0
- data/src/model/part_info_container.rb +15 -0
- data/src/model/party.rb +23 -0
- data/src/model/party_container.rb +20 -0
- data/src/model/price.rb +10 -0
- data/src/model/price_container.rb +18 -0
- data/src/model/transaction.rb +28 -0
- data/src/state/global.rb +28 -0
- data/src/state/global_predefine.rb +11 -0
- data/src/state/login.rb +38 -0
- data/src/state/transaction.rb +13 -0
- data/src/state/transactions.rb +130 -0
- data/src/util/application.rb +143 -0
- data/src/util/destination.rb +130 -0
- data/src/util/invoicer.rb +72 -0
- data/src/util/known_user.rb +16 -0
- data/src/util/polling_manager.rb +78 -0
- data/src/util/session.rb +23 -0
- data/src/util/transaction.rb +105 -0
- data/src/util/validator.rb +20 -0
- data/src/view/foot.rb +27 -0
- data/src/view/head.rb +13 -0
- data/src/view/login.rb +36 -0
- data/src/view/navigation.rb +30 -0
- data/src/view/navigationlink.rb +21 -0
- data/src/view/pager.rb +73 -0
- data/src/view/preformatted.rb +39 -0
- data/src/view/template.rb +17 -0
- data/src/view/transaction.rb +42 -0
- data/src/view/transactions.rb +90 -0
- data/test/mock.rb +149 -0
- data/test/suite.rb +16 -0
- data/test/test_conversion/bdd_geh.rb +533 -0
- data/test/test_conversion/bdd_i2.rb +314 -0
- data/test/test_conversion/bdd_xml.rb +556 -0
- data/test/test_conversion/geh_bdd.rb +372 -0
- data/test/test_conversion/i2_bdd.rb +804 -0
- data/test/test_conversion/xml_bdd.rb +203 -0
- data/test/test_i2/address.rb +88 -0
- data/test/test_i2/date.rb +49 -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 +309 -0
- data/test/test_i2/position.rb +65 -0
- data/test/test_integration/geh_i2.rb +312 -0
- data/test/test_integration/i2_geh.rb +449 -0
- data/test/test_integration/i2_xml.rb +162 -0
- data/test/test_integration/xml_i2.rb +254 -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 +197 -0
- data/test/test_util/invoicer.rb +36 -0
- data/test/test_util/polling_manager.rb +111 -0
- data/test/test_util/transaction.rb +129 -0
- data/user-stories/UserStories_XmlConv2.txt +381 -0
- data/user-stories/doku/ABB.incoming.HTTP.invoice.xml +315 -0
- data/user-stories/doku/ABB.received.xml +259 -0
- data/user-stories/doku/BO_OrderProcessing.sxw +0 -0
- metadata +195 -0
@@ -0,0 +1,254 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Integration::TestXmlI2 -- xmlconv2 -- 02.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/xml_bdd'
|
11
|
+
require 'conversion/bdd_i2'
|
12
|
+
require 'mock'
|
13
|
+
|
14
|
+
module XmlConv
|
15
|
+
module Integration
|
16
|
+
class TestXmlI2 < Test::Unit::TestCase
|
17
|
+
def setup
|
18
|
+
@src = <<-EOS
|
19
|
+
<?xml version="1.0" encoding="ISO-8859-1"?>
|
20
|
+
<!DOCTYPE BDD SYSTEM "ABB BDD.dtd">
|
21
|
+
<BDD Version="2">
|
22
|
+
<BSR Version="3">
|
23
|
+
<Timestamp Zone="+1">20040416151630</Timestamp>
|
24
|
+
<Verb>Place</Verb>
|
25
|
+
<Noun>Order</Noun>
|
26
|
+
<Party Role="Customer" Version="2">
|
27
|
+
<Name>Winterhalter + Fenner AG</Name>
|
28
|
+
<PartyId Domain="ACC">%%%99999%%% Kundennummer ElectroLAN</PartyId>
|
29
|
+
</Party>
|
30
|
+
</BSR>
|
31
|
+
<Delivery Version="3">
|
32
|
+
<Status Date="20040416151441" Domain="">Order</Status>
|
33
|
+
<DeliveryId Domain="Customer">B-465178 W</DeliveryId>
|
34
|
+
<Party Version="2" Role="Seller">
|
35
|
+
<Name>Plica AG</Name>
|
36
|
+
<Address>
|
37
|
+
<AddressLine>Z�rcherstr. 350/Postfach 173</AddressLine>
|
38
|
+
<City>Frauenfeld</City>
|
39
|
+
<ZipCode Domain="">8501</ZipCode>
|
40
|
+
</Address>
|
41
|
+
</Party>
|
42
|
+
<Party Version="2" Role="Customer">
|
43
|
+
<Name>Winterhalter + Fenner AG</Name>
|
44
|
+
<Phone Domain="Business">01 / 839 58 44</Phone>
|
45
|
+
<Address>
|
46
|
+
<AddressLine>Birgistrasse 10</AddressLine>
|
47
|
+
<City>Wallisellen</City>
|
48
|
+
<ZipCode Domain="CH">8304</ZipCode>
|
49
|
+
</Address>
|
50
|
+
<Party Role="Employee">
|
51
|
+
<Name>
|
52
|
+
<LastName>Russo Giovanni</LastName>
|
53
|
+
</Name>
|
54
|
+
<Competency>Sachbearbeiter</Competency>
|
55
|
+
</Party>
|
56
|
+
<Party Role="ShipTo">
|
57
|
+
<Name>Winterhalter + Fenner AG</Name>
|
58
|
+
<PartyId Domain="ACC">%%%99999%%% Lieferadressnummer</PartyId>
|
59
|
+
<Address>
|
60
|
+
<AddressLine>Filiale Wallisellen</AddressLine>
|
61
|
+
<AddressLine>Hertistrasse 31</AddressLine>
|
62
|
+
<City>Wallisellen</City>
|
63
|
+
<ZipCode Domain="CH">8304</ZipCode>
|
64
|
+
</Address>
|
65
|
+
</Party>
|
66
|
+
<Party Role="BillTo">
|
67
|
+
<Name>Winterhalter + Fenner AG</Name>
|
68
|
+
<PartyId Domain="ACC">%%%99999%%% Rechnungsadressnummer</PartyId>
|
69
|
+
<Address>
|
70
|
+
<AddressLine>Birgistrasse 10</AddressLine>
|
71
|
+
<City>Wallisellen</City>
|
72
|
+
<ZipCode Domain="CH">8304</ZipCode>
|
73
|
+
</Address>
|
74
|
+
</Party>
|
75
|
+
</Party>
|
76
|
+
<DeliveryItem>
|
77
|
+
<LineNo>2508466</LineNo>
|
78
|
+
<PartId>
|
79
|
+
<IdentNo Domain="ET-NUMMER">125301307</IdentNo>
|
80
|
+
<IdentNo Domain="LIEFERANTENARTIKEL">15.0205.025</IdentNo>
|
81
|
+
</PartId>
|
82
|
+
<Qty>7200</Qty>
|
83
|
+
<FreeText Type="BEZEICHNUNG">KRF-ROHR PE O/DRAHT M25 OR</FreeText>
|
84
|
+
<DeliveryDate>14.04.2004</DeliveryDate>
|
85
|
+
</DeliveryItem>
|
86
|
+
<DeliveryItem>
|
87
|
+
<LineNo>2508467</LineNo>
|
88
|
+
<PartId>
|
89
|
+
<IdentNo Domain="ET-NUMMER">125301607</IdentNo>
|
90
|
+
<IdentNo Domain="LIEFERANTENARTIKEL">15.0202.550</IdentNo>
|
91
|
+
</PartId>
|
92
|
+
<Qty>900</Qty>
|
93
|
+
<FreeText Type="BEZEICHNUNG">KRF-ROHR PE O/DRAHT M50 OR</FreeText>
|
94
|
+
<DeliveryDate>SOFORT</DeliveryDate>
|
95
|
+
</DeliveryItem>
|
96
|
+
<DeliveryItem>
|
97
|
+
<LineNo>2508468</LineNo>
|
98
|
+
<PartId>
|
99
|
+
<IdentNo Domain="ET-NUMMER">125301707</IdentNo>
|
100
|
+
<IdentNo Domain="LIEFERANTENARTIKEL">15.0202.563</IdentNo>
|
101
|
+
</PartId>
|
102
|
+
<Qty>250</Qty>
|
103
|
+
<FreeText Type="BEZEICHNUNG">KRF-ROHR PE O/DRAHT M63 OR</FreeText>
|
104
|
+
<DeliveryDate>14.04.2004</DeliveryDate>
|
105
|
+
</DeliveryItem>
|
106
|
+
</Delivery>
|
107
|
+
</BDD>
|
108
|
+
EOS
|
109
|
+
@xml_doc = REXML::Document.new(@src)
|
110
|
+
@target_dir = File.expand_path('data/xml_i2',
|
111
|
+
File.dirname(__FILE__))
|
112
|
+
clear_dir
|
113
|
+
end
|
114
|
+
def teardown
|
115
|
+
clear_dir
|
116
|
+
end
|
117
|
+
def clear_dir
|
118
|
+
if(File.exist?(@target_dir))
|
119
|
+
FileUtils.rm_r(@target_dir)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
def test_xml_i2
|
123
|
+
bdd = Conversion::XmlBdd.convert(@xml_doc)
|
124
|
+
i2_doc = Conversion::BddI2.convert(bdd)
|
125
|
+
result = i2_doc.to_s.split("\n")
|
126
|
+
expected = <<-EOS
|
127
|
+
001:EPIN_PL
|
128
|
+
002:ORDERX
|
129
|
+
003:220
|
130
|
+
010:#{i2_doc.filename}
|
131
|
+
100:%%%99999%%% Kundennummer ElectroLAN
|
132
|
+
101:B-465178 W
|
133
|
+
201:EP
|
134
|
+
220:Russo Giovanni
|
135
|
+
201:DP
|
136
|
+
202:%%%99999%%% Lieferadressnummer
|
137
|
+
220:Winterhalter + Fenner AG
|
138
|
+
221:Filiale Wallisellen
|
139
|
+
222:Hertistrasse 31
|
140
|
+
223:Wallisellen
|
141
|
+
225:8304
|
142
|
+
201:BY
|
143
|
+
202:%%%99999%%% Rechnungsadressnummer
|
144
|
+
220:Winterhalter + Fenner AG
|
145
|
+
222:Birgistrasse 10
|
146
|
+
223:Wallisellen
|
147
|
+
225:8304
|
148
|
+
237:61
|
149
|
+
300:4
|
150
|
+
301:#{Date.today.strftime('%Y%m%d')}
|
151
|
+
500:2508466
|
152
|
+
501:125301307
|
153
|
+
502:15.0205.025
|
154
|
+
520:7200
|
155
|
+
540:2
|
156
|
+
541:20040414
|
157
|
+
500:2508467
|
158
|
+
501:125301607
|
159
|
+
502:15.0202.550
|
160
|
+
520:900
|
161
|
+
540:2
|
162
|
+
541:#{Date.today.strftime('%Y%m%d')}
|
163
|
+
500:2508468
|
164
|
+
501:125301707
|
165
|
+
502:15.0202.563
|
166
|
+
520:250
|
167
|
+
540:2
|
168
|
+
541:20040414
|
169
|
+
EOS
|
170
|
+
expected.split("\n").each_with_index { |line, index|
|
171
|
+
assert_equal(line, result[index])
|
172
|
+
}
|
173
|
+
end
|
174
|
+
def test_execute_transaction
|
175
|
+
storage = Mock.new('Storage')
|
176
|
+
storage.__next(:transaction) { |block|
|
177
|
+
block.call
|
178
|
+
}
|
179
|
+
ODBA.storage = storage
|
180
|
+
cache = Mock.new('Cache')
|
181
|
+
cache.__next(:store) { |persistable|
|
182
|
+
assert_instance_of(Util::DestinationDir, persistable)
|
183
|
+
}
|
184
|
+
ODBA.cache = cache
|
185
|
+
destination = Util::DestinationDir.new
|
186
|
+
destination.path = @target_dir
|
187
|
+
transaction = Util::Transaction.new
|
188
|
+
transaction.reader = "XmlBdd"
|
189
|
+
transaction.writer = "BddI2"
|
190
|
+
transaction.input = @src
|
191
|
+
transaction.destination = destination
|
192
|
+
output = transaction.execute
|
193
|
+
result = output.to_s.split("\n")
|
194
|
+
expected = <<-EOS
|
195
|
+
001:EPIN_PL
|
196
|
+
002:ORDERX
|
197
|
+
003:220
|
198
|
+
010:#{transaction.destination.filename}
|
199
|
+
100:%%%99999%%% Kundennummer ElectroLAN
|
200
|
+
101:B-465178 W
|
201
|
+
201:EP
|
202
|
+
220:Russo Giovanni
|
203
|
+
201:DP
|
204
|
+
202:%%%99999%%% Lieferadressnummer
|
205
|
+
220:Winterhalter + Fenner AG
|
206
|
+
221:Filiale Wallisellen
|
207
|
+
222:Hertistrasse 31
|
208
|
+
223:Wallisellen
|
209
|
+
225:8304
|
210
|
+
201:BY
|
211
|
+
202:%%%99999%%% Rechnungsadressnummer
|
212
|
+
220:Winterhalter + Fenner AG
|
213
|
+
222:Birgistrasse 10
|
214
|
+
223:Wallisellen
|
215
|
+
225:8304
|
216
|
+
237:61
|
217
|
+
300:4
|
218
|
+
301:#{Date.today.strftime('%Y%m%d')}
|
219
|
+
500:2508466
|
220
|
+
501:125301307
|
221
|
+
502:15.0205.025
|
222
|
+
520:7200
|
223
|
+
540:2
|
224
|
+
541:20040414
|
225
|
+
500:2508467
|
226
|
+
501:125301607
|
227
|
+
502:15.0202.550
|
228
|
+
520:900
|
229
|
+
540:2
|
230
|
+
541:#{Date.today.strftime('%Y%m%d')}
|
231
|
+
500:2508468
|
232
|
+
501:125301707
|
233
|
+
502:15.0202.563
|
234
|
+
520:250
|
235
|
+
540:2
|
236
|
+
541:20040414
|
237
|
+
EOS
|
238
|
+
expected.split("\n").each_with_index { |line, index|
|
239
|
+
assert_equal(line, result[index])
|
240
|
+
}
|
241
|
+
assert(File.exist?(@target_dir), 'Target Directory does not exist')
|
242
|
+
entries = Dir.entries(@target_dir)
|
243
|
+
assert_equal(3, entries.size)
|
244
|
+
entry = entries.sort.last
|
245
|
+
path = File.expand_path(entry, @target_dir)
|
246
|
+
content = File.read(path)
|
247
|
+
assert_equal(expected, content)
|
248
|
+
ensure
|
249
|
+
ODBA.storage = nil
|
250
|
+
ODBA.cache = nil
|
251
|
+
end
|
252
|
+
end
|
253
|
+
end
|
254
|
+
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('../../src', File.dirname(__FILE__))
|
6
|
+
|
7
|
+
require 'test/unit'
|
8
|
+
require '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('../../src', File.dirname(__FILE__))
|
6
|
+
|
7
|
+
require 'test/unit'
|
8
|
+
require '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('../../src', File.dirname(__FILE__))
|
6
|
+
|
7
|
+
require 'test/unit'
|
8
|
+
require 'model/bdd'
|
9
|
+
require 'mock'
|
10
|
+
require 'flexmock'
|
11
|
+
|
12
|
+
module XmlConv
|
13
|
+
module Model
|
14
|
+
class TestBdd < Test::Unit::TestCase
|
15
|
+
def setup
|
16
|
+
@bdd = Bdd.new
|
17
|
+
end
|
18
|
+
def test_attr_accessors
|
19
|
+
assert_respond_to(@bdd, :bsr)
|
20
|
+
assert_respond_to(@bdd, :bsr=)
|
21
|
+
end
|
22
|
+
def test_attr_readers
|
23
|
+
assert_respond_to(@bdd, :deliveries)
|
24
|
+
assert_respond_to(@bdd, :invoices)
|
25
|
+
end
|
26
|
+
def test_add_delivery
|
27
|
+
delivery = Mock.new('Delivery')
|
28
|
+
assert_equal([], @bdd.deliveries)
|
29
|
+
@bdd.add_delivery(delivery)
|
30
|
+
assert_equal([delivery], @bdd.deliveries)
|
31
|
+
end
|
32
|
+
def test_add_invoice
|
33
|
+
invoice = Mock.new('Invoice')
|
34
|
+
assert_equal([], @bdd.invoices)
|
35
|
+
@bdd.add_invoice(invoice)
|
36
|
+
assert_equal([invoice], @bdd.invoices)
|
37
|
+
end
|
38
|
+
def test_invoiced_amount
|
39
|
+
assert_equal(0, @bdd.invoiced_amount)
|
40
|
+
invoice = FlexMock.new
|
41
|
+
price = FlexMock.new
|
42
|
+
@bdd.invoices.push(invoice, invoice)
|
43
|
+
invoice.mock_handle(:get_price, 4) { |purpose|
|
44
|
+
assert_equal('SummePositionen', purpose)
|
45
|
+
price
|
46
|
+
}
|
47
|
+
price.mock_handle(:amount) { '123.45' }
|
48
|
+
assert_equal(246.90, @bdd.invoiced_amount)
|
49
|
+
@bdd.deliveries.push(invoice)
|
50
|
+
assert_equal(246.90, @bdd.invoiced_amount)
|
51
|
+
invoice.mock_verify
|
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('../../src', File.dirname(__FILE__))
|
6
|
+
|
7
|
+
require 'test/unit'
|
8
|
+
require '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.dirname(__FILE__)
|
5
|
+
$: << File.expand_path('../../src', File.dirname(__FILE__))
|
6
|
+
|
7
|
+
require 'test/unit'
|
8
|
+
require '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
|