### Question:
IdGenerator { public static String generateIdUsingHash(final String value) { MessageDigest converter; try { converter = MessageDigest.getInstance("SHA1"); String id = new String(Hex.encodeHex(converter.digest(value.getBytes()))); return id.substring(0, 8); } catch (final NoSuchAlgorithmException e) { LOGGER.info("Can't generate SHA1 hash code", e); throw new RuntimeException("Can't generate SHA1 hash code", e); } }  static String generateRandomId(); static String generateIdUsingHash(final String value);  }### Answer:
@Test void allHashesAreOfLength8() { assertEquals(8, IdGenerator.generateIdUsingHash("").length()); assertEquals(8, IdGenerator.generateIdUsingHash("hello").length()); assertEquals(8, IdGenerator.generateIdUsingHash("hello world").length()); }
@Test void hashOfNullString_throwsException() { assertThrows(NullPointerException.class, () -> IdGenerator.generateIdUsingHash(null)); }
@Test void hashOfEmptyString() { assertEquals("da39a3ee", IdGenerator.generateIdUsingHash("")); }
@Test void hashOfNonEmptyString() { assertEquals("3e3de94a", IdGenerator.generateIdUsingHash("Scenarioo")); }