### Question:
DefaultCertificateClient implements CertificateClient { @Override public X509Certificate getCertificate() { if (x509Certificate != null) { return x509Certificate; } if (certSerialId == null) { getLogger().error("Default certificate serial id is not set. Can't " + "locate the default certificate for this client."); return null; } loadAllCertificates(); if (certificateMap.containsKey(certSerialId)) { x509Certificate = certificateMap.get(certSerialId); } return x509Certificate; } DefaultCertificateClient(SecurityConfig securityConfig, Logger log,
      String certSerialId, String component); @Override PrivateKey getPrivateKey(); @Override PublicKey getPublicKey(); @Override X509Certificate getCertificate(); @Override X509Certificate getCACertificate(); @Override X509Certificate getCertificate(String certId); @Override boolean verifyCertificate(X509Certificate certificate); @Override byte[] signDataStream(InputStream stream); @Override byte[] signData(byte[] data); @Override boolean verifySignature(InputStream stream, byte[] signature,
      X509Certificate cert); @Override boolean verifySignature(byte[] data, byte[] signature,
      X509Certificate cert); @Override CertificateSignRequest.Builder getCSRBuilder(); @Override X509Certificate queryCertificate(String query); @Override void storeCertificate(String pemEncodedCert, boolean force); @Override void storeCertificate(String pemEncodedCert, boolean force,
      boolean caCert); @Override synchronized void storeTrustChain(CertStore ks); @Override synchronized void storeTrustChain(List<X509Certificate> certificates); @Override synchronized InitResponse init(); Logger getLogger();  }### Answer:
@Test public void testCertificateLoadingOnInit() throws Exception { KeyPair keyPair = keyGenerator.generateKey(); X509Certificate cert1 = generateX509Cert(keyPair); X509Certificate cert2 = generateX509Cert(keyPair); X509Certificate cert3 = generateX509Cert(keyPair); Path certPath = dnSecurityConfig.getCertificateLocation(DN_COMPONENT); CertificateCodec codec = new CertificateCodec(dnSecurityConfig, DN_COMPONENT); LambdaTestUtils.intercept(CertificateException.class, "Error while" + " getting certificate", () -> dnCertClient.getCertificate(cert1.getSerialNumber() .toString())); LambdaTestUtils.intercept(CertificateException.class, "Error while" + " getting certificate", () -> dnCertClient.getCertificate(cert2.getSerialNumber() .toString())); LambdaTestUtils.intercept(CertificateException.class, "Error while" + " getting certificate", () -> dnCertClient.getCertificate(cert3.getSerialNumber() .toString())); codec.writeCertificate(certPath, "1.crt", getPEMEncodedString(cert1), true); codec.writeCertificate(certPath, "2.crt", getPEMEncodedString(cert2), true); codec.writeCertificate(certPath, "3.crt", getPEMEncodedString(cert3), true); dnCertClient = new DNCertificateClient(dnSecurityConfig, certSerialId); assertNotNull(dnCertClient.getCertificate(cert1.getSerialNumber() .toString())); assertNotNull(dnCertClient.getCertificate(cert2.getSerialNumber() .toString())); assertNotNull(dnCertClient.getCertificate(cert3.getSerialNumber() .toString())); }