SoapResourceLoader implements EntityLoader { @Override public void load(final Bundle bundle, final File rootDir) { final File soapResourceRootDir = FolderLoaderUtils.getSoapResourcesRootDir(rootDir); if (soapResourceRootDir == null) return; final Map<String, SoapResource> soapResources = new HashMap<>(); loadSoapResources(soapResourceRootDir, soapResourceRootDir, soapResources); bundle.putAllSoapResources(soapResources); } @Inject  SoapResourceLoader(FileUtils fileUtils); @Override void load(final Bundle bundle, final File rootDir); @Override void load(Bundle bundle, String name, String value); @Override Map<String, Object> load(File entitiesFile); @Override Object loadSingle(String name, File entitiesFile); @Override String getEntityType();  }
@Test @ExtendWith(TemporaryFolderExtension.class) void testLoad(TemporaryFolder temporaryFolder) throws IOException { SoapResourceLoader soapResourceLoader = new SoapResourceLoader(fileUtils); File soapResourceFolder = temporaryFolder.createDirectory(SOAP_RESOURCES_FOLDER); File a = new File(soapResourceFolder, "a"); Assert.assertTrue(a.mkdir()); File b = new File(a, "b"); Assert.assertTrue(b.mkdir()); File c = new File(b, "c"); Assert.assertTrue(c.mkdir()); File soapResource = new File(c, "wsdl.wsdl"); Files.touch(soapResource); soapResource = new File(c, "schema.xsd"); Files.touch(soapResource); soapResource = new File(c, "invalid.txt"); Files.touch(soapResource); Bundle bundle = new Bundle(); soapResourceLoader.load(bundle, temporaryFolder.getRoot()); SoapResource loadedSoapResource = bundle.getSoapResources().get("a/b/c/wsdl.wsdl"); Assert.assertNotNull(loadedSoapResource); loadedSoapResource = bundle.getSoapResources().get("a/b/c/schema.xsd"); Assert.assertNotNull(loadedSoapResource); loadedSoapResource = bundle.getSoapResources().get("a/b/c/invalid.txt"); Assert.assertNull(loadedSoapResource); }
@Test @ExtendWith(TemporaryFolderExtension.class) void testLoadNoSoapResourceFolder(TemporaryFolder temporaryFolder) { SoapResourceLoader soapResourceLoader = new SoapResourceLoader(fileUtils); Bundle bundle = new Bundle(); soapResourceLoader.load(bundle, temporaryFolder.getRoot()); Assert.assertTrue(bundle.getFolders().isEmpty()); }
@Test @ExtendWith(TemporaryFolderExtension.class) void testLoadEmptyResourceFolder(TemporaryFolder temporaryFolder) { SoapResourceLoader soapResourceLoader = new SoapResourceLoader(fileUtils); temporaryFolder.createDirectory(SOAP_RESOURCES_FOLDER); Bundle bundle = new Bundle(); soapResourceLoader.load(bundle, temporaryFolder.getRoot()); Assert.assertTrue(bundle.getFolders().isEmpty()); }