@Test public void checkAndEnsureTableExists() { JdbcContentPersistenceService tested = getTested(); Assert.assertFalse(tested.checkTableExists("table1")); Assert.assertFalse(tested.checkTableExists("table1")); tested.ensureTableExists("table1"); Assert.assertTrue(tested.checkTableExists("table1")); tested.ensureTableExists("table1"); Assert.assertTrue(tested.checkTableExists("table1")); Assert.assertTrue(tested.checkTableExists("table1")); Assert.assertFalse(tested.checkTableExists("table_2")); tested.ensureTableExists("table_2"); Assert.assertTrue(tested.checkTableExists("table_2")); Assert.assertTrue(tested.checkTableExists("table1")); }
@Test public void countRecords() { JdbcContentPersistenceService tested = getTested(); String CT = "count_test_type"; // case - nonexisting table Assert.assertEquals(0, tested.countRecords(CT)); // case - existing empty table tested.ensureTableExists(tested.getTableName(CT)); Assert.assertEquals(0, tested.countRecords(CT)); Map<String, Object> content = new HashMap<>(); tested.store("1", CT, content); Assert.assertEquals(1, tested.countRecords(CT)); tested.store("2", CT, content); tested.store("3", CT, content); tested.store("asdas", CT, content); Assert.assertEquals(4, tested.countRecords(CT)); }