source: class NFATest {
  
      private Event<String, String> ev1;
      private Event<String, String> ev2;
      private Event<String, String> ev3;
      private Event<String, String> ev4;
      private Event<String, String> ev5;
      private Event<String, String> ev6;
      private Event<String, String> ev7;
      private Event<String, String> ev8;
      private AtomicInteger offset;
  
      @Test
      public void testNFAGivenOptionalExpectingOccurrenceStageWhenMatchingInputs() {
  
target: 
          Pattern<String, String> pattern = new QueryBuilder<String, String>()
                  .select("first")
                  .where(TestMatcher.isEqualTo("A"))
                  .then()
                  .select("second")
                  .times(2)
                  .optional()
                  .where(TestMatcher.isEqualTo("C"))
                  .then()
                  .select("latest")
                  .where(TestMatcher.isEqualTo("D"))
                  .build();
  
          final NFA<String, String> nfa = newNFA(pattern);
  
          List<Sequence<String, String>> s = simulate(nfa, ev1, ev3, ev4, ev5);
          assertEquals(1, s.size());
  
          assertNFA(nfa, 2, 1);
  
          Sequence<String, String> expected =  Sequence.<String, String>newBuilder()
                  .add("latest", ev5)
                  .add("second", ev4)
                  .add("second", ev3)
                  .add("first", ev1)
                  .build(true);
  
          assertEquals(expected, s.get(0));
      }
  
  }