diff options
Diffstat (limited to 'sdc-workflow-designer-server')
5 files changed, 137 insertions, 122 deletions
diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/converter/Bpmn4Tosca2Bpmn.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/converter/Bpmn4Tosca2Bpmn.java deleted file mode 100644 index 0b4f2edb..00000000 --- a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/converter/Bpmn4Tosca2Bpmn.java +++ /dev/null @@ -1,56 +0,0 @@ -/**
- * Copyright (c) 2017 ZTE Corporation.
- * All rights reserved. This program and the accompanying materials
- * are made available under the Apache License, Version 2.0
- * and the Eclipse Public License v1.0 which both accompany this distribution,
- * and are available at http://www.eclipse.org/legal/epl-v10.html
- * and http://www.apache.org/licenses/LICENSE-2.0
- *
- * Contributors:
- * ZTE - initial API and implementation and/or initial documentation
- */
-package org.onap.sdc.workflowdesigner.converter;
-
-import java.net.URI;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.StandardOpenOption;
-
-import org.onap.sdc.workflowdesigner.model.Process;
-import org.onap.sdc.workflowdesigner.parser.Bpmn4ToscaJsonParser;
-import org.onap.sdc.workflowdesigner.writer.BpmnPlanArtefactWriter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class Bpmn4Tosca2Bpmn {
-
- private static Logger log = LoggerFactory.getLogger(Bpmn4Tosca2Bpmn.class);
-
- /**
- * Transforms the given BPMN4Tosca Json management into a bpmn plan that can
- * be excuted by activiti.
- * <p>
- *
- * @param srcBpmn4ToscaJsonFile
- * @param targetBpmnArchive
- * @throws Exception
- */
- public void transform(String processId, URI srcBpmn4ToscaJsonFile, URI targetBpmnArchive) throws Exception {
- log.info("transform start");
-
- // parse json object
- Bpmn4ToscaJsonParser parser = new Bpmn4ToscaJsonParser();
- Process process = parser.parse(processId, srcBpmn4ToscaJsonFile);
-
- // transform bpmn template
- BpmnPlanArtefactWriter writer = new BpmnPlanArtefactWriter(process);
- String workflowString = writer.completePlanTemplate();
-
- // write bpmn to file
- Path targetPath = Paths.get(targetBpmnArchive);
- Files.write(targetPath, workflowString.getBytes(), StandardOpenOption.CREATE);
- log.info("transform end");
- }
-
-}
diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/WorkflowModelerResource.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/WorkflowModelerResource.java index fe736890..0f0e2dd8 100644 --- a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/WorkflowModelerResource.java +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/WorkflowModelerResource.java @@ -14,9 +14,9 @@ package org.onap.sdc.workflowdesigner.resources; import java.io.IOException; import java.net.URI; -import java.nio.file.Paths; +//import java.nio.file.Paths; import java.util.List; -import java.util.UUID; +//import java.util.UUID; import javax.ws.rs.Consumes; import javax.ws.rs.GET; @@ -32,14 +32,14 @@ import org.dom4j.Document; import org.dom4j.DocumentException; import org.dom4j.DocumentHelper; import org.eclipse.jetty.http.HttpStatus; -import org.onap.sdc.workflowdesigner.common.WorkflowDesignerException; -import org.onap.sdc.workflowdesigner.externalservice.sdc.SDCServiceProxy; -import org.onap.sdc.workflowdesigner.externalservice.sdc.entity.WorkflowArtifactInfo; +//import org.onap.sdc.workflowdesigner.common.WorkflowDesignerException; +//import org.onap.sdc.workflowdesigner.externalservice.sdc.SDCServiceProxy; +//import org.onap.sdc.workflowdesigner.externalservice.sdc.entity.WorkflowArtifactInfo; import org.onap.sdc.workflowdesigner.model.Process; import org.onap.sdc.workflowdesigner.parser.Bpmn4ToscaJsonParser; -import org.onap.sdc.workflowdesigner.resources.entity.WorkflowInfo; +//import org.onap.sdc.workflowdesigner.resources.entity.WorkflowInfo; import org.onap.sdc.workflowdesigner.utils.FileCommonUtils; -import org.onap.sdc.workflowdesigner.utils.JsonUtils; +//import org.onap.sdc.workflowdesigner.utils.JsonUtils; import org.onap.sdc.workflowdesigner.utils.RestUtils; import org.onap.sdc.workflowdesigner.writer.BpmnPlanArtefactWriter; import org.slf4j.Logger; @@ -63,7 +63,7 @@ public class WorkflowModelerResource { private static final Logger logger = LoggerFactory.getLogger(WorkflowModelerResource.class); private static final String WORKFLOW_JSON_TEMP_FILE_NAME = "temp_workflow.json"; - private static final String WORKFLOW_XML_TEMP_FILE_NAME = "temp_workflow.xml"; +// private static final String WORKFLOW_XML_TEMP_FILE_NAME = "temp_workflow.xml"; /** @@ -112,10 +112,10 @@ public class WorkflowModelerResource { @ApiParam(value = "Model Content", required = true) String json) { try { FileCommonUtils.write(WORKFLOW_JSON_TEMP_FILE_NAME, json); - - URI srcUri = Paths.get(".", WORKFLOW_JSON_TEMP_FILE_NAME).toUri(); - String processName = "plan_" + UUID.randomUUID().toString(); - // TODO for Nexus-IQ + + // TODO for Nexus-IQ +// URI srcUri = Paths.get(".", WORKFLOW_JSON_TEMP_FILE_NAME).toUri(); +// String processName = "plan_" + UUID.randomUUID().toString(); // String bpmn = buildBPMN(srcUri, processName); // String jsonBpmn = insertJson2Bpmn(json, bpmn); @@ -163,20 +163,20 @@ public class WorkflowModelerResource { } - /** - * @param json - * @param bpmn - * @throws WorkflowDesignerException - */ - private void save2SDC(String json, String bpmn) throws WorkflowDesignerException { - WorkflowInfo workflowInfo = JsonUtils.fromJson(json, WorkflowInfo.class); - WorkflowArtifactInfo workflowArtifactInfo = - new WorkflowArtifactInfo(workflowInfo.getName(), workflowInfo.getDescription(), bpmn); - - SDCServiceProxy sdcProxy = new SDCServiceProxy(); - sdcProxy.saveWorkflowArtifact(workflowInfo.getUuid(), workflowInfo.getOperationId(), - workflowInfo.getId(), workflowArtifactInfo); - } +// /** +// * @param json +// * @param bpmn +// * @throws WorkflowDesignerException +// */ +// private void save2SDC(String json, String bpmn) throws WorkflowDesignerException { +// WorkflowInfo workflowInfo = JsonUtils.fromJson(json, WorkflowInfo.class); +// WorkflowArtifactInfo workflowArtifactInfo = +// new WorkflowArtifactInfo(workflowInfo.getName(), workflowInfo.getDescription(), bpmn); +// +// SDCServiceProxy sdcProxy = new SDCServiceProxy(); +// sdcProxy.saveWorkflowArtifact(workflowInfo.getUuid(), workflowInfo.getOperationId(), +// workflowInfo.getId(), workflowArtifactInfo); +// } /** * diff --git a/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/SDCServiceProxyInfoTest.java b/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/SDCServiceProxyInfoTest.java new file mode 100644 index 00000000..6ae8ffa1 --- /dev/null +++ b/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/SDCServiceProxyInfoTest.java @@ -0,0 +1,54 @@ +/**
+ * Copyright (c) 2018 ZTE Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the Apache License, Version 2.0
+ * and the Eclipse Public License v1.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * ZTE - initial API and implementation and/or initial documentation
+ */
+package org.onap.sdc.workflowdesigner;
+
+import static org.junit.Assert.*;
+
+import org.hibernate.validator.constraints.NotEmpty;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class SDCServiceProxyInfoTest {
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Before
+ public void setUp() throws Exception {}
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @After
+ public void tearDown() throws Exception {}
+
+ @Test
+ public void test() {
+ String serviceAddr = "serviceAddr";
+ String xEcompInstanceId = "xEcompInstanceId";
+ String authorization = "authorization";
+
+ SDCServiceProxyInfo spi = new SDCServiceProxyInfo();
+ spi.setAuthorization(authorization);
+ spi.setServiceAddr(serviceAddr);
+ spi.setxEcompInstanceId(xEcompInstanceId);
+
+ assertEquals(authorization, spi.getAuthorization());
+ assertEquals(serviceAddr, spi.getServiceAddr());
+ assertEquals(xEcompInstanceId, spi.getxEcompInstanceId());
+ }
+
+}
diff --git a/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/WorkflowDesignerConfigurationTest.java b/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/WorkflowDesignerConfigurationTest.java new file mode 100644 index 00000000..12e18531 --- /dev/null +++ b/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/WorkflowDesignerConfigurationTest.java @@ -0,0 +1,57 @@ +/**
+ * Copyright (c) 2018 ZTE Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the Apache License, Version 2.0
+ * and the Eclipse Public License v1.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * ZTE - initial API and implementation and/or initial documentation
+ */
+package org.onap.sdc.workflowdesigner;
+
+import static org.junit.Assert.*;
+
+import javax.validation.constraints.NotNull;
+
+import org.hibernate.validator.constraints.NotEmpty;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class WorkflowDesignerConfigurationTest {
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Before
+ public void setUp() throws Exception {}
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @After
+ public void tearDown() throws Exception {}
+
+ @Test
+ public void test() {
+ String template = "template";
+ String defaultName = "Workflow Designer";
+ SDCServiceProxyInfo sdcServiceProxy = new SDCServiceProxyInfo();
+
+
+ WorkflowDesignerConfiguration wdc = new WorkflowDesignerConfiguration();
+ wdc.setDefaultName(defaultName);
+ wdc.setSdcServiceProxy(sdcServiceProxy);
+ wdc.setTemplate(template);
+
+ assertEquals(defaultName, wdc.getDefaultName());
+ assertEquals(sdcServiceProxy, wdc.getSdcServiceProxy());
+ assertEquals(template, wdc.getTemplate());
+ }
+
+}
diff --git a/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/convert/BPMN4Tosca2BpmnTest.java b/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/convert/BPMN4Tosca2BpmnTest.java deleted file mode 100644 index 83b52dfd..00000000 --- a/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/convert/BPMN4Tosca2BpmnTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/**
- * Copyright (c) 2017-2018 ZTE Corporation.
- * All rights reserved. This program and the accompanying materials
- * are made available under the Apache License, Version 2.0
- * and the Eclipse Public License v1.0 which both accompany this distribution,
- * and are available at http://www.eclipse.org/legal/epl-v10.html
- * and http://www.apache.org/licenses/LICENSE-2.0
- *
- * Contributors:
- * ZTE - initial API and implementation and/or initial documentation
- */
-package org.onap.sdc.workflowdesigner.convert;
-
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.net.URI;
-import java.nio.file.Paths;
-
-import org.apache.velocity.exception.ParseErrorException;
-import org.apache.velocity.exception.ResourceNotFoundException;
-import org.junit.Test;
-import org.onap.sdc.workflowdesigner.converter.Bpmn4Tosca2Bpmn;
-
-public class BPMN4Tosca2BpmnTest {
- private static String RESOURCES_DIR = "src/test/resources/workflow";
-
- @Test
- public void testTransform() throws ResourceNotFoundException, ParseErrorException, Exception {
-
- URI srcUri = Paths.get(RESOURCES_DIR, "workflow.json").toUri();
- URI targetUri = Paths.get(RESOURCES_DIR, "bpmnworkflow.bpmn20.xml").toUri();
- BPMN4Tosca2BpmnTest.class.getResource(".");
- Bpmn4Tosca2Bpmn transformer = new Bpmn4Tosca2Bpmn();
-// transformer.transform("transformTest", srcUri, targetUri);
-// assertTrue(new File(targetUri.getPath()).exists());
- // TODO for Nexus-IQ
- }
-
-}
|