Last active
August 29, 2015 14:10
-
-
Save dmcg/57527540ceb01a455fcf to your computer and use it in GitHub Desktop.
JMock, Hamcrest, Guava and Java8 lambdas collide in expressive ways
This file contains 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
@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