Package org.talend.sdk.component.junit
Class ExceptionVerifier<T extends RuntimeException>
java.lang.Object
org.talend.sdk.component.junit.ExceptionVerifier<T>
- All Implemented Interfaces:
org.junit.rules.TestRule
public class ExceptionVerifier<T extends RuntimeException>
extends Object
implements org.junit.rules.TestRule
A rule to access an exception from a test using a
Consumer
Usage example :
Rule public ExceptionVerifier<HttpException> httpExceptionRule = new ExceptionVerifier<>();
@Test
public void test(){
httpExceptionRule.assertWith(e -> {
assertEquals(401, e.getResponse().status());
assertEquals("expected error message", e.getResponse().error(String.class));
});
}
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionorg.junit.runners.model.Statement
apply
(org.junit.runners.model.Statement base, org.junit.runner.Description description) void
assertWith
(Consumer<T> consumer)
-
Constructor Details
-
ExceptionVerifier
public ExceptionVerifier()
-
-
Method Details
-
assertWith
-
apply
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description) - Specified by:
apply
in interfaceorg.junit.rules.TestRule
-