-
-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#355 - ENH: Add notIn(...) expressions. Just to make life easier in t…
…hose cases
- Loading branch information
Showing
9 changed files
with
237 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
src/test/java/com/avaje/ebeaninternal/server/expression/InExpressionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package com.avaje.ebeaninternal.server.expression; | ||
|
||
import com.avaje.ebeaninternal.api.HashQueryPlanBuilder; | ||
import org.junit.Test; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
public class InExpressionTest { | ||
|
||
|
||
@Test | ||
public void queryPlanHash_given_diffPropertyName_should_differentPlanHash() throws Exception { | ||
|
||
List<Integer> values = values(42, 92); | ||
|
||
InExpression ex1 = new InExpression("foo", values, false); | ||
InExpression ex2 = new InExpression("bar", values, false); | ||
|
||
HashQueryPlanBuilder b1 = new HashQueryPlanBuilder(); | ||
ex1.queryPlanHash(null, b1); | ||
|
||
HashQueryPlanBuilder b2 = new HashQueryPlanBuilder(); | ||
ex2.queryPlanHash(null, b2); | ||
|
||
assertNotEquals(b1.build(), b2.build()); | ||
} | ||
|
||
@Test | ||
public void queryPlanHash_given_diffBindCount_should_differentPlanHash() throws Exception { | ||
|
||
List<Integer> values1 = values(42, 92); | ||
List<Integer> values2 = values(42, 92, 82); | ||
|
||
InExpression ex1 = new InExpression("foo", values1, false); | ||
InExpression ex2 = new InExpression("foo", values2, false); | ||
|
||
HashQueryPlanBuilder b1 = new HashQueryPlanBuilder(); | ||
ex1.queryPlanHash(null, b1); | ||
|
||
HashQueryPlanBuilder b2 = new HashQueryPlanBuilder(); | ||
ex2.queryPlanHash(null, b2); | ||
|
||
assertNotEquals(b1.build(), b2.build()); | ||
} | ||
|
||
@Test | ||
public void queryPlanHash_given_diffNotFlag_should_differentPlanHash() throws Exception { | ||
|
||
List<Integer> values = values(42, 92); | ||
|
||
InExpression ex1 = new InExpression("foo", values, true); | ||
InExpression ex2 = new InExpression("foo", values, false); | ||
|
||
HashQueryPlanBuilder b1 = new HashQueryPlanBuilder(); | ||
ex1.queryPlanHash(null, b1); | ||
|
||
HashQueryPlanBuilder b2 = new HashQueryPlanBuilder(); | ||
ex2.queryPlanHash(null, b2); | ||
|
||
assertNotEquals(b1.build(), b2.build()); | ||
} | ||
|
||
@Test | ||
public void queryPlanHash_given_sameNotFlag_should_samePlanHash() throws Exception { | ||
|
||
List<Integer> values = values(42, 92); | ||
|
||
InExpression ex1 = new InExpression("foo", values, true); | ||
InExpression ex2 = new InExpression("foo", values, true); | ||
|
||
HashQueryPlanBuilder b1 = new HashQueryPlanBuilder(); | ||
ex1.queryPlanHash(null, b1); | ||
|
||
HashQueryPlanBuilder b2 = new HashQueryPlanBuilder(); | ||
ex2.queryPlanHash(null, b2); | ||
|
||
assertEquals(b1.build(), b2.build()); | ||
} | ||
|
||
List<Integer> values(int... vals) { | ||
ArrayList list = new ArrayList<Integer>(); | ||
for (int i = 0; i < vals.length; i++) { | ||
list.add(vals[i]); | ||
} | ||
return list; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters