@Override public int compare(AssociationRoleIF ar1, AssociationRoleIF ar2) { // Compare the IDs of the role types. int retVal = lazyStringCompare(lazyTypeElementId(ar1), lazyTypeElementId(ar2)); // Compare the IDs of the roles themselves. if (retVal == 0) retVal = lazyStringCompare(lazyPlayerElementId(ar1), lazyPlayerElementId(ar2)); // Compare the reifier(if any) of the association roles. if (retVal == 0) { TopicIF reifier1 = ar1.getReifier(); Collection<TopicIF> reifiers1 = (reifier1 == null ? Collections.<TopicIF>emptySet() : Collections.singleton(reifier1)); TopicIF reifier2 = ar2.getReifier(); Collection<TopicIF> reifiers2 = (reifier2 == null ? Collections.<TopicIF>emptySet() : Collections.singleton(reifier2)); reifiers1 = filterCollection(reifiers1); reifiers2 = filterCollection(reifiers2); retVal = reifierComparator.compare(reifiers1, reifiers2); } return retVal; } }
newdrole.getReifier() == reifier); assertTrue("Topic lost reified on merge", reifier.getReified() == newdrole);
public void testMergeReifiedNearRole() { // 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); nrole.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 newnrole = (AssociationRoleIF)target.getRoles().iterator().next(); assertTrue("Near role lost reifier on merge", newnrole.getReifier() == reifier); assertTrue("Topic lost reified on merge", reifier.getReified() == newnrole); }
@Test public void testAssociationRole() throws Exception { AssociationIF assoc = tm1.getBuilder().makeAssociation(tm1.getBuilder().makeTopic()); AssociationRoleIF role = tm1.getBuilder().makeAssociationRole(assoc, foo1, foo1); role.setReifier(foo1); concurrentCommit(); // verify no inconsistenties were created check(tm1, role.getType(), "Association role", "type"); check(tm1, role.getPlayer(), "Association role", "player"); check(tm1, role.getReifier(), "Association role", "reifier"); }