Search in sources :

Example 6 with StringPath

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

the class EnumConversionTest method illegal.

@Test(expected = IllegalArgumentException.class)
public void illegal() {
    StringPath string = Expressions.stringPath("path");
    EnumConversion<String> conv = new EnumConversion<String>(string);
    fail("EnumConversion successfully created for a non-enum type");
    conv.newInstance(0);
}
Also used : StringPath(com.querydsl.core.types.dsl.StringPath) Test(org.junit.Test)

Example 7 with StringPath

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

the class JDOQLTemplatesTest method concat.

@Test
public void concat() {
    StringPath a = Expressions.stringPath("a");
    StringPath b = Expressions.stringPath("b");
    StringPath c = Expressions.stringPath("c");
    Expression<?> expr = a.append(b).toLowerCase();
    String str = new JDOQLSerializer(JDOQLTemplates.DEFAULT, c).handle(expr).toString();
    assertEquals("(a + b).toLowerCase()", str);
}
Also used : StringPath(com.querydsl.core.types.dsl.StringPath) Test(org.junit.Test)

Example 8 with StringPath

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

the class StringOperationsTest method indexOf2.

@Test
public void indexOf2() {
    StringPath str = QCat.cat.name;
    assertToString("substring(cat.name,1,locate(?1,cat.name)-1 - ?2)", str.substring(0, str.indexOf("x")));
}
Also used : StringPath(com.querydsl.core.types.dsl.StringPath) Test(org.junit.Test)

Example 9 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) Test(org.junit.Test)

Example 10 with StringPath

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

the class MongodbQueryTest method various.

@Test
public void various() {
    ListPath<Address, QAddress> list = user.addresses;
    StringPath str = user.lastName;
    List<Predicate> predicates = new ArrayList<Predicate>();
    predicates.add(str.between("a", "b"));
    predicates.add(str.contains("a"));
    predicates.add(str.containsIgnoreCase("a"));
    predicates.add(str.endsWith("a"));
    predicates.add(str.endsWithIgnoreCase("a"));
    predicates.add(str.eq("a"));
    predicates.add(str.equalsIgnoreCase("a"));
    predicates.add(str.goe("a"));
    predicates.add(str.gt("a"));
    predicates.add(str.in("a", "b", "c"));
    predicates.add(str.isEmpty());
    predicates.add(str.isNotNull());
    predicates.add(str.isNull());
    predicates.add(str.like("a"));
    predicates.add(str.loe("a"));
    predicates.add(str.lt("a"));
    predicates.add(str.matches("a"));
    predicates.add(str.ne("a"));
    predicates.add(str.notBetween("a", "b"));
    predicates.add(str.notIn("a", "b", "c"));
    predicates.add(str.startsWith("a"));
    predicates.add(str.startsWithIgnoreCase("a"));
    predicates.add(list.isEmpty());
    predicates.add(list.isNotEmpty());
    for (Predicate predicate : predicates) {
        long count1 = where(predicate).fetchCount();
        long count2 = where(predicate.not()).fetchCount();
        assertEquals(predicate.toString(), 4, count1 + count2);
    }
}
Also used : StringPath(com.querydsl.core.types.dsl.StringPath) Predicate(com.querydsl.core.types.Predicate) 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