Last active
July 27, 2016 13:17
-
-
Save Dalamar42/25797642b9c0d1dc4684708138915d7b to your computer and use it in GitHub Desktop.
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
// This is the stub generated by our fictional framework | |
Database mockDatabase = mock(Database.class); | |
// Class that we want to test and that uses mockDatabase | |
ApplicationService service = new ApplicationService(stubDatabase); | |
// Here we are telling the stub what to return | |
when(mockDatabase.getApplicationKey(APP_ID)) | |
.thenReturn(new ApplicationKey(APP_ID, Status.REVOKED)); | |
// Test ApplicationService behaviour | |
assertThat(service.isRevoked(APP_ID), is(true)); | |
// Verify the the expected method with the expected parameters | |
// was called on the mock | |
verify(mockDatabase).getApplicationKey(APP_ID); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment