Search in sources :

Example 1 with ResponseLocator

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));
}
Also used : DefaultResponseLocator(org.talend.sdk.component.junit.http.internal.impl.DefaultResponseLocator) ResponseLocator(org.talend.sdk.component.junit.http.api.ResponseLocator) DefaultResponseLocator(org.talend.sdk.component.junit.http.internal.impl.DefaultResponseLocator)

Example 2 with ResponseLocator

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());
                    }
                }
            }
        }
    };
}
Also used : DefaultResponseLocator(org.talend.sdk.component.junit.http.internal.impl.DefaultResponseLocator) Statement(org.junit.runners.model.Statement) DefaultResponseLocator(org.talend.sdk.component.junit.http.internal.impl.DefaultResponseLocator) ResponseLocator(org.talend.sdk.component.junit.http.api.ResponseLocator)

Aggregations

ResponseLocator (org.talend.sdk.component.junit.http.api.ResponseLocator)2 DefaultResponseLocator (org.talend.sdk.component.junit.http.internal.impl.DefaultResponseLocator)2 Statement (org.junit.runners.model.Statement)1