@Test
public void testNFACompilerWithSimplePattern() {

	Pattern<Event, Event> pattern = Pattern.<Event>begin("start").where(startFilter)
		.followedBy("middle").subtype(SubEvent.class)
		.next("end").where(endFilter);
	NFA<Event> nfa = NFACompiler.compile(pattern, serializer, false);
	Set<State<Event>> states = nfa.getStates();
	assertEquals(4, states.size());
	Map<String, State<Event>> stateMap = new HashMap<>();
	for (State<Event> state : states) {
		stateMap.put(state.getName(), state);
	}
	assertTrue(stateMap.containsKey("start"));
	State<Event> startState = stateMap.get("start");
	assertTrue(startState.isStart());
	final Set<Tuple2<String, StateTransitionAction>> startTransitions = unfoldTransitions(startState);
	assertEquals(Sets.newHashSet(
		Tuple2.of("middle", StateTransitionAction.TAKE)
	), startTransitions);
	assertTrue(stateMap.containsKey("middle"));
	State<Event> middleState = stateMap.get("middle");
	final Set<Tuple2<String, StateTransitionAction>> middleTransitions = unfoldTransitions(middleState);
	assertEquals(Sets.newHashSet(
		Tuple2.of("middle", StateTransitionAction.IGNORE),
		Tuple2.of("end", StateTransitionAction.TAKE)
	), middleTransitions);
	assertTrue(stateMap.containsKey("end"));
	State<Event> endState = stateMap.get("end");
	final Set<Tuple2<String, StateTransitionAction>> endTransitions = unfoldTransitions(endState);
	assertEquals(Sets.newHashSet(
		Tuple2.of(NFACompiler.ENDING_STATE_NAME, StateTransitionAction.TAKE)
	), endTransitions);
	assertTrue(stateMap.containsKey(NFACompiler.ENDING_STATE_NAME));
	State<Event> endingState = stateMap.get(NFACompiler.ENDING_STATE_NAME);
	assertTrue(endingState.isFinal());
	assertEquals(0, endingState.getStateTransitions().size());
}