Java Code Examples for org.apache.flink.cep.utils.NFATestHarness#feedRecord()
The following examples show how to use
org.apache.flink.cep.utils.NFATestHarness#feedRecord() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NFAIterativeConditionTimeContextTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@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)); compareMaps(resultingPattern, Collections.singletonList( Collections.singletonList(event) )); }
Example 2
Source File: NFAIterativeConditionTimeContextTest.java From flink with Apache License 2.0 | 6 votes |
@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)); compareMaps(resultingPattern, Collections.singletonList( Collections.singletonList(event) )); }
Example 3
Source File: NFAIterativeConditionTimeContextTest.java From flink with Apache License 2.0 | 6 votes |
@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) )); }
Example 4
Source File: NFAIterativeConditionTimeContextTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testCurrentProcessingTime() throws Exception { final Event event1 = event().withId(1).build(); final Event event2 = event().withId(2).build(); 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.currentProcessingTime() == 3; } }); final TestTimerService cepTimerService = new TestTimerService(); final NFATestHarness testHarness = forPattern(pattern) .withTimerService(cepTimerService) .build(); cepTimerService.setCurrentProcessingTime(1); final List<List<Event>> resultingPatterns1 = testHarness.feedRecord(new StreamRecord<>(event1, 7)); cepTimerService.setCurrentProcessingTime(3); final List<List<Event>> resultingPatterns2 = testHarness.feedRecord(new StreamRecord<>(event2, 8)); compareMaps(resultingPatterns1, Collections.emptyList()); compareMaps(resultingPatterns2, Collections.singletonList( Collections.singletonList(event2) )); }
Example 5
Source File: NFAIterativeConditionTimeContextTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testCurrentProcessingTime() throws Exception { final Event event1 = event().withId(1).build(); final Event event2 = event().withId(2).build(); 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.currentProcessingTime() == 3; } }); final TestTimerService cepTimerService = new TestTimerService(); final NFATestHarness testHarness = forPattern(pattern) .withTimerService(cepTimerService) .build(); cepTimerService.setCurrentProcessingTime(1); final List<List<Event>> resultingPatterns1 = testHarness.feedRecord(new StreamRecord<>(event1, 7)); cepTimerService.setCurrentProcessingTime(3); final List<List<Event>> resultingPatterns2 = testHarness.feedRecord(new StreamRecord<>(event2, 8)); compareMaps(resultingPatterns1, Collections.emptyList()); compareMaps(resultingPatterns2, Collections.singletonList( Collections.singletonList(event2) )); }
Example 6
Source File: NFAIterativeConditionTimeContextTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testCurrentProcessingTime() throws Exception { final Event event1 = event().withId(1).build(); final Event event2 = event().withId(2).build(); 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.currentProcessingTime() == 3; } }); final TestTimerService cepTimerService = new TestTimerService(); final NFATestHarness testHarness = forPattern(pattern) .withTimerService(cepTimerService) .build(); cepTimerService.setCurrentProcessingTime(1); final List<List<Event>> resultingPatterns1 = testHarness.feedRecord(new StreamRecord<>(event1, 7)); cepTimerService.setCurrentProcessingTime(3); final List<List<Event>> resultingPatterns2 = testHarness.feedRecord(new StreamRecord<>(event2, 8)); comparePatterns(resultingPatterns1, Collections.emptyList()); comparePatterns(resultingPatterns2, Collections.singletonList( Collections.singletonList(event2) )); }