Repository: flink Updated Branches: refs/heads/master f2a8bc92d -> ad21a4414
http://git-wip-us.apache.org/repos/asf/flink/blob/7fbdc100/flink-libraries/flink-cep/src/test/java/org/apache/flink/cep/pattern/PatternTest.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-cep/src/test/java/org/apache/flink/cep/pattern/PatternTest.java b/flink-libraries/flink-cep/src/test/java/org/apache/flink/cep/pattern/PatternTest.java index 68b0419..e9aa7d2 100644 --- a/flink-libraries/flink-cep/src/test/java/org/apache/flink/cep/pattern/PatternTest.java +++ b/flink-libraries/flink-cep/src/test/java/org/apache/flink/cep/pattern/PatternTest.java @@ -18,9 +18,11 @@ package org.apache.flink.cep.pattern; -import org.apache.flink.api.common.functions.FilterFunction; import org.apache.flink.cep.Event; import org.apache.flink.cep.SubEvent; +import org.apache.flink.cep.pattern.conditions.OrCondition; +import org.apache.flink.cep.pattern.conditions.SimpleCondition; +import org.apache.flink.cep.pattern.conditions.SubtypeCondition; import org.apache.flink.util.TestLogger; import org.junit.Test; @@ -66,14 +68,14 @@ public class PatternTest extends TestLogger { @Test public void testStrictContiguityWithCondition() { - Pattern<Event, ?> pattern = Pattern.<Event>begin("start").next("next").where(new FilterFunction<Event>() { + Pattern<Event, ?> pattern = Pattern.<Event>begin("start").next("next").where(new SimpleCondition<Event>() { private static final long serialVersionUID = -7657256242101104925L; @Override public boolean filter(Event value) throws Exception { return value.getName().equals("foobar"); } - }).next("end").where(new FilterFunction<Event>() { + }).next("end").where(new SimpleCondition<Event>() { private static final long serialVersionUID = -7597452389191504189L; @Override @@ -89,9 +91,9 @@ public class PatternTest extends TestLogger { assertNotNull(previous2 = previous.getPrevious()); assertNull(previous2.getPrevious()); - assertNotNull(pattern.getFilterFunction()); - assertNotNull(previous.getFilterFunction()); - assertNull(previous2.getFilterFunction()); + assertNotNull(pattern.getCondition()); + assertNotNull(previous.getCondition()); + assertNull(previous2.getCondition()); assertEquals(pattern.getName(), "end"); assertEquals(previous.getName(), "next"); @@ -109,8 +111,8 @@ public class PatternTest extends TestLogger { assertNotNull(previous2 = previous.getPrevious()); assertNull(previous2.getPrevious()); - assertNotNull(previous.getFilterFunction()); - assertTrue(previous.getFilterFunction() instanceof SubtypeFilterFunction); + assertNotNull(previous.getCondition()); + assertTrue(previous.getCondition() instanceof SubtypeCondition); assertEquals(pattern.getName(), "end"); assertEquals(previous.getName(), "subevent"); @@ -119,7 +121,7 @@ public class PatternTest extends TestLogger { @Test public void testPatternWithSubtypingAndFilter() { - Pattern<Event, Event> pattern = Pattern.<Event>begin("start").next("subevent").subtype(SubEvent.class).where(new FilterFunction<SubEvent>() { + Pattern<Event, Event> pattern = Pattern.<Event>begin("start").next("subevent").subtype(SubEvent.class).where(new SimpleCondition<SubEvent>() { private static final long serialVersionUID = -4118591291880230304L; @Override @@ -136,7 +138,7 @@ public class PatternTest extends TestLogger { assertNull(previous2.getPrevious()); assertTrue(pattern instanceof FollowedByPattern); - assertNotNull(previous.getFilterFunction()); + assertNotNull(previous.getCondition()); assertEquals(pattern.getName(), "end"); assertEquals(previous.getName(), "subevent"); @@ -145,21 +147,21 @@ public class PatternTest extends TestLogger { @Test public void testPatternWithOrFilter() { - Pattern<Event, Event> pattern = Pattern.<Event>begin("start").where(new FilterFunction<Event>() { + Pattern<Event, Event> pattern = Pattern.<Event>begin("start").where(new SimpleCondition<Event>() { private static final long serialVersionUID = 3518061453394250543L; @Override public boolean filter(Event value) throws Exception { return false; } - }).or(new FilterFunction<Event>() { + }).or(new SimpleCondition<Event>() { private static final long serialVersionUID = 947463545810023841L; @Override public boolean filter(Event value) throws Exception { return false; } - }).next("or").or(new FilterFunction<Event>() { + }).next("or").or(new SimpleCondition<Event>() { private static final long serialVersionUID = -2775487887505922250L; @Override @@ -176,8 +178,8 @@ public class PatternTest extends TestLogger { assertNull(previous2.getPrevious()); assertTrue(pattern instanceof FollowedByPattern); - assertFalse(previous.getFilterFunction() instanceof OrFilterFunction); - assertTrue(previous2.getFilterFunction() instanceof OrFilterFunction); + assertFalse(previous.getCondition() instanceof OrCondition); + assertTrue(previous2.getCondition() instanceof OrCondition); assertEquals(pattern.getName(), "end"); assertEquals(previous.getName(), "or"); @@ -187,7 +189,9 @@ public class PatternTest extends TestLogger { @Test(expected = MalformedPatternException.class) public void testPatternCanHaveQuantifierSpecifiedOnce1() throws Exception { - Pattern.begin("start").where(new FilterFunction<Object>() { + Pattern.begin("start").where(new SimpleCondition<Object>() { + private static final long serialVersionUID = 8876425689668531458L; + @Override public boolean filter(Object value) throws Exception { return true; @@ -198,7 +202,9 @@ public class PatternTest extends TestLogger { @Test(expected = MalformedPatternException.class) public void testPatternCanHaveQuantifierSpecifiedOnce2() throws Exception { - Pattern.begin("start").where(new FilterFunction<Object>() { + Pattern.begin("start").where(new SimpleCondition<Object>() { + private static final long serialVersionUID = 8311890695733430258L; + @Override public boolean filter(Object value) throws Exception { return true; @@ -209,7 +215,9 @@ public class PatternTest extends TestLogger { @Test(expected = MalformedPatternException.class) public void testPatternCanHaveQuantifierSpecifiedOnce3() throws Exception { - Pattern.begin("start").where(new FilterFunction<Object>() { + Pattern.begin("start").where(new SimpleCondition<Object>() { + private static final long serialVersionUID = 8093713196099078214L; + @Override public boolean filter(Object value) throws Exception { return true; @@ -220,7 +228,9 @@ public class PatternTest extends TestLogger { @Test(expected = MalformedPatternException.class) public void testPatternCanHaveQuantifierSpecifiedOnce4() throws Exception { - Pattern.begin("start").where(new FilterFunction<Object>() { + Pattern.begin("start").where(new SimpleCondition<Object>() { + private static final long serialVersionUID = -2995187062849334113L; + @Override public boolean filter(Object value) throws Exception { return true; @@ -231,7 +241,9 @@ public class PatternTest extends TestLogger { @Test(expected = MalformedPatternException.class) public void testPatternCanHaveQuantifierSpecifiedOnce5() throws Exception { - Pattern.begin("start").where(new FilterFunction<Object>() { + Pattern.begin("start").where(new SimpleCondition<Object>() { + private static final long serialVersionUID = -2205071036073867531L; + @Override public boolean filter(Object value) throws Exception { return true;
