Bpmn4Tosca2Bpel { public void transform(URI srcBpmn4ToscaJsonFile, URI targetBPELArchive) throws ParseException, PlanWriterException { Bpmn4JsonParser parser = new Bpmn4JsonParser(); ManagementFlow managementFlow = parser.parse(srcBpmn4ToscaJsonFile); List<Path> planArtefactPaths = new ArrayList<Path>(); try { Path tempPath = FileUtil.createTempDir(DIR_NAME_TEMP_BPMN4TOSCA); BpelPlanArtefactWriter writer = new BpelPlanArtefactWriter(managementFlow); String plan = writer.completePlanTemplate(); planArtefactPaths.add(FileUtil.writeStringToFile(plan, Paths.get(tempPath.toString(), FILE_NAME_PLAN))); String planWsdl = writer.completePlanWsdlTemplate(); planArtefactPaths.add(FileUtil.writeStringToFile(planWsdl, Paths.get(tempPath.toString(), FILE_NAME_PLAN_WSDL))); String invokerWsdl = writer.completeInvokerWsdlTemplate(); planArtefactPaths.add(FileUtil.writeStringToFile(invokerWsdl, Paths.get(tempPath.toString(), FILE_NAME_INVOKER_WSDL))); String invokerXsd = writer.completeInvokerXsdTemplate(); planArtefactPaths.add(FileUtil.writeStringToFile(invokerXsd, Paths.get(tempPath.toString(), FILE_NAME_INVOKER_XSD))); String deploymentDesc = writer.completeDeploymentDescriptorTemplate(); planArtefactPaths.add(FileUtil.writeStringToFile(deploymentDesc, Paths.get(tempPath.toString(), FILE_NAME_DEPLOYMENT_DESC))); LOGGER.debug("Creating BPEL Archive..."); Path zipFilePath = FileUtil.createApacheOdeProcessArchive(Paths.get(targetBPELArchive), planArtefactPaths); LOGGER.debug("Management plan zip file saved to " + zipFilePath.toString()); } catch (Exception e) { throw new PlanWriterException(e); } finally { try { LOGGER.debug("Deleting temporary plan artefact files..."); FileUtil.deleteFiles(planArtefactPaths); } catch (IOException e) { throw new PlanWriterException(e); } } }  void transform(URI srcBpmn4ToscaJsonFile, URI targetBPELArchive); static final String FILE_NAME_PLAN; static final String FILE_NAME_PLAN_WSDL; static final String FILE_NAME_INVOKER_WSDL; static final String FILE_NAME_INVOKER_XSD; static final String FILE_NAME_DEPLOYMENT_DESC; static final String DIR_NAME_TEMP_BPMN4TOSCA; }
@Test public void testTransform() throws ParseException, PlanWriterException, MalformedURLException, URISyntaxException { URI srcUri = Paths.get(RESOURCES_DIR, "bpmn4tosca.json").toUri(); URI targetUri = Paths.get(RESOURCES_DIR, "managementplan.zip").toUri(); BPMN4Tosca2BpelTest.class.getResource("."); Bpmn4Tosca2Bpel transformer = new Bpmn4Tosca2Bpel(); transformer.transform(srcUri, targetUri); }
@Test public void testTransformGateway() throws ParseException, PlanWriterException, MalformedURLException, URISyntaxException { URI srcUri = Paths.get(RESOURCES_DIR, "bpmn4tosca.exclusivegateway.json").toUri(); URI targetUri = Paths.get(RESOURCES_DIR, "managementplan.exclusivegateway.zip").toUri(); BPMN4Tosca2BpelTest.class.getResource("."); Bpmn4Tosca2Bpel transformer = new Bpmn4Tosca2Bpel(); transformer.transform(srcUri, targetUri); }
@Test public void testNoEndpointGateway() throws ParseException, PlanWriterException, MalformedURLException, URISyntaxException { URI srcUri = Paths.get(RESOURCES_DIR, "bpmn4tosca.noEndpoint.json").toUri(); URI targetUri = Paths.get(RESOURCES_DIR, "managementplan.noEndpoint.zip").toUri(); BPMN4Tosca2BpelTest.class.getResource("."); Bpmn4Tosca2Bpel transformer = new Bpmn4Tosca2Bpel(); transformer.transform(srcUri, targetUri); }
@Test public void testUndefinedEndpointGateway() throws ParseException, PlanWriterException, MalformedURLException, URISyntaxException { URI srcUri = Paths.get(RESOURCES_DIR, "bpmn4tosca.undefinedEndpoint.json").toUri(); URI targetUri = Paths.get(RESOURCES_DIR, "managementplan.undefinedEndpoint.zip").toUri(); BPMN4Tosca2BpelTest.class.getResource("."); Bpmn4Tosca2Bpel transformer = new Bpmn4Tosca2Bpel(); transformer.transform(srcUri, targetUri); }
@Test public void testNonExistingEndpointGateway() throws ParseException, PlanWriterException, MalformedURLException, URISyntaxException { URI srcUri = Paths.get(RESOURCES_DIR, "bpmn4tosca.nonExistingEndpoint.json").toUri(); URI targetUri = Paths.get(RESOURCES_DIR, "managementplan.nonExistingEndpoint.zip").toUri(); BPMN4Tosca2BpelTest.class.getResource("."); Bpmn4Tosca2Bpel transformer = new Bpmn4Tosca2Bpel(); assertThrows(ParseException.class, () -> transformer.transform(srcUri, targetUri)); }