parse_decision 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/Gemfile +6 -0
- data/LICENSE +22 -0
- data/README.md +71 -0
- data/bin/parse_decision +126 -0
- data/lib/parse_decision/config.rb +90 -0
- data/lib/parse_decision/controller.rb +142 -0
- data/lib/parse_decision/parsedecisiontask.rb +31 -0
- data/lib/parse_decision/parser.rb +194 -0
- data/lib/parse_decision/pd_context.rb +148 -0
- data/lib/parse_decision/plugin/application.rb +48 -0
- data/lib/parse_decision/plugin/plugin.rb +56 -0
- data/lib/parse_decision/plugin/ppm_xpath.rb +70 -0
- data/lib/parse_decision/plugin/pre_decision_guideline.rb +177 -0
- data/lib/parse_decision/plugin/product.rb +176 -0
- data/lib/parse_decision/plugin/product_xpath.rb +52 -0
- data/lib/parse_decision/plugin/web_product.rb +179 -0
- data/lib/parse_decision/plugin.rb +50 -0
- data/lib/parse_decision/version.rb +5 -0
- data/lib/parse_decision.rb +59 -0
- data/parse_decision.gemspec +27 -0
- data/rakefile.rb +58 -0
- data/spec/context_spec.rb +21 -0
- data/spec/data/multiproduct.decision.txt +1481 -0
- data/spec/data/prod.decision.txt +3957 -0
- data/spec/data/reference/multiproduct/001-APP.xml +1 -0
- data/spec/data/reference/multiproduct/001-Mod-Forbear-PRODUCT.xml +357 -0
- data/spec/data/reference/multiproduct/001-Mod-Forgive-PRODUCT.xml +361 -0
- data/spec/data/reference/multiproduct/001-Mod-RateTerm-PRODUCT.xml +353 -0
- data/spec/data/reference/multiproduct/001-Mod-SAM-PRODUCT.xml +365 -0
- data/spec/data/reference/product/001-APP.xml +1 -0
- data/spec/data/reference/product/001-Validation-Rules.xml +536 -0
- data/spec/data/reference/product/002-APP.xml +1 -0
- data/spec/data/reference/product/002-FAPIILoanModification-PRODUCT.xml +1770 -0
- data/spec/data/reference/web/001-APP.xml +1 -0
- data/spec/data/reference/web/001-Product01-PRODUCT.xml +1088 -0
- data/spec/data/reference/web/002-APP.xml +1 -0
- data/spec/data/reference/web/002-Product01-PRODUCT.xml +15 -0
- data/spec/data/reference/workflow/001-APP.xml +1 -0
- data/spec/data/reference/workflow/001-WF-DataClearing-Pre-Rules.xml +37 -0
- data/spec/data/reference/workflow-2/001-APP.xml +1 -0
- data/spec/data/reference/workflow-2/001-WF-ProdSel-Post-Rules.xml +699 -0
- data/spec/data/test.rb +13 -0
- data/spec/data/validation.decision.txt +1199 -0
- data/spec/data/web.decision.txt +1128 -0
- data/spec/data/wf.decision.txt +43 -0
- data/spec/data/wf2.decision.txt +705 -0
- data/spec/parser_spec.rb +308 -0
- data/spec/plugin_app_spec.rb +40 -0
- data/spec/plugin_ppmxpath_spec.rb +74 -0
- data/spec/plugin_predecision_spec.rb +81 -0
- data/spec/plugin_product_spec.rb +117 -0
- data/spec/plugin_productxpath_spec.rb +76 -0
- data/spec/plugin_spec.rb +54 -0
- data/spec/spec_helper.rb +81 -0
- data/test/data/2.2.decision-multiple.txt +1391 -0
- data/test/data/2.2.decision.txt +1128 -0
- data/test/data/2.decision.txt +1481 -0
- data/test/plugins/test_plugin_predecisionguideline.rb +120 -0
- data/test/plugins/test_plugin_product.rb +120 -0
- data/test/test_config.rb +90 -0
- data/test/test_context.rb +103 -0
- data/test/test_parse_webdecision.rb +121 -0
- data/test/test_parser.rb +69 -0
- data/test/test_parser_parse.rb +110 -0
- metadata +225 -0
@@ -0,0 +1,120 @@
|
|
1
|
+
##############################################################################
|
2
|
+
# File:: test_plugin_predecisionguideline.rb
|
3
|
+
# Purpose:: Test Plugin::PreDecisionGuideline class functionality
|
4
|
+
#
|
5
|
+
# Author:: Jeff McAffee 04/18/2010
|
6
|
+
# Copyright:: Copyright (c) 2010, kTech Systems LLC. All rights reserved.
|
7
|
+
# Website:: http://ktechsystems.com
|
8
|
+
##############################################################################
|
9
|
+
|
10
|
+
require 'test/unit' #(1)
|
11
|
+
require 'flexmock/test_unit'
|
12
|
+
#require 'testhelper/filecomparer'
|
13
|
+
require 'logger'
|
14
|
+
|
15
|
+
require 'fileutils'
|
16
|
+
|
17
|
+
require 'parse_decision'
|
18
|
+
|
19
|
+
class TestPluginPreDecisionGuideline < Test::Unit::TestCase #(3)
|
20
|
+
include FileUtils
|
21
|
+
include FlexMock::TestCase
|
22
|
+
include ParseDecision
|
23
|
+
|
24
|
+
#-------------------------------------------------------------------------------------------------------------#
|
25
|
+
# setup - Set up test fixture
|
26
|
+
#
|
27
|
+
#------------------------------------------------------------------------------------------------------------#
|
28
|
+
def setup
|
29
|
+
$LOG = Logger.new(STDERR)
|
30
|
+
$LOG.level = Logger::DEBUG
|
31
|
+
@baseDir = File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
32
|
+
@dataDir = File.join(@baseDir, "data")
|
33
|
+
@outputDir = File.join(@dataDir, "output")
|
34
|
+
|
35
|
+
@context = PDContext.new
|
36
|
+
assert(nil != @context)
|
37
|
+
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
#-------------------------------------------------------------------------------------------------------------#
|
42
|
+
# teardown - Clean up test fixture
|
43
|
+
#
|
44
|
+
#------------------------------------------------------------------------------------------------------------#
|
45
|
+
def teardown
|
46
|
+
@context = nil
|
47
|
+
end
|
48
|
+
|
49
|
+
#-------------------------------------------------------------------------------------------------------------#
|
50
|
+
# cleanOutput - Clean up output directory
|
51
|
+
#
|
52
|
+
#------------------------------------------------------------------------------------------------------------#
|
53
|
+
def cleanOutput
|
54
|
+
if(!File.exists?(@outputDir))
|
55
|
+
FileUtils.mkdir(@outputDir)
|
56
|
+
return
|
57
|
+
end
|
58
|
+
|
59
|
+
if(File.directory?(@outputDir))
|
60
|
+
FileUtils.rm_r(@outputDir)
|
61
|
+
FileUtils.mkdir(@outputDir)
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
#-------------------------------------------------------------------------------------------------------------#
|
68
|
+
# test_plugin_predecisionguideline_attrib_replacement - Test the Plugin::Product class
|
69
|
+
#
|
70
|
+
#------------------------------------------------------------------------------------------------------------#
|
71
|
+
def test_plugin_predecisionguideline_attrib_replacement
|
72
|
+
plugin = Plugin::PreDecisionGuideline.new
|
73
|
+
assert(nil != plugin)
|
74
|
+
|
75
|
+
target = "<PARAMS><_DATA_SET _Name='Test1' _Value='1'/><_DATA_SET _Name='Test2' _Value='2'/><_DATA_SET _Name='Test3' _Value='3'/></PARAMS>"
|
76
|
+
expected = "<PARAMS><DATA_SET Name='Test1' Value='1'/><DATA_SET Name='Test2' Value='2'/><DATA_SET Name='Test3' Value='3'/></PARAMS>"
|
77
|
+
|
78
|
+
@context.state = :app
|
79
|
+
result = plugin.execute( @context, target )
|
80
|
+
assert(result, "Product.execute() returned false.")
|
81
|
+
|
82
|
+
output = plugin.ppmData
|
83
|
+
assert(output == expected, "Output did not match expected.")
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
#-------------------------------------------------------------------------------------------------------------#
|
88
|
+
# INOPtest_parsedecision_parse - Test the parseFile function
|
89
|
+
#
|
90
|
+
#------------------------------------------------------------------------------------------------------------#
|
91
|
+
def INOPtest_parsedecision_parse
|
92
|
+
target = Parser.new
|
93
|
+
assert(nil != target)
|
94
|
+
|
95
|
+
fname = "2.decision.txt"
|
96
|
+
srcFile = File.join(@dataDir, fname)
|
97
|
+
assert(File.exists?(srcFile))
|
98
|
+
|
99
|
+
cleanOutput()
|
100
|
+
|
101
|
+
target.setOutdir(@outputDir)
|
102
|
+
target.parseFile(srcFile)
|
103
|
+
|
104
|
+
assert(File.exists?(File.join(@outputDir, "01-APP.xml")))
|
105
|
+
assert(File.exists?(File.join(@outputDir, "01-Mod-Forbear-PRODUCT.xml")))
|
106
|
+
assert(File.exists?(File.join(@outputDir, "01-Mod-Forgive-PRODUCT.xml")))
|
107
|
+
assert(File.exists?(File.join(@outputDir, "01-Mod-RateTerm-PRODUCT.xml")))
|
108
|
+
assert(File.exists?(File.join(@outputDir, "01-Mod-SAM-PRODUCT.xml")))
|
109
|
+
end
|
110
|
+
|
111
|
+
#-------------------------------------------------------------------------------------------------------------#
|
112
|
+
# test_parsedecision_does_something
|
113
|
+
#
|
114
|
+
#------------------------------------------------------------------------------------------------------------#
|
115
|
+
def test_plugin_product_does_something
|
116
|
+
|
117
|
+
end
|
118
|
+
|
119
|
+
|
120
|
+
end # TestPluginProduct
|
@@ -0,0 +1,120 @@
|
|
1
|
+
##############################################################################
|
2
|
+
# File:: test_plugin_product.rb
|
3
|
+
# Purpose:: Test Plugin::Product class functionality
|
4
|
+
#
|
5
|
+
# Author:: Jeff McAffee 04/18/2010
|
6
|
+
# Copyright:: Copyright (c) 2010, kTech Systems LLC. All rights reserved.
|
7
|
+
# Website:: http://ktechsystems.com
|
8
|
+
##############################################################################
|
9
|
+
|
10
|
+
require 'test/unit' #(1)
|
11
|
+
require 'flexmock/test_unit'
|
12
|
+
#require 'testhelper/filecomparer'
|
13
|
+
require 'logger'
|
14
|
+
|
15
|
+
require 'fileutils'
|
16
|
+
|
17
|
+
require 'parse_decision'
|
18
|
+
|
19
|
+
class TestPluginProduct < Test::Unit::TestCase #(3)
|
20
|
+
include FileUtils
|
21
|
+
include FlexMock::TestCase
|
22
|
+
include ParseDecision
|
23
|
+
|
24
|
+
#-------------------------------------------------------------------------------------------------------------#
|
25
|
+
# setup - Set up test fixture
|
26
|
+
#
|
27
|
+
#------------------------------------------------------------------------------------------------------------#
|
28
|
+
def setup
|
29
|
+
$LOG = Logger.new(STDERR)
|
30
|
+
$LOG.level = Logger::DEBUG
|
31
|
+
@baseDir = File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
32
|
+
@dataDir = File.join(@baseDir, "data")
|
33
|
+
@outputDir = File.join(@dataDir, "output")
|
34
|
+
|
35
|
+
@context = PDContext.new
|
36
|
+
assert(nil != @context)
|
37
|
+
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
#-------------------------------------------------------------------------------------------------------------#
|
42
|
+
# teardown - Clean up test fixture
|
43
|
+
#
|
44
|
+
#------------------------------------------------------------------------------------------------------------#
|
45
|
+
def teardown
|
46
|
+
@context = nil
|
47
|
+
end
|
48
|
+
|
49
|
+
#-------------------------------------------------------------------------------------------------------------#
|
50
|
+
# cleanOutput - Clean up output directory
|
51
|
+
#
|
52
|
+
#------------------------------------------------------------------------------------------------------------#
|
53
|
+
def cleanOutput
|
54
|
+
if(!File.exists?(@outputDir))
|
55
|
+
FileUtils.mkdir(@outputDir)
|
56
|
+
return
|
57
|
+
end
|
58
|
+
|
59
|
+
if(File.directory?(@outputDir))
|
60
|
+
FileUtils.rm_r(@outputDir)
|
61
|
+
FileUtils.mkdir(@outputDir)
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
#-------------------------------------------------------------------------------------------------------------#
|
68
|
+
# test_plugin_product_attrib_replacement - Test the Plugin::Product class
|
69
|
+
#
|
70
|
+
#------------------------------------------------------------------------------------------------------------#
|
71
|
+
def test_plugin_product_attrib_replacement
|
72
|
+
plugin = Plugin::Product.new
|
73
|
+
assert(nil != plugin)
|
74
|
+
|
75
|
+
target = "<PARAMS><_DATA_SET _Name='Test1' _Value='1'/><_DATA_SET _Name='Test2' _Value='2'/><_DATA_SET _Name='Test3' _Value='3'/></PARAMS>"
|
76
|
+
expected = "<PARAMS><DATA_SET Name='Test1' Value='1'/><DATA_SET Name='Test2' Value='2'/><DATA_SET Name='Test3' Value='3'/></PARAMS>"
|
77
|
+
|
78
|
+
@context.state = :productXml
|
79
|
+
result = plugin.execute( @context, target )
|
80
|
+
assert(result, "Product.execute() returned false.")
|
81
|
+
|
82
|
+
output = plugin.data[0]
|
83
|
+
assert(output == expected, "Output did not match expected.")
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
#-------------------------------------------------------------------------------------------------------------#
|
88
|
+
# test_parsedecision_parse - Test the parseFile function
|
89
|
+
#
|
90
|
+
#------------------------------------------------------------------------------------------------------------#
|
91
|
+
def INOPtest_parsedecision_parse
|
92
|
+
target = Parser.new
|
93
|
+
assert(nil != target)
|
94
|
+
|
95
|
+
fname = "2.decision.txt"
|
96
|
+
srcFile = File.join(@dataDir, fname)
|
97
|
+
assert(File.exists?(srcFile))
|
98
|
+
|
99
|
+
cleanOutput()
|
100
|
+
|
101
|
+
target.setOutdir(@outputDir)
|
102
|
+
target.parseFile(srcFile)
|
103
|
+
|
104
|
+
assert(File.exists?(File.join(@outputDir, "01-APP.xml")))
|
105
|
+
assert(File.exists?(File.join(@outputDir, "01-Mod-Forbear-PRODUCT.xml")))
|
106
|
+
assert(File.exists?(File.join(@outputDir, "01-Mod-Forgive-PRODUCT.xml")))
|
107
|
+
assert(File.exists?(File.join(@outputDir, "01-Mod-RateTerm-PRODUCT.xml")))
|
108
|
+
assert(File.exists?(File.join(@outputDir, "01-Mod-SAM-PRODUCT.xml")))
|
109
|
+
end
|
110
|
+
|
111
|
+
#-------------------------------------------------------------------------------------------------------------#
|
112
|
+
# test_parsedecision_does_something
|
113
|
+
#
|
114
|
+
#------------------------------------------------------------------------------------------------------------#
|
115
|
+
def test_plugin_product_does_something
|
116
|
+
|
117
|
+
end
|
118
|
+
|
119
|
+
|
120
|
+
end # TestPluginProduct
|
data/test/test_config.rb
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
##############################################################################
|
2
|
+
# File:: testconfig.rb
|
3
|
+
# Purpose:: Test Config class functionality
|
4
|
+
#
|
5
|
+
# Author:: Jeff McAffee 03/12/2010
|
6
|
+
# Copyright:: Copyright (c) 2010, kTech Systems LLC. All rights reserved.
|
7
|
+
# Website:: http://ktechsystems.com
|
8
|
+
##############################################################################
|
9
|
+
|
10
|
+
require 'test/unit' #(1)
|
11
|
+
require 'flexmock/test_unit'
|
12
|
+
#require 'testhelper/filecomparer'
|
13
|
+
require 'logger'
|
14
|
+
|
15
|
+
require 'fileutils'
|
16
|
+
|
17
|
+
require 'parse_decision'
|
18
|
+
|
19
|
+
class TestConfig < Test::Unit::TestCase #(3)
|
20
|
+
include FileUtils
|
21
|
+
include FlexMock::TestCase
|
22
|
+
include ParseDecision
|
23
|
+
|
24
|
+
#-------------------------------------------------------------------------------------------------------------#
|
25
|
+
# setup - Set up test fixture
|
26
|
+
#
|
27
|
+
#------------------------------------------------------------------------------------------------------------#
|
28
|
+
def setup
|
29
|
+
$LOG = Logger.new(STDERR)
|
30
|
+
$LOG.level = Logger::DEBUG
|
31
|
+
@baseDir = File.dirname(__FILE__)
|
32
|
+
@dataDir = File.join(@baseDir, "data")
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
#-------------------------------------------------------------------------------------------------------------#
|
37
|
+
# teardown - Clean up test fixture
|
38
|
+
#
|
39
|
+
#------------------------------------------------------------------------------------------------------------#
|
40
|
+
def teardown
|
41
|
+
end
|
42
|
+
|
43
|
+
#-------------------------------------------------------------------------------------------------------------#
|
44
|
+
# test_config_ctor - Test the constructor
|
45
|
+
#
|
46
|
+
#------------------------------------------------------------------------------------------------------------#
|
47
|
+
def test_config_ctor
|
48
|
+
target = Config.new(@dataDir)
|
49
|
+
|
50
|
+
assert(nil != target)
|
51
|
+
end
|
52
|
+
|
53
|
+
#-------------------------------------------------------------------------------------------------------------#
|
54
|
+
# test_config_writes_cfg_file
|
55
|
+
#
|
56
|
+
#------------------------------------------------------------------------------------------------------------#
|
57
|
+
def test_config_writes_cfg_file
|
58
|
+
targetFile = File.join(@dataDir, "pdconfig.yml")
|
59
|
+
rm_rf(targetFile) if(File.exists?(targetFile))
|
60
|
+
|
61
|
+
target = Config.new(@dataDir)
|
62
|
+
target.save
|
63
|
+
|
64
|
+
assert(File.exists?(targetFile), "Cfg file not written to disk")
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
#-------------------------------------------------------------------------------------------------------------#
|
69
|
+
# test_config_reads_cfg_file
|
70
|
+
#
|
71
|
+
#------------------------------------------------------------------------------------------------------------#
|
72
|
+
def test_config_reads_cfg_file
|
73
|
+
targetFile = File.join(@dataDir, "pdconfig.yml")
|
74
|
+
rm_rf(targetFile) if(File.exists?(targetFile))
|
75
|
+
|
76
|
+
expected = "Test Data"
|
77
|
+
helper = Config.new(@dataDir)
|
78
|
+
helper.cfg[:appPath] = expected
|
79
|
+
helper.save
|
80
|
+
helper = nil
|
81
|
+
|
82
|
+
target = Config.new(@dataDir)
|
83
|
+
target.load
|
84
|
+
|
85
|
+
assert(!target.cfg[:appPath].empty?, "Cfg file not read from disk")
|
86
|
+
assert(target.cfg[:appPath] == expected, "Cfg file contains incorrect data")
|
87
|
+
end
|
88
|
+
|
89
|
+
|
90
|
+
end # TestConfig
|
@@ -0,0 +1,103 @@
|
|
1
|
+
##############################################################################
|
2
|
+
# File:: test_context.rb
|
3
|
+
# Purpose:: Test PDContext class functionality
|
4
|
+
#
|
5
|
+
# Author:: Jeff McAffee 03/12/2010
|
6
|
+
# Copyright:: Copyright (c) 2010, kTech Systems LLC. All rights reserved.
|
7
|
+
# Website:: http://ktechsystems.com
|
8
|
+
##############################################################################
|
9
|
+
|
10
|
+
require 'test/unit' #(1)
|
11
|
+
require 'flexmock/test_unit'
|
12
|
+
#require 'testhelper/filecomparer'
|
13
|
+
require 'logger'
|
14
|
+
|
15
|
+
require 'fileutils'
|
16
|
+
|
17
|
+
require 'parser'
|
18
|
+
|
19
|
+
class TestPDContext < Test::Unit::TestCase #(3)
|
20
|
+
include FileUtils
|
21
|
+
include FlexMock::TestCase
|
22
|
+
include ParseDecision
|
23
|
+
|
24
|
+
#-------------------------------------------------------------------------------------------------------------#
|
25
|
+
# setup - Set up test fixture
|
26
|
+
#
|
27
|
+
#------------------------------------------------------------------------------------------------------------#
|
28
|
+
def setup
|
29
|
+
$LOG = Logger.new(STDERR)
|
30
|
+
$LOG.level = Logger::DEBUG
|
31
|
+
@baseDir = File.dirname(__FILE__)
|
32
|
+
@dataDir = File.join(@baseDir, "data")
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
#-------------------------------------------------------------------------------------------------------------#
|
37
|
+
# teardown - Clean up test fixture
|
38
|
+
#
|
39
|
+
#------------------------------------------------------------------------------------------------------------#
|
40
|
+
def teardown
|
41
|
+
end
|
42
|
+
|
43
|
+
#-------------------------------------------------------------------------------------------------------------#
|
44
|
+
# test_pdcontext_ctor - Test the constructor
|
45
|
+
#
|
46
|
+
#------------------------------------------------------------------------------------------------------------#
|
47
|
+
def test_pdcontext_ctor
|
48
|
+
target = PDContext.new
|
49
|
+
|
50
|
+
assert(nil != target)
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
def test_pdcontext_data
|
55
|
+
ctx = PDContext.new
|
56
|
+
target = :testVal
|
57
|
+
expected = "This is a Test Value"
|
58
|
+
|
59
|
+
ctx[target] = expected
|
60
|
+
|
61
|
+
assert(ctx[target] == expected)
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
def test_pdcontext_nil_data
|
66
|
+
ctx = PDContext.new
|
67
|
+
target = :testVal
|
68
|
+
|
69
|
+
assert(ctx[target].nil?)
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
def test_pdcontext_set_parsemode
|
74
|
+
ctx = PDContext.new
|
75
|
+
target = :webdecision
|
76
|
+
|
77
|
+
ctx.parseMode = target
|
78
|
+
assert(ctx.parseMode == target)
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
def test_pdcontext_set_invalid_parsemode
|
83
|
+
ctx = PDContext.new
|
84
|
+
target = :badMode
|
85
|
+
expected = :default
|
86
|
+
|
87
|
+
ctx.parseMode = expected
|
88
|
+
ctx.parseMode = target
|
89
|
+
assert(ctx.parseMode == expected)
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
#-------------------------------------------------------------------------------------------------------------#
|
95
|
+
# test_pdcontext_does_something
|
96
|
+
#
|
97
|
+
#------------------------------------------------------------------------------------------------------------#
|
98
|
+
def test_pdcontext_does_something
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
|
103
|
+
end # TestPDContext
|
@@ -0,0 +1,121 @@
|
|
1
|
+
##############################################################################
|
2
|
+
# File:: test_parse_webdecision.rb
|
3
|
+
# Purpose:: Test ParseDecision::Parser.parse functionality when given a
|
4
|
+
# webdecision file.
|
5
|
+
#
|
6
|
+
# Author:: Jeff McAffee 03/23/2010
|
7
|
+
# Copyright:: Copyright (c) 2010, kTech Systems LLC. All rights reserved.
|
8
|
+
# Website:: http://ktechsystems.com
|
9
|
+
##############################################################################
|
10
|
+
|
11
|
+
require 'test/unit' #(1)
|
12
|
+
require 'flexmock/test_unit'
|
13
|
+
#require 'testhelper/filecomparer'
|
14
|
+
require 'logger'
|
15
|
+
|
16
|
+
require 'fileutils'
|
17
|
+
|
18
|
+
require 'parse_decision'
|
19
|
+
|
20
|
+
class TestParseWebDecision < Test::Unit::TestCase #(3)
|
21
|
+
include FileUtils
|
22
|
+
include FlexMock::TestCase
|
23
|
+
include ParseDecision
|
24
|
+
|
25
|
+
#-------------------------------------------------------------------------------------------------------------#
|
26
|
+
# setup - Set up test fixture
|
27
|
+
#
|
28
|
+
#------------------------------------------------------------------------------------------------------------#
|
29
|
+
def setup
|
30
|
+
$LOG = Logger.new(STDERR)
|
31
|
+
$LOG.level = Logger::DEBUG
|
32
|
+
@baseDir = File.dirname(__FILE__)
|
33
|
+
@dataDir = File.join(@baseDir, "data")
|
34
|
+
@outputDir = File.join(@dataDir, "output-webdecision")
|
35
|
+
cleanOutput
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
#-------------------------------------------------------------------------------------------------------------#
|
40
|
+
# teardown - Clean up test fixture
|
41
|
+
#
|
42
|
+
#------------------------------------------------------------------------------------------------------------#
|
43
|
+
def teardown
|
44
|
+
end
|
45
|
+
|
46
|
+
#-------------------------------------------------------------------------------------------------------------#
|
47
|
+
# cleanOutput - Clean up output directory
|
48
|
+
#
|
49
|
+
#------------------------------------------------------------------------------------------------------------#
|
50
|
+
def cleanOutput
|
51
|
+
if(!File.exists?(@outputDir))
|
52
|
+
FileUtils.mkdir(@outputDir)
|
53
|
+
return
|
54
|
+
end
|
55
|
+
|
56
|
+
if(File.directory?(@outputDir))
|
57
|
+
FileUtils.rm_r(@outputDir)
|
58
|
+
FileUtils.mkdir(@outputDir)
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
#-------------------------------------------------------------------------------------------------------------#
|
65
|
+
# test_parse_webdecision - Test the parseFile function
|
66
|
+
#
|
67
|
+
#------------------------------------------------------------------------------------------------------------#
|
68
|
+
def test_parse_webdecision
|
69
|
+
target = Parser.new
|
70
|
+
assert(nil != target)
|
71
|
+
|
72
|
+
fname = "2.2.decision.txt"
|
73
|
+
srcFile = File.join(@dataDir, fname)
|
74
|
+
assert(File.exists?(srcFile))
|
75
|
+
|
76
|
+
cleanOutput()
|
77
|
+
|
78
|
+
target.setOutdir(@outputDir)
|
79
|
+
target.parseFile(srcFile)
|
80
|
+
|
81
|
+
puts "OUTPUT DIR: #{@outputDir}"
|
82
|
+
|
83
|
+
assert(File.exists?(File.join(@outputDir, "01-APP.xml")))
|
84
|
+
assert(File.exists?(File.join(@outputDir, "01-Product01-PRODUCT.xml")))
|
85
|
+
#assert(File.exists?(File.join(@outputDir, "01-decisionResponse.xml")))
|
86
|
+
end
|
87
|
+
|
88
|
+
#-------------------------------------------------------------------------------------------------------------#
|
89
|
+
# ztest_parsedecision_parse - Test the parseFile function
|
90
|
+
#
|
91
|
+
#------------------------------------------------------------------------------------------------------------#
|
92
|
+
def ztest_parsedecision_parse
|
93
|
+
target = Parser.new
|
94
|
+
assert(nil != target)
|
95
|
+
|
96
|
+
fname = "2.decision.txt"
|
97
|
+
srcFile = File.join(@dataDir, fname)
|
98
|
+
assert(File.exists?(srcFile))
|
99
|
+
|
100
|
+
cleanOutput()
|
101
|
+
|
102
|
+
target.setOutdir(@outputDir)
|
103
|
+
target.parseFile(srcFile)
|
104
|
+
|
105
|
+
assert(File.exists?(File.join(@outputDir, "01-APP.xml")))
|
106
|
+
assert(File.exists?(File.join(@outputDir, "01-Mod-Forbear-PRODUCT.xml")))
|
107
|
+
assert(File.exists?(File.join(@outputDir, "01-Mod-Forgive-PRODUCT.xml")))
|
108
|
+
assert(File.exists?(File.join(@outputDir, "01-Mod-RateTerm-PRODUCT.xml")))
|
109
|
+
assert(File.exists?(File.join(@outputDir, "01-Mod-SAM-PRODUCT.xml")))
|
110
|
+
end
|
111
|
+
|
112
|
+
#-------------------------------------------------------------------------------------------------------------#
|
113
|
+
# ztest_parsedecision_does_something
|
114
|
+
#
|
115
|
+
#------------------------------------------------------------------------------------------------------------#
|
116
|
+
def ztest_parsedecision_does_something
|
117
|
+
|
118
|
+
end
|
119
|
+
|
120
|
+
|
121
|
+
end # TestParseWebDecision
|
data/test/test_parser.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
##############################################################################
|
2
|
+
# File:: test_parser.rb
|
3
|
+
# Purpose:: Test ParseDecision class functionality
|
4
|
+
#
|
5
|
+
# Author:: Jeff McAffee 03/12/2010
|
6
|
+
# Copyright:: Copyright (c) 2010, kTech Systems LLC. All rights reserved.
|
7
|
+
# Website:: http://ktechsystems.com
|
8
|
+
##############################################################################
|
9
|
+
|
10
|
+
require 'test/unit' #(1)
|
11
|
+
require 'flexmock/test_unit'
|
12
|
+
#require 'testhelper/filecomparer'
|
13
|
+
require 'logger'
|
14
|
+
|
15
|
+
require 'fileutils'
|
16
|
+
|
17
|
+
require 'parser'
|
18
|
+
|
19
|
+
class TestParser < Test::Unit::TestCase #(3)
|
20
|
+
include FileUtils
|
21
|
+
include FlexMock::TestCase
|
22
|
+
include ParseDecision
|
23
|
+
|
24
|
+
#-------------------------------------------------------------------------------------------------------------#
|
25
|
+
# setup - Set up test fixture
|
26
|
+
#
|
27
|
+
#------------------------------------------------------------------------------------------------------------#
|
28
|
+
def setup
|
29
|
+
$LOG = Logger.new(STDERR)
|
30
|
+
$LOG.level = Logger::DEBUG
|
31
|
+
@baseDir = File.dirname(__FILE__)
|
32
|
+
@dataDir = File.join(@baseDir, "data")
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
#-------------------------------------------------------------------------------------------------------------#
|
37
|
+
# teardown - Clean up test fixture
|
38
|
+
#
|
39
|
+
#------------------------------------------------------------------------------------------------------------#
|
40
|
+
def teardown
|
41
|
+
end
|
42
|
+
|
43
|
+
#-------------------------------------------------------------------------------------------------------------#
|
44
|
+
# test_parser_ctor - Test the constructor
|
45
|
+
#
|
46
|
+
#------------------------------------------------------------------------------------------------------------#
|
47
|
+
def test_parser_ctor
|
48
|
+
target = Parser.new
|
49
|
+
|
50
|
+
assert(nil != target)
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
def test_parser_data
|
55
|
+
target = Parser.new
|
56
|
+
|
57
|
+
assert(nil != target)
|
58
|
+
end
|
59
|
+
|
60
|
+
#-------------------------------------------------------------------------------------------------------------#
|
61
|
+
# test_parser_does_something
|
62
|
+
#
|
63
|
+
#------------------------------------------------------------------------------------------------------------#
|
64
|
+
def test_parser_does_something
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
end # TestParser
|