PublicKeyReader { Optional<PublicKey> fromPEM(Optional<String> pemKey) { return pemKey .map(k -> new PEMParser(new PemReader(new StringReader(k)))) .flatMap(this::publicKeyFrom); }    }
@Test public void fromPEMShouldReturnEmptyWhenEmptyProvided() { assertThat(new PublicKeyReader().fromPEM(Optional.empty())).isEmpty(); }
@Test public void fromPEMShouldReturnEmptyWhenInvalidPEMKey() { assertThat(new PublicKeyReader().fromPEM(Optional.of("blabla"))).isEmpty(); }
@Test public void fromPEMShouldReturnRSAPublicKeyWhenValidPEMKey() { assertThat(new PublicKeyReader().fromPEM(Optional.of(PUBLIC_PEM_KEY))).isPresent(); }