public NoNames(TopicMapIF tm) { this.tm = tm; findNoNameTopics(); }
/** * ******************************************* * methods used to test the sanity checker. * ******************************************* */ public void testDuplicateAssociations() { AssociationSanity test = new AssociationSanity(tm); test.traverse(); assertTrue("type checking (getDuplicateAssociations)", test.getDuplicateAssociations() instanceof HashMap); assertTrue("type checking (getNumberOfDuplicates)", test.getNumberOfDuplicates() instanceof HashMap); assertEquals(1, test.getDuplicateAssociations().size()); }
public void testDuplicateNames() { DuplicateNames test = new DuplicateNames(tm); assertTrue("type checking (getDuplicateNames)", test.getDuplicatedNames() instanceof Collection); assertEquals(0, test.getDuplicatedNames().size()); } }
/** * Handles all the topics without name. */ private void getNoNameTopics() { //Create a new NoNames object NoNames nn = new NoNames(tm); nn.findNoNameTopics(); //Get the result from the nn object, and just prints out //the number of different topicmap elements without name. Collection nonametopics = nn.getNoNameTopics(); print("\nNumber of Topics with no name: " + nonametopics.size() + "\n"); Iterator it = nonametopics.iterator(); while (it.hasNext()) { TopicIF topic = (TopicIF)it.next(); print(getTopicId(topic) + "\n"); } Collection noChar = nn.getNoCharacteristics(); print("\nTopics with no characteristics: " + noChar.size() +"\n"); it = noChar.iterator(); while (it.hasNext()) { TopicIF topic = (TopicIF)it.next(); print(getTopicId(topic) + "\n"); } Collection noscopes = nn.getNoNameUnconstrained(); print("\nNumber of topics with no name in the unconstrained scope: " + noscopes.size() + "\n"); list(noscopes); }
public void testDuplicateOccurrences() { DuplicateOccurrences test = new DuplicateOccurrences(tm); assertTrue("type checking (getDuplicateOccurrences)", test.getDuplicateOccurrences() instanceof Collection); assertEquals(1, test.getDuplicateOccurrences().size()); }
public void traverse() throws NullPointerException { assocs = tm.getAssociations(); Iterator it = assocs.iterator(); while (it.hasNext()) { AssociationIF temp = (AssociationIF)it.next(); String key = createKey(temp); if (checkedAssociations.containsKey(key)) { //This association already exist. //Update number of occurrences and put it back in the //HashMap. Integer tempint = (Integer)numberOfDuplicates.get(key); if (tempint == null){ //first occurrences of this duplicate Association. numberOfDuplicates.put(key, new Integer(2)); } else { //update the number of occurrences for this duplicate assoc. int number = tempint.intValue() + 1; numberOfDuplicates.put(key, new Integer(number)); } //add the duplicate assoc to a HashMap. duplicateAssociations.put(key, temp); } else { //This association has no duplicates - (yet). checkedAssociations.put(key, temp); } } }
assocname = getTopicId(aif.getType()); } catch (NullPointerException e) { assocname = "null"; retur += "$" +rolenames[i] + "$" + getTopicId((TopicIF)types.get(rolenames[i])); } else { retur += "$" +rolenames[i] + "$null";
public void testNoNameTopics() { NoNames test = new NoNames(tm); test.findNoNameTopics(); //Type checking assertTrue("type checking (getNoNameTopics)", test.getNoNameTopics() instanceof Collection); assertTrue("type checking (getNoCharacteristics)", test.getNoCharacteristics() instanceof Collection); assertTrue("type checking (getNoNameUnconstrained)", test.getNoNameUnconstrained() instanceof Collection); assertEquals(2, test.getNoNameTopics().size()); assertEquals(2, test.getNoCharacteristics().size()); //! assertEquals(8, test.getNoNameUnconstrained().size()); }
AssociationSanity ts = new AssociationSanity(tm); ts.traverse(); HashMap duplicateAssocs = ts.getDuplicateAssociations(); HashMap numberOfDuplicates = ts.getNumberOfDuplicates();
/** * Handles all the topics with duplicate names, which means same basename * and scope. */ private void getDuplicatedNames() { //Create a new DuplicateNames object. DuplicateNames dn = new DuplicateNames(tm); //Get the result from the dn object. Collection topics = dn.getDuplicatedNames(); if (topics.size() > 0) { //Print out the result. print("\nNumber of topics with same basename and scope : " + topics.size() + "\n"); Iterator it = topics.iterator(); while (it.hasNext()) { TopicIF t = (TopicIF)it.next(); print(t.getObjectId() + "\n"); } } else { print("\nThis TopicMap contains no topics with same basename and scope.\n"); } }
/** * Handles all the topics with duplicate occurrences. */ private void getDuplicateOccurrences() { //Create a new DuplicateOccurrences object. DuplicateOccurrences dupocc = new DuplicateOccurrences(tm); //Get the result from the dupocc object, and prints the result. Collection duplicateoccurrences = dupocc.getDuplicateOccurrences(); if (duplicateoccurrences.size() > 0) { print("\nNumber of duplicate occurrences : " + duplicateoccurrences.size() + "\n"); print("Topics containing duplicate occurrences :\n"); Iterator it = duplicateoccurrences.iterator(); while (it.hasNext()) { print(getTopicId((TopicIF)it.next()) + "\n"); } } else { print("\nThis TopicMap contains no duplicate occurrences.\n"); } }