use of example.domain.PhoneNumber in project doma by domaframework.
the class ScalarProviderTest method testOptionalDomain.
@Test
public void testOptionalDomain() throws Exception {
MockResultSetMetaData metaData = new MockResultSetMetaData();
metaData.columns.add(new ColumnMetaData("aaa"));
MockResultSet resultSet = new MockResultSet(metaData);
resultSet.rows.add(new RowData("hoge"));
resultSet.next();
DomainType<String, PhoneNumber> domainType = _PhoneNumber.getSingletonInternal();
ScalarProvider<String, Optional<PhoneNumber>> provider = new ScalarProvider<>(domainType::createOptionalScalar, new MySelectQuery());
Optional<PhoneNumber> result = provider.get(resultSet);
assertEquals("hoge", result.get().getValue());
}
use of example.domain.PhoneNumber in project doma by domaframework.
the class SelectBuilderTest method testSingleResult_Domain.
@Test
public void testSingleResult_Domain() {
SelectBuilder builder = SelectBuilder.newInstance(new MockConfig());
builder.sql("select ccc from Emp");
builder.sql("where");
builder.sql("aaa = ").param(String.class, "aaa");
builder.sql("and");
builder.sql("bbb = ").param(int.class, 100);
PhoneNumber phoneNumber = builder.getScalarSingleResult(PhoneNumber.class);
assertNull(phoneNumber);
}
Aggregations