JpaUnitFixture extends FixtureInstance { @Override public void afterSpecification() { try { executor.processAfterAll(invocation); } catch (final Exception e) { throw new JpaUnitException(e); } super.afterSpecification(); } JpaUnitFixture(final DecoratorExecutor executor, final Object fixtureObject); @Override void beforeSpecification(); @Override void afterSpecification(); @Override String getSpecificationDescription();  }
@Test public void testAfterSpecificationCallsProcessAfterAllOnExecutorWithOriginalClassAndCorrespondingExecutor() throws Exception { fixture.afterSpecification(); final ArgumentCaptor<TestInvocation> invocationCaptor = ArgumentCaptor.forClass(TestInvocation.class); verify(executor).processAfterAll(invocationCaptor.capture()); final TestInvocation invocation = invocationCaptor.getValue(); assertThat(invocation.getTestClass(), equalTo(TestClass.class)); assertThat(invocation.getContext(), equalTo(ctx)); assertThat(invocation.getFeatureResolver(), notNullValue()); }
@Test public void testAfterSpecificationThrowsJpaUnitExceptionIfAnyExceptionIsThrown() throws Exception { final Exception exception = new Exception("error"); doThrow(exception).when(executor).processAfterAll(any(TestInvocation.class)); try { fixture.afterSpecification(); fail("JpaUnitException is expected"); } catch (final JpaUnitException e) { assertThat(e.getCause(), equalTo(exception)); } }