### Question:
CertificateValidityChecker { public boolean isValid(Certificate certificate) { return validate(certificate) .map(CertificateValidity::isValid) .orElse(false); } 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 considersSelfServiceCertificateToBeValidWithoutCheckingTrustChain() { Boolean isCertificateValid = certificateValidityChecker.isValid(selfServiceCertificate); assertThat(isCertificateValid).isTrue(); verifyNoInteractions(certificateChainValidator); }
@Test public void considersLocalCertificateWithEmptyX509ToBeInvalid() { Certificate certificateWithoutX509 = new Certificate("entityId", FederationEntityType.RP, "", CertificateUse.SIGNING, CertificateOrigin.FEDERATION, true); Boolean isCertificateValid = certificateValidityChecker.isValid(certificateWithoutX509); assertThat(isCertificateValid).isFalse(); }
@Test public void considersSelfServiceCertificateWithEmptyX509ToBeInvalid() { Certificate certificateWithoutX509 = new Certificate("entityId", FederationEntityType.RP, "", CertificateUse.SIGNING, CertificateOrigin.SELFSERVICE, true); Boolean isCertificateValid = certificateValidityChecker.isValid(certificateWithoutX509); assertThat(isCertificateValid).isFalse(); }