Skip to content

Instantly share code, notes, and snippets.

@dmcg
Last active August 29, 2015 14:10
Show Gist options
  • Save dmcg/57527540ceb01a455fcf to your computer and use it in GitHub Desktop.
Save dmcg/57527540ceb01a455fcf to your computer and use it in GitHub Desktop.
JMock, Hamcrest, Guava and Java8 lambdas collide in expressive ways
@Test
public void saves_results() throws IOException {
ImmutableList<Associate> associates = ImmutableList.of(
new Associate("id1", "fn1", "ln2"),
new Associate("id2", "fn1", "ln2"));
mockery.given((given) -> {
given.oneOf(source).findAssociates("token");
given.will(returnValue(associates.stream()));
});
mockery.when(() -> {
assertThat(finder.findAssociates("token"), streamContaining(associates.toArray()));
}).then((then) -> {
then.oneOf(database).save(
new AssociateList(Ids.NO_ID, OAuthAccount.STRAVA_PROD, "stravaId", associates));
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment