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
private <T> CompletionStage<T> wrapContext(Supplier<T> toRun) { | |
return supplyAsync(toRun, executionContext); // here we are passing the context to run the method in, this means this is running in our new actor context | |
} | |
// and here is the magic, we are returning async and we are doing it in the context of executionContext. For the JS folk this is like using call or apply, we are saying do this call, but do this call within a different context than the http thread you were called from | |
public CompletionStage<List<Charity>> findList() { | |
return wrapContext(() -> ebeanServer.find(Charity.class).findList()); | |
} |
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
@SuppressWarnings("unused") EbeanDynamicEvolutions ebeanDynamicEvolutions /* Required for Ebean/DI bug */) { |
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
EXPOSE 9000 5005 | |
RUN unzip target/universal/$APP_NAME-$APP_VERSION.zip | |
RUN chmod +x $APP_NAME-$APP_VERSION/bin/$APP_NAME | |
ENTRYPOINT $APP_NAME-$APP_VERSION/bin/$APP_NAME -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 |
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
RUN sbt test dist | |
EXPOSE 9000 | |
RUN unzip target/universal/$APP_NAME-$APP_VERSION.zip | |
RUN chmod +x $APP_NAME-$APP_VERSION/bin/$APP_NAME | |
ENTRYPOINT $APP_NAME-$APP_VERSION/bin/$APP_NAME |
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
javaOptions in Test ++= Seq("-Dconfig.file=conf/application.test.conf") |
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
private final EbeanServer ebeanServer; | |
private final DatabaseExecutionContext executionContext; | |
@Inject | |
public CharityRepository(EbeanConfig ebeanConfig, DatabaseExecutionContext executionContext, | |
@SuppressWarnings("unused") | |
EbeanDynamicEvolutions ebeanDynamicEvolutions /* Required for Ebean/DI bug */) { | |
this.ebeanServer = getServer(ebeanConfig.defaultServer()); | |
this.executionContext = executionContext; | |
} |
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 CompletionStage<List<Charity>> findList() { | |
return null; | |
} |
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 Given_CharityObjectsExist_When_FindListIsCalled_Then_AllCharityObjectsAreReturned() { | |
// GIVEN | |
rangeClosed(1, 4).boxed().map(Charity::new).forEach(Model::save); | |
// WHEN | |
List<Charity> result = repository.findList().toCompletableFuture().join(); | |
// THEN |
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 CharityRepositoryTest extends WithApplication { | |
private CharityRepository repository; | |
@Before | |
public void setUp() { | |
repository = instanceOf(CharityRepository.class); | |
CallableSql cleanCharityTable = getDefaultServer().createCallableSql("delete from charity"); | |
getDefaultServer().execute(cleanCharityTable); |
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 Given_IsBeforeEndDate_When_GetRequestIsMadeToIndexPage_Then_StatusIs200() { | |
// GIVEN | |
long beforeEndDate = 9L; | |
given(clock.instant()).willReturn(ofEpochMilli(beforeEndDate)); | |
given(clock.getZone()).willReturn(ZoneId.of("+0")); | |
// WHEN | |
WSResponse result = newClient(providePort()).url("/").get().toCompletableFuture().join(); |
NewerOlder