aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2024-09-18 17:27:04 +0100
committerFrancescoFioraEst <francesco.fiora@est.tech>2024-12-11 17:16:19 +0000
commit2df59bcd84c52b013ac5f607acd0ae50fdbff8bf (patch)
tree8cfc384cea63c97808bd2b01c0acee3acaba976a
parent4e99849bef97bdc98f96fd62668ab4f83aa25c7a (diff)
Move policy definition data under instance propertiesHEADmaster
Move policy definition data under instance properties for policy-participant. Issue-ID: POLICY-4938 Change-Id: I60c6536554ce3750f03e42e397f000b35b5d6e07 Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
-rw-r--r--examples/src/main/resources/clamp/acm/acelement-helm/acelement/values.yaml2
-rw-r--r--examples/src/main/resources/clamp/acm/acm-demo/AutomationComposition.yaml844
-rw-r--r--examples/src/main/resources/clamp/acm/acm-demo/toscaServiceTemplate.yaml785
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementDeploy.java5
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementRestart.java3
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java25
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java28
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/CommonTestData.java5
-rw-r--r--participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandler.java16
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandlerTest.java42
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV2Test.java15
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV3Test.java16
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/InstanceElementDto.java29
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV1.java1
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AcLockHandler.java8
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AcSubStateHandler.java8
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java17
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/CacheProvider.java15
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV1Test.java20
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV2Test.java16
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV3Test.java16
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java11
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AcLockHandlerTest.java11
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandlerTest.java17
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/CacheProviderTest.java33
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ThreadHandlerTest.java20
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java3
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandler.java8
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java9
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java35
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionDeployPublisher.java7
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantSyncPublisher.java9
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandlerTest.java56
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java41
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java14
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/comm/SupervisionMessagesTest.java9
36 files changed, 1122 insertions, 1077 deletions
diff --git a/examples/src/main/resources/clamp/acm/acelement-helm/acelement/values.yaml b/examples/src/main/resources/clamp/acm/acelement-helm/acelement/values.yaml
index c26ac991c..2d1fd1df1 100644
--- a/examples/src/main/resources/clamp/acm/acelement-helm/acelement/values.yaml
+++ b/examples/src/main/resources/clamp/acm/acelement-helm/acelement/values.yaml
@@ -26,7 +26,7 @@ image:
repository: nexus3.onap.org:10001
name: onap/policy-clamp-acm-element-impl
pullPolicy: IfNotPresent
- tag: "7.1.0"
+ tag: "8.0.1"
nameOverride: "ac-element-impl"
diff --git a/examples/src/main/resources/clamp/acm/acm-demo/AutomationComposition.yaml b/examples/src/main/resources/clamp/acm/acm-demo/AutomationComposition.yaml
index 27426d1ee..5f8067866 100644
--- a/examples/src/main/resources/clamp/acm/acm-demo/AutomationComposition.yaml
+++ b/examples/src/main/resources/clamp/acm/acm-demo/AutomationComposition.yaml
@@ -1,5 +1,5 @@
# ============LICENSE_START=======================================================
-# Copyright (C) 2023 Nordix Foundation.
+# Copyright (C) 2023-2024 Nordix Foundation.
# ================================================================================
# Licensed under the Apache License, Version 2.0 (the License);
# you may not use this file except in compliance with the License.
@@ -15,24 +15,821 @@
#
# SPDX-License-Identifier: Apache-2.0
# ============LICENSE_END=========================================================
-name: DemoInstance0
+name: DemoInstanceOslo
version: 1.0.1
-compositionId: {{compositionId}}
-description: Demo automation composition instance 0
+compositionId: {{composition1Id}}
+description: Demo automation composition instance for Oslo
elements:
709c62b3-8918-41b9-a747-d21eb79c6c20:
id: 709c62b3-8918-41b9-a747-d21eb79c6c20
definition:
- name: onap.policy.clamp.ac.element.Policy_AutomationCompositionElement
- version: 1.2.3
+ name: onap.policy.clamp.ac.element.Policy_AutomationCompositionElement
+ version: 1.2.3
description: Starter Automation Composition Element for the Demo
properties:
- policy_type_id:
- name: onap.policies.operational.pm-subscription-handler
- version: 1.0.0
- policy_id:
- get_input: acm_element_policy
+ tosca_definitions_version: tosca_simple_yaml_1_3
+ name: "NULL"
+ version: 0.0.0
+ data_types:
+ onap.datatypes.native.apex.EngineService:
+ derived_from: tosca.datatypes.Root
+ properties:
+ name:
+ type: string
+ description: Specifies the engine name
+ required: false
+ default: "ApexEngineService"
+ version:
+ type: string
+ description: Specifies the engine version in double dotted format
+ required: false
+ default: "1.0.0"
+ id:
+ type: integer
+ description: Specifies the engine id
+ required: true
+ instance_count:
+ type: integer
+ description: Specifies the number of engine threads that should be run
+ required: true
+ deployment_port:
+ type: integer
+ description: Specifies the port to connect to for engine administration
+ required: false
+ default: 1
+ policy_model_file_name:
+ type: string
+ description: The name of the file from which to read the APEX policy model
+ required: false
+ policy_type_impl:
+ type: string
+ description: The policy type implementation from which to read the APEX policy model
+ required: false
+ periodic_event_period:
+ type: string
+ description: The time interval in milliseconds for the periodic scanning event, 0 means don't scan
+ required: false
+ engine:
+ type: onap.datatypes.native.apex.engineservice.Engine
+ description: The parameters for all engines in the APEX engine service
+ required: true
+ onap.datatypes.native.apex.EventHandler:
+ derived_from: tosca.datatypes.Root
+ properties:
+ name:
+ type: string
+ description: Specifies the event handler name, if not specified this is set to the key name
+ required: false
+ carrier_technology:
+ type: onap.datatypes.native.apex.CarrierTechnology
+ description: Specifies the carrier technology of the event handler (such as REST/Web Socket/Kafka)
+ required: true
+ event_protocol:
+ type: onap.datatypes.native.apex.EventProtocol
+ description: Specifies the event protocol of events for the event handler (such as Yaml/JSON/XML/POJO)
+ required: true
+ event_name:
+ type: string
+ description: Specifies the event name for events on this event handler, if not specified, the event name is read from or written to the event being received or sent
+ required: false
+ event_name_filter:
+ type: string
+ description: Specifies a filter as a regular expression, events that do not match the filter are dropped, the default is to let all events through
+ required: false
+ synchronous_mode:
+ type: boolean
+ description: Specifies the event handler is syncronous (receive event and send response)
+ required: false
+ default: false
+ synchronous_peer:
+ type: string
+ description: The peer event handler (output for input or input for output) of this event handler in synchronous mode, this parameter is mandatory if the event handler is in synchronous mode
+ required: false
+ synchronous_timeout:
+ type: integer
+ description: The timeout in milliseconds for responses to be issued by APEX torequests, this parameter is mandatory if the event handler is in synchronous mode
+ required: false
+ requestor_mode:
+ type: boolean
+ description: Specifies the event handler is in requestor mode (send event and wait for response mode)
+ required: false
+ default: false
+ requestor_peer:
+ type: string
+ description: The peer event handler (output for input or input for output) of this event handler in requestor mode, this parameter is mandatory if the event handler is in requestor mode
+ required: false
+ requestor_timeout:
+ type: integer
+ description: The timeout in milliseconds for wait for responses to requests, this parameter is mandatory if the event handler is in requestor mode
+ required: false
+ onap.datatypes.native.apex.CarrierTechnology:
+ derived_from: tosca.datatypes.Root
+ properties:
+ label:
+ type: string
+ description: The label (name) of the carrier technology (such as REST, Kafka, WebSocket)
+ required: true
+ plugin_parameter_class_name:
+ type: string
+ description: The class name of the class that overrides default handling of event input or output for this carrier technology, defaults to the supplied input or output class
+ required: false
+ onap.datatypes.native.apex.EventProtocol:
+ derived_from: tosca.datatypes.Root
+ properties:
+ label:
+ type: string
+ description: The label (name) of the event protocol (such as Yaml, JSON, XML, or POJO)
+ required: true
+ event_protocol_plugin_class:
+ type: string
+ description: The class name of the class that overrides default handling of the event protocol for this carrier technology, defaults to the supplied event protocol class
+ required: false
+ onap.datatypes.native.apex.Environment:
+ derived_from: tosca.datatypes.Root
+ properties:
+ name:
+ type: string
+ description: The name of the environment variable
+ required: true
+ value:
+ type: string
+ description: The value of the environment variable
+ required: true
+ onap.datatypes.native.apex.engineservice.Engine:
+ derived_from: tosca.datatypes.Root
+ properties:
+ context:
+ type: onap.datatypes.native.apex.engineservice.engine.Context
+ description: The properties for handling context in APEX engines, defaults to using Java maps for context
+ required: false
+ executors:
+ type: map
+ description: The plugins for policy executors used in engines such as javascript, MVEL, Jython
+ required: true
+ entry_schema:
+ description: The plugin class path for this policy executor
+ type: string
+ onap.datatypes.native.apex.engineservice.engine.Context:
+ derived_from: tosca.datatypes.Root
+ properties:
+ distributor:
+ type: onap.datatypes.native.apex.Plugin
+ description: The plugin to be used for distributing context between APEX PDPs at runtime
+ required: false
+ schemas:
+ type: map
+ description: The plugins for context schemas available in APEX PDPs such as Java and Avro
+ required: false
+ entry_schema:
+ type: onap.datatypes.native.apex.Plugin
+ locking:
+ type: onap.datatypes.native.apex.Plugin
+ description: The plugin to be used for locking context in and between APEX PDPs at runtime
+ required: false
+ persistence:
+ type: onap.datatypes.native.apex.Plugin
+ description: The plugin to be used for persisting context for APEX PDPs at runtime
+ required: false
+ onap.datatypes.native.apex.Plugin:
+ derived_from: tosca.datatypes.Root
+ properties:
+ name:
+ type: string
+ description: The name of the executor such as Javascript, Jython or MVEL
+ required: true
+ plugin_class_name:
+ type: string
+ description: The class path of the plugin class for this executor
+
+ policy_types:
+ onap.policies.Native:
+ derived_from: tosca.policies.Root
+ description: a base policy type for all native PDP policies
+ version: 1.0.0
+ name: onap.policies.Native
+ onap.policies.native.Apex:
+ derived_from: onap.policies.Native
+ description: a policy type for native apex policies
+ version: 1.0.0
+ name: onap.policies.native.Apex
+ properties:
+ engine_service:
+ type: onap.datatypes.native.apex.EngineService
+ description: APEX Engine Service Parameters
+ inputs:
+ type: map
+ description: Inputs for handling events coming into the APEX engine
+ entry_schema:
+ type: onap.datatypes.native.apex.EventHandler
+ outputs:
+ type: map
+ description: Outputs for handling events going out of the APEX engine
+ entry_schema:
+ type: onap.datatypes.native.apex.EventHandler
+ environment:
+ type: list
+ description: Envioronmental parameters for the APEX engine
+ entry_schema:
+ type: onap.datatypes.native.apex.Environment
+
+ topology_template:
+ policies:
+ - onap.policies.native.apex.ac.element:
+ type: onap.policies.native.Apex
+ type_version: 1.0.0
+ properties:
+ engineServiceParameters:
+ name: MyApexEngine
+ version: 0.0.1
+ id: 45
+ instanceCount: 2
+ deploymentPort: 12561
+ engineParameters:
+ executorParameters:
+ JAVASCRIPT:
+ parameterClassName: org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters
+ contextParameters:
+ parameterClassName: org.onap.policy.apex.context.parameters.ContextParameters
+ schemaParameters:
+ Json:
+ parameterClassName: org.onap.policy.apex.plugins.context.schema.json.JsonSchemaHelperParameters
+ policy_type_impl:
+ policies:
+ key:
+ name: APEXacElementPolicy_Policies
+ version: 0.0.1
+ policyMap:
+ entry:
+ - key:
+ name: ReceiveEventPolicy
+ version: 0.0.1
+ value:
+ policyKey:
+ name: ReceiveEventPolicy
+ version: 0.0.1
+ template: Freestyle
+ state:
+ entry:
+ - key: DecideForwardingState
+ value:
+ stateKey:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: 'NULL'
+ localName: DecideForwardingState
+ trigger:
+ name: AcElementEvent
+ version: 0.0.1
+ stateOutputs:
+ entry:
+ - key: CreateForwardPayload
+ value:
+ key:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: DecideForwardingState
+ localName: CreateForwardPayload
+ outgoingEvent:
+ name: KafkaResponseStatusEvent
+ version: 0.0.1
+ outgoingEventReference:
+ - name: KafkaResponseStatusEvent
+ version: 0.0.1
+ nextState:
+ parentKeyName: 'NULL'
+ parentKeyVersion: 0.0.0
+ parentLocalName: 'NULL'
+ localName: 'NULL'
+ contextAlbumReference: []
+ taskSelectionLogic:
+ key:
+ parentKeyName: 'NULL'
+ parentKeyVersion: 0.0.0
+ parentLocalName: 'NULL'
+ localName: 'NULL'
+ logicFlavour: UNDEFINED
+ logic: ''
+ stateFinalizerLogicMap:
+ entry: []
+ defaultTask:
+ name: ForwardPayloadTask
+ version: 0.0.1
+ taskReferences:
+ entry:
+ - key:
+ name: ForwardPayloadTask
+ version: 0.0.1
+ value:
+ key:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: DecideForwardingState
+ localName: ReceiveEventPolicy
+ outputType: DIRECT
+ output:
+ parentKeyName: ReceiveEventPolicy
+ parentKeyVersion: 0.0.1
+ parentLocalName: DecideForwardingState
+ localName: CreateForwardPayload
+ firstState: DecideForwardingState
+ tasks:
+ key:
+ name: APEXacElementPolicy_Tasks
+ version: 0.0.1
+ taskMap:
+ entry:
+ - key:
+ name: ForwardPayloadTask
+ version: 0.0.1
+ value:
+ key:
+ name: ForwardPayloadTask
+ version: 0.0.1
+ inputEvent:
+ key:
+ name: AcElementEvent
+ version: 0.0.1
+ nameSpace: org.onap.policy.apex.ac.element
+ source: Kafka
+ target: APEX
+ parameter:
+ entry:
+ - key: KafkaResponseEvent
+ value:
+ key:
+ parentKeyName: AcElementEvent
+ parentKeyVersion: 0.0.1
+ parentLocalName: 'NULL'
+ localName: KafkaResponseEvent
+ fieldSchemaKey:
+ name: ACEventType
+ version: 0.0.1
+ optional: false
+ toscaPolicyState: ENTRY
+ outputEvents:
+ entry:
+ - key: KafkaResponseStatusEvent
+ value:
+ key:
+ name: KafkaResponseStatusEvent
+ version: 0.0.1
+ nameSpace: org.onap.policy.apex.ac.element
+ source: APEX
+ target: Kafka
+ parameter:
+ entry:
+ - key: KafkaResponseStatusEvent
+ value:
+ key:
+ parentKeyName: KafkaResponseStatusEvent
+ parentKeyVersion: 0.0.1
+ parentLocalName: 'NULL'
+ localName: KafkaResponseStatusEvent
+ fieldSchemaKey:
+ name: ACEventType
+ version: 0.0.1
+ optional: false
+ toscaPolicyState: ''
+ taskParameters:
+ entry: []
+ contextAlbumReference:
+ - name: ACElementAlbum
+ version: 0.0.1
+ taskLogic:
+ key:
+ parentKeyName: ForwardPayloadTask
+ parentKeyVersion: 0.0.1
+ parentLocalName: 'NULL'
+ localName: TaskLogic
+ logicFlavour: JAVASCRIPT
+ logic: "/*\n * ============LICENSE_START=======================================================\n\
+ \ * Copyright (C) 2022 Nordix. All rights reserved.\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\
+ \ */\n\nexecutor.logger.info(executor.subject.id);\nexecutor.logger.info(executor.inFields);\n\
+ \nvar msgResponse = executor.inFields.get('KafkaResponseEvent');\n\
+ executor.logger.info('Task in progress with mesages: ' + msgResponse);\n\
+ \nvar elementId = msgResponse.get('elementId').get('name');\n\
+ \nif (msgResponse.get('messageType') == 'STATUS' &&\n (elementId\
+ \ == 'onap.policy.clamp.ac.startertobridge'\n || elementId\
+ \ == 'onap.policy.clamp.ac.bridgetosink')) {\n\n var receiverId\
+ \ = '';\n if (elementId == 'onap.policy.clamp.ac.startertobridge')\
+ \ {\n receiverId = 'onap.policy.clamp.ac.bridge';\n\
+ \ } else {\n receiverId = 'onap.policy.clamp.ac.sink';\n\
+ \ }\n\n var elementIdResponse = new java.util.HashMap();\n\
+ \ elementIdResponse.put('name', receiverId);\n elementIdResponse.put('version',\
+ \ msgResponse.get('elementId').get('version'));\n\n var\
+ \ kafkaResponse = new java.util.HashMap();\n kafkaResponse.put('elementId',\
+ \ elementIdResponse);\n\n var message = msgResponse.get('message')\
+ \ + ' trace added from policy';\n kafkaResponse.put('message',\
+ \ message);\n kafkaResponse.put('messageType', 'STATUS');\n\
+ \ kafkaResponse.put('messageId', msgResponse.get('messageId'));\n\
+ \ kafkaResponse.put('timestamp', msgResponse.get('timestamp'));\n\
+ \n executor.logger.info('Sending forwarding Event to Ac\
+ \ element: ' + kafkaResponse);\n\n executor.outFields.put('KafkaResponseStatusEvent',\
+ \ kafkaResponse);\n}\n\ntrue;"
+ events:
+ key:
+ name: APEXacElementPolicy_Events
+ version: 0.0.1
+ eventMap:
+ entry:
+ - key:
+ name: AcElementEvent
+ version: 0.0.1
+ value:
+ key:
+ name: AcElementEvent
+ version: 0.0.1
+ nameSpace: org.onap.policy.apex.ac.element
+ source: Kafka
+ target: APEX
+ parameter:
+ entry:
+ - key: KafkaResponseEvent
+ value:
+ key:
+ parentKeyName: AcElementEvent
+ parentKeyVersion: 0.0.1
+ parentLocalName: 'NULL'
+ localName: KafkaResponseEvent
+ fieldSchemaKey:
+ name: ACEventType
+ version: 0.0.1
+ optional: false
+ toscaPolicyState: ENTRY
+ - key:
+ name: KafkaResponseStatusEvent
+ version: 0.0.1
+ value:
+ key:
+ name: KafkaResponseStatusEvent
+ version: 0.0.1
+ nameSpace: org.onap.policy.apex.ac.element
+ source: APEX
+ target: Kafka
+ parameter:
+ entry:
+ - key: KafkaResponseStatusEvent
+ value:
+ key:
+ parentKeyName: KafkaResponseStatusEvent
+ parentKeyVersion: 0.0.1
+ parentLocalName: 'NULL'
+ localName: KafkaResponseStatusEvent
+ fieldSchemaKey:
+ name: ACEventType
+ version: 0.0.1
+ optional: false
+ toscaPolicyState: ''
+ - key:
+ name: LogEvent
+ version: 0.0.1
+ value:
+ key:
+ name: LogEvent
+ version: 0.0.1
+ nameSpace: org.onap.policy.apex.ac.element
+ source: APEX
+ target: file
+ parameter:
+ entry:
+ - key: final_status
+ value:
+ key:
+ parentKeyName: LogEvent
+ parentKeyVersion: 0.0.1
+ parentLocalName: 'NULL'
+ localName: final_status
+ fieldSchemaKey:
+ name: SimpleStringType
+ version: 0.0.1
+ optional: false
+ - key: message
+ value:
+ key:
+ parentKeyName: LogEvent
+ parentKeyVersion: 0.0.1
+ parentLocalName: 'NULL'
+ localName: message
+ fieldSchemaKey:
+ name: SimpleStringType
+ version: 0.0.1
+ optional: false
+ toscaPolicyState: ''
+ albums:
+ key:
+ name: APEXacElementPolicy_Albums
+ version: 0.0.1
+ albums:
+ entry:
+ - key:
+ name: ACElementAlbum
+ version: 0.0.1
+ value:
+ key:
+ name: ACElementAlbum
+ version: 0.0.1
+ scope: policy
+ isWritable: true
+ itemSchema:
+ name: ACEventType
+ version: 0.0.1
+ schemas:
+ key:
+ name: APEXacElementPolicy_Schemas
+ version: 0.0.1
+ schemas:
+ entry:
+ - key:
+ name: ACEventType
+ version: 0.0.1
+ value:
+ key:
+ name: ACEventType
+ version: 0.0.1
+ schemaFlavour: Json
+ schemaDefinition: "{\n \"$schema\": \"http://json-schema.org/draft-04/schema#\"\
+ ,\n \"type\": \"object\",\n \"properties\": {\n \
+ \ \"elementId\": {\n \"type\": \"object\",\n \
+ \ \"properties\": {\n \"name\": {\n \
+ \ \"type\": \"string\"\n },\n\
+ \ \"version\": {\n \"type\"\
+ : \"string\"\n }\n },\n \
+ \ \"required\": [\n \"name\",\n \
+ \ \"version\"\n ]\n },\n \"message\"\
+ : {\n \"type\": \"string\"\n },\n \"\
+ messageType\": {\n \"type\": \"string\"\n \
+ \ }\n },\n \"required\": [\n \"elementId\",\n \
+ \ \"message\",\n \"messageType\"\n ]\n}"
+ - key:
+ name: SimpleIntType
+ version: 0.0.1
+ value:
+ key:
+ name: SimpleIntType
+ version: 0.0.1
+ schemaFlavour: Java
+ schemaDefinition: java.lang.Integer
+ - key:
+ name: SimpleStringType
+ version: 0.0.1
+ value:
+ key:
+ name: SimpleStringType
+ version: 0.0.1
+ schemaFlavour: Java
+ schemaDefinition: java.lang.String
+ - key:
+ name: UUIDType
+ version: 0.0.1
+ value:
+ key:
+ name: UUIDType
+ version: 0.0.1
+ schemaFlavour: Java
+ schemaDefinition: java.util.UUID
+ key:
+ name: APEXacElementPolicy
+ version: 0.0.1
+ keyInformation:
+ key:
+ name: APEXacElementPolicy_KeyInfo
+ version: 0.0.1
+ keyInfoMap:
+ entry:
+ - key:
+ name: ACElementAlbum
+ version: 0.0.1
+ value:
+ key:
+ name: ACElementAlbum
+ version: 0.0.1
+ UUID: 7cddfab8-6d3f-3f7f-8ac3-e2eb5979c900
+ description: Generated description for concept referred to by
+ key "ACElementAlbum:0.0.1"
+ - key:
+ name: ACEventType
+ version: 0.0.1
+ value:
+ key:
+ name: ACEventType
+ version: 0.0.1
+ UUID: dab78794-b666-3929-a75b-70d634b04fe5
+ description: Generated description for concept referred to by
+ key "ACEventType:0.0.1"
+ - key:
+ name: APEXacElementPolicy
+ version: 0.0.1
+ value:
+ key:
+ name: APEXacElementPolicy
+ version: 0.0.1
+ UUID: da478611-7d77-3c46-b4be-be968769ba4e
+ description: Generated description for concept referred to by
+ key "APEXacElementPolicy:0.0.1"
+ - key:
+ name: APEXacElementPolicy_Albums
+ version: 0.0.1
+ value:
+ key:
+ name: APEXacElementPolicy_Albums
+ version: 0.0.1
+ UUID: fa8dc15e-8c8d-3de3-a0f8-585b76511175
+ description: Generated description for concept referred to by
+ key "APEXacElementPolicy_Albums:0.0.1"
+ - key:
+ name: APEXacElementPolicy_Events
+ version: 0.0.1
+ value:
+ key:
+ name: APEXacElementPolicy_Events
+ version: 0.0.1
+ UUID: 8508cd65-8dd2-342d-a5c6-1570810dbe2b
+ description: Generated description for concept referred to by
+ key "APEXacElementPolicy_Events:0.0.1"
+ - key:
+ name: APEXacElementPolicy_KeyInfo
+ version: 0.0.1
+ value:
+ key:
+ name: APEXacElementPolicy_KeyInfo
+ version: 0.0.1
+ UUID: 09e6927d-c5ac-3779-919f-9333994eed22
+ description: Generated description for concept referred to by
+ key "APEXacElementPolicy_KeyInfo:0.0.1"
+ - key:
+ name: APEXacElementPolicy_Policies
+ version: 0.0.1
+ value:
+ key:
+ name: APEXacElementPolicy_Policies
+ version: 0.0.1
+ UUID: cade3c9a-1600-3642-a6f4-315612187f46
+ description: Generated description for concept referred to by
+ key "APEXacElementPolicy_Policies:0.0.1"
+ - key:
+ name: APEXacElementPolicy_Schemas
+ version: 0.0.1
+ value:
+ key:
+ name: APEXacElementPolicy_Schemas
+ version: 0.0.1
+ UUID: 5bb4a8e9-35fa-37db-9a49-48ef036a7ba9
+ description: Generated description for concept referred to by
+ key "APEXacElementPolicy_Schemas:0.0.1"
+ - key:
+ name: APEXacElementPolicy_Tasks
+ version: 0.0.1
+ value:
+ key:
+ name: APEXacElementPolicy_Tasks
+ version: 0.0.1
+ UUID: 2527eeec-0d1f-3094-ad3f-212622b12836
+ description: Generated description for concept referred to by
+ key "APEXacElementPolicy_Tasks:0.0.1"
+ - key:
+ name: AcElementEvent
+ version: 0.0.1
+ value:
+ key:
+ name: AcElementEvent
+ version: 0.0.1
+ UUID: 32c013e2-2740-3986-a626-cbdf665b63e9
+ description: Generated description for concept referred to by
+ key "AcElementEvent:0.0.1"
+ - key:
+ name: KafkaResponseStatusEvent
+ version: 0.0.1
+ value:
+ key:
+ name: KafkaResponseStatusEvent
+ version: 0.0.1
+ UUID: 2715cb6c-2778-3461-8b69-871e79f95935
+ description: Generated description for concept referred to by
+ key "KafkaResponseStatusEvent:0.0.1"
+ - key:
+ name: ForwardPayloadTask
+ version: 0.0.1
+ value:
+ key:
+ name: ForwardPayloadTask
+ version: 0.0.1
+ UUID: 51defa03-1ecf-3314-bf34-2a652bce57fa
+ description: Generated description for concept referred to by
+ key "ForwardPayloadTask:0.0.1"
+ - key:
+ name: LogEvent
+ version: 0.0.1
+ value:
+ key:
+ name: LogEvent
+ version: 0.0.1
+ UUID: c540f048-96af-35e3-a36e-e9c29377cba7
+ description: Generated description for concept referred to by
+ key "LogEvent:0.0.1"
+ - key:
+ name: ReceiveEventPolicy
+ version: 0.0.1
+ value:
+ key:
+ name: ReceiveEventPolicy
+ version: 0.0.1
+ UUID: 568b7345-9de1-36d3-b6a3-9b857e6809a1
+ description: Generated description for concept referred to by
+ key "ReceiveEventPolicy:0.0.1"
+ - key:
+ name: SimpleIntType
+ version: 0.0.1
+ value:
+ key:
+ name: SimpleIntType
+ version: 0.0.1
+ UUID: 153791fd-ae0a-36a7-88a5-309a7936415d
+ description: Generated description for concept referred to by
+ key "SimpleIntType:0.0.1"
+ - key:
+ name: SimpleStringType
+ version: 0.0.1
+ value:
+ key:
+ name: SimpleStringType
+ version: 0.0.1
+ UUID: 8a4957cf-9493-3a76-8c22-a208e23259af
+ description: Generated description for concept referred to by
+ key "SimpleStringType:0.0.1"
+ - key:
+ name: UUIDType
+ version: 0.0.1
+ value:
+ key:
+ name: UUIDType
+ version: 0.0.1
+ UUID: 6a8cc68e-dfc8-3403-9c6d-071c886b319c
+ description: Generated description for concept referred to by
+ key "UUIDType:0.0.1"
+ eventInputParameters:
+ KafkaConsumer:
+ carrierTechnologyParameters:
+ carrierTechnology: KAFKA
+ parameterClassName: org.onap.policy.apex.plugins.event.carrier.kafka.KafkaCarrierTechnologyParameters
+ parameters:
+ bootstrapServers: kafka:9092
+ groupId: apex-group-id
+ enableAutoCommit: true
+ autoCommitTime: 1000
+ sessionTimeout: 30000
+ consumerPollTime: 100
+ consumerTopicList:
+ - ac_element_msg
+ keyDeserializer: org.apache.kafka.common.serialization.StringDeserializer
+ valueDeserializer: org.apache.kafka.common.serialization.StringDeserializer
+ eventProtocolParameters:
+ eventProtocol: JSON
+ parameters:
+ pojoField: KafkaResponseEvent
+ eventName: AcElementEvent
+ eventNameFilter: AcElementEvent
+ eventOutputParameters:
+ logOutputter:
+ carrierTechnologyParameters:
+ carrierTechnology: FILE
+ parameters:
+ fileName: outputevents.log
+ eventProtocolParameters:
+ eventProtocol: JSON
+ KafkaReplyProducer:
+ carrierTechnologyParameters:
+ carrierTechnology: KAFKA
+ parameterClassName: org.onap.policy.apex.plugins.event.carrier.kafka.KafkaCarrierTechnologyParameters
+ parameters:
+ bootstrapServers: kafka:9092
+ acks: all
+ retries: 0
+ batchSize: 16384
+ lingerTime: 1
+ bufferMemory: 33554432
+ producerTopic: policy_update_msg
+ keySerializer: org.apache.kafka.common.serialization.StringSerializer
+ valueSerializer: org.apache.kafka.common.serialization.StringSerializer
+ eventProtocolParameters:
+ eventProtocol: JSON
+ parameters:
+ pojoField: KafkaResponseStatusEvent
+ eventNameFilter: (LogEvent|KafkaResponseStatusEvent)
+ name: onap.policies.native.apex.ac.element
+ version: 1.0.0
+
709c62b3-8918-41b9-a747-d21eb79c6c21:
id: 709c62b3-8918-41b9-a747-d21eb79c6c21
@@ -49,8 +846,8 @@ elements:
releaseName: acm-starter
podName: acm-starter
repository:
- repoName: chartmuseum
- address: 'http://cluster-ip:8080'
+ repoName: policy-chartmuseum
+ address: 'http://policy-chartmuseum:8080'
overrideParams:
acelement.elementId.name: onap.policy.clamp.ac.starter
service.nodeport: 30800
@@ -70,8 +867,8 @@ elements:
releaseName: acm-bridge
podName: acm-bridge
repository:
- repoName: chartmuseum
- address: 'http://cluster-ip:8080'
+ repoName: policy-chartmuseum
+ address: 'http://policy-chartmuseum:8080'
overrideParams:
acelement.elementId.name: onap.policy.clamp.ac.bridge
service.nodeport: 30801
@@ -91,8 +888,8 @@ elements:
releaseName: acm-sink
podName: acm-sink
repository:
- repoName: chartmuseum
- address: 'http://cluster-ip:8080'
+ repoName: policy-chartmuseum
+ address: 'http://policy-chartmuseum:8080'
overrideParams:
acelement.elementId.name: onap.policy.clamp.ac.sink
service.nodeport: 30802
@@ -104,7 +901,7 @@ elements:
version: 1.2.3
description: Starter Automation Composition Element for the Demo
properties:
- baseUrl: http://cluster-ip:30800
+ baseUrl: http://{{address}}:30800
httpHeaders:
Content-Type: application/json
Authorization: Basic YWNtVXNlcjp6YiFYenRHMzQ=
@@ -118,7 +915,7 @@ elements:
version: 1.0.1
httpMethod: POST
path: /onap/policy/clamp/acelement/v2/activate
- body: '{ "receiverId": { "name": "onap.policy.clamp.ac.startertobridge", "version": "1.0.0" }, "timerMs": 20000, "elementType": "STARTER", "topicParameterGroup": { "server": "message-router:3904", "listenerTopic": "POLICY_UPDATE_MSG", "publisherTopic": "AC_ELEMENT_MSG", "fetchTimeout": 15000, "topicCommInfrastructure": "dmaap" } }'
+ body: '{ "receiverId": { "name": "onap.policy.clamp.ac.startertobridge", "version": "1.0.0" }, "timerMs": 20000, "elementType": "STARTER", "topicParameterGroup": { "server": "kafka:9092", "listenerTopic": "policy_update_msg", "publisherTopic": "ac_element_msg", "fetchTimeout": 15000, "topicCommInfrastructure": "kafka" } }'
expectedResponse: 201
709c62b3-8918-41b9-a747-d21eb79c6c25:
@@ -128,7 +925,7 @@ elements:
version: 1.2.3
description: Bridge Automation Composition Element for the Demo
properties:
- baseUrl: http://cluster-ip:30801
+ baseUrl: http://{{address}}:30801
httpHeaders:
Content-Type: application/json
Authorization: Basic YWNtVXNlcjp6YiFYenRHMzQ=
@@ -142,7 +939,7 @@ elements:
version: 1.0.1
httpMethod: POST
path: /onap/policy/clamp/acelement/v2/activate
- body: '{ "receiverId": { "name": "onap.policy.clamp.ac.bridgetosink", "version": "1.0.0" }, "timerMs": 20000, "elementType": "BRIDGE", "topicParameterGroup": { "server": "message-router:3904", "listenerTopic": "POLICY_UPDATE_MSG", "publisherTopic": "AC_ELEMENT_MSG", "fetchTimeout": 15000, "topicCommInfrastructure": "dmaap" } }'
+ body: '{ "receiverId": { "name": "onap.policy.clamp.ac.bridgetosink", "version": "1.0.0" }, "timerMs": 20000, "elementType": "BRIDGE", "topicParameterGroup": { "server": "kafka:9092", "listenerTopic": "policy_update_msg", "publisherTopic": "ac_element_msg", "fetchTimeout": 15000, "topicCommInfrastructure": "kafka" } }'
expectedResponse: 201
709c62b3-8918-41b9-a747-d21eb79c6c26:
@@ -152,7 +949,7 @@ elements:
version: 1.2.3
description: Sink Automation Composition Element for the Demo
properties:
- baseUrl: http://cluster-ip:30802
+ baseUrl: http://{{address}}:30802
httpHeaders:
Content-Type: application/json
Authorization: Basic YWNtVXNlcjp6YiFYenRHMzQ=
@@ -166,6 +963,5 @@ elements:
version: 1.0.1
httpMethod: POST
path: /onap/policy/clamp/acelement/v2/activate
- body: '{ "receiverId": { "name": "onap.policy.clamp.ac.sink", "version": "1.0.0" }, "timerMs": 20000, "elementType": "SINK", "topicParameterGroup": { "server": "message-router", "listenerTopic": "POLICY_UPDATE_MSG", "publisherTopic": "AC_ELEMENT_MSG", "fetchTimeout": 15000, "topicCommInfrastructure": "dmaap" } }'
+ body: '{ "receiverId": { "name": "onap.policy.clamp.ac.sink", "version": "1.0.0" }, "timerMs": 20000, "elementType": "SINK", "topicParameterGroup": { "server": "kafka:9092", "listenerTopic": "policy_update_msg", "publisherTopic": "ac_element_msg", "fetchTimeout": 15000, "topicCommInfrastructure": "kafka" } }'
expectedResponse: 201
-
diff --git a/examples/src/main/resources/clamp/acm/acm-demo/toscaServiceTemplate.yaml b/examples/src/main/resources/clamp/acm/acm-demo/toscaServiceTemplate.yaml
index bd8bcf89d..56ac186c7 100644
--- a/examples/src/main/resources/clamp/acm/acm-demo/toscaServiceTemplate.yaml
+++ b/examples/src/main/resources/clamp/acm/acm-demo/toscaServiceTemplate.yaml
@@ -1,5 +1,5 @@
# ============LICENSE_START=======================================================
-# Copyright (C) 2023 Nordix Foundation.
+# Copyright (C) 2023-2024 Nordix Foundation.
# ================================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -16,6 +16,8 @@
# SPDX-License-Identifier: Apache-2.0
# ============LICENSE_END=========================================================
tosca_definitions_version: tosca_simple_yaml_1_3
+name: ACM_Oslo
+version: 1.0.0
data_types:
onap.datatypes.ToscaConceptIdentifier:
derived_from: tosca.datatypes.Root
@@ -27,176 +29,6 @@ data_types:
type: string
required: true
- onap.datatypes.native.apex.EngineService:
- derived_from: tosca.datatypes.Root
- properties:
- name:
- type: string
- description: Specifies the engine name
- required: false
- default: "ApexEngineService"
- version:
- type: string
- description: Specifies the engine version in double dotted format
- required: false
- default: "1.0.0"
- id:
- type: integer
- description: Specifies the engine id
- required: true
- instance_count:
- type: integer
- description: Specifies the number of engine threads that should be run
- required: true
- deployment_port:
- type: integer
- description: Specifies the port to connect to for engine administration
- required: false
- default: 1
- policy_model_file_name:
- type: string
- description: The name of the file from which to read the APEX policy model
- required: false
- policy_type_impl:
- type: string
- description: The policy type implementation from which to read the APEX policy model
- required: false
- periodic_event_period:
- type: string
- description: The time interval in milliseconds for the periodic scanning event, 0 means don't scan
- required: false
- engine:
- type: onap.datatypes.native.apex.engineservice.Engine
- description: The parameters for all engines in the APEX engine service
- required: true
- onap.datatypes.native.apex.EventHandler:
- derived_from: tosca.datatypes.Root
- properties:
- name:
- type: string
- description: Specifies the event handler name, if not specified this is set to the key name
- required: false
- carrier_technology:
- type: onap.datatypes.native.apex.CarrierTechnology
- description: Specifies the carrier technology of the event handler (such as REST/Web Socket/Kafka)
- required: true
- event_protocol:
- type: onap.datatypes.native.apex.EventProtocol
- description: Specifies the event protocol of events for the event handler (such as Yaml/JSON/XML/POJO)
- required: true
- event_name:
- type: string
- description: Specifies the event name for events on this event handler, if not specified, the event name is read from or written to the event being received or sent
- required: false
- event_name_filter:
- type: string
- description: Specifies a filter as a regular expression, events that do not match the filter are dropped, the default is to let all events through
- required: false
- synchronous_mode:
- type: boolean
- description: Specifies the event handler is syncronous (receive event and send response)
- required: false
- default: false
- synchronous_peer:
- type: string
- description: The peer event handler (output for input or input for output) of this event handler in synchronous mode, this parameter is mandatory if the event handler is in synchronous mode
- required: false
- synchronous_timeout:
- type: integer
- description: The timeout in milliseconds for responses to be issued by APEX torequests, this parameter is mandatory if the event handler is in synchronous mode
- required: false
- requestor_mode:
- type: boolean
- description: Specifies the event handler is in requestor mode (send event and wait for response mode)
- required: false
- default: false
- requestor_peer:
- type: string
- description: The peer event handler (output for input or input for output) of this event handler in requestor mode, this parameter is mandatory if the event handler is in requestor mode
- required: false
- requestor_timeout:
- type: integer
- description: The timeout in milliseconds for wait for responses to requests, this parameter is mandatory if the event handler is in requestor mode
- required: false
- onap.datatypes.native.apex.CarrierTechnology:
- derived_from: tosca.datatypes.Root
- properties:
- label:
- type: string
- description: The label (name) of the carrier technology (such as REST, Kafka, WebSocket)
- required: true
- plugin_parameter_class_name:
- type: string
- description: The class name of the class that overrides default handling of event input or output for this carrier technology, defaults to the supplied input or output class
- required: false
- onap.datatypes.native.apex.EventProtocol:
- derived_from: tosca.datatypes.Root
- properties:
- label:
- type: string
- description: The label (name) of the event protocol (such as Yaml, JSON, XML, or POJO)
- required: true
- event_protocol_plugin_class:
- type: string
- description: The class name of the class that overrides default handling of the event protocol for this carrier technology, defaults to the supplied event protocol class
- required: false
- onap.datatypes.native.apex.Environment:
- derived_from: tosca.datatypes.Root
- properties:
- name:
- type: string
- description: The name of the environment variable
- required: true
- value:
- type: string
- description: The value of the environment variable
- required: true
- onap.datatypes.native.apex.engineservice.Engine:
- derived_from: tosca.datatypes.Root
- properties:
- context:
- type: onap.datatypes.native.apex.engineservice.engine.Context
- description: The properties for handling context in APEX engines, defaults to using Java maps for context
- required: false
- executors:
- type: map
- description: The plugins for policy executors used in engines such as javascript, MVEL, Jython
- required: true
- entry_schema:
- description: The plugin class path for this policy executor
- type: string
- onap.datatypes.native.apex.engineservice.engine.Context:
- derived_from: tosca.datatypes.Root
- properties:
- distributor:
- type: onap.datatypes.native.apex.Plugin
- description: The plugin to be used for distributing context between APEX PDPs at runtime
- required: false
- schemas:
- type: map
- description: The plugins for context schemas available in APEX PDPs such as Java and Avro
- required: false
- entry_schema:
- type: onap.datatypes.native.apex.Plugin
- locking:
- type: onap.datatypes.native.apex.Plugin
- description: The plugin to be used for locking context in and between APEX PDPs at runtime
- required: false
- persistence:
- type: onap.datatypes.native.apex.Plugin
- description: The plugin to be used for persisting context for APEX PDPs at runtime
- required: false
- onap.datatypes.native.apex.Plugin:
- derived_from: tosca.datatypes.Root
- properties:
- name:
- type: string
- description: The name of the executor such as Javascript, Jython or MVEL
- required: true
- plugin_class_name:
- type: string
- description: The class path of the plugin class for this executor
-
org.onap.datatypes.policy.clamp.acm.httpAutomationCompositionElement.RestRequest:
version: 1.0.0
derived_from: tosca.datatypes.Root
@@ -244,37 +76,6 @@ data_types:
type_version: 1.0.0
description: A sequence of REST commands to send to the REST endpoint
-policy_types:
- onap.policies.Native:
- derived_from: tosca.policies.Root
- description: a base policy type for all native PDP policies
- version: 1.0.0
- name: onap.policies.Native
- onap.policies.native.Apex:
- derived_from: onap.policies.Native
- description: a policy type for native apex policies
- version: 1.0.0
- name: onap.policies.native.Apex
- properties:
- engine_service:
- type: onap.datatypes.native.apex.EngineService
- description: APEX Engine Service Parameters
- inputs:
- type: map
- description: Inputs for handling events coming into the APEX engine
- entry_schema:
- type: onap.datatypes.native.apex.EventHandler
- outputs:
- type: map
- description: Outputs for handling events going out of the APEX engine
- entry_schema:
- type: onap.datatypes.native.apex.EventHandler
- environment:
- type: list
- description: Envioronmental parameters for the APEX engine
- entry_schema:
- type: onap.datatypes.native.apex.Environment
-
node_types:
org.onap.policy.clamp.acm.Participant:
version: 1.0.1
@@ -410,6 +211,7 @@ node_types:
type_version: 1.0.0
description: The connfiguration entities the Automation Composition Element is managing and their associated REST requests
+
topology_template:
inputs:
acm_element_policy:
@@ -536,582 +338,3 @@ topology_template:
version: 1.2.3
- name: onap.policy.clamp.ac.element.Http_SinkAutomationCompositionElement
version: 1.2.3
-
- policies:
- - onap.policies.native.apex.ac.element:
- type: onap.policies.native.Apex
- type_version: 1.0.0
- properties:
- engineServiceParameters:
- name: MyApexEngine
- version: 0.0.1
- id: 45
- instanceCount: 2
- deploymentPort: 12561
- engineParameters:
- executorParameters:
- JAVASCRIPT:
- parameterClassName: org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters
- contextParameters:
- parameterClassName: org.onap.policy.apex.context.parameters.ContextParameters
- schemaParameters:
- Json:
- parameterClassName: org.onap.policy.apex.plugins.context.schema.json.JsonSchemaHelperParameters
- policy_type_impl:
- policies:
- key:
- name: APEXacElementPolicy_Policies
- version: 0.0.1
- policyMap:
- entry:
- - key:
- name: ReceiveEventPolicy
- version: 0.0.1
- value:
- policyKey:
- name: ReceiveEventPolicy
- version: 0.0.1
- template: Freestyle
- state:
- entry:
- - key: DecideForwardingState
- value:
- stateKey:
- parentKeyName: ReceiveEventPolicy
- parentKeyVersion: 0.0.1
- parentLocalName: 'NULL'
- localName: DecideForwardingState
- trigger:
- name: AcElementEvent
- version: 0.0.1
- stateOutputs:
- entry:
- - key: CreateForwardPayload
- value:
- key:
- parentKeyName: ReceiveEventPolicy
- parentKeyVersion: 0.0.1
- parentLocalName: DecideForwardingState
- localName: CreateForwardPayload
- outgoingEvent:
- name: DmaapResponseStatusEvent
- version: 0.0.1
- outgoingEventReference:
- - name: DmaapResponseStatusEvent
- version: 0.0.1
- nextState:
- parentKeyName: 'NULL'
- parentKeyVersion: 0.0.0
- parentLocalName: 'NULL'
- localName: 'NULL'
- contextAlbumReference: []
- taskSelectionLogic:
- key:
- parentKeyName: 'NULL'
- parentKeyVersion: 0.0.0
- parentLocalName: 'NULL'
- localName: 'NULL'
- logicFlavour: UNDEFINED
- logic: ''
- stateFinalizerLogicMap:
- entry: []
- defaultTask:
- name: ForwardPayloadTask
- version: 0.0.1
- taskReferences:
- entry:
- - key:
- name: ForwardPayloadTask
- version: 0.0.1
- value:
- key:
- parentKeyName: ReceiveEventPolicy
- parentKeyVersion: 0.0.1
- parentLocalName: DecideForwardingState
- localName: ReceiveEventPolicy
- outputType: DIRECT
- output:
- parentKeyName: ReceiveEventPolicy
- parentKeyVersion: 0.0.1
- parentLocalName: DecideForwardingState
- localName: CreateForwardPayload
- firstState: DecideForwardingState
- tasks:
- key:
- name: APEXacElementPolicy_Tasks
- version: 0.0.1
- taskMap:
- entry:
- - key:
- name: ForwardPayloadTask
- version: 0.0.1
- value:
- key:
- name: ForwardPayloadTask
- version: 0.0.1
- inputEvent:
- key:
- name: AcElementEvent
- version: 0.0.1
- nameSpace: org.onap.policy.apex.ac.element
- source: Dmaap
- target: APEX
- parameter:
- entry:
- - key: DmaapResponseEvent
- value:
- key:
- parentKeyName: AcElementEvent
- parentKeyVersion: 0.0.1
- parentLocalName: 'NULL'
- localName: DmaapResponseEvent
- fieldSchemaKey:
- name: ACEventType
- version: 0.0.1
- optional: false
- toscaPolicyState: ENTRY
- outputEvents:
- entry:
- - key: DmaapResponseStatusEvent
- value:
- key:
- name: DmaapResponseStatusEvent
- version: 0.0.1
- nameSpace: org.onap.policy.apex.ac.element
- source: APEX
- target: Dmaap
- parameter:
- entry:
- - key: DmaapResponseStatusEvent
- value:
- key:
- parentKeyName: DmaapResponseStatusEvent
- parentKeyVersion: 0.0.1
- parentLocalName: 'NULL'
- localName: DmaapResponseStatusEvent
- fieldSchemaKey:
- name: ACEventType
- version: 0.0.1
- optional: false
- toscaPolicyState: ''
- taskParameters:
- entry: []
- contextAlbumReference:
- - name: ACElementAlbum
- version: 0.0.1
- taskLogic:
- key:
- parentKeyName: ForwardPayloadTask
- parentKeyVersion: 0.0.1
- parentLocalName: 'NULL'
- localName: TaskLogic
- logicFlavour: JAVASCRIPT
- logic: "/*\n * ============LICENSE_START=======================================================\n\
- \ * Copyright (C) 2022 Nordix. All rights reserved.\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\
- \ */\n\nexecutor.logger.info(executor.subject.id);\nexecutor.logger.info(executor.inFields);\n\
- \nvar msgResponse = executor.inFields.get('DmaapResponseEvent');\n\
- executor.logger.info('Task in progress with mesages: ' + msgResponse);\n\
- \nvar elementId = msgResponse.get('elementId').get('name');\n\
- \nif (msgResponse.get('messageType') == 'STATUS' &&\n (elementId\
- \ == 'onap.policy.clamp.ac.startertobridge'\n || elementId\
- \ == 'onap.policy.clamp.ac.bridgetosink')) {\n\n var receiverId\
- \ = '';\n if (elementId == 'onap.policy.clamp.ac.startertobridge')\
- \ {\n receiverId = 'onap.policy.clamp.ac.bridge';\n\
- \ } else {\n receiverId = 'onap.policy.clamp.ac.sink';\n\
- \ }\n\n var elementIdResponse = new java.util.HashMap();\n\
- \ elementIdResponse.put('name', receiverId);\n elementIdResponse.put('version',\
- \ msgResponse.get('elementId').get('version'));\n\n var\
- \ dmaapResponse = new java.util.HashMap();\n dmaapResponse.put('elementId',\
- \ elementIdResponse);\n\n var message = msgResponse.get('message')\
- \ + ' trace added from policy';\n dmaapResponse.put('message',\
- \ message);\n dmaapResponse.put('messageType', 'STATUS');\n\
- \ dmaapResponse.put('messageId', msgResponse.get('messageId'));\n\
- \ dmaapResponse.put('timestamp', msgResponse.get('timestamp'));\n\
- \n executor.logger.info('Sending forwarding Event to Ac\
- \ element: ' + dmaapResponse);\n\n executor.outFields.put('DmaapResponseStatusEvent',\
- \ dmaapResponse);\n}\n\ntrue;"
- events:
- key:
- name: APEXacElementPolicy_Events
- version: 0.0.1
- eventMap:
- entry:
- - key:
- name: AcElementEvent
- version: 0.0.1
- value:
- key:
- name: AcElementEvent
- version: 0.0.1
- nameSpace: org.onap.policy.apex.ac.element
- source: Dmaap
- target: APEX
- parameter:
- entry:
- - key: DmaapResponseEvent
- value:
- key:
- parentKeyName: AcElementEvent
- parentKeyVersion: 0.0.1
- parentLocalName: 'NULL'
- localName: DmaapResponseEvent
- fieldSchemaKey:
- name: ACEventType
- version: 0.0.1
- optional: false
- toscaPolicyState: ENTRY
- - key:
- name: DmaapResponseStatusEvent
- version: 0.0.1
- value:
- key:
- name: DmaapResponseStatusEvent
- version: 0.0.1
- nameSpace: org.onap.policy.apex.ac.element
- source: APEX
- target: Dmaap
- parameter:
- entry:
- - key: DmaapResponseStatusEvent
- value:
- key:
- parentKeyName: DmaapResponseStatusEvent
- parentKeyVersion: 0.0.1
- parentLocalName: 'NULL'
- localName: DmaapResponseStatusEvent
- fieldSchemaKey:
- name: ACEventType
- version: 0.0.1
- optional: false
- toscaPolicyState: ''
- - key:
- name: LogEvent
- version: 0.0.1
- value:
- key:
- name: LogEvent
- version: 0.0.1
- nameSpace: org.onap.policy.apex.ac.element
- source: APEX
- target: file
- parameter:
- entry:
- - key: final_status
- value:
- key:
- parentKeyName: LogEvent
- parentKeyVersion: 0.0.1
- parentLocalName: 'NULL'
- localName: final_status
- fieldSchemaKey:
- name: SimpleStringType
- version: 0.0.1
- optional: false
- - key: message
- value:
- key:
- parentKeyName: LogEvent
- parentKeyVersion: 0.0.1
- parentLocalName: 'NULL'
- localName: message
- fieldSchemaKey:
- name: SimpleStringType
- version: 0.0.1
- optional: false
- toscaPolicyState: ''
- albums:
- key:
- name: APEXacElementPolicy_Albums
- version: 0.0.1
- albums:
- entry:
- - key:
- name: ACElementAlbum
- version: 0.0.1
- value:
- key:
- name: ACElementAlbum
- version: 0.0.1
- scope: policy
- isWritable: true
- itemSchema:
- name: ACEventType
- version: 0.0.1
- schemas:
- key:
- name: APEXacElementPolicy_Schemas
- version: 0.0.1
- schemas:
- entry:
- - key:
- name: ACEventType
- version: 0.0.1
- value:
- key:
- name: ACEventType
- version: 0.0.1
- schemaFlavour: Json
- schemaDefinition: "{\n \"$schema\": \"http://json-schema.org/draft-04/schema#\"\
- ,\n \"type\": \"object\",\n \"properties\": {\n \
- \ \"elementId\": {\n \"type\": \"object\",\n \
- \ \"properties\": {\n \"name\": {\n \
- \ \"type\": \"string\"\n },\n\
- \ \"version\": {\n \"type\"\
- : \"string\"\n }\n },\n \
- \ \"required\": [\n \"name\",\n \
- \ \"version\"\n ]\n },\n \"message\"\
- : {\n \"type\": \"string\"\n },\n \"\
- messageType\": {\n \"type\": \"string\"\n \
- \ }\n },\n \"required\": [\n \"elementId\",\n \
- \ \"message\",\n \"messageType\"\n ]\n}"
- - key:
- name: SimpleIntType
- version: 0.0.1
- value:
- key:
- name: SimpleIntType
- version: 0.0.1
- schemaFlavour: Java
- schemaDefinition: java.lang.Integer
- - key:
- name: SimpleStringType
- version: 0.0.1
- value:
- key:
- name: SimpleStringType
- version: 0.0.1
- schemaFlavour: Java
- schemaDefinition: java.lang.String
- - key:
- name: UUIDType
- version: 0.0.1
- value:
- key:
- name: UUIDType
- version: 0.0.1
- schemaFlavour: Java
- schemaDefinition: java.util.UUID
- key:
- name: APEXacElementPolicy
- version: 0.0.1
- keyInformation:
- key:
- name: APEXacElementPolicy_KeyInfo
- version: 0.0.1
- keyInfoMap:
- entry:
- - key:
- name: ACElementAlbum
- version: 0.0.1
- value:
- key:
- name: ACElementAlbum
- version: 0.0.1
- UUID: 7cddfab8-6d3f-3f7f-8ac3-e2eb5979c900
- description: Generated description for concept referred to by
- key "ACElementAlbum:0.0.1"
- - key:
- name: ACEventType
- version: 0.0.1
- value:
- key:
- name: ACEventType
- version: 0.0.1
- UUID: dab78794-b666-3929-a75b-70d634b04fe5
- description: Generated description for concept referred to by
- key "ACEventType:0.0.1"
- - key:
- name: APEXacElementPolicy
- version: 0.0.1
- value:
- key:
- name: APEXacElementPolicy
- version: 0.0.1
- UUID: da478611-7d77-3c46-b4be-be968769ba4e
- description: Generated description for concept referred to by
- key "APEXacElementPolicy:0.0.1"
- - key:
- name: APEXacElementPolicy_Albums
- version: 0.0.1
- value:
- key:
- name: APEXacElementPolicy_Albums
- version: 0.0.1
- UUID: fa8dc15e-8c8d-3de3-a0f8-585b76511175
- description: Generated description for concept referred to by
- key "APEXacElementPolicy_Albums:0.0.1"
- - key:
- name: APEXacElementPolicy_Events
- version: 0.0.1
- value:
- key:
- name: APEXacElementPolicy_Events
- version: 0.0.1
- UUID: 8508cd65-8dd2-342d-a5c6-1570810dbe2b
- description: Generated description for concept referred to by
- key "APEXacElementPolicy_Events:0.0.1"
- - key:
- name: APEXacElementPolicy_KeyInfo
- version: 0.0.1
- value:
- key:
- name: APEXacElementPolicy_KeyInfo
- version: 0.0.1
- UUID: 09e6927d-c5ac-3779-919f-9333994eed22
- description: Generated description for concept referred to by
- key "APEXacElementPolicy_KeyInfo:0.0.1"
- - key:
- name: APEXacElementPolicy_Policies
- version: 0.0.1
- value:
- key:
- name: APEXacElementPolicy_Policies
- version: 0.0.1
- UUID: cade3c9a-1600-3642-a6f4-315612187f46
- description: Generated description for concept referred to by
- key "APEXacElementPolicy_Policies:0.0.1"
- - key:
- name: APEXacElementPolicy_Schemas
- version: 0.0.1
- value:
- key:
- name: APEXacElementPolicy_Schemas
- version: 0.0.1
- UUID: 5bb4a8e9-35fa-37db-9a49-48ef036a7ba9
- description: Generated description for concept referred to by
- key "APEXacElementPolicy_Schemas:0.0.1"
- - key:
- name: APEXacElementPolicy_Tasks
- version: 0.0.1
- value:
- key:
- name: APEXacElementPolicy_Tasks
- version: 0.0.1
- UUID: 2527eeec-0d1f-3094-ad3f-212622b12836
- description: Generated description for concept referred to by
- key "APEXacElementPolicy_Tasks:0.0.1"
- - key:
- name: AcElementEvent
- version: 0.0.1
- value:
- key:
- name: AcElementEvent
- version: 0.0.1
- UUID: 32c013e2-2740-3986-a626-cbdf665b63e9
- description: Generated description for concept referred to by
- key "AcElementEvent:0.0.1"
- - key:
- name: DmaapResponseStatusEvent
- version: 0.0.1
- value:
- key:
- name: DmaapResponseStatusEvent
- version: 0.0.1
- UUID: 2715cb6c-2778-3461-8b69-871e79f95935
- description: Generated description for concept referred to by
- key "DmaapResponseStatusEvent:0.0.1"
- - key:
- name: ForwardPayloadTask
- version: 0.0.1
- value:
- key:
- name: ForwardPayloadTask
- version: 0.0.1
- UUID: 51defa03-1ecf-3314-bf34-2a652bce57fa
- description: Generated description for concept referred to by
- key "ForwardPayloadTask:0.0.1"
- - key:
- name: LogEvent
- version: 0.0.1
- value:
- key:
- name: LogEvent
- version: 0.0.1
- UUID: c540f048-96af-35e3-a36e-e9c29377cba7
- description: Generated description for concept referred to by
- key "LogEvent:0.0.1"
- - key:
- name: ReceiveEventPolicy
- version: 0.0.1
- value:
- key:
- name: ReceiveEventPolicy
- version: 0.0.1
- UUID: 568b7345-9de1-36d3-b6a3-9b857e6809a1
- description: Generated description for concept referred to by
- key "ReceiveEventPolicy:0.0.1"
- - key:
- name: SimpleIntType
- version: 0.0.1
- value:
- key:
- name: SimpleIntType
- version: 0.0.1
- UUID: 153791fd-ae0a-36a7-88a5-309a7936415d
- description: Generated description for concept referred to by
- key "SimpleIntType:0.0.1"
- - key:
- name: SimpleStringType
- version: 0.0.1
- value:
- key:
- name: SimpleStringType
- version: 0.0.1
- UUID: 8a4957cf-9493-3a76-8c22-a208e23259af
- description: Generated description for concept referred to by
- key "SimpleStringType:0.0.1"
- - key:
- name: UUIDType
- version: 0.0.1
- value:
- key:
- name: UUIDType
- version: 0.0.1
- UUID: 6a8cc68e-dfc8-3403-9c6d-071c886b319c
- description: Generated description for concept referred to by
- key "UUIDType:0.0.1"
- eventInputParameters:
- DmaapConsumer:
- carrierTechnologyParameters:
- carrierTechnology: RESTCLIENT
- parameterClassName: org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters
- parameters:
- url: http://message-router:3904/events/AC_ELEMENT_MSG/APEX/1?timeout=30000
- eventProtocolParameters:
- eventProtocol: JSON
- parameters:
- pojoField: DmaapResponseEvent
- eventName: AcElementEvent
- eventNameFilter: AcElementEvent
- eventOutputParameters:
- logOutputter:
- carrierTechnologyParameters:
- carrierTechnology: FILE
- parameters:
- fileName: outputevents.log
- eventProtocolParameters:
- eventProtocol: JSON
- DmaapReplyProducer:
- carrierTechnologyParameters:
- carrierTechnology: RESTCLIENT
- parameterClassName: org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters
- parameters:
- url: http://message-router:3904/events/POLICY_UPDATE_MSG
- eventProtocolParameters:
- eventProtocol: JSON
- parameters:
- pojoField: DmaapResponseStatusEvent
- eventNameFilter: (LogEvent|DmaapResponseStatusEvent)
- name: onap.policies.native.apex.ac.element
- version: 1.0.0
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementDeploy.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementDeploy.java
index 5408d3179..22f3cd830 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementDeploy.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementDeploy.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2023 Nordix Foundation.
+ * Copyright (C) 2023-2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -51,7 +51,8 @@ public class AcElementDeploy {
@NonNull
private DeployOrder orderedState = DeployOrder.DEPLOY;
- private ToscaServiceTemplate toscaServiceTemplateFragment;
+ // backward compatibility
+ private ToscaServiceTemplate toscaServiceTemplateFragment = new ToscaServiceTemplate();
// A map indexed by the property name. Each map entry is the serialized value of the property,
// which can be deserialized into an instance of the type of the property.
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementRestart.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementRestart.java
index 3d1b5df33..687a2cfb0 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementRestart.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementRestart.java
@@ -55,7 +55,8 @@ public class AcElementRestart {
private String operationalState;
private String useState;
- private ToscaServiceTemplate toscaServiceTemplateFragment;
+ // backward compatibility
+ private ToscaServiceTemplate toscaServiceTemplateFragment = new ToscaServiceTemplate();
// A map indexed by the property name. Each map entry is the serialized value of the property,
// which can be deserialized into an instance of the type of the property.
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java b/models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java
index 172de34fe..22985fb3b 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java
@@ -64,7 +64,6 @@ import org.onap.policy.models.base.PfUtils;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaTopologyTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -80,26 +79,6 @@ public final class AcmUtils {
private static final Logger LOGGER = LoggerFactory.getLogger(AcmUtils.class);
/**
- * Get the Policy information in the service template for the deploy message to participants.
- *
- * @param toscaServiceTemplate ToscaServiceTemplate
- */
- public static ToscaServiceTemplate getToscaServiceTemplateFragment(ToscaServiceTemplate toscaServiceTemplate) {
- // Pass respective PolicyTypes or Policies as part of toscaServiceTemplateFragment
- if (toscaServiceTemplate.getPolicyTypes() == null
- && toscaServiceTemplate.getToscaTopologyTemplate().getPolicies() == null) {
- return new ToscaServiceTemplate();
- }
- var toscaServiceTemplateFragment = new ToscaServiceTemplate();
- toscaServiceTemplateFragment.setPolicyTypes(toscaServiceTemplate.getPolicyTypes());
- var toscaTopologyTemplate = new ToscaTopologyTemplate();
- toscaTopologyTemplate.setPolicies(toscaServiceTemplate.getToscaTopologyTemplate().getPolicies());
- toscaServiceTemplateFragment.setToscaTopologyTemplate(toscaTopologyTemplate);
- toscaServiceTemplateFragment.setDataTypes(toscaServiceTemplate.getDataTypes());
- return toscaServiceTemplateFragment;
- }
-
- /**
* Checks if a NodeTemplate is an AutomationCompositionElement.
*
* @param nodeTemplate the ToscaNodeTemplate
@@ -466,11 +445,10 @@ public final class AcmUtils {
*
* @param automationComposition the AutomationComposition
* @param participantId the participantId of the participant restarted
- * @param serviceTemplateFragment the ToscaServiceTemplate with policies and policy types
* @return the ParticipantRestartAc
*/
public static ParticipantRestartAc createAcRestart(AutomationComposition automationComposition,
- UUID participantId, ToscaServiceTemplate serviceTemplateFragment) {
+ UUID participantId) {
var syncAc = new ParticipantRestartAc();
syncAc.setDeployState(automationComposition.getDeployState());
syncAc.setLockState(automationComposition.getLockState());
@@ -478,7 +456,6 @@ public final class AcmUtils {
for (var element : automationComposition.getElements().values()) {
if (participantId.equals(element.getParticipantId())) {
var acElementSync = createAcElementRestart(element);
- acElementSync.setToscaServiceTemplateFragment(serviceTemplateFragment);
syncAc.getAcElementList().add(acElementSync);
}
}
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java
index 97af64cf7..ce1a752b9 100644
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java
@@ -119,24 +119,6 @@ class AcmUtilsTest {
}
@Test
- void testCommonUtilsServiceTemplate() {
- var toscaServiceTemplate = getDummyToscaServiceTemplate();
- var toscaServiceTemplateFragment = AcmUtils.getToscaServiceTemplateFragment(toscaServiceTemplate);
- assertEquals(getDummyToscaDataTypeMap(), toscaServiceTemplateFragment.getDataTypes());
- }
-
- @Test
- void testSetServiceTemplatePolicyInfoWithNullInfo() {
- var toscaServiceTemplate = getDummyToscaServiceTemplate();
- toscaServiceTemplate.setPolicyTypes(null);
- toscaServiceTemplate.getToscaTopologyTemplate().setPolicies(null);
- var toscaServiceTemplateFragment = AcmUtils.getToscaServiceTemplateFragment(toscaServiceTemplate);
- assertNull(toscaServiceTemplateFragment.getPolicyTypes());
- assertNull(toscaServiceTemplateFragment.getToscaTopologyTemplate());
- assertNull(toscaServiceTemplateFragment.getDataTypes());
- }
-
- @Test
void testValidateAutomationComposition() {
var automationComposition = getDummyAutomationComposition();
var toscaServiceTemplate = getDummyToscaServiceTemplate();
@@ -312,10 +294,12 @@ class AcmUtilsTest {
void testcreateAcRestart() {
var automationComposition = getDummyAutomationComposition();
automationComposition.setInstanceId(UUID.randomUUID());
- var toscaServiceTemplate = getDummyToscaServiceTemplate();
- var participantId = automationComposition.getElements().values().iterator().next().getParticipantId();
- var serviceTemplateFragment = AcmUtils.getToscaServiceTemplateFragment(toscaServiceTemplate);
- var result = AcmUtils.createAcRestart(automationComposition, participantId, serviceTemplateFragment);
+ var element = automationComposition.getElements().values().iterator().next();
+ var secondElement = new AutomationCompositionElement(element);
+ secondElement.setParticipantId(UUID.randomUUID());
+ secondElement.setId(UUID.randomUUID());
+ automationComposition.getElements().put(secondElement.getId(), secondElement);
+ var result = AcmUtils.createAcRestart(automationComposition, element.getParticipantId());
assertEquals(result.getAutomationCompositionId(), automationComposition.getInstanceId());
assertThat(result.getAcElementList()).hasSize(1);
}
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/CommonTestData.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/CommonTestData.java
index 42939b813..ae7f98d8d 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/CommonTestData.java
+++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/CommonTestData.java
@@ -37,7 +37,6 @@ import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
public class CommonTestData {
@@ -199,11 +198,9 @@ public class CommonTestData {
* @return an InstanceElementDto
*/
public InstanceElementDto createInstanceElementDto(Map<String, Object> inProperties) {
- return new InstanceElementDto(getAutomationCompositionId(), UUID.randomUUID(),
- new ToscaServiceTemplate(), inProperties, new HashMap<>());
+ return new InstanceElementDto(getAutomationCompositionId(), UUID.randomUUID(), inProperties, new HashMap<>());
}
-
/**
* Create an compositionElementDto.
*
diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandler.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandler.java
index 5a3bc6328..5cf79acf8 100644
--- a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandler.java
+++ b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandler.java
@@ -36,6 +36,9 @@ import org.onap.policy.clamp.acm.participant.policy.client.PolicyApiHttpClient;
import org.onap.policy.clamp.acm.participant.policy.client.PolicyPapHttpClient;
import org.onap.policy.clamp.models.acm.concepts.DeployState;
import org.onap.policy.clamp.models.acm.concepts.StateChangeResult;
+import org.onap.policy.common.utils.coder.Coder;
+import org.onap.policy.common.utils.coder.CoderException;
+import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.pdp.concepts.DeploymentSubGroup;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
@@ -51,6 +54,7 @@ import org.springframework.stereotype.Component;
public class AutomationCompositionElementHandler extends AcElementListenerV2 {
private static final Logger LOGGER = LoggerFactory.getLogger(AutomationCompositionElementHandler.class);
+ private static final Coder CODER = new StandardCoder();
private final PolicyApiHttpClient apiHttpClient;
private final PolicyPapHttpClient papHttpClient;
@@ -79,7 +83,7 @@ public class AutomationCompositionElementHandler extends AcElementListenerV2 {
@Override
public void undeploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
throws PfModelException {
- var automationCompositionDefinition = instanceElement.toscaServiceTemplateFragment();
+ var automationCompositionDefinition = getToscaServiceTemplate(instanceElement.inProperties());
if (automationCompositionDefinition.getToscaTopologyTemplate() == null) {
LOGGER.debug("No policies to undeploy to {}", instanceElement.elementId());
intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(),
@@ -161,7 +165,7 @@ public class AutomationCompositionElementHandler extends AcElementListenerV2 {
var createPolicyTypeResp = HttpStatus.SC_OK;
var createPolicyResp = HttpStatus.SC_OK;
- var automationCompositionDefinition = instanceElement.toscaServiceTemplateFragment();
+ var automationCompositionDefinition = getToscaServiceTemplate(instanceElement.inProperties());
if (automationCompositionDefinition.getToscaTopologyTemplate() == null) {
intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(),
instanceElement.elementId(), DeployState.UNDEPLOYED, null, StateChangeResult.FAILED,
@@ -222,4 +226,12 @@ public class AutomationCompositionElementHandler extends AcElementListenerV2 {
return policyList;
}
+
+ private ToscaServiceTemplate getToscaServiceTemplate(Map<String, Object> properties) throws PfModelException {
+ try {
+ return CODER.convert(properties, ToscaServiceTemplate.class);
+ } catch (CoderException e) {
+ throw new PfModelException(Status.BAD_REQUEST, e.getMessage());
+ }
+ }
}
diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandlerTest.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandlerTest.java
index 39f35e6df..cc8bb0ac1 100644
--- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandlerTest.java
+++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandlerTest.java
@@ -22,6 +22,7 @@ package org.onap.policy.clamp.acm.participant.policy.main.handler;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.clearInvocations;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -38,6 +39,9 @@ import org.onap.policy.clamp.acm.participant.policy.client.PolicyApiHttpClient;
import org.onap.policy.clamp.acm.participant.policy.client.PolicyPapHttpClient;
import org.onap.policy.clamp.models.acm.concepts.DeployState;
import org.onap.policy.clamp.models.acm.concepts.StateChangeResult;
+import org.onap.policy.common.utils.coder.Coder;
+import org.onap.policy.common.utils.coder.CoderException;
+import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
@@ -47,6 +51,8 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaTopologyTemplate;
class AutomationCompositionElementHandlerTest {
+ private static final Coder CODER = new StandardCoder();
+
private static final ToscaConceptIdentifier DEFINITION =
new ToscaConceptIdentifier("1.0.1", "org.onap.PM_CDS_Blueprint");
@@ -74,7 +80,17 @@ class AutomationCompositionElementHandlerTest {
template.setToscaTopologyTemplate(new ToscaTopologyTemplate());
template.getToscaTopologyTemplate().setPolicies(List.of(Map.of("DummyPolicy", new ToscaPolicy())));
template.setPolicyTypes(Map.of("dummy policy type", new ToscaPolicyType()));
- return new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), template, Map.of(), Map.of());
+ var inProperties = getProperties(template);
+ return new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), inProperties, Map.of());
+ }
+
+ private Map<String, Object> getProperties(ToscaServiceTemplate template) {
+ try {
+ var json = CODER.encode(template);
+ return CODER.decode(json, Map.class);
+ } catch (CoderException e) {
+ throw new RuntimeException(e);
+ }
}
@Test
@@ -98,6 +114,7 @@ class AutomationCompositionElementHandlerTest {
instanceElement.elementId(), DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR,
"Deployed");
+ clearInvocations(intermediaryApi);
handler.undeploy(compositionElement, instanceElement);
verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
instanceElement.elementId(), DeployState.UNDEPLOYED, null, StateChangeResult.NO_ERROR,
@@ -116,12 +133,33 @@ class AutomationCompositionElementHandlerTest {
verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
instanceElement.elementId(), DeployState.UNDEPLOYED, null, StateChangeResult.FAILED,
"ToscaTopologyTemplate not defined");
+
+ clearInvocations(intermediaryApi);
+ instanceElement = getInstanceElementWithNoPolicy();
+ handler.deploy(compositionElement, instanceElement);
+ verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
+ instanceElement.elementId(), DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR,
+ "Deployed");
+
+ clearInvocations(intermediaryApi);
+ handler.undeploy(compositionElement, instanceElement);
+ verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
+ instanceElement.elementId(), DeployState.UNDEPLOYED, null, StateChangeResult.NO_ERROR,
+ "Undeployed");
}
private InstanceElementDto getInstanceElementWithNullTopology() {
var template = new ToscaServiceTemplate();
template.setToscaTopologyTemplate(null);
- return new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), template, Map.of(), Map.of());
+ var inProperties = getProperties(template);
+ return new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), inProperties, Map.of());
+ }
+
+ private InstanceElementDto getInstanceElementWithNoPolicy() {
+ var template = new ToscaServiceTemplate();
+ template.setToscaTopologyTemplate(new ToscaTopologyTemplate());
+ var inProperties = getProperties(template);
+ return new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), inProperties, Map.of());
}
@Test
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV2Test.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV2Test.java
index e89a82696..2f1e9dc9d 100644
--- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV2Test.java
+++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV2Test.java
@@ -44,7 +44,7 @@ class AutomationCompositionElementHandlerV2Test {
private static final CompositionElementDto COMPOSITION_ELEMENT =
new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(), Map.of(), Map.of());
private static final InstanceElementDto INSTANCE_ELEMENT =
- new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of());
+ new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of());
private static final CompositionDto COMPOSITION = new CompositionDto(UUID.randomUUID(), Map.of(), Map.of());
@Test
@@ -131,7 +131,7 @@ class AutomationCompositionElementHandlerV2Test {
var acElementHandler = new AutomationCompositionElementHandlerV2(intermediaryApi, simulatorService);
simulatorService.setConfig(config);
var instanceElementUpdated = new InstanceElementDto(
- INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(), null,
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(),
Map.of("key", "value"), Map.of());
acElementHandler.update(COMPOSITION_ELEMENT, INSTANCE_ELEMENT, instanceElementUpdated);
verify(intermediaryApi).updateAutomationCompositionElementState(
@@ -209,7 +209,7 @@ class AutomationCompositionElementHandlerV2Test {
Map.of(), Map.of());
var instanceElementMigrated = new InstanceElementDto(
INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(),
- null, Map.of("key", "value"), new HashMap<>());
+ Map.of("key", "value"), new HashMap<>());
acElementHandler
.migrate(COMPOSITION_ELEMENT, compositionElementTarget, INSTANCE_ELEMENT, instanceElementMigrated);
verify(intermediaryApi).updateAutomationCompositionElementState(
@@ -236,13 +236,12 @@ class AutomationCompositionElementHandlerV2Test {
UUID.randomUUID(), new ToscaConceptIdentifier(), Map.of(), Map.of(), ElementState.NOT_PRESENT);
var instanceElement = new InstanceElementDto(
- UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of(), ElementState.NOT_PRESENT);
+ UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of(), ElementState.NOT_PRESENT);
var compoElTargetAdd = new CompositionElementDto(
UUID.randomUUID(), new ToscaConceptIdentifier(), Map.of(), Map.of(), ElementState.NEW);
var inElMigratedAdd = new InstanceElementDto(
- instanceElement.instanceId(), instanceElement.elementId(), null,
- Map.of(), new HashMap<>(), ElementState.NEW);
+ instanceElement.instanceId(), instanceElement.elementId(), Map.of(), new HashMap<>(), ElementState.NEW);
acElementHandler
.migrate(compositionElement, compoElTargetAdd, instanceElement, inElMigratedAdd);
verify(intermediaryApi).updateAutomationCompositionElementState(
@@ -262,7 +261,7 @@ class AutomationCompositionElementHandlerV2Test {
Map.of(), Map.of(), ElementState.REMOVED);
var inElMigratedRemove = new InstanceElementDto(
INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(),
- null, Map.of("key", "value"), Map.of(), ElementState.REMOVED);
+ Map.of("key", "value"), Map.of(), ElementState.REMOVED);
acElementHandler
.migrate(COMPOSITION_ELEMENT, compoElTargetRemove, INSTANCE_ELEMENT, inElMigratedRemove);
verify(intermediaryApi).updateAutomationCompositionElementState(
@@ -284,7 +283,7 @@ class AutomationCompositionElementHandlerV2Test {
Map.of(), Map.of());
var instanceElementMigrated = new InstanceElementDto(
INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(),
- null, Map.of("key", "value"), Map.of());
+ Map.of("key", "value"), Map.of());
acElementHandler.migratePrecheck(COMPOSITION_ELEMENT, compositionElementTarget,
INSTANCE_ELEMENT, instanceElementMigrated);
verify(intermediaryApi).updateAutomationCompositionElementState(
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV3Test.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV3Test.java
index d2d3d5c7e..41b3f2001 100644
--- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV3Test.java
+++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV3Test.java
@@ -45,7 +45,7 @@ class AutomationCompositionElementHandlerV3Test {
private static final CompositionElementDto COMPOSITION_ELEMENT =
new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(), Map.of(), Map.of());
private static final InstanceElementDto INSTANCE_ELEMENT =
- new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of());
+ new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of());
private static final CompositionDto COMPOSITION = new CompositionDto(UUID.randomUUID(), Map.of(), Map.of());
@Test
@@ -132,7 +132,7 @@ class AutomationCompositionElementHandlerV3Test {
var acElementHandler = new AutomationCompositionElementHandlerV3(intermediaryApi, simulatorService);
simulatorService.setConfig(config);
var instanceElementUpdated = new InstanceElementDto(
- INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(), null,
+ INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(),
Map.of("key", "value"), Map.of());
acElementHandler.update(COMPOSITION_ELEMENT, INSTANCE_ELEMENT, instanceElementUpdated);
verify(intermediaryApi).updateAutomationCompositionElementState(
@@ -210,7 +210,7 @@ class AutomationCompositionElementHandlerV3Test {
Map.of(), Map.of());
var instanceElementMigrated = new InstanceElementDto(
INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(),
- null, Map.of("key", "value"), new HashMap<>());
+ Map.of("key", "value"), new HashMap<>());
acElementHandler
.migrate(COMPOSITION_ELEMENT, compositionElementTarget, INSTANCE_ELEMENT, instanceElementMigrated, 0);
verify(intermediaryApi).updateAutomationCompositionElementState(
@@ -235,7 +235,7 @@ class AutomationCompositionElementHandlerV3Test {
var compositionElementTarget = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
Map.of("stage", List.of(1, 2)), Map.of());
var instanceElementMigrated = new InstanceElementDto(INSTANCE_ELEMENT.instanceId(),
- INSTANCE_ELEMENT.elementId(), null, Map.of(), new HashMap<>());
+ INSTANCE_ELEMENT.elementId(), Map.of(), new HashMap<>());
acElementHandler
.migrate(COMPOSITION_ELEMENT, compositionElementTarget, INSTANCE_ELEMENT, instanceElementMigrated, 1);
verify(intermediaryApi).updateAutomationCompositionElementStage(
@@ -254,12 +254,12 @@ class AutomationCompositionElementHandlerV3Test {
UUID.randomUUID(), new ToscaConceptIdentifier(), Map.of(), Map.of(), ElementState.NOT_PRESENT);
var instanceElement = new InstanceElementDto(
- UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of(), ElementState.NOT_PRESENT);
+ UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of(), ElementState.NOT_PRESENT);
var compoElTargetAdd = new CompositionElementDto(
UUID.randomUUID(), new ToscaConceptIdentifier(), Map.of(), Map.of(), ElementState.NEW);
var inElMigratedAdd = new InstanceElementDto(instanceElement.instanceId(), instanceElement.elementId(),
- null, Map.of(), new HashMap<>(), ElementState.NEW);
+ Map.of(), new HashMap<>(), ElementState.NEW);
acElementHandler
.migrate(compositionElement, compoElTargetAdd, instanceElement, inElMigratedAdd, 0);
verify(intermediaryApi).updateAutomationCompositionElementState(
@@ -279,7 +279,7 @@ class AutomationCompositionElementHandlerV3Test {
Map.of(), Map.of(), ElementState.REMOVED);
var inElMigratedRemove = new InstanceElementDto(
INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(),
- null, Map.of("key", "value"), Map.of(), ElementState.REMOVED);
+ Map.of("key", "value"), Map.of(), ElementState.REMOVED);
acElementHandler
.migrate(COMPOSITION_ELEMENT, compoElTargetRemove, INSTANCE_ELEMENT, inElMigratedRemove, 0);
verify(intermediaryApi).updateAutomationCompositionElementState(
@@ -301,7 +301,7 @@ class AutomationCompositionElementHandlerV3Test {
Map.of(), Map.of());
var instanceElementMigrated = new InstanceElementDto(
INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(),
- null, Map.of("key", "value"), Map.of());
+ Map.of("key", "value"), Map.of());
acElementHandler.migratePrecheck(COMPOSITION_ELEMENT, compositionElementTarget,
INSTANCE_ELEMENT, instanceElementMigrated);
verify(intermediaryApi).updateAutomationCompositionElementState(
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/InstanceElementDto.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/InstanceElementDto.java
index b4fdefbf3..6e5e690be 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/InstanceElementDto.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/InstanceElementDto.java
@@ -23,13 +23,32 @@ package org.onap.policy.clamp.acm.participant.intermediary.api;
import java.util.Map;
import java.util.UUID;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
-public record InstanceElementDto(UUID instanceId, UUID elementId, ToscaServiceTemplate toscaServiceTemplateFragment,
- Map<String, Object> inProperties, Map<String, Object> outProperties,
- ElementState state) {
+public record InstanceElementDto(UUID instanceId, UUID elementId,
+ Map<String, Object> inProperties, Map<String, Object> outProperties, ElementState state) {
+ private static final Logger LOGGER = LoggerFactory.getLogger(InstanceElementDto.class);
+
+ /**
+ * Constructor for backward compatibility.
+ *
+ * @param instanceId AC instanceid
+ * @param elementId AC element instanceid
+ * @param toscaServiceTemplateFragment backward compatibility
+ * @param inProperties AC element instance In properties
+ * @param outProperties AC element instance Out properties
+ */
public InstanceElementDto(UUID instanceId, UUID elementId, ToscaServiceTemplate toscaServiceTemplateFragment,
- Map<String, Object> inProperties, Map<String, Object> outProperties) {
- this(instanceId, elementId, toscaServiceTemplateFragment, inProperties, outProperties, ElementState.PRESENT);
+ Map<String, Object> inProperties, Map<String, Object> outProperties) {
+ this(instanceId, elementId, inProperties, outProperties, ElementState.PRESENT);
+ LOGGER.debug("Obsolete InstanceElementDto constructor: toscaServiceTemplateFragment field {} is not used!",
+ toscaServiceTemplateFragment);
+ }
+
+ public InstanceElementDto(UUID instanceId, UUID elementId,
+ Map<String, Object> inProperties, Map<String, Object> outProperties) {
+ this(instanceId, elementId, inProperties, outProperties, ElementState.PRESENT);
}
}
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV1.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV1.java
index 34bdc349b..7bea81e4d 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV1.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV1.java
@@ -61,7 +61,6 @@ public abstract class AcElementListenerV1
var element = new AcElementDeploy();
element.setId(instanceElement.elementId());
element.setDefinition(compositionElement.elementDefinitionId());
- element.setToscaServiceTemplateFragment(instanceElement.toscaServiceTemplateFragment());
element.setProperties(instanceElement.inProperties());
Map<String, Object> properties = new HashMap<>(instanceElement.inProperties());
properties.putAll(compositionElement.inProperties());
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AcLockHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AcLockHandler.java
index 95613cc9e..109bd3f8f 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AcLockHandler.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AcLockHandler.java
@@ -72,8 +72,6 @@ public class AcLockHandler {
private void handleLockState(UUID messageId, final AutomationComposition automationComposition,
Integer startPhaseMsg) {
automationComposition.setLockState(LockState.LOCKING);
- var serviceTemplateFragment = cacheProvider
- .getServiceTemplateFragmentMap().get(automationComposition.getCompositionId());
for (var element : automationComposition.getElements().values()) {
var compositionInProperties = cacheProvider
.getCommonProperties(automationComposition.getCompositionId(), element.getDefinition());
@@ -84,7 +82,7 @@ public class AcLockHandler {
var compositionElement = cacheProvider.createCompositionElementDto(
automationComposition.getCompositionId(), element, compositionInProperties);
var instanceElement = new InstanceElementDto(automationComposition.getInstanceId(), element.getId(),
- serviceTemplateFragment, element.getProperties(), element.getOutProperties());
+ element.getProperties(), element.getOutProperties());
listener.lock(messageId, compositionElement, instanceElement);
}
}
@@ -93,8 +91,6 @@ public class AcLockHandler {
private void handleUnlockState(UUID messageId, final AutomationComposition automationComposition,
Integer startPhaseMsg) {
automationComposition.setLockState(LockState.UNLOCKING);
- var serviceTemplateFragment = cacheProvider
- .getServiceTemplateFragmentMap().get(automationComposition.getCompositionId());
for (var element : automationComposition.getElements().values()) {
var compositionInProperties = cacheProvider
.getCommonProperties(automationComposition.getCompositionId(), element.getDefinition());
@@ -105,7 +101,7 @@ public class AcLockHandler {
var compositionElement = cacheProvider.createCompositionElementDto(
automationComposition.getCompositionId(), element, compositionInProperties);
var instanceElement = new InstanceElementDto(automationComposition.getInstanceId(), element.getId(),
- serviceTemplateFragment, element.getProperties(), element.getOutProperties());
+ element.getProperties(), element.getOutProperties());
listener.unlock(messageId, compositionElement, instanceElement);
}
}
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AcSubStateHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AcSubStateHandler.java
index 1dbf2c935..4c5baf6fd 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AcSubStateHandler.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AcSubStateHandler.java
@@ -35,7 +35,6 @@ import org.onap.policy.clamp.models.acm.concepts.SubState;
import org.onap.policy.clamp.models.acm.messages.kafka.participant.AutomationCompositionMigration;
import org.onap.policy.clamp.models.acm.messages.kafka.participant.AutomationCompositionPrepare;
import org.onap.policy.clamp.models.acm.utils.AcmUtils;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@@ -120,7 +119,7 @@ public class AcSubStateHandler {
compositionElement = new CompositionElementDto(automationComposition.getCompositionId(),
acElement.getDefinition(), Map.of(), Map.of(), ElementState.NOT_PRESENT);
instanceElement = new InstanceElementDto(automationComposition.getInstanceId(), acElement.getId(),
- new ToscaServiceTemplate(), Map.of(), Map.of(), ElementState.NOT_PRESENT);
+ Map.of(), Map.of(), ElementState.NOT_PRESENT);
compositionElementTarget = CacheProvider.changeStateToNew(compositionElementTarget);
instanceElementMigrate = CacheProvider.changeStateToNew(instanceElementMigrate);
}
@@ -136,7 +135,7 @@ public class AcSubStateHandler {
Map.of(), Map.of(), ElementState.REMOVED);
var instanceDtoTarget =
new InstanceElementDto(automationComposition.getInstanceId(), elementId,
- null, Map.of(), Map.of(), ElementState.REMOVED);
+ Map.of(), Map.of(), ElementState.REMOVED);
listener.migratePrecheck(messageId, compositionElementMap.get(elementId), compositionDtoTarget,
instanceElementMap.get(elementId), instanceDtoTarget);
@@ -176,7 +175,6 @@ public class AcSubStateHandler {
var compositionElement = cacheProvider.createCompositionElementDto(automationComposition.getCompositionId(),
element, compositionInProperties);
var instanceElement = new InstanceElementDto(instanceId, elementDeploy.getId(),
- elementDeploy.getToscaServiceTemplateFragment(),
elementDeploy.getProperties(), element.getOutProperties());
listener.prepare(messageId, compositionElement, instanceElement);
}
@@ -190,7 +188,7 @@ public class AcSubStateHandler {
var compositionElement = cacheProvider.createCompositionElementDto(automationComposition.getCompositionId(),
element, compositionInProperties);
var instanceElement = new InstanceElementDto(automationComposition.getInstanceId(), element.getId(),
- null, element.getProperties(), element.getOutProperties());
+ element.getProperties(), element.getOutProperties());
listener.review(messageId, compositionElement, instanceElement);
}
}
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java
index 6d94efb0f..73888873c 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java
@@ -167,7 +167,6 @@ public class AutomationCompositionHandler {
var compositionElement = cacheProvider.createCompositionElementDto(
automationComposition.getCompositionId(), element, compositionInProperties);
var instanceElement = new InstanceElementDto(instanceId, elementDeploy.getId(),
- elementDeploy.getToscaServiceTemplateFragment(),
elementDeploy.getProperties(), element.getOutProperties());
listener.deploy(messageId, compositionElement, instanceElement);
}
@@ -249,8 +248,6 @@ public class AutomationCompositionHandler {
Integer startPhaseMsg) {
automationComposition.setCompositionTargetId(null);
automationComposition.setDeployState(DeployState.UNDEPLOYING);
- var serviceTemplateFragment = cacheProvider
- .getServiceTemplateFragmentMap().get(automationComposition.getCompositionId());
for (var element : automationComposition.getElements().values()) {
var compositionInProperties = cacheProvider
.getCommonProperties(automationComposition.getCompositionId(), element.getDefinition());
@@ -260,7 +257,7 @@ public class AutomationCompositionHandler {
var compositionElement = cacheProvider.createCompositionElementDto(
automationComposition.getCompositionId(), element, compositionInProperties);
var instanceElement = new InstanceElementDto(automationComposition.getInstanceId(), element.getId(),
- serviceTemplateFragment, element.getProperties(), element.getOutProperties());
+ element.getProperties(), element.getOutProperties());
listener.undeploy(messageId, compositionElement, instanceElement);
}
}
@@ -269,8 +266,6 @@ public class AutomationCompositionHandler {
private void handleDeleteState(UUID messageId, final AutomationComposition automationComposition,
Integer startPhaseMsg) {
automationComposition.setDeployState(DeployState.DELETING);
- var serviceTemplateFragment = cacheProvider
- .getServiceTemplateFragmentMap().get(automationComposition.getCompositionId());
for (var element : automationComposition.getElements().values()) {
var compositionInProperties = cacheProvider
.getCommonProperties(automationComposition.getCompositionId(), element.getDefinition());
@@ -281,7 +276,7 @@ public class AutomationCompositionHandler {
var compositionElement = cacheProvider.createCompositionElementDto(
automationComposition.getCompositionId(), element, compositionInProperties);
var instanceElement = new InstanceElementDto(automationComposition.getInstanceId(), element.getId(),
- serviceTemplateFragment, element.getProperties(), element.getOutProperties());
+ element.getProperties(), element.getOutProperties());
listener.delete(messageId, compositionElement, instanceElement);
}
}
@@ -338,7 +333,7 @@ public class AutomationCompositionHandler {
new CompositionElementDto(acCopy.getCompositionId(), acElement.getDefinition(),
Map.of(), Map.of(), ElementState.NOT_PRESENT);
var instanceElementDto = new InstanceElementDto(acCopy.getInstanceId(), acElement.getId(),
- null, Map.of(), Map.of(), ElementState.NOT_PRESENT);
+ Map.of(), Map.of(), ElementState.NOT_PRESENT);
var compositionElementTargetDto = CacheProvider.changeStateToNew(
compositionElementTargetMap.get(acElement.getId()));
var instanceElementMigrateDto = CacheProvider
@@ -358,12 +353,10 @@ public class AutomationCompositionHandler {
// Call migrate for removed elements
List<UUID> removedElements = findElementsToRemove(acElements, acCopy.getElements());
for (var elementId : removedElements) {
- var compositionDtoTarget =
- new CompositionElementDto(compositionTargetId,
+ var compositionDtoTarget = new CompositionElementDto(compositionTargetId,
acCopy.getElements().get(elementId).getDefinition(),
Map.of(), Map.of(), ElementState.REMOVED);
- var instanceDtoTarget =
- new InstanceElementDto(acCopy.getInstanceId(), elementId, null, Map.of(),
+ var instanceDtoTarget = new InstanceElementDto(acCopy.getInstanceId(), elementId, Map.of(),
Map.of(), ElementState.REMOVED);
listener.migrate(messageId, compositionElementMap.get(elementId), compositionDtoTarget,
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/CacheProvider.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/CacheProvider.java
index c6915026a..9973e4022 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/CacheProvider.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/CacheProvider.java
@@ -46,7 +46,6 @@ import org.onap.policy.clamp.models.acm.concepts.SubState;
import org.onap.policy.models.base.PfUtils;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.springframework.stereotype.Component;
@Component
@@ -74,9 +73,6 @@ public class CacheProvider {
@Getter
private final Map<UUID, UUID> msgIdentification = new ConcurrentHashMap<>();
- @Getter
- private final Map<UUID, ToscaServiceTemplate> serviceTemplateFragmentMap = new ConcurrentHashMap<>();
-
/**
* Constructor.
*
@@ -127,7 +123,6 @@ public class CacheProvider {
public void removeElementDefinition(@NonNull UUID compositionId) {
acElementsDefinitions.remove(compositionId);
- serviceTemplateFragmentMap.remove(compositionId);
}
/**
@@ -206,9 +201,6 @@ public class CacheProvider {
acElement.setOutProperties(acElementLast.getOutProperties());
acElement.setOperationalState(acElementLast.getOperationalState());
acElement.setUseState(acElementLast.getUseState());
- if (element.getToscaServiceTemplateFragment() != null) {
- serviceTemplateFragmentMap.put(compositionId, element.getToscaServiceTemplateFragment());
- }
}
acElementMap.put(element.getId(), acElement);
}
@@ -246,9 +238,6 @@ public class CacheProvider {
acElement.setProperties(element.getProperties());
acElement.setOutProperties(element.getOutProperties());
acElementMap.put(element.getId(), acElement);
- if (element.getToscaServiceTemplateFragment() != null) {
- serviceTemplateFragmentMap.put(compositionId, element.getToscaServiceTemplateFragment());
- }
}
var automationComposition = new AutomationComposition();
@@ -329,10 +318,9 @@ public class CacheProvider {
*/
public Map<UUID, InstanceElementDto> getInstanceElementDtoMap(AutomationComposition automationComposition) {
Map<UUID, InstanceElementDto> map = new HashMap<>();
- var serviceTemplateFragment = serviceTemplateFragmentMap.get(automationComposition.getCompositionId());
for (var element : automationComposition.getElements().values()) {
var instanceElement = new InstanceElementDto(automationComposition.getInstanceId(), element.getId(),
- serviceTemplateFragment, element.getProperties(), element.getOutProperties());
+ element.getProperties(), element.getOutProperties());
map.put(element.getId(), instanceElement);
}
return map;
@@ -346,7 +334,6 @@ public class CacheProvider {
*/
public static InstanceElementDto changeStateToNew(InstanceElementDto instanceElement) {
return new InstanceElementDto(instanceElement.instanceId(), instanceElement.elementId(),
- instanceElement.toscaServiceTemplateFragment(),
instanceElement.inProperties(), instanceElement.outProperties(), ElementState.NEW);
}
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV1Test.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV1Test.java
index 12acdbbb6..3ea221e92 100644
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV1Test.java
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV1Test.java
@@ -48,7 +48,7 @@ class AcElementListenerV1Test {
var acElementListenerV1 = mock(AcElementListenerV1.class, Answers.CALLS_REAL_METHODS);
var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
Map.of(), Map.of());
- var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of());
+ var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of());
acElementListenerV1.deploy(compositionElement, instanceElement);
verify(acElementListenerV1).deploy(any(), any(), any());
}
@@ -58,7 +58,7 @@ class AcElementListenerV1Test {
var acElementListenerV1 = mock(AcElementListenerV1.class, Answers.CALLS_REAL_METHODS);
var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
Map.of(), Map.of());
- var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of());
+ var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of());
acElementListenerV1.undeploy(compositionElement, instanceElement);
verify(acElementListenerV1).undeploy(instanceElement.instanceId(), instanceElement.elementId());
}
@@ -69,7 +69,7 @@ class AcElementListenerV1Test {
var acElementListenerV1 = createAcElementListenerV1(intermediaryApi);
var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
Map.of(), Map.of());
- var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of());
+ var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of());
acElementListenerV1.lock(compositionElement, instanceElement);
verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
instanceElement.elementId(), null, LockState.LOCKED, StateChangeResult.NO_ERROR, "Locked");
@@ -81,7 +81,7 @@ class AcElementListenerV1Test {
var acElementListenerV1 = createAcElementListenerV1(intermediaryApi);
var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
Map.of(), Map.of());
- var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of());
+ var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of());
acElementListenerV1.delete(compositionElement, instanceElement);
verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
instanceElement.elementId(), DeployState.DELETED, null, StateChangeResult.NO_ERROR, "Deleted");
@@ -93,7 +93,7 @@ class AcElementListenerV1Test {
var acElementListenerV1 = createAcElementListenerV1(intermediaryApi);
var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
Map.of(), Map.of());
- var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of());
+ var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of());
acElementListenerV1.update(compositionElement, instanceElement, instanceElement);
verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
instanceElement.elementId(), DeployState.DEPLOYED, null,
@@ -106,7 +106,7 @@ class AcElementListenerV1Test {
var acElementListenerV1 = createAcElementListenerV1(intermediaryApi);
var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
Map.of(), Map.of());
- var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of());
+ var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of());
acElementListenerV1.unlock(compositionElement, instanceElement);
verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
instanceElement.elementId(), null, LockState.UNLOCKED, StateChangeResult.NO_ERROR, "Unlocked");
@@ -156,7 +156,7 @@ class AcElementListenerV1Test {
var acElementListenerV1 = createAcElementListenerV1(intermediaryApi);
var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
Map.of(), Map.of());
- var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of());
+ var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of());
acElementListenerV1.migrate(compositionElement, compositionElement, instanceElement, instanceElement, 0);
verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
instanceElement.elementId(), DeployState.DEPLOYED, null,
@@ -169,7 +169,7 @@ class AcElementListenerV1Test {
var acElementListenerV1 = createAcElementListenerV1(intermediaryApi);
var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
Map.of(), Map.of());
- var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of());
+ var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of());
acElementListenerV1.migratePrecheck(compositionElement, compositionElement, instanceElement, instanceElement);
verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
instanceElement.elementId(), DeployState.DEPLOYED, null,
@@ -182,7 +182,7 @@ class AcElementListenerV1Test {
var acElementListenerV1 = createAcElementListenerV1(intermediaryApi);
var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
Map.of(), Map.of());
- var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of());
+ var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of());
acElementListenerV1.review(compositionElement, instanceElement);
verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
instanceElement.elementId(), DeployState.DEPLOYED, null,
@@ -195,7 +195,7 @@ class AcElementListenerV1Test {
var acElementListenerV1 = createAcElementListenerV1(intermediaryApi);
var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
Map.of(), Map.of());
- var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of());
+ var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of());
acElementListenerV1.prepare(compositionElement, instanceElement);
verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
instanceElement.elementId(), DeployState.UNDEPLOYED, null,
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV2Test.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV2Test.java
index a6cb7b005..0d195d71c 100644
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV2Test.java
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV2Test.java
@@ -46,7 +46,7 @@ class AcElementListenerV2Test {
var acElementListenerV2 = createAcElementListenerV2(intermediaryApi);
var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
Map.of(), Map.of());
- var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of());
+ var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of());
acElementListenerV2.lock(compositionElement, instanceElement);
verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
instanceElement.elementId(), null, LockState.LOCKED, StateChangeResult.NO_ERROR, "Locked");
@@ -58,7 +58,7 @@ class AcElementListenerV2Test {
var acElementListenerV2 = createAcElementListenerV2(intermediaryApi);
var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
Map.of(), Map.of());
- var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of());
+ var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of());
acElementListenerV2.delete(compositionElement, instanceElement);
verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
instanceElement.elementId(), DeployState.DELETED, null, StateChangeResult.NO_ERROR, "Deleted");
@@ -70,7 +70,7 @@ class AcElementListenerV2Test {
var acElementListenerV2 = createAcElementListenerV2(intermediaryApi);
var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
Map.of(), Map.of());
- var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of());
+ var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of());
acElementListenerV2.update(compositionElement, instanceElement, instanceElement);
verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
instanceElement.elementId(), DeployState.DEPLOYED, null,
@@ -83,7 +83,7 @@ class AcElementListenerV2Test {
var acElementListenerV2 = createAcElementListenerV2(intermediaryApi);
var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
Map.of(), Map.of());
- var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of());
+ var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of());
acElementListenerV2.unlock(compositionElement, instanceElement);
verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
instanceElement.elementId(), null, LockState.UNLOCKED, StateChangeResult.NO_ERROR, "Unlocked");
@@ -133,7 +133,7 @@ class AcElementListenerV2Test {
var acElementListenerV2 = createAcElementListenerV2(intermediaryApi);
var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
Map.of(), Map.of());
- var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of());
+ var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of());
acElementListenerV2.migrate(compositionElement, compositionElement, instanceElement, instanceElement, 0);
verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
instanceElement.elementId(), DeployState.DEPLOYED, null,
@@ -146,7 +146,7 @@ class AcElementListenerV2Test {
var acElementListenerV1 = createAcElementListenerV2(intermediaryApi);
var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
Map.of(), Map.of());
- var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of());
+ var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of());
acElementListenerV1.migratePrecheck(compositionElement, compositionElement, instanceElement, instanceElement);
verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
instanceElement.elementId(), DeployState.DEPLOYED, null,
@@ -159,7 +159,7 @@ class AcElementListenerV2Test {
var acElementListenerV1 = createAcElementListenerV2(intermediaryApi);
var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
Map.of(), Map.of());
- var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of());
+ var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of());
acElementListenerV1.review(compositionElement, instanceElement);
verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
instanceElement.elementId(), DeployState.DEPLOYED, null,
@@ -172,7 +172,7 @@ class AcElementListenerV2Test {
var acElementListenerV1 = createAcElementListenerV2(intermediaryApi);
var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
Map.of(), Map.of());
- var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of());
+ var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of());
acElementListenerV1.prepare(compositionElement, instanceElement);
verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
instanceElement.elementId(), DeployState.UNDEPLOYED, null,
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV3Test.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV3Test.java
index 1385f439a..8dbefe29f 100644
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV3Test.java
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV3Test.java
@@ -45,7 +45,7 @@ class AcElementListenerV3Test {
var acElementListenerV2 = createAcElementListenerV3(intermediaryApi);
var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
Map.of(), Map.of());
- var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of());
+ var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of());
acElementListenerV2.lock(compositionElement, instanceElement);
verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
instanceElement.elementId(), null, LockState.LOCKED, StateChangeResult.NO_ERROR, "Locked");
@@ -57,7 +57,7 @@ class AcElementListenerV3Test {
var acElementListenerV2 = createAcElementListenerV3(intermediaryApi);
var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
Map.of(), Map.of());
- var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of());
+ var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of());
acElementListenerV2.delete(compositionElement, instanceElement);
verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
instanceElement.elementId(), DeployState.DELETED, null, StateChangeResult.NO_ERROR, "Deleted");
@@ -69,7 +69,7 @@ class AcElementListenerV3Test {
var acElementListenerV2 = createAcElementListenerV3(intermediaryApi);
var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
Map.of(), Map.of());
- var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of());
+ var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of());
acElementListenerV2.update(compositionElement, instanceElement, instanceElement);
verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
instanceElement.elementId(), DeployState.DEPLOYED, null,
@@ -82,7 +82,7 @@ class AcElementListenerV3Test {
var acElementListenerV2 = createAcElementListenerV3(intermediaryApi);
var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
Map.of(), Map.of());
- var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of());
+ var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of());
acElementListenerV2.unlock(compositionElement, instanceElement);
verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
instanceElement.elementId(), null, LockState.UNLOCKED, StateChangeResult.NO_ERROR, "Unlocked");
@@ -118,7 +118,7 @@ class AcElementListenerV3Test {
var acElementListenerV2 = createAcElementListenerV3(intermediaryApi);
var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
Map.of(), Map.of());
- var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of());
+ var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of());
acElementListenerV2.migrate(compositionElement, compositionElement, instanceElement, instanceElement, 0);
verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
instanceElement.elementId(), DeployState.DEPLOYED, null,
@@ -131,7 +131,7 @@ class AcElementListenerV3Test {
var acElementListenerV1 = createAcElementListenerV3(intermediaryApi);
var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
Map.of(), Map.of());
- var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of());
+ var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of());
acElementListenerV1.migratePrecheck(compositionElement, compositionElement, instanceElement, instanceElement);
verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
instanceElement.elementId(), DeployState.DEPLOYED, null,
@@ -144,7 +144,7 @@ class AcElementListenerV3Test {
var acElementListenerV1 = createAcElementListenerV3(intermediaryApi);
var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
Map.of(), Map.of());
- var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of());
+ var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of());
acElementListenerV1.review(compositionElement, instanceElement);
verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
instanceElement.elementId(), DeployState.DEPLOYED, null,
@@ -157,7 +157,7 @@ class AcElementListenerV3Test {
var acElementListenerV1 = createAcElementListenerV3(intermediaryApi);
var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
Map.of(), Map.of());
- var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), null, Map.of(), Map.of());
+ var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of());
acElementListenerV1.prepare(compositionElement, instanceElement);
verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
instanceElement.elementId(), DeployState.UNDEPLOYED, null,
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java
index 71af77fbf..9efe2e273 100644
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java
@@ -29,6 +29,7 @@ import static org.mockito.Mockito.when;
import java.util.Map;
import java.util.UUID;
import org.junit.jupiter.api.Test;
+import org.onap.policy.clamp.acm.participant.intermediary.api.InstanceElementDto;
import org.onap.policy.clamp.acm.participant.intermediary.handler.AutomationCompositionOutHandler;
import org.onap.policy.clamp.acm.participant.intermediary.handler.CacheProvider;
import org.onap.policy.clamp.models.acm.concepts.AcTypeState;
@@ -40,6 +41,7 @@ import org.onap.policy.clamp.models.acm.concepts.LockState;
import org.onap.policy.clamp.models.acm.concepts.StateChangeResult;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
class ParticipantIntermediaryApiImplTest {
@@ -148,4 +150,13 @@ class ParticipantIntermediaryApiImplTest {
element = apiImpl.getAcElementDefinition(COMPOSITION_ID, DEFINITION_ELEMENT_ID);
assertEquals(acElementDefinition, element);
}
+
+ @Test
+ void testInstanceElementDto() {
+ // test InstanceElementDto with toscaServiceTemplateFragment
+ var instanceElementDto = new InstanceElementDto(COMPOSITION_ID, ELEMENT_ID, new ToscaServiceTemplate(),
+ Map.of(), Map.of());
+ assertEquals(COMPOSITION_ID, instanceElementDto.instanceId());
+ assertEquals(ELEMENT_ID, instanceElementDto.elementId());
+ }
}
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AcLockHandlerTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AcLockHandlerTest.java
index ebc9c8da3..9ea3f9f1b 100644
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AcLockHandlerTest.java
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AcLockHandlerTest.java
@@ -23,6 +23,7 @@ package org.onap.policy.clamp.acm.participant.intermediary.handler;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.clearInvocations;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -81,6 +82,11 @@ class AcLockHandlerTest {
for (var element : automationComposition.getElements().values()) {
assertEquals(LockState.LOCKING, element.getLockState());
}
+
+ clearInvocations(listener);
+ automationCompositionStateChange.setStartPhase(2);
+ ach.handleAutomationCompositionStateChange(automationCompositionStateChange);
+ verify(listener, times(0)).lock(any(), any(), any());
}
@Test
@@ -108,5 +114,10 @@ class AcLockHandlerTest {
for (var element : automationComposition.getElements().values()) {
assertEquals(LockState.UNLOCKING, element.getLockState());
}
+
+ clearInvocations(listener);
+ automationCompositionStateChange.setStartPhase(2);
+ ach.handleAutomationCompositionStateChange(automationCompositionStateChange);
+ verify(listener, times(0)).unlock(any(), any(), any());
}
}
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandlerTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandlerTest.java
index ec61f886e..b301ef1e8 100644
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandlerTest.java
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandlerTest.java
@@ -101,6 +101,11 @@ class AutomationCompositionHandlerTest {
for (var element : automationComposition.getElements().values()) {
assertEquals(DeployState.UNDEPLOYING, element.getDeployState());
}
+
+ clearInvocations(listener);
+ automationCompositionStateChange.setStartPhase(2);
+ ach.handleAutomationCompositionStateChange(automationCompositionStateChange);
+ verify(listener, times(0)).undeploy(any(), any(), any());
}
@Test
@@ -127,6 +132,11 @@ class AutomationCompositionHandlerTest {
for (var element : automationComposition.getElements().values()) {
assertEquals(DeployState.DELETING, element.getDeployState());
}
+
+ clearInvocations(listener);
+ automationCompositionStateChange.setStartPhase(2);
+ ach.handleAutomationCompositionStateChange(automationCompositionStateChange);
+ verify(listener, times(0)).delete(any(), any(), any());
}
@Test
@@ -197,6 +207,12 @@ class AutomationCompositionHandlerTest {
ach.handleAutomationCompositionDeploy(deployMsg);
verify(listener, times(automationComposition.getElements().size())).deploy(any(), any(), any());
+
+ clearInvocations(listener);
+ deployMsg.setStartPhase(2);
+ deployMsg.setFirstStartPhase(false);
+ ach.handleAutomationCompositionDeploy(deployMsg);
+ verify(listener, times(0)).deploy(any(), any(), any());
}
@Test
@@ -340,5 +356,4 @@ class AutomationCompositionHandlerTest {
ach.handleAutomationCompositionMigration(migrationMsg);
verify(listener, times(expectedMigrated)).migrate(any(), any(), any(), any(), any(), anyInt());
}
-
}
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/CacheProviderTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/CacheProviderTest.java
index 1d4e3dff3..6edd9db81 100644
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/CacheProviderTest.java
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/CacheProviderTest.java
@@ -29,6 +29,9 @@ import java.util.UUID;
import org.junit.jupiter.api.Test;
import org.onap.policy.clamp.acm.participant.intermediary.api.ElementState;
import org.onap.policy.clamp.acm.participant.intermediary.main.parameters.CommonTestData;
+import org.onap.policy.clamp.models.acm.concepts.DeployState;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantDeploy;
+import org.onap.policy.clamp.models.acm.concepts.SubState;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
class CacheProviderTest {
@@ -43,16 +46,35 @@ class CacheProviderTest {
}
@Test
- void testNotNull() {
+ void testInitializeAutomationCompositionNotNull() {
var parameter = CommonTestData.getParticipantParameters();
var cacheProvider = new CacheProvider(parameter);
var instanceId = UUID.randomUUID();
- assertThatThrownBy(() -> cacheProvider.initializeAutomationComposition(null, null, null))
+ var participantDeploy = new ParticipantDeploy();
+
+ assertThatThrownBy(() -> cacheProvider.initializeAutomationComposition(null, instanceId, participantDeploy))
.isInstanceOf(NullPointerException.class);
- assertThatThrownBy(() -> cacheProvider.initializeAutomationComposition(instanceId, null, null))
+ assertThatThrownBy(() -> cacheProvider.initializeAutomationComposition(instanceId, null, participantDeploy))
.isInstanceOf(NullPointerException.class);
assertThatThrownBy(() -> cacheProvider.initializeAutomationComposition(instanceId, instanceId, null))
.isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(() -> cacheProvider.initializeAutomationComposition(null, null))
+ .isInstanceOf(NullPointerException.class);
+
+ var deployState = DeployState.DEPLOYED;
+ var subState = SubState.NONE;
+
+ assertThatThrownBy(() -> cacheProvider.initializeAutomationComposition(null, instanceId, participantDeploy,
+ deployState, subState)).isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(() -> cacheProvider.initializeAutomationComposition(instanceId, null, participantDeploy,
+ deployState, subState)).isInstanceOf(NullPointerException.class);
+ }
+
+ @Test
+ void testNotNull() {
+ var parameter = CommonTestData.getParticipantParameters();
+ var cacheProvider = new CacheProvider(parameter);
+ var instanceId = UUID.randomUUID();
assertThatThrownBy(() -> cacheProvider.addElementDefinition(null, null))
.isInstanceOf(NullPointerException.class);
@@ -64,6 +86,8 @@ class CacheProviderTest {
var definition = new ToscaConceptIdentifier();
assertThatThrownBy(() -> cacheProvider.getCommonProperties(null, definition))
.isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(() -> cacheProvider.getCommonProperties(instanceId, (ToscaConceptIdentifier) null))
+ .isInstanceOf(NullPointerException.class);
assertThatThrownBy(() -> cacheProvider.getCommonProperties(instanceId, (UUID) null))
.isInstanceOf(NullPointerException.class);
assertThatThrownBy(() -> cacheProvider.getCommonProperties(null, instanceId))
@@ -73,9 +97,6 @@ class CacheProviderTest {
.isInstanceOf(NullPointerException.class);
assertThatThrownBy(() -> cacheProvider.removeElementDefinition(null)).isInstanceOf(NullPointerException.class);
-
- assertThatThrownBy(() -> cacheProvider.initializeAutomationComposition(null, null))
- .isInstanceOf(NullPointerException.class);
}
@Test
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ThreadHandlerTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ThreadHandlerTest.java
index d05471901..8502becbb 100644
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ThreadHandlerTest.java
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ThreadHandlerTest.java
@@ -98,7 +98,7 @@ class ThreadHandlerTest {
var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
properties, properties);
var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(),
- null, properties, properties);
+ properties, properties);
var messageId = UUID.randomUUID();
threadHandler.deploy(messageId, compositionElement, instanceElement);
verify(listener, timeout(TIMEOUT)).deploy(compositionElement, instanceElement);
@@ -108,7 +108,7 @@ class ThreadHandlerTest {
var elementId = UUID.randomUUID();
element.setId(elementId);
var instanceElementUpdated = new InstanceElementDto(instanceElement.instanceId(),
- instanceElement.elementId(), null, properties, properties);
+ instanceElement.elementId(), properties, properties);
threadHandler.update(messageId, compositionElement, instanceElement, instanceElementUpdated);
verify(listener, timeout(TIMEOUT)).update(compositionElement, instanceElement, instanceElementUpdated);
@@ -142,7 +142,7 @@ class ThreadHandlerTest {
properties, properties);
var instanceId = UUID.randomUUID();
var elementId = UUID.randomUUID();
- var instanceElement = new InstanceElementDto(instanceId, elementId, null, properties, properties);
+ var instanceElement = new InstanceElementDto(instanceId, elementId, properties, properties);
var element = new AcElementDeploy();
element.setId(elementId);
doThrow(new PfModelException(Status.INTERNAL_SERVER_ERROR, "Error")).when(listener)
@@ -155,7 +155,7 @@ class ThreadHandlerTest {
clearInvocations(listener);
var instanceElementUpdated = new InstanceElementDto(instanceElement.instanceId(),
- instanceElement.elementId(), null, properties, properties);
+ instanceElement.elementId(), properties, properties);
doThrow(new PfModelException(Status.INTERNAL_SERVER_ERROR, "Error")).when(listener)
.update(compositionElement, instanceElement, instanceElementUpdated);
threadHandler.update(messageId, compositionElement, instanceElement, instanceElementUpdated);
@@ -203,7 +203,7 @@ class ThreadHandlerTest {
var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
properties, properties);
var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(),
- null, properties, properties);
+ properties, properties);
var messageId = UUID.randomUUID();
threadHandler.lock(messageId, compositionElement, instanceElement);
verify(listener, timeout(TIMEOUT)).lock(compositionElement, instanceElement);
@@ -229,7 +229,7 @@ class ThreadHandlerTest {
properties, properties);
var instanceId = UUID.randomUUID();
var elementId = UUID.randomUUID();
- var instanceElement = new InstanceElementDto(instanceId, elementId, null, properties, properties);
+ var instanceElement = new InstanceElementDto(instanceId, elementId, properties, properties);
var element = new AcElementDeploy();
element.setId(elementId);
var messageId = UUID.randomUUID();
@@ -258,7 +258,7 @@ class ThreadHandlerTest {
var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
properties, properties);
var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(),
- null, properties, properties);
+ properties, properties);
var messageId = UUID.randomUUID();
threadHandler.prepare(messageId, compositionElement, instanceElement);
verify(listener, timeout(TIMEOUT)).prepare(compositionElement, instanceElement);
@@ -269,7 +269,7 @@ class ThreadHandlerTest {
clearInvocations(listener);
var instanceElementMigrate = new InstanceElementDto(instanceElement.instanceId(),
- instanceElement.elementId(), null, properties, properties);
+ instanceElement.elementId(), properties, properties);
var compositionTargetId = UUID.randomUUID();
var compositionElementTarget = new CompositionElementDto(compositionTargetId, new ToscaConceptIdentifier(),
properties, properties);
@@ -291,7 +291,7 @@ class ThreadHandlerTest {
properties, properties);
var instanceId = UUID.randomUUID();
var elementId = UUID.randomUUID();
- var instanceElement = new InstanceElementDto(instanceId, elementId, null, properties, properties);
+ var instanceElement = new InstanceElementDto(instanceId, elementId, properties, properties);
var element = new AcElementDeploy();
element.setId(elementId);
doThrow(new PfModelException(Status.INTERNAL_SERVER_ERROR, "Error")).when(listener)
@@ -315,7 +315,7 @@ class ThreadHandlerTest {
var compositionElementTarget = new CompositionElementDto(compositionTargetId, new ToscaConceptIdentifier(),
properties, properties);
var instanceElementMigrate = new InstanceElementDto(instanceElement.instanceId(),
- instanceElement.elementId(), null, properties, properties);
+ instanceElement.elementId(), properties, properties);
doThrow(new PfModelException(Status.INTERNAL_SERVER_ERROR, "Error")).when(listener)
.migratePrecheck(compositionElement, compositionElementTarget, instanceElement, instanceElementMigrate);
threadHandler.migratePrecheck(messageId, compositionElement, compositionElementTarget,
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java
index 5e11dbafd..bcde4c5c6 100644
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java
@@ -50,7 +50,6 @@ import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
/**
* Class to hold/create all parameters for test cases.
@@ -261,7 +260,6 @@ public class CommonTestData {
acElementRestart.setUseState("UseState");
acElementRestart.setProperties(Map.of("key", "value"));
acElementRestart.setOutProperties(Map.of("keyOut", "valueOut"));
- acElementRestart.setToscaServiceTemplateFragment(new ToscaServiceTemplate());
acElementRestart.setId(UUID.randomUUID());
participantRestartAc.getAcElementList().add(acElementRestart);
return participantRestartAc;
@@ -283,7 +281,6 @@ public class CommonTestData {
acElement.setId(element.getId());
acElement.setDefinition(element.getDefinition());
acElement.setProperties(element.getProperties());
- acElement.setToscaServiceTemplateFragment(new ToscaServiceTemplate());
participantDeploy.getAcElementList().add(acElement);
}
return participantDeploy;
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandler.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandler.java
index 4f564478f..05a866e43 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandler.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandler.java
@@ -43,7 +43,6 @@ import org.onap.policy.clamp.models.acm.concepts.ParticipantUtils;
import org.onap.policy.clamp.models.acm.concepts.StateChangeResult;
import org.onap.policy.clamp.models.acm.concepts.SubState;
import org.onap.policy.clamp.models.acm.messages.kafka.participant.AutomationCompositionDeployAck;
-import org.onap.policy.clamp.models.acm.persistence.provider.AcDefinitionProvider;
import org.onap.policy.clamp.models.acm.persistence.provider.AutomationCompositionProvider;
import org.onap.policy.clamp.models.acm.utils.AcmUtils;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
@@ -61,7 +60,6 @@ public class SupervisionAcHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(SupervisionAcHandler.class);
private final AutomationCompositionProvider automationCompositionProvider;
- private final AcDefinitionProvider acDefinitionProvider;
// Publishers for participant communication
private final AutomationCompositionDeployPublisher automationCompositionDeployPublisher;
@@ -96,8 +94,7 @@ public class SupervisionAcHandler {
automationComposition.setPhase(startPhase);
automationCompositionProvider.updateAutomationComposition(automationComposition);
executor.execute(
- () -> automationCompositionDeployPublisher.send(automationComposition, acDefinition.getServiceTemplate(),
- startPhase, true));
+ () -> automationCompositionDeployPublisher.send(automationComposition, startPhase, true));
}
/**
@@ -287,8 +284,7 @@ public class SupervisionAcHandler {
automationCompositionAckMessage.getStateChangeResult(), automationCompositionAckMessage.getStage());
if (updated) {
automationComposition = automationCompositionProvider.updateAcState(automationComposition);
- var acDefinition = acDefinitionProvider.getAcDefinition(automationComposition.getCompositionId());
- participantSyncPublisher.sendSync(acDefinition.getServiceTemplate(), automationComposition);
+ participantSyncPublisher.sendSync(automationComposition);
}
}
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java
index 3eb471609..5de6a4c74 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java
@@ -110,8 +110,7 @@ public class SupervisionParticipantHandler {
participantStatusMsg.getParticipantSupportedElementType(), false);
if (!participantStatusMsg.getAutomationCompositionInfoList().isEmpty()) {
- updateAcOutProperties(participantStatusMsg.getAutomationCompositionInfoList(),
- participantStatusMsg.getCompositionId());
+ updateAcOutProperties(participantStatusMsg.getAutomationCompositionInfoList());
}
if (!participantStatusMsg.getParticipantDefinitionUpdates().isEmpty()
&& participantStatusMsg.getCompositionId() != null) {
@@ -152,13 +151,11 @@ public class SupervisionParticipantHandler {
}
- private void updateAcOutProperties(List<AutomationCompositionInfo> automationCompositionInfoList,
- UUID compositionId) {
+ private void updateAcOutProperties(List<AutomationCompositionInfo> automationCompositionInfoList) {
automationCompositionProvider.upgradeStates(automationCompositionInfoList);
- var acDefinition = acDefinitionProvider.getAcDefinition(compositionId);
for (var acInfo : automationCompositionInfoList) {
var ac = automationCompositionProvider.getAutomationComposition(acInfo.getAutomationCompositionId());
- participantSyncPublisher.sendSync(acDefinition.getServiceTemplate(), ac);
+ participantSyncPublisher.sendSync(ac);
}
}
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java
index de2f37564..9b030eae1 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java
@@ -151,7 +151,7 @@ public class SupervisionScanner {
|| SubState.PREPARING.equals(automationComposition.getSubState())
|| SubState.REVIEWING.equals(automationComposition.getSubState())
|| SubState.MIGRATION_PRECHECKING.equals(automationComposition.getSubState())) {
- simpleScan(automationComposition, serviceTemplate);
+ simpleScan(automationComposition);
} else {
scanWithPhase(automationComposition, serviceTemplate);
}
@@ -187,7 +187,7 @@ public class SupervisionScanner {
}
if (completed) {
- complete(automationComposition, serviceTemplate);
+ complete(automationComposition);
} else {
LOGGER.debug("automation composition scan: transition state {} {} not completed",
automationComposition.getDeployState(), automationComposition.getLockState());
@@ -198,9 +198,9 @@ public class SupervisionScanner {
var nextSpNotCompleted = isForward ? minSpNotCompleted : maxSpNotCompleted;
if (nextSpNotCompleted != automationComposition.getPhase()) {
- sendAutomationCompositionMsg(automationComposition, serviceTemplate, nextSpNotCompleted);
+ sendAutomationCompositionMsg(automationComposition, nextSpNotCompleted);
} else {
- handleTimeout(automationComposition, serviceTemplate);
+ handleTimeout(automationComposition);
}
}
}
@@ -209,17 +209,16 @@ public class SupervisionScanner {
* Simple scan: UPDATE, PREPARE, REVIEW, MIGRATE_PRECHECKING.
*
* @param automationComposition the AutomationComposition
- * @param serviceTemplate the ToscaServiceTemplate
*/
- private void simpleScan(final AutomationComposition automationComposition, ToscaServiceTemplate serviceTemplate) {
+ private void simpleScan(final AutomationComposition automationComposition) {
var completed = automationComposition.getElements().values().stream()
.filter(element -> AcmUtils.isInTransitionalState(element.getDeployState(), element.getLockState(),
element.getSubState())).findFirst().isEmpty();
if (completed) {
- complete(automationComposition, serviceTemplate);
+ complete(automationComposition);
} else {
- handleTimeout(automationComposition, serviceTemplate);
+ handleTimeout(automationComposition);
}
}
@@ -246,7 +245,7 @@ public class SupervisionScanner {
}
if (completed) {
- complete(automationComposition, serviceTemplate);
+ complete(automationComposition);
} else {
LOGGER.debug("automation composition scan: transition from state {} to {} not completed",
automationComposition.getDeployState(), automationComposition.getLockState());
@@ -256,13 +255,12 @@ public class SupervisionScanner {
LOGGER.debug("retry message AutomationCompositionMigration");
automationCompositionMigrationPublisher.send(automationComposition, minStageNotCompleted);
} else {
- handleTimeout(automationComposition, serviceTemplate);
+ handleTimeout(automationComposition);
}
}
}
- private void complete(final AutomationComposition automationComposition,
- ToscaServiceTemplate serviceTemplate) {
+ private void complete(final AutomationComposition automationComposition) {
LOGGER.debug("automation composition scan: transition state {} {} {} completed",
automationComposition.getDeployState(), automationComposition.getLockState(),
automationComposition.getSubState());
@@ -287,7 +285,7 @@ public class SupervisionScanner {
} else {
acToUpdate = automationCompositionProvider.updateAcState(acToUpdate);
}
- participantSyncPublisher.sendSync(serviceTemplate, acToUpdate);
+ participantSyncPublisher.sendSync(acToUpdate);
}
private void handleTimeout(AutomationCompositionDefinition acDefinition) {
@@ -306,8 +304,7 @@ public class SupervisionScanner {
}
}
- private void handleTimeout(AutomationComposition automationComposition,
- ToscaServiceTemplate serviceTemplate) {
+ private void handleTimeout(AutomationComposition automationComposition) {
LOGGER.debug("automation composition scan: transition from state {} to {} {} not completed",
automationComposition.getDeployState(), automationComposition.getLockState(),
automationComposition.getSubState());
@@ -322,7 +319,7 @@ public class SupervisionScanner {
LOGGER.debug("Report timeout for the ac instance {}", automationComposition.getInstanceId());
automationComposition.setStateChangeResult(StateChangeResult.TIMEOUT);
automationCompositionProvider.updateAcState(automationComposition);
- participantSyncPublisher.sendSync(serviceTemplate, automationComposition);
+ participantSyncPublisher.sendSync(automationComposition);
}
}
@@ -332,14 +329,12 @@ public class SupervisionScanner {
automationCompositionProvider.updateAcState(automationComposition);
}
- private void sendAutomationCompositionMsg(AutomationComposition automationComposition,
- ToscaServiceTemplate serviceTemplate, int startPhase) {
+ private void sendAutomationCompositionMsg(AutomationComposition automationComposition, int startPhase) {
savePhase(automationComposition, startPhase);
if (DeployState.DEPLOYING.equals(automationComposition.getDeployState())) {
LOGGER.debug("retry message AutomationCompositionDeploy");
- automationCompositionDeployPublisher.send(automationComposition, serviceTemplate, startPhase,
- false);
+ automationCompositionDeployPublisher.send(automationComposition, startPhase, false);
} else {
LOGGER.debug("retry message AutomationCompositionStateChange");
automationCompositionStateChangePublisher.send(automationComposition, startPhase, false);
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionDeployPublisher.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionDeployPublisher.java
index 7fe63a7c5..d6d38ddf1 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionDeployPublisher.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionDeployPublisher.java
@@ -36,7 +36,6 @@ import org.onap.policy.clamp.models.acm.concepts.ParticipantDeploy;
import org.onap.policy.clamp.models.acm.messages.kafka.participant.AutomationCompositionDeploy;
import org.onap.policy.clamp.models.acm.messages.rest.instantiation.DeployOrder;
import org.onap.policy.clamp.models.acm.utils.AcmUtils;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@@ -59,14 +58,10 @@ public class AutomationCompositionDeployPublisher extends AbstractParticipantPub
*/
@Timed(value = "publisher.automation_composition_deploy",
description = "AUTOMATION_COMPOSITION_DEPLOY messages published")
- public void send(AutomationComposition automationComposition, ToscaServiceTemplate toscaServiceTemplate,
- int startPhase, boolean firstStartPhase) {
- var toscaServiceTemplateFragment = AcmUtils.getToscaServiceTemplateFragment(toscaServiceTemplate);
+ public void send(AutomationComposition automationComposition, int startPhase, boolean firstStartPhase) {
Map<UUID, List<AcElementDeploy>> map = new HashMap<>();
for (var element : automationComposition.getElements().values()) {
var acElementDeploy = AcmUtils.createAcElementDeploy(element, DeployOrder.DEPLOY);
- acElementDeploy.setToscaServiceTemplateFragment(toscaServiceTemplateFragment);
-
map.putIfAbsent(element.getParticipantId(), new ArrayList<>());
map.get(element.getParticipantId()).add(acElementDeploy);
}
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantSyncPublisher.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantSyncPublisher.java
index d90b6f667..3e42f940c 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantSyncPublisher.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantSyncPublisher.java
@@ -33,7 +33,6 @@ import org.onap.policy.clamp.models.acm.concepts.DeployState;
import org.onap.policy.clamp.models.acm.concepts.ParticipantRestartAc;
import org.onap.policy.clamp.models.acm.messages.kafka.participant.ParticipantSync;
import org.onap.policy.clamp.models.acm.utils.AcmUtils;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@@ -67,10 +66,9 @@ public class ParticipantSyncPublisher extends AbstractParticipantPublisher<Parti
message.setState(acmDefinition.getState());
message.setParticipantDefinitionUpdates(AcmUtils.prepareParticipantRestarting(participantId, acmDefinition,
acRuntimeParameterGroup.getAcmParameters().getToscaElementName()));
- var toscaServiceTemplateFragment = AcmUtils.getToscaServiceTemplateFragment(acmDefinition.getServiceTemplate());
for (var automationComposition : automationCompositions) {
- var syncAc = AcmUtils.createAcRestart(automationComposition, participantId, toscaServiceTemplateFragment);
+ var syncAc = AcmUtils.createAcRestart(automationComposition, participantId);
message.getAutomationcompositionList().add(syncAc);
}
@@ -117,11 +115,10 @@ public class ParticipantSyncPublisher extends AbstractParticipantPublisher<Parti
/**
* Send AutomationComposition sync msg to all Participants.
*
- * @param serviceTemplate the ServiceTemplate
* @param automationComposition the automationComposition
*/
@Timed(value = "publisher.participant_sync_msg", description = "Participant Sync published")
- public void sendSync(ToscaServiceTemplate serviceTemplate, AutomationComposition automationComposition) {
+ public void sendSync(AutomationComposition automationComposition) {
var message = new ParticipantSync();
message.setCompositionId(automationComposition.getCompositionId());
message.setAutomationCompositionId(automationComposition.getInstanceId());
@@ -136,10 +133,8 @@ public class ParticipantSyncPublisher extends AbstractParticipantPublisher<Parti
if (DeployState.DELETED.equals(automationComposition.getDeployState())) {
message.setDelete(true);
} else {
- var toscaServiceTemplateFragment = AcmUtils.getToscaServiceTemplateFragment(serviceTemplate);
for (var element : automationComposition.getElements().values()) {
var acElementSync = AcmUtils.createAcElementRestart(element);
- acElementSync.setToscaServiceTemplateFragment(toscaServiceTemplateFragment);
syncAc.getAcElementList().add(acElementSync);
}
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandlerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandlerTest.java
index b104084a8..c5345f2f1 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandlerTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandlerTest.java
@@ -45,14 +45,12 @@ import org.onap.policy.clamp.acm.runtime.util.CommonTestData;
import org.onap.policy.clamp.models.acm.concepts.AcElementDeployAck;
import org.onap.policy.clamp.models.acm.concepts.AcTypeState;
import org.onap.policy.clamp.models.acm.concepts.AutomationComposition;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionDefinition;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement;
import org.onap.policy.clamp.models.acm.concepts.DeployState;
import org.onap.policy.clamp.models.acm.concepts.LockState;
import org.onap.policy.clamp.models.acm.concepts.StateChangeResult;
import org.onap.policy.clamp.models.acm.messages.kafka.participant.AutomationCompositionDeployAck;
import org.onap.policy.clamp.models.acm.messages.kafka.participant.ParticipantMessageType;
-import org.onap.policy.clamp.models.acm.persistence.provider.AcDefinitionProvider;
import org.onap.policy.clamp.models.acm.persistence.provider.AutomationCompositionProvider;
class SupervisionAcHandlerTest {
@@ -62,7 +60,7 @@ class SupervisionAcHandlerTest {
@Test
void testAutomationCompositionDeployAckNull() {
var automationCompositionProvider = mock(AutomationCompositionProvider.class);
- var handler = new SupervisionAcHandler(automationCompositionProvider, mock(AcDefinitionProvider.class),
+ var handler = new SupervisionAcHandler(automationCompositionProvider,
mock(AutomationCompositionDeployPublisher.class), mock(AutomationCompositionStateChangePublisher.class),
mock(AcElementPropertiesPublisher.class), null,
mock(ParticipantSyncPublisher.class), null);
@@ -76,6 +74,9 @@ class SupervisionAcHandlerTest {
automationCompositionAckMessage.setStateChangeResult(null);
handler.handleAutomationCompositionStateChangeAckMessage(automationCompositionAckMessage);
+ automationCompositionAckMessage.setStateChangeResult(StateChangeResult.TIMEOUT);
+ handler.handleAutomationCompositionStateChangeAckMessage(automationCompositionAckMessage);
+
automationCompositionAckMessage.setStateChangeResult(StateChangeResult.NO_ERROR);
automationCompositionAckMessage.setAutomationCompositionId(null);
handler.handleAutomationCompositionStateChangeAckMessage(automationCompositionAckMessage);
@@ -102,11 +103,7 @@ class SupervisionAcHandlerTest {
when(automationCompositionProvider.updateAcState(any(AutomationComposition.class)))
.thenReturn(automationComposition);
- var acDefinitionProvider = mock(AcDefinitionProvider.class);
- when(acDefinitionProvider.getAcDefinition(automationComposition.getCompositionId()))
- .thenReturn(new AutomationCompositionDefinition());
-
- var handler = new SupervisionAcHandler(automationCompositionProvider, acDefinitionProvider,
+ var handler = new SupervisionAcHandler(automationCompositionProvider,
mock(AutomationCompositionDeployPublisher.class), mock(AutomationCompositionStateChangePublisher.class),
mock(AcElementPropertiesPublisher.class), null,
mock(ParticipantSyncPublisher.class), null);
@@ -132,11 +129,7 @@ class SupervisionAcHandlerTest {
when(automationCompositionProvider.updateAcState(any(AutomationComposition.class)))
.thenReturn(automationComposition);
- var acDefinitionProvider = mock(AcDefinitionProvider.class);
- when(acDefinitionProvider.getAcDefinition(automationComposition.getCompositionId()))
- .thenReturn(new AutomationCompositionDefinition());
-
- var handler = new SupervisionAcHandler(automationCompositionProvider, acDefinitionProvider,
+ var handler = new SupervisionAcHandler(automationCompositionProvider,
mock(AutomationCompositionDeployPublisher.class), mock(AutomationCompositionStateChangePublisher.class),
mock(AcElementPropertiesPublisher.class), null,
mock(ParticipantSyncPublisher.class), null);
@@ -175,16 +168,12 @@ class SupervisionAcHandlerTest {
when(automationCompositionProvider.updateAcState(any(AutomationComposition.class)))
.thenReturn(automationComposition);
- var acDefinitionProvider = mock(AcDefinitionProvider.class);
- when(acDefinitionProvider.getAcDefinition(automationComposition.getCompositionId()))
- .thenReturn(new AutomationCompositionDefinition());
-
var automationCompositionAckMessage =
getAutomationCompositionDeployAck(ParticipantMessageType.AUTOMATION_COMPOSITION_DEPLOY_ACK,
automationComposition, DeployState.DEPLOYED, LockState.LOCKED);
automationCompositionAckMessage.setParticipantId(CommonTestData.getParticipantId());
- var handler = new SupervisionAcHandler(automationCompositionProvider, acDefinitionProvider,
+ var handler = new SupervisionAcHandler(automationCompositionProvider,
mock(AutomationCompositionDeployPublisher.class), mock(AutomationCompositionStateChangePublisher.class),
mock(AcElementPropertiesPublisher.class), null,
mock(ParticipantSyncPublisher.class), null);
@@ -222,7 +211,7 @@ class SupervisionAcHandlerTest {
var automationCompositionStateChangePublisher = mock(AutomationCompositionStateChangePublisher.class);
- var handler = new SupervisionAcHandler(automationCompositionProvider, mock(AcDefinitionProvider.class),
+ var handler = new SupervisionAcHandler(automationCompositionProvider,
mock(AutomationCompositionDeployPublisher.class), automationCompositionStateChangePublisher, null,
null, mock(ParticipantSyncPublisher.class), null);
@@ -236,7 +225,7 @@ class SupervisionAcHandlerTest {
void testDeployFailed() {
var automationCompositionDeployPublisher = mock(AutomationCompositionDeployPublisher.class);
var automationCompositionProvider = mock(AutomationCompositionProvider.class);
- var handler = new SupervisionAcHandler(automationCompositionProvider, mock(AcDefinitionProvider.class),
+ var handler = new SupervisionAcHandler(automationCompositionProvider,
automationCompositionDeployPublisher, mock(AutomationCompositionStateChangePublisher.class),
mock(AcElementPropertiesPublisher.class), null,
mock(ParticipantSyncPublisher.class), null);
@@ -248,15 +237,14 @@ class SupervisionAcHandlerTest {
automationComposition.setStateChangeResult(StateChangeResult.FAILED);
handler.deploy(automationComposition, acDefinition);
verify(automationCompositionProvider).updateAutomationComposition(automationComposition);
- verify(automationCompositionDeployPublisher, timeout(1000))
- .send(automationComposition, acDefinition.getServiceTemplate(), 0, true);
+ verify(automationCompositionDeployPublisher, timeout(1000)).send(automationComposition, 0, true);
}
@Test
void testUndeploy() {
var automationCompositionProvider = mock(AutomationCompositionProvider.class);
var acStateChangePublisher = mock(AutomationCompositionStateChangePublisher.class);
- var handler = new SupervisionAcHandler(automationCompositionProvider, mock(AcDefinitionProvider.class),
+ var handler = new SupervisionAcHandler(automationCompositionProvider,
mock(AutomationCompositionDeployPublisher.class), acStateChangePublisher,
mock(AcElementPropertiesPublisher.class), null,
mock(ParticipantSyncPublisher.class), null);
@@ -274,7 +262,7 @@ class SupervisionAcHandlerTest {
void testUndeployFailed() {
var acStateChangePublisher = mock(AutomationCompositionStateChangePublisher.class);
var automationCompositionProvider = mock(AutomationCompositionProvider.class);
- var handler = new SupervisionAcHandler(automationCompositionProvider, mock(AcDefinitionProvider.class),
+ var handler = new SupervisionAcHandler(automationCompositionProvider,
mock(AutomationCompositionDeployPublisher.class), acStateChangePublisher,
mock(AcElementPropertiesPublisher.class), null,
mock(ParticipantSyncPublisher.class), null);
@@ -295,7 +283,7 @@ class SupervisionAcHandlerTest {
void testUnlock() {
var automationCompositionProvider = mock(AutomationCompositionProvider.class);
var acStateChangePublisher = mock(AutomationCompositionStateChangePublisher.class);
- var handler = new SupervisionAcHandler(automationCompositionProvider, mock(AcDefinitionProvider.class),
+ var handler = new SupervisionAcHandler(automationCompositionProvider,
mock(AutomationCompositionDeployPublisher.class), acStateChangePublisher,
mock(AcElementPropertiesPublisher.class), null,
mock(ParticipantSyncPublisher.class), null);
@@ -313,7 +301,7 @@ class SupervisionAcHandlerTest {
void testUnlockFailed() {
var automationCompositionProvider = mock(AutomationCompositionProvider.class);
var acStateChangePublisher = mock(AutomationCompositionStateChangePublisher.class);
- var handler = new SupervisionAcHandler(automationCompositionProvider, mock(AcDefinitionProvider.class),
+ var handler = new SupervisionAcHandler(automationCompositionProvider,
mock(AutomationCompositionDeployPublisher.class), acStateChangePublisher,
mock(AcElementPropertiesPublisher.class), null,
mock(ParticipantSyncPublisher.class), null);
@@ -333,7 +321,7 @@ class SupervisionAcHandlerTest {
void testLock() {
var automationCompositionProvider = mock(AutomationCompositionProvider.class);
var acStateChangePublisher = mock(AutomationCompositionStateChangePublisher.class);
- var handler = new SupervisionAcHandler(automationCompositionProvider, mock(AcDefinitionProvider.class),
+ var handler = new SupervisionAcHandler(automationCompositionProvider,
mock(AutomationCompositionDeployPublisher.class), acStateChangePublisher,
mock(AcElementPropertiesPublisher.class), null,
mock(ParticipantSyncPublisher.class), null);
@@ -351,7 +339,7 @@ class SupervisionAcHandlerTest {
void testLockFailed() {
var automationCompositionProvider = mock(AutomationCompositionProvider.class);
var acStateChangePublisher = mock(AutomationCompositionStateChangePublisher.class);
- var handler = new SupervisionAcHandler(automationCompositionProvider, mock(AcDefinitionProvider.class),
+ var handler = new SupervisionAcHandler(automationCompositionProvider,
mock(AutomationCompositionDeployPublisher.class), acStateChangePublisher,
mock(AcElementPropertiesPublisher.class), null,
mock(ParticipantSyncPublisher.class), null);
@@ -383,7 +371,7 @@ class SupervisionAcHandlerTest {
automationCompositionAckMessage.setAutomationCompositionId(IDENTIFIER);
automationCompositionAckMessage.setStateChangeResult(StateChangeResult.NO_ERROR);
- var handler = new SupervisionAcHandler(automationCompositionProvider, mock(AcDefinitionProvider.class),
+ var handler = new SupervisionAcHandler(automationCompositionProvider,
mock(AutomationCompositionDeployPublisher.class), mock(AutomationCompositionStateChangePublisher.class),
mock(AcElementPropertiesPublisher.class), null,
mock(ParticipantSyncPublisher.class), null);
@@ -398,7 +386,7 @@ class SupervisionAcHandlerTest {
void testUpdate() {
var acElementPropertiesPublisher = mock(AcElementPropertiesPublisher.class);
var handler = new SupervisionAcHandler(mock(AutomationCompositionProvider.class),
- mock(AcDefinitionProvider.class), mock(AutomationCompositionDeployPublisher.class),
+ mock(AutomationCompositionDeployPublisher.class),
mock(AutomationCompositionStateChangePublisher.class), acElementPropertiesPublisher, null,
mock(ParticipantSyncPublisher.class), null);
var automationComposition =
@@ -411,7 +399,7 @@ class SupervisionAcHandlerTest {
void testMigrate() {
var automationCompositionProvider = mock(AutomationCompositionProvider.class);
var acCompositionMigrationPublisher = mock(AutomationCompositionMigrationPublisher.class);
- var handler = new SupervisionAcHandler(automationCompositionProvider, mock(AcDefinitionProvider.class),
+ var handler = new SupervisionAcHandler(automationCompositionProvider,
null, null, null,
acCompositionMigrationPublisher, mock(ParticipantSyncPublisher.class), null);
var automationComposition =
@@ -425,7 +413,7 @@ class SupervisionAcHandlerTest {
void testMigratePrecheck() {
var automationCompositionProvider = mock(AutomationCompositionProvider.class);
var acCompositionMigrationPublisher = mock(AutomationCompositionMigrationPublisher.class);
- var handler = new SupervisionAcHandler(automationCompositionProvider, null, null, null,
+ var handler = new SupervisionAcHandler(automationCompositionProvider, null, null,
null, acCompositionMigrationPublisher, null, null);
var automationComposition =
InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Migrate");
@@ -437,7 +425,7 @@ class SupervisionAcHandlerTest {
void testPrepare() {
var automationCompositionProvider = mock(AutomationCompositionProvider.class);
var acPreparePublisher = mock(AcPreparePublisher.class);
- var handler = new SupervisionAcHandler(automationCompositionProvider, null, null, null,
+ var handler = new SupervisionAcHandler(automationCompositionProvider, null, null,
null, null, null, acPreparePublisher);
var automationComposition =
InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Migrate");
@@ -449,7 +437,7 @@ class SupervisionAcHandlerTest {
void testReview() {
var automationCompositionProvider = mock(AutomationCompositionProvider.class);
var acPreparePublisher = mock(AcPreparePublisher.class);
- var handler = new SupervisionAcHandler(automationCompositionProvider, null, null, null,
+ var handler = new SupervisionAcHandler(automationCompositionProvider, null, null,
null, null, null, acPreparePublisher);
var automationComposition =
InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Migrate");
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java
index 83a279cb7..e3387c668 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java
@@ -22,6 +22,7 @@ package org.onap.policy.clamp.acm.runtime.supervision;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.clearInvocations;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -62,17 +63,11 @@ class SupervisionParticipantHandlerTest {
@Test
void testHandleParticipantDeregister() {
- var replica = CommonTestData.createParticipantReplica(CommonTestData.getReplicaId());
-
- var participantProvider = mock(ParticipantProvider.class);
- when(participantProvider.findParticipantReplica(replica.getReplicaId()))
- .thenReturn(Optional.of(replica));
-
var participantDeregisterMessage = new ParticipantDeregister();
participantDeregisterMessage.setMessageId(UUID.randomUUID());
participantDeregisterMessage.setParticipantId(CommonTestData.getParticipantId());
- participantDeregisterMessage.setReplicaId(replica.getReplicaId());
var participantDeregisterAckPublisher = mock(ParticipantDeregisterAckPublisher.class);
+ var participantProvider = mock(ParticipantProvider.class);
var handler =
new SupervisionParticipantHandler(participantProvider, mock(ParticipantRegisterAckPublisher.class),
participantDeregisterAckPublisher, mock(AutomationCompositionProvider.class),
@@ -80,7 +75,14 @@ class SupervisionParticipantHandlerTest {
mock(AcRuntimeParameterGroup.class));
handler.handleParticipantMessage(participantDeregisterMessage);
+ verify(participantDeregisterAckPublisher).send(participantDeregisterMessage.getMessageId());
+ clearInvocations(participantDeregisterAckPublisher);
+ var replica = CommonTestData.createParticipantReplica(CommonTestData.getReplicaId());
+ participantDeregisterMessage.setReplicaId(replica.getReplicaId());
+ when(participantProvider.findParticipantReplica(replica.getReplicaId()))
+ .thenReturn(Optional.of(replica));
+ handler.handleParticipantMessage(participantDeregisterMessage);
verify(participantProvider).deleteParticipantReplica(CommonTestData.getReplicaId());
verify(participantDeregisterAckPublisher).send(participantDeregisterMessage.getMessageId());
}
@@ -120,6 +122,7 @@ class SupervisionParticipantHandlerTest {
var participant = new Participant();
var replica = new ParticipantReplica();
replica.setReplicaId(replicaId);
+ replica.setParticipantState(ParticipantState.OFF_LINE);
participant.setParticipantId(participantId);
participant.getReplicas().put(replica.getReplicaId(), replica);
var participantProvider = mock(ParticipantProvider.class);
@@ -177,15 +180,20 @@ class SupervisionParticipantHandlerTest {
when(acDefinitionProvider.getAcDefinition(acDefinition.getCompositionId())).thenReturn(acDefinition);
var participantProvider = mock(ParticipantProvider.class);
+ var participant = CommonTestData.createParticipant(CommonTestData.getParticipantId());
+ when(participantProvider.findParticipant(CommonTestData.getParticipantId()))
+ .thenReturn(Optional.of(participant));
+ var replica = CommonTestData.createParticipantReplica(CommonTestData.getReplicaId());
+ participantStatusMessage.setReplicaId(replica.getReplicaId());
+ when(participantProvider.findParticipantReplica(replica.getReplicaId()))
+ .thenReturn(Optional.of(replica));
+
var automationCompositionProvider = mock(AutomationCompositionProvider.class);
var handler =
new SupervisionParticipantHandler(participantProvider, mock(ParticipantRegisterAckPublisher.class),
mock(ParticipantDeregisterAckPublisher.class), automationCompositionProvider,
acDefinitionProvider, mock(ParticipantSyncPublisher.class),
mock(AcRuntimeParameterGroup.class));
- var participant = CommonTestData.createParticipant(CommonTestData.getParticipantId());
- when(participantProvider.findParticipant(CommonTestData.getParticipantId()))
- .thenReturn(Optional.of(participant));
handler.handleParticipantMessage(participantStatusMessage);
verify(automationCompositionProvider).upgradeStates(any());
@@ -228,25 +236,18 @@ class SupervisionParticipantHandlerTest {
@Test
void testHandleParticipantStatusNotRegisterd() {
var participantStatusMessage = createParticipantStatus();
- participantStatusMessage.setAutomationCompositionInfoList(List.of(new AutomationCompositionInfo()));
+ participantStatusMessage.setAutomationCompositionInfoList(List.of());
participantStatusMessage.setCompositionId(UUID.randomUUID());
- var acDefinitionProvider = mock(AcDefinitionProvider.class);
- var acDefinition = new AutomationCompositionDefinition();
- acDefinition.setCompositionId(participantStatusMessage.getCompositionId());
- when(acDefinitionProvider.getAcDefinition(acDefinition.getCompositionId())).thenReturn(acDefinition);
-
var participantProvider = mock(ParticipantProvider.class);
- var automationCompositionProvider = mock(AutomationCompositionProvider.class);
var handler =
new SupervisionParticipantHandler(participantProvider, mock(ParticipantRegisterAckPublisher.class),
- mock(ParticipantDeregisterAckPublisher.class), automationCompositionProvider,
- acDefinitionProvider, mock(ParticipantSyncPublisher.class),
+ mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionProvider.class),
+ mock(AcDefinitionProvider.class), mock(ParticipantSyncPublisher.class),
mock(AcRuntimeParameterGroup.class));
handler.handleParticipantMessage(participantStatusMessage);
verify(participantProvider).saveParticipant(any());
- verify(automationCompositionProvider).upgradeStates(any());
}
@Test
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java
index b425c4b80..ddb8a3332 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java
@@ -54,7 +54,6 @@ import org.onap.policy.clamp.models.acm.concepts.SubState;
import org.onap.policy.clamp.models.acm.persistence.provider.AcDefinitionProvider;
import org.onap.policy.clamp.models.acm.persistence.provider.AutomationCompositionProvider;
import org.onap.policy.clamp.models.acm.utils.TimestampHelper;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
class SupervisionScannerTest {
@@ -282,7 +281,7 @@ class SupervisionScannerTest {
automationComposition.setLastMsg(TimestampHelper.now());
scannerObj2.run();
verify(automationCompositionProvider).updateAcState(any(AutomationComposition.class));
- verify(participantSyncPublisher).sendSync(any(ToscaServiceTemplate.class), any(AutomationComposition.class));
+ verify(participantSyncPublisher).sendSync(any(AutomationComposition.class));
assertEquals(StateChangeResult.TIMEOUT, automationComposition.getStateChangeResult());
//already in TIMEOUT
@@ -291,7 +290,7 @@ class SupervisionScannerTest {
scannerObj2.run();
verify(automationCompositionProvider, times(0)).updateAutomationComposition(any(AutomationComposition.class));
verify(participantSyncPublisher, times(0))
- .sendSync(any(ToscaServiceTemplate.class), any(AutomationComposition.class));
+ .sendSync(any(AutomationComposition.class));
clearInvocations(automationCompositionProvider);
clearInvocations(participantSyncPublisher);
@@ -300,7 +299,7 @@ class SupervisionScannerTest {
}
scannerObj2.run();
verify(automationCompositionProvider).updateAcState(any(AutomationComposition.class));
- verify(participantSyncPublisher).sendSync(any(ToscaServiceTemplate.class), any(AutomationComposition.class));
+ verify(participantSyncPublisher).sendSync(any(AutomationComposition.class));
assertEquals(StateChangeResult.NO_ERROR, automationComposition.getStateChangeResult());
}
@@ -334,8 +333,7 @@ class SupervisionScannerTest {
supervisionScanner.run();
- verify(automationCompositionDeployPublisher).send(any(AutomationComposition.class),
- any(ToscaServiceTemplate.class), anyInt(), anyBoolean());
+ verify(automationCompositionDeployPublisher).send(any(AutomationComposition.class), anyInt(), anyBoolean());
}
@Test
@@ -370,8 +368,8 @@ class SupervisionScannerTest {
supervisionScanner.run();
- verify(automationCompositionDeployPublisher, times(0)).send(any(AutomationComposition.class),
- any(ToscaServiceTemplate.class), anyInt(), anyBoolean());
+ verify(automationCompositionDeployPublisher, times(0))
+ .send(any(AutomationComposition.class), anyInt(), anyBoolean());
}
@Test
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/comm/SupervisionMessagesTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/comm/SupervisionMessagesTest.java
index 04c883890..4e862c4e9 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/comm/SupervisionMessagesTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/comm/SupervisionMessagesTest.java
@@ -23,6 +23,7 @@ package org.onap.policy.clamp.acm.runtime.supervision.comm;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.clearInvocations;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -263,10 +264,14 @@ class SupervisionMessagesTest {
var topicSink = mock(TopicSink.class);
publisher.active(topicSink);
- var serviceTemplate = InstantiationUtils.getToscaServiceTemplate(TOSCA_SERVICE_TEMPLATE_YAML);
var automationComposition =
InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_UPDATE_JSON, "Crud");
- publisher.sendSync(serviceTemplate, automationComposition);
+ publisher.sendSync(automationComposition);
+ verify(topicSink).send(anyString());
+
+ clearInvocations(topicSink);
+ automationComposition.setDeployState(DeployState.DELETED);
+ publisher.sendSync(automationComposition);
verify(topicSink).send(anyString());
}