Skip to content

Instantly share code, notes, and snippets.

@Dalamar42
Last active July 27, 2016 13:17
Show Gist options
  • Save Dalamar42/2866df212f17560cd8f8948a524e375b to your computer and use it in GitHub Desktop.
Save Dalamar42/2866df212f17560cd8f8948a524e375b to your computer and use it in GitHub Desktop.
// This is the stub generated by our fictional framework
Database stubDatabase = stub(Database.class);
// Class that we want to test and that uses stubDatabase
ApplicationService service = new ApplicationService(stubDatabase);
// Here we are telling the stub what to return
when(stubDatabase.getApplicationKey(APP_ID))
.thenReturn(new ApplicationKey(APP_ID, Status.REVOKED));
// Test ApplicationService behaviour
assertThat(service.isRevoked(APP_ID), is(true));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment