Class: QualifiedNameResolverTest
- Defined in:
- lib/puppet/vendor/rgen/test/qualified_name_resolver_test.rb
Defined Under Namespace
Classes: TestNode, TestNode2, TestNode3
Instance Method Summary collapse
- #test_customNameAttribute ⇒ Object
- #test_customSeparator ⇒ Object
- #test_noLeadingSeparator ⇒ Object
- #test_oneChild ⇒ Object
- #test_resolve ⇒ Object
- #testModel ⇒ Object
- #testModel2 ⇒ Object
- #testModel3 ⇒ Object
Instance Method Details
#test_customNameAttribute ⇒ Object
50 51 52 53 54 55 |
# File 'lib/puppet/vendor/rgen/test/qualified_name_resolver_test.rb', line 50 def test_customNameAttribute model = testModel2 res = RGen::Instantiator::QualifiedNameResolver.new(model, :nameAttribute => "cname") assert_equal model[0], res.resolveIdentifier("/Root1") assert_equal model[0].children[0], res.resolveIdentifier("/Root1/Sub11") end |
#test_customSeparator ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/puppet/vendor/rgen/test/qualified_name_resolver_test.rb', line 57 def test_customSeparator model = testModel res = RGen::Instantiator::QualifiedNameResolver.new(model, :separator => "|") assert_equal model[0], res.resolveIdentifier("|Root1") assert_nil res.resolveIdentifier("/Root1") assert_equal model[0].children[0], res.resolveIdentifier("|Root1|Sub11") end |
#test_noLeadingSeparator ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/puppet/vendor/rgen/test/qualified_name_resolver_test.rb', line 65 def test_noLeadingSeparator model = testModel res = RGen::Instantiator::QualifiedNameResolver.new(model, :leadingSeparator => false) assert_equal model[0], res.resolveIdentifier("Root1") assert_nil res.resolveIdentifier("/Root1") assert_equal model[0].children[0], res.resolveIdentifier("Root1/Sub11") end |
#test_oneChild ⇒ Object
93 94 95 96 97 98 99 |
# File 'lib/puppet/vendor/rgen/test/qualified_name_resolver_test.rb', line 93 def test_oneChild model = testModel3 res = RGen::Instantiator::QualifiedNameResolver.new(model) assert_equal model[0], res.resolveIdentifier("/Root1") assert_equal model[0].child, res.resolveIdentifier("/Root1/Sub11") assert_equal model[0].child.child, res.resolveIdentifier("/Root1/Sub11/Sub111") end |
#test_resolve ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/puppet/vendor/rgen/test/qualified_name_resolver_test.rb', line 73 def test_resolve model = testModel res = RGen::Instantiator::QualifiedNameResolver.new(model) assert_equal model[0], res.resolveIdentifier("/Root1") # again assert_equal model[0], res.resolveIdentifier("/Root1") assert_equal model[0].children[0], res.resolveIdentifier("/Root1/Sub11") # again assert_equal model[0].children[0], res.resolveIdentifier("/Root1/Sub11") assert_equal model[0].children[1], res.resolveIdentifier("/Root1/Sub12") assert_equal model[0].children[1].children[0], res.resolveIdentifier("/Root1/Sub12/Sub121") assert_equal model[1], res.resolveIdentifier("/Root2") assert_equal model[1].children[0], res.resolveIdentifier("/Root2/Sub21") assert_equal model[1].children[0].children[0], res.resolveIdentifier("/Root2/Sub21/Sub211") # duplicate name yields two result elements assert_equal [model[2], model[3]], res.resolveIdentifier("/Root3") assert_equal nil, res.resolveIdentifier("/RootX") assert_equal nil, res.resolveIdentifier("/Root1/SubX") end |
#testModel ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/puppet/vendor/rgen/test/qualified_name_resolver_test.rb', line 26 def testModel [TestNode.new(:name => "Root1", :children => [ TestNode.new(:name => "Sub11"), TestNode.new(:name => "Sub12", :children => [ TestNode.new(:name => "Sub121")])]), TestNode.new(:name => "Root2", :children => [ TestNode.new(:name => "Sub21", :children => [ TestNode.new(:name => "Sub211")])]), TestNode.new(:name => "Root3"), TestNode.new(:name => "Root3") ] end |