use of org.talend.sdk.component.junit.http.api.ResponseLocator in project component-runtime by Talend.
the class JUnit5HttpApi method beforeEach.
@Override
public void beforeEach(final ExtensionContext extensionContext) {
// test name
final ResponseLocator responseLocator = getResponseLocator();
if (!DefaultResponseLocator.class.isInstance(responseLocator)) {
return;
}
DefaultResponseLocator.class.cast(responseLocator).setTest(extensionContext.getTestMethod().map(m -> m.getDeclaringClass().getName() + "_" + m.getName()).orElse(null));
}
use of org.talend.sdk.component.junit.http.api.ResponseLocator in project component-runtime by Talend.
the class JUnit4HttpApiPerMethodConfigurator method apply.
@Override
public Statement apply(final Statement base, final Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
final ResponseLocator responseLocator = server.getResponseLocator();
if (DefaultResponseLocator.class.isInstance(responseLocator)) {
final DefaultResponseLocator defaultResponseLocator = DefaultResponseLocator.class.cast(responseLocator);
defaultResponseLocator.setTest(description.getClassName() + "_" + description.getMethodName());
}
try {
base.evaluate();
} finally {
if (DefaultResponseLocator.class.isInstance(responseLocator)) {
if (Handlers.isActive("capture")) {
final DefaultResponseLocator defaultResponseLocator = DefaultResponseLocator.class.cast(responseLocator);
defaultResponseLocator.flush(Handlers.getBaseCapture());
}
}
}
}
};
}
Aggregations