Add TOSCA policy status header field to APEX event create CLI 15/126715/3
authorRashmi Pujar <rashmi.pujar1@bell.ca>
Sat, 22 Jan 2022 05:37:28 +0000 (00:37 -0500)
committerRashmi Pujar <rashmi.pujar1@bell.ca>
Mon, 24 Jan 2022 19:06:57 +0000 (14:06 -0500)
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

42 files changed:
auth/cli-editor/src/main/resources/etc/editor/Commands.json
auth/cli-editor/src/test/resources/tosca/PolicyModel.json
auth/cli-editor/src/test/resources/tosca/ToscaPolicyOutput_compare.json
core/core-engine/src/test/java/org/onap/policy/apex/core/engine/event/EnEventTest.java
examples/examples-grpc/src/main/resources/examples/events/APEXgRPC/CDSResponseStatusEvent.json
examples/examples-grpc/src/main/resources/examples/events/APEXgRPC/LogEvent.json
examples/examples-grpc/src/main/resources/policy/APEXgRPCPolicy.apex
examples/examples-grpc/src/test/java/org/onap/policy/apex/examples/grpc/TestApexGrpcExample.java
model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxToscaPolicyProcessingStatus.java [new file with mode: 0644]
model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxEvent.java
model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventsTest.java
model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexEditorApi.java
model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ApexModelImpl.java
model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/EventFacade.java
model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiEventTest.java
model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentVerboseValues.txt
model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonIdenticalVerboseValues.txt
plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/test/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsProducerTest.java
plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JmsObjectEventConverter.java
plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/main/java/org/onap/policy/apex/plugins/event/protocol/xml/Apex2XmlEventConverter.java
plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/XmlEventHandlerTest.java
plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java/org/onap/policy/apex/plugins/event/protocol/yaml/Apex2YamlEventConverter.java
plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java/org/onap/policy/apex/plugins/event/protocol/yaml/YamlEventProtocolParameters.java
plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/YamlPluginStabilityTest.java
services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexEvent.java
services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexPeriodicEventGenerator.java
services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/enevent/ApexEvent2EnEventConverter.java
services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/Apex2JsonEventConverter.java
services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/JsonEventProtocolParameters.java
services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/ApexEventTest.java
services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/JsonEventConverterTest.java
services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/JsonEventHandlerTest.java
services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/impl/apexprotocolplugin/Apex2ApexEventConverterTest.java
services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/impl/enevent/ApexEvent2EnEventConverterTest.java
services/services-engine/src/test/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImplTest.java
services/services-engine/src/test/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorkerTest.java
testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/file/TestFile2File.java
testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/file/TestFile2FileFiltered.java
testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/engine/ApexServiceModelUpdateTest.java
testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/engine/ApexServiceTest.java
testsuites/integration/integration-uservice-test/src/test/resources/events/Context_AvroEventAlbum_EventOutCompare.json
testsuites/integration/integration-uservice-test/src/test/resources/events/Context_JavaEventAlbum_EventOutCompare.json

index 7136922..4f55389 100644 (file)
           "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",
           "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",
       "description": "Delete a policy state context reference."
     }
   ]
-}
+}
\ No newline at end of file
index 95fab2d..96976d1 100644 (file)
                       }
                     }
                   ]
-                }
+                },
+                "toscaPolicyState": ""
               },
               "outputEvents": {
                 "entry": [
                             }
                           }
                         ]
-                      }
+                      },
+                      "toscaPolicyState": ""
                     }
                   }
                 ]
                     }
                   }
                 ]
-              }
+              },
+              "toscaPolicyState": ""
             }
           },
           {
                     }
                   }
                 ]
-              }
+              },
+              "toscaPolicyState": ""
             }
           }
         ]
       }
     }
   }
-}
+}
\ No newline at end of file
index 3649f94..26a844b 100644 (file)
@@ -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
index 128e585..49b4f80 100644 (file)
@@ -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
index 9389833..d616ac1 100644 (file)
@@ -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
index e227b66..6fd9077 100644 (file)
@@ -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
index 636c74b..34d590d 100644 (file)
@@ -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
index a197432..f5a51a7 100644 (file)
@@ -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 (file)
index 0000000..43c7e78
--- /dev/null
@@ -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
index 156b733..e3663e7 100644 (file)
@@ -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;
     }
 
     /**
@@ -326,6 +337,24 @@ public class AxEvent extends AxConcept {
         this.parameterMap = parameterMap;
     }
 
+    /**
+     * 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}.
      */
@@ -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
index 21601d7..111d27f 100644 (file)
@@ -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
index fab6ba1..8974d1f 100644 (file)
@@ -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
index 05976c6..cca9d34 100644 (file)
@@ -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
index 0a75840..f1f9393 100644 (file)
@@ -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
index bc46ee3..775fcc1 100644 (file)
@@ -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
index 2138e97..77d17f6 100644 (file)
@@ -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
index 0faab1c..4e07c53 100644 (file)
@@ -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
index 708f29f..2f78168 100644 (file)
@@ -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
index cd14f4a..8d9416f 100644 (file)
@@ -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
index f601c4b..907d426 100644 (file)
@@ -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
index 609b047..f8caf8c 100644 (file)
@@ -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
index 9359e4e..731d351 100644 (file)
@@ -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);
     }
 
     /**
@@ -317,6 +319,23 @@ public class Apex2YamlEventConverter implements ApexEventProtocolConverter {
         return target;
     }
 
+    /**
+     * 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.
      *
@@ -391,4 +410,4 @@ public class Apex2YamlEventConverter implements ApexEventProtocolConverter {
 
         return eventElement;
     }
-}
+}
\ No newline at end of file
index e5539cd..1201044 100644 (file)
@@ -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
index ab91149..0d3d623 100644 (file)
@@ -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
index 76a1c03..a8f13bb 100644 (file)
@@ -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;
 
@@ -91,6 +96,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
index 1300f21..ea3cb4b 100644 (file)
@@ -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
index 27fa509..3bbd3ab 100644 (file)
@@ -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
index 56f0d6b..976a3ae 100644 (file)
@@ -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);
     }
 
     /**
@@ -520,6 +522,23 @@ public class Apex2JsonEventConverter implements ApexEventProtocolConverter {
         return target;
     }
 
+    /**
+     * 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.
      *
@@ -609,4 +628,4 @@ public class Apex2JsonEventConverter implements ApexEventProtocolConverter {
         // check for the field
         return jsonObject.has(fieldName);
     }
-}
+}
\ No newline at end of file
index 51e9b6d..397a56e 100644 (file)
@@ -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
index bb299a8..0f17bf1 100644 (file)
@@ -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,10 +83,18 @@ 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();
@@ -161,4 +170,4 @@ public class ApexEventTest {
         assertThat(actual2).isNull();
         assertThat(actual3).isNull();
     }
-}
+}
\ No newline at end of file
index a7d08bb..ed1e09b 100644 (file)
@@ -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
index fdb886e..dd7acdd 100644 (file)
@@ -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
index 04e87ee..9a61f87 100644 (file)
@@ -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
index 562760f..4d36b7b 100644 (file)
@@ -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};
index ed1afe4..0095c96 100644 (file)
@@ -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
index 504e8df..c95b465 100644 (file)
@@ -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);
index ea1e301..941c608 100644 (file)
@@ -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
index 04dcb57..a03b97e 100644 (file)
@@ -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
index fc9b8da..b3f9faa 100644 (file)
@@ -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
index e058251..e2464e3 100644 (file)
@@ -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
index e043ea1..6c13b1f 100644 (file)
@@ -4,6 +4,7 @@
     "nameSpace": "org.onap.policy.apex.test",
     "source": "External",
     "target": "Apex",
+    "toscaPolicyState": "",
     "AvroArray": [
         "I",
         "once",
     "CustomString": {
         "stringValue": "I Wandered Lonely as a Cloud added to end of string"
     }
-}
+}
\ No newline at end of file
index a0f8549..fa64b2e 100644 (file)
@@ -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