#2 - Refactor to functional usage of resources.

DatabaseClient now creates functions. The actual invocation/execution takes place from DefaultFetchFunctions (FetchSpec) to keep stateful resources in the scope of the execution. execute()/executeMany() use Flux.usingWhen/Mono.usingWhen to release connections after their usage.
This commit is contained in:
Mark Paluch
2018-06-19 15:08:11 +02:00
parent f490c1f3d9
commit b8375f5a96
2 changed files with 204 additions and 84 deletions

View File

@@ -121,12 +121,29 @@ public class DatabaseClientIntegrationTests {
.value("name", "SCHAUFELRADBAGGER") //
.nullValue("manual") //
.exchange() //
.flatMapMany(it -> it.extract((r, m) -> r.get("id", Integer.class)).all()).as(StepVerifier::create) //
.flatMapMany(it -> it.extract((r, m) -> r.get("id", Integer.class)).all()) //
.as(StepVerifier::create) //
.expectNext(42055).verifyComplete();
assertThat(jdbc.queryForMap("SELECT id, name, manual FROM legoset")).containsEntry("id", 42055);
}
@Test
public void insertWithoutResult() {
DatabaseClient databaseClient = DatabaseClient.create(connectionFactory);
databaseClient.insert().into("legoset")//
.value("id", 42055) //
.value("name", "SCHAUFELRADBAGGER") //
.nullValue("manual") //
.then() //
.as(StepVerifier::create) //
.verifyComplete();
assertThat(jdbc.queryForMap("SELECT id, name, manual FROM legoset")).containsEntry("id", 42055);
}
@Test
public void insertTypedObject() {