SoapResourceWriter implements EntityWriter { @Override public void write(Bundle bundle, File rootFolder, Bundle rawBundle) { Map<String, Service> services = bundle.getEntities(Service.class); services.values().stream().filter(s -> isNotEmpty(s.getSoapResources())).forEach(serviceEntity -> serviceEntity.getSoapResources().forEach(resource -> writeSoapResource(bundle, rootFolder, serviceEntity.getParentFolder().getId(), serviceEntity.getName(), resource) )); } @Inject  SoapResourceWriter(DocumentFileUtils documentFileUtils); @Override void write(Bundle bundle, File rootFolder, Bundle rawBundle);  }
@Test void testWriteSoapResources(final TemporaryFolder temporaryFolder) { SoapResourceWriter writer = new SoapResourceWriter(DocumentFileUtils.INSTANCE); Bundle bundle = new Bundle(); bundle.addEntity(ROOT_FOLDER); bundle.setFolderTree(new FolderTree(bundle.getEntities(Folder.class).values())); Service service = new Service(); service.setName(NAME_SERVICE); service.setParentFolder(ROOT_FOLDER); service.addSoapResource(getSoapResource(WSDL_FILE_NAME, WSDL_XML, SoapResourceType.WSDL)); service.addSoapResource(getSoapResource(XML_SCHEMA_FILE_NAME, XML_SCHEMA, SoapResourceType.XMLSCHEMA)); service.setPolicy(POLICY_XML); service.setSoapVersion("1.1"); service.setWssProcessingEnabled(true); bundle.getServices().put("service", service); writer.write(bundle, temporaryFolder.getRoot(), bundle); File wsdlFolder = new File(temporaryFolder.getRoot(), SOAP_RESOURCES_FOLDER); assertTrue(wsdlFolder.exists()); File serviceSoapResourcesFolder = new File(wsdlFolder, NAME_SERVICE); assertTrue(serviceSoapResourcesFolder.exists()); File wsdlFile = new File(serviceSoapResourcesFolder, WSDL_FILE_NAME); assertTrue(wsdlFile.exists()); File xsdFile = new File(serviceSoapResourcesFolder, XML_SCHEMA_FILE_NAME); assertTrue(xsdFile.exists()); }
@Test void testWriteEmptySoapResource(final TemporaryFolder temporaryFolder) { SoapResourceWriter writer = new SoapResourceWriter(DocumentFileUtils.INSTANCE); Bundle bundle = new Bundle(); bundle.addEntity(ROOT_FOLDER); bundle.setFolderTree(new FolderTree(bundle.getEntities(Folder.class).values())); Service service = new Service(); service.setName(NAME_SERVICE); service.setParentFolder(ROOT_FOLDER); service.addSoapResource(getSoapResource(WSDL_FILE_NAME, EMPTY, SoapResourceType.WSDL)); service.setPolicy(POLICY_XML); service.setSoapVersion("1.1"); service.setWssProcessingEnabled(true); bundle.getServices().put("service", service); writer.write(bundle, temporaryFolder.getRoot(), bundle); File wsdlFolder = new File(temporaryFolder.getRoot(), SOAP_RESOURCES_FOLDER); assertTrue(wsdlFolder.exists()); File serviceSoapResourcesFolder = new File(wsdlFolder, NAME_SERVICE); assertTrue(serviceSoapResourcesFolder.exists()); File wsdlFile = new File(serviceSoapResourcesFolder, WSDL_FILE_NAME); assertTrue(wsdlFile.exists()); }
@Test void testWriteNonSoapService_NofolderCreated(final TemporaryFolder temporaryFolder) { SoapResourceWriter writer = new SoapResourceWriter(DocumentFileUtils.INSTANCE); Bundle bundle = new Bundle(); bundle.addEntity(ROOT_FOLDER); bundle.setFolderTree(new FolderTree(bundle.getEntities(Folder.class).values())); Service service = new Service(); service.setName(NAME_SERVICE); service.setParentFolder(ROOT_FOLDER); service.setPolicy(POLICY_XML); bundle.getServices().put("service", service); writer.write(bundle, temporaryFolder.getRoot(), bundle); File wsdlFolder = new File(temporaryFolder.getRoot(), SOAP_RESOURCES_FOLDER); assertFalse(wsdlFolder.exists()); File serviceSoapResourcesFolder = new File(wsdlFolder, NAME_SERVICE); assertFalse(serviceSoapResourcesFolder.exists()); File wsdlFile = new File(serviceSoapResourcesFolder, WSDL_FILE_NAME); assertFalse(wsdlFile.exists()); }