### Question:
AnnotationDataBuilder { static void populateClassName(final AnnotationData data, final Annotation annotation, final Class expectedAnnotationClass) { if (annotation == null) { throw new InvalidParameterException(String.format( "No annotation of type [%s] found.", expectedAnnotationClass.getName() )); } final Class clazz = annotation.annotationType(); if (!expectedAnnotationClass.equals(clazz)) { throw new InvalidParameterException(String.format( "No annotation of type [%s] found, class was of type [%s].", expectedAnnotationClass.getName(), clazz.getName() )); } data.setClassName(clazz.getName()); }    }### Answer:
@Test public void testPopulateClassName() throws Exception { final AnnotationData data = new AnnotationData(); Class expected; String method; Annotation annotation; expected = InvalidateAssignCache.class; method = "populateClassName01"; try { AnnotationDataBuilder.populateClassName(data, null, expected); fail("expected exception"); } catch (InvalidParameterException ex) {} assertEquals("", data.getClassName()); expected = InvalidateAssignCache.class; method = "populateClassName01"; annotation = new Mirror().on(AnnotationDataDummy.class).reflect() .annotation(expected) .atMethod(method).withArgs(String.class); try { AnnotationDataBuilder.populateClassName(data, annotation, UpdateAssignCache.class); fail("expected exception"); } catch (InvalidParameterException ex) {} assertEquals("", data.getClassName()); expected = InvalidateAssignCache.class; method = "populateClassName01"; annotation = new Mirror().on(AnnotationDataDummy.class).reflect() .annotation(expected) .atMethod(method).withArgs(String.class); AnnotationDataBuilder.populateClassName(data, annotation, expected); assertEquals(expected.getName(), data.getClassName()); }