summaryrefslogtreecommitdiffstats
path: root/testsuites/integration/integration-uservice-test/src/test/resources
diff options
context:
space:
mode:
authora.sreekumar <ajith.sreekumar@est.tech>2020-02-25 16:49:33 +0000
committera.sreekumar <ajith.sreekumar@est.tech>2020-02-27 09:50:48 +0000
commit6ddf46e995be34cc03d92a41948e14dfc5c9f4f9 (patch)
tree505ca1d25eba0bf62635a10e0eebd0d4449178a6 /testsuites/integration/integration-uservice-test/src/test/resources
parentaacc7442f046d44359934ea3d93f425a809e7616 (diff)
Add integration tests for Parameter passing in APEX
Change-Id: I5d01766ffb0104f632bebc9b553e7dca83b4829f Issue-ID: POLICY-2364 Signed-off-by: a.sreekumar <ajith.sreekumar@est.tech>
Diffstat (limited to 'testsuites/integration/integration-uservice-test/src/test/resources')
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/resources/policies/taskparameters/SetControlLoopNameForTest.js37
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/resources/policies/taskparameters/SetServiceIdForTest.js36
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/resources/policies/taskparameters/TaskParametersTestPolicyModel.apex65
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/resources/testdata/taskparameters/TaskParameterTestConfig_with_invalidTaskIds.json88
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/resources/testdata/taskparameters/TaskParameterTestConfig_with_noTaskIds.json86
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/resources/testdata/taskparameters/TaskParameterTestConfig_with_validTaskIds.json88
6 files changed, 400 insertions, 0 deletions
diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/policies/taskparameters/SetControlLoopNameForTest.js b/testsuites/integration/integration-uservice-test/src/test/resources/policies/taskparameters/SetControlLoopNameForTest.js
new file mode 100644
index 000000000..a4ab0360f
--- /dev/null
+++ b/testsuites/integration/integration-uservice-test/src/test/resources/policies/taskparameters/SetControlLoopNameForTest.js
@@ -0,0 +1,37 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+executor.logger.info(executor.subject.id);
+executor.logger.info(executor.inFields);
+executor.logger.info(executor.outFields);
+executor.logger.info(executor.parameters);
+
+executor.logger.info("executionProperties in: {}", executor.getExecutionProperties());
+
+executor.getExecutionProperties().setProperty("tagId", "doActionForCL");
+var closedLoopId = executor.parameters.get("closedLoopId")
+if (null == closedLoopId) {
+ closedLoopId = "INVALID - closedLoopId not available in TaskParameters"
+}
+executor.getExecutionProperties().setProperty("value", closedLoopId);
+
+executor.logger.info("executionProperties out: {}", executor.getExecutionProperties());
+
+var returnValue = executor.isTrue; \ No newline at end of file
diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/policies/taskparameters/SetServiceIdForTest.js b/testsuites/integration/integration-uservice-test/src/test/resources/policies/taskparameters/SetServiceIdForTest.js
new file mode 100644
index 000000000..6d56616d8
--- /dev/null
+++ b/testsuites/integration/integration-uservice-test/src/test/resources/policies/taskparameters/SetServiceIdForTest.js
@@ -0,0 +1,36 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+executor.logger.info(executor.subject.id);
+executor.logger.info(executor.inFields);
+executor.logger.info(executor.outFields);
+executor.logger.info(executor.parameters);
+
+executor.logger.info("executionProperties in: {}", executor.getExecutionProperties());
+
+executor.getExecutionProperties().setProperty("tagId", "getInfoForServiceId");
+var svcId = executor.parameters.get("serviceId")
+if (null == svcId) {
+ svcId = "INVALID - serviceId not available in TaskParameters"
+}
+executor.getExecutionProperties().setProperty("value", svcId);
+
+executor.logger.info("executionProperties out: {}", executor.getExecutionProperties());
+var returnValue = executor.isTrue; \ No newline at end of file
diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/policies/taskparameters/TaskParametersTestPolicyModel.apex b/testsuites/integration/integration-uservice-test/src/test/resources/policies/taskparameters/TaskParametersTestPolicyModel.apex
new file mode 100644
index 000000000..551a46bfd
--- /dev/null
+++ b/testsuites/integration/integration-uservice-test/src/test/resources/policies/taskparameters/TaskParametersTestPolicyModel.apex
@@ -0,0 +1,65 @@
+#-------------------------------------------------------------------------------
+# ============LICENSE_START=======================================================
+# Copyright (C) 2020 Nordix Foundation.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+# ============LICENSE_END=========================================================
+#-------------------------------------------------------------------------------
+
+model create name=TaskParametersTestPolicyModel
+
+schema create name=SimpleStringType flavour=Java schema=java.lang.String
+
+event create name=CLTriggerEvent nameSpace=org.onap.policy.apex.domains.test source=Junit target=APEX
+event parameter create name=CLTriggerEvent parName=event schemaName=SimpleStringType
+
+event create name=ServiceInfoEvent nameSpace=org.onap.policy.apex.domains.test source=Decide target=OutSide
+event parameter create name=ServiceInfoEvent parName=serviceDetails schemaName=SimpleStringType
+
+event create name=CLOutputEvent nameSpace=org.onap.policy.apex.domains.test source=Decide target=OutSide
+event parameter create name=CLOutputEvent parName=status schemaName=SimpleStringType
+
+task create name=SetServiceIdForTest version=1.0.0
+
+task inputfield create name=SetServiceIdForTest fieldName=event schemaName=SimpleStringType
+task outputfield create name=SetServiceIdForTest fieldName=serviceDetails schemaName=SimpleStringType
+
+task logic create name=SetServiceIdForTest logicFlavour=JAVASCRIPT logic=LS
+#MACROFILE:"src/test/resources/policies/taskparameters/SetServiceIdForTest.js"
+LE
+
+task create name=SetControlLoopNameForTest version=1.0.0
+
+task inputfield create name=SetControlLoopNameForTest fieldName=serviceDetails schemaName=SimpleStringType
+task outputfield create name=SetControlLoopNameForTest fieldName=status schemaName=SimpleStringType
+
+task logic create name=SetControlLoopNameForTest logicFlavour=JAVASCRIPT logic=LS
+#MACROFILE:"src/test/resources/policies/taskparameters/SetControlLoopNameForTest.js"
+LE
+
+
+policy create name=Policy1 template=freestyle firstState=Junit
+
+policy state create name=Policy1 stateName=Junit triggerName=CLTriggerEvent defaultTaskName=SetServiceIdForTest
+policy state output create name=Policy1 stateName=Junit outputName=ServiceInfo eventName=ServiceInfoEvent nextState=NULL
+policy state taskref create name=Policy1 stateName=Junit taskLocalName=SetServiceInfo taskName=SetServiceIdForTest outputType=DIRECT outputName=ServiceInfo
+
+policy create name=Policy2 template=freestyle firstState=Decide
+
+policy state create name=Policy2 stateName=Decide triggerName=ServiceInfoEvent defaultTaskName=SetControlLoopNameForTest
+policy state output create name=Policy2 stateName=Decide outputName=CLOut eventName=CLOutputEvent nextState=NULL
+policy state taskref create name=Policy2 stateName=Decide taskLocalName=SetControlLoopName taskName=SetControlLoopNameForTest outputType=DIRECT outputName=CLOut
+validate
+
diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/testdata/taskparameters/TaskParameterTestConfig_with_invalidTaskIds.json b/testsuites/integration/integration-uservice-test/src/test/resources/testdata/taskparameters/TaskParameterTestConfig_with_invalidTaskIds.json
new file mode 100644
index 000000000..0714f4b37
--- /dev/null
+++ b/testsuites/integration/integration-uservice-test/src/test/resources/testdata/taskparameters/TaskParameterTestConfig_with_invalidTaskIds.json
@@ -0,0 +1,88 @@
+{
+ "engineServiceParameters": {
+ "name": "MyApexEngine",
+ "version": "0.0.1",
+ "id": 45,
+ "instanceCount": 1,
+ "deploymentPort": 12561,
+ "policyModelFileName": "target/TaskParametersTestPolicyModel.json",
+ "engineParameters": {
+ "executorParameters": {
+ "JAVASCRIPT": {
+ "parameterClassName": "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters"
+ }
+ },
+ "taskParameters": [
+ {
+ "key": "serviceId",
+ "value": "serviceId123",
+ "taskId": "InvalidTaskId:1.0.0"
+ },
+ {
+ "key": "closedLoopId",
+ "value": "closedLoopId123",
+ "taskId": "InvalidTaskIdForCLOutTask"
+ }
+ ]
+ } },
+ "eventInputParameters": {
+ "GetCodeConsumer": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "RESTCLIENT",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters",
+ "parameters": {
+ "url": "http://localhost:32801/TestTaskParametersRest/apex/event/GetEvent",
+ "httpMethod": "GET"
+ }
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ },
+ "eventName": "CLTriggerEvent"
+ },
+ "FirstConsumer": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "RESTREQUESTOR",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters",
+ "parameters": {
+ "url": "http://localhost:32801/TestTaskParametersRest/apex/service/{tagId}/{value}",
+ "httpMethod": "POST"
+ }
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ },
+ "eventNameFilter": "ServiceInfoEvent",
+ "requestorMode": true,
+ "requestorPeer": "FirstProducer"
+ }
+ },
+ "eventOutputParameters": {
+ "FirstProducer": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "RESTREQUESTOR",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters"
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ },
+ "eventNameFilter": "ServiceInfoEvent",
+ "requestorMode": true,
+ "requestorPeer": "FirstConsumer"
+ },
+ "SecondProducer": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "RESTCLIENT",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters",
+ "parameters": {
+ "url": "http://localhost:32801/TestTaskParametersRest/apex/action/{tagId}/{value}",
+ "httpMethod": "POST"
+ }
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ },
+ "eventNameFilter": "CLOutputEvent"
+ }
+ }
+}
diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/testdata/taskparameters/TaskParameterTestConfig_with_noTaskIds.json b/testsuites/integration/integration-uservice-test/src/test/resources/testdata/taskparameters/TaskParameterTestConfig_with_noTaskIds.json
new file mode 100644
index 000000000..217d6bda2
--- /dev/null
+++ b/testsuites/integration/integration-uservice-test/src/test/resources/testdata/taskparameters/TaskParameterTestConfig_with_noTaskIds.json
@@ -0,0 +1,86 @@
+{
+ "engineServiceParameters": {
+ "name": "MyApexEngine",
+ "version": "0.0.1",
+ "id": 45,
+ "instanceCount": 1,
+ "deploymentPort": 12561,
+ "policyModelFileName": "target/TaskParametersTestPolicyModel.json",
+ "engineParameters": {
+ "executorParameters": {
+ "JAVASCRIPT": {
+ "parameterClassName": "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters"
+ }
+ },
+ "taskParameters": [
+ {
+ "key": "serviceId",
+ "value": "serviceId123"
+ },
+ {
+ "key": "closedLoopId",
+ "value": "closedLoopId123"
+ }
+ ]
+ } },
+ "eventInputParameters": {
+ "GetCodeConsumer": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "RESTCLIENT",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters",
+ "parameters": {
+ "url": "http://localhost:32801/TestTaskParametersRest/apex/event/GetEvent",
+ "httpMethod": "GET"
+ }
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ },
+ "eventName": "CLTriggerEvent"
+ },
+ "FirstConsumer": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "RESTREQUESTOR",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters",
+ "parameters": {
+ "url": "http://localhost:32801/TestTaskParametersRest/apex/service/{tagId}/{value}",
+ "httpMethod": "POST"
+ }
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ },
+ "eventNameFilter": "ServiceInfoEvent",
+ "requestorMode": true,
+ "requestorPeer": "FirstProducer"
+ }
+ },
+ "eventOutputParameters": {
+ "FirstProducer": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "RESTREQUESTOR",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters"
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ },
+ "eventNameFilter": "ServiceInfoEvent",
+ "requestorMode": true,
+ "requestorPeer": "FirstConsumer"
+ },
+ "SecondProducer": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "RESTCLIENT",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters",
+ "parameters": {
+ "url": "http://localhost:32801/TestTaskParametersRest/apex/action/{tagId}/{value}",
+ "httpMethod": "POST"
+ }
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ },
+ "eventNameFilter": "CLOutputEvent"
+ }
+ }
+}
diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/testdata/taskparameters/TaskParameterTestConfig_with_validTaskIds.json b/testsuites/integration/integration-uservice-test/src/test/resources/testdata/taskparameters/TaskParameterTestConfig_with_validTaskIds.json
new file mode 100644
index 000000000..0029374f9
--- /dev/null
+++ b/testsuites/integration/integration-uservice-test/src/test/resources/testdata/taskparameters/TaskParameterTestConfig_with_validTaskIds.json
@@ -0,0 +1,88 @@
+{
+ "engineServiceParameters": {
+ "name": "MyApexEngine",
+ "version": "0.0.1",
+ "id": 45,
+ "instanceCount": 1,
+ "deploymentPort": 12561,
+ "policyModelFileName": "target/TaskParametersTestPolicyModel.json",
+ "engineParameters": {
+ "executorParameters": {
+ "JAVASCRIPT": {
+ "parameterClassName": "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters"
+ }
+ },
+ "taskParameters": [
+ {
+ "key": "serviceId",
+ "value": "serviceIdxyz",
+ "taskId": "SetServiceIdForTest:1.0.0"
+ },
+ {
+ "key": "closedLoopId",
+ "value": "closedLoopIdxyz",
+ "taskId": "SetControlLoopNameForTest:1.0.0"
+ }
+ ]
+ } },
+ "eventInputParameters": {
+ "GetCodeConsumer": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "RESTCLIENT",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters",
+ "parameters": {
+ "url": "http://localhost:32801/TestTaskParametersRest/apex/event/GetEvent",
+ "httpMethod": "GET"
+ }
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ },
+ "eventName": "CLTriggerEvent"
+ },
+ "FirstConsumer": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "RESTREQUESTOR",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters",
+ "parameters": {
+ "url": "http://localhost:32801/TestTaskParametersRest/apex/service/{tagId}/{value}",
+ "httpMethod": "POST"
+ }
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ },
+ "eventNameFilter": "ServiceInfoEvent",
+ "requestorMode": true,
+ "requestorPeer": "FirstProducer"
+ }
+ },
+ "eventOutputParameters": {
+ "FirstProducer": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "RESTREQUESTOR",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters"
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ },
+ "eventNameFilter": "ServiceInfoEvent",
+ "requestorMode": true,
+ "requestorPeer": "FirstConsumer"
+ },
+ "SecondProducer": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "RESTCLIENT",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters",
+ "parameters": {
+ "url": "http://localhost:32801/TestTaskParametersRest/apex/action/{tagId}/{value}",
+ "httpMethod": "POST"
+ }
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ },
+ "eventNameFilter": "CLOutputEvent"
+ }
+ }
+}