이것은 오래된 질문이지만이 질문에 답을 얻고 다른 사람들이 답할 수 있다고 생각했습니다. 나는 이것을 단위 테스트의 일부로 사용하고있다. 특정 상태에 도달하는 것이 매우 유용하다. (나는 상태 A에서 사건의 연속이 일어나면 상태 B로 간다. 거기에 내가 상태 기계 XML을 어지러운 후에!)
나는이 코드를 SCXMLTestHelper에서 마침내 발견했다. 집행자와 대상 국가를 호출하십시오.
public static void setCurrentState(SCXMLExecutor exec, final String id) throws IllegalArgumentException{
try {
exec.reset();
} catch (ModelException me) {
throw new IllegalArgumentException("Provided SCXMLExecutor "
+ "instance cannot be reset.");
}
TransitionTarget active = (TransitionTarget) exec.getStateMachine().
getTargets().get(id);
if (active == null) {
throw new IllegalArgumentException("No target with id '" + id
+ "' present in state machine.");
}
Set current = exec.getCurrentStatus().getStates();
current.clear();
current.add(active);
}
좋은 아이디어. 귀중한 의견에 감사드립니다. –