use of org.apache.beam.sdk.state.TimerSpec in project beam by apache.
the class DoFnSignaturesTest method testSimpleTimerIdNamedDoFn.
@Test
public void testSimpleTimerIdNamedDoFn() throws Exception {
class DoFnForTestSimpleTimerIdNamedDoFn extends DoFn<KV<String, Integer>, Long> {
@TimerId("foo")
private final TimerSpec bizzle = TimerSpecs.timer(TimeDomain.EVENT_TIME);
@ProcessElement
public void foo(ProcessContext context) {
}
@OnTimer("foo")
public void onFoo() {
}
}
// Test classes at the bottom of the file
DoFnSignature sig = DoFnSignatures.signatureForDoFn(new DoFnForTestSimpleTimerIdNamedDoFn());
final String timerDeclarationId = TimerDeclaration.PREFIX + "foo";
assertThat(sig.timerDeclarations().size(), equalTo(1));
DoFnSignature.TimerDeclaration decl = sig.timerDeclarations().get(timerDeclarationId);
assertThat(decl.id(), equalTo(timerDeclarationId));
assertThat(decl.field(), equalTo(DoFnForTestSimpleTimerIdNamedDoFn.class.getDeclaredField("bizzle")));
}
Aggregations