use of example.domain.PhoneNumber in project doma by domaframework.
the class DomainSingleResultHandlerTest method testHandle.
@Test
public void testHandle() throws Exception {
MockResultSetMetaData metaData = new MockResultSetMetaData();
metaData.columns.add(new ColumnMetaData("x"));
MockResultSet resultSet = new MockResultSet(metaData);
resultSet.rows.add(new RowData("01-2345-6789"));
SqlFileSelectQuery query = new SqlFileSelectQuery();
query.setConfig(runtimeConfig);
query.setSqlFilePath(SqlFileUtil.buildPath(getClass().getName(), method.getName()));
query.setCallerClassName("aaa");
query.setCallerMethodName("bbb");
query.setMethod(method);
query.setSqlLogType(SqlLogType.FORMATTED);
query.prepare();
DomainSingleResultHandler<String, PhoneNumber> handler = new DomainSingleResultHandler<>(_PhoneNumber.getSingletonInternal());
PhoneNumber result = handler.handle(resultSet, query, (i, next) -> {
}).get();
assertEquals("01-2345-6789", result.getValue());
}
use of example.domain.PhoneNumber in project doma by domaframework.
the class SelectBuilderTest method testGetResultList_Domain.
@Test
public void testGetResultList_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);
List<PhoneNumber> list = builder.getScalarResultList(PhoneNumber.class);
assertNotNull(list);
}
use of example.domain.PhoneNumber in project doma by domaframework.
the class ScalarInOutParameterTest method testGetDomainClass.
@Test
public void testGetDomainClass() {
DomainType<String, PhoneNumber> domainType = DomainTypeFactory.getDomainType(PhoneNumber.class, new ClassHelper() {
});
Scalar<String, PhoneNumber> scalar = domainType.createScalar();
Reference<PhoneNumber> ref = new Reference<>();
ScalarInOutParameter<String, PhoneNumber> parameter = new ScalarInOutParameter<>(scalar, ref);
Optional<Class<?>> optional = parameter.getDomainClass();
assertEquals(PhoneNumber.class, optional.get());
}
use of example.domain.PhoneNumber in project doma by domaframework.
the class ScalarInParameterTest method testGetDomainClass.
@Test
public void testGetDomainClass() {
DomainType<String, PhoneNumber> domainType = DomainTypeFactory.getDomainType(PhoneNumber.class, new ClassHelper() {
});
Scalar<String, PhoneNumber> scalar = domainType.createScalar();
ScalarInParameter<String, PhoneNumber> parameter = new ScalarInParameter<>(scalar);
Optional<Class<?>> optional = parameter.getDomainClass();
assertEquals(PhoneNumber.class, optional.get());
}
use of example.domain.PhoneNumber in project doma by domaframework.
the class ScalarsTest method testWrapDomain.
@Test
public void testWrapDomain() {
PhoneNumber phoneNumber = new PhoneNumber("123-456-789");
Supplier<Scalar<?, ?>> supplier = Scalars.wrap(phoneNumber, PhoneNumber.class, false, classHelper);
assertNotNull(supplier);
Scalar<?, ?> scalar = supplier.get();
assertEquals(phoneNumber, scalar.get());
assertEquals(phoneNumber, scalar.getAsNonOptional());
Wrapper<?> wrapper = scalar.getWrapper();
assertEquals(StringWrapper.class, wrapper.getClass());
assertEquals("123-456-789", wrapper.get());
}
Aggregations