Sha256: e84c84fc8700f1893ab5181659c12a5ecac4fb49b03153dd49499ce0ea438ce4

Contents?: true

Size: 1.54 KB

Versions: 1

Compression:

Stored size: 1.54 KB

Contents

#
# Testing OpenWFE
#
# John Mettraux at openwfe.org
#
# Sun Oct 29 16:18:25 JST 2006
#

require 'rubygems'
require 'json'

require 'test/unit'

require 'openwfe/workitem'
require 'openwfe/flowexpressionid'

require 'rutest_utils'


#
# testing fei.to_h and wi.to_h
#

class HashTest < Test::Unit::TestCase

  #def setup
  #end

  #def teardown
  #end

  def test_fei_to_h

    fei0 = new_fei
    h = fei0.to_h
    fei1 = OpenWFE::FlowExpressionId.from_h(h)

    assert_equal fei0, fei1
  end

  def test_wi_to_h

    wi0 = OpenWFE::InFlowWorkItem.new
    wi0.fei = new_fei

    h = wi0.to_h
    #p h

    wi1 = OpenWFE::InFlowWorkItem.from_h(h)

    assert_equal wi0.fei, wi1.fei
    assert_equal wi0.attributes.length, wi1.attributes.length

    wi2 = OpenWFE::workitem_from_h(h)

    assert_equal wi0.fei, wi2.fei
    assert_equal wi0.attributes.length, wi2.attributes.length
  end

  def test_any_from_h

    li = OpenWFE::LaunchItem.new
    li.workflow_definition_url = "http://www.openwfe.org/nada"
    li.price = "USD 12"
    li.customer = "Captain Nemo"

    h = li.to_h
    #p h

    li1 = OpenWFE::workitem_from_h h

    assert_kind_of OpenWFE::LaunchItem, li1
    assert_equal 'USD 12', li1.price
    assert_equal 2, li1.attributes.size
  end

  def test_wi_to_h_to_json_and_back

    wi0 = OpenWFE::InFlowWorkItem.new
    wi0.fei = new_fei
    wi0.attributes['data'] = (0..5).to_a

    s = wi0.to_h.to_json

    wi1 = OpenWFE::InFlowWorkItem.from_h(JSON.parse(s))

    assert_equal wi0.attributes, wi1.attributes
    assert_equal wi0.fei, wi1.fei
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruote-0.9.19 test/hash_test.rb