diff options
author | vempo <vitaliy.emporopulo@amdocs.com> | 2018-07-24 17:34:04 +0300 |
---|---|---|
committer | vempo <vitaliy.emporopulo@amdocs.com> | 2018-07-25 11:39:10 +0300 |
commit | a52d50e788792a63e97a9176ab319d53db7a2853 (patch) | |
tree | b1c2222cacf4b8192aea16d1e0315b1f005c5347 /deprecated-workflow-designer/sdc-workflow-designer-server/src/test | |
parent | 3c2665debb400aef7f0ed9e235698d2ff9f859db (diff) |
Replaced old implementation at root
Old project files and directories has been moved
under 'deprecated-workflow-designer'. The old project
is not built by the CI anymore, but can be still built manually.
New modules/directories have been moved up and integrated with
the CI system.
Change-Id: I1528c792bcbcce9e50bfc294a1328a20e72c91cf
Issue-ID: SDC-1559
Signed-off-by: vempo <vitaliy.emporopulo@amdocs.com>
Diffstat (limited to 'deprecated-workflow-designer/sdc-workflow-designer-server/src/test')
37 files changed, 2292 insertions, 0 deletions
diff --git a/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/SDCServiceProxyInfoTest.java b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/SDCServiceProxyInfoTest.java new file mode 100644 index 00000000..dde607e9 --- /dev/null +++ b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/SDCServiceProxyInfoTest.java @@ -0,0 +1,53 @@ +/** + * 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.assertEquals; + +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/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/WorkflowDesignerConfigurationTest.java b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/WorkflowDesignerConfigurationTest.java new file mode 100644 index 00000000..a09afb15 --- /dev/null +++ b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/WorkflowDesignerConfigurationTest.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.assertEquals; + +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/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/config/AdapterTypeTest.java b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/config/AdapterTypeTest.java new file mode 100644 index 00000000..6d779cc2 --- /dev/null +++ b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/config/AdapterTypeTest.java @@ -0,0 +1,45 @@ +/** + * 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.config; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * + */ +public class AdapterTypeTest { + + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception {} + + /** + * @throws java.lang.Exception + */ + @After + public void tearDown() throws Exception {} + + @Test + public void test() { + AdapterType at = AdapterType.valueOf("SDC"); + assertEquals(AdapterType.SDC, at); + AdapterType at1 = AdapterType.valueOf("DEFAULT"); + assertEquals(AdapterType.DEFAULT, at1); + } + +} diff --git a/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/config/ConfigTest.java b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/config/ConfigTest.java new file mode 100644 index 00000000..deb04c57 --- /dev/null +++ b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/config/ConfigTest.java @@ -0,0 +1,26 @@ +/** + * 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.config; + +import static org.junit.Assert.assertEquals; + +import org.apache.velocity.exception.ParseErrorException; +import org.apache.velocity.exception.ResourceNotFoundException; +import org.junit.Test; + +public class ConfigTest { + @Test + public void testLoad() throws ResourceNotFoundException, ParseErrorException, Exception { + assertEquals(Config.PROPERTIES.get(Config.HANDLER_ClASS), + "org.onap.workflow.activitiext.restservicetask.HttpUtil"); + } +} diff --git a/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/externalservice/sdc/entity/ActivityContentTest.java b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/externalservice/sdc/entity/ActivityContentTest.java new file mode 100644 index 00000000..27a9872d --- /dev/null +++ b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/externalservice/sdc/entity/ActivityContentTest.java @@ -0,0 +1,56 @@ +/** + * 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.externalservice.sdc.entity; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * + */ +public class ActivityContentTest { + + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception {} + + /** + * @throws java.lang.Exception + */ + @After + public void tearDown() throws Exception {} + + /** + * Test method for {@link java.lang.Object#toString()}. + */ + @Test + public void testToString() { +// String clazz = "clazz"; + String script = "script"; + String scriptFormat = "scriptFormat"; + + ActivityContent ac = new ActivityContent(); +// ac.setClass(clazz); + ac.setScript(script); + ac.setScriptFormat(scriptFormat ); + +// assertEquals(clazz, ac.getClazz()); + assertEquals(script, ac.getScript()); + assertEquals(scriptFormat, ac.getScriptFormat()); + } + +} diff --git a/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/externalservice/sdc/entity/ActivitySpecTest.java b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/externalservice/sdc/entity/ActivitySpecTest.java new file mode 100644 index 00000000..84ca9198 --- /dev/null +++ b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/externalservice/sdc/entity/ActivitySpecTest.java @@ -0,0 +1,74 @@ +/** + * 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.externalservice.sdc.entity; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * + */ +public class ActivitySpecTest { + + /** + * @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 id = ""; + String versionId = ""; + String name = ""; + String description = ""; + String type = ""; + String content = ""; + String[] categoryList = new String[]{"aaa"}; + Parameter[] inputs = new Parameter[0]; + Parameter[] outputs = new Parameter[0]; + String status = "status"; + + ActivitySpec as = new ActivitySpec(); + as.setId(id); + as.setVersionId(versionId); + as.setName(name); + as.setDescription(description); + as.setType(type); + as.setContent(content); + as.setCategoryList(categoryList); + as.setInputs(inputs); + as.setOutputs(outputs); + as.setStatus(status); + + assertEquals(id, as.getId()); + assertEquals(versionId, as.getVersionId()); + assertEquals(name, as.getName()); + assertEquals(description, as.getDescription()); + assertEquals(type, as.getType()); + assertEquals(content, as.getContent()); + assertEquals(categoryList, as.getCategoryList()); + assertEquals(inputs, as.getInputs()); + assertEquals(outputs, as.getOutputs()); + assertEquals(status, as.getStatus()); + } + +} diff --git a/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/externalservice/sdc/entity/ParameterTest.java b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/externalservice/sdc/entity/ParameterTest.java new file mode 100644 index 00000000..0a56b302 --- /dev/null +++ b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/externalservice/sdc/entity/ParameterTest.java @@ -0,0 +1,59 @@ +/** + * 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.externalservice.sdc.entity; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import com.google.gson.annotations.SerializedName; + +/** + * + */ +public class ParameterTest { + + /** + * @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 name = "name"; + String type = "type"; + String defaultValue = "defaultValue"; + String value = "value"; + + Parameter p = new Parameter(); + p.setDefault(defaultValue); + p.setName(name); + p.setType(type); + p.setValue(value); + + assertEquals(name, p.getName()); + assertEquals(type, p.getType()); + assertEquals(defaultValue, p.getDefault()); + assertEquals(value, p.getValue()); + + } + +} diff --git a/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/externalservice/sdc/entity/WorkflowArtifactInfoTest.java b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/externalservice/sdc/entity/WorkflowArtifactInfoTest.java new file mode 100644 index 00000000..73412637 --- /dev/null +++ b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/externalservice/sdc/entity/WorkflowArtifactInfoTest.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.externalservice.sdc.entity; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * + */ +public class WorkflowArtifactInfoTest { + + /** + * @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 artifactName = "artifactName"; + String description = "description"; + String artifactType = "WORKFLOW"; + String payloadData = "payloadData"; + + WorkflowArtifactInfo wai = new WorkflowArtifactInfo(artifactName, description, payloadData); + wai.setArtifactName(artifactName); + wai.setArtifactType(artifactType); + wai.setDescription(description); + wai.setPayloadData(payloadData); + + assertEquals(artifactName, wai.getArtifactName()); + assertEquals(description, wai.getDescription()); + assertEquals(artifactType, wai.getArtifactType()); + assertEquals(payloadData, wai.getPayloadData()); + } + +} diff --git a/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/model/DataObjectTest.java b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/model/DataObjectTest.java new file mode 100644 index 00000000..da2806ce --- /dev/null +++ b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/model/DataObjectTest.java @@ -0,0 +1,53 @@ +/** + * 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.model; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * + */ +public class DataObjectTest { + + /** + * @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 id = "id"; + String name = "name"; + String value = "value"; + + DataObject d = new DataObject(); + d.setId(id); + d.setName(name); + d.setValue(value); + + assertEquals(id, d.getId()); + assertEquals(name, d.getName()); + assertEquals(value, d.getValue()); + } + +} diff --git a/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/model/ElementTest.java b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/model/ElementTest.java new file mode 100644 index 00000000..520061ed --- /dev/null +++ b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/model/ElementTest.java @@ -0,0 +1,79 @@ +/** + * 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.model; + +import static org.junit.Assert.assertEquals; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.onap.sdc.workflowdesigner.model.Element.TYPE; + +/** + * + */ +public class ElementTest { + + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception {} + + /** + * @throws java.lang.Exception + */ + @After + public void tearDown() throws Exception {} + + /** + * Test method for {@link org.onap.sdc.workflowdesigner.model.Element#getType()} + * + */ + @Test + public final void getType() { + Element endEvent = new EndEvent(); + System.out.println(endEvent.getType()); + assertEquals(endEvent.getType(), null); + } + + + @Test + public void test() { + String id = "id"; + String name = "name"; + TYPE type = TYPE.endEvent; + String documentation = "documentation"; + Position position = new Position(); + List<String> connections= new ArrayList<>(); + + Element e = new Element(); + e.setConnections(connections); + e.setDocumentation(documentation); + e.setId(id); + e.setName(name); + e.setPosition(position); + e.setType(type); + + assertEquals(connections, e.getConnections()); + assertEquals(documentation, e.getDocumentation()); + assertEquals(id, e.getId()); + assertEquals(name, e.getName()); + assertEquals(position, e.getPosition()); + assertEquals(type, e.getType()); + } + +} diff --git a/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/model/ErrorEndEventTest.java b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/model/ErrorEndEventTest.java new file mode 100644 index 00000000..98e19646 --- /dev/null +++ b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/model/ErrorEndEventTest.java @@ -0,0 +1,47 @@ +/** + * 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.model; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * + */ +public class ErrorEndEventTest { + + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception {} + + /** + * @throws java.lang.Exception + */ + @After + public void tearDown() throws Exception {} + + @Test + public void test() { + Parameter parameter = new Parameter(); + + ErrorEndEvent eee = new ErrorEndEvent(); + eee.setParameter(parameter); + + assertEquals(parameter, eee.getParameter()); + } + +} diff --git a/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/model/ParameterTest.java b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/model/ParameterTest.java new file mode 100644 index 00000000..fea6a6f4 --- /dev/null +++ b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/model/ParameterTest.java @@ -0,0 +1,69 @@ +/** + * 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.model; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; + +/** + * + */ +public class ParameterTest { + + /** + * @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 description = "description"; + String name = "name"; + String position = "position"; + boolean required = false; + String type = "type"; + Object value = "value"; + String valueSource = "valueSource"; + + Parameter p = new Parameter(); + p.setDescription(description); + p.setName(name); + p.setPosition(position); + p.setRequired(required); + p.setType(type); + p.setValueSource(valueSource); + p.setValue(value); + + assertEquals(description, p.getDescription()); + assertEquals(name, p.getName()); + assertEquals(position, p.getPosition()); + assertEquals(required, p.isRequired()); + assertEquals(type, p.getType()); + assertEquals(valueSource, p.getValueSource()); + assertEquals(value, p.getValue()); + + } + +} diff --git a/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/model/PositionTest.java b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/model/PositionTest.java new file mode 100644 index 00000000..5ebb335c --- /dev/null +++ b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/model/PositionTest.java @@ -0,0 +1,50 @@ +/** + * 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.model; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * + */ +public class PositionTest { + + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception {} + + /** + * @throws java.lang.Exception + */ + @After + public void tearDown() throws Exception {} + + @Test + public void test() { + int left = 100; + int top = 100; + + Position p = new Position(); + p.setLeft(left); + p.setTop(top); + + assertEquals(left, p.getLeft()); + assertEquals(top, p.getTop()); + } + +} diff --git a/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/model/ProcessTest.java b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/model/ProcessTest.java new file mode 100644 index 00000000..34c3cc64 --- /dev/null +++ b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/model/ProcessTest.java @@ -0,0 +1,62 @@ +/** + * 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.model; + +import static org.junit.Assert.*; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * + */ +public class ProcessTest { + + /** + * @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 id = "id"; + boolean isExecutable = false; + List<Element> elementList = new ArrayList<Element>(); + List<SequenceFlow> sequenceFlowList = new ArrayList<SequenceFlow>(); + List<DataObject> dataObjectList = new ArrayList<DataObject>(); + + Process p = new Process(id); + p.setDataObjectList(dataObjectList); + p.setElementList(elementList); + p.setExecutable(isExecutable); + p.setId(id); + p.setSequenceFlowList(sequenceFlowList); + + assertEquals(dataObjectList, p.getDataObjectList()); + assertEquals(elementList, p.getElementList()); + assertEquals(isExecutable, p.isExecutable()); + assertEquals(id, p.getId()); + assertEquals(sequenceFlowList, p.getSequenceFlowList()); + } + +} diff --git a/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/model/RestServiceTaskTest.java b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/model/RestServiceTaskTest.java new file mode 100644 index 00000000..1aa593c5 --- /dev/null +++ b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/model/RestServiceTaskTest.java @@ -0,0 +1,71 @@ +/** + * 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.model; + +import static org.junit.Assert.*; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * + */ +public class RestServiceTaskTest { + + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception {} + + /** + * @throws java.lang.Exception + */ + @After + public void tearDown() throws Exception {} + + @Test + public void test() { + List<String> produces = new ArrayList<>(); + List<String> consumes = new ArrayList<>(); + List<Parameter> parameters = new ArrayList<>(); + String baseUrl = ""; + String serviceName = ""; + String serviceVersion = ""; + String path = ""; + String method = ""; + + RestServiceTask rst = new RestServiceTask(); + rst.setProduces(produces); + rst.setConsumes(consumes); + rst.setParameters(parameters); + rst.setBaseUrl(baseUrl); + rst.setServiceName(serviceName); + rst.setServiceVersion(serviceVersion); + rst.setPath(path); + rst.setMethod(method); + + assertEquals(produces, rst.getProduces()); + assertEquals(consumes, rst.getConsumes()); + assertEquals(parameters, rst.getParameters()); + assertEquals(baseUrl, rst.getBaseUrl()); + assertEquals(serviceName, rst.getServiceName()); + assertEquals(serviceVersion, rst.getServiceVersion()); + assertEquals(path, rst.getPath()); + assertEquals(method, rst.getMethod()); + } + +} diff --git a/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/model/ScriptTaskTest.java b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/model/ScriptTaskTest.java new file mode 100644 index 00000000..1eaba96d --- /dev/null +++ b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/model/ScriptTaskTest.java @@ -0,0 +1,50 @@ +/** + * 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.model; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * + */ +public class ScriptTaskTest { + + /** + * @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 scriptFormat = "scriptFormat"; + String script = "script"; + + ScriptTask st = new ScriptTask(); + st.setScript(script); + st.setScriptFormat(scriptFormat); + + assertEquals(scriptFormat, st.getScriptFormat()); + assertEquals(script, st.getScript()); + } + +} diff --git a/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/model/SequenceFlowTest.java b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/model/SequenceFlowTest.java new file mode 100644 index 00000000..ae947b58 --- /dev/null +++ b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/model/SequenceFlowTest.java @@ -0,0 +1,62 @@ +/** + * 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.model; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * + */ +public class SequenceFlowTest { + + /** + * @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 id = "id"; + String name = "name"; + String sourceRef = "sourceRef"; + String targetRef = "targetRef"; + String documentation = "documentation"; + String condition = "condition"; + + SequenceFlow sf = new SequenceFlow(); + sf.setCondition(condition); + sf.setDocumentation(documentation); + sf.setId(id); + sf.setName(name); + sf.setSourceRef(sourceRef); + sf.setTargetRef(targetRef); + + assertEquals(condition, sf.getCondition()); + assertEquals(documentation, sf.getDocumentation()); + assertEquals(id, sf.getId()); + assertEquals(name, sf.getName()); + assertEquals(sourceRef, sf.getSourceRef()); + assertEquals(targetRef, sf.getTargetRef()); + } + +} diff --git a/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/model/ServiceTaskTest.java b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/model/ServiceTaskTest.java new file mode 100644 index 00000000..e2718d19 --- /dev/null +++ b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/model/ServiceTaskTest.java @@ -0,0 +1,56 @@ +/** + * 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.model; + +import static org.junit.Assert.*; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * + */ +public class ServiceTaskTest { + + /** + * @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 className = "className"; + List<Parameter> inputs = new ArrayList<>(); + List<Parameter> outputs = new ArrayList<>(); + + ServiceTask st = new ServiceTask(); + st.setClassName(className); + st.setInputs(inputs); + st.setOutputs(outputs); + + assertEquals(className, st.getClassName()); + assertEquals(inputs, st.getInputs()); + assertEquals(outputs, st.getOutputs()); + } + +} diff --git a/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/model/TimerEventDefinitionTest.java b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/model/TimerEventDefinitionTest.java new file mode 100644 index 00000000..8c82ddf0 --- /dev/null +++ b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/model/TimerEventDefinitionTest.java @@ -0,0 +1,56 @@ +/** + * 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.model; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * + */ +public class TimerEventDefinitionTest { + + /** + * @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 type = "type"; + String timeDuration = "timeDuration"; + String timeDate = "timeDate"; + String timeCycle = "timeCycle"; + + TimerEventDefinition ted = new TimerEventDefinition(); + ted.setType(type); + ted.setTimeDate(timeDate); + ted.setTimeDuration(timeDuration); + ted.setTimeCycle(timeCycle); + + assertEquals(type, ted.getType()); + assertEquals(timeDate, ted.getTimeDate()); + assertEquals(timeDuration, ted.getTimeDuration()); + assertEquals(timeCycle, ted.getTimeCycle()); + } + +} diff --git a/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/parser/Bpmn4ToscaJsonParserTest.java b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/parser/Bpmn4ToscaJsonParserTest.java new file mode 100644 index 00000000..abadd298 --- /dev/null +++ b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/parser/Bpmn4ToscaJsonParserTest.java @@ -0,0 +1,130 @@ +/** + * 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.parser; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URI; +import java.nio.file.Paths; +import java.util.Iterator; +import java.util.List; + +import org.junit.Test; +import org.onap.sdc.workflowdesigner.model.Element; +import org.onap.sdc.workflowdesigner.model.Position; +import org.onap.sdc.workflowdesigner.model.Process; +import org.onap.sdc.workflowdesigner.model.ScriptTask; +import org.onap.sdc.workflowdesigner.model.SequenceFlow; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; + +public class Bpmn4ToscaJsonParserTest { + + private static String RESOURCES_DIR = "src/test/resources/workflow"; + protected static String PROCESS_NAME = "test1"; + + @Test + public void parseTest() throws JsonParseException, JsonMappingException, MalformedURLException, IOException { + Bpmn4ToscaJsonParser parser = new Bpmn4ToscaJsonParser(); + URI srcUri = Paths.get(RESOURCES_DIR, "workflow.json").toUri(); + Process actualProcess = parser.parse(PROCESS_NAME, srcUri); + Process expectedProcess = createReferenceProcess(); + + assertElements(expectedProcess.getElementList(), actualProcess.getElementList()); + assertSequenceFlows(expectedProcess.getSequenceFlowList(), actualProcess.getSequenceFlowList()); + } + + private static void assertElements(List<Element> expectedElementList, List<Element> actualElementList) { + assertEquals(expectedElementList.size(), actualElementList.size()); + + for (Iterator<Element> iterator = expectedElementList.iterator(); iterator.hasNext();) { + Element expectedElement = (Element) iterator.next(); + Element actualElement = getElementById(expectedElement.getId(), actualElementList); + if (actualElement != null) { + assertElement(expectedElement, actualElement); + } else { + fail("Element with id " + expectedElement.getId() + " could not be found"); + } + } + } + + private static Element getElementById(String id, List<Element> actualElementList) { + Iterator<Element> iter = actualElementList.iterator(); + while (iter.hasNext()) { + Element element = (Element) iter.next(); + if (element.getId().equals(id)) { + return element; + } + } + return null; + } + + public static void assertElement(Element expected, Element actual) { + assertEquals("element: id ", expected.getId(), actual.getId()); + assertEquals("element: name ", expected.getName(), actual.getName()); + } + + public static void assertSequenceFlows(List<SequenceFlow> expectedSequenceList, + List<SequenceFlow> actualSequenceFlowList) { + assertEquals(expectedSequenceList.size(), actualSequenceFlowList.size()); + + for (Iterator<SequenceFlow> iterator = expectedSequenceList.iterator(); iterator.hasNext();) { + SequenceFlow expectedElement = (SequenceFlow) iterator.next(); + SequenceFlow actualElement = getSequenceById(expectedElement.getSourceRef(), expectedElement.getTargetRef(), + actualSequenceFlowList); + if (actualElement != null) { + assertLink(expectedElement, actualElement); + } else { + fail("Element with id " + expectedElement.getId() + " could not be found"); + } + } + } + + private static SequenceFlow getSequenceById(String sourceRef, String targetRef, + List<SequenceFlow> actualSequenceFlowList) { + Iterator<SequenceFlow> iter = actualSequenceFlowList.iterator(); + while (iter.hasNext()) { + SequenceFlow element = (SequenceFlow) iter.next(); + if (element.getSourceRef().equals(sourceRef) && element.getTargetRef().equals(targetRef)) { + return element; + } + } + return null; + } + + public static void assertLink(SequenceFlow expectedLink, SequenceFlow actualLink) { + assertEquals("Link source: id", expectedLink.getSourceRef(), actualLink.getSourceRef()); + assertEquals("Link target :id", expectedLink.getTargetRef(), actualLink.getTargetRef()); + } + + private static Process createReferenceProcess() { + Process process = new Process(PROCESS_NAME); + + ScriptTask scriptTask = new ScriptTask(); + scriptTask.setId("scriptTask"); + scriptTask.setName("Script Task"); + Position position = new Position(); + position.setLeft(328); + position.setTop(134); + scriptTask.setPosition(position); + scriptTask.setScript(""); + scriptTask.setScriptFormat("JavaScript"); + process.getElementList().add(scriptTask); + + return process; + } + +} diff --git a/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/planwriter/BpmnPlanArtefactWriterTest.java b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/planwriter/BpmnPlanArtefactWriterTest.java new file mode 100644 index 00000000..a67a2070 --- /dev/null +++ b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/planwriter/BpmnPlanArtefactWriterTest.java @@ -0,0 +1,58 @@ +/** + * 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.planwriter; + +import static org.junit.Assert.assertEquals; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; + +import org.junit.Test; +import org.onap.sdc.workflowdesigner.model.Process; +import org.onap.sdc.workflowdesigner.writer.BpmnPlanArtefactWriter; + +public class BpmnPlanArtefactWriterTest { + + @Test + public void testWritePlan() throws Exception { + BpmnPlanArtefactWriter writer = new BpmnPlanArtefactWriter(mockProcss()); + String result = writer.completePlanTemplate(); + assertEquals(result, getResult()); + } + + private Process mockProcss() { + Process process = new Process("templateTest"); + + return process; + } + + public String getResult() throws IOException { + StringBuffer buffer = new StringBuffer(); + + String path = "src/test/resources/workflow/template-test.bpmn20.xml"; + BufferedReader reader = new BufferedReader(new FileReader(new File(path))); + + String line = null; + while ((line = reader.readLine()) != null) { + buffer.append(line).append("\r\n"); + } + + if (reader != null) { + reader.close(); + } + + return buffer.toString(); + } + +} diff --git a/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/ExtendActivityResourceTest.java b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/ExtendActivityResourceTest.java new file mode 100644 index 00000000..be55aed0 --- /dev/null +++ b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/ExtendActivityResourceTest.java @@ -0,0 +1,66 @@ +/** + * 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.resources; + +import static org.junit.Assert.assertEquals; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.onap.sdc.workflowdesigner.resources.entity.ExtActivity; +import org.onap.sdc.workflowdesigner.utils.FileCommonUtils; +import org.onap.sdc.workflowdesigner.utils.JsonUtils; + +/** + * + */ +public class ExtendActivityResourceTest { + private static final String EXT_ACTIVITIES_FILE_NAME = "src/main/assembly/ext-activities.json"; + + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception {} + + /** + * @throws java.lang.Exception + */ + @After + public void tearDown() throws Exception {} + + /** + * + */ + @Test + public void testRetriveExtActivites() { + try { + String json = FileCommonUtils.readString(EXT_ACTIVITIES_FILE_NAME); + ExtActivity[] extActivities = JsonUtils.fromJson(json, ExtActivity[].class); + + FileCommonUtils.write("test.json", JsonUtils.toJson(extActivities)); + assertEquals(extActivities.length == 0, false); + } catch (Exception e) { + e.printStackTrace(); + } + + } + + /** + * Test method for {@link org.onap.sdc.workflowdesigner.resources.ExtendActivityResource#getDisplayInfo(java.lang.String)}. + */ + @Test + public void testGetDisplayInfo() { + + } + +} diff --git a/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/WorkflowModelerResourceTest.java b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/WorkflowModelerResourceTest.java new file mode 100644 index 00000000..47a46a8c --- /dev/null +++ b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/WorkflowModelerResourceTest.java @@ -0,0 +1,109 @@ +/** + * 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.resources; + +import static org.junit.Assert.assertEquals; + +import java.io.IOException; +import java.net.URI; +import java.nio.file.Paths; +import java.util.UUID; + +import org.dom4j.DocumentException; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.onap.sdc.workflowdesigner.resources.entity.WorkflowInfo; +import org.onap.sdc.workflowdesigner.utils.FileCommonUtils; +import org.onap.sdc.workflowdesigner.utils.JsonUtils; + +/** + * + */ +public class WorkflowModelerResourceTest { + private static final String WORKFLOW_JSON_TEMP_FILE_NAME = "temp_workflow.json"; + + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception {} + + /** + * @throws java.lang.Exception + */ + @After + public void tearDown() throws Exception {} + + /** + * Test method for + * {@link org.onap.sdc.workflowdesigner.resources.WorkflowModelerResource#buildBPMN(java.net.URI, java.lang.String)}. + */ + @Test + public void testBuildBPMN() { + String bpmn = parseBpmnfromJsonFile(); + assertEquals(false, bpmn.isEmpty()); + } + + /** + * @return + */ + private String parseBpmnfromJsonFile() { + try { + URI srcUri = Paths.get("src/main/assembly", WORKFLOW_JSON_TEMP_FILE_NAME).toUri(); + WorkflowModelerResource resource = new WorkflowModelerResource(); + String processName = "plan_" + UUID.randomUUID().toString(); + return resource.buildBPMN(srcUri, processName); + } catch (IOException e) { + } catch (Exception e) { + } + + return null; + } + + /** + * Test method for + * {@link org.onap.sdc.workflowdesigner.resources.WorkflowModelerResource#insertJson2Bpmn(java.lang.String, java.lang.String)}. + */ + @Test + public void testInsertJson2Bpmn() { + String bpmn = parseBpmnfromJsonFile(); + + try { + String json = FileCommonUtils.readString("src/main/assembly/" + WORKFLOW_JSON_TEMP_FILE_NAME); + WorkflowModelerResource resource = new WorkflowModelerResource(); + String combineBpmn = resource.insertJson2Bpmn(json, bpmn); + + String json1 = resource.readJsonfromBPMN(combineBpmn); + + assertEqualsJson(json, json1); + } catch (IOException e) { + } catch (DocumentException e) { + } + } + + /** + * @param json + * @param json1 + */ + private void assertEqualsJson(String json, String json1) { + WorkflowInfo wi = JsonUtils.fromJson(json, WorkflowInfo.class); + WorkflowInfo wi1 = JsonUtils.fromJson(json1, WorkflowInfo.class); + + String newJson = JsonUtils.toJson(wi); + String newJson1 = JsonUtils.toJson(wi1); + + assertEquals(newJson1, newJson); + + } + +} diff --git a/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/entity/CategoryDataTest.java b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/entity/CategoryDataTest.java new file mode 100644 index 00000000..590432fd --- /dev/null +++ b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/entity/CategoryDataTest.java @@ -0,0 +1,50 @@ +/** + * 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.resources.entity; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * + */ +public class CategoryDataTest { + + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception {} + + /** + * @throws java.lang.Exception + */ + @After + public void tearDown() throws Exception {} + + @Test + public void test() { + I18nString displayName = new I18nString(); + boolean collapse = false; + + CategoryData cd = new CategoryData(); + cd.setDisplayName(displayName); + cd.setCollapse(collapse); + + assertEquals(false, cd.isCollapse()); + assertEquals(displayName, cd.getDisplayName()); + } + +} diff --git a/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/entity/ContentTest.java b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/entity/ContentTest.java new file mode 100644 index 00000000..8458fc5e --- /dev/null +++ b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/entity/ContentTest.java @@ -0,0 +1,73 @@ +/** + * 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.resources.entity; + +import static org.junit.Assert.*; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.onap.sdc.workflowdesigner.utils.JsonUtils; + +/** + * + */ +public class ContentTest { + + /** + * @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 clazz = "clazz"; + String script = "script"; + String scriptFormat = "scriptFormat"; + Map<String, InputOutput> inputs = new HashMap<String, InputOutput>(); + Map<String, InputOutput> outputs = new HashMap<String, InputOutput>(); + + Content c = new Content(); +// c.setClass(clazz); + c.setInputs(inputs); + c.setOutputs(outputs); + c.setScript(script); + c.setScriptFormat(scriptFormat); + +// assertEquals(clazz, c.getClazz()); + assertEquals(inputs, c.getInputs()); + assertEquals(outputs, c.getOutputs()); + assertEquals(script, c.getScript()); + assertEquals(scriptFormat, c.getScriptFormat()); + } + + @Test + public void testGson() { + String json = "{\r\n" + + " \"class\": \"aaaa\",\r\n" + + " \"inputs\": {}\r\n" + + " }"; + Content content = JsonUtils.fromJson(json, Content.class); + assertNotNull(content); + } + +} diff --git a/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/entity/ExtActivityDisplayInfoTest.java b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/entity/ExtActivityDisplayInfoTest.java new file mode 100644 index 00000000..6c26ec75 --- /dev/null +++ b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/entity/ExtActivityDisplayInfoTest.java @@ -0,0 +1,53 @@ +/** + * 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.resources.entity; + +import static org.junit.Assert.*; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * + */ +public class ExtActivityDisplayInfoTest { + + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception {} + + /** + * @throws java.lang.Exception + */ + @After + public void tearDown() throws Exception {} + + @Test + public void test() { + Map<String, NodeCategory> nodes = new HashMap<>(); + Map<String, CategoryData> categoryData = new HashMap<>(); + + ExtActivityDisplayInfo ed = new ExtActivityDisplayInfo(); + ed.setCategoryData(categoryData); + ed.setNodes(nodes); + + assertEquals(categoryData, ed.getCategoryData()); + assertEquals(nodes, ed.getNodes()); + } + +} diff --git a/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/entity/ExtendActivityTest.java b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/entity/ExtendActivityTest.java new file mode 100644 index 00000000..aca66b0f --- /dev/null +++ b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/entity/ExtendActivityTest.java @@ -0,0 +1,63 @@ +/** + * 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.resources.entity; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * + */ +public class ExtendActivityTest { + + /** + * @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 id = ""; + I18nString displayName = new I18nString(); + I18nString description = new I18nString(); + String type = ""; + IconData icon = new IconData(); + Content content = new Content(); + + ExtActivity ea = new ExtActivity(); + ea.setContent(content); + ea.setDescription(description); + ea.setDisplayName(displayName); + ea.setIcon(icon); + ea.setId(id); + ea.setType(type); + + assertEquals(content, ea.getContent()); + assertEquals(description, ea.getDescription()); + assertEquals(displayName, ea.getDisplayName()); + assertEquals(icon, ea.getIcon()); + assertEquals(id, ea.getId()); + assertEquals(type, ea.getType()); + + } + +} diff --git a/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/entity/I18nStringTest.java b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/entity/I18nStringTest.java new file mode 100644 index 00000000..f72a10b3 --- /dev/null +++ b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/entity/I18nStringTest.java @@ -0,0 +1,49 @@ +/** + * 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.resources.entity; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * + */ +public class I18nStringTest { + + /** + * @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 en_US = "en_US"; + String zh_CN = "zh_CN"; + I18nString i18n = new I18nString(en_US, zh_CN); + i18n.setEn_US(en_US); + i18n.setZh_CN(zh_CN); + + assertEquals(en_US, i18n.getEn_US()); + assertEquals(zh_CN, i18n.getZh_CN()); + } + +} diff --git a/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/entity/IconDataTest.java b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/entity/IconDataTest.java new file mode 100644 index 00000000..dae22c03 --- /dev/null +++ b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/entity/IconDataTest.java @@ -0,0 +1,53 @@ +/** + * 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.resources.entity; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * + */ +public class IconDataTest { + + /** + * @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 name = "name"; + int width = 100; + int height= 10; + + IconData id = new IconData(); + id.setHeight(height); + id.setName(name); + id.setWidth(width); + + assertEquals(height, id.getHeight()); + assertEquals(name, id.getName()); + assertEquals(width, id.getWidth()); + } + +} diff --git a/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/entity/InputOutputTest.java b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/entity/InputOutputTest.java new file mode 100644 index 00000000..f453088d --- /dev/null +++ b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/entity/InputOutputTest.java @@ -0,0 +1,67 @@ +/** + * 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.resources.entity; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import com.google.gson.annotations.SerializedName; + +/** + * + */ +public class InputOutputTest { + + /** + * @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 type = ""; + String defaultValue = ""; + boolean required = false; + I18nString displayName = new I18nString(); + boolean show = true; + boolean editable = true; + String value = ""; + + InputOutput io = new InputOutput(); + io.setDefault(defaultValue); + io.setDisplayName(displayName); + io.setEditable(editable); + io.setRequired(required); + io.setShow(show); + io.setType(type); + io.setValue(value); + + assertEquals(defaultValue, io.getDefault()); + assertEquals(displayName, io.getDisplayName()); + assertEquals(editable, io.isEditable()); + assertEquals(required, io.isRequired()); + assertEquals(show, io.isShow()); + assertEquals(type, io.getType()); + assertEquals(value, io.getValue()); + } + +} diff --git a/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/entity/NodeCategoryTest.java b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/entity/NodeCategoryTest.java new file mode 100644 index 00000000..2342d43d --- /dev/null +++ b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/entity/NodeCategoryTest.java @@ -0,0 +1,47 @@ +/** + * 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.resources.entity; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * + */ +public class NodeCategoryTest { + + /** + * @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 category = "category"; + + NodeCategory nc = new NodeCategory(); + nc.setCategory(category); + + assertEquals(category, nc.getCategory()); + } + +} diff --git a/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/entity/WorkflowInfoTest.java b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/entity/WorkflowInfoTest.java new file mode 100644 index 00000000..488a744c --- /dev/null +++ b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/resources/entity/WorkflowInfoTest.java @@ -0,0 +1,67 @@ +/** + * 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.resources.entity; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import com.google.gson.JsonObject; + +/** + * + */ +public class WorkflowInfoTest { + + /** + * @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 uuid = ""; + String operationId = ""; + String id = ""; + String name = ""; + String description = ""; + String scene = ""; + JsonObject data =new JsonObject(); + + WorkflowInfo wi = new WorkflowInfo(); + wi.setData(data); + wi.setDescription(description); + wi.setId(id); + wi.setName(name); + wi.setOperationId(operationId); + wi.setScene(scene); + wi.setUuid(uuid); + + assertEquals(data, wi.getData()); + assertEquals(description, wi.getDescription()); + assertEquals(id, wi.getId()); + assertEquals(name, wi.getName()); + assertEquals(operationId, wi.getOperationId()); + assertEquals(scene, wi.getScene()); + assertEquals(uuid, wi.getUuid()); + } + +} diff --git a/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/utils/FileCommonUtilsTest.java b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/utils/FileCommonUtilsTest.java new file mode 100644 index 00000000..0abddfff --- /dev/null +++ b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/utils/FileCommonUtilsTest.java @@ -0,0 +1,175 @@ +/** + * 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.utils; + +import static org.junit.Assert.assertEquals; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.StringBufferInputStream; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * + */ +public class FileCommonUtilsTest { + + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception {} + + /** + * @throws java.lang.Exception + */ + @After + public void tearDown() throws Exception {} + + /** + * Test method for {@link org.onap.sdc.workflowdesigner.utils.FileCommonUtils#readLines(java.io.InputStream)}. + */ + @Test + public void testReadLines() { + String fileName = "src/test/resources/workflow/template-test.bpmn20.xml"; + File file = new File(fileName); + FileInputStream ins = null; + try { + ins = new FileInputStream(file); + String[] ss = FileCommonUtils.readLines(ins); + assertEquals(false, ss.length == 0); + + FileCommonUtils.write("template-test.bpmn20.xml", ss); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } finally { + FileCommonUtils.closeInputStream(ins); + } + + } + + /** + * Test method for {@link org.onap.sdc.workflowdesigner.utils.FileCommonUtils#readString(java.io.InputStream)}. + */ + @Test + public void testReadStringInputStream() { + } + + /** + * Test method for {@link org.onap.sdc.workflowdesigner.utils.FileCommonUtils#readString(java.lang.String)}. + */ + @Test + public void testReadStringString() { + String fileName = "src/test/resources/workflow/template-test.bpmn20.xml"; + File file = new File(fileName); + if (file.exists()) { + try { + String s = FileCommonUtils.readString(fileName); + FileCommonUtils.write("test.xml", s); + assertEquals(s.isEmpty(), false); + } catch (IOException e) { + } + } + } + + /** + * Test method for {@link org.onap.sdc.workflowdesigner.utils.FileCommonUtils#saveFile(java.io.InputStream, java.lang.String, java.lang.String)}. + */ + @Test + public void testSaveFile() { + String fileName = "test3.json"; + String content = "{\"aaa\": \"节点\"}"; + StringBufferInputStream ins = null; + try { + ins = new StringBufferInputStream(content); + FileCommonUtils.saveFile(ins, ".", fileName); + } catch (IOException e) { + e.printStackTrace(); + FileCommonUtils.closeInputStream(ins); + } + } + + /** + * Test method for {@link org.onap.sdc.workflowdesigner.utils.FileCommonUtils#writetoAbsoluteFile(java.lang.String, java.lang.String, java.lang.String)}. + */ + @Test + public void testWritetoAbsoluteFileStringStringString() { + String fileName = "test1.json"; + String content = "{\"aaa\": \"节点\"}"; + + try { + FileCommonUtils.writetoAbsoluteFile(".", fileName, content); + String s = FileCommonUtils.readString(fileName); + assertEquals(s, content); + } catch (IOException e) { + } + } + + /** + * Test method for {@link org.onap.sdc.workflowdesigner.utils.FileCommonUtils#writetoAbsoluteFile(java.lang.String, java.lang.String, java.lang.String, java.lang.String)}. + */ + @Test + public void testWritetoAbsoluteFileStringStringStringString() { + } + + /** + * Test method for {@link org.onap.sdc.workflowdesigner.utils.FileCommonUtils#write(java.lang.String, java.lang.String)}. + */ + @Test + public void testWriteStringString() { + String fileName = "test.json"; + String content = "{\"aaa\": \"节点\"}"; + + try { + FileCommonUtils.write(fileName, content); + String s = FileCommonUtils.readString(fileName); + assertEquals(s, content); + } catch (IOException e) { + } + } + + /** + * Test method for {@link org.onap.sdc.workflowdesigner.utils.FileCommonUtils#write(java.lang.String, java.lang.String, java.lang.String, java.lang.String)}. + */ + @Test + public void testWriteStringStringStringString() { + } + + /** + * Test method for {@link org.onap.sdc.workflowdesigner.utils.FileCommonUtils#write(java.lang.String, java.lang.String, java.lang.String)}. + */ + @Test + public void testWriteStringStringString() { + } + + /** + * Test method for {@link org.onap.sdc.workflowdesigner.utils.FileCommonUtils#write(java.lang.String, java.lang.String[])}. + */ + @Test + public void testWriteStringStringArray() { + } + + /** + * Test method for {@link org.onap.sdc.workflowdesigner.utils.FileCommonUtils#write(java.lang.String, java.lang.String[], java.lang.String)}. + */ + @Test + public void testWriteStringStringArrayString() { + } + +} diff --git a/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/utils/JsonUtilsTest.java b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/utils/JsonUtilsTest.java new file mode 100644 index 00000000..c4b341fd --- /dev/null +++ b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/utils/JsonUtilsTest.java @@ -0,0 +1,59 @@ +/** + * 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.utils; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.onap.sdc.workflowdesigner.resources.entity.I18nString; + +/** + * + */ +public class JsonUtilsTest { + + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception {} + + /** + * @throws java.lang.Exception + */ + @After + public void tearDown() throws Exception {} + + /** + * Test method for {@link org.onap.sdc.workflowdesigner.utils.JsonUtils#fromJson(java.lang.String, java.lang.Class)}. + */ + @Test + public void testFromJson() { + String i18n = "{\"en_US\":\"Service Task\",\"zh_CN\":\"Service Task\"}"; + I18nString i18nString = JsonUtils.fromJson(i18n, I18nString.class); + assertNotNull(i18nString); + } + + /** + * Test method for {@link org.onap.sdc.workflowdesigner.utils.JsonUtils#toJson(java.lang.Object)}. + */ + @Test + public void testToJson() { + I18nString i18nString = new I18nString("Service Task", "Service Task"); + String i18n = JsonUtils.toJson(i18nString); + String expect = "{\"en_US\":\"Service Task\",\"zh_CN\":\"Service Task\"}"; + assertEquals(expect, i18n); + } + +} diff --git a/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/utils/entity/CommonErrorResponseTest.java b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/utils/entity/CommonErrorResponseTest.java new file mode 100644 index 00000000..f6014cfd --- /dev/null +++ b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/utils/entity/CommonErrorResponseTest.java @@ -0,0 +1,51 @@ +/** + * 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.utils.entity; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * + */ +public class CommonErrorResponseTest { + + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception {} + + /** + * @throws java.lang.Exception + */ + @After + public void tearDown() throws Exception {} + + /** + * Test method for {@link org.onap.sdc.workflowdesigner.utils.entity.CommonErrorResponse#failure(java.lang.String)}. + */ + @Test + public void testFailure() { + String code = "code"; + String message = "message"; + CommonErrorResponse errorResponse = new CommonErrorResponse(code); + errorResponse.setCode(code); + errorResponse.setMessage(message); + assertEquals(code, errorResponse.getCode()); + assertEquals(message, errorResponse.getMessage()); + } + +} diff --git a/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/resources/workflow/template-test.bpmn20.xml b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/resources/workflow/template-test.bpmn20.xml new file mode 100644 index 00000000..de2dee8d --- /dev/null +++ b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/resources/workflow/template-test.bpmn20.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" + xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" + xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" + expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test"> + <process id="templateTest" isExecutable="true"> + <!-- dataObjects --> + + <!-- Perform bpmn elements --> + + <!-- Perform bpmn sequence flow --> + + </process> +</definitions> diff --git a/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/resources/workflow/workflow.json b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/resources/workflow/workflow.json new file mode 100644 index 00000000..554e663f --- /dev/null +++ b/deprecated-workflow-designer/sdc-workflow-designer-server/src/test/resources/workflow/workflow.json @@ -0,0 +1,28 @@ +{ + "id":"id12345", + "name":"test", + "scene":"abcd", + "data":{ + "nodes":[ + { + "id":"scriptTask", + "type":"scriptTask", + "typeId":"apds_script", + "icon":"apds_script", + "name":"Script Task", + "parentId":"root", + "position":{ + "left":328, + "top":134, + "width":56, + "height":56 + }, + "connection":[ + + ], + "scriptFormat":"JavaScript", + "script":"" + } + ] + } +}
\ No newline at end of file |