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);
}
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);
}
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")));
}
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());
}
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);
}
}
Aggregations