Ignore:
Timestamp:
May 1, 2008, 8:21:09 AM (16 years ago)
Author:
Tatsukawa, Akimichi
Message:

working on adl_parser semantic functions

File:
1 edited

Legend:

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

    r21 r23  
    55class ArchetypeModelTest < Test::Unit::TestCase
    66  def setup
    7     @archetype = OpenEHR::AM::Archetype::ARCHETYPE.new #(nil,nil,nil,nil,nil,nil,nil,nil)
     7    @archetype = OpenEHR::AM::Archetype::ARCHETYPE.new
     8    @validity_kind = OpenEHR::AM::Archetype::VALIDITY_KIND.new
     9
    810    @archetype_description = OpenEHR::AM::Archetype::Archetype_Description::ARCHETYPE_DESCRIPTION.new
     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
     21end
     22
     23class ArchetypeModelConstraintTest < Test::Unit::TestCase
     24  def setup
    925    @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
    15 
     26    @cardinality = OpenEHR::AM::Archetype::Constraint_Model::CARDINALITY.new   
     27   
    1628    @archetype_constraint = OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_CONSTRAINT.new
    1729    @c_object = OpenEHR::AM::Archetype::Constraint_Model::C_OBJECT.new
    1830    @c_defined_object = OpenEHR::AM::Archetype::Constraint_Model::C_DEFINED_OBJECT.new
    1931    @c_attribute = OpenEHR::AM::Archetype::Constraint_Model::C_ATTRIBUTE.new
     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)
    2034    @c_primitive_object = OpenEHR::AM::Archetype::Constraint_Model::C_PRIMITIVE_OBJECT.new
    2135    @c_reference_object =  OpenEHR::AM::Archetype::Constraint_Model::C_REFERENCE_OBJECT.new
     
    2438    @constraint_ref = OpenEHR::AM::Archetype::Constraint_Model::CONSTRAINT_REF.new
    2539    @c_domain_type = OpenEHR::AM::Archetype::Constraint_Model::C_DOMAIN_TYPE.new
    26     @c_complex_object = OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT.new
     40    @c_complex_object = OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT.new(:attributes => [@c_single_attribute])
    2741  end
    28  
     42
    2943  def test_init
    30     assert_instance_of OpenEHR::AM::Archetype::Ontology::Archetype_Ontology, @archetype_ontology
    31     assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_CONSTRAINT, @archetype_constraint
    32     assert_instance_of OpenEHR::AM::Archetype::Archetype_Description::ARCHETYPE_DESCRIPTION, @archetype_description
    33     assert_instance_of OpenEHR::AM::Archetype::ARCHETYPE, @archetype
    34     assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::Assertion::Assertion, @assertion
    35     assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_Primitive, @c_primitive
    36     assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_Boolean, @c_boolean
    3744    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_CONSTRAINT, @archetype_constraint
    3845    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_OBJECT, @c_object
    3946    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_DEFINED_OBJECT, @c_defined_object
    4047    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_ATTRIBUTE, @c_attribute
     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
    4152    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_PRIMITIVE_OBJECT, @c_primitive_object
    4253    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_REFERENCE_OBJECT, @c_reference_object
     
    4657    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_DOMAIN_TYPE, @c_domain_type
    4758    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT, @c_complex_object
     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
     62  end
     63
     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
     72end
     73
     74class 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
    4899  end
    49100
    50101  def test_primitive
    51     assert @c_boolean.true_valid?
    52     assert @c_boolean.false_valid?
     102    assert @c_boolean.true_valid
     103    assert @c_boolean.false_valid
    53104    assert @c_boolean.assumed_value
    54105    assert @c_boolean.has_assumed_value?
    55106    assert @c_boolean.default_value
    56107    assert @c_boolean.default_value(true)
    57     assert_raise(ArgumentError) {@c_boolean.set_true_valid(false); @c_boolean.set_false_valid(false)}
    58     assert_raise(ArgumentError) {OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_Boolean.new(false,false,false)}
     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
     117  end
     118 
     119end
     120
     121class 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
     131end
     132   
     133class 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
    59154  end
    60155end
    61156
     157class 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
     185end
Note: See TracChangeset for help on using the changeset viewer.