use of com.querydsl.core.types.dsl.StringPath in project querydsl by querydsl.
the class ProjectionsTest method nestedSkipNulls2.
@Test
public void nestedSkipNulls2() {
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).skipNulls();
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);
}
use of com.querydsl.core.types.dsl.StringPath in project querydsl by querydsl.
the class ExpressionUtilsTest method regexToLike.
@Test
public void regexToLike() {
assertEquals("%", like(ConstantImpl.create(".*")));
assertEquals("_", like(ConstantImpl.create(".")));
assertEquals(".", like(ConstantImpl.create("\\.")));
StringPath path = Expressions.stringPath("path");
assertEquals("path + %", like(path.append(".*")));
assertEquals("% + path", like(path.prepend(".*")));
assertEquals("path + _", like(path.append(".")));
assertEquals("_ + path", like(path.prepend(".")));
}
use of com.querydsl.core.types.dsl.StringPath in project querydsl by querydsl.
the class ExpressionUtilsTest method likeToRegexSpeed.
@Test
@Ignore
public void likeToRegexSpeed() {
// 4570
StringPath path = Expressions.stringPath("path");
final int iterations = 1000000;
long start = System.currentTimeMillis();
for (int i = 0; i < iterations; i++) {
regex(ConstantImpl.create("%"));
regex(ConstantImpl.create("abc%"));
regex(ConstantImpl.create("%abc"));
regex(ConstantImpl.create("_"));
regex(path.append("%"));
regex(path.prepend("%"));
regex(path.append("_"));
regex(path.prepend("_"));
}
long duration = System.currentTimeMillis() - start;
System.err.println(duration);
}
use of com.querydsl.core.types.dsl.StringPath in project querydsl by querydsl.
the class ExpressionUtilsTest method likeToRegex.
@Test
public void likeToRegex() {
assertEquals(".*", regex(ConstantImpl.create("%")));
assertEquals("^abc.*", regex(ConstantImpl.create("abc%")));
assertEquals(".*abc$", regex(ConstantImpl.create("%abc")));
assertEquals("^.$", regex(ConstantImpl.create("_")));
StringPath path = Expressions.stringPath("path");
assertEquals("path + .*", regex(path.append("%")));
assertEquals(".* + path", regex(path.prepend("%")));
assertEquals("path + .", regex(path.append("_")));
assertEquals(". + path", regex(path.prepend("_")));
}
use of com.querydsl.core.types.dsl.StringPath in project querydsl by querydsl.
the class ExpressionUtilsTest method regexToLikeSpeed.
@Test
@Ignore
public void regexToLikeSpeed() {
// 3255
StringPath path = Expressions.stringPath("path");
final int iterations = 1000000;
long start = System.currentTimeMillis();
for (int i = 0; i < iterations; i++) {
like(ConstantImpl.create(".*"));
like(ConstantImpl.create("."));
like(path.append(".*"));
like(path.prepend(".*"));
like(path.append("."));
like(path.prepend("."));
}
long duration = System.currentTimeMillis() - start;
System.err.println(duration);
}
Aggregations