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<>();
  &#64;Test
  public void test(){
      httpExceptionRule.assertWith(e -> {
          assertEquals(401, e.getResponse().status());
          assertEquals("expected error message", e.getResponse().error(String.class));
      });
  }
 
 
  • Constructor Details

  • Method Details

    • 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 interface org.junit.rules.TestRule