source: ruby/trunk/lib/models/tests/rm/test_common.rb@ 128

Last change on this file since 128 was 128, checked in by KOBAYASHI, Shinji, 15 years ago

fixed #59

File size: 5.9 KB
Line 
1require 'test/unit'
2require 'set'
3require 'rm'
4
5class RM_Common_Resource_Test < Test::Unit::TestCase
6 def setup
7 @authored_resource = OpenEHR::RM::Common::Resource::AUTHORED_RESOURCE.new(:original_language => "ja",
8 :translations => "en",
9 :description => "test")
10 @translation_details = OpenEHR::RM::Common::Resource::TRANSLATION_DETAILS.new(nil,nil,nil,nil,nil)
11 end
12 def test_init
13 assert_instance_of OpenEHR::RM::Common::Resource::AUTHORED_RESOURCE, @authored_resource
14 assert_instance_of OpenEHR::RM::Common::Resource::TRANSLATION_DETAILS, @translation_details
15 end
16
17end
18
19class RM_Common_Archetyped_Test < Test::Unit::TestCase
20 def setup
21 @dv_text = OpenEHR::RM::Data_Types::Text::DV_Text.new('Test')
22 @uid_based_id = OpenEHR::RM::Support::Identification::UID_Based_ID.new('rrip::0.0.5')
23 @archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", "biochemistry result_cholesterol", "entry", "ehr_rm", "openehr","cholesterol","0.0.3")
24 @template_id = OpenEHR::RM::Support::Identification::Template_ID.new('1.0.1')
25 assert_nothing_raised(Exception){@archetyped = OpenEHR::RM::Common::Archetyped::Archetyped.new(@archetype_id, '1.0.1')}
26 assert_nothing_raised(Exception){@link = OpenEHR::RM::Common::Archetyped::Link.new(OpenEHR::RM::Data_Types::Text::DV_Text.new("generic"), OpenEHR::RM::Data_Types::URI::DV_EHR_URI.new("ehr://test/"),OpenEHR::RM::Data_Types::Text::DV_Text.new("problem"))}
27 assert_nothing_raised(Exception){
28 @pathable = OpenEHR::RM::Common::Archetyped::Pathable.new }
29 name = OpenEHR::RM::Data_Types::Text::DV_Text.new('blood')
30 links = Set.new([@uid_based_id])
31 assert_nothing_raised(Exception){
32 @locatable = OpenEHR::RM::Common::Archetyped::Locatable.new('at0001',name,links)}
33 end
34
35 def test_init
36 assert_instance_of OpenEHR::RM::Common::Archetyped::Archetyped, @archetyped
37 assert_instance_of OpenEHR::RM::Common::Archetyped::Link, @link
38 assert_instance_of OpenEHR::RM::Common::Archetyped::Pathable, @pathable
39 assert_instance_of OpenEHR::RM::Common::Archetyped::Locatable, @locatable
40 end
41
42 def test_archetyped
43 assert_equal @archetype_id, @archetyped.archetype_id
44 assert_equal '1.0.1', @archetyped.rm_version
45 assert_raise(ArgumentError){@archetyped.archetype_id = nil}
46 assert_raise(ArgumentError){@archetyped.rm_version = nil}
47 assert_raise(ArgumentError){@archetyped.rm_version = ''}
48 assert_nothing_raised(Exception){@archetyped.template_id = @template_id}
49 assert_equal @template_id, @archetyped.template_id
50 archetype_id2 = OpenEHR::RM::Support::Identification::Archetype_ID.new("1.0.2", "biochemistry result_cholesterol", "entry", "ehr_rm", "openehr","cholesterol","0.0.3")
51 assert_nothing_raised(ArgumentError){@archetyped.archetype_id = archetype_id2}
52 assert_equal archetype_id2, @archetyped.archetype_id
53 assert_nothing_raised(ArgumentError){@archetyped.rm_version = '1.0.2'}
54 assert_equal '1.0.2', @archetyped.rm_version
55 end
56
57 def test_link
58 # test constructor
59 assert_equal 'generic', @link.meaning.value
60 assert_equal 'ehr://test/', @link.target.value
61 assert_equal 'problem', @link.type.value
62 # test meaning
63 assert_nothing_raised(Exception){@link.meaning = OpenEHR::RM::Data_Types::Text::DV_Text.new('clinical')}
64 assert_equal 'clinical', @link.meaning.value
65 assert_raise(ArgumentError){@link.meaning = nil}
66 # test target
67 assert_nothing_raised(Exception){@link.target = OpenEHR::RM::Data_Types::URI::DV_EHR_URI.new("ehr://try/")}
68 assert_equal 'ehr://try/', @link.target.value
69 assert_raise(ArgumentError){@link.target = nil}
70 # test type
71 assert_nothing_raised(Exception){@link.type = OpenEHR::RM::Data_Types::Text::DV_Text.new("issue")}
72 assert_equal 'issue', @link.type.value
73 assert_raise(ArgumentError){@link.type = nil}
74 end
75end
76
77class RM_Common_Generic_Test < Test::Unit::TestCase
78 def setup
79# assert_nothing_raised(Exception){@party_proxy = OpenEHR::RM::Common::Generic::Party_Proxy.new}
80# change_type = OpenEHR::RM::Data_Types::Text::DV_Text.new('audit_type')
81# time_committed = OpenEHR::RM::Data_Types::Quantity::Date_Time::DV_Date_Time.new(2008)
82# assert_nothing_raised(Exception){@audit_details = OpenEHR::RM::Common::Generic::Audit_Details.new('rails',@party_proxy, change_type, time_committed)}
83 end
84 def test_init
85 end
86end
87
88class RM_Common_Directory_Test < Test::Unit::TestCase
89 def setup
90 dv_text = OpenEHR::RM::Data_Types::Text::DV_Text.new('root')
91 assert_nothing_raised(Exception){@folder = OpenEHR::RM::Common::Directory::Folder.new('at0000', dv_text, nil)}
92 end
93
94 def test_init
95 assert_instance_of OpenEHR::RM::Common::Directory::Folder, @folder
96 end
97
98 def test_folder
99 assert_equal 'at0000', @folder.archetype_node_id
100 assert_equal 'root', @folder.name.value
101 end
102end
103
104class RM_Common_Change_Control_Test < Test::Unit::TestCase
105 def setup
106 hier_object_id = OpenEHR::RM::Support::Identification::Hier_Object_ID.new('0.0.4')
107 object_id = OpenEHR::RM::Support::Identification::Object_ID.new("0.0.3")
108 object_ref = OpenEHR::RM::Support::Identification::Object_Ref.new('local', 'ANY', object_id)
109 versions = Set.new [object_ref]
110# audit_detail = OpenEHR::RM::Generic::Audit_Detail.new()
111# assert_nothing_raised(Exception){@version = OpenEHR::RM::Common::Change_Control::Version.new(hier_object_id, versions)}
112# assert_nothing_raised(Exception){@contribution = OpenEHR::RM::Common::Change_Control::Contribution.new(hier_object_id, versions, audit_detail)}
113 end
114 def test_init
115# assert_instace_of OpenEHR::RM::Common::Change_Control::Contribution @contribution
116# assert_instace_of OpenEHR::RM::Common::Change_Control::Version @version
117 end
118 def test_version
119 end
120 def test_contribution
121# assert_equal @contribution.uid
122 end
123end
Note: See TracBrowser for help on using the repository browser.