#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:
@@ -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() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user