### Question:
AnnotationDataBuilder { static void populateDataIndexFromAnnotations(final AnnotationData data, final Class expectedAnnotationClass, final Method targetMethod) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { if (!UPDATES.contains(expectedAnnotationClass)) { return; } final ReturnDataUpdateContent returnAnnotation = targetMethod.getAnnotation(ReturnDataUpdateContent.class); if (returnAnnotation != null) { data.setDataIndex(-1); return; } final Annotation[][] paramAnnotationArrays = targetMethod.getParameterAnnotations(); int foundIndex = Integer.MIN_VALUE; if (paramAnnotationArrays != null && paramAnnotationArrays.length > 0) { for (int ix = 0; ix < paramAnnotationArrays.length; ix++) { final Annotation[] paramAnnotations = paramAnnotationArrays[ix]; if (paramAnnotations != null && paramAnnotations.length > 0) { for (int jx = 0; jx < paramAnnotations.length; jx++) { final Annotation paramAnnotation = paramAnnotations[jx]; if (ParameterDataUpdateContent.class.equals(paramAnnotation.annotationType())) { if (foundIndex >= 0) { throw new InvalidParameterException(String.format( "Multiple annotations of type [%s] found on method [%s]", ParameterDataUpdateContent.class.getName(), targetMethod.getName() )); } foundIndex = ix; } } } } } if (foundIndex < 0) { throw new InvalidParameterException(String.format( "No KeyProvider annotation found method [%s]", targetMethod.getName() )); } data.setDataIndex(foundIndex); }    }### Answer:
@Test public void testPopulateDataIndex() throws Exception { final AnnotationData data = new AnnotationData(); Class expected = InvalidateAssignCache.class; Method targetMethod = null; AnnotationDataBuilder.populateDataIndexFromAnnotations(data, expected, null); assertEquals(AnnotationData.DEFAULT_INTEGER, data.getDataIndex()); expected = UpdateAssignCache.class; targetMethod = new Mirror().on(AnnotationDataDummy.class).reflect() .method("populateData01").withArgs(String.class); try { AnnotationDataBuilder.populateDataIndexFromAnnotations(data, expected, targetMethod); fail("expected exception"); } catch (InvalidParameterException ex) {} assertEquals(AnnotationData.DEFAULT_INTEGER, data.getDataIndex()); expected = UpdateAssignCache.class; targetMethod = new Mirror().on(AnnotationDataDummy.class).reflect() .method("populateData02").withArgs(String.class, String.class); try { AnnotationDataBuilder.populateDataIndexFromAnnotations(data, expected, targetMethod); fail("expected exception"); } catch (InvalidParameterException ex) {} assertEquals(AnnotationData.DEFAULT_INTEGER, data.getDataIndex()); expected = UpdateAssignCache.class; targetMethod = new Mirror().on(AnnotationDataDummy.class).reflect() .method("populateData03").withArgs(String.class); AnnotationDataBuilder.populateDataIndexFromAnnotations(data, expected, targetMethod); assertEquals(-1, data.getDataIndex()); expected = UpdateAssignCache.class; targetMethod = new Mirror().on(AnnotationDataDummy.class).reflect() .method("populateData04").withArgs(String.class, String.class); AnnotationDataBuilder.populateDataIndexFromAnnotations(data, expected, targetMethod); assertEquals(1, data.getDataIndex()); }