### Question:
CertificateValidatorFactory { public boolean validate(String encodedCert) throws CertificateValidationException { if (StringUtils.isBlank(encodedCert)) { throw new FailedCertValidationException(CertificateErrorMsgCode.CERTIFICATE_MISSING.name(), CertificateErrorMsgCode.CERTIFICATE_MISSING.toString()); } X509Certificate cert = X509CertUtils.parse(encodedCert); if(cert == null) { throw new FailedCertValidationException(CertificateErrorMsgCode.CERTIFICATE_MISSING.name(), CertificateErrorMsgCode.CERTIFICATE_MISSING.toString()); } validator.validate(cert); return true; } CertificateValidatorFactory(SimpleCertificateBucket blockedCertBucket,
			SimpleCertificateBucket rootCertificates, SimpleCertificateBucket intermediateCertificates); boolean validate(String encodedCert);  }### Answer:
@Test void when_ValidCertificate_Expected_True() { String encodedCert = CertificateUtils.getCertificateByName("certificateValid.crt"); CertificateValidatorFactory validatorFactory = new CertificateValidatorFactory(blockedCertBucket, rootCertBucket, intermediateCertBucket); assertThrows( CertificateValidationException.class, () -> validatorFactory.validate(encodedCert) ); }
@Test void when_InValidCertificate_Expected_Exception() { String encodedCert = CertificateUtils.getCertificateByName("certificateInvalid.crt"); CertificateValidatorFactory validatorFactory = new CertificateValidatorFactory(blockedCertBucket, rootCertBucket, intermediateCertBucket); assertThrows( CertificateValidationException.class, () -> validatorFactory.validate(encodedCert) ); }