Created
January 17, 2018 19:59
-
-
Save rowanl/d41af0efc42601d943cbcdd2b88abe00 to your computer and use it in GitHub Desktop.
playframework-kubernetes - Mocking time dependency in tests using Guice
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
public class CharityControllerTest extends WithServer { | |
private Clock clock; | |
@Override | |
protected Application provideApplication() { | |
return new GuiceApplicationBuilder() | |
.overrides(bindClockToMockInstance()) | |
.build(); | |
} | |
private AbstractModule bindClockToMockInstance() { | |
return new AbstractModule() { | |
@Override | |
protected void configure() { | |
bind(Clock.class).toInstance(clock = mock(Clock.class)); | |
} | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment