use of org.apache.beam.runners.core.StateNamespaceForTest in project beam by apache.
the class StreamingModeExecutionContextTest method testTimerInternalsSetTimer.
@Test
public void testTimerInternalsSetTimer() {
Windmill.WorkItemCommitRequest.Builder outputBuilder = Windmill.WorkItemCommitRequest.newBuilder();
NameContext nameContext = NameContextsForTests.nameContextForTest();
DataflowOperationContext operationContext = executionContext.createOperationContext(nameContext);
StreamingModeExecutionContext.StepContext stepContext = executionContext.getStepContext(operationContext);
executionContext.start("key", Windmill.WorkItem.newBuilder().setKey(ByteString.EMPTY).setWorkToken(17L).build(), // input watermark
new Instant(1000), // output watermark
null, // synchronized processing time
null, stateReader, stateFetcher, outputBuilder);
TimerInternals timerInternals = stepContext.timerInternals();
timerInternals.setTimer(TimerData.of(new StateNamespaceForTest("key"), new Instant(5000), new Instant(5000), TimeDomain.EVENT_TIME));
executionContext.flushState();
Windmill.Timer timer = outputBuilder.buildPartial().getOutputTimers(0);
assertThat(timer.getTag().toStringUtf8(), equalTo("/skey+0:5000"));
assertThat(timer.getTimestamp(), equalTo(TimeUnit.MILLISECONDS.toMicros(5000)));
assertThat(timer.getType(), equalTo(Windmill.Timer.Type.WATERMARK));
}
Aggregations