Index: by/trunk/lib/models/tests/test_assumed_library_types.rb
===================================================================
--- /ruby/trunk/lib/models/tests/test_assumed_library_types.rb	(revision 369)
+++ 	(revision )
@@ -1,356 +1,0 @@
-require 'test/unit'
-require 'assumed_library_types.rb'
-
-include OpenEhr::AssumedLibraryTypes
-
-class Assumed_Library_Test < Test::Unit::TestCase
-  def setup
-    assert_nothing_raised(Exception){@interval = OpenEhr::AssumedLibraryTypes::Interval.new(1,2)}
-    assert_nothing_raised(Exception){@iso8601_date = OpenEhr::AssumedLibraryTypes::ISO8601_DATE.new('2009-04-27')}
-    assert_nothing_raised(Exception){@iso8601_time = OpenEhr::AssumedLibraryTypes::ISO8601_TIME.new('15:55:37.32+0900')}
-    assert_nothing_raised(Exception){@iso8601_date_time = OpenEhr::AssumedLibraryTypes::ISO8601_DATE_TIME.new('2009-04-27T15:55:37.32+0900')}
-    assert_nothing_raised(Exception){@iso8601_duration = OpenEhr::AssumedLibraryTypes::ISO8601_DURATION.new('P1Y2M3W4DT5H6M7.8S')}
-    assert_nothing_raised(Exception){@iso8601_timezone = OpenEhr::AssumedLibraryTypes::ISO8601_TIMEZONE.new}
-  end
-
-  def test_initialize
-    assert_instance_of OpenEhr::AssumedLibraryTypes::Interval, @interval
-    assert_instance_of OpenEhr::AssumedLibraryTypes::ISO8601_DATE, @iso8601_date
-    assert_instance_of OpenEhr::AssumedLibraryTypes::ISO8601_TIME, @iso8601_time
-    assert_instance_of OpenEhr::AssumedLibraryTypes::ISO8601_DATE_TIME, @iso8601_date_time
-    assert_instance_of OpenEhr::AssumedLibraryTypes::ISO8601_DURATION, @iso8601_duration
-    assert_instance_of OpenEhr::AssumedLibraryTypes::ISO8601_TIMEZONE, @iso8601_timezone
-  end
-
-  def test_limits_comparable
-    assert @interval.lower < @interval.upper
-    assert_nothing_raised(Exception){@interval.lower=1.0}
-    assert_nothing_raised(Exception){@interval.upper=2.0}
-    assert @interval.lower < @interval.upper
-  end
-
-  def test_limits_consistent
-    assert @interval.has?(1.5)
-    assert !@interval.has?(3.0)
-    assert !@interval.has?(0.5)
-    assert_nothing_raised(Exception){@interval.lower_included=true}
-    assert @interval.has?(1.0)
-    assert_nothing_raised(Exception){@interval.lower_included=false}
-    assert !@interval.has?(1.0)
-    assert_nothing_raised(Exception){@interval.upper_included=true}
-    assert @interval.has?(2.0)
-    assert_nothing_raised(Exception){@interval.upper_included=false}
-    assert !@interval.has?(2.0)
-  end
-
-  def test_lower_included_valid
-    assert_nothing_raised(Exception){@interval.lower=nil}
-    assert @interval.lower_unbounded?
-    assert !@interval.lower_included?
-    assert_nothing_raised(Exception){@interval.lower=1.0}
-  end
-
-  def test_upper_included_valid
-    assert_nothing_raised(Exception){@interval.upper=nil}
-    assert @interval.upper_unbounded?
-    assert !@interval.upper_included?
-  end
-
-  def test_time_definitions
-    assert_equal OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS::DAYS_IN_LEAP_YEAR, 366
-    assert_equal OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS::DAYS_IN_WEEK, 7
-    assert_equal OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS::DAYS_IN_YEAR, 365
-    assert_equal OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS::HOURS_IN_DAY, 24
-    assert_equal OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS::MAX_DAYS_IN_MONTH, 31
-    assert_equal OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS::MAX_DAYS_IN_YEAR, 366
-    assert_equal OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS::MINUTES_IN_HOUR, 60
-    assert_equal OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS::MONTH_IN_YEAR, 12
-    assert_equal OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS::NOMINAL_DAYS_IN_MONTH, 30.42
-    assert_equal OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS::NOMINAL_DAYS_IN_YEAR, 365.24
-    assert_equal OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS::SECONDS_IN_MINUTE, 60
-  end
-
-  def test_time_definition_validity
-    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_year?(2008)
-    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_year?(-20)
-    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_year?(0)
-# today
-    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,6,19)
-# test valid_day lower limit
-    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(0,0,0)
-    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(0,1,1)
-    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(-1,1,1)
-    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(0,1,0)
-# test valid_day upper and lowerlimit of each month
-    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(0,0,1)
-    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,1,1)
-    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,1,0)
-    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,0,1)
-    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,1,31)
-    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,1,32)
-    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,2,1)
-    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,2,0)
-    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,2,31)
-    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,3,1)
-    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,3,0)
-    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,3,31)
-    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,3,32)
-    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,4,1)
-    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,4,0)
-    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,4,30)
-    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,4,31)
-    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,5,1)
-    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,5,0)
-    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,5,31)
-    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,5,32)
-    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,6,1)
-    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,6,0)
-    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,6,30)
-    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,6,31)
-    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,7,1)
-    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,7,0)
-    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,7,31)
-    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,7,32)
-    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,8,1)
-    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,8,0)
-    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,8,31)
-    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,8,32)
-    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,9,1)
-    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,9,0)
-    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,9,30)
-    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,9,31)
-    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,10,1)
-    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,10,0)
-    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,10,31)
-    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,10,32)
-    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,11,1)
-    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,11,0)
-    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,11,30)
-    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,11,31)
-    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,12,1)
-    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,12,0)
-    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,12,31)
-    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,12,32)
-# test valid_day leap year
-    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(1900,2,28)
-    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(1900,2,29)
-    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2000,2,29)
-    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,2,29)
-# test valid_hour lower limit
-    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_hour?(0,0,0)
-    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_hour?(-1,0,0)
-    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_hour?(0,-1,0)
-    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_hour?(0,0,-1)
-# test valid_hour upper limit
-    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_hour?(0,59,0)
-    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_hour?(0,60,0)
-    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_hour?(0,0,59)
-    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_hour?(0,0,60)
-    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_hour?(24,0,0)
-    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_hour?(24,0,1)
-    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_hour?(24,1,0)
-# test valid_minute method lower limit
-    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_minute?(0)
-    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_minute?(-1)
-# test valid_minute method upper limit
-    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_minute?(59)
-    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_minute?(60)
-# test valid_second method lower limit
-    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_second?(0)
-    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_second?(-1)
-# test valid_second method upper limit
-    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_second?(59)
-    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_second?(60)
-# test valid_month method lower limit
-    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_month?(1)
-    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_month?(0)
-# test valid_month method upper limit
-    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_month?(12)
-    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_month?(13)
-  end
-  def test_iso8601_date
-    assert_equal 2009, @iso8601_date.year
-    assert_equal 4,@iso8601_date.month
-    assert_equal 27,@iso8601_date.day
-    assert_nothing_raised(Exception){@iso8601_date = OpenEhr::AssumedLibraryTypes::ISO8601_DATE.new('2008')}
-    assert @iso8601_date.day_unknown?
-    assert @iso8601_date.month_unknown?
-    assert @iso8601_date.is_partial?
-    assert @iso8601_date.is_extended?
-    assert_nothing_raised(Exception){@iso8601_date.year = 2008}
-    assert_raise(ArgumentError){@iso8601_date.year = -1}
-    assert_equal "2008", @iso8601_date.as_string
-    assert_nothing_raised(Exception){@iso8601_date.month = 6}
-    assert_equal 6, @iso8601_date.month
-    assert_raise(ArgumentError){@iso8601_date.month = 13}
-    assert_raise(ArgumentError){@iso8601_date.month = 0}
-    assert !@iso8601_date.month_unknown?
-    assert_equal "2008-06", @iso8601_date.as_string
-    assert_nothing_raised(Exception){@iso8601_date.day = 14}
-    assert_equal 14, @iso8601_date.day
-    assert_raise(ArgumentError){@iso8601_date.day = 0}
-    assert_raise(ArgumentError){@iso8601_date.day = 31}
-    assert !@iso8601_date.day_unknown?
-    assert !@iso8601_date.is_partial?
-    assert_equal "2008-06-14", @iso8601_date.as_string
-    assert OpenEhr::AssumedLibraryTypes::ISO8601_DATE.valid_iso8601_date?("2006-06-14")
-    assert !OpenEhr::AssumedLibraryTypes::ISO8601_DATE.valid_iso8601_date?("ABCDEFG")
-  end
-
-  def test_iso8601_time
-    assert_equal 15, @iso8601_time.hour
-    assert_equal 55, @iso8601_time.minute
-    assert_equal 37, @iso8601_time.second
-    assert_equal 0.32, @iso8601_time.fractional_second
-    assert_equal '+0900', @iso8601_time.timezone
-
-#    assert_nothing_raised(Exception){@iso8601_time = OpenEHR::Assumed_Library_Types::ISO8601_TIME.new('15:55:37.32+0900')}
-
-    assert_nothing_raised(Exception){@iso8601_time = OpenEhr::AssumedLibraryTypes::ISO8601_TIME.new('01')}
-    assert_equal 1, @iso8601_time.hour
-    assert @iso8601_time.is_partial?
-    assert_equal "01", @iso8601_time.as_string
-    assert_raise(ArgumentError){@iso8601_time.hour = -1}
-    assert_raise(ArgumentError){@iso8601_time.hour = 24}
-    assert_nothing_raised(Exception){@iso8601_time.hour = 0}
-    assert_equal 0, @iso8601_time.hour
-    assert_equal "00", @iso8601_time.as_string
-    assert_nothing_raised(Exception){@iso8601_time.hour = 23}
-    assert_equal 23, @iso8601_time.hour
-    assert_equal "23", @iso8601_time.as_string
-    assert @iso8601_time.minute_unknown?
-    assert @iso8601_time.second_unknown?
-    assert !@iso8601_time.has_fractional_second?
-    assert_raise(ArgumentError){@iso8601_time.fractional_second = 0.012}
-    assert_raise(ArgumentError){@iso8601_time.second = 10}
-    assert_raise(ArgumentError){@iso8601_time.minute = -1}
-    assert_raise(ArgumentError){@iso8601_time.minute = 60}
-    assert_nothing_raised(Exception){@iso8601_time.minute = 0}
-    assert_equal 0, @iso8601_time.minute
-    assert_equal "23:00", @iso8601_time.as_string
-    assert_nothing_raised(Exception){@iso8601_time.minute = 59}
-    assert_equal 59, @iso8601_time.minute
-    assert_equal "23:59", @iso8601_time.as_string
-    assert !@iso8601_time.minute_unknown?
-    assert @iso8601_time.second_unknown?
-    assert @iso8601_time.is_partial?
-    assert_raise(ArgumentError){@iso8601_time.fractional_second = 0.012}
-    assert_raise(ArgumentError){@iso8601_time.second = -1}
-    assert_raise(ArgumentError){@iso8601_time.second = 60}
-    assert_nothing_raised(Exception){@iso8601_time.second = 0}
-    assert !@iso8601_time.second_unknown?
-    assert_equal 0, @iso8601_time.second
-    assert_equal "23:59:00", @iso8601_time.as_string
-    assert_nothing_raised(Exception){@iso8601_time.second = 59}
-    assert_equal 59, @iso8601_time.second
-    assert_equal "23:59:59", @iso8601_time.as_string
-    assert !@iso8601_time.is_partial?
-    assert_raise(ArgumentError){@iso8601_time.fractional_second = 1.23}
-    assert_nothing_raised(Exception){@iso8601_time.fractional_second = 0.23}
-    assert @iso8601_time.has_fractional_second?
-    assert_equal 0.23, @iso8601_time.fractional_second
-    assert_equal "23:59:59.23", @iso8601_time.as_string
-    assert @iso8601_time.is_extended?
-    assert !@iso8601_time.is_decimal_sign_comma?
-    assert OpenEhr::AssumedLibraryTypes::ISO8601_TIME.valid_iso8601_time?("012345Z")
-    assert OpenEhr::AssumedLibraryTypes::ISO8601_TIME.valid_iso8601_time?("012345.67+0900")
-    assert !OpenEhr::AssumedLibraryTypes::ISO8601_TIME.valid_iso8601_time?("242345.67+0900")
-    assert !OpenEhr::AssumedLibraryTypes::ISO8601_TIME.valid_iso8601_time?("242345.67+0900")
-    assert OpenEhr::AssumedLibraryTypes::ISO8601_TIME.valid_iso8601_time?("240000")
-    assert OpenEhr::AssumedLibraryTypes::ISO8601_TIME.valid_iso8601_time?("240000Z")
-    assert !OpenEhr::AssumedLibraryTypes::ISO8601_TIME.valid_iso8601_time?("240000.011Z")
-  end
-
-  def test_iso_8601_date_time
-    assert_equal 2009, @iso8601_date_time.year
-    assert_equal 4, @iso8601_date_time.month
-    assert_equal 27, @iso8601_date_time.day
-    assert_equal 15, @iso8601_date_time.hour
-    assert_equal 55, @iso8601_date_time.minute
-    assert_equal 37, @iso8601_date_time.second
-    assert_equal 0.32, @iso8601_date_time.fractional_second
-    assert_equal '+0900', @iso8601_date_time.timezone
-    assert_equal '2009-04-27T15:55:37.32+0900', @iso8601_date_time.as_string
-    assert_nothing_raised(Exception){
-      @iso8601_date_time.year = 2008 }
-    assert_equal 2008, @iso8601_date_time.year
-  end
-
-  def test_iso8601_timezone
-    @iso8601_timezone.sign = "+1"
-    @iso8601_timezone.hour = 0
-    @iso8601_timezone.minute = 0
-    assert @iso8601_timezone.is_gmt?
-    assert_equal "Z+0000", @iso8601_timezone.as_string
-    @iso8601_timezone.hour = 9
-    assert_equal "Z+0900", @iso8601_timezone.as_string
-    assert !@iso8601_timezone.is_gmt?
-    @iso8601_timezone.sign = "-1"
-    @iso8601_timezone.hour = 4
-    @iso8601_timezone.minute = 30
-    assert_equal "Z-0430", @iso8601_timezone.as_string
-  end
-
-  def test_iso8601_duration
-    assert_equal 1, @iso8601_duration.years
-    assert_equal 2, @iso8601_duration.months
-    assert_equal 3, @iso8601_duration.weeks
-    assert_equal 4, @iso8601_duration.days
-    assert_equal 5, @iso8601_duration.hours
-    assert_equal 6, @iso8601_duration.minutes
-    assert_equal 7, @iso8601_duration.seconds
-    assert_equal 0.8, @iso8601_duration.fractional_second
-    assert_equal 'P1Y2M3W4DT5H6M7.8S', @iso8601_duration.as_string
-    assert_raise(ArgumentError){@iso8601_duration.years = -1}
-    assert_nothing_raised(Exception){@iso8601_duration.years = nil}
-    assert_nil @iso8601_duration.years
-    assert_equal 'P2M3W4DT5H6M7.8S', @iso8601_duration.as_string
-    assert_nothing_raised(Exception){@iso8601_duration.years = 2}
-    assert_equal 2, @iso8601_duration.years
-    assert_nothing_raised(Exception){@iso8601_duration.months = nil}
-    assert_nil @iso8601_duration.months
-    assert_equal 'P2Y3W4DT5H6M7.8S', @iso8601_duration.as_string
-    assert_raise(ArgumentError){@iso8601_duration.months = -1}
-    assert_nothing_raised(Exception){@iso8601_duration.months = 3}
-    assert_equal 3, @iso8601_duration.months
-    assert_nothing_raised(Exception){@iso8601_duration.weeks = nil}
-    assert_nil @iso8601_duration.weeks
-    assert_equal 'P2Y3M4DT5H6M7.8S', @iso8601_duration.as_string
-    assert_raise(ArgumentError){@iso8601_duration.weeks = -1}
-    assert_nothing_raised(Exception){@iso8601_duration.weeks = 1}
-    assert_equal 'P2Y3M1W4DT5H6M7.8S', @iso8601_duration.as_string
-    assert_raise(ArgumentError){@iso8601_duration.days = -1}
-    assert_nothing_raised(Exception){@iso8601_duration.days = nil}
-    assert_nil @iso8601_duration.days
-    assert_equal 'P2Y3M1WT5H6M7.8S', @iso8601_duration.as_string
-    assert_nothing_raised(Exception){@iso8601_duration.hours = nil}
-    assert_nil @iso8601_duration.hours
-    assert_equal 'P2Y3M1W', @iso8601_duration.as_string
-    assert_raise(ArgumentError){@iso8601_duration.hours = -1}
-    assert_nothing_raised(Exception){@iso8601_duration.hours = 5}
-    assert_equal 5, @iso8601_duration.hours
-    assert_equal 'P2Y3M1WT5H6M7.8S', @iso8601_duration.as_string
-    assert_raise(ArgumentError){@iso8601_duration.minutes = -1}
-    assert_nothing_raised(Exception){@iso8601_duration.minutes = nil}
-    assert_nil @iso8601_duration.minutes
-    assert_equal 'P2Y3M1WT5H', @iso8601_duration.as_string
-    assert_nothing_raised(Exception){@iso8601_duration.minutes = 0}
-    assert_equal 0, @iso8601_duration.minutes
-    assert_equal 'P2Y3M1WT5H0M7.8S', @iso8601_duration.as_string
-    assert_raise(ArgumentError){@iso8601_duration.seconds = -1}
-    assert_nothing_raised(Exception){@iso8601_duration.seconds = nil}
-    assert_nil @iso8601_duration.seconds
-    assert_equal 'P2Y3M1WT5H0M', @iso8601_duration.as_string
-    assert_nothing_raised(Exception){@iso8601_duration.seconds = 10}
-    assert_equal 10, @iso8601_duration.seconds
-    assert_equal 'P2Y3M1WT5H0M10.8S', @iso8601_duration.as_string
-    assert_raise(ArgumentError){@iso8601_duration.fractional_second = 1.0}
-    assert_raise(ArgumentError){@iso8601_duration.fractional_second = -0.1}
-    assert_nothing_raised(Exception){@iso8601_duration.fractional_second = nil}
-    assert_nil @iso8601_duration.fractional_second
-    assert_equal 'P2Y3M1WT5H0M10S', @iso8601_duration.as_string
-    assert_nothing_raised(Exception){@iso8601_duration.fractional_second = 0.2}
-    assert_equal 0.2, @iso8601_duration.fractional_second
-    assert_equal 'P2Y3M1WT5H0M10.2S', @iso8601_duration.as_string
-  end
-end
Index: by/trunk/lib/models/tests/test_reference_model.rb
===================================================================
--- /ruby/trunk/lib/models/tests/test_reference_model.rb	(revision 369)
+++ 	(revision )
@@ -1,6 +1,0 @@
-# this is obsoleted file
-require 'test/unit'
-require 'set'
-require 'rm'
-
-Test::Unit::AutoRunner.run(true, './tests/rm')
Index: /ruby/trunk/lib/open_ehr/rm/common/archetyped.rb
===================================================================
--- /ruby/trunk/lib/open_ehr/rm/common/archetyped.rb	(revision 369)
+++ /ruby/trunk/lib/open_ehr/rm/common/archetyped.rb	(revision 370)
@@ -65,33 +65,24 @@
 
           def name=(name)
-            raise ArgumentError, 'name should not be empty' if name.nil? or name.value.empty?
+            if name.nil? or name.value.empty?
+              raise ArgumentError, 'name should not be empty'
+            end
             @name = name
           end
+
           def links=(links)
-            raise ArgumentError, "links shoud not be empty" if !links.nil? and links.empty?
+            if !links.nil? and links.empty?
+              raise ArgumentError, "links shoud not be empty"
+            end
             @links = links
           end
 
-          def item_at_path(path)
-            if !@path.nil?
-              if @path == ""
-                raise ArgumentError, "path is not valid"
-              end
+          def concept
+            if self.is_archetype_root?
+              return DvText.new(:value => 
+                                @archetype_details.archetype_id.concept_name)
+            else
+              raise ArgumentError, 'this is not root'
             end
-          end
-
-          def items_at_path(path)
-            raise NotImplementError, "items_at_path must be implemented"
-          end
-
-          def path_exists?
-            raise NotImplementError, "path_exists? must be implemented"
-          end
-
-          def path_unique
-            raise NotImplementError, "path_unique must be implemented"
-          end
-
-          def concept
           end
 
@@ -104,15 +95,20 @@
           attr_reader :archetype_id, :rm_version
           attr_accessor :template_id
-          def initialize(archetype_id, rm_version, template_id = nil)            
-            self.archetype_id = archetype_id
-            self.rm_version = rm_version
-            self.template_id = template_id
+
+          def initialize(args = { })
+            self.archetype_id = args[:archetype_id]
+            self.rm_version = args[:rm_version]
+            self.template_id = args[:template_id]
           end
+
           def archetype_id=(archetype_id)
             raise ArgumentError, "invalid archetype_id" if archetype_id.nil?
             @archetype_id = archetype_id
           end
+
           def rm_version=(rm_version)
-            raise ArgumentError, "invalid rm_version" if rm_version.nil? or rm_version.empty?
+            if rm_version.nil? or rm_version.empty?
+              raise ArgumentError, "invalid rm_version"
+            end
             @rm_version = rm_version
           end
@@ -121,8 +117,8 @@
         class Link
           attr_reader :meaning, :target, :type
-          def initialize(meaning, target, type)
-            self.meaning = meaning
-            self.target = target
-            self.type = type
+          def initialize(args = { })
+            self.meaning = args[:meaning]
+            self.target = args[:target]
+            self.type = args[:type]
           end
           def meaning=(meaning)
@@ -165,5 +161,5 @@
           attr_accessor :provider, :location, :time, :subject, :version_id
 
-          def initialize(args ={ })
+          def initialize(args = { })
             self.system_id = args[:system_id]
             self.provider = args[:provider]
@@ -175,5 +171,7 @@
 
           def system_id=(system_id)
-            raise ArgumentError, 'system_id invalid' if system_id.nil? or system_id.empty?
+            if system_id.nil? or system_id.empty?
+              raise ArgumentError, 'system_id invalid'
+            end
             @system_id = system_id
           end
Index: /ruby/trunk/lib/open_ehr/rm/common/change_control.rb
===================================================================
--- /ruby/trunk/lib/open_ehr/rm/common/change_control.rb	(revision 369)
+++ /ruby/trunk/lib/open_ehr/rm/common/change_control.rb	(revision 370)
@@ -2,6 +2,6 @@
 # http://www.openehr.org/uml/release-1.0.1/Browsable/_9_0_76d0249_1109326589721_134411_997Report.html
 # Ticket refs #64
-
-module OpenEhr
+include OpenEHR::RM::Common::Generic
+module OpenEHR
   module RM
     module Common
@@ -88,10 +88,16 @@
 
           def contribution=(contribution)
-            raise ArgumentError, "contribution should not be nil" if contribution.nil? or contribution.type.empty?
-            @contribution = contribution
+            if contribution.nil? or contribution.type.empty?
+              raise ArgumentError, "contribution is invalid"
+            end
+            if contribution.type == 'CONTRIBUTION'
+              @contribution = contribution
+            else
+              raise ArgumentError, 'contribution is invalid'
+            end
           end
 
           def owner_id
-            return HierObjectId.new(@uid.object_id.value)
+            return HierObjectID.new(:value => @uid.value)
           end
 
@@ -101,5 +107,5 @@
 
           def canonical_form
-            raise NotImplementedError, 'canonical form not implemented'
+            raise NotImplementedError, 'canonical form is not determined'
           end
         end
@@ -116,6 +122,5 @@
                   :contribution => args[:contribution],
                   :lifecycle_state => @item.lifecycle_state,
-                  :signature => args[:signature])
-                  
+                  :signature => args[:signature])                  
           end
 
@@ -150,6 +155,5 @@
 
           def is_merged?
-# Java implementation has is_merged attribute, Eiffel implementation does
-# nothing
+            return !other_input_version_uids.nil?
           end
         end
@@ -275,18 +279,22 @@
                                           :version_id => ver.uid)
             end
-            return RevisionHistory.new(revision_history_items)
+            return RevisionHistory.new(:items => revision_history_items)
           end
 
           def commit_original_version(args={ })
-            @all_versions << OriginalVersion.new(:uid => args[:uid],
-                                                  :preceding_version_uid => args[:preceding_version_uid],
-                                                  :contribution => args[:contribution],
-                                                  :commit_audit => args[:commit_audit],
-                                                  :lifecycle_state => args[:lifecycle_state],
-                                                  :data => args[:data],
-                                                  :attestations => args[:attestations],
-                                                  :signature => args[:signature])
-          end
-
+            if has_version_id?(args[:preceding_version_uid]) or self.version_count == 0
+              @all_versions << OriginalVersion.new(:uid => args[:uid],
+                                                   :preceding_version_uid => args[:preceding_version_uid],
+                                                   :contribution => args[:contribution],
+                                                   :commit_audit => args[:commit_audit],
+                                                   :lifecycle_state => args[:lifecycle_state],
+                                                   :data => args[:data],
+                                                   :attestations => args[:attestations],
+                                                   :signature => args[:signature])
+            else
+              raise ArgumentError, 'invalid preceding uid'
+            end
+          end
+            
           def commit_original_merged_version(args = { })
             @all_versions << OriginalVersion.new(:uid => args[:uid],
@@ -303,6 +311,6 @@
           def commit_imported_version(args = { })
             @all_versions << ImportedVersion.new(:item => args[:item],
-                                                  :contribution => args[:contribution],
-                                                  :commit_audit => args[:commit_audit])
+                                                 :contribution => args[:contribution],
+                                                 :commit_audit => args[:commit_audit])
           end
 
Index: /ruby/trunk/lib/open_ehr/rm/common/generic.rb
===================================================================
--- /ruby/trunk/lib/open_ehr/rm/common/generic.rb	(revision 369)
+++ /ruby/trunk/lib/open_ehr/rm/common/generic.rb	(revision 370)
@@ -2,7 +2,7 @@
 # http://www.openehr.org/uml/release-1.0.1/Browsable/_9_5_1_76d0249_1140169202660_257304_813Report.html
 # Related to the ticket #62
-include OpenEhr::RM::Support::Identification
-include OpenEhr::RM::DataTypes::Basic
-module OpenEhr
+include OpenEHR::RM::Support::Identification
+include OpenEHR::RM::DataTypes::Basic
+module OpenEHR
   module RM
     module Common
@@ -34,9 +34,9 @@
           def time_committed=(time_committed)
             if time_committed.nil?
-              raise ArgumentError, 'time_commited is mandatory'
+              raise ArgumentError, 'time_committed is mandatory'
             end
             @time_committed = time_committed
           end
-
+             
           def change_type=(change_type)
             raise ArgumentError, 'change_type is mandatory' if change_type.nil?
@@ -48,6 +48,6 @@
           attr_reader :items
 
-          def initialize(items)
-            self.items = items
+          def initialize(args = { })
+            self.items = args[:items]
           end
 
@@ -103,4 +103,5 @@
         class PartyIdentified < PartyProxy
           attr_reader :name, :identifier
+
           def initialize(args = { })
             if args[:external_ref].nil? && args[:name].nil? &&
@@ -108,7 +109,7 @@
               raise ArgumentError, 'cannot identified'
             end
-            super(:external_ref => args[:external_ref])
             self.name = args[:name]
             self.identifier = args[:identifier]
+            super(args)
           end
 
@@ -125,8 +126,15 @@
               raise ArgumentError, 'cannot identified'
             end
-            unless identifier.nil? || !identifier.empty?
+            if !identifier.nil? && identifier.empty?
               raise ArgumentError, 'invaild identifier'
             end
             @identifier = identifier
+          end
+
+          def external_ref=(external_ref)
+            if @name.nil? && @identifier.nil? && external_ref.nil?
+              raise ArgumentError, 'invalid external_ref'
+            end
+            @external_ref = external_ref
           end
         end
@@ -176,5 +184,5 @@
         class Attestation < AuditDetails
           attr_reader :reason
-          attr_accessor :proof, :items
+          attr_accessor :proof, :attested_view, :is_pending, :items
 
           def initialize(args = { })
@@ -183,4 +191,6 @@
             self.proof = args[:proof]
             self.items = args[:items]
+            self.attested_view = args[:attested_view]
+            self.is_pending = args[:is_pending]
           end
 
@@ -188,4 +198,15 @@
             raise ArgumentError, 'reason is mandatory' if reason.nil?
             @reason = reason
+          end
+
+          def items=(items)
+            if !items.nil? && items.empty?
+              raise ArgumentError, 'items should not be empty'
+            end
+            @items = items
+          end
+          
+          def is_pending?
+            return is_pending
           end
         end
Index: /ruby/trunk/lib/open_ehr/rm/common/resource.rb
===================================================================
--- /ruby/trunk/lib/open_ehr/rm/common/resource.rb	(revision 369)
+++ /ruby/trunk/lib/open_ehr/rm/common/resource.rb	(revision 370)
@@ -1,4 +1,4 @@
 require 'set'
-module OpenEhr
+module OpenEHR
   module RM
     module Common
@@ -29,10 +29,10 @@
           end
 
-          def current_version
-            @revision_history.most_recent_revision
+          def current_revision
+            @revision_history.most_recent_version
           end
 
           def languages_available
-            return Set.new(@translations.keys)
+            return Set.new(@translations.keys) << original_language.code_string
           end
 
Index: /ruby/trunk/log/development.log
===================================================================
--- /ruby/trunk/log/development.log	(revision 369)
+++ /ruby/trunk/log/development.log	(revision 370)
@@ -1663,2 +1663,48 @@
   [4;35;1mSQL (0.1ms)[0m   [0mSELECT version FROM "schema_migrations"[0m
   [4;36;1mSQL (2.3ms)[0m   [0;1mINSERT INTO "schema_migrations" (version) VALUES ('20090725052538')[0m
+  [4;36;1mSQL (1.7ms)[0m   [0;1m SELECT name
+ FROM sqlite_master
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
+[0m
+  [4;35;1mSQL (0.3ms)[0m   [0mSELECT version FROM schema_migrations[0m
+  [4;36;1mSQL (0.3ms)[0m   [0;1mselect sqlite_version(*)[0m
+  [4;35;1mSQL (0.6ms)[0m   [0m SELECT name
+ FROM sqlite_master
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
+[0m
+  [4;36;1mSQL (60.8ms)[0m   [0;1mCREATE TABLE "terminologies" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "code" varchar(255), "name" varchar(255), "lang" varchar(255), "group" text, "rubric" varchar(255), "description" text, "mappings" varchar(255)) [0m
+  [4;35;1mSQL (0.4ms)[0m   [0m SELECT name
+ FROM sqlite_master
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
+[0m
+  [4;36;1mSQL (2.6ms)[0m   [0;1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) [0m
+  [4;35;1mSQL (2.7ms)[0m   [0mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
+  [4;36;1mSQL (0.3ms)[0m   [0;1m SELECT name
+ FROM sqlite_master
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
+[0m
+  [4;35;1mSQL (0.1ms)[0m   [0mSELECT version FROM "schema_migrations"[0m
+  [4;36;1mSQL (2.4ms)[0m   [0;1mINSERT INTO "schema_migrations" (version) VALUES ('20090725052538')[0m
+  [4;36;1mSQL (0.9ms)[0m   [0;1m SELECT name
+ FROM sqlite_master
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
+[0m
+  [4;35;1mSQL (0.4ms)[0m   [0mSELECT version FROM schema_migrations[0m
+  [4;36;1mSQL (0.3ms)[0m   [0;1mselect sqlite_version(*)[0m
+  [4;35;1mSQL (0.7ms)[0m   [0m SELECT name
+ FROM sqlite_master
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
+[0m
+  [4;36;1mSQL (3.6ms)[0m   [0;1mCREATE TABLE "terminologies" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "code" varchar(255), "name" varchar(255), "lang" varchar(255), "group" text, "rubric" varchar(255), "description" text, "mappings" varchar(255)) [0m
+  [4;35;1mSQL (0.3ms)[0m   [0m SELECT name
+ FROM sqlite_master
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
+[0m
+  [4;36;1mSQL (6.9ms)[0m   [0;1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) [0m
+  [4;35;1mSQL (2.7ms)[0m   [0mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
+  [4;36;1mSQL (0.4ms)[0m   [0;1m SELECT name
+ FROM sqlite_master
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
+[0m
+  [4;35;1mSQL (0.2ms)[0m   [0mSELECT version FROM "schema_migrations"[0m
+  [4;36;1mSQL (2.1ms)[0m   [0;1mINSERT INTO "schema_migrations" (version) VALUES ('20090725052538')[0m
