### Question:
TokenCertificateConverter { public TokenCertificate convert(CertificateInfo certificateInfo, KeyInfo keyInfo, TokenInfo tokenInfo) { TokenCertificate tokenCertificate = convert(certificateInfo); tokenCertificate.setPossibleActions(possibleActionConverter.convert( possibleActionsRuleEngine.getPossibleCertificateActions( tokenInfo, keyInfo, certificateInfo))); return tokenCertificate; } @Autowired  TokenCertificateConverter(CertificateDetailsConverter certificateDetailsConverter,
            ClientConverter clientConverter,
            PossibleActionsRuleEngine possibleActionsRuleEngine,
            PossibleActionConverter possibleActionConverter); TokenCertificate convert(CertificateInfo certificateInfo,
            KeyInfo keyInfo,
            TokenInfo tokenInfo); TokenCertificate convert(CertificateInfo certificateInfo); List<TokenCertificate> convert(Iterable<CertificateInfo> certificateInfos); List<TokenCertificate> convert(Iterable<CertificateInfo> certificateInfos,
            KeyInfo keyInfo,
            TokenInfo tokenInfo);  }### Answer:
@Test public void convertWithPossibleActions() throws Exception { CertificateInfo certificateInfo = new CertificateInfoBuilder().build(); KeyInfo keyInfo = new KeyInfoBuilder() .cert(certificateInfo) .build(); TokenInfo tokenInfo = new TokenInfoBuilder() .key(keyInfo) .build(); TokenCertificate certificate = tokenCertificateConverter.convert(certificateInfo, keyInfo, tokenInfo); Collection<PossibleAction> actions = certificate.getPossibleActions(); assertTrue(actions.contains(PossibleAction.ACTIVATE)); assertEquals(1, actions.size()); }
@Test public void convert() throws Exception { CertificateInfo certificateInfo = new CertificateInfoBuilder().build(); TokenCertificate certificate = tokenCertificateConverter.convert(certificateInfo); assertEquals(true, certificate.getActive()); assertEquals("N/A", certificate.getCertificateDetails().getSubjectCommonName()); assertEquals(2038, certificate.getCertificateDetails().getNotAfter().getYear()); assertEquals(CertificateOcspStatus.OCSP_RESPONSE_GOOD, certificate.getOcspStatus()); assertEquals("a:b:c", certificate.getOwnerId()); assertEquals(true, certificate.getSavedToConfiguration()); assertEquals(org.niis.xroad.restapi.openapi.model.CertificateStatus.REGISTERED, certificate.getStatus()); }