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 testGenerateNewIdShouldReturnNewIdWhenInputLengthIsLongerThanTargetLength() {
    String longId = "long-test-id-string";

    String actual = generateNewId(longId, 13);

    assertThat(actual).matches("long-([a-zA-Z0-9]){8}");
  }