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"
# ============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.
#
# 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
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
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
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
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=
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:
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=
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:
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=
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
-
# ============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.
# 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
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
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
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:
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
/*-
* ============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.
@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.
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.
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;
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 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());
for (var element : automationComposition.getElements().values()) {
if (participantId.equals(element.getParticipantId())) {
var acElementSync = createAcElementRestart(element);
- acElementSync.setToscaServiceTemplateFragment(serviceTemplateFragment);
syncAc.getAcElementList().add(acElementSync);
}
}
assertThat(result).isNotEmpty().hasSize(1);
}
- @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();
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);
}
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 {
* @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.
*
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;
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;
@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(),
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,
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());
+ }
+ }
}
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;
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;
class AutomationCompositionElementHandlerTest {
+ private static final Coder CODER = new StandardCoder();
+
private static final ToscaConceptIdentifier DEFINITION =
new ToscaConceptIdentifier("1.0.1", "org.onap.PM_CDS_Blueprint");
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
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,
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
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
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(
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(
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(
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(
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(
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
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(
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(
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(
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(
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(
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(
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);
}
}
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());
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());
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);
}
}
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());
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);
}
}
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;
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);
}
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);
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);
}
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);
}
}
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);
}
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());
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);
}
}
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());
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);
}
}
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
// 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,
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
@Getter
private final Map<UUID, UUID> msgIdentification = new ConcurrentHashMap<>();
- @Getter
- private final Map<UUID, ToscaServiceTemplate> serviceTemplateFragmentMap = new ConcurrentHashMap<>();
-
/**
* Constructor.
*
public void removeElementDefinition(@NonNull UUID compositionId) {
acElementsDefinitions.remove(compositionId);
- serviceTemplateFragmentMap.remove(compositionId);
}
/**
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);
}
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();
*/
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;
*/
public static InstanceElementDto changeStateToNew(InstanceElementDto instanceElement) {
return new InstanceElementDto(instanceElement.instanceId(), instanceElement.elementId(),
- instanceElement.toscaServiceTemplateFragment(),
instanceElement.inProperties(), instanceElement.outProperties(), ElementState.NEW);
}
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());
}
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());
}
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");
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");
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,
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");
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,
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,
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,
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,
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");
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");
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,
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");
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,
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,
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,
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,
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");
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");
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,
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");
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,
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,
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,
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,
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;
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 {
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());
+ }
}
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;
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
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());
}
}
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
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
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
ach.handleAutomationCompositionMigration(migrationMsg);
verify(listener, times(expectedMigrated)).migrate(any(), any(), any(), any(), any(), anyInt());
}
-
}
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 {
}
@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);
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))
.isInstanceOf(NullPointerException.class);
assertThatThrownBy(() -> cacheProvider.removeElementDefinition(null)).isInstanceOf(NullPointerException.class);
-
- assertThatThrownBy(() -> cacheProvider.initializeAutomationComposition(null, null))
- .isInstanceOf(NullPointerException.class);
}
@Test
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);
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);
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)
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);
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);
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();
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);
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);
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)
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,
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.
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;
acElement.setId(element.getId());
acElement.setDefinition(element.getDefinition());
acElement.setProperties(element.getProperties());
- acElement.setToscaServiceTemplateFragment(new ToscaServiceTemplate());
participantDeploy.getAcElementList().add(acElement);
}
return participantDeploy;
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;
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;
automationComposition.setPhase(startPhase);
automationCompositionProvider.updateAutomationComposition(automationComposition);
executor.execute(
- () -> automationCompositionDeployPublisher.send(automationComposition, acDefinition.getServiceTemplate(),
- startPhase, true));
+ () -> automationCompositionDeployPublisher.send(automationComposition, startPhase, true));
}
/**
automationCompositionAckMessage.getStateChangeResult(), automationCompositionAckMessage.getStage());
if (updated) {
automationComposition = automationCompositionProvider.updateAcState(automationComposition);
- var acDefinition = acDefinitionProvider.getAcDefinition(automationComposition.getCompositionId());
- participantSyncPublisher.sendSync(acDefinition.getServiceTemplate(), automationComposition);
+ participantSyncPublisher.sendSync(automationComposition);
}
}
participantStatusMsg.getParticipantSupportedElementType(), false);
if (!participantStatusMsg.getAutomationCompositionInfoList().isEmpty()) {
- updateAcOutProperties(participantStatusMsg.getAutomationCompositionInfoList(),
- participantStatusMsg.getCompositionId());
+ updateAcOutProperties(participantStatusMsg.getAutomationCompositionInfoList());
}
if (!participantStatusMsg.getParticipantDefinitionUpdates().isEmpty()
&& participantStatusMsg.getCompositionId() != null) {
}
- 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);
}
}
|| 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);
}
}
if (completed) {
- complete(automationComposition, serviceTemplate);
+ complete(automationComposition);
} else {
LOGGER.debug("automation composition scan: transition state {} {} not completed",
automationComposition.getDeployState(), automationComposition.getLockState());
var nextSpNotCompleted = isForward ? minSpNotCompleted : maxSpNotCompleted;
if (nextSpNotCompleted != automationComposition.getPhase()) {
- sendAutomationCompositionMsg(automationComposition, serviceTemplate, nextSpNotCompleted);
+ sendAutomationCompositionMsg(automationComposition, nextSpNotCompleted);
} else {
- handleTimeout(automationComposition, serviceTemplate);
+ handleTimeout(automationComposition);
}
}
}
* 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);
}
}
}
if (completed) {
- complete(automationComposition, serviceTemplate);
+ complete(automationComposition);
} else {
LOGGER.debug("automation composition scan: transition from state {} to {} not completed",
automationComposition.getDeployState(), automationComposition.getLockState());
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());
} else {
acToUpdate = automationCompositionProvider.updateAcState(acToUpdate);
}
- participantSyncPublisher.sendSync(serviceTemplate, acToUpdate);
+ participantSyncPublisher.sendSync(acToUpdate);
}
private void handleTimeout(AutomationCompositionDefinition acDefinition) {
}
}
- 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());
LOGGER.debug("Report timeout for the ac instance {}", automationComposition.getInstanceId());
automationComposition.setStateChangeResult(StateChangeResult.TIMEOUT);
automationCompositionProvider.updateAcState(automationComposition);
- participantSyncPublisher.sendSync(serviceTemplate, automationComposition);
+ participantSyncPublisher.sendSync(automationComposition);
}
}
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);
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;
*/
@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);
}
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;
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);
}
/**
* 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());
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);
}
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 {
@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);
automationCompositionAckMessage.setStateChangeResult(null);
handler.handleAutomationCompositionStateChangeAckMessage(automationCompositionAckMessage);
+ automationCompositionAckMessage.setStateChangeResult(StateChangeResult.TIMEOUT);
+ handler.handleAutomationCompositionStateChangeAckMessage(automationCompositionAckMessage);
+
automationCompositionAckMessage.setStateChangeResult(StateChangeResult.NO_ERROR);
automationCompositionAckMessage.setAutomationCompositionId(null);
handler.handleAutomationCompositionStateChangeAckMessage(automationCompositionAckMessage);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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 =
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 =
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");
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");
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");
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;
@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),
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());
}
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);
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());
@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
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 {
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
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);
}
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());
}
supervisionScanner.run();
- verify(automationCompositionDeployPublisher).send(any(AutomationComposition.class),
- any(ToscaServiceTemplate.class), anyInt(), anyBoolean());
+ verify(automationCompositionDeployPublisher).send(any(AutomationComposition.class), anyInt(), anyBoolean());
}
@Test
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
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;
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());
}