- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ruby/trunk/models/tests/test_archetype_model.rb
r24 r4 5 5 class ArchetypeModelTest < Test::Unit::TestCase 6 6 def setup 7 @archetype = OpenEHR::AM::Archetype::ARCHETYPE.new 8 @validity_kind = OpenEHR::AM::Archetype::VALIDITY_KIND.new 9 10 @archetype_description = OpenEHR::AM::Archetype::Archetype_Description::ARCHETYPE_DESCRIPTION.new 11 @archetype_description_item = OpenEHR::AM::Archetype::Archetype_Description::ARCHETYPE_DESCRIPTION_ITEM.new 7 @archetype = OpenEHR::AM::Archetype::Archetype.new(nil,nil,nil,nil,nil,nil,nil,nil) 8 @archetype_description = OpenEHR::AM::Archetype::Archetype_Description::Archetype_Description.new 9 @archetype_constraint = OpenEHR::AM::Archetype::Constraint_Model::Archetype_Constraint.new 10 @assertion = OpenEHR::AM::Archetype::Constraint_Model::Assertion::Assertion.new 11 @c_primitive = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_Primitive.new 12 @c_boolean = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_Boolean.new(true, true, true) 13 @c_integer = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_Integer.new 14 @archetype_ontology = OpenEHR::AM::Archetype::Ontology::Archetype_Ontology.new 12 15 end 13 16 14 17 def test_init 15 assert_instance_of OpenEHR::AM::Archetype::ARCHETYPE, @archetype 16 assert_instance_of OpenEHR::AM::Archetype::VALIDITY_KIND, @validity_kind 17 assert_instance_of OpenEHR::AM::Archetype::Archetype_Description::ARCHETYPE_DESCRIPTION, @archetype_description 18 assert_instance_of OpenEHR::AM::Archetype::Archetype_Description::ARCHETYPE_DESCRIPTION_ITEM, @archetype_description_item 19 assert_instance_of OpenEHR::AM::Archetype::ARCHETYPE, @archetype 18 assert_instance_of OpenEHR::AM::Archetype::Ontology::Archetype_Ontology, @archetype_ontology 19 assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::Archetype_Constraint, @archetype_constraint 20 assert_instance_of OpenEHR::AM::Archetype::Archetype_Description::Archetype_Description, @archetype_description 21 assert_instance_of OpenEHR::AM::Archetype::Archetype, @archetype 22 assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::Assertion::Assertion, @assertion 23 assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_Primitive, @c_primitive 24 assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_Boolean, @c_boolean 20 25 end 21 22 def test_create23 archetype_instance = OpenEHR::AM::Archetype::ARCHETYPE.create() do |archetype|24 archetype.adl_version = '1.4'25 end26 27 assert_instance_of OpenEHR::AM::Archetype::ARCHETYPE, archetype_instance28 end29 end30 31 class ArchetypeModelConstraintTest < Test::Unit::TestCase32 def setup33 @archetype_constraint = OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_CONSTRAINT.new34 @cardinality = OpenEHR::AM::Archetype::Constraint_Model::CARDINALITY.new35 36 @archetype_constraint = OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_CONSTRAINT.new37 @c_object = OpenEHR::AM::Archetype::Constraint_Model::C_OBJECT.new38 @c_defined_object = OpenEHR::AM::Archetype::Constraint_Model::C_DEFINED_OBJECT.new39 @c_attribute = OpenEHR::AM::Archetype::Constraint_Model::C_ATTRIBUTE.new40 @c_single_attribute = OpenEHR::AM::Archetype::Constraint_Model::C_SINGLE_ATTRIBUTE.new41 @c_multiple_attribute = OpenEHR::AM::Archetype::Constraint_Model::C_MULTIPLE_ATTRIBUTE.new(:rm_attribute_name => 'attribute_name', :cardinality => @cardinality)42 @c_primitive_object = OpenEHR::AM::Archetype::Constraint_Model::C_PRIMITIVE_OBJECT.new43 @c_reference_object = OpenEHR::AM::Archetype::Constraint_Model::C_REFERENCE_OBJECT.new44 @archetype_internal_ref = OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_INTERNAL_REF.new45 @archetype_slot = OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_SLOT.new46 @constraint_ref = OpenEHR::AM::Archetype::Constraint_Model::CONSTRAINT_REF.new47 @c_domain_type = OpenEHR::AM::Archetype::Constraint_Model::C_DOMAIN_TYPE.new48 @c_complex_object = OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT.new(:attributes => [@c_single_attribute])49 end50 51 def test_init52 assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_CONSTRAINT, @archetype_constraint53 assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_OBJECT, @c_object54 assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_DEFINED_OBJECT, @c_defined_object55 assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_ATTRIBUTE, @c_attribute56 assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_SINGLE_ATTRIBUTE, @c_single_attribute57 assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_MULTIPLE_ATTRIBUTE, @c_multiple_attribute58 assert_equal 'attribute_name', @c_multiple_attribute.rm_attribute_name59 assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::CARDINALITY, @c_multiple_attribute.cardinality60 assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_PRIMITIVE_OBJECT, @c_primitive_object61 assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_REFERENCE_OBJECT, @c_reference_object62 assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_INTERNAL_REF, @archetype_internal_ref63 assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_SLOT, @archetype_slot64 assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::CONSTRAINT_REF, @constraint_ref65 assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_DOMAIN_TYPE, @c_domain_type66 assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT, @c_complex_object67 assert_instance_of Array, @c_complex_object.attributes68 assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_CONSTRAINT, @archetype_constraint69 assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::CARDINALITY, @cardinality70 end71 72 def test_create73 c_complex_object = OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT.create(:node_id => 'test_node',74 :attributes => [1,2],75 :assumed_value => Array76 )77 assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT, c_complex_object78 assert_equal 'test_node', c_complex_object.node_id79 end80 end81 82 class ArchetypeModelPrimitiveTest < Test::Unit::TestCase83 def setup84 @c_primitive = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_PRIMITIVE.new85 @c_boolean = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_BOOLEAN.new(:true_valid => true,86 :false_valid => true,87 :assumed_value => true)88 @c_string = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_STRING.new89 @c_integer = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_INTEGER.new90 @c_real = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_REAL.new91 @c_time = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_TIME.new92 @c_date = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_DATE.new93 @c_date_time = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_DATE_TIME.new94 @c_duration = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_DURATION.new95 end96 97 def test_init98 assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_PRIMITIVE, @c_primitive99 assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_BOOLEAN, @c_boolean100 assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_STRING, @c_string101 assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_INTEGER, @c_integer102 assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_REAL, @c_real103 assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_TIME, @c_time104 assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_DATE, @c_date105 assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_DATE_TIME, @c_date_time106 assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_DURATION, @c_duration107 end108 109 26 def test_primitive 110 assert @c_boolean.true_valid 111 assert @c_boolean.false_valid 27 assert @c_boolean.true_valid? 28 assert @c_boolean.false_valid? 112 29 assert @c_boolean.assumed_value 113 30 assert @c_boolean.has_assumed_value? 114 31 assert @c_boolean.default_value 115 32 assert @c_boolean.default_value(true) 116 assert_raise(ArgumentError) do 117 @c_boolean.true_valid = false 118 @c_boolean.false_valid = false 119 end 120 assert_raise(ArgumentError) do 121 OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_BOOLEAN.new(:true_valid =>false, 122 :false_valid => false, 123 :assumed_value => false) 124 end 125 end 126 127 end 128 129 class ArchetypeModelOntologyTest < Test::Unit::TestCase 130 def setup 131 @archetype_ontology = OpenEHR::AM::Archetype::Ontology::ARCHETYPE_ONTOLOGY.new 132 @archetype_term = OpenEHR::AM::Archetype::Ontology::ARCHETYPE_TERM.new(:code => '', :items => '') 133 end 134 135 def test_init 136 assert_instance_of OpenEHR::AM::Archetype::Ontology::ARCHETYPE_ONTOLOGY, @archetype_ontology 137 assert_instance_of OpenEHR::AM::Archetype::Ontology::ARCHETYPE_TERM, @archetype_term 138 end 139 end 140 141 class ArchetypeModelAssertionTest < Test::Unit::TestCase 142 def setup 143 @assertion = OpenEHR::AM::Archetype::Assertion::ASSERTION.new 144 @assertion_variable = OpenEHR::AM::Archetype::Assertion::ASSERTION_VARIABLE.new 145 @operator_kind = OpenEHR::AM::Archetype::Assertion::OPERATOR_KIND.new 146 @expr_item = OpenEHR::AM::Archetype::Assertion::EXPR_ITEM.new 147 @expr_leaf = OpenEHR::AM::Archetype::Assertion::EXPR_LEAF.new 148 @expr_operator = OpenEHR::AM::Archetype::Assertion::EXPR_OPERATOR.new 149 @expr_unary_operator = OpenEHR::AM::Archetype::Assertion::EXPR_UNARY_OPERATOR.new 150 @expr_binary_operator = OpenEHR::AM::Archetype::Assertion::EXPR_BINARY_OPERATOR.new 151 end 152 153 def test_init 154 assert_instance_of OpenEHR::AM::Archetype::Assertion::ASSERTION, @assertion 155 assert_instance_of OpenEHR::AM::Archetype::Assertion::ASSERTION_VARIABLE, @assertion_variable 156 assert_instance_of OpenEHR::AM::Archetype::Assertion::OPERATOR_KIND, @operator_kind 157 assert_instance_of OpenEHR::AM::Archetype::Assertion::EXPR_ITEM, @expr_item 158 assert_instance_of OpenEHR::AM::Archetype::Assertion::EXPR_LEAF, @expr_leaf 159 assert_instance_of OpenEHR::AM::Archetype::Assertion::EXPR_OPERATOR, @expr_operator 160 assert_instance_of OpenEHR::AM::Archetype::Assertion::EXPR_UNARY_OPERATOR, @expr_unary_operator 161 assert_instance_of OpenEHR::AM::Archetype::Assertion::EXPR_BINARY_OPERATOR, @expr_binary_operator 33 assert_raise(ArgumentError) {@c_boolean.set_true_valid(false); @c_boolean.set_false_valid(false)} 34 assert_raise(ArgumentError) {OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_Boolean.new(false,false,false)} 162 35 end 163 36 end 164 37 165 class ArchetypeModelProfileTest < Test::Unit::TestCase166 def setup167 @c_dv_state = OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::C_DV_STATE.new168 @state_machine = OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::STATE_MACHINE.new169 @state = OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::STATE.new170 @terminal_state = OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::TERMINAL_STATE.new171 @non_terminal_state = OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::NON_TERMINAL_STATE.new172 @transition = OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::TRANSITION.new173 174 @c_code_phase = OpenEHR::AM::OpenEHR_Profile::Data_Types::Text::C_CODE_PHASE.new175 176 @c_dv_quantity = OpenEHR::AM::OpenEHR_Profile::Data_Types::Quantity::C_DV_QUANTITY.new177 @c_dv_ordinal = OpenEHR::AM::OpenEHR_Profile::Data_Types::Quantity::C_DV_ORDINAL.new178 @c_quantity_item = OpenEHR::AM::OpenEHR_Profile::Data_Types::Quantity::C_QUANTITY_ITEM.new179 end180 181 def test_init182 assert_instance_of OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::C_DV_STATE, @c_dv_state183 assert_instance_of OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::STATE_MACHINE, @state_machine184 assert_instance_of OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::STATE, @state185 assert_instance_of OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::TERMINAL_STATE, @terminal_state186 assert_instance_of OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::NON_TERMINAL_STATE, @non_terminal_state187 assert_instance_of OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::TRANSITION, @transition188 assert_instance_of OpenEHR::AM::OpenEHR_Profile::Data_Types::Text::C_CODE_PHASE, @c_code_phase189 assert_instance_of OpenEHR::AM::OpenEHR_Profile::Data_Types::Quantity::C_DV_QUANTITY, @c_dv_quantity190 assert_instance_of OpenEHR::AM::OpenEHR_Profile::Data_Types::Quantity::C_DV_ORDINAL, @c_dv_ordinal191 assert_instance_of OpenEHR::AM::OpenEHR_Profile::Data_Types::Quantity::C_QUANTITY_ITEM, @c_quantity_item192 end193 end
Note:
See TracChangeset
for help on using the changeset viewer.