diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/com/iciql/test/IciqlSuite.java | 2 | ||||
-rw-r--r-- | tests/com/iciql/test/JoinTest.java | 23 |
2 files changed, 11 insertions, 14 deletions
diff --git a/tests/com/iciql/test/IciqlSuite.java b/tests/com/iciql/test/IciqlSuite.java index 3c98d69..000b1c8 100644 --- a/tests/com/iciql/test/IciqlSuite.java +++ b/tests/com/iciql/test/IciqlSuite.java @@ -170,6 +170,8 @@ public class IciqlSuite { db.dropTable(ProductInheritedAnnotation.class);
db.dropTable(ProductMixedAnnotation.class);
db.dropTable(SupportedTypes.class);
+ db.dropTable(JoinTest.UserId.class);
+ db.dropTable(JoinTest.UserNote.class);
return db;
}
diff --git a/tests/com/iciql/test/JoinTest.java b/tests/com/iciql/test/JoinTest.java index ceb2ad5..3d72ab8 100644 --- a/tests/com/iciql/test/JoinTest.java +++ b/tests/com/iciql/test/JoinTest.java @@ -39,6 +39,9 @@ public class JoinTest { @Before public void setup() { db = IciqlSuite.openNewDb(); + + db.insertAll(UserId.getList()); + db.insertAll(UserNote.getList()); } @After @@ -48,9 +51,6 @@ public class JoinTest { @Test public void testPrimitiveJoin() throws Exception { - db.insertAll(UserId.getList()); - db.insertAll(UserNote.getList()); - final UserId u = new UserId(); final UserNote n = new UserNote(); @@ -62,28 +62,23 @@ public class JoinTest { text = n.text; } }); - - db.dropTable(UserId.class); - db.dropTable(UserNote.class); - assertEquals(3, notes.size()); } @Test public void testJoin() throws Exception { - db.insertAll(UserId.getList()); - db.insertAll(UserNote.getList()); - final UserId u = new UserId(); final UserNote n = new UserNote(); // this query returns 1 UserId if the user has a note - List<UserId> users = db.from(u).innerJoin(n).on(u.id).is(n.userId).groupBy(u.id).where(u.id).is(2).select(); - - db.dropTable(UserId.class); - db.dropTable(UserNote.class); + // it's purpose is to confirm fluency/type-safety on a very simple + // join case where the main table is filtered/reduced by hits in a + // related table + + List<UserId> users = db.from(u).innerJoin(n).on(u.id).is(n.userId).where(u.id).is(2).selectDistinct(); assertEquals(1, users.size()); + assertEquals(2, users.get(0).id); } @IQTable |