test/unit/ut_7_workitem.rb in ruote-2.1.11 vs test/unit/ut_7_workitem.rb in ruote-2.2.0

- old
+ new

@@ -8,11 +8,14 @@ require File.join(File.dirname(__FILE__), '..', 'test_helper.rb') require 'ruote/fei' require 'ruote/workitem' +require_json +require 'rufus/json' + class UtWorkitemTest < Test::Unit::TestCase def test_equality f0 = { 'expid' => '0', 'wfid' => '20101224-baba', 'engine_id' => 'engine' } @@ -64,8 +67,33 @@ f0 = { 'expid' => '0', 'wfid' => '20101224-baba', 'engine_id' => 'engine' } w0 = Ruote::Workitem.new('fei' => f0, 'fields' => { 'a' => 'A' }) assert_equal '20101224-baba', w0.wfid + end + + WI = { + 'fei' => { + 'expid' => '0', + 'wfid' => '20101224-baba', + 'engine_id' => 'engine', + 'subid' => '123423fde6' }, + 'participant_name' => 'john', + 'fields' => { + 'customer' => 'swissre' + } + } + WI_JSON = ::Rufus::Json.encode(WI) + WI_PRETTY_JSON = ::Rufus::Json.pretty_encode(WI) + + def test_from_json + + assert_equal WI, Ruote::Workitem.from_json(WI_JSON).h + assert_equal WI, Ruote::Workitem.from_json(WI_PRETTY_JSON).h + end + + def test_as_json + + assert_equal WI, Rufus::Json.decode(Ruote::Workitem.new(WI).as_json) end end