Search in sources :

Example 1 with TimerParameter

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));
}
Also used : TimerParameter(org.apache.beam.sdk.transforms.reflect.DoFnSignature.Parameter.TimerParameter) TimerDeclaration(org.apache.beam.sdk.transforms.reflect.DoFnSignature.TimerDeclaration) Test(org.junit.Test)

Aggregations

TimerParameter (org.apache.beam.sdk.transforms.reflect.DoFnSignature.Parameter.TimerParameter)1 TimerDeclaration (org.apache.beam.sdk.transforms.reflect.DoFnSignature.TimerDeclaration)1 Test (org.junit.Test)1