added tests

This commit is contained in:
Timo Westkämper 2012-07-03 23:02:31 +03:00
parent c9dc7b9899
commit b070f4069f
3 changed files with 13 additions and 0 deletions

View File

@ -20,6 +20,7 @@ import javax.annotation.Nullable;
import com.mysema.query.types.ConstantImpl;
import com.mysema.query.types.Expression;
import com.mysema.query.types.NullExpression;
import com.mysema.query.types.Operator;
import com.mysema.query.types.Ops;
@ -91,6 +92,10 @@ public final class CaseForEqBuilder<D> {
public <T> Cases<T,Expression<T>> then(T then){
return then(new ConstantImpl<T>(then));
}
public <T> Cases<T,Expression<T>> thenNull() {
return then((Expression<T>)NullExpression.DEFAULT);
}
public <T extends Number & Comparable<?>> Cases<T,NumberExpression<T>> then(T then){
return thenNumber(new ConstantImpl<T>(then));

View File

@ -86,4 +86,5 @@ public class CoalesceTest {
public void Desc() {
assertEquals("coalesce(firstname, xxx) DESC", firstname.coalesce("xxx").desc().toString());
}
}

View File

@ -54,6 +54,13 @@ public class SimpleExpressionTest {
assertEquals("str as alias", str.as("alias").toString());
assertEquals("str as alias", str.as(new StringPath("alias")).toString());
}
@Test
public void Case() {
SimpleExpression<String> str = new StringPath("str");
// nullif(str, 'xxx')
str.when("xxx").thenNull().otherwise(str);
}
@Test
public void Subclasses_Override_As() throws SecurityException, NoSuchMethodException{