use of com.querydsl.core.types.dsl.StringPath in project querydsl by querydsl.
the class ProjectionsTest method nested.
@Test
public void nested() {
StringPath str1 = Expressions.stringPath("str1");
StringPath str2 = Expressions.stringPath("str2");
StringPath str3 = Expressions.stringPath("str3");
FactoryExpression<Entity1> entity = Projections.constructor(Entity1.class, str1, str2);
FactoryExpression<Entity2> wrapper = Projections.constructor(Entity2.class, str3, entity);
FactoryExpression<Entity2> wrapped = FactoryExpressionUtils.wrap(wrapper);
Entity2 w = wrapped.newInstance("a", "b", "c");
assertEquals("a", w.arg1);
assertEquals("b", w.entity.arg1);
assertEquals("c", w.entity.arg2);
w = wrapped.newInstance("a", null, null);
assertEquals("a", w.arg1);
assertNotNull(w.entity);
w = wrapped.newInstance(null, null, null);
assertNotNull(w.entity);
}
use of com.querydsl.core.types.dsl.StringPath in project querydsl by querydsl.
the class ProjectionsTest method nestedSkipNulls.
@Test
public void nestedSkipNulls() {
StringPath str1 = Expressions.stringPath("str1");
StringPath str2 = Expressions.stringPath("str2");
StringPath str3 = Expressions.stringPath("str3");
FactoryExpression<Entity1> entity = Projections.constructor(Entity1.class, str1, str2).skipNulls();
FactoryExpression<Entity2> wrapper = Projections.constructor(Entity2.class, str3, entity);
FactoryExpression<Entity2> wrapped = FactoryExpressionUtils.wrap(wrapper);
Entity2 w = wrapped.newInstance("a", "b", "c");
assertEquals("a", w.arg1);
assertEquals("b", w.entity.arg1);
assertEquals("c", w.entity.arg2);
w = wrapped.newInstance("a", null, null);
assertEquals("a", w.arg1);
assertNull(w.entity);
w = wrapped.newInstance(null, null, null);
assertNull(w.entity);
}
use of com.querydsl.core.types.dsl.StringPath in project querydsl by querydsl.
the class GroupByMapTest method signature.
@Test
public void signature() {
StringPath str = Expressions.stringPath("str");
NumberPath<BigDecimal> bigd = Expressions.numberPath(BigDecimal.class, "bigd");
ResultTransformer<Map<String, SortedMap<BigDecimal, SortedMap<BigDecimal, Map<String, String>>>>> resultTransformer = GroupBy.groupBy(str).as(GroupBy.sortedMap(bigd, GroupBy.sortedMap(bigd, GroupBy.map(str, str), Ordering.natural().nullsLast()), Ordering.natural().nullsFirst()));
assertNotNull(resultTransformer);
}
use of com.querydsl.core.types.dsl.StringPath in project querydsl by querydsl.
the class SerializerBaseTest method test.
@Test
public void test() {
DummySerializer serializer = new DummySerializer(new JavaTemplates());
StringPath strPath = Expressions.stringPath("str");
// path
serializer.handle(strPath);
// operation
serializer.handle(strPath.isNotNull());
// long path
serializer.handle(new PathBuilder<Object>(Object.class, "p").getList("l", Map.class).get(0));
// constant
serializer.handle(ConstantImpl.create(""));
// custom
serializer.handle(ExpressionUtils.template(Object.class, "xxx", ConstantImpl.create("")));
}
use of com.querydsl.core.types.dsl.StringPath in project querydsl by querydsl.
the class NumberConversionsTest method number_conversion.
@Test
public void number_conversion() {
StringPath strPath = Expressions.stringPath("strPath");
NumberPath<Integer> intPath = Expressions.numberPath(Integer.class, "intPath");
QTuple qTuple = Projections.tuple(strPath, intPath);
NumberConversions<Tuple> conversions = new NumberConversions<Tuple>(qTuple);
Tuple tuple = conversions.newInstance("a", Long.valueOf(3));
assertEquals("a", tuple.get(strPath));
assertEquals(Integer.valueOf(3), tuple.get(intPath));
}
Aggregations