use of org.apache.beam.sdk.transforms.reflect.DoFnSignature.Parameter.TimerParameter in project beam by apache.
the class DoFnSignaturesTest method testDeclAndUsageOfTimerInSuperclass.
@Test
public void testDeclAndUsageOfTimerInSuperclass() throws Exception {
DoFnSignature sig = DoFnSignatures.getSignature(new DoFnOverridingAbstractTimerUse().getClass());
assertThat(sig.timerDeclarations().size(), equalTo(1));
assertThat(sig.processElement().extraParameters().size(), equalTo(2));
DoFnSignature.TimerDeclaration decl = sig.timerDeclarations().get(TimerDeclaration.PREFIX + DoFnOverridingAbstractTimerUse.TIMER_ID);
TimerParameter timerParam = (TimerParameter) sig.processElement().extraParameters().get(1);
assertThat(decl.field(), equalTo(DoFnDeclaringTimerAndAbstractUse.class.getDeclaredField("myTimerSpec")));
// The method we pull out is the superclass method; this is what allows validation to remain
// simple. The later invokeDynamic instruction causes it to invoke the actual implementation.
assertThat(timerParam.referent(), equalTo(decl));
}
Aggregations