### Question:
AnnotationFactory { public static <T extends Annotation> T create(Class<T> annotationType) { return create(annotationType, Collections.emptyMap()); } private  AnnotationFactory(); static T create(Class<T> annotationType); static T create(Class<T> annotationType, Map<String, ?> values);  }### Answer:
@Test @Foo public void createNoProperties() throws Exception { checkImplementation(Foo.class, "createNoProperties", AnnotationFactory.create(Foo.class), "@org.jdbi.v3.core.internal.AnnotationFactoryTest$Foo()"); }
@Test public void createAnnotationWithAttributeFails() { assertThatThrownBy(() -> AnnotationFactory.create(Bar.class)) .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining("Cannot synthesize annotation @Bar from Bar.class because it has attribute"); }
@Test @Baz("baz") public void createWithDefaults() throws Exception { checkImplementation(Baz.class, "createWithDefaults", AnnotationFactory.create(Baz.class, Collections.singletonMap("value", "baz")), "@org.jdbi.v3.core.internal.AnnotationFactoryTest$Baz(value=baz)"); }
@Test @Baz(value = "baz", coolness = -1, soMeta = Foo.class) public void createWithExplicitProperties() throws Exception { Map<String, Object> values = new HashMap<>(); values.put("value", "baz"); values.put("coolness", -1); values.put("soMeta", Foo.class); checkImplementation(Baz.class, "createWithExplicitProperties", AnnotationFactory.create(Baz.class, values), "@org.jdbi.v3.core.internal.AnnotationFactoryTest$Baz(coolness=-1, soMeta=interface org.jdbi.v3.core.internal.AnnotationFactoryTest$Foo, value=baz)"); }
@Test public void unequal() throws Exception { assertThat(AnnotationFactory.create(Baz.class, Collections.singletonMap("value", "baz"))) .isNotEqualTo(getAnno(Baz.class, "createWithExplicitProperties")); }