### Question:
IdAndNameCaptionProvider implements ItemCaptionProvider<Object> { @Override public String getCaption(Object o) { return getName(o) + " [" + getId(o) + "]"; }  @Override String getCaption(Object o);  }### Answer:
@Test public void testIdAndNameCaptionProvider_AnonymousClass() { ItemCaptionProvider<Object> provider = new IdAndNameCaptionProvider(); assertThat(provider.getCaption(TestEnum.VALUE1), is("name1 [id1]")); }
@Test public void testIdAndNameCaptionProvider_AllMethods() { ItemCaptionProvider<Object> provider = new IdAndNameCaptionProvider(); assertThat(provider.getCaption(AllMethodsEnum.VALUE), is("getName(Locale) [id]")); }
@Test public void testIdAndNameCaptionProvider_MissingGetIdMethod() { ItemCaptionProvider<Object> provider = new IdAndNameCaptionProvider(); Assertions.assertThrows(IllegalStateException.class, () -> { provider.getCaption(UnnamedEnum.VALUE); }); }