### Question:
StaticRSAKeyProvider implements RSAKeyProvider { @SneakyThrows(NoSuchAlgorithmException.class) static RSAPublicKey parsePubKey(String key) throws InvalidKeySpecException { String keyContent = key.replaceAll("\\n", "") .replace("-----BEGIN PUBLIC KEY-----", "") .replace("-----END PUBLIC KEY-----", ""); byte[] byteKey = Base64.getDecoder().decode(keyContent); var x509EncodedKeySpec = new X509EncodedKeySpec(byteKey); return (RSAPublicKey) KeyFactory.getInstance("RSA").generatePublic(x509EncodedKeySpec); } StaticRSAKeyProvider(Map<String, String> keys); @Override RSAPublicKey getPublicKeyById(String keyId); @Override RSAPrivateKey getPrivateKey(); @Override String getPrivateKeyId();  }### Answer:
@Test void shouldThrowExceptionOnInvalid() { assertThatThrownBy(() -> StaticRSAKeyProvider.parsePubKey("")).isInstanceOf(InvalidKeySpecException.class); }