public static String toString(String impl, AssociationRoleIF role) { String id = UNASSIGNED; try { if (role.getTopicMap() != null) id = role.getObjectId(); return "[" + impl + ", " + id + ", type: " + role.getType() + "]"; } catch (Throwable t) { return "[" + impl + ", " + role.getObjectId() + "!]"; } }
public void testTopicRemovalPolicyRole() { TopicIF topic = builder.makeTopic(); TopicIF other = builder.makeTopic(); AssociationIF assoc = builder.makeAssociation(builder.makeTopic()); AssociationRoleIF role1 = builder.makeAssociationRole(assoc, builder.makeTopic(), topic); AssociationRoleIF role2 = builder.makeAssociationRole(assoc, builder.makeTopic(), other); topic.remove(); assertTrue("association not deleted", assoc.getTopicMap() == null); assertTrue("role1 not deleted", role1.getTopicMap() == null); assertTrue("role2 not deleted", role2.getTopicMap() == null); assertTrue("remaining topic has roles left", other.getRoles().size() == 0); }
public void testTopicAssociationDeletion() { TopicMapIF topicmap = makeTopicMap(); TopicMapBuilderIF builder = topicmap.getBuilder(); TopicIF morituri = builder.makeTopic(); TopicIF other = builder.makeTopic(); AssociationIF assoc = builder.makeAssociation(builder.makeTopic()); AssociationRoleIF role1 = builder.makeAssociationRole(assoc, builder.makeTopic(), morituri); AssociationRoleIF role2 = builder.makeAssociationRole(assoc, builder.makeTopic(), other); morituri.remove(); assertTrue("Topic still connected to topic map", morituri.getTopicMap() == null); assertTrue("Topic map has too many topics", topicmap.getTopics().size() == 4); assertTrue("Role 1 still connected to topic map", role1.getTopicMap() == null); assertTrue("Role 2 still connected to topic map", role2.getTopicMap() == null); assertTrue("Association still connected to topic map", assoc.getTopicMap() == null); assertTrue("Topic map still has association", topicmap.getAssociations().size() == 0); }
public void testTopicAssociationRolePlayerDeletion() { TopicMapIF topicmap = makeTopicMap(); TopicMapBuilderIF builder = topicmap.getBuilder(); TopicIF morituri = builder.makeTopic(); TopicIF other = builder.makeTopic(); AssociationIF assoc = builder.makeAssociation(builder.makeTopic()); AssociationRoleIF role1 = builder.makeAssociationRole(assoc, builder.makeTopic(), morituri); AssociationRoleIF role2 = builder.makeAssociationRole(assoc, builder.makeTopic(), other); morituri.remove(); assertTrue("Topic still connected to topic map", morituri.getTopicMap() == null); assertTrue("Topic map has too many topics", topicmap.getTopics().size() == 4); assertTrue("Role still part of topic map", role1.getTopicMap() == null); assertTrue("other still has role", other.getRoles().size() == 0); assertTrue("Topic map lost association", topicmap.getAssociations().size() == 0); }