mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#1100 - Refactor OrmQueryPlanKey to use string expression for where
This commit is contained in:
@@ -2,65 +2,65 @@ package io.ebeaninternal.server.expression;
|
||||
|
||||
import io.ebean.Expr;
|
||||
import io.ebean.Expression;
|
||||
import org.tests.model.basic.Order;
|
||||
import org.junit.Test;
|
||||
import org.tests.model.basic.Order;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class LogicExpressionTest extends BaseExpressionTest {
|
||||
|
||||
Expression eq(String propName, int value) {
|
||||
private Expression eq(String propName, int value) {
|
||||
return Expr.eq(propName, value);
|
||||
}
|
||||
|
||||
LogicExpression and(Expression a, Expression b) {
|
||||
private LogicExpression and(Expression a, Expression b) {
|
||||
return new LogicExpression.And(a, b);
|
||||
}
|
||||
|
||||
LogicExpression or(Expression a, Expression b) {
|
||||
private LogicExpression or(Expression a, Expression b) {
|
||||
return new LogicExpression.Or(a, b);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByPlan_when_same() {
|
||||
|
||||
assertThat(and(eq("a", 10), eq("b", 10))
|
||||
.isSameByPlan(and(eq("a", 10), eq("b", 10)))).isTrue();
|
||||
same(and(eq("a", 10), eq("b", 10))
|
||||
, and(eq("a", 10), eq("b", 10)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByPlan_when_diffBind_then_stillSame() {
|
||||
|
||||
assertThat(and(eq("a", 10), eq("b", 10))
|
||||
.isSameByPlan(and(eq("a", 20), eq("b", 20)))).isTrue();
|
||||
same(and(eq("a", 10), eq("b", 10))
|
||||
, and(eq("a", 20), eq("b", 20)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByPlan_when_diffExp1_then_diff() {
|
||||
|
||||
assertThat(and(eq("a", 10), eq("b", 10))
|
||||
.isSameByPlan(and(eq("c", 10), eq("b", 10)))).isFalse();
|
||||
different(and(eq("a", 10), eq("b", 10))
|
||||
, and(eq("c", 10), eq("b", 10)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByPlan_when_diffExp2_then_diff() {
|
||||
|
||||
assertThat(and(eq("a", 10), eq("b", 10))
|
||||
.isSameByPlan(and(eq("a", 10), eq("c", 10)))).isFalse();
|
||||
different(and(eq("a", 10), eq("b", 10))
|
||||
, and(eq("a", 10), eq("c", 10)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByPlan_when_diffType_then_diff() {
|
||||
|
||||
assertThat(or(eq("a", 10), eq("b", 10))
|
||||
.isSameByPlan(and(eq("a", 10), eq("c", 10)))).isFalse();
|
||||
different(or(eq("a", 10), eq("b", 10))
|
||||
, and(eq("a", 10), eq("c", 10)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByPlan_when_diffExpressionType() {
|
||||
|
||||
assertThat(or(eq("a", 10), eq("b", 10))
|
||||
.isSameByPlan(new NoopExpression())).isFalse();
|
||||
different(or(eq("a", 10), eq("b", 10))
|
||||
, new NoopExpression());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user