Search in sources :

Example 46 with NFATestHarness

use of org.apache.flink.cep.utils.NFATestHarness in project flink by apache.

the class NFAIterativeConditionTimeContextTest method testEventTimestamp.

@Test
public void testEventTimestamp() throws Exception {
    final Event event = event().withId(1).build();
    final long timestamp = 3;
    final Pattern<Event, ?> pattern = Pattern.<Event>begin("start").where(new IterativeCondition<Event>() {

        @Override
        public boolean filter(Event value, Context<Event> ctx) throws Exception {
            return ctx.timestamp() == timestamp;
        }
    });
    final NFATestHarness testHarness = forPattern(pattern).build();
    final List<List<Event>> resultingPattern = testHarness.feedRecord(new StreamRecord<>(event, timestamp));
    comparePatterns(resultingPattern, Collections.singletonList(Collections.singletonList(event)));
}
Also used : NFATestHarness(org.apache.flink.cep.utils.NFATestHarness) Event(org.apache.flink.cep.Event) List(java.util.List) Test(org.junit.Test)

Aggregations

Event (org.apache.flink.cep.Event)46 NFATestHarness (org.apache.flink.cep.utils.NFATestHarness)46 Test (org.junit.Test)46 ArrayList (java.util.ArrayList)40 StreamRecord (org.apache.flink.streaming.runtime.streamrecord.StreamRecord)39 List (java.util.List)37 SimpleCondition (org.apache.flink.cep.pattern.conditions.SimpleCondition)23 FlinkRuntimeException (org.apache.flink.util.FlinkRuntimeException)15 SubEvent (org.apache.flink.cep.SubEvent)8 HashMap (java.util.HashMap)6 Map (java.util.Map)6 IterativeCondition (org.apache.flink.cep.pattern.conditions.IterativeCondition)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 SkipPastLastStrategy (org.apache.flink.cep.nfa.aftermatch.SkipPastLastStrategy)1 Pattern (org.apache.flink.cep.pattern.Pattern)1 TestTimerService (org.apache.flink.cep.utils.TestTimerService)1 DataInputViewStreamWrapper (org.apache.flink.core.memory.DataInputViewStreamWrapper)1 DataOutputViewStreamWrapper (org.apache.flink.core.memory.DataOutputViewStreamWrapper)1