@Test
public void testLastProjectCommitShaQuery() {

    List<Map<String, Object>> result;
    // No commit means no result
    result = persistence.query(queries.lastProjectCommitShaQuery(projectId));
    assertTrue(result.isEmpty());
    Commit commit = generateCommit("sha", 1);
    executeSuccess(queries.commitInsertionStatement(projectId, commit, GitDiff.EMPTY));
    // Only commit is returned
    result = persistence.query(queries.lastProjectCommitShaQuery(projectId));
    assertEquals(commit.sha, result.get(0).get("sha1"));
    // Most advanced ordinal commit is returned
    Commit fifthOrdinal = generateCommit("anotherSha", 5);
    executeSuccess(queries.commitInsertionStatement(projectId, fifthOrdinal, GitDiff.EMPTY));
    result = persistence.query(queries.lastProjectCommitShaQuery(projectId));
    assertEquals(fifthOrdinal.sha, result.get(0).get("sha1"));
    // Most advanced ordinal commit is kept
    Commit fourthOrdinal = generateCommit("yetAnotherSha", 4);
    executeSuccess(queries.commitInsertionStatement(projectId, fourthOrdinal, GitDiff.EMPTY));
    result = persistence.query(queries.lastProjectCommitShaQuery(projectId));
    assertEquals(fifthOrdinal.sha, result.get(0).get("sha1"));
}