Search in sources :

Example 16 with StringPath

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);
}
Also used : StringPath(com.querydsl.core.types.dsl.StringPath) Test(org.junit.Test)

Example 17 with StringPath

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);
}
Also used : StringPath(com.querydsl.core.types.dsl.StringPath) Test(org.junit.Test)

Example 18 with StringPath

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);
}
Also used : StringPath(com.querydsl.core.types.dsl.StringPath) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 19 with StringPath

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("")));
}
Also used : JavaTemplates(com.querydsl.core.types.JavaTemplates) StringPath(com.querydsl.core.types.dsl.StringPath) Test(org.junit.Test)

Example 20 with StringPath

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));
}
Also used : QTuple(com.querydsl.core.types.QTuple) StringPath(com.querydsl.core.types.dsl.StringPath) QTuple(com.querydsl.core.types.QTuple) Tuple(com.querydsl.core.Tuple) Test(org.junit.Test)

Aggregations

StringPath (com.querydsl.core.types.dsl.StringPath)33 Test (org.junit.Test)33 DefaultQueryMetadata (com.querydsl.core.DefaultQueryMetadata)6 QueryMetadata (com.querydsl.core.QueryMetadata)6 Tuple (com.querydsl.core.Tuple)4 QTuple (com.querydsl.core.types.QTuple)2 LuceneSerializer (com.querydsl.lucene5.LuceneSerializer)2 Ignore (org.junit.Ignore)2 ExcludeIn (com.querydsl.core.testutil.ExcludeIn)1 JavaTemplates (com.querydsl.core.types.JavaTemplates)1 Predicate (com.querydsl.core.types.Predicate)1 BooleanExpression (com.querydsl.core.types.dsl.BooleanExpression)1 PhraseElement (com.querydsl.lucene5.PhraseElement)1 TermElement (com.querydsl.lucene5.TermElement)1 BigDecimal (java.math.BigDecimal)1