use of org.jdbi.v3.sqlobject.customizer.Bind in project jdbi by jdbi.
the class TestVavrValueArgumentFactoryWithDB method testGetOption_shouldReturnCorrectRow.
@Test
public void testGetOption_shouldReturnCorrectRow() {
Something result = dbRule.getSharedHandle().createQuery(SELECT_BY_NAME).bind("name", Option.of("eric")).mapToBean(Something.class).findOnly();
assertThat(result).isEqualTo(ERIC_SOMETHING);
}
use of org.jdbi.v3.sqlobject.customizer.Bind in project jdbi by jdbi.
the class TestVavrValueArgumentFactoryWithDB method testGetTrySuccess_shouldReturnCorrectRow.
@Test
public void testGetTrySuccess_shouldReturnCorrectRow() {
Something result = dbRule.getSharedHandle().createQuery(SELECT_BY_NAME).bind("name", Try.success("brian")).mapToBean(Something.class).findOnly();
assertThat(result).isEqualTo(BRIAN_SOMETHING);
}
use of org.jdbi.v3.sqlobject.customizer.Bind in project providence by morimekta.
the class MessageInserterTest method testDefaultMapping.
@Test
public void testDefaultMapping() {
generator.setFillRate(1.0).setMaxCollectionItems(16);
OptionalFields expected = generator.generate(OptionalFields.kDescriptor).mutate().setId(1234).setTimestampS((int) clock.instant().getEpochSecond()).setTimestampMs(clock.instant().getEpochSecond() * 1000).build();
OptionalFields empty = OptionalFields.builder().setId(2345).build();
try (Handle handle = db.getDBI().open()) {
INSERTER.execute(handle, expected, empty);
OptionalFields val = handle.createQuery("SELECT * FROM mappings_v3.default_mappings WHERE id = :id").bind("id", expected.getId()).map(toMessage(OptionalFields.kDescriptor, columnsFromAllFields(), withColumn("compact", MESSAGE), withColumn("other_message", CLOB_MESSAGE))).findFirst().orElseThrow(() -> new AssertionError("No content in default_mappings"));
OptionalFields val2 = handle.createQuery("SELECT * FROM mappings_v3.default_mappings WHERE id = :id").bind("id", empty.getId()).map(toMessage(OptionalFields.kDescriptor, columnsFromAllFields(), withColumn("compact", MESSAGE), withColumn("other_message", CLOB_MESSAGE))).findFirst().orElseThrow(() -> new AssertionError("No content in default_mappings"));
assertThat(val, is(equalToMessage(expected)));
assertThat(val2, is(equalToMessage(empty)));
}
}
Aggregations