Class ATestCase<T,R,STATE extends ATestCaseState<T>,RESULT extends ATestCaseResult<R>>

java.lang.Object
io.github.imagineDevit.giwt.core.CloseableCase
io.github.imagineDevit.giwt.core.ATestCase<T,R,STATE,RESULT>
Type Parameters:
T -
R -

public abstract class ATestCase<T,R,STATE extends ATestCaseState<T>,RESULT extends ATestCaseResult<R>> extends CloseableCase
Test case abstract class.
Since:
0.0.1
Author:
Henri Joel SEDJAME
  • Field Details

  • Constructor Details

  • Method Details

    • given

      public <TC extends ATestCase<T, R, STATE, RESULT>> AGivenStmt<T,R,STATE,RESULT,TC> given(String message, GivenSFn<T> fn)
      Creates a new Given statement with the provided message and (supplier) function.
      Parameters:
      message - the description of the statement being given
      fn - the function that executes the given statement
      Returns:
      the Given statement object
    • given

      public <TC extends ATestCase<T, R, STATE, RESULT>> AGivenStmt<T,R,STATE,RESULT,TC> given(String message, T t)
    • given

      public <TC extends ATestCase<T, R, STATE, RESULT>> AGivenStmt<T,R,STATE,RESULT,TC> given(String message, GivenRFn fn)
      Creates a new Given statement with the provided message and (runnable) function.
      Parameters:
      message - the description of the statement being given
      fn - the function that executes the given statement
      Returns:
      the Given statement object
    • when

      public <TC extends ATestCase<T, R, STATE, RESULT>> AWhenStmt<T,R,STATE,RESULT,TC> when(String message, WhenSFn<R> fn)
      Adds a When statement to the current test case with the provided message and a supplier function.
      Parameters:
      message - the description of the new When statement
      fn - the function that executes the When statement
      Returns:
      a new instance of WhenStmt that is associated with this test case
    • when

      public <TC extends ATestCase<T, R, STATE, RESULT>> AWhenStmt<T,R,STATE,RESULT,TC> when(String message, WhenRFn fn)
      Adds a When statement to the current test case with the provided message and a runnable function
      Parameters:
      message - the description of the new When statement
      fn - the function that executes the When statement
      Returns:
      a new instance of WhenStmt that is associated with this test case
    • andGiven

      protected void andGiven(String message, GivenFFn<T,STATE> fn)
      Adds another Given statement to the current test case with the provided message and function.
      Parameters:
      message - the description of the new Given statement
      fn - the function that executes the given statement
    • when

      protected <TC extends ATestCase<T, R, STATE, RESULT>> AWhenStmt<T,R,STATE,RESULT,TC> when(String message, WhenFFn<T,R> fn)
      Adds a When statement to the current test case with the provided message and a function.
      Parameters:
      message - the description of the new When statement
      fn - the function that executes the When statement and returns a result of type R
      Returns:
      a new instance of WhenStmt that is associated with this test case
    • whenc

      protected <TC extends ATestCase<T, R, STATE, RESULT>> AWhenStmt<T,R,STATE,RESULT,TC> whenc(String message, WhenCFn<T> fn)
      Adds a When statement to the current test case with the provided message and a runnable function
      Parameters:
      message - the description of the new When statement
      fn - the function that executes the When statement
      Returns:
      a new instance of WhenStmt that is associated with this test case
    • whenr

      protected <TC extends ATestCase<T, R, STATE, RESULT>> AWhenStmt<T,R,STATE,RESULT,TC> whenr(String message, WhenRFn fn)
      Adds a When statement to the current test case with the provided message and a function.
      Parameters:
      message - the description of the new When statement
      fn - the function that executes the When statement and returns a result of type R
      Returns:
      a new instance of WhenStmt that is associated with this test case
    • then

      protected <TC extends ATestCase<T, R, STATE, RESULT>> AThenStmt<T,R,STATE,RESULT,TC> then(String message, ThenFn<R,RESULT> fn)
      Adds a Then statement to the current test case with the provided message and a consumer function.
      Parameters:
      message - the description of the new Then statement
      fn - the function that executes the Then statement
      Returns:
      a new instance of ThenStmt that is associated with this test case
    • andThen

      protected void andThen(String message, ThenFn<R,RESULT> fn)
      Adds a then statement to the current test case with the provided message and a consumer function. This method is used in conjunction with the initial ThenStmt method, allowing for multiple Then statements in a single test case.
      Parameters:
      message - the description of the new Then statement
      fn - the function that executes the additional Then statement
    • run

      protected void run()
    • getName

      protected String getName()
      Returns the name of the test case with its relevant parameters formatted. If the test case has parameters, it will format the name using the parameters. If not, it will return the name as is. Note: This method is protected, which means it can only be accessed by classes within the same package or subclasses.
      Returns:
      the formatted name of the test case.
    • stateOf

      protected abstract STATE stateOf(T value)
    • stateToResult

      protected abstract RESULT stateToResult(Function<T,R> mapper)
    • resultOf

      protected abstract RESULT resultOf(R value)
    • resultOfErr

      protected abstract RESULT resultOfErr(Exception e)