@Test void load() throws IOException { createCertificates("cert1.cer", "cert2.cer", "cert3.cer"); CertificatesLoader loader = new CertificatesLoader(FileUtils.INSTANCE); Bundle bundle = new Bundle(); loader.load(bundle, rootProjectDir.getRoot()); assertFalse(bundle.getCertificateFiles().isEmpty()); assertEquals(3, bundle.getCertificateFiles().size()); assertNotNull(bundle.getCertificateFiles().get("cert1")); assertNotNull(bundle.getCertificateFiles().get("cert2")); assertNotNull(bundle.getCertificateFiles().get("cert3")); }
@Override public void load(Bundle bundle, File rootDir) { final File certificatesDir = findConfigFileOrDir(rootDir, "certificates"); if (certificatesDir != null && certificatesDir.exists()) { final String[] certs = certificatesDir.list(); if (certs != null && certs.length > 0) { final Map<String, SupplierWithIO<InputStream>> map = new HashMap<>(); stream(certs).forEach(cert -> { if (checkCertFormat(cert)) { map.put(getBaseName(cert), () -> new FileInputStream(new File(certificatesDir, cert))); } else { throw new ConfigLoadException(cert + " must be a valid certificate extension."); } }); bundle.putAllCertificateFiles(map); } } }
CertificatesLoader implements EntityLoader { @Override public void load(Bundle bundle, File rootDir) { final File certificatesDir = findConfigFileOrDir(rootDir, "certificates"); if (certificatesDir != null && certificatesDir.exists()) { final String[] certs = certificatesDir.list(); if (certs != null && certs.length > 0) { final Map<String, SupplierWithIO<InputStream>> map = new HashMap<>(); stream(certs).forEach(cert -> { if (checkCertFormat(cert)) { map.put(getBaseName(cert), () -> new FileInputStream(new File(certificatesDir, cert))); } else { throw new ConfigLoadException(cert + " must be a valid certificate extension."); } }); bundle.putAllCertificateFiles(map); } } } }
CertificatesLoader implements EntityLoader { @Override public void load(Bundle bundle, File rootDir) { final File certificatesDir = findConfigFileOrDir(rootDir, "certificates"); if (certificatesDir != null && certificatesDir.exists()) { final String[] certs = certificatesDir.list(); if (certs != null && certs.length > 0) { final Map<String, SupplierWithIO<InputStream>> map = new HashMap<>(); stream(certs).forEach(cert -> { if (checkCertFormat(cert)) { map.put(getBaseName(cert), () -> new FileInputStream(new File(certificatesDir, cert))); } else { throw new ConfigLoadException(cert + " must be a valid certificate extension."); } }); bundle.putAllCertificateFiles(map); } } } @Inject  CertificatesLoader(FileUtils fileUtils); }
CertificatesLoader implements EntityLoader { @Override public void load(Bundle bundle, File rootDir) { final File certificatesDir = findConfigFileOrDir(rootDir, "certificates"); if (certificatesDir != null && certificatesDir.exists()) { final String[] certs = certificatesDir.list(); if (certs != null && certs.length > 0) { final Map<String, SupplierWithIO<InputStream>> map = new HashMap<>(); stream(certs).forEach(cert -> { if (checkCertFormat(cert)) { map.put(getBaseName(cert), () -> new FileInputStream(new File(certificatesDir, cert))); } else { throw new ConfigLoadException(cert + " must be a valid certificate extension."); } }); bundle.putAllCertificateFiles(map); } } } @Inject  CertificatesLoader(FileUtils fileUtils); @Override void load(Bundle bundle, File rootDir); @Override void load(Bundle bundle, String name, String value); @Override Object loadSingle(String name, File entitiesFile); @Override Map<String, Object> load(File entitiesFile); @Override String getEntityType(); }
CertificatesLoader implements EntityLoader { @Override public void load(Bundle bundle, File rootDir) { final File certificatesDir = findConfigFileOrDir(rootDir, "certificates"); if (certificatesDir != null && certificatesDir.exists()) { final String[] certs = certificatesDir.list(); if (certs != null && certs.length > 0) { final Map<String, SupplierWithIO<InputStream>> map = new HashMap<>(); stream(certs).forEach(cert -> { if (checkCertFormat(cert)) { map.put(getBaseName(cert), () -> new FileInputStream(new File(certificatesDir, cert))); } else { throw new ConfigLoadException(cert + " must be a valid certificate extension."); } }); bundle.putAllCertificateFiles(map); } } } @Inject  CertificatesLoader(FileUtils fileUtils); @Override void load(Bundle bundle, File rootDir); @Override void load(Bundle bundle, String name, String value); @Override Object loadSingle(String name, File entitiesFile); @Override Map<String, Object> load(File entitiesFile); @Override String getEntityType();  }