Pair<TCGNode, TCGTransition> in_oPair,
// TCGConjunction in_oPrecondition,
TCGConjunction in_oPostCondition)
{
boolean bFirstTestGoalIsEmptyTransitionSequence = false;
TestGoalGuardConditions oTestGuardGoal = null;
TestGoalTransitionSequence oTestGoalToSatisfySpec = null;
if(!m_oTestCaseRunnerState.getTestGoalsToSatisfy().isEmpty()) {
int nIndexForGuardCondition = 0;
TestGoalBase oTestGoalToSatisfy = m_oTestCaseRunnerState.getTestGoalsToSatisfy().get(0);
if(oTestGoalToSatisfy instanceof TestGoalTransitionSequence) {
nIndexForGuardCondition = 1;
oTestGoalToSatisfySpec =
(TestGoalTransitionSequence)oTestGoalToSatisfy;
if(oTestGoalToSatisfySpec.getTransitionSequence().isEmpty()) {
bFirstTestGoalIsEmptyTransitionSequence = true;
}
}
if(m_oTestCaseRunnerState.getTestGoalsToSatisfy().size() > nIndexForGuardCondition) {
TestGoalBase oSecondGoal =
m_oTestCaseRunnerState.getTestGoalsToSatisfy().get(nIndexForGuardCondition);
if(oSecondGoal instanceof TestGoalGuardConditions) {
oTestGuardGoal = (TestGoalGuardConditions)oSecondGoal;
}
}
}
// 0th case: the only remaining test goal is an empty transition sequence
if(bFirstTestGoalIsEmptyTransitionSequence && oTestGuardGoal == null) {
int nSize = m_oTestCaseRunnerState.getTestGoalsToSatisfy().size();
m_oTestCaseRunnerState.getTestGoalsToSatisfy().remove(
nSize - 1);
searchBackwardForSourceNodeAndTransitionStandard(
in_oPair, in_oPostCondition);
// add used goals again
m_oTestCaseRunnerState.getTestGoalsToSatisfy().add(
oTestGuardGoal);
}
else {
// first case:
// the first goal to satisfy is an empty transition sequence
// the second goal is a guard condition that has to be satisfied
// -> satisfy the guard while traversing the first transition
// -> of the following transition sequence
if(bFirstTestGoalIsEmptyTransitionSequence && oTestGuardGoal != null) {
// TCGConjunction oGuardConjunction = null;
// if(!oTestGuardGoal.getDNFToBeSatisfied().getConjunctions().isEmpty()) {
// oGuardConjunction =
// oTestGuardGoal.getDNFToBeSatisfied().getConjunctions().get(0);
// }
// if(TCGDisjunctiveNormalFormHelperClass.firstConjunctionIsSatisfiedByDNF(
// oGuardConjunction, in_oPair.getSecond().getPrecondition(), false)) {
// remove both guards
int nSize = m_oTestCaseRunnerState.getTestGoalsToSatisfy().size();
m_oTestCaseRunnerState.getTestGoalsToSatisfy().remove(
nSize - 1);
m_oTestCaseRunnerState.getTestGoalsToSatisfy().remove(
nSize - 2);
// searchBackwardsFromEventAndPostcondition(
// in_oPair, oTestGuardGoal.getEventToBeCalled(),
// oGuardConjunction, in_oPostCondition);
searchBackwardForSourceNodeAndTransitionGuardSelection(
in_oPair, oTestGuardGoal.getEventToBeCalled(),
oTestGuardGoal.getDNFToBeSatisfied(), in_oPostCondition);
// add used goals again
m_oTestCaseRunnerState.getTestGoalsToSatisfy().add(
oTestGoalToSatisfySpec);
m_oTestCaseRunnerState.getTestGoalsToSatisfy().add(
oTestGuardGoal);
// }
}
else {
// second case:
// the first goal is a guard condition that has to be violated and
// does not result in a state change
// -> then continue traversing transitions
if(oTestGoalToSatisfySpec == null && oTestGuardGoal != null) {
// the correct target state already has been found while
// initializing the TestCaseGeneratorRunner
// TCGConjunction oGuardConjunction = null;
// if(!oTestGuardGoal.getDNFToBeSatisfied().getConjunctions().isEmpty()) {
// oGuardConjunction =
// oTestGuardGoal.getDNFToBeSatisfied().getConjunctions().get(0);
// }
// // transition source node is equal to test goal element
// //if(in_oPair.getSecond().getSourceNode().equals(oTestGuardGoal.getElement()) ||
// the predefined guard goal to satisfy on the way cannot be satisfied by a transition guard
// if(!TCGDisjunctiveNormalFormHelperClass.firstConjunctionIsSatisfiedByDNF(
// oGuardConjunction, in_oPair.getSecond().getPrecondition(), false)) {
// // we have to pay attention to the case that the violated guard
// // does not result in a state change
in_oPair.setFirst(in_oPair.getSecond().getTargetNode());
in_oPair.setSecond(null);
// }
int nSize = m_oTestCaseRunnerState.getTestGoalsToSatisfy().size();
m_oTestCaseRunnerState.getTestGoalsToSatisfy().remove(
nSize - 1);
// searchBackwardsFromEventAndPostcondition(
// in_oPair, oTestGuardGoal.getEventToBeCalled(),
// oGuardConjunction, in_oPostCondition);
searchBackwardForSourceNodeAndTransitionGuardSelection(
in_oPair, oTestGuardGoal.getEventToBeCalled(),
oTestGuardGoal.getDNFToBeSatisfied(), in_oPostCondition);
// add used goals again
m_oTestCaseRunnerState.getTestGoalsToSatisfy().add(
oTestGuardGoal);
}