### Question:
AnnotationDataBuilder { static void populateNamespace(final AnnotationData data, final Annotation annotation, final Class expectedAnnotationClass, final String targetMethodName) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { final Method namespaceMethod = expectedAnnotationClass.getDeclaredMethod("namespace", null); final String namespace = (String) namespaceMethod.invoke(annotation, null); if (AnnotationConstants.DEFAULT_STRING.equals(namespace) || namespace == null || namespace.length() < 1) { throw new InvalidParameterException(String.format( "Namespace for annotation [%s] must be defined on [%s]", expectedAnnotationClass.getName(), targetMethodName )); } data.setNamespace(namespace); }    }### Answer:
@Test public void testPopulateNamespace() throws Exception { final AnnotationData data = new AnnotationData(); Class expected; String method; Annotation annotation; expected = InvalidateAssignCache.class; method = "populateNamespace01"; annotation = new Mirror().on(AnnotationDataDummy.class).reflect() .annotation(expected) .atMethod(method).withArgs(String.class); try { AnnotationDataBuilder.populateNamespace(data, annotation, expected, method); fail("expected exception"); } catch (InvalidParameterException ex) {} assertEquals("", data.getNamespace()); expected = InvalidateAssignCache.class; method = "populateNamespace02"; annotation = new Mirror().on(AnnotationDataDummy.class).reflect() .annotation(expected) .atMethod(method).withArgs(String.class); try { AnnotationDataBuilder.populateNamespace(data, annotation, expected, method); fail("expected exception"); } catch (InvalidParameterException ex) {} assertEquals("", data.getNamespace()); expected = InvalidateAssignCache.class; method = "populateNamespace03"; annotation = new Mirror().on(AnnotationDataDummy.class).reflect() .annotation(expected) .atMethod(method).withArgs(String.class); AnnotationDataBuilder.populateNamespace(data, annotation, expected, method); assertEquals(AnnotationDataDummy.SAMPLE_NS, data.getNamespace()); }