@Override public void afterEach(ExtensionContext extensionContext) throws Exception { final Object testInstance = extensionContext.getTestInstance() .orElseThrow(() -> new IllegalStateException("Unable to get the current test instance")); try { for (Field member : findAnnotatedFields(testInstance.getClass(), false)) { ((DropwizardExtension) ReflectionUtils.makeAccessible(member).get(testInstance)).after(); } } catch (Throwable e) { throw new RuntimeException(e); } }
@Override public void beforeEach(ExtensionContext extensionContext) throws Exception { final Object testInstance = extensionContext.getTestInstance() .orElseThrow(() -> new IllegalStateException("Unable to get the current test instance")); try { for (Field member : findAnnotatedFields(testInstance.getClass(), false)) { ((DropwizardExtension) ReflectionUtils.makeAccessible(member).get(testInstance)).before(); } } catch (Throwable e) { throw new RuntimeException(e); } } }
@Override public void afterAll(ExtensionContext extensionContext) throws Exception { try { for (Field member : findAnnotatedFields(extensionContext.getRequiredTestClass(), true)) { ((DropwizardExtension) ReflectionUtils.makeAccessible(member).get(null)).after(); } } catch (Throwable e) { throw new RuntimeException(e); } }
@Override public void beforeAll(ExtensionContext extensionContext) throws Exception { try { for (Field member : findAnnotatedFields(extensionContext.getRequiredTestClass(), true)) { ((DropwizardExtension) ReflectionUtils.makeAccessible(member).get(null)).before(); } } catch (Throwable e) { throw new RuntimeException(e); } }
private void injectFields(ExtensionContext context, Object testInstance, Predicate<Field> predicate) { findAnnotatedFields(context.getRequiredTestClass(), TempDir.class, predicate).forEach(field -> { assertValidFieldCandidate(field); try { makeAccessible(field).set(testInstance, getPathOrFile(field.getType(), context)); } catch (Throwable t) { ExceptionUtils.throwAsUncheckedException(t); } }); }
private static TestRule retrieveTestRule(Object testInstance, Field field) { try { return (TestRule) makeAccessible(field).get(testInstance); } catch (IllegalAccessException exception) { throw ExceptionUtils.throwAsUncheckedException(exception); } }
@Override public void afterEach(ExtensionContext extensionContext) throws Exception { final Object testInstance = extensionContext.getTestInstance() .orElseThrow(() -> new IllegalStateException("Unable to get the current test instance")); try { for (Field member : findAnnotatedFields(testInstance.getClass(), false)) { ((DropwizardExtension) ReflectionUtils.makeAccessible(member).get(testInstance)).after(); } } catch (Throwable e) { throw new RuntimeException(e); } }
@Override public void beforeEach(ExtensionContext extensionContext) throws Exception { final Object testInstance = extensionContext.getTestInstance() .orElseThrow(() -> new IllegalStateException("Unable to get the current test instance")); try { for (Field member : findAnnotatedFields(testInstance.getClass(), false)) { ((DropwizardExtension) ReflectionUtils.makeAccessible(member).get(testInstance)).before(); } } catch (Throwable e) { throw new RuntimeException(e); } } }
@Override public void beforeAll(ExtensionContext extensionContext) throws Exception { try { for (Field member : findAnnotatedFields(extensionContext.getRequiredTestClass(), true)) { ((DropwizardExtension) ReflectionUtils.makeAccessible(member).get(null)).before(); } } catch (Throwable e) { throw new RuntimeException(e); } }
@Override public void afterAll(ExtensionContext extensionContext) throws Exception { try { for (Field member : findAnnotatedFields(extensionContext.getRequiredTestClass(), true)) { ((DropwizardExtension) ReflectionUtils.makeAccessible(member).get(null)).after(); } } catch (Throwable e) { throw new RuntimeException(e); } }