### Question:
CertificateValidityChecker { public Optional<CertificateValidity> validate(Certificate certificate) { return certificate.getX509Certificate() .map(x509 -> getCertificateValidity(certificate, x509)); } private  CertificateValidityChecker(TrustStoreForCertificateProvider trustStoreForCertificateProvider, CertificateChainValidator certificateChainValidator); static CertificateValidityChecker createOCSPCheckingCertificateValidityChecker(TrustStoreForCertificateProvider trustStoreForCertificateProvider, OCSPCertificateChainValidator ocspCertificateChainValidator); static CertificateValidityChecker createNonOCSPCheckingCertificateValidityChecker(TrustStoreForCertificateProvider trustStoreForCertificateProvider, CertificateChainValidator certificateChainValidator); Set<InvalidCertificateDto> getInvalidCertificates(Collection<Certificate> certificates); Optional<CertificateValidity> validate(Certificate certificate); boolean isValid(Certificate certificate);  }### Answer:
@Test public void validateReturnsNoResultForLocalCertWithEmptyX509() { Certificate certificateWithoutX509 = new Certificate("entityId", FederationEntityType.RP, "", CertificateUse.SIGNING, CertificateOrigin.FEDERATION, true); Optional<CertificateValidity> result = certificateValidityChecker.validate(certificateWithoutX509); assertThat(result).isEmpty(); }
@Test public void validateReturnsNoResultForSelfServiceCertWithEmptyX509() { Certificate certificateWithoutX509 = new Certificate("entityId", FederationEntityType.RP, "", CertificateUse.SIGNING, CertificateOrigin.SELFSERVICE, true); Optional<CertificateValidity> result = certificateValidityChecker.validate(certificateWithoutX509); assertThat(result).isEmpty(); }