Search in sources :

Example 16 with Parameter

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()));
}
Also used : DoFn(org.apache.beam.sdk.transforms.DoFn) FakeDoFn(org.apache.beam.sdk.transforms.reflect.DoFnSignaturesTestUtils.FakeDoFn) Parameter(org.apache.beam.sdk.transforms.reflect.DoFnSignature.Parameter) ProcessContextParameter(org.apache.beam.sdk.transforms.reflect.DoFnSignature.Parameter.ProcessContextParameter) BundleFinalizerParameter(org.apache.beam.sdk.transforms.reflect.DoFnSignature.Parameter.BundleFinalizerParameter) OutputReceiverParameter(org.apache.beam.sdk.transforms.reflect.DoFnSignature.Parameter.OutputReceiverParameter) PipelineOptionsParameter(org.apache.beam.sdk.transforms.reflect.DoFnSignature.Parameter.PipelineOptionsParameter) PaneInfoParameter(org.apache.beam.sdk.transforms.reflect.DoFnSignature.Parameter.PaneInfoParameter) TimeDomainParameter(org.apache.beam.sdk.transforms.reflect.DoFnSignature.Parameter.TimeDomainParameter) ElementParameter(org.apache.beam.sdk.transforms.reflect.DoFnSignature.Parameter.ElementParameter) StartBundleContextParameter(org.apache.beam.sdk.transforms.reflect.DoFnSignature.Parameter.StartBundleContextParameter) WindowParameter(org.apache.beam.sdk.transforms.reflect.DoFnSignature.Parameter.WindowParameter) TimerParameter(org.apache.beam.sdk.transforms.reflect.DoFnSignature.Parameter.TimerParameter) SchemaElementParameter(org.apache.beam.sdk.transforms.reflect.DoFnSignature.Parameter.SchemaElementParameter) FinishBundleContextParameter(org.apache.beam.sdk.transforms.reflect.DoFnSignature.Parameter.FinishBundleContextParameter) SideInputParameter(org.apache.beam.sdk.transforms.reflect.DoFnSignature.Parameter.SideInputParameter) StateParameter(org.apache.beam.sdk.transforms.reflect.DoFnSignature.Parameter.StateParameter) TimestampParameter(org.apache.beam.sdk.transforms.reflect.DoFnSignature.Parameter.TimestampParameter) TaggedOutputReceiverParameter(org.apache.beam.sdk.transforms.reflect.DoFnSignature.Parameter.TaggedOutputReceiverParameter) Matchers.containsString(org.hamcrest.Matchers.containsString) TimerDeclaration(org.apache.beam.sdk.transforms.reflect.DoFnSignature.TimerDeclaration) TimerSpec(org.apache.beam.sdk.state.TimerSpec) Test(org.junit.Test)

Aggregations

Parameter (org.apache.beam.sdk.transforms.reflect.DoFnSignature.Parameter)16 WindowParameter (org.apache.beam.sdk.transforms.reflect.DoFnSignature.Parameter.WindowParameter)16 BundleFinalizerParameter (org.apache.beam.sdk.transforms.reflect.DoFnSignature.Parameter.BundleFinalizerParameter)15 PipelineOptionsParameter (org.apache.beam.sdk.transforms.reflect.DoFnSignature.Parameter.PipelineOptionsParameter)15 RestrictionTrackerParameter (org.apache.beam.sdk.transforms.reflect.DoFnSignature.Parameter.RestrictionTrackerParameter)15 SchemaElementParameter (org.apache.beam.sdk.transforms.reflect.DoFnSignature.Parameter.SchemaElementParameter)15 StateParameter (org.apache.beam.sdk.transforms.reflect.DoFnSignature.Parameter.StateParameter)15 TimerParameter (org.apache.beam.sdk.transforms.reflect.DoFnSignature.Parameter.TimerParameter)15 ParameterizedType (java.lang.reflect.ParameterizedType)14 Type (java.lang.reflect.Type)14 RestrictionParameter (org.apache.beam.sdk.transforms.reflect.DoFnSignature.Parameter.RestrictionParameter)14 TimerFamilyParameter (org.apache.beam.sdk.transforms.reflect.DoFnSignature.Parameter.TimerFamilyParameter)14 WatermarkEstimatorParameter (org.apache.beam.sdk.transforms.reflect.DoFnSignature.Parameter.WatermarkEstimatorParameter)14 WatermarkEstimatorStateParameter (org.apache.beam.sdk.transforms.reflect.DoFnSignature.Parameter.WatermarkEstimatorStateParameter)14 TypeParameter (org.apache.beam.sdk.values.TypeParameter)14 VisibleForTesting (org.apache.beam.vendor.guava.v26_0_jre.com.google.common.annotations.VisibleForTesting)14 DoFn (org.apache.beam.sdk.transforms.DoFn)10 ArrayList (java.util.ArrayList)4 Nullable (org.checkerframework.checker.nullness.qual.Nullable)4 Map (java.util.Map)2