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,52 @@
1
+ #!/usr/bin/env ruby
2
+ # TestDeliveryItem -- 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_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
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env ruby
2
+ # Model::TestFreeTextContainer -- xmlconv2 -- 29.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/invoice_item'
9
+
10
+ module XmlConv
11
+ module Model
12
+ class Container
13
+ include FreeTextContainer
14
+ end
15
+ class TestFreeTextContainer < Test::Unit::TestCase
16
+ def setup
17
+ @container = Container.new
18
+ end
19
+ def test_attr_readers
20
+ assert_respond_to(@container, :free_text)
21
+ end
22
+ def test_add_free_text
23
+ txt = @container.add_free_text('Description', 'Foo, Bar and Baz')
24
+ assert_instance_of(FreeText, @container.free_text)
25
+ assert_equal(@container.free_text, txt)
26
+ assert_equal('Foo, Bar and Baz', txt)
27
+ assert_equal('Description', txt.type)
28
+ end
29
+ end
30
+ class TestFreeText < Test::Unit::TestCase
31
+ def setup
32
+ @text = FreeText.new
33
+ end
34
+ def test_append
35
+ assert_equal('', @text)
36
+ @text << "Foo, Bar and Baz"
37
+ assert_equal('Foo, Bar and Baz', @text)
38
+ @text << "with a newline"
39
+ assert_equal("Foo, Bar and Baz\nwith a newline", @text)
40
+ @text << ""
41
+ assert_equal("Foo, Bar and Baz\nwith a newline", @text)
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/env ruby
2
+ # Model::TestInvoice -- 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/invoice'
9
+ require 'mock'
10
+
11
+ module XmlConv
12
+ module Model
13
+ class TestInvoice < Test::Unit::TestCase
14
+ def setup
15
+ @invoice = Invoice.new
16
+ end
17
+ def test_attr_readers
18
+ assert_respond_to(@invoice, :ids)
19
+ assert_respond_to(@invoice, :items)
20
+ assert_respond_to(@invoice, :parties)
21
+ assert_respond_to(@invoice, :prices)
22
+ assert_respond_to(@invoice, :delivery_id)
23
+ end
24
+ def test_attr_accessors
25
+ assert_respond_to(@invoice, :free_text)
26
+ assert_respond_to(@invoice, :free_text=)
27
+ assert_respond_to(@invoice, :agreement)
28
+ assert_respond_to(@invoice, :agreement=)
29
+ assert_respond_to(@invoice, :status)
30
+ assert_respond_to(@invoice, :status=)
31
+ assert_respond_to(@invoice, :status_date)
32
+ assert_respond_to(@invoice, :status_date=)
33
+ end
34
+ def test_add_free_text
35
+ assert_respond_to(@invoice, :add_free_text)
36
+ end
37
+ def test_add_item
38
+ item = Mock.new
39
+ @invoice.add_item(item)
40
+ assert_equal([item], @invoice.items)
41
+ item.__verify
42
+ end
43
+ def test_add_delivery_id
44
+ @invoice.add_delivery_id('Domain', 'Id')
45
+ assert_equal(['Domain', 'Id'], @invoice.delivery_id)
46
+ end
47
+ def test_add_party__customer
48
+ party = Mock.new('Customer')
49
+ party.__next(:role) { 'Customer' }
50
+ @invoice.add_party(party)
51
+ assert_equal(party, @invoice.customer)
52
+ assert_equal([party], @invoice.parties)
53
+ party.__verify
54
+ end
55
+ def test_add_party__seller
56
+ party = Mock.new('Seller')
57
+ party.__next(:role) { 'Seller' }
58
+ @invoice.add_party(party)
59
+ assert_equal(party, @invoice.seller)
60
+ assert_equal([party], @invoice.parties)
61
+ party.__verify
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env ruby
2
+ # Model::TestInvoiceItem -- xmlconv2 -- 23.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/invoice_item'
9
+ require 'mock'
10
+
11
+ module XmlConv
12
+ module Model
13
+ class TestInvoiceItem < Test::Unit::TestCase
14
+ def setup
15
+ @item = InvoiceItem.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
+ end
23
+ def test_attr_readers
24
+ assert_respond_to(@item, :part_infos)
25
+ assert_respond_to(@item, :ids)
26
+ assert_respond_to(@item, :free_text)
27
+ end
28
+ def test_add_id
29
+ assert_equal({}, @item.ids)
30
+ @item.add_id('ET-NUMMER', 'et_number')
31
+ assert_equal({'ET-NUMMER' => 'et_number'}, @item.ids)
32
+ end
33
+ def test_add_part_info
34
+ info = Mock.new('PartInfo')
35
+ assert_equal([], @item.part_infos)
36
+ @item.add_part_info(info)
37
+ assert_equal([info], @item.part_infos)
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env ruby
2
+ # TestName -- 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/name'
9
+
10
+ module XmlConv
11
+ module Model
12
+ class TestName < Test::Unit::TestCase
13
+ def setup
14
+ @name = Name.new
15
+ end
16
+ def test_attr_accessors
17
+ assert_respond_to(@name, :first)
18
+ assert_respond_to(@name, :first=)
19
+ assert_respond_to(@name, :last)
20
+ assert_respond_to(@name, :last=)
21
+ assert_respond_to(@name, :text)
22
+ assert_respond_to(@name, :text=)
23
+ end
24
+ def test_to_s
25
+ @name.first = 'First'
26
+ assert_equal('First', @name.to_s)
27
+ @name.last = 'Last'
28
+ assert_equal('First Last', @name.to_s)
29
+ @name.text = 'Text'
30
+ assert_equal('First Text Last', @name.to_s)
31
+ end
32
+ def test_attr_writers
33
+ assert_nil(@name.first)
34
+ @name.first = nil
35
+ assert_nil(@name.first)
36
+ @name.first = 'first'
37
+ assert_equal('first', @name.first)
38
+ @name.first = ''
39
+ assert_nil(@name.first)
40
+ assert_nil(@name.last)
41
+ @name.last = nil
42
+ assert_nil(@name.last)
43
+ @name.last = 'last'
44
+ assert_equal('last', @name.last)
45
+ @name.last = ''
46
+ assert_nil(@name.last)
47
+ assert_nil(@name.text)
48
+ @name.text = nil
49
+ assert_nil(@name.text)
50
+ @name.text = 'text'
51
+ assert_equal('text', @name.text)
52
+ @name.text = ''
53
+ assert_nil(@name.text)
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env ruby
2
+ # Model::TestPartInfo -- xmlconv2 -- 23.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/part_info'
9
+
10
+ module XmlConv
11
+ module Model
12
+ class TestPartInfo < Test::Unit::TestCase
13
+ def setup
14
+ @part_info = PartInfo.new
15
+ end
16
+ def test_attr_accessors
17
+ assert_respond_to(@part_info, :dimension)
18
+ assert_respond_to(@part_info, :dimension=)
19
+ assert_respond_to(@part_info, :value)
20
+ assert_respond_to(@part_info, :value=)
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,96 @@
1
+ #!/usr/bin/env ruby
2
+ # TestParty -- xmlconv2 -- 01.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 'model/party'
9
+ require 'mock'
10
+
11
+ module XmlConv
12
+ module Model
13
+ class TestParty < Test::Unit::TestCase
14
+ class ToSMock < Mock
15
+ def to_s
16
+ true
17
+ end
18
+ end
19
+ def setup
20
+ @party = Party.new
21
+ end
22
+ def test_attr_accessors
23
+ assert_respond_to(@party, :role)
24
+ assert_respond_to(@party, :role=)
25
+ assert_respond_to(@party, :name)
26
+ assert_respond_to(@party, :name=)
27
+ assert_respond_to(@party, :employee)
28
+ assert_respond_to(@party, :employee=)
29
+ assert_respond_to(@party, :address)
30
+ assert_respond_to(@party, :address=)
31
+ end
32
+ def test_attr_readers
33
+ assert_respond_to(@party, :ids)
34
+ assert_respond_to(@party, :acc_id)
35
+ end
36
+ def test_add_id
37
+ assert_equal({}, @party.ids)
38
+ @party.add_id('ACC', 'id_string')
39
+ assert_equal({'ACC' => 'id_string'}, @party.ids)
40
+ assert_equal('id_string', @party.acc_id)
41
+ end
42
+ def test_add_party
43
+ employee = Mock.new('Employee')
44
+ employee.__next(:role) { 'Employee' }
45
+ @party.add_party(employee)
46
+ assert_equal(employee, @party.employee)
47
+ assert_equal([employee], @party.parties)
48
+ ship_to = Mock.new('ShipTo')
49
+ ship_to.__next(:role) { 'ShipTo' }
50
+ @party.add_party(ship_to)
51
+ assert_equal(employee, @party.employee)
52
+ assert_equal(ship_to, @party.ship_to)
53
+ assert_equal([employee, ship_to], @party.parties)
54
+ bill_to = Mock.new('BillTo')
55
+ bill_to.__next(:role) { 'BillTo' }
56
+ @party.add_party(bill_to)
57
+ assert_equal(employee, @party.employee)
58
+ assert_equal(bill_to, @party.bill_to)
59
+ assert_equal([employee, ship_to, bill_to], @party.parties)
60
+ end
61
+ def test_party_id
62
+ assert_nil(@party.party_id)
63
+ @party.add_id('ACC', 'id_string')
64
+ assert_equal('id_string', @party.party_id)
65
+ end
66
+ def test_name
67
+ assert_nil(@party.name)
68
+ @party.name = 'a_string'
69
+ assert_equal('a_string', @party.name)
70
+ name = ToSMock.new('Name')
71
+ @party.name = name
72
+ assert_equal(name, @party.name)
73
+ name.__verify
74
+ end
75
+ def test_employee
76
+ employee = Mock.new('Employee')
77
+ employee.__next(:role) { 'Employee' }
78
+ @party.add_party(employee)
79
+ assert_equal(employee, @party.employee)
80
+ assert_equal([employee], @party.parties)
81
+ ship_to = Mock.new('ShipTo')
82
+ ship_to.__next(:role) { 'ShipTo' }
83
+ @party.add_party(ship_to)
84
+ assert_equal(employee, @party.employee)
85
+ assert_equal(ship_to, @party.ship_to)
86
+ assert_equal([employee, ship_to], @party.parties)
87
+ bill_to = Mock.new('BillTo')
88
+ bill_to.__next(:role) { 'BillTo' }
89
+ @party.add_party(bill_to)
90
+ assert_equal(employee, @party.employee)
91
+ assert_equal(bill_to, @party.bill_to)
92
+ assert_equal([employee, ship_to, bill_to], @party.parties)
93
+ end
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env ruby
2
+ # TestPrice -- xmlconv2 -- 21.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/price'
9
+
10
+ module XmlConv
11
+ module Model
12
+ class TestPrice < Test::Unit::TestCase
13
+ def setup
14
+ @price = Price.new
15
+ end
16
+ def test_attr_accessors
17
+ assert_respond_to(@price, :purpose)
18
+ assert_respond_to(@price, :purpose=)
19
+ assert_respond_to(@price, :amount)
20
+ assert_respond_to(@price, :amount=)
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,168 @@
1
+ #!/usr/bin/env ruby
2
+ # XmlConv::TestApplication -- xmlconv2 -- 07.06.2004 -- hwyss@ywesee.com
3
+
4
+ $: << File.dirname(__FILE__)
5
+ $: << File.expand_path('..', File.dirname(__FILE__))
6
+ $: << File.expand_path('../../src', File.dirname(__FILE__))
7
+
8
+ require 'test/unit'
9
+ require 'util/application'
10
+ require 'mock'
11
+
12
+ module XmlConv
13
+ module Conversion
14
+ def const_get(symbol)
15
+ if(symbol.is_a?(Mock))
16
+ symbol
17
+ else
18
+ super
19
+ end
20
+ end
21
+ module_function :const_get
22
+ end
23
+ module Util
24
+ class TestApplication < Test::Unit::TestCase
25
+ def setup
26
+ @app = Util::Application.new
27
+ @app.init
28
+ end
29
+ def test_attr_readers
30
+ assert_respond_to(@app, :transactions)
31
+ assert_respond_to(@app, :failed_transactions)
32
+ end
33
+ def test_execute
34
+ transaction = Mock.new('Transaction')
35
+ cache = Mock.new('Cache')
36
+ cache.__next(:transaction) { |block|
37
+ block.call
38
+ }
39
+ cache.__next(:store) { |transactions|
40
+ assert_equal(@app.transactions, transactions)
41
+ }
42
+ ODBA.cache = cache
43
+ transaction.__next(:transaction_id=) { |id|
44
+ assert_equal(1, id)
45
+ }
46
+ transaction.__next(:execute) { }
47
+ transaction.__next(:notify) { }
48
+ assert_equal([], @app.transactions)
49
+ assert_equal(0, @app.transactions.size)
50
+ @app.execute(transaction)
51
+ assert_equal([transaction], @app.transactions)
52
+ transaction.__verify
53
+ cache.__verify
54
+ ensure
55
+ ODBA.cache = nil
56
+ end
57
+ def test_execute__survive_notification_failure
58
+ transaction = Mock.new('Transaction')
59
+ cache = Mock.new('Cache')
60
+ cache.__next(:transaction) { |block|
61
+ block.call
62
+ }
63
+ cache.__next(:store) { |transactions|
64
+ assert_equal(@app.transactions, transactions)
65
+ }
66
+ ODBA.cache = cache
67
+ transaction.__next(:transaction_id=) { |id|
68
+ assert_equal(1, id)
69
+ }
70
+ transaction.__next(:execute) { }
71
+ transaction.__next(:notify) {
72
+ raise Net::SMTPFatalError, 'could not send email'
73
+ }
74
+ assert_equal([], @app.transactions)
75
+ assert_equal(0, @app.transactions.size)
76
+ @app.execute(transaction)
77
+ assert_equal([transaction], @app.transactions)
78
+ transaction.__verify
79
+ cache.__verify
80
+ ensure
81
+ ODBA.cache = nil
82
+ end
83
+ def test_execute__notify_errors
84
+ transaction = Mock.new('Transaction')
85
+ cache = Mock.new('Cache')
86
+ cache.__next(:transaction) { |block|
87
+ block.call
88
+ }
89
+ cache.__next(:store) { |transactions|
90
+ assert_equal(@app.transactions, transactions)
91
+ }
92
+ ODBA.cache = cache
93
+ transaction.__next(:transaction_id=) { |id|
94
+ assert_equal(1, id)
95
+ }
96
+ transaction.__next(:execute) {
97
+ raise 'oops, something went wrong'
98
+ }
99
+ transaction.__next(:error=) { }
100
+ transaction.__next(:notify) { }
101
+ assert_equal([], @app.transactions)
102
+ assert_equal(0, @app.transactions.size)
103
+ @app.execute(transaction)
104
+ assert_equal([transaction], @app.transactions)
105
+ transaction.__verify
106
+ cache.__verify
107
+ ensure
108
+ ODBA.cache = nil
109
+ end
110
+ def test_dumpable
111
+ assert_nothing_raised { Marshal.dump(@app) }
112
+ end
113
+ def test_next_transaction_id
114
+ assert_equal([], @app.transactions)
115
+ assert_equal(1, @app.next_transaction_id)
116
+ assert_equal(2, @app.next_transaction_id)
117
+ assert_equal(3, @app.next_transaction_id)
118
+ trans1 = Mock.new('Transaction1')
119
+ trans2 = Mock.new('Transaction2')
120
+ @app.transactions.push(trans1)
121
+ @app.transactions.push(trans2)
122
+ @app.instance_variable_set('@next_transaction_id', nil)
123
+ trans1.__next(:transaction_id) { 6 }
124
+ trans2.__next(:transaction_id) { 3 }
125
+ assert_equal(7, @app.next_transaction_id)
126
+ trans1.__verify
127
+ trans2.__verify
128
+ end
129
+ def test_odba_exclude_vars
130
+ @app.instance_variable_set('@next_transaction_id', 10)
131
+ @app.instance_eval('odba_replace_excluded!')
132
+ assert_nil(@app.instance_variable_get('@next_transaction_id'))
133
+ end
134
+ def test_transaction
135
+ trans1 = Mock.new('Transaction1')
136
+ trans2 = Mock.new('Transaction2')
137
+ trans3 = Mock.new('Transaction2')
138
+ @app.transactions.push(trans1)
139
+ @app.transactions.push(trans2)
140
+ trans2.__next(:transaction_id) { 2 }
141
+ trans1.__next(:transaction_id) { 1 }
142
+ assert_equal(trans1, @app.transaction(1))
143
+ trans1.__verify
144
+ trans2.__verify
145
+ @app.transactions.push(trans3)
146
+ trans3.__next(:transaction_id) { 5 }
147
+ trans1.__next(:transaction_id) { 1 }
148
+ trans2.__next(:transaction_id) { 2 }
149
+ assert_equal(trans2, @app.transaction(2))
150
+ trans1.__verify
151
+ trans2.__verify
152
+ trans3.__verify
153
+ trans3.__next(:transaction_id) { 5 }
154
+ trans3.__next(:transaction_id) { 5 }
155
+ assert_equal(trans3, @app.transaction(5))
156
+ trans1.__verify
157
+ trans2.__verify
158
+ trans3.__verify
159
+ trans3.__next(:transaction_id) { 5 }
160
+ trans3.__next(:transaction_id) { 5 }
161
+ assert_equal(trans3, @app.transaction('5'))
162
+ trans1.__verify
163
+ trans2.__verify
164
+ trans3.__verify
165
+ end
166
+ end
167
+ end
168
+ end