aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/com')
-rw-r--r--src/test/java/com/iciql/test/IciqlSuite.java3
-rw-r--r--src/test/java/com/iciql/test/ModelsTest.java13
-rw-r--r--src/test/java/com/iciql/test/NestedConditionsTest.java43
-rw-r--r--src/test/java/com/iciql/test/models/ProductAnnotationOnly.java5
4 files changed, 38 insertions, 26 deletions
diff --git a/src/test/java/com/iciql/test/IciqlSuite.java b/src/test/java/com/iciql/test/IciqlSuite.java
index 6ec61df..19b3d60 100644
--- a/src/test/java/com/iciql/test/IciqlSuite.java
+++ b/src/test/java/com/iciql/test/IciqlSuite.java
@@ -290,6 +290,9 @@ public class IciqlSuite {
} else if (isMySQL(db)) {
// MySQL does not have schemas
return null;
+ } else if (isSQLite(db)) {
+ // SQLite does not have schemas
+ return null;
}
return "PUBLIC";
diff --git a/src/test/java/com/iciql/test/ModelsTest.java b/src/test/java/com/iciql/test/ModelsTest.java
index c5ba27a..683e494 100644
--- a/src/test/java/com/iciql/test/ModelsTest.java
+++ b/src/test/java/com/iciql/test/ModelsTest.java
@@ -17,9 +17,9 @@
package com.iciql.test;
+import static com.iciql.test.IciqlSuite.assertEqualsIgnoreCase;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-import static com.iciql.test.IciqlSuite.assertEqualsIgnoreCase;
import java.sql.SQLException;
import java.text.MessageFormat;
@@ -69,10 +69,11 @@ public class ModelsTest {
@Test
public void testValidateModels() {
+ // SQLite metadata mapping in the JDBC driver needs improvement
String schemaName = IciqlSuite.getDefaultSchema(db);
DbInspector inspector = new DbInspector(db);
- validateModel(inspector, schemaName, new ProductAnnotationOnly(), 2);
- validateModel(inspector, schemaName, new ProductMixedAnnotation(), 4);
+ validateModel(inspector, schemaName, new ProductAnnotationOnly(), IciqlSuite.isSQLite(db) ? 5 : 2);
+ validateModel(inspector, schemaName, new ProductMixedAnnotation(), IciqlSuite.isSQLite(db) ? 6 : 4);
}
private void validateModel(DbInspector inspector, String schemaName, Object o, int expected) {
@@ -89,7 +90,9 @@ public class ModelsTest {
}
}
- if (StringUtils.isNullOrEmpty(schemaName)) {
+ if (IciqlSuite.isSQLite(db)) {
+ assertEquals(sb.toString(), expected, remarks.size());
+ } else if (StringUtils.isNullOrEmpty(schemaName)) {
// no schema expected
assertEquals(sb.toString(), expected - 1, remarks.size());
} else {
@@ -137,6 +140,8 @@ public class ModelsTest {
// MySQL uses timestamp default values like
// 0000-00-00 00:00:00 and CURRENT_TIMESTAMP
assertEquals(1673, models.get(0).length());
+ } else if (dbName.equals("SQLite")) {
+ assertEquals(1566, models.get(0).length());
} else {
// unknown database
assertEquals(0, models.get(0).length());
diff --git a/src/test/java/com/iciql/test/NestedConditionsTest.java b/src/test/java/com/iciql/test/NestedConditionsTest.java
index 7a20468..6676c9e 100644
--- a/src/test/java/com/iciql/test/NestedConditionsTest.java
+++ b/src/test/java/com/iciql/test/NestedConditionsTest.java
@@ -80,36 +80,37 @@ public class NestedConditionsTest {
String Customer = db.getDialect().prepareTableName(null, "Customer");
String customerId = db.getDialect().prepareColumnName("customerId");
String region = db.getDialect().prepareColumnName("region");
+ String trueValue = db.getDialect().prepareStringParameter(true);
assertEquals(
- String.format("SELECT * FROM %s WHERE (true)", Customer),
+ String.format("SELECT * FROM %s WHERE (%s)", Customer, trueValue),
search(null, (String[]) null));
assertEquals(
- String.format("SELECT * FROM %s WHERE (true)", Customer),
+ String.format("SELECT * FROM %s WHERE (%s)", Customer, trueValue),
search(null, new String[0]));
assertEquals(
- String.format("SELECT * FROM %s WHERE (true) AND ( %s = '0001' )",
- Customer, customerId),
+ String.format("SELECT * FROM %s WHERE (%s) AND ( %s = '0001' )",
+ Customer, trueValue, customerId),
search(null, "0001"));
assertEquals(
- String.format("SELECT * FROM %s WHERE (true) AND ( %s = '0001' OR %s = '0002' )",
- Customer, customerId, customerId),
+ String.format("SELECT * FROM %s WHERE (%s) AND ( %s = '0001' OR %s = '0002' )",
+ Customer, trueValue, customerId, customerId),
search(null, "0001", "0002"));
assertEquals(
- String.format("SELECT * FROM %s WHERE (true) AND %s = 'JP'",
- Customer, region),
+ String.format("SELECT * FROM %s WHERE (%s) AND %s = 'JP'",
+ Customer, trueValue, region),
search(Region.JP, (String[]) null));
assertEquals(
- String.format("SELECT * FROM %s WHERE (true) AND %s = 'JP'",
- Customer, region),
+ String.format("SELECT * FROM %s WHERE (%s) AND %s = 'JP'",
+ Customer, trueValue, region),
search(Region.JP, new String[0]));
assertEquals(
- String.format("SELECT * FROM %s WHERE (true) AND ( %s = '0001' ) AND %s = 'JP'",
- Customer, customerId, region),
+ String.format("SELECT * FROM %s WHERE (%s) AND ( %s = '0001' ) AND %s = 'JP'",
+ Customer, trueValue, customerId, region),
search(Region.JP, "0001"));
assertEquals(
- String.format("SELECT * FROM %s WHERE (true) AND ( %s = '0001' OR %s = '0002' ) AND %s = 'JP'",
- Customer, customerId, customerId, region),
+ String.format("SELECT * FROM %s WHERE (%s) AND ( %s = '0001' OR %s = '0002' ) AND %s = 'JP'",
+ Customer, trueValue, customerId, customerId, region),
search(Region.JP, "0001", "0002"));
}
@@ -165,12 +166,14 @@ public class NestedConditionsTest {
String Customer = db.getDialect().prepareTableName(null, "Customer");
String customerId = db.getDialect().prepareColumnName("customerId");
String region = db.getDialect().prepareColumnName("region");
+ String trueValue = db.getDialect().prepareStringParameter(true);
+ String falseValue = db.getDialect().prepareStringParameter(false);
final Customer model = new Customer();
assertEquals(
- String.format("SELECT * FROM %s WHERE (true) AND %s = '0001' AND ( %s = 'CA' OR %s = 'LA' )",
- Customer, customerId, region, region),
+ String.format("SELECT * FROM %s WHERE (%s) AND %s = '0001' AND ( %s = 'CA' OR %s = 'LA' )",
+ Customer, trueValue, customerId, region, region),
db.from(model).where(new And<Customer>(db, model) {{
@@ -185,8 +188,8 @@ public class NestedConditionsTest {
.toSQL());
assertEquals(
- String.format("SELECT * FROM %s WHERE (false) OR %s = '0001' OR ( %s = '0002' AND %s = 'LA' )",
- Customer, customerId, customerId, region),
+ String.format("SELECT * FROM %s WHERE (%s) OR %s = '0001' OR ( %s = '0002' AND %s = 'LA' )",
+ Customer, falseValue, customerId, customerId, region),
db.from(model).where(new Or<Customer>(db, model) {{
@@ -202,8 +205,8 @@ public class NestedConditionsTest {
.toSQL());
assertEquals(
- String.format("SELECT * FROM %s WHERE (false) OR ( %s = '0001' AND %s = 'WA' ) OR ( %s = '0002' AND %s = 'LA' )",
- Customer, customerId, region, customerId, region),
+ String.format("SELECT * FROM %s WHERE (%s) OR ( %s = '0001' AND %s = 'WA' ) OR ( %s = '0002' AND %s = 'LA' )",
+ Customer, falseValue, customerId, region, customerId, region),
db.from(model).where(new Or<Customer>(db, model) {{
diff --git a/src/test/java/com/iciql/test/models/ProductAnnotationOnly.java b/src/test/java/com/iciql/test/models/ProductAnnotationOnly.java
index 1f6b4e2..ea5856b 100644
--- a/src/test/java/com/iciql/test/models/ProductAnnotationOnly.java
+++ b/src/test/java/com/iciql/test/models/ProductAnnotationOnly.java
@@ -30,13 +30,13 @@ import com.iciql.Iciql.IndexType;
* A table containing product data.
*/
-@IQTable(name = "AnnotatedProduct", primaryKey = "id")
+@IQTable(name = "AnnotatedProduct")
@IQIndexes({ @IQIndex({ "name", "cat" }), @IQIndex(name = "nameidx", type = IndexType.HASH, value = "name") })
public class ProductAnnotationOnly {
public String unmappedField;
- @IQColumn(name = "id", autoIncrement = true)
+ @IQColumn(name = "id", autoIncrement = true, primaryKey = true)
public Long productId;
@IQColumn(name = "cat", length = 15, trim = true)
@@ -87,6 +87,7 @@ public class ProductAnnotationOnly {
return Arrays.asList(list);
}
+ @Override
public String toString() {
return productName + ": " + unitsInStock;
}