Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • ruby/trunk/models/tests/test_archetype_model.rb

    r4 r24  
    55class ArchetypeModelTest < Test::Unit::TestCase
    66  def setup
    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
     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
    1512  end
    1613 
    1714  def test_init
    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
     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
    2520  end
     21
     22  def test_create
     23    archetype_instance = OpenEHR::AM::Archetype::ARCHETYPE.create() do |archetype|
     24      archetype.adl_version = '1.4'
     25    end
     26
     27    assert_instance_of OpenEHR::AM::Archetype::ARCHETYPE, archetype_instance
     28  end
     29end
     30
     31class ArchetypeModelConstraintTest < Test::Unit::TestCase
     32  def setup
     33    @archetype_constraint = OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_CONSTRAINT.new
     34    @cardinality = OpenEHR::AM::Archetype::Constraint_Model::CARDINALITY.new   
     35   
     36    @archetype_constraint = OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_CONSTRAINT.new
     37    @c_object = OpenEHR::AM::Archetype::Constraint_Model::C_OBJECT.new
     38    @c_defined_object = OpenEHR::AM::Archetype::Constraint_Model::C_DEFINED_OBJECT.new
     39    @c_attribute = OpenEHR::AM::Archetype::Constraint_Model::C_ATTRIBUTE.new
     40    @c_single_attribute = OpenEHR::AM::Archetype::Constraint_Model::C_SINGLE_ATTRIBUTE.new
     41    @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.new
     43    @c_reference_object =  OpenEHR::AM::Archetype::Constraint_Model::C_REFERENCE_OBJECT.new
     44    @archetype_internal_ref =  OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_INTERNAL_REF.new
     45    @archetype_slot = OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_SLOT.new
     46    @constraint_ref = OpenEHR::AM::Archetype::Constraint_Model::CONSTRAINT_REF.new
     47    @c_domain_type = OpenEHR::AM::Archetype::Constraint_Model::C_DOMAIN_TYPE.new
     48    @c_complex_object = OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT.new(:attributes => [@c_single_attribute])
     49  end
     50
     51  def test_init
     52    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_CONSTRAINT, @archetype_constraint
     53    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_OBJECT, @c_object
     54    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_DEFINED_OBJECT, @c_defined_object
     55    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_ATTRIBUTE, @c_attribute
     56    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_SINGLE_ATTRIBUTE, @c_single_attribute
     57    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_MULTIPLE_ATTRIBUTE, @c_multiple_attribute
     58    assert_equal 'attribute_name', @c_multiple_attribute.rm_attribute_name
     59    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::CARDINALITY, @c_multiple_attribute.cardinality
     60    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_PRIMITIVE_OBJECT, @c_primitive_object
     61    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_REFERENCE_OBJECT, @c_reference_object
     62    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_INTERNAL_REF, @archetype_internal_ref
     63    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_SLOT, @archetype_slot
     64    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::CONSTRAINT_REF, @constraint_ref
     65    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_DOMAIN_TYPE, @c_domain_type
     66    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT, @c_complex_object
     67    assert_instance_of Array, @c_complex_object.attributes
     68    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_CONSTRAINT, @archetype_constraint
     69    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::CARDINALITY, @cardinality
     70  end
     71
     72  def test_create
     73    c_complex_object = OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT.create(:node_id => 'test_node',
     74                                                                                         :attributes => [1,2],
     75                                                                                         :assumed_value => Array
     76                                                                                         )
     77    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT, c_complex_object
     78    assert_equal 'test_node', c_complex_object.node_id
     79  end
     80end
     81
     82class ArchetypeModelPrimitiveTest < Test::Unit::TestCase
     83  def setup
     84    @c_primitive = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_PRIMITIVE.new
     85    @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.new
     89    @c_integer = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_INTEGER.new
     90    @c_real = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_REAL.new
     91    @c_time = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_TIME.new
     92    @c_date = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_DATE.new
     93    @c_date_time = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_DATE_TIME.new
     94    @c_duration = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_DURATION.new
     95  end
     96
     97  def test_init
     98    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_PRIMITIVE, @c_primitive
     99    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_BOOLEAN, @c_boolean
     100    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_STRING, @c_string
     101    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_INTEGER, @c_integer
     102    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_REAL, @c_real
     103    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_TIME, @c_time
     104    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_DATE, @c_date
     105    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_DATE_TIME, @c_date_time
     106    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_DURATION, @c_duration
     107  end
     108
    26109  def test_primitive
    27     assert @c_boolean.true_valid?
    28     assert @c_boolean.false_valid?
     110    assert @c_boolean.true_valid
     111    assert @c_boolean.false_valid
    29112    assert @c_boolean.assumed_value
    30113    assert @c_boolean.has_assumed_value?
    31114    assert @c_boolean.default_value
    32115    assert @c_boolean.default_value(true)
    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)}
     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 
     127end
     128
     129class 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
     139end
     140   
     141class 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
    35162  end
    36163end
    37164
     165class ArchetypeModelProfileTest < Test::Unit::TestCase
     166  def setup
     167    @c_dv_state = OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::C_DV_STATE.new
     168    @state_machine = OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::STATE_MACHINE.new
     169    @state = OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::STATE.new
     170    @terminal_state = OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::TERMINAL_STATE.new
     171    @non_terminal_state = OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::NON_TERMINAL_STATE.new
     172    @transition = OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::TRANSITION.new
     173
     174    @c_code_phase = OpenEHR::AM::OpenEHR_Profile::Data_Types::Text::C_CODE_PHASE.new
     175
     176    @c_dv_quantity = OpenEHR::AM::OpenEHR_Profile::Data_Types::Quantity::C_DV_QUANTITY.new
     177    @c_dv_ordinal = OpenEHR::AM::OpenEHR_Profile::Data_Types::Quantity::C_DV_ORDINAL.new
     178    @c_quantity_item = OpenEHR::AM::OpenEHR_Profile::Data_Types::Quantity::C_QUANTITY_ITEM.new
     179  end
     180
     181  def test_init
     182    assert_instance_of OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::C_DV_STATE, @c_dv_state
     183    assert_instance_of OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::STATE_MACHINE, @state_machine
     184    assert_instance_of OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::STATE, @state
     185    assert_instance_of OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::TERMINAL_STATE, @terminal_state
     186    assert_instance_of OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::NON_TERMINAL_STATE, @non_terminal_state
     187    assert_instance_of OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::TRANSITION, @transition
     188    assert_instance_of OpenEHR::AM::OpenEHR_Profile::Data_Types::Text::C_CODE_PHASE, @c_code_phase
     189    assert_instance_of OpenEHR::AM::OpenEHR_Profile::Data_Types::Quantity::C_DV_QUANTITY, @c_dv_quantity
     190    assert_instance_of OpenEHR::AM::OpenEHR_Profile::Data_Types::Quantity::C_DV_ORDINAL, @c_dv_ordinal
     191    assert_instance_of OpenEHR::AM::OpenEHR_Profile::Data_Types::Quantity::C_QUANTITY_ITEM, @c_quantity_item
     192  end
     193end
Note: See TracChangeset for help on using the changeset viewer.