public static String generateNewId(String id, int targetLength) {
    if (id.length() <= targetLength) {
      return id;
    }

    if (targetLength <= 8) {
      throw new IllegalArgumentException("targetLength must be greater than 8");
    }

    HashFunction hashFunction = goodFastHash(32);
    String hash = hashFunction.hashUnencodedChars(id).toString();
    return id.substring(0, targetLength - hash.length() - 1) + "-" + hash;
  }
@Test
  public void testGenerateNewIdShouldThrowExceptionWhenTargetLengthIsNotGreaterThanEight() {
    String id = "long-test-id";

    assertThrows(IllegalArgumentException.class, () -> generateNewId(id, 8));
  }