source: ruby/branches/0.5/test/unit/open_ehr/rm/common/generic_test.rb@ 199

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

test case rearrangement

File size: 7.7 KB
Line 
1require File.dirname(__FILE__) + '/../../../../test_helper'
2require 'test/unit'
3require 'set'
4
5include OpenEhr::RM::DataTypes::Text
6
7class RM_Common_Generic_Test < Test::Unit::TestCase
8 def setup
9 assert_nothing_raised(Exception){party_proxy = PartyProxy.new}
10 object_id = ObjectId.new('0.0.4')
11 party_ref = PartyRef.new('unknown', 'ORGANISATION', object_id)
12 assert_nothing_raised(Exception){
13 @party_proxy = PartyProxy.new(:external_ref => party_ref)}
14 assert_nothing_raised(Exception){party_self = PartySelf.new}
15 assert_nothing_raised(Exception){
16 @party_self = PartySelf.new(:external_ref => party_ref)}
17 assert_raise(ArgumentError){
18 party_identified = PartyIdentified.new}
19
20 identifiers = []
21 identifiers << DvIdentifier.new('NERV', 'MELCHIOR', 'GENDO', 'COMPUTER')
22 identifiers << DvIdentifier.new('NERV', 'CASPER', 'GENDO', 'COMPUTER')
23 identifiers << DvIdentifier.new('NERV', 'BALTHAZAR', 'GENDO', 'COMPUTER')
24 assert_nothing_raised(Exception){
25 @party_identified = PartyIdentified.new(:name => 'NERV',
26 :external_ref => party_ref,
27 :identifier => identifiers)}
28
29 terminology_id = TerminologyId.new('test(0.04)')
30 code_phrase = CodePhrase.new('self', terminology_id)
31 dv_coded_text = DvCodedText.new('Seele',code_phrase)
32 assert_nothing_raised(Exception){
33 @party_related = PartyRelated.new(:name => 'GEHIRN',
34 :relationship => dv_coded_text)}
35 dv_text = DvText.new('commiter')
36 dv_coded_text = DvCodedText.new('present',terminology_id)
37 dv_date_time1 = OpenEhr::RM::DataTypes::Quantity::DateTime::DvDateTime.new('2009-07-04T16:30:00')
38 dv_date_time2 = OpenEhr::RM::DataTypes::Quantity::DateTime::DvDateTime.new('2009-07-14T00:00:00')
39 dv_interval = OpenEhr::RM::DataTypes::Quantity::DvInterval.new(dv_date_time1, dv_date_time2)
40 assert_nothing_raised(Exception){
41 @participation = Participation.new(:performer => @party_proxy,
42 :function => dv_text,
43 :mode => dv_coded_text,
44 :time => dv_interval)}
45 dv_date_time = OpenEhr::RM::DataTypes::Quantity::DateTime::DvDateTime.new('2009-07-04T18:56:00')
46 terminology_id = TerminologyId.new('openehr(1.0.2)')
47 code_phrase = CodePhrase.new('249', terminology_id)
48 dv_coded_text = DvCodedText.new('creation', code_phrase)
49 dv_text = DvText.new('test environment')
50 assert_nothing_raised(Exception){
51 @audit_details = AuditDetails.new(:system_id => 'MAGI',
52 :committer => @party_proxy,
53 :time_committed => dv_date_time,
54 :change_type => dv_coded_text,
55 :description => dv_text)}
56 dv_text = DvText.new('authorisation')
57 dv_ehr_uri = OpenEhr::RM::DataTypes::Uri::DvEhrUri.new('ehr://test/')
58 assert_nothing_raised(Exception){
59 @attestation = Attestation.new(:system_id => 'NERV',
60 :committer => @party_proxy,
61 :time_committed => dv_date_time,
62 :change_type => dv_coded_text,
63 :reason => dv_text,
64 :description => dv_text,
65 :proof => 'hashedstring',
66 :items => Set[dv_ehr_uri])}
67 object_version_id = ObjectVersionId.new('SHOGOUKI::NERV::1.1.1')
68 audit_details2 = AuditDetails.new(:system_id => 'MAGI',
69 :committer => @party_proxy,
70 :time_committed => dv_date_time2,
71 :change_type => dv_coded_text)
72 assert_nothing_raised(Exception){
73 @revision_history_item = RevisionHistoryItem.new(:audits => [@audit_details, audit_details2],
74 :version_id => object_version_id)}
75 dv_date_time3 = OpenEhr::RM::DataTypes::Quantity::DateTime::DvDateTime.new('2009-07-14T12:00:00')
76 dv_date_time4 = OpenEhr::RM::DataTypes::Quantity::DateTime::DvDateTime.new('2009-07-15T00:00:00')
77 audit_details3 = AuditDetails.new(:system_id => 'MAGI',
78 :committer => @party_proxy,
79 :time_committed => dv_date_time3,
80 :change_type => dv_coded_text)
81 audit_details4 = AuditDetails.new(:system_id => 'MAGI',
82 :committer => @party_proxy,
83 :time_committed => dv_date_time4,
84 :change_type => dv_coded_text)
85 object_version_id = ObjectVersionId.new('NIGOUKI::NERV::2.2.2')
86 revision_history_item2 = RevisionHistoryItem.new(:audits => [audit_details3, audit_details4],
87 :version_id => object_version_id)
88 assert_nothing_raised(Exception){
89 @revision_history = RevisionHistory.new([@revision_history_item, revision_history_item2])}
90 end
91
92 def test_init
93 assert_instance_of PartyProxy, @party_proxy
94 assert_instance_of PartySelf, @party_self
95 assert_instance_of PartyIdentified, @party_identified
96 assert_instance_of Participation, @participation
97 assert_instance_of AuditDetails, @audit_details
98 assert_instance_of Attestation, @attestation
99 assert_instance_of RevisionHistoryItem, @revision_history_item
100 assert_instance_of RevisionHistory, @revision_history
101 end
102
103 def test_party_proxy
104 assert_equal 'unknown', @party_proxy.external_ref.namespace
105 end
106
107 def test_party_self
108 assert_equal 'ORGANISATION', @party_self.external_ref.type
109 end
110
111 def test_party_identified
112 assert_equal 'NERV', @party_identified.name
113 assert_equal '0.0.4', @party_identified.external_ref.id.value
114 identifiers = @party_identified.identifier
115 ids = [ ]
116 identifiers.each do |id|
117 ids << id.id
118 end
119 assert_equal %w[MELCHIOR CASPER BALTHAZAR], ids
120 end
121
122 def test_party_related
123 assert_equal 'GEHIRN', @party_related.name
124 end
125
126 def test_participation
127 assert_equal 'unknown', @participation.performer.external_ref.namespace
128 assert_equal 'commiter', @participation.function.value
129 assert_equal 'present', @participation.mode.value
130 assert_equal 2009, @participation.time.lower.year
131 end
132
133 def test_audit_details
134 assert_equal 'MAGI', @audit_details.system_id
135 assert_equal 'unknown', @audit_details.committer.external_ref.namespace
136 assert_equal '2009-07-04T18:56:00', @audit_details.time_committed.as_string
137 assert_equal 'creation', @audit_details.change_type.value
138 assert_equal 'test environment', @audit_details.description.value
139 end
140
141 def test_attestation
142 assert_equal 'NERV', @attestation.system_id
143 assert_equal 'unknown', @attestation.committer.external_ref.namespace
144 assert_equal '249', @attestation.change_type.defining_code.code_string
145 assert_equal 7, @attestation.time_committed.month
146 assert_equal 'authorisation', @attestation.reason.value
147 assert_equal 'authorisation', @attestation.description.value
148 assert_equal 'hashedstring', @attestation.proof
149 assert_equal 'ehr://test/', @attestation.items.to_a[0].value
150 end
151
152 def test_revision_history_item
153 assert_equal 'SHOGOUKI::NERV::1.1.1', @revision_history_item.version_id.value
154 assert_equal 'MAGI', @revision_history_item.audits[0].system_id
155 end
156
157 def test_revision_history
158 assert_equal 'NIGOUKI::NERV::2.2.2', @revision_history.most_recent_version
159 assert_equal '2009-07-14T12:00:00', @revision_history.most_recent_version_time_committed
160 end
161end
Note: See TracBrowser for help on using the repository browser.