### Question:
KeyConverter { public Key convert(KeyInfo keyInfo) { Key key = new Key(); key.setId(keyInfo.getId()); key.setName(keyInfo.getFriendlyName()); key.setLabel(keyInfo.getLabel()); if (keyInfo.getUsage() != null) { if (keyInfo.isForSigning()) { key.setUsage(KeyUsageType.SIGNING); } else { key.setUsage(KeyUsageType.AUTHENTICATION); } } key.setAvailable(keyInfo.isAvailable()); key.setSavedToConfiguration(isSavedToConfiguration(keyInfo)); key.setCertificates(tokenCertificateConverter.convert(keyInfo.getCerts())); key.setCertificateSigningRequests(tokenCsrConverter.convert(keyInfo.getCertRequests())); return key; } @Autowired  KeyConverter(TokenCertificateConverter tokenCertificateConverter,
            TokenCertificateSigningRequestConverter tokenCsrConverter); Key convert(KeyInfo keyInfo); boolean isSavedToConfiguration(KeyInfo keyInfo); List<Key> convert(Iterable<KeyInfo> keyInfos);  }### Answer:
@Test public void convert() throws Exception { List<CertificateInfo> certs = new ArrayList<>(); certs.add(createTestCertificateInfo(CertificateTestUtils.getMockCertificate(), CertificateStatus.GOOD, CertificateInfo.STATUS_REGISTERED)); List<CertRequestInfo> csrs = new ArrayList<>(); csrs.add(new CertRequestInfo("id", ClientId.create("a", "b", "c"), "sujbect-name")); KeyInfo info = new KeyInfo(true, KeyUsageInfo.SIGNING, "friendly-name", "id", "label", "public-key", certs, csrs, "sign-mechanism-name"); Key key = keyConverter.convert(info); assertEquals(true, key.getAvailable()); assertNotNull(key.getCertificates()); assertEquals(1, key.getCertificates().size()); assertNotNull(key.getCertificateSigningRequests()); assertEquals(1, key.getCertificateSigningRequests().size()); assertEquals("id", key.getId()); assertEquals("label", key.getLabel()); assertEquals("friendly-name", key.getName()); assertEquals(true, key.getSavedToConfiguration()); assertEquals(KeyUsageType.SIGNING, key.getUsage()); }