assoc.setReifier(reifier);
/** * Internal method to set reification twice with the same reifier. * DuplicateReificationException should be detected, fail test otherwise. */ private void checkDuplicateReificationException(ReifiableIF reifiable) { TopicIF reifier = builder.makeTopic(); builder.makeAssociation(builder.makeTopic()).setReifier(reifier); try { reifiable.setReifier(reifier); fail("Failed to catch DuplicateReificationException"); } catch (DuplicateReificationException e) { // test succeeded } } }
public void testMergeAssociationReifiers() { // the idea here is: what happens if you attempt to merge two topics // which reify duplicate associations? TopicIF atype = builder1.makeTopic(); AssociationIF assoc1 = builder1.makeAssociation(atype); AssociationIF assoc2 = builder1.makeAssociation(atype); TopicIF player = builder1.makeTopic(); TopicIF type = builder1.makeTopic(); AssociationRoleIF ar1 = builder1.makeAssociationRole(assoc1, type, player); AssociationRoleIF ar2 = builder1.makeAssociationRole(assoc2, type, player); // the two associations should be equal TopicIF r1 = builder1.makeTopic(); assoc1.setReifier(r1); TopicIF r2 = builder1.makeTopic(); assoc2.setReifier(r2); MergeUtils.mergeInto(r1, r2); assertTrue("wrong number of roles after merge", player.getRoles().size() == 1); } }
public void testFindHorseInAssocDesc() throws InvalidQueryException, IOException { load("bb-test.ltm", true); TopicIF isabout = getTopicById("is-about"); TopicIF reifier = getTopicById("is-about-horse"); AssociationIF assoc = getAssociationOfType(isabout); // make reifier reify assoc assoc.setReifier(reifier); List matches = new ArrayList(); addMatch(matches, "ASSOC", assoc, "DATE", "2003-08-14", "DESCR", "The best association ever"); verifyQueryOrder(matches, "select $ASSOC, $DATE, $DESCR from " + " value-like($OCC, \"association\"), " + " occurrence($TOPIC, $OCC), type($OCC, beskrivelse), " + " reifies($TOPIC, $ASSOC), association($ASSOC), " + " association-role($ASSOC, $ROLE), " + " type($ROLE, role1), " + " role-player($ROLE, $BBTOPIC), " + " topicbelongstosubject($BBTOPIC : bbtopic, k7ahistory : fag), " + " userownstopic($BBTOPIC : ownedtopic, gdm : bruker), " + " beskrivelse($TOPIC, $DESCR), " + " lastupdated($TOPIC, $DATE) " + "order by $DATE?"); closeStore(); }
role = builder.makeAssociationRole(assoc, role2, player2); TopicIF r1 = builder.makeTopic(); assoc.setReifier(r1); builder.makeTopicName(r1, "r1"); role = builder.makeAssociationRole(assoc, role2, player2); TopicIF r2 = builder.makeTopic(); assoc.setReifier(r2); builder.makeTopicName(r2, "r2");
public void testMergeReifiedAssociation() { // build TM TopicIF reifier = builder1.makeTopic(); TopicIF at = builder1.makeTopic(); TopicIF nrt = builder1.makeTopic(); TopicIF nrp = builder1.makeTopic(); TopicIF drt = builder1.makeTopic(); TopicIF drp = builder1.makeTopic(); TopicIF target = builder1.makeTopic(); AssociationIF assoc = builder1.makeAssociation(at); AssociationRoleIF nrole = builder1.makeAssociationRole(assoc, nrt, nrp); AssociationRoleIF drole = builder1.makeAssociationRole(assoc, drt, drp); assoc.setReifier(reifier); // merge MergeUtils.mergeInto(target, nrp); // previous line checks if moving association from nrp to target causes it to lose // its reifier // check AssociationRoleIF newrole = (AssociationRoleIF)target.getRoles().iterator().next(); AssociationIF newassoc = newrole.getAssociation(); assertTrue("Association lost reifier on merge", newassoc.getReifier() == reifier); assertTrue("Topic lost reified on merge", reifier.getReified() == newassoc); }
@Test public void testAssociation() throws Exception { AssociationIF assoc = tm1.getBuilder().makeAssociation(foo1); tm1.getBuilder().makeAssociationRole(assoc, tm1.getBuilder().makeTopic(), tm1.getBuilder().makeTopic()); assoc.setReifier(foo1); // todo: assoc.addTheme(foo1); pending #265 concurrentCommit(); // verify no inconsistenties were created check(tm1, assoc.getType(), "Association", "type"); check(tm1, assoc.getReifier(), "Association", "reifier"); // todo: check(tm1, assoc.getScope().iterator().next().getObjectId(), "Association", "scope"); pending #265 }