ClassMappings { public void add(Class<?> srcClass, Class<?> destClass, ClassMap classMap) { ClassMap result = classMappings.put(keyFactory.createKey(srcClass, destClass), classMap); failOnDuplicate(result, classMap); } ClassMappings(BeanContainer beanContainer); void addDefault(Class<?> srcClass, Class<?> destClass, ClassMap classMap); void add(Class<?> srcClass, Class<?> destClass, ClassMap classMap); void add(Class<?> srcClass, Class<?> destClass, String mapId, ClassMap classMap); void addAll(ClassMappings additionalClassMappings); void failOnDuplicate(Object result, ClassMap classMap); Map<String, ClassMap> getAll(); long size(); ClassMap find(Class<?> srcClass, Class<?> destClass); boolean contains(Class<?> srcClass, Class<?> destClass, String mapId); ClassMap find(Class<?> srcClass, Class<?> destClass, String mapId);  }
@Test(expected = IllegalArgumentException.class) public void shouldFailOnDuplicate() { ClassMap classMap = mock(ClassMap.class); when(classMap.getSrcClassName()).thenReturn(String.class.getName()); when(classMap.getDestClassName()).thenReturn(Integer.class.getName()); classMappings.add(String.class, Integer.class, classMap); classMappings.add(String.class, Integer.class, classMap); }
@Test public void shouldNotFailOnDuplicatesForSameSrcAndDest() { ClassMap classMap = mock(ClassMap.class); when(classMap.getSrcClassName()).thenReturn(String.class.getName()); when(classMap.getDestClassName()).thenReturn(String.class.getName()); classMappings.add(String.class, String.class, classMap); classMappings.add(String.class, String.class, classMap); }