Created
April 4, 2015 03:15
-
-
Save btforsythe/6f8beddc37bb2e81456a to your computer and use it in GitHub Desktop.
Lambdas to invoke builder methods
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@FunctionalInterface | |
interface BuilderMethod<B, V> { | |
Builder invoke(B builder, V value); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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