1 | require 'test/unit'
|
---|
2 | require 'set'
|
---|
3 | require 'rm'
|
---|
4 |
|
---|
5 | include OpenEHR::RM::Data_Types::Text
|
---|
6 | include OpenEHR::RM::Common::Resource
|
---|
7 | include OpenEHR::RM::Common::Archetyped
|
---|
8 |
|
---|
9 | class RM_Common_Resource_Test < Test::Unit::TestCase
|
---|
10 | def setup
|
---|
11 | @authored_resource = OpenEHR::RM::Common::Resource::AUTHORED_RESOURCE.new(:original_language => "ja",
|
---|
12 | :translations => "en",
|
---|
13 | :description => "test")
|
---|
14 | @translation_details = OpenEHR::RM::Common::Resource::TRANSLATION_DETAILS.new(nil,nil,nil,nil,nil)
|
---|
15 | end
|
---|
16 | def test_init
|
---|
17 | assert_instance_of OpenEHR::RM::Common::Resource::AUTHORED_RESOURCE, @authored_resource
|
---|
18 | assert_instance_of OpenEHR::RM::Common::Resource::TRANSLATION_DETAILS, @translation_details
|
---|
19 | end
|
---|
20 |
|
---|
21 | def test_authoured_resource
|
---|
22 | assert_equal 'ja', @authored_resource.original_language
|
---|
23 | end
|
---|
24 | end
|
---|
25 |
|
---|
26 | class RM_Common_Archetyped_Test < Test::Unit::TestCase
|
---|
27 | def setup
|
---|
28 | @dv_text = OpenEHR::RM::Data_Types::Text::DV_Text.new('Test')
|
---|
29 | @uid_based_id = OpenEHR::RM::Support::Identification::UID_Based_ID.new('rrip::0.0.5')
|
---|
30 | @archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", "biochemistry result_cholesterol", "entry", "ehr_rm", "openehr","cholesterol","0.0.3")
|
---|
31 | @template_id = OpenEHR::RM::Support::Identification::Template_ID.new('1.0.1')
|
---|
32 | assert_nothing_raised(Exception){@archetyped = OpenEHR::RM::Common::Archetyped::Archetyped.new(@archetype_id, '1.0.1')}
|
---|
33 | 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"))}
|
---|
34 | assert_nothing_raised(Exception){
|
---|
35 | @pathable = OpenEHR::RM::Common::Archetyped::Pathable.new }
|
---|
36 | name = OpenEHR::RM::Data_Types::Text::DV_Text.new('blood')
|
---|
37 | links = Set.new([@uid_based_id])
|
---|
38 | assert_nothing_raised(Exception){
|
---|
39 | @locatable = OpenEHR::RM::Common::Archetyped::Locatable.new('at0001',name,links)}
|
---|
40 | assert_nothing_raised(Exception){
|
---|
41 | @feeder_audit_details = Feeder_Audit_Details.new(:system_id => 'MAGI')}
|
---|
42 | end
|
---|
43 |
|
---|
44 | def test_init
|
---|
45 | assert_instance_of OpenEHR::RM::Common::Archetyped::Archetyped, @archetyped
|
---|
46 | assert_instance_of OpenEHR::RM::Common::Archetyped::Link, @link
|
---|
47 | assert_instance_of OpenEHR::RM::Common::Archetyped::Pathable, @pathable
|
---|
48 | assert_instance_of OpenEHR::RM::Common::Archetyped::Locatable, @locatable
|
---|
49 | assert_instance_of Feeder_Audit_Details, @feeder_audit_details
|
---|
50 | end
|
---|
51 |
|
---|
52 | def test_archetyped
|
---|
53 | assert_equal @archetype_id, @archetyped.archetype_id
|
---|
54 | assert_equal '1.0.1', @archetyped.rm_version
|
---|
55 | assert_raise(ArgumentError){@archetyped.archetype_id = nil}
|
---|
56 | assert_raise(ArgumentError){@archetyped.rm_version = nil}
|
---|
57 | assert_raise(ArgumentError){@archetyped.rm_version = ''}
|
---|
58 | assert_nothing_raised(Exception){@archetyped.template_id = @template_id}
|
---|
59 | assert_equal @template_id, @archetyped.template_id
|
---|
60 | archetype_id2 = OpenEHR::RM::Support::Identification::Archetype_ID.new("1.0.2", "biochemistry result_cholesterol", "entry", "ehr_rm", "openehr","cholesterol","0.0.3")
|
---|
61 | assert_nothing_raised(ArgumentError){@archetyped.archetype_id = archetype_id2}
|
---|
62 | assert_equal archetype_id2, @archetyped.archetype_id
|
---|
63 | assert_nothing_raised(ArgumentError){@archetyped.rm_version = '1.0.2'}
|
---|
64 | assert_equal '1.0.2', @archetyped.rm_version
|
---|
65 | end
|
---|
66 |
|
---|
67 | def test_link
|
---|
68 | # test constructor
|
---|
69 | assert_equal 'generic', @link.meaning.value
|
---|
70 | assert_equal 'ehr://test/', @link.target.value
|
---|
71 | assert_equal 'problem', @link.type.value
|
---|
72 | # test meaning
|
---|
73 | assert_nothing_raised(Exception){@link.meaning = OpenEHR::RM::Data_Types::Text::DV_Text.new('clinical')}
|
---|
74 | assert_equal 'clinical', @link.meaning.value
|
---|
75 | assert_raise(ArgumentError){@link.meaning = nil}
|
---|
76 | # test target
|
---|
77 | assert_nothing_raised(Exception){@link.target = OpenEHR::RM::Data_Types::URI::DV_EHR_URI.new("ehr://try/")}
|
---|
78 | assert_equal 'ehr://try/', @link.target.value
|
---|
79 | assert_raise(ArgumentError){@link.target = nil}
|
---|
80 | # test type
|
---|
81 | assert_nothing_raised(Exception){@link.type = OpenEHR::RM::Data_Types::Text::DV_Text.new("issue")}
|
---|
82 | assert_equal 'issue', @link.type.value
|
---|
83 | assert_raise(ArgumentError){@link.type = nil}
|
---|
84 | end
|
---|
85 |
|
---|
86 | def test_feeder_audit
|
---|
87 | end
|
---|
88 |
|
---|
89 | def test_feeder_audit_detail
|
---|
90 | assert_equal 'MAGI', @feeder_audit_details.system_id
|
---|
91 | end
|
---|
92 | end
|
---|
93 |
|
---|
94 | class RM_Common_Generic_Test < Test::Unit::TestCase
|
---|
95 | include OpenEHR::RM::Common::Generic
|
---|
96 | include OpenEHR::RM::Support::Identification
|
---|
97 | include OpenEHR::RM::Data_Types::Basic
|
---|
98 | def setup
|
---|
99 | assert_nothing_raised(Exception){party_proxy = Party_Proxy.new}
|
---|
100 | object_id = Object_ID.new('0.0.4')
|
---|
101 | party_ref = Party_Ref.new('unknown', 'ORGANISATION', object_id)
|
---|
102 | assert_nothing_raised(Exception){
|
---|
103 | @party_proxy = Party_Proxy.new(:external_ref => party_ref)}
|
---|
104 | assert_nothing_raised(Exception){party_self = Party_Self.new}
|
---|
105 | assert_nothing_raised(Exception){
|
---|
106 | @party_self = Party_Self.new(:external_ref => party_ref)}
|
---|
107 | assert_raise(ArgumentError){
|
---|
108 | party_identified = Party_Identified.new}
|
---|
109 | identifiers = []
|
---|
110 | identifiers << DV_Identifier.new('NERV', 'MELCHIOR', 'GENDO', 'COMPUTER')
|
---|
111 | identifiers << DV_Identifier.new('NERV', 'CASPER', 'GENDO', 'COMPUTER')
|
---|
112 | identifiers << DV_Identifier.new('NERV', 'BALTHAZAR', 'GENDO', 'COMPUTER')
|
---|
113 | assert_nothing_raised(Exception){
|
---|
114 | @party_identified = Party_Identified.new(:name => 'NERV',
|
---|
115 | :external_ref => party_ref,
|
---|
116 | :identifier => identifiers)}
|
---|
117 | # change_type = OpenEHR::RM::Data_Types::Text::DV_Text.new('audit_type')
|
---|
118 | # time_committed = OpenEHR::RM::Data_Types::Quantity::Date_Time::DV_Date_Time.new(2008)
|
---|
119 | # assert_nothing_raised(Exception){@audit_details = OpenEHR::RM::Common::Generic::Audit_Details.new('rails',@party_proxy, change_type, time_committed)}
|
---|
120 | end
|
---|
121 |
|
---|
122 | def test_init
|
---|
123 | assert_instance_of Party_Proxy, @party_proxy
|
---|
124 | assert_instance_of Party_Self, @party_self
|
---|
125 | assert_instance_of Party_Identified, @party_identified
|
---|
126 | end
|
---|
127 |
|
---|
128 | def test_party_proxy
|
---|
129 | assert_equal 'unknown', @party_proxy.external_ref.namespace
|
---|
130 | end
|
---|
131 |
|
---|
132 | def test_party_self
|
---|
133 | assert_equal 'ORGANISATION', @party_self.external_ref.type
|
---|
134 | end
|
---|
135 |
|
---|
136 | def test_party_identified
|
---|
137 | assert_equal 'NERV', @party_identified.name
|
---|
138 | assert_equal '0.0.4', @party_identified.external_ref.id.value
|
---|
139 | identifiers = @party_identified.identifier
|
---|
140 | ids = [ ]
|
---|
141 | identifiers.each do |id|
|
---|
142 | ids << id.id
|
---|
143 | end
|
---|
144 | assert_equal %w[MELCHIOR CASPER BALTHAZAR], ids
|
---|
145 | end
|
---|
146 | end
|
---|
147 |
|
---|
148 | class RM_Common_Directory_Test < Test::Unit::TestCase
|
---|
149 | def setup
|
---|
150 | dv_text = OpenEHR::RM::Data_Types::Text::DV_Text.new('root')
|
---|
151 | assert_nothing_raised(Exception){@folder = OpenEHR::RM::Common::Directory::Folder.new('at0000', dv_text, nil)}
|
---|
152 | end
|
---|
153 |
|
---|
154 | def test_init
|
---|
155 | assert_instance_of OpenEHR::RM::Common::Directory::Folder, @folder
|
---|
156 | end
|
---|
157 |
|
---|
158 | def test_folder
|
---|
159 | assert_equal 'at0000', @folder.archetype_node_id
|
---|
160 | assert_equal 'root', @folder.name.value
|
---|
161 | end
|
---|
162 | end
|
---|
163 |
|
---|
164 | class RM_Common_Change_Control_Test < Test::Unit::TestCase
|
---|
165 | def setup
|
---|
166 | hier_object_id = OpenEHR::RM::Support::Identification::Hier_Object_ID.new('0.0.4')
|
---|
167 | object_id = OpenEHR::RM::Support::Identification::Object_ID.new("0.0.3")
|
---|
168 | object_ref = OpenEHR::RM::Support::Identification::Object_Ref.new('local', 'ANY', object_id)
|
---|
169 | versions = Set.new [object_ref]
|
---|
170 | # audit_detail = OpenEHR::RM::Generic::Audit_Detail.new()
|
---|
171 | # assert_nothing_raised(Exception){@version = OpenEHR::RM::Common::Change_Control::Version.new(hier_object_id, versions)}
|
---|
172 | # assert_nothing_raised(Exception){@contribution = OpenEHR::RM::Common::Change_Control::Contribution.new(hier_object_id, versions, audit_detail)}
|
---|
173 | end
|
---|
174 | def test_init
|
---|
175 | # assert_instace_of OpenEHR::RM::Common::Change_Control::Contribution @contribution
|
---|
176 | # assert_instace_of OpenEHR::RM::Common::Change_Control::Version @version
|
---|
177 | end
|
---|
178 | def test_version
|
---|
179 | end
|
---|
180 | def test_contribution
|
---|
181 | # assert_equal @contribution.uid
|
---|
182 | end
|
---|
183 | end
|
---|