public void testParentTopicMap() { assertTrue("parent topic map is not correct", topic.getTopicMap() == topicmap); }
public void testNamesByType() { TopicIF type = builder.makeTopic(); assertTrue("names by non-existent type initially not empty", topic.getTopicNamesByType(type).size() == 0); TopicNameIF name = builder.makeTopicName(topic, type, "foo"); assertTrue("names of correct type not found", topic.getTopicNamesByType(type).size() == 1); TopicNameIF name2 = builder.makeTopicName(topic, builder.makeTopic(), "bar"); assertTrue("name with with incorrect type found", topic.getTopicNamesByType(type).size() == 1); }
public void testOccurrencesByType() { TopicIF type = builder.makeTopic(); assertTrue("occurrences by non-existent type initially not empty", topic.getOccurrencesByType(type).size() == 0); OccurrenceIF occ = builder.makeOccurrence(topic, type, "foo"); assertTrue("occurrences of correct type not found", topic.getOccurrencesByType(type).size() == 1); OccurrenceIF occ2 = builder.makeOccurrence(topic, builder.makeTopic(), "bar"); assertTrue("occurrence with with incorrect type found", topic.getOccurrencesByType(type).size() == 1); }
public void testTopicNames() { // STATE 1 assertTrue("basename set not empty initially", topic.getTopicNames().size() == 0); // STATE 2 TopicNameIF basename = builder.makeTopicName(topic, ""); // added by builder assertTrue("basename not added", topic.getTopicNames().size() == 1); assertTrue("basename identity not retained", topic.getTopicNames().iterator().next().equals(basename)); // STATE 2 basename.remove(); assertTrue("basename not removed", topic.getTopicNames().size() == 0); // verify that it's safe basename.remove(); }
public void testOccurrences() { // STATE 1 assertTrue("occurrence set not empty initially", topic.getOccurrences().size() == 0); // STATE 2 TopicIF otype = builder.makeTopic(); OccurrenceIF occurrence = builder.makeOccurrence(topic, otype, ""); // added by builder assertTrue("occurrence not added", topic.getOccurrences().size() == 1); assertTrue("occurrence identity not retained", topic.getOccurrences().iterator().next().equals(occurrence)); // STATE 2 occurrence.remove(); assertTrue("occurrence not removed", topic.getOccurrences().size() == 0); // verify that it's safe occurrence.remove(); }
public void testTypes() { // STATE 1 assertTrue("type set not empty initially", topic.getTypes().size() == 0); // STATE 2 TopicIF type = builder.makeTopic(); topic.addType(type); assertTrue("type not added", topic.getTypes().size() == 1); assertTrue("type identity not retained", topic.getTypes().iterator().next().equals(type)); topic.addType(type); assertTrue("duplicate not rejected", topic.getTypes().size() == 1); // STATE 2 topic.removeType(type); assertTrue("type not removed", topic.getTypes().size() == 0); // verify that it's safe topic.removeType(type); }
public void testAssociations() { assertTrue("associations initially not empty", topic.getAssociations().size() == 0); builder.makeAssociation(builder.makeTopic(), builder.makeTopic(), topic); assertTrue("associations incorrect count", topic.getAssociations().size() == 1); builder.makeAssociation(builder.makeTopic(), builder.makeTopic(), topic); assertTrue("associations incorrect count", topic.getAssociations().size() == 2); }
public void testAssociationsByType() { TopicIF type = builder.makeTopic(); assertTrue("associations by non-existent type initially not empty", topic.getAssociationsByType(type).size() == 0); builder.makeAssociation(type, builder.makeTopic(), topic); assertTrue("associations of correct type not found", topic.getAssociationsByType(type).size() == 1); builder.makeAssociation(builder.makeTopic(), builder.makeTopic(), topic); assertTrue("associations with with incorrect type found", topic.getAssociationsByType(type).size() == 1); }
public void testSubject() { assertTrue("subject not null initially", topic.getSubjectLocators().isEmpty()); try { URILocator loc = new URILocator("http://www.ontopia.net/"); topic.addSubjectLocator(loc); assertTrue("subject not set properly", topic.getSubjectLocators().contains(loc)); topic.removeSubjectLocator(loc); assertTrue("couldn't set subject to null", topic.getSubjectLocators().isEmpty()); } catch (MalformedURLException e) { fail("(INTERNAL) URL malformed"); } catch (ConstraintViolationException e) { fail("constraint violated for no good reason"); } }
public void testRoles() { // STATE 1 assertTrue("role set not empty initially", topic.getRoles().size() == 0); // STATE 2 AssociationIF assoc = builder.makeAssociation(builder.makeTopic()); AssociationRoleIF role = builder.makeAssociationRole(assoc, builder.makeTopic(), topic); assertTrue("role not added", topic.getRoles().size() == 1); assertTrue("role identity not retained", topic.getRoles().iterator().next().equals(role)); role.setPlayer(topic); assertTrue("duplicate not rejected", topic.getRoles().size() == 1); try { role.setPlayer(null); fail("player could be set to null"); } catch (NullPointerException e) { } assertTrue("player not retained", role.getPlayer().equals(topic)); }
public void testRolesByType() { TopicIF type = builder.makeTopic(); assertTrue("roles by non-existent type initially not empty", topic.getRolesByType(type).size() == 0); AssociationIF assoc = builder.makeAssociation(builder.makeTopic()); // builder adds role to assoc AssociationRoleIF role = builder.makeAssociationRole(assoc, type, topic); assertTrue("roles of correct type not found", topic.getRolesByType(type).size() == 1); // builder adds role to assoc TopicIF other = builder.makeTopic(); TopicIF rtype = builder.makeTopic(); AssociationRoleIF role2 = builder.makeAssociationRole(assoc, rtype, other); assertTrue("role with no type found", topic.getRolesByType(type).size() == 1); assertTrue("role with no type not found", other.getRolesByType(rtype).size() == 1); }
public void testSubjectIndicators() { assertTrue("indicator set not empty initially", topic.getSubjectIdentifiers().size() == 0); topic.addSubjectIdentifier(indicator); assertTrue("indicator not added", topic.getSubjectIdentifiers().size() == 1); assertTrue("indicator identity not retained", topic.getSubjectIdentifiers().iterator().next().equals(indicator)); assertTrue("duplicate not rejected", topic.getSubjectIdentifiers().size() == 1); assertTrue("indicator not removed", topic.getSubjectIdentifiers().size() == 0);
public void testDeleteInstanceOfSelf() { TopicIF topic = builder.makeTopic(); topic.addType(topic); topic.remove(); assertTrue("topic was not deleted", topic.getTopicMap() == null); }
public void testDeleteTopicWithRole() { // first create a ternary association TopicIF atype = builder.makeTopic(); TopicIF other = builder.makeTopic(); TopicIF roletype = builder.makeTopic(); for (int ix = 0; ix < 150; ix++) { // must do this 100 times to trigger creation of TreeSet AssociationIF assoc = builder.makeAssociation(atype); AssociationRoleIF role1 = builder.makeAssociationRole(assoc, roletype, other); AssociationRoleIF role2 = builder.makeAssociationRole(assoc, roletype, topic); } // then delete the topic topic.remove(); // boom // now verify that it's gone assertEquals("wrong number of topics in TM", 3, topicmap.getTopics().size()); assertTrue("wrong number of associations in TM", topicmap.getAssociations().size() == 0); }