Search in sources :

Example 21 with StringPath

use of com.querydsl.core.types.dsl.StringPath in project querydsl by querydsl.

the class NumberConversionsTest method safe_number_conversion.

@Test
public void safe_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);
    assertNotNull(conversions.newInstance(1, 2));
}
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)

Example 22 with StringPath

use of com.querydsl.core.types.dsl.StringPath in project querydsl by querydsl.

the class DeepPopulationTest method deep_population_via_qBean.

@Test
public void deep_population_via_qBean() {
    StringPath name = Expressions.stringPath("name");
    StringPath id = Expressions.stringPath("id");
    QBean<Entity2> entity2Bean = new QBean<Entity2>(Entity2.class, name, id);
    QBean<Entity1> entity1Bean = new QBean<Entity1>(Entity1.class, Collections.singletonMap("entity2", entity2Bean));
    Entity1 entity1 = FactoryExpressionUtils.wrap(entity1Bean).newInstance("nameX", "idX");
    assertEquals("nameX", entity1.getEntity2().getName());
    assertEquals("idX", entity1.getEntity2().getId());
}
Also used : StringPath(com.querydsl.core.types.dsl.StringPath) Test(org.junit.Test)

Example 23 with StringPath

use of com.querydsl.core.types.dsl.StringPath in project querydsl by querydsl.

the class DeepPopulationTest method deep_population_via_qTuple.

@Test
public void deep_population_via_qTuple() {
    StringPath name = Expressions.stringPath("name");
    StringPath id = Expressions.stringPath("id");
    QBean<Entity2> entity2Bean = new QBean<Entity2>(Entity2.class, name, id);
    QTuple tupleExpr = new QTuple(entity2Bean);
    Tuple tuple = FactoryExpressionUtils.wrap(tupleExpr).newInstance("nameX", "idX");
    assertEquals("nameX", tuple.get(entity2Bean).getName());
    assertEquals("idX", tuple.get(entity2Bean).getId());
}
Also used : StringPath(com.querydsl.core.types.dsl.StringPath) Tuple(com.querydsl.core.Tuple) Test(org.junit.Test)

Example 24 with StringPath

use of com.querydsl.core.types.dsl.StringPath in project querydsl by querydsl.

the class PhraseElementTest method test.

@Test
public void test() {
    StringPath title = Expressions.stringPath("title");
    LuceneSerializer serializer = new LuceneSerializer(false, false);
    QueryMetadata metadata = new DefaultQueryMetadata();
    assertEquals("title:Hello World", serializer.toQuery(title.eq("Hello World"), metadata).toString());
    assertEquals("title:\"Hello World\"", serializer.toQuery(title.eq(new PhraseElement("Hello World")), metadata).toString());
}
Also used : QueryMetadata(com.querydsl.core.QueryMetadata) DefaultQueryMetadata(com.querydsl.core.DefaultQueryMetadata) DefaultQueryMetadata(com.querydsl.core.DefaultQueryMetadata) StringPath(com.querydsl.core.types.dsl.StringPath) PhraseElement(com.querydsl.lucene5.PhraseElement) LuceneSerializer(com.querydsl.lucene5.LuceneSerializer) Test(org.junit.Test)

Example 25 with StringPath

use of com.querydsl.core.types.dsl.StringPath in project querydsl by querydsl.

the class TermElementTest method test.

@Test
public void test() {
    StringPath title = Expressions.stringPath("title");
    LuceneSerializer serializer = new LuceneSerializer(false, true);
    QueryMetadata metadata = new DefaultQueryMetadata();
    assertEquals("title:\"Hello World\"", serializer.toQuery(title.eq("Hello World"), metadata).toString());
    assertEquals("title:Hello World", serializer.toQuery(title.eq(new TermElement("Hello World")), metadata).toString());
}
Also used : QueryMetadata(com.querydsl.core.QueryMetadata) DefaultQueryMetadata(com.querydsl.core.DefaultQueryMetadata) DefaultQueryMetadata(com.querydsl.core.DefaultQueryMetadata) TermElement(com.querydsl.lucene5.TermElement) StringPath(com.querydsl.core.types.dsl.StringPath) LuceneSerializer(com.querydsl.lucene5.LuceneSerializer) 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