Smell { public static Smell copyWithoutParent(Smell smell) { return new Smell(smell.type, smell.instance, smell.file); } Smell(String type, String instance, String file); static Smell fromPaprikaInstance(Map<String, Object> smell, String type); static Smell fromDetectorInstance(Map<String, Object> smell); static Smell copyWithoutParent(Smell smell); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); public int id; final String type; final String instance; final String file; public Smell parent; }
@Test public void testHashMap() { Map<Smell, Smell> myMap = new HashMap<>(); myMap.put(first, third); assertEquals(third, myMap.get(first)); assertEquals(third, myMap.get(second)); assertEquals(third, myMap.get(Smell.copyWithoutParent(first))); second.parent = first; third.parent = second; myMap.put(third, first); assertEquals(first, myMap.get(third)); assertTrue(myMap.containsKey(myMap.keySet().toArray()[0])); }