diff options
author | James Moger <james.moger@gmail.com> | 2012-01-04 22:12:56 -0500 |
---|---|---|
committer | James Moger <james.moger@gmail.com> | 2012-01-04 22:12:56 -0500 |
commit | 0932e559b420d46f8394a464c466804c1df0ede1 (patch) | |
tree | 822a49e35ce8ff3d7dd37cff84cf9e19bce0e6ae /tests | |
parent | cc0c4f0e0b632ebfb1635e5ed2fe9a2119240157 (diff) | |
download | iciql-0932e559b420d46f8394a464c466804c1df0ede1.tar.gz iciql-0932e559b420d46f8394a464c466804c1df0ede1.zip |
Disallow multiple instances of an enum within a model class
Diffstat (limited to 'tests')
-rw-r--r-- | tests/com/iciql/test/EnumsTest.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/com/iciql/test/EnumsTest.java b/tests/com/iciql/test/EnumsTest.java index d010683..d8a0589 100644 --- a/tests/com/iciql/test/EnumsTest.java +++ b/tests/com/iciql/test/EnumsTest.java @@ -17,6 +17,7 @@ package com.iciql.test;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import java.util.List;
@@ -25,6 +26,7 @@ import org.junit.Before; import org.junit.Test;
import com.iciql.Db;
+import com.iciql.IciqlException;
import com.iciql.test.models.EnumModels;
import com.iciql.test.models.EnumModels.EnumIdModel;
import com.iciql.test.models.EnumModels.EnumOrdinalModel;
@@ -108,4 +110,20 @@ public class EnumsTest { list = db.from(e).where(e.tree()).between(Tree.MAPLE).and(Tree.PINE).select();
assertEquals(3, list.size());
}
+
+ @Test
+ public void testMultipleEnumInstances() {
+ BadEnums b = new BadEnums();
+ try {
+ db.from(b).where(b.tree1).is(Tree.BIRCH).and (b.tree2).is(Tree.MAPLE).getSQL();
+ assertTrue("Failed to detect multiple Tree fields?!", false);
+ } catch (IciqlException e) {
+ assertTrue(e.getMessage(), e.getMessage().startsWith("Can not explicitly reference Tree"));
+ }
+ }
+
+ public static class BadEnums {
+ Tree tree1 = Tree.BIRCH;
+ Tree tree2 = Tree.MAPLE;
+ }
}
|