Search in sources :

Example 1 with AnonymousMethod

use of org.apache.beam.sdk.transforms.reflect.DoFnSignaturesTestUtils.AnonymousMethod in project beam by apache.

the class DoFnSignaturesSplittableDoFnTest method testSplittableProcessElementMustNotHaveOtherParams.

@Test
public void testSplittableProcessElementMustNotHaveOtherParams() throws Exception {
    thrown.expect(IllegalArgumentException.class);
    thrown.expectMessage("Illegal parameter");
    thrown.expectMessage("BoundedWindow");
    DoFnSignature.ProcessElementMethod signature = analyzeProcessElementMethod(new AnonymousMethod() {

        private void method(DoFn<Integer, String>.ProcessContext<Integer, String> context, SomeRestrictionTracker tracker, BoundedWindow window) {
        }
    });
}
Also used : DoFn(org.apache.beam.sdk.transforms.DoFn) FakeDoFn(org.apache.beam.sdk.transforms.reflect.DoFnSignaturesTestUtils.FakeDoFn) BoundedWindow(org.apache.beam.sdk.transforms.windowing.BoundedWindow) AnonymousMethod(org.apache.beam.sdk.transforms.reflect.DoFnSignaturesTestUtils.AnonymousMethod) Test(org.junit.Test)

Example 2 with AnonymousMethod

use of org.apache.beam.sdk.transforms.reflect.DoFnSignaturesTestUtils.AnonymousMethod in project beam by apache.

the class DoFnSignaturesProcessElementTest method testBadGenericWildCards.

@Test
public void testBadGenericWildCards() throws Exception {
    thrown.expect(IllegalArgumentException.class);
    thrown.expectMessage("DoFn<Integer, ? super Integer>.ProcessContext");
    thrown.expectMessage("must have type");
    thrown.expectMessage("DoFn<Integer, String>.ProcessContext");
    analyzeProcessElementMethod(new AnonymousMethod() {

        private void method(DoFn<Integer, ? super Integer>.ProcessContext c) {
        }
    });
}
Also used : DoFn(org.apache.beam.sdk.transforms.DoFn) AnonymousMethod(org.apache.beam.sdk.transforms.reflect.DoFnSignaturesTestUtils.AnonymousMethod) Test(org.junit.Test)

Example 3 with AnonymousMethod

use of org.apache.beam.sdk.transforms.reflect.DoFnSignaturesTestUtils.AnonymousMethod in project beam by apache.

the class DoFnSignaturesSplittableDoFnTest method testHasRestrictionTracker.

@Test
// used via reflection
@SuppressWarnings("unused")
public void testHasRestrictionTracker() throws Exception {
    DoFnSignature.ProcessElementMethod signature = analyzeProcessElementMethod(new AnonymousMethod() {

        private void method(DoFn<Integer, String>.ProcessContext context, SomeRestrictionTracker tracker) {
        }
    });
    assertTrue(signature.isSplittable());
    assertTrue(signature.extraParameters().stream().anyMatch(Predicates.instanceOf(DoFnSignature.Parameter.RestrictionTrackerParameter.class)::apply));
    assertEquals(SomeRestrictionTracker.class, signature.trackerT().getRawType());
}
Also used : DoFn(org.apache.beam.sdk.transforms.DoFn) FakeDoFn(org.apache.beam.sdk.transforms.reflect.DoFnSignaturesTestUtils.FakeDoFn) AnonymousMethod(org.apache.beam.sdk.transforms.reflect.DoFnSignaturesTestUtils.AnonymousMethod) Test(org.junit.Test)

Example 4 with AnonymousMethod

use of org.apache.beam.sdk.transforms.reflect.DoFnSignaturesTestUtils.AnonymousMethod in project beam by apache.

the class DoFnSignaturesSplittableDoFnTest method testReturnsProcessContinuation.

@Test
// used via reflection
@SuppressWarnings("unused")
public void testReturnsProcessContinuation() throws Exception {
    DoFnSignature.ProcessElementMethod signature = analyzeProcessElementMethod(new AnonymousMethod() {

        private DoFn.ProcessContinuation method(DoFn<Integer, String>.ProcessContext context) {
            return null;
        }
    });
    assertTrue(signature.hasReturnValue());
}
Also used : DoFn(org.apache.beam.sdk.transforms.DoFn) FakeDoFn(org.apache.beam.sdk.transforms.reflect.DoFnSignaturesTestUtils.FakeDoFn) AnonymousMethod(org.apache.beam.sdk.transforms.reflect.DoFnSignaturesTestUtils.AnonymousMethod) Test(org.junit.Test)

Example 5 with AnonymousMethod

use of org.apache.beam.sdk.transforms.reflect.DoFnSignaturesTestUtils.AnonymousMethod in project beam by apache.

the class DoFnSignaturesProcessElementTest method testBadExtraProcessContextType.

@Test
public void testBadExtraProcessContextType() throws Exception {
    thrown.expect(IllegalArgumentException.class);
    thrown.expectMessage("Integer is not a valid context parameter.");
    analyzeProcessElementMethod(new AnonymousMethod() {

        private void method(DoFn<Integer, String>.ProcessContext c, Integer n) {
        }
    });
}
Also used : DoFn(org.apache.beam.sdk.transforms.DoFn) AnonymousMethod(org.apache.beam.sdk.transforms.reflect.DoFnSignaturesTestUtils.AnonymousMethod) Test(org.junit.Test)

Aggregations

DoFn (org.apache.beam.sdk.transforms.DoFn)7 AnonymousMethod (org.apache.beam.sdk.transforms.reflect.DoFnSignaturesTestUtils.AnonymousMethod)7 Test (org.junit.Test)7 FakeDoFn (org.apache.beam.sdk.transforms.reflect.DoFnSignaturesTestUtils.FakeDoFn)3 BoundedWindow (org.apache.beam.sdk.transforms.windowing.BoundedWindow)1