### Question:
TokenConverter { private boolean isSavedToConfiguration(TokenInfo tokenInfo) { return tokenInfo.getKeyInfo().stream() .anyMatch(keyInfo -> keyConverter.isSavedToConfiguration(keyInfo)); } @Autowired  TokenConverter(KeyConverter keyConverter); Token convert(TokenInfo tokenInfo); List<Token> convert(Iterable<TokenInfo> tokenInfos);  }### Answer:
@Test public void isSavedToConfiguration() throws Exception { KeyInfo savedKey = new KeyInfo(true, KeyUsageInfo.SIGNING, "friendly-name", "id", "label", "public-key", new ArrayList<>(), new ArrayList<>(), "sign-mechanism-name"); KeyInfo unsavedKey = new KeyInfo(true, KeyUsageInfo.SIGNING, "friendly-name", "id", "label", "public-key", new ArrayList<>(), new ArrayList<>(), "sign-mechanism-name"); savedKey.getCerts().clear(); savedKey.getCertRequests().clear(); savedKey.getCertRequests().add(KeyConverterTest.createTestCsr()); unsavedKey.getCerts().clear(); unsavedKey.getCertRequests().clear(); TokenInfo tokenInfo = TokenTestUtils.createTestTokenInfo("friendly-name"); tokenInfo.getKeyInfo().clear(); assertEquals(false, tokenConverter.convert(tokenInfo).getSavedToConfiguration()); tokenInfo.getKeyInfo().clear(); tokenInfo.getKeyInfo().add(unsavedKey); assertEquals(false, tokenConverter.convert(tokenInfo).getSavedToConfiguration()); tokenInfo.getKeyInfo().clear(); tokenInfo.getKeyInfo().add(savedKey); assertEquals(true, tokenConverter.convert(tokenInfo).getSavedToConfiguration()); tokenInfo.getKeyInfo().clear(); tokenInfo.getKeyInfo().add(unsavedKey); tokenInfo.getKeyInfo().add(savedKey); tokenInfo.getKeyInfo().add(unsavedKey); assertEquals(true, tokenConverter.convert(tokenInfo).getSavedToConfiguration()); }