public void testObjectByNonNumericId() { assertTrue("Found object by non-sensical ID 'bongo'", tm.getObjectById("Bongo") == null); }
public void testTopics() { // STATE 1 assertTrue("topic set not empty initially", tm.getTopics().size() == 0); // STATE 2 TopicIF topic = builder.makeTopic(); // added by builder assertTrue("topic not added", tm.getTopics().size() == 1); assertTrue("topic identity not retained", tm.getTopics().iterator().next().equals(topic)); // STATE 3 topic.remove(); assertTrue("topic not removed", tm.getTopics().size() == 0); assertTrue("topic topicMap property not reset after topic removed", topic.getTopicMap() == null); // verify that it's safe topic.remove(); }
public void testReification() { TopicIF reifier = builder.makeTopic(); ReifiableIF reifiable = tm; assertTrue("Object reified by the reifying topic was found", reifier.getReified() == null); assertTrue("Topic reifying the reifiable was found", reifiable.getReifier() == null); reifiable.setReifier(reifier); assertTrue("No topic reifying the reifiable was found", reifiable.getReifier() == reifier); assertTrue("No object reified by the reifying topic was found", reifier.getReified() == reifiable); reifiable.setReifier(null); assertTrue("Object reified by the reifying topic was found", reifier.getReified() == null); assertTrue("Topic reifying the first reifiable was found", reifiable.getReifier() == null); }
public void testAssociations() { // STATE 1 assertTrue("association set not empty initially", tm.getAssociations().size() == 0); // STATE 2 AssociationIF association = builder.makeAssociation(builder.makeTopic()); // added by builder assertTrue("association not added", tm.getAssociations().size() == 1); assertTrue("association identity not retained", tm.getAssociations().iterator().next().equals(association)); // STATE 2 association.remove(); assertTrue("association not removed", tm.getAssociations().size() == 0); // verify that it's safe association.remove(); }
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 testObjectById() { TopicIF topic = builder.makeTopic(); String id = topic.getObjectId(); assertTrue("Could not locate object by ID (" + id + ")", tm.getObjectById(id) != null); assertTrue("Found wrong object type by ID (" + id + ")", tm.getObjectById(id) instanceof TopicIF); assertTrue("Found wrong object: " + tm.getObjectById(id).getObjectId() + " - " + topic.getObjectId(), tm.getObjectById(id).getObjectId().equals(topic.getObjectId())); topic.remove(); //! System.out.println("------------------------->" + topic); //! System.out.println("--" + topic.getTopicMap()); //! System.out.println("--" + tm.getObjectById(id) + " " + System.identityHashCode(tm.getObjectById(id))); //! System.out.println("--" + tm.getObjectById(id).getTopicMap()); assertTrue("Found topic by ID after it was removed", tm.getObjectById(id) == null); try { tm.getObjectById(null); fail("getObjectById accepts null parameter."); } catch (NullPointerException ex) { // Expected. } }
public void testAssociationRemove() { TopicIF at = builder.makeTopic(); TopicIF rt1 = builder.makeTopic(); TopicIF rt2 = builder.makeTopic(); TopicIF t1 = builder.makeTopic(); TopicIF t2 = builder.makeTopic(); AssociationIF association = builder.makeAssociation(at); AssociationRoleIF role1 = builder.makeAssociationRole(association, rt1, t1); AssociationRoleIF role2 = builder.makeAssociationRole(association, rt2, t2); association.remove(); assertTrue("removing association from topic map does not remove child roles from their players", t1.getRoles().size() == 0); assertTrue("removing association from topic map does not remove child roles from their players", t2.getRoles().size() == 0); }
assertTrue("topic not found by source locator", found.equals(topic)); assertTrue("topic found by source locator when it shouldn't be", found == null); assertTrue("topic not found by source locator", tm.getObjectByItemIdentifier(loc).equals(topic)); assertTrue("topic found by source locator after it has been removed", tm.getObjectByItemIdentifier(loc) == null);
assertTrue("topic not found by indicator", found.equals(topic)); assertTrue("topic found by indicator when it shouldn't be", found == null); assertTrue("topic not found by indicator", tm.getTopicBySubjectIdentifier(loc).equals(topic)); assertTrue("topic found by indicator after it has been removed", tm.getTopicBySubjectIdentifier(loc) == null);
assertTrue("topic not found by subject", found.equals(topic)); assertTrue("topic found by subject when it shouldn't be", found == null); assertTrue("topic not found by subject", tm.getTopicBySubjectLocator(loc).equals(topic)); assertTrue("topic found by subject after it has been removed", tm.getTopicBySubjectLocator(loc) == null);