private void addContent(JdbcContentPersistenceService tested, String sysContentType, String id) {
   Map<String, Object> content = new HashMap<String, Object>();
   content.put(ContentObjectFields.SYS_ID, id);
   content.put(ContentObjectFields.SYS_CONTENT_TYPE, sysContentType);
   content.put(ContentObjectFields.SYS_DESCRIPTION, "value " + id);
   tested.store(id, sysContentType, content);
 }
  @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));
  }
  @Test
  public void store_get_delete() throws Exception {
    JdbcContentPersistenceService tested = getTested();

    // case - get from noexisting table
    Assert.assertNull(tested.get("a-1", "tt"));

    String sysContentType = "testtype_1";
    Map<String, Object> content = null;
    // case - store into nonexisting table, nonexisting id
    tested.store("aaa-1", sysContentType, content);

    assertRowCount(tested, sysContentType, 1);
    Assert.assertNull(tested.get("aaa-1", sysContentType));

    // case - get nonexisting id from existing table
    Assert.assertNull(tested.get("a-1", sysContentType));

    // case - test persistence after commit
    assertRowCount(tested, sysContentType, 1);
    Assert.assertNull(tested.get("aaa-1", sysContentType));

    // case - store into existing table, nonexisting id
    content = new HashMap<String, Object>();
    content.put("testkey", "testvalue");
    tested.store("aaa-2", sysContentType, content);
    assertRowCount(tested, sysContentType, 2);
    Assert.assertNull(tested.get("aaa-1", sysContentType));
    TestUtils.assertJsonContent(
        "{\"testkey\" : \"testvalue\"}", tested.get("aaa-2", sysContentType));

    // case - store into existing table, existing id so update, sys_updated is Date instance
    content.put(ContentObjectFields.SYS_UPDATED, new Date(65463749865l));
    tested.store("aaa-1", sysContentType, content);
    assertRowCount(tested, sysContentType, 2);
    TestUtils.assertJsonContent(
        "{\"testkey\" : \"testvalue\", \"sys_updated\":\"1972-01-28T16:22:29.865Z\"}",
        tested.get("aaa-1", sysContentType));
    assertTableContent(
        tested,
        sysContentType,
        "aaa-1",
        SearchUtils.getISODateFormat().parse("1972-01-28T16:22:29.865+0000"));
    // case - store into existing table, existing id so update, sys_updated is ISO String instance
    content.put(ContentObjectFields.SYS_UPDATED, "1973-01-28T17:22:29.865+0100");
    tested.store("aaa-2", sysContentType, content);
    assertRowCount(tested, sysContentType, 2);
    TestUtils.assertJsonContent(
        "{\"testkey\" : \"testvalue\", \"sys_updated\":\"1973-01-28T17:22:29.865+0100\"}",
        tested.get("aaa-2", sysContentType));
    assertTableContent(
        tested,
        sysContentType,
        "aaa-2",
        SearchUtils.getISODateFormat().parse("1973-01-28T17:22:29.865+0100"));

    // case - store into existing table, existing id so update, sys_updated is invalid String
    // instance but no
    // exception and table is correctly filled
    content.put(ContentObjectFields.SYS_UPDATED, "sdfasdf");
    tested.store("aaa-2", sysContentType, content);
    assertRowCount(tested, sysContentType, 2);
    TestUtils.assertJsonContent(
        "{\"testkey\" : \"testvalue\", \"sys_updated\":\"sdfasdf\"}",
        tested.get("aaa-2", sysContentType));
    assertTableContent(tested, sysContentType, "aaa-2", null);

    // case - delete from nonexisting table
    tested.delete("aaa", "jj");

    // case - delete from existing table, nonexisting id
    tested.delete("a-1", sysContentType);
    assertRowCount(tested, sysContentType, 2);

    // case - delete existing id
    tested.delete("aaa-1", sysContentType);
    assertRowCount(tested, sysContentType, 1);
    Assert.assertNull(tested.get("aaa-1", sysContentType));
    Assert.assertNotNull(tested.get("aaa-2", sysContentType));
  }