Class UseCaseTest<I,O>

java.lang.Object
com.guinetik.hexafun.testing.UseCaseTest<I,O>
Type Parameters:
I - The input type of the use case
O - The output type of the use case

public class UseCaseTest<I,O> extends Object
A fluent API for testing HexaFun use cases.
  • Method Details

    • with

      public UseCaseTest<I,O> with(I input)
      Specify the input for the use case.
      Parameters:
      input - The input to provide to the use case
      Returns:
      This test instance
    • expectOk

      public UseCaseTest<I,O> expectOk(Consumer<O> verifier)
      Execute the use case and verify the result is successful.
      Parameters:
      verifier - A consumer that receives the result for verification
      Returns:
      This test instance
    • expectFailure

      public UseCaseTest<I,O> expectFailure(Consumer<String> errorVerifier)
      Execute the use case and verify the result is a failure.
      Parameters:
      errorVerifier - A consumer that receives the error message for verification
      Returns:
      This test instance
    • expect

      public UseCaseTest<I,O> expect(Predicate<O> predicate, String description)
      Execute the use case and verify the result matches a predicate.
      Parameters:
      predicate - A predicate to test the result
      description - Description of what the predicate checks
      Returns:
      This test instance
    • expectException

      public UseCaseTest<I,O> expectException(Class<? extends Exception> exceptionClass)
      Execute the use case and verify it throws a specific exception.
      Parameters:
      exceptionClass - Expected exception class
      Returns:
      This test instance
    • map

      public <T> UseCaseTest<I,T> map(Function<O,T> mapper)
      Map the result using a transformer function for further verification.
      Type Parameters:
      T - Target type
      Parameters:
      mapper - Function to transform the result
      Returns:
      A new test instance with the transformed result