public Collection makeStrings(Collection topics) { Collection result = new ArrayList(); Iterator it = topics.iterator(); while (it.hasNext()) { TopicIF topic = (TopicIF)it.next(); result.add(getName(topic)); } return result; }
TopicCounter topiccounter = new TopicCounter(tm); topiccounter.count(); int numberOfTopics = topiccounter.getNumberOfTopics(); int numberOfAssociations = topiccounter.getNumberOfAssociations(); int numberOfOccurrences = topiccounter.getNumberOfOccurrences(); HashMap topicTypes = topiccounter.getTopicTypes(); HashMap assocTypes = topiccounter.getAssociationTypes(); HashMap ocursTypes = topiccounter.getOccurrenceTypes();
TopicCounter test = new TopicCounter(tm); test.count(); } catch (NullPointerException e) { fail("Cought an \"unexpected\" null pointer exception"); assertTrue("check (getTopicTypes)", test.getTopicTypes() instanceof HashMap); assertTrue("check (getAssociationTypes)", test.getAssociationTypes() instanceof HashMap); assertTrue("check (getOccurrenceTypes)", test.getOccurrenceTypes() instanceof HashMap); test.getNumberOfTopics() == tm.getTopics().size()); assertEquals(15, test.getNumberOfTopics()); test.getNumberOfAssociations() == tm.getAssociations().size()); assertEquals(3, test.getNumberOfAssociations()); assertEquals(3, test.getNumberOfOccurrences()); test.getNumberOfOccurrences() != 0); assertTrue("Variable numberOfAssociations not null", test.getNumberOfAssociations() != 0); assertTrue("Variable numberOfOcurrences not null", test.getNumberOfOccurrences() != 0); test = new TopicCounter(null);