use of au.com.dius.pact.provider.junit.target.Target in project pact-jvm by DiUS.
the class InteractionRunner method interactionBlock.
protected Statement interactionBlock(final Interaction interaction) {
//1. prepare object
//2. get Target
//3. run Rule`s
//4. run Before`s
//5. run OnStateChange`s
//6. run test
//7. run After`s
final Object test;
try {
test = new ReflectiveCallable() {
@Override
protected Object runReflectiveCall() throws Throwable {
return createTest();
}
}.run();
} catch (Throwable e) {
return new Fail(e);
}
final Target target = testClass.getAnnotatedFieldValues(test, TestTarget.class, Target.class).get(0);
if (target instanceof TestClassAwareTarget) {
((TestClassAwareTarget) target).setTestClass(testClass, test);
}
Statement statement = new Statement() {
@Override
public void evaluate() throws Throwable {
target.testInteraction(pact.getConsumer().getName(), interaction);
}
};
statement = withStateChanges(interaction, test, statement);
statement = withBefores(interaction, test, statement);
statement = withRules(interaction, test, statement);
statement = withAfters(interaction, test, statement);
return statement;
}
Aggregations