[4] | 1 | require 'test/unit'
|
---|
| 2 | require 'am.rb'
|
---|
| 3 | require 'rm.rb'
|
---|
| 4 |
|
---|
| 5 | class ArchetypeModelTest < Test::Unit::TestCase
|
---|
| 6 | def setup
|
---|
[23] | 7 | @archetype = OpenEHR::AM::Archetype::ARCHETYPE.new
|
---|
| 8 | @validity_kind = OpenEHR::AM::Archetype::VALIDITY_KIND.new
|
---|
| 9 |
|
---|
[21] | 10 | @archetype_description = OpenEHR::AM::Archetype::Archetype_Description::ARCHETYPE_DESCRIPTION.new
|
---|
[23] | 11 | @archetype_description_item = OpenEHR::AM::Archetype::Archetype_Description::ARCHETYPE_DESCRIPTION_ITEM.new
|
---|
| 12 | end
|
---|
| 13 |
|
---|
| 14 | 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
|
---|
| 20 | end
|
---|
| 21 | end
|
---|
[21] | 22 |
|
---|
[23] | 23 | class ArchetypeModelConstraintTest < Test::Unit::TestCase
|
---|
| 24 | def setup
|
---|
[21] | 25 | @archetype_constraint = OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_CONSTRAINT.new
|
---|
[23] | 26 | @cardinality = OpenEHR::AM::Archetype::Constraint_Model::CARDINALITY.new
|
---|
| 27 |
|
---|
| 28 | @archetype_constraint = OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_CONSTRAINT.new
|
---|
[21] | 29 | @c_object = OpenEHR::AM::Archetype::Constraint_Model::C_OBJECT.new
|
---|
| 30 | @c_defined_object = OpenEHR::AM::Archetype::Constraint_Model::C_DEFINED_OBJECT.new
|
---|
| 31 | @c_attribute = OpenEHR::AM::Archetype::Constraint_Model::C_ATTRIBUTE.new
|
---|
[23] | 32 | @c_single_attribute = OpenEHR::AM::Archetype::Constraint_Model::C_SINGLE_ATTRIBUTE.new
|
---|
| 33 | @c_multiple_attribute = OpenEHR::AM::Archetype::Constraint_Model::C_MULTIPLE_ATTRIBUTE.new(:rm_attribute_name => 'attribute_name', :cardinality => @cardinality)
|
---|
[21] | 34 | @c_primitive_object = OpenEHR::AM::Archetype::Constraint_Model::C_PRIMITIVE_OBJECT.new
|
---|
| 35 | @c_reference_object = OpenEHR::AM::Archetype::Constraint_Model::C_REFERENCE_OBJECT.new
|
---|
| 36 | @archetype_internal_ref = OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_INTERNAL_REF.new
|
---|
| 37 | @archetype_slot = OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_SLOT.new
|
---|
| 38 | @constraint_ref = OpenEHR::AM::Archetype::Constraint_Model::CONSTRAINT_REF.new
|
---|
| 39 | @c_domain_type = OpenEHR::AM::Archetype::Constraint_Model::C_DOMAIN_TYPE.new
|
---|
[23] | 40 | @c_complex_object = OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT.new(:attributes => [@c_single_attribute])
|
---|
[4] | 41 | end
|
---|
[23] | 42 |
|
---|
[4] | 43 | def test_init
|
---|
[21] | 44 | assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_CONSTRAINT, @archetype_constraint
|
---|
| 45 | assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_OBJECT, @c_object
|
---|
| 46 | assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_DEFINED_OBJECT, @c_defined_object
|
---|
| 47 | assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_ATTRIBUTE, @c_attribute
|
---|
[23] | 48 | assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_SINGLE_ATTRIBUTE, @c_single_attribute
|
---|
| 49 | assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_MULTIPLE_ATTRIBUTE, @c_multiple_attribute
|
---|
| 50 | assert_equal 'attribute_name', @c_multiple_attribute.rm_attribute_name
|
---|
| 51 | assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::CARDINALITY, @c_multiple_attribute.cardinality
|
---|
[21] | 52 | assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_PRIMITIVE_OBJECT, @c_primitive_object
|
---|
| 53 | assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_REFERENCE_OBJECT, @c_reference_object
|
---|
| 54 | assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_INTERNAL_REF, @archetype_internal_ref
|
---|
| 55 | assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_SLOT, @archetype_slot
|
---|
| 56 | assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::CONSTRAINT_REF, @constraint_ref
|
---|
| 57 | assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_DOMAIN_TYPE, @c_domain_type
|
---|
| 58 | assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT, @c_complex_object
|
---|
[23] | 59 | assert_instance_of Array, @c_complex_object.attributes
|
---|
| 60 | assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_CONSTRAINT, @archetype_constraint
|
---|
| 61 | assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::CARDINALITY, @cardinality
|
---|
[4] | 62 | end
|
---|
[21] | 63 |
|
---|
[23] | 64 | def test_create
|
---|
| 65 | c_complex_object = OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT.create(:node_id => 'test_node',
|
---|
| 66 | :attributes => [1,2],
|
---|
| 67 | :assumed_value => Array
|
---|
| 68 | )
|
---|
| 69 | assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT, c_complex_object
|
---|
| 70 | assert_equal 'test_node', c_complex_object.node_id
|
---|
| 71 | end
|
---|
| 72 | end
|
---|
| 73 |
|
---|
| 74 | class ArchetypeModelPrimitiveTest < Test::Unit::TestCase
|
---|
| 75 | def setup
|
---|
| 76 | @c_primitive = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_PRIMITIVE.new
|
---|
| 77 | @c_boolean = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_BOOLEAN.new(:true_valid => true,
|
---|
| 78 | :false_valid => true,
|
---|
| 79 | :assumed_value => true)
|
---|
| 80 | @c_string = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_STRING.new
|
---|
| 81 | @c_integer = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_INTEGER.new
|
---|
| 82 | @c_real = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_REAL.new
|
---|
| 83 | @c_time = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_TIME.new
|
---|
| 84 | @c_date = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_DATE.new
|
---|
| 85 | @c_date_time = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_DATE_TIME.new
|
---|
| 86 | @c_duration = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_DURATION.new
|
---|
| 87 | end
|
---|
| 88 |
|
---|
| 89 | def test_init
|
---|
| 90 | assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_PRIMITIVE, @c_primitive
|
---|
| 91 | assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_BOOLEAN, @c_boolean
|
---|
| 92 | assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_STRING, @c_string
|
---|
| 93 | assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_INTEGER, @c_integer
|
---|
| 94 | assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_REAL, @c_real
|
---|
| 95 | assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_TIME, @c_time
|
---|
| 96 | assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_DATE, @c_date
|
---|
| 97 | assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_DATE_TIME, @c_date_time
|
---|
| 98 | assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_DURATION, @c_duration
|
---|
| 99 | end
|
---|
| 100 |
|
---|
[4] | 101 | def test_primitive
|
---|
[23] | 102 | assert @c_boolean.true_valid
|
---|
| 103 | assert @c_boolean.false_valid
|
---|
[4] | 104 | assert @c_boolean.assumed_value
|
---|
| 105 | assert @c_boolean.has_assumed_value?
|
---|
| 106 | assert @c_boolean.default_value
|
---|
| 107 | assert @c_boolean.default_value(true)
|
---|
[23] | 108 | assert_raise(ArgumentError) do
|
---|
| 109 | @c_boolean.true_valid = false
|
---|
| 110 | @c_boolean.false_valid = false
|
---|
| 111 | end
|
---|
| 112 | assert_raise(ArgumentError) do
|
---|
| 113 | OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_BOOLEAN.new(:true_valid =>false,
|
---|
| 114 | :false_valid => false,
|
---|
| 115 | :assumed_value => false)
|
---|
| 116 | end
|
---|
[4] | 117 | end
|
---|
[23] | 118 |
|
---|
[4] | 119 | end
|
---|
| 120 |
|
---|
[23] | 121 | class ArchetypeModelOntologyTest < Test::Unit::TestCase
|
---|
| 122 | def setup
|
---|
| 123 | @archetype_ontology = OpenEHR::AM::Archetype::Ontology::ARCHETYPE_ONTOLOGY.new
|
---|
| 124 | @archetype_term = OpenEHR::AM::Archetype::Ontology::ARCHETYPE_TERM.new(:code => '', :items => '')
|
---|
| 125 | end
|
---|
| 126 |
|
---|
| 127 | def test_init
|
---|
| 128 | assert_instance_of OpenEHR::AM::Archetype::Ontology::ARCHETYPE_ONTOLOGY, @archetype_ontology
|
---|
| 129 | assert_instance_of OpenEHR::AM::Archetype::Ontology::ARCHETYPE_TERM, @archetype_term
|
---|
| 130 | end
|
---|
| 131 | end
|
---|
| 132 |
|
---|
| 133 | class ArchetypeModelAssertionTest < Test::Unit::TestCase
|
---|
| 134 | def setup
|
---|
| 135 | @assertion = OpenEHR::AM::Archetype::Assertion::ASSERTION.new
|
---|
| 136 | @assertion_variable = OpenEHR::AM::Archetype::Assertion::ASSERTION_VARIABLE.new
|
---|
| 137 | @operator_kind = OpenEHR::AM::Archetype::Assertion::OPERATOR_KIND.new
|
---|
| 138 | @expr_item = OpenEHR::AM::Archetype::Assertion::EXPR_ITEM.new
|
---|
| 139 | @expr_leaf = OpenEHR::AM::Archetype::Assertion::EXPR_LEAF.new
|
---|
| 140 | @expr_operator = OpenEHR::AM::Archetype::Assertion::EXPR_OPERATOR.new
|
---|
| 141 | @expr_unary_operator = OpenEHR::AM::Archetype::Assertion::EXPR_UNARY_OPERATOR.new
|
---|
| 142 | @expr_binary_operator = OpenEHR::AM::Archetype::Assertion::EXPR_BINARY_OPERATOR.new
|
---|
| 143 | end
|
---|
| 144 |
|
---|
| 145 | def test_init
|
---|
| 146 | assert_instance_of OpenEHR::AM::Archetype::Assertion::ASSERTION, @assertion
|
---|
| 147 | assert_instance_of OpenEHR::AM::Archetype::Assertion::ASSERTION_VARIABLE, @assertion_variable
|
---|
| 148 | assert_instance_of OpenEHR::AM::Archetype::Assertion::OPERATOR_KIND, @operator_kind
|
---|
| 149 | assert_instance_of OpenEHR::AM::Archetype::Assertion::EXPR_ITEM, @expr_item
|
---|
| 150 | assert_instance_of OpenEHR::AM::Archetype::Assertion::EXPR_LEAF, @expr_leaf
|
---|
| 151 | assert_instance_of OpenEHR::AM::Archetype::Assertion::EXPR_OPERATOR, @expr_operator
|
---|
| 152 | assert_instance_of OpenEHR::AM::Archetype::Assertion::EXPR_UNARY_OPERATOR, @expr_unary_operator
|
---|
| 153 | assert_instance_of OpenEHR::AM::Archetype::Assertion::EXPR_BINARY_OPERATOR, @expr_binary_operator
|
---|
| 154 | end
|
---|
| 155 | end
|
---|
| 156 |
|
---|
| 157 | class ArchetypeModelProfileTest < Test::Unit::TestCase
|
---|
| 158 | def setup
|
---|
| 159 | @c_dv_state = OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::C_DV_STATE.new
|
---|
| 160 | @state_machine = OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::STATE_MACHINE.new
|
---|
| 161 | @state = OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::STATE.new
|
---|
| 162 | @terminal_state = OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::TERMINAL_STATE.new
|
---|
| 163 | @non_terminal_state = OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::NON_TERMINAL_STATE.new
|
---|
| 164 | @transition = OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::TRANSITION.new
|
---|
| 165 |
|
---|
| 166 | @c_code_phase = OpenEHR::AM::OpenEHR_Profile::Data_Types::Text::C_CODE_PHASE.new
|
---|
| 167 |
|
---|
| 168 | @c_dv_quantity = OpenEHR::AM::OpenEHR_Profile::Data_Types::Quantity::C_DV_QUANTITY.new
|
---|
| 169 | @c_dv_ordinal = OpenEHR::AM::OpenEHR_Profile::Data_Types::Quantity::C_DV_ORDINAL.new
|
---|
| 170 | @c_quantity_item = OpenEHR::AM::OpenEHR_Profile::Data_Types::Quantity::C_QUANTITY_ITEM.new
|
---|
| 171 | end
|
---|
| 172 |
|
---|
| 173 | def test_init
|
---|
| 174 | assert_instance_of OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::C_DV_STATE, @c_dv_state
|
---|
| 175 | assert_instance_of OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::STATE_MACHINE, @state_machine
|
---|
| 176 | assert_instance_of OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::STATE, @state
|
---|
| 177 | assert_instance_of OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::TERMINAL_STATE, @terminal_state
|
---|
| 178 | assert_instance_of OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::NON_TERMINAL_STATE, @non_terminal_state
|
---|
| 179 | assert_instance_of OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::TRANSITION, @transition
|
---|
| 180 | assert_instance_of OpenEHR::AM::OpenEHR_Profile::Data_Types::Text::C_CODE_PHASE, @c_code_phase
|
---|
| 181 | assert_instance_of OpenEHR::AM::OpenEHR_Profile::Data_Types::Quantity::C_DV_QUANTITY, @c_dv_quantity
|
---|
| 182 | assert_instance_of OpenEHR::AM::OpenEHR_Profile::Data_Types::Quantity::C_DV_ORDINAL, @c_dv_ordinal
|
---|
| 183 | assert_instance_of OpenEHR::AM::OpenEHR_Profile::Data_Types::Quantity::C_QUANTITY_ITEM, @c_quantity_item
|
---|
| 184 | end
|
---|
| 185 | end
|
---|