@Test public void testSplitRestrictionReturnsWrongType() throws Exception { thrown.expectMessage( "Third argument must be DoFn.OutputReceiver<SomeRestriction>, " + "but is DoFn.OutputReceiver<String>"); DoFnSignatures.analyzeSplitRestrictionMethod( errors(), TypeDescriptor.of(FakeDoFn.class), new AnonymousMethod() { void method( Integer element, SomeRestriction restriction, DoFn.OutputReceiver<String> receiver) {} }.getMethod(), TypeDescriptor.of(Integer.class)); }
@Test public void testSplitRestrictionWrongNumArguments() throws Exception { thrown.expectMessage("Must have exactly 3 arguments"); DoFnSignatures.analyzeSplitRestrictionMethod( errors(), TypeDescriptor.of(FakeDoFn.class), new AnonymousMethod() { private void method( Integer element, SomeRestriction restriction, DoFn.OutputReceiver<SomeRestriction> receiver, Object extra) {} }.getMethod(), TypeDescriptor.of(Integer.class)); }
@Test public void testSplitRestrictionWrongElementArgument() throws Exception { class BadFn { private List<SomeRestriction> splitRestriction(String element, SomeRestriction restriction) { return null; } } thrown.expectMessage("First argument must be the element type Integer"); DoFnSignatures.analyzeSplitRestrictionMethod( errors(), TypeDescriptor.of(FakeDoFn.class), new AnonymousMethod() { void method( String element, SomeRestriction restriction, DoFn.OutputReceiver<SomeRestriction> receiver) {} }.getMethod(), TypeDescriptor.of(Integer.class)); }
errors.forMethod(DoFn.SplitRestriction.class, splitRestrictionMethod); signatureBuilder.setSplitRestriction( analyzeSplitRestrictionMethod( splitRestrictionErrors, fnT, splitRestrictionMethod, inputT));