aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/functions
diff options
context:
space:
mode:
Diffstat (limited to 'ms/blueprintsprocessor/functions')
-rw-r--r--ms/blueprintsprocessor/functions/ansible-awx-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/ansible/executor/ComponentRemoteAnsibleExecutor.kt89
-rw-r--r--ms/blueprintsprocessor/functions/ansible-awx-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/ansible/executor/ComponentRemoteAnsibleExecutorTest.kt52
-rw-r--r--ms/blueprintsprocessor/functions/cli-executor/src/main/kotlin/internal/scripts/InternalSimpleCli.kt2
-rw-r--r--ms/blueprintsprocessor/functions/cli-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/cli/executor/CliExecutorConfiguration.kt2
-rw-r--r--ms/blueprintsprocessor/functions/cli-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/cli/executor/CliExecutorExtensions.kt1
-rw-r--r--ms/blueprintsprocessor/functions/cli-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/cli/executor/ComponentCliExecutorTest.kt26
-rw-r--r--ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/ComponentConfigSnapshotsExecutor.kt68
-rw-r--r--ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshot.kt11
-rw-r--r--ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotRepository.kt6
-rw-r--r--ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotService.kt79
-rw-r--r--ms/blueprintsprocessor/functions/config-snapshots/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/ComponentConfigSnapshotsExecutorTest.kt255
-rw-r--r--ms/blueprintsprocessor/functions/config-snapshots/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotServiceTest.kt4
-rw-r--r--ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/AbstractMessagePrioritizeProcessor.kt (renamed from ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/AbstractTopologyComponents.kt)6
-rw-r--r--ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/MessagePrioritizationConfiguration.kt3
-rw-r--r--ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/MessagePrioritizationConsumer.kt83
-rw-r--r--ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/MessagePrioritizationData.kt7
-rw-r--r--ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/MessagePrioritizeExtensions.kt9
-rw-r--r--ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/api/MessagePrioritizationApi.kt33
-rw-r--r--ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/db/MessagePrioritization.kt (renamed from ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/db/PrioritizationMessageEntity.kt)14
-rw-r--r--ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/db/MessagePrioritizationRepositories.kt118
-rw-r--r--ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/db/PrioritizationMessageRepository.kt160
-rw-r--r--ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/service/MessagePrioritizationStateService.kt93
-rw-r--r--ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/topology/MessageAggregateProcessor.kt22
-rw-r--r--ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/topology/MessageOutputProcessor.kt3
-rw-r--r--ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/topology/MessagePrioritizationPunctuators.kt33
-rw-r--r--ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/topology/MessagePrioritizationSerde.kt (renamed from ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/topology/MessagePrioritizationSerdes.kt)4
-rw-r--r--ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/topology/MessagePrioritizeProcessor.kt69
-rw-r--r--ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/utils/MessageCorrelationUtils.kt10
-rw-r--r--ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/utils/MessagePrioritizationSample.kt39
-rw-r--r--ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/utils/MessageProcessorUtils.kt7
-rw-r--r--ms/blueprintsprocessor/functions/message-prioritizaion/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/MessagePrioritizationConsumerTest.kt100
-rw-r--r--ms/blueprintsprocessor/functions/message-prioritizaion/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/TestConfiguration.kt3
-rw-r--r--ms/blueprintsprocessor/functions/message-prioritizaion/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/utils/MessageCorrelationUtilsTest.kt83
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutor.kt16
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/JsonParserService.kt4
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/NetconfComponentFunction.kt60
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/NetconfDevice.kt2
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/NetconfExecutorConfiguration.kt2
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/NetconfExecutorExtensions.kt11
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/DeviceInfo.kt3
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/NetconfException.kt3
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/NetconfMessage.kt23
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/NetconfRpcService.kt17
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/NetconfSession.kt3
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfDeviceCommunicator.kt88
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImpl.kt17
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionImpl.kt77
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionListenerImpl.kt3
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/utils/NetconfMessageUtils.kt83
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutorTest.kt27
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/DeviceInfoTest.kt17
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/NetconfMessageTest.kt7
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfDeviceCommunicatorTest.kt117
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfMessageStateTest.kt149
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImplTest.kt17
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionImplTest.kt144
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionListenerImplTest.kt26
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/utils/NetconfMessageUtilsTest.kt28
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/utils/RpcMessageUtilsTest.kt131
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentJythonExecutor.kt19
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutor.kt43
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorDSL.kt93
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/JythonComponentFunction.kt3
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentJythonExecutorTest.kt29
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorDSLTest.kt18
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorTest.kt104
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/mock/MockInstanceConfiguration.kt5
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceAssignmentRuntimeService.kt9
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceDefinitionDSL.kt73
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt45
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSL.kt133
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConfiguration.kt2
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt24
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionExtensions.kt19
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt351
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceDSL.kt244
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt2
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolution.kt29
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBService.kt101
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionRepository.kt40
-rwxr-xr-xms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolution.kt23
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionRepository.kt12
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionService.kt107
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt7
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt22
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt3
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessor.kt31
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt37
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt13
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt73
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceDefinitionUtils.kt17
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/scripts/SimpleRAProcessor.kt (renamed from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/scripts/InternalRAProcessor.cba.kt)0
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceDefinitionDSLTest.kt26
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSLTest.kt12
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt44
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt190
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceDSLTest.kt24
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBServiceTest.kt47
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionServiceTest.kt35
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBluePrintRestLibPropertyService.kt (renamed from ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBlueprintResLibPropertyService.kt)6
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBlueprintWebClientService.kt44
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockDatabaseConfiguration.kt6
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockRestResourceResolutionProcessor.kt25
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt8
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceResolutionProcessorTest.kt19
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessorTest.kt5
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessorTest.kt5
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessorTest.kt24
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtilsTest.kt144
-rw-r--r--ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/internal/scripts/InternalSimpleRestconf.kt8
-rw-r--r--ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restconf/executor/RestconfExecutorConfiguration.kt3
-rw-r--r--ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restconf/executor/RestconfExecutorExtensions.kt42
-rw-r--r--ms/blueprintsprocessor/functions/restconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restconf/executor/ComponentRestconfExecutorTest.kt16
113 files changed, 3080 insertions, 1953 deletions
diff --git a/ms/blueprintsprocessor/functions/ansible-awx-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/ansible/executor/ComponentRemoteAnsibleExecutor.kt b/ms/blueprintsprocessor/functions/ansible-awx-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/ansible/executor/ComponentRemoteAnsibleExecutor.kt
index 3a655ded7..9ea6034a8 100644
--- a/ms/blueprintsprocessor/functions/ansible-awx-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/ansible/executor/ComponentRemoteAnsibleExecutor.kt
+++ b/ms/blueprintsprocessor/functions/ansible-awx-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/ansible/executor/ComponentRemoteAnsibleExecutor.kt
@@ -24,7 +24,12 @@ import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInpu
import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BluePrintRestLibPropertyService
import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService
import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractComponentFunction
-import org.onap.ccsdk.cds.controllerblueprints.core.*
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonNode
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonString
+import org.onap.ccsdk.cds.controllerblueprints.core.isNullOrMissing
+import org.onap.ccsdk.cds.controllerblueprints.core.returnNullIfMissing
+import org.onap.ccsdk.cds.controllerblueprints.core.rootFieldsToMap
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.config.ConfigurableBeanFactory
@@ -33,7 +38,7 @@ import org.springframework.http.HttpMethod
import org.springframework.stereotype.Component
import java.net.URI
import java.net.URLEncoder
-import java.util.*
+import java.util.NoSuchElementException
/**
* ComponentRemoteAnsibleExecutor
@@ -48,9 +53,11 @@ import java.util.*
*/
@Component("component-remote-ansible-executor")
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-open class ComponentRemoteAnsibleExecutor(private val blueprintRestLibPropertyService: BluePrintRestLibPropertyService,
- private val mapper: ObjectMapper)
- : AbstractComponentFunction() {
+open class ComponentRemoteAnsibleExecutor(
+ private val blueprintRestLibPropertyService: BluePrintRestLibPropertyService,
+ private val mapper: ObjectMapper
+) :
+ AbstractComponentFunction() {
// HTTP related constants
private val HTTP_SUCCESS = 200..202
@@ -98,7 +105,7 @@ open class ComponentRemoteAnsibleExecutor(private val blueprintRestLibPropertySe
if (jtId.isNotEmpty()) {
runJobTemplateOnAWX(restClientService, jobTemplateName, jtId, workflowURIPrefix)
} else {
- val message = "Workflow/Job template ${jobTemplateName} does not exists"
+ val message = "Workflow/Job template $jobTemplateName does not exists"
log.error(message)
setNodeOutputErrors(ATTRIBUTE_EXEC_CMD_STATUS_ERROR, message)
}
@@ -108,7 +115,6 @@ open class ComponentRemoteAnsibleExecutor(private val blueprintRestLibPropertySe
}
}
-
override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
val message = "Error in ComponentRemoteAnsibleExecutor : ${runtimeException.message}"
log.error(message, runtimeException)
@@ -143,11 +149,16 @@ open class ComponentRemoteAnsibleExecutor(private val blueprintRestLibPropertySe
/**
* Finds the job template ID based on the job template name provided in the request
*/
- private fun lookupJobTemplateIDByName(awxClient: BlueprintWebClientService, job_template_name: String?,
- workflowPrefix : String) : String {
- val encodedJTName = URI(null, null,
- "/api/v2/${workflowPrefix}job_templates/${job_template_name}/",
- null, null).rawPath
+ private fun lookupJobTemplateIDByName(
+ awxClient: BlueprintWebClientService,
+ job_template_name: String?,
+ workflowPrefix: String
+ ): String {
+ val encodedJTName = URI(
+ null, null,
+ "/api/v2/${workflowPrefix}job_templates/$job_template_name/",
+ null, null
+ ).rawPath
// Get Job Template details by name
var response = awxClient.exchangeResource(GET, encodedJTName, "")
@@ -161,12 +172,16 @@ open class ComponentRemoteAnsibleExecutor(private val blueprintRestLibPropertySe
* its execution. Finally, it retrieves the job results via the stdout api.
* The status and output attributes are populated in the process.
*/
- private fun runJobTemplateOnAWX(awxClient: BlueprintWebClientService, job_template_name: String?, jtId: String,
- workflowPrefix : String) {
- setNodeOutputProperties("preparing".asJsonPrimitive(), "".asJsonPrimitive(), "".asJsonPrimitive())
+ private fun runJobTemplateOnAWX(
+ awxClient: BlueprintWebClientService,
+ job_template_name: String?,
+ jtId: String,
+ workflowPrefix: String
+ ) {
+ setNodeOutputProperties("preparing".asJsonPrimitive(), "".asJsonPrimitive(), "".asJsonPrimitive())
// Get Job Template requirements
- var response = awxClient.exchangeResource(GET, "/api/v2/${workflowPrefix}job_templates/${jtId}/launch/", "")
+ var response = awxClient.exchangeResource(GET, "/api/v2/${workflowPrefix}job_templates/$jtId/launch/", "")
// FIXME: handle non-successful SC
val jtLaunchReqs: JsonNode = mapper.readTree(response.body)
val payload = prepareLaunchPayload(awxClient, jtLaunchReqs, workflowPrefix.isNotBlank())
@@ -175,7 +190,7 @@ open class ComponentRemoteAnsibleExecutor(private val blueprintRestLibPropertySe
// Launch the job for the targeted template
var jtLaunched: JsonNode = JacksonUtils.objectMapper.createObjectNode()
- response = awxClient.exchangeResource(POST, "/api/v2/${workflowPrefix}job_templates/${jtId}/launch/", payload)
+ response = awxClient.exchangeResource(POST, "/api/v2/${workflowPrefix}job_templates/$jtId/launch/", payload)
if (response.status in HTTP_SUCCESS) {
jtLaunched = mapper.readTree(response.body)
val fieldsIgnored: JsonNode = jtLaunched.at("/ignored_fields")
@@ -191,7 +206,7 @@ open class ComponentRemoteAnsibleExecutor(private val blueprintRestLibPropertySe
var jobStatus = "unknown"
var jobEndTime = "null"
while (jobEndTime == "null") {
- response = awxClient.exchangeResource(GET, "/api/v2/${workflowPrefix}jobs/${jobId}/", "")
+ response = awxClient.exchangeResource(GET, "/api/v2/${workflowPrefix}jobs/$jobId/", "")
val jobLaunched: JsonNode = mapper.readTree(response.body)
jobStatus = jobLaunched.at("/status").asText()
jobEndTime = jobLaunched.at("/finished").asText()
@@ -201,7 +216,6 @@ open class ComponentRemoteAnsibleExecutor(private val blueprintRestLibPropertySe
log.info("Execution of job template $job_template_name in job #$jobId finished with status ($jobStatus) for requestId $processId")
populateJobRunResponse(awxClient, jobId, workflowPrefix, jobStatus)
-
} else {
// The job template requirements were not fulfilled with the values passed in. The message below will
// provide more information via the response, like the ignored_fields, or variables_needed_to_start,
@@ -217,8 +231,12 @@ open class ComponentRemoteAnsibleExecutor(private val blueprintRestLibPropertySe
* Extracts the output from either a job stdout call OR collects the workflow run output, as well as the artifacts
* and populate the component corresponding output properties
*/
- private fun populateJobRunResponse(awxClient: BlueprintWebClientService, jobId: String, workflowPrefix: String,
- jobStatus: String) {
+ private fun populateJobRunResponse(
+ awxClient: BlueprintWebClientService,
+ jobId: String,
+ workflowPrefix: String,
+ jobStatus: String
+ ) {
val collectedResponses = StringBuilder(4096)
val artifacts: MutableMap<String, JsonNode> = mutableMapOf()
@@ -226,20 +244,20 @@ open class ComponentRemoteAnsibleExecutor(private val blueprintRestLibPropertySe
collectJobIdsRelatedToJobRun(awxClient, jobId, workflowPrefix).forEach { aJobId ->
// Collect the response text from the corresponding jobIds
- var response = awxClient.exchangeResource(GET, "/api/v2/jobs/${aJobId}/stdout/?format=txt", "", plainTextHeaders)
+ var response = awxClient.exchangeResource(GET, "/api/v2/jobs/$aJobId/stdout/?format=txt", "", plainTextHeaders)
if (response.status in HTTP_SUCCESS) {
val jobOutput = response.body
collectedResponses
- .append("Output for Job $aJobId :" + System.lineSeparator())
- .append(jobOutput)
- .append(System.lineSeparator())
- log.info("Response for job ${aJobId}: \n ${jobOutput} \n")
+ .append("Output for Job $aJobId :" + System.lineSeparator())
+ .append(jobOutput)
+ .append(System.lineSeparator())
+ log.info("Response for job $aJobId: \n $jobOutput \n")
} else {
- log.warn("Could not gather response for job ${aJobId}. Status=${response.status}")
+ log.warn("Could not gather response for job $aJobId. Status=${response.status}")
}
// Collect artifacts variables from each job and gather them up in one json node
- response = awxClient.exchangeResource(GET, "/api/v2/jobs/${aJobId}/", "")
+ response = awxClient.exchangeResource(GET, "/api/v2/jobs/$aJobId/", "")
if (response.status in HTTP_SUCCESS) {
val jobArtifacts = mapper.readTree(response.body).at("/artifacts")
if (jobArtifacts != null) {
@@ -248,7 +266,7 @@ open class ComponentRemoteAnsibleExecutor(private val blueprintRestLibPropertySe
}
}
- log.info("Artifacts for job ${jobId}: \n $artifacts \n")
+ log.info("Artifacts for job $jobId: \n $artifacts \n")
setNodeOutputProperties(jobStatus.asJsonPrimitive(), collectedResponses.toString().asJsonPrimitive(), artifacts.asJsonNode())
}
@@ -261,7 +279,7 @@ open class ComponentRemoteAnsibleExecutor(private val blueprintRestLibPropertySe
var jobIds: Array<String>
if (workflowPrefix.isNotEmpty()) {
- var response = awxClient.exchangeResource(GET, "/api/v2/${workflowPrefix}jobs/${jobId}/workflow_nodes/", "")
+ var response = awxClient.exchangeResource(GET, "/api/v2/${workflowPrefix}jobs/$jobId/workflow_nodes/", "")
val jobDetails = mapper.readTree(response.body).at("/results")
// gather up job Id of all actual job nodes that ran during the workflow
@@ -282,8 +300,11 @@ open class ComponentRemoteAnsibleExecutor(private val blueprintRestLibPropertySe
* by applying the overrides that were provided
* and allowed by the template definition flags in jtLaunchReqs
*/
- private fun prepareLaunchPayload(awxClient: BlueprintWebClientService, jtLaunchReqs: JsonNode,
- isWorkflow : Boolean): String {
+ private fun prepareLaunchPayload(
+ awxClient: BlueprintWebClientService,
+ jtLaunchReqs: JsonNode,
+ isWorkflow: Boolean
+ ): String {
val payload = JacksonUtils.objectMapper.createObjectNode()
// Parameter defaults
@@ -318,7 +339,7 @@ open class ComponentRemoteAnsibleExecutor(private val blueprintRestLibPropertySe
payload.set(INPUT_INVENTORY, inventoryKeyId)
}
- payload.set("extra_vars", extraArgs)
+ payload.set("extra_vars", extraArgs)
return payload.asJsonString(false)
}
@@ -363,7 +384,7 @@ open class ComponentRemoteAnsibleExecutor(private val blueprintRestLibPropertySe
/**
* Utility function to set the output properties and errors of the executor node, in cas of errors
*/
- private fun setNodeOutputErrors(status: String, message: String, artifacts: JsonNode = "".asJsonPrimitive() ) {
+ private fun setNodeOutputErrors(status: String, message: String, artifacts: JsonNode = "".asJsonPrimitive()) {
setAttribute(ATTRIBUTE_EXEC_CMD_STATUS, status.asJsonPrimitive())
setAttribute(ATTRIBUTE_EXEC_CMD_LOG, message.asJsonPrimitive())
setAttribute(ATTRIBUTE_EXEC_CMD_ARTIFACTS, artifacts)
diff --git a/ms/blueprintsprocessor/functions/ansible-awx-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/ansible/executor/ComponentRemoteAnsibleExecutorTest.kt b/ms/blueprintsprocessor/functions/ansible-awx-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/ansible/executor/ComponentRemoteAnsibleExecutorTest.kt
index 5e0905dec..262563d1f 100644
--- a/ms/blueprintsprocessor/functions/ansible-awx-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/ansible/executor/ComponentRemoteAnsibleExecutorTest.kt
+++ b/ms/blueprintsprocessor/functions/ansible-awx-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/ansible/executor/ComponentRemoteAnsibleExecutorTest.kt
@@ -73,20 +73,24 @@ class ComponentRemoteAnsibleExecutorTest {
webClientService.exchangeResource("GET", "/api/v2/inventories/?name=Demo+Inventory", "")
} returns WebClientResponse(200, getInventory())
every {
- webClientService.exchangeResource("POST", "/api/v2/job_templates/$jtId/launch/",
- """{"inventory":1,"extra_vars":{"site_id":"3 - Belmont","tor_group":"vEPC"}}""")
+ webClientService.exchangeResource(
+ "POST", "/api/v2/job_templates/$jtId/launch/",
+ """{"inventory":1,"extra_vars":{"site_id":"3 - Belmont","tor_group":"vEPC"}}"""
+ )
} returns WebClientResponse(201, newJobTemplateLaunch(jtId, jobId))
every {
webClientService.exchangeResource("GET", "/api/v2/jobs/$jobId/", "")
} returnsMany listOf(
- WebClientResponse(200, getJobStatus1(jtId, jobId)),
- WebClientResponse(200, getJobStatus2(jtId, jobId)),
- WebClientResponse(200, getJobStatus3(jtId, jobId)),
- WebClientResponse(200, getJobStatus4(jtId, jobId))
+ WebClientResponse(200, getJobStatus1(jtId, jobId)),
+ WebClientResponse(200, getJobStatus2(jtId, jobId)),
+ WebClientResponse(200, getJobStatus3(jtId, jobId)),
+ WebClientResponse(200, getJobStatus4(jtId, jobId))
)
every {
- webClientService.exchangeResource("GET", "/api/v2/jobs/$jobId/stdout/?format=txt", "",
- mapOf("Accept" to "text/plain"))
+ webClientService.exchangeResource(
+ "GET", "/api/v2/jobs/$jobId/stdout/?format=txt", "",
+ mapOf("Accept" to "text/plain")
+ )
} returns WebClientResponse(200, getReport())
val selector = mapper.readTree(endpointSelector)
val bluePrintRestLibPropertyService = mockk<BluePrintRestLibPropertyService>()
@@ -95,8 +99,9 @@ class ComponentRemoteAnsibleExecutorTest {
awxRemoteExecutor.checkDelay = 1
val executionServiceInput = JacksonUtils.readValueFromClassPathFile(
- "payload/requests/sample-remote-ansible-request.json",
- ExecutionServiceInput::class.java)!!
+ "payload/requests/sample-remote-ansible-request.json",
+ ExecutionServiceInput::class.java
+ )!!
val bluePrintRuntimeService = createBlueprintRuntimeService(awxRemoteExecutor, executionServiceInput)
@@ -128,8 +133,9 @@ class ComponentRemoteAnsibleExecutorTest {
awxRemoteExecutor.checkDelay = 1
val executionServiceInput = JacksonUtils.readValueFromClassPathFile(
- "payload/requests/remote-ansible-request-full.json",
- ExecutionServiceInput::class.java)!!
+ "payload/requests/remote-ansible-request-full.json",
+ ExecutionServiceInput::class.java
+ )!!
val bluePrintRuntimeService = createBlueprintRuntimeService(awxRemoteExecutor, executionServiceInput)
@@ -156,8 +162,10 @@ class ComponentRemoteAnsibleExecutorTest {
webClientService.exchangeResource("GET", "/api/v2/inventories/?name=Demo+Inventory", "")
} returns WebClientResponse(200, getInventory())
every {
- webClientService.exchangeResource("POST", "/api/v2/job_templates/$jtId/launch/",
- """{"limit":"123","tags":"some-tag","skip_tags":"some-skip-tag","inventory":1,"extra_vars":{"site_id":"3 - Belmont","tor_group":"vEPC"}}""")
+ webClientService.exchangeResource(
+ "POST", "/api/v2/job_templates/$jtId/launch/",
+ """{"limit":"123","tags":"some-tag","skip_tags":"some-skip-tag","inventory":1,"extra_vars":{"site_id":"3 - Belmont","tor_group":"vEPC"}}"""
+ )
} returns WebClientResponse(500, "")
val selector = mapper.readTree(endpointSelector)
val bluePrintRestLibPropertyService = mockk<BluePrintRestLibPropertyService>()
@@ -166,8 +174,9 @@ class ComponentRemoteAnsibleExecutorTest {
awxRemoteExecutor.checkDelay = 1
val executionServiceInput = JacksonUtils.readValueFromClassPathFile(
- "payload/requests/remote-ansible-request-full.json",
- ExecutionServiceInput::class.java)!!
+ "payload/requests/remote-ansible-request-full.json",
+ ExecutionServiceInput::class.java
+ )!!
val bluePrintRuntimeService = createBlueprintRuntimeService(awxRemoteExecutor, executionServiceInput)
@@ -181,9 +190,14 @@ class ComponentRemoteAnsibleExecutorTest {
assertEquals(1, errors.size)
}
- private fun createBlueprintRuntimeService(awxRemoteExecutor: ComponentRemoteAnsibleExecutor, executionServiceInput: ExecutionServiceInput): BluePrintRuntimeService<MutableMap<String, JsonNode>> {
- val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("123456-1000",
- "./../../../../components/model-catalog/blueprint-model/test-blueprint/remote_ansible")
+ private fun createBlueprintRuntimeService(
+ awxRemoteExecutor: ComponentRemoteAnsibleExecutor,
+ executionServiceInput: ExecutionServiceInput
+ ): BluePrintRuntimeService<MutableMap<String, JsonNode>> {
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(
+ "123456-1000",
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/remote_ansible"
+ )
awxRemoteExecutor.bluePrintRuntimeService = bluePrintRuntimeService
val workflowName = executionServiceInput.actionIdentifiers.actionName
diff --git a/ms/blueprintsprocessor/functions/cli-executor/src/main/kotlin/internal/scripts/InternalSimpleCli.kt b/ms/blueprintsprocessor/functions/cli-executor/src/main/kotlin/internal/scripts/InternalSimpleCli.kt
index 15365e176..b3708a092 100644
--- a/ms/blueprintsprocessor/functions/cli-executor/src/main/kotlin/internal/scripts/InternalSimpleCli.kt
+++ b/ms/blueprintsprocessor/functions/cli-executor/src/main/kotlin/internal/scripts/InternalSimpleCli.kt
@@ -24,7 +24,6 @@ import org.onap.ccsdk.cds.blueprintsprocessor.functions.cli.executor.getSshClien
import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction
import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ComponentScriptExecutor
import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
-
import org.slf4j.LoggerFactory
open class TestCliScriptFunction : AbstractScriptComponentFunction() {
@@ -44,7 +43,6 @@ open class TestCliScriptFunction : AbstractScriptComponentFunction() {
}
}
-
open class Check : AbstractScriptComponentFunction() {
private val log = LoggerFactory.getLogger(AbstractScriptComponentFunction::class.java)!!
diff --git a/ms/blueprintsprocessor/functions/cli-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/cli/executor/CliExecutorConfiguration.kt b/ms/blueprintsprocessor/functions/cli-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/cli/executor/CliExecutorConfiguration.kt
index 13afc58af..dc2f9edb1 100644
--- a/ms/blueprintsprocessor/functions/cli-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/cli/executor/CliExecutorConfiguration.kt
+++ b/ms/blueprintsprocessor/functions/cli-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/cli/executor/CliExecutorConfiguration.kt
@@ -25,4 +25,4 @@ import org.springframework.context.annotation.Configuration
@ComponentScan
@EnableConfigurationProperties
@ConditionalOnProperty(name = ["blueprintsprocessor.cliExecutor.enabled"], havingValue = "true")
-open class CliExecutorConfiguration \ No newline at end of file
+open class CliExecutorConfiguration
diff --git a/ms/blueprintsprocessor/functions/cli-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/cli/executor/CliExecutorExtensions.kt b/ms/blueprintsprocessor/functions/cli-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/cli/executor/CliExecutorExtensions.kt
index ad95759a9..b6f2dcb94 100644
--- a/ms/blueprintsprocessor/functions/cli-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/cli/executor/CliExecutorExtensions.kt
+++ b/ms/blueprintsprocessor/functions/cli-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/cli/executor/CliExecutorExtensions.kt
@@ -33,4 +33,3 @@ fun AbstractComponentFunction.cliDeviceInfo(requirementName: String): JsonNode {
fun AbstractComponentFunction.getSshClientService(cliDeviceInfo: JsonNode): BlueprintSshClientService {
return BluePrintDependencyService.sshClientService(cliDeviceInfo)
}
-
diff --git a/ms/blueprintsprocessor/functions/cli-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/cli/executor/ComponentCliExecutorTest.kt b/ms/blueprintsprocessor/functions/cli-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/cli/executor/ComponentCliExecutorTest.kt
index c4e674c91..1f070d46d 100644
--- a/ms/blueprintsprocessor/functions/cli-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/cli/executor/ComponentCliExecutorTest.kt
+++ b/ms/blueprintsprocessor/functions/cli-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/cli/executor/ComponentCliExecutorTest.kt
@@ -47,10 +47,12 @@ import org.springframework.test.context.junit4.SpringRunner
import kotlin.test.assertNotNull
@RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [CliExecutorConfiguration::class,
- ExecutionServiceConfiguration::class,
- BluePrintSshLibConfiguration::class, BluePrintScriptsServiceImpl::class,
- BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, BluePrintDependencyService::class])
+@ContextConfiguration(
+ classes = [CliExecutorConfiguration::class,
+ ExecutionServiceConfiguration::class,
+ BluePrintSshLibConfiguration::class, BluePrintScriptsServiceImpl::class,
+ BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, BluePrintDependencyService::class]
+)
@DirtiesContext
@TestPropertySource(properties = [], locations = ["classpath:application-test.properties"])
class ComponentCliExecutorTest {
@@ -81,7 +83,7 @@ class ComponentCliExecutorTest {
operationInputs[BluePrintConstants.PROPERTY_CURRENT_OPERATION] = "operationName".asJsonPrimitive()
operationInputs[ComponentScriptExecutor.INPUT_SCRIPT_TYPE] = BluePrintConstants.SCRIPT_INTERNAL.asJsonPrimitive()
operationInputs[ComponentScriptExecutor.INPUT_SCRIPT_CLASS_REFERENCE] =
- "internal.scripts.TestCliScriptFunction".asJsonPrimitive()
+ "internal.scripts.TestCliScriptFunction".asJsonPrimitive()
val stepInputData = StepData().apply {
name = "activate-cli"
@@ -92,17 +94,21 @@ class ComponentCliExecutorTest {
val blueprintContext = mockk<BluePrintContext>()
every { bluePrintRuntime.bluePrintContext() } returns blueprintContext
every {
- bluePrintRuntime.resolveNodeTemplateInterfaceOperationInputs("activate-cli",
- "interfaceName", "operationName")
+ bluePrintRuntime.resolveNodeTemplateInterfaceOperationInputs(
+ "activate-cli",
+ "interfaceName", "operationName"
+ )
} returns operationInputs
val operationOutputs = hashMapOf<String, JsonNode>()
every {
- bluePrintRuntime.resolveNodeTemplateInterfaceOperationOutputs("activate-cli",
- "interfaceName", "operationName")
+ bluePrintRuntime.resolveNodeTemplateInterfaceOperationOutputs(
+ "activate-cli",
+ "interfaceName", "operationName"
+ )
} returns operationOutputs
componentScriptExecutor.applyNB(executionServiceInput)
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/ComponentConfigSnapshotsExecutor.kt b/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/ComponentConfigSnapshotsExecutor.kt
index 82eaf394d..0bf4e5f32 100644
--- a/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/ComponentConfigSnapshotsExecutor.kt
+++ b/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/ComponentConfigSnapshotsExecutor.kt
@@ -38,7 +38,6 @@ import org.xmlunit.builder.Input
import org.xmlunit.diff.ComparisonType
import org.xmlunit.diff.Diff
-
/**
* ComponentConfigSnapshotsExecutor
*
@@ -54,7 +53,7 @@ import org.xmlunit.diff.Diff
@Component("component-config-snapshots-executor")
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
open class ComponentConfigSnapshotsExecutor(private val cfgSnapshotService: ResourceConfigSnapshotService) :
- AbstractComponentFunction() {
+ AbstractComponentFunction() {
companion object {
private val log = LoggerFactory.getLogger(ComponentConfigSnapshotsExecutor::class.java)
@@ -100,10 +99,12 @@ open class ComponentConfigSnapshotsExecutor(private val cfgSnapshotService: Reso
when (operation) {
OPERATION_FETCH -> fetchConfigurationSnapshot(resourceId, resourceType, status)
OPERATION_STORE -> storeConfigurationSnapshot(snapshot, resourceId, resourceType, status)
- OPERATION_DIFF -> compareConfigurationSnapshot(resourceId, resourceType, contentType)
+ OPERATION_DIFF -> compareConfigurationSnapshot(resourceId, resourceType, contentType)
- else -> setNodeOutputErrors(OUTPUT_STATUS_ERROR,
- "Operation parameter must be fetch, store or diff")
+ else -> setNodeOutputErrors(
+ OUTPUT_STATUS_ERROR,
+ "Operation parameter must be fetch, store or diff"
+ )
}
}
@@ -117,12 +118,15 @@ open class ComponentConfigSnapshotsExecutor(private val cfgSnapshotService: Reso
/**
* Fetch a configuration snapshot, for resource identified by ID/type, of type status (RUNNING by default)
*/
- private suspend fun fetchConfigurationSnapshot(resourceId: String, resourceType: String,
- status : ResourceConfigSnapshot.Status = RUNNING) {
+ private suspend fun fetchConfigurationSnapshot(
+ resourceId: String,
+ resourceType: String,
+ status: ResourceConfigSnapshot.Status = RUNNING
+ ) {
try {
val cfgSnapshotValue = cfgSnapshotService.findByResourceIdAndResourceTypeAndStatus(resourceId, resourceType, status)
setNodeOutputProperties(OUTPUT_STATUS_SUCCESS, cfgSnapshotValue)
- } catch (er : NoSuchElementException) {
+ } catch (er: NoSuchElementException) {
val message = "No Resource config snapshot identified by resourceId={$resourceId}, " +
"resourceType={$resourceType} does not exists"
setNodeOutputErrors(OUTPUT_STATUS_ERROR, message)
@@ -132,11 +136,15 @@ open class ComponentConfigSnapshotsExecutor(private val cfgSnapshotService: Reso
/**
* Store a configuration snapshot, for resource identified by ID/type, of type status (RUNNING by default)
*/
- private suspend fun storeConfigurationSnapshot(cfgSnapshotValue : String, resourceId: String, resourceType: String,
- status : ResourceConfigSnapshot.Status = RUNNING) {
+ private suspend fun storeConfigurationSnapshot(
+ cfgSnapshotValue: String,
+ resourceId: String,
+ resourceType: String,
+ status: ResourceConfigSnapshot.Status = RUNNING
+ ) {
if (cfgSnapshotValue.isNotEmpty()) {
val cfgSnapshotSaved = cfgSnapshotService.write(cfgSnapshotValue, resourceId, resourceType, status)
- setNodeOutputProperties(OUTPUT_STATUS_SUCCESS, cfgSnapshotSaved.config_snapshot ?: "" )
+ setNodeOutputProperties(OUTPUT_STATUS_SUCCESS, cfgSnapshotSaved.config_snapshot ?: "")
} else {
val message = "Could not store config snapshot identified by resourceId={$resourceId},resourceType={$resourceType} does not exists"
setNodeOutputErrors(OUTPUT_STATUS_ERROR, message)
@@ -146,7 +154,7 @@ open class ComponentConfigSnapshotsExecutor(private val cfgSnapshotService: Reso
/**
* Compare two configs (RUNNING vs CANDIDATE) for resource identified by ID/type, using the specified contentType
*/
- private suspend fun compareConfigurationSnapshot(resourceId: String, resourceType: String, contentType : String) {
+ private suspend fun compareConfigurationSnapshot(resourceId: String, resourceType: String, contentType: String) {
val cfgRunning = cfgSnapshotService.findByResourceIdAndResourceTypeAndStatus(resourceId, resourceType, RUNNING)
val cfgCandidate = cfgSnapshotService.findByResourceIdAndResourceTypeAndStatus(resourceId, resourceType, CANDIDATE)
@@ -163,13 +171,13 @@ open class ComponentConfigSnapshotsExecutor(private val cfgSnapshotService: Reso
}
DIFF_XML -> {
val myDiff = DiffBuilder
- .compare(Input.fromString(cfgRunning))
- .withTest(Input.fromString(cfgCandidate))
- .checkForSimilar()
- .ignoreComments()
- .ignoreWhitespace()
- .normalizeWhitespace()
- .build()
+ .compare(Input.fromString(cfgRunning))
+ .withTest(Input.fromString(cfgCandidate))
+ .checkForSimilar()
+ .ignoreComments()
+ .ignoreWhitespace()
+ .normalizeWhitespace()
+ .build()
setNodeOutputProperties(OUTPUT_STATUS_SUCCESS, formatXmlDifferences(myDiff))
}
@@ -205,10 +213,12 @@ open class ComponentConfigSnapshotsExecutor(private val cfgSnapshotService: Reso
/**
* Formats XmlUnit differences into xml-patch like response (RFC5261)
*/
- private fun formatXmlDifferences(differences : Diff) : String {
+ private fun formatXmlDifferences(differences: Diff): String {
val output = StringBuilder()
- output.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
- "<diff>")
+ output.append(
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
+ "<diff>"
+ )
val diffIterator = differences.getDifferences().iterator()
while (diffIterator.hasNext()) {
@@ -216,18 +226,18 @@ open class ComponentConfigSnapshotsExecutor(private val cfgSnapshotService: Reso
when (aDiff.type) {
ComparisonType.ATTR_VALUE -> {
output.append("<replace sel=\"").append(aDiff.testDetails.xPath).append("\">")
- .append(aDiff.testDetails.value)
- .append("</replace>")
+ .append(aDiff.testDetails.value)
+ .append("</replace>")
}
ComparisonType.TEXT_VALUE -> {
output.append("<replace sel=\"").append(aDiff.testDetails.xPath).append("\">")
- .append(aDiff.testDetails.value)
- .append("</replace>")
+ .append(aDiff.testDetails.value)
+ .append("</replace>")
}
ComparisonType.CHILD_LOOKUP -> {
output.append("<add sel=\"").append(aDiff.testDetails.parentXPath).append("\">")
- .append(formatNode(aDiff.testDetails.target))
- .append("</add>")
+ .append(formatNode(aDiff.testDetails.target))
+ .append("</add>")
}
ComparisonType.CHILD_NODELIST_LENGTH -> {
// Ignored; will be processed in the CHILD_LOOKUP case
@@ -253,7 +263,7 @@ open class ComponentConfigSnapshotsExecutor(private val cfgSnapshotService: Reso
if (node.hasChildNodes()) {
val nodes = node.childNodes
for (index in 1..nodes.length) {
- val child = nodes.item(index-1)
+ val child = nodes.item(index - 1)
if (child.nodeType == Node.TEXT_NODE || child.nodeType == Node.COMMENT_NODE) {
output.append(child.nodeValue)
} else {
diff --git a/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshot.kt b/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshot.kt
index ef34e6ff9..73c9e22f3 100644
--- a/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshot.kt
+++ b/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshot.kt
@@ -22,8 +22,15 @@ import org.hibernate.annotations.Proxy
import org.springframework.data.annotation.LastModifiedDate
import org.springframework.data.jpa.domain.support.AuditingEntityListener
import java.io.Serializable
-import java.util.*
-import javax.persistence.*
+import java.util.Date
+import javax.persistence.Column
+import javax.persistence.Entity
+import javax.persistence.EntityListeners
+import javax.persistence.Id
+import javax.persistence.Lob
+import javax.persistence.Table
+import javax.persistence.Temporal
+import javax.persistence.TemporalType
/**
* ResourceConfigSnapshot model
diff --git a/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotRepository.kt b/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotRepository.kt
index 4ab7d7f0e..cb7467b60 100644
--- a/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotRepository.kt
+++ b/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotRepository.kt
@@ -29,11 +29,13 @@ interface ResourceConfigSnapshotRepository : JpaRepository<ResourceConfigSnapsho
fun findByResourceIdAndResourceTypeAndStatus(
resourceId: String,
resourceType: String,
- status : ResourceConfigSnapshot.Status): ResourceConfigSnapshot?
+ status: ResourceConfigSnapshot.Status
+ ): ResourceConfigSnapshot?
@Transactional
fun deleteByResourceIdAndResourceTypeAndStatus(
resourceId: String,
resourceType: String,
- status : ResourceConfigSnapshot.Status)
+ status: ResourceConfigSnapshot.Status
+ )
}
diff --git a/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotService.kt b/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotService.kt
index 73d517553..fcbc15702 100644
--- a/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotService.kt
+++ b/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotService.kt
@@ -23,7 +23,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
import org.slf4j.LoggerFactory
import org.springframework.dao.DataIntegrityViolationException
import org.springframework.stereotype.Service
-import java.util.*
+import java.util.UUID
/**
* ResourceConfigSnapshot managing service.
@@ -36,42 +36,53 @@ class ResourceConfigSnapshotService(private val repository: ResourceConfigSnapsh
private val log = LoggerFactory.getLogger(ResourceConfigSnapshotService::class.toString())
- suspend fun findByResourceIdAndResourceTypeAndStatus(resourceId: String, resourceType: String,
- status : ResourceConfigSnapshot.Status = RUNNING): String =
- withContext(Dispatchers.IO) {
- repository.findByResourceIdAndResourceTypeAndStatus(resourceId, resourceType, status)
- ?.config_snapshot ?: Strings.EMPTY
- }
+ suspend fun findByResourceIdAndResourceTypeAndStatus(
+ resourceId: String,
+ resourceType: String,
+ status: ResourceConfigSnapshot.Status = RUNNING
+ ): String =
+ withContext(Dispatchers.IO) {
+ repository.findByResourceIdAndResourceTypeAndStatus(resourceId, resourceType, status)
+ ?.config_snapshot ?: Strings.EMPTY
+ }
- suspend fun write(snapshot: String, resId: String, resType: String,
- status: ResourceConfigSnapshot.Status = RUNNING) : ResourceConfigSnapshot =
- withContext(Dispatchers.IO) {
+ suspend fun write(
+ snapshot: String,
+ resId: String,
+ resType: String,
+ status: ResourceConfigSnapshot.Status = RUNNING
+ ): ResourceConfigSnapshot =
+ withContext(Dispatchers.IO) {
- val resourceConfigSnapshotEntry = ResourceConfigSnapshot()
- resourceConfigSnapshotEntry.id = UUID.randomUUID().toString()
- resourceConfigSnapshotEntry.resourceId = resId
- resourceConfigSnapshotEntry.resourceType = resType
- resourceConfigSnapshotEntry.status = status
- resourceConfigSnapshotEntry.config_snapshot = snapshot
+ val resourceConfigSnapshotEntry = ResourceConfigSnapshot()
+ resourceConfigSnapshotEntry.id = UUID.randomUUID().toString()
+ resourceConfigSnapshotEntry.resourceId = resId
+ resourceConfigSnapshotEntry.resourceType = resType
+ resourceConfigSnapshotEntry.status = status
+ resourceConfigSnapshotEntry.config_snapshot = snapshot
- // Overwrite configuration snapshot entry of resId/resType
- if (resId.isNotEmpty() && resType.isNotEmpty()) {
- repository.findByResourceIdAndResourceTypeAndStatus(resId, resType, status)?.
- let {
- log.info("Overwriting configuration snapshot entry for resourceId=($resId), " +
- "resourceType=($resType), status=($status)")
- repository.deleteByResourceIdAndResourceTypeAndStatus(resId, resType, status)
- }
- }
- var storedSnapshot: ResourceConfigSnapshot
- try {
- storedSnapshot = repository.saveAndFlush(resourceConfigSnapshotEntry)
- log.info("Stored configuration snapshot for resourceId=($resId), " +
+ // Overwrite configuration snapshot entry of resId/resType
+ if (resId.isNotEmpty() && resType.isNotEmpty()) {
+ repository.findByResourceIdAndResourceTypeAndStatus(resId, resType, status)
+ ?.let {
+ log.info(
+ "Overwriting configuration snapshot entry for resourceId=($resId), " +
+ "resourceType=($resType), status=($status)"
+ )
+ repository.deleteByResourceIdAndResourceTypeAndStatus(resId, resType, status)
+ }
+ }
+ var storedSnapshot: ResourceConfigSnapshot
+ try {
+ storedSnapshot = repository.saveAndFlush(resourceConfigSnapshotEntry)
+ log.info(
+ "Stored configuration snapshot for resourceId=($resId), " +
"resourceType=($resType), status=($status), " +
- "dated=(${storedSnapshot.createdDate})")
- } catch (ex: DataIntegrityViolationException) {
- throw BluePrintException("Failed to store configuration snapshot entry.", ex)
- }
- storedSnapshot
+ "dated=(${storedSnapshot.createdDate})"
+ )
+ } catch (ex: DataIntegrityViolationException) {
+ throw BluePrintException("Failed to store configuration snapshot entry.", ex)
}
+ storedSnapshot
+ }
}
diff --git a/ms/blueprintsprocessor/functions/config-snapshots/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/ComponentConfigSnapshotsExecutorTest.kt b/ms/blueprintsprocessor/functions/config-snapshots/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/ComponentConfigSnapshotsExecutorTest.kt
index f013e89a1..c472337ac 100644
--- a/ms/blueprintsprocessor/functions/config-snapshots/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/ComponentConfigSnapshotsExecutorTest.kt
+++ b/ms/blueprintsprocessor/functions/config-snapshots/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/ComponentConfigSnapshotsExecutorTest.kt
@@ -47,9 +47,11 @@ import org.springframework.test.context.TestPropertySource
import org.springframework.test.context.junit4.SpringRunner
@RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [ResourceConfigSnapshotService::class,
- BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class,
- BluePrintDBLibConfiguration::class, BluePrintLoadConfiguration::class])
+@ContextConfiguration(
+ classes = [ResourceConfigSnapshotService::class,
+ BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class,
+ BluePrintDBLibConfiguration::class, BluePrintLoadConfiguration::class]
+)
@TestPropertySource(locations = ["classpath:application-test.properties"])
@ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor", "org.onap.ccsdk.cds.controllerblueprints"])
@EnableAutoConfiguration
@@ -57,10 +59,12 @@ import org.springframework.test.context.junit4.SpringRunner
class ComponentConfigSnapshotsExecutorTest {
@Autowired
- lateinit var cfgSnapshotService : ResourceConfigSnapshotService
- lateinit var cfgSnapshotComponent : ComponentConfigSnapshotsExecutor
- private var bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("123456-1000",
- "./../../../../components/model-catalog/blueprint-model/test-blueprint/remote_scripts")
+ lateinit var cfgSnapshotService: ResourceConfigSnapshotService
+ lateinit var cfgSnapshotComponent: ComponentConfigSnapshotsExecutor
+ private var bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(
+ "123456-1000",
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/remote_scripts"
+ )
private val resourceId = "1"
private val resourceType = "ServiceInstance"
@@ -75,7 +79,6 @@ class ComponentConfigSnapshotsExecutorTest {
props[ComponentConfigSnapshotsExecutor.INPUT_RESOURCE_ID] = resourceId.asJsonPrimitive()
props[ComponentConfigSnapshotsExecutor.INPUT_RESOURCE_TYPE] = resourceType.asJsonPrimitive()
-
cfgSnapshotComponent.operationInputs = props
cfgSnapshotComponent.bluePrintRuntimeService = bluePrintRuntimeService
cfgSnapshotComponent.nodeTemplateName = nodeTemplateName
@@ -103,17 +106,27 @@ class ComponentConfigSnapshotsExecutorTest {
cfgSnapshotComponent.processNB(executionRequest)
} catch (e: BluePrintProcessorException) {
- kotlin.test.assertEquals("Can't proceed with the cfg snapshot lookup: provide resource-id and resource-type.",
- e.message)
+ kotlin.test.assertEquals(
+ "Can't proceed with the cfg snapshot lookup: provide resource-id and resource-type.",
+ e.message
+ )
return@runBlocking
}
// then; we should get success and the TEST1 payload in our output properties
- assertEquals(ComponentConfigSnapshotsExecutor.OUTPUT_STATUS_SUCCESS.asJsonPrimitive(),
- bluePrintRuntimeService.getNodeTemplateAttributeValue(nodeTemplateName,
- ComponentConfigSnapshotsExecutor.OUTPUT_STATUS))
- assertEquals(snapshotConfig.asJsonPrimitive(),
- bluePrintRuntimeService.getNodeTemplateAttributeValue(nodeTemplateName,
- ComponentConfigSnapshotsExecutor.OUTPUT_SNAPSHOT))
+ assertEquals(
+ ComponentConfigSnapshotsExecutor.OUTPUT_STATUS_SUCCESS.asJsonPrimitive(),
+ bluePrintRuntimeService.getNodeTemplateAttributeValue(
+ nodeTemplateName,
+ ComponentConfigSnapshotsExecutor.OUTPUT_STATUS
+ )
+ )
+ assertEquals(
+ snapshotConfig.asJsonPrimitive(),
+ bluePrintRuntimeService.getNodeTemplateAttributeValue(
+ nodeTemplateName,
+ ComponentConfigSnapshotsExecutor.OUTPUT_SNAPSHOT
+ )
+ )
}
}
@@ -127,22 +140,32 @@ class ComponentConfigSnapshotsExecutorTest {
try {
val resId = "121111"
val resType = "PNF"
- cfgSnapshotService.write(snapshotConfig, resId, resType, ResourceConfigSnapshot.Status.CANDIDATE)
+ cfgSnapshotService.write(snapshotConfig, resId, resType, ResourceConfigSnapshot.Status.CANDIDATE)
prepareRequestProperties(OPERATION_FETCH, resId, resType, ResourceConfigSnapshot.Status.CANDIDATE.name)
cfgSnapshotComponent.processNB(executionRequest)
} catch (e: BluePrintProcessorException) {
- kotlin.test.assertEquals("Can't proceed with the cfg snapshot lookup: provide resource-id and resource-type.",
- e.message)
+ kotlin.test.assertEquals(
+ "Can't proceed with the cfg snapshot lookup: provide resource-id and resource-type.",
+ e.message
+ )
return@runBlocking
}
// then; we should get success and the TEST payload in our output properties
- assertEquals(ComponentConfigSnapshotsExecutor.OUTPUT_STATUS_SUCCESS.asJsonPrimitive(),
- bluePrintRuntimeService.getNodeTemplateAttributeValue(nodeTemplateName,
- ComponentConfigSnapshotsExecutor.OUTPUT_STATUS))
- assertEquals(snapshotConfig.asJsonPrimitive(),
- bluePrintRuntimeService.getNodeTemplateAttributeValue(nodeTemplateName,
- ComponentConfigSnapshotsExecutor.OUTPUT_SNAPSHOT))
+ assertEquals(
+ ComponentConfigSnapshotsExecutor.OUTPUT_STATUS_SUCCESS.asJsonPrimitive(),
+ bluePrintRuntimeService.getNodeTemplateAttributeValue(
+ nodeTemplateName,
+ ComponentConfigSnapshotsExecutor.OUTPUT_STATUS
+ )
+ )
+ assertEquals(
+ snapshotConfig.asJsonPrimitive(),
+ bluePrintRuntimeService.getNodeTemplateAttributeValue(
+ nodeTemplateName,
+ ComponentConfigSnapshotsExecutor.OUTPUT_SNAPSHOT
+ )
+ )
}
}
@@ -159,20 +182,29 @@ class ComponentConfigSnapshotsExecutorTest {
prepareRequestProperties(OPERATION_STORE, resId, resType, snapshotConfig)
cfgSnapshotComponent.processNB(executionRequest)
-
} catch (e: BluePrintProcessorException) {
- kotlin.test.assertEquals("Can't proceed with the cfg snapshot lookup: provide resource-id and resource-type.",
- e.message)
+ kotlin.test.assertEquals(
+ "Can't proceed with the cfg snapshot lookup: provide resource-id and resource-type.",
+ e.message
+ )
return@runBlocking
}
// then; we should get success and the PAYLOAD payload in our output properties
- assertEquals(ComponentConfigSnapshotsExecutor.OUTPUT_STATUS_SUCCESS.asJsonPrimitive(),
- bluePrintRuntimeService.getNodeTemplateAttributeValue(nodeTemplateName,
- ComponentConfigSnapshotsExecutor.OUTPUT_STATUS))
- assertEquals(snapshotConfig.asJsonPrimitive(),
- bluePrintRuntimeService.getNodeTemplateAttributeValue(nodeTemplateName,
- ComponentConfigSnapshotsExecutor.OUTPUT_SNAPSHOT))
+ assertEquals(
+ ComponentConfigSnapshotsExecutor.OUTPUT_STATUS_SUCCESS.asJsonPrimitive(),
+ bluePrintRuntimeService.getNodeTemplateAttributeValue(
+ nodeTemplateName,
+ ComponentConfigSnapshotsExecutor.OUTPUT_STATUS
+ )
+ )
+ assertEquals(
+ snapshotConfig.asJsonPrimitive(),
+ bluePrintRuntimeService.getNodeTemplateAttributeValue(
+ nodeTemplateName,
+ ComponentConfigSnapshotsExecutor.OUTPUT_SNAPSHOT
+ )
+ )
}
}
@@ -182,19 +214,24 @@ class ComponentConfigSnapshotsExecutorTest {
runBlocking {
// when; asking for unknown resource Id/ resource Type combo; should get an error response
try {
- prepareRequestProperties(OPERATION_FETCH, "asdasd", "PNF", ResourceConfigSnapshot.Status.RUNNING.name)
+ prepareRequestProperties(OPERATION_FETCH, "asdasd", "PNF", ResourceConfigSnapshot.Status.RUNNING.name)
cfgSnapshotComponent.processNB(executionRequest)
-
} catch (e: BluePrintProcessorException) {
- kotlin.test.assertEquals("Can't proceed with the cfg snapshot lookup: provide resource-id and resource-type.",
- e.message)
+ kotlin.test.assertEquals(
+ "Can't proceed with the cfg snapshot lookup: provide resource-id and resource-type.",
+ e.message
+ )
return@runBlocking
}
- assertEquals(ComponentConfigSnapshotsExecutor.OUTPUT_STATUS_SUCCESS.asJsonPrimitive(),
- bluePrintRuntimeService.getNodeTemplateAttributeValue(nodeTemplateName,
- ComponentConfigSnapshotsExecutor.OUTPUT_STATUS))
+ assertEquals(
+ ComponentConfigSnapshotsExecutor.OUTPUT_STATUS_SUCCESS.asJsonPrimitive(),
+ bluePrintRuntimeService.getNodeTemplateAttributeValue(
+ nodeTemplateName,
+ ComponentConfigSnapshotsExecutor.OUTPUT_STATUS
+ )
+ )
}
}
@@ -204,25 +241,34 @@ class ComponentConfigSnapshotsExecutorTest {
runBlocking {
// when; asking for unknown operation update; should get an error response
try {
- prepareRequestProperties("update", "asdasd", "PNF", ResourceConfigSnapshot.Status.RUNNING.name)
+ prepareRequestProperties("update", "asdasd", "PNF", ResourceConfigSnapshot.Status.RUNNING.name)
cfgSnapshotComponent.processNB(executionRequest)
-
} catch (e: BluePrintProcessorException) {
- kotlin.test.assertEquals("Can't proceed with the cfg snapshot lookup: provide resource-id and resource-type.",
- e.message)
+ kotlin.test.assertEquals(
+ "Can't proceed with the cfg snapshot lookup: provide resource-id and resource-type.",
+ e.message
+ )
return@runBlocking
}
// then; we should get error in our output properties
- assertTrue( bluePrintRuntimeService.getBluePrintError().errors.size == 1 )
- assertEquals(ComponentConfigSnapshotsExecutor.OUTPUT_STATUS_ERROR.asJsonPrimitive(),
- bluePrintRuntimeService.getNodeTemplateAttributeValue(nodeTemplateName,
- ComponentConfigSnapshotsExecutor.OUTPUT_STATUS))
+ assertTrue(bluePrintRuntimeService.getBluePrintError().errors.size == 1)
+ assertEquals(
+ ComponentConfigSnapshotsExecutor.OUTPUT_STATUS_ERROR.asJsonPrimitive(),
+ bluePrintRuntimeService.getNodeTemplateAttributeValue(
+ nodeTemplateName,
+ ComponentConfigSnapshotsExecutor.OUTPUT_STATUS
+ )
+ )
val msg = "Operation parameter must be fetch, store or diff"
- assertEquals(msg.asJsonPrimitive(),
- bluePrintRuntimeService.getNodeTemplateAttributeValue(nodeTemplateName,
- ComponentConfigSnapshotsExecutor.OUTPUT_MESSAGE))
+ assertEquals(
+ msg.asJsonPrimitive(),
+ bluePrintRuntimeService.getNodeTemplateAttributeValue(
+ nodeTemplateName,
+ ComponentConfigSnapshotsExecutor.OUTPUT_MESSAGE
+ )
+ )
}
}
@@ -234,25 +280,34 @@ class ComponentConfigSnapshotsExecutorTest {
try {
val resId = "121111"
val resType = "PNF"
- cfgSnapshotService.write("snapshotConfig", resId, resType, ResourceConfigSnapshot.Status.CANDIDATE)
- prepareRequestProperties(OPERATION_DIFF, resId, resType, "YANG")
+ cfgSnapshotService.write("snapshotConfig", resId, resType, ResourceConfigSnapshot.Status.CANDIDATE)
+ prepareRequestProperties(OPERATION_DIFF, resId, resType, "YANG")
cfgSnapshotComponent.processNB(executionRequest)
-
} catch (e: BluePrintProcessorException) {
- kotlin.test.assertEquals("Can't proceed with the cfg snapshot lookup: provide resource-id and resource-type.",
- e.message)
+ kotlin.test.assertEquals(
+ "Can't proceed with the cfg snapshot lookup: provide resource-id and resource-type.",
+ e.message
+ )
return@runBlocking
}
// then; we should get error in our output properties
- assertEquals(ComponentConfigSnapshotsExecutor.OUTPUT_STATUS_ERROR.asJsonPrimitive(),
- bluePrintRuntimeService.getNodeTemplateAttributeValue(nodeTemplateName,
- ComponentConfigSnapshotsExecutor.OUTPUT_STATUS))
+ assertEquals(
+ ComponentConfigSnapshotsExecutor.OUTPUT_STATUS_ERROR.asJsonPrimitive(),
+ bluePrintRuntimeService.getNodeTemplateAttributeValue(
+ nodeTemplateName,
+ ComponentConfigSnapshotsExecutor.OUTPUT_STATUS
+ )
+ )
val message = "Could not compare config snapshots for type YANG"
- assertEquals(message.asJsonPrimitive(),
- bluePrintRuntimeService.getNodeTemplateAttributeValue(nodeTemplateName,
- ComponentConfigSnapshotsExecutor.OUTPUT_MESSAGE))
+ assertEquals(
+ message.asJsonPrimitive(),
+ bluePrintRuntimeService.getNodeTemplateAttributeValue(
+ nodeTemplateName,
+ ComponentConfigSnapshotsExecutor.OUTPUT_MESSAGE
+ )
+ )
}
}
@@ -270,27 +325,37 @@ class ComponentConfigSnapshotsExecutorTest {
prepareRequestProperties(OPERATION_DIFF, resId, resType, DIFF_JSON)
cfgSnapshotComponent.processNB(executionRequest)
-
} catch (e: BluePrintProcessorException) {
- kotlin.test.assertEquals("Can't proceed with the cfg snapshot diff: provide resource-id and resource-type.",
- e.message)
+ kotlin.test.assertEquals(
+ "Can't proceed with the cfg snapshot diff: provide resource-id and resource-type.",
+ e.message
+ )
return@runBlocking
}
// then; we should get success
- assertTrue( bluePrintRuntimeService.getBluePrintError().errors.size == 0 )
- assertEquals(ComponentConfigSnapshotsExecutor.OUTPUT_STATUS_SUCCESS.asJsonPrimitive(),
- bluePrintRuntimeService.getNodeTemplateAttributeValue(nodeTemplateName,
- ComponentConfigSnapshotsExecutor.OUTPUT_STATUS))
+ assertTrue(bluePrintRuntimeService.getBluePrintError().errors.size == 0)
+ assertEquals(
+ ComponentConfigSnapshotsExecutor.OUTPUT_STATUS_SUCCESS.asJsonPrimitive(),
+ bluePrintRuntimeService.getNodeTemplateAttributeValue(
+ nodeTemplateName,
+ ComponentConfigSnapshotsExecutor.OUTPUT_STATUS
+ )
+ )
// then; we should get JSON-patches differences in our response property
- val diffJson = "[{\"op\":\"add\",\"path\":\"/system-uptime-information/last-configured-time/new-child-object\",\"value\":{\"property\":\"value\"}}," +
- "{\"op\":\"replace\",\"path\":\"/system-uptime-information/system-booted-time/time-length\",\"value\":\"14:52:54\"}," +
- "{\"op\":\"replace\",\"path\":\"/system-uptime-information/time-source\",\"value\":\" DNS CLOCK \"}," +
- "{\"op\":\"add\",\"path\":\"/system-uptime-information/uptime-information/load-average-10\",\"value\":\"0.05\"}]"
- assertEquals(diffJson.asJsonPrimitive(),
- bluePrintRuntimeService.getNodeTemplateAttributeValue(nodeTemplateName,
- ComponentConfigSnapshotsExecutor.OUTPUT_SNAPSHOT))
+ val diffJson =
+ "[{\"op\":\"add\",\"path\":\"/system-uptime-information/last-configured-time/new-child-object\",\"value\":{\"property\":\"value\"}}," +
+ "{\"op\":\"replace\",\"path\":\"/system-uptime-information/system-booted-time/time-length\",\"value\":\"14:52:54\"}," +
+ "{\"op\":\"replace\",\"path\":\"/system-uptime-information/time-source\",\"value\":\" DNS CLOCK \"}," +
+ "{\"op\":\"add\",\"path\":\"/system-uptime-information/uptime-information/load-average-10\",\"value\":\"0.05\"}]"
+ assertEquals(
+ diffJson.asJsonPrimitive(),
+ bluePrintRuntimeService.getNodeTemplateAttributeValue(
+ nodeTemplateName,
+ ComponentConfigSnapshotsExecutor.OUTPUT_SNAPSHOT
+ )
+ )
}
}
@@ -309,18 +374,23 @@ class ComponentConfigSnapshotsExecutorTest {
prepareRequestProperties(OPERATION_DIFF, resId, resType, DIFF_XML)
cfgSnapshotComponent.processNB(executionRequest)
-
} catch (e: BluePrintProcessorException) {
- kotlin.test.assertEquals("Can't proceed with the cfg snapshot diff: provide resource-id and resource-type.",
- e.message)
+ kotlin.test.assertEquals(
+ "Can't proceed with the cfg snapshot diff: provide resource-id and resource-type.",
+ e.message
+ )
return@runBlocking
}
// then; we should get success
- assertTrue( bluePrintRuntimeService.getBluePrintError().errors.size == 0 )
- assertEquals(ComponentConfigSnapshotsExecutor.OUTPUT_STATUS_SUCCESS.asJsonPrimitive(),
- bluePrintRuntimeService.getNodeTemplateAttributeValue(nodeTemplateName,
- ComponentConfigSnapshotsExecutor.OUTPUT_STATUS))
+ assertTrue(bluePrintRuntimeService.getBluePrintError().errors.size == 0)
+ assertEquals(
+ ComponentConfigSnapshotsExecutor.OUTPUT_STATUS_SUCCESS.asJsonPrimitive(),
+ bluePrintRuntimeService.getNodeTemplateAttributeValue(
+ nodeTemplateName,
+ ComponentConfigSnapshotsExecutor.OUTPUT_STATUS
+ )
+ )
// then; we should get XML-patches differences in our response property
val diffXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
@@ -331,18 +401,23 @@ class ComponentConfigSnapshotsExecutorTest {
"<replace sel=\"/output[1]/interface-information[1]/traffic-statistics[1]/output-packets[1]/text()[1]\">2828828</replace>" +
"<add sel=\"/output[1]/interface-information[1]/physical-interface[1]\"><interface-name>TEGig400-int01</interface-name></add>" +
"</diff>"
- assertEquals(diffXml.asJsonPrimitive(),
- bluePrintRuntimeService.getNodeTemplateAttributeValue(nodeTemplateName,
- ComponentConfigSnapshotsExecutor.OUTPUT_SNAPSHOT)) }
+ assertEquals(
+ diffXml.asJsonPrimitive(),
+ bluePrintRuntimeService.getNodeTemplateAttributeValue(
+ nodeTemplateName,
+ ComponentConfigSnapshotsExecutor.OUTPUT_SNAPSHOT
+ )
+ )
+ }
}
- private fun preparePayload(filename : String, resId : String, resType : String, status: ResourceConfigSnapshot.Status) {
+ private fun preparePayload(filename: String, resId: String, resType: String, status: ResourceConfigSnapshot.Status) {
runBlocking {
cfgSnapshotService.write(JacksonUtils.getClassPathFileContent("payload/requests/$filename"), resId, resType, status)
}
}
- private fun prepareRequestProperties (oper : String, resId : String, resType : String, optional: String = "") {
+ private fun prepareRequestProperties(oper: String, resId: String, resType: String, optional: String = "") {
cfgSnapshotComponent.operationInputs[ComponentConfigSnapshotsExecutor.INPUT_OPERATION] = oper.asJsonPrimitive()
cfgSnapshotComponent.operationInputs[ComponentConfigSnapshotsExecutor.INPUT_RESOURCE_ID] = resId.asJsonPrimitive()
cfgSnapshotComponent.operationInputs[ComponentConfigSnapshotsExecutor.INPUT_RESOURCE_TYPE] = resType.asJsonPrimitive()
@@ -351,7 +426,7 @@ class ComponentConfigSnapshotsExecutorTest {
cfgSnapshotComponent.operationInputs[ComponentConfigSnapshotsExecutor.INPUT_DIFF_CONTENT_TYPE] = "".asJsonPrimitive()
cfgSnapshotComponent.operationInputs[ComponentConfigSnapshotsExecutor.INPUT_RESOURCE_SNAPSHOT] = "".asJsonPrimitive()
cfgSnapshotComponent.operationInputs[ComponentConfigSnapshotsExecutor.INPUT_RESOURCE_STATUS] =
- ResourceConfigSnapshot.Status.RUNNING.name.asJsonPrimitive()
+ ResourceConfigSnapshot.Status.RUNNING.name.asJsonPrimitive()
when (oper) {
OPERATION_DIFF ->
diff --git a/ms/blueprintsprocessor/functions/config-snapshots/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotServiceTest.kt b/ms/blueprintsprocessor/functions/config-snapshots/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotServiceTest.kt
index 18ee8c9dc..f25b6f9c7 100644
--- a/ms/blueprintsprocessor/functions/config-snapshots/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotServiceTest.kt
+++ b/ms/blueprintsprocessor/functions/config-snapshots/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotServiceTest.kt
@@ -55,7 +55,7 @@ class ResourceConfigSnapshotServiceTest {
every {
cfgRepository.findByResourceIdAndResourceTypeAndStatus(any(), any(), any())
} returns null
- val res = cfgService.write( configSnapshot, resourceId, resourceType, resourceStatus)
+ val res = cfgService.write(configSnapshot, resourceId, resourceType, resourceStatus)
assertEquals(tr, res)
}
}
@@ -71,7 +71,7 @@ class ResourceConfigSnapshotServiceTest {
every {
cfgRepository.deleteByResourceIdAndResourceTypeAndStatus(any(), any(), any())
} returns Unit
- val res = cfgService.write( configSnapshot, resourceId, resourceType)
+ val res = cfgService.write(configSnapshot, resourceId, resourceType)
verify {
cfgRepository.deleteByResourceIdAndResourceTypeAndStatus(eq(resourceId), eq(resourceType), eq(resourceStatus))
}
diff --git a/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/AbstractTopologyComponents.kt b/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/AbstractMessagePrioritizeProcessor.kt
index d114da521..c2965c4e8 100644
--- a/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/AbstractTopologyComponents.kt
+++ b/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/AbstractMessagePrioritizeProcessor.kt
@@ -34,8 +34,6 @@ abstract class AbstractMessagePrioritizeProcessor<K, V> : AbstractBluePrintMessa
this.processorContext = context
/** Get the State service to update in store */
this.messagePrioritizationStateService = BluePrintDependencyService
- .messagePrioritizationStateService()
-
+ .messagePrioritizationStateService()
}
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/MessagePrioritizationConfiguration.kt b/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/MessagePrioritizationConfiguration.kt
index cce883c91..28e096352 100644
--- a/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/MessagePrioritizationConfiguration.kt
+++ b/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/MessagePrioritizationConfiguration.kt
@@ -23,7 +23,6 @@ import org.springframework.context.annotation.Configuration
@ComponentScan
open class MessagePrioritizationConfiguration
-
object MessagePrioritizationConstants {
const val SOURCE_INPUT = "source-prioritization-input"
@@ -34,4 +33,4 @@ object MessagePrioritizationConstants {
const val SINK_OUTPUT = "sink-prioritization-output"
const val SINK_EXPIRED = "sink-prioritization-expired"
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/MessagePrioritizationConsumer.kt b/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/MessagePrioritizationConsumer.kt
index 967cc190e..ed124d1b2 100644
--- a/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/MessagePrioritizationConsumer.kt
+++ b/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/MessagePrioritizationConsumer.kt
@@ -28,7 +28,8 @@ import org.onap.ccsdk.cds.blueprintsprocessor.message.service.KafkaStreamConsume
import org.onap.ccsdk.cds.controllerblueprints.core.logger
open class MessagePrioritizationConsumer(
- private val bluePrintMessageLibPropertyService: BluePrintMessageLibPropertyService) {
+ private val bluePrintMessageLibPropertyService: BluePrintMessageLibPropertyService
+) {
private val log = logger(MessagePrioritizationConsumer::class)
@@ -36,15 +37,17 @@ open class MessagePrioritizationConsumer(
open fun consumerService(selector: String): BlueprintMessageConsumerService {
return bluePrintMessageLibPropertyService
- .blueprintMessageConsumerService(selector)
+ .blueprintMessageConsumerService(selector)
}
- open fun kafkaStreamConsumerFunction(prioritizationConfiguration: PrioritizationConfiguration)
- : KafkaStreamConsumerFunction {
+ open fun kafkaStreamConsumerFunction(prioritizationConfiguration: PrioritizationConfiguration):
+ KafkaStreamConsumerFunction {
return object : KafkaStreamConsumerFunction {
- override suspend fun createTopology(messageConsumerProperties: MessageConsumerProperties,
- additionalConfig: Map<String, Any>?): Topology {
+ override suspend fun createTopology(
+ messageConsumerProperties: MessageConsumerProperties,
+ additionalConfig: Map<String, Any>?
+ ): Topology {
val topology = Topology()
val kafkaStreamsBasicAuthConsumerProperties = messageConsumerProperties
@@ -55,33 +58,49 @@ open class MessagePrioritizationConsumer(
topology.addSource(MessagePrioritizationConstants.SOURCE_INPUT, *topics.toTypedArray())
- topology.addProcessor(MessagePrioritizationConstants.PROCESSOR_PRIORITIZE,
- bluePrintProcessorSupplier<ByteArray, ByteArray>(MessagePrioritizationConstants.PROCESSOR_PRIORITIZE,
- prioritizationConfiguration),
- MessagePrioritizationConstants.SOURCE_INPUT)
-
- topology.addProcessor(MessagePrioritizationConstants.PROCESSOR_AGGREGATE,
- bluePrintProcessorSupplier<String, String>(MessagePrioritizationConstants.PROCESSOR_AGGREGATE,
- prioritizationConfiguration),
- MessagePrioritizationConstants.PROCESSOR_PRIORITIZE)
-
- topology.addProcessor(MessagePrioritizationConstants.PROCESSOR_OUTPUT,
- bluePrintProcessorSupplier<String, String>(MessagePrioritizationConstants.PROCESSOR_OUTPUT,
- prioritizationConfiguration),
- MessagePrioritizationConstants.PROCESSOR_AGGREGATE)
-
- topology.addSink(MessagePrioritizationConstants.SINK_EXPIRED,
- prioritizationConfiguration.expiredTopic,
- Serdes.String().serializer(), MessagePrioritizationSerde().serializer(),
- MessagePrioritizationConstants.PROCESSOR_PRIORITIZE)
-
- /** To receive completed and error messages */
- topology.addSink(MessagePrioritizationConstants.SINK_OUTPUT,
- prioritizationConfiguration.outputTopic,
- Serdes.String().serializer(), MessagePrioritizationSerde().serializer(),
+ topology.addProcessor(
+ MessagePrioritizationConstants.PROCESSOR_PRIORITIZE,
+ bluePrintProcessorSupplier<ByteArray, ByteArray>(
MessagePrioritizationConstants.PROCESSOR_PRIORITIZE,
+ prioritizationConfiguration
+ ),
+ MessagePrioritizationConstants.SOURCE_INPUT
+ )
+
+ topology.addProcessor(
+ MessagePrioritizationConstants.PROCESSOR_AGGREGATE,
+ bluePrintProcessorSupplier<String, String>(
MessagePrioritizationConstants.PROCESSOR_AGGREGATE,
- MessagePrioritizationConstants.PROCESSOR_OUTPUT)
+ prioritizationConfiguration
+ ),
+ MessagePrioritizationConstants.PROCESSOR_PRIORITIZE
+ )
+
+ topology.addProcessor(
+ MessagePrioritizationConstants.PROCESSOR_OUTPUT,
+ bluePrintProcessorSupplier<String, String>(
+ MessagePrioritizationConstants.PROCESSOR_OUTPUT,
+ prioritizationConfiguration
+ ),
+ MessagePrioritizationConstants.PROCESSOR_AGGREGATE
+ )
+
+ topology.addSink(
+ MessagePrioritizationConstants.SINK_EXPIRED,
+ prioritizationConfiguration.expiredTopic,
+ Serdes.String().serializer(), MessagePrioritizationSerde().serializer(),
+ MessagePrioritizationConstants.PROCESSOR_PRIORITIZE
+ )
+
+ /** To receive completed and error messages */
+ topology.addSink(
+ MessagePrioritizationConstants.SINK_OUTPUT,
+ prioritizationConfiguration.outputTopic,
+ Serdes.String().serializer(), MessagePrioritizationSerde().serializer(),
+ MessagePrioritizationConstants.PROCESSOR_PRIORITIZE,
+ MessagePrioritizationConstants.PROCESSOR_AGGREGATE,
+ MessagePrioritizationConstants.PROCESSOR_OUTPUT
+ )
// Output will be sent to the group-output topic from Processor API
return topology
@@ -102,4 +121,4 @@ open class MessagePrioritizationConsumer(
streamingConsumerService.shutDown()
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/MessagePrioritizationData.kt b/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/MessagePrioritizationData.kt
index 3358a5643..3ecfa27e0 100644
--- a/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/MessagePrioritizationData.kt
+++ b/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/MessagePrioritizationData.kt
@@ -61,8 +61,9 @@ open class UpdateStateRequest : Serializable {
var state: String? = null
}
-data class CorrelationCheckResponse(var message: String? = null,
- var correlated: Boolean = false)
+data class CorrelationCheckResponse(
+ var message: String? = null,
+ var correlated: Boolean = false
+)
data class TypeCorrelationKey(val type: String, val correlationId: String)
-
diff --git a/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/MessagePrioritizeExtensions.kt b/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/MessagePrioritizeExtensions.kt
index ec061ad47..39d081455 100644
--- a/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/MessagePrioritizeExtensions.kt
+++ b/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/MessagePrioritizeExtensions.kt
@@ -21,30 +21,29 @@ import org.onap.ccsdk.cds.blueprintsprocessor.functions.message.prioritization.s
import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractComponentFunction
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintDependencyService
-
/**
* Register the MessagePrioritizationStateService and exposed dependency
*/
fun BluePrintDependencyService.messagePrioritizationStateService(): MessagePrioritizationStateService =
- instance(MessagePrioritizationStateService::class)
+ instance(MessagePrioritizationStateService::class)
/**
* Expose messagePrioritizationStateService to AbstractComponentFunction
*/
fun AbstractComponentFunction.messagePrioritizationStateService() =
- BluePrintDependencyService.messagePrioritizationStateService()
+ BluePrintDependencyService.messagePrioritizationStateService()
/**
* MessagePrioritization correlation extensions
*/
fun MessagePrioritization.toFormatedCorrelation(): String {
val ascendingKey = this.correlationId!!.split(",")
- .map { it.trim() }.sorted().joinToString(",")
+ .map { it.trim() }.sorted().joinToString(",")
return ascendingKey
}
fun MessagePrioritization.toTypeNCorrelation(): TypeCorrelationKey {
val ascendingKey = this.correlationId!!.split(",")
- .map { it.trim() }.sorted().joinToString(",")
+ .map { it.trim() }.sorted().joinToString(",")
return TypeCorrelationKey(this.type, ascendingKey)
}
diff --git a/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/api/MessagePrioritizationApi.kt b/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/api/MessagePrioritizationApi.kt
index 382cb9c8a..262dcb402 100644
--- a/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/api/MessagePrioritizationApi.kt
+++ b/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/api/MessagePrioritizationApi.kt
@@ -21,7 +21,13 @@ import org.onap.ccsdk.cds.blueprintsprocessor.functions.message.prioritization.d
import org.onap.ccsdk.cds.blueprintsprocessor.functions.message.prioritization.service.MessagePrioritizationStateService
import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.monoMdc
import org.springframework.http.MediaType
-import org.springframework.web.bind.annotation.*
+import org.springframework.web.bind.annotation.GetMapping
+import org.springframework.web.bind.annotation.PathVariable
+import org.springframework.web.bind.annotation.PostMapping
+import org.springframework.web.bind.annotation.RequestBody
+import org.springframework.web.bind.annotation.RequestMapping
+import org.springframework.web.bind.annotation.ResponseBody
+import org.springframework.web.bind.annotation.RestController
@RestController
@RequestMapping(value = ["/api/v1/message-prioritization"])
@@ -31,25 +37,30 @@ open class MessagePrioritizationApi(private val messagePrioritizationStateServic
@ResponseBody
fun ping(): String = "Success"
-
@GetMapping(path = ["/{id}"], produces = [MediaType.APPLICATION_JSON_VALUE])
@ResponseBody
fun messagePrioritization(@PathVariable(value = "id") id: String) = monoMdc {
messagePrioritizationStateService.getMessage(id)
}
- @PostMapping(path = ["/"], produces = [MediaType.APPLICATION_JSON_VALUE],
- consumes = [MediaType.APPLICATION_JSON_VALUE])
+ @PostMapping(
+ path = ["/"], produces = [MediaType.APPLICATION_JSON_VALUE],
+ consumes = [MediaType.APPLICATION_JSON_VALUE]
+ )
@ResponseBody
fun saveMessagePrioritization(@RequestBody messagePrioritization: MessagePrioritization) = monoMdc {
messagePrioritizationStateService.saveMessage(messagePrioritization)
}
- @PostMapping(path = ["/update-state"], produces = [MediaType.APPLICATION_JSON_VALUE],
- consumes = [MediaType.APPLICATION_JSON_VALUE])
+ @PostMapping(
+ path = ["/update-state"], produces = [MediaType.APPLICATION_JSON_VALUE],
+ consumes = [MediaType.APPLICATION_JSON_VALUE]
+ )
fun updateMessagePrioritizationState(@RequestBody updateMessageState: UpdateStateRequest) =
- monoMdc {
- messagePrioritizationStateService.setMessageState(updateMessageState.id,
- updateMessageState.state!!)
- }
-} \ No newline at end of file
+ monoMdc {
+ messagePrioritizationStateService.setMessageState(
+ updateMessageState.id,
+ updateMessageState.state!!
+ )
+ }
+}
diff --git a/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/db/PrioritizationMessageEntity.kt b/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/db/MessagePrioritization.kt
index 15e85b0e7..ce2085f68 100644
--- a/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/db/PrioritizationMessageEntity.kt
+++ b/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/db/MessagePrioritization.kt
@@ -21,8 +21,15 @@ import org.hibernate.annotations.Proxy
import org.springframework.data.annotation.LastModifiedDate
import org.springframework.data.jpa.domain.support.AuditingEntityListener
import org.springframework.data.jpa.repository.config.EnableJpaAuditing
-import java.util.*
-import javax.persistence.*
+import java.util.Date
+import javax.persistence.Column
+import javax.persistence.Entity
+import javax.persistence.EntityListeners
+import javax.persistence.Id
+import javax.persistence.Lob
+import javax.persistence.Table
+import javax.persistence.Temporal
+import javax.persistence.TemporalType
@EnableJpaAuditing
@EntityListeners(AuditingEntityListener::class)
@@ -30,6 +37,7 @@ import javax.persistence.*
@Table(name = "MESSAGE_PRIORITIZATION")
@Proxy(lazy = false)
open class MessagePrioritization {
+
@Id
@Column(name = "message_id", length = 50)
lateinit var id: String
@@ -78,4 +86,4 @@ open class MessagePrioritization {
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "expiry_date", nullable = false)
var expiryDate: Date? = null
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/db/MessagePrioritizationRepositories.kt b/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/db/MessagePrioritizationRepositories.kt
deleted file mode 100644
index 5c2495fd7..000000000
--- a/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/db/MessagePrioritizationRepositories.kt
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright © 2018-2019 AT&T Intellectual Property.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.cds.blueprintsprocessor.functions.message.prioritization.db
-
-import org.springframework.data.domain.Pageable
-import org.springframework.data.jpa.repository.JpaRepository
-import org.springframework.data.jpa.repository.Modifying
-import org.springframework.data.jpa.repository.Query
-import org.springframework.stereotype.Repository
-import org.springframework.transaction.annotation.Transactional
-import java.util.*
-
-@Repository
-@Transactional(readOnly = true)
-interface PrioritizationMessageRepository : JpaRepository<MessagePrioritization, String> {
-
- @Query("FROM MessagePrioritization pm WHERE pm.group = :group ORDER BY pm.createdDate asc")
- fun findByGroup(group: String, count: Pageable): List<MessagePrioritization>?
-
- @Query("FROM MessagePrioritization pm WHERE pm.group = :group AND pm.state in :states " +
- "ORDER BY pm.createdDate asc")
- fun findByGroupAndStateIn(group: String, states: List<String>, count: Pageable): List<MessagePrioritization>?
-
- @Query("FROM MessagePrioritization pm WHERE pm.group = :group AND pm.state in :states " +
- "ORDER BY pm.updatedDate asc")
- fun findByGroupAndStateInOrderByUpdatedDate(group: String, states: List<String>, count: Pageable)
- : List<MessagePrioritization>?
-
- @Query("FROM MessagePrioritization pm WHERE pm.group = :group AND pm.state in :states " +
- "AND pm.expiryDate > :expiryCheckDate ORDER BY pm.createdDate asc")
- fun findByGroupAndStateInAndNotExpiredDate(group: String, states: List<String>, expiryCheckDate: Date,
- count: Pageable): List<MessagePrioritization>?
-
- @Query("FROM MessagePrioritization pm WHERE pm.state in :states " +
- "AND pm.expiryDate < :expiryCheckDate ORDER BY pm.createdDate asc")
- fun findByStateInAndExpiredDate(states: List<String>, expiryCheckDate: Date,
- count: Pageable): List<MessagePrioritization>?
-
- @Query("FROM MessagePrioritization pm WHERE pm.group = :group AND pm.state in :states " +
- "AND pm.expiryDate < :expiryCheckDate ORDER BY pm.createdDate asc")
- fun findByGroupAndStateInAndExpiredDate(group: String, states: List<String>, expiryCheckDate: Date,
- count: Pageable): List<MessagePrioritization>?
-
- @Query("FROM MessagePrioritization pm WHERE pm.group = :group " +
- "AND pm.expiryDate < :expiryCheckDate ORDER BY pm.createdDate asc")
- fun findByByGroupAndExpiredDate(group: String, expiryCheckDate: Date, count: Pageable): List<MessagePrioritization>?
-
- @Query("FROM MessagePrioritization pm WHERE pm.group = :group AND pm.state in :states " +
- "AND pm.correlationId = :correlationId ORDER BY pm.createdDate asc")
- fun findByGroupAndCorrelationId(group: String, states: List<String>, correlationId: String)
- : List<MessagePrioritization>?
-
- @Query("FROM MessagePrioritization pm WHERE pm.group = :group AND pm.state in :states " +
- "AND pm.type in :types AND pm.correlationId = :correlationId ORDER BY pm.createdDate asc")
- fun findByGroupAndTypesAndCorrelationId(group: String, states: List<String>, types: List<String>,
- correlationId: String): List<MessagePrioritization>?
-
- @Modifying
- @Transactional
- @Query("UPDATE MessagePrioritization SET state = :state, updatedDate = :currentDate " +
- "WHERE id = :id")
- fun setStateForMessageId(id: String, state: String, currentDate: Date): Int
-
- @Modifying
- @Transactional
- @Query("UPDATE MessagePrioritization SET priority = :priority, updatedDate = :currentDate " +
- "WHERE id = :id")
- fun setPriorityForMessageId(id: String, priority: String, currentDate: Date): Int
-
- @Modifying
- @Transactional
- @Query("UPDATE MessagePrioritization SET state = :state, updatedDate = :currentDate " +
- "WHERE id IN :ids")
- fun setStateForMessageIds(ids: List<String>, state: String, currentDate: Date): Int
-
- @Modifying
- @Transactional
- @Query("UPDATE MessagePrioritization SET priority = :priority, updatedDate = :currentDate " +
- "WHERE id IN :ids")
- fun setPriorityForMessageIds(ids: List<String>, priority: String, currentDate: Date): Int
-
- @Modifying
- @Transactional
- @Query("UPDATE MessagePrioritization SET state = :state, error = :error, updatedDate = :currentDate " +
- "WHERE id = :id")
- fun setStateAndErrorForMessageId(id: String, state: String, error: String, currentDate: Date): Int
-
- @Modifying
- @Transactional
- @Query("UPDATE MessagePrioritization SET state = :state, " +
- "aggregatedMessageIds = :aggregatedMessageIds, updatedDate = :currentDate WHERE id = :id")
- fun setStateAndAggregatedMessageIds(id: String, state: String, aggregatedMessageIds: String, currentDate: Date): Int
-
- @Modifying
- @Transactional
- @Query("DELETE FROM MessagePrioritization pm WHERE pm.group = :group")
- fun deleteGroup(group: String)
-
- @Modifying
- @Transactional
- @Query("DELETE FROM MessagePrioritization pm WHERE pm.group = :group AND pm.state IN :states")
- fun deleteGroupAndStateIn(group: String, states: List<String>)
-}
-
diff --git a/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/db/PrioritizationMessageRepository.kt b/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/db/PrioritizationMessageRepository.kt
new file mode 100644
index 000000000..b0514838a
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/db/PrioritizationMessageRepository.kt
@@ -0,0 +1,160 @@
+/*
+ * Copyright © 2018-2019 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.cds.blueprintsprocessor.functions.message.prioritization.db
+
+import org.springframework.data.domain.Pageable
+import org.springframework.data.jpa.repository.JpaRepository
+import org.springframework.data.jpa.repository.Modifying
+import org.springframework.data.jpa.repository.Query
+import org.springframework.stereotype.Repository
+import org.springframework.transaction.annotation.Transactional
+import java.util.Date
+
+@Repository
+@Transactional(readOnly = true)
+interface PrioritizationMessageRepository : JpaRepository<MessagePrioritization, String> {
+
+ @Query("FROM MessagePrioritization pm WHERE pm.group = :group ORDER BY pm.createdDate asc")
+ fun findByGroup(group: String, count: Pageable): List<MessagePrioritization>?
+
+ @Query(
+ "FROM MessagePrioritization pm WHERE pm.group = :group AND pm.state in :states " +
+ "ORDER BY pm.createdDate asc"
+ )
+ fun findByGroupAndStateIn(group: String, states: List<String>, count: Pageable): List<MessagePrioritization>?
+
+ @Query(
+ "FROM MessagePrioritization pm WHERE pm.group = :group AND pm.state in :states " +
+ "ORDER BY pm.updatedDate asc"
+ )
+ fun findByGroupAndStateInOrderByUpdatedDate(group: String, states: List<String>, count: Pageable):
+ List<MessagePrioritization>?
+
+ @Query(
+ "FROM MessagePrioritization pm WHERE pm.group = :group AND pm.state in :states " +
+ "AND pm.expiryDate > :expiryCheckDate ORDER BY pm.createdDate asc"
+ )
+ fun findByGroupAndStateInAndNotExpiredDate(
+ group: String,
+ states: List<String>,
+ expiryCheckDate: Date,
+ count: Pageable
+ ): List<MessagePrioritization>?
+
+ @Query(
+ "FROM MessagePrioritization pm WHERE pm.state in :states " +
+ "AND pm.expiryDate < :expiryCheckDate ORDER BY pm.createdDate asc"
+ )
+ fun findByStateInAndExpiredDate(
+ states: List<String>,
+ expiryCheckDate: Date,
+ count: Pageable
+ ): List<MessagePrioritization>?
+
+ @Query(
+ "FROM MessagePrioritization pm WHERE pm.group = :group AND pm.state in :states " +
+ "AND pm.expiryDate < :expiryCheckDate ORDER BY pm.createdDate asc"
+ )
+ fun findByGroupAndStateInAndExpiredDate(
+ group: String,
+ states: List<String>,
+ expiryCheckDate: Date,
+ count: Pageable
+ ): List<MessagePrioritization>?
+
+ @Query(
+ "FROM MessagePrioritization pm WHERE pm.group = :group " +
+ "AND pm.expiryDate < :expiryCheckDate ORDER BY pm.createdDate asc"
+ )
+ fun findByByGroupAndExpiredDate(group: String, expiryCheckDate: Date, count: Pageable): List<MessagePrioritization>?
+
+ @Query(
+ "FROM MessagePrioritization pm WHERE pm.group = :group AND pm.state in :states " +
+ "AND pm.correlationId = :correlationId ORDER BY pm.createdDate asc"
+ )
+ fun findByGroupAndCorrelationId(group: String, states: List<String>, correlationId: String):
+ List<MessagePrioritization>?
+
+ @Query(
+ "FROM MessagePrioritization pm WHERE pm.group = :group AND pm.state in :states " +
+ "AND pm.type in :types AND pm.correlationId = :correlationId ORDER BY pm.createdDate asc"
+ )
+ fun findByGroupAndTypesAndCorrelationId(
+ group: String,
+ states: List<String>,
+ types: List<String>,
+ correlationId: String
+ ): List<MessagePrioritization>?
+
+ @Modifying
+ @Transactional
+ @Query(
+ "UPDATE MessagePrioritization SET state = :state, updatedDate = :currentDate " +
+ "WHERE id = :id"
+ )
+ fun setStateForMessageId(id: String, state: String, currentDate: Date): Int
+
+ @Modifying
+ @Transactional
+ @Query(
+ "UPDATE MessagePrioritization SET priority = :priority, updatedDate = :currentDate " +
+ "WHERE id = :id"
+ )
+ fun setPriorityForMessageId(id: String, priority: String, currentDate: Date): Int
+
+ @Modifying
+ @Transactional
+ @Query(
+ "UPDATE MessagePrioritization SET state = :state, updatedDate = :currentDate " +
+ "WHERE id IN :ids"
+ )
+ fun setStateForMessageIds(ids: List<String>, state: String, currentDate: Date): Int
+
+ @Modifying
+ @Transactional
+ @Query(
+ "UPDATE MessagePrioritization SET priority = :priority, updatedDate = :currentDate " +
+ "WHERE id IN :ids"
+ )
+ fun setPriorityForMessageIds(ids: List<String>, priority: String, currentDate: Date): Int
+
+ @Modifying
+ @Transactional
+ @Query(
+ "UPDATE MessagePrioritization SET state = :state, error = :error, updatedDate = :currentDate " +
+ "WHERE id = :id"
+ )
+ fun setStateAndErrorForMessageId(id: String, state: String, error: String, currentDate: Date): Int
+
+ @Modifying
+ @Transactional
+ @Query(
+ "UPDATE MessagePrioritization SET state = :state, " +
+ "aggregatedMessageIds = :aggregatedMessageIds, updatedDate = :currentDate WHERE id = :id"
+ )
+ fun setStateAndAggregatedMessageIds(id: String, state: String, aggregatedMessageIds: String, currentDate: Date): Int
+
+ @Modifying
+ @Transactional
+ @Query("DELETE FROM MessagePrioritization pm WHERE pm.group = :group")
+ fun deleteGroup(group: String)
+
+ @Modifying
+ @Transactional
+ @Query("DELETE FROM MessagePrioritization pm WHERE pm.group = :group AND pm.state IN :states")
+ fun deleteGroupAndStateIn(group: String, states: List<String>)
+}
diff --git a/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/service/MessagePrioritizationStateService.kt b/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/service/MessagePrioritizationStateService.kt
index 6138fa9d3..017658ff6 100644
--- a/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/service/MessagePrioritizationStateService.kt
+++ b/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/service/MessagePrioritizationStateService.kt
@@ -25,7 +25,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.logger
import org.springframework.data.domain.PageRequest
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional
-import java.util.*
+import java.util.Date
interface MessagePrioritizationStateService {
@@ -37,16 +37,20 @@ interface MessagePrioritizationStateService {
suspend fun getExpiryEligibleMessages(count: Int): List<MessagePrioritization>?
- suspend fun getMessageForStatesNotExpiredIn(group: String, states: List<String>, count: Int)
- : List<MessagePrioritization>?
+ suspend fun getMessageForStatesNotExpiredIn(group: String, states: List<String>, count: Int):
+ List<MessagePrioritization>?
- suspend fun getMessageForStatesExpired(group: String, states: List<String>, count: Int)
- : List<MessagePrioritization>?
+ suspend fun getMessageForStatesExpired(group: String, states: List<String>, count: Int):
+ List<MessagePrioritization>?
suspend fun getExpiredMessages(group: String, expiryDate: Date, count: Int): List<MessagePrioritization>?
- suspend fun getCorrelatedMessages(group: String, states: List<String>, types: List<String>?,
- correlationIds: String): List<MessagePrioritization>?
+ suspend fun getCorrelatedMessages(
+ group: String,
+ states: List<String>,
+ types: List<String>?,
+ correlationIds: String
+ ): List<MessagePrioritization>?
suspend fun updateMessagesState(ids: List<String>, state: String)
@@ -73,8 +77,9 @@ interface MessagePrioritizationStateService {
@Service
open class MessagePrioritizationStateServiceImpl(
- private val prioritizationMessageRepository: PrioritizationMessageRepository)
- : MessagePrioritizationStateService {
+ private val prioritizationMessageRepository: PrioritizationMessageRepository
+) :
+ MessagePrioritizationStateService {
private val log = logger(MessagePrioritizationStateServiceImpl::class)
@@ -89,7 +94,7 @@ open class MessagePrioritizationStateServiceImpl(
override suspend fun getMessage(id: String): MessagePrioritization {
return prioritizationMessageRepository.findById(id).orElseGet(null)
- ?: throw BluePrintProcessorException("couldn't find message for id($id)")
+ ?: throw BluePrintProcessorException("couldn't find message for id($id)")
}
override suspend fun getMessages(ids: List<String>): List<MessagePrioritization>? {
@@ -98,30 +103,42 @@ open class MessagePrioritizationStateServiceImpl(
override suspend fun getExpiryEligibleMessages(count: Int): List<MessagePrioritization>? {
return prioritizationMessageRepository
- .findByStateInAndExpiredDate(arrayListOf(MessageState.NEW.name, MessageState.WAIT.name),
- Date(), PageRequest.of(0, count))
- }
-
- override suspend fun getMessageForStatesNotExpiredIn(group: String, states: List<String>, count: Int)
- : List<MessagePrioritization>? {
- return prioritizationMessageRepository.findByGroupAndStateInAndNotExpiredDate(group,
- states, Date(), PageRequest.of(0, count))
- }
-
- override suspend fun getMessageForStatesExpired(group: String, states: List<String>, count: Int)
- : List<MessagePrioritization>? {
- return prioritizationMessageRepository.findByGroupAndStateInAndExpiredDate(group,
- states, Date(), PageRequest.of(0, count))
- }
-
- override suspend fun getExpiredMessages(group: String, expiryDate: Date, count: Int)
- : List<MessagePrioritization>? {
- return prioritizationMessageRepository.findByByGroupAndExpiredDate(group,
- expiryDate, PageRequest.of(0, count))
- }
-
- override suspend fun getCorrelatedMessages(group: String, states: List<String>, types: List<String>?,
- correlationIds: String): List<MessagePrioritization>? {
+ .findByStateInAndExpiredDate(
+ arrayListOf(MessageState.NEW.name, MessageState.WAIT.name),
+ Date(), PageRequest.of(0, count)
+ )
+ }
+
+ override suspend fun getMessageForStatesNotExpiredIn(group: String, states: List<String>, count: Int):
+ List<MessagePrioritization>? {
+ return prioritizationMessageRepository.findByGroupAndStateInAndNotExpiredDate(
+ group,
+ states, Date(), PageRequest.of(0, count)
+ )
+ }
+
+ override suspend fun getMessageForStatesExpired(group: String, states: List<String>, count: Int):
+ List<MessagePrioritization>? {
+ return prioritizationMessageRepository.findByGroupAndStateInAndExpiredDate(
+ group,
+ states, Date(), PageRequest.of(0, count)
+ )
+ }
+
+ override suspend fun getExpiredMessages(group: String, expiryDate: Date, count: Int):
+ List<MessagePrioritization>? {
+ return prioritizationMessageRepository.findByByGroupAndExpiredDate(
+ group,
+ expiryDate, PageRequest.of(0, count)
+ )
+ }
+
+ override suspend fun getCorrelatedMessages(
+ group: String,
+ states: List<String>,
+ types: List<String>?,
+ correlationIds: String
+ ): List<MessagePrioritization>? {
return if (!types.isNullOrEmpty()) {
prioritizationMessageRepository.findByGroupAndTypesAndCorrelationId(group, states, types, correlationIds)
} else {
@@ -185,7 +202,9 @@ open class MessagePrioritizationStateServiceImpl(
}
override suspend fun deleteExpiredMessage(group: String, retentionDays: Int) {
- return prioritizationMessageRepository.deleteGroupAndStateIn(group,
- arrayListOf(MessageState.EXPIRED.name))
+ return prioritizationMessageRepository.deleteGroupAndStateIn(
+ group,
+ arrayListOf(MessageState.EXPIRED.name)
+ )
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/topology/MessageAggregateProcessor.kt b/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/topology/MessageAggregateProcessor.kt
index 45f5c773d..3e697e633 100644
--- a/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/topology/MessageAggregateProcessor.kt
+++ b/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/topology/MessageAggregateProcessor.kt
@@ -22,7 +22,6 @@ import org.onap.ccsdk.cds.blueprintsprocessor.functions.message.prioritization.M
import org.onap.ccsdk.cds.blueprintsprocessor.functions.message.prioritization.MessageState
import org.onap.ccsdk.cds.controllerblueprints.core.logger
-
open class MessageAggregateProcessor : AbstractMessagePrioritizeProcessor<String, String>() {
private val log = logger(MessageAggregateProcessor::class)
@@ -50,16 +49,21 @@ open class MessageAggregateProcessor : AbstractMessagePrioritizeProcessor<String
storeMessages.forEach { messagePrioritization ->
try {
/** Update the data store */
- messagePrioritizationStateService.setMessageStateANdError(messagePrioritization.id,
- MessageState.ERROR.name, error)
+ messagePrioritizationStateService.setMessageStateANdError(
+ messagePrioritization.id,
+ MessageState.ERROR.name, error
+ )
/** Publish to Error topic */
- this.processorContext.forward(messagePrioritization.id, messagePrioritization,
- To.child(MessagePrioritizationConstants.SINK_OUTPUT))
+ this.processorContext.forward(
+ messagePrioritization.id, messagePrioritization,
+ To.child(MessagePrioritizationConstants.SINK_OUTPUT)
+ )
} catch (sendException: Exception) {
- log.error("failed to update/publish error message(${messagePrioritization.id}) : " +
- "${sendException.message}", e)
+ log.error(
+ "failed to update/publish error message(${messagePrioritization.id}) : " +
+ "${sendException.message}", e
+ )
}
-
}
}
}
@@ -73,4 +77,4 @@ open class MessageAggregateProcessor : AbstractMessagePrioritizeProcessor<String
processorContext.forward(id, id, To.child(MessagePrioritizationConstants.PROCESSOR_OUTPUT))
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/topology/MessageOutputProcessor.kt b/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/topology/MessageOutputProcessor.kt
index 34faa1b3b..cf6520df5 100644
--- a/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/topology/MessageOutputProcessor.kt
+++ b/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/topology/MessageOutputProcessor.kt
@@ -22,7 +22,6 @@ import org.onap.ccsdk.cds.blueprintsprocessor.functions.message.prioritization.M
import org.onap.ccsdk.cds.blueprintsprocessor.functions.message.prioritization.MessageState
import org.onap.ccsdk.cds.controllerblueprints.core.logger
-
open class MessageOutputProcessor : AbstractMessagePrioritizeProcessor<String, String>() {
private val log = logger(MessageOutputProcessor::class)
@@ -32,4 +31,4 @@ open class MessageOutputProcessor : AbstractMessagePrioritizeProcessor<String, S
val message = messagePrioritizationStateService.updateMessageState(value, MessageState.COMPLETED.name)
processorContext.forward(message.id, message, To.child(MessagePrioritizationConstants.SINK_OUTPUT))
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/topology/MessagePrioritizationPunctuators.kt b/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/topology/MessagePrioritizationPunctuators.kt
index a745e034c..5435ebe30 100644
--- a/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/topology/MessagePrioritizationPunctuators.kt
+++ b/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/topology/MessagePrioritizationPunctuators.kt
@@ -24,41 +24,46 @@ import org.onap.ccsdk.cds.blueprintsprocessor.functions.message.prioritization.s
import org.onap.ccsdk.cds.blueprintsprocessor.message.kafka.AbstractBluePrintMessagePunctuator
import org.onap.ccsdk.cds.controllerblueprints.core.logger
-
-class MessagePriorityExpiryPunctuator(private val messagePrioritizationStateService: MessagePrioritizationStateService)
- : AbstractBluePrintMessagePunctuator() {
+class MessagePriorityExpiryPunctuator(private val messagePrioritizationStateService: MessagePrioritizationStateService) :
+ AbstractBluePrintMessagePunctuator() {
private val log = logger(MessagePriorityExpiryPunctuator::class)
lateinit var configuration: PrioritizationConfiguration
override suspend fun punctuateNB(timestamp: Long) {
- log.info("**** executing expiry punctuator applicationId(${processorContext.applicationId()}), " +
- "taskId(${processorContext.taskId()})")
+ log.info(
+ "**** executing expiry punctuator applicationId(${processorContext.applicationId()}), " +
+ "taskId(${processorContext.taskId()})"
+ )
val expiryConfiguration = configuration.expiryConfiguration
val fetchMessages = messagePrioritizationStateService
- .getExpiryEligibleMessages(expiryConfiguration.maxPollRecord)
+ .getExpiryEligibleMessages(expiryConfiguration.maxPollRecord)
val expiredIds = fetchMessages?.map { it.id }
if (expiredIds != null && expiredIds.isNotEmpty()) {
messagePrioritizationStateService.updateMessagesState(expiredIds, MessageState.EXPIRED.name)
fetchMessages.forEach { expired ->
- processorContext.forward(expired.id, expired,
- To.child(MessagePrioritizationConstants.SINK_EXPIRED))
+ processorContext.forward(
+ expired.id, expired,
+ To.child(MessagePrioritizationConstants.SINK_EXPIRED)
+ )
}
}
}
}
-class MessagePriorityCleanPunctuator(private val messagePrioritizationStateService: MessagePrioritizationStateService)
- : AbstractBluePrintMessagePunctuator() {
+class MessagePriorityCleanPunctuator(private val messagePrioritizationStateService: MessagePrioritizationStateService) :
+ AbstractBluePrintMessagePunctuator() {
private val log = logger(MessagePriorityCleanPunctuator::class)
lateinit var configuration: PrioritizationConfiguration
override suspend fun punctuateNB(timestamp: Long) {
- log.info("**** executing clean punctuator applicationId(${processorContext.applicationId()}), " +
- "taskId(${processorContext.taskId()})")
- //TODO
+ log.info(
+ "**** executing clean punctuator applicationId(${processorContext.applicationId()}), " +
+ "taskId(${processorContext.taskId()})"
+ )
+ // TODO
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/topology/MessagePrioritizationSerdes.kt b/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/topology/MessagePrioritizationSerde.kt
index 00d454727..f2a481f74 100644
--- a/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/topology/MessagePrioritizationSerdes.kt
+++ b/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/topology/MessagePrioritizationSerde.kt
@@ -37,7 +37,7 @@ open class MessagePrioritizationSerde : Serde<MessagePrioritization> {
return object : Deserializer<MessagePrioritization> {
override fun deserialize(topic: String, data: ByteArray): MessagePrioritization {
return JacksonUtils.readValue(String(data), MessagePrioritization::class.java)
- ?: throw BluePrintProcessorException("failed to convert")
+ ?: throw BluePrintProcessorException("failed to convert")
}
override fun configure(configs: MutableMap<String, *>?, isKey: Boolean) {
@@ -61,4 +61,4 @@ open class MessagePrioritizationSerde : Serde<MessagePrioritization> {
}
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/topology/MessagePrioritizeProcessor.kt b/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/topology/MessagePrioritizeProcessor.kt
index 7dde2655d..431e02f30 100644
--- a/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/topology/MessagePrioritizeProcessor.kt
+++ b/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/topology/MessagePrioritizeProcessor.kt
@@ -29,8 +29,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.cds.controllerblueprints.core.logger
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import java.time.Duration
-import java.util.*
-
+import java.util.UUID
open class MessagePrioritizeProcessor : AbstractMessagePrioritizeProcessor<ByteArray, ByteArray>() {
@@ -42,7 +41,7 @@ open class MessagePrioritizeProcessor : AbstractMessagePrioritizeProcessor<ByteA
override suspend fun processNB(key: ByteArray, value: ByteArray) {
log.info("***** received in prioritize processor key(${String(key)})")
val messagePrioritize = JacksonUtils.readValue(String(value), MessagePrioritization::class.java)
- ?: throw BluePrintProcessorException("failed to convert")
+ ?: throw BluePrintProcessorException("failed to convert")
try {
// Save the Message
messagePrioritizationStateService.saveMessage(messagePrioritize)
@@ -51,11 +50,15 @@ open class MessagePrioritizeProcessor : AbstractMessagePrioritizeProcessor<ByteA
messagePrioritize.error = "failed in Prioritize message(${messagePrioritize.id}) : ${e.message}"
log.error(messagePrioritize.error)
/** Update the data store */
- messagePrioritizationStateService.setMessageStateANdError(messagePrioritize.id, MessageState.ERROR.name,
- messagePrioritize.error!!)
+ messagePrioritizationStateService.setMessageStateANdError(
+ messagePrioritize.id, MessageState.ERROR.name,
+ messagePrioritize.error!!
+ )
/** Publish to Output topic */
- this.processorContext.forward(messagePrioritize.id, messagePrioritize,
- To.child(MessagePrioritizationConstants.SINK_OUTPUT))
+ this.processorContext.forward(
+ messagePrioritize.id, messagePrioritize,
+ To.child(MessagePrioritizationConstants.SINK_OUTPUT)
+ )
}
}
@@ -68,8 +71,10 @@ open class MessagePrioritizeProcessor : AbstractMessagePrioritizeProcessor<ByteA
}
override fun close() {
- log.info("closing prioritization processor applicationId(${processorContext.applicationId()}), " +
- "taskId(${processorContext.taskId()})")
+ log.info(
+ "closing prioritization processor applicationId(${processorContext.applicationId()}), " +
+ "taskId(${processorContext.taskId()})"
+ )
expiryCancellable.cancel()
cleanCancellable.cancel()
}
@@ -79,8 +84,10 @@ open class MessagePrioritizeProcessor : AbstractMessagePrioritizeProcessor<ByteA
expiryPunctuator.processorContext = processorContext
expiryPunctuator.configuration = prioritizationConfiguration
val expiryConfiguration = prioritizationConfiguration.expiryConfiguration
- expiryCancellable = processorContext.schedule(Duration.ofMillis(expiryConfiguration.frequencyMilli),
- PunctuationType.WALL_CLOCK_TIME, expiryPunctuator)
+ expiryCancellable = processorContext.schedule(
+ Duration.ofMillis(expiryConfiguration.frequencyMilli),
+ PunctuationType.WALL_CLOCK_TIME, expiryPunctuator
+ )
log.info("Expiry punctuator setup complete with frequency(${expiryConfiguration.frequencyMilli})mSec")
}
@@ -89,10 +96,14 @@ open class MessagePrioritizeProcessor : AbstractMessagePrioritizeProcessor<ByteA
cleanPunctuator.processorContext = processorContext
cleanPunctuator.configuration = prioritizationConfiguration
val cleanConfiguration = prioritizationConfiguration.cleanConfiguration
- cleanCancellable = processorContext.schedule(Duration.ofDays(cleanConfiguration.expiredRecordsHoldDays.toLong()),
- PunctuationType.WALL_CLOCK_TIME, cleanPunctuator)
- log.info("Clean punctuator setup complete with expiry " +
- "hold(${cleanConfiguration.expiredRecordsHoldDays})days")
+ cleanCancellable = processorContext.schedule(
+ Duration.ofDays(cleanConfiguration.expiredRecordsHoldDays.toLong()),
+ PunctuationType.WALL_CLOCK_TIME, cleanPunctuator
+ )
+ log.info(
+ "Clean punctuator setup complete with expiry " +
+ "hold(${cleanConfiguration.expiredRecordsHoldDays})days"
+ )
}
open suspend fun handleCorrelationAndNextStep(messagePrioritization: MessagePrioritization) {
@@ -102,25 +113,31 @@ open class MessagePrioritizeProcessor : AbstractMessagePrioritizeProcessor<ByteA
val group = messagePrioritization.group
val correlationId = messagePrioritization.correlationId!!
val types = getGroupCorrelationTypes(messagePrioritization)
- log.info("checking correlation for message($id), group($group), types($types), " +
- "correlation id($correlationId)")
+ log.info(
+ "checking correlation for message($id), group($group), types($types), " +
+ "correlation id($correlationId)"
+ )
/** Get all previously received messages from database for group and optional types and correlation Id */
- val waitingCorrelatedStoreMessages = messagePrioritizationStateService.getCorrelatedMessages(group,
- arrayListOf(MessageState.NEW.name, MessageState.WAIT.name), types, correlationId)
+ val waitingCorrelatedStoreMessages = messagePrioritizationStateService.getCorrelatedMessages(
+ group,
+ arrayListOf(MessageState.NEW.name, MessageState.WAIT.name), types, correlationId
+ )
/** If multiple records found, then check correlation */
if (!waitingCorrelatedStoreMessages.isNullOrEmpty() && waitingCorrelatedStoreMessages.size > 1) {
/** Check all correlation satisfies */
val correlationResults = MessageCorrelationUtils
- .correlatedMessagesWithTypes(waitingCorrelatedStoreMessages, types)
+ .correlatedMessagesWithTypes(waitingCorrelatedStoreMessages, types)
if (correlationResults.correlated) {
/** Correlation satisfied */
val correlatedIds = waitingCorrelatedStoreMessages.map { it.id }.joinToString(",")
/** Send only correlated ids to next processor */
- this.processorContext.forward(UUID.randomUUID().toString(), correlatedIds,
- To.child(MessagePrioritizationConstants.PROCESSOR_AGGREGATE))
+ this.processorContext.forward(
+ UUID.randomUUID().toString(), correlatedIds,
+ To.child(MessagePrioritizationConstants.PROCESSOR_AGGREGATE)
+ )
} else {
/** Correlation not satisfied */
log.trace("correlation not matched : ${correlationResults.message}")
@@ -135,8 +152,10 @@ open class MessagePrioritizeProcessor : AbstractMessagePrioritizeProcessor<ByteA
} else {
// No Correlation check needed, simply forward to next processor.
messagePrioritizationStateService.setMessageState(messagePrioritization.id, MessageState.PRIORITIZED.name)
- this.processorContext.forward(messagePrioritization.id, messagePrioritization.id,
- To.child(MessagePrioritizationConstants.PROCESSOR_AGGREGATE))
+ this.processorContext.forward(
+ messagePrioritization.id, messagePrioritization.id,
+ To.child(MessagePrioritizationConstants.PROCESSOR_AGGREGATE)
+ )
}
}
@@ -145,4 +164,4 @@ open class MessagePrioritizeProcessor : AbstractMessagePrioritizeProcessor<ByteA
open fun getGroupCorrelationTypes(messagePrioritization: MessagePrioritization): List<String>? {
return null
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/utils/MessageCorrelationUtils.kt b/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/utils/MessageCorrelationUtils.kt
index cc30af2f1..fb35df75b 100644
--- a/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/utils/MessageCorrelationUtils.kt
+++ b/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/utils/MessageCorrelationUtils.kt
@@ -43,8 +43,8 @@ object MessageCorrelationUtils {
}
/** Assumption is message is of same group and checking for required types **/
- fun correlatedMessagesWithTypes(collectedMessages: List<MessagePrioritization>, types: List<String>?)
- : CorrelationCheckResponse {
+ fun correlatedMessagesWithTypes(collectedMessages: List<MessagePrioritization>, types: List<String>?):
+ CorrelationCheckResponse {
return if (!types.isNullOrEmpty() && collectedMessages.size > 1) {
@@ -56,8 +56,8 @@ object MessageCorrelationUtils {
val copyTypes = types.toTypedArray().copyOf().toMutableList()
val filteredMessage = collectedMessages.filter {
- !it.correlationId.isNullOrBlank()
- && types.contains(it.type)
+ !it.correlationId.isNullOrBlank() &&
+ types.contains(it.type)
}
var correlatedKeys: MutableSet<String> = mutableSetOf()
if (filteredMessage.isNotEmpty()) {
@@ -79,4 +79,4 @@ object MessageCorrelationUtils {
return correlatedMessages(collectedMessages)
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/utils/MessagePrioritizationSample.kt b/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/utils/MessagePrioritizationSample.kt
index 185022973..4a36a40f3 100644
--- a/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/utils/MessagePrioritizationSample.kt
+++ b/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/utils/MessagePrioritizationSample.kt
@@ -21,7 +21,9 @@ import org.onap.ccsdk.cds.blueprintsprocessor.functions.message.prioritization.E
import org.onap.ccsdk.cds.blueprintsprocessor.functions.message.prioritization.PrioritizationConfiguration
import org.onap.ccsdk.cds.blueprintsprocessor.functions.message.prioritization.ShutDownConfiguration
import org.onap.ccsdk.cds.blueprintsprocessor.functions.message.prioritization.db.MessagePrioritization
-import java.util.*
+import java.util.Calendar
+import java.util.Date
+import java.util.UUID
object MessagePrioritizationSample {
@@ -57,8 +59,10 @@ object MessagePrioritizationSample {
fun sampleMessages(groupName: String, messageState: String, count: Int): List<MessagePrioritization> {
val messages: MutableList<MessagePrioritization> = arrayListOf()
repeat(count) {
- val backPressureMessage = createMessage(groupName, messageState,
- "sample-type", null)
+ val backPressureMessage = createMessage(
+ groupName, messageState,
+ "sample-type", null
+ )
messages.add(backPressureMessage)
}
return messages
@@ -67,26 +71,37 @@ object MessagePrioritizationSample {
fun sampleMessageWithSameCorrelation(groupName: String, messageState: String, count: Int): List<MessagePrioritization> {
val messages: MutableList<MessagePrioritization> = arrayListOf()
repeat(count) {
- val backPressureMessage = createMessage(groupName, messageState, "sample-type",
- "key1=value1,key2=value2")
+ val backPressureMessage = createMessage(
+ groupName, messageState, "sample-type",
+ "key1=value1,key2=value2"
+ )
messages.add(backPressureMessage)
}
return messages
}
- fun sampleMessageWithDifferentTypeSameCorrelation(groupName: String, messageState: String,
- count: Int): List<MessagePrioritization> {
+ fun sampleMessageWithDifferentTypeSameCorrelation(
+ groupName: String,
+ messageState: String,
+ count: Int
+ ): List<MessagePrioritization> {
val messages: MutableList<MessagePrioritization> = arrayListOf()
repeat(count) {
- val backPressureMessage = createMessage(groupName, messageState, "type-$it",
- "key1=value1,key2=value2")
+ val backPressureMessage = createMessage(
+ groupName, messageState, "type-$it",
+ "key1=value1,key2=value2"
+ )
messages.add(backPressureMessage)
}
return messages
}
- fun createMessage(groupName: String, messageState: String, messageType: String,
- messageCorrelationId: String?): MessagePrioritization {
+ fun createMessage(
+ groupName: String,
+ messageState: String,
+ messageType: String,
+ messageCorrelationId: String?
+ ): MessagePrioritization {
return MessagePrioritization().apply {
id = UUID.randomUUID().toString()
@@ -101,4 +116,4 @@ object MessagePrioritizationSample {
expiryDate = currentDatePlusDays(3)
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/utils/MessageProcessorUtils.kt b/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/utils/MessageProcessorUtils.kt
index 02614d821..7e5862cce 100644
--- a/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/utils/MessageProcessorUtils.kt
+++ b/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/utils/MessageProcessorUtils.kt
@@ -23,8 +23,8 @@ import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintDependencyS
object MessageProcessorUtils {
- fun <K, V> bluePrintProcessorSupplier(name: String, prioritizationConfiguration: PrioritizationConfiguration)
- : ProcessorSupplier<K, V> {
+ fun <K, V> bluePrintProcessorSupplier(name: String, prioritizationConfiguration: PrioritizationConfiguration):
+ ProcessorSupplier<K, V> {
return ProcessorSupplier<K, V> {
// Dynamically resolve the Prioritization Processor
val processorInstance = BluePrintDependencyService.instance<AbstractMessagePrioritizeProcessor<K, V>>(name)
@@ -32,5 +32,4 @@ object MessageProcessorUtils {
processorInstance
}
}
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/message-prioritizaion/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/MessagePrioritizationConsumerTest.kt b/ms/blueprintsprocessor/functions/message-prioritizaion/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/MessagePrioritizationConsumerTest.kt
index 84f13dc1d..0ed9598f0 100644
--- a/ms/blueprintsprocessor/functions/message-prioritizaion/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/MessagePrioritizationConsumerTest.kt
+++ b/ms/blueprintsprocessor/functions/message-prioritizaion/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/MessagePrioritizationConsumerTest.kt
@@ -44,29 +44,32 @@ import org.springframework.test.context.junit4.SpringRunner
import kotlin.test.Test
import kotlin.test.assertNotNull
-
@RunWith(SpringRunner::class)
@DataJpaTest
@DirtiesContext
-@ContextConfiguration(classes = [BluePrintMessageLibConfiguration::class,
- BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class,
- MessagePrioritizationConfiguration::class, TestDatabaseConfiguration::class])
-@TestPropertySource(properties =
-[
- "spring.jpa.show-sql=true",
- "spring.jpa.properties.hibernate.show_sql=true",
- "spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl",
-
- "blueprintsprocessor.messageconsumer.prioritize-input.type=kafka-streams-basic-auth",
- "blueprintsprocessor.messageconsumer.prioritize-input.bootstrapServers=127.0.0.1:9092",
- "blueprintsprocessor.messageconsumer.prioritize-input.applicationId=test-prioritize-application",
- "blueprintsprocessor.messageconsumer.prioritize-input.topic=prioritize-input-topic",
-
- // To send initial test message
- "blueprintsprocessor.messageproducer.prioritize-input.type=kafka-basic-auth",
- "blueprintsprocessor.messageproducer.prioritize-input.bootstrapServers=127.0.0.1:9092",
- "blueprintsprocessor.messageproducer.prioritize-input.topic=prioritize-input-topic"
-])
+@ContextConfiguration(
+ classes = [BluePrintMessageLibConfiguration::class,
+ BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class,
+ MessagePrioritizationConfiguration::class, TestDatabaseConfiguration::class]
+)
+@TestPropertySource(
+ properties =
+ [
+ "spring.jpa.show-sql=true",
+ "spring.jpa.properties.hibernate.show_sql=true",
+ "spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl",
+
+ "blueprintsprocessor.messageconsumer.prioritize-input.type=kafka-streams-basic-auth",
+ "blueprintsprocessor.messageconsumer.prioritize-input.bootstrapServers=127.0.0.1:9092",
+ "blueprintsprocessor.messageconsumer.prioritize-input.applicationId=test-prioritize-application",
+ "blueprintsprocessor.messageconsumer.prioritize-input.topic=prioritize-input-topic",
+
+ // To send initial test message
+ "blueprintsprocessor.messageproducer.prioritize-input.type=kafka-basic-auth",
+ "blueprintsprocessor.messageproducer.prioritize-input.bootstrapServers=127.0.0.1:9092",
+ "blueprintsprocessor.messageproducer.prioritize-input.topic=prioritize-input-topic"
+ ]
+)
open class MessagePrioritizationConsumerTest {
@Autowired
@@ -89,7 +92,7 @@ open class MessagePrioritizationConsumerTest {
assertNotNull(prioritizationMessageRepository, "failed to get prioritizationMessageRepository")
val messagePrioritizationService: MessagePrioritizationStateService = BluePrintDependencyService
- .instance(MessagePrioritizationStateService::class)
+ .instance(MessagePrioritizationStateService::class)
assertNotNull(messagePrioritizationService, "failed to get messagePrioritizationService")
MessagePrioritizationSample.sampleMessages(MessageState.NEW.name, 1).forEach {
@@ -106,7 +109,7 @@ open class MessagePrioritizationConsumerTest {
val configuration = MessagePrioritizationSample.samplePrioritizationConfiguration()
val streamingConsumerService = bluePrintMessageLibPropertyService
- .blueprintMessageConsumerService(configuration.inputTopicSelector)
+ .blueprintMessageConsumerService(configuration.inputTopicSelector)
assertNotNull(streamingConsumerService, "failed to get blueprintMessageConsumerService")
val spyStreamingConsumerService = spyk(streamingConsumerService)
@@ -115,11 +118,10 @@ open class MessagePrioritizationConsumerTest {
val messagePrioritizationConsumer = MessagePrioritizationConsumer(bluePrintMessageLibPropertyService)
val spyMessagePrioritizationConsumer = spyk(messagePrioritizationConsumer)
-
// Test Topology
val kafkaStreamConsumerFunction = spyMessagePrioritizationConsumer.kafkaStreamConsumerFunction(configuration)
val messageConsumerProperties = bluePrintMessageLibPropertyService
- .messageConsumerProperties("blueprintsprocessor.messageconsumer.prioritize-input")
+ .messageConsumerProperties("blueprintsprocessor.messageconsumer.prioritize-input")
val topology = kafkaStreamConsumerFunction.createTopology(messageConsumerProperties, null)
assertNotNull(topology, "failed to get create topology")
@@ -130,7 +132,7 @@ open class MessagePrioritizationConsumerTest {
}
/** Integration Kafka Testing, Enable and use this test case only for local desktop testing with real kafka broker */
- //@Test
+ // @Test
fun testMessagePrioritizationConsumer() {
runBlocking {
val messagePrioritizationConsumer = MessagePrioritizationConsumer(bluePrintMessageLibPropertyService)
@@ -138,38 +140,44 @@ open class MessagePrioritizationConsumerTest {
/** Send sample message with every 1 sec */
val blueprintMessageProducerService = bluePrintMessageLibPropertyService
- .blueprintMessageProducerService("prioritize-input") as KafkaBasicAuthMessageProducerService
+ .blueprintMessageProducerService("prioritize-input") as KafkaBasicAuthMessageProducerService
launch {
- MessagePrioritizationSample.sampleMessages(MessageState.NEW.name, 2).forEach {
+ MessagePrioritizationSample.sampleMessages(MessageState.NEW.name, 2).forEach {
delay(100)
val headers: MutableMap<String, String> = hashMapOf()
headers["id"] = it.id
- blueprintMessageProducerService.sendMessageNB(message = it.asJsonString(false),
- headers = headers)
+ blueprintMessageProducerService.sendMessageNB(
+ message = it.asJsonString(false),
+ headers = headers
+ )
}
MessagePrioritizationSample
- .sampleMessageWithSameCorrelation("same-group", MessageState.NEW.name, 2)
- .forEach {
- delay(100)
- val headers: MutableMap<String, String> = hashMapOf()
- headers["id"] = it.id
- blueprintMessageProducerService.sendMessageNB(message = it.asJsonString(false),
- headers = headers)
- }
+ .sampleMessageWithSameCorrelation("same-group", MessageState.NEW.name, 2)
+ .forEach {
+ delay(100)
+ val headers: MutableMap<String, String> = hashMapOf()
+ headers["id"] = it.id
+ blueprintMessageProducerService.sendMessageNB(
+ message = it.asJsonString(false),
+ headers = headers
+ )
+ }
MessagePrioritizationSample
- .sampleMessageWithDifferentTypeSameCorrelation("group-typed", MessageState.NEW.name, 3)
- .forEach {
- delay(2000)
- val headers: MutableMap<String, String> = hashMapOf()
- headers["id"] = it.id
- blueprintMessageProducerService.sendMessageNB(message = it.asJsonString(false),
- headers = headers)
- }
+ .sampleMessageWithDifferentTypeSameCorrelation("group-typed", MessageState.NEW.name, 3)
+ .forEach {
+ delay(2000)
+ val headers: MutableMap<String, String> = hashMapOf()
+ headers["id"] = it.id
+ blueprintMessageProducerService.sendMessageNB(
+ message = it.asJsonString(false),
+ headers = headers
+ )
+ }
}
delay(10000)
messagePrioritizationConsumer.shutDown()
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/message-prioritizaion/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/TestConfiguration.kt b/ms/blueprintsprocessor/functions/message-prioritizaion/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/TestConfiguration.kt
index 4e3eb191b..be65c1d7c 100644
--- a/ms/blueprintsprocessor/functions/message-prioritizaion/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/TestConfiguration.kt
+++ b/ms/blueprintsprocessor/functions/message-prioritizaion/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/TestConfiguration.kt
@@ -42,6 +42,7 @@ open class TestDatabaseConfiguration {
@Service(MessagePrioritizationConstants.PROCESSOR_PRIORITIZE)
open class TestMessagePrioritizeProcessor : MessagePrioritizeProcessor() {
+
override fun getGroupCorrelationTypes(messagePrioritization: MessagePrioritization): List<String>? {
return when (messagePrioritization.group) {
"group-typed" -> arrayListOf("type-0", "type-1", "type-2")
@@ -54,4 +55,4 @@ open class TestMessagePrioritizeProcessor : MessagePrioritizeProcessor() {
open class DefaultMessageAggregateProcessor() : MessageAggregateProcessor()
@Service(MessagePrioritizationConstants.PROCESSOR_OUTPUT)
-open class DefaultMessageOutputProcessor : MessageOutputProcessor() \ No newline at end of file
+open class DefaultMessageOutputProcessor : MessageOutputProcessor()
diff --git a/ms/blueprintsprocessor/functions/message-prioritizaion/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/utils/MessageCorrelationUtilsTest.kt b/ms/blueprintsprocessor/functions/message-prioritizaion/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/utils/MessageCorrelationUtilsTest.kt
index b470db909..3876cbba5 100644
--- a/ms/blueprintsprocessor/functions/message-prioritizaion/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/utils/MessageCorrelationUtilsTest.kt
+++ b/ms/blueprintsprocessor/functions/message-prioritizaion/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/utils/MessageCorrelationUtilsTest.kt
@@ -26,10 +26,14 @@ class MessageCorrelationUtilsTest {
@Test
fun testCorrelationKeysReordered() {
- val message1 = MessagePrioritizationSample.createMessage("sample-group", MessageState.NEW.name,
- "type-0", "key1=value1,key2=value2")
- val message2 = MessagePrioritizationSample.createMessage("sample-group", MessageState.NEW.name,
- "type-0", "key2=value2,key1=value1")
+ val message1 = MessagePrioritizationSample.createMessage(
+ "sample-group", MessageState.NEW.name,
+ "type-0", "key1=value1,key2=value2"
+ )
+ val message2 = MessagePrioritizationSample.createMessage(
+ "sample-group", MessageState.NEW.name,
+ "type-0", "key2=value2,key1=value1"
+ )
val multipleMessages: MutableList<MessagePrioritization> = arrayListOf()
multipleMessages.add(message1)
@@ -43,20 +47,26 @@ class MessageCorrelationUtilsTest {
/** With Types **/
/* Assumption is Same group with different types */
val differentTypesWithSameCorrelationMessages = MessagePrioritizationSample
- .sampleMessageWithDifferentTypeSameCorrelation("sample-group", MessageState.NEW.name, 3)
+ .sampleMessageWithDifferentTypeSameCorrelation("sample-group", MessageState.NEW.name, 3)
val differentTypesWithSameCorrelationMessagesResponse = MessageCorrelationUtils.correlatedMessagesWithTypes(
- differentTypesWithSameCorrelationMessages,
- arrayListOf("type-0", "type-1", "type-2"))
- assertTrue(differentTypesWithSameCorrelationMessagesResponse.correlated,
- "failed to correlate differentTypesWithSameCorrelationMessagesResponse")
+ differentTypesWithSameCorrelationMessages,
+ arrayListOf("type-0", "type-1", "type-2")
+ )
+ assertTrue(
+ differentTypesWithSameCorrelationMessagesResponse.correlated,
+ "failed to correlate differentTypesWithSameCorrelationMessagesResponse"
+ )
/* Assumption is Same group with different types and one missing expected types,
In this case type-3 message is missing */
val differentTypesWithSameCorrelationMessagesResWithMissingType = MessageCorrelationUtils.correlatedMessagesWithTypes(
- differentTypesWithSameCorrelationMessages,
- arrayListOf("type-0", "type-1", "type-2", "type-3"))
- assertTrue(!differentTypesWithSameCorrelationMessagesResWithMissingType.correlated,
- "failed to correlate differentTypesWithSameCorrelationMessagesResWithMissingType")
+ differentTypesWithSameCorrelationMessages,
+ arrayListOf("type-0", "type-1", "type-2", "type-3")
+ )
+ assertTrue(
+ !differentTypesWithSameCorrelationMessagesResWithMissingType.correlated,
+ "failed to correlate differentTypesWithSameCorrelationMessagesResWithMissingType"
+ )
}
@Test
@@ -64,35 +74,48 @@ class MessageCorrelationUtilsTest {
/** With ignoring Types */
/** Assumption is only one message received */
val withSameCorrelationOneMessages = MessagePrioritizationSample
- .sampleMessageWithSameCorrelation("sample-group", MessageState.NEW.name, 1)
+ .sampleMessageWithSameCorrelation("sample-group", MessageState.NEW.name, 1)
val withSameCorrelationOneMessagesResp = MessageCorrelationUtils.correlatedMessagesWithTypes(
- withSameCorrelationOneMessages, null)
- assertTrue(!withSameCorrelationOneMessagesResp.correlated,
- "failed to correlate withSameCorrelationMessagesResp")
+ withSameCorrelationOneMessages, null
+ )
+ assertTrue(
+ !withSameCorrelationOneMessagesResp.correlated,
+ "failed to correlate withSameCorrelationMessagesResp"
+ )
/** Assumption is two message received for same group with same correlation */
val withSameCorrelationMessages = MessagePrioritizationSample
- .sampleMessageWithSameCorrelation("sample-group", MessageState.NEW.name, 2)
+ .sampleMessageWithSameCorrelation("sample-group", MessageState.NEW.name, 2)
val withSameCorrelationMessagesResp = MessageCorrelationUtils.correlatedMessagesWithTypes(
- withSameCorrelationMessages, null)
- assertTrue(withSameCorrelationMessagesResp.correlated,
- "failed to correlate withSameCorrelationMessagesResp")
+ withSameCorrelationMessages, null
+ )
+ assertTrue(
+ withSameCorrelationMessagesResp.correlated,
+ "failed to correlate withSameCorrelationMessagesResp"
+ )
}
@Test
fun differentTypesWithDifferentCorrelationMessage() {
/** Assumption is two message received for same group with different expected types and different correlation */
- val message1 = MessagePrioritizationSample.createMessage("sample-group", MessageState.NEW.name,
- "type-0", "key1=value1,key2=value2")
- val message2 = MessagePrioritizationSample.createMessage("sample-group", MessageState.NEW.name,
- "type-1", "key1=value1,key2=value3")
+ val message1 = MessagePrioritizationSample.createMessage(
+ "sample-group", MessageState.NEW.name,
+ "type-0", "key1=value1,key2=value2"
+ )
+ val message2 = MessagePrioritizationSample.createMessage(
+ "sample-group", MessageState.NEW.name,
+ "type-1", "key1=value1,key2=value3"
+ )
val differentTypesWithDifferentCorrelationMessage: MutableList<MessagePrioritization> = arrayListOf()
differentTypesWithDifferentCorrelationMessage.add(message1)
differentTypesWithDifferentCorrelationMessage.add(message2)
val differentTypesWithDifferentCorrelationMessageResp = MessageCorrelationUtils.correlatedMessagesWithTypes(
- differentTypesWithDifferentCorrelationMessage,
- arrayListOf("type-0", "type-1"))
- assertTrue(!differentTypesWithDifferentCorrelationMessageResp.correlated,
- "failed to correlate differentTypesWithDifferentCorrelationMessageResp")
+ differentTypesWithDifferentCorrelationMessage,
+ arrayListOf("type-0", "type-1")
+ )
+ assertTrue(
+ !differentTypesWithDifferentCorrelationMessageResp.correlated,
+ "failed to correlate differentTypesWithDifferentCorrelationMessageResp"
+ )
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutor.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutor.kt
index cdee3903b..1262e8500 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutor.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutor.kt
@@ -31,8 +31,8 @@ import org.springframework.stereotype.Component
@Component("component-netconf-executor")
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-open class ComponentNetconfExecutor(private var componentFunctionScriptingService: ComponentFunctionScriptingService)
- : AbstractComponentFunction() {
+open class ComponentNetconfExecutor(private var componentFunctionScriptingService: ComponentFunctionScriptingService) :
+ AbstractComponentFunction() {
companion object {
const val SCRIPT_TYPE = "script-type"
@@ -56,9 +56,10 @@ open class ComponentNetconfExecutor(private var componentFunctionScriptingServic
}
scriptComponent = componentFunctionScriptingService
- .scriptInstance<AbstractScriptComponentFunction>(this, scriptType,
- scriptClassReference, scriptDependencies)
-
+ .scriptInstance<AbstractScriptComponentFunction>(
+ this, scriptType,
+ scriptClassReference, scriptDependencies
+ )
checkNotNull(scriptComponent) { "failed to get netconf script component" }
@@ -68,7 +69,6 @@ open class ComponentNetconfExecutor(private var componentFunctionScriptingServic
override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
bluePrintRuntimeService.getBluePrintError()
- .addError("Failed in ComponentNetconfExecutor : ${runtimeException.message}")
-
+ .addError("Failed in ComponentNetconfExecutor : ${runtimeException.message}")
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/JsonParserService.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/JsonParserService.kt
index 73c82acb2..abaa7fed1 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/JsonParserService.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/JsonParserService.kt
@@ -19,6 +19,4 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor
import org.springframework.stereotype.Service
@Service("json-parser-service")
-class JsonParserService {
-
-} \ No newline at end of file
+class JsonParserService
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/NetconfComponentFunction.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/NetconfComponentFunction.kt
index 5e0b4a117..58e6151f0 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/NetconfComponentFunction.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/NetconfComponentFunction.kt
@@ -25,40 +25,62 @@ import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptC
@Deprecated("Methods defined as extension function of AbstractComponentFunction")
abstract class NetconfComponentFunction : AbstractScriptComponentFunction() {
- @Deprecated(" Use resourceResolutionService method directly",
- replaceWith = ReplaceWith("resourceResolutionService()",
- "org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.resourceResolutionService"))
+ @Deprecated(
+ " Use resourceResolutionService method directly",
+ replaceWith = ReplaceWith(
+ "resourceResolutionService()",
+ "org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.resourceResolutionService"
+ )
+ )
open fun resourceResolutionService(): ResourceResolutionService =
- functionDependencyInstanceAsType(ResourceResolutionConstants.SERVICE_RESOURCE_RESOLUTION)
+ functionDependencyInstanceAsType(ResourceResolutionConstants.SERVICE_RESOURCE_RESOLUTION)
// Called from python script
- @Deprecated(" Use netconfDeviceInfo method directly",
- replaceWith = ReplaceWith("netconfDeviceInfo(requirementName)",
- "org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.netconfDeviceInfo"))
+ @Deprecated(
+ " Use netconfDeviceInfo method directly",
+ replaceWith = ReplaceWith(
+ "netconfDeviceInfo(requirementName)",
+ "org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.netconfDeviceInfo"
+ )
+ )
fun initializeNetconfConnection(requirementName: String): NetconfDevice {
val deviceInfo = netconfDeviceInfo(requirementName)
return NetconfDevice(deviceInfo)
}
- @Deprecated(" Use artifactContent method directly",
- replaceWith = ReplaceWith("artifactContent(artifactName)",
- "org.onap.ccsdk.cds.blueprintsprocessor.services.execution.artifactContent"))
+ @Deprecated(
+ " Use artifactContent method directly",
+ replaceWith = ReplaceWith(
+ "artifactContent(artifactName)",
+ "org.onap.ccsdk.cds.blueprintsprocessor.services.execution.artifactContent"
+ )
+ )
fun generateMessage(artifactName: String): String {
return bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, artifactName)
}
- @Deprecated(" Use storedContentFromResolvedArtifact method directly",
- replaceWith = ReplaceWith("storedContentFromResolvedArtifact(resolutionKey, artifactName)",
- "org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.storedContentFromResolvedArtifact"))
+ @Deprecated(
+ " Use storedContentFromResolvedArtifact method directly",
+ replaceWith = ReplaceWith(
+ "storedContentFromResolvedArtifact(resolutionKey, artifactName)",
+ "org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.storedContentFromResolvedArtifact"
+ )
+ )
fun resolveFromDatabase(resolutionKey: String, artifactName: String): String = runBlocking {
resourceResolutionService().resolveFromDatabase(bluePrintRuntimeService, artifactName, resolutionKey)
}
- @Deprecated(" Use contentFromResolvedArtifact method directly",
- replaceWith = ReplaceWith("resolveAndGenerateMessage(artifactPrefix)",
- "org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.resolveAndGenerateMessage"))
+ @Deprecated(
+ " Use contentFromResolvedArtifact method directly",
+ replaceWith = ReplaceWith(
+ "resolveAndGenerateMessage(artifactPrefix)",
+ "org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.resolveAndGenerateMessage"
+ )
+ )
fun resolveAndGenerateMessage(artifactPrefix: String): String = runBlocking {
- resourceResolutionService().resolveResources(bluePrintRuntimeService, nodeTemplateName,
- artifactPrefix, mapOf())
+ resourceResolutionService().resolveResources(
+ bluePrintRuntimeService, nodeTemplateName,
+ artifactPrefix, mapOf()
+ )
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/NetconfDevice.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/NetconfDevice.kt
index 61090f485..a69e4d9d6 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/NetconfDevice.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/NetconfDevice.kt
@@ -28,4 +28,4 @@ data class NetconfDevice(val deviceInfo: DeviceInfo) {
netconfSession = NetconfSessionImpl(deviceInfo, netconfRpcService)
netconfRpcService.setNetconfSession(netconfSession)
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/NetconfExecutorConfiguration.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/NetconfExecutorConfiguration.kt
index 214969346..f9aa38f8c 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/NetconfExecutorConfiguration.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/NetconfExecutorConfiguration.kt
@@ -25,4 +25,4 @@ import org.springframework.context.annotation.Configuration
@ComponentScan
@EnableConfigurationProperties
@ConditionalOnProperty(name = ["blueprintsprocessor.netconfExecutor.enabled"], havingValue = "true")
-open class NetconfExecutorConfiguration \ No newline at end of file
+open class NetconfExecutorConfiguration
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/NetconfExecutorExtensions.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/NetconfExecutorExtensions.kt
index 510621b2e..f52cb0a62 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/NetconfExecutorExtensions.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/NetconfExecutorExtensions.kt
@@ -29,8 +29,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
* Register the Netconf module exposed dependency
*/
fun BluePrintDependencyService.netconfClientService(): ResourceResolutionService =
- instance(ResourceResolutionConstants.SERVICE_RESOURCE_RESOLUTION)
-
+ instance(ResourceResolutionConstants.SERVICE_RESOURCE_RESOLUTION)
fun AbstractComponentFunction.netconfDevice(requirementName: String): NetconfDevice {
val deviceInfo = netconfDeviceInfo(requirementName)
@@ -43,8 +42,10 @@ fun AbstractComponentFunction.netconfDeviceInfo(requirementName: String): Device
val requirement = blueprintContext.nodeTemplateRequirement(nodeTemplateName, requirementName)
- val capabilityProperties = bluePrintRuntimeService.resolveNodeTemplateCapabilityProperties(requirement
- .node!!, requirement.capability!!)
+ val capabilityProperties = bluePrintRuntimeService.resolveNodeTemplateCapabilityProperties(
+ requirement
+ .node!!, requirement.capability!!
+ )
return netconfDeviceInfo(capabilityProperties)
}
@@ -55,4 +56,4 @@ private fun AbstractComponentFunction.netconfDeviceInfo(capabilityProperty: Muta
/**
* Blocking Methods called from Jython Scripts
- */ \ No newline at end of file
+ */
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/DeviceInfo.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/DeviceInfo.kt
index 2395dddb8..2f10bb56b 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/DeviceInfo.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/DeviceInfo.kt
@@ -40,7 +40,8 @@ class DeviceInfo {
override fun toString(): String {
return "$ipAddress:$port"
}
- //TODO: should this be a data class instead? Is anything using the JSON serdes?
+
+ // TODO: should this be a data class instead? Is anything using the JSON serdes?
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/NetconfException.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/NetconfException.kt
index 7e6a88b48..62a6ac3e3 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/NetconfException.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/NetconfException.kt
@@ -20,5 +20,4 @@ class NetconfException : Exception {
constructor(cause: Throwable) : super(cause)
constructor(message: String) : super(message)
constructor(message: String, cause: Throwable) : super(message, cause)
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/NetconfMessage.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/NetconfMessage.kt
index 1d5f515d0..744476c2a 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/NetconfMessage.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/NetconfMessage.kt
@@ -18,17 +18,18 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.api
import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.utils.RpcStatus
-data class DeviceResponse(var status: String? = null,
- var errorMessage: String? = null,
- var responseMessage: String? = null,
- var requestMessage: String? = null) {
+data class DeviceResponse(
+ var status: String? = null,
+ var errorMessage: String? = null,
+ var responseMessage: String? = null,
+ var requestMessage: String? = null
+) {
fun isSuccess(): Boolean {
return this.status == RpcStatus.SUCCESS && this.errorMessage.isNullOrEmpty()
}
}
-
/**
* Creates an event of a given type and for the specified subject and the current time.
*
@@ -37,10 +38,12 @@ data class DeviceResponse(var status: String? = null,
* @param messageId id of the message related to the event
* @param deviceInfo device of event
*/
-class NetconfReceivedEvent(val type: Type,
- val messagePayload: String = "",
- val messageId: String = "",
- val deviceInfo: DeviceInfo) {
+class NetconfReceivedEvent(
+ val type: Type,
+ val messagePayload: String = "",
+ val messageId: String = "",
+ val deviceInfo: DeviceInfo
+) {
enum class Type {
DEVICE_REPLY,
@@ -48,4 +51,4 @@ class NetconfReceivedEvent(val type: Type,
DEVICE_ERROR,
SESSION_CLOSED
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/NetconfRpcService.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/NetconfRpcService.kt
index ecb6267f5..ea93ebd40 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/NetconfRpcService.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/NetconfRpcService.kt
@@ -54,8 +54,11 @@ interface NetconfRpcService {
* @param editDefaultOperation, default set to none. Valid values: merge, replace, create, delete, none
* @return Device response
*/
- fun editConfig(messageContent: String, configTarget: String = NetconfDatastore.CANDIDATE.datastore,
- editDefaultOperation: String = ModifyAction.NONE.action): DeviceResponse
+ fun editConfig(
+ messageContent: String,
+ configTarget: String = NetconfDatastore.CANDIDATE.datastore,
+ editDefaultOperation: String = ModifyAction.NONE.action
+ ): DeviceResponse
/**
* Invoke custom RPC as provided as input.
@@ -96,8 +99,12 @@ interface NetconfRpcService {
* If unspecified, the confirm timeout defaults to 600 seconds.
* @return Device response
*/
- fun commit(confirmed: Boolean = false, confirmTimeout: Int = 60, persist: String = "",
- persistId: String = ""): DeviceResponse
+ fun commit(
+ confirmed: Boolean = false,
+ confirmTimeout: Int = 60,
+ persist: String = "",
+ persistId: String = ""
+ ): DeviceResponse
/**
* Cancels an ongoing confirmed commit. If the <persist-id> parameter is not given,
@@ -148,4 +155,4 @@ interface NetconfRpcService {
* @return Device response
*/
fun get(filter: String): DeviceResponse
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/NetconfSession.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/NetconfSession.kt
index 0272d1a19..ceeb444f7 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/NetconfSession.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/NetconfSession.kt
@@ -25,7 +25,6 @@ interface NetconfSession {
*/
fun connect()
-
/**
* Disconnect netconf session
*/
@@ -83,4 +82,4 @@ interface NetconfSession {
* @return Network capabilities as strings in a Set.
*/
fun getDeviceCapabilitiesSet(): Set<String>
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfDeviceCommunicator.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfDeviceCommunicator.kt
index 06a71cad3..8f8fc1463 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfDeviceCommunicator.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfDeviceCommunicator.kt
@@ -22,15 +22,26 @@ import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.api.Net
import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.utils.NetconfMessageUtils
import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.utils.RpcMessageUtils
import org.slf4j.LoggerFactory
-import java.io.*
-import java.nio.charset.*
-import java.util.concurrent.*
+import java.io.BufferedReader
+import java.io.IOException
+import java.io.InputStream
+import java.io.InputStreamReader
+import java.io.OutputStream
+import java.io.OutputStreamWriter
+import java.nio.charset.StandardCharsets
+import java.util.concurrent.CancellationException
+import java.util.concurrent.CompletableFuture
+import java.util.concurrent.ExecutionException
+import java.util.concurrent.TimeUnit
+import java.util.concurrent.TimeoutException
-class NetconfDeviceCommunicator(private var inputStream: InputStream,
- private var out: OutputStream,
- private val deviceInfo: DeviceInfo,
- private val sessionListener: NetconfSessionListener,
- private var replies: MutableMap<String, CompletableFuture<String>>) : Thread() {
+class NetconfDeviceCommunicator(
+ private var inputStream: InputStream,
+ private var out: OutputStream,
+ private val deviceInfo: DeviceInfo,
+ private val sessionListener: NetconfSessionListener,
+ private var replies: MutableMap<String, CompletableFuture<String>>
+) : Thread() {
private val log = LoggerFactory.getLogger(NetconfDeviceCommunicator::class.java)
private var state = NetconfMessageState.NO_MATCHING_PATTERN
@@ -62,9 +73,12 @@ class NetconfDeviceCommunicator(private var inputStream: InputStream,
if (deviceReply == RpcMessageUtils.END_PATTERN) {
socketClosed = true
bufferReader.close()
- sessionListener.accept(NetconfReceivedEvent(
- NetconfReceivedEvent.Type.DEVICE_UNREGISTERED,
- deviceInfo = deviceInfo))
+ sessionListener.accept(
+ NetconfReceivedEvent(
+ NetconfReceivedEvent.Type.DEVICE_UNREGISTERED,
+ deviceInfo = deviceInfo
+ )
+ )
} else {
deviceReply = deviceReply.replace(RpcMessageUtils.END_PATTERN, "")
receivedMessage(deviceReply)
@@ -75,9 +89,12 @@ class NetconfDeviceCommunicator(private var inputStream: InputStream,
if (!NetconfMessageUtils.validateChunkedFraming(deviceReply)) {
log.debug("$deviceInfo: Received badly framed message $deviceReply")
socketClosed = true
- sessionListener.accept(NetconfReceivedEvent(
- NetconfReceivedEvent.Type.DEVICE_ERROR,
- deviceInfo = deviceInfo))
+ sessionListener.accept(
+ NetconfReceivedEvent(
+ NetconfReceivedEvent.Type.DEVICE_ERROR,
+ deviceInfo = deviceInfo
+ )
+ )
} else {
deviceReply = deviceReply.replace(RpcMessageUtils.MSGLEN_REGEX_PATTERN.toRegex(), "")
deviceReply = deviceReply.replace(NetconfMessageUtils.CHUNKED_END_REGEX_PATTERN.toRegex(), "")
@@ -86,20 +103,22 @@ class NetconfDeviceCommunicator(private var inputStream: InputStream,
}
}
}
-
} catch (e: IOException) {
log.warn("$deviceInfo: Fail while reading from channel", e)
- sessionListener.accept(NetconfReceivedEvent(
- NetconfReceivedEvent.Type.DEVICE_ERROR,
- deviceInfo = deviceInfo))
+ sessionListener.accept(
+ NetconfReceivedEvent(
+ NetconfReceivedEvent.Type.DEVICE_ERROR,
+ deviceInfo = deviceInfo
+ )
+ )
}
-
}
/**
* State machine for the Netconf message parser
*/
internal enum class NetconfMessageState {
+
NO_MATCHING_PATTERN {
override fun evaluateChar(c: Char): NetconfMessageState {
return when (c) {
@@ -207,25 +226,29 @@ class NetconfDeviceCommunicator(private var inputStream: InputStream,
log.error("$deviceInfo: Failed to send message : \n $request", e)
future.completeExceptionally(e)
}
-
}
return future
}
private fun receivedMessage(deviceReply: String) {
- if (deviceReply.contains(RpcMessageUtils.RPC_REPLY) || deviceReply.contains(RpcMessageUtils.RPC_ERROR)
- || deviceReply.contains(RpcMessageUtils.HELLO)) {
- log.info("$deviceInfo: Received message with messageId: {} \n $deviceReply",
- NetconfMessageUtils.getMsgId(deviceReply))
-
+ if (deviceReply.contains(RpcMessageUtils.RPC_REPLY) || deviceReply.contains(RpcMessageUtils.RPC_ERROR) ||
+ deviceReply.contains(RpcMessageUtils.HELLO)
+ ) {
+ log.info(
+ "$deviceInfo: Received message with messageId: {} \n $deviceReply",
+ NetconfMessageUtils.getMsgId(deviceReply)
+ )
} else {
log.error("$deviceInfo: Invalid message received: \n $deviceReply")
}
- sessionListener.accept(NetconfReceivedEvent(
- NetconfReceivedEvent.Type.DEVICE_REPLY,
- deviceReply,
- NetconfMessageUtils.getMsgId(deviceReply),
- deviceInfo))
+ sessionListener.accept(
+ NetconfReceivedEvent(
+ NetconfReceivedEvent.Type.DEVICE_REPLY,
+ deviceReply,
+ NetconfMessageUtils.getMsgId(deviceReply),
+ deviceInfo
+ )
+ )
}
/**
@@ -241,7 +264,10 @@ class NetconfDeviceCommunicator(private var inputStream: InputStream,
* @throws TimeoutException if the wait timed outStream
*/
internal fun getFutureFromSendMessage(
- fut: CompletableFuture<String>, timeout: Long, timeUnit: TimeUnit): String {
+ fut: CompletableFuture<String>,
+ timeout: Long,
+ timeUnit: TimeUnit
+ ): String {
return fut.get(timeout, timeUnit)
}
}
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImpl.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImpl.kt
index 2e33b9aa2..b9fab06b1 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImpl.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImpl.kt
@@ -17,7 +17,11 @@
package org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.core
-import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.api.*
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.api.DeviceInfo
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.api.DeviceResponse
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.api.NetconfException
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.api.NetconfRpcService
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.api.NetconfSession
import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.utils.NetconfMessageUtils
import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.utils.RpcStatus
import org.slf4j.LoggerFactory
@@ -58,7 +62,7 @@ class NetconfRpcServiceImpl(private var deviceInfo: DeviceInfo) : NetconfRpcServ
override fun invokeRpc(rpc: String): DeviceResponse {
var output = DeviceResponse()
- //Attempt to extract the message-id field from the <rpc call
+ // Attempt to extract the message-id field from the <rpc call
val updatedMessageId = messageIdInteger.getAndIncrement().toString()
val origMessageId = NetconfMessageUtils.getMsgId(rpc)
log.info("$deviceInfo: invokeRpc: updating rpc original message-id:($origMessageId) to messageId($updatedMessageId)")
@@ -197,8 +201,11 @@ class NetconfRpcServiceImpl(private var deviceInfo: DeviceInfo) : NetconfRpcServ
return output
}
- override fun editConfig(messageContent: String, configTarget: String,
- editDefaultOperation: String): DeviceResponse {
+ override fun editConfig(
+ messageContent: String,
+ configTarget: String,
+ editDefaultOperation: String
+ ): DeviceResponse {
var response = DeviceResponse()
val messageId = messageIdInteger.getAndIncrement().toString()
log.info("$deviceInfo: editConfig: messageId($messageId)")
@@ -252,7 +259,7 @@ class NetconfRpcServiceImpl(private var deviceInfo: DeviceInfo) : NetconfRpcServ
response.requestMessage = request
val rpcResponse = netconfSession.asyncRpc(request, messageId).get(responseTimeout.toLong(), TimeUnit.SECONDS)
- //TODO catch TimeoutException and ExecutionException
+ // TODO catch TimeoutException and ExecutionException
if (!NetconfMessageUtils.checkReply(rpcResponse)) {
log.error("RPC response didn't pass validation... $rpcResponse")
throw NetconfException(rpcResponse)
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionImpl.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionImpl.kt
index 6be93179f..3d3eee8f0 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionImpl.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionImpl.kt
@@ -22,14 +22,22 @@ import org.apache.sshd.client.SshClient
import org.apache.sshd.client.channel.ClientChannel
import org.apache.sshd.client.session.ClientSession
import org.apache.sshd.common.FactoryManager
-import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.api.*
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.api.DeviceInfo
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.api.NetconfException
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.api.NetconfRpcService
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.api.NetconfSession
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.api.NetconfSessionListener
import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.utils.NetconfMessageUtils
import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.utils.RpcMessageUtils
import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.utils.RpcStatus
import org.slf4j.LoggerFactory
import java.io.IOException
-import java.util.*
-import java.util.concurrent.*
+import java.util.Collections
+import java.util.concurrent.CompletableFuture
+import java.util.concurrent.ConcurrentHashMap
+import java.util.concurrent.ExecutionException
+import java.util.concurrent.TimeUnit
+import java.util.concurrent.TimeoutException
class NetconfSessionImpl(private val deviceInfo: DeviceInfo, private val rpcService: NetconfRpcService) :
NetconfSession {
@@ -55,8 +63,10 @@ class NetconfSessionImpl(private val deviceInfo: DeviceInfo, private val rpcServ
override fun connect() {
try {
- log.info("$deviceInfo: Connecting to Netconf Device with timeouts C:${deviceInfo.connectTimeout}, " +
- "R:${deviceInfo.replyTimeout}, I:${deviceInfo.idleTimeout}")
+ log.info(
+ "$deviceInfo: Connecting to Netconf Device with timeouts C:${deviceInfo.connectTimeout}, " +
+ "R:${deviceInfo.replyTimeout}, I:${deviceInfo.idleTimeout}"
+ )
startConnection()
log.info("$deviceInfo: Connected to Netconf Device")
} catch (e: NetconfException) {
@@ -67,13 +77,14 @@ class NetconfSessionImpl(private val deviceInfo: DeviceInfo, private val rpcServ
override fun disconnect() {
var retryNum = 3
- while(rpcService.closeSession(false).status
- .equals(RpcStatus.FAILURE, true) &&retryNum>0) {
+ while (rpcService.closeSession(false).status
+ .equals(RpcStatus.FAILURE, true) && retryNum > 0
+ ) {
log.error("disconnect: graceful disconnect failed, retrying $retryNum times...")
- retryNum--;
+ retryNum--
}
- //if we can't close the session, try to force terminate.
- if(retryNum == 0) {
+ // if we can't close the session, try to force terminate.
+ if (retryNum == 0) {
log.error("disconnect: trying to force-terminate the session.")
rpcService.closeSession(true)
}
@@ -95,13 +106,17 @@ class NetconfSessionImpl(private val deviceInfo: DeviceInfo, private val rpcServ
checkAndReestablish()
try {
- return streamHandler.getFutureFromSendMessage(streamHandler.sendMessage(formattedRequest, messageId),
- replyTimeout.toLong(), TimeUnit.SECONDS)
+ return streamHandler.getFutureFromSendMessage(
+ streamHandler.sendMessage(formattedRequest, messageId),
+ replyTimeout.toLong(), TimeUnit.SECONDS
+ )
} catch (e: InterruptedException) {
throw NetconfException("$deviceInfo: Interrupted while waiting for reply for request: $formattedRequest", e)
} catch (e: TimeoutException) {
- throw NetconfException("$deviceInfo: Timed out while waiting for reply for request $formattedRequest after $replyTimeout sec.",
- e)
+ throw NetconfException(
+ "$deviceInfo: Timed out while waiting for reply for request $formattedRequest after $replyTimeout sec.",
+ e
+ )
} catch (e: ExecutionException) {
log.warn("$deviceInfo: Closing session($sessionId) due to unexpected Error", e)
try {
@@ -179,10 +194,9 @@ class NetconfSessionImpl(private val deviceInfo: DeviceInfo, private val rpcServ
} catch (e: Exception) {
throw NetconfException("$deviceInfo: Failed to establish SSH session", e)
}
-
}
- //Needed to unit test connect method interacting with client.start in startClient() below
+ // Needed to unit test connect method interacting with client.start in startClient() below
private fun setupNewSSHClient() {
client = SshClient.setUpDefaultClient()
}
@@ -210,8 +224,12 @@ class NetconfSessionImpl(private val deviceInfo: DeviceInfo, private val rpcServ
private fun authSession() {
session.addPasswordIdentity(deviceInfo.password)
session.auth().verify(connectionTimeout, TimeUnit.SECONDS)
- val event = session.waitFor(ImmutableSet.of(ClientSession.ClientSessionEvent.WAIT_AUTH,
- ClientSession.ClientSessionEvent.CLOSED, ClientSession.ClientSessionEvent.AUTHED), 0)
+ val event = session.waitFor(
+ ImmutableSet.of(
+ ClientSession.ClientSessionEvent.WAIT_AUTH,
+ ClientSession.ClientSessionEvent.CLOSED, ClientSession.ClientSessionEvent.AUTHED
+ ), 0
+ )
if (!event.contains(ClientSession.ClientSessionEvent.AUTHED)) {
throw NetconfException("$deviceInfo: Failed to authenticate session.")
}
@@ -233,8 +251,10 @@ class NetconfSessionImpl(private val deviceInfo: DeviceInfo, private val rpcServ
private fun setupHandler() {
val sessionListener: NetconfSessionListener = NetconfSessionListenerImpl(this)
- streamHandler = NetconfDeviceCommunicator(channel.invertedOut, channel.invertedIn, deviceInfo,
- sessionListener, replies)
+ streamHandler = NetconfDeviceCommunicator(
+ channel.invertedOut, channel.invertedIn, deviceInfo,
+ sessionListener, replies
+ )
exchangeHelloMessage()
}
@@ -254,7 +274,7 @@ class NetconfSessionImpl(private val deviceInfo: DeviceInfo, private val rpcServ
}
val capabilityMatcher = NetconfMessageUtils.CAPABILITY_REGEX_PATTERN.matcher(serverHelloResponse)
- while (capabilityMatcher.find()) { //TODO: refactor to add unit test easily for device capability accumulation.
+ while (capabilityMatcher.find()) { // TODO: refactor to add unit test easily for device capability accumulation.
deviceCapabilities.add(capabilityMatcher.group(1))
}
}
@@ -300,9 +320,18 @@ class NetconfSessionImpl(private val deviceInfo: DeviceInfo, private val rpcServ
* internal function for accessing errorReplies for testing.
*/
internal fun getErrorReplies() = errorReplies
+
internal fun clearErrorReplies() = errorReplies.clear()
internal fun clearReplies() = replies.clear()
- internal fun setClient(client: SshClient) { this.client = client }
- internal fun setSession(session: ClientSession) { this.session = session }
- internal fun setChannel(channel: ClientChannel) { this.channel = channel }
+ internal fun setClient(client: SshClient) {
+ this.client = client
+ }
+
+ internal fun setSession(session: ClientSession) {
+ this.session = session
+ }
+
+ internal fun setChannel(channel: ClientChannel) {
+ this.channel = channel
+ }
}
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionListenerImpl.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionListenerImpl.kt
index c8b9c5543..e27b51d16 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionListenerImpl.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionListenerImpl.kt
@@ -28,6 +28,7 @@ import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.api.Net
*/
internal class NetconfSessionListenerImpl(private val session: NetconfSessionImpl) : NetconfSessionListener {
+
override fun accept(event: NetconfReceivedEvent) {
when (event.type) {
NetconfReceivedEvent.Type.DEVICE_UNREGISTERED -> session.disconnect()
@@ -36,4 +37,4 @@ internal class NetconfSessionListenerImpl(private val session: NetconfSessionImp
NetconfReceivedEvent.Type.DEVICE_REPLY -> session.addDeviceReply(event.messageId, event.messagePayload)
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/utils/NetconfMessageUtils.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/utils/NetconfMessageUtils.kt
index 34816b79b..232dca621 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/utils/NetconfMessageUtils.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/utils/NetconfMessageUtils.kt
@@ -28,7 +28,6 @@ import javax.xml.XMLConstants
import javax.xml.parsers.DocumentBuilderFactory
import kotlin.text.Charsets.UTF_8
-
class NetconfMessageUtils {
companion object {
@@ -91,8 +90,12 @@ class NetconfMessageUtils {
return rpc.toString()
}
- fun editConfig(messageId: String, configType: String, defaultOperation: String?,
- newConfiguration: String): String {
+ fun editConfig(
+ messageId: String,
+ configType: String,
+ defaultOperation: String?,
+ newConfiguration: String
+ ): String {
val request = StringBuilder()
request.append("<edit-config>").append(NEW_LINE)
request.append(RpcMessageUtils.TARGET_OPEN).append(NEW_LINE)
@@ -127,16 +130,25 @@ class NetconfMessageUtils {
return doWrappedRpc(messageId, request.toString())
}
- fun commit(messageId: String, confirmed: Boolean, confirmTimeout: Int, persist: String,
- persistId: String): String {
+ fun commit(
+ messageId: String,
+ confirmed: Boolean,
+ confirmTimeout: Int,
+ persist: String,
+ persistId: String
+ ): String {
if (!persist.isEmpty() && !persistId.isEmpty()) {
- throw NetconfException("Can't proceed <commit> with both persist($persist) and " +
- "persistId($persistId) specified. Only one should be specified.")
+ throw NetconfException(
+ "Can't proceed <commit> with both persist($persist) and " +
+ "persistId($persistId) specified. Only one should be specified."
+ )
}
if (confirmed && !persistId.isEmpty()) {
- throw NetconfException("Can't proceed <commit> with both confirmed flag and " +
- "persistId($persistId) specified. Only one should be specified.")
+ throw NetconfException(
+ "Can't proceed <commit> with both confirmed flag and " +
+ "persistId($persistId) specified. Only one should be specified."
+ )
}
val request = StringBuilder()
@@ -221,15 +233,15 @@ class NetconfMessageUtils {
fun closeSession(messageId: String, force: Boolean): String {
val request = StringBuilder()
- //TODO: kill-session without session-id is a cisco-only variant.
- //will fail on JUNIPER device.
- //netconf RFC for kill-session requires session-id
- //Cisco can accept <kill-session/> for current session
- //or <kill-session><session-id>####</session-id></kill-session>
- //as long as session ID is not the same as the current session.
-
- //Juniperhttps://www.juniper.net/documentation/en_US/junos/topics/task/operational/netconf-session-terminating.html
- //will accept only with session-id
+ // TODO: kill-session without session-id is a cisco-only variant.
+ // will fail on JUNIPER device.
+ // netconf RFC for kill-session requires session-id
+ // Cisco can accept <kill-session/> for current session
+ // or <kill-session><session-id>####</session-id></kill-session>
+ // as long as session ID is not the same as the current session.
+
+ // Juniperhttps://www.juniper.net/documentation/en_US/junos/topics/task/operational/netconf-session-terminating.html
+ // will accept only with session-id
if (force) {
request.append("<kill-session/>")
} else {
@@ -254,7 +266,6 @@ class NetconfMessageUtils {
} catch (e: Exception) {
return false
}
-
}
fun getMsgId(message: String): String {
@@ -355,8 +366,8 @@ class NetconfMessageUtils {
if (!message.startsWith(RpcMessageUtils.NEW_LINE + RpcMessageUtils.HASH)) {
// chunk encode message
message =
- (RpcMessageUtils.NEW_LINE + RpcMessageUtils.HASH + message.toByteArray(UTF_8).size + RpcMessageUtils.NEW_LINE + message + RpcMessageUtils.NEW_LINE + RpcMessageUtils.HASH + RpcMessageUtils.HASH
- + RpcMessageUtils.NEW_LINE)
+ (RpcMessageUtils.NEW_LINE + RpcMessageUtils.HASH + message.toByteArray(UTF_8).size + RpcMessageUtils.NEW_LINE + message + RpcMessageUtils.NEW_LINE + RpcMessageUtils.HASH + RpcMessageUtils.HASH +
+ RpcMessageUtils.NEW_LINE)
}
return message
}
@@ -373,7 +384,8 @@ class NetconfMessageUtils {
if (request.startsWith(RpcMessageUtils.NEW_LINE + RpcMessageUtils.HASH)) {
request =
request.split("<".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()[0] + RpcMessageUtils.XML_HEADER + request.substring(
- request.split("<".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()[0].length)
+ request.split("<".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()[0].length
+ )
} else {
request = RpcMessageUtils.XML_HEADER + "\n" + request
}
@@ -385,12 +397,18 @@ class NetconfMessageUtils {
var request = request
if (request.contains(RpcMessageUtils.MESSAGE_ID_STRING)) {
request =
- request.replaceFirst((RpcMessageUtils.MESSAGE_ID_STRING + RpcMessageUtils.EQUAL + RpcMessageUtils.NUMBER_BETWEEN_QUOTES_MATCHER).toRegex(),
- RpcMessageUtils.MESSAGE_ID_STRING + RpcMessageUtils.EQUAL + RpcMessageUtils.QUOTE + messageId + RpcMessageUtils.QUOTE)
+ request.replaceFirst(
+ (RpcMessageUtils.MESSAGE_ID_STRING + RpcMessageUtils.EQUAL + RpcMessageUtils.NUMBER_BETWEEN_QUOTES_MATCHER).toRegex(),
+ RpcMessageUtils.MESSAGE_ID_STRING + RpcMessageUtils.EQUAL + RpcMessageUtils.QUOTE + messageId + RpcMessageUtils.QUOTE
+ )
} else if (!request.contains(RpcMessageUtils.MESSAGE_ID_STRING) && !request.contains(
- RpcMessageUtils.HELLO)) {
- request = request.replaceFirst(RpcMessageUtils.END_OF_RPC_OPEN_TAG.toRegex(),
- RpcMessageUtils.QUOTE_SPACE + RpcMessageUtils.MESSAGE_ID_STRING + RpcMessageUtils.EQUAL + RpcMessageUtils.QUOTE + messageId + RpcMessageUtils.QUOTE + ">")
+ RpcMessageUtils.HELLO
+ )
+ ) {
+ request = request.replaceFirst(
+ RpcMessageUtils.END_OF_RPC_OPEN_TAG.toRegex(),
+ RpcMessageUtils.QUOTE_SPACE + RpcMessageUtils.MESSAGE_ID_STRING + RpcMessageUtils.EQUAL + RpcMessageUtils.QUOTE + messageId + RpcMessageUtils.QUOTE + ">"
+ )
}
return updateRequestLength(request)
}
@@ -398,12 +416,16 @@ class NetconfMessageUtils {
fun updateRequestLength(request: String): String {
if (request.contains(NEW_LINE + RpcMessageUtils.HASH + RpcMessageUtils.HASH + NEW_LINE)) {
val oldLen =
- Integer.parseInt(request.split(RpcMessageUtils.HASH.toRegex()).dropLastWhile({ it.isEmpty() }).toTypedArray()[1].split(
- NEW_LINE.toRegex()).dropLastWhile({ it.isEmpty() }).toTypedArray()[0])
+ Integer.parseInt(
+ request.split(RpcMessageUtils.HASH.toRegex()).dropLastWhile({ it.isEmpty() }).toTypedArray()[1].split(
+ NEW_LINE.toRegex()
+ ).dropLastWhile({ it.isEmpty() }).toTypedArray()[0]
+ )
val rpcWithEnding = request.substring(request.indexOf('<'))
val firstBlock =
request.split(RpcMessageUtils.MSGLEN_REGEX_PATTERN.toRegex()).dropLastWhile({ it.isEmpty() }).toTypedArray()[1].split(
- (NEW_LINE + RpcMessageUtils.HASH + RpcMessageUtils.HASH + NEW_LINE).toRegex()).dropLastWhile(
+ (NEW_LINE + RpcMessageUtils.HASH + RpcMessageUtils.HASH + NEW_LINE).toRegex()
+ ).dropLastWhile(
{ it.isEmpty() }).toTypedArray()[0]
var newLen = 0
newLen = firstBlock.toByteArray(UTF_8).size
@@ -420,5 +442,4 @@ class NetconfMessageUtils {
} else false
}
}
-
}
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutorTest.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutorTest.kt
index be3ee4614..f3df55b4b 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutorTest.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutorTest.kt
@@ -54,16 +54,22 @@ class ComponentNetconfExecutorTest {
coEvery { blueprintJythonService.jythonComponentInstance(any(), any()) } returns mockAbstractScriptComponentFunction
- val componentFunctionScriptingService = ComponentFunctionScriptingService(applicationContext,
- blueprintJythonService)
+ val componentFunctionScriptingService = ComponentFunctionScriptingService(
+ applicationContext,
+ blueprintJythonService
+ )
val componentNetconfExecutor = ComponentNetconfExecutor(componentFunctionScriptingService)
- val executionServiceInput = JacksonUtils.readValueFromClassPathFile("requests/sample-activate-request.json",
- ExecutionServiceInput::class.java)!!
+ val executionServiceInput = JacksonUtils.readValueFromClassPathFile(
+ "requests/sample-activate-request.json",
+ ExecutionServiceInput::class.java
+ )!!
- val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
- "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(
+ "1234",
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
val assignmentParams = """{
"ipAddress" : "127.0.0.1",
@@ -77,12 +83,14 @@ class ComponentNetconfExecutorTest {
""".trimIndent()
bluePrintRuntimeService.assignInputs(json.asJsonType())
- bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment", "assignment-params",
- JacksonUtils.jsonNode(assignmentParams))
+ bluePrintRuntimeService.setNodeTemplateAttributeValue(
+ "resource-assignment", "assignment-params",
+ JacksonUtils.jsonNode(assignmentParams)
+ )
componentNetconfExecutor.bluePrintRuntimeService = bluePrintRuntimeService
- //TODO("Set Attribute properties")
+ // TODO("Set Attribute properties")
val stepMetaData: MutableMap<String, JsonNode> = hashMapOf()
stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, "activate-netconf")
stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, "ComponentNetconfExecutor")
@@ -98,4 +106,3 @@ class ComponentNetconfExecutorTest {
}
}
}
-
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/DeviceInfoTest.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/DeviceInfoTest.kt
index 4e1ff655d..ab051597b 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/DeviceInfoTest.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/DeviceInfoTest.kt
@@ -16,7 +16,6 @@
package org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.api
-
import org.junit.Test
import kotlin.test.assertEquals
@@ -24,13 +23,13 @@ class DeviceInfoTest {
@Test
fun testToString() {
- val di: DeviceInfo = DeviceInfo().apply {
- username = "username"
- password = "password"
- ipAddress = "localhost"
- port = 2224
- connectTimeout = 10
- }
+ val di: DeviceInfo = DeviceInfo().apply {
+ username = "username"
+ password = "password"
+ ipAddress = "localhost"
+ port = 2224
+ connectTimeout = 10
+ }
assertEquals("localhost:2224", di.toString())
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/NetconfMessageTest.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/NetconfMessageTest.kt
index 70bf0158d..e5bacc547 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/NetconfMessageTest.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/NetconfMessageTest.kt
@@ -37,13 +37,13 @@ class NetconfMessageTest {
val dr: DeviceResponse = genUnsuccessfulEmptyDeviceResponse()
assertFalse(dr.isSuccess())
- //case 2: Success, but with error message
+ // case 2: Success, but with error message
val dr2: DeviceResponse = genUnsuccessfulEmptyDeviceResponse()
dr2.errorMessage = "Some error message."
assertFalse(dr2.isSuccess())
}
- //helper function to generate a device response
+ // helper function to generate a device response
private fun genSuccessfulEmptyDeviceResponse(): DeviceResponse {
return DeviceResponse().apply {
status = RpcStatus.SUCCESS
@@ -61,5 +61,4 @@ class NetconfMessageTest {
requestMessage = ""
}
}
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfDeviceCommunicatorTest.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfDeviceCommunicatorTest.kt
index 2240f48c2..1991fc4f6 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfDeviceCommunicatorTest.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfDeviceCommunicatorTest.kt
@@ -16,7 +16,13 @@
package org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.core
-import io.mockk.*
+import io.mockk.CapturingSlot
+import io.mockk.Runs
+import io.mockk.every
+import io.mockk.just
+import io.mockk.mockk
+import io.mockk.spyk
+import io.mockk.verify
import org.junit.Before
import org.junit.Test
import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.api.DeviceInfo
@@ -27,9 +33,10 @@ import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.utils.R
import java.io.IOException
import java.io.InputStream
import java.io.OutputStream
-import java.nio.charset.*
-import java.util.concurrent.*
-import java.util.regex.*
+import java.nio.charset.StandardCharsets
+import java.util.concurrent.CompletableFuture
+import java.util.concurrent.ConcurrentHashMap
+import java.util.regex.Pattern
import kotlin.test.assertEquals
import kotlin.test.assertFalse
import kotlin.test.assertTrue
@@ -43,10 +50,9 @@ class NetconfDeviceCommunicatorTest {
private lateinit var replies: MutableMap<String, CompletableFuture<String>>
private val endPatternCharArray: List<Int> = stringToCharArray(RpcMessageUtils.END_PATTERN)
-
companion object {
private val chunkedEnding = "\n##\n"
- //using example from section 4.2 of RFC6242 (https://tools.ietf.org/html/rfc6242#section-4.2)
+ // using example from section 4.2 of RFC6242 (https://tools.ietf.org/html/rfc6242#section-4.2)
private val validChunkedEncodedMsg = """
|
|#4
@@ -82,25 +88,27 @@ class NetconfDeviceCommunicatorTest {
val communicator: NetconfDeviceCommunicator =
NetconfDeviceCommunicator(mockInputStream, mockOutputStream, genDeviceInfo(), netconfSessionListener, replies)
communicator.join()
- //verify
+ // verify
verify { mockInputStream.read(any(), any(), any()) }
}
@Test
fun `NetconfDeviceCommunicator unregisters device on END_PATTERN`() {
- //The reader will generate RpcMessageUtils.END_PATTERN "]]>]]>" which tells Netconf
- //to unregister the device.
- //we want to capture the slot to return the value as inputStreamReader will pass a char array
- //create a slot where NetconfReceivedEvent will be placed to further verify Type.DEVICE_UNREGISTERED
+ // The reader will generate RpcMessageUtils.END_PATTERN "]]>]]>" which tells Netconf
+ // to unregister the device.
+ // we want to capture the slot to return the value as inputStreamReader will pass a char array
+ // create a slot where NetconfReceivedEvent will be placed to further verify Type.DEVICE_UNREGISTERED
val eventSlot = CapturingSlot<NetconfReceivedEvent>()
every { netconfSessionListener.accept(event = capture(eventSlot)) } just Runs
stubInputStream = RpcMessageUtils.END_PATTERN.byteInputStream(StandardCharsets.UTF_8)
val inputStreamSpy = spyk(stubInputStream)
- //RUN the test
- val communicator = NetconfDeviceCommunicator(inputStreamSpy, mockOutputStream,
- genDeviceInfo(), netconfSessionListener, replies)
+ // RUN the test
+ val communicator = NetconfDeviceCommunicator(
+ inputStreamSpy, mockOutputStream,
+ genDeviceInfo(), netconfSessionListener, replies
+ )
communicator.join()
- //Verify
+ // Verify
verify { inputStreamSpy.close() }
assertTrue { eventSlot.isCaptured }
assertEquals(NetconfReceivedEvent.Type.DEVICE_UNREGISTERED, eventSlot.captured.type)
@@ -114,11 +122,13 @@ class NetconfDeviceCommunicatorTest {
stubInputStream = "".byteInputStream(StandardCharsets.UTF_8)
val inputStreamSpy = spyk(stubInputStream)
every { inputStreamSpy.read(any(), any(), any()) } returns 1 andThenThrows IOException("Fake IO Exception")
- //RUN THE TEST
- val communicator = NetconfDeviceCommunicator(inputStreamSpy, mockOutputStream,
- genDeviceInfo(), netconfSessionListener, replies)
+ // RUN THE TEST
+ val communicator = NetconfDeviceCommunicator(
+ inputStreamSpy, mockOutputStream,
+ genDeviceInfo(), netconfSessionListener, replies
+ )
communicator.join()
- //Verify
+ // Verify
assertTrue { eventSlot.isCaptured }
assertEquals(genDeviceInfo(), eventSlot.captured.deviceInfo)
assertEquals(NetconfReceivedEvent.Type.DEVICE_ERROR, eventSlot.captured.type)
@@ -130,14 +140,16 @@ class NetconfDeviceCommunicatorTest {
val payload = "<rpc-reply>blah</rpc-reply>"
stubInputStream = "$payload${RpcMessageUtils.END_PATTERN}".byteInputStream(StandardCharsets.UTF_8)
every { netconfSessionListener.accept(event = capture(eventSlot)) } just Runs
- //RUN the test
- val communicator = NetconfDeviceCommunicator(stubInputStream, mockOutputStream,
- genDeviceInfo(), netconfSessionListener, replies)
+ // RUN the test
+ val communicator = NetconfDeviceCommunicator(
+ stubInputStream, mockOutputStream,
+ genDeviceInfo(), netconfSessionListener, replies
+ )
communicator.join()
- //Verify
- verify(exactly = 0) { mockInputStream.close() } //make sure the reader is not closed as this could cause problems
+ // Verify
+ verify(exactly = 0) { mockInputStream.close() } // make sure the reader is not closed as this could cause problems
assertTrue { eventSlot.isCaptured }
- //eventually, sessionListener is called with message type DEVICE_REPLY
+ // eventually, sessionListener is called with message type DEVICE_REPLY
assertEquals(NetconfReceivedEvent.Type.DEVICE_REPLY, eventSlot.captured.type)
assertEquals(payload, eventSlot.captured.messagePayload)
}
@@ -150,16 +162,18 @@ class NetconfDeviceCommunicatorTest {
every { netconfSessionListener.accept(event = capture(eventSlot)) } just Runs
stubInputStream = payloadWithChunkedEnding.byteInputStream(StandardCharsets.UTF_8)
- //we have to ensure that the input stream is processed, so need to create a spy object.
+ // we have to ensure that the input stream is processed, so need to create a spy object.
val inputStreamSpy = spyk(stubInputStream)
- //RUN the test
- val communicator = NetconfDeviceCommunicator(inputStreamSpy, mockOutputStream, genDeviceInfo(),
- netconfSessionListener, replies)
+ // RUN the test
+ val communicator = NetconfDeviceCommunicator(
+ inputStreamSpy, mockOutputStream, genDeviceInfo(),
+ netconfSessionListener, replies
+ )
communicator.join()
- //Verify
- verify(exactly = 0) { inputStreamSpy.close() } //make sure the reader is not closed as this could cause problems
+ // Verify
+ verify(exactly = 0) { inputStreamSpy.close() } // make sure the reader is not closed as this could cause problems
assertTrue { eventSlot.isCaptured }
- //eventually, sessionListener is called with message type DEVICE_REPLY
+ // eventually, sessionListener is called with message type DEVICE_REPLY
assertEquals(NetconfReceivedEvent.Type.DEVICE_ERROR, eventSlot.captured.type)
assertEquals("", eventSlot.captured.messagePayload)
}
@@ -170,23 +184,25 @@ class NetconfDeviceCommunicatorTest {
stubInputStream = validChunkedEncodedMsg.byteInputStream(StandardCharsets.UTF_8)
val inputStreamSpy = spyk(stubInputStream)
every { netconfSessionListener.accept(event = capture(eventSlot)) } just Runs
- //RUN the test
+ // RUN the test
NetconfDeviceCommunicator(inputStreamSpy, mockOutputStream, genDeviceInfo(), netconfSessionListener, replies).join()
- //Verify
- verify(exactly = 0) { inputStreamSpy.close() } //make sure the reader is not closed as this could cause problems
+ // Verify
+ verify(exactly = 0) { inputStreamSpy.close() } // make sure the reader is not closed as this could cause problems
assertTrue { eventSlot.isCaptured }
- //eventually, sessionListener is called with message type DEVICE_REPLY
+ // eventually, sessionListener is called with message type DEVICE_REPLY
assertEquals(NetconfReceivedEvent.Type.DEVICE_REPLY, eventSlot.captured.type)
- assertEquals("""
+ assertEquals(
+ """
<rpc message-id="102"
xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<close-session/>
</rpc>
- """.trimIndent(), eventSlot.captured.messagePayload)
+ """.trimIndent(), eventSlot.captured.messagePayload
+ )
}
@Test
- //test to ensure that we have a valid test message to be then used in the case of chunked message
+ // test to ensure that we have a valid test message to be then used in the case of chunked message
// validation code path
fun `chunked sample is validated by the chunked response regex`() {
val test1 = "\n#10\nblah\n##\n"
@@ -196,7 +212,7 @@ class NetconfDeviceCommunicatorTest {
}
@Test
- //Verify that our test sample passes the second pattern for chunked size
+ // Verify that our test sample passes the second pattern for chunked size
fun `chunkSizeMatcher pattern finds matches in chunkedMessageSample`() {
val sizePattern = Pattern.compile("\\n#([1-9][0-9]*)\\n")
val matcher = sizePattern.matcher(validChunkedEncodedMsg)
@@ -207,17 +223,18 @@ class NetconfDeviceCommunicatorTest {
fun `sendMessage writes the request to NetconfDeviceCommunicator Writer`() {
val msgPayload = "some text"
val msgId = "100"
- stubInputStream = "".byteInputStream(StandardCharsets.UTF_8) //no data available in the stream...
+ stubInputStream = "".byteInputStream(StandardCharsets.UTF_8) // no data available in the stream...
every { mockOutputStream.write(any(), any(), any()) } just Runs
every { mockOutputStream.write(msgPayload.toByteArray(Charsets.UTF_8)) } just Runs
every { mockOutputStream.flush() } just Runs
- //Run the command
+ // Run the command
val communicator = NetconfDeviceCommunicator(
stubInputStream, mockOutputStream,
- genDeviceInfo(), netconfSessionListener, replies)
+ genDeviceInfo(), netconfSessionListener, replies
+ )
val completableFuture = communicator.sendMessage(msgPayload, msgId)
communicator.join()
- //verify
+ // verify
verify { mockOutputStream.write(any(), any(), any()) }
verify { mockOutputStream.flush() }
assertFalse { completableFuture.isCompletedExceptionally }
@@ -227,14 +244,15 @@ class NetconfDeviceCommunicatorTest {
fun `sendMessage on IOError returns completed exceptionally future`() {
val msgPayload = "some text"
val msgId = "100"
- every { mockOutputStream.write(any(), any(), any()) } throws IOException("Some IO error occurred!")
- stubInputStream = "".byteInputStream(StandardCharsets.UTF_8) //no data available in the stream...
- //Run the command
+ every { mockOutputStream.write(any(), any(), any()) } throws IOException("Some IO error occurred!")
+ stubInputStream = "".byteInputStream(StandardCharsets.UTF_8) // no data available in the stream...
+ // Run the command
val communicator = NetconfDeviceCommunicator(
stubInputStream, mockOutputStream,
- genDeviceInfo(), netconfSessionListener, replies)
+ genDeviceInfo(), netconfSessionListener, replies
+ )
val completableFuture = communicator.sendMessage(msgPayload, msgId)
- //verify
+ // verify
verify { mockOutputStream.write(any(), any(), any()) }
verify(exactly = 0) { mockOutputStream.flush() }
assertTrue { completableFuture.isCompletedExceptionally }
@@ -248,5 +266,4 @@ class NetconfDeviceCommunicatorTest {
port = 4567
}
}
-
}
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfMessageStateTest.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfMessageStateTest.kt
index ce7594c4a..e68e5d865 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfMessageStateTest.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfMessageStateTest.kt
@@ -27,121 +27,166 @@ class NetconfMessageStateTest {
@Test
fun `NO_MATCHING_PATTERN transitions`() {
- assertEquals(NetconfMessageState.FIRST_BRACKET,
- NetconfMessageState.NO_MATCHING_PATTERN.evaluateChar(']'))
- assertEquals(NetconfMessageState.FIRST_LF,
- NetconfMessageState.NO_MATCHING_PATTERN.evaluateChar('\n'))
-
- charList.minus(listOf(']','\n')).forEach {
- assertEquals(NetconfMessageState.NO_MATCHING_PATTERN,
- NetconfMessageState.NO_MATCHING_PATTERN.evaluateChar(it))
+ assertEquals(
+ NetconfMessageState.FIRST_BRACKET,
+ NetconfMessageState.NO_MATCHING_PATTERN.evaluateChar(']')
+ )
+ assertEquals(
+ NetconfMessageState.FIRST_LF,
+ NetconfMessageState.NO_MATCHING_PATTERN.evaluateChar('\n')
+ )
+
+ charList.minus(listOf(']', '\n')).forEach {
+ assertEquals(
+ NetconfMessageState.NO_MATCHING_PATTERN,
+ NetconfMessageState.NO_MATCHING_PATTERN.evaluateChar(it)
+ )
}
}
@Test
fun `FIRST_BRACKET transitions`() {
- assertEquals(NetconfMessageState.SECOND_BRACKET,
- NetconfMessageState.FIRST_BRACKET.evaluateChar(']'))
+ assertEquals(
+ NetconfMessageState.SECOND_BRACKET,
+ NetconfMessageState.FIRST_BRACKET.evaluateChar(']')
+ )
- charList.minus( ']').forEach {
- assertEquals(NetconfMessageState.NO_MATCHING_PATTERN,
- NetconfMessageState.FIRST_BRACKET.evaluateChar(it))
+ charList.minus(']').forEach {
+ assertEquals(
+ NetconfMessageState.NO_MATCHING_PATTERN,
+ NetconfMessageState.FIRST_BRACKET.evaluateChar(it)
+ )
}
}
@Test
fun `SECOND_BRACKET transitions`() {
- assertEquals(NetconfMessageState.FIRST_BIGGER,
- NetconfMessageState.SECOND_BRACKET.evaluateChar('>'))
+ assertEquals(
+ NetconfMessageState.FIRST_BIGGER,
+ NetconfMessageState.SECOND_BRACKET.evaluateChar('>')
+ )
charList.minus('>').forEach {
- assertEquals(NetconfMessageState.NO_MATCHING_PATTERN,
- NetconfMessageState.SECOND_BRACKET.evaluateChar(it))
+ assertEquals(
+ NetconfMessageState.NO_MATCHING_PATTERN,
+ NetconfMessageState.SECOND_BRACKET.evaluateChar(it)
+ )
}
}
@Test
fun `FIRST_BIGGER transitions`() {
- assertEquals(NetconfMessageState.THIRD_BRACKET,
- NetconfMessageState.FIRST_BIGGER.evaluateChar(']'))
+ assertEquals(
+ NetconfMessageState.THIRD_BRACKET,
+ NetconfMessageState.FIRST_BIGGER.evaluateChar(']')
+ )
charList.minus(']').forEach {
- assertEquals(NetconfMessageState.NO_MATCHING_PATTERN,
- NetconfMessageState.FIRST_BIGGER.evaluateChar(it))
+ assertEquals(
+ NetconfMessageState.NO_MATCHING_PATTERN,
+ NetconfMessageState.FIRST_BIGGER.evaluateChar(it)
+ )
}
}
@Test
fun `THIRD_BRACKET transitions`() {
- assertEquals(NetconfMessageState.ENDING_BIGGER,
- NetconfMessageState.THIRD_BRACKET.evaluateChar(']'))
+ assertEquals(
+ NetconfMessageState.ENDING_BIGGER,
+ NetconfMessageState.THIRD_BRACKET.evaluateChar(']')
+ )
charList.minus(']').forEach {
- assertEquals(NetconfMessageState.NO_MATCHING_PATTERN,
- NetconfMessageState.THIRD_BRACKET.evaluateChar(it))
+ assertEquals(
+ NetconfMessageState.NO_MATCHING_PATTERN,
+ NetconfMessageState.THIRD_BRACKET.evaluateChar(it)
+ )
}
}
@Test
fun `ENDING_BIGGER transitions`() {
- assertEquals(NetconfMessageState.END_PATTERN,
- NetconfMessageState.ENDING_BIGGER.evaluateChar('>'))
+ assertEquals(
+ NetconfMessageState.END_PATTERN,
+ NetconfMessageState.ENDING_BIGGER.evaluateChar('>')
+ )
charList.minus('>').forEach {
- assertEquals(NetconfMessageState.NO_MATCHING_PATTERN,
- NetconfMessageState.ENDING_BIGGER.evaluateChar(it))
+ assertEquals(
+ NetconfMessageState.NO_MATCHING_PATTERN,
+ NetconfMessageState.ENDING_BIGGER.evaluateChar(it)
+ )
}
}
@Test
fun `FIRST_LF transitions`() {
- assertEquals(NetconfMessageState.FIRST_HASH,
- NetconfMessageState.FIRST_LF.evaluateChar('#'))
- assertEquals(NetconfMessageState.FIRST_BRACKET,
- NetconfMessageState.FIRST_LF.evaluateChar(']'))
- assertEquals(NetconfMessageState.FIRST_LF,
- NetconfMessageState.FIRST_LF.evaluateChar('\n'))
+ assertEquals(
+ NetconfMessageState.FIRST_HASH,
+ NetconfMessageState.FIRST_LF.evaluateChar('#')
+ )
+ assertEquals(
+ NetconfMessageState.FIRST_BRACKET,
+ NetconfMessageState.FIRST_LF.evaluateChar(']')
+ )
+ assertEquals(
+ NetconfMessageState.FIRST_LF,
+ NetconfMessageState.FIRST_LF.evaluateChar('\n')
+ )
charList.minus(listOf('#', ']', '\n')).forEach {
- assertEquals(NetconfMessageState.NO_MATCHING_PATTERN,
- NetconfMessageState.FIRST_LF.evaluateChar(it))
+ assertEquals(
+ NetconfMessageState.NO_MATCHING_PATTERN,
+ NetconfMessageState.FIRST_LF.evaluateChar(it)
+ )
}
}
@Test
fun `FIRST_HASH transitions`() {
- assertEquals(NetconfMessageState.SECOND_HASH,
- NetconfMessageState.FIRST_HASH.evaluateChar('#'))
+ assertEquals(
+ NetconfMessageState.SECOND_HASH,
+ NetconfMessageState.FIRST_HASH.evaluateChar('#')
+ )
charList.minus('#').forEach {
- assertEquals(NetconfMessageState.NO_MATCHING_PATTERN,
- NetconfMessageState.FIRST_HASH.evaluateChar(it))
+ assertEquals(
+ NetconfMessageState.NO_MATCHING_PATTERN,
+ NetconfMessageState.FIRST_HASH.evaluateChar(it)
+ )
}
}
@Test
fun `SECOND_HASH transitions`() {
- assertEquals(NetconfMessageState.END_CHUNKED_PATTERN,
- NetconfMessageState.SECOND_HASH.evaluateChar('\n'))
-
- charList.minus( '\n').forEach {
- assertEquals(NetconfMessageState.NO_MATCHING_PATTERN,
- NetconfMessageState.SECOND_HASH.evaluateChar(it))
+ assertEquals(
+ NetconfMessageState.END_CHUNKED_PATTERN,
+ NetconfMessageState.SECOND_HASH.evaluateChar('\n')
+ )
+
+ charList.minus('\n').forEach {
+ assertEquals(
+ NetconfMessageState.NO_MATCHING_PATTERN,
+ NetconfMessageState.SECOND_HASH.evaluateChar(it)
+ )
}
}
@Test
fun `END_CHUNKED_PATTERN transitions`() {
charList.forEach {
- assertEquals(NetconfMessageState.NO_MATCHING_PATTERN,
- NetconfMessageState.END_CHUNKED_PATTERN.evaluateChar(it))
+ assertEquals(
+ NetconfMessageState.NO_MATCHING_PATTERN,
+ NetconfMessageState.END_CHUNKED_PATTERN.evaluateChar(it)
+ )
}
}
@Test
fun `END_PATTERN transitions`() {
charList.forEach {
- assertEquals(NetconfMessageState.NO_MATCHING_PATTERN,
- NetconfMessageState.END_PATTERN.evaluateChar(it))
+ assertEquals(
+ NetconfMessageState.NO_MATCHING_PATTERN,
+ NetconfMessageState.END_PATTERN.evaluateChar(it)
+ )
}
}
-
}
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImplTest.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImplTest.kt
index 7b0b799bc..9a3652aa1 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImplTest.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImplTest.kt
@@ -21,7 +21,6 @@ import io.mockk.every
import io.mockk.mockk
import io.mockk.spyk
import org.junit.Before
-
import org.junit.Test
import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.api.DeviceInfo
import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.api.DeviceResponse
@@ -39,11 +38,15 @@ class NetconfRpcServiceImplTest {
companion object {
private const val someString = "someString"
private const val replyStr = "this is a reply"
- private val failedDeviceResponse = DeviceResponse(status = RpcStatus.FAILURE,
- requestMessage = "request message", responseMessage = replyStr) //responseMessage will be null in this POJO
- private val successfulDeviceResponse = DeviceResponse(status = RpcStatus.SUCCESS,
- requestMessage = "request message", responseMessage = replyStr) //responseMessage will be null in this POJO
- //but will be set later from mockSession
+ private val failedDeviceResponse = DeviceResponse(
+ status = RpcStatus.FAILURE,
+ requestMessage = "request message", responseMessage = replyStr
+ ) // responseMessage will be null in this POJO
+ private val successfulDeviceResponse = DeviceResponse(
+ status = RpcStatus.SUCCESS,
+ requestMessage = "request message", responseMessage = replyStr
+ ) // responseMessage will be null in this POJO
+ // but will be set later from mockSession
private const val msgId = "100"
private const val timeout = 5
private val deviceInfo: DeviceInfo = DeviceInfo().apply {
@@ -375,4 +378,4 @@ class NetconfRpcServiceImplTest {
assertTrue { rpcResult.errorMessage!!.contains("failed in 'closeSession' command") }
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionImplTest.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionImplTest.kt
index e3cda5a49..b94c092e3 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionImplTest.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionImplTest.kt
@@ -16,7 +16,13 @@
package org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.core
-import io.mockk.*
+import io.mockk.CapturingSlot
+import io.mockk.Runs
+import io.mockk.every
+import io.mockk.just
+import io.mockk.mockk
+import io.mockk.spyk
+import io.mockk.verify
import org.apache.sshd.client.SshClient
import org.apache.sshd.client.channel.ChannelSubsystem
import org.apache.sshd.client.channel.ClientChannel
@@ -37,8 +43,10 @@ import java.io.ByteArrayInputStream
import java.io.ByteArrayOutputStream
import java.io.IOException
import java.io.InputStream
-import java.nio.charset.*
-import java.util.concurrent.*
+import java.nio.charset.StandardCharsets
+import java.util.concurrent.CompletableFuture
+import java.util.concurrent.ExecutionException
+import java.util.concurrent.TimeoutException
import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
import kotlin.test.assertTrue
@@ -106,7 +114,7 @@ class NetconfSessionImplTest {
verify { session["startClient"]() }
}
- //look for NetconfException being thrown when cannot connect
+ // look for NetconfException being thrown when cannot connect
@Test
fun `connect throws NetconfException on error`() {
val errMsg = "$deviceInfo: Failed to establish SSH session"
@@ -119,7 +127,7 @@ class NetconfSessionImplTest {
@Test
fun `disconnect without force option for rpcService succeeds`() {
- //rpcService.closeSession succeeds with status not RpcStatus.FAILURE
+ // rpcService.closeSession succeeds with status not RpcStatus.FAILURE
every { rpcService.closeSession(false) } returns SUCCESSFUL_DEVICE_RESPONSE
every { mockClientSession.close() } just Runs
every { mockSshClient.close() } just Runs
@@ -128,9 +136,9 @@ class NetconfSessionImplTest {
netconfSessionSpy.setSession(mockClientSession)
netconfSessionSpy.setClient(mockSshClient)
netconfSessionSpy.setChannel(mockClientChannel)
- //RUN
+ // RUN
netconfSessionSpy.disconnect()
- //make sure that rpcService.close session is not called again.
+ // make sure that rpcService.close session is not called again.
verify(exactly = 0) { rpcService.closeSession(true) }
verify { mockClientSession.close() }
verify { mockSshClient.close() }
@@ -139,24 +147,23 @@ class NetconfSessionImplTest {
@Test
fun `disconnect with force option for rpcService succeeds`() {
- //rpcService.closeSession succeeds with status not RpcStatus.FAILURE
+ // rpcService.closeSession succeeds with status not RpcStatus.FAILURE
val netconfSessionSpy = spyk(netconfSession, recordPrivateCalls = true)
every { rpcService.closeSession(any()) } returns
- FAILED_DEVICE_RESPONSE andThen SUCCESSFUL_DEVICE_RESPONSE
+ FAILED_DEVICE_RESPONSE andThen SUCCESSFUL_DEVICE_RESPONSE
every { mockClientSession.close() } just Runs
every { mockSshClient.close() } just Runs
every { mockClientChannel.close() } just Runs
netconfSessionSpy.setSession(mockClientSession)
netconfSessionSpy.setClient(mockSshClient)
netconfSessionSpy.setChannel(mockClientChannel)
- //RUN
+ // RUN
netconfSessionSpy.disconnect()
- //VERIFY
+ // VERIFY
verify(exactly = 2) { rpcService.closeSession(any()) }
verify { mockClientSession.close() }
verify { mockSshClient.close() }
verify { mockClientChannel.close() }
-
}
@Test
@@ -185,9 +192,9 @@ class NetconfSessionImplTest {
every { mockSshClient.isClosed } returns true
netconfSessionSpy.setClient(mockSshClient)
every { netconfSessionSpy["startConnection"]() as Unit } just Runs
- //Call method
+ // Call method
netconfSessionSpy.checkAndReestablish()
- //Verify
+ // Verify
verify { netconfSessionSpy.clearReplies() }
verify { netconfSessionSpy["startConnection"]() }
}
@@ -200,9 +207,9 @@ class NetconfSessionImplTest {
every { netconfSessionSpy["startSession"]() as Unit } just Runs
netconfSessionSpy.setClient(mockSshClient)
netconfSessionSpy.setSession(mockClientSession)
- //Call method
+ // Call method
netconfSessionSpy.checkAndReestablish()
- //Verify
+ // Verify
verify { netconfSessionSpy.clearReplies() }
verify { netconfSessionSpy["startSession"]() }
}
@@ -217,59 +224,57 @@ class NetconfSessionImplTest {
netconfSessionSpy.setClient(mockSshClient)
netconfSessionSpy.setSession(mockClientSession)
netconfSessionSpy.setChannel(mockClientChannel)
- //Call method
+ // Call method
netconfSessionSpy.checkAndReestablish()
- //Verify
+ // Verify
verify { netconfSessionSpy.clearReplies() }
verify { netconfSessionSpy["openChannel"]() }
}
-
@Test
fun `syncRpc runs normally`() {
val netconfSessionSpy = spyk(netconfSession)
val futureRet: CompletableFuture<String> = CompletableFuture.completedFuture(futureMsg)
- //test the case where SSH connection did not need to be re-established.
- //put an existing item into the replies
+ // test the case where SSH connection did not need to be re-established.
+ // put an existing item into the replies
netconfSessionSpy.getReplies()["somekey"] = CompletableFuture.completedFuture("${futureMsg}2")
every { netconfCommunicator.sendMessage(any(), any()) } returns futureRet
every { netconfCommunicator.getFutureFromSendMessage(any(), any(), any()) } returns futureRet.get()
every { netconfSessionSpy.checkAndReestablish() } just Runs
- //call the method
+ // call the method
assertEquals(futureMsg, netconfSessionSpy.syncRpc("0", "0"))
- //make sure the replies didn't change
+ // make sure the replies didn't change
assertTrue {
netconfSessionSpy.getReplies().size == 1 &&
- netconfSessionSpy.getReplies().containsKey("somekey")
+ netconfSessionSpy.getReplies().containsKey("somekey")
}
verify(exactly = 0) { netconfSessionSpy.clearReplies() }
}
-
@Test
fun `syncRpc still succeeds and replies are cleared on client disconnect`() {
val netconfSessionSpy = spyk(netconfSession, recordPrivateCalls = true)
val futureRet: CompletableFuture<String> = CompletableFuture.completedFuture(futureMsg)
- //put an item into the replies
+ // put an item into the replies
netconfSessionSpy.getReplies()["somekey"] = CompletableFuture.completedFuture("${futureMsg}2")
- //tests the case where SSH session needs to be re-established.
+ // tests the case where SSH session needs to be re-established.
every { netconfCommunicator.sendMessage(any(), any()) } returns futureRet
every { netconfSessionSpy["startClient"]() as Unit } just Runs
every { netconfCommunicator.getFutureFromSendMessage(any(), any(), any()) } returns futureRet.get()
every { mockSshClient.isClosed } returns true
netconfSessionSpy.setClient(mockSshClient)
- //call the method
+ // call the method
assertEquals(futureMsg, netconfSessionSpy.syncRpc("0", "0"))
- //make sure the replies got cleared out
+ // make sure the replies got cleared out
assertTrue { netconfSessionSpy.getReplies().isEmpty() }
verify(exactly = 1) { netconfSessionSpy.clearReplies() }
}
- //Test for handling CompletableFuture.get returns InterruptedException inside NetconfDeviceCommunicator
+ // Test for handling CompletableFuture.get returns InterruptedException inside NetconfDeviceCommunicator
@Test
fun `syncRpc throws NetconfException if InterruptedException is caught`() {
val expectedExceptionMsg = "$deviceInfo: Interrupted while waiting for reply for request: $formattedRequest"
@@ -279,21 +284,22 @@ class NetconfSessionImplTest {
every { netconfCommunicator.sendMessage(any(), any()) } returns futureRet
every { netconfCommunicator.getFutureFromSendMessage(any(), any(), any()) } throws InterruptedException("interrupted")
every { netconfSessionSpy.checkAndReestablish() } just Runs
- //call the method
+ // call the method
netconfSessionSpy.syncRpc("0", "0")
}
}
@Test
fun `syncRpc throws NetconfException if TimeoutException is caught`() {
- val expectedExceptionMsg = "$deviceInfo: Timed out while waiting for reply for request $formattedRequest after ${deviceInfo.replyTimeout} sec."
+ val expectedExceptionMsg =
+ "$deviceInfo: Timed out while waiting for reply for request $formattedRequest after ${deviceInfo.replyTimeout} sec."
assertFailsWith(exceptionClass = NetconfException::class, message = expectedExceptionMsg) {
val netconfSessionSpy = spyk(netconfSession)
val futureRet: CompletableFuture<String> = CompletableFuture.completedFuture(futureMsg)
every { netconfCommunicator.sendMessage(any(), any()) } returns futureRet
every { netconfCommunicator.getFutureFromSendMessage(any(), any(), any()) } throws TimeoutException("timed out")
every { netconfSessionSpy.checkAndReestablish() } just Runs
- //call the method
+ // call the method
netconfSessionSpy.syncRpc("0", "0")
}
}
@@ -306,11 +312,11 @@ class NetconfSessionImplTest {
val futureRet: CompletableFuture<String> = CompletableFuture.completedFuture(futureMsg)
every { netconfCommunicator.sendMessage(any(), any()) } returns futureRet
every { netconfCommunicator.getFutureFromSendMessage(any(), any(), any()) } throws
- ExecutionException("exec exception", Exception("nested exception"))
+ ExecutionException("exec exception", Exception("nested exception"))
every { netconfSessionSpy["close"]() as Unit } just Runs
every { netconfSessionSpy.checkAndReestablish() } just Runs
netconfSessionSpy.setSession(mockClientSession)
- //call the method
+ // call the method
netconfSessionSpy.syncRpc("0", "0")
}
}
@@ -323,12 +329,12 @@ class NetconfSessionImplTest {
val futureRet: CompletableFuture<String> = CompletableFuture.completedFuture(futureMsg)
every { netconfCommunicator.sendMessage(any(), any()) } returns futureRet
every { netconfCommunicator.getFutureFromSendMessage(any(), any(), any()) } throws
- ExecutionException("exec exception", Exception("nested exception"))
+ ExecutionException("exec exception", Exception("nested exception"))
every { netconfSessionSpy["close"]() as Unit } throws IOException("got an IO exception")
every { netconfSessionSpy.checkAndReestablish() } just Runs
- //call the method
+ // call the method
netconfSessionSpy.syncRpc("0", "0")
- //make sure replies are cleared...
+ // make sure replies are cleared...
verify(exactly = 1) { netconfSessionSpy.clearReplies() }
verify(exactly = 1) { netconfSessionSpy.clearErrorReplies() }
}
@@ -340,12 +346,12 @@ class NetconfSessionImplTest {
every { netconfSessionSpy.checkAndReestablish() } just Runs
val futureRet: CompletableFuture<String> = CompletableFuture.completedFuture(futureMsg)
every { netconfCommunicator.sendMessage(any(), any()) } returns futureRet
- //run the method
+ // run the method
val rpcResultFuture = netconfSessionSpy.asyncRpc("0", "0")
every { netconfSessionSpy.checkAndReestablish() } just Runs
- //make sure the future gets resolved
+ // make sure the future gets resolved
assertTrue { rpcResultFuture.get() == futureMsg }
- //make sure that clearReplies wasn't called (reestablishConnection check)
+ // make sure that clearReplies wasn't called (reestablishConnection check)
verify(exactly = 0) { netconfSessionSpy.clearReplies() }
}
@@ -357,7 +363,7 @@ class NetconfSessionImplTest {
throw Exception("blah")
}
every { netconfCommunicator.sendMessage(any(), any()) } returns futureRet
- //run the method
+ // run the method
val rpcResultFuture = netconfSessionSpy.asyncRpc("0", "0")
every { netconfSessionSpy.checkAndReestablish() } just Runs
val e = assertFailsWith(exceptionClass = ExecutionException::class, message = futureMsg) {
@@ -386,11 +392,11 @@ class NetconfSessionImplTest {
fun `startSession tries to connect to user supplied device`() {
every { mockSshClient.start() } just Runs
every { mockSshClient.properties } returns hashMapOf<String, Any>()
- //setup slots to capture values from the invocations
+ // setup slots to capture values from the invocations
val userSlot = CapturingSlot<String>()
val ipSlot = CapturingSlot<String>()
val portSlot = CapturingSlot<Int>()
- //create a future that succeeded
+ // create a future that succeeded
val succeededFuture = DefaultConnectFuture(Any(), Any())
succeededFuture.value = mockClientSession
every { mockSshClient.connect(capture(userSlot), capture(ipSlot), capture(portSlot)) } returns succeededFuture
@@ -398,9 +404,9 @@ class NetconfSessionImplTest {
every { netconfSessionSpy["authSession"]() as Unit } just Runs
every { netconfSessionSpy["setupNewSSHClient"]() as Unit } just Runs
netconfSessionSpy.setClient(mockSshClient)
- //RUN
+ // RUN
netconfSessionSpy.connect()
- //Verify
+ // Verify
verify { mockSshClient.connect(deviceInfo.username, deviceInfo.ipAddress, deviceInfo.port) }
assertEquals(deviceInfo.username, userSlot.captured)
assertEquals(deviceInfo.ipAddress, ipSlot.captured)
@@ -411,11 +417,11 @@ class NetconfSessionImplTest {
@Test
fun `authSession throws exception if ClientSession is not AUTHED`() {
assertFailsWith(exceptionClass = NetconfException::class) {
- //after client session connects,
+ // after client session connects,
every { mockSshClient.start() } just Runs
every { mockSshClient.properties } returns hashMapOf<String, Any>()
val succeededAuthFuture = DefaultAuthFuture(Any(), Any())
- succeededAuthFuture.value = true //AuthFuture's value is Boolean
+ succeededAuthFuture.value = true // AuthFuture's value is Boolean
val passSlot = CapturingSlot<String>()
every { mockClientSession.addPasswordIdentity(capture(passSlot)) } just Runs
every { mockClientSession.auth() } returns succeededAuthFuture
@@ -423,21 +429,21 @@ class NetconfSessionImplTest {
succeededSessionFuture.value = mockClientSession
every { mockSshClient.connect(deviceInfo.username, deviceInfo.ipAddress, deviceInfo.port) } returns succeededSessionFuture
every { mockClientSession.waitFor(any(), any()) } returns
- setOf(ClientSession.ClientSessionEvent.WAIT_AUTH, ClientSession.ClientSessionEvent.CLOSED)
+ setOf(ClientSession.ClientSessionEvent.WAIT_AUTH, ClientSession.ClientSessionEvent.CLOSED)
val netconfSessionSpy = spyk(netconfSession, recordPrivateCalls = true)
every { netconfSessionSpy["setupNewSSHClient"]() as Unit } just Runs
netconfSessionSpy.setClient(mockSshClient)
- //RUN
+ // RUN
netconfSessionSpy.connect()
}
}
- //common mock initializer for more weird tests.
- private fun setupOpenChannelMocks(): Unit {
+ // common mock initializer for more weird tests.
+ private fun setupOpenChannelMocks() {
every { mockSshClient.start() } just Runs
every { mockSshClient.properties } returns hashMapOf<String, Any>()
val succeededAuthFuture = DefaultAuthFuture(Any(), Any())
- succeededAuthFuture.value = true //AuthFuture's value is Boolean
+ succeededAuthFuture.value = true // AuthFuture's value is Boolean
val passSlot = CapturingSlot<String>()
every { mockClientSession.addPasswordIdentity(capture(passSlot)) } just Runs
every { mockClientSession.auth() } returns succeededAuthFuture
@@ -445,9 +451,11 @@ class NetconfSessionImplTest {
succeededSessionFuture.value = mockClientSession
every { mockSshClient.connect(deviceInfo.username, deviceInfo.ipAddress, deviceInfo.port) } returns succeededSessionFuture
every { mockClientSession.waitFor(any(), any()) } returns
- setOf(ClientSession.ClientSessionEvent.WAIT_AUTH,
- ClientSession.ClientSessionEvent.CLOSED,
- ClientSession.ClientSessionEvent.AUTHED)
+ setOf(
+ ClientSession.ClientSessionEvent.WAIT_AUTH,
+ ClientSession.ClientSessionEvent.CLOSED,
+ ClientSession.ClientSessionEvent.AUTHED
+ )
every { mockClientSession.createSubsystemChannel(any()) } returns mockSubsystem
every { mockClientChannel.invertedOut } returns sampleInputStream
@@ -456,7 +464,7 @@ class NetconfSessionImplTest {
@Test
fun `authSession opensChannel if ClientSession is AUTHED and session can be opened`() {
- //after client session connects, make sure the client receives authentication
+ // after client session connects, make sure the client receives authentication
setupOpenChannelMocks()
val channelFuture = DefaultOpenFuture(Any(), Any())
channelFuture.value = true
@@ -471,17 +479,16 @@ class NetconfSessionImplTest {
every { netconfSessionSpy["setupNewSSHClient"]() as Unit } just Runs
every { netconfSessionSpy["setupHandler"]() as Unit } just Runs
netconfSessionSpy.setClient(mockSshClient)
- //Run
+ // Run
netconfSessionSpy.connect()
- //Verify
+ // Verify
verify { mockSubsystem.open() }
}
-
@Test
fun `authSession throws NetconfException if ClientSession is AUTHED but channelFuture timed out or not open`() {
assertFailsWith(exceptionClass = NetconfException::class) {
- //after client session connects, make sure the client receives authentication
+ // after client session connects, make sure the client receives authentication
setupOpenChannelMocks()
val channelFuture = DefaultOpenFuture(Any(), Any())
every { mockSubsystem.open() } returns channelFuture
@@ -489,14 +496,13 @@ class NetconfSessionImplTest {
every { netconfSessionSpy["setupNewSSHClient"]() as Unit } just Runs
every { netconfSessionSpy["setupHandler"]() as Unit } just Runs
netconfSessionSpy.setClient(mockSshClient)
- //Run
+ // Run
netconfSessionSpy.connect()
- //Verify
+ // Verify
verify { mockSubsystem.open() }
}
}
-
@Test
fun `disconnect closes session, channel, and client`() {
every { rpcService.closeSession(false) } returns SUCCESSFUL_DEVICE_RESPONSE
@@ -507,16 +513,16 @@ class NetconfSessionImplTest {
netconfSessionSpy.setChannel(mockClientChannel)
netconfSessionSpy.setClient(mockSshClient)
netconfSessionSpy.setSession(mockClientSession)
- //RUN
+ // RUN
netconfSessionSpy.disconnect()
- //VERIFY
+ // VERIFY
verify { mockClientSession.close() }
verify { mockClientChannel.close() }
verify { mockSshClient.close() }
}
@Test
- fun `disconnect wraps IOException if channel doesn't close`() { //this test is equivalent to others
+ fun `disconnect wraps IOException if channel doesn't close`() { // this test is equivalent to others
every { rpcService.closeSession(false) } returns SUCCESSFUL_DEVICE_RESPONSE
every { mockClientSession.close() } just Runs
every { mockClientChannel.close() } throws IOException("channel doesn't want to close!")
@@ -524,9 +530,9 @@ class NetconfSessionImplTest {
netconfSessionSpy.setChannel(mockClientChannel)
netconfSessionSpy.setClient(mockSshClient)
netconfSessionSpy.setSession(mockClientSession)
- //RUN
+ // RUN
netconfSessionSpy.disconnect()
- //VERIFY
+ // VERIFY
verify { mockClientSession.close() }
}
}
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionListenerImplTest.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionListenerImplTest.kt
index f3817b7fc..ab762e821 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionListenerImplTest.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionListenerImplTest.kt
@@ -16,16 +16,16 @@
package org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.core
-import org.junit.Test
import io.mockk.every
import io.mockk.mockk
import io.mockk.verifyAll
import org.junit.Before
+import org.junit.Test
import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.api.DeviceInfo
import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.api.NetconfReceivedEvent
class NetconfSessionListenerImplTest {
- //Note: mockk's verifyAll is akin to verify with verifyNoMoreInteractions in Mockito
+ // Note: mockk's verifyAll is akin to verify with verifyNoMoreInteractions in Mockito
private val netconSession = mockk<NetconfSessionImpl>()
@Before
@@ -36,7 +36,7 @@ class NetconfSessionListenerImplTest {
}
@Test
- //NetconfReceivedEvent wth DEVICE_UNREGISTERED TYPE should call disconnect() on the NetconfSession
+ // NetconfReceivedEvent wth DEVICE_UNREGISTERED TYPE should call disconnect() on the NetconfSession
fun deviceUnregisteredMessageShouldCallSessionDisconnect() {
val netconfSessionListener = NetconfSessionListenerImpl(netconSession)
val event: NetconfReceivedEvent = genEventByType(NetconfReceivedEvent.Type.DEVICE_UNREGISTERED)
@@ -45,7 +45,7 @@ class NetconfSessionListenerImplTest {
}
@Test
- //NetconfReceivedEvent wth SESSION_CLOSED TYPE should ALSO call disconnect() on the NetconfSession
+ // NetconfReceivedEvent wth SESSION_CLOSED TYPE should ALSO call disconnect() on the NetconfSession
fun sessionClosedMessageShouldCallSesionDisconnect() {
val netconfSessionListener = NetconfSessionListenerImpl(netconSession)
val event: NetconfReceivedEvent = genEventByType(NetconfReceivedEvent.Type.SESSION_CLOSED)
@@ -54,8 +54,8 @@ class NetconfSessionListenerImplTest {
}
@Test
- //NetconfReceivedEvent wth DEVICE_ERROR TYPE should call addDeviceErrorReply() on the NetconfSession
- //with the event message payload
+ // NetconfReceivedEvent wth DEVICE_ERROR TYPE should call addDeviceErrorReply() on the NetconfSession
+ // with the event message payload
fun deviceErrorMessageShouldCallAddDeviceErrorReply() {
val netconfSessionListener = NetconfSessionListenerImpl(netconSession)
val event: NetconfReceivedEvent = genEventByType(NetconfReceivedEvent.Type.DEVICE_ERROR)
@@ -64,7 +64,7 @@ class NetconfSessionListenerImplTest {
}
@Test
- //NetconfReceivedEvent wth DEVICE_REPLY TYPE should call addDeviceReply(messageId, payload) on the NetconfSession
+ // NetconfReceivedEvent wth DEVICE_REPLY TYPE should call addDeviceReply(messageId, payload) on the NetconfSession
fun deviceReplyMessageShouldCallAddDeviceReply() {
val netconfSessionListener = NetconfSessionListenerImpl(netconSession)
val event: NetconfReceivedEvent = genEventByType(NetconfReceivedEvent.Type.DEVICE_REPLY)
@@ -74,14 +74,14 @@ class NetconfSessionListenerImplTest {
/**
* Helper to generate {@link NetconfReceivedEvent} object based on the {@link NetconfReceivedEvent.Type}
- * @param type {@link NetconfReceivedEvent.Type} of event
+ * @param type {@link NetconfReceivedEvent.Type} of event
*/
private fun genEventByType(type: NetconfReceivedEvent.Type): NetconfReceivedEvent {
return NetconfReceivedEvent(
- type,
- "messagePayload",
- "messageId",
- DeviceInfo()
+ type,
+ "messagePayload",
+ "messageId",
+ DeviceInfo()
)
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/utils/NetconfMessageUtilsTest.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/utils/NetconfMessageUtilsTest.kt
index fcfa12570..cec0fda66 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/utils/NetconfMessageUtilsTest.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/utils/NetconfMessageUtilsTest.kt
@@ -40,7 +40,7 @@ class NetconfMessageUtilsTest {
@Test
fun `test getConfig with filterContent parameter null`() {
- val outcome = NetconfMessageUtils.getConfig("customMessageId", "customConfigType",null)
+ val outcome = NetconfMessageUtils.getConfig("customMessageId", "customConfigType", null)
val expectation = JacksonUtils.getClassPathFileContent("netconf-messages/getConfig-response-filterContent-null.xml")
assertEquals("getConfig return was not correct", expectation, outcome)
}
@@ -54,16 +54,20 @@ class NetconfMessageUtilsTest {
@Test
fun `test editConfig with all parameters present`() {
- val outcome = NetconfMessageUtils.editConfig("customMessageId", "customConfigType", "customDefaultOperation",
- "customNewConfiguration")
+ val outcome = NetconfMessageUtils.editConfig(
+ "customMessageId", "customConfigType", "customDefaultOperation",
+ "customNewConfiguration"
+ )
val expectation = JacksonUtils.getClassPathFileContent("netconf-messages/editConfig-response-all-parameters.xml")
assertEquals("editConfig return was not correct", expectation, outcome)
}
@Test
fun `test editConfig with defaultOperation parameter null`() {
- val outcome = NetconfMessageUtils.editConfig("customMessageId", "customConfigType", null,
- "customNewConfiguration")
+ val outcome = NetconfMessageUtils.editConfig(
+ "customMessageId", "customConfigType", null,
+ "customNewConfiguration"
+ )
val expectation = JacksonUtils.getClassPathFileContent("netconf-messages/editConfig-response-defaultOperation-null.xml")
assertEquals("editConfig return was not correct", expectation, outcome)
}
@@ -92,21 +96,24 @@ class NetconfMessageUtilsTest {
@Test
fun `test commit with confirmed true, persistId empty and persist empty`() {
val outcome = NetconfMessageUtils.commit("customMessageId", true, 1, "", "")
- val expectation = JacksonUtils.getClassPathFileContent("netconf-messages/commit-response-confirmed-true-and-persistId-empty-and-persist-empty.xml")
+ val expectation =
+ JacksonUtils.getClassPathFileContent("netconf-messages/commit-response-confirmed-true-and-persistId-empty-and-persist-empty.xml")
assertEquals("commit return was not correct", expectation, outcome)
}
@Test
fun `test commit with confirmed false, persistId non-empty and persist empty`() {
val outcome = NetconfMessageUtils.commit("customMessageId", false, 1, "", "customPersistId")
- val expectation = JacksonUtils.getClassPathFileContent("netconf-messages/commit-response-confirmed-false-and-persistId-empty-and-persist-not-empty.xml")
+ val expectation =
+ JacksonUtils.getClassPathFileContent("netconf-messages/commit-response-confirmed-false-and-persistId-empty-and-persist-not-empty.xml")
assertEquals("commit return was not correct", expectation, outcome)
}
@Test
fun `test commit with confirmed false, persistId empty and persist non-empty`() {
val outcome = NetconfMessageUtils.commit("customMessageId", false, 1, "customPersist", "")
- val expectation = JacksonUtils.getClassPathFileContent("netconf-messages/commit-response-confirmed-false-and-persistId-not-empty-and-persist-empty.xml")
+ val expectation =
+ JacksonUtils.getClassPathFileContent("netconf-messages/commit-response-confirmed-false-and-persistId-not-empty-and-persist-empty.xml")
assertEquals("commit return was not correct", expectation, outcome)
}
@@ -173,7 +180,7 @@ class NetconfMessageUtilsTest {
assertEquals("closeSession return was not correct", expectation, outcome)
}
- //TODO validateRPCXML
+ // TODO validateRPCXML
@Test
fun `test getMsgId with valid message`() {
@@ -197,6 +204,5 @@ class NetconfMessageUtilsTest {
assertEquals("getMsgId return was not correct", expectation, outcome)
}
-//TODO validateChunkedFraming
-
+ // TODO validateChunkedFraming
}
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/utils/RpcMessageUtilsTest.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/utils/RpcMessageUtilsTest.kt
index b80dc2d88..0d791c2a6 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/utils/RpcMessageUtilsTest.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/utils/RpcMessageUtilsTest.kt
@@ -27,29 +27,28 @@ class RpcMessageUtilsTest {
@Test
fun getConfig() {
- val checkString = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
- + "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">"
- + "<get-config><source><candidate/></source><filter type=\"subtree\">Test-Filter-Content</filter>"
- + "</get-config></rpc>")
+ val checkString = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
+ "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" +
+ "<get-config><source><candidate/></source><filter type=\"subtree\">Test-Filter-Content</filter>" +
+ "</get-config></rpc>")
val messageId = "Test-Message-ID"
val configType = NetconfDatastore.CANDIDATE.datastore
val filterContent = "Test-Filter-Content"
val result =
- NetconfMessageUtils.getConfig(messageId, configType, filterContent).replace("[\n\r\t]".toRegex(), "")
+ NetconfMessageUtils.getConfig(messageId, configType, filterContent).replace("[\n\r\t]".toRegex(), "")
assertTrue(NetconfMessageUtils.validateRPCXML(result))
Assert.assertEquals(checkString, result)
}
-
@Test
fun editConfig() {
- val checkString = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
- + "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">"
- + "<edit-config><target><candidate/></target><default-operation>Test-Default-Operation</default-operation>"
- + "<config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">Test-Filter-Content</config></edit-config></rpc>")
+ val checkString = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
+ "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" +
+ "<edit-config><target><candidate/></target><default-operation>Test-Default-Operation</default-operation>" +
+ "<config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">Test-Filter-Content</config></edit-config></rpc>")
val messageId = "Test-Message-ID"
val configType = NetconfDatastore.CANDIDATE.datastore
@@ -57,7 +56,7 @@ class RpcMessageUtilsTest {
val defaultOperation = "Test-Default-Operation"
val result =
- NetconfMessageUtils.editConfig(messageId, configType, defaultOperation, filterContent).replace("[\n\r\t]".toRegex(), "")
+ NetconfMessageUtils.editConfig(messageId, configType, defaultOperation, filterContent).replace("[\n\r\t]".toRegex(), "")
assertTrue(NetconfMessageUtils.validateRPCXML(result))
Assert.assertEquals(checkString, result)
@@ -65,9 +64,9 @@ class RpcMessageUtilsTest {
@Test
fun validate() {
- val checkString = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
- + "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">"
- + "<validate><source><candidate/></source></validate></rpc>")
+ val checkString = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
+ "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" +
+ "<validate><source><candidate/></source></validate></rpc>")
val messageId = "Test-Message-ID"
val configType = NetconfDatastore.CANDIDATE.datastore
@@ -81,16 +80,16 @@ class RpcMessageUtilsTest {
@Test
fun cancelCommit() {
val checkString =
- ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
- "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" +
- "<cancel-commit>" +
- "<persist-id>1234</persist-id>" +
- "</cancel-commit></rpc>")
+ ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
+ "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" +
+ "<cancel-commit>" +
+ "<persist-id>1234</persist-id>" +
+ "</cancel-commit></rpc>")
val messageId = "Test-Message-ID"
val cancelCommitPersistId =
- NetconfMessageUtils.cancelCommit(messageId, "1234").replace("[\n\r\t]".toRegex(), "")
+ NetconfMessageUtils.cancelCommit(messageId, "1234").replace("[\n\r\t]".toRegex(), "")
assertTrue(NetconfMessageUtils.validateRPCXML(cancelCommitPersistId))
Assert.assertEquals(checkString, cancelCommitPersistId)
@@ -99,10 +98,10 @@ class RpcMessageUtilsTest {
@Test
fun cancelCommitNoPersistId() {
val checkString =
- ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
- "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" +
- "<cancel-commit>" +
- "</cancel-commit></rpc>")
+ ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
+ "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" +
+ "<cancel-commit>" +
+ "</cancel-commit></rpc>")
val messageId = "Test-Message-ID"
@@ -114,31 +113,30 @@ class RpcMessageUtilsTest {
@Test
fun commit() {
- val checkString = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
- + "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">"
- + "<commit></commit></rpc>")
+ val checkString = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
+ "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" +
+ "<commit></commit></rpc>")
val messageId = "Test-Message-ID"
val commit = NetconfMessageUtils.commit(messageId, false, 0, "", "").replace("[\n\r\t]".toRegex(), "")
val commitWithPersistButNotConfirmed =
- NetconfMessageUtils.commit(messageId, false, 0, "1234", "").replace("[\n\r\t]".toRegex(), "")
+ NetconfMessageUtils.commit(messageId, false, 0, "1234", "").replace("[\n\r\t]".toRegex(), "")
assertTrue(NetconfMessageUtils.validateRPCXML(commit))
Assert.assertEquals(checkString, commit)
Assert.assertEquals(checkString, commitWithPersistButNotConfirmed)
-
}
@Test
fun commitPersistId() {
val checkString =
- ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
- "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" +
- "<commit>" +
- "<persist-id>1234</persist-id>" +
- "</commit></rpc>")
+ ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
+ "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" +
+ "<commit>" +
+ "<persist-id>1234</persist-id>" +
+ "</commit></rpc>")
val messageId = "Test-Message-ID"
@@ -149,8 +147,10 @@ class RpcMessageUtilsTest {
try {
NetconfMessageUtils.commit(messageId, true, 30, "", "1234").replace("[\n\r\t]".toRegex(), "")
} catch (e: NetconfException) {
- Assert.assertEquals("Can't proceed <commit> with both confirmed flag and persistId(1234) specified. Only one should be specified.",
- e.message)
+ Assert.assertEquals(
+ "Can't proceed <commit> with both confirmed flag and persistId(1234) specified. Only one should be specified.",
+ e.message
+ )
return
}
@@ -160,13 +160,13 @@ class RpcMessageUtilsTest {
@Test
fun commitPersist() {
val checkString =
- ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
- "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" +
- "<commit>" +
- "<confirmed/>" +
- "<confirm-timeout>30</confirm-timeout>" +
- "<persist>1234</persist>" +
- "</commit></rpc>")
+ ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
+ "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" +
+ "<commit>" +
+ "<confirmed/>" +
+ "<confirm-timeout>30</confirm-timeout>" +
+ "<persist>1234</persist>" +
+ "</commit></rpc>")
val messageId = "Test-Message-ID"
@@ -178,8 +178,10 @@ class RpcMessageUtilsTest {
try {
NetconfMessageUtils.commit(messageId, false, 30, "1234", "1234").replace("[\n\r\t]".toRegex(), "")
} catch (e: NetconfException) {
- Assert.assertEquals("Can't proceed <commit> with both persist(1234) and persistId(1234) specified. Only one should be specified.",
- e.message)
+ Assert.assertEquals(
+ "Can't proceed <commit> with both persist(1234) and persistId(1234) specified. Only one should be specified.",
+ e.message
+ )
return
}
fail()
@@ -187,9 +189,9 @@ class RpcMessageUtilsTest {
@Test
fun unlock() {
- val checkString = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
- + "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">"
- + "<unlock><target><candidate/></target></unlock></rpc>")
+ val checkString = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
+ "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" +
+ "<unlock><target><candidate/></target></unlock></rpc>")
val messageId = "Test-Message-ID"
val configType = NetconfDatastore.CANDIDATE.datastore
@@ -202,9 +204,9 @@ class RpcMessageUtilsTest {
@Test
fun deleteConfig() {
- val checkString = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
- + "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">"
- + "<delete-config><target><candidate/></target></delete-config></rpc>")
+ val checkString = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
+ "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" +
+ "<delete-config><target><candidate/></target></delete-config></rpc>")
val messageId = "Test-Message-ID"
val netconfTargetConfig = NetconfDatastore.CANDIDATE.datastore
@@ -226,9 +228,9 @@ class RpcMessageUtilsTest {
@Test
fun discardChanges() {
- val checkString = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
- + "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">"
- + "<discard-changes/></rpc>")
+ val checkString = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
+ "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" +
+ "<discard-changes/></rpc>")
val messageId = "Test-Message-ID"
@@ -240,9 +242,9 @@ class RpcMessageUtilsTest {
@Test
fun lock() {
- val checkString = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
- + "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">"
- + "<lock><target><candidate/></target></lock></rpc>")
+ val checkString = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
+ "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" +
+ "<lock><target><candidate/></target></lock></rpc>")
val messageId = "Test-Message-ID"
val configType = NetconfDatastore.CANDIDATE.datastore
@@ -271,8 +273,8 @@ class RpcMessageUtilsTest {
@Test
fun createHelloString() {
- val checkString = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?><hello xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"> "
- +"<capabilities> <capability>hi</capability> <capability>hello</capability> </capabilities></hello>]]>]]>")
+ val checkString = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?><hello xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"> " +
+ "<capabilities> <capability>hi</capability> <capability>hello</capability> </capabilities></hello>]]>]]>")
val capability = listOf<String>("hi", "hello")
@@ -303,19 +305,19 @@ class RpcMessageUtilsTest {
}
@Test
- fun formatRPCRequest(){
+ fun formatRPCRequest() {
val checkString = ("#199" +
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><hello xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"> <capabilities> <capability>hi</capability> <capability>hello</capability> </capabilities></hello>" +
"##")
- val request = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?><hello xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"> "
- +"<capabilities> <capability>hi</capability> <capability>hello</capability> </capabilities></hello>]]>]]>")
+ val request = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?><hello xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"> " +
+ "<capabilities> <capability>hi</capability> <capability>hello</capability> </capabilities></hello>]]>]]>")
val messageId = "Test-Message-ID"
- val capabilities = setOf<String>("hi", "hello","urn:ietf:params:netconf:base:1.1")
+ val capabilities = setOf<String>("hi", "hello", "urn:ietf:params:netconf:base:1.1")
- val result = NetconfMessageUtils.formatRPCRequest(request,messageId,capabilities).replace("[\n\r\t]".toRegex(), "")
+ val result = NetconfMessageUtils.formatRPCRequest(request, messageId, capabilities).replace("[\n\r\t]".toRegex(), "")
Assert.assertEquals(checkString, result)
}
@@ -329,5 +331,4 @@ class RpcMessageUtilsTest {
println("Don't fear \"[Fatal Error] :1:1: Content is not allowed in prolog.\" TODO: adjust logging for NetconfMessageUtils")
assertFalse { NetconfMessageUtils.validateRPCXML("really bad XML ~~~input") }
}
-
}
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentJythonExecutor.kt b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentJythonExecutor.kt
index e13c150ee..b0dcc6339 100644
--- a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentJythonExecutor.kt
+++ b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentJythonExecutor.kt
@@ -36,8 +36,10 @@ import org.springframework.stereotype.Component
@Component("component-jython-executor")
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-open class ComponentJythonExecutor(private var applicationContext: ApplicationContext,
- private val blueprintJythonService: BlueprintJythonService) : AbstractComponentFunction() {
+open class ComponentJythonExecutor(
+ private var applicationContext: ApplicationContext,
+ private val blueprintJythonService: BlueprintJythonService
+) : AbstractComponentFunction() {
private val log = LoggerFactory.getLogger(ComponentJythonExecutor::class.java)
@@ -51,27 +53,26 @@ open class ComponentJythonExecutor(private var applicationContext: ApplicationCo
// Invoke Jython Component Script
componentFunction.executeScript(executionServiceInput)
-
}
override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
bluePrintRuntimeService.getBluePrintError()
- .addError("Failed in ComponentJythonExecutor : ${runtimeException.message}")
+ .addError("Failed in ComponentJythonExecutor : ${runtimeException.message}")
}
private fun populateJythonComponentInstance() {
val bluePrintContext = bluePrintRuntimeService.bluePrintContext()
val operationAssignment: OperationAssignment = bluePrintContext
- .nodeTemplateInterfaceOperation(nodeTemplateName, interfaceName, operationName)
+ .nodeTemplateInterfaceOperation(nodeTemplateName, interfaceName, operationName)
val artifactName: String = operationAssignment.implementation?.primary
- ?: throw BluePrintProcessorException("missing primary field to get artifact name for node template ($nodeTemplateName)")
+ ?: throw BluePrintProcessorException("missing primary field to get artifact name for node template ($nodeTemplateName)")
val artifactDefinition = bluePrintRuntimeService.resolveNodeTemplateArtifactDefinition(nodeTemplateName, artifactName)
val pythonFileName = artifactDefinition.file
- ?: throw BluePrintProcessorException("missing file name for node template ($nodeTemplateName)'s artifactName($artifactName)")
+ ?: throw BluePrintProcessorException("missing file name for node template ($nodeTemplateName)'s artifactName($artifactName)")
val pythonClassName = FilenameUtils.getBaseName(pythonFileName)
@@ -80,7 +81,7 @@ open class ComponentJythonExecutor(private var applicationContext: ApplicationCo
checkNotEmpty(content) { "artifact ($artifactName) content is empty" }
val instanceDependenciesNode: ArrayNode = operationInputs[PythonExecutorConstants.INPUT_INSTANCE_DEPENDENCIES] as? ArrayNode
- ?: throw BluePrintProcessorException("Failed to get property(${PythonExecutorConstants.INPUT_INSTANCE_DEPENDENCIES})")
+ ?: throw BluePrintProcessorException("Failed to get property(${PythonExecutorConstants.INPUT_INSTANCE_DEPENDENCIES})")
val jythonInstance: MutableMap<String, Any> = hashMapOf()
jythonInstance["log"] = LoggerFactory.getLogger(pythonClassName)
@@ -101,4 +102,4 @@ open class ComponentJythonExecutor(private var applicationContext: ApplicationCo
componentFunction.workflowName = workflowName
componentFunction.scriptType = BluePrintConstants.SCRIPT_JYTHON
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutor.kt b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutor.kt
index 91d51757a..ddfaf9ac2 100644
--- a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutor.kt
+++ b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutor.kt
@@ -17,12 +17,22 @@
package org.onap.ccsdk.cds.blueprintsprocessor.functions.python.executor
import com.fasterxml.jackson.databind.JsonNode
-import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.*
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.PrepareRemoteEnvInput
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.RemoteIdentifier
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.RemoteScriptExecutionInput
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.StatusType
import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractComponentFunction
import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ExecutionServiceConstant
import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.RemoteScriptExecutionService
-import org.onap.ccsdk.cds.controllerblueprints.core.*
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
+import org.onap.ccsdk.cds.controllerblueprints.core.checkFileExists
+import org.onap.ccsdk.cds.controllerblueprints.core.checkNotBlank
import org.onap.ccsdk.cds.controllerblueprints.core.data.OperationAssignment
+import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile
+import org.onap.ccsdk.cds.controllerblueprints.core.returnNullIfMissing
+import org.onap.ccsdk.cds.controllerblueprints.core.rootFieldsToMap
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.config.ConfigurableBeanFactory
@@ -33,8 +43,7 @@ import org.springframework.stereotype.Component
@ConditionalOnBean(name = [ExecutionServiceConstant.SERVICE_GRPC_REMOTE_SCRIPT_EXECUTION])
@Component("component-remote-python-executor")
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-open class ComponentRemotePythonExecutor(private val remoteScriptExecutionService: RemoteScriptExecutionService)
- : AbstractComponentFunction() {
+open class ComponentRemotePythonExecutor(private val remoteScriptExecutionService: RemoteScriptExecutionService) : AbstractComponentFunction() {
private val log = LoggerFactory.getLogger(ComponentRemotePythonExecutor::class.java)!!
@@ -103,9 +112,12 @@ open class ComponentRemotePythonExecutor(private val remoteScriptExecutionServic
// If packages are defined, then install in remote server
if (packages != null) {
- val prepareEnvInput = PrepareRemoteEnvInput(requestId = processId,
- remoteIdentifier = RemoteIdentifier(blueprintName = blueprintName,
- blueprintVersion = blueprintVersion),
+ val prepareEnvInput = PrepareRemoteEnvInput(
+ requestId = processId,
+ remoteIdentifier = RemoteIdentifier(
+ blueprintName = blueprintName,
+ blueprintVersion = blueprintVersion
+ ),
packages = packages
)
val prepareEnvOutput = remoteScriptExecutionService.prepareEnv(prepareEnvInput)
@@ -128,18 +140,21 @@ open class ComponentRemotePythonExecutor(private val remoteScriptExecutionServic
val properties = dynamicProperties?.returnNullIfMissing()?.rootFieldsToMap() ?: hashMapOf()
val remoteExecutionInput = RemoteScriptExecutionInput(
- requestId = processId,
- remoteIdentifier = RemoteIdentifier(blueprintName = blueprintName, blueprintVersion = blueprintVersion),
- command = scriptCommand,
- properties = properties)
+ requestId = processId,
+ remoteIdentifier = RemoteIdentifier(blueprintName = blueprintName, blueprintVersion = blueprintVersion),
+ command = scriptCommand,
+ properties = properties
+ )
val remoteExecutionOutput = remoteScriptExecutionService.executeCommand(remoteExecutionInput)
val logs = JacksonUtils.jsonNodeFromObject(remoteExecutionOutput.response)
if (remoteExecutionOutput.status != StatusType.SUCCESS) {
setNodeOutputErrors(remoteExecutionOutput.status.name, logs, remoteExecutionOutput.payload)
} else {
- setNodeOutputProperties(remoteExecutionOutput.status.name.asJsonPrimitive(), logs,
- remoteExecutionOutput.payload)
+ setNodeOutputProperties(
+ remoteExecutionOutput.status.name.asJsonPrimitive(), logs,
+ remoteExecutionOutput.payload
+ )
}
}
} catch (e: Exception) {
@@ -179,7 +194,7 @@ open class ComponentRemotePythonExecutor(private val remoteScriptExecutionServic
/**
* Utility function to set the output properties and errors of the executor node, in cas of errors
*/
- private fun setNodeOutputErrors(status: String, message: JsonNode, artifacts: JsonNode = "".asJsonPrimitive() ) {
+ private fun setNodeOutputErrors(status: String, message: JsonNode, artifacts: JsonNode = "".asJsonPrimitive()) {
setAttribute(ATTRIBUTE_EXEC_CMD_STATUS, status.asJsonPrimitive())
log.info("Executor status : $status")
setAttribute(ATTRIBUTE_EXEC_CMD_LOG, message)
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorDSL.kt b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorDSL.kt
index c2055f9a5..6998f0229 100644
--- a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorDSL.kt
+++ b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorDSL.kt
@@ -33,36 +33,54 @@ import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
/** Component Extensions **/
fun BluePrintTypes.nodeTypeComponentRemotePythonExecutor(): NodeType {
- return nodeType(id = "component-remote-python-executor", version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
- derivedFrom = BluePrintConstants.MODEL_TYPE_NODE_COMPONENT,
- description = "This is Remote Python Execution Component.") {
-
- attribute(ComponentRemotePythonExecutor.ATTRIBUTE_PREPARE_ENV_LOG, BluePrintConstants.DATA_TYPE_STRING,
- false)
- attribute(ComponentRemotePythonExecutor.ATTRIBUTE_EXEC_CMD_LOG, BluePrintConstants.DATA_TYPE_LIST,
- false) {
+ return nodeType(
+ id = "component-remote-python-executor", version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
+ derivedFrom = BluePrintConstants.MODEL_TYPE_NODE_COMPONENT,
+ description = "This is Remote Python Execution Component."
+ ) {
+
+ attribute(
+ ComponentRemotePythonExecutor.ATTRIBUTE_PREPARE_ENV_LOG, BluePrintConstants.DATA_TYPE_STRING,
+ false
+ )
+ attribute(
+ ComponentRemotePythonExecutor.ATTRIBUTE_EXEC_CMD_LOG, BluePrintConstants.DATA_TYPE_LIST,
+ false
+ ) {
entrySchema(BluePrintConstants.DATA_TYPE_STRING)
}
- attribute(ComponentRemotePythonExecutor.ATTRIBUTE_RESPONSE_DATA, BluePrintConstants.DATA_TYPE_JSON,
- false)
+ attribute(
+ ComponentRemotePythonExecutor.ATTRIBUTE_RESPONSE_DATA, BluePrintConstants.DATA_TYPE_JSON,
+ false
+ )
operation("ComponentRemotePythonExecutor", "ComponentRemotePythonExecutor Operation") {
inputs {
- property(ComponentRemotePythonExecutor.INPUT_ENDPOINT_SELECTOR, BluePrintConstants.DATA_TYPE_STRING,
- false, "Remote Container or Server selector name.") {
+ property(
+ ComponentRemotePythonExecutor.INPUT_ENDPOINT_SELECTOR, BluePrintConstants.DATA_TYPE_STRING,
+ false, "Remote Container or Server selector name."
+ ) {
defaultValue(ComponentRemotePythonExecutor.DEFAULT_SELECTOR)
}
- property(ComponentRemotePythonExecutor.INPUT_DYNAMIC_PROPERTIES, BluePrintConstants.DATA_TYPE_JSON,
- false, "Dynamic Json Content or DSL Json reference.")
-
- property(ComponentRemotePythonExecutor.INPUT_ARGUMENT_PROPERTIES, BluePrintConstants.DATA_TYPE_JSON,
- false, "Argument Json Content or DSL Json reference.")
-
- property(ComponentRemotePythonExecutor.INPUT_COMMAND, BluePrintConstants.DATA_TYPE_STRING,
- true, "Command to execute.")
-
- property(ComponentRemotePythonExecutor.INPUT_PACKAGES, BluePrintConstants.DATA_TYPE_LIST,
- false, "Packages to install based on type.") {
+ property(
+ ComponentRemotePythonExecutor.INPUT_DYNAMIC_PROPERTIES, BluePrintConstants.DATA_TYPE_JSON,
+ false, "Dynamic Json Content or DSL Json reference."
+ )
+
+ property(
+ ComponentRemotePythonExecutor.INPUT_ARGUMENT_PROPERTIES, BluePrintConstants.DATA_TYPE_JSON,
+ false, "Argument Json Content or DSL Json reference."
+ )
+
+ property(
+ ComponentRemotePythonExecutor.INPUT_COMMAND, BluePrintConstants.DATA_TYPE_STRING,
+ true, "Command to execute."
+ )
+
+ property(
+ ComponentRemotePythonExecutor.INPUT_PACKAGES, BluePrintConstants.DATA_TYPE_LIST,
+ false, "Packages to install based on type."
+ ) {
entrySchema("dt-system-packages")
}
}
@@ -71,9 +89,11 @@ fun BluePrintTypes.nodeTypeComponentRemotePythonExecutor(): NodeType {
}
fun BluePrintTypes.dataTypeDtSystemPackages(): DataType {
- return dataType(id = "dt-system-packages", version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
- derivedFrom = BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT,
- description = "This represent System Package Data Type") {
+ return dataType(
+ id = "dt-system-packages", version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
+ derivedFrom = BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT,
+ description = "This represent System Package Data Type"
+ ) {
property("type", BluePrintConstants.DATA_TYPE_LIST, true, "") {
constrain {
entrySchema(BluePrintConstants.DATA_TYPE_STRING)
@@ -87,10 +107,12 @@ fun BluePrintTypes.dataTypeDtSystemPackages(): DataType {
}
/** Component Builder */
-fun BluePrintTypes.nodeTemplateComponentRemotePythonExecutor(id: String,
- description: String,
- block: ComponentRemotePythonExecutorNodeTemplateBuilder.() -> Unit)
- : NodeTemplate {
+fun BluePrintTypes.nodeTemplateComponentRemotePythonExecutor(
+ id: String,
+ description: String,
+ block: ComponentRemotePythonExecutorNodeTemplateBuilder.() -> Unit
+):
+ NodeTemplate {
return ComponentRemotePythonExecutorNodeTemplateBuilder(id, description).apply(block).build()
}
@@ -112,9 +134,11 @@ class DtSystemPackageDataTypeBuilder : PropertiesAssignmentBuilder() {
}
class ComponentRemotePythonExecutorNodeTemplateBuilder(id: String, description: String) :
- AbstractNodeTemplateOperationImplBuilder<PropertiesAssignmentBuilder, ComponentRemotePythonExecutorNodeTemplateBuilder.InputsBuilder,
- ComponentRemotePythonExecutorNodeTemplateBuilder.OutputsBuilder>(id, "component-remote-python-executor",
- "ComponentRemotePythonExecutor", description) {
+ AbstractNodeTemplateOperationImplBuilder<PropertiesAssignmentBuilder, ComponentRemotePythonExecutorNodeTemplateBuilder.InputsBuilder,
+ ComponentRemotePythonExecutorNodeTemplateBuilder.OutputsBuilder>(
+ id, "component-remote-python-executor",
+ "ComponentRemotePythonExecutor", description
+ ) {
class InputsBuilder : PropertiesAssignmentBuilder() {
@@ -161,5 +185,4 @@ class ComponentRemotePythonExecutorNodeTemplateBuilder(id: String, description:
}
class OutputsBuilder : PropertiesAssignmentBuilder()
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/JythonComponentFunction.kt b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/JythonComponentFunction.kt
index 7e00206ca..891b09d88 100644
--- a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/JythonComponentFunction.kt
+++ b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/JythonComponentFunction.kt
@@ -29,5 +29,4 @@ open class JythonComponentFunction : AbstractScriptComponentFunction() {
override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
throw BluePrintException("Not Implemented required")
}
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentJythonExecutorTest.kt b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentJythonExecutorTest.kt
index 11396b7e9..4e919272a 100644
--- a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentJythonExecutorTest.kt
+++ b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentJythonExecutorTest.kt
@@ -36,11 +36,15 @@ import org.springframework.test.context.TestPropertySource
import org.springframework.test.context.junit4.SpringRunner
@RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [PythonExecutorConfiguration::class, PythonExecutorProperty::class,
- ComponentJythonExecutor::class, MockInstanceConfiguration::class])
-@TestPropertySource(properties =
-["blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_blueprints",
- "blueprints.processor.functions.python.executor.executionPath=./../../../../components/scripts/python/ccsdk_blueprints"])
+@ContextConfiguration(
+ classes = [PythonExecutorConfiguration::class, PythonExecutorProperty::class,
+ ComponentJythonExecutor::class, MockInstanceConfiguration::class]
+)
+@TestPropertySource(
+ properties =
+ ["blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_blueprints",
+ "blueprints.processor.functions.python.executor.executionPath=./../../../../components/scripts/python/ccsdk_blueprints"]
+)
class ComponentJythonExecutorTest {
@Autowired
@@ -50,11 +54,15 @@ class ComponentJythonExecutorTest {
fun testPythonComponentInjection() {
runBlocking {
- val executionServiceInput = JacksonUtils.readValueFromClassPathFile("payload/requests/sample-activate-request.json",
- ExecutionServiceInput::class.java)!!
+ val executionServiceInput = JacksonUtils.readValueFromClassPathFile(
+ "payload/requests/sample-activate-request.json",
+ ExecutionServiceInput::class.java
+ )!!
- val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
- "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(
+ "1234",
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
val stepMetaData: MutableMap<String, JsonNode> = hashMapOf()
stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, "activate-jython")
@@ -68,6 +76,5 @@ class ComponentJythonExecutorTest {
executionServiceInput.stepData = stepInputData
componentJythonExecutor.applyNB(executionServiceInput)
}
-
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorDSLTest.kt b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorDSLTest.kt
index 18eb77b80..5e77937bc 100644
--- a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorDSLTest.kt
+++ b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorDSLTest.kt
@@ -25,23 +25,27 @@ class ComponentRemotePythonExecutorDSLTest {
@Test
fun testNodeTypeComponentRemotePythonExecutor() {
val nodeType = BluePrintTypes.nodeTypeComponentRemotePythonExecutor()
- //println(nodeType.asJsonString(true))
+ // println(nodeType.asJsonString(true))
assertNotNull(nodeType, "failed to generate nodeTypeComponentRemotePythonExecutor")
}
@Test
fun testNodeTemplateComponentRemotePythonExecutor() {
- val nodeTemplate = BluePrintTypes.nodeTemplateComponentRemotePythonExecutor("test-nodetemplate",
- "test nodetemplate") {
+ val nodeTemplate = BluePrintTypes.nodeTemplateComponentRemotePythonExecutor(
+ "test-nodetemplate",
+ "test nodetemplate"
+ ) {
definedOperation("test operation") {
inputs {
endpointSelector("remote-container")
command("python sample.py")
- dynamicProperties("""{
+ dynamicProperties(
+ """{
"prop1" : "1234",
"prop2" : true,
"prop3" : 23
- }""".trimIndent())
+ }""".trimIndent()
+ )
argumentProperties("""["one", "two"]""")
packages {
type("pip")
@@ -50,7 +54,7 @@ class ComponentRemotePythonExecutorDSLTest {
}
}
}
- //println(nodeTemplate.asJsonString(true))
+ // println(nodeTemplate.asJsonString(true))
assertNotNull(nodeTemplate, "failed to generate nodeTemplateComponentRemotePythonExecutor")
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorTest.kt b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorTest.kt
index 89af42579..847b08018 100644
--- a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorTest.kt
+++ b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorTest.kt
@@ -22,7 +22,12 @@ import io.mockk.every
import io.mockk.mockk
import kotlinx.coroutines.runBlocking
import org.junit.Test
-import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.*
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.PrepareRemoteEnvInput
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.RemoteScriptExecutionInput
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.RemoteScriptExecutionOutput
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.StatusType
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.StepData
import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.RemoteScriptExecutionService
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
@@ -34,7 +39,6 @@ import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import kotlin.test.assertEquals
import kotlin.test.assertNotNull
-
class ComponentRemotePythonExecutorTest {
@Test
@@ -45,16 +49,21 @@ class ComponentRemotePythonExecutorTest {
val componentRemotePythonExecutor = ComponentRemotePythonExecutor(remoteScriptExecutionService)
val executionServiceInput =
- JacksonUtils.readValueFromClassPathFile("payload/requests/sample-remote-python-request.json",
- ExecutionServiceInput::class.java)!!
-
+ JacksonUtils.readValueFromClassPathFile(
+ "payload/requests/sample-remote-python-request.json",
+ ExecutionServiceInput::class.java
+ )!!
- val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("123456-1000",
- "./../../../../components/model-catalog/blueprint-model/test-blueprint/remote_scripts")
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(
+ "123456-1000",
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/remote_scripts"
+ )
/** Load Workflow Inputs */
- bluePrintRuntimeService.assignWorkflowInputs("execute-remote-python",
- executionServiceInput.payload.get("execute-remote-python-request"))
+ bluePrintRuntimeService.assignWorkflowInputs(
+ "execute-remote-python",
+ executionServiceInput.payload.get("execute-remote-python-request")
+ )
val stepMetaData: MutableMap<String, JsonNode> = hashMapOf()
stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, "execute-remote-python")
@@ -97,13 +106,16 @@ class ComponentRemotePythonExecutorTest {
val stepMetaData: MutableMap<String, JsonNode> = hashMapOf()
stepMetaData.putJsonElement(
- BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE,
- "execute-remote-python")
+ BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE,
+ "execute-remote-python"
+ )
stepMetaData.putJsonElement(
- BluePrintConstants.PROPERTY_CURRENT_INTERFACE,
- "ComponentRemotePythonExecutor")
+ BluePrintConstants.PROPERTY_CURRENT_INTERFACE,
+ "ComponentRemotePythonExecutor"
+ )
stepMetaData.putJsonElement(
- BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process")
+ BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process"
+ )
val mapper = ObjectMapper()
val rootNode = mapper.createObjectNode()
@@ -112,13 +124,16 @@ class ComponentRemotePythonExecutorTest {
val operationalInputs: MutableMap<String, JsonNode> = hashMapOf()
operationalInputs.putJsonElement(
- BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE,
- "execute-remote-python")
+ BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE,
+ "execute-remote-python"
+ )
operationalInputs.putJsonElement(
- BluePrintConstants.PROPERTY_CURRENT_INTERFACE,
- "ComponentRemotePythonExecutor")
+ BluePrintConstants.PROPERTY_CURRENT_INTERFACE,
+ "ComponentRemotePythonExecutor"
+ )
operationalInputs.putJsonElement(
- BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process")
+ BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process"
+ )
operationalInputs.putJsonElement("endpoint-selector", "aai")
operationalInputs.putJsonElement("dynamic-properties", rootNode)
operationalInputs.putJsonElement("command", "./run.sh")
@@ -126,8 +141,9 @@ class ComponentRemotePythonExecutorTest {
every {
svc.resolveNodeTemplateInterfaceOperationInputs(
- "execute-remote-python",
- "ComponentRemotePythonExecutor", "process")
+ "execute-remote-python",
+ "ComponentRemotePythonExecutor", "process"
+ )
} returns operationalInputs
val stepInputData = StepData().apply {
@@ -136,42 +152,51 @@ class ComponentRemotePythonExecutorTest {
}
val executionServiceInput = JacksonUtils
- .readValueFromClassPathFile(
- "payload/requests/sample-remote-python-request.json",
- ExecutionServiceInput::class.java)!!
+ .readValueFromClassPathFile(
+ "payload/requests/sample-remote-python-request.json",
+ ExecutionServiceInput::class.java
+ )!!
executionServiceInput.stepData = stepInputData
val operationOutputs = hashMapOf<String, JsonNode>()
every {
svc.resolveNodeTemplateInterfaceOperationOutputs(
- "execute-remote-python",
- "ComponentRemotePythonExecutor", "process")
+ "execute-remote-python",
+ "ComponentRemotePythonExecutor", "process"
+ )
} returns operationOutputs
val bluePrintRuntimeService = BluePrintMetadataUtils
- .getBluePrintRuntime("123456-1000",
- "./../../../../components/model-" +
- "catalog/blueprint-model/test-blueprint/" +
- "remote_scripts")
+ .getBluePrintRuntime(
+ "123456-1000",
+ "./../../../../components/model-" +
+ "catalog/blueprint-model/test-blueprint/" +
+ "remote_scripts"
+ )
every {
svc.resolveNodeTemplateArtifactDefinition(
- "execute-remote-python", "component-script")
+ "execute-remote-python", "component-script"
+ )
} returns bluePrintRuntimeService.resolveNodeTemplateArtifactDefinition(
- "execute-remote-python", "component-script")
+ "execute-remote-python", "component-script"
+ )
every {
svc.setNodeTemplateAttributeValue(
- "execute-remote-python", "prepare-environment-logs",
- "prepared successfully".asJsonPrimitive())
+ "execute-remote-python", "prepare-environment-logs",
+ "prepared successfully".asJsonPrimitive()
+ )
} returns Unit
every {
svc.setNodeTemplateAttributeValue(
- "execute-remote-python",
- "execute-command-logs", "N/A".asJsonPrimitive())
+ "execute-remote-python",
+ "execute-command-logs", "N/A".asJsonPrimitive()
+ )
} returns Unit
every {
svc.setNodeTemplateAttributeValue(
- "execute-remote-python",
- "execute-command-logs",
- "processed successfully".asJsonPrimitive())
+ "execute-remote-python",
+ "execute-command-logs",
+ "processed successfully".asJsonPrimitive()
+ )
} returns Unit
every {
@@ -211,6 +236,5 @@ class MockRemoteScriptExecutionService : RemoteScriptExecutionService {
}
override suspend fun close() {
-
}
}
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/mock/MockInstanceConfiguration.kt b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/mock/MockInstanceConfiguration.kt
index 33f68e273..c523b6653 100644
--- a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/mock/MockInstanceConfiguration.kt
+++ b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/mock/MockInstanceConfiguration.kt
@@ -21,12 +21,11 @@ import org.springframework.context.annotation.Configuration
@Configuration
open class MockInstanceConfiguration {
+
@Bean(name = ["json-parser-service", "netconf-rpc-service"])
open fun createComponentFunction(): MockJythonService {
return MockJythonService()
}
}
-class MockJythonService {
-
-} \ No newline at end of file
+class MockJythonService
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceAssignmentRuntimeService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceAssignmentRuntimeService.kt
index 3a3750acb..a65ec585b 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceAssignmentRuntimeService.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceAssignmentRuntimeService.kt
@@ -5,8 +5,8 @@ import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
import org.onap.ccsdk.cds.controllerblueprints.core.service.DefaultBluePrintRuntimeService
-class ResourceAssignmentRuntimeService(private var id: String, private var bluePrintContext: BluePrintContext)
- : DefaultBluePrintRuntimeService(id, bluePrintContext) {
+class ResourceAssignmentRuntimeService(private var id: String, private var bluePrintContext: BluePrintContext) :
+ DefaultBluePrintRuntimeService(id, bluePrintContext) {
private lateinit var resolutionId: String
private var resourceStore: MutableMap<String, JsonNode> = hashMapOf()
@@ -25,7 +25,7 @@ class ResourceAssignmentRuntimeService(private var id: String, private var blueP
fun getResolutionStore(key: String): JsonNode {
return resourceStore[key]
- ?: throw BluePrintProcessorException("failed to get execution property ($key)")
+ ?: throw BluePrintProcessorException("failed to get execution property ($key)")
}
fun checkResolutionStore(key: String): Boolean {
@@ -58,7 +58,7 @@ class ResourceAssignmentRuntimeService(private var id: String, private var blueP
fun getDictionaryStore(key: String): JsonNode {
return resourceStore["dictionary-$key"]
- ?: throw BluePrintProcessorException("failed to get execution property (dictionary-$key)")
+ ?: throw BluePrintProcessorException("failed to get execution property (dictionary-$key)")
}
fun checkDictionaryStore(key: String): Boolean {
@@ -84,5 +84,4 @@ class ResourceAssignmentRuntimeService(private var id: String, private var blueP
fun getDoubleFromDictionaryStore(key: String): Double? {
return getResolutionStore("dictionary-$key").asDouble()
}
-
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceDefinitionDSL.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceDefinitionDSL.kt
index 141bad619..7c6ba603b 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceDefinitionDSL.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceDefinitionDSL.kt
@@ -24,32 +24,42 @@ import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition
/** Resource Definition DSL **/
-fun BluePrintTypes.resourceDefinitions(block: ResourceDefinitionsBuilder.() -> Unit)
- : MutableMap<String, ResourceDefinition> {
+fun BluePrintTypes.resourceDefinitions(block: ResourceDefinitionsBuilder.() -> Unit):
+ MutableMap<String, ResourceDefinition> {
return ResourceDefinitionsBuilder().apply(block).build()
}
-fun BluePrintTypes.resourceDefinition(name: String, description: String,
- block: ResourceDefinitionBuilder.() -> Unit): ResourceDefinition {
+fun BluePrintTypes.resourceDefinition(
+ name: String,
+ description: String,
+ block: ResourceDefinitionBuilder.() -> Unit
+): ResourceDefinition {
return ResourceDefinitionBuilder(name, description).apply(block).build()
}
/** Resource Mapping DSL **/
-fun BluePrintTypes.resourceAssignments(block: ResourceAssignmentsBuilder.() -> Unit)
- : MutableMap<String, ResourceAssignment> {
+fun BluePrintTypes.resourceAssignments(block: ResourceAssignmentsBuilder.() -> Unit):
+ MutableMap<String, ResourceAssignment> {
return ResourceAssignmentsBuilder().apply(block).build()
}
-fun BluePrintTypes.resourceAssignment(name: String, dictionaryName: String, dictionarySource: String,
- block: ResourceAssignmentBuilder.() -> Unit): ResourceAssignment {
+fun BluePrintTypes.resourceAssignment(
+ name: String,
+ dictionaryName: String,
+ dictionarySource: String,
+ block: ResourceAssignmentBuilder.() -> Unit
+): ResourceAssignment {
return ResourceAssignmentBuilder(name, dictionaryName, dictionarySource).apply(block).build()
}
class ResourceDefinitionsBuilder() {
private val resourceDefinitions: MutableMap<String, ResourceDefinition> = hashMapOf()
- fun resourceDefinition(name: String, description: String,
- block: ResourceDefinitionBuilder.() -> Unit) {
+ fun resourceDefinition(
+ name: String,
+ description: String,
+ block: ResourceDefinitionBuilder.() -> Unit
+ ) {
val resourceDefinition = ResourceDefinitionBuilder(name, description).apply(block).build()
resourceDefinitions[resourceDefinition.name] = resourceDefinition
}
@@ -82,8 +92,11 @@ class ResourceDefinitionBuilder(private val name: String, private val descriptio
resourceDefinition.property = PropertyDefinitionBuilder(name, type, required, description).build()
}
- fun property(type: String, required: Boolean,
- block: PropertyDefinitionBuilder.() -> Unit) {
+ fun property(
+ type: String,
+ required: Boolean,
+ block: PropertyDefinitionBuilder.() -> Unit
+ ) {
resourceDefinition.property = PropertyDefinitionBuilder(name, type, required, description).apply(block).build()
}
@@ -136,8 +149,12 @@ class ResourceDefinitionSourcesBuilder {
class ResourceAssignmentsBuilder() {
private val resourceAssignments: MutableMap<String, ResourceAssignment> = hashMapOf()
- fun resourceAssignment(name: String, dictionaryName: String, dictionarySource: String,
- block: ResourceAssignmentBuilder.() -> Unit) {
+ fun resourceAssignment(
+ name: String,
+ dictionaryName: String,
+ dictionarySource: String,
+ block: ResourceAssignmentBuilder.() -> Unit
+ ) {
val resourceAssignment = ResourceAssignmentBuilder(name, dictionaryName, dictionarySource).apply(block).build()
resourceAssignments[resourceAssignment.name] = resourceAssignment
}
@@ -151,8 +168,12 @@ class ResourceAssignmentsBuilder() {
}
}
-class ResourceAssignmentBuilder(private val name: String, private val dictionaryName: String,
- private val dictionarySource: String) {
+class ResourceAssignmentBuilder(
+ private val name: String,
+ private val dictionaryName: String,
+ private val dictionarySource: String
+) {
+
private val resourceAssignment = ResourceAssignment()
fun inputParameter(inputParameter: Boolean) {
@@ -163,8 +184,12 @@ class ResourceAssignmentBuilder(private val name: String, private val dictionary
resourceAssignment.property = PropertyDefinitionBuilder(name, type, required, description).build()
}
- fun property(type: String, required: Boolean, description: String? = "",
- block: PropertyDefinitionBuilder.() -> Unit) {
+ fun property(
+ type: String,
+ required: Boolean,
+ description: String? = "",
+ block: PropertyDefinitionBuilder.() -> Unit
+ ) {
resourceAssignment.property = PropertyDefinitionBuilder(name, type, required, description).apply(block).build()
}
@@ -174,27 +199,27 @@ class ResourceAssignmentBuilder(private val name: String, private val dictionary
fun sourceInput(block: SourceInputNodeTemplateBuilder.() -> Unit) {
resourceAssignment.dictionarySourceDefinition = SourceInputNodeTemplateBuilder(dictionarySource, "")
- .apply(block).build()
+ .apply(block).build()
}
fun sourceDefault(block: SourceDefaultNodeTemplateBuilder.() -> Unit) {
resourceAssignment.dictionarySourceDefinition = SourceDefaultNodeTemplateBuilder(dictionarySource, "")
- .apply(block).build()
+ .apply(block).build()
}
fun sourceDb(block: SourceDbNodeTemplateBuilder.() -> Unit) {
resourceAssignment.dictionarySourceDefinition = SourceDbNodeTemplateBuilder(dictionarySource, "")
- .apply(block).build()
+ .apply(block).build()
}
fun sourceRest(block: SourceRestNodeTemplateBuilder.() -> Unit) {
resourceAssignment.dictionarySourceDefinition = SourceRestNodeTemplateBuilder(dictionarySource, "")
- .apply(block).build()
+ .apply(block).build()
}
fun sourceCapability(block: SourceCapabilityNodeTemplateBuilder.() -> Unit) {
resourceAssignment.dictionarySourceDefinition = SourceCapabilityNodeTemplateBuilder(dictionarySource, "")
- .apply(block).build()
+ .apply(block).build()
}
fun dependencies(dependencies: MutableList<String>) {
@@ -207,4 +232,4 @@ class ResourceAssignmentBuilder(private val name: String, private val dictionary
resourceAssignment.dictionarySource = dictionarySource
return resourceAssignment
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt
index 0521919aa..293f29cfc 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt
@@ -32,8 +32,9 @@ import org.springframework.stereotype.Component
@Component("component-resource-resolution")
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
open class ResourceResolutionComponent(private val resourceResolutionService: ResourceResolutionService) :
- AbstractComponentFunction() {
- companion object{
+ AbstractComponentFunction() {
+
+ companion object {
const val INPUT_REQUEST_ID = "request-id"
const val INPUT_RESOURCE_ID = "resource-id"
const val INPUT_ACTION_NAME = "action-name"
@@ -54,11 +55,14 @@ open class ResourceResolutionComponent(private val resourceResolutionService: Re
override suspend fun processNB(executionRequest: ExecutionServiceInput) {
val occurrence = getOptionalOperationInput(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE)?.asInt() ?: 1
- val resolutionKey = getOptionalOperationInput(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOLUTION_KEY)?.returnNullIfMissing()?.textValue() ?: ""
+ val resolutionKey =
+ getOptionalOperationInput(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOLUTION_KEY)?.returnNullIfMissing()?.textValue() ?: ""
val storeResult = getOptionalOperationInput(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_STORE_RESULT)?.asBoolean() ?: false
- val resourceId = getOptionalOperationInput(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOURCE_ID)?.returnNullIfMissing()?.textValue() ?: ""
+ val resourceId =
+ getOptionalOperationInput(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOURCE_ID)?.returnNullIfMissing()?.textValue() ?: ""
- val resourceType = getOptionalOperationInput(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOURCE_TYPE)?.returnNullIfMissing()?.textValue() ?: ""
+ val resourceType =
+ getOptionalOperationInput(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOURCE_TYPE)?.returnNullIfMissing()?.textValue() ?: ""
val properties: MutableMap<String, Any> = mutableMapOf()
properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_STORE_RESULT] = storeResult
@@ -69,8 +73,10 @@ open class ResourceResolutionComponent(private val resourceResolutionService: Re
val jsonResponse = JsonNodeFactory.instance.objectNode()
// Initialize Output Attribute to empty JSON
- bluePrintRuntimeService.setNodeTemplateAttributeValue(nodeTemplateName,
- ResourceResolutionConstants.OUTPUT_ASSIGNMENT_PARAMS, jsonResponse)
+ bluePrintRuntimeService.setNodeTemplateAttributeValue(
+ nodeTemplateName,
+ ResourceResolutionConstants.OUTPUT_ASSIGNMENT_PARAMS, jsonResponse
+ )
// validate inputs if we need to store the resource and template resolution.
if (storeResult) {
@@ -79,8 +85,10 @@ open class ResourceResolutionComponent(private val resourceResolutionService: Re
} else if ((resourceType.isNotEmpty() && resourceId.isEmpty()) || (resourceType.isEmpty() && resourceId.isNotEmpty())) {
throw BluePrintProcessorException("Can't proceed with the resolution: both resource-id and resource-type should be provided, one of them is missing.")
} else if (resourceType.isEmpty() && resourceId.isEmpty() && resolutionKey.isEmpty()) {
- throw BluePrintProcessorException("Can't proceed with the resolution: can't persist resolution without a correlation key. " +
- "Either provide a resolution-key OR combination of resource-id and resource-type OR set `storeResult` to false.")
+ throw BluePrintProcessorException(
+ "Can't proceed with the resolution: can't persist resolution without a correlation key. " +
+ "Either provide a resolution-key OR combination of resource-id and resource-type OR set `storeResult` to false."
+ )
}
}
@@ -90,10 +98,12 @@ open class ResourceResolutionComponent(private val resourceResolutionService: Re
for (j in 1..occurrence) {
properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE] = j
- val response = resourceResolutionService.resolveResources(bluePrintRuntimeService,
- nodeTemplateName,
- artifactPrefixNames,
- properties)
+ val response = resourceResolutionService.resolveResources(
+ bluePrintRuntimeService,
+ nodeTemplateName,
+ artifactPrefixNames,
+ properties
+ )
// provide indexed result in output if we have multiple resolution
if (occurrence != 1) {
@@ -101,15 +111,16 @@ open class ResourceResolutionComponent(private val resourceResolutionService: Re
} else {
jsonResponse.setAll(response.asObjectNode())
}
-
}
// Set Output Attributes with resolved value
- bluePrintRuntimeService.setNodeTemplateAttributeValue(nodeTemplateName,
- ResourceResolutionConstants.OUTPUT_ASSIGNMENT_PARAMS, jsonResponse)
+ bluePrintRuntimeService.setNodeTemplateAttributeValue(
+ nodeTemplateName,
+ ResourceResolutionConstants.OUTPUT_ASSIGNMENT_PARAMS, jsonResponse
+ )
}
override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
bluePrintRuntimeService.getBluePrintError().addError(runtimeException.message!!)
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSL.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSL.kt
index 40ea47e33..25338c6ca 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSL.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSL.kt
@@ -17,81 +17,118 @@
package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution
import com.fasterxml.jackson.databind.JsonNode
-import org.onap.ccsdk.cds.controllerblueprints.core.*
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonString
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType
import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeTemplate
import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeType
import org.onap.ccsdk.cds.controllerblueprints.core.dsl.AbstractNodeTemplateOperationImplBuilder
import org.onap.ccsdk.cds.controllerblueprints.core.dsl.PropertiesAssignmentBuilder
import org.onap.ccsdk.cds.controllerblueprints.core.dsl.nodeType
+import org.onap.ccsdk.cds.controllerblueprints.core.jsonAsJsonType
/** Component Extensions **/
fun BluePrintTypes.nodeTypeComponentResourceResolution(): NodeType {
- return nodeType(id = "component-resource-resolution", version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
- derivedFrom = BluePrintConstants.MODEL_TYPE_NODE_COMPONENT,
- description = "Resource Assignment Component") {
-
- attribute(ResourceResolutionComponent.ATTRIBUTE_ASSIGNMENT_PARAM, BluePrintConstants.DATA_TYPE_STRING,
- true)
- attribute(ResourceResolutionComponent.ATTRIBUTE_STATUS, BluePrintConstants.DATA_TYPE_STRING,
- true)
+ return nodeType(
+ id = "component-resource-resolution", version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
+ derivedFrom = BluePrintConstants.MODEL_TYPE_NODE_COMPONENT,
+ description = "Resource Assignment Component"
+ ) {
+
+ attribute(
+ ResourceResolutionComponent.ATTRIBUTE_ASSIGNMENT_PARAM, BluePrintConstants.DATA_TYPE_STRING,
+ true
+ )
+ attribute(
+ ResourceResolutionComponent.ATTRIBUTE_STATUS, BluePrintConstants.DATA_TYPE_STRING,
+ true
+ )
operation("ResourceResolutionComponent", "ResourceResolutionComponent Operation") {
inputs {
- property(ResourceResolutionComponent.INPUT_REQUEST_ID, BluePrintConstants.DATA_TYPE_STRING,
- true, "Request Id, Unique Id for the request.")
-
- property(ResourceResolutionComponent.INPUT_RESOURCE_ID, BluePrintConstants.DATA_TYPE_STRING,
- false, "Resource Id.")
-
- property(ResourceResolutionComponent.INPUT_ACTION_NAME, BluePrintConstants.DATA_TYPE_STRING,
- false, "Action Name of the process")
-
- property(ResourceResolutionComponent.INPUT_DYNAMIC_PROPERTIES, BluePrintConstants.DATA_TYPE_JSON,
- false, "Dynamic Json Content or DSL Json reference.")
-
- property(ResourceResolutionComponent.INPUT_RESOLUTION_KEY, BluePrintConstants.DATA_TYPE_STRING,
- false, "Key for service instance related correlation.")
-
- property(ResourceResolutionComponent.INPUT_OCCURRENCE, BluePrintConstants.DATA_TYPE_INTEGER,
- false, "Number of time to perform the resolution.") {
+ property(
+ ResourceResolutionComponent.INPUT_REQUEST_ID, BluePrintConstants.DATA_TYPE_STRING,
+ true, "Request Id, Unique Id for the request."
+ )
+
+ property(
+ ResourceResolutionComponent.INPUT_RESOURCE_ID, BluePrintConstants.DATA_TYPE_STRING,
+ false, "Resource Id."
+ )
+
+ property(
+ ResourceResolutionComponent.INPUT_ACTION_NAME, BluePrintConstants.DATA_TYPE_STRING,
+ false, "Action Name of the process"
+ )
+
+ property(
+ ResourceResolutionComponent.INPUT_DYNAMIC_PROPERTIES, BluePrintConstants.DATA_TYPE_JSON,
+ false, "Dynamic Json Content or DSL Json reference."
+ )
+
+ property(
+ ResourceResolutionComponent.INPUT_RESOLUTION_KEY, BluePrintConstants.DATA_TYPE_STRING,
+ false, "Key for service instance related correlation."
+ )
+
+ property(
+ ResourceResolutionComponent.INPUT_OCCURRENCE, BluePrintConstants.DATA_TYPE_INTEGER,
+ false, "Number of time to perform the resolution."
+ ) {
defaultValue(1)
}
- property(ResourceResolutionComponent.INPUT_STORE_RESULT, BluePrintConstants.DATA_TYPE_BOOLEAN,
- false, "Whether or not to store the output.")
+ property(
+ ResourceResolutionComponent.INPUT_STORE_RESULT, BluePrintConstants.DATA_TYPE_BOOLEAN,
+ false, "Whether or not to store the output."
+ )
- property(ResourceResolutionComponent.INPUT_RESOURCE_TYPE, BluePrintConstants.DATA_TYPE_STRING,
- false, "Request type.")
+ property(
+ ResourceResolutionComponent.INPUT_RESOURCE_TYPE, BluePrintConstants.DATA_TYPE_STRING,
+ false, "Request type."
+ )
- property(ResourceResolutionComponent.INPUT_ARTIFACT_PREFIX_NAMES, BluePrintConstants.DATA_TYPE_LIST,
- true, "Template , Resource Assignment Artifact Prefix names") {
+ property(
+ ResourceResolutionComponent.INPUT_ARTIFACT_PREFIX_NAMES, BluePrintConstants.DATA_TYPE_LIST,
+ true, "Template , Resource Assignment Artifact Prefix names"
+ ) {
entrySchema(BluePrintConstants.DATA_TYPE_STRING)
}
}
outputs {
- property(ResourceResolutionComponent.OUTPUT_RESOURCE_ASSIGNMENT_PARAMS, BluePrintConstants.DATA_TYPE_STRING,
- true, "Output Response")
- property(ResourceResolutionComponent.OUTPUT_STATUS, BluePrintConstants.DATA_TYPE_STRING,
- true, "Status of the Component Execution ( success or failure )")
+ property(
+ ResourceResolutionComponent.OUTPUT_RESOURCE_ASSIGNMENT_PARAMS, BluePrintConstants.DATA_TYPE_STRING,
+ true, "Output Response"
+ )
+ property(
+ ResourceResolutionComponent.OUTPUT_STATUS, BluePrintConstants.DATA_TYPE_STRING,
+ true, "Status of the Component Execution ( success or failure )"
+ )
}
}
}
}
/** Component Builder */
-fun BluePrintTypes.nodeTemplateComponentResourceResolution(id: String,
- description: String,
- block: ComponentResourceResolutionNodeTemplateBuilder.() -> Unit)
- : NodeTemplate {
+fun BluePrintTypes.nodeTemplateComponentResourceResolution(
+ id: String,
+ description: String,
+ block: ComponentResourceResolutionNodeTemplateBuilder.() -> Unit
+):
+ NodeTemplate {
return ComponentResourceResolutionNodeTemplateBuilder(id, description).apply(block).build()
}
class ComponentResourceResolutionNodeTemplateBuilder(id: String, description: String) :
- AbstractNodeTemplateOperationImplBuilder<PropertiesAssignmentBuilder,
- ComponentResourceResolutionNodeTemplateBuilder.InputsBuilder,
- ComponentResourceResolutionNodeTemplateBuilder.OutputsBuilder>(id, "component-script-executor",
- "ComponentResourceResolution",
- description) {
+ AbstractNodeTemplateOperationImplBuilder<PropertiesAssignmentBuilder,
+ ComponentResourceResolutionNodeTemplateBuilder.InputsBuilder,
+ ComponentResourceResolutionNodeTemplateBuilder.OutputsBuilder>(
+ id, "component-script-executor",
+ "ComponentResourceResolution",
+ description
+ ) {
class InputsBuilder : PropertiesAssignmentBuilder() {
@@ -146,7 +183,7 @@ class ComponentResourceResolutionNodeTemplateBuilder(id: String, description: St
fun artifactPrefixNames(artifactPrefixNames: String) = artifactPrefixNames(artifactPrefixNames.jsonAsJsonType())
fun artifactPrefixNames(artifactPrefixNameList: List<String>) =
- artifactPrefixNames(artifactPrefixNameList.asJsonString())
+ artifactPrefixNames(artifactPrefixNameList.asJsonString())
fun artifactPrefixNames(artifactPrefixNames: JsonNode) {
property(ResourceResolutionComponent.INPUT_ARTIFACT_PREFIX_NAMES, artifactPrefixNames)
@@ -162,10 +199,10 @@ class ComponentResourceResolutionNodeTemplateBuilder(id: String, description: St
}
fun resourceAssignmentParams(resourceAssignmentParams: String) =
- resourceAssignmentParams(resourceAssignmentParams.asJsonType())
+ resourceAssignmentParams(resourceAssignmentParams.asJsonType())
fun resourceAssignmentParams(resourceAssignmentParams: JsonNode) {
property(ResourceResolutionComponent.OUTPUT_RESOURCE_ASSIGNMENT_PARAMS, resourceAssignmentParams)
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConfiguration.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConfiguration.kt
index 13ff0a73f..219040e6b 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConfiguration.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConfiguration.kt
@@ -22,5 +22,3 @@ import org.springframework.context.annotation.Configuration
@Configuration
@ComponentScan
open class ResourceResolutionConfiguration
-
-
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt
index 537074383..0726d2871 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt
@@ -19,15 +19,15 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution
object ResourceResolutionConstants {
- const val SERVICE_RESOURCE_RESOLUTION = "resource-resolution-service"
- const val PREFIX_RESOURCE_RESOLUTION_PROCESSOR = "rr-processor-"
- const val INPUT_ARTIFACT_PREFIX_NAMES = "artifact-prefix-names"
- const val OUTPUT_ASSIGNMENT_PARAMS = "assignment-params"
- const val FILE_NAME_RESOURCE_DEFINITION_TYPES = "resources_definition_types.json"
- const val RESOURCE_RESOLUTION_INPUT_RESOLUTION_KEY = "resolution-key"
- const val RESOURCE_RESOLUTION_INPUT_STORE_RESULT = "store-result"
- const val RESOURCE_RESOLUTION_INPUT_OCCURRENCE = "occurrence"
- const val RESOURCE_RESOLUTION_INPUT_RESOURCE_ID = "resource-id"
- const val RESOURCE_RESOLUTION_INPUT_RESOURCE_TYPE = "resource-type"
- const val RESOURCE_RESOLUTION_LOG_PROTECTED_METADATA = "log-protect"
-} \ No newline at end of file
+ const val SERVICE_RESOURCE_RESOLUTION = "resource-resolution-service"
+ const val PREFIX_RESOURCE_RESOLUTION_PROCESSOR = "rr-processor-"
+ const val INPUT_ARTIFACT_PREFIX_NAMES = "artifact-prefix-names"
+ const val OUTPUT_ASSIGNMENT_PARAMS = "assignment-params"
+ const val FILE_NAME_RESOURCE_DEFINITION_TYPES = "resources_definition_types.json"
+ const val RESOURCE_RESOLUTION_INPUT_RESOLUTION_KEY = "resolution-key"
+ const val RESOURCE_RESOLUTION_INPUT_STORE_RESULT = "store-result"
+ const val RESOURCE_RESOLUTION_INPUT_OCCURRENCE = "occurrence"
+ const val RESOURCE_RESOLUTION_INPUT_RESOURCE_ID = "resource-id"
+ const val RESOURCE_RESOLUTION_INPUT_RESOURCE_TYPE = "resource-type"
+ const val RESOURCE_RESOLUTION_LOG_PROTECTED_METADATA = "log-protect"
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionExtensions.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionExtensions.kt
index ab01b15b7..53ce65d0b 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionExtensions.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionExtensions.kt
@@ -20,18 +20,18 @@ import kotlinx.coroutines.runBlocking
import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractComponentFunction
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintDependencyService
-
/**
* Register the Resolution module exposed dependency
*/
fun BluePrintDependencyService.resourceResolutionService(): ResourceResolutionService =
- instance(ResourceResolutionConstants.SERVICE_RESOURCE_RESOLUTION)
-
+ instance(ResourceResolutionConstants.SERVICE_RESOURCE_RESOLUTION)
-suspend fun AbstractComponentFunction.storedContentFromResolvedArtifactNB(resolutionKey: String,
- artifactName: String): String {
+suspend fun AbstractComponentFunction.storedContentFromResolvedArtifactNB(
+ resolutionKey: String,
+ artifactName: String
+): String {
return BluePrintDependencyService.resourceResolutionService()
- .resolveFromDatabase(bluePrintRuntimeService, artifactName, resolutionKey)
+ .resolveFromDatabase(bluePrintRuntimeService, artifactName, resolutionKey)
}
/**
@@ -39,16 +39,15 @@ suspend fun AbstractComponentFunction.storedContentFromResolvedArtifactNB(resolu
*/
suspend fun AbstractComponentFunction.contentFromResolvedArtifactNB(artifactPrefix: String): String {
return BluePrintDependencyService.resourceResolutionService()
- .resolveResources(bluePrintRuntimeService, nodeTemplateName, artifactPrefix, mapOf())
+ .resolveResources(bluePrintRuntimeService, nodeTemplateName, artifactPrefix, mapOf())
}
-
/**
* Blocking Methods called from Jython Scripts
*/
-fun AbstractComponentFunction.storedContentFromResolvedArtifact(resolutionKey: String, artifactName: String)
- : String = runBlocking {
+fun AbstractComponentFunction.storedContentFromResolvedArtifact(resolutionKey: String, artifactName: String):
+ String = runBlocking {
storedContentFromResolvedArtifactNB(resolutionKey, artifactName)
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt
index 28e7d395a..14e60bc95 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt
@@ -27,7 +27,11 @@ import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.db.T
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.ResourceAssignmentProcessor
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.utils.ResourceDefinitionUtils.createResourceAssignments
-import org.onap.ccsdk.cds.controllerblueprints.core.*
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType
+import org.onap.ccsdk.cds.controllerblueprints.core.checkNotEmpty
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintTemplateService
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
@@ -37,80 +41,109 @@ import org.onap.ccsdk.cds.controllerblueprints.resource.dict.utils.BulkResourceS
import org.slf4j.LoggerFactory
import org.springframework.context.ApplicationContext
import org.springframework.stereotype.Service
-import java.util.*
+import java.util.UUID
interface ResourceResolutionService {
fun registeredResourceSources(): List<String>
- suspend fun resolveFromDatabase(bluePrintRuntimeService: BluePrintRuntimeService<*>, artifactTemplate: String,
- resolutionKey: String): String
-
- suspend fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
- artifactNames: List<String>, properties: Map<String, Any>): MutableMap<String, String>
-
- suspend fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
- artifactPrefix: String, properties: Map<String, Any>): String
+ suspend fun resolveFromDatabase(
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ artifactTemplate: String,
+ resolutionKey: String
+ ): String
+
+ suspend fun resolveResources(
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ nodeTemplateName: String,
+ artifactNames: List<String>,
+ properties: Map<String, Any>
+ ): MutableMap<String, String>
+
+ suspend fun resolveResources(
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ nodeTemplateName: String,
+ artifactPrefix: String,
+ properties: Map<String, Any>
+ ): String
/** Resolve resources for all the sources defined in a particular resource Definition[resolveDefinition]
* with other [resourceDefinitions] dependencies for the sources [sources]
* Used to get the same resource values from multiple sources. **/
- suspend fun resolveResourceDefinition(blueprintRuntimeService: BluePrintRuntimeService<*>,
- resourceDefinitions: MutableMap<String, ResourceDefinition>,
- resolveDefinition: String, sources: List<String>)
- : MutableMap<String, JsonNode>
-
- suspend fun resolveResourceAssignments(blueprintRuntimeService: BluePrintRuntimeService<*>,
- resourceDefinitions: MutableMap<String, ResourceDefinition>,
- resourceAssignments: MutableList<ResourceAssignment>,
- artifactPrefix: String,
- properties: Map<String, Any>)
+ suspend fun resolveResourceDefinition(
+ blueprintRuntimeService: BluePrintRuntimeService<*>,
+ resourceDefinitions: MutableMap<String, ResourceDefinition>,
+ resolveDefinition: String,
+ sources: List<String>
+ ):
+ MutableMap<String, JsonNode>
+
+ suspend fun resolveResourceAssignments(
+ blueprintRuntimeService: BluePrintRuntimeService<*>,
+ resourceDefinitions: MutableMap<String, ResourceDefinition>,
+ resourceAssignments: MutableList<ResourceAssignment>,
+ artifactPrefix: String,
+ properties: Map<String, Any>
+ )
}
@Service(ResourceResolutionConstants.SERVICE_RESOURCE_RESOLUTION)
-open class ResourceResolutionServiceImpl(private var applicationContext: ApplicationContext,
- private var templateResolutionDBService: TemplateResolutionService,
- private var blueprintTemplateService: BluePrintTemplateService,
- private var resourceResolutionDBService: ResourceResolutionDBService) :
- ResourceResolutionService {
+open class ResourceResolutionServiceImpl(
+ private var applicationContext: ApplicationContext,
+ private var templateResolutionDBService: TemplateResolutionService,
+ private var blueprintTemplateService: BluePrintTemplateService,
+ private var resourceResolutionDBService: ResourceResolutionDBService
+) :
+ ResourceResolutionService {
private val log = LoggerFactory.getLogger(ResourceResolutionService::class.java)
override fun registeredResourceSources(): List<String> {
return applicationContext.getBeanNamesForType(ResourceAssignmentProcessor::class.java)
- .filter { it.startsWith(ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR) }
- .map { it.substringAfter(ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR) }
+ .filter { it.startsWith(ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR) }
+ .map { it.substringAfter(ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR) }
}
- override suspend fun resolveFromDatabase(bluePrintRuntimeService: BluePrintRuntimeService<*>,
- artifactTemplate: String,
- resolutionKey: String): String {
+ override suspend fun resolveFromDatabase(
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ artifactTemplate: String,
+ resolutionKey: String
+ ): String {
return templateResolutionDBService.findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactName(
- bluePrintRuntimeService,
- artifactTemplate,
- resolutionKey)
+ bluePrintRuntimeService,
+ artifactTemplate,
+ resolutionKey
+ )
}
- override suspend fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
- artifactNames: List<String>,
- properties: Map<String, Any>): MutableMap<String, String> {
+ override suspend fun resolveResources(
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ nodeTemplateName: String,
+ artifactNames: List<String>,
+ properties: Map<String, Any>
+ ): MutableMap<String, String> {
val resourceAssignmentRuntimeService =
- ResourceAssignmentUtils.transformToRARuntimeService(bluePrintRuntimeService, artifactNames.toString())
+ ResourceAssignmentUtils.transformToRARuntimeService(bluePrintRuntimeService, artifactNames.toString())
val resolvedParams: MutableMap<String, String> = hashMapOf()
artifactNames.forEach { artifactName ->
- val resolvedContent = resolveResources(resourceAssignmentRuntimeService, nodeTemplateName,
- artifactName, properties)
+ val resolvedContent = resolveResources(
+ resourceAssignmentRuntimeService, nodeTemplateName,
+ artifactName, properties
+ )
resolvedParams[artifactName] = resolvedContent
}
return resolvedParams
}
-
- override suspend fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
- artifactPrefix: String, properties: Map<String, Any>): String {
+ override suspend fun resolveResources(
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ nodeTemplateName: String,
+ artifactPrefix: String,
+ properties: Map<String, Any>
+ ): String {
// Velocity Artifact Definition Name
val artifactTemplate = "$artifactPrefix-template"
@@ -121,39 +154,47 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
log.info("Resolving resource for template artifact($artifactTemplate) with resource assignment artifact($artifactMapping)")
val resourceAssignmentContent =
- bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, artifactMapping)
+ bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, artifactMapping)
val resourceAssignments: MutableList<ResourceAssignment> =
- JacksonUtils.getListFromJson(resourceAssignmentContent, ResourceAssignment::class.java)
- as? MutableList<ResourceAssignment>
- ?: throw BluePrintProcessorException("couldn't get Dictionary Definitions")
+ JacksonUtils.getListFromJson(resourceAssignmentContent, ResourceAssignment::class.java)
+ as? MutableList<ResourceAssignment>
+ ?: throw BluePrintProcessorException("couldn't get Dictionary Definitions")
if (isToStore(properties)) {
val existingResourceResolution = isNewResolution(bluePrintRuntimeService, properties, artifactPrefix)
if (existingResourceResolution.isNotEmpty()) {
- updateResourceAssignmentWithExisting(bluePrintRuntimeService as ResourceAssignmentRuntimeService,
- existingResourceResolution, resourceAssignments)
+ updateResourceAssignmentWithExisting(
+ bluePrintRuntimeService as ResourceAssignmentRuntimeService,
+ existingResourceResolution, resourceAssignments
+ )
}
}
// Get the Resource Dictionary Name
val resourceDefinitions: MutableMap<String, ResourceDefinition> = ResourceAssignmentUtils
- .resourceDefinitions(bluePrintRuntimeService.bluePrintContext().rootPath)
+ .resourceDefinitions(bluePrintRuntimeService.bluePrintContext().rootPath)
// Resolve resources
- resolveResourceAssignments(bluePrintRuntimeService,
- resourceDefinitions,
- resourceAssignments,
- artifactPrefix,
- properties)
+ resolveResourceAssignments(
+ bluePrintRuntimeService,
+ resourceDefinitions,
+ resourceAssignments,
+ artifactPrefix,
+ properties
+ )
val resolvedParamJsonContent =
- ResourceAssignmentUtils.generateResourceDataForAssignments(resourceAssignments.toList())
+ ResourceAssignmentUtils.generateResourceDataForAssignments(resourceAssignments.toList())
- resolvedContent = blueprintTemplateService.generateContent(bluePrintRuntimeService, nodeTemplateName,
- artifactTemplate, resolvedParamJsonContent, false,
- mutableMapOf(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE to
- properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE].asJsonPrimitive()))
+ resolvedContent = blueprintTemplateService.generateContent(
+ bluePrintRuntimeService, nodeTemplateName,
+ artifactTemplate, resolvedParamJsonContent, false,
+ mutableMapOf(
+ ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE to
+ properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE].asJsonPrimitive()
+ )
+ )
if (isToStore(properties)) {
templateResolutionDBService.write(properties, resolvedContent, bluePrintRuntimeService, artifactPrefix)
@@ -163,16 +204,21 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
return resolvedContent
}
- override suspend fun resolveResourceDefinition(blueprintRuntimeService: BluePrintRuntimeService<*>,
- resourceDefinitions: MutableMap<String, ResourceDefinition>,
- resolveDefinition: String, sources: List<String>)
- : MutableMap<String, JsonNode> {
+ override suspend fun resolveResourceDefinition(
+ blueprintRuntimeService: BluePrintRuntimeService<*>,
+ resourceDefinitions: MutableMap<String, ResourceDefinition>,
+ resolveDefinition: String,
+ sources: List<String>
+ ):
+ MutableMap<String, JsonNode> {
// Populate Dummy Resource Assignments
val resourceAssignments = createResourceAssignments(resourceDefinitions, resolveDefinition, sources)
- resolveResourceAssignments(blueprintRuntimeService, resourceDefinitions, resourceAssignments,
- UUID.randomUUID().toString(), hashMapOf())
+ resolveResourceAssignments(
+ blueprintRuntimeService, resourceDefinitions, resourceAssignments,
+ UUID.randomUUID().toString(), hashMapOf()
+ )
// Get the data from Resource Assignments
return ResourceAssignmentUtils.generateResourceForAssignments(resourceAssignments)
@@ -183,11 +229,13 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
* name, then get the type of the Resource Definition, Get the instance for the Resource Type and process the
* request.
*/
- override suspend fun resolveResourceAssignments(blueprintRuntimeService: BluePrintRuntimeService<*>,
- resourceDefinitions: MutableMap<String, ResourceDefinition>,
- resourceAssignments: MutableList<ResourceAssignment>,
- artifactPrefix: String,
- properties: Map<String, Any>) {
+ override suspend fun resolveResourceAssignments(
+ blueprintRuntimeService: BluePrintRuntimeService<*>,
+ resourceDefinitions: MutableMap<String, ResourceDefinition>,
+ resourceAssignments: MutableList<ResourceAssignment>,
+ artifactPrefix: String,
+ properties: Map<String, Any>
+ ) {
val bulkSequenced = BulkResourceSequencingUtils.process(resourceAssignments)
@@ -204,56 +252,62 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
bulkSequenced.forEach { batchResourceAssignments ->
// Execute Non Dependent Assignments in parallel ( ie asynchronously )
val deferred = batchResourceAssignments
- .filter { it.name != "*" && it.name != "start" }
- .filter { it.status != BluePrintConstants.STATUS_SUCCESS }
- .map { resourceAssignment ->
- async {
- val dictionaryName = resourceAssignment.dictionaryName
- val dictionarySource = resourceAssignment.dictionarySource
-
- val processorName = processorName(dictionaryName!!, dictionarySource!!, resourceDefinitions)
-
- val resourceAssignmentProcessor =
- applicationContext.getBean(processorName) as? ResourceAssignmentProcessor
- ?: throw BluePrintProcessorException("failed to get resource processor ($processorName) " +
- "for resource assignment(${resourceAssignment.name})")
- try {
- // Set BluePrint Runtime Service
- resourceAssignmentProcessor.raRuntimeService = resourceAssignmentRuntimeService
- // Set Resource Dictionaries
- resourceAssignmentProcessor.resourceDictionaries = resourceDefinitions
- // Invoke Apply Method
- resourceAssignmentProcessor.applyNB(resourceAssignment)
-
- if (isToStore(properties)) {
- resourceResolutionDBService.write(properties,
- blueprintRuntimeService,
- artifactPrefix,
- resourceAssignment)
- log.info("Resource resolution saved into database successfully : (${resourceAssignment.name})")
- }
-
- // Set errors from RA
- blueprintRuntimeService.setBluePrintError(resourceAssignmentRuntimeService.getBluePrintError())
- } catch (e: RuntimeException) {
- log.error("Fail in processing ${resourceAssignment.name}", e)
- throw BluePrintProcessorException(e)
+ .filter { it.name != "*" && it.name != "start" }
+ .filter { it.status != BluePrintConstants.STATUS_SUCCESS }
+ .map { resourceAssignment ->
+ async {
+ val dictionaryName = resourceAssignment.dictionaryName
+ val dictionarySource = resourceAssignment.dictionarySource
+
+ val processorName = processorName(dictionaryName!!, dictionarySource!!, resourceDefinitions)
+
+ val resourceAssignmentProcessor =
+ applicationContext.getBean(processorName) as? ResourceAssignmentProcessor
+ ?: throw BluePrintProcessorException(
+ "failed to get resource processor ($processorName) " +
+ "for resource assignment(${resourceAssignment.name})"
+ )
+ try {
+ // Set BluePrint Runtime Service
+ resourceAssignmentProcessor.raRuntimeService = resourceAssignmentRuntimeService
+ // Set Resource Dictionaries
+ resourceAssignmentProcessor.resourceDictionaries = resourceDefinitions
+ // Invoke Apply Method
+ resourceAssignmentProcessor.applyNB(resourceAssignment)
+
+ if (isToStore(properties)) {
+ resourceResolutionDBService.write(
+ properties,
+ blueprintRuntimeService,
+ artifactPrefix,
+ resourceAssignment
+ )
+ log.info("Resource resolution saved into database successfully : (${resourceAssignment.name})")
}
+
+ // Set errors from RA
+ blueprintRuntimeService.setBluePrintError(resourceAssignmentRuntimeService.getBluePrintError())
+ } catch (e: RuntimeException) {
+ log.error("Fail in processing ${resourceAssignment.name}", e)
+ throw BluePrintProcessorException(e)
}
}
+ }
log.debug("Resolving (${deferred.size})resources parallel.")
deferred.awaitAll()
}
}
-
}
/**
* If the Source instance is "input", then it is not mandatory to have source Resource Definition, So it can
* derive the default input processor.
*/
- private fun processorName(dictionaryName: String, dictionarySource: String,
- resourceDefinitions: MutableMap<String, ResourceDefinition>): String {
+ private fun processorName(
+ dictionaryName: String,
+ dictionarySource: String,
+ resourceDefinitions: MutableMap<String, ResourceDefinition>
+ ): String {
val processorName: String = when (dictionarySource) {
"input" -> {
"${ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR}source-input"
@@ -263,10 +317,10 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
}
else -> {
val resourceDefinition = resourceDefinitions[dictionaryName]
- ?: throw BluePrintProcessorException("couldn't get resource dictionary definition for $dictionaryName")
+ ?: throw BluePrintProcessorException("couldn't get resource dictionary definition for $dictionaryName")
val resourceSource = resourceDefinition.sources[dictionarySource]
- ?: throw BluePrintProcessorException("couldn't get resource definition $dictionaryName source($dictionarySource)")
+ ?: throw BluePrintProcessorException("couldn't get resource definition $dictionaryName source($dictionarySource)")
ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR.plus(resourceSource.type)
}
@@ -276,19 +330,20 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
}
return processorName
-
}
// Check whether to store or not the resolution of resource and template
private fun isToStore(properties: Map<String, Any>): Boolean {
- return properties.containsKey(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_STORE_RESULT)
- && properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_STORE_RESULT] as Boolean
+ return properties.containsKey(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_STORE_RESULT) &&
+ properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_STORE_RESULT] as Boolean
}
// Check whether resolution already exist in the database for the specified resolution-key or resourceId/resourceType
- private suspend fun isNewResolution(bluePrintRuntimeService: BluePrintRuntimeService<*>,
- properties: Map<String, Any>,
- artifactPrefix: String): List<ResourceResolution> {
+ private suspend fun isNewResolution(
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ properties: Map<String, Any>,
+ artifactPrefix: String
+ ): List<ResourceResolution> {
val occurrence = properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE] as Int
val resolutionKey = properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOLUTION_KEY] as String
val resourceId = properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOURCE_ID] as String
@@ -296,28 +351,34 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
if (resolutionKey.isNotEmpty()) {
val existingResourceAssignments =
- resourceResolutionDBService.findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKeyAndOccurrence(
- bluePrintRuntimeService,
- resolutionKey,
- occurrence,
- artifactPrefix)
+ resourceResolutionDBService.findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKeyAndOccurrence(
+ bluePrintRuntimeService,
+ resolutionKey,
+ occurrence,
+ artifactPrefix
+ )
if (existingResourceAssignments.isNotEmpty()) {
- log.info("Resolution with resolutionKey=($resolutionKey) already exist - will resolve all resources not already resolved.",
- resolutionKey)
+ log.info(
+ "Resolution with resolutionKey=($resolutionKey) already exist - will resolve all resources not already resolved.",
+ resolutionKey
+ )
}
return existingResourceAssignments
} else if (resourceId.isNotEmpty() && resourceType.isNotEmpty()) {
val existingResourceAssignments =
- resourceResolutionDBService.findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResourceIdAndResourceTypeAndOccurrence(
- bluePrintRuntimeService,
- resourceId,
- resourceType,
-
- occurrence,
- artifactPrefix)
+ resourceResolutionDBService.findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResourceIdAndResourceTypeAndOccurrence(
+ bluePrintRuntimeService,
+ resourceId,
+ resourceType,
+
+ occurrence,
+ artifactPrefix
+ )
if (existingResourceAssignments.isNotEmpty()) {
- log.info("Resolution with resourceId=($resourceId) and resourceType=($resourceType) already exist - will resolve " +
- "all resources not already resolved.")
+ log.info(
+ "Resolution with resourceId=($resourceId) and resourceType=($resourceType) already exist - will resolve " +
+ "all resources not already resolved."
+ )
}
return existingResourceAssignments
}
@@ -325,9 +386,11 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
}
// Update the resource assignment list with the status of the resource that have already been resolved
- private fun updateResourceAssignmentWithExisting(raRuntimeService : ResourceAssignmentRuntimeService,
- resourceResolutionList: List<ResourceResolution>,
- resourceAssignmentList: MutableList<ResourceAssignment>) {
+ private fun updateResourceAssignmentWithExisting(
+ raRuntimeService: ResourceAssignmentRuntimeService,
+ resourceResolutionList: List<ResourceResolution>,
+ resourceAssignmentList: MutableList<ResourceAssignment>
+ ) {
resourceResolutionList.forEach { resourceResolution ->
if (resourceResolution.status == BluePrintConstants.STATUS_SUCCESS) {
resourceAssignmentList.forEach {
@@ -347,15 +410,19 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
// Comparision between what we have in the database vs what we have to assign.
private fun compareOne(resourceResolution: ResourceResolution, resourceAssignment: ResourceAssignment): Boolean {
- return (resourceResolution.name == resourceAssignment.name
- && resourceResolution.dictionaryName == resourceAssignment.dictionaryName
- && resourceResolution.dictionarySource == resourceAssignment.dictionarySource
- && resourceResolution.dictionaryVersion == resourceAssignment.version)
+ return (resourceResolution.name == resourceAssignment.name &&
+ resourceResolution.dictionaryName == resourceAssignment.dictionaryName &&
+ resourceResolution.dictionarySource == resourceAssignment.dictionarySource &&
+ resourceResolution.dictionaryVersion == resourceAssignment.version)
}
- private fun exposeOccurrencePropertyInResourceAssignments(raRuntimeService: ResourceAssignmentRuntimeService,
- properties: Map<String, Any>) {
- raRuntimeService.putResolutionStore(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE,
- properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE].asJsonPrimitive())
+ private fun exposeOccurrencePropertyInResourceAssignments(
+ raRuntimeService: ResourceAssignmentRuntimeService,
+ properties: Map<String, Any>
+ ) {
+ raRuntimeService.putResolutionStore(
+ ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE,
+ properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE].asJsonPrimitive()
+ )
}
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceDSL.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceDSL.kt
index 182f3a178..d541fe60c 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceDSL.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceDSL.kt
@@ -18,7 +18,11 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution
import com.fasterxml.jackson.databind.JsonNode
import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ComponentScriptExecutor
-import org.onap.ccsdk.cds.controllerblueprints.core.*
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonString
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType
import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeTemplate
import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeType
import org.onap.ccsdk.cds.controllerblueprints.core.dsl.AbstractNodeTemplatePropertyImplBuilder
@@ -27,149 +31,220 @@ import org.onap.ccsdk.cds.controllerblueprints.core.dsl.nodeType
import kotlin.reflect.KClass
fun BluePrintTypes.nodeTypeSourceInput(): NodeType {
- return nodeType(id = "source-input", version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
- derivedFrom = BluePrintConstants.MODEL_TYPE_NODE_RESOURCE_SOURCE,
- description = "This is Input Resource Source Node Type") {}
+ return nodeType(
+ id = "source-input", version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
+ derivedFrom = BluePrintConstants.MODEL_TYPE_NODE_RESOURCE_SOURCE,
+ description = "This is Input Resource Source Node Type"
+ ) {}
}
fun BluePrintTypes.nodeTypeSourceDefault(): NodeType {
- return nodeType(id = "source-default", version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
- derivedFrom = BluePrintConstants.MODEL_TYPE_NODE_RESOURCE_SOURCE,
- description = "This is Default Resource Source Node Type") {}
+ return nodeType(
+ id = "source-default", version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
+ derivedFrom = BluePrintConstants.MODEL_TYPE_NODE_RESOURCE_SOURCE,
+ description = "This is Default Resource Source Node Type"
+ ) {}
}
fun BluePrintTypes.nodeTypeSourceDb(): NodeType {
- return nodeType(id = "source-db", version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
- derivedFrom = BluePrintConstants.MODEL_TYPE_NODE_RESOURCE_SOURCE,
- description = "This is Database Resource Source Node Type") {
- property("type", BluePrintConstants.DATA_TYPE_STRING,
- true, "") {
+ return nodeType(
+ id = "source-db", version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
+ derivedFrom = BluePrintConstants.MODEL_TYPE_NODE_RESOURCE_SOURCE,
+ description = "This is Database Resource Source Node Type"
+ ) {
+ property(
+ "type", BluePrintConstants.DATA_TYPE_STRING,
+ true, ""
+ ) {
defaultValue("SQL".asJsonPrimitive())
constrain {
validValues(arrayListOf("SQL".asJsonPrimitive(), "PLSQL".asJsonPrimitive()))
}
}
- property("endpoint-selector", BluePrintConstants.DATA_TYPE_STRING,
- false, "")
- property("query", BluePrintConstants.DATA_TYPE_STRING,
- true, "")
- property("input-key-mapping", BluePrintConstants.DATA_TYPE_MAP,
- true, "") {
+ property(
+ "endpoint-selector", BluePrintConstants.DATA_TYPE_STRING,
+ false, ""
+ )
+ property(
+ "query", BluePrintConstants.DATA_TYPE_STRING,
+ true, ""
+ )
+ property(
+ "input-key-mapping", BluePrintConstants.DATA_TYPE_MAP,
+ true, ""
+ ) {
entrySchema(BluePrintConstants.DATA_TYPE_STRING)
}
- property("output-key-mapping", BluePrintConstants.DATA_TYPE_MAP,
- false, "") {
+ property(
+ "output-key-mapping", BluePrintConstants.DATA_TYPE_MAP,
+ false, ""
+ ) {
entrySchema(BluePrintConstants.DATA_TYPE_STRING)
}
- property("key-dependencies", BluePrintConstants.DATA_TYPE_LIST,
- true, "Resource Resolution dependency dictionary names.") {
+ property(
+ "key-dependencies", BluePrintConstants.DATA_TYPE_LIST,
+ true, "Resource Resolution dependency dictionary names."
+ ) {
entrySchema(BluePrintConstants.DATA_TYPE_STRING)
}
}
}
fun BluePrintTypes.nodeTypeSourceRest(): NodeType {
- return nodeType(id = "source-rest", version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
- derivedFrom = BluePrintConstants.MODEL_TYPE_NODE_RESOURCE_SOURCE,
- description = "This is Rest Resource Source Node Type") {
- property("type", BluePrintConstants.DATA_TYPE_STRING,
- true, "") {
+ return nodeType(
+ id = "source-rest", version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
+ derivedFrom = BluePrintConstants.MODEL_TYPE_NODE_RESOURCE_SOURCE,
+ description = "This is Rest Resource Source Node Type"
+ ) {
+ property(
+ "type", BluePrintConstants.DATA_TYPE_STRING,
+ true, ""
+ ) {
defaultValue("JSON".asJsonPrimitive())
constrain {
validValues(arrayListOf("JSON".asJsonPrimitive(), "XML".asJsonPrimitive()))
}
}
- property("verb", BluePrintConstants.DATA_TYPE_STRING,
- true, "") {
+ property(
+ "verb", BluePrintConstants.DATA_TYPE_STRING,
+ true, ""
+ ) {
defaultValue("GET".asJsonPrimitive())
constrain {
- validValues(arrayListOf("GET".asJsonPrimitive(), "POST".asJsonPrimitive(),
- "DELETE".asJsonPrimitive(), "PUT".asJsonPrimitive()))
+ validValues(
+ arrayListOf(
+ "GET".asJsonPrimitive(), "POST".asJsonPrimitive(),
+ "DELETE".asJsonPrimitive(), "PUT".asJsonPrimitive()
+ )
+ )
}
}
- property("payload", BluePrintConstants.DATA_TYPE_STRING,
- false, "") {
+ property(
+ "payload", BluePrintConstants.DATA_TYPE_STRING,
+ false, ""
+ ) {
defaultValue("".asJsonPrimitive())
}
- property("endpoint-selector", BluePrintConstants.DATA_TYPE_STRING,
- false, "")
- property("url-path", BluePrintConstants.DATA_TYPE_STRING,
- true, "")
- property("path", BluePrintConstants.DATA_TYPE_STRING,
- true, "")
- property("expression-type", BluePrintConstants.DATA_TYPE_STRING,
- false, "") {
+ property(
+ "endpoint-selector", BluePrintConstants.DATA_TYPE_STRING,
+ false, ""
+ )
+ property(
+ "url-path", BluePrintConstants.DATA_TYPE_STRING,
+ true, ""
+ )
+ property(
+ "path", BluePrintConstants.DATA_TYPE_STRING,
+ true, ""
+ )
+ property(
+ "expression-type", BluePrintConstants.DATA_TYPE_STRING,
+ false, ""
+ ) {
defaultValue("JSON_PATH".asJsonPrimitive())
constrain {
validValues(arrayListOf("JSON_PATH".asJsonPrimitive(), "JSON_POINTER".asJsonPrimitive()))
}
}
- property("input-key-mapping", BluePrintConstants.DATA_TYPE_MAP,
- true, "") {
+ property(
+ "input-key-mapping", BluePrintConstants.DATA_TYPE_MAP,
+ true, ""
+ ) {
entrySchema(BluePrintConstants.DATA_TYPE_STRING)
}
- property("output-key-mapping", BluePrintConstants.DATA_TYPE_MAP,
- false, "") {
+ property(
+ "output-key-mapping", BluePrintConstants.DATA_TYPE_MAP,
+ false, ""
+ ) {
entrySchema(BluePrintConstants.DATA_TYPE_STRING)
}
- property("key-dependencies", BluePrintConstants.DATA_TYPE_LIST,
- true, "Resource Resolution dependency dictionary names.") {
+ property(
+ "key-dependencies", BluePrintConstants.DATA_TYPE_LIST,
+ true, "Resource Resolution dependency dictionary names."
+ ) {
entrySchema(BluePrintConstants.DATA_TYPE_STRING)
}
}
}
fun BluePrintTypes.nodeTypeSourceCapability(): NodeType {
- return nodeType(id = "source-capability", version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
- derivedFrom = BluePrintConstants.MODEL_TYPE_NODE_RESOURCE_SOURCE,
- description = "This is Component Resource Source Node Type") {
- property(ComponentScriptExecutor.INPUT_SCRIPT_TYPE, BluePrintConstants.DATA_TYPE_STRING,
- true, "Request Id, Unique Id for the request.") {
+ return nodeType(
+ id = "source-capability", version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
+ derivedFrom = BluePrintConstants.MODEL_TYPE_NODE_RESOURCE_SOURCE,
+ description = "This is Component Resource Source Node Type"
+ ) {
+ property(
+ ComponentScriptExecutor.INPUT_SCRIPT_TYPE, BluePrintConstants.DATA_TYPE_STRING,
+ true, "Request Id, Unique Id for the request."
+ ) {
defaultValue(BluePrintConstants.SCRIPT_KOTLIN)
constrain {
- validValues(arrayListOf(BluePrintConstants.SCRIPT_KOTLIN.asJsonPrimitive(),
+ validValues(
+ arrayListOf(
+ BluePrintConstants.SCRIPT_KOTLIN.asJsonPrimitive(),
BluePrintConstants.SCRIPT_INTERNAL.asJsonPrimitive(),
- BluePrintConstants.SCRIPT_JYTHON.asJsonPrimitive()))
+ BluePrintConstants.SCRIPT_JYTHON.asJsonPrimitive()
+ )
+ )
}
}
- property(ComponentScriptExecutor.INPUT_SCRIPT_CLASS_REFERENCE, BluePrintConstants.DATA_TYPE_STRING,
- true, "Kotlin Script class name or jython script name.")
- property("key-dependencies", BluePrintConstants.DATA_TYPE_LIST,
- true, "Resource Resolution dependency dictionary names.") {
+ property(
+ ComponentScriptExecutor.INPUT_SCRIPT_CLASS_REFERENCE, BluePrintConstants.DATA_TYPE_STRING,
+ true, "Kotlin Script class name or jython script name."
+ )
+ property(
+ "key-dependencies", BluePrintConstants.DATA_TYPE_LIST,
+ true, "Resource Resolution dependency dictionary names."
+ ) {
entrySchema(BluePrintConstants.DATA_TYPE_STRING)
}
}
}
/** Node Template Source Input **/
-fun BluePrintTypes.nodeTemplateSourceInput(id: String, description: String,
- block: SourceInputNodeTemplateBuilder.() -> Unit): NodeTemplate {
+fun BluePrintTypes.nodeTemplateSourceInput(
+ id: String,
+ description: String,
+ block: SourceInputNodeTemplateBuilder.() -> Unit
+): NodeTemplate {
return SourceInputNodeTemplateBuilder(id, description).apply(block).build()
}
class SourceInputNodeTemplateBuilder(id: String, description: String) :
- AbstractNodeTemplatePropertyImplBuilder<PropertiesAssignmentBuilder>(id,
- "source-input", description)
+ AbstractNodeTemplatePropertyImplBuilder<PropertiesAssignmentBuilder>(
+ id,
+ "source-input", description
+ )
/** Node Template Source Default **/
-fun BluePrintTypes.nodeTemplateSourceDefault(id: String, description: String,
- block: SourceDefaultNodeTemplateBuilder.() -> Unit): NodeTemplate {
+fun BluePrintTypes.nodeTemplateSourceDefault(
+ id: String,
+ description: String,
+ block: SourceDefaultNodeTemplateBuilder.() -> Unit
+): NodeTemplate {
return SourceDefaultNodeTemplateBuilder(id, description).apply(block).build()
}
class SourceDefaultNodeTemplateBuilder(id: String, description: String) :
- AbstractNodeTemplatePropertyImplBuilder<PropertiesAssignmentBuilder>(id,
- "source-default", description)
+ AbstractNodeTemplatePropertyImplBuilder<PropertiesAssignmentBuilder>(
+ id,
+ "source-default", description
+ )
/** Node Template Source DB **/
-fun BluePrintTypes.nodeTemplateSourceDb(id: String, description: String,
- block: SourceDbNodeTemplateBuilder.() -> Unit): NodeTemplate {
+fun BluePrintTypes.nodeTemplateSourceDb(
+ id: String,
+ description: String,
+ block: SourceDbNodeTemplateBuilder.() -> Unit
+): NodeTemplate {
return SourceDbNodeTemplateBuilder(id, description).apply(block).build()
}
class SourceDbNodeTemplateBuilder(id: String, description: String) :
- AbstractNodeTemplatePropertyImplBuilder<SourceDbNodeTemplateBuilder.PropertiesBuilder>(id,
- "source-db", description) {
+ AbstractNodeTemplatePropertyImplBuilder<SourceDbNodeTemplateBuilder.PropertiesBuilder>(
+ id,
+ "source-db", description
+ ) {
class PropertiesBuilder : PropertiesAssignmentBuilder() {
fun type(type: String) = type(type.asJsonPrimitive())
@@ -221,16 +296,20 @@ class KeyMappingBuilder() {
}
}
-
/** Node Template Source Rest **/
-fun BluePrintTypes.nodeTemplateSourceRest(id: String, description: String,
- block: SourceRestNodeTemplateBuilder.() -> Unit): NodeTemplate {
+fun BluePrintTypes.nodeTemplateSourceRest(
+ id: String,
+ description: String,
+ block: SourceRestNodeTemplateBuilder.() -> Unit
+): NodeTemplate {
return SourceRestNodeTemplateBuilder(id, description).apply(block).build()
}
class SourceRestNodeTemplateBuilder(id: String, description: String) :
- AbstractNodeTemplatePropertyImplBuilder<SourceRestNodeTemplateBuilder.PropertiesBuilder>(id,
- "source-rest", description) {
+ AbstractNodeTemplatePropertyImplBuilder<SourceRestNodeTemplateBuilder.PropertiesBuilder>(
+ id,
+ "source-rest", description
+ ) {
class PropertiesBuilder : PropertiesAssignmentBuilder() {
fun type(type: String) = type(type.asJsonPrimitive())
@@ -296,14 +375,19 @@ class SourceRestNodeTemplateBuilder(id: String, description: String) :
}
/** Node Template Source Rest **/
-fun BluePrintTypes.nodeTemplateSourceCapability(id: String, description: String,
- block: SourceCapabilityNodeTemplateBuilder.() -> Unit): NodeTemplate {
+fun BluePrintTypes.nodeTemplateSourceCapability(
+ id: String,
+ description: String,
+ block: SourceCapabilityNodeTemplateBuilder.() -> Unit
+): NodeTemplate {
return SourceCapabilityNodeTemplateBuilder(id, description).apply(block).build()
}
class SourceCapabilityNodeTemplateBuilder(id: String, description: String) :
- AbstractNodeTemplatePropertyImplBuilder<SourceCapabilityNodeTemplateBuilder.PropertiesBuilder>(id,
- "source-capability", description) {
+ AbstractNodeTemplatePropertyImplBuilder<SourceCapabilityNodeTemplateBuilder.PropertiesBuilder>(
+ id,
+ "source-capability", description
+ ) {
class PropertiesBuilder : PropertiesAssignmentBuilder() {
fun type(type: String) = type(type.asJsonPrimitive())
@@ -330,4 +414,4 @@ class SourceCapabilityNodeTemplateBuilder(id: String, description: String) :
property("key-dependencies", keyDependencies)
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt
index 2a0e7a443..636e81dda 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt
@@ -78,4 +78,4 @@ open class CapabilityResourceSource : ResourceSourceProperties() {
var instanceDependencies: List<String>? = null
@get:JsonProperty("key-dependencies")
lateinit var keyDependencies: MutableList<String>
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolution.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolution.kt
index 781cafd97..db023acfb 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolution.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolution.kt
@@ -22,8 +22,15 @@ import org.hibernate.annotations.Proxy
import org.springframework.data.annotation.LastModifiedDate
import org.springframework.data.jpa.domain.support.AuditingEntityListener
import java.io.Serializable
-import java.util.*
-import javax.persistence.*
+import java.util.Date
+import javax.persistence.Column
+import javax.persistence.Entity
+import javax.persistence.EntityListeners
+import javax.persistence.Id
+import javax.persistence.Lob
+import javax.persistence.Table
+import javax.persistence.Temporal
+import javax.persistence.TemporalType
@EntityListeners(AuditingEntityListener::class)
@Entity
@@ -56,8 +63,10 @@ class ResourceResolution : Serializable {
@Column(name = "status", nullable = false)
var status: String? = null
- @get:ApiModelProperty(value = "Resolution Key uniquely identifying the resolution of a given artifact within a CBA.",
- required = true)
+ @get:ApiModelProperty(
+ value = "Resolution Key uniquely identifying the resolution of a given artifact within a CBA.",
+ required = true
+ )
@Column(name = "resolution_key", nullable = false)
var resolutionKey: String? = null
@@ -69,8 +78,10 @@ class ResourceResolution : Serializable {
@Column(name = "resource_id", nullable = false)
var resourceId: String? = null
- @get:ApiModelProperty(value = "If resolution occurred multiple time, this field provides the index.",
- required = true)
+ @get:ApiModelProperty(
+ value = "If resolution occurred multiple time, this field provides the index.",
+ required = true
+ )
@Column(name = "occurrence", nullable = false)
var occurrence: Int = 0
@@ -78,8 +89,10 @@ class ResourceResolution : Serializable {
@Column(name = "dictionary_name", nullable = false)
var dictionaryName: String? = null
- @get:ApiModelProperty(value = "Source associated with the data dictionary used for the resolution.",
- required = true)
+ @get:ApiModelProperty(
+ value = "Source associated with the data dictionary used for the resolution.",
+ required = true
+ )
@Column(name = "dictionary_status", nullable = false)
var dictionarySource: String? = null
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBService.kt
index e5a13a630..f8bf7bd09 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBService.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBService.kt
@@ -26,7 +26,7 @@ import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
import org.slf4j.LoggerFactory
import org.springframework.dao.EmptyResultDataAccessException
import org.springframework.stereotype.Service
-import java.util.*
+import java.util.UUID
@Service
class ResourceResolutionDBService(private val resourceResolutionRepository: ResourceResolutionRepository) {
@@ -34,8 +34,11 @@ class ResourceResolutionDBService(private val resourceResolutionRepository: Reso
private val log = LoggerFactory.getLogger(ResourceResolutionDBService::class.toString())
suspend fun findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKeyAndOccurrence(
- bluePrintRuntimeService: BluePrintRuntimeService<*>, key: String,
- occurrence: Int, artifactPrefix: String): List<ResourceResolution> {
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ key: String,
+ occurrence: Int,
+ artifactPrefix: String
+ ): List<ResourceResolution> {
return try {
val metadata = bluePrintRuntimeService.bluePrintContext().metadata!!
@@ -47,16 +50,20 @@ class ResourceResolutionDBService(private val resourceResolutionRepository: Reso
blueprintVersion,
artifactPrefix,
key,
- occurrence)
+ occurrence
+ )
} catch (e: EmptyResultDataAccessException) {
emptyList()
}
}
suspend fun findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResourceIdAndResourceTypeAndOccurrence(
- bluePrintRuntimeService: BluePrintRuntimeService<*>, resourceId: String,
- resourceType: String, occurrence: Int,
- artifactPrefix: String): List<ResourceResolution> {
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ resourceId: String,
+ resourceType: String,
+ occurrence: Int,
+ artifactPrefix: String
+ ): List<ResourceResolution> {
return try {
val metadata = bluePrintRuntimeService.bluePrintContext().metadata!!
@@ -70,55 +77,67 @@ class ResourceResolutionDBService(private val resourceResolutionRepository: Reso
artifactPrefix,
resourceId,
resourceType,
- occurrence)
+ occurrence
+ )
} catch (e: EmptyResultDataAccessException) {
emptyList()
}
}
- suspend fun readValue(blueprintName: String,
- blueprintVersion: String,
- artifactPrefix: String,
- resolutionKey: String,
- name: String): ResourceResolution = withContext(Dispatchers.IO) {
+ suspend fun readValue(
+ blueprintName: String,
+ blueprintVersion: String,
+ artifactPrefix: String,
+ resolutionKey: String,
+ name: String
+ ): ResourceResolution = withContext(Dispatchers.IO) {
resourceResolutionRepository.findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactNameAndName(
resolutionKey,
blueprintName,
blueprintVersion,
artifactPrefix,
- name)
+ name
+ )
}
- suspend fun readWithResolutionKey(blueprintName: String,
- blueprintVersion: String,
- artifactPrefix: String,
- resolutionKey: String): List<ResourceResolution> = withContext(Dispatchers.IO) {
+ suspend fun readWithResolutionKey(
+ blueprintName: String,
+ blueprintVersion: String,
+ artifactPrefix: String,
+ resolutionKey: String
+ ): List<ResourceResolution> = withContext(Dispatchers.IO) {
resourceResolutionRepository.findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactName(
resolutionKey,
blueprintName,
blueprintVersion,
- artifactPrefix)
+ artifactPrefix
+ )
}
- suspend fun readWithResourceIdAndResourceType(blueprintName: String,
- blueprintVersion: String,
- resourceId: String,
- resourceType: String): List<ResourceResolution> =
+ suspend fun readWithResourceIdAndResourceType(
+ blueprintName: String,
+ blueprintVersion: String,
+ resourceId: String,
+ resourceType: String
+ ): List<ResourceResolution> =
withContext(Dispatchers.IO) {
resourceResolutionRepository.findByBlueprintNameAndBlueprintVersionAndResourceIdAndResourceType(
blueprintName,
blueprintVersion,
resourceId,
- resourceType)
+ resourceType
+ )
}
- suspend fun write(properties: Map<String, Any>,
- bluePrintRuntimeService: BluePrintRuntimeService<*>,
- artifactPrefix: String,
- resourceAssignment: ResourceAssignment): ResourceResolution = withContext(Dispatchers.IO) {
+ suspend fun write(
+ properties: Map<String, Any>,
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ artifactPrefix: String,
+ resourceAssignment: ResourceAssignment
+ ): ResourceResolution = withContext(Dispatchers.IO) {
val metadata = bluePrintRuntimeService.bluePrintContext().metadata!!
@@ -130,24 +149,28 @@ class ResourceResolutionDBService(private val resourceResolutionRepository: Reso
val resourceType = properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOURCE_TYPE] as String
val occurrence = properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE] as Int
- write(blueprintName,
+ write(
+ blueprintName,
blueprintVersion,
resolutionKey,
resourceId,
resourceType,
artifactPrefix,
resourceAssignment,
- occurrence)
+ occurrence
+ )
}
- suspend fun write(blueprintName: String,
- blueprintVersion: String,
- resolutionKey: String,
- resourceId: String,
- resourceType: String,
- artifactPrefix: String,
- resourceAssignment: ResourceAssignment,
- occurrence: Int = 0): ResourceResolution = withContext(Dispatchers.IO) {
+ suspend fun write(
+ blueprintName: String,
+ blueprintVersion: String,
+ resolutionKey: String,
+ resourceId: String,
+ resourceType: String,
+ artifactPrefix: String,
+ resourceAssignment: ResourceAssignment,
+ occurrence: Int = 0
+ ): ResourceResolution = withContext(Dispatchers.IO) {
val resourceResolution = ResourceResolution()
resourceResolution.id = UUID.randomUUID().toString()
@@ -175,4 +198,4 @@ class ResourceResolutionDBService(private val resourceResolutionRepository: Reso
throw BluePrintException("Failed to store resource resolution result.", ex)
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionRepository.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionRepository.kt
index 429041e14..155270cd9 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionRepository.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionRepository.kt
@@ -19,28 +19,35 @@ import org.springframework.data.jpa.repository.JpaRepository
interface ResourceResolutionRepository : JpaRepository<ResourceResolution, String> {
- fun findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactNameAndName(key: String,
- blueprintName: String?,
- blueprintVersion: String?,
- artifactName: String,
- name: String): ResourceResolution
+ fun findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactNameAndName(
+ key: String,
+ blueprintName: String?,
+ blueprintVersion: String?,
+ artifactName: String,
+ name: String
+ ): ResourceResolution
- fun findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactName(resolutionKey: String,
- blueprintName: String,
- blueprintVersion: String,
- artifactPrefix: String): List<ResourceResolution>
+ fun findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactName(
+ resolutionKey: String,
+ blueprintName: String,
+ blueprintVersion: String,
+ artifactPrefix: String
+ ): List<ResourceResolution>
- fun findByBlueprintNameAndBlueprintVersionAndResourceIdAndResourceType(blueprintName: String,
- blueprintVersion: String,
- resourceId: String,
- resourceType: String): List<ResourceResolution>
+ fun findByBlueprintNameAndBlueprintVersionAndResourceIdAndResourceType(
+ blueprintName: String,
+ blueprintVersion: String,
+ resourceId: String,
+ resourceType: String
+ ): List<ResourceResolution>
fun findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKeyAndOccurrence(
blueprintName: String?,
blueprintVersion: String?,
artifactName: String,
resolutionKey: String,
- occurrence: Int): List<ResourceResolution>
+ occurrence: Int
+ ): List<ResourceResolution>
fun findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResourceIdAndResourceTypeAndOccurrence(
blueprintName: String?,
@@ -48,5 +55,6 @@ interface ResourceResolutionRepository : JpaRepository<ResourceResolution, Strin
artifactName: String,
resourceId: String,
resourceType: String,
- occurrence: Int): List<ResourceResolution>
-} \ No newline at end of file
+ occurrence: Int
+ ): List<ResourceResolution>
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolution.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolution.kt
index 9d5a3f5d5..8b235925b 100755
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolution.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolution.kt
@@ -22,8 +22,15 @@ import org.hibernate.annotations.Proxy
import org.springframework.data.annotation.LastModifiedDate
import org.springframework.data.jpa.domain.support.AuditingEntityListener
import java.io.Serializable
-import java.util.*
-import javax.persistence.*
+import java.util.Date
+import javax.persistence.Column
+import javax.persistence.Entity
+import javax.persistence.EntityListeners
+import javax.persistence.Id
+import javax.persistence.Lob
+import javax.persistence.Table
+import javax.persistence.Temporal
+import javax.persistence.TemporalType
@EntityListeners(AuditingEntityListener::class)
@Entity
@@ -48,8 +55,10 @@ class TemplateResolution : Serializable {
@Column(name = "result", nullable = false)
var result: String? = null
- @get:ApiModelProperty(value = "Resolution Key uniquely identifying the resolution of a given artifact within a CBA.",
- required = true)
+ @get:ApiModelProperty(
+ value = "Resolution Key uniquely identifying the resolution of a given artifact within a CBA.",
+ required = true
+ )
@Column(name = "resolution_key", nullable = false)
var resolutionKey: String? = null
@@ -61,8 +70,10 @@ class TemplateResolution : Serializable {
@Column(name = "resource_id", nullable = false)
var resourceId: String? = null
- @get:ApiModelProperty(value = "If resolution occurred multiple time, this field provides the index.",
- required = true)
+ @get:ApiModelProperty(
+ value = "If resolution occurred multiple time, this field provides the index.",
+ required = true
+ )
@Column(name = "occurrence", nullable = false)
var occurrence: Int = 1
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionRepository.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionRepository.kt
index 440663f25..610a3cfe3 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionRepository.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionRepository.kt
@@ -26,14 +26,16 @@ interface TemplateResolutionRepository : JpaRepository<TemplateResolution, Strin
blueprintName: String?,
blueprintVersion: String?,
artifactName: String,
- occurrence: Int): TemplateResolution ?
+ occurrence: Int
+ ): TemplateResolution?
fun findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
key: String,
blueprintName: String?,
blueprintVersion: String?,
artifactName: String,
- occurrence: Int): TemplateResolution ?
+ occurrence: Int
+ ): TemplateResolution?
@Transactional
fun deleteByResourceIdAndResourceTypeAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
@@ -42,7 +44,8 @@ interface TemplateResolutionRepository : JpaRepository<TemplateResolution, Strin
blueprintName: String?,
blueprintVersion: String?,
artifactName: String,
- occurrence: Int)
+ occurrence: Int
+ )
@Transactional
fun deleteByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
@@ -50,5 +53,6 @@ interface TemplateResolutionRepository : JpaRepository<TemplateResolution, Strin
blueprintName: String?,
blueprintVersion: String?,
artifactName: String,
- occurrence: Int)
+ occurrence: Int
+ )
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionService.kt
index c64605ef0..895bc993f 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionService.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionService.kt
@@ -25,7 +25,7 @@ import org.slf4j.LoggerFactory
import org.springframework.dao.DataIntegrityViolationException
import org.springframework.dao.EmptyResultDataAccessException
import org.springframework.stereotype.Service
-import java.util.*
+import java.util.UUID
@Service
class TemplateResolutionService(private val templateResolutionRepository: TemplateResolutionRepository) {
@@ -35,7 +35,8 @@ class TemplateResolutionService(private val templateResolutionRepository: Templa
suspend fun findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactName(
bluePrintRuntimeService: BluePrintRuntimeService<*>,
artifactPrefix: String,
- resolutionKey: String): String =
+ resolutionKey: String
+ ): String =
withContext(Dispatchers.IO) {
val metadata = bluePrintRuntimeService.bluePrintContext().metadata!!
@@ -43,17 +44,21 @@ class TemplateResolutionService(private val templateResolutionRepository: Templa
val blueprintVersion = metadata[BluePrintConstants.METADATA_TEMPLATE_VERSION]!!
val blueprintName = metadata[BluePrintConstants.METADATA_TEMPLATE_NAME]!!
- findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactName(blueprintName,
+ findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactName(
+ blueprintName,
blueprintVersion,
artifactPrefix,
- resolutionKey)
+ resolutionKey
+ )
}
- suspend fun findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactName(blueprintName: String,
- blueprintVersion: String,
- artifactPrefix: String,
- resolutionKey: String,
- occurrence: Int = 1): String =
+ suspend fun findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactName(
+ blueprintName: String,
+ blueprintVersion: String,
+ artifactPrefix: String,
+ resolutionKey: String,
+ occurrence: Int = 1
+ ): String =
withContext(Dispatchers.IO) {
templateResolutionRepository.findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
@@ -61,15 +66,18 @@ class TemplateResolutionService(private val templateResolutionRepository: Templa
blueprintName,
blueprintVersion,
artifactPrefix,
- occurrence)?.result ?: throw EmptyResultDataAccessException(1)
+ occurrence
+ )?.result ?: throw EmptyResultDataAccessException(1)
}
- suspend fun findByResoureIdAndResourceTypeAndBlueprintNameAndBlueprintVersionAndArtifactName(blueprintName: String,
- blueprintVersion: String,
- artifactPrefix: String,
- resourceId: String,
- resourceType: String,
- occurrence: Int = 1): String =
+ suspend fun findByResoureIdAndResourceTypeAndBlueprintNameAndBlueprintVersionAndArtifactName(
+ blueprintName: String,
+ blueprintVersion: String,
+ artifactPrefix: String,
+ resourceId: String,
+ resourceType: String,
+ occurrence: Int = 1
+ ): String =
withContext(Dispatchers.IO) {
templateResolutionRepository.findByResourceIdAndResourceTypeAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
@@ -78,12 +86,16 @@ class TemplateResolutionService(private val templateResolutionRepository: Templa
blueprintName,
blueprintVersion,
artifactPrefix,
- occurrence)?.result!!
+ occurrence
+ )?.result!!
}
- suspend fun write(properties: Map<String, Any>,
- result: String, bluePrintRuntimeService: BluePrintRuntimeService<*>,
- artifactPrefix: String): TemplateResolution = withContext(Dispatchers.IO) {
+ suspend fun write(
+ properties: Map<String, Any>,
+ result: String,
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ artifactPrefix: String
+ ): TemplateResolution = withContext(Dispatchers.IO) {
val metadata = bluePrintRuntimeService.bluePrintContext().metadata!!
@@ -93,19 +105,28 @@ class TemplateResolutionService(private val templateResolutionRepository: Templa
val resourceId = properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOURCE_ID] as String
val resourceType = properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOURCE_TYPE] as String
val occurrence = properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE] as Int
- write(blueprintName,
+ write(
+ blueprintName,
blueprintVersion,
artifactPrefix,
result,
occurrence,
resolutionKey,
resourceId,
- resourceType)
+ resourceType
+ )
}
- suspend fun write(blueprintName: String, blueprintVersion: String, artifactPrefix: String,
- template: String, occurrence: Int = 1, resolutionKey: String = "", resourceId: String = "",
- resourceType: String = ""): TemplateResolution =
+ suspend fun write(
+ blueprintName: String,
+ blueprintVersion: String,
+ artifactPrefix: String,
+ template: String,
+ occurrence: Int = 1,
+ resolutionKey: String = "",
+ resourceId: String = "",
+ resourceType: String = ""
+ ): TemplateResolution =
withContext(Dispatchers.IO) {
val resourceResolutionResult = TemplateResolution()
@@ -122,37 +143,49 @@ class TemplateResolutionService(private val templateResolutionRepository: Templa
// Overwrite template resolution-key of resourceId/resourceType already existant
if (resolutionKey.isNotEmpty()) {
templateResolutionRepository.findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
- resolutionKey, blueprintName, blueprintVersion, artifactPrefix, occurrence)?.let {
- log.info("Overwriting template resolution for blueprintName=($blueprintVersion), blueprintVersion=($blueprintName), " +
- "artifactName=($artifactPrefix) and resolutionKey=($resolutionKey)")
+ resolutionKey, blueprintName, blueprintVersion, artifactPrefix, occurrence
+ )?.let {
+ log.info(
+ "Overwriting template resolution for blueprintName=($blueprintVersion), blueprintVersion=($blueprintName), " +
+ "artifactName=($artifactPrefix) and resolutionKey=($resolutionKey)"
+ )
templateResolutionRepository.deleteByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
resolutionKey,
blueprintName,
blueprintVersion,
artifactPrefix,
- occurrence)
+ occurrence
+ )
}
} else if (resourceId.isNotEmpty() && resourceType.isNotEmpty()) {
templateResolutionRepository.findByResourceIdAndResourceTypeAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
- resourceId, resourceType, blueprintName, blueprintVersion, artifactPrefix, occurrence)?.let {
- log.info("Overwriting template resolution for blueprintName=($blueprintVersion), blueprintVersion=($blueprintName), " +
- "artifactName=($artifactPrefix), resourceId=($resourceId) and resourceType=($resourceType)")
+ resourceId, resourceType, blueprintName, blueprintVersion, artifactPrefix, occurrence
+ )?.let {
+ log.info(
+ "Overwriting template resolution for blueprintName=($blueprintVersion), blueprintVersion=($blueprintName), " +
+ "artifactName=($artifactPrefix), resourceId=($resourceId) and resourceType=($resourceType)"
+ )
templateResolutionRepository.deleteByResourceIdAndResourceTypeAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
resourceId,
resourceType,
blueprintName,
blueprintVersion,
artifactPrefix,
- occurrence)
+ occurrence
+ )
}
}
try {
- log.info("Writing out template_resolution result: bpName: $blueprintName bpVer $blueprintVersion resKey:$resolutionKey" +
- " (resourceId: $resourceId resourceType: $resourceType) occurrence:$occurrence")
+ log.info(
+ "Writing out template_resolution result: bpName: $blueprintName bpVer $blueprintVersion resKey:$resolutionKey" +
+ " (resourceId: $resourceId resourceType: $resourceType) occurrence:$occurrence"
+ )
templateResolutionRepository.saveAndFlush(resourceResolutionResult)
} catch (ex: DataIntegrityViolationException) {
- log.error("Error writing out template_resolution result: bpName: $blueprintName bpVer $blueprintVersion resKey:$resolutionKey" +
- " (resourceId: $resourceId resourceType: $resourceType) occurrence:$occurrence error: {}", ex.message)
+ log.error(
+ "Error writing out template_resolution result: bpName: $blueprintName bpVer $blueprintVersion resKey:$resolutionKey" +
+ " (resourceId: $resourceId resourceType: $resourceType) occurrence:$occurrence error: {}", ex.message
+ )
throw BluePrintException("Failed to store resource api result.", ex)
}
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt
index 9867cd658..feef4c2fe 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt
@@ -90,8 +90,8 @@ open class CapabilityResourceResolutionProcessor(private var componentFunctionSc
ResourceAssignmentUtils.setFailedResourceDataValue(resourceAssignment, runtimeException.message)
}
- suspend fun scriptInstance(scriptType: String, scriptClassReference: String, instanceDependencies: List<String>)
- : ResourceAssignmentProcessor {
+ suspend fun scriptInstance(scriptType: String, scriptClassReference: String, instanceDependencies: List<String>):
+ ResourceAssignmentProcessor {
log.info(
"creating resource resolution of script type($scriptType), reference name($scriptClassReference) and" +
@@ -106,5 +106,4 @@ open class CapabilityResourceResolutionProcessor(private var componentFunctionSc
return scriptComponent
}
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt
index 0f5d91415..8ca0ab63f 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt
@@ -18,7 +18,7 @@
package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor
import org.onap.ccsdk.cds.blueprintsprocessor.db.BluePrintDBLibGenericService
-import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.BluePrintDBLibPropertySevice
+import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.BluePrintDBLibPropertyService
import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.PrimaryDBLibGenericService
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.DatabaseResourceSource
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR
@@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory
import org.springframework.beans.factory.config.ConfigurableBeanFactory
import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Service
-import java.util.*
+import java.util.HashMap
/**
* DatabaseResourceAssignmentProcessor
@@ -44,7 +44,7 @@ import java.util.*
@Service("${PREFIX_RESOURCE_RESOLUTION_PROCESSOR}source-db")
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
open class DatabaseResourceAssignmentProcessor(
- private val bluePrintDBLibPropertySevice: BluePrintDBLibPropertySevice,
+ private val bluePrintDBLibPropertyService: BluePrintDBLibPropertyService,
private val primaryDBLibGenericService: PrimaryDBLibGenericService
) : ResourceAssignmentProcessor() {
@@ -91,8 +91,10 @@ open class DatabaseResourceAssignmentProcessor(
"failed to get input-key-mappings for $dName under $dSource properties"
}
- logger.info("DatabaseResource ($dSource) dictionary information: " +
- "Query:($sql), input-key-mapping:($inputKeyMapping), output-key-mapping:(${sourceProperties.outputKeyMapping})")
+ logger.info(
+ "DatabaseResource ($dSource) dictionary information: " +
+ "Query:($sql), input-key-mapping:($inputKeyMapping), output-key-mapping:(${sourceProperties.outputKeyMapping})"
+ )
val jdbcTemplate = blueprintDBLibService(sourceProperties)
val rows = jdbcTemplate.query(sql, populateNamedParameter(inputKeyMapping))
@@ -106,11 +108,10 @@ open class DatabaseResourceAssignmentProcessor(
private fun blueprintDBLibService(sourceProperties: DatabaseResourceSource): BluePrintDBLibGenericService {
return if (isNotEmpty(sourceProperties.endpointSelector)) {
val dbPropertiesJson = raRuntimeService.resolveDSLExpression(sourceProperties.endpointSelector!!)
- bluePrintDBLibPropertySevice.JdbcTemplate(dbPropertiesJson)
+ bluePrintDBLibPropertyService.JdbcTemplate(dbPropertiesJson)
} else {
primaryDBLibGenericService
}
-
}
@Throws(BluePrintProcessorException::class)
@@ -119,14 +120,13 @@ open class DatabaseResourceAssignmentProcessor(
checkNotEmpty(resourceAssignment.dictionaryName) {
"resource assignment dictionary name is not defined for template key (${resourceAssignment.name})"
}
- check(resourceAssignment.dictionarySource in getListOfDBSources())
- {
+ check(resourceAssignment.dictionarySource in getListOfDBSources()) {
"resource assignment source is not ${ResourceDictionaryConstants.PROCESSOR_DB} but it is ${resourceAssignment.dictionarySource}"
}
}
- //placeholder to get the list of DB sources.
- //TODO: This will be replaced with a DB
+ // placeholder to get the list of DB sources.
+ // TODO: This will be replaced with a DB
private fun getListOfDBSources(): Array<String> = arrayOf(ResourceDictionaryConstants.PROCESSOR_DB)
private fun populateNamedParameter(inputKeyMapping: Map<String, String>): Map<String, Any> {
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt
index 9a83b0cc0..7705c1102 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt
@@ -53,10 +53,9 @@ open class DefaultResourceResolutionProcessor : ResourceAssignmentProcessor() {
ResourceAssignmentUtils.setFailedResourceDataValue(resourceAssignment, e.message)
throw BluePrintProcessorException("Failed in template key ($resourceAssignment) assignments with: ${e.message}", e)
}
-
}
override suspend fun recoverNB(runtimeException: RuntimeException, resourceAssignment: ResourceAssignment) {
raRuntimeService.getBluePrintError().addError(runtimeException.message!!)
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessor.kt
index a78e7872e..f04a787db 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessor.kt
@@ -17,10 +17,12 @@
package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.DatabaseResourceSource
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.cds.controllerblueprints.core.isNotEmpty
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
import org.springframework.beans.factory.config.ConfigurableBeanFactory
import org.springframework.context.annotation.Scope
@@ -41,8 +43,8 @@ open class InputResourceResolutionProcessor : ResourceAssignmentProcessor() {
override suspend fun processNB(resourceAssignment: ResourceAssignment) {
try {
- if (isNotEmpty(resourceAssignment.name)) {
- setFromInput(resourceAssignment)
+ if (isNotEmpty(resourceAssignment.name) && !setFromInput(resourceAssignment)) {
+ setFromKeyDependencies(resourceAssignment)
}
// Check the value has populated for mandatory case
ResourceAssignmentUtils.assertTemplateKeyValueNotNull(resourceAssignment)
@@ -52,7 +54,30 @@ open class InputResourceResolutionProcessor : ResourceAssignmentProcessor() {
}
}
+ // usecase: where input data attribute doesn't match with resourceName, and needs an alternate mapping provided under key-dependencies.
+ private fun setFromKeyDependencies(resourceAssignment: ResourceAssignment) {
+ val dName = resourceAssignment.dictionaryName!!
+ val dSource = resourceAssignment.dictionarySource!!
+ val resourceDefinition = resourceDefinition(dName)
+
+ /** Check Resource Assignment has the source definitions, If not get from Resource Definition **/
+ val resourceSource = resourceAssignment.dictionarySourceDefinition
+ ?: resourceDefinition?.sources?.get(dSource)
+ ?: throw BluePrintProcessorException("couldn't get resource definition $dName source($dSource)")
+ val resourceSourceProperties = checkNotNull(resourceSource.properties) {
+ "failed to get source properties for $dName "
+ }
+ val sourceProperties =
+ JacksonUtils.getInstanceFromMap(resourceSourceProperties, DatabaseResourceSource::class.java)
+
+ val keyDependency = checkNotNull(sourceProperties.keyDependencies) {
+ "failed to get input-key-mappings for $dName under $dSource properties"
+ }
+ // keyDependency = service-instance.service-instance-id
+ setFromInputKeyDependencies(keyDependency, resourceAssignment); // New API which picks arrtibute from Input
+ }
+
override suspend fun recoverNB(runtimeException: RuntimeException, resourceAssignment: ResourceAssignment) {
raRuntimeService.getBluePrintError().addError(runtimeException.message!!)
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt
index e513170a8..454a899aa 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt
@@ -22,13 +22,17 @@ import com.fasterxml.jackson.databind.JsonNode
import org.apache.commons.collections.MapUtils
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceAssignmentRuntimeService
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
-import org.onap.ccsdk.cds.controllerblueprints.core.*
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonNode
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintFunctionNode
+import org.onap.ccsdk.cds.controllerblueprints.core.isNullOrMissing
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintVelocityTemplateService
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition
import org.slf4j.LoggerFactory
-import java.util.*
+import java.util.HashMap
abstract class ResourceAssignmentProcessor : BlueprintFunctionNode<ResourceAssignment, Boolean> {
@@ -52,8 +56,10 @@ abstract class ResourceAssignmentProcessor : BlueprintFunctionNode<ResourceAssig
try {
val value = raRuntimeService.getInputValue(resourceAssignment.name)
if (!value.isNullOrMissing()) {
- log.debug("For Resource:(${resourceAssignment.name}) found value:({}) in input-data.",
- ResourceAssignmentUtils.getValueToLog(resourceAssignment.property?.metadata, value))
+ log.debug(
+ "For Resource:(${resourceAssignment.name}) found value:({}) in input-data.",
+ ResourceAssignmentUtils.getValueToLog(resourceAssignment.property?.metadata, value)
+ )
ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, value)
return true
}
@@ -63,6 +69,25 @@ abstract class ResourceAssignmentProcessor : BlueprintFunctionNode<ResourceAssig
return false
}
+ open fun setFromInputKeyDependencies(keys: MutableList<String>, resourceAssignment: ResourceAssignment): Boolean {
+ try {
+ for (dependencyKey in keys) {
+ var value = raRuntimeService.getInputValue(dependencyKey)
+ if (!value.isNullOrMissing()) {
+ log.debug(
+ "For Resource:(${resourceAssignment.name}) found value:({}) in input-data under: ($dependencyKey).",
+ ResourceAssignmentUtils.getValueToLog(resourceAssignment.property?.metadata, value)
+ )
+ ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, value)
+ return true
+ }
+ }
+ } catch (e: BluePrintProcessorException) {
+ // NoOp - couldn't find value from input
+ }
+ return false
+ }
+
open fun resourceDefinition(name: String): ResourceDefinition? {
return if (resourceDictionaries.containsKey(name)) resourceDictionaries[name] else null
}
@@ -83,7 +108,7 @@ abstract class ResourceAssignmentProcessor : BlueprintFunctionNode<ResourceAssig
if (valueToResolve.isEmpty() || !valueToResolve.contains("$")) {
return valueToResolve
}
- //TODO("Optimize to JSON Node directly without velocity").asJsonNode().toString()
+ // TODO("Optimize to JSON Node directly without velocity").asJsonNode().toString()
return BluePrintVelocityTemplateService.generateContent(valueToResolve, keyMapping.asJsonNode().toString())
}
@@ -171,4 +196,4 @@ abstract class ResourceAssignmentProcessor : BlueprintFunctionNode<ResourceAssig
fun addError(error: String) {
raRuntimeService.getBluePrintError().addError(error)
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt
index e9aa2749a..2ff5c441e 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt
@@ -81,8 +81,10 @@ open class RestResourceResolutionProcessor(private val blueprintRestLibPropertyS
resolveFromInputKeyMapping(checkNotNull(sourceProperties.urlPath), resolvedInputKeyMapping)
val verb = resolveFromInputKeyMapping(nullToEmpty(sourceProperties.verb), resolvedInputKeyMapping)
- logger.info("RestResource ($dSource) dictionary information: " +
- "URL:($urlPath), input-key-mapping:($inputKeyMapping), output-key-mapping:(${sourceProperties.outputKeyMapping})")
+ logger.info(
+ "RestResource ($dSource) dictionary information: " +
+ "URL:($urlPath), input-key-mapping:($inputKeyMapping), output-key-mapping:(${sourceProperties.outputKeyMapping})"
+ )
val requestHeaders = sourceProperties.headers
logger.info("$dSource dictionary information : ($urlPath), ($inputKeyMapping), (${sourceProperties.outputKeyMapping})")
// Get the Rest Client Service
@@ -125,8 +127,10 @@ open class RestResourceResolutionProcessor(private val blueprintRestLibPropertyS
@Throws(BluePrintProcessorException::class)
private fun populateResource(
- resourceAssignment: ResourceAssignment, sourceProperties: RestResourceSource,
- restResponse: String, path: String
+ resourceAssignment: ResourceAssignment,
+ sourceProperties: RestResourceSource,
+ restResponse: String,
+ path: String
) {
val dName = resourceAssignment.dictionaryName
val dSource = resourceAssignment.dictionarySource
@@ -168,5 +172,4 @@ open class RestResourceResolutionProcessor(private val blueprintRestLibPropertyS
override suspend fun recoverNB(runtimeException: RuntimeException, resourceAssignment: ResourceAssignment) {
raRuntimeService.getBluePrintError().addError(runtimeException.message!!)
}
-
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt
index 688713469..b818cc2b1 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt
@@ -25,14 +25,25 @@ import com.fasterxml.jackson.databind.node.ObjectNode
import com.fasterxml.jackson.databind.node.TextNode
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceAssignmentRuntimeService
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants
-import org.onap.ccsdk.cds.controllerblueprints.core.*
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType
+import org.onap.ccsdk.cds.controllerblueprints.core.checkFileExists
+import org.onap.ccsdk.cds.controllerblueprints.core.checkNotEmpty
+import org.onap.ccsdk.cds.controllerblueprints.core.isComplexType
+import org.onap.ccsdk.cds.controllerblueprints.core.isNotEmpty
+import org.onap.ccsdk.cds.controllerblueprints.core.isNullOrMissing
+import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile
+import org.onap.ccsdk.cds.controllerblueprints.core.nullToEmpty
+import org.onap.ccsdk.cds.controllerblueprints.core.rootFieldsToMap
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonReactorUtils
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition
import org.slf4j.LoggerFactory
-import java.util.*
+import java.util.Date
class ResourceAssignmentUtils {
companion object {
@@ -51,7 +62,8 @@ class ResourceAssignmentUtils {
@Throws(BluePrintProcessorException::class)
fun setResourceDataValue(
resourceAssignment: ResourceAssignment,
- raRuntimeService: ResourceAssignmentRuntimeService, value: Any?
+ raRuntimeService: ResourceAssignmentRuntimeService,
+ value: Any?
) {
// TODO("See if Validation is needed in future with respect to conversion and Types")
return setResourceDataValue(resourceAssignment, raRuntimeService, value.asJsonType())
@@ -60,7 +72,8 @@ class ResourceAssignmentUtils {
@Throws(BluePrintProcessorException::class)
fun setResourceDataValue(
resourceAssignment: ResourceAssignment,
- raRuntimeService: ResourceAssignmentRuntimeService, value: JsonNode
+ raRuntimeService: ResourceAssignmentRuntimeService,
+ value: JsonNode
) {
val resourceProp = checkNotNull(resourceAssignment.property) {
"Failed in setting resource value for resource mapping $resourceAssignment"
@@ -102,7 +115,8 @@ class ResourceAssignmentUtils {
private fun setResourceValue(
resourceAssignment: ResourceAssignment,
- raRuntimeService: ResourceAssignmentRuntimeService, value: JsonNode
+ raRuntimeService: ResourceAssignmentRuntimeService,
+ value: JsonNode
) {
// TODO("See if Validation is needed wrt to type before storing")
raRuntimeService.putResolutionStore(resourceAssignment.name, value)
@@ -211,7 +225,8 @@ class ResourceAssignmentUtils {
@Throws(BluePrintProcessorException::class)
fun getPropertyType(
- raRuntimeService: ResourceAssignmentRuntimeService, dataTypeName: String,
+ raRuntimeService: ResourceAssignmentRuntimeService,
+ dataTypeName: String,
propertyName: String
): String {
lateinit var type: String
@@ -231,8 +246,10 @@ class ResourceAssignmentUtils {
@Throws(BluePrintProcessorException::class)
fun parseResponseNode(
- responseNode: JsonNode, resourceAssignment: ResourceAssignment,
- raRuntimeService: ResourceAssignmentRuntimeService, outputKeyMapping: MutableMap<String, String>
+ responseNode: JsonNode,
+ resourceAssignment: ResourceAssignment,
+ raRuntimeService: ResourceAssignmentRuntimeService,
+ outputKeyMapping: MutableMap<String, String>
): JsonNode {
val metadata = resourceAssignment.property!!.metadata
try {
@@ -297,7 +314,8 @@ class ResourceAssignmentUtils {
}
private fun parseResponseNodeForCollection(
- responseNode: JsonNode, resourceAssignment: ResourceAssignment,
+ responseNode: JsonNode,
+ resourceAssignment: ResourceAssignment,
raRuntimeService: ResourceAssignmentRuntimeService,
outputKeyMapping: MutableMap<String, String>
): JsonNode {
@@ -368,9 +386,11 @@ class ResourceAssignmentUtils {
}
private fun parseSingleElementOfArrayResponseNode(
- entrySchemaType: String, outputKeyMapping: MutableMap<String, String>,
+ entrySchemaType: String,
+ outputKeyMapping: MutableMap<String, String>,
raRuntimeService: ResourceAssignmentRuntimeService,
- responseNode: JsonNode, metadata: MutableMap<String, String>?
+ responseNode: JsonNode,
+ metadata: MutableMap<String, String>?
): ObjectNode {
val outputKeyMappingHasOnlyOneElement = checkIfOutputKeyMappingProvideOneElement(outputKeyMapping)
when (entrySchemaType) {
@@ -421,8 +441,10 @@ class ResourceAssignmentUtils {
}
private fun parseObjectResponseNode(
- entrySchemaType: String, outputKeyMapping: MutableMap<String, String>,
- responseArrayNode: MutableMap<String, JsonNode>, metadata: MutableMap<String, String>?
+ entrySchemaType: String,
+ outputKeyMapping: MutableMap<String, String>,
+ responseArrayNode: MutableMap<String, JsonNode>,
+ metadata: MutableMap<String, String>?
): ObjectNode {
val outputKeyMappingHasOnlyOneElement = checkIfOutputKeyMappingProvideOneElement(outputKeyMapping)
if (outputKeyMappingHasOnlyOneElement) {
@@ -437,8 +459,12 @@ class ResourceAssignmentUtils {
}
private fun parseSingleElementNodeWithOneOutputKeyMapping(
- responseSingleJsonNode: JsonNode, outputKeyMappingKey:
- String, outputKeyMappingValue: String, type: String, metadata: MutableMap<String, String>?
+ responseSingleJsonNode: JsonNode,
+ outputKeyMappingKey:
+ String,
+ outputKeyMappingValue: String,
+ type: String,
+ metadata: MutableMap<String, String>?
): ObjectNode {
val arrayChildNode = JacksonUtils.objectMapper.createObjectNode()
@@ -457,7 +483,8 @@ class ResourceAssignmentUtils {
private fun parseSingleElementNodeWithAllOutputKeyMapping(
responseSingleJsonNode: JsonNode,
outputKeyMapping: MutableMap<String, String>,
- type: String, metadata: MutableMap<String, String>?
+ type: String,
+ metadata: MutableMap<String, String>?
): ObjectNode {
val arrayChildNode = JacksonUtils.objectMapper.createObjectNode()
outputKeyMapping.map {
@@ -475,8 +502,10 @@ class ResourceAssignmentUtils {
private fun parseObjectResponseNodeWithOneOutputKeyMapping(
responseArrayNode: MutableMap<String, JsonNode>,
- outputKeyMappingKey: String, outputKeyMappingValue: String,
- type: String, metadata: MutableMap<String, String>?
+ outputKeyMappingKey: String,
+ outputKeyMappingValue: String,
+ type: String,
+ metadata: MutableMap<String, String>?
): ObjectNode {
val objectNode = JacksonUtils.objectMapper.createObjectNode()
val responseSingleJsonNode = responseArrayNode.filterKeys { key ->
@@ -494,7 +523,8 @@ class ResourceAssignmentUtils {
}
private fun parseResponseNodeForComplexType(
- responseNode: JsonNode, resourceAssignment: ResourceAssignment,
+ responseNode: JsonNode,
+ resourceAssignment: ResourceAssignment,
raRuntimeService: ResourceAssignmentRuntimeService,
outputKeyMapping: MutableMap<String, String>
): JsonNode {
@@ -536,7 +566,8 @@ class ResourceAssignmentUtils {
}
private fun checkOutputKeyMappingAllElementsInDataTypeProperties(
- dataTypeName: String, outputKeyMapping: MutableMap<String, String>,
+ dataTypeName: String,
+ outputKeyMapping: MutableMap<String, String>,
raRuntimeService: ResourceAssignmentRuntimeService
): Boolean {
val dataTypeProps = raRuntimeService.bluePrintContext().dataTypeByName(dataTypeName)?.properties
@@ -583,4 +614,4 @@ class ResourceAssignmentUtils {
return checkProtected
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceDefinitionUtils.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceDefinitionUtils.kt
index 15a8c6c80..d3641a850 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceDefinitionUtils.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceDefinitionUtils.kt
@@ -40,19 +40,22 @@ object ResourceDefinitionUtils {
}
/** Create a processing resource assignments for the resource definition */
- fun createResourceAssignments(resourceDefinitions: MutableMap<String, ResourceDefinition>,
- resolveDefinition: String, sources: List<String>)
- : MutableList<ResourceAssignment> {
+ fun createResourceAssignments(
+ resourceDefinitions: MutableMap<String, ResourceDefinition>,
+ resolveDefinition: String,
+ sources: List<String>
+ ):
+ MutableList<ResourceAssignment> {
/** Check if resolve definition is defined in the resource definition Map */
val resourceDefinition = resourceDefinitions[resolveDefinition]
- ?: throw BluePrintProcessorException("failed to get resolve definition($resolveDefinition)")
+ ?: throw BluePrintProcessorException("failed to get resolve definition($resolveDefinition)")
val resourceAssignments: MutableList<ResourceAssignment> = arrayListOf()
/** Get the dependency property fields for the the resource definition to resolve */
val definitionDependencies = definitionDependencies(resourceDefinition, sources)
definitionDependencies.forEach { definitionDependencyName ->
val definitionDependency = resourceDefinitions[definitionDependencyName]
- ?: throw BluePrintProcessorException("failed to get dependency definition($definitionDependencyName)")
+ ?: throw BluePrintProcessorException("failed to get dependency definition($definitionDependencyName)")
val resourceAssignment = ResourceAssignment().apply {
name = definitionDependency.name
@@ -73,7 +76,7 @@ object ResourceDefinitionUtils {
dictionarySourceDefinition = source
// Clone the PropertyDefinition, otherwise property value will be overridden
property = JacksonUtils
- .readValue(resourceDefinition.property.asJsonString(), PropertyDefinition::class.java)
+ .readValue(resourceDefinition.property.asJsonString(), PropertyDefinition::class.java)
val keyDependenciesExists = source.properties?.containsKey("key-dependencies") ?: false
if (keyDependenciesExists) {
dependencies = source.properties!!["key-dependencies"]!!.asListOfString().toMutableList()
@@ -85,4 +88,4 @@ object ResourceDefinitionUtils {
// Populate Resource Definition's dependencies as Input Resource Assignment
return resourceAssignments
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/scripts/InternalRAProcessor.cba.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/scripts/SimpleRAProcessor.kt
index 32f04e6a0..32f04e6a0 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/scripts/InternalRAProcessor.cba.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/scripts/SimpleRAProcessor.kt
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceDefinitionDSLTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceDefinitionDSLTest.kt
index f8f0e991e..7dcaab733 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceDefinitionDSLTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceDefinitionDSLTest.kt
@@ -25,8 +25,10 @@ class ResourceDefinitionDSLTest {
@Test
fun testResourceDefinitionDSL() {
- val testResourceDefinition = BluePrintTypes.resourceDefinition("service-instance-id",
- "VFW Service Instance Name") {
+ val testResourceDefinition = BluePrintTypes.resourceDefinition(
+ "service-instance-id",
+ "VFW Service Instance Name"
+ ) {
tags("service-instance-name, vfw, resources")
updatedBy("brindasanth@onap.com")
property("string", true)
@@ -74,7 +76,7 @@ class ResourceDefinitionDSLTest {
}
}
}
- //println(resourceDefinition.asJsonString(true))
+ // println(resourceDefinition.asJsonString(true))
assertNotNull(testResourceDefinition, "failed to generate testResourceDefinition")
val testResourceDefinitions = BluePrintTypes.resourceDefinitions {
@@ -86,26 +88,30 @@ class ResourceDefinitionDSLTest {
@Test
fun testResourceAssignment() {
- val testResourceAssignment = BluePrintTypes.resourceAssignment("instance-name",
- "service-instance-name", "odl-mdsal") {
+ val testResourceAssignment = BluePrintTypes.resourceAssignment(
+ "instance-name",
+ "service-instance-name", "odl-mdsal"
+ ) {
inputParameter(true)
property("string", true)
dependencies(arrayListOf("service-instance-id"))
}
- //println(resourceAssignment.asJsonString(true))
+ // println(resourceAssignment.asJsonString(true))
assertNotNull(testResourceAssignment, "failed to generate resourceAssignment")
val testResourceAssignments = BluePrintTypes.resourceAssignments {
resourceAssignment(testResourceAssignment)
- resourceAssignment("instance-name1",
- "service-instance-name", "odl-mdsal") {
+ resourceAssignment(
+ "instance-name1",
+ "service-instance-name", "odl-mdsal"
+ ) {
inputParameter(true)
property("string", true)
dependencies(arrayListOf("service-instance-id"))
}
}
- //println(testResourceAssignments.asJsonString(true))
+ // println(testResourceAssignments.asJsonString(true))
assertNotNull(testResourceAssignments, "failed to generate testResourceAssignments")
assertEquals(2, testResourceAssignments.size, "testResourceAssignments size doesn't match")
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSLTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSLTest.kt
index 671acff95..ae9b4208f 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSLTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSLTest.kt
@@ -26,7 +26,7 @@ class ResourceResolutionComponentDSLTest {
@Test
fun testNodeTypeComponentResourceResolution() {
val nodeType = BluePrintTypes.nodeTypeComponentResourceResolution()
- //println(nodeType.asJsonString(true))
+ // println(nodeType.asJsonString(true))
assertNotNull(nodeType, "failed to generate nodeTypeComponentResourceResolution")
}
@@ -42,11 +42,13 @@ class ResourceResolutionComponentDSLTest {
resourceType("vnf")
storeResult(false)
artifactPrefixNames(arrayListOf("template1", "template2"))
- dynamicProperties("""{
+ dynamicProperties(
+ """{
"prop1" : "1234",
"prop2" : true,
"prop3" : 23
- }""".trimIndent())
+ }""".trimIndent()
+ )
}
outputs {
resourceAssignmentParams(getAttribute("assignment-params"))
@@ -54,7 +56,7 @@ class ResourceResolutionComponentDSLTest {
}
}
}
- //println(nodeTemplate.asJsonString(true))
+ // println(nodeTemplate.asJsonString(true))
assertNotNull(nodeTemplate, "failed to generate nodeTemplateComponentResourceResolution")
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt
index b63fa6798..e1f708341 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt
@@ -50,7 +50,6 @@ class ResourceResolutionComponentTest {
private val executionRequest = ExecutionServiceInput()
-
@Before
fun setup() {
@@ -81,8 +80,10 @@ class ResourceResolutionComponentTest {
try {
resourceResolutionComponent.processNB(executionRequest)
} catch (e: BluePrintProcessorException) {
- assertEquals("Can't proceed with the resolution: either provide resolution-key OR combination of resource-id and resource-type.",
- e.message)
+ assertEquals(
+ "Can't proceed with the resolution: either provide resolution-key OR combination of resource-id and resource-type.",
+ e.message
+ )
return@runBlocking
}
fail()
@@ -98,8 +99,10 @@ class ResourceResolutionComponentTest {
try {
resourceResolutionComponent.processNB(executionRequest)
} catch (e: BluePrintProcessorException) {
- assertEquals("Can't proceed with the resolution: both resource-id and resource-type should be provided, one of them is missing.",
- e.message)
+ assertEquals(
+ "Can't proceed with the resolution: both resource-id and resource-type should be provided, one of them is missing.",
+ e.message
+ )
return@runBlocking
}
fail()
@@ -116,9 +119,11 @@ class ResourceResolutionComponentTest {
try {
resourceResolutionComponent.processNB(executionRequest)
} catch (e: BluePrintProcessorException) {
- assertEquals("Can't proceed with the resolution: can't persist resolution without a correlation key. " +
- "Either provide a resolution-key OR combination of resource-id and resource-type OR set `storeResult` to false.",
- e.message)
+ assertEquals(
+ "Can't proceed with the resolution: can't persist resolution without a correlation key. " +
+ "Either provide a resolution-key OR combination of resource-id and resource-type OR set `storeResult` to false.",
+ e.message
+ )
return@runBlocking
}
fail()
@@ -136,22 +141,23 @@ class ResourceResolutionComponentTest {
properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE] = occurrence
coEvery {
- resourceResolutionService.resolveResources(any(),
- any(),
- any<List<String>>(),
- any<MutableMap<String, Any>>())
+ resourceResolutionService.resolveResources(
+ any(),
+ any(),
+ any<List<String>>(),
+ any<MutableMap<String, Any>>()
+ )
} returns mutableMapOf()
-
runBlocking {
resourceResolutionComponent.processNB(executionRequest)
}
-// FIXME add verification
-// coVerify {
-// resourceResolutionService.resolveResources(eq(bluePrintRuntimeService),
-// eq(nodeTemplateName), eq(artifactNames), eq(properties))
-// }
+ // FIXME add verification
+ // coVerify {
+ // resourceResolutionService.resolveResources(eq(bluePrintRuntimeService),
+ // eq(nodeTemplateName), eq(artifactNames), eq(properties))
+ // }
}
@Test
@@ -165,4 +171,4 @@ class ResourceResolutionComponentTest {
assertEquals(1, blueprintError.errors.size)
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt
index db453acf4..e46d457cd 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt
@@ -30,7 +30,12 @@ import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertyConfiguratio
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
import org.onap.ccsdk.cds.blueprintsprocessor.core.utils.PayloadUtils
import org.onap.ccsdk.cds.blueprintsprocessor.db.BluePrintDBLibConfiguration
-import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.*
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.CapabilityResourceResolutionProcessor
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.DatabaseResourceAssignmentProcessor
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.DefaultResourceResolutionProcessor
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.InputResourceResolutionProcessor
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.MockCapabilityScriptRA
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.RestResourceResolutionProcessor
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintError
@@ -57,12 +62,14 @@ import kotlin.test.assertTrue
* @author Brinda Santh DATE : 8/15/2018
*/
@RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [ResourceResolutionServiceImpl::class,
- InputResourceResolutionProcessor::class, DefaultResourceResolutionProcessor::class,
- DatabaseResourceAssignmentProcessor::class, RestResourceResolutionProcessor::class,
- CapabilityResourceResolutionProcessor::class,
- BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class,
- BluePrintDBLibConfiguration::class, BluePrintLoadConfiguration::class])
+@ContextConfiguration(
+ classes = [ResourceResolutionServiceImpl::class,
+ InputResourceResolutionProcessor::class, DefaultResourceResolutionProcessor::class,
+ DatabaseResourceAssignmentProcessor::class, RestResourceResolutionProcessor::class,
+ CapabilityResourceResolutionProcessor::class,
+ BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class,
+ BluePrintDBLibConfiguration::class, BluePrintLoadConfiguration::class]
+)
@TestPropertySource(locations = ["classpath:application-test.properties"])
@ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor", "org.onap.ccsdk.cds.controllerblueprints"])
@EnableAutoConfiguration
@@ -92,8 +99,14 @@ class ResourceResolutionServiceTest {
fun testRegisteredSource() {
val sources = resourceResolutionService.registeredResourceSources()
assertNotNull(sources, "failed to get registered sources")
- assertTrue(sources.containsAll(arrayListOf("source-input", "source-default", "source-db",
- "source-rest", "source-capability")), "failed to get registered sources : $sources")
+ assertTrue(
+ sources.containsAll(
+ arrayListOf(
+ "source-input", "source-default", "source-db",
+ "source-rest", "source-capability"
+ )
+ ), "failed to get registered sources : $sources"
+ )
}
@Test
@@ -103,29 +116,36 @@ class ResourceResolutionServiceTest {
Assert.assertNotNull("failed to create ResourceResolutionService", resourceResolutionService)
- val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
- "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(
+ "1234",
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
val executionServiceInput =
- JacksonUtils.readValueFromClassPathFile("payload/requests/sample-resourceresolution-request.json",
- ExecutionServiceInput::class.java)!!
-
+ JacksonUtils.readValueFromClassPathFile(
+ "payload/requests/sample-resourceresolution-request.json",
+ ExecutionServiceInput::class.java
+ )!!
val resourceAssignmentRuntimeService =
- ResourceAssignmentUtils.transformToRARuntimeService(bluePrintRuntimeService,
- "testResolveResource")
-
+ ResourceAssignmentUtils.transformToRARuntimeService(
+ bluePrintRuntimeService,
+ "testResolveResource"
+ )
// Prepare Inputs
- PayloadUtils.prepareInputsFromWorkflowPayload(bluePrintRuntimeService,
- executionServiceInput.payload,
- "resource-assignment")
-
- resourceResolutionService.resolveResources(resourceAssignmentRuntimeService,
- "resource-assignment",
- "baseconfig",
- props)
-
+ PayloadUtils.prepareInputsFromWorkflowPayload(
+ bluePrintRuntimeService,
+ executionServiceInput.payload,
+ "resource-assignment"
+ )
+
+ resourceResolutionService.resolveResources(
+ resourceAssignmentRuntimeService,
+ "resource-assignment",
+ "baseconfig",
+ props
+ )
}
}
@@ -135,26 +155,33 @@ class ResourceResolutionServiceTest {
runBlocking {
Assert.assertNotNull("failed to create ResourceResolutionService", resourceResolutionService)
- val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
- "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(
+ "1234",
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
val executionServiceInput =
- JacksonUtils.readValueFromClassPathFile("payload/requests/sample-resourceresolution-request.json",
- ExecutionServiceInput::class.java)!!
+ JacksonUtils.readValueFromClassPathFile(
+ "payload/requests/sample-resourceresolution-request.json",
+ ExecutionServiceInput::class.java
+ )!!
val artefactNames = listOf("baseconfig", "another")
// Prepare Inputs
- PayloadUtils.prepareInputsFromWorkflowPayload(bluePrintRuntimeService,
- executionServiceInput.payload,
- "resource-assignment")
-
- resourceResolutionService.resolveResources(bluePrintRuntimeService,
- "resource-assignment",
- artefactNames,
- props)
+ PayloadUtils.prepareInputsFromWorkflowPayload(
+ bluePrintRuntimeService,
+ executionServiceInput.payload,
+ "resource-assignment"
+ )
+
+ resourceResolutionService.resolveResources(
+ bluePrintRuntimeService,
+ "resource-assignment",
+ artefactNames,
+ props
+ )
}
-
}
@Test
@@ -163,32 +190,41 @@ class ResourceResolutionServiceTest {
runBlocking {
Assert.assertNotNull("failed to create ResourceResolutionService", resourceResolutionService)
- val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
- "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(
+ "1234",
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
val executionServiceInput =
- JacksonUtils.readValueFromClassPathFile("payload/requests/sample-resourceresolution-request.json",
- ExecutionServiceInput::class.java)!!
+ JacksonUtils.readValueFromClassPathFile(
+ "payload/requests/sample-resourceresolution-request.json",
+ ExecutionServiceInput::class.java
+ )!!
val resourceAssignmentRuntimeService =
- ResourceAssignmentUtils.transformToRARuntimeService(bluePrintRuntimeService,
- "testResolveResourcesWithMappingAndTemplate")
+ ResourceAssignmentUtils.transformToRARuntimeService(
+ bluePrintRuntimeService,
+ "testResolveResourcesWithMappingAndTemplate"
+ )
val artifactPrefix = "another"
// Prepare Inputs
- PayloadUtils.prepareInputsFromWorkflowPayload(bluePrintRuntimeService,
- executionServiceInput.payload,
- "resource-assignment")
-
- resourceResolutionService.resolveResources(resourceAssignmentRuntimeService,
- "resource-assignment",
- artifactPrefix,
- props)
+ PayloadUtils.prepareInputsFromWorkflowPayload(
+ bluePrintRuntimeService,
+ executionServiceInput.payload,
+ "resource-assignment"
+ )
+
+ resourceResolutionService.resolveResources(
+ resourceAssignmentRuntimeService,
+ "resource-assignment",
+ artifactPrefix,
+ props
+ )
}
}
-
@Test
fun testResolveResourcesWithResourceIdAndResourceType() {
@@ -197,28 +233,38 @@ class ResourceResolutionServiceTest {
runBlocking {
Assert.assertNotNull("failed to create ResourceResolutionService", resourceResolutionService)
- val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
- "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(
+ "1234",
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
val executionServiceInput =
- JacksonUtils.readValueFromClassPathFile("payload/requests/sample-resourceresolution-request.json",
- ExecutionServiceInput::class.java)!!
+ JacksonUtils.readValueFromClassPathFile(
+ "payload/requests/sample-resourceresolution-request.json",
+ ExecutionServiceInput::class.java
+ )!!
val resourceAssignmentRuntimeService =
- ResourceAssignmentUtils.transformToRARuntimeService(bluePrintRuntimeService,
- "testResolveResourcesWithMappingAndTemplate")
+ ResourceAssignmentUtils.transformToRARuntimeService(
+ bluePrintRuntimeService,
+ "testResolveResourcesWithMappingAndTemplate"
+ )
val artifactPrefix = "another"
// Prepare Inputs
- PayloadUtils.prepareInputsFromWorkflowPayload(bluePrintRuntimeService,
- executionServiceInput.payload,
- "resource-assignment")
-
- resourceResolutionService.resolveResources(resourceAssignmentRuntimeService,
- "resource-assignment",
- artifactPrefix,
- props)
+ PayloadUtils.prepareInputsFromWorkflowPayload(
+ bluePrintRuntimeService,
+ executionServiceInput.payload,
+ "resource-assignment"
+ )
+
+ resourceResolutionService.resolveResources(
+ resourceAssignmentRuntimeService,
+ "resource-assignment",
+ artifactPrefix,
+ props
+ )
}
}
@@ -259,7 +305,7 @@ class ResourceResolutionServiceTest {
val raRuntimeService = mockk<ResourceAssignmentRuntimeService>()
every { raRuntimeService.bluePrintContext() } returns mockk<BluePrintContext>()
every { raRuntimeService.getBluePrintError() } returns BluePrintError()
- every { raRuntimeService.setBluePrintError(any())} returns Unit
+ every { raRuntimeService.setBluePrintError(any()) } returns Unit
every { raRuntimeService.getInputValue("device-id") } returns "123456".asJsonPrimitive()
every { raRuntimeService.putResolutionStore(any(), any()) } returns Unit
@@ -271,8 +317,10 @@ class ResourceResolutionServiceTest {
val sources = arrayListOf<String>("sdno", "sdnc")
val resourceResolutionService = ResourceResolutionServiceImpl(applicationContext, mockk(), mockk(), mockk())
- val resolvedResources = resourceResolutionService.resolveResourceDefinition(raRuntimeService,
- resourceDefinitions, "port-speed", sources)
+ val resolvedResources = resourceResolutionService.resolveResourceDefinition(
+ raRuntimeService,
+ resourceDefinitions, "port-speed", sources
+ )
assertNotNull(resolvedResources, "failed to resolve the resources")
}
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceDSLTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceDSLTest.kt
index 2eb208566..2e9dc9e2a 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceDSLTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceDSLTest.kt
@@ -25,53 +25,51 @@ class ResourceSourceDSLTest {
@Test
fun testNodeTypeSourceInput() {
val nodeType = BluePrintTypes.nodeTypeSourceInput()
- //println(nodeType.asJsonString(true))
+ // println(nodeType.asJsonString(true))
assertNotNull(nodeType, "failed to generate nodeTypeSourceInput")
}
@Test
fun testNodeTypeSourceDefault() {
val nodeType = BluePrintTypes.nodeTypeSourceDefault()
- //println(nodeType.asJsonString(true))
+ // println(nodeType.asJsonString(true))
assertNotNull(nodeType, "failed to generate nodeTypeSourceDefault")
}
@Test
fun testNodeTypeSourceDb() {
val nodeType = BluePrintTypes.nodeTypeSourceDb()
- //println(nodeType.asJsonString(true))
+ // println(nodeType.asJsonString(true))
assertNotNull(nodeType, "failed to generate nodeTypeSourceDb")
}
@Test
fun testNodeTypeSourceRest() {
val nodeType = BluePrintTypes.nodeTypeSourceRest()
- //println(nodeType.asJsonString(true))
+ // println(nodeType.asJsonString(true))
assertNotNull(nodeType, "failed to generate nodeTypeSourceRest")
}
@Test
fun testNodeTypeSourceCapability() {
val nodeType = BluePrintTypes.nodeTypeSourceCapability()
- //println(nodeType.asJsonString(true))
+ // println(nodeType.asJsonString(true))
assertNotNull(nodeType, "failed to generate nodeTypeSourceCapability")
}
@Test
fun testNodeTemplateSourceInput() {
val nodeTemplate = BluePrintTypes.nodeTemplateSourceInput("InputSystem", "") {
-
}
- //println(nodeTemplate.asJsonString(true))
+ // println(nodeTemplate.asJsonString(true))
assertNotNull(nodeTemplate, "failed to generate nodeTemplateSourceInput")
}
@Test
fun testNodeTemplateSourceDefault() {
val nodeTemplate = BluePrintTypes.nodeTemplateSourceDefault("DefaultSystem", "") {
-
}
- //println(nodeTemplate.asJsonString(true))
+ // println(nodeTemplate.asJsonString(true))
assertNotNull(nodeTemplate, "failed to generate nodeTemplateSourceDefault")
}
@@ -91,7 +89,7 @@ class ResourceSourceDSLTest {
keyDependencies(arrayListOf("name"))
}
}
- //println(nodeTemplate.asJsonString(true))
+ // println(nodeTemplate.asJsonString(true))
assertNotNull(nodeTemplate, "failed to generate nodeTemplateSourceDb")
}
@@ -115,7 +113,7 @@ class ResourceSourceDSLTest {
keyDependencies(arrayListOf("name"))
}
}
- //println(nodeTemplate.asJsonString(true))
+ // println(nodeTemplate.asJsonString(true))
assertNotNull(nodeTemplate, "failed to generate nodeTemplateSourceRest")
}
@@ -128,7 +126,7 @@ class ResourceSourceDSLTest {
keyDependencies(arrayListOf("name"))
}
}
- //println(nodeTemplate.asJsonString(true))
+ // println(nodeTemplate.asJsonString(true))
assertNotNull(nodeTemplate, "failed to generate nodeTemplateSourceCapability")
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBServiceTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBServiceTest.kt
index dcf2e64a5..4f864a49c 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBServiceTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBServiceTest.kt
@@ -72,13 +72,15 @@ open class ResourceResolutionDBServiceTest {
val list = listOf(rr1, rr2)
every {
resourceResolutionRepository.findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKeyAndOccurrence(
- any(), any(), any(), any(), any())
+ any(), any(), any(), any(), any()
+ )
} returns list
runBlocking {
val res =
resourceResolutionDBService.findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKeyAndOccurrence(
- bluePrintRuntimeService, resolutionKey, occurrence, artifactPrefix)
+ bluePrintRuntimeService, resolutionKey, occurrence, artifactPrefix
+ )
assertEquals(2, res.size)
}
@@ -88,12 +90,14 @@ open class ResourceResolutionDBServiceTest {
fun findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKeyAndOccurrenceTestException() {
every {
resourceResolutionRepository.findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKeyAndOccurrence(
- any(), any(), any(), any(), any())
+ any(), any(), any(), any(), any()
+ )
} throws EmptyResultDataAccessException(1)
runBlocking {
val res =
resourceResolutionDBService.findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKeyAndOccurrence(
- bluePrintRuntimeService, resolutionKey, occurrence, artifactPrefix)
+ bluePrintRuntimeService, resolutionKey, occurrence, artifactPrefix
+ )
assert(res.isEmpty())
}
@@ -107,13 +111,15 @@ open class ResourceResolutionDBServiceTest {
val list = listOf(rr1, rr2)
every {
resourceResolutionRepository.findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResourceIdAndResourceTypeAndOccurrence(
- any(), any(), any(), any(), any(), any())
+ any(), any(), any(), any(), any(), any()
+ )
} returns list
runBlocking {
val res =
resourceResolutionDBService.findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResourceIdAndResourceTypeAndOccurrence(
- bluePrintRuntimeService, resourceId, resourceType, occurrence, artifactPrefix)
+ bluePrintRuntimeService, resourceId, resourceType, occurrence, artifactPrefix
+ )
assertEquals(2, res.size)
}
@@ -123,12 +129,14 @@ open class ResourceResolutionDBServiceTest {
fun findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResourceIdAndResourceTypeAndOccurrenceTestException() {
every {
resourceResolutionRepository.findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResourceIdAndResourceTypeAndOccurrence(
- any(), any(), any(), any(), any(), any())
+ any(), any(), any(), any(), any(), any()
+ )
} throws EmptyResultDataAccessException(1)
runBlocking {
val res =
resourceResolutionDBService.findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResourceIdAndResourceTypeAndOccurrence(
- bluePrintRuntimeService, resourceId, resourceType, occurrence, artifactPrefix)
+ bluePrintRuntimeService, resourceId, resourceType, occurrence, artifactPrefix
+ )
assert(res.isEmpty())
}
@@ -141,12 +149,14 @@ open class ResourceResolutionDBServiceTest {
rr.value = "testValue"
every {
resourceResolutionRepository.findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactNameAndName(
- any(), any(), any(), any(), any())
+ any(), any(), any(), any(), any()
+ )
} returns rr
runBlocking {
val res =
resourceResolutionDBService.readValue(
- blueprintName, blueprintVersion, artifactPrefix, resolutionKey, "bob")
+ blueprintName, blueprintVersion, artifactPrefix, resolutionKey, "bob"
+ )
assertEquals(rr.name, res.name)
assertEquals(rr.value, res.value)
@@ -160,12 +170,14 @@ open class ResourceResolutionDBServiceTest {
val list = listOf(rr1, rr2)
every {
resourceResolutionRepository.findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactName(
- any(), any(), any(), any())
+ any(), any(), any(), any()
+ )
} returns list
runBlocking {
val res =
resourceResolutionDBService.readWithResolutionKey(
- blueprintName, blueprintVersion, artifactPrefix, resolutionKey)
+ blueprintName, blueprintVersion, artifactPrefix, resolutionKey
+ )
assertEquals(2, res.size)
}
}
@@ -177,12 +189,14 @@ open class ResourceResolutionDBServiceTest {
val list = listOf(rr1, rr2)
every {
resourceResolutionRepository.findByBlueprintNameAndBlueprintVersionAndResourceIdAndResourceType(
- any(), any(), any(), any())
+ any(), any(), any(), any()
+ )
} returns list
runBlocking {
val res =
resourceResolutionDBService.readWithResourceIdAndResourceType(
- blueprintName, blueprintVersion, resourceId, resourceType)
+ blueprintName, blueprintVersion, resourceId, resourceType
+ )
assertEquals(2, res.size)
}
}
@@ -203,9 +217,10 @@ open class ResourceResolutionDBServiceTest {
runBlocking {
val res =
resourceResolutionDBService.write(
- props, bluePrintRuntimeService, artifactPrefix, resourceAssignment)
+ props, bluePrintRuntimeService, artifactPrefix, resourceAssignment
+ )
assertEquals(resourceResolution, res)
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionServiceTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionServiceTest.kt
index 48c6f02ef..18a9f3233 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionServiceTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionServiceTest.kt
@@ -54,11 +54,13 @@ class TemplateResolutionServiceTest {
runBlocking {
every {
templateResolutionRepository.findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
- any(), any(), any(), any(), any())
+ any(), any(), any(), any(), any()
+ )
} returns tr
val res =
templateResolutionService.findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactName(
- bluePrintRuntimeService, artifactPrefix, resolutionKey)
+ bluePrintRuntimeService, artifactPrefix, resolutionKey
+ )
assertEquals(tr.result, res)
}
}
@@ -69,10 +71,12 @@ class TemplateResolutionServiceTest {
runBlocking {
every {
templateResolutionRepository.findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
- any(), any(), any(), any(), any())
+ any(), any(), any(), any(), any()
+ )
} returns tr
templateResolutionService.findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactName(
- bluePrintRuntimeService, artifactPrefix, resolutionKey)
+ bluePrintRuntimeService, artifactPrefix, resolutionKey
+ )
}
}
@@ -83,7 +87,8 @@ class TemplateResolutionServiceTest {
every { templateResolutionRepository.saveAndFlush(any<TemplateResolution>()) } returns tr
every {
templateResolutionRepository.findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
- any(), any(), any(), any(), any())
+ any(), any(), any(), any(), any()
+ )
} returns null
val res = templateResolutionService.write(props, result, bluePrintRuntimeService, artifactPrefix)
assertEquals(tr, res)
@@ -97,16 +102,19 @@ class TemplateResolutionServiceTest {
every { templateResolutionRepository.saveAndFlush(any<TemplateResolution>()) } returns tr
every {
templateResolutionRepository.findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
- any(), any(), any(), any(), any())
+ any(), any(), any(), any(), any()
+ )
} returns tr
every {
templateResolutionRepository.deleteByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
- any(), any(), any(), any(), any())
+ any(), any(), any(), any(), any()
+ )
} returns Unit
val res = templateResolutionService.write(props, result, bluePrintRuntimeService, artifactPrefix)
verify {
templateResolutionRepository.deleteByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
- eq(resolutionKey), eq(blueprintName), eq(blueprintVersion), eq(artifactPrefix), eq(occurrence))
+ eq(resolutionKey), eq(blueprintName), eq(blueprintVersion), eq(artifactPrefix), eq(occurrence)
+ )
}
assertEquals(tr, res)
}
@@ -120,18 +128,21 @@ class TemplateResolutionServiceTest {
every { templateResolutionRepository.saveAndFlush(any<TemplateResolution>()) } returns tr
every {
templateResolutionRepository.findByResourceIdAndResourceTypeAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
- any(), any(), any(), any(), any(), any())
+ any(), any(), any(), any(), any(), any()
+ )
} returns tr
every {
templateResolutionRepository.deleteByResourceIdAndResourceTypeAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
- any(), any(), any(), any(), any(), any())
+ any(), any(), any(), any(), any(), any()
+ )
} returns Unit
val res = templateResolutionService.write(props, result, bluePrintRuntimeService, artifactPrefix)
verify {
templateResolutionRepository.deleteByResourceIdAndResourceTypeAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
- eq(resourceId), eq(resourceType), eq(blueprintName), eq(blueprintVersion), eq(artifactPrefix), eq(occurrence))
+ eq(resourceId), eq(resourceType), eq(blueprintName), eq(blueprintVersion), eq(artifactPrefix), eq(occurrence)
+ )
}
assertEquals(tr, res)
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBlueprintResLibPropertyService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBluePrintRestLibPropertyService.kt
index f64ba2bbd..d6331fe33 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBlueprintResLibPropertyService.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBluePrintRestLibPropertyService.kt
@@ -20,9 +20,9 @@ import org.onap.ccsdk.cds.blueprintsprocessor.rest.RestClientProperties
import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BluePrintRestLibPropertyService
class MockBluePrintRestLibPropertyService(bluePrintProperties: BluePrintPropertiesService) :
- BluePrintRestLibPropertyService(bluePrintProperties) {
+ BluePrintRestLibPropertyService(bluePrintProperties) {
- fun mockBlueprintWebClientService (selector: String):
+ fun mockBlueprintWebClientService(selector: String):
MockBlueprintWebClientService {
val prefix = "blueprintsprocessor.restclient.$selector"
val restClientProperties = restClientProperties(prefix)
@@ -33,4 +33,4 @@ class MockBluePrintRestLibPropertyService(bluePrintProperties: BluePrintProperti
MockBlueprintWebClientService {
return MockBlueprintWebClientService(restClientProperties)
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBlueprintWebClientService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBlueprintWebClientService.kt
index fede7be7b..ef5c79eab 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBlueprintWebClientService.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBlueprintWebClientService.kt
@@ -25,32 +25,37 @@ import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientSer
import org.springframework.http.HttpHeaders
import org.springframework.http.MediaType
import java.nio.charset.Charset
-import java.util.*
+import java.util.Base64
-class MockBlueprintWebClientService(private var restClientProperties: RestClientProperties): BlueprintWebClientService {
+class MockBlueprintWebClientService(private var restClientProperties: RestClientProperties) : BlueprintWebClientService {
private var mockServer: ClientAndServer
private var port: String = if (restClientProperties.url.split(":")[2].isEmpty()) "8080"
- else restClientProperties.url.split(":")[2]
+ else restClientProperties.url.split(":")[2]
private var headers: Map<String, String>
init {
- mockServer = ClientAndServer.startClientAndServer(port.toInt())
- headers = defaultHeaders()
+ mockServer = ClientAndServer.startClientAndServer(port.toInt())
+ headers = defaultHeaders()
// Create expected requests and responses
setRequest("GET", "/aai/v14/network/generic-vnfs/generic-vnf/123456")
- setRequest("GET", "/config/GENERIC-RESOURCE-API:services/service/10/service-data/vnfs/vnf/123456/" +
- "vnf-data/vnf-topology/vnf-parameters-data/param/vnf_name")
- setRequestWithPayload("PUT", "/query",
- "{\r\n\"start\": \"\\/nodes\\/vf-modules?vf-module-name=vf-module-name\",\r\n\"query\": \"\\/query\\/related-to?startingNodeType=vf-module&relatedToNodeType=generic-vnf\"\r\n}")
+ setRequest(
+ "GET", "/config/GENERIC-RESOURCE-API:services/service/10/service-data/vnfs/vnf/123456/" +
+ "vnf-data/vnf-topology/vnf-parameters-data/param/vnf_name"
+ )
+ setRequestWithPayload(
+ "PUT", "/query",
+ "{\r\n\"start\": \"\\/nodes\\/vf-modules?vf-module-name=vf-module-name\",\r\n\"query\": \"\\/query\\/related-to?startingNodeType=vf-module&relatedToNodeType=generic-vnf\"\r\n}"
+ )
}
override fun defaultHeaders(): Map<String, String> {
val encodedCredentials = this.setBasicAuth("admin", "aaiTest")
return mapOf(
- HttpHeaders.CONTENT_TYPE to MediaType.APPLICATION_JSON_VALUE,
- HttpHeaders.ACCEPT to MediaType.APPLICATION_JSON_VALUE,
- HttpHeaders.AUTHORIZATION to "Basic $encodedCredentials")
+ HttpHeaders.CONTENT_TYPE to MediaType.APPLICATION_JSON_VALUE,
+ HttpHeaders.ACCEPT to MediaType.APPLICATION_JSON_VALUE,
+ HttpHeaders.AUTHORIZATION to "Basic $encodedCredentials"
+ )
}
override fun host(uri: String): String {
@@ -87,11 +92,11 @@ class MockBlueprintWebClientService(private var restClientProperties: RestClient
else -> {
"Get response"
}
-
}
- mockServer.`when`(request().withHeaders(Header(HttpHeaders.AUTHORIZATION, headers[HttpHeaders.AUTHORIZATION]))
- .withMethod(method)
- .withPath(path)
+ mockServer.`when`(
+ request().withHeaders(Header(HttpHeaders.AUTHORIZATION, headers[HttpHeaders.AUTHORIZATION]))
+ .withMethod(method)
+ .withPath(path)
).respond(response().withStatusCode(200).withBody("{\"aai-resource\":\"$requestResponse\"}"))
}
@@ -106,9 +111,9 @@ class MockBlueprintWebClientService(private var restClientProperties: RestClient
else -> {
"Get response"
}
-
}
- mockServer.`when`(request().withHeaders(Header(HttpHeaders.AUTHORIZATION, headers[HttpHeaders.AUTHORIZATION]))
+ mockServer.`when`(
+ request().withHeaders(Header(HttpHeaders.AUTHORIZATION, headers[HttpHeaders.AUTHORIZATION]))
.withMethod(method)
.withPath(path)
.withQueryStringParameter("format", "resource")
@@ -119,6 +124,7 @@ class MockBlueprintWebClientService(private var restClientProperties: RestClient
private fun setBasicAuth(username: String, password: String): String {
val credentialsString = "$username:$password"
return Base64.getEncoder().encodeToString(
- credentialsString.toByteArray(Charset.defaultCharset()))
+ credentialsString.toByteArray(Charset.defaultCharset())
+ )
}
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockDatabaseConfiguration.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockDatabaseConfiguration.kt
index 7644df37a..0a4de9218 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockDatabaseConfiguration.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockDatabaseConfiguration.kt
@@ -28,7 +28,7 @@ open class MockDatabaseConfiguration {
@Bean(name = ["MariaDatabaseConfiguration", "MySqlDatabaseConfiguration", "PrimaryDatabaseConfiguration"])
open fun createDatabaseConfiguration(): BluePrintDBLibGenericService {
- return mockk<BluePrintDBLibGenericService>()
+ return mockk<BluePrintDBLibGenericService>()
}
}
@@ -42,6 +42,4 @@ open class MockBlueprintProcessorCatalogServiceImpl {
every { bluePrintValidatorService.validateBluePrints(any<BluePrintRuntimeService<*>>()) } returns true
return bluePrintValidatorService
}
-
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockRestResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockRestResourceResolutionProcessor.kt
index e5b559826..a7379e22a 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockRestResourceResolutionProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockRestResourceResolutionProcessor.kt
@@ -29,10 +29,12 @@ import org.onap.ccsdk.cds.controllerblueprints.core.nullToEmpty
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
import org.slf4j.LoggerFactory
-import java.util.*
+import java.util.HashMap
-class MockRestResourceResolutionProcessor(private val blueprintRestLibPropertyService:
- MockBluePrintRestLibPropertyService) : ResourceAssignmentProcessor() {
+class MockRestResourceResolutionProcessor(
+ private val blueprintRestLibPropertyService:
+ MockBluePrintRestLibPropertyService
+) : ResourceAssignmentProcessor() {
private val logger = LoggerFactory.getLogger(MockRestResourceResolutionProcessor::class.java)
@@ -77,8 +79,10 @@ class MockRestResourceResolutionProcessor(private val blueprintRestLibPropertySe
resolveFromInputKeyMapping(checkNotNull(sourceProperties.urlPath), resolvedInputKeyMapping)
val verb = resolveFromInputKeyMapping(nullToEmpty(sourceProperties.verb), resolvedInputKeyMapping)
- logger.info("MockRestResource ($dSource) dictionary information: " +
- "URL:($urlPath), input-key-mapping:($inputKeyMapping), output-key-mapping:(${sourceProperties.outputKeyMapping})")
+ logger.info(
+ "MockRestResource ($dSource) dictionary information: " +
+ "URL:($urlPath), input-key-mapping:($inputKeyMapping), output-key-mapping:(${sourceProperties.outputKeyMapping})"
+ )
// Get the Rest Client Service
val restClientService = blueprintWebClientService(executionRequest)
@@ -90,7 +94,8 @@ class MockRestResourceResolutionProcessor(private val blueprintRestLibPropertySe
populateResource(executionRequest, sourceProperties, responseBody, path)
restClientService.tearDown()
} else {
- val errMsg = "Failed to get $dSource result for dictionary name ($dName) using urlPath ($urlPath) response_code: ($responseStatusCode)"
+ val errMsg =
+ "Failed to get $dSource result for dictionary name ($dName) using urlPath ($urlPath) response_code: ($responseStatusCode)"
logger.warn(errMsg)
throw BluePrintProcessorException(errMsg)
}
@@ -110,8 +115,12 @@ class MockRestResourceResolutionProcessor(private val blueprintRestLibPropertySe
}
@Throws(BluePrintProcessorException::class)
- private fun populateResource(resourceAssignment: ResourceAssignment, sourceProperties: RestResourceSource,
- restResponse: String, path: String) {
+ private fun populateResource(
+ resourceAssignment: ResourceAssignment,
+ sourceProperties: RestResourceSource,
+ restResponse: String,
+ path: String
+ ) {
val type = nullToEmpty(resourceAssignment.property?.type)
lateinit var entrySchemaType: String
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt
index 98f68ebaa..8f6ac9fd5 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt
@@ -140,9 +140,7 @@ class CapabilityResourceResolutionProcessorTest {
}
}
-open class MockCapabilityService {
-
-}
+open class MockCapabilityService
open class MockCapabilityScriptRA : ResourceAssignmentProcessor() {
val log = logger(MockCapabilityScriptRA::class)
@@ -157,6 +155,6 @@ open class MockCapabilityScriptRA : ResourceAssignmentProcessor() {
}
override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ResourceAssignment) {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ TODO("not implemented") // To change body of created functions use File | Settings | File Templates.
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceResolutionProcessorTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceResolutionProcessorTest.kt
index ac5ba3c46..da2282018 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceResolutionProcessorTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceResolutionProcessorTest.kt
@@ -22,7 +22,7 @@ import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintCoreConfiguration
import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertiesService
import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertyConfiguration
import org.onap.ccsdk.cds.blueprintsprocessor.db.BluePrintDBLibConfiguration
-import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.BluePrintDBLibPropertySevice
+import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.BluePrintDBLibPropertyService
import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.PrimaryDatabaseConfiguration
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceAssignmentRuntimeService
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.mock.MockBlueprintProcessorCatalogServiceImpl
@@ -38,10 +38,12 @@ import org.springframework.test.context.junit4.SpringRunner
import kotlin.test.assertNotNull
@RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [DatabaseResourceAssignmentProcessor::class, BluePrintPropertyConfiguration::class,
- BluePrintPropertiesService::class, BluePrintDBLibPropertySevice::class, BluePrintDBLibConfiguration::class,
- BluePrintCoreConfiguration::class, MockDatabaseConfiguration::class, MockBlueprintProcessorCatalogServiceImpl::class,
- BluePrintPropertiesService::class, PrimaryDatabaseConfiguration::class])
+@ContextConfiguration(
+ classes = [DatabaseResourceAssignmentProcessor::class, BluePrintPropertyConfiguration::class,
+ BluePrintPropertiesService::class, BluePrintDBLibPropertyService::class, BluePrintDBLibConfiguration::class,
+ BluePrintCoreConfiguration::class, MockDatabaseConfiguration::class, MockBlueprintProcessorCatalogServiceImpl::class,
+ BluePrintPropertiesService::class, PrimaryDatabaseConfiguration::class]
+)
@TestPropertySource(locations = ["classpath:application-test.properties"])
class DatabaseResourceResolutionProcessorTest {
@@ -52,13 +54,14 @@ class DatabaseResourceResolutionProcessorTest {
fun `test database resource resolution processor db`() {
runBlocking {
val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(
- "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
val resourceAssignmentRuntimeService = ResourceAssignmentRuntimeService("1234", bluePrintContext)
databaseResourceAssignmentProcessor.raRuntimeService = resourceAssignmentRuntimeService
databaseResourceAssignmentProcessor.resourceDictionaries = ResourceAssignmentUtils
- .resourceDefinitions(bluePrintContext.rootPath)
+ .resourceDefinitions(bluePrintContext.rootPath)
val resourceAssignment = ResourceAssignment().apply {
name = "service-instance-id"
@@ -73,4 +76,4 @@ class DatabaseResourceResolutionProcessorTest {
assertNotNull(processorName, "couldn't get Database resource assignment processor name")
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessorTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessorTest.kt
index 093a3347a..a109131fe 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessorTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessorTest.kt
@@ -40,7 +40,8 @@ class DefaultResourceResolutionProcessorTest {
fun `test default resource resolution`() {
runBlocking {
val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(
- "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
val resourceAssignmentRuntimeService = ResourceAssignmentRuntimeService("1234", bluePrintContext)
@@ -61,4 +62,4 @@ class DefaultResourceResolutionProcessorTest {
println(processorName)
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessorTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessorTest.kt
index 242739067..17bb5e6b0 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessorTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessorTest.kt
@@ -46,13 +46,14 @@ class InputResourceResolutionProcessorTest {
runBlocking {
val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(
- "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
val resourceAssignmentRuntimeService = spyk(ResourceAssignmentRuntimeService("1234", bluePrintContext))
// mocking input for resource resolution
val textNode: JsonNode = TextNode("any value")
- every {resourceAssignmentRuntimeService.getInputValue("rr-name") } returns textNode
+ every { resourceAssignmentRuntimeService.getInputValue("rr-name") } returns textNode
inputResourceResolutionProcessor.raRuntimeService = resourceAssignmentRuntimeService
inputResourceResolutionProcessor.resourceDictionaries = ResourceAssignmentUtils.resourceDefinitions(bluePrintContext.rootPath)
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessorTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessorTest.kt
index 1c0f33fcd..af78a604a 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessorTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessorTest.kt
@@ -36,17 +36,20 @@ import kotlin.test.BeforeTest
import kotlin.test.assertNotNull
@RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [MockRestResourceResolutionProcessor::class, MockBluePrintRestLibPropertyService::class,
- BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, RestClientProperties::class])
+@ContextConfiguration(
+ classes = [MockRestResourceResolutionProcessor::class, MockBluePrintRestLibPropertyService::class,
+ BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, RestClientProperties::class]
+)
@TestPropertySource(locations = ["classpath:application-test.properties"])
class RestResourceResolutionProcessorTest {
+
@Autowired
lateinit var bluePrintRestLibPropertyService: MockBluePrintRestLibPropertyService
private lateinit var restResourceResolutionProcessor: MockRestResourceResolutionProcessor
@BeforeTest
- fun init(){
+ fun init() {
restResourceResolutionProcessor = MockRestResourceResolutionProcessor(bluePrintRestLibPropertyService)
}
@@ -54,13 +57,14 @@ class RestResourceResolutionProcessorTest {
fun `test rest resource resolution`() {
runBlocking {
val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(
- "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
val resourceAssignmentRuntimeService = ResourceAssignmentRuntimeService("1234", bluePrintContext)
restResourceResolutionProcessor.raRuntimeService = resourceAssignmentRuntimeService
restResourceResolutionProcessor.resourceDictionaries = ResourceAssignmentUtils
- .resourceDefinitions(bluePrintContext.rootPath)
+ .resourceDefinitions(bluePrintContext.rootPath)
val scriptPropertyInstances: MutableMap<String, Any> = mutableMapOf()
scriptPropertyInstances["mock-service1"] = MockCapabilityService()
@@ -87,13 +91,14 @@ class RestResourceResolutionProcessorTest {
fun `test rest aai get resource resolution`() {
runBlocking {
val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(
- "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
val resourceAssignmentRuntimeService = ResourceAssignmentRuntimeService("1234", bluePrintContext)
restResourceResolutionProcessor.raRuntimeService = resourceAssignmentRuntimeService
restResourceResolutionProcessor.resourceDictionaries = ResourceAssignmentUtils
- .resourceDefinitions(bluePrintContext.rootPath)
+ .resourceDefinitions(bluePrintContext.rootPath)
val scriptPropertyInstances: MutableMap<String, Any> = mutableMapOf()
scriptPropertyInstances["mock-service1"] = MockCapabilityService()
@@ -120,13 +125,14 @@ class RestResourceResolutionProcessorTest {
fun `test rest aai put resource resolution`() {
runBlocking {
val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(
- "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
val resourceAssignmentRuntimeService = ResourceAssignmentRuntimeService("1234", bluePrintContext)
restResourceResolutionProcessor.raRuntimeService = resourceAssignmentRuntimeService
restResourceResolutionProcessor.resourceDictionaries = ResourceAssignmentUtils
- .resourceDefinitions(bluePrintContext.rootPath)
+ .resourceDefinitions(bluePrintContext.rootPath)
val scriptPropertyInstances: MutableMap<String, Any> = mutableMapOf()
scriptPropertyInstances["mock-service1"] = MockCapabilityService()
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtilsTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtilsTest.kt
index d7a696848..7631339e8 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtilsTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtilsTest.kt
@@ -64,11 +64,12 @@ class ResourceAssignmentUtilsTest {
fun setup() {
val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(
- "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
resourceAssignmentRuntimeService = spyk(ResourceAssignmentRuntimeService("1234", bluePrintContext))
- //Init input map and expected values for tests
+ // Init input map and expected values for tests
initInputMapAndExpectedValuesForPrimitiveType()
initInputMapAndExpectedValuesForCollection()
initInputMapAndExpectedValuesForComplexType()
@@ -120,35 +121,34 @@ class ResourceAssignmentUtilsTest {
@Test
fun `generateResourceDataForAssignments - positive test`() {
- //given a valid resource assignment
+ // given a valid resource assignment
val validResourceAssignment = createResourceAssignmentForTest("valid_value")
- //and a list containing that resource assignment
+ // and a list containing that resource assignment
val resourceAssignmentList = listOf<ResourceAssignment>(validResourceAssignment)
- //when the values of the resources are evaluated
+ // when the values of the resources are evaluated
val outcome = ResourceAssignmentUtils.generateResourceDataForAssignments(resourceAssignmentList)
- //then the assignment should produce a valid result
+ // then the assignment should produce a valid result
val expected = "{\n" + " \"pnf-id\" : \"valid_value\"\n" + "}"
- assertEquals(expected, outcome.replace("\r\n","\n"), "unexpected outcome generated")
+ assertEquals(expected, outcome.replace("\r\n", "\n"), "unexpected outcome generated")
}
@Test
fun `generateResourceDataForAssignments - resource without value is not resolved as null`() {
- //given a valid resource assignment
+ // given a valid resource assignment
val resourceAssignmentWithNullValue = createResourceAssignmentForTest(null)
- //and a list containing that resource assignment
+ // and a list containing that resource assignment
val resourceAssignmentList = listOf<ResourceAssignment>(resourceAssignmentWithNullValue)
- //when the values of the resources are evaluated
+ // when the values of the resources are evaluated
val outcome = ResourceAssignmentUtils.generateResourceDataForAssignments(resourceAssignmentList)
- //then the assignment should produce a valid result
+ // then the assignment should produce a valid result
val expected = "{\n" + " \"pnf-id\" : \"\${pnf-id}\"\n" + "}"
- assertEquals(expected, outcome.replace("\r\n","\n"), "unexpected outcome generated")
-
+ assertEquals(expected, outcome.replace("\r\n", "\n"), "unexpected outcome generated")
}
private fun createResourceAssignmentForTest(resourceValue: String?): ResourceAssignment {
@@ -166,61 +166,77 @@ class ResourceAssignmentUtilsTest {
}
@Test
- fun parseResponseNodeTestForPrimitivesTypes(){
- var outcome = prepareResponseNodeForTest("sample-value", "string", "",
- inputMapToTestPrimitiveTypeWithValue)
+ fun parseResponseNodeTestForPrimitivesTypes() {
+ var outcome = prepareResponseNodeForTest(
+ "sample-value", "string", "",
+ inputMapToTestPrimitiveTypeWithValue
+ )
assertEquals(expectedValueToTestPrimitiveType, outcome, "Unexpected outcome returned for primitive type of simple String")
- outcome = prepareResponseNodeForTest("sample-key-value", "string", "",
- inputMapToTestPrimitiveTypeWithKeyValue)
+ outcome = prepareResponseNodeForTest(
+ "sample-key-value", "string", "",
+ inputMapToTestPrimitiveTypeWithKeyValue
+ )
assertEquals(expectedValueToTestPrimitiveType, outcome, "Unexpected outcome returned for primitive type of key-value String")
}
@Test
- fun parseResponseNodeTestForCollectionsOfString(){
- var outcome = prepareResponseNodeForTest("listOfString", "list",
- "string", inputMapToTestCollectionOfPrimitiveType)
+ fun parseResponseNodeTestForCollectionsOfString() {
+ var outcome = prepareResponseNodeForTest(
+ "listOfString", "list",
+ "string", inputMapToTestCollectionOfPrimitiveType
+ )
assertEquals(expectedValueToTesCollectionOfPrimitiveType, outcome, "unexpected outcome returned for list of String")
- outcome = prepareResponseNodeForTest("mapOfString", "map", "string",
- inputMapToTestCollectionOfPrimitiveType)
+ outcome = prepareResponseNodeForTest(
+ "mapOfString", "map", "string",
+ inputMapToTestCollectionOfPrimitiveType
+ )
assertEquals(expectedValueToTesCollectionOfPrimitiveType, outcome, "unexpected outcome returned for map of String")
}
@Test
- fun parseResponseNodeTestForCollectionsOfComplexType(){
- var outcome = prepareResponseNodeForTest("listOfMyDataTypeWithOneOutputKeyMapping", "list",
- "ip-address", inputMapToTestCollectionOfComplexTypeWithOneOutputKeyMapping)
+ fun parseResponseNodeTestForCollectionsOfComplexType() {
+ var outcome = prepareResponseNodeForTest(
+ "listOfMyDataTypeWithOneOutputKeyMapping", "list",
+ "ip-address", inputMapToTestCollectionOfComplexTypeWithOneOutputKeyMapping
+ )
assertEquals(expectedValueToTestCollectionOfComplexTypeWithOneOutputKeyMapping, outcome, "unexpected outcome returned for list of String")
- outcome = prepareResponseNodeForTest("listOfMyDataTypeWithAllOutputKeyMapping", "list",
- "ip-address", inputMapToTestCollectionOfComplexTypeWithAllOutputKeyMapping)
+ outcome = prepareResponseNodeForTest(
+ "listOfMyDataTypeWithAllOutputKeyMapping", "list",
+ "ip-address", inputMapToTestCollectionOfComplexTypeWithAllOutputKeyMapping
+ )
assertEquals(expectedValueToTestCollectionOfComplexTypeWithAllOutputKeyMapping, outcome, "unexpected outcome returned for list of String")
}
@Test
- fun `parseResponseNodeTestForComplexType find one output key mapping`(){
- val outcome = prepareResponseNodeForTest("complexTypeOneKeys", "host",
- "", inputMapToTestComplexTypeWithOneOutputKeyMapping)
+ fun `parseResponseNodeTestForComplexType find one output key mapping`() {
+ val outcome = prepareResponseNodeForTest(
+ "complexTypeOneKeys", "host",
+ "", inputMapToTestComplexTypeWithOneOutputKeyMapping
+ )
assertEquals(expectedValueToTestComplexTypeWithOneOutputKeyMapping, outcome, "Unexpected outcome returned for complex type")
}
@Test
- fun `parseResponseNodeTestForComplexType find all output key mapping`(){
- val outcome = prepareResponseNodeForTest("complexTypeAllKeys", "host",
- "", inputMapToTestComplexTypeWithAllOutputKeyMapping)
+ fun `parseResponseNodeTestForComplexType find all output key mapping`() {
+ val outcome = prepareResponseNodeForTest(
+ "complexTypeAllKeys", "host",
+ "", inputMapToTestComplexTypeWithAllOutputKeyMapping
+ )
assertEquals(expectedValueToTestComplexTypeWithAllOutputKeyMapping, outcome, "Unexpected outcome returned for complex type")
}
private fun initInputMapAndExpectedValuesForPrimitiveType() {
inputMapToTestPrimitiveTypeWithValue = "1.2.3.1".asJsonType()
val keyValue = mutableMapOf<String, String>()
- keyValue["value"]= "1.2.3.1"
+ keyValue["value"] = "1.2.3.1"
inputMapToTestPrimitiveTypeWithKeyValue = keyValue.asJsonType()
expectedValueToTestPrimitiveType = TextNode("1.2.3.1")
}
- private fun initInputMapAndExpectedValuesForCollection(){
+ private fun initInputMapAndExpectedValuesForCollection() {
val listOfIps = arrayListOf("1.2.3.1", "1.2.3.2", "1.2.3.3")
val arrayNodeForList1 = JacksonUtils.objectMapper.createArrayNode()
listOfIps.forEach {
@@ -230,12 +246,15 @@ class ResourceAssignmentUtilsTest {
}
inputMapToTestCollectionOfPrimitiveType = arrayNodeForList1
- expectedValueToTesCollectionOfPrimitiveType = arrayListOf(ExpectedResponseIp("1.2.3.1"),
- ExpectedResponseIp( "1.2.3.2"), ExpectedResponseIp("1.2.3.3")).asJsonType()
-
+ expectedValueToTesCollectionOfPrimitiveType = arrayListOf(
+ ExpectedResponseIp("1.2.3.1"),
+ ExpectedResponseIp("1.2.3.2"), ExpectedResponseIp("1.2.3.3")
+ ).asJsonType()
- val listOfIpAddresses = arrayListOf(IpAddress("1111", "1.2.3.1").asJsonType(),
- IpAddress("2222", "1.2.3.2").asJsonType(), IpAddress("3333", "1.2.3.3").asJsonType())
+ val listOfIpAddresses = arrayListOf(
+ IpAddress("1111", "1.2.3.1").asJsonType(),
+ IpAddress("2222", "1.2.3.2").asJsonType(), IpAddress("3333", "1.2.3.3").asJsonType()
+ )
val arrayNodeForList2 = JacksonUtils.objectMapper.createArrayNode()
listOfIpAddresses.forEach {
val arrayChildNode = JacksonUtils.objectMapper.createObjectNode()
@@ -259,15 +278,20 @@ class ResourceAssignmentUtilsTest {
arrayNodeForList3.add(childNode)
inputMapToTestCollectionOfComplexTypeWithAllOutputKeyMapping = arrayNodeForList3
- expectedValueToTestCollectionOfComplexTypeWithOneOutputKeyMapping = arrayListOf(ExpectedResponseIpAddress(IpAddress("1111", "1.2.3.1")),
- ExpectedResponseIpAddress(IpAddress("2222", "1.2.3.2")), ExpectedResponseIpAddress(
- IpAddress("3333", "1.2.3.3"))).asJsonType()
- expectedValueToTestCollectionOfComplexTypeWithAllOutputKeyMapping = arrayListOf(IpAddress("1111", "1.2.3.1"),
- IpAddress("2222", "1.2.3.2"),
- IpAddress("3333", "1.2.3.3")).asJsonType()
+ expectedValueToTestCollectionOfComplexTypeWithOneOutputKeyMapping = arrayListOf(
+ ExpectedResponseIpAddress(IpAddress("1111", "1.2.3.1")),
+ ExpectedResponseIpAddress(IpAddress("2222", "1.2.3.2")), ExpectedResponseIpAddress(
+ IpAddress("3333", "1.2.3.3")
+ )
+ ).asJsonType()
+ expectedValueToTestCollectionOfComplexTypeWithAllOutputKeyMapping = arrayListOf(
+ IpAddress("1111", "1.2.3.1"),
+ IpAddress("2222", "1.2.3.2"),
+ IpAddress("3333", "1.2.3.3")
+ ).asJsonType()
}
- private fun initInputMapAndExpectedValuesForComplexType(){
+ private fun initInputMapAndExpectedValuesForComplexType() {
val mapOfComplexType = mutableMapOf<String, JsonNode>()
mapOfComplexType["value"] = Host("my-ipAddress", IpAddress("1111", "1.2.3.1")).asJsonType()
mapOfComplexType["port"] = "8888".asJsonType()
@@ -275,7 +299,8 @@ class ResourceAssignmentUtilsTest {
inputMapToTestComplexTypeWithOneOutputKeyMapping = mapOfComplexType.asJsonType()
val objectNode = JacksonUtils.objectMapper.createObjectNode()
- expectedValueToTestComplexTypeWithOneOutputKeyMapping = objectNode.set("host", Host("my-ipAddress", IpAddress("1111", "1.2.3.1")).asJsonType())
+ expectedValueToTestComplexTypeWithOneOutputKeyMapping =
+ objectNode.set("host", Host("my-ipAddress", IpAddress("1111", "1.2.3.1")).asJsonType())
val childNode1 = JacksonUtils.objectMapper.createObjectNode()
childNode1.set("name", "my-ipAddress".asJsonPrimitive())
@@ -290,8 +315,12 @@ class ResourceAssignmentUtilsTest {
expectedValueToTestComplexTypeWithAllOutputKeyMapping = childNode2
}
- private fun prepareResponseNodeForTest(dictionary_source: String, sourceType: String, entrySchema: String,
- response: Any): JsonNode {
+ private fun prepareResponseNodeForTest(
+ dictionary_source: String,
+ sourceType: String,
+ entrySchema: String,
+ response: Any
+ ): JsonNode {
val resourceAssignment = when (sourceType) {
"list", "map" -> {
@@ -355,16 +384,16 @@ class ResourceAssignmentUtilsTest {
when (dictionary_source) {
"sample-key-value", "sample-value" -> {
- //Primary Type
- if (dictionary_source=="sample-key-value")
+ // Primary Type
+ if (dictionary_source == "sample-key-value")
outputMapping["sample-ip"] = "value"
}
"listOfString", "mapOfString" -> {
- //List of string
+ // List of string
outputMapping["ip"] = "value"
}
"listOfMyDataTypeWithOneOutputKeyMapping", "listOfMyDataTypeWithAllOutputKeyMapping" -> {
- //List or map of complex Type
+ // List or map of complex Type
if (dictionary_source == "listOfMyDataTypeWithOneOutputKeyMapping")
outputMapping["ipAddress"] = "value"
else {
@@ -373,16 +402,15 @@ class ResourceAssignmentUtilsTest {
}
}
else -> {
- //Complex Type
+ // Complex Type
if (dictionary_source == "complexTypeOneKeys")
outputMapping["host"] = "value"
else {
outputMapping["name"] = "name"
outputMapping["ipAddress"] = "ipAddress"
}
-
}
}
return outputMapping
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/internal/scripts/InternalSimpleRestconf.kt b/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/internal/scripts/InternalSimpleRestconf.kt
index c4553abd6..6e468509f 100644
--- a/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/internal/scripts/InternalSimpleRestconf.kt
+++ b/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/internal/scripts/InternalSimpleRestconf.kt
@@ -14,6 +14,7 @@
* limitations under the License.
*/
@file:Suppress("unused")
+
package internal.scripts
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
@@ -29,12 +30,12 @@ open class EditConfigure : AbstractScriptComponentFunction() {
}
override suspend fun processNB(executionRequest: ExecutionServiceInput) {
- //val webClientService = restClientService("odlparent")
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ // val webClientService = restClientService("odlparent")
+ TODO("not implemented") // To change body of created functions use File | Settings | File Templates.
}
override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ TODO("not implemented") // To change body of created functions use File | Settings | File Templates.
}
}
@@ -53,7 +54,6 @@ open class MountNEditConfigure : AbstractScriptComponentFunction() {
override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
addError("failed in restconf execution : ${runtimeException.message}")
}
-
}
/**
diff --git a/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restconf/executor/RestconfExecutorConfiguration.kt b/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restconf/executor/RestconfExecutorConfiguration.kt
index 11e774315..ff6714f21 100644
--- a/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restconf/executor/RestconfExecutorConfiguration.kt
+++ b/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restconf/executor/RestconfExecutorConfiguration.kt
@@ -21,9 +21,8 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.context.annotation.ComponentScan
import org.springframework.context.annotation.Configuration
-
@Configuration
@ComponentScan
@EnableConfigurationProperties
@ConditionalOnProperty(name = ["blueprintsprocessor.restconfEnabled"], havingValue = "true")
-open class RestconfExecutorConfiguration \ No newline at end of file
+open class RestconfExecutorConfiguration
diff --git a/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restconf/executor/RestconfExecutorExtensions.kt b/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restconf/executor/RestconfExecutorExtensions.kt
index 11a35eede..906bef9a4 100644
--- a/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restconf/executor/RestconfExecutorExtensions.kt
+++ b/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restconf/executor/RestconfExecutorExtensions.kt
@@ -38,10 +38,12 @@ fun AbstractScriptComponentFunction.restconfClientService(selector: String): Blu
* Generic Mount function
*/
-suspend fun AbstractScriptComponentFunction.restconfMountDevice(webClientService: BlueprintWebClientService,
- deviceId: String,
- payload: Any,
- headers: Map<String, String> = mutableMapOf("Content-Type" to "application/xml")) {
+suspend fun AbstractScriptComponentFunction.restconfMountDevice(
+ webClientService: BlueprintWebClientService,
+ deviceId: String,
+ payload: Any,
+ headers: Map<String, String> = mutableMapOf("Content-Type" to "application/xml")
+) {
val mountUrl = "restconf/config/network-topology:network-topology/topology/topology-netconf/node/$deviceId"
log.info("sending mount request, url: $mountUrl")
@@ -68,23 +70,28 @@ suspend fun AbstractScriptComponentFunction.restconfMountDevice(webClientService
/**
* Generic Configure function
*/
-suspend fun AbstractScriptComponentFunction.restconfApplyDeviceConfig(webClientService: BlueprintWebClientService,
- deviceId: String, configletResourcePath: String,
- configletToApply: Any,
- additionalHeaders: Map<String, String > = mutableMapOf("Content-Type" to "application/yang.patch+xml")) {
+suspend fun AbstractScriptComponentFunction.restconfApplyDeviceConfig(
+ webClientService: BlueprintWebClientService,
+ deviceId: String,
+ configletResourcePath: String,
+ configletToApply: Any,
+ additionalHeaders: Map<String, String> = mutableMapOf("Content-Type" to "application/yang.patch+xml")
+) {
log.debug("headers: $additionalHeaders")
log.info("configuring device: $deviceId, Configlet: $configletToApply")
val applyConfigUrl = "restconf/config/network-topology:network-topology/topology/topology-netconf/node/" +
"$deviceId/$configletResourcePath"
- val result:Any = webClientService.exchangeResource("PATCH", applyConfigUrl, configletToApply as String, additionalHeaders)
+ val result: Any = webClientService.exchangeResource("PATCH", applyConfigUrl, configletToApply as String, additionalHeaders)
log.info("Configuration application result: $result")
}
-
-suspend fun AbstractScriptComponentFunction.restconfDeviceConfig(webClientService: BlueprintWebClientService,
- deviceId: String, configletResourcePath: String)
- : BlueprintWebClientService.WebClientResponse<String> {
+suspend fun AbstractScriptComponentFunction.restconfDeviceConfig(
+ webClientService: BlueprintWebClientService,
+ deviceId: String,
+ configletResourcePath: String
+):
+ BlueprintWebClientService.WebClientResponse<String> {
val configPathUrl = "restconf/config/network-topology:network-topology/topology/topology-netconf/node/" +
"$deviceId/$configletResourcePath"
@@ -95,9 +102,12 @@ suspend fun AbstractScriptComponentFunction.restconfDeviceConfig(webClientServic
/**
* Generic UnMount function
*/
-suspend fun AbstractScriptComponentFunction.restconfUnMountDevice(webClientService: BlueprintWebClientService,
- deviceId: String, payload: String) {
+suspend fun AbstractScriptComponentFunction.restconfUnMountDevice(
+ webClientService: BlueprintWebClientService,
+ deviceId: String,
+ payload: String
+) {
val unMountUrl = "restconf/config/network-topology:network-topology/topology/topology-netconf/node/$deviceId"
log.info("sending unMount request, url: $unMountUrl")
webClientService.exchangeResource("DELETE", unMountUrl, "")
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/restconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restconf/executor/ComponentRestconfExecutorTest.kt b/ms/blueprintsprocessor/functions/restconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restconf/executor/ComponentRestconfExecutorTest.kt
index 0336ce958..7d81ef3dc 100644
--- a/ms/blueprintsprocessor/functions/restconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restconf/executor/ComponentRestconfExecutorTest.kt
+++ b/ms/blueprintsprocessor/functions/restconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restconf/executor/ComponentRestconfExecutorTest.kt
@@ -67,7 +67,7 @@ class ComponentRestconfExecutorTest {
operationInputs[BluePrintConstants.PROPERTY_CURRENT_OPERATION] = "operationName".asJsonPrimitive()
operationInputs[ComponentScriptExecutor.INPUT_SCRIPT_TYPE] = BluePrintConstants.SCRIPT_INTERNAL.asJsonPrimitive()
operationInputs[ComponentScriptExecutor.INPUT_SCRIPT_CLASS_REFERENCE] =
- "internal.scripts.TestRestconfConfigure".asJsonPrimitive()
+ "internal.scripts.TestRestconfConfigure".asJsonPrimitive()
val stepInputData = StepData().apply {
name = "activate-restconf"
@@ -78,17 +78,21 @@ class ComponentRestconfExecutorTest {
val blueprintContext = mockk<BluePrintContext>()
every { bluePrintRuntime.bluePrintContext() } returns blueprintContext
every {
- bluePrintRuntime.resolveNodeTemplateInterfaceOperationInputs("activate-restconf",
- "interfaceName", "operationName")
+ bluePrintRuntime.resolveNodeTemplateInterfaceOperationInputs(
+ "activate-restconf",
+ "interfaceName", "operationName"
+ )
} returns operationInputs
val operationOutputs = hashMapOf<String, JsonNode>()
every {
- bluePrintRuntime.resolveNodeTemplateInterfaceOperationOutputs("activate-restconf",
- "interfaceName", "operationName")
+ bluePrintRuntime.resolveNodeTemplateInterfaceOperationOutputs(
+ "activate-restconf",
+ "interfaceName", "operationName"
+ )
} returns operationOutputs
componentScriptExecutor.applyNB(executionServiceInput)
}
}
-} \ No newline at end of file
+}