### Question:
FileCertificateRepo implements CertificateRepo { @Override public X509Certificate findBySubjectDn(String subjectDn) { List<X509Certificate> result = new ArrayList<>(); File[] list = getX509Files(); String[] sDnArray = subjectDn.split(SPLIT_REGEX); Arrays.sort(sDnArray); for (File certFile : list) { try { if (certFile.isDirectory()) { continue; } X509Certificate cert = readCertificate(certFile); LOG.debug("Searching for " + subjectDn + ". Checking cert " + cert.getSubjectDN().getName() + ", " + cert.getSubjectX500Principal().getName()); String[] csDnArray = cert.getSubjectDN().getName().split(SPLIT_REGEX); Arrays.sort(csDnArray); String[] csX500Array = cert.getSubjectX500Principal().getName().split(SPLIT_REGEX); Arrays.sort(csX500Array); if (arraysEqualsIgnoreCaseIgnoreWhiteSpace(sDnArray, csDnArray) || arraysEqualsIgnoreCaseIgnoreWhiteSpace(sDnArray, csX500Array)) { result.add(cert); } } catch (Exception e) { LOG.warn(String.format("Cannot load certificate from file: %s. Error: %s", certFile, e.getMessage())); } } if (!result.isEmpty()) { return result.get(0); } return null; } FileCertificateRepo(String path); void saveCertificate(X509Certificate cert, UseKeyWithType id); void saveTrustedCACertificate(X509Certificate cert, UseKeyWithType id); void saveCACertificate(X509Certificate cert, UseKeyWithType id); void saveCRL(X509CRL crl, UseKeyWithType id); String convertIdForFileSystem(String dn); String getCertPath(X509Certificate cert, UseKeyWithType id); X509Certificate readCertificate(File certFile); X509CRL readCRL(File crlFile); @Override List<X509Certificate> getTrustedCaCerts(); @Override List<X509Certificate> getCaCerts(); @Override List<X509CRL> getCRLs(); @Override X509Certificate findByServiceName(String serviceName); @Override X509Certificate findByEndpoint(String endpoint); @Override X509Certificate findBySubjectDn(String subjectDn); @Override X509Certificate findByIssuerSerial(String issuer, String serial);  }### Answer:
@Test public void testFindBySubjectName() throws CertificateException { File storageDir = new File("src/test/resources/store1"); assertTrue(storageDir.exists()); assertTrue(storageDir.isDirectory()); FileCertificateRepo persistenceManager = new FileCertificateRepo("src/test/resources/store1"); X509Certificate resCert = persistenceManager.findBySubjectDn(EXAMPLE_SUBJECT_DN); assertNotNull(resCert); }