aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRashmi Pujar <rashmi.pujar1@bell.ca>2022-01-22 00:37:28 -0500
committerRashmi Pujar <rashmi.pujar1@bell.ca>2022-01-24 14:06:57 -0500
commit632899642b6a1d1489a0b96932c9c38863a53a26 (patch)
treeab9665853aa637ab1d76d7c25523c77835d3ca3e
parentc719ee941bd4202b617544e351a11a35b20b8a6a (diff)
Add TOSCA policy status header field to APEX event create CLI
In order to expose the processing status of a TOSCA policy to APEX-PDP, a new header field for APEX concept "event" has been introduced to track this within an APEX policy implementation. This field will be leveraged to extract the TOSCA policy execution metrics. Note, that the field is marked as optional for backward compatibility. Unit tests have been augmented to test for the field wherever applicable and the default empty value is retained for the others. "example-grpc" module has been updated to include this field. Exposing the TOSCA policy execution metrics is outside the scope of this patch since the current changes are already very large owing to the atomic nature of the change introduced. Issue-ID: POLICY-3845 Signed-off-by: Rashmi Pujar <rashmi.pujar1@bell.ca> Change-Id: Ief6d70f9abcfc8414e10aa51a27815ee9028e4c8
-rw-r--r--auth/cli-editor/src/main/resources/etc/editor/Commands.json12
-rw-r--r--auth/cli-editor/src/test/resources/tosca/PolicyModel.json14
-rw-r--r--auth/cli-editor/src/test/resources/tosca/ToscaPolicyOutput_compare.json2
-rw-r--r--core/core-engine/src/test/java/org/onap/policy/apex/core/engine/event/EnEventTest.java5
-rw-r--r--examples/examples-grpc/src/main/resources/examples/events/APEXgRPC/CDSResponseStatusEvent.json3
-rw-r--r--examples/examples-grpc/src/main/resources/examples/events/APEXgRPC/LogEvent.json3
-rw-r--r--examples/examples-grpc/src/main/resources/policy/APEXgRPCPolicy.apex7
-rw-r--r--examples/examples-grpc/src/test/java/org/onap/policy/apex/examples/grpc/TestApexGrpcExample.java7
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxToscaPolicyProcessingStatus.java46
-rw-r--r--model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxEvent.java64
-rw-r--r--model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventsTest.java52
-rw-r--r--model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexEditorApi.java10
-rw-r--r--model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ApexModelImpl.java14
-rw-r--r--model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/EventFacade.java17
-rw-r--r--model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiEventTest.java32
-rw-r--r--model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentVerboseValues.txt8
-rw-r--r--model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonIdenticalVerboseValues.txt8
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/test/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsProducerTest.java15
-rw-r--r--plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JmsObjectEventConverter.java7
-rw-r--r--plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/main/java/org/onap/policy/apex/plugins/event/protocol/xml/Apex2XmlEventConverter.java7
-rw-r--r--plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/XmlEventHandlerTest.java9
-rw-r--r--plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java/org/onap/policy/apex/plugins/event/protocol/yaml/Apex2YamlEventConverter.java25
-rw-r--r--plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java/org/onap/policy/apex/plugins/event/protocol/yaml/YamlEventProtocolParameters.java16
-rw-r--r--plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/YamlPluginStabilityTest.java8
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexEvent.java40
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexPeriodicEventGenerator.java8
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/enevent/ApexEvent2EnEventConverter.java8
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/Apex2JsonEventConverter.java25
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/JsonEventProtocolParameters.java14
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/ApexEventTest.java23
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/JsonEventConverterTest.java5
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/JsonEventHandlerTest.java8
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/impl/apexprotocolplugin/Apex2ApexEventConverterTest.java25
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/impl/enevent/ApexEvent2EnEventConverterTest.java9
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImplTest.java9
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorkerTest.java4
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/file/TestFile2File.java6
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/file/TestFile2FileFiltered.java10
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/engine/ApexServiceModelUpdateTest.java10
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/engine/ApexServiceTest.java21
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/resources/events/Context_AvroEventAlbum_EventOutCompare.json3
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/resources/events/Context_JavaEventAlbum_EventOutCompare.json3
42 files changed, 439 insertions, 183 deletions
diff --git a/auth/cli-editor/src/main/resources/etc/editor/Commands.json b/auth/cli-editor/src/main/resources/etc/editor/Commands.json
index 7136922a8..4f55389f8 100644
--- a/auth/cli-editor/src/main/resources/etc/editor/Commands.json
+++ b/auth/cli-editor/src/main/resources/etc/editor/Commands.json
@@ -507,6 +507,11 @@
"argumentName": "description",
"nullable": true,
"description": "event description, omit to generate a description"
+ },
+ {
+ "argumentName": "toscaPolicyState",
+ "nullable": true,
+ "description": "event toscaPolicyState, omit to generate a toscaPolicyState"
}
],
"apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorApi.createEvent",
@@ -553,6 +558,11 @@
"argumentName": "description",
"nullable": true,
"description": "event description, omit to not update"
+ },
+ {
+ "argumentName": "toscaPolicyState",
+ "nullable": true,
+ "description": "event toscaPolicyState, omit to generate a toscaPolicyState"
}
],
"apiMethod": "org.onap.policy.apex.model.modelapi.ApexEditorApi.updateEvent",
@@ -2424,4 +2434,4 @@
"description": "Delete a policy state context reference."
}
]
-}
+} \ No newline at end of file
diff --git a/auth/cli-editor/src/test/resources/tosca/PolicyModel.json b/auth/cli-editor/src/test/resources/tosca/PolicyModel.json
index 95fab2d5e..96976d1e1 100644
--- a/auth/cli-editor/src/test/resources/tosca/PolicyModel.json
+++ b/auth/cli-editor/src/test/resources/tosca/PolicyModel.json
@@ -522,7 +522,8 @@
}
}
]
- }
+ },
+ "toscaPolicyState": ""
},
"outputEvents": {
"entry": [
@@ -649,7 +650,8 @@
}
}
]
- }
+ },
+ "toscaPolicyState": ""
}
}
]
@@ -801,7 +803,8 @@
}
}
]
- }
+ },
+ "toscaPolicyState": ""
}
},
{
@@ -908,7 +911,8 @@
}
}
]
- }
+ },
+ "toscaPolicyState": ""
}
}
]
@@ -1065,4 +1069,4 @@
}
}
}
-}
+} \ No newline at end of file
diff --git a/auth/cli-editor/src/test/resources/tosca/ToscaPolicyOutput_compare.json b/auth/cli-editor/src/test/resources/tosca/ToscaPolicyOutput_compare.json
index 3649f945b..26a844ba4 100644
--- a/auth/cli-editor/src/test/resources/tosca/ToscaPolicyOutput_compare.json
+++ b/auth/cli-editor/src/test/resources/tosca/ToscaPolicyOutput_compare.json
@@ -1 +1 @@
-{"tosca_definitions_version":"tosca_simple_yaml_1_1_0","topology_template":{"policies":[{"native.sampledomain":{"type":"onap.policies.native.Apex","type_version":"1.0.0","name":"native.sampledomain","version":"1.0.0","properties":{"engineServiceParameters":{"name":"MyFirstPolicyApexEngine","version":"0.0.1","id":101,"instanceCount":4,"deploymentPort":12345,"engineParameters":{"executorParameters":{"MVEL":{"parameterClassName":"org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters"},"JAVASCRIPT":{"parameterClassName":"org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters"}}},"policy_type_impl":{"apexPolicyModel":{"key":{"name":"MyFirstPolicyModel","version":"0.0.1"},"keyInformation":{"key":{"name":"MyFirstPolicyModel_KeyInfo","version":"0.0.1"},"keyInfoMap":{"entry":[{"key":{"name":"MorningBoozeCheck","version":"0.0.1"},"value":{"key":{"name":"MorningBoozeCheck","version":"0.0.1"},"UUID":"3351b0f4-cf06-4fa2-8823-edf67bd30223","description":"This task checks if the sales request is for an item that contains alcohol. \nIf the local time is between 00:00:00 and 11:30:00 then the sale is not authorised. Otherwise the sale is authorised. \nIn this implementation we assume that all items with item_ID values between 1000 and 2000 contain alcohol :-)"}},{"key":{"name":"MyFirstPolicy","version":"0.0.1"},"value":{"key":{"name":"MyFirstPolicy","version":"0.0.1"},"UUID":"6c5e410f-489a-46ff-964e-982ce6e8b6d0","description":"This is my first Apex policy. It checks if a sale should be authorised or not."}},{"key":{"name":"MyFirstPolicyModel","version":"0.0.1"},"value":{"key":{"name":"MyFirstPolicyModel","version":"0.0.1"},"UUID":"540226fb-55ee-4f0e-a444-983a0494818e","description":"This is my first Apex Policy Model."}},{"key":{"name":"MyFirstPolicyModel_Events","version":"0.0.1"},"value":{"key":{"name":"MyFirstPolicyModel_Events","version":"0.0.1"},"UUID":"ef281318-5ac9-3ef0-8db3-8f9c4e4a81e2","description":"Generated description for concept referred to by key \"MyFirstPolicyModel_Events:0.0.1\""}},{"key":{"name":"MyFirstPolicyModel_KeyInfo","version":"0.0.1"},"value":{"key":{"name":"MyFirstPolicyModel_KeyInfo","version":"0.0.1"},"UUID":"d9248c6f-7c00-38df-8251-611463ba4065","description":"Generated description for concept referred to by key \"MyFirstPolicyModel_KeyInfo:0.0.1\""}},{"key":{"name":"MyFirstPolicyModel_Policies","version":"0.0.1"},"value":{"key":{"name":"MyFirstPolicyModel_Policies","version":"0.0.1"},"UUID":"77c01a6b-510c-3aa9-b640-b4db356aa03b","description":"Generated description for concept referred to by key \"MyFirstPolicyModel_Policies:0.0.1\""}},{"key":{"name":"MyFirstPolicyModel_Schemas","version":"0.0.1"},"value":{"key":{"name":"MyFirstPolicyModel_Schemas","version":"0.0.1"},"UUID":"d0cc3aa0-ea69-3a43-80ff-a0dbb0ebd885","description":"Generated description for concept referred to by key \"MyFirstPolicyModel_Schemas:0.0.1\""}},{"key":{"name":"MyFirstPolicyModel_Tasks","version":"0.0.1"},"value":{"key":{"name":"MyFirstPolicyModel_Tasks","version":"0.0.1"},"UUID":"b02a7e02-2cd0-39e6-b3cb-946fa83a8f08","description":"Generated description for concept referred to by key \"MyFirstPolicyModel_Tasks:0.0.1\""}},{"key":{"name":"SALE_AUTH","version":"0.0.1"},"value":{"key":{"name":"SALE_AUTH","version":"0.0.1"},"UUID":"c4500941-3f98-4080-a9cc-5b9753ed050b","description":"An event emitted by the Policy to indicate whether the sale of an item has been authorised"}},{"key":{"name":"SALE_INPUT","version":"0.0.1"},"value":{"key":{"name":"SALE_INPUT","version":"0.0.1"},"UUID":"4f04aa98-e917-4f4a-882a-c75ba5a99374","description":"An event raised by the PoS system each time an item is scanned for purchase"}},{"key":{"name":"assistant_ID_type","version":"0.0.1"},"value":{"key":{"name":"assistant_ID_type","version":"0.0.1"},"UUID":"36df4c71-9616-4206-8b53-976a5cd4bd87","description":"A type for 'assistant_ID' values"}},{"key":{"name":"authorised_type","version":"0.0.1"},"value":{"key":{"name":"authorised_type","version":"0.0.1"},"UUID":"d48b619e-d00d-4008-b884-02d76ea4350b","description":"A type for 'authorised' values"}},{"key":{"name":"branch_ID_type","version":"0.0.1"},"value":{"key":{"name":"branch_ID_type","version":"0.0.1"},"UUID":"6468845f-4122-4128-8e49-0f52c26078b5","description":"A type for 'branch_ID' values"}},{"key":{"name":"item_ID_type","version":"0.0.1"},"value":{"key":{"name":"item_ID_type","version":"0.0.1"},"UUID":"4f227ff1-aee0-453a-b6b6-9a4b2e0da932","description":"A type for 'item_ID' values"}},{"key":{"name":"message_type","version":"0.0.1"},"value":{"key":{"name":"message_type","version":"0.0.1"},"UUID":"ad1431bb-3155-4e73-b5a3-b89bee498749","description":"A type for 'message' values"}},{"key":{"name":"notes_type","version":"0.0.1"},"value":{"key":{"name":"notes_type","version":"0.0.1"},"UUID":"eecfde90-896c-4343-8f9c-2603ced94e2d","description":"A type for 'notes' values"}},{"key":{"name":"price_type","version":"0.0.1"},"value":{"key":{"name":"price_type","version":"0.0.1"},"UUID":"52c2fc45-fd8c-463c-bd6f-d91b0554aea7","description":"A type for 'amount'/'price' values"}},{"key":{"name":"quantity_type","version":"0.0.1"},"value":{"key":{"name":"quantity_type","version":"0.0.1"},"UUID":"ac3d9842-80af-4a98-951c-bd79a431c613","description":"A type for 'quantity' values"}},{"key":{"name":"sale_ID_type","version":"0.0.1"},"value":{"key":{"name":"sale_ID_type","version":"0.0.1"},"UUID":"cca47d74-7754-4a61-b163-ca31f66b157b","description":"A type for 'sale_ID' values"}},{"key":{"name":"timestamp_type","version":"0.0.1"},"value":{"key":{"name":"timestamp_type","version":"0.0.1"},"UUID":"fd594e88-411d-4a94-b2be-697b3a0d7adf","description":"A type for 'time' values"}}]}},"policies":{"key":{"name":"MyFirstPolicyModel_Policies","version":"0.0.1"},"policyMap":{"entry":[{"key":{"name":"MyFirstPolicy","version":"0.0.1"},"value":{"policyKey":{"name":"MyFirstPolicy","version":"0.0.1"},"template":"FREEFORM","state":{"entry":[{"key":"BoozeAuthDecide","value":{"stateKey":{"parentKeyName":"MyFirstPolicy","parentKeyVersion":"0.0.1","parentLocalName":"NULL","localName":"BoozeAuthDecide"},"trigger":{"name":"SALE_INPUT","version":"0.0.1"},"stateOutputs":{"entry":[{"key":"MorningBoozeCheck_Output_Direct","value":{"key":{"parentKeyName":"MyFirstPolicy","parentKeyVersion":"0.0.1","parentLocalName":"BoozeAuthDecide","localName":"MorningBoozeCheck_Output_Direct"},"outgoingEvent":{"name":"SALE_AUTH","version":"0.0.1"},"outgoingEventReference":[{"name":"SALE_AUTH","version":"0.0.1"}],"nextState":{"parentKeyName":"NULL","parentKeyVersion":"0.0.0","parentLocalName":"NULL","localName":"NULL"}}}]},"contextAlbumReference":[],"taskSelectionLogic":{"key":"NULL","logicFlavour":"UNDEFINED","logic":""},"stateFinalizerLogicMap":{"entry":[]},"defaultTask":{"name":"MorningBoozeCheck","version":"0.0.1"},"taskReferences":{"entry":[{"key":{"name":"MorningBoozeCheck","version":"0.0.1"},"value":{"key":{"parentKeyName":"MyFirstPolicy","parentKeyVersion":"0.0.1","parentLocalName":"BoozeAuthDecide","localName":"MorningBoozeCheck"},"outputType":"DIRECT","output":{"parentKeyName":"MyFirstPolicy","parentKeyVersion":"0.0.1","parentLocalName":"BoozeAuthDecide","localName":"MorningBoozeCheck_Output_Direct"}}}]}}}]},"firstState":"BoozeAuthDecide"}}]}},"tasks":{"key":{"name":"MyFirstPolicyModel_Tasks","version":"0.0.1"},"taskMap":{"entry":[{"key":{"name":"MorningBoozeCheck","version":"0.0.1"},"value":{"key":{"name":"MorningBoozeCheck","version":"0.0.1"},"inputEvent":{"key":{"name":"SALE_INPUT","version":"0.0.1"},"nameSpace":"com.hyperm","source":"POS","target":"APEX","parameter":{"entry":[{"key":"amount","value":{"key":"amount","fieldSchemaKey":{"name":"price_type","version":"0.0.1"},"optional":false}},{"key":"assistant_ID","value":{"key":"assistant_ID","fieldSchemaKey":{"name":"assistant_ID_type","version":"0.0.1"},"optional":false}},{"key":"branch_ID","value":{"key":"branch_ID","fieldSchemaKey":{"name":"branch_ID_type","version":"0.0.1"},"optional":false}},{"key":"item_ID","value":{"key":"item_ID","fieldSchemaKey":{"name":"item_ID_type","version":"0.0.1"},"optional":false}},{"key":"notes","value":{"key":"notes","fieldSchemaKey":{"name":"notes_type","version":"0.0.1"},"optional":true}},{"key":"quantity","value":{"key":"quantity","fieldSchemaKey":{"name":"quantity_type","version":"0.0.1"},"optional":false}},{"key":"sale_ID","value":{"key":"sale_ID","fieldSchemaKey":{"name":"sale_ID_type","version":"0.0.1"},"optional":false}},{"key":"time","value":{"key":"time","fieldSchemaKey":{"name":"timestamp_type","version":"0.0.1"},"optional":false}}]}},"outputEvents":{"entry":[{"key":"SALE_AUTH","value":{"key":{"name":"SALE_AUTH","version":"0.0.1"},"nameSpace":"com.hyperm","source":"APEX","target":"POS","parameter":{"entry":[{"key":"amount","value":{"key":"amount","fieldSchemaKey":{"name":"price_type","version":"0.0.1"},"optional":false}},{"key":"assistant_ID","value":{"key":"assistant_ID","fieldSchemaKey":{"name":"assistant_ID_type","version":"0.0.1"},"optional":false}},{"key":"authorised","value":{"key":"authorised","fieldSchemaKey":{"name":"authorised_type","version":"0.0.1"},"optional":false}},{"key":"branch_ID","value":{"key":"branch_ID","fieldSchemaKey":{"name":"branch_ID_type","version":"0.0.1"},"optional":false}},{"key":"item_ID","value":{"key":"item_ID","fieldSchemaKey":{"name":"item_ID_type","version":"0.0.1"},"optional":false}},{"key":"message","value":{"key":"message","fieldSchemaKey":{"name":"message_type","version":"0.0.1"},"optional":true}},{"key":"notes","value":{"key":"notes","fieldSchemaKey":{"name":"notes_type","version":"0.0.1"},"optional":true}},{"key":"quantity","value":{"key":"quantity","fieldSchemaKey":{"name":"quantity_type","version":"0.0.1"},"optional":false}},{"key":"sale_ID","value":{"key":"sale_ID","fieldSchemaKey":{"name":"sale_ID_type","version":"0.0.1"},"optional":false}},{"key":"time","value":{"key":"time","fieldSchemaKey":{"name":"timestamp_type","version":"0.0.1"},"optional":false}}]}}}]},"taskParameters":{"entry":[]},"contextAlbumReference":[],"taskLogic":{"key":"TaskLogic","logicFlavour":"MVEL","logic":"/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2016-2018 Ericsson. All rights reserved.\n * Modifications Copyright (C) 2019 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\nimport java.util.Date;\nimport java.util.Calendar;\nimport java.util.TimeZone;\nimport java.text.SimpleDateFormat;\n\nlogger.info(\"Task Execution: '\"+subject.id+\"'. Input Fields: '\"+inFields+\"'\");\n\noutFields.put(\"amount\" , inFields.get(\"amount\"));\noutFields.put(\"assistant_ID\", inFields.get(\"assistant_ID\"));\noutFields.put(\"notes\" , inFields.get(\"notes\"));\noutFields.put(\"quantity\" , inFields.get(\"quantity\"));\noutFields.put(\"branch_ID\" , inFields.get(\"branch_ID\"));\noutFields.put(\"item_ID\" , inFields.get(\"item_ID\"));\noutFields.put(\"time\" , inFields.get(\"time\"));\noutFields.put(\"sale_ID\" , inFields.get(\"sale_ID\"));\n\nitem_id = inFields.get(\"item_ID\");\n\n//The events used later to test this task use GMT timezone!\ngmt = TimeZone.getTimeZone(\"GMT\");\ntimenow = Calendar.getInstance(gmt);\ndf = new SimpleDateFormat(\"HH:mm:ss z\");\ndf.setTimeZone(gmt);\ntimenow.setTimeInMillis(inFields.get(\"time\"));\n\nmidnight = timenow.clone();\nmidnight.set(\n timenow.get(Calendar.YEAR),timenow.get(Calendar.MONTH),\n timenow.get(Calendar.DATE),0,0,0);\neleven30 = timenow.clone();\neleven30.set(\n timenow.get(Calendar.YEAR),timenow.get(Calendar.MONTH),\n timenow.get(Calendar.DATE),11,30,0);\n\nitemisalcohol = false;\nif(item_id != null && item_id >=1000 && item_id < 2000)\n itemisalcohol = true;\n\nif( itemisalcohol\n && timenow.after(midnight) && timenow.before(eleven30)){\n outFields.put(\"authorised\", false);\n outFields.put(\"message\", \"Sale not authorised by policy task \"+subject.taskName+\n \" for time \"+df.format(timenow.getTime())+\n \". Alcohol can not be sold between \"+df.format(midnight.getTime())+\n \" and \"+df.format(eleven30.getTime()));\n return true;\n}\nelse{\n outFields.put(\"authorised\", true);\n outFields.put(\"message\", \"Sale authorised by policy task \"+subject.taskName+\n \" for time \"+df.format(timenow.getTime()));\n return true;\n}\n\n/*\nThis task checks if a sale request is for an item that is an alcoholic drink.\nIf the local time is between 00:00:00 GMT and 11:30:00 GMT then the sale is not\nauthorised. Otherwise the sale is authorised.\nIn this implementation we assume that items with item_ID value between 1000 and\n2000 are all alcoholic drinks :-)\n*/"}}}]}},"events":{"key":{"name":"MyFirstPolicyModel_Events","version":"0.0.1"},"eventMap":{"entry":[{"key":{"name":"SALE_AUTH","version":"0.0.1"},"value":{"key":{"name":"SALE_AUTH","version":"0.0.1"},"nameSpace":"com.hyperm","source":"APEX","target":"POS","parameter":{"entry":[{"key":"amount","value":{"key":"amount","fieldSchemaKey":{"name":"price_type","version":"0.0.1"},"optional":false}},{"key":"assistant_ID","value":{"key":"assistant_ID","fieldSchemaKey":{"name":"assistant_ID_type","version":"0.0.1"},"optional":false}},{"key":"authorised","value":{"key":"authorised","fieldSchemaKey":{"name":"authorised_type","version":"0.0.1"},"optional":false}},{"key":"branch_ID","value":{"key":"branch_ID","fieldSchemaKey":{"name":"branch_ID_type","version":"0.0.1"},"optional":false}},{"key":"item_ID","value":{"key":"item_ID","fieldSchemaKey":{"name":"item_ID_type","version":"0.0.1"},"optional":false}},{"key":"message","value":{"key":"message","fieldSchemaKey":{"name":"message_type","version":"0.0.1"},"optional":true}},{"key":"notes","value":{"key":"notes","fieldSchemaKey":{"name":"notes_type","version":"0.0.1"},"optional":true}},{"key":"quantity","value":{"key":"quantity","fieldSchemaKey":{"name":"quantity_type","version":"0.0.1"},"optional":false}},{"key":"sale_ID","value":{"key":"sale_ID","fieldSchemaKey":{"name":"sale_ID_type","version":"0.0.1"},"optional":false}},{"key":"time","value":{"key":"time","fieldSchemaKey":{"name":"timestamp_type","version":"0.0.1"},"optional":false}}]}}},{"key":{"name":"SALE_INPUT","version":"0.0.1"},"value":{"key":{"name":"SALE_INPUT","version":"0.0.1"},"nameSpace":"com.hyperm","source":"POS","target":"APEX","parameter":{"entry":[{"key":"amount","value":{"key":"amount","fieldSchemaKey":{"name":"price_type","version":"0.0.1"},"optional":false}},{"key":"assistant_ID","value":{"key":"assistant_ID","fieldSchemaKey":{"name":"assistant_ID_type","version":"0.0.1"},"optional":false}},{"key":"branch_ID","value":{"key":"branch_ID","fieldSchemaKey":{"name":"branch_ID_type","version":"0.0.1"},"optional":false}},{"key":"item_ID","value":{"key":"item_ID","fieldSchemaKey":{"name":"item_ID_type","version":"0.0.1"},"optional":false}},{"key":"notes","value":{"key":"notes","fieldSchemaKey":{"name":"notes_type","version":"0.0.1"},"optional":true}},{"key":"quantity","value":{"key":"quantity","fieldSchemaKey":{"name":"quantity_type","version":"0.0.1"},"optional":false}},{"key":"sale_ID","value":{"key":"sale_ID","fieldSchemaKey":{"name":"sale_ID_type","version":"0.0.1"},"optional":false}},{"key":"time","value":{"key":"time","fieldSchemaKey":{"name":"timestamp_type","version":"0.0.1"},"optional":false}}]}}}]}},"schemas":{"key":{"name":"MyFirstPolicyModel_Schemas","version":"0.0.1"},"schemas":{"entry":[{"key":{"name":"assistant_ID_type","version":"0.0.1"},"value":{"key":{"name":"assistant_ID_type","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.Long"}},{"key":{"name":"authorised_type","version":"0.0.1"},"value":{"key":{"name":"authorised_type","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.Boolean"}},{"key":{"name":"branch_ID_type","version":"0.0.1"},"value":{"key":{"name":"branch_ID_type","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.Long"}},{"key":{"name":"item_ID_type","version":"0.0.1"},"value":{"key":{"name":"item_ID_type","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.Long"}},{"key":{"name":"message_type","version":"0.0.1"},"value":{"key":{"name":"message_type","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.String"}},{"key":{"name":"notes_type","version":"0.0.1"},"value":{"key":{"name":"notes_type","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.String"}},{"key":{"name":"price_type","version":"0.0.1"},"value":{"key":{"name":"price_type","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.Long"}},{"key":{"name":"quantity_type","version":"0.0.1"},"value":{"key":{"name":"quantity_type","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.Integer"}},{"key":{"name":"sale_ID_type","version":"0.0.1"},"value":{"key":{"name":"sale_ID_type","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.Long"}},{"key":{"name":"timestamp_type","version":"0.0.1"},"value":{"key":{"name":"timestamp_type","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.Long"}}]}}}}},"eventOutputParameters":{"FirstProducer":{"carrierTechnologyParameters":{"carrierTechnology":"FILE","parameters":{"standardIo":true}},"eventProtocolParameters":{"eventProtocol":"JSON"}}},"eventInputParameters":{"FirstConsumer":{"carrierTechnologyParameters":{"carrierTechnology":"FILE","parameters":{"standardIo":true}},"eventProtocolParameters":{"eventProtocol":"JSON"}}}}}}]}}
+{"tosca_definitions_version":"tosca_simple_yaml_1_1_0","topology_template":{"policies":[{"native.sampledomain":{"type":"onap.policies.native.Apex","type_version":"1.0.0","name":"native.sampledomain","version":"1.0.0","properties":{"engineServiceParameters":{"name":"MyFirstPolicyApexEngine","version":"0.0.1","id":101,"instanceCount":4,"deploymentPort":12345,"engineParameters":{"executorParameters":{"MVEL":{"parameterClassName":"org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters"},"JAVASCRIPT":{"parameterClassName":"org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters"}}},"policy_type_impl":{"apexPolicyModel":{"key":{"name":"MyFirstPolicyModel","version":"0.0.1"},"keyInformation":{"key":{"name":"MyFirstPolicyModel_KeyInfo","version":"0.0.1"},"keyInfoMap":{"entry":[{"key":{"name":"MorningBoozeCheck","version":"0.0.1"},"value":{"key":{"name":"MorningBoozeCheck","version":"0.0.1"},"UUID":"3351b0f4-cf06-4fa2-8823-edf67bd30223","description":"This task checks if the sales request is for an item that contains alcohol. \nIf the local time is between 00:00:00 and 11:30:00 then the sale is not authorised. Otherwise the sale is authorised. \nIn this implementation we assume that all items with item_ID values between 1000 and 2000 contain alcohol :-)"}},{"key":{"name":"MyFirstPolicy","version":"0.0.1"},"value":{"key":{"name":"MyFirstPolicy","version":"0.0.1"},"UUID":"6c5e410f-489a-46ff-964e-982ce6e8b6d0","description":"This is my first Apex policy. It checks if a sale should be authorised or not."}},{"key":{"name":"MyFirstPolicyModel","version":"0.0.1"},"value":{"key":{"name":"MyFirstPolicyModel","version":"0.0.1"},"UUID":"540226fb-55ee-4f0e-a444-983a0494818e","description":"This is my first Apex Policy Model."}},{"key":{"name":"MyFirstPolicyModel_Events","version":"0.0.1"},"value":{"key":{"name":"MyFirstPolicyModel_Events","version":"0.0.1"},"UUID":"ef281318-5ac9-3ef0-8db3-8f9c4e4a81e2","description":"Generated description for concept referred to by key \"MyFirstPolicyModel_Events:0.0.1\""}},{"key":{"name":"MyFirstPolicyModel_KeyInfo","version":"0.0.1"},"value":{"key":{"name":"MyFirstPolicyModel_KeyInfo","version":"0.0.1"},"UUID":"d9248c6f-7c00-38df-8251-611463ba4065","description":"Generated description for concept referred to by key \"MyFirstPolicyModel_KeyInfo:0.0.1\""}},{"key":{"name":"MyFirstPolicyModel_Policies","version":"0.0.1"},"value":{"key":{"name":"MyFirstPolicyModel_Policies","version":"0.0.1"},"UUID":"77c01a6b-510c-3aa9-b640-b4db356aa03b","description":"Generated description for concept referred to by key \"MyFirstPolicyModel_Policies:0.0.1\""}},{"key":{"name":"MyFirstPolicyModel_Schemas","version":"0.0.1"},"value":{"key":{"name":"MyFirstPolicyModel_Schemas","version":"0.0.1"},"UUID":"d0cc3aa0-ea69-3a43-80ff-a0dbb0ebd885","description":"Generated description for concept referred to by key \"MyFirstPolicyModel_Schemas:0.0.1\""}},{"key":{"name":"MyFirstPolicyModel_Tasks","version":"0.0.1"},"value":{"key":{"name":"MyFirstPolicyModel_Tasks","version":"0.0.1"},"UUID":"b02a7e02-2cd0-39e6-b3cb-946fa83a8f08","description":"Generated description for concept referred to by key \"MyFirstPolicyModel_Tasks:0.0.1\""}},{"key":{"name":"SALE_AUTH","version":"0.0.1"},"value":{"key":{"name":"SALE_AUTH","version":"0.0.1"},"UUID":"c4500941-3f98-4080-a9cc-5b9753ed050b","description":"An event emitted by the Policy to indicate whether the sale of an item has been authorised"}},{"key":{"name":"SALE_INPUT","version":"0.0.1"},"value":{"key":{"name":"SALE_INPUT","version":"0.0.1"},"UUID":"4f04aa98-e917-4f4a-882a-c75ba5a99374","description":"An event raised by the PoS system each time an item is scanned for purchase"}},{"key":{"name":"assistant_ID_type","version":"0.0.1"},"value":{"key":{"name":"assistant_ID_type","version":"0.0.1"},"UUID":"36df4c71-9616-4206-8b53-976a5cd4bd87","description":"A type for 'assistant_ID' values"}},{"key":{"name":"authorised_type","version":"0.0.1"},"value":{"key":{"name":"authorised_type","version":"0.0.1"},"UUID":"d48b619e-d00d-4008-b884-02d76ea4350b","description":"A type for 'authorised' values"}},{"key":{"name":"branch_ID_type","version":"0.0.1"},"value":{"key":{"name":"branch_ID_type","version":"0.0.1"},"UUID":"6468845f-4122-4128-8e49-0f52c26078b5","description":"A type for 'branch_ID' values"}},{"key":{"name":"item_ID_type","version":"0.0.1"},"value":{"key":{"name":"item_ID_type","version":"0.0.1"},"UUID":"4f227ff1-aee0-453a-b6b6-9a4b2e0da932","description":"A type for 'item_ID' values"}},{"key":{"name":"message_type","version":"0.0.1"},"value":{"key":{"name":"message_type","version":"0.0.1"},"UUID":"ad1431bb-3155-4e73-b5a3-b89bee498749","description":"A type for 'message' values"}},{"key":{"name":"notes_type","version":"0.0.1"},"value":{"key":{"name":"notes_type","version":"0.0.1"},"UUID":"eecfde90-896c-4343-8f9c-2603ced94e2d","description":"A type for 'notes' values"}},{"key":{"name":"price_type","version":"0.0.1"},"value":{"key":{"name":"price_type","version":"0.0.1"},"UUID":"52c2fc45-fd8c-463c-bd6f-d91b0554aea7","description":"A type for 'amount'/'price' values"}},{"key":{"name":"quantity_type","version":"0.0.1"},"value":{"key":{"name":"quantity_type","version":"0.0.1"},"UUID":"ac3d9842-80af-4a98-951c-bd79a431c613","description":"A type for 'quantity' values"}},{"key":{"name":"sale_ID_type","version":"0.0.1"},"value":{"key":{"name":"sale_ID_type","version":"0.0.1"},"UUID":"cca47d74-7754-4a61-b163-ca31f66b157b","description":"A type for 'sale_ID' values"}},{"key":{"name":"timestamp_type","version":"0.0.1"},"value":{"key":{"name":"timestamp_type","version":"0.0.1"},"UUID":"fd594e88-411d-4a94-b2be-697b3a0d7adf","description":"A type for 'time' values"}}]}},"policies":{"key":{"name":"MyFirstPolicyModel_Policies","version":"0.0.1"},"policyMap":{"entry":[{"key":{"name":"MyFirstPolicy","version":"0.0.1"},"value":{"policyKey":{"name":"MyFirstPolicy","version":"0.0.1"},"template":"FREEFORM","state":{"entry":[{"key":"BoozeAuthDecide","value":{"stateKey":{"parentKeyName":"MyFirstPolicy","parentKeyVersion":"0.0.1","parentLocalName":"NULL","localName":"BoozeAuthDecide"},"trigger":{"name":"SALE_INPUT","version":"0.0.1"},"stateOutputs":{"entry":[{"key":"MorningBoozeCheck_Output_Direct","value":{"key":{"parentKeyName":"MyFirstPolicy","parentKeyVersion":"0.0.1","parentLocalName":"BoozeAuthDecide","localName":"MorningBoozeCheck_Output_Direct"},"outgoingEvent":{"name":"SALE_AUTH","version":"0.0.1"},"outgoingEventReference":[{"name":"SALE_AUTH","version":"0.0.1"}],"nextState":{"parentKeyName":"NULL","parentKeyVersion":"0.0.0","parentLocalName":"NULL","localName":"NULL"}}}]},"contextAlbumReference":[],"taskSelectionLogic":{"key":"NULL","logicFlavour":"UNDEFINED","logic":""},"stateFinalizerLogicMap":{"entry":[]},"defaultTask":{"name":"MorningBoozeCheck","version":"0.0.1"},"taskReferences":{"entry":[{"key":{"name":"MorningBoozeCheck","version":"0.0.1"},"value":{"key":{"parentKeyName":"MyFirstPolicy","parentKeyVersion":"0.0.1","parentLocalName":"BoozeAuthDecide","localName":"MorningBoozeCheck"},"outputType":"DIRECT","output":{"parentKeyName":"MyFirstPolicy","parentKeyVersion":"0.0.1","parentLocalName":"BoozeAuthDecide","localName":"MorningBoozeCheck_Output_Direct"}}}]}}}]},"firstState":"BoozeAuthDecide"}}]}},"tasks":{"key":{"name":"MyFirstPolicyModel_Tasks","version":"0.0.1"},"taskMap":{"entry":[{"key":{"name":"MorningBoozeCheck","version":"0.0.1"},"value":{"key":{"name":"MorningBoozeCheck","version":"0.0.1"},"inputEvent":{"key":{"name":"SALE_INPUT","version":"0.0.1"},"nameSpace":"com.hyperm","source":"POS","target":"APEX","parameter":{"entry":[{"key":"amount","value":{"key":"amount","fieldSchemaKey":{"name":"price_type","version":"0.0.1"},"optional":false}},{"key":"assistant_ID","value":{"key":"assistant_ID","fieldSchemaKey":{"name":"assistant_ID_type","version":"0.0.1"},"optional":false}},{"key":"branch_ID","value":{"key":"branch_ID","fieldSchemaKey":{"name":"branch_ID_type","version":"0.0.1"},"optional":false}},{"key":"item_ID","value":{"key":"item_ID","fieldSchemaKey":{"name":"item_ID_type","version":"0.0.1"},"optional":false}},{"key":"notes","value":{"key":"notes","fieldSchemaKey":{"name":"notes_type","version":"0.0.1"},"optional":true}},{"key":"quantity","value":{"key":"quantity","fieldSchemaKey":{"name":"quantity_type","version":"0.0.1"},"optional":false}},{"key":"sale_ID","value":{"key":"sale_ID","fieldSchemaKey":{"name":"sale_ID_type","version":"0.0.1"},"optional":false}},{"key":"time","value":{"key":"time","fieldSchemaKey":{"name":"timestamp_type","version":"0.0.1"},"optional":false}}]},"toscaPolicyState":""},"outputEvents":{"entry":[{"key":"SALE_AUTH","value":{"key":{"name":"SALE_AUTH","version":"0.0.1"},"nameSpace":"com.hyperm","source":"APEX","target":"POS","parameter":{"entry":[{"key":"amount","value":{"key":"amount","fieldSchemaKey":{"name":"price_type","version":"0.0.1"},"optional":false}},{"key":"assistant_ID","value":{"key":"assistant_ID","fieldSchemaKey":{"name":"assistant_ID_type","version":"0.0.1"},"optional":false}},{"key":"authorised","value":{"key":"authorised","fieldSchemaKey":{"name":"authorised_type","version":"0.0.1"},"optional":false}},{"key":"branch_ID","value":{"key":"branch_ID","fieldSchemaKey":{"name":"branch_ID_type","version":"0.0.1"},"optional":false}},{"key":"item_ID","value":{"key":"item_ID","fieldSchemaKey":{"name":"item_ID_type","version":"0.0.1"},"optional":false}},{"key":"message","value":{"key":"message","fieldSchemaKey":{"name":"message_type","version":"0.0.1"},"optional":true}},{"key":"notes","value":{"key":"notes","fieldSchemaKey":{"name":"notes_type","version":"0.0.1"},"optional":true}},{"key":"quantity","value":{"key":"quantity","fieldSchemaKey":{"name":"quantity_type","version":"0.0.1"},"optional":false}},{"key":"sale_ID","value":{"key":"sale_ID","fieldSchemaKey":{"name":"sale_ID_type","version":"0.0.1"},"optional":false}},{"key":"time","value":{"key":"time","fieldSchemaKey":{"name":"timestamp_type","version":"0.0.1"},"optional":false}}]},"toscaPolicyState":""}}]},"taskParameters":{"entry":[]},"contextAlbumReference":[],"taskLogic":{"key":"TaskLogic","logicFlavour":"MVEL","logic":"/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2016-2018 Ericsson. All rights reserved.\n * Modifications Copyright (C) 2019 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\nimport java.util.Date;\nimport java.util.Calendar;\nimport java.util.TimeZone;\nimport java.text.SimpleDateFormat;\n\nlogger.info(\"Task Execution: '\"+subject.id+\"'. Input Fields: '\"+inFields+\"'\");\n\noutFields.put(\"amount\" , inFields.get(\"amount\"));\noutFields.put(\"assistant_ID\", inFields.get(\"assistant_ID\"));\noutFields.put(\"notes\" , inFields.get(\"notes\"));\noutFields.put(\"quantity\" , inFields.get(\"quantity\"));\noutFields.put(\"branch_ID\" , inFields.get(\"branch_ID\"));\noutFields.put(\"item_ID\" , inFields.get(\"item_ID\"));\noutFields.put(\"time\" , inFields.get(\"time\"));\noutFields.put(\"sale_ID\" , inFields.get(\"sale_ID\"));\n\nitem_id = inFields.get(\"item_ID\");\n\n//The events used later to test this task use GMT timezone!\ngmt = TimeZone.getTimeZone(\"GMT\");\ntimenow = Calendar.getInstance(gmt);\ndf = new SimpleDateFormat(\"HH:mm:ss z\");\ndf.setTimeZone(gmt);\ntimenow.setTimeInMillis(inFields.get(\"time\"));\n\nmidnight = timenow.clone();\nmidnight.set(\n timenow.get(Calendar.YEAR),timenow.get(Calendar.MONTH),\n timenow.get(Calendar.DATE),0,0,0);\neleven30 = timenow.clone();\neleven30.set(\n timenow.get(Calendar.YEAR),timenow.get(Calendar.MONTH),\n timenow.get(Calendar.DATE),11,30,0);\n\nitemisalcohol = false;\nif(item_id != null && item_id >=1000 && item_id < 2000)\n itemisalcohol = true;\n\nif( itemisalcohol\n && timenow.after(midnight) && timenow.before(eleven30)){\n outFields.put(\"authorised\", false);\n outFields.put(\"message\", \"Sale not authorised by policy task \"+subject.taskName+\n \" for time \"+df.format(timenow.getTime())+\n \". Alcohol can not be sold between \"+df.format(midnight.getTime())+\n \" and \"+df.format(eleven30.getTime()));\n return true;\n}\nelse{\n outFields.put(\"authorised\", true);\n outFields.put(\"message\", \"Sale authorised by policy task \"+subject.taskName+\n \" for time \"+df.format(timenow.getTime()));\n return true;\n}\n\n/*\nThis task checks if a sale request is for an item that is an alcoholic drink.\nIf the local time is between 00:00:00 GMT and 11:30:00 GMT then the sale is not\nauthorised. Otherwise the sale is authorised.\nIn this implementation we assume that items with item_ID value between 1000 and\n2000 are all alcoholic drinks :-)\n*/"}}}]}},"events":{"key":{"name":"MyFirstPolicyModel_Events","version":"0.0.1"},"eventMap":{"entry":[{"key":{"name":"SALE_AUTH","version":"0.0.1"},"value":{"key":{"name":"SALE_AUTH","version":"0.0.1"},"nameSpace":"com.hyperm","source":"APEX","target":"POS","parameter":{"entry":[{"key":"amount","value":{"key":"amount","fieldSchemaKey":{"name":"price_type","version":"0.0.1"},"optional":false}},{"key":"assistant_ID","value":{"key":"assistant_ID","fieldSchemaKey":{"name":"assistant_ID_type","version":"0.0.1"},"optional":false}},{"key":"authorised","value":{"key":"authorised","fieldSchemaKey":{"name":"authorised_type","version":"0.0.1"},"optional":false}},{"key":"branch_ID","value":{"key":"branch_ID","fieldSchemaKey":{"name":"branch_ID_type","version":"0.0.1"},"optional":false}},{"key":"item_ID","value":{"key":"item_ID","fieldSchemaKey":{"name":"item_ID_type","version":"0.0.1"},"optional":false}},{"key":"message","value":{"key":"message","fieldSchemaKey":{"name":"message_type","version":"0.0.1"},"optional":true}},{"key":"notes","value":{"key":"notes","fieldSchemaKey":{"name":"notes_type","version":"0.0.1"},"optional":true}},{"key":"quantity","value":{"key":"quantity","fieldSchemaKey":{"name":"quantity_type","version":"0.0.1"},"optional":false}},{"key":"sale_ID","value":{"key":"sale_ID","fieldSchemaKey":{"name":"sale_ID_type","version":"0.0.1"},"optional":false}},{"key":"time","value":{"key":"time","fieldSchemaKey":{"name":"timestamp_type","version":"0.0.1"},"optional":false}}]},"toscaPolicyState":""}},{"key":{"name":"SALE_INPUT","version":"0.0.1"},"value":{"key":{"name":"SALE_INPUT","version":"0.0.1"},"nameSpace":"com.hyperm","source":"POS","target":"APEX","parameter":{"entry":[{"key":"amount","value":{"key":"amount","fieldSchemaKey":{"name":"price_type","version":"0.0.1"},"optional":false}},{"key":"assistant_ID","value":{"key":"assistant_ID","fieldSchemaKey":{"name":"assistant_ID_type","version":"0.0.1"},"optional":false}},{"key":"branch_ID","value":{"key":"branch_ID","fieldSchemaKey":{"name":"branch_ID_type","version":"0.0.1"},"optional":false}},{"key":"item_ID","value":{"key":"item_ID","fieldSchemaKey":{"name":"item_ID_type","version":"0.0.1"},"optional":false}},{"key":"notes","value":{"key":"notes","fieldSchemaKey":{"name":"notes_type","version":"0.0.1"},"optional":true}},{"key":"quantity","value":{"key":"quantity","fieldSchemaKey":{"name":"quantity_type","version":"0.0.1"},"optional":false}},{"key":"sale_ID","value":{"key":"sale_ID","fieldSchemaKey":{"name":"sale_ID_type","version":"0.0.1"},"optional":false}},{"key":"time","value":{"key":"time","fieldSchemaKey":{"name":"timestamp_type","version":"0.0.1"},"optional":false}}]},"toscaPolicyState":""}}]}},"schemas":{"key":{"name":"MyFirstPolicyModel_Schemas","version":"0.0.1"},"schemas":{"entry":[{"key":{"name":"assistant_ID_type","version":"0.0.1"},"value":{"key":{"name":"assistant_ID_type","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.Long"}},{"key":{"name":"authorised_type","version":"0.0.1"},"value":{"key":{"name":"authorised_type","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.Boolean"}},{"key":{"name":"branch_ID_type","version":"0.0.1"},"value":{"key":{"name":"branch_ID_type","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.Long"}},{"key":{"name":"item_ID_type","version":"0.0.1"},"value":{"key":{"name":"item_ID_type","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.Long"}},{"key":{"name":"message_type","version":"0.0.1"},"value":{"key":{"name":"message_type","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.String"}},{"key":{"name":"notes_type","version":"0.0.1"},"value":{"key":{"name":"notes_type","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.String"}},{"key":{"name":"price_type","version":"0.0.1"},"value":{"key":{"name":"price_type","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.Long"}},{"key":{"name":"quantity_type","version":"0.0.1"},"value":{"key":{"name":"quantity_type","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.Integer"}},{"key":{"name":"sale_ID_type","version":"0.0.1"},"value":{"key":{"name":"sale_ID_type","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.Long"}},{"key":{"name":"timestamp_type","version":"0.0.1"},"value":{"key":{"name":"timestamp_type","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.Long"}}]}}}}},"eventOutputParameters":{"FirstProducer":{"carrierTechnologyParameters":{"carrierTechnology":"FILE","parameters":{"standardIo":true}},"eventProtocolParameters":{"eventProtocol":"JSON"}}},"eventInputParameters":{"FirstConsumer":{"carrierTechnologyParameters":{"carrierTechnology":"FILE","parameters":{"standardIo":true}},"eventProtocolParameters":{"eventProtocol":"JSON"}}}}}}]}} \ No newline at end of file
diff --git a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/event/EnEventTest.java b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/event/EnEventTest.java
index 128e585fe..49b4f80d2 100644
--- a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/event/EnEventTest.java
+++ b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/event/EnEventTest.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020-2021 Nordix Foundation
+ * Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -95,7 +96,7 @@ public class EnEventTest {
event.setUserArtifactStack(usedArtifactStackArray);
assertEquals(usedArtifactStackArray.length, event.getUserArtifactStack().length);
assertEquals("EnEvent [axEvent=AxEvent:(key=AxArtifactKey:(name=Event,version=0.0.1),nameSpace=a.name.space,"
- + "source=some source,target=some target,parameter={}), "
+ + "source=some source,target=some target,parameter={},toscaPolicyState=), "
+ "userArtifactStack=[AxArtifactKey:(name=Event,version=0.0.1)], map={}]", event.toString());
assertThatThrownBy(() -> event.put(null, null))
.hasMessage("null keys are illegal on method parameter \"key\"");
@@ -166,4 +167,4 @@ public class EnEventTest {
EnEvent otherEvent = new EnEvent(eventKey);
assertEquals(event, otherEvent);
}
-}
+} \ No newline at end of file
diff --git a/examples/examples-grpc/src/main/resources/examples/events/APEXgRPC/CDSResponseStatusEvent.json b/examples/examples-grpc/src/main/resources/examples/events/APEXgRPC/CDSResponseStatusEvent.json
index 938983362..d616ac12e 100644
--- a/examples/examples-grpc/src/main/resources/examples/events/APEXgRPC/CDSResponseStatusEvent.json
+++ b/examples/examples-grpc/src/main/resources/examples/events/APEXgRPC/CDSResponseStatusEvent.json
@@ -4,10 +4,11 @@
"nameSpace": "org.onap.policy.apex.onap.pmcontrol",
"source": "APEX",
"target": "DCAE",
+ "toscaPolicyState": "EXIT_SUCCESS",
"status": {
"subscriptionName": "testPolicyB",
"nfName": "pnf300",
"changeType": "CREATE",
"message": "success"
}
-}
+} \ No newline at end of file
diff --git a/examples/examples-grpc/src/main/resources/examples/events/APEXgRPC/LogEvent.json b/examples/examples-grpc/src/main/resources/examples/events/APEXgRPC/LogEvent.json
index e227b6699..6fd90771f 100644
--- a/examples/examples-grpc/src/main/resources/examples/events/APEXgRPC/LogEvent.json
+++ b/examples/examples-grpc/src/main/resources/examples/events/APEXgRPC/LogEvent.json
@@ -4,6 +4,7 @@
"nameSpace": "org.onap.policy.apex.onap.pmcontrol",
"source": "APEX",
"target": "DCAE",
+ "toscaPolicyState": "",
"final_status": "FINAL_SUCCESS",
"message": "Operation successfully completed."
-}
+} \ No newline at end of file
diff --git a/examples/examples-grpc/src/main/resources/policy/APEXgRPCPolicy.apex b/examples/examples-grpc/src/main/resources/policy/APEXgRPCPolicy.apex
index 636c74b80..34d590dcf 100644
--- a/examples/examples-grpc/src/main/resources/policy/APEXgRPCPolicy.apex
+++ b/examples/examples-grpc/src/main/resources/policy/APEXgRPCPolicy.apex
@@ -1,7 +1,7 @@
#-------------------------------------------------------------------------------
# ============LICENSE_START=======================================================
# Copyright (C) 2020 Nordix Foundation.
-# Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
+# Modifications Copyright (C) 2021-2022 Bell Canada. All rights reserved.
# ================================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -75,7 +75,8 @@ LE
album create name=PMSubscriptionAlbum scope=policy writable=true schemaName=PMSubscriptionType
-event create name=testPolicyB version=0.0.1 nameSpace=org.onap.policy.apex.onap.pmcontrol source=DCAE target=APEX
+# Incoming event
+event create name=testPolicyB version=0.0.1 nameSpace=org.onap.policy.apex.onap.pmcontrol source=DCAE target=APEX toscaPolicyState=ENTRY
event parameter create name=testPolicyB parName=nfName schemaName=SimpleStringType
event parameter create name=testPolicyB parName=policyName schemaName=SimpleStringType
event parameter create name=testPolicyB parName=changeType schemaName=SimpleStringType
@@ -109,7 +110,7 @@ event parameter create name=CDSResponseEvent parName=actionIdentifiers schemaNam
event parameter create name=CDSResponseEvent parName=status schemaName=CDSResponseStatusType
event parameter create name=CDSResponseEvent parName=payload schemaName=CDSResponsePayloadType
-event create name=CDSResponseStatusEvent nameSpace=org.onap.policy.apex.onap.pmcontrol source=APEX target=DCAE
+event create name=CDSResponseStatusEvent nameSpace=org.onap.policy.apex.onap.pmcontrol source=APEX target=DCAE toscaPolicyState=EXIT_SUCCESS
event parameter create name=CDSResponseStatusEvent parName=status schemaName=SubscriptionStatusType
event create name=LogEvent nameSpace=org.onap.policy.apex.onap.pmcontrol source=APEX target=DCAE
diff --git a/examples/examples-grpc/src/test/java/org/onap/policy/apex/examples/grpc/TestApexGrpcExample.java b/examples/examples-grpc/src/test/java/org/onap/policy/apex/examples/grpc/TestApexGrpcExample.java
index a197432ba..f5a51a7fe 100644
--- a/examples/examples-grpc/src/test/java/org/onap/policy/apex/examples/grpc/TestApexGrpcExample.java
+++ b/examples/examples-grpc/src/test/java/org/onap/policy/apex/examples/grpc/TestApexGrpcExample.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Nordix Foundation.
- * Modifications Copyright (C) 2020-2021 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2020-2022 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -91,6 +91,7 @@ public class TestApexGrpcExample {
Files.readString(Paths.get("src/main/resources/examples/events/APEXgRPC/CDSResponseStatusEvent.json"))
.replaceAll("\r", "");
// Both LogEvent and CDSResponseStatusEvent are generated from the final state in the policy
- assertThat(responseEntity).contains(expectedStatusEvent + expectedLoggedOutputEvent);
+ assertThat(responseEntity).contains(expectedStatusEvent);
+ assertThat(responseEntity).contains(expectedLoggedOutputEvent);
}
-}
+} \ No newline at end of file
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxToscaPolicyProcessingStatus.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxToscaPolicyProcessingStatus.java
new file mode 100644
index 000000000..43c7e7866
--- /dev/null
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxToscaPolicyProcessingStatus.java
@@ -0,0 +1,46 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 Bell Canada. All rights reserved.
+ * ================================================================================
+ * 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=========================================================
+ */
+
+package org.onap.policy.apex.model.basicmodel.concepts;
+
+/**
+ * This enumeration indicates the status of TOSCA policy processing on an APEX event.
+ */
+public enum AxToscaPolicyProcessingStatus {
+
+ /** Indicates the entrypoint for the processing of a TOSCA Policy. */
+ ENTRY(0),
+
+ /** Indicates a successful exit point for a TOSCA Policy. */
+ EXIT_SUCCESS(1),
+
+ /** Indicates a failure exit point for a TOSCA Policy. */
+ EXIT_FAILURE(2);
+
+ private final int statusCode;
+
+ AxToscaPolicyProcessingStatus(int statusCode) {
+ this.statusCode = statusCode;
+ }
+
+ public int getStatusCode() {
+ return statusCode;
+ }
+} \ No newline at end of file
diff --git a/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxEvent.java b/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxEvent.java
index 156b733ef..e3663e702 100644
--- a/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxEvent.java
+++ b/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxEvent.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2022 Bell Canada.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,6 +22,8 @@
package org.onap.policy.apex.model.eventmodel.concepts;
+import com.google.common.base.Strings;
+import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -40,9 +43,11 @@ import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
+import org.apache.commons.lang3.EnumUtils;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
+import org.onap.policy.apex.model.basicmodel.concepts.AxToscaPolicyProcessingStatus;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationMessage;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
@@ -50,7 +55,7 @@ import org.onap.policy.common.utils.validation.Assertions;
/**
* This class defines an Apex event. An {@link AxEvent} is used to kick off execution of policies in Apex and is emitted
- * by policies when they completer execution. In addition, Apex uses {@link AxEvent} instances internally to pass
+ * by policies when they complete execution. In addition, Apex uses {@link AxEvent} instances internally to pass
* control from one Apex state to the next during execution.
*
* <p>The {@link AxArtifactKey} of an event uniquely identifies it in an Apex system and the name field in the key is
@@ -76,7 +81,7 @@ import org.onap.policy.common.utils.validation.Assertions;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "apexEvent", namespace = "http://www.onap.org/policy/apex-pdp")
@XmlType(name = "AxEvent", namespace = "http://www.onap.org/policy/apex-pdp", propOrder =
- { "key", "nameSpace", "source", "target", "parameterMap" })
+ { "key", "nameSpace", "source", "target", "parameterMap", "toscaPolicyState"})
public class AxEvent extends AxConcept {
private static final long serialVersionUID = -1460388382582984269L;
@@ -106,6 +111,10 @@ public class AxEvent extends AxConcept {
@XmlElement(name = "parameter", required = true)
private Map<String, AxField> parameterMap;
+ @Column(name = "toscaPolicyState")
+ @XmlElement(required = false)
+ private String toscaPolicyState;
+
/**
* The default constructor creates an event with a null artifact key. The event name space, source, and target are
* all defined as empty strings and the parameter map is initialized as an empty map.
@@ -130,7 +139,7 @@ public class AxEvent extends AxConcept {
* @param key the key of the event
*/
public AxEvent(final AxArtifactKey key) {
- this(key, "", "", "", new TreeMap<>());
+ this(key, "", "", "", new TreeMap<>(), "");
}
/**
@@ -141,7 +150,7 @@ public class AxEvent extends AxConcept {
* @param nameSpace the name space of the event
*/
public AxEvent(final AxArtifactKey key, final String nameSpace) {
- this(key, nameSpace, "", "", new TreeMap<>());
+ this(key, nameSpace, "", "", new TreeMap<>(), "");
}
/**
@@ -154,7 +163,7 @@ public class AxEvent extends AxConcept {
* @param target the target of the event
*/
public AxEvent(final AxArtifactKey key, final String nameSpace, final String source, final String target) {
- this(key, nameSpace, source, target, new TreeMap<>());
+ this(key, nameSpace, source, target, new TreeMap<>(), "");
}
/**
@@ -165,9 +174,10 @@ public class AxEvent extends AxConcept {
* @param source the source of the event
* @param target the target of the event
* @param parameterMap the map of parameters that the event has
+ * @param toscaPolicyState the TOSCA policy processing status that event is flagged with
*/
public AxEvent(final AxArtifactKey key, final String nameSpace, final String source, final String target,
- final SortedMap<String, AxField> parameterMap) {
+ final SortedMap<String, AxField> parameterMap, final String toscaPolicyState) {
super();
Assertions.argumentNotNull(key, "key may not be null");
Assertions.argumentNotNull(nameSpace, "nameSpace may not be null");
@@ -180,6 +190,7 @@ public class AxEvent extends AxConcept {
this.source = source;
this.target = target;
this.parameterMap = parameterMap;
+ this.toscaPolicyState = toscaPolicyState;
}
/**
@@ -327,6 +338,24 @@ public class AxEvent extends AxConcept {
}
/**
+ * Gets the TOSCA policy processing status from the event.
+ *
+ * @return the TOSCA policy processing status
+ */
+ public String getToscaPolicyState() {
+ return toscaPolicyState;
+ }
+
+ /**
+ * Sets the TOSCA policy processing status on the event.
+ *
+ * @param toscaPolicyState the TOSCA policy processing status
+ */
+ public void setToscaPolicyState(String toscaPolicyState) {
+ this.toscaPolicyState = toscaPolicyState;
+ }
+
+ /**
* {@inheritDoc}.
*/
@Override
@@ -363,10 +392,17 @@ public class AxEvent extends AxConcept {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
"value on parameter " + eventParameterEntry.getKey() + " may not be null"));
} else {
- result = vaidateEventParameters(eventParameterEntry, result);
+ result = validateEventParameters(eventParameterEntry, result);
}
}
+ if (!Strings.isNullOrEmpty(toscaPolicyState)
+ && !EnumUtils.isValidEnum(AxToscaPolicyProcessingStatus.class, toscaPolicyState)) {
+ result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
+ "toscaPolicyState on event is not a valid enum. Valid values are: "
+ + Arrays.asList(AxToscaPolicyProcessingStatus.values())));
+ }
+
return result;
}
@@ -377,7 +413,7 @@ public class AxEvent extends AxConcept {
* @param result the validation result to append to
* @return The validation result
*/
- private AxValidationResult vaidateEventParameters(final Entry<String, AxField> eventParameterEntry,
+ private AxValidationResult validateEventParameters(final Entry<String, AxField> eventParameterEntry,
final AxValidationResult result) {
if (!eventParameterEntry.getKey().equals(eventParameterEntry.getValue().getKey().getLocalName())) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
@@ -424,6 +460,8 @@ public class AxEvent extends AxConcept {
builder.append(target);
builder.append(",parameter=");
builder.append(parameterMap);
+ builder.append(",toscaPolicyState=");
+ builder.append(toscaPolicyState);
builder.append(")");
return builder.toString();
}
@@ -450,6 +488,7 @@ public class AxEvent extends AxConcept {
copy.setNameSpace(nameSpace);
copy.setSource(source);
copy.setTarget(target);
+ copy.setToscaPolicyState(toscaPolicyState);
return copy;
}
@@ -466,6 +505,7 @@ public class AxEvent extends AxConcept {
result = prime * result + source.hashCode();
result = prime * result + target.hashCode();
result = prime * result + parameterMap.hashCode();
+ result = prime * result + toscaPolicyState.hashCode();
return result;
}
@@ -498,6 +538,9 @@ public class AxEvent extends AxConcept {
if (!target.equals(other.target)) {
return false;
}
+ if (!toscaPolicyState.equals(other.toscaPolicyState)) {
+ return false;
+ }
return parameterMap.equals(other.parameterMap);
}
@@ -532,7 +575,10 @@ public class AxEvent extends AxConcept {
if (!parameterMap.equals(other.parameterMap)) {
return (parameterMap.hashCode() - other.parameterMap.hashCode());
}
+ if (!toscaPolicyState.equals(other.toscaPolicyState)) {
+ return toscaPolicyState.compareTo(other.toscaPolicyState);
+ }
return 0;
}
-}
+} \ No newline at end of file
diff --git a/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventsTest.java b/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventsTest.java
index 21601d770..111d27f70 100644
--- a/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventsTest.java
+++ b/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventsTest.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2022 Bell Canada.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,6 +33,7 @@ import org.junit.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
+import org.onap.policy.apex.model.basicmodel.concepts.AxToscaPolicyProcessingStatus;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
@@ -51,7 +53,7 @@ public class EventsTest {
assertNotNull(new AxEvent(new AxArtifactKey(), "namespace"));
assertNotNull(new AxEvent(new AxArtifactKey(), "namespace", "source", "target"));
assertNotNull(new AxEvent(new AxArtifactKey(), "namespace", "source", "target"));
- assertNotNull(new AxEvent(new AxArtifactKey(), "namespace", "source", "target", parameterMap));
+ assertNotNull(new AxEvent(new AxArtifactKey(), "namespace", "source", "target", parameterMap, ""));
final AxEvent event = new AxEvent();
@@ -72,6 +74,9 @@ public class EventsTest {
event.setParameterMap(parameterMap);
assertEquals(0, event.getParameterMap().size());
+ event.setToscaPolicyState(AxToscaPolicyProcessingStatus.ENTRY.name());
+ assertEquals(AxToscaPolicyProcessingStatus.ENTRY.name(), event.getToscaPolicyState());
+
final AxField eventField =
new AxField(new AxReferenceKey(eventKey, "Field0"), new AxArtifactKey("Field0Schema", "0.0.1"));
event.getParameterMap().put(eventField.getKey().getLocalName(), eventField);
@@ -178,6 +183,12 @@ public class EventsTest {
result = event.validate(result);
assertEquals(ValidationResult.VALID, result.getValidationResult());
+ event.setToscaPolicyState("invalid_enum");
+ result = new AxValidationResult();
+ result = event.validate(result);
+ assertEquals(ValidationResult.INVALID, result.getValidationResult());
+ event.setToscaPolicyState(AxToscaPolicyProcessingStatus.ENTRY.name());
+
event.clean();
event.afterUnmarshal(null, null);
@@ -192,25 +203,36 @@ public class EventsTest {
assertEquals(event, clonedEvent);
assertNotNull(event);
assertNotEquals(event, (Object) "Hello");
- assertNotEquals(
- event, new AxEvent(AxArtifactKey.getNullKey(), "namespace", "source", "target", parameterMap));
- assertNotEquals(event, new AxEvent(eventKey, "namespace1", "source", "target", parameterMap));
- assertNotEquals(event, new AxEvent(eventKey, "namespace", "source2", "target", parameterMap));
- assertNotEquals(event, new AxEvent(eventKey, "namespace", "source", "target3", parameterMap));
- assertNotEquals(event, new AxEvent(eventKey, "namespace", "source", "target", parameterMapEmpty));
- assertEquals(event, new AxEvent(eventKey, "namespace", "source", "target", parameterMap));
+ assertNotEquals(event, new AxEvent(AxArtifactKey.getNullKey(), "namespace", "source", "target", parameterMap,
+ AxToscaPolicyProcessingStatus.ENTRY.name()));
+ assertNotEquals(event, new AxEvent(eventKey, "namespace1", "source", "target", parameterMap,
+ AxToscaPolicyProcessingStatus.ENTRY.name()));
+ assertNotEquals(event, new AxEvent(eventKey, "namespace", "source2", "target", parameterMap,
+ AxToscaPolicyProcessingStatus.ENTRY.name()));
+ assertNotEquals(event, new AxEvent(eventKey, "namespace", "source", "target3", parameterMap,
+ AxToscaPolicyProcessingStatus.ENTRY.name()));
+ assertNotEquals(event, new AxEvent(eventKey, "namespace", "source", "target", parameterMapEmpty,
+ AxToscaPolicyProcessingStatus.ENTRY.name()));
+ assertEquals(event, new AxEvent(eventKey, "namespace", "source", "target", parameterMap,
+ AxToscaPolicyProcessingStatus.ENTRY.name()));
assertEquals(0, event.compareTo(event));
assertEquals(0, event.compareTo(clonedEvent));
assertNotEquals(0, event.compareTo(new AxArtifactKey()));
assertNotEquals(0, event.compareTo(null));
assertNotEquals(0, event
- .compareTo(new AxEvent(AxArtifactKey.getNullKey(), "namespace", "source", "target", parameterMap)));
- assertNotEquals(0, event.compareTo(new AxEvent(eventKey, "namespace1", "source", "target", parameterMap)));
- assertNotEquals(0, event.compareTo(new AxEvent(eventKey, "namespace", "source2", "target", parameterMap)));
- assertNotEquals(0, event.compareTo(new AxEvent(eventKey, "namespace", "source", "target3", parameterMap)));
- assertNotEquals(0, event.compareTo(new AxEvent(eventKey, "namespace", "source", "target", parameterMapEmpty)));
- assertEquals(0, event.compareTo(new AxEvent(eventKey, "namespace", "source", "target", parameterMap)));
+ .compareTo(new AxEvent(AxArtifactKey.getNullKey(), "namespace", "source", "target", parameterMap,
+ AxToscaPolicyProcessingStatus.ENTRY.name())));
+ assertNotEquals(0, event.compareTo(new AxEvent(eventKey, "namespace1", "source", "target", parameterMap,
+ AxToscaPolicyProcessingStatus.ENTRY.name())));
+ assertNotEquals(0, event.compareTo(new AxEvent(eventKey, "namespace", "source2", "target", parameterMap,
+ AxToscaPolicyProcessingStatus.ENTRY.name())));
+ assertNotEquals(0, event.compareTo(new AxEvent(eventKey, "namespace", "source", "target3", parameterMap,
+ AxToscaPolicyProcessingStatus.ENTRY.name())));
+ assertNotEquals(0, event.compareTo(new AxEvent(eventKey, "namespace", "source", "target", parameterMapEmpty,
+ AxToscaPolicyProcessingStatus.ENTRY.name())));
+ assertEquals(0, event.compareTo(new AxEvent(eventKey, "namespace", "source", "target", parameterMap,
+ AxToscaPolicyProcessingStatus.ENTRY.name())));
assertNotNull(event.getKeys());
@@ -292,4 +314,4 @@ public class EventsTest {
assertEquals(1, events.getAll("EventName", "0.0.1").size());
assertEquals(0, events.getAll("NonExistantEventsName").size());
}
-}
+} \ No newline at end of file
diff --git a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexEditorApi.java b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexEditorApi.java
index fab6ba163..8974d1fa8 100644
--- a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexEditorApi.java
+++ b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexEditorApi.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2021-2022 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -205,10 +205,11 @@ public interface ApexEditorApi {
* @param target of the event, set to null to use the default value
* @param uuid event UUID, set to null to generate a UUID
* @param description event description, set to null to generate a description
+ * @param toscaPolicyState specifies TOSCA policy processing status
* @return result of the operation
*/
ApexApiResult createEvent(final String name, final String version, final String nameSpace, final String source,
- final String target, final String uuid, final String description);
+ final String target, final String uuid, final String description, final String toscaPolicyState);
/**
* Update an event.
@@ -220,10 +221,11 @@ public interface ApexEditorApi {
* @param target of the event, set to null to not update
* @param uuid event UUID, set to null to not update
* @param description event description, set to null to not update
+ * @param toscaPolicyState specifies TOSCA policy processing status
* @return result of the operation
*/
ApexApiResult updateEvent(final String name, final String version, final String nameSpace, final String source,
- final String target, final String uuid, final String description);
+ final String target, final String uuid, final String description, final String toscaPolicyState);
/**
* List events.
@@ -900,4 +902,4 @@ public interface ApexEditorApi {
*/
ApexApiResult deletePolicyStateContextRef(final String name, final String version, final String stateName,
final String contextAlbumName, final String contextAlbumVersion);
-}
+} \ No newline at end of file
diff --git a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ApexModelImpl.java b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ApexModelImpl.java
index 05976c6ed..cca9d3454 100644
--- a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ApexModelImpl.java
+++ b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ApexModelImpl.java
@@ -3,7 +3,7 @@
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019 Samsung Electronics Co., Ltd.
* Modifications Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -251,8 +251,9 @@ public final class ApexModelImpl implements ApexModel {
*/
@Override
public ApexApiResult createEvent(final String name, final String version, final String nameSpace,
- final String source, final String target, final String uuid, final String description) {
- return eventFacade.createEvent(name, version, nameSpace, source, target, uuid, description);
+ final String source, final String target, final String uuid, final String description,
+ final String toscaPolicyState) {
+ return eventFacade.createEvent(name, version, nameSpace, source, target, uuid, description, toscaPolicyState);
}
/**
@@ -260,8 +261,9 @@ public final class ApexModelImpl implements ApexModel {
*/
@Override
public ApexApiResult updateEvent(final String name, final String version, final String nameSpace,
- final String source, final String target, final String uuid, final String description) {
- return eventFacade.updateEvent(name, version, nameSpace, source, target, uuid, description);
+ final String source, final String target, final String uuid, final String description,
+ final String toscaPolicyState) {
+ return eventFacade.updateEvent(name, version, nameSpace, source, target, uuid, description, toscaPolicyState);
}
/**
@@ -892,4 +894,4 @@ public final class ApexModelImpl implements ApexModel {
return policyModel;
}
-}
+} \ No newline at end of file
diff --git a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/EventFacade.java b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/EventFacade.java
index 0a758407b..f1f939397 100644
--- a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/EventFacade.java
+++ b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/EventFacade.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2022 Bell Canada.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -85,10 +86,12 @@ public class EventFacade {
* @param target of the event, set to null to use the default value
* @param uuid event UUID, set to null to generate a UUID
* @param description event description, set to null to generate a description
+ * @param toscaPolicyState specifies TOSCA policy processing status
* @return result of the operation
*/
public ApexApiResult createEvent(final String name, final String version, final String nameSpace,
- final String source, final String target, final String uuid, final String description) {
+ final String source, final String target, final String uuid, final String description,
+ final String toscaPolicyState) {
try {
final AxArtifactKey key = new AxArtifactKey();
key.setName(name);
@@ -107,6 +110,9 @@ public class EventFacade {
event.setNameSpace((nameSpace != null ? nameSpace : apexProperties.getProperty("DEFAULT_EVENT_NAMESPACE")));
event.setSource((source != null ? source : apexProperties.getProperty("DEFAULT_EVENT_SOURCE")));
event.setTarget((target != null ? target : apexProperties.getProperty("DEFAULT_EVENT_TARGET")));
+ if (toscaPolicyState != null) {
+ event.setToscaPolicyState(toscaPolicyState);
+ }
apexModel.getPolicyModel().getEvents().getEventMap().put(key, event);
@@ -130,10 +136,12 @@ public class EventFacade {
* @param target of the event, set to null to not update
* @param uuid event UUID, set to null to not update
* @param description event description, set to null to not update
+ * @param toscaPolicyState specifies TOSCA policy processing status
* @return result of the operation
*/
public ApexApiResult updateEvent(final String name, final String version, final String nameSpace,
- final String source, final String target, final String uuid, final String description) {
+ final String source, final String target, final String uuid, final String description,
+ final String toscaPolicyState) {
try {
final AxEvent event = apexModel.getPolicyModel().getEvents().get(name, version);
if (event == null) {
@@ -150,6 +158,9 @@ public class EventFacade {
if (target != null) {
event.setTarget(target);
}
+ if (toscaPolicyState != null) {
+ event.setToscaPolicyState(toscaPolicyState);
+ }
return keyInformationFacade.updateKeyInformation(name, version, uuid, description);
} catch (final Exception e) {
@@ -382,4 +393,4 @@ public class EventFacade {
return new ApexApiResult(ApexApiResult.Result.FAILED, e);
}
}
-}
+} \ No newline at end of file
diff --git a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiEventTest.java b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiEventTest.java
index bc46ee3d3..775fcc1d3 100644
--- a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiEventTest.java
+++ b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiEventTest.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,29 +45,29 @@ public class ApexEditorApiEventTest {
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createEvent("MyEvent002", "0.0.2", "My Namespace", "My Source", "my target",
- "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002");
+ "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002", null);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createEvent("MyEvent012", "0.1.2", "My Namespace", "My Source", "my target",
- "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 012");
+ "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 012", null);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createEvent("MyEvent012", "0.1.4", "My Namespace", "My Source", "my target",
- "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 014");
+ "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 014", null);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.createEvent("MyEvent012", null, null, null, null, null, null);
+ result = apexModel.createEvent("MyEvent012", null, null, null, null, null, null, null);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.createEvent("MyEvent012", null, null, null, null, null, null);
+ result = apexModel.createEvent("MyEvent012", null, null, null, null, null, null, null);
assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult());
result = apexModel.createEvent("MyEvent002", "0.0.2", "My Namespace", "My Source", "my target",
- "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002");
+ "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002", null);
assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult());
result = apexModel.createEvent("@£$%^", "0.2.5", "My Namespace", "My Source", "my target",
- "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002");
+ "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002", null);
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
result = apexModel.deleteEvent("MyEvent012", "0.1.4");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createEvent("MyEvent012", "0.1.4", "My Namespace", "My Source", "my target",
- "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 014");
+ "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 014", null);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.validateEvent(null, null);
@@ -74,18 +75,19 @@ public class ApexEditorApiEventTest {
result = apexModel.updateContextSchema(null, null, null, null, null, null);
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
- result = apexModel.updateEvent("MyEvent012", "0.1.2", "Another Namespace", null, "Another target", null, null);
+ result = apexModel.updateEvent("MyEvent012", "0.1.2", "Another Namespace", null, "Another target", null, null,
+ null);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.updateEvent("MyEvent002", "0.0.2", "My Namespace", "My Source", "my target",
- "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002");
+ "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002", null);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.updateEvent("MyEvent012", null, null, null, null, null, null);
+ result = apexModel.updateEvent("MyEvent012", null, null, null, null, null, null, null);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.updateEvent("MyEvent015", null, null, null, null, null, null);
+ result = apexModel.updateEvent("MyEvent015", null, null, null, null, null, null, null);
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
- result = apexModel.updateEvent("MyEvent014", "0.1.5", null, null, null, null, null);
+ result = apexModel.updateEvent("MyEvent014", "0.1.5", null, null, null, null, null, null);
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
- result = apexModel.updateEvent("@£$%^^", "0.6.9", null, null, null, null, null);
+ result = apexModel.updateEvent("@£$%^^", "0.6.9", null, null, null, null, null, null);
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
result = apexModel.listEvent("@£$%", null);
@@ -194,4 +196,4 @@ public class ApexEditorApiEventTest {
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
assertEquals(0, result.getMessages().size());
}
-}
+} \ No newline at end of file
diff --git a/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentVerboseValues.txt b/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentVerboseValues.txt
index 2138e97f0..77d17f679 100644
--- a/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentVerboseValues.txt
+++ b/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentVerboseValues.txt
@@ -16,9 +16,9 @@ left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtif
*** all right keys in left
*** all values in left and right are identical
*** list of identical entries in left and right
-key=AxArtifactKey:(name=inEvent,version=0.0.1),value=AxEvent:(key=AxArtifactKey:(name=inEvent,version=0.0.1),nameSpace=org.onap.policy.apex.model.policymodel.events,source=Source,target=Target,parameter={IEPAR0=AxField:(key=AxReferenceKey:(parentKeyName=inEvent,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=IEPAR0),fieldSchemaKey=AxArtifactKey:(name=eventContextItem0,version=0.0.1),optional=false), IEPAR1=AxField:(key=AxReferenceKey:(parentKeyName=inEvent,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=IEPAR1),fieldSchemaKey=AxArtifactKey:(name=eventContextItem1,version=0.0.1),optional=false)})
-key=AxArtifactKey:(name=outEvent0,version=0.0.1),value=AxEvent:(key=AxArtifactKey:(name=outEvent0,version=0.0.1),nameSpace=org.onap.policy.apex.model.policymodel.events,source=Source,target=Target,parameter={OE0PAR0=AxField:(key=AxReferenceKey:(parentKeyName=outEvent0,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=OE0PAR0),fieldSchemaKey=AxArtifactKey:(name=eventContextItem0,version=0.0.1),optional=false), OE0PAR1=AxField:(key=AxReferenceKey:(parentKeyName=outEvent0,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=OE0PAR1),fieldSchemaKey=AxArtifactKey:(name=eventContextItem1,version=0.0.1),optional=false), OE1PAR0=AxField:(key=AxReferenceKey:(parentKeyName=outEvent0,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=OE1PAR0),fieldSchemaKey=AxArtifactKey:(name=eventContextItem0,version=0.0.1),optional=false), OE1PAR1=AxField:(key=AxReferenceKey:(parentKeyName=outEvent0,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=OE1PAR1),fieldSchemaKey=AxArtifactKey:(name=eventContextItem1,version=0.0.1),optional=false)})
-key=AxArtifactKey:(name=outEvent1,version=0.0.1),value=AxEvent:(key=AxArtifactKey:(name=outEvent1,version=0.0.1),nameSpace=org.onap.policy.apex.model.policymodel.events,source=Source,target=Target,parameter={OE1PAR0=AxField:(key=AxReferenceKey:(parentKeyName=outEvent1,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=OE1PAR0),fieldSchemaKey=AxArtifactKey:(name=eventContextItem0,version=0.0.1),optional=false), OE1PAR1=AxField:(key=AxReferenceKey:(parentKeyName=outEvent1,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=OE1PAR1),fieldSchemaKey=AxArtifactKey:(name=eventContextItem1,version=0.0.1),optional=false)})
+key=AxArtifactKey:(name=inEvent,version=0.0.1),value=AxEvent:(key=AxArtifactKey:(name=inEvent,version=0.0.1),nameSpace=org.onap.policy.apex.model.policymodel.events,source=Source,target=Target,parameter={IEPAR0=AxField:(key=AxReferenceKey:(parentKeyName=inEvent,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=IEPAR0),fieldSchemaKey=AxArtifactKey:(name=eventContextItem0,version=0.0.1),optional=false), IEPAR1=AxField:(key=AxReferenceKey:(parentKeyName=inEvent,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=IEPAR1),fieldSchemaKey=AxArtifactKey:(name=eventContextItem1,version=0.0.1),optional=false)},toscaPolicyState=)
+key=AxArtifactKey:(name=outEvent0,version=0.0.1),value=AxEvent:(key=AxArtifactKey:(name=outEvent0,version=0.0.1),nameSpace=org.onap.policy.apex.model.policymodel.events,source=Source,target=Target,parameter={OE0PAR0=AxField:(key=AxReferenceKey:(parentKeyName=outEvent0,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=OE0PAR0),fieldSchemaKey=AxArtifactKey:(name=eventContextItem0,version=0.0.1),optional=false), OE0PAR1=AxField:(key=AxReferenceKey:(parentKeyName=outEvent0,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=OE0PAR1),fieldSchemaKey=AxArtifactKey:(name=eventContextItem1,version=0.0.1),optional=false), OE1PAR0=AxField:(key=AxReferenceKey:(parentKeyName=outEvent0,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=OE1PAR0),fieldSchemaKey=AxArtifactKey:(name=eventContextItem0,version=0.0.1),optional=false), OE1PAR1=AxField:(key=AxReferenceKey:(parentKeyName=outEvent0,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=OE1PAR1),fieldSchemaKey=AxArtifactKey:(name=eventContextItem1,version=0.0.1),optional=false)},toscaPolicyState=)
+key=AxArtifactKey:(name=outEvent1,version=0.0.1),value=AxEvent:(key=AxArtifactKey:(name=outEvent1,version=0.0.1),nameSpace=org.onap.policy.apex.model.policymodel.events,source=Source,target=Target,parameter={OE1PAR0=AxField:(key=AxReferenceKey:(parentKeyName=outEvent1,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=OE1PAR0),fieldSchemaKey=AxArtifactKey:(name=eventContextItem0,version=0.0.1),optional=false), OE1PAR1=AxField:(key=AxReferenceKey:(parentKeyName=outEvent1,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=OE1PAR1),fieldSchemaKey=AxArtifactKey:(name=eventContextItem1,version=0.0.1),optional=false)},toscaPolicyState=)
*** context album differences ***
left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtifactKey:(name=PolicyModel,version=0.0.1)
*** all left keys in right
@@ -67,4 +67,4 @@ key=AxArtifactKey:(name=policies,version=0.0.1),value=AxKeyInfo:(artifactId=AxAr
key=AxArtifactKey:(name=policy,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=policy,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e015,description=Generated description for concept referred to by key "policy:0.0.1")
key=AxArtifactKey:(name=task,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=task,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e016,description=Generated description for concept referred to by key "task:0.0.1")
key=AxArtifactKey:(name=tasks,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=tasks,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e017,description=Generated description for concept referred to by key "tasks:0.0.1")
-***********************************
+*********************************** \ No newline at end of file
diff --git a/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonIdenticalVerboseValues.txt b/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonIdenticalVerboseValues.txt
index 0faab1cdb..4e07c5360 100644
--- a/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonIdenticalVerboseValues.txt
+++ b/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonIdenticalVerboseValues.txt
@@ -16,9 +16,9 @@ left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtif
*** all right keys in left
*** all values in left and right are identical
*** list of identical entries in left and right
-key=AxArtifactKey:(name=inEvent,version=0.0.1),value=AxEvent:(key=AxArtifactKey:(name=inEvent,version=0.0.1),nameSpace=org.onap.policy.apex.model.policymodel.events,source=Source,target=Target,parameter={IEPAR0=AxField:(key=AxReferenceKey:(parentKeyName=inEvent,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=IEPAR0),fieldSchemaKey=AxArtifactKey:(name=eventContextItem0,version=0.0.1),optional=false), IEPAR1=AxField:(key=AxReferenceKey:(parentKeyName=inEvent,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=IEPAR1),fieldSchemaKey=AxArtifactKey:(name=eventContextItem1,version=0.0.1),optional=false)})
-key=AxArtifactKey:(name=outEvent0,version=0.0.1),value=AxEvent:(key=AxArtifactKey:(name=outEvent0,version=0.0.1),nameSpace=org.onap.policy.apex.model.policymodel.events,source=Source,target=Target,parameter={OE0PAR0=AxField:(key=AxReferenceKey:(parentKeyName=outEvent0,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=OE0PAR0),fieldSchemaKey=AxArtifactKey:(name=eventContextItem0,version=0.0.1),optional=false), OE0PAR1=AxField:(key=AxReferenceKey:(parentKeyName=outEvent0,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=OE0PAR1),fieldSchemaKey=AxArtifactKey:(name=eventContextItem1,version=0.0.1),optional=false), OE1PAR0=AxField:(key=AxReferenceKey:(parentKeyName=outEvent0,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=OE1PAR0),fieldSchemaKey=AxArtifactKey:(name=eventContextItem0,version=0.0.1),optional=false), OE1PAR1=AxField:(key=AxReferenceKey:(parentKeyName=outEvent0,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=OE1PAR1),fieldSchemaKey=AxArtifactKey:(name=eventContextItem1,version=0.0.1),optional=false)})
-key=AxArtifactKey:(name=outEvent1,version=0.0.1),value=AxEvent:(key=AxArtifactKey:(name=outEvent1,version=0.0.1),nameSpace=org.onap.policy.apex.model.policymodel.events,source=Source,target=Target,parameter={OE1PAR0=AxField:(key=AxReferenceKey:(parentKeyName=outEvent1,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=OE1PAR0),fieldSchemaKey=AxArtifactKey:(name=eventContextItem0,version=0.0.1),optional=false), OE1PAR1=AxField:(key=AxReferenceKey:(parentKeyName=outEvent1,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=OE1PAR1),fieldSchemaKey=AxArtifactKey:(name=eventContextItem1,version=0.0.1),optional=false)})
+key=AxArtifactKey:(name=inEvent,version=0.0.1),value=AxEvent:(key=AxArtifactKey:(name=inEvent,version=0.0.1),nameSpace=org.onap.policy.apex.model.policymodel.events,source=Source,target=Target,parameter={IEPAR0=AxField:(key=AxReferenceKey:(parentKeyName=inEvent,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=IEPAR0),fieldSchemaKey=AxArtifactKey:(name=eventContextItem0,version=0.0.1),optional=false), IEPAR1=AxField:(key=AxReferenceKey:(parentKeyName=inEvent,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=IEPAR1),fieldSchemaKey=AxArtifactKey:(name=eventContextItem1,version=0.0.1),optional=false)},toscaPolicyState=)
+key=AxArtifactKey:(name=outEvent0,version=0.0.1),value=AxEvent:(key=AxArtifactKey:(name=outEvent0,version=0.0.1),nameSpace=org.onap.policy.apex.model.policymodel.events,source=Source,target=Target,parameter={OE0PAR0=AxField:(key=AxReferenceKey:(parentKeyName=outEvent0,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=OE0PAR0),fieldSchemaKey=AxArtifactKey:(name=eventContextItem0,version=0.0.1),optional=false), OE0PAR1=AxField:(key=AxReferenceKey:(parentKeyName=outEvent0,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=OE0PAR1),fieldSchemaKey=AxArtifactKey:(name=eventContextItem1,version=0.0.1),optional=false), OE1PAR0=AxField:(key=AxReferenceKey:(parentKeyName=outEvent0,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=OE1PAR0),fieldSchemaKey=AxArtifactKey:(name=eventContextItem0,version=0.0.1),optional=false), OE1PAR1=AxField:(key=AxReferenceKey:(parentKeyName=outEvent0,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=OE1PAR1),fieldSchemaKey=AxArtifactKey:(name=eventContextItem1,version=0.0.1),optional=false)},toscaPolicyState=)
+key=AxArtifactKey:(name=outEvent1,version=0.0.1),value=AxEvent:(key=AxArtifactKey:(name=outEvent1,version=0.0.1),nameSpace=org.onap.policy.apex.model.policymodel.events,source=Source,target=Target,parameter={OE1PAR0=AxField:(key=AxReferenceKey:(parentKeyName=outEvent1,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=OE1PAR0),fieldSchemaKey=AxArtifactKey:(name=eventContextItem0,version=0.0.1),optional=false), OE1PAR1=AxField:(key=AxReferenceKey:(parentKeyName=outEvent1,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=OE1PAR1),fieldSchemaKey=AxArtifactKey:(name=eventContextItem1,version=0.0.1),optional=false)},toscaPolicyState=)
*** context album differences ***
left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtifactKey:(name=PolicyModel,version=0.0.1)
*** all left keys in right
@@ -65,4 +65,4 @@ key=AxArtifactKey:(name=policies,version=0.0.1),value=AxKeyInfo:(artifactId=AxAr
key=AxArtifactKey:(name=policy,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=policy,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e015,description=Generated description for concept referred to by key "policy:0.0.1")
key=AxArtifactKey:(name=task,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=task,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e016,description=Generated description for concept referred to by key "task:0.0.1")
key=AxArtifactKey:(name=tasks,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=tasks,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e017,description=Generated description for concept referred to by key "tasks:0.0.1")
-***********************************
+*********************************** \ No newline at end of file
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/test/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsProducerTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/test/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsProducerTest.java
index 708f29f4f..2f781689f 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/test/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsProducerTest.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/test/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsProducerTest.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Samsung. All rights reserved.
* Modifications Copyright (C) 2019-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -328,7 +329,7 @@ public class ApexJmsProducerTest {
// Prepare sendEvent
ApexEvent apexEvent = new ApexEvent("testEvent", "testVersion", "testNameSpace",
- "testSource", "testTarget");
+ "testSource", "testTarget", "");
Mockito.doThrow(JMSException.class).when(session).createObjectMessage(apexEvent);
final long executionId = random.nextLong();
@@ -367,7 +368,7 @@ public class ApexJmsProducerTest {
// Prepare sendEvent
final Message message = Mockito.mock(ObjectMessage.class);
ApexEvent apexEvent = new ApexEvent("testEvent", "testVersion", "testNameSpace",
- "testSource", "testTarget");
+ "testSource", "testTarget", "");
Mockito.doReturn(message).when(session).createObjectMessage(apexEvent);
Mockito.doThrow(JMSException.class).when(messageProducer).send(message);
@@ -410,7 +411,7 @@ public class ApexJmsProducerTest {
// Prepare sendEvent
final Message message = Mockito.mock(ObjectMessage.class);
ApexEvent apexEvent = new ApexEvent("testEvent", "testVersion", "testNameSpace",
- "testSource", "testTarget");
+ "testSource", "testTarget", "");
Mockito.doReturn(message).when(session).createObjectMessage(apexEvent);
Mockito.doNothing().when(messageProducer).send(message);
@@ -452,7 +453,7 @@ public class ApexJmsProducerTest {
// Prepare sendEvent
ApexEvent apexEvent = new ApexEvent("testEvent", "testVersion", "testNameSpace",
- "testSource", "testTarget");
+ "testSource", "testTarget", "");
Mockito.doThrow(JMSException.class).when(session).createTextMessage(apexEvent.toString());
@@ -495,7 +496,7 @@ public class ApexJmsProducerTest {
// Prepare sendEvent
final Message message = Mockito.mock(TextMessage.class);
ApexEvent apexEvent = new ApexEvent("testEvent", "testVersion", "testNameSpace",
- "testSource", "testTarget");
+ "testSource", "testTarget", "");
Mockito.doReturn(message).when(session).createTextMessage(apexEvent.toString());
Mockito.doThrow(JMSException.class).when(messageProducer).send(message);
@@ -539,7 +540,7 @@ public class ApexJmsProducerTest {
// Prepare sendEvent
final Message message = Mockito.mock(TextMessage.class);
ApexEvent apexEvent = new ApexEvent("testEvent", "testVersion", "testNameSpace",
- "testSource", "testTarget");
+ "testSource", "testTarget", "");
Mockito.doReturn(message).when(session).createTextMessage(apexEvent.toString());
Mockito.doNothing().when(messageProducer).send(message);
@@ -707,4 +708,4 @@ public class ApexJmsProducerTest {
// do the test
assertThatCode(apexJmsProducer::stop).doesNotThrowAnyException();
}
-}
+} \ No newline at end of file
diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JmsObjectEventConverter.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JmsObjectEventConverter.java
index cd14f4a3b..8d9416fb1 100644
--- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JmsObjectEventConverter.java
+++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JmsObjectEventConverter.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2021 Nordix Foundation.
- * Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2021-2022 Bell Canada. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -100,12 +100,13 @@ public final class Apex2JmsObjectEventConverter implements ApexEventProtocolConv
// Create the Apex event
// @formatter:off
+ // FIXME: Introduce new AxEvent field for APEX to Jms object conversion
final var apexEvent = new ApexEvent(
jmsIncomingObject.getClass().getSimpleName() + eventProtocolParameters.getIncomingEventSuffix(),
eventProtocolParameters.getIncomingEventVersion(),
jmsIncomingObject.toString().getClass().getPackage().getName(),
eventProtocolParameters.getIncomingEventSource(),
- eventProtocolParameters.getIncomingEventTarget());
+ eventProtocolParameters.getIncomingEventTarget(), "");
// @formatter:on
// Set the data on the apex event as the incoming object
@@ -137,4 +138,4 @@ public final class Apex2JmsObjectEventConverter implements ApexEventProtocolConv
// Return the single object from the Apex event message
return apexEvent.values().iterator().next();
}
-}
+} \ No newline at end of file
diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/main/java/org/onap/policy/apex/plugins/event/protocol/xml/Apex2XmlEventConverter.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/main/java/org/onap/policy/apex/plugins/event/protocol/xml/Apex2XmlEventConverter.java
index f601c4b6f..907d426e7 100644
--- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/main/java/org/onap/policy/apex/plugins/event/protocol/xml/Apex2XmlEventConverter.java
+++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/main/java/org/onap/policy/apex/plugins/event/protocol/xml/Apex2XmlEventConverter.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2021-2022 Bell Canada. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -128,8 +128,9 @@ public final class Apex2XmlEventConverter implements ApexEventProtocolConverter
}
// Create the Apex event
+ // FIXME: Introduce new AxEvent field for APEX to Xml conversion
final var apexEvent = new ApexEvent(xmlApexEvent.getName(), xmlApexEvent.getVersion(),
- xmlApexEvent.getNameSpace(), xmlApexEvent.getSource(), xmlApexEvent.getTarget());
+ xmlApexEvent.getNameSpace(), xmlApexEvent.getSource(), xmlApexEvent.getTarget(), "");
// Set the data on the apex event
for (final XMLApexEventData xmlData : xmlApexEvent.getData()) {
@@ -184,4 +185,4 @@ public final class Apex2XmlEventConverter implements ApexEventProtocolConverter
throw new ApexEventException("Unable to unmarshal Apex event to XML\n" + apexEvent, e);
}
}
-}
+} \ No newline at end of file
diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/XmlEventHandlerTest.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/XmlEventHandlerTest.java
index 609b0471b..f8caf8c2f 100644
--- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/XmlEventHandlerTest.java
+++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/XmlEventHandlerTest.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2022 Bell Canada.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -152,7 +153,7 @@ public class XmlEventHandlerTest {
event0000DataMap.put("NullValue", null);
final ApexEvent apexEvent0000 =
- new ApexEvent("Event0000", "0.0.1", "org.onap.policy.apex.sample.events", "test", "apex");
+ new ApexEvent("Event0000", "0.0.1", "org.onap.policy.apex.sample.events", "test", "apex", "");
apexEvent0000.putAll(event0000DataMap);
final String apexEvent0000XmlString = xmlEventConverter.fromApexEvent(apexEvent0000);
@@ -182,8 +183,8 @@ public class XmlEventHandlerTest {
event0004DataMap.put("TestActCaseSelected", Integer.valueOf(2));
event0004DataMap.put("TestActStateTime", Long.valueOf(1434370506095L));
- final ApexEvent apexEvent0004 =
- new ApexEvent("Event0004", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex");
+ final ApexEvent apexEvent0004 = new ApexEvent("Event0004", "0.0.1",
+ "org.onap.policy.apex.domains.sample.events", "test", "apex", "");
apexEvent0004.putAll(event0004DataMap);
final String apexEvent0004XmlString = xmlEventConverter.fromApexEvent(apexEvent0004);
@@ -201,4 +202,4 @@ public class XmlEventHandlerTest {
throw new ApexException("Exception reading Apex event xml file", e);
}
}
-}
+} \ No newline at end of file
diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java/org/onap/policy/apex/plugins/event/protocol/yaml/Apex2YamlEventConverter.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java/org/onap/policy/apex/plugins/event/protocol/yaml/Apex2YamlEventConverter.java
index 9359e4ef9..731d3519a 100644
--- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java/org/onap/policy/apex/plugins/event/protocol/yaml/Apex2YamlEventConverter.java
+++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java/org/onap/policy/apex/plugins/event/protocol/yaml/Apex2YamlEventConverter.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2021 Nordix Foundation.
- * Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2021-2022 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -257,7 +257,9 @@ public class Apex2YamlEventConverter implements ApexEventProtocolConverter {
String target = getHeaderTarget(yamlMap, eventDefinition);
- return new ApexEvent(name, version, namespace, source, target);
+ String toscaPolicyState = getHeaderToscaPolicyState(yamlMap, eventDefinition);
+
+ return new ApexEvent(name, version, namespace, source, target, toscaPolicyState);
}
/**
@@ -318,6 +320,23 @@ public class Apex2YamlEventConverter implements ApexEventProtocolConverter {
}
/**
+ * Get the event header toscaPolicyState field.
+ *
+ * @param yamlMap the YAML map to read from
+ * @param eventDefinition the event definition
+ * @return the event header toscaPolicyState field
+ */
+ private String getHeaderToscaPolicyState(final Map<?, ?> yamlMap, final AxEvent eventDefinition) {
+ // For toscaPolicyState, use the defined value only if not found on the incoming event
+ var toscaPolicyState = getYamlStringField(yamlMap, ApexEvent.TOSCA_POLICY_STATE_HEADER_FIELD,
+ yamlPars.getToscaPolicyStateAlias(), null, false);
+ if (toscaPolicyState == null) {
+ toscaPolicyState = eventDefinition.getTarget();
+ }
+ return toscaPolicyState;
+ }
+
+ /**
* This method gets an event string field from a JSON object.
*
* @param yamlMap the YAML containing the YAML representation of the incoming event
@@ -391,4 +410,4 @@ public class Apex2YamlEventConverter implements ApexEventProtocolConverter {
return eventElement;
}
-}
+} \ No newline at end of file
diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java/org/onap/policy/apex/plugins/event/protocol/yaml/YamlEventProtocolParameters.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java/org/onap/policy/apex/plugins/event/protocol/yaml/YamlEventProtocolParameters.java
index e5539cd04..120104460 100644
--- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java/org/onap/policy/apex/plugins/event/protocol/yaml/YamlEventProtocolParameters.java
+++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java/org/onap/policy/apex/plugins/event/protocol/yaml/YamlEventProtocolParameters.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -61,12 +62,13 @@ public class YamlEventProtocolParameters extends EventProtocolTextTokenDelimited
// Aliases for Apex event header fields
// @formatter:off
- private String nameAlias = null;
- private String versionAlias = null;
- private String nameSpaceAlias = null;
- private String sourceAlias = null;
- private String targetAlias = null;
- private String yamlFieldName = DEFAULT_YAML_FIELD_NAME;
+ private String nameAlias = null;
+ private String versionAlias = null;
+ private String nameSpaceAlias = null;
+ private String sourceAlias = null;
+ private String targetAlias = null;
+ private String toscaPolicyStateAlias = null;
+ private String yamlFieldName = DEFAULT_YAML_FIELD_NAME;
// @formatter:on
/**
@@ -96,4 +98,4 @@ public class YamlEventProtocolParameters extends EventProtocolTextTokenDelimited
// Set the event protocol plugin class
this.setEventProtocolPluginClass(Apex2YamlEventConverter.class.getName());
}
-}
+} \ No newline at end of file
diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/YamlPluginStabilityTest.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/YamlPluginStabilityTest.java
index ab911499a..0d3d62382 100644
--- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/YamlPluginStabilityTest.java
+++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/YamlPluginStabilityTest.java
@@ -3,6 +3,7 @@
* Copyright (C) 2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 Nordix Foundation
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,6 +36,7 @@ import org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters;
import org.onap.policy.apex.context.parameters.SchemaParameters;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
+import org.onap.policy.apex.model.basicmodel.concepts.AxToscaPolicyProcessingStatus;
import org.onap.policy.apex.model.basicmodel.service.ModelService;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
@@ -80,6 +82,7 @@ public class YamlPluginStabilityTest {
testEvent = new AxEvent(new AxArtifactKey("TestEvent", "0.0.1"));
testEvent.setNameSpace("org.onap.policy.apex.plugins.event.protocol.yaml");
+ testEvent.setToscaPolicyState(AxToscaPolicyProcessingStatus.ENTRY.name());
AxField teField0 = new AxField(new AxReferenceKey(testEvent.getKey(), "intValue"), simpleIntSchema.getKey());
testEvent.getParameterMap().put("intValue", teField0);
AxField teField1 = new AxField(new AxReferenceKey(testEvent.getKey(), "doubleValue"),
@@ -130,7 +133,8 @@ public class YamlPluginStabilityTest {
assertThatThrownBy(() -> converter.fromApexEvent(null))
.hasMessage("event processing failed, Apex event is null");
ApexEvent apexEvent = new ApexEvent(testEvent.getKey().getName(), testEvent.getKey().getVersion(),
- testEvent.getNameSpace(), testEvent.getSource(), testEvent.getTarget());
+ testEvent.getNameSpace(), testEvent.getSource(), testEvent.getTarget(),
+ testEvent.getToscaPolicyState());
apexEvent.put("doubleValue", 123.45);
apexEvent.put("intValue", 123);
apexEvent.put("stringValue", "123.45");
@@ -216,4 +220,4 @@ public class YamlPluginStabilityTest {
assertThatThrownBy(() -> converter.toApexEvent("TestEvent", "doubleValue: 123.45\n" + "intValue: ~\n"
+ "stringValue: MyString")).getCause().hasMessageStartingWith("mandatory field \"intValue\" is missing");
}
-}
+} \ No newline at end of file
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexEvent.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexEvent.java
index 76a1c03a2..a8f13bbf6 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexEvent.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexEvent.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +22,9 @@
package org.onap.policy.apex.service.engine.event;
+import com.google.common.base.Strings;
import java.io.Serializable;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
@@ -30,7 +33,9 @@ import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
+import org.apache.commons.lang3.EnumUtils;
import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
+import org.onap.policy.apex.model.basicmodel.concepts.AxToscaPolicyProcessingStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -92,6 +97,14 @@ public class ApexEvent extends HashMap<String, Object> implements Serializable {
public static final String TARGET_HEADER_FIELD = "target";
/**
+ * The toscaPolicyState of Apex event, an optional field. It specifies the TOSCA Policy processing status
+ * on an Apex event, with possible values as enumerated in
+ * {@link org.onap.policy.apex.model.basicmodel.concepts.AxToscaPolicyProcessingStatus}.
+ * If no toscaPolicyState is specified, it indicates that the TOSCA Policy is under process.
+ */
+ public static final String TOSCA_POLICY_STATE_HEADER_FIELD = "toscaPolicyState";
+
+ /**
* The exception message field of an Apex event is an exception message indicating that an event
* failed.
*/
@@ -118,6 +131,7 @@ public class ApexEvent extends HashMap<String, Object> implements Serializable {
private final String nameSpace;
private final String source;
private final String target;
+ private final String toscaPolicyState;
// An identifier for the current event execution. The default value here will always be unique
// in a single JVM
@@ -143,14 +157,13 @@ public class ApexEvent extends HashMap<String, Object> implements Serializable {
* @throws ApexEventException thrown on validation errors on event names and versions
*/
public ApexEvent(final String name, final String version, final String nameSpace, final String source,
- final String target) throws ApexEventException {
- // @formatter:off
- this.name = validateField(NAME_HEADER_FIELD, name, NAME_REGEXP);
- this.version = validateField(VERSION_HEADER_FIELD, version, VERSION_REGEXP);
+ final String target, final String toscaPolicyState) throws ApexEventException {
+ this.name = validateField(NAME_HEADER_FIELD, name, NAME_REGEXP);
+ this.version = validateField(VERSION_HEADER_FIELD, version, VERSION_REGEXP);
this.nameSpace = validateField(NAMESPACE_HEADER_FIELD, nameSpace, NAMESPACE_REGEXP);
- this.source = validateField(SOURCE_HEADER_FIELD, source, SOURCE_REGEXP);
- this.target = validateField(TARGET_HEADER_FIELD, target, TARGET_REGEXP);
- // @formatter:on
+ this.source = validateField(SOURCE_HEADER_FIELD, source, SOURCE_REGEXP);
+ this.target = validateField(TARGET_HEADER_FIELD, target, TARGET_REGEXP);
+ this.toscaPolicyState = validateField(TOSCA_POLICY_STATE_HEADER_FIELD, toscaPolicyState, "");
}
/**
@@ -174,6 +187,17 @@ public class ApexEvent extends HashMap<String, Object> implements Serializable {
*/
private String validateField(final String fieldName, final String fieldValue, final String fieldRegexp)
throws ApexEventException {
+ if (fieldName.equals(TOSCA_POLICY_STATE_HEADER_FIELD) && !Strings.isNullOrEmpty(fieldValue)) {
+ if (EnumUtils.isValidEnum(AxToscaPolicyProcessingStatus.class, fieldValue)) {
+ return fieldValue;
+ } else {
+ String message = EVENT_PREAMBLE + name + ": field \"" + fieldName + "=" + fieldValue
+ + "\" is illegal. It doesn't match supported values '"
+ + Arrays.asList(AxToscaPolicyProcessingStatus.values()) + "'";
+ LOGGER.warn(message);
+ throw new ApexEventException(message);
+ }
+ }
if (fieldValue.matches(fieldRegexp)) {
return fieldValue;
} else {
@@ -243,4 +267,4 @@ public class ApexEvent extends HashMap<String, Object> implements Serializable {
// Go ahead and put everything
super.putAll(incomingMap);
}
-}
+} \ No newline at end of file
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexPeriodicEventGenerator.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexPeriodicEventGenerator.java
index 1300f2176..ea3cb4b29 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexPeriodicEventGenerator.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexPeriodicEventGenerator.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2021 Nordix Foundation.
+ * Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -53,6 +54,9 @@ public class ApexPeriodicEventGenerator extends TimerTask {
/** The target of the periodic event. */
public static final String PERIODIC_EVENT_TARGET = PERIODIC_EVENT_SOURCE;
+ /** The status of the periodic event. */
+ public static final String PERIODIC_EVENT_STATUS = "";
+
/**
* The field name in the periodic event for the delay between occurrences of the periodic event.
*/
@@ -137,7 +141,7 @@ public class ApexPeriodicEventGenerator extends TimerTask {
// Send the periodic event
try {
final var periodicEvent = new ApexEvent(PERIODIC_EVENT_NAME, PERIODIC_EVENT_VERSION,
- PERIODIC_EVENT_NAMESPACE, PERIODIC_EVENT_SOURCE, PERIODIC_EVENT_TARGET);
+ PERIODIC_EVENT_NAMESPACE, PERIODIC_EVENT_SOURCE, PERIODIC_EVENT_TARGET, PERIODIC_EVENT_STATUS);
periodicEvent.putAll(periodicEventMap);
engineServiceEventInterface.sendEvent(periodicEvent);
} catch (final ApexEventException e) {
@@ -171,4 +175,4 @@ public class ApexPeriodicEventGenerator extends TimerTask {
return "ApexPeriodicEventGenerator [period=" + eventGeneratorPeriod + ", firstEventTime=" + firstEventTime
+ ", lastEventTime=" + lastEventTime + ", eventCount=" + eventCount + "]";
}
-}
+} \ No newline at end of file
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/enevent/ApexEvent2EnEventConverter.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/enevent/ApexEvent2EnEventConverter.java
index 27fa50988..3bbd3ab4f 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/enevent/ApexEvent2EnEventConverter.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/enevent/ApexEvent2EnEventConverter.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2021-2022 Bell Canada. All rights reserved.
* Modifications Copyright (C) 2021 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -72,12 +72,12 @@ public final class ApexEvent2EnEventConverter implements ApexEventConverter {
// Create the Apex event
final var axEvent = enEvent.getAxEvent();
final var apexEvent = new ApexEvent(axEvent.getKey().getName(), axEvent.getKey().getVersion(),
- axEvent.getNameSpace(), axEvent.getSource(), axEvent.getTarget());
+ axEvent.getNameSpace(), axEvent.getSource(), axEvent.getTarget(), axEvent.getToscaPolicyState());
apexEvent.setExecutionId(enEvent.getExecutionId());
apexEvent.setExecutionProperties(enEvent.getExecutionProperties());
- // Copy he exception message to the Apex event if it is set
+ // Copy the exception message to the Apex event if it is set
if (enEvent.getExceptionMessage() != null) {
apexEvent.setExceptionMessage(enEvent.getExceptionMessage());
}
@@ -119,4 +119,4 @@ public final class ApexEvent2EnEventConverter implements ApexEventConverter {
return enEvent;
}
-}
+} \ No newline at end of file
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/Apex2JsonEventConverter.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/Apex2JsonEventConverter.java
index 56f0d6ba8..976a3ae3d 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/Apex2JsonEventConverter.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/Apex2JsonEventConverter.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2021 Nordix Foundation.
- * Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2021-2022 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -188,6 +188,7 @@ public class Apex2JsonEventConverter implements ApexEventProtocolConverter {
jsonObject.addProperty(ApexEvent.NAMESPACE_HEADER_FIELD, apexEvent.getNameSpace());
jsonObject.addProperty(ApexEvent.SOURCE_HEADER_FIELD, apexEvent.getSource());
jsonObject.addProperty(ApexEvent.TARGET_HEADER_FIELD, apexEvent.getTarget());
+ jsonObject.addProperty(ApexEvent.TOSCA_POLICY_STATE_HEADER_FIELD, apexEvent.getToscaPolicyState());
if (apexEvent.getExceptionMessage() != null) {
jsonObject.addProperty(ApexEvent.EXCEPTION_MESSAGE_HEADER_FIELD, apexEvent.getExceptionMessage());
@@ -416,8 +417,9 @@ public class Apex2JsonEventConverter implements ApexEventProtocolConverter {
final String eventNamespace = getHeaderNamespace(jsonObject, eventName, eventDefinition);
final String eventSource = getHeaderSource(jsonObject, eventDefinition);
final String eventTarget = getHeaderTarget(jsonObject, eventDefinition);
+ final String eventStatus = getHeaderToscaPolicyState(jsonObject, eventDefinition);
- return new ApexEvent(eventName, eventVersion, eventNamespace, eventSource, eventTarget);
+ return new ApexEvent(eventName, eventVersion, eventNamespace, eventSource, eventTarget, eventStatus);
}
/**
@@ -521,6 +523,23 @@ public class Apex2JsonEventConverter implements ApexEventProtocolConverter {
}
/**
+ * Determine the status field of the event header.
+ *
+ * @param jsonObject the event in JSON format
+ * @param eventDefinition the definition of the event structure
+ * @return the event toscaPolicyState
+ */
+ private String getHeaderToscaPolicyState(final JsonObject jsonObject, final AxEvent eventDefinition) {
+ // For toscaPolicyState, use defined value from model only if value is not found on the incoming event
+ var toscaPolicyState = getJsonStringField(jsonObject, ApexEvent.TOSCA_POLICY_STATE_HEADER_FIELD,
+ jsonPars.getToscaPolicyStateAlias(), null, false);
+ if (toscaPolicyState == null) {
+ toscaPolicyState = eventDefinition.getToscaPolicyState();
+ }
+ return toscaPolicyState;
+ }
+
+ /**
* This method gets an event string field from a JSON object.
*
* @param jsonObject the JSON object containing the JSON representation of the incoming event
@@ -609,4 +628,4 @@ public class Apex2JsonEventConverter implements ApexEventProtocolConverter {
// check for the field
return jsonObject.has(fieldName);
}
-}
+} \ No newline at end of file
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/JsonEventProtocolParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/JsonEventProtocolParameters.java
index 51e9b6d40..397a56e78 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/JsonEventProtocolParameters.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/JsonEventProtocolParameters.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -61,11 +62,12 @@ public class JsonEventProtocolParameters extends EventProtocolTextCharDelimitedP
// Aliases for Apex event header fields
// @formatter:off
- private String nameAlias = null;
- private String versionAlias = null;
- private String nameSpaceAlias = null;
- private String sourceAlias = null;
- private String targetAlias = null;
+ private String nameAlias = null;
+ private String versionAlias = null;
+ private String nameSpaceAlias = null;
+ private String sourceAlias = null;
+ private String targetAlias = null;
+ private String toscaPolicyStateAlias = null;
// @formatter:on
// Flag indicating POJO decoding and encoding and parameter indicating the name of the Pojo field
@@ -104,4 +106,4 @@ public class JsonEventProtocolParameters extends EventProtocolTextCharDelimitedP
public String getName() {
return this.getLabel();
}
-}
+} \ No newline at end of file
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/ApexEventTest.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/ApexEventTest.java
index bb299a834..0f17bf193 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/ApexEventTest.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/ApexEventTest.java
@@ -1,6 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2021. Nordix Foundation.
+ * Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -42,7 +43,7 @@ public class ApexEventTest {
@Before
public void setUp() throws Exception {
apexEvent =
- new ApexEvent("name", "version", "namespace", "source", "target");
+ new ApexEvent("name", "version", "namespace", "source", "target", "");
}
@@ -50,7 +51,7 @@ public class ApexEventTest {
public void invalidEventName() {
final String name = "++" + RandomStringUtils.randomAlphabetic(5);
Assertions.assertThatCode(() ->
- apexEvent = new ApexEvent(name, "version", "namespace", "source", "target"))
+ apexEvent = new ApexEvent(name, "version", "namespace", "source", "target", ""))
.isInstanceOf(ApexEventException.class);
}
@@ -58,7 +59,7 @@ public class ApexEventTest {
public void invalidEventVersion() {
final String version = "++" + RandomStringUtils.randomAlphabetic(5);
Assertions.assertThatCode(() ->
- apexEvent = new ApexEvent("name", version, "namespace", "source", "target"))
+ apexEvent = new ApexEvent("name", version, "namespace", "source", "target", ""))
.isInstanceOf(ApexEventException.class);
}
@@ -66,7 +67,7 @@ public class ApexEventTest {
public void invalidEventNamespace() {
final String namespace = "++" + RandomStringUtils.randomAlphabetic(5);
Assertions.assertThatCode(() ->
- apexEvent = new ApexEvent("name", "version", namespace, "source", "target"))
+ apexEvent = new ApexEvent("name", "version", namespace, "source", "target", ""))
.isInstanceOf(ApexEventException.class);
}
@@ -74,7 +75,7 @@ public class ApexEventTest {
public void invalidEventSource() {
final String source = "++" + RandomStringUtils.randomAlphabetic(5);
Assertions.assertThatCode(() ->
- apexEvent = new ApexEvent("name", "version", "namespace", source, "target"))
+ apexEvent = new ApexEvent("name", "version", "namespace", source, "target", ""))
.isInstanceOf(ApexEventException.class);
}
@@ -82,11 +83,19 @@ public class ApexEventTest {
public void invalidEventTarget() {
final String target = "++" + RandomStringUtils.randomAlphabetic(5);
Assertions.assertThatCode(() ->
- apexEvent = new ApexEvent("name", "version", "namespace", "source", target))
+ apexEvent = new ApexEvent("name", "version", "namespace", "source", target, ""))
.isInstanceOf(ApexEventException.class);
}
@Test
+ public void invalidEventStatus() {
+ final String toscaPolicyState = "INVALID_STATUS";
+ Assertions.assertThatCode(() ->
+ apexEvent = new ApexEvent("name", "version", "namespace", "source", "target", toscaPolicyState))
+ .isInstanceOf(ApexEventException.class);
+ }
+
+ @Test
public void setExecutionId() {
final int executionId = random.nextInt();
apexEvent.setExecutionId(executionId);
@@ -161,4 +170,4 @@ public class ApexEventTest {
assertThat(actual2).isNull();
assertThat(actual3).isNull();
}
-}
+} \ No newline at end of file
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/JsonEventConverterTest.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/JsonEventConverterTest.java
index a7d08bb55..ed1e09b2a 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/JsonEventConverterTest.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/JsonEventConverterTest.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -59,7 +60,7 @@ public class JsonEventConverterTest {
assertThatThrownBy(() -> converter.fromApexEvent(null))
.hasMessage("event processing failed, Apex event is null");
assertThatThrownBy(() -> converter.fromApexEvent(new ApexEvent("Event", "0.0.1", "a.name.space",
- "here", "there")))
+ "here", "there", "")))
.hasMessage("Model for org.onap.policy.apex.model.eventmodel.concepts.AxEvents not found in model service");
}
-}
+} \ No newline at end of file
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/JsonEventHandlerTest.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/JsonEventHandlerTest.java
index fdb886e10..dd7acddaa 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/JsonEventHandlerTest.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/JsonEventHandlerTest.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,6 +39,7 @@ import org.junit.Test;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.SchemaParameters;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
+import org.onap.policy.apex.model.basicmodel.concepts.AxToscaPolicyProcessingStatus;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelReader;
import org.onap.policy.apex.model.basicmodel.service.ModelService;
@@ -250,7 +252,8 @@ public class JsonEventHandlerTest {
basicEventMap.put("intPar", 12345);
final ApexEvent basicEvent =
- new ApexEvent("BasicEvent", "0.0.1", "org.onap.policy.apex.events", "test", "apex");
+ new ApexEvent("BasicEvent", "0.0.1", "org.onap.policy.apex.events", "test", "apex",
+ AxToscaPolicyProcessingStatus.ENTRY.name());
basicEvent.putAll(basicEventMap);
final String apexEvent0000JsonString = (String) jsonEventConverter.fromApexEvent(basicEvent);
@@ -263,5 +266,6 @@ public class JsonEventHandlerTest {
assertTrue(apexEvent0000JsonString.contains("\"source\": \"test\""));
assertTrue(apexEvent0000JsonString.contains("\"target\": \"apex\""));
assertTrue(apexEvent0000JsonString.contains("\"intPar\": 12345"));
+ assertTrue(apexEvent0000JsonString.contains("\"toscaPolicyState\": \"ENTRY\""));
}
-}
+} \ No newline at end of file
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/impl/apexprotocolplugin/Apex2ApexEventConverterTest.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/impl/apexprotocolplugin/Apex2ApexEventConverterTest.java
index 04e87ee42..9a61f8739 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/impl/apexprotocolplugin/Apex2ApexEventConverterTest.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/impl/apexprotocolplugin/Apex2ApexEventConverterTest.java
@@ -1,6 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2021 Nordix Foundation
+ * Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,6 +30,7 @@ import java.util.List;
import org.apache.commons.lang3.RandomStringUtils;
import org.junit.Before;
import org.junit.Test;
+import org.onap.policy.apex.model.basicmodel.concepts.AxToscaPolicyProcessingStatus;
import org.onap.policy.apex.service.engine.event.ApexEvent;
import org.onap.policy.apex.service.engine.event.ApexEventException;
import org.onap.policy.apex.service.engine.event.ApexEventList;
@@ -76,8 +78,9 @@ public class Apex2ApexEventConverterTest {
final String nameSpace = "a" + RandomStringUtils.randomAlphanumeric(7);
final String source = RandomStringUtils.randomAlphanumeric(8);
final String target = RandomStringUtils.randomAlphanumeric(9);
+ final String toscaPolicyState = AxToscaPolicyProcessingStatus.ENTRY.name();
- final ApexEvent event = new ApexEvent(name, version, nameSpace, source, target);
+ final ApexEvent event = new ApexEvent(name, version, nameSpace, source, target, toscaPolicyState);
final List<ApexEvent> result = converter.toApexEvent(eventName, event);
assertThat(result).isEmpty();
}
@@ -90,8 +93,9 @@ public class Apex2ApexEventConverterTest {
final String nameSpace1 = "a" + RandomStringUtils.randomAlphanumeric(7);
final String source1 = RandomStringUtils.randomAlphanumeric(8);
final String target1 = RandomStringUtils.randomAlphanumeric(9);
+ final String toscaPolicyState1 = AxToscaPolicyProcessingStatus.ENTRY.name();
- final ApexEvent event = new ApexEvent(name1, version1, nameSpace1, source1, target1);
+ final ApexEvent event = new ApexEvent(name1, version1, nameSpace1, source1, target1, toscaPolicyState1);
final String key = RandomStringUtils.randomAlphabetic(3);
event.put(key, new Object());
@@ -108,8 +112,9 @@ public class Apex2ApexEventConverterTest {
final String nameSpace1 = "a" + RandomStringUtils.randomAlphanumeric(7);
final String source1 = RandomStringUtils.randomAlphanumeric(8);
final String target1 = RandomStringUtils.randomAlphanumeric(9);
+ final String toscaPolicyState1 = AxToscaPolicyProcessingStatus.ENTRY.name();
- final ApexEvent event = new ApexEvent(name1, version1, nameSpace1, source1, target1);
+ final ApexEvent event = new ApexEvent(name1, version1, nameSpace1, source1, target1, toscaPolicyState1);
final ApexEventList eventList = new ApexEventList();
eventList.add(event);
@@ -119,8 +124,9 @@ public class Apex2ApexEventConverterTest {
final String nameSpace2 = "b" + RandomStringUtils.randomAlphanumeric(17);
final String source2 = RandomStringUtils.randomAlphanumeric(18);
final String target2 = RandomStringUtils.randomAlphanumeric(19);
+ final String toscaPolicyState2 = AxToscaPolicyProcessingStatus.EXIT_SUCCESS.name();
- final ApexEvent parentEvent = new ApexEvent(name2, version2, nameSpace2, source2, target2);
+ final ApexEvent parentEvent = new ApexEvent(name2, version2, nameSpace2, source2, target2, toscaPolicyState2);
final String key = RandomStringUtils.randomAlphabetic(3);
parentEvent.put(key, eventList);
final List<ApexEvent> result = converter.toApexEvent(eventName, parentEvent);
@@ -136,8 +142,9 @@ public class Apex2ApexEventConverterTest {
final String nameSpace1 = "a" + RandomStringUtils.randomAlphanumeric(7);
final String source1 = RandomStringUtils.randomAlphanumeric(8);
final String target1 = RandomStringUtils.randomAlphanumeric(9);
+ final String toscaPolicyState1 = AxToscaPolicyProcessingStatus.ENTRY.name();
- final ApexEvent event = new ApexEvent(name1, version1, nameSpace1, source1, target1);
+ final ApexEvent event = new ApexEvent(name1, version1, nameSpace1, source1, target1, toscaPolicyState1);
final ApexEventList eventList = new ApexEventList();
eventList.add(event);
@@ -147,8 +154,9 @@ public class Apex2ApexEventConverterTest {
final String nameSpace2 = "b" + RandomStringUtils.randomAlphanumeric(17);
final String source2 = RandomStringUtils.randomAlphanumeric(18);
final String target2 = RandomStringUtils.randomAlphanumeric(19);
+ final String toscaPolicyState2 = AxToscaPolicyProcessingStatus.EXIT_FAILURE.name();
- final ApexEvent parentEvent = new ApexEvent(name2, version2, nameSpace2, source2, target2);
+ final ApexEvent parentEvent = new ApexEvent(name2, version2, nameSpace2, source2, target2, toscaPolicyState2);
final String key1 = RandomStringUtils.randomAlphabetic(3);
final String key2 = RandomStringUtils.randomAlphabetic(2);
parentEvent.put(key1, eventList);
@@ -170,11 +178,12 @@ public class Apex2ApexEventConverterTest {
final String nameSpace1 = "a" + RandomStringUtils.randomAlphanumeric(7);
final String source1 = RandomStringUtils.randomAlphanumeric(8);
final String target1 = RandomStringUtils.randomAlphanumeric(9);
+ final String toscaPolicyState1 = AxToscaPolicyProcessingStatus.ENTRY.name();
- final ApexEvent event = new ApexEvent(name1, version1, nameSpace1, source1, target1);
+ final ApexEvent event = new ApexEvent(name1, version1, nameSpace1, source1, target1, toscaPolicyState1);
final Object actual = converter.fromApexEvent(event);
assertSame(event, actual);
}
-}
+} \ No newline at end of file
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/impl/enevent/ApexEvent2EnEventConverterTest.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/impl/enevent/ApexEvent2EnEventConverterTest.java
index 562760f69..4d36b7be4 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/impl/enevent/ApexEvent2EnEventConverterTest.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/impl/enevent/ApexEvent2EnEventConverterTest.java
@@ -1,6 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2021 Nordix Foundation
+ * Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,6 +30,7 @@ import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.core.engine.event.EnEvent;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
+import org.onap.policy.apex.model.basicmodel.concepts.AxToscaPolicyProcessingStatus;
import org.onap.policy.apex.model.eventmodel.concepts.AxEvent;
import org.onap.policy.apex.service.engine.event.ApexEvent;
import org.onap.policy.apex.service.engine.event.ApexEventException;
@@ -58,8 +60,9 @@ public class ApexEvent2EnEventConverterTest {
final String nameSpace = "a" + RandomStringUtils.randomAlphanumeric(7);
final String source = RandomStringUtils.randomAlphanumeric(8);
final String target = RandomStringUtils.randomAlphanumeric(9);
+ final String toscaPolicyState = AxToscaPolicyProcessingStatus.ENTRY.name();
- final ApexEvent event = new ApexEvent(name, version, nameSpace, source, target);
+ final ApexEvent event = new ApexEvent(name, version, nameSpace, source, target, toscaPolicyState);
assertThatThrownBy(() -> converter.toApexEvent(eventName, event))
.isInstanceOf(ApexEventRuntimeException.class);
@@ -73,6 +76,7 @@ public class ApexEvent2EnEventConverterTest {
final String nameSpace = "b" + RandomStringUtils.randomAlphabetic(7);
final String source = RandomStringUtils.randomAlphabetic(8);
final String target = RandomStringUtils.randomAlphabetic(9);
+ final String toscaPolicyState = AxToscaPolicyProcessingStatus.ENTRY.name();
final int executionId = random.nextInt(1000);
final String exceptionMessage = RandomStringUtils.randomAlphabetic(11);
@@ -83,12 +87,13 @@ public class ApexEvent2EnEventConverterTest {
axEvent.setNameSpace(nameSpace);
axEvent.setSource(source);
axEvent.setTarget(target);
+ axEvent.setToscaPolicyState(toscaPolicyState);
final EnEvent enEvent = new EnEvent(axEvent);
enEvent.setExecutionId(executionId);
enEvent.setExceptionMessage(exceptionMessage);
// prepare expected event
- final ApexEvent apexEvent = new ApexEvent(name, version, nameSpace, source, target);
+ final ApexEvent apexEvent = new ApexEvent(name, version, nameSpace, source, target, toscaPolicyState);
apexEvent.setExecutionId(executionId);
apexEvent.setExceptionMessage(exceptionMessage);
final Object[] expected = {apexEvent};
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImplTest.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImplTest.java
index ed1afe4da..0095c9630 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImplTest.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImplTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020-2021 Nordix Foundation.
- * Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2020-2022 Bell Canada. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -239,7 +239,7 @@ public class EngineServiceImplTest {
esImpl.stop();
esImpl.sendEvent(null);
- esImpl.sendEvent(new ApexEvent("SomeEvent", "0.0.1", "the.event.namespace", "EventSource", "EventTarget"));
+ esImpl.sendEvent(new ApexEvent("SomeEvent", "0.0.1", "the.event.namespace", "EventSource", "EventTarget", ""));
esImpl.startPeriodicEvents(100000);
@@ -381,7 +381,8 @@ public class EngineServiceImplTest {
}
try {
- esImpl.sendEvent(new ApexEvent("SomeEvent", "0.0.1", "the.event.namespace", "EventSource", "EventTarget"));
+ esImpl.sendEvent(new ApexEvent("SomeEvent", "0.0.1", "the.event.namespace", "EventSource", "EventTarget",
+ ""));
} catch (ApexException apEx) {
fail("test should not throw an exception");
}
@@ -420,4 +421,4 @@ public class EngineServiceImplTest {
fail("test should not throw an exception");
}
}
-}
+} \ No newline at end of file
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorkerTest.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorkerTest.java
index 504e8df14..c95b465cf 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorkerTest.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorkerTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 Nordix Foundation.
- * Modifications Copyright (C) 2021 Bell Canada Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021-2022 Bell Canada Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -348,7 +348,7 @@ public class EngineWorkerTest {
fail("test should not throw an exception");
}
- eventQueue.add(new ApexEvent("SomeEvent", "0.0.1", "the.event.namespace", "EventSource", "EventTarget"));
+ eventQueue.add(new ApexEvent("SomeEvent", "0.0.1", "the.event.namespace", "EventSource", "EventTarget", ""));
try {
worker.updateModel(worker.getKey(), differentModelString, false);
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/file/TestFile2File.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/file/TestFile2File.java
index ea1e30114..941c60849 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/file/TestFile2File.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/file/TestFile2File.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020-2021 Nordix Foundation.
- * Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2020-2022 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,7 +47,7 @@ public class TestFile2File {
public void testJsonFileEvents() throws MessagingException, ApexException, IOException {
final String[] args = {"-rfr", "target", "-p", "target/examples/config/SampleDomain/File2FileJsonEvent.json"};
- testFileEvents(args, "target/examples/events/SampleDomain/EventsOut.json", 42200);
+ testFileEvents(args, "target/examples/events/SampleDomain/EventsOut.json", 44400);
}
@Test
@@ -93,4 +93,4 @@ public class TestFile2File {
return TextFileUtils.getTextFileAsString(outFile).replaceAll("\\s+", "").replaceAll(":\\d*\\.?\\d*,", ":0,")
.replaceAll(":\\d*}", ":0}").replaceAll("<value>\\d*\\.?\\d*</value>", "<value>0</value>");
}
-}
+} \ No newline at end of file
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/file/TestFile2FileFiltered.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/file/TestFile2FileFiltered.java
index 04dcb5704..a03b97e55 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/file/TestFile2FileFiltered.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/file/TestFile2FileFiltered.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020-2021 Nordix Foundation.
- * Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2020-2022 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -54,7 +54,7 @@ public class TestFile2FileFiltered {
"target/examples/events/SampleDomain/Events0104Out.json" };
final long[] expectedFileSizes =
- { 22366, 19834 };
+ { 23532, 20868 };
testFilteredFileEvents(args, outFilePaths, expectedFileSizes);
// @formatter:on
@@ -71,7 +71,7 @@ public class TestFile2FileFiltered {
"target/examples/events/SampleDomain/Events0104Out.json" };
final long[] expectedFileSizes =
- { 22366, 19834 };
+ { 23532, 20868 };
testFilteredFileEvents(args, outFilePaths, expectedFileSizes);
// @formatter:on
@@ -87,7 +87,7 @@ public class TestFile2FileFiltered {
{ "target/examples/events/SampleDomain/Events0004Out.json" };
final long[] expectedFileSizes =
- { 22366 };
+ { 23532 };
testFilteredFileEvents(args, outFilePaths, expectedFileSizes);
// @formatter:on
@@ -141,4 +141,4 @@ public class TestFile2FileFiltered {
return TextFileUtils.getTextFileAsString(outFile).replaceAll("\\s+", "").replaceAll(":\\d*\\.?\\d*,", ":0,")
.replaceAll(":\\d*}", ":0}").replaceAll("<value>\\d*\\.?\\d*</value>", "<value>0</value>");
}
-}
+} \ No newline at end of file
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/engine/ApexServiceModelUpdateTest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/engine/ApexServiceModelUpdateTest.java
index fc9b8da96..b3f9faa3f 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/engine/ApexServiceModelUpdateTest.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/engine/ApexServiceModelUpdateTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 Nordix Foundation.
- * Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2020-2022 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -323,12 +323,12 @@ public class ApexServiceModelUpdateTest {
eventDataMap.put("TestTemperature", 34.5445667);
final ApexEvent event =
- new ApexEvent("Event0000", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex");
+ new ApexEvent("Event0000", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex", "");
event.putAll(eventDataMap);
engineServiceEventInterface.sendEvent(event);
final ApexEvent event2 =
- new ApexEvent("Event0100", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex");
+ new ApexEvent("Event0100", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex", "");
event2.putAll(eventDataMap);
engineServiceEventInterface.sendEvent(event2);
@@ -344,8 +344,6 @@ public class ApexServiceModelUpdateTest {
* implements this interface, and the object created with that class is registered with a component using the
* component's <code>addTestListener</code> method. When the test event occurs, that object's appropriate method is
* invoked.
- *
- * @see TestEvent
*/
private final class TestListener implements ApexEventListener {
@@ -400,4 +398,4 @@ public class ApexServiceModelUpdateTest {
return baOutputStream.toString();
}
}
-}
+} \ No newline at end of file
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/engine/ApexServiceTest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/engine/ApexServiceTest.java
index e05825183..e2464e368 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/engine/ApexServiceTest.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/engine/ApexServiceTest.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -179,13 +180,13 @@ public class ApexServiceTest {
eventDataMap.put("TestTemperature", 34.5445667);
final ApexEvent event =
- new ApexEvent("Event0000", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex");
+ new ApexEvent("Event0000", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex", "");
event.setExecutionId(System.nanoTime());
event.putAll(eventDataMap);
engineServiceEventInterface.sendEvent(event);
final ApexEvent event2 =
- new ApexEvent("Event0100", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex");
+ new ApexEvent("Event0100", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex", "");
event2.setExecutionId(System.nanoTime());
event2.putAll(eventDataMap);
engineServiceEventInterface.sendEvent(event2);
@@ -239,7 +240,7 @@ public class ApexServiceTest {
eventDataMap.put("TestTemperature", 34.5445667);
final ApexEvent event1 =
- new ApexEvent("Event0000", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex");
+ new ApexEvent("Event0000", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex", "");
event1.putAll(eventDataMap);
event1.setExecutionId(System.nanoTime());
@@ -261,7 +262,7 @@ public class ApexServiceTest {
}
final ApexEvent event2 =
- new ApexEvent("Event0100", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex");
+ new ApexEvent("Event0100", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex", "");
event2.setExecutionId(System.nanoTime());
event2.putAll(eventDataMap);
@@ -329,13 +330,13 @@ public class ApexServiceTest {
eventDataMap.put("TestTemperature", 34.5445667);
final ApexEvent event =
- new ApexEvent("Event0000", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex");
+ new ApexEvent("Event0000", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex", "");
event.setExecutionId(System.nanoTime());
event.putAll(eventDataMap);
engineServiceEventInterface.sendEvent(event);
final ApexEvent event2 =
- new ApexEvent("Event0100", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex");
+ new ApexEvent("Event0100", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex", "");
event2.setExecutionId(System.nanoTime());
event2.putAll(eventDataMap);
engineServiceEventInterface.sendEvent(event2);
@@ -389,7 +390,7 @@ public class ApexServiceTest {
eventDataMap.put("TestTemperature", 34.5445667);
final ApexEvent event1 =
- new ApexEvent("Event0000", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex");
+ new ApexEvent("Event0000", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex", "");
event1.putAll(eventDataMap);
final ApexEventListener myEventListener1 = new ApexEventListener() {
@@ -410,7 +411,7 @@ public class ApexServiceTest {
}
final ApexEvent event2 =
- new ApexEvent("Event0100", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex");
+ new ApexEvent("Event0100", "0.0.1", "org.onap.policy.apex.domains.sample.events", "test", "apex", "");
event2.putAll(eventDataMap);
final ApexEventListener myEventListener2 = new ApexEventListener() {
@@ -472,8 +473,6 @@ public class ApexServiceTest {
* implements this interface, and the object created with that class is registered with a component using the
* component's <code>addTestListener</code> method. When the test event occurs, that object's appropriate method is
* invoked.
- *
- * @see TestEvent
*/
private static final class TestListener implements ApexEventListener {
@@ -528,4 +527,4 @@ public class ApexServiceTest {
return baOutputStream.toString();
}
}
-}
+} \ No newline at end of file
diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/events/Context_AvroEventAlbum_EventOutCompare.json b/testsuites/integration/integration-uservice-test/src/test/resources/events/Context_AvroEventAlbum_EventOutCompare.json
index e043ea1e2..6c13b1f0e 100644
--- a/testsuites/integration/integration-uservice-test/src/test/resources/events/Context_AvroEventAlbum_EventOutCompare.json
+++ b/testsuites/integration/integration-uservice-test/src/test/resources/events/Context_AvroEventAlbum_EventOutCompare.json
@@ -4,6 +4,7 @@
"nameSpace": "org.onap.policy.apex.test",
"source": "External",
"target": "Apex",
+ "toscaPolicyState": "",
"AvroArray": [
"I",
"once",
@@ -114,4 +115,4 @@
"CustomString": {
"stringValue": "I Wandered Lonely as a Cloud added to end of string"
}
-}
+} \ No newline at end of file
diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/events/Context_JavaEventAlbum_EventOutCompare.json b/testsuites/integration/integration-uservice-test/src/test/resources/events/Context_JavaEventAlbum_EventOutCompare.json
index a0f8549e6..fa64b2eeb 100644
--- a/testsuites/integration/integration-uservice-test/src/test/resources/events/Context_JavaEventAlbum_EventOutCompare.json
+++ b/testsuites/integration/integration-uservice-test/src/test/resources/events/Context_JavaEventAlbum_EventOutCompare.json
@@ -4,6 +4,7 @@
"nameSpace": "org.onap.policy.apex.test",
"source": "External",
"target": "Apex",
+ "toscaPolicyState": "",
"CustomBoolean": {
"flag": false
},
@@ -98,4 +99,4 @@
"JavaLong": 1234567890124,
"JavaShort": 32001,
"JavaString": "The four green provinces of Ireland added to end of string"
-}
+} \ No newline at end of file