Class TestcaseComputationStrategy

java.lang.Object
org.chenile.workflow.testcases.TestcaseComputationStrategy

public class TestcaseComputationStrategy extends Object
Construct a flow without self transitions that goes forward till the last state has no transitions or alternatively has transitions that only go backwards to already visited states.

This class returns multiple test cases each with their own flow. We can use that to construct multiple test scenarios.

  • Field Details

  • Constructor Details

    • TestcaseComputationStrategy

      TestcaseComputationStrategy(STMFlowStore flowStore)
  • Method Details

    • toTestcases

      public List<Testcase> toTestcases(State state)
    • enhance

      private void enhance(List<Testcase> testcases)
      Adds useful information to the test cases such as an ID, first flag etc.
      Parameters:
      testcases - the testcases to enhance
    • cachedComputePaths

      private List<Testcase> cachedComputePaths(State state, Set<State> visitedStates)
    • dropAutoStates

      private List<Testcase> dropAutoStates(List<Testcase> testcases)
      If the test case happens to have auto states they need to be simply dropped from the test case. Store the old steps in allSteps so that consumers who want all the steps inclusive of auto states can access them.
      Parameters:
      testcases - - List of test cases to update
      Returns:
      the altered test cases with the auto states dropped
    • computePaths

      private List<Testcase> computePaths(State state, Set<State> visitedStates)
    • noActivities

      private void noActivities(StateDescriptor sd, State state, List<Testcase> testcaseList, Set<State> visitedStates)
    • addToNext

      private void addToNext(Transition transition, State newState, List<Testcase> testcaseList, Set<State> visitedStates)
      Obtain the next state for the given transition. Get all the testcases that are associated with the next state and then add this transition to each of those. Return the next state transitions with this one added. If no transitions are found for the next state then create a new test case with just this transition in it.
      Parameters:
      transition - the transition for which the next state needs to be obtained
      testcaseList - - an empty list to which the test cases have to be added.
    • computeActivitiesPath

      private void computeActivitiesPath(StateDescriptor sd, List<Testcase> testcaseList, Set<State> visitedStates)
    • process

      private void process(StateDescriptor sd, State state, List<Testcase> testcaseList, Set<State> visitedStates)
    • computeActivitiesWithAutoComputationChecker

      private void computeActivitiesWithAutoComputationChecker(StateDescriptor sd, List<Testcase> testcaseList, AutomaticStateDescriptor asd, Set<State> visitedStates)
      This method computes the path for states that have concurrent activities culminating in an auto state. The auto state will lead to the new state if all the activities are completed.
      Parameters:
      sd - the state descriptor for the start state.
      testcaseList - the test case list that we need to generate.
      asd - - the Automatic state descriptor for the activities. This is a completion checker that leads to the new state.