### Question:
KeyConverter { public boolean isSavedToConfiguration(KeyInfo keyInfo) { if (!keyInfo.getCertRequests().isEmpty()) { return true; } return keyInfo.getCerts().stream() .anyMatch(certificateInfo -> certificateInfo.isSavedToConfiguration()); } @Autowired  KeyConverter(TokenCertificateConverter tokenCertificateConverter,
            TokenCertificateSigningRequestConverter tokenCsrConverter); Key convert(KeyInfo keyInfo); boolean isSavedToConfiguration(KeyInfo keyInfo); List<Key> convert(Iterable<KeyInfo> keyInfos);  }### Answer:
@Test public void isSavedToConfiguration() throws Exception { KeyInfo info = new KeyInfo(true, KeyUsageInfo.SIGNING, "friendly-name", "id", "label", "public-key", new ArrayList<>(), new ArrayList<>(), "sign-mechanism-name"); info.getCerts().clear(); info.getCertRequests().clear(); info.getCertRequests().add(createTestCsr()); assertEquals(true, keyConverter.convert(info).getSavedToConfiguration()); info.getCerts().clear(); info.getCertRequests().clear(); assertEquals(false, keyConverter.convert(info).getSavedToConfiguration()); info.getCerts().clear(); info.getCertRequests().clear(); info.getCerts().add(createTestCertificateInfo(CertificateTestUtils.getMockCertificate(), CertificateStatus.GOOD, CertificateInfo.STATUS_REGISTERED, false)); info.getCerts().add(createTestCertificateInfo(CertificateTestUtils.getMockCertificate(), CertificateStatus.GOOD, CertificateInfo.STATUS_REGISTERED, false)); assertEquals(false, keyConverter.convert(info).getSavedToConfiguration()); info.getCerts().clear(); info.getCertRequests().clear(); info.getCerts().add(createTestCertificateInfo(CertificateTestUtils.getMockCertificate(), CertificateStatus.GOOD, CertificateInfo.STATUS_REGISTERED, false)); info.getCerts().add(createTestCertificateInfo(CertificateTestUtils.getMockCertificate(), CertificateStatus.GOOD, CertificateInfo.STATUS_REGISTERED, true)); assertEquals(true, keyConverter.convert(info).getSavedToConfiguration()); info.getCerts().clear(); info.getCertRequests().clear(); info.getCerts().add(createTestCertificateInfo(CertificateTestUtils.getMockCertificate(), CertificateStatus.GOOD, CertificateInfo.STATUS_REGISTERED, true)); info.getCerts().add(createTestCertificateInfo(CertificateTestUtils.getMockCertificate(), CertificateStatus.GOOD, CertificateInfo.STATUS_REGISTERED, false)); assertEquals(true, keyConverter.convert(info).getSavedToConfiguration()); }