CertificatesLoader implements EntityLoader { @Override public Object loadSingle(String name, File entitiesFile) { if (!checkCertFormat(entitiesFile.getName())) { throw new ConfigLoadException(name + " must have a valid certificate extension."); } return fileUtils.getFileAsString(entitiesFile); } @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();  }
@Test void loadSingle() throws IOException { CertificatesLoader loader = new CertificatesLoader(FileUtils.INSTANCE); createCertificates("cert1.cer"); Object certContent = loader.loadSingle("cert1", new File(certsDir, "cert1.cer")); assertNotNull(certContent); assertTrue(certContent instanceof String); }
@Test void loadSingleInvalidExtension() throws IOException { CertificatesLoader loader = new CertificatesLoader(FileUtils.INSTANCE); createCertificates("cert1.cerT"); assertThrows(ConfigLoadException.class, () -> loader.loadSingle("cert1", new File(certsDir, "cert1.cerT"))); }