### Question:
KeyUtils { public static boolean isValidKey(String key) { return key == null || EXPECTED_KEY_PATTERN.matcher(key).matches(); }  static boolean isValidKey(String key); static void assertValidKey(String key); static final Pattern UUID_PATTERN; static final Pattern EXPECTED_KEY_PATTERN; }### Answer:
@Test public void testValidKeys() { assertTrue(KeyUtils.isValidKey(UUID.randomUUID().toString())); assertTrue(KeyUtils.isValidKey("01234567-1234-1234-aAAa-123456789012")); assertTrue(KeyUtils.isValidKey("01234567-1234-1234-aAAf-123456789012")); assertTrue(KeyUtils.isValidKey("f:" + UUID.randomUUID() + ":dsadsada")); assertTrue(KeyUtils.isValidKey("f:01234567-1234-1234-aAAa-123456789012:dsadsada")); assertTrue(KeyUtils.isValidKey("f:a1234567-1234-1234-aAAa-123456789012:dsadsada")); }
@Test public void testInvalidKeys() { assertFalse(KeyUtils.isValidKey("any string")); assertFalse(KeyUtils.isValidKey("0")); assertFalse(KeyUtils.isValidKey("01234567-1234-1234-aAAg-123456789012a")); assertFalse(KeyUtils.isValidKey("z1234567-1234-1234-aAAa-123456789012")); assertFalse(KeyUtils.isValidKey("f:g1234567-1234-1234-aAAa-123456789012:dsadsada")); assertFalse(KeyUtils.isValidKey("g:a1234567-1234-1234-aAAa-123456789012:dsadsada")); assertFalse(KeyUtils.isValidKey("f:a1234567-1234-1234-aAAa-123456789012")); }