CitrusDslAnnotations { public static void injectTestDesigner(final Object target, final TestDesigner designer) { ReflectionUtils.doWithFields(target.getClass(), field -> { Class<?> type = field.getType(); if (TestDesigner.class.isAssignableFrom(type)) { log.debug(String.format("Injecting test designer instance on test class field '%s'", field.getName())); ReflectionUtils.setField(field, target, designer); } else { throw new CitrusRuntimeException("Not able to provide a Citrus resource injection for type " + type); } }, field -> { if (field.isAnnotationPresent(CitrusResource.class) && TestDesigner.class.isAssignableFrom(field.getType())) { if (!field.isAccessible()) { ReflectionUtils.makeAccessible(field); } return true; } return false; }); } private  CitrusDslAnnotations(); static void injectTestDesigner(final Object target, final TestDesigner designer); static void injectTestRunner(final Object target, final TestRunner runner);  }
@Test public void testInjectTestDesigner() throws Exception { TestDesignerClient client = new TestDesignerClient(); Assert.assertNull(client.getDesigner()); CitrusDslAnnotations.injectTestDesigner(client, designer); Assert.assertEquals(client.getDesigner(), designer); Assert.assertEquals(client.otherAnnotatedResource, "foo"); Assert.assertNull(client.otherDesigner); }