razorrisk-razor-connectivity 0.14.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Rakefile +89 -0
- data/lib/razor_risk/razor/connectivity/clarite_2/config_maker.rb +162 -0
- data/lib/razor_risk/razor/connectivity/exceptions.rb +101 -0
- data/lib/razor_risk/razor/connectivity/razor_3/body_maker.rb +126 -0
- data/lib/razor_risk/razor/connectivity/razor_3/header_maker.rb +273 -0
- data/lib/razor_risk/razor/connectivity/razor_3/message_map.rb +156 -0
- data/lib/razor_risk/razor/connectivity/razor_3/razor_requester.rb +559 -0
- data/lib/razor_risk/razor/connectivity/razor_3/response.rb +224 -0
- data/lib/razor_risk/razor/connectivity/razor_3.rb +5 -0
- data/lib/razor_risk/razor/connectivity/version.rb +40 -0
- data/test/bin/razor_request_exe_empty_response.rb +28 -0
- data/test/unit/connectivity/clarite_2/tc_config_maker.rb +399 -0
- data/test/unit/connectivity/razor_3/tc_body_maker.rb +164 -0
- data/test/unit/connectivity/razor_3/tc_header_maker.rb +652 -0
- data/test/unit/connectivity/razor_3/tc_message_map.rb +125 -0
- data/test/unit/connectivity/razor_3/tc_razor_requester.rb +244 -0
- data/test/unit/connectivity/razor_3/tc_razor_requester_executable.rb +176 -0
- data/test/unit/connectivity/razor_3/tc_response.rb +239 -0
- metadata +158 -0
@@ -0,0 +1,164 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
# ##########################################################################
|
5
|
+
#
|
6
|
+
# Copyright (c) 2018 Razor Risk Technologies Pty Limited. All rights reserved.
|
7
|
+
#
|
8
|
+
# ##########################################################################
|
9
|
+
|
10
|
+
|
11
|
+
# ##########################################################
|
12
|
+
# load path
|
13
|
+
|
14
|
+
$:.unshift File.join(File.dirname(__FILE__), *(['..'] * 4), 'lib')
|
15
|
+
|
16
|
+
|
17
|
+
# ##########################################################
|
18
|
+
# diagnostics
|
19
|
+
|
20
|
+
unless $DEBUG
|
21
|
+
|
22
|
+
require 'pantheios/globals'
|
23
|
+
require 'pantheios/services/null_log_service'
|
24
|
+
|
25
|
+
::Pantheios::Globals.INITIAL_SERVICE_CLASSES = [ ::Pantheios::Services::NullLogService ]
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
# ##########################################################
|
30
|
+
# code coverage
|
31
|
+
|
32
|
+
require 'simplecov'
|
33
|
+
|
34
|
+
|
35
|
+
# ##########################################################
|
36
|
+
# requires
|
37
|
+
|
38
|
+
require 'razor_risk/razor/connectivity/razor_3/body_maker'
|
39
|
+
|
40
|
+
require 'xqsr3/xml/utilities/compare'
|
41
|
+
require 'xqsr3/extensions/test/unit'
|
42
|
+
|
43
|
+
require 'test/unit'
|
44
|
+
|
45
|
+
|
46
|
+
# ##########################################################
|
47
|
+
# tests
|
48
|
+
|
49
|
+
class Test_BodyMaker_types_exist < Test::Unit::TestCase
|
50
|
+
|
51
|
+
def test_has_RazorRisk_module
|
52
|
+
|
53
|
+
assert Object.const_defined? :RazorRisk
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_has_RazorRisk_Razor_module
|
57
|
+
|
58
|
+
assert RazorRisk.const_defined? :Razor
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_has_RazorRisk_Razor_Connectivity_module
|
62
|
+
|
63
|
+
assert RazorRisk::Razor.const_defined? :Connectivity
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_has_RazorRisk_Razor_Connectivity_Razor3_module
|
67
|
+
|
68
|
+
assert RazorRisk::Razor::Connectivity.const_defined? :Razor3
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_has_BodyMaker_class
|
72
|
+
|
73
|
+
assert RazorRisk::Razor::Connectivity::Razor3.const_defined? :BodyMaker
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_BodyMaker_is_a_class
|
77
|
+
|
78
|
+
assert_kind_of ::Class, ::RazorRisk::Razor::Connectivity::Razor3::BodyMaker
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
class Test_BodyMaker_class_methods < Test::Unit::TestCase
|
84
|
+
|
85
|
+
include ::RazorRisk::Razor::Connectivity::Razor3
|
86
|
+
|
87
|
+
include ::Xqsr3::XML::Utilities::Compare
|
88
|
+
|
89
|
+
def test_make_condition
|
90
|
+
|
91
|
+
xp = <<END_OF_xml
|
92
|
+
<condition id="789">
|
93
|
+
<keyPath>
|
94
|
+
<keyElement nodeOffset="1">Portfolio</keyElement>
|
95
|
+
<keyElement nodeOffset="2">ID</keyElement>
|
96
|
+
</keyPath>
|
97
|
+
<name>Portfolio</name>
|
98
|
+
<values>
|
99
|
+
<value id="1">12345</value>
|
100
|
+
</values>
|
101
|
+
<oper>Equals</oper>
|
102
|
+
</condition>
|
103
|
+
END_OF_xml
|
104
|
+
|
105
|
+
bm = BodyMaker.new
|
106
|
+
|
107
|
+
b = bm.make_condition(id: 789, key_path_elements: { 1 => 'Portfolio', 2 => 'ID' }, name: 'Portfolio', oper: 'Equals', values: { 1 => '12345' })
|
108
|
+
|
109
|
+
assert_kind_of ::Nokogiri::XML::Element, b
|
110
|
+
|
111
|
+
assert_not_nil 789, b['id']
|
112
|
+
|
113
|
+
assert_not_nil b.at_xpath('name')
|
114
|
+
assert_equal 'Portfolio', b.at_xpath('name').text
|
115
|
+
assert_equal 2, b.xpath('keyPath/keyElement').size
|
116
|
+
assert_not_nil b.at_xpath('values')
|
117
|
+
assert_equal 1, b.xpath('values').size
|
118
|
+
assert_not_nil b.at_xpath('oper')
|
119
|
+
|
120
|
+
r = xml_compare xp, b, ignore_child_node_order: true, normalise_whitespace: true
|
121
|
+
|
122
|
+
assert r.same?, "#{r.details}"
|
123
|
+
end
|
124
|
+
|
125
|
+
def test_make_query
|
126
|
+
|
127
|
+
xp = <<END_OF_xml
|
128
|
+
<query>
|
129
|
+
<exactMatch>true</exactMatch>
|
130
|
+
<condition id="789">
|
131
|
+
<keyPath>
|
132
|
+
<keyElement nodeOffset="1">Portfolio</keyElement>
|
133
|
+
<keyElement nodeOffset="2">ID</keyElement>
|
134
|
+
</keyPath>
|
135
|
+
<name>Portfolio</name>
|
136
|
+
<values>
|
137
|
+
<value id="1">12345</value>
|
138
|
+
</values>
|
139
|
+
<oper>Equals</oper>
|
140
|
+
</condition>
|
141
|
+
</query>
|
142
|
+
END_OF_xml
|
143
|
+
|
144
|
+
bm = BodyMaker.new
|
145
|
+
|
146
|
+
c1 = bm.make_condition(id: 789, key_path_elements: { 1 => 'Portfolio', 2 => 'ID' }, name: 'Portfolio', oper: 'Equals', values: { 1 => '12345' })
|
147
|
+
|
148
|
+
q = bm.make_query(params: { :exactMatch => true }, conditions: [ c1 ])
|
149
|
+
|
150
|
+
assert_kind_of ::Nokogiri::XML::Element, q
|
151
|
+
|
152
|
+
assert_not_nil q.at_xpath('exactMatch')
|
153
|
+
assert_equal 'true', q.at_xpath('exactMatch').text
|
154
|
+
|
155
|
+
assert_not_nil q.at_xpath('conditions')
|
156
|
+
cs = q.xpath('conditions/condition')
|
157
|
+
assert_not_empty cs
|
158
|
+
assert_equal 1, cs.size
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
# ############################## end of file ############################# #
|
163
|
+
|
164
|
+
|