@Test
public void testReleaseLead() {

  DBI dbi = new DBI(DB_URL);
  UUID reaperInstanceId = UUID.randomUUID();
  PostgresStorage storage = new PostgresStorage(reaperInstanceId, dbi);
  Assertions.assertThat(storage.isStorageConnected()).isTrue();
  Handle handle = dbi.open();
  handle.execute("DELETE from leader");
  UUID leaderIdForSelf = UUID.randomUUID();
  UUID leaderIdForOther = UUID.randomUUID();
  storage.takeLead(leaderIdForSelf);
  storage.takeLead(leaderIdForOther);
  List<UUID> fetchedLeaderIds = storage.getLeaders();
  Assertions.assertThat(fetchedLeaderIds.size()).isEqualTo(2);
  handle.createStatement("UPDATE leader SET reaper_instance_id = 0 WHERE leader_id = :id")
      .bind("id", UuidUtil.toSequenceId(leaderIdForOther))
      .execute();
  // test that releaseLead succeeds for entry where instance_id = self
  storage.releaseLead(leaderIdForSelf);
  fetchedLeaderIds = storage.getLeaders();
  Assertions.assertThat(fetchedLeaderIds.size()).isEqualTo(1);
  // test that releaseLead fails for entry where instance_id != self
  storage.releaseLead(leaderIdForOther);
  fetchedLeaderIds = storage.getLeaders();
  Assertions.assertThat(fetchedLeaderIds.size()).isEqualTo(1);
}