Package net.sf.parteg.base.testcasegraph.testgoals

Examples of net.sf.parteg.base.testcasegraph.testgoals.TestGoalGuardConditions


      new HashMap<TestGoalBase, Double>();
    // measure branching factor
    for(TestGoalBase oTestGoal : io_colGoals) {
      Double nAtomNumber = 0.0;
      if(oTestGoal instanceof TestGoalGuardConditions) {
        TestGoalGuardConditions oGoalGuard = (TestGoalGuardConditions)oTestGoal;
        nAtomNumber = 0.0;
       
        // collect branching factor of transition's target node
        if(!oGoalGuard.getDNFToBeSatisfied().getConjunctions().isEmpty()) {
          for(TCGConjunction oConjunction : oGoalGuard.getDNFToBeSatisfied().getConjunctions()) {
            Integer nLocalAtomNumber = oConjunction.getExpressions().size();
            nAtomNumber += nLocalAtomNumber;
          }
          nAtomNumber /= Double.valueOf(
              (double)oGoalGuard.getDNFToBeSatisfied().getConjunctions().size());
        }
      }
      oTestGoal.setPriority(nAtomNumber);
      colGoalsAtomNumber.put(oTestGoal, nAtomNumber);
    }
View Full Code Here


      new HashMap<TestGoalBase, Double>();
    // measure branching factor
    for(TestGoalBase oTestGoal : io_colGoals) {
      Double nAtomNumber = 0.0;
      if(oTestGoal instanceof TestGoalGuardConditions) {
        TestGoalGuardConditions oGoalGuard = (TestGoalGuardConditions)oTestGoal;
        nAtomNumber = 0.0;
       
        // collect branching factor of transition's target node
        if(!oGoalGuard.getDNFToBeSatisfied().getConjunctions().isEmpty()) {
          for(TCGConjunction oConjunction : oGoalGuard.getDNFToBeSatisfied().getConjunctions()) {
            Double nLocalAtomNumber = Double.valueOf((double)oConjunction.getExpressions().size());
            Double nNumberOfPositives = 0.0;
            for(TCGOCLExpression oExp : oConjunction.getExpressions()) {
              if(oExp.isPositiveAssignmentOfOriginal())
                ++nNumberOfPositives;
            }
            nAtomNumber += nNumberOfPositives / nLocalAtomNumber;
          }
          nAtomNumber /= Double.valueOf(
              (double)oGoalGuard.getDNFToBeSatisfied().getConjunctions().size());
        }
      }
      oTestGoal.setPriority(nAtomNumber);
      colGoalsAtomNumber.put(oTestGoal, nAtomNumber);
    }
View Full Code Here

      new HashMap<TestGoalBase, Double>();
    // measure branching factor
    for(TestGoalBase oTestGoal : io_colGoals) {
      Double nBranchingFactor = 1.0;
      if(oTestGoal instanceof TestGoalGuardConditions) {
        TestGoalGuardConditions oGoalGuard = (TestGoalGuardConditions)oTestGoal;
        nBranchingFactor = 0.0;
        TCGNode oBranchingNode = (TCGNode)oGoalGuard.getElement();
       
        // collect branching factor of transition's target node
        if(oGoalGuard.getDNFToBeSatisfied().getConjunctions().isEmpty()) {
          List<TCGTransition> colTransitions = TCGTransitionHelperClass.findResultingTransitions(
              oBranchingNode, oGoalGuard.getEventToBeCalled(), null);
          if(!colTransitions.isEmpty()) {
            oBranchingNode = colTransitions.get(0).getTargetNode();
          }
          nBranchingFactor = getBranchingFactor(oBranchingNode);
        }
        else {
          for(TCGConjunction oConjunction : oGoalGuard.getDNFToBeSatisfied().getConjunctions()) {
            oBranchingNode = (TCGNode)oGoalGuard.getElement();
            List<TCGTransition> colTransitions = TCGTransitionHelperClass.findResultingTransitions(
                oBranchingNode, oGoalGuard.getEventToBeCalled(), oConjunction);
            if(!colTransitions.isEmpty()) {
              oBranchingNode = colTransitions.get(0).getTargetNode();
            }
            Double nBranching = getBranchingFactor(oBranchingNode);
            nBranchingFactor += nBranching;
          }
          nBranchingFactor /= Double.valueOf(
              (double)oGoalGuard.getDNFToBeSatisfied().getConjunctions().size());
        }
      }
      else {
        TCGNode oBranchingNode = (TCGNode)oTestGoal.getElement();
        nBranchingFactor = getBranchingFactor(oBranchingNode);
View Full Code Here

        // create temporary modification of the original test goal
        TCGDisjunctiveNormalForm oModifiedDNF =
          GeneratedFactory.eINSTANCE.createTCGDisjunctiveNormalForm();
        if(in_oConjunction != null)
          oModifiedDNF.getConjunctions().add(in_oConjunction);
        TestGoalGuardConditions oModifiedTestGoal =
          new TestGoalGuardConditions(in_oNode, in_oEventToBeTriggered,
              oModifiedDNF);
        m_oTestCaseRunnerState.getTestGoalsToSatisfy().add(oModifiedTestGoal);
      }
     
      // search backwards
View Full Code Here

      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);
        }
View Full Code Here

    {
      if(oTestGoalFromSet.getElement().equals(in_oTestGoal.getElement()))
      {
        if(oTestGoalFromSet instanceof TestGoalGuardConditions)
        {
          TestGoalGuardConditions oTestGoalEventFromSet = (TestGoalGuardConditions)oTestGoalFromSet;
         
          if(TCGEventHelperClass.eventsAreEqual(
              in_oTestGoal.getEventToBeCalled(),
              oTestGoalEventFromSet.getEventToBeCalled()) &&
            TCGDisjunctiveNormalFormHelperClass.firstDNFIsSatisfiedBySecondDNF(
              in_oTestGoal.getDNFToBeSatisfied(),
              oTestGoalEventFromSet.getDNFToBeSatisfied(),
              in_bBoundariesMatchExactly))
          {
            return true;
          }
        }
View Full Code Here

        in_oLogger.getFormattedOutput().appendln(in_sPrefix + " (test goal #" + in_nTestGoalNumber + " - node) ");
        in_oLogger.getFormattedOutput().appendln("   reach state " + oNodeGoal.getName());
      }
    }
    else if(in_oTestGoal instanceof TestGoalGuardConditions) {
      TestGoalGuardConditions oTestGoalGuard = (TestGoalGuardConditions)in_oTestGoal;
      if(oTestGoalGuard.getElement() instanceof TCGNode) {
        if(oTestGoalGuard.getNecessaryTransitionToTraverse() != null) {
          TCGTransition oTransition = oTestGoalGuard.getNecessaryTransitionToTraverse();
          in_oLogger.getFormattedOutput().appendln(in_sPrefix + " (test goal #" + in_nTestGoalNumber + " - traversed transition) ");
          in_oLogger.getFormattedOutput().appendln("   from node " + oTransition.getSourceNode().getName());
          in_oLogger.getFormattedOutput().appendln("   to node " + oTransition.getTargetNode().getName());
          for(TCGEvent oEvent : oTransition.getEvents()) {
            in_oLogger.getFormattedOutput().appendln("   triggered by " + oEvent.getName());
          }
        }
        else {
          in_oLogger.getFormattedOutput().appendln(in_sPrefix + " (test goal #" + in_nTestGoalNumber + " - satisfied guard) ");
          in_oLogger.getFormattedOutput().appendln("   from node " + ((TCGNode)oTestGoalGuard.getElement()).getName());
          if(oTestGoalGuard.getEventToBeCalled() != null)
            in_oLogger.getFormattedOutput().appendln("   call event " + oTestGoalGuard.getEventToBeCalled().getName());
        }
        String sCondition = TCGDisjunctiveNormalFormHelperClass.toString(oTestGoalGuard.getDNFToBeSatisfied());
        if(!sCondition.isEmpty())
          in_oLogger.getFormattedOutput().appendln("   with condition " + sCondition);
      }
    }   
  }
View Full Code Here

TOP

Related Classes of net.sf.parteg.base.testcasegraph.testgoals.TestGoalGuardConditions

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.