# Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig. # License: Apache License, Version 2.0 require File.dirname(__FILE__) + '/../spec_helper' module RTM::TopicMap describe self do before(:each) do @tm = get_used_tm_sys_tm @tm.should be_a_kind_of RTM::TopicMap @tm.clear @tm.revision_index.first_revision.should be_nil end after(:each) do if implementation_for_spec == :majortom_db @tm.remove else @tm.close end end describe "the id of a revision" do it "should not be 0" do @tm.revision_index.last_revision.should be_nil @tm.get!("topic") @tm.revision_index.last_revision.should_not be_nil @tm.revision_index.last_revision.getId.should_not == 0 pending "not working for db" do @tm.revision_index.last_revision.getId.should == 1 end if implementation_for_spec == :majortom_db end it "should be return via latest_revision_id" do @tm.revision_index.last_revision.should be_nil @tm.latest_revision_id.should == 0 @tm.get!("topic") @tm.revision_index.last_revision.should_not be_nil pending "not working for db" do @tm.latest_revision_id.should == 1 end if implementation_for_spec == :majortom_db end end describe "#all_revisions" do it "should be callable on an empty topic map" do @tm.all_revisions.should be_empty end it "should give back all revisions in the revision index" do # ... will be filled end end describe "Revisions" do describe "should work properly" do it "when adding a topic with si" do @tm.topics.should be_empty @tm.revision_index.last_revision.should be_nil topic1 = @tm.get!("topic1") @tm.should have(1).all_revisions last_revision = @tm.revision_index.last_revision last_revision.should_not be_nil last_revision.changeset_type.to_s.should == "TOPIC_ADDED" RTM::Revision.topic_or_association_context(last_revision).should == topic1 changeset = last_revision.changeset changeset.size.should == 2 change1 = changeset.first change1.type.to_s.should == "TOPIC_ADDED" change1.context.should == @tm change2 = changeset.last change2.type.to_s.should == "SUBJECT_IDENTIFIER_ADDED" change2.context.should == topic1 end it "when adding a topic with sl" do @tm.topics.should be_empty @tm.revision_index.last_revision.should be_nil topic1 = @tm.get!("sl:topic1") @tm.should have(1).all_revisions last_revision = @tm.revision_index.last_revision last_revision.should_not be_nil last_revision.changeset_type.to_s.should == "TOPIC_ADDED" RTM::Revision.topic_or_association_context(last_revision).should == topic1 changeset = last_revision.changeset changeset.size.should == 2 change1 = changeset.first change1.type.to_s.should == "TOPIC_ADDED" change1.context.should == @tm change2 = changeset.last change2.type.to_s.should == "SUBJECT_LOCATOR_ADDED" change2.context.should == topic1 end it "when adding a topic with ii" do @tm.topics.should be_empty @tm.revision_index.last_revision.should be_nil topic1 = @tm.get!("ii:topic1") @tm.should have(1).all_revisions last_revision = @tm.revision_index.last_revision last_revision.should_not be_nil last_revision.changeset_type.to_s.should == "TOPIC_ADDED" RTM::Revision.topic_or_association_context(last_revision).should == topic1 changeset = last_revision.changeset changeset.size.should == 2 change1 = changeset.first change1.type.to_s.should == "TOPIC_ADDED" change1.context.should == @tm change2 = changeset.last change2.type.to_s.should == "ITEM_IDENTIFIER_ADDED" change2.context.should == topic1 end it "when adding a topic with nothing" do @tm.topics.should be_empty @tm.revision_index.last_revision.should be_nil topic1 = @tm.create_topic @tm.should have(1).all_revisions last_revision = @tm.revision_index.last_revision last_revision.should_not be_nil last_revision.changeset_type.to_s.should == "TOPIC_ADDED" RTM::Revision.topic_or_association_context(last_revision).should == topic1 changeset = last_revision.changeset changeset.size.should == 2 change1 = changeset.first change1.type.to_s.should == "TOPIC_ADDED" change1.context.should == @tm change2 = changeset.last change2.type.to_s.should == "ITEM_IDENTIFIER_ADDED" change2.context.should == topic1 end it "when adding an association" do @tm.topics.should be_empty @tm.revision_index.last_revision.should be_nil @tm.disable_revision_management @tm.get!("assoc_type") @tm.enable_revision_management @tm.revision_index.last_revision.should be_nil assoc = @tm.create_association("assoc_type") @tm.should have(1).all_revisions last_revision = @tm.revision_index.last_revision last_revision.should_not be_nil last_revision.changeset_type.to_s.should == "ASSOCIATION_ADDED" RTM::Revision.topic_or_association_context(last_revision).should == assoc changeset = last_revision.changeset changeset.size.should == 3 change1 = changeset.first change1.type.to_s.should == "ASSOCIATION_ADDED" change1.context.should == @tm change2 = changeset.get(1) change2.type.to_s.should == "TYPE_SET" change2.context.should == assoc change3 = changeset.last change3.type.to_s.should == "SCOPE_MODIFIED" change3.context.should == assoc end it "when adding a role to an association" do @tm.topics.should be_empty @tm.revision_index.last_revision.should be_nil @tm.disable_revision_management @tm.get!("assoc_type") @tm.get!("role_type") @tm.get!("role_player") assoc = @tm.create_association("assoc_type") @tm.enable_revision_management @tm.revision_index.last_revision.should be_nil role = assoc.create_role("role_type", "role_player") @tm.should have(1).all_revisions last_revision = @tm.revision_index.last_revision last_revision.should_not be_nil last_revision.changeset_type.to_s.should == "ROLE_ADDED" RTM::Revision.topic_or_association_context(last_revision).should == assoc changeset = last_revision.changeset changeset.size.should == 3 change1 = changeset.first change1.type.to_s.should == "ROLE_ADDED" change1.context.should == assoc change2 = changeset.get(1) change2.type.to_s.should == "TYPE_SET" change2.context.should == role change3 = changeset.last change3.type.to_s.should == "PLAYER_MODIFIED" change3.context.should == role end it "when adding a type to a topic" do @tm.topics.should be_empty @tm.revision_index.last_revision.should be_nil @tm.disable_revision_management topic = @tm.get!("topic") type = @tm.get!("type") @tm.enable_revision_management @tm.revision_index.last_revision.should be_nil topic.add_type("type") @tm.should have(1).all_revisions last_revision = @tm.revision_index.last_revision last_revision.should_not be_nil last_revision.changeset_type.to_s.should == "TYPE_ADDED" RTM::Revision.topic_or_association_context(last_revision).should == topic changeset = last_revision.changeset changeset.size.should == 1 change = changeset.first change.type.to_s.should == "TYPE_ADDED" change.context.should == topic end it "when removing a type from a topic" do @tm.topics.should be_empty @tm.revision_index.last_revision.should be_nil @tm.disable_revision_management topic = @tm.get!("topic") type = @tm.get!("type") topic.add_type("type") @tm.enable_revision_management @tm.revision_index.last_revision.should be_nil topic.remove_type("type") @tm.should have(1).all_revisions last_revision = @tm.revision_index.last_revision last_revision.should_not be_nil last_revision.changeset_type.to_s.should == "TYPE_REMOVED" RTM::Revision.topic_or_association_context(last_revision).should == topic changeset = last_revision.changeset changeset.size.should == 1 change = changeset.first change.type.to_s.should == "TYPE_REMOVED" change.context.should == topic end it "when adding a name to a topic" do @tm.topics.should be_empty @tm.revision_index.last_revision.should be_nil @tm.disable_revision_management topic = @tm.get!("topic") nametype = @tm.get!("nametype") @tm.enable_revision_management @tm.revision_index.last_revision.should be_nil name = topic.create_name(nametype, "a Name") @tm.should have(1).all_revisions last_revision = @tm.revision_index.last_revision last_revision.should_not be_nil last_revision.changeset_type.to_s.should == "NAME_ADDED" RTM::Revision.topic_or_association_context(last_revision).should == topic changeset = last_revision.changeset changeset.size.should == 4 change1 = changeset.first change1.type.to_s.should == "NAME_ADDED" change1.context.should == topic change2 = changeset.get(1) change2.type.to_s.should == "TYPE_SET" change2.context.should == name change3 = changeset.get(2) change3.type.to_s.should == "VALUE_MODIFIED" change3.context.should == name change4 = changeset.last change4.type.to_s.should == "SCOPE_MODIFIED" change4.context.should == name end it "when adding a variant to a name" do @tm.topics.should be_empty @tm.revision_index.last_revision.should be_nil @tm.disable_revision_management topic = @tm.get!("topic") nametype = @tm.get!("nametype") name = topic.create_name(nametype, "a Name") @tm.get!("theme") @tm.enable_revision_management @tm.revision_index.last_revision.should be_nil variant = name.create_variant("a Variant", ["theme"]) @tm.should have(1).all_revisions last_revision = @tm.revision_index.last_revision last_revision.should_not be_nil last_revision.changeset_type.to_s.should == "VARIANT_ADDED" RTM::Revision.topic_or_association_context(last_revision).should == topic changeset = last_revision.changeset changeset.size.should == 4 change1 = changeset.first change1.type.to_s.should == "VARIANT_ADDED" change1.context.should == name change2 = changeset.get(1) change2.type.to_s.should == "VALUE_MODIFIED" change2.context.should == variant change3 = changeset.get(2) change3.type.to_s.should == "DATATYPE_SET" change3.context.should == variant change4 = changeset.last change4.type.to_s.should == "SCOPE_MODIFIED" change4.context.should == variant end it "when adding a occurrence to a topic" do @tm.topics.should be_empty @tm.revision_index.last_revision.should be_nil @tm.disable_revision_management topic = @tm.get!("topic") occtype = @tm.get!("occtype") @tm.enable_revision_management @tm.revision_index.last_revision.should be_nil occ = topic.create_occurrence(occtype, "a Name") @tm.should have(1).all_revisions last_revision = @tm.revision_index.last_revision last_revision.should_not be_nil last_revision.changeset_type.to_s.should == "OCCURRENCE_ADDED" RTM::Revision.topic_or_association_context(last_revision).should == topic changeset = last_revision.changeset changeset.size.should == 5 change1 = changeset.first change1.type.to_s.should == "OCCURRENCE_ADDED" change1.context.should == topic change2 = changeset.get(1) change2.type.to_s.should == "TYPE_SET" change2.context.should == occ change3 = changeset.get(2) change3.type.to_s.should == "VALUE_MODIFIED" change3.context.should == occ change4 = changeset.get(3) change4.type.to_s.should == "DATATYPE_SET" change4.context.should == occ change5 = changeset.last change5.type.to_s.should == "SCOPE_MODIFIED" change5.context.should == occ end it "when removing a si from a topic" do @tm.topics.should be_empty @tm.revision_index.last_revision.should be_nil @tm.disable_revision_management topic1 = @tm.get!("topic1") @tm.enable_revision_management @tm.revision_index.last_revision.should be_nil topic1.remove_si("topic1") topic1.references.should be_empty @tm.should have(1).all_revisions last_revision = @tm.revision_index.last_revision last_revision.should_not be_nil last_revision.changeset_type.to_s.should == "SUBJECT_IDENTIFIER_REMOVED" RTM::Revision.topic_or_association_context(last_revision).should == topic1 changeset = last_revision.changeset changeset.size.should == 1 change1 = changeset.first change1.type.to_s.should == "SUBJECT_IDENTIFIER_REMOVED" change1.context.should == topic1 end it "when removing an ii from a topic" do @tm.topics.should be_empty @tm.revision_index.last_revision.should be_nil @tm.disable_revision_management topic1 = @tm.get!("ii:topic1") @tm.enable_revision_management @tm.revision_index.last_revision.should be_nil topic1.remove_ii("topic1") topic1.references.should be_empty @tm.should have(1).all_revisions last_revision = @tm.revision_index.last_revision last_revision.should_not be_nil last_revision.changeset_type.to_s.should == "ITEM_IDENTIFIER_REMOVED" RTM::Revision.topic_or_association_context(last_revision).should == topic1 changeset = last_revision.changeset changeset.size.should == 1 change1 = changeset.first change1.type.to_s.should == "ITEM_IDENTIFIER_REMOVED" change1.context.should == topic1 last_revision.changeset.first.context.should be_a_kind_of RTM::Topic end it "when removing a sl from a topic" do @tm.topics.should be_empty @tm.revision_index.last_revision.should be_nil @tm.disable_revision_management topic1 = @tm.get!("sl:topic1") @tm.enable_revision_management @tm.revision_index.last_revision.should be_nil topic1.remove_sl("topic1") topic1.references.should be_empty @tm.should have(1).all_revisions last_revision = @tm.revision_index.last_revision last_revision.should_not be_nil last_revision.changeset_type.to_s.should == "SUBJECT_LOCATOR_REMOVED" RTM::Revision.topic_or_association_context(last_revision).should == topic1 changeset = last_revision.changeset changeset.size.should == 1 change1 = changeset.first change1.type.to_s.should == "SUBJECT_LOCATOR_REMOVED" change1.context.should == topic1 end it "when adding a si from a topic" do @tm.topics.should be_empty @tm.revision_index.last_revision.should be_nil @tm.disable_revision_management topic1 = @tm.get!("topic1") @tm.enable_revision_management @tm.revision_index.last_revision.should be_nil topic1.add_si("topic_identifier2") topic1.should have(2).references @tm.should have(1).all_revisions last_revision = @tm.revision_index.last_revision last_revision.should_not be_nil last_revision.changeset_type.to_s.should == "SUBJECT_IDENTIFIER_ADDED" RTM::Revision.topic_or_association_context(last_revision).should == topic1 changeset = last_revision.changeset changeset.size.should == 1 change1 = changeset.first change1.type.to_s.should == "SUBJECT_IDENTIFIER_ADDED" change1.context.should == topic1 end it "when adding an ii from a topic" do @tm.topics.should be_empty @tm.revision_index.last_revision.should be_nil @tm.disable_revision_management topic1 = @tm.get!("ii:topic1") @tm.enable_revision_management @tm.revision_index.last_revision.should be_nil topic1.add_ii("topic_identifier2") topic1.should have(2).references @tm.should have(1).all_revisions last_revision = @tm.revision_index.last_revision last_revision.should_not be_nil last_revision.changeset_type.to_s.should == "ITEM_IDENTIFIER_ADDED" RTM::Revision.topic_or_association_context(last_revision).should == topic1 changeset = last_revision.changeset changeset.size.should == 1 change1 = changeset.first change1.type.to_s.should == "ITEM_IDENTIFIER_ADDED" change1.context.should == topic1 last_revision.changeset.first.context.should be_a_kind_of RTM::Topic end it "when adding a sl from a topic" do @tm.topics.should be_empty @tm.revision_index.last_revision.should be_nil @tm.disable_revision_management topic1 = @tm.get!("sl:topic1") @tm.enable_revision_management @tm.revision_index.last_revision.should be_nil topic1.add_sl("topic_identifier2") topic1.should have(2).references @tm.should have(1).all_revisions last_revision = @tm.revision_index.last_revision last_revision.should_not be_nil last_revision.changeset_type.to_s.should == "SUBJECT_LOCATOR_ADDED" RTM::Revision.topic_or_association_context(last_revision).should == topic1 changeset = last_revision.changeset changeset.size.should == 1 change1 = changeset.first change1.type.to_s.should == "SUBJECT_LOCATOR_ADDED" change1.context.should == topic1 end it "when removing a topic" do @tm.topics.should be_empty @tm.revision_index.last_revision.should be_nil @tm.disable_revision_management topic1 = @tm.get!("topic1") name = topic1.create_name("name") name.create_variant("var", ["theme"]) occ = topic1.create_occurrence("occ_type", "occ") @tm.enable_revision_management @tm.revision_index.last_revision.should be_nil topic1.remove @tm.should have(1).all_revisions last_revision = @tm.revision_index.last_revision last_revision.should_not be_nil last_revision.changeset_type.to_s.should == "TOPIC_REMOVED" RTM::Revision.topic_or_association_context(last_revision).should == topic1 changeset = last_revision.changeset changeset.size.should == 4 change1 = changeset.first ["VARIANT_REMOVED", "OCCURRENCE_REMOVED"].should include change1.type.to_s [name, topic1].should include change1.context change2 = changeset.get(1) ["VARIANT_REMOVED", "OCCURRENCE_REMOVED", "NAME_REMOVED"].should include change2.type.to_s [name, topic1].should include change2.context change3 = changeset.get(2) ["OCCURRENCE_REMOVED", "NAME_REMOVED"].should include change3.type.to_s [topic1].should include change3.context change4 = changeset.last change4.type.to_s.should == "TOPIC_REMOVED" change4.context.should == @tm end it "when removing a name" do @tm.topics.should be_empty @tm.revision_index.last_revision.should be_nil @tm.disable_revision_management topic1 = @tm.get!("topic1") name = topic1.create_name("name") name.create_variant("var", ["theme"]) @tm.enable_revision_management @tm.revision_index.last_revision.should be_nil name.remove @tm.should have(1).all_revisions last_revision = @tm.revision_index.last_revision last_revision.should_not be_nil last_revision.changeset_type.to_s.should == "NAME_REMOVED" RTM::Revision.topic_or_association_context(last_revision).should == topic1 changeset = last_revision.changeset changeset.size.should == 2 change1 = changeset.first ["VARIANT_REMOVED"].should include change1.type.to_s [name].should include change1.context change2 = changeset.last ["NAME_REMOVED"].should include change2.type.to_s [topic1].should include change2.context end it "when removing a variant" do @tm.topics.should be_empty @tm.revision_index.last_revision.should be_nil @tm.disable_revision_management topic1 = @tm.get!("topic1") name = topic1.create_name("name") variant = name.create_variant("var", ["theme"]) @tm.enable_revision_management @tm.revision_index.last_revision.should be_nil variant.remove @tm.should have(1).all_revisions last_revision = @tm.revision_index.last_revision last_revision.should_not be_nil last_revision.changeset_type.to_s.should == "VARIANT_REMOVED" RTM::Revision.topic_or_association_context(last_revision).should == topic1 changeset = last_revision.changeset changeset.size.should == 1 change1 = changeset.first ["VARIANT_REMOVED"].should include change1.type.to_s [name].should include change1.context end it "when removing an occurrence" do @tm.topics.should be_empty @tm.revision_index.last_revision.should be_nil @tm.disable_revision_management topic1 = @tm.get!("topic1") occ = topic1.create_occurrence("occ_type", "occ", :scope => ["theme"]) @tm.enable_revision_management @tm.revision_index.last_revision.should be_nil occ.remove @tm.should have(1).all_revisions last_revision = @tm.revision_index.last_revision last_revision.should_not be_nil last_revision.changeset_type.to_s.should == "OCCURRENCE_REMOVED" RTM::Revision.topic_or_association_context(last_revision).should == topic1 changeset = last_revision.changeset changeset.size.should == 1 change1 = changeset.first ["OCCURRENCE_REMOVED"].should include change1.type.to_s [topic1].should include change1.context end it "when removing an association without roles" do @tm.topics.should be_empty @tm.revision_index.last_revision.should be_nil @tm.disable_revision_management assoc = @tm.create_association("assoc_type") @tm.enable_revision_management @tm.revision_index.last_revision.should be_nil assoc.remove @tm.should have(1).all_revisions last_revision = @tm.revision_index.last_revision last_revision.should_not be_nil last_revision.changeset_type.to_s.should == "ASSOCIATION_REMOVED" RTM::Revision.topic_or_association_context(last_revision).should == assoc changeset = last_revision.changeset changeset.size.should == 1 change1 = changeset.first change1.type.to_s.should == "ASSOCIATION_REMOVED" change1.context.should == @tm end it "when removing an association with roles" do @tm.topics.should be_empty @tm.revision_index.last_revision.should be_nil @tm.disable_revision_management assoc = @tm.create_association("assoc_type", "role_type1" => "role_player1", "role_type2" => "role_player2") @tm.enable_revision_management @tm.revision_index.last_revision.should be_nil assoc.remove @tm.should have(1).all_revisions last_revision = @tm.revision_index.last_revision last_revision.should_not be_nil last_revision.changeset_type.to_s.should == "ASSOCIATION_REMOVED" RTM::Revision.topic_or_association_context(last_revision).should == assoc changeset = last_revision.changeset changeset.size.should == 3 change1 = changeset.first change1.type.to_s.should == "ROLE_REMOVED" change1.context.should == assoc change2 = changeset.get(1) change2.type.to_s.should == "ROLE_REMOVED" change2.context.should == assoc change3 = changeset.last change3.type.to_s.should == "ASSOCIATION_REMOVED" change3.context.should == @tm number_of_roles_removed = changeset.size - 1 number_of_roles_removed.times do |i| puts i changeset[i].old_value.player.reference.should include "role_player" end end it "when removing a role from an association" do @tm.topics.should be_empty @tm.revision_index.last_revision.should be_nil @tm.disable_revision_management assoc = @tm.create_association("assoc_type", "role_type1" => "role_player1") role = assoc.create_role("role_type2", "role_player2") @tm.enable_revision_management @tm.revision_index.last_revision.should be_nil role.remove @tm.should have(1).all_revisions last_revision = @tm.revision_index.last_revision last_revision.should_not be_nil last_revision.changeset_type.to_s.should == "ROLE_REMOVED" RTM::Revision.topic_or_association_context(last_revision).should == assoc changeset = last_revision.changeset changeset.size.should == 1 change1 = changeset.first change1.type.to_s.should == "ROLE_REMOVED" change1.context.should == assoc end it "when setting a value of a name" do @tm.topics.should be_empty @tm.revision_index.last_revision.should be_nil @tm.disable_revision_management topic1 = @tm.get!("topic1") name = topic1.create_name("name") @tm.enable_revision_management @tm.revision_index.last_revision.should be_nil name.set_value("other name") @tm.should have(1).all_revisions last_revision = @tm.revision_index.last_revision last_revision.should_not be_nil last_revision.changeset_type.to_s.should == "VALUE_MODIFIED" RTM::Revision.topic_or_association_context(last_revision).should == topic1 changeset = last_revision.changeset changeset.size.should == 1 change1 = changeset.first change1.type.to_s.should == "VALUE_MODIFIED" change1.context.should == name end it "when setting a value of an occurrence" do @tm.topics.should be_empty @tm.revision_index.last_revision.should be_nil @tm.disable_revision_management topic1 = @tm.get!("topic1") occ = topic1.create_occurrence("occ_type", "occ") @tm.enable_revision_management @tm.revision_index.last_revision.should be_nil occ.set_value(@tm.create_locator("other occ")) @tm.should have(1).all_revisions last_revision = @tm.revision_index.last_revision last_revision.should_not be_nil last_revision.changeset_type.to_s.should == "VALUE_MODIFIED" RTM::Revision.topic_or_association_context(last_revision).should == topic1 changeset = last_revision.changeset changeset.size.should == 2 change1 = changeset.first change1.type.to_s.should == "VALUE_MODIFIED" change1.context.should == occ change1 = changeset.last change1.type.to_s.should == "DATATYPE_SET" change1.context.should == occ end it "when setting a value of a variant" do @tm.topics.should be_empty @tm.revision_index.last_revision.should be_nil @tm.disable_revision_management topic1 = @tm.get!("topic1") name = topic1.create_name("name") variant = name.create_variant("var", ["theme"]) @tm.enable_revision_management @tm.revision_index.last_revision.should be_nil variant.set_value(@tm.create_locator("other val")) @tm.should have(1).all_revisions last_revision = @tm.revision_index.last_revision last_revision.should_not be_nil last_revision.changeset_type.to_s.should == "VALUE_MODIFIED" RTM::Revision.topic_or_association_context(last_revision).should == topic1 changeset = last_revision.changeset changeset.size.should == 2 change1 = changeset.first change1.type.to_s.should == "VALUE_MODIFIED" change1.context.should == variant change1 = changeset.last change1.type.to_s.should == "DATATYPE_SET" change1.context.should == variant end it "when adding a theme to a scoped (name)" do @tm.topics.should be_empty @tm.revision_index.last_revision.should be_nil @tm.disable_revision_management topic1 = @tm.get!("topic1") name = topic1.create_name("name") @tm.get!("theme") @tm.enable_revision_management @tm.revision_index.last_revision.should be_nil name.add_theme("theme") @tm.should have(1).all_revisions last_revision = @tm.revision_index.last_revision last_revision.should_not be_nil last_revision.changeset_type.to_s.should == "SCOPE_MODIFIED" RTM::Revision.topic_or_association_context(last_revision).should == topic1 changeset = last_revision.changeset changeset.size.should == 1 change1 = changeset.first change1.type.to_s.should == "SCOPE_MODIFIED" change1.context.should == name end it "when adding a theme to a scoped (association)" do @tm.topics.should be_empty @tm.revision_index.last_revision.should be_nil @tm.disable_revision_management topic1 = @tm.get!("topic1") assoc = @tm.create_association("assoc_type", "role_type1" => "role_player1", "role_type2" => "role_player2") @tm.get!("theme") @tm.enable_revision_management @tm.revision_index.last_revision.should be_nil assoc.add_theme("theme") @tm.should have(1).all_revisions last_revision = @tm.revision_index.last_revision last_revision.should_not be_nil last_revision.changeset_type.to_s.should == "SCOPE_MODIFIED" RTM::Revision.topic_or_association_context(last_revision).should == assoc changeset = last_revision.changeset changeset.size.should == 1 change1 = changeset.first change1.type.to_s.should == "SCOPE_MODIFIED" change1.context.should == assoc end it "when removing a theme from a scoped (name)" do @tm.topics.should be_empty @tm.revision_index.last_revision.should be_nil @tm.disable_revision_management topic1 = @tm.get!("topic1") name = topic1.create_name("name", ["theme"]) @tm.enable_revision_management @tm.revision_index.last_revision.should be_nil name.remove_theme("theme") @tm.should have(1).all_revisions last_revision = @tm.revision_index.last_revision last_revision.should_not be_nil last_revision.changeset_type.to_s.should == "SCOPE_MODIFIED" RTM::Revision.topic_or_association_context(last_revision).should == topic1 changeset = last_revision.changeset changeset.size.should == 1 change1 = changeset.first change1.type.to_s.should == "SCOPE_MODIFIED" change1.context.should == name end it "when removing a theme to a scoped (association)" do @tm.topics.should be_empty @tm.revision_index.last_revision.should be_nil @tm.disable_revision_management topic1 = @tm.get!("topic1") assoc = @tm.create_association("assoc_type", "role_type1" => "role_player1", "role_type2" => "role_player2") assoc.add_theme("theme") @tm.enable_revision_management @tm.revision_index.last_revision.should be_nil assoc.remove_theme("theme") @tm.should have(1).all_revisions last_revision = @tm.revision_index.last_revision last_revision.should_not be_nil last_revision.changeset_type.to_s.should == "SCOPE_MODIFIED" RTM::Revision.topic_or_association_context(last_revision).should == assoc changeset = last_revision.changeset changeset.size.should == 1 change1 = changeset.first change1.type.to_s.should == "SCOPE_MODIFIED" change1.context.should == assoc end it "when setting a type of a typed (occurrence)" do @tm.topics.should be_empty @tm.revision_index.last_revision.should be_nil @tm.disable_revision_management topic1 = @tm.get!("topic1") occ = topic1.create_occurrence("occ_type", "occ") @tm.get!("other_type") @tm.enable_revision_management @tm.revision_index.last_revision.should be_nil occ.type = "other_type" @tm.should have(1).all_revisions last_revision = @tm.revision_index.last_revision last_revision.should_not be_nil last_revision.changeset_type.to_s.should == "TYPE_SET" RTM::Revision.topic_or_association_context(last_revision).should == topic1 changeset = last_revision.changeset changeset.size.should == 1 change1 = changeset.first change1.type.to_s.should == "TYPE_SET" change1.context.should == occ end it "when setting a type of a typed (role)" do @tm.topics.should be_empty @tm.revision_index.last_revision.should be_nil @tm.disable_revision_management topic1 = @tm.get!("topic1") assoc = @tm.create_association("assoc_type", "role_type1" => "role_player1") role = assoc.create_role("role_type2", "role_player2") @tm.get!("role_type3") @tm.enable_revision_management @tm.revision_index.last_revision.should be_nil role.type = "role_type3" @tm.should have(1).all_revisions last_revision = @tm.revision_index.last_revision last_revision.should_not be_nil last_revision.changeset_type.to_s.should == "TYPE_SET" RTM::Revision.topic_or_association_context(last_revision).should == assoc changeset = last_revision.changeset changeset.size.should == 1 change1 = changeset.first change1.type.to_s.should == "TYPE_SET" change1.context.should == role end it "when setting the player of a role" do @tm.topics.should be_empty @tm.revision_index.last_revision.should be_nil @tm.disable_revision_management topic1 = @tm.get!("topic1") assoc = @tm.create_association("assoc_type", "role_type1" => "role_player1") role = assoc.create_role("role_type2", "role_player2") @tm.get!("role_player3") @tm.enable_revision_management @tm.revision_index.last_revision.should be_nil role.player = "role_player3" @tm.should have(1).all_revisions last_revision = @tm.revision_index.first_revision last_revision.should_not be_nil last_revision.changeset_type.to_s.should == "PLAYER_MODIFIED" RTM::Revision.topic_or_association_context(last_revision).should == assoc changeset = last_revision.changeset changeset.size.should == 1 change1 = changeset.first change1.type.to_s.should == "PLAYER_MODIFIED" change1.context.should == role end it "when setting a reifier of a reifier (role)" do @tm.topics.should be_empty @tm.revision_index.last_revision.should be_nil @tm.disable_revision_management topic1 = @tm.get!("topic1") assoc = @tm.create_association("assoc_type", "role_type1" => "role_player1") role = assoc.create_role("role_type2", "role_player2") @tm.get!("reifier") @tm.enable_revision_management @tm.revision_index.last_revision.should be_nil role.reifier = "reifier" @tm.should have(1).all_revisions last_revision = @tm.revision_index.first_revision last_revision.should_not be_nil last_revision.changeset_type.to_s.should == "REIFIER_SET" changeset = last_revision.changeset changeset.size.should == 1 change1 = changeset.first change1.type.to_s.should == "REIFIER_SET" change1.context.should == role end it "when de-setting a reifier of a reifier (role) " do @tm.topics.should be_empty @tm.revision_index.last_revision.should be_nil @tm.disable_revision_management topic1 = @tm.get!("topic1") assoc = @tm.create_association("assoc_type", "role_type1" => "role_player1") role = assoc.create_role("role_type2", "role_player2") role.reifier = "reifier" role.reifier.should_not be_nil @tm.enable_revision_management @tm.revision_index.last_revision.should be_nil role.reifier = nil role.reifier.should be_nil @tm.should have(1).all_revisions last_revision = @tm.revision_index.first_revision last_revision.should_not be_nil last_revision.changeset_type.to_s.should == "REIFIER_SET" changeset = last_revision.changeset changeset.size.should == 1 change1 = changeset.first change1.type.to_s.should == "REIFIER_SET" change1.context.should == role end it "when calling merge_in " do @tm.topics.should be_empty @tm.revision_index.last_revision.should be_nil @tm.disable_revision_management topic1 = @tm.get!("topic1") topic1.create_name("name") topic1.create_occurrence("occ_type", "occ") assoc = @tm.create_association("assoc_type", "role_type1" => "role_player1", "role_type2" => "role_player2") tm = get_used_tm_sys.create("http://example.org/merging_map/") topic2 = tm.get!("topic1") topic2.create_name("name") topic2.create_occurrence("occ_type", "occ") assoc = tm.create_association("assoc_type", "role_type1" => "role_player1", "role_type2" => "role_player2") @tm.enable_revision_management @tm.revision_index.last_revision.should be_nil @tm.merge_in(tm) if implementation_for_spec == :majortom_db pending "not working" do @tm.should have(1).all_revisions last_revision = @tm.revision_index.first_revision last_revision.should_not be_nil last_revision.changeset_type.to_s.should == "MERGE" changeset = last_revision.changeset changeset.size.should == 32 end else @tm.should have(1).all_revisions last_revision = @tm.revision_index.first_revision last_revision.should_not be_nil last_revision.changeset_type.to_s.should == "MERGE" changeset = last_revision.changeset changeset.size.should == 32 end end it "when calling remove_duplicates" do @tm.topics.should be_empty @tm.revision_index.last_revision.should be_nil @tm.disable_revision_management topic1 = @tm.get!("topic1") topic1.create_name("name") topic1.create_name("name") @tm.enable_revision_management @tm.revision_index.last_revision.should be_nil @tm.remove_duplicates @tm.should have(1).all_revisions last_revision = @tm.revision_index.first_revision last_revision.should_not be_nil if implementation_for_spec == :majortom_db pending "not working" do last_revision.changeset_type.to_s.should == "REMOVE_DUPLICATES" changeset = last_revision.changeset changeset.size.should == 1 end else last_revision.changeset_type.to_s.should == "REMOVE_DUPLICATES" changeset = last_revision.changeset changeset.size.should == 1 end end end end describe "Changes in the topic map" do it "should handle creating and deleting a topic" do @tm.topics.should be_empty @tm.revision_index.last_revision.should be_nil @tm.enable_revision_management topic = @tm.get!("topic") topic.remove @tm.should have(2).all_revisions first_revision = @tm.revision_index.first_revision first_revision.changeset_type.should == RTM::Revision::Type::TOPIC_ADDED first_revision.changeset.first.new_value.read_only?.should be_true end end end # of describe self end