@Test public void testSelectTransition_notDoneButNoNextState () { DirectedGraph mainGraph = new DirectedGraphImpl ("main graph"); State startState = mainGraph.addState ("start state"); RandomTransitionSelector selector = new RandomTransitionSelector (mainGraph, null, null); try { selector.selectTransition (mainGraph, startState); fail ("no exception"); } catch (ExecutionException ee) { } }
@Override public Transition selectTransition (DirectedGraph graph, State currentState) { boolean isMainGraph = graph.equals (mMainGraph); boolean atEndState = false; if (isMainGraph) { if (currentState.mLabel.equalsIgnoreCase (Model.END_STATE_LABEL)) { atEndState = true; } } else { if (graph.getTransitions (currentState).isEmpty ()) { return null; } } Set<Transition> remainingTransitions = new HashSet<Transition> (graph.getTransitions (currentState)); while (!remainingTransitions.isEmpty ()) { Transition transition = removeRandomTransition (remainingTransitions); if (conditionNoProblem (transition)) { return transition; } } if (atEndState) { return graph.addTransition (currentState, graph.getBeginState ()); } else { throw new ExecutionException ("no transitions out of end node '%s'", currentState.getName ()); } }
RandomTransitionSelector implements TransitionSelectionStrategy { @Override public Transition selectTransition (DirectedGraph graph, State currentState) { boolean isMainGraph = graph.equals (mMainGraph); boolean atEndState = false; if (isMainGraph) { if (currentState.mLabel.equalsIgnoreCase (Model.END_STATE_LABEL)) { atEndState = true; } } else { if (graph.getTransitions (currentState).isEmpty ()) { return null; } } Set<Transition> remainingTransitions = new HashSet<Transition> (graph.getTransitions (currentState)); while (!remainingTransitions.isEmpty ()) { Transition transition = removeRandomTransition (remainingTransitions); if (conditionNoProblem (transition)) { return transition; } } if (atEndState) { return graph.addTransition (currentState, graph.getBeginState ()); } else { throw new ExecutionException ("no transitions out of end node '%s'", currentState.getName ()); } } }
RandomTransitionSelector implements TransitionSelectionStrategy { @Override public Transition selectTransition (DirectedGraph graph, State currentState) { boolean isMainGraph = graph.equals (mMainGraph); boolean atEndState = false; if (isMainGraph) { if (currentState.mLabel.equalsIgnoreCase (Model.END_STATE_LABEL)) { atEndState = true; } } else { if (graph.getTransitions (currentState).isEmpty ()) { return null; } } Set<Transition> remainingTransitions = new HashSet<Transition> (graph.getTransitions (currentState)); while (!remainingTransitions.isEmpty ()) { Transition transition = removeRandomTransition (remainingTransitions); if (conditionNoProblem (transition)) { return transition; } } if (atEndState) { return graph.addTransition (currentState, graph.getBeginState ()); } else { throw new ExecutionException ("no transitions out of end node '%s'", currentState.getName ()); } } RandomTransitionSelector(DirectedGraph mainGraph, RunTime runTime, RandomNumberGenerator numberGenerator); }
RandomTransitionSelector implements TransitionSelectionStrategy { @Override public Transition selectTransition (DirectedGraph graph, State currentState) { boolean isMainGraph = graph.equals (mMainGraph); boolean atEndState = false; if (isMainGraph) { if (currentState.mLabel.equalsIgnoreCase (Model.END_STATE_LABEL)) { atEndState = true; } } else { if (graph.getTransitions (currentState).isEmpty ()) { return null; } } Set<Transition> remainingTransitions = new HashSet<Transition> (graph.getTransitions (currentState)); while (!remainingTransitions.isEmpty ()) { Transition transition = removeRandomTransition (remainingTransitions); if (conditionNoProblem (transition)) { return transition; } } if (atEndState) { return graph.addTransition (currentState, graph.getBeginState ()); } else { throw new ExecutionException ("no transitions out of end node '%s'", currentState.getName ()); } } RandomTransitionSelector(DirectedGraph mainGraph, RunTime runTime, RandomNumberGenerator numberGenerator); @Override String getDescription(); @Override Transition selectTransition(DirectedGraph graph, State currentState); }
RandomTransitionSelector implements TransitionSelectionStrategy { @Override public Transition selectTransition (DirectedGraph graph, State currentState) { boolean isMainGraph = graph.equals (mMainGraph); boolean atEndState = false; if (isMainGraph) { if (currentState.mLabel.equalsIgnoreCase (Model.END_STATE_LABEL)) { atEndState = true; } } else { if (graph.getTransitions (currentState).isEmpty ()) { return null; } } Set<Transition> remainingTransitions = new HashSet<Transition> (graph.getTransitions (currentState)); while (!remainingTransitions.isEmpty ()) { Transition transition = removeRandomTransition (remainingTransitions); if (conditionNoProblem (transition)) { return transition; } } if (atEndState) { return graph.addTransition (currentState, graph.getBeginState ()); } else { throw new ExecutionException ("no transitions out of end node '%s'", currentState.getName ()); } } RandomTransitionSelector(DirectedGraph mainGraph, RunTime runTime, RandomNumberGenerator numberGenerator); @Override String getDescription(); @Override Transition selectTransition(DirectedGraph graph, State currentState);  }