iotaz 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/doc/PERSISTENT +137 -0
- data/doc/README +470 -0
- data/examples/example01.rb +105 -0
- data/examples/example02.rb +105 -0
- data/lib/iotaz.rb +35 -0
- data/lib/iotaz/DatabaseInterfaceFactory.rb +92 -0
- data/lib/iotaz/FirebirdInterface.rb +788 -0
- data/lib/iotaz/IotazError.rb +81 -0
- data/lib/iotaz/MetaData.rb +646 -0
- data/lib/iotaz/ObjectPool.rb +299 -0
- data/lib/iotaz/Persistent.rb +155 -0
- data/lib/iotaz/Query.rb +566 -0
- data/lib/iotaz/Session.rb +379 -0
- data/lib/iotaz/WorkSet.rb +295 -0
- data/test/ActionTest.rb +31 -0
- data/test/AtomTest.rb +90 -0
- data/test/AttributeTest.rb +64 -0
- data/test/DatabaseInterfaceFactoryTest.rb +41 -0
- data/test/FirebirdInterfaceTest.rb +276 -0
- data/test/GeneratedAttributeTest.rb +124 -0
- data/test/IotazErrorTest.rb +23 -0
- data/test/IotazMetaDataTest.rb +87 -0
- data/test/ObjectPoolTest.rb +106 -0
- data/test/PersistentTest.rb +102 -0
- data/test/QueryFieldTest.rb +152 -0
- data/test/QueryRowTest.rb +42 -0
- data/test/QueryTest.rb +59 -0
- data/test/SessionTest.rb +162 -0
- data/test/UnitTest.rb +17 -0
- data/test/ValueCallbackTest.rb +44 -0
- data/test/dbinfo.rb +7 -0
- metadata +75 -0
@@ -0,0 +1,124 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'rubygems'
|
5
|
+
require_gem 'iotaz'
|
6
|
+
|
7
|
+
include Iotaz
|
8
|
+
|
9
|
+
class GeneratedAttributeTest < Test::Unit::TestCase
|
10
|
+
def test01
|
11
|
+
a = GeneratedAttribute.new('att01', 'SEQUENCE', 'INSERT', 'ATT_01_SQ')
|
12
|
+
|
13
|
+
assert(a.type == 'SEQUENCE')
|
14
|
+
assert(a.events == 'INSERT')
|
15
|
+
assert(a.source == 'ATT_01_SQ')
|
16
|
+
assert(a.column == 'att01')
|
17
|
+
|
18
|
+
a = GeneratedAttribute.new('att02', 'DATE', 'UPDATE', 'YESTERDAY', 'COL_NAME')
|
19
|
+
|
20
|
+
assert(a.type == 'DATE')
|
21
|
+
assert(a.events == 'UPDATE')
|
22
|
+
assert(a.source == 'YESTERDAY')
|
23
|
+
assert(a.column == 'COL_NAME')
|
24
|
+
|
25
|
+
a = GeneratedAttribute.new('att03', 'TIME', 'INSERT, UPDATE', 'NOW')
|
26
|
+
|
27
|
+
assert(a.type == 'TIME')
|
28
|
+
assert(a.events == 'INSERT,UPDATE')
|
29
|
+
assert(a.source == 'NOW')
|
30
|
+
assert(a.column == 'att03')
|
31
|
+
|
32
|
+
a = GeneratedAttribute.new('att04', 'TIMESTAMP', 'UPDATE, INSERT ', 'NOW')
|
33
|
+
|
34
|
+
assert(a.type == 'TIMESTAMP')
|
35
|
+
assert(a.events == 'UPDATE,INSERT')
|
36
|
+
assert(a.source == 'NOW')
|
37
|
+
assert(a.column == 'att04')
|
38
|
+
end
|
39
|
+
|
40
|
+
def test02
|
41
|
+
a1 = GeneratedAttribute.new('att01', 'SEQUENCE', 'INSERT', 'ATT_01_SQ')
|
42
|
+
a2 = GeneratedAttribute.new('att01', 'SEQUENCE', 'INSERT', 'ATT_01_SQ')
|
43
|
+
a3 = GeneratedAttribute.new('att04', 'TIMESTAMP', 'UPDATE, INSERT ', 'NOW')
|
44
|
+
|
45
|
+
assert(a1 == a1)
|
46
|
+
assert(a1 == a2)
|
47
|
+
assert(a1 != a3)
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
def test03
|
52
|
+
a = GeneratedAttribute.new('TestAttribute', 'TIME', 'INSERT', 'NOW')
|
53
|
+
|
54
|
+
a.events = 'UPDATE'
|
55
|
+
assert(a.events == 'UPDATE')
|
56
|
+
|
57
|
+
a.events = 'INSERT, UPDATE'
|
58
|
+
assert(a.events == 'INSERT,UPDATE')
|
59
|
+
|
60
|
+
a.events = 'UPDATE , INSERT'
|
61
|
+
assert(a.events == 'UPDATE,INSERT')
|
62
|
+
|
63
|
+
a.type = 'SEQUENCE'
|
64
|
+
assert(a.type == 'SEQUENCE')
|
65
|
+
|
66
|
+
a.source = 'ANYTHING'
|
67
|
+
assert(a.source = 'ANYTHING')
|
68
|
+
|
69
|
+
a.type = 'DATE'
|
70
|
+
a.source = 'TODAY'
|
71
|
+
assert(a.source == 'TODAY')
|
72
|
+
|
73
|
+
a.source = 'YESTERDAY'
|
74
|
+
assert(a.source == 'YESTERDAY')
|
75
|
+
|
76
|
+
a.source = 'TOMORROW'
|
77
|
+
assert(a.source == 'TOMORROW')
|
78
|
+
end
|
79
|
+
|
80
|
+
def test04
|
81
|
+
begin
|
82
|
+
GeneratedAttribute.new('name', 'DATE', 'INSERT', 'NOW')
|
83
|
+
assert(false, "1. Able to create an illegal generated attribute.")
|
84
|
+
rescue IotazError
|
85
|
+
end
|
86
|
+
|
87
|
+
begin
|
88
|
+
GeneratedAttribute.new('name', 'TIME', 'INSERT', 'TODAY')
|
89
|
+
assert(false, "2. Able to create an illegal generated attribute.")
|
90
|
+
rescue IotazError
|
91
|
+
end
|
92
|
+
|
93
|
+
begin
|
94
|
+
GeneratedAttribute.new('name', 'TIMESTAMP', 'INSERT', 'TODAY')
|
95
|
+
assert(false, "3. Able to create an illegal generated attribute.")
|
96
|
+
rescue IotazError
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def test05
|
101
|
+
a = GeneratedAttribute.new('name', 'SEQUENCE', 'INSERT', 'BLAH')
|
102
|
+
|
103
|
+
a.type = 'DATE'
|
104
|
+
begin
|
105
|
+
a.source = 'NOW'
|
106
|
+
assert(false, '1. Illegal update of generated attribute succesful.')
|
107
|
+
rescue IotazError
|
108
|
+
end
|
109
|
+
|
110
|
+
a.type = 'TIME'
|
111
|
+
begin
|
112
|
+
a.source = 'TOMORROW'
|
113
|
+
assert(false, '2. Illegal update of generated attribute succesful.')
|
114
|
+
rescue IotazError
|
115
|
+
end
|
116
|
+
|
117
|
+
a.type = 'TIMESTAMP'
|
118
|
+
begin
|
119
|
+
a.source = 'LaLaLa'
|
120
|
+
assert(false, '3. Illegal update of generated attribute succesful.')
|
121
|
+
rescue IotazError
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'rubygems'
|
5
|
+
require_gem 'iotaz'
|
6
|
+
|
7
|
+
include Iotaz
|
8
|
+
|
9
|
+
class IotazErrorTest < Test::Unit::TestCase
|
10
|
+
def test01
|
11
|
+
e = IotazError.new("This is an example message.")
|
12
|
+
|
13
|
+
assert(e.message == "This is an example message.")
|
14
|
+
assert(e.context == [])
|
15
|
+
assert(e.populate("{0} {1} {2}") == "{0} {1} {2}")
|
16
|
+
|
17
|
+
e = IotazError.new("{0} = 1, {1} = 2", "One", 2)
|
18
|
+
|
19
|
+
assert(e.message == "One = 1, 2 = 2")
|
20
|
+
assert(e.context == ["One", 2])
|
21
|
+
assert(e.populate("{0} {1} {2}") == "One 2 {2}")
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'rubygems'
|
5
|
+
require_gem 'iotaz'
|
6
|
+
|
7
|
+
include Iotaz
|
8
|
+
|
9
|
+
class MetaDataTestClass
|
10
|
+
def initialize
|
11
|
+
@id = @one = @two = @three = @created = @updated = nil
|
12
|
+
end
|
13
|
+
|
14
|
+
attr_accessor :one, :two, :three, :id, :created, :updated
|
15
|
+
end
|
16
|
+
|
17
|
+
class IotazMetaDataTest < Test::Unit::TestCase
|
18
|
+
def setup
|
19
|
+
@attributes = []
|
20
|
+
|
21
|
+
@attributes.push(Attribute.new('attribute01'))
|
22
|
+
@attributes.push(Attribute.new('attribute02'))
|
23
|
+
@attributes.push(Attribute.new('attribute03'))
|
24
|
+
@attributes.push(Attribute.new('attribute04'))
|
25
|
+
@attributes.push(Attribute.new('attribute05'))
|
26
|
+
end
|
27
|
+
|
28
|
+
def test01
|
29
|
+
t = 0
|
30
|
+
m = IotazMetaData.new(MetaDataTestClass)
|
31
|
+
|
32
|
+
assert(m.name == 'MetaDataTestClass')
|
33
|
+
assert(m.table == 'MetaDataTestClass')
|
34
|
+
m.each {|entry| t = t + 1}
|
35
|
+
assert(t == 0)
|
36
|
+
assert(m.keys == [])
|
37
|
+
|
38
|
+
t = 0
|
39
|
+
m = IotazMetaData.new(MetaDataTestClass, 'TABLE_NAME')
|
40
|
+
|
41
|
+
assert(m.name == 'MetaDataTestClass')
|
42
|
+
assert(m.table == 'TABLE_NAME')
|
43
|
+
m.each {|entry| t = t + 1}
|
44
|
+
assert(t == 0)
|
45
|
+
assert(m.keys == [])
|
46
|
+
end
|
47
|
+
|
48
|
+
def test02
|
49
|
+
m = IotazMetaData.new(MetaDataTestClass)
|
50
|
+
|
51
|
+
m.add_attribute(@attributes[0])
|
52
|
+
assert(m.attribute_exists?(@attributes[0].name))
|
53
|
+
assert(m.get_attribute(@attributes[0].name) != nil)
|
54
|
+
assert(m.get_attribute(@attributes[0].name) == @attributes[0])
|
55
|
+
assert(m.keys == [])
|
56
|
+
|
57
|
+
t = 0
|
58
|
+
m.each {|a| t = t + 1}
|
59
|
+
assert(t == 1)
|
60
|
+
|
61
|
+
m.delete_attribute(@attributes[0].name)
|
62
|
+
assert(m.attribute_exists?(@attributes[0].name) == false)
|
63
|
+
end
|
64
|
+
|
65
|
+
def test03
|
66
|
+
m = IotazMetaData.scan(MetaDataTestClass)
|
67
|
+
|
68
|
+
assert(m.name == 'MetaDataTestClass')
|
69
|
+
assert(m.table == 'MetaDataTestClass')
|
70
|
+
|
71
|
+
t = 0
|
72
|
+
m.each {|a| t = t + 1}
|
73
|
+
assert(t == 6)
|
74
|
+
|
75
|
+
assert(m.attribute_exists?('two'))
|
76
|
+
assert(m.attribute_exists?('id'))
|
77
|
+
assert(m.attribute_exists?('created'))
|
78
|
+
assert(m.keys == ["id"])
|
79
|
+
|
80
|
+
assert(m.get_attribute('one').instance_of?(Attribute))
|
81
|
+
assert(m.get_attribute('created').instance_of?(GeneratedAttribute))
|
82
|
+
|
83
|
+
m.delete_attribute('id')
|
84
|
+
assert(m.attribute_exists?('id') == false)
|
85
|
+
assert(m.keys == [])
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'rubygems'
|
5
|
+
require_gem 'iotaz'
|
6
|
+
|
7
|
+
include Iotaz
|
8
|
+
|
9
|
+
class ObjectFactory
|
10
|
+
def initialize
|
11
|
+
@current = 0
|
12
|
+
end
|
13
|
+
|
14
|
+
def create
|
15
|
+
@current += 1
|
16
|
+
end
|
17
|
+
|
18
|
+
def destroy(object)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class ObjectPoolTest < Test::Unit::TestCase
|
23
|
+
def setup
|
24
|
+
@factory = ObjectFactory.new
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
def test01
|
29
|
+
p = ObjectPool.new(@factory, 10)
|
30
|
+
|
31
|
+
assert(p.factory == @factory)
|
32
|
+
assert(p.idle == -1)
|
33
|
+
assert(p.interval == 600)
|
34
|
+
assert(p.maximum == 10)
|
35
|
+
assert(p.minimum == 0)
|
36
|
+
assert(p.size == 0)
|
37
|
+
assert(p.available == 0)
|
38
|
+
|
39
|
+
p = ObjectPool.new(@factory, 20, 5)
|
40
|
+
|
41
|
+
assert(p.factory == @factory)
|
42
|
+
assert(p.idle == -1)
|
43
|
+
assert(p.interval == 600)
|
44
|
+
assert(p.maximum == 20)
|
45
|
+
assert(p.minimum == 5)
|
46
|
+
assert(p.size == 5)
|
47
|
+
assert(p.available == 5)
|
48
|
+
|
49
|
+
p = ObjectPool.new(@factory, 20, 5, 1800)
|
50
|
+
|
51
|
+
assert(p.factory == @factory)
|
52
|
+
assert(p.idle == 1800)
|
53
|
+
assert(p.interval == 600)
|
54
|
+
assert(p.maximum == 20)
|
55
|
+
assert(p.minimum == 5)
|
56
|
+
assert(p.size == 5)
|
57
|
+
assert(p.available == 5)
|
58
|
+
|
59
|
+
p = ObjectPool.new(@factory, 20, 5, 3600, 300)
|
60
|
+
|
61
|
+
assert(p.factory == @factory)
|
62
|
+
assert(p.idle == 3600)
|
63
|
+
assert(p.interval == 300)
|
64
|
+
assert(p.maximum == 20)
|
65
|
+
assert(p.minimum == 5)
|
66
|
+
assert(p.size == 5)
|
67
|
+
assert(p.available == 5)
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
def test02
|
72
|
+
p = ObjectPool.new(@factory, 10)
|
73
|
+
a = []
|
74
|
+
|
75
|
+
a.push(p.acquire)
|
76
|
+
assert(a[0] != nil)
|
77
|
+
assert(p.size == 1)
|
78
|
+
assert(p.available == 0)
|
79
|
+
|
80
|
+
p.release(a[0])
|
81
|
+
|
82
|
+
assert(p.size == 1)
|
83
|
+
assert(p.available == 1)
|
84
|
+
|
85
|
+
a.clear
|
86
|
+
10.times do
|
87
|
+
a.push(p.acquire)
|
88
|
+
end
|
89
|
+
|
90
|
+
begin
|
91
|
+
p.acquire(false)
|
92
|
+
assert(false, "Acquired resource from max'ed out pool")
|
93
|
+
rescue Exception
|
94
|
+
end
|
95
|
+
|
96
|
+
assert(p.size == 10)
|
97
|
+
assert(p.available == 0)
|
98
|
+
|
99
|
+
available = 1
|
100
|
+
a.each do |entry|
|
101
|
+
p.release(entry)
|
102
|
+
assert(p.available == available)
|
103
|
+
available += 1
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'dbinfo'
|
5
|
+
require 'rubygems'
|
6
|
+
require_gem 'iotaz'
|
7
|
+
require_gem 'fireruby'
|
8
|
+
|
9
|
+
include Iotaz
|
10
|
+
|
11
|
+
# Class for use in testing.
|
12
|
+
class PersistentTestClass
|
13
|
+
include Persistent
|
14
|
+
|
15
|
+
sequence_attr :id
|
16
|
+
persistent_attr :number, 'accountno'
|
17
|
+
persistent_attr :customer, 'name', true
|
18
|
+
date_attr :created
|
19
|
+
time_attr :now, 'nowtime', true, false, false
|
20
|
+
timestamp_attr :updated, nil, false, true
|
21
|
+
|
22
|
+
def initialize(number, customer)
|
23
|
+
@number = number
|
24
|
+
@customer = customer
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class PersistentTest < Test::Unit::TestCase
|
29
|
+
def test01
|
30
|
+
metadata = PersistentTestClass.iotaz_meta_data
|
31
|
+
account = PersistentTestClass.new('', '')
|
32
|
+
|
33
|
+
assert(metadata.attribute_exists?('id'))
|
34
|
+
assert(metadata.attribute_exists?('number'))
|
35
|
+
assert(metadata.attribute_exists?('customer'))
|
36
|
+
assert(metadata.attribute_exists?('created'))
|
37
|
+
assert(metadata.attribute_exists?('now'))
|
38
|
+
assert(metadata.attribute_exists?('updated'))
|
39
|
+
|
40
|
+
attribute = metadata.get_attribute('id')
|
41
|
+
assert(attribute.name == 'id')
|
42
|
+
assert(attribute.accessor == 'id')
|
43
|
+
assert(attribute.mutator == 'id=')
|
44
|
+
assert(attribute.column == 'id')
|
45
|
+
assert(attribute.type == 'SEQUENCE')
|
46
|
+
assert(attribute.is_generated? == true)
|
47
|
+
assert(attribute.source == 'PERSISTENTTESTCLASS_ID_SQ')
|
48
|
+
assert(attribute.events.include?('INSERT') == true)
|
49
|
+
assert(attribute.events.include?('UPDATE') == false)
|
50
|
+
assert(account.methods.include?('id=') == false)
|
51
|
+
|
52
|
+
attribute = metadata.get_attribute('number')
|
53
|
+
assert(attribute.name == 'number')
|
54
|
+
assert(attribute.accessor == 'number')
|
55
|
+
assert(attribute.mutator == 'number=')
|
56
|
+
assert(attribute.column == 'accountno')
|
57
|
+
assert(account.methods.include?('number=') == true)
|
58
|
+
|
59
|
+
attribute = metadata.get_attribute('customer')
|
60
|
+
assert(attribute.name == 'customer')
|
61
|
+
assert(attribute.accessor == 'customer')
|
62
|
+
assert(attribute.mutator == 'customer=')
|
63
|
+
assert(attribute.column == 'name')
|
64
|
+
assert(account.methods.include?('customer=') == false)
|
65
|
+
|
66
|
+
attribute = metadata.get_attribute('created')
|
67
|
+
assert(attribute.name == 'created')
|
68
|
+
assert(attribute.accessor == 'created')
|
69
|
+
assert(attribute.mutator == 'created=')
|
70
|
+
assert(attribute.column == 'created')
|
71
|
+
assert(attribute.type == 'DATE')
|
72
|
+
assert(attribute.is_generated? == true)
|
73
|
+
assert(attribute.source == 'TODAY')
|
74
|
+
assert(attribute.events.include?('INSERT') == true)
|
75
|
+
assert(attribute.events.include?('UPDATE') == false)
|
76
|
+
assert(account.methods.include?('created=') == false)
|
77
|
+
|
78
|
+
attribute = metadata.get_attribute('now')
|
79
|
+
assert(attribute.name == 'now')
|
80
|
+
assert(attribute.accessor == 'now')
|
81
|
+
assert(attribute.mutator == 'now=')
|
82
|
+
assert(attribute.column == 'nowtime')
|
83
|
+
assert(attribute.type == 'TIME')
|
84
|
+
assert(attribute.is_generated? == true)
|
85
|
+
assert(attribute.source == 'NOW')
|
86
|
+
assert(attribute.events.include?('INSERT') == true)
|
87
|
+
assert(attribute.events.include?('UPDATE') == false)
|
88
|
+
assert(account.methods.include?('now=') == true)
|
89
|
+
|
90
|
+
attribute = metadata.get_attribute('updated')
|
91
|
+
assert(attribute.name == 'updated')
|
92
|
+
assert(attribute.accessor == 'updated')
|
93
|
+
assert(attribute.mutator == 'updated=')
|
94
|
+
assert(attribute.column == 'updated')
|
95
|
+
assert(attribute.type == 'TIMESTAMP')
|
96
|
+
assert(attribute.is_generated? == true)
|
97
|
+
assert(attribute.source == 'NOW')
|
98
|
+
assert(attribute.events.include?('INSERT') == false)
|
99
|
+
assert(attribute.events.include?('UPDATE') == true)
|
100
|
+
assert(account.methods.include?('updated=') == false)
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,152 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'rubygems'
|
5
|
+
require_gem 'iotaz'
|
6
|
+
|
7
|
+
include Iotaz
|
8
|
+
|
9
|
+
class QueryFieldTest < Test::Unit::TestCase
|
10
|
+
def setup
|
11
|
+
@metadata = IotazMetaData.new(QueryFieldTest, 'THE_TABLE')
|
12
|
+
|
13
|
+
@metadata.add_attribute(GeneratedAttribute.new('id', 'SEQUENCE',
|
14
|
+
'INSERT', 'QUERY_ID_SQ'))
|
15
|
+
@metadata.add_attribute(Attribute.new('value01', 'val01'))
|
16
|
+
@metadata.add_attribute(Attribute.new('value02', 'val02'))
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
def test1
|
21
|
+
field = QueryField.new('value01', @metadata)
|
22
|
+
|
23
|
+
assert(field.name == 'value01')
|
24
|
+
assert(field.column == 'val01')
|
25
|
+
assert(field.table == @metadata.table)
|
26
|
+
assert(field.fetched == true)
|
27
|
+
assert(field.comparison == nil)
|
28
|
+
assert(field.value == nil)
|
29
|
+
|
30
|
+
field = QueryField.new('value02', @metadata, false)
|
31
|
+
|
32
|
+
assert(field.name == 'value02')
|
33
|
+
assert(field.column == 'val02')
|
34
|
+
assert(field.table == @metadata.table)
|
35
|
+
assert(field.fetched? == false)
|
36
|
+
assert(field.comparison == nil)
|
37
|
+
assert(field.value == nil)
|
38
|
+
end
|
39
|
+
|
40
|
+
def test2
|
41
|
+
field = QueryField.new('value01', @metadata)
|
42
|
+
|
43
|
+
field.equal_to(nil)
|
44
|
+
assert(field.comparison == 'is null')
|
45
|
+
assert(field.value == nil)
|
46
|
+
|
47
|
+
field.equal_to(1234)
|
48
|
+
assert(field.comparison == '= ?')
|
49
|
+
assert(field.value == 1234)
|
50
|
+
|
51
|
+
field.not_equal_to(nil)
|
52
|
+
assert(field.comparison == 'is not null')
|
53
|
+
assert(field.value == nil)
|
54
|
+
|
55
|
+
field.not_equal_to('lalala')
|
56
|
+
assert(field.comparison == '!= ?')
|
57
|
+
assert(field.value == 'lalala')
|
58
|
+
|
59
|
+
field.greater_than(1234)
|
60
|
+
assert(field.comparison == '> ?')
|
61
|
+
assert(field.value == 1234)
|
62
|
+
|
63
|
+
field.less_than('1234')
|
64
|
+
assert(field.comparison == '< ?')
|
65
|
+
assert(field.value == '1234')
|
66
|
+
|
67
|
+
field.greater_than_or_equal_to('woowoo')
|
68
|
+
assert(field.comparison == '>= ?')
|
69
|
+
assert(field.value == 'woowoo')
|
70
|
+
|
71
|
+
field.less_than_or_equal_to(5432)
|
72
|
+
assert(field.comparison == '<= ?')
|
73
|
+
assert(field.value == 5432)
|
74
|
+
|
75
|
+
field.between(1, 10)
|
76
|
+
assert(field.comparison == 'between ? and ?')
|
77
|
+
assert(field.value == [1, 10])
|
78
|
+
|
79
|
+
field.not_between(25, 100)
|
80
|
+
assert(field.comparison == 'not between ? and ?')
|
81
|
+
assert(field.value == [25, 100])
|
82
|
+
|
83
|
+
field.in(1, 3, 5, 7 , 9)
|
84
|
+
assert(field.comparison == 'in (1, 3, 5, 7, 9)')
|
85
|
+
assert(field.value == nil)
|
86
|
+
|
87
|
+
field.not_in('one', 'two', 'three')
|
88
|
+
assert(field.comparison == "not in ('one', 'two', 'three')")
|
89
|
+
assert(field.value == nil)
|
90
|
+
|
91
|
+
begin
|
92
|
+
field.greater_than(nil)
|
93
|
+
assert(fail, 'Added query field > comparison for nil.')
|
94
|
+
rescue Exception
|
95
|
+
end
|
96
|
+
|
97
|
+
begin
|
98
|
+
field.less_than(nil)
|
99
|
+
assert(fail, 'Added query field < comparison for nil.')
|
100
|
+
rescue Exception
|
101
|
+
end
|
102
|
+
|
103
|
+
begin
|
104
|
+
field.greater_than_or_equal_to(nil)
|
105
|
+
assert(fail, 'Added query field >= comparison for nil.')
|
106
|
+
rescue Exception
|
107
|
+
end
|
108
|
+
|
109
|
+
begin
|
110
|
+
field.less_than_or_equal_to(nil)
|
111
|
+
assert(fail, 'Added query field <= comparison for nil.')
|
112
|
+
rescue Exception
|
113
|
+
end
|
114
|
+
|
115
|
+
begin
|
116
|
+
field.between(100, nil)
|
117
|
+
assert(fail, 'Added query field between comparison for nil.')
|
118
|
+
rescue Exception
|
119
|
+
end
|
120
|
+
|
121
|
+
begin
|
122
|
+
field.not_between(100, nil)
|
123
|
+
assert(fail, 'Added query field not between comparison for nil.')
|
124
|
+
rescue Exception
|
125
|
+
end
|
126
|
+
|
127
|
+
begin
|
128
|
+
field.in([])
|
129
|
+
assert(fail, 'Added query field in comparison for empty array.')
|
130
|
+
rescue Exception
|
131
|
+
end
|
132
|
+
|
133
|
+
begin
|
134
|
+
field.not_in([])
|
135
|
+
assert(fail, 'Added query field not in comparison for empty array.')
|
136
|
+
rescue Exception
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
|
141
|
+
def test03
|
142
|
+
field = QueryField.new('value01', @metadata)
|
143
|
+
|
144
|
+
assert(field.name_match?('value01'))
|
145
|
+
assert(field.name_match?('QueryFieldTest.value01'))
|
146
|
+
assert(field.name_match?('val01'))
|
147
|
+
assert(field.name_match?('THE_TABLE.val01'))
|
148
|
+
assert(field.name_match?(nil) == false)
|
149
|
+
assert(field.name_match?('') == false)
|
150
|
+
assert(field.name_match?('Lalala') == false)
|
151
|
+
end
|
152
|
+
end
|