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 aConsumer
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
Constructors Constructor Description ExceptionVerifier()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.junit.runners.model.Statement
apply(org.junit.runners.model.Statement base, org.junit.runner.Description description)
void
assertWith(Consumer<T> consumer)
-
-
-
Constructor Detail
-
ExceptionVerifier
public ExceptionVerifier()
-
-
Method Detail
-
assertWith
public void assertWith(Consumer<T> consumer)
-
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
-
-