applicationContext = SpringExtension.getApplicationContext(context);
/** * Delegates to {@link TestContextManager#afterTestClass}. */ @Override public void afterAll(ExtensionContext context) throws Exception { try { getTestContextManager(context).afterTestClass(); } finally { getStore(context).remove(context.getRequiredTestClass()); } }
/** * Delegates to {@link TestContextManager#beforeTestClass}. */ @Override public void beforeAll(ExtensionContext context) throws Exception { getTestContextManager(context).beforeTestClass(); }
/** * Get the {@link TestContextManager} associated with the supplied {@code ExtensionContext}. * @return the {@code TestContextManager} (never {@code null}) */ private static TestContextManager getTestContextManager(ExtensionContext context) { Assert.notNull(context, "ExtensionContext must not be null"); Class<?> testClass = context.getRequiredTestClass(); Store store = getStore(context); return store.getOrComputeIfAbsent(testClass, TestContextManager::new, TestContextManager.class); }
@Override public void afterEach(ExtensionContext context) throws Exception { mockitoEndpointExtension.afterEach(context); springExtension.afterEach(context); }
@Override public void afterAll(ExtensionContext context) throws Exception { mockitoEndpointExtension.afterAll(context); springExtension.afterAll(context); }
/** * Delegates to {@link TestContextManager#prepareTestInstance}. */ @Override public void postProcessTestInstance(Object testInstance, ExtensionContext context) throws Exception { getTestContextManager(context).prepareTestInstance(testInstance); }
/** * Get the {@link TestContextManager} associated with the supplied {@code ExtensionContext}. * @return the {@code TestContextManager} (never {@code null}) */ private static TestContextManager getTestContextManager(ExtensionContext context) { Assert.notNull(context, "ExtensionContext must not be null"); Class<?> testClass = context.getRequiredTestClass(); Store store = getStore(context); return store.getOrComputeIfAbsent(testClass, TestContextManager::new, TestContextManager.class); }
/** * Resolve a value for the {@link Parameter} in the supplied {@link ParameterContext} by * retrieving the corresponding dependency from the test's {@link ApplicationContext}. * <p>Delegates to {@link ParameterAutowireUtils#resolveDependency}. * @see #supportsParameter * @see ParameterAutowireUtils#resolveDependency */ @Override @Nullable public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) { Parameter parameter = parameterContext.getParameter(); int index = parameterContext.getIndex(); Class<?> testClass = extensionContext.getRequiredTestClass(); ApplicationContext applicationContext = getApplicationContext(extensionContext); return ParameterAutowireUtils.resolveDependency(parameter, index, testClass, applicationContext); }
/** * Get the {@link ApplicationContext} associated with the supplied {@code ExtensionContext}. * @param context the current {@code ExtensionContext} (never {@code null}) * @return the application context * @throws IllegalStateException if an error occurs while retrieving the application context * @see org.springframework.test.context.TestContext#getApplicationContext() */ public static ApplicationContext getApplicationContext(ExtensionContext context) { return getTestContextManager(context).getTestContext().getApplicationContext(); }
/** * Delegates to {@link TestContextManager#afterTestClass}. */ @Override public void afterAll(ExtensionContext context) throws Exception { try { getTestContextManager(context).afterTestClass(); } finally { getStore(context).remove(context.getRequiredTestClass()); } }
/** * Get the {@link TestContextManager} associated with the supplied {@code ExtensionContext}. * @return the {@code TestContextManager} (never {@code null}) */ private static TestContextManager getTestContextManager(ExtensionContext context) { Assert.notNull(context, "ExtensionContext must not be null"); Class<?> testClass = context.getRequiredTestClass(); Store store = getStore(context); return store.getOrComputeIfAbsent(testClass, TestContextManager::new, TestContextManager.class); }
@Override public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException { ApplicationContext applicationContext = SpringExtension.getApplicationContext(extensionContext); ZoneSeeder zoneSeeder = new ZoneSeeder(applicationContext); zoneSeeders.add(zoneSeeder); return zoneSeeder; }
/** * Delegates to {@link TestContextManager#beforeTestExecution}. */ @Override public void beforeTestExecution(ExtensionContext context) throws Exception { Object testInstance = context.getRequiredTestInstance(); Method testMethod = context.getRequiredTestMethod(); getTestContextManager(context).beforeTestExecution(testInstance, testMethod); }
/** * Delegates to {@link TestContextManager#afterTestClass}. */ @Override public void afterAll(ExtensionContext context) throws Exception { try { getTestContextManager(context).afterTestClass(); } finally { getStore(context).remove(context.getRequiredTestClass()); } }
/** * Get the {@link TestContextManager} associated with the supplied {@code ExtensionContext}. * @return the {@code TestContextManager} (never {@code null}) */ private static TestContextManager getTestContextManager(ExtensionContext context) { Assert.notNull(context, "ExtensionContext must not be null"); Class<?> testClass = context.getRequiredTestClass(); Store store = getStore(context); return store.getOrComputeIfAbsent(testClass, TestContextManager::new, TestContextManager.class); }
@Override protected DmnEngine createDmnEngine(ExtensionContext context) { return SpringExtension.getApplicationContext(context).getBean(DmnEngine.class); }
/** * Delegates to {@link TestContextManager#afterTestExecution}. */ @Override public void afterTestExecution(ExtensionContext context) throws Exception { Object testInstance = context.getRequiredTestInstance(); Method testMethod = context.getRequiredTestMethod(); Throwable testException = context.getExecutionException().orElse(null); getTestContextManager(context).afterTestExecution(testInstance, testMethod, testException); }
/** * Delegates to {@link TestContextManager#afterTestClass}. */ @Override public void afterAll(ExtensionContext context) throws Exception { try { getTestContextManager(context).afterTestClass(); } finally { getStore(context).remove(context.getRequiredTestClass()); } }
@Override protected CmmnEngine createCmmnEngine(ExtensionContext context) { return SpringExtension.getApplicationContext(context).getBean(CmmnEngine.class); }