use of org.apache.beam.sdk.transforms.reflect.DoFnSignature.Parameter in project beam by apache.
the class DoFnSignaturesTest method testSimpleTimerWithContext.
@Test
public void testSimpleTimerWithContext() throws Exception {
DoFnSignature sig = DoFnSignatures.getSignature(new 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(OnTimerContext c) {
}
}.getClass());
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().getName(), equalTo("bizzle"));
assertThat(sig.onTimerMethods().get(timerDeclarationId).extraParameters().get(0), equalTo((Parameter) Parameter.onTimerContext()));
}
Aggregations