Sha256: 273de77403440889779b1a36dc87b73b54c427ec47d6a24f754c0474dab07996

Contents?: true

Size: 1.31 KB

Versions: 217

Compression:

Stored size: 1.31 KB

Contents

$:.unshift File.join(File.dirname(__FILE__),"..","lib")

require 'test/unit'
require 'rgen/metamodel_builder'
require 'rgen/serializer/qualified_name_provider'

class QualifiedNameProviderTest < Test::Unit::TestCase

  class AbstractTestNode < RGen::MetamodelBuilder::MMBase
    contains_many 'children', AbstractTestNode, "parent"
  end

  class NamedNode < AbstractTestNode
    has_attr 'n', String
  end

  class UnnamedNode < AbstractTestNode
  end

  def test_simple
    root = NamedNode.new(:n => "root", :children => [
      NamedNode.new(:n => "a", :children => [
        NamedNode.new(:n => "a1")
      ]),
      UnnamedNode.new(:children => [
        NamedNode.new(:n => "b1")
      ])
    ])

    qnp = RGen::Serializer::QualifiedNameProvider.new(:attribute_name => "n")

    assert_equal "/root", qnp.identifier(root)
    assert_equal "/root/a", qnp.identifier(root.children[0])
    assert_equal "/root/a/a1", qnp.identifier(root.children[0].children[0])
    assert_equal "/root", qnp.identifier(root.children[1])
    assert_equal "/root/b1", qnp.identifier(root.children[1].children[0])
  end

  def test_unnamed_root
    root = UnnamedNode.new

    qnp = RGen::Serializer::QualifiedNameProvider.new(:attribute_name => "n")

    assert_equal "/", qnp.identifier(root)
  end

end

Version data entries

217 entries across 217 versions & 3 rubygems

Version Path
puppet-4.10.12 lib/puppet/vendor/rgen/test/qualified_name_provider_test.rb
puppet-4.10.12-x86-mingw32 lib/puppet/vendor/rgen/test/qualified_name_provider_test.rb
puppet-4.10.12-x64-mingw32 lib/puppet/vendor/rgen/test/qualified_name_provider_test.rb
puppet-4.10.12-universal-darwin lib/puppet/vendor/rgen/test/qualified_name_provider_test.rb
puppet-4.10.11 lib/puppet/vendor/rgen/test/qualified_name_provider_test.rb
puppet-4.10.11-x86-mingw32 lib/puppet/vendor/rgen/test/qualified_name_provider_test.rb
puppet-4.10.11-x64-mingw32 lib/puppet/vendor/rgen/test/qualified_name_provider_test.rb
puppet-4.10.11-universal-darwin lib/puppet/vendor/rgen/test/qualified_name_provider_test.rb
puppet-4.10.10 lib/puppet/vendor/rgen/test/qualified_name_provider_test.rb
puppet-4.10.10-x86-mingw32 lib/puppet/vendor/rgen/test/qualified_name_provider_test.rb
puppet-4.10.10-x64-mingw32 lib/puppet/vendor/rgen/test/qualified_name_provider_test.rb
puppet-4.10.10-universal-darwin lib/puppet/vendor/rgen/test/qualified_name_provider_test.rb
puppet-4.10.9 lib/puppet/vendor/rgen/test/qualified_name_provider_test.rb
puppet-4.10.9-x86-mingw32 lib/puppet/vendor/rgen/test/qualified_name_provider_test.rb
puppet-4.10.9-x64-mingw32 lib/puppet/vendor/rgen/test/qualified_name_provider_test.rb
puppet-4.10.9-universal-darwin lib/puppet/vendor/rgen/test/qualified_name_provider_test.rb
puppet-retrospec-1.5.0 vendor/gems/puppet-4.5.2/lib/puppet/vendor/rgen/test/qualified_name_provider_test.rb
puppet-4.10.8 lib/puppet/vendor/rgen/test/qualified_name_provider_test.rb
puppet-4.10.8-x86-mingw32 lib/puppet/vendor/rgen/test/qualified_name_provider_test.rb
puppet-4.10.8-x64-mingw32 lib/puppet/vendor/rgen/test/qualified_name_provider_test.rb