StephanEwen commented on a change in pull request #11235: [FLINK-15980] fix
that the notFollowedBy in the end of GroupPattern may be ignored
URL: https://github.com/apache/flink/pull/11235#discussion_r386271750
##########
File path:
flink-libraries/flink-cep/src/test/java/org/apache/flink/cep/nfa/NotPatternITCase.java
##########
@@ -980,6 +980,53 @@ public void
testNotFollowedByBeforeZeroOrMoreCombinationsSkipTillAny() throws Ex
));
}
+ @Test
+ public void testNotFollowedByInTheEndOfGroupPattern() throws Exception {
+
+ List<StreamRecord<Event>> inputEvents = new ArrayList<>();
+
+ int i = 0;
+ inputEvents.add(new StreamRecord<>(NotFollowByData.A_1, i++));
+ inputEvents.add(new StreamRecord<>(NotFollowByData.C_1, i++));
+ inputEvents.add(new StreamRecord<>(NotFollowByData.B_1, i++));
+ inputEvents.add(new StreamRecord<>(NotFollowByData.A_1, i++));
+ inputEvents.add(new StreamRecord<>(NotFollowByData.B_2, i++));
+
+ Pattern<Event, ?> startPattern = Pattern
+ .<Event>begin("a").where(new
SimpleCondition<Event>() {
+ private static final long
serialVersionUID = 5726188262756267490L;
+
+ @Override
+ public boolean filter(Event value)
throws Exception {
+ return
value.getName().equals("a");
+ }
+ })
+ .notFollowedBy("not c").where(new
SimpleCondition<Event>() {
+ private static final long
serialVersionUID = 5726188262756267490L;
+
+ @Override
+ public boolean filter(Event value)
throws Exception {
+ return
value.getName().equals("c");
+ }
+ });
+
+ Pattern<Event, ?> pattern =
Pattern.begin(startPattern).followedBy("b")
+ .where(new SimpleCondition<Event>() {
+ private static final long
serialVersionUID = 5726188262756267490L;
+
+ @Override
+ public boolean filter(Event value)
throws Exception {
+ return
value.getName().equals("b");
+ }
+ });
+
+ NFA<Event> nfa = compile(pattern, false);
+
+ final List<List<Event>> matches = feedNFA(inputEvents, nfa);
+
+ comparePatterns(matches,
Lists.<List<Event>>newArrayList(Lists.newArrayList(NotFollowByData.A_1,
NotFollowByData.B_2)));
Review comment:
Would it be simpler to just use `new ArrayList<>(...)`?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services