@Test
public void testTakeLead() {

  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");
  int numEntries = 5;
  Set<UUID> leaderIds = new HashSet<>();
  for (int i = 0; i < numEntries; i++) {
    UUID msbLeaderId = UuidUtil.fromSequenceId(UuidUtil.toSequenceId(UUID.randomUUID()));
    leaderIds.add(msbLeaderId);
  }
  // insert all five leader entries
  for (UUID leaderId : leaderIds) {
    boolean result = storage.takeLead(leaderId);
    Assertions.assertThat(result).isEqualTo(true);
  }
  // make sure fetched leaders has all the inserted leaders
  List<UUID> fetchedLeaderIds = storage.getLeaders();
  for (UUID fetchedLeaderId : fetchedLeaderIds) {
    Assertions.assertThat(leaderIds.contains(fetchedLeaderId)).isTrue();
  }
}