### Question:
AnnotationDataBuilder { static void populateAssignedKey(final AnnotationData data, final Annotation annotation, final Class expectedAnnotationClass, final String targetMethodName) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { if (ASSIGNS.contains(expectedAnnotationClass)) { final Method assignKeyMethod = expectedAnnotationClass.getDeclaredMethod("assignedKey", null); final String assignKey = (String) assignKeyMethod.invoke(annotation, null); if (AnnotationConstants.DEFAULT_STRING.equals(assignKey) || assignKey == null || assignKey.length() < 1) { throw new InvalidParameterException(String.format( "AssignedKey for annotation [%s] must be defined on [%s]", expectedAnnotationClass.getName(), targetMethodName )); } data.setAssignedKey(assignKey); } }    }### Answer:
@Test public void testPopulateAssignedKey() throws Exception { final AnnotationData data = new AnnotationData(); Class expected; String method; Annotation annotation; expected = InvalidateSingleCache.class; method = "populateAssign01"; annotation = new Mirror().on(AnnotationDataDummy.class).reflect() .annotation(expected) .atMethod(method).withArgs(String.class); AnnotationDataBuilder.populateAssignedKey(data, annotation, expected, method); assertEquals("", data.getAssignedKey()); expected = InvalidateAssignCache.class; method = "populateAssign02"; annotation = new Mirror().on(AnnotationDataDummy.class).reflect() .annotation(expected) .atMethod(method).withArgs(String.class); try { AnnotationDataBuilder.populateAssignedKey(data, annotation, expected, method); fail("expected exception"); } catch (InvalidParameterException ex) {} assertEquals("", data.getAssignedKey()); expected = InvalidateAssignCache.class; method = "populateAssign03"; annotation = new Mirror().on(AnnotationDataDummy.class).reflect() .annotation(expected) .atMethod(method).withArgs(String.class); try { AnnotationDataBuilder.populateAssignedKey(data, annotation, expected, method); fail("expected exception"); } catch (InvalidParameterException ex) {} assertEquals("", data.getAssignedKey()); expected = InvalidateAssignCache.class; method = "populateAssign04"; annotation = new Mirror().on(AnnotationDataDummy.class).reflect() .annotation(expected) .atMethod(method).withArgs(String.class); AnnotationDataBuilder.populateAssignedKey(data, annotation, expected, method); assertEquals(AnnotationDataDummy.SAMPLE_KEY, data.getAssignedKey()); }