summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJames Moger <james.moger@gmail.com>2011-12-09 16:42:59 -0500
committerJames Moger <james.moger@gmail.com>2011-12-09 16:42:59 -0500
commit876c4e51578dfa7bd98956d2f07ae7498a70629c (patch)
treee23df1f9a29cb027c55a95e50f019e7f6d717d08 /tests
parent407ea16f9f8f6d3bd5135783d98b63c0e4704609 (diff)
downloadiciql-876c4e51578dfa7bd98956d2f07ae7498a70629c.tar.gz
iciql-876c4e51578dfa7bd98956d2f07ae7498a70629c.zip
Columns mapped by name in result set instead of index. Disallow multiple
primitive bools in a model WITH explicit referencing.
Diffstat (limited to 'tests')
-rw-r--r--tests/com/iciql/test/PrimitivesTest.java17
-rw-r--r--tests/com/iciql/test/SamplesTest.java5
-rw-r--r--tests/com/iciql/test/models/MultipleBoolsModel.java40
3 files changed, 61 insertions, 1 deletions
diff --git a/tests/com/iciql/test/PrimitivesTest.java b/tests/com/iciql/test/PrimitivesTest.java
index be2b726..3d3811e 100644
--- a/tests/com/iciql/test/PrimitivesTest.java
+++ b/tests/com/iciql/test/PrimitivesTest.java
@@ -25,6 +25,8 @@ import java.util.List;
import org.junit.Test;
import com.iciql.Db;
+import com.iciql.IciqlException;
+import com.iciql.test.models.MultipleBoolsModel;
import com.iciql.test.models.PrimitivesModel;
/**
@@ -82,4 +84,19 @@ public class PrimitivesTest {
db.close();
}
+
+ @Test
+ public void testMultipleBooleans() {
+ Db db = IciqlSuite.openNewDb();
+ db.insertAll(MultipleBoolsModel.getList());
+
+ MultipleBoolsModel m = new MultipleBoolsModel();
+ try {
+ db.from(m).where(m.a).is(true).select();
+ assertTrue(false);
+ } catch (IciqlException e) {
+ assertTrue(true);
+ }
+ db.close();
+ }
}
diff --git a/tests/com/iciql/test/SamplesTest.java b/tests/com/iciql/test/SamplesTest.java
index 17c2151..5c7ffc8 100644
--- a/tests/com/iciql/test/SamplesTest.java
+++ b/tests/com/iciql/test/SamplesTest.java
@@ -39,6 +39,8 @@ import org.junit.Test;
import com.iciql.Db;
import com.iciql.Filter;
+import com.iciql.Iciql.IQColumn;
+import com.iciql.Iciql.IQFunction;
import com.iciql.test.models.ComplexObject;
import com.iciql.test.models.Customer;
import com.iciql.test.models.Order;
@@ -161,6 +163,7 @@ public class SamplesTest {
public static class ProductPrice {
public String productName;
public String category;
+ @IQColumn(name = "unitPrice")
public Double price;
}
@@ -406,6 +409,7 @@ public class SamplesTest {
*/
public static class ProductGroup {
public String category;
+ @IQFunction
public Long productCount;
public String toString() {
@@ -432,7 +436,6 @@ public class SamplesTest {
productCount = count();
}
});
-
assertEquals("[Beverages:2, Condiments:5, Meat/Poultry:1, Produce:1, Seafood:1]", list.toString());
}
diff --git a/tests/com/iciql/test/models/MultipleBoolsModel.java b/tests/com/iciql/test/models/MultipleBoolsModel.java
new file mode 100644
index 0000000..7bc429c
--- /dev/null
+++ b/tests/com/iciql/test/models/MultipleBoolsModel.java
@@ -0,0 +1,40 @@
+package com.iciql.test.models;
+
+import java.util.Arrays;
+import java.util.List;
+
+import com.iciql.Iciql.IQColumn;
+import com.iciql.Iciql.IQTable;
+
+/**
+ * Model class to test the runtime exception of too many primitive boolean
+ * fields in the model.
+ *
+ * @author James Moger
+ *
+ */
+@IQTable
+public class MultipleBoolsModel {
+
+ @IQColumn(autoIncrement = true, primaryKey = true)
+ public int id;
+
+ @IQColumn
+ public boolean a;
+
+ @IQColumn
+ public boolean b;
+
+ public MultipleBoolsModel() {
+ }
+
+ public MultipleBoolsModel(boolean a, boolean b) {
+ this.a = a;
+ this.b = b;
+ }
+
+ public static List<MultipleBoolsModel> getList() {
+ return Arrays.asList(new MultipleBoolsModel(true, true), new MultipleBoolsModel(true, false),
+ new MultipleBoolsModel(true, false), new MultipleBoolsModel(false, false));
+ }
+} \ No newline at end of file