Package com.guinetik.hexafun.testing
Class UseCaseTest<I,O>
java.lang.Object
com.guinetik.hexafun.testing.UseCaseTest<I,O>
- Type Parameters:
I- The input type of the use caseO- The output type of the use case
A fluent API for testing HexaFun use cases.
-
Method Summary
Modifier and TypeMethodDescriptionExecute the use case and verify the result matches a predicate.expectException(Class<? extends Exception> exceptionClass) Execute the use case and verify it throws a specific exception.expectFailure(Consumer<String> errorVerifier) Execute the use case and verify the result is a failure.Execute the use case and verify the result is successful.<T> UseCaseTest<I,T> Map the result using a transformer function for further verification.Specify the input for the use case.
-
Method Details
-
with
Specify the input for the use case.- Parameters:
input- The input to provide to the use case- Returns:
- This test instance
-
expectOk
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
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
Execute the use case and verify the result matches a predicate.- Parameters:
predicate- A predicate to test the resultdescription- Description of what the predicate checks- Returns:
- This test instance
-
expectException
Execute the use case and verify it throws a specific exception.- Parameters:
exceptionClass- Expected exception class- Returns:
- This test instance
-
map
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
-