Skip to content

Instantly share code, notes, and snippets.

@btforsythe
Created April 4, 2015 03:15
Show Gist options
  • Save btforsythe/6f8beddc37bb2e81456a to your computer and use it in GitHub Desktop.
Save btforsythe/6f8beddc37bb2e81456a to your computer and use it in GitHub Desktop.
Lambdas to invoke builder methods
@FunctionalInterface
interface BuilderMethod<B, V> {
Builder invoke(B builder, V value);
}
public class BuilderTest {
@Mock
private Builder builder;
@Mock
private Value value;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
}
@Test
public void shouldInvokeUsingInvokerWithTypeParameters() {
BuilderMethod<Builder,Value> lambda = Builder::foo;
lambda.invoke(builder, value);
verify(builder).foo(value);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment