TaggedConverter implements Converter { public void addConverters(Converter converter, String... tags) { for (String tag : tags) { if (tag.startsWith("!")) { notConverters.put(tag.substring(1), converter); } else { converters.put(tag, converter); } } }  void addConverters(Converter converter, String... tags); @Override void convert(Object source, Object target, String... tags);  }
@Test public void testAddConverters() throws Exception { Converter c1 = mock(Converter.class); Converter c2 = mock(Converter.class); taggedConverter.addConverters(c1, TAG, "zzz"); taggedConverter.addConverters(c2, TAG); Map<String, Converter> res = (Map<String, Converter>) ReflectionTestUtils.getField(taggedConverter, "converters"); assertThat(res).hasSize(2).contains(entry("zzz", c1), entry("key", c2)); }