### Question:
AnnotationDataBuilder { static void populateExpiration(final AnnotationData data, final Annotation annotation, final Class expectedAnnotationClass, final String targetMethodName) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { if (!INVALIDATES.contains(expectedAnnotationClass)) { final Method expirationMethod = expectedAnnotationClass.getDeclaredMethod("expiration", null); final int expiration = (Integer) expirationMethod.invoke(annotation, null); if (expiration < 0) { throw new InvalidParameterException(String.format( "Expiration for annotation [%s] must be 0 or greater on [%s]", expectedAnnotationClass.getName(), targetMethodName )); } data.setExpiration(expiration); } }    }### Answer:
@Test public void testPopulateExpiration() throws Exception { final AnnotationData data = new AnnotationData(); Class expected; String method; Annotation annotation; expected = InvalidateAssignCache.class; method = "populateExpiration01"; annotation = new Mirror().on(AnnotationDataDummy.class).reflect() .annotation(expected) .atMethod(method).withArgs(String.class); AnnotationDataBuilder.populateExpiration(data, annotation, expected, method); assertEquals(0, data.getExpiration()); expected = UpdateAssignCache.class; method = "populateExpiration02"; annotation = new Mirror().on(AnnotationDataDummy.class).reflect() .annotation(expected) .atMethod(method).withArgs(String.class); try { AnnotationDataBuilder.populateExpiration(data, annotation, expected, method); fail("expected exception"); } catch (InvalidParameterException ex) {} assertEquals(0, data.getExpiration()); expected = UpdateAssignCache.class; method = "populateExpiration03"; annotation = new Mirror().on(AnnotationDataDummy.class).reflect() .annotation(expected) .atMethod(method).withArgs(String.class); AnnotationDataBuilder.populateExpiration(data, annotation, expected, method); assertEquals(AnnotationDataDummy.SAMPLE_EXP, data.getExpiration()); }