aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/so-bpmn-tasks/src')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/HomingV2.java2
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/OofHomingV2.java221
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/SniroHomingV2.java1030
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICommonTasks.java40
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java988
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasks.java295
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIFlagTasks.java148
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIQueryTasks.java399
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java1026
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java196
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterCreateTasks.java135
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterDeleteTasks.java46
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1.java222
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterUpdateTasks.java69
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterCreateTasks.java119
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterDeleteTasks.java86
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java236
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/Constants.java42
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/EtsiVnfDeleteTask.java68
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/InputParameterRetrieverTask.java1
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmCreateJobTask.java109
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmDeleteJobTask.java105
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmJobTask.java101
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmNodeTask.java70
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTask.java5
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTaskConfiguration.java1
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProvider.java6
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImpl.java192
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterUrlProvider.java48
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmBasicHttpConfigProvider.java1
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParameter.java1
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParametersProviderImpl.java4
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/VnfParameter.java1
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java263
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/audit/AuditTasks.java67
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ActivateVfModule.java34
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetwork.java45
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetworkBBUtils.java124
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignVnf.java62
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CloudSiteCatalogUtils.java85
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigAssignVnf.java8
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnf.java202
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOut.java229
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetwork.java60
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetworkCollection.java191
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheck.java181
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/NetworkBBUtils.java89
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/SourceSystem.java3
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBB.java156
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignVnf.java47
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasks.java364
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasks.java43
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceDeleteTasks.java36
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/exceptions/SDNCErrorResponseException.java16
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTasks.java153
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasks.java191
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasks.java158
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTasks.java205
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCQueryTasks.java146
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java174
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasks.java167
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/validations/CloudRegionOrchestrationValidator.java58
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/FlowCompletionTasks.java59
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java274
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/Resource.java141
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java2401
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailure.java217
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java744
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAI.java41
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowType.java52
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/sdno/tasks/SDNOHealthCheckTasks.java68
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java537
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/NetworkAdapterClient.java29
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/NetworkAdapterClientException.java14
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/NetworkAdapterClientImpl.java237
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/NetworkAdapterRestProperties.java42
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java675
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfAdapterClient.java20
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfAdapterClientException.java14
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfAdapterClientImpl.java183
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfAdapterRestProperties.java42
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterClient.java20
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterClientImpl.java137
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterRestProperties.java50
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/AttributeNameValue.java7
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapper.java257
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapperUtils.java33
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java1505
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClient.java93
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClientResponseValidator.java189
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingRequestObjectBuilder.java57
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/OofClient.java9
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/OofValidator.java35
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ModelInfo.java11
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofProperties.java9
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofRequest.java16
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofRequestParameters.java7
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/PlacementDemand.java8
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/PlacementInfo.java6
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/RequestInfo.java12
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/Resource.java11
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ResourceModelInfo.java1
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ServiceInfo.java7
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/SubscriberInfo.java7
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAICollectionResources.java48
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIConfigurationResources.java96
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIInstanceGroupResources.java87
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java305
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java207
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVfModuleResources.java120
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVnfResources.java211
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVolumeGroupResources.java99
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVpnBindingResources.java110
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/NamingServiceResources.java48
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/NetworkAdapterResources.java155
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCConfigurationResources.java145
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCNetworkResources.java104
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCServiceInstanceResources.java145
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVfModuleResources.java76
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVnfResources.java98
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNOHealthCheckResources.java24
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/VnfAdapterVfModuleResources.java35
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/VnfAdapterVolumeGroupResources.java33
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java116
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java76
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCProperties.java51
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCRequest.java130
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcAction.java63
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcOperation.java38
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/endpoint/SDNCTopology.java37
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapper.java59
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java344
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapper.java112
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapper.java85
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java265
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java170
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/SniroClient.java144
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/SniroValidator.java197
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/Candidate.java54
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/ConductorProperties.java51
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/Demand.java85
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/LicenseInfo.java21
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/ManagerProperties.java51
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/ModelInfo.java76
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/PlacementInfo.java61
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/RequestInfo.java130
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/Resource.java37
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/ServiceInfo.java76
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/SniroConductorRequest.java43
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/SniroManagerRequest.java116
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/SubscriberInfo.java53
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/ticket/ExternalTicket.java165
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/AllIntegrationTestSuites.java3
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/BaseIntegrationTest.java94
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java28
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/FileUtil.java85
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/IntegrationTestSuite.java1
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/TestApplication.java18
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/UnitTestSuite.java1
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java128
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/aai/tasks/AAIFlagTasksTest.java321
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java997
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java1192
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasksTest.java365
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java1285
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivityTest.java76
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterCreateTasksTest.java112
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterDeleteTasksTest.java70
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java137
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterUpdateTasksTest.java84
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterCreateTasksTest.java348
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterDeleteTasksTest.java174
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImplTest.java412
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/EtsiVnfDeleteTaskTest.java124
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/InputParameterRetrieverTaskTest.java2
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmCreateJobTaskTest.java251
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmDeleteJobTaskTest.java239
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmNodeJobTest.java122
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/StubbedBuildingBlockExecution.java96
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/TestConstants.java4
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTaskConfigurationTest.java1
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTaskTest.java169
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImplTest.java466
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterUrlProviderTest.java1
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParametersProviderImplTest.java2
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/VnfParameterTest.java1
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksIT.java120
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksTest.java86
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/audit/AuditTasksTest.java67
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ActivateVfModuleTest.java24
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetworkBBUtilsTest.java61
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetworkTest.java70
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignVnfTest.java191
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CloudSiteCatalogUtilsTest.java111
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigAssignVnfTest.java2
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnfTest.java130
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOutTest.java284
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetworkCollectionTest.java152
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetworkTest.java90
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheckTest.java262
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/NetworkBBUtilsTest.java160
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/SniroHomingV2IT.java941
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBBTest.java140
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignVnfTest.java80
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasksTest.java146
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasksTest.java87
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceDeleteTasksTest.java63
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTaskTest.java169
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasksTest.java191
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasksTest.java122
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTaskTest.java201
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCQueryTasksTest.java187
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasksTest.java241
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasksTest.java203
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/validations/CloudRegionOrchestrationValidatorTest.java156
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/FlowCompletionTasksTest.java57
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorTest.java812
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorUnitTest.java45
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java201
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java623
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksUpdateReqDbTest.java97
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java2786
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java110
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/sdno/tasks/SDNOHealthCheckTasksTest.java121
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java1119
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/NetworkAdapterClientIT.java381
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java633
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfAdapterClientIT.java348
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterClientIT.java333
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterRestPropertiesTest.java36
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapperTest.java604
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java1637
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperTest.java155
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingClientResponseValidatorTest.java134
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingClientTest.java146
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingRequestObjectBuilderTest.java142
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/oof/OofClientTestIT.java132
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAICollectionResourcesTest.java82
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIConfigurationResourcesTest.java135
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIInstanceGroupResourcesTest.java147
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java671
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIServiceInstanceResourcesTest.java63
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVfModuleResourcesTest.java211
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVnfResourcesTest.java328
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVolumeGroupResourcesTest.java143
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVpnBindingResourcesTest.java142
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/NamingServiceResourcesTest.java109
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/NetworkAdapterResourcesTest.java327
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCConfigurationResourcesTest.java70
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCNetworkResourcesTest.java239
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCServiceInstanceResourcesTest.java192
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVfModuleResourcesTest.java155
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVnfResourcesTest.java244
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNOHealthCheckResourcesTest.java52
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/VnfAdapterVfModuleResourcesTest.java189
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/VnfAdapterVolumeGroupResourcesTest.java142
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/policy/CommonObjectMapperProviderTest.java4
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java8
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientIT.java54
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapperTest.java28
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapperTest.java742
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapperTest.java339
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapperTest.java89
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java547
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java190
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sniro/SniroClientTestIT.java98
266 files changed, 26394 insertions, 25043 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/HomingV2.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/HomingV2.java
index 55f898742c..513ff74180 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/HomingV2.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/HomingV2.java
@@ -54,7 +54,7 @@ public class HomingV2 {
// Default solution is SNIRO. OOF gets called only if specified.
private boolean isOof(BuildingBlockExecution execution) {
for (Map<String, Object> params : execution.getGeneralBuildingBlock().getRequestContext().getRequestParameters()
- .getUserParams()) {
+ .getUserParams()) {
if (params.containsKey(HOMINGSOLUTION) && params.get(HOMINGSOLUTION).equals("oof")) {
return true;
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/OofHomingV2.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/OofHomingV2.java
index f65dde1af5..2524fc7892 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/OofHomingV2.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/OofHomingV2.java
@@ -65,19 +65,16 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import org.springframework.web.util.UriUtils;
-
import java.time.Duration;
import java.util.List;
import java.util.Map;
import java.util.UUID;
-
import static org.apache.commons.lang3.StringUtils.isBlank;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
/**
- * The oof homing building block obtains licensing and homing solutions for a given
- * resource or set of resources.
+ * The oof homing building block obtains licensing and homing solutions for a given resource or set of resources.
*
*/
@Component("OofHoming")
@@ -109,14 +106,13 @@ public class OofHomingV2 {
private static final int INTERNAL = 500;
/**
- * Generates the request payload then sends to Oof to perform homing and
- * licensing for the provided demands
+ * Generates the request payload then sends to Oof to perform homing and licensing for the provided demands
*
* @param execution
*/
- public void callOof(BuildingBlockExecution execution){
+ public void callOof(BuildingBlockExecution execution) {
logger.trace("Started Sniro Homing Call Sniro");
- try{
+ try {
GeneralBuildingBlock bb = execution.getGeneralBuildingBlock();
RequestContext requestContext = bb.getRequestContext();
@@ -127,13 +123,13 @@ public class OofHomingV2 {
Customer customer = bb.getCustomer();
String timeout = execution.getVariable("timeout");
- if(isBlank(timeout)){
+ if (isBlank(timeout)) {
timeout = env.getProperty("oof.timeout", "PT30M");
}
OofRequest request = new OofRequest();
- RequestInfo requestInfo = (RequestInfo)buildRequestInfo(requestId, timeout);
+ RequestInfo requestInfo = (RequestInfo) buildRequestInfo(requestId, timeout);
request.setRequestInformation(requestInfo);
ServiceInfo serviceInfo = buildServiceInfo(serviceInstance);
@@ -151,71 +147,74 @@ public class OofHomingV2 {
licenseInfo.put("licenseDemands", licenseDemands);
request.setLicenseInformation(licenseInfo.toString());
- if(placementDemands.size() > 0 || licenseDemands.length() > 0){
+ if (placementDemands.size() > 0 || licenseDemands.length() > 0) {
client.postDemands(request);
- }else{
+ } else {
logger.debug(SERVICE_MISSING_DATA + " resources eligible for homing or licensing");
- throw new BpmnError(UNPROCESSABLE, SERVICE_MISSING_DATA + " resources eligible for homing or licensing");
+ throw new BpmnError(UNPROCESSABLE,
+ SERVICE_MISSING_DATA + " resources eligible for homing or licensing");
}
- //Variables for ReceiveWorkflowMessage subflow
+ // Variables for ReceiveWorkflowMessage subflow
execution.setVariable("asyncCorrelator", requestId);
execution.setVariable("asyncMessageType", "OofResponse");
execution.setVariable("asyncTimeout", timeout);
logger.trace("Completed Oof Homing Call Oof");
- }catch(BpmnError e){
+ } catch (BpmnError e) {
exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(e.getErrorCode()), e.getMessage());
- }catch(BadResponseException e){
+ } catch (BadResponseException e) {
exceptionUtil.buildAndThrowWorkflowException(execution, 400, e.getMessage());
- }catch(Exception e){
- exceptionUtil.buildAndThrowWorkflowException(execution, INTERNAL, "Internal Error - occurred while preparing oof request: " + e.getMessage());
+ } catch (Exception e) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, INTERNAL,
+ "Internal Error - occurred while preparing oof request: " + e.getMessage());
}
}
/**
- * Validates, processes, and sets the homing and licensing solutions that are returned by
- * Oof
+ * Validates, processes, and sets the homing and licensing solutions that are returned by Oof
*
* @param execution
* @param asyncResponse
*/
- public void processSolution(BuildingBlockExecution execution, String asyncResponse){
+ public void processSolution(BuildingBlockExecution execution, String asyncResponse) {
logger.trace("Started Oof Homing Process Solution");
- try{
+ try {
oofValidator.validateSolution(asyncResponse);
- ServiceInstance serviceInstance = execution.getGeneralBuildingBlock().getCustomer().getServiceSubscription().getServiceInstances().get(0);
+ ServiceInstance serviceInstance = execution.getGeneralBuildingBlock().getCustomer().getServiceSubscription()
+ .getServiceInstances().get(0);
logger.debug("Processing Oof asyncronous response");
JSONObject response = new JSONObject(asyncResponse);
- if(response.has(SOLUTIONS)){
+ if (response.has(SOLUTIONS)) {
JSONObject allSolutions = response.getJSONObject(SOLUTIONS);
- if(allSolutions.has("placementSolutions")){
+ if (allSolutions.has("placementSolutions")) {
JSONArray placementSolutions = allSolutions.getJSONArray("placementSolutions");
- for(int i = 0; i < placementSolutions.length(); i++){
+ for (int i = 0; i < placementSolutions.length(); i++) {
JSONArray placements = placementSolutions.getJSONArray(i);
processPlacementSolution(serviceInstance, placements, i);
}
}
- if(allSolutions.has("licenseSolutions")){
+ if (allSolutions.has("licenseSolutions")) {
JSONArray licenseSolutions = allSolutions.getJSONArray("licenseSolutions");
- if(licenseSolutions.length() > 0){
+ if (licenseSolutions.length() > 0) {
processLicenseSolution(serviceInstance, licenseSolutions);
}
}
- }else{
+ } else {
throw new BpmnError(UNPROCESSABLE, "Oof response does not contain: " + SOLUTIONS);
}
execution.setVariable("generalBuildingBlock", execution.getGeneralBuildingBlock());
logger.trace("Completed Oof Homing Process Solution");
- }catch(BpmnError e){
+ } catch (BpmnError e) {
exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(e.getErrorCode()), e.getMessage());
- }catch(BadResponseException e){
+ } catch (BadResponseException e) {
exceptionUtil.buildAndThrowWorkflowException(execution, 400, e.getMessage());
- }catch(Exception e){
- exceptionUtil.buildAndThrowWorkflowException(execution, INTERNAL, "Internal Error - occurred while processing Oof asynchronous response: " + e.getMessage());
+ } catch (Exception e) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, INTERNAL,
+ "Internal Error - occurred while processing Oof asynchronous response: " + e.getMessage());
}
}
@@ -224,12 +223,13 @@ public class OofHomingV2 {
*
* @throws Exception
*/
- private RequestInfo buildRequestInfo(String requestId, String timeout) throws Exception{
+ private RequestInfo buildRequestInfo(String requestId, String timeout) throws Exception {
logger.trace("Building request information");
RequestInfo requestInfo = new RequestInfo();
- if(requestId != null){
+ if (requestId != null) {
String host = env.getProperty("mso.workflow.message.endpoint");
- String callbackUrl = host + "/" + UriUtils.encodePathSegment("OofResponse", "UTF-8") + "/" + UriUtils.encodePathSegment(requestId, "UTF-8");
+ String callbackUrl = host + "/" + UriUtils.encodePathSegment("OofResponse", "UTF-8") + "/"
+ + UriUtils.encodePathSegment(requestId, "UTF-8");
Duration d = Duration.parse(timeout);
long timeoutSeconds = d.getSeconds();
@@ -240,7 +240,7 @@ public class OofHomingV2 {
requestInfo.setSourceId("mso");
requestInfo.setRequestType("create");
requestInfo.setTimeout(timeoutSeconds);
- } else{
+ } else {
throw new BpmnError(UNPROCESSABLE, "Request Context does not contain: requestId");
}
return requestInfo;
@@ -250,17 +250,17 @@ public class OofHomingV2 {
* Builds the request information section for the homing/licensing request
*
*/
- private ServiceInfo buildServiceInfo(ServiceInstance serviceInstance){
+ private ServiceInfo buildServiceInfo(ServiceInstance serviceInstance) {
logger.trace("Building service information");
ServiceInfo info = new ServiceInfo();
ModelInfoServiceInstance modelInfo = serviceInstance.getModelInfoServiceInstance();
- if(isNotBlank(modelInfo.getModelInvariantUuid()) && isNotBlank(modelInfo.getModelUuid())){
+ if (isNotBlank(modelInfo.getModelInvariantUuid()) && isNotBlank(modelInfo.getModelUuid())) {
info.setServiceInstanceId(serviceInstance.getServiceInstanceId());
- if(modelInfo.getServiceType() != null && modelInfo.getServiceType().length() > 0){ //temp solution
+ if (modelInfo.getServiceType() != null && modelInfo.getServiceType().length() > 0) { // temp solution
info.setServiceName(modelInfo.getServiceType());
}
info.setModelInfo(buildModelInfo(serviceInstance.getModelInfoServiceInstance()));
- }else{
+ } else {
throw new BpmnError(UNPROCESSABLE, SERVICE_MISSING_DATA + MODEL_VERSION_ID + ", " + MODEL_INVARIANT_ID);
}
return info;
@@ -270,32 +270,32 @@ public class OofHomingV2 {
* Builds initial section of placement info for the homing/licensing request
*
*/
- private PlacementInfo buildPlacementInfo(Customer customer, RequestParameters requestParams){
+ private PlacementInfo buildPlacementInfo(Customer customer, RequestParameters requestParams) {
PlacementInfo placementInfo = new PlacementInfo();
- if(customer != null){
+ if (customer != null) {
logger.debug("Adding subscriber to placement information");
SubscriberInfo subscriberInfo = new SubscriberInfo();
subscriberInfo.setGlobalSubscriberId(customer.getGlobalCustomerId());
subscriberInfo.setSubscriberName(customer.getSubscriberName());
subscriberInfo.setSubscriberCommonSiteId(customer.getSubscriberCommonSiteId());
placementInfo.setSubscriberInfo(subscriberInfo);
- if(requestParams != null){
+ if (requestParams != null) {
logger.debug("Adding request parameters to placement information");
OofRequestParameters oofRequestParams = new OofRequestParameters();
- for (Map requestParam : requestParams.getUserParams()){
- if (requestParam.containsKey("customerLatitude")){
+ for (Map requestParam : requestParams.getUserParams()) {
+ if (requestParam.containsKey("customerLatitude")) {
oofRequestParams.setCustomerLatitude(requestParam.get("customerLatitude").toString());
}
- if (requestParam.containsKey("customerLongitude")){
+ if (requestParam.containsKey("customerLongitude")) {
oofRequestParams.setCustomerLongitude(requestParam.get("customerLongitude").toString());
}
- if (requestParam.containsKey("customerName")){
+ if (requestParam.containsKey("customerName")) {
oofRequestParams.setCustomerName(requestParam.get("customerName").toString());
}
}
placementInfo.setRequestParameters(oofRequestParams);
}
- }else{
+ } else {
throw new BpmnError(UNPROCESSABLE, SERVICE_MISSING_DATA + "customer");
}
return placementInfo;
@@ -306,33 +306,33 @@ public class OofHomingV2 {
* Builds the placement demand list for the homing/licensing request
*
*/
- private ArrayList<PlacementDemand> buildPlacementDemands(ServiceInstance serviceInstance){
+ private ArrayList<PlacementDemand> buildPlacementDemands(ServiceInstance serviceInstance) {
logger.trace("Building placement information demands");
ArrayList<PlacementDemand> placementDemands = new ArrayList();
List<AllottedResource> allottedResourceList = serviceInstance.getAllottedResources();
- if(!allottedResourceList.isEmpty()){
+ if (!allottedResourceList.isEmpty()) {
logger.debug("Adding allotted resources to placement demands list");
- for(AllottedResource ar : allottedResourceList){
- if(isBlank(ar.getId())){
+ for (AllottedResource ar : allottedResourceList) {
+ if (isBlank(ar.getId())) {
ar.setId(UUID.randomUUID().toString());
}
PlacementDemand demand = buildDemand(ar.getId(), ar.getModelInfoAllottedResource());
- //addCandidates(ar, demand);
+ // addCandidates(ar, demand);
placementDemands.add(demand);
}
}
List<VpnBondingLink> vpnBondingLinkList = serviceInstance.getVpnBondingLinks();
- if(!vpnBondingLinkList.isEmpty()){
+ if (!vpnBondingLinkList.isEmpty()) {
logger.debug("Adding vpn bonding links to placement demands list");
- for(VpnBondingLink vbl:vpnBondingLinkList){
+ for (VpnBondingLink vbl : vpnBondingLinkList) {
List<ServiceProxy> serviceProxyList = vbl.getServiceProxies();
- for(ServiceProxy sp : serviceProxyList){
- if(isBlank(sp.getId())){
+ for (ServiceProxy sp : serviceProxyList) {
+ if (isBlank(sp.getId())) {
sp.setId(UUID.randomUUID().toString());
}
PlacementDemand demand = buildDemand(sp.getId(), sp.getModelInfoServiceProxy());
- //addCandidates(sp, demand);
+ // addCandidates(sp, demand);
placementDemands.add(demand);
}
}
@@ -344,13 +344,13 @@ public class OofHomingV2 {
* Builds the license demand list for the homing/licensing request
*
*/
- private JSONArray buildLicenseDemands(ServiceInstance serviceInstance){
+ private JSONArray buildLicenseDemands(ServiceInstance serviceInstance) {
logger.trace("Building license information");
JSONArray licenseDemands = new JSONArray();
List<GenericVnf> vnfList = serviceInstance.getVnfs();
- if(!vnfList.isEmpty()){
+ if (!vnfList.isEmpty()) {
logger.debug("Adding vnfs to license demands list");
- for(GenericVnf vnf : vnfList){
+ for (GenericVnf vnf : vnfList) {
JSONObject demand = buildLicenseDemand(vnf.getVnfId(), vnf.getModelInfoGenericVnf());
licenseDemands.put(demand);
}
@@ -362,14 +362,14 @@ public class OofHomingV2 {
* Builds a single license demand object
*
*/
- private JSONObject buildLicenseDemand(String id, ModelInfoMetadata metadata){
+ private JSONObject buildLicenseDemand(String id, ModelInfoMetadata metadata) {
logger.debug("Building demand for service or resource: " + id);
JSONObject demand = new JSONObject();
- if(isNotBlank(id) && isNotBlank(metadata.getModelInstanceName())){
+ if (isNotBlank(id) && isNotBlank(metadata.getModelInstanceName())) {
demand.put(SERVICE_RESOURCE_ID, id);
demand.put(RESOURCE_MODULE_NAME, metadata.getModelInstanceName());
demand.put(RESOURCE_MODEL_INFO, buildModelInfo(metadata));
- }else{
+ } else {
throw new BpmnError(UNPROCESSABLE, RESOURCE_MISSING_DATA + "modelInstanceName");
}
return demand;
@@ -379,14 +379,14 @@ public class OofHomingV2 {
* Builds a single demand object
*
*/
- private PlacementDemand buildDemand(String id, ModelInfoMetadata metadata){
+ private PlacementDemand buildDemand(String id, ModelInfoMetadata metadata) {
logger.debug("Building demand for service or resource: " + id);
PlacementDemand placementDemand = new PlacementDemand();
- if(isNotBlank(id) && isNotBlank(metadata.getModelInstanceName())){
+ if (isNotBlank(id) && isNotBlank(metadata.getModelInstanceName())) {
placementDemand.setServiceResourceId(id);
placementDemand.setResourceModuleName(metadata.getModelInstanceName());
placementDemand.setResourceModelInfo((ResourceModelInfo) buildModelInfo(metadata));
- }else{
+ } else {
throw new BpmnError(UNPROCESSABLE, RESOURCE_MISSING_DATA + "modelInstanceName");
}
return placementDemand;
@@ -396,18 +396,18 @@ public class OofHomingV2 {
* Builds the resource model info section
*
*/
- private ModelInfo buildModelInfo(ModelInfoMetadata metadata){
+ private ModelInfo buildModelInfo(ModelInfoMetadata metadata) {
ModelInfo modelInfo = new ModelInfo();
String invariantUuid = metadata.getModelInvariantUuid();
String modelUuid = metadata.getModelUuid();
- if(isNotBlank(invariantUuid) && isNotBlank(modelUuid)){
+ if (isNotBlank(invariantUuid) && isNotBlank(modelUuid)) {
modelInfo.setModelInvariantId(invariantUuid);
modelInfo.setModelVersionId(modelUuid);
modelInfo.setModelName(metadata.getModelName());
modelInfo.setModelVersion(metadata.getModelVersion());
- }else if(isNotBlank(invariantUuid)){
+ } else if (isNotBlank(invariantUuid)) {
throw new BpmnError(UNPROCESSABLE, RESOURCE_MISSING_DATA + MODEL_VERSION_ID);
- }else{
+ } else {
throw new BpmnError(UNPROCESSABLE, RESOURCE_MISSING_DATA + MODEL_INVARIANT_ID);
}
return modelInfo;
@@ -417,30 +417,30 @@ public class OofHomingV2 {
* Adds required, excluded, and existing candidates to a demand
*
*/
- private void addCandidates(SolutionCandidates candidates, JSONObject demand){
+ private void addCandidates(SolutionCandidates candidates, JSONObject demand) {
List<Candidate> required = candidates.getRequiredCandidates();
List<Candidate> excluded = candidates.getExcludedCandidates();
- if(!required.isEmpty()){
+ if (!required.isEmpty()) {
demand.put("requiredCandidates", required);
}
- if(!excluded.isEmpty()){
+ if (!excluded.isEmpty()) {
demand.put("excludedCandidates", excluded);
}
- //TODO support existing candidates
+ // TODO support existing candidates
}
/**
* Processes the license solutions and sets to the corresponding generic vnf
*
*/
- private void processLicenseSolution(ServiceInstance serviceInstance, JSONArray licenseSolutions){
+ private void processLicenseSolution(ServiceInstance serviceInstance, JSONArray licenseSolutions) {
List<GenericVnf> vnfs = serviceInstance.getVnfs();
logger.debug("Processing the license solution");
- for(int i = 0; i < licenseSolutions.length(); i++){
+ for (int i = 0; i < licenseSolutions.length(); i++) {
JSONObject licenseSolution = licenseSolutions.getJSONObject(i);
- for(GenericVnf vnf:vnfs){
- if(licenseSolution.getString(SERVICE_RESOURCE_ID).equals(vnf.getVnfId())){
+ for (GenericVnf vnf : vnfs) {
+ if (licenseSolution.getString(SERVICE_RESOURCE_ID).equals(vnf.getVnfId())) {
License license = new License();
JSONArray entitlementPools = licenseSolution.getJSONArray("entitlementPoolUUID");
List<String> entitlementPoolsList = jsonUtils.StringArrayToList(entitlementPools);
@@ -456,47 +456,48 @@ public class OofHomingV2 {
}
/**
- * Processes a placement solution list then correlates and sets each placement solution
- * to its corresponding resource
+ * Processes a placement solution list then correlates and sets each placement solution to its corresponding
+ * resource
*
*/
- private void processPlacementSolution(ServiceInstance serviceInstance, JSONArray placements, int i){
+ private void processPlacementSolution(ServiceInstance serviceInstance, JSONArray placements, int i) {
List<VpnBondingLink> links = serviceInstance.getVpnBondingLinks();
List<AllottedResource> allottes = serviceInstance.getAllottedResources();
List<GenericVnf> vnfs = serviceInstance.getVnfs();
- logger.debug("Processing placement solution " + i+1);
- for(int p = 0; p < placements.length(); p++){
+ logger.debug("Processing placement solution " + i + 1);
+ for (int p = 0; p < placements.length(); p++) {
JSONObject placement = placements.getJSONObject(p);
SolutionInfo solutionInfo = new SolutionInfo();
solutionInfo.setSolutionId(i + 1);
search: {
- for(VpnBondingLink vbl:links){
+ for (VpnBondingLink vbl : links) {
List<ServiceProxy> proxies = vbl.getServiceProxies();
- for(ServiceProxy sp:proxies){
- if(placement.getString(SERVICE_RESOURCE_ID).equals(sp.getId())){
- if(i > 0){
- if(p % 2 == 0){
+ for (ServiceProxy sp : proxies) {
+ if (placement.getString(SERVICE_RESOURCE_ID).equals(sp.getId())) {
+ if (i > 0) {
+ if (p % 2 == 0) {
VpnBondingLink vblNew = (VpnBondingLink) SerializationUtils.clone(vbl);
vblNew.setVpnBondingLinkId(UUID.randomUUID().toString());
links.add(vblNew);
}
- links.get(links.size() - 1).getServiceProxy(sp.getId()).setServiceInstance(setSolution(solutionInfo, placement));
- }else{
+ links.get(links.size() - 1).getServiceProxy(sp.getId())
+ .setServiceInstance(setSolution(solutionInfo, placement));
+ } else {
sp.setServiceInstance(setSolution(solutionInfo, placement));
}
break search;
}
}
}
- for(AllottedResource ar:allottes){
- if(placement.getString(SERVICE_RESOURCE_ID).equals(ar.getId())){
+ for (AllottedResource ar : allottes) {
+ if (placement.getString(SERVICE_RESOURCE_ID).equals(ar.getId())) {
ar.setParentServiceInstance(setSolution(solutionInfo, placement));
break search;
}
}
- for(GenericVnf vnf:vnfs){
- if(placement.getString(SERVICE_RESOURCE_ID).equals(vnf.getVnfId())){
+ for (GenericVnf vnf : vnfs) {
+ if (placement.getString(SERVICE_RESOURCE_ID).equals(vnf.getVnfId())) {
ServiceInstance si = setSolution(solutionInfo, placement);
serviceInstance.setSolutionInfo(si.getSolutionInfo());
serviceInstance.getVnfs().add(si.getVnfs().get(0));
@@ -512,7 +513,7 @@ public class OofHomingV2 {
* Creates and sets necessary pojos with placement solution data for a given demand
*
*/
- private ServiceInstance setSolution(SolutionInfo solutionInfo, JSONObject placement){
+ private ServiceInstance setSolution(SolutionInfo solutionInfo, JSONObject placement) {
logger.debug("Mapping placement solution");
String invalidMessage = "Oof Response contains invalid: ";
@@ -528,45 +529,45 @@ public class OofHomingV2 {
ServiceInstance si = new ServiceInstance();
CloudRegion cloud = setCloud(assignmentsMap);
- if(type.equals("service")){
- if(identifierType.equals(CandidateType.SERVICE_INSTANCE_ID.toString())){
+ if (type.equals("service")) {
+ if (identifierType.equals(CandidateType.SERVICE_INSTANCE_ID.toString())) {
solutionInfo.setHomed(true);
si.setServiceInstanceId(identifierValue);
si.setOrchestrationStatus(OrchestrationStatus.CREATED);
cloud.setLcpCloudRegionId(assignmentsMap.get("cloudRegionId"));
- if(assignmentsMap.containsKey("vnfHostName")){
+ if (assignmentsMap.containsKey("vnfHostName")) {
logger.debug("Resources has been homed to a vnf");
GenericVnf vnf = setVnf(assignmentsMap);
vnf.setCloudRegion(cloud);
si.getVnfs().add(vnf);
- }else if(assignmentsMap.containsKey("primaryPnfName")){
+ } else if (assignmentsMap.containsKey("primaryPnfName")) {
logger.debug("Resources has been homed to a pnf");
Pnf priPnf = setPnf(assignmentsMap, "primary");
priPnf.setCloudRegion(cloud);
si.getPnfs().add(priPnf);
- if(assignmentsMap.containsKey("secondaryPnfName")){
+ if (assignmentsMap.containsKey("secondaryPnfName")) {
Pnf secPnf = setPnf(assignmentsMap, "secondary");
secPnf.setCloudRegion(cloud);
si.getPnfs().add(secPnf);
}
}
- }else{
+ } else {
logger.debug(invalidMessage + IDENTIFIER_TYPE);
throw new BpmnError(UNPROCESSABLE, invalidMessage + IDENTIFIER_TYPE);
}
- }else if(type.equals("cloud")){
- if(identifierType.equals(CandidateType.CLOUD_REGION_ID.toString())){
+ } else if (type.equals("cloud")) {
+ if (identifierType.equals(CandidateType.CLOUD_REGION_ID.toString())) {
logger.debug("Resources has been homed to a cloud region");
cloud.setLcpCloudRegionId(identifierValue);
solutionInfo.setHomed(false);
solutionInfo.setTargetedCloudRegion(cloud);
si.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
- }else{
+ } else {
logger.debug(invalidMessage + IDENTIFIER_TYPE);
throw new BpmnError(UNPROCESSABLE, invalidMessage + IDENTIFIER_TYPE);
}
- }else{
+ } else {
logger.debug(invalidMessage + INVENTORY_TYPE);
throw new BpmnError(UNPROCESSABLE, invalidMessage + INVENTORY_TYPE);
}
@@ -578,7 +579,7 @@ public class OofHomingV2 {
* Sets the cloud data to a cloud region object
*
*/
- private CloudRegion setCloud(Map<String, String> assignmentsMap){
+ private CloudRegion setCloud(Map<String, String> assignmentsMap) {
CloudRegion cloud = new CloudRegion();
cloud.setCloudOwner(assignmentsMap.get("cloudOwner"));
cloud.setCloudRegionVersion(assignmentsMap.get("aicVersion"));
@@ -590,7 +591,7 @@ public class OofHomingV2 {
* Sets the vnf data to a generic vnf object
*
*/
- private GenericVnf setVnf(Map<String, String> assignmentsMap){
+ private GenericVnf setVnf(Map<String, String> assignmentsMap) {
GenericVnf vnf = new GenericVnf();
vnf.setOrchestrationStatus(OrchestrationStatus.CREATED);
vnf.setVnfName(assignmentsMap.get("vnfHostName"));
@@ -602,7 +603,7 @@ public class OofHomingV2 {
* Sets the pnf data to a pnf object
*
*/
- private Pnf setPnf(Map<String, String> assignmentsMap, String role){
+ private Pnf setPnf(Map<String, String> assignmentsMap, String role) {
Pnf pnf = new Pnf();
pnf.setRole(role);
pnf.setOrchestrationStatus(OrchestrationStatus.CREATED);
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/SniroHomingV2.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/SniroHomingV2.java
index 2e7184b9ff..29037980cc 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/SniroHomingV2.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/SniroHomingV2.java
@@ -23,13 +23,11 @@
package org.onap.so.bpmn.buildingblock;
import static org.apache.commons.lang3.StringUtils.*;
-
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
-
import org.apache.commons.lang.SerializationUtils;
import org.camunda.bpm.engine.delegate.BpmnError;
import org.json.JSONArray;
@@ -56,10 +54,8 @@ import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoMetadata;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance;
import org.onap.so.client.exception.BadResponseException;
import org.onap.so.client.exception.ExceptionBuilder;
-
import org.onap.so.client.sniro.SniroClient;
import static org.onap.so.client.sniro.SniroValidator.*;
-
import org.onap.so.client.sniro.beans.Demand;
import org.onap.so.client.sniro.beans.LicenseInfo;
import org.onap.so.client.sniro.beans.ModelInfo;
@@ -78,8 +74,7 @@ import org.springframework.web.util.UriUtils;
/**
- * The sniro homing building block obtains licensing and homing solutions for a given
- * resource or set of resources.
+ * The sniro homing building block obtains licensing and homing solutions for a given resource or set of resources.
*
* @author cb645j
*
@@ -87,514 +82,521 @@ import org.springframework.web.util.UriUtils;
@Component("SniroHoming")
public class SniroHomingV2 {
- private static final Logger logger = LoggerFactory.getLogger(SniroHomingV2.class);
- private JsonUtils jsonUtils = new JsonUtils();
- @Autowired
- private Environment env;
- @Autowired
- private SniroClient client;
- @Autowired
- private ExceptionBuilder exceptionUtil;
- private static final String MODEL_NAME = "modelName";
- private static final String MODEL_INVARIANT_ID = "modelInvariantId";
- private static final String MODEL_VERSION_ID = "modelVersionId";
- private static final String MODEL_VERSION = "modelVersion";
- private static final String SERVICE_RESOURCE_ID = "serviceResourceId";
- private static final String RESOURCE_MODULE_NAME = "resourceModuleName";
- private static final String RESOURCE_MODEL_INFO = "resourceModelInfo";
- private static final String IDENTIFIER_TYPE = "identifierType";
- private static final String SOLUTIONS = "solutions";
- private static final String RESOURCE_MISSING_DATA = "Resource does not contain: ";
- private static final String SERVICE_MISSING_DATA = "Service Instance does not contain: ";
- private static final String UNPROCESSABLE = "422";
- private static final int INTERNAL = 500;
-
- /**
- * Generates the request payload then sends to sniro manager to perform homing and
- * licensing for the provided demands
- *
- * @param execution
- */
- public void callSniro(BuildingBlockExecution execution){
- logger.debug("Started Sniro Homing Call Sniro");
- try{
- GeneralBuildingBlock bb = execution.getGeneralBuildingBlock();
-
- RequestContext requestContext = bb.getRequestContext();
- RequestParameters requestParams = requestContext.getRequestParameters();
- String requestId = requestContext.getMsoRequestId();
-
- ServiceInstance serviceInstance = bb.getCustomer().getServiceSubscription().getServiceInstances().get(0);
- Customer customer = bb.getCustomer();
-
- String timeout = execution.getVariable("timeout");
- if(isBlank(timeout)){
- timeout = env.getProperty("sniro.manager.timeout", "PT30M");
- }
-
- SniroManagerRequest request = new SniroManagerRequest();
-
- RequestInfo requestInfo = buildRequestInfo(requestId, timeout);
- request.setRequestInformation(requestInfo);
-
- ServiceInfo serviceInfo = buildServiceInfo(serviceInstance);
- request.setServiceInformation(serviceInfo);
-
- PlacementInfo placementInfo = buildPlacementInfo(customer, requestParams);
-
- List<Demand> placementDemands = buildPlacementDemands(serviceInstance);
- placementInfo.setDemands(placementDemands);
- request.setPlacementInformation(placementInfo);
-
- LicenseInfo licenseInfo = new LicenseInfo();
-
- List<Demand> licenseDemands = buildLicenseDemands(serviceInstance);
- licenseInfo.setDemands(licenseDemands);
- request.setLicenseInformation(licenseInfo);
-
- if(placementDemands.size() > 0 || licenseDemands.size() > 0){
- client.postDemands(request);
- }else{
- logger.debug(SERVICE_MISSING_DATA + "resources eligible for homing or licensing");
- throw new BpmnError(UNPROCESSABLE, SERVICE_MISSING_DATA + "resources eligible for homing or licensing");
- }
-
- //Variables for ReceiveWorkflowMessage subflow
- execution.setVariable("asyncCorrelator", requestId);
- execution.setVariable("asyncMessageType", "SNIROResponse");
- execution.setVariable("asyncTimeout", timeout);
-
- logger.trace("Completed Sniro Homing Call Sniro");
- }catch(BpmnError e){
- logger.error("Exception occurred", e);
- exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(e.getErrorCode()), e.getMessage());
- }catch(BadResponseException e){
- logger.error("Exception occurred", e);
- exceptionUtil.buildAndThrowWorkflowException(execution, 400, e.getMessage());
- }catch(Exception e){
- logger.error("Exception occurred", e);
- exceptionUtil.buildAndThrowWorkflowException(execution, INTERNAL, "Internal Error - occurred while preparing sniro request: " + e.getMessage());
- }
- }
-
- /**
- * Validates, processes, and sets the homing and licensing solutions that are returned by
- * sniro manager
- *
- * @param execution
- * @param asyncResponse
- */
- public void processSolution(BuildingBlockExecution execution, String asyncResponse){
- logger.trace("Started Sniro Homing Process Solution");
- try{
- //TODO improve handling multiple solutions but is dependent on sniro enhancing api + work with sniro conductor to improve "inventoryType" representation
- validateSolution(asyncResponse);
- ServiceInstance serviceInstance = execution.getGeneralBuildingBlock().getCustomer().getServiceSubscription().getServiceInstances().get(0);
-
- logger.debug("Processing sniro manager asyncronous response");
- JSONObject response = new JSONObject(asyncResponse);
- if(response.has(SOLUTIONS)){
- JSONObject allSolutions = response.getJSONObject(SOLUTIONS);
- if(allSolutions.has("placementSolutions")){
- JSONArray placementSolutions = allSolutions.getJSONArray("placementSolutions");
- for(int i = 0; i < placementSolutions.length(); i++){
- JSONArray placements = placementSolutions.getJSONArray(i);
- processPlacementSolution(serviceInstance, placements, i);
- }
- }
- if(allSolutions.has("licenseSolutions")){
- JSONArray licenseSolutions = allSolutions.getJSONArray("licenseSolutions");
- if(licenseSolutions.length() > 0){
- processLicenseSolution(serviceInstance, licenseSolutions);
- }
- }
- }else{
- throw new BpmnError(UNPROCESSABLE, "Sniro Managers response does not contain: " + SOLUTIONS);
- }
-
- execution.setVariable("generalBuildingBlock", execution.getGeneralBuildingBlock());
-
- logger.trace("Completed Sniro Homing Process Solution");
- }catch(BpmnError e){
- logger.error("Exception occurred", e);
- exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(e.getErrorCode()), e.getMessage());
- }catch(BadResponseException e){
- logger.error("Exception occurred", e);
- exceptionUtil.buildAndThrowWorkflowException(execution, 400, e.getMessage());
- }catch(Exception e){
- logger.error("Exception occurred", e);
- exceptionUtil.buildAndThrowWorkflowException(execution, INTERNAL, "Internal Error - occurred while processing sniro asynchronous response: " + e.getMessage());
- }
- }
-
- /**
- * Builds the request information section for the homing/licensing request
- *
- * @throws Exception
- */
- private RequestInfo buildRequestInfo(String requestId, String timeout) throws Exception{
- logger.trace("Building request information");
- RequestInfo requestInfo = new RequestInfo();
- if(requestId != null){
- String host = env.getProperty("mso.workflow.message.endpoint");
- String callbackUrl = host + "/" + UriUtils.encodePathSegment("SNIROResponse", "UTF-8") + "/" + UriUtils.encodePathSegment(requestId, "UTF-8");
-
- Duration d = Duration.parse(timeout);
-
- requestInfo.setTransactionId(requestId);
- requestInfo.setRequestId(requestId);
- requestInfo.setCallbackUrl(callbackUrl);
- requestInfo.setRequestType("create");
- requestInfo.setTimeout(d.getSeconds());
-
- } else{
- throw new BpmnError(UNPROCESSABLE, "Request Context does not contain: requestId");
- }
- return requestInfo;
- }
-
- /**
- * Builds the request information section for the homing/licensing request
- *
- */
- private ServiceInfo buildServiceInfo(ServiceInstance serviceInstance){
- logger.trace("Building service information");
- ServiceInfo info = new ServiceInfo();
- ModelInfoServiceInstance modelInfo = serviceInstance.getModelInfoServiceInstance();
- if(isNotBlank(modelInfo.getModelInvariantUuid()) && isNotBlank(modelInfo.getModelUuid())){
- info.setServiceInstanceId(serviceInstance.getServiceInstanceId());
- if(modelInfo.getServiceType() != null && modelInfo.getServiceType().length() > 0){ //temp solution
- info.setServiceName(modelInfo.getServiceType());
- }
- if(modelInfo.getServiceRole() != null){
- info.setServiceRole(modelInfo.getServiceRole());
- }
- info.setModelInfo(buildModelInfo(modelInfo));
- }else{
- throw new BpmnError(UNPROCESSABLE, SERVICE_MISSING_DATA + MODEL_VERSION_ID + ", " + MODEL_INVARIANT_ID);
- }
- return info;
- }
-
- /**
- * Builds initial section of placement info for the homing/licensing request
- *
- */
- private PlacementInfo buildPlacementInfo(Customer customer, RequestParameters requestParams){
- PlacementInfo placementInfo = new PlacementInfo();
- if(customer != null){
- logger.debug("Adding subscriber to placement information");
- SubscriberInfo subscriber = new SubscriberInfo();
- subscriber.setGlobalSubscriberId(customer.getGlobalCustomerId());
- subscriber.setSubscriberName(customer.getSubscriberName());
- subscriber.setSubscriberCommonSiteId(customer.getSubscriberCommonSiteId());
- placementInfo.setSubscriberInfo(subscriber);
- if(requestParams != null){
- logger.debug("Adding request parameters to placement information");
- placementInfo.setRequestParameters(requestParams.toJsonString());
- }
- }else{
- throw new BpmnError(UNPROCESSABLE, SERVICE_MISSING_DATA + "customer");
- }
- return placementInfo;
-
- }
-
- /**
- * Builds the placement demand list for the homing/licensing request
- *
- */
- private List<Demand> buildPlacementDemands(ServiceInstance serviceInstance){
- logger.trace("Building placement information demands");
- List<Demand> placementDemands = new ArrayList<Demand>();
-
- List<AllottedResource> allottedResourceList = serviceInstance.getAllottedResources();
- if(!allottedResourceList.isEmpty()){
- logger.debug("Adding allotted resources to placement demands list");
- for(AllottedResource ar : allottedResourceList){
- if(isBlank(ar.getId())){
- ar.setId(UUID.randomUUID().toString());
- }
- Demand demand = buildDemand(ar.getId(), ar.getModelInfoAllottedResource());
- addCandidates(ar, demand);
- placementDemands.add(demand);
- }
- }
- List<VpnBondingLink> vpnBondingLinkList = serviceInstance.getVpnBondingLinks();
- if(!vpnBondingLinkList.isEmpty()){
- logger.debug("Adding vpn bonding links to placement demands list");
- for(VpnBondingLink vbl:vpnBondingLinkList){
- List<ServiceProxy> serviceProxyList = vbl.getServiceProxies();
- for(ServiceProxy sp : serviceProxyList){
- if(isBlank(sp.getId())){
- sp.setId(UUID.randomUUID().toString());
- }
- Demand demand = buildDemand(sp.getId(), sp.getModelInfoServiceProxy());
- addCandidates(sp, demand);
- placementDemands.add(demand);
- }
- }
- }
- return placementDemands;
- }
-
- /**
- * Builds the license demand list for the homing/licensing request
- *
- */
- private List<Demand> buildLicenseDemands(ServiceInstance serviceInstance){
- logger.trace("Building license information");
- List<Demand> licenseDemands = new ArrayList<Demand>();
- List<GenericVnf> vnfList = serviceInstance.getVnfs();
- if(!vnfList.isEmpty()){
- logger.debug("Adding vnfs to license demands list");
- for(GenericVnf vnf : vnfList){
- Demand demand = buildDemand(vnf.getVnfId(), vnf.getModelInfoGenericVnf());
- licenseDemands.add(demand);
- }
- }
- return licenseDemands;
- }
-
- /**
- * Builds a single demand object
- *
- */
- private Demand buildDemand(String id, ModelInfoMetadata metadata){
- logger.debug("Building demand for service or resource: " + id);
- Demand demand = new Demand();
- if(isNotBlank(id) && isNotBlank(metadata.getModelInstanceName())){
- demand.setServiceResourceId(id);
- demand.setResourceModuleName(metadata.getModelInstanceName());
- demand.setModelInfo(buildModelInfo(metadata));
- }else{
- throw new BpmnError(UNPROCESSABLE, RESOURCE_MISSING_DATA + "modelInstanceName");
- }
- return demand;
- }
-
- /**
- * Builds the resource model info section
- *
- */
- private ModelInfo buildModelInfo(ModelInfoMetadata metadata){
- ModelInfo object = new ModelInfo();
- String invariantUuid = metadata.getModelInvariantUuid();
- String modelUuid = metadata.getModelUuid();
- if(isNotBlank(invariantUuid) && isNotBlank(modelUuid)){
- object.setModelInvariantId(invariantUuid);
- object.setModelVersionId(modelUuid);
- object.setModelName(metadata.getModelName());
- object.setModelVersion(metadata.getModelVersion());
- }else if(isNotBlank(invariantUuid)){
- throw new BpmnError(UNPROCESSABLE, RESOURCE_MISSING_DATA + MODEL_VERSION_ID);
- }else{
- throw new BpmnError(UNPROCESSABLE, RESOURCE_MISSING_DATA + MODEL_INVARIANT_ID);
- }
- return object;
- }
-
- /**
- * Adds required, excluded, and existing candidates to a demand
- *
- */
- private void addCandidates(SolutionCandidates candidates, Demand demand){
- List<Candidate> required = candidates.getRequiredCandidates();
- List<Candidate> excluded = candidates.getExcludedCandidates();
- if(!required.isEmpty()){
- List<org.onap.so.client.sniro.beans.Candidate> cans = new ArrayList<org.onap.so.client.sniro.beans.Candidate>();
- for(Candidate c:required){
- org.onap.so.client.sniro.beans.Candidate can = new org.onap.so.client.sniro.beans.Candidate();
- can.setIdentifierType(c.getIdentifierType());
- can.setIdentifiers(c.getIdentifiers());
- can.setCloudOwner(c.getCloudOwner());
- cans.add(can);
- }
- demand.setRequiredCandidates(cans);
- }
- if(!excluded.isEmpty()){
- List<org.onap.so.client.sniro.beans.Candidate> cans = new ArrayList<org.onap.so.client.sniro.beans.Candidate>();
- for(Candidate c:excluded){
- org.onap.so.client.sniro.beans.Candidate can = new org.onap.so.client.sniro.beans.Candidate();
- can.setIdentifierType(c.getIdentifierType());
- can.setIdentifiers(c.getIdentifiers());
- can.setCloudOwner(c.getCloudOwner());
- cans.add(can);
- }
- demand.setExcludedCandidates(cans);
- }
- //TODO support existing candidates
- }
-
- /**
- * Processes the license solutions and sets to the corresponding generic vnf
- *
- */
- private void processLicenseSolution(ServiceInstance serviceInstance, JSONArray licenseSolutions){
- List<GenericVnf> vnfs = serviceInstance.getVnfs();
-
- logger.debug("Processing the license solution");
- for(int i = 0; i < licenseSolutions.length(); i++){
- JSONObject licenseSolution = licenseSolutions.getJSONObject(i);
- for(GenericVnf vnf:vnfs){
- if(licenseSolution.getString(SERVICE_RESOURCE_ID).equals(vnf.getVnfId())){
- License license = new License();
- JSONArray entitlementPools = licenseSolution.getJSONArray("entitlementPoolUUID");
- List<String> entitlementPoolsList = jsonUtils.StringArrayToList(entitlementPools);
- license.setEntitlementPoolUuids(entitlementPoolsList);
- JSONArray licenseKeys = licenseSolution.getJSONArray("licenseKeyGroupUUID");
- List<String> licenseKeysList = jsonUtils.StringArrayToList(licenseKeys);
- license.setLicenseKeyGroupUuids(licenseKeysList);
-
- vnf.setLicense(license);
- }
- }
- }
- }
-
- /**
- * Processes a placement solution list then correlates and sets each placement solution
- * to its corresponding resource
- *
- */
- private void processPlacementSolution(ServiceInstance serviceInstance, JSONArray placements, int i){
- List<VpnBondingLink> links = serviceInstance.getVpnBondingLinks();
- List<AllottedResource> allottes = serviceInstance.getAllottedResources();
- List<GenericVnf> vnfs = serviceInstance.getVnfs();
-
- logger.debug("Processing placement solution " + i+1);
- for(int p = 0; p < placements.length(); p++){
- JSONObject placement = placements.getJSONObject(p);
- SolutionInfo solutionInfo = new SolutionInfo();
- solutionInfo.setSolutionId(i + 1);
- search: {
- for(VpnBondingLink vbl:links){
- List<ServiceProxy> proxies = vbl.getServiceProxies();
- for(ServiceProxy sp:proxies){
- if(placement.getString(SERVICE_RESOURCE_ID).equals(sp.getId())){
- if(i > 0){
- if(p % 2 == 0){
- VpnBondingLink vblNew = (VpnBondingLink) SerializationUtils.clone(vbl);
- vblNew.setVpnBondingLinkId(UUID.randomUUID().toString());
- links.add(vblNew);
- }
- links.get(links.size() - 1).getServiceProxy(sp.getId()).setServiceInstance(setSolution(solutionInfo, placement));
- }else{
- sp.setServiceInstance(setSolution(solutionInfo, placement));
- }
- break search;
- }
- }
- }
- for(AllottedResource ar:allottes){
- if(placement.getString(SERVICE_RESOURCE_ID).equals(ar.getId())){
- ar.setParentServiceInstance(setSolution(solutionInfo, placement));
- break search;
- }
- }
- for(GenericVnf vnf:vnfs){
- if(placement.getString(SERVICE_RESOURCE_ID).equals(vnf.getVnfId())){
- ServiceInstance si = setSolution(solutionInfo, placement);
- serviceInstance.setSolutionInfo(si.getSolutionInfo());
- serviceInstance.getVnfs().add(si.getVnfs().get(0));
- break search;
- }
- }
- }
- }
- }
-
-
- /**
- * Creates and sets necessary pojos with placement solution data for a given demand
- *
- */
- private ServiceInstance setSolution(SolutionInfo solutionInfo, JSONObject placement){
- logger.debug("Mapping placement solution");
- String invalidMessage = "Sniro Managers Response contains invalid: ";
-
- JSONObject solution = placement.getJSONObject("solution");
- String identifierType = solution.getString(IDENTIFIER_TYPE);
- List<String> identifiersList = jsonUtils.StringArrayToList(solution.getJSONArray("identifiers").toString());
- String identifierValue = identifiersList.get(0);
-
- JSONArray assignments = placement.getJSONArray("assignmentInfo");
- Map<String, String> assignmentsMap = jsonUtils.entryArrayToMap(assignments.toString(), "key", "value");
- solutionInfo.setRehome(Boolean.parseBoolean(assignmentsMap.get("isRehome")));
-
- ServiceInstance si = new ServiceInstance();
- CloudRegion cloud = setCloud(assignmentsMap);
- if(identifierType.equals(CandidateType.SERVICE_INSTANCE_ID.toString())){
- solutionInfo.setHomed(true);
- si.setServiceInstanceId(identifierValue);
- si.setOrchestrationStatus(OrchestrationStatus.CREATED);
- cloud.setLcpCloudRegionId(assignmentsMap.get("cloudRegionId"));
- if(assignmentsMap.containsKey("vnfHostName")){
- logger.debug("Resources has been homed to a vnf");
- GenericVnf vnf = setVnf(assignmentsMap);
- vnf.setCloudRegion(cloud);
- si.getVnfs().add(vnf);
-
- }else if(assignmentsMap.containsKey("primaryPnfName")){
- logger.debug("Resources has been homed to a pnf");
- Pnf priPnf = setPnf(assignmentsMap, "primary");
- priPnf.setCloudRegion(cloud);
- si.getPnfs().add(priPnf);
- if(assignmentsMap.containsKey("secondaryPnfName")){
- Pnf secPnf = setPnf(assignmentsMap, "secondary");
- secPnf.setCloudRegion(cloud);
- si.getPnfs().add(secPnf);
- }
- }
- }else if(identifierType.equals(CandidateType.CLOUD_REGION_ID.toString())){
- logger.debug("Resources has been homed to a cloud region");
- cloud.setLcpCloudRegionId(identifierValue);
- solutionInfo.setHomed(false);
- solutionInfo.setTargetedCloudRegion(cloud);
- si.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
- }else{
- logger.debug(invalidMessage + IDENTIFIER_TYPE);
- throw new BpmnError(UNPROCESSABLE, invalidMessage + IDENTIFIER_TYPE);
- }
- si.setSolutionInfo(solutionInfo);
- return si;
- }
-
- /**
- * Sets the cloud data to a cloud region object
- *
- */
- private CloudRegion setCloud(Map<String, String> assignmentsMap){
- CloudRegion cloud = new CloudRegion();
- cloud.setCloudOwner(assignmentsMap.get("cloudOwner"));
- cloud.setCloudRegionVersion(assignmentsMap.get("aicVersion"));
- cloud.setComplex(assignmentsMap.get("aicClli"));
- return cloud;
- }
-
- /**
- * Sets the vnf data to a generic vnf object
- *
- */
- private GenericVnf setVnf(Map<String, String> assignmentsMap){
- GenericVnf vnf = new GenericVnf();
- vnf.setOrchestrationStatus(OrchestrationStatus.CREATED);
- vnf.setVnfName(assignmentsMap.get("vnfHostName"));
- vnf.setVnfId(assignmentsMap.get("vnfId"));
- return vnf;
- }
-
- /**
- * Sets the pnf data to a pnf object
- *
- */
- private Pnf setPnf(Map<String, String> assignmentsMap, String role){
- Pnf pnf = new Pnf();
- pnf.setRole(role);
- pnf.setOrchestrationStatus(OrchestrationStatus.CREATED);
- pnf.setPnfName(assignmentsMap.get(role + "PnfName"));
- return pnf;
- }
+ private static final Logger logger = LoggerFactory.getLogger(SniroHomingV2.class);
+ private JsonUtils jsonUtils = new JsonUtils();
+ @Autowired
+ private Environment env;
+ @Autowired
+ private SniroClient client;
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+ private static final String MODEL_NAME = "modelName";
+ private static final String MODEL_INVARIANT_ID = "modelInvariantId";
+ private static final String MODEL_VERSION_ID = "modelVersionId";
+ private static final String MODEL_VERSION = "modelVersion";
+ private static final String SERVICE_RESOURCE_ID = "serviceResourceId";
+ private static final String RESOURCE_MODULE_NAME = "resourceModuleName";
+ private static final String RESOURCE_MODEL_INFO = "resourceModelInfo";
+ private static final String IDENTIFIER_TYPE = "identifierType";
+ private static final String SOLUTIONS = "solutions";
+ private static final String RESOURCE_MISSING_DATA = "Resource does not contain: ";
+ private static final String SERVICE_MISSING_DATA = "Service Instance does not contain: ";
+ private static final String UNPROCESSABLE = "422";
+ private static final int INTERNAL = 500;
+
+ /**
+ * Generates the request payload then sends to sniro manager to perform homing and licensing for the provided
+ * demands
+ *
+ * @param execution
+ */
+ public void callSniro(BuildingBlockExecution execution) {
+ logger.debug("Started Sniro Homing Call Sniro");
+ try {
+ GeneralBuildingBlock bb = execution.getGeneralBuildingBlock();
+
+ RequestContext requestContext = bb.getRequestContext();
+ RequestParameters requestParams = requestContext.getRequestParameters();
+ String requestId = requestContext.getMsoRequestId();
+
+ ServiceInstance serviceInstance = bb.getCustomer().getServiceSubscription().getServiceInstances().get(0);
+ Customer customer = bb.getCustomer();
+
+ String timeout = execution.getVariable("timeout");
+ if (isBlank(timeout)) {
+ timeout = env.getProperty("sniro.manager.timeout", "PT30M");
+ }
+
+ SniroManagerRequest request = new SniroManagerRequest();
+
+ RequestInfo requestInfo = buildRequestInfo(requestId, timeout);
+ request.setRequestInformation(requestInfo);
+
+ ServiceInfo serviceInfo = buildServiceInfo(serviceInstance);
+ request.setServiceInformation(serviceInfo);
+
+ PlacementInfo placementInfo = buildPlacementInfo(customer, requestParams);
+
+ List<Demand> placementDemands = buildPlacementDemands(serviceInstance);
+ placementInfo.setDemands(placementDemands);
+ request.setPlacementInformation(placementInfo);
+
+ LicenseInfo licenseInfo = new LicenseInfo();
+
+ List<Demand> licenseDemands = buildLicenseDemands(serviceInstance);
+ licenseInfo.setDemands(licenseDemands);
+ request.setLicenseInformation(licenseInfo);
+
+ if (placementDemands.size() > 0 || licenseDemands.size() > 0) {
+ client.postDemands(request);
+ } else {
+ logger.debug(SERVICE_MISSING_DATA + "resources eligible for homing or licensing");
+ throw new BpmnError(UNPROCESSABLE, SERVICE_MISSING_DATA + "resources eligible for homing or licensing");
+ }
+
+ // Variables for ReceiveWorkflowMessage subflow
+ execution.setVariable("asyncCorrelator", requestId);
+ execution.setVariable("asyncMessageType", "SNIROResponse");
+ execution.setVariable("asyncTimeout", timeout);
+
+ logger.trace("Completed Sniro Homing Call Sniro");
+ } catch (BpmnError e) {
+ logger.error("Exception occurred", e);
+ exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(e.getErrorCode()), e.getMessage());
+ } catch (BadResponseException e) {
+ logger.error("Exception occurred", e);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 400, e.getMessage());
+ } catch (Exception e) {
+ logger.error("Exception occurred", e);
+ exceptionUtil.buildAndThrowWorkflowException(execution, INTERNAL,
+ "Internal Error - occurred while preparing sniro request: " + e.getMessage());
+ }
+ }
+
+ /**
+ * Validates, processes, and sets the homing and licensing solutions that are returned by sniro manager
+ *
+ * @param execution
+ * @param asyncResponse
+ */
+ public void processSolution(BuildingBlockExecution execution, String asyncResponse) {
+ logger.trace("Started Sniro Homing Process Solution");
+ try {
+ // TODO improve handling multiple solutions but is dependent on sniro enhancing api + work with sniro
+ // conductor to improve "inventoryType" representation
+ validateSolution(asyncResponse);
+ ServiceInstance serviceInstance = execution.getGeneralBuildingBlock().getCustomer().getServiceSubscription()
+ .getServiceInstances().get(0);
+
+ logger.debug("Processing sniro manager asyncronous response");
+ JSONObject response = new JSONObject(asyncResponse);
+ if (response.has(SOLUTIONS)) {
+ JSONObject allSolutions = response.getJSONObject(SOLUTIONS);
+ if (allSolutions.has("placementSolutions")) {
+ JSONArray placementSolutions = allSolutions.getJSONArray("placementSolutions");
+ for (int i = 0; i < placementSolutions.length(); i++) {
+ JSONArray placements = placementSolutions.getJSONArray(i);
+ processPlacementSolution(serviceInstance, placements, i);
+ }
+ }
+ if (allSolutions.has("licenseSolutions")) {
+ JSONArray licenseSolutions = allSolutions.getJSONArray("licenseSolutions");
+ if (licenseSolutions.length() > 0) {
+ processLicenseSolution(serviceInstance, licenseSolutions);
+ }
+ }
+ } else {
+ throw new BpmnError(UNPROCESSABLE, "Sniro Managers response does not contain: " + SOLUTIONS);
+ }
+
+ execution.setVariable("generalBuildingBlock", execution.getGeneralBuildingBlock());
+
+ logger.trace("Completed Sniro Homing Process Solution");
+ } catch (BpmnError e) {
+ logger.error("Exception occurred", e);
+ exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(e.getErrorCode()), e.getMessage());
+ } catch (BadResponseException e) {
+ logger.error("Exception occurred", e);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 400, e.getMessage());
+ } catch (Exception e) {
+ logger.error("Exception occurred", e);
+ exceptionUtil.buildAndThrowWorkflowException(execution, INTERNAL,
+ "Internal Error - occurred while processing sniro asynchronous response: " + e.getMessage());
+ }
+ }
+
+ /**
+ * Builds the request information section for the homing/licensing request
+ *
+ * @throws Exception
+ */
+ private RequestInfo buildRequestInfo(String requestId, String timeout) throws Exception {
+ logger.trace("Building request information");
+ RequestInfo requestInfo = new RequestInfo();
+ if (requestId != null) {
+ String host = env.getProperty("mso.workflow.message.endpoint");
+ String callbackUrl = host + "/" + UriUtils.encodePathSegment("SNIROResponse", "UTF-8") + "/"
+ + UriUtils.encodePathSegment(requestId, "UTF-8");
+
+ Duration d = Duration.parse(timeout);
+
+ requestInfo.setTransactionId(requestId);
+ requestInfo.setRequestId(requestId);
+ requestInfo.setCallbackUrl(callbackUrl);
+ requestInfo.setRequestType("create");
+ requestInfo.setTimeout(d.getSeconds());
+
+ } else {
+ throw new BpmnError(UNPROCESSABLE, "Request Context does not contain: requestId");
+ }
+ return requestInfo;
+ }
+
+ /**
+ * Builds the request information section for the homing/licensing request
+ *
+ */
+ private ServiceInfo buildServiceInfo(ServiceInstance serviceInstance) {
+ logger.trace("Building service information");
+ ServiceInfo info = new ServiceInfo();
+ ModelInfoServiceInstance modelInfo = serviceInstance.getModelInfoServiceInstance();
+ if (isNotBlank(modelInfo.getModelInvariantUuid()) && isNotBlank(modelInfo.getModelUuid())) {
+ info.setServiceInstanceId(serviceInstance.getServiceInstanceId());
+ if (modelInfo.getServiceType() != null && modelInfo.getServiceType().length() > 0) { // temp solution
+ info.setServiceName(modelInfo.getServiceType());
+ }
+ if (modelInfo.getServiceRole() != null) {
+ info.setServiceRole(modelInfo.getServiceRole());
+ }
+ info.setModelInfo(buildModelInfo(modelInfo));
+ } else {
+ throw new BpmnError(UNPROCESSABLE, SERVICE_MISSING_DATA + MODEL_VERSION_ID + ", " + MODEL_INVARIANT_ID);
+ }
+ return info;
+ }
+
+ /**
+ * Builds initial section of placement info for the homing/licensing request
+ *
+ */
+ private PlacementInfo buildPlacementInfo(Customer customer, RequestParameters requestParams) {
+ PlacementInfo placementInfo = new PlacementInfo();
+ if (customer != null) {
+ logger.debug("Adding subscriber to placement information");
+ SubscriberInfo subscriber = new SubscriberInfo();
+ subscriber.setGlobalSubscriberId(customer.getGlobalCustomerId());
+ subscriber.setSubscriberName(customer.getSubscriberName());
+ subscriber.setSubscriberCommonSiteId(customer.getSubscriberCommonSiteId());
+ placementInfo.setSubscriberInfo(subscriber);
+ if (requestParams != null) {
+ logger.debug("Adding request parameters to placement information");
+ placementInfo.setRequestParameters(requestParams.toJsonString());
+ }
+ } else {
+ throw new BpmnError(UNPROCESSABLE, SERVICE_MISSING_DATA + "customer");
+ }
+ return placementInfo;
+
+ }
+
+ /**
+ * Builds the placement demand list for the homing/licensing request
+ *
+ */
+ private List<Demand> buildPlacementDemands(ServiceInstance serviceInstance) {
+ logger.trace("Building placement information demands");
+ List<Demand> placementDemands = new ArrayList<Demand>();
+
+ List<AllottedResource> allottedResourceList = serviceInstance.getAllottedResources();
+ if (!allottedResourceList.isEmpty()) {
+ logger.debug("Adding allotted resources to placement demands list");
+ for (AllottedResource ar : allottedResourceList) {
+ if (isBlank(ar.getId())) {
+ ar.setId(UUID.randomUUID().toString());
+ }
+ Demand demand = buildDemand(ar.getId(), ar.getModelInfoAllottedResource());
+ addCandidates(ar, demand);
+ placementDemands.add(demand);
+ }
+ }
+ List<VpnBondingLink> vpnBondingLinkList = serviceInstance.getVpnBondingLinks();
+ if (!vpnBondingLinkList.isEmpty()) {
+ logger.debug("Adding vpn bonding links to placement demands list");
+ for (VpnBondingLink vbl : vpnBondingLinkList) {
+ List<ServiceProxy> serviceProxyList = vbl.getServiceProxies();
+ for (ServiceProxy sp : serviceProxyList) {
+ if (isBlank(sp.getId())) {
+ sp.setId(UUID.randomUUID().toString());
+ }
+ Demand demand = buildDemand(sp.getId(), sp.getModelInfoServiceProxy());
+ addCandidates(sp, demand);
+ placementDemands.add(demand);
+ }
+ }
+ }
+ return placementDemands;
+ }
+
+ /**
+ * Builds the license demand list for the homing/licensing request
+ *
+ */
+ private List<Demand> buildLicenseDemands(ServiceInstance serviceInstance) {
+ logger.trace("Building license information");
+ List<Demand> licenseDemands = new ArrayList<Demand>();
+ List<GenericVnf> vnfList = serviceInstance.getVnfs();
+ if (!vnfList.isEmpty()) {
+ logger.debug("Adding vnfs to license demands list");
+ for (GenericVnf vnf : vnfList) {
+ Demand demand = buildDemand(vnf.getVnfId(), vnf.getModelInfoGenericVnf());
+ licenseDemands.add(demand);
+ }
+ }
+ return licenseDemands;
+ }
+
+ /**
+ * Builds a single demand object
+ *
+ */
+ private Demand buildDemand(String id, ModelInfoMetadata metadata) {
+ logger.debug("Building demand for service or resource: " + id);
+ Demand demand = new Demand();
+ if (isNotBlank(id) && isNotBlank(metadata.getModelInstanceName())) {
+ demand.setServiceResourceId(id);
+ demand.setResourceModuleName(metadata.getModelInstanceName());
+ demand.setModelInfo(buildModelInfo(metadata));
+ } else {
+ throw new BpmnError(UNPROCESSABLE, RESOURCE_MISSING_DATA + "modelInstanceName");
+ }
+ return demand;
+ }
+
+ /**
+ * Builds the resource model info section
+ *
+ */
+ private ModelInfo buildModelInfo(ModelInfoMetadata metadata) {
+ ModelInfo object = new ModelInfo();
+ String invariantUuid = metadata.getModelInvariantUuid();
+ String modelUuid = metadata.getModelUuid();
+ if (isNotBlank(invariantUuid) && isNotBlank(modelUuid)) {
+ object.setModelInvariantId(invariantUuid);
+ object.setModelVersionId(modelUuid);
+ object.setModelName(metadata.getModelName());
+ object.setModelVersion(metadata.getModelVersion());
+ } else if (isNotBlank(invariantUuid)) {
+ throw new BpmnError(UNPROCESSABLE, RESOURCE_MISSING_DATA + MODEL_VERSION_ID);
+ } else {
+ throw new BpmnError(UNPROCESSABLE, RESOURCE_MISSING_DATA + MODEL_INVARIANT_ID);
+ }
+ return object;
+ }
+
+ /**
+ * Adds required, excluded, and existing candidates to a demand
+ *
+ */
+ private void addCandidates(SolutionCandidates candidates, Demand demand) {
+ List<Candidate> required = candidates.getRequiredCandidates();
+ List<Candidate> excluded = candidates.getExcludedCandidates();
+ if (!required.isEmpty()) {
+ List<org.onap.so.client.sniro.beans.Candidate> cans =
+ new ArrayList<org.onap.so.client.sniro.beans.Candidate>();
+ for (Candidate c : required) {
+ org.onap.so.client.sniro.beans.Candidate can = new org.onap.so.client.sniro.beans.Candidate();
+ can.setIdentifierType(c.getIdentifierType());
+ can.setIdentifiers(c.getIdentifiers());
+ can.setCloudOwner(c.getCloudOwner());
+ cans.add(can);
+ }
+ demand.setRequiredCandidates(cans);
+ }
+ if (!excluded.isEmpty()) {
+ List<org.onap.so.client.sniro.beans.Candidate> cans =
+ new ArrayList<org.onap.so.client.sniro.beans.Candidate>();
+ for (Candidate c : excluded) {
+ org.onap.so.client.sniro.beans.Candidate can = new org.onap.so.client.sniro.beans.Candidate();
+ can.setIdentifierType(c.getIdentifierType());
+ can.setIdentifiers(c.getIdentifiers());
+ can.setCloudOwner(c.getCloudOwner());
+ cans.add(can);
+ }
+ demand.setExcludedCandidates(cans);
+ }
+ // TODO support existing candidates
+ }
+
+ /**
+ * Processes the license solutions and sets to the corresponding generic vnf
+ *
+ */
+ private void processLicenseSolution(ServiceInstance serviceInstance, JSONArray licenseSolutions) {
+ List<GenericVnf> vnfs = serviceInstance.getVnfs();
+
+ logger.debug("Processing the license solution");
+ for (int i = 0; i < licenseSolutions.length(); i++) {
+ JSONObject licenseSolution = licenseSolutions.getJSONObject(i);
+ for (GenericVnf vnf : vnfs) {
+ if (licenseSolution.getString(SERVICE_RESOURCE_ID).equals(vnf.getVnfId())) {
+ License license = new License();
+ JSONArray entitlementPools = licenseSolution.getJSONArray("entitlementPoolUUID");
+ List<String> entitlementPoolsList = jsonUtils.StringArrayToList(entitlementPools);
+ license.setEntitlementPoolUuids(entitlementPoolsList);
+ JSONArray licenseKeys = licenseSolution.getJSONArray("licenseKeyGroupUUID");
+ List<String> licenseKeysList = jsonUtils.StringArrayToList(licenseKeys);
+ license.setLicenseKeyGroupUuids(licenseKeysList);
+
+ vnf.setLicense(license);
+ }
+ }
+ }
+ }
+
+ /**
+ * Processes a placement solution list then correlates and sets each placement solution to its corresponding
+ * resource
+ *
+ */
+ private void processPlacementSolution(ServiceInstance serviceInstance, JSONArray placements, int i) {
+ List<VpnBondingLink> links = serviceInstance.getVpnBondingLinks();
+ List<AllottedResource> allottes = serviceInstance.getAllottedResources();
+ List<GenericVnf> vnfs = serviceInstance.getVnfs();
+
+ logger.debug("Processing placement solution " + i + 1);
+ for (int p = 0; p < placements.length(); p++) {
+ JSONObject placement = placements.getJSONObject(p);
+ SolutionInfo solutionInfo = new SolutionInfo();
+ solutionInfo.setSolutionId(i + 1);
+ search: {
+ for (VpnBondingLink vbl : links) {
+ List<ServiceProxy> proxies = vbl.getServiceProxies();
+ for (ServiceProxy sp : proxies) {
+ if (placement.getString(SERVICE_RESOURCE_ID).equals(sp.getId())) {
+ if (i > 0) {
+ if (p % 2 == 0) {
+ VpnBondingLink vblNew = (VpnBondingLink) SerializationUtils.clone(vbl);
+ vblNew.setVpnBondingLinkId(UUID.randomUUID().toString());
+ links.add(vblNew);
+ }
+ links.get(links.size() - 1).getServiceProxy(sp.getId())
+ .setServiceInstance(setSolution(solutionInfo, placement));
+ } else {
+ sp.setServiceInstance(setSolution(solutionInfo, placement));
+ }
+ break search;
+ }
+ }
+ }
+ for (AllottedResource ar : allottes) {
+ if (placement.getString(SERVICE_RESOURCE_ID).equals(ar.getId())) {
+ ar.setParentServiceInstance(setSolution(solutionInfo, placement));
+ break search;
+ }
+ }
+ for (GenericVnf vnf : vnfs) {
+ if (placement.getString(SERVICE_RESOURCE_ID).equals(vnf.getVnfId())) {
+ ServiceInstance si = setSolution(solutionInfo, placement);
+ serviceInstance.setSolutionInfo(si.getSolutionInfo());
+ serviceInstance.getVnfs().add(si.getVnfs().get(0));
+ break search;
+ }
+ }
+ }
+ }
+ }
+
+
+ /**
+ * Creates and sets necessary pojos with placement solution data for a given demand
+ *
+ */
+ private ServiceInstance setSolution(SolutionInfo solutionInfo, JSONObject placement) {
+ logger.debug("Mapping placement solution");
+ String invalidMessage = "Sniro Managers Response contains invalid: ";
+
+ JSONObject solution = placement.getJSONObject("solution");
+ String identifierType = solution.getString(IDENTIFIER_TYPE);
+ List<String> identifiersList = jsonUtils.StringArrayToList(solution.getJSONArray("identifiers").toString());
+ String identifierValue = identifiersList.get(0);
+
+ JSONArray assignments = placement.getJSONArray("assignmentInfo");
+ Map<String, String> assignmentsMap = jsonUtils.entryArrayToMap(assignments.toString(), "key", "value");
+ solutionInfo.setRehome(Boolean.parseBoolean(assignmentsMap.get("isRehome")));
+
+ ServiceInstance si = new ServiceInstance();
+ CloudRegion cloud = setCloud(assignmentsMap);
+ if (identifierType.equals(CandidateType.SERVICE_INSTANCE_ID.toString())) {
+ solutionInfo.setHomed(true);
+ si.setServiceInstanceId(identifierValue);
+ si.setOrchestrationStatus(OrchestrationStatus.CREATED);
+ cloud.setLcpCloudRegionId(assignmentsMap.get("cloudRegionId"));
+ if (assignmentsMap.containsKey("vnfHostName")) {
+ logger.debug("Resources has been homed to a vnf");
+ GenericVnf vnf = setVnf(assignmentsMap);
+ vnf.setCloudRegion(cloud);
+ si.getVnfs().add(vnf);
+
+ } else if (assignmentsMap.containsKey("primaryPnfName")) {
+ logger.debug("Resources has been homed to a pnf");
+ Pnf priPnf = setPnf(assignmentsMap, "primary");
+ priPnf.setCloudRegion(cloud);
+ si.getPnfs().add(priPnf);
+ if (assignmentsMap.containsKey("secondaryPnfName")) {
+ Pnf secPnf = setPnf(assignmentsMap, "secondary");
+ secPnf.setCloudRegion(cloud);
+ si.getPnfs().add(secPnf);
+ }
+ }
+ } else if (identifierType.equals(CandidateType.CLOUD_REGION_ID.toString())) {
+ logger.debug("Resources has been homed to a cloud region");
+ cloud.setLcpCloudRegionId(identifierValue);
+ solutionInfo.setHomed(false);
+ solutionInfo.setTargetedCloudRegion(cloud);
+ si.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
+ } else {
+ logger.debug(invalidMessage + IDENTIFIER_TYPE);
+ throw new BpmnError(UNPROCESSABLE, invalidMessage + IDENTIFIER_TYPE);
+ }
+ si.setSolutionInfo(solutionInfo);
+ return si;
+ }
+
+ /**
+ * Sets the cloud data to a cloud region object
+ *
+ */
+ private CloudRegion setCloud(Map<String, String> assignmentsMap) {
+ CloudRegion cloud = new CloudRegion();
+ cloud.setCloudOwner(assignmentsMap.get("cloudOwner"));
+ cloud.setCloudRegionVersion(assignmentsMap.get("aicVersion"));
+ cloud.setComplex(assignmentsMap.get("aicClli"));
+ return cloud;
+ }
+
+ /**
+ * Sets the vnf data to a generic vnf object
+ *
+ */
+ private GenericVnf setVnf(Map<String, String> assignmentsMap) {
+ GenericVnf vnf = new GenericVnf();
+ vnf.setOrchestrationStatus(OrchestrationStatus.CREATED);
+ vnf.setVnfName(assignmentsMap.get("vnfHostName"));
+ vnf.setVnfId(assignmentsMap.get("vnfId"));
+ return vnf;
+ }
+
+ /**
+ * Sets the pnf data to a pnf object
+ *
+ */
+ private Pnf setPnf(Map<String, String> assignmentsMap, String role) {
+ Pnf pnf = new Pnf();
+ pnf.setRole(role);
+ pnf.setOrchestrationStatus(OrchestrationStatus.CREATED);
+ pnf.setPnfName(assignmentsMap.get(role + "PnfName"));
+ return pnf;
+ }
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICommonTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICommonTasks.java
index bdb46e8d2b..7b518dcc86 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICommonTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICommonTasks.java
@@ -21,7 +21,6 @@
package org.onap.so.bpmn.infrastructure.aai.tasks;
import java.util.Optional;
-
import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
@@ -33,24 +32,25 @@ import org.springframework.stereotype.Component;
@Component
public class AAICommonTasks {
-
- @Autowired
- private ExceptionBuilder exceptionUtil;
- @Autowired
- private ExtractPojosForBB extractPojosForBB;
-
- public Optional<String> getServiceType(BuildingBlockExecution execution) {
- try {
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- ModelInfoServiceInstance model = serviceInstance.getModelInfoServiceInstance();
- if (model != null) {
- return Optional.of(model.getServiceType());
- }
- } catch(Exception e) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, e);
- }
- return Optional.empty();
- }
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+ @Autowired
+ private ExtractPojosForBB extractPojosForBB;
+
+ public Optional<String> getServiceType(BuildingBlockExecution execution) {
+ try {
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+
+ ModelInfoServiceInstance model = serviceInstance.getModelInfoServiceInstance();
+ if (model != null) {
+ return Optional.of(model.getServiceType());
+ }
+ } catch (Exception e) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, e);
+ }
+ return Optional.empty();
+ }
-} \ No newline at end of file
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java
index 279957ca1e..4d4b7c9ad2 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java
@@ -29,7 +29,6 @@ import java.util.TreeSet;
import java.util.UUID;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
@@ -74,493 +73,524 @@ import org.springframework.stereotype.Component;
@Component
public class AAICreateTasks {
- private static final Logger logger = LoggerFactory.getLogger(AAICreateTasks.class);
- private static final String networkTypeProvider = "PROVIDER";
- private static String NETWORK_COLLECTION_NAME = "networkCollectionName";
- private static String CONTRAIL_NETWORK_POLICY_FQDN_LIST = "contrailNetworkPolicyFqdnList";
- private static String HEAT_STACK_ID = "heatStackId";
- private static String NETWORK_POLICY_FQDN_PARAM = "network-policy-fqdn";
- @Autowired
- private AAIServiceInstanceResources aaiSIResources;
- @Autowired
- private AAIVnfResources aaiVnfResources;
- @Autowired
- private ExceptionBuilder exceptionUtil;
- @Autowired
- private ExtractPojosForBB extractPojosForBB;
- @Autowired
- private AAIVolumeGroupResources aaiVolumeGroupResources;
- @Autowired
- private AAIVfModuleResources aaiVfModuleResources;
- @Autowired
- private AAINetworkResources aaiNetworkResources;
- @Autowired
- private AAIVpnBindingResources aaiVpnBindingResources;
- @Autowired
- private AAIConfigurationResources aaiConfigurationResources;
- @Autowired
- private AAIInstanceGroupResources aaiInstanceGroupResources;
- @Autowired
- private Environment env;
-
- public void createServiceInstance(BuildingBlockExecution execution) {
- try {
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- Customer customer = execution.getGeneralBuildingBlock().getCustomer();
- aaiSIResources.createServiceInstance(serviceInstance, customer);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void createServiceSubscription(BuildingBlockExecution execution){
- try{
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution,
- ResourceKey.SERVICE_INSTANCE_ID);
+ private static final Logger logger = LoggerFactory.getLogger(AAICreateTasks.class);
+ private static final String networkTypeProvider = "PROVIDER";
+ private static String NETWORK_COLLECTION_NAME = "networkCollectionName";
+ private static String CONTRAIL_NETWORK_POLICY_FQDN_LIST = "contrailNetworkPolicyFqdnList";
+ private static String HEAT_STACK_ID = "heatStackId";
+ private static String NETWORK_POLICY_FQDN_PARAM = "network-policy-fqdn";
+ @Autowired
+ private AAIServiceInstanceResources aaiSIResources;
+ @Autowired
+ private AAIVnfResources aaiVnfResources;
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+ @Autowired
+ private ExtractPojosForBB extractPojosForBB;
+ @Autowired
+ private AAIVolumeGroupResources aaiVolumeGroupResources;
+ @Autowired
+ private AAIVfModuleResources aaiVfModuleResources;
+ @Autowired
+ private AAINetworkResources aaiNetworkResources;
+ @Autowired
+ private AAIVpnBindingResources aaiVpnBindingResources;
+ @Autowired
+ private AAIConfigurationResources aaiConfigurationResources;
+ @Autowired
+ private AAIInstanceGroupResources aaiInstanceGroupResources;
+ @Autowired
+ private Environment env;
+
+ public void createServiceInstance(BuildingBlockExecution execution) {
+ try {
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ Customer customer = execution.getGeneralBuildingBlock().getCustomer();
+ aaiSIResources.createServiceInstance(serviceInstance, customer);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void createServiceSubscription(BuildingBlockExecution execution) {
+ try {
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
Customer customer = execution.getGeneralBuildingBlock().getCustomer();
if (null == customer) {
- String errorMessage = "Exception in creating ServiceSubscription. Customer not present for ServiceInstanceID: "
- + serviceInstance.getServiceInstanceId();
- logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), errorMessage, "BPMN",
- ErrorCode.UnknownError.getValue(), errorMessage);
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, errorMessage);
+ String errorMessage =
+ "Exception in creating ServiceSubscription. Customer not present for ServiceInstanceID: "
+ + serviceInstance.getServiceInstanceId();
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), errorMessage, "BPMN",
+ ErrorCode.UnknownError.getValue(), errorMessage);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, errorMessage);
}
aaiSIResources.createServiceSubscription(customer);
} catch (BpmnError ex) {
throw ex;
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
- catch (Exception ex) {
+ }
+
+ public void createProject(BuildingBlockExecution execution) {
+ try {
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ Project project = serviceInstance.getProject();
+ if (project != null) {
+ if (project.getProjectName() == null || "".equals(project.getProjectName())) {
+ logger.info("ProjectName is null in input. Skipping create project...");
+ } else {
+ aaiSIResources.createProjectandConnectServiceInstance(project, serviceInstance);
+ }
+ }
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void createOwningEntity(BuildingBlockExecution execution) {
+ try {
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ OwningEntity owningEntity = serviceInstance.getOwningEntity();
+ String owningEntityId = owningEntity.getOwningEntityId();
+ String owningEntityName = owningEntity.getOwningEntityName();
+ if (owningEntityId == null || "".equals(owningEntityId)) {
+ String msg = "Exception in AAICreateOwningEntity. OwningEntityId is null.";
+ execution.setVariable("ErrorCreateOEAAI", msg);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg);
+ } else {
+ if (aaiSIResources.existsOwningEntity(owningEntity)) {
+ aaiSIResources.connectOwningEntityandServiceInstance(owningEntity, serviceInstance);
+ } else {
+ if (owningEntityName == null || "".equals(owningEntityName)) {
+ String msg =
+ "Exception in AAICreateOwningEntity. Can't create an owningEntity with no owningEntityName.";
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ ErrorCode.UnknownError.getValue(), msg);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg);
+ } else {
+ if (aaiSIResources.existsOwningEntityName(owningEntityName)) {
+ String msg =
+ "Exception in AAICreateOwningEntity. Can't create OwningEntity as name already exists in AAI associated with a different owning-entity-id (name must be unique)";
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg,
+ "BPMN", ErrorCode.UnknownError.getValue(), msg);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg);
+ } else {
+ aaiSIResources.createOwningEntityandConnectServiceInstance(owningEntity, serviceInstance);
+ }
+ }
+ }
+ }
+ } catch (Exception ex) {
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
}
- public void createProject(BuildingBlockExecution execution) {
- try {
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- Project project = serviceInstance.getProject();
- if(project != null) {
- if (project.getProjectName() == null || "".equals(project.getProjectName())) {
- logger.info("ProjectName is null in input. Skipping create project...");
- } else {
- aaiSIResources.createProjectandConnectServiceInstance(project, serviceInstance);
- }
- }
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void createOwningEntity(BuildingBlockExecution execution) {
- try {
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- OwningEntity owningEntity = serviceInstance.getOwningEntity();
- String owningEntityId = owningEntity.getOwningEntityId();
- String owningEntityName = owningEntity.getOwningEntityName();
- if (owningEntityId == null || "".equals(owningEntityId)) {
- String msg = "Exception in AAICreateOwningEntity. OwningEntityId is null.";
- execution.setVariable("ErrorCreateOEAAI", msg);
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg);
- } else {
- if (aaiSIResources.existsOwningEntity(owningEntity)) {
- aaiSIResources.connectOwningEntityandServiceInstance(owningEntity, serviceInstance);
- } else {
- if (owningEntityName == null || "".equals(owningEntityName)) {
- String msg = "Exception in AAICreateOwningEntity. Can't create an owningEntity with no owningEntityName.";
- logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
- ErrorCode.UnknownError.getValue(), msg);
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg);
- } else {
- if(aaiSIResources.existsOwningEntityName(owningEntityName)){
- String msg = "Exception in AAICreateOwningEntity. Can't create OwningEntity as name already exists in AAI associated with a different owning-entity-id (name must be unique)";
- logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
- ErrorCode.UnknownError.getValue(), msg);
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg);
- }else{
- aaiSIResources.createOwningEntityandConnectServiceInstance(owningEntity, serviceInstance);
- }
- }
- }
- }
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void createVnf(BuildingBlockExecution execution) {
- try {
- GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- execution.setVariable("callHoming", Boolean.TRUE.equals(vnf.isCallHoming()));
- aaiVnfResources.createVnfandConnectServiceInstance(vnf, serviceInstance);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void createPlatform(BuildingBlockExecution execution) {
- try {
- GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- Platform platform = vnf.getPlatform();
- if(platform != null) {
- if (platform.getPlatformName() == null || "".equals(platform.getPlatformName())) {
- logger.debug("PlatformName is null in input. Skipping create platform...");
- } else {
- List<String> platforms = splitCDL(platform.getPlatformName());
- platforms.stream().forEach(platformName -> aaiVnfResources.createPlatformandConnectVnf(new Platform(platformName),vnf));
- }
- }
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
-
- }
-
- public List<String> splitCDL(String str){
- return Stream.of(str.split(","))
- .map(String::trim)
- .map (elem -> new String(elem))
- .collect(Collectors.toList());
- }
-
- public void createLineOfBusiness(BuildingBlockExecution execution) {
- try {
- GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- LineOfBusiness lineOfBusiness = vnf.getLineOfBusiness();
- if(lineOfBusiness != null) {
- if (lineOfBusiness.getLineOfBusinessName() == null || "".equals(lineOfBusiness.getLineOfBusinessName())) {
- logger.info("lineOfBusiness is null in input. Skipping create lineOfBusiness...");
- } else {
- List<String> lineOfBussinesses = splitCDL(lineOfBusiness.getLineOfBusinessName());
- lineOfBussinesses.stream().forEach(lobName -> aaiVnfResources.createLineOfBusinessandConnectVnf(new LineOfBusiness(lobName),vnf));
- }
- }
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void createVolumeGroup(BuildingBlockExecution execution) {
- try {
- GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
-
- GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
- CloudRegion cloudRegion = gBBInput.getCloudRegion();
- aaiVolumeGroupResources.createVolumeGroup(volumeGroup, cloudRegion);
- aaiVolumeGroupResources.connectVolumeGroupToVnf(genericVnf, volumeGroup, cloudRegion);
- aaiVolumeGroupResources.connectVolumeGroupToTenant(volumeGroup,cloudRegion);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void createVfModule(BuildingBlockExecution execution) {
- try {
- GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
- int moduleIndex = 0;
- if (vfModule.getModelInfoVfModule() != null && !Boolean.TRUE.equals(vfModule.getModelInfoVfModule().getIsBaseBoolean())) {
- moduleIndex = this.getLowestUnusedVfModuleIndexFromAAIVnfResponse(vnf, vfModule);
- }
- vfModule.setModuleIndex(moduleIndex);
- aaiVfModuleResources.createVfModule(vfModule, vnf);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- /**
- * BPMN access method to establish relationships in AAI
- * @param execution
- * @throws Exception
- */
- public void connectVfModuleToVolumeGroup(BuildingBlockExecution execution) {
- try {
- GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
- VolumeGroup volumeGroup = null;
- try{
- volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
- } catch (BBObjectNotFoundException e){
- logger.info("VolumeGroup not found. Skipping Connect between VfModule and VolumeGroup");
- }
- if (volumeGroup != null) {
- aaiVfModuleResources.connectVfModuleToVolumeGroup(vnf, vfModule, volumeGroup, execution.getGeneralBuildingBlock().getCloudRegion());
- }
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- /**
- * BPMN access method to execute Create L3Network operation (PUT )in AAI
- * @param execution
- * @throws Exception
- */
- public void createNetwork(BuildingBlockExecution execution) {
- try {
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
- //set default to false. ToBe updated by SDNC
- l3network.setIsBoundToVpn(false);
- //define is bound to vpn flag as true if NEUTRON_NETWORK_TYPE is PROVIDER
- if (l3network.getModelInfoNetwork().getNeutronNetworkType().equalsIgnoreCase(networkTypeProvider))
- l3network.setIsBoundToVpn(true);
- //put network shell in AAI
- aaiNetworkResources.createNetworkConnectToServiceInstance(l3network, serviceInstance);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
- public void createCustomer(BuildingBlockExecution execution) throws Exception {
- try {
- Customer customer = execution.getGeneralBuildingBlock().getCustomer();
-
- aaiVpnBindingResources.createCustomer(customer);
- } catch(Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- /**
- * BPMN access method to execute NetworkCollection operation (PUT) in AAI
- * @param execution
- * @throws Exception
- */
- public void createNetworkCollection(BuildingBlockExecution execution) {
- try {
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- Collection networkCollection = serviceInstance.getCollection();
- //pass name generated for NetworkCollection/NetworkCollectionInstanceGroup in previous step of the BB flow
- //put shell in AAI
- networkCollection.setName(execution.getVariable(NETWORK_COLLECTION_NAME));
- aaiNetworkResources.createNetworkCollection(networkCollection);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- /**
- * BPMN access method to execute NetworkCollectionInstanceGroup operation (PUT) in AAI
- * @param execution
- * @throws Exception
- */
- public void createNetworkCollectionInstanceGroup(BuildingBlockExecution execution) {
- try {
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- InstanceGroup instanceGroup = serviceInstance.getCollection().getInstanceGroup();
- //set name generated for NetworkCollection/NetworkCollectionInstanceGroup in previous step of the BB flow
- instanceGroup.setInstanceGroupName(execution.getVariable(NETWORK_COLLECTION_NAME));
- //put shell in AAI
- aaiNetworkResources.createNetworkInstanceGroup(instanceGroup);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
-
- /**
- * BPMN access method to establish relationships in AAI
- * @param execution
- * @throws Exception
- */
- public void connectNetworkToTenant(BuildingBlockExecution execution) {
- try {
- L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
- aaiNetworkResources.connectNetworkToTenant(l3network, execution.getGeneralBuildingBlock().getCloudRegion());
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- /**
- * BPMN access method to establish relationships in AAI
- * @param execution
- * @throws Exception
- */
- public void connectNetworkToCloudRegion(BuildingBlockExecution execution) {
- try {
- L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
- aaiNetworkResources.connectNetworkToCloudRegion(l3network, execution.getGeneralBuildingBlock().getCloudRegion());
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- /**
- * BPMN access method to establish relationships in AAI
- * @param execution
- * @throws Exception
- */
- public void connectVnfToCloudRegion(BuildingBlockExecution execution) {
- try {
- boolean cloudRegionsToSkip = false;
- String[] cloudRegions = env.getProperty("mso.bpmn.cloudRegionIdsToSkipAddingVnfEdgesTo", String[].class);
- if (cloudRegions != null){
- cloudRegionsToSkip = Arrays.stream(cloudRegions).anyMatch(execution.getGeneralBuildingBlock().getCloudRegion().getLcpCloudRegionId()::equals);
- }
- if(!cloudRegionsToSkip) {
- GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- aaiVnfResources.connectVnfToCloudRegion(vnf, execution.getGeneralBuildingBlock().getCloudRegion());
- }
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- /**
- * BPMN access method to establish relationships in AAI
- * @param execution
- * @throws Exception
- */
- public void connectVnfToTenant(BuildingBlockExecution execution) {
- try {
- GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- aaiVnfResources.connectVnfToTenant(vnf, execution.getGeneralBuildingBlock().getCloudRegion());
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- /**
- * BPMN access method to establish relationships in AAI
- * @param execution
- * @throws Exception
- */
- public void connectNetworkToNetworkCollectionServiceInstance(BuildingBlockExecution execution) {
- try {
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
- aaiNetworkResources.connectNetworkToNetworkCollectionServiceInstance(l3network, serviceInstance);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- /**
- * BPMN access method to establish relationships in AAI
- * @param execution
- * @throws Exception
- */
- public void connectNetworkToNetworkCollectionInstanceGroup(BuildingBlockExecution execution) {
- try {
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
- //connect network only if Instance Group / Collection objects exist
- if (serviceInstance.getCollection() != null && serviceInstance.getCollection().getInstanceGroup() != null)
- aaiNetworkResources.connectNetworkToNetworkCollectionInstanceGroup(l3network, serviceInstance.getCollection().getInstanceGroup());
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void createConfiguration(BuildingBlockExecution execution){
- try{
- Configuration configuration = extractPojosForBB.extractByKey(execution, ResourceKey.CONFIGURATION_ID);
- aaiConfigurationResources.createConfiguration(configuration);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void createInstanceGroupVnf(BuildingBlockExecution execution){
- try{
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- InstanceGroup instanceGroup = extractPojosForBB.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID);
- aaiInstanceGroupResources.createInstanceGroupandConnectServiceInstance(instanceGroup, serviceInstance);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void createNetworkPolicies(BuildingBlockExecution execution) {
- try{
- String fqdns = execution.getVariable(CONTRAIL_NETWORK_POLICY_FQDN_LIST);
- if (fqdns != null && !fqdns.isEmpty()) {
- String fqdnList[] = fqdns.split(",");
- int fqdnCount = fqdnList.length;
- if (fqdnCount > 0) {
- for (int i=0; i < fqdnCount; i++) {
- String fqdn = fqdnList[i];
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY);
- uri.queryParam(NETWORK_POLICY_FQDN_PARAM, fqdn);
- Optional<org.onap.aai.domain.yang.NetworkPolicy> oNetPolicy = aaiNetworkResources.getNetworkPolicy(uri);
- if(!oNetPolicy.isPresent()) {
- logger.debug("This network policy FQDN is not in AAI yet: {}", fqdn);
- String networkPolicyId = UUID.randomUUID().toString();
- logger.debug("Adding network-policy with network-policy-id {}", networkPolicyId);
- NetworkPolicy networkPolicy = new NetworkPolicy();
- networkPolicy.setNetworkPolicyId(networkPolicyId);
- networkPolicy.setNetworkPolicyFqdn(fqdn);
- networkPolicy.setHeatStackId(execution.getVariable(HEAT_STACK_ID));
-
- aaiNetworkResources.createNetworkPolicy(networkPolicy);
- }
- }
- }
- }
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- /**
- * Groups existing vf modules by the model uuid of our new vf module and returns the lowest unused index
- *
- * if we have a module type A, and there are 3 instances of those,
- * and then module type B has 2 instances, if we are adding a new module type A,
- * the vf-module-index should be 3 assuming contiguous indices (not 5, or 2)
- *
- */
- protected int getLowestUnusedVfModuleIndexFromAAIVnfResponse(GenericVnf genericVnf, VfModule newVfModule) {
-
- String newVfModuleModelInvariantUUID = null;
- if (newVfModule.getModelInfoVfModule() != null) {
- newVfModuleModelInvariantUUID = newVfModule.getModelInfoVfModule().getModelInvariantUUID();
- }
-
-
- if (genericVnf != null && genericVnf.getVfModules() != null && !genericVnf.getVfModules().isEmpty()) {
- List<VfModule> modules = genericVnf.getVfModules().stream().filter(item -> !item.getVfModuleId().equals(newVfModule.getVfModuleId())).collect(Collectors.toList());
- TreeSet<Integer> moduleIndices = new TreeSet<>();
- int nullIndexFound = 0;
- for (VfModule vfModule : modules) {
- if (vfModule.getModelInfoVfModule() != null) {
- if (vfModule.getModelInfoVfModule().getModelInvariantUUID().equals(newVfModuleModelInvariantUUID)) {
- if (vfModule.getModuleIndex() != null) {
- moduleIndices.add(vfModule.getModuleIndex());
- } else {
- nullIndexFound++;
- logger.warn("Found null index for vf-module-id {} and model-invariant-uuid {}", vfModule.getVfModuleId(), vfModule.getModelInfoVfModule().getModelInvariantUUID());
- }
- }
- }
- }
-
- return calculateUnusedIndex(moduleIndices, nullIndexFound);
- } else {
- return 0;
- }
- }
-
- protected int calculateUnusedIndex(TreeSet<Integer> moduleIndices, int nullIndexFound) {
- //pad array with nulls
- Integer[] temp = new Integer[moduleIndices.size() + nullIndexFound];
- Integer[] array = moduleIndices.toArray(temp);
- int result = 0;
- //when a null is found skip that potential value
- //effectively creates something like, [0,1,3,null,null] -> [0,1,null(2),3,null(4)]
- for (int i=0; i < array.length; i++, result++) {
- if (Integer.valueOf(result) != array[i]) {
- if (nullIndexFound > 0) {
- nullIndexFound--;
- i--;
- } else {
- break;
- }
- }
- }
-
- return result;
- }
+ public void createVnf(BuildingBlockExecution execution) {
+ try {
+ GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ execution.setVariable("callHoming", Boolean.TRUE.equals(vnf.isCallHoming()));
+ aaiVnfResources.createVnfandConnectServiceInstance(vnf, serviceInstance);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void createPlatform(BuildingBlockExecution execution) {
+ try {
+ GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ Platform platform = vnf.getPlatform();
+ if (platform != null) {
+ if (platform.getPlatformName() == null || "".equals(platform.getPlatformName())) {
+ logger.debug("PlatformName is null in input. Skipping create platform...");
+ } else {
+ List<String> platforms = splitCDL(platform.getPlatformName());
+ platforms.stream().forEach(platformName -> aaiVnfResources
+ .createPlatformandConnectVnf(new Platform(platformName), vnf));
+ }
+ }
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+
+ }
+
+ public List<String> splitCDL(String str) {
+ return Stream.of(str.split(",")).map(String::trim).map(elem -> new String(elem)).collect(Collectors.toList());
+ }
+
+ public void createLineOfBusiness(BuildingBlockExecution execution) {
+ try {
+ GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ LineOfBusiness lineOfBusiness = vnf.getLineOfBusiness();
+ if (lineOfBusiness != null) {
+ if (lineOfBusiness.getLineOfBusinessName() == null
+ || "".equals(lineOfBusiness.getLineOfBusinessName())) {
+ logger.info("lineOfBusiness is null in input. Skipping create lineOfBusiness...");
+ } else {
+ List<String> lineOfBussinesses = splitCDL(lineOfBusiness.getLineOfBusinessName());
+ lineOfBussinesses.stream().forEach(lobName -> aaiVnfResources
+ .createLineOfBusinessandConnectVnf(new LineOfBusiness(lobName), vnf));
+ }
+ }
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void createVolumeGroup(BuildingBlockExecution execution) {
+ try {
+ GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+
+ GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
+ CloudRegion cloudRegion = gBBInput.getCloudRegion();
+ aaiVolumeGroupResources.createVolumeGroup(volumeGroup, cloudRegion);
+ aaiVolumeGroupResources.connectVolumeGroupToVnf(genericVnf, volumeGroup, cloudRegion);
+ aaiVolumeGroupResources.connectVolumeGroupToTenant(volumeGroup, cloudRegion);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void createVfModule(BuildingBlockExecution execution) {
+ try {
+ GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
+ int moduleIndex = 0;
+ if (vfModule.getModelInfoVfModule() != null
+ && !Boolean.TRUE.equals(vfModule.getModelInfoVfModule().getIsBaseBoolean())) {
+ moduleIndex = this.getLowestUnusedVfModuleIndexFromAAIVnfResponse(vnf, vfModule);
+ }
+ vfModule.setModuleIndex(moduleIndex);
+ aaiVfModuleResources.createVfModule(vfModule, vnf);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ /**
+ * BPMN access method to establish relationships in AAI
+ *
+ * @param execution
+ * @throws Exception
+ */
+ public void connectVfModuleToVolumeGroup(BuildingBlockExecution execution) {
+ try {
+ GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
+ VolumeGroup volumeGroup = null;
+ try {
+ volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
+ } catch (BBObjectNotFoundException e) {
+ logger.info("VolumeGroup not found. Skipping Connect between VfModule and VolumeGroup");
+ }
+ if (volumeGroup != null) {
+ aaiVfModuleResources.connectVfModuleToVolumeGroup(vnf, vfModule, volumeGroup,
+ execution.getGeneralBuildingBlock().getCloudRegion());
+ }
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ /**
+ * BPMN access method to execute Create L3Network operation (PUT )in AAI
+ *
+ * @param execution
+ * @throws Exception
+ */
+ public void createNetwork(BuildingBlockExecution execution) {
+ try {
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
+ // set default to false. ToBe updated by SDNC
+ l3network.setIsBoundToVpn(false);
+ // define is bound to vpn flag as true if NEUTRON_NETWORK_TYPE is PROVIDER
+ if (l3network.getModelInfoNetwork().getNeutronNetworkType().equalsIgnoreCase(networkTypeProvider))
+ l3network.setIsBoundToVpn(true);
+ // put network shell in AAI
+ aaiNetworkResources.createNetworkConnectToServiceInstance(l3network, serviceInstance);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void createCustomer(BuildingBlockExecution execution) throws Exception {
+ try {
+ Customer customer = execution.getGeneralBuildingBlock().getCustomer();
+
+ aaiVpnBindingResources.createCustomer(customer);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ /**
+ * BPMN access method to execute NetworkCollection operation (PUT) in AAI
+ *
+ * @param execution
+ * @throws Exception
+ */
+ public void createNetworkCollection(BuildingBlockExecution execution) {
+ try {
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ Collection networkCollection = serviceInstance.getCollection();
+ // pass name generated for NetworkCollection/NetworkCollectionInstanceGroup in previous step of the BB flow
+ // put shell in AAI
+ networkCollection.setName(execution.getVariable(NETWORK_COLLECTION_NAME));
+ aaiNetworkResources.createNetworkCollection(networkCollection);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ /**
+ * BPMN access method to execute NetworkCollectionInstanceGroup operation (PUT) in AAI
+ *
+ * @param execution
+ * @throws Exception
+ */
+ public void createNetworkCollectionInstanceGroup(BuildingBlockExecution execution) {
+ try {
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ InstanceGroup instanceGroup = serviceInstance.getCollection().getInstanceGroup();
+ // set name generated for NetworkCollection/NetworkCollectionInstanceGroup in previous step of the BB flow
+ instanceGroup.setInstanceGroupName(execution.getVariable(NETWORK_COLLECTION_NAME));
+ // put shell in AAI
+ aaiNetworkResources.createNetworkInstanceGroup(instanceGroup);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+
+ /**
+ * BPMN access method to establish relationships in AAI
+ *
+ * @param execution
+ * @throws Exception
+ */
+ public void connectNetworkToTenant(BuildingBlockExecution execution) {
+ try {
+ L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
+ aaiNetworkResources.connectNetworkToTenant(l3network, execution.getGeneralBuildingBlock().getCloudRegion());
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ /**
+ * BPMN access method to establish relationships in AAI
+ *
+ * @param execution
+ * @throws Exception
+ */
+ public void connectNetworkToCloudRegion(BuildingBlockExecution execution) {
+ try {
+ L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
+ aaiNetworkResources.connectNetworkToCloudRegion(l3network,
+ execution.getGeneralBuildingBlock().getCloudRegion());
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ /**
+ * BPMN access method to establish relationships in AAI
+ *
+ * @param execution
+ * @throws Exception
+ */
+ public void connectVnfToCloudRegion(BuildingBlockExecution execution) {
+ try {
+ boolean cloudRegionsToSkip = false;
+ String[] cloudRegions = env.getProperty("mso.bpmn.cloudRegionIdsToSkipAddingVnfEdgesTo", String[].class);
+ if (cloudRegions != null) {
+ cloudRegionsToSkip = Arrays.stream(cloudRegions)
+ .anyMatch(execution.getGeneralBuildingBlock().getCloudRegion().getLcpCloudRegionId()::equals);
+ }
+ if (!cloudRegionsToSkip) {
+ GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ aaiVnfResources.connectVnfToCloudRegion(vnf, execution.getGeneralBuildingBlock().getCloudRegion());
+ }
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ /**
+ * BPMN access method to establish relationships in AAI
+ *
+ * @param execution
+ * @throws Exception
+ */
+ public void connectVnfToTenant(BuildingBlockExecution execution) {
+ try {
+ GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ aaiVnfResources.connectVnfToTenant(vnf, execution.getGeneralBuildingBlock().getCloudRegion());
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ /**
+ * BPMN access method to establish relationships in AAI
+ *
+ * @param execution
+ * @throws Exception
+ */
+ public void connectNetworkToNetworkCollectionServiceInstance(BuildingBlockExecution execution) {
+ try {
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
+ aaiNetworkResources.connectNetworkToNetworkCollectionServiceInstance(l3network, serviceInstance);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ /**
+ * BPMN access method to establish relationships in AAI
+ *
+ * @param execution
+ * @throws Exception
+ */
+ public void connectNetworkToNetworkCollectionInstanceGroup(BuildingBlockExecution execution) {
+ try {
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
+ // connect network only if Instance Group / Collection objects exist
+ if (serviceInstance.getCollection() != null && serviceInstance.getCollection().getInstanceGroup() != null)
+ aaiNetworkResources.connectNetworkToNetworkCollectionInstanceGroup(l3network,
+ serviceInstance.getCollection().getInstanceGroup());
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void createConfiguration(BuildingBlockExecution execution) {
+ try {
+ Configuration configuration = extractPojosForBB.extractByKey(execution, ResourceKey.CONFIGURATION_ID);
+ aaiConfigurationResources.createConfiguration(configuration);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void createInstanceGroupVnf(BuildingBlockExecution execution) {
+ try {
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ InstanceGroup instanceGroup = extractPojosForBB.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID);
+ aaiInstanceGroupResources.createInstanceGroupandConnectServiceInstance(instanceGroup, serviceInstance);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void createNetworkPolicies(BuildingBlockExecution execution) {
+ try {
+ String fqdns = execution.getVariable(CONTRAIL_NETWORK_POLICY_FQDN_LIST);
+ if (fqdns != null && !fqdns.isEmpty()) {
+ String fqdnList[] = fqdns.split(",");
+ int fqdnCount = fqdnList.length;
+ if (fqdnCount > 0) {
+ for (int i = 0; i < fqdnCount; i++) {
+ String fqdn = fqdnList[i];
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY);
+ uri.queryParam(NETWORK_POLICY_FQDN_PARAM, fqdn);
+ Optional<org.onap.aai.domain.yang.NetworkPolicy> oNetPolicy =
+ aaiNetworkResources.getNetworkPolicy(uri);
+ if (!oNetPolicy.isPresent()) {
+ logger.debug("This network policy FQDN is not in AAI yet: {}", fqdn);
+ String networkPolicyId = UUID.randomUUID().toString();
+ logger.debug("Adding network-policy with network-policy-id {}", networkPolicyId);
+ NetworkPolicy networkPolicy = new NetworkPolicy();
+ networkPolicy.setNetworkPolicyId(networkPolicyId);
+ networkPolicy.setNetworkPolicyFqdn(fqdn);
+ networkPolicy.setHeatStackId(execution.getVariable(HEAT_STACK_ID));
+
+ aaiNetworkResources.createNetworkPolicy(networkPolicy);
+ }
+ }
+ }
+ }
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ /**
+ * Groups existing vf modules by the model uuid of our new vf module and returns the lowest unused index
+ *
+ * if we have a module type A, and there are 3 instances of those, and then module type B has 2 instances, if we are
+ * adding a new module type A, the vf-module-index should be 3 assuming contiguous indices (not 5, or 2)
+ *
+ */
+ protected int getLowestUnusedVfModuleIndexFromAAIVnfResponse(GenericVnf genericVnf, VfModule newVfModule) {
+
+ String newVfModuleModelInvariantUUID = null;
+ if (newVfModule.getModelInfoVfModule() != null) {
+ newVfModuleModelInvariantUUID = newVfModule.getModelInfoVfModule().getModelInvariantUUID();
+ }
+
+
+ if (genericVnf != null && genericVnf.getVfModules() != null && !genericVnf.getVfModules().isEmpty()) {
+ List<VfModule> modules = genericVnf.getVfModules().stream()
+ .filter(item -> !item.getVfModuleId().equals(newVfModule.getVfModuleId()))
+ .collect(Collectors.toList());
+ TreeSet<Integer> moduleIndices = new TreeSet<>();
+ int nullIndexFound = 0;
+ for (VfModule vfModule : modules) {
+ if (vfModule.getModelInfoVfModule() != null) {
+ if (vfModule.getModelInfoVfModule().getModelInvariantUUID().equals(newVfModuleModelInvariantUUID)) {
+ if (vfModule.getModuleIndex() != null) {
+ moduleIndices.add(vfModule.getModuleIndex());
+ } else {
+ nullIndexFound++;
+ logger.warn("Found null index for vf-module-id {} and model-invariant-uuid {}",
+ vfModule.getVfModuleId(), vfModule.getModelInfoVfModule().getModelInvariantUUID());
+ }
+ }
+ }
+ }
+
+ return calculateUnusedIndex(moduleIndices, nullIndexFound);
+ } else {
+ return 0;
+ }
+ }
+
+ protected int calculateUnusedIndex(TreeSet<Integer> moduleIndices, int nullIndexFound) {
+ // pad array with nulls
+ Integer[] temp = new Integer[moduleIndices.size() + nullIndexFound];
+ Integer[] array = moduleIndices.toArray(temp);
+ int result = 0;
+ // when a null is found skip that potential value
+ // effectively creates something like, [0,1,3,null,null] -> [0,1,null(2),3,null(4)]
+ for (int i = 0; i < array.length; i++, result++) {
+ if (Integer.valueOf(result) != array[i]) {
+ if (nullIndexFound > 0) {
+ nullIndexFound--;
+ i--;
+ } else {
+ break;
+ }
+ }
+ }
+
+ return result;
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasks.java
index 095fd7f86d..28186528e4 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasks.java
@@ -25,7 +25,6 @@ package org.onap.so.bpmn.infrastructure.aai.tasks;
import java.util.List;
import java.util.Optional;
-
import org.onap.aai.domain.yang.NetworkPolicies;
import org.onap.aai.domain.yang.NetworkPolicy;
import org.onap.so.bpmn.common.BuildingBlockExecution;
@@ -57,151 +56,151 @@ import org.springframework.stereotype.Component;
@Component
public class AAIDeleteTasks {
- private static final Logger logger = LoggerFactory.getLogger(AAIDeleteTasks.class);
-
- private static String CONTRAIL_NETWORK_POLICY_FQDN_LIST = "contrailNetworkPolicyFqdnList";
- private static String NETWORK_POLICY_FQDN_PARAM = "network-policy-fqdn";
-
- @Autowired
- private ExceptionBuilder exceptionUtil;
- @Autowired
- private ExtractPojosForBB extractPojosForBB;
- @Autowired
- private AAIServiceInstanceResources aaiSIResources;
- @Autowired
- private AAIVnfResources aaiVnfResources;
- @Autowired
- private AAIVfModuleResources aaiVfModuleResources;
- @Autowired
- private AAINetworkResources aaiNetworkResources;
- @Autowired
- private AAIVolumeGroupResources aaiVolumeGroupResources;
- @Autowired
- private AAIConfigurationResources aaiConfigurationResources;
- @Autowired
- private AAIInstanceGroupResources aaiInstanceGroupResources;
-
- public void deleteVfModule(BuildingBlockExecution execution) throws Exception {
- GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
-
- execution.setVariable("aaiVfModuleRollback", false);
- try {
- aaiVfModuleResources.deleteVfModule(vfModule, genericVnf);
- execution.setVariable("aaiVfModuleRollback", true);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void deleteVnf(BuildingBlockExecution execution) throws Exception {
- GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
-
- execution.setVariable("aaiVnfRollback", false);
- try {
- aaiVnfResources.deleteVnf(genericVnf);
- execution.setVariable("aaiVnfRollback", true);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void deleteServiceInstance(BuildingBlockExecution execution) throws Exception {
- try {
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- aaiSIResources.deleteServiceInstance(serviceInstance);
- }
- catch(Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
-
- }
-
- public void deleteNetwork(BuildingBlockExecution execution) throws Exception {
- try {
- L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
- aaiNetworkResources.deleteNetwork(l3network);
- execution.setVariable("isRollbackNeeded", true);
- }
- catch(Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void deleteCollection(BuildingBlockExecution execution) throws Exception {
- try {
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- aaiNetworkResources.deleteCollection(serviceInstance.getCollection());
- }
- catch(Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void deleteInstanceGroup(BuildingBlockExecution execution) throws Exception {
- try {
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- aaiNetworkResources.deleteNetworkInstanceGroup(serviceInstance.getCollection().getInstanceGroup());
- }
- catch(Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void deleteVolumeGroup(BuildingBlockExecution execution) {
- try {
- VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
- CloudRegion cloudRegion = execution.getGeneralBuildingBlock().getCloudRegion();
- aaiVolumeGroupResources.deleteVolumeGroup(volumeGroup, cloudRegion);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
- public void deleteConfiguration(BuildingBlockExecution execution) {
- try {
- Configuration configuration = extractPojosForBB.extractByKey(execution, ResourceKey.CONFIGURATION_ID);
- aaiConfigurationResources.deleteConfiguration(configuration);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void deleteInstanceGroupVnf(BuildingBlockExecution execution) {
- try {
- InstanceGroup instanceGroup = extractPojosForBB.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID);
- aaiInstanceGroupResources.deleteInstanceGroup(instanceGroup);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void deleteNetworkPolicies(BuildingBlockExecution execution) {
- try{
- String fqdns = execution.getVariable(CONTRAIL_NETWORK_POLICY_FQDN_LIST);
- if (fqdns != null && !fqdns.isEmpty()) {
- String fqdnList[] = fqdns.split(",");
- int fqdnCount = fqdnList.length;
- if (fqdnCount > 0) {
- for (int i=0; i < fqdnCount; i++) {
- String fqdn = fqdnList[i];
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY);
- uri.queryParam(NETWORK_POLICY_FQDN_PARAM, fqdn);
- Optional<NetworkPolicies> oNetPolicies = aaiNetworkResources.getNetworkPolicies(uri);
- if(oNetPolicies.isPresent()) {
- NetworkPolicies networkPolicies = oNetPolicies.get();
- List<NetworkPolicy> networkPolicyList = networkPolicies.getNetworkPolicy();
- if (networkPolicyList != null && !networkPolicyList.isEmpty()) {
- NetworkPolicy networkPolicy = networkPolicyList.get(0);
- String networkPolicyId = networkPolicy.getNetworkPolicyId();
- logger.debug("Deleting network-policy with network-policy-id {}", networkPolicyId);
- aaiNetworkResources.deleteNetworkPolicy(networkPolicyId);
- }
- }
- }
- }
- }
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
+ private static final Logger logger = LoggerFactory.getLogger(AAIDeleteTasks.class);
+
+ private static String CONTRAIL_NETWORK_POLICY_FQDN_LIST = "contrailNetworkPolicyFqdnList";
+ private static String NETWORK_POLICY_FQDN_PARAM = "network-policy-fqdn";
+
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+ @Autowired
+ private ExtractPojosForBB extractPojosForBB;
+ @Autowired
+ private AAIServiceInstanceResources aaiSIResources;
+ @Autowired
+ private AAIVnfResources aaiVnfResources;
+ @Autowired
+ private AAIVfModuleResources aaiVfModuleResources;
+ @Autowired
+ private AAINetworkResources aaiNetworkResources;
+ @Autowired
+ private AAIVolumeGroupResources aaiVolumeGroupResources;
+ @Autowired
+ private AAIConfigurationResources aaiConfigurationResources;
+ @Autowired
+ private AAIInstanceGroupResources aaiInstanceGroupResources;
+
+ public void deleteVfModule(BuildingBlockExecution execution) throws Exception {
+ GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
+
+ execution.setVariable("aaiVfModuleRollback", false);
+ try {
+ aaiVfModuleResources.deleteVfModule(vfModule, genericVnf);
+ execution.setVariable("aaiVfModuleRollback", true);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void deleteVnf(BuildingBlockExecution execution) throws Exception {
+ GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+
+ execution.setVariable("aaiVnfRollback", false);
+ try {
+ aaiVnfResources.deleteVnf(genericVnf);
+ execution.setVariable("aaiVnfRollback", true);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void deleteServiceInstance(BuildingBlockExecution execution) throws Exception {
+ try {
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ aaiSIResources.deleteServiceInstance(serviceInstance);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+
+ }
+
+ public void deleteNetwork(BuildingBlockExecution execution) throws Exception {
+ try {
+ L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
+ aaiNetworkResources.deleteNetwork(l3network);
+ execution.setVariable("isRollbackNeeded", true);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void deleteCollection(BuildingBlockExecution execution) throws Exception {
+ try {
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ aaiNetworkResources.deleteCollection(serviceInstance.getCollection());
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void deleteInstanceGroup(BuildingBlockExecution execution) throws Exception {
+ try {
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ aaiNetworkResources.deleteNetworkInstanceGroup(serviceInstance.getCollection().getInstanceGroup());
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void deleteVolumeGroup(BuildingBlockExecution execution) {
+ try {
+ VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
+ CloudRegion cloudRegion = execution.getGeneralBuildingBlock().getCloudRegion();
+ aaiVolumeGroupResources.deleteVolumeGroup(volumeGroup, cloudRegion);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void deleteConfiguration(BuildingBlockExecution execution) {
+ try {
+ Configuration configuration = extractPojosForBB.extractByKey(execution, ResourceKey.CONFIGURATION_ID);
+ aaiConfigurationResources.deleteConfiguration(configuration);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void deleteInstanceGroupVnf(BuildingBlockExecution execution) {
+ try {
+ InstanceGroup instanceGroup = extractPojosForBB.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID);
+ aaiInstanceGroupResources.deleteInstanceGroup(instanceGroup);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void deleteNetworkPolicies(BuildingBlockExecution execution) {
+ try {
+ String fqdns = execution.getVariable(CONTRAIL_NETWORK_POLICY_FQDN_LIST);
+ if (fqdns != null && !fqdns.isEmpty()) {
+ String fqdnList[] = fqdns.split(",");
+ int fqdnCount = fqdnList.length;
+ if (fqdnCount > 0) {
+ for (int i = 0; i < fqdnCount; i++) {
+ String fqdn = fqdnList[i];
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY);
+ uri.queryParam(NETWORK_POLICY_FQDN_PARAM, fqdn);
+ Optional<NetworkPolicies> oNetPolicies = aaiNetworkResources.getNetworkPolicies(uri);
+ if (oNetPolicies.isPresent()) {
+ NetworkPolicies networkPolicies = oNetPolicies.get();
+ List<NetworkPolicy> networkPolicyList = networkPolicies.getNetworkPolicy();
+ if (networkPolicyList != null && !networkPolicyList.isEmpty()) {
+ NetworkPolicy networkPolicy = networkPolicyList.get(0);
+ String networkPolicyId = networkPolicy.getNetworkPolicyId();
+ logger.debug("Deleting network-policy with network-policy-id {}", networkPolicyId);
+ aaiNetworkResources.deleteNetworkPolicy(networkPolicyId);
+ }
+ }
+ }
+ }
+ }
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIFlagTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIFlagTasks.java
index 177e09d5a1..12aade71bc 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIFlagTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIFlagTasks.java
@@ -35,83 +35,83 @@ import org.springframework.stereotype.Component;
@Component
public class AAIFlagTasks {
- private static final Logger logger = LoggerFactory.getLogger(AAIFlagTasks.class);
-
- @Autowired
- private AAIVnfResources aaiVnfResources;
- @Autowired
- private ExceptionBuilder exceptionUtil;
- @Autowired
- private ExtractPojosForBB extractPojosForBB;
-
- public void checkVnfInMaintFlag(BuildingBlockExecution execution) {
- boolean inMaint = false;
- try {
- GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- String vnfId = vnf.getVnfId();
- inMaint = aaiVnfResources.checkInMaintFlag(vnfId);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- if (inMaint) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "VNF is in maintenance in A&AI");
- }
- }
-
- public void modifyVnfInMaintFlag(BuildingBlockExecution execution, boolean inMaint) {
- try {
- GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ private static final Logger logger = LoggerFactory.getLogger(AAIFlagTasks.class);
- GenericVnf copiedGenericVnf = genericVnf.shallowCopyId();
+ @Autowired
+ private AAIVnfResources aaiVnfResources;
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+ @Autowired
+ private ExtractPojosForBB extractPojosForBB;
- copiedGenericVnf.setInMaint(inMaint);
- genericVnf.setInMaint(inMaint);
+ public void checkVnfInMaintFlag(BuildingBlockExecution execution) {
+ boolean inMaint = false;
+ try {
+ GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ String vnfId = vnf.getVnfId();
+ inMaint = aaiVnfResources.checkInMaintFlag(vnfId);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ if (inMaint) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "VNF is in maintenance in A&AI");
+ }
+ }
- aaiVnfResources.updateObjectVnf(copiedGenericVnf);
- } catch(Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void checkVnfClosedLoopDisabledFlag(BuildingBlockExecution execution) {
- boolean isClosedLoopDisabled = false;
- try {
- GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- String vnfId = vnf.getVnfId();
- isClosedLoopDisabled = aaiVnfResources.checkVnfClosedLoopDisabledFlag(vnfId);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- if (isClosedLoopDisabled) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "VNF Close Loop Disabled in A&AI");
- }
- }
-
- public void modifyVnfClosedLoopDisabledFlag(BuildingBlockExecution execution, boolean closedLoopDisabled) {
- try {
- GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ public void modifyVnfInMaintFlag(BuildingBlockExecution execution, boolean inMaint) {
+ try {
+ GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- GenericVnf copiedGenericVnf = genericVnf.shallowCopyId();
- copiedGenericVnf.setClosedLoopDisabled(closedLoopDisabled);
- genericVnf.setClosedLoopDisabled(closedLoopDisabled);
+ GenericVnf copiedGenericVnf = genericVnf.shallowCopyId();
- aaiVnfResources.updateObjectVnf(copiedGenericVnf);
- } catch(Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void checkVnfPserversLockedFlag(BuildingBlockExecution execution) {
- boolean inPserversLocked = false;
- try {
- GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- String vnfId = vnf.getVnfId();
- inPserversLocked = aaiVnfResources.checkVnfPserversLockedFlag(vnfId);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- if (inPserversLocked) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "VNF PServers in Locked in A&AI");
- }
- }
+ copiedGenericVnf.setInMaint(inMaint);
+ genericVnf.setInMaint(inMaint);
+
+ aaiVnfResources.updateObjectVnf(copiedGenericVnf);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void checkVnfClosedLoopDisabledFlag(BuildingBlockExecution execution) {
+ boolean isClosedLoopDisabled = false;
+ try {
+ GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ String vnfId = vnf.getVnfId();
+ isClosedLoopDisabled = aaiVnfResources.checkVnfClosedLoopDisabledFlag(vnfId);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ if (isClosedLoopDisabled) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "VNF Close Loop Disabled in A&AI");
+ }
+ }
+
+ public void modifyVnfClosedLoopDisabledFlag(BuildingBlockExecution execution, boolean closedLoopDisabled) {
+ try {
+ GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+
+ GenericVnf copiedGenericVnf = genericVnf.shallowCopyId();
+ copiedGenericVnf.setClosedLoopDisabled(closedLoopDisabled);
+ genericVnf.setClosedLoopDisabled(closedLoopDisabled);
+
+ aaiVnfResources.updateObjectVnf(copiedGenericVnf);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void checkVnfPserversLockedFlag(BuildingBlockExecution execution) {
+ boolean inPserversLocked = false;
+ try {
+ GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ String vnfId = vnf.getVnfId();
+ inPserversLocked = aaiVnfResources.checkVnfPserversLockedFlag(vnfId);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ if (inPserversLocked) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "VNF PServers in Locked in A&AI");
+ }
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIQueryTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIQueryTasks.java
index e0e139e290..7668c6b00f 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIQueryTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIQueryTasks.java
@@ -25,7 +25,6 @@ package org.onap.so.bpmn.infrastructure.aai.tasks;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
-
import org.modelmapper.ModelMapper;
import org.modelmapper.PropertyMap;
import org.onap.aai.domain.yang.NetworkPolicy;
@@ -52,197 +51,209 @@ import org.springframework.stereotype.Component;
@Component
public class AAIQueryTasks {
- private static final Logger logger = LoggerFactory.getLogger(AAIQueryTasks.class);
- private static final String ERROR_MSG = "No relationships were returned from AAIResultWrapper.getRelationships()";
- @Autowired
- private ExtractPojosForBB extractPojosForBB;
- @Autowired
- private ExceptionBuilder exceptionUtil;
- @Autowired
- private AAINetworkResources aaiNetworkResources;
- private static final ModelMapper modelMapper = new ModelMapper();
-
- /**
- * BPMN access method to query data for VPN bindings from the AAI result wrapper.
- * The resulting VPN bindings are mapped to the corresponding bbobject and placed in the customer bbobject
- *
- * @param execution
- */
-
- public void queryNetworkVpnBinding(BuildingBlockExecution execution) {
- try {
- L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
- AAIResultWrapper aaiResultWrapper = aaiNetworkResources.queryNetworkWrapperById(l3network);
- Optional<Relationships> networkRelationships = aaiResultWrapper.getRelationships();
- if (!networkRelationships.isPresent()) {
- throw (new Exception(ERROR_MSG));
- }
- List<AAIResourceUri> netBindingsUriList = networkRelationships.get().getRelatedAAIUris(AAIObjectType.VPN_BINDING);
-
- List<org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding> mappedVpnBindings = new ArrayList<>();
- if(netBindingsUriList != null && !netBindingsUriList.isEmpty()) {
- for(AAIResourceUri netBindingUri : netBindingsUriList) {
- Optional<VpnBinding> oVpnBinding = aaiNetworkResources.getVpnBinding(netBindingUri);
- if(oVpnBinding.isPresent()) {
- org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding mappedVpnBinding =
- modelMapper.map(oVpnBinding.get(), org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding.class);
- if (oVpnBinding.get().getRouteTargets() != null){
- mappedVpnBinding.getRouteTargets().addAll(mapRouteTargets(oVpnBinding.get().getRouteTargets().getRouteTarget()));
- mappedVpnBindings.add(mappedVpnBinding);
- }
- }
- }
- }
- execution.getGeneralBuildingBlock().getCustomer().getVpnBindings().addAll(mappedVpnBindings);
- } catch(Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- /**
- * BPMN access method to extract VPN Binding data from AAI result and populate proper fields into CreateNetworkRequest
- */
- public void getNetworkVpnBinding(BuildingBlockExecution execution) {
-
- try {
- L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
- AAIResultWrapper aaiResultWrapper = aaiNetworkResources.queryNetworkWrapperById(l3network);
- CreateNetworkRequest createNetworkRequest = execution.getVariable("createNetworkRequest");
-
- Optional<Relationships> networkRelationships = aaiResultWrapper.getRelationships();
- if (!networkRelationships.isPresent()) {
- throw (new Exception(ERROR_MSG));
- }
- List<AAIResourceUri> netBindingsUriList = networkRelationships.get()
- .getRelatedAAIUris(AAIObjectType.VPN_BINDING);
- List<org.onap.so.openstack.beans.RouteTarget> routeTargets = new ArrayList<>();
- for (AAIResourceUri netBindingUri : netBindingsUriList) {
- logger.info("Get Route Targests");
- Optional<VpnBinding> oVpnBinding = aaiNetworkResources.getVpnBinding(netBindingUri);
- if (oVpnBinding.isPresent()) {
- VpnBinding vpnBinding = oVpnBinding.get();
- RouteTargets rts = vpnBinding.getRouteTargets();
- if (rts != null) {
- List<org.onap.aai.domain.yang.RouteTarget> rtList = rts.getRouteTarget();
- if (!rtList.isEmpty()) {
- PropertyMap<org.onap.aai.domain.yang.RouteTarget, org.onap.so.openstack.beans.RouteTarget> personMap = new PropertyMap<org.onap.aai.domain.yang.RouteTarget, org.onap.so.openstack.beans.RouteTarget>() {
- @Override
- protected void configure() {
- map().setRouteTarget(source.getGlobalRouteTarget());
- map(source.getRouteTargetRole(), destination.getRouteTargetRole());
- }
- };
- modelMapper.addMappings(personMap);
- for (org.onap.aai.domain.yang.RouteTarget rt : rtList) {
- org.onap.so.openstack.beans.RouteTarget openstackRtBean = modelMapper.map(rt,
- org.onap.so.openstack.beans.RouteTarget.class);
- routeTargets.add(openstackRtBean);
- }
- }
- }
- }
- }
- // store route targets data in execution - to be used as part of
- // Network adapter input
- createNetworkRequest.getContrailNetwork().setRouteTargets(routeTargets);
- execution.setVariable("createNetworkRequest", createNetworkRequest);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- /**
- * BPMN access method to query data for network policies from the AAI result wrapper
- * From the resulting network policy, the network policy fqdn parameter is added to
- * the network bbobject contrail network policy fqdns list
- *
- * @param execution
- */
- public void queryNetworkPolicy(BuildingBlockExecution execution) {
- try {
- L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
- AAIResultWrapper aaiResultWrapper = aaiNetworkResources.queryNetworkWrapperById(l3network);
- Optional<Relationships> networkRelationships = aaiResultWrapper.getRelationships();
- if (!networkRelationships.isPresent()) {
- throw (new Exception(ERROR_MSG));
- }
- List<AAIResourceUri> netPoliciesUriList = networkRelationships.get().getRelatedAAIUris(AAIObjectType.NETWORK_POLICY);
-
- if(!netPoliciesUriList.isEmpty()) {
- for(AAIResourceUri netPolicyUri : netPoliciesUriList) {
- Optional<NetworkPolicy> oNetPolicy = aaiNetworkResources.getNetworkPolicy(netPolicyUri);
- if(oNetPolicy.isPresent()) {
- l3network.getNetworkPolicies().add(modelMapper.map(oNetPolicy.get(), org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy.class));
- }
- }
- }
- } catch(Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- /**
- * BPMN access method to query data for network table ref from the AAI result wrapper
- * The resulting route table reference is mapped to the corresponding bbobject and added
- * to the network bbobject contrail network route table references list
- *
- * @param execution
- */
- public void queryNetworkTableRef(BuildingBlockExecution execution) {
- try {
- L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
- AAIResultWrapper aaiResultWrapper = aaiNetworkResources.queryNetworkWrapperById(l3network);
- Optional<Relationships> networkRelationships = aaiResultWrapper.getRelationships();
- if (!networkRelationships.isPresent()) {
- throw (new Exception(ERROR_MSG));
- }
- List<AAIResourceUri> routeTableUriList = networkRelationships.get().getRelatedAAIUris(AAIObjectType.ROUTE_TABLE_REFERENCE);
-
- if(!routeTableUriList.isEmpty()) {
- for(AAIResourceUri routeTableUri : routeTableUriList) {
- Optional<RouteTableReference> oRouteTableReference = aaiNetworkResources.getRouteTable(routeTableUri);
- if(oRouteTableReference.isPresent()) {
- org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference mappedRouteTableReference = modelMapper.map(oRouteTableReference.get(), org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference.class);
- l3network.getContrailNetworkRouteTableReferences().add(mappedRouteTableReference);
- }
- }
- }
- } catch(Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- private List<org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTarget> mapRouteTargets(List<org.onap.aai.domain.yang.RouteTarget> routeTargets) {
- List<org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTarget> mappedRouteTargets = new ArrayList<>();
- if(!routeTargets.isEmpty()) {
- for(org.onap.aai.domain.yang.RouteTarget routeTarget : routeTargets) {
- org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTarget mappedRouteTarget = modelMapper.map(routeTarget, org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTarget.class);
- mappedRouteTargets.add(mappedRouteTarget);
- }
- }
- return mappedRouteTargets;
- }
-
- public void querySubnet(BuildingBlockExecution execution) {
- try {
- L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
- AAIResultWrapper aaiResultWrapper = aaiNetworkResources.queryNetworkWrapperById(l3network);
- Optional<Relationships> networkRelationships = aaiResultWrapper.getRelationships();
- if (!networkRelationships.isPresent()) {
- throw (new Exception(ERROR_MSG));
- }
- List<AAIResourceUri> subnetsUriList = networkRelationships.get().getRelatedAAIUris(AAIObjectType.SUBNET);
-
- if(!subnetsUriList.isEmpty()) {
- for(AAIResourceUri subnetUri : subnetsUriList) {
- Optional<Subnet> oSubnet = aaiNetworkResources.getSubnet(subnetUri);
- if(oSubnet.isPresent()) {
- l3network.getSubnets().add(modelMapper.map(oSubnet.get(), org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet.class));
- }
- }
- }
- } catch(Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
+ private static final Logger logger = LoggerFactory.getLogger(AAIQueryTasks.class);
+ private static final String ERROR_MSG = "No relationships were returned from AAIResultWrapper.getRelationships()";
+ @Autowired
+ private ExtractPojosForBB extractPojosForBB;
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+ @Autowired
+ private AAINetworkResources aaiNetworkResources;
+ private static final ModelMapper modelMapper = new ModelMapper();
+
+ /**
+ * BPMN access method to query data for VPN bindings from the AAI result wrapper. The resulting VPN bindings are
+ * mapped to the corresponding bbobject and placed in the customer bbobject
+ *
+ * @param execution
+ */
+
+ public void queryNetworkVpnBinding(BuildingBlockExecution execution) {
+ try {
+ L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
+ AAIResultWrapper aaiResultWrapper = aaiNetworkResources.queryNetworkWrapperById(l3network);
+ Optional<Relationships> networkRelationships = aaiResultWrapper.getRelationships();
+ if (!networkRelationships.isPresent()) {
+ throw (new Exception(ERROR_MSG));
+ }
+ List<AAIResourceUri> netBindingsUriList =
+ networkRelationships.get().getRelatedAAIUris(AAIObjectType.VPN_BINDING);
+
+ List<org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding> mappedVpnBindings = new ArrayList<>();
+ if (netBindingsUriList != null && !netBindingsUriList.isEmpty()) {
+ for (AAIResourceUri netBindingUri : netBindingsUriList) {
+ Optional<VpnBinding> oVpnBinding = aaiNetworkResources.getVpnBinding(netBindingUri);
+ if (oVpnBinding.isPresent()) {
+ org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding mappedVpnBinding = modelMapper.map(
+ oVpnBinding.get(), org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding.class);
+ if (oVpnBinding.get().getRouteTargets() != null) {
+ mappedVpnBinding.getRouteTargets()
+ .addAll(mapRouteTargets(oVpnBinding.get().getRouteTargets().getRouteTarget()));
+ mappedVpnBindings.add(mappedVpnBinding);
+ }
+ }
+ }
+ }
+ execution.getGeneralBuildingBlock().getCustomer().getVpnBindings().addAll(mappedVpnBindings);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ /**
+ * BPMN access method to extract VPN Binding data from AAI result and populate proper fields into
+ * CreateNetworkRequest
+ */
+ public void getNetworkVpnBinding(BuildingBlockExecution execution) {
+
+ try {
+ L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
+ AAIResultWrapper aaiResultWrapper = aaiNetworkResources.queryNetworkWrapperById(l3network);
+ CreateNetworkRequest createNetworkRequest = execution.getVariable("createNetworkRequest");
+
+ Optional<Relationships> networkRelationships = aaiResultWrapper.getRelationships();
+ if (!networkRelationships.isPresent()) {
+ throw (new Exception(ERROR_MSG));
+ }
+ List<AAIResourceUri> netBindingsUriList =
+ networkRelationships.get().getRelatedAAIUris(AAIObjectType.VPN_BINDING);
+ List<org.onap.so.openstack.beans.RouteTarget> routeTargets = new ArrayList<>();
+ for (AAIResourceUri netBindingUri : netBindingsUriList) {
+ logger.info("Get Route Targests");
+ Optional<VpnBinding> oVpnBinding = aaiNetworkResources.getVpnBinding(netBindingUri);
+ if (oVpnBinding.isPresent()) {
+ VpnBinding vpnBinding = oVpnBinding.get();
+ RouteTargets rts = vpnBinding.getRouteTargets();
+ if (rts != null) {
+ List<org.onap.aai.domain.yang.RouteTarget> rtList = rts.getRouteTarget();
+ if (!rtList.isEmpty()) {
+ PropertyMap<org.onap.aai.domain.yang.RouteTarget, org.onap.so.openstack.beans.RouteTarget> personMap =
+ new PropertyMap<org.onap.aai.domain.yang.RouteTarget, org.onap.so.openstack.beans.RouteTarget>() {
+ @Override
+ protected void configure() {
+ map().setRouteTarget(source.getGlobalRouteTarget());
+ map(source.getRouteTargetRole(), destination.getRouteTargetRole());
+ }
+ };
+ modelMapper.addMappings(personMap);
+ for (org.onap.aai.domain.yang.RouteTarget rt : rtList) {
+ org.onap.so.openstack.beans.RouteTarget openstackRtBean =
+ modelMapper.map(rt, org.onap.so.openstack.beans.RouteTarget.class);
+ routeTargets.add(openstackRtBean);
+ }
+ }
+ }
+ }
+ }
+ // store route targets data in execution - to be used as part of
+ // Network adapter input
+ createNetworkRequest.getContrailNetwork().setRouteTargets(routeTargets);
+ execution.setVariable("createNetworkRequest", createNetworkRequest);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ /**
+ * BPMN access method to query data for network policies from the AAI result wrapper From the resulting network
+ * policy, the network policy fqdn parameter is added to the network bbobject contrail network policy fqdns list
+ *
+ * @param execution
+ */
+ public void queryNetworkPolicy(BuildingBlockExecution execution) {
+ try {
+ L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
+ AAIResultWrapper aaiResultWrapper = aaiNetworkResources.queryNetworkWrapperById(l3network);
+ Optional<Relationships> networkRelationships = aaiResultWrapper.getRelationships();
+ if (!networkRelationships.isPresent()) {
+ throw (new Exception(ERROR_MSG));
+ }
+ List<AAIResourceUri> netPoliciesUriList =
+ networkRelationships.get().getRelatedAAIUris(AAIObjectType.NETWORK_POLICY);
+
+ if (!netPoliciesUriList.isEmpty()) {
+ for (AAIResourceUri netPolicyUri : netPoliciesUriList) {
+ Optional<NetworkPolicy> oNetPolicy = aaiNetworkResources.getNetworkPolicy(netPolicyUri);
+ if (oNetPolicy.isPresent()) {
+ l3network.getNetworkPolicies().add(modelMapper.map(oNetPolicy.get(),
+ org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy.class));
+ }
+ }
+ }
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ /**
+ * BPMN access method to query data for network table ref from the AAI result wrapper The resulting route table
+ * reference is mapped to the corresponding bbobject and added to the network bbobject contrail network route table
+ * references list
+ *
+ * @param execution
+ */
+ public void queryNetworkTableRef(BuildingBlockExecution execution) {
+ try {
+ L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
+ AAIResultWrapper aaiResultWrapper = aaiNetworkResources.queryNetworkWrapperById(l3network);
+ Optional<Relationships> networkRelationships = aaiResultWrapper.getRelationships();
+ if (!networkRelationships.isPresent()) {
+ throw (new Exception(ERROR_MSG));
+ }
+ List<AAIResourceUri> routeTableUriList =
+ networkRelationships.get().getRelatedAAIUris(AAIObjectType.ROUTE_TABLE_REFERENCE);
+
+ if (!routeTableUriList.isEmpty()) {
+ for (AAIResourceUri routeTableUri : routeTableUriList) {
+ Optional<RouteTableReference> oRouteTableReference =
+ aaiNetworkResources.getRouteTable(routeTableUri);
+ if (oRouteTableReference.isPresent()) {
+ org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference mappedRouteTableReference =
+ modelMapper.map(oRouteTableReference.get(),
+ org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference.class);
+ l3network.getContrailNetworkRouteTableReferences().add(mappedRouteTableReference);
+ }
+ }
+ }
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ private List<org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTarget> mapRouteTargets(
+ List<org.onap.aai.domain.yang.RouteTarget> routeTargets) {
+ List<org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTarget> mappedRouteTargets = new ArrayList<>();
+ if (!routeTargets.isEmpty()) {
+ for (org.onap.aai.domain.yang.RouteTarget routeTarget : routeTargets) {
+ org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTarget mappedRouteTarget =
+ modelMapper.map(routeTarget, org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTarget.class);
+ mappedRouteTargets.add(mappedRouteTarget);
+ }
+ }
+ return mappedRouteTargets;
+ }
+
+ public void querySubnet(BuildingBlockExecution execution) {
+ try {
+ L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
+ AAIResultWrapper aaiResultWrapper = aaiNetworkResources.queryNetworkWrapperById(l3network);
+ Optional<Relationships> networkRelationships = aaiResultWrapper.getRelationships();
+ if (!networkRelationships.isPresent()) {
+ throw (new Exception(ERROR_MSG));
+ }
+ List<AAIResourceUri> subnetsUriList = networkRelationships.get().getRelatedAAIUris(AAIObjectType.SUBNET);
+
+ if (!subnetsUriList.isEmpty()) {
+ for (AAIResourceUri subnetUri : subnetsUriList) {
+ Optional<Subnet> oSubnet = aaiNetworkResources.getSubnet(subnetUri);
+ if (oSubnet.isPresent()) {
+ l3network.getSubnets().add(modelMapper.map(oSubnet.get(),
+ org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet.class));
+ }
+ }
+ }
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java
index 82b61c17b5..3304d1b113 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java
@@ -24,7 +24,6 @@ package org.onap.so.bpmn.infrastructure.aai.tasks;
import java.util.List;
import java.util.Map;
-
import org.onap.so.adapters.nwrest.CreateNetworkResponse;
import org.onap.so.adapters.nwrest.UpdateNetworkResponse;
import org.onap.so.bpmn.common.BuildingBlockExecution;
@@ -57,507 +56,526 @@ import org.springframework.stereotype.Component;
@Component
public class AAIUpdateTasks {
- private static final Logger logger = LoggerFactory.getLogger(AAIUpdateTasks.class);
- private static final String ALACARTE = "aLaCarte";
- private static final String MULTI_STAGE_DESIGN_OFF = "false";
- private static final String MULTI_STAGE_DESIGN_ON = "true";
- @Autowired
- private AAIServiceInstanceResources aaiServiceInstanceResources;
- @Autowired
- private AAIVnfResources aaiVnfResources;
- @Autowired
- private AAIVfModuleResources aaiVfModuleResources;
- @Autowired
- private ExceptionBuilder exceptionUtil;
- @Autowired
- private ExtractPojosForBB extractPojosForBB;
- @Autowired
- private AAIVolumeGroupResources aaiVolumeGroupResources;
- @Autowired
- private AAINetworkResources aaiNetworkResources;
- @Autowired
- private AAICollectionResources aaiCollectionResources;
- @Autowired
- private AAIConfigurationResources aaiConfigurationResources;
-
- public void updateOrchestrationStatusAssignedService(BuildingBlockExecution execution) {
- try {
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- aaiServiceInstanceResources.updateOrchestrationStatusServiceInstance(serviceInstance, OrchestrationStatus.ASSIGNED);
- execution.setVariable("aaiServiceInstanceRollback", true);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void updateOrchestrationStatusActiveService(BuildingBlockExecution execution) {
- try {
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- aaiServiceInstanceResources.updateOrchestrationStatusServiceInstance(serviceInstance, OrchestrationStatus.ACTIVE);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void updateOrchestrationStatusAssignedVnf(BuildingBlockExecution execution) {
- try {
- GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- aaiVnfResources.updateOrchestrationStatusVnf(vnf,OrchestrationStatus.ASSIGNED);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void updateOrchestrationStatusActiveVnf(BuildingBlockExecution execution) {
- try {
- GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- aaiVnfResources.updateOrchestrationStatusVnf(vnf,OrchestrationStatus.ACTIVE);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void updateOrchestrationStatusAssignedVolumeGroup(BuildingBlockExecution execution) {
- try {
- GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
-
- VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
- CloudRegion cloudRegion = gBBInput.getCloudRegion();
- volumeGroup.setHeatStackId("");
- aaiVolumeGroupResources.updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.ASSIGNED);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void updateOrchestrationStatusActiveVolumeGroup(BuildingBlockExecution execution) {
- try {
- GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
-
- VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
- CloudRegion cloudRegion = gBBInput.getCloudRegion();
-
- aaiVolumeGroupResources.updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.ACTIVE);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void updateOrchestrationStatusCreatedVolumeGroup(BuildingBlockExecution execution) {
- try {
- GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
-
- VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
- CloudRegion cloudRegion = gBBInput.getCloudRegion();
-
- aaiVolumeGroupResources.updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.CREATED);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void updateHeatStackIdVolumeGroup(BuildingBlockExecution execution) {
- try {
- GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
- String heatStackId = execution.getVariable("heatStackId");
- if (heatStackId == null) {
- heatStackId = "";
- }
- VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
- CloudRegion cloudRegion = gBBInput.getCloudRegion();
- volumeGroup.setHeatStackId(heatStackId);
-
- aaiVolumeGroupResources.updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void updateOrchestrationStatusAssignedVfModule(BuildingBlockExecution execution) {
- try {
- VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
- vfModule.setHeatStackId("");
- GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- aaiVfModuleResources.updateOrchestrationStatusVfModule(vfModule,vnf,OrchestrationStatus.ASSIGNED);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void updateOrchestrationStatusPendingActivationVfModule(BuildingBlockExecution execution) {
- try {
- VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
- GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- aaiVfModuleResources.updateOrchestrationStatusVfModule(vfModule,vnf,OrchestrationStatus.PENDING_ACTIVATION);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void updateOrchestrationStatusAssignedOrPendingActivationVfModule(BuildingBlockExecution execution) {
- try {
- VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
- vfModule.setHeatStackId("");
- GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- String multiStageDesign = MULTI_STAGE_DESIGN_OFF;
- if (vnf.getModelInfoGenericVnf() != null) {
- multiStageDesign = vnf.getModelInfoGenericVnf().getMultiStageDesign();
- }
- boolean aLaCarte = (boolean) execution.getVariable(ALACARTE);
- if (aLaCarte && multiStageDesign != null && multiStageDesign.equalsIgnoreCase(MULTI_STAGE_DESIGN_ON)) {
- aaiVfModuleResources.updateOrchestrationStatusVfModule(vfModule,vnf,OrchestrationStatus.PENDING_ACTIVATION);
- }
- else {
- aaiVfModuleResources.updateOrchestrationStatusVfModule(vfModule,vnf,OrchestrationStatus.ASSIGNED);
- }
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void updateOrchestrationStatusCreatedVfModule(BuildingBlockExecution execution) {
- try {
- VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
- GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- aaiVfModuleResources.updateOrchestrationStatusVfModule(vfModule,vnf,OrchestrationStatus.CREATED);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void updateOrchestrationStatusDeactivateVfModule(BuildingBlockExecution execution) {
- execution.setVariable("aaiDeactivateVfModuleRollback", false);
- try {
- VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
- GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- aaiVfModuleResources.updateOrchestrationStatusVfModule(vfModule,vnf,OrchestrationStatus.CREATED);
- execution.setVariable("aaiDeactivateVfModuleRollback", true);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- /**
- * BPMN access method to update status of L3Network to Assigned in AAI
- * @param execution
- * @throws BBObjectNotFoundException
- */
- public void updateOrchestrationStatusAssignedNetwork(BuildingBlockExecution execution) {
- updateNetwork(execution, OrchestrationStatus.ASSIGNED);
- }
-
- /**
- * BPMN access method to update status of L3Network to Active in AAI
- * @param execution
- * @throws BBObjectNotFoundException
- */
- public void updateOrchestrationStatusActiveNetwork(BuildingBlockExecution execution) {
- updateNetwork(execution, OrchestrationStatus.ACTIVE);
- }
-
- /**
- * BPMN access method to update status of L3Network to Created in AAI
- * @param execution
- * @throws BBObjectNotFoundException
- */
- public void updateOrchestrationStatusCreatedNetwork(BuildingBlockExecution execution) {
- updateNetwork(execution, OrchestrationStatus.CREATED);
- }
-
- protected void updateNetwork(BuildingBlockExecution execution, OrchestrationStatus status) {
- try {
- L3Network l3Network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
- updateNetworkAAI(l3Network, status);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- protected void updateNetworkAAI(L3Network l3Network, OrchestrationStatus status) {
- L3Network copiedl3Network = l3Network.shallowCopyId();
-
- copiedl3Network.setOrchestrationStatus(status);
- l3Network.setOrchestrationStatus(status);
- aaiNetworkResources.updateNetwork(copiedl3Network);
-
- List<Subnet> subnets = l3Network.getSubnets();
- if (subnets != null){
- for (Subnet subnet : subnets){
- Subnet copiedSubnet = subnet.shallowCopyId();
- copiedSubnet.setOrchestrationStatus(status);
- aaiNetworkResources.updateSubnet(copiedl3Network, copiedSubnet);
- }
- }
- }
-
- /**
- * BPMN access method to update status of L3Network Collection to Active in AAI
- * @param execution
- * @throws BBObjectNotFoundException
- */
- public void updateOrchestrationStatusActiveNetworkCollection(BuildingBlockExecution execution) {
- execution.setVariable("aaiNetworkCollectionActivateRollback", false);
- try {
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- Collection networkCollection = serviceInstance.getCollection();
- Collection copiedNetworkCollection = networkCollection.shallowCopyId();
-
- networkCollection.setOrchestrationStatus(OrchestrationStatus.ACTIVE);
- copiedNetworkCollection.setOrchestrationStatus(OrchestrationStatus.ACTIVE);
- aaiCollectionResources.updateCollection(copiedNetworkCollection);
- execution.setVariable("aaiNetworkCollectionActivateRollback", true);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void updateOrchestrationStatusActivateVfModule(BuildingBlockExecution execution) {
- execution.setVariable("aaiActivateVfModuleRollback", false);
- try {
- VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
- GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- aaiVfModuleResources.updateOrchestrationStatusVfModule(vfModule, vnf, OrchestrationStatus.ACTIVE);
- execution.setVariable("aaiActivateVfModuleRollback", true);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void updateHeatStackIdVfModule(BuildingBlockExecution execution) {
- try {
- String heatStackId = execution.getVariable("heatStackId");
- if (heatStackId == null) {
- heatStackId = "";
- }
- VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
- GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- vfModule.setHeatStackId(heatStackId);
- aaiVfModuleResources.updateHeatStackIdVfModule(vfModule, vnf);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- /**
- * BPMN access method to update L3Network after it was created in cloud
- * @param execution
- * @throws Exception
- */
- public void updateNetworkCreated(BuildingBlockExecution execution) throws Exception {
- execution.setVariable("aaiNetworkActivateRollback", false);
- L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
- L3Network copiedl3network = l3network.shallowCopyId();
- CreateNetworkResponse response = execution.getVariable("createNetworkResponse");
- try {
- if(response.getNetworkFqdn()!=null){
- l3network.setContrailNetworkFqdn(response.getNetworkFqdn());
- }
- l3network.setOrchestrationStatus(OrchestrationStatus.CREATED);
- l3network.setHeatStackId(response.getNetworkStackId());
- l3network.setNeutronNetworkId(response.getNeutronNetworkId());
-
- copiedl3network.setContrailNetworkFqdn(response.getNetworkFqdn());
- copiedl3network.setOrchestrationStatus(OrchestrationStatus.CREATED);
- copiedl3network.setHeatStackId(response.getNetworkStackId());
- copiedl3network.setNeutronNetworkId(response.getNeutronNetworkId());
-
- aaiNetworkResources.updateNetwork(copiedl3network);
-
- Map<String, String> subnetMap = response.getSubnetMap();
- List<Subnet> subnets = l3network.getSubnets();
- if (subnets != null && subnetMap != null){
- for (Subnet subnet: subnets){
- Subnet copiedSubnet = subnet.shallowCopyId();
- copiedSubnet.setNeutronSubnetId(subnetMap.get(copiedSubnet.getSubnetId()));
- copiedSubnet.setOrchestrationStatus(OrchestrationStatus.CREATED);
- aaiNetworkResources.updateSubnet(copiedl3network, copiedSubnet);
- }
- }
-
- execution.setVariable("aaiNetworkActivateRollback", true);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- /**
- * BPMN access method to update L3Network after it was updated in cloud
- * @param execution
- * @throws Exception
- */
- public void updateNetworkUpdated(BuildingBlockExecution execution) throws Exception {
- L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
- L3Network copiedl3network = l3network.shallowCopyId();
- UpdateNetworkResponse response = execution.getVariable("updateNetworkResponse");
- try {
- copiedl3network.setNeutronNetworkId(response.getNeutronNetworkId());
- aaiNetworkResources.updateNetwork(copiedl3network);
-
- Map<String, String> subnetMap = response.getSubnetMap();
- List<Subnet> subnets = l3network.getSubnets();
- if (subnets != null && subnetMap != null){
- for (Subnet subnet: subnets){
- Subnet copiedSubnet = subnet.shallowCopyId();
- copiedSubnet.setNeutronSubnetId(subnetMap.get(copiedSubnet.getSubnetId()));
- copiedSubnet.setOrchestrationStatus(OrchestrationStatus.CREATED);
- aaiNetworkResources.updateSubnet(copiedl3network, copiedSubnet);
- }
- }
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void updateObjectNetwork(BuildingBlockExecution execution) {
- try {
- L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
- aaiNetworkResources.updateNetwork(l3network);
- } catch(Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- /**
- * BPMN access method to update ServiceInstance
- * @param execution
- */
- public void updateServiceInstance(BuildingBlockExecution execution) {
- try {
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- aaiServiceInstanceResources.updateServiceInstance(serviceInstance);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void updateObjectVnf(BuildingBlockExecution execution) {
- try {
- GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- aaiVnfResources.updateObjectVnf(genericVnf);
- } catch(Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void updateOrchestrationStatusDeleteVfModule(BuildingBlockExecution execution) {
- execution.setVariable("aaiDeleteVfModuleRollback", false);
- try {
- VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
- vfModule.setHeatStackId("");
- GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
-
- VfModule copiedVfModule = vfModule.shallowCopyId();
- copiedVfModule.setHeatStackId("");
- aaiVfModuleResources.updateOrchestrationStatusVfModule(vfModule,vnf,OrchestrationStatus.ASSIGNED);
- execution.setVariable("aaiDeleteVfModuleRollback", true);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void updateModelVfModule(BuildingBlockExecution execution) {
- try {
- VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
- GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- aaiVfModuleResources.changeAssignVfModule(vfModule, vnf);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
- public void updateOrchestrationStatusActivateFabricConfiguration(BuildingBlockExecution execution) {
- try {
- Configuration configuration = extractPojosForBB.extractByKey(execution, ResourceKey.CONFIGURATION_ID);
- aaiConfigurationResources.updateOrchestrationStatusConfiguration(configuration, OrchestrationStatus.ACTIVE);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void updateOrchestrationStatusDeactivateFabricConfiguration(BuildingBlockExecution execution) {
- try {
- Configuration configuration = extractPojosForBB.extractByKey(execution, ResourceKey.CONFIGURATION_ID);
- aaiConfigurationResources.updateOrchestrationStatusConfiguration(configuration, OrchestrationStatus.ASSIGNED);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void updateIpv4OamAddressVnf(BuildingBlockExecution execution) {
- try {
- String ipv4OamAddress = execution.getVariable("oamManagementV4Address");
- if (ipv4OamAddress != null) {
- GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- GenericVnf copiedGenericVnf = genericVnf.shallowCopyId();
-
- genericVnf.setIpv4OamAddress(ipv4OamAddress);
- copiedGenericVnf.setIpv4OamAddress(ipv4OamAddress);
-
- aaiVnfResources.updateObjectVnf(copiedGenericVnf);
- }
- } catch(Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void updateManagementV6AddressVnf(BuildingBlockExecution execution) {
- try {
- String managementV6Address = execution.getVariable("oamManagementV6Address");
- if (managementV6Address != null) {
- GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- GenericVnf copiedGenericVnf = genericVnf.shallowCopyId();
-
- genericVnf.setManagementV6Address(managementV6Address);
- copiedGenericVnf.setManagementV6Address(managementV6Address);
-
- aaiVnfResources.updateObjectVnf(copiedGenericVnf);
- }
- } catch(Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void updateContrailServiceInstanceFqdnVfModule(BuildingBlockExecution execution) {
- try {
- String contrailServiceInstanceFqdn = execution.getVariable("contrailServiceInstanceFqdn");
- if (contrailServiceInstanceFqdn != null) {
- VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
- GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- vfModule.setContrailServiceInstanceFqdn(contrailServiceInstanceFqdn);
- aaiVfModuleResources.updateContrailServiceInstanceFqdnVfModule(vfModule, vnf);
- }
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void updateOrchestrationStatusConfigAssignedVnf(BuildingBlockExecution execution) {
- try {
- GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- aaiVnfResources.updateOrchestrationStatusVnf(vnf, OrchestrationStatus.CONFIGASSIGNED);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void updateOrchestrationStausConfigDeployConfigureVnf(BuildingBlockExecution execution){
- try{
- GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- aaiVnfResources.updateOrchestrationStatusVnf(vnf, OrchestrationStatus.CONFIGURE);
-
- }catch(Exception ex){
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
-
- }
-
- public void updateOrchestrationStausConfigDeployConfiguredVnf(BuildingBlockExecution execution){
- try{
- GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- aaiVnfResources.updateOrchestrationStatusVnf(vnf, OrchestrationStatus.CONFIGURED);
-
- }catch(Exception ex){
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
-
- }
+ private static final Logger logger = LoggerFactory.getLogger(AAIUpdateTasks.class);
+ private static final String ALACARTE = "aLaCarte";
+ private static final String MULTI_STAGE_DESIGN_OFF = "false";
+ private static final String MULTI_STAGE_DESIGN_ON = "true";
+ @Autowired
+ private AAIServiceInstanceResources aaiServiceInstanceResources;
+ @Autowired
+ private AAIVnfResources aaiVnfResources;
+ @Autowired
+ private AAIVfModuleResources aaiVfModuleResources;
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+ @Autowired
+ private ExtractPojosForBB extractPojosForBB;
+ @Autowired
+ private AAIVolumeGroupResources aaiVolumeGroupResources;
+ @Autowired
+ private AAINetworkResources aaiNetworkResources;
+ @Autowired
+ private AAICollectionResources aaiCollectionResources;
+ @Autowired
+ private AAIConfigurationResources aaiConfigurationResources;
+
+ public void updateOrchestrationStatusAssignedService(BuildingBlockExecution execution) {
+ try {
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ aaiServiceInstanceResources.updateOrchestrationStatusServiceInstance(serviceInstance,
+ OrchestrationStatus.ASSIGNED);
+ execution.setVariable("aaiServiceInstanceRollback", true);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void updateOrchestrationStatusActiveService(BuildingBlockExecution execution) {
+ try {
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ aaiServiceInstanceResources.updateOrchestrationStatusServiceInstance(serviceInstance,
+ OrchestrationStatus.ACTIVE);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void updateOrchestrationStatusAssignedVnf(BuildingBlockExecution execution) {
+ try {
+ GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ aaiVnfResources.updateOrchestrationStatusVnf(vnf, OrchestrationStatus.ASSIGNED);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void updateOrchestrationStatusActiveVnf(BuildingBlockExecution execution) {
+ try {
+ GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ aaiVnfResources.updateOrchestrationStatusVnf(vnf, OrchestrationStatus.ACTIVE);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void updateOrchestrationStatusAssignedVolumeGroup(BuildingBlockExecution execution) {
+ try {
+ GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+
+ VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
+ CloudRegion cloudRegion = gBBInput.getCloudRegion();
+ volumeGroup.setHeatStackId("");
+ aaiVolumeGroupResources.updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion,
+ OrchestrationStatus.ASSIGNED);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void updateOrchestrationStatusActiveVolumeGroup(BuildingBlockExecution execution) {
+ try {
+ GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+
+ VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
+ CloudRegion cloudRegion = gBBInput.getCloudRegion();
+
+ aaiVolumeGroupResources.updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion,
+ OrchestrationStatus.ACTIVE);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void updateOrchestrationStatusCreatedVolumeGroup(BuildingBlockExecution execution) {
+ try {
+ GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+
+ VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
+ CloudRegion cloudRegion = gBBInput.getCloudRegion();
+
+ aaiVolumeGroupResources.updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion,
+ OrchestrationStatus.CREATED);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void updateHeatStackIdVolumeGroup(BuildingBlockExecution execution) {
+ try {
+ GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+ String heatStackId = execution.getVariable("heatStackId");
+ if (heatStackId == null) {
+ heatStackId = "";
+ }
+ VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
+ CloudRegion cloudRegion = gBBInput.getCloudRegion();
+ volumeGroup.setHeatStackId(heatStackId);
+
+ aaiVolumeGroupResources.updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void updateOrchestrationStatusAssignedVfModule(BuildingBlockExecution execution) {
+ try {
+ VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
+ vfModule.setHeatStackId("");
+ GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ aaiVfModuleResources.updateOrchestrationStatusVfModule(vfModule, vnf, OrchestrationStatus.ASSIGNED);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void updateOrchestrationStatusPendingActivationVfModule(BuildingBlockExecution execution) {
+ try {
+ VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
+ GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ aaiVfModuleResources.updateOrchestrationStatusVfModule(vfModule, vnf,
+ OrchestrationStatus.PENDING_ACTIVATION);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void updateOrchestrationStatusAssignedOrPendingActivationVfModule(BuildingBlockExecution execution) {
+ try {
+ VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
+ vfModule.setHeatStackId("");
+ GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ String multiStageDesign = MULTI_STAGE_DESIGN_OFF;
+ if (vnf.getModelInfoGenericVnf() != null) {
+ multiStageDesign = vnf.getModelInfoGenericVnf().getMultiStageDesign();
+ }
+ boolean aLaCarte = (boolean) execution.getVariable(ALACARTE);
+ if (aLaCarte && multiStageDesign != null && multiStageDesign.equalsIgnoreCase(MULTI_STAGE_DESIGN_ON)) {
+ aaiVfModuleResources.updateOrchestrationStatusVfModule(vfModule, vnf,
+ OrchestrationStatus.PENDING_ACTIVATION);
+ } else {
+ aaiVfModuleResources.updateOrchestrationStatusVfModule(vfModule, vnf, OrchestrationStatus.ASSIGNED);
+ }
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void updateOrchestrationStatusCreatedVfModule(BuildingBlockExecution execution) {
+ try {
+ VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
+ GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ aaiVfModuleResources.updateOrchestrationStatusVfModule(vfModule, vnf, OrchestrationStatus.CREATED);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void updateOrchestrationStatusDeactivateVfModule(BuildingBlockExecution execution) {
+ execution.setVariable("aaiDeactivateVfModuleRollback", false);
+ try {
+ VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
+ GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ aaiVfModuleResources.updateOrchestrationStatusVfModule(vfModule, vnf, OrchestrationStatus.CREATED);
+ execution.setVariable("aaiDeactivateVfModuleRollback", true);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ /**
+ * BPMN access method to update status of L3Network to Assigned in AAI
+ *
+ * @param execution
+ * @throws BBObjectNotFoundException
+ */
+ public void updateOrchestrationStatusAssignedNetwork(BuildingBlockExecution execution) {
+ updateNetwork(execution, OrchestrationStatus.ASSIGNED);
+ }
+
+ /**
+ * BPMN access method to update status of L3Network to Active in AAI
+ *
+ * @param execution
+ * @throws BBObjectNotFoundException
+ */
+ public void updateOrchestrationStatusActiveNetwork(BuildingBlockExecution execution) {
+ updateNetwork(execution, OrchestrationStatus.ACTIVE);
+ }
+
+ /**
+ * BPMN access method to update status of L3Network to Created in AAI
+ *
+ * @param execution
+ * @throws BBObjectNotFoundException
+ */
+ public void updateOrchestrationStatusCreatedNetwork(BuildingBlockExecution execution) {
+ updateNetwork(execution, OrchestrationStatus.CREATED);
+ }
+
+ protected void updateNetwork(BuildingBlockExecution execution, OrchestrationStatus status) {
+ try {
+ L3Network l3Network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
+ updateNetworkAAI(l3Network, status);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ protected void updateNetworkAAI(L3Network l3Network, OrchestrationStatus status) {
+ L3Network copiedl3Network = l3Network.shallowCopyId();
+
+ copiedl3Network.setOrchestrationStatus(status);
+ l3Network.setOrchestrationStatus(status);
+ aaiNetworkResources.updateNetwork(copiedl3Network);
+
+ List<Subnet> subnets = l3Network.getSubnets();
+ if (subnets != null) {
+ for (Subnet subnet : subnets) {
+ Subnet copiedSubnet = subnet.shallowCopyId();
+ copiedSubnet.setOrchestrationStatus(status);
+ aaiNetworkResources.updateSubnet(copiedl3Network, copiedSubnet);
+ }
+ }
+ }
+
+ /**
+ * BPMN access method to update status of L3Network Collection to Active in AAI
+ *
+ * @param execution
+ * @throws BBObjectNotFoundException
+ */
+ public void updateOrchestrationStatusActiveNetworkCollection(BuildingBlockExecution execution) {
+ execution.setVariable("aaiNetworkCollectionActivateRollback", false);
+ try {
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ Collection networkCollection = serviceInstance.getCollection();
+ Collection copiedNetworkCollection = networkCollection.shallowCopyId();
+
+ networkCollection.setOrchestrationStatus(OrchestrationStatus.ACTIVE);
+ copiedNetworkCollection.setOrchestrationStatus(OrchestrationStatus.ACTIVE);
+ aaiCollectionResources.updateCollection(copiedNetworkCollection);
+ execution.setVariable("aaiNetworkCollectionActivateRollback", true);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void updateOrchestrationStatusActivateVfModule(BuildingBlockExecution execution) {
+ execution.setVariable("aaiActivateVfModuleRollback", false);
+ try {
+ VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
+ GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ aaiVfModuleResources.updateOrchestrationStatusVfModule(vfModule, vnf, OrchestrationStatus.ACTIVE);
+ execution.setVariable("aaiActivateVfModuleRollback", true);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void updateHeatStackIdVfModule(BuildingBlockExecution execution) {
+ try {
+ String heatStackId = execution.getVariable("heatStackId");
+ if (heatStackId == null) {
+ heatStackId = "";
+ }
+ VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
+ GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ vfModule.setHeatStackId(heatStackId);
+ aaiVfModuleResources.updateHeatStackIdVfModule(vfModule, vnf);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ /**
+ * BPMN access method to update L3Network after it was created in cloud
+ *
+ * @param execution
+ * @throws Exception
+ */
+ public void updateNetworkCreated(BuildingBlockExecution execution) throws Exception {
+ execution.setVariable("aaiNetworkActivateRollback", false);
+ L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
+ L3Network copiedl3network = l3network.shallowCopyId();
+ CreateNetworkResponse response = execution.getVariable("createNetworkResponse");
+ try {
+ if (response.getNetworkFqdn() != null) {
+ l3network.setContrailNetworkFqdn(response.getNetworkFqdn());
+ }
+ l3network.setOrchestrationStatus(OrchestrationStatus.CREATED);
+ l3network.setHeatStackId(response.getNetworkStackId());
+ l3network.setNeutronNetworkId(response.getNeutronNetworkId());
+
+ copiedl3network.setContrailNetworkFqdn(response.getNetworkFqdn());
+ copiedl3network.setOrchestrationStatus(OrchestrationStatus.CREATED);
+ copiedl3network.setHeatStackId(response.getNetworkStackId());
+ copiedl3network.setNeutronNetworkId(response.getNeutronNetworkId());
+
+ aaiNetworkResources.updateNetwork(copiedl3network);
+
+ Map<String, String> subnetMap = response.getSubnetMap();
+ List<Subnet> subnets = l3network.getSubnets();
+ if (subnets != null && subnetMap != null) {
+ for (Subnet subnet : subnets) {
+ Subnet copiedSubnet = subnet.shallowCopyId();
+ copiedSubnet.setNeutronSubnetId(subnetMap.get(copiedSubnet.getSubnetId()));
+ copiedSubnet.setOrchestrationStatus(OrchestrationStatus.CREATED);
+ aaiNetworkResources.updateSubnet(copiedl3network, copiedSubnet);
+ }
+ }
+
+ execution.setVariable("aaiNetworkActivateRollback", true);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ /**
+ * BPMN access method to update L3Network after it was updated in cloud
+ *
+ * @param execution
+ * @throws Exception
+ */
+ public void updateNetworkUpdated(BuildingBlockExecution execution) throws Exception {
+ L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
+ L3Network copiedl3network = l3network.shallowCopyId();
+ UpdateNetworkResponse response = execution.getVariable("updateNetworkResponse");
+ try {
+ copiedl3network.setNeutronNetworkId(response.getNeutronNetworkId());
+ aaiNetworkResources.updateNetwork(copiedl3network);
+
+ Map<String, String> subnetMap = response.getSubnetMap();
+ List<Subnet> subnets = l3network.getSubnets();
+ if (subnets != null && subnetMap != null) {
+ for (Subnet subnet : subnets) {
+ Subnet copiedSubnet = subnet.shallowCopyId();
+ copiedSubnet.setNeutronSubnetId(subnetMap.get(copiedSubnet.getSubnetId()));
+ copiedSubnet.setOrchestrationStatus(OrchestrationStatus.CREATED);
+ aaiNetworkResources.updateSubnet(copiedl3network, copiedSubnet);
+ }
+ }
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void updateObjectNetwork(BuildingBlockExecution execution) {
+ try {
+ L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
+ aaiNetworkResources.updateNetwork(l3network);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ /**
+ * BPMN access method to update ServiceInstance
+ *
+ * @param execution
+ */
+ public void updateServiceInstance(BuildingBlockExecution execution) {
+ try {
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ aaiServiceInstanceResources.updateServiceInstance(serviceInstance);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void updateObjectVnf(BuildingBlockExecution execution) {
+ try {
+ GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ aaiVnfResources.updateObjectVnf(genericVnf);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void updateOrchestrationStatusDeleteVfModule(BuildingBlockExecution execution) {
+ execution.setVariable("aaiDeleteVfModuleRollback", false);
+ try {
+ VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
+ vfModule.setHeatStackId("");
+ GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+
+ VfModule copiedVfModule = vfModule.shallowCopyId();
+ copiedVfModule.setHeatStackId("");
+ aaiVfModuleResources.updateOrchestrationStatusVfModule(vfModule, vnf, OrchestrationStatus.ASSIGNED);
+ execution.setVariable("aaiDeleteVfModuleRollback", true);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void updateModelVfModule(BuildingBlockExecution execution) {
+ try {
+ VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
+ GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ aaiVfModuleResources.changeAssignVfModule(vfModule, vnf);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void updateOrchestrationStatusActivateFabricConfiguration(BuildingBlockExecution execution) {
+ try {
+ Configuration configuration = extractPojosForBB.extractByKey(execution, ResourceKey.CONFIGURATION_ID);
+ aaiConfigurationResources.updateOrchestrationStatusConfiguration(configuration, OrchestrationStatus.ACTIVE);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void updateOrchestrationStatusDeactivateFabricConfiguration(BuildingBlockExecution execution) {
+ try {
+ Configuration configuration = extractPojosForBB.extractByKey(execution, ResourceKey.CONFIGURATION_ID);
+ aaiConfigurationResources.updateOrchestrationStatusConfiguration(configuration,
+ OrchestrationStatus.ASSIGNED);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void updateIpv4OamAddressVnf(BuildingBlockExecution execution) {
+ try {
+ String ipv4OamAddress = execution.getVariable("oamManagementV4Address");
+ if (ipv4OamAddress != null) {
+ GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ GenericVnf copiedGenericVnf = genericVnf.shallowCopyId();
+
+ genericVnf.setIpv4OamAddress(ipv4OamAddress);
+ copiedGenericVnf.setIpv4OamAddress(ipv4OamAddress);
+
+ aaiVnfResources.updateObjectVnf(copiedGenericVnf);
+ }
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void updateManagementV6AddressVnf(BuildingBlockExecution execution) {
+ try {
+ String managementV6Address = execution.getVariable("oamManagementV6Address");
+ if (managementV6Address != null) {
+ GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ GenericVnf copiedGenericVnf = genericVnf.shallowCopyId();
+
+ genericVnf.setManagementV6Address(managementV6Address);
+ copiedGenericVnf.setManagementV6Address(managementV6Address);
+
+ aaiVnfResources.updateObjectVnf(copiedGenericVnf);
+ }
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void updateContrailServiceInstanceFqdnVfModule(BuildingBlockExecution execution) {
+ try {
+ String contrailServiceInstanceFqdn = execution.getVariable("contrailServiceInstanceFqdn");
+ if (contrailServiceInstanceFqdn != null) {
+ VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
+ GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ vfModule.setContrailServiceInstanceFqdn(contrailServiceInstanceFqdn);
+ aaiVfModuleResources.updateContrailServiceInstanceFqdnVfModule(vfModule, vnf);
+ }
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void updateOrchestrationStatusConfigAssignedVnf(BuildingBlockExecution execution) {
+ try {
+ GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ aaiVnfResources.updateOrchestrationStatusVnf(vnf, OrchestrationStatus.CONFIGASSIGNED);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void updateOrchestrationStausConfigDeployConfigureVnf(BuildingBlockExecution execution) {
+ try {
+ GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ aaiVnfResources.updateOrchestrationStatusVnf(vnf, OrchestrationStatus.CONFIGURE);
+
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+
+ }
+
+ public void updateOrchestrationStausConfigDeployConfiguredVnf(BuildingBlockExecution execution) {
+ try {
+ GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ aaiVnfResources.updateOrchestrationStatusVnf(vnf, OrchestrationStatus.CONFIGURED);
+
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java
index 821dfc18b0..05d4f56fdc 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java
@@ -25,7 +25,6 @@ package org.onap.so.bpmn.infrastructure.activity;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-
import org.camunda.bpm.engine.RuntimeService;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
@@ -44,106 +43,107 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-
import com.fasterxml.jackson.databind.ObjectMapper;
@Component("ExecuteActivity")
public class ExecuteActivity implements JavaDelegate {
- private static final Logger logger = LoggerFactory.getLogger(ExecuteActivity.class);
- private static final String G_BPMN_REQUEST = "bpmnRequest";
- private static final String VNF_TYPE = "vnfType";
- private static final String G_ACTION = "requestAction";
- private static final String G_REQUEST_ID = "mso-request-id";
- private static final String VNF_ID = "vnfId";
- private static final String SERVICE_INSTANCE_ID = "serviceInstanceId";
-
- private static final String SERVICE_TASK_IMPLEMENTATION_ATTRIBUTE = "implementation";
- private static final String ACTIVITY_PREFIX = "activity:";
-
- private ObjectMapper mapper = new ObjectMapper();
-
- @Autowired
- private RuntimeService runtimeService;
- @Autowired
- private ExceptionBuilder exceptionBuilder;
-
- @Override
- public void execute(DelegateExecution execution) throws Exception {
- final String requestId = (String) execution.getVariable(G_REQUEST_ID);
-
- try {
- final String implementationString = execution.getBpmnModelElementInstance().getAttributeValue(SERVICE_TASK_IMPLEMENTATION_ATTRIBUTE);
- logger.debug("activity implementation String: {}", implementationString);
- if (!implementationString.startsWith(ACTIVITY_PREFIX)) {
- buildAndThrowException(execution, "Implementation attribute has a wrong format");
- }
- String activityName = implementationString.replaceFirst(ACTIVITY_PREFIX, "");
- logger.info("activityName is: {}", activityName);
-
- BuildingBlock buildingBlock = buildBuildingBlock(activityName);
- ExecuteBuildingBlock executeBuildingBlock = buildExecuteBuildingBlock(execution, requestId, buildingBlock);
-
- Map<String, Object> variables = new HashMap<>();
- variables.put("buildingBlock", executeBuildingBlock);
- variables.put("mso-request-id", requestId);
- variables.put("retryCount", 1);
- variables.put("aLaCarte", true);
-
- ProcessInstanceWithVariables buildingBlockResult = runtimeService.createProcessInstanceByKey("ExecuteBuildingBlock").setVariables(variables).executeWithVariablesInReturn();
- VariableMap variableMap = buildingBlockResult.getVariables();
-
- WorkflowException workflowException = (WorkflowException) variableMap.get("WorklfowException");
- if (workflowException != null) {
- logger.error("Workflow exception is: {}", workflowException.getErrorMessage());
- }
- execution.setVariable("WorkflowException", workflowException);
- }
- catch (Exception e) {
- buildAndThrowException(execution, e.getMessage());
- }
- }
-
- protected BuildingBlock buildBuildingBlock(String activityName) {
- BuildingBlock buildingBlock = new BuildingBlock();
- buildingBlock.setBpmnFlowName(activityName);
- buildingBlock.setMsoId(UUID.randomUUID().toString());
- buildingBlock.setKey("");
- buildingBlock.setIsVirtualLink(false);
- buildingBlock.setVirtualLinkKey("");
- return buildingBlock;
- }
-
- protected ExecuteBuildingBlock buildExecuteBuildingBlock(DelegateExecution execution, String requestId,
- BuildingBlock buildingBlock) throws Exception {
- ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock();
- String bpmnRequest = (String) execution.getVariable(G_BPMN_REQUEST);
- ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class);
- RequestDetails requestDetails = sIRequest.getRequestDetails();
- executeBuildingBlock.setaLaCarte(true);
- executeBuildingBlock.setRequestAction((String) execution.getVariable(G_ACTION));
- executeBuildingBlock.setResourceId((String) execution.getVariable(VNF_ID));
- executeBuildingBlock.setVnfType((String) execution.getVariable(VNF_TYPE));
- WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
- workflowResourceIds.setServiceInstanceId((String) execution.getVariable(SERVICE_INSTANCE_ID));
- workflowResourceIds.setVnfId((String) execution.getVariable(VNF_ID));
- executeBuildingBlock.setWorkflowResourceIds(workflowResourceIds);
- executeBuildingBlock.setRequestId(requestId);
- executeBuildingBlock.setBuildingBlock(buildingBlock);
- executeBuildingBlock.setRequestDetails(requestDetails);
- return executeBuildingBlock;
- }
-
- protected void buildAndThrowException(DelegateExecution execution, String msg, Exception ex) {
- logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
- ErrorCode.UnknownError.getValue(), msg, ex);
- execution.setVariable("ExecuteActivityErrorMessage", msg);
- exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, msg);
- }
-
- protected void buildAndThrowException(DelegateExecution execution, String msg) {
- logger.error(msg);
- execution.setVariable("ExecuteActuvityErrorMessage", msg);
- exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, msg);
- }
+ private static final Logger logger = LoggerFactory.getLogger(ExecuteActivity.class);
+ private static final String G_BPMN_REQUEST = "bpmnRequest";
+ private static final String VNF_TYPE = "vnfType";
+ private static final String G_ACTION = "requestAction";
+ private static final String G_REQUEST_ID = "mso-request-id";
+ private static final String VNF_ID = "vnfId";
+ private static final String SERVICE_INSTANCE_ID = "serviceInstanceId";
+
+ private static final String SERVICE_TASK_IMPLEMENTATION_ATTRIBUTE = "implementation";
+ private static final String ACTIVITY_PREFIX = "activity:";
+
+ private ObjectMapper mapper = new ObjectMapper();
+
+ @Autowired
+ private RuntimeService runtimeService;
+ @Autowired
+ private ExceptionBuilder exceptionBuilder;
+
+ @Override
+ public void execute(DelegateExecution execution) throws Exception {
+ final String requestId = (String) execution.getVariable(G_REQUEST_ID);
+
+ try {
+ final String implementationString =
+ execution.getBpmnModelElementInstance().getAttributeValue(SERVICE_TASK_IMPLEMENTATION_ATTRIBUTE);
+ logger.debug("activity implementation String: {}", implementationString);
+ if (!implementationString.startsWith(ACTIVITY_PREFIX)) {
+ buildAndThrowException(execution, "Implementation attribute has a wrong format");
+ }
+ String activityName = implementationString.replaceFirst(ACTIVITY_PREFIX, "");
+ logger.info("activityName is: {}", activityName);
+
+ BuildingBlock buildingBlock = buildBuildingBlock(activityName);
+ ExecuteBuildingBlock executeBuildingBlock = buildExecuteBuildingBlock(execution, requestId, buildingBlock);
+
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("buildingBlock", executeBuildingBlock);
+ variables.put("mso-request-id", requestId);
+ variables.put("retryCount", 1);
+ variables.put("aLaCarte", true);
+
+ ProcessInstanceWithVariables buildingBlockResult =
+ runtimeService.createProcessInstanceByKey("ExecuteBuildingBlock").setVariables(variables)
+ .executeWithVariablesInReturn();
+ VariableMap variableMap = buildingBlockResult.getVariables();
+
+ WorkflowException workflowException = (WorkflowException) variableMap.get("WorklfowException");
+ if (workflowException != null) {
+ logger.error("Workflow exception is: {}", workflowException.getErrorMessage());
+ }
+ execution.setVariable("WorkflowException", workflowException);
+ } catch (Exception e) {
+ buildAndThrowException(execution, e.getMessage());
+ }
+ }
+
+ protected BuildingBlock buildBuildingBlock(String activityName) {
+ BuildingBlock buildingBlock = new BuildingBlock();
+ buildingBlock.setBpmnFlowName(activityName);
+ buildingBlock.setMsoId(UUID.randomUUID().toString());
+ buildingBlock.setKey("");
+ buildingBlock.setIsVirtualLink(false);
+ buildingBlock.setVirtualLinkKey("");
+ return buildingBlock;
+ }
+
+ protected ExecuteBuildingBlock buildExecuteBuildingBlock(DelegateExecution execution, String requestId,
+ BuildingBlock buildingBlock) throws Exception {
+ ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock();
+ String bpmnRequest = (String) execution.getVariable(G_BPMN_REQUEST);
+ ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class);
+ RequestDetails requestDetails = sIRequest.getRequestDetails();
+ executeBuildingBlock.setaLaCarte(true);
+ executeBuildingBlock.setRequestAction((String) execution.getVariable(G_ACTION));
+ executeBuildingBlock.setResourceId((String) execution.getVariable(VNF_ID));
+ executeBuildingBlock.setVnfType((String) execution.getVariable(VNF_TYPE));
+ WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
+ workflowResourceIds.setServiceInstanceId((String) execution.getVariable(SERVICE_INSTANCE_ID));
+ workflowResourceIds.setVnfId((String) execution.getVariable(VNF_ID));
+ executeBuildingBlock.setWorkflowResourceIds(workflowResourceIds);
+ executeBuildingBlock.setRequestId(requestId);
+ executeBuildingBlock.setBuildingBlock(buildingBlock);
+ executeBuildingBlock.setRequestDetails(requestDetails);
+ return executeBuildingBlock;
+ }
+
+ protected void buildAndThrowException(DelegateExecution execution, String msg, Exception ex) {
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ ErrorCode.UnknownError.getValue(), msg, ex);
+ execution.setVariable("ExecuteActivityErrorMessage", msg);
+ exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, msg);
+ }
+
+ protected void buildAndThrowException(DelegateExecution execution, String msg) {
+ logger.error(msg);
+ execution.setVariable("ExecuteActuvityErrorMessage", msg);
+ exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, msg);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterCreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterCreateTasks.java
index 67d2864204..0ec28d901c 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterCreateTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterCreateTasks.java
@@ -21,7 +21,6 @@
package org.onap.so.bpmn.infrastructure.adapter.network.tasks;
import java.util.Map;
-
import org.onap.so.adapters.nwrest.CreateNetworkRequest;
import org.onap.so.adapters.nwrest.CreateNetworkResponse;
import org.onap.so.bpmn.common.BuildingBlockExecution;
@@ -38,68 +37,74 @@ import org.springframework.stereotype.Component;
@Component
public class NetworkAdapterCreateTasks {
-
- @Autowired
- private ExtractPojosForBB extractPojosForBB;
- @Autowired
- private ExceptionBuilder exceptionUtil;
- @Autowired
- private NetworkAdapterObjectMapper networkAdapterObjectMapper;
- @Autowired
- private NetworkAdapterResources networkAdapterResources;
-
- public void createNetwork(BuildingBlockExecution execution) {
- execution.setVariable("networkAdapterCreateRollback", false);
- try {
- GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
-
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- L3Network l3Network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
-
- Map<String, String> userInput = gBBInput.getUserInput();
- String cloudRegionPo = execution.getVariable("cloudRegionPo");
-
- CreateNetworkRequest createNetworkRequest = networkAdapterObjectMapper.createNetworkRequestMapper(gBBInput.getRequestContext(), gBBInput.getCloudRegion(), gBBInput.getOrchContext(), serviceInstance, l3Network, userInput, cloudRegionPo, gBBInput.getCustomer());
-
- execution.setVariable("networkAdapterRequest", createNetworkRequest);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void processResponseFromOpenstack(BuildingBlockExecution execution) {
- try {
- L3Network l3Network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
-
- CreateNetworkResponse createNetworkResponse = execution.getVariable("createNetworkResponse");
- if(createNetworkResponse != null) {
- l3Network.setHeatStackId(createNetworkResponse.getNetworkStackId());
- if (createNetworkResponse.getNetworkCreated()){
- //setting rollback TRUE only if network was actually created (not a silent success OP)
- execution.setVariable("networkAdapterCreateRollback", true);
- }
- } else {
- throw new Exception("No response was sent back from NetworkAdapterRestV1 subflow.");
- }
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void rollbackCreateNetwork(BuildingBlockExecution execution) {
- try {
- GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
-
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- L3Network l3Network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
- CreateNetworkResponse createNetworkResponse = execution.getVariable("createNetworkResponse");
-
- Map<String, String> userInput = gBBInput.getUserInput();
- String cloudRegionPo = execution.getVariable("cloudRegionPo");
- networkAdapterResources.rollbackCreateNetwork(gBBInput.getRequestContext(), gBBInput.getCloudRegion(), gBBInput.getOrchContext(), serviceInstance, l3Network, userInput, cloudRegionPo, createNetworkResponse);
-
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
+
+ @Autowired
+ private ExtractPojosForBB extractPojosForBB;
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+ @Autowired
+ private NetworkAdapterObjectMapper networkAdapterObjectMapper;
+ @Autowired
+ private NetworkAdapterResources networkAdapterResources;
+
+ public void createNetwork(BuildingBlockExecution execution) {
+ execution.setVariable("networkAdapterCreateRollback", false);
+ try {
+ GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ L3Network l3Network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
+
+ Map<String, String> userInput = gBBInput.getUserInput();
+ String cloudRegionPo = execution.getVariable("cloudRegionPo");
+
+ CreateNetworkRequest createNetworkRequest = networkAdapterObjectMapper.createNetworkRequestMapper(
+ gBBInput.getRequestContext(), gBBInput.getCloudRegion(), gBBInput.getOrchContext(), serviceInstance,
+ l3Network, userInput, cloudRegionPo, gBBInput.getCustomer());
+
+ execution.setVariable("networkAdapterRequest", createNetworkRequest);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void processResponseFromOpenstack(BuildingBlockExecution execution) {
+ try {
+ L3Network l3Network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
+
+ CreateNetworkResponse createNetworkResponse = execution.getVariable("createNetworkResponse");
+ if (createNetworkResponse != null) {
+ l3Network.setHeatStackId(createNetworkResponse.getNetworkStackId());
+ if (createNetworkResponse.getNetworkCreated()) {
+ // setting rollback TRUE only if network was actually created (not a silent success OP)
+ execution.setVariable("networkAdapterCreateRollback", true);
+ }
+ } else {
+ throw new Exception("No response was sent back from NetworkAdapterRestV1 subflow.");
+ }
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void rollbackCreateNetwork(BuildingBlockExecution execution) {
+ try {
+ GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ L3Network l3Network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
+ CreateNetworkResponse createNetworkResponse = execution.getVariable("createNetworkResponse");
+
+ Map<String, String> userInput = gBBInput.getUserInput();
+ String cloudRegionPo = execution.getVariable("cloudRegionPo");
+ networkAdapterResources.rollbackCreateNetwork(gBBInput.getRequestContext(), gBBInput.getCloudRegion(),
+ gBBInput.getOrchContext(), serviceInstance, l3Network, userInput, cloudRegionPo,
+ createNetworkResponse);
+
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterDeleteTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterDeleteTasks.java
index 7e0c5f6da4..7a7d681762 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterDeleteTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterDeleteTasks.java
@@ -34,26 +34,28 @@ import org.springframework.stereotype.Component;
@Component
public class NetworkAdapterDeleteTasks {
-
- @Autowired
- private ExtractPojosForBB extractPojosForBB;
- @Autowired
- private NetworkAdapterObjectMapper networkAdapterObjectMapper;
- @Autowired
- private ExceptionBuilder exceptionUtil;
-
- public void deleteNetwork(BuildingBlockExecution execution) {
- try {
- GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
-
- L3Network l3Network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
-
- DeleteNetworkRequest deleteNetworkRequest = networkAdapterObjectMapper.deleteNetworkRequestMapper(gBBInput.getRequestContext(), gBBInput.getCloudRegion(), serviceInstance, l3Network);
-
- execution.setVariable("networkAdapterRequest", deleteNetworkRequest);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
+
+ @Autowired
+ private ExtractPojosForBB extractPojosForBB;
+ @Autowired
+ private NetworkAdapterObjectMapper networkAdapterObjectMapper;
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+
+ public void deleteNetwork(BuildingBlockExecution execution) {
+ try {
+ GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+
+ L3Network l3Network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+
+ DeleteNetworkRequest deleteNetworkRequest = networkAdapterObjectMapper.deleteNetworkRequestMapper(
+ gBBInput.getRequestContext(), gBBInput.getCloudRegion(), serviceInstance, l3Network);
+
+ execution.setVariable("networkAdapterRequest", deleteNetworkRequest);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1.java
index 4861257833..859db11037 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1.java
@@ -22,12 +22,10 @@ package org.onap.so.bpmn.infrastructure.adapter.network.tasks;
import java.io.StringReader;
import java.util.Optional;
-
import javax.ws.rs.core.Response;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
-
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.onap.so.adapters.nwrest.CreateNetworkError;
import org.onap.so.adapters.nwrest.CreateNetworkRequest;
@@ -48,111 +46,119 @@ import org.springframework.stereotype.Component;
@Component
public class NetworkAdapterRestV1 {
- private static final Logger logger = LoggerFactory.getLogger(NetworkAdapterRestV1.class);
-
- private static final String NETWORK_REQUEST = "networkAdapterRequest";
- private static final String NETWORK_MESSAGE = "NetworkAResponse_MESSAGE";
- private static final String NETWORK_SYNC_CODE = "NETWORKREST_networkAdapterStatusCode";
- private static final String NETWORK_SYNC_RESPONSE = "NETWORKREST_networkAdapterResponse";
- private static final String NETWORK_CORRELATOR = "NetworkAResponse_CORRELATOR";
-
- @Autowired
- private ExceptionBuilder exceptionBuilder;
+ private static final Logger logger = LoggerFactory.getLogger(NetworkAdapterRestV1.class);
+
+ private static final String NETWORK_REQUEST = "networkAdapterRequest";
+ private static final String NETWORK_MESSAGE = "NetworkAResponse_MESSAGE";
+ private static final String NETWORK_SYNC_CODE = "NETWORKREST_networkAdapterStatusCode";
+ private static final String NETWORK_SYNC_RESPONSE = "NETWORKREST_networkAdapterResponse";
+ private static final String NETWORK_CORRELATOR = "NetworkAResponse_CORRELATOR";
+
+ @Autowired
+ private ExceptionBuilder exceptionBuilder;
+
+ @Autowired
+ private NetworkAdapterResources networkAdapterResources;
+
+ public void callNetworkAdapter(DelegateExecution execution) {
+ try {
+ Object networkAdapterRequest = execution.getVariable(NETWORK_REQUEST);
+ if (networkAdapterRequest != null) {
+ Optional<Response> response = Optional.empty();
+ if (networkAdapterRequest instanceof CreateNetworkRequest) {
+ CreateNetworkRequest createNetworkRequest = (CreateNetworkRequest) networkAdapterRequest;
+ execution.setVariable(NETWORK_CORRELATOR, createNetworkRequest.getMessageId());
+ response = networkAdapterResources.createNetworkAsync(createNetworkRequest);
+ } else if (networkAdapterRequest instanceof DeleteNetworkRequest) {
+ DeleteNetworkRequest deleteNetworkRequest = (DeleteNetworkRequest) networkAdapterRequest;
+ execution.setVariable(NETWORK_CORRELATOR, deleteNetworkRequest.getMessageId());
+ response = networkAdapterResources.deleteNetworkAsync(deleteNetworkRequest);
+ } else if (networkAdapterRequest instanceof UpdateNetworkRequest) {
+ UpdateNetworkRequest updateNetworkRequest = (UpdateNetworkRequest) networkAdapterRequest;
+ execution.setVariable(NETWORK_CORRELATOR, updateNetworkRequest.getMessageId());
+ response = networkAdapterResources.updateNetworkAsync(updateNetworkRequest);
+ }
+ if (response.isPresent()) {
+ String statusCode = Integer.toString(response.get().getStatus());
+ String responseString = "";
+ if (response.get().getEntity() != null) {
+ responseString = (String) response.get().getEntity();
+ }
+ execution.setVariable(NETWORK_SYNC_CODE, statusCode);
+ execution.setVariable(NETWORK_SYNC_RESPONSE, responseString);
+ } else {
+ throw new Exception("No Ack response from Openstack Adapter");
+ }
+ } else {
+ throw new Exception("No Network Request was created. networkAdapterRequest was null.");
+ }
+ } catch (Exception ex) {
+ exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void processCallback(DelegateExecution execution) {
+ try {
+ Object networkAdapterRequest = execution.getVariable(NETWORK_REQUEST);
+ String callback = (String) execution.getVariable(NETWORK_MESSAGE);
+ String logCallbackMessage = "Callback from OpenstackAdapter: " + callback;
+ logger.debug(logCallbackMessage);
+ if (networkAdapterRequest != null) {
+ if (networkAdapterRequest instanceof CreateNetworkRequest) {
+ if (callback.contains("createNetworkError")) {
+ CreateNetworkError createNetworkError =
+ (CreateNetworkError) unmarshalXml(callback, CreateNetworkError.class);
+ throw new Exception(createNetworkError.getMessage());
+ } else {
+ CreateNetworkResponse createNetworkResponse =
+ (CreateNetworkResponse) unmarshalXml(callback, CreateNetworkResponse.class);
+ execution.setVariable("createNetworkResponse", createNetworkResponse);
+ }
+ } else if (networkAdapterRequest instanceof DeleteNetworkRequest) {
+ if (callback.contains("deleteNetworkError")) {
+ DeleteNetworkError deleteNetworkError =
+ (DeleteNetworkError) unmarshalXml(callback, DeleteNetworkError.class);
+ throw new Exception(deleteNetworkError.getMessage());
+ } else {
+ DeleteNetworkResponse deleteNetworkResponse =
+ (DeleteNetworkResponse) unmarshalXml(callback, DeleteNetworkResponse.class);
+ execution.setVariable("deleteNetworkResponse", deleteNetworkResponse);
+ }
+ } else if (networkAdapterRequest instanceof UpdateNetworkRequest) {
+ if (callback.contains("updateNetworkError")) {
+ UpdateNetworkError updateNetworkError =
+ (UpdateNetworkError) unmarshalXml(callback, UpdateNetworkError.class);
+ throw new Exception(updateNetworkError.getMessage());
+ } else {
+ UpdateNetworkResponse updateNetworkResponse =
+ (UpdateNetworkResponse) unmarshalXml(callback, UpdateNetworkResponse.class);
+ execution.setVariable("updateNetworkResponse", updateNetworkResponse);
+ }
+ }
+ }
+ } catch (Exception e) {
+ logger.error("Error in Openstack Adapter callback", e);
+ exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, e.getMessage());
+ }
+ }
+
+ protected <T> Object unmarshalXml(String xmlString, Class<T> resultClass) throws JAXBException {
+ StringReader reader = new StringReader(xmlString);
+ JAXBContext context = JAXBContext.newInstance(resultClass);
+ Unmarshaller unmarshaller = context.createUnmarshaller();
+ return unmarshaller.unmarshal(reader);
+ }
+
+ public void handleTimeOutException(DelegateExecution execution) {
+ exceptionBuilder.buildAndThrowWorkflowException(execution, 7000,
+ "Error timed out waiting on Openstack Async-Response");
+ }
- @Autowired
- private NetworkAdapterResources networkAdapterResources;
-
- public void callNetworkAdapter (DelegateExecution execution) {
- try {
- Object networkAdapterRequest = execution.getVariable(NETWORK_REQUEST);
- if (networkAdapterRequest != null) {
- Optional<Response> response = Optional.empty();
- if (networkAdapterRequest instanceof CreateNetworkRequest) {
- CreateNetworkRequest createNetworkRequest = (CreateNetworkRequest) networkAdapterRequest;
- execution.setVariable(NETWORK_CORRELATOR, createNetworkRequest.getMessageId());
- response = networkAdapterResources.createNetworkAsync(createNetworkRequest);
- } else if (networkAdapterRequest instanceof DeleteNetworkRequest) {
- DeleteNetworkRequest deleteNetworkRequest = (DeleteNetworkRequest) networkAdapterRequest;
- execution.setVariable(NETWORK_CORRELATOR, deleteNetworkRequest.getMessageId());
- response = networkAdapterResources.deleteNetworkAsync(deleteNetworkRequest);
- } else if (networkAdapterRequest instanceof UpdateNetworkRequest) {
- UpdateNetworkRequest updateNetworkRequest = (UpdateNetworkRequest) networkAdapterRequest;
- execution.setVariable(NETWORK_CORRELATOR, updateNetworkRequest.getMessageId());
- response = networkAdapterResources.updateNetworkAsync(updateNetworkRequest);
- }
- if(response.isPresent()) {
- String statusCode = Integer.toString(response.get().getStatus());
- String responseString = "";
- if(response.get().getEntity() != null) {
- responseString = (String) response.get().getEntity();
- }
- execution.setVariable(NETWORK_SYNC_CODE, statusCode);
- execution.setVariable(NETWORK_SYNC_RESPONSE, responseString);
- } else {
- throw new Exception("No Ack response from Openstack Adapter");
- }
- } else {
- throw new Exception("No Network Request was created. networkAdapterRequest was null.");
- }
- } catch (Exception ex) {
- exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void processCallback (DelegateExecution execution) {
- try {
- Object networkAdapterRequest = execution.getVariable(NETWORK_REQUEST);
- String callback = (String) execution.getVariable(NETWORK_MESSAGE);
- String logCallbackMessage = "Callback from OpenstackAdapter: " + callback;
- logger.debug(logCallbackMessage);
- if (networkAdapterRequest != null) {
- if (networkAdapterRequest instanceof CreateNetworkRequest) {
- if(callback.contains("createNetworkError")) {
- CreateNetworkError createNetworkError = (CreateNetworkError) unmarshalXml(callback, CreateNetworkError.class);
- throw new Exception(createNetworkError.getMessage());
- } else {
- CreateNetworkResponse createNetworkResponse = (CreateNetworkResponse) unmarshalXml(callback, CreateNetworkResponse.class);
- execution.setVariable("createNetworkResponse", createNetworkResponse);
- }
- } else if (networkAdapterRequest instanceof DeleteNetworkRequest) {
- if(callback.contains("deleteNetworkError")) {
- DeleteNetworkError deleteNetworkError = (DeleteNetworkError) unmarshalXml(callback, DeleteNetworkError.class);
- throw new Exception(deleteNetworkError.getMessage());
- } else {
- DeleteNetworkResponse deleteNetworkResponse = (DeleteNetworkResponse) unmarshalXml(callback, DeleteNetworkResponse.class);
- execution.setVariable("deleteNetworkResponse", deleteNetworkResponse);
- }
- } else if (networkAdapterRequest instanceof UpdateNetworkRequest) {
- if (callback.contains("updateNetworkError")) {
- UpdateNetworkError updateNetworkError = (UpdateNetworkError) unmarshalXml(callback, UpdateNetworkError.class);
- throw new Exception(updateNetworkError.getMessage());
- } else {
- UpdateNetworkResponse updateNetworkResponse = (UpdateNetworkResponse) unmarshalXml(callback, UpdateNetworkResponse.class);
- execution.setVariable("updateNetworkResponse", updateNetworkResponse);
- }
- }
- }
- } catch (Exception e) {
- logger.error("Error in Openstack Adapter callback", e);
- exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, e.getMessage());
- }
- }
-
- protected <T> Object unmarshalXml(String xmlString, Class<T> resultClass) throws JAXBException {
- StringReader reader = new StringReader(xmlString);
- JAXBContext context = JAXBContext.newInstance(resultClass);
- Unmarshaller unmarshaller = context.createUnmarshaller();
- return unmarshaller.unmarshal(reader);
- }
-
- public void handleTimeOutException (DelegateExecution execution) {
- exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, "Error timed out waiting on Openstack Async-Response");
- }
-
- public void handleSyncError (DelegateExecution execution) {
- String statusCode = (String) execution.getVariable(NETWORK_SYNC_CODE);
- String responseString = (String) execution.getVariable(NETWORK_SYNC_RESPONSE);
- String errorMessage = "Error with Openstack Adapter Sync Request: StatusCode = " + statusCode + " Response = " + responseString;
- exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, errorMessage);
- }
+ public void handleSyncError(DelegateExecution execution) {
+ String statusCode = (String) execution.getVariable(NETWORK_SYNC_CODE);
+ String responseString = (String) execution.getVariable(NETWORK_SYNC_RESPONSE);
+ String errorMessage = "Error with Openstack Adapter Sync Request: StatusCode = " + statusCode + " Response = "
+ + responseString;
+ exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, errorMessage);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterUpdateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterUpdateTasks.java
index 9eeba0445b..77898dd5cc 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterUpdateTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterUpdateTasks.java
@@ -40,37 +40,40 @@ import org.springframework.stereotype.Component;
@Component
public class NetworkAdapterUpdateTasks {
- private static final Logger logger = LoggerFactory.getLogger(NetworkAdapterUpdateTasks.class);
-
- @Autowired
- private ExtractPojosForBB extractPojosForBB;
- @Autowired
- private NetworkAdapterObjectMapper networkAdapterObjectMapper;
- @Autowired
- private ExceptionBuilder exceptionUtil;
-
- public void updateNetwork(BuildingBlockExecution execution) {
- try {
- GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- L3Network l3Network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
-
- UpdateNetworkRequest updateNetworkRequest = networkAdapterObjectMapper.createNetworkUpdateRequestMapper(gBBInput.getRequestContext(), gBBInput.getCloudRegion(), gBBInput.getOrchContext(), serviceInstance, l3Network, gBBInput.getUserInput(), gBBInput.getCustomer());
- execution.setVariable("networkAdapterRequest", updateNetworkRequest);
-
- } catch(Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void processResponseFromOpenstack(BuildingBlockExecution execution) {
- try {
- UpdateNetworkResponse updateNetworkResponse = execution.getVariable("updateNetworkResponse");
- if(updateNetworkResponse == null) {
- throw new Exception("No response was sent back from NetworkAdapterRestV1 subflow.");
- }
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
+ private static final Logger logger = LoggerFactory.getLogger(NetworkAdapterUpdateTasks.class);
+
+ @Autowired
+ private ExtractPojosForBB extractPojosForBB;
+ @Autowired
+ private NetworkAdapterObjectMapper networkAdapterObjectMapper;
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+
+ public void updateNetwork(BuildingBlockExecution execution) {
+ try {
+ GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ L3Network l3Network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
+
+ UpdateNetworkRequest updateNetworkRequest = networkAdapterObjectMapper.createNetworkUpdateRequestMapper(
+ gBBInput.getRequestContext(), gBBInput.getCloudRegion(), gBBInput.getOrchContext(), serviceInstance,
+ l3Network, gBBInput.getUserInput(), gBBInput.getCustomer());
+ execution.setVariable("networkAdapterRequest", updateNetworkRequest);
+
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void processResponseFromOpenstack(BuildingBlockExecution execution) {
+ try {
+ UpdateNetworkResponse updateNetworkResponse = execution.getVariable("updateNetworkResponse");
+ if (updateNetworkResponse == null) {
+ throw new Exception("No response was sent back from NetworkAdapterRestV1 subflow.");
+ }
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterCreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterCreateTasks.java
index ae9e6e7488..849465e787 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterCreateTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterCreateTasks.java
@@ -47,72 +47,79 @@ import static org.apache.commons.lang3.StringUtils.*;
@Component
public class VnfAdapterCreateTasks {
- private static final Logger logger = LoggerFactory.getLogger(VnfAdapterCreateTasks.class);
- private static final String VNFREST_REQUEST = "VNFREST_Request";
+ private static final Logger logger = LoggerFactory.getLogger(VnfAdapterCreateTasks.class);
+ private static final String VNFREST_REQUEST = "VNFREST_Request";
- @Autowired
- private ExtractPojosForBB extractPojosForBB;
- @Autowired
- private VnfAdapterVolumeGroupResources vnfAdapterVolumeGroupResources;
- @Autowired
- private VnfAdapterVfModuleResources vnfAdapterVfModuleResources;
+ @Autowired
+ private ExtractPojosForBB extractPojosForBB;
+ @Autowired
+ private VnfAdapterVolumeGroupResources vnfAdapterVolumeGroupResources;
+ @Autowired
+ private VnfAdapterVfModuleResources vnfAdapterVfModuleResources;
@Autowired
private ExceptionBuilder exceptionUtil;
- public void createVolumeGroupRequest(BuildingBlockExecution execution) {
- try {
- GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+ public void createVolumeGroupRequest(BuildingBlockExecution execution) {
+ try {
+ GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+
+ ServiceInstance serviceInstance =
+ gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0);
- ServiceInstance serviceInstance = gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0);
+ GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
+ VfModule vfModule;
+ String sdncVfModuleQueryResponse = null;
+ try {
+ vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
+ if (vfModule.getSelflink() != null && !vfModule.getSelflink().isEmpty()) {
+ sdncVfModuleQueryResponse = execution.getVariable("SDNCQueryResponse_" + vfModule.getVfModuleId());
+ } else {
+ throw new Exception("Vf Module " + vfModule.getVfModuleId()
+ + " exists in gBuildingBlock but does not have a selflink value");
+ }
+ } catch (BBObjectNotFoundException bbException) {
+ // If there is not a vf module in the general building block (in aLaCarte case), we will not retrieve
+ // the SDNCQueryResponse and proceed as normal without throwing an error
+ }
- GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
- VfModule vfModule;
- String sdncVfModuleQueryResponse = null;
- try {
- vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
- if(vfModule.getSelflink() != null && !vfModule.getSelflink().isEmpty()) {
- sdncVfModuleQueryResponse = execution.getVariable("SDNCQueryResponse_" + vfModule.getVfModuleId());
- }
- else {
- throw new Exception("Vf Module " + vfModule.getVfModuleId() + " exists in gBuildingBlock but does not have a selflink value");
- }
- } catch(BBObjectNotFoundException bbException) {
- // If there is not a vf module in the general building block (in aLaCarte case), we will not retrieve the SDNCQueryResponse and proceed as normal without throwing an error
- }
+ CreateVolumeGroupRequest createVolumeGroupRequest = vnfAdapterVolumeGroupResources.createVolumeGroupRequest(
+ gBBInput.getRequestContext(), gBBInput.getCloudRegion(), gBBInput.getOrchContext(), serviceInstance,
+ genericVnf, volumeGroup, sdncVfModuleQueryResponse);
+ execution.setVariable(VNFREST_REQUEST, createVolumeGroupRequest.toXmlString());
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
- CreateVolumeGroupRequest createVolumeGroupRequest = vnfAdapterVolumeGroupResources.createVolumeGroupRequest(gBBInput.getRequestContext(), gBBInput.getCloudRegion(), gBBInput.getOrchContext(), serviceInstance, genericVnf, volumeGroup, sdncVfModuleQueryResponse);
- execution.setVariable(VNFREST_REQUEST, createVolumeGroupRequest.toXmlString());
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
+ public void createVfModule(BuildingBlockExecution execution) {
+ try {
+ GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
- public void createVfModule(BuildingBlockExecution execution) {
- try {
- GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+ ServiceInstance serviceInstance =
+ gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0);
+ VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
+ GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ VolumeGroup volumeGroup = null;
+ try {
+ volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
+ } catch (BBObjectNotFoundException bbException) {
+ }
+ CloudRegion cloudRegion = gBBInput.getCloudRegion();
+ RequestContext requestContext = gBBInput.getRequestContext();
+ OrchestrationContext orchestrationContext = gBBInput.getOrchContext();
+ String sdncVfModuleQueryResponse = execution.getVariable("SDNCQueryResponse_" + vfModule.getVfModuleId());
+ String sdncVnfQueryResponse = execution.getVariable("SDNCQueryResponse_" + genericVnf.getVnfId());
- ServiceInstance serviceInstance = gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0);
- VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
- GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- VolumeGroup volumeGroup = null;
- try {
- volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
- } catch(BBObjectNotFoundException bbException) {
- }
- CloudRegion cloudRegion = gBBInput.getCloudRegion();
- RequestContext requestContext = gBBInput.getRequestContext();
- OrchestrationContext orchestrationContext = gBBInput.getOrchContext();
- String sdncVfModuleQueryResponse = execution.getVariable("SDNCQueryResponse_" + vfModule.getVfModuleId());
- String sdncVnfQueryResponse = execution.getVariable("SDNCQueryResponse_" + genericVnf.getVnfId());
+ CreateVfModuleRequest createVfModuleRequest = vnfAdapterVfModuleResources.createVfModuleRequest(
+ requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, vfModule,
+ volumeGroup, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
+ execution.setVariable(VNFREST_REQUEST, createVfModuleRequest.toXmlString());
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
- CreateVfModuleRequest createVfModuleRequest = vnfAdapterVfModuleResources.createVfModuleRequest(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, vfModule, volumeGroup, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
- execution.setVariable(VNFREST_REQUEST, createVfModuleRequest.toXmlString());
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterDeleteTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterDeleteTasks.java
index a96e2702cd..116dc30d63 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterDeleteTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterDeleteTasks.java
@@ -42,46 +42,50 @@ import org.springframework.stereotype.Component;
@Component
public class VnfAdapterDeleteTasks {
- private static final Logger logger = LoggerFactory.getLogger(VnfAdapterDeleteTasks.class);
- private static final String VNFREST_REQUEST = "VNFREST_Request";
-
- @Autowired
- private ExtractPojosForBB extractPojosForBB;
- @Autowired
- private VnfAdapterVolumeGroupResources vnfAdapterVolumeGroupResources;
- @Autowired
- private VnfAdapterVfModuleResources vnfAdapterVfModuleResources;
- @Autowired
- private ExceptionBuilder exceptionUtil;
-
- public void deleteVolumeGroup(BuildingBlockExecution execution) {
- try {
- GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
-
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
-
- DeleteVolumeGroupRequest deleteVolumeGroupRequest = vnfAdapterVolumeGroupResources.deleteVolumeGroupRequest(gBBInput.getRequestContext(), gBBInput.getCloudRegion(), serviceInstance, volumeGroup);
- execution.setVariable(VNFREST_REQUEST, deleteVolumeGroupRequest.toXmlString());
- execution.setVariable("deleteVolumeGroupRequest", "true");
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
+ private static final Logger logger = LoggerFactory.getLogger(VnfAdapterDeleteTasks.class);
+ private static final String VNFREST_REQUEST = "VNFREST_Request";
- public void deleteVfModule(BuildingBlockExecution execution) {
- try {
- GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
-
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
- GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
-
- DeleteVfModuleRequest deleteVfModuleRequest = vnfAdapterVfModuleResources.deleteVfModuleRequest( gBBInput.getRequestContext(), gBBInput.getCloudRegion(), serviceInstance, genericVnf, vfModule);
- execution.setVariable(VNFREST_REQUEST, deleteVfModuleRequest.toXmlString());
- execution.setVariable("deleteVfModuleRequest", "true");
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
+ @Autowired
+ private ExtractPojosForBB extractPojosForBB;
+ @Autowired
+ private VnfAdapterVolumeGroupResources vnfAdapterVolumeGroupResources;
+ @Autowired
+ private VnfAdapterVfModuleResources vnfAdapterVfModuleResources;
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+
+ public void deleteVolumeGroup(BuildingBlockExecution execution) {
+ try {
+ GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
+
+ DeleteVolumeGroupRequest deleteVolumeGroupRequest = vnfAdapterVolumeGroupResources.deleteVolumeGroupRequest(
+ gBBInput.getRequestContext(), gBBInput.getCloudRegion(), serviceInstance, volumeGroup);
+ execution.setVariable(VNFREST_REQUEST, deleteVolumeGroupRequest.toXmlString());
+ execution.setVariable("deleteVolumeGroupRequest", "true");
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void deleteVfModule(BuildingBlockExecution execution) {
+ try {
+ GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
+ GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+
+ DeleteVfModuleRequest deleteVfModuleRequest = vnfAdapterVfModuleResources.deleteVfModuleRequest(
+ gBBInput.getRequestContext(), gBBInput.getCloudRegion(), serviceInstance, genericVnf, vfModule);
+ execution.setVariable(VNFREST_REQUEST, deleteVfModuleRequest.toXmlString());
+ execution.setVariable("deleteVfModuleRequest", "true");
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java
index e854efd414..bfa76c5053 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java
@@ -45,7 +45,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
-
import javax.xml.XMLConstants;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;
@@ -59,96 +58,100 @@ import java.util.Map;
@Component
public class VnfAdapterImpl {
- private static final Logger logger = LoggerFactory.getLogger(VnfAdapterImpl.class);
- private static final String CONTRAIL_SERVICE_INSTANCE_FQDN = "contrailServiceInstanceFqdn";
- private static final String OAM_MANAGEMENT_V4_ADDRESS = "oamManagementV4Address";
- private static final String OAM_MANAGEMENT_V6_ADDRESS = "oamManagementV6Address";
- private static final String CONTRAIL_NETWORK_POLICY_FQDN_LIST = "contrailNetworkPolicyFqdnList";
-
- @Autowired
- private ExtractPojosForBB extractPojosForBB;
-
- @Autowired
- private ExceptionBuilder exceptionUtil;
+ private static final Logger logger = LoggerFactory.getLogger(VnfAdapterImpl.class);
+ private static final String CONTRAIL_SERVICE_INSTANCE_FQDN = "contrailServiceInstanceFqdn";
+ private static final String OAM_MANAGEMENT_V4_ADDRESS = "oamManagementV4Address";
+ private static final String OAM_MANAGEMENT_V6_ADDRESS = "oamManagementV6Address";
+ private static final String CONTRAIL_NETWORK_POLICY_FQDN_LIST = "contrailNetworkPolicyFqdnList";
+
+ @Autowired
+ private ExtractPojosForBB extractPojosForBB;
+
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+
+ public void preProcessVnfAdapter(BuildingBlockExecution execution) {
+ try {
+ GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ execution.setVariable("mso-request-id", gBBInput.getRequestContext().getMsoRequestId());
+ execution.setVariable("mso-service-instance-id", serviceInstance.getServiceInstanceId());
+ execution.setVariable("heatStackId", null);
+ execution.setVariable(CONTRAIL_SERVICE_INSTANCE_FQDN, null);
+ execution.setVariable(OAM_MANAGEMENT_V4_ADDRESS, null);
+ execution.setVariable(OAM_MANAGEMENT_V6_ADDRESS, null);
+ execution.setVariable(CONTRAIL_NETWORK_POLICY_FQDN_LIST, null);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
- public void preProcessVnfAdapter(BuildingBlockExecution execution) {
- try {
- GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- execution.setVariable("mso-request-id", gBBInput.getRequestContext().getMsoRequestId());
- execution.setVariable("mso-service-instance-id", serviceInstance.getServiceInstanceId());
- execution.setVariable("heatStackId", null);
- execution.setVariable(CONTRAIL_SERVICE_INSTANCE_FQDN, null);
- execution.setVariable(OAM_MANAGEMENT_V4_ADDRESS, null);
- execution.setVariable(OAM_MANAGEMENT_V6_ADDRESS, null);
- execution.setVariable(CONTRAIL_NETWORK_POLICY_FQDN_LIST, null);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void postProcessVnfAdapter(BuildingBlockExecution execution) {
- try {
- String vnfAdapterResponse = execution.getVariable("vnfAdapterRestV1Response");
- if (!StringUtils.isEmpty( vnfAdapterResponse)) {
+ public void postProcessVnfAdapter(BuildingBlockExecution execution) {
+ try {
+ String vnfAdapterResponse = execution.getVariable("vnfAdapterRestV1Response");
+ if (!StringUtils.isEmpty(vnfAdapterResponse)) {
Object vnfRestResponse = unMarshal(vnfAdapterResponse);
- if(vnfRestResponse instanceof CreateVfModuleResponse) {
+ if (vnfRestResponse instanceof CreateVfModuleResponse) {
VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
String heatStackId = ((CreateVfModuleResponse) vnfRestResponse).getVfModuleStackId();
- if(!StringUtils.isEmpty(heatStackId)) {
- vfModule.setHeatStackId(heatStackId);
+ if (!StringUtils.isEmpty(heatStackId)) {
+ vfModule.setHeatStackId(heatStackId);
execution.setVariable("heatStackId", heatStackId);
}
- Map<String,String> vfModuleOutputs = ((CreateVfModuleResponse) vnfRestResponse).getVfModuleOutputs();
+ Map<String, String> vfModuleOutputs =
+ ((CreateVfModuleResponse) vnfRestResponse).getVfModuleOutputs();
if (vfModuleOutputs != null) {
- processVfModuleOutputs(execution, vfModuleOutputs);
+ processVfModuleOutputs(execution, vfModuleOutputs);
}
- } else if(vnfRestResponse instanceof DeleteVfModuleResponse) {
+ } else if (vnfRestResponse instanceof DeleteVfModuleResponse) {
VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
Boolean vfModuleDelete = ((DeleteVfModuleResponse) vnfRestResponse).getVfModuleDeleted();
- if(null!= vfModuleDelete && vfModuleDelete) {
+ if (null != vfModuleDelete && vfModuleDelete) {
vfModule.setHeatStackId(null);
execution.setVariable("heatStackId", null);
- Map<String,String> vfModuleOutputs = ((DeleteVfModuleResponse) vnfRestResponse).getVfModuleOutputs();
+ Map<String, String> vfModuleOutputs =
+ ((DeleteVfModuleResponse) vnfRestResponse).getVfModuleOutputs();
if (vfModuleOutputs != null) {
- processVfModuleOutputs(execution, vfModuleOutputs);
- if (execution.getVariable(OAM_MANAGEMENT_V4_ADDRESS) != null) {
- genericVnf.setIpv4OamAddress("");
- execution.setVariable(OAM_MANAGEMENT_V4_ADDRESS, "");
- }
- if (execution.getVariable(OAM_MANAGEMENT_V6_ADDRESS) != null) {
- genericVnf.setManagementV6Address("");
- execution.setVariable(OAM_MANAGEMENT_V6_ADDRESS, "");
- }
- if (execution.getVariable(CONTRAIL_SERVICE_INSTANCE_FQDN) != null) {
- vfModule.setContrailServiceInstanceFqdn("");
- execution.setVariable(CONTRAIL_SERVICE_INSTANCE_FQDN, "");
- }
+ processVfModuleOutputs(execution, vfModuleOutputs);
+ if (execution.getVariable(OAM_MANAGEMENT_V4_ADDRESS) != null) {
+ genericVnf.setIpv4OamAddress("");
+ execution.setVariable(OAM_MANAGEMENT_V4_ADDRESS, "");
+ }
+ if (execution.getVariable(OAM_MANAGEMENT_V6_ADDRESS) != null) {
+ genericVnf.setManagementV6Address("");
+ execution.setVariable(OAM_MANAGEMENT_V6_ADDRESS, "");
+ }
+ if (execution.getVariable(CONTRAIL_SERVICE_INSTANCE_FQDN) != null) {
+ vfModule.setContrailServiceInstanceFqdn("");
+ execution.setVariable(CONTRAIL_SERVICE_INSTANCE_FQDN, "");
+ }
}
}
- } else if(vnfRestResponse instanceof CreateVolumeGroupResponse) {
+ } else if (vnfRestResponse instanceof CreateVolumeGroupResponse) {
VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
String heatStackId = ((CreateVolumeGroupResponse) vnfRestResponse).getVolumeGroupStackId();
- if(!StringUtils.isEmpty(heatStackId)) {
+ if (!StringUtils.isEmpty(heatStackId)) {
volumeGroup.setHeatStackId(heatStackId);
execution.setVariable("heatStackId", heatStackId);
- }else{
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "HeatStackId is missing from create VolumeGroup Vnf Adapter response.");
- }
- } else if(vnfRestResponse instanceof DeleteVolumeGroupResponse) {
- VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
- Boolean volumeGroupDelete = ((DeleteVolumeGroupResponse) vnfRestResponse).getVolumeGroupDeleted();
- if(null!= volumeGroupDelete && volumeGroupDelete) {
- volumeGroup.setHeatStackId(null);
- execution.setVariable("heatStackId", null);
- }
+ } else {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000,
+ "HeatStackId is missing from create VolumeGroup Vnf Adapter response.");
+ }
+ } else if (vnfRestResponse instanceof DeleteVolumeGroupResponse) {
+ VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
+ Boolean volumeGroupDelete = ((DeleteVolumeGroupResponse) vnfRestResponse).getVolumeGroupDeleted();
+ if (null != volumeGroupDelete && volumeGroupDelete) {
+ volumeGroup.setHeatStackId(null);
+ execution.setVariable("heatStackId", null);
+ }
}
}
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
private Object unMarshal(String input) throws MarshallerException {
try {
@@ -160,61 +163,60 @@ public class VnfAdapterImpl {
XMLReader xmlReader = spf.newSAXParser().getXMLReader();
JAXBContext jaxbContext = JAXBContext.newInstance(CreateVfModuleResponse.class,
- CreateVolumeGroupResponse.class,DeleteVfModuleResponse.class,DeleteVolumeGroupResponse.class);
+ CreateVolumeGroupResponse.class, DeleteVfModuleResponse.class, DeleteVolumeGroupResponse.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
InputSource inputSource = new InputSource(new StringReader(input));
SAXSource source = new SAXSource(xmlReader, inputSource);
return jaxbUnmarshaller.unmarshal(source);
} catch (Exception e) {
- logger.error("{} {} {}", MessageEnum.GENERAL_EXCEPTION.toString(), ErrorCode.SchemaError.getValue(),
- e.getMessage(), e);
- throw new MarshallerException("Error parsing VNF Adapter response. " + e.getMessage(), ErrorCode.SchemaError.getValue(), e);
+ logger.error("{} {} {}", MessageEnum.GENERAL_EXCEPTION.toString(), ErrorCode.SchemaError.getValue(),
+ e.getMessage(), e);
+ throw new MarshallerException("Error parsing VNF Adapter response. " + e.getMessage(),
+ ErrorCode.SchemaError.getValue(), e);
}
}
-
- private void processVfModuleOutputs(BuildingBlockExecution execution, Map<String,String> vfModuleOutputs) {
- if (vfModuleOutputs == null) {
- return;
- }
- try {
- VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
- GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- List<String> contrailNetworkPolicyFqdnList = new ArrayList<String>();
- Iterator<String> keys = vfModuleOutputs.keySet().iterator();
- while (keys.hasNext()) {
- String key = keys.next();
- if (key.equals("contrail-service-instance-fqdn")) {
- String contrailServiceInstanceFqdn = vfModuleOutputs.get(key);
- logger.debug("Obtained contrailServiceInstanceFqdn: {}", contrailServiceInstanceFqdn);
- vfModule.setContrailServiceInstanceFqdn(contrailServiceInstanceFqdn);
- execution.setVariable(CONTRAIL_SERVICE_INSTANCE_FQDN, contrailServiceInstanceFqdn);
- }
- else if (key.endsWith("contrail_network_policy_fqdn")) {
- String contrailNetworkPolicyFqdn = vfModuleOutputs.get(key);
- logger.debug("Obtained contrailNetworkPolicyFqdn: {}", contrailNetworkPolicyFqdn);
- contrailNetworkPolicyFqdnList.add(contrailNetworkPolicyFqdn);
- }
- else if (key.equals("oam_management_v4_address")) {
- String oamManagementV4Address = vfModuleOutputs.get(key);
- logger.debug("Obtained oamManagementV4Address: {}", oamManagementV4Address);
- genericVnf.setIpv4OamAddress(oamManagementV4Address);
- execution.setVariable(OAM_MANAGEMENT_V4_ADDRESS, oamManagementV4Address);
- }
- else if (key.equals("oam_management_v6_address")) {
- String oamManagementV6Address = vfModuleOutputs.get(key);
- logger.debug("Obtained oamManagementV6Address: {}", oamManagementV6Address);
- genericVnf.setManagementV6Address(oamManagementV6Address);
- execution.setVariable(OAM_MANAGEMENT_V6_ADDRESS, oamManagementV6Address);
- }
-
- if (!contrailNetworkPolicyFqdnList.isEmpty()) {
- execution.setVariable(CONTRAIL_NETWORK_POLICY_FQDN_LIST, String.join(",", contrailNetworkPolicyFqdnList));
- }
- }
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
-
+
+ private void processVfModuleOutputs(BuildingBlockExecution execution, Map<String, String> vfModuleOutputs) {
+ if (vfModuleOutputs == null) {
+ return;
+ }
+ try {
+ VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
+ GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ List<String> contrailNetworkPolicyFqdnList = new ArrayList<String>();
+ Iterator<String> keys = vfModuleOutputs.keySet().iterator();
+ while (keys.hasNext()) {
+ String key = keys.next();
+ if (key.equals("contrail-service-instance-fqdn")) {
+ String contrailServiceInstanceFqdn = vfModuleOutputs.get(key);
+ logger.debug("Obtained contrailServiceInstanceFqdn: {}", contrailServiceInstanceFqdn);
+ vfModule.setContrailServiceInstanceFqdn(contrailServiceInstanceFqdn);
+ execution.setVariable(CONTRAIL_SERVICE_INSTANCE_FQDN, contrailServiceInstanceFqdn);
+ } else if (key.endsWith("contrail_network_policy_fqdn")) {
+ String contrailNetworkPolicyFqdn = vfModuleOutputs.get(key);
+ logger.debug("Obtained contrailNetworkPolicyFqdn: {}", contrailNetworkPolicyFqdn);
+ contrailNetworkPolicyFqdnList.add(contrailNetworkPolicyFqdn);
+ } else if (key.equals("oam_management_v4_address")) {
+ String oamManagementV4Address = vfModuleOutputs.get(key);
+ logger.debug("Obtained oamManagementV4Address: {}", oamManagementV4Address);
+ genericVnf.setIpv4OamAddress(oamManagementV4Address);
+ execution.setVariable(OAM_MANAGEMENT_V4_ADDRESS, oamManagementV4Address);
+ } else if (key.equals("oam_management_v6_address")) {
+ String oamManagementV6Address = vfModuleOutputs.get(key);
+ logger.debug("Obtained oamManagementV6Address: {}", oamManagementV6Address);
+ genericVnf.setManagementV6Address(oamManagementV6Address);
+ execution.setVariable(OAM_MANAGEMENT_V6_ADDRESS, oamManagementV6Address);
+ }
+
+ if (!contrailNetworkPolicyFqdnList.isEmpty()) {
+ execution.setVariable(CONTRAIL_NETWORK_POLICY_FQDN_LIST,
+ String.join(",", contrailNetworkPolicyFqdnList));
+ }
+ }
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+
}
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/Constants.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/Constants.java
index 976b1bc8df..01519fab6e 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/Constants.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/Constants.java
@@ -30,34 +30,34 @@ import org.onap.vnfmadapter.v1.model.OperationStatusRetrievalStatusEnum;
*/
public class Constants {
- public static final String CREATE_VNF_REQUEST_PARAM_NAME = "createVnfRequest";
- public static final String CREATE_VNF_RESPONSE_PARAM_NAME = "createVnfResponse";
- public static final String INPUT_PARAMETER = "inputParameter";
- public static final String DELETE_VNF_RESPONSE_PARAM_NAME = "deleteVnfResponse";
- public static final String DELETE_VNF_NODE_STATUS = "deleteVnfNodeStatus";
- public static final String CREATE_VNF_NODE_STATUS = "createVnfNodeStatus";
- public static final String VNF_ASSIGNED = "Assigned";
- public static final String VNF_CREATED = "Created";
+ public static final String CREATE_VNF_REQUEST_PARAM_NAME = "createVnfRequest";
+ public static final String CREATE_VNF_RESPONSE_PARAM_NAME = "createVnfResponse";
+ public static final String INPUT_PARAMETER = "inputParameter";
+ public static final String DELETE_VNF_RESPONSE_PARAM_NAME = "deleteVnfResponse";
+ public static final String DELETE_VNF_NODE_STATUS = "deleteVnfNodeStatus";
+ public static final String CREATE_VNF_NODE_STATUS = "createVnfNodeStatus";
+ public static final String VNF_ASSIGNED = "Assigned";
+ public static final String VNF_CREATED = "Created";
- public static final String DOT = ".";
- public static final String UNDERSCORE = "_";
- public static final String SPACE = "\\s+";
+ public static final String DOT = ".";
+ public static final String UNDERSCORE = "_";
+ public static final String SPACE = "\\s+";
- public static final String VNFM_ADAPTER_DEFAULT_URL = "http://so-vnfm-adapter.onap:9092/so/vnfm-adapter/v1/";
- public static final String VNFM_ADAPTER_DEFAULT_AUTH = "Basic dm5mbTpwYXNzd29yZDEk";
+ public static final String VNFM_ADAPTER_DEFAULT_URL = "http://so-vnfm-adapter.onap:9092/so/vnfm-adapter/v1/";
+ public static final String VNFM_ADAPTER_DEFAULT_AUTH = "Basic dm5mbTpwYXNzd29yZDEk";
- public static final String FORWARD_SLASH = "/";
- public static final String PRELOAD_VNFS_URL = "/restconf/config/VNF-API:preload-vnfs/vnf-preload-list/";
+ public static final String FORWARD_SLASH = "/";
+ public static final String PRELOAD_VNFS_URL = "/restconf/config/VNF-API:preload-vnfs/vnf-preload-list/";
- public static final Set<OperationStateEnum> OPERATION_FINISHED_STATES =
- newHashSet(OperationStateEnum.COMPLETED, OperationStateEnum.FAILED, OperationStateEnum.ROLLED_BACK);
+ public static final Set<OperationStateEnum> OPERATION_FINISHED_STATES =
+ newHashSet(OperationStateEnum.COMPLETED, OperationStateEnum.FAILED, OperationStateEnum.ROLLED_BACK);
- public static final Set<OperationStatusRetrievalStatusEnum> OPERATION_RETRIEVAL_STATES = newHashSet(
- OperationStatusRetrievalStatusEnum.STATUS_FOUND, OperationStatusRetrievalStatusEnum.WAITING_FOR_STATUS);
+ public static final Set<OperationStatusRetrievalStatusEnum> OPERATION_RETRIEVAL_STATES = newHashSet(
+ OperationStatusRetrievalStatusEnum.STATUS_FOUND, OperationStatusRetrievalStatusEnum.WAITING_FOR_STATUS);
- public static final String OPERATION_STATUS_PARAM_NAME = "operationStatus";
+ public static final String OPERATION_STATUS_PARAM_NAME = "operationStatus";
- private Constants() {}
+ private Constants() {}
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/EtsiVnfDeleteTask.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/EtsiVnfDeleteTask.java
index 857c5cb6fe..f29f842709 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/EtsiVnfDeleteTask.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/EtsiVnfDeleteTask.java
@@ -39,46 +39,46 @@ import com.google.common.base.Optional;
@Component
public class EtsiVnfDeleteTask {
- private static final Logger LOGGER = LoggerFactory.getLogger(EtsiVnfDeleteTask.class);
- private final ExtractPojosForBB extractPojosForBB;
- private final ExceptionBuilder exceptionUtil;
- private final VnfmAdapterServiceProvider vnfmAdapterServiceProvider;
+ private static final Logger LOGGER = LoggerFactory.getLogger(EtsiVnfDeleteTask.class);
+ private final ExtractPojosForBB extractPojosForBB;
+ private final ExceptionBuilder exceptionUtil;
+ private final VnfmAdapterServiceProvider vnfmAdapterServiceProvider;
- @Autowired
- public EtsiVnfDeleteTask(final ExceptionBuilder exceptionUtil, final ExtractPojosForBB extractPojosForBB,
- final VnfmAdapterServiceProvider vnfmAdapterServiceProvider) {
- this.exceptionUtil = exceptionUtil;
- this.extractPojosForBB = extractPojosForBB;
- this.vnfmAdapterServiceProvider = vnfmAdapterServiceProvider;
- }
+ @Autowired
+ public EtsiVnfDeleteTask(final ExceptionBuilder exceptionUtil, final ExtractPojosForBB extractPojosForBB,
+ final VnfmAdapterServiceProvider vnfmAdapterServiceProvider) {
+ this.exceptionUtil = exceptionUtil;
+ this.extractPojosForBB = extractPojosForBB;
+ this.vnfmAdapterServiceProvider = vnfmAdapterServiceProvider;
+ }
- /**
- * Invoke VNFM adapter to delete the VNF
- *
- * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
- */
- public void invokeVnfmAdapter(final BuildingBlockExecution execution) {
- try {
- LOGGER.debug("Executing invokeVnfmAdapter ...");
- final GenericVnf vnf = extractPojosForBB.extractByKey(execution, GENERIC_VNF_ID);
+ /**
+ * Invoke VNFM adapter to delete the VNF
+ *
+ * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
+ */
+ public void invokeVnfmAdapter(final BuildingBlockExecution execution) {
+ try {
+ LOGGER.debug("Executing invokeVnfmAdapter ...");
+ final GenericVnf vnf = extractPojosForBB.extractByKey(execution, GENERIC_VNF_ID);
- final Optional<DeleteVnfResponse> response = vnfmAdapterServiceProvider.invokeDeleteRequest(vnf.getVnfId());
+ final Optional<DeleteVnfResponse> response = vnfmAdapterServiceProvider.invokeDeleteRequest(vnf.getVnfId());
- if (!response.isPresent()) {
- final String errorMessage = "Unexpected error while processing delete request";
- LOGGER.error(errorMessage);
- exceptionUtil.buildAndThrowWorkflowException(execution, 1211, errorMessage);
- }
+ if (!response.isPresent()) {
+ final String errorMessage = "Unexpected error while processing delete request";
+ LOGGER.error(errorMessage);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 1211, errorMessage);
+ }
- final DeleteVnfResponse vnfResponse = response.get();
+ final DeleteVnfResponse vnfResponse = response.get();
- LOGGER.debug("Vnf delete response: {}", vnfResponse);
- execution.setVariable(Constants.DELETE_VNF_RESPONSE_PARAM_NAME, vnfResponse);
+ LOGGER.debug("Vnf delete response: {}", vnfResponse);
+ execution.setVariable(Constants.DELETE_VNF_RESPONSE_PARAM_NAME, vnfResponse);
- LOGGER.debug("Finished executing invokeVnfmAdapter ...");
- } catch (final Exception exception) {
- LOGGER.error("Unable to invoke delete request", exception);
- exceptionUtil.buildAndThrowWorkflowException(execution, 1212, exception);
+ LOGGER.debug("Finished executing invokeVnfmAdapter ...");
+ } catch (final Exception exception) {
+ LOGGER.error("Unable to invoke delete request", exception);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 1212, exception);
+ }
}
- }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/InputParameterRetrieverTask.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/InputParameterRetrieverTask.java
index ebb9d521c3..661fdb258b 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/InputParameterRetrieverTask.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/InputParameterRetrieverTask.java
@@ -21,7 +21,6 @@ package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks;
import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.INPUT_PARAMETER;
import static org.onap.so.bpmn.servicedecomposition.entities.ResourceKey.GENERIC_VNF_ID;
-
import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.utils.InputParameter;
import org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.utils.InputParametersProvider;
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmCreateJobTask.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmCreateJobTask.java
index 9e0c26ba20..4645680fc2 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmCreateJobTask.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmCreateJobTask.java
@@ -39,64 +39,65 @@ import com.google.common.base.Optional;
*
*/
@Component
-public class MonitorVnfmCreateJobTask extends MonitorVnfmJobTask{
+public class MonitorVnfmCreateJobTask extends MonitorVnfmJobTask {
- private static final Logger LOGGER = LoggerFactory.getLogger(MonitorVnfmCreateJobTask.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(MonitorVnfmCreateJobTask.class);
- @Autowired
- public MonitorVnfmCreateJobTask(final VnfmAdapterServiceProvider vnfmAdapterServiceProvider,
- final ExceptionBuilder exceptionUtil) {
- super(vnfmAdapterServiceProvider, exceptionUtil);
- }
-
- /**
- * Get the current operation status of instantiation job
- *
- * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
- */
- public void getCurrentOperationStatus(final BuildingBlockExecution execution) {
- LOGGER.debug("Executing getCurrentOperationStatus ...");
- final CreateVnfResponse vnfInstantiateResponse = execution.getVariable(CREATE_VNF_RESPONSE_PARAM_NAME);
- execution.setVariable(OPERATION_STATUS_PARAM_NAME, getOperationStatus(execution, vnfInstantiateResponse.getJobId()));
- LOGGER.debug("Finished executing getCurrentOperationStatus ...");
- }
+ @Autowired
+ public MonitorVnfmCreateJobTask(final VnfmAdapterServiceProvider vnfmAdapterServiceProvider,
+ final ExceptionBuilder exceptionUtil) {
+ super(vnfmAdapterServiceProvider, exceptionUtil);
+ }
- /**
- * Log and throw exception on timeout for job status
- *
- * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
- */
- public void timeOutLogFailue(final BuildingBlockExecution execution) {
- final String message = "Instantiation operation time out";
- LOGGER.error(message);
- exceptionUtil.buildAndThrowWorkflowException(execution, 1205, message);
- }
+ /**
+ * Get the current operation status of instantiation job
+ *
+ * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
+ */
+ public void getCurrentOperationStatus(final BuildingBlockExecution execution) {
+ LOGGER.debug("Executing getCurrentOperationStatus ...");
+ final CreateVnfResponse vnfInstantiateResponse = execution.getVariable(CREATE_VNF_RESPONSE_PARAM_NAME);
+ execution.setVariable(OPERATION_STATUS_PARAM_NAME,
+ getOperationStatus(execution, vnfInstantiateResponse.getJobId()));
+ LOGGER.debug("Finished executing getCurrentOperationStatus ...");
+ }
- /**
- * Check the final status of instantiation throw exception if not completed successfully
- *
- * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
- */
- public void checkIfOperationWasSuccessful(final BuildingBlockExecution execution) {
- LOGGER.debug("Executing checkIfOperationWasSuccessful ...");
- final Optional<OperationStateEnum> operationStatusOption = execution.getVariable(OPERATION_STATUS_PARAM_NAME);
- final CreateVnfResponse vnfInstantiateResponse = execution.getVariable(CREATE_VNF_RESPONSE_PARAM_NAME);
- if (operationStatusOption == null || !operationStatusOption.isPresent()) {
- final String message = "Unable to instantiate jobId: "
- + (vnfInstantiateResponse != null ? vnfInstantiateResponse.getJobId() : "null")
- + "Unable to retrieve OperationStatus";
- LOGGER.error(message);
- exceptionUtil.buildAndThrowWorkflowException(execution, 1206, message);
- } else if (operationStatusOption != null && operationStatusOption.isPresent()) {
- final OperationStateEnum operationStatus = operationStatusOption.get();
- if (operationStatus != OperationStateEnum.COMPLETED) {
- final String message = "Unable to instantiate jobId: "
- + (vnfInstantiateResponse != null ? vnfInstantiateResponse.getJobId() : "null") + " OperationStatus: "
- + operationStatus;
+ /**
+ * Log and throw exception on timeout for job status
+ *
+ * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
+ */
+ public void timeOutLogFailue(final BuildingBlockExecution execution) {
+ final String message = "Instantiation operation time out";
LOGGER.error(message);
- exceptionUtil.buildAndThrowWorkflowException(execution, 1207, message);
- }
- LOGGER.debug("Successfully completed instatiation of job {}", vnfInstantiateResponse);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 1205, message);
+ }
+
+ /**
+ * Check the final status of instantiation throw exception if not completed successfully
+ *
+ * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
+ */
+ public void checkIfOperationWasSuccessful(final BuildingBlockExecution execution) {
+ LOGGER.debug("Executing checkIfOperationWasSuccessful ...");
+ final Optional<OperationStateEnum> operationStatusOption = execution.getVariable(OPERATION_STATUS_PARAM_NAME);
+ final CreateVnfResponse vnfInstantiateResponse = execution.getVariable(CREATE_VNF_RESPONSE_PARAM_NAME);
+ if (operationStatusOption == null || !operationStatusOption.isPresent()) {
+ final String message = "Unable to instantiate jobId: "
+ + (vnfInstantiateResponse != null ? vnfInstantiateResponse.getJobId() : "null")
+ + "Unable to retrieve OperationStatus";
+ LOGGER.error(message);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 1206, message);
+ } else if (operationStatusOption != null && operationStatusOption.isPresent()) {
+ final OperationStateEnum operationStatus = operationStatusOption.get();
+ if (operationStatus != OperationStateEnum.COMPLETED) {
+ final String message = "Unable to instantiate jobId: "
+ + (vnfInstantiateResponse != null ? vnfInstantiateResponse.getJobId() : "null")
+ + " OperationStatus: " + operationStatus;
+ LOGGER.error(message);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 1207, message);
+ }
+ LOGGER.debug("Successfully completed instatiation of job {}", vnfInstantiateResponse);
+ }
}
- }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmDeleteJobTask.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmDeleteJobTask.java
index e13d1e4dda..e91f362d53 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmDeleteJobTask.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmDeleteJobTask.java
@@ -42,61 +42,62 @@ import com.google.common.base.Optional;
@Component
public class MonitorVnfmDeleteJobTask extends MonitorVnfmJobTask {
- private static final Logger LOGGER = LoggerFactory.getLogger(MonitorVnfmDeleteJobTask.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(MonitorVnfmDeleteJobTask.class);
- @Autowired
- public MonitorVnfmDeleteJobTask(final VnfmAdapterServiceProvider vnfmAdapterServiceProvider,
- final ExceptionBuilder exceptionUtil) {
- super(vnfmAdapterServiceProvider, exceptionUtil);
- }
-
- /**
- * Get the current operation status of Delete job
- *
- * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
- */
- public void getCurrentOperationStatus(final BuildingBlockExecution execution) {
- LOGGER.debug("Executing getCurrentOperationStatus ...");
- final DeleteVnfResponse deleteVnfResponse = execution.getVariable(Constants.DELETE_VNF_RESPONSE_PARAM_NAME);
- execution.setVariable(OPERATION_STATUS_PARAM_NAME, getOperationStatus(execution, deleteVnfResponse.getJobId()));
- LOGGER.debug("Finished executing getCurrentOperationStatus ...");
- }
+ @Autowired
+ public MonitorVnfmDeleteJobTask(final VnfmAdapterServiceProvider vnfmAdapterServiceProvider,
+ final ExceptionBuilder exceptionUtil) {
+ super(vnfmAdapterServiceProvider, exceptionUtil);
+ }
- /**
- * Log and throw exception on timeout for job status
- *
- * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
- */
- public void timeOutLogFailue(final BuildingBlockExecution execution) {
- final String message = "Delete operation time out";
- LOGGER.error(message);
- exceptionUtil.buildAndThrowWorkflowException(execution, 1213, message);
- }
+ /**
+ * Get the current operation status of Delete job
+ *
+ * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
+ */
+ public void getCurrentOperationStatus(final BuildingBlockExecution execution) {
+ LOGGER.debug("Executing getCurrentOperationStatus ...");
+ final DeleteVnfResponse deleteVnfResponse = execution.getVariable(Constants.DELETE_VNF_RESPONSE_PARAM_NAME);
+ execution.setVariable(OPERATION_STATUS_PARAM_NAME, getOperationStatus(execution, deleteVnfResponse.getJobId()));
+ LOGGER.debug("Finished executing getCurrentOperationStatus ...");
+ }
- /**
- * Check the final status of delete throw exception if not completed successfully
- *
- * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
- */
- public void checkIfOperationWasSuccessful(final BuildingBlockExecution execution) {
- LOGGER.debug("Executing checkIfOperationWasSuccessful ...");
- final Optional<OperationStateEnum> operationStatusOption = execution.getVariable(OPERATION_STATUS_PARAM_NAME);
- final DeleteVnfResponse deleteVnfResponse = execution.getVariable(DELETE_VNF_RESPONSE_PARAM_NAME);
- if (operationStatusOption == null || !operationStatusOption.isPresent()) {
- final String message = "Unable to delete jobId: "
- + (deleteVnfResponse != null ? deleteVnfResponse.getJobId() : "null") + "Unable to retrieve OperationStatus";
- LOGGER.error(message);
- exceptionUtil.buildAndThrowWorkflowException(execution, 1214, message);
- } else if (operationStatusOption != null && operationStatusOption.isPresent()) {
- final OperationStateEnum operationStatus = operationStatusOption.get();
- if (operationStatus != OperationStateEnum.COMPLETED) {
- final String message =
- "Unable to Delete jobId: " + (deleteVnfResponse != null ? deleteVnfResponse.getJobId() : "null")
- + " OperationStatus: " + operationStatus;
+ /**
+ * Log and throw exception on timeout for job status
+ *
+ * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
+ */
+ public void timeOutLogFailue(final BuildingBlockExecution execution) {
+ final String message = "Delete operation time out";
LOGGER.error(message);
- exceptionUtil.buildAndThrowWorkflowException(execution, 1215, message);
- }
- LOGGER.debug("Successfully completed Deletion of job {}", deleteVnfResponse);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 1213, message);
+ }
+
+ /**
+ * Check the final status of delete throw exception if not completed successfully
+ *
+ * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
+ */
+ public void checkIfOperationWasSuccessful(final BuildingBlockExecution execution) {
+ LOGGER.debug("Executing checkIfOperationWasSuccessful ...");
+ final Optional<OperationStateEnum> operationStatusOption = execution.getVariable(OPERATION_STATUS_PARAM_NAME);
+ final DeleteVnfResponse deleteVnfResponse = execution.getVariable(DELETE_VNF_RESPONSE_PARAM_NAME);
+ if (operationStatusOption == null || !operationStatusOption.isPresent()) {
+ final String message =
+ "Unable to delete jobId: " + (deleteVnfResponse != null ? deleteVnfResponse.getJobId() : "null")
+ + "Unable to retrieve OperationStatus";
+ LOGGER.error(message);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 1214, message);
+ } else if (operationStatusOption != null && operationStatusOption.isPresent()) {
+ final OperationStateEnum operationStatus = operationStatusOption.get();
+ if (operationStatus != OperationStateEnum.COMPLETED) {
+ final String message =
+ "Unable to Delete jobId: " + (deleteVnfResponse != null ? deleteVnfResponse.getJobId() : "null")
+ + " OperationStatus: " + operationStatus;
+ LOGGER.error(message);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 1215, message);
+ }
+ LOGGER.debug("Successfully completed Deletion of job {}", deleteVnfResponse);
+ }
}
- }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmJobTask.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmJobTask.java
index e3992428cb..395018fb38 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmJobTask.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmJobTask.java
@@ -41,64 +41,65 @@ import com.google.common.base.Optional;
@Component
public class MonitorVnfmJobTask {
- private static final Logger LOGGER = LoggerFactory.getLogger(MonitorVnfmJobTask.class);
- protected final ExceptionBuilder exceptionUtil;
- protected final VnfmAdapterServiceProvider vnfmAdapterServiceProvider;
+ private static final Logger LOGGER = LoggerFactory.getLogger(MonitorVnfmJobTask.class);
+ protected final ExceptionBuilder exceptionUtil;
+ protected final VnfmAdapterServiceProvider vnfmAdapterServiceProvider;
- @Autowired
- public MonitorVnfmJobTask(final VnfmAdapterServiceProvider vnfmAdapterServiceProvider,
- final ExceptionBuilder exceptionUtil) {
- this.vnfmAdapterServiceProvider = vnfmAdapterServiceProvider;
- this.exceptionUtil = exceptionUtil;
- }
+ @Autowired
+ public MonitorVnfmJobTask(final VnfmAdapterServiceProvider vnfmAdapterServiceProvider,
+ final ExceptionBuilder exceptionUtil) {
+ this.vnfmAdapterServiceProvider = vnfmAdapterServiceProvider;
+ this.exceptionUtil = exceptionUtil;
+ }
- /**
- * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
- * @return boolean to indicate whether job has competed or not
- */
- public boolean hasOperationFinished(final BuildingBlockExecution execution) {
- LOGGER.debug("Executing hasOperationFinished ...");
+ /**
+ * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
+ * @return boolean to indicate whether job has competed or not
+ */
+ public boolean hasOperationFinished(final BuildingBlockExecution execution) {
+ LOGGER.debug("Executing hasOperationFinished ...");
- final Optional<OperationStateEnum> operationStatusOption = execution.getVariable(OPERATION_STATUS_PARAM_NAME);
- if (operationStatusOption != null && operationStatusOption.isPresent()) {
- return OPERATION_FINISHED_STATES.contains(operationStatusOption.get());
+ final Optional<OperationStateEnum> operationStatusOption = execution.getVariable(OPERATION_STATUS_PARAM_NAME);
+ if (operationStatusOption != null && operationStatusOption.isPresent()) {
+ return OPERATION_FINISHED_STATES.contains(operationStatusOption.get());
+ }
+ LOGGER.debug("OperationStatus is not present yet... ");
+ LOGGER.debug("Finished executing hasOperationFinished ...");
+ return false;
}
- LOGGER.debug("OperationStatus is not present yet... ");
- LOGGER.debug("Finished executing hasOperationFinished ...");
- return false;
- }
- /**
- * This method calls the Vnfm adapter and gets the Operation status of the job
- * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
- * @param jobId unique job id
- * @return Operation State
- */
- protected Optional<OperationStateEnum> getOperationStatus(final BuildingBlockExecution execution,
- final String jobId) {
+ /**
+ * This method calls the Vnfm adapter and gets the Operation status of the job
+ *
+ * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
+ * @param jobId unique job id
+ * @return Operation State
+ */
+ protected Optional<OperationStateEnum> getOperationStatus(final BuildingBlockExecution execution,
+ final String jobId) {
- final Optional<QueryJobResponse> instantiateOperationJobStatus =
- vnfmAdapterServiceProvider.getInstantiateOperationJobStatus(jobId);
+ final Optional<QueryJobResponse> instantiateOperationJobStatus =
+ vnfmAdapterServiceProvider.getInstantiateOperationJobStatus(jobId);
- if (instantiateOperationJobStatus.isPresent()) {
- final QueryJobResponse queryJobResponse = instantiateOperationJobStatus.get();
+ if (instantiateOperationJobStatus.isPresent()) {
+ final QueryJobResponse queryJobResponse = instantiateOperationJobStatus.get();
- if (!OPERATION_RETRIEVAL_STATES.contains(queryJobResponse.getOperationStatusRetrievalStatus())) {
- final String message =
- "Recevied invalid operation reterivel state: " + queryJobResponse.getOperationStatusRetrievalStatus();
- LOGGER.error(message);
- exceptionUtil.buildAndThrowWorkflowException(execution, 1203, message);
- }
- if (queryJobResponse.getOperationState() != null) {
- final OperationStateEnum operationStatus = queryJobResponse.getOperationState();
- LOGGER.debug("Operation {} with {} and operation retrieval status : {}", queryJobResponse.getId(),
- operationStatus, queryJobResponse.getOperationStatusRetrievalStatus());
- return Optional.of(queryJobResponse.getOperationState());
- }
+ if (!OPERATION_RETRIEVAL_STATES.contains(queryJobResponse.getOperationStatusRetrievalStatus())) {
+ final String message = "Recevied invalid operation reterivel state: "
+ + queryJobResponse.getOperationStatusRetrievalStatus();
+ LOGGER.error(message);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 1203, message);
+ }
+ if (queryJobResponse.getOperationState() != null) {
+ final OperationStateEnum operationStatus = queryJobResponse.getOperationState();
+ LOGGER.debug("Operation {} with {} and operation retrieval status : {}", queryJobResponse.getId(),
+ operationStatus, queryJobResponse.getOperationStatusRetrievalStatus());
+ return Optional.of(queryJobResponse.getOperationState());
+ }
- LOGGER.debug("Operation {} without operationStatus and operation retrieval status :{}", queryJobResponse.getId(),
- queryJobResponse.getOperationStatusRetrievalStatus());
+ LOGGER.debug("Operation {} without operationStatus and operation retrieval status :{}",
+ queryJobResponse.getId(), queryJobResponse.getOperationStatusRetrievalStatus());
+ }
+ return Optional.absent();
}
- return Optional.absent();
- }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmNodeTask.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmNodeTask.java
index 22a5d28e52..65b05e21f5 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmNodeTask.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmNodeTask.java
@@ -42,44 +42,44 @@ import org.springframework.stereotype.Component;
@Component
public class MonitorVnfmNodeTask {
- private static final Logger LOGGER = LoggerFactory.getLogger(MonitorVnfmNodeTask.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(MonitorVnfmNodeTask.class);
- private final ExtractPojosForBB extractPojosForBB;
- private final ExceptionBuilder exceptionUtil;
+ private final ExtractPojosForBB extractPojosForBB;
+ private final ExceptionBuilder exceptionUtil;
- @Autowired
- public MonitorVnfmNodeTask(final ExtractPojosForBB extractPojosForBB, final ExceptionBuilder exceptionUtil) {
- this.exceptionUtil = exceptionUtil;
- this.extractPojosForBB = extractPojosForBB;
- }
+ @Autowired
+ public MonitorVnfmNodeTask(final ExtractPojosForBB extractPojosForBB, final ExceptionBuilder exceptionUtil) {
+ this.exceptionUtil = exceptionUtil;
+ this.extractPojosForBB = extractPojosForBB;
+ }
- /**
- * Check the final status of vnf in A&AI
- *
- * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
- */
- public void getNodeStatus(final BuildingBlockExecution execution) {
- try {
- LOGGER.debug("Executing getNodeStatus ...");
- final GenericVnf vnf = extractPojosForBB.extractByKey(execution, GENERIC_VNF_ID);
- String orchestrationStatus = vnf.getOrchestrationStatus();
- LOGGER.debug("Orchestration Status in AAI {}", orchestrationStatus);
- execution.setVariable(CREATE_VNF_NODE_STATUS, VNF_CREATED.equalsIgnoreCase(orchestrationStatus));
- execution.setVariable(DELETE_VNF_NODE_STATUS, VNF_ASSIGNED.equalsIgnoreCase(orchestrationStatus));
- } catch (final Exception exception) {
- LOGGER.error("Unable to get vnf from AAI", exception);
- exceptionUtil.buildAndThrowWorkflowException(execution, 1220, exception);
+ /**
+ * Check the final status of vnf in A&AI
+ *
+ * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
+ */
+ public void getNodeStatus(final BuildingBlockExecution execution) {
+ try {
+ LOGGER.debug("Executing getNodeStatus ...");
+ final GenericVnf vnf = extractPojosForBB.extractByKey(execution, GENERIC_VNF_ID);
+ String orchestrationStatus = vnf.getOrchestrationStatus();
+ LOGGER.debug("Orchestration Status in AAI {}", orchestrationStatus);
+ execution.setVariable(CREATE_VNF_NODE_STATUS, VNF_CREATED.equalsIgnoreCase(orchestrationStatus));
+ execution.setVariable(DELETE_VNF_NODE_STATUS, VNF_ASSIGNED.equalsIgnoreCase(orchestrationStatus));
+ } catch (final Exception exception) {
+ LOGGER.error("Unable to get vnf from AAI", exception);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 1220, exception);
+ }
}
- }
- /**
- * Log and throw exception on timeout for job status
- *
- * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
- */
- public void timeOutLogFailue(final BuildingBlockExecution execution) {
- final String message = "Node operation time out";
- LOGGER.error(message);
- exceptionUtil.buildAndThrowWorkflowException(execution, 1221, message);
- }
+ /**
+ * Log and throw exception on timeout for job status
+ *
+ * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
+ */
+ public void timeOutLogFailue(final BuildingBlockExecution execution) {
+ final String message = "Node operation time out";
+ LOGGER.error(message);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 1221, message);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTask.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTask.java
index 4e15474e46..9ff2835480 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTask.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTask.java
@@ -27,7 +27,6 @@ import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.INPUT
import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.SPACE;
import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.UNDERSCORE;
import static org.onap.so.bpmn.servicedecomposition.entities.ResourceKey.GENERIC_VNF_ID;
-
import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.utils.InputParameter;
import org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.utils.NullInputParameter;
@@ -44,12 +43,10 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-
import com.google.common.base.Optional;
/**
- * This class is executed from EtsiVnfInstantiateBB building block and it sends the create request
- * to the VNFM adapter
+ * This class is executed from EtsiVnfInstantiateBB building block and it sends the create request to the VNFM adapter
*
* @author waqas.ikram@est.tech
*/
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTaskConfiguration.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTaskConfiguration.java
index 1046b6bf26..f5bae2c82a 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTaskConfiguration.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTaskConfiguration.java
@@ -21,7 +21,6 @@
package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks;
import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE;
-
import org.onap.so.configuration.rest.BasicHttpHeadersProvider;
import org.onap.so.configuration.rest.HttpHeadersProvider;
import org.onap.so.rest.service.HttpRestServiceProvider;
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProvider.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProvider.java
index 1e785074f3..d1b270bc1e 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProvider.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProvider.java
@@ -34,10 +34,10 @@ import com.google.common.base.Optional;
*/
public interface VnfmAdapterServiceProvider {
- Optional<CreateVnfResponse> invokeCreateInstantiationRequest(final String vnfId, final CreateVnfRequest request);
+ Optional<CreateVnfResponse> invokeCreateInstantiationRequest(final String vnfId, final CreateVnfRequest request);
- Optional<DeleteVnfResponse> invokeDeleteRequest(final String vnfId);
+ Optional<DeleteVnfResponse> invokeDeleteRequest(final String vnfId);
- Optional<QueryJobResponse> getInstantiateOperationJobStatus(final String jobId);
+ Optional<QueryJobResponse> getInstantiateOperationJobStatus(final String jobId);
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImpl.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImpl.java
index e8f4c08f38..f193967a32 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImpl.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImpl.java
@@ -41,111 +41,111 @@ import com.google.common.base.Optional;
@Service
public class VnfmAdapterServiceProviderImpl implements VnfmAdapterServiceProvider {
- private static final Logger LOGGER = LoggerFactory.getLogger(VnfmAdapterServiceProviderImpl.class);
-
- private final VnfmAdapterUrlProvider urlProvider;
- private final HttpRestServiceProvider httpServiceProvider;
-
- @Autowired
- public VnfmAdapterServiceProviderImpl(final VnfmAdapterUrlProvider urlProvider,
- final HttpRestServiceProvider httpServiceProvider) {
- this.urlProvider = urlProvider;
- this.httpServiceProvider = httpServiceProvider;
- }
-
- @Override
- public Optional<CreateVnfResponse> invokeCreateInstantiationRequest(final String vnfId,
- final CreateVnfRequest request) {
- try {
- final String url = urlProvider.getCreateInstantiateUrl(vnfId);
-
- final ResponseEntity<CreateVnfResponse> response =
- httpServiceProvider.postHttpRequest(request, url, CreateVnfResponse.class);
-
- final HttpStatus httpStatus = response.getStatusCode();
- if (!(httpStatus.equals(HttpStatus.ACCEPTED)) && !(httpStatus.equals(HttpStatus.OK))) {
- LOGGER.error("Unable to invoke HTTP POST using URL: {}, Response Code: {}", url, httpStatus.value());
- return Optional.absent();
- }
-
- if (!response.hasBody()) {
- LOGGER.error("Received response without body: {}", response);
- return Optional.absent();
- }
-
- final CreateVnfResponse createVnfResponse = response.getBody();
-
- if (createVnfResponse.getJobId() == null || createVnfResponse.getJobId().isEmpty()) {
- LOGGER.error("Received invalid instantiation response: {}", response);
- return Optional.absent();
- }
-
- return Optional.of(createVnfResponse);
- } catch (final RestProcessingException | InvalidRestRequestException httpInvocationException) {
- LOGGER.error("Unexpected error while processing create and instantiation request", httpInvocationException);
- return Optional.absent();
+ private static final Logger LOGGER = LoggerFactory.getLogger(VnfmAdapterServiceProviderImpl.class);
+
+ private final VnfmAdapterUrlProvider urlProvider;
+ private final HttpRestServiceProvider httpServiceProvider;
+
+ @Autowired
+ public VnfmAdapterServiceProviderImpl(final VnfmAdapterUrlProvider urlProvider,
+ final HttpRestServiceProvider httpServiceProvider) {
+ this.urlProvider = urlProvider;
+ this.httpServiceProvider = httpServiceProvider;
}
- }
+ @Override
+ public Optional<CreateVnfResponse> invokeCreateInstantiationRequest(final String vnfId,
+ final CreateVnfRequest request) {
+ try {
+ final String url = urlProvider.getCreateInstantiateUrl(vnfId);
- @Override
- public Optional<DeleteVnfResponse> invokeDeleteRequest(final String vnfId) {
- try {
- final String url = urlProvider.getDeleteUrl(vnfId);
- LOGGER.debug("Will send request to vnfm adapter using url: {}", url);
+ final ResponseEntity<CreateVnfResponse> response =
+ httpServiceProvider.postHttpRequest(request, url, CreateVnfResponse.class);
- final ResponseEntity<DeleteVnfResponse> response =
- httpServiceProvider.deleteHttpRequest(url, DeleteVnfResponse.class);
+ final HttpStatus httpStatus = response.getStatusCode();
+ if (!(httpStatus.equals(HttpStatus.ACCEPTED)) && !(httpStatus.equals(HttpStatus.OK))) {
+ LOGGER.error("Unable to invoke HTTP POST using URL: {}, Response Code: {}", url, httpStatus.value());
+ return Optional.absent();
+ }
- LOGGER.debug("Response received: ", response);
+ if (!response.hasBody()) {
+ LOGGER.error("Received response without body: {}", response);
+ return Optional.absent();
+ }
- final HttpStatus httpStatus = response.getStatusCode();
+ final CreateVnfResponse createVnfResponse = response.getBody();
- if (!(httpStatus.equals(HttpStatus.ACCEPTED)) && !(httpStatus.equals(HttpStatus.OK))) {
- LOGGER.error("Unable to invoke HTTP DELETE using URL: {}, Response Code: {}", url, httpStatus.value());
- return Optional.absent();
- }
+ if (createVnfResponse.getJobId() == null || createVnfResponse.getJobId().isEmpty()) {
+ LOGGER.error("Received invalid instantiation response: {}", response);
+ return Optional.absent();
+ }
- if (!response.hasBody()) {
- LOGGER.error("Received response without body: {}", response);
- return Optional.absent();
- }
- final DeleteVnfResponse deleteVnfResponse = response.getBody();
+ return Optional.of(createVnfResponse);
+ } catch (final RestProcessingException | InvalidRestRequestException httpInvocationException) {
+ LOGGER.error("Unexpected error while processing create and instantiation request", httpInvocationException);
+ return Optional.absent();
+ }
- if (deleteVnfResponse.getJobId() == null || deleteVnfResponse.getJobId().isEmpty()) {
- LOGGER.error("Received invalid delete response: {}", response);
- return Optional.absent();
- }
- return Optional.of(deleteVnfResponse);
- } catch (final RestProcessingException | InvalidRestRequestException httpInvocationException) {
- LOGGER.error("Unexpected error while processing delete request", httpInvocationException);
- return Optional.absent();
}
- }
-
- @Override
- public Optional<QueryJobResponse> getInstantiateOperationJobStatus(final String jobId) {
- try {
- final String url = urlProvider.getJobStatusUrl(jobId);
-
- final ResponseEntity<QueryJobResponse> response =
- httpServiceProvider.getHttpResponse(url, QueryJobResponse.class);
-
- final HttpStatus httpStatus = response.getStatusCode();
-
- if (!(httpStatus.equals(HttpStatus.ACCEPTED)) && !(httpStatus.equals(HttpStatus.OK))) {
- LOGGER.error("Unable to invoke HTTP GET using URL: {}, Response Code: ", url, httpStatus.value());
- return Optional.absent();
- }
-
- if (!response.hasBody()) {
- LOGGER.error("Received response without body: {}", response);
- return Optional.absent();
- }
- return Optional.of(response.getBody());
- } catch (final RestProcessingException | InvalidRestRequestException httpInvocationException) {
- LOGGER.error("Unexpected error while processing job request", httpInvocationException);
- return Optional.absent();
+
+ @Override
+ public Optional<DeleteVnfResponse> invokeDeleteRequest(final String vnfId) {
+ try {
+ final String url = urlProvider.getDeleteUrl(vnfId);
+ LOGGER.debug("Will send request to vnfm adapter using url: {}", url);
+
+ final ResponseEntity<DeleteVnfResponse> response =
+ httpServiceProvider.deleteHttpRequest(url, DeleteVnfResponse.class);
+
+ LOGGER.debug("Response received: ", response);
+
+ final HttpStatus httpStatus = response.getStatusCode();
+
+ if (!(httpStatus.equals(HttpStatus.ACCEPTED)) && !(httpStatus.equals(HttpStatus.OK))) {
+ LOGGER.error("Unable to invoke HTTP DELETE using URL: {}, Response Code: {}", url, httpStatus.value());
+ return Optional.absent();
+ }
+
+ if (!response.hasBody()) {
+ LOGGER.error("Received response without body: {}", response);
+ return Optional.absent();
+ }
+ final DeleteVnfResponse deleteVnfResponse = response.getBody();
+
+ if (deleteVnfResponse.getJobId() == null || deleteVnfResponse.getJobId().isEmpty()) {
+ LOGGER.error("Received invalid delete response: {}", response);
+ return Optional.absent();
+ }
+ return Optional.of(deleteVnfResponse);
+ } catch (final RestProcessingException | InvalidRestRequestException httpInvocationException) {
+ LOGGER.error("Unexpected error while processing delete request", httpInvocationException);
+ return Optional.absent();
+ }
+ }
+
+ @Override
+ public Optional<QueryJobResponse> getInstantiateOperationJobStatus(final String jobId) {
+ try {
+ final String url = urlProvider.getJobStatusUrl(jobId);
+
+ final ResponseEntity<QueryJobResponse> response =
+ httpServiceProvider.getHttpResponse(url, QueryJobResponse.class);
+
+ final HttpStatus httpStatus = response.getStatusCode();
+
+ if (!(httpStatus.equals(HttpStatus.ACCEPTED)) && !(httpStatus.equals(HttpStatus.OK))) {
+ LOGGER.error("Unable to invoke HTTP GET using URL: {}, Response Code: ", url, httpStatus.value());
+ return Optional.absent();
+ }
+
+ if (!response.hasBody()) {
+ LOGGER.error("Received response without body: {}", response);
+ return Optional.absent();
+ }
+ return Optional.of(response.getBody());
+ } catch (final RestProcessingException | InvalidRestRequestException httpInvocationException) {
+ LOGGER.error("Unexpected error while processing job request", httpInvocationException);
+ return Optional.absent();
+ }
}
- }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterUrlProvider.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterUrlProvider.java
index 97a7197373..cacba5c5fd 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterUrlProvider.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterUrlProvider.java
@@ -35,34 +35,32 @@ import org.springframework.web.util.UriComponentsBuilder;
@Service
public class VnfmAdapterUrlProvider {
- private final URI baseUri;
+ private final URI baseUri;
- @Autowired
- public VnfmAdapterUrlProvider(final VnfmBasicHttpConfigProvider etsiVnfmAdapter) {
- this.baseUri = UriComponentsBuilder.fromHttpUrl(etsiVnfmAdapter.getUrl()).build().toUri();
- }
+ @Autowired
+ public VnfmAdapterUrlProvider(final VnfmBasicHttpConfigProvider etsiVnfmAdapter) {
+ this.baseUri = UriComponentsBuilder.fromHttpUrl(etsiVnfmAdapter.getUrl()).build().toUri();
+ }
- /**
- * Get VNFM create and instantiate URL
- *
- * @param vnfId The identifier of the VNF. This must be the vnf-id of an existing generic-vnf in
- * AAI.
- * @return VNFM create and instantiate URL
- */
- public String getCreateInstantiateUrl(final String vnfId) {
- return UriComponentsBuilder.fromUri(baseUri).pathSegment("vnfs").pathSegment(vnfId).build().toString();
- }
+ /**
+ * Get VNFM create and instantiate URL
+ *
+ * @param vnfId The identifier of the VNF. This must be the vnf-id of an existing generic-vnf in AAI.
+ * @return VNFM create and instantiate URL
+ */
+ public String getCreateInstantiateUrl(final String vnfId) {
+ return UriComponentsBuilder.fromUri(baseUri).pathSegment("vnfs").pathSegment(vnfId).build().toString();
+ }
- /**
- * Get VNFM delete URL
- *
- * @param vnfId The identifier of the VNF. This must be the vnf-id of an existing generic-vnf in
- * AAI.
- * @return VNFM delete URL
- */
- public String getDeleteUrl(final String vnfId) {
- return UriComponentsBuilder.fromUri(baseUri).pathSegment("vnfs").pathSegment(vnfId).build().toString();
- }
+ /**
+ * Get VNFM delete URL
+ *
+ * @param vnfId The identifier of the VNF. This must be the vnf-id of an existing generic-vnf in AAI.
+ * @return VNFM delete URL
+ */
+ public String getDeleteUrl(final String vnfId) {
+ return UriComponentsBuilder.fromUri(baseUri).pathSegment("vnfs").pathSegment(vnfId).build().toString();
+ }
/**
* Get job status URL
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmBasicHttpConfigProvider.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmBasicHttpConfigProvider.java
index c9b1ad1ce1..8bb5302ce9 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmBasicHttpConfigProvider.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmBasicHttpConfigProvider.java
@@ -22,7 +22,6 @@ package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks;
import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.VNFM_ADAPTER_DEFAULT_AUTH;
import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.VNFM_ADAPTER_DEFAULT_URL;
-
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParameter.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParameter.java
index 5ade3240a0..d01d494c58 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParameter.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParameter.java
@@ -24,7 +24,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
import org.onap.vnfmadapter.v1.model.ExternalVirtualLink;
/**
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParametersProviderImpl.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParametersProviderImpl.java
index 6027e78d8b..bf4f16b355 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParametersProviderImpl.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParametersProviderImpl.java
@@ -21,14 +21,12 @@ package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.utils;
import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.FORWARD_SLASH;
import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.PRELOAD_VNFS_URL;
-
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
-
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf;
import org.onap.so.client.sdnc.SDNCClient;
@@ -37,12 +35,10 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
-
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.jayway.jsonpath.JsonPath;
-
import net.minidev.json.JSONArray;
/**
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/VnfParameter.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/VnfParameter.java
index 11e93e733d..0d45dad6fe 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/VnfParameter.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/VnfParameter.java
@@ -20,7 +20,6 @@
package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.utils;
import java.util.Objects;
-
import com.fasterxml.jackson.annotation.JsonProperty;
/**
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java
index 75c66345a0..ef882b4694 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java
@@ -46,139 +46,138 @@ import org.springframework.stereotype.Component;
@Component
public class AppcRunTasks {
- private static final Logger logger = LoggerFactory.getLogger(AppcRunTasks.class);
- @Autowired
- private ExceptionBuilder exceptionUtil;
- @Autowired
- private ExtractPojosForBB extractPojosForBB;
- @Autowired
- private CatalogDbClient catalogDbClient;
- @Autowired
- private ApplicationControllerAction appCClient;
-
- public void preProcessActivity(BuildingBlockExecution execution) {
- execution.setVariable("actionSnapshot", Action.Snapshot);
- execution.setVariable("actionLock", Action.Lock);
- execution.setVariable("actionUnlock", Action.Unlock);
- execution.setVariable("actionUpgradePreCheck", Action.UpgradePreCheck);
- execution.setVariable("actionUpgradePostCheck", Action.UpgradePostCheck);
- execution.setVariable("actionQuiesceTraffic", Action.QuiesceTraffic);
- execution.setVariable("actionUpgradeBackup", Action.UpgradeBackup);
- execution.setVariable("actionUpgradeSoftware", Action.UpgradeSoftware);
- execution.setVariable("actionResumeTraffic", Action.ResumeTraffic);
- execution.setVariable("actionStop", Action.Stop);
- execution.setVariable("actionStart", Action.Start);
- execution.setVariable("actionHealthCheck", Action.HealthCheck);
- execution.setVariable("actionDistributeTraffic", Action.DistributeTraffic);
- execution.setVariable("actionDistributeTrafficCheck", Action.DistributeTrafficCheck);
- execution.setVariable("rollbackVnfStop", false);
- execution.setVariable("rollbackVnfLock", false);
- execution.setVariable("rollbackQuiesceTraffic", false);
- }
-
- public void runAppcCommand(BuildingBlockExecution execution, Action action) {
- logger.trace("Start runAppcCommand ");
- String appcCode = "1002";
- String appcMessage = "";
- try {
- GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
- GenericVnf vnf = null;
- try {
- vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- } catch (BBObjectNotFoundException e) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "No valid VNF exists");
- }
- String vnfId = null;
- String vnfName = null;
- String vnfType = null;
- String vnfHostIpAddress = null;
+ private static final Logger logger = LoggerFactory.getLogger(AppcRunTasks.class);
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+ @Autowired
+ private ExtractPojosForBB extractPojosForBB;
+ @Autowired
+ private CatalogDbClient catalogDbClient;
+ @Autowired
+ private ApplicationControllerAction appCClient;
- if (vnf != null) {
- vnfId = vnf.getVnfId();
- vnfName = vnf.getVnfName();
- vnfType = vnf.getVnfType();
- vnfHostIpAddress = vnf.getIpv4OamAddress();
+ public void preProcessActivity(BuildingBlockExecution execution) {
+ execution.setVariable("actionSnapshot", Action.Snapshot);
+ execution.setVariable("actionLock", Action.Lock);
+ execution.setVariable("actionUnlock", Action.Unlock);
+ execution.setVariable("actionUpgradePreCheck", Action.UpgradePreCheck);
+ execution.setVariable("actionUpgradePostCheck", Action.UpgradePostCheck);
+ execution.setVariable("actionQuiesceTraffic", Action.QuiesceTraffic);
+ execution.setVariable("actionUpgradeBackup", Action.UpgradeBackup);
+ execution.setVariable("actionUpgradeSoftware", Action.UpgradeSoftware);
+ execution.setVariable("actionResumeTraffic", Action.ResumeTraffic);
+ execution.setVariable("actionStop", Action.Stop);
+ execution.setVariable("actionStart", Action.Start);
+ execution.setVariable("actionHealthCheck", Action.HealthCheck);
+ execution.setVariable("actionDistributeTraffic", Action.DistributeTraffic);
+ execution.setVariable("actionDistributeTrafficCheck", Action.DistributeTrafficCheck);
+ execution.setVariable("rollbackVnfStop", false);
+ execution.setVariable("rollbackVnfLock", false);
+ execution.setVariable("rollbackQuiesceTraffic", false);
+ }
+
+ public void runAppcCommand(BuildingBlockExecution execution, Action action) {
+ logger.trace("Start runAppcCommand ");
+ String appcCode = "1002";
+ String appcMessage = "";
+ try {
+ GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+ GenericVnf vnf = null;
+ try {
+ vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ } catch (BBObjectNotFoundException e) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "No valid VNF exists");
+ }
+ String vnfId = null;
+ String vnfName = null;
+ String vnfType = null;
+ String vnfHostIpAddress = null;
+
+ if (vnf != null) {
+ vnfId = vnf.getVnfId();
+ vnfName = vnf.getVnfName();
+ vnfType = vnf.getVnfType();
+ vnfHostIpAddress = vnf.getIpv4OamAddress();
+ }
+ String msoRequestId = gBBInput.getRequestContext().getMsoRequestId();
+
+ String aicIdentity = execution.getVariable("aicIdentity");
+ String vmIdList = execution.getVariable("vmIdList");
+ String vserverIdList = execution.getVariable("vserverIdList");
+ String identityUrl = execution.getVariable("identityUrl");
+
+ ControllerSelectionReference controllerSelectionReference = catalogDbClient
+ .getControllerSelectionReferenceByVnfTypeAndActionCategory(vnfType, action.toString());
+ String controllerType = controllerSelectionReference.getControllerName();
+
+ String vfModuleId = null;
+ VfModule vfModule = null;
+ try {
+ vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
+ } catch (BBObjectNotFoundException e) {
+ }
+ if (vfModule != null) {
+ vfModuleId = vfModule.getVfModuleId();
+ }
+
+ HashMap<String, String> payloadInfo = buildPayloadInfo(vnfName, aicIdentity, vnfHostIpAddress, vmIdList,
+ vserverIdList, identityUrl, vfModuleId);
+ Optional<String> payload = null;
+ RequestParameters requestParameters = gBBInput.getRequestContext().getRequestParameters();
+ if (requestParameters != null) {
+ String pay = requestParameters.getPayload();
+ if (pay != null) {
+ payload = Optional.of(pay);
+ }
+ }
+ logger.debug("Running APP-C action: {}", action.toString());
+ logger.debug("VNFID: {}", vnfId);
+ appCClient.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType);
+ appcCode = appCClient.getErrorCode();
+ appcMessage = appCClient.getErrorMessage();
+ mapRollbackVariables(execution, action, appcCode);
+ } catch (Exception e) {
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(),
+ "Caught exception in runAppcCommand", "BPMN", ErrorCode.UnknownError.getValue(), "APPC Error", e);
+ appcMessage = e.getMessage();
+ }
+
+ logger.error("Error Message: {}", appcMessage);
+ logger.error("ERROR CODE: {}", appcCode);
+ logger.trace("End of runAppCommand ");
+ if (appcCode != null && !appcCode.equals("0")) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(appcCode), appcMessage);
+ }
+ }
+
+ protected void mapRollbackVariables(BuildingBlockExecution execution, Action action, String appcCode) {
+ if (appcCode.equals("0") && action != null) {
+ if (action.equals(Action.Lock)) {
+ execution.setVariable("rollbackVnfLock", true);
+ } else if (action.equals(Action.Unlock)) {
+ execution.setVariable("rollbackVnfLock", false);
+ } else if (action.equals(Action.Start)) {
+ execution.setVariable("rollbackVnfStop", false);
+ } else if (action.equals(Action.Stop)) {
+ execution.setVariable("rollbackVnfStop", true);
+ } else if (action.equals(Action.QuiesceTraffic)) {
+ execution.setVariable("rollbackQuiesceTraffic", true);
+ } else if (action.equals(Action.ResumeTraffic)) {
+ execution.setVariable("rollbackQuiesceTraffic", false);
+ }
}
- String msoRequestId = gBBInput.getRequestContext().getMsoRequestId();
+ }
- String aicIdentity = execution.getVariable("aicIdentity");
- String vmIdList = execution.getVariable("vmIdList");
- String vserverIdList = execution.getVariable("vserverIdList");
- String identityUrl = execution.getVariable("identityUrl");
-
- ControllerSelectionReference controllerSelectionReference = catalogDbClient.getControllerSelectionReferenceByVnfTypeAndActionCategory(vnfType, action.toString());
- String controllerType = controllerSelectionReference.getControllerName();
-
- String vfModuleId = null;
- VfModule vfModule = null;
- try {
- vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
- } catch (BBObjectNotFoundException e) {
- }
- if (vfModule != null) {
- vfModuleId = vfModule.getVfModuleId();
- }
-
- HashMap<String, String> payloadInfo = buildPayloadInfo(vnfName, aicIdentity, vnfHostIpAddress, vmIdList, vserverIdList,
- identityUrl, vfModuleId);
- Optional<String> payload = null;
- RequestParameters requestParameters = gBBInput.getRequestContext().getRequestParameters();
- if(requestParameters != null){
- String pay = requestParameters.getPayload();
- if (pay != null) {
- payload = Optional.of(pay);
- }
- }
- logger.debug("Running APP-C action: {}", action.toString());
- logger.debug("VNFID: {}", vnfId);
- appCClient.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType);
- appcCode = appCClient.getErrorCode();
- appcMessage = appCClient.getErrorMessage();
- mapRollbackVariables(execution, action, appcCode);
- }
- catch (Exception e) {
- logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(),
- "Caught exception in runAppcCommand", "BPMN",
- ErrorCode.UnknownError.getValue(), "APPC Error", e);
- appcMessage = e.getMessage();
- }
-
- logger.error("Error Message: {}", appcMessage);
- logger.error("ERROR CODE: {}", appcCode);
- logger.trace("End of runAppCommand ");
- if (appcCode != null && !appcCode.equals("0")) {
- exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(appcCode), appcMessage);
- }
- }
-
- protected void mapRollbackVariables(BuildingBlockExecution execution, Action action, String appcCode) {
- if (appcCode.equals("0") && action != null) {
- if (action.equals(Action.Lock)) {
- execution.setVariable("rollbackVnfLock", true);
- } else if (action.equals(Action.Unlock)) {
- execution.setVariable("rollbackVnfLock", false);
- } else if (action.equals(Action.Start)) {
- execution.setVariable("rollbackVnfStop", false);
- } else if (action.equals(Action.Stop)) {
- execution.setVariable("rollbackVnfStop", true);
- } else if (action.equals(Action.QuiesceTraffic)) {
- execution.setVariable("rollbackQuiesceTraffic", true);
- } else if (action.equals(Action.ResumeTraffic)) {
- execution.setVariable("rollbackQuiesceTraffic", false);
- }
- }
- }
-
- private HashMap<String,String> buildPayloadInfo(String vnfName, String aicIdentity, String vnfHostIpAddress,
- String vmIdList, String vserverIdList, String identityUrl, String vfModuleId) {
- HashMap<String, String> payloadInfo = new HashMap<String, String>();
- payloadInfo.put("vnfName", vnfName);
- payloadInfo.put("aicIdentity", aicIdentity);
- payloadInfo.put("vnfHostIpAddress", vnfHostIpAddress);
- payloadInfo.put("vmIdList", vmIdList);
- payloadInfo.put("vserverIdList", vserverIdList);
- payloadInfo.put("identityUrl", identityUrl);
- payloadInfo.put("vfModuleId",vfModuleId);
- return payloadInfo;
- }
+ private HashMap<String, String> buildPayloadInfo(String vnfName, String aicIdentity, String vnfHostIpAddress,
+ String vmIdList, String vserverIdList, String identityUrl, String vfModuleId) {
+ HashMap<String, String> payloadInfo = new HashMap<String, String>();
+ payloadInfo.put("vnfName", vnfName);
+ payloadInfo.put("aicIdentity", aicIdentity);
+ payloadInfo.put("vnfHostIpAddress", vnfHostIpAddress);
+ payloadInfo.put("vmIdList", vmIdList);
+ payloadInfo.put("vserverIdList", vserverIdList);
+ payloadInfo.put("identityUrl", identityUrl);
+ payloadInfo.put("vfModuleId", vfModuleId);
+ return payloadInfo;
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/audit/AuditTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/audit/AuditTasks.java
index f6e07c8303..a223259d4d 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/audit/AuditTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/audit/AuditTasks.java
@@ -39,45 +39,46 @@ import org.springframework.stereotype.Component;
@Component
public class AuditTasks {
- private static final Logger logger = LoggerFactory.getLogger(AuditTasks.class);
+ private static final Logger logger = LoggerFactory.getLogger(AuditTasks.class);
- @Autowired
- private ExceptionBuilder exceptionUtil;
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
- @Autowired
- private ExtractPojosForBB extractPojosForBB;
+ @Autowired
+ private ExtractPojosForBB extractPojosForBB;
- @Autowired
- private Environment env;
+ @Autowired
+ private Environment env;
- public void isAuditNeeded(BuildingBlockExecution execution) {
- try {
- logger.debug("auditInventoryNeeded Value: {}", env.getProperty("mso.infra.auditInventory"));
- execution.setVariable("auditInventoryNeeded", Boolean.parseBoolean(env.getProperty("mso.infra.auditInventory")));
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
+ public void isAuditNeeded(BuildingBlockExecution execution) {
+ try {
+ logger.debug("auditInventoryNeeded Value: {}", env.getProperty("mso.infra.auditInventory"));
+ execution.setVariable("auditInventoryNeeded",
+ Boolean.parseBoolean(env.getProperty("mso.infra.auditInventory")));
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
- public void setupAuditVariable(BuildingBlockExecution execution) {
- try {
- execution.setVariable("auditInventory",createAuditInventory(execution));
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
+ public void setupAuditVariable(BuildingBlockExecution execution) {
+ try {
+ execution.setVariable("auditInventory", createAuditInventory(execution));
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
- private AuditInventory createAuditInventory(BuildingBlockExecution execution) throws BBObjectNotFoundException {
- AuditInventory auditInventory = new AuditInventory();
+ private AuditInventory createAuditInventory(BuildingBlockExecution execution) throws BBObjectNotFoundException {
+ AuditInventory auditInventory = new AuditInventory();
- GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
- VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
- CloudRegion cloudRegion = gBBInput.getCloudRegion();
+ GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+ VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
+ CloudRegion cloudRegion = gBBInput.getCloudRegion();
- auditInventory.setCloudOwner(cloudRegion.getCloudOwner());
- auditInventory.setCloudRegion(cloudRegion.getLcpCloudRegionId());
- auditInventory.setTenantId(cloudRegion.getTenantId());
- auditInventory.setHeatStackName(vfModule.getVfModuleName());
- return auditInventory;
- }
+ auditInventory.setCloudOwner(cloudRegion.getCloudOwner());
+ auditInventory.setCloudRegion(cloudRegion.getLcpCloudRegionId());
+ auditInventory.setTenantId(cloudRegion.getTenantId());
+ auditInventory.setHeatStackName(vfModule.getVfModuleName());
+ return auditInventory;
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ActivateVfModule.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ActivateVfModule.java
index f2fb37e182..9ed77d47ea 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ActivateVfModule.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ActivateVfModule.java
@@ -32,24 +32,24 @@ import org.springframework.stereotype.Component;
public class ActivateVfModule {
private static final Logger logger = LoggerFactory.getLogger(ActivateVfModule.class);
-
- protected static final String VF_MODULE_TIMER_DURATION_PATH = "mso.workflow.vfModuleActivate.timer.duration";
- protected static final String DEFAULT_TIMER_DURATION = "PT180S";
-
- @Autowired
- private ExceptionBuilder exceptionUtil;
-
- @Autowired
+
+ protected static final String VF_MODULE_TIMER_DURATION_PATH = "mso.workflow.vfModuleActivate.timer.duration";
+ protected static final String DEFAULT_TIMER_DURATION = "PT180S";
+
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+
+ @Autowired
private Environment environment;
- public void setTimerDuration(BuildingBlockExecution execution) {
- try {
- String waitDuration = this.environment.getProperty(VF_MODULE_TIMER_DURATION_PATH, DEFAULT_TIMER_DURATION);
- logger.debug("Sleeping before proceeding with SDNC activate. Timer duration: {}", waitDuration);
- execution.setVariable("vfModuleActivateTimerDuration", waitDuration);
- } catch (Exception e) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, e);
- }
- }
+ public void setTimerDuration(BuildingBlockExecution execution) {
+ try {
+ String waitDuration = this.environment.getProperty(VF_MODULE_TIMER_DURATION_PATH, DEFAULT_TIMER_DURATION);
+ logger.debug("Sleeping before proceeding with SDNC activate. Timer duration: {}", waitDuration);
+ execution.setVariable("vfModuleActivateTimerDuration", waitDuration);
+ } catch (Exception e) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, e);
+ }
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetwork.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetwork.java
index c3106d6e49..164480d7c7 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetwork.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetwork.java
@@ -34,28 +34,29 @@ import org.springframework.stereotype.Component;
@Component
public class AssignNetwork {
- private static final Logger logger = LoggerFactory.getLogger(AssignNetwork.class);
+ private static final Logger logger = LoggerFactory.getLogger(AssignNetwork.class);
- @Autowired
- private ExtractPojosForBB extractPojosForBB;
-
- /**
- * Check if network was found by name
- * @param execution
- * @return
- */
- public boolean networkFoundByName(BuildingBlockExecution execution) {
- boolean networkFound = false;
- try {
- L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
+ @Autowired
+ private ExtractPojosForBB extractPojosForBB;
- if (!OrchestrationStatus.PRECREATED.equals(l3network.getOrchestrationStatus())){
- networkFound = true;
- logger.debug("network found in NOT PRECREATED status");
- }
- } catch (Exception ex) {
- // return false if no network present
- }
- return networkFound;
- }
+ /**
+ * Check if network was found by name
+ *
+ * @param execution
+ * @return
+ */
+ public boolean networkFoundByName(BuildingBlockExecution execution) {
+ boolean networkFound = false;
+ try {
+ L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
+
+ if (!OrchestrationStatus.PRECREATED.equals(l3network.getOrchestrationStatus())) {
+ networkFound = true;
+ logger.debug("network found in NOT PRECREATED status");
+ }
+ } catch (Exception ex) {
+ // return false if no network present
+ }
+ return networkFound;
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetworkBBUtils.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetworkBBUtils.java
index df3f5465e6..ab8818f682 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetworkBBUtils.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetworkBBUtils.java
@@ -37,65 +37,69 @@ import org.springframework.stereotype.Component;
@Component
public class AssignNetworkBBUtils {
- private static final Logger logger = LoggerFactory.getLogger(AssignNetworkBBUtils.class);
- @Autowired
- private ExceptionBuilder exceptionUtil;
- @Autowired
- private AAINetworkResources aaiNetworkResources;
- @Autowired
- private SDNCNetworkResources sdncNetworkResources;
- @Autowired
- private ExtractPojosForBB extractPojosForBB;
+ private static final Logger logger = LoggerFactory.getLogger(AssignNetworkBBUtils.class);
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+ @Autowired
+ private AAINetworkResources aaiNetworkResources;
+ @Autowired
+ private SDNCNetworkResources sdncNetworkResources;
+ @Autowired
+ private ExtractPojosForBB extractPojosForBB;
- /**
- * BPMN access method. Verify if network name was provided as input to BB
- * @param execution
- * @return
- */
- public boolean networkFoundByName(BuildingBlockExecution execution) throws Exception {
- boolean found = false;
- //TODO - populate logic after iTrack MSO-2143 implemented
- return found;
- }
-
- /**
- * BPMN access method to extract Cloud Region data
- * @param execution
- * @throws Exception
- */
- public void getCloudRegion(BuildingBlockExecution execution) {
- try{
- GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
- CloudRegion cloudRegion = gBBInput.getCloudRegion();
- String cloudRegionSdnc;
- String cloudRegionPo = cloudRegion.getLcpCloudRegionId();
- if (cloudRegion.getCloudRegionVersion().equalsIgnoreCase("2.5")){
- cloudRegionSdnc = "AAIAIC25";
- } else {
- cloudRegionSdnc = cloudRegionPo;
- }
- execution.setVariable("cloudRegionPo", cloudRegionPo);
- execution.setVariable("cloudRegionSdnc", cloudRegionSdnc);
- }catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- /**
- * BPMN access method. Process silent success scenario
- * @param execution
- */
- public void processSilentSuccess(BuildingBlockExecution execution) {
- String msg = "Silent success processing network assign";
- logger.info(msg);
- }
-
- /**
- * BPMN access method. Process silent success scenario
- * @param execution
- */
- public void failOrchestrationStatus(BuildingBlockExecution execution) {
- BpmnError error = new BpmnError("Failed orchestration status verificaiton");
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, error);
- }
+ /**
+ * BPMN access method. Verify if network name was provided as input to BB
+ *
+ * @param execution
+ * @return
+ */
+ public boolean networkFoundByName(BuildingBlockExecution execution) throws Exception {
+ boolean found = false;
+ // TODO - populate logic after iTrack MSO-2143 implemented
+ return found;
+ }
+
+ /**
+ * BPMN access method to extract Cloud Region data
+ *
+ * @param execution
+ * @throws Exception
+ */
+ public void getCloudRegion(BuildingBlockExecution execution) {
+ try {
+ GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+ CloudRegion cloudRegion = gBBInput.getCloudRegion();
+ String cloudRegionSdnc;
+ String cloudRegionPo = cloudRegion.getLcpCloudRegionId();
+ if (cloudRegion.getCloudRegionVersion().equalsIgnoreCase("2.5")) {
+ cloudRegionSdnc = "AAIAIC25";
+ } else {
+ cloudRegionSdnc = cloudRegionPo;
+ }
+ execution.setVariable("cloudRegionPo", cloudRegionPo);
+ execution.setVariable("cloudRegionSdnc", cloudRegionSdnc);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ /**
+ * BPMN access method. Process silent success scenario
+ *
+ * @param execution
+ */
+ public void processSilentSuccess(BuildingBlockExecution execution) {
+ String msg = "Silent success processing network assign";
+ logger.info(msg);
+ }
+
+ /**
+ * BPMN access method. Process silent success scenario
+ *
+ * @param execution
+ */
+ public void failOrchestrationStatus(BuildingBlockExecution execution) {
+ BpmnError error = new BpmnError("Failed orchestration status verificaiton");
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, error);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignVnf.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignVnf.java
index 0aa3142996..1b06fe114f 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignVnf.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignVnf.java
@@ -21,7 +21,6 @@
package org.onap.so.bpmn.infrastructure.flowspecific.tasks;
import java.util.List;
-
import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.infrastructure.common.name.generation.AAIObjectInstanceNameGenerator;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
@@ -37,35 +36,36 @@ import org.springframework.stereotype.Component;
@Component
public class AssignVnf {
-
- @Autowired
- private ExceptionBuilder exceptionUtil;
- @Autowired
- private ExtractPojosForBB extractPojosForBB;
- @Autowired
- private AAIInstanceGroupResources aaiInstanceGroupResources;
- @Autowired
- private AAIObjectInstanceNameGenerator aaiObjectInstanceNameGenerator;
-
-
- public void createInstanceGroups(BuildingBlockExecution execution) {
- try {
- GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- List<InstanceGroup> instanceGroups = vnf.getInstanceGroups();
- for(InstanceGroup instanceGroup : instanceGroups) {
- if(ModelInfoInstanceGroup.TYPE_VNFC.equalsIgnoreCase(instanceGroup.getModelInfoInstanceGroup().getType())) {
- instanceGroup.setInstanceGroupName(aaiObjectInstanceNameGenerator.generateInstanceGroupName(instanceGroup, vnf));
- aaiInstanceGroupResources.createInstanceGroup(instanceGroup);
- aaiInstanceGroupResources.connectInstanceGroupToVnf(instanceGroup, vnf, AAIEdgeLabel.BELONGS_TO);
- }
- else if(ModelInfoInstanceGroup.TYPE_L3_NETWORK.equalsIgnoreCase(instanceGroup.getModelInfoInstanceGroup().getType())) {
- aaiInstanceGroupResources.connectInstanceGroupToVnf(instanceGroup, vnf, AAIEdgeLabel.USES);
- }
- }
- }
- catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
+
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+ @Autowired
+ private ExtractPojosForBB extractPojosForBB;
+ @Autowired
+ private AAIInstanceGroupResources aaiInstanceGroupResources;
+ @Autowired
+ private AAIObjectInstanceNameGenerator aaiObjectInstanceNameGenerator;
+
+
+ public void createInstanceGroups(BuildingBlockExecution execution) {
+ try {
+ GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ List<InstanceGroup> instanceGroups = vnf.getInstanceGroups();
+ for (InstanceGroup instanceGroup : instanceGroups) {
+ if (ModelInfoInstanceGroup.TYPE_VNFC
+ .equalsIgnoreCase(instanceGroup.getModelInfoInstanceGroup().getType())) {
+ instanceGroup.setInstanceGroupName(
+ aaiObjectInstanceNameGenerator.generateInstanceGroupName(instanceGroup, vnf));
+ aaiInstanceGroupResources.createInstanceGroup(instanceGroup);
+ aaiInstanceGroupResources.connectInstanceGroupToVnf(instanceGroup, vnf, AAIEdgeLabel.BELONGS_TO);
+ } else if (ModelInfoInstanceGroup.TYPE_L3_NETWORK
+ .equalsIgnoreCase(instanceGroup.getModelInfoInstanceGroup().getType())) {
+ aaiInstanceGroupResources.connectInstanceGroupToVnf(instanceGroup, vnf, AAIEdgeLabel.USES);
+ }
+ }
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CloudSiteCatalogUtils.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CloudSiteCatalogUtils.java
index 752c39a0a6..c1482d1463 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CloudSiteCatalogUtils.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CloudSiteCatalogUtils.java
@@ -22,7 +22,6 @@
package org.onap.so.bpmn.infrastructure.flowspecific.tasks;
import java.util.Optional;
-
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.onap.so.client.exception.ExceptionBuilder;
import org.onap.so.db.catalog.client.CatalogDbClient;
@@ -35,45 +34,49 @@ import org.springframework.stereotype.Component;
@Component
public class CloudSiteCatalogUtils {
- private static final Logger logger = LoggerFactory.getLogger(CloudSiteCatalogUtils.class);
- @Autowired
- private ExceptionBuilder exceptionUtil;
-
- @Autowired
- private CatalogDbClient catalogDbClient;
-
-
- public void getIdentityUrlFromCloudSite(DelegateExecution execution) {
- String cloudRegionId = (String) execution.getVariable("lcpCloudRegionId");
-
- if (cloudRegionId != null) {
- Optional<CloudSite> cloudSite = getCloudSite(cloudRegionId);
- if (!cloudSite.isPresent()) {
- logger.debug("Cloud Region with cloudRegionId {} not found in Catalog DB", cloudRegionId);
- exceptionUtil.buildAndThrowWorkflowException(execution, 404, "Cloud Region with cloudRegionId " + cloudRegionId + " not found in Catalog DB");
- }
-
- if (cloudSite.get().getIdentityService() == null) {
- logger.debug("No identityService found for Cloud Region with cloudRegionId {} in Catalog DB", cloudRegionId);
- exceptionUtil.buildAndThrowWorkflowException(execution, 404, "No identityService found for Cloud Region with cloudRegionId " + cloudRegionId + " in Catalog DB");
- }
- String identityUrl = cloudSite.get().getIdentityService().getIdentityUrl();
-
- logger.debug("identityUrl from Catalog DB is: {}", identityUrl);
- execution.setVariable("identityUrl", identityUrl);
- }
- }
-
- protected Optional<CloudSite> getCloudSite(String id) {
- if (id == null) {
- return Optional.empty();
- }
- CloudSite cloudSite = catalogDbClient.getCloudSite(id);
+ private static final Logger logger = LoggerFactory.getLogger(CloudSiteCatalogUtils.class);
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+
+ @Autowired
+ private CatalogDbClient catalogDbClient;
+
+
+ public void getIdentityUrlFromCloudSite(DelegateExecution execution) {
+ String cloudRegionId = (String) execution.getVariable("lcpCloudRegionId");
+
+ if (cloudRegionId != null) {
+ Optional<CloudSite> cloudSite = getCloudSite(cloudRegionId);
+ if (!cloudSite.isPresent()) {
+ logger.debug("Cloud Region with cloudRegionId {} not found in Catalog DB", cloudRegionId);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 404,
+ "Cloud Region with cloudRegionId " + cloudRegionId + " not found in Catalog DB");
+ }
+
+ if (cloudSite.get().getIdentityService() == null) {
+ logger.debug("No identityService found for Cloud Region with cloudRegionId {} in Catalog DB",
+ cloudRegionId);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 404,
+ "No identityService found for Cloud Region with cloudRegionId " + cloudRegionId
+ + " in Catalog DB");
+ }
+ String identityUrl = cloudSite.get().getIdentityService().getIdentityUrl();
+
+ logger.debug("identityUrl from Catalog DB is: {}", identityUrl);
+ execution.setVariable("identityUrl", identityUrl);
+ }
+ }
+
+ protected Optional<CloudSite> getCloudSite(String id) {
+ if (id == null) {
+ return Optional.empty();
+ }
+ CloudSite cloudSite = catalogDbClient.getCloudSite(id);
- if (cloudSite != null) {
- return Optional.of(cloudSite);
- } else {
- return(Optional.of(catalogDbClient.getCloudSiteByClliAndAicVersion(id,"2.5")));
- }
- }
+ if (cloudSite != null) {
+ return Optional.of(cloudSite);
+ } else {
+ return (Optional.of(catalogDbClient.getCloudSiteByClliAndAicVersion(id, "2.5")));
+ }
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigAssignVnf.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigAssignVnf.java
index 242135adb8..8a24330093 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigAssignVnf.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigAssignVnf.java
@@ -22,7 +22,6 @@ package org.onap.so.bpmn.infrastructure.flowspecific.tasks;
import java.util.Map;
import java.util.UUID;
-
import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
@@ -57,8 +56,8 @@ public class ConfigAssignVnf {
private ExtractPojosForBB extractPojosForBB;
/**
- * Getting the vnf data, blueprint name, blueprint version etc and setting them
- * in execution object and calling the subprocess.
+ * Getting the vnf data, blueprint name, blueprint version etc and setting them in execution object and calling the
+ * subprocess.
*
* @param execution
*/
@@ -66,7 +65,8 @@ public class ConfigAssignVnf {
logger.info("Start preProcessAbstractCDSProcessing ");
try {
GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
Map<String, Object> userParams = execution.getGeneralBuildingBlock().getRequestContext().getUserParams();
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnf.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnf.java
index 1bc7c0f574..359f19285f 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnf.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnf.java
@@ -1,27 +1,21 @@
/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2019 TechMahindra
-*=================================================================================
-* 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.
-* ============LICENSE_END=========================================================
-*/
+ * ============LICENSE_START======================================================= ONAP : SO
+ * ================================================================================ Copyright 2019 TechMahindra
+ * ================================================================================= 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.
+ * ============LICENSE_END=========================================================
+ */
package org.onap.so.bpmn.infrastructure.flowspecific.tasks;
import java.util.UUID;
-
import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.infrastructure.aai.tasks.AAIUpdateTasks;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
@@ -45,86 +39,90 @@ import org.springframework.stereotype.Component;
*/
@Component
public class ConfigDeployVnf {
- private static final Logger logger = LoggerFactory.getLogger(ConfigDeployVnf.class);
- private final static String ORIGINATOR_ID = "SO";
- private final static String ACTION_NAME = "config-deploy";
- private final static String MODE = "async";
-
- @Autowired
- private ExceptionBuilder exceptionUtil;
- @Autowired
- private ExtractPojosForBB extractPojosForBB;
- @Autowired
- private AAIUpdateTasks aaiUpdateTask;
-
- /**
- * Update vnf orch status to configure in AAI
- *
- * @param execution
- */
- public void updateAAIConfigure(BuildingBlockExecution execution) {
- aaiUpdateTask.updateOrchestrationStausConfigDeployConfigureVnf(execution);
-
- }
- /**
- * Getting the vnf object and set in execution object
- *
- * @param execution
- *
- *
- */
- public void preProcessAbstractCDSProcessing(BuildingBlockExecution execution) {
-
-
- logger.info("Start preProcessAbstractCDSProcessing");
- try {
- GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
-
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
-
- ConfigDeployPropertiesForVnf configDeployPropertiesForVnf = new ConfigDeployPropertiesForVnf();
- configDeployPropertiesForVnf.setServiceInstanceId(serviceInstance.getServiceInstanceId());
- configDeployPropertiesForVnf.setServiceModelUuid(serviceInstance.getModelInfoServiceInstance().getModelUuid());
- configDeployPropertiesForVnf.setVnfCustomizationUuid(vnf.getModelInfoGenericVnf().getModelCustomizationUuid());
- configDeployPropertiesForVnf.setVnfId(vnf.getVnfId());
- configDeployPropertiesForVnf.setVnfName(vnf.getVnfName());
-
- ConfigDeployRequestVnf configDeployRequestVnf = new ConfigDeployRequestVnf();
-
- configDeployRequestVnf.setResolutionKey(vnf.getVnfName());
- configDeployRequestVnf.setConfigDeployPropertiesForVnf(configDeployPropertiesForVnf);
-
- String blueprintName = vnf.getBlueprintName();
- String blueprintVersion = vnf.getBlueprintVersion();
- AbstractCDSPropertiesBean abstractCDSPropertiesBean = new AbstractCDSPropertiesBean();
-
- abstractCDSPropertiesBean.setBlueprintName(blueprintName);
- abstractCDSPropertiesBean.setBlueprintVersion(blueprintVersion);
- abstractCDSPropertiesBean.setRequestObject(configDeployRequestVnf.toString());
-
-
- GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
-
- abstractCDSPropertiesBean.setOriginatorId( ORIGINATOR_ID);
- abstractCDSPropertiesBean.setRequestId(gBBInput.getRequestContext().getMsoRequestId());
- abstractCDSPropertiesBean.setSubRequestId(UUID.randomUUID().toString());
- abstractCDSPropertiesBean.setActionName(ACTION_NAME);
- abstractCDSPropertiesBean.setMode(MODE);
-
- execution.setVariable("executionObject", abstractCDSPropertiesBean);
-
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- /**
- * Update vnf orch status to configured in AAI
- *
- * @param execution
- */
- public void updateAAIConfigured(BuildingBlockExecution execution) {
- aaiUpdateTask.updateOrchestrationStausConfigDeployConfiguredVnf(execution);
-
- }
-} \ No newline at end of file
+ private static final Logger logger = LoggerFactory.getLogger(ConfigDeployVnf.class);
+ private final static String ORIGINATOR_ID = "SO";
+ private final static String ACTION_NAME = "config-deploy";
+ private final static String MODE = "async";
+
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+ @Autowired
+ private ExtractPojosForBB extractPojosForBB;
+ @Autowired
+ private AAIUpdateTasks aaiUpdateTask;
+
+ /**
+ * Update vnf orch status to configure in AAI
+ *
+ * @param execution
+ */
+ public void updateAAIConfigure(BuildingBlockExecution execution) {
+ aaiUpdateTask.updateOrchestrationStausConfigDeployConfigureVnf(execution);
+
+ }
+
+ /**
+ * Getting the vnf object and set in execution object
+ *
+ * @param execution
+ *
+ *
+ */
+ public void preProcessAbstractCDSProcessing(BuildingBlockExecution execution) {
+
+
+ logger.info("Start preProcessAbstractCDSProcessing");
+ try {
+ GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+
+ ConfigDeployPropertiesForVnf configDeployPropertiesForVnf = new ConfigDeployPropertiesForVnf();
+ configDeployPropertiesForVnf.setServiceInstanceId(serviceInstance.getServiceInstanceId());
+ configDeployPropertiesForVnf
+ .setServiceModelUuid(serviceInstance.getModelInfoServiceInstance().getModelUuid());
+ configDeployPropertiesForVnf
+ .setVnfCustomizationUuid(vnf.getModelInfoGenericVnf().getModelCustomizationUuid());
+ configDeployPropertiesForVnf.setVnfId(vnf.getVnfId());
+ configDeployPropertiesForVnf.setVnfName(vnf.getVnfName());
+
+ ConfigDeployRequestVnf configDeployRequestVnf = new ConfigDeployRequestVnf();
+
+ configDeployRequestVnf.setResolutionKey(vnf.getVnfName());
+ configDeployRequestVnf.setConfigDeployPropertiesForVnf(configDeployPropertiesForVnf);
+
+ String blueprintName = vnf.getBlueprintName();
+ String blueprintVersion = vnf.getBlueprintVersion();
+ AbstractCDSPropertiesBean abstractCDSPropertiesBean = new AbstractCDSPropertiesBean();
+
+ abstractCDSPropertiesBean.setBlueprintName(blueprintName);
+ abstractCDSPropertiesBean.setBlueprintVersion(blueprintVersion);
+ abstractCDSPropertiesBean.setRequestObject(configDeployRequestVnf.toString());
+
+
+ GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+
+ abstractCDSPropertiesBean.setOriginatorId(ORIGINATOR_ID);
+ abstractCDSPropertiesBean.setRequestId(gBBInput.getRequestContext().getMsoRequestId());
+ abstractCDSPropertiesBean.setSubRequestId(UUID.randomUUID().toString());
+ abstractCDSPropertiesBean.setActionName(ACTION_NAME);
+ abstractCDSPropertiesBean.setMode(MODE);
+
+ execution.setVariable("executionObject", abstractCDSPropertiesBean);
+
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ /**
+ * Update vnf orch status to configured in AAI
+ *
+ * @param execution
+ */
+ public void updateAAIConfigured(BuildingBlockExecution execution) {
+ aaiUpdateTask.updateOrchestrationStausConfigDeployConfiguredVnf(execution);
+
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOut.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOut.java
index 4cd0321578..1925d8b69f 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOut.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOut.java
@@ -25,7 +25,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
-
import org.onap.appc.client.lcm.model.Action;
import org.onap.so.bpmn.appc.payload.beans.ConfigScaleOutPayload;
import org.onap.so.bpmn.appc.payload.beans.RequestParametersConfigScaleOut;
@@ -45,124 +44,124 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-
import com.fasterxml.jackson.databind.ObjectMapper;
import com.jayway.jsonpath.JsonPath;
@Component
public class ConfigurationScaleOut {
- private static final Logger logger = LoggerFactory.getLogger(ConfigurationScaleOut.class);
- @Autowired
- private ExceptionBuilder exceptionUtil;
- @Autowired
- private ExtractPojosForBB extractPojosForBB;
- @Autowired
- private CatalogDbClient catalogDbClient;
- @Autowired
- private ApplicationControllerAction appCClient;
- private static final String ACTION = "action";
- private static final String MSO_REQUEST_ID = "msoRequestId";
- private static final String VNF_ID = "vnfId";
- private static final String VNF_NAME = "vnfName";
- private static final String VFMODULE_ID = "vfModuleId";
- private static final String CONTROLLER_TYPE = "controllerType";
- private static final String PAYLOAD = "payload";
-
- public void setParamsForConfigurationScaleOut(BuildingBlockExecution execution) {
-
- GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
-
- try {
- List<Map<String, String>> jsonPathForCfgParams = gBBInput.getRequestContext().getConfigurationParameters();
- String key = null;
- String paramValue = null;
- ObjectMapper mapper = new ObjectMapper();
- String configScaleOutPayloadString = null;
- ControllerSelectionReference controllerSelectionReference;
- ConfigScaleOutPayload configPayload = new ConfigScaleOutPayload();
- GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- String vnfId = vnf.getVnfId();
- String vnfName = vnf.getVnfName();
- String vnfType = vnf.getVnfType();
- String actionCategory = Action.ConfigScaleOut.toString();
- controllerSelectionReference = catalogDbClient.getControllerSelectionReferenceByVnfTypeAndActionCategory(vnfType, actionCategory);
- String controllerName = controllerSelectionReference.getControllerName();
-
- VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
- String sdncVfModuleQueryResponse = execution.getVariable("SDNCQueryResponse_" + vfModule.getVfModuleId());
-
- Map<String, String> paramsMap = new HashMap<>();
- RequestParametersConfigScaleOut requestParameters = new RequestParametersConfigScaleOut();
- String configScaleOutParam = null;
- if (jsonPathForCfgParams != null) {
- for (Map<String, String> param : jsonPathForCfgParams) {
- for (Map.Entry<String,String> entry : param.entrySet()) {
- key = entry.getKey();
- paramValue = entry.getValue();
- try{
- configScaleOutParam = JsonPath.parse(sdncVfModuleQueryResponse).read(paramValue);
- }catch(ClassCastException e){
- configScaleOutParam = null;
- logger.warn("Incorrect JSON path. Path points to object rather than value causing: ", e);
- }
- paramsMap.put(key, configScaleOutParam);
- }
- }
- }
- requestParameters.setVfModuleId(vfModule.getVfModuleId());
- requestParameters.setVnfHostIpAddress(vnf.getIpv4OamAddress());
- configPayload.setConfigurationParameters(paramsMap);
- configPayload.setRequestParameters(requestParameters);
- configScaleOutPayloadString = mapper.writeValueAsString(configPayload);
-
- execution.setVariable(ACTION, actionCategory);
- execution.setVariable(MSO_REQUEST_ID, gBBInput.getRequestContext().getMsoRequestId());
- execution.setVariable(VNF_ID, vnfId);
- execution.setVariable(VNF_NAME, vnfName);
- execution.setVariable(VFMODULE_ID, vfModule.getVfModuleId());
- execution.setVariable(CONTROLLER_TYPE, controllerName);
- execution.setVariable(PAYLOAD, configScaleOutPayloadString);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void callAppcClient(BuildingBlockExecution execution) {
- logger.trace("Start runAppcCommand ");
- String appcCode = "1002";
- String appcMessage = "";
- try{
- Action commandAction = Action.valueOf(execution.getVariable(ACTION));
- String msoRequestId = execution.getVariable(MSO_REQUEST_ID);
- String vnfId = execution.getVariable(VNF_ID);
- Optional<String> payloadString = null;
- if(execution.getVariable(PAYLOAD) != null){
- String pay = execution.getVariable(PAYLOAD);
- payloadString = Optional.of(pay);
- }
- String controllerType = execution.getVariable(CONTROLLER_TYPE);
- HashMap<String, String> payloadInfo = new HashMap<>();
- payloadInfo.put(VNF_NAME, execution.getVariable(VNF_NAME));
- payloadInfo.put(VFMODULE_ID,execution.getVariable(VFMODULE_ID));
- logger.debug("Running APP-C action: {}", commandAction.toString());
- logger.debug("VNFID: {}", vnfId);
- //PayloadInfo contains extra information that adds on to payload before making request to appc
- appCClient.runAppCCommand(commandAction, msoRequestId, vnfId, payloadString, payloadInfo, controllerType);
- appcCode = appCClient.getErrorCode();
- appcMessage = appCClient.getErrorMessage();
-
- } catch (Exception e) {
- logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(),
- "Caught exception in runAppcCommand in ConfigurationScaleOut", "BPMN",
- ErrorCode.UnknownError.getValue(), "APPC Error", e);
- appcMessage = e.getMessage();
- }
- logger.error("Error Message: " + appcMessage);
- logger.error("ERROR CODE: " + appcCode);
- logger.trace("End of runAppCommand ");
- if (appcCode != null && !appcCode.equals("0")) {
- exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(appcCode), appcMessage);
- }
- }
+ private static final Logger logger = LoggerFactory.getLogger(ConfigurationScaleOut.class);
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+ @Autowired
+ private ExtractPojosForBB extractPojosForBB;
+ @Autowired
+ private CatalogDbClient catalogDbClient;
+ @Autowired
+ private ApplicationControllerAction appCClient;
+ private static final String ACTION = "action";
+ private static final String MSO_REQUEST_ID = "msoRequestId";
+ private static final String VNF_ID = "vnfId";
+ private static final String VNF_NAME = "vnfName";
+ private static final String VFMODULE_ID = "vfModuleId";
+ private static final String CONTROLLER_TYPE = "controllerType";
+ private static final String PAYLOAD = "payload";
+
+ public void setParamsForConfigurationScaleOut(BuildingBlockExecution execution) {
+
+ GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+
+ try {
+ List<Map<String, String>> jsonPathForCfgParams = gBBInput.getRequestContext().getConfigurationParameters();
+ String key = null;
+ String paramValue = null;
+ ObjectMapper mapper = new ObjectMapper();
+ String configScaleOutPayloadString = null;
+ ControllerSelectionReference controllerSelectionReference;
+ ConfigScaleOutPayload configPayload = new ConfigScaleOutPayload();
+ GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ String vnfId = vnf.getVnfId();
+ String vnfName = vnf.getVnfName();
+ String vnfType = vnf.getVnfType();
+ String actionCategory = Action.ConfigScaleOut.toString();
+ controllerSelectionReference =
+ catalogDbClient.getControllerSelectionReferenceByVnfTypeAndActionCategory(vnfType, actionCategory);
+ String controllerName = controllerSelectionReference.getControllerName();
+
+ VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
+ String sdncVfModuleQueryResponse = execution.getVariable("SDNCQueryResponse_" + vfModule.getVfModuleId());
+
+ Map<String, String> paramsMap = new HashMap<>();
+ RequestParametersConfigScaleOut requestParameters = new RequestParametersConfigScaleOut();
+ String configScaleOutParam = null;
+ if (jsonPathForCfgParams != null) {
+ for (Map<String, String> param : jsonPathForCfgParams) {
+ for (Map.Entry<String, String> entry : param.entrySet()) {
+ key = entry.getKey();
+ paramValue = entry.getValue();
+ try {
+ configScaleOutParam = JsonPath.parse(sdncVfModuleQueryResponse).read(paramValue);
+ } catch (ClassCastException e) {
+ configScaleOutParam = null;
+ logger.warn("Incorrect JSON path. Path points to object rather than value causing: ", e);
+ }
+ paramsMap.put(key, configScaleOutParam);
+ }
+ }
+ }
+ requestParameters.setVfModuleId(vfModule.getVfModuleId());
+ requestParameters.setVnfHostIpAddress(vnf.getIpv4OamAddress());
+ configPayload.setConfigurationParameters(paramsMap);
+ configPayload.setRequestParameters(requestParameters);
+ configScaleOutPayloadString = mapper.writeValueAsString(configPayload);
+
+ execution.setVariable(ACTION, actionCategory);
+ execution.setVariable(MSO_REQUEST_ID, gBBInput.getRequestContext().getMsoRequestId());
+ execution.setVariable(VNF_ID, vnfId);
+ execution.setVariable(VNF_NAME, vnfName);
+ execution.setVariable(VFMODULE_ID, vfModule.getVfModuleId());
+ execution.setVariable(CONTROLLER_TYPE, controllerName);
+ execution.setVariable(PAYLOAD, configScaleOutPayloadString);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void callAppcClient(BuildingBlockExecution execution) {
+ logger.trace("Start runAppcCommand ");
+ String appcCode = "1002";
+ String appcMessage = "";
+ try {
+ Action commandAction = Action.valueOf(execution.getVariable(ACTION));
+ String msoRequestId = execution.getVariable(MSO_REQUEST_ID);
+ String vnfId = execution.getVariable(VNF_ID);
+ Optional<String> payloadString = null;
+ if (execution.getVariable(PAYLOAD) != null) {
+ String pay = execution.getVariable(PAYLOAD);
+ payloadString = Optional.of(pay);
+ }
+ String controllerType = execution.getVariable(CONTROLLER_TYPE);
+ HashMap<String, String> payloadInfo = new HashMap<>();
+ payloadInfo.put(VNF_NAME, execution.getVariable(VNF_NAME));
+ payloadInfo.put(VFMODULE_ID, execution.getVariable(VFMODULE_ID));
+ logger.debug("Running APP-C action: {}", commandAction.toString());
+ logger.debug("VNFID: {}", vnfId);
+ // PayloadInfo contains extra information that adds on to payload before making request to appc
+ appCClient.runAppCCommand(commandAction, msoRequestId, vnfId, payloadString, payloadInfo, controllerType);
+ appcCode = appCClient.getErrorCode();
+ appcMessage = appCClient.getErrorMessage();
+
+ } catch (Exception e) {
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(),
+ "Caught exception in runAppcCommand in ConfigurationScaleOut", "BPMN",
+ ErrorCode.UnknownError.getValue(), "APPC Error", e);
+ appcMessage = e.getMessage();
+ }
+ logger.error("Error Message: " + appcMessage);
+ logger.error("ERROR CODE: " + appcCode);
+ logger.trace("End of runAppCommand ");
+ if (appcCode != null && !appcCode.equals("0")) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(appcCode), appcMessage);
+ }
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetwork.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetwork.java
index 8cad8f93ec..c2d9c6e7bb 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetwork.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetwork.java
@@ -22,7 +22,6 @@
package org.onap.so.bpmn.infrastructure.flowspecific.tasks;
import java.util.Map;
-
import org.onap.so.adapters.nwrest.CreateNetworkRequest;
import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
@@ -40,32 +39,35 @@ import org.springframework.stereotype.Component;
@Component
public class CreateNetwork {
- private static final Logger logger = LoggerFactory.getLogger(CreateNetwork.class);
- @Autowired
- private ExceptionBuilder exceptionUtil;
- @Autowired
- private ExtractPojosForBB extractPojosForBB;
- @Autowired
- private NetworkAdapterObjectMapper networkAdapterObjectMapper;
-
- /**
- * BPMN access method to build CreateNetworkRequest object
- *
- */
- public void buildCreateNetworkRequest(BuildingBlockExecution execution) throws Exception {
- try{
- GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- L3Network l3Network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
- Map<String, String> userInput = gBBInput.getUserInput();
- String cloudRegionPo = execution.getVariable("cloudRegionPo");
-
- CreateNetworkRequest createNetworkRequest = networkAdapterObjectMapper.createNetworkRequestMapper(gBBInput.getRequestContext(), gBBInput.getCloudRegion(), gBBInput.getOrchContext(), serviceInstance, l3Network, userInput, cloudRegionPo, gBBInput.getCustomer());
-
- //set CreateNetowrkRequest object on execution to be re-used within current BB
- execution.setVariable("createNetworkRequest", createNetworkRequest);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
+ private static final Logger logger = LoggerFactory.getLogger(CreateNetwork.class);
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+ @Autowired
+ private ExtractPojosForBB extractPojosForBB;
+ @Autowired
+ private NetworkAdapterObjectMapper networkAdapterObjectMapper;
+
+ /**
+ * BPMN access method to build CreateNetworkRequest object
+ *
+ */
+ public void buildCreateNetworkRequest(BuildingBlockExecution execution) throws Exception {
+ try {
+ GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ L3Network l3Network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
+ Map<String, String> userInput = gBBInput.getUserInput();
+ String cloudRegionPo = execution.getVariable("cloudRegionPo");
+
+ CreateNetworkRequest createNetworkRequest = networkAdapterObjectMapper.createNetworkRequestMapper(
+ gBBInput.getRequestContext(), gBBInput.getCloudRegion(), gBBInput.getOrchContext(), serviceInstance,
+ l3Network, userInput, cloudRegionPo, gBBInput.getCustomer());
+
+ // set CreateNetowrkRequest object on execution to be re-used within current BB
+ execution.setVariable("createNetworkRequest", createNetworkRequest);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetworkCollection.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetworkCollection.java
index 5665302b2a..4eaec381e9 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetworkCollection.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetworkCollection.java
@@ -36,94 +36,107 @@ import org.springframework.stereotype.Component;
@Component
public class CreateNetworkCollection {
- private static final Logger logger = LoggerFactory.getLogger(CreateNetworkCollection.class);
- @Autowired
- private ExceptionBuilder exceptionUtil;
- @Autowired
- private ExtractPojosForBB extractPojosForBB;
- @Autowired
- private AAINetworkResources aaiNetworkResources;
+ private static final Logger logger = LoggerFactory.getLogger(CreateNetworkCollection.class);
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+ @Autowired
+ private ExtractPojosForBB extractPojosForBB;
+ @Autowired
+ private AAINetworkResources aaiNetworkResources;
- private static final String UNDERSCORE = "_";
- private static final String NETWORK_COLLECTION_NAME = "networkCollectionName";
-
- /**
- * BPMN access method to build Network Collection Name
- * @param execution
- * @throws Exception
- */
- public void buildNetworkCollectionName(BuildingBlockExecution execution) throws Exception {
- try{
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- InstanceGroup instanceGroup = serviceInstance.getCollection().getInstanceGroup();
- if(instanceGroup.getModelInfoInstanceGroup() != null) {
- //Build collection name assembling SI name and IG function
- if(serviceInstance.getServiceInstanceName() != null
- && instanceGroup.getModelInfoInstanceGroup().getFunction() != null) {
- String networkCollectionName = serviceInstance.getServiceInstanceName().concat(UNDERSCORE).concat(instanceGroup.getModelInfoInstanceGroup().getFunction());
- //set networkCollectionName object on execution to be re-used within current BB
- execution.setVariable(NETWORK_COLLECTION_NAME, networkCollectionName);
- } else {
- throw new IllegalArgumentException("Cannot generate collection name because either one or both fields are null: "
- + " Service Instance Name: " + serviceInstance.getServiceInstanceName()
- + ", Instance Group Function: " + instanceGroup.getModelInfoInstanceGroup().getFunction());
- }
- } else {
- throw new IllegalArgumentException("Instance group model info is null");
- }
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- /**
- * BPMN access method to connect Network Collection
- * @param execution
- * @throws Exception
- */
- public void connectCollectionToInstanceGroup(BuildingBlockExecution execution) throws Exception {
- execution.setVariable("connectCollectionToInstanceGroupRollback", false);
- try{
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- Collection networkCollection = serviceInstance.getCollection();
- aaiNetworkResources.connectNetworkCollectionInstanceGroupToNetworkCollection(networkCollection.getInstanceGroup(), networkCollection);
- execution.setVariable("connectCollectionToInstanceGroupRollback", true);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- /**
- * BPMN access method to connect Instance Group to Cloud Region
- * @param execution
- * @throws Exception
- */
- public void connectInstanceGroupToCloudRegion(BuildingBlockExecution execution) throws Exception {
- execution.setVariable("connectInstanceGroupToCloudRegionRollback", false);
- try{
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- Collection networkCollection = serviceInstance.getCollection();
- aaiNetworkResources.connectInstanceGroupToCloudRegion(networkCollection.getInstanceGroup(), execution.getGeneralBuildingBlock().getCloudRegion());
- execution.setVariable("connectInstanceGroupToCloudRegionRollback", true);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- /**
- * BPMN access method to connect Network Collection
- * @param execution
- * @throws Exception
- */
- public void connectCollectionToServiceInstance(BuildingBlockExecution execution) throws Exception {
- execution.setVariable("connectCollectionToServiceInstanceRollback", false);
- try{
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- Collection networkCollection = serviceInstance.getCollection();
- aaiNetworkResources.connectNetworkCollectionToServiceInstance(networkCollection, serviceInstance);
- execution.setVariable("connectCollectionToServiceInstanceRollback", true);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
+ private static final String UNDERSCORE = "_";
+ private static final String NETWORK_COLLECTION_NAME = "networkCollectionName";
+
+ /**
+ * BPMN access method to build Network Collection Name
+ *
+ * @param execution
+ * @throws Exception
+ */
+ public void buildNetworkCollectionName(BuildingBlockExecution execution) throws Exception {
+ try {
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ InstanceGroup instanceGroup = serviceInstance.getCollection().getInstanceGroup();
+ if (instanceGroup.getModelInfoInstanceGroup() != null) {
+ // Build collection name assembling SI name and IG function
+ if (serviceInstance.getServiceInstanceName() != null
+ && instanceGroup.getModelInfoInstanceGroup().getFunction() != null) {
+ String networkCollectionName = serviceInstance.getServiceInstanceName().concat(UNDERSCORE)
+ .concat(instanceGroup.getModelInfoInstanceGroup().getFunction());
+ // set networkCollectionName object on execution to be re-used within current BB
+ execution.setVariable(NETWORK_COLLECTION_NAME, networkCollectionName);
+ } else {
+ throw new IllegalArgumentException(
+ "Cannot generate collection name because either one or both fields are null: "
+ + " Service Instance Name: " + serviceInstance.getServiceInstanceName()
+ + ", Instance Group Function: "
+ + instanceGroup.getModelInfoInstanceGroup().getFunction());
+ }
+ } else {
+ throw new IllegalArgumentException("Instance group model info is null");
+ }
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ /**
+ * BPMN access method to connect Network Collection
+ *
+ * @param execution
+ * @throws Exception
+ */
+ public void connectCollectionToInstanceGroup(BuildingBlockExecution execution) throws Exception {
+ execution.setVariable("connectCollectionToInstanceGroupRollback", false);
+ try {
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ Collection networkCollection = serviceInstance.getCollection();
+ aaiNetworkResources.connectNetworkCollectionInstanceGroupToNetworkCollection(
+ networkCollection.getInstanceGroup(), networkCollection);
+ execution.setVariable("connectCollectionToInstanceGroupRollback", true);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ /**
+ * BPMN access method to connect Instance Group to Cloud Region
+ *
+ * @param execution
+ * @throws Exception
+ */
+ public void connectInstanceGroupToCloudRegion(BuildingBlockExecution execution) throws Exception {
+ execution.setVariable("connectInstanceGroupToCloudRegionRollback", false);
+ try {
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ Collection networkCollection = serviceInstance.getCollection();
+ aaiNetworkResources.connectInstanceGroupToCloudRegion(networkCollection.getInstanceGroup(),
+ execution.getGeneralBuildingBlock().getCloudRegion());
+ execution.setVariable("connectInstanceGroupToCloudRegionRollback", true);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ /**
+ * BPMN access method to connect Network Collection
+ *
+ * @param execution
+ * @throws Exception
+ */
+ public void connectCollectionToServiceInstance(BuildingBlockExecution execution) throws Exception {
+ execution.setVariable("connectCollectionToServiceInstanceRollback", false);
+ try {
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ Collection networkCollection = serviceInstance.getCollection();
+ aaiNetworkResources.connectNetworkCollectionToServiceInstance(networkCollection, serviceInstance);
+ execution.setVariable("connectCollectionToServiceInstanceRollback", true);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheck.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheck.java
index f0db5eda2e..98b602eca1 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheck.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheck.java
@@ -44,98 +44,97 @@ import org.springframework.stereotype.Component;
@Component
public class GenericVnfHealthCheck {
- private static final Logger logger = LoggerFactory.getLogger(GenericVnfHealthCheck.class);
- @Autowired
- private ExceptionBuilder exceptionUtil;
- @Autowired
- private ExtractPojosForBB extractPojosForBB;
- @Autowired
- private CatalogDbClient catalogDbClient;
- @Autowired
- private ApplicationControllerAction appCClient;
-
- public void setParamsForGenericVnfHealthCheck(BuildingBlockExecution execution) {
-
- GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+ private static final Logger logger = LoggerFactory.getLogger(GenericVnfHealthCheck.class);
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+ @Autowired
+ private ExtractPojosForBB extractPojosForBB;
+ @Autowired
+ private CatalogDbClient catalogDbClient;
+ @Autowired
+ private ApplicationControllerAction appCClient;
- try {
- ControllerSelectionReference controllerSelectionReference;
- GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- String vnfId = vnf.getVnfId();
- String vnfName = vnf.getVnfName();
- String vnfType = vnf.getVnfType();
- String oamIpAddress = vnf.getIpv4OamAddress();
- String actionCategory = Action.HealthCheck.toString();
- controllerSelectionReference = catalogDbClient.getControllerSelectionReferenceByVnfTypeAndActionCategory(vnfType, actionCategory);
- String controllerName = controllerSelectionReference.getControllerName();
-
- execution.setVariable("vnfId", vnfId);
- execution.setVariable("vnfName", vnfName);
- execution.setVariable("oamIpAddress", oamIpAddress);
- execution.setVariable("vnfHostIpAddress", oamIpAddress);
- execution.setVariable("msoRequestId", gBBInput.getRequestContext().getMsoRequestId());
- execution.setVariable("action", actionCategory);
- execution.setVariable("controllerType", controllerName);
-
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void callAppcClient(BuildingBlockExecution execution) {
- logger.trace("Start runAppcCommand ");
- String appcCode = "1002";
- String appcMessage = "";
- try {
- Action action = null;
- action = Action.valueOf(execution.getVariable("action"));
- String msoRequestId = execution.getVariable("msoRequestId");
- String vnfId = execution.getVariable("vnfId");
- Optional<String> payload = null;
- if(execution.getVariable("payload") != null){
- String pay = execution.getVariable("payload");
- payload = Optional.of(pay);
- }
- String controllerType = execution.getVariable("controllerType");
- HashMap<String, String> payloadInfo = new HashMap<String, String>();
- payloadInfo.put("vnfName", execution.getVariable("vnfName"));
- payloadInfo.put("vfModuleId",execution.getVariable("vfModuleId"));
- payloadInfo.put("oamIpAddress",execution.getVariable("oamIpAddress"));
- payloadInfo.put("vnfHostIpAddress",execution.getVariable("vnfHostIpAddress"));
-
- logger.debug("Running APP-C action: {}", action.toString());
- logger.debug("VNFID: {}", vnfId);
- //PayloadInfo contains extra information that adds on to payload before making request to appc
- appCClient.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType);
- appcCode = appCClient.getErrorCode();
- appcMessage = appCClient.getErrorMessage();
+ public void setParamsForGenericVnfHealthCheck(BuildingBlockExecution execution) {
+
+ GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+
+ try {
+ ControllerSelectionReference controllerSelectionReference;
+ GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ String vnfId = vnf.getVnfId();
+ String vnfName = vnf.getVnfName();
+ String vnfType = vnf.getVnfType();
+ String oamIpAddress = vnf.getIpv4OamAddress();
+ String actionCategory = Action.HealthCheck.toString();
+ controllerSelectionReference =
+ catalogDbClient.getControllerSelectionReferenceByVnfTypeAndActionCategory(vnfType, actionCategory);
+ String controllerName = controllerSelectionReference.getControllerName();
+
+ execution.setVariable("vnfId", vnfId);
+ execution.setVariable("vnfName", vnfName);
+ execution.setVariable("oamIpAddress", oamIpAddress);
+ execution.setVariable("vnfHostIpAddress", oamIpAddress);
+ execution.setVariable("msoRequestId", gBBInput.getRequestContext().getMsoRequestId());
+ execution.setVariable("action", actionCategory);
+ execution.setVariable("controllerType", controllerName);
+
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void callAppcClient(BuildingBlockExecution execution) {
+ logger.trace("Start runAppcCommand ");
+ String appcCode = "1002";
+ String appcMessage = "";
+ try {
+ Action action = null;
+ action = Action.valueOf(execution.getVariable("action"));
+ String msoRequestId = execution.getVariable("msoRequestId");
+ String vnfId = execution.getVariable("vnfId");
+ Optional<String> payload = null;
+ if (execution.getVariable("payload") != null) {
+ String pay = execution.getVariable("payload");
+ payload = Optional.of(pay);
+ }
+ String controllerType = execution.getVariable("controllerType");
+ HashMap<String, String> payloadInfo = new HashMap<String, String>();
+ payloadInfo.put("vnfName", execution.getVariable("vnfName"));
+ payloadInfo.put("vfModuleId", execution.getVariable("vfModuleId"));
+ payloadInfo.put("oamIpAddress", execution.getVariable("oamIpAddress"));
+ payloadInfo.put("vnfHostIpAddress", execution.getVariable("vnfHostIpAddress"));
+
+ logger.debug("Running APP-C action: {}", action.toString());
+ logger.debug("VNFID: {}", vnfId);
+ // PayloadInfo contains extra information that adds on to payload before making request to appc
+ appCClient.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType);
+ appcCode = appCClient.getErrorCode();
+ appcMessage = appCClient.getErrorMessage();
} catch (BpmnError ex) {
- logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
- "Caught exception in GenericVnfHealthCheck", "BPMN", ErrorCode.UnknownError.getValue(), ex);
- appcMessage = ex.getMessage();
+ logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ "Caught exception in GenericVnfHealthCheck", "BPMN", ErrorCode.UnknownError.getValue(), ex);
+ appcMessage = ex.getMessage();
+ exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(appcCode), appcMessage);
+ } catch (Exception e) {
+ if (e instanceof java.util.concurrent.TimeoutException) {
+ appcMessage = "Request to APPC timed out. ";
+ logger.error("{} {} {} {} {}", MessageEnum.RA_CONNECTION_EXCEPTION.toString(),
+ "Caught timedOut exception in runAppcCommand in GenericVnfHealthCheck", "BPMN",
+ ErrorCode.UnknownError.getValue(), "APPC Error", e);
+ throw e;
+ } else {
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(),
+ "Caught exception in runAppcCommand in GenericVnfHealthCheck", "BPMN",
+ ErrorCode.UnknownError.getValue(), "APPC Error", e);
+ appcMessage = e.getMessage();
+ exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(appcCode), appcMessage);
+ }
+ }
+ logger.error("Error Message: " + appcMessage);
+ logger.error("ERROR CODE: " + appcCode);
+ logger.trace("End of runAppCommand ");
+ if (appcCode != null && !appcCode.equals("0")) {
exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(appcCode), appcMessage);
- } catch (Exception e) {
- if (e instanceof java.util.concurrent.TimeoutException )
- {
- appcMessage = "Request to APPC timed out. ";
- logger.error("{} {} {} {} {}", MessageEnum.RA_CONNECTION_EXCEPTION.toString(),
- "Caught timedOut exception in runAppcCommand in GenericVnfHealthCheck", "BPMN",
- ErrorCode.UnknownError.getValue(), "APPC Error", e);
- throw e;
- }
- else {
- logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(),
- "Caught exception in runAppcCommand in GenericVnfHealthCheck", "BPMN",
- ErrorCode.UnknownError.getValue(), "APPC Error", e);
- appcMessage = e.getMessage();
- exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(appcCode), appcMessage);
- }
- }
- logger.error("Error Message: " + appcMessage);
- logger.error("ERROR CODE: " + appcCode);
- logger.trace("End of runAppCommand ");
- if (appcCode != null && !appcCode.equals("0")) {
- exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(appcCode), appcMessage);
- }
- }
+ }
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/NetworkBBUtils.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/NetworkBBUtils.java
index 217a60b60a..7ab53cb506 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/NetworkBBUtils.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/NetworkBBUtils.java
@@ -22,53 +22,56 @@ package org.onap.so.bpmn.infrastructure.flowspecific.tasks;
import java.util.List;
import java.util.Optional;
-
import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
import org.springframework.stereotype.Component;
@Component
-public class NetworkBBUtils {
-
- private static final String CLOUD_REGION_VER25 = "2.5";
- private static final String CLOUD_REGION_AAIAIC25 = "AAIAIC25";
-
- /**
- * BPMN access method to check if Relationship's Related-To value exists.
- *
- * @param l3Network - L3Network object
- * @param relatedToValue - String, ex: 'vf-module'
- * @return boolean
- */
- public boolean isRelationshipRelatedToExists(Optional<org.onap.aai.domain.yang.L3Network> l3network, String relatedToValue) {
- boolean isRelatedToExists = false;
- if (l3network.isPresent()) {
- List<org.onap.aai.domain.yang.Relationship> relationshipList = l3network.get().getRelationshipList().getRelationship();
- for (org.onap.aai.domain.yang.Relationship relationship : relationshipList) {
- if (relationship.getRelatedTo().equals(relatedToValue)) {
- isRelatedToExists = true;
- break;
- }
- }
- }
- return isRelatedToExists;
- }
-
- /**
- * BPMN access method to extract Cloud Region data
- * @param execution
- * @param motsValue (ex: SourceSystem.SDNC or SourceSystem.PO)
- */
- public String getCloudRegion(BuildingBlockExecution execution, SourceSystem sourceValue) {
- GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
- CloudRegion cloudRegion = gBBInput.getCloudRegion();
- String cloudRegionId = cloudRegion.getLcpCloudRegionId();
- if (sourceValue.equals(SourceSystem.SDNC) && CLOUD_REGION_VER25.equalsIgnoreCase(cloudRegion.getCloudRegionVersion())) {
- cloudRegionId = CLOUD_REGION_AAIAIC25;
- }
- return cloudRegionId;
- }
-
-
+public class NetworkBBUtils {
+
+ private static final String CLOUD_REGION_VER25 = "2.5";
+ private static final String CLOUD_REGION_AAIAIC25 = "AAIAIC25";
+
+ /**
+ * BPMN access method to check if Relationship's Related-To value exists.
+ *
+ * @param l3Network - L3Network object
+ * @param relatedToValue - String, ex: 'vf-module'
+ * @return boolean
+ */
+ public boolean isRelationshipRelatedToExists(Optional<org.onap.aai.domain.yang.L3Network> l3network,
+ String relatedToValue) {
+ boolean isRelatedToExists = false;
+ if (l3network.isPresent()) {
+ List<org.onap.aai.domain.yang.Relationship> relationshipList =
+ l3network.get().getRelationshipList().getRelationship();
+ for (org.onap.aai.domain.yang.Relationship relationship : relationshipList) {
+ if (relationship.getRelatedTo().equals(relatedToValue)) {
+ isRelatedToExists = true;
+ break;
+ }
+ }
+ }
+ return isRelatedToExists;
+ }
+
+ /**
+ * BPMN access method to extract Cloud Region data
+ *
+ * @param execution
+ * @param motsValue (ex: SourceSystem.SDNC or SourceSystem.PO)
+ */
+ public String getCloudRegion(BuildingBlockExecution execution, SourceSystem sourceValue) {
+ GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+ CloudRegion cloudRegion = gBBInput.getCloudRegion();
+ String cloudRegionId = cloudRegion.getLcpCloudRegionId();
+ if (sourceValue.equals(SourceSystem.SDNC)
+ && CLOUD_REGION_VER25.equalsIgnoreCase(cloudRegion.getCloudRegionVersion())) {
+ cloudRegionId = CLOUD_REGION_AAIAIC25;
+ }
+ return cloudRegionId;
+ }
+
+
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/SourceSystem.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/SourceSystem.java
index 596b280916..0f545b9145 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/SourceSystem.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/SourceSystem.java
@@ -21,6 +21,5 @@
package org.onap.so.bpmn.infrastructure.flowspecific.tasks;
public enum SourceSystem {
- PO,
- SDNC
+ PO, SDNC
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBB.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBB.java
index 9a7d695c01..27415190cc 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBB.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBB.java
@@ -23,7 +23,6 @@
package org.onap.so.bpmn.infrastructure.flowspecific.tasks;
import java.util.Optional;
-
import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
@@ -39,80 +38,83 @@ import org.springframework.stereotype.Component;
@Component
public class UnassignNetworkBB {
- private static final Logger logger = LoggerFactory.getLogger(UnassignNetworkBB.class);
-
- private static String MESSAGE_CANNOT_PERFORM_UNASSIGN = "Cannot perform Unassign Network. Network is still related to ";
- private static String MESSAGE_ERROR_ROLLBACK = " Rollback is not possible. Please restore data manually.";
-
- @Autowired
- private ExceptionBuilder exceptionUtil;
-
- @Autowired
- private NetworkBBUtils networkBBUtils;
-
- @Autowired
- private ExtractPojosForBB extractPojosForBB;
-
- @Autowired
- private AAINetworkResources aaiNetworkResources;
-
- /**
- * BPMN access method to prepare overall error messages.
- *
- * @param execution - BuildingBlockExecution
- * @param relatedToValue - String, ex: vf-module
- * @return void - nothing
- * @throws Exception
- */
-
- public void checkRelationshipRelatedTo(BuildingBlockExecution execution, String relatedToValue) throws Exception {
- try {
- L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
- AAIResultWrapper aaiResultWrapper = aaiNetworkResources.queryNetworkWrapperById(l3network);
- Optional<org.onap.aai.domain.yang.L3Network> network = aaiResultWrapper.asBean(org.onap.aai.domain.yang.L3Network.class);
- if (networkBBUtils.isRelationshipRelatedToExists(network, relatedToValue)) {
- String msg = MESSAGE_CANNOT_PERFORM_UNASSIGN + relatedToValue;
- execution.setVariable("ErrorUnassignNetworkBB", msg);
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg);
- }
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- /**
- * BPMN access method to getCloudRegionId
- *
- * @param execution - BuildingBlockExecution
- * @return void - nothing
- * @throws Exception
- */
-
- public void getCloudSdncRegion(BuildingBlockExecution execution) throws Exception {
- try {
- String cloudRegionSdnc = networkBBUtils.getCloudRegion(execution, SourceSystem.SDNC);
- execution.setVariable("cloudRegionSdnc", cloudRegionSdnc);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- /**
- * BPMN access method to prepare overall error messages.
- *
- * @param execution - BuildingBlockExecution
- * @return void - nothing
- */
- public void errorEncountered(BuildingBlockExecution execution) {
- String msg;
- boolean isRollbackNeeded = execution.getVariable("isRollbackNeeded") != null ? execution.getVariable("isRollbackNeeded") : false;
- if (isRollbackNeeded == true) {
- msg = execution.getVariable("ErrorUnassignNetworkBB") + MESSAGE_ERROR_ROLLBACK;
- } else {
- msg = execution.getVariable("ErrorUnassignNetworkBB");
- }
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg);
- }
-
-
+ private static final Logger logger = LoggerFactory.getLogger(UnassignNetworkBB.class);
+
+ private static String MESSAGE_CANNOT_PERFORM_UNASSIGN =
+ "Cannot perform Unassign Network. Network is still related to ";
+ private static String MESSAGE_ERROR_ROLLBACK = " Rollback is not possible. Please restore data manually.";
+
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+
+ @Autowired
+ private NetworkBBUtils networkBBUtils;
+
+ @Autowired
+ private ExtractPojosForBB extractPojosForBB;
+
+ @Autowired
+ private AAINetworkResources aaiNetworkResources;
+
+ /**
+ * BPMN access method to prepare overall error messages.
+ *
+ * @param execution - BuildingBlockExecution
+ * @param relatedToValue - String, ex: vf-module
+ * @return void - nothing
+ * @throws Exception
+ */
+
+ public void checkRelationshipRelatedTo(BuildingBlockExecution execution, String relatedToValue) throws Exception {
+ try {
+ L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
+ AAIResultWrapper aaiResultWrapper = aaiNetworkResources.queryNetworkWrapperById(l3network);
+ Optional<org.onap.aai.domain.yang.L3Network> network =
+ aaiResultWrapper.asBean(org.onap.aai.domain.yang.L3Network.class);
+ if (networkBBUtils.isRelationshipRelatedToExists(network, relatedToValue)) {
+ String msg = MESSAGE_CANNOT_PERFORM_UNASSIGN + relatedToValue;
+ execution.setVariable("ErrorUnassignNetworkBB", msg);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg);
+ }
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ /**
+ * BPMN access method to getCloudRegionId
+ *
+ * @param execution - BuildingBlockExecution
+ * @return void - nothing
+ * @throws Exception
+ */
+
+ public void getCloudSdncRegion(BuildingBlockExecution execution) throws Exception {
+ try {
+ String cloudRegionSdnc = networkBBUtils.getCloudRegion(execution, SourceSystem.SDNC);
+ execution.setVariable("cloudRegionSdnc", cloudRegionSdnc);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ /**
+ * BPMN access method to prepare overall error messages.
+ *
+ * @param execution - BuildingBlockExecution
+ * @return void - nothing
+ */
+ public void errorEncountered(BuildingBlockExecution execution) {
+ String msg;
+ boolean isRollbackNeeded =
+ execution.getVariable("isRollbackNeeded") != null ? execution.getVariable("isRollbackNeeded") : false;
+ if (isRollbackNeeded == true) {
+ msg = execution.getVariable("ErrorUnassignNetworkBB") + MESSAGE_ERROR_ROLLBACK;
+ } else {
+ msg = execution.getVariable("ErrorUnassignNetworkBB");
+ }
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg);
+ }
+
+
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignVnf.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignVnf.java
index afa9b439db..e51774c12c 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignVnf.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignVnf.java
@@ -21,7 +21,6 @@
package org.onap.so.bpmn.infrastructure.flowspecific.tasks;
import java.util.List;
-
import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.infrastructure.common.name.generation.AAIObjectInstanceNameGenerator;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
@@ -37,27 +36,27 @@ import org.springframework.stereotype.Component;
@Component()
public class UnassignVnf {
- @Autowired
- private ExceptionBuilder exceptionUtil;
- @Autowired
- private ExtractPojosForBB extractPojosForBB;
- @Autowired
- private AAIInstanceGroupResources aaiInstanceGroupResources;
- @Autowired
- private AAIObjectInstanceNameGenerator aaiObjectInstanceNameGenerator;
-
- public void deleteInstanceGroups(BuildingBlockExecution execution) {
- try {
- GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- List<InstanceGroup> instanceGroups = vnf.getInstanceGroups();
- for(InstanceGroup instanceGroup : instanceGroups) {
- if(ModelInfoInstanceGroup.TYPE_VNFC.equalsIgnoreCase(instanceGroup.getModelInfoInstanceGroup().getType())) {
- aaiInstanceGroupResources.deleteInstanceGroup(instanceGroup);
- }
- }
- }
- catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+ @Autowired
+ private ExtractPojosForBB extractPojosForBB;
+ @Autowired
+ private AAIInstanceGroupResources aaiInstanceGroupResources;
+ @Autowired
+ private AAIObjectInstanceNameGenerator aaiObjectInstanceNameGenerator;
+
+ public void deleteInstanceGroups(BuildingBlockExecution execution) {
+ try {
+ GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ List<InstanceGroup> instanceGroups = vnf.getInstanceGroups();
+ for (InstanceGroup instanceGroup : instanceGroups) {
+ if (ModelInfoInstanceGroup.TYPE_VNFC
+ .equalsIgnoreCase(instanceGroup.getModelInfoInstanceGroup().getType())) {
+ aaiInstanceGroupResources.deleteInstanceGroup(instanceGroup);
+ }
+ }
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasks.java
index 9214635602..b906b8a662 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasks.java
@@ -2,7 +2,6 @@ package org.onap.so.bpmn.infrastructure.manualhandling.tasks;
import java.util.Map;
import java.util.HashMap;
-
import org.camunda.bpm.engine.TaskService;
import org.camunda.bpm.engine.delegate.BpmnError;
import org.camunda.bpm.engine.delegate.DelegateTask;
@@ -20,185 +19,188 @@ import org.springframework.stereotype.Component;
@Component
public class ManualHandlingTasks {
- private static final Logger logger = LoggerFactory.getLogger(ManualHandlingTasks.class);
-
- private static final String TASK_TYPE_PAUSE = "pause";
- private static final String TASK_TYPE_FALLOUT = "fallout";
-
- @Autowired
- private ExceptionBuilder exceptionUtil;
-
- @Autowired
- private RequestsDbClient requestDbclient;
-
- public void setFalloutTaskVariables (DelegateTask task) {
-
- DelegateExecution execution = task.getExecution();
- try {
- String taskId = task.getId();
- logger.debug("taskId is: " + taskId);
- String type = TASK_TYPE_FALLOUT;
- String nfRole = (String) execution.getVariable("vnfType");
- String subscriptionServiceType = (String) execution.getVariable("serviceType");
- String originalRequestId = (String) execution.getVariable("msoRequestId");
- String originalRequestorId = (String) execution.getVariable("requestorId");
- String description = "";
- String timeout = "";
- String errorSource = (String) execution.getVariable("failedActivity");
- String errorCode = (String) execution.getVariable("errorCode");
- String errorMessage = (String) execution.getVariable("errorText");
- String buildingBlockName = (String) execution.getVariable("currentActivity");
- String buildingBlockStep = (String) execution.getVariable("workStep");
- String validResponses = (String) execution.getVariable("validResponses");
-
- Map<String, String> taskVariables = new HashMap<String, String>();
- taskVariables.put("type", type);
- taskVariables.put("nfRole", nfRole);
- taskVariables.put("subscriptionServiceType", subscriptionServiceType);
- taskVariables.put("originalRequestId", originalRequestId);
- taskVariables.put("originalRequestorId", originalRequestorId);
- taskVariables.put("errorSource", errorSource);
- taskVariables.put("errorCode", errorCode);
- taskVariables.put("errorMessage", errorMessage);
- taskVariables.put("buildingBlockName", buildingBlockName);
- taskVariables.put("buildingBlockStep", buildingBlockStep);
- taskVariables.put("validResponses", validResponses);
- taskVariables.put("tmeout", timeout);
- taskVariables.put("description", description);
- TaskService taskService = execution.getProcessEngineServices().getTaskService();
-
- taskService.setVariables(taskId, taskVariables);
- logger.debug("successfully created fallout task: "+ taskId);
- } catch (BpmnError e) {
- logger.debug("BPMN exception: " + e.getMessage());
- throw e;
- } catch (Exception ex){
- String msg = "Exception in setFalloutTaskVariables " + ex.getMessage();
- logger.debug(msg);
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg);
- }
- }
-
- public void setPauseTaskVariables (DelegateTask task) {
-
- DelegateExecution execution = task.getExecution();
-
- try {
- String taskId = task.getId();
- logger.debug("taskId is: " + taskId);
- String type = TASK_TYPE_PAUSE;
- String nfRole = (String) execution.getVariable("vnfType");
- String subscriptionServiceType = (String) execution.getVariable("serviceType");
- String originalRequestId = (String) execution.getVariable("msoRequestId");
- String originalRequestorId = (String) execution.getVariable("requestorId");
- String description = (String) execution.getVariable("description");
- String timeout = (String) execution.getVariable("taskTimeout");
- String errorSource = "";
- String errorCode = "";
- String errorMessage = "";
- String buildingBlockName = "";
- String buildingBlockStep = "";
- String validResponses = (String) execution.getVariable("validResponses");
-
- Map<String, String> taskVariables = new HashMap<String, String>();
- taskVariables.put("type", type);
- taskVariables.put("nfRole", nfRole);
- taskVariables.put("description", description);
- taskVariables.put("timeout", timeout);
- taskVariables.put("subscriptionServiceType", subscriptionServiceType);
- taskVariables.put("originalRequestId", originalRequestId);
- taskVariables.put("originalRequestorId", originalRequestorId);
- taskVariables.put("errorSource", errorSource);
- taskVariables.put("errorCode", errorCode);
- taskVariables.put("errorMessage", errorMessage);
- taskVariables.put("buildingBlockName", buildingBlockName);
- taskVariables.put("buildingBlockStep", buildingBlockStep);
- taskVariables.put("validResponses", validResponses);
- TaskService taskService = execution.getProcessEngineServices().getTaskService();
-
- taskService.setVariables(taskId, taskVariables);
- logger.debug("successfully created pause task: "+ taskId);
- } catch (BpmnError e) {
- logger.debug("BPMN exception: " + e.getMessage());
- throw e;
- } catch (Exception ex){
- String msg = "Exception in setPauseTaskVariables " + ex.getMessage();
- logger.debug(msg);
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg);
- }
-
- }
-
- public void completeTask (DelegateTask task) {
-
- DelegateExecution execution = task.getExecution();
-
- try {
-
- String taskId = task.getId();
- logger.debug("taskId is: " + taskId);
- TaskService taskService = execution.getProcessEngineServices().getTaskService();
-
- Map<String, Object> taskVariables = taskService.getVariables(taskId);
- String responseValue = (String) taskVariables.get("responseValue");
-
- logger.debug("Received responseValue on completion: "+ responseValue);
- // Have to set the first letter of the response to upper case
- String responseValueUppercaseStart = responseValue.substring(0, 1).toUpperCase() + responseValue.substring(1);
- logger.debug("ResponseValue to taskListener: "+ responseValueUppercaseStart);
- execution.setVariable("responseValueTask", responseValueUppercaseStart);
-
- } catch (BpmnError e) {
- logger.debug("BPMN exception: " + e.getMessage());
- throw e;
- } catch (Exception ex){
- String msg = "Exception in completeManualTask " + ex.getMessage();
- logger.debug(msg);
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg);
- }
-
- }
-
- public void createExternalTicket (DelegateExecution execution) {
-
- try {
- ExternalTicket ticket = new ExternalTicket();
-
- ticket.setRequestId((String) execution.getVariable("msoRequestId"));
- ticket.setCurrentActivity((String) execution.getVariable("currentActivity"));
- ticket.setNfRole((String) execution.getVariable("vnfType"));
- ticket.setDescription((String) execution.getVariable("description"));
- ticket.setSubscriptionServiceType((String) execution.getVariable("serviceType"));
- ticket.setRequestorId((String) execution.getVariable("requestorId"));
- ticket.setTimeout((String) execution.getVariable("taskTimeout"));
- ticket.setErrorSource((String) execution.getVariable("failedActivity"));
- ticket.setErrorCode((String) execution.getVariable("errorCode"));
- ticket.setErrorMessage((String) execution.getVariable("errorText"));
- ticket.setWorkStep((String) execution.getVariable("workStep"));
-
- ticket.createTicket();
- } catch (BpmnError e) {
- String msg = "BPMN error in createAOTSTicket " + e.getMessage();
- logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", ErrorCode.UnknownError.getValue());
- } catch (Exception ex){
- String msg = "Exception in createExternalTicket " + ex.getMessage();
- logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", ErrorCode.UnknownError.getValue());
- }
-
- }
-
- public void updateRequestDbStatus(DelegateExecution execution, String status) {
- try {
- String requestId = (String) execution.getVariable("msoRequestId");
- InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId);
-
- request.setRequestStatus(status);
- request.setLastModifiedBy("ManualHandling");
-
- requestDbclient.updateInfraActiveRequests(request);
- } catch (Exception e) {
- logger.error("Unable to save the updated request status to the DB",e);
- }
- }
+ private static final Logger logger = LoggerFactory.getLogger(ManualHandlingTasks.class);
+
+ private static final String TASK_TYPE_PAUSE = "pause";
+ private static final String TASK_TYPE_FALLOUT = "fallout";
+
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+
+ @Autowired
+ private RequestsDbClient requestDbclient;
+
+ public void setFalloutTaskVariables(DelegateTask task) {
+
+ DelegateExecution execution = task.getExecution();
+ try {
+ String taskId = task.getId();
+ logger.debug("taskId is: " + taskId);
+ String type = TASK_TYPE_FALLOUT;
+ String nfRole = (String) execution.getVariable("vnfType");
+ String subscriptionServiceType = (String) execution.getVariable("serviceType");
+ String originalRequestId = (String) execution.getVariable("msoRequestId");
+ String originalRequestorId = (String) execution.getVariable("requestorId");
+ String description = "";
+ String timeout = "";
+ String errorSource = (String) execution.getVariable("failedActivity");
+ String errorCode = (String) execution.getVariable("errorCode");
+ String errorMessage = (String) execution.getVariable("errorText");
+ String buildingBlockName = (String) execution.getVariable("currentActivity");
+ String buildingBlockStep = (String) execution.getVariable("workStep");
+ String validResponses = (String) execution.getVariable("validResponses");
+
+ Map<String, String> taskVariables = new HashMap<String, String>();
+ taskVariables.put("type", type);
+ taskVariables.put("nfRole", nfRole);
+ taskVariables.put("subscriptionServiceType", subscriptionServiceType);
+ taskVariables.put("originalRequestId", originalRequestId);
+ taskVariables.put("originalRequestorId", originalRequestorId);
+ taskVariables.put("errorSource", errorSource);
+ taskVariables.put("errorCode", errorCode);
+ taskVariables.put("errorMessage", errorMessage);
+ taskVariables.put("buildingBlockName", buildingBlockName);
+ taskVariables.put("buildingBlockStep", buildingBlockStep);
+ taskVariables.put("validResponses", validResponses);
+ taskVariables.put("tmeout", timeout);
+ taskVariables.put("description", description);
+ TaskService taskService = execution.getProcessEngineServices().getTaskService();
+
+ taskService.setVariables(taskId, taskVariables);
+ logger.debug("successfully created fallout task: " + taskId);
+ } catch (BpmnError e) {
+ logger.debug("BPMN exception: " + e.getMessage());
+ throw e;
+ } catch (Exception ex) {
+ String msg = "Exception in setFalloutTaskVariables " + ex.getMessage();
+ logger.debug(msg);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg);
+ }
+ }
+
+ public void setPauseTaskVariables(DelegateTask task) {
+
+ DelegateExecution execution = task.getExecution();
+
+ try {
+ String taskId = task.getId();
+ logger.debug("taskId is: " + taskId);
+ String type = TASK_TYPE_PAUSE;
+ String nfRole = (String) execution.getVariable("vnfType");
+ String subscriptionServiceType = (String) execution.getVariable("serviceType");
+ String originalRequestId = (String) execution.getVariable("msoRequestId");
+ String originalRequestorId = (String) execution.getVariable("requestorId");
+ String description = (String) execution.getVariable("description");
+ String timeout = (String) execution.getVariable("taskTimeout");
+ String errorSource = "";
+ String errorCode = "";
+ String errorMessage = "";
+ String buildingBlockName = "";
+ String buildingBlockStep = "";
+ String validResponses = (String) execution.getVariable("validResponses");
+
+ Map<String, String> taskVariables = new HashMap<String, String>();
+ taskVariables.put("type", type);
+ taskVariables.put("nfRole", nfRole);
+ taskVariables.put("description", description);
+ taskVariables.put("timeout", timeout);
+ taskVariables.put("subscriptionServiceType", subscriptionServiceType);
+ taskVariables.put("originalRequestId", originalRequestId);
+ taskVariables.put("originalRequestorId", originalRequestorId);
+ taskVariables.put("errorSource", errorSource);
+ taskVariables.put("errorCode", errorCode);
+ taskVariables.put("errorMessage", errorMessage);
+ taskVariables.put("buildingBlockName", buildingBlockName);
+ taskVariables.put("buildingBlockStep", buildingBlockStep);
+ taskVariables.put("validResponses", validResponses);
+ TaskService taskService = execution.getProcessEngineServices().getTaskService();
+
+ taskService.setVariables(taskId, taskVariables);
+ logger.debug("successfully created pause task: " + taskId);
+ } catch (BpmnError e) {
+ logger.debug("BPMN exception: " + e.getMessage());
+ throw e;
+ } catch (Exception ex) {
+ String msg = "Exception in setPauseTaskVariables " + ex.getMessage();
+ logger.debug(msg);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg);
+ }
+
+ }
+
+ public void completeTask(DelegateTask task) {
+
+ DelegateExecution execution = task.getExecution();
+
+ try {
+
+ String taskId = task.getId();
+ logger.debug("taskId is: " + taskId);
+ TaskService taskService = execution.getProcessEngineServices().getTaskService();
+
+ Map<String, Object> taskVariables = taskService.getVariables(taskId);
+ String responseValue = (String) taskVariables.get("responseValue");
+
+ logger.debug("Received responseValue on completion: " + responseValue);
+ // Have to set the first letter of the response to upper case
+ String responseValueUppercaseStart =
+ responseValue.substring(0, 1).toUpperCase() + responseValue.substring(1);
+ logger.debug("ResponseValue to taskListener: " + responseValueUppercaseStart);
+ execution.setVariable("responseValueTask", responseValueUppercaseStart);
+
+ } catch (BpmnError e) {
+ logger.debug("BPMN exception: " + e.getMessage());
+ throw e;
+ } catch (Exception ex) {
+ String msg = "Exception in completeManualTask " + ex.getMessage();
+ logger.debug(msg);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg);
+ }
+
+ }
+
+ public void createExternalTicket(DelegateExecution execution) {
+
+ try {
+ ExternalTicket ticket = new ExternalTicket();
+
+ ticket.setRequestId((String) execution.getVariable("msoRequestId"));
+ ticket.setCurrentActivity((String) execution.getVariable("currentActivity"));
+ ticket.setNfRole((String) execution.getVariable("vnfType"));
+ ticket.setDescription((String) execution.getVariable("description"));
+ ticket.setSubscriptionServiceType((String) execution.getVariable("serviceType"));
+ ticket.setRequestorId((String) execution.getVariable("requestorId"));
+ ticket.setTimeout((String) execution.getVariable("taskTimeout"));
+ ticket.setErrorSource((String) execution.getVariable("failedActivity"));
+ ticket.setErrorCode((String) execution.getVariable("errorCode"));
+ ticket.setErrorMessage((String) execution.getVariable("errorText"));
+ ticket.setWorkStep((String) execution.getVariable("workStep"));
+
+ ticket.createTicket();
+ } catch (BpmnError e) {
+ String msg = "BPMN error in createAOTSTicket " + e.getMessage();
+ logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN",
+ ErrorCode.UnknownError.getValue());
+ } catch (Exception ex) {
+ String msg = "Exception in createExternalTicket " + ex.getMessage();
+ logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN",
+ ErrorCode.UnknownError.getValue());
+ }
+
+ }
+
+ public void updateRequestDbStatus(DelegateExecution execution, String status) {
+ try {
+ String requestId = (String) execution.getVariable("msoRequestId");
+ InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId);
+
+ request.setRequestStatus(status);
+ request.setLastModifiedBy("ManualHandling");
+
+ requestDbclient.updateInfraActiveRequests(request);
+ } catch (Exception e) {
+ logger.error("Unable to save the updated request status to the DB", e);
+ }
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasks.java
index 119716a58d..d248ad5443 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasks.java
@@ -32,25 +32,26 @@ import org.springframework.stereotype.Component;
@Component
public class NamingServiceCreateTasks {
-
- @Autowired
- private ExceptionBuilder exceptionUtil;
- @Autowired
- private ExtractPojosForBB extractPojosForBB;
-
- @Autowired
- private NamingServiceResources namingServiceResources;
-
- public void createInstanceGroupName(BuildingBlockExecution execution) throws Exception {
- InstanceGroup instanceGroup = extractPojosForBB.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID);
- String policyInstanceName = execution.getVariable("policyInstanceName");
- String nfNamingCode = execution.getVariable("nfNamingCode");
- String generatedInstanceGroupName = "";
- try {
- generatedInstanceGroupName = namingServiceResources.generateInstanceGroupName(instanceGroup, policyInstanceName, nfNamingCode);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- instanceGroup.setInstanceGroupName(generatedInstanceGroupName);
- }
+
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+ @Autowired
+ private ExtractPojosForBB extractPojosForBB;
+
+ @Autowired
+ private NamingServiceResources namingServiceResources;
+
+ public void createInstanceGroupName(BuildingBlockExecution execution) throws Exception {
+ InstanceGroup instanceGroup = extractPojosForBB.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID);
+ String policyInstanceName = execution.getVariable("policyInstanceName");
+ String nfNamingCode = execution.getVariable("nfNamingCode");
+ String generatedInstanceGroupName = "";
+ try {
+ generatedInstanceGroupName =
+ namingServiceResources.generateInstanceGroupName(instanceGroup, policyInstanceName, nfNamingCode);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ instanceGroup.setInstanceGroupName(generatedInstanceGroupName);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceDeleteTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceDeleteTasks.java
index c998e4aa75..9a8c9df8b5 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceDeleteTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceDeleteTasks.java
@@ -32,22 +32,22 @@ import org.springframework.stereotype.Component;
@Component
public class NamingServiceDeleteTasks {
-
- @Autowired
- private ExceptionBuilder exceptionUtil;
- @Autowired
- private ExtractPojosForBB extractPojosForBB;
-
- @Autowired
- private NamingServiceResources namingServiceResources;
-
- public void deleteInstanceGroupName(BuildingBlockExecution execution) throws Exception {
- InstanceGroup instanceGroup = extractPojosForBB.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID);
-
- try {
- namingServiceResources.deleteInstanceGroupName(instanceGroup);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
+
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+ @Autowired
+ private ExtractPojosForBB extractPojosForBB;
+
+ @Autowired
+ private NamingServiceResources namingServiceResources;
+
+ public void deleteInstanceGroupName(BuildingBlockExecution execution) throws Exception {
+ InstanceGroup instanceGroup = extractPojosForBB.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID);
+
+ try {
+ namingServiceResources.deleteInstanceGroupName(instanceGroup);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/exceptions/SDNCErrorResponseException.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/exceptions/SDNCErrorResponseException.java
index e0f88a20a5..d76d860b3b 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/exceptions/SDNCErrorResponseException.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/exceptions/SDNCErrorResponseException.java
@@ -2,12 +2,12 @@ package org.onap.so.bpmn.infrastructure.sdnc.exceptions;
public class SDNCErrorResponseException extends Exception {
- /**
- *
- */
- private static final long serialVersionUID = 7807799223298140702L;
-
- public SDNCErrorResponseException(String message) {
- super(message);
- }
+ /**
+ *
+ */
+ private static final long serialVersionUID = 7807799223298140702L;
+
+ public SDNCErrorResponseException(String message) {
+ super(message);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTasks.java
index 31f4b33e0c..7a0008d5a2 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTasks.java
@@ -50,80 +50,85 @@ import org.springframework.stereotype.Component;
@Component
public class SDNCActivateTasks {
- private static final Logger logger = LoggerFactory.getLogger(SDNCActivateTasks.class);
- @Autowired
- private SDNCVnfResources sdncVnfResources;
- @Autowired
- private ExceptionBuilder exceptionUtil;
- @Autowired
- private ExtractPojosForBB extractPojosForBB;
- @Autowired
- private SDNCNetworkResources sdncNetworkResources;
- @Autowired
- private SDNCVfModuleResources sdncVfModuleResources;
+ private static final Logger logger = LoggerFactory.getLogger(SDNCActivateTasks.class);
+ @Autowired
+ private SDNCVnfResources sdncVnfResources;
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+ @Autowired
+ private ExtractPojosForBB extractPojosForBB;
+ @Autowired
+ private SDNCNetworkResources sdncNetworkResources;
+ @Autowired
+ private SDNCVfModuleResources sdncVfModuleResources;
- public void activateVnf(BuildingBlockExecution execution) {
- try {
- GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
- RequestContext requestContext = gBBInput.getRequestContext();
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- CloudRegion cloudRegion = gBBInput.getCloudRegion();
- Customer customer = gBBInput.getCustomer();
- GenericResourceApiVnfOperationInformation req = sdncVnfResources.activateVnf(vnf, serviceInstance, customer, cloudRegion, requestContext);
- SDNCRequest sdncRequest = new SDNCRequest();
- sdncRequest.setSDNCPayload(req);
- sdncRequest.setTopology(SDNCTopology.VNF);
- execution.setVariable("SDNCRequest", sdncRequest);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- /**
- * BPMN access method to perform Assign action on SDNC for L3Network
- * @param execution
- * @throws BBObjectNotFoundException
- */
- public void activateNetwork(BuildingBlockExecution execution) throws BBObjectNotFoundException {
- try{
- GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
- L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- Customer customer = gBBInput.getCustomer();
- RequestContext requestContext = gBBInput.getRequestContext();
- CloudRegion cloudRegion = gBBInput.getCloudRegion();
- GenericResourceApiNetworkOperationInformation req = sdncNetworkResources.activateNetwork(l3network, serviceInstance, customer, requestContext, cloudRegion);
- SDNCRequest sdncRequest = new SDNCRequest();
- sdncRequest.setSDNCPayload(req);
- sdncRequest.setTopology(SDNCTopology.NETWORK);
- execution.setVariable("SDNCRequest", sdncRequest);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void activateVfModule(BuildingBlockExecution execution) {
- GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
- RequestContext requestContext = gBBInput.getRequestContext();
- ServiceInstance serviceInstance = null;
- GenericVnf vnf = null;
- VfModule vfModule = null;
- try {
- serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
- Customer customer = gBBInput.getCustomer();
- CloudRegion cloudRegion = gBBInput.getCloudRegion();
- GenericResourceApiVfModuleOperationInformation req = sdncVfModuleResources.activateVfModule(vfModule, vnf, serviceInstance, customer,
- cloudRegion, requestContext);
- SDNCRequest sdncRequest = new SDNCRequest();
- sdncRequest.setSDNCPayload(req);
- sdncRequest.setTopology(SDNCTopology.VFMODULE);
- execution.setVariable("SDNCRequest", sdncRequest);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
+ public void activateVnf(BuildingBlockExecution execution) {
+ try {
+ GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+ RequestContext requestContext = gBBInput.getRequestContext();
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ CloudRegion cloudRegion = gBBInput.getCloudRegion();
+ Customer customer = gBBInput.getCustomer();
+ GenericResourceApiVnfOperationInformation req =
+ sdncVnfResources.activateVnf(vnf, serviceInstance, customer, cloudRegion, requestContext);
+ SDNCRequest sdncRequest = new SDNCRequest();
+ sdncRequest.setSDNCPayload(req);
+ sdncRequest.setTopology(SDNCTopology.VNF);
+ execution.setVariable("SDNCRequest", sdncRequest);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ /**
+ * BPMN access method to perform Assign action on SDNC for L3Network
+ *
+ * @param execution
+ * @throws BBObjectNotFoundException
+ */
+ public void activateNetwork(BuildingBlockExecution execution) throws BBObjectNotFoundException {
+ try {
+ GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+ L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ Customer customer = gBBInput.getCustomer();
+ RequestContext requestContext = gBBInput.getRequestContext();
+ CloudRegion cloudRegion = gBBInput.getCloudRegion();
+ GenericResourceApiNetworkOperationInformation req = sdncNetworkResources.activateNetwork(l3network,
+ serviceInstance, customer, requestContext, cloudRegion);
+ SDNCRequest sdncRequest = new SDNCRequest();
+ sdncRequest.setSDNCPayload(req);
+ sdncRequest.setTopology(SDNCTopology.NETWORK);
+ execution.setVariable("SDNCRequest", sdncRequest);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void activateVfModule(BuildingBlockExecution execution) {
+ GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+ RequestContext requestContext = gBBInput.getRequestContext();
+ ServiceInstance serviceInstance = null;
+ GenericVnf vnf = null;
+ VfModule vfModule = null;
+ try {
+ serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
+ Customer customer = gBBInput.getCustomer();
+ CloudRegion cloudRegion = gBBInput.getCloudRegion();
+ GenericResourceApiVfModuleOperationInformation req = sdncVfModuleResources.activateVfModule(vfModule, vnf,
+ serviceInstance, customer, cloudRegion, requestContext);
+ SDNCRequest sdncRequest = new SDNCRequest();
+ sdncRequest.setSDNCPayload(req);
+ sdncRequest.setTopology(SDNCTopology.VFMODULE);
+ execution.setVariable("SDNCRequest", sdncRequest);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasks.java
index cbb1f34ae5..d3878f06b7 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasks.java
@@ -53,99 +53,108 @@ import org.springframework.stereotype.Component;
@Component
public class SDNCAssignTasks {
- private static final Logger logger = LoggerFactory.getLogger(SDNCAssignTasks.class);
- @Autowired
- private SDNCServiceInstanceResources sdncSIResources;
- @Autowired
- private SDNCVnfResources sdncVnfResources;
- @Autowired
- private SDNCVfModuleResources sdncVfModuleResources;
- @Autowired
- private ExceptionBuilder exceptionUtil;
- @Autowired
- private ExtractPojosForBB extractPojosForBB;
- @Autowired
- private SDNCNetworkResources sdncNetworkResources;
+ private static final Logger logger = LoggerFactory.getLogger(SDNCAssignTasks.class);
+ @Autowired
+ private SDNCServiceInstanceResources sdncSIResources;
+ @Autowired
+ private SDNCVnfResources sdncVnfResources;
+ @Autowired
+ private SDNCVfModuleResources sdncVfModuleResources;
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+ @Autowired
+ private ExtractPojosForBB extractPojosForBB;
+ @Autowired
+ private SDNCNetworkResources sdncNetworkResources;
- public void assignServiceInstance(BuildingBlockExecution execution) {
- try {
- GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
- RequestContext requestContext = gBBInput.getRequestContext();
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- Customer customer = gBBInput.getCustomer();
- GenericResourceApiServiceOperationInformation req = sdncSIResources.assignServiceInstance(serviceInstance, customer, requestContext);
- SDNCRequest sdncRequest = new SDNCRequest();
- sdncRequest.setSDNCPayload(req);
- sdncRequest.setTopology(SDNCTopology.SERVICE);
- execution.setVariable("SDNCRequest", sdncRequest);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
+ public void assignServiceInstance(BuildingBlockExecution execution) {
+ try {
+ GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+ RequestContext requestContext = gBBInput.getRequestContext();
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ Customer customer = gBBInput.getCustomer();
+ GenericResourceApiServiceOperationInformation req =
+ sdncSIResources.assignServiceInstance(serviceInstance, customer, requestContext);
+ SDNCRequest sdncRequest = new SDNCRequest();
+ sdncRequest.setSDNCPayload(req);
+ sdncRequest.setTopology(SDNCTopology.SERVICE);
+ execution.setVariable("SDNCRequest", sdncRequest);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
- public void assignVnf(BuildingBlockExecution execution) {
- try {
- GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
- RequestContext requestContext = gBBInput.getRequestContext();
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- Customer customer = gBBInput.getCustomer();
- CloudRegion cloudRegion = gBBInput.getCloudRegion();
- GenericResourceApiVnfOperationInformation req = sdncVnfResources.assignVnf(vnf, serviceInstance, customer, cloudRegion, requestContext, Boolean.TRUE.equals(vnf.isCallHoming()));
- SDNCRequest sdncRequest = new SDNCRequest();
- sdncRequest.setSDNCPayload(req);
- sdncRequest.setTopology(SDNCTopology.VNF);
- execution.setVariable("SDNCRequest", sdncRequest);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
+ public void assignVnf(BuildingBlockExecution execution) {
+ try {
+ GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+ RequestContext requestContext = gBBInput.getRequestContext();
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ Customer customer = gBBInput.getCustomer();
+ CloudRegion cloudRegion = gBBInput.getCloudRegion();
+ GenericResourceApiVnfOperationInformation req = sdncVnfResources.assignVnf(vnf, serviceInstance, customer,
+ cloudRegion, requestContext, Boolean.TRUE.equals(vnf.isCallHoming()));
+ SDNCRequest sdncRequest = new SDNCRequest();
+ sdncRequest.setSDNCPayload(req);
+ sdncRequest.setTopology(SDNCTopology.VNF);
+ execution.setVariable("SDNCRequest", sdncRequest);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
- public void assignVfModule(BuildingBlockExecution execution) {
- try {
- GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
- RequestContext requestContext = gBBInput.getRequestContext();
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
- VolumeGroup volumeGroup = null;
- try{
- volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
- } catch (BBObjectNotFoundException e){
- logger.info("No volume group was found.");
- }
- Customer customer = gBBInput.getCustomer();
- CloudRegion cloudRegion = gBBInput.getCloudRegion();
- GenericResourceApiVfModuleOperationInformation req = sdncVfModuleResources.assignVfModule(vfModule, volumeGroup, vnf, serviceInstance, customer, cloudRegion, requestContext);
- SDNCRequest sdncRequest = new SDNCRequest();
- sdncRequest.setSDNCPayload(req);
- sdncRequest.setTopology(SDNCTopology.VFMODULE);
- execution.setVariable("SDNCRequest", sdncRequest);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
+ public void assignVfModule(BuildingBlockExecution execution) {
+ try {
+ GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+ RequestContext requestContext = gBBInput.getRequestContext();
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
+ VolumeGroup volumeGroup = null;
+ try {
+ volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
+ } catch (BBObjectNotFoundException e) {
+ logger.info("No volume group was found.");
+ }
+ Customer customer = gBBInput.getCustomer();
+ CloudRegion cloudRegion = gBBInput.getCloudRegion();
+ GenericResourceApiVfModuleOperationInformation req = sdncVfModuleResources.assignVfModule(vfModule,
+ volumeGroup, vnf, serviceInstance, customer, cloudRegion, requestContext);
+ SDNCRequest sdncRequest = new SDNCRequest();
+ sdncRequest.setSDNCPayload(req);
+ sdncRequest.setTopology(SDNCTopology.VFMODULE);
+ execution.setVariable("SDNCRequest", sdncRequest);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
- /**
- * BPMN access method to perform Assign action on SDNC for L3Network
- * @param execution
- * @throws Exception
- */
- public void assignNetwork(BuildingBlockExecution execution) {
- try {
- GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
- L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- Customer customer = gBBInput.getCustomer();
- RequestContext requestContext = gBBInput.getRequestContext();
- CloudRegion cloudRegion = gBBInput.getCloudRegion();
- GenericResourceApiNetworkOperationInformation req = sdncNetworkResources.assignNetwork(l3network, serviceInstance, customer, requestContext, cloudRegion);
- SDNCRequest sdncRequest = new SDNCRequest();
- sdncRequest.setSDNCPayload(req);
- sdncRequest.setTopology(SDNCTopology.NETWORK);
- execution.setVariable("SDNCRequest", sdncRequest);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
+ /**
+ * BPMN access method to perform Assign action on SDNC for L3Network
+ *
+ * @param execution
+ * @throws Exception
+ */
+ public void assignNetwork(BuildingBlockExecution execution) {
+ try {
+ GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+ L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ Customer customer = gBBInput.getCustomer();
+ RequestContext requestContext = gBBInput.getRequestContext();
+ CloudRegion cloudRegion = gBBInput.getCloudRegion();
+ GenericResourceApiNetworkOperationInformation req = sdncNetworkResources.assignNetwork(l3network,
+ serviceInstance, customer, requestContext, cloudRegion);
+ SDNCRequest sdncRequest = new SDNCRequest();
+ sdncRequest.setSDNCPayload(req);
+ sdncRequest.setTopology(SDNCTopology.NETWORK);
+ execution.setVariable("SDNCRequest", sdncRequest);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasks.java
index 59e46e1667..50cf0fb074 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasks.java
@@ -47,79 +47,87 @@ import org.springframework.stereotype.Component;
@Component
public class SDNCChangeAssignTasks {
- @Autowired
- private SDNCNetworkResources sdncNetworkResources;
- @Autowired
- private SDNCServiceInstanceResources sdncServiceInstanceResources;
- @Autowired
- private SDNCVnfResources sdncVnfResources;
- @Autowired
- private ExtractPojosForBB extractPojosForBB;
- @Autowired
- private ExceptionBuilder exceptionUtil;
- @Autowired
- private SDNCVfModuleResources sdncVfModuleResources;
-
- public void changeModelServiceInstance(BuildingBlockExecution execution) {
- try {
- GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- GenericResourceApiServiceOperationInformation req = sdncServiceInstanceResources.changeModelServiceInstance(serviceInstance, gBBInput.getCustomer(), gBBInput.getRequestContext());
- SDNCRequest sdncRequest = new SDNCRequest();
- sdncRequest.setSDNCPayload(req);
- sdncRequest.setTopology(SDNCTopology.SERVICE);
- execution.setVariable("SDNCRequest", sdncRequest);
- } catch(Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void changeModelVnf(BuildingBlockExecution execution) {
- try {
- GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
- GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- GenericResourceApiVnfOperationInformation req = sdncVnfResources.changeModelVnf(genericVnf, serviceInstance, gBBInput.getCustomer(), gBBInput.getCloudRegion(), gBBInput.getRequestContext());
- SDNCRequest sdncRequest = new SDNCRequest();
- sdncRequest.setSDNCPayload(req);
- sdncRequest.setTopology(SDNCTopology.VNF);
- execution.setVariable("SDNCRequest", sdncRequest);
- } catch(Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void changeAssignNetwork(BuildingBlockExecution execution) {
- try {
- GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
- L3Network network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- GenericResourceApiNetworkOperationInformation req = sdncNetworkResources.changeAssignNetwork(network, serviceInstance, gBBInput.getCustomer(), gBBInput.getRequestContext(), gBBInput.getCloudRegion());
- SDNCRequest sdncRequest = new SDNCRequest();
- sdncRequest.setSDNCPayload(req);
- sdncRequest.setTopology(SDNCTopology.NETWORK);
- execution.setVariable("SDNCRequest", sdncRequest);
- } catch(Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void changeAssignModelVfModule(BuildingBlockExecution execution) throws Exception {
- try {
- GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
- RequestContext requestContext = gBBInput.getRequestContext();
- CloudRegion cloudRegion = gBBInput.getCloudRegion();
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
- Customer customer = gBBInput.getCustomer();
- GenericResourceApiVfModuleOperationInformation req = sdncVfModuleResources.changeAssignVfModule(vfModule, vnf, serviceInstance, customer, cloudRegion, requestContext);
- SDNCRequest sdncRequest = new SDNCRequest();
- sdncRequest.setSDNCPayload(req);
- sdncRequest.setTopology(SDNCTopology.VFMODULE);
- execution.setVariable("SDNCRequest", sdncRequest);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
+ @Autowired
+ private SDNCNetworkResources sdncNetworkResources;
+ @Autowired
+ private SDNCServiceInstanceResources sdncServiceInstanceResources;
+ @Autowired
+ private SDNCVnfResources sdncVnfResources;
+ @Autowired
+ private ExtractPojosForBB extractPojosForBB;
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+ @Autowired
+ private SDNCVfModuleResources sdncVfModuleResources;
+
+ public void changeModelServiceInstance(BuildingBlockExecution execution) {
+ try {
+ GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ GenericResourceApiServiceOperationInformation req = sdncServiceInstanceResources
+ .changeModelServiceInstance(serviceInstance, gBBInput.getCustomer(), gBBInput.getRequestContext());
+ SDNCRequest sdncRequest = new SDNCRequest();
+ sdncRequest.setSDNCPayload(req);
+ sdncRequest.setTopology(SDNCTopology.SERVICE);
+ execution.setVariable("SDNCRequest", sdncRequest);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void changeModelVnf(BuildingBlockExecution execution) {
+ try {
+ GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+ GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ GenericResourceApiVnfOperationInformation req = sdncVnfResources.changeModelVnf(genericVnf, serviceInstance,
+ gBBInput.getCustomer(), gBBInput.getCloudRegion(), gBBInput.getRequestContext());
+ SDNCRequest sdncRequest = new SDNCRequest();
+ sdncRequest.setSDNCPayload(req);
+ sdncRequest.setTopology(SDNCTopology.VNF);
+ execution.setVariable("SDNCRequest", sdncRequest);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void changeAssignNetwork(BuildingBlockExecution execution) {
+ try {
+ GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+ L3Network network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ GenericResourceApiNetworkOperationInformation req = sdncNetworkResources.changeAssignNetwork(network,
+ serviceInstance, gBBInput.getCustomer(), gBBInput.getRequestContext(), gBBInput.getCloudRegion());
+ SDNCRequest sdncRequest = new SDNCRequest();
+ sdncRequest.setSDNCPayload(req);
+ sdncRequest.setTopology(SDNCTopology.NETWORK);
+ execution.setVariable("SDNCRequest", sdncRequest);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void changeAssignModelVfModule(BuildingBlockExecution execution) throws Exception {
+ try {
+ GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+ RequestContext requestContext = gBBInput.getRequestContext();
+ CloudRegion cloudRegion = gBBInput.getCloudRegion();
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
+ Customer customer = gBBInput.getCustomer();
+ GenericResourceApiVfModuleOperationInformation req = sdncVfModuleResources.changeAssignVfModule(vfModule,
+ vnf, serviceInstance, customer, cloudRegion, requestContext);
+ SDNCRequest sdncRequest = new SDNCRequest();
+ sdncRequest.setSDNCPayload(req);
+ sdncRequest.setTopology(SDNCTopology.VFMODULE);
+ execution.setVariable("SDNCRequest", sdncRequest);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTasks.java
index 8202a14fa3..3a1528946d 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTasks.java
@@ -51,106 +51,115 @@ import org.springframework.stereotype.Component;
@Component
public class SDNCDeactivateTasks {
- private static final Logger logger = LoggerFactory.getLogger(SDNCDeactivateTasks.class);
- @Autowired
- private SDNCNetworkResources sdncNetworkResources;
- @Autowired
- private SDNCVfModuleResources sdncVfModuleResources;
- @Autowired
- private SDNCServiceInstanceResources sdncSIResources;
- @Autowired
- private SDNCVnfResources sdncVnfResources;
- @Autowired
- private ExceptionBuilder exceptionUtil;
- @Autowired
- private ExtractPojosForBB extractPojosForBB;
+ private static final Logger logger = LoggerFactory.getLogger(SDNCDeactivateTasks.class);
+ @Autowired
+ private SDNCNetworkResources sdncNetworkResources;
+ @Autowired
+ private SDNCVfModuleResources sdncVfModuleResources;
+ @Autowired
+ private SDNCServiceInstanceResources sdncSIResources;
+ @Autowired
+ private SDNCVnfResources sdncVnfResources;
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+ @Autowired
+ private ExtractPojosForBB extractPojosForBB;
- public void deactivateVfModule(BuildingBlockExecution execution) {
- try {
- GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
- RequestContext requestContext = gBBInput.getRequestContext();
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
- Customer customer = gBBInput.getCustomer();
- CloudRegion cloudRegion = gBBInput.getCloudRegion();
- GenericResourceApiVfModuleOperationInformation req = sdncVfModuleResources.deactivateVfModule(vfModule, vnf, serviceInstance, customer,
- cloudRegion, requestContext);
- SDNCRequest sdncRequest = new SDNCRequest();
- sdncRequest.setSDNCPayload(req);
- sdncRequest.setTopology(SDNCTopology.VFMODULE);
- execution.setVariable("SDNCRequest", sdncRequest); } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
+ public void deactivateVfModule(BuildingBlockExecution execution) {
+ try {
+ GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+ RequestContext requestContext = gBBInput.getRequestContext();
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
+ Customer customer = gBBInput.getCustomer();
+ CloudRegion cloudRegion = gBBInput.getCloudRegion();
+ GenericResourceApiVfModuleOperationInformation req = sdncVfModuleResources.deactivateVfModule(vfModule, vnf,
+ serviceInstance, customer, cloudRegion, requestContext);
+ SDNCRequest sdncRequest = new SDNCRequest();
+ sdncRequest.setSDNCPayload(req);
+ sdncRequest.setTopology(SDNCTopology.VFMODULE);
+ execution.setVariable("SDNCRequest", sdncRequest);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
- /**
- * BPMN access method to perform Service Topology Deactivate action on SDNC for Vnf
- * @param execution
- * @throws Exception
- */
- public void deactivateVnf(BuildingBlockExecution execution) throws Exception {
- try {
- GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
- RequestContext requestContext = gBBInput.getRequestContext();
- ServiceInstance serviceInstance = null;
- GenericVnf vnf = null;
- serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- CloudRegion cloudRegion = gBBInput.getCloudRegion();
- Customer customer = gBBInput.getCustomer();
- GenericResourceApiVnfOperationInformation req = sdncVnfResources.deactivateVnf(vnf, serviceInstance, customer, cloudRegion, requestContext);
- SDNCRequest sdncRequest = new SDNCRequest();
- sdncRequest.setSDNCPayload(req);
- sdncRequest.setTopology(SDNCTopology.VNF);
- execution.setVariable("SDNCRequest", sdncRequest);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
+ /**
+ * BPMN access method to perform Service Topology Deactivate action on SDNC for Vnf
+ *
+ * @param execution
+ * @throws Exception
+ */
+ public void deactivateVnf(BuildingBlockExecution execution) throws Exception {
+ try {
+ GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+ RequestContext requestContext = gBBInput.getRequestContext();
+ ServiceInstance serviceInstance = null;
+ GenericVnf vnf = null;
+ serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ CloudRegion cloudRegion = gBBInput.getCloudRegion();
+ Customer customer = gBBInput.getCustomer();
+ GenericResourceApiVnfOperationInformation req =
+ sdncVnfResources.deactivateVnf(vnf, serviceInstance, customer, cloudRegion, requestContext);
+ SDNCRequest sdncRequest = new SDNCRequest();
+ sdncRequest.setSDNCPayload(req);
+ sdncRequest.setTopology(SDNCTopology.VNF);
+ execution.setVariable("SDNCRequest", sdncRequest);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
- /*
- * BPMN access method to perform Service Topology Deactivate action on SDNC for Service Instance
- * @param execution
- * @throws Exception
- */
- public void deactivateServiceInstance(BuildingBlockExecution execution) throws Exception {
- try {
- GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
- RequestContext requestContext = gBBInput.getRequestContext();
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- Customer customer = gBBInput.getCustomer();
- GenericResourceApiServiceOperationInformation req = sdncSIResources.deactivateServiceInstance(serviceInstance, customer, requestContext);
- SDNCRequest sdncRequest = new SDNCRequest();
- sdncRequest.setSDNCPayload(req);
- sdncRequest.setTopology(SDNCTopology.SERVICE);
- execution.setVariable("SDNCRequest", sdncRequest);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
+ /*
+ * BPMN access method to perform Service Topology Deactivate action on SDNC for Service Instance
+ *
+ * @param execution
+ *
+ * @throws Exception
+ */
+ public void deactivateServiceInstance(BuildingBlockExecution execution) throws Exception {
+ try {
+ GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+ RequestContext requestContext = gBBInput.getRequestContext();
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ Customer customer = gBBInput.getCustomer();
+ GenericResourceApiServiceOperationInformation req =
+ sdncSIResources.deactivateServiceInstance(serviceInstance, customer, requestContext);
+ SDNCRequest sdncRequest = new SDNCRequest();
+ sdncRequest.setSDNCPayload(req);
+ sdncRequest.setTopology(SDNCTopology.SERVICE);
+ execution.setVariable("SDNCRequest", sdncRequest);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
- /**
- * BPMN access method to invoke deactivate on a L3Network object
- *
- * @param execution
- */
- public void deactivateNetwork(BuildingBlockExecution execution) {
- try {
- GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
- L3Network l3Network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- Customer customer = gBBInput.getCustomer();
- RequestContext requestContext = gBBInput.getRequestContext();
- CloudRegion cloudRegion = gBBInput.getCloudRegion();
- GenericResourceApiNetworkOperationInformation req = sdncNetworkResources.deactivateNetwork(l3Network, serviceInstance, customer,
- requestContext, cloudRegion);
- SDNCRequest sdncRequest = new SDNCRequest();
- sdncRequest.setSDNCPayload(req);
- sdncRequest.setTopology(SDNCTopology.NETWORK);
- execution.setVariable("SDNCRequest", sdncRequest);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
+ /**
+ * BPMN access method to invoke deactivate on a L3Network object
+ *
+ * @param execution
+ */
+ public void deactivateNetwork(BuildingBlockExecution execution) {
+ try {
+ GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+ L3Network l3Network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ Customer customer = gBBInput.getCustomer();
+ RequestContext requestContext = gBBInput.getRequestContext();
+ CloudRegion cloudRegion = gBBInput.getCloudRegion();
+ GenericResourceApiNetworkOperationInformation req = sdncNetworkResources.deactivateNetwork(l3Network,
+ serviceInstance, customer, requestContext, cloudRegion);
+ SDNCRequest sdncRequest = new SDNCRequest();
+ sdncRequest.setSDNCPayload(req);
+ sdncRequest.setTopology(SDNCTopology.NETWORK);
+ execution.setVariable("SDNCRequest", sdncRequest);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCQueryTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCQueryTasks.java
index 941eb7a004..7ae6117c61 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCQueryTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCQueryTasks.java
@@ -39,77 +39,79 @@ import org.springframework.stereotype.Component;
@Component
public class SDNCQueryTasks {
- private static final Logger logger = LoggerFactory.getLogger(SDNCQueryTasks.class);
- @Autowired
- private SDNCVnfResources sdncVnfResources;
- @Autowired
- private SDNCVfModuleResources sdncVfModuleResources;
- @Autowired
- private ExceptionBuilder exceptionUtil;
- @Autowired
- private ExtractPojosForBB extractPojosForBB;
-
- public void queryVnf(BuildingBlockExecution execution) throws Exception {
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
-
- String selfLink = "restconf/config/GENERIC-RESOURCE-API:services/service/"
- + serviceInstance.getServiceInstanceId() + "/service-data/vnfs/vnf/"
- + genericVnf.getVnfId() + "/vnf-data/vnf-topology/";
- try {
- if(genericVnf.getSelflink() == null) {
- genericVnf.setSelflink(selfLink);
- }
- String response = sdncVnfResources.queryVnf(genericVnf);
- execution.setVariable("SDNCQueryResponse_" + genericVnf.getVnfId(), response);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
+ private static final Logger logger = LoggerFactory.getLogger(SDNCQueryTasks.class);
+ @Autowired
+ private SDNCVnfResources sdncVnfResources;
+ @Autowired
+ private SDNCVfModuleResources sdncVfModuleResources;
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+ @Autowired
+ private ExtractPojosForBB extractPojosForBB;
-
- public void queryVfModule(BuildingBlockExecution execution) throws Exception {
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
- String selfLink = "restconf/config/GENERIC-RESOURCE-API:services/service/"
- + serviceInstance.getServiceInstanceId() + "/service-data/vnfs/vnf/"
- + genericVnf.getVnfId() + "/vnf-data/vf-modules/vf-module/"
- + vfModule.getVfModuleId() + "/vf-module-data/vf-module-topology/";
- try {
- if(vfModule.getSelflink() == null || (vfModule.getSelflink() != null && vfModule.getSelflink().isEmpty())) {
- vfModule.setSelflink(selfLink);
- }
- if(vfModule.getSelflink() != null && !vfModule.getSelflink().isEmpty()) {
- String response = sdncVfModuleResources.queryVfModule(vfModule);
- execution.setVariable("SDNCQueryResponse_" + vfModule.getVfModuleId(), response);
- }
- else {
- throw new Exception("Vf Module " + vfModule.getVfModuleId() + " exists in gBuildingBlock but does not have a selflink value");
- }
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void queryVfModuleForVolumeGroup(BuildingBlockExecution execution) {
- try {
- VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
- if(vfModule.getSelflink() != null && !vfModule.getSelflink().isEmpty()) {
- String response = sdncVfModuleResources.queryVfModule(vfModule);
- execution.setVariable("SDNCQueryResponse_" + vfModule.getVfModuleId(), response);
- }
- else {
- throw new Exception("Vf Module " + vfModule.getVfModuleId() + " exists in gBuildingBlock but does not have a selflink value");
- }
- } catch(BBObjectNotFoundException bbException) {
- // If there is not a vf module in the general building block, we will not call SDNC and proceed as normal without throwing an error
- // If we see a bb object not found exception for something that is not a vf module id, then we should throw the error as normal
- if(!ResourceKey.VF_MODULE_ID.equals(bbException.getResourceKey())) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, bbException);
- }
- } catch(Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
+ public void queryVnf(BuildingBlockExecution execution) throws Exception {
+ ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+
+ String selfLink =
+ "restconf/config/GENERIC-RESOURCE-API:services/service/" + serviceInstance.getServiceInstanceId()
+ + "/service-data/vnfs/vnf/" + genericVnf.getVnfId() + "/vnf-data/vnf-topology/";
+ try {
+ if (genericVnf.getSelflink() == null) {
+ genericVnf.setSelflink(selfLink);
+ }
+ String response = sdncVnfResources.queryVnf(genericVnf);
+ execution.setVariable("SDNCQueryResponse_" + genericVnf.getVnfId(), response);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+
+ public void queryVfModule(BuildingBlockExecution execution) throws Exception {
+ ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
+ String selfLink = "restconf/config/GENERIC-RESOURCE-API:services/service/"
+ + serviceInstance.getServiceInstanceId() + "/service-data/vnfs/vnf/" + genericVnf.getVnfId()
+ + "/vnf-data/vf-modules/vf-module/" + vfModule.getVfModuleId() + "/vf-module-data/vf-module-topology/";
+ try {
+ if (vfModule.getSelflink() == null
+ || (vfModule.getSelflink() != null && vfModule.getSelflink().isEmpty())) {
+ vfModule.setSelflink(selfLink);
+ }
+ if (vfModule.getSelflink() != null && !vfModule.getSelflink().isEmpty()) {
+ String response = sdncVfModuleResources.queryVfModule(vfModule);
+ execution.setVariable("SDNCQueryResponse_" + vfModule.getVfModuleId(), response);
+ } else {
+ throw new Exception("Vf Module " + vfModule.getVfModuleId()
+ + " exists in gBuildingBlock but does not have a selflink value");
+ }
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void queryVfModuleForVolumeGroup(BuildingBlockExecution execution) {
+ try {
+ VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
+ if (vfModule.getSelflink() != null && !vfModule.getSelflink().isEmpty()) {
+ String response = sdncVfModuleResources.queryVfModule(vfModule);
+ execution.setVariable("SDNCQueryResponse_" + vfModule.getVfModuleId(), response);
+ } else {
+ throw new Exception("Vf Module " + vfModule.getVfModuleId()
+ + " exists in gBuildingBlock but does not have a selflink value");
+ }
+ } catch (BBObjectNotFoundException bbException) {
+ // If there is not a vf module in the general building block, we will not call SDNC and proceed as normal
+ // without throwing an error
+ // If we see a bb object not found exception for something that is not a vf module id, then we should throw
+ // the error as normal
+ if (!ResourceKey.VF_MODULE_ID.equals(bbException.getResourceKey())) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, bbException);
+ }
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java
index 24f642ae72..f32ffd72c3 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java
@@ -21,12 +21,10 @@
package org.onap.so.bpmn.infrastructure.sdnc.tasks;
import java.io.StringReader;
-
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathFactory;
-
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.onap.so.bpmn.infrastructure.sdnc.exceptions.SDNCErrorResponseException;
import org.onap.so.client.exception.BadResponseException;
@@ -41,93 +39,95 @@ import org.springframework.stereotype.Component;
import org.springframework.web.client.HttpClientErrorException;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
-
import com.jayway.jsonpath.JsonPath;
import com.jayway.jsonpath.PathNotFoundException;
-
+
@Component
public class SDNCRequestTasks {
-
- private static final Logger logger = LoggerFactory.getLogger(SDNCRequestTasks.class);
-
- private static final String SDNC_REQUEST = "SDNCRequest";
- private static final String MESSAGE = "_MESSAGE";
- private static final String CORRELATOR = "_CORRELATOR";
- protected static final String IS_CALLBACK_COMPLETED = "isCallbackCompleted";
- protected static final String SDNC_SUCCESS = "200";
-
- @Autowired
- private ExceptionBuilder exceptionBuilder;
-
- @Autowired
- private SDNCClient sdncClient;
-
- public void createCorrelationVariables (DelegateExecution execution) {
- SDNCRequest request = (SDNCRequest)execution.getVariable(SDNC_REQUEST);
- execution.setVariable(request.getCorrelationName()+CORRELATOR, request.getCorrelationValue());
- execution.setVariable("sdncTimeout", request.getTimeOut());
- }
-
- public void callSDNC (DelegateExecution execution) {
- SDNCRequest request = (SDNCRequest)execution.getVariable(SDNC_REQUEST);
- try {
- String response = sdncClient.post(request.getSDNCPayload(),request.getTopology());
- String finalMessageIndicator = JsonPath.read(response, "$.output.ack-final-indicator");
- execution.setVariable("isSDNCCompleted", convertIndicatorToBoolean(finalMessageIndicator));
- } catch(PathNotFoundException e) {
- logger.error("Error Parsing SDNC Response. Could not find read final ack indicator from JSON.", e);
- exceptionBuilder.buildAndThrowWorkflowException(execution, 7000,"Recieved invalid response from SDNC, unable to read message content.");
- } catch (MapperException e) {
- logger.error("Failed to map SDNC object to JSON prior to POST.", e);
- exceptionBuilder.buildAndThrowWorkflowException(execution, 7000,"Failed to map SDNC object to JSON prior to POST.");
- } catch (BadResponseException e) {
- logger.error("Did not receive a successful response from SDNC.", e);
- exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, e.getLocalizedMessage());
- } catch (HttpClientErrorException e){
- logger.error("HttpClientErrorException: 404 Not Found, Failed to contact SDNC", e);
- exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, "SDNC cannot be contacted.");
- }
- }
-
- public void processCallback (DelegateExecution execution) {
- try {
- SDNCRequest request = (SDNCRequest)execution.getVariable(SDNC_REQUEST);
- String asyncRequest = (String) execution.getVariable(request.getCorrelationName()+MESSAGE);
-
- DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance ();
- DocumentBuilder db = dbf.newDocumentBuilder();
- Document doc = db.parse(new InputSource(new StringReader(asyncRequest)));
-
- String finalMessageIndicator = getXmlElement(doc, "/input/ack-final-indicator");
- boolean isCallbackCompleted = convertIndicatorToBoolean(finalMessageIndicator);
- execution.setVariable(IS_CALLBACK_COMPLETED, isCallbackCompleted);
- if(isCallbackCompleted) {
- String responseCode = getXmlElement(doc, "/input/response-code");
- String responseMessage = getXmlElement(doc, "/input/response-message");
- if(!SDNC_SUCCESS.equalsIgnoreCase(responseCode)) {
- throw new SDNCErrorResponseException(responseMessage);
- }
- }
- } catch (SDNCErrorResponseException e) {
- logger.error("SDNC error response - " + e.getMessage());
- exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, e.getMessage());
- } catch (Exception e) {
- logger.error("Error procesing SDNC callback", e);
- exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, "Error procesing SDNC callback");
- }
- }
-
- public void handleTimeOutException (DelegateExecution execution) {
- exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, "Error timed out waiting on SDNC Async-Response");
- }
-
- protected boolean convertIndicatorToBoolean(String finalMessageIndicator) {
- return "Y".equals(finalMessageIndicator);
- }
-
- protected String getXmlElement(Document doc, String exp) throws Exception {
- XPath xPath = XPathFactory.newInstance().newXPath();
- return xPath.evaluate(exp, doc);
- }
-
+
+ private static final Logger logger = LoggerFactory.getLogger(SDNCRequestTasks.class);
+
+ private static final String SDNC_REQUEST = "SDNCRequest";
+ private static final String MESSAGE = "_MESSAGE";
+ private static final String CORRELATOR = "_CORRELATOR";
+ protected static final String IS_CALLBACK_COMPLETED = "isCallbackCompleted";
+ protected static final String SDNC_SUCCESS = "200";
+
+ @Autowired
+ private ExceptionBuilder exceptionBuilder;
+
+ @Autowired
+ private SDNCClient sdncClient;
+
+ public void createCorrelationVariables(DelegateExecution execution) {
+ SDNCRequest request = (SDNCRequest) execution.getVariable(SDNC_REQUEST);
+ execution.setVariable(request.getCorrelationName() + CORRELATOR, request.getCorrelationValue());
+ execution.setVariable("sdncTimeout", request.getTimeOut());
+ }
+
+ public void callSDNC(DelegateExecution execution) {
+ SDNCRequest request = (SDNCRequest) execution.getVariable(SDNC_REQUEST);
+ try {
+ String response = sdncClient.post(request.getSDNCPayload(), request.getTopology());
+ String finalMessageIndicator = JsonPath.read(response, "$.output.ack-final-indicator");
+ execution.setVariable("isSDNCCompleted", convertIndicatorToBoolean(finalMessageIndicator));
+ } catch (PathNotFoundException e) {
+ logger.error("Error Parsing SDNC Response. Could not find read final ack indicator from JSON.", e);
+ exceptionBuilder.buildAndThrowWorkflowException(execution, 7000,
+ "Recieved invalid response from SDNC, unable to read message content.");
+ } catch (MapperException e) {
+ logger.error("Failed to map SDNC object to JSON prior to POST.", e);
+ exceptionBuilder.buildAndThrowWorkflowException(execution, 7000,
+ "Failed to map SDNC object to JSON prior to POST.");
+ } catch (BadResponseException e) {
+ logger.error("Did not receive a successful response from SDNC.", e);
+ exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, e.getLocalizedMessage());
+ } catch (HttpClientErrorException e) {
+ logger.error("HttpClientErrorException: 404 Not Found, Failed to contact SDNC", e);
+ exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, "SDNC cannot be contacted.");
+ }
+ }
+
+ public void processCallback(DelegateExecution execution) {
+ try {
+ SDNCRequest request = (SDNCRequest) execution.getVariable(SDNC_REQUEST);
+ String asyncRequest = (String) execution.getVariable(request.getCorrelationName() + MESSAGE);
+
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ Document doc = db.parse(new InputSource(new StringReader(asyncRequest)));
+
+ String finalMessageIndicator = getXmlElement(doc, "/input/ack-final-indicator");
+ boolean isCallbackCompleted = convertIndicatorToBoolean(finalMessageIndicator);
+ execution.setVariable(IS_CALLBACK_COMPLETED, isCallbackCompleted);
+ if (isCallbackCompleted) {
+ String responseCode = getXmlElement(doc, "/input/response-code");
+ String responseMessage = getXmlElement(doc, "/input/response-message");
+ if (!SDNC_SUCCESS.equalsIgnoreCase(responseCode)) {
+ throw new SDNCErrorResponseException(responseMessage);
+ }
+ }
+ } catch (SDNCErrorResponseException e) {
+ logger.error("SDNC error response - " + e.getMessage());
+ exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, e.getMessage());
+ } catch (Exception e) {
+ logger.error("Error procesing SDNC callback", e);
+ exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, "Error procesing SDNC callback");
+ }
+ }
+
+ public void handleTimeOutException(DelegateExecution execution) {
+ exceptionBuilder.buildAndThrowWorkflowException(execution, 7000,
+ "Error timed out waiting on SDNC Async-Response");
+ }
+
+ protected boolean convertIndicatorToBoolean(String finalMessageIndicator) {
+ return "Y".equals(finalMessageIndicator);
+ }
+
+ protected String getXmlElement(Document doc, String exp) throws Exception {
+ XPath xPath = XPathFactory.newInstance().newXPath();
+ return xPath.evaluate(exp, doc);
+ }
+
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasks.java
index 340872593f..e9848d1646 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasks.java
@@ -51,85 +51,94 @@ import org.springframework.stereotype.Component;
@Component
public class SDNCUnassignTasks {
- private static final Logger logger = LoggerFactory.getLogger(SDNCUnassignTasks.class);
- @Autowired
- private SDNCServiceInstanceResources sdncSIResources;
- @Autowired
- private SDNCVfModuleResources sdncVfModuleResources;
- @Autowired
- private SDNCVnfResources sdncVnfResources;
- @Autowired
- private ExceptionBuilder exceptionUtil;
- @Autowired
- private ExtractPojosForBB extractPojosForBB;
- @Autowired
- private SDNCNetworkResources sdncNetworkResources;
+ private static final Logger logger = LoggerFactory.getLogger(SDNCUnassignTasks.class);
+ @Autowired
+ private SDNCServiceInstanceResources sdncSIResources;
+ @Autowired
+ private SDNCVfModuleResources sdncVfModuleResources;
+ @Autowired
+ private SDNCVnfResources sdncVnfResources;
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+ @Autowired
+ private ExtractPojosForBB extractPojosForBB;
+ @Autowired
+ private SDNCNetworkResources sdncNetworkResources;
- public void unassignServiceInstance(BuildingBlockExecution execution) {
- try {
- GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- RequestContext requestContext = gBBInput.getRequestContext();
- Customer customer = gBBInput.getCustomer();
- GenericResourceApiServiceOperationInformation req = sdncSIResources.unassignServiceInstance(serviceInstance, customer, requestContext);
- SDNCRequest sdncRequest = new SDNCRequest();
- sdncRequest.setSDNCPayload(req);
- sdncRequest.setTopology(SDNCTopology.SERVICE);
- execution.setVariable("SDNCRequest", sdncRequest);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void unassignVfModule(BuildingBlockExecution execution) {
- try {
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
- GenericResourceApiVfModuleOperationInformation req = sdncVfModuleResources.unassignVfModule(vfModule, vnf, serviceInstance);
- SDNCRequest sdncRequest = new SDNCRequest();
- sdncRequest.setSDNCPayload(req);
- sdncRequest.setTopology(SDNCTopology.VFMODULE);
- execution.setVariable("SDNCRequest", sdncRequest); } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
-
- public void unassignVnf(BuildingBlockExecution execution) {
- try {
- GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- RequestContext requestContext = gBBInput.getRequestContext();
- Customer customer = gBBInput.getCustomer();
- CloudRegion cloudRegion = gBBInput.getCloudRegion();
- GenericResourceApiVnfOperationInformation req = sdncVnfResources.unassignVnf(vnf, serviceInstance, customer, cloudRegion, requestContext);
- SDNCRequest sdncRequest = new SDNCRequest();
- sdncRequest.setSDNCPayload(req);
- sdncRequest.setTopology(SDNCTopology.VNF);
- execution.setVariable("SDNCRequest", sdncRequest);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
+ public void unassignServiceInstance(BuildingBlockExecution execution) {
+ try {
+ GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ RequestContext requestContext = gBBInput.getRequestContext();
+ Customer customer = gBBInput.getCustomer();
+ GenericResourceApiServiceOperationInformation req =
+ sdncSIResources.unassignServiceInstance(serviceInstance, customer, requestContext);
+ SDNCRequest sdncRequest = new SDNCRequest();
+ sdncRequest.setSDNCPayload(req);
+ sdncRequest.setTopology(SDNCTopology.SERVICE);
+ execution.setVariable("SDNCRequest", sdncRequest);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
- public void unassignNetwork(BuildingBlockExecution execution) throws Exception {
- try {
- GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
- L3Network network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- Customer customer = gBBInput.getCustomer();
- RequestContext requestContext = gBBInput.getRequestContext();
- CloudRegion cloudRegion = gBBInput.getCloudRegion();
- String cloudRegionSdnc = execution.getVariable("cloudRegionSdnc");
- cloudRegion.setLcpCloudRegionId(cloudRegionSdnc);
- GenericResourceApiNetworkOperationInformation req = sdncNetworkResources.unassignNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
- SDNCRequest sdncRequest = new SDNCRequest();
- sdncRequest.setSDNCPayload(req);
- sdncRequest.setTopology(SDNCTopology.NETWORK);
- execution.setVariable("SDNCRequest", sdncRequest);
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }
+ public void unassignVfModule(BuildingBlockExecution execution) {
+ try {
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
+ GenericResourceApiVfModuleOperationInformation req =
+ sdncVfModuleResources.unassignVfModule(vfModule, vnf, serviceInstance);
+ SDNCRequest sdncRequest = new SDNCRequest();
+ sdncRequest.setSDNCPayload(req);
+ sdncRequest.setTopology(SDNCTopology.VFMODULE);
+ execution.setVariable("SDNCRequest", sdncRequest);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void unassignVnf(BuildingBlockExecution execution) {
+ try {
+ GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ RequestContext requestContext = gBBInput.getRequestContext();
+ Customer customer = gBBInput.getCustomer();
+ CloudRegion cloudRegion = gBBInput.getCloudRegion();
+ GenericResourceApiVnfOperationInformation req =
+ sdncVnfResources.unassignVnf(vnf, serviceInstance, customer, cloudRegion, requestContext);
+ SDNCRequest sdncRequest = new SDNCRequest();
+ sdncRequest.setSDNCPayload(req);
+ sdncRequest.setTopology(SDNCTopology.VNF);
+ execution.setVariable("SDNCRequest", sdncRequest);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void unassignNetwork(BuildingBlockExecution execution) throws Exception {
+ try {
+ GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+ L3Network network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ Customer customer = gBBInput.getCustomer();
+ RequestContext requestContext = gBBInput.getRequestContext();
+ CloudRegion cloudRegion = gBBInput.getCloudRegion();
+ String cloudRegionSdnc = execution.getVariable("cloudRegionSdnc");
+ cloudRegion.setLcpCloudRegionId(cloudRegionSdnc);
+ GenericResourceApiNetworkOperationInformation req = sdncNetworkResources.unassignNetwork(network,
+ serviceInstance, customer, requestContext, cloudRegion);
+ SDNCRequest sdncRequest = new SDNCRequest();
+ sdncRequest.setSDNCPayload(req);
+ sdncRequest.setTopology(SDNCTopology.NETWORK);
+ execution.setVariable("SDNCRequest", sdncRequest);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/validations/CloudRegionOrchestrationValidator.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/validations/CloudRegionOrchestrationValidator.java
index 3763fca34f..47855eaa6e 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/validations/CloudRegionOrchestrationValidator.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/validations/CloudRegionOrchestrationValidator.java
@@ -22,7 +22,6 @@ package org.onap.so.bpmn.infrastructure.validations;
import java.util.Optional;
import java.util.regex.Pattern;
-
import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.common.validation.PreBuildingBlockValidator;
import org.onap.so.bpmn.common.validation.Skip;
@@ -37,34 +36,35 @@ import org.springframework.stereotype.Component;
@Skip
public class CloudRegionOrchestrationValidator implements PreBuildingBlockValidator {
- private static Logger logger = LoggerFactory.getLogger(CloudRegionOrchestrationValidator.class);
- private final Pattern pattern = Pattern.compile("(?:Activate|Assign|Create|Deactivate|Delete|Unassign|Update)(?:Network|Vnf|VfModule|VolumeGroup|FabricConfiguration)BB");
-
- @Autowired
- private ExceptionBuilder exceptionBuilder;
+ private static Logger logger = LoggerFactory.getLogger(CloudRegionOrchestrationValidator.class);
+ private final Pattern pattern = Pattern.compile(
+ "(?:Activate|Assign|Create|Deactivate|Delete|Unassign|Update)(?:Network|Vnf|VfModule|VolumeGroup|FabricConfiguration)BB");
+
+ @Autowired
+ private ExceptionBuilder exceptionBuilder;
+
+ @Override
+ public boolean shouldRunFor(String bbName) {
+ return pattern.matcher(bbName).find();
+ }
- @Override
- public boolean shouldRunFor(String bbName) {
- return pattern.matcher(bbName).find();
- }
-
- @Override
- public Optional<String> validate(BuildingBlockExecution execution) {
- String msg = null;
- try {
- CloudRegion cloudRegion = execution.getGeneralBuildingBlock().getCloudRegion();
- if (Boolean.TRUE.equals(cloudRegion.getOrchestrationDisabled())) {
- msg = String.format("Error: The request has failed due to orchestration currently disabled for the target cloud region %s for cloud owner %s",
- cloudRegion.getLcpCloudRegionId(), cloudRegion.getCloudOwner());
- logger.error(msg);
- return Optional.ofNullable(msg);
- }
- }
- catch(Exception e) {
- logger.error("failed to validate", e);
- exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, e);
- }
- return Optional.empty();
- }
+ @Override
+ public Optional<String> validate(BuildingBlockExecution execution) {
+ String msg = null;
+ try {
+ CloudRegion cloudRegion = execution.getGeneralBuildingBlock().getCloudRegion();
+ if (Boolean.TRUE.equals(cloudRegion.getOrchestrationDisabled())) {
+ msg = String.format(
+ "Error: The request has failed due to orchestration currently disabled for the target cloud region %s for cloud owner %s",
+ cloudRegion.getLcpCloudRegionId(), cloudRegion.getCloudOwner());
+ logger.error(msg);
+ return Optional.ofNullable(msg);
+ }
+ } catch (Exception e) {
+ logger.error("failed to validate", e);
+ exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, e);
+ }
+ return Optional.empty();
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/FlowCompletionTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/FlowCompletionTasks.java
index ec2ccdf202..e809ecd0ae 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/FlowCompletionTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/FlowCompletionTasks.java
@@ -22,7 +22,6 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks;
import java.util.ArrayList;
import java.util.List;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.onap.so.bpmn.common.BuildingBlockExecution;
@@ -40,41 +39,39 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
@Component
public class FlowCompletionTasks {
- private static final Logger logger = LoggerFactory.getLogger(FlowCompletionTasks.class);
+ private static final Logger logger = LoggerFactory.getLogger(FlowCompletionTasks.class);
+
+ @Autowired
+ private RequestsDbClient requestDbclient;
+
+ public void updateRequestDbStatus(BuildingBlockExecution execution) {
+ try {
+ String requestId = execution.getGeneralBuildingBlock().getRequestContext().getMsoRequestId();
+ InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId);
+
+ WorkflowException workflowException = (WorkflowException) execution.getVariable("WorkflowException");
+ if (workflowException == null) {
+ request.setStatusMessage("RequestCompletedSuccessfully");
+ request.setRequestStatus("COMPLETE");
+
+ } else {
+ request.setStatusMessage(workflowException.getErrorMessage());
+ request.setRequestStatus("FAILED");
+ }
+ request.setProgress(100L);
+ request.setLastModifiedBy("CamundaBPMN");
+
+ requestDbclient.updateInfraActiveRequests(request);
+ } catch (Exception e) {
+ logger.error("Unable to save the updated request status to the DB", e);
+ }
+ }
+
- @Autowired
- private RequestsDbClient requestDbclient;
-
- public void updateRequestDbStatus(BuildingBlockExecution execution) {
- try {
- String requestId = execution.getGeneralBuildingBlock().getRequestContext().getMsoRequestId();
- InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId);
-
- WorkflowException workflowException = (WorkflowException) execution.getVariable("WorkflowException");
- if (workflowException == null) {
- request.setStatusMessage("RequestCompletedSuccessfully");
- request.setRequestStatus("COMPLETE");
-
- }
- else {
- request.setStatusMessage(workflowException.getErrorMessage());
- request.setRequestStatus("FAILED");
- }
- request.setProgress(100L);
- request.setLastModifiedBy("CamundaBPMN");
-
- requestDbclient.updateInfraActiveRequests(request);
- } catch (Exception e) {
- logger.error("Unable to save the updated request status to the DB",e);
- }
- }
-
-
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java
index bbfc01921c..4fcacb3c42 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java
@@ -42,124 +42,158 @@ import org.springframework.stereotype.Component;
@Component
public class OrchestrationStatusValidator {
- private static final Logger logger = LoggerFactory.getLogger(OrchestrationStatusValidator.class);
-
- private static final String BUILDING_BLOCK_DETAIL_NOT_FOUND = "Building Block (%s) not set up in Orchestration_Status_Validation table in CatalogDB.";
- private static final String UNKNOWN_RESOURCE_TYPE = "Building Block (%s) not set up correctly in Orchestration_Status_Validation table in CatalogDB. ResourceType=(%s), TargetAction=(%s)";
- private static final String ORCHESTRATION_VALIDATION_FAIL = "Orchestration Status Validation failed. ResourceType=(%s), TargetAction=(%s), OrchestrationStatus=(%s)";
- private static final String ORCHESTRATION_STATUS_VALIDATION_RESULT = "orchestrationStatusValidationResult";
- private static final String ALACARTE = "aLaCarte";
- private static final String MULTI_STAGE_DESIGN_OFF = "false";
- private static final String MULTI_STAGE_DESIGN_ON = "true";
-
-
- @Autowired
- private ExtractPojosForBB extractPojosForBB;
- @Autowired
- private ExceptionBuilder exceptionBuilder;
- @Autowired
- private CatalogDbClient catalogDbClient;
-
- public void validateOrchestrationStatus(BuildingBlockExecution execution) {
- try {
- OrchestrationStatusValidationDirective previousOrchestrationStatusValidationResult = execution.getVariable(ORCHESTRATION_STATUS_VALIDATION_RESULT);
-
- execution.setVariable(ORCHESTRATION_STATUS_VALIDATION_RESULT, null);
-
- boolean aLaCarte = (boolean) execution.getVariable(ALACARTE);
-
- String buildingBlockFlowName = execution.getFlowToBeCalled();
-
- BuildingBlockDetail buildingBlockDetail = catalogDbClient.getBuildingBlockDetail(buildingBlockFlowName);
-
- if (buildingBlockDetail == null) {
- throw new OrchestrationStatusValidationException(String.format(BUILDING_BLOCK_DETAIL_NOT_FOUND, buildingBlockFlowName));
- }
-
- OrchestrationStatus orchestrationStatus = null;
-
- switch(buildingBlockDetail.getResourceType()) {
- case SERVICE:
- org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- orchestrationStatus = serviceInstance.getOrchestrationStatus();
- break;
- case VNF:
- org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- orchestrationStatus = genericVnf.getOrchestrationStatus();
- break;
- case VF_MODULE:
- org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
- orchestrationStatus = vfModule.getOrchestrationStatus();
- break;
- case VOLUME_GROUP:
- org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
- orchestrationStatus = volumeGroup.getOrchestrationStatus();
- break;
- case NETWORK:
- org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
- orchestrationStatus = network.getOrchestrationStatus();
- break;
- case NETWORK_COLLECTION:
- org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInst = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- org.onap.so.bpmn.servicedecomposition.bbobjects.Collection networkCollection = serviceInst.getCollection();
- orchestrationStatus = networkCollection.getOrchestrationStatus();
- break;
- case CONFIGURATION:
- org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration configuration = extractPojosForBB.extractByKey(execution, ResourceKey.CONFIGURATION_ID);
- orchestrationStatus = configuration.getOrchestrationStatus();
- break;
- case INSTANCE_GROUP:
- org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup instanceGroup = extractPojosForBB.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID);
- orchestrationStatus = instanceGroup.getOrchestrationStatus();
- break;
- case NO_VALIDATE:
- //short circuit and exit method
- execution.setVariable(ORCHESTRATION_STATUS_VALIDATION_RESULT, OrchestrationStatusValidationDirective.VALIDATION_SKIPPED);
- return;
- default:
- // can't currently get here, so not tested. Added in case enum is expanded without a change to this code
- throw new OrchestrationStatusValidationException(String.format(UNKNOWN_RESOURCE_TYPE, buildingBlockFlowName, buildingBlockDetail.getResourceType(), buildingBlockDetail.getTargetAction()));
- }
-
- if(orchestrationStatus==null){
- throw new OrchestrationStatusValidationException("The resource's orchstration status is null. Cannot perform task on a null orchestration status");
- }
- OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = catalogDbClient.getOrchestrationStatusStateTransitionDirective(buildingBlockDetail.getResourceType(), orchestrationStatus, buildingBlockDetail.getTargetAction());
-
- if(aLaCarte && ResourceType.VF_MODULE.equals(buildingBlockDetail.getResourceType()) && OrchestrationAction.CREATE.equals(buildingBlockDetail.getTargetAction()) &&
- OrchestrationStatus.PENDING_ACTIVATION.equals(orchestrationStatus)) {
- org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- orchestrationStatusStateTransitionDirective = processPossibleSecondStageofVfModuleCreate(execution, previousOrchestrationStatusValidationResult,
- genericVnf, orchestrationStatusStateTransitionDirective);
- }
-
- if (orchestrationStatusStateTransitionDirective.getFlowDirective() == OrchestrationStatusValidationDirective.FAIL) {
- throw new OrchestrationStatusValidationException(String.format(ORCHESTRATION_VALIDATION_FAIL, buildingBlockDetail.getResourceType(), buildingBlockDetail.getTargetAction(), orchestrationStatus));
- }
-
- execution.setVariable(ORCHESTRATION_STATUS_VALIDATION_RESULT, orchestrationStatusStateTransitionDirective.getFlowDirective());
- }catch(BBObjectNotFoundException ex){
- if(execution.getFlowToBeCalled().contains("Unassign")){
- execution.setVariable(ORCHESTRATION_STATUS_VALIDATION_RESULT, OrchestrationStatusValidationDirective.SILENT_SUCCESS);
- }else{
- exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- }catch (Exception e) {
- exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, e);
- }
- }
-
- private OrchestrationStatusStateTransitionDirective processPossibleSecondStageofVfModuleCreate(BuildingBlockExecution execution, OrchestrationStatusValidationDirective previousOrchestrationStatusValidationResult,
- org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf genericVnf, OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective) {
- if (previousOrchestrationStatusValidationResult != null && previousOrchestrationStatusValidationResult.equals(OrchestrationStatusValidationDirective.SILENT_SUCCESS)) {
- String multiStageDesign = MULTI_STAGE_DESIGN_OFF;
- if (genericVnf.getModelInfoGenericVnf() != null) {
- multiStageDesign = genericVnf.getModelInfoGenericVnf().getMultiStageDesign();
- }
- if (multiStageDesign != null && multiStageDesign.equalsIgnoreCase(MULTI_STAGE_DESIGN_ON)) {
- orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.CONTINUE);
- }
- }
- return orchestrationStatusStateTransitionDirective;
- }
+ private static final Logger logger = LoggerFactory.getLogger(OrchestrationStatusValidator.class);
+
+ private static final String BUILDING_BLOCK_DETAIL_NOT_FOUND =
+ "Building Block (%s) not set up in Orchestration_Status_Validation table in CatalogDB.";
+ private static final String UNKNOWN_RESOURCE_TYPE =
+ "Building Block (%s) not set up correctly in Orchestration_Status_Validation table in CatalogDB. ResourceType=(%s), TargetAction=(%s)";
+ private static final String ORCHESTRATION_VALIDATION_FAIL =
+ "Orchestration Status Validation failed. ResourceType=(%s), TargetAction=(%s), OrchestrationStatus=(%s)";
+ private static final String ORCHESTRATION_STATUS_VALIDATION_RESULT = "orchestrationStatusValidationResult";
+ private static final String ALACARTE = "aLaCarte";
+ private static final String MULTI_STAGE_DESIGN_OFF = "false";
+ private static final String MULTI_STAGE_DESIGN_ON = "true";
+
+
+ @Autowired
+ private ExtractPojosForBB extractPojosForBB;
+ @Autowired
+ private ExceptionBuilder exceptionBuilder;
+ @Autowired
+ private CatalogDbClient catalogDbClient;
+
+ public void validateOrchestrationStatus(BuildingBlockExecution execution) {
+ try {
+ OrchestrationStatusValidationDirective previousOrchestrationStatusValidationResult =
+ execution.getVariable(ORCHESTRATION_STATUS_VALIDATION_RESULT);
+
+ execution.setVariable(ORCHESTRATION_STATUS_VALIDATION_RESULT, null);
+
+ boolean aLaCarte = (boolean) execution.getVariable(ALACARTE);
+
+ String buildingBlockFlowName = execution.getFlowToBeCalled();
+
+ BuildingBlockDetail buildingBlockDetail = catalogDbClient.getBuildingBlockDetail(buildingBlockFlowName);
+
+ if (buildingBlockDetail == null) {
+ throw new OrchestrationStatusValidationException(
+ String.format(BUILDING_BLOCK_DETAIL_NOT_FOUND, buildingBlockFlowName));
+ }
+
+ OrchestrationStatus orchestrationStatus = null;
+
+ switch (buildingBlockDetail.getResourceType()) {
+ case SERVICE:
+ org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ orchestrationStatus = serviceInstance.getOrchestrationStatus();
+ break;
+ case VNF:
+ org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf genericVnf =
+ extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ orchestrationStatus = genericVnf.getOrchestrationStatus();
+ break;
+ case VF_MODULE:
+ org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule =
+ extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
+ orchestrationStatus = vfModule.getOrchestrationStatus();
+ break;
+ case VOLUME_GROUP:
+ org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup volumeGroup =
+ extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
+ orchestrationStatus = volumeGroup.getOrchestrationStatus();
+ break;
+ case NETWORK:
+ org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network network =
+ extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
+ orchestrationStatus = network.getOrchestrationStatus();
+ break;
+ case NETWORK_COLLECTION:
+ org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInst =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ org.onap.so.bpmn.servicedecomposition.bbobjects.Collection networkCollection =
+ serviceInst.getCollection();
+ orchestrationStatus = networkCollection.getOrchestrationStatus();
+ break;
+ case CONFIGURATION:
+ org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration configuration =
+ extractPojosForBB.extractByKey(execution, ResourceKey.CONFIGURATION_ID);
+ orchestrationStatus = configuration.getOrchestrationStatus();
+ break;
+ case INSTANCE_GROUP:
+ org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup instanceGroup =
+ extractPojosForBB.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID);
+ orchestrationStatus = instanceGroup.getOrchestrationStatus();
+ break;
+ case NO_VALIDATE:
+ // short circuit and exit method
+ execution.setVariable(ORCHESTRATION_STATUS_VALIDATION_RESULT,
+ OrchestrationStatusValidationDirective.VALIDATION_SKIPPED);
+ return;
+ default:
+ // can't currently get here, so not tested. Added in case enum is expanded without a change to this
+ // code
+ throw new OrchestrationStatusValidationException(
+ String.format(UNKNOWN_RESOURCE_TYPE, buildingBlockFlowName,
+ buildingBlockDetail.getResourceType(), buildingBlockDetail.getTargetAction()));
+ }
+
+ if (orchestrationStatus == null) {
+ throw new OrchestrationStatusValidationException(
+ "The resource's orchstration status is null. Cannot perform task on a null orchestration status");
+ }
+ OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = catalogDbClient
+ .getOrchestrationStatusStateTransitionDirective(buildingBlockDetail.getResourceType(),
+ orchestrationStatus, buildingBlockDetail.getTargetAction());
+
+ if (aLaCarte && ResourceType.VF_MODULE.equals(buildingBlockDetail.getResourceType())
+ && OrchestrationAction.CREATE.equals(buildingBlockDetail.getTargetAction())
+ && OrchestrationStatus.PENDING_ACTIVATION.equals(orchestrationStatus)) {
+ org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf genericVnf =
+ extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ orchestrationStatusStateTransitionDirective = processPossibleSecondStageofVfModuleCreate(execution,
+ previousOrchestrationStatusValidationResult, genericVnf,
+ orchestrationStatusStateTransitionDirective);
+ }
+
+ if (orchestrationStatusStateTransitionDirective
+ .getFlowDirective() == OrchestrationStatusValidationDirective.FAIL) {
+ throw new OrchestrationStatusValidationException(
+ String.format(ORCHESTRATION_VALIDATION_FAIL, buildingBlockDetail.getResourceType(),
+ buildingBlockDetail.getTargetAction(), orchestrationStatus));
+ }
+
+ execution.setVariable(ORCHESTRATION_STATUS_VALIDATION_RESULT,
+ orchestrationStatusStateTransitionDirective.getFlowDirective());
+ } catch (BBObjectNotFoundException ex) {
+ if (execution.getFlowToBeCalled().contains("Unassign")) {
+ execution.setVariable(ORCHESTRATION_STATUS_VALIDATION_RESULT,
+ OrchestrationStatusValidationDirective.SILENT_SUCCESS);
+ } else {
+ exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ } catch (Exception e) {
+ exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, e);
+ }
+ }
+
+ private OrchestrationStatusStateTransitionDirective processPossibleSecondStageofVfModuleCreate(
+ BuildingBlockExecution execution,
+ OrchestrationStatusValidationDirective previousOrchestrationStatusValidationResult,
+ org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf genericVnf,
+ OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective) {
+ if (previousOrchestrationStatusValidationResult != null && previousOrchestrationStatusValidationResult
+ .equals(OrchestrationStatusValidationDirective.SILENT_SUCCESS)) {
+ String multiStageDesign = MULTI_STAGE_DESIGN_OFF;
+ if (genericVnf.getModelInfoGenericVnf() != null) {
+ multiStageDesign = genericVnf.getModelInfoGenericVnf().getMultiStageDesign();
+ }
+ if (multiStageDesign != null && multiStageDesign.equalsIgnoreCase(MULTI_STAGE_DESIGN_ON)) {
+ orchestrationStatusStateTransitionDirective
+ .setFlowDirective(OrchestrationStatusValidationDirective.CONTINUE);
+ }
+ }
+ return orchestrationStatusStateTransitionDirective;
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/Resource.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/Resource.java
index 03559afb33..447f8994db 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/Resource.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/Resource.java
@@ -22,67 +22,82 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks;
public class Resource {
- private String resourceId;
- private WorkflowType resourceType;
- private boolean generated;
- private boolean baseVfModule;
- private String virtualLinkKey;
- private String vnfCustomizationId;
- private String vfModuleCustomizationId;
- private String cvnfModuleCustomizationId;
-
- public Resource(WorkflowType resourceType, String resourceId, boolean generated){
- this.resourceId = resourceId;
- this.resourceType = resourceType;
- this.generated = generated;
- }
-
- public String getResourceId() {
- return resourceId;
- }
- public void setResourceId(String resourceId) {
- this.resourceId = resourceId;
- }
- public WorkflowType getResourceType() {
- return resourceType;
- }
- public void setResourceType(WorkflowType resourceType) {
- this.resourceType = resourceType;
- }
- public boolean isGenerated() {
- return generated;
- }
- public void setGenerated(boolean generated) {
- this.generated = generated;
- }
- public boolean isBaseVfModule() {
- return baseVfModule;
- }
- public void setBaseVfModule(boolean baseVfModule) {
- this.baseVfModule = baseVfModule;
- }
- public String getVirtualLinkKey() {
- return virtualLinkKey;
- }
- public void setVirtualLinkKey(String virtualLinkKey) {
- this.virtualLinkKey = virtualLinkKey;
- }
- public String getVnfCustomizationId() {
- return vnfCustomizationId;
- }
- public void setVnfCustomizationId(String vnfCustomizationId) {
- this.vnfCustomizationId = vnfCustomizationId;
- }
- public String getVfModuleCustomizationId() {
- return vfModuleCustomizationId;
- }
- public void setVfModuleCustomizationId(String vfModuleCustomizationId) {
- this.vfModuleCustomizationId = vfModuleCustomizationId;
- }
- public String getCvnfModuleCustomizationId() {
- return cvnfModuleCustomizationId;
- }
- public void setCvnfModuleCustomizationId(String cvnfModuleCustomizationId) {
- this.cvnfModuleCustomizationId = cvnfModuleCustomizationId;
- }
+ private String resourceId;
+ private WorkflowType resourceType;
+ private boolean generated;
+ private boolean baseVfModule;
+ private String virtualLinkKey;
+ private String vnfCustomizationId;
+ private String vfModuleCustomizationId;
+ private String cvnfModuleCustomizationId;
+
+ public Resource(WorkflowType resourceType, String resourceId, boolean generated) {
+ this.resourceId = resourceId;
+ this.resourceType = resourceType;
+ this.generated = generated;
+ }
+
+ public String getResourceId() {
+ return resourceId;
+ }
+
+ public void setResourceId(String resourceId) {
+ this.resourceId = resourceId;
+ }
+
+ public WorkflowType getResourceType() {
+ return resourceType;
+ }
+
+ public void setResourceType(WorkflowType resourceType) {
+ this.resourceType = resourceType;
+ }
+
+ public boolean isGenerated() {
+ return generated;
+ }
+
+ public void setGenerated(boolean generated) {
+ this.generated = generated;
+ }
+
+ public boolean isBaseVfModule() {
+ return baseVfModule;
+ }
+
+ public void setBaseVfModule(boolean baseVfModule) {
+ this.baseVfModule = baseVfModule;
+ }
+
+ public String getVirtualLinkKey() {
+ return virtualLinkKey;
+ }
+
+ public void setVirtualLinkKey(String virtualLinkKey) {
+ this.virtualLinkKey = virtualLinkKey;
+ }
+
+ public String getVnfCustomizationId() {
+ return vnfCustomizationId;
+ }
+
+ public void setVnfCustomizationId(String vnfCustomizationId) {
+ this.vnfCustomizationId = vnfCustomizationId;
+ }
+
+ public String getVfModuleCustomizationId() {
+ return vfModuleCustomizationId;
+ }
+
+ public void setVfModuleCustomizationId(String vfModuleCustomizationId) {
+ this.vfModuleCustomizationId = vfModuleCustomizationId;
+ }
+
+ public String getCvnfModuleCustomizationId() {
+ return cvnfModuleCustomizationId;
+ }
+
+ public void setCvnfModuleCustomizationId(String cvnfModuleCustomizationId) {
+ this.cvnfModuleCustomizationId = cvnfModuleCustomizationId;
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java
index 7562bd964e..2fc301f9d7 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java
@@ -33,7 +33,6 @@ import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
-
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.javatuples.Pair;
import org.slf4j.LoggerFactory;
@@ -82,1184 +81,1306 @@ import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
-
import com.fasterxml.jackson.databind.ObjectMapper;
@Component
public class WorkflowAction {
- private static final String WORKFLOW_ACTION_ERROR_MESSAGE = "WorkflowActionErrorMessage";
- private static final String SERVICE_INSTANCES = "serviceInstances";
- private static final String VF_MODULES = "vfModules";
- private static final String WORKFLOW_ACTION_WAS_UNABLE_TO_VERIFY_IF_THE_INSTANCE_NAME_ALREADY_EXIST_IN_AAI = "WorkflowAction was unable to verify if the instance name already exist in AAI.";
- private static final String G_ORCHESTRATION_FLOW = "gOrchestrationFlow";
- private static final String G_ACTION = "requestAction";
- private static final String G_CURRENT_SEQUENCE = "gCurrentSequence";
- private static final String G_REQUEST_ID = "mso-request-id";
- private static final String G_BPMN_REQUEST = "bpmnRequest";
- private static final String G_ALACARTE = "aLaCarte";
- private static final String G_APIVERSION = "apiVersion";
- private static final String G_URI = "requestUri";
- private static final String G_ISTOPLEVELFLOW = "isTopLevelFlow";
- private static final String VNF_TYPE = "vnfType";
- private static final String SERVICE = "Service";
- private static final String VNF = "Vnf";
- private static final String VFMODULE = "VfModule";
- private static final String VOLUMEGROUP = "VolumeGroup";
- private static final String NETWORK = "Network";
- private static final String NETWORKCOLLECTION = "NetworkCollection";
- private static final String CONFIGURATION = "Configuration";
- private static final String ASSIGNINSTANCE = "assignInstance";
- private static final String CREATEINSTANCE = "createInstance";
- private static final String USERPARAMSERVICE = "service";
- private static final String supportedTypes = "vnfs|vfModules|networks|networkCollections|volumeGroups|serviceInstances|instanceGroups";
- private static final String HOMINGSOLUTION = "Homing_Solution";
- private static final String FABRIC_CONFIGURATION = "FabricConfiguration";
- private static final String G_SERVICE_TYPE = "serviceType";
- private static final String SERVICE_TYPE_TRANSPORT = "TRANSPORT";
- private static final Logger logger = LoggerFactory.getLogger(WorkflowAction.class);
-
- @Autowired
- protected BBInputSetup bbInputSetup;
- @Autowired
- protected BBInputSetupUtils bbInputSetupUtils;
- @Autowired
- private ExceptionBuilder exceptionBuilder;
- @Autowired
- private CatalogDbClient catalogDbClient;
- @Autowired
- private AAIConfigurationResources aaiConfigurationResources;
- @Autowired
- private WorkflowActionExtractResourcesAAI workflowActionUtils;
+ private static final String WORKFLOW_ACTION_ERROR_MESSAGE = "WorkflowActionErrorMessage";
+ private static final String SERVICE_INSTANCES = "serviceInstances";
+ private static final String VF_MODULES = "vfModules";
+ private static final String WORKFLOW_ACTION_WAS_UNABLE_TO_VERIFY_IF_THE_INSTANCE_NAME_ALREADY_EXIST_IN_AAI =
+ "WorkflowAction was unable to verify if the instance name already exist in AAI.";
+ private static final String G_ORCHESTRATION_FLOW = "gOrchestrationFlow";
+ private static final String G_ACTION = "requestAction";
+ private static final String G_CURRENT_SEQUENCE = "gCurrentSequence";
+ private static final String G_REQUEST_ID = "mso-request-id";
+ private static final String G_BPMN_REQUEST = "bpmnRequest";
+ private static final String G_ALACARTE = "aLaCarte";
+ private static final String G_APIVERSION = "apiVersion";
+ private static final String G_URI = "requestUri";
+ private static final String G_ISTOPLEVELFLOW = "isTopLevelFlow";
+ private static final String VNF_TYPE = "vnfType";
+ private static final String SERVICE = "Service";
+ private static final String VNF = "Vnf";
+ private static final String VFMODULE = "VfModule";
+ private static final String VOLUMEGROUP = "VolumeGroup";
+ private static final String NETWORK = "Network";
+ private static final String NETWORKCOLLECTION = "NetworkCollection";
+ private static final String CONFIGURATION = "Configuration";
+ private static final String ASSIGNINSTANCE = "assignInstance";
+ private static final String CREATEINSTANCE = "createInstance";
+ private static final String USERPARAMSERVICE = "service";
+ private static final String supportedTypes =
+ "vnfs|vfModules|networks|networkCollections|volumeGroups|serviceInstances|instanceGroups";
+ private static final String HOMINGSOLUTION = "Homing_Solution";
+ private static final String FABRIC_CONFIGURATION = "FabricConfiguration";
+ private static final String G_SERVICE_TYPE = "serviceType";
+ private static final String SERVICE_TYPE_TRANSPORT = "TRANSPORT";
+ private static final Logger logger = LoggerFactory.getLogger(WorkflowAction.class);
+
+ @Autowired
+ protected BBInputSetup bbInputSetup;
+ @Autowired
+ protected BBInputSetupUtils bbInputSetupUtils;
+ @Autowired
+ private ExceptionBuilder exceptionBuilder;
+ @Autowired
+ private CatalogDbClient catalogDbClient;
+ @Autowired
+ private AAIConfigurationResources aaiConfigurationResources;
+ @Autowired
+ private WorkflowActionExtractResourcesAAI workflowActionUtils;
+
+ @Autowired
+ private Environment environment;
+ private String defaultCloudOwner = "org.onap.so.cloud-owner";
+
+ public void setBbInputSetupUtils(BBInputSetupUtils bbInputSetupUtils) {
+ this.bbInputSetupUtils = bbInputSetupUtils;
+ }
+
+ public void setBbInputSetup(BBInputSetup bbInputSetup) {
+ this.bbInputSetup = bbInputSetup;
+ }
+
+ public void selectExecutionList(DelegateExecution execution) throws Exception {
+ final String requestAction = (String) execution.getVariable(G_ACTION);
+ final String requestId = (String) execution.getVariable(G_REQUEST_ID);
+ final String bpmnRequest = (String) execution.getVariable(G_BPMN_REQUEST);
+ final boolean aLaCarte = (boolean) execution.getVariable(G_ALACARTE);
+ final String apiVersion = (String) execution.getVariable(G_APIVERSION);
+ final String uri = (String) execution.getVariable(G_URI);
+ final String vnfType = (String) execution.getVariable(VNF_TYPE);
+ String serviceInstanceId = (String) execution.getVariable("serviceInstanceId");
+ final String serviceType = Optional.ofNullable((String) execution.getVariable(G_SERVICE_TYPE)).orElse("");
+
+ List<OrchestrationFlow> orchFlows = (List<OrchestrationFlow>) execution.getVariable(G_ORCHESTRATION_FLOW);
+ List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
+ WorkflowResourceIds workflowResourceIds = populateResourceIdsFromApiHandler(execution);
+ List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>();
+ List<Resource> resourceCounter = new ArrayList<>();
+ execution.setVariable("sentSyncResponse", false);
+ execution.setVariable("homing", false);
+ execution.setVariable("calledHoming", false);
+
+ try {
+ ObjectMapper mapper = new ObjectMapper();
+ execution.setVariable(G_ISTOPLEVELFLOW, true);
+ ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class);
+ RequestDetails requestDetails = sIRequest.getRequestDetails();
+ String cloudOwner = "";
+ try {
+ cloudOwner = requestDetails.getCloudConfiguration().getCloudOwner();
+ } catch (Exception ex) {
+ cloudOwner = environment.getProperty(defaultCloudOwner);
+ }
+ boolean suppressRollback = false;
+ try {
+ suppressRollback = requestDetails.getRequestInfo().getSuppressRollback();
+ } catch (Exception ex) {
+ suppressRollback = false;
+ }
+ execution.setVariable("suppressRollback", suppressRollback);
+ Resource resource = extractResourceIdAndTypeFromUri(uri);
+ WorkflowType resourceType = resource.getResourceType();
+ execution.setVariable("resourceName", resourceType.toString());
+ String resourceId = "";
+ if (resource.isGenerated()) {
+ resourceId = validateResourceIdInAAI(resource.getResourceId(), resourceType,
+ sIRequest.getRequestDetails().getRequestInfo().getInstanceName(), sIRequest.getRequestDetails(),
+ workflowResourceIds);
+ } else {
+ resourceId = resource.getResourceId();
+ }
+ if ((serviceInstanceId == null || serviceInstanceId.equals("")) && resourceType == WorkflowType.SERVICE) {
+ serviceInstanceId = resourceId;
+ }
+ execution.setVariable("resourceId", resourceId);
+ execution.setVariable("resourceType", resourceType);
+
+ if (aLaCarte) {
+ if (orchFlows == null || orchFlows.isEmpty()) {
+ orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, aLaCarte,
+ cloudOwner, serviceType);
+ }
+ String key = "";
+ ModelInfo modelInfo = sIRequest.getRequestDetails().getModelInfo();
+ if (modelInfo != null) {
+ if (modelInfo.getModelType().equals(ModelType.service)) {
+ key = modelInfo.getModelVersionId();
+ } else {
+ key = modelInfo.getModelCustomizationId();
+ }
+ }
+ boolean isConfiguration = isConfiguration(orchFlows);
+ Resource resourceKey = new Resource(resourceType, key, aLaCarte);
+ if (isConfiguration && !requestAction.equalsIgnoreCase(CREATEINSTANCE)) {
+ List<ExecuteBuildingBlock> configBuildingBlocks = getConfigBuildingBlocks(sIRequest, orchFlows,
+ requestId, resourceKey, apiVersion, resourceId, requestAction, aLaCarte, vnfType,
+ workflowResourceIds, requestDetails, execution);
+ flowsToExecute.addAll(configBuildingBlocks);
+ }
+ orchFlows = orchFlows.stream().filter(item -> !item.getFlowName().contains(FABRIC_CONFIGURATION))
+ .collect(Collectors.toList());
+ for (OrchestrationFlow orchFlow : orchFlows) {
+ ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, requestId, resourceKey, apiVersion,
+ resourceId, requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false,
+ null, false);
+ flowsToExecute.add(ebb);
+ }
+ } else {
+ boolean foundRelated = false;
+ boolean containsService = false;
+ if (resourceType == WorkflowType.SERVICE && requestAction.equalsIgnoreCase(ASSIGNINSTANCE)) {
+ // SERVICE-MACRO-ASSIGN will always get user params with a
+ // service.
+ if (sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) {
+ List<Map<String, Object>> userParams =
+ sIRequest.getRequestDetails().getRequestParameters().getUserParams();
+ for (Map<String, Object> params : userParams) {
+ if (params.containsKey(USERPARAMSERVICE)) {
+ containsService = true;
+ }
+ }
+ if (containsService) {
+ traverseUserParamsService(execution, resourceCounter, sIRequest, requestAction);
+ }
+ } else {
+ buildAndThrowException(execution,
+ "Service-Macro-Assign request details must contain user params with a service");
+ }
+ } else if (resourceType == WorkflowType.SERVICE && requestAction.equalsIgnoreCase(CREATEINSTANCE)) {
+ // SERVICE-MACRO-CREATE will get user params with a service,
+ // a service with a network, a service with a
+ // networkcollection, OR an empty service.
+ // If user params is just a service or null and macro
+ // queries the SI and finds a VNF, macro fails.
+
+ if (sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) {
+ List<Map<String, Object>> userParams =
+ sIRequest.getRequestDetails().getRequestParameters().getUserParams();
+ for (Map<String, Object> params : userParams) {
+ if (params.containsKey(USERPARAMSERVICE)) {
+ containsService = true;
+ }
+ }
+ }
+ if (containsService) {
+ foundRelated = traverseUserParamsService(execution, resourceCounter, sIRequest, requestAction);
+ }
+ if (!foundRelated) {
+ traverseCatalogDbService(execution, sIRequest, resourceCounter);
+ }
+ } else if (resourceType == WorkflowType.SERVICE && (requestAction.equalsIgnoreCase("activateInstance")
+ || requestAction.equalsIgnoreCase("unassignInstance")
+ || requestAction.equalsIgnoreCase("deleteInstance")
+ || requestAction.equalsIgnoreCase("activate" + FABRIC_CONFIGURATION))) {
+ // SERVICE-MACRO-ACTIVATE, SERVICE-MACRO-UNASSIGN, and
+ // SERVICE-MACRO-DELETE
+ // Will never get user params with service, macro will have
+ // to query the SI in AAI to find related instances.
+ traverseAAIService(execution, resourceCounter, resourceId, aaiResourceIds);
+ } else if (resourceType == WorkflowType.SERVICE
+ && requestAction.equalsIgnoreCase("deactivateInstance")) {
+ resourceCounter.add(new Resource(WorkflowType.SERVICE, "", false));
+ } else if (resourceType == WorkflowType.VNF && (requestAction.equalsIgnoreCase("replaceInstance")
+ || (requestAction.equalsIgnoreCase("recreateInstance")))) {
+ traverseAAIVnf(execution, resourceCounter, workflowResourceIds.getServiceInstanceId(),
+ workflowResourceIds.getVnfId(), aaiResourceIds);
+ } else {
+ buildAndThrowException(execution, "Current Macro Request is not supported");
+ }
+ String foundObjects = "";
+ for (WorkflowType type : WorkflowType.values()) {
+ foundObjects = foundObjects + type + " - " + resourceCounter.stream()
+ .filter(x -> type.equals(x.getResourceType())).collect(Collectors.toList()).size() + " ";
+ }
+ logger.info("Found {}", foundObjects);
+
+ if (orchFlows == null || orchFlows.isEmpty()) {
+ orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, aLaCarte,
+ cloudOwner, serviceType);
+ }
+ flowsToExecute =
+ buildExecuteBuildingBlockList(orchFlows, resourceCounter, requestId, apiVersion, resourceId,
+ resourceType, requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails);
+ if (!resourceCounter.stream().filter(x -> WorkflowType.NETWORKCOLLECTION == x.getResourceType())
+ .collect(Collectors.toList()).isEmpty()) {
+ logger.info("Sorting for Vlan Tagging");
+ flowsToExecute = sortExecutionPathByObjectForVlanTagging(flowsToExecute, requestAction);
+ }
+ // By default, enable homing at VNF level for CREATEINSTANCE and ASSIGNINSTANCE
+ if (resourceType == WorkflowType.SERVICE
+ && (requestAction.equals(CREATEINSTANCE) || requestAction.equals(ASSIGNINSTANCE))
+ && !resourceCounter.stream().filter(x -> WorkflowType.VNF.equals(x.getResourceType()))
+ .collect(Collectors.toList()).isEmpty()) {
+ execution.setVariable("homing", true);
+ execution.setVariable("calledHoming", false);
+ }
+ if (resourceType == WorkflowType.SERVICE && (requestAction.equalsIgnoreCase(ASSIGNINSTANCE)
+ || requestAction.equalsIgnoreCase(CREATEINSTANCE))) {
+ generateResourceIds(flowsToExecute, resourceCounter, serviceInstanceId);
+ } else {
+ updateResourceIdsFromAAITraversal(flowsToExecute, resourceCounter, aaiResourceIds,
+ serviceInstanceId);
+ }
+ }
+
+ // If the user set "Homing_Solution" to "none", disable homing, else if "Homing_Solution" is specified,
+ // enable it.
+ if (sIRequest.getRequestDetails().getRequestParameters() != null
+ && sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) {
+ List<Map<String, Object>> userParams =
+ sIRequest.getRequestDetails().getRequestParameters().getUserParams();
+ for (Map<String, Object> params : userParams) {
+ if (params.containsKey(HOMINGSOLUTION)) {
+ if (params.get(HOMINGSOLUTION).equals("none")) {
+ execution.setVariable("homing", false);
+ } else {
+ execution.setVariable("homing", true);
+ }
+ }
+ }
+ }
+
+ if (flowsToExecute.isEmpty()) {
+ throw new IllegalStateException("Macro did not come up with a valid execution path.");
+ }
+ List<String> flowNames = new ArrayList<>();
+ logger.info("List of BuildingBlocks to execute:");
+ for (ExecuteBuildingBlock ebb : flowsToExecute) {
+ logger.info(ebb.getBuildingBlock().getBpmnFlowName());
+ flowNames.add(ebb.getBuildingBlock().getBpmnFlowName());
+ }
+ execution.setVariable("flowNames", flowNames);
+ execution.setVariable(G_CURRENT_SEQUENCE, 0);
+ execution.setVariable("retryCount", 0);
+ execution.setVariable("isRollback", false);
+ execution.setVariable("flowsToExecute", flowsToExecute);
+ execution.setVariable("isRollbackComplete", false);
+
+ } catch (Exception ex) {
+ buildAndThrowException(execution, "Exception in create execution list " + ex.getMessage(), ex);
+ }
+ }
+
+ protected <T> List<T> getRelatedResourcesInVfModule(String vnfId, String vfModuleId, Class<T> resultClass,
+ AAIObjectType type) {
+ List<T> vnfcs = new ArrayList<>();
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId);
+ AAIResultWrapper vfModuleResultsWrapper = bbInputSetupUtils.getAAIResourceDepthOne(uri);
+ Optional<Relationships> relationshipsOp = vfModuleResultsWrapper.getRelationships();
+ if (!relationshipsOp.isPresent()) {
+ logger.debug("No relationships were found for vfModule in AAI");
+ } else {
+ Relationships relationships = relationshipsOp.get();
+ List<AAIResultWrapper> vnfcResultWrappers = relationships.getByType(type);
+ for (AAIResultWrapper vnfcResultWrapper : vnfcResultWrappers) {
+ Optional<T> vnfcOp = vnfcResultWrapper.asBean(resultClass);
+ if (vnfcOp.isPresent()) {
+ vnfcs.add(vnfcOp.get());
+ }
+ }
+ }
+ return vnfcs;
+ }
+
+ protected <T> List<T> getRelatedResourcesInVnfc(Vnfc vnfc, Class<T> resultClass, AAIObjectType type) {
+
+ List<T> configurations = new ArrayList<>();
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VNFC, vnfc.getVnfcName());
+ AAIResultWrapper vnfcResultsWrapper = bbInputSetupUtils.getAAIResourceDepthOne(uri);
+ Optional<Relationships> relationshipsOp = vnfcResultsWrapper.getRelationships();
+ if (!relationshipsOp.isPresent()) {
+ logger.debug("No relationships were found for VNFC in AAI");
+ } else {
+ Relationships relationships = relationshipsOp.get();
+ List<AAIResultWrapper> configurationResultWrappers =
+ this.getResultWrappersFromRelationships(relationships, type);
+ for (AAIResultWrapper configurationResultWrapper : configurationResultWrappers) {
+ Optional<T> configurationOp = configurationResultWrapper.asBean(resultClass);
+ if (configurationOp.isPresent()) {
+ configurations.add(configurationOp.get());
+ }
+ }
+ }
+ return configurations;
+ }
+
+ protected List<AAIResultWrapper> getResultWrappersFromRelationships(Relationships relationships,
+ AAIObjectType type) {
+ return relationships.getByType(type);
+ }
- @Autowired
- private Environment environment;
- private String defaultCloudOwner = "org.onap.so.cloud-owner";
+ protected boolean isConfiguration(List<OrchestrationFlow> orchFlows) {
+ for (OrchestrationFlow flow : orchFlows) {
+ if (flow.getFlowName().contains("Configuration")) {
+ return true;
+ }
+ }
+ return false;
+ }
- public void setBbInputSetupUtils(BBInputSetupUtils bbInputSetupUtils) {
- this.bbInputSetupUtils = bbInputSetupUtils;
- }
+ protected List<ExecuteBuildingBlock> getConfigBuildingBlocks(ServiceInstancesRequest sIRequest,
+ List<OrchestrationFlow> orchFlows, String requestId, Resource resourceKey, String apiVersion,
+ String resourceId, String requestAction, boolean aLaCarte, String vnfType,
+ WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails, DelegateExecution execution) {
- public void setBbInputSetup(BBInputSetup bbInputSetup) {
- this.bbInputSetup = bbInputSetup;
- }
+ List<ExecuteBuildingBlock> flowsToExecuteConfigs = new ArrayList<>();
+ List<OrchestrationFlow> result = new ArrayList<>(orchFlows);
+ result = orchFlows.stream().filter(item -> item.getFlowName().contains(FABRIC_CONFIGURATION))
+ .collect(Collectors.toList());
+ String vnfId = workflowResourceIds.getVnfId();
+ String vfModuleId = workflowResourceIds.getVfModuleId();
- public void selectExecutionList(DelegateExecution execution) throws Exception {
- final String requestAction = (String) execution.getVariable(G_ACTION);
- final String requestId = (String) execution.getVariable(G_REQUEST_ID);
- final String bpmnRequest = (String) execution.getVariable(G_BPMN_REQUEST);
- final boolean aLaCarte = (boolean) execution.getVariable(G_ALACARTE);
- final String apiVersion = (String) execution.getVariable(G_APIVERSION);
- final String uri = (String) execution.getVariable(G_URI);
- final String vnfType = (String) execution.getVariable(VNF_TYPE);
- String serviceInstanceId = (String) execution.getVariable("serviceInstanceId");
- final String serviceType = Optional.ofNullable((String) execution.getVariable(G_SERVICE_TYPE)).orElse("");
+ String vnfCustomizationUUID = bbInputSetupUtils.getAAIGenericVnf(vnfId).getModelCustomizationId();
+ String vfModuleCustomizationUUID =
+ bbInputSetupUtils.getAAIVfModule(vnfId, vfModuleId).getModelCustomizationId();
- List<OrchestrationFlow> orchFlows = (List<OrchestrationFlow>) execution.getVariable(G_ORCHESTRATION_FLOW);
- List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
- WorkflowResourceIds workflowResourceIds = populateResourceIdsFromApiHandler(execution);
- List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>();
- List<Resource> resourceCounter = new ArrayList<>();
- execution.setVariable("sentSyncResponse", false);
- execution.setVariable("homing", false);
- execution.setVariable("calledHoming", false);
+ List<org.onap.aai.domain.yang.Vnfc> vnfcs = getRelatedResourcesInVfModule(vnfId, vfModuleId,
+ org.onap.aai.domain.yang.Vnfc.class, AAIObjectType.VNFC);
+ for (org.onap.aai.domain.yang.Vnfc vnfc : vnfcs) {
+ List<org.onap.aai.domain.yang.Configuration> configurations = getRelatedResourcesInVnfc(vnfc,
+ org.onap.aai.domain.yang.Configuration.class, AAIObjectType.CONFIGURATION);
+ if (configurations.size() > 1) {
+ String multipleRelationshipsError =
+ "Multiple relationships exist from VNFC " + vnfc.getVnfcName() + " to Configurations";
+ buildAndThrowException(execution, multipleRelationshipsError,
+ new Exception(multipleRelationshipsError));
+ }
+ for (org.onap.aai.domain.yang.Configuration configuration : configurations) {
+ workflowResourceIds.setConfigurationId(configuration.getConfigurationId());
+ for (OrchestrationFlow orchFlow : result) {
+ resourceKey.setVfModuleCustomizationId(vfModuleCustomizationUUID);
+ resourceKey.setCvnfModuleCustomizationId(vnfc.getModelCustomizationId());
+ resourceKey.setVnfCustomizationId(vnfCustomizationUUID);
+ ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, requestId, resourceKey, apiVersion,
+ resourceId, requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false,
+ null, true);
+ String vnfcName = getVnfcNameForConfiguration(configuration);
+ if (vnfcName == null || vnfcName.isEmpty()) {
+ buildAndThrowException(execution, "Exception in create execution list "
+ + ": VnfcName does not exist or is null while there is a configuration for the vfModule",
+ new Exception("Vnfc and Configuration do not match"));
+ }
+ ebb.getConfigurationResourceKeys().setVnfcName(vnfcName);
+ flowsToExecuteConfigs.add(ebb);
+ }
+ }
+ }
+ return flowsToExecuteConfigs;
+ }
- try {
- ObjectMapper mapper = new ObjectMapper();
- execution.setVariable(G_ISTOPLEVELFLOW, true);
- ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class);
- RequestDetails requestDetails = sIRequest.getRequestDetails();
- String cloudOwner = "";
- try{
- cloudOwner = requestDetails.getCloudConfiguration().getCloudOwner();
- } catch (Exception ex) {
- cloudOwner = environment.getProperty(defaultCloudOwner);
- }
- boolean suppressRollback = false;
- try{
- suppressRollback = requestDetails.getRequestInfo().getSuppressRollback();
- } catch (Exception ex) {
- suppressRollback = false;
- }
- execution.setVariable("suppressRollback", suppressRollback);
- Resource resource = extractResourceIdAndTypeFromUri(uri);
- WorkflowType resourceType = resource.getResourceType();
- execution.setVariable("resourceName", resourceType.toString());
- String resourceId = "";
- if (resource.isGenerated()) {
- resourceId = validateResourceIdInAAI(resource.getResourceId(), resourceType,
- sIRequest.getRequestDetails().getRequestInfo().getInstanceName(), sIRequest.getRequestDetails(),
- workflowResourceIds);
- } else {
- resourceId = resource.getResourceId();
- }
- if((serviceInstanceId == null || serviceInstanceId.equals("")) && resourceType == WorkflowType.SERVICE){
- serviceInstanceId = resourceId;
- }
- execution.setVariable("resourceId", resourceId);
- execution.setVariable("resourceType", resourceType);
+ protected String getVnfcNameForConfiguration(org.onap.aai.domain.yang.Configuration configuration) {
+ AAIResultWrapper wrapper = new AAIResultWrapper(configuration);
+ Optional<Relationships> relationshipsOp = wrapper.getRelationships();
+ if (!relationshipsOp.isPresent()) {
+ logger.debug("No relationships were found for Configuration in AAI");
+ return null;
+ } else {
+ Relationships relationships = relationshipsOp.get();
+ List<AAIResultWrapper> vnfcResultWrappers = relationships.getByType(AAIObjectType.VNFC);
+ if (vnfcResultWrappers.size() > 1 || vnfcResultWrappers.isEmpty()) {
+ logger.debug("Too many vnfcs or no vnfc found that are related to configuration");
+ }
+ Optional<Vnfc> vnfcOp = vnfcResultWrappers.get(0).asBean(Vnfc.class);
+ if (vnfcOp.isPresent()) {
+ return vnfcOp.get().getVnfcName();
+ } else {
+ return null;
+ }
+ }
+ }
- if (aLaCarte) {
- if (orchFlows == null || orchFlows.isEmpty()) {
- orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, aLaCarte, cloudOwner, serviceType);
- }
- String key = "";
- ModelInfo modelInfo = sIRequest.getRequestDetails().getModelInfo();
- if(modelInfo != null) {
- if(modelInfo.getModelType().equals(ModelType.service)) {
- key = modelInfo.getModelVersionId();
- } else {
- key = modelInfo.getModelCustomizationId();
- }
- }
- boolean isConfiguration = isConfiguration(orchFlows);
- Resource resourceKey = new Resource(resourceType, key, aLaCarte);
- if(isConfiguration && !requestAction.equalsIgnoreCase(CREATEINSTANCE)) {
- List<ExecuteBuildingBlock> configBuildingBlocks = getConfigBuildingBlocks(sIRequest, orchFlows, requestId, resourceKey, apiVersion, resourceId, requestAction, aLaCarte, vnfType,
- workflowResourceIds, requestDetails, execution);
- flowsToExecute.addAll(configBuildingBlocks);
- }
- orchFlows = orchFlows.stream().filter(item -> !item.getFlowName().contains(FABRIC_CONFIGURATION)).collect(Collectors.toList());
- for (OrchestrationFlow orchFlow : orchFlows) {
- ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, requestId, resourceKey, apiVersion, resourceId,
- requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null, false);
- flowsToExecute.add(ebb);
- }
- } else {
- boolean foundRelated = false;
- boolean containsService = false;
- if (resourceType == WorkflowType.SERVICE && requestAction.equalsIgnoreCase(ASSIGNINSTANCE)) {
- // SERVICE-MACRO-ASSIGN will always get user params with a
- // service.
- if (sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) {
- List<Map<String, Object>> userParams = sIRequest.getRequestDetails().getRequestParameters()
- .getUserParams();
- for (Map<String, Object> params : userParams) {
- if (params.containsKey(USERPARAMSERVICE)) {
- containsService = true;
- }
- }
- if (containsService) {
- traverseUserParamsService(execution, resourceCounter, sIRequest, requestAction);
- }
- } else {
- buildAndThrowException(execution,
- "Service-Macro-Assign request details must contain user params with a service");
- }
- } else if (resourceType == WorkflowType.SERVICE
- && requestAction.equalsIgnoreCase(CREATEINSTANCE)) {
- // SERVICE-MACRO-CREATE will get user params with a service,
- // a service with a network, a service with a
- // networkcollection, OR an empty service.
- // If user params is just a service or null and macro
- // queries the SI and finds a VNF, macro fails.
+ protected List<Resource> sortVfModulesByBaseFirst(List<Resource> vfModuleResources) {
+ int count = 0;
+ for (Resource resource : vfModuleResources) {
+ if (resource.isBaseVfModule()) {
+ Collections.swap(vfModuleResources, 0, count);
+ break;
+ }
+ count++;
+ }
+ return vfModuleResources;
+ }
- if (sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) {
- List<Map<String, Object>> userParams = sIRequest.getRequestDetails().getRequestParameters()
- .getUserParams();
- for (Map<String, Object> params : userParams) {
- if (params.containsKey(USERPARAMSERVICE)) {
- containsService = true;
- }
- }
- }
- if (containsService) {
- foundRelated = traverseUserParamsService(execution, resourceCounter, sIRequest, requestAction);
- }
- if (!foundRelated) {
- traverseCatalogDbService(execution, sIRequest, resourceCounter);
- }
- } else if (resourceType == WorkflowType.SERVICE
- && (requestAction.equalsIgnoreCase("activateInstance")
- || requestAction.equalsIgnoreCase("unassignInstance")
- || requestAction.equalsIgnoreCase("deleteInstance")
- || requestAction.equalsIgnoreCase("activate" + FABRIC_CONFIGURATION))) {
- // SERVICE-MACRO-ACTIVATE, SERVICE-MACRO-UNASSIGN, and
- // SERVICE-MACRO-DELETE
- // Will never get user params with service, macro will have
- // to query the SI in AAI to find related instances.
- traverseAAIService(execution, resourceCounter, resourceId, aaiResourceIds);
- } else if (resourceType == WorkflowType.SERVICE
- && requestAction.equalsIgnoreCase("deactivateInstance")) {
- resourceCounter.add(new Resource(WorkflowType.SERVICE,"",false));
- } else if (resourceType == WorkflowType.VNF && (requestAction.equalsIgnoreCase("replaceInstance") || (requestAction.equalsIgnoreCase("recreateInstance")))) {
- traverseAAIVnf(execution, resourceCounter, workflowResourceIds.getServiceInstanceId(), workflowResourceIds.getVnfId(), aaiResourceIds);
- } else {
- buildAndThrowException(execution, "Current Macro Request is not supported");
- }
- String foundObjects = "";
- for(WorkflowType type : WorkflowType.values()){
- foundObjects = foundObjects + type + " - " + resourceCounter.stream().filter(x -> type.equals(x.getResourceType())).collect(Collectors.toList()).size() + " ";
- }
- logger.info("Found {}", foundObjects);
+ protected List<Resource> sortVfModulesByBaseLast(List<Resource> vfModuleResources) {
+ int count = 0;
+ for (Resource resource : vfModuleResources) {
+ if (resource.isBaseVfModule()) {
+ Collections.swap(vfModuleResources, vfModuleResources.size() - 1, count);
+ break;
+ }
+ count++;
+ }
+ return vfModuleResources;
+ }
- if (orchFlows == null || orchFlows.isEmpty()) {
- orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, aLaCarte, cloudOwner, serviceType);
- }
- flowsToExecute = buildExecuteBuildingBlockList(orchFlows, resourceCounter, requestId, apiVersion, resourceId,
- resourceType, requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails);
- if (!resourceCounter.stream().filter(x -> WorkflowType.NETWORKCOLLECTION == x.getResourceType()).collect(Collectors.toList()).isEmpty()) {
- logger.info("Sorting for Vlan Tagging");
- flowsToExecute = sortExecutionPathByObjectForVlanTagging(flowsToExecute, requestAction);
- }
- // By default, enable homing at VNF level for CREATEINSTANCE and ASSIGNINSTANCE
- if (resourceType == WorkflowType.SERVICE
- && (requestAction.equals(CREATEINSTANCE) || requestAction.equals(ASSIGNINSTANCE))
- && !resourceCounter.stream().filter(x -> WorkflowType.VNF.equals(x.getResourceType())).collect(Collectors.toList()).isEmpty()) {
- execution.setVariable("homing", true);
- execution.setVariable("calledHoming", false);
- }
- if (resourceType == WorkflowType.SERVICE && (requestAction.equalsIgnoreCase(ASSIGNINSTANCE) || requestAction.equalsIgnoreCase(CREATEINSTANCE))){
- generateResourceIds(flowsToExecute, resourceCounter, serviceInstanceId);
- }else{
- updateResourceIdsFromAAITraversal(flowsToExecute, resourceCounter, aaiResourceIds, serviceInstanceId);
- }
- }
+ private void updateResourceIdsFromAAITraversal(List<ExecuteBuildingBlock> flowsToExecute,
+ List<Resource> resourceCounter, List<Pair<WorkflowType, String>> aaiResourceIds, String serviceInstanceId) {
+ for (Pair<WorkflowType, String> pair : aaiResourceIds) {
+ logger.debug(pair.getValue0() + ", " + pair.getValue1());
+ }
- // If the user set "Homing_Solution" to "none", disable homing, else if "Homing_Solution" is specified, enable it.
- if (sIRequest.getRequestDetails().getRequestParameters() != null &&
- sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) {
- List<Map<String, Object>> userParams = sIRequest.getRequestDetails().getRequestParameters().getUserParams();
- for (Map<String, Object> params : userParams) {
- if (params.containsKey(HOMINGSOLUTION)) {
- if (params.get(HOMINGSOLUTION).equals("none")) {
- execution.setVariable("homing", false);
- } else {
- execution.setVariable("homing", true);
- }
- }
- }
- }
+ Arrays.stream(WorkflowType.values()).filter(type -> !type.equals(WorkflowType.SERVICE)).forEach(type -> {
+ List<Resource> resources =
+ resourceCounter.stream().filter(x -> type.equals(x.getResourceType())).collect(Collectors.toList());
+ for (int i = 0; i < resources.size(); i++) {
+ updateWorkflowResourceIds(flowsToExecute, type, resources.get(i).getResourceId(),
+ retrieveAAIResourceId(aaiResourceIds, type), null, serviceInstanceId);
+ }
+ });
+ }
- if (flowsToExecute.isEmpty()) {
- throw new IllegalStateException("Macro did not come up with a valid execution path.");
- }
- List<String> flowNames = new ArrayList<>();
- logger.info("List of BuildingBlocks to execute:");
- for (ExecuteBuildingBlock ebb : flowsToExecute) {
- logger.info(ebb.getBuildingBlock().getBpmnFlowName());
- flowNames.add(ebb.getBuildingBlock().getBpmnFlowName());
- }
- execution.setVariable("flowNames", flowNames);
- execution.setVariable(G_CURRENT_SEQUENCE, 0);
- execution.setVariable("retryCount", 0);
- execution.setVariable("isRollback", false);
- execution.setVariable("flowsToExecute", flowsToExecute);
- execution.setVariable("isRollbackComplete", false);
+ private String retrieveAAIResourceId(List<Pair<WorkflowType, String>> aaiResourceIds, WorkflowType resource) {
+ String id = null;
+ for (int i = 0; i < aaiResourceIds.size(); i++) {
+ if (aaiResourceIds.get(i).getValue0() == resource) {
+ id = aaiResourceIds.get(i).getValue1();
+ aaiResourceIds.remove(i);
+ break;
+ }
+ }
+ return id;
+ }
- } catch (Exception ex) {
- buildAndThrowException(execution, "Exception in create execution list " + ex.getMessage(), ex);
- }
- }
-
- protected <T> List<T> getRelatedResourcesInVfModule(String vnfId, String vfModuleId, Class<T> resultClass, AAIObjectType type) {
- List<T> vnfcs = new ArrayList<>();
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId);
- AAIResultWrapper vfModuleResultsWrapper = bbInputSetupUtils.getAAIResourceDepthOne(uri);
- Optional<Relationships> relationshipsOp = vfModuleResultsWrapper.getRelationships();
- if (!relationshipsOp.isPresent()) {
- logger.debug("No relationships were found for vfModule in AAI");
- } else {
- Relationships relationships = relationshipsOp.get();
- List<AAIResultWrapper> vnfcResultWrappers = relationships.getByType(type);
- for(AAIResultWrapper vnfcResultWrapper : vnfcResultWrappers) {
- Optional<T> vnfcOp = vnfcResultWrapper.asBean(resultClass);
- if(vnfcOp.isPresent()) {
- vnfcs.add(vnfcOp.get());
- }
- }
- }
- return vnfcs;
- }
-
- protected <T> List<T> getRelatedResourcesInVnfc(Vnfc vnfc, Class<T> resultClass, AAIObjectType type) {
-
- List<T> configurations = new ArrayList<>();
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VNFC, vnfc.getVnfcName());
- AAIResultWrapper vnfcResultsWrapper = bbInputSetupUtils.getAAIResourceDepthOne(uri);
- Optional<Relationships> relationshipsOp = vnfcResultsWrapper.getRelationships();
- if (!relationshipsOp.isPresent()) {
- logger.debug("No relationships were found for VNFC in AAI");
- } else {
- Relationships relationships = relationshipsOp.get();
- List<AAIResultWrapper> configurationResultWrappers = this.getResultWrappersFromRelationships(relationships, type);
- for(AAIResultWrapper configurationResultWrapper : configurationResultWrappers) {
- Optional<T> configurationOp = configurationResultWrapper.asBean(resultClass);
- if(configurationOp.isPresent()) {
- configurations.add(configurationOp.get());
- }
- }
- }
- return configurations;
- }
-
- protected List<AAIResultWrapper> getResultWrappersFromRelationships(Relationships relationships, AAIObjectType type){
- return relationships.getByType(type);
- }
-
- protected boolean isConfiguration(List<OrchestrationFlow> orchFlows) {
- for(OrchestrationFlow flow : orchFlows) {
- if(flow.getFlowName().contains("Configuration")) {
- return true;
- }
- }
- return false;
- }
+ private void generateResourceIds(List<ExecuteBuildingBlock> flowsToExecute, List<Resource> resourceCounter,
+ String serviceInstanceId) {
+ Arrays.stream(WorkflowType.values()).filter(type -> !type.equals(WorkflowType.SERVICE)).forEach(type -> {
+ List<Resource> resources =
+ resourceCounter.stream().filter(x -> type.equals(x.getResourceType())).collect(Collectors.toList());
+ for (int i = 0; i < resources.size(); i++) {
+ Resource resource = resourceCounter.stream().filter(x -> type.equals(x.getResourceType()))
+ .collect(Collectors.toList()).get(i);
+ updateWorkflowResourceIds(flowsToExecute, type, resource.getResourceId(), null,
+ resource.getVirtualLinkKey(), serviceInstanceId);
+ }
+ });
+ }
- protected List<ExecuteBuildingBlock> getConfigBuildingBlocks(ServiceInstancesRequest sIRequest, List<OrchestrationFlow> orchFlows, String requestId, Resource resourceKey,
- String apiVersion, String resourceId, String requestAction, boolean aLaCarte, String vnfType,
- WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails, DelegateExecution execution) {
-
- List<ExecuteBuildingBlock> flowsToExecuteConfigs = new ArrayList<>();
- List<OrchestrationFlow> result = new ArrayList<>(orchFlows);
- result = orchFlows.stream().filter(item -> item.getFlowName().contains(FABRIC_CONFIGURATION)).collect(Collectors.toList());
- String vnfId = workflowResourceIds.getVnfId();
- String vfModuleId = workflowResourceIds.getVfModuleId();
-
- String vnfCustomizationUUID = bbInputSetupUtils.getAAIGenericVnf(vnfId).getModelCustomizationId();
- String vfModuleCustomizationUUID = bbInputSetupUtils.getAAIVfModule(vnfId, vfModuleId).getModelCustomizationId();
+ protected void updateWorkflowResourceIds(List<ExecuteBuildingBlock> flowsToExecute, WorkflowType resource,
+ String key, String id, String virtualLinkKey, String serviceInstanceId) {
+ String resourceId = id;
+ if (resourceId == null) {
+ resourceId = UUID.randomUUID().toString();
+ }
+ for (ExecuteBuildingBlock ebb : flowsToExecute) {
+ if (key != null && key.equalsIgnoreCase(ebb.getBuildingBlock().getKey())
+ && ebb.getBuildingBlock().getBpmnFlowName().contains(resource.toString())) {
+ WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
+ workflowResourceIds.setServiceInstanceId(serviceInstanceId);
+ if (resource == WorkflowType.VNF) {
+ workflowResourceIds.setVnfId(resourceId);
+ } else if (resource == WorkflowType.VFMODULE) {
+ workflowResourceIds.setVfModuleId(resourceId);
+ } else if (resource == WorkflowType.VOLUMEGROUP) {
+ workflowResourceIds.setVolumeGroupId(resourceId);
+ } else if (resource == WorkflowType.NETWORK) {
+ workflowResourceIds.setNetworkId(resourceId);
+ } else if (resource == WorkflowType.NETWORKCOLLECTION) {
+ workflowResourceIds.setNetworkCollectionId(resourceId);
+ } else if (resource == WorkflowType.CONFIGURATION) {
+ workflowResourceIds.setConfigurationId(resourceId);
+ }
+ ebb.setWorkflowResourceIds(workflowResourceIds);
+ }
+ if (virtualLinkKey != null && ebb.getBuildingBlock().getIsVirtualLink()
+ && virtualLinkKey.equalsIgnoreCase(ebb.getBuildingBlock().getVirtualLinkKey())) {
+ WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
+ workflowResourceIds.setServiceInstanceId(serviceInstanceId);
+ workflowResourceIds.setNetworkId(resourceId);
+ ebb.setWorkflowResourceIds(workflowResourceIds);
+ }
+ }
+ }
- List<org.onap.aai.domain.yang.Vnfc> vnfcs = getRelatedResourcesInVfModule(vnfId, vfModuleId, org.onap.aai.domain.yang.Vnfc.class, AAIObjectType.VNFC);
- for(org.onap.aai.domain.yang.Vnfc vnfc : vnfcs) {
- List<org.onap.aai.domain.yang.Configuration> configurations = getRelatedResourcesInVnfc(vnfc, org.onap.aai.domain.yang.Configuration.class, AAIObjectType.CONFIGURATION);
- if (configurations.size() > 1){
- String multipleRelationshipsError = "Multiple relationships exist from VNFC "+vnfc.getVnfcName()+" to Configurations";
- buildAndThrowException(execution, multipleRelationshipsError, new Exception(multipleRelationshipsError));
- }
- for(org.onap.aai.domain.yang.Configuration configuration : configurations) {
- workflowResourceIds.setConfigurationId(configuration.getConfigurationId());
- for(OrchestrationFlow orchFlow : result) {
- resourceKey.setVfModuleCustomizationId(vfModuleCustomizationUUID);
- resourceKey.setCvnfModuleCustomizationId(vnfc.getModelCustomizationId());
- resourceKey.setVnfCustomizationId(vnfCustomizationUUID);
- ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, requestId, resourceKey, apiVersion, resourceId,
- requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null, true);
- String vnfcName = getVnfcNameForConfiguration(configuration);
- if(vnfcName == null || vnfcName.isEmpty()) {
- buildAndThrowException(execution, "Exception in create execution list " + ": VnfcName does not exist or is null while there is a configuration for the vfModule", new Exception("Vnfc and Configuration do not match"));
- }
- ebb.getConfigurationResourceKeys().setVnfcName(vnfcName);
- flowsToExecuteConfigs.add(ebb);
- }
- }
- }
- return flowsToExecuteConfigs;
- }
-
- protected String getVnfcNameForConfiguration(org.onap.aai.domain.yang.Configuration configuration) {
- AAIResultWrapper wrapper = new AAIResultWrapper(configuration);
- Optional<Relationships> relationshipsOp = wrapper.getRelationships();
- if (!relationshipsOp.isPresent()) {
- logger.debug("No relationships were found for Configuration in AAI");
- return null;
- } else {
- Relationships relationships = relationshipsOp.get();
- List<AAIResultWrapper> vnfcResultWrappers = relationships.getByType(AAIObjectType.VNFC);
- if(vnfcResultWrappers.size() > 1 || vnfcResultWrappers.isEmpty()) {
- logger.debug("Too many vnfcs or no vnfc found that are related to configuration");
- }
- Optional<Vnfc> vnfcOp = vnfcResultWrappers.get(0).asBean(Vnfc.class);
- if(vnfcOp.isPresent()) {
- return vnfcOp.get().getVnfcName();
- } else {
- return null;
- }
- }
- }
+ protected CollectionResourceCustomization findCatalogNetworkCollection(DelegateExecution execution,
+ org.onap.so.db.catalog.beans.Service service) {
+ CollectionResourceCustomization networkCollection = null;
+ int count = 0;
+ for (CollectionResourceCustomization collectionCust : service.getCollectionResourceCustomizations()) {
+ if (catalogDbClient.getNetworkCollectionResourceCustomizationByID(
+ collectionCust.getModelCustomizationUUID()) != null) {
+ networkCollection = collectionCust;
+ count++;
+ }
+ }
+ if (count == 0) {
+ return null;
+ } else if (count > 1) {
+ buildAndThrowException(execution,
+ "Found multiple Network Collections in the Service model, only one per Service is supported.");
+ }
+ return networkCollection;
+ }
- protected List<Resource> sortVfModulesByBaseFirst(List<Resource> vfModuleResources) {
- int count = 0;
- for(Resource resource : vfModuleResources){
- if(resource.isBaseVfModule()){
- Collections.swap(vfModuleResources, 0, count);
- break;
- }
- count++;
- }
- return vfModuleResources;
- }
-
- protected List<Resource> sortVfModulesByBaseLast(List<Resource> vfModuleResources) {
- int count = 0;
- for(Resource resource : vfModuleResources){
- if(resource.isBaseVfModule()){
- Collections.swap(vfModuleResources, vfModuleResources.size()-1, count);
- break;
- }
- count++;
- }
- return vfModuleResources;
- }
+ protected void traverseCatalogDbService(DelegateExecution execution, ServiceInstancesRequest sIRequest,
+ List<Resource> resourceCounter) {
+ String modelUUID = sIRequest.getRequestDetails().getModelInfo().getModelVersionId();
+ org.onap.so.db.catalog.beans.Service service = catalogDbClient.getServiceByID(modelUUID);
+ if (service == null) {
+ buildAndThrowException(execution, "Could not find the service model in catalog db.");
+ } else {
+ resourceCounter.add(new Resource(WorkflowType.SERVICE, service.getModelUUID(), false));
+ if (service.getVnfCustomizations() == null || service.getVnfCustomizations().isEmpty()) {
+ List<CollectionResourceCustomization> customizations = service.getCollectionResourceCustomizations();
+ if (customizations.isEmpty()) {
+ logger.debug("No Collections found. CollectionResourceCustomization list is empty.");
+ } else {
+ CollectionResourceCustomization collectionResourceCustomization =
+ findCatalogNetworkCollection(execution, service);
+ if (collectionResourceCustomization != null) {
+ resourceCounter.add(new Resource(WorkflowType.NETWORKCOLLECTION,
+ collectionResourceCustomization.getModelCustomizationUUID(), false));
+ logger.debug("Found a network collection");
+ if (collectionResourceCustomization.getCollectionResource() != null) {
+ if (collectionResourceCustomization.getCollectionResource().getInstanceGroup() != null) {
+ String toscaNodeType = collectionResourceCustomization.getCollectionResource()
+ .getInstanceGroup().getToscaNodeType();
+ if (toscaNodeType != null && toscaNodeType.contains("NetworkCollection")) {
+ int minNetworks = 0;
+ org.onap.so.db.catalog.beans.InstanceGroup instanceGroup =
+ collectionResourceCustomization.getCollectionResource().getInstanceGroup();
+ CollectionResourceInstanceGroupCustomization collectionInstCust = null;
+ if (!instanceGroup.getCollectionInstanceGroupCustomizations().isEmpty()) {
+ for (CollectionResourceInstanceGroupCustomization collectionInstanceGroupTemp : instanceGroup
+ .getCollectionInstanceGroupCustomizations()) {
+ if (collectionInstanceGroupTemp.getModelCustomizationUUID()
+ .equalsIgnoreCase(collectionResourceCustomization
+ .getModelCustomizationUUID())) {
+ collectionInstCust = collectionInstanceGroupTemp;
+ break;
+ }
+ }
+ if (collectionInstCust != null
+ && collectionInstCust.getSubInterfaceNetworkQuantity() != null) {
+ minNetworks = collectionInstCust.getSubInterfaceNetworkQuantity();
+ }
+ }
+ logger.debug("minNetworks: {}", minNetworks);
+ CollectionNetworkResourceCustomization collectionNetworkResourceCust = null;
+ for (CollectionNetworkResourceCustomization collectionNetworkTemp : instanceGroup
+ .getCollectionNetworkResourceCustomizations()) {
+ if (collectionNetworkTemp.getNetworkResourceCustomization()
+ .getModelCustomizationUUID().equalsIgnoreCase(
+ collectionResourceCustomization.getModelCustomizationUUID())) {
+ collectionNetworkResourceCust = collectionNetworkTemp;
+ break;
+ }
+ }
+ for (int i = 0; i < minNetworks; i++) {
+ if (collectionNetworkResourceCust != null && collectionInstCust != null) {
+ Resource resource = new Resource(WorkflowType.VIRTUAL_LINK,
+ collectionNetworkResourceCust.getModelCustomizationUUID(), false);
+ resource.setVirtualLinkKey(Integer.toString(i));
+ resourceCounter.add(resource);
+ }
+ }
+ } else {
+ logger.debug(
+ "Instance Group tosca node type does not contain NetworkCollection: {}",
+ toscaNodeType);
+ }
+ } else {
+ logger.debug("No Instance Group found for network collection.");
+ }
+ } else {
+ logger.debug("No Network Collection found. collectionResource is null");
+ }
+ } else {
+ logger.debug("No Network Collection Customization found");
+ }
+ }
+ if (resourceCounter.stream().filter(x -> WorkflowType.NETWORKCOLLECTION == x.getResourceType())
+ .collect(Collectors.toList()).isEmpty()) {
+ if (service.getNetworkCustomizations() == null) {
+ logger.debug("No networks were found on this service model");
+ } else {
+ for (int i = 0; i < service.getNetworkCustomizations().size(); i++) {
+ resourceCounter.add(new Resource(WorkflowType.NETWORK,
+ service.getNetworkCustomizations().get(i).getModelCustomizationUUID(), false));
+ }
+ }
+ }
+ } else {
+ buildAndThrowException(execution,
+ "Cannot orchestrate Service-Macro-Create without user params with a vnf. Please update ASDC model for new macro orchestration support or add service_recipe records to route to old macro flows");
+ }
+ }
+ }
- private void updateResourceIdsFromAAITraversal(List<ExecuteBuildingBlock> flowsToExecute,
- List<Resource> resourceCounter, List<Pair<WorkflowType, String>> aaiResourceIds, String serviceInstanceId) {
- for(Pair<WorkflowType,String> pair : aaiResourceIds){
- logger.debug(pair.getValue0() + ", " + pair.getValue1());
- }
-
- Arrays.stream(WorkflowType.values()).filter(type -> !type.equals(WorkflowType.SERVICE)).forEach(type -> {
- List<Resource> resources = resourceCounter.stream().filter(x -> type.equals(x.getResourceType())).collect(Collectors.toList());
- for(int i = 0; i < resources.size(); i++){
- updateWorkflowResourceIds(flowsToExecute, type, resources.get(i).getResourceId(), retrieveAAIResourceId(aaiResourceIds,type), null, serviceInstanceId);
- }
- });
- }
+ protected void traverseAAIService(DelegateExecution execution, List<Resource> resourceCounter, String resourceId,
+ List<Pair<WorkflowType, String>> aaiResourceIds) {
+ try {
+ ServiceInstance serviceInstanceAAI = bbInputSetupUtils.getAAIServiceInstanceById(resourceId);
+ org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO =
+ bbInputSetup.getExistingServiceInstance(serviceInstanceAAI);
+ resourceCounter.add(new Resource(WorkflowType.SERVICE, serviceInstanceMSO.getServiceInstanceId(), false));
+ if (serviceInstanceMSO.getVnfs() != null) {
+ for (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf : serviceInstanceMSO.getVnfs()) {
+ aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.VNF, vnf.getVnfId()));
+ resourceCounter.add(new Resource(WorkflowType.VNF, vnf.getVnfId(), false));
+ if (vnf.getVfModules() != null) {
+ for (VfModule vfModule : vnf.getVfModules()) {
+ aaiResourceIds.add(
+ new Pair<WorkflowType, String>(WorkflowType.VFMODULE, vfModule.getVfModuleId()));
+ resourceCounter.add(new Resource(WorkflowType.VFMODULE, vfModule.getVfModuleId(), false));
+ }
+ }
+ if (vnf.getVolumeGroups() != null) {
+ for (org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup volumeGroup : vnf
+ .getVolumeGroups()) {
+ aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.VOLUMEGROUP,
+ volumeGroup.getVolumeGroupId()));
+ resourceCounter
+ .add(new Resource(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId(), false));
+ }
+ }
+ }
+ }
+ if (serviceInstanceMSO.getNetworks() != null) {
+ for (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network network : serviceInstanceMSO
+ .getNetworks()) {
+ aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.NETWORK, network.getNetworkId()));
+ resourceCounter.add(new Resource(WorkflowType.NETWORK, network.getNetworkId(), false));
+ }
+ }
+ if (serviceInstanceMSO.getCollection() != null) {
+ logger.debug("found networkcollection");
+ aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.NETWORKCOLLECTION,
+ serviceInstanceMSO.getCollection().getId()));
+ resourceCounter.add(new Resource(WorkflowType.NETWORKCOLLECTION,
+ serviceInstanceMSO.getCollection().getId(), false));
+ }
+ if (serviceInstanceMSO.getConfigurations() != null) {
+ for (Configuration config : serviceInstanceMSO.getConfigurations()) {
+ Optional<org.onap.aai.domain.yang.Configuration> aaiConfig =
+ aaiConfigurationResources.getConfiguration(config.getConfigurationId());
+ if (aaiConfig.isPresent() && aaiConfig.get().getRelationshipList() != null) {
+ for (Relationship relationship : aaiConfig.get().getRelationshipList().getRelationship()) {
+ if (relationship.getRelatedTo().contains("vnfc")) {
+ aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.CONFIGURATION,
+ config.getConfigurationId()));
+ resourceCounter.add(
+ new Resource(WorkflowType.CONFIGURATION, config.getConfigurationId(), false));
+ break;
+ }
+ }
+ }
+ }
+ }
+ } catch (Exception ex) {
+ buildAndThrowException(execution,
+ "Could not find existing Service Instance or related Instances to execute the request on.");
+ }
+ }
- private String retrieveAAIResourceId(List<Pair<WorkflowType, String>> aaiResourceIds, WorkflowType resource){
- String id = null;
- for(int i = 0; i<aaiResourceIds.size();i++){
- if(aaiResourceIds.get(i).getValue0() == resource){
- id = aaiResourceIds.get(i).getValue1();
- aaiResourceIds.remove(i);
- break;
- }
- }
- return id;
- }
- private void generateResourceIds(List<ExecuteBuildingBlock> flowsToExecute, List<Resource> resourceCounter, String serviceInstanceId) {
- Arrays.stream(WorkflowType.values()).filter(type -> !type.equals(WorkflowType.SERVICE)).forEach(type -> {
- List<Resource> resources = resourceCounter.stream().filter(x -> type.equals(x.getResourceType())).collect(Collectors.toList());
- for(int i = 0; i < resources.size(); i++){
- Resource resource = resourceCounter.stream().filter(x -> type.equals(x.getResourceType()))
- .collect(Collectors.toList()).get(i);
- updateWorkflowResourceIds(flowsToExecute, type, resource.getResourceId(), null, resource.getVirtualLinkKey(),serviceInstanceId);
- }
- });
- }
-
- protected void updateWorkflowResourceIds(List<ExecuteBuildingBlock> flowsToExecute, WorkflowType resource, String key, String id, String virtualLinkKey, String serviceInstanceId){
- String resourceId = id;
- if(resourceId==null){
- resourceId = UUID.randomUUID().toString();
- }
- for(ExecuteBuildingBlock ebb : flowsToExecute){
- if(key != null && key.equalsIgnoreCase(ebb.getBuildingBlock().getKey()) && ebb.getBuildingBlock().getBpmnFlowName().contains(resource.toString())){
- WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
- workflowResourceIds.setServiceInstanceId(serviceInstanceId);
- if(resource == WorkflowType.VNF){
- workflowResourceIds.setVnfId(resourceId);
- }else if(resource == WorkflowType.VFMODULE){
- workflowResourceIds.setVfModuleId(resourceId);
- }else if(resource == WorkflowType.VOLUMEGROUP){
- workflowResourceIds.setVolumeGroupId(resourceId);
- }else if(resource == WorkflowType.NETWORK){
- workflowResourceIds.setNetworkId(resourceId);
- }else if(resource == WorkflowType.NETWORKCOLLECTION){
- workflowResourceIds.setNetworkCollectionId(resourceId);
- }else if(resource == WorkflowType.CONFIGURATION){
- workflowResourceIds.setConfigurationId(resourceId);
- }
- ebb.setWorkflowResourceIds(workflowResourceIds);
- }
- if(virtualLinkKey != null && ebb.getBuildingBlock().getIsVirtualLink()
- && virtualLinkKey.equalsIgnoreCase(ebb.getBuildingBlock().getVirtualLinkKey())) {
- WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
- workflowResourceIds.setServiceInstanceId(serviceInstanceId);
- workflowResourceIds.setNetworkId(resourceId);
- ebb.setWorkflowResourceIds(workflowResourceIds);
- }
- }
- }
+ private void traverseAAIVnf(DelegateExecution execution, List<Resource> resourceCounter, String serviceId,
+ String vnfId, List<Pair<WorkflowType, String>> aaiResourceIds) {
+ try {
+ ServiceInstance serviceInstanceAAI = bbInputSetupUtils.getAAIServiceInstanceById(serviceId);
+ org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO =
+ bbInputSetup.getExistingServiceInstance(serviceInstanceAAI);
+ resourceCounter.add(new Resource(WorkflowType.SERVICE, serviceInstanceMSO.getServiceInstanceId(), false));
+ if (serviceInstanceMSO.getVnfs() != null) {
+ for (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf : serviceInstanceMSO.getVnfs()) {
+ if (vnf.getVnfId().equals(vnfId)) {
+ aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.VNF, vnf.getVnfId()));
+ resourceCounter.add(new Resource(WorkflowType.VNF, vnf.getVnfId(), false));
+ if (vnf.getVfModules() != null) {
+ for (VfModule vfModule : vnf.getVfModules()) {
+ aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.VFMODULE,
+ vfModule.getVfModuleId()));
+ resourceCounter
+ .add(new Resource(WorkflowType.VFMODULE, vfModule.getVfModuleId(), false));
+ findConfigurationsInsideVfModule(execution, vnf.getVnfId(), vfModule.getVfModuleId(),
+ resourceCounter, aaiResourceIds);
+ }
+ }
+ if (vnf.getVolumeGroups() != null) {
+ for (org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup volumeGroup : vnf
+ .getVolumeGroups()) {
+ aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.VOLUMEGROUP,
+ volumeGroup.getVolumeGroupId()));
+ resourceCounter.add(
+ new Resource(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId(), false));
+ }
+ }
+ break;
+ }
+ }
+ }
+ } catch (Exception ex) {
+ buildAndThrowException(execution,
+ "Could not find existing Vnf or related Instances to execute the request on.");
+ }
+ }
- protected CollectionResourceCustomization findCatalogNetworkCollection(DelegateExecution execution, org.onap.so.db.catalog.beans.Service service) {
- CollectionResourceCustomization networkCollection = null;
- int count = 0;
- for(CollectionResourceCustomization collectionCust : service.getCollectionResourceCustomizations()){
- if(catalogDbClient.getNetworkCollectionResourceCustomizationByID(collectionCust.getModelCustomizationUUID()) != null) {
- networkCollection = collectionCust;
- count++;
- }
- }
- if(count == 0){
- return null;
- }else if(count > 1) {
- buildAndThrowException(execution, "Found multiple Network Collections in the Service model, only one per Service is supported.");
- }
- return networkCollection;
- }
-
- protected void traverseCatalogDbService(DelegateExecution execution, ServiceInstancesRequest sIRequest,
- List<Resource> resourceCounter) {
- String modelUUID = sIRequest.getRequestDetails().getModelInfo().getModelVersionId();
- org.onap.so.db.catalog.beans.Service service = catalogDbClient.getServiceByID(modelUUID);
- if (service == null) {
- buildAndThrowException(execution, "Could not find the service model in catalog db.");
- } else {
- resourceCounter.add(new Resource(WorkflowType.SERVICE,service.getModelUUID(),false));
- if (service.getVnfCustomizations() == null || service.getVnfCustomizations().isEmpty()) {
- List<CollectionResourceCustomization> customizations = service.getCollectionResourceCustomizations();
- if(customizations.isEmpty()) {
- logger.debug("No Collections found. CollectionResourceCustomization list is empty.");
- }else{
- CollectionResourceCustomization collectionResourceCustomization = findCatalogNetworkCollection(execution, service);
- if(collectionResourceCustomization!=null){
- resourceCounter.add(new Resource(WorkflowType.NETWORKCOLLECTION,collectionResourceCustomization.getModelCustomizationUUID(),false));
- logger.debug("Found a network collection");
- if(collectionResourceCustomization.getCollectionResource()!=null){
- if(collectionResourceCustomization.getCollectionResource().getInstanceGroup() != null){
- String toscaNodeType = collectionResourceCustomization.getCollectionResource().getInstanceGroup().getToscaNodeType();
- if (toscaNodeType != null && toscaNodeType.contains("NetworkCollection")) {
- int minNetworks = 0;
- org.onap.so.db.catalog.beans.InstanceGroup instanceGroup = collectionResourceCustomization.getCollectionResource().getInstanceGroup();
- CollectionResourceInstanceGroupCustomization collectionInstCust = null;
- if(!instanceGroup.getCollectionInstanceGroupCustomizations().isEmpty()) {
- for(CollectionResourceInstanceGroupCustomization collectionInstanceGroupTemp : instanceGroup.getCollectionInstanceGroupCustomizations()) {
- if(collectionInstanceGroupTemp.getModelCustomizationUUID().equalsIgnoreCase(collectionResourceCustomization.getModelCustomizationUUID())) {
- collectionInstCust = collectionInstanceGroupTemp;
- break;
- }
- }
- if(collectionInstCust != null && collectionInstCust.getSubInterfaceNetworkQuantity() != null) {
- minNetworks = collectionInstCust.getSubInterfaceNetworkQuantity();
- }
- }
- logger.debug("minNetworks: {}" , minNetworks);
- CollectionNetworkResourceCustomization collectionNetworkResourceCust = null;
- for(CollectionNetworkResourceCustomization collectionNetworkTemp : instanceGroup.getCollectionNetworkResourceCustomizations()) {
- if(collectionNetworkTemp.getNetworkResourceCustomization().getModelCustomizationUUID().equalsIgnoreCase(collectionResourceCustomization.getModelCustomizationUUID())) {
- collectionNetworkResourceCust = collectionNetworkTemp;
- break;
- }
- }
- for (int i = 0; i < minNetworks; i++) {
- if(collectionNetworkResourceCust != null && collectionInstCust != null) {
- Resource resource = new Resource(WorkflowType.VIRTUAL_LINK,collectionNetworkResourceCust.getModelCustomizationUUID(),false);
- resource.setVirtualLinkKey(Integer.toString(i));
- resourceCounter.add(resource);
- }
- }
- } else {
- logger.debug("Instance Group tosca node type does not contain NetworkCollection: {}" , toscaNodeType);
- }
- }else{
- logger.debug("No Instance Group found for network collection.");
- }
- }else{
- logger.debug("No Network Collection found. collectionResource is null");
- }
- } else {
- logger.debug("No Network Collection Customization found");
- }
- }
- if (resourceCounter.stream().filter(x -> WorkflowType.NETWORKCOLLECTION == x.getResourceType()).collect(Collectors.toList()).isEmpty()) {
- if (service.getNetworkCustomizations() == null) {
- logger.debug("No networks were found on this service model");
- } else {
- for (int i = 0; i < service.getNetworkCustomizations().size(); i++) {
- resourceCounter.add(new Resource(WorkflowType.NETWORK,service.getNetworkCustomizations().get(i).getModelCustomizationUUID(),false));
- }
- }
- }
- } else {
- buildAndThrowException(execution,
- "Cannot orchestrate Service-Macro-Create without user params with a vnf. Please update ASDC model for new macro orchestration support or add service_recipe records to route to old macro flows");
- }
- }
- }
+ private void findConfigurationsInsideVfModule(DelegateExecution execution, String vnfId, String vfModuleId,
+ List<Resource> resourceCounter, List<Pair<WorkflowType, String>> aaiResourceIds) {
+ try {
+ org.onap.aai.domain.yang.VfModule aaiVfModule = bbInputSetupUtils.getAAIVfModule(vnfId, vfModuleId);
+ AAIResultWrapper vfModuleWrapper = new AAIResultWrapper(
+ new AAICommonObjectMapperProvider().getMapper().writeValueAsString(aaiVfModule));
+ Optional<Relationships> relationshipsOp;
+ relationshipsOp = vfModuleWrapper.getRelationships();
+ if (relationshipsOp.isPresent()) {
+ relationshipsOp = workflowActionUtils.extractRelationshipsVnfc(relationshipsOp.get());
+ if (relationshipsOp.isPresent()) {
+ Optional<Configuration> config =
+ workflowActionUtils.extractRelationshipsConfiguration(relationshipsOp.get());
+ if (config.isPresent()) {
+ aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.CONFIGURATION,
+ config.get().getConfigurationId()));
+ resourceCounter.add(
+ new Resource(WorkflowType.CONFIGURATION, config.get().getConfigurationId(), false));
+ }
+ }
+ }
+ } catch (Exception ex) {
+ buildAndThrowException(execution, "Failed to find Configuration object from the vfModule.");
+ }
+ }
- protected void traverseAAIService(DelegateExecution execution, List<Resource> resourceCounter, String resourceId, List<Pair<WorkflowType, String>> aaiResourceIds) {
- try {
- ServiceInstance serviceInstanceAAI = bbInputSetupUtils.getAAIServiceInstanceById(resourceId);
- org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO = bbInputSetup
- .getExistingServiceInstance(serviceInstanceAAI);
- resourceCounter.add(new Resource(WorkflowType.SERVICE,serviceInstanceMSO.getServiceInstanceId(),false));
- if (serviceInstanceMSO.getVnfs() != null) {
- for (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf : serviceInstanceMSO
- .getVnfs()) {
- aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.VNF, vnf.getVnfId()));
- resourceCounter.add(new Resource(WorkflowType.VNF,vnf.getVnfId(),false));
- if (vnf.getVfModules() != null) {
- for (VfModule vfModule : vnf.getVfModules()) {
- aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.VFMODULE, vfModule.getVfModuleId()));
- resourceCounter.add(new Resource(WorkflowType.VFMODULE,vfModule.getVfModuleId(),false));
- }
- }
- if (vnf.getVolumeGroups() != null) {
- for (org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup volumeGroup : vnf
- .getVolumeGroups()) {
- aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId()));
- resourceCounter.add(new Resource(WorkflowType.VOLUMEGROUP,volumeGroup.getVolumeGroupId(),false));
- }
- }
- }
- }
- if (serviceInstanceMSO.getNetworks() != null) {
- for (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network network : serviceInstanceMSO
- .getNetworks()) {
- aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.NETWORK, network.getNetworkId()));
- resourceCounter.add(new Resource(WorkflowType.NETWORK,network.getNetworkId(),false));
- }
- }
- if (serviceInstanceMSO.getCollection() != null) {
- logger.debug("found networkcollection");
- aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.NETWORKCOLLECTION, serviceInstanceMSO.getCollection().getId()));
- resourceCounter.add(new Resource(WorkflowType.NETWORKCOLLECTION,serviceInstanceMSO.getCollection().getId(),false));
- }
- if (serviceInstanceMSO.getConfigurations() !=null) {
- for(Configuration config : serviceInstanceMSO.getConfigurations()){
- Optional<org.onap.aai.domain.yang.Configuration> aaiConfig = aaiConfigurationResources.getConfiguration(config.getConfigurationId());
- if(aaiConfig.isPresent() && aaiConfig.get().getRelationshipList()!=null){
- for(Relationship relationship : aaiConfig.get().getRelationshipList().getRelationship()){
- if(relationship.getRelatedTo().contains("vnfc")){
- aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.CONFIGURATION, config.getConfigurationId()));
- resourceCounter.add(new Resource(WorkflowType.CONFIGURATION,config.getConfigurationId(),false));
- break;
- }
- }
- }
- }
- }
- } catch (Exception ex) {
- buildAndThrowException(execution,
- "Could not find existing Service Instance or related Instances to execute the request on.");
- }
- }
+ protected boolean traverseUserParamsService(DelegateExecution execution, List<Resource> resourceCounter,
+ ServiceInstancesRequest sIRequest, String requestAction) throws IOException {
+ boolean foundRelated = false;
+ boolean foundVfModuleOrVG = false;
+ String vnfCustomizationUUID = "";
+ String vfModuleCustomizationUUID = "";
+ if (sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) {
+ List<Map<String, Object>> userParams = sIRequest.getRequestDetails().getRequestParameters().getUserParams();
+ for (Map<String, Object> params : userParams) {
+ if (params.containsKey(USERPARAMSERVICE)) {
+ ObjectMapper obj = new ObjectMapper();
+ String input = obj.writeValueAsString(params.get(USERPARAMSERVICE));
+ Service validate = obj.readValue(input, Service.class);
+ resourceCounter.add(
+ new Resource(WorkflowType.SERVICE, validate.getModelInfo().getModelVersionId(), false));
+ if (validate.getResources().getVnfs() != null) {
+ for (Vnfs vnf : validate.getResources().getVnfs()) {
+ resourceCounter.add(new Resource(WorkflowType.VNF,
+ vnf.getModelInfo().getModelCustomizationId(), false));
+ foundRelated = true;
+ if (vnf.getModelInfo() != null && vnf.getModelInfo().getModelCustomizationUuid() != null) {
+ vnfCustomizationUUID = vnf.getModelInfo().getModelCustomizationUuid();
+ }
+ if (vnf.getVfModules() != null) {
+ for (VfModules vfModule : vnf.getVfModules()) {
+ VfModuleCustomization vfModuleCustomization =
+ catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID(
+ vfModule.getModelInfo().getModelCustomizationUuid());
+ if (vfModuleCustomization != null) {
- private void traverseAAIVnf(DelegateExecution execution, List<Resource> resourceCounter, String serviceId, String vnfId,
- List<Pair<WorkflowType, String>> aaiResourceIds) {
- try{
- ServiceInstance serviceInstanceAAI = bbInputSetupUtils.getAAIServiceInstanceById(serviceId);
- org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO = bbInputSetup
- .getExistingServiceInstance(serviceInstanceAAI);
- resourceCounter.add(new Resource(WorkflowType.SERVICE,serviceInstanceMSO.getServiceInstanceId(),false));
- if (serviceInstanceMSO.getVnfs() != null) {
- for (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf : serviceInstanceMSO
- .getVnfs()) {
- if(vnf.getVnfId().equals(vnfId)){
- aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.VNF, vnf.getVnfId()));
- resourceCounter.add(new Resource(WorkflowType.VNF,vnf.getVnfId(),false));
- if (vnf.getVfModules() != null) {
- for (VfModule vfModule : vnf.getVfModules()) {
- aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.VFMODULE, vfModule.getVfModuleId()));
- resourceCounter.add(new Resource(WorkflowType.VFMODULE,vfModule.getVfModuleId(),false));
- findConfigurationsInsideVfModule(execution, vnf.getVnfId(), vfModule.getVfModuleId(), resourceCounter, aaiResourceIds);
- }
- }
- if (vnf.getVolumeGroups() != null) {
- for (org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup volumeGroup : vnf
- .getVolumeGroups()) {
- aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId()));
- resourceCounter.add(new Resource(WorkflowType.VOLUMEGROUP,volumeGroup.getVolumeGroupId(),false));
- }
- }
- break;
- }
- }
- }
- } catch (Exception ex) {
- buildAndThrowException(execution,
- "Could not find existing Vnf or related Instances to execute the request on.");
- }
- }
+ if (vfModuleCustomization.getVfModule() != null
+ && vfModuleCustomization.getVfModule().getVolumeHeatTemplate() != null
+ && vfModuleCustomization.getVolumeHeatEnv() != null) {
+ resourceCounter.add(new Resource(WorkflowType.VOLUMEGROUP,
+ vfModuleCustomization.getModelCustomizationUUID(), false));
+ foundRelated = true;
+ foundVfModuleOrVG = true;
+ }
- private void findConfigurationsInsideVfModule(DelegateExecution execution, String vnfId, String vfModuleId, List<Resource> resourceCounter,
- List<Pair<WorkflowType, String>> aaiResourceIds) {
- try{
- org.onap.aai.domain.yang.VfModule aaiVfModule = bbInputSetupUtils.getAAIVfModule(vnfId, vfModuleId);
- AAIResultWrapper vfModuleWrapper = new AAIResultWrapper(
- new AAICommonObjectMapperProvider().getMapper().writeValueAsString(aaiVfModule));
- Optional<Relationships> relationshipsOp;
- relationshipsOp = vfModuleWrapper.getRelationships();
- if(relationshipsOp.isPresent()) {
- relationshipsOp = workflowActionUtils.extractRelationshipsVnfc(relationshipsOp.get());
- if(relationshipsOp.isPresent()){
- Optional<Configuration> config = workflowActionUtils.extractRelationshipsConfiguration(relationshipsOp.get());
- if(config.isPresent()){
- aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.CONFIGURATION, config.get().getConfigurationId()));
- resourceCounter.add(new Resource(WorkflowType.CONFIGURATION, config.get().getConfigurationId(), false));
- }
- }
- }
- }catch (Exception ex){
- buildAndThrowException(execution,
- "Failed to find Configuration object from the vfModule.");
- }
- }
-
- protected boolean traverseUserParamsService(DelegateExecution execution, List<Resource> resourceCounter,
- ServiceInstancesRequest sIRequest, String requestAction)
- throws IOException {
- boolean foundRelated = false;
- boolean foundVfModuleOrVG = false;
- String vnfCustomizationUUID = "";
- String vfModuleCustomizationUUID = "";
- if (sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) {
- List<Map<String, Object>> userParams = sIRequest.getRequestDetails().getRequestParameters().getUserParams();
- for (Map<String, Object> params : userParams) {
- if (params.containsKey(USERPARAMSERVICE)) {
- ObjectMapper obj = new ObjectMapper();
- String input = obj.writeValueAsString(params.get(USERPARAMSERVICE));
- Service validate = obj.readValue(input, Service.class);
- resourceCounter.add(new Resource(WorkflowType.SERVICE,validate.getModelInfo().getModelVersionId(),false));
- if (validate.getResources().getVnfs() != null) {
- for (Vnfs vnf : validate.getResources().getVnfs()) {
- resourceCounter.add(new Resource(WorkflowType.VNF,vnf.getModelInfo().getModelCustomizationId(),false));
- foundRelated = true;
- if(vnf.getModelInfo()!=null && vnf.getModelInfo().getModelCustomizationUuid()!=null){
- vnfCustomizationUUID = vnf.getModelInfo().getModelCustomizationUuid();
- }
- if (vnf.getVfModules() != null) {
- for (VfModules vfModule : vnf.getVfModules()) {
- VfModuleCustomization vfModuleCustomization = catalogDbClient
- .getVfModuleCustomizationByModelCuztomizationUUID(
- vfModule.getModelInfo().getModelCustomizationUuid());
- if (vfModuleCustomization != null) {
+ if (vfModuleCustomization.getVfModule() != null
+ && vfModuleCustomization.getVfModule().getModuleHeatTemplate() != null
+ && vfModuleCustomization.getHeatEnvironment() != null) {
+ foundRelated = true;
+ foundVfModuleOrVG = true;
+ Resource resource = new Resource(WorkflowType.VFMODULE,
+ vfModuleCustomization.getModelCustomizationUUID(), false);
+ if (vfModuleCustomization.getVfModule().getIsBase() != null
+ && vfModuleCustomization.getVfModule().getIsBase()) {
+ resource.setBaseVfModule(true);
+ } else {
+ resource.setBaseVfModule(false);
+ }
+ resourceCounter.add(resource);
+ if (vfModule.getModelInfo() != null
+ && vfModule.getModelInfo().getModelCustomizationUuid() != null) {
+ vfModuleCustomizationUUID =
+ vfModule.getModelInfo().getModelCustomizationUuid();
+ }
+ if (!vnfCustomizationUUID.equals("")
+ && !vfModuleCustomizationUUID.equals("")) {
+ List<CvnfcConfigurationCustomization> configs =
+ traverseCatalogDbForConfiguration(
+ validate.getModelInfo().getModelVersionId(),
+ vnfCustomizationUUID, vfModuleCustomizationUUID);
+ for (CvnfcConfigurationCustomization config : configs) {
+ Resource configResource = new Resource(WorkflowType.CONFIGURATION,
+ config.getConfigurationResource().getModelUUID(), false);
+ resource.setVnfCustomizationId(
+ vnf.getModelInfo().getModelCustomizationId());
+ resource.setVfModuleCustomizationId(
+ vfModule.getModelInfo().getModelCustomizationId());
+ resourceCounter.add(configResource);
+ }
+ }
+ }
+ if (!foundVfModuleOrVG) {
+ buildAndThrowException(execution,
+ "Could not determine if vfModule was a vfModule or volume group. Heat template and Heat env are null");
+ }
+ }
+ }
+ }
+ }
+ }
+ if (validate.getResources().getNetworks() != null) {
+ for (Networks network : validate.getResources().getNetworks()) {
+ resourceCounter.add(new Resource(WorkflowType.NETWORK,
+ network.getModelInfo().getModelCustomizationId(), false));
+ foundRelated = true;
+ }
+ if (requestAction.equals(CREATEINSTANCE)) {
+ String networkColCustId = queryCatalogDBforNetworkCollection(execution, sIRequest);
+ if (networkColCustId != null) {
+ resourceCounter
+ .add(new Resource(WorkflowType.NETWORKCOLLECTION, networkColCustId, false));
+ foundRelated = true;
+ }
+ }
+ }
+ break;
+ }
+ }
+ }
+ return foundRelated;
+ }
- if(vfModuleCustomization.getVfModule() != null && vfModuleCustomization.getVfModule().getVolumeHeatTemplate() != null && vfModuleCustomization.getVolumeHeatEnv() != null) {
- resourceCounter.add(new Resource(WorkflowType.VOLUMEGROUP,vfModuleCustomization.getModelCustomizationUUID(),false));
- foundRelated = true;
- foundVfModuleOrVG = true;
- }
+ protected List<CvnfcConfigurationCustomization> traverseCatalogDbForConfiguration(String serviceModelUUID,
+ String vnfCustomizationUUID, String vfModuleCustomizationUUID) {
+ List<CvnfcConfigurationCustomization> configurations = new ArrayList<>();
+ try {
+ List<CvnfcCustomization> cvnfcCustomizations = catalogDbClient.getCvnfcCustomization(serviceModelUUID,
+ vnfCustomizationUUID, vfModuleCustomizationUUID);
+ for (CvnfcCustomization cvnfc : cvnfcCustomizations) {
+ for (CvnfcConfigurationCustomization customization : cvnfc.getCvnfcConfigurationCustomization()) {
+ if (customization.getConfigurationResource().getToscaNodeType().contains(FABRIC_CONFIGURATION)) {
+ configurations.add(customization);
+ }
+ }
+ }
+ logger.debug("found {} fabric configuration(s)", configurations.size());
+ return configurations;
+ } catch (Exception ex) {
+ logger.error("Error in finding configurations", ex);
+ return configurations;
+ }
+ }
- if(vfModuleCustomization.getVfModule() != null && vfModuleCustomization.getVfModule().getModuleHeatTemplate() != null && vfModuleCustomization.getHeatEnvironment() != null){
- foundRelated = true;
- foundVfModuleOrVG = true;
- Resource resource = new Resource(WorkflowType.VFMODULE,vfModuleCustomization.getModelCustomizationUUID(),false);
- if(vfModuleCustomization.getVfModule().getIsBase()!=null && vfModuleCustomization.getVfModule().getIsBase()){
- resource.setBaseVfModule(true);
- }else{
- resource.setBaseVfModule(false);
- }
- resourceCounter.add(resource);
- if(vfModule.getModelInfo()!=null && vfModule.getModelInfo().getModelCustomizationUuid()!=null){
- vfModuleCustomizationUUID = vfModule.getModelInfo().getModelCustomizationUuid();
- }
- if(!vnfCustomizationUUID.equals("")&&!vfModuleCustomizationUUID.equals("")){
- List<CvnfcConfigurationCustomization> configs = traverseCatalogDbForConfiguration(validate.getModelInfo().getModelVersionId(),vnfCustomizationUUID,vfModuleCustomizationUUID);
- for(CvnfcConfigurationCustomization config : configs){
- Resource configResource = new Resource(WorkflowType.CONFIGURATION,config.getConfigurationResource().getModelUUID(),false);
- resource.setVnfCustomizationId(vnf.getModelInfo().getModelCustomizationId());
- resource.setVfModuleCustomizationId(vfModule.getModelInfo().getModelCustomizationId());
- resourceCounter.add(configResource);
- }
- }
- }
- if(!foundVfModuleOrVG){
- buildAndThrowException(execution, "Could not determine if vfModule was a vfModule or volume group. Heat template and Heat env are null");
- }
- }
- }
- }
- }
- }
- if (validate.getResources().getNetworks() != null) {
- for (Networks network : validate.getResources().getNetworks()) {
- resourceCounter.add(new Resource(WorkflowType.NETWORK,network.getModelInfo().getModelCustomizationId(),false));
- foundRelated = true;
- }
- if (requestAction.equals(CREATEINSTANCE)) {
- String networkColCustId = queryCatalogDBforNetworkCollection(execution, sIRequest);
- if (networkColCustId != null) {
- resourceCounter.add(new Resource(WorkflowType.NETWORKCOLLECTION,networkColCustId,false));
- foundRelated = true;
- }
- }
- }
- break;
- }
- }
- }
- return foundRelated;
- }
+ protected String queryCatalogDBforNetworkCollection(DelegateExecution execution,
+ ServiceInstancesRequest sIRequest) {
+ org.onap.so.db.catalog.beans.Service service =
+ catalogDbClient.getServiceByID(sIRequest.getRequestDetails().getModelInfo().getModelVersionId());
+ if (service != null) {
+ CollectionResourceCustomization networkCollection = this.findCatalogNetworkCollection(execution, service);
+ if (networkCollection != null) {
+ return networkCollection.getModelCustomizationUUID();
+ }
+ }
+ return null;
+ }
- protected List<CvnfcConfigurationCustomization> traverseCatalogDbForConfiguration(String serviceModelUUID, String vnfCustomizationUUID, String vfModuleCustomizationUUID) {
- List<CvnfcConfigurationCustomization> configurations = new ArrayList<>();
- try{
- List<CvnfcCustomization> cvnfcCustomizations = catalogDbClient.getCvnfcCustomization(serviceModelUUID,vnfCustomizationUUID, vfModuleCustomizationUUID);
- for(CvnfcCustomization cvnfc : cvnfcCustomizations){
- for(CvnfcConfigurationCustomization customization : cvnfc.getCvnfcConfigurationCustomization()){
- if(customization.getConfigurationResource().getToscaNodeType().contains(FABRIC_CONFIGURATION)){
- configurations.add(customization);
- }
- }
- }
- logger.debug("found {} fabric configuration(s)" , configurations.size() );
- return configurations;
- } catch (Exception ex){
- logger.error("Error in finding configurations", ex);
- return configurations;
- }
- }
+ protected WorkflowResourceIds populateResourceIdsFromApiHandler(DelegateExecution execution) {
+ WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
+ workflowResourceIds.setServiceInstanceId((String) execution.getVariable("serviceInstanceId"));
+ workflowResourceIds.setNetworkId((String) execution.getVariable("networkId"));
+ workflowResourceIds.setVfModuleId((String) execution.getVariable("vfModuleId"));
+ workflowResourceIds.setVnfId((String) execution.getVariable("vnfId"));
+ workflowResourceIds.setVolumeGroupId((String) execution.getVariable("volumeGroupId"));
+ workflowResourceIds.setInstanceGroupId((String) execution.getVariable("instanceGroupId"));
+ return workflowResourceIds;
+ }
- protected String queryCatalogDBforNetworkCollection(DelegateExecution execution, ServiceInstancesRequest sIRequest) {
- org.onap.so.db.catalog.beans.Service service = catalogDbClient
- .getServiceByID(sIRequest.getRequestDetails().getModelInfo().getModelVersionId());
- if (service != null) {
- CollectionResourceCustomization networkCollection = this.findCatalogNetworkCollection(execution, service);
- if(networkCollection != null) {
- return networkCollection.getModelCustomizationUUID();
- }
- }
- return null;
- }
+ protected Resource extractResourceIdAndTypeFromUri(String uri) {
+ Pattern patt = Pattern.compile(
+ "[vV]\\d+.*?(?:(?:/(?<type>" + supportedTypes + ")(?:/(?<id>[^/]+))?)(?:/(?<action>[^/]+))?)?$");
+ Matcher m = patt.matcher(uri);
+ Boolean generated = false;
- protected WorkflowResourceIds populateResourceIdsFromApiHandler(DelegateExecution execution) {
- WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
- workflowResourceIds.setServiceInstanceId((String) execution.getVariable("serviceInstanceId"));
- workflowResourceIds.setNetworkId((String) execution.getVariable("networkId"));
- workflowResourceIds.setVfModuleId((String) execution.getVariable("vfModuleId"));
- workflowResourceIds.setVnfId((String) execution.getVariable("vnfId"));
- workflowResourceIds.setVolumeGroupId((String) execution.getVariable("volumeGroupId"));
- workflowResourceIds.setInstanceGroupId((String) execution.getVariable("instanceGroupId"));
- return workflowResourceIds;
- }
+ if (m.find()) {
+ logger.debug("found match on {} : {} ", uri, m);
+ String type = m.group("type");
+ String id = m.group("id");
+ String action = m.group("action");
+ if (type == null) {
+ throw new IllegalArgumentException("Uri could not be parsed. No type found. " + uri);
+ }
+ if (action == null) {
+ if (type.equals(SERVICE_INSTANCES) && (id == null || id.equals("assign"))) {
+ id = UUID.randomUUID().toString();
+ generated = true;
+ } else if (type.equals(VF_MODULES) && id.equals("scaleOut")) {
+ id = UUID.randomUUID().toString();
+ generated = true;
+ }
+ } else {
+ if (action.matches(supportedTypes)) {
+ id = UUID.randomUUID().toString();
+ generated = true;
+ type = action;
+ }
+ }
+ return new Resource(WorkflowType.fromString(convertTypeFromPlural(type)), id, generated);
+ } else {
+ throw new IllegalArgumentException("Uri could not be parsed: " + uri);
+ }
+ }
- protected Resource extractResourceIdAndTypeFromUri(String uri) {
- Pattern patt = Pattern.compile(
- "[vV]\\d+.*?(?:(?:/(?<type>" + supportedTypes + ")(?:/(?<id>[^/]+))?)(?:/(?<action>[^/]+))?)?$");
- Matcher m = patt.matcher(uri);
- Boolean generated = false;
+ protected String validateResourceIdInAAI(String generatedResourceId, WorkflowType type, String instanceName,
+ RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds) throws Exception {
+ try {
+ if ("SERVICE".equalsIgnoreCase(type.toString())) {
+ String globalCustomerId = reqDetails.getSubscriberInfo().getGlobalSubscriberId();
+ String serviceType = reqDetails.getRequestParameters().getSubscriptionServiceType();
+ if (instanceName != null) {
+ Optional<ServiceInstance> serviceInstanceAAI =
+ bbInputSetupUtils.getAAIServiceInstanceByName(globalCustomerId, serviceType, instanceName);
+ if (serviceInstanceAAI.isPresent()) {
+ return serviceInstanceAAI.get().getServiceInstanceId();
+ }
+ }
+ } else if ("NETWORK".equalsIgnoreCase(type.toString())) {
+ Optional<L3Network> network = bbInputSetupUtils.getRelatedNetworkByNameFromServiceInstance(
+ workflowResourceIds.getServiceInstanceId(), instanceName);
+ if (network.isPresent()) {
+ return network.get().getNetworkId();
+ }
+ } else if ("VNF".equalsIgnoreCase(type.toString())) {
+ Optional<GenericVnf> vnf = bbInputSetupUtils.getRelatedVnfByNameFromServiceInstance(
+ workflowResourceIds.getServiceInstanceId(), instanceName);
+ if (vnf.isPresent()) {
+ return vnf.get().getVnfId();
+ }
+ } else if ("VFMODULE".equalsIgnoreCase(type.toString())) {
+ GenericVnf vnf = bbInputSetupUtils.getAAIGenericVnf(workflowResourceIds.getVnfId());
+ if (vnf != null && vnf.getVfModules() != null) {
+ for (org.onap.aai.domain.yang.VfModule vfModule : vnf.getVfModules().getVfModule()) {
+ if (vfModule.getVfModuleName().equalsIgnoreCase(instanceName)) {
+ return vfModule.getVfModuleId();
+ }
+ }
+ }
+ } else if ("VOLUMEGROUP".equalsIgnoreCase(type.toString())) {
+ Optional<VolumeGroup> volumeGroup = bbInputSetupUtils
+ .getRelatedVolumeGroupByNameFromVnf(workflowResourceIds.getVnfId(), instanceName);
+ if (volumeGroup.isPresent()) {
+ return volumeGroup.get().getVolumeGroupId();
+ }
+ GenericVnf vnf = bbInputSetupUtils.getAAIGenericVnf(workflowResourceIds.getVnfId());
+ if (vnf != null && vnf.getVfModules() != null) {
+ for (org.onap.aai.domain.yang.VfModule vfModule : vnf.getVfModules().getVfModule()) {
+ Optional<VolumeGroup> volumeGroupFromVfModule =
+ bbInputSetupUtils.getRelatedVolumeGroupByNameFromVfModule(vnf.getVnfId(),
+ vfModule.getVfModuleId(), instanceName);
+ if (volumeGroupFromVfModule.isPresent()) {
+ return volumeGroupFromVfModule.get().getVolumeGroupId();
+ }
+ }
+ }
+ }
+ return generatedResourceId;
+ } catch (Exception ex) {
+ logger.error(WORKFLOW_ACTION_WAS_UNABLE_TO_VERIFY_IF_THE_INSTANCE_NAME_ALREADY_EXIST_IN_AAI, ex);
+ throw new IllegalStateException(
+ WORKFLOW_ACTION_WAS_UNABLE_TO_VERIFY_IF_THE_INSTANCE_NAME_ALREADY_EXIST_IN_AAI);
+ }
+ }
- if (m.find()) {
- logger.debug("found match on {} : {} " , uri , m);
- String type = m.group("type");
- String id = m.group("id");
- String action = m.group("action");
- if (type == null) {
- throw new IllegalArgumentException("Uri could not be parsed. No type found. " + uri);
- }
- if (action == null) {
- if (type.equals(SERVICE_INSTANCES) && (id == null || id.equals("assign"))) {
- id = UUID.randomUUID().toString();
- generated = true;
- }else if (type.equals(VF_MODULES) && id.equals("scaleOut")) {
- id = UUID.randomUUID().toString();
- generated = true;
- }
- } else {
- if (action.matches(supportedTypes)) {
- id = UUID.randomUUID().toString();
- generated = true;
- type = action;
- }
- }
- return new Resource(WorkflowType.fromString(convertTypeFromPlural(type)), id, generated);
- } else {
- throw new IllegalArgumentException("Uri could not be parsed: " + uri);
- }
- }
+ protected String convertTypeFromPlural(String type) {
+ if (!type.matches(supportedTypes)) {
+ return type;
+ } else {
+ if (type.equals(SERVICE_INSTANCES)) {
+ return SERVICE;
+ } else {
+ return type.substring(0, 1).toUpperCase() + type.substring(1, type.length() - 1);
+ }
+ }
+ }
- protected String validateResourceIdInAAI(String generatedResourceId, WorkflowType type, String instanceName,
- RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds) throws Exception {
- try {
- if ("SERVICE".equalsIgnoreCase(type.toString())) {
- String globalCustomerId = reqDetails.getSubscriberInfo().getGlobalSubscriberId();
- String serviceType = reqDetails.getRequestParameters().getSubscriptionServiceType();
- if (instanceName != null) {
- Optional<ServiceInstance> serviceInstanceAAI = bbInputSetupUtils
- .getAAIServiceInstanceByName(globalCustomerId, serviceType, instanceName);
- if (serviceInstanceAAI.isPresent()) {
- return serviceInstanceAAI.get().getServiceInstanceId();
- }
- }
- } else if ("NETWORK".equalsIgnoreCase(type.toString())) {
- Optional<L3Network> network = bbInputSetupUtils.getRelatedNetworkByNameFromServiceInstance(
- workflowResourceIds.getServiceInstanceId(), instanceName);
- if (network.isPresent()) {
- return network.get().getNetworkId();
- }
- } else if ("VNF".equalsIgnoreCase(type.toString())) {
- Optional<GenericVnf> vnf = bbInputSetupUtils.getRelatedVnfByNameFromServiceInstance(
- workflowResourceIds.getServiceInstanceId(), instanceName);
- if (vnf.isPresent()) {
- return vnf.get().getVnfId();
- }
- } else if ("VFMODULE".equalsIgnoreCase(type.toString())) {
- GenericVnf vnf = bbInputSetupUtils.getAAIGenericVnf(workflowResourceIds.getVnfId());
- if (vnf != null && vnf.getVfModules() != null) {
- for (org.onap.aai.domain.yang.VfModule vfModule : vnf.getVfModules().getVfModule()) {
- if (vfModule.getVfModuleName().equalsIgnoreCase(instanceName)) {
- return vfModule.getVfModuleId();
- }
- }
- }
- } else if ("VOLUMEGROUP".equalsIgnoreCase(type.toString())) {
- Optional<VolumeGroup> volumeGroup = bbInputSetupUtils
- .getRelatedVolumeGroupByNameFromVnf(workflowResourceIds.getVnfId(), instanceName);
- if (volumeGroup.isPresent()) {
- return volumeGroup.get().getVolumeGroupId();
- }
- GenericVnf vnf = bbInputSetupUtils.getAAIGenericVnf(workflowResourceIds.getVnfId());
- if (vnf != null && vnf.getVfModules() != null) {
- for (org.onap.aai.domain.yang.VfModule vfModule : vnf.getVfModules().getVfModule()) {
- Optional<VolumeGroup> volumeGroupFromVfModule = bbInputSetupUtils
- .getRelatedVolumeGroupByNameFromVfModule(vnf.getVnfId(), vfModule.getVfModuleId(), instanceName);
- if (volumeGroupFromVfModule.isPresent()) {
- return volumeGroupFromVfModule.get().getVolumeGroupId();
- }
- }
- }
- }
- return generatedResourceId;
- } catch (Exception ex) {
- logger.error(WORKFLOW_ACTION_WAS_UNABLE_TO_VERIFY_IF_THE_INSTANCE_NAME_ALREADY_EXIST_IN_AAI, ex);
- throw new IllegalStateException(
- WORKFLOW_ACTION_WAS_UNABLE_TO_VERIFY_IF_THE_INSTANCE_NAME_ALREADY_EXIST_IN_AAI);
- }
- }
+ protected List<ExecuteBuildingBlock> sortExecutionPathByObjectForVlanTagging(List<ExecuteBuildingBlock> orchFlows,
+ String requestAction) {
+ List<ExecuteBuildingBlock> sortedOrchFlows = new ArrayList<>();
+ if (requestAction.equals(CREATEINSTANCE)) {
+ for (ExecuteBuildingBlock ebb : orchFlows) {
+ if (ebb.getBuildingBlock().getBpmnFlowName().equals("AssignNetworkBB")) {
+ String key = ebb.getBuildingBlock().getKey();
+ boolean isVirtualLink = Boolean.TRUE.equals(ebb.getBuildingBlock().getIsVirtualLink());
+ String virtualLinkKey = ebb.getBuildingBlock().getVirtualLinkKey();
+ sortedOrchFlows.add(ebb);
+ for (ExecuteBuildingBlock ebb2 : orchFlows) {
+ if (!isVirtualLink && ebb2.getBuildingBlock().getBpmnFlowName().equals("CreateNetworkBB")
+ && ebb2.getBuildingBlock().getKey().equalsIgnoreCase(key)) {
+ sortedOrchFlows.add(ebb2);
+ break;
+ }
+ if (isVirtualLink && ebb2.getBuildingBlock().getBpmnFlowName().equals("CreateNetworkBB")
+ && ebb2.getBuildingBlock().getVirtualLinkKey().equalsIgnoreCase(virtualLinkKey)) {
+ sortedOrchFlows.add(ebb2);
+ break;
+ }
+ }
+ for (ExecuteBuildingBlock ebb2 : orchFlows) {
+ if (!isVirtualLink && ebb2.getBuildingBlock().getBpmnFlowName().equals("ActivateNetworkBB")
+ && ebb2.getBuildingBlock().getKey().equalsIgnoreCase(key)) {
+ sortedOrchFlows.add(ebb2);
+ break;
+ }
+ if (isVirtualLink && ebb2.getBuildingBlock().getBpmnFlowName().equals("ActivateNetworkBB")
+ && ebb2.getBuildingBlock().getVirtualLinkKey().equalsIgnoreCase(virtualLinkKey)) {
+ sortedOrchFlows.add(ebb2);
+ break;
+ }
+ }
+ } else if (ebb.getBuildingBlock().getBpmnFlowName().equals("CreateNetworkBB")
+ || ebb.getBuildingBlock().getBpmnFlowName().equals("ActivateNetworkBB")) {
+ continue;
+ } else if (!ebb.getBuildingBlock().getBpmnFlowName().equals("")) {
+ sortedOrchFlows.add(ebb);
+ }
+ }
+ } else if (requestAction.equals("deleteInstance")) {
+ for (ExecuteBuildingBlock ebb : orchFlows) {
+ if (ebb.getBuildingBlock().getBpmnFlowName().equals("DeactivateNetworkBB")) {
+ sortedOrchFlows.add(ebb);
+ String key = ebb.getBuildingBlock().getKey();
+ for (ExecuteBuildingBlock ebb2 : orchFlows) {
+ if (ebb2.getBuildingBlock().getBpmnFlowName().equals("DeleteNetworkBB")
+ && ebb2.getBuildingBlock().getKey().equalsIgnoreCase(key)) {
+ sortedOrchFlows.add(ebb2);
+ break;
+ }
+ }
+ for (ExecuteBuildingBlock ebb2 : orchFlows) {
+ if (ebb2.getBuildingBlock().getBpmnFlowName().equals("UnassignNetworkBB")
+ && ebb2.getBuildingBlock().getKey().equalsIgnoreCase(key)) {
+ sortedOrchFlows.add(ebb2);
+ break;
+ }
+ }
+ } else if (ebb.getBuildingBlock().getBpmnFlowName().equals("DeleteNetworkBB")
+ || ebb.getBuildingBlock().getBpmnFlowName().equals("UnassignNetworkBB")) {
+ continue;
+ } else if (!ebb.getBuildingBlock().getBpmnFlowName().equals("")) {
+ sortedOrchFlows.add(ebb);
+ }
+ }
+ }
+ return sortedOrchFlows;
+ }
- protected String convertTypeFromPlural(String type) {
- if (!type.matches(supportedTypes)) {
- return type;
- } else {
- if (type.equals(SERVICE_INSTANCES)) {
- return SERVICE;
- } else {
- return type.substring(0, 1).toUpperCase() + type.substring(1, type.length() - 1);
- }
- }
- }
+ protected List<ExecuteBuildingBlock> buildExecuteBuildingBlockList(List<OrchestrationFlow> orchFlows,
+ List<Resource> resourceCounter, String requestId, String apiVersion, String resourceId,
+ WorkflowType resourceType, String requestAction, boolean aLaCarte, String vnfType,
+ WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails) {
+ List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
+ for (OrchestrationFlow orchFlow : orchFlows) {
+ if (orchFlow.getFlowName().contains(SERVICE)) {
+ for (int i = 0; i < resourceCounter.stream().filter(x -> WorkflowType.SERVICE == x.getResourceType())
+ .collect(Collectors.toList()).size(); i++) {
+ workflowResourceIds.setServiceInstanceId(resourceId);
+ flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId,
+ resourceCounter.stream().filter(x -> WorkflowType.SERVICE == x.getResourceType())
+ .collect(Collectors.toList()).get(i),
+ apiVersion, resourceId, requestAction, aLaCarte, vnfType, workflowResourceIds,
+ requestDetails, false, null, false));
+ }
+ } else if (orchFlow.getFlowName().contains(VNF)) {
+ for (int i = 0; i < resourceCounter.stream().filter(x -> WorkflowType.VNF == x.getResourceType())
+ .collect(Collectors.toList()).size(); i++) {
+ flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId,
+ resourceCounter.stream().filter(x -> WorkflowType.VNF == x.getResourceType())
+ .collect(Collectors.toList()).get(i),
+ apiVersion, resourceId, requestAction, aLaCarte, vnfType, workflowResourceIds,
+ requestDetails, false, null, false));
+ }
+ } else if (orchFlow.getFlowName().contains(NETWORK)
+ && !orchFlow.getFlowName().contains(NETWORKCOLLECTION)) {
+ for (int i = 0; i < resourceCounter.stream().filter(x -> WorkflowType.NETWORK == x.getResourceType())
+ .collect(Collectors.toList()).size(); i++) {
+ flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId,
+ resourceCounter.stream().filter(x -> WorkflowType.NETWORK == x.getResourceType())
+ .collect(Collectors.toList()).get(i),
+ apiVersion, resourceId, requestAction, aLaCarte, vnfType, workflowResourceIds,
+ requestDetails, false, null, false));
+ }
+ for (int i = 0; i < resourceCounter.stream()
+ .filter(x -> WorkflowType.VIRTUAL_LINK == x.getResourceType()).collect(Collectors.toList())
+ .size(); i++) {
+ Resource resource =
+ resourceCounter.stream().filter(x -> WorkflowType.VIRTUAL_LINK == x.getResourceType())
+ .collect(Collectors.toList()).get(i);
+ flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, resource, apiVersion, resourceId,
+ requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, true,
+ resource.getVirtualLinkKey(), false));
+ }
+ } else if (orchFlow.getFlowName().contains(VFMODULE)) {
+ List<Resource> vfModuleResourcesSorted = null;
+ if (requestAction.equals("createInstance") || requestAction.equals("assignInstance")
+ || requestAction.equals("activateInstance")) {
+ vfModuleResourcesSorted = sortVfModulesByBaseFirst(resourceCounter.stream()
+ .filter(x -> WorkflowType.VFMODULE == x.getResourceType()).collect(Collectors.toList()));
+ } else {
+ vfModuleResourcesSorted = sortVfModulesByBaseLast(resourceCounter.stream()
+ .filter(x -> WorkflowType.VFMODULE == x.getResourceType()).collect(Collectors.toList()));
+ }
+ for (int i = 0; i < vfModuleResourcesSorted.size(); i++) {
+ flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, vfModuleResourcesSorted.get(i),
+ apiVersion, resourceId, requestAction, aLaCarte, vnfType, workflowResourceIds,
+ requestDetails, false, null, false));
+ }
+ } else if (orchFlow.getFlowName().contains(VOLUMEGROUP)) {
+ for (int i = 0; i < resourceCounter.stream()
+ .filter(x -> WorkflowType.VOLUMEGROUP == x.getResourceType()).collect(Collectors.toList())
+ .size(); i++) {
+ flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId,
+ resourceCounter.stream().filter(x -> WorkflowType.VOLUMEGROUP == x.getResourceType())
+ .collect(Collectors.toList()).get(i),
+ apiVersion, resourceId, requestAction, aLaCarte, vnfType, workflowResourceIds,
+ requestDetails, false, null, false));
+ }
+ } else if (orchFlow.getFlowName().contains(NETWORKCOLLECTION)) {
+ for (int i = 0; i < resourceCounter.stream()
+ .filter(x -> WorkflowType.NETWORKCOLLECTION == x.getResourceType()).collect(Collectors.toList())
+ .size(); i++) {
+ flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId,
+ resourceCounter.stream().filter(x -> WorkflowType.NETWORKCOLLECTION == x.getResourceType())
+ .collect(Collectors.toList()).get(i),
+ apiVersion, resourceId, requestAction, aLaCarte, vnfType, workflowResourceIds,
+ requestDetails, false, null, false));
+ }
+ } else if (orchFlow.getFlowName().contains(CONFIGURATION)) {
+ for (int i = 0; i < resourceCounter.stream()
+ .filter(x -> WorkflowType.CONFIGURATION == x.getResourceType()).collect(Collectors.toList())
+ .size(); i++) {
+ flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId,
+ resourceCounter.stream().filter(x -> WorkflowType.CONFIGURATION == x.getResourceType())
+ .collect(Collectors.toList()).get(i),
+ apiVersion, resourceId, requestAction, aLaCarte, vnfType, workflowResourceIds,
+ requestDetails, false, null, true));
+ }
+ } else {
+ flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, null, apiVersion, resourceId,
+ requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null, false));
+ }
+ }
+ return flowsToExecute;
+ }
- protected List<ExecuteBuildingBlock> sortExecutionPathByObjectForVlanTagging(List<ExecuteBuildingBlock> orchFlows,
- String requestAction) {
- List<ExecuteBuildingBlock> sortedOrchFlows = new ArrayList<>();
- if (requestAction.equals(CREATEINSTANCE)) {
- for (ExecuteBuildingBlock ebb : orchFlows) {
- if (ebb.getBuildingBlock().getBpmnFlowName().equals("AssignNetworkBB")) {
- String key = ebb.getBuildingBlock().getKey();
- boolean isVirtualLink = Boolean.TRUE.equals(ebb.getBuildingBlock().getIsVirtualLink());
- String virtualLinkKey = ebb.getBuildingBlock().getVirtualLinkKey();
- sortedOrchFlows.add(ebb);
- for (ExecuteBuildingBlock ebb2 : orchFlows) {
- if (!isVirtualLink && ebb2.getBuildingBlock().getBpmnFlowName().equals("CreateNetworkBB")
- && ebb2.getBuildingBlock().getKey().equalsIgnoreCase(key)) {
- sortedOrchFlows.add(ebb2);
- break;
- }
- if(isVirtualLink && ebb2.getBuildingBlock().getBpmnFlowName().equals("CreateNetworkBB")
- && ebb2.getBuildingBlock().getVirtualLinkKey().equalsIgnoreCase(virtualLinkKey)) {
- sortedOrchFlows.add(ebb2);
- break;
- }
- }
- for (ExecuteBuildingBlock ebb2 : orchFlows) {
- if (!isVirtualLink && ebb2.getBuildingBlock().getBpmnFlowName().equals("ActivateNetworkBB")
- && ebb2.getBuildingBlock().getKey().equalsIgnoreCase(key)) {
- sortedOrchFlows.add(ebb2);
- break;
- }
- if(isVirtualLink && ebb2.getBuildingBlock().getBpmnFlowName().equals("ActivateNetworkBB")
- && ebb2.getBuildingBlock().getVirtualLinkKey().equalsIgnoreCase(virtualLinkKey)) {
- sortedOrchFlows.add(ebb2);
- break;
- }
- }
- } else if (ebb.getBuildingBlock().getBpmnFlowName().equals("CreateNetworkBB")
- || ebb.getBuildingBlock().getBpmnFlowName().equals("ActivateNetworkBB")) {
- continue;
- } else if (!ebb.getBuildingBlock().getBpmnFlowName().equals("")) {
- sortedOrchFlows.add(ebb);
- }
- }
- } else if (requestAction.equals("deleteInstance")) {
- for (ExecuteBuildingBlock ebb : orchFlows) {
- if (ebb.getBuildingBlock().getBpmnFlowName().equals("DeactivateNetworkBB")) {
- sortedOrchFlows.add(ebb);
- String key = ebb.getBuildingBlock().getKey();
- for (ExecuteBuildingBlock ebb2 : orchFlows) {
- if (ebb2.getBuildingBlock().getBpmnFlowName().equals("DeleteNetworkBB")
- && ebb2.getBuildingBlock().getKey().equalsIgnoreCase(key)) {
- sortedOrchFlows.add(ebb2);
- break;
- }
- }
- for (ExecuteBuildingBlock ebb2 : orchFlows) {
- if (ebb2.getBuildingBlock().getBpmnFlowName().equals("UnassignNetworkBB")
- && ebb2.getBuildingBlock().getKey().equalsIgnoreCase(key)) {
- sortedOrchFlows.add(ebb2);
- break;
- }
- }
- } else if (ebb.getBuildingBlock().getBpmnFlowName().equals("DeleteNetworkBB")
- || ebb.getBuildingBlock().getBpmnFlowName().equals("UnassignNetworkBB")) {
- continue;
- } else if (!ebb.getBuildingBlock().getBpmnFlowName().equals("")) {
- sortedOrchFlows.add(ebb);
- }
- }
- }
- return sortedOrchFlows;
- }
+ protected ExecuteBuildingBlock buildExecuteBuildingBlock(OrchestrationFlow orchFlow, String requestId,
+ Resource resource, String apiVersion, String resourceId, String requestAction, boolean aLaCarte,
+ String vnfType, WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails,
+ boolean isVirtualLink, String virtualLinkKey, boolean isConfiguration) {
+ ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock();
+ BuildingBlock buildingBlock = new BuildingBlock();
+ buildingBlock.setBpmnFlowName(orchFlow.getFlowName());
+ buildingBlock.setMsoId(UUID.randomUUID().toString());
+ if (resource == null) {
+ buildingBlock.setKey("");
+ } else {
+ buildingBlock.setKey(resource.getResourceId());
+ }
+ buildingBlock.setIsVirtualLink(isVirtualLink);
+ buildingBlock.setVirtualLinkKey(virtualLinkKey);
+ executeBuildingBlock.setApiVersion(apiVersion);
+ executeBuildingBlock.setaLaCarte(aLaCarte);
+ executeBuildingBlock.setRequestAction(requestAction);
+ executeBuildingBlock.setResourceId(resourceId);
+ executeBuildingBlock.setVnfType(vnfType);
+ executeBuildingBlock.setWorkflowResourceIds(workflowResourceIds);
+ executeBuildingBlock.setRequestId(requestId);
+ executeBuildingBlock.setBuildingBlock(buildingBlock);
+ executeBuildingBlock.setRequestDetails(requestDetails);
+ if (resource != null && (isConfiguration || resource.getResourceType().equals(WorkflowType.CONFIGURATION))) {
+ ConfigurationResourceKeys configurationResourceKeys = new ConfigurationResourceKeys();
+ if (resource != null) {
+ configurationResourceKeys.setCvnfcCustomizationUUID(resource.getCvnfModuleCustomizationId());
+ configurationResourceKeys.setVfModuleCustomizationUUID(resource.getVfModuleCustomizationId());
+ configurationResourceKeys.setVnfResourceCustomizationUUID(resource.getVnfCustomizationId());
+ }
+ executeBuildingBlock.setConfigurationResourceKeys(configurationResourceKeys);
+ }
+ return executeBuildingBlock;
+ }
- protected List<ExecuteBuildingBlock> buildExecuteBuildingBlockList(List<OrchestrationFlow> orchFlows,
- List<Resource> resourceCounter, String requestId, String apiVersion, String resourceId, WorkflowType resourceType,
- String requestAction, boolean aLaCarte, String vnfType,
- WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails) {
- List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
- for (OrchestrationFlow orchFlow : orchFlows) {
- if (orchFlow.getFlowName().contains(SERVICE)) {
- for (int i = 0; i < resourceCounter.stream().filter(x -> WorkflowType.SERVICE == x.getResourceType()).collect(Collectors.toList()).size(); i++) {
- workflowResourceIds.setServiceInstanceId(resourceId);
- flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, resourceCounter.stream().filter(x -> WorkflowType.SERVICE == x.getResourceType())
- .collect(Collectors.toList()).get(i), apiVersion, resourceId,
- requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null, false));
- }
- } else if (orchFlow.getFlowName().contains(VNF)) {
- for (int i = 0; i < resourceCounter.stream().filter(x -> WorkflowType.VNF == x.getResourceType()).collect(Collectors.toList()).size(); i++) {
- flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, resourceCounter.stream().filter(x -> WorkflowType.VNF == x.getResourceType())
- .collect(Collectors.toList()).get(i), apiVersion, resourceId,
- requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null, false));
- }
- } else if (orchFlow.getFlowName().contains(NETWORK)
- && !orchFlow.getFlowName().contains(NETWORKCOLLECTION)) {
- for (int i = 0; i < resourceCounter.stream().filter(x -> WorkflowType.NETWORK == x.getResourceType()).collect(Collectors.toList()).size(); i++) {
- flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, resourceCounter.stream().filter(x -> WorkflowType.NETWORK == x.getResourceType())
- .collect(Collectors.toList()).get(i), apiVersion, resourceId,
- requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null, false));
- }
- for (int i = 0; i < resourceCounter.stream().filter(x -> WorkflowType.VIRTUAL_LINK == x.getResourceType()).collect(Collectors.toList()).size(); i++) {
- Resource resource = resourceCounter.stream().filter(x -> WorkflowType.VIRTUAL_LINK == x.getResourceType())
- .collect(Collectors.toList()).get(i);
- flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, resource, apiVersion, resourceId,
- requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, true, resource.getVirtualLinkKey(), false));
- }
- } else if (orchFlow.getFlowName().contains(VFMODULE)) {
- List<Resource> vfModuleResourcesSorted = null;
- if(requestAction.equals("createInstance")||requestAction.equals("assignInstance")||requestAction.equals("activateInstance")){
- vfModuleResourcesSorted = sortVfModulesByBaseFirst(resourceCounter.stream().filter(x -> WorkflowType.VFMODULE == x.getResourceType())
- .collect(Collectors.toList()));
- }else{
- vfModuleResourcesSorted = sortVfModulesByBaseLast(resourceCounter.stream().filter(x -> WorkflowType.VFMODULE == x.getResourceType())
- .collect(Collectors.toList()));
- }
- for (int i = 0; i < vfModuleResourcesSorted.size(); i++) {
- flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, vfModuleResourcesSorted.get(i), apiVersion, resourceId,
- requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null, false));
- }
- } else if (orchFlow.getFlowName().contains(VOLUMEGROUP)) {
- for (int i = 0; i < resourceCounter.stream().filter(x -> WorkflowType.VOLUMEGROUP == x.getResourceType()).collect(Collectors.toList()).size(); i++) {
- flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, resourceCounter.stream().filter(x -> WorkflowType.VOLUMEGROUP == x.getResourceType())
- .collect(Collectors.toList()).get(i), apiVersion, resourceId,
- requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null, false));
- }
- } else if (orchFlow.getFlowName().contains(NETWORKCOLLECTION)) {
- for (int i = 0; i < resourceCounter.stream().filter(x -> WorkflowType.NETWORKCOLLECTION == x.getResourceType()).collect(Collectors.toList()).size(); i++) {
- flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, resourceCounter.stream().filter(x -> WorkflowType.NETWORKCOLLECTION == x.getResourceType())
- .collect(Collectors.toList()).get(i), apiVersion, resourceId,
- requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null, false));
- }
- } else if (orchFlow.getFlowName().contains(CONFIGURATION)) {
- for (int i = 0; i < resourceCounter.stream().filter(x -> WorkflowType.CONFIGURATION == x.getResourceType()).collect(Collectors.toList()).size(); i++) {
- flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, resourceCounter.stream().filter(x -> WorkflowType.CONFIGURATION == x.getResourceType())
- .collect(Collectors.toList()).get(i), apiVersion, resourceId,
- requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null, true));
- }
- }else {
- flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, null, apiVersion, resourceId,
- requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null, false));
- }
- }
- return flowsToExecute;
- }
+ protected List<OrchestrationFlow> queryNorthBoundRequestCatalogDb(DelegateExecution execution, String requestAction,
+ WorkflowType resourceName, boolean aLaCarte, String cloudOwner) {
+ return this.queryNorthBoundRequestCatalogDb(execution, requestAction, resourceName, aLaCarte, cloudOwner, "");
+ }
- protected ExecuteBuildingBlock buildExecuteBuildingBlock(OrchestrationFlow orchFlow, String requestId, Resource resource,
- String apiVersion, String resourceId, String requestAction, boolean aLaCarte, String vnfType,
- WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails, boolean isVirtualLink, String virtualLinkKey, boolean isConfiguration) {
- ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock();
- BuildingBlock buildingBlock = new BuildingBlock();
- buildingBlock.setBpmnFlowName(orchFlow.getFlowName());
- buildingBlock.setMsoId(UUID.randomUUID().toString());
- if(resource == null){
- buildingBlock.setKey("");
- }else{
- buildingBlock.setKey(resource.getResourceId());
- }
- buildingBlock.setIsVirtualLink(isVirtualLink);
- buildingBlock.setVirtualLinkKey(virtualLinkKey);
- executeBuildingBlock.setApiVersion(apiVersion);
- executeBuildingBlock.setaLaCarte(aLaCarte);
- executeBuildingBlock.setRequestAction(requestAction);
- executeBuildingBlock.setResourceId(resourceId);
- executeBuildingBlock.setVnfType(vnfType);
- executeBuildingBlock.setWorkflowResourceIds(workflowResourceIds);
- executeBuildingBlock.setRequestId(requestId);
- executeBuildingBlock.setBuildingBlock(buildingBlock);
- executeBuildingBlock.setRequestDetails(requestDetails);
- if(resource != null && (isConfiguration || resource.getResourceType().equals(WorkflowType.CONFIGURATION))){
- ConfigurationResourceKeys configurationResourceKeys = new ConfigurationResourceKeys();
- if (resource != null){
- configurationResourceKeys.setCvnfcCustomizationUUID(resource.getCvnfModuleCustomizationId());
- configurationResourceKeys.setVfModuleCustomizationUUID(resource.getVfModuleCustomizationId());
- configurationResourceKeys.setVnfResourceCustomizationUUID(resource.getVnfCustomizationId());
- }
- executeBuildingBlock.setConfigurationResourceKeys(configurationResourceKeys);
- }
- return executeBuildingBlock;
- }
+ protected List<OrchestrationFlow> queryNorthBoundRequestCatalogDb(DelegateExecution execution, String requestAction,
+ WorkflowType resourceName, boolean aLaCarte, String cloudOwner, String serviceType) {
+ List<OrchestrationFlow> listToExecute = new ArrayList<>();
+ NorthBoundRequest northBoundRequest = null;
+ if (serviceType.equalsIgnoreCase(SERVICE_TYPE_TRANSPORT)) {
+ northBoundRequest =
+ catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwnerAndServiceType(
+ requestAction, resourceName.toString(), aLaCarte, cloudOwner, serviceType);
+ } else {
+ northBoundRequest = catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(
+ requestAction, resourceName.toString(), aLaCarte, cloudOwner);
+ }
+ if (northBoundRequest == null) {
+ if (aLaCarte) {
+ buildAndThrowException(execution,
+ "The request: ALaCarte " + resourceName + " " + requestAction + " is not supported by GR_API.");
+ } else {
+ buildAndThrowException(execution,
+ "The request: Macro " + resourceName + " " + requestAction + " is not supported by GR_API.");
+ }
+ } else {
+ if (northBoundRequest.getIsToplevelflow() != null) {
+ execution.setVariable(G_ISTOPLEVELFLOW, northBoundRequest.getIsToplevelflow());
+ }
+ List<OrchestrationFlow> flows = northBoundRequest.getOrchestrationFlowList();
+ if (flows == null)
+ flows = new ArrayList<>();
+ for (OrchestrationFlow flow : flows) {
+ if (!flow.getFlowName().contains("BB")) {
+ List<OrchestrationFlow> macroQueryFlows =
+ catalogDbClient.getOrchestrationFlowByAction(flow.getFlowName());
+ for (OrchestrationFlow macroFlow : macroQueryFlows) {
+ listToExecute.add(macroFlow);
+ }
+ } else {
+ listToExecute.add(flow);
+ }
+ }
+ }
+ return listToExecute;
+ }
- protected List<OrchestrationFlow> queryNorthBoundRequestCatalogDb(DelegateExecution execution, String requestAction,
- WorkflowType resourceName, boolean aLaCarte, String cloudOwner) {
- return this.queryNorthBoundRequestCatalogDb(execution, requestAction, resourceName, aLaCarte, cloudOwner, "");
- }
-
- protected List<OrchestrationFlow> queryNorthBoundRequestCatalogDb(DelegateExecution execution, String requestAction,
- WorkflowType resourceName, boolean aLaCarte, String cloudOwner, String serviceType) {
- List<OrchestrationFlow> listToExecute = new ArrayList<>();
- NorthBoundRequest northBoundRequest = null;
- if (serviceType.equalsIgnoreCase(SERVICE_TYPE_TRANSPORT)) {
- northBoundRequest = catalogDbClient
- .getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwnerAndServiceType(requestAction,
- resourceName.toString(), aLaCarte, cloudOwner, serviceType);
- } else {
- northBoundRequest = catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(
- requestAction, resourceName.toString(), aLaCarte, cloudOwner);
- }
- if(northBoundRequest == null){
- if(aLaCarte){
- buildAndThrowException(execution,"The request: ALaCarte " + resourceName + " " + requestAction + " is not supported by GR_API.");
- }else{
- buildAndThrowException(execution,"The request: Macro " + resourceName + " " + requestAction + " is not supported by GR_API.");
- }
- } else {
- if(northBoundRequest.getIsToplevelflow()!=null){
- execution.setVariable(G_ISTOPLEVELFLOW, northBoundRequest.getIsToplevelflow());
- }
- List<OrchestrationFlow> flows = northBoundRequest.getOrchestrationFlowList();
- if (flows == null)
- flows = new ArrayList<>();
- for (OrchestrationFlow flow : flows) {
- if (!flow.getFlowName().contains("BB")) {
- List<OrchestrationFlow> macroQueryFlows = catalogDbClient
- .getOrchestrationFlowByAction(flow.getFlowName());
- for (OrchestrationFlow macroFlow : macroQueryFlows) {
- listToExecute.add(macroFlow);
- }
- } else {
- listToExecute.add(flow);
- }
- }
- }
- return listToExecute;
- }
+ protected void buildAndThrowException(DelegateExecution execution, String msg, Exception ex) {
+ logger.error(msg, ex);
+ execution.setVariable(WORKFLOW_ACTION_ERROR_MESSAGE, msg);
+ exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, msg);
+ }
- protected void buildAndThrowException(DelegateExecution execution, String msg, Exception ex) {
- logger.error(msg, ex);
- execution.setVariable(WORKFLOW_ACTION_ERROR_MESSAGE, msg);
- exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, msg);
- }
+ protected void buildAndThrowException(DelegateExecution execution, String msg) {
+ logger.error(msg);
+ execution.setVariable(WORKFLOW_ACTION_ERROR_MESSAGE, msg);
+ exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, msg);
+ }
- protected void buildAndThrowException(DelegateExecution execution, String msg) {
- logger.error(msg);
- execution.setVariable(WORKFLOW_ACTION_ERROR_MESSAGE, msg);
- exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, msg);
- }
-
- public void handleRuntimeException (DelegateExecution execution){
- StringBuilder wfeExpMsg = new StringBuilder("Runtime error ");
- String runtimeErrorMessage = null;
- try{
- String javaExpMsg = (String) execution.getVariable("BPMN_javaExpMsg");
- if (javaExpMsg != null && !javaExpMsg.isEmpty()) {
- wfeExpMsg = wfeExpMsg.append(": ").append(javaExpMsg);
- }
- runtimeErrorMessage = wfeExpMsg.toString();
- logger.error(runtimeErrorMessage);
- execution.setVariable(WORKFLOW_ACTION_ERROR_MESSAGE, runtimeErrorMessage);
- } catch (Exception e){
- logger.error("Runtime error", e);
- //if runtime message was mulformed
- runtimeErrorMessage = "Runtime error";
- }
- exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, runtimeErrorMessage);
- }
+ public void handleRuntimeException(DelegateExecution execution) {
+ StringBuilder wfeExpMsg = new StringBuilder("Runtime error ");
+ String runtimeErrorMessage = null;
+ try {
+ String javaExpMsg = (String) execution.getVariable("BPMN_javaExpMsg");
+ if (javaExpMsg != null && !javaExpMsg.isEmpty()) {
+ wfeExpMsg = wfeExpMsg.append(": ").append(javaExpMsg);
+ }
+ runtimeErrorMessage = wfeExpMsg.toString();
+ logger.error(runtimeErrorMessage);
+ execution.setVariable(WORKFLOW_ACTION_ERROR_MESSAGE, runtimeErrorMessage);
+ } catch (Exception e) {
+ logger.error("Runtime error", e);
+ // if runtime message was mulformed
+ runtimeErrorMessage = "Runtime error";
+ }
+ exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, runtimeErrorMessage);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailure.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailure.java
index 1812e50328..4fc4d85b97 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailure.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailure.java
@@ -21,7 +21,6 @@
package org.onap.so.bpmn.infrastructure.workflow.tasks;
import java.util.Optional;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.onap.so.bpmn.core.WorkflowException;
@@ -36,113 +35,115 @@ import org.springframework.stereotype.Component;
@Component
public class WorkflowActionBBFailure {
- private static final Logger logger = LoggerFactory.getLogger(WorkflowActionBBFailure.class);
- @Autowired
- private RequestsDbClient requestDbclient;
- @Autowired
- private WorkflowAction workflowAction;
-
- protected void updateRequestErrorStatusMessage(DelegateExecution execution) {
- try {
- String requestId = (String) execution.getVariable("mso-request-id");
- InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId);
- String errorMsg = "";
- Optional<String> errorMsgOp = retrieveErrorMessage(execution);
- if(errorMsgOp.isPresent()){
- errorMsg = errorMsgOp.get();
- }else{
- errorMsg = "Failed to determine error message";
- }
- request.setStatusMessage(errorMsg);
- requestDbclient.updateInfraActiveRequests(request);
- } catch (Exception e) {
- logger.error("Failed to update Request db with the status message after retry or rollback has been initialized.",e);
- }
- }
-
- public void updateRequestStatusToFailed(DelegateExecution execution) {
- try {
- String requestId = (String) execution.getVariable("mso-request-id");
- InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId);
- String rollbackErrorMsg = "";
- String errorMsg = "";
- Boolean rollbackCompletedSuccessfully = (Boolean) execution.getVariable("isRollbackComplete");
- Boolean isRollbackFailure = (Boolean) execution.getVariable("isRollback");
- ExecuteBuildingBlock ebb = (ExecuteBuildingBlock) execution.getVariable("buildingBlock");
- if(rollbackCompletedSuccessfully==null)
- rollbackCompletedSuccessfully = false;
-
- if(isRollbackFailure==null)
- isRollbackFailure = false;
-
- if(rollbackCompletedSuccessfully){
- rollbackErrorMsg = "Rollback has been completed successfully.";
- request.setRollbackStatusMessage(rollbackErrorMsg);
- execution.setVariable("RollbackErrorMessage", rollbackErrorMsg);
- }else if(isRollbackFailure){
- Optional<String> rollbackErrorMsgOp = retrieveErrorMessage(execution);
- if(rollbackErrorMsgOp.isPresent()){
- rollbackErrorMsg = rollbackErrorMsgOp.get();
- }else{
- rollbackErrorMsg = "Failed to determine rollback error message.";
- }
- request.setRollbackStatusMessage(rollbackErrorMsg);
- execution.setVariable("RollbackErrorMessage", rollbackErrorMsg);
- }else{
- Optional<String> errorMsgOp = retrieveErrorMessage(execution);
- if(errorMsgOp.isPresent()){
- errorMsg = errorMsgOp.get();
- }else{
- errorMsg = "Failed to determine error message";
- }
- request.setStatusMessage(errorMsg);
- execution.setVariable("ErrorMessage", errorMsg);
- }
- if(ebb!=null && ebb.getBuildingBlock()!=null){
- String flowStatus = "";
- if(rollbackCompletedSuccessfully){
- flowStatus = "All Rollback flows have completed successfully";
- }else{
- flowStatus = ebb.getBuildingBlock().getBpmnFlowName() + " has failed.";
- }
- request.setFlowStatus(flowStatus);
- execution.setVariable("flowStatus", flowStatus);
- }
+ private static final Logger logger = LoggerFactory.getLogger(WorkflowActionBBFailure.class);
+ @Autowired
+ private RequestsDbClient requestDbclient;
+ @Autowired
+ private WorkflowAction workflowAction;
+
+ protected void updateRequestErrorStatusMessage(DelegateExecution execution) {
+ try {
+ String requestId = (String) execution.getVariable("mso-request-id");
+ InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId);
+ String errorMsg = "";
+ Optional<String> errorMsgOp = retrieveErrorMessage(execution);
+ if (errorMsgOp.isPresent()) {
+ errorMsg = errorMsgOp.get();
+ } else {
+ errorMsg = "Failed to determine error message";
+ }
+ request.setStatusMessage(errorMsg);
+ requestDbclient.updateInfraActiveRequests(request);
+ } catch (Exception e) {
+ logger.error(
+ "Failed to update Request db with the status message after retry or rollback has been initialized.",
+ e);
+ }
+ }
+
+ public void updateRequestStatusToFailed(DelegateExecution execution) {
+ try {
+ String requestId = (String) execution.getVariable("mso-request-id");
+ InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId);
+ String rollbackErrorMsg = "";
+ String errorMsg = "";
+ Boolean rollbackCompletedSuccessfully = (Boolean) execution.getVariable("isRollbackComplete");
+ Boolean isRollbackFailure = (Boolean) execution.getVariable("isRollback");
+ ExecuteBuildingBlock ebb = (ExecuteBuildingBlock) execution.getVariable("buildingBlock");
+ if (rollbackCompletedSuccessfully == null)
+ rollbackCompletedSuccessfully = false;
+
+ if (isRollbackFailure == null)
+ isRollbackFailure = false;
+
+ if (rollbackCompletedSuccessfully) {
+ rollbackErrorMsg = "Rollback has been completed successfully.";
+ request.setRollbackStatusMessage(rollbackErrorMsg);
+ execution.setVariable("RollbackErrorMessage", rollbackErrorMsg);
+ } else if (isRollbackFailure) {
+ Optional<String> rollbackErrorMsgOp = retrieveErrorMessage(execution);
+ if (rollbackErrorMsgOp.isPresent()) {
+ rollbackErrorMsg = rollbackErrorMsgOp.get();
+ } else {
+ rollbackErrorMsg = "Failed to determine rollback error message.";
+ }
+ request.setRollbackStatusMessage(rollbackErrorMsg);
+ execution.setVariable("RollbackErrorMessage", rollbackErrorMsg);
+ } else {
+ Optional<String> errorMsgOp = retrieveErrorMessage(execution);
+ if (errorMsgOp.isPresent()) {
+ errorMsg = errorMsgOp.get();
+ } else {
+ errorMsg = "Failed to determine error message";
+ }
+ request.setStatusMessage(errorMsg);
+ execution.setVariable("ErrorMessage", errorMsg);
+ }
+ if (ebb != null && ebb.getBuildingBlock() != null) {
+ String flowStatus = "";
+ if (rollbackCompletedSuccessfully) {
+ flowStatus = "All Rollback flows have completed successfully";
+ } else {
+ flowStatus = ebb.getBuildingBlock().getBpmnFlowName() + " has failed.";
+ }
+ request.setFlowStatus(flowStatus);
+ execution.setVariable("flowStatus", flowStatus);
+ }
+
+ request.setProgress(Long.valueOf(100));
+ request.setRequestStatus("FAILED");
+ request.setLastModifiedBy("CamundaBPMN");
+ requestDbclient.updateInfraActiveRequests(request);
+ } catch (Exception e) {
+ workflowAction.buildAndThrowException(execution, "Error Updating Request Database", e);
+ }
+ }
+
+ private Optional<String> retrieveErrorMessage(DelegateExecution execution) {
+ String errorMsg = "";
+ try {
+ WorkflowException exception = (WorkflowException) execution.getVariable("WorkflowException");
+ if (exception != null && (exception.getErrorMessage() != null || !exception.getErrorMessage().equals(""))) {
+ errorMsg = exception.getErrorMessage();
+ }
+ if (errorMsg == null || errorMsg.equals("")) {
+ errorMsg = (String) execution.getVariable("WorkflowExceptionErrorMessage");
+ }
+ return Optional.of(errorMsg);
+ } catch (Exception ex) {
+ logger.error("Failed to extract workflow exception from execution.", ex);
+ }
+ return Optional.empty();
+ }
- request.setProgress(Long.valueOf(100));
- request.setRequestStatus("FAILED");
- request.setLastModifiedBy("CamundaBPMN");
- requestDbclient.updateInfraActiveRequests(request);
- } catch (Exception e) {
- workflowAction.buildAndThrowException(execution, "Error Updating Request Database", e);
- }
- }
-
- private Optional<String> retrieveErrorMessage (DelegateExecution execution){
- String errorMsg = "";
- try {
- WorkflowException exception = (WorkflowException) execution.getVariable("WorkflowException");
- if(exception != null && (exception.getErrorMessage()!=null || !exception.getErrorMessage().equals(""))){
- errorMsg = exception.getErrorMessage();
- }
- if(errorMsg == null || errorMsg.equals("")){
- errorMsg = (String) execution.getVariable("WorkflowExceptionErrorMessage");
- }
- return Optional.of(errorMsg);
- } catch (Exception ex) {
- logger.error("Failed to extract workflow exception from execution.",ex);
- }
- return Optional.empty();
- }
-
- public void updateRequestStatusToFailedWithRollback(DelegateExecution execution) {
- execution.setVariable("isRollbackComplete", true);
- updateRequestStatusToFailed(execution);
- }
+ public void updateRequestStatusToFailedWithRollback(DelegateExecution execution) {
+ execution.setVariable("isRollbackComplete", true);
+ updateRequestStatusToFailed(execution);
+ }
- public void abortCallErrorHandling(DelegateExecution execution) {
- String msg = "Flow has failed. Rainy day handler has decided to abort the process.";
- logger.error(msg);
- throw new BpmnError(msg);
- }
+ public void abortCallErrorHandling(DelegateExecution execution) {
+ String msg = "Flow has failed. Rainy day handler has decided to abort the process.";
+ logger.error(msg);
+ throw new BpmnError(msg);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java
index a327f0670a..4514d24c54 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java
@@ -24,9 +24,7 @@ import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
-
import javax.persistence.EntityNotFoundException;
-
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.onap.aai.domain.yang.Vnfc;
import org.onap.so.bpmn.common.workflow.context.WorkflowCallbackResponse;
@@ -49,382 +47,394 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
-
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
@Component
public class WorkflowActionBBTasks {
- private static final String G_CURRENT_SEQUENCE = "gCurrentSequence";
- private static final String G_REQUEST_ID = "mso-request-id";
- private static final String G_ALACARTE = "aLaCarte";
- private static final String G_ACTION = "requestAction";
- private static final String RETRY_COUNT = "retryCount";
- private static final String FABRIC_CONFIGURATION = "FabricConfiguration";
- private static final String ASSIGN_FABRIC_CONFIGURATION_BB = "AssignFabricConfigurationBB";
- private static final String ACTIVATE_FABRIC_CONFIGURATION_BB = "ActivateFabricConfigurationBB";
- protected String maxRetries = "mso.rainyDay.maxRetries";
- private static final Logger logger = LoggerFactory.getLogger(WorkflowActionBBTasks.class);
+ private static final String G_CURRENT_SEQUENCE = "gCurrentSequence";
+ private static final String G_REQUEST_ID = "mso-request-id";
+ private static final String G_ALACARTE = "aLaCarte";
+ private static final String G_ACTION = "requestAction";
+ private static final String RETRY_COUNT = "retryCount";
+ private static final String FABRIC_CONFIGURATION = "FabricConfiguration";
+ private static final String ASSIGN_FABRIC_CONFIGURATION_BB = "AssignFabricConfigurationBB";
+ private static final String ACTIVATE_FABRIC_CONFIGURATION_BB = "ActivateFabricConfigurationBB";
+ protected String maxRetries = "mso.rainyDay.maxRetries";
+ private static final Logger logger = LoggerFactory.getLogger(WorkflowActionBBTasks.class);
+
+ @Autowired
+ private RequestsDbClient requestDbclient;
+ @Autowired
+ private WorkflowAction workflowAction;
+ @Autowired
+ private WorkflowActionBBFailure workflowActionBBFailure;
+ @Autowired
+ private Environment environment;
+ @Autowired
+ private BBInputSetupUtils bbInputSetupUtils;
+ @Autowired
+ private CatalogDbClient catalogDbClient;
+
+ public void selectBB(DelegateExecution execution) {
+ List<ExecuteBuildingBlock> flowsToExecute =
+ (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ execution.setVariable("MacroRollback", false);
+ int currentSequence = (int) execution.getVariable(G_CURRENT_SEQUENCE);
+ ExecuteBuildingBlock ebb = flowsToExecute.get(currentSequence);
+ boolean homing = (boolean) execution.getVariable("homing");
+ boolean calledHoming = (boolean) execution.getVariable("calledHoming");
+ if (homing && !calledHoming) {
+ if (ebb.getBuildingBlock().getBpmnFlowName().equals("AssignVnfBB")) {
+ ebb.setHoming(true);
+ execution.setVariable("calledHoming", true);
+ }
+ } else {
+ ebb.setHoming(false);
+ }
+ execution.setVariable("buildingBlock", ebb);
+ currentSequence++;
+ if (currentSequence >= flowsToExecute.size()) {
+ execution.setVariable("completed", true);
+ } else {
+ execution.setVariable("completed", false);
+ }
+ execution.setVariable(G_CURRENT_SEQUENCE, currentSequence);
+ }
+
+ public void updateFlowStatistics(DelegateExecution execution) {
+ try {
+ int currentSequence = (int) execution.getVariable(G_CURRENT_SEQUENCE);
+ if (currentSequence > 1) {
+ InfraActiveRequests request = this.getUpdatedRequest(execution, currentSequence);
+ requestDbclient.updateInfraActiveRequests(request);
+ }
+ } catch (Exception ex) {
+ logger.warn(
+ "Bpmn Flow Statistics was unable to update Request Db with the new completion percentage. Competion percentage may be invalid.");
+ }
+ }
+
+ protected InfraActiveRequests getUpdatedRequest(DelegateExecution execution, int currentSequence) {
+ List<ExecuteBuildingBlock> flowsToExecute =
+ (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ String requestId = (String) execution.getVariable(G_REQUEST_ID);
+ InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId);
+ ExecuteBuildingBlock completedBB = flowsToExecute.get(currentSequence - 2);
+ ExecuteBuildingBlock nextBB = flowsToExecute.get(currentSequence - 1);
+ int completedBBs = currentSequence - 1;
+ int totalBBs = flowsToExecute.size();
+ int remainingBBs = totalBBs - completedBBs;
+ String statusMessage = this.getStatusMessage(completedBB.getBuildingBlock().getBpmnFlowName(),
+ nextBB.getBuildingBlock().getBpmnFlowName(), completedBBs, remainingBBs);
+ Long percentProgress = this.getPercentProgress(completedBBs, totalBBs);
+ request.setFlowStatus(statusMessage);
+ request.setProgress(percentProgress);
+ request.setLastModifiedBy("CamundaBPMN");
+ return request;
+ }
+
+ protected Long getPercentProgress(int completedBBs, int totalBBs) {
+ double ratio = (completedBBs / (totalBBs * 1.0));
+ int percentProgress = (int) (ratio * 95);
+ return new Long(percentProgress + 5);
+ }
+
+ protected String getStatusMessage(String completedBB, String nextBB, int completedBBs, int remainingBBs) {
+ return "Execution of " + completedBB + " has completed successfully, next invoking " + nextBB
+ + " (Execution Path progress: BBs completed = " + completedBBs + "; BBs remaining = " + remainingBBs
+ + ").";
+ }
+
+ public void sendSyncAck(DelegateExecution execution) {
+ final String requestId = (String) execution.getVariable(G_REQUEST_ID);
+ final String resourceId = (String) execution.getVariable("resourceId");
+ ServiceInstancesResponse serviceInstancesResponse = new ServiceInstancesResponse();
+ RequestReferences requestRef = new RequestReferences();
+ requestRef.setInstanceId(resourceId);
+ requestRef.setRequestId(requestId);
+ serviceInstancesResponse.setRequestReferences(requestRef);
+ ObjectMapper mapper = new ObjectMapper();
+ String jsonRequest = "";
+ try {
+ jsonRequest = mapper.writeValueAsString(serviceInstancesResponse);
+ } catch (JsonProcessingException e) {
+ workflowAction.buildAndThrowException(execution,
+ "Could not marshall ServiceInstancesRequest to Json string to respond to API Handler.", e);
+ }
+ WorkflowCallbackResponse callbackResponse = new WorkflowCallbackResponse();
+ callbackResponse.setStatusCode(200);
+ callbackResponse.setMessage("Success");
+ callbackResponse.setResponse(jsonRequest);
+ String processKey = execution.getProcessEngineServices().getRepositoryService()
+ .getProcessDefinition(execution.getProcessDefinitionId()).getKey();
+ WorkflowContextHolder.getInstance().processCallback(processKey, execution.getProcessInstanceId(), requestId,
+ callbackResponse);
+ logger.info("Successfully sent sync ack.");
+ updateInstanceId(execution);
+ }
+
+ public void sendErrorSyncAck(DelegateExecution execution) {
+ final String requestId = (String) execution.getVariable(G_REQUEST_ID);
+ try {
+ ExceptionBuilder exceptionBuilder = new ExceptionBuilder();
+ String errorMsg = (String) execution.getVariable("WorkflowActionErrorMessage");
+ if (errorMsg == null) {
+ errorMsg = "WorkflowAction failed unexpectedly.";
+ }
+ String processKey = exceptionBuilder.getProcessKey(execution);
+ String buildworkflowException =
+ "<aetgt:WorkflowException xmlns:aetgt=\"http://org.onap/so/workflow/schema/v1\"><aetgt:ErrorMessage>"
+ + errorMsg
+ + "</aetgt:ErrorMessage><aetgt:ErrorCode>7000</aetgt:ErrorCode></aetgt:WorkflowException>";
+ WorkflowCallbackResponse callbackResponse = new WorkflowCallbackResponse();
+ callbackResponse.setStatusCode(500);
+ callbackResponse.setMessage("Fail");
+ callbackResponse.setResponse(buildworkflowException);
+ WorkflowContextHolder.getInstance().processCallback(processKey, execution.getProcessInstanceId(), requestId,
+ callbackResponse);
+ execution.setVariable("sentSyncResponse", true);
+ } catch (Exception ex) {
+ logger.error(" Sending Sync Error Activity Failed. {}", ex.getMessage(), ex);
+ }
+ }
+
+ public void updateRequestStatusToComplete(DelegateExecution execution) {
+ try {
+ final String requestId = (String) execution.getVariable(G_REQUEST_ID);
+ InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId);
+ final String action = (String) execution.getVariable(G_ACTION);
+ final boolean aLaCarte = (boolean) execution.getVariable(G_ALACARTE);
+ final String resourceName = (String) execution.getVariable("resourceName");
+ String macroAction = "";
+ if (aLaCarte) {
+ macroAction = "ALaCarte-" + resourceName + "-" + action + " request was executed correctly.";
+ } else {
+ macroAction = "Macro-" + resourceName + "-" + action + " request was executed correctly.";
+ }
+ execution.setVariable("finalStatusMessage", macroAction);
+ Timestamp endTime = new Timestamp(System.currentTimeMillis());
+ request.setEndTime(endTime);
+ request.setFlowStatus("Successfully completed all Building Blocks");
+ request.setStatusMessage(macroAction);
+ request.setProgress(Long.valueOf(100));
+ request.setRequestStatus("COMPLETE");
+ request.setLastModifiedBy("CamundaBPMN");
+ requestDbclient.updateInfraActiveRequests(request);
+ } catch (Exception ex) {
+ workflowAction.buildAndThrowException(execution, "Error Updating Request Database", ex);
+ }
+ }
+
+ public void checkRetryStatus(DelegateExecution execution) {
+ String handlingCode = (String) execution.getVariable("handlingCode");
+ String requestId = (String) execution.getVariable(G_REQUEST_ID);
+ String retryDuration = (String) execution.getVariable("RetryDuration");
+ int retryCount = (int) execution.getVariable(RETRY_COUNT);
+ int envMaxRetries;
+ try {
+ envMaxRetries = Integer.parseInt(this.environment.getProperty(maxRetries));
+ } catch (Exception ex) {
+ logger.error("Could not read maxRetries from config file. Setting max to 5 retries");
+ envMaxRetries = 5;
+ }
+ int nextCount = retryCount + 1;
+ if (handlingCode.equals("Retry")) {
+ workflowActionBBFailure.updateRequestErrorStatusMessage(execution);
+ try {
+ InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId);
+ request.setRetryStatusMessage(
+ "Retry " + nextCount + "/" + envMaxRetries + " will be started in " + retryDuration);
+ requestDbclient.updateInfraActiveRequests(request);
+ } catch (Exception ex) {
+ logger.warn("Failed to update Request Db Infra Active Requests with Retry Status", ex);
+ }
+ if (retryCount < envMaxRetries) {
+ int currSequence = (int) execution.getVariable("gCurrentSequence");
+ execution.setVariable("gCurrentSequence", currSequence - 1);
+ execution.setVariable(RETRY_COUNT, nextCount);
+ } else {
+ workflowAction.buildAndThrowException(execution,
+ "Exceeded maximum retries. Ending flow with status Abort");
+ }
+ } else {
+ execution.setVariable(RETRY_COUNT, 0);
+ }
+ }
+
+ /**
+ * Rollback will only handle Create/Activate/Assign Macro flows. Execute layer will rollback the flow its currently
+ * working on.
+ */
+ public void rollbackExecutionPath(DelegateExecution execution) {
+ if (!(boolean) execution.getVariable("isRollback")) {
+ List<ExecuteBuildingBlock> flowsToExecute =
+ (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ List<ExecuteBuildingBlock> rollbackFlows = new ArrayList();
+ int currentSequence = (int) execution.getVariable(G_CURRENT_SEQUENCE);
+ int listSize = flowsToExecute.size();
+ for (int i = listSize - 1; i >= 0; i--) {
+ if (i > currentSequence - 1) {
+ flowsToExecute.remove(i);
+ } else {
+ String flowName = flowsToExecute.get(i).getBuildingBlock().getBpmnFlowName();
+ if (flowName.contains("Assign")) {
+ flowName = "Unassign" + flowName.substring(6, flowName.length());
+ } else if (flowName.contains("Create")) {
+ flowName = "Delete" + flowName.substring(6, flowName.length());
+ } else if (flowName.contains("Activate")) {
+ flowName = "Deactivate" + flowName.substring(8, flowName.length());
+ } else {
+ continue;
+ }
+ flowsToExecute.get(i).getBuildingBlock().setBpmnFlowName(flowName);
+ rollbackFlows.add(flowsToExecute.get(i));
+ }
+ }
- @Autowired
- private RequestsDbClient requestDbclient;
- @Autowired
- private WorkflowAction workflowAction;
- @Autowired
- private WorkflowActionBBFailure workflowActionBBFailure;
- @Autowired
- private Environment environment;
- @Autowired
- private BBInputSetupUtils bbInputSetupUtils;
- @Autowired
- private CatalogDbClient catalogDbClient;
-
- public void selectBB(DelegateExecution execution) {
- List<ExecuteBuildingBlock> flowsToExecute = (List<ExecuteBuildingBlock>) execution
- .getVariable("flowsToExecute");
- execution.setVariable("MacroRollback", false);
- int currentSequence = (int) execution.getVariable(G_CURRENT_SEQUENCE);
- ExecuteBuildingBlock ebb = flowsToExecute.get(currentSequence);
- boolean homing = (boolean) execution.getVariable("homing");
- boolean calledHoming = (boolean) execution.getVariable("calledHoming");
- if (homing && !calledHoming) {
- if (ebb.getBuildingBlock().getBpmnFlowName().equals("AssignVnfBB")) {
- ebb.setHoming(true);
- execution.setVariable("calledHoming", true);
- }
- } else {
- ebb.setHoming(false);
- }
- execution.setVariable("buildingBlock", ebb);
- currentSequence++;
- if (currentSequence >= flowsToExecute.size()) {
- execution.setVariable("completed", true);
- } else {
- execution.setVariable("completed", false);
- }
- execution.setVariable(G_CURRENT_SEQUENCE, currentSequence);
- }
-
- public void updateFlowStatistics(DelegateExecution execution) {
- try{
- int currentSequence = (int) execution.getVariable(G_CURRENT_SEQUENCE);
- if(currentSequence > 1) {
- InfraActiveRequests request = this.getUpdatedRequest(execution, currentSequence);
- requestDbclient.updateInfraActiveRequests(request);
- }
- }catch (Exception ex){
- logger.warn("Bpmn Flow Statistics was unable to update Request Db with the new completion percentage. Competion percentage may be invalid.");
- }
- }
+ String handlingCode = (String) execution.getVariable("handlingCode");
+ List<ExecuteBuildingBlock> rollbackFlowsFiltered = new ArrayList<>();
+ rollbackFlowsFiltered.addAll(rollbackFlows);
+ if (handlingCode.equals("RollbackToAssigned") || handlingCode.equals("RollbackToCreated")) {
+ for (int i = 0; i < rollbackFlows.size(); i++) {
+ if (rollbackFlows.get(i).getBuildingBlock().getBpmnFlowName().contains("Unassign")) {
+ rollbackFlowsFiltered.remove(rollbackFlows.get(i));
+ } else if (rollbackFlows.get(i).getBuildingBlock().getBpmnFlowName().contains("Delete")
+ && handlingCode.equals("RollbackToCreated")) {
+ rollbackFlowsFiltered.remove(rollbackFlows.get(i));
+ }
+ }
+ }
- protected InfraActiveRequests getUpdatedRequest(DelegateExecution execution, int currentSequence) {
- List<ExecuteBuildingBlock> flowsToExecute = (List<ExecuteBuildingBlock>) execution
- .getVariable("flowsToExecute");
- String requestId = (String) execution.getVariable(G_REQUEST_ID);
- InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId);
- ExecuteBuildingBlock completedBB = flowsToExecute.get(currentSequence - 2);
- ExecuteBuildingBlock nextBB = flowsToExecute.get(currentSequence - 1);
- int completedBBs = currentSequence - 1;
- int totalBBs = flowsToExecute.size();
- int remainingBBs = totalBBs - completedBBs;
- String statusMessage = this.getStatusMessage(completedBB.getBuildingBlock().getBpmnFlowName(),
- nextBB.getBuildingBlock().getBpmnFlowName(), completedBBs, remainingBBs);
- Long percentProgress = this.getPercentProgress(completedBBs, totalBBs);
- request.setFlowStatus(statusMessage);
- request.setProgress(percentProgress);
- request.setLastModifiedBy("CamundaBPMN");
- return request;
- }
-
- protected Long getPercentProgress(int completedBBs, int totalBBs) {
- double ratio = (completedBBs / (totalBBs * 1.0));
- int percentProgress = (int) (ratio * 95);
- return new Long(percentProgress + 5);
- }
-
- protected String getStatusMessage(String completedBB, String nextBB, int completedBBs, int remainingBBs) {
- return "Execution of " + completedBB + " has completed successfully, next invoking " + nextBB
- + " (Execution Path progress: BBs completed = " + completedBBs + "; BBs remaining = " + remainingBBs
- + ").";
- }
+ workflowActionBBFailure.updateRequestErrorStatusMessage(execution);
- public void sendSyncAck(DelegateExecution execution) {
- final String requestId = (String) execution.getVariable(G_REQUEST_ID);
- final String resourceId = (String) execution.getVariable("resourceId");
- ServiceInstancesResponse serviceInstancesResponse = new ServiceInstancesResponse();
- RequestReferences requestRef = new RequestReferences();
- requestRef.setInstanceId(resourceId);
- requestRef.setRequestId(requestId);
- serviceInstancesResponse.setRequestReferences(requestRef);
- ObjectMapper mapper = new ObjectMapper();
- String jsonRequest = "";
- try {
- jsonRequest = mapper.writeValueAsString(serviceInstancesResponse);
- } catch (JsonProcessingException e) {
- workflowAction.buildAndThrowException(execution,
- "Could not marshall ServiceInstancesRequest to Json string to respond to API Handler.", e);
- }
- WorkflowCallbackResponse callbackResponse = new WorkflowCallbackResponse();
- callbackResponse.setStatusCode(200);
- callbackResponse.setMessage("Success");
- callbackResponse.setResponse(jsonRequest);
- String processKey = execution.getProcessEngineServices().getRepositoryService()
- .getProcessDefinition(execution.getProcessDefinitionId()).getKey();
- WorkflowContextHolder.getInstance().processCallback(processKey, execution.getProcessInstanceId(), requestId,
- callbackResponse);
- logger.info("Successfully sent sync ack.");
- updateInstanceId(execution);
- }
+ if (rollbackFlows.isEmpty())
+ execution.setVariable("isRollbackNeeded", false);
+ else
+ execution.setVariable("isRollbackNeeded", true);
+ execution.setVariable("flowsToExecute", rollbackFlowsFiltered);
+ execution.setVariable("handlingCode", "PreformingRollback");
+ execution.setVariable("isRollback", true);
+ execution.setVariable("gCurrentSequence", 0);
+ execution.setVariable(RETRY_COUNT, 0);
+ } else {
+ workflowAction.buildAndThrowException(execution,
+ "Rollback has already been called. Cannot rollback a request that is currently in the rollback state.");
+ }
+ }
- public void sendErrorSyncAck(DelegateExecution execution) {
- final String requestId = (String) execution.getVariable(G_REQUEST_ID);
- try {
- ExceptionBuilder exceptionBuilder = new ExceptionBuilder();
- String errorMsg = (String) execution.getVariable("WorkflowActionErrorMessage");
- if (errorMsg == null) {
- errorMsg = "WorkflowAction failed unexpectedly.";
- }
- String processKey = exceptionBuilder.getProcessKey(execution);
- String buildworkflowException = "<aetgt:WorkflowException xmlns:aetgt=\"http://org.onap/so/workflow/schema/v1\"><aetgt:ErrorMessage>"
- + errorMsg
- + "</aetgt:ErrorMessage><aetgt:ErrorCode>7000</aetgt:ErrorCode></aetgt:WorkflowException>";
- WorkflowCallbackResponse callbackResponse = new WorkflowCallbackResponse();
- callbackResponse.setStatusCode(500);
- callbackResponse.setMessage("Fail");
- callbackResponse.setResponse(buildworkflowException);
- WorkflowContextHolder.getInstance().processCallback(processKey, execution.getProcessInstanceId(), requestId,
- callbackResponse);
- execution.setVariable("sentSyncResponse", true);
- } catch (Exception ex) {
- logger.error(" Sending Sync Error Activity Failed. {}" , ex.getMessage(), ex);
- }
- }
+ protected void updateInstanceId(DelegateExecution execution) {
+ try {
+ String requestId = (String) execution.getVariable(G_REQUEST_ID);
+ String resourceId = (String) execution.getVariable("resourceId");
+ WorkflowType resourceType = (WorkflowType) execution.getVariable("resourceType");
+ InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId);
+ if (resourceType == WorkflowType.SERVICE) {
+ request.setServiceInstanceId(resourceId);
+ } else if (resourceType == WorkflowType.VNF) {
+ request.setVnfId(resourceId);
+ } else if (resourceType == WorkflowType.VFMODULE) {
+ request.setVfModuleId(resourceId);
+ } else if (resourceType == WorkflowType.VOLUMEGROUP) {
+ request.setVolumeGroupId(resourceId);
+ } else if (resourceType == WorkflowType.NETWORK) {
+ request.setNetworkId(resourceId);
+ } else if (resourceType == WorkflowType.CONFIGURATION) {
+ request.setConfigurationId(resourceId);
+ } else if (resourceType == WorkflowType.INSTANCE_GROUP) {
+ request.setInstanceGroupId(resourceId);
+ }
+ requestDbclient.updateInfraActiveRequests(request);
+ } catch (Exception ex) {
+ workflowAction.buildAndThrowException(execution, "Failed to update Request db with instanceId");
+ }
+ }
- public void updateRequestStatusToComplete(DelegateExecution execution) {
- try{
- final String requestId = (String) execution.getVariable(G_REQUEST_ID);
- InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId);
- final String action = (String) execution.getVariable(G_ACTION);
- final boolean aLaCarte = (boolean) execution.getVariable(G_ALACARTE);
- final String resourceName = (String) execution.getVariable("resourceName");
- String macroAction = "";
- if (aLaCarte) {
- macroAction = "ALaCarte-" + resourceName + "-" + action + " request was executed correctly.";
- } else {
- macroAction = "Macro-" + resourceName + "-" + action + " request was executed correctly.";
- }
- execution.setVariable("finalStatusMessage", macroAction);
- Timestamp endTime = new Timestamp(System.currentTimeMillis());
- request.setEndTime(endTime);
- request.setFlowStatus("Successfully completed all Building Blocks");
- request.setStatusMessage(macroAction);
- request.setProgress(Long.valueOf(100));
- request.setRequestStatus("COMPLETE");
- request.setLastModifiedBy("CamundaBPMN");
- requestDbclient.updateInfraActiveRequests(request);
- }catch (Exception ex) {
- workflowAction.buildAndThrowException(execution, "Error Updating Request Database", ex);
- }
- }
+ public void postProcessingExecuteBB(DelegateExecution execution) {
+ List<ExecuteBuildingBlock> flowsToExecute =
+ (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ String handlingCode = (String) execution.getVariable("handlingCode");
+ final boolean aLaCarte = (boolean) execution.getVariable(G_ALACARTE);
+ int currentSequence = (int) execution.getVariable(G_CURRENT_SEQUENCE);
+ ExecuteBuildingBlock ebb = flowsToExecute.get(currentSequence - 1);
+ String bbFlowName = ebb.getBuildingBlock().getBpmnFlowName();
+ if (bbFlowName.equalsIgnoreCase("ActivateVfModuleBB") && aLaCarte && handlingCode.equalsIgnoreCase("Success")) {
+ postProcessingExecuteBBActivateVfModule(execution, ebb, flowsToExecute);
+ }
+ }
- public void checkRetryStatus(DelegateExecution execution) {
- String handlingCode = (String) execution.getVariable("handlingCode");
- String requestId = (String) execution.getVariable(G_REQUEST_ID);
- String retryDuration = (String) execution.getVariable("RetryDuration");
- int retryCount = (int) execution.getVariable(RETRY_COUNT);
- int envMaxRetries;
- try{
- envMaxRetries = Integer.parseInt(this.environment.getProperty(maxRetries));
- } catch (Exception ex) {
- logger.error("Could not read maxRetries from config file. Setting max to 5 retries");
- envMaxRetries = 5;
- }
- int nextCount = retryCount +1;
- if (handlingCode.equals("Retry")){
- workflowActionBBFailure.updateRequestErrorStatusMessage(execution);
- try{
- InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId);
- request.setRetryStatusMessage("Retry " + nextCount + "/" + envMaxRetries + " will be started in " + retryDuration);
- requestDbclient.updateInfraActiveRequests(request);
- } catch(Exception ex){
- logger.warn("Failed to update Request Db Infra Active Requests with Retry Status",ex);
- }
- if(retryCount<envMaxRetries){
- int currSequence = (int) execution.getVariable("gCurrentSequence");
- execution.setVariable("gCurrentSequence", currSequence-1);
- execution.setVariable(RETRY_COUNT, nextCount);
- }else{
- workflowAction.buildAndThrowException(execution, "Exceeded maximum retries. Ending flow with status Abort");
- }
- }else{
- execution.setVariable(RETRY_COUNT, 0);
- }
- }
+ protected void postProcessingExecuteBBActivateVfModule(DelegateExecution execution, ExecuteBuildingBlock ebb,
+ List<ExecuteBuildingBlock> flowsToExecute) {
+ try {
+ String serviceInstanceId = ebb.getWorkflowResourceIds().getServiceInstanceId();
+ String vnfId = ebb.getWorkflowResourceIds().getVnfId();
+ String vfModuleId = ebb.getResourceId();
+ ebb.getWorkflowResourceIds().setVfModuleId(vfModuleId);
+ String serviceModelUUID =
+ bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId).getModelVersionId();
+ String vnfCustomizationUUID = bbInputSetupUtils.getAAIGenericVnf(vnfId).getModelCustomizationId();
+ String vfModuleCustomizationUUID =
+ bbInputSetupUtils.getAAIVfModule(vnfId, vfModuleId).getModelCustomizationId();
+ List<Vnfc> vnfcs =
+ workflowAction.getRelatedResourcesInVfModule(vnfId, vfModuleId, Vnfc.class, AAIObjectType.VNFC);
+ logger.debug("Vnfc Size: {}", vnfcs.size());
+ for (Vnfc vnfc : vnfcs) {
+ String modelCustomizationId = vnfc.getModelCustomizationId();
+ logger.debug("Processing Vnfc: {}", modelCustomizationId);
+ CvnfcConfigurationCustomization fabricConfig = catalogDbClient.getCvnfcCustomization(serviceModelUUID,
+ vnfCustomizationUUID, vfModuleCustomizationUUID, modelCustomizationId);
+ if (fabricConfig != null && fabricConfig.getConfigurationResource() != null
+ && fabricConfig.getConfigurationResource().getToscaNodeType() != null
+ && fabricConfig.getConfigurationResource().getToscaNodeType().contains(FABRIC_CONFIGURATION)) {
+ String configurationId = UUID.randomUUID().toString();
+ ConfigurationResourceKeys configurationResourceKeys = new ConfigurationResourceKeys();
+ configurationResourceKeys.setCvnfcCustomizationUUID(modelCustomizationId);
+ configurationResourceKeys.setVfModuleCustomizationUUID(vfModuleCustomizationUUID);
+ configurationResourceKeys.setVnfResourceCustomizationUUID(vnfCustomizationUUID);
+ configurationResourceKeys.setVnfcName(vnfc.getVnfcName());
+ ExecuteBuildingBlock assignConfigBB = getExecuteBBForConfig(ASSIGN_FABRIC_CONFIGURATION_BB, ebb,
+ configurationId, configurationResourceKeys);
+ ExecuteBuildingBlock activateConfigBB = getExecuteBBForConfig(ACTIVATE_FABRIC_CONFIGURATION_BB, ebb,
+ configurationId, configurationResourceKeys);
+ flowsToExecute.add(assignConfigBB);
+ flowsToExecute.add(activateConfigBB);
+ flowsToExecute.stream()
+ .forEach(executeBB -> logger.info("Flows to Execute After Post Processing: {}",
+ executeBB.getBuildingBlock().getBpmnFlowName()));
+ execution.setVariable("flowsToExecute", flowsToExecute);
+ execution.setVariable("completed", false);
+ } else {
+ logger.debug("No cvnfcCustomization found for customizationId: " + modelCustomizationId);
+ }
+ }
+ } catch (EntityNotFoundException e) {
+ logger.debug(e.getMessage() + " Will not be running Fabric Config Building Blocks");
+ } catch (Exception e) {
+ String errorMessage = "Error occurred in post processing of Vf Module create";
+ execution.setVariable("handlingCode", "RollbackToCreated");
+ execution.setVariable("WorkflowActionErrorMessage", errorMessage);
+ logger.error(errorMessage, e);
+ }
+ }
- /**
- * Rollback will only handle Create/Activate/Assign Macro flows. Execute
- * layer will rollback the flow its currently working on.
- */
- public void rollbackExecutionPath(DelegateExecution execution) {
- if(!(boolean)execution.getVariable("isRollback")){
- List<ExecuteBuildingBlock> flowsToExecute = (List<ExecuteBuildingBlock>) execution
- .getVariable("flowsToExecute");
- List<ExecuteBuildingBlock> rollbackFlows = new ArrayList();
- int currentSequence = (int) execution.getVariable(G_CURRENT_SEQUENCE);
- int listSize = flowsToExecute.size();
- for (int i = listSize - 1; i >= 0; i--) {
- if (i > currentSequence - 1) {
- flowsToExecute.remove(i);
- } else {
- String flowName = flowsToExecute.get(i).getBuildingBlock().getBpmnFlowName();
- if (flowName.contains("Assign")) {
- flowName = "Unassign" + flowName.substring(6, flowName.length());
- } else if (flowName.contains("Create")) {
- flowName = "Delete" + flowName.substring(6, flowName.length());
- } else if (flowName.contains("Activate")) {
- flowName = "Deactivate" + flowName.substring(8, flowName.length());
- }else{
- continue;
- }
- flowsToExecute.get(i).getBuildingBlock().setBpmnFlowName(flowName);
- rollbackFlows.add(flowsToExecute.get(i));
- }
- }
-
- String handlingCode = (String) execution.getVariable("handlingCode");
- List<ExecuteBuildingBlock> rollbackFlowsFiltered = new ArrayList<>();
- rollbackFlowsFiltered.addAll(rollbackFlows);
- if(handlingCode.equals("RollbackToAssigned") || handlingCode.equals("RollbackToCreated")){
- for(int i = 0; i<rollbackFlows.size(); i++){
- if(rollbackFlows.get(i).getBuildingBlock().getBpmnFlowName().contains("Unassign")){
- rollbackFlowsFiltered.remove(rollbackFlows.get(i));
- } else if(rollbackFlows.get(i).getBuildingBlock().getBpmnFlowName().contains("Delete") && handlingCode.equals("RollbackToCreated")) {
- rollbackFlowsFiltered.remove(rollbackFlows.get(i));
- }
- }
- }
-
- workflowActionBBFailure.updateRequestErrorStatusMessage(execution);
-
- if (rollbackFlows.isEmpty())
- execution.setVariable("isRollbackNeeded", false);
- else
- execution.setVariable("isRollbackNeeded", true);
- execution.setVariable("flowsToExecute", rollbackFlowsFiltered);
- execution.setVariable("handlingCode", "PreformingRollback");
- execution.setVariable("isRollback", true);
- execution.setVariable("gCurrentSequence", 0);
- execution.setVariable(RETRY_COUNT, 0);
- }else{
- workflowAction.buildAndThrowException(execution, "Rollback has already been called. Cannot rollback a request that is currently in the rollback state.");
- }
- }
-
- protected void updateInstanceId(DelegateExecution execution){
- try{
- String requestId = (String) execution.getVariable(G_REQUEST_ID);
- String resourceId = (String) execution.getVariable("resourceId");
- WorkflowType resourceType = (WorkflowType) execution.getVariable("resourceType");
- InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId);
- if(resourceType == WorkflowType.SERVICE){
- request.setServiceInstanceId(resourceId);
- }else if(resourceType == WorkflowType.VNF){
- request.setVnfId(resourceId);
- }else if(resourceType == WorkflowType.VFMODULE){
- request.setVfModuleId(resourceId);
- }else if(resourceType == WorkflowType.VOLUMEGROUP){
- request.setVolumeGroupId(resourceId);
- }else if(resourceType == WorkflowType.NETWORK){
- request.setNetworkId(resourceId);
- }else if(resourceType == WorkflowType.CONFIGURATION){
- request.setConfigurationId(resourceId);
- }else if(resourceType == WorkflowType.INSTANCE_GROUP){
- request.setInstanceGroupId(resourceId);
- }
- requestDbclient.updateInfraActiveRequests(request);
- }catch(Exception ex){
- workflowAction.buildAndThrowException(execution, "Failed to update Request db with instanceId");
- }
- }
-
- public void postProcessingExecuteBB(DelegateExecution execution) {
- List<ExecuteBuildingBlock> flowsToExecute = (List<ExecuteBuildingBlock>) execution
- .getVariable("flowsToExecute");
- String handlingCode = (String) execution.getVariable("handlingCode");
- final boolean aLaCarte = (boolean) execution.getVariable(G_ALACARTE);
- int currentSequence = (int) execution.getVariable(G_CURRENT_SEQUENCE);
- ExecuteBuildingBlock ebb = flowsToExecute.get(currentSequence - 1);
- String bbFlowName = ebb.getBuildingBlock().getBpmnFlowName();
- if(bbFlowName.equalsIgnoreCase("ActivateVfModuleBB") && aLaCarte && handlingCode.equalsIgnoreCase("Success")) {
- postProcessingExecuteBBActivateVfModule(execution, ebb, flowsToExecute);
- }
- }
-
- protected void postProcessingExecuteBBActivateVfModule(DelegateExecution execution,
- ExecuteBuildingBlock ebb, List<ExecuteBuildingBlock> flowsToExecute) {
- try {
- String serviceInstanceId = ebb.getWorkflowResourceIds().getServiceInstanceId();
- String vnfId = ebb.getWorkflowResourceIds().getVnfId();
- String vfModuleId = ebb.getResourceId();
- ebb.getWorkflowResourceIds().setVfModuleId(vfModuleId);
- String serviceModelUUID = bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId).getModelVersionId();
- String vnfCustomizationUUID = bbInputSetupUtils.getAAIGenericVnf(vnfId).getModelCustomizationId();
- String vfModuleCustomizationUUID = bbInputSetupUtils.getAAIVfModule(vnfId, vfModuleId).getModelCustomizationId();
- List<Vnfc> vnfcs = workflowAction.getRelatedResourcesInVfModule(vnfId, vfModuleId, Vnfc.class, AAIObjectType.VNFC);
- logger.debug("Vnfc Size: {}", vnfcs.size());
- for(Vnfc vnfc : vnfcs) {
- String modelCustomizationId = vnfc.getModelCustomizationId();
- logger.debug("Processing Vnfc: {}", modelCustomizationId);
- CvnfcConfigurationCustomization fabricConfig =
- catalogDbClient.getCvnfcCustomization(serviceModelUUID,vnfCustomizationUUID,
- vfModuleCustomizationUUID, modelCustomizationId);
- if(fabricConfig != null && fabricConfig.getConfigurationResource() != null
- && fabricConfig.getConfigurationResource().getToscaNodeType() != null
- && fabricConfig.getConfigurationResource().getToscaNodeType().contains(FABRIC_CONFIGURATION)) {
- String configurationId = UUID.randomUUID().toString();
- ConfigurationResourceKeys configurationResourceKeys = new ConfigurationResourceKeys();
- configurationResourceKeys.setCvnfcCustomizationUUID(modelCustomizationId);
- configurationResourceKeys.setVfModuleCustomizationUUID(vfModuleCustomizationUUID);
- configurationResourceKeys.setVnfResourceCustomizationUUID(vnfCustomizationUUID);
- configurationResourceKeys.setVnfcName(vnfc.getVnfcName());
- ExecuteBuildingBlock assignConfigBB = getExecuteBBForConfig(ASSIGN_FABRIC_CONFIGURATION_BB, ebb, configurationId, configurationResourceKeys);
- ExecuteBuildingBlock activateConfigBB = getExecuteBBForConfig(ACTIVATE_FABRIC_CONFIGURATION_BB, ebb, configurationId, configurationResourceKeys);
- flowsToExecute.add(assignConfigBB);
- flowsToExecute.add(activateConfigBB);
- flowsToExecute.stream().forEach(executeBB -> logger.info("Flows to Execute After Post Processing: {}", executeBB.getBuildingBlock().getBpmnFlowName()));
- execution.setVariable("flowsToExecute", flowsToExecute);
- execution.setVariable("completed", false);
- } else {
- logger.debug("No cvnfcCustomization found for customizationId: " + modelCustomizationId);
- }
- }
- } catch (EntityNotFoundException e) {
- logger.debug(e.getMessage() + " Will not be running Fabric Config Building Blocks");
- } catch (Exception e) {
- String errorMessage = "Error occurred in post processing of Vf Module create";
- execution.setVariable("handlingCode", "RollbackToCreated");
- execution.setVariable("WorkflowActionErrorMessage", errorMessage);
- logger.error(errorMessage, e);
- }
- }
-
- protected ExecuteBuildingBlock getExecuteBBForConfig(String bbName, ExecuteBuildingBlock ebb, String configurationId, ConfigurationResourceKeys configurationResourceKeys) {
- ExecuteBuildingBlock configBB = new ExecuteBuildingBlock();
- BuildingBlock buildingBlock = new BuildingBlock();
- buildingBlock.setBpmnFlowName(bbName);
- buildingBlock.setMsoId(UUID.randomUUID().toString());
- configBB.setaLaCarte(ebb.isaLaCarte());
- configBB.setApiVersion(ebb.getApiVersion());
- configBB.setRequestAction(ebb.getRequestAction());
- configBB.setVnfType(ebb.getVnfType());
- configBB.setRequestId(ebb.getRequestId());
- configBB.setRequestDetails(ebb.getRequestDetails());
- configBB.setBuildingBlock(buildingBlock);
- WorkflowResourceIds workflowResourceIds = ebb.getWorkflowResourceIds();
- workflowResourceIds.setConfigurationId(configurationId);
- configBB.setWorkflowResourceIds(workflowResourceIds);
- configBB.setConfigurationResourceKeys(configurationResourceKeys);
- return configBB;
- }
+ protected ExecuteBuildingBlock getExecuteBBForConfig(String bbName, ExecuteBuildingBlock ebb,
+ String configurationId, ConfigurationResourceKeys configurationResourceKeys) {
+ ExecuteBuildingBlock configBB = new ExecuteBuildingBlock();
+ BuildingBlock buildingBlock = new BuildingBlock();
+ buildingBlock.setBpmnFlowName(bbName);
+ buildingBlock.setMsoId(UUID.randomUUID().toString());
+ configBB.setaLaCarte(ebb.isaLaCarte());
+ configBB.setApiVersion(ebb.getApiVersion());
+ configBB.setRequestAction(ebb.getRequestAction());
+ configBB.setVnfType(ebb.getVnfType());
+ configBB.setRequestId(ebb.getRequestId());
+ configBB.setRequestDetails(ebb.getRequestDetails());
+ configBB.setBuildingBlock(buildingBlock);
+ WorkflowResourceIds workflowResourceIds = ebb.getWorkflowResourceIds();
+ workflowResourceIds.setConfigurationId(configurationId);
+ configBB.setWorkflowResourceIds(workflowResourceIds);
+ configBB.setConfigurationResourceKeys(configurationResourceKeys);
+ return configBB;
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAI.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAI.java
index 2b0f8bf946..99ae2e7495 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAI.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAI.java
@@ -22,7 +22,6 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks;
import java.util.List;
import java.util.Optional;
-
import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
import org.onap.so.client.aai.AAIObjectType;
import org.onap.so.client.aai.entities.AAIResultWrapper;
@@ -33,26 +32,26 @@ import org.springframework.stereotype.Component;
@Component
public class WorkflowActionExtractResourcesAAI {
- private static final Logger logger = LoggerFactory.getLogger(WorkflowActionExtractResourcesAAI.class);
+ private static final Logger logger = LoggerFactory.getLogger(WorkflowActionExtractResourcesAAI.class);
- public Optional<Configuration> extractRelationshipsConfiguration(Relationships relationships) {
- List<AAIResultWrapper> configurations = relationships.getByType(AAIObjectType.CONFIGURATION);
- for(AAIResultWrapper configWrapper : configurations) {
- Optional<Configuration> config = configWrapper.asBean(Configuration.class);
- if(config.isPresent()){
- return config;
- }
- }
- return Optional.empty();
- }
+ public Optional<Configuration> extractRelationshipsConfiguration(Relationships relationships) {
+ List<AAIResultWrapper> configurations = relationships.getByType(AAIObjectType.CONFIGURATION);
+ for (AAIResultWrapper configWrapper : configurations) {
+ Optional<Configuration> config = configWrapper.asBean(Configuration.class);
+ if (config.isPresent()) {
+ return config;
+ }
+ }
+ return Optional.empty();
+ }
- public Optional<Relationships> extractRelationshipsVnfc(Relationships relationships) {
- List<AAIResultWrapper> vnfcs = relationships.getByType(AAIObjectType.VNFC);
- for(AAIResultWrapper vnfcWrapper : vnfcs){
- if(vnfcWrapper.getRelationships().isPresent()){
- return vnfcWrapper.getRelationships();
- }
- }
- return Optional.empty();
- }
+ public Optional<Relationships> extractRelationshipsVnfc(Relationships relationships) {
+ List<AAIResultWrapper> vnfcs = relationships.getByType(AAIObjectType.VNFC);
+ for (AAIResultWrapper vnfcWrapper : vnfcs) {
+ if (vnfcWrapper.getRelationships().isPresent()) {
+ return vnfcWrapper.getRelationships();
+ }
+ }
+ return Optional.empty();
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowType.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowType.java
index 304b4000bd..af8f93b92b 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowType.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowType.java
@@ -22,33 +22,27 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks;
public enum WorkflowType {
- SERVICE("Service"),
- VNF("Vnf"),
- VFMODULE("VfModule"),
- VOLUMEGROUP("VolumeGroup"),
- NETWORK("Network"),
- VIRTUAL_LINK("VirtualLink"),
- NETWORKCOLLECTION("NetworkCollection"),
- CONFIGURATION("Configuration"),
- INSTANCE_GROUP("InstanceGroup");
-
- private final String type;
-
- private WorkflowType (String type){
- this.type = type;
- }
-
- @Override
- public String toString() {
- return this.type;
- }
-
- public static WorkflowType fromString (String text){
- for (WorkflowType x : WorkflowType.values()) {
- if (x.type.equalsIgnoreCase(text)) {
- return x;
- }
- }
- return null;
- }
+ SERVICE("Service"), VNF("Vnf"), VFMODULE("VfModule"), VOLUMEGROUP("VolumeGroup"), NETWORK("Network"), VIRTUAL_LINK(
+ "VirtualLink"), NETWORKCOLLECTION(
+ "NetworkCollection"), CONFIGURATION("Configuration"), INSTANCE_GROUP("InstanceGroup");
+
+ private final String type;
+
+ private WorkflowType(String type) {
+ this.type = type;
+ }
+
+ @Override
+ public String toString() {
+ return this.type;
+ }
+
+ public static WorkflowType fromString(String text) {
+ for (WorkflowType x : WorkflowType.values()) {
+ if (x.type.equalsIgnoreCase(text)) {
+ return x;
+ }
+ }
+ return null;
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/sdno/tasks/SDNOHealthCheckTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/sdno/tasks/SDNOHealthCheckTasks.java
index c0f7b21a9e..adfeb5ac6a 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/sdno/tasks/SDNOHealthCheckTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/sdno/tasks/SDNOHealthCheckTasks.java
@@ -23,7 +23,6 @@
package org.onap.so.bpmn.sdno.tasks;
import java.util.Map;
-
import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
@@ -39,38 +38,37 @@ import org.springframework.stereotype.Component;
@Component
public class SDNOHealthCheckTasks {
- private static final Logger logger = LoggerFactory.getLogger(SDNOHealthCheckTasks.class);
- @Autowired
- private ExceptionBuilder exceptionUtil;
- @Autowired
- private ExtractPojosForBB extractPojosForBB;
- @Autowired
- private SDNOHealthCheckResources sdnoHealthCheckResources;
-
- public void sdnoHealthCheck(BuildingBlockExecution execution) {
- boolean response = false;
- try {
- GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
- RequestContext requestContext = gBBInput.getRequestContext();
-
- GenericVnf vnf = null;
- Map<ResourceKey, String> lookupMap = execution.getLookupMap();
- for (Map.Entry<ResourceKey, String> entry : lookupMap.entrySet()) {
- if (entry.getKey().equals(ResourceKey.GENERIC_VNF_ID)) {
- vnf = extractPojosForBB.extractByKey(execution, entry.getKey());
- }
- }
-
- response = sdnoHealthCheckResources.healthCheck(vnf, requestContext);
- }
- catch (Exception ex) {
- logger.error("Exception occurred", ex);
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex.getMessage());
- }
-
- if (!response) {
- logger.error("SDNO Health Check failed");
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "SDNO Health Check failed");
- }
- }
+ private static final Logger logger = LoggerFactory.getLogger(SDNOHealthCheckTasks.class);
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+ @Autowired
+ private ExtractPojosForBB extractPojosForBB;
+ @Autowired
+ private SDNOHealthCheckResources sdnoHealthCheckResources;
+
+ public void sdnoHealthCheck(BuildingBlockExecution execution) {
+ boolean response = false;
+ try {
+ GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+ RequestContext requestContext = gBBInput.getRequestContext();
+
+ GenericVnf vnf = null;
+ Map<ResourceKey, String> lookupMap = execution.getLookupMap();
+ for (Map.Entry<ResourceKey, String> entry : lookupMap.entrySet()) {
+ if (entry.getKey().equals(ResourceKey.GENERIC_VNF_ID)) {
+ vnf = extractPojosForBB.extractByKey(execution, entry.getKey());
+ }
+ }
+
+ response = sdnoHealthCheckResources.healthCheck(vnf, requestContext);
+ } catch (Exception ex) {
+ logger.error("Exception occurred", ex);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex.getMessage());
+ }
+
+ if (!response) {
+ logger.error("SDNO Health Check failed");
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "SDNO Health Check failed");
+ }
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java
index 518da1fa5f..06f6550d51 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java
@@ -25,7 +25,6 @@ import org.modelmapper.PropertyMap;
import org.onap.aai.domain.yang.RouteTargets;
import org.onap.so.bpmn.servicedecomposition.bbobjects.*;
import org.springframework.stereotype.Component;
-
import java.util.List;
import org.modelmapper.Converter;
import org.modelmapper.spi.MappingContext;
@@ -36,277 +35,287 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet;
@Component
public class AAIObjectMapper {
- private static final ModelMapper modelMapper = new ModelMapper();
-
- public org.onap.aai.domain.yang.ServiceInstance mapServiceInstance (ServiceInstance serviceInstance){
- if (modelMapper.getTypeMap(ServiceInstance.class, org.onap.aai.domain.yang.ServiceInstance.class) == null) {
- modelMapper.addMappings(new PropertyMap<ServiceInstance, org.onap.aai.domain.yang.ServiceInstance>(){
- @Override
- protected void configure() {
- map().setServiceType(source.getModelInfoServiceInstance().getServiceType());
- map().setServiceRole(source.getModelInfoServiceInstance().getServiceRole());
- map().setModelInvariantId(source.getModelInfoServiceInstance().getModelInvariantUuid());
- map().setModelVersionId(source.getModelInfoServiceInstance().getModelUuid());
- map().setEnvironmentContext(source.getModelInfoServiceInstance().getEnvironmentContext());
- map().setWorkloadContext(source.getModelInfoServiceInstance().getWorkloadContext());
- }
- });
- }
-
- return modelMapper.map(serviceInstance,org.onap.aai.domain.yang.ServiceInstance.class);
- }
-
- public org.onap.aai.domain.yang.Project mapProject (Project project){
- return modelMapper.map(project,org.onap.aai.domain.yang.Project.class);
- }
-
- public org.onap.aai.domain.yang.ServiceSubscription mapServiceSubscription(ServiceSubscription serviceSubscription){
- return modelMapper.map(serviceSubscription,org.onap.aai.domain.yang.ServiceSubscription.class);
+ private static final ModelMapper modelMapper = new ModelMapper();
+
+ public org.onap.aai.domain.yang.ServiceInstance mapServiceInstance(ServiceInstance serviceInstance) {
+ if (modelMapper.getTypeMap(ServiceInstance.class, org.onap.aai.domain.yang.ServiceInstance.class) == null) {
+ modelMapper.addMappings(new PropertyMap<ServiceInstance, org.onap.aai.domain.yang.ServiceInstance>() {
+ @Override
+ protected void configure() {
+ map().setServiceType(source.getModelInfoServiceInstance().getServiceType());
+ map().setServiceRole(source.getModelInfoServiceInstance().getServiceRole());
+ map().setModelInvariantId(source.getModelInfoServiceInstance().getModelInvariantUuid());
+ map().setModelVersionId(source.getModelInfoServiceInstance().getModelUuid());
+ map().setEnvironmentContext(source.getModelInfoServiceInstance().getEnvironmentContext());
+ map().setWorkloadContext(source.getModelInfoServiceInstance().getWorkloadContext());
+ }
+ });
+ }
+
+ return modelMapper.map(serviceInstance, org.onap.aai.domain.yang.ServiceInstance.class);
+ }
+
+ public org.onap.aai.domain.yang.Project mapProject(Project project) {
+ return modelMapper.map(project, org.onap.aai.domain.yang.Project.class);
+ }
+
+ public org.onap.aai.domain.yang.ServiceSubscription mapServiceSubscription(
+ ServiceSubscription serviceSubscription) {
+ return modelMapper.map(serviceSubscription, org.onap.aai.domain.yang.ServiceSubscription.class);
+ }
+
+ public org.onap.aai.domain.yang.OwningEntity mapOwningEntity(OwningEntity owningEntity) {
+ return modelMapper.map(owningEntity, org.onap.aai.domain.yang.OwningEntity.class);
+ }
+
+ public org.onap.aai.domain.yang.GenericVnf mapVnf(GenericVnf vnf) {
+ if (modelMapper.getTypeMap(GenericVnf.class, org.onap.aai.domain.yang.GenericVnf.class) == null) {
+ modelMapper.addMappings(new PropertyMap<GenericVnf, org.onap.aai.domain.yang.GenericVnf>() {
+ @Override
+ protected void configure() {
+ map().setModelCustomizationId(source.getModelInfoGenericVnf().getModelCustomizationUuid());
+ map().setModelInvariantId(source.getModelInfoGenericVnf().getModelInvariantUuid());
+ map().setModelVersionId(source.getModelInfoGenericVnf().getModelUuid());
+ map().setNfRole(source.getModelInfoGenericVnf().getNfRole());
+ map().setNfType(source.getModelInfoGenericVnf().getNfType());
+ map().setNfFunction(source.getModelInfoGenericVnf().getNfFunction());
+ map().setNfNamingCode(source.getModelInfoGenericVnf().getNfNamingCode());
+ }
+ });
+ }
+
+ return modelMapper.map(vnf, org.onap.aai.domain.yang.GenericVnf.class);
}
- public org.onap.aai.domain.yang.OwningEntity mapOwningEntity (OwningEntity owningEntity){
- return modelMapper.map(owningEntity,org.onap.aai.domain.yang.OwningEntity.class);
- }
-
- public org.onap.aai.domain.yang.GenericVnf mapVnf (GenericVnf vnf){
- if (modelMapper.getTypeMap(GenericVnf.class, org.onap.aai.domain.yang.GenericVnf.class) == null) {
- modelMapper.addMappings(new PropertyMap<GenericVnf, org.onap.aai.domain.yang.GenericVnf>(){
- @Override
- protected void configure() {
- map().setModelCustomizationId(source.getModelInfoGenericVnf().getModelCustomizationUuid());
- map().setModelInvariantId(source.getModelInfoGenericVnf().getModelInvariantUuid());
- map().setModelVersionId(source.getModelInfoGenericVnf().getModelUuid());
- map().setNfRole(source.getModelInfoGenericVnf().getNfRole());
- map().setNfType(source.getModelInfoGenericVnf().getNfType());
- map().setNfFunction(source.getModelInfoGenericVnf().getNfFunction());
- map().setNfNamingCode(source.getModelInfoGenericVnf().getNfNamingCode());
- }
- });
- }
-
- return modelMapper.map(vnf, org.onap.aai.domain.yang.GenericVnf.class);
- }
-
- public org.onap.aai.domain.yang.VfModule mapVfModule (VfModule vfModule){
- if (modelMapper.getTypeMap(VfModule.class, org.onap.aai.domain.yang.VfModule.class) == null) {
- modelMapper.addMappings(new PropertyMap<VfModule, org.onap.aai.domain.yang.VfModule>(){
- @Override
- protected void configure() {
- map().setModelCustomizationId(source.getModelInfoVfModule().getModelCustomizationUUID());
- map().setModelInvariantId(source.getModelInfoVfModule().getModelInvariantUUID());
- map().setModelVersionId(source.getModelInfoVfModule().getModelUUID());
- map().setPersonaModelVersion(source.getModelInfoVfModule().getModelInvariantUUID());
- map().setIsBaseVfModule(source.getModelInfoVfModule().getIsBaseBoolean());
-
- }
- });
- }
-
- return modelMapper.map(vfModule, org.onap.aai.domain.yang.VfModule.class);
- }
-
- public org.onap.aai.domain.yang.VolumeGroup mapVolumeGroup(VolumeGroup volumeGroup) {
- if (modelMapper.getTypeMap(VolumeGroup.class, org.onap.aai.domain.yang.VolumeGroup.class) == null) {
- modelMapper.addMappings(new PropertyMap<VolumeGroup, org.onap.aai.domain.yang.VolumeGroup>(){
- @Override
- protected void configure() {
- map().setModelCustomizationId(source.getModelInfoVfModule().getModelCustomizationUUID());
- map().setVfModuleModelCustomizationId(source.getModelInfoVfModule().getModelCustomizationUUID());
- }
- });
- }
- return modelMapper.map(volumeGroup, org.onap.aai.domain.yang.VolumeGroup.class);
- }
-
- public org.onap.aai.domain.yang.L3Network mapNetwork (L3Network l3Network){
- if (modelMapper.getTypeMap(L3Network.class, org.onap.aai.domain.yang.L3Network.class) == null) {
- modelMapper.addMappings(new PropertyMap<L3Network, org.onap.aai.domain.yang.L3Network>(){
- @Override
- protected void configure() {
- map().setModelCustomizationId(source.getModelInfoNetwork().getModelCustomizationUUID());
- map().setModelInvariantId(source.getModelInfoNetwork().getModelInvariantUUID());
- map().setModelVersionId(source.getModelInfoNetwork().getModelUUID());
- map().setNetworkType(source.getModelInfoNetwork().getNetworkType());
- map().setNetworkRole(source.getModelInfoNetwork().getNetworkRole());
- map().setNetworkTechnology(source.getModelInfoNetwork().getNetworkTechnology());
- modelMapper.addConverter(convertSubnets);
- modelMapper.addConverter(convertCtagAssignments);
- modelMapper.addConverter(convertSegmentationAssignments);
- }
- });
- }
- return modelMapper.map(l3Network, org.onap.aai.domain.yang.L3Network.class);
- }
-
- public org.onap.aai.domain.yang.InstanceGroup mapInstanceGroup(InstanceGroup instanceGroup) {
- if (modelMapper.getTypeMap(InstanceGroup.class, org.onap.aai.domain.yang.InstanceGroup.class) == null) {
- modelMapper.addMappings(new PropertyMap<InstanceGroup, org.onap.aai.domain.yang.InstanceGroup>(){
- @Override
- protected void configure() {
- map().setInstanceGroupRole(source.getModelInfoInstanceGroup().getInstanceGroupRole());
- map().setModelInvariantId(source.getModelInfoInstanceGroup().getModelInvariantUUID());
- map().setModelVersionId(source.getModelInfoInstanceGroup().getModelUUID());
- map().setInstanceGroupType(source.getModelInfoInstanceGroup().getType());
- map().setDescription(source.getModelInfoInstanceGroup().getDescription());
- map().setInstanceGroupFunction(source.getModelInfoInstanceGroup().getFunction());
- }
- });
- }
- return modelMapper.map(instanceGroup, org.onap.aai.domain.yang.InstanceGroup.class);
- }
-
- public org.onap.aai.domain.yang.Customer mapCustomer(Customer customer) {
- return modelMapper.map(customer, org.onap.aai.domain.yang.Customer.class);
- }
-
- private Converter<List<Subnet>, org.onap.aai.domain.yang.Subnets> convertSubnets = new Converter<List<Subnet>, org.onap.aai.domain.yang.Subnets>() {
- public org.onap.aai.domain.yang.Subnets convert(MappingContext<List<Subnet>, org.onap.aai.domain.yang.Subnets> context) {
- return mapToAAISubNets(context.getSource());
+ public org.onap.aai.domain.yang.VfModule mapVfModule(VfModule vfModule) {
+ if (modelMapper.getTypeMap(VfModule.class, org.onap.aai.domain.yang.VfModule.class) == null) {
+ modelMapper.addMappings(new PropertyMap<VfModule, org.onap.aai.domain.yang.VfModule>() {
+ @Override
+ protected void configure() {
+ map().setModelCustomizationId(source.getModelInfoVfModule().getModelCustomizationUUID());
+ map().setModelInvariantId(source.getModelInfoVfModule().getModelInvariantUUID());
+ map().setModelVersionId(source.getModelInfoVfModule().getModelUUID());
+ map().setPersonaModelVersion(source.getModelInfoVfModule().getModelInvariantUUID());
+ map().setIsBaseVfModule(source.getModelInfoVfModule().getIsBaseBoolean());
+
+ }
+ });
}
- };
- private Converter<List<CtagAssignment>, org.onap.aai.domain.yang.CtagAssignments> convertCtagAssignments = new Converter<List<CtagAssignment>, org.onap.aai.domain.yang.CtagAssignments>() {
- public org.onap.aai.domain.yang.CtagAssignments convert(MappingContext<List<CtagAssignment>, org.onap.aai.domain.yang.CtagAssignments> context) {
- return mapToAAICtagAssignmentList(context.getSource());
+ return modelMapper.map(vfModule, org.onap.aai.domain.yang.VfModule.class);
+ }
+
+ public org.onap.aai.domain.yang.VolumeGroup mapVolumeGroup(VolumeGroup volumeGroup) {
+ if (modelMapper.getTypeMap(VolumeGroup.class, org.onap.aai.domain.yang.VolumeGroup.class) == null) {
+ modelMapper.addMappings(new PropertyMap<VolumeGroup, org.onap.aai.domain.yang.VolumeGroup>() {
+ @Override
+ protected void configure() {
+ map().setModelCustomizationId(source.getModelInfoVfModule().getModelCustomizationUUID());
+ map().setVfModuleModelCustomizationId(source.getModelInfoVfModule().getModelCustomizationUUID());
+ }
+ });
}
- };
+ return modelMapper.map(volumeGroup, org.onap.aai.domain.yang.VolumeGroup.class);
+ }
+
+ public org.onap.aai.domain.yang.L3Network mapNetwork(L3Network l3Network) {
+ if (modelMapper.getTypeMap(L3Network.class, org.onap.aai.domain.yang.L3Network.class) == null) {
+ modelMapper.addMappings(new PropertyMap<L3Network, org.onap.aai.domain.yang.L3Network>() {
+ @Override
+ protected void configure() {
+ map().setModelCustomizationId(source.getModelInfoNetwork().getModelCustomizationUUID());
+ map().setModelInvariantId(source.getModelInfoNetwork().getModelInvariantUUID());
+ map().setModelVersionId(source.getModelInfoNetwork().getModelUUID());
+ map().setNetworkType(source.getModelInfoNetwork().getNetworkType());
+ map().setNetworkRole(source.getModelInfoNetwork().getNetworkRole());
+ map().setNetworkTechnology(source.getModelInfoNetwork().getNetworkTechnology());
+ modelMapper.addConverter(convertSubnets);
+ modelMapper.addConverter(convertCtagAssignments);
+ modelMapper.addConverter(convertSegmentationAssignments);
+ }
+ });
+ }
+ return modelMapper.map(l3Network, org.onap.aai.domain.yang.L3Network.class);
+ }
- private Converter<List<SegmentationAssignment>, org.onap.aai.domain.yang.SegmentationAssignments> convertSegmentationAssignments = new Converter<List<SegmentationAssignment>, org.onap.aai.domain.yang.SegmentationAssignments>() {
- public org.onap.aai.domain.yang.SegmentationAssignments convert(MappingContext<List<SegmentationAssignment>, org.onap.aai.domain.yang.SegmentationAssignments> context) {
- return mapToAAISegmentationAssignmentList(context.getSource());
+ public org.onap.aai.domain.yang.InstanceGroup mapInstanceGroup(InstanceGroup instanceGroup) {
+ if (modelMapper.getTypeMap(InstanceGroup.class, org.onap.aai.domain.yang.InstanceGroup.class) == null) {
+ modelMapper.addMappings(new PropertyMap<InstanceGroup, org.onap.aai.domain.yang.InstanceGroup>() {
+ @Override
+ protected void configure() {
+ map().setInstanceGroupRole(source.getModelInfoInstanceGroup().getInstanceGroupRole());
+ map().setModelInvariantId(source.getModelInfoInstanceGroup().getModelInvariantUUID());
+ map().setModelVersionId(source.getModelInfoInstanceGroup().getModelUUID());
+ map().setInstanceGroupType(source.getModelInfoInstanceGroup().getType());
+ map().setDescription(source.getModelInfoInstanceGroup().getDescription());
+ map().setInstanceGroupFunction(source.getModelInfoInstanceGroup().getFunction());
+ }
+ });
}
- };
-
- public org.onap.aai.domain.yang.Subnets mapToAAISubNets(List<Subnet> subnetList) {
- org.onap.aai.domain.yang.Subnets subnets = null;
-
- if (!subnetList.isEmpty()) {
- subnets = new org.onap.aai.domain.yang.Subnets();
- org.onap.aai.domain.yang.Subnet subnet = null;
- for (Subnet subnetSource : subnetList) {
- subnet = new org.onap.aai.domain.yang.Subnet();
- subnet.setSubnetId(subnetSource.getSubnetId());
- subnet.setSubnetName(subnetSource.getSubnetName());
- subnet.setNeutronSubnetId(subnetSource.getNeutronSubnetId());
- subnet.setGatewayAddress(subnetSource.getGatewayAddress());
- subnet.setCidrMask(subnetSource.getCidrMask());
- subnet.setIpVersion(subnetSource.getIpVersion());
- subnet.setOrchestrationStatus(subnetSource.getOrchestrationStatus().toString());
- subnet.setCidrMask(subnetSource.getCidrMask());
- subnet.setDhcpEnabled(subnetSource.isDhcpEnabled());
- subnet.setDhcpStart(subnetSource.getDhcpStart());
- subnet.setDhcpEnd(subnetSource.getDhcpEnd());
- subnet.setSubnetRole(subnetSource.getSubnetRole());
- subnet.setIpAssignmentDirection(subnetSource.getIpAssignmentDirection());
- subnet.setSubnetSequence(subnetSource.getSubnetSequence());
-
- org.onap.aai.domain.yang.HostRoutes hostRoutes = new org.onap.aai.domain.yang.HostRoutes();
- org.onap.aai.domain.yang.HostRoute hostRoute = null;
- for (HostRoute hostRouteSource : subnetSource.getHostRoutes()) {
- hostRoute = new org.onap.aai.domain.yang.HostRoute();
- hostRoute.setHostRouteId(hostRouteSource.getHostRouteId());
- hostRoute.setRoutePrefix(hostRouteSource.getRoutePrefix());
- hostRoute.setNextHop(hostRouteSource.getNextHop());
- hostRoute.setNextHopType(hostRouteSource.getNextHopType());
- hostRoutes.getHostRoute().add(hostRoute);
- }
- subnet.setHostRoutes(hostRoutes);
- subnets.getSubnet().add(subnet);
- }
- }
- return subnets;
- }
-
- public org.onap.aai.domain.yang.CtagAssignments mapToAAICtagAssignmentList(List<CtagAssignment> ctagAssignmentsList) {
- org.onap.aai.domain.yang.CtagAssignments ctagAssignments = null;
- if (!ctagAssignmentsList.isEmpty()) {
- ctagAssignments = new org.onap.aai.domain.yang.CtagAssignments();
-
- org.onap.aai.domain.yang.CtagAssignment ctagAssignment = null;
- for (CtagAssignment ctagAssignmentSource : ctagAssignmentsList) {
- ctagAssignment = new org.onap.aai.domain.yang.CtagAssignment();
- ctagAssignment.setVlanIdInner(ctagAssignmentSource.getVlanIdInner());
- ctagAssignments.getCtagAssignment().add(ctagAssignment);
- }
- }
- return ctagAssignments;
- }
-
- public org.onap.aai.domain.yang.SegmentationAssignments mapToAAISegmentationAssignmentList(List<SegmentationAssignment> segmentationAssignmentList) {
- org.onap.aai.domain.yang.SegmentationAssignments segmentationAssignments = null;
- if (!segmentationAssignmentList.isEmpty()) {
- segmentationAssignments = new org.onap.aai.domain.yang.SegmentationAssignments();
- org.onap.aai.domain.yang.SegmentationAssignment segmentationAssignment = null;
- for (SegmentationAssignment segmentationAssignmentSource : segmentationAssignmentList) {
- segmentationAssignment = new org.onap.aai.domain.yang.SegmentationAssignment();
- segmentationAssignment.setSegmentationId(segmentationAssignmentSource.getSegmentationId());
- segmentationAssignments.getSegmentationAssignment().add(segmentationAssignment);
- }
- }
- return segmentationAssignments;
- }
-
- public org.onap.aai.domain.yang.Configuration mapConfiguration(Configuration configuration) {
- if (null == modelMapper.getTypeMap(Configuration.class, org.onap.aai.domain.yang.Configuration.class)) {
- modelMapper.addMappings(new PropertyMap<Configuration, org.onap.aai.domain.yang.Configuration>(){
- @Override
- protected void configure() {
- map().setModelCustomizationId(source.getModelInfoConfiguration().getModelCustomizationId());
- map().setModelVersionId(source.getModelInfoConfiguration().getModelVersionId());
- map().setModelInvariantId(source.getModelInfoConfiguration().getModelInvariantId());
- map().setConfigurationType(source.getModelInfoConfiguration().getConfigurationType());
- map().setConfigurationSubType(source.getModelInfoConfiguration().getConfigurationRole());
- map().setConfigPolicyName(source.getModelInfoConfiguration().getPolicyName());
- }
- });
- }
- return modelMapper.map(configuration, org.onap.aai.domain.yang.Configuration.class);
- }
-
- public org.onap.aai.domain.yang.Collection mapCollection (Collection networkCollection){
- if (modelMapper.getTypeMap(Collection.class, org.onap.aai.domain.yang.Collection.class) == null) {
- modelMapper.addMappings(new PropertyMap<Collection, org.onap.aai.domain.yang.Collection>(){
- @Override
- protected void configure() {
- map().setModelInvariantId(source.getModelInfoCollection().getModelInvariantUUID());
- map().setModelVersionId(source.getModelInfoCollection().getModelVersionId());
- map().setCollectionCustomizationId(source.getModelInfoCollection().getModelCustomizationUUID());
- map().setCollectionFunction(source.getModelInfoCollection().getCollectionFunction());
- map().setCollectionRole(source.getModelInfoCollection().getCollectionRole());
- map().setCollectionType(source.getModelInfoCollection().getCollectionType());
- map().setCollectionName(source.getName());
- }
- });
- }
- return modelMapper.map(networkCollection, org.onap.aai.domain.yang.Collection.class);
- }
+ return modelMapper.map(instanceGroup, org.onap.aai.domain.yang.InstanceGroup.class);
+ }
+
+ public org.onap.aai.domain.yang.Customer mapCustomer(Customer customer) {
+ return modelMapper.map(customer, org.onap.aai.domain.yang.Customer.class);
+ }
+
+ private Converter<List<Subnet>, org.onap.aai.domain.yang.Subnets> convertSubnets =
+ new Converter<List<Subnet>, org.onap.aai.domain.yang.Subnets>() {
+ public org.onap.aai.domain.yang.Subnets convert(
+ MappingContext<List<Subnet>, org.onap.aai.domain.yang.Subnets> context) {
+ return mapToAAISubNets(context.getSource());
+ }
+ };
+
+ private Converter<List<CtagAssignment>, org.onap.aai.domain.yang.CtagAssignments> convertCtagAssignments =
+ new Converter<List<CtagAssignment>, org.onap.aai.domain.yang.CtagAssignments>() {
+ public org.onap.aai.domain.yang.CtagAssignments convert(
+ MappingContext<List<CtagAssignment>, org.onap.aai.domain.yang.CtagAssignments> context) {
+ return mapToAAICtagAssignmentList(context.getSource());
+ }
+ };
+
+ private Converter<List<SegmentationAssignment>, org.onap.aai.domain.yang.SegmentationAssignments> convertSegmentationAssignments =
+ new Converter<List<SegmentationAssignment>, org.onap.aai.domain.yang.SegmentationAssignments>() {
+ public org.onap.aai.domain.yang.SegmentationAssignments convert(
+ MappingContext<List<SegmentationAssignment>, org.onap.aai.domain.yang.SegmentationAssignments> context) {
+ return mapToAAISegmentationAssignmentList(context.getSource());
+ }
+ };
+
+ public org.onap.aai.domain.yang.Subnets mapToAAISubNets(List<Subnet> subnetList) {
+ org.onap.aai.domain.yang.Subnets subnets = null;
+
+ if (!subnetList.isEmpty()) {
+ subnets = new org.onap.aai.domain.yang.Subnets();
+ org.onap.aai.domain.yang.Subnet subnet = null;
+ for (Subnet subnetSource : subnetList) {
+ subnet = new org.onap.aai.domain.yang.Subnet();
+ subnet.setSubnetId(subnetSource.getSubnetId());
+ subnet.setSubnetName(subnetSource.getSubnetName());
+ subnet.setNeutronSubnetId(subnetSource.getNeutronSubnetId());
+ subnet.setGatewayAddress(subnetSource.getGatewayAddress());
+ subnet.setCidrMask(subnetSource.getCidrMask());
+ subnet.setIpVersion(subnetSource.getIpVersion());
+ subnet.setOrchestrationStatus(subnetSource.getOrchestrationStatus().toString());
+ subnet.setCidrMask(subnetSource.getCidrMask());
+ subnet.setDhcpEnabled(subnetSource.isDhcpEnabled());
+ subnet.setDhcpStart(subnetSource.getDhcpStart());
+ subnet.setDhcpEnd(subnetSource.getDhcpEnd());
+ subnet.setSubnetRole(subnetSource.getSubnetRole());
+ subnet.setIpAssignmentDirection(subnetSource.getIpAssignmentDirection());
+ subnet.setSubnetSequence(subnetSource.getSubnetSequence());
+
+ org.onap.aai.domain.yang.HostRoutes hostRoutes = new org.onap.aai.domain.yang.HostRoutes();
+ org.onap.aai.domain.yang.HostRoute hostRoute = null;
+ for (HostRoute hostRouteSource : subnetSource.getHostRoutes()) {
+ hostRoute = new org.onap.aai.domain.yang.HostRoute();
+ hostRoute.setHostRouteId(hostRouteSource.getHostRouteId());
+ hostRoute.setRoutePrefix(hostRouteSource.getRoutePrefix());
+ hostRoute.setNextHop(hostRouteSource.getNextHop());
+ hostRoute.setNextHopType(hostRouteSource.getNextHopType());
+ hostRoutes.getHostRoute().add(hostRoute);
+ }
+ subnet.setHostRoutes(hostRoutes);
+ subnets.getSubnet().add(subnet);
+ }
+ }
+ return subnets;
+ }
+
+ public org.onap.aai.domain.yang.CtagAssignments mapToAAICtagAssignmentList(
+ List<CtagAssignment> ctagAssignmentsList) {
+ org.onap.aai.domain.yang.CtagAssignments ctagAssignments = null;
+ if (!ctagAssignmentsList.isEmpty()) {
+ ctagAssignments = new org.onap.aai.domain.yang.CtagAssignments();
+
+ org.onap.aai.domain.yang.CtagAssignment ctagAssignment = null;
+ for (CtagAssignment ctagAssignmentSource : ctagAssignmentsList) {
+ ctagAssignment = new org.onap.aai.domain.yang.CtagAssignment();
+ ctagAssignment.setVlanIdInner(ctagAssignmentSource.getVlanIdInner());
+ ctagAssignments.getCtagAssignment().add(ctagAssignment);
+ }
+ }
+ return ctagAssignments;
+ }
+
+ public org.onap.aai.domain.yang.SegmentationAssignments mapToAAISegmentationAssignmentList(
+ List<SegmentationAssignment> segmentationAssignmentList) {
+ org.onap.aai.domain.yang.SegmentationAssignments segmentationAssignments = null;
+ if (!segmentationAssignmentList.isEmpty()) {
+ segmentationAssignments = new org.onap.aai.domain.yang.SegmentationAssignments();
+ org.onap.aai.domain.yang.SegmentationAssignment segmentationAssignment = null;
+ for (SegmentationAssignment segmentationAssignmentSource : segmentationAssignmentList) {
+ segmentationAssignment = new org.onap.aai.domain.yang.SegmentationAssignment();
+ segmentationAssignment.setSegmentationId(segmentationAssignmentSource.getSegmentationId());
+ segmentationAssignments.getSegmentationAssignment().add(segmentationAssignment);
+ }
+ }
+ return segmentationAssignments;
+ }
+
+ public org.onap.aai.domain.yang.Configuration mapConfiguration(Configuration configuration) {
+ if (null == modelMapper.getTypeMap(Configuration.class, org.onap.aai.domain.yang.Configuration.class)) {
+ modelMapper.addMappings(new PropertyMap<Configuration, org.onap.aai.domain.yang.Configuration>() {
+ @Override
+ protected void configure() {
+ map().setModelCustomizationId(source.getModelInfoConfiguration().getModelCustomizationId());
+ map().setModelVersionId(source.getModelInfoConfiguration().getModelVersionId());
+ map().setModelInvariantId(source.getModelInfoConfiguration().getModelInvariantId());
+ map().setConfigurationType(source.getModelInfoConfiguration().getConfigurationType());
+ map().setConfigurationSubType(source.getModelInfoConfiguration().getConfigurationRole());
+ map().setConfigPolicyName(source.getModelInfoConfiguration().getPolicyName());
+ }
+ });
+ }
+ return modelMapper.map(configuration, org.onap.aai.domain.yang.Configuration.class);
+ }
+
+ public org.onap.aai.domain.yang.Collection mapCollection(Collection networkCollection) {
+ if (modelMapper.getTypeMap(Collection.class, org.onap.aai.domain.yang.Collection.class) == null) {
+ modelMapper.addMappings(new PropertyMap<Collection, org.onap.aai.domain.yang.Collection>() {
+ @Override
+ protected void configure() {
+ map().setModelInvariantId(source.getModelInfoCollection().getModelInvariantUUID());
+ map().setModelVersionId(source.getModelInfoCollection().getModelVersionId());
+ map().setCollectionCustomizationId(source.getModelInfoCollection().getModelCustomizationUUID());
+ map().setCollectionFunction(source.getModelInfoCollection().getCollectionFunction());
+ map().setCollectionRole(source.getModelInfoCollection().getCollectionRole());
+ map().setCollectionType(source.getModelInfoCollection().getCollectionType());
+ map().setCollectionName(source.getName());
+ }
+ });
+ }
+ return modelMapper.map(networkCollection, org.onap.aai.domain.yang.Collection.class);
+ }
public org.onap.aai.domain.yang.VpnBinding mapVpnBinding(VpnBinding vpnBinding) {
- org.onap.aai.domain.yang.VpnBinding aaiVpnBinding = modelMapper.map(vpnBinding, org.onap.aai.domain.yang.VpnBinding.class);
- mapRouteTargetToVpnBinding(aaiVpnBinding,vpnBinding);
- return aaiVpnBinding;
- }
-
- public org.onap.aai.domain.yang.RouteTarget mapRouteTarget(RouteTarget routeTarget) {
- return modelMapper.map(routeTarget, org.onap.aai.domain.yang.RouteTarget.class);
- }
-
- private void mapRouteTargetToVpnBinding(org.onap.aai.domain.yang.VpnBinding aaiVpnBinding, VpnBinding vpnBinding) {
- if(vpnBinding.getRouteTargets() != null && !vpnBinding.getRouteTargets().isEmpty()) {
- RouteTargets routeTargets = new RouteTargets();
- for (RouteTarget routeTarget : vpnBinding.getRouteTargets()) {
- routeTargets.getRouteTarget().add(mapRouteTarget(routeTarget));
- }
- aaiVpnBinding.setRouteTargets(routeTargets);
- }
- }
-
- public org.onap.aai.domain.yang.Subnet mapSubnet (Subnet subnet){
- return modelMapper.map(subnet,org.onap.aai.domain.yang.Subnet.class);
- }
-
- public org.onap.aai.domain.yang.NetworkPolicy mapNetworkPolicy (NetworkPolicy networkPolicy){
- return modelMapper.map(networkPolicy,org.onap.aai.domain.yang.NetworkPolicy.class);
- }
+ org.onap.aai.domain.yang.VpnBinding aaiVpnBinding =
+ modelMapper.map(vpnBinding, org.onap.aai.domain.yang.VpnBinding.class);
+ mapRouteTargetToVpnBinding(aaiVpnBinding, vpnBinding);
+ return aaiVpnBinding;
+ }
+
+ public org.onap.aai.domain.yang.RouteTarget mapRouteTarget(RouteTarget routeTarget) {
+ return modelMapper.map(routeTarget, org.onap.aai.domain.yang.RouteTarget.class);
+ }
+
+ private void mapRouteTargetToVpnBinding(org.onap.aai.domain.yang.VpnBinding aaiVpnBinding, VpnBinding vpnBinding) {
+ if (vpnBinding.getRouteTargets() != null && !vpnBinding.getRouteTargets().isEmpty()) {
+ RouteTargets routeTargets = new RouteTargets();
+ for (RouteTarget routeTarget : vpnBinding.getRouteTargets()) {
+ routeTargets.getRouteTarget().add(mapRouteTarget(routeTarget));
+ }
+ aaiVpnBinding.setRouteTargets(routeTargets);
+ }
+ }
+
+ public org.onap.aai.domain.yang.Subnet mapSubnet(Subnet subnet) {
+ return modelMapper.map(subnet, org.onap.aai.domain.yang.Subnet.class);
+ }
+
+ public org.onap.aai.domain.yang.NetworkPolicy mapNetworkPolicy(NetworkPolicy networkPolicy) {
+ return modelMapper.map(networkPolicy, org.onap.aai.domain.yang.NetworkPolicy.class);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/NetworkAdapterClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/NetworkAdapterClient.java
index 350a6ae8d6..62d0c230fb 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/NetworkAdapterClient.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/NetworkAdapterClient.java
@@ -21,7 +21,6 @@
package org.onap.so.client.adapter.network;
import javax.ws.rs.core.Response;
-
import org.onap.so.adapters.nwrest.CreateNetworkRequest;
import org.onap.so.adapters.nwrest.CreateNetworkResponse;
import org.onap.so.adapters.nwrest.DeleteNetworkRequest;
@@ -33,25 +32,25 @@ import org.onap.so.adapters.nwrest.UpdateNetworkRequest;
import org.onap.so.adapters.nwrest.UpdateNetworkResponse;
public interface NetworkAdapterClient {
- CreateNetworkResponse createNetwork(CreateNetworkRequest req) throws NetworkAdapterClientException;
+ CreateNetworkResponse createNetwork(CreateNetworkRequest req) throws NetworkAdapterClientException;
+
+ DeleteNetworkResponse deleteNetwork(String aaiNetworkId, DeleteNetworkRequest req)
+ throws NetworkAdapterClientException;
- DeleteNetworkResponse deleteNetwork(String aaiNetworkId, DeleteNetworkRequest req)
- throws NetworkAdapterClientException;
+ RollbackNetworkResponse rollbackNetwork(String aaiNetworkId, RollbackNetworkRequest req)
+ throws NetworkAdapterClientException;
- RollbackNetworkResponse rollbackNetwork(String aaiNetworkId, RollbackNetworkRequest req)
- throws NetworkAdapterClientException;
+ QueryNetworkResponse queryNetwork(String aaiNetworkId, String cloudSiteId, String tenantId, String networkStackId,
+ boolean skipAAI, String requestId, String serviceInstanceId) throws NetworkAdapterClientException;
- QueryNetworkResponse queryNetwork(String aaiNetworkId, String cloudSiteId, String tenantId, String networkStackId,
- boolean skipAAI, String requestId, String serviceInstanceId) throws NetworkAdapterClientException;
+ UpdateNetworkResponse updateNetwork(String aaiNetworkId, UpdateNetworkRequest req)
+ throws NetworkAdapterClientException;
- UpdateNetworkResponse updateNetwork(String aaiNetworkId, UpdateNetworkRequest req)
- throws NetworkAdapterClientException;
+ Response createNetworkAsync(CreateNetworkRequest req) throws NetworkAdapterClientException;
- Response createNetworkAsync(CreateNetworkRequest req) throws NetworkAdapterClientException;
+ Response deleteNetworkAsync(String aaiNetworkId, DeleteNetworkRequest req) throws NetworkAdapterClientException;
- Response deleteNetworkAsync(String aaiNetworkId, DeleteNetworkRequest req) throws NetworkAdapterClientException;
+ Response rollbackNetworkAsync(String aaiNetworkId, RollbackNetworkRequest req) throws NetworkAdapterClientException;
- Response rollbackNetworkAsync(String aaiNetworkId, RollbackNetworkRequest req) throws NetworkAdapterClientException;
-
- Response updateNetworkAsync(String aaiNetworkId, UpdateNetworkRequest req) throws NetworkAdapterClientException;
+ Response updateNetworkAsync(String aaiNetworkId, UpdateNetworkRequest req) throws NetworkAdapterClientException;
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/NetworkAdapterClientException.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/NetworkAdapterClientException.java
index 0492477cf6..2712f1e6f7 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/NetworkAdapterClientException.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/NetworkAdapterClientException.java
@@ -23,13 +23,13 @@ package org.onap.so.client.adapter.network;
public class NetworkAdapterClientException extends Exception {
- /**
- *
- */
- private static final long serialVersionUID = 8040736661096488110L;
+ /**
+ *
+ */
+ private static final long serialVersionUID = 8040736661096488110L;
- public NetworkAdapterClientException(String message) {
- super(message);
- }
+ public NetworkAdapterClientException(String message) {
+ super(message);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/NetworkAdapterClientImpl.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/NetworkAdapterClientImpl.java
index e8a5723e19..8668306f13 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/NetworkAdapterClientImpl.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/NetworkAdapterClientImpl.java
@@ -24,7 +24,6 @@ import javax.ws.rs.InternalServerErrorException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriBuilder;
-
import org.onap.so.adapters.nwrest.CreateNetworkRequest;
import org.onap.so.adapters.nwrest.CreateNetworkResponse;
import org.onap.so.adapters.nwrest.DeleteNetworkRequest;
@@ -40,120 +39,126 @@ import org.springframework.stereotype.Component;
@Component
public class NetworkAdapterClientImpl implements NetworkAdapterClient {
- private final NetworkAdapterRestProperties props;
-
- public NetworkAdapterClientImpl() {
- this.props = new NetworkAdapterRestProperties();
- }
-
- @Override
- public CreateNetworkResponse createNetwork(CreateNetworkRequest req) throws NetworkAdapterClientException{
- try {
- return new AdapterRestClient(this.props, this.getUri("").build()).post(req,
- CreateNetworkResponse.class);
- } catch (InternalServerErrorException e) {
- throw new NetworkAdapterClientException(e.getMessage());
- }
- }
-
- @Override
- public Response createNetworkAsync(CreateNetworkRequest req) throws NetworkAdapterClientException{
- try {
- return new AdapterRestClient(this.props, this.getUri("").build()).post(req);
- } catch (InternalServerErrorException e) {
- throw new NetworkAdapterClientException(e.getMessage());
- }
- }
-
- @Override
- public DeleteNetworkResponse deleteNetwork(String aaiNetworkId, DeleteNetworkRequest req) throws NetworkAdapterClientException {
- try {
- return new AdapterRestClient(this.props, this.getUri("/" + aaiNetworkId).build()).delete(req,
- DeleteNetworkResponse.class);
- } catch (InternalServerErrorException e) {
- throw new NetworkAdapterClientException(e.getMessage());
- }
- }
-
- @Override
- public Response deleteNetworkAsync(String aaiNetworkId, DeleteNetworkRequest req) throws NetworkAdapterClientException {
- try {
- return new AdapterRestClient(this.props, this.getUri("/" + aaiNetworkId).build()).delete(req);
- } catch (InternalServerErrorException e) {
- throw new NetworkAdapterClientException(e.getMessage());
- }
- }
-
- @Override
- public RollbackNetworkResponse rollbackNetwork(String aaiNetworkId, RollbackNetworkRequest req) throws NetworkAdapterClientException {
- try {
- return new AdapterRestClient(this.props, this.getUri("/" + aaiNetworkId).build()).delete(req,
- RollbackNetworkResponse.class);
- } catch (InternalServerErrorException e) {
- throw new NetworkAdapterClientException(e.getMessage());
- }
- }
-
- @Override
- public Response rollbackNetworkAsync(String aaiNetworkId, RollbackNetworkRequest req) throws NetworkAdapterClientException {
- try {
- return new AdapterRestClient(this.props, this.getUri("/" + aaiNetworkId).build()).delete(req);
- } catch (InternalServerErrorException e) {
- throw new NetworkAdapterClientException(e.getMessage());
- }
- }
-
- @Override
- public QueryNetworkResponse queryNetwork(String aaiNetworkId, String cloudSiteId, String tenantId,
- String networkStackId, boolean skipAAI, String requestId, String serviceInstanceId) throws NetworkAdapterClientException {
- UriBuilder builder = this.getUri("/" + aaiNetworkId);
- if (cloudSiteId != null) {
- builder.queryParam("cloudSiteId", cloudSiteId);
- }
- if (tenantId != null) {
- builder.queryParam("tenantId", tenantId);
- }
- if (networkStackId != null) {
- builder.queryParam("networkStackId", networkStackId);
- }
-
- builder.queryParam("skipAAI", skipAAI);
-
- if (requestId != null) {
- builder.queryParam("msoRequest.requestId", requestId);
- }
- if (serviceInstanceId != null) {
- builder.queryParam("msoRequest.serviceInstanceId", serviceInstanceId);
- }
- try {
- return new AdapterRestClient(this.props, builder.build(), MediaType.APPLICATION_XML, MediaType.APPLICATION_XML)
- .get(QueryNetworkResponse.class).get();
- } catch (InternalServerErrorException e) {
- throw new NetworkAdapterClientException(e.getMessage());
- }
- }
-
- @Override
- public UpdateNetworkResponse updateNetwork(String aaiNetworkId, UpdateNetworkRequest req) throws NetworkAdapterClientException {
- try {
- return new AdapterRestClient(this.props, this.getUri("/" + aaiNetworkId).build()).put(req,
- UpdateNetworkResponse.class);
- } catch (InternalServerErrorException e) {
- throw new NetworkAdapterClientException(e.getMessage());
- }
- }
-
- @Override
- public Response updateNetworkAsync(String aaiNetworkId, UpdateNetworkRequest req) throws NetworkAdapterClientException{
- try {
- return new AdapterRestClient(this.props, this.getUri("/" + aaiNetworkId).build()).put(req);
- } catch (InternalServerErrorException e) {
- throw new NetworkAdapterClientException(e.getMessage());
- }
- }
-
- protected UriBuilder getUri(String path) {
- return UriBuilder.fromPath(path);
- }
+ private final NetworkAdapterRestProperties props;
+
+ public NetworkAdapterClientImpl() {
+ this.props = new NetworkAdapterRestProperties();
+ }
+
+ @Override
+ public CreateNetworkResponse createNetwork(CreateNetworkRequest req) throws NetworkAdapterClientException {
+ try {
+ return new AdapterRestClient(this.props, this.getUri("").build()).post(req, CreateNetworkResponse.class);
+ } catch (InternalServerErrorException e) {
+ throw new NetworkAdapterClientException(e.getMessage());
+ }
+ }
+
+ @Override
+ public Response createNetworkAsync(CreateNetworkRequest req) throws NetworkAdapterClientException {
+ try {
+ return new AdapterRestClient(this.props, this.getUri("").build()).post(req);
+ } catch (InternalServerErrorException e) {
+ throw new NetworkAdapterClientException(e.getMessage());
+ }
+ }
+
+ @Override
+ public DeleteNetworkResponse deleteNetwork(String aaiNetworkId, DeleteNetworkRequest req)
+ throws NetworkAdapterClientException {
+ try {
+ return new AdapterRestClient(this.props, this.getUri("/" + aaiNetworkId).build()).delete(req,
+ DeleteNetworkResponse.class);
+ } catch (InternalServerErrorException e) {
+ throw new NetworkAdapterClientException(e.getMessage());
+ }
+ }
+
+ @Override
+ public Response deleteNetworkAsync(String aaiNetworkId, DeleteNetworkRequest req)
+ throws NetworkAdapterClientException {
+ try {
+ return new AdapterRestClient(this.props, this.getUri("/" + aaiNetworkId).build()).delete(req);
+ } catch (InternalServerErrorException e) {
+ throw new NetworkAdapterClientException(e.getMessage());
+ }
+ }
+
+ @Override
+ public RollbackNetworkResponse rollbackNetwork(String aaiNetworkId, RollbackNetworkRequest req)
+ throws NetworkAdapterClientException {
+ try {
+ return new AdapterRestClient(this.props, this.getUri("/" + aaiNetworkId).build()).delete(req,
+ RollbackNetworkResponse.class);
+ } catch (InternalServerErrorException e) {
+ throw new NetworkAdapterClientException(e.getMessage());
+ }
+ }
+
+ @Override
+ public Response rollbackNetworkAsync(String aaiNetworkId, RollbackNetworkRequest req)
+ throws NetworkAdapterClientException {
+ try {
+ return new AdapterRestClient(this.props, this.getUri("/" + aaiNetworkId).build()).delete(req);
+ } catch (InternalServerErrorException e) {
+ throw new NetworkAdapterClientException(e.getMessage());
+ }
+ }
+
+ @Override
+ public QueryNetworkResponse queryNetwork(String aaiNetworkId, String cloudSiteId, String tenantId,
+ String networkStackId, boolean skipAAI, String requestId, String serviceInstanceId)
+ throws NetworkAdapterClientException {
+ UriBuilder builder = this.getUri("/" + aaiNetworkId);
+ if (cloudSiteId != null) {
+ builder.queryParam("cloudSiteId", cloudSiteId);
+ }
+ if (tenantId != null) {
+ builder.queryParam("tenantId", tenantId);
+ }
+ if (networkStackId != null) {
+ builder.queryParam("networkStackId", networkStackId);
+ }
+
+ builder.queryParam("skipAAI", skipAAI);
+
+ if (requestId != null) {
+ builder.queryParam("msoRequest.requestId", requestId);
+ }
+ if (serviceInstanceId != null) {
+ builder.queryParam("msoRequest.serviceInstanceId", serviceInstanceId);
+ }
+ try {
+ return new AdapterRestClient(this.props, builder.build(), MediaType.APPLICATION_XML,
+ MediaType.APPLICATION_XML).get(QueryNetworkResponse.class).get();
+ } catch (InternalServerErrorException e) {
+ throw new NetworkAdapterClientException(e.getMessage());
+ }
+ }
+
+ @Override
+ public UpdateNetworkResponse updateNetwork(String aaiNetworkId, UpdateNetworkRequest req)
+ throws NetworkAdapterClientException {
+ try {
+ return new AdapterRestClient(this.props, this.getUri("/" + aaiNetworkId).build()).put(req,
+ UpdateNetworkResponse.class);
+ } catch (InternalServerErrorException e) {
+ throw new NetworkAdapterClientException(e.getMessage());
+ }
+ }
+
+ @Override
+ public Response updateNetworkAsync(String aaiNetworkId, UpdateNetworkRequest req)
+ throws NetworkAdapterClientException {
+ try {
+ return new AdapterRestClient(this.props, this.getUri("/" + aaiNetworkId).build()).put(req);
+ } catch (InternalServerErrorException e) {
+ throw new NetworkAdapterClientException(e.getMessage());
+ }
+ }
+
+ protected UriBuilder getUri(String path) {
+ return UriBuilder.fromPath(path);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/NetworkAdapterRestProperties.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/NetworkAdapterRestProperties.java
index 9888dd3be2..d35f810d2d 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/NetworkAdapterRestProperties.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/NetworkAdapterRestProperties.java
@@ -22,32 +22,32 @@ package org.onap.so.client.adapter.network;
import java.net.MalformedURLException;
import java.net.URL;
-
import org.onap.so.bpmn.core.UrnPropertiesReader;
import org.onap.so.client.adapter.rest.AdapterRestProperties;
public class NetworkAdapterRestProperties implements AdapterRestProperties {
- public NetworkAdapterRestProperties() {
- }
-
- @Override
- public String getAuth() {
- return UrnPropertiesReader.getVariable("mso.adapters.po.auth");
- }
- @Override
- public String getKey() {
- return UrnPropertiesReader.getVariable("mso.msoKey");
- }
- @Override
- public URL getEndpoint() throws MalformedURLException {
- return new URL(UrnPropertiesReader.getVariable("mso.adapters.network.rest.endpoint"));
- }
-
- @Override
- public String getSystemName() {
- return "MSO";
- }
+ public NetworkAdapterRestProperties() {}
+
+ @Override
+ public String getAuth() {
+ return UrnPropertiesReader.getVariable("mso.adapters.po.auth");
+ }
+
+ @Override
+ public String getKey() {
+ return UrnPropertiesReader.getVariable("mso.msoKey");
+ }
+
+ @Override
+ public URL getEndpoint() throws MalformedURLException {
+ return new URL(UrnPropertiesReader.getVariable("mso.adapters.network.rest.endpoint"));
+ }
+
+ @Override
+ public String getSystemName() {
+ return "MSO";
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java
index 8c774d8677..4fee1f909b 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java
@@ -27,7 +27,6 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
-
import org.apache.commons.lang3.StringUtils;
import org.modelmapper.ModelMapper;
import org.modelmapper.PropertyMap;
@@ -61,329 +60,353 @@ import org.springframework.web.util.UriUtils;
@Component
public class NetworkAdapterObjectMapper {
- private static final ModelMapper modelMapper = new ModelMapper();
- private static String FORWARD_SLASH = "/";
- private static final Logger logger = LoggerFactory.getLogger(NetworkAdapterObjectMapper.class);
-
- public CreateNetworkRequest createNetworkRequestMapper(RequestContext requestContext, CloudRegion cloudRegion, OrchestrationContext orchestrationContext, ServiceInstance serviceInstance, L3Network l3Network, Map<String, String> userInput, String cloudRegionPo, Customer customer) throws UnsupportedEncodingException {
- CreateNetworkRequest createNetworkRequest = new CreateNetworkRequest();
-
- //set cloudSiteId as determined for cloud region PO instead of cloudRegion.getLcpCloudRegionId()
- createNetworkRequest.setCloudSiteId(cloudRegionPo);
- createNetworkRequest.setTenantId(cloudRegion.getTenantId());
- createNetworkRequest.setNetworkId(l3Network.getNetworkId());
- createNetworkRequest.setNetworkName(l3Network.getNetworkName());
- //TODO fields not available
- createNetworkRequest.setNetworkType(l3Network.getNetworkType());
- //createNetworkRequest.setNetworkTypeVersion(serviceInstance.getModelInfoServiceInstance().getModelVersion());
- ModelInfoNetwork modelInfoNetwork = l3Network.getModelInfoNetwork();
- if (modelInfoNetwork != null){
- createNetworkRequest.setModelCustomizationUuid(modelInfoNetwork.getModelCustomizationUUID());
- }
-
- //build and set Subnet list
- createNetworkRequest.setSubnets(buildOpenstackSubnetList(l3Network));
-
- //build and set provider Vlan Network
- ProviderVlanNetwork providerVlanNetwork = buildProviderVlanNetwork(l3Network);
- createNetworkRequest.setProviderVlanNetwork(providerVlanNetwork);
- String networkTechnology = l3Network.getModelInfoNetwork().getNetworkTechnology();
- if(networkTechnology == null) {
- networkTechnology = l3Network.getNetworkTechnology();
- logger.warn("NetworkTechnology was null in CatalogDB. Using field from AAI: " + networkTechnology);
- }
- if (networkTechnology != null) {
- createNetworkRequest.setNetworkTechnology(networkTechnology.toUpperCase());
- if (createNetworkRequest.getNetworkTechnology().contains("CONTRAIL")) {
- createNetworkRequest.setContrailRequest(true);
- }
- }
-
- //build and set Contrail Network
- ContrailNetwork contrailNetwork = buildContrailNetwork(l3Network, customer);
- createNetworkRequest.setContrailNetwork(contrailNetwork);
-
- //set Network Parameters from VID request, add "shared" and "external" to this map
- createNetworkRequest.setNetworkParams(addSharedAndExternal(userInput, l3Network));
-
- createNetworkRequest = setFlowFlags(createNetworkRequest, orchestrationContext);
-
- createNetworkRequest.setMsoRequest(createMsoRequest(requestContext, serviceInstance));
-
- String messageId = getRandomUuid();
- createNetworkRequest.setMessageId(messageId);
- createNetworkRequest.setNotificationUrl(createCallbackUrl("NetworkAResponse", messageId));
-
- return createNetworkRequest;
- }
-
- public DeleteNetworkRequest deleteNetworkRequestMapper(RequestContext requestContext, CloudRegion cloudRegion, ServiceInstance serviceInstance, L3Network l3Network) throws UnsupportedEncodingException {
- DeleteNetworkRequest deleteNetworkRequest = new DeleteNetworkRequest();
-
- deleteNetworkRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
-
- String messageId = getRandomUuid();
- deleteNetworkRequest.setMessageId(messageId);
-
- ModelInfoNetwork modelInfoNetwork = l3Network.getModelInfoNetwork();
- if (modelInfoNetwork != null){
- deleteNetworkRequest.setModelCustomizationUuid(modelInfoNetwork.getModelCustomizationUUID());
- }
-
- deleteNetworkRequest.setMsoRequest(createMsoRequest(requestContext, serviceInstance));
- deleteNetworkRequest.setNetworkId(l3Network.getNetworkId());
- if (!StringUtils.isEmpty(l3Network.getHeatStackId())){
- deleteNetworkRequest.setNetworkStackId(l3Network.getHeatStackId());
- }
- else {
- deleteNetworkRequest.setNetworkStackId(l3Network.getNetworkName());
- }
- deleteNetworkRequest.setNetworkType(l3Network.getNetworkType());
- deleteNetworkRequest.setSkipAAI(true);
- deleteNetworkRequest.setTenantId(cloudRegion.getTenantId());
-
- deleteNetworkRequest.setNotificationUrl(createCallbackUrl("NetworkAResponse", messageId));
-
- return deleteNetworkRequest;
- }
-
- /**
- * Access method to build Rollback Network Request
- * @return
- * @throws UnsupportedEncodingException
- */
- public RollbackNetworkRequest createNetworkRollbackRequestMapper(RequestContext requestContext, CloudRegion cloudRegion, OrchestrationContext orchestrationContext, ServiceInstance serviceInstance, L3Network l3Network, Map<String, String> userInput, String cloudRegionPo, CreateNetworkResponse createNetworkResponse) throws UnsupportedEncodingException {
- RollbackNetworkRequest rollbackNetworkRequest = new RollbackNetworkRequest();
-
- rollbackNetworkRequest = setCommonRollbackRequestFields(rollbackNetworkRequest, requestContext);
-
- NetworkRollback networkRollback = buildNetworkRollback(l3Network, cloudRegion, cloudRegionPo, createNetworkResponse);
- rollbackNetworkRequest.setNetworkRollback(networkRollback);
-
- return rollbackNetworkRequest;
- }
-
- public UpdateNetworkRequest createNetworkUpdateRequestMapper(RequestContext requestContext, CloudRegion cloudRegion, OrchestrationContext orchestrationContext, ServiceInstance serviceInstance, L3Network l3Network, Map<String, String> userInput, Customer customer) throws UnsupportedEncodingException {
- UpdateNetworkRequest updateNetworkRequest = new UpdateNetworkRequest();
-
- updateNetworkRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
- updateNetworkRequest.setTenantId(cloudRegion.getTenantId());
- updateNetworkRequest.setNetworkId(l3Network.getNetworkId());
- updateNetworkRequest.setNetworkStackId(l3Network.getHeatStackId());
- updateNetworkRequest.setNetworkName(l3Network.getNetworkName());
- updateNetworkRequest.setNetworkType(l3Network.getModelInfoNetwork().getNetworkType());
- updateNetworkRequest.setNetworkTypeVersion(l3Network.getModelInfoNetwork().getModelVersion());
- updateNetworkRequest.setModelCustomizationUuid(l3Network.getModelInfoNetwork().getModelCustomizationUUID());
- updateNetworkRequest.setSubnets(buildOpenstackSubnetList(l3Network));
- updateNetworkRequest.setProviderVlanNetwork(buildProviderVlanNetwork(l3Network));
- updateNetworkRequest.setContrailNetwork(buildContrailNetwork(l3Network, customer));
- updateNetworkRequest.setNetworkParams(addSharedAndExternal(userInput, l3Network));
- updateNetworkRequest.setMsoRequest(createMsoRequest(requestContext, serviceInstance));
-
- setFlowFlags(updateNetworkRequest, orchestrationContext);
-
- String messageId = getRandomUuid();
- updateNetworkRequest.setMessageId(messageId);
- updateNetworkRequest.setNotificationUrl(createCallbackUrl("NetworkAResponse", messageId));
-
- return updateNetworkRequest;
- }
-
- private RollbackNetworkRequest setCommonRollbackRequestFields(RollbackNetworkRequest request,RequestContext requestContext) throws UnsupportedEncodingException{
- request.setSkipAAI(true);
- String messageId = requestContext.getMsoRequestId();
- request.setMessageId(messageId);
- //request.setNotificationUrl(createCallbackUrl("NetworkAResponse", messageId));
- return request;
- }
-
- private NetworkRollback buildNetworkRollback(L3Network l3Network, CloudRegion cloudRegion, String cloudRegionPo, CreateNetworkResponse createNetworkResponse){
- NetworkRollback networkRollback = new NetworkRollback();
- networkRollback.setNetworkId(l3Network.getNetworkId());
- networkRollback.setNeutronNetworkId(createNetworkResponse.getMessageId());
- networkRollback.setNetworkStackId(createNetworkResponse.getNetworkStackId());
- networkRollback.setTenantId(cloudRegion.getTenantId());
- networkRollback.setCloudId(cloudRegionPo);
- networkRollback.setNetworkType(l3Network.getNetworkType());
- ModelInfoNetwork modelInfoNetwork = l3Network.getModelInfoNetwork();
- if (modelInfoNetwork != null){
- networkRollback.setModelCustomizationUuid(modelInfoNetwork.getModelCustomizationUUID());
- }
- //rollback will only be called when network was actually created
- networkRollback.setNetworkCreated(createNetworkResponse.getNetworkCreated());
- //TODO confirm below not required for create rollback
- //NetworkName
- //PhysicalNetwork
- //Vlans
- //msoRequest
- return networkRollback;
- }
-
- public MsoRequest createMsoRequest(RequestContext requestContext, ServiceInstance serviceInstance) {
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId(requestContext.getMsoRequestId());
- msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
- return msoRequest;
- }
-
- protected String getRandomUuid() {
- return UUID.randomUUID().toString();
- }
-
- protected String createCallbackUrl(String messageType, String correlator) throws UnsupportedEncodingException {
- String endpoint = this.getEndpoint();
-
- while (endpoint.endsWith("/")) {
- endpoint = endpoint.substring(0, endpoint.length()-1);
- }
- return endpoint + "/" + UriUtils.encodePathSegment(messageType, "UTF-8") + "/" + UriUtils.encodePathSegment(correlator, "UTF-8");
- }
-
- protected String getEndpoint() {
- return UrnPropertiesReader.getVariable("mso.workflow.message.endpoint");
- }
- /**
- * Use BB L3Network object to build subnets list of type org.onap.so.openstack.beans.Subnet
- * @param L3Network
- * @return List<org.onap.so.openstack.beans.Subnet>
- */
- private List<Subnet> buildOpenstackSubnetList(L3Network l3Network){
-
- List<org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet> subnets = l3Network.getSubnets();
- List<org.onap.so.openstack.beans.Subnet> subnetList = new ArrayList<org.onap.so.openstack.beans.Subnet>();
- //create mapper from onap Subnet to openstack bean Subnet
- if(modelMapper.getTypeMap(org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet.class, org.onap.so.openstack.beans.Subnet.class) == null) {
- PropertyMap<org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet, org.onap.so.openstack.beans.Subnet> personMap = new PropertyMap<org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet, org.onap.so.openstack.beans.Subnet>() {
- protected void configure() {
- map().setSubnetName(source.getSubnetName());
- map(source.getSubnetId(), destination.getSubnetId());
- map(source.getNeutronSubnetId(), destination.getNeutronId());
- map(source.getGatewayAddress(), destination.getGatewayIp());
- map(source.getIpVersion(), destination.getIpVersion());
- map(source.isDhcpEnabled(), destination.getEnableDHCP());
- map(source.getSubnetSequence(), destination.getSubnetSequence());
- }
- };
- modelMapper.addMappings(personMap);
- }
-
- for (org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet subnet : subnets) {
- org.onap.so.openstack.beans.Subnet openstackSubnet = modelMapper.map(subnet, org.onap.so.openstack.beans.Subnet.class);
- //update cidr value
- if (subnet.getNetworkStartAddress() != null && subnet.getCidrMask() != null)
- openstackSubnet.setCidr(subnet.getNetworkStartAddress().concat(FORWARD_SLASH).concat(subnet.getCidrMask()));
- List<org.onap.so.bpmn.servicedecomposition.bbobjects.HostRoute> hostRouteList = subnet.getHostRoutes();
- List<org.onap.so.openstack.beans.HostRoute> openstackHostRouteList = new ArrayList<>();
- org.onap.so.openstack.beans.HostRoute openstackHostRoute = new org.onap.so.openstack.beans.HostRoute();
- //TODO only 2 fields available on openstack object. Confirm it is sufficient or add as needed
- for (org.onap.so.bpmn.servicedecomposition.bbobjects.HostRoute hostRoute : hostRouteList) {
- openstackHostRoute.setNextHop(hostRoute.getNextHop());
- openstackHostRoute.setPrefix(hostRoute.getRoutePrefix());
- //add host route to the list
- openstackHostRouteList.add(openstackHostRoute);
- }
- if (subnet.getDhcpStart() != null && !subnet.getDhcpStart().equals("")) {
- org.onap.so.openstack.beans.Pool openstackAllocationPool = new org.onap.so.openstack.beans.Pool();
- openstackAllocationPool.setStart(subnet.getDhcpStart());
- openstackAllocationPool.setEnd(subnet.getDhcpEnd());
- List<org.onap.so.openstack.beans.Pool> allocationPools = new ArrayList<>();
- allocationPools.add(openstackAllocationPool);
- openstackSubnet.setAllocationPools(allocationPools);
- }
- openstackSubnet.setHostRoutes(openstackHostRouteList);
- //add subnet to the list
- subnetList.add(openstackSubnet);
- }
- return subnetList;
- }
-
- private ProviderVlanNetwork buildProviderVlanNetwork(L3Network l3Network){
- ProviderVlanNetwork providerVlanNetwork = new ProviderVlanNetwork();
- providerVlanNetwork.setPhysicalNetworkName(l3Network.getPhysicalNetworkName());
- List<Integer> vlans = new ArrayList<Integer>();
- List<org.onap.so.bpmn.servicedecomposition.bbobjects.SegmentationAssignment> segmentationAssignments = l3Network.getSegmentationAssignments();
- for (org.onap.so.bpmn.servicedecomposition.bbobjects.SegmentationAssignment assignment : segmentationAssignments) {
- vlans.add(Integer.valueOf(assignment.getSegmentationId()));
- }
- providerVlanNetwork.setVlans(vlans);
- return providerVlanNetwork;
- }
-
- private ContrailNetwork buildContrailNetwork(L3Network l3Network, Customer customer){
- ContrailNetwork contrailNetwork = new ContrailNetwork();
- contrailNetwork.setExternal(Optional.ofNullable(l3Network.isIsExternalNetwork()).orElse(false).toString());
- contrailNetwork.setShared(Optional.ofNullable(l3Network.isIsSharedNetwork()).orElse(false).toString());
- contrailNetwork.setPolicyFqdns(buildPolicyFqdns(l3Network.getNetworkPolicies()));
- contrailNetwork.setRouteTableFqdns(buildRouteTableFqdns(l3Network.getContrailNetworkRouteTableReferences()));
- if(customer!= null)
- contrailNetwork.setRouteTargets(buildRouteTargets(customer.getVpnBindings()));
- //PolicyFqdns(policyFqdns); --- is set in getAAINetworkPolicy
- //RouteTableFqdns(routeTableFqdns); --- is set in getAAINetworkTableRef
- //RouteTargets(routeTargets); --- is set in getAAINetworkVpnBinding
- return contrailNetwork;
- }
-
- private List<String> buildPolicyFqdns(List<NetworkPolicy> networkPolicies) {
- List<String> policyFqdns = new ArrayList<>();
- for(NetworkPolicy networkPolicy : networkPolicies) {
- policyFqdns.add(networkPolicy.getNetworkPolicyFqdn());
- }
- return policyFqdns;
- }
-
- private List<String> buildRouteTableFqdns(List<RouteTableReference> contrailNetworkRouteTableReferences) {
- List<String> routeTableFqdns = new ArrayList<>();
- for(RouteTableReference routeTableReference : contrailNetworkRouteTableReferences) {
- routeTableFqdns.add(routeTableReference.getRouteTableReferenceFqdn());
- }
- return routeTableFqdns;
- }
-
- private List<RouteTarget> buildRouteTargets(List<VpnBinding> vpnBindings) {
- if(modelMapper.getTypeMap(org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTarget.class, RouteTarget.class) == null) {
- modelMapper.addMappings(new PropertyMap<org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTarget, RouteTarget>() {
- @Override
- protected void configure() {
- map().setRouteTarget(source.getGlobalRouteTarget());
- map().setRouteTargetRole(source.getRouteTargetRole());
- }
- });
- }
-
- List<RouteTarget> routeTargets = new ArrayList<>();
- for(VpnBinding vpnBinding : vpnBindings) {
- for(org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTarget routeTarget : vpnBinding.getRouteTargets()) {
- routeTargets.add(modelMapper.map(routeTarget, RouteTarget.class));
- }
- }
- return routeTargets;
- }
-
- private CreateNetworkRequest setFlowFlags(CreateNetworkRequest createNetworkRequest, OrchestrationContext orchestrationContext){
- //TODO confirm flag value
- createNetworkRequest.setSkipAAI(true);
- createNetworkRequest.setBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled()));
- //TODO confirm value - false by default
- createNetworkRequest.setFailIfExists(true);
- //NetworkTechnology(NetworkTechnology.NEUTRON); NOOP - default
- return createNetworkRequest;
- }
-
- private void setFlowFlags(UpdateNetworkRequest updateNetworkRequest, OrchestrationContext orchestrationContext){
- updateNetworkRequest.setSkipAAI(true);
- updateNetworkRequest.setBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled()));
- //NetworkTechnology(NetworkTechnology.NEUTRON); NOOP - default
- }
-
- private Map<String, String> addSharedAndExternal(Map<String, String> userInput, L3Network l3Network) {
- if (userInput == null)
- userInput = new HashMap<String, String>();
- if (!userInput.containsKey("shared")) {
- userInput.put("shared", Optional.ofNullable(l3Network.isIsSharedNetwork()).orElse(false).toString());
- }
- if (!userInput.containsKey("external")) {
- userInput.put("external", Optional.ofNullable(l3Network.isIsExternalNetwork()).orElse(false).toString());
- }
- return userInput;
- }
+ private static final ModelMapper modelMapper = new ModelMapper();
+ private static String FORWARD_SLASH = "/";
+ private static final Logger logger = LoggerFactory.getLogger(NetworkAdapterObjectMapper.class);
+
+ public CreateNetworkRequest createNetworkRequestMapper(RequestContext requestContext, CloudRegion cloudRegion,
+ OrchestrationContext orchestrationContext, ServiceInstance serviceInstance, L3Network l3Network,
+ Map<String, String> userInput, String cloudRegionPo, Customer customer)
+ throws UnsupportedEncodingException {
+ CreateNetworkRequest createNetworkRequest = new CreateNetworkRequest();
+
+ // set cloudSiteId as determined for cloud region PO instead of cloudRegion.getLcpCloudRegionId()
+ createNetworkRequest.setCloudSiteId(cloudRegionPo);
+ createNetworkRequest.setTenantId(cloudRegion.getTenantId());
+ createNetworkRequest.setNetworkId(l3Network.getNetworkId());
+ createNetworkRequest.setNetworkName(l3Network.getNetworkName());
+ // TODO fields not available
+ createNetworkRequest.setNetworkType(l3Network.getNetworkType());
+ // createNetworkRequest.setNetworkTypeVersion(serviceInstance.getModelInfoServiceInstance().getModelVersion());
+ ModelInfoNetwork modelInfoNetwork = l3Network.getModelInfoNetwork();
+ if (modelInfoNetwork != null) {
+ createNetworkRequest.setModelCustomizationUuid(modelInfoNetwork.getModelCustomizationUUID());
+ }
+
+ // build and set Subnet list
+ createNetworkRequest.setSubnets(buildOpenstackSubnetList(l3Network));
+
+ // build and set provider Vlan Network
+ ProviderVlanNetwork providerVlanNetwork = buildProviderVlanNetwork(l3Network);
+ createNetworkRequest.setProviderVlanNetwork(providerVlanNetwork);
+ String networkTechnology = l3Network.getModelInfoNetwork().getNetworkTechnology();
+ if (networkTechnology == null) {
+ networkTechnology = l3Network.getNetworkTechnology();
+ logger.warn("NetworkTechnology was null in CatalogDB. Using field from AAI: " + networkTechnology);
+ }
+ if (networkTechnology != null) {
+ createNetworkRequest.setNetworkTechnology(networkTechnology.toUpperCase());
+ if (createNetworkRequest.getNetworkTechnology().contains("CONTRAIL")) {
+ createNetworkRequest.setContrailRequest(true);
+ }
+ }
+
+ // build and set Contrail Network
+ ContrailNetwork contrailNetwork = buildContrailNetwork(l3Network, customer);
+ createNetworkRequest.setContrailNetwork(contrailNetwork);
+
+ // set Network Parameters from VID request, add "shared" and "external" to this map
+ createNetworkRequest.setNetworkParams(addSharedAndExternal(userInput, l3Network));
+
+ createNetworkRequest = setFlowFlags(createNetworkRequest, orchestrationContext);
+
+ createNetworkRequest.setMsoRequest(createMsoRequest(requestContext, serviceInstance));
+
+ String messageId = getRandomUuid();
+ createNetworkRequest.setMessageId(messageId);
+ createNetworkRequest.setNotificationUrl(createCallbackUrl("NetworkAResponse", messageId));
+
+ return createNetworkRequest;
+ }
+
+ public DeleteNetworkRequest deleteNetworkRequestMapper(RequestContext requestContext, CloudRegion cloudRegion,
+ ServiceInstance serviceInstance, L3Network l3Network) throws UnsupportedEncodingException {
+ DeleteNetworkRequest deleteNetworkRequest = new DeleteNetworkRequest();
+
+ deleteNetworkRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
+
+ String messageId = getRandomUuid();
+ deleteNetworkRequest.setMessageId(messageId);
+
+ ModelInfoNetwork modelInfoNetwork = l3Network.getModelInfoNetwork();
+ if (modelInfoNetwork != null) {
+ deleteNetworkRequest.setModelCustomizationUuid(modelInfoNetwork.getModelCustomizationUUID());
+ }
+
+ deleteNetworkRequest.setMsoRequest(createMsoRequest(requestContext, serviceInstance));
+ deleteNetworkRequest.setNetworkId(l3Network.getNetworkId());
+ if (!StringUtils.isEmpty(l3Network.getHeatStackId())) {
+ deleteNetworkRequest.setNetworkStackId(l3Network.getHeatStackId());
+ } else {
+ deleteNetworkRequest.setNetworkStackId(l3Network.getNetworkName());
+ }
+ deleteNetworkRequest.setNetworkType(l3Network.getNetworkType());
+ deleteNetworkRequest.setSkipAAI(true);
+ deleteNetworkRequest.setTenantId(cloudRegion.getTenantId());
+
+ deleteNetworkRequest.setNotificationUrl(createCallbackUrl("NetworkAResponse", messageId));
+
+ return deleteNetworkRequest;
+ }
+
+ /**
+ * Access method to build Rollback Network Request
+ *
+ * @return
+ * @throws UnsupportedEncodingException
+ */
+ public RollbackNetworkRequest createNetworkRollbackRequestMapper(RequestContext requestContext,
+ CloudRegion cloudRegion, OrchestrationContext orchestrationContext, ServiceInstance serviceInstance,
+ L3Network l3Network, Map<String, String> userInput, String cloudRegionPo,
+ CreateNetworkResponse createNetworkResponse) throws UnsupportedEncodingException {
+ RollbackNetworkRequest rollbackNetworkRequest = new RollbackNetworkRequest();
+
+ rollbackNetworkRequest = setCommonRollbackRequestFields(rollbackNetworkRequest, requestContext);
+
+ NetworkRollback networkRollback =
+ buildNetworkRollback(l3Network, cloudRegion, cloudRegionPo, createNetworkResponse);
+ rollbackNetworkRequest.setNetworkRollback(networkRollback);
+
+ return rollbackNetworkRequest;
+ }
+
+ public UpdateNetworkRequest createNetworkUpdateRequestMapper(RequestContext requestContext, CloudRegion cloudRegion,
+ OrchestrationContext orchestrationContext, ServiceInstance serviceInstance, L3Network l3Network,
+ Map<String, String> userInput, Customer customer) throws UnsupportedEncodingException {
+ UpdateNetworkRequest updateNetworkRequest = new UpdateNetworkRequest();
+
+ updateNetworkRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
+ updateNetworkRequest.setTenantId(cloudRegion.getTenantId());
+ updateNetworkRequest.setNetworkId(l3Network.getNetworkId());
+ updateNetworkRequest.setNetworkStackId(l3Network.getHeatStackId());
+ updateNetworkRequest.setNetworkName(l3Network.getNetworkName());
+ updateNetworkRequest.setNetworkType(l3Network.getModelInfoNetwork().getNetworkType());
+ updateNetworkRequest.setNetworkTypeVersion(l3Network.getModelInfoNetwork().getModelVersion());
+ updateNetworkRequest.setModelCustomizationUuid(l3Network.getModelInfoNetwork().getModelCustomizationUUID());
+ updateNetworkRequest.setSubnets(buildOpenstackSubnetList(l3Network));
+ updateNetworkRequest.setProviderVlanNetwork(buildProviderVlanNetwork(l3Network));
+ updateNetworkRequest.setContrailNetwork(buildContrailNetwork(l3Network, customer));
+ updateNetworkRequest.setNetworkParams(addSharedAndExternal(userInput, l3Network));
+ updateNetworkRequest.setMsoRequest(createMsoRequest(requestContext, serviceInstance));
+
+ setFlowFlags(updateNetworkRequest, orchestrationContext);
+
+ String messageId = getRandomUuid();
+ updateNetworkRequest.setMessageId(messageId);
+ updateNetworkRequest.setNotificationUrl(createCallbackUrl("NetworkAResponse", messageId));
+
+ return updateNetworkRequest;
+ }
+
+ private RollbackNetworkRequest setCommonRollbackRequestFields(RollbackNetworkRequest request,
+ RequestContext requestContext) throws UnsupportedEncodingException {
+ request.setSkipAAI(true);
+ String messageId = requestContext.getMsoRequestId();
+ request.setMessageId(messageId);
+ // request.setNotificationUrl(createCallbackUrl("NetworkAResponse", messageId));
+ return request;
+ }
+
+ private NetworkRollback buildNetworkRollback(L3Network l3Network, CloudRegion cloudRegion, String cloudRegionPo,
+ CreateNetworkResponse createNetworkResponse) {
+ NetworkRollback networkRollback = new NetworkRollback();
+ networkRollback.setNetworkId(l3Network.getNetworkId());
+ networkRollback.setNeutronNetworkId(createNetworkResponse.getMessageId());
+ networkRollback.setNetworkStackId(createNetworkResponse.getNetworkStackId());
+ networkRollback.setTenantId(cloudRegion.getTenantId());
+ networkRollback.setCloudId(cloudRegionPo);
+ networkRollback.setNetworkType(l3Network.getNetworkType());
+ ModelInfoNetwork modelInfoNetwork = l3Network.getModelInfoNetwork();
+ if (modelInfoNetwork != null) {
+ networkRollback.setModelCustomizationUuid(modelInfoNetwork.getModelCustomizationUUID());
+ }
+ // rollback will only be called when network was actually created
+ networkRollback.setNetworkCreated(createNetworkResponse.getNetworkCreated());
+ // TODO confirm below not required for create rollback
+ // NetworkName
+ // PhysicalNetwork
+ // Vlans
+ // msoRequest
+ return networkRollback;
+ }
+
+ public MsoRequest createMsoRequest(RequestContext requestContext, ServiceInstance serviceInstance) {
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId(requestContext.getMsoRequestId());
+ msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
+ return msoRequest;
+ }
+
+ protected String getRandomUuid() {
+ return UUID.randomUUID().toString();
+ }
+
+ protected String createCallbackUrl(String messageType, String correlator) throws UnsupportedEncodingException {
+ String endpoint = this.getEndpoint();
+
+ while (endpoint.endsWith("/")) {
+ endpoint = endpoint.substring(0, endpoint.length() - 1);
+ }
+ return endpoint + "/" + UriUtils.encodePathSegment(messageType, "UTF-8") + "/"
+ + UriUtils.encodePathSegment(correlator, "UTF-8");
+ }
+
+ protected String getEndpoint() {
+ return UrnPropertiesReader.getVariable("mso.workflow.message.endpoint");
+ }
+
+ /**
+ * Use BB L3Network object to build subnets list of type org.onap.so.openstack.beans.Subnet
+ *
+ * @param L3Network
+ * @return List<org.onap.so.openstack.beans.Subnet>
+ */
+ private List<Subnet> buildOpenstackSubnetList(L3Network l3Network) {
+
+ List<org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet> subnets = l3Network.getSubnets();
+ List<org.onap.so.openstack.beans.Subnet> subnetList = new ArrayList<org.onap.so.openstack.beans.Subnet>();
+ // create mapper from onap Subnet to openstack bean Subnet
+ if (modelMapper.getTypeMap(org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet.class,
+ org.onap.so.openstack.beans.Subnet.class) == null) {
+ PropertyMap<org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet, org.onap.so.openstack.beans.Subnet> personMap =
+ new PropertyMap<org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet, org.onap.so.openstack.beans.Subnet>() {
+ protected void configure() {
+ map().setSubnetName(source.getSubnetName());
+ map(source.getSubnetId(), destination.getSubnetId());
+ map(source.getNeutronSubnetId(), destination.getNeutronId());
+ map(source.getGatewayAddress(), destination.getGatewayIp());
+ map(source.getIpVersion(), destination.getIpVersion());
+ map(source.isDhcpEnabled(), destination.getEnableDHCP());
+ map(source.getSubnetSequence(), destination.getSubnetSequence());
+ }
+ };
+ modelMapper.addMappings(personMap);
+ }
+
+ for (org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet subnet : subnets) {
+ org.onap.so.openstack.beans.Subnet openstackSubnet =
+ modelMapper.map(subnet, org.onap.so.openstack.beans.Subnet.class);
+ // update cidr value
+ if (subnet.getNetworkStartAddress() != null && subnet.getCidrMask() != null)
+ openstackSubnet
+ .setCidr(subnet.getNetworkStartAddress().concat(FORWARD_SLASH).concat(subnet.getCidrMask()));
+ List<org.onap.so.bpmn.servicedecomposition.bbobjects.HostRoute> hostRouteList = subnet.getHostRoutes();
+ List<org.onap.so.openstack.beans.HostRoute> openstackHostRouteList = new ArrayList<>();
+ org.onap.so.openstack.beans.HostRoute openstackHostRoute = new org.onap.so.openstack.beans.HostRoute();
+ // TODO only 2 fields available on openstack object. Confirm it is sufficient or add as needed
+ for (org.onap.so.bpmn.servicedecomposition.bbobjects.HostRoute hostRoute : hostRouteList) {
+ openstackHostRoute.setNextHop(hostRoute.getNextHop());
+ openstackHostRoute.setPrefix(hostRoute.getRoutePrefix());
+ // add host route to the list
+ openstackHostRouteList.add(openstackHostRoute);
+ }
+ if (subnet.getDhcpStart() != null && !subnet.getDhcpStart().equals("")) {
+ org.onap.so.openstack.beans.Pool openstackAllocationPool = new org.onap.so.openstack.beans.Pool();
+ openstackAllocationPool.setStart(subnet.getDhcpStart());
+ openstackAllocationPool.setEnd(subnet.getDhcpEnd());
+ List<org.onap.so.openstack.beans.Pool> allocationPools = new ArrayList<>();
+ allocationPools.add(openstackAllocationPool);
+ openstackSubnet.setAllocationPools(allocationPools);
+ }
+ openstackSubnet.setHostRoutes(openstackHostRouteList);
+ // add subnet to the list
+ subnetList.add(openstackSubnet);
+ }
+ return subnetList;
+ }
+
+ private ProviderVlanNetwork buildProviderVlanNetwork(L3Network l3Network) {
+ ProviderVlanNetwork providerVlanNetwork = new ProviderVlanNetwork();
+ providerVlanNetwork.setPhysicalNetworkName(l3Network.getPhysicalNetworkName());
+ List<Integer> vlans = new ArrayList<Integer>();
+ List<org.onap.so.bpmn.servicedecomposition.bbobjects.SegmentationAssignment> segmentationAssignments =
+ l3Network.getSegmentationAssignments();
+ for (org.onap.so.bpmn.servicedecomposition.bbobjects.SegmentationAssignment assignment : segmentationAssignments) {
+ vlans.add(Integer.valueOf(assignment.getSegmentationId()));
+ }
+ providerVlanNetwork.setVlans(vlans);
+ return providerVlanNetwork;
+ }
+
+ private ContrailNetwork buildContrailNetwork(L3Network l3Network, Customer customer) {
+ ContrailNetwork contrailNetwork = new ContrailNetwork();
+ contrailNetwork.setExternal(Optional.ofNullable(l3Network.isIsExternalNetwork()).orElse(false).toString());
+ contrailNetwork.setShared(Optional.ofNullable(l3Network.isIsSharedNetwork()).orElse(false).toString());
+ contrailNetwork.setPolicyFqdns(buildPolicyFqdns(l3Network.getNetworkPolicies()));
+ contrailNetwork.setRouteTableFqdns(buildRouteTableFqdns(l3Network.getContrailNetworkRouteTableReferences()));
+ if (customer != null)
+ contrailNetwork.setRouteTargets(buildRouteTargets(customer.getVpnBindings()));
+ // PolicyFqdns(policyFqdns); --- is set in getAAINetworkPolicy
+ // RouteTableFqdns(routeTableFqdns); --- is set in getAAINetworkTableRef
+ // RouteTargets(routeTargets); --- is set in getAAINetworkVpnBinding
+ return contrailNetwork;
+ }
+
+ private List<String> buildPolicyFqdns(List<NetworkPolicy> networkPolicies) {
+ List<String> policyFqdns = new ArrayList<>();
+ for (NetworkPolicy networkPolicy : networkPolicies) {
+ policyFqdns.add(networkPolicy.getNetworkPolicyFqdn());
+ }
+ return policyFqdns;
+ }
+
+ private List<String> buildRouteTableFqdns(List<RouteTableReference> contrailNetworkRouteTableReferences) {
+ List<String> routeTableFqdns = new ArrayList<>();
+ for (RouteTableReference routeTableReference : contrailNetworkRouteTableReferences) {
+ routeTableFqdns.add(routeTableReference.getRouteTableReferenceFqdn());
+ }
+ return routeTableFqdns;
+ }
+
+ private List<RouteTarget> buildRouteTargets(List<VpnBinding> vpnBindings) {
+ if (modelMapper.getTypeMap(org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTarget.class,
+ RouteTarget.class) == null) {
+ modelMapper.addMappings(
+ new PropertyMap<org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTarget, RouteTarget>() {
+ @Override
+ protected void configure() {
+ map().setRouteTarget(source.getGlobalRouteTarget());
+ map().setRouteTargetRole(source.getRouteTargetRole());
+ }
+ });
+ }
+
+ List<RouteTarget> routeTargets = new ArrayList<>();
+ for (VpnBinding vpnBinding : vpnBindings) {
+ for (org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTarget routeTarget : vpnBinding
+ .getRouteTargets()) {
+ routeTargets.add(modelMapper.map(routeTarget, RouteTarget.class));
+ }
+ }
+ return routeTargets;
+ }
+
+ private CreateNetworkRequest setFlowFlags(CreateNetworkRequest createNetworkRequest,
+ OrchestrationContext orchestrationContext) {
+ // TODO confirm flag value
+ createNetworkRequest.setSkipAAI(true);
+ createNetworkRequest.setBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled()));
+ // TODO confirm value - false by default
+ createNetworkRequest.setFailIfExists(true);
+ // NetworkTechnology(NetworkTechnology.NEUTRON); NOOP - default
+ return createNetworkRequest;
+ }
+
+ private void setFlowFlags(UpdateNetworkRequest updateNetworkRequest, OrchestrationContext orchestrationContext) {
+ updateNetworkRequest.setSkipAAI(true);
+ updateNetworkRequest.setBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled()));
+ // NetworkTechnology(NetworkTechnology.NEUTRON); NOOP - default
+ }
+
+ private Map<String, String> addSharedAndExternal(Map<String, String> userInput, L3Network l3Network) {
+ if (userInput == null)
+ userInput = new HashMap<String, String>();
+ if (!userInput.containsKey("shared")) {
+ userInput.put("shared", Optional.ofNullable(l3Network.isIsSharedNetwork()).orElse(false).toString());
+ }
+ if (!userInput.containsKey("external")) {
+ userInput.put("external", Optional.ofNullable(l3Network.isIsExternalNetwork()).orElse(false).toString());
+ }
+ return userInput;
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfAdapterClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfAdapterClient.java
index 13739faec2..2ab337037b 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfAdapterClient.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfAdapterClient.java
@@ -32,18 +32,18 @@ import org.onap.so.adapters.vnfrest.UpdateVfModuleResponse;
public interface VnfAdapterClient {
- CreateVfModuleResponse createVfModule(String aaiVnfId, CreateVfModuleRequest req) throws VnfAdapterClientException;
+ CreateVfModuleResponse createVfModule(String aaiVnfId, CreateVfModuleRequest req) throws VnfAdapterClientException;
- RollbackVfModuleResponse rollbackVfModule(String aaiVnfId, String aaiVfModuleId, RollbackVfModuleRequest req)
- throws VnfAdapterClientException;
+ RollbackVfModuleResponse rollbackVfModule(String aaiVnfId, String aaiVfModuleId, RollbackVfModuleRequest req)
+ throws VnfAdapterClientException;
- DeleteVfModuleResponse deleteVfModule(String aaiVnfId, String aaiVfModuleId, DeleteVfModuleRequest req)
- throws VnfAdapterClientException;
+ DeleteVfModuleResponse deleteVfModule(String aaiVnfId, String aaiVfModuleId, DeleteVfModuleRequest req)
+ throws VnfAdapterClientException;
- UpdateVfModuleResponse updateVfModule(String aaiVnfId, String aaiVfModuleId, UpdateVfModuleRequest req)
- throws VnfAdapterClientException;
+ UpdateVfModuleResponse updateVfModule(String aaiVnfId, String aaiVfModuleId, UpdateVfModuleRequest req)
+ throws VnfAdapterClientException;
- QueryVfModuleResponse queryVfModule(String aaiVnfId, String aaiVfModuleId, String cloudSiteId, String tenantId,
- String vfModuleName, boolean skipAAI, String requestId, String serviceInstanceId)
- throws VnfAdapterClientException;
+ QueryVfModuleResponse queryVfModule(String aaiVnfId, String aaiVfModuleId, String cloudSiteId, String tenantId,
+ String vfModuleName, boolean skipAAI, String requestId, String serviceInstanceId)
+ throws VnfAdapterClientException;
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfAdapterClientException.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfAdapterClientException.java
index b4ad9ef055..9e58fa349b 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfAdapterClientException.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfAdapterClientException.java
@@ -22,13 +22,13 @@ package org.onap.so.client.adapter.vnf;
public class VnfAdapterClientException extends Exception {
- /**
- *
- */
- private static final long serialVersionUID = -7154784472485852602L;
+ /**
+ *
+ */
+ private static final long serialVersionUID = -7154784472485852602L;
- public VnfAdapterClientException(String message) {
- super(message);
- }
+ public VnfAdapterClientException(String message) {
+ super(message);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfAdapterClientImpl.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfAdapterClientImpl.java
index 7b9a8c5312..e24e86285c 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfAdapterClientImpl.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfAdapterClientImpl.java
@@ -23,7 +23,6 @@ package org.onap.so.client.adapter.vnf;
import javax.ws.rs.InternalServerErrorException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.UriBuilder;
-
import org.onap.so.adapters.vnfrest.CreateVfModuleRequest;
import org.onap.so.adapters.vnfrest.CreateVfModuleResponse;
import org.onap.so.adapters.vnfrest.DeleteVfModuleRequest;
@@ -39,96 +38,96 @@ import org.springframework.stereotype.Component;
@Component
public class VnfAdapterClientImpl implements VnfAdapterClient {
- private static final String VF_MODULES = "/vf-modules/";
-
- private VnfAdapterRestProperties props;
-
- public VnfAdapterClientImpl() {
- this.props = new VnfAdapterRestProperties();
- }
-
- public VnfAdapterClientImpl(VnfAdapterRestProperties props) {
- this.props = props;
- }
-
- @Override
- public CreateVfModuleResponse createVfModule(String aaiVnfId, CreateVfModuleRequest req)
- throws VnfAdapterClientException {
- try {
- return new AdapterRestClient(this.props, this.getUri("/" + aaiVnfId + "/vf-modules").build()).post(req,
- CreateVfModuleResponse.class);
- } catch (InternalServerErrorException e) {
- throw new VnfAdapterClientException(e.getMessage());
- }
- }
-
- @Override
- public RollbackVfModuleResponse rollbackVfModule(String aaiVnfId, String aaiVfModuleId, RollbackVfModuleRequest req)
- throws VnfAdapterClientException {
- try {
- return new AdapterRestClient(this.props,
- this.getUri("/" + aaiVnfId + VF_MODULES + aaiVfModuleId + "/rollback").build()).delete(req,
- RollbackVfModuleResponse.class);
- } catch (InternalServerErrorException e) {
- throw new VnfAdapterClientException(e.getMessage());
- }
- }
-
- @Override
- public DeleteVfModuleResponse deleteVfModule(String aaiVnfId, String aaiVfModuleId, DeleteVfModuleRequest req)
- throws VnfAdapterClientException {
- try {
- return new AdapterRestClient(this.props, this.getUri("/" + aaiVnfId + VF_MODULES + aaiVfModuleId).build())
- .delete(req, DeleteVfModuleResponse.class);
- } catch (InternalServerErrorException e) {
- throw new VnfAdapterClientException(e.getMessage());
- }
- }
-
- @Override
- public UpdateVfModuleResponse updateVfModule(String aaiVnfId, String aaiVfModuleId, UpdateVfModuleRequest req)
- throws VnfAdapterClientException {
- try {
- return new AdapterRestClient(this.props, this.getUri("/" + aaiVnfId + VF_MODULES + aaiVfModuleId).build())
- .put(req, UpdateVfModuleResponse.class);
- } catch (InternalServerErrorException e) {
- throw new VnfAdapterClientException(e.getMessage());
- }
- }
-
- @Override
- public QueryVfModuleResponse queryVfModule(String aaiVnfId, String aaiVfModuleId, String cloudSiteId,
- String tenantId, String vfModuleName, boolean skipAAI, String requestId, String serviceInstanceId)
- throws VnfAdapterClientException {
- UriBuilder builder = this.getUri("/" + aaiVnfId + VF_MODULES + aaiVfModuleId);
- if (cloudSiteId != null) {
- builder.queryParam("cloudSiteId", cloudSiteId);
- }
- if (tenantId != null) {
- builder.queryParam("tenantId", tenantId);
- }
- if (vfModuleName != null) {
- builder.queryParam("vfModuleName", vfModuleName);
- }
-
- builder.queryParam("skipAAI", skipAAI);
-
- if (requestId != null) {
- builder.queryParam("msoRequest.requestId", requestId);
- }
- if (serviceInstanceId != null) {
- builder.queryParam("msoRequest.serviceInstanceId", serviceInstanceId);
- }
- try {
- return new AdapterRestClient(this.props, builder.build(), MediaType.APPLICATION_JSON,
- MediaType.APPLICATION_JSON).get(QueryVfModuleResponse.class).get();
- } catch (InternalServerErrorException e) {
- throw new VnfAdapterClientException(e.getMessage());
- }
- }
-
- public UriBuilder getUri(String path) {
- return UriBuilder.fromPath(path);
- }
+ private static final String VF_MODULES = "/vf-modules/";
+
+ private VnfAdapterRestProperties props;
+
+ public VnfAdapterClientImpl() {
+ this.props = new VnfAdapterRestProperties();
+ }
+
+ public VnfAdapterClientImpl(VnfAdapterRestProperties props) {
+ this.props = props;
+ }
+
+ @Override
+ public CreateVfModuleResponse createVfModule(String aaiVnfId, CreateVfModuleRequest req)
+ throws VnfAdapterClientException {
+ try {
+ return new AdapterRestClient(this.props, this.getUri("/" + aaiVnfId + "/vf-modules").build()).post(req,
+ CreateVfModuleResponse.class);
+ } catch (InternalServerErrorException e) {
+ throw new VnfAdapterClientException(e.getMessage());
+ }
+ }
+
+ @Override
+ public RollbackVfModuleResponse rollbackVfModule(String aaiVnfId, String aaiVfModuleId, RollbackVfModuleRequest req)
+ throws VnfAdapterClientException {
+ try {
+ return new AdapterRestClient(this.props,
+ this.getUri("/" + aaiVnfId + VF_MODULES + aaiVfModuleId + "/rollback").build()).delete(req,
+ RollbackVfModuleResponse.class);
+ } catch (InternalServerErrorException e) {
+ throw new VnfAdapterClientException(e.getMessage());
+ }
+ }
+
+ @Override
+ public DeleteVfModuleResponse deleteVfModule(String aaiVnfId, String aaiVfModuleId, DeleteVfModuleRequest req)
+ throws VnfAdapterClientException {
+ try {
+ return new AdapterRestClient(this.props, this.getUri("/" + aaiVnfId + VF_MODULES + aaiVfModuleId).build())
+ .delete(req, DeleteVfModuleResponse.class);
+ } catch (InternalServerErrorException e) {
+ throw new VnfAdapterClientException(e.getMessage());
+ }
+ }
+
+ @Override
+ public UpdateVfModuleResponse updateVfModule(String aaiVnfId, String aaiVfModuleId, UpdateVfModuleRequest req)
+ throws VnfAdapterClientException {
+ try {
+ return new AdapterRestClient(this.props, this.getUri("/" + aaiVnfId + VF_MODULES + aaiVfModuleId).build())
+ .put(req, UpdateVfModuleResponse.class);
+ } catch (InternalServerErrorException e) {
+ throw new VnfAdapterClientException(e.getMessage());
+ }
+ }
+
+ @Override
+ public QueryVfModuleResponse queryVfModule(String aaiVnfId, String aaiVfModuleId, String cloudSiteId,
+ String tenantId, String vfModuleName, boolean skipAAI, String requestId, String serviceInstanceId)
+ throws VnfAdapterClientException {
+ UriBuilder builder = this.getUri("/" + aaiVnfId + VF_MODULES + aaiVfModuleId);
+ if (cloudSiteId != null) {
+ builder.queryParam("cloudSiteId", cloudSiteId);
+ }
+ if (tenantId != null) {
+ builder.queryParam("tenantId", tenantId);
+ }
+ if (vfModuleName != null) {
+ builder.queryParam("vfModuleName", vfModuleName);
+ }
+
+ builder.queryParam("skipAAI", skipAAI);
+
+ if (requestId != null) {
+ builder.queryParam("msoRequest.requestId", requestId);
+ }
+ if (serviceInstanceId != null) {
+ builder.queryParam("msoRequest.serviceInstanceId", serviceInstanceId);
+ }
+ try {
+ return new AdapterRestClient(this.props, builder.build(), MediaType.APPLICATION_JSON,
+ MediaType.APPLICATION_JSON).get(QueryVfModuleResponse.class).get();
+ } catch (InternalServerErrorException e) {
+ throw new VnfAdapterClientException(e.getMessage());
+ }
+ }
+
+ public UriBuilder getUri(String path) {
+ return UriBuilder.fromPath(path);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfAdapterRestProperties.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfAdapterRestProperties.java
index 8302375c7e..51b1525a28 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfAdapterRestProperties.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfAdapterRestProperties.java
@@ -22,7 +22,6 @@ package org.onap.so.client.adapter.vnf;
import java.net.MalformedURLException;
import java.net.URL;
-
import org.onap.so.bpmn.core.UrnPropertiesReader;
import org.onap.so.client.adapter.rest.AdapterRestProperties;
@@ -30,25 +29,26 @@ import org.onap.so.client.adapter.rest.AdapterRestProperties;
public class VnfAdapterRestProperties implements AdapterRestProperties {
- public VnfAdapterRestProperties() {
- }
-
- @Override
- public String getAuth() {
- return UrnPropertiesReader.getVariable("mso.adapters.po.auth");
- }
- @Override
- public String getKey() {
- return UrnPropertiesReader.getVariable("mso.msoKey");
- }
- @Override
- public URL getEndpoint() throws MalformedURLException {
- return new URL(UrnPropertiesReader.getVariable("mso.adapters.vnf.rest.endpoint"));
- }
-
- @Override
- public String getSystemName() {
- return "MSO";
- }
+ public VnfAdapterRestProperties() {}
+
+ @Override
+ public String getAuth() {
+ return UrnPropertiesReader.getVariable("mso.adapters.po.auth");
+ }
+
+ @Override
+ public String getKey() {
+ return UrnPropertiesReader.getVariable("mso.msoKey");
+ }
+
+ @Override
+ public URL getEndpoint() throws MalformedURLException {
+ return new URL(UrnPropertiesReader.getVariable("mso.adapters.vnf.rest.endpoint"));
+ }
+
+ @Override
+ public String getSystemName() {
+ return "MSO";
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterClient.java
index 0626efbd03..f4e4ce8cb1 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterClient.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterClient.java
@@ -31,18 +31,18 @@ import org.onap.so.adapters.vnfrest.UpdateVolumeGroupRequest;
import org.onap.so.adapters.vnfrest.UpdateVolumeGroupResponse;
public interface VnfVolumeAdapterClient {
- CreateVolumeGroupResponse createVNFVolumes(CreateVolumeGroupRequest req) throws VnfAdapterClientException;
+ CreateVolumeGroupResponse createVNFVolumes(CreateVolumeGroupRequest req) throws VnfAdapterClientException;
- DeleteVolumeGroupResponse deleteVNFVolumes(String aaiVolumeGroupId, DeleteVolumeGroupRequest req)
- throws VnfAdapterClientException;
+ DeleteVolumeGroupResponse deleteVNFVolumes(String aaiVolumeGroupId, DeleteVolumeGroupRequest req)
+ throws VnfAdapterClientException;
- RollbackVolumeGroupResponse rollbackVNFVolumes(String aaiVolumeGroupId, RollbackVolumeGroupRequest req)
- throws VnfAdapterClientException;
+ RollbackVolumeGroupResponse rollbackVNFVolumes(String aaiVolumeGroupId, RollbackVolumeGroupRequest req)
+ throws VnfAdapterClientException;
- UpdateVolumeGroupResponse updateVNFVolumes(String aaiVolumeGroupId, UpdateVolumeGroupRequest req)
- throws VnfAdapterClientException;
+ UpdateVolumeGroupResponse updateVNFVolumes(String aaiVolumeGroupId, UpdateVolumeGroupRequest req)
+ throws VnfAdapterClientException;
- QueryVolumeGroupResponse queryVNFVolumes(String aaiVolumeGroupId, String cloudSiteId, String tenantId,
- String volumeGroupStackId, Boolean skipAAI, String requestId, String serviceInstanceId)
- throws VnfAdapterClientException;
+ QueryVolumeGroupResponse queryVNFVolumes(String aaiVolumeGroupId, String cloudSiteId, String tenantId,
+ String volumeGroupStackId, Boolean skipAAI, String requestId, String serviceInstanceId)
+ throws VnfAdapterClientException;
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterClientImpl.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterClientImpl.java
index 0e0fd3bb5d..2af4d5f1fa 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterClientImpl.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterClientImpl.java
@@ -23,7 +23,6 @@ package org.onap.so.client.adapter.vnf;
import javax.ws.rs.InternalServerErrorException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.UriBuilder;
-
import org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest;
import org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse;
import org.onap.so.adapters.vnfrest.DeleteVolumeGroupRequest;
@@ -40,81 +39,81 @@ import org.springframework.stereotype.Component;
@Component
public class VnfVolumeAdapterClientImpl implements VnfVolumeAdapterClient {
- private final VnfVolumeAdapterRestProperties props;
+ private final VnfVolumeAdapterRestProperties props;
- public VnfVolumeAdapterClientImpl() {
- this.props = new VnfVolumeAdapterRestProperties();
- }
+ public VnfVolumeAdapterClientImpl() {
+ this.props = new VnfVolumeAdapterRestProperties();
+ }
- @Override
- public CreateVolumeGroupResponse createVNFVolumes(CreateVolumeGroupRequest req) throws VnfAdapterClientException {
- try {
- return this.getAdapterRestClient("").post(req, CreateVolumeGroupResponse.class);
- } catch (InternalServerErrorException e) {
- throw new VnfAdapterClientException(e.getMessage());
- }
- }
+ @Override
+ public CreateVolumeGroupResponse createVNFVolumes(CreateVolumeGroupRequest req) throws VnfAdapterClientException {
+ try {
+ return this.getAdapterRestClient("").post(req, CreateVolumeGroupResponse.class);
+ } catch (InternalServerErrorException e) {
+ throw new VnfAdapterClientException(e.getMessage());
+ }
+ }
- @Override
- public DeleteVolumeGroupResponse deleteVNFVolumes(String aaiVolumeGroupId, DeleteVolumeGroupRequest req)
- throws VnfAdapterClientException {
- try {
- return this.getAdapterRestClient("/" + aaiVolumeGroupId).delete(req, DeleteVolumeGroupResponse.class);
- } catch (InternalServerErrorException e) {
- throw new VnfAdapterClientException(e.getMessage());
- }
- }
+ @Override
+ public DeleteVolumeGroupResponse deleteVNFVolumes(String aaiVolumeGroupId, DeleteVolumeGroupRequest req)
+ throws VnfAdapterClientException {
+ try {
+ return this.getAdapterRestClient("/" + aaiVolumeGroupId).delete(req, DeleteVolumeGroupResponse.class);
+ } catch (InternalServerErrorException e) {
+ throw new VnfAdapterClientException(e.getMessage());
+ }
+ }
- @Override
- public RollbackVolumeGroupResponse rollbackVNFVolumes(String aaiVolumeGroupId, RollbackVolumeGroupRequest req)
- throws VnfAdapterClientException {
- try {
- return this.getAdapterRestClient("/" + aaiVolumeGroupId + "/rollback").delete(req,
- RollbackVolumeGroupResponse.class);
- } catch (InternalServerErrorException e) {
- throw new VnfAdapterClientException(e.getMessage());
- }
- }
+ @Override
+ public RollbackVolumeGroupResponse rollbackVNFVolumes(String aaiVolumeGroupId, RollbackVolumeGroupRequest req)
+ throws VnfAdapterClientException {
+ try {
+ return this.getAdapterRestClient("/" + aaiVolumeGroupId + "/rollback").delete(req,
+ RollbackVolumeGroupResponse.class);
+ } catch (InternalServerErrorException e) {
+ throw new VnfAdapterClientException(e.getMessage());
+ }
+ }
- @Override
- public UpdateVolumeGroupResponse updateVNFVolumes(String aaiVolumeGroupId, UpdateVolumeGroupRequest req)
- throws VnfAdapterClientException {
- try {
- return this.getAdapterRestClient("/" + aaiVolumeGroupId).put(req, UpdateVolumeGroupResponse.class);
- } catch (InternalServerErrorException e) {
- throw new VnfAdapterClientException(e.getMessage());
- }
- }
+ @Override
+ public UpdateVolumeGroupResponse updateVNFVolumes(String aaiVolumeGroupId, UpdateVolumeGroupRequest req)
+ throws VnfAdapterClientException {
+ try {
+ return this.getAdapterRestClient("/" + aaiVolumeGroupId).put(req, UpdateVolumeGroupResponse.class);
+ } catch (InternalServerErrorException e) {
+ throw new VnfAdapterClientException(e.getMessage());
+ }
+ }
- @Override
- public QueryVolumeGroupResponse queryVNFVolumes(String aaiVolumeGroupId, String cloudSiteId, String tenantId,
- String volumeGroupStackId, Boolean skipAAI, String requestId, String serviceInstanceId)
- throws VnfAdapterClientException {
- try {
- String path = buildQueryPath(aaiVolumeGroupId, cloudSiteId, tenantId, volumeGroupStackId, skipAAI,
- requestId, serviceInstanceId);
- return this.getAdapterRestClient(path).get(QueryVolumeGroupResponse.class).get();
- } catch (InternalServerErrorException e) {
- throw new VnfAdapterClientException(e.getMessage());
- }
- }
+ @Override
+ public QueryVolumeGroupResponse queryVNFVolumes(String aaiVolumeGroupId, String cloudSiteId, String tenantId,
+ String volumeGroupStackId, Boolean skipAAI, String requestId, String serviceInstanceId)
+ throws VnfAdapterClientException {
+ try {
+ String path = buildQueryPath(aaiVolumeGroupId, cloudSiteId, tenantId, volumeGroupStackId, skipAAI,
+ requestId, serviceInstanceId);
+ return this.getAdapterRestClient(path).get(QueryVolumeGroupResponse.class).get();
+ } catch (InternalServerErrorException e) {
+ throw new VnfAdapterClientException(e.getMessage());
+ }
+ }
- protected String buildQueryPath(String aaiVolumeGroupId, String cloudSiteId, String tenantId,
- String volumeGroupStackId, Boolean skipAAI, String requestId, String serviceInstanceId) {
- javax.ws.rs.core.UriBuilder builder = this.getUri("/" + aaiVolumeGroupId);
- builder.queryParam("cloudSiteId", cloudSiteId).queryParam("tenantId", tenantId)
- .queryParam("volumeGroupStackId", volumeGroupStackId).queryParam("skipAAI", skipAAI)
- .queryParam("msoRequest.requestId", requestId)
- .queryParam("msoRequest.serviceInstanceId", serviceInstanceId);
- return builder.build().toString();
- }
+ protected String buildQueryPath(String aaiVolumeGroupId, String cloudSiteId, String tenantId,
+ String volumeGroupStackId, Boolean skipAAI, String requestId, String serviceInstanceId) {
+ javax.ws.rs.core.UriBuilder builder = this.getUri("/" + aaiVolumeGroupId);
+ builder.queryParam("cloudSiteId", cloudSiteId).queryParam("tenantId", tenantId)
+ .queryParam("volumeGroupStackId", volumeGroupStackId).queryParam("skipAAI", skipAAI)
+ .queryParam("msoRequest.requestId", requestId)
+ .queryParam("msoRequest.serviceInstanceId", serviceInstanceId);
+ return builder.build().toString();
+ }
- protected UriBuilder getUri(String path) {
- return UriBuilder.fromPath(path);
- }
+ protected UriBuilder getUri(String path) {
+ return UriBuilder.fromPath(path);
+ }
- protected RestClient getAdapterRestClient(String path) {
- return new AdapterRestClient(props, this.getUri(path).build(), MediaType.APPLICATION_JSON,
- MediaType.APPLICATION_JSON);
- }
+ protected RestClient getAdapterRestClient(String path) {
+ return new AdapterRestClient(props, this.getUri(path).build(), MediaType.APPLICATION_JSON,
+ MediaType.APPLICATION_JSON);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterRestProperties.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterRestProperties.java
index 80d064249b..1f774f5be7 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterRestProperties.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterRestProperties.java
@@ -22,36 +22,36 @@ package org.onap.so.client.adapter.vnf;
import java.net.MalformedURLException;
import java.net.URL;
-
import org.onap.so.bpmn.core.UrnPropertiesReader;
import org.onap.so.client.adapter.rest.AdapterRestProperties;
public class VnfVolumeAdapterRestProperties implements AdapterRestProperties {
- protected static final String authProp = "mso.adapters.po.auth";
- protected static final String keyProp = "mso.msoKey";
- protected static final String endpointProp = "mso.adapters.volume-groups.rest.endpoint";
-
- public VnfVolumeAdapterRestProperties() {
- }
-
- @Override
- public String getAuth() {
- return UrnPropertiesReader.getVariable(authProp);
- }
- @Override
- public String getKey() {
- return UrnPropertiesReader.getVariable(keyProp);
- }
- @Override
- public URL getEndpoint() throws MalformedURLException {
- return new URL(UrnPropertiesReader.getVariable(endpointProp));
- }
-
- @Override
- public String getSystemName() {
- return "MSO";
- }
+ protected static final String authProp = "mso.adapters.po.auth";
+ protected static final String keyProp = "mso.msoKey";
+ protected static final String endpointProp = "mso.adapters.volume-groups.rest.endpoint";
+
+ public VnfVolumeAdapterRestProperties() {}
+
+ @Override
+ public String getAuth() {
+ return UrnPropertiesReader.getVariable(authProp);
+ }
+
+ @Override
+ public String getKey() {
+ return UrnPropertiesReader.getVariable(keyProp);
+ }
+
+ @Override
+ public URL getEndpoint() throws MalformedURLException {
+ return new URL(UrnPropertiesReader.getVariable(endpointProp));
+ }
+
+ @Override
+ public String getSystemName() {
+ return "MSO";
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/AttributeNameValue.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/AttributeNameValue.java
index e93e216ea3..6daed56675 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/AttributeNameValue.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/AttributeNameValue.java
@@ -51,10 +51,7 @@ public class AttributeNameValue implements Serializable {
@Override
public String toString() {
- return new StringBuilder().append("{\"attribute_name\": \"")
- .append(attributeName.toString())
- .append("\", \"attribute_value\": \"")
- .append(attributeValue.toString())
- .append("\"}").toString();
+ return new StringBuilder().append("{\"attribute_name\": \"").append(attributeName.toString())
+ .append("\", \"attribute_value\": \"").append(attributeValue.toString()).append("\"}").toString();
}
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapper.java
index 2559087619..a78870afc4 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapper.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapper.java
@@ -26,9 +26,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
-
import javax.annotation.PostConstruct;
-
import org.apache.commons.lang3.StringUtils;
import org.onap.sdnc.northbound.client.model.GenericResourceApiParam;
import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam;
@@ -46,7 +44,6 @@ import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
import org.onap.so.entity.MsoRequest;
import org.springframework.stereotype.Component;
import org.springframework.web.util.UriUtils;
-
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonMappingException;
@@ -54,129 +51,143 @@ import com.fasterxml.jackson.databind.ObjectMapper;
@Component
public class VnfAdapterObjectMapper {
- private ObjectMapper mapper = new ObjectMapper();
-
- @PostConstruct
- public void init () {
- mapper.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
- }
-
- public CreateVolumeGroupRequest createVolumeGroupRequestMapper(RequestContext requestContext, CloudRegion cloudRegion, OrchestrationContext orchestrationContext, ServiceInstance serviceInstance, GenericVnf genericVnf, VolumeGroup volumeGroup, String sdncVfModuleQueryResponse) throws JsonParseException, JsonMappingException, IOException {
- CreateVolumeGroupRequest createVolumeGroupRequest = new CreateVolumeGroupRequest();
-
- createVolumeGroupRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
- createVolumeGroupRequest.setTenantId(cloudRegion.getTenantId());
- createVolumeGroupRequest.setVolumeGroupId(volumeGroup.getVolumeGroupId());
- createVolumeGroupRequest.setVolumeGroupName(volumeGroup.getVolumeGroupName());
- createVolumeGroupRequest.setVnfType(genericVnf.getVnfType());
- createVolumeGroupRequest.setVnfVersion(serviceInstance.getModelInfoServiceInstance().getModelVersion());
- createVolumeGroupRequest.setVfModuleType(volumeGroup.getModelInfoVfModule().getModelName());
- createVolumeGroupRequest.setModelCustomizationUuid(volumeGroup.getModelInfoVfModule().getModelCustomizationUUID());
- createVolumeGroupRequest.setVolumeGroupParams(createVolumeGroupParams(requestContext,genericVnf, volumeGroup, sdncVfModuleQueryResponse));
-
- createVolumeGroupRequest.setSkipAAI(true);
- createVolumeGroupRequest.setSuppressBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled()));
- createVolumeGroupRequest.setFailIfExists(true);
-
- createVolumeGroupRequest.setMsoRequest(createMsoRequest(requestContext, serviceInstance));
-
- String messageId = getRandomUuid();
- createVolumeGroupRequest.setMessageId(messageId);
- createVolumeGroupRequest.setNotificationUrl(createCallbackUrl("VNFAResponse", messageId));
-
- return createVolumeGroupRequest;
- }
-
- public DeleteVolumeGroupRequest deleteVolumeGroupRequestMapper(RequestContext requestContext, CloudRegion cloudRegion, ServiceInstance serviceInstance, VolumeGroup volumeGroup) throws IOException {
- DeleteVolumeGroupRequest deleteVolumeGroupRequest = new DeleteVolumeGroupRequest();
-
- deleteVolumeGroupRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
- deleteVolumeGroupRequest.setTenantId(cloudRegion.getTenantId());
- deleteVolumeGroupRequest.setVolumeGroupId(volumeGroup.getVolumeGroupId());
- if (!StringUtils.isEmpty(volumeGroup.getHeatStackId())){
- deleteVolumeGroupRequest.setVolumeGroupStackId(volumeGroup.getHeatStackId());
- } else
- {
- deleteVolumeGroupRequest.setVolumeGroupStackId(volumeGroup.getVolumeGroupName());
- }
-
- deleteVolumeGroupRequest.setSkipAAI(true);
- deleteVolumeGroupRequest.setMsoRequest(createMsoRequest(requestContext, serviceInstance));
-
- String messageId = getRandomUuid();
- deleteVolumeGroupRequest.setMessageId(messageId);
- deleteVolumeGroupRequest.setNotificationUrl(createCallbackUrl("VNFAResponse", messageId));
-
- return deleteVolumeGroupRequest;
- }
-
- public Map<String, Object> createVolumeGroupParams(RequestContext requestContext,GenericVnf genericVnf, VolumeGroup volumeGroup, String sdncVfModuleQueryResponse) throws JsonParseException, JsonMappingException, IOException {
- Map<String, Object> volumeGroupParams = new HashMap<>();
- final String USER_PARAM_NAME_KEY = "name";
+ private ObjectMapper mapper = new ObjectMapper();
+
+ @PostConstruct
+ public void init() {
+ mapper.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+ }
+
+ public CreateVolumeGroupRequest createVolumeGroupRequestMapper(RequestContext requestContext,
+ CloudRegion cloudRegion, OrchestrationContext orchestrationContext, ServiceInstance serviceInstance,
+ GenericVnf genericVnf, VolumeGroup volumeGroup, String sdncVfModuleQueryResponse)
+ throws JsonParseException, JsonMappingException, IOException {
+ CreateVolumeGroupRequest createVolumeGroupRequest = new CreateVolumeGroupRequest();
+
+ createVolumeGroupRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
+ createVolumeGroupRequest.setTenantId(cloudRegion.getTenantId());
+ createVolumeGroupRequest.setVolumeGroupId(volumeGroup.getVolumeGroupId());
+ createVolumeGroupRequest.setVolumeGroupName(volumeGroup.getVolumeGroupName());
+ createVolumeGroupRequest.setVnfType(genericVnf.getVnfType());
+ createVolumeGroupRequest.setVnfVersion(serviceInstance.getModelInfoServiceInstance().getModelVersion());
+ createVolumeGroupRequest.setVfModuleType(volumeGroup.getModelInfoVfModule().getModelName());
+ createVolumeGroupRequest
+ .setModelCustomizationUuid(volumeGroup.getModelInfoVfModule().getModelCustomizationUUID());
+ createVolumeGroupRequest.setVolumeGroupParams(
+ createVolumeGroupParams(requestContext, genericVnf, volumeGroup, sdncVfModuleQueryResponse));
+
+ createVolumeGroupRequest.setSkipAAI(true);
+ createVolumeGroupRequest.setSuppressBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled()));
+ createVolumeGroupRequest.setFailIfExists(true);
+
+ createVolumeGroupRequest.setMsoRequest(createMsoRequest(requestContext, serviceInstance));
+
+ String messageId = getRandomUuid();
+ createVolumeGroupRequest.setMessageId(messageId);
+ createVolumeGroupRequest.setNotificationUrl(createCallbackUrl("VNFAResponse", messageId));
+
+ return createVolumeGroupRequest;
+ }
+
+ public DeleteVolumeGroupRequest deleteVolumeGroupRequestMapper(RequestContext requestContext,
+ CloudRegion cloudRegion, ServiceInstance serviceInstance, VolumeGroup volumeGroup) throws IOException {
+ DeleteVolumeGroupRequest deleteVolumeGroupRequest = new DeleteVolumeGroupRequest();
+
+ deleteVolumeGroupRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
+ deleteVolumeGroupRequest.setTenantId(cloudRegion.getTenantId());
+ deleteVolumeGroupRequest.setVolumeGroupId(volumeGroup.getVolumeGroupId());
+ if (!StringUtils.isEmpty(volumeGroup.getHeatStackId())) {
+ deleteVolumeGroupRequest.setVolumeGroupStackId(volumeGroup.getHeatStackId());
+ } else {
+ deleteVolumeGroupRequest.setVolumeGroupStackId(volumeGroup.getVolumeGroupName());
+ }
+
+ deleteVolumeGroupRequest.setSkipAAI(true);
+ deleteVolumeGroupRequest.setMsoRequest(createMsoRequest(requestContext, serviceInstance));
+
+ String messageId = getRandomUuid();
+ deleteVolumeGroupRequest.setMessageId(messageId);
+ deleteVolumeGroupRequest.setNotificationUrl(createCallbackUrl("VNFAResponse", messageId));
+
+ return deleteVolumeGroupRequest;
+ }
+
+ public Map<String, Object> createVolumeGroupParams(RequestContext requestContext, GenericVnf genericVnf,
+ VolumeGroup volumeGroup, String sdncVfModuleQueryResponse)
+ throws JsonParseException, JsonMappingException, IOException {
+ Map<String, Object> volumeGroupParams = new HashMap<>();
+ final String USER_PARAM_NAME_KEY = "name";
final String USER_PARAM_VALUE_KEY = "value";
- // sdncVfModuleQueryResponse will not be available in aLaCarte case
- if (sdncVfModuleQueryResponse != null) {
- GenericResourceApiVfModuleTopology vfModuleTop = mapper.readValue(sdncVfModuleQueryResponse, GenericResourceApiVfModuleTopology.class);
- GenericResourceApiVfmoduletopologyVfModuleTopology vfModuleTopology = vfModuleTop.getVfModuleTopology();
- buildParamsMapFromSdncParams(volumeGroupParams, vfModuleTopology.getVfModuleParameters());
- }
-
- if(null != requestContext.getRequestParameters() && null != requestContext.getRequestParameters().getUserParams()) {
+ // sdncVfModuleQueryResponse will not be available in aLaCarte case
+ if (sdncVfModuleQueryResponse != null) {
+ GenericResourceApiVfModuleTopology vfModuleTop =
+ mapper.readValue(sdncVfModuleQueryResponse, GenericResourceApiVfModuleTopology.class);
+ GenericResourceApiVfmoduletopologyVfModuleTopology vfModuleTopology = vfModuleTop.getVfModuleTopology();
+ buildParamsMapFromSdncParams(volumeGroupParams, vfModuleTopology.getVfModuleParameters());
+ }
+
+ if (null != requestContext.getRequestParameters()
+ && null != requestContext.getRequestParameters().getUserParams()) {
List<Map<String, Object>> userParams = requestContext.getRequestParameters().getUserParams();
for (Map<String, Object> userParamsMap : userParams) {
- if ( userParamsMap.containsKey(USER_PARAM_NAME_KEY) && (userParamsMap.get(USER_PARAM_NAME_KEY) instanceof String)
- && userParamsMap.containsKey(USER_PARAM_VALUE_KEY) && (userParamsMap.get(USER_PARAM_VALUE_KEY) instanceof String)) {
- volumeGroupParams.put((String) userParamsMap.get(USER_PARAM_NAME_KEY), (String) userParamsMap.get(USER_PARAM_VALUE_KEY));
+ if (userParamsMap.containsKey(USER_PARAM_NAME_KEY)
+ && (userParamsMap.get(USER_PARAM_NAME_KEY) instanceof String)
+ && userParamsMap.containsKey(USER_PARAM_VALUE_KEY)
+ && (userParamsMap.get(USER_PARAM_VALUE_KEY) instanceof String)) {
+ volumeGroupParams.put((String) userParamsMap.get(USER_PARAM_NAME_KEY),
+ (String) userParamsMap.get(USER_PARAM_VALUE_KEY));
}
}
}
- volumeGroupParams.put("vnf_id", genericVnf.getVnfId());
- volumeGroupParams.put("vnf_name", genericVnf.getVnfName());
- volumeGroupParams.put("vf_module_id", volumeGroup.getVolumeGroupId());
- volumeGroupParams.put("vf_module_name", volumeGroup.getVolumeGroupName());
-
- return volumeGroupParams;
- }
-
- public MsoRequest createMsoRequest(RequestContext requestContext, ServiceInstance serviceInstance) {
- MsoRequest msoRequest = new MsoRequest();
-
- msoRequest.setRequestId(requestContext.getMsoRequestId());
- msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
-
- return msoRequest;
- }
-
- private void buildParamsMapFromSdncParams(Map<String,Object> volumeGroupParams, GenericResourceApiParam sdncParameters) {
- if (sdncParameters != null) {
- List<GenericResourceApiParamParam> sdncParametersList = sdncParameters.getParam();
- if (sdncParametersList != null) {
- for (int i = 0; i < sdncParametersList.size(); i++) {
- GenericResourceApiParamParam param = sdncParametersList.get(i);
- String parameterName = param.getName();
- String parameterValue = param.getValue();
- volumeGroupParams.put(parameterName, parameterValue);
- }
- }
- }
- }
-
- protected String getRandomUuid() {
- return UUID.randomUUID().toString();
- }
-
- protected String createCallbackUrl(String messageType, String correlator) throws UnsupportedEncodingException {
- String endpoint = getProperty("mso.workflow.message.endpoint");
-
- while (endpoint.endsWith("/")) {
- endpoint = endpoint.substring(0, endpoint.length()-1);
- }
-
- return endpoint + "/" + UriUtils.encodePathSegment(messageType, "UTF-8") + "/" + UriUtils.encodePathSegment(correlator, "UTF-8");
- }
-
- protected String getProperty(String key) {
- return UrnPropertiesReader.getVariable(key);
- }
-
-} \ No newline at end of file
+ volumeGroupParams.put("vnf_id", genericVnf.getVnfId());
+ volumeGroupParams.put("vnf_name", genericVnf.getVnfName());
+ volumeGroupParams.put("vf_module_id", volumeGroup.getVolumeGroupId());
+ volumeGroupParams.put("vf_module_name", volumeGroup.getVolumeGroupName());
+
+ return volumeGroupParams;
+ }
+
+ public MsoRequest createMsoRequest(RequestContext requestContext, ServiceInstance serviceInstance) {
+ MsoRequest msoRequest = new MsoRequest();
+
+ msoRequest.setRequestId(requestContext.getMsoRequestId());
+ msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
+
+ return msoRequest;
+ }
+
+ private void buildParamsMapFromSdncParams(Map<String, Object> volumeGroupParams,
+ GenericResourceApiParam sdncParameters) {
+ if (sdncParameters != null) {
+ List<GenericResourceApiParamParam> sdncParametersList = sdncParameters.getParam();
+ if (sdncParametersList != null) {
+ for (int i = 0; i < sdncParametersList.size(); i++) {
+ GenericResourceApiParamParam param = sdncParametersList.get(i);
+ String parameterName = param.getName();
+ String parameterValue = param.getValue();
+ volumeGroupParams.put(parameterName, parameterValue);
+ }
+ }
+ }
+ }
+
+ protected String getRandomUuid() {
+ return UUID.randomUUID().toString();
+ }
+
+ protected String createCallbackUrl(String messageType, String correlator) throws UnsupportedEncodingException {
+ String endpoint = getProperty("mso.workflow.message.endpoint");
+
+ while (endpoint.endsWith("/")) {
+ endpoint = endpoint.substring(0, endpoint.length() - 1);
+ }
+
+ return endpoint + "/" + UriUtils.encodePathSegment(messageType, "UTF-8") + "/"
+ + UriUtils.encodePathSegment(correlator, "UTF-8");
+ }
+
+ protected String getProperty(String key) {
+ return UrnPropertiesReader.getVariable(key);
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapperUtils.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapperUtils.java
index 6b2d64f170..269484eadf 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapperUtils.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapperUtils.java
@@ -22,7 +22,6 @@ package org.onap.so.client.adapter.vnf.mapper;
import java.io.UnsupportedEncodingException;
import java.util.UUID;
-
import org.onap.so.bpmn.core.UrnPropertiesReader;
import org.springframework.stereotype.Component;
import org.springframework.web.util.UriUtils;
@@ -30,25 +29,25 @@ import org.springframework.web.util.UriUtils;
@Component("VnfAdapterObjectMapperUtils")
public class VnfAdapterObjectMapperUtils {
- public String getRandomUuid() {
- return UUID.randomUUID().toString();
- }
+ public String getRandomUuid() {
+ return UUID.randomUUID().toString();
+ }
- public String createCallbackUrl(String messageType, String correlator) throws UnsupportedEncodingException {
- String endpoint = getProperty("mso.workflow.message.endpoint");
- if (endpoint != null) {
- while (endpoint.endsWith("/")) {
- endpoint = endpoint.substring(0, endpoint.length() - 1);
- }
- }
+ public String createCallbackUrl(String messageType, String correlator) throws UnsupportedEncodingException {
+ String endpoint = getProperty("mso.workflow.message.endpoint");
+ if (endpoint != null) {
+ while (endpoint.endsWith("/")) {
+ endpoint = endpoint.substring(0, endpoint.length() - 1);
+ }
+ }
- return endpoint + "/" + UriUtils.encodePathSegment(messageType, "UTF-8") + "/"
- + UriUtils.encodePathSegment(correlator, "UTF-8");
- }
+ return endpoint + "/" + UriUtils.encodePathSegment(messageType, "UTF-8") + "/"
+ + UriUtils.encodePathSegment(correlator, "UTF-8");
+ }
- protected String getProperty(String key) {
+ protected String getProperty(String key) {
- return UrnPropertiesReader.getVariable(key);
- }
+ return UrnPropertiesReader.getVariable(key);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java
index dc113e5abc..94e95687db 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java
@@ -21,7 +21,6 @@
package org.onap.so.client.adapter.vnf.mapper;
import static java.util.Arrays.asList;
-
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
@@ -33,9 +32,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
-
import javax.annotation.PostConstruct;
-
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang3.StringUtils;
import org.onap.sdnc.northbound.client.model.GenericResourceApiParam;
@@ -82,7 +79,6 @@ import org.onap.so.jsonpath.JsonPathUtil;
import org.onap.so.openstack.utils.MsoMulticloudUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
@@ -93,120 +89,128 @@ import com.google.common.base.Joiner;
@Component
public class VnfAdapterVfModuleObjectMapper {
- @Autowired
- protected VnfAdapterObjectMapperUtils vnfAdapterObjectMapperUtils;
- private static List<String> sdncResponseParamsToSkip = asList("vnf_id", "vf_module_id", "vnf_name", "vf_module_name");
-
- private ObjectMapper mapper = new ObjectMapper();
- private static final JsonPathUtil jsonPath = JsonPathUtil.getInstance();
- private static final String SUB_INT = "subint";
- private static final String SUBNET_ID = "_subnet_id";
- private static final String V6_SUBNET_ID = "_v6_subnet_id";
- private static final String PORT = "port";
- private static final String SUB_INT_COUNT = "_subintcount";
- private static final String VLAN_IDS = "_vlan_ids";
- private static final String NET_NAMES = "_net_names";
- private static final String NET_IDS = "_net_ids";
- private static final String IP = "_ip";
- private static final String V6_IP = "_v6_ip";
- private static final String FLOATING_IP = "_floating_ip";
- private static final String FLOATING_V6_IP = "_floating_v6_ip";
- private static final String UNDERSCORE = "_";
-
- @PostConstruct
- public void init () {
- mapper.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
- }
-
- public CreateVfModuleRequest createVfModuleRequestMapper(RequestContext requestContext, CloudRegion cloudRegion, OrchestrationContext orchestrationContext, ServiceInstance serviceInstance, GenericVnf genericVnf,
- VfModule vfModule, VolumeGroup volumeGroup, String sdncVnfQueryResponse, String sdncVfModuleQueryResponse) throws JsonParseException, JsonMappingException, IOException {
- CreateVfModuleRequest createVfModuleRequest = new CreateVfModuleRequest();
-
- createVfModuleRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
- createVfModuleRequest.setCloudOwner(cloudRegion.getCloudOwner());
- createVfModuleRequest.setTenantId(cloudRegion.getTenantId());
- createVfModuleRequest.setVfModuleId(vfModule.getVfModuleId());
- createVfModuleRequest.setVfModuleName(vfModule.getVfModuleName());
- createVfModuleRequest.setVnfId(genericVnf.getVnfId());
- createVfModuleRequest.setVnfType(genericVnf.getVnfType());
- createVfModuleRequest.setVnfVersion(serviceInstance.getModelInfoServiceInstance().getModelVersion());
- createVfModuleRequest.setVfModuleType(vfModule.getModelInfoVfModule().getModelName());
- createVfModuleRequest.setModelCustomizationUuid(vfModule.getModelInfoVfModule().getModelCustomizationUUID());
- if (volumeGroup != null) {
- createVfModuleRequest.setVolumeGroupId(volumeGroup.getVolumeGroupId());
- createVfModuleRequest.setVolumeGroupStackId(volumeGroup.getHeatStackId());
- }
- VfModule baseVfModule = getBaseVfModule(genericVnf);
- if (baseVfModule != null) {
- createVfModuleRequest.setBaseVfModuleId(baseVfModule.getVfModuleId());
- createVfModuleRequest.setBaseVfModuleStackId(baseVfModule.getHeatStackId());
- }
- createVfModuleRequest.setVfModuleParams(buildVfModuleParamsMap(requestContext, serviceInstance, genericVnf, vfModule, sdncVnfQueryResponse, sdncVfModuleQueryResponse));
-
- createVfModuleRequest.setSkipAAI(true);
- createVfModuleRequest.setBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled()));
- createVfModuleRequest.setFailIfExists(true);
-
- MsoRequest msoRequest = buildMsoRequest(requestContext, serviceInstance);
- createVfModuleRequest.setMsoRequest(msoRequest);
-
- String messageId = vnfAdapterObjectMapperUtils.getRandomUuid();
- createVfModuleRequest.setMessageId(messageId);
- createVfModuleRequest.setNotificationUrl(vnfAdapterObjectMapperUtils.createCallbackUrl("VNFAResponse", messageId));
-
- return createVfModuleRequest;
- }
-
- private MsoRequest buildMsoRequest(RequestContext requestContext,ServiceInstance serviceInstance) {
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId(requestContext.getMsoRequestId());
- msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
- return msoRequest;
- }
-
- private Map<String,Object> buildVfModuleParamsMap(RequestContext requestContext, ServiceInstance serviceInstance, GenericVnf genericVnf,
- VfModule vfModule, String sdncVnfQueryResponse, String sdncVfModuleQueryResponse) throws JsonParseException, JsonMappingException, IOException {
-
-
- GenericResourceApiVnfTopology vnfTop= mapper.readValue(sdncVnfQueryResponse, GenericResourceApiVnfTopology.class);
- GenericResourceApiVfModuleTopology vfModuleTop = mapper.readValue(sdncVfModuleQueryResponse, GenericResourceApiVfModuleTopology.class);
- GenericResourceApiVnftopologyVnfTopology vnfTopology = vnfTop.getVnfTopology();
- GenericResourceApiVfmoduletopologyVfModuleTopology vfModuleTopology = vfModuleTop.getVfModuleTopology();
- Map<String,Object> paramsMap = new HashMap<>();
-
- if( vfModuleTopology.getSdncGeneratedCloudResources()) {
- buildParamsMapFromVfModuleSdncResponse(paramsMap, vfModuleTopology, true);
- buildParamsMapFromVnfSdncResponse(paramsMap, vnfTopology, null, true);
- }
- else {
- Map<String,String> networkRoleMap = buildNetworkRoleMap(vfModuleTopology);
- buildParamsMapFromVfModuleSdncResponse(paramsMap, vfModuleTopology, false);
- buildParamsMapFromVnfSdncResponse(paramsMap, vnfTopology, networkRoleMap, false);
- }
-
- // build the sdnc_directives from paramsMap
- buildDirectivesParamFromMap(paramsMap, MsoMulticloudUtils.SDNC_DIRECTIVES, paramsMap);
- buildDirectivesParamFromMap(paramsMap, MsoMulticloudUtils.USER_DIRECTIVES, requestContext.getUserParams());
-
- buildMandatoryParamsMap(paramsMap, serviceInstance, genericVnf, vfModule);
-
- // Parameters received from the request should overwrite any parameters received from SDNC
- paramsMap.putAll(requestContext.getUserParams());
-
- if (vfModule.getCloudParams() != null) {
- paramsMap.putAll(vfModule.getCloudParams());
- }
- return paramsMap;
- }
-
- private void buildDirectivesParamFromMap(Map<String, Object> paramsMap, String directive, Map<String, Object> srcMap) {
+ @Autowired
+ protected VnfAdapterObjectMapperUtils vnfAdapterObjectMapperUtils;
+ private static List<String> sdncResponseParamsToSkip =
+ asList("vnf_id", "vf_module_id", "vnf_name", "vf_module_name");
+
+ private ObjectMapper mapper = new ObjectMapper();
+ private static final JsonPathUtil jsonPath = JsonPathUtil.getInstance();
+ private static final String SUB_INT = "subint";
+ private static final String SUBNET_ID = "_subnet_id";
+ private static final String V6_SUBNET_ID = "_v6_subnet_id";
+ private static final String PORT = "port";
+ private static final String SUB_INT_COUNT = "_subintcount";
+ private static final String VLAN_IDS = "_vlan_ids";
+ private static final String NET_NAMES = "_net_names";
+ private static final String NET_IDS = "_net_ids";
+ private static final String IP = "_ip";
+ private static final String V6_IP = "_v6_ip";
+ private static final String FLOATING_IP = "_floating_ip";
+ private static final String FLOATING_V6_IP = "_floating_v6_ip";
+ private static final String UNDERSCORE = "_";
+
+ @PostConstruct
+ public void init() {
+ mapper.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
+ }
+
+ public CreateVfModuleRequest createVfModuleRequestMapper(RequestContext requestContext, CloudRegion cloudRegion,
+ OrchestrationContext orchestrationContext, ServiceInstance serviceInstance, GenericVnf genericVnf,
+ VfModule vfModule, VolumeGroup volumeGroup, String sdncVnfQueryResponse, String sdncVfModuleQueryResponse)
+ throws JsonParseException, JsonMappingException, IOException {
+ CreateVfModuleRequest createVfModuleRequest = new CreateVfModuleRequest();
+
+ createVfModuleRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
+ createVfModuleRequest.setCloudOwner(cloudRegion.getCloudOwner());
+ createVfModuleRequest.setTenantId(cloudRegion.getTenantId());
+ createVfModuleRequest.setVfModuleId(vfModule.getVfModuleId());
+ createVfModuleRequest.setVfModuleName(vfModule.getVfModuleName());
+ createVfModuleRequest.setVnfId(genericVnf.getVnfId());
+ createVfModuleRequest.setVnfType(genericVnf.getVnfType());
+ createVfModuleRequest.setVnfVersion(serviceInstance.getModelInfoServiceInstance().getModelVersion());
+ createVfModuleRequest.setVfModuleType(vfModule.getModelInfoVfModule().getModelName());
+ createVfModuleRequest.setModelCustomizationUuid(vfModule.getModelInfoVfModule().getModelCustomizationUUID());
+ if (volumeGroup != null) {
+ createVfModuleRequest.setVolumeGroupId(volumeGroup.getVolumeGroupId());
+ createVfModuleRequest.setVolumeGroupStackId(volumeGroup.getHeatStackId());
+ }
+ VfModule baseVfModule = getBaseVfModule(genericVnf);
+ if (baseVfModule != null) {
+ createVfModuleRequest.setBaseVfModuleId(baseVfModule.getVfModuleId());
+ createVfModuleRequest.setBaseVfModuleStackId(baseVfModule.getHeatStackId());
+ }
+ createVfModuleRequest.setVfModuleParams(buildVfModuleParamsMap(requestContext, serviceInstance, genericVnf,
+ vfModule, sdncVnfQueryResponse, sdncVfModuleQueryResponse));
+
+ createVfModuleRequest.setSkipAAI(true);
+ createVfModuleRequest.setBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled()));
+ createVfModuleRequest.setFailIfExists(true);
+
+ MsoRequest msoRequest = buildMsoRequest(requestContext, serviceInstance);
+ createVfModuleRequest.setMsoRequest(msoRequest);
+
+ String messageId = vnfAdapterObjectMapperUtils.getRandomUuid();
+ createVfModuleRequest.setMessageId(messageId);
+ createVfModuleRequest
+ .setNotificationUrl(vnfAdapterObjectMapperUtils.createCallbackUrl("VNFAResponse", messageId));
+
+ return createVfModuleRequest;
+ }
+
+ private MsoRequest buildMsoRequest(RequestContext requestContext, ServiceInstance serviceInstance) {
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId(requestContext.getMsoRequestId());
+ msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
+ return msoRequest;
+ }
+
+ private Map<String, Object> buildVfModuleParamsMap(RequestContext requestContext, ServiceInstance serviceInstance,
+ GenericVnf genericVnf, VfModule vfModule, String sdncVnfQueryResponse, String sdncVfModuleQueryResponse)
+ throws JsonParseException, JsonMappingException, IOException {
+
+
+ GenericResourceApiVnfTopology vnfTop =
+ mapper.readValue(sdncVnfQueryResponse, GenericResourceApiVnfTopology.class);
+ GenericResourceApiVfModuleTopology vfModuleTop =
+ mapper.readValue(sdncVfModuleQueryResponse, GenericResourceApiVfModuleTopology.class);
+ GenericResourceApiVnftopologyVnfTopology vnfTopology = vnfTop.getVnfTopology();
+ GenericResourceApiVfmoduletopologyVfModuleTopology vfModuleTopology = vfModuleTop.getVfModuleTopology();
+ Map<String, Object> paramsMap = new HashMap<>();
+
+ if (vfModuleTopology.getSdncGeneratedCloudResources()) {
+ buildParamsMapFromVfModuleSdncResponse(paramsMap, vfModuleTopology, true);
+ buildParamsMapFromVnfSdncResponse(paramsMap, vnfTopology, null, true);
+ } else {
+ Map<String, String> networkRoleMap = buildNetworkRoleMap(vfModuleTopology);
+ buildParamsMapFromVfModuleSdncResponse(paramsMap, vfModuleTopology, false);
+ buildParamsMapFromVnfSdncResponse(paramsMap, vnfTopology, networkRoleMap, false);
+ }
+
+ // build the sdnc_directives from paramsMap
+ buildDirectivesParamFromMap(paramsMap, MsoMulticloudUtils.SDNC_DIRECTIVES, paramsMap);
+ buildDirectivesParamFromMap(paramsMap, MsoMulticloudUtils.USER_DIRECTIVES, requestContext.getUserParams());
+
+ buildMandatoryParamsMap(paramsMap, serviceInstance, genericVnf, vfModule);
+
+ // Parameters received from the request should overwrite any parameters received from SDNC
+ paramsMap.putAll(requestContext.getUserParams());
+
+ if (vfModule.getCloudParams() != null) {
+ paramsMap.putAll(vfModule.getCloudParams());
+ }
+ return paramsMap;
+ }
+
+ private void buildDirectivesParamFromMap(Map<String, Object> paramsMap, String directive,
+ Map<String, Object> srcMap) {
StringBuilder directives = new StringBuilder();
if (srcMap.size() > 0) {
directives.append("{ \"attributes\": [ ");
int i = 0;
for (String attributeName : srcMap.keySet()) {
directives.append(new AttributeNameValue(attributeName, srcMap.get(attributeName).toString()));
- if (i < (srcMap.size()-1))
+ if (i < (srcMap.size() - 1))
directives.append(", ");
i++;
}
@@ -217,636 +221,679 @@ public class VnfAdapterVfModuleObjectMapper {
paramsMap.put(directive, directives.toString());
}
- private void buildMandatoryParamsMap(Map<String,Object> paramsMap, ServiceInstance serviceInstance, GenericVnf genericVnf, VfModule vfModule) {
- paramsMap.put("vnf_id", genericVnf.getVnfId());
- paramsMap.put("vnf_name", genericVnf.getVnfName());
- paramsMap.put("vf_module_id", vfModule.getVfModuleId());
- paramsMap.put("vf_module_name", vfModule.getVfModuleName());
- paramsMap.put("environment_context",serviceInstance.getModelInfoServiceInstance().getEnvironmentContext());
- paramsMap.putIfAbsent("environment_context", "");
- paramsMap.put("workload_context", serviceInstance.getModelInfoServiceInstance().getWorkloadContext());
- paramsMap.putIfAbsent("workload_context", "");
- Integer vfModuleIndex = vfModule.getModuleIndex();
- if (vfModuleIndex != null) {
- paramsMap.put("vf_module_index", vfModuleIndex.toString());
- }
- }
-
- private void buildParamsMapFromVnfSdncResponse(Map<String,Object> paramsMap, GenericResourceApiVnftopologyVnfTopology vnfTopology, Map<String,String> networkRoleMap, boolean skipVnfResourceAssignments) throws JsonParseException, JsonMappingException, IOException {
- // Get VNF parameters from SDNC response
- GenericResourceApiParam vnfParametersData = vnfTopology.getVnfParametersData();
- buildParamsMapFromSdncParams(paramsMap, vnfParametersData);
-
- if(!skipVnfResourceAssignments) {
- GenericResourceApiVnfresourceassignmentsVnfResourceAssignments vnfResourceAssignments = vnfTopology.getVnfResourceAssignments();
- if (vnfResourceAssignments != null) {
- // Availability Zones
- buildAvailabilityZones(paramsMap, vnfResourceAssignments);
- // VNF Networks
- buildVnfNetworks(paramsMap, vnfResourceAssignments, networkRoleMap);
- }
- }
- }
-
- private void buildAvailabilityZones (Map<String,Object> paramsMap, GenericResourceApiVnfresourceassignmentsVnfResourceAssignments vnfResourceAssignments) {
- GenericResourceApiVnfresourceassignmentsVnfresourceassignmentsAvailabilityZones availabilityZones = vnfResourceAssignments.getAvailabilityZones();
- if (availabilityZones != null) {
- List<String> availabilityZonesList = availabilityZones.getAvailabilityZone();
- if (availabilityZonesList != null) {
- for(int i = 0; i < availabilityZonesList.size(); i++) {
- paramsMap.put("availability_zone_" + i, availabilityZonesList.get(i));
- }
- }
- }
- }
-
- private void buildVnfNetworks (Map<String,Object> paramsMap, GenericResourceApiVnfresourceassignmentsVnfResourceAssignments vnfResourceAssignments, Map<String,String> networkRoleMap) {
- GenericResourceApiVnfresourceassignmentsVnfresourceassignmentsVnfNetworks vnfNetworks = vnfResourceAssignments.getVnfNetworks();
- if (vnfNetworks != null) {
- List<GenericResourceApiVnfNetworkData> vnfNetworksList = vnfNetworks.getVnfNetwork();
- if (vnfNetworksList != null) {
- for (int i = 0; i < vnfNetworksList.size(); i++) {
- GenericResourceApiVnfNetworkData vnfNetwork = vnfNetworksList.get(i);
- String networkRole = vnfNetwork.getNetworkRole();
- String vnfNetworkKey = networkRoleMap.get(networkRole);
- if (vnfNetworkKey == null || vnfNetworkKey.isEmpty()) {
- vnfNetworkKey = networkRole;
- }
-
- String vnfNetworkNeutronIdValue = vnfNetwork.getNeutronId();
- paramsMap.put(vnfNetworkKey + "_net_id", vnfNetworkNeutronIdValue);
- String vnfNetworkNetNameValue = vnfNetwork.getNetworkName();
- paramsMap.put(vnfNetworkKey + "_net_name", vnfNetworkNetNameValue);
- String vnfNetworkNetFqdnValue = vnfNetwork.getContrailNetworkFqdn();
- paramsMap.put(vnfNetworkKey + "_net_fqdn", vnfNetworkNetFqdnValue);
-
- buildVnfNetworkSubnets(paramsMap, vnfNetwork, vnfNetworkKey);
-
- }
- }
- }
- }
-
- private void buildVnfNetworkSubnets(Map<String,Object> paramsMap, GenericResourceApiVnfNetworkData vnfNetwork, String vnfNetworkKey) {
- String vnfNetworkString = convertToString(vnfNetwork);
- Optional<String> ipv4Ips = jsonPath.locateResult(vnfNetworkString, "$.subnets-data.subnet-data[*].[?(@.ip-version == 'ipv4' && @.dhcp-enabled == 'Y')].subnet-id");
- if(ipv4Ips.isPresent())
- addPairToMap(paramsMap, vnfNetworkKey, SUBNET_ID, ipv4Ips.get());
-
- Optional<String> ipv6Ips = jsonPath.locateResult(vnfNetworkString, "$.subnets-data.subnet-data[*].[?(@.ip-version == 'ipv6' && @.dhcp-enabled == 'Y')].subnet-id");
- if(ipv6Ips.isPresent())
- addPairToMap(paramsMap, vnfNetworkKey, V6_SUBNET_ID, ipv6Ips.get());
- }
-
- private void buildParamsMapFromVfModuleSdncResponse(Map<String,Object> paramsMap, GenericResourceApiVfmoduletopologyVfModuleTopology vfModuleTopology, boolean skipVfModuleAssignments) throws JsonParseException, JsonMappingException, IOException {
- // Get VF Module parameters from SDNC response
- GenericResourceApiParam vfModuleParametersData = vfModuleTopology.getVfModuleParameters();
- buildParamsMapFromSdncParams(paramsMap, vfModuleParametersData);
-
- if(!skipVfModuleAssignments) {
- GenericResourceApiVfmoduleassignmentsVfModuleAssignments vfModuleAssignments = vfModuleTopology.getVfModuleAssignments();
- if (vfModuleAssignments != null) {
- // VNF-VMS
- GenericResourceApiVfmoduleassignmentsVfmoduleassignmentsVms vms = vfModuleAssignments.getVms();
- if (vms != null) {
- List<GenericResourceApiVmTopologyData> vmsList = vms.getVm();
- if (vmsList != null) {
- for (GenericResourceApiVmTopologyData vm : vmsList){
- String key = vm.getVmType();
- buildVfModuleVmNames(paramsMap, vm, key);
- GenericResourceApiVmtopologydataVmNetworks vmNetworks = vm.getVmNetworks();
- if (vmNetworks != null) {
- List<GenericResourceApiVmNetworkData> vmNetworksList = vmNetworks.getVmNetwork();
- if (vmNetworksList != null) {
- for(int n = 0; n < vmNetworksList.size(); n++){
- GenericResourceApiVmNetworkData network = vmNetworksList.get(n);
- network.getNetworkRoleTag();
- String networkKey = network.getNetworkRole();
- // Floating IPs
- buildVfModuleFloatingIps(paramsMap, network, key, networkKey);
- // Interface Route Prefixes
- buildVfModuleInterfaceRoutePrefixes(paramsMap, network, key, networkKey);
- // SRIOV Parameters
- buildVfModuleSriovParameters(paramsMap, network, networkKey);
- // IPV4 and IPV6 Addresses
- buildVfModuleNetworkInformation(paramsMap, network, key, networkKey);
-
- buildVlanInformation(paramsMap, network, key, networkKey);
-
- }
- }
- }
-
- buildParamsMapFromVfModuleForHeatTemplate(paramsMap, vm);
- }
- }
- }
- }
- }
- }
-
- protected void buildVlanInformation(Map<String, Object> paramsMap,
- GenericResourceApiVmNetworkData network, String key, String networkKey) {
-
- String networkString = convertToString(network);
- String vlanFilterKey = key + UNDERSCORE + networkKey + UNDERSCORE + "vlan_filter";
- String privateVlansKey = key + UNDERSCORE + networkKey + UNDERSCORE + "private_vlans";
- String publicVlansKey = key + UNDERSCORE + networkKey + UNDERSCORE + "public_vlans";
- String guestVlansKey = key + UNDERSCORE + networkKey + UNDERSCORE + "guest_vlans";
-
- if (network.getSegmentationId() != null) {
- paramsMap.put(vlanFilterKey, network.getSegmentationId());
- }
-
- List<String> privateVlans = jsonPath.locateResultList(networkString, "$.related-networks.related-network[?(@.vlan-tags.is-private == true)].vlan-tags.upper-tag-id");
- List<String> publicVlans = jsonPath.locateResultList(networkString, "$.related-networks.related-network[?(@.vlan-tags.is-private == false)].vlan-tags.upper-tag-id");
- List<String> concat = new ArrayList<>(privateVlans);
- concat.addAll(publicVlans);
- Collection<String> guestVlans = new HashSet<>(concat);
-
- if (!privateVlans.isEmpty()) {
- paramsMap.put(privateVlansKey, Joiner.on(",").join(privateVlans));
- }
- if (!publicVlans.isEmpty()) {
- paramsMap.put(publicVlansKey, Joiner.on(",").join(publicVlans));
- }
- if (!guestVlans.isEmpty()) {
- paramsMap.put(guestVlansKey, Joiner.on(",").join(guestVlans));
- }
- }
-
- private void buildVfModuleVmNames(Map<String,Object> paramsMap, GenericResourceApiVmTopologyData vm, String key) {
- String values = "";
- GenericResourceApiVmtopologydataVmNames vmNames = vm.getVmNames();
- if (vmNames != null) {
- List<String> valueList = vmNames.getVmName();
- if (valueList != null) {
- for(int i = 0; i < valueList.size(); i++){
- String value = valueList.get(i);
- if (i != valueList.size() - 1) {
- values += value + ",";
- }
- else {
- values += value;
- }
- paramsMap.put(key + "_name_" + i, value);
- }
- paramsMap.put(key + "_names", values);
- }
- }
- }
-
- private void buildVfModuleFloatingIps(Map<String,Object> paramsMap, GenericResourceApiVmNetworkData network, String key, String networkKey) {
- GenericResourceApiVmnetworkdataFloatingIps floatingIps = network.getFloatingIps();
- if (floatingIps != null) {
- List<String> floatingIpV4List = floatingIps.getFloatingIpV4();
- if (floatingIpV4List != null) {
- // add only one ipv4 floating ip for now
- String floatingIPKey = key + UNDERSCORE + networkKey + FLOATING_IP;
- String floatingIPKeyValue = floatingIpV4List.get(0);
- if (floatingIPKeyValue != null && !floatingIPKeyValue.isEmpty()) {
- paramsMap.put(floatingIPKey, floatingIPKeyValue);
- }
- }
- // add only one ipv6 floating ip for now
- List<String> floatingIpV6List = floatingIps.getFloatingIpV6();
- if (floatingIpV6List != null) {
- String floatingIPV6Key = key + UNDERSCORE + networkKey + FLOATING_V6_IP;
- String floatingIPV6KeyValue = floatingIpV6List.get(0);
- if (floatingIPV6KeyValue != null && !floatingIPV6KeyValue.isEmpty()) {
- paramsMap.put(floatingIPV6Key, floatingIPV6KeyValue);
- }
- }
- }
- }
-
- private void buildVfModuleInterfaceRoutePrefixes(Map<String,Object> paramsMap, GenericResourceApiVmNetworkData network, String key, String networkKey) {
- GenericResourceApiVmnetworkdataInterfaceRoutePrefixes interfaceRoutePrefixes = network.getInterfaceRoutePrefixes();
- if (interfaceRoutePrefixes != null) {
- List<String> interfaceRoutePrefixesList = interfaceRoutePrefixes.getInterfaceRoutePrefix();
- StringBuilder sbInterfaceRoutePrefixes = new StringBuilder();
- sbInterfaceRoutePrefixes.append("[");
- if (interfaceRoutePrefixesList != null) {
- for(int a = 0; a < interfaceRoutePrefixesList.size(); a++){
- String interfaceRoutePrefixValue = interfaceRoutePrefixesList.get(a);
- if (a != interfaceRoutePrefixesList.size() - 1) {
- sbInterfaceRoutePrefixes.append("{\"interface_route_table_routes_route_prefix\": \"" + interfaceRoutePrefixValue + "\"}" + ",");
- }
- else {
- sbInterfaceRoutePrefixes.append("{\"interface_route_table_routes_route_prefix\": \"" + interfaceRoutePrefixValue + "\"}");
- }
- }
- sbInterfaceRoutePrefixes.append("]");
- if (interfaceRoutePrefixesList.size() > 0) {
- paramsMap.put(key + UNDERSCORE + networkKey + "_route_prefixes", sbInterfaceRoutePrefixes.toString());
- }
- }
- }
- }
-
- private void buildVfModuleSriovParameters(Map<String,Object> paramsMap, GenericResourceApiVmNetworkData network, String networkKey) {
- // SRIOV Parameters
- GenericResourceApiVmnetworkdataSriovParameters sriovParameters = network.getSriovParameters();
- if (sriovParameters != null) {
- GenericResourceApiVmnetworkdataSriovparametersHeatVlanFilters heatVlanFilters = sriovParameters.getHeatVlanFilters();
- if (heatVlanFilters != null) {
- List<String> heatVlanFiltersList = heatVlanFilters.getHeatVlanFilter();
- StringBuilder sriovFilterBuf = new StringBuilder();
- if (heatVlanFiltersList != null) {
- for(int a = 0; a < heatVlanFiltersList.size(); a++){
- String heatVlanFilterValue = heatVlanFiltersList.get(a);
- if (a != heatVlanFiltersList.size() - 1) {
- sriovFilterBuf.append(heatVlanFilterValue).append(",");
- }
- else {
- sriovFilterBuf.append(heatVlanFilterValue);
- }
- }
- if (heatVlanFiltersList.size() > 0) {
- paramsMap.put(networkKey + "_ATT_VF_VLAN_FILTER", sriovFilterBuf.toString());
- }
- }
- }
- }
- }
-
- private void buildVfModuleNetworkInformation(Map<String,Object> paramsMap, GenericResourceApiVmNetworkData network, String key, String networkKey) {
-
- GenericResourceApiVmnetworkdataNetworkInformationItems networkInformationItems = network.getNetworkInformationItems();
- StringBuilder sbIpv4Ips = new StringBuilder();
- StringBuilder sbIpv6Ips = new StringBuilder();
-
- if (networkInformationItems != null) {
- List<GenericResourceApiVmnetworkdataNetworkinformationitemsNetworkInformationItem> networkInformationItemList = networkInformationItems.getNetworkInformationItem();
- if (networkInformationItemList != null) {
- for(int a = 0; a < networkInformationItemList.size(); a++){
- GenericResourceApiVmnetworkdataNetworkinformationitemsNetworkInformationItem ipAddress = networkInformationItemList.get(a);
- if (ipAddress != null) {
- GenericResourceApiVmnetworkdataNetworkinformationitemsNetworkinformationitemNetworkIps ips = ipAddress.getNetworkIps();
- if (ips != null) {
- List<String> ipsList = ips.getNetworkIp();
- if (ipsList != null) {
- String ipVersion = ipAddress.getIpVersion();
- for (int b = 0; b < ipsList.size(); b++) {
- String ipAddressValue = ipsList.get(b);
- if (ipVersion.equals("ipv4")) {
- if (b != ipsList.size() - 1) {
- sbIpv4Ips.append(ipAddressValue + ",");
- }
- else {
- sbIpv4Ips.append(ipAddressValue);
- }
- paramsMap.put(key + UNDERSCORE + networkKey + IP + UNDERSCORE + b, ipAddressValue);
- }
- else if (ipVersion.equals("ipv6")) {
- if (b != ipsList.size() - 1) {
- sbIpv6Ips.append(ipAddressValue + ",");
- }
- else {
- sbIpv6Ips.append(ipAddressValue);
- }
- paramsMap.put(key + UNDERSCORE + networkKey + V6_IP + UNDERSCORE + b, ipAddressValue);
- }
- }
- paramsMap.put(key + UNDERSCORE + networkKey + "_ips", sbIpv4Ips.toString());
- paramsMap.put(key + UNDERSCORE + networkKey + "_v6_ips", sbIpv6Ips.toString());
- }
- }
- }
- }
- }
- }
- }
-
- /*
- * Build Mapping from GenericResourceApi SDNC for Heat Template so that AIC - PO gets accurate requests for vf module assignments.
- * Build Count of SubInterfaces, VLAN Tag, network_name, network_id,
- * ip_address (V4 and V6) and Floating IPs Addresses (V4 and V6) for Heat Template
- */
- private void buildParamsMapFromVfModuleForHeatTemplate(Map<String,Object> paramsMap, GenericResourceApiVmTopologyData vm) {
- GenericResourceApiVmtopologydataVmNames vmNames = vm.getVmNames();
-
- if (vmNames != null) {
-
- List<GenericResourceApiVmtopologydataVmnamesVnfcNames> vnfcNamesList = vmNames.getVnfcNames();
- if (vnfcNamesList != null) {
-
- for(int i = 0; i < vnfcNamesList.size(); i++){
-
- GenericResourceApiVmtopologydataVmnamesVnfcNames vnfcNames = vnfcNamesList.get(i);
- parseVnfcNamesData(paramsMap, vnfcNames);
- }
- }
- }
- }
-
- /*
- * Parse vnfcNames data to build Mapping from GenericResourceApi SDNC for Heat Template.
- */
- private void parseVnfcNamesData(Map<String,Object> paramsMap, GenericResourceApiVmtopologydataVmnamesVnfcNames vnfcNames) {
-
- if (vnfcNames != null) {
- GenericResourceApiVnfcNetworkData vnfcNetworks = vnfcNames.getVnfcNetworks();
- if (vnfcNetworks != null) {
- List<GenericResourceApiVnfcnetworkdataVnfcNetworkData> vnfcNetworkdataList = vnfcNetworks.getVnfcNetworkData();
-
- if (vnfcNetworkdataList != null) {
-
- for(int networkDataIdx = 0; networkDataIdx < vnfcNetworkdataList.size(); networkDataIdx++){
-
- GenericResourceApiVnfcnetworkdataVnfcNetworkData vnfcNetworkdata = vnfcNetworkdataList.get(networkDataIdx);
- parseVnfcNetworkData(paramsMap, vnfcNetworkdata, networkDataIdx);
- }
- }
- }
- }
- }
-
- /*
- * Parse VnfcNetworkData to build Mapping from GenericResourceApi SDNC for Heat Template.
- * Build Count of SubInterfaces, VLAN Tag, network_name, network_id,
- * ip_address (V4 and V6) and Floating IPs Addresses (V4 and V6) for Heat Template
- */
- private void parseVnfcNetworkData(Map<String,Object> paramsMap, GenericResourceApiVnfcnetworkdataVnfcNetworkData vnfcNetworkdata, int networkDataIdx) {
-
- String vmTypeKey = vnfcNetworkdata.getVnfcType();
- GenericResourceApiVnfcnetworkdataVnfcnetworkdataVnfcPorts vnfcPorts = vnfcNetworkdata.getVnfcPorts();
- if (vnfcPorts != null) {
- List<GenericResourceApiVnfcnetworkdataVnfcnetworkdataVnfcportsVnfcPort> vnfcPortList = vnfcPorts.getVnfcPort();
- if (vnfcPortList != null) {
- for(int portIdx = 0; portIdx < vnfcPortList.size(); portIdx++){
-
- GenericResourceApiVnfcnetworkdataVnfcnetworkdataVnfcportsVnfcPort vnfcPort = vnfcPortList.get(portIdx);
- GenericResourceApiSubInterfaceNetworkData vnicSubInterfaces = vnfcPort.getVnicSubInterfaces();
-
- String vnicSubInterfacesString = convertToString(vnicSubInterfaces);
- String networkRoleKey = vnfcPort.getCommonSubInterfaceRole();
- String subInterfaceKey = createVnfcSubInterfaceKey(vmTypeKey, networkDataIdx, networkRoleKey, portIdx);
- String globalSubInterfaceKey = createGlobalVnfcSubInterfaceKey(vmTypeKey, networkRoleKey, portIdx);
-
- buildVfModuleSubInterfacesCount(paramsMap, globalSubInterfaceKey, vnicSubInterfaces);
-
- buildVfModuleVlanTag(paramsMap, subInterfaceKey, vnicSubInterfacesString);
-
- buildVfModuleNetworkName(paramsMap, subInterfaceKey, vnicSubInterfacesString);
-
- buildVfModuleNetworkId(paramsMap, subInterfaceKey, vnicSubInterfacesString);
-
- buildVfModuleIpV4AddressHeatTemplate(paramsMap, subInterfaceKey, vnicSubInterfacesString);
-
- buildVfModuleIpV6AddressHeatTemplate(paramsMap, subInterfaceKey, vnicSubInterfacesString);
-
- buildVfModuleFloatingIpV4HeatTemplate(paramsMap, globalSubInterfaceKey, vnicSubInterfacesString);
-
- buildVfModuleFloatingIpV6HeatTemplate(paramsMap, globalSubInterfaceKey, vnicSubInterfacesString);
- }
- }
- }
- }
-
- /*
- * Build "count" (calculating the total number of sub-interfaces) for Heat Template
- * Building Criteria : {vm-type}_subint_{network-role}_port_{index}_subintcount
- * vmTypeKey = vm-type, networkRoleKey = common-sub-interface-role
- * Example: fw_subint_ctrl_port_0_subintcount
- *
- */
- private void buildVfModuleSubInterfacesCount(Map<String,Object> paramsMap, String keyPrefix, GenericResourceApiSubInterfaceNetworkData vnicSubInterfaces) {
+ private void buildMandatoryParamsMap(Map<String, Object> paramsMap, ServiceInstance serviceInstance,
+ GenericVnf genericVnf, VfModule vfModule) {
+ paramsMap.put("vnf_id", genericVnf.getVnfId());
+ paramsMap.put("vnf_name", genericVnf.getVnfName());
+ paramsMap.put("vf_module_id", vfModule.getVfModuleId());
+ paramsMap.put("vf_module_name", vfModule.getVfModuleName());
+ paramsMap.put("environment_context", serviceInstance.getModelInfoServiceInstance().getEnvironmentContext());
+ paramsMap.putIfAbsent("environment_context", "");
+ paramsMap.put("workload_context", serviceInstance.getModelInfoServiceInstance().getWorkloadContext());
+ paramsMap.putIfAbsent("workload_context", "");
+ Integer vfModuleIndex = vfModule.getModuleIndex();
+ if (vfModuleIndex != null) {
+ paramsMap.put("vf_module_index", vfModuleIndex.toString());
+ }
+ }
+
+ private void buildParamsMapFromVnfSdncResponse(Map<String, Object> paramsMap,
+ GenericResourceApiVnftopologyVnfTopology vnfTopology, Map<String, String> networkRoleMap,
+ boolean skipVnfResourceAssignments) throws JsonParseException, JsonMappingException, IOException {
+ // Get VNF parameters from SDNC response
+ GenericResourceApiParam vnfParametersData = vnfTopology.getVnfParametersData();
+ buildParamsMapFromSdncParams(paramsMap, vnfParametersData);
+
+ if (!skipVnfResourceAssignments) {
+ GenericResourceApiVnfresourceassignmentsVnfResourceAssignments vnfResourceAssignments =
+ vnfTopology.getVnfResourceAssignments();
+ if (vnfResourceAssignments != null) {
+ // Availability Zones
+ buildAvailabilityZones(paramsMap, vnfResourceAssignments);
+ // VNF Networks
+ buildVnfNetworks(paramsMap, vnfResourceAssignments, networkRoleMap);
+ }
+ }
+ }
+
+ private void buildAvailabilityZones(Map<String, Object> paramsMap,
+ GenericResourceApiVnfresourceassignmentsVnfResourceAssignments vnfResourceAssignments) {
+ GenericResourceApiVnfresourceassignmentsVnfresourceassignmentsAvailabilityZones availabilityZones =
+ vnfResourceAssignments.getAvailabilityZones();
+ if (availabilityZones != null) {
+ List<String> availabilityZonesList = availabilityZones.getAvailabilityZone();
+ if (availabilityZonesList != null) {
+ for (int i = 0; i < availabilityZonesList.size(); i++) {
+ paramsMap.put("availability_zone_" + i, availabilityZonesList.get(i));
+ }
+ }
+ }
+ }
+
+ private void buildVnfNetworks(Map<String, Object> paramsMap,
+ GenericResourceApiVnfresourceassignmentsVnfResourceAssignments vnfResourceAssignments,
+ Map<String, String> networkRoleMap) {
+ GenericResourceApiVnfresourceassignmentsVnfresourceassignmentsVnfNetworks vnfNetworks =
+ vnfResourceAssignments.getVnfNetworks();
+ if (vnfNetworks != null) {
+ List<GenericResourceApiVnfNetworkData> vnfNetworksList = vnfNetworks.getVnfNetwork();
+ if (vnfNetworksList != null) {
+ for (int i = 0; i < vnfNetworksList.size(); i++) {
+ GenericResourceApiVnfNetworkData vnfNetwork = vnfNetworksList.get(i);
+ String networkRole = vnfNetwork.getNetworkRole();
+ String vnfNetworkKey = networkRoleMap.get(networkRole);
+ if (vnfNetworkKey == null || vnfNetworkKey.isEmpty()) {
+ vnfNetworkKey = networkRole;
+ }
+
+ String vnfNetworkNeutronIdValue = vnfNetwork.getNeutronId();
+ paramsMap.put(vnfNetworkKey + "_net_id", vnfNetworkNeutronIdValue);
+ String vnfNetworkNetNameValue = vnfNetwork.getNetworkName();
+ paramsMap.put(vnfNetworkKey + "_net_name", vnfNetworkNetNameValue);
+ String vnfNetworkNetFqdnValue = vnfNetwork.getContrailNetworkFqdn();
+ paramsMap.put(vnfNetworkKey + "_net_fqdn", vnfNetworkNetFqdnValue);
+
+ buildVnfNetworkSubnets(paramsMap, vnfNetwork, vnfNetworkKey);
+
+ }
+ }
+ }
+ }
+
+ private void buildVnfNetworkSubnets(Map<String, Object> paramsMap, GenericResourceApiVnfNetworkData vnfNetwork,
+ String vnfNetworkKey) {
+ String vnfNetworkString = convertToString(vnfNetwork);
+ Optional<String> ipv4Ips = jsonPath.locateResult(vnfNetworkString,
+ "$.subnets-data.subnet-data[*].[?(@.ip-version == 'ipv4' && @.dhcp-enabled == 'Y')].subnet-id");
+ if (ipv4Ips.isPresent())
+ addPairToMap(paramsMap, vnfNetworkKey, SUBNET_ID, ipv4Ips.get());
+
+ Optional<String> ipv6Ips = jsonPath.locateResult(vnfNetworkString,
+ "$.subnets-data.subnet-data[*].[?(@.ip-version == 'ipv6' && @.dhcp-enabled == 'Y')].subnet-id");
+ if (ipv6Ips.isPresent())
+ addPairToMap(paramsMap, vnfNetworkKey, V6_SUBNET_ID, ipv6Ips.get());
+ }
+
+ private void buildParamsMapFromVfModuleSdncResponse(Map<String, Object> paramsMap,
+ GenericResourceApiVfmoduletopologyVfModuleTopology vfModuleTopology, boolean skipVfModuleAssignments)
+ throws JsonParseException, JsonMappingException, IOException {
+ // Get VF Module parameters from SDNC response
+ GenericResourceApiParam vfModuleParametersData = vfModuleTopology.getVfModuleParameters();
+ buildParamsMapFromSdncParams(paramsMap, vfModuleParametersData);
+
+ if (!skipVfModuleAssignments) {
+ GenericResourceApiVfmoduleassignmentsVfModuleAssignments vfModuleAssignments =
+ vfModuleTopology.getVfModuleAssignments();
+ if (vfModuleAssignments != null) {
+ // VNF-VMS
+ GenericResourceApiVfmoduleassignmentsVfmoduleassignmentsVms vms = vfModuleAssignments.getVms();
+ if (vms != null) {
+ List<GenericResourceApiVmTopologyData> vmsList = vms.getVm();
+ if (vmsList != null) {
+ for (GenericResourceApiVmTopologyData vm : vmsList) {
+ String key = vm.getVmType();
+ buildVfModuleVmNames(paramsMap, vm, key);
+ GenericResourceApiVmtopologydataVmNetworks vmNetworks = vm.getVmNetworks();
+ if (vmNetworks != null) {
+ List<GenericResourceApiVmNetworkData> vmNetworksList = vmNetworks.getVmNetwork();
+ if (vmNetworksList != null) {
+ for (int n = 0; n < vmNetworksList.size(); n++) {
+ GenericResourceApiVmNetworkData network = vmNetworksList.get(n);
+ network.getNetworkRoleTag();
+ String networkKey = network.getNetworkRole();
+ // Floating IPs
+ buildVfModuleFloatingIps(paramsMap, network, key, networkKey);
+ // Interface Route Prefixes
+ buildVfModuleInterfaceRoutePrefixes(paramsMap, network, key, networkKey);
+ // SRIOV Parameters
+ buildVfModuleSriovParameters(paramsMap, network, networkKey);
+ // IPV4 and IPV6 Addresses
+ buildVfModuleNetworkInformation(paramsMap, network, key, networkKey);
+
+ buildVlanInformation(paramsMap, network, key, networkKey);
+
+ }
+ }
+ }
+
+ buildParamsMapFromVfModuleForHeatTemplate(paramsMap, vm);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ protected void buildVlanInformation(Map<String, Object> paramsMap, GenericResourceApiVmNetworkData network,
+ String key, String networkKey) {
+
+ String networkString = convertToString(network);
+ String vlanFilterKey = key + UNDERSCORE + networkKey + UNDERSCORE + "vlan_filter";
+ String privateVlansKey = key + UNDERSCORE + networkKey + UNDERSCORE + "private_vlans";
+ String publicVlansKey = key + UNDERSCORE + networkKey + UNDERSCORE + "public_vlans";
+ String guestVlansKey = key + UNDERSCORE + networkKey + UNDERSCORE + "guest_vlans";
+
+ if (network.getSegmentationId() != null) {
+ paramsMap.put(vlanFilterKey, network.getSegmentationId());
+ }
+
+ List<String> privateVlans = jsonPath.locateResultList(networkString,
+ "$.related-networks.related-network[?(@.vlan-tags.is-private == true)].vlan-tags.upper-tag-id");
+ List<String> publicVlans = jsonPath.locateResultList(networkString,
+ "$.related-networks.related-network[?(@.vlan-tags.is-private == false)].vlan-tags.upper-tag-id");
+ List<String> concat = new ArrayList<>(privateVlans);
+ concat.addAll(publicVlans);
+ Collection<String> guestVlans = new HashSet<>(concat);
+
+ if (!privateVlans.isEmpty()) {
+ paramsMap.put(privateVlansKey, Joiner.on(",").join(privateVlans));
+ }
+ if (!publicVlans.isEmpty()) {
+ paramsMap.put(publicVlansKey, Joiner.on(",").join(publicVlans));
+ }
+ if (!guestVlans.isEmpty()) {
+ paramsMap.put(guestVlansKey, Joiner.on(",").join(guestVlans));
+ }
+ }
+
+ private void buildVfModuleVmNames(Map<String, Object> paramsMap, GenericResourceApiVmTopologyData vm, String key) {
+ String values = "";
+ GenericResourceApiVmtopologydataVmNames vmNames = vm.getVmNames();
+ if (vmNames != null) {
+ List<String> valueList = vmNames.getVmName();
+ if (valueList != null) {
+ for (int i = 0; i < valueList.size(); i++) {
+ String value = valueList.get(i);
+ if (i != valueList.size() - 1) {
+ values += value + ",";
+ } else {
+ values += value;
+ }
+ paramsMap.put(key + "_name_" + i, value);
+ }
+ paramsMap.put(key + "_names", values);
+ }
+ }
+ }
+
+ private void buildVfModuleFloatingIps(Map<String, Object> paramsMap, GenericResourceApiVmNetworkData network,
+ String key, String networkKey) {
+ GenericResourceApiVmnetworkdataFloatingIps floatingIps = network.getFloatingIps();
+ if (floatingIps != null) {
+ List<String> floatingIpV4List = floatingIps.getFloatingIpV4();
+ if (floatingIpV4List != null) {
+ // add only one ipv4 floating ip for now
+ String floatingIPKey = key + UNDERSCORE + networkKey + FLOATING_IP;
+ String floatingIPKeyValue = floatingIpV4List.get(0);
+ if (floatingIPKeyValue != null && !floatingIPKeyValue.isEmpty()) {
+ paramsMap.put(floatingIPKey, floatingIPKeyValue);
+ }
+ }
+ // add only one ipv6 floating ip for now
+ List<String> floatingIpV6List = floatingIps.getFloatingIpV6();
+ if (floatingIpV6List != null) {
+ String floatingIPV6Key = key + UNDERSCORE + networkKey + FLOATING_V6_IP;
+ String floatingIPV6KeyValue = floatingIpV6List.get(0);
+ if (floatingIPV6KeyValue != null && !floatingIPV6KeyValue.isEmpty()) {
+ paramsMap.put(floatingIPV6Key, floatingIPV6KeyValue);
+ }
+ }
+ }
+ }
+
+ private void buildVfModuleInterfaceRoutePrefixes(Map<String, Object> paramsMap,
+ GenericResourceApiVmNetworkData network, String key, String networkKey) {
+ GenericResourceApiVmnetworkdataInterfaceRoutePrefixes interfaceRoutePrefixes =
+ network.getInterfaceRoutePrefixes();
+ if (interfaceRoutePrefixes != null) {
+ List<String> interfaceRoutePrefixesList = interfaceRoutePrefixes.getInterfaceRoutePrefix();
+ StringBuilder sbInterfaceRoutePrefixes = new StringBuilder();
+ sbInterfaceRoutePrefixes.append("[");
+ if (interfaceRoutePrefixesList != null) {
+ for (int a = 0; a < interfaceRoutePrefixesList.size(); a++) {
+ String interfaceRoutePrefixValue = interfaceRoutePrefixesList.get(a);
+ if (a != interfaceRoutePrefixesList.size() - 1) {
+ sbInterfaceRoutePrefixes.append("{\"interface_route_table_routes_route_prefix\": \""
+ + interfaceRoutePrefixValue + "\"}" + ",");
+ } else {
+ sbInterfaceRoutePrefixes.append("{\"interface_route_table_routes_route_prefix\": \""
+ + interfaceRoutePrefixValue + "\"}");
+ }
+ }
+ sbInterfaceRoutePrefixes.append("]");
+ if (interfaceRoutePrefixesList.size() > 0) {
+ paramsMap.put(key + UNDERSCORE + networkKey + "_route_prefixes",
+ sbInterfaceRoutePrefixes.toString());
+ }
+ }
+ }
+ }
+
+ private void buildVfModuleSriovParameters(Map<String, Object> paramsMap, GenericResourceApiVmNetworkData network,
+ String networkKey) {
+ // SRIOV Parameters
+ GenericResourceApiVmnetworkdataSriovParameters sriovParameters = network.getSriovParameters();
+ if (sriovParameters != null) {
+ GenericResourceApiVmnetworkdataSriovparametersHeatVlanFilters heatVlanFilters =
+ sriovParameters.getHeatVlanFilters();
+ if (heatVlanFilters != null) {
+ List<String> heatVlanFiltersList = heatVlanFilters.getHeatVlanFilter();
+ StringBuilder sriovFilterBuf = new StringBuilder();
+ if (heatVlanFiltersList != null) {
+ for (int a = 0; a < heatVlanFiltersList.size(); a++) {
+ String heatVlanFilterValue = heatVlanFiltersList.get(a);
+ if (a != heatVlanFiltersList.size() - 1) {
+ sriovFilterBuf.append(heatVlanFilterValue).append(",");
+ } else {
+ sriovFilterBuf.append(heatVlanFilterValue);
+ }
+ }
+ if (heatVlanFiltersList.size() > 0) {
+ paramsMap.put(networkKey + "_ATT_VF_VLAN_FILTER", sriovFilterBuf.toString());
+ }
+ }
+ }
+ }
+ }
+
+ private void buildVfModuleNetworkInformation(Map<String, Object> paramsMap, GenericResourceApiVmNetworkData network,
+ String key, String networkKey) {
+
+ GenericResourceApiVmnetworkdataNetworkInformationItems networkInformationItems =
+ network.getNetworkInformationItems();
+ StringBuilder sbIpv4Ips = new StringBuilder();
+ StringBuilder sbIpv6Ips = new StringBuilder();
+
+ if (networkInformationItems != null) {
+ List<GenericResourceApiVmnetworkdataNetworkinformationitemsNetworkInformationItem> networkInformationItemList =
+ networkInformationItems.getNetworkInformationItem();
+ if (networkInformationItemList != null) {
+ for (int a = 0; a < networkInformationItemList.size(); a++) {
+ GenericResourceApiVmnetworkdataNetworkinformationitemsNetworkInformationItem ipAddress =
+ networkInformationItemList.get(a);
+ if (ipAddress != null) {
+ GenericResourceApiVmnetworkdataNetworkinformationitemsNetworkinformationitemNetworkIps ips =
+ ipAddress.getNetworkIps();
+ if (ips != null) {
+ List<String> ipsList = ips.getNetworkIp();
+ if (ipsList != null) {
+ String ipVersion = ipAddress.getIpVersion();
+ for (int b = 0; b < ipsList.size(); b++) {
+ String ipAddressValue = ipsList.get(b);
+ if (ipVersion.equals("ipv4")) {
+ if (b != ipsList.size() - 1) {
+ sbIpv4Ips.append(ipAddressValue + ",");
+ } else {
+ sbIpv4Ips.append(ipAddressValue);
+ }
+ paramsMap.put(key + UNDERSCORE + networkKey + IP + UNDERSCORE + b,
+ ipAddressValue);
+ } else if (ipVersion.equals("ipv6")) {
+ if (b != ipsList.size() - 1) {
+ sbIpv6Ips.append(ipAddressValue + ",");
+ } else {
+ sbIpv6Ips.append(ipAddressValue);
+ }
+ paramsMap.put(key + UNDERSCORE + networkKey + V6_IP + UNDERSCORE + b,
+ ipAddressValue);
+ }
+ }
+ paramsMap.put(key + UNDERSCORE + networkKey + "_ips", sbIpv4Ips.toString());
+ paramsMap.put(key + UNDERSCORE + networkKey + "_v6_ips", sbIpv6Ips.toString());
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /*
+ * Build Mapping from GenericResourceApi SDNC for Heat Template so that AIC - PO gets accurate requests for vf
+ * module assignments. Build Count of SubInterfaces, VLAN Tag, network_name, network_id, ip_address (V4 and V6) and
+ * Floating IPs Addresses (V4 and V6) for Heat Template
+ */
+ private void buildParamsMapFromVfModuleForHeatTemplate(Map<String, Object> paramsMap,
+ GenericResourceApiVmTopologyData vm) {
+ GenericResourceApiVmtopologydataVmNames vmNames = vm.getVmNames();
+
+ if (vmNames != null) {
+
+ List<GenericResourceApiVmtopologydataVmnamesVnfcNames> vnfcNamesList = vmNames.getVnfcNames();
+ if (vnfcNamesList != null) {
+
+ for (int i = 0; i < vnfcNamesList.size(); i++) {
+
+ GenericResourceApiVmtopologydataVmnamesVnfcNames vnfcNames = vnfcNamesList.get(i);
+ parseVnfcNamesData(paramsMap, vnfcNames);
+ }
+ }
+ }
+ }
+
+ /*
+ * Parse vnfcNames data to build Mapping from GenericResourceApi SDNC for Heat Template.
+ */
+ private void parseVnfcNamesData(Map<String, Object> paramsMap,
+ GenericResourceApiVmtopologydataVmnamesVnfcNames vnfcNames) {
+
+ if (vnfcNames != null) {
+ GenericResourceApiVnfcNetworkData vnfcNetworks = vnfcNames.getVnfcNetworks();
+ if (vnfcNetworks != null) {
+ List<GenericResourceApiVnfcnetworkdataVnfcNetworkData> vnfcNetworkdataList =
+ vnfcNetworks.getVnfcNetworkData();
+
+ if (vnfcNetworkdataList != null) {
+
+ for (int networkDataIdx = 0; networkDataIdx < vnfcNetworkdataList.size(); networkDataIdx++) {
+
+ GenericResourceApiVnfcnetworkdataVnfcNetworkData vnfcNetworkdata =
+ vnfcNetworkdataList.get(networkDataIdx);
+ parseVnfcNetworkData(paramsMap, vnfcNetworkdata, networkDataIdx);
+ }
+ }
+ }
+ }
+ }
+
+ /*
+ * Parse VnfcNetworkData to build Mapping from GenericResourceApi SDNC for Heat Template. Build Count of
+ * SubInterfaces, VLAN Tag, network_name, network_id, ip_address (V4 and V6) and Floating IPs Addresses (V4 and V6)
+ * for Heat Template
+ */
+ private void parseVnfcNetworkData(Map<String, Object> paramsMap,
+ GenericResourceApiVnfcnetworkdataVnfcNetworkData vnfcNetworkdata, int networkDataIdx) {
+
+ String vmTypeKey = vnfcNetworkdata.getVnfcType();
+ GenericResourceApiVnfcnetworkdataVnfcnetworkdataVnfcPorts vnfcPorts = vnfcNetworkdata.getVnfcPorts();
+ if (vnfcPorts != null) {
+ List<GenericResourceApiVnfcnetworkdataVnfcnetworkdataVnfcportsVnfcPort> vnfcPortList =
+ vnfcPorts.getVnfcPort();
+ if (vnfcPortList != null) {
+ for (int portIdx = 0; portIdx < vnfcPortList.size(); portIdx++) {
+
+ GenericResourceApiVnfcnetworkdataVnfcnetworkdataVnfcportsVnfcPort vnfcPort =
+ vnfcPortList.get(portIdx);
+ GenericResourceApiSubInterfaceNetworkData vnicSubInterfaces = vnfcPort.getVnicSubInterfaces();
+
+ String vnicSubInterfacesString = convertToString(vnicSubInterfaces);
+ String networkRoleKey = vnfcPort.getCommonSubInterfaceRole();
+ String subInterfaceKey =
+ createVnfcSubInterfaceKey(vmTypeKey, networkDataIdx, networkRoleKey, portIdx);
+ String globalSubInterfaceKey = createGlobalVnfcSubInterfaceKey(vmTypeKey, networkRoleKey, portIdx);
+
+ buildVfModuleSubInterfacesCount(paramsMap, globalSubInterfaceKey, vnicSubInterfaces);
+
+ buildVfModuleVlanTag(paramsMap, subInterfaceKey, vnicSubInterfacesString);
+
+ buildVfModuleNetworkName(paramsMap, subInterfaceKey, vnicSubInterfacesString);
+
+ buildVfModuleNetworkId(paramsMap, subInterfaceKey, vnicSubInterfacesString);
+
+ buildVfModuleIpV4AddressHeatTemplate(paramsMap, subInterfaceKey, vnicSubInterfacesString);
+
+ buildVfModuleIpV6AddressHeatTemplate(paramsMap, subInterfaceKey, vnicSubInterfacesString);
+
+ buildVfModuleFloatingIpV4HeatTemplate(paramsMap, globalSubInterfaceKey, vnicSubInterfacesString);
+
+ buildVfModuleFloatingIpV6HeatTemplate(paramsMap, globalSubInterfaceKey, vnicSubInterfacesString);
+ }
+ }
+ }
+ }
+
+ /*
+ * Build "count" (calculating the total number of sub-interfaces) for Heat Template Building Criteria :
+ * {vm-type}_subint_{network-role}_port_{index}_subintcount vmTypeKey = vm-type, networkRoleKey =
+ * common-sub-interface-role Example: fw_subint_ctrl_port_0_subintcount
+ *
+ */
+ private void buildVfModuleSubInterfacesCount(Map<String, Object> paramsMap, String keyPrefix,
+ GenericResourceApiSubInterfaceNetworkData vnicSubInterfaces) {
+
+ List<GenericResourceApiSubinterfacenetworkdataSubInterfaceNetworkData> subInterfaceNetworkDataList =
+ vnicSubInterfaces.getSubInterfaceNetworkData();
+
+ if ((subInterfaceNetworkDataList != null) && !subInterfaceNetworkDataList.isEmpty()) {
+ addPairToMap(paramsMap, keyPrefix, SUB_INT_COUNT, String.valueOf(subInterfaceNetworkDataList.size()));
+ }
+ }
+
+ protected String createVnfcSubInterfaceKey(String vmTypeKey, int networkDataIdx, String networkRoleKey,
+ int portIdx) {
+
+ return Joiner.on(UNDERSCORE)
+ .join(Arrays.asList(vmTypeKey, networkDataIdx, SUB_INT, networkRoleKey, PORT, portIdx));
+ }
+
+ protected String createGlobalVnfcSubInterfaceKey(String vmTypeKey, String networkRoleKey, int portIdx) {
+
+ return Joiner.on(UNDERSCORE).join(Arrays.asList(vmTypeKey, SUB_INT, networkRoleKey, PORT, portIdx));
+ }
+
+ /*
+ * Build VLAN Tag for Heat Template Building Criteria :
+ * {vm-type}_{index}_subint_{network-role}_port_{index}_vlan_ids vmTypeKey = vm-type, networkRoleKey =
+ * common-sub-interface-role Example: fw_0_subint_ctrl_port_0_vlan_ids
+ *
+ */
+ protected void buildVfModuleVlanTag(Map<String, Object> paramsMap, String keyPrefix, String vnicSubInterfaces) {
+
+ List<String> vlanTagIds =
+ jsonPath.locateResultList(vnicSubInterfaces, "$.sub-interface-network-data[*].vlan-tag-id");
+
+ addPairToMap(paramsMap, keyPrefix, VLAN_IDS, vlanTagIds);
+ }
+
+ /*
+ * Build "network_name" for Heat Template Building Criteria :
+ * {vm-type}_{index}_subint_{network-role}_port_{index}_net_names vmTypeKey = vm-type, networkRoleKey =
+ * common-sub-interface-role Example: fw_0_subint_ctrl_port_0_net_names
+ *
+ */
+ protected void buildVfModuleNetworkName(Map<String, Object> paramsMap, String keyPrefix, String vnicSubInterfaces) {
+
+ List<String> neworkNames =
+ jsonPath.locateResultList(vnicSubInterfaces, "$.sub-interface-network-data[*].network-name");
+
+ addPairToMap(paramsMap, keyPrefix, NET_NAMES, neworkNames);
+ }
+
+ /*
+ * Build "network_id" for Heat Template Building Criteria :
+ * {vm-type}_{index}_subint_{network-role}_port_{index}_net_ids vmTypeKey = vm-type, networkRoleKey =
+ * common-sub-interface-role Example: fw_0_subint_ctrl_port_0_net_ids
+ *
+ */
+ protected void buildVfModuleNetworkId(Map<String, Object> paramsMap, String keyPrefix, String vnicSubInterfaces) {
+
+ List<String> neworkIds =
+ jsonPath.locateResultList(vnicSubInterfaces, "$.sub-interface-network-data[*].network-id");
+
+ addPairToMap(paramsMap, keyPrefix, NET_IDS, neworkIds);
+ }
+
+ /*
+ * Build ip_address for V4 for Heat Template Building Criteria :
+ * {vm-type}_{index}_subint_{network-role}_port_{index}_ip_{index} -- for ipV4 key = vm-type, networkRoleKey =
+ * NetWork-Role
+ */
+ protected void buildVfModuleIpV4AddressHeatTemplate(Map<String, Object> paramsMap, String keyPrefix,
+ String vnicSubInterfaces) {
+
+ List<String> ipv4Ips = jsonPath.locateResultList(vnicSubInterfaces,
+ "$.sub-interface-network-data[*].network-information-items.network-information-item[?(@.ip-version == 'ipv4')].network-ips.network-ip[*]");
+
+ addPairToMap(paramsMap, keyPrefix, IP, ipv4Ips);
+
+ for (int i = 0; i < ipv4Ips.size(); i++) {
+ addPairToMap(paramsMap, keyPrefix, IP + UNDERSCORE + i, ipv4Ips.get(i));
+ }
+
+ }
+
+ /*
+ * Build ip_address for Heat Template Building Criteria :
+ * {vm-type}_{index}_subint_{network-role}_port_{index}_v6_ip_{index} -- for ipV6 key = vm-type, networkRoleKey =
+ * NetWork-Role
+ */
+ protected void buildVfModuleIpV6AddressHeatTemplate(Map<String, Object> paramsMap, String keyPrefix,
+ String vnicSubInterfaces) {
+
+ List<String> ipv6Ips = jsonPath.locateResultList(vnicSubInterfaces,
+ "$.sub-interface-network-data[*].network-information-items.network-information-item[?(@.ip-version == 'ipv6')].network-ips.network-ip[*]");
- List<GenericResourceApiSubinterfacenetworkdataSubInterfaceNetworkData> subInterfaceNetworkDataList = vnicSubInterfaces.getSubInterfaceNetworkData();
+ addPairToMap(paramsMap, keyPrefix, V6_IP, ipv6Ips);
- if ( (subInterfaceNetworkDataList != null) && !subInterfaceNetworkDataList.isEmpty() ) {
- addPairToMap(paramsMap, keyPrefix, SUB_INT_COUNT, String.valueOf(subInterfaceNetworkDataList.size()));
- }
+ for (int i = 0; i < ipv6Ips.size(); i++) {
+ addPairToMap(paramsMap, keyPrefix, V6_IP + UNDERSCORE + i, ipv6Ips.get(i));
+ }
}
- protected String createVnfcSubInterfaceKey(String vmTypeKey, int networkDataIdx, String networkRoleKey, int portIdx) {
+ /*
+ * Build floatingip_address for Heat Template Building Criteria :
+ * {vm-type}_subint_{network-role}_port_{index}_floating_ip -- for ipV4
+ */
+ protected void buildVfModuleFloatingIpV4HeatTemplate(Map<String, Object> paramsMap, String keyPrefix,
+ String vnicSubInterfaces) {
- return Joiner.on(UNDERSCORE).join(Arrays.asList(vmTypeKey, networkDataIdx, SUB_INT, networkRoleKey, PORT, portIdx));
- }
+ List<String> floatingV4 = jsonPath.locateResultList(vnicSubInterfaces,
+ "$.sub-interface-network-data[*].floating-ips.floating-ip-v4[*]");
- protected String createGlobalVnfcSubInterfaceKey(String vmTypeKey,String networkRoleKey, int portIdx) {
+ if (!floatingV4.isEmpty()) {
+ floatingV4 = Collections.singletonList(floatingV4.get(0));
+ }
+ addPairToMap(paramsMap, keyPrefix, FLOATING_IP, floatingV4);
- return Joiner.on(UNDERSCORE).join(Arrays.asList(vmTypeKey, SUB_INT, networkRoleKey, PORT, portIdx));
- }
+ }
- /*
- * Build VLAN Tag for Heat Template
- * Building Criteria : {vm-type}_{index}_subint_{network-role}_port_{index}_vlan_ids
- * vmTypeKey = vm-type, networkRoleKey = common-sub-interface-role
- * Example: fw_0_subint_ctrl_port_0_vlan_ids
- *
- */
- protected void buildVfModuleVlanTag(Map<String,Object> paramsMap, String keyPrefix, String vnicSubInterfaces) {
+ /*
+ * Build floatingip_address for Heat Template Building Criteria :
+ * {vm-type}_subint_{network-role}_port_{index}_floating_v6_ip -- for ipV6
+ */
+ protected void buildVfModuleFloatingIpV6HeatTemplate(Map<String, Object> paramsMap, String keyPrefix,
+ String vnicSubInterfaces) {
- List<String> vlanTagIds = jsonPath.locateResultList(vnicSubInterfaces, "$.sub-interface-network-data[*].vlan-tag-id");
+ List<String> floatingV6 = jsonPath.locateResultList(vnicSubInterfaces,
+ "$.sub-interface-network-data[*].floating-ips.floating-ip-v6[*]");
- addPairToMap(paramsMap, keyPrefix, VLAN_IDS, vlanTagIds);
- }
- /*
- * Build "network_name" for Heat Template
- * Building Criteria : {vm-type}_{index}_subint_{network-role}_port_{index}_net_names
- * vmTypeKey = vm-type, networkRoleKey = common-sub-interface-role
- * Example: fw_0_subint_ctrl_port_0_net_names
- *
- */
- protected void buildVfModuleNetworkName(Map<String,Object> paramsMap, String keyPrefix, String vnicSubInterfaces) {
+ if (!floatingV6.isEmpty()) {
+ floatingV6 = Collections.singletonList(floatingV6.get(0));
+ }
+ addPairToMap(paramsMap, keyPrefix, FLOATING_V6_IP, floatingV6);
+ }
- List<String> neworkNames = jsonPath.locateResultList(vnicSubInterfaces, "$.sub-interface-network-data[*].network-name");
+ protected void addPairToMap(Map<String, Object> paramsMap, String keyPrefix, String key, String value) {
- addPairToMap(paramsMap, keyPrefix, NET_NAMES, neworkNames);
- }
+ addPairToMap(paramsMap, keyPrefix, key, Collections.singletonList(value));
+ }
- /*
- * Build "network_id" for Heat Template
- * Building Criteria : {vm-type}_{index}_subint_{network-role}_port_{index}_net_ids
- * vmTypeKey = vm-type, networkRoleKey = common-sub-interface-role
- * Example: fw_0_subint_ctrl_port_0_net_ids
- *
- */
- protected void buildVfModuleNetworkId(Map<String,Object> paramsMap, String keyPrefix, String vnicSubInterfaces) {
+ protected void addPairToMap(Map<String, Object> paramsMap, String keyPrefix, String key, List<String> value) {
- List<String> neworkIds = jsonPath.locateResultList(vnicSubInterfaces, "$.sub-interface-network-data[*].network-id");
+ if (!value.isEmpty()) {
+ paramsMap.put(keyPrefix + key, Joiner.on(",").join(value));
+ }
+ }
- addPairToMap(paramsMap, keyPrefix, NET_IDS, neworkIds);
- }
-
- /*
- * Build ip_address for V4 for Heat Template
- * Building Criteria :
- * {vm-type}_{index}_subint_{network-role}_port_{index}_ip_{index} -- for ipV4
- * key = vm-type, networkRoleKey = NetWork-Role
- */
- protected void buildVfModuleIpV4AddressHeatTemplate(Map<String,Object> paramsMap, String keyPrefix, String vnicSubInterfaces) {
-
- List<String> ipv4Ips = jsonPath.locateResultList(vnicSubInterfaces, "$.sub-interface-network-data[*].network-information-items.network-information-item[?(@.ip-version == 'ipv4')].network-ips.network-ip[*]");
-
- addPairToMap(paramsMap, keyPrefix, IP, ipv4Ips);
-
- for (int i = 0; i < ipv4Ips.size(); i++) {
- addPairToMap(paramsMap, keyPrefix, IP + UNDERSCORE + i, ipv4Ips.get(i));
- }
-
- }
-
- /*
- * Build ip_address for Heat Template
- * Building Criteria :
- * {vm-type}_{index}_subint_{network-role}_port_{index}_v6_ip_{index} -- for ipV6
- * key = vm-type, networkRoleKey = NetWork-Role
- */
- protected void buildVfModuleIpV6AddressHeatTemplate(Map<String,Object> paramsMap, String keyPrefix, String vnicSubInterfaces) {
-
- List<String> ipv6Ips = jsonPath.locateResultList(vnicSubInterfaces, "$.sub-interface-network-data[*].network-information-items.network-information-item[?(@.ip-version == 'ipv6')].network-ips.network-ip[*]");
-
- addPairToMap(paramsMap, keyPrefix, V6_IP, ipv6Ips);
-
- for (int i = 0; i < ipv6Ips.size(); i++) {
- addPairToMap(paramsMap, keyPrefix, V6_IP + UNDERSCORE + i, ipv6Ips.get(i));
- }
- }
-
- /*
- * Build floatingip_address for Heat Template
- * Building Criteria :
- * {vm-type}_subint_{network-role}_port_{index}_floating_ip -- for ipV4
- */
- protected void buildVfModuleFloatingIpV4HeatTemplate(Map<String,Object> paramsMap, String keyPrefix, String vnicSubInterfaces) {
-
- List<String> floatingV4 = jsonPath.locateResultList(vnicSubInterfaces, "$.sub-interface-network-data[*].floating-ips.floating-ip-v4[*]");
-
- if (!floatingV4.isEmpty()) {
- floatingV4 = Collections.singletonList(floatingV4.get(0));
- }
- addPairToMap(paramsMap, keyPrefix, FLOATING_IP, floatingV4);
-
- }
-
- /*
- * Build floatingip_address for Heat Template
- * Building Criteria :
- * {vm-type}_subint_{network-role}_port_{index}_floating_v6_ip -- for ipV6
- */
- protected void buildVfModuleFloatingIpV6HeatTemplate(Map<String,Object> paramsMap, String keyPrefix, String vnicSubInterfaces) {
-
- List<String> floatingV6 = jsonPath.locateResultList(vnicSubInterfaces, "$.sub-interface-network-data[*].floating-ips.floating-ip-v6[*]");
-
- if (!floatingV6.isEmpty()) {
- floatingV6 = Collections.singletonList(floatingV6.get(0));
- }
- addPairToMap(paramsMap, keyPrefix, FLOATING_V6_IP, floatingV6);
- }
-
- protected void addPairToMap(Map<String, Object> paramsMap, String keyPrefix, String key, String value) {
-
- addPairToMap(paramsMap, keyPrefix, key, Collections.singletonList(value));
- }
-
- protected void addPairToMap(Map<String, Object> paramsMap, String keyPrefix, String key, List<String> value) {
-
- if (!value.isEmpty()) {
- paramsMap.put(keyPrefix + key, Joiner.on(",").join(value));
- }
- }
-
- private void buildParamsMapFromSdncParams(Map<String,Object> paramsMap, GenericResourceApiParam parametersData) {
- if (parametersData != null) {
- List<GenericResourceApiParamParam> paramsList = parametersData.getParam();
- if (paramsList != null) {
- for (int i = 0; i < paramsList.size(); i++) {
- GenericResourceApiParamParam param = paramsList.get(i);
- String parameterName = param.getName();
- if (!sdncResponseParamsToSkip.contains(parameterName)) {
- String parameterValue = param.getValue();
- paramsMap.put(parameterName, parameterValue);
- }
- }
- }
- }
- }
-
- private Map<String,String> buildNetworkRoleMap(GenericResourceApiVfmoduletopologyVfModuleTopology vfModuleTopology) throws JsonParseException, JsonMappingException, IOException {
- Map<String, String> networkRoleMap = new HashMap<>();
- GenericResourceApiVfmoduleassignmentsVfModuleAssignments vfModuleAssignments = vfModuleTopology.getVfModuleAssignments();
- if (vfModuleAssignments != null) {
- GenericResourceApiVfmoduleassignmentsVfmoduleassignmentsVms vms = vfModuleAssignments.getVms();
- if (vms != null) {
- List<GenericResourceApiVmTopologyData> vmsList = vms.getVm();
- if (vmsList != null) {
- for (GenericResourceApiVmTopologyData vm : vmsList){
- GenericResourceApiVmtopologydataVmNetworks vmNetworks = vm.getVmNetworks();
- if (vmNetworks != null) {
- List<GenericResourceApiVmNetworkData> vmNetworksList = vmNetworks.getVmNetwork();
- if (vmNetworksList != null) {
- for(int n = 0; n < vmNetworksList.size(); n++){
- GenericResourceApiVmNetworkData network = vmNetworksList.get(n);
- String networkRole = network.getNetworkRole();
- String networkRoleValue = network.getNetworkRoleTag();
- if (networkRoleValue == null || networkRoleValue.isEmpty()) {
- networkRoleValue = networkRole;
- }
- networkRoleMap.put(networkRole, networkRoleValue);
- }
- }
- }
- }
- }
- }
- }
- return networkRoleMap;
- }
-
- public DeleteVfModuleRequest deleteVfModuleRequestMapper(RequestContext requestContext,CloudRegion cloudRegion,
- ServiceInstance serviceInstance, GenericVnf genericVnf,
- VfModule vfModule) throws IOException {
- DeleteVfModuleRequest deleteVfModuleRequest = new DeleteVfModuleRequest();
- deleteVfModuleRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
- deleteVfModuleRequest.setCloudOwner(cloudRegion.getCloudOwner());
- deleteVfModuleRequest.setTenantId(cloudRegion.getTenantId());
- deleteVfModuleRequest.setVnfId(genericVnf.getVnfId());
- deleteVfModuleRequest.setVfModuleId(vfModule.getVfModuleId());
- if (!StringUtils.isEmpty(vfModule.getHeatStackId())){
- deleteVfModuleRequest.setVfModuleStackId(vfModule.getHeatStackId());//DoDVfMod_heatStackId
- } else
- {
- deleteVfModuleRequest.setVfModuleStackId(vfModule.getVfModuleName());
- }
-
- deleteVfModuleRequest.setSkipAAI(true);
- setIdAndUrl(deleteVfModuleRequest);
- MsoRequest msoRequest = buildMsoRequest(requestContext, serviceInstance);
- deleteVfModuleRequest.setMsoRequest(msoRequest);
- return deleteVfModuleRequest;
- }
-
- protected void setIdAndUrl(DeleteVfModuleRequest deleteVfModuleRequest) throws UnsupportedEncodingException{
- String messageId = vnfAdapterObjectMapperUtils.getRandomUuid();
- deleteVfModuleRequest.setMessageId(messageId);
- deleteVfModuleRequest.setNotificationUrl(vnfAdapterObjectMapperUtils.createCallbackUrl("VNFAResponse", messageId));
- }
-
- private String convertToString(Object obj) {
- String json;
- try {
- json = mapper.writeValueAsString(obj);
- } catch (JsonProcessingException e) {
- json = "{}";
- }
-
- return json;
- }
-
- private VfModule getBaseVfModule(GenericVnf genericVnf) {
- List<VfModule> vfModules = genericVnf.getVfModules();
- VfModule baseVfModule = null;
- if (vfModules != null) {
- for(int i = 0; i < vfModules.size(); i++) {
- if (vfModules.get(i).getModelInfoVfModule().getIsBaseBoolean()) {
- baseVfModule = vfModules.get(i);
- break;
- }
- }
- }
- return baseVfModule;
- }
+ private void buildParamsMapFromSdncParams(Map<String, Object> paramsMap, GenericResourceApiParam parametersData) {
+ if (parametersData != null) {
+ List<GenericResourceApiParamParam> paramsList = parametersData.getParam();
+ if (paramsList != null) {
+ for (int i = 0; i < paramsList.size(); i++) {
+ GenericResourceApiParamParam param = paramsList.get(i);
+ String parameterName = param.getName();
+ if (!sdncResponseParamsToSkip.contains(parameterName)) {
+ String parameterValue = param.getValue();
+ paramsMap.put(parameterName, parameterValue);
+ }
+ }
+ }
+ }
+ }
+
+ private Map<String, String> buildNetworkRoleMap(GenericResourceApiVfmoduletopologyVfModuleTopology vfModuleTopology)
+ throws JsonParseException, JsonMappingException, IOException {
+ Map<String, String> networkRoleMap = new HashMap<>();
+ GenericResourceApiVfmoduleassignmentsVfModuleAssignments vfModuleAssignments =
+ vfModuleTopology.getVfModuleAssignments();
+ if (vfModuleAssignments != null) {
+ GenericResourceApiVfmoduleassignmentsVfmoduleassignmentsVms vms = vfModuleAssignments.getVms();
+ if (vms != null) {
+ List<GenericResourceApiVmTopologyData> vmsList = vms.getVm();
+ if (vmsList != null) {
+ for (GenericResourceApiVmTopologyData vm : vmsList) {
+ GenericResourceApiVmtopologydataVmNetworks vmNetworks = vm.getVmNetworks();
+ if (vmNetworks != null) {
+ List<GenericResourceApiVmNetworkData> vmNetworksList = vmNetworks.getVmNetwork();
+ if (vmNetworksList != null) {
+ for (int n = 0; n < vmNetworksList.size(); n++) {
+ GenericResourceApiVmNetworkData network = vmNetworksList.get(n);
+ String networkRole = network.getNetworkRole();
+ String networkRoleValue = network.getNetworkRoleTag();
+ if (networkRoleValue == null || networkRoleValue.isEmpty()) {
+ networkRoleValue = networkRole;
+ }
+ networkRoleMap.put(networkRole, networkRoleValue);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return networkRoleMap;
+ }
+
+ public DeleteVfModuleRequest deleteVfModuleRequestMapper(RequestContext requestContext, CloudRegion cloudRegion,
+ ServiceInstance serviceInstance, GenericVnf genericVnf, VfModule vfModule) throws IOException {
+ DeleteVfModuleRequest deleteVfModuleRequest = new DeleteVfModuleRequest();
+ deleteVfModuleRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
+ deleteVfModuleRequest.setCloudOwner(cloudRegion.getCloudOwner());
+ deleteVfModuleRequest.setTenantId(cloudRegion.getTenantId());
+ deleteVfModuleRequest.setVnfId(genericVnf.getVnfId());
+ deleteVfModuleRequest.setVfModuleId(vfModule.getVfModuleId());
+ if (!StringUtils.isEmpty(vfModule.getHeatStackId())) {
+ deleteVfModuleRequest.setVfModuleStackId(vfModule.getHeatStackId());// DoDVfMod_heatStackId
+ } else {
+ deleteVfModuleRequest.setVfModuleStackId(vfModule.getVfModuleName());
+ }
+
+ deleteVfModuleRequest.setSkipAAI(true);
+ setIdAndUrl(deleteVfModuleRequest);
+ MsoRequest msoRequest = buildMsoRequest(requestContext, serviceInstance);
+ deleteVfModuleRequest.setMsoRequest(msoRequest);
+ return deleteVfModuleRequest;
+ }
+
+ protected void setIdAndUrl(DeleteVfModuleRequest deleteVfModuleRequest) throws UnsupportedEncodingException {
+ String messageId = vnfAdapterObjectMapperUtils.getRandomUuid();
+ deleteVfModuleRequest.setMessageId(messageId);
+ deleteVfModuleRequest
+ .setNotificationUrl(vnfAdapterObjectMapperUtils.createCallbackUrl("VNFAResponse", messageId));
+ }
+
+ private String convertToString(Object obj) {
+ String json;
+ try {
+ json = mapper.writeValueAsString(obj);
+ } catch (JsonProcessingException e) {
+ json = "{}";
+ }
+
+ return json;
+ }
+
+ private VfModule getBaseVfModule(GenericVnf genericVnf) {
+ List<VfModule> vfModules = genericVnf.getVfModules();
+ VfModule baseVfModule = null;
+ if (vfModules != null) {
+ for (int i = 0; i < vfModules.size(); i++) {
+ if (vfModules.get(i).getModelInfoVfModule().getIsBaseBoolean()) {
+ baseVfModule = vfModules.get(i);
+ break;
+ }
+ }
+ }
+ return baseVfModule;
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClient.java
index 9613fbdcf1..593426a85f 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClient.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClient.java
@@ -25,7 +25,6 @@ package org.onap.so.client.namingservice;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
-
import org.onap.namingservice.model.NameGenDeleteRequest;
import org.onap.namingservice.model.NameGenDeleteResponse;
import org.onap.namingservice.model.NameGenRequest;
@@ -47,53 +46,53 @@ import org.springframework.web.client.RestTemplate;
@Component
-public class NamingClient{
- private static final Logger logger = LoggerFactory.getLogger(NamingClient.class);
- private static final String ENDPOINT = "mso.naming.endpoint";
- private static final String AUTH = "mso.naming.auth";
-
- @Autowired
- private RestTemplate restTemplate;
- @Autowired
+public class NamingClient {
+ private static final Logger logger = LoggerFactory.getLogger(NamingClient.class);
+ private static final String ENDPOINT = "mso.naming.endpoint";
+ private static final String AUTH = "mso.naming.auth";
+
+ @Autowired
+ private RestTemplate restTemplate;
+ @Autowired
private Environment env;
- @Autowired
- private NamingClientResponseValidator namingClientResponseValidator;
-
- public String postNameGenRequest(NameGenRequest request) throws BadResponseException, IOException {
- String targetUrl = env.getProperty(ENDPOINT);
- HttpHeaders headers = setHeaders(env.getProperty(AUTH));
- logger.info("Sending postNameGenRequest to url: {}", targetUrl);
- HttpEntity<NameGenRequest> requestEntity = new HttpEntity<>(request, headers);
- ResponseEntity<NameGenResponse> response;
- try{
- response = restTemplate.postForEntity(targetUrl, requestEntity, NameGenResponse.class);
- }catch(HttpStatusCodeException e){
- throw new BadResponseException(namingClientResponseValidator.formatError(e));
- }
- return namingClientResponseValidator.validateNameGenResponse(response);
- }
+ @Autowired
+ private NamingClientResponseValidator namingClientResponseValidator;
+
+ public String postNameGenRequest(NameGenRequest request) throws BadResponseException, IOException {
+ String targetUrl = env.getProperty(ENDPOINT);
+ HttpHeaders headers = setHeaders(env.getProperty(AUTH));
+ logger.info("Sending postNameGenRequest to url: {}", targetUrl);
+ HttpEntity<NameGenRequest> requestEntity = new HttpEntity<>(request, headers);
+ ResponseEntity<NameGenResponse> response;
+ try {
+ response = restTemplate.postForEntity(targetUrl, requestEntity, NameGenResponse.class);
+ } catch (HttpStatusCodeException e) {
+ throw new BadResponseException(namingClientResponseValidator.formatError(e));
+ }
+ return namingClientResponseValidator.validateNameGenResponse(response);
+ }
- public String deleteNameGenRequest(NameGenDeleteRequest request) throws BadResponseException, IOException {
- String targetUrl = env.getProperty(ENDPOINT);
- HttpHeaders headers = setHeaders(env.getProperty(AUTH));
- logger.info("Sending deleteNameGenRequest to url: {}", targetUrl);
- HttpEntity<NameGenDeleteRequest> requestEntity = new HttpEntity<>(request, headers);
- ResponseEntity<NameGenDeleteResponse> response;
- try{
- response = restTemplate.exchange(targetUrl, HttpMethod.DELETE, requestEntity, NameGenDeleteResponse.class);
- }catch(HttpStatusCodeException e){
- throw new BadResponseException(namingClientResponseValidator.formatError(e));
- }
- return namingClientResponseValidator.validateNameGenDeleteResponse(response);
- }
+ public String deleteNameGenRequest(NameGenDeleteRequest request) throws BadResponseException, IOException {
+ String targetUrl = env.getProperty(ENDPOINT);
+ HttpHeaders headers = setHeaders(env.getProperty(AUTH));
+ logger.info("Sending deleteNameGenRequest to url: {}", targetUrl);
+ HttpEntity<NameGenDeleteRequest> requestEntity = new HttpEntity<>(request, headers);
+ ResponseEntity<NameGenDeleteResponse> response;
+ try {
+ response = restTemplate.exchange(targetUrl, HttpMethod.DELETE, requestEntity, NameGenDeleteResponse.class);
+ } catch (HttpStatusCodeException e) {
+ throw new BadResponseException(namingClientResponseValidator.formatError(e));
+ }
+ return namingClientResponseValidator.validateNameGenDeleteResponse(response);
+ }
- private HttpHeaders setHeaders(String auth) {
- HttpHeaders headers = new HttpHeaders();
- headers.setContentType(MediaType.APPLICATION_JSON);
- List<MediaType> acceptableMediaTypes = new ArrayList<>();
- acceptableMediaTypes.add(MediaType.APPLICATION_JSON);
- headers.setAccept(acceptableMediaTypes);
- headers.add(HttpHeaders.AUTHORIZATION, auth);
- return headers;
- }
+ private HttpHeaders setHeaders(String auth) {
+ HttpHeaders headers = new HttpHeaders();
+ headers.setContentType(MediaType.APPLICATION_JSON);
+ List<MediaType> acceptableMediaTypes = new ArrayList<>();
+ acceptableMediaTypes.add(MediaType.APPLICATION_JSON);
+ headers.setAccept(acceptableMediaTypes);
+ headers.add(HttpHeaders.AUTHORIZATION, auth);
+ return headers;
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClientResponseValidator.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClientResponseValidator.java
index 8456f26239..717bb04099 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClientResponseValidator.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClientResponseValidator.java
@@ -24,7 +24,6 @@ package org.onap.so.client.namingservice;
import java.io.IOException;
import java.util.List;
-
import org.apache.http.HttpStatus;
import org.onap.namingservice.model.NameGenDeleteResponse;
import org.onap.namingservice.model.NameGenResponse;
@@ -38,113 +37,113 @@ import org.slf4j.LoggerFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.client.HttpStatusCodeException;
-
import com.fasterxml.jackson.databind.ObjectMapper;
@Component
public class NamingClientResponseValidator {
- private static final Logger logger = LoggerFactory.getLogger(NamingClientResponseValidator.class);
- private static final String INSTANCE_GROUP_NAME = "instance-group-name";
- private static final String NO_RESPONSE_FROM_NAMING_SERVICE = "Error did not receive a response from Naming Service.";
- private static final String NULL_RESPONSE_FROM_NAMING_SERVICE = "Error received a null response from Naming Service.";
- private static final String NAMING_SERVICE_ERROR = "Error from Naming Service: %s";
-
- public String validateNameGenResponse(ResponseEntity<NameGenResponse> response) throws BadResponseException {
- if (response == null) {
- logger.error("{} {} {} {} {}", MessageEnum.RA_GENERAL_EXCEPTION.toString(), NO_RESPONSE_FROM_NAMING_SERVICE,
- "BPMN", ErrorCode.UnknownError.getValue(),
- NO_RESPONSE_FROM_NAMING_SERVICE);
- throw new BadResponseException(NO_RESPONSE_FROM_NAMING_SERVICE);
- }
-
+ private static final Logger logger = LoggerFactory.getLogger(NamingClientResponseValidator.class);
+ private static final String INSTANCE_GROUP_NAME = "instance-group-name";
+ private static final String NO_RESPONSE_FROM_NAMING_SERVICE =
+ "Error did not receive a response from Naming Service.";
+ private static final String NULL_RESPONSE_FROM_NAMING_SERVICE =
+ "Error received a null response from Naming Service.";
+ private static final String NAMING_SERVICE_ERROR = "Error from Naming Service: %s";
+
+ public String validateNameGenResponse(ResponseEntity<NameGenResponse> response) throws BadResponseException {
+ if (response == null) {
+ logger.error("{} {} {} {} {}", MessageEnum.RA_GENERAL_EXCEPTION.toString(), NO_RESPONSE_FROM_NAMING_SERVICE,
+ "BPMN", ErrorCode.UnknownError.getValue(), NO_RESPONSE_FROM_NAMING_SERVICE);
+ throw new BadResponseException(NO_RESPONSE_FROM_NAMING_SERVICE);
+ }
+
int responseCode = response.getStatusCodeValue();
String generatedName = "";
NameGenResponse responseBody = response.getBody();
if (responseBody == null) {
- logger.error("{} {} {} {} {}", MessageEnum.RA_GENERAL_EXCEPTION.toString(), NULL_RESPONSE_FROM_NAMING_SERVICE,
- "BPMN", ErrorCode.UnknownError.getValue(),
- NULL_RESPONSE_FROM_NAMING_SERVICE);
- throw new BadResponseException(NULL_RESPONSE_FROM_NAMING_SERVICE);
- }
-
- if (isHttpCodeSuccess(responseCode)) {
- logger.info("Successful Response from Naming Service");
- List<Respelement> respList = responseBody.getElements();
-
- if (respList != null) {
- for (int i=0; i < respList.size(); i++) {
- Respelement respElement = respList.get(i);
- if (respElement != null) {
- String resourceName = respElement.getResourceName();
- if (INSTANCE_GROUP_NAME.equals(resourceName)) {
- generatedName = respElement.getResourceValue();
- break;
- }
- }
- }
- }
- return generatedName;
- } else {
- NameGenResponseError error = responseBody.getError();
- String errorMessageString = NAMING_SERVICE_ERROR;
- if (error != null) {
- errorMessageString = error.getMessage();
- }
- String errorMessage = String.format(NAMING_SERVICE_ERROR, errorMessageString);
- logger.error("{} {} {} {} {}", MessageEnum.RA_GENERAL_EXCEPTION.toString(), errorMessage, "BPMN",
- ErrorCode.DataError.getValue(), errorMessage);
- throw new BadResponseException(errorMessage);
- }
- }
-
- public String validateNameGenDeleteResponse(ResponseEntity<NameGenDeleteResponse> response) throws BadResponseException {
- if (response == null) {
- logger.error("{} {} {} {} {}", MessageEnum.RA_GENERAL_EXCEPTION.toString(), NO_RESPONSE_FROM_NAMING_SERVICE,
- "BPMN", ErrorCode.UnknownError.getValue(),
- NO_RESPONSE_FROM_NAMING_SERVICE);
- throw new BadResponseException(NO_RESPONSE_FROM_NAMING_SERVICE);
- }
-
+ logger.error("{} {} {} {} {}", MessageEnum.RA_GENERAL_EXCEPTION.toString(),
+ NULL_RESPONSE_FROM_NAMING_SERVICE, "BPMN", ErrorCode.UnknownError.getValue(),
+ NULL_RESPONSE_FROM_NAMING_SERVICE);
+ throw new BadResponseException(NULL_RESPONSE_FROM_NAMING_SERVICE);
+ }
+
+ if (isHttpCodeSuccess(responseCode)) {
+ logger.info("Successful Response from Naming Service");
+ List<Respelement> respList = responseBody.getElements();
+
+ if (respList != null) {
+ for (int i = 0; i < respList.size(); i++) {
+ Respelement respElement = respList.get(i);
+ if (respElement != null) {
+ String resourceName = respElement.getResourceName();
+ if (INSTANCE_GROUP_NAME.equals(resourceName)) {
+ generatedName = respElement.getResourceValue();
+ break;
+ }
+ }
+ }
+ }
+ return generatedName;
+ } else {
+ NameGenResponseError error = responseBody.getError();
+ String errorMessageString = NAMING_SERVICE_ERROR;
+ if (error != null) {
+ errorMessageString = error.getMessage();
+ }
+ String errorMessage = String.format(NAMING_SERVICE_ERROR, errorMessageString);
+ logger.error("{} {} {} {} {}", MessageEnum.RA_GENERAL_EXCEPTION.toString(), errorMessage, "BPMN",
+ ErrorCode.DataError.getValue(), errorMessage);
+ throw new BadResponseException(errorMessage);
+ }
+ }
+
+ public String validateNameGenDeleteResponse(ResponseEntity<NameGenDeleteResponse> response)
+ throws BadResponseException {
+ if (response == null) {
+ logger.error("{} {} {} {} {}", MessageEnum.RA_GENERAL_EXCEPTION.toString(), NO_RESPONSE_FROM_NAMING_SERVICE,
+ "BPMN", ErrorCode.UnknownError.getValue(), NO_RESPONSE_FROM_NAMING_SERVICE);
+ throw new BadResponseException(NO_RESPONSE_FROM_NAMING_SERVICE);
+ }
+
int responseCode = response.getStatusCodeValue();
String responseMessage = "";
NameGenDeleteResponse responseBody = response.getBody();
if (responseBody == null) {
- logger.error("{} {} {} {} {}", MessageEnum.RA_GENERAL_EXCEPTION.toString(), NULL_RESPONSE_FROM_NAMING_SERVICE,
- "BPMN", ErrorCode.UnknownError.getValue(),
- NULL_RESPONSE_FROM_NAMING_SERVICE);
- throw new BadResponseException(NULL_RESPONSE_FROM_NAMING_SERVICE);
- }
-
- if (isHttpCodeSuccess(responseCode)) {
- logger.info("Successful Response from Naming Service");
- return responseMessage;
- } else {
- String errorMessageString = NAMING_SERVICE_ERROR;
-
- String errorMessage = String.format(NAMING_SERVICE_ERROR, errorMessageString);
- logger.error("{} {} {} {} {}", MessageEnum.RA_GENERAL_EXCEPTION.toString(), errorMessage, "BPMN",
- ErrorCode.DataError.getValue(), errorMessage);
- throw new BadResponseException(errorMessage);
- }
- }
-
- private boolean isHttpCodeSuccess(int code) {
+ logger.error("{} {} {} {} {}", MessageEnum.RA_GENERAL_EXCEPTION.toString(),
+ NULL_RESPONSE_FROM_NAMING_SERVICE, "BPMN", ErrorCode.UnknownError.getValue(),
+ NULL_RESPONSE_FROM_NAMING_SERVICE);
+ throw new BadResponseException(NULL_RESPONSE_FROM_NAMING_SERVICE);
+ }
+
+ if (isHttpCodeSuccess(responseCode)) {
+ logger.info("Successful Response from Naming Service");
+ return responseMessage;
+ } else {
+ String errorMessageString = NAMING_SERVICE_ERROR;
+
+ String errorMessage = String.format(NAMING_SERVICE_ERROR, errorMessageString);
+ logger.error("{} {} {} {} {}", MessageEnum.RA_GENERAL_EXCEPTION.toString(), errorMessage, "BPMN",
+ ErrorCode.DataError.getValue(), errorMessage);
+ throw new BadResponseException(errorMessage);
+ }
+ }
+
+ private boolean isHttpCodeSuccess(int code) {
return code >= HttpStatus.SC_OK && code < HttpStatus.SC_MULTIPLE_CHOICES || code == 0;
}
-
- protected String formatError(HttpStatusCodeException e) throws IOException {
- ObjectMapper mapper = new ObjectMapper();
- NameGenResponse errorResponse = mapper.readValue(e.getResponseBodyAsString(), NameGenResponse.class);
- NameGenResponseError error = errorResponse.getError();
-
- String errorMessageString = null;
- if (error != null) {
- errorMessageString = error.getMessage();
- }
- String errorMessage = String.format(NAMING_SERVICE_ERROR, errorMessageString);
- logger.error("{} {} {} {} {}", MessageEnum.RA_GENERAL_EXCEPTION.toString(), errorMessage, "BPMN",
- ErrorCode.DataError.getValue(), errorMessage);
- return errorMessage;
- }
+
+ protected String formatError(HttpStatusCodeException e) throws IOException {
+ ObjectMapper mapper = new ObjectMapper();
+ NameGenResponse errorResponse = mapper.readValue(e.getResponseBodyAsString(), NameGenResponse.class);
+ NameGenResponseError error = errorResponse.getError();
+
+ String errorMessageString = null;
+ if (error != null) {
+ errorMessageString = error.getMessage();
+ }
+ String errorMessage = String.format(NAMING_SERVICE_ERROR, errorMessageString);
+ logger.error("{} {} {} {} {}", MessageEnum.RA_GENERAL_EXCEPTION.toString(), errorMessage, "BPMN",
+ ErrorCode.DataError.getValue(), errorMessage);
+ return errorMessage;
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingRequestObjectBuilder.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingRequestObjectBuilder.java
index ba9f170d71..a4e68f8100 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingRequestObjectBuilder.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingRequestObjectBuilder.java
@@ -21,7 +21,6 @@
package org.onap.so.client.namingservice;
import java.util.List;
-
import org.onap.namingservice.model.Deleteelement;
import org.onap.namingservice.model.Element;
import org.onap.namingservice.model.NameGenDeleteRequest;
@@ -29,30 +28,34 @@ import org.onap.namingservice.model.NameGenRequest;
import org.springframework.stereotype.Component;
@Component
-public class NamingRequestObjectBuilder{
-
- public Element elementMapper(String instanceGroupId, String policyInstanceName, String namingType, String nfNamingCode, String instanceGroupName){
- Element element = new Element();
- element.put("external-key", instanceGroupId);
- element.put("policy-instance-name", policyInstanceName);
- element.put("naming-type", namingType);
- element.put("resource-name", instanceGroupName);
- element.put("nf-naming-code", nfNamingCode);
- return element;
- }
- public Deleteelement deleteElementMapper(String instanceGroupId){
- Deleteelement deleteElement = new Deleteelement();
- deleteElement.setExternalKey(instanceGroupId);
- return deleteElement;
- }
- public NameGenRequest nameGenRequestMapper(List<Element> elements){
- NameGenRequest nameGenRequest = new NameGenRequest();
- nameGenRequest.setElements(elements);
- return nameGenRequest;
- }
- public NameGenDeleteRequest nameGenDeleteRequestMapper(List<Deleteelement> deleteElements){
- NameGenDeleteRequest nameGenDeleteRequest = new NameGenDeleteRequest();
- nameGenDeleteRequest.setElements(deleteElements);
- return nameGenDeleteRequest;
- }
+public class NamingRequestObjectBuilder {
+
+ public Element elementMapper(String instanceGroupId, String policyInstanceName, String namingType,
+ String nfNamingCode, String instanceGroupName) {
+ Element element = new Element();
+ element.put("external-key", instanceGroupId);
+ element.put("policy-instance-name", policyInstanceName);
+ element.put("naming-type", namingType);
+ element.put("resource-name", instanceGroupName);
+ element.put("nf-naming-code", nfNamingCode);
+ return element;
+ }
+
+ public Deleteelement deleteElementMapper(String instanceGroupId) {
+ Deleteelement deleteElement = new Deleteelement();
+ deleteElement.setExternalKey(instanceGroupId);
+ return deleteElement;
+ }
+
+ public NameGenRequest nameGenRequestMapper(List<Element> elements) {
+ NameGenRequest nameGenRequest = new NameGenRequest();
+ nameGenRequest.setElements(elements);
+ return nameGenRequest;
+ }
+
+ public NameGenDeleteRequest nameGenDeleteRequestMapper(List<Deleteelement> deleteElements) {
+ NameGenDeleteRequest nameGenDeleteRequest = new NameGenDeleteRequest();
+ nameGenDeleteRequest.setElements(deleteElements);
+ return nameGenDeleteRequest;
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/OofClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/OofClient.java
index fa039c235c..e31285f044 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/OofClient.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/OofClient.java
@@ -34,7 +34,6 @@ import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
-
import com.fasterxml.jackson.core.JsonProcessingException;
import java.util.LinkedHashMap;
@@ -54,15 +53,14 @@ public class OofClient {
/**
- * Makes a rest call to oof to perform homing and licensing for a
- * list of demands
+ * Makes a rest call to oof to perform homing and licensing for a list of demands
*
* @param homingRequest
* @return
* @throws JsonProcessingException
* @throws BpmnError
*/
- public void postDemands(OofRequest homingRequest) throws BadResponseException, JsonProcessingException{
+ public void postDemands(OofRequest homingRequest) throws BadResponseException, JsonProcessingException {
logger.trace("Started oof Client Post Demands");
String url = oofProperties.getHost() + oofProperties.getUri();
logger.debug("Post demands url: " + url);
@@ -79,7 +77,8 @@ public class OofClient {
baseClient.setTargetUrl(url);
baseClient.setHttpHeader(header);
- LinkedHashMap<?, ?> response = baseClient.post(homingRequest.toJsonString(), new ParameterizedTypeReference<LinkedHashMap<? ,?>>() {});
+ LinkedHashMap<?, ?> response =
+ baseClient.post(homingRequest.toJsonString(), new ParameterizedTypeReference<LinkedHashMap<?, ?>>() {});
validator.validateDemandsResponse(response);
logger.trace("Completed OOF Client Post Demands");
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/OofValidator.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/OofValidator.java
index 252ff0d6a6..abbf52e38c 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/OofValidator.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/OofValidator.java
@@ -26,9 +26,7 @@ import org.onap.so.client.exception.BadResponseException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
-
import java.util.LinkedHashMap;
-
import static org.apache.commons.lang.StringUtils.isNotBlank;
@@ -44,55 +42,54 @@ public class OofValidator {
*/
public void validateDemandsResponse(LinkedHashMap<?, ?> response) throws BadResponseException {
logger.debug("Validating oofs synchronous response");
- if(!response.isEmpty()){
+ if (!response.isEmpty()) {
JSONObject jsonResponse = new JSONObject(response);
- if(jsonResponse.has("requestStatus")){
+ if (jsonResponse.has("requestStatus")) {
String status = jsonResponse.getString("requestStatus");
- if(status.equals("accepted")){
+ if (status.equals("accepted")) {
logger.debug("oofs synchronous response indicates accepted");
- }else{
+ } else {
String message = jsonResponse.getString("statusMessage");
- if(isNotBlank(message)){
+ if (isNotBlank(message)) {
logger.debug("oofs response indicates failed: " + message);
- }else{
+ } else {
logger.debug("oofs response indicates failed: no status message provided");
message = "error message not provided";
}
throw new BadResponseException("oofs synchronous response indicates failed: " + message);
}
- }else{
+ } else {
logger.debug("oofs synchronous response does not contain: request status");
throw new BadResponseException("oofs synchronous response does not contain: request status");
}
- }else{
+ } else {
logger.debug("oofs synchronous response is empty");
throw new BadResponseException("oofs synchronous response i is empty");
}
}
/**
- * Validates the asynchronous/callback response from oof which
- * contains the homing and licensing solutions
+ * Validates the asynchronous/callback response from oof which contains the homing and licensing solutions
*
* @throws BadResponseException
*/
- public void validateSolution(String response) throws BadResponseException{
+ public void validateSolution(String response) throws BadResponseException {
logger.debug("Validating oofs asynchronous callback response");
- if(isNotBlank(response)) {
+ if (isNotBlank(response)) {
JSONObject jsonResponse = new JSONObject(response);
- if(!jsonResponse.has("serviceException")){
+ if (!jsonResponse.has("serviceException")) {
logger.debug("oofs asynchronous response is valid");
- }else{
+ } else {
String message = jsonResponse.getJSONObject("serviceException").getString("text");
- if(isNotBlank(message)){
+ if (isNotBlank(message)) {
logger.debug("oofs response contains a service exception: " + message);
- }else{
+ } else {
logger.debug("oofs response contains a service exception: no service exception text provided");
message = "error message not provided";
}
throw new BadResponseException("oofs asynchronous response contains a service exception: " + message);
}
- }else{
+ } else {
logger.debug("oofs asynchronous response is empty");
throw new BadResponseException("oofs asynchronous response is empty");
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ModelInfo.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ModelInfo.java
index f5fb87503a..433de22aba 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ModelInfo.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ModelInfo.java
@@ -24,18 +24,11 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonRootName;
-
import java.io.Serializable;
@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonPropertyOrder({
- "modelType",
- "modelInvariantId",
- "modelVersionId",
- "modelName",
- "modelVersion",
- "modelCustomizationName"
-})
+@JsonPropertyOrder({"modelType", "modelInvariantId", "modelVersionId", "modelName", "modelVersion",
+ "modelCustomizationName"})
@JsonRootName("modelInfo")
public class ModelInfo implements Serializable {
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofProperties.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofProperties.java
index 507eaeaf5e..84e29b6f2d 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofProperties.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofProperties.java
@@ -22,7 +22,6 @@ package org.onap.so.client.oof.beans;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
-
import java.util.Map;
@Configuration
@@ -38,25 +37,27 @@ public class OofProperties {
public String getHost() {
return host;
}
+
public void setHost(String host) {
this.host = host;
}
+
public String getUri() {
return uri;
}
+
public void setUri(String uri) {
this.uri = uri;
}
+
public Map<String, String> getHeaders() {
return headers;
}
+
public void setHeaders(Map<String, String> headers) {
this.headers = headers;
}
-
-
-
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofRequest.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofRequest.java
index 58f0bfc9cc..e3c29fe04d 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofRequest.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofRequest.java
@@ -27,11 +27,10 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
import java.io.Serializable;
-public class OofRequest implements Serializable{
+public class OofRequest implements Serializable {
private static final long serialVersionUID = -1541132882892163132L;
private static final Logger logger = LoggerFactory.getLogger(OofRequest.class);
@@ -53,38 +52,45 @@ public class OofRequest implements Serializable{
public RequestInfo getRequestInformation() {
return requestInformation;
}
+
public void setRequestInformation(RequestInfo requestInformation) {
this.requestInformation = requestInformation;
}
+
public ServiceInfo getServiceInformation() {
return serviceInformation;
}
+
public void setServiceInformation(ServiceInfo serviceInformation) {
this.serviceInformation = serviceInformation;
}
+
public PlacementInfo getPlacementInformation() {
return placementInformation;
}
+
public void setPlacementInformation(PlacementInfo placementInformation) {
this.placementInformation = placementInformation;
}
+
public String getLicenseInformation() {
return licenseInformation;
}
+
public void setLicenseInformation(String licenseInformation) {
this.licenseInformation = licenseInformation;
}
@JsonInclude(Include.NON_NULL)
- public String toJsonString(){
+ public String toJsonString() {
String json = "";
ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(Include.NON_NULL);
ObjectWriter ow = mapper.writer().withDefaultPrettyPrinter();
- try{
+ try {
json = ow.writeValueAsString(this);
- }catch (Exception e){
+ } catch (Exception e) {
logger.error("Unable to convert oofRequest to string", e);
}
return json.replaceAll("\\\\", "");
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofRequestParameters.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofRequestParameters.java
index 621f5652a3..6c9e45c787 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofRequestParameters.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofRequestParameters.java
@@ -24,15 +24,10 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonRootName;
-
import java.io.Serializable;
@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonPropertyOrder({
- "customerLatitude",
- "customerLongitude",
- "customerName"
-})
+@JsonPropertyOrder({"customerLatitude", "customerLongitude", "customerName"})
@JsonRootName("requestParameters")
public class OofRequestParameters implements Serializable {
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/PlacementDemand.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/PlacementDemand.java
index 38728efcfb..73c100df6d 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/PlacementDemand.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/PlacementDemand.java
@@ -24,16 +24,10 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonRootName;
-
import java.io.Serializable;
@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonPropertyOrder({
- "resourceModuleName",
- "serviceResourceId",
- "tenantId",
- "resourceModelInfo"
-})
+@JsonPropertyOrder({"resourceModuleName", "serviceResourceId", "tenantId", "resourceModelInfo"})
@JsonRootName("placementDemand")
public class PlacementDemand implements Serializable {
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/PlacementInfo.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/PlacementInfo.java
index 2a7dc9decb..0eb14d991a 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/PlacementInfo.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/PlacementInfo.java
@@ -28,11 +28,7 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonRootName;
@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonPropertyOrder({
- "requestParameters",
- "subscriberInfo",
- "placementDemands"
-})
+@JsonPropertyOrder({"requestParameters", "subscriberInfo", "placementDemands"})
@JsonRootName("placementInfo")
public class PlacementInfo implements Serializable {
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/RequestInfo.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/RequestInfo.java
index 6831fe54e9..0132ed56e9 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/RequestInfo.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/RequestInfo.java
@@ -28,16 +28,8 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonRootName;
@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonPropertyOrder({
- "transactionId",
- "requestId",
- "callbackUrl",
- "sourceId",
- "requestType",
- "numSolutions",
- "optimizers",
- "timeout"
-})
+@JsonPropertyOrder({"transactionId", "requestId", "callbackUrl", "sourceId", "requestType", "numSolutions",
+ "optimizers", "timeout"})
@JsonRootName("requestInfo")
public class RequestInfo implements Serializable {
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/Resource.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/Resource.java
index fea7437a93..8d44c63571 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/Resource.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/Resource.java
@@ -21,10 +21,9 @@
package org.onap.so.client.oof.beans;
import com.fasterxml.jackson.annotation.JsonProperty;
-
import java.io.Serializable;
-public class Resource implements Serializable{
+public class Resource implements Serializable {
private static final long serialVersionUID = 5949861520571440421L;
@@ -34,19 +33,19 @@ public class Resource implements Serializable{
private String status;
- public String getServiceResourceId(){
+ public String getServiceResourceId() {
return serviceResourceId;
}
- public void setServiceResourceId(String serviceResourceId){
+ public void setServiceResourceId(String serviceResourceId) {
this.serviceResourceId = serviceResourceId;
}
- public String getStatus(){
+ public String getStatus() {
return status;
}
- public void setStatus(String status){
+ public void setStatus(String status) {
this.status = status;
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ResourceModelInfo.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ResourceModelInfo.java
index e9257bcb0c..9d0352525d 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ResourceModelInfo.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ResourceModelInfo.java
@@ -23,7 +23,6 @@ package org.onap.so.client.oof.beans;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName;
-
import java.io.Serializable;
@JsonInclude(JsonInclude.Include.NON_NULL)
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ServiceInfo.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ServiceInfo.java
index 0cfffbbff6..db0e2acd60 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ServiceInfo.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ServiceInfo.java
@@ -24,15 +24,10 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonRootName;
-
import java.io.Serializable;
@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonPropertyOrder({
- "serviceInstanceId",
- "serviceName",
- "modelInfo"
-})
+@JsonPropertyOrder({"serviceInstanceId", "serviceName", "modelInfo"})
@JsonRootName("serviceInfo")
public class ServiceInfo implements Serializable {
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/SubscriberInfo.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/SubscriberInfo.java
index 3218975095..8fef4c45e7 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/SubscriberInfo.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/SubscriberInfo.java
@@ -24,15 +24,10 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonRootName;
-
import java.io.Serializable;
@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonPropertyOrder({
- "globalSubscriberId",
- "subscriberName",
- "subscriberCommonSiteId"
-})
+@JsonPropertyOrder({"globalSubscriberId", "subscriberName", "subscriberCommonSiteId"})
@JsonRootName("subscriberInfo")
public class SubscriberInfo implements Serializable {
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAICollectionResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAICollectionResources.java
index 4a9f01fa53..5df7518698 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAICollectionResources.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAICollectionResources.java
@@ -32,27 +32,29 @@ import org.springframework.stereotype.Component;
@Component
public class AAICollectionResources {
- @Autowired
- private InjectionHelper injectionHelper;
-
- @Autowired
- private AAIObjectMapper aaiObjectMapper;
-
- public void createCollection(Collection collection) {
- AAIResourceUri networkCollectionURI = AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, collection.getId());
- collection.setOrchestrationStatus(OrchestrationStatus.INVENTORIED);
- org.onap.aai.domain.yang.Collection aaiCollection = aaiObjectMapper.mapCollection(collection);
- injectionHelper.getAaiClient().create(networkCollectionURI, aaiCollection);
- }
-
- public void updateCollection(Collection collection) {
- AAIResourceUri networkCollectionURI = AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, collection.getId());
- org.onap.aai.domain.yang.Collection aaiCollection = aaiObjectMapper.mapCollection(collection);
- injectionHelper.getAaiClient().update(networkCollectionURI, aaiCollection);
- }
-
- public void deleteCollection(Collection collection) {
- AAIResourceUri instanceGroupUri = AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, collection.getId());
- injectionHelper.getAaiClient().delete(instanceGroupUri);
- }
+ @Autowired
+ private InjectionHelper injectionHelper;
+
+ @Autowired
+ private AAIObjectMapper aaiObjectMapper;
+
+ public void createCollection(Collection collection) {
+ AAIResourceUri networkCollectionURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, collection.getId());
+ collection.setOrchestrationStatus(OrchestrationStatus.INVENTORIED);
+ org.onap.aai.domain.yang.Collection aaiCollection = aaiObjectMapper.mapCollection(collection);
+ injectionHelper.getAaiClient().create(networkCollectionURI, aaiCollection);
+ }
+
+ public void updateCollection(Collection collection) {
+ AAIResourceUri networkCollectionURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, collection.getId());
+ org.onap.aai.domain.yang.Collection aaiCollection = aaiObjectMapper.mapCollection(collection);
+ injectionHelper.getAaiClient().update(networkCollectionURI, aaiCollection);
+ }
+
+ public void deleteCollection(Collection collection) {
+ AAIResourceUri instanceGroupUri = AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, collection.getId());
+ injectionHelper.getAaiClient().delete(instanceGroupUri);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIConfigurationResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIConfigurationResources.java
index f412720af7..746f136e96 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIConfigurationResources.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIConfigurationResources.java
@@ -21,9 +21,7 @@
package org.onap.so.client.orchestration;
import java.util.Optional;
-
import javax.ws.rs.core.UriBuilder;
-
import org.onap.so.bpmn.common.InjectionHelper;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
import org.onap.so.client.aai.AAIObjectType;
@@ -37,11 +35,11 @@ import org.springframework.stereotype.Component;
@Component
public class AAIConfigurationResources {
- @Autowired
- private InjectionHelper injectionHelper;
+ @Autowired
+ private InjectionHelper injectionHelper;
- @Autowired
- private AAIObjectMapper aaiObjectMapper;
+ @Autowired
+ private AAIObjectMapper aaiObjectMapper;
/**
* A&AI call to create configuration
@@ -49,14 +47,15 @@ public class AAIConfigurationResources {
* @param configuration
*/
public void createConfiguration(Configuration configuration) {
- AAIResourceUri configurationURI = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configuration.getConfigurationId());
+ AAIResourceUri configurationURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configuration.getConfigurationId());
configuration.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
org.onap.aai.domain.yang.Configuration aaiConfiguration = aaiObjectMapper.mapConfiguration(configuration);
injectionHelper.getAaiClient().create(configurationURI, aaiConfiguration);
}
/**
- * method to get Configuration details from A&AI
+ * method to get Configuration details from A&AI
*
* @param configurationId
* @return
@@ -72,21 +71,24 @@ public class AAIConfigurationResources {
* @param configuration
*/
public void updateConfiguration(Configuration configuration) {
- AAIResourceUri configurationURI = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configuration.getConfigurationId());
+ AAIResourceUri configurationURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configuration.getConfigurationId());
org.onap.aai.domain.yang.Configuration aaiConfiguration = aaiObjectMapper.mapConfiguration(configuration);
injectionHelper.getAaiClient().update(configurationURI, aaiConfiguration);
}
+
/**
* A&AI call to disconnect configuration relation with service instance
+ *
* @param configurationId
* @param serviceInstanceId
*/
- public void disconnectConfigurationToServiceInstance(String configurationId, String serviceInstanceId){
+ public void disconnectConfigurationToServiceInstance(String configurationId, String serviceInstanceId) {
AAIResourceUri configurationURI = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configurationId);
- AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
- serviceInstanceId);
- injectionHelper.getAaiClient().disconnect(configurationURI,serviceInstanceURI);
+ AAIResourceUri serviceInstanceURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId);
+ injectionHelper.getAaiClient().disconnect(configurationURI, serviceInstanceURI);
}
/**
@@ -96,8 +98,10 @@ public class AAIConfigurationResources {
* @param vnrConfigurationId
*/
public void connectVrfConfigurationToVnrConfiguration(String vrfConfigurationId, String vnrConfigurationId) {
- AAIResourceUri vnrConfigurationUri = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, vnrConfigurationId);
- AAIResourceUri vrfConfigurationUri = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, vrfConfigurationId);
+ AAIResourceUri vnrConfigurationUri =
+ AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, vnrConfigurationId);
+ AAIResourceUri vrfConfigurationUri =
+ AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, vrfConfigurationId);
injectionHelper.getAaiClient().connect(vrfConfigurationUri, vnrConfigurationUri);
}
@@ -121,11 +125,11 @@ public class AAIConfigurationResources {
*/
public void connectConfigurationToServiceInstance(String configurationId, String serviceInstanceId) {
AAIResourceUri configurationURI = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configurationId);
- AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
- serviceInstanceId);
+ AAIResourceUri serviceInstanceURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId);
injectionHelper.getAaiClient().connect(configurationURI, serviceInstanceURI);
}
-
+
/**
* A&AI call to add configuration relationship with service instance
*
@@ -133,10 +137,11 @@ public class AAIConfigurationResources {
* @param serviceInstanceId
* @param aaiLabel
*/
- public void connectConfigurationToServiceInstance(String configurationId, String serviceInstanceId, AAIEdgeLabel aaiLabel) {
+ public void connectConfigurationToServiceInstance(String configurationId, String serviceInstanceId,
+ AAIEdgeLabel aaiLabel) {
AAIResourceUri configurationURI = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configurationId);
- AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
- serviceInstanceId);
+ AAIResourceUri serviceInstanceURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId);
injectionHelper.getAaiClient().connect(configurationURI, serviceInstanceURI, aaiLabel);
}
@@ -165,22 +170,22 @@ public class AAIConfigurationResources {
injectionHelper.getAaiClient().connect(configurationURI, vpnBindingURI);
}
- public void connectConfigurationToVfModule(String configurationId, String vnfId, String vfModuleId){
- AAIResourceUri configurationURI = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configurationId);
- AAIResourceUri vfModuleURI = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId);
- injectionHelper.getAaiClient().connect(configurationURI, vfModuleURI);
+ public void connectConfigurationToVfModule(String configurationId, String vnfId, String vfModuleId) {
+ AAIResourceUri configurationURI = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configurationId);
+ AAIResourceUri vfModuleURI = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId);
+ injectionHelper.getAaiClient().connect(configurationURI, vfModuleURI);
}
- public void connectConfigurationToVnfc(String configurationId, String vnfcName){
- AAIResourceUri configurationURI = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configurationId);
- AAIResourceUri vnfcURI = AAIUriFactory.createResourceUri(AAIObjectType.VNFC, vnfcName);
- injectionHelper.getAaiClient().connect(configurationURI, vnfcURI);
+ public void connectConfigurationToVnfc(String configurationId, String vnfcName) {
+ AAIResourceUri configurationURI = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configurationId);
+ AAIResourceUri vnfcURI = AAIUriFactory.createResourceUri(AAIObjectType.VNFC, vnfcName);
+ injectionHelper.getAaiClient().connect(configurationURI, vnfcURI);
}
- public void connectConfigurationToL3Network(String configurationId, String networkId){
- AAIResourceUri configurationURI = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configurationId);
- AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId);
- injectionHelper.getAaiClient().connect(configurationURI, networkURI);
+ public void connectConfigurationToL3Network(String configurationId, String networkId) {
+ AAIResourceUri configurationURI = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configurationId);
+ AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId);
+ injectionHelper.getAaiClient().connect(configurationURI, networkURI);
}
/**
@@ -192,30 +197,35 @@ public class AAIConfigurationResources {
AAIResourceUri aaiResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configurationId);
injectionHelper.getAaiClient().delete(aaiResourceUri);
}
+
/**
* method to delete Configuration details in A&AI
*
* @param configuration
*/
public void deleteConfiguration(Configuration configuration) {
- AAIResourceUri aaiResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configuration.getConfigurationId());
+ AAIResourceUri aaiResourceUri =
+ AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configuration.getConfigurationId());
injectionHelper.getAaiClient().delete(aaiResourceUri);
}
/**
* Get Configuration from AAI using related Link
+ *
* @param relatedLink related link - URI
* @return AAI Configuration object
*/
- public Optional<org.onap.aai.domain.yang.Configuration> getConfigurationFromRelatedLink(String relatedLink){
- return injectionHelper.getAaiClient()
- .get(org.onap.aai.domain.yang.Configuration.class, AAIUriFactory.createResourceFromExistingURI(AAIObjectType.CONFIGURATION, UriBuilder.fromPath(relatedLink).build()));
+ public Optional<org.onap.aai.domain.yang.Configuration> getConfigurationFromRelatedLink(String relatedLink) {
+ return injectionHelper.getAaiClient().get(org.onap.aai.domain.yang.Configuration.class, AAIUriFactory
+ .createResourceFromExistingURI(AAIObjectType.CONFIGURATION, UriBuilder.fromPath(relatedLink).build()));
}
- public void updateOrchestrationStatusConfiguration(Configuration configuration, OrchestrationStatus orchestrationStatus) {
- AAIResourceUri aaiResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configuration.getConfigurationId());
- configuration.setOrchestrationStatus(orchestrationStatus);
- org.onap.aai.domain.yang.Configuration aaiConfiguration = aaiObjectMapper.mapConfiguration(configuration);
- injectionHelper.getAaiClient().update(aaiResourceUri, aaiConfiguration);
- }
+ public void updateOrchestrationStatusConfiguration(Configuration configuration,
+ OrchestrationStatus orchestrationStatus) {
+ AAIResourceUri aaiResourceUri =
+ AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configuration.getConfigurationId());
+ configuration.setOrchestrationStatus(orchestrationStatus);
+ org.onap.aai.domain.yang.Configuration aaiConfiguration = aaiObjectMapper.mapConfiguration(configuration);
+ injectionHelper.getAaiClient().update(aaiResourceUri, aaiConfiguration);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIInstanceGroupResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIInstanceGroupResources.java
index c325dd75ee..c48593037a 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIInstanceGroupResources.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIInstanceGroupResources.java
@@ -21,7 +21,6 @@
package org.onap.so.client.orchestration;
import java.util.Optional;
-
import org.onap.so.bpmn.common.InjectionHelper;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup;
@@ -36,45 +35,53 @@ import org.springframework.stereotype.Component;
@Component
public class AAIInstanceGroupResources {
- @Autowired
- private InjectionHelper injectionHelper;
-
- @Autowired
- private AAIObjectMapper aaiObjectMapper;
+ @Autowired
+ private InjectionHelper injectionHelper;
+
+ @Autowired
+ private AAIObjectMapper aaiObjectMapper;
+
+ public void createInstanceGroup(InstanceGroup instanceGroup) {
+ AAIResourceUri instanceGroupUri =
+ AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId());
+ org.onap.aai.domain.yang.InstanceGroup aaiInstanceGroup = aaiObjectMapper.mapInstanceGroup(instanceGroup);
+ injectionHelper.getAaiClient().createIfNotExists(instanceGroupUri, Optional.of(aaiInstanceGroup));
+ }
+
+ public void deleteInstanceGroup(InstanceGroup instanceGroup) {
+ AAIResourceUri instanceGroupUri =
+ AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId());
+ injectionHelper.getAaiClient().delete(instanceGroupUri);
+ }
+
+ public void connectInstanceGroupToVnf(InstanceGroup instanceGroup, GenericVnf vnf) {
+ AAIResourceUri instanceGroupUri =
+ AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId());
+ AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId());
+ injectionHelper.getAaiClient().connect(instanceGroupUri, vnfURI);
+ }
+
+ public void connectInstanceGroupToVnf(InstanceGroup instanceGroup, GenericVnf vnf, AAIEdgeLabel aaiLabel) {
+ AAIResourceUri instanceGroupUri =
+ AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId());
+ AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId());
+ injectionHelper.getAaiClient().connect(instanceGroupUri, vnfURI, aaiLabel);
+ }
- public void createInstanceGroup(InstanceGroup instanceGroup) {
- AAIResourceUri instanceGroupUri = AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId());
- org.onap.aai.domain.yang.InstanceGroup aaiInstanceGroup = aaiObjectMapper.mapInstanceGroup(instanceGroup);
- injectionHelper.getAaiClient().createIfNotExists(instanceGroupUri, Optional.of(aaiInstanceGroup));
- }
-
- public void deleteInstanceGroup(InstanceGroup instanceGroup) {
- AAIResourceUri instanceGroupUri = AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId());
- injectionHelper.getAaiClient().delete(instanceGroupUri);
- }
+ public boolean exists(InstanceGroup instanceGroup) {
+ AAIResourceUri instanceGroupUri =
+ AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId());
+ return injectionHelper.getAaiClient().exists(instanceGroupUri);
+ }
- public void connectInstanceGroupToVnf(InstanceGroup instanceGroup, GenericVnf vnf) {
- AAIResourceUri instanceGroupUri = AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId());
- AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId());
- injectionHelper.getAaiClient().connect(instanceGroupUri, vnfURI);
- }
-
- public void connectInstanceGroupToVnf(InstanceGroup instanceGroup, GenericVnf vnf, AAIEdgeLabel aaiLabel) {
- AAIResourceUri instanceGroupUri = AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId());
- AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId());
- injectionHelper.getAaiClient().connect(instanceGroupUri, vnfURI, aaiLabel);
- }
-
- public boolean exists(InstanceGroup instanceGroup) {
- AAIResourceUri instanceGroupUri = AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId());
- return injectionHelper.getAaiClient().exists(instanceGroupUri);
- }
-
- public void createInstanceGroupandConnectServiceInstance(InstanceGroup instanceGroup, ServiceInstance serviceInstance) {
- AAIResourceUri instanceGroupUri = AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId());
- org.onap.aai.domain.yang.InstanceGroup aaiInstanceGroup = aaiObjectMapper.mapInstanceGroup(instanceGroup);
- AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
- serviceInstance.getServiceInstanceId());
- injectionHelper.getAaiClient().createIfNotExists(instanceGroupUri, Optional.of(aaiInstanceGroup)).connect(instanceGroupUri, serviceInstanceURI);
- }
+ public void createInstanceGroupandConnectServiceInstance(InstanceGroup instanceGroup,
+ ServiceInstance serviceInstance) {
+ AAIResourceUri instanceGroupUri =
+ AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId());
+ org.onap.aai.domain.yang.InstanceGroup aaiInstanceGroup = aaiObjectMapper.mapInstanceGroup(instanceGroup);
+ AAIResourceUri serviceInstanceURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance.getServiceInstanceId());
+ injectionHelper.getAaiClient().createIfNotExists(instanceGroupUri, Optional.of(aaiInstanceGroup))
+ .connect(instanceGroupUri, serviceInstanceURI);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java
index 7283c9967c..b936551549 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java
@@ -21,7 +21,6 @@
package org.onap.so.client.orchestration;
import java.util.Optional;
-
import org.onap.aai.domain.yang.NetworkPolicies;
import org.onap.aai.domain.yang.NetworkPolicy;
import org.onap.aai.domain.yang.RouteTableReference;
@@ -46,147 +45,165 @@ import org.springframework.stereotype.Component;
@Component
public class AAINetworkResources {
-
- @Autowired
- private InjectionHelper injectionHelper;
-
- @Autowired
- private AAIObjectMapper aaiObjectMapper;
-
- public void updateNetwork(L3Network network) {
- AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, network.getNetworkId());
- org.onap.aai.domain.yang.L3Network aaiL3Network = aaiObjectMapper.mapNetwork(network);
- injectionHelper.getAaiClient().update(networkURI, aaiL3Network);
- }
-
- public void updateSubnet(L3Network network, Subnet subnet) {
- AAIResourceUri subnetURI = AAIUriFactory.createResourceUri(AAIObjectType.SUBNET, network.getNetworkId(), subnet.getSubnetId());
- org.onap.aai.domain.yang.Subnet aaiSubnet = aaiObjectMapper.mapSubnet(subnet);
- injectionHelper.getAaiClient().update(subnetURI, aaiSubnet);
- }
-
- public void createNetworkConnectToServiceInstance(L3Network network, ServiceInstance serviceInstance) {
- AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, network.getNetworkId());
- network.setOrchestrationStatus(OrchestrationStatus.INVENTORIED);
- AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
- serviceInstance.getServiceInstanceId());
- org.onap.aai.domain.yang.L3Network aaiL3Network = aaiObjectMapper.mapNetwork(network);
- injectionHelper.getAaiClient().createIfNotExists(networkURI, Optional.of(aaiL3Network)).connect(networkURI, serviceInstanceURI);
- }
-
- public void deleteNetwork(L3Network network) {
- AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, network.getNetworkId());
- injectionHelper.getAaiClient().delete(networkURI);
- }
-
- public Optional<VpnBinding> getVpnBinding(AAIResourceUri netBindingUri) {
- return injectionHelper.getAaiClient().get(netBindingUri.depth(Depth.TWO)).asBean(VpnBinding.class);
- }
-
- public Optional<NetworkPolicy> getNetworkPolicy(AAIResourceUri netPolicyUri) {
- return injectionHelper.getAaiClient().get(netPolicyUri).asBean(NetworkPolicy.class);
- }
-
- public Optional<NetworkPolicies> getNetworkPolicies(AAIResourceUri netPoliciesUri) {
- return injectionHelper.getAaiClient().get(netPoliciesUri).asBean(NetworkPolicies.class);
- }
-
- public Optional<org.onap.aai.domain.yang.Subnet> getSubnet(AAIResourceUri subnetUri) {
- return injectionHelper.getAaiClient().get(subnetUri).asBean(org.onap.aai.domain.yang.Subnet.class);
- }
-
- public Optional<RouteTableReference> getRouteTable(AAIResourceUri rTableUri) {
- return injectionHelper.getAaiClient().get(rTableUri).asBean(RouteTableReference.class);
- }
-
- public Optional<org.onap.aai.domain.yang.L3Network> queryNetworkById(L3Network l3network) {
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK,l3network.getNetworkId()).depth(Depth.ALL);
- AAIResultWrapper aaiWrapper = injectionHelper.getAaiClient().get(uri);
- return aaiWrapper.asBean(org.onap.aai.domain.yang.L3Network.class);
- }
-
- public AAIResultWrapper queryNetworkWrapperById(L3Network l3network) {
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK,l3network.getNetworkId()).depth(Depth.ALL);
- return injectionHelper.getAaiClient().get(uri);
- }
-
- public void createNetworkInstanceGroup(InstanceGroup instanceGroup) {
- AAIResourceUri instanceGroupURI = AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId());
- org.onap.aai.domain.yang.InstanceGroup aaiInstanceGroup = aaiObjectMapper.mapInstanceGroup(instanceGroup);
- injectionHelper.getAaiClient().create(instanceGroupURI, aaiInstanceGroup);
- }
-
- public void createNetworkCollection(Collection networkCollection) {
- AAIResourceUri networkCollectionURI = AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, networkCollection.getId());
- networkCollection.setOrchestrationStatus(OrchestrationStatus.INVENTORIED);
- org.onap.aai.domain.yang.Collection aaiCollection = aaiObjectMapper.mapCollection(networkCollection);
- injectionHelper.getAaiClient().create(networkCollectionURI, aaiCollection);
- }
-
- public void connectNetworkToTenant(L3Network l3network, CloudRegion cloudRegion) {
- AAIResourceUri tenantURI = AAIUriFactory.createResourceUri(AAIObjectType.TENANT,
- cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId(), cloudRegion.getTenantId());
- AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, l3network.getNetworkId());
- injectionHelper.getAaiClient().connect(tenantURI, networkURI);
- }
-
- public void connectNetworkToCloudRegion(L3Network l3network, CloudRegion cloudRegion) {
- AAIResourceUri cloudRegionURI = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION,
- cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId());
- AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, l3network.getNetworkId());
- injectionHelper.getAaiClient().connect(networkURI,cloudRegionURI);
- }
-
- public void connectNetworkToNetworkCollectionInstanceGroup(L3Network l3network, InstanceGroup instanceGroup) {
- AAIResourceUri netwrokCollectionInstanceGroupURI = AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId());
- AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, l3network.getNetworkId());
- injectionHelper.getAaiClient().connect(netwrokCollectionInstanceGroupURI, networkURI);
- }
-
- public void connectNetworkToNetworkCollectionServiceInstance(L3Network l3network, ServiceInstance networkCollectionServiceInstance) {
- AAIResourceUri networkCollectionServiceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, networkCollectionServiceInstance.getServiceInstanceId());
- AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, l3network.getNetworkId());
- injectionHelper.getAaiClient().connect(networkCollectionServiceInstanceUri, networkURI);
- }
-
- public void connectNetworkCollectionInstanceGroupToNetworkCollection(InstanceGroup instanceGroup, Collection networkCollection) {
- AAIResourceUri networkCollectionUri = AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, networkCollection.getId());
- AAIResourceUri netwrokCollectionInstanceGroupURI = AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId());
- injectionHelper.getAaiClient().connect(networkCollectionUri, netwrokCollectionInstanceGroupURI);
- }
-
- public void connectInstanceGroupToCloudRegion(InstanceGroup instanceGroup, CloudRegion cloudRegion) {
- AAIResourceUri cloudRegionURI = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION,
- cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId());
- AAIResourceUri instanceGroupURI = AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId());
- injectionHelper.getAaiClient().connect(instanceGroupURI, cloudRegionURI, AAIEdgeLabel.USES);
- }
-
- public void connectNetworkCollectionToServiceInstance(Collection networkCollection, ServiceInstance networkCollectionServiceInstance) {
- AAIResourceUri networkCollectionUri = AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, networkCollection.getId());
- AAIResourceUri networkCollectionServiceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, networkCollectionServiceInstance.getServiceInstanceId());
- injectionHelper.getAaiClient().connect(networkCollectionUri, networkCollectionServiceInstanceUri);
- }
-
- public void deleteCollection(Collection collection) {
- AAIResourceUri collectionURI = AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, collection.getId());
- injectionHelper.getAaiClient().delete(collectionURI);
- }
-
- public void deleteNetworkInstanceGroup(InstanceGroup instanceGroup) {
- AAIResourceUri instanceGroupURI = AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId());
- injectionHelper.getAaiClient().delete(instanceGroupURI);
- }
-
- public void createNetworkPolicy(org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy networkPolicy) {
- NetworkPolicy aaiNetworkPolicy = aaiObjectMapper.mapNetworkPolicy(networkPolicy);
- String networkPolicyId = networkPolicy.getNetworkPolicyId();
- AAIResourceUri netUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicyId);
- injectionHelper.getAaiClient().create(netUri, aaiNetworkPolicy);
- }
-
- public void deleteNetworkPolicy(String networkPolicyId) {
- AAIResourceUri networkPolicyURI = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicyId);
- injectionHelper.getAaiClient().delete(networkPolicyURI);
- }
+
+ @Autowired
+ private InjectionHelper injectionHelper;
+
+ @Autowired
+ private AAIObjectMapper aaiObjectMapper;
+
+ public void updateNetwork(L3Network network) {
+ AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, network.getNetworkId());
+ org.onap.aai.domain.yang.L3Network aaiL3Network = aaiObjectMapper.mapNetwork(network);
+ injectionHelper.getAaiClient().update(networkURI, aaiL3Network);
+ }
+
+ public void updateSubnet(L3Network network, Subnet subnet) {
+ AAIResourceUri subnetURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.SUBNET, network.getNetworkId(), subnet.getSubnetId());
+ org.onap.aai.domain.yang.Subnet aaiSubnet = aaiObjectMapper.mapSubnet(subnet);
+ injectionHelper.getAaiClient().update(subnetURI, aaiSubnet);
+ }
+
+ public void createNetworkConnectToServiceInstance(L3Network network, ServiceInstance serviceInstance) {
+ AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, network.getNetworkId());
+ network.setOrchestrationStatus(OrchestrationStatus.INVENTORIED);
+ AAIResourceUri serviceInstanceURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance.getServiceInstanceId());
+ org.onap.aai.domain.yang.L3Network aaiL3Network = aaiObjectMapper.mapNetwork(network);
+ injectionHelper.getAaiClient().createIfNotExists(networkURI, Optional.of(aaiL3Network)).connect(networkURI,
+ serviceInstanceURI);
+ }
+
+ public void deleteNetwork(L3Network network) {
+ AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, network.getNetworkId());
+ injectionHelper.getAaiClient().delete(networkURI);
+ }
+
+ public Optional<VpnBinding> getVpnBinding(AAIResourceUri netBindingUri) {
+ return injectionHelper.getAaiClient().get(netBindingUri.depth(Depth.TWO)).asBean(VpnBinding.class);
+ }
+
+ public Optional<NetworkPolicy> getNetworkPolicy(AAIResourceUri netPolicyUri) {
+ return injectionHelper.getAaiClient().get(netPolicyUri).asBean(NetworkPolicy.class);
+ }
+
+ public Optional<NetworkPolicies> getNetworkPolicies(AAIResourceUri netPoliciesUri) {
+ return injectionHelper.getAaiClient().get(netPoliciesUri).asBean(NetworkPolicies.class);
+ }
+
+ public Optional<org.onap.aai.domain.yang.Subnet> getSubnet(AAIResourceUri subnetUri) {
+ return injectionHelper.getAaiClient().get(subnetUri).asBean(org.onap.aai.domain.yang.Subnet.class);
+ }
+
+ public Optional<RouteTableReference> getRouteTable(AAIResourceUri rTableUri) {
+ return injectionHelper.getAaiClient().get(rTableUri).asBean(RouteTableReference.class);
+ }
+
+ public Optional<org.onap.aai.domain.yang.L3Network> queryNetworkById(L3Network l3network) {
+ AAIResourceUri uri =
+ AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, l3network.getNetworkId()).depth(Depth.ALL);
+ AAIResultWrapper aaiWrapper = injectionHelper.getAaiClient().get(uri);
+ return aaiWrapper.asBean(org.onap.aai.domain.yang.L3Network.class);
+ }
+
+ public AAIResultWrapper queryNetworkWrapperById(L3Network l3network) {
+ AAIResourceUri uri =
+ AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, l3network.getNetworkId()).depth(Depth.ALL);
+ return injectionHelper.getAaiClient().get(uri);
+ }
+
+ public void createNetworkInstanceGroup(InstanceGroup instanceGroup) {
+ AAIResourceUri instanceGroupURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId());
+ org.onap.aai.domain.yang.InstanceGroup aaiInstanceGroup = aaiObjectMapper.mapInstanceGroup(instanceGroup);
+ injectionHelper.getAaiClient().create(instanceGroupURI, aaiInstanceGroup);
+ }
+
+ public void createNetworkCollection(Collection networkCollection) {
+ AAIResourceUri networkCollectionURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, networkCollection.getId());
+ networkCollection.setOrchestrationStatus(OrchestrationStatus.INVENTORIED);
+ org.onap.aai.domain.yang.Collection aaiCollection = aaiObjectMapper.mapCollection(networkCollection);
+ injectionHelper.getAaiClient().create(networkCollectionURI, aaiCollection);
+ }
+
+ public void connectNetworkToTenant(L3Network l3network, CloudRegion cloudRegion) {
+ AAIResourceUri tenantURI = AAIUriFactory.createResourceUri(AAIObjectType.TENANT, cloudRegion.getCloudOwner(),
+ cloudRegion.getLcpCloudRegionId(), cloudRegion.getTenantId());
+ AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, l3network.getNetworkId());
+ injectionHelper.getAaiClient().connect(tenantURI, networkURI);
+ }
+
+ public void connectNetworkToCloudRegion(L3Network l3network, CloudRegion cloudRegion) {
+ AAIResourceUri cloudRegionURI = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION,
+ cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId());
+ AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, l3network.getNetworkId());
+ injectionHelper.getAaiClient().connect(networkURI, cloudRegionURI);
+ }
+
+ public void connectNetworkToNetworkCollectionInstanceGroup(L3Network l3network, InstanceGroup instanceGroup) {
+ AAIResourceUri netwrokCollectionInstanceGroupURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId());
+ AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, l3network.getNetworkId());
+ injectionHelper.getAaiClient().connect(netwrokCollectionInstanceGroupURI, networkURI);
+ }
+
+ public void connectNetworkToNetworkCollectionServiceInstance(L3Network l3network,
+ ServiceInstance networkCollectionServiceInstance) {
+ AAIResourceUri networkCollectionServiceInstanceUri = AAIUriFactory.createResourceUri(
+ AAIObjectType.SERVICE_INSTANCE, networkCollectionServiceInstance.getServiceInstanceId());
+ AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, l3network.getNetworkId());
+ injectionHelper.getAaiClient().connect(networkCollectionServiceInstanceUri, networkURI);
+ }
+
+ public void connectNetworkCollectionInstanceGroupToNetworkCollection(InstanceGroup instanceGroup,
+ Collection networkCollection) {
+ AAIResourceUri networkCollectionUri =
+ AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, networkCollection.getId());
+ AAIResourceUri netwrokCollectionInstanceGroupURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId());
+ injectionHelper.getAaiClient().connect(networkCollectionUri, netwrokCollectionInstanceGroupURI);
+ }
+
+ public void connectInstanceGroupToCloudRegion(InstanceGroup instanceGroup, CloudRegion cloudRegion) {
+ AAIResourceUri cloudRegionURI = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION,
+ cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId());
+ AAIResourceUri instanceGroupURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId());
+ injectionHelper.getAaiClient().connect(instanceGroupURI, cloudRegionURI, AAIEdgeLabel.USES);
+ }
+
+ public void connectNetworkCollectionToServiceInstance(Collection networkCollection,
+ ServiceInstance networkCollectionServiceInstance) {
+ AAIResourceUri networkCollectionUri =
+ AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, networkCollection.getId());
+ AAIResourceUri networkCollectionServiceInstanceUri = AAIUriFactory.createResourceUri(
+ AAIObjectType.SERVICE_INSTANCE, networkCollectionServiceInstance.getServiceInstanceId());
+ injectionHelper.getAaiClient().connect(networkCollectionUri, networkCollectionServiceInstanceUri);
+ }
+
+ public void deleteCollection(Collection collection) {
+ AAIResourceUri collectionURI = AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, collection.getId());
+ injectionHelper.getAaiClient().delete(collectionURI);
+ }
+
+ public void deleteNetworkInstanceGroup(InstanceGroup instanceGroup) {
+ AAIResourceUri instanceGroupURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId());
+ injectionHelper.getAaiClient().delete(instanceGroupURI);
+ }
+
+ public void createNetworkPolicy(org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy networkPolicy) {
+ NetworkPolicy aaiNetworkPolicy = aaiObjectMapper.mapNetworkPolicy(networkPolicy);
+ String networkPolicyId = networkPolicy.getNetworkPolicyId();
+ AAIResourceUri netUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicyId);
+ injectionHelper.getAaiClient().create(netUri, aaiNetworkPolicy);
+ }
+
+ public void deleteNetworkPolicy(String networkPolicyId) {
+ AAIResourceUri networkPolicyURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicyId);
+ injectionHelper.getAaiClient().delete(networkPolicyURI);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java
index 3032b66e6d..e391349d2c 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java
@@ -23,7 +23,6 @@
package org.onap.so.client.orchestration;
import java.util.Optional;
-
import org.onap.so.bpmn.common.InjectionHelper;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
import org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity;
@@ -43,112 +42,120 @@ import org.springframework.stereotype.Component;
@Component
public class AAIServiceInstanceResources {
- private static final Logger logger = LoggerFactory.getLogger(AAIServiceInstanceResources
- .class);
-
- @Autowired
- private InjectionHelper injectionHelper;
-
- @Autowired
- private AAIObjectMapper aaiObjectMapper;
-
- public boolean existsServiceInstance(ServiceInstance serviceInstance) {
- AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
- serviceInstance.getServiceInstanceId());
- return injectionHelper.getAaiClient().exists(serviceInstanceURI);
- }
-
- public void createServiceInstance(ServiceInstance serviceInstance, Customer customer) {
- AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
- customer.getGlobalCustomerId(), customer.getServiceSubscription().getServiceType(), serviceInstance.getServiceInstanceId());
- serviceInstance.setOrchestrationStatus(OrchestrationStatus.INVENTORIED);
- org.onap.aai.domain.yang.ServiceInstance AAIServiceInstance = aaiObjectMapper.mapServiceInstance(serviceInstance);
- injectionHelper.getAaiClient().createIfNotExists(serviceInstanceURI, Optional.of(AAIServiceInstance));
- }
+ private static final Logger logger = LoggerFactory.getLogger(AAIServiceInstanceResources.class);
+
+ @Autowired
+ private InjectionHelper injectionHelper;
+
+ @Autowired
+ private AAIObjectMapper aaiObjectMapper;
+
+ public boolean existsServiceInstance(ServiceInstance serviceInstance) {
+ AAIResourceUri serviceInstanceURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance.getServiceInstanceId());
+ return injectionHelper.getAaiClient().exists(serviceInstanceURI);
+ }
+
+ public void createServiceInstance(ServiceInstance serviceInstance, Customer customer) {
+ AAIResourceUri serviceInstanceURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, customer.getGlobalCustomerId(),
+ customer.getServiceSubscription().getServiceType(), serviceInstance.getServiceInstanceId());
+ serviceInstance.setOrchestrationStatus(OrchestrationStatus.INVENTORIED);
+ org.onap.aai.domain.yang.ServiceInstance AAIServiceInstance =
+ aaiObjectMapper.mapServiceInstance(serviceInstance);
+ injectionHelper.getAaiClient().createIfNotExists(serviceInstanceURI, Optional.of(AAIServiceInstance));
+ }
/**
* Create ServiceSubscription in A&AI
+ *
* @param customer
*/
- public void createServiceSubscription(Customer customer) {
+ public void createServiceSubscription(Customer customer) {
AAIResourceUri serviceSubscriptionURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_SUBSCRIPTION,
- customer.getGlobalCustomerId(),customer.getServiceSubscription().getServiceType());
- org.onap.aai.domain.yang.ServiceSubscription serviceSubscription = aaiObjectMapper.mapServiceSubscription(customer.getServiceSubscription());
- injectionHelper.getAaiClient().createIfNotExists(serviceSubscriptionURI , Optional.of(serviceSubscription));
+ customer.getGlobalCustomerId(), customer.getServiceSubscription().getServiceType());
+ org.onap.aai.domain.yang.ServiceSubscription serviceSubscription =
+ aaiObjectMapper.mapServiceSubscription(customer.getServiceSubscription());
+ injectionHelper.getAaiClient().createIfNotExists(serviceSubscriptionURI, Optional.of(serviceSubscription));
+ }
+
+ public void deleteServiceInstance(ServiceInstance serviceInstance) {
+ AAIResourceUri serviceInstanceURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance.getServiceInstanceId());
+ injectionHelper.getAaiClient().delete(serviceInstanceURI);
+ }
+
+ public void createProject(Project project) {
+ AAIResourceUri projectURI = AAIUriFactory.createResourceUri(AAIObjectType.PROJECT, project.getProjectName());
+ org.onap.aai.domain.yang.Project AAIProject = aaiObjectMapper.mapProject(project);
+ injectionHelper.getAaiClient().createIfNotExists(projectURI, Optional.of(AAIProject));
+ }
+
+ public void createProjectandConnectServiceInstance(Project project, ServiceInstance serviceInstance) {
+ AAIResourceUri projectURI = AAIUriFactory.createResourceUri(AAIObjectType.PROJECT, project.getProjectName());
+ AAIResourceUri serviceInstanceURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance.getServiceInstanceId());
+ org.onap.aai.domain.yang.Project AAIProject = aaiObjectMapper.mapProject(project);
+ injectionHelper.getAaiClient().createIfNotExists(projectURI, Optional.of(AAIProject)).connect(projectURI,
+ serviceInstanceURI);
+ }
+
+ public void createOwningEntity(OwningEntity owningEntity) {
+ AAIResourceUri owningEntityURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntity.getOwningEntityId());
+ org.onap.aai.domain.yang.OwningEntity AAIOwningEntity = aaiObjectMapper.mapOwningEntity(owningEntity);
+ injectionHelper.getAaiClient().createIfNotExists(owningEntityURI, Optional.of(AAIOwningEntity));
+ }
+
+ public boolean existsOwningEntity(OwningEntity owningEntity) {
+ AAIResourceUri owningEntityUri =
+ AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntity.getOwningEntityId());
+ return injectionHelper.getAaiClient().exists(owningEntityUri);
+ }
+
+ public boolean existsOwningEntityName(String owningEntityName) {
+ AAIResourceUri owningEntityUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.OWNING_ENTITY)
+ .queryParam("owning-entity-name", owningEntityName);
+ AAIResourcesClient aaiRC = injectionHelper.getAaiClient();
+ return aaiRC.exists(owningEntityUri);
+ }
+
+ public void connectOwningEntityandServiceInstance(OwningEntity owningEntity, ServiceInstance serviceInstance) {
+ AAIResourceUri owningEntityURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntity.getOwningEntityId());
+ AAIResourceUri serviceInstanceURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance.getServiceInstanceId());
+ injectionHelper.getAaiClient().connect(owningEntityURI, serviceInstanceURI);
+ }
+
+ public void createOwningEntityandConnectServiceInstance(OwningEntity owningEntity,
+ ServiceInstance serviceInstance) {
+ AAIResourceUri owningEntityURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntity.getOwningEntityId());
+ AAIResourceUri serviceInstanceURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance.getServiceInstanceId());
+ org.onap.aai.domain.yang.OwningEntity AAIOwningEntity = aaiObjectMapper.mapOwningEntity(owningEntity);
+ injectionHelper.getAaiClient().createIfNotExists(owningEntityURI, Optional.of(AAIOwningEntity))
+ .connect(owningEntityURI, serviceInstanceURI);
+ }
+
+ public void updateOrchestrationStatusServiceInstance(ServiceInstance serviceInstance,
+ OrchestrationStatus orchestrationStatus) {
+ ServiceInstance copiedServiceInstance = serviceInstance.shallowCopyId();
+
+ copiedServiceInstance.setOrchestrationStatus(orchestrationStatus);
+ copiedServiceInstance.setServiceInstanceName(serviceInstance.getServiceInstanceName());
+ serviceInstance.setOrchestrationStatus(orchestrationStatus);
+ updateServiceInstance(copiedServiceInstance);
+ }
+
+ public void updateServiceInstance(ServiceInstance serviceInstance) {
+ AAIResourceUri serviceInstanceURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance.getServiceInstanceId());
+ org.onap.aai.domain.yang.ServiceInstance AAIServiceInstance =
+ aaiObjectMapper.mapServiceInstance(serviceInstance);
+ injectionHelper.getAaiClient().update(serviceInstanceURI, AAIServiceInstance);
}
- public void deleteServiceInstance(ServiceInstance serviceInstance) {
- AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
- serviceInstance.getServiceInstanceId());
- injectionHelper.getAaiClient().delete(serviceInstanceURI);
- }
-
- public void createProject(Project project) {
- AAIResourceUri projectURI = AAIUriFactory.createResourceUri(AAIObjectType.PROJECT, project.getProjectName());
- org.onap.aai.domain.yang.Project AAIProject = aaiObjectMapper.mapProject(project);
- injectionHelper.getAaiClient().createIfNotExists(projectURI, Optional.of(AAIProject));
- }
-
- public void createProjectandConnectServiceInstance(Project project, ServiceInstance serviceInstance) {
- AAIResourceUri projectURI = AAIUriFactory.createResourceUri(AAIObjectType.PROJECT, project.getProjectName());
- AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
- serviceInstance.getServiceInstanceId());
- org.onap.aai.domain.yang.Project AAIProject = aaiObjectMapper.mapProject(project);
- injectionHelper.getAaiClient().createIfNotExists(projectURI, Optional.of(AAIProject)).connect(projectURI, serviceInstanceURI);
- }
-
- public void createOwningEntity(OwningEntity owningEntity) {
- AAIResourceUri owningEntityURI = AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY,
- owningEntity.getOwningEntityId());
- org.onap.aai.domain.yang.OwningEntity AAIOwningEntity = aaiObjectMapper.mapOwningEntity(owningEntity);
- injectionHelper.getAaiClient().createIfNotExists(owningEntityURI, Optional.of(AAIOwningEntity));
- }
-
- public boolean existsOwningEntity(OwningEntity owningEntity) {
- AAIResourceUri owningEntityUri = AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY,
- owningEntity.getOwningEntityId());
- return injectionHelper.getAaiClient().exists(owningEntityUri);
- }
-
- public boolean existsOwningEntityName(String owningEntityName) {
- AAIResourceUri owningEntityUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.OWNING_ENTITY).queryParam("owning-entity-name", owningEntityName);
- AAIResourcesClient aaiRC = injectionHelper.getAaiClient();
- return aaiRC.exists(owningEntityUri);
- }
-
- public void connectOwningEntityandServiceInstance(OwningEntity owningEntity, ServiceInstance serviceInstance) {
- AAIResourceUri owningEntityURI = AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY,
- owningEntity.getOwningEntityId());
- AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
- serviceInstance.getServiceInstanceId());
- injectionHelper.getAaiClient().connect(owningEntityURI, serviceInstanceURI);
- }
-
- public void createOwningEntityandConnectServiceInstance(OwningEntity owningEntity,
- ServiceInstance serviceInstance) {
- AAIResourceUri owningEntityURI = AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY,
- owningEntity.getOwningEntityId());
- AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
- serviceInstance.getServiceInstanceId());
- org.onap.aai.domain.yang.OwningEntity AAIOwningEntity = aaiObjectMapper.mapOwningEntity(owningEntity);
- injectionHelper.getAaiClient().createIfNotExists(owningEntityURI, Optional.of(AAIOwningEntity)).connect(owningEntityURI,
- serviceInstanceURI);
- }
-
- public void updateOrchestrationStatusServiceInstance(ServiceInstance serviceInstance, OrchestrationStatus orchestrationStatus){
- ServiceInstance copiedServiceInstance = serviceInstance.shallowCopyId();
-
- copiedServiceInstance.setOrchestrationStatus(orchestrationStatus);
- copiedServiceInstance.setServiceInstanceName(serviceInstance.getServiceInstanceName());
- serviceInstance.setOrchestrationStatus(orchestrationStatus);
- updateServiceInstance(copiedServiceInstance);
- }
-
- public void updateServiceInstance(ServiceInstance serviceInstance) {
- AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance.getServiceInstanceId());
- org.onap.aai.domain.yang.ServiceInstance AAIServiceInstance = aaiObjectMapper.mapServiceInstance(serviceInstance);
- injectionHelper.getAaiClient().update(serviceInstanceURI, AAIServiceInstance);
- }
-
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVfModuleResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVfModuleResources.java
index 5fa73c85ff..83fe31a116 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVfModuleResources.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVfModuleResources.java
@@ -23,7 +23,6 @@
package org.onap.so.client.orchestration;
import java.util.Optional;
-
import org.onap.so.bpmn.common.InjectionHelper;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
@@ -41,62 +40,73 @@ import org.springframework.stereotype.Component;
@Component
public class AAIVfModuleResources {
- private static final Logger logger = LoggerFactory.getLogger(AAIVfModuleResources.class);
-
- @Autowired
- private InjectionHelper injectionHelper;
-
- @Autowired
- private AAIObjectMapper aaiObjectMapper;
+ private static final Logger logger = LoggerFactory.getLogger(AAIVfModuleResources.class);
+
+ @Autowired
+ private InjectionHelper injectionHelper;
+
+ @Autowired
+ private AAIObjectMapper aaiObjectMapper;
+
+ public void createVfModule(VfModule vfModule, GenericVnf vnf) {
+ AAIResourceUri vfModuleURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnf.getVnfId(), vfModule.getVfModuleId());
+ vfModule.setOrchestrationStatus(OrchestrationStatus.INVENTORIED);
+ injectionHelper.getAaiClient().createIfNotExists(vfModuleURI,
+ Optional.of(aaiObjectMapper.mapVfModule(vfModule)));
+ }
+
+ public void deleteVfModule(VfModule vfModule, GenericVnf vnf) {
+ AAIResourceUri vfModuleURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnf.getVnfId(), vfModule.getVfModuleId());
+ injectionHelper.getAaiClient().delete(vfModuleURI);
+ }
+
+ public void updateOrchestrationStatusVfModule(VfModule vfModule, GenericVnf vnf,
+ OrchestrationStatus orchestrationStatus) {
+ AAIResourceUri vfModuleURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnf.getVnfId(), vfModule.getVfModuleId());
+ VfModule copiedVfModule = vfModule.shallowCopyId();
+
+ vfModule.setOrchestrationStatus(orchestrationStatus);
+ copiedVfModule.setOrchestrationStatus(orchestrationStatus);
+ org.onap.aai.domain.yang.VfModule aaiVfModule = aaiObjectMapper.mapVfModule(copiedVfModule);
+ injectionHelper.getAaiClient().update(vfModuleURI, aaiVfModule);
+ }
+
+ public void updateHeatStackIdVfModule(VfModule vfModule, GenericVnf vnf) {
+ AAIResourceUri vfModuleURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnf.getVnfId(), vfModule.getVfModuleId());
+ VfModule copiedVfModule = vfModule.shallowCopyId();
+
+ copiedVfModule.setHeatStackId(vfModule.getHeatStackId());
+ org.onap.aai.domain.yang.VfModule aaiVfModule = aaiObjectMapper.mapVfModule(copiedVfModule);
+ injectionHelper.getAaiClient().update(vfModuleURI, aaiVfModule);
+ }
- public void createVfModule(VfModule vfModule, GenericVnf vnf) {
- AAIResourceUri vfModuleURI = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnf.getVnfId(), vfModule.getVfModuleId());
- vfModule.setOrchestrationStatus(OrchestrationStatus.INVENTORIED);
- injectionHelper.getAaiClient().createIfNotExists(vfModuleURI, Optional.of(aaiObjectMapper.mapVfModule(vfModule)));
- }
-
- public void deleteVfModule(VfModule vfModule, GenericVnf vnf) {
- AAIResourceUri vfModuleURI = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnf.getVnfId(), vfModule.getVfModuleId());
- injectionHelper.getAaiClient().delete(vfModuleURI);
- }
+ public void updateContrailServiceInstanceFqdnVfModule(VfModule vfModule, GenericVnf vnf) {
+ AAIResourceUri vfModuleURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnf.getVnfId(), vfModule.getVfModuleId());
+ VfModule copiedVfModule = vfModule.shallowCopyId();
- public void updateOrchestrationStatusVfModule(VfModule vfModule, GenericVnf vnf, OrchestrationStatus orchestrationStatus) {
- AAIResourceUri vfModuleURI = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnf.getVnfId(), vfModule.getVfModuleId());
- VfModule copiedVfModule = vfModule.shallowCopyId();
+ copiedVfModule.setContrailServiceInstanceFqdn(vfModule.getContrailServiceInstanceFqdn());
+ org.onap.aai.domain.yang.VfModule aaiVfModule = aaiObjectMapper.mapVfModule(copiedVfModule);
+ injectionHelper.getAaiClient().update(vfModuleURI, aaiVfModule);
+ }
- vfModule.setOrchestrationStatus(orchestrationStatus);
- copiedVfModule.setOrchestrationStatus(orchestrationStatus);
- org.onap.aai.domain.yang.VfModule aaiVfModule = aaiObjectMapper.mapVfModule(copiedVfModule);
- injectionHelper.getAaiClient().update(vfModuleURI, aaiVfModule);
- }
-
- public void updateHeatStackIdVfModule(VfModule vfModule, GenericVnf vnf) {
- AAIResourceUri vfModuleURI = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnf.getVnfId(), vfModule.getVfModuleId());
- VfModule copiedVfModule = vfModule.shallowCopyId();
+ public void changeAssignVfModule(VfModule vfModule, GenericVnf vnf) {
+ AAIResourceUri vfModuleURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnf.getVnfId(), vfModule.getVfModuleId());
+ org.onap.aai.domain.yang.VfModule AAIVfModule = aaiObjectMapper.mapVfModule(vfModule);
+ injectionHelper.getAaiClient().update(vfModuleURI, AAIVfModule);
+ }
- copiedVfModule.setHeatStackId(vfModule.getHeatStackId());
- org.onap.aai.domain.yang.VfModule aaiVfModule = aaiObjectMapper.mapVfModule(copiedVfModule);
- injectionHelper.getAaiClient().update(vfModuleURI, aaiVfModule);
- }
-
- public void updateContrailServiceInstanceFqdnVfModule(VfModule vfModule, GenericVnf vnf) {
- AAIResourceUri vfModuleURI = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnf.getVnfId(), vfModule.getVfModuleId());
- VfModule copiedVfModule = vfModule.shallowCopyId();
-
- copiedVfModule.setContrailServiceInstanceFqdn(vfModule.getContrailServiceInstanceFqdn());
- org.onap.aai.domain.yang.VfModule aaiVfModule = aaiObjectMapper.mapVfModule(copiedVfModule);
- injectionHelper.getAaiClient().update(vfModuleURI, aaiVfModule);
- }
-
- public void changeAssignVfModule(VfModule vfModule, GenericVnf vnf) {
- AAIResourceUri vfModuleURI = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnf.getVnfId(), vfModule.getVfModuleId());
- org.onap.aai.domain.yang.VfModule AAIVfModule = aaiObjectMapper.mapVfModule(vfModule);
- injectionHelper.getAaiClient().update(vfModuleURI, AAIVfModule);
- }
-
- public void connectVfModuleToVolumeGroup(GenericVnf vnf, VfModule vfModule, VolumeGroup volumeGroup, CloudRegion cloudRegion) {
- AAIResourceUri vfModuleURI = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnf.getVnfId(), vfModule.getVfModuleId());
- AAIResourceUri volumeGroupURI = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId());
- injectionHelper.getAaiClient().connect(vfModuleURI, volumeGroupURI);
- }
+ public void connectVfModuleToVolumeGroup(GenericVnf vnf, VfModule vfModule, VolumeGroup volumeGroup,
+ CloudRegion cloudRegion) {
+ AAIResourceUri vfModuleURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnf.getVnfId(), vfModule.getVfModuleId());
+ AAIResourceUri volumeGroupURI = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP,
+ cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId());
+ injectionHelper.getAaiClient().connect(vfModuleURI, volumeGroupURI);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVnfResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVnfResources.java
index 48a1c1e558..fc61d862aa 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVnfResources.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVnfResources.java
@@ -24,7 +24,6 @@ package org.onap.so.client.orchestration;
import java.io.IOException;
import java.util.Optional;
-
import org.onap.so.bpmn.common.InjectionHelper;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
@@ -44,104 +43,114 @@ import org.springframework.stereotype.Component;
@Component
public class AAIVnfResources {
- private static final Logger logger = LoggerFactory.getLogger(AAIVnfResources.class);
-
- @Autowired
- private InjectionHelper injectionHelper;
-
- @Autowired
- private AAIObjectMapper aaiObjectMapper;
-
- private AAIValidatorImpl aaiValidatorImpl= new AAIValidatorImpl();
-
- public void createVnfandConnectServiceInstance(GenericVnf vnf, ServiceInstance serviceInstance) {
- AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId());
- vnf.setOrchestrationStatus(OrchestrationStatus.INVENTORIED);
- AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
- serviceInstance.getServiceInstanceId());
- injectionHelper.getAaiClient().createIfNotExists(vnfURI, Optional.of(aaiObjectMapper.mapVnf(vnf))).connect(vnfURI, serviceInstanceURI);
- }
-
- public void createPlatformandConnectVnf(Platform platform, GenericVnf vnf) {
- AAIResourceUri platformURI = AAIUriFactory.createResourceUri(AAIObjectType.PLATFORM, platform.getPlatformName());
- AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId());
- injectionHelper.getAaiClient().createIfNotExists(platformURI, Optional.of(platform)).connect(vnfURI, platformURI);
- }
-
- public void createLineOfBusinessandConnectVnf(LineOfBusiness lineOfBusiness, GenericVnf vnf) {
- AAIResourceUri lineOfBusinessURI = AAIUriFactory.createResourceUri(AAIObjectType.LINE_OF_BUSINESS, lineOfBusiness.getLineOfBusinessName());
- AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId());
- injectionHelper.getAaiClient().createIfNotExists(lineOfBusinessURI, Optional.of(lineOfBusiness)).connect(vnfURI, lineOfBusinessURI);
- }
-
- public void deleteVnf(GenericVnf vnf) {
- AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId());
- injectionHelper.getAaiClient().delete(vnfURI);
- }
-
- public void updateOrchestrationStatusVnf(GenericVnf vnf, OrchestrationStatus orchestrationStatus) {
- AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId());
-
- GenericVnf copiedVnf = vnf.shallowCopyId();
-
- vnf.setOrchestrationStatus(orchestrationStatus);
- copiedVnf.setOrchestrationStatus(orchestrationStatus);
- injectionHelper.getAaiClient().update(vnfURI, aaiObjectMapper.mapVnf(copiedVnf));
- }
-
- public void updateObjectVnf(GenericVnf vnf) {
- AAIResourceUri vnfUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId());
- injectionHelper.getAaiClient().update(vnfUri, aaiObjectMapper.mapVnf(vnf));
- }
-
- /**
- * Retrieve Generic VNF from AAI using vnf Id
- * @param vnfId - vnf-id required vnf
- * @return AAI Generic Vnf
- */
- public Optional<org.onap.aai.domain.yang.GenericVnf> getGenericVnf( String vnfId) {
- return injectionHelper.getAaiClient()
- .get(org.onap.aai.domain.yang.GenericVnf.class, AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId));
- }
-
- /**
- * Check inMaint flag value of Generic VNF from AAI using vnf Id
- * @param vnfId - vnf-id required vnf
- * @return inMaint flag value
- */
- public boolean checkInMaintFlag(String vnfId) {
- org.onap.aai.domain.yang.GenericVnf vnf = injectionHelper.getAaiClient()
- .get(org.onap.aai.domain.yang.GenericVnf.class, AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId))
- .orElse(new org.onap.aai.domain.yang.GenericVnf());
- return vnf.isInMaint();
- }
-
- public void connectVnfToCloudRegion(GenericVnf vnf, CloudRegion cloudRegion) {
- AAIResourceUri cloudRegionURI = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION,
- cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId());
- AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId());
- injectionHelper.getAaiClient().connect(vnfURI,cloudRegionURI);
- }
-
- public void connectVnfToTenant(GenericVnf vnf, CloudRegion cloudRegion) {
- AAIResourceUri tenantURI = AAIUriFactory.createResourceUri(AAIObjectType.TENANT,
- cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId(), cloudRegion.getTenantId());
- AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId());
- injectionHelper.getAaiClient().connect(tenantURI, vnfURI);
- }
-
- public boolean checkVnfClosedLoopDisabledFlag(String vnfId) {
- org.onap.aai.domain.yang.GenericVnf vnf = injectionHelper.getAaiClient()
- .get(org.onap.aai.domain.yang.GenericVnf.class, AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId))
- .orElse(new org.onap.aai.domain.yang.GenericVnf());
- return vnf.isIsClosedLoopDisabled();
- }
-
- public boolean checkVnfPserversLockedFlag (String vnfId) throws IOException {
- org.onap.aai.domain.yang.GenericVnf vnf = injectionHelper.getAaiClient()
- .get(org.onap.aai.domain.yang.GenericVnf.class, AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId))
- .orElse(new org.onap.aai.domain.yang.GenericVnf());
- return aaiValidatorImpl.isPhysicalServerLocked(vnf.getVnfId());
-
- }
+ private static final Logger logger = LoggerFactory.getLogger(AAIVnfResources.class);
+
+ @Autowired
+ private InjectionHelper injectionHelper;
+
+ @Autowired
+ private AAIObjectMapper aaiObjectMapper;
+
+ private AAIValidatorImpl aaiValidatorImpl = new AAIValidatorImpl();
+
+ public void createVnfandConnectServiceInstance(GenericVnf vnf, ServiceInstance serviceInstance) {
+ AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId());
+ vnf.setOrchestrationStatus(OrchestrationStatus.INVENTORIED);
+ AAIResourceUri serviceInstanceURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance.getServiceInstanceId());
+ injectionHelper.getAaiClient().createIfNotExists(vnfURI, Optional.of(aaiObjectMapper.mapVnf(vnf)))
+ .connect(vnfURI, serviceInstanceURI);
+ }
+
+ public void createPlatformandConnectVnf(Platform platform, GenericVnf vnf) {
+ AAIResourceUri platformURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.PLATFORM, platform.getPlatformName());
+ AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId());
+ injectionHelper.getAaiClient().createIfNotExists(platformURI, Optional.of(platform)).connect(vnfURI,
+ platformURI);
+ }
+
+ public void createLineOfBusinessandConnectVnf(LineOfBusiness lineOfBusiness, GenericVnf vnf) {
+ AAIResourceUri lineOfBusinessURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.LINE_OF_BUSINESS, lineOfBusiness.getLineOfBusinessName());
+ AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId());
+ injectionHelper.getAaiClient().createIfNotExists(lineOfBusinessURI, Optional.of(lineOfBusiness)).connect(vnfURI,
+ lineOfBusinessURI);
+ }
+
+ public void deleteVnf(GenericVnf vnf) {
+ AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId());
+ injectionHelper.getAaiClient().delete(vnfURI);
+ }
+
+ public void updateOrchestrationStatusVnf(GenericVnf vnf, OrchestrationStatus orchestrationStatus) {
+ AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId());
+
+ GenericVnf copiedVnf = vnf.shallowCopyId();
+
+ vnf.setOrchestrationStatus(orchestrationStatus);
+ copiedVnf.setOrchestrationStatus(orchestrationStatus);
+ injectionHelper.getAaiClient().update(vnfURI, aaiObjectMapper.mapVnf(copiedVnf));
+ }
+
+ public void updateObjectVnf(GenericVnf vnf) {
+ AAIResourceUri vnfUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId());
+ injectionHelper.getAaiClient().update(vnfUri, aaiObjectMapper.mapVnf(vnf));
+ }
+
+ /**
+ * Retrieve Generic VNF from AAI using vnf Id
+ *
+ * @param vnfId - vnf-id required vnf
+ * @return AAI Generic Vnf
+ */
+ public Optional<org.onap.aai.domain.yang.GenericVnf> getGenericVnf(String vnfId) {
+ return injectionHelper.getAaiClient().get(org.onap.aai.domain.yang.GenericVnf.class,
+ AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId));
+ }
+
+ /**
+ * Check inMaint flag value of Generic VNF from AAI using vnf Id
+ *
+ * @param vnfId - vnf-id required vnf
+ * @return inMaint flag value
+ */
+ public boolean checkInMaintFlag(String vnfId) {
+ org.onap.aai.domain.yang.GenericVnf vnf = injectionHelper.getAaiClient()
+ .get(org.onap.aai.domain.yang.GenericVnf.class,
+ AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId))
+ .orElse(new org.onap.aai.domain.yang.GenericVnf());
+ return vnf.isInMaint();
+ }
+
+ public void connectVnfToCloudRegion(GenericVnf vnf, CloudRegion cloudRegion) {
+ AAIResourceUri cloudRegionURI = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION,
+ cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId());
+ AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId());
+ injectionHelper.getAaiClient().connect(vnfURI, cloudRegionURI);
+ }
+
+ public void connectVnfToTenant(GenericVnf vnf, CloudRegion cloudRegion) {
+ AAIResourceUri tenantURI = AAIUriFactory.createResourceUri(AAIObjectType.TENANT, cloudRegion.getCloudOwner(),
+ cloudRegion.getLcpCloudRegionId(), cloudRegion.getTenantId());
+ AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId());
+ injectionHelper.getAaiClient().connect(tenantURI, vnfURI);
+ }
+
+ public boolean checkVnfClosedLoopDisabledFlag(String vnfId) {
+ org.onap.aai.domain.yang.GenericVnf vnf = injectionHelper.getAaiClient()
+ .get(org.onap.aai.domain.yang.GenericVnf.class,
+ AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId))
+ .orElse(new org.onap.aai.domain.yang.GenericVnf());
+ return vnf.isIsClosedLoopDisabled();
+ }
+
+ public boolean checkVnfPserversLockedFlag(String vnfId) throws IOException {
+ org.onap.aai.domain.yang.GenericVnf vnf = injectionHelper.getAaiClient()
+ .get(org.onap.aai.domain.yang.GenericVnf.class,
+ AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId))
+ .orElse(new org.onap.aai.domain.yang.GenericVnf());
+ return aaiValidatorImpl.isPhysicalServerLocked(vnf.getVnfId());
+
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVolumeGroupResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVolumeGroupResources.java
index 7bb96ec2ed..c24d1483e2 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVolumeGroupResources.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVolumeGroupResources.java
@@ -38,51 +38,60 @@ import org.springframework.stereotype.Component;
@Component
public class AAIVolumeGroupResources {
- private static final Logger logger = LoggerFactory.getLogger(AAIVolumeGroupResources.class);
-
- @Autowired
- private InjectionHelper injectionHelper;
-
- @Autowired
- private AAIObjectMapper aaiObjectMapper;
+ private static final Logger logger = LoggerFactory.getLogger(AAIVolumeGroupResources.class);
- public void createVolumeGroup(VolumeGroup volumeGroup, CloudRegion cloudRegion) {
- AAIResourceUri uriVolumeGroup = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId());
- volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
- injectionHelper.getAaiClient().create(uriVolumeGroup, aaiObjectMapper.mapVolumeGroup(volumeGroup));
- }
-
- public void updateOrchestrationStatusVolumeGroup(VolumeGroup volumeGroup, CloudRegion cloudRegion, OrchestrationStatus orchestrationStatus) {
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId());
- VolumeGroup copiedVolumeGroup = volumeGroup.shallowCopyId();
+ @Autowired
+ private InjectionHelper injectionHelper;
- volumeGroup.setOrchestrationStatus(orchestrationStatus);
- copiedVolumeGroup.setOrchestrationStatus(orchestrationStatus);
- injectionHelper.getAaiClient().update(uri, aaiObjectMapper.mapVolumeGroup(copiedVolumeGroup));
- }
-
- public void connectVolumeGroupToVnf(GenericVnf genericVnf, VolumeGroup volumeGroup, CloudRegion cloudRegion) {
- AAIResourceUri uriGenericVnf = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, genericVnf.getVnfId());
- AAIResourceUri uriVolumeGroup = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId());
- injectionHelper.getAaiClient().connect(uriGenericVnf, uriVolumeGroup);
- }
-
- public void connectVolumeGroupToTenant(VolumeGroup volumeGroup , CloudRegion cloudRegion) {
- AAIResourceUri uriTenant = AAIUriFactory.createResourceUri(AAIObjectType.TENANT, cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId(),cloudRegion.getTenantId());
- AAIResourceUri uriVolumeGroup = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId());
- injectionHelper.getAaiClient().connect(uriTenant, uriVolumeGroup);
- }
-
- public void deleteVolumeGroup(VolumeGroup volumeGroup, CloudRegion cloudRegion) {
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId());
- injectionHelper.getAaiClient().delete(uri);
- }
-
- public void updateHeatStackIdVolumeGroup(VolumeGroup volumeGroup, CloudRegion cloudRegion) {
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId());
- VolumeGroup copiedVolumeGroup = volumeGroup.shallowCopyId();
-
- copiedVolumeGroup.setHeatStackId(volumeGroup.getHeatStackId());
- injectionHelper.getAaiClient().update(uri, aaiObjectMapper.mapVolumeGroup(copiedVolumeGroup));
- }
+ @Autowired
+ private AAIObjectMapper aaiObjectMapper;
+
+ public void createVolumeGroup(VolumeGroup volumeGroup, CloudRegion cloudRegion) {
+ AAIResourceUri uriVolumeGroup = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP,
+ cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId());
+ volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
+ injectionHelper.getAaiClient().create(uriVolumeGroup, aaiObjectMapper.mapVolumeGroup(volumeGroup));
+ }
+
+ public void updateOrchestrationStatusVolumeGroup(VolumeGroup volumeGroup, CloudRegion cloudRegion,
+ OrchestrationStatus orchestrationStatus) {
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, cloudRegion.getCloudOwner(),
+ cloudRegion.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId());
+ VolumeGroup copiedVolumeGroup = volumeGroup.shallowCopyId();
+
+ volumeGroup.setOrchestrationStatus(orchestrationStatus);
+ copiedVolumeGroup.setOrchestrationStatus(orchestrationStatus);
+ injectionHelper.getAaiClient().update(uri, aaiObjectMapper.mapVolumeGroup(copiedVolumeGroup));
+ }
+
+ public void connectVolumeGroupToVnf(GenericVnf genericVnf, VolumeGroup volumeGroup, CloudRegion cloudRegion) {
+ AAIResourceUri uriGenericVnf =
+ AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, genericVnf.getVnfId());
+ AAIResourceUri uriVolumeGroup = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP,
+ cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId());
+ injectionHelper.getAaiClient().connect(uriGenericVnf, uriVolumeGroup);
+ }
+
+ public void connectVolumeGroupToTenant(VolumeGroup volumeGroup, CloudRegion cloudRegion) {
+ AAIResourceUri uriTenant = AAIUriFactory.createResourceUri(AAIObjectType.TENANT, cloudRegion.getCloudOwner(),
+ cloudRegion.getLcpCloudRegionId(), cloudRegion.getTenantId());
+ AAIResourceUri uriVolumeGroup = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP,
+ cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId());
+ injectionHelper.getAaiClient().connect(uriTenant, uriVolumeGroup);
+ }
+
+ public void deleteVolumeGroup(VolumeGroup volumeGroup, CloudRegion cloudRegion) {
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, cloudRegion.getCloudOwner(),
+ cloudRegion.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId());
+ injectionHelper.getAaiClient().delete(uri);
+ }
+
+ public void updateHeatStackIdVolumeGroup(VolumeGroup volumeGroup, CloudRegion cloudRegion) {
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, cloudRegion.getCloudOwner(),
+ cloudRegion.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId());
+ VolumeGroup copiedVolumeGroup = volumeGroup.shallowCopyId();
+
+ copiedVolumeGroup.setHeatStackId(volumeGroup.getHeatStackId());
+ injectionHelper.getAaiClient().update(uri, aaiObjectMapper.mapVolumeGroup(copiedVolumeGroup));
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVpnBindingResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVpnBindingResources.java
index 092af30558..3ac61dff60 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVpnBindingResources.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVpnBindingResources.java
@@ -21,9 +21,7 @@
package org.onap.so.client.orchestration;
import java.util.Optional;
-
import javax.ws.rs.NotFoundException;
-
import org.onap.aai.domain.yang.VpnBindings;
import org.onap.so.bpmn.common.InjectionHelper;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
@@ -38,65 +36,69 @@ import org.springframework.stereotype.Component;
@Component
public class AAIVpnBindingResources {
- @Autowired
- private InjectionHelper injectionHelper;
+ @Autowired
+ private InjectionHelper injectionHelper;
- @Autowired
- private AAIObjectMapper aaiObjectMapper;
+ @Autowired
+ private AAIObjectMapper aaiObjectMapper;
- /**
- * @param customer
- */
- public boolean existsCustomer(Customer customer) {
- AAIResourceUri uriCustomer = AAIUriFactory.createResourceUri(AAIObjectType.CUSTOMER, customer.getGlobalCustomerId());
- return injectionHelper.getAaiClient().exists(uriCustomer);
- }
+ /**
+ * @param customer
+ */
+ public boolean existsCustomer(Customer customer) {
+ AAIResourceUri uriCustomer =
+ AAIUriFactory.createResourceUri(AAIObjectType.CUSTOMER, customer.getGlobalCustomerId());
+ return injectionHelper.getAaiClient().exists(uriCustomer);
+ }
- /**
- * @param customerVpnId
- * @return
- */
- public Optional<VpnBindings> getVpnBindingByCustomerVpnId (String customerVpnId) {
- AAIResourceUri aaiVpnBindingsResourceUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VPN_BINDING)
- .queryParam("customer-vpn-id",customerVpnId);
- return injectionHelper.getAaiClient().get(VpnBindings.class,aaiVpnBindingsResourceUri);
+ /**
+ * @param customerVpnId
+ * @return
+ */
+ public Optional<VpnBindings> getVpnBindingByCustomerVpnId(String customerVpnId) {
+ AAIResourceUri aaiVpnBindingsResourceUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VPN_BINDING)
+ .queryParam("customer-vpn-id", customerVpnId);
+ return injectionHelper.getAaiClient().get(VpnBindings.class, aaiVpnBindingsResourceUri);
- }
+ }
- /**
- * @param vpnBinding
- */
- public void createVpnBinding(VpnBinding vpnBinding) {
- AAIResourceUri aaiVpnBindingResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VPN_BINDING,vpnBinding.getVpnId());
- injectionHelper.getAaiClient().create(aaiVpnBindingResourceUri, aaiObjectMapper.mapVpnBinding(vpnBinding));
- }
+ /**
+ * @param vpnBinding
+ */
+ public void createVpnBinding(VpnBinding vpnBinding) {
+ AAIResourceUri aaiVpnBindingResourceUri =
+ AAIUriFactory.createResourceUri(AAIObjectType.VPN_BINDING, vpnBinding.getVpnId());
+ injectionHelper.getAaiClient().create(aaiVpnBindingResourceUri, aaiObjectMapper.mapVpnBinding(vpnBinding));
+ }
- /**
- * @param customer
- */
- public void createCustomer(Customer customer) {
- AAIResourceUri uriCustomer = AAIUriFactory.createResourceUri(AAIObjectType.CUSTOMER, customer.getGlobalCustomerId());
- injectionHelper.getAaiClient().create(uriCustomer, aaiObjectMapper.mapCustomer(customer));
- }
+ /**
+ * @param customer
+ */
+ public void createCustomer(Customer customer) {
+ AAIResourceUri uriCustomer =
+ AAIUriFactory.createResourceUri(AAIObjectType.CUSTOMER, customer.getGlobalCustomerId());
+ injectionHelper.getAaiClient().create(uriCustomer, aaiObjectMapper.mapCustomer(customer));
+ }
- /**
- * Retrieve VPN Binding from AAI using vpn-id
- * @param vpnId - vpn-id required VPN Binding
- * @return AAI VPN Binding
- */
- public Optional<org.onap.aai.domain.yang.VpnBinding> getVpnBinding(String vpnId){
- return injectionHelper.getAaiClient()
- .get(org.onap.aai.domain.yang.VpnBinding.class, AAIUriFactory.createResourceUri(AAIObjectType.VPN_BINDING, vpnId));
- }
+ /**
+ * Retrieve VPN Binding from AAI using vpn-id
+ *
+ * @param vpnId - vpn-id required VPN Binding
+ * @return AAI VPN Binding
+ */
+ public Optional<org.onap.aai.domain.yang.VpnBinding> getVpnBinding(String vpnId) {
+ return injectionHelper.getAaiClient().get(org.onap.aai.domain.yang.VpnBinding.class,
+ AAIUriFactory.createResourceUri(AAIObjectType.VPN_BINDING, vpnId));
+ }
- /**
- * @param globalSubscriberId
- * @param vpnId
- */
- public void connectCustomerToVpnBinding(String globalSubscriberId, String vpnId) {
- AAIResourceUri customerURI = AAIUriFactory.createResourceUri(AAIObjectType.CUSTOMER, globalSubscriberId);
- AAIResourceUri vpnBindingURI = AAIUriFactory.createResourceUri(AAIObjectType.VPN_BINDING,vpnId);
- injectionHelper.getAaiClient().connect(customerURI, vpnBindingURI);
- }
+ /**
+ * @param globalSubscriberId
+ * @param vpnId
+ */
+ public void connectCustomerToVpnBinding(String globalSubscriberId, String vpnId) {
+ AAIResourceUri customerURI = AAIUriFactory.createResourceUri(AAIObjectType.CUSTOMER, globalSubscriberId);
+ AAIResourceUri vpnBindingURI = AAIUriFactory.createResourceUri(AAIObjectType.VPN_BINDING, vpnId);
+ injectionHelper.getAaiClient().connect(customerURI, vpnBindingURI);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/NamingServiceResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/NamingServiceResources.java
index 2a25ec5ba1..06535bb765 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/NamingServiceResources.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/NamingServiceResources.java
@@ -25,7 +25,6 @@ package org.onap.so.client.orchestration;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
-
import org.onap.namingservice.model.Element;
import org.onap.namingservice.model.Deleteelement;
import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup;
@@ -39,26 +38,29 @@ import org.springframework.stereotype.Component;
@Component
public class NamingServiceResources {
- private static final Logger logger = LoggerFactory.getLogger(NamingServiceResources.class);
- private static final String NAMING_TYPE = "instanceGroup";
-
- @Autowired
- private NamingClient namingClient;
-
- @Autowired
- private NamingRequestObjectBuilder namingRequestObjectBuilder;
-
- public String generateInstanceGroupName(InstanceGroup instanceGroup, String policyInstanceName, String nfNamingCode) throws BadResponseException, IOException {
- Element element = namingRequestObjectBuilder.elementMapper(instanceGroup.getId(), policyInstanceName, NAMING_TYPE, nfNamingCode, instanceGroup.getInstanceGroupName());
- List<Element> elements = new ArrayList<Element>();
- elements.add(element);
- return(namingClient.postNameGenRequest(namingRequestObjectBuilder.nameGenRequestMapper(elements)));
- }
-
- public String deleteInstanceGroupName(InstanceGroup instanceGroup) throws BadResponseException, IOException {
- Deleteelement deleteElement = namingRequestObjectBuilder.deleteElementMapper(instanceGroup.getId());
- List<Deleteelement> deleteElements = new ArrayList<Deleteelement>();
- deleteElements.add(deleteElement);
- return(namingClient.deleteNameGenRequest(namingRequestObjectBuilder.nameGenDeleteRequestMapper(deleteElements)));
- }
+ private static final Logger logger = LoggerFactory.getLogger(NamingServiceResources.class);
+ private static final String NAMING_TYPE = "instanceGroup";
+
+ @Autowired
+ private NamingClient namingClient;
+
+ @Autowired
+ private NamingRequestObjectBuilder namingRequestObjectBuilder;
+
+ public String generateInstanceGroupName(InstanceGroup instanceGroup, String policyInstanceName, String nfNamingCode)
+ throws BadResponseException, IOException {
+ Element element = namingRequestObjectBuilder.elementMapper(instanceGroup.getId(), policyInstanceName,
+ NAMING_TYPE, nfNamingCode, instanceGroup.getInstanceGroupName());
+ List<Element> elements = new ArrayList<Element>();
+ elements.add(element);
+ return (namingClient.postNameGenRequest(namingRequestObjectBuilder.nameGenRequestMapper(elements)));
+ }
+
+ public String deleteInstanceGroupName(InstanceGroup instanceGroup) throws BadResponseException, IOException {
+ Deleteelement deleteElement = namingRequestObjectBuilder.deleteElementMapper(instanceGroup.getId());
+ List<Deleteelement> deleteElements = new ArrayList<Deleteelement>();
+ deleteElements.add(deleteElement);
+ return (namingClient
+ .deleteNameGenRequest(namingRequestObjectBuilder.nameGenDeleteRequestMapper(deleteElements)));
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/NetworkAdapterResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/NetworkAdapterResources.java
index 8f3445529e..b3efa71969 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/NetworkAdapterResources.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/NetworkAdapterResources.java
@@ -23,9 +23,7 @@ package org.onap.so.client.orchestration;
import java.io.UnsupportedEncodingException;
import java.util.Map;
import java.util.Optional;
-
import javax.ws.rs.core.Response;
-
import org.onap.so.adapters.nwrest.CreateNetworkRequest;
import org.onap.so.adapters.nwrest.CreateNetworkResponse;
import org.onap.so.adapters.nwrest.DeleteNetworkRequest;
@@ -48,66 +46,95 @@ import org.springframework.stereotype.Component;
@Component
public class NetworkAdapterResources {
-
- @Autowired
- private NetworkAdapterClientImpl networkAdapterClient;
-
- @Autowired
- private NetworkAdapterObjectMapper networkAdapterObjectMapper;
-
- public Optional<CreateNetworkResponse> createNetwork(RequestContext requestContext, CloudRegion cloudRegion, OrchestrationContext orchestrationContext, ServiceInstance serviceInstance, L3Network l3Network, Map<String, String> userInput, String cloudRegionPo, Customer customer) throws UnsupportedEncodingException, NetworkAdapterClientException {
-
- CreateNetworkRequest createNetworkRequest = networkAdapterObjectMapper.createNetworkRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, customer);
- return Optional.of(networkAdapterClient.createNetwork(createNetworkRequest));
- }
-
- public Optional<RollbackNetworkResponse> rollbackCreateNetwork(RequestContext requestContext, CloudRegion cloudRegion, OrchestrationContext orchestrationContext, ServiceInstance serviceInstance, L3Network l3Network, Map<String, String> userInput, String cloudRegionPo, CreateNetworkResponse createNetworkResponse) throws UnsupportedEncodingException, NetworkAdapterClientException {
-
- RollbackNetworkRequest rollbackNetworkRequest = null;
- rollbackNetworkRequest = networkAdapterObjectMapper.createNetworkRollbackRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, createNetworkResponse);
-
- return Optional.of(networkAdapterClient.rollbackNetwork(l3Network.getNetworkId(), rollbackNetworkRequest));
- }
-
- public Optional<UpdateNetworkResponse> updateNetwork(RequestContext requestContext, CloudRegion cloudRegion, OrchestrationContext orchestrationContext, ServiceInstance serviceInstance, L3Network l3Network, Map<String, String> userInput, Customer customer) throws UnsupportedEncodingException, NetworkAdapterClientException {
- UpdateNetworkRequest updateNetworkRequest = networkAdapterObjectMapper.createNetworkUpdateRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, customer);
-
- return Optional.of(networkAdapterClient.updateNetwork(l3Network.getNetworkId(), updateNetworkRequest));
- }
-
- public Optional<DeleteNetworkResponse> deleteNetwork(RequestContext requestContext, CloudRegion cloudRegion, ServiceInstance serviceInstance, L3Network l3Network) throws UnsupportedEncodingException, NetworkAdapterClientException {
-
- DeleteNetworkRequest deleteNetworkRequest = networkAdapterObjectMapper.deleteNetworkRequestMapper(requestContext, cloudRegion, serviceInstance, l3Network);
- return Optional.of(networkAdapterClient.deleteNetwork(l3Network.getNetworkId(), deleteNetworkRequest));
- }
-
- public Optional<Response> createNetworkAsync(CreateNetworkRequest createNetworkRequest) throws UnsupportedEncodingException, NetworkAdapterClientException {
-
- return Optional.of(networkAdapterClient.createNetworkAsync(createNetworkRequest));
- }
-
- public Optional<Response> deleteNetworkAsync(DeleteNetworkRequest deleteNetworkRequest) throws UnsupportedEncodingException, NetworkAdapterClientException {
-
- return Optional.of(networkAdapterClient.deleteNetworkAsync(deleteNetworkRequest.getNetworkId(), deleteNetworkRequest));
- }
-
- public Optional<Response> updateNetworkAsync(UpdateNetworkRequest updateNetworkRequest) throws UnsupportedEncodingException, NetworkAdapterClientException {
-
- return Optional.of(networkAdapterClient.updateNetworkAsync(updateNetworkRequest.getNetworkId(), updateNetworkRequest));
- }
-
- public Optional<RollbackNetworkResponse> rollbackCreateNetwork(String networkId, RollbackNetworkRequest rollbackNetworkRequest) throws UnsupportedEncodingException, NetworkAdapterClientException {
-
- return Optional.of(networkAdapterClient.rollbackNetwork(networkId, rollbackNetworkRequest));
- }
-
- public Optional<UpdateNetworkResponse> updateNetwork(UpdateNetworkRequest updateNetworkRequest) throws UnsupportedEncodingException, NetworkAdapterClientException {
-
- return Optional.of(networkAdapterClient.updateNetwork(updateNetworkRequest.getNetworkId(), updateNetworkRequest));
- }
-
- public Optional<DeleteNetworkResponse> deleteNetwork(DeleteNetworkRequest deleteNetworkRequest) throws UnsupportedEncodingException, NetworkAdapterClientException {
-
- return Optional.of(networkAdapterClient.deleteNetwork(deleteNetworkRequest.getNetworkId(), deleteNetworkRequest));
- }
+
+ @Autowired
+ private NetworkAdapterClientImpl networkAdapterClient;
+
+ @Autowired
+ private NetworkAdapterObjectMapper networkAdapterObjectMapper;
+
+ public Optional<CreateNetworkResponse> createNetwork(RequestContext requestContext, CloudRegion cloudRegion,
+ OrchestrationContext orchestrationContext, ServiceInstance serviceInstance, L3Network l3Network,
+ Map<String, String> userInput, String cloudRegionPo, Customer customer)
+ throws UnsupportedEncodingException, NetworkAdapterClientException {
+
+ CreateNetworkRequest createNetworkRequest =
+ networkAdapterObjectMapper.createNetworkRequestMapper(requestContext, cloudRegion, orchestrationContext,
+ serviceInstance, l3Network, userInput, cloudRegionPo, customer);
+ return Optional.of(networkAdapterClient.createNetwork(createNetworkRequest));
+ }
+
+ public Optional<RollbackNetworkResponse> rollbackCreateNetwork(RequestContext requestContext,
+ CloudRegion cloudRegion, OrchestrationContext orchestrationContext, ServiceInstance serviceInstance,
+ L3Network l3Network, Map<String, String> userInput, String cloudRegionPo,
+ CreateNetworkResponse createNetworkResponse)
+ throws UnsupportedEncodingException, NetworkAdapterClientException {
+
+ RollbackNetworkRequest rollbackNetworkRequest = null;
+ rollbackNetworkRequest = networkAdapterObjectMapper.createNetworkRollbackRequestMapper(requestContext,
+ cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo,
+ createNetworkResponse);
+
+ return Optional.of(networkAdapterClient.rollbackNetwork(l3Network.getNetworkId(), rollbackNetworkRequest));
+ }
+
+ public Optional<UpdateNetworkResponse> updateNetwork(RequestContext requestContext, CloudRegion cloudRegion,
+ OrchestrationContext orchestrationContext, ServiceInstance serviceInstance, L3Network l3Network,
+ Map<String, String> userInput, Customer customer)
+ throws UnsupportedEncodingException, NetworkAdapterClientException {
+ UpdateNetworkRequest updateNetworkRequest = networkAdapterObjectMapper.createNetworkUpdateRequestMapper(
+ requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, customer);
+
+ return Optional.of(networkAdapterClient.updateNetwork(l3Network.getNetworkId(), updateNetworkRequest));
+ }
+
+ public Optional<DeleteNetworkResponse> deleteNetwork(RequestContext requestContext, CloudRegion cloudRegion,
+ ServiceInstance serviceInstance, L3Network l3Network)
+ throws UnsupportedEncodingException, NetworkAdapterClientException {
+
+ DeleteNetworkRequest deleteNetworkRequest = networkAdapterObjectMapper
+ .deleteNetworkRequestMapper(requestContext, cloudRegion, serviceInstance, l3Network);
+ return Optional.of(networkAdapterClient.deleteNetwork(l3Network.getNetworkId(), deleteNetworkRequest));
+ }
+
+ public Optional<Response> createNetworkAsync(CreateNetworkRequest createNetworkRequest)
+ throws UnsupportedEncodingException, NetworkAdapterClientException {
+
+ return Optional.of(networkAdapterClient.createNetworkAsync(createNetworkRequest));
+ }
+
+ public Optional<Response> deleteNetworkAsync(DeleteNetworkRequest deleteNetworkRequest)
+ throws UnsupportedEncodingException, NetworkAdapterClientException {
+
+ return Optional
+ .of(networkAdapterClient.deleteNetworkAsync(deleteNetworkRequest.getNetworkId(), deleteNetworkRequest));
+ }
+
+ public Optional<Response> updateNetworkAsync(UpdateNetworkRequest updateNetworkRequest)
+ throws UnsupportedEncodingException, NetworkAdapterClientException {
+
+ return Optional
+ .of(networkAdapterClient.updateNetworkAsync(updateNetworkRequest.getNetworkId(), updateNetworkRequest));
+ }
+
+ public Optional<RollbackNetworkResponse> rollbackCreateNetwork(String networkId,
+ RollbackNetworkRequest rollbackNetworkRequest)
+ throws UnsupportedEncodingException, NetworkAdapterClientException {
+
+ return Optional.of(networkAdapterClient.rollbackNetwork(networkId, rollbackNetworkRequest));
+ }
+
+ public Optional<UpdateNetworkResponse> updateNetwork(UpdateNetworkRequest updateNetworkRequest)
+ throws UnsupportedEncodingException, NetworkAdapterClientException {
+
+ return Optional
+ .of(networkAdapterClient.updateNetwork(updateNetworkRequest.getNetworkId(), updateNetworkRequest));
+ }
+
+ public Optional<DeleteNetworkResponse> deleteNetwork(DeleteNetworkRequest deleteNetworkRequest)
+ throws UnsupportedEncodingException, NetworkAdapterClientException {
+
+ return Optional
+ .of(networkAdapterClient.deleteNetwork(deleteNetworkRequest.getNetworkId(), deleteNetworkRequest));
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCConfigurationResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCConfigurationResources.java
index 9dc03ecb88..ca32130c23 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCConfigurationResources.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCConfigurationResources.java
@@ -34,90 +34,83 @@ import org.onap.so.client.sdnc.endpoint.SDNCTopology;
import org.onap.so.client.sdnc.mapper.GCTopologyOperationRequestMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-
import java.net.URI;
-
import org.onap.sdnc.northbound.client.model.GenericResourceApiGcTopologyOperationInformation;
import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration;
@Component
public class SDNCConfigurationResources {
- @Autowired
- private GCTopologyOperationRequestMapper sdncRM;
+ @Autowired
+ private GCTopologyOperationRequestMapper sdncRM;
- /**
- * SDN-C call to assign configuration after it was created in A&AI
- *
- * @param serviceInstance
- * @param requestContext
- * @param vnrConfiguration
- * @param voiceVnf
- * @return
- * @throws MapperException
- * @throws BadResponseException
- */
- public GenericResourceApiGcTopologyOperationInformation assignVnrConfiguration(ServiceInstance serviceInstance,
- RequestContext requestContext,
- Customer customer,
- Configuration vnrConfiguration,
- GenericVnf voiceVnf, String sdncRequestId, URI callbackUri)
- throws MapperException, BadResponseException {
- return sdncRM.assignOrActivateVnrReqMapper(
- SDNCSvcAction.ASSIGN,
- GenericResourceApiRequestActionEnumeration.CREATEGENERICCONFIGURATIONINSTANCE ,
- serviceInstance , requestContext, customer, vnrConfiguration,voiceVnf,sdncRequestId,callbackUri);
- }
+ /**
+ * SDN-C call to assign configuration after it was created in A&AI
+ *
+ * @param serviceInstance
+ * @param requestContext
+ * @param vnrConfiguration
+ * @param voiceVnf
+ * @return
+ * @throws MapperException
+ * @throws BadResponseException
+ */
+ public GenericResourceApiGcTopologyOperationInformation assignVnrConfiguration(ServiceInstance serviceInstance,
+ RequestContext requestContext, Customer customer, Configuration vnrConfiguration, GenericVnf voiceVnf,
+ String sdncRequestId, URI callbackUri) throws MapperException, BadResponseException {
+ return sdncRM.assignOrActivateVnrReqMapper(SDNCSvcAction.ASSIGN,
+ GenericResourceApiRequestActionEnumeration.CREATEGENERICCONFIGURATIONINSTANCE, serviceInstance,
+ requestContext, customer, vnrConfiguration, voiceVnf, sdncRequestId, callbackUri);
+ }
- /**
- * SDNC Call to Activate VNR Configuration
- *
- * @param serviceInstance
- * @param requestContext
- * @param vnrConfiguration
- * @param voiceVnf
- * @return
- * @throws MapperException
- * @throws BadResponseException
- */
- public GenericResourceApiGcTopologyOperationInformation activateVnrConfiguration(ServiceInstance serviceInstance,
- RequestContext requestContext,
- Customer customer,
- Configuration vnrConfiguration,
- GenericVnf voiceVnf, String sdncRequestId, URI callbackUri)
- throws MapperException, BadResponseException {
- return sdncRM.assignOrActivateVnrReqMapper(
- SDNCSvcAction.ACTIVATE,
- GenericResourceApiRequestActionEnumeration.CREATEGENERICCONFIGURATIONINSTANCE,
- serviceInstance , requestContext, customer, vnrConfiguration, voiceVnf,sdncRequestId,callbackUri);
- }
+ /**
+ * SDNC Call to Activate VNR Configuration
+ *
+ * @param serviceInstance
+ * @param requestContext
+ * @param vnrConfiguration
+ * @param voiceVnf
+ * @return
+ * @throws MapperException
+ * @throws BadResponseException
+ */
+ public GenericResourceApiGcTopologyOperationInformation activateVnrConfiguration(ServiceInstance serviceInstance,
+ RequestContext requestContext, Customer customer, Configuration vnrConfiguration, GenericVnf voiceVnf,
+ String sdncRequestId, URI callbackUri) throws MapperException, BadResponseException {
+ return sdncRM.assignOrActivateVnrReqMapper(SDNCSvcAction.ACTIVATE,
+ GenericResourceApiRequestActionEnumeration.CREATEGENERICCONFIGURATIONINSTANCE, serviceInstance,
+ requestContext, customer, vnrConfiguration, voiceVnf, sdncRequestId, callbackUri);
+ }
- /**
- * method to unAssign Vnr Configuration in SDNC
- *
- * @param serviceInstance
- * @param requestContext
- * @param vnrConfiguration
- * @return
- * @throws BadResponseException
- * @throws MapperException
- */
- public GenericResourceApiGcTopologyOperationInformation unAssignVnrConfiguration(ServiceInstance serviceInstance, RequestContext requestContext,
- Configuration vnrConfiguration, String sdncRequestId, URI callbackUri) throws BadResponseException, MapperException {
- return sdncRM.deactivateOrUnassignVnrReqMapper
- (SDNCSvcAction.UNASSIGN,serviceInstance, requestContext, vnrConfiguration,sdncRequestId,callbackUri);
- }
+ /**
+ * method to unAssign Vnr Configuration in SDNC
+ *
+ * @param serviceInstance
+ * @param requestContext
+ * @param vnrConfiguration
+ * @return
+ * @throws BadResponseException
+ * @throws MapperException
+ */
+ public GenericResourceApiGcTopologyOperationInformation unAssignVnrConfiguration(ServiceInstance serviceInstance,
+ RequestContext requestContext, Configuration vnrConfiguration, String sdncRequestId, URI callbackUri)
+ throws BadResponseException, MapperException {
+ return sdncRM.deactivateOrUnassignVnrReqMapper(SDNCSvcAction.UNASSIGN, serviceInstance, requestContext,
+ vnrConfiguration, sdncRequestId, callbackUri);
+ }
- /***
- * Deactivate VNR SDNC Call
- * @param serviceInstance
- * @param requestContext
- * @param vnrConfiguration
- * @throws BadResponseException
- * @throws MapperException
- */
- public GenericResourceApiGcTopologyOperationInformation deactivateVnrConfiguration(ServiceInstance serviceInstance, RequestContext requestContext, Configuration vnrConfiguration, String sdncRequestId, URI callbackUri) throws BadResponseException, MapperException {
- return sdncRM.deactivateOrUnassignVnrReqMapper(
- SDNCSvcAction.DEACTIVATE,
- serviceInstance , requestContext, vnrConfiguration,sdncRequestId,callbackUri);
- }
+ /***
+ * Deactivate VNR SDNC Call
+ *
+ * @param serviceInstance
+ * @param requestContext
+ * @param vnrConfiguration
+ * @throws BadResponseException
+ * @throws MapperException
+ */
+ public GenericResourceApiGcTopologyOperationInformation deactivateVnrConfiguration(ServiceInstance serviceInstance,
+ RequestContext requestContext, Configuration vnrConfiguration, String sdncRequestId, URI callbackUri)
+ throws BadResponseException, MapperException {
+ return sdncRM.deactivateOrUnassignVnrReqMapper(SDNCSvcAction.DEACTIVATE, serviceInstance, requestContext,
+ vnrConfiguration, sdncRequestId, callbackUri);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCNetworkResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCNetworkResources.java
index fb828c1981..54a9cabb57 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCNetworkResources.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCNetworkResources.java
@@ -39,64 +39,64 @@ import org.springframework.stereotype.Component;
@Component
public class SDNCNetworkResources {
- private static final Logger logger = LoggerFactory.getLogger(SDNCNetworkResources.class);
+ private static final Logger logger = LoggerFactory.getLogger(SDNCNetworkResources.class);
- @Autowired
- private NetworkTopologyOperationRequestMapper sdncRM;
+ @Autowired
+ private NetworkTopologyOperationRequestMapper sdncRM;
- public GenericResourceApiNetworkOperationInformation assignNetwork(L3Network network,
- ServiceInstance serviceInstance, Customer customer, RequestContext requestContext,
- CloudRegion cloudRegion) {
- return sdncRM.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,
- GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, customer,
- requestContext, cloudRegion);
- }
+ public GenericResourceApiNetworkOperationInformation assignNetwork(L3Network network,
+ ServiceInstance serviceInstance, Customer customer, RequestContext requestContext,
+ CloudRegion cloudRegion) {
+ return sdncRM.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,
+ GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, customer,
+ requestContext, cloudRegion);
+ }
- public GenericResourceApiNetworkOperationInformation rollbackAssignNetwork(L3Network network,
- ServiceInstance serviceInstance, Customer customer, RequestContext requestContext,
- CloudRegion cloudRegion) {
- return sdncRM.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN,
- GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, customer,
- requestContext, cloudRegion);
- }
+ public GenericResourceApiNetworkOperationInformation rollbackAssignNetwork(L3Network network,
+ ServiceInstance serviceInstance, Customer customer, RequestContext requestContext,
+ CloudRegion cloudRegion) {
+ return sdncRM.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN,
+ GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, customer,
+ requestContext, cloudRegion);
+ }
- public GenericResourceApiNetworkOperationInformation activateNetwork(L3Network network,
- ServiceInstance serviceInstance, Customer customer, RequestContext requestContext,
- CloudRegion cloudRegion) {
- return sdncRM.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ACTIVATE,
- GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, customer,
- requestContext, cloudRegion);
- }
+ public GenericResourceApiNetworkOperationInformation activateNetwork(L3Network network,
+ ServiceInstance serviceInstance, Customer customer, RequestContext requestContext,
+ CloudRegion cloudRegion) {
+ return sdncRM.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ACTIVATE,
+ GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, customer,
+ requestContext, cloudRegion);
+ }
- public GenericResourceApiNetworkOperationInformation deactivateNetwork(L3Network network,
- ServiceInstance serviceInstance, Customer customer, RequestContext requestContext,
- CloudRegion cloudRegion) {
- return sdncRM.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.DEACTIVATE,
- GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, customer,
- requestContext, cloudRegion);
- }
+ public GenericResourceApiNetworkOperationInformation deactivateNetwork(L3Network network,
+ ServiceInstance serviceInstance, Customer customer, RequestContext requestContext,
+ CloudRegion cloudRegion) {
+ return sdncRM.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.DEACTIVATE,
+ GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, customer,
+ requestContext, cloudRegion);
+ }
- public GenericResourceApiNetworkOperationInformation deleteNetwork(L3Network network,
- ServiceInstance serviceInstance, Customer customer, RequestContext requestContext,
- CloudRegion cloudRegion) {
- return sdncRM.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.DELETE,
- GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, customer,
- requestContext, cloudRegion);
- }
+ public GenericResourceApiNetworkOperationInformation deleteNetwork(L3Network network,
+ ServiceInstance serviceInstance, Customer customer, RequestContext requestContext,
+ CloudRegion cloudRegion) {
+ return sdncRM.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.DELETE,
+ GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, customer,
+ requestContext, cloudRegion);
+ }
- public GenericResourceApiNetworkOperationInformation changeAssignNetwork(L3Network network,
- ServiceInstance serviceInstance, Customer customer, RequestContext requestContext,
- CloudRegion cloudRegion) {
- return sdncRM.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.CHANGE_ASSIGN,
- GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, customer,
- requestContext, cloudRegion);
- }
+ public GenericResourceApiNetworkOperationInformation changeAssignNetwork(L3Network network,
+ ServiceInstance serviceInstance, Customer customer, RequestContext requestContext,
+ CloudRegion cloudRegion) {
+ return sdncRM.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.CHANGE_ASSIGN,
+ GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, customer,
+ requestContext, cloudRegion);
+ }
- public GenericResourceApiNetworkOperationInformation unassignNetwork(L3Network network,
- ServiceInstance serviceInstance, Customer customer, RequestContext requestContext,
- CloudRegion cloudRegion) {
- return sdncRM.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN,
- GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, customer,
- requestContext, cloudRegion);
- }
+ public GenericResourceApiNetworkOperationInformation unassignNetwork(L3Network network,
+ ServiceInstance serviceInstance, Customer customer, RequestContext requestContext,
+ CloudRegion cloudRegion) {
+ return sdncRM.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN,
+ GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, customer,
+ requestContext, cloudRegion);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCServiceInstanceResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCServiceInstanceResources.java
index a4c9b8fe05..960efea2f0 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCServiceInstanceResources.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCServiceInstanceResources.java
@@ -36,82 +36,81 @@ import org.springframework.stereotype.Component;
@Component
public class SDNCServiceInstanceResources {
- @Autowired
- private ServiceTopologyOperationMapper sdncRM;
+ @Autowired
+ private ServiceTopologyOperationMapper sdncRM;
- /**
- * SDNC call to perform Service Topology Assign for ServiceInsatnce
- *
- * @param serviceInstance
- * @param customer
- * @param requestContext
- * @throws MapperException
- * @throws BadResponseException
- * @return the response as a String
- */
- public GenericResourceApiServiceOperationInformation assignServiceInstance(ServiceInstance serviceInstance,
- Customer customer, RequestContext requestContext) {
- return sdncRM.reqMapper(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,
- GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE, serviceInstance, customer,
- requestContext);
- }
+ /**
+ * SDNC call to perform Service Topology Assign for ServiceInsatnce
+ *
+ * @param serviceInstance
+ * @param customer
+ * @param requestContext
+ * @throws MapperException
+ * @throws BadResponseException
+ * @return the response as a String
+ */
+ public GenericResourceApiServiceOperationInformation assignServiceInstance(ServiceInstance serviceInstance,
+ Customer customer, RequestContext requestContext) {
+ return sdncRM.reqMapper(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,
+ GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE, serviceInstance, customer,
+ requestContext);
+ }
- /**
- * SDNC call to perform Service Topology Delete for ServiceInsatnce
- *
- * @param serviceInstance
- * @param customer
- * @param requestContext
- * @throws MapperException
- * @throws BadResponseException
- * @return the response as a String
- */
- public GenericResourceApiServiceOperationInformation deleteServiceInstance(ServiceInstance serviceInstance,
- Customer customer, RequestContext requestContext) {
- return sdncRM.reqMapper(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.DELETE,
- GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE, serviceInstance, customer,
- requestContext);
- }
+ /**
+ * SDNC call to perform Service Topology Delete for ServiceInsatnce
+ *
+ * @param serviceInstance
+ * @param customer
+ * @param requestContext
+ * @throws MapperException
+ * @throws BadResponseException
+ * @return the response as a String
+ */
+ public GenericResourceApiServiceOperationInformation deleteServiceInstance(ServiceInstance serviceInstance,
+ Customer customer, RequestContext requestContext) {
+ return sdncRM.reqMapper(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.DELETE,
+ GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE, serviceInstance, customer,
+ requestContext);
+ }
- public GenericResourceApiServiceOperationInformation unassignServiceInstance(ServiceInstance serviceInstance,
- Customer customer, RequestContext requestContext) {
- return sdncRM.reqMapper(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.DELETE,
- GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE, serviceInstance, customer,
- requestContext);
- }
+ public GenericResourceApiServiceOperationInformation unassignServiceInstance(ServiceInstance serviceInstance,
+ Customer customer, RequestContext requestContext) {
+ return sdncRM.reqMapper(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.DELETE,
+ GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE, serviceInstance, customer,
+ requestContext);
+ }
- /**
- * SDNC call to perform Service Topology Deactivate for ServiceInstance
- *
- * @param serviceInstance
- * @param customer
- * @param requestContext
- * @throws MapperException
- * @throws BadResponseException
- * @return the response as a String
- */
- public GenericResourceApiServiceOperationInformation deactivateServiceInstance(ServiceInstance serviceInstance,
- Customer customer, RequestContext requestContext) {
- return sdncRM.reqMapper(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.DEACTIVATE,
- GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE, serviceInstance, customer,
- requestContext);
- }
+ /**
+ * SDNC call to perform Service Topology Deactivate for ServiceInstance
+ *
+ * @param serviceInstance
+ * @param customer
+ * @param requestContext
+ * @throws MapperException
+ * @throws BadResponseException
+ * @return the response as a String
+ */
+ public GenericResourceApiServiceOperationInformation deactivateServiceInstance(ServiceInstance serviceInstance,
+ Customer customer, RequestContext requestContext) {
+ return sdncRM.reqMapper(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.DEACTIVATE,
+ GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE, serviceInstance, customer,
+ requestContext);
+ }
- /**
- * SDNC call to perform Service Topology Change Assign for the
- * ServiceInstance
- *
- * @param serviceInstance
- * @param customer
- * @param requestContext
- * @throws MapperException
- * @throws BadResponseException
- * @return the response as a String
- */
- public GenericResourceApiServiceOperationInformation changeModelServiceInstance(ServiceInstance serviceInstance,
- Customer customer, RequestContext requestContext) {
- return sdncRM.reqMapper(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.CHANGE_ASSIGN,
- GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE, serviceInstance, customer,
- requestContext);
- }
+ /**
+ * SDNC call to perform Service Topology Change Assign for the ServiceInstance
+ *
+ * @param serviceInstance
+ * @param customer
+ * @param requestContext
+ * @throws MapperException
+ * @throws BadResponseException
+ * @return the response as a String
+ */
+ public GenericResourceApiServiceOperationInformation changeModelServiceInstance(ServiceInstance serviceInstance,
+ Customer customer, RequestContext requestContext) {
+ return sdncRM.reqMapper(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.CHANGE_ASSIGN,
+ GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE, serviceInstance, customer,
+ requestContext);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVfModuleResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVfModuleResources.java
index 1e3d655298..60cad78f5d 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVfModuleResources.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVfModuleResources.java
@@ -43,50 +43,50 @@ import org.springframework.stereotype.Component;
@Component
public class SDNCVfModuleResources {
- private static final Logger logger = LoggerFactory.getLogger(SDNCVfModuleResources.class);
+ private static final Logger logger = LoggerFactory.getLogger(SDNCVfModuleResources.class);
- @Autowired
- private VfModuleTopologyOperationRequestMapper sdncRM;
+ @Autowired
+ private VfModuleTopologyOperationRequestMapper sdncRM;
- @Autowired
- private SDNCClient sdncClient;
+ @Autowired
+ private SDNCClient sdncClient;
- public GenericResourceApiVfModuleOperationInformation assignVfModule(VfModule vfModule, VolumeGroup volumeGroup,
- GenericVnf vnf, ServiceInstance serviceInstance, Customer customer, CloudRegion cloudRegion,
- RequestContext requestContext) throws MapperException {
- return sdncRM.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, vfModule,
- volumeGroup, vnf, serviceInstance, customer, cloudRegion, requestContext, null);
- }
+ public GenericResourceApiVfModuleOperationInformation assignVfModule(VfModule vfModule, VolumeGroup volumeGroup,
+ GenericVnf vnf, ServiceInstance serviceInstance, Customer customer, CloudRegion cloudRegion,
+ RequestContext requestContext) throws MapperException {
+ return sdncRM.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, vfModule,
+ volumeGroup, vnf, serviceInstance, customer, cloudRegion, requestContext, null);
+ }
- public GenericResourceApiVfModuleOperationInformation unassignVfModule(VfModule vfModule, GenericVnf vnf,
- ServiceInstance serviceInstance) throws MapperException {
- return sdncRM.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN, vfModule, null,
- vnf, serviceInstance, null, null, null, null);
- }
+ public GenericResourceApiVfModuleOperationInformation unassignVfModule(VfModule vfModule, GenericVnf vnf,
+ ServiceInstance serviceInstance) throws MapperException {
+ return sdncRM.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN, vfModule, null,
+ vnf, serviceInstance, null, null, null, null);
+ }
- public GenericResourceApiVfModuleOperationInformation deactivateVfModule(VfModule vfModule, GenericVnf vnf,
- ServiceInstance serviceInstance, Customer customer, CloudRegion cloudRegion, RequestContext requestContext)
- throws MapperException {
- return sdncRM.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.DEACTIVATE, vfModule, null,
- vnf, serviceInstance, customer, cloudRegion, requestContext, null);
- }
+ public GenericResourceApiVfModuleOperationInformation deactivateVfModule(VfModule vfModule, GenericVnf vnf,
+ ServiceInstance serviceInstance, Customer customer, CloudRegion cloudRegion, RequestContext requestContext)
+ throws MapperException {
+ return sdncRM.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.DEACTIVATE, vfModule, null,
+ vnf, serviceInstance, customer, cloudRegion, requestContext, null);
+ }
- public String queryVfModule(VfModule vfModule) throws MapperException, BadResponseException {
- String objectPath = vfModule.getSelflink();
- return sdncClient.get(objectPath);
- }
+ public String queryVfModule(VfModule vfModule) throws MapperException, BadResponseException {
+ String objectPath = vfModule.getSelflink();
+ return sdncClient.get(objectPath);
+ }
- public GenericResourceApiVfModuleOperationInformation activateVfModule(VfModule vfModule, GenericVnf vnf,
- ServiceInstance serviceInstance, Customer customer, CloudRegion cloudRegion, RequestContext requestContext)
- throws MapperException {
- return sdncRM.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ACTIVATE, vfModule, null,
- vnf, serviceInstance, customer, cloudRegion, requestContext, null);
- }
+ public GenericResourceApiVfModuleOperationInformation activateVfModule(VfModule vfModule, GenericVnf vnf,
+ ServiceInstance serviceInstance, Customer customer, CloudRegion cloudRegion, RequestContext requestContext)
+ throws MapperException {
+ return sdncRM.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ACTIVATE, vfModule, null,
+ vnf, serviceInstance, customer, cloudRegion, requestContext, null);
+ }
- public GenericResourceApiVfModuleOperationInformation changeAssignVfModule(VfModule vfModule, GenericVnf vnf,
- ServiceInstance serviceInstance, Customer customer, CloudRegion cloudRegion, RequestContext requestContext)
- throws MapperException {
- return sdncRM.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.CHANGE_ASSIGN, vfModule,
- null, vnf, serviceInstance, customer, cloudRegion, requestContext, null);
- }
+ public GenericResourceApiVfModuleOperationInformation changeAssignVfModule(VfModule vfModule, GenericVnf vnf,
+ ServiceInstance serviceInstance, Customer customer, CloudRegion cloudRegion, RequestContext requestContext)
+ throws MapperException {
+ return sdncRM.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.CHANGE_ASSIGN, vfModule,
+ null, vnf, serviceInstance, customer, cloudRegion, requestContext, null);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVnfResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVnfResources.java
index d8f2e47224..954cbc1b1d 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVnfResources.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVnfResources.java
@@ -42,54 +42,60 @@ import org.springframework.stereotype.Component;
@Component
public class SDNCVnfResources {
- private static final Logger logger = LoggerFactory.getLogger(SDNCVnfResources.class);
+ private static final Logger logger = LoggerFactory.getLogger(SDNCVnfResources.class);
- @Autowired
- private VnfTopologyOperationRequestMapper sdncRM;
-
- @Autowired
- private SDNCClient sdncClient;
-
- public GenericResourceApiVnfOperationInformation assignVnf(GenericVnf vnf, ServiceInstance serviceInstance, Customer customer,
- CloudRegion cloudRegion, RequestContext requestContext, boolean homing) {
- return sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION,
- SDNCSvcAction.ASSIGN,GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer, cloudRegion, requestContext, homing);
- }
+ @Autowired
+ private VnfTopologyOperationRequestMapper sdncRM;
- public GenericResourceApiVnfOperationInformation activateVnf(GenericVnf vnf, ServiceInstance serviceInstance, Customer customer,
- CloudRegion cloudRegion, RequestContext requestContext) {
- return sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION,
- SDNCSvcAction.ACTIVATE,GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer,cloudRegion, requestContext, false);
- }
+ @Autowired
+ private SDNCClient sdncClient;
-
- public GenericResourceApiVnfOperationInformation deactivateVnf(GenericVnf vnf, ServiceInstance serviceInstance, Customer customer,
- CloudRegion cloudRegion, RequestContext requestContext) {
- return sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION,
- SDNCSvcAction.DEACTIVATE,GenericResourceApiRequestActionEnumeration.DELETEVNFINSTANCE, vnf, serviceInstance, customer,cloudRegion, requestContext, false);
- }
+ public GenericResourceApiVnfOperationInformation assignVnf(GenericVnf vnf, ServiceInstance serviceInstance,
+ Customer customer, CloudRegion cloudRegion, RequestContext requestContext, boolean homing) {
+ return sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,
+ GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer,
+ cloudRegion, requestContext, homing);
+ }
-
- public GenericResourceApiVnfOperationInformation unassignVnf(GenericVnf vnf, ServiceInstance serviceInstance, Customer customer,
- CloudRegion cloudRegion, RequestContext requestContext) {
- return sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION,
- SDNCSvcAction.UNASSIGN,GenericResourceApiRequestActionEnumeration.DELETEVNFINSTANCE, vnf, serviceInstance, customer, cloudRegion, requestContext, false);
- }
-
- public GenericResourceApiVnfOperationInformation deleteVnf(GenericVnf vnf, ServiceInstance serviceInstance, Customer customer,
- CloudRegion cloudRegion, RequestContext requestContext) {
- return sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION,
- SDNCSvcAction.DEACTIVATE, GenericResourceApiRequestActionEnumeration.DELETEVNFINSTANCE,vnf, serviceInstance, customer, cloudRegion, requestContext, false);
- }
-
- public GenericResourceApiVnfOperationInformation changeModelVnf(GenericVnf vnf, ServiceInstance serviceInstance, Customer customer,
- CloudRegion cloudRegion, RequestContext requestContext) {
- return sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION,
- SDNCSvcAction.CHANGE_ASSIGN,GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer, cloudRegion, requestContext, false);
- }
-
- public String queryVnf(GenericVnf vnf) throws MapperException, BadResponseException {
- String queryPath = vnf.getSelflink();
- return sdncClient.get(queryPath);
- }
+ public GenericResourceApiVnfOperationInformation activateVnf(GenericVnf vnf, ServiceInstance serviceInstance,
+ Customer customer, CloudRegion cloudRegion, RequestContext requestContext) {
+ return sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.ACTIVATE,
+ GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer,
+ cloudRegion, requestContext, false);
+ }
+
+
+ public GenericResourceApiVnfOperationInformation deactivateVnf(GenericVnf vnf, ServiceInstance serviceInstance,
+ Customer customer, CloudRegion cloudRegion, RequestContext requestContext) {
+ return sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.DEACTIVATE,
+ GenericResourceApiRequestActionEnumeration.DELETEVNFINSTANCE, vnf, serviceInstance, customer,
+ cloudRegion, requestContext, false);
+ }
+
+
+ public GenericResourceApiVnfOperationInformation unassignVnf(GenericVnf vnf, ServiceInstance serviceInstance,
+ Customer customer, CloudRegion cloudRegion, RequestContext requestContext) {
+ return sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN,
+ GenericResourceApiRequestActionEnumeration.DELETEVNFINSTANCE, vnf, serviceInstance, customer,
+ cloudRegion, requestContext, false);
+ }
+
+ public GenericResourceApiVnfOperationInformation deleteVnf(GenericVnf vnf, ServiceInstance serviceInstance,
+ Customer customer, CloudRegion cloudRegion, RequestContext requestContext) {
+ return sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.DEACTIVATE,
+ GenericResourceApiRequestActionEnumeration.DELETEVNFINSTANCE, vnf, serviceInstance, customer,
+ cloudRegion, requestContext, false);
+ }
+
+ public GenericResourceApiVnfOperationInformation changeModelVnf(GenericVnf vnf, ServiceInstance serviceInstance,
+ Customer customer, CloudRegion cloudRegion, RequestContext requestContext) {
+ return sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.CHANGE_ASSIGN,
+ GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer,
+ cloudRegion, requestContext, false);
+ }
+
+ public String queryVnf(GenericVnf vnf) throws MapperException, BadResponseException {
+ String queryPath = vnf.getSelflink();
+ return sdncClient.get(queryPath);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNOHealthCheckResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNOHealthCheckResources.java
index dac89a495d..e93b80c562 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNOHealthCheckResources.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNOHealthCheckResources.java
@@ -21,7 +21,6 @@
package org.onap.so.client.orchestration;
import java.util.UUID;
-
import org.onap.so.bpmn.common.InjectionHelper;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
@@ -30,24 +29,23 @@ import org.springframework.stereotype.Component;
@Component
public class SDNOHealthCheckResources {
- @Autowired
- private InjectionHelper injectionHelper;
-
+ @Autowired
+ private InjectionHelper injectionHelper;
+
/**
* SDNO Call to Check Health Status
*
* @param vnf
- * @param requestContext *
+ * @param requestContext *
* @return healthCheckResult
- * @throws
- * @throws Exception
+ * @throws @throws Exception
*/
public boolean healthCheck(GenericVnf vnf, RequestContext requestContext) throws Exception {
- String requestId = requestContext.getMsoRequestId();
- String requestorId = requestContext.getRequestorId();
- String vnfId = vnf.getVnfId();
- UUID uuid = UUID.fromString(requestId);
+ String requestId = requestContext.getMsoRequestId();
+ String requestorId = requestContext.getRequestorId();
+ String vnfId = vnf.getVnfId();
+ UUID uuid = UUID.fromString(requestId);
- return injectionHelper.getSdnoValidator().healthDiagnostic(vnfId, uuid, requestorId);
- }
+ return injectionHelper.getSdnoValidator().healthDiagnostic(vnfId, uuid, requestorId);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/VnfAdapterVfModuleResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/VnfAdapterVfModuleResources.java
index de59e6835e..939f53727d 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/VnfAdapterVfModuleResources.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/VnfAdapterVfModuleResources.java
@@ -23,7 +23,6 @@
package org.onap.so.client.orchestration;
import java.io.IOException;
-
import org.onap.so.adapters.vnfrest.CreateVfModuleRequest;
import org.onap.so.adapters.vnfrest.DeleteVfModuleRequest;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
@@ -41,19 +40,23 @@ import org.springframework.stereotype.Component;
@Component
public class VnfAdapterVfModuleResources {
- private static final Logger logger = LoggerFactory.getLogger(VnfAdapterVfModuleResources.class);
-
- @Autowired
- private VnfAdapterVfModuleObjectMapper vnfAdapterVfModuleObjectMapper;
-
- public CreateVfModuleRequest createVfModuleRequest(RequestContext requestContext, CloudRegion cloudRegion, OrchestrationContext orchestrationContext, ServiceInstance serviceInstance, GenericVnf genericVnf,
- VfModule vfModule, VolumeGroup volumeGroup, String sdncVnfQueryResponse, String sdncVfModuleQueryResponse) throws IOException {
- return vnfAdapterVfModuleObjectMapper.createVfModuleRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, vfModule, volumeGroup, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
- }
-
- public DeleteVfModuleRequest deleteVfModuleRequest(RequestContext requestContext, CloudRegion cloudRegion,
- ServiceInstance serviceInstance, GenericVnf genericVnf,
- VfModule vfModule) throws IOException {
- return vnfAdapterVfModuleObjectMapper.deleteVfModuleRequestMapper(requestContext, cloudRegion, serviceInstance, genericVnf, vfModule);
- }
+ private static final Logger logger = LoggerFactory.getLogger(VnfAdapterVfModuleResources.class);
+
+ @Autowired
+ private VnfAdapterVfModuleObjectMapper vnfAdapterVfModuleObjectMapper;
+
+ public CreateVfModuleRequest createVfModuleRequest(RequestContext requestContext, CloudRegion cloudRegion,
+ OrchestrationContext orchestrationContext, ServiceInstance serviceInstance, GenericVnf genericVnf,
+ VfModule vfModule, VolumeGroup volumeGroup, String sdncVnfQueryResponse, String sdncVfModuleQueryResponse)
+ throws IOException {
+ return vnfAdapterVfModuleObjectMapper.createVfModuleRequestMapper(requestContext, cloudRegion,
+ orchestrationContext, serviceInstance, genericVnf, vfModule, volumeGroup, sdncVnfQueryResponse,
+ sdncVfModuleQueryResponse);
+ }
+
+ public DeleteVfModuleRequest deleteVfModuleRequest(RequestContext requestContext, CloudRegion cloudRegion,
+ ServiceInstance serviceInstance, GenericVnf genericVnf, VfModule vfModule) throws IOException {
+ return vnfAdapterVfModuleObjectMapper.deleteVfModuleRequestMapper(requestContext, cloudRegion, serviceInstance,
+ genericVnf, vfModule);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/VnfAdapterVolumeGroupResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/VnfAdapterVolumeGroupResources.java
index 737e9eeb37..c97ca8e0ea 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/VnfAdapterVolumeGroupResources.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/VnfAdapterVolumeGroupResources.java
@@ -39,19 +39,24 @@ import org.springframework.stereotype.Component;
@Component
public class VnfAdapterVolumeGroupResources {
- private static final Logger logger = LoggerFactory.getLogger(VnfAdapterVolumeGroupResources.class);
+ private static final Logger logger = LoggerFactory.getLogger(VnfAdapterVolumeGroupResources.class);
- @Autowired
- private VnfAdapterObjectMapper vnfAdapterObjectMapper;
-
- @Autowired
- private VnfVolumeAdapterClientImpl vnfVolumeAdapterClient;
-
- public CreateVolumeGroupRequest createVolumeGroupRequest(RequestContext requestContext, CloudRegion cloudRegion, OrchestrationContext orchestrationContext, ServiceInstance serviceInstance, GenericVnf genericVnf, VolumeGroup volumeGroup, String sdncVfModuleQueryResponse) throws Exception {
- return vnfAdapterObjectMapper.createVolumeGroupRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, volumeGroup, sdncVfModuleQueryResponse);
- }
-
- public DeleteVolumeGroupRequest deleteVolumeGroupRequest(RequestContext requestContext, CloudRegion cloudRegion, ServiceInstance serviceInstance, VolumeGroup volumeGroup) throws Exception {
- return vnfAdapterObjectMapper.deleteVolumeGroupRequestMapper(requestContext, cloudRegion, serviceInstance, volumeGroup);
- }
+ @Autowired
+ private VnfAdapterObjectMapper vnfAdapterObjectMapper;
+
+ @Autowired
+ private VnfVolumeAdapterClientImpl vnfVolumeAdapterClient;
+
+ public CreateVolumeGroupRequest createVolumeGroupRequest(RequestContext requestContext, CloudRegion cloudRegion,
+ OrchestrationContext orchestrationContext, ServiceInstance serviceInstance, GenericVnf genericVnf,
+ VolumeGroup volumeGroup, String sdncVfModuleQueryResponse) throws Exception {
+ return vnfAdapterObjectMapper.createVolumeGroupRequestMapper(requestContext, cloudRegion, orchestrationContext,
+ serviceInstance, genericVnf, volumeGroup, sdncVfModuleQueryResponse);
+ }
+
+ public DeleteVolumeGroupRequest deleteVolumeGroupRequest(RequestContext requestContext, CloudRegion cloudRegion,
+ ServiceInstance serviceInstance, VolumeGroup volumeGroup) throws Exception {
+ return vnfAdapterObjectMapper.deleteVolumeGroupRequestMapper(requestContext, cloudRegion, serviceInstance,
+ volumeGroup);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java
index cae4a19f20..732bba8489 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java
@@ -23,9 +23,7 @@
package org.onap.so.client.sdnc;
import java.util.LinkedHashMap;
-
import javax.ws.rs.core.UriBuilder;
-
import org.onap.so.bpmn.common.baseclient.BaseClient;
import org.onap.so.client.exception.BadResponseException;
import org.onap.so.client.exception.MapperException;
@@ -41,65 +39,63 @@ import org.springframework.stereotype.Component;
@Component
public class SDNCClient {
- private static final Logger logger = LoggerFactory.getLogger(SDNCClient.class);
+ private static final Logger logger = LoggerFactory.getLogger(SDNCClient.class);
+
+ @Autowired
+ private SDNCProperties properties;
+ @Autowired
+ private SdnCommonTasks sdnCommonTasks;
+
+ /**
+ *
+ * @param request - takes in a generated object from sdnc client - creates a json request string and sends it to
+ * sdnc - receives and validates the linkedhashmap sent back from sdnc
+ * @throws MapperException
+ * @throws BadResponseException
+ */
+ public String post(Object request, SDNCTopology topology) throws MapperException, BadResponseException {
+ String jsonRequest = sdnCommonTasks.buildJsonRequest(request);
+ String targetUrl = properties.getHost() + properties.getPath() + ":" + topology.toString() + "/";
+ BaseClient<String, LinkedHashMap<String, Object>> STOClient = new BaseClient<>();
+
+ STOClient.setTargetUrl(targetUrl);
+ HttpHeaders httpHeader = sdnCommonTasks.getHttpHeaders(properties.getAuth());
+ STOClient.setHttpHeader(httpHeader);
+ LinkedHashMap<String, Object> output =
+ STOClient.post(jsonRequest, new ParameterizedTypeReference<LinkedHashMap<String, Object>>() {});
+ return sdnCommonTasks.validateSDNResponse(output);
+ }
+
- @Autowired
- private SDNCProperties properties;
- @Autowired
- private SdnCommonTasks sdnCommonTasks;
-
- /**
- *
- * @param request
- * - takes in a generated object from sdnc client
- * - creates a json request string and sends it to sdnc
- * - receives and validates the linkedhashmap sent back from sdnc
- * @throws MapperException
- * @throws BadResponseException
- */
- public String post(Object request, SDNCTopology topology) throws MapperException, BadResponseException {
- String jsonRequest = sdnCommonTasks.buildJsonRequest(request);
- String targetUrl = properties.getHost() + properties.getPath() + ":" + topology.toString() + "/";
- BaseClient<String, LinkedHashMap<String, Object>> STOClient = new BaseClient<>();
+ public String post(Object request, String url) throws MapperException, BadResponseException {
+ String jsonRequest = sdnCommonTasks.buildJsonRequest(request);
+ BaseClient<String, LinkedHashMap<String, Object>> STOClient = new BaseClient<>();
+ STOClient.setTargetUrl(url);
+ HttpHeaders httpHeader = sdnCommonTasks.getHttpHeaders(properties.getAuth());
+ STOClient.setHttpHeader(httpHeader);
+ LinkedHashMap<String, Object> output =
+ STOClient.post(jsonRequest, new ParameterizedTypeReference<LinkedHashMap<String, Object>>() {});
+ return sdnCommonTasks.validateSDNResponse(output);
+ }
- STOClient.setTargetUrl(targetUrl);
- HttpHeaders httpHeader = sdnCommonTasks.getHttpHeaders(properties.getAuth());
- STOClient.setHttpHeader(httpHeader);
- LinkedHashMap<String, Object> output = STOClient.post(jsonRequest, new ParameterizedTypeReference<LinkedHashMap<String, Object>>() {});
- return sdnCommonTasks.validateSDNResponse(output);
- }
-
-
- public String post(Object request, String url) throws MapperException, BadResponseException {
- String jsonRequest = sdnCommonTasks.buildJsonRequest(request);
- BaseClient<String, LinkedHashMap<String, Object>> STOClient = new BaseClient<>();
- STOClient.setTargetUrl(url);
- HttpHeaders httpHeader = sdnCommonTasks.getHttpHeaders(properties.getAuth());
- STOClient.setHttpHeader(httpHeader);
- LinkedHashMap<String, Object> output = STOClient.post(jsonRequest, new ParameterizedTypeReference<LinkedHashMap<String, Object>>() {});
- return sdnCommonTasks.validateSDNResponse(output);
- }
-
- /**
- *
- * @param queryLink
- * - takes in a link to topology that needs to be queried
- * - creates a json request string and sends it to sdnc
- * - receives and validates the linkedhashmap sent back from sdnc
- * *
- * @throws MapperException
- * @throws BadResponseException
- */
- public String get(String queryLink) throws MapperException, BadResponseException {
- String request = "";
- String jsonRequest = sdnCommonTasks.buildJsonRequest(request);
- String targetUrl = UriBuilder.fromUri(properties.getHost()).path(queryLink).build().toString();
- BaseClient<String, LinkedHashMap<String, Object>> STOClient = new BaseClient<>();
- STOClient.setTargetUrl(targetUrl);
- HttpHeaders httpHeader = sdnCommonTasks.getHttpHeaders(properties.getAuth());
- STOClient.setHttpHeader(httpHeader);
- LinkedHashMap<String, Object> output = STOClient.get(jsonRequest, new ParameterizedTypeReference<LinkedHashMap<String, Object>>() {});
- return sdnCommonTasks.validateSDNGetResponse(output);
- }
+ /**
+ *
+ * @param queryLink - takes in a link to topology that needs to be queried - creates a json request string and sends
+ * it to sdnc - receives and validates the linkedhashmap sent back from sdnc *
+ * @throws MapperException
+ * @throws BadResponseException
+ */
+ public String get(String queryLink) throws MapperException, BadResponseException {
+ String request = "";
+ String jsonRequest = sdnCommonTasks.buildJsonRequest(request);
+ String targetUrl = UriBuilder.fromUri(properties.getHost()).path(queryLink).build().toString();
+ BaseClient<String, LinkedHashMap<String, Object>> STOClient = new BaseClient<>();
+ STOClient.setTargetUrl(targetUrl);
+ HttpHeaders httpHeader = sdnCommonTasks.getHttpHeaders(properties.getAuth());
+ STOClient.setHttpHeader(httpHeader);
+ LinkedHashMap<String, Object> output =
+ STOClient.get(jsonRequest, new ParameterizedTypeReference<LinkedHashMap<String, Object>>() {});
+ return sdnCommonTasks.validateSDNGetResponse(output);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java
index 418e70a09e..e21f64accd 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java
@@ -25,7 +25,6 @@ package org.onap.so.client.sdnc;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
-
import org.apache.commons.lang.StringUtils;
import org.apache.http.HttpStatus;
import org.onap.so.client.exception.BadResponseException;
@@ -38,7 +37,6 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
-
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -52,7 +50,8 @@ public class SdnCommonTasks {
private static final String NO_RESPONSE_FROM_SDNC = "Error did not receive a response from SDNC.";
private static final String BAD_RESPONSE_FROM_SDNC = "Error received a bad response from SDNC.";
private static final String SDNC_CODE_NOT_0_OR_IN_200_299 = "Error from SDNC: %s";
- private static final String COULD_NOT_CONVERT_SDNC_POJO_TO_JSON = "ERROR: Could not convert SDNC pojo to json string.";
+ private static final String COULD_NOT_CONVERT_SDNC_POJO_TO_JSON =
+ "ERROR: Could not convert SDNC pojo to json string.";
/***
*
@@ -67,8 +66,7 @@ public class SdnCommonTasks {
try {
jsonRequest = objMapper.writerWithDefaultPrettyPrinter().writeValueAsString(request);
} catch (JsonProcessingException e) {
- logger.error("{} {} {} {} {}", MessageEnum.JAXB_EXCEPTION.toString(),
- COULD_NOT_CONVERT_SDNC_POJO_TO_JSON,
+ logger.error("{} {} {} {} {}", MessageEnum.JAXB_EXCEPTION.toString(), COULD_NOT_CONVERT_SDNC_POJO_TO_JSON,
"BPMN", ErrorCode.DataError.getValue(), e.getMessage());
throw new MapperException(COULD_NOT_CONVERT_SDNC_POJO_TO_JSON);
}
@@ -98,41 +96,41 @@ public class SdnCommonTasks {
* @return
* @throws BadResponseException
*/
- public String validateSDNResponse(LinkedHashMap<String, Object> output) throws BadResponseException {
- if (CollectionUtils.isEmpty(output)) {
- logger.error("{} {} {} {} {}", MessageEnum.RA_RESPONSE_FROM_SDNC.toString(), NO_RESPONSE_FROM_SDNC, "BPMN",
- ErrorCode.UnknownError.getValue(), NO_RESPONSE_FROM_SDNC);
- throw new BadResponseException(NO_RESPONSE_FROM_SDNC);
- }
- LinkedHashMap<String, Object> embeddedResponse =(LinkedHashMap<String, Object>) output.get("output");
+ public String validateSDNResponse(LinkedHashMap<String, Object> output) throws BadResponseException {
+ if (CollectionUtils.isEmpty(output)) {
+ logger.error("{} {} {} {} {}", MessageEnum.RA_RESPONSE_FROM_SDNC.toString(), NO_RESPONSE_FROM_SDNC, "BPMN",
+ ErrorCode.UnknownError.getValue(), NO_RESPONSE_FROM_SDNC);
+ throw new BadResponseException(NO_RESPONSE_FROM_SDNC);
+ }
+ LinkedHashMap<String, Object> embeddedResponse = (LinkedHashMap<String, Object>) output.get("output");
String responseCode = "";
String responseMessage = "";
if (embeddedResponse != null) {
- responseCode = (String) embeddedResponse.get(RESPONSE_CODE);
+ responseCode = (String) embeddedResponse.get(RESPONSE_CODE);
responseMessage = (String) embeddedResponse.get(RESPONSE_MESSAGE);
}
ObjectMapper objMapper = new ObjectMapper();
String jsonResponse;
- try {
- jsonResponse = objMapper.writeValueAsString(output);
- logger.debug(jsonResponse);
- } catch (JsonProcessingException e) {
- logger.warn("Could not convert SDNC Response to String", e);
- jsonResponse = "";
- }
- logger.info("ResponseCode: {} ResponseMessage: {}", responseCode, responseMessage);
- int code = StringUtils.isNotEmpty(responseCode) ? Integer.parseInt(responseCode) : 0;
- if (isHttpCodeSuccess(code)) {
- logger.info("Successful Response from SDNC");
- return jsonResponse;
- } else {
- String errorMessage = String.format(SDNC_CODE_NOT_0_OR_IN_200_299, responseMessage);
- logger.error("{} {} {} {} {}", MessageEnum.RA_RESPONSE_FROM_SDNC.toString(), errorMessage, "BPMN",
- ErrorCode.DataError.getValue(), errorMessage);
- throw new BadResponseException(errorMessage);
- }
- }
-
+ try {
+ jsonResponse = objMapper.writeValueAsString(output);
+ logger.debug(jsonResponse);
+ } catch (JsonProcessingException e) {
+ logger.warn("Could not convert SDNC Response to String", e);
+ jsonResponse = "";
+ }
+ logger.info("ResponseCode: {} ResponseMessage: {}", responseCode, responseMessage);
+ int code = StringUtils.isNotEmpty(responseCode) ? Integer.parseInt(responseCode) : 0;
+ if (isHttpCodeSuccess(code)) {
+ logger.info("Successful Response from SDNC");
+ return jsonResponse;
+ } else {
+ String errorMessage = String.format(SDNC_CODE_NOT_0_OR_IN_200_299, responseMessage);
+ logger.error("{} {} {} {} {}", MessageEnum.RA_RESPONSE_FROM_SDNC.toString(), errorMessage, "BPMN",
+ ErrorCode.DataError.getValue(), errorMessage);
+ throw new BadResponseException(errorMessage);
+ }
+ }
+
/***
*
* @param output
@@ -149,18 +147,16 @@ public class SdnCommonTasks {
logger.debug("Using object mapper");
String stringOutput = "";
try {
- stringOutput = objMapper.writeValueAsString(output);
- }
- catch (Exception e) {
- logger.error("{} {} {} {} {}", MessageEnum.RA_RESPONSE_FROM_SDNC.toString(), BAD_RESPONSE_FROM_SDNC,
- "BPMN", ErrorCode.UnknownError.getValue(),
- BAD_RESPONSE_FROM_SDNC);
+ stringOutput = objMapper.writeValueAsString(output);
+ } catch (Exception e) {
+ logger.error("{} {} {} {} {}", MessageEnum.RA_RESPONSE_FROM_SDNC.toString(), BAD_RESPONSE_FROM_SDNC, "BPMN",
+ ErrorCode.UnknownError.getValue(), BAD_RESPONSE_FROM_SDNC);
throw new BadResponseException(BAD_RESPONSE_FROM_SDNC);
}
logger.debug("Received from GET request: {}", stringOutput);
return stringOutput;
}
-
+
private boolean isHttpCodeSuccess(int code) {
return code >= HttpStatus.SC_OK && code < HttpStatus.SC_MULTIPLE_CHOICES || code == 0;
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCProperties.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCProperties.java
index 08be73e3fd..15076fa45a 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCProperties.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCProperties.java
@@ -24,29 +24,34 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Configuration
-@ConfigurationProperties(prefix="sdnc")
+@ConfigurationProperties(prefix = "sdnc")
public class SDNCProperties {
- private String host;
- private String path;
- private String auth;
-
- public String getHost() {
- return host;
- }
- public void setHost(String host) {
- this.host = host;
- }
- public String getPath() {
- return path;
- }
- public void setPath(String path) {
- this.path = path;
- }
- public String getAuth() {
- return auth;
- }
- public void setAuth(String auth) {
- this.auth = auth;
- }
+ private String host;
+ private String path;
+ private String auth;
+
+ public String getHost() {
+ return host;
+ }
+
+ public void setHost(String host) {
+ this.host = host;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ public String getAuth() {
+ return auth;
+ }
+
+ public void setAuth(String auth) {
+ this.auth = auth;
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCRequest.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCRequest.java
index 3ee560f4f4..5910975051 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCRequest.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCRequest.java
@@ -23,72 +23,76 @@ package org.onap.so.client.sdnc.beans;
import java.io.Serializable;
import java.time.Duration;
import java.util.UUID;
-
import org.onap.so.client.sdnc.endpoint.SDNCTopology;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.EqualsBuilder;
-public class SDNCRequest implements Serializable{
-
- /**
- *
- */
- private static final long serialVersionUID = 4679678988657593282L;
- private String timeOut = "PT1H";
- private SDNCTopology topology;
- private String CorrelationValue = UUID.randomUUID().toString();
- private String CorrelationName = "SDNCCallback";
- private Object SDNCPayload;
-
-
- public String getTimeOut() {
- return timeOut;
- }
-
- public void setTimeOut(String timeOut) {
- this.timeOut = timeOut;
- }
-
- public SDNCTopology getTopology() {
- return topology;
- }
-
- public void setTopology(SDNCTopology topology) {
- this.topology = topology;
- }
-
- public String getCorrelationValue() {
- return CorrelationValue;
- }
- public void setCorrelationValue(String correlationValue) {
- CorrelationValue = correlationValue;
- }
- public String getCorrelationName() {
- return CorrelationName;
- }
- public void setCorrelationName(String correlationName) {
- CorrelationName = correlationName;
- }
- public Object getSDNCPayload() {
- return SDNCPayload;
- }
- public void setSDNCPayload(Object sDNCPayload) {
- SDNCPayload = sDNCPayload;
- }
-
- @Override
- public boolean equals(final Object other) {
- if (!(other instanceof SDNCRequest)) {
- return false;
- }
- SDNCRequest castOther = (SDNCRequest) other;
- return new EqualsBuilder().append(CorrelationValue, castOther.CorrelationValue)
- .append(CorrelationName, castOther.CorrelationName).isEquals();
- }
-
- @Override
- public int hashCode() {
- return new HashCodeBuilder().append(CorrelationValue).append(CorrelationName).toHashCode();
- }
+public class SDNCRequest implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 4679678988657593282L;
+ private String timeOut = "PT1H";
+ private SDNCTopology topology;
+ private String CorrelationValue = UUID.randomUUID().toString();
+ private String CorrelationName = "SDNCCallback";
+ private Object SDNCPayload;
+
+
+ public String getTimeOut() {
+ return timeOut;
+ }
+
+ public void setTimeOut(String timeOut) {
+ this.timeOut = timeOut;
+ }
+
+ public SDNCTopology getTopology() {
+ return topology;
+ }
+
+ public void setTopology(SDNCTopology topology) {
+ this.topology = topology;
+ }
+
+ public String getCorrelationValue() {
+ return CorrelationValue;
+ }
+
+ public void setCorrelationValue(String correlationValue) {
+ CorrelationValue = correlationValue;
+ }
+
+ public String getCorrelationName() {
+ return CorrelationName;
+ }
+
+ public void setCorrelationName(String correlationName) {
+ CorrelationName = correlationName;
+ }
+
+ public Object getSDNCPayload() {
+ return SDNCPayload;
+ }
+
+ public void setSDNCPayload(Object sDNCPayload) {
+ SDNCPayload = sDNCPayload;
+ }
+
+ @Override
+ public boolean equals(final Object other) {
+ if (!(other instanceof SDNCRequest)) {
+ return false;
+ }
+ SDNCRequest castOther = (SDNCRequest) other;
+ return new EqualsBuilder().append(CorrelationValue, castOther.CorrelationValue)
+ .append(CorrelationName, castOther.CorrelationName).isEquals();
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder().append(CorrelationValue).append(CorrelationName).toHashCode();
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcAction.java
index 876c7e002f..1718de9fe0 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcAction.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcAction.java
@@ -23,33 +23,38 @@ package org.onap.so.client.sdnc.beans;
import org.onap.sdnc.northbound.client.model.GenericResourceApiSvcActionEnumeration;
public enum SDNCSvcAction {
- ACTIVATE("activate",GenericResourceApiSvcActionEnumeration.ACTIVATE),
- DELETE("delete",GenericResourceApiSvcActionEnumeration.DELETE),
- ASSIGN("assign",GenericResourceApiSvcActionEnumeration.ASSIGN),
- ROLLBACK("rollback",GenericResourceApiSvcActionEnumeration.ROLLBACK),
- UNASSIGN("unassign",GenericResourceApiSvcActionEnumeration.UNASSIGN),
- DEACTIVATE("deactivate",GenericResourceApiSvcActionEnumeration.DEACTIVATE),
- CHANGE_DELETE("changedelete",GenericResourceApiSvcActionEnumeration.CHANGEDELETE),
- CHANGE_ASSIGN("changeassign",GenericResourceApiSvcActionEnumeration.CHANGEASSIGN),
- CREATE("create",GenericResourceApiSvcActionEnumeration.CREATE),
- ENABLE("enable",GenericResourceApiSvcActionEnumeration.ENABLE),
- DISABLE("disable",GenericResourceApiSvcActionEnumeration.DISABLE);
-
- private final String name;
-
- private GenericResourceApiSvcActionEnumeration sdncApiAction ;
-
- private SDNCSvcAction(String name , GenericResourceApiSvcActionEnumeration sdncApiAction) {
- this.name = name;
- this.sdncApiAction = sdncApiAction;
- }
-
- public GenericResourceApiSvcActionEnumeration getSdncApiAction(){
- return this.sdncApiAction;
- }
-
- @Override
- public String toString() {
- return name;
- }
+ ACTIVATE("activate", GenericResourceApiSvcActionEnumeration.ACTIVATE), DELETE("delete",
+ GenericResourceApiSvcActionEnumeration.DELETE), ASSIGN("assign",
+ GenericResourceApiSvcActionEnumeration.ASSIGN), ROLLBACK("rollback",
+ GenericResourceApiSvcActionEnumeration.ROLLBACK), UNASSIGN("unassign",
+ GenericResourceApiSvcActionEnumeration.UNASSIGN), DEACTIVATE("deactivate",
+ GenericResourceApiSvcActionEnumeration.DEACTIVATE), CHANGE_DELETE(
+ "changedelete",
+ GenericResourceApiSvcActionEnumeration.CHANGEDELETE), CHANGE_ASSIGN(
+ "changeassign",
+ GenericResourceApiSvcActionEnumeration.CHANGEASSIGN), CREATE(
+ "create",
+ GenericResourceApiSvcActionEnumeration.CREATE), ENABLE(
+ "enable",
+ GenericResourceApiSvcActionEnumeration.ENABLE), DISABLE(
+ "disable",
+ GenericResourceApiSvcActionEnumeration.DISABLE);
+
+ private final String name;
+
+ private GenericResourceApiSvcActionEnumeration sdncApiAction;
+
+ private SDNCSvcAction(String name, GenericResourceApiSvcActionEnumeration sdncApiAction) {
+ this.name = name;
+ this.sdncApiAction = sdncApiAction;
+ }
+
+ public GenericResourceApiSvcActionEnumeration getSdncApiAction() {
+ return this.sdncApiAction;
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcOperation.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcOperation.java
index ba9fedccac..b9b04bc7b7 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcOperation.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcOperation.java
@@ -22,23 +22,23 @@ package org.onap.so.client.sdnc.beans;
public enum SDNCSvcOperation {
- VF_MODULE_TOPOLOGY_OPERATION("vf-module-topology-operation"),
- NETWORK_TOPOLOGY_OPERATION("network-topology-operation"),
- VNF_TOPOLOGY_OPERATION("vnf-topology-operation"),
- CONTRAIL_ROUTE_TOPOLOGY_OPERATION("contrail-route-topology-operation"),
- SECURITY_ZONE_TOPOLOGY_OPERATION("security-zone-topology-operation"),
- PORT_MIRROR_TOPOLOGY_OPERATION("port-mirror-topology-operation"),
- SERVICE_TOPOLOGY_OPERATION("service-topology-operation"),
- GENERIC_CONFIGURATION_TOPOLOGY_OPERATION("generic-configuration-topology-operation");
-
- private final String name;
-
- private SDNCSvcOperation(String name) {
- this.name = name;
- }
-
- @Override
- public String toString() {
- return name;
- }
+ VF_MODULE_TOPOLOGY_OPERATION("vf-module-topology-operation"), NETWORK_TOPOLOGY_OPERATION(
+ "network-topology-operation"), VNF_TOPOLOGY_OPERATION(
+ "vnf-topology-operation"), CONTRAIL_ROUTE_TOPOLOGY_OPERATION(
+ "contrail-route-topology-operation"), SECURITY_ZONE_TOPOLOGY_OPERATION(
+ "security-zone-topology-operation"), PORT_MIRROR_TOPOLOGY_OPERATION(
+ "port-mirror-topology-operation"), SERVICE_TOPOLOGY_OPERATION(
+ "service-topology-operation"), GENERIC_CONFIGURATION_TOPOLOGY_OPERATION(
+ "generic-configuration-topology-operation");
+
+ private final String name;
+
+ private SDNCSvcOperation(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/endpoint/SDNCTopology.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/endpoint/SDNCTopology.java
index a709e80220..fb5f24694b 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/endpoint/SDNCTopology.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/endpoint/SDNCTopology.java
@@ -21,24 +21,21 @@
package org.onap.so.client.sdnc.endpoint;
public enum SDNCTopology {
-
- SERVICE("service-topology-operation"),
- VNF("vnf-topology-operation"),
- VFMODULE("vf-module-topology-operation"),
- CONTRAILROUTE("contrail-route-topology-operation"),
- PORTMIRROR("port-mirror-topology-operation"),
- NETWORK("network-topology-operation"),
- SECURITYZONE("security-zone-topology-operation"),
- CONFIGURATION("generic-configuration-topology-operation");
-
- private final String topology;
-
- private SDNCTopology(String topology) {
- this.topology = topology;
- }
-
- @Override
- public String toString(){
- return this.topology;
- }
+
+ SERVICE("service-topology-operation"), VNF("vnf-topology-operation"), VFMODULE(
+ "vf-module-topology-operation"), CONTRAILROUTE("contrail-route-topology-operation"), PORTMIRROR(
+ "port-mirror-topology-operation"), NETWORK("network-topology-operation"), SECURITYZONE(
+ "security-zone-topology-operation"), CONFIGURATION(
+ "generic-configuration-topology-operation");
+
+ private final String topology;
+
+ private SDNCTopology(String topology) {
+ this.topology = topology;
+ }
+
+ @Override
+ public String toString() {
+ return this.topology;
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapper.java
index 7b86756afa..6af8c2f9c5 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapper.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapper.java
@@ -22,7 +22,6 @@ package org.onap.so.client.sdnc.mapper;
import java.net.URI;
import java.util.UUID;
-
import org.onap.sdnc.northbound.client.model.GenericResourceApiConfigurationinformationConfigurationInformation;
import org.onap.sdnc.northbound.client.model.GenericResourceApiGcTopologyOperationInformation;
import org.onap.sdnc.northbound.client.model.GenericResourceApiGcrequestinputGcRequestInput;
@@ -42,27 +41,29 @@ import org.springframework.stereotype.Component;
@Component(value = "sdncGCTopologyOperationRequestMapper")
public class GCTopologyOperationRequestMapper {
- @Autowired
+ @Autowired
private GeneralTopologyObjectMapper generalTopologyObjectMapper;
public GenericResourceApiGcTopologyOperationInformation assignOrActivateVnrReqMapper(SDNCSvcAction svcAction,
- GenericResourceApiRequestActionEnumeration reqAction,
- ServiceInstance serviceInstance,
- RequestContext requestContext,
- Customer customer,
- Configuration vnrConfiguration,
- GenericVnf voiceVnf, String sdncReqId,URI callbackUri) {
+ GenericResourceApiRequestActionEnumeration reqAction, ServiceInstance serviceInstance,
+ RequestContext requestContext, Customer customer, Configuration vnrConfiguration, GenericVnf voiceVnf,
+ String sdncReqId, URI callbackUri) {
- String msoRequestId = UUID.randomUUID().toString();
- if (requestContext != null && requestContext.getMsoRequestId() != null) {
- msoRequestId = requestContext.getMsoRequestId();
- }
+ String msoRequestId = UUID.randomUUID().toString();
+ if (requestContext != null && requestContext.getMsoRequestId() != null) {
+ msoRequestId = requestContext.getMsoRequestId();
+ }
GenericResourceApiGcTopologyOperationInformation req = new GenericResourceApiGcTopologyOperationInformation();
- GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId,callbackUri.toString());
- GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper.buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, reqAction);
- GenericResourceApiServiceinformationServiceInformation serviceInformation = generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, false);
- GenericResourceApiConfigurationinformationConfigurationInformation configurationInformation = generalTopologyObjectMapper.buildConfigurationInformation(vnrConfiguration,true);
- GenericResourceApiGcrequestinputGcRequestInput gcRequestInput = generalTopologyObjectMapper.buildGcRequestInformation(voiceVnf,null);
+ GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader =
+ generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId, callbackUri.toString());
+ GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper
+ .buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, reqAction);
+ GenericResourceApiServiceinformationServiceInformation serviceInformation =
+ generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, false);
+ GenericResourceApiConfigurationinformationConfigurationInformation configurationInformation =
+ generalTopologyObjectMapper.buildConfigurationInformation(vnrConfiguration, true);
+ GenericResourceApiGcrequestinputGcRequestInput gcRequestInput =
+ generalTopologyObjectMapper.buildGcRequestInformation(voiceVnf, null);
req.setRequestInformation(requestInformation);
req.setSdncRequestHeader(sdncRequestHeader);
req.setServiceInformation(serviceInformation);
@@ -75,21 +76,21 @@ public class GCTopologyOperationRequestMapper {
public GenericResourceApiGcTopologyOperationInformation deactivateOrUnassignVnrReqMapper(SDNCSvcAction svcAction,
- ServiceInstance serviceInstance,
- RequestContext requestContext,
- Configuration vnrConfiguration, String sdncReqId, URI callbackUri) {
+ ServiceInstance serviceInstance, RequestContext requestContext, Configuration vnrConfiguration,
+ String sdncReqId, URI callbackUri) {
- String msoRequestId = null;
- if (requestContext != null) {
- msoRequestId = requestContext.getMsoRequestId();
- }
- GenericResourceApiGcTopologyOperationInformation req = new GenericResourceApiGcTopologyOperationInformation();
+ String msoRequestId = null;
+ if (requestContext != null) {
+ msoRequestId = requestContext.getMsoRequestId();
+ }
+ GenericResourceApiGcTopologyOperationInformation req = new GenericResourceApiGcTopologyOperationInformation();
GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader =
- generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId,callbackUri.toString());
- GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper
- .buildGenericResourceApiRequestinformationRequestInformation(msoRequestId,
+ generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId, callbackUri.toString());
+ GenericResourceApiRequestinformationRequestInformation requestInformation =
+ generalTopologyObjectMapper.buildGenericResourceApiRequestinformationRequestInformation(msoRequestId,
GenericResourceApiRequestActionEnumeration.DELETEGENERICCONFIGURATIONINSTANCE);
- GenericResourceApiServiceinformationServiceInformation serviceInformation = new GenericResourceApiServiceinformationServiceInformation();
+ GenericResourceApiServiceinformationServiceInformation serviceInformation =
+ new GenericResourceApiServiceinformationServiceInformation();
serviceInformation.setServiceInstanceId(serviceInstance.getServiceInstanceId());
GenericResourceApiConfigurationinformationConfigurationInformation configurationInformation =
new GenericResourceApiConfigurationinformationConfigurationInformation();
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java
index 756e5b068e..a9611cbde5 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java
@@ -23,7 +23,6 @@ package org.onap.so.client.sdnc.mapper;
import java.util.List;
import java.util.Map;
import java.util.Set;
-
import org.onap.sdnc.northbound.client.model.GenericResourceApiConfigurationinformationConfigurationInformation;
import org.onap.sdnc.northbound.client.model.GenericResourceApiGcrequestinputGcRequestInput;
import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkinformationNetworkInformation;
@@ -47,157 +46,183 @@ import org.onap.so.client.sdnc.beans.SDNCSvcAction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
-
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
@Component
public class GeneralTopologyObjectMapper {
-
- private static final Logger logger = LoggerFactory.getLogger(GeneralTopologyObjectMapper.class);
- private ObjectMapper mapper = new ObjectMapper();
-
- /*
- * Build GenericResourceApiRequestinformationRequestInformation
- */
- public GenericResourceApiRequestinformationRequestInformation buildGenericResourceApiRequestinformationRequestInformation(String msoReqId, GenericResourceApiRequestActionEnumeration requestAction){
-
- GenericResourceApiRequestinformationRequestInformation requestInformation = new GenericResourceApiRequestinformationRequestInformation();
- requestInformation.setRequestId(msoReqId);
- requestInformation.setRequestAction(requestAction);
- requestInformation.setSource("MSO");
- return requestInformation;
- }
- /*
- * Build GenericResourceApiServiceinformationServiceInformation
- */
- public GenericResourceApiServiceinformationServiceInformation buildServiceInformation(ServiceInstance serviceInstance, RequestContext requestContext, Customer customer, boolean includeModelInformation){
- GenericResourceApiServiceinformationServiceInformation serviceInformation = new GenericResourceApiServiceinformationServiceInformation();
- serviceInformation.serviceId(serviceInstance.getServiceInstanceId());
- if (requestContext != null) {
- serviceInformation.setSubscriptionServiceType(requestContext.getProductFamilyId());
- }
- if (includeModelInformation) {
- GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation = new GenericResourceApiOnapmodelinformationOnapModelInformation();
- onapModelInformation.setModelInvariantUuid(serviceInstance.getModelInfoServiceInstance().getModelInvariantUuid());
- onapModelInformation.setModelVersion(serviceInstance.getModelInfoServiceInstance().getModelVersion());
- onapModelInformation.setModelName(serviceInstance.getModelInfoServiceInstance().getModelName());
- onapModelInformation.setModelUuid(serviceInstance.getModelInfoServiceInstance().getModelUuid());
- serviceInformation.setOnapModelInformation(onapModelInformation );
- }
- serviceInformation.setServiceInstanceId(serviceInstance.getServiceInstanceId());
-
- if (customer != null) {
- serviceInformation.setGlobalCustomerId(customer.getGlobalCustomerId());
- if(customer.getServiceSubscription() != null){
- serviceInformation.setSubscriptionServiceType(customer.getServiceSubscription().getServiceType());
- }
-
- }
- return serviceInformation;
- }
- /*
- * Build GenericResourceApiNetworkinformationNetworkInformation
- */
- public GenericResourceApiNetworkinformationNetworkInformation buildNetworkInformation(L3Network network){
- GenericResourceApiNetworkinformationNetworkInformation networkInformation = new GenericResourceApiNetworkinformationNetworkInformation();
- GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation = new GenericResourceApiOnapmodelinformationOnapModelInformation();
- if (network.getModelInfoNetwork() != null) {
- onapModelInformation.setModelInvariantUuid(network.getModelInfoNetwork().getModelInvariantUUID());
- onapModelInformation.setModelName(network.getModelInfoNetwork().getModelName());
- onapModelInformation.setModelVersion(network.getModelInfoNetwork().getModelVersion());
- onapModelInformation.setModelUuid(network.getModelInfoNetwork().getModelUUID());
- onapModelInformation.setModelCustomizationUuid(network.getModelInfoNetwork().getModelCustomizationUUID());
- networkInformation.setOnapModelInformation(onapModelInformation);
- }
-
- networkInformation.setFromPreload(null);
- networkInformation.setNetworkId(network.getNetworkId());
- networkInformation.setNetworkType(network.getNetworkType());
- networkInformation.setNetworkTechnology(network.getNetworkTechnology());
- return networkInformation;
- }
- /*
- * Build GenericResourceApiVnfinformationVnfInformation
- */
- public GenericResourceApiVnfinformationVnfInformation buildVnfInformation(GenericVnf vnf, ServiceInstance serviceInstance, boolean includeModelInformation){
- GenericResourceApiVnfinformationVnfInformation vnfInformation = new GenericResourceApiVnfinformationVnfInformation();
- if (includeModelInformation && vnf.getModelInfoGenericVnf() != null) {
- GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation = new GenericResourceApiOnapmodelinformationOnapModelInformation();
- onapModelInformation.setModelInvariantUuid(vnf.getModelInfoGenericVnf().getModelInvariantUuid());
- onapModelInformation.setModelName(vnf.getModelInfoGenericVnf().getModelName());
- onapModelInformation.setModelVersion(vnf.getModelInfoGenericVnf().getModelVersion());
- onapModelInformation.setModelUuid(vnf.getModelInfoGenericVnf().getModelUuid());
- onapModelInformation.setModelCustomizationUuid(vnf.getModelInfoGenericVnf().getModelCustomizationUuid());
- vnfInformation.setOnapModelInformation(onapModelInformation);
- }
- vnfInformation.setVnfId(vnf.getVnfId());
- vnfInformation.setVnfType(vnf.getVnfType());
- vnfInformation.setVnfName(vnf.getVnfName());
- return vnfInformation;
- }
- /*
- * Build GenericResourceApiVfModuleinformationVfModuleInformation
- */
- public GenericResourceApiVfmoduleinformationVfModuleInformation buildVfModuleInformation(VfModule vfModule, GenericVnf vnf, ServiceInstance serviceInstance, RequestContext requestContext, boolean includeModelInformation) throws MapperException {
- GenericResourceApiVfmoduleinformationVfModuleInformation vfModuleInformation = new GenericResourceApiVfmoduleinformationVfModuleInformation();
- if (includeModelInformation) {
- if (vfModule.getModelInfoVfModule() == null) {
- throw new MapperException("VF Module model info is null for " + vfModule.getVfModuleId());
- }
- else {
- GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation = new GenericResourceApiOnapmodelinformationOnapModelInformation();
- onapModelInformation.setModelInvariantUuid(vfModule.getModelInfoVfModule().getModelInvariantUUID());
- onapModelInformation.setModelName(vfModule.getModelInfoVfModule().getModelName());
- onapModelInformation.setModelVersion(vfModule.getModelInfoVfModule().getModelVersion());
- onapModelInformation.setModelUuid(vfModule.getModelInfoVfModule().getModelUUID());
- onapModelInformation.setModelCustomizationUuid(vfModule.getModelInfoVfModule().getModelCustomizationUUID());
- vfModuleInformation.setOnapModelInformation(onapModelInformation);
- }
- }
- if (vfModule.getModelInfoVfModule() != null) {
- vfModuleInformation.setVfModuleType(vfModule.getModelInfoVfModule().getModelName());
- }
- vfModuleInformation.setVfModuleId(vfModule.getVfModuleId());
- if (requestContext != null && requestContext.getRequestParameters() != null) {
- vfModuleInformation.setFromPreload(requestContext.getRequestParameters().getUsePreload());
- }
- else {
- vfModuleInformation.setFromPreload(true);
- }
-
- return vfModuleInformation;
- }
-
-
- public GenericResourceApiSdncrequestheaderSdncRequestHeader buildSdncRequestHeader(SDNCSvcAction svcAction, String sdncReqId){
- return buildSdncRequestHeader(svcAction, sdncReqId, null);
- }
-
- public GenericResourceApiSdncrequestheaderSdncRequestHeader buildSdncRequestHeader(SDNCSvcAction svcAction, String sdncReqId, String callbackUrl){
- GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = new GenericResourceApiSdncrequestheaderSdncRequestHeader();
- sdncRequestHeader.setSvcAction(svcAction.getSdncApiAction());
- sdncRequestHeader.setSvcRequestId(sdncReqId);
- sdncRequestHeader.setSvcNotificationUrl(callbackUrl);
- return sdncRequestHeader;
- }
+
+ private static final Logger logger = LoggerFactory.getLogger(GeneralTopologyObjectMapper.class);
+ private ObjectMapper mapper = new ObjectMapper();
+
+ /*
+ * Build GenericResourceApiRequestinformationRequestInformation
+ */
+ public GenericResourceApiRequestinformationRequestInformation buildGenericResourceApiRequestinformationRequestInformation(
+ String msoReqId, GenericResourceApiRequestActionEnumeration requestAction) {
+
+ GenericResourceApiRequestinformationRequestInformation requestInformation =
+ new GenericResourceApiRequestinformationRequestInformation();
+ requestInformation.setRequestId(msoReqId);
+ requestInformation.setRequestAction(requestAction);
+ requestInformation.setSource("MSO");
+ return requestInformation;
+ }
+
+ /*
+ * Build GenericResourceApiServiceinformationServiceInformation
+ */
+ public GenericResourceApiServiceinformationServiceInformation buildServiceInformation(
+ ServiceInstance serviceInstance, RequestContext requestContext, Customer customer,
+ boolean includeModelInformation) {
+ GenericResourceApiServiceinformationServiceInformation serviceInformation =
+ new GenericResourceApiServiceinformationServiceInformation();
+ serviceInformation.serviceId(serviceInstance.getServiceInstanceId());
+ if (requestContext != null) {
+ serviceInformation.setSubscriptionServiceType(requestContext.getProductFamilyId());
+ }
+ if (includeModelInformation) {
+ GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation =
+ new GenericResourceApiOnapmodelinformationOnapModelInformation();
+ onapModelInformation
+ .setModelInvariantUuid(serviceInstance.getModelInfoServiceInstance().getModelInvariantUuid());
+ onapModelInformation.setModelVersion(serviceInstance.getModelInfoServiceInstance().getModelVersion());
+ onapModelInformation.setModelName(serviceInstance.getModelInfoServiceInstance().getModelName());
+ onapModelInformation.setModelUuid(serviceInstance.getModelInfoServiceInstance().getModelUuid());
+ serviceInformation.setOnapModelInformation(onapModelInformation);
+ }
+ serviceInformation.setServiceInstanceId(serviceInstance.getServiceInstanceId());
+
+ if (customer != null) {
+ serviceInformation.setGlobalCustomerId(customer.getGlobalCustomerId());
+ if (customer.getServiceSubscription() != null) {
+ serviceInformation.setSubscriptionServiceType(customer.getServiceSubscription().getServiceType());
+ }
+
+ }
+ return serviceInformation;
+ }
+
+ /*
+ * Build GenericResourceApiNetworkinformationNetworkInformation
+ */
+ public GenericResourceApiNetworkinformationNetworkInformation buildNetworkInformation(L3Network network) {
+ GenericResourceApiNetworkinformationNetworkInformation networkInformation =
+ new GenericResourceApiNetworkinformationNetworkInformation();
+ GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation =
+ new GenericResourceApiOnapmodelinformationOnapModelInformation();
+ if (network.getModelInfoNetwork() != null) {
+ onapModelInformation.setModelInvariantUuid(network.getModelInfoNetwork().getModelInvariantUUID());
+ onapModelInformation.setModelName(network.getModelInfoNetwork().getModelName());
+ onapModelInformation.setModelVersion(network.getModelInfoNetwork().getModelVersion());
+ onapModelInformation.setModelUuid(network.getModelInfoNetwork().getModelUUID());
+ onapModelInformation.setModelCustomizationUuid(network.getModelInfoNetwork().getModelCustomizationUUID());
+ networkInformation.setOnapModelInformation(onapModelInformation);
+ }
+
+ networkInformation.setFromPreload(null);
+ networkInformation.setNetworkId(network.getNetworkId());
+ networkInformation.setNetworkType(network.getNetworkType());
+ networkInformation.setNetworkTechnology(network.getNetworkTechnology());
+ return networkInformation;
+ }
+
+ /*
+ * Build GenericResourceApiVnfinformationVnfInformation
+ */
+ public GenericResourceApiVnfinformationVnfInformation buildVnfInformation(GenericVnf vnf,
+ ServiceInstance serviceInstance, boolean includeModelInformation) {
+ GenericResourceApiVnfinformationVnfInformation vnfInformation =
+ new GenericResourceApiVnfinformationVnfInformation();
+ if (includeModelInformation && vnf.getModelInfoGenericVnf() != null) {
+ GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation =
+ new GenericResourceApiOnapmodelinformationOnapModelInformation();
+ onapModelInformation.setModelInvariantUuid(vnf.getModelInfoGenericVnf().getModelInvariantUuid());
+ onapModelInformation.setModelName(vnf.getModelInfoGenericVnf().getModelName());
+ onapModelInformation.setModelVersion(vnf.getModelInfoGenericVnf().getModelVersion());
+ onapModelInformation.setModelUuid(vnf.getModelInfoGenericVnf().getModelUuid());
+ onapModelInformation.setModelCustomizationUuid(vnf.getModelInfoGenericVnf().getModelCustomizationUuid());
+ vnfInformation.setOnapModelInformation(onapModelInformation);
+ }
+ vnfInformation.setVnfId(vnf.getVnfId());
+ vnfInformation.setVnfType(vnf.getVnfType());
+ vnfInformation.setVnfName(vnf.getVnfName());
+ return vnfInformation;
+ }
+
+ /*
+ * Build GenericResourceApiVfModuleinformationVfModuleInformation
+ */
+ public GenericResourceApiVfmoduleinformationVfModuleInformation buildVfModuleInformation(VfModule vfModule,
+ GenericVnf vnf, ServiceInstance serviceInstance, RequestContext requestContext,
+ boolean includeModelInformation) throws MapperException {
+ GenericResourceApiVfmoduleinformationVfModuleInformation vfModuleInformation =
+ new GenericResourceApiVfmoduleinformationVfModuleInformation();
+ if (includeModelInformation) {
+ if (vfModule.getModelInfoVfModule() == null) {
+ throw new MapperException("VF Module model info is null for " + vfModule.getVfModuleId());
+ } else {
+ GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation =
+ new GenericResourceApiOnapmodelinformationOnapModelInformation();
+ onapModelInformation.setModelInvariantUuid(vfModule.getModelInfoVfModule().getModelInvariantUUID());
+ onapModelInformation.setModelName(vfModule.getModelInfoVfModule().getModelName());
+ onapModelInformation.setModelVersion(vfModule.getModelInfoVfModule().getModelVersion());
+ onapModelInformation.setModelUuid(vfModule.getModelInfoVfModule().getModelUUID());
+ onapModelInformation
+ .setModelCustomizationUuid(vfModule.getModelInfoVfModule().getModelCustomizationUUID());
+ vfModuleInformation.setOnapModelInformation(onapModelInformation);
+ }
+ }
+ if (vfModule.getModelInfoVfModule() != null) {
+ vfModuleInformation.setVfModuleType(vfModule.getModelInfoVfModule().getModelName());
+ }
+ vfModuleInformation.setVfModuleId(vfModule.getVfModuleId());
+ if (requestContext != null && requestContext.getRequestParameters() != null) {
+ vfModuleInformation.setFromPreload(requestContext.getRequestParameters().getUsePreload());
+ } else {
+ vfModuleInformation.setFromPreload(true);
+ }
+
+ return vfModuleInformation;
+ }
+
+
+ public GenericResourceApiSdncrequestheaderSdncRequestHeader buildSdncRequestHeader(SDNCSvcAction svcAction,
+ String sdncReqId) {
+ return buildSdncRequestHeader(svcAction, sdncReqId, null);
+ }
+
+ public GenericResourceApiSdncrequestheaderSdncRequestHeader buildSdncRequestHeader(SDNCSvcAction svcAction,
+ String sdncReqId, String callbackUrl) {
+ GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader =
+ new GenericResourceApiSdncrequestheaderSdncRequestHeader();
+ sdncRequestHeader.setSvcAction(svcAction.getSdncApiAction());
+ sdncRequestHeader.setSvcRequestId(sdncReqId);
+ sdncRequestHeader.setSvcNotificationUrl(callbackUrl);
+ return sdncRequestHeader;
+ }
/**
- * Build ConfigurationInformation
+ * Build ConfigurationInformation
+ *
* @param configuration
* @param includeModelInformation
* @return
*/
- public GenericResourceApiConfigurationinformationConfigurationInformation buildConfigurationInformation(Configuration configuration, boolean includeModelInformation) {
- GenericResourceApiConfigurationinformationConfigurationInformation configurationInformation = new GenericResourceApiConfigurationinformationConfigurationInformation();
+ public GenericResourceApiConfigurationinformationConfigurationInformation buildConfigurationInformation(
+ Configuration configuration, boolean includeModelInformation) {
+ GenericResourceApiConfigurationinformationConfigurationInformation configurationInformation =
+ new GenericResourceApiConfigurationinformationConfigurationInformation();
configurationInformation.setConfigurationId(configuration.getConfigurationId());
configurationInformation.setConfigurationName(configuration.getConfigurationName());
configurationInformation.setConfigurationType(configuration.getConfigurationType());
- if(includeModelInformation) {
- GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation = new GenericResourceApiOnapmodelinformationOnapModelInformation();
+ if (includeModelInformation) {
+ GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation =
+ new GenericResourceApiOnapmodelinformationOnapModelInformation();
onapModelInformation.setModelInvariantUuid(configuration.getModelInfoConfiguration().getModelInvariantId());
onapModelInformation.setModelUuid(configuration.getModelInfoConfiguration().getModelVersionId());
- onapModelInformation.setModelCustomizationUuid(configuration.getModelInfoConfiguration().getModelCustomizationId());
+ onapModelInformation
+ .setModelCustomizationUuid(configuration.getModelInfoConfiguration().getModelCustomizationId());
configurationInformation.setOnapModelInformation(onapModelInformation);
}
return configurationInformation;
@@ -205,35 +230,38 @@ public class GeneralTopologyObjectMapper {
/**
- * Build GcRequestInformation
+ * Build GcRequestInformation
+ *
* @param vnf
* @param genericResourceApiParam
* @return
*/
- public GenericResourceApiGcrequestinputGcRequestInput buildGcRequestInformation(GenericVnf vnf,GenericResourceApiParam genericResourceApiParam) {
- GenericResourceApiGcrequestinputGcRequestInput gcRequestInput = new GenericResourceApiGcrequestinputGcRequestInput();
+ public GenericResourceApiGcrequestinputGcRequestInput buildGcRequestInformation(GenericVnf vnf,
+ GenericResourceApiParam genericResourceApiParam) {
+ GenericResourceApiGcrequestinputGcRequestInput gcRequestInput =
+ new GenericResourceApiGcrequestinputGcRequestInput();
gcRequestInput.setVnfId(vnf.getVnfId());
- if(genericResourceApiParam != null) {
+ if (genericResourceApiParam != null) {
gcRequestInput.setInputParameters(genericResourceApiParam);
}
- return gcRequestInput;
- }
-
-
+ return gcRequestInput;
+ }
+
+
public String mapUserParamValue(Object value) {
- if (value == null) {
- return null;
- } else {
- if (value instanceof Map || value instanceof Set || value instanceof List) {
- try {
- return mapper.writeValueAsString(value);
- } catch (JsonProcessingException e) {
- logger.error("could not map value to string", e);
- throw new IllegalArgumentException(e);
- }
- } else {
- return value.toString();
- }
- }
+ if (value == null) {
+ return null;
+ } else {
+ if (value instanceof Map || value instanceof Set || value instanceof List) {
+ try {
+ return mapper.writeValueAsString(value);
+ } catch (JsonProcessingException e) {
+ logger.error("could not map value to string", e);
+ throw new IllegalArgumentException(e);
+ }
+ } else {
+ return value.toString();
+ }
+ }
}
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapper.java
index aef7e9e044..b1c95154c6 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapper.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapper.java
@@ -22,7 +22,6 @@ package org.onap.so.client.sdnc.mapper;
import java.util.Map;
import java.util.UUID;
-
import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation;
import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkinformationNetworkInformation;
import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkrequestinputNetworkRequestInput;
@@ -48,59 +47,68 @@ import org.springframework.stereotype.Component;
*/
@Component
public class NetworkTopologyOperationRequestMapper {
-
- @Autowired
- private GeneralTopologyObjectMapper generalTopologyObjectMapper;
- public GenericResourceApiNetworkOperationInformation reqMapper(SDNCSvcOperation svcOperation,
- SDNCSvcAction svcAction, GenericResourceApiRequestActionEnumeration reqAction, L3Network network, ServiceInstance serviceInstance,
- Customer customer, RequestContext requestContext, CloudRegion cloudRegion) {
- GenericResourceApiNetworkOperationInformation req = new GenericResourceApiNetworkOperationInformation();
- String sdncReqId = UUID.randomUUID().toString();
- String msoRequestId = UUID.randomUUID().toString();
- if (requestContext != null && requestContext.getMsoRequestId() != null) {
- msoRequestId = requestContext.getMsoRequestId();
- }
- GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId);
- GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper.buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, reqAction);
- GenericResourceApiServiceinformationServiceInformation serviceInformation = generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, true);
- GenericResourceApiNetworkinformationNetworkInformation networkInformation = generalTopologyObjectMapper.buildNetworkInformation(network);
- GenericResourceApiNetworkrequestinputNetworkRequestInput networkRequestInput = buildNetworkRequestInput(network, serviceInstance, cloudRegion);
+ @Autowired
+ private GeneralTopologyObjectMapper generalTopologyObjectMapper;
+
+ public GenericResourceApiNetworkOperationInformation reqMapper(SDNCSvcOperation svcOperation,
+ SDNCSvcAction svcAction, GenericResourceApiRequestActionEnumeration reqAction, L3Network network,
+ ServiceInstance serviceInstance, Customer customer, RequestContext requestContext,
+ CloudRegion cloudRegion) {
+ GenericResourceApiNetworkOperationInformation req = new GenericResourceApiNetworkOperationInformation();
+ String sdncReqId = UUID.randomUUID().toString();
+ String msoRequestId = UUID.randomUUID().toString();
+ if (requestContext != null && requestContext.getMsoRequestId() != null) {
+ msoRequestId = requestContext.getMsoRequestId();
+ }
+ GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader =
+ generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId);
+ GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper
+ .buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, reqAction);
+ GenericResourceApiServiceinformationServiceInformation serviceInformation =
+ generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, true);
+ GenericResourceApiNetworkinformationNetworkInformation networkInformation =
+ generalTopologyObjectMapper.buildNetworkInformation(network);
+ GenericResourceApiNetworkrequestinputNetworkRequestInput networkRequestInput =
+ buildNetworkRequestInput(network, serviceInstance, cloudRegion);
+
+ req.setRequestInformation(requestInformation);
+ req.setSdncRequestHeader(sdncRequestHeader);
+ req.setServiceInformation(serviceInformation);
+ req.setNetworkInformation(networkInformation);
- req.setRequestInformation(requestInformation);
- req.setSdncRequestHeader(sdncRequestHeader);
- req.setServiceInformation(serviceInformation);
- req.setNetworkInformation(networkInformation);
+ if (requestContext != null && requestContext.getUserParams() != null) {
+ for (Map.Entry<String, Object> entry : requestContext.getUserParams().entrySet()) {
+ GenericResourceApiParam networkInputParameters = new GenericResourceApiParam();
+ GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam();
+ paramItem.setName(entry.getKey());
+ paramItem.setValue(generalTopologyObjectMapper.mapUserParamValue(entry.getValue()));
+ networkInputParameters.addParamItem(paramItem);
+ networkRequestInput.setNetworkInputParameters(networkInputParameters);
+ }
+ }
- if (requestContext != null && requestContext.getUserParams() != null) {
- for (Map.Entry<String, Object> entry : requestContext.getUserParams().entrySet()) {
- GenericResourceApiParam networkInputParameters = new GenericResourceApiParam();
- GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam();
- paramItem.setName(entry.getKey());
- paramItem.setValue(generalTopologyObjectMapper.mapUserParamValue(entry.getValue()));
- networkInputParameters.addParamItem(paramItem);
- networkRequestInput.setNetworkInputParameters(networkInputParameters);
- }
- }
+ req.setNetworkRequestInput(networkRequestInput);
+ return req;
+ }
- req.setNetworkRequestInput(networkRequestInput);
- return req;
- }
- /*
- * Private helper to build GenericResourceApiNetworkrequestinputNetworkRequestInput
- */
- private GenericResourceApiNetworkrequestinputNetworkRequestInput buildNetworkRequestInput(L3Network network, ServiceInstance serviceInstance, CloudRegion cloudRegion){
- GenericResourceApiNetworkrequestinputNetworkRequestInput networkRequestInput = new GenericResourceApiNetworkrequestinputNetworkRequestInput();
- networkRequestInput.setTenant(cloudRegion.getTenantId());
- networkRequestInput.setCloudOwner(cloudRegion.getCloudOwner());
- networkRequestInput.setAicCloudRegion(cloudRegion.getLcpCloudRegionId());
- if (network.getNetworkName() != null && !network.getNetworkName().equals("")) {
- networkRequestInput.setNetworkName(network.getNetworkName());
- }
- if (serviceInstance.getCollection() != null && serviceInstance.getCollection().getInstanceGroup() != null){
- //set only for network created as part of the collection/instance since 1806
- networkRequestInput.setNetworkInstanceGroupId(serviceInstance.getCollection().getInstanceGroup().getId());
- }
- return networkRequestInput;
- }
+ /*
+ * Private helper to build GenericResourceApiNetworkrequestinputNetworkRequestInput
+ */
+ private GenericResourceApiNetworkrequestinputNetworkRequestInput buildNetworkRequestInput(L3Network network,
+ ServiceInstance serviceInstance, CloudRegion cloudRegion) {
+ GenericResourceApiNetworkrequestinputNetworkRequestInput networkRequestInput =
+ new GenericResourceApiNetworkrequestinputNetworkRequestInput();
+ networkRequestInput.setTenant(cloudRegion.getTenantId());
+ networkRequestInput.setCloudOwner(cloudRegion.getCloudOwner());
+ networkRequestInput.setAicCloudRegion(cloudRegion.getLcpCloudRegionId());
+ if (network.getNetworkName() != null && !network.getNetworkName().equals("")) {
+ networkRequestInput.setNetworkName(network.getNetworkName());
+ }
+ if (serviceInstance.getCollection() != null && serviceInstance.getCollection().getInstanceGroup() != null) {
+ // set only for network created as part of the collection/instance since 1806
+ networkRequestInput.setNetworkInstanceGroupId(serviceInstance.getCollection().getInstanceGroup().getId());
+ }
+ return networkRequestInput;
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapper.java
index cdb4ab96aa..b5957b3009 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapper.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapper.java
@@ -22,7 +22,6 @@ package org.onap.so.client.sdnc.mapper;
import java.util.Map;
import java.util.UUID;
-
import org.onap.sdnc.northbound.client.model.GenericResourceApiParam;
import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam;
import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration;
@@ -40,45 +39,51 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
-public class ServiceTopologyOperationMapper{
+public class ServiceTopologyOperationMapper {
+
+ @Autowired
+ public GeneralTopologyObjectMapper generalTopologyObjectMapper;
+
+ public GenericResourceApiServiceOperationInformation reqMapper(SDNCSvcOperation svcOperation,
+ SDNCSvcAction svcAction, GenericResourceApiRequestActionEnumeration resourceAction,
+ ServiceInstance serviceInstance, Customer customer, RequestContext requestContext) {
+
+ String sdncReqId = UUID.randomUUID().toString();
+ String msoRequestId = UUID.randomUUID().toString();
+ if (requestContext != null && requestContext.getMsoRequestId() != null) {
+ msoRequestId = requestContext.getMsoRequestId();
+ }
+ GenericResourceApiServiceOperationInformation servOpInput = new GenericResourceApiServiceOperationInformation();
+ GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader =
+ generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId);
+ GenericResourceApiRequestinformationRequestInformation reqInfo = generalTopologyObjectMapper
+ .buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, resourceAction);
+ GenericResourceApiServiceinformationServiceInformation servInfo =
+ generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, true);
+ GenericResourceApiServicerequestinputServiceRequestInput servReqInfo =
+ new GenericResourceApiServicerequestinputServiceRequestInput();
+
+ servReqInfo.setServiceInstanceName(serviceInstance.getServiceInstanceName());
- @Autowired
- public GeneralTopologyObjectMapper generalTopologyObjectMapper;
-
- public GenericResourceApiServiceOperationInformation reqMapper (SDNCSvcOperation svcOperation,
- SDNCSvcAction svcAction, GenericResourceApiRequestActionEnumeration resourceAction,ServiceInstance serviceInstance, Customer customer, RequestContext requestContext) {
+ servOpInput.setSdncRequestHeader(sdncRequestHeader);
+ servOpInput.setRequestInformation(reqInfo);
+ servOpInput.setServiceInformation(servInfo);
+ servOpInput.setServiceRequestInput(servReqInfo);
- String sdncReqId = UUID.randomUUID().toString();
- String msoRequestId = UUID.randomUUID().toString();
- if (requestContext != null && requestContext.getMsoRequestId() != null) {
- msoRequestId = requestContext.getMsoRequestId();
- }
- GenericResourceApiServiceOperationInformation servOpInput = new GenericResourceApiServiceOperationInformation();
- GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId);
- GenericResourceApiRequestinformationRequestInformation reqInfo = generalTopologyObjectMapper.buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, resourceAction);
- GenericResourceApiServiceinformationServiceInformation servInfo = generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, true);
- GenericResourceApiServicerequestinputServiceRequestInput servReqInfo = new GenericResourceApiServicerequestinputServiceRequestInput();
-
- servReqInfo.setServiceInstanceName(serviceInstance.getServiceInstanceName());
-
- servOpInput.setSdncRequestHeader(sdncRequestHeader);
- servOpInput.setRequestInformation(reqInfo);
- servOpInput.setServiceInformation(servInfo);
- servOpInput.setServiceRequestInput(servReqInfo);
-
- if(requestContext != null && requestContext.getUserParams()!=null){
- for (Map.Entry<String, Object> entry : requestContext.getUserParams().entrySet()) {
- GenericResourceApiServicerequestinputServiceRequestInput serviceRequestInput = new GenericResourceApiServicerequestinputServiceRequestInput();
- serviceRequestInput.setServiceInstanceName(serviceInstance.getServiceInstanceName());
- GenericResourceApiParam serviceInputParameters = new GenericResourceApiParam();
- GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam();
- paramItem.setName(entry.getKey());
- paramItem.setValue(generalTopologyObjectMapper.mapUserParamValue(entry.getValue()));
- serviceInputParameters.addParamItem(paramItem );
- serviceRequestInput.serviceInputParameters(serviceInputParameters);
- servOpInput.setServiceRequestInput(serviceRequestInput );
- }
- }
- return servOpInput;
- }
+ if (requestContext != null && requestContext.getUserParams() != null) {
+ for (Map.Entry<String, Object> entry : requestContext.getUserParams().entrySet()) {
+ GenericResourceApiServicerequestinputServiceRequestInput serviceRequestInput =
+ new GenericResourceApiServicerequestinputServiceRequestInput();
+ serviceRequestInput.setServiceInstanceName(serviceInstance.getServiceInstanceName());
+ GenericResourceApiParam serviceInputParameters = new GenericResourceApiParam();
+ GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam();
+ paramItem.setName(entry.getKey());
+ paramItem.setValue(generalTopologyObjectMapper.mapUserParamValue(entry.getValue()));
+ serviceInputParameters.addParamItem(paramItem);
+ serviceRequestInput.serviceInputParameters(serviceInputParameters);
+ servOpInput.setServiceRequestInput(serviceRequestInput);
+ }
+ }
+ return servOpInput;
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java
index 86c718d165..6627625d62 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java
@@ -24,7 +24,6 @@ package org.onap.so.client.sdnc.mapper;
import java.util.Map;
import java.util.UUID;
-
import org.onap.sdnc.northbound.client.model.GenericResourceApiParam;
import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam;
import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration;
@@ -53,134 +52,146 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-
import com.fasterxml.jackson.databind.ObjectMapper;
@Component
public class VfModuleTopologyOperationRequestMapper {
- private static final Logger logger = LoggerFactory.getLogger(VfModuleTopologyOperationRequestMapper.class);
-
- @Autowired
- private GeneralTopologyObjectMapper generalTopologyObjectMapper;
-
- public GenericResourceApiVfModuleOperationInformation reqMapper(SDNCSvcOperation svcOperation,
- SDNCSvcAction svcAction, VfModule vfModule, VolumeGroup volumeGroup, GenericVnf vnf, ServiceInstance serviceInstance,
- Customer customer, CloudRegion cloudRegion, RequestContext requestContext, String sdncAssignResponse) throws MapperException {
- GenericResourceApiVfModuleOperationInformation req = new GenericResourceApiVfModuleOperationInformation();
-
- boolean includeModelInformation = false;
-
- GenericResourceApiRequestActionEnumeration requestAction = GenericResourceApiRequestActionEnumeration.CREATEVFMODULEINSTANCE;
- GenericResourceApiSvcActionEnumeration genericResourceApiSvcAction = GenericResourceApiSvcActionEnumeration.ASSIGN;
-
- if (svcAction.equals(SDNCSvcAction.ACTIVATE)) {
- genericResourceApiSvcAction = GenericResourceApiSvcActionEnumeration.ACTIVATE;
- requestAction = GenericResourceApiRequestActionEnumeration.CREATEVFMODULEINSTANCE;
- includeModelInformation = true;
- } else if (svcAction.equals(SDNCSvcAction.ASSIGN)) {
- genericResourceApiSvcAction = GenericResourceApiSvcActionEnumeration.ASSIGN;
- requestAction = GenericResourceApiRequestActionEnumeration.CREATEVFMODULEINSTANCE;
- includeModelInformation = true;
- } else if (svcAction.equals(SDNCSvcAction.DEACTIVATE)) {
- genericResourceApiSvcAction = GenericResourceApiSvcActionEnumeration.DEACTIVATE;
- requestAction = GenericResourceApiRequestActionEnumeration.DELETEVFMODULEINSTANCE;
- includeModelInformation = false;
- } else if (svcAction.equals(SDNCSvcAction.DELETE)) {
- genericResourceApiSvcAction = GenericResourceApiSvcActionEnumeration.DELETE;
- requestAction = GenericResourceApiRequestActionEnumeration.DELETEVFMODULEINSTANCE;
- includeModelInformation = false;
- } else if (svcAction.equals(SDNCSvcAction.UNASSIGN)) {
- genericResourceApiSvcAction = GenericResourceApiSvcActionEnumeration.UNASSIGN;
- requestAction = GenericResourceApiRequestActionEnumeration.DELETEVFMODULEINSTANCE;
- includeModelInformation = false;
- }
-
- String sdncReqId = UUID.randomUUID().toString();
- String msoRequestId = UUID.randomUUID().toString();
- if (requestContext != null && requestContext.getMsoRequestId() != null) {
- msoRequestId = requestContext.getMsoRequestId();
- }
-
- GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper.buildGenericResourceApiRequestinformationRequestInformation(msoRequestId,
- requestAction);
- GenericResourceApiServiceinformationServiceInformation serviceInformation = generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, includeModelInformation);
- GenericResourceApiVnfinformationVnfInformation vnfInformation = generalTopologyObjectMapper.buildVnfInformation(vnf, serviceInstance, includeModelInformation);
- GenericResourceApiVfmoduleinformationVfModuleInformation vfModuleInformation = generalTopologyObjectMapper.buildVfModuleInformation(vfModule, vnf, serviceInstance, requestContext, includeModelInformation);
- GenericResourceApiVfmodulerequestinputVfModuleRequestInput vfModuleRequestInput = buildVfModuleRequestInput(vfModule, volumeGroup, cloudRegion, requestContext);
- GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = buildVfModuleSdncRequestHeader(sdncReqId, genericResourceApiSvcAction);
-
- req.setRequestInformation(requestInformation);
- req.setSdncRequestHeader(sdncRequestHeader);
- req.setServiceInformation(serviceInformation);
- req.setVnfInformation(vnfInformation);
- req.setVfModuleInformation(vfModuleInformation);
- req.setVfModuleRequestInput(vfModuleRequestInput);
-
- return req;
- }
-
- private GenericResourceApiVfmodulerequestinputVfModuleRequestInput buildVfModuleRequestInput(VfModule vfModule, VolumeGroup volumeGroup, CloudRegion cloudRegion, RequestContext requestContext) {
- GenericResourceApiVfmodulerequestinputVfModuleRequestInput vfModuleRequestInput = new GenericResourceApiVfmodulerequestinputVfModuleRequestInput();
- if (cloudRegion != null) {
- vfModuleRequestInput.setTenant(cloudRegion.getTenantId());
- vfModuleRequestInput.setAicCloudRegion(cloudRegion.getLcpCloudRegionId());
- vfModuleRequestInput.setCloudOwner(cloudRegion.getCloudOwner());
- }
- if (vfModule.getVfModuleName() != null && !vfModule.getVfModuleName().equals("")) {
- vfModuleRequestInput.setVfModuleName(vfModule.getVfModuleName());
- }
- GenericResourceApiParam vfModuleInputParameters = new GenericResourceApiParam();
-
- if (requestContext != null && requestContext.getUserParams() != null) {
- for (Map.Entry<String, Object> entry : requestContext.getUserParams().entrySet()) {
- GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam();
- paramItem.setName(entry.getKey());
- paramItem.setValue(generalTopologyObjectMapper.mapUserParamValue(entry.getValue()));
- vfModuleInputParameters.addParamItem(paramItem);
- }
- }
-
- if (vfModule.getCloudParams() != null) {
- for (Map.Entry<String, String> entry : vfModule.getCloudParams().entrySet()) {
- GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam();
- paramItem.setName(entry.getKey());
- paramItem.setValue(entry.getValue());
- vfModuleInputParameters.addParamItem(paramItem);
- }
- }
-
- if (volumeGroup != null) {
- GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam();
- paramItem.setName("volume-group-id");
- paramItem.setValue(volumeGroup.getVolumeGroupId());
- vfModuleInputParameters.addParamItem(paramItem);
- }
- vfModuleRequestInput.setVfModuleInputParameters(vfModuleInputParameters);
-
- return vfModuleRequestInput;
- }
-
- private GenericResourceApiSdncrequestheaderSdncRequestHeader buildVfModuleSdncRequestHeader(String sdncReqId, GenericResourceApiSvcActionEnumeration svcAction) {
- GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = new GenericResourceApiSdncrequestheaderSdncRequestHeader();
-
- sdncRequestHeader.setSvcRequestId(sdncReqId);
- sdncRequestHeader.setSvcAction(svcAction);
-
- return sdncRequestHeader;
- }
-
- public String buildObjectPath(String sdncAssignResponse) {
- String objectPath = null;
- if (sdncAssignResponse != null) {
- ObjectMapper mapper = new ObjectMapper();
- try {
- GenericResourceApiVfModuleResponseInformation assignResponseInfo = mapper.readValue(sdncAssignResponse, GenericResourceApiVfModuleResponseInformation.class);
- objectPath = assignResponseInfo.getVfModuleResponseInformation().getObjectPath();
- } catch (Exception e) {
- logger.error("{} {} {} {} {}", MessageEnum.RA_RESPONSE_FROM_SDNC.toString(), e.getMessage(), "BPMN",
- ErrorCode.UnknownError.getValue(), e.getMessage());
- }
- }
- return objectPath;
- }
+ private static final Logger logger = LoggerFactory.getLogger(VfModuleTopologyOperationRequestMapper.class);
+
+ @Autowired
+ private GeneralTopologyObjectMapper generalTopologyObjectMapper;
+
+ public GenericResourceApiVfModuleOperationInformation reqMapper(SDNCSvcOperation svcOperation,
+ SDNCSvcAction svcAction, VfModule vfModule, VolumeGroup volumeGroup, GenericVnf vnf,
+ ServiceInstance serviceInstance, Customer customer, CloudRegion cloudRegion, RequestContext requestContext,
+ String sdncAssignResponse) throws MapperException {
+ GenericResourceApiVfModuleOperationInformation req = new GenericResourceApiVfModuleOperationInformation();
+
+ boolean includeModelInformation = false;
+
+ GenericResourceApiRequestActionEnumeration requestAction =
+ GenericResourceApiRequestActionEnumeration.CREATEVFMODULEINSTANCE;
+ GenericResourceApiSvcActionEnumeration genericResourceApiSvcAction =
+ GenericResourceApiSvcActionEnumeration.ASSIGN;
+
+ if (svcAction.equals(SDNCSvcAction.ACTIVATE)) {
+ genericResourceApiSvcAction = GenericResourceApiSvcActionEnumeration.ACTIVATE;
+ requestAction = GenericResourceApiRequestActionEnumeration.CREATEVFMODULEINSTANCE;
+ includeModelInformation = true;
+ } else if (svcAction.equals(SDNCSvcAction.ASSIGN)) {
+ genericResourceApiSvcAction = GenericResourceApiSvcActionEnumeration.ASSIGN;
+ requestAction = GenericResourceApiRequestActionEnumeration.CREATEVFMODULEINSTANCE;
+ includeModelInformation = true;
+ } else if (svcAction.equals(SDNCSvcAction.DEACTIVATE)) {
+ genericResourceApiSvcAction = GenericResourceApiSvcActionEnumeration.DEACTIVATE;
+ requestAction = GenericResourceApiRequestActionEnumeration.DELETEVFMODULEINSTANCE;
+ includeModelInformation = false;
+ } else if (svcAction.equals(SDNCSvcAction.DELETE)) {
+ genericResourceApiSvcAction = GenericResourceApiSvcActionEnumeration.DELETE;
+ requestAction = GenericResourceApiRequestActionEnumeration.DELETEVFMODULEINSTANCE;
+ includeModelInformation = false;
+ } else if (svcAction.equals(SDNCSvcAction.UNASSIGN)) {
+ genericResourceApiSvcAction = GenericResourceApiSvcActionEnumeration.UNASSIGN;
+ requestAction = GenericResourceApiRequestActionEnumeration.DELETEVFMODULEINSTANCE;
+ includeModelInformation = false;
+ }
+
+ String sdncReqId = UUID.randomUUID().toString();
+ String msoRequestId = UUID.randomUUID().toString();
+ if (requestContext != null && requestContext.getMsoRequestId() != null) {
+ msoRequestId = requestContext.getMsoRequestId();
+ }
+
+ GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper
+ .buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, requestAction);
+ GenericResourceApiServiceinformationServiceInformation serviceInformation = generalTopologyObjectMapper
+ .buildServiceInformation(serviceInstance, requestContext, customer, includeModelInformation);
+ GenericResourceApiVnfinformationVnfInformation vnfInformation =
+ generalTopologyObjectMapper.buildVnfInformation(vnf, serviceInstance, includeModelInformation);
+ GenericResourceApiVfmoduleinformationVfModuleInformation vfModuleInformation = generalTopologyObjectMapper
+ .buildVfModuleInformation(vfModule, vnf, serviceInstance, requestContext, includeModelInformation);
+ GenericResourceApiVfmodulerequestinputVfModuleRequestInput vfModuleRequestInput =
+ buildVfModuleRequestInput(vfModule, volumeGroup, cloudRegion, requestContext);
+ GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader =
+ buildVfModuleSdncRequestHeader(sdncReqId, genericResourceApiSvcAction);
+
+ req.setRequestInformation(requestInformation);
+ req.setSdncRequestHeader(sdncRequestHeader);
+ req.setServiceInformation(serviceInformation);
+ req.setVnfInformation(vnfInformation);
+ req.setVfModuleInformation(vfModuleInformation);
+ req.setVfModuleRequestInput(vfModuleRequestInput);
+
+ return req;
+ }
+
+ private GenericResourceApiVfmodulerequestinputVfModuleRequestInput buildVfModuleRequestInput(VfModule vfModule,
+ VolumeGroup volumeGroup, CloudRegion cloudRegion, RequestContext requestContext) {
+ GenericResourceApiVfmodulerequestinputVfModuleRequestInput vfModuleRequestInput =
+ new GenericResourceApiVfmodulerequestinputVfModuleRequestInput();
+ if (cloudRegion != null) {
+ vfModuleRequestInput.setTenant(cloudRegion.getTenantId());
+ vfModuleRequestInput.setAicCloudRegion(cloudRegion.getLcpCloudRegionId());
+ vfModuleRequestInput.setCloudOwner(cloudRegion.getCloudOwner());
+ }
+ if (vfModule.getVfModuleName() != null && !vfModule.getVfModuleName().equals("")) {
+ vfModuleRequestInput.setVfModuleName(vfModule.getVfModuleName());
+ }
+ GenericResourceApiParam vfModuleInputParameters = new GenericResourceApiParam();
+
+ if (requestContext != null && requestContext.getUserParams() != null) {
+ for (Map.Entry<String, Object> entry : requestContext.getUserParams().entrySet()) {
+ GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam();
+ paramItem.setName(entry.getKey());
+ paramItem.setValue(generalTopologyObjectMapper.mapUserParamValue(entry.getValue()));
+ vfModuleInputParameters.addParamItem(paramItem);
+ }
+ }
+
+ if (vfModule.getCloudParams() != null) {
+ for (Map.Entry<String, String> entry : vfModule.getCloudParams().entrySet()) {
+ GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam();
+ paramItem.setName(entry.getKey());
+ paramItem.setValue(entry.getValue());
+ vfModuleInputParameters.addParamItem(paramItem);
+ }
+ }
+
+ if (volumeGroup != null) {
+ GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam();
+ paramItem.setName("volume-group-id");
+ paramItem.setValue(volumeGroup.getVolumeGroupId());
+ vfModuleInputParameters.addParamItem(paramItem);
+ }
+ vfModuleRequestInput.setVfModuleInputParameters(vfModuleInputParameters);
+
+ return vfModuleRequestInput;
+ }
+
+ private GenericResourceApiSdncrequestheaderSdncRequestHeader buildVfModuleSdncRequestHeader(String sdncReqId,
+ GenericResourceApiSvcActionEnumeration svcAction) {
+ GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader =
+ new GenericResourceApiSdncrequestheaderSdncRequestHeader();
+
+ sdncRequestHeader.setSvcRequestId(sdncReqId);
+ sdncRequestHeader.setSvcAction(svcAction);
+
+ return sdncRequestHeader;
+ }
+
+ public String buildObjectPath(String sdncAssignResponse) {
+ String objectPath = null;
+ if (sdncAssignResponse != null) {
+ ObjectMapper mapper = new ObjectMapper();
+ try {
+ GenericResourceApiVfModuleResponseInformation assignResponseInfo =
+ mapper.readValue(sdncAssignResponse, GenericResourceApiVfModuleResponseInformation.class);
+ objectPath = assignResponseInfo.getVfModuleResponseInformation().getObjectPath();
+ } catch (Exception e) {
+ logger.error("{} {} {} {} {}", MessageEnum.RA_RESPONSE_FROM_SDNC.toString(), e.getMessage(), "BPMN",
+ ErrorCode.UnknownError.getValue(), e.getMessage());
+ }
+ }
+ return objectPath;
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java
index 85e5b85529..f31bff988a 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java
@@ -24,7 +24,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
-
import org.apache.commons.lang.StringUtils;
import org.onap.sdnc.northbound.client.model.GenericResourceApiParam;
import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam;
@@ -52,93 +51,96 @@ import org.springframework.stereotype.Component;
@Component
public class VnfTopologyOperationRequestMapper {
- @Autowired
- private GeneralTopologyObjectMapper generalTopologyObjectMapper;
+ @Autowired
+ private GeneralTopologyObjectMapper generalTopologyObjectMapper;
+
+ public GenericResourceApiVnfOperationInformation reqMapper(SDNCSvcOperation svcOperation, SDNCSvcAction svcAction,
+ GenericResourceApiRequestActionEnumeration requestAction, GenericVnf vnf, ServiceInstance serviceInstance,
+ Customer customer, CloudRegion cloudRegion, RequestContext requestContext, boolean homing) {
+ String sdncReqId = UUID.randomUUID().toString();
+ String msoRequestId = UUID.randomUUID().toString();
+ if (requestContext != null && requestContext.getMsoRequestId() != null) {
+ msoRequestId = requestContext.getMsoRequestId();
+ }
+ GenericResourceApiVnfOperationInformation req = new GenericResourceApiVnfOperationInformation();
+ GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader =
+ generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId);
+ GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper
+ .buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, requestAction);
+ GenericResourceApiServiceinformationServiceInformation serviceInformation =
+ generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, true);
+ GenericResourceApiVnfinformationVnfInformation vnfInformation =
+ generalTopologyObjectMapper.buildVnfInformation(vnf, serviceInstance, true);
+ GenericResourceApiVnfrequestinputVnfRequestInput vnfRequestInput =
+ new GenericResourceApiVnfrequestinputVnfRequestInput();
- public GenericResourceApiVnfOperationInformation reqMapper(SDNCSvcOperation svcOperation, SDNCSvcAction svcAction,
- GenericResourceApiRequestActionEnumeration requestAction, GenericVnf vnf, ServiceInstance serviceInstance,
- Customer customer, CloudRegion cloudRegion, RequestContext requestContext, boolean homing) {
- String sdncReqId = UUID.randomUUID().toString();
- String msoRequestId = UUID.randomUUID().toString();
- if (requestContext != null && requestContext.getMsoRequestId() != null) {
- msoRequestId = requestContext.getMsoRequestId();
- }
- GenericResourceApiVnfOperationInformation req = new GenericResourceApiVnfOperationInformation();
- GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = generalTopologyObjectMapper
- .buildSdncRequestHeader(svcAction, sdncReqId);
- GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper
- .buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, requestAction);
- GenericResourceApiServiceinformationServiceInformation serviceInformation = generalTopologyObjectMapper
- .buildServiceInformation(serviceInstance, requestContext, customer, true);
- GenericResourceApiVnfinformationVnfInformation vnfInformation = generalTopologyObjectMapper
- .buildVnfInformation(vnf, serviceInstance, true);
- GenericResourceApiVnfrequestinputVnfRequestInput vnfRequestInput = new GenericResourceApiVnfrequestinputVnfRequestInput();
+ vnfRequestInput.setTenant(cloudRegion.getTenantId());
+ vnfRequestInput.setAicCloudRegion(cloudRegion.getLcpCloudRegionId());
+ vnfRequestInput.setCloudOwner(cloudRegion.getCloudOwner());
- vnfRequestInput.setTenant(cloudRegion.getTenantId());
- vnfRequestInput.setAicCloudRegion(cloudRegion.getLcpCloudRegionId());
- vnfRequestInput.setCloudOwner(cloudRegion.getCloudOwner());
-
- if (StringUtils.isNotBlank(vnf.getVnfName())) {
- vnfRequestInput.setVnfName(vnf.getVnfName());
- }
+ if (StringUtils.isNotBlank(vnf.getVnfName())) {
+ vnfRequestInput.setVnfName(vnf.getVnfName());
+ }
- req.setRequestInformation(requestInformation);
- req.setSdncRequestHeader(sdncRequestHeader);
- req.setServiceInformation(serviceInformation);
- req.setVnfInformation(vnfInformation);
+ req.setRequestInformation(requestInformation);
+ req.setSdncRequestHeader(sdncRequestHeader);
+ req.setServiceInformation(serviceInformation);
+ req.setVnfInformation(vnfInformation);
- GenericResourceApiParam vnfInputParameters = new GenericResourceApiParam();
- if (requestContext != null && requestContext.getUserParams() != null) {
- for (Map.Entry<String, Object> entry : requestContext.getUserParams().entrySet()) {
- GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam();
- paramItem.setName(entry.getKey());
- paramItem.setValue(generalTopologyObjectMapper.mapUserParamValue(entry.getValue()));
- vnfInputParameters.addParamItem(paramItem);
- vnfRequestInput.setVnfInputParameters(vnfInputParameters);
- }
- }
- if (vnf.getCloudParams() != null) {
- for (Map.Entry<String, String> entry : vnf.getCloudParams().entrySet()) {
- GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam();
- paramItem.setName(entry.getKey());
- paramItem.setValue(entry.getValue());
- vnfInputParameters.addParamItem(paramItem);
- }
- }
- if (homing) {
- License license = vnf.getLicense();
- if (license != null) {
- if(license.getEntitlementPoolUuids() != null && !license.getEntitlementPoolUuids().isEmpty()) {
- String entitlementPoolUuid = license.getEntitlementPoolUuids().get(0);
- GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam();
- paramItem.setName("entitlement_assignment_group_uuid");
- paramItem.setValue(entitlementPoolUuid);
- vnfInputParameters.addParamItem(paramItem);
- }
- if (license.getLicenseKeyGroupUuids() != null && !license.getLicenseKeyGroupUuids().isEmpty()) {
- String licenseKeyGroupUuid = license.getLicenseKeyGroupUuids().get(0);
- GenericResourceApiParamParam paramItem2 = new GenericResourceApiParamParam();
- paramItem2.setName("license_assignment_group_uuid");
- paramItem2.setValue(licenseKeyGroupUuid);
- vnfInputParameters.addParamItem(paramItem2);
- }
- }
- }
- List<InstanceGroup> instanceGroups = vnf.getInstanceGroups();
- List<GenericResourceApiVnfrequestinputVnfrequestinputVnfNetworkInstanceGroupIds> networkInstanceGroupIdList = new ArrayList<GenericResourceApiVnfrequestinputVnfrequestinputVnfNetworkInstanceGroupIds>();
+ GenericResourceApiParam vnfInputParameters = new GenericResourceApiParam();
+ if (requestContext != null && requestContext.getUserParams() != null) {
+ for (Map.Entry<String, Object> entry : requestContext.getUserParams().entrySet()) {
+ GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam();
+ paramItem.setName(entry.getKey());
+ paramItem.setValue(generalTopologyObjectMapper.mapUserParamValue(entry.getValue()));
+ vnfInputParameters.addParamItem(paramItem);
+ vnfRequestInput.setVnfInputParameters(vnfInputParameters);
+ }
+ }
+ if (vnf.getCloudParams() != null) {
+ for (Map.Entry<String, String> entry : vnf.getCloudParams().entrySet()) {
+ GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam();
+ paramItem.setName(entry.getKey());
+ paramItem.setValue(entry.getValue());
+ vnfInputParameters.addParamItem(paramItem);
+ }
+ }
+ if (homing) {
+ License license = vnf.getLicense();
+ if (license != null) {
+ if (license.getEntitlementPoolUuids() != null && !license.getEntitlementPoolUuids().isEmpty()) {
+ String entitlementPoolUuid = license.getEntitlementPoolUuids().get(0);
+ GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam();
+ paramItem.setName("entitlement_assignment_group_uuid");
+ paramItem.setValue(entitlementPoolUuid);
+ vnfInputParameters.addParamItem(paramItem);
+ }
+ if (license.getLicenseKeyGroupUuids() != null && !license.getLicenseKeyGroupUuids().isEmpty()) {
+ String licenseKeyGroupUuid = license.getLicenseKeyGroupUuids().get(0);
+ GenericResourceApiParamParam paramItem2 = new GenericResourceApiParamParam();
+ paramItem2.setName("license_assignment_group_uuid");
+ paramItem2.setValue(licenseKeyGroupUuid);
+ vnfInputParameters.addParamItem(paramItem2);
+ }
+ }
+ }
+ List<InstanceGroup> instanceGroups = vnf.getInstanceGroups();
+ List<GenericResourceApiVnfrequestinputVnfrequestinputVnfNetworkInstanceGroupIds> networkInstanceGroupIdList =
+ new ArrayList<GenericResourceApiVnfrequestinputVnfrequestinputVnfNetworkInstanceGroupIds>();
- for (InstanceGroup instanceGroup : instanceGroups) {
- if (ModelInfoInstanceGroup.TYPE_L3_NETWORK
- .equalsIgnoreCase(instanceGroup.getModelInfoInstanceGroup().getType())) {
- GenericResourceApiVnfrequestinputVnfrequestinputVnfNetworkInstanceGroupIds instanceGroupId = new GenericResourceApiVnfrequestinputVnfrequestinputVnfNetworkInstanceGroupIds();
- instanceGroupId.setVnfNetworkInstanceGroupId(instanceGroup.getId());
- networkInstanceGroupIdList.add(instanceGroupId);
- }
- }
+ for (InstanceGroup instanceGroup : instanceGroups) {
+ if (ModelInfoInstanceGroup.TYPE_L3_NETWORK
+ .equalsIgnoreCase(instanceGroup.getModelInfoInstanceGroup().getType())) {
+ GenericResourceApiVnfrequestinputVnfrequestinputVnfNetworkInstanceGroupIds instanceGroupId =
+ new GenericResourceApiVnfrequestinputVnfrequestinputVnfNetworkInstanceGroupIds();
+ instanceGroupId.setVnfNetworkInstanceGroupId(instanceGroup.getId());
+ networkInstanceGroupIdList.add(instanceGroupId);
+ }
+ }
- vnfRequestInput.setVnfNetworkInstanceGroupIds(networkInstanceGroupIdList);
- vnfRequestInput.setVnfInputParameters(vnfInputParameters);
- req.setVnfRequestInput(vnfRequestInput);
- return req;
- }
+ vnfRequestInput.setVnfNetworkInstanceGroupIds(networkInstanceGroupIdList);
+ vnfRequestInput.setVnfInputParameters(vnfInputParameters);
+ req.setVnfRequestInput(vnfRequestInput);
+ return req;
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/SniroClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/SniroClient.java
index 5a48a757bc..f7aad558b2 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/SniroClient.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/SniroClient.java
@@ -23,7 +23,6 @@
package org.onap.so.client.sniro;
import java.util.LinkedHashMap;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.onap.so.bpmn.common.baseclient.BaseClient;
import org.onap.so.bpmn.core.UrnPropertiesReader;
@@ -38,82 +37,83 @@ import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
-
import com.fasterxml.jackson.core.JsonProcessingException;
@Component
public class SniroClient {
- private static final Logger logger = LoggerFactory.getLogger(SniroClient.class);
-
- @Autowired
- private ManagerProperties managerProperties;
-
- @Autowired
- private SniroValidator validator;
-
-
- /**
- * Makes a rest call to sniro manager to perform homing and licensing for a
- * list of demands
- *
- * @param homingRequest
- * @return
- * @throws JsonProcessingException
- * @throws BpmnError
- */
- public void postDemands(SniroManagerRequest homingRequest) throws BadResponseException, JsonProcessingException{
- logger.trace("Started Sniro Client Post Demands");
- String url = managerProperties.getHost() + managerProperties.getUri().get("v2");
- logger.debug("Post demands url: {}", url);
- logger.debug("Post demands payload: {}", homingRequest.toJsonString());
-
- HttpHeaders header = new HttpHeaders();
- header.setContentType(MediaType.APPLICATION_JSON);
- header.set("Authorization", managerProperties.getHeaders().get("auth"));
- header.set("X-patchVersion", managerProperties.getHeaders().get("patchVersion"));
- header.set("X-minorVersion", managerProperties.getHeaders().get("minorVersion"));
- header.set("X-latestVersion", managerProperties.getHeaders().get("latestVersion"));
- BaseClient<String, LinkedHashMap<String, Object>> baseClient = new BaseClient<>();
-
- baseClient.setTargetUrl(url);
- baseClient.setHttpHeader(header);
-
- LinkedHashMap<String, Object> response = baseClient.post(homingRequest.toJsonString(), new ParameterizedTypeReference<LinkedHashMap<String, Object>>() {});
- validator.validateDemandsResponse(response);
- logger.trace("Completed Sniro Client Post Demands");
- }
-
- /**
- * Makes a rest call to sniro conductor to notify them of successful or unsuccessful vnf
- * creation for previously homed resources
- *
- * TODO Temporarily being used in groovy therefore can not utilize autowire. Once java "release"
- * subflow is developed it will be refactored to use autowire.
- *
- * @param releaseRequest
- * @return
- * @throws BadResponseException
- */
- public void postRelease(SniroConductorRequest releaseRequest) throws BadResponseException {
- logger.trace("Started Sniro Client Post Release");
- String url = UrnPropertiesReader.getVariable("sniro.conductor.host") + UrnPropertiesReader.getVariable("sniro.conductor.uri");
- logger.debug("Post release url: {}", url);
- logger.debug("Post release payload: {}", releaseRequest.toJsonString());
-
- HttpHeaders header = new HttpHeaders();
- header.setContentType(MediaType.APPLICATION_JSON);
- header.set("Authorization", UrnPropertiesReader.getVariable("sniro.conductor.headers.auth"));
- BaseClient<String, LinkedHashMap<String, Object>> baseClient = new BaseClient<>();
-
- baseClient.setTargetUrl(url);
- baseClient.setHttpHeader(header);
-
- LinkedHashMap<String, Object> response = baseClient.post(releaseRequest.toJsonString(), new ParameterizedTypeReference<LinkedHashMap<String, Object>>() {});
- SniroValidator v = new SniroValidator();
- v.validateReleaseResponse(response);
- logger.trace("Completed Sniro Client Post Release");
- }
+ private static final Logger logger = LoggerFactory.getLogger(SniroClient.class);
+
+ @Autowired
+ private ManagerProperties managerProperties;
+
+ @Autowired
+ private SniroValidator validator;
+
+
+ /**
+ * Makes a rest call to sniro manager to perform homing and licensing for a list of demands
+ *
+ * @param homingRequest
+ * @return
+ * @throws JsonProcessingException
+ * @throws BpmnError
+ */
+ public void postDemands(SniroManagerRequest homingRequest) throws BadResponseException, JsonProcessingException {
+ logger.trace("Started Sniro Client Post Demands");
+ String url = managerProperties.getHost() + managerProperties.getUri().get("v2");
+ logger.debug("Post demands url: {}", url);
+ logger.debug("Post demands payload: {}", homingRequest.toJsonString());
+
+ HttpHeaders header = new HttpHeaders();
+ header.setContentType(MediaType.APPLICATION_JSON);
+ header.set("Authorization", managerProperties.getHeaders().get("auth"));
+ header.set("X-patchVersion", managerProperties.getHeaders().get("patchVersion"));
+ header.set("X-minorVersion", managerProperties.getHeaders().get("minorVersion"));
+ header.set("X-latestVersion", managerProperties.getHeaders().get("latestVersion"));
+ BaseClient<String, LinkedHashMap<String, Object>> baseClient = new BaseClient<>();
+
+ baseClient.setTargetUrl(url);
+ baseClient.setHttpHeader(header);
+
+ LinkedHashMap<String, Object> response = baseClient.post(homingRequest.toJsonString(),
+ new ParameterizedTypeReference<LinkedHashMap<String, Object>>() {});
+ validator.validateDemandsResponse(response);
+ logger.trace("Completed Sniro Client Post Demands");
+ }
+
+ /**
+ * Makes a rest call to sniro conductor to notify them of successful or unsuccessful vnf creation for previously
+ * homed resources
+ *
+ * TODO Temporarily being used in groovy therefore can not utilize autowire. Once java "release" subflow is
+ * developed it will be refactored to use autowire.
+ *
+ * @param releaseRequest
+ * @return
+ * @throws BadResponseException
+ */
+ public void postRelease(SniroConductorRequest releaseRequest) throws BadResponseException {
+ logger.trace("Started Sniro Client Post Release");
+ String url = UrnPropertiesReader.getVariable("sniro.conductor.host")
+ + UrnPropertiesReader.getVariable("sniro.conductor.uri");
+ logger.debug("Post release url: {}", url);
+ logger.debug("Post release payload: {}", releaseRequest.toJsonString());
+
+ HttpHeaders header = new HttpHeaders();
+ header.setContentType(MediaType.APPLICATION_JSON);
+ header.set("Authorization", UrnPropertiesReader.getVariable("sniro.conductor.headers.auth"));
+ BaseClient<String, LinkedHashMap<String, Object>> baseClient = new BaseClient<>();
+
+ baseClient.setTargetUrl(url);
+ baseClient.setHttpHeader(header);
+
+ LinkedHashMap<String, Object> response = baseClient.post(releaseRequest.toJsonString(),
+ new ParameterizedTypeReference<LinkedHashMap<String, Object>>() {});
+ SniroValidator v = new SniroValidator();
+ v.validateReleaseResponse(response);
+ logger.trace("Completed Sniro Client Post Release");
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/SniroValidator.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/SniroValidator.java
index dcccd319c6..a448082cfe 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/SniroValidator.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/SniroValidator.java
@@ -24,12 +24,9 @@ package org.onap.so.client.sniro;
import static org.apache.commons.lang.StringUtils.*;
-
import java.util.LinkedHashMap;
-
import org.json.JSONObject;
import org.onap.so.client.exception.BadResponseException;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@@ -39,101 +36,103 @@ import org.springframework.stereotype.Component;
@Component
public class SniroValidator {
- private static final Logger logger = LoggerFactory.getLogger(SniroValidator.class);
-
- /**
- * Validates the synchronous homing response from sniro manager
- *
- * @throws BadResponseException
- */
- public void validateDemandsResponse(LinkedHashMap<String, Object> response) throws BadResponseException {
- logger.debug("Validating Sniro Managers synchronous response");
- if(!response.isEmpty()){
- JSONObject jsonResponse = new JSONObject(response);
- if(jsonResponse.has("requestStatus")){
- String status = jsonResponse.getString("requestStatus");
- if(status.equals("accepted")){
- logger.debug("Sniro Managers synchronous response indicates accepted");
- }else{
- String message = jsonResponse.getString("statusMessage");
- if(isNotBlank(message)){
- logger.debug("Sniro Managers response indicates failed: " + message);
- }else{
- logger.debug("Sniro Managers response indicates failed: no status message provided");
- message = "error message not provided";
- }
- throw new BadResponseException("Sniro Managers synchronous response indicates failed: " + message);
- }
- }else{
- logger.debug("Sniro Managers synchronous response does not contain: request status");
- throw new BadResponseException("Sniro Managers synchronous response does not contain: request status");
- }
- }else{
- logger.debug("Sniro Managers synchronous response is empty");
- throw new BadResponseException("Sniro Managers synchronous response i is empty");
- }
- }
-
- /**
- * Validates the asynchronous/callback response from sniro manager which
- * contains the homing and licensing solutions
- *
- * @throws BadResponseException
- */
- public static void validateSolution(String response) throws BadResponseException{
- logger.debug("Validating Sniro Managers asynchronous callback response");
- if(isNotBlank(response)) {
- JSONObject jsonResponse = new JSONObject(response);
- if(!jsonResponse.has("serviceException")){
- logger.debug("Sniro Managers asynchronous response is valid");
- }else{
- String message = jsonResponse.getJSONObject("serviceException").getString("text");
- if(isNotBlank(message)){
- logger.debug("Sniro Managers response contains a service exception: " + message);
- }else{
- logger.debug("Sniro Managers response contains a service exception: no service exception text provided");
- message = "error message not provided";
- }
- throw new BadResponseException("Sniro Managers asynchronous response contains a service exception: " + message);
- }
- }else{
- logger.debug("Sniro Managers asynchronous response is empty");
- throw new BadResponseException("Sniro Managers asynchronous response is empty");
- }
- }
-
-
- /**
- * Validates the release response from sniro conductor
- *
- * @throws BadResponseException
- */
- public void validateReleaseResponse(LinkedHashMap<String, Object> response) throws BadResponseException {
- logger.debug("Validating Sniro Conductors response");
- if(!response.isEmpty()){
- String status = (String) response.get("status");
- if(isNotBlank(status)){
- if(status.equals("success")){
- logger.debug("Sniro Conductors synchronous response indicates success");
- }else{
- String message = (String) response.get("message");
- if(isNotBlank(message)){
- logger.debug("Sniro Conductors response indicates failed: " + message);
- }else{
- logger.debug("Sniro Conductors response indicates failed: error message not provided");
- message = "error message not provided";
- }
- throw new BadResponseException("Sniro Conductors synchronous response indicates failed: " + message);
- }
- }else{
- logger.debug("Sniro Managers Conductors response does not contain: status");
- throw new BadResponseException("Sniro Conductors synchronous response does not contain: status");
- }
- }else{
- logger.debug("Sniro Conductors response is empty");
- throw new BadResponseException("Sniro Conductors response is empty");
- }
-
- }
+ private static final Logger logger = LoggerFactory.getLogger(SniroValidator.class);
+
+ /**
+ * Validates the synchronous homing response from sniro manager
+ *
+ * @throws BadResponseException
+ */
+ public void validateDemandsResponse(LinkedHashMap<String, Object> response) throws BadResponseException {
+ logger.debug("Validating Sniro Managers synchronous response");
+ if (!response.isEmpty()) {
+ JSONObject jsonResponse = new JSONObject(response);
+ if (jsonResponse.has("requestStatus")) {
+ String status = jsonResponse.getString("requestStatus");
+ if (status.equals("accepted")) {
+ logger.debug("Sniro Managers synchronous response indicates accepted");
+ } else {
+ String message = jsonResponse.getString("statusMessage");
+ if (isNotBlank(message)) {
+ logger.debug("Sniro Managers response indicates failed: " + message);
+ } else {
+ logger.debug("Sniro Managers response indicates failed: no status message provided");
+ message = "error message not provided";
+ }
+ throw new BadResponseException("Sniro Managers synchronous response indicates failed: " + message);
+ }
+ } else {
+ logger.debug("Sniro Managers synchronous response does not contain: request status");
+ throw new BadResponseException("Sniro Managers synchronous response does not contain: request status");
+ }
+ } else {
+ logger.debug("Sniro Managers synchronous response is empty");
+ throw new BadResponseException("Sniro Managers synchronous response i is empty");
+ }
+ }
+
+ /**
+ * Validates the asynchronous/callback response from sniro manager which contains the homing and licensing solutions
+ *
+ * @throws BadResponseException
+ */
+ public static void validateSolution(String response) throws BadResponseException {
+ logger.debug("Validating Sniro Managers asynchronous callback response");
+ if (isNotBlank(response)) {
+ JSONObject jsonResponse = new JSONObject(response);
+ if (!jsonResponse.has("serviceException")) {
+ logger.debug("Sniro Managers asynchronous response is valid");
+ } else {
+ String message = jsonResponse.getJSONObject("serviceException").getString("text");
+ if (isNotBlank(message)) {
+ logger.debug("Sniro Managers response contains a service exception: " + message);
+ } else {
+ logger.debug(
+ "Sniro Managers response contains a service exception: no service exception text provided");
+ message = "error message not provided";
+ }
+ throw new BadResponseException(
+ "Sniro Managers asynchronous response contains a service exception: " + message);
+ }
+ } else {
+ logger.debug("Sniro Managers asynchronous response is empty");
+ throw new BadResponseException("Sniro Managers asynchronous response is empty");
+ }
+ }
+
+
+ /**
+ * Validates the release response from sniro conductor
+ *
+ * @throws BadResponseException
+ */
+ public void validateReleaseResponse(LinkedHashMap<String, Object> response) throws BadResponseException {
+ logger.debug("Validating Sniro Conductors response");
+ if (!response.isEmpty()) {
+ String status = (String) response.get("status");
+ if (isNotBlank(status)) {
+ if (status.equals("success")) {
+ logger.debug("Sniro Conductors synchronous response indicates success");
+ } else {
+ String message = (String) response.get("message");
+ if (isNotBlank(message)) {
+ logger.debug("Sniro Conductors response indicates failed: " + message);
+ } else {
+ logger.debug("Sniro Conductors response indicates failed: error message not provided");
+ message = "error message not provided";
+ }
+ throw new BadResponseException(
+ "Sniro Conductors synchronous response indicates failed: " + message);
+ }
+ } else {
+ logger.debug("Sniro Managers Conductors response does not contain: status");
+ throw new BadResponseException("Sniro Conductors synchronous response does not contain: status");
+ }
+ } else {
+ logger.debug("Sniro Conductors response is empty");
+ throw new BadResponseException("Sniro Conductors response is empty");
+ }
+
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/Candidate.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/Candidate.java
index 3b7e509752..cded23aad2 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/Candidate.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/Candidate.java
@@ -22,45 +22,43 @@ package org.onap.so.client.sniro.beans;
import java.io.Serializable;
import java.util.List;
-
import org.onap.so.bpmn.servicedecomposition.homingobjects.CandidateType;
-
import com.fasterxml.jackson.annotation.JsonProperty;
-public class Candidate implements Serializable{
+public class Candidate implements Serializable {
- private static final long serialVersionUID = -5474502255533410907L;
+ private static final long serialVersionUID = -5474502255533410907L;
- @JsonProperty("identifierType")
- private CandidateType identifierType;
- @JsonProperty("identifiers")
- private List<String> identifiers;
- @JsonProperty("cloudOwner")
- private String cloudOwner;
+ @JsonProperty("identifierType")
+ private CandidateType identifierType;
+ @JsonProperty("identifiers")
+ private List<String> identifiers;
+ @JsonProperty("cloudOwner")
+ private String cloudOwner;
- public CandidateType getIdentifierType(){
- return identifierType;
- }
+ public CandidateType getIdentifierType() {
+ return identifierType;
+ }
- public void setIdentifierType(CandidateType identifierType){
- this.identifierType = identifierType;
- }
+ public void setIdentifierType(CandidateType identifierType) {
+ this.identifierType = identifierType;
+ }
- public List<String> getIdentifiers(){
- return identifiers;
- }
+ public List<String> getIdentifiers() {
+ return identifiers;
+ }
- public void setIdentifiers(List<String> identifiers){
- this.identifiers = identifiers;
- }
+ public void setIdentifiers(List<String> identifiers) {
+ this.identifiers = identifiers;
+ }
- public String getCloudOwner(){
- return cloudOwner;
- }
+ public String getCloudOwner() {
+ return cloudOwner;
+ }
- public void setCloudOwner(String cloudOwner){
- this.cloudOwner = cloudOwner;
- }
+ public void setCloudOwner(String cloudOwner) {
+ this.cloudOwner = cloudOwner;
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/ConductorProperties.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/ConductorProperties.java
index 6e60bfa293..9ac8727a0f 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/ConductorProperties.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/ConductorProperties.java
@@ -21,7 +21,6 @@
package org.onap.so.client.sniro.beans;
import java.util.Map;
-
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@@ -29,33 +28,35 @@ import org.springframework.context.annotation.Configuration;
@ConfigurationProperties(prefix = "sniro.conductor")
public class ConductorProperties {
- private String host;
- private String uri;
-
- private Map<String, String> headers;
-
-
- public String getHost() {
- return host;
- }
- public void setHost(String host) {
- this.host = host;
- }
- public String getUri() {
- return uri;
- }
- public void setUri(String uri) {
- this.uri = uri;
- }
- public Map<String, String> getHeaders() {
- return headers;
- }
- public void setHeaders(Map<String, String> headers) {
- this.headers = headers;
- }
+ private String host;
+ private String uri;
+
+ private Map<String, String> headers;
+
+
+ public String getHost() {
+ return host;
+ }
+
+ public void setHost(String host) {
+ this.host = host;
+ }
+
+ public String getUri() {
+ return uri;
+ }
+ public void setUri(String uri) {
+ this.uri = uri;
+ }
+ public Map<String, String> getHeaders() {
+ return headers;
+ }
+ public void setHeaders(Map<String, String> headers) {
+ this.headers = headers;
+ }
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/Demand.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/Demand.java
index ed7875f286..19378cdbfa 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/Demand.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/Demand.java
@@ -22,63 +22,62 @@ package org.onap.so.client.sniro.beans;
import java.io.Serializable;
import java.util.List;
-
import com.fasterxml.jackson.annotation.JsonProperty;
-public class Demand implements Serializable{
+public class Demand implements Serializable {
- private static final long serialVersionUID = 5676094538091859816L;
+ private static final long serialVersionUID = 5676094538091859816L;
- @JsonProperty("serviceResourceId")
- private String serviceResourceId;
- @JsonProperty("resourceModuleName")
- private String resourceModuleName;
- @JsonProperty("resourceModelInfo")
- private ModelInfo modelInfo;
- @JsonProperty("requiredCandidates")
- private List<Candidate> requiredCandidates;
- @JsonProperty("excludedCandidates")
- private List<Candidate> excludedCandidates;
+ @JsonProperty("serviceResourceId")
+ private String serviceResourceId;
+ @JsonProperty("resourceModuleName")
+ private String resourceModuleName;
+ @JsonProperty("resourceModelInfo")
+ private ModelInfo modelInfo;
+ @JsonProperty("requiredCandidates")
+ private List<Candidate> requiredCandidates;
+ @JsonProperty("excludedCandidates")
+ private List<Candidate> excludedCandidates;
- public List<Candidate> getRequiredCandidates(){
- return requiredCandidates;
- }
+ public List<Candidate> getRequiredCandidates() {
+ return requiredCandidates;
+ }
- public void setRequiredCandidates(List<Candidate> requiredCandidates){
- this.requiredCandidates = requiredCandidates;
- }
+ public void setRequiredCandidates(List<Candidate> requiredCandidates) {
+ this.requiredCandidates = requiredCandidates;
+ }
- public List<Candidate> getExcludedCandidates(){
- return excludedCandidates;
- }
+ public List<Candidate> getExcludedCandidates() {
+ return excludedCandidates;
+ }
- public void setExcludedCandidates(List<Candidate> excludedCandidates){
- this.excludedCandidates = excludedCandidates;
- }
+ public void setExcludedCandidates(List<Candidate> excludedCandidates) {
+ this.excludedCandidates = excludedCandidates;
+ }
- public String getServiceResourceId(){
- return serviceResourceId;
- }
+ public String getServiceResourceId() {
+ return serviceResourceId;
+ }
- public void setServiceResourceId(String serviceResourceId){
- this.serviceResourceId = serviceResourceId;
- }
+ public void setServiceResourceId(String serviceResourceId) {
+ this.serviceResourceId = serviceResourceId;
+ }
- public String getResourceModuleName(){
- return resourceModuleName;
- }
+ public String getResourceModuleName() {
+ return resourceModuleName;
+ }
- public void setResourceModuleName(String resourceModuleName){
- this.resourceModuleName = resourceModuleName;
- }
+ public void setResourceModuleName(String resourceModuleName) {
+ this.resourceModuleName = resourceModuleName;
+ }
- public ModelInfo getModelInfo(){
- return modelInfo;
- }
+ public ModelInfo getModelInfo() {
+ return modelInfo;
+ }
- public void setModelInfo(ModelInfo modelInfo){
- this.modelInfo = modelInfo;
- }
+ public void setModelInfo(ModelInfo modelInfo) {
+ this.modelInfo = modelInfo;
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/LicenseInfo.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/LicenseInfo.java
index 209792b4d7..d71b4ec5fc 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/LicenseInfo.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/LicenseInfo.java
@@ -23,23 +23,22 @@ package org.onap.so.client.sniro.beans;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
-
import com.fasterxml.jackson.annotation.JsonProperty;
-public class LicenseInfo implements Serializable{
+public class LicenseInfo implements Serializable {
- private static final long serialVersionUID = 6878164369491185856L;
+ private static final long serialVersionUID = 6878164369491185856L;
- @JsonProperty("licenseDemands")
- private List<Demand> demands = new ArrayList<Demand>();
+ @JsonProperty("licenseDemands")
+ private List<Demand> demands = new ArrayList<Demand>();
- public List<Demand> getDemands(){
- return demands;
- }
+ public List<Demand> getDemands() {
+ return demands;
+ }
- public void setDemands(List<Demand> demands){
- this.demands = demands;
- }
+ public void setDemands(List<Demand> demands) {
+ this.demands = demands;
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/ManagerProperties.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/ManagerProperties.java
index 0070f2fe04..70b1a37b5e 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/ManagerProperties.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/ManagerProperties.java
@@ -21,7 +21,6 @@
package org.onap.so.client.sniro.beans;
import java.util.Map;
-
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@@ -29,30 +28,34 @@ import org.springframework.context.annotation.Configuration;
@ConfigurationProperties(prefix = "sniro.manager")
public class ManagerProperties {
- private String host;
- private Map<String, String> uri;
- private Map<String, String> headers;
-
-
- public String getHost() {
- return host;
- }
- public void setHost(String host) {
- this.host = host;
- }
- public Map<String, String> getUri() {
- return uri;
- }
- public void setUri(Map<String, String> uri) {
- this.uri = uri;
- }
- public Map<String, String> getHeaders() {
- return headers;
- }
- public void setHeaders(Map<String, String> headers) {
- this.headers = headers;
- }
+ private String host;
+ private Map<String, String> uri;
+ private Map<String, String> headers;
+
+
+ public String getHost() {
+ return host;
+ }
+
+ public void setHost(String host) {
+ this.host = host;
+ }
+
+ public Map<String, String> getUri() {
+ return uri;
+ }
+
+ public void setUri(Map<String, String> uri) {
+ this.uri = uri;
+ }
+
+ public Map<String, String> getHeaders() {
+ return headers;
+ }
+ public void setHeaders(Map<String, String> headers) {
+ this.headers = headers;
+ }
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/ModelInfo.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/ModelInfo.java
index 34d746b8d2..6c1932e344 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/ModelInfo.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/ModelInfo.java
@@ -21,62 +21,56 @@
package org.onap.so.client.sniro.beans;
import java.io.Serializable;
-
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonRootName;
-@JsonPropertyOrder({
- "modelName",
- "modelVersionId",
- "modelVersion",
- "modelInvariantId"
-})
+@JsonPropertyOrder({"modelName", "modelVersionId", "modelVersion", "modelInvariantId"})
@JsonRootName("modelInfo")
-public class ModelInfo implements Serializable{
+public class ModelInfo implements Serializable {
- private static final long serialVersionUID = 1488642558601651075L;
+ private static final long serialVersionUID = 1488642558601651075L;
- @JsonProperty("modelInvariantId")
- private String modelInvariantId;
- @JsonProperty("modelVersionId")
- private String modelVersionId;
- @JsonProperty("modelName")
- private String modelName;
- @JsonProperty("modelVersion")
- private String modelVersion;
+ @JsonProperty("modelInvariantId")
+ private String modelInvariantId;
+ @JsonProperty("modelVersionId")
+ private String modelVersionId;
+ @JsonProperty("modelName")
+ private String modelName;
+ @JsonProperty("modelVersion")
+ private String modelVersion;
- public String getModelInvariantId(){
- return modelInvariantId;
- }
+ public String getModelInvariantId() {
+ return modelInvariantId;
+ }
- public void setModelInvariantId(String modelInvariantId){
- this.modelInvariantId = modelInvariantId;
- }
+ public void setModelInvariantId(String modelInvariantId) {
+ this.modelInvariantId = modelInvariantId;
+ }
- public String getModelVersionId(){
- return modelVersionId;
- }
+ public String getModelVersionId() {
+ return modelVersionId;
+ }
- public void setModelVersionId(String modelVersionId){
- this.modelVersionId = modelVersionId;
- }
+ public void setModelVersionId(String modelVersionId) {
+ this.modelVersionId = modelVersionId;
+ }
- public String getModelName(){
- return modelName;
- }
+ public String getModelName() {
+ return modelName;
+ }
- public void setModelName(String modelName){
- this.modelName = modelName;
- }
+ public void setModelName(String modelName) {
+ this.modelName = modelName;
+ }
- public String getModelVersion(){
- return modelVersion;
- }
+ public String getModelVersion() {
+ return modelVersion;
+ }
- public void setModelVersion(String modelVersion){
- this.modelVersion = modelVersion;
- }
+ public void setModelVersion(String modelVersion) {
+ this.modelVersion = modelVersion;
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/PlacementInfo.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/PlacementInfo.java
index 9ae2c72798..ae13903a22 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/PlacementInfo.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/PlacementInfo.java
@@ -23,53 +23,48 @@ package org.onap.so.client.sniro.beans;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
-
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonRawValue;
import com.fasterxml.jackson.annotation.JsonRootName;
-@JsonPropertyOrder({
- "subscriberInfo",
- "placementDemands",
- "requestParameters"
-})
+@JsonPropertyOrder({"subscriberInfo", "placementDemands", "requestParameters"})
@JsonRootName("placementInfo")
-public class PlacementInfo implements Serializable{
+public class PlacementInfo implements Serializable {
- private static final long serialVersionUID = -964488472247386556L;
+ private static final long serialVersionUID = -964488472247386556L;
- @JsonProperty("subscriberInfo")
- private SubscriberInfo subscriberInfo;
- @JsonProperty("placementDemands")
- private List<Demand> demands = new ArrayList<Demand>();
- @JsonRawValue
- @JsonProperty("requestParameters")
- private String requestParameters;
+ @JsonProperty("subscriberInfo")
+ private SubscriberInfo subscriberInfo;
+ @JsonProperty("placementDemands")
+ private List<Demand> demands = new ArrayList<Demand>();
+ @JsonRawValue
+ @JsonProperty("requestParameters")
+ private String requestParameters;
- public SubscriberInfo getSubscriberInfo(){
- return subscriberInfo;
- }
+ public SubscriberInfo getSubscriberInfo() {
+ return subscriberInfo;
+ }
- public void setSubscriberInfo(SubscriberInfo subscriberInfo){
- this.subscriberInfo = subscriberInfo;
- }
+ public void setSubscriberInfo(SubscriberInfo subscriberInfo) {
+ this.subscriberInfo = subscriberInfo;
+ }
- public List<Demand> getDemands(){
- return demands;
- }
+ public List<Demand> getDemands() {
+ return demands;
+ }
- public void setDemands(List<Demand> demands){
- this.demands = demands;
- }
+ public void setDemands(List<Demand> demands) {
+ this.demands = demands;
+ }
- public String getRequestParameters(){
- return requestParameters;
- }
+ public String getRequestParameters() {
+ return requestParameters;
+ }
- public void setRequestParameters(String requestParameters){
- this.requestParameters = requestParameters;
- }
+ public void setRequestParameters(String requestParameters) {
+ this.requestParameters = requestParameters;
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/RequestInfo.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/RequestInfo.java
index e92b5d1ca3..fc6aec7d14 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/RequestInfo.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/RequestInfo.java
@@ -21,77 +21,75 @@
package org.onap.so.client.sniro.beans;
import java.io.Serializable;
-
-
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName;
@JsonRootName("requestInfo")
-public class RequestInfo implements Serializable{
-
- private static final long serialVersionUID = -759180997599143791L;
-
- @JsonProperty("transactionId")
- String transactionId;
- @JsonProperty("requestId")
- String requestId;
- @JsonProperty("callbackUrl")
- String callbackUrl;
- @JsonProperty("sourceId")
- String sourceId = "mso";
- @JsonProperty("requestType")
- String requestType;
- @JsonProperty("timeout")
- long timeout;
-
- public String getTransactionId(){
- return transactionId;
- }
-
- public void setTransactionId(String transactionId){
- this.transactionId = transactionId;
- }
-
- public String getRequestId(){
- return requestId;
- }
-
- public void setRequestId(String requestId){
- this.requestId = requestId;
- }
-
- public String getCallbackUrl(){
- return callbackUrl;
- }
-
- public void setCallbackUrl(String callbackUrl){
- this.callbackUrl = callbackUrl;
- }
-
- public String getSourceId(){
- return sourceId;
- }
-
- public void setSourceId(String sourceId){
- this.sourceId = sourceId;
- }
-
- public String getRequestType(){
- return requestType;
- }
-
- public void setRequestType(String requestType){
- this.requestType = requestType;
- }
-
- public long getTimeout(){
- return timeout;
- }
-
- public void setTimeout(long timeout){
- this.timeout = timeout;
- }
+public class RequestInfo implements Serializable {
+
+ private static final long serialVersionUID = -759180997599143791L;
+
+ @JsonProperty("transactionId")
+ String transactionId;
+ @JsonProperty("requestId")
+ String requestId;
+ @JsonProperty("callbackUrl")
+ String callbackUrl;
+ @JsonProperty("sourceId")
+ String sourceId = "mso";
+ @JsonProperty("requestType")
+ String requestType;
+ @JsonProperty("timeout")
+ long timeout;
+
+ public String getTransactionId() {
+ return transactionId;
+ }
+
+ public void setTransactionId(String transactionId) {
+ this.transactionId = transactionId;
+ }
+
+ public String getRequestId() {
+ return requestId;
+ }
+
+ public void setRequestId(String requestId) {
+ this.requestId = requestId;
+ }
+
+ public String getCallbackUrl() {
+ return callbackUrl;
+ }
+
+ public void setCallbackUrl(String callbackUrl) {
+ this.callbackUrl = callbackUrl;
+ }
+
+ public String getSourceId() {
+ return sourceId;
+ }
+
+ public void setSourceId(String sourceId) {
+ this.sourceId = sourceId;
+ }
+
+ public String getRequestType() {
+ return requestType;
+ }
+
+ public void setRequestType(String requestType) {
+ this.requestType = requestType;
+ }
+
+ public long getTimeout() {
+ return timeout;
+ }
+
+ public void setTimeout(long timeout) {
+ this.timeout = timeout;
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/Resource.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/Resource.java
index 8441a01072..b5d40a8e80 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/Resource.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/Resource.java
@@ -21,34 +21,33 @@
package org.onap.so.client.sniro.beans;
import java.io.Serializable;
-
import com.fasterxml.jackson.annotation.JsonProperty;
-public class Resource implements Serializable{
+public class Resource implements Serializable {
- private static final long serialVersionUID = 5949861520571440421L;
+ private static final long serialVersionUID = 5949861520571440421L;
- @JsonProperty("service-resource-id")
- private String serviceResourceId;
- @JsonProperty("status")
- private String status;
+ @JsonProperty("service-resource-id")
+ private String serviceResourceId;
+ @JsonProperty("status")
+ private String status;
- public String getServiceResourceId(){
- return serviceResourceId;
- }
+ public String getServiceResourceId() {
+ return serviceResourceId;
+ }
- public void setServiceResourceId(String serviceResourceId){
- this.serviceResourceId = serviceResourceId;
- }
+ public void setServiceResourceId(String serviceResourceId) {
+ this.serviceResourceId = serviceResourceId;
+ }
- public String getStatus(){
- return status;
- }
+ public String getStatus() {
+ return status;
+ }
- public void setStatus(String status){
- this.status = status;
- }
+ public void setStatus(String status) {
+ this.status = status;
+ }
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/ServiceInfo.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/ServiceInfo.java
index f035013cd5..8b6f234c1e 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/ServiceInfo.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/ServiceInfo.java
@@ -21,62 +21,56 @@
package org.onap.so.client.sniro.beans;
import java.io.Serializable;
-
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonRootName;
-@JsonPropertyOrder({
- "modelInfo",
- "serviceRole",
- "serviceInstanceId",
- "serviceName"
-})
+@JsonPropertyOrder({"modelInfo", "serviceRole", "serviceInstanceId", "serviceName"})
@JsonRootName("serviceInfo")
-public class ServiceInfo implements Serializable{
+public class ServiceInfo implements Serializable {
- private static final long serialVersionUID = -6866022419398548585L;
+ private static final long serialVersionUID = -6866022419398548585L;
- @JsonProperty("serviceInstanceId")
- private String serviceInstanceId;
- @JsonProperty("serviceName")
- private String serviceName;
- @JsonProperty("serviceRole")
- private String serviceRole;
- @JsonProperty("modelInfo")
- private ModelInfo modelInfo;
+ @JsonProperty("serviceInstanceId")
+ private String serviceInstanceId;
+ @JsonProperty("serviceName")
+ private String serviceName;
+ @JsonProperty("serviceRole")
+ private String serviceRole;
+ @JsonProperty("modelInfo")
+ private ModelInfo modelInfo;
- public String getServiceInstanceId(){
- return serviceInstanceId;
- }
+ public String getServiceInstanceId() {
+ return serviceInstanceId;
+ }
- public void setServiceInstanceId(String serviceInstanceId){
- this.serviceInstanceId = serviceInstanceId;
- }
+ public void setServiceInstanceId(String serviceInstanceId) {
+ this.serviceInstanceId = serviceInstanceId;
+ }
- public String getServiceName(){
- return serviceName;
- }
+ public String getServiceName() {
+ return serviceName;
+ }
- public void setServiceName(String serviceName){
- this.serviceName = serviceName;
- }
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
- public String getServiceRole(){
- return serviceRole;
- }
+ public String getServiceRole() {
+ return serviceRole;
+ }
- public void setServiceRole(String serviceRole){
- this.serviceRole = serviceRole;
- }
+ public void setServiceRole(String serviceRole) {
+ this.serviceRole = serviceRole;
+ }
- public ModelInfo getModelInfo(){
- return modelInfo;
- }
+ public ModelInfo getModelInfo() {
+ return modelInfo;
+ }
- public void setModelInfo(ModelInfo modelInfo){
- this.modelInfo = modelInfo;
- }
+ public void setModelInfo(ModelInfo modelInfo) {
+ this.modelInfo = modelInfo;
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/SniroConductorRequest.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/SniroConductorRequest.java
index 11417d646c..f632424c26 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/SniroConductorRequest.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/SniroConductorRequest.java
@@ -25,7 +25,6 @@ package org.onap.so.client.sniro.beans;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
-
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
@@ -35,32 +34,32 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class SniroConductorRequest implements Serializable{
+public class SniroConductorRequest implements Serializable {
- private static final long serialVersionUID = 1906052095861777655L;
- private static final Logger logger = LoggerFactory.getLogger(SniroConductorRequest.class);
+ private static final long serialVersionUID = 1906052095861777655L;
+ private static final Logger logger = LoggerFactory.getLogger(SniroConductorRequest.class);
- @JsonProperty("release-locks")
- private List<Resource> resources = new ArrayList<Resource>();
+ @JsonProperty("release-locks")
+ private List<Resource> resources = new ArrayList<Resource>();
- public List<Resource> getResources(){
- return resources;
- }
+ public List<Resource> getResources() {
+ return resources;
+ }
- @JsonInclude(Include.NON_NULL)
- public String toJsonString(){
- String json = "";
- ObjectMapper mapper = new ObjectMapper();
- mapper.setSerializationInclusion(Include.NON_NULL);
- ObjectWriter ow = mapper.writer().withDefaultPrettyPrinter();
- try{
- json = ow.writeValueAsString(this);
- }catch (Exception e){
- logger.error("Unable to convert SniroConductorRequest to string", e);
- }
- return json;
- }
+ @JsonInclude(Include.NON_NULL)
+ public String toJsonString() {
+ String json = "";
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.setSerializationInclusion(Include.NON_NULL);
+ ObjectWriter ow = mapper.writer().withDefaultPrettyPrinter();
+ try {
+ json = ow.writeValueAsString(this);
+ } catch (Exception e) {
+ logger.error("Unable to convert SniroConductorRequest to string", e);
+ }
+ return json;
+ }
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/SniroManagerRequest.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/SniroManagerRequest.java
index c1e376814f..4babbe5c39 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/SniroManagerRequest.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/SniroManagerRequest.java
@@ -23,7 +23,6 @@
package org.onap.so.client.sniro.beans;
import java.io.Serializable;
-
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
@@ -33,60 +32,67 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class SniroManagerRequest implements Serializable{
-
- private static final long serialVersionUID = -1541132882892163132L;
- private static final Logger logger = LoggerFactory.getLogger(SniroManagerRequest.class);
-
- @JsonProperty("requestInfo")
- private RequestInfo requestInformation;
- @JsonProperty("serviceInfo")
- private ServiceInfo serviceInformation;
- @JsonProperty("placementInfo")
- private PlacementInfo placementInformation;
- @JsonProperty("licenseInfo")
- private LicenseInfo licenseInformation;
-
-
- public RequestInfo getRequestInformation() {
- return requestInformation;
- }
- public void setRequestInformation(RequestInfo requestInformation) {
- this.requestInformation = requestInformation;
- }
- public ServiceInfo getServiceInformation() {
- return serviceInformation;
- }
- public void setServiceInformation(ServiceInfo serviceInformation) {
- this.serviceInformation = serviceInformation;
- }
- public PlacementInfo getPlacementInformation() {
- return placementInformation;
- }
- public void setPlacementInformation(PlacementInfo placementInformation) {
- this.placementInformation = placementInformation;
- }
- public LicenseInfo getLicenseInformation() {
- return licenseInformation;
- }
- public void setLicenseInformation(LicenseInfo licenseInformation) {
- this.licenseInformation = licenseInformation;
- }
-
-
- @JsonInclude(Include.NON_NULL)
- public String toJsonString(){
- String json = "";
- ObjectMapper mapper = new ObjectMapper();
- mapper.setSerializationInclusion(Include.NON_NULL);
- ObjectWriter ow = mapper.writer().withDefaultPrettyPrinter();
- try{
- json = ow.writeValueAsString(this);
- }catch (Exception e){
- logger.error("Unable to convert SniroManagerRequest to string", e);
- }
- return json.replaceAll("\\\\", "");
- }
+public class SniroManagerRequest implements Serializable {
+
+ private static final long serialVersionUID = -1541132882892163132L;
+ private static final Logger logger = LoggerFactory.getLogger(SniroManagerRequest.class);
+
+ @JsonProperty("requestInfo")
+ private RequestInfo requestInformation;
+ @JsonProperty("serviceInfo")
+ private ServiceInfo serviceInformation;
+ @JsonProperty("placementInfo")
+ private PlacementInfo placementInformation;
+ @JsonProperty("licenseInfo")
+ private LicenseInfo licenseInformation;
+
+
+ public RequestInfo getRequestInformation() {
+ return requestInformation;
+ }
+
+ public void setRequestInformation(RequestInfo requestInformation) {
+ this.requestInformation = requestInformation;
+ }
+
+ public ServiceInfo getServiceInformation() {
+ return serviceInformation;
+ }
+
+ public void setServiceInformation(ServiceInfo serviceInformation) {
+ this.serviceInformation = serviceInformation;
+ }
+
+ public PlacementInfo getPlacementInformation() {
+ return placementInformation;
+ }
+
+ public void setPlacementInformation(PlacementInfo placementInformation) {
+ this.placementInformation = placementInformation;
+ }
+
+ public LicenseInfo getLicenseInformation() {
+ return licenseInformation;
+ }
+
+ public void setLicenseInformation(LicenseInfo licenseInformation) {
+ this.licenseInformation = licenseInformation;
+ }
+
+
+ @JsonInclude(Include.NON_NULL)
+ public String toJsonString() {
+ String json = "";
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.setSerializationInclusion(Include.NON_NULL);
+ ObjectWriter ow = mapper.writer().withDefaultPrettyPrinter();
+ try {
+ json = ow.writeValueAsString(this);
+ } catch (Exception e) {
+ logger.error("Unable to convert SniroManagerRequest to string", e);
+ }
+ return json.replaceAll("\\\\", "");
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/SubscriberInfo.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/SubscriberInfo.java
index b6b09cbf80..eaf8b6e379 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/SubscriberInfo.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/SubscriberInfo.java
@@ -21,46 +21,45 @@
package org.onap.so.client.sniro.beans;
import java.io.Serializable;
-
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRawValue;
import com.fasterxml.jackson.annotation.JsonRootName;
@JsonRootName("subscriberInfo")
-public class SubscriberInfo implements Serializable{
+public class SubscriberInfo implements Serializable {
- private static final long serialVersionUID = -6350949051379748872L;
+ private static final long serialVersionUID = -6350949051379748872L;
- @JsonProperty("globalSubscriberId")
- private String globalSubscriberId;
- @JsonProperty("subscriberName")
- private String subscriberName;
- @JsonProperty("subscriberCommonSiteId")
- private String subscriberCommonSiteId;
+ @JsonProperty("globalSubscriberId")
+ private String globalSubscriberId;
+ @JsonProperty("subscriberName")
+ private String subscriberName;
+ @JsonProperty("subscriberCommonSiteId")
+ private String subscriberCommonSiteId;
- public String getGlobalSubscriberId(){
- return globalSubscriberId;
- }
+ public String getGlobalSubscriberId() {
+ return globalSubscriberId;
+ }
- public void setGlobalSubscriberId(String globalSubscriberId){
- this.globalSubscriberId = globalSubscriberId;
- }
+ public void setGlobalSubscriberId(String globalSubscriberId) {
+ this.globalSubscriberId = globalSubscriberId;
+ }
- public String getSubscriberName(){
- return subscriberName;
- }
+ public String getSubscriberName() {
+ return subscriberName;
+ }
- public void setSubscriberName(String subscriberName){
- this.subscriberName = subscriberName;
- }
+ public void setSubscriberName(String subscriberName) {
+ this.subscriberName = subscriberName;
+ }
- public String getSubscriberCommonSiteId(){
- return subscriberCommonSiteId;
- }
+ public String getSubscriberCommonSiteId() {
+ return subscriberCommonSiteId;
+ }
- public void setSubscriberCommonSiteId(String subscriberCommonSiteId){
- this.subscriberCommonSiteId = subscriberCommonSiteId;
- }
+ public void setSubscriberCommonSiteId(String subscriberCommonSiteId) {
+ this.subscriberCommonSiteId = subscriberCommonSiteId;
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/ticket/ExternalTicket.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/ticket/ExternalTicket.java
index 519afe6f2d..a78dffb4e0 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/ticket/ExternalTicket.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/ticket/ExternalTicket.java
@@ -1,155 +1,154 @@
package org.onap.so.client.ticket;
public class ExternalTicket {
- private String requestId;
- private String nfRole;
- private String currentActivity;
- private String description;
- private String subscriptionServiceType;
- private String requestorId;
- private String timeout;
- private String errorSource;
- private String errorCode;
- private String errorMessage;
- private String workStep;
+ private String requestId;
+ private String nfRole;
+ private String currentActivity;
+ private String description;
+ private String subscriptionServiceType;
+ private String requestorId;
+ private String timeout;
+ private String errorSource;
+ private String errorCode;
+ private String errorMessage;
+ private String workStep;
- public String getRequestId() {
- return requestId;
- }
+ public String getRequestId() {
+ return requestId;
+ }
- public void setRequestId(String requestId) {
- this.requestId = requestId;
- }
+ public void setRequestId(String requestId) {
+ this.requestId = requestId;
+ }
- public String getNfRole() {
- return nfRole;
- }
+ public String getNfRole() {
+ return nfRole;
+ }
- public void setNfRole(String nfRole) {
- this.nfRole = nfRole;
- }
+ public void setNfRole(String nfRole) {
+ this.nfRole = nfRole;
+ }
- public String getCurrentActivity() {
- return currentActivity;
- }
+ public String getCurrentActivity() {
+ return currentActivity;
+ }
- public void setCurrentActivity(String currentActivity) {
- this.currentActivity = currentActivity;
- }
+ public void setCurrentActivity(String currentActivity) {
+ this.currentActivity = currentActivity;
+ }
- public String getDescription() {
- return description;
- }
+ public String getDescription() {
+ return description;
+ }
- public void setDescription(String description) {
- this.description = description;
- }
+ public void setDescription(String description) {
+ this.description = description;
+ }
- public String getSubscriptionServiceType() {
- return subscriptionServiceType;
- }
+ public String getSubscriptionServiceType() {
+ return subscriptionServiceType;
+ }
- public void setSubscriptionServiceType(String subscriptionServiceType) {
- this.subscriptionServiceType = subscriptionServiceType;
- }
+ public void setSubscriptionServiceType(String subscriptionServiceType) {
+ this.subscriptionServiceType = subscriptionServiceType;
+ }
- public String getRequestorId() {
- return requestorId;
- }
+ public String getRequestorId() {
+ return requestorId;
+ }
- public void setRequestorId(String requestorId) {
- this.requestorId = requestorId;
- }
+ public void setRequestorId(String requestorId) {
+ this.requestorId = requestorId;
+ }
- public String getTimeout() {
- return timeout;
- }
+ public String getTimeout() {
+ return timeout;
+ }
- public void setTimeout(String timeout) {
- this.timeout = timeout;
- }
+ public void setTimeout(String timeout) {
+ this.timeout = timeout;
+ }
- public String getErrorSource() {
- return errorSource;
- }
+ public String getErrorSource() {
+ return errorSource;
+ }
- public void setErrorSource(String errorSource) {
- this.errorSource = errorSource;
- }
+ public void setErrorSource(String errorSource) {
+ this.errorSource = errorSource;
+ }
- public String getErrorCode() {
- return errorCode;
- }
+ public String getErrorCode() {
+ return errorCode;
+ }
- public void setErrorCode(String errorCode) {
- this.errorCode = errorCode;
- }
+ public void setErrorCode(String errorCode) {
+ this.errorCode = errorCode;
+ }
- public String getErrorMessage() {
- return errorMessage;
- }
+ public String getErrorMessage() {
+ return errorMessage;
+ }
- public void setErrorMessage(String errorMessage) {
- this.errorMessage = errorMessage;
- }
+ public void setErrorMessage(String errorMessage) {
+ this.errorMessage = errorMessage;
+ }
- public String getWorkStep() {
- return workStep;
- }
+ public String getWorkStep() {
+ return workStep;
+ }
- public void setWorkStep(String workStep) {
- this.workStep = workStep;
- }
+ public void setWorkStep(String workStep) {
+ this.workStep = workStep;
+ }
- public void createTicket() throws Exception {
- //Replace with your ticket creation mechanism if any
- }
-
-
-
+ public void createTicket() throws Exception {
+ // Replace with your ticket creation mechanism if any
+ }
+
+
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/AllIntegrationTestSuites.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/AllIntegrationTestSuites.java
index 23fcddfe8a..c5cdae4425 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/AllIntegrationTestSuites.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/AllIntegrationTestSuites.java
@@ -21,12 +21,11 @@
package org.onap.so;
import org.junit.runner.RunWith;
-
import com.googlecode.junittoolbox.SuiteClasses;
import com.googlecode.junittoolbox.WildcardPatternSuite;
@RunWith(WildcardPatternSuite.class)
@SuiteClasses({"**/SniroHomingV2IT.class"})
-public class AllIntegrationTestSuites{
+public class AllIntegrationTestSuites {
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/BaseIntegrationTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/BaseIntegrationTest.java
index aefe4c64bf..3bb8fb70f2 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/BaseIntegrationTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/BaseIntegrationTest.java
@@ -21,7 +21,6 @@ package org.onap.so;
import java.io.IOException;
import java.io.InputStream;
-
import org.junit.Before;
import org.junit.runner.RunWith;
import org.onap.so.bpmn.buildingblock.SniroHomingV2;
@@ -40,7 +39,6 @@ import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
-
import com.github.tomakehurst.wiremock.WireMockServer;
@RunWith(SpringRunner.class)
@@ -50,60 +48,60 @@ import com.github.tomakehurst.wiremock.WireMockServer;
@AutoConfigureWireMock(port = 0)
public abstract class BaseIntegrationTest extends TestDataSetup {
- @Value("${wiremock.server.port}")
- protected String wireMockPort;
+ @Value("${wiremock.server.port}")
+ protected String wireMockPort;
+
+ @SpyBean
+ protected SDNCClient SPY_sdncClient;
+
+ @SpyBean
+ protected SDNOHealthCheckResources MOCK_sdnoHealthCheckResources;
- @SpyBean
- protected SDNCClient SPY_sdncClient;
+ @SpyBean
+ protected SniroHomingV2 sniroHoming;
- @SpyBean
- protected SDNOHealthCheckResources MOCK_sdnoHealthCheckResources;
+ @SpyBean
+ protected SniroClient sniroClient;
- @SpyBean
- protected SniroHomingV2 sniroHoming;
+ @MockBean
+ protected ApplicationControllerAction appCClient;
- @SpyBean
- protected SniroClient sniroClient;
+ @MockBean
+ protected CatalogDbClient catalogDbClient;
- @MockBean
- protected ApplicationControllerAction appCClient;
+ @Autowired
+ protected WireMockServer wireMockServer;
- @MockBean
- protected CatalogDbClient catalogDbClient;
-
- @Autowired
- protected WireMockServer wireMockServer;
+ @Before
+ public void baseTestBefore() {
+ wireMockServer.resetAll();
+ }
- @Before
- public void baseTestBefore() {
- wireMockServer.resetAll();
- }
- public String readResourceFile(String fileName) {
- InputStream stream;
- try {
- stream = getResourceAsStream(fileName);
- byte[] bytes;
- bytes = new byte[stream.available()];
- if(stream.read(bytes) > 0) {
- stream.close();
- return new String(bytes);
- } else {
- stream.close();
- return "";
- }
- } catch (IOException e) {
- return "";
- }
- }
+ public String readResourceFile(String fileName) {
+ InputStream stream;
+ try {
+ stream = getResourceAsStream(fileName);
+ byte[] bytes;
+ bytes = new byte[stream.available()];
+ if (stream.read(bytes) > 0) {
+ stream.close();
+ return new String(bytes);
+ } else {
+ stream.close();
+ return "";
+ }
+ } catch (IOException e) {
+ return "";
+ }
+ }
- private InputStream getResourceAsStream(String resourceName) throws IOException {
- InputStream stream =
- FileUtil.class.getClassLoader().getResourceAsStream(resourceName);
- if (stream == null) {
- throw new IOException("Can't access resource '" + resourceName + "'");
- }
- return stream;
- }
+ private InputStream getResourceAsStream(String resourceName) throws IOException {
+ InputStream stream = FileUtil.class.getClassLoader().getResourceAsStream(resourceName);
+ if (stream == null) {
+ throw new IOException("Can't access resource '" + resourceName + "'");
+ }
+ return stream;
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java
index fb08e5e830..62d9ecee44 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java
@@ -19,6 +19,7 @@
*/
package org.onap.so;
+
import ch.vorburger.exec.ManagedProcessException;
import ch.vorburger.mariadb4j.DBConfigurationBuilder;
import ch.vorburger.mariadb4j.springframework.MariaDB4jSpringService;
@@ -35,30 +36,25 @@ public class EmbeddedMariaDbConfig {
@Bean
MariaDB4jSpringService mariaDB4jSpringService() {
- MariaDB4jSpringService service = new MariaDB4jSpringService();
-
-
- service.getConfiguration().addArg("--lower_case_table_names=1");
+ MariaDB4jSpringService service = new MariaDB4jSpringService();
+
+
+ service.getConfiguration().addArg("--lower_case_table_names=1");
return service;
}
@Bean
DataSource dataSource(MariaDB4jSpringService mariaDB4jSpringService,
- @Value("${mariaDB4j.databaseName}") String databaseName,
- @Value("${spring.datasource.username}") String datasourceUsername,
- @Value("${spring.datasource.password}") String datasourcePassword,
- @Value("${spring.datasource.driver-class-name}") String datasourceDriver) throws ManagedProcessException {
- //Create our database with default root user and no password
+ @Value("${mariaDB4j.databaseName}") String databaseName,
+ @Value("${spring.datasource.username}") String datasourceUsername,
+ @Value("${spring.datasource.password}") String datasourcePassword,
+ @Value("${spring.datasource.driver-class-name}") String datasourceDriver) throws ManagedProcessException {
+ // Create our database with default root user and no password
mariaDB4jSpringService.getDB().createDB(databaseName);
DBConfigurationBuilder config = mariaDB4jSpringService.getConfiguration();
- return DataSourceBuilder
- .create()
- .username(datasourceUsername)
- .password(datasourcePassword)
- .url(config.getURL(databaseName))
- .driverClassName(datasourceDriver)
- .build();
+ return DataSourceBuilder.create().username(datasourceUsername).password(datasourcePassword)
+ .url(config.getURL(databaseName)).driverClassName(datasourceDriver).build();
}
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/FileUtil.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/FileUtil.java
index 366c9c11a9..24927b0d1c 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/FileUtil.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/FileUtil.java
@@ -34,51 +34,50 @@ import org.slf4j.LoggerFactory;
* </p>
*
* @author
- * @version ONAP Sep 15, 2017
+ * @version ONAP Sep 15, 2017
*/
public class FileUtil {
private static final Logger logger = LoggerFactory.getLogger(FileUtil.class);
-
- /**
- * Read the specified resource file and return the contents as a String.
- *
- * @param fileName Name of the resource file
- * @return the contents of the resource file as a String
- * @throws IOException if there is a problem reading the file
- */
- public static String readResourceFile(String fileName) {
- InputStream stream;
- try {
- stream = getResourceAsStream(fileName);
- byte[] bytes;
- bytes = new byte[stream.available()];
- if(stream.read(bytes) > 0) {
- stream.close();
- return new String(bytes);
- } else {
- stream.close();
- return "";
- }
- } catch (IOException e) {
- logger.debug("Exception:", e);
- return "";
- }
- }
-
- /**
- * Get an InputStream for the resource specified.
- *
- * @param resourceName Name of resource for which to get InputStream.
- * @return an InputStream for the resource specified.
- * @throws IOException If we can't get the InputStream for whatever reason.
- */
- private static InputStream getResourceAsStream(String resourceName) throws IOException {
- InputStream stream =
- FileUtil.class.getClassLoader().getResourceAsStream(resourceName);
- if (stream == null) {
- throw new IOException("Can't access resource '" + resourceName + "'");
- }
- return stream;
- }
+
+ /**
+ * Read the specified resource file and return the contents as a String.
+ *
+ * @param fileName Name of the resource file
+ * @return the contents of the resource file as a String
+ * @throws IOException if there is a problem reading the file
+ */
+ public static String readResourceFile(String fileName) {
+ InputStream stream;
+ try {
+ stream = getResourceAsStream(fileName);
+ byte[] bytes;
+ bytes = new byte[stream.available()];
+ if (stream.read(bytes) > 0) {
+ stream.close();
+ return new String(bytes);
+ } else {
+ stream.close();
+ return "";
+ }
+ } catch (IOException e) {
+ logger.debug("Exception:", e);
+ return "";
+ }
+ }
+
+ /**
+ * Get an InputStream for the resource specified.
+ *
+ * @param resourceName Name of resource for which to get InputStream.
+ * @return an InputStream for the resource specified.
+ * @throws IOException If we can't get the InputStream for whatever reason.
+ */
+ private static InputStream getResourceAsStream(String resourceName) throws IOException {
+ InputStream stream = FileUtil.class.getClassLoader().getResourceAsStream(resourceName);
+ if (stream == null) {
+ throw new IOException("Can't access resource '" + resourceName + "'");
+ }
+ return stream;
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/IntegrationTestSuite.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/IntegrationTestSuite.java
index 0eddeb1649..50bbc1845f 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/IntegrationTestSuite.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/IntegrationTestSuite.java
@@ -21,7 +21,6 @@
package org.onap.so;
import org.junit.runner.RunWith;
-
import com.googlecode.junittoolbox.SuiteClasses;
import com.googlecode.junittoolbox.WildcardPatternSuite;
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/TestApplication.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/TestApplication.java
index 87153144c8..2e27b346ea 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/TestApplication.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/TestApplication.java
@@ -31,14 +31,14 @@ import org.springframework.context.annotation.Profile;
@SpringBootApplication
@Profile("test")
-@ComponentScan(basePackages = {"org.onap.so"}, nameGenerator = DefaultToShortClassNameBeanNameGenerator.class, excludeFilters = {
- @Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class)})
+@ComponentScan(basePackages = {"org.onap.so"}, nameGenerator = DefaultToShortClassNameBeanNameGenerator.class,
+ excludeFilters = {@Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class)})
public class TestApplication {
- public static void main(String... args) {
- SpringApplication.run(TestApplication.class, args);
- System.getProperties().setProperty("mso.db", "MARIADB");
- System.getProperties().setProperty("server.name", "Springboot");
-
-
- }
+ public static void main(String... args) {
+ SpringApplication.run(TestApplication.class, args);
+ System.getProperties().setProperty("mso.db", "MARIADB");
+ System.getProperties().setProperty("server.name", "Springboot");
+
+
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/UnitTestSuite.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/UnitTestSuite.java
index 82ad6582c5..890c81daeb 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/UnitTestSuite.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/UnitTestSuite.java
@@ -22,7 +22,6 @@ package org.onap.so;
import org.junit.runner.RunWith;
-
import com.googlecode.junittoolbox.SuiteClasses;
import com.googlecode.junittoolbox.WildcardPatternSuite;
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java
index 6dc0b1861d..b40e43b959 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java
@@ -58,96 +58,96 @@ import org.springframework.core.env.Environment;
@RunWith(MockitoJUnitRunner.Silent.class)
public abstract class BaseTaskTest extends TestDataSetup {
- @Mock
- protected AAIVolumeGroupResources aaiVolumeGroupResources;
+ @Mock
+ protected AAIVolumeGroupResources aaiVolumeGroupResources;
- @Mock
- protected AAIServiceInstanceResources aaiServiceInstanceResources;
+ @Mock
+ protected AAIServiceInstanceResources aaiServiceInstanceResources;
- @Mock
- protected AAIVnfResources aaiVnfResources;
+ @Mock
+ protected AAIVnfResources aaiVnfResources;
- @Mock
- protected AAIVfModuleResources aaiVfModuleResources;
+ @Mock
+ protected AAIVfModuleResources aaiVfModuleResources;
- @Mock
- protected AAIVpnBindingResources aaiVpnBindingResources;
+ @Mock
+ protected AAIVpnBindingResources aaiVpnBindingResources;
- @Mock
- protected AAINetworkResources aaiNetworkResources;
+ @Mock
+ protected AAINetworkResources aaiNetworkResources;
- @Mock
- protected AAICollectionResources aaiCollectionResources;
+ @Mock
+ protected AAICollectionResources aaiCollectionResources;
- @Mock
- protected NetworkAdapterResources networkAdapterResources;
+ @Mock
+ protected NetworkAdapterResources networkAdapterResources;
- @Mock
- protected VnfAdapterVolumeGroupResources vnfAdapterVolumeGroupResources;
+ @Mock
+ protected VnfAdapterVolumeGroupResources vnfAdapterVolumeGroupResources;
- @Mock
- protected VnfAdapterVfModuleResources vnfAdapterVfModuleResources;
+ @Mock
+ protected VnfAdapterVfModuleResources vnfAdapterVfModuleResources;
- @Mock
- protected SDNCVnfResources sdncVnfResources;
+ @Mock
+ protected SDNCVnfResources sdncVnfResources;
- @Mock
- protected SDNCNetworkResources sdncNetworkResources;
+ @Mock
+ protected SDNCNetworkResources sdncNetworkResources;
- @Mock
- protected SDNCVfModuleResources sdncVfModuleResources;
+ @Mock
+ protected SDNCVfModuleResources sdncVfModuleResources;
- @Mock
- protected SDNCServiceInstanceResources sdncServiceInstanceResources;
+ @Mock
+ protected SDNCServiceInstanceResources sdncServiceInstanceResources;
- @Mock
- protected AssignNetworkBBUtils assignNetworkBBUtils;
+ @Mock
+ protected AssignNetworkBBUtils assignNetworkBBUtils;
- @Mock
- protected NetworkAdapterObjectMapper networkAdapterObjectMapper;
+ @Mock
+ protected NetworkAdapterObjectMapper networkAdapterObjectMapper;
- @Mock
- protected AAIInstanceGroupResources aaiInstanceGroupResources;
-
- @Mock
- protected NamingServiceResources namingServiceResources;
+ @Mock
+ protected AAIInstanceGroupResources aaiInstanceGroupResources;
- @Mock
- protected ApplicationControllerAction appCClient;
+ @Mock
+ protected NamingServiceResources namingServiceResources;
- @Mock
- protected CatalogDbClient catalogDbClient;
+ @Mock
+ protected ApplicationControllerAction appCClient;
- @Mock
- protected RequestsDbClient requestsDbClient;
+ @Mock
+ protected CatalogDbClient catalogDbClient;
- @Mock
- protected BBInputSetupUtils bbSetupUtils;
+ @Mock
+ protected RequestsDbClient requestsDbClient;
- @Mock
- protected BBInputSetup bbInputSetup;
+ @Mock
+ protected BBInputSetupUtils bbSetupUtils;
- @Mock
- protected AAIConfigurationResources aaiConfigurationResources;
+ @Mock
+ protected BBInputSetup bbInputSetup;
- @Mock
- protected AAIObjectMapper MOCK_aaiObjectMapper;
+ @Mock
+ protected AAIConfigurationResources aaiConfigurationResources;
- @Mock
- protected InjectionHelper MOCK_injectionHelper;
+ @Mock
+ protected AAIObjectMapper MOCK_aaiObjectMapper;
- @Mock
- protected AAIResourcesClient MOCK_aaiResourcesClient;
+ @Mock
+ protected InjectionHelper MOCK_injectionHelper;
- @Mock
- protected ExtractPojosForBB extractPojosForBB;
+ @Mock
+ protected AAIResourcesClient MOCK_aaiResourcesClient;
- @Mock
- protected ExceptionBuilder exceptionUtil;
+ @Mock
+ protected ExtractPojosForBB extractPojosForBB;
- @Mock
- protected WorkflowActionExtractResourcesAAI workflowActionUtils;
-
- @Mock
- protected Environment env;
+ @Mock
+ protected ExceptionBuilder exceptionUtil;
+
+ @Mock
+ protected WorkflowActionExtractResourcesAAI workflowActionUtils;
+
+ @Mock
+ protected Environment env;
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/aai/tasks/AAIFlagTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/aai/tasks/AAIFlagTasksTest.java
index a91ef66a29..95689e49cd 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/aai/tasks/AAIFlagTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/aai/tasks/AAIFlagTasksTest.java
@@ -28,9 +28,7 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import java.io.IOException;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
@@ -56,154 +54,173 @@ import org.springframework.beans.factory.annotation.Autowired;
public class AAIFlagTasksTest extends BaseTaskTest {
- @InjectMocks
- private AAIFlagTasks aaiFlagTasks = new AAIFlagTasks();
-
- private GenericVnf genericVnf;
-
- @Before
- public void before() throws BBObjectNotFoundException {
- genericVnf = setGenericVnf();
- doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
- when(extractPojosForBB.extractByKey(any(),any())).thenReturn(genericVnf);
- }
-
- @Test
- public void checkVnfInMaintTestTrue() throws Exception {
- doThrow(new BpmnError("VNF is in maintenance in A&AI")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
- doReturn(false).when(aaiVnfResources).checkInMaintFlag(isA(String.class));
- doReturn(true).when(aaiVnfResources).checkInMaintFlag(isA(String.class));
- try {
- aaiFlagTasks.checkVnfInMaintFlag(execution);
- } catch (Exception e) {
- verify(aaiVnfResources, times(1)).checkInMaintFlag(any(String.class));
- verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), eq("VNF is in maintenance in A&AI"));
- }
- }
-
- @Test
- public void checkVnfInMaintTestFalse() throws Exception {
- doReturn(false).when(aaiVnfResources).checkInMaintFlag(isA(String.class));
- aaiFlagTasks.checkVnfInMaintFlag(execution);
- verify(exceptionUtil, times(0)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), any(int.class), any(String.class));
- }
-
- @Test
- public void checkVnfInMaintFlagExceptionTest() {
-
- doThrow(new BpmnError("Unknown Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
- doThrow(RuntimeException.class).when(aaiVnfResources).checkInMaintFlag(isA(String.class));
- try {
- aaiFlagTasks.checkVnfInMaintFlag(execution);
- } catch (Exception e) {
- verify(aaiVnfResources, times(1)).checkInMaintFlag(any(String.class));
- verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
- }
-
- }
-
- @Test
- public void modifyVnfInMaintFlagTest() throws Exception {
- doNothing().when(aaiVnfResources).updateObjectVnf(ArgumentMatchers.any(GenericVnf.class));
- aaiFlagTasks.modifyVnfInMaintFlag(execution, true);
- verify(aaiVnfResources, times(1)).updateObjectVnf(ArgumentMatchers.any(GenericVnf.class));
- }
-
- @Test
- public void modifyVnfInMaintFlagExceptionTest() {
-
- doThrow(new BpmnError("Unknown Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
- doThrow(RuntimeException.class).when(aaiVnfResources).updateObjectVnf(isA(GenericVnf.class));
- try {
- aaiFlagTasks.modifyVnfInMaintFlag(execution, true);
- } catch (Exception e) {
- verify(aaiVnfResources, times(1)).checkInMaintFlag(any(String.class));
- verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
- }
- }
-
- @Test
- public void checkVnfClosedLoopDisabledTestTrue() throws Exception {
- doThrow(new BpmnError("VNF Closed Loop Disabled in A&AI")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
- doReturn(false).when(aaiVnfResources).checkVnfClosedLoopDisabledFlag(isA(String.class));
- try {
- aaiFlagTasks.checkVnfClosedLoopDisabledFlag(execution);
- } catch (Exception e) {
- verify(aaiVnfResources, times(1)).checkVnfClosedLoopDisabledFlag(any(String.class));
- verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), eq("VNF Closed Loop Disabled in A&AI"));
- }
- }
-
- @Test
- public void checkVnfClosedLoopDisabledTestFalse() throws Exception {
- doReturn(false).when(aaiVnfResources).checkVnfClosedLoopDisabledFlag(isA(String.class));
- aaiFlagTasks.checkVnfClosedLoopDisabledFlag(execution);
- verify(exceptionUtil, times(0)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), any(int.class), any(String.class));
- }
-
- @Test
- public void checkVnfClosedLoopDisabledFlagExceptionTest() {
-
- doThrow(new BpmnError("Unknown Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
- doThrow(RuntimeException.class).when(aaiVnfResources).checkVnfClosedLoopDisabledFlag(isA(String.class));
- try {
- aaiFlagTasks.checkVnfClosedLoopDisabledFlag(execution);
- } catch (Exception e) {
- verify(aaiVnfResources, times(1)).checkVnfClosedLoopDisabledFlag(any(String.class));
- verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
- }
- }
-
- @Test
- public void modifyVnfClosedLoopDisabledFlagTest() throws Exception {
- doNothing().when(aaiVnfResources).updateObjectVnf(ArgumentMatchers.any(GenericVnf.class));
- aaiFlagTasks.modifyVnfClosedLoopDisabledFlag(execution, true);
- verify(aaiVnfResources, times(1)).updateObjectVnf(ArgumentMatchers.any(GenericVnf.class));
- }
-
- @Test
- public void modifyVnfClosedLoopDisabledFlagExceptionTest() {
-
- doThrow(new BpmnError("Unknown Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
- doThrow(RuntimeException.class).when(aaiVnfResources).updateObjectVnf(isA(GenericVnf.class));
- try {
- aaiFlagTasks.modifyVnfClosedLoopDisabledFlag(execution, true);
- } catch (Exception e) {
- verify(aaiVnfResources, times(1)).checkVnfClosedLoopDisabledFlag(any(String.class));
- verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
- }
- }
-
-
- @Test
- public void checkVnfPserversLockedFlagTestTrue() throws Exception {
- doThrow(new BpmnError("VNF PServers in Locked in A&AI")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
- doReturn(true).when(aaiVnfResources).checkVnfPserversLockedFlag(isA(String.class));
- try {
- aaiFlagTasks.checkVnfClosedLoopDisabledFlag(execution);
- } catch (Exception e) {
- verify(aaiVnfResources, times(1)).checkVnfPserversLockedFlag(any(String.class));
- verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), eq("VNF PServers in Locked in A&AI"));
- }
- }
-
- @Test
- public void checkVnfPserversLockedFlagTestFalse() throws Exception {
- doReturn(false).when(aaiVnfResources).checkVnfPserversLockedFlag(isA(String.class));
- aaiFlagTasks.checkVnfPserversLockedFlag(execution);
- verify(exceptionUtil, times(0)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), any(int.class), any(String.class));
- }
-
- @Test
- public void checkVnfPserversLockedFlagExceptionTest() throws IOException {
-
- doThrow(new BpmnError("Unknown Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
- doThrow(RuntimeException.class).when(aaiVnfResources).checkVnfClosedLoopDisabledFlag(isA(String.class));
- try {
- aaiFlagTasks.checkVnfPserversLockedFlag(execution);
- } catch (Exception e) {
- verify(aaiVnfResources, times(1)).checkVnfPserversLockedFlag(any(String.class));
- verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
- }
- }
+ @InjectMocks
+ private AAIFlagTasks aaiFlagTasks = new AAIFlagTasks();
+
+ private GenericVnf genericVnf;
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ genericVnf = setGenericVnf();
+ doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
+ when(extractPojosForBB.extractByKey(any(), any())).thenReturn(genericVnf);
+ }
+
+ @Test
+ public void checkVnfInMaintTestTrue() throws Exception {
+ doThrow(new BpmnError("VNF is in maintenance in A&AI")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
+ doReturn(false).when(aaiVnfResources).checkInMaintFlag(isA(String.class));
+ doReturn(true).when(aaiVnfResources).checkInMaintFlag(isA(String.class));
+ try {
+ aaiFlagTasks.checkVnfInMaintFlag(execution);
+ } catch (Exception e) {
+ verify(aaiVnfResources, times(1)).checkInMaintFlag(any(String.class));
+ verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000),
+ eq("VNF is in maintenance in A&AI"));
+ }
+ }
+
+ @Test
+ public void checkVnfInMaintTestFalse() throws Exception {
+ doReturn(false).when(aaiVnfResources).checkInMaintFlag(isA(String.class));
+ aaiFlagTasks.checkVnfInMaintFlag(execution);
+ verify(exceptionUtil, times(0)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class),
+ any(int.class), any(String.class));
+ }
+
+ @Test
+ public void checkVnfInMaintFlagExceptionTest() {
+
+ doThrow(new BpmnError("Unknown Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
+ doThrow(RuntimeException.class).when(aaiVnfResources).checkInMaintFlag(isA(String.class));
+ try {
+ aaiFlagTasks.checkVnfInMaintFlag(execution);
+ } catch (Exception e) {
+ verify(aaiVnfResources, times(1)).checkInMaintFlag(any(String.class));
+ verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000),
+ any(String.class));
+ }
+
+ }
+
+ @Test
+ public void modifyVnfInMaintFlagTest() throws Exception {
+ doNothing().when(aaiVnfResources).updateObjectVnf(ArgumentMatchers.any(GenericVnf.class));
+ aaiFlagTasks.modifyVnfInMaintFlag(execution, true);
+ verify(aaiVnfResources, times(1)).updateObjectVnf(ArgumentMatchers.any(GenericVnf.class));
+ }
+
+ @Test
+ public void modifyVnfInMaintFlagExceptionTest() {
+
+ doThrow(new BpmnError("Unknown Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
+ doThrow(RuntimeException.class).when(aaiVnfResources).updateObjectVnf(isA(GenericVnf.class));
+ try {
+ aaiFlagTasks.modifyVnfInMaintFlag(execution, true);
+ } catch (Exception e) {
+ verify(aaiVnfResources, times(1)).checkInMaintFlag(any(String.class));
+ verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000),
+ any(String.class));
+ }
+ }
+
+ @Test
+ public void checkVnfClosedLoopDisabledTestTrue() throws Exception {
+ doThrow(new BpmnError("VNF Closed Loop Disabled in A&AI")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
+ doReturn(false).when(aaiVnfResources).checkVnfClosedLoopDisabledFlag(isA(String.class));
+ try {
+ aaiFlagTasks.checkVnfClosedLoopDisabledFlag(execution);
+ } catch (Exception e) {
+ verify(aaiVnfResources, times(1)).checkVnfClosedLoopDisabledFlag(any(String.class));
+ verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000),
+ eq("VNF Closed Loop Disabled in A&AI"));
+ }
+ }
+
+ @Test
+ public void checkVnfClosedLoopDisabledTestFalse() throws Exception {
+ doReturn(false).when(aaiVnfResources).checkVnfClosedLoopDisabledFlag(isA(String.class));
+ aaiFlagTasks.checkVnfClosedLoopDisabledFlag(execution);
+ verify(exceptionUtil, times(0)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class),
+ any(int.class), any(String.class));
+ }
+
+ @Test
+ public void checkVnfClosedLoopDisabledFlagExceptionTest() {
+
+ doThrow(new BpmnError("Unknown Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
+ doThrow(RuntimeException.class).when(aaiVnfResources).checkVnfClosedLoopDisabledFlag(isA(String.class));
+ try {
+ aaiFlagTasks.checkVnfClosedLoopDisabledFlag(execution);
+ } catch (Exception e) {
+ verify(aaiVnfResources, times(1)).checkVnfClosedLoopDisabledFlag(any(String.class));
+ verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000),
+ any(String.class));
+ }
+ }
+
+ @Test
+ public void modifyVnfClosedLoopDisabledFlagTest() throws Exception {
+ doNothing().when(aaiVnfResources).updateObjectVnf(ArgumentMatchers.any(GenericVnf.class));
+ aaiFlagTasks.modifyVnfClosedLoopDisabledFlag(execution, true);
+ verify(aaiVnfResources, times(1)).updateObjectVnf(ArgumentMatchers.any(GenericVnf.class));
+ }
+
+ @Test
+ public void modifyVnfClosedLoopDisabledFlagExceptionTest() {
+
+ doThrow(new BpmnError("Unknown Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
+ doThrow(RuntimeException.class).when(aaiVnfResources).updateObjectVnf(isA(GenericVnf.class));
+ try {
+ aaiFlagTasks.modifyVnfClosedLoopDisabledFlag(execution, true);
+ } catch (Exception e) {
+ verify(aaiVnfResources, times(1)).checkVnfClosedLoopDisabledFlag(any(String.class));
+ verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000),
+ any(String.class));
+ }
+ }
+
+
+ @Test
+ public void checkVnfPserversLockedFlagTestTrue() throws Exception {
+ doThrow(new BpmnError("VNF PServers in Locked in A&AI")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
+ doReturn(true).when(aaiVnfResources).checkVnfPserversLockedFlag(isA(String.class));
+ try {
+ aaiFlagTasks.checkVnfClosedLoopDisabledFlag(execution);
+ } catch (Exception e) {
+ verify(aaiVnfResources, times(1)).checkVnfPserversLockedFlag(any(String.class));
+ verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000),
+ eq("VNF PServers in Locked in A&AI"));
+ }
+ }
+
+ @Test
+ public void checkVnfPserversLockedFlagTestFalse() throws Exception {
+ doReturn(false).when(aaiVnfResources).checkVnfPserversLockedFlag(isA(String.class));
+ aaiFlagTasks.checkVnfPserversLockedFlag(execution);
+ verify(exceptionUtil, times(0)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class),
+ any(int.class), any(String.class));
+ }
+
+ @Test
+ public void checkVnfPserversLockedFlagExceptionTest() throws IOException {
+
+ doThrow(new BpmnError("Unknown Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
+ doThrow(RuntimeException.class).when(aaiVnfResources).checkVnfClosedLoopDisabledFlag(isA(String.class));
+ try {
+ aaiFlagTasks.checkVnfPserversLockedFlag(execution);
+ } catch (Exception e) {
+ verify(aaiVnfResources, times(1)).checkVnfPserversLockedFlag(any(String.class));
+ verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000),
+ any(String.class));
+ }
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java
index 8bbb6c7f46..ff6426d351 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java
@@ -21,14 +21,12 @@ package org.onap.so.bpmn.common.data;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
-
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.impl.pvm.runtime.ExecutionImpl;
import org.junit.Before;
@@ -75,540 +73,543 @@ import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
import org.onap.so.client.exception.BBObjectNotFoundException;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
-public class TestDataSetup{
- private int collectionCounter;
- private int configurationCounter;
- private int customerCounter;
- private int genericVnfCounter;
- private int instanceGroupCounter;
- private int l3NetworkCounter;
- private int owningEntityCounter;
- private int pnfCounter;
- private int projectCounter;
- private int serviceInstanceCounter;
- private int serviceProxyCounter;
- private int serviceSubscriptionCounter;
- private int vfModuleCounter;
- private int volumeGroupCounter;
- private int vpnBindingCounter;
- private int vpnBondingLinkCounter;
-
- protected BuildingBlockExecution execution;
-
- protected GeneralBuildingBlock gBBInput;
-
- protected HashMap<ResourceKey, String> lookupKeyMap;
-
- protected ExtractPojosForBB extractPojosForBB = new ExtractPojosForBB();
-
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- protected DelegateExecution delegateExecution;
-
- @Before
- public void buildingBlockTestDataSetupBefore() {
- collectionCounter = 0;
- configurationCounter = 0;
- customerCounter = 0;
- genericVnfCounter = 0;
- instanceGroupCounter = 0;
- l3NetworkCounter = 0;
- owningEntityCounter = 0;
- pnfCounter = 0;
- projectCounter = 0;
- serviceInstanceCounter = 0;
- serviceProxyCounter = 0;
- serviceSubscriptionCounter = 0;
- vfModuleCounter = 0;
- volumeGroupCounter = 0;
- vpnBindingCounter = 0;
- vpnBondingLinkCounter = 0;
-
- execution = new DelegateExecutionImpl(new ExecutionImpl());
- execution.setVariable("testProcessKey", "testProcessKeyValue");
-
- gBBInput = new GeneralBuildingBlock();
- execution.setVariable("gBBInput", gBBInput);
-
- lookupKeyMap = new HashMap<ResourceKey, String>();
- execution.setVariable("lookupKeyMap", lookupKeyMap);
-
- ExecutionImpl mockExecutionImpl = mock(ExecutionImpl.class);
- doReturn("test").when(mockExecutionImpl).getProcessInstanceId();
-
- ExecutionImpl executionImpl = new ExecutionImpl();
- executionImpl.setProcessInstance(mockExecutionImpl);
-
- delegateExecution = (DelegateExecution) executionImpl;
- delegateExecution.setVariable("testProcessKey", "testProcessKeyValue");
- }
-
- public Map<String, String> buildUserInput() {
- Map<String, String> userInput = new HashMap<>();
- userInput.put("testUserInputKey", "testUserInputValue");
-
- return userInput;
- }
-
- public Map<String, String> setUserInput() {
- Map<String, String> userInput = buildUserInput();
-
- gBBInput.setUserInput(userInput);
-
- return userInput;
- }
-
- public RequestContext buildRequestContext() {
- RequestContext requestContext = new RequestContext();
- requestContext.setMsoRequestId(UUID.randomUUID().toString());
- requestContext.setProductFamilyId("testProductFamilyId");
- requestContext.setRequestorId("testRequestorId");
-
- requestContext.setUserParams(new HashMap<>());
-
- Map<String,Object> dataMap = new HashMap<>();
- dataMap.put("vpnId","testVpnId");
- dataMap.put("vpnRegion","testVpnRegion");
- dataMap.put("vpnRt","testVpnRt");
- dataMap.put("vpnName","vpnName");
+public class TestDataSetup {
+ private int collectionCounter;
+ private int configurationCounter;
+ private int customerCounter;
+ private int genericVnfCounter;
+ private int instanceGroupCounter;
+ private int l3NetworkCounter;
+ private int owningEntityCounter;
+ private int pnfCounter;
+ private int projectCounter;
+ private int serviceInstanceCounter;
+ private int serviceProxyCounter;
+ private int serviceSubscriptionCounter;
+ private int vfModuleCounter;
+ private int volumeGroupCounter;
+ private int vpnBindingCounter;
+ private int vpnBondingLinkCounter;
+
+ protected BuildingBlockExecution execution;
+
+ protected GeneralBuildingBlock gBBInput;
+
+ protected HashMap<ResourceKey, String> lookupKeyMap;
+
+ protected ExtractPojosForBB extractPojosForBB = new ExtractPojosForBB();
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ protected DelegateExecution delegateExecution;
+
+ @Before
+ public void buildingBlockTestDataSetupBefore() {
+ collectionCounter = 0;
+ configurationCounter = 0;
+ customerCounter = 0;
+ genericVnfCounter = 0;
+ instanceGroupCounter = 0;
+ l3NetworkCounter = 0;
+ owningEntityCounter = 0;
+ pnfCounter = 0;
+ projectCounter = 0;
+ serviceInstanceCounter = 0;
+ serviceProxyCounter = 0;
+ serviceSubscriptionCounter = 0;
+ vfModuleCounter = 0;
+ volumeGroupCounter = 0;
+ vpnBindingCounter = 0;
+ vpnBondingLinkCounter = 0;
+
+ execution = new DelegateExecutionImpl(new ExecutionImpl());
+ execution.setVariable("testProcessKey", "testProcessKeyValue");
+
+ gBBInput = new GeneralBuildingBlock();
+ execution.setVariable("gBBInput", gBBInput);
+
+ lookupKeyMap = new HashMap<ResourceKey, String>();
+ execution.setVariable("lookupKeyMap", lookupKeyMap);
+
+ ExecutionImpl mockExecutionImpl = mock(ExecutionImpl.class);
+ doReturn("test").when(mockExecutionImpl).getProcessInstanceId();
+
+ ExecutionImpl executionImpl = new ExecutionImpl();
+ executionImpl.setProcessInstance(mockExecutionImpl);
+
+ delegateExecution = (DelegateExecution) executionImpl;
+ delegateExecution.setVariable("testProcessKey", "testProcessKeyValue");
+ }
+
+ public Map<String, String> buildUserInput() {
+ Map<String, String> userInput = new HashMap<>();
+ userInput.put("testUserInputKey", "testUserInputValue");
+
+ return userInput;
+ }
+
+ public Map<String, String> setUserInput() {
+ Map<String, String> userInput = buildUserInput();
+
+ gBBInput.setUserInput(userInput);
+
+ return userInput;
+ }
+
+ public RequestContext buildRequestContext() {
+ RequestContext requestContext = new RequestContext();
+ requestContext.setMsoRequestId(UUID.randomUUID().toString());
+ requestContext.setProductFamilyId("testProductFamilyId");
+ requestContext.setRequestorId("testRequestorId");
+
+ requestContext.setUserParams(new HashMap<>());
+
+ Map<String, Object> dataMap = new HashMap<>();
+ dataMap.put("vpnId", "testVpnId");
+ dataMap.put("vpnRegion", "testVpnRegion");
+ dataMap.put("vpnRt", "testVpnRt");
+ dataMap.put("vpnName", "vpnName");
dataMap.put("vpnRegion", Arrays.asList(new String[] {"USA", "EMEA", "APAC"}));
- HashMap<String,Object> userParams = new HashMap<>();
- userParams.put("vpnData",dataMap);
+ HashMap<String, Object> userParams = new HashMap<>();
+ userParams.put("vpnData", dataMap);
+
+ List<Map<String, Object>> userParamsList = new ArrayList<>();
+ userParamsList.add(userParams);
- List<Map<String,Object>> userParamsList = new ArrayList<>();
- userParamsList.add(userParams);
+ RequestParameters requestParameters = new RequestParameters();
+ requestParameters.setUserParams(userParamsList);
+ requestContext.setRequestParameters(requestParameters);
- RequestParameters requestParameters = new RequestParameters();
- requestParameters.setUserParams(userParamsList);
- requestContext.setRequestParameters(requestParameters);
+ return requestContext;
+ }
- return requestContext;
- }
+ public RequestContext setRequestContext() {
+ RequestContext requestContext = buildRequestContext();
- public RequestContext setRequestContext() {
- RequestContext requestContext = buildRequestContext();
+ gBBInput.setRequestContext(requestContext);
- gBBInput.setRequestContext(requestContext);
+ return requestContext;
+ }
- return requestContext;
- }
+ public CloudRegion buildCloudRegion() {
+ CloudRegion cloudRegion = new CloudRegion();
+ cloudRegion.setLcpCloudRegionId("testLcpCloudRegionId");
+ cloudRegion.setTenantId("testTenantId");
+ cloudRegion.setCloudOwner("testCloudOwner");
- public CloudRegion buildCloudRegion() {
- CloudRegion cloudRegion = new CloudRegion();
- cloudRegion.setLcpCloudRegionId("testLcpCloudRegionId");
- cloudRegion.setTenantId("testTenantId");
- cloudRegion.setCloudOwner("testCloudOwner");
+ return cloudRegion;
+ }
- return cloudRegion;
- }
+ public CloudRegion setCloudRegion() {
+ CloudRegion cloudRegion = buildCloudRegion();
- public CloudRegion setCloudRegion() {
- CloudRegion cloudRegion = buildCloudRegion();
+ gBBInput.setCloudRegion(cloudRegion);
- gBBInput.setCloudRegion(cloudRegion);
+ return cloudRegion;
+ }
- return cloudRegion;
- }
+ public OrchestrationContext buildOrchestrationContext() {
+ OrchestrationContext orchestrationContext = new OrchestrationContext();
- public OrchestrationContext buildOrchestrationContext() {
- OrchestrationContext orchestrationContext = new OrchestrationContext();
+ return orchestrationContext;
+ }
- return orchestrationContext;
- }
+ public OrchestrationContext setOrchestrationContext() {
+ OrchestrationContext orchestrationContext = buildOrchestrationContext();
- public OrchestrationContext setOrchestrationContext() {
- OrchestrationContext orchestrationContext = buildOrchestrationContext();
+ gBBInput.setOrchContext(orchestrationContext);
- gBBInput.setOrchContext(orchestrationContext);
+ return orchestrationContext;
+ }
- return orchestrationContext;
- }
+ public Collection buildCollection() {
+ collectionCounter++;
- public Collection buildCollection() {
- collectionCounter++;
+ Collection collection = new Collection();
+ collection.setId("testId" + collectionCounter);
+ collection.setInstanceGroup(buildInstanceGroup());
- Collection collection = new Collection();
- collection.setId("testId" + collectionCounter);
- collection.setInstanceGroup(buildInstanceGroup());
+ return collection;
+ }
- return collection;
- }
+ public Configuration buildConfiguration() {
+ configurationCounter++;
- public Configuration buildConfiguration() {
- configurationCounter++;
+ Configuration configuration = new Configuration();
+ configuration.setConfigurationId("testConfigurationId" + configurationCounter);
+ configuration.setConfigurationName("testConfigurationName" + configurationCounter);
- Configuration configuration = new Configuration();
- configuration.setConfigurationId("testConfigurationId" + configurationCounter);
- configuration.setConfigurationName("testConfigurationName" + configurationCounter);
+ ModelInfoConfiguration modelInfoConfiguration = new ModelInfoConfiguration();
+ modelInfoConfiguration.setModelVersionId("testModelVersionId" + configurationCounter);
+ modelInfoConfiguration.setModelInvariantId("testModelInvariantId" + configurationCounter);
+ modelInfoConfiguration.setModelCustomizationId("testModelCustomizationId" + configurationCounter);
- ModelInfoConfiguration modelInfoConfiguration = new ModelInfoConfiguration();
- modelInfoConfiguration.setModelVersionId("testModelVersionId" + configurationCounter);
- modelInfoConfiguration.setModelInvariantId("testModelInvariantId" + configurationCounter);
- modelInfoConfiguration.setModelCustomizationId("testModelCustomizationId" + configurationCounter);
+ configuration.setModelInfoConfiguration(modelInfoConfiguration);
- configuration.setModelInfoConfiguration(modelInfoConfiguration);
+ return configuration;
+ }
- return configuration;
- }
+ public OwningEntity buildOwningEntity() {
+ owningEntityCounter++;
- public OwningEntity buildOwningEntity() {
- owningEntityCounter++;
+ OwningEntity owningEntity = new OwningEntity();
+ owningEntity.setOwningEntityId("testOwningEntityId" + owningEntityCounter);
+ owningEntity.setOwningEntityName("testOwningEntityName" + owningEntityCounter);
- OwningEntity owningEntity = new OwningEntity();
- owningEntity.setOwningEntityId("testOwningEntityId" + owningEntityCounter);
- owningEntity.setOwningEntityName("testOwningEntityName" + owningEntityCounter);
+ return owningEntity;
+ }
- return owningEntity;
- }
+ public Project buildProject() {
+ projectCounter++;
- public Project buildProject() {
- projectCounter++;
+ Project project = new Project();
+ project.setProjectName("testProjectName1 , testProjectName2 , testProjectName3" + projectCounter);
- Project project = new Project();
- project.setProjectName("testProjectName1 , testProjectName2 , testProjectName3" + projectCounter);
+ return project;
+ }
- return project;
- }
+ public ServiceSubscription buildServiceSubscription() {
+ serviceSubscriptionCounter++;
- public ServiceSubscription buildServiceSubscription() {
- serviceSubscriptionCounter++;
+ ServiceSubscription serviceSubscription = new ServiceSubscription();
+ serviceSubscription.setTempUbSubAccountId("testTempUbSubAccountId" + serviceSubscriptionCounter);
+ serviceSubscription.setServiceType("testServiceType" + serviceSubscriptionCounter);
- ServiceSubscription serviceSubscription = new ServiceSubscription();
- serviceSubscription.setTempUbSubAccountId("testTempUbSubAccountId" + serviceSubscriptionCounter);
- serviceSubscription.setServiceType("testServiceType" + serviceSubscriptionCounter);
+ return serviceSubscription;
+ }
- return serviceSubscription;
- }
+ public Customer buildCustomer() {
+ customerCounter++;
- public Customer buildCustomer() {
- customerCounter++;
+ Customer customer = new Customer();
+ customer.setGlobalCustomerId("testGlobalCustomerId" + customerCounter);
+ customer.setSubscriberType("testSubscriberType" + customerCounter);
- Customer customer = new Customer();
- customer.setGlobalCustomerId("testGlobalCustomerId" + customerCounter);
- customer.setSubscriberType("testSubscriberType" + customerCounter);
+ customer.setServiceSubscription(buildServiceSubscription());
- customer.setServiceSubscription(buildServiceSubscription());
+ return customer;
+ }
- return customer;
- }
+ public ServiceInstance buildServiceInstance() {
+ serviceInstanceCounter++;
- public ServiceInstance buildServiceInstance() {
- serviceInstanceCounter++;
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("testServiceInstanceId" + serviceInstanceCounter);
+ serviceInstance.setServiceInstanceName("testServiceInstanceName" + serviceInstanceCounter);
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("testServiceInstanceId" + serviceInstanceCounter);
- serviceInstance.setServiceInstanceName("testServiceInstanceName" + serviceInstanceCounter);
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelInvariantUuid("testModelInvariantUUID" + serviceInstanceCounter);
+ modelInfoServiceInstance.setModelUuid("testModelUUID" + serviceInstanceCounter);
+ modelInfoServiceInstance.setModelVersion("testModelVersion" + serviceInstanceCounter);
+ modelInfoServiceInstance.setModelName("testModelName" + serviceInstanceCounter);
+ modelInfoServiceInstance.setServiceType("testServiceType" + serviceInstanceCounter);
+ modelInfoServiceInstance.setServiceRole("testServiceRole" + serviceInstanceCounter);
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setModelInvariantUuid("testModelInvariantUUID" + serviceInstanceCounter);
- modelInfoServiceInstance.setModelUuid("testModelUUID" + serviceInstanceCounter);
- modelInfoServiceInstance.setModelVersion("testModelVersion" + serviceInstanceCounter);
- modelInfoServiceInstance.setModelName("testModelName" + serviceInstanceCounter);
- modelInfoServiceInstance.setServiceType("testServiceType" + serviceInstanceCounter);
- modelInfoServiceInstance.setServiceRole("testServiceRole" + serviceInstanceCounter);
- serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+ serviceInstance.setProject(buildProject());
- serviceInstance.setProject(buildProject());
+ serviceInstance.setOwningEntity(buildOwningEntity());
- serviceInstance.setOwningEntity(buildOwningEntity());
+ serviceInstance.setCollection(buildCollection());
- serviceInstance.setCollection(buildCollection());
+ serviceInstance.getConfigurations().add(buildConfiguration());
- serviceInstance.getConfigurations().add(buildConfiguration());
+ return serviceInstance;
+ }
- return serviceInstance;
- }
+ public ServiceInstance setServiceInstance() {
+ ServiceInstance serviceInstance = buildServiceInstance();
- public ServiceInstance setServiceInstance() {
- ServiceInstance serviceInstance = buildServiceInstance();
+ if (gBBInput.getCustomer() == null) {
+ gBBInput.setCustomer(buildCustomer());
+ }
+ gBBInput.getCustomer().getServiceSubscription().getServiceInstances().add(serviceInstance);
+ lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, serviceInstance.getServiceInstanceId());
- if(gBBInput.getCustomer() == null) {
- gBBInput.setCustomer(buildCustomer());
- }
- gBBInput.getCustomer().getServiceSubscription().getServiceInstances().add(serviceInstance);
- lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, serviceInstance.getServiceInstanceId());
+ return serviceInstance;
+ }
- return serviceInstance;
- }
+ public Customer setCustomer() {
+ if (gBBInput.getCustomer() != null)
+ return gBBInput.getCustomer();
+ Customer customer = new Customer();
+ customer.setGlobalCustomerId("testGlobalCustomerId");
+ customer.setSubscriberType("testSubscriberType");
- public Customer setCustomer() {
- if(gBBInput.getCustomer() != null) return gBBInput.getCustomer();
- Customer customer = new Customer();
- customer.setGlobalCustomerId("testGlobalCustomerId");
- customer.setSubscriberType("testSubscriberType");
+ customer.setServiceSubscription(buildServiceSubscription());
- customer.setServiceSubscription(buildServiceSubscription());
+ gBBInput.setCustomer(customer);
- gBBInput.setCustomer(customer);
+ return customer;
+ }
- return customer;
- }
+ public Collection setCollection() {
+ Collection collection = new Collection();
+ collection.setId("testId");
- public Collection setCollection() {
- Collection collection = new Collection();
- collection.setId("testId");
+ ServiceInstance serviceInstance = null;
- ServiceInstance serviceInstance = null;
+ try {
+ serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ } catch (BBObjectNotFoundException e) {
+ serviceInstance = setServiceInstance();
+ }
- try {
- serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- } catch(BBObjectNotFoundException e) {
- serviceInstance = setServiceInstance();
- }
+ serviceInstance.setCollection(collection);
- serviceInstance.setCollection(collection);
+ return collection;
+ }
- return collection;
- }
+ public InstanceGroup setInstanceGroup() {
+ InstanceGroup instanceGroup = new InstanceGroup();
+ instanceGroup.setId("testId");
+ instanceGroup.setInstanceGroupFunction("testInstanceGroupFunction");
- public InstanceGroup setInstanceGroup() {
- InstanceGroup instanceGroup = new InstanceGroup();
- instanceGroup.setId("testId");
- instanceGroup.setInstanceGroupFunction("testInstanceGroupFunction");
+ Collection collection = null;
- Collection collection = null;
+ try {
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ collection = serviceInstance.getCollection();
- try {
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- collection = serviceInstance.getCollection();
+ if (collection == null) {
+ collection = setCollection();
+ }
+ } catch (BBObjectNotFoundException e) {
+ collection = setCollection();
+ }
- if (collection == null) {
- collection = setCollection();
- }
- } catch(BBObjectNotFoundException e) {
- collection = setCollection();
- }
+ collection.setInstanceGroup(instanceGroup);
- collection.setInstanceGroup(instanceGroup);
-
- return instanceGroup;
- }
+ return instanceGroup;
+ }
- public InstanceGroup setInstanceGroupVnf() {
- InstanceGroup instanceGroup = buildInstanceGroup();
+ public InstanceGroup setInstanceGroupVnf() {
+ InstanceGroup instanceGroup = buildInstanceGroup();
- ServiceInstance serviceInstance = null;
+ ServiceInstance serviceInstance = null;
- try {
- serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- } catch(BBObjectNotFoundException e) {
- serviceInstance = setServiceInstance();
- }
+ try {
+ serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ } catch (BBObjectNotFoundException e) {
+ serviceInstance = setServiceInstance();
+ }
- serviceInstance.getInstanceGroups().add(instanceGroup);
- lookupKeyMap.put(ResourceKey.INSTANCE_GROUP_ID, instanceGroup.getId());
+ serviceInstance.getInstanceGroups().add(instanceGroup);
+ lookupKeyMap.put(ResourceKey.INSTANCE_GROUP_ID, instanceGroup.getId());
- return instanceGroup;
- }
+ return instanceGroup;
+ }
- public VpnBinding buildVpnBinding() {
- vpnBindingCounter++;
+ public VpnBinding buildVpnBinding() {
+ vpnBindingCounter++;
- VpnBinding vpnBinding = new VpnBinding();
- vpnBinding.setVpnId("testVpnId" + vpnBindingCounter);
- vpnBinding.setVpnName("testVpnName" + vpnBindingCounter);
- vpnBinding.setCustomerVpnId("testCustomerVpnId" + vpnBindingCounter);
+ VpnBinding vpnBinding = new VpnBinding();
+ vpnBinding.setVpnId("testVpnId" + vpnBindingCounter);
+ vpnBinding.setVpnName("testVpnName" + vpnBindingCounter);
+ vpnBinding.setCustomerVpnId("testCustomerVpnId" + vpnBindingCounter);
- return vpnBinding;
- }
+ return vpnBinding;
+ }
- public VpnBinding setVpnBinding() {
- VpnBinding vpnBinding = buildVpnBinding();
+ public VpnBinding setVpnBinding() {
+ VpnBinding vpnBinding = buildVpnBinding();
- Customer customer = gBBInput.getCustomer();
+ Customer customer = gBBInput.getCustomer();
- if(customer == null){
- customer = buildCustomer();
- }
+ if (customer == null) {
+ customer = buildCustomer();
+ }
- customer.getVpnBindings().add(vpnBinding);
- lookupKeyMap.put(ResourceKey.VPN_ID, vpnBinding.getVpnId());
+ customer.getVpnBindings().add(vpnBinding);
+ lookupKeyMap.put(ResourceKey.VPN_ID, vpnBinding.getVpnId());
- return vpnBinding;
- }
+ return vpnBinding;
+ }
- public InstanceGroup buildInstanceGroup() {
- instanceGroupCounter++;
+ public InstanceGroup buildInstanceGroup() {
+ instanceGroupCounter++;
- InstanceGroup instanceGroup = new InstanceGroup();
- instanceGroup.setId("testId" + instanceGroupCounter);
- instanceGroup.setInstanceGroupFunction("testInstanceGroupFunction" + instanceGroupCounter);
+ InstanceGroup instanceGroup = new InstanceGroup();
+ instanceGroup.setId("testId" + instanceGroupCounter);
+ instanceGroup.setInstanceGroupFunction("testInstanceGroupFunction" + instanceGroupCounter);
- return instanceGroup;
- }
+ return instanceGroup;
+ }
- public L3Network buildL3Network() {
- l3NetworkCounter++;
+ public L3Network buildL3Network() {
+ l3NetworkCounter++;
- L3Network network = new L3Network();
- network.setNetworkId("testNetworkId" + l3NetworkCounter);
- network.setNetworkName("testNetworkName" + l3NetworkCounter);
- network.setNetworkType("testNetworkType" + l3NetworkCounter);
+ L3Network network = new L3Network();
+ network.setNetworkId("testNetworkId" + l3NetworkCounter);
+ network.setNetworkName("testNetworkName" + l3NetworkCounter);
+ network.setNetworkType("testNetworkType" + l3NetworkCounter);
- ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
- modelInfoNetwork.setModelInvariantUUID("testModelInvariantUUID" + l3NetworkCounter);
- modelInfoNetwork.setModelName("testModelName" + l3NetworkCounter);
- modelInfoNetwork.setModelVersion("testModelVersion" + l3NetworkCounter);
- modelInfoNetwork.setModelUUID("testModelUUID" + l3NetworkCounter);
- network.setModelInfoNetwork(modelInfoNetwork);
+ ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
+ modelInfoNetwork.setModelInvariantUUID("testModelInvariantUUID" + l3NetworkCounter);
+ modelInfoNetwork.setModelName("testModelName" + l3NetworkCounter);
+ modelInfoNetwork.setModelVersion("testModelVersion" + l3NetworkCounter);
+ modelInfoNetwork.setModelUUID("testModelUUID" + l3NetworkCounter);
+ network.setModelInfoNetwork(modelInfoNetwork);
- return network;
- }
+ return network;
+ }
- public L3Network setL3Network() {
- L3Network network = buildL3Network();
+ public L3Network setL3Network() {
+ L3Network network = buildL3Network();
- ServiceInstance serviceInstance = null;
+ ServiceInstance serviceInstance = null;
- try {
- serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- } catch(BBObjectNotFoundException e) {
- serviceInstance = setServiceInstance();
- }
+ try {
+ serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ } catch (BBObjectNotFoundException e) {
+ serviceInstance = setServiceInstance();
+ }
- serviceInstance.getNetworks().add(network);
- lookupKeyMap.put(ResourceKey.NETWORK_ID, network.getNetworkId());
+ serviceInstance.getNetworks().add(network);
+ lookupKeyMap.put(ResourceKey.NETWORK_ID, network.getNetworkId());
- return network;
- }
+ return network;
+ }
- public GenericVnf buildGenericVnf() {
- genericVnfCounter++;
+ public GenericVnf buildGenericVnf() {
+ genericVnfCounter++;
- GenericVnf genericVnf = new GenericVnf();
- genericVnf.setVnfId("testVnfId" + genericVnfCounter);
- genericVnf.setVnfName("testVnfName" + genericVnfCounter);
- genericVnf.setVnfType("testVnfType" + genericVnfCounter);
- genericVnf.setIpv4OamAddress("10.222.22.2");
+ GenericVnf genericVnf = new GenericVnf();
+ genericVnf.setVnfId("testVnfId" + genericVnfCounter);
+ genericVnf.setVnfName("testVnfName" + genericVnfCounter);
+ genericVnf.setVnfType("testVnfType" + genericVnfCounter);
+ genericVnf.setIpv4OamAddress("10.222.22.2");
- Platform platform = new Platform();
- platform.setPlatformName(" testPlatformName, testPlatformName2 , testPlatformName3 , testPlatformName4");
- genericVnf.setPlatform(platform);
+ Platform platform = new Platform();
+ platform.setPlatformName(" testPlatformName, testPlatformName2 , testPlatformName3 , testPlatformName4");
+ genericVnf.setPlatform(platform);
- LineOfBusiness lob = new LineOfBusiness();
- lob.setLineOfBusinessName(" testLineOfBusinessName , testLineOfBusinessName2, testLineOfBusinessName3, testLineOfBusinessName4");
- genericVnf.setLineOfBusiness(lob);
+ LineOfBusiness lob = new LineOfBusiness();
+ lob.setLineOfBusinessName(
+ " testLineOfBusinessName , testLineOfBusinessName2, testLineOfBusinessName3, testLineOfBusinessName4");
+ genericVnf.setLineOfBusiness(lob);
- ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
- modelInfoGenericVnf.setModelName("testModelName" + genericVnfCounter);
- modelInfoGenericVnf.setModelCustomizationUuid("testModelCustomizationUUID" + genericVnfCounter);
- modelInfoGenericVnf.setModelInvariantUuid("testModelInvariantUUID" + genericVnfCounter);
- modelInfoGenericVnf.setModelVersion("testModelVersion" + genericVnfCounter);
- modelInfoGenericVnf.setModelUuid("testModelUUID" + genericVnfCounter);
- modelInfoGenericVnf.setModelInstanceName("testInstanceName" + genericVnfCounter);
+ ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setModelName("testModelName" + genericVnfCounter);
+ modelInfoGenericVnf.setModelCustomizationUuid("testModelCustomizationUUID" + genericVnfCounter);
+ modelInfoGenericVnf.setModelInvariantUuid("testModelInvariantUUID" + genericVnfCounter);
+ modelInfoGenericVnf.setModelVersion("testModelVersion" + genericVnfCounter);
+ modelInfoGenericVnf.setModelUuid("testModelUUID" + genericVnfCounter);
+ modelInfoGenericVnf.setModelInstanceName("testInstanceName" + genericVnfCounter);
- genericVnf.setModelInfoGenericVnf(modelInfoGenericVnf);
+ genericVnf.setModelInfoGenericVnf(modelInfoGenericVnf);
- License license = new License();
- List<String> array = new ArrayList<String>();
- array.add("testPoolUuid");
- license.setEntitlementPoolUuids(array);
- genericVnf.setLicense(license);
+ License license = new License();
+ List<String> array = new ArrayList<String>();
+ array.add("testPoolUuid");
+ license.setEntitlementPoolUuids(array);
+ genericVnf.setLicense(license);
- return genericVnf;
- }
+ return genericVnf;
+ }
- public GenericVnf setGenericVnf() {
- GenericVnf genericVnf = buildGenericVnf();
+ public GenericVnf setGenericVnf() {
+ GenericVnf genericVnf = buildGenericVnf();
- ServiceInstance serviceInstance = null;
+ ServiceInstance serviceInstance = null;
- try {
- serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- } catch(BBObjectNotFoundException e) {
- serviceInstance = setServiceInstance();
- }
+ try {
+ serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ } catch (BBObjectNotFoundException e) {
+ serviceInstance = setServiceInstance();
+ }
- serviceInstance.getVnfs().add(genericVnf);
- lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, genericVnf.getVnfId());
+ serviceInstance.getVnfs().add(genericVnf);
+ lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, genericVnf.getVnfId());
- return genericVnf;
- }
+ return genericVnf;
+ }
- public VfModule buildVfModule() {
- vfModuleCounter++;
+ public VfModule buildVfModule() {
+ vfModuleCounter++;
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("testVfModuleId" + vfModuleCounter);
- vfModule.setVfModuleName("testVfModuleName" + vfModuleCounter);
- vfModule.setModuleIndex(0);
- ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
- modelInfoVfModule.setModelInvariantUUID("testModelInvariantUUID" + vfModuleCounter);
- modelInfoVfModule.setModelVersion("testModelVersion" + vfModuleCounter);
- modelInfoVfModule.setModelUUID("testModelUUID" + vfModuleCounter);
- modelInfoVfModule.setModelName("testModelName" + vfModuleCounter);
- modelInfoVfModule.setModelCustomizationUUID("testModelCustomizationUUID" + vfModuleCounter);
- vfModule.setModelInfoVfModule(modelInfoVfModule);
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("testVfModuleId" + vfModuleCounter);
+ vfModule.setVfModuleName("testVfModuleName" + vfModuleCounter);
+ vfModule.setModuleIndex(0);
+ ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
+ modelInfoVfModule.setModelInvariantUUID("testModelInvariantUUID" + vfModuleCounter);
+ modelInfoVfModule.setModelVersion("testModelVersion" + vfModuleCounter);
+ modelInfoVfModule.setModelUUID("testModelUUID" + vfModuleCounter);
+ modelInfoVfModule.setModelName("testModelName" + vfModuleCounter);
+ modelInfoVfModule.setModelCustomizationUUID("testModelCustomizationUUID" + vfModuleCounter);
+ vfModule.setModelInfoVfModule(modelInfoVfModule);
- return vfModule;
- }
+ return vfModule;
+ }
- public VfModule setVfModule() {
- return setVfModule(true);
- }
-
- public VfModule setVfModule(boolean addToGenericVnf) {
- VfModule vfModule = buildVfModule();
+ public VfModule setVfModule() {
+ return setVfModule(true);
+ }
- GenericVnf genericVnf = null;
+ public VfModule setVfModule(boolean addToGenericVnf) {
+ VfModule vfModule = buildVfModule();
- try {
- genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- } catch(BBObjectNotFoundException e) {
- genericVnf = setGenericVnf();
- }
+ GenericVnf genericVnf = null;
- if (addToGenericVnf) {
- genericVnf.getVfModules().add(vfModule);
- }
- lookupKeyMap.put(ResourceKey.VF_MODULE_ID, vfModule.getVfModuleId());
+ try {
+ genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ } catch (BBObjectNotFoundException e) {
+ genericVnf = setGenericVnf();
+ }
- return vfModule;
- }
+ if (addToGenericVnf) {
+ genericVnf.getVfModules().add(vfModule);
+ }
+ lookupKeyMap.put(ResourceKey.VF_MODULE_ID, vfModule.getVfModuleId());
- public VolumeGroup buildVolumeGroup() {
- volumeGroupCounter++;
+ return vfModule;
+ }
- VolumeGroup volumeGroup = new VolumeGroup();
- volumeGroup.setVolumeGroupId("testVolumeGroupId" + volumeGroupCounter);
- volumeGroup.setVolumeGroupName("testVolumeGroupName" + volumeGroupCounter);
- volumeGroup.setHeatStackId("testHeatStackId" + volumeGroupCounter);
+ public VolumeGroup buildVolumeGroup() {
+ volumeGroupCounter++;
- return volumeGroup;
- }
+ VolumeGroup volumeGroup = new VolumeGroup();
+ volumeGroup.setVolumeGroupId("testVolumeGroupId" + volumeGroupCounter);
+ volumeGroup.setVolumeGroupName("testVolumeGroupName" + volumeGroupCounter);
+ volumeGroup.setHeatStackId("testHeatStackId" + volumeGroupCounter);
- public VolumeGroup setVolumeGroup() {
- VolumeGroup volumeGroup = buildVolumeGroup();
+ return volumeGroup;
+ }
- GenericVnf genericVnf = null;
+ public VolumeGroup setVolumeGroup() {
+ VolumeGroup volumeGroup = buildVolumeGroup();
- try {
- genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- } catch(BBObjectNotFoundException e) {
- genericVnf = setGenericVnf();
- }
+ GenericVnf genericVnf = null;
- genericVnf.getVolumeGroups().add(volumeGroup);
- lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, volumeGroup.getVolumeGroupId());
+ try {
+ genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ } catch (BBObjectNotFoundException e) {
+ genericVnf = setGenericVnf();
+ }
- return volumeGroup;
- }
+ genericVnf.getVolumeGroups().add(volumeGroup);
+ lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, volumeGroup.getVolumeGroupId());
- public Pnf buildPnf() {
- pnfCounter++;
+ return volumeGroup;
+ }
- Pnf pnf = new Pnf();
- pnf.setPnfId("testPnfId" + pnfCounter);
- pnf.setPnfName("testPnfName" + pnfCounter);
+ public Pnf buildPnf() {
+ pnfCounter++;
- return pnf;
- }
+ Pnf pnf = new Pnf();
+ pnf.setPnfId("testPnfId" + pnfCounter);
+ pnf.setPnfName("testPnfName" + pnfCounter);
- public ServiceProxy buildServiceProxy() {
- serviceProxyCounter++;
+ return pnf;
+ }
+
+ public ServiceProxy buildServiceProxy() {
+ serviceProxyCounter++;
ServiceProxy serviceProxy = new ServiceProxy();
serviceProxy.setServiceInstance(buildServiceInstance());
@@ -623,115 +624,115 @@ public class TestDataSetup{
serviceProxy.getServiceInstance().getPnfs().add(secondaryPnf);
return serviceProxy;
- }
+ }
- public VpnBondingLink buildVpnBondingLink() {
- vpnBondingLinkCounter++;
+ public VpnBondingLink buildVpnBondingLink() {
+ vpnBondingLinkCounter++;
- VpnBondingLink vpnBondingLink = new VpnBondingLink();
- vpnBondingLink.setVpnBondingLinkId("testVpnBondingLinkId" + vpnBondingLinkCounter);
+ VpnBondingLink vpnBondingLink = new VpnBondingLink();
+ vpnBondingLink.setVpnBondingLinkId("testVpnBondingLinkId" + vpnBondingLinkCounter);
- Configuration vnrConfiguration = buildConfiguration();
- vnrConfiguration.setNetwork(buildL3Network());
- vpnBondingLink.setVnrConfiguration(vnrConfiguration);
+ Configuration vnrConfiguration = buildConfiguration();
+ vnrConfiguration.setNetwork(buildL3Network());
+ vpnBondingLink.setVnrConfiguration(vnrConfiguration);
- vpnBondingLink.setVrfConfiguration(buildConfiguration());
+ vpnBondingLink.setVrfConfiguration(buildConfiguration());
vpnBondingLink.setInfrastructureServiceProxy(buildServiceProxy());
vpnBondingLink.setTransportServiceProxy(buildServiceProxy());
- return vpnBondingLink;
- }
-
- public VpnBondingLink setVpnBondingLink() {
- VpnBondingLink vpnBondingLink = buildVpnBondingLink();
-
- ServiceInstance serviceInstance = null;
+ return vpnBondingLink;
+ }
- try {
- serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- } catch(BBObjectNotFoundException e) {
- serviceInstance = setServiceInstance();
- }
+ public VpnBondingLink setVpnBondingLink() {
+ VpnBondingLink vpnBondingLink = buildVpnBondingLink();
- serviceInstance.getVpnBondingLinks().add(vpnBondingLink);
- lookupKeyMap.put(ResourceKey.VPN_BONDING_LINK_ID, vpnBondingLink.getVpnBondingLinkId());
+ ServiceInstance serviceInstance = null;
+ try {
+ serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ } catch (BBObjectNotFoundException e) {
+ serviceInstance = setServiceInstance();
+ }
- return vpnBondingLink;
- }
+ serviceInstance.getVpnBondingLinks().add(vpnBondingLink);
+ lookupKeyMap.put(ResourceKey.VPN_BONDING_LINK_ID, vpnBondingLink.getVpnBondingLinkId());
- public Customer setAvpnCustomer() {
- Customer customer = buildCustomer();
- gBBInput.setCustomer(customer);
+ return vpnBondingLink;
+ }
- return customer;
- }
+ public Customer setAvpnCustomer() {
+ Customer customer = buildCustomer();
- public ServiceProxy setServiceProxy(String uniqueIdentifier, String type) {
- ServiceProxy serviceProxy = new ServiceProxy();
- serviceProxy.setId("testProxyId" + uniqueIdentifier);
- serviceProxy.setType(type);
+ gBBInput.setCustomer(customer);
- ModelInfoServiceProxy modelInfo = new ModelInfoServiceProxy();
- modelInfo.setModelInvariantUuid("testProxyModelInvariantUuid" + uniqueIdentifier);
- modelInfo.setModelName("testProxyModelName" + uniqueIdentifier);
- modelInfo.setModelUuid("testProxyModelUuid" + uniqueIdentifier);
- modelInfo.setModelVersion("testProxyModelVersion" + uniqueIdentifier);
- modelInfo.setModelInstanceName("testProxyInstanceName" + uniqueIdentifier);
+ return customer;
+ }
- serviceProxy.setModelInfoServiceProxy(modelInfo);
-
- return serviceProxy;
- }
-
- public AllottedResource setAllottedResource(String uniqueIdentifier) {
- AllottedResource ar = new AllottedResource();
- ar.setId("testAllottedResourceId" + uniqueIdentifier);
-
- ModelInfoAllottedResource modelInfo = new ModelInfoAllottedResource();
- modelInfo.setModelInvariantUuid("testAllottedModelInvariantUuid" + uniqueIdentifier);
- modelInfo.setModelName("testAllottedModelName" + uniqueIdentifier);
- modelInfo.setModelUuid("testAllottedModelUuid" + uniqueIdentifier);
- modelInfo.setModelVersion("testAllottedModelVersion" + uniqueIdentifier);
- modelInfo.setModelInstanceName("testAllottedModelInstanceName" + uniqueIdentifier);
-
- ar.setModelInfoAllottedResource(modelInfo);
+ public ServiceProxy setServiceProxy(String uniqueIdentifier, String type) {
+ ServiceProxy serviceProxy = new ServiceProxy();
+ serviceProxy.setId("testProxyId" + uniqueIdentifier);
+ serviceProxy.setType(type);
- return ar;
- }
+ ModelInfoServiceProxy modelInfo = new ModelInfoServiceProxy();
+ modelInfo.setModelInvariantUuid("testProxyModelInvariantUuid" + uniqueIdentifier);
+ modelInfo.setModelName("testProxyModelName" + uniqueIdentifier);
+ modelInfo.setModelUuid("testProxyModelUuid" + uniqueIdentifier);
+ modelInfo.setModelVersion("testProxyModelVersion" + uniqueIdentifier);
+ modelInfo.setModelInstanceName("testProxyInstanceName" + uniqueIdentifier);
- public Configuration setConfiguration () {
- Configuration config = new Configuration();
- config.setConfigurationId("testConfigurationId");
- List<Configuration> configurations = new ArrayList<>();
- configurations.add(config);
- ServiceInstance serviceInstance = new ServiceInstance();
- try {
- serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- } catch(BBObjectNotFoundException e) {
- serviceInstance = setServiceInstance();
- }
- lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "testConfigurationId");
- serviceInstance.setConfigurations(configurations);
- return config;
- }
+ serviceProxy.setModelInfoServiceProxy(modelInfo);
- public Subnet buildSubnet() {
+ return serviceProxy;
+ }
+
+ public AllottedResource setAllottedResource(String uniqueIdentifier) {
+ AllottedResource ar = new AllottedResource();
+ ar.setId("testAllottedResourceId" + uniqueIdentifier);
+
+ ModelInfoAllottedResource modelInfo = new ModelInfoAllottedResource();
+ modelInfo.setModelInvariantUuid("testAllottedModelInvariantUuid" + uniqueIdentifier);
+ modelInfo.setModelName("testAllottedModelName" + uniqueIdentifier);
+ modelInfo.setModelUuid("testAllottedModelUuid" + uniqueIdentifier);
+ modelInfo.setModelVersion("testAllottedModelVersion" + uniqueIdentifier);
+ modelInfo.setModelInstanceName("testAllottedModelInstanceName" + uniqueIdentifier);
+
+ ar.setModelInfoAllottedResource(modelInfo);
+
+ return ar;
+ }
+
+ public Configuration setConfiguration() {
+ Configuration config = new Configuration();
+ config.setConfigurationId("testConfigurationId");
+ List<Configuration> configurations = new ArrayList<>();
+ configurations.add(config);
+ ServiceInstance serviceInstance = new ServiceInstance();
+ try {
+ serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ } catch (BBObjectNotFoundException e) {
+ serviceInstance = setServiceInstance();
+ }
+ lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "testConfigurationId");
+ serviceInstance.setConfigurations(configurations);
+ return config;
+ }
+
+ public Subnet buildSubnet() {
Subnet subnet = new Subnet();
subnet.setSubnetId("testSubnetId");
subnet.setOrchestrationStatus(OrchestrationStatus.PENDING);
subnet.setNeutronSubnetId("testNeutronSubnetId");
- return subnet;
- }
-
- public NetworkPolicy buildNetworkPolicy() {
- NetworkPolicy networkPolicy = new NetworkPolicy();
- networkPolicy.setNetworkPolicyId("testNetworkPolicyId");
- networkPolicy.setNetworkPolicyFqdn("testNetworkPolicyFqdn");
- networkPolicy.setHeatStackId("testHeatStackId");
- return networkPolicy;
- }
+ return subnet;
+ }
+
+ public NetworkPolicy buildNetworkPolicy() {
+ NetworkPolicy networkPolicy = new NetworkPolicy();
+ networkPolicy.setNetworkPolicyId("testNetworkPolicyId");
+ networkPolicy.setNetworkPolicyFqdn("testNetworkPolicyFqdn");
+ networkPolicy.setHeatStackId("testHeatStackId");
+ return networkPolicy;
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java
index 5c1caccc2d..b054cc17bb 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java
@@ -30,12 +30,10 @@ import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.TreeSet;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Rule;
@@ -67,589 +65,631 @@ import org.onap.so.db.catalog.beans.OrchestrationStatus;
import org.onap.so.client.aai.entities.uri.AAIResourceUri;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform;
-public class AAICreateTasksTest extends BaseTaskTest{
-
- @InjectMocks
- private AAICreateTasks aaiCreateTasks = new AAICreateTasks();
-
-
- private ServiceInstance serviceInstance;
- private L3Network network;
- private GenericVnf genericVnf;
- private VolumeGroup volumeGroup;
- private CloudRegion cloudRegion;
- private VfModule vfModule;
- private Customer customer;
- private Configuration configuration;
- private InstanceGroup instanceGroup;
-
- @Captor
- ArgumentCaptor<NetworkPolicy> networkPolicyCaptor;
-
- @Rule
- public final ExpectedException exception = ExpectedException.none();
-
- @Before
- public void before() throws BBObjectNotFoundException {
- customer = setCustomer();
- serviceInstance = setServiceInstance();
- network = setL3Network();
- genericVnf = setGenericVnf();
- volumeGroup = setVolumeGroup();
- cloudRegion = setCloudRegion();
- vfModule = setVfModule();
- configuration = setConfiguration();
- instanceGroup = setInstanceGroupVnf();
-
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID))).thenReturn(volumeGroup);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))).thenReturn(serviceInstance);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.CONFIGURATION_ID))).thenReturn(configuration);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.INSTANCE_GROUP_ID))).thenReturn(instanceGroup);
-
-
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
-
- }
-
- @Test
- public void createServiceInstanceTest() throws Exception {
- doNothing().when(aaiServiceInstanceResources).createServiceInstance(serviceInstance, customer);
- aaiCreateTasks.createServiceInstance(execution);
- verify(aaiServiceInstanceResources, times(1)).createServiceInstance(serviceInstance, customer);
- }
-
- @Test
- public void createServiceInstanceExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
-
- lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "notfound");
- doThrow(RuntimeException.class).when(aaiServiceInstanceResources).createServiceInstance(serviceInstance, customer);
- aaiCreateTasks.createServiceInstance(execution);
- }
-
- @Test
- public void createVolumeGroupTest() throws Exception {
- volumeGroup.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
-
- doNothing().when(aaiVolumeGroupResources).createVolumeGroup(volumeGroup, cloudRegion);
- doNothing().when(aaiVolumeGroupResources).connectVolumeGroupToVnf(genericVnf, volumeGroup, cloudRegion);
-
- aaiCreateTasks.createVolumeGroup(execution);
-
- verify(aaiVolumeGroupResources, times(1)).createVolumeGroup(volumeGroup, cloudRegion);
- verify(aaiVolumeGroupResources, times(1)).connectVolumeGroupToVnf(genericVnf, volumeGroup, cloudRegion);
- verify(aaiVolumeGroupResources, times(1)).connectVolumeGroupToTenant(volumeGroup, cloudRegion);
- }
-
- @Test
- public void createVolumeGroupExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
-
- volumeGroup.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
-
- doThrow(RuntimeException.class).when(aaiVolumeGroupResources).createVolumeGroup(volumeGroup, cloudRegion);
-
- aaiCreateTasks.createVolumeGroup(execution);
- }
-
- @Test
- public void createProjectTest() throws Exception {
- doNothing().when(aaiServiceInstanceResources).createProjectandConnectServiceInstance(serviceInstance.getProject(), serviceInstance);
- aaiCreateTasks.createProject(execution);
- verify(aaiServiceInstanceResources, times(1)).createProjectandConnectServiceInstance(serviceInstance.getProject(), serviceInstance);
- }
-
- @Test
- public void createPlatformTest() throws Exception {
- doNothing().when(aaiVnfResources).createPlatformandConnectVnf(genericVnf.getPlatform(), genericVnf);
- aaiCreateTasks.createPlatform(execution);
- ArgumentCaptor<Platform> platformCaptor = ArgumentCaptor.forClass(Platform.class);
- ArgumentCaptor<GenericVnf> genericVnf = ArgumentCaptor.forClass(GenericVnf.class);
- Mockito.verify(aaiVnfResources,times(4)).createPlatformandConnectVnf(platformCaptor.capture(),genericVnf.capture());
-
- List<Platform> capturedPlatforms = platformCaptor.getAllValues();
- assertTrue(capturedPlatforms.stream().anyMatch(item -> "testPlatformName".equals(item.getPlatformName())));
- assertTrue(capturedPlatforms.stream().anyMatch(item -> "testPlatformName2".equals(item.getPlatformName())));
- assertTrue(capturedPlatforms.stream().anyMatch(item -> "testPlatformName3".equals(item.getPlatformName())));
- assertTrue(capturedPlatforms.stream().anyMatch(item -> "testPlatformName4".equals(item.getPlatformName())));
- }
-
- @Test
- public void createLineOfBusinessTest() throws Exception {
- doNothing().when(aaiVnfResources).createLineOfBusinessandConnectVnf(genericVnf.getLineOfBusiness(), genericVnf);
- aaiCreateTasks.createLineOfBusiness(execution);
-
- ArgumentCaptor<LineOfBusiness> lobCaptor = ArgumentCaptor.forClass(LineOfBusiness.class);
- ArgumentCaptor<GenericVnf> genericVnf = ArgumentCaptor.forClass(GenericVnf.class);
- Mockito.verify(aaiVnfResources,times(4)).createLineOfBusinessandConnectVnf(lobCaptor.capture(),genericVnf.capture());
-
- List<LineOfBusiness> capturedLOB = lobCaptor.getAllValues();
- assertTrue(capturedLOB.stream().anyMatch(item -> "testLineOfBusinessName".equals(item.getLineOfBusinessName())));
- assertTrue(capturedLOB.stream().anyMatch(item -> "testLineOfBusinessName2".equals(item.getLineOfBusinessName())));
- assertTrue(capturedLOB.stream().anyMatch(item -> "testLineOfBusinessName3".equals(item.getLineOfBusinessName())));
- assertTrue(capturedLOB.stream().anyMatch(item -> "testLineOfBusinessName4".equals(item.getLineOfBusinessName())));
-
- }
-
- @Test
- public void splitCDL_Test() throws Exception {
- List<String> strings = aaiCreateTasks.splitCDL("Test");
- assertEquals(strings.get(0),"Test");
-
- List<String> strings2 = aaiCreateTasks.splitCDL("");
- assertEquals(strings2.get(0),"");
- }
-
- @Test
- public void createProjectExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
-
- lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "notfound");
- doThrow(RuntimeException.class).when(aaiServiceInstanceResources).createProjectandConnectServiceInstance(serviceInstance.getProject(), serviceInstance);
- aaiCreateTasks.createProject(execution);
- }
-
- @Test
- public void createProjectNullProjectNameTest() throws Exception {
- serviceInstance.getProject().setProjectName(null);
- doNothing().when(aaiServiceInstanceResources).createProjectandConnectServiceInstance(serviceInstance.getProject(), serviceInstance);
- aaiCreateTasks.createProject(execution);
- verify(aaiServiceInstanceResources, times(0)).createProjectandConnectServiceInstance(serviceInstance.getProject(), serviceInstance);
- }
-
- @Test
- public void createProjectEmptyProjectNameTest() throws Exception {
- serviceInstance.getProject().setProjectName("");
- doNothing().when(aaiServiceInstanceResources).createProjectandConnectServiceInstance(serviceInstance.getProject(), serviceInstance);
- aaiCreateTasks.createProject(execution);
- verify(aaiServiceInstanceResources, times(0)).createProjectandConnectServiceInstance(serviceInstance.getProject(), serviceInstance);
- }
-
- @Test
- public void createOwningEntityTest() throws Exception {
- doReturn(true).when(aaiServiceInstanceResources).existsOwningEntity(serviceInstance.getOwningEntity());
- doNothing().when(aaiServiceInstanceResources).connectOwningEntityandServiceInstance(serviceInstance.getOwningEntity(),serviceInstance);
- aaiCreateTasks.createOwningEntity(execution);
- verify(aaiServiceInstanceResources, times(1)).existsOwningEntity(serviceInstance.getOwningEntity());
- verify(aaiServiceInstanceResources, times(1)).connectOwningEntityandServiceInstance(serviceInstance.getOwningEntity(), serviceInstance);
- }
-
- @Test
- public void createOwningEntityNotExistsOwningEntityTest() throws Exception {
- doReturn(false).when(aaiServiceInstanceResources).existsOwningEntity(serviceInstance.getOwningEntity());
- doNothing().when(aaiServiceInstanceResources).createOwningEntityandConnectServiceInstance(serviceInstance.getOwningEntity(),serviceInstance);
- aaiCreateTasks.createOwningEntity(execution);
- verify(aaiServiceInstanceResources, times(1)).existsOwningEntity(serviceInstance.getOwningEntity());
- verify(aaiServiceInstanceResources, times(1)).createOwningEntityandConnectServiceInstance(serviceInstance.getOwningEntity(), serviceInstance);
- }
-
- @Test
- public void createOwningEntityNullOwningEntityIdTest() throws Exception {
- expectedException.expect(BpmnError.class);
-
- serviceInstance.getOwningEntity().setOwningEntityId(null);
-
- aaiCreateTasks.createOwningEntity(execution);
- }
-
- @Test
- public void createOwningEntityEmptyOwningEntityIdTest() throws Exception {
- expectedException.expect(BpmnError.class);
-
- serviceInstance.getOwningEntity().setOwningEntityId("");
-
- aaiCreateTasks.createOwningEntity(execution);
- }
-
- @Test
- public void createOwningEntityNullOwningEntityNameTest() throws Exception {
- expectedException.expect(BpmnError.class);
-
- serviceInstance.getOwningEntity().setOwningEntityName(null);
-
- doReturn(false).when(aaiServiceInstanceResources).existsOwningEntity(serviceInstance.getOwningEntity());
-
- aaiCreateTasks.createOwningEntity(execution);
- }
-
- @Test
- public void createOwningEntityEmptyOwningEntityNameTest() throws Exception {
- expectedException.expect(BpmnError.class);
-
- serviceInstance.getOwningEntity().setOwningEntityName("");
-
- doReturn(false).when(aaiServiceInstanceResources).existsOwningEntity(serviceInstance.getOwningEntity());
-
- aaiCreateTasks.createOwningEntity(execution);
- }
-
- @Test
- public void createOwningEntityExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
-
- doReturn(true).when(aaiServiceInstanceResources).existsOwningEntity(serviceInstance.getOwningEntity());
-
- doThrow(RuntimeException.class).when(aaiServiceInstanceResources).connectOwningEntityandServiceInstance(serviceInstance.getOwningEntity(), serviceInstance);
-
- aaiCreateTasks.createOwningEntity(execution);
- }
-
- @Test
- public void createVnfTest() throws Exception {
- doNothing().when(aaiVnfResources).createVnfandConnectServiceInstance(genericVnf, serviceInstance);
- aaiCreateTasks.createVnf(execution);
- verify(aaiVnfResources, times(1)).createVnfandConnectServiceInstance(genericVnf, serviceInstance);
- }
-
- @Test
- public void createVnfExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "notfound");
- doThrow(BBObjectNotFoundException.class).when(extractPojosForBB).extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID));
- doNothing().when(aaiVnfResources).createVnfandConnectServiceInstance(genericVnf, serviceInstance);
- aaiCreateTasks.createVnf(execution);
- verify(aaiVnfResources, times(1)).createVnfandConnectServiceInstance(genericVnf, serviceInstance);
- }
-
-
- @Test
- public void createVfModuleTest() throws Exception {
-
- VfModule newVfModule = setVfModule(false);
- newVfModule.setModuleIndex(null);
- newVfModule.getModelInfoVfModule().setModelInvariantUUID("testModelInvariantUUID1");
- doNothing().when(aaiVfModuleResources).createVfModule(newVfModule, genericVnf);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(newVfModule);
-
- assertEquals(null, newVfModule.getModuleIndex());
- aaiCreateTasks.createVfModule(execution);
- assertEquals(1, newVfModule.getModuleIndex().intValue());
- verify(aaiVfModuleResources, times(1)).createVfModule(newVfModule, genericVnf);
- }
-
- @Test
- public void createServiceSubscriptionTest(){
- doNothing().when(aaiServiceInstanceResources).createServiceSubscription(customer);
- aaiCreateTasks.createServiceSubscription(execution);
- verify(aaiServiceInstanceResources, times(1)).createServiceSubscription(customer);
- }
-
- @Test
- public void createServiceSubscriptionTestExceptionHandling(){
+public class AAICreateTasksTest extends BaseTaskTest {
+
+ @InjectMocks
+ private AAICreateTasks aaiCreateTasks = new AAICreateTasks();
+
+
+ private ServiceInstance serviceInstance;
+ private L3Network network;
+ private GenericVnf genericVnf;
+ private VolumeGroup volumeGroup;
+ private CloudRegion cloudRegion;
+ private VfModule vfModule;
+ private Customer customer;
+ private Configuration configuration;
+ private InstanceGroup instanceGroup;
+
+ @Captor
+ ArgumentCaptor<NetworkPolicy> networkPolicyCaptor;
+
+ @Rule
+ public final ExpectedException exception = ExpectedException.none();
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ customer = setCustomer();
+ serviceInstance = setServiceInstance();
+ network = setL3Network();
+ genericVnf = setGenericVnf();
+ volumeGroup = setVolumeGroup();
+ cloudRegion = setCloudRegion();
+ vfModule = setVfModule();
+ configuration = setConfiguration();
+ instanceGroup = setInstanceGroupVnf();
+
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
+ .thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID)))
+ .thenReturn(volumeGroup);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
+ .thenReturn(serviceInstance);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.CONFIGURATION_ID)))
+ .thenReturn(configuration);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.INSTANCE_GROUP_ID)))
+ .thenReturn(instanceGroup);
+
+
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
+
+ }
+
+ @Test
+ public void createServiceInstanceTest() throws Exception {
+ doNothing().when(aaiServiceInstanceResources).createServiceInstance(serviceInstance, customer);
+ aaiCreateTasks.createServiceInstance(execution);
+ verify(aaiServiceInstanceResources, times(1)).createServiceInstance(serviceInstance, customer);
+ }
+
+ @Test
+ public void createServiceInstanceExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "notfound");
+ doThrow(RuntimeException.class).when(aaiServiceInstanceResources).createServiceInstance(serviceInstance,
+ customer);
+ aaiCreateTasks.createServiceInstance(execution);
+ }
+
+ @Test
+ public void createVolumeGroupTest() throws Exception {
+ volumeGroup.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
+
+ doNothing().when(aaiVolumeGroupResources).createVolumeGroup(volumeGroup, cloudRegion);
+ doNothing().when(aaiVolumeGroupResources).connectVolumeGroupToVnf(genericVnf, volumeGroup, cloudRegion);
+
+ aaiCreateTasks.createVolumeGroup(execution);
+
+ verify(aaiVolumeGroupResources, times(1)).createVolumeGroup(volumeGroup, cloudRegion);
+ verify(aaiVolumeGroupResources, times(1)).connectVolumeGroupToVnf(genericVnf, volumeGroup, cloudRegion);
+ verify(aaiVolumeGroupResources, times(1)).connectVolumeGroupToTenant(volumeGroup, cloudRegion);
+ }
+
+ @Test
+ public void createVolumeGroupExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ volumeGroup.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
+
+ doThrow(RuntimeException.class).when(aaiVolumeGroupResources).createVolumeGroup(volumeGroup, cloudRegion);
+
+ aaiCreateTasks.createVolumeGroup(execution);
+ }
+
+ @Test
+ public void createProjectTest() throws Exception {
+ doNothing().when(aaiServiceInstanceResources)
+ .createProjectandConnectServiceInstance(serviceInstance.getProject(), serviceInstance);
+ aaiCreateTasks.createProject(execution);
+ verify(aaiServiceInstanceResources, times(1))
+ .createProjectandConnectServiceInstance(serviceInstance.getProject(), serviceInstance);
+ }
+
+ @Test
+ public void createPlatformTest() throws Exception {
+ doNothing().when(aaiVnfResources).createPlatformandConnectVnf(genericVnf.getPlatform(), genericVnf);
+ aaiCreateTasks.createPlatform(execution);
+ ArgumentCaptor<Platform> platformCaptor = ArgumentCaptor.forClass(Platform.class);
+ ArgumentCaptor<GenericVnf> genericVnf = ArgumentCaptor.forClass(GenericVnf.class);
+ Mockito.verify(aaiVnfResources, times(4)).createPlatformandConnectVnf(platformCaptor.capture(),
+ genericVnf.capture());
+
+ List<Platform> capturedPlatforms = platformCaptor.getAllValues();
+ assertTrue(capturedPlatforms.stream().anyMatch(item -> "testPlatformName".equals(item.getPlatformName())));
+ assertTrue(capturedPlatforms.stream().anyMatch(item -> "testPlatformName2".equals(item.getPlatformName())));
+ assertTrue(capturedPlatforms.stream().anyMatch(item -> "testPlatformName3".equals(item.getPlatformName())));
+ assertTrue(capturedPlatforms.stream().anyMatch(item -> "testPlatformName4".equals(item.getPlatformName())));
+ }
+
+ @Test
+ public void createLineOfBusinessTest() throws Exception {
+ doNothing().when(aaiVnfResources).createLineOfBusinessandConnectVnf(genericVnf.getLineOfBusiness(), genericVnf);
+ aaiCreateTasks.createLineOfBusiness(execution);
+
+ ArgumentCaptor<LineOfBusiness> lobCaptor = ArgumentCaptor.forClass(LineOfBusiness.class);
+ ArgumentCaptor<GenericVnf> genericVnf = ArgumentCaptor.forClass(GenericVnf.class);
+ Mockito.verify(aaiVnfResources, times(4)).createLineOfBusinessandConnectVnf(lobCaptor.capture(),
+ genericVnf.capture());
+
+ List<LineOfBusiness> capturedLOB = lobCaptor.getAllValues();
+ assertTrue(
+ capturedLOB.stream().anyMatch(item -> "testLineOfBusinessName".equals(item.getLineOfBusinessName())));
+ assertTrue(
+ capturedLOB.stream().anyMatch(item -> "testLineOfBusinessName2".equals(item.getLineOfBusinessName())));
+ assertTrue(
+ capturedLOB.stream().anyMatch(item -> "testLineOfBusinessName3".equals(item.getLineOfBusinessName())));
+ assertTrue(
+ capturedLOB.stream().anyMatch(item -> "testLineOfBusinessName4".equals(item.getLineOfBusinessName())));
+
+ }
+
+ @Test
+ public void splitCDL_Test() throws Exception {
+ List<String> strings = aaiCreateTasks.splitCDL("Test");
+ assertEquals(strings.get(0), "Test");
+
+ List<String> strings2 = aaiCreateTasks.splitCDL("");
+ assertEquals(strings2.get(0), "");
+ }
+
+ @Test
+ public void createProjectExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "notfound");
+ doThrow(RuntimeException.class).when(aaiServiceInstanceResources)
+ .createProjectandConnectServiceInstance(serviceInstance.getProject(), serviceInstance);
+ aaiCreateTasks.createProject(execution);
+ }
+
+ @Test
+ public void createProjectNullProjectNameTest() throws Exception {
+ serviceInstance.getProject().setProjectName(null);
+ doNothing().when(aaiServiceInstanceResources)
+ .createProjectandConnectServiceInstance(serviceInstance.getProject(), serviceInstance);
+ aaiCreateTasks.createProject(execution);
+ verify(aaiServiceInstanceResources, times(0))
+ .createProjectandConnectServiceInstance(serviceInstance.getProject(), serviceInstance);
+ }
+
+ @Test
+ public void createProjectEmptyProjectNameTest() throws Exception {
+ serviceInstance.getProject().setProjectName("");
+ doNothing().when(aaiServiceInstanceResources)
+ .createProjectandConnectServiceInstance(serviceInstance.getProject(), serviceInstance);
+ aaiCreateTasks.createProject(execution);
+ verify(aaiServiceInstanceResources, times(0))
+ .createProjectandConnectServiceInstance(serviceInstance.getProject(), serviceInstance);
+ }
+
+ @Test
+ public void createOwningEntityTest() throws Exception {
+ doReturn(true).when(aaiServiceInstanceResources).existsOwningEntity(serviceInstance.getOwningEntity());
+ doNothing().when(aaiServiceInstanceResources)
+ .connectOwningEntityandServiceInstance(serviceInstance.getOwningEntity(), serviceInstance);
+ aaiCreateTasks.createOwningEntity(execution);
+ verify(aaiServiceInstanceResources, times(1)).existsOwningEntity(serviceInstance.getOwningEntity());
+ verify(aaiServiceInstanceResources, times(1))
+ .connectOwningEntityandServiceInstance(serviceInstance.getOwningEntity(), serviceInstance);
+ }
+
+ @Test
+ public void createOwningEntityNotExistsOwningEntityTest() throws Exception {
+ doReturn(false).when(aaiServiceInstanceResources).existsOwningEntity(serviceInstance.getOwningEntity());
+ doNothing().when(aaiServiceInstanceResources)
+ .createOwningEntityandConnectServiceInstance(serviceInstance.getOwningEntity(), serviceInstance);
+ aaiCreateTasks.createOwningEntity(execution);
+ verify(aaiServiceInstanceResources, times(1)).existsOwningEntity(serviceInstance.getOwningEntity());
+ verify(aaiServiceInstanceResources, times(1))
+ .createOwningEntityandConnectServiceInstance(serviceInstance.getOwningEntity(), serviceInstance);
+ }
+
+ @Test
+ public void createOwningEntityNullOwningEntityIdTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ serviceInstance.getOwningEntity().setOwningEntityId(null);
+
+ aaiCreateTasks.createOwningEntity(execution);
+ }
+
+ @Test
+ public void createOwningEntityEmptyOwningEntityIdTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ serviceInstance.getOwningEntity().setOwningEntityId("");
+
+ aaiCreateTasks.createOwningEntity(execution);
+ }
+
+ @Test
+ public void createOwningEntityNullOwningEntityNameTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ serviceInstance.getOwningEntity().setOwningEntityName(null);
+
+ doReturn(false).when(aaiServiceInstanceResources).existsOwningEntity(serviceInstance.getOwningEntity());
+
+ aaiCreateTasks.createOwningEntity(execution);
+ }
+
+ @Test
+ public void createOwningEntityEmptyOwningEntityNameTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ serviceInstance.getOwningEntity().setOwningEntityName("");
+
+ doReturn(false).when(aaiServiceInstanceResources).existsOwningEntity(serviceInstance.getOwningEntity());
+
+ aaiCreateTasks.createOwningEntity(execution);
+ }
+
+ @Test
+ public void createOwningEntityExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ doReturn(true).when(aaiServiceInstanceResources).existsOwningEntity(serviceInstance.getOwningEntity());
+
+ doThrow(RuntimeException.class).when(aaiServiceInstanceResources)
+ .connectOwningEntityandServiceInstance(serviceInstance.getOwningEntity(), serviceInstance);
+
+ aaiCreateTasks.createOwningEntity(execution);
+ }
+
+ @Test
+ public void createVnfTest() throws Exception {
+ doNothing().when(aaiVnfResources).createVnfandConnectServiceInstance(genericVnf, serviceInstance);
+ aaiCreateTasks.createVnf(execution);
+ verify(aaiVnfResources, times(1)).createVnfandConnectServiceInstance(genericVnf, serviceInstance);
+ }
+
+ @Test
+ public void createVnfExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "notfound");
+ doThrow(BBObjectNotFoundException.class).when(extractPojosForBB).extractByKey(any(),
+ ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID));
+ doNothing().when(aaiVnfResources).createVnfandConnectServiceInstance(genericVnf, serviceInstance);
+ aaiCreateTasks.createVnf(execution);
+ verify(aaiVnfResources, times(1)).createVnfandConnectServiceInstance(genericVnf, serviceInstance);
+ }
+
+
+ @Test
+ public void createVfModuleTest() throws Exception {
+
+ VfModule newVfModule = setVfModule(false);
+ newVfModule.setModuleIndex(null);
+ newVfModule.getModelInfoVfModule().setModelInvariantUUID("testModelInvariantUUID1");
+ doNothing().when(aaiVfModuleResources).createVfModule(newVfModule, genericVnf);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID)))
+ .thenReturn(newVfModule);
+
+ assertEquals(null, newVfModule.getModuleIndex());
+ aaiCreateTasks.createVfModule(execution);
+ assertEquals(1, newVfModule.getModuleIndex().intValue());
+ verify(aaiVfModuleResources, times(1)).createVfModule(newVfModule, genericVnf);
+ }
+
+ @Test
+ public void createServiceSubscriptionTest() {
+ doNothing().when(aaiServiceInstanceResources).createServiceSubscription(customer);
+ aaiCreateTasks.createServiceSubscription(execution);
+ verify(aaiServiceInstanceResources, times(1)).createServiceSubscription(customer);
+ }
+
+ @Test
+ public void createServiceSubscriptionTestExceptionHandling() {
expectedException.expect(BpmnError.class);
doThrow(RuntimeException.class).when(aaiServiceInstanceResources).createServiceSubscription(customer);
aaiCreateTasks.createServiceSubscription(execution);
}
@Test
- public void createServiceSubscriptionTestCustomerIsNull(){
+ public void createServiceSubscriptionTestCustomerIsNull() {
expectedException.expect(BpmnError.class);
gBBInput.setCustomer(null);
aaiCreateTasks.createServiceSubscription(execution);
}
- @Test
- public void createVfModuleExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
-
- doThrow(RuntimeException.class).when(aaiVfModuleResources).createVfModule(vfModule, genericVnf);
- aaiCreateTasks.createVfModule(execution);
- }
-
- @Test
- public void connectVfModuleToVolumeGroupTest() throws Exception {
- doNothing().when(aaiVfModuleResources).connectVfModuleToVolumeGroup(genericVnf, vfModule, volumeGroup, cloudRegion);
- aaiCreateTasks.connectVfModuleToVolumeGroup(execution);
- verify(aaiVfModuleResources, times(1)).connectVfModuleToVolumeGroup(genericVnf, vfModule, volumeGroup, cloudRegion);
- }
-
- @Test
- public void createNetworkTest() throws Exception {
- network.getModelInfoNetwork().setNeutronNetworkType("PROVIDER");
-
- doNothing().when(aaiNetworkResources).createNetworkConnectToServiceInstance(network,serviceInstance);
- aaiCreateTasks.createNetwork(execution);
- verify(aaiNetworkResources, times(1)).createNetworkConnectToServiceInstance(network, serviceInstance);
- }
-
- @Test
- public void createNetworkExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
-
- lookupKeyMap.put(ResourceKey.NETWORK_ID, "notfound");
- doThrow(RuntimeException.class).when(aaiNetworkResources).createNetworkConnectToServiceInstance(network,serviceInstance);
- aaiCreateTasks.createNetwork(execution);
- }
-
- @Test
- public void createCustomerTest() throws Exception {
- doNothing().when(aaiVpnBindingResources).createCustomer(customer);
-
- aaiCreateTasks.createCustomer(execution);
-
- verify(aaiVpnBindingResources, times(1)).createCustomer(customer);
- }
-
- @Test
- public void createCustomerExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
-
- doThrow(RuntimeException.class).when(aaiVpnBindingResources).createCustomer(customer);
-
- aaiCreateTasks.createCustomer(execution);
- }
-
- @Test
- public void createNetworkCollectionTest() throws Exception {
- doNothing().when(aaiNetworkResources).createNetworkCollection(serviceInstance.getCollection());
- execution.setVariable("networkCollectionName", "testNetworkCollectionName");
- aaiCreateTasks.createNetworkCollection(execution);
- verify(aaiNetworkResources, times(1)).createNetworkCollection(serviceInstance.getCollection());
- }
-
- @Test
- public void createNetworkCollectionInstanceGroupTest() throws Exception {
- doNothing().when(aaiNetworkResources).createNetworkInstanceGroup(serviceInstance.getCollection().getInstanceGroup());
- aaiCreateTasks.createNetworkCollectionInstanceGroup(execution);
- verify(aaiNetworkResources, times(1)).createNetworkInstanceGroup(serviceInstance.getCollection().getInstanceGroup());
- }
-
- @Test
- public void connectNetworkToNetworkCollectionServiceInstanceTest() throws Exception {
- doNothing().when(aaiNetworkResources).connectNetworkToNetworkCollectionServiceInstance(network, serviceInstance);
- aaiCreateTasks.connectNetworkToNetworkCollectionServiceInstance(execution);
- verify(aaiNetworkResources, times(1)).connectNetworkToNetworkCollectionServiceInstance(network, serviceInstance);
- }
-
- @Test
- public void connectNetworkToNetworkCollectionInstanceGroupTest() throws Exception {
- doNothing().when(aaiNetworkResources).connectNetworkToNetworkCollectionInstanceGroup(network, serviceInstance.getCollection().getInstanceGroup());
- aaiCreateTasks.connectNetworkToNetworkCollectionInstanceGroup(execution);
- verify(aaiNetworkResources, times(1)).connectNetworkToNetworkCollectionInstanceGroup(network, serviceInstance.getCollection().getInstanceGroup());
- }
-
- @Test
- public void connectNetworkToNullNetworkCollectionInstanceGroupTest() throws Exception {
- //reset test data to have no network collection instance group
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("testServiceInstanceId");
- L3Network network = new L3Network();
- network.setNetworkId("testNetworkId");
- serviceInstance.getNetworks().add(network);
- lookupKeyMap.put(ResourceKey.NETWORK_ID, network.getNetworkId());
- gBBInput.setServiceInstance(serviceInstance);
- lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, serviceInstance.getServiceInstanceId());
-
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))).thenReturn(serviceInstance);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(serviceInstance);
- //verify connection call was not executednetwork
- exception.expect(BpmnError.class);
- aaiCreateTasks.connectNetworkToNetworkCollectionInstanceGroup(execution);
- verify(aaiNetworkResources, never()).connectNetworkToNetworkCollectionInstanceGroup(network, null);
- }
-
- @Test
- public void connectNetworkToCloudRegionTest() throws Exception {
- gBBInput = execution.getGeneralBuildingBlock();
- doNothing().when(aaiNetworkResources).connectNetworkToCloudRegion(network, gBBInput.getCloudRegion());
- aaiCreateTasks.connectNetworkToCloudRegion(execution);
- verify(aaiNetworkResources, times(1)).connectNetworkToCloudRegion(network, gBBInput.getCloudRegion());
- }
-
- @Test
- public void connectNetworkToTenantTest() throws Exception {
- gBBInput = execution.getGeneralBuildingBlock();
- doNothing().when(aaiNetworkResources).connectNetworkToTenant(network, gBBInput.getCloudRegion());
- aaiCreateTasks.connectNetworkToTenant(execution);
- verify(aaiNetworkResources, times(1)).connectNetworkToTenant(network, gBBInput.getCloudRegion());
- }
-
- @Test
- public void createConfigurationTest() throws Exception {
- gBBInput = execution.getGeneralBuildingBlock();
- doNothing().when(aaiConfigurationResources).createConfiguration(configuration);
- aaiCreateTasks.createConfiguration(execution);
- verify(aaiConfigurationResources, times(1)).createConfiguration(configuration);
- }
-
- @Test
- public void connectVnfToCloudRegionTest() throws Exception {
- gBBInput = execution.getGeneralBuildingBlock();
- doNothing().when(aaiVnfResources).connectVnfToCloudRegion(genericVnf, gBBInput.getCloudRegion());
- aaiCreateTasks.connectVnfToCloudRegion(execution);
- verify(aaiVnfResources, times(1)).connectVnfToCloudRegion(genericVnf, gBBInput.getCloudRegion());
- }
-
- @Test
- public void connectNoneToVnfToCloudRegionTest() throws Exception {
- String[] arr = new String[1];
- arr[0] = "test25Region2";
- doReturn(arr).when(env).getProperty("mso.bpmn.cloudRegionIdsToSkipAddingVnfEdgesTo", String[].class);
- gBBInput = execution.getGeneralBuildingBlock();
- gBBInput.getCloudRegion().setLcpCloudRegionId("test25Region2");
- doNothing().when(aaiVnfResources).connectVnfToCloudRegion(genericVnf, gBBInput.getCloudRegion());
- aaiCreateTasks.connectVnfToCloudRegion(execution);
- verify(aaiVnfResources, times(0)).connectVnfToCloudRegion(genericVnf, gBBInput.getCloudRegion());
- }
-
- @Test
- public void connectVnfTenantTest() throws Exception {
- gBBInput = execution.getGeneralBuildingBlock();
- doNothing().when(aaiVnfResources).connectVnfToTenant(genericVnf, gBBInput.getCloudRegion());
- aaiCreateTasks.connectVnfToTenant(execution);
- verify(aaiVnfResources, times(1)).connectVnfToTenant(genericVnf, gBBInput.getCloudRegion());
- }
-
- @Test
- public void createInstanceGroupVnfTest() throws Exception {
- doNothing().when(aaiInstanceGroupResources).createInstanceGroupandConnectServiceInstance(instanceGroup, serviceInstance);
- aaiCreateTasks.createInstanceGroupVnf(execution);
- verify(aaiInstanceGroupResources, times(1)).createInstanceGroupandConnectServiceInstance(instanceGroup, serviceInstance);
- }
-
- @Test
- public void createInstanceGroupVnfExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(aaiInstanceGroupResources).createInstanceGroupandConnectServiceInstance(instanceGroup, serviceInstance);
- aaiCreateTasks.createInstanceGroupVnf(execution);
- }
-
- @Test
- public void createNetworkPolicyNeedToCreateAllTest() throws Exception {
- execution.setVariable("heatStackId", "testHeatStackId");
- execution.setVariable("contrailNetworkPolicyFqdnList", "ABC123,ED456");
- Optional<NetworkPolicy> networkPolicy = Optional.empty();
- doReturn(networkPolicy).when(aaiNetworkResources).getNetworkPolicy(any(AAIResourceUri.class));
- doNothing().when(aaiNetworkResources).createNetworkPolicy(any(NetworkPolicy.class));
- aaiCreateTasks.createNetworkPolicies(execution);
- verify(aaiNetworkResources, times(2)).createNetworkPolicy(networkPolicyCaptor.capture());
- assertEquals("ABC123", networkPolicyCaptor.getAllValues().get(0).getNetworkPolicyFqdn());
- assertEquals("ED456", networkPolicyCaptor.getAllValues().get(1).getNetworkPolicyFqdn());
- assertEquals("testHeatStackId", networkPolicyCaptor.getAllValues().get(0).getHeatStackId());
- assertEquals("testHeatStackId", networkPolicyCaptor.getAllValues().get(1).getHeatStackId());
- }
-
- @Test
- public void createNetworkPolicyNeedToCreateNoneTest() throws Exception {
- execution.setVariable("heatStackId", "testHeatStackId");
- execution.setVariable("contrailNetworkPolicyFqdnList", "ABC123");
- NetworkPolicy networkPolicy = new NetworkPolicy();
- doReturn(Optional.of(networkPolicy)).when(aaiNetworkResources).getNetworkPolicy(any(AAIResourceUri.class));
- doNothing().when(aaiNetworkResources).createNetworkPolicy(any(NetworkPolicy.class));
- aaiCreateTasks.createNetworkPolicies(execution);
- verify(aaiNetworkResources, times(0)).createNetworkPolicy(any(NetworkPolicy.class));
- }
-
- @Test
- public void createNetworkPolicyNoNetworkPoliciesTest() throws Exception {
- execution.setVariable("heatStackId", "testHeatStackId");
- aaiCreateTasks.createNetworkPolicies(execution);
- verify(aaiNetworkResources, times(0)).createNetworkPolicy(any(NetworkPolicy.class));
- }
-
- @Test
- public void createVfModuleGetLowestIndexTest() throws Exception {
- GenericVnf vnf = new GenericVnf();
- ModelInfoGenericVnf vnfInfo = new ModelInfoGenericVnf();
- vnf.setModelInfoGenericVnf(vnfInfo);
- vnfInfo.setModelInvariantUuid("my-uuid");
-
- ModelInfoVfModule infoA = new ModelInfoVfModule();
- infoA.setIsBaseBoolean(false);
- infoA.setModelInvariantUUID("A");
-
- ModelInfoVfModule infoB = new ModelInfoVfModule();
- infoB.setIsBaseBoolean(false);
- infoB.setModelInvariantUUID("B");
-
- ModelInfoVfModule infoC = new ModelInfoVfModule();
- infoC.setIsBaseBoolean(false);
- infoC.setModelInvariantUUID("C");
-
- VfModule newVfModuleA = new VfModule();
- newVfModuleA.setVfModuleId("a");
- VfModule newVfModuleB = new VfModule();
- newVfModuleB.setVfModuleId("b");
- VfModule newVfModuleC = new VfModule();
- newVfModuleC.setVfModuleId("c");
-
- VfModule vfModule = new VfModule();
- vnf.getVfModules().add(vfModule);
- vfModule.setVfModuleId("1");
-
- VfModule vfModule2 = new VfModule();
- vnf.getVfModules().add(vfModule2);
- vfModule2.setVfModuleId("2");
-
- VfModule vfModule3 = new VfModule();
- vnf.getVfModules().add(vfModule3);
- vfModule3.setVfModuleId("3");
-
- VfModule vfModule4 = new VfModule();
- vnf.getVfModules().add(vfModule4);
- vfModule4.setVfModuleId("4");
-
- VfModule vfModule5 = new VfModule();
- vnf.getVfModules().add(vfModule5);
- vfModule5.setVfModuleId("5");
-
- //modules are included in the vnf already
- vnf.getVfModules().add(newVfModuleA);
- vnf.getVfModules().add(newVfModuleB);
- vnf.getVfModules().add(newVfModuleC);
-
- //A
- newVfModuleA.setModelInfoVfModule(infoA);
- vfModule.setModelInfoVfModule(infoA);
- vfModule2.setModelInfoVfModule(infoA);
- vfModule3.setModelInfoVfModule(infoA);
-
- //B
-
- newVfModuleB.setModelInfoVfModule(infoB);
- vfModule4.setModelInfoVfModule(infoB);
- vfModule5.setModelInfoVfModule(infoB);
-
- //C
- newVfModuleC.setModelInfoVfModule(infoC);
-
-
- //A
- vfModule.setModuleIndex(2);
- vfModule2.setModuleIndex(0);
- vfModule3.setModuleIndex(3);
-
- //B
- vfModule4.setModuleIndex(null);
- vfModule5.setModuleIndex(1);
-
- assertEquals(1, aaiCreateTasks.getLowestUnusedVfModuleIndexFromAAIVnfResponse(vnf, newVfModuleA));
-
- assertEquals(2, aaiCreateTasks.getLowestUnusedVfModuleIndexFromAAIVnfResponse(vnf, newVfModuleB));
-
- assertEquals(0, aaiCreateTasks.getLowestUnusedVfModuleIndexFromAAIVnfResponse(vnf, newVfModuleC));
-
- }
-
- @Test
- public void calculateUnusedIndexTest() {
-
- TreeSet<Integer> a = new TreeSet<>(Arrays.asList(0,1,3));
- TreeSet<Integer> b = new TreeSet<>(Arrays.asList(0,1,8));
- TreeSet<Integer> c = new TreeSet<>(Arrays.asList(0,2,4));
- assertEquals(2, aaiCreateTasks.calculateUnusedIndex(a, 0));
- assertEquals(5, aaiCreateTasks.calculateUnusedIndex(a, 2));
-
- assertEquals(4, aaiCreateTasks.calculateUnusedIndex(b, 2));
- assertEquals(3, aaiCreateTasks.calculateUnusedIndex(b, 1));
-
- assertEquals(5, aaiCreateTasks.calculateUnusedIndex(c, 2));
- assertEquals(9, aaiCreateTasks.calculateUnusedIndex(c, 6));
- assertEquals(1, aaiCreateTasks.calculateUnusedIndex(c, 0));
-
- }
+ @Test
+ public void createVfModuleExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ doThrow(RuntimeException.class).when(aaiVfModuleResources).createVfModule(vfModule, genericVnf);
+ aaiCreateTasks.createVfModule(execution);
+ }
+
+ @Test
+ public void connectVfModuleToVolumeGroupTest() throws Exception {
+ doNothing().when(aaiVfModuleResources).connectVfModuleToVolumeGroup(genericVnf, vfModule, volumeGroup,
+ cloudRegion);
+ aaiCreateTasks.connectVfModuleToVolumeGroup(execution);
+ verify(aaiVfModuleResources, times(1)).connectVfModuleToVolumeGroup(genericVnf, vfModule, volumeGroup,
+ cloudRegion);
+ }
+
+ @Test
+ public void createNetworkTest() throws Exception {
+ network.getModelInfoNetwork().setNeutronNetworkType("PROVIDER");
+
+ doNothing().when(aaiNetworkResources).createNetworkConnectToServiceInstance(network, serviceInstance);
+ aaiCreateTasks.createNetwork(execution);
+ verify(aaiNetworkResources, times(1)).createNetworkConnectToServiceInstance(network, serviceInstance);
+ }
+
+ @Test
+ public void createNetworkExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ lookupKeyMap.put(ResourceKey.NETWORK_ID, "notfound");
+ doThrow(RuntimeException.class).when(aaiNetworkResources).createNetworkConnectToServiceInstance(network,
+ serviceInstance);
+ aaiCreateTasks.createNetwork(execution);
+ }
+
+ @Test
+ public void createCustomerTest() throws Exception {
+ doNothing().when(aaiVpnBindingResources).createCustomer(customer);
+
+ aaiCreateTasks.createCustomer(execution);
+
+ verify(aaiVpnBindingResources, times(1)).createCustomer(customer);
+ }
+
+ @Test
+ public void createCustomerExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ doThrow(RuntimeException.class).when(aaiVpnBindingResources).createCustomer(customer);
+
+ aaiCreateTasks.createCustomer(execution);
+ }
+
+ @Test
+ public void createNetworkCollectionTest() throws Exception {
+ doNothing().when(aaiNetworkResources).createNetworkCollection(serviceInstance.getCollection());
+ execution.setVariable("networkCollectionName", "testNetworkCollectionName");
+ aaiCreateTasks.createNetworkCollection(execution);
+ verify(aaiNetworkResources, times(1)).createNetworkCollection(serviceInstance.getCollection());
+ }
+
+ @Test
+ public void createNetworkCollectionInstanceGroupTest() throws Exception {
+ doNothing().when(aaiNetworkResources)
+ .createNetworkInstanceGroup(serviceInstance.getCollection().getInstanceGroup());
+ aaiCreateTasks.createNetworkCollectionInstanceGroup(execution);
+ verify(aaiNetworkResources, times(1))
+ .createNetworkInstanceGroup(serviceInstance.getCollection().getInstanceGroup());
+ }
+
+ @Test
+ public void connectNetworkToNetworkCollectionServiceInstanceTest() throws Exception {
+ doNothing().when(aaiNetworkResources).connectNetworkToNetworkCollectionServiceInstance(network,
+ serviceInstance);
+ aaiCreateTasks.connectNetworkToNetworkCollectionServiceInstance(execution);
+ verify(aaiNetworkResources, times(1)).connectNetworkToNetworkCollectionServiceInstance(network,
+ serviceInstance);
+ }
+
+ @Test
+ public void connectNetworkToNetworkCollectionInstanceGroupTest() throws Exception {
+ doNothing().when(aaiNetworkResources).connectNetworkToNetworkCollectionInstanceGroup(network,
+ serviceInstance.getCollection().getInstanceGroup());
+ aaiCreateTasks.connectNetworkToNetworkCollectionInstanceGroup(execution);
+ verify(aaiNetworkResources, times(1)).connectNetworkToNetworkCollectionInstanceGroup(network,
+ serviceInstance.getCollection().getInstanceGroup());
+ }
+
+ @Test
+ public void connectNetworkToNullNetworkCollectionInstanceGroupTest() throws Exception {
+ // reset test data to have no network collection instance group
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("testServiceInstanceId");
+ L3Network network = new L3Network();
+ network.setNetworkId("testNetworkId");
+ serviceInstance.getNetworks().add(network);
+ lookupKeyMap.put(ResourceKey.NETWORK_ID, network.getNetworkId());
+ gBBInput.setServiceInstance(serviceInstance);
+ lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, serviceInstance.getServiceInstanceId());
+
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
+ .thenReturn(serviceInstance);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.NETWORK_ID)))
+ .thenReturn(serviceInstance);
+ // verify connection call was not executednetwork
+ exception.expect(BpmnError.class);
+ aaiCreateTasks.connectNetworkToNetworkCollectionInstanceGroup(execution);
+ verify(aaiNetworkResources, never()).connectNetworkToNetworkCollectionInstanceGroup(network, null);
+ }
+
+ @Test
+ public void connectNetworkToCloudRegionTest() throws Exception {
+ gBBInput = execution.getGeneralBuildingBlock();
+ doNothing().when(aaiNetworkResources).connectNetworkToCloudRegion(network, gBBInput.getCloudRegion());
+ aaiCreateTasks.connectNetworkToCloudRegion(execution);
+ verify(aaiNetworkResources, times(1)).connectNetworkToCloudRegion(network, gBBInput.getCloudRegion());
+ }
+
+ @Test
+ public void connectNetworkToTenantTest() throws Exception {
+ gBBInput = execution.getGeneralBuildingBlock();
+ doNothing().when(aaiNetworkResources).connectNetworkToTenant(network, gBBInput.getCloudRegion());
+ aaiCreateTasks.connectNetworkToTenant(execution);
+ verify(aaiNetworkResources, times(1)).connectNetworkToTenant(network, gBBInput.getCloudRegion());
+ }
+
+ @Test
+ public void createConfigurationTest() throws Exception {
+ gBBInput = execution.getGeneralBuildingBlock();
+ doNothing().when(aaiConfigurationResources).createConfiguration(configuration);
+ aaiCreateTasks.createConfiguration(execution);
+ verify(aaiConfigurationResources, times(1)).createConfiguration(configuration);
+ }
+
+ @Test
+ public void connectVnfToCloudRegionTest() throws Exception {
+ gBBInput = execution.getGeneralBuildingBlock();
+ doNothing().when(aaiVnfResources).connectVnfToCloudRegion(genericVnf, gBBInput.getCloudRegion());
+ aaiCreateTasks.connectVnfToCloudRegion(execution);
+ verify(aaiVnfResources, times(1)).connectVnfToCloudRegion(genericVnf, gBBInput.getCloudRegion());
+ }
+
+ @Test
+ public void connectNoneToVnfToCloudRegionTest() throws Exception {
+ String[] arr = new String[1];
+ arr[0] = "test25Region2";
+ doReturn(arr).when(env).getProperty("mso.bpmn.cloudRegionIdsToSkipAddingVnfEdgesTo", String[].class);
+ gBBInput = execution.getGeneralBuildingBlock();
+ gBBInput.getCloudRegion().setLcpCloudRegionId("test25Region2");
+ doNothing().when(aaiVnfResources).connectVnfToCloudRegion(genericVnf, gBBInput.getCloudRegion());
+ aaiCreateTasks.connectVnfToCloudRegion(execution);
+ verify(aaiVnfResources, times(0)).connectVnfToCloudRegion(genericVnf, gBBInput.getCloudRegion());
+ }
+
+ @Test
+ public void connectVnfTenantTest() throws Exception {
+ gBBInput = execution.getGeneralBuildingBlock();
+ doNothing().when(aaiVnfResources).connectVnfToTenant(genericVnf, gBBInput.getCloudRegion());
+ aaiCreateTasks.connectVnfToTenant(execution);
+ verify(aaiVnfResources, times(1)).connectVnfToTenant(genericVnf, gBBInput.getCloudRegion());
+ }
+
+ @Test
+ public void createInstanceGroupVnfTest() throws Exception {
+ doNothing().when(aaiInstanceGroupResources).createInstanceGroupandConnectServiceInstance(instanceGroup,
+ serviceInstance);
+ aaiCreateTasks.createInstanceGroupVnf(execution);
+ verify(aaiInstanceGroupResources, times(1)).createInstanceGroupandConnectServiceInstance(instanceGroup,
+ serviceInstance);
+ }
+
+ @Test
+ public void createInstanceGroupVnfExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(aaiInstanceGroupResources)
+ .createInstanceGroupandConnectServiceInstance(instanceGroup, serviceInstance);
+ aaiCreateTasks.createInstanceGroupVnf(execution);
+ }
+
+ @Test
+ public void createNetworkPolicyNeedToCreateAllTest() throws Exception {
+ execution.setVariable("heatStackId", "testHeatStackId");
+ execution.setVariable("contrailNetworkPolicyFqdnList", "ABC123,ED456");
+ Optional<NetworkPolicy> networkPolicy = Optional.empty();
+ doReturn(networkPolicy).when(aaiNetworkResources).getNetworkPolicy(any(AAIResourceUri.class));
+ doNothing().when(aaiNetworkResources).createNetworkPolicy(any(NetworkPolicy.class));
+ aaiCreateTasks.createNetworkPolicies(execution);
+ verify(aaiNetworkResources, times(2)).createNetworkPolicy(networkPolicyCaptor.capture());
+ assertEquals("ABC123", networkPolicyCaptor.getAllValues().get(0).getNetworkPolicyFqdn());
+ assertEquals("ED456", networkPolicyCaptor.getAllValues().get(1).getNetworkPolicyFqdn());
+ assertEquals("testHeatStackId", networkPolicyCaptor.getAllValues().get(0).getHeatStackId());
+ assertEquals("testHeatStackId", networkPolicyCaptor.getAllValues().get(1).getHeatStackId());
+ }
+
+ @Test
+ public void createNetworkPolicyNeedToCreateNoneTest() throws Exception {
+ execution.setVariable("heatStackId", "testHeatStackId");
+ execution.setVariable("contrailNetworkPolicyFqdnList", "ABC123");
+ NetworkPolicy networkPolicy = new NetworkPolicy();
+ doReturn(Optional.of(networkPolicy)).when(aaiNetworkResources).getNetworkPolicy(any(AAIResourceUri.class));
+ doNothing().when(aaiNetworkResources).createNetworkPolicy(any(NetworkPolicy.class));
+ aaiCreateTasks.createNetworkPolicies(execution);
+ verify(aaiNetworkResources, times(0)).createNetworkPolicy(any(NetworkPolicy.class));
+ }
+
+ @Test
+ public void createNetworkPolicyNoNetworkPoliciesTest() throws Exception {
+ execution.setVariable("heatStackId", "testHeatStackId");
+ aaiCreateTasks.createNetworkPolicies(execution);
+ verify(aaiNetworkResources, times(0)).createNetworkPolicy(any(NetworkPolicy.class));
+ }
+
+ @Test
+ public void createVfModuleGetLowestIndexTest() throws Exception {
+ GenericVnf vnf = new GenericVnf();
+ ModelInfoGenericVnf vnfInfo = new ModelInfoGenericVnf();
+ vnf.setModelInfoGenericVnf(vnfInfo);
+ vnfInfo.setModelInvariantUuid("my-uuid");
+
+ ModelInfoVfModule infoA = new ModelInfoVfModule();
+ infoA.setIsBaseBoolean(false);
+ infoA.setModelInvariantUUID("A");
+
+ ModelInfoVfModule infoB = new ModelInfoVfModule();
+ infoB.setIsBaseBoolean(false);
+ infoB.setModelInvariantUUID("B");
+
+ ModelInfoVfModule infoC = new ModelInfoVfModule();
+ infoC.setIsBaseBoolean(false);
+ infoC.setModelInvariantUUID("C");
+
+ VfModule newVfModuleA = new VfModule();
+ newVfModuleA.setVfModuleId("a");
+ VfModule newVfModuleB = new VfModule();
+ newVfModuleB.setVfModuleId("b");
+ VfModule newVfModuleC = new VfModule();
+ newVfModuleC.setVfModuleId("c");
+
+ VfModule vfModule = new VfModule();
+ vnf.getVfModules().add(vfModule);
+ vfModule.setVfModuleId("1");
+
+ VfModule vfModule2 = new VfModule();
+ vnf.getVfModules().add(vfModule2);
+ vfModule2.setVfModuleId("2");
+
+ VfModule vfModule3 = new VfModule();
+ vnf.getVfModules().add(vfModule3);
+ vfModule3.setVfModuleId("3");
+
+ VfModule vfModule4 = new VfModule();
+ vnf.getVfModules().add(vfModule4);
+ vfModule4.setVfModuleId("4");
+
+ VfModule vfModule5 = new VfModule();
+ vnf.getVfModules().add(vfModule5);
+ vfModule5.setVfModuleId("5");
+
+ // modules are included in the vnf already
+ vnf.getVfModules().add(newVfModuleA);
+ vnf.getVfModules().add(newVfModuleB);
+ vnf.getVfModules().add(newVfModuleC);
+
+ // A
+ newVfModuleA.setModelInfoVfModule(infoA);
+ vfModule.setModelInfoVfModule(infoA);
+ vfModule2.setModelInfoVfModule(infoA);
+ vfModule3.setModelInfoVfModule(infoA);
+
+ // B
+
+ newVfModuleB.setModelInfoVfModule(infoB);
+ vfModule4.setModelInfoVfModule(infoB);
+ vfModule5.setModelInfoVfModule(infoB);
+
+ // C
+ newVfModuleC.setModelInfoVfModule(infoC);
+
+
+ // A
+ vfModule.setModuleIndex(2);
+ vfModule2.setModuleIndex(0);
+ vfModule3.setModuleIndex(3);
+
+ // B
+ vfModule4.setModuleIndex(null);
+ vfModule5.setModuleIndex(1);
+
+ assertEquals(1, aaiCreateTasks.getLowestUnusedVfModuleIndexFromAAIVnfResponse(vnf, newVfModuleA));
+
+ assertEquals(2, aaiCreateTasks.getLowestUnusedVfModuleIndexFromAAIVnfResponse(vnf, newVfModuleB));
+
+ assertEquals(0, aaiCreateTasks.getLowestUnusedVfModuleIndexFromAAIVnfResponse(vnf, newVfModuleC));
+
+ }
+
+ @Test
+ public void calculateUnusedIndexTest() {
+
+ TreeSet<Integer> a = new TreeSet<>(Arrays.asList(0, 1, 3));
+ TreeSet<Integer> b = new TreeSet<>(Arrays.asList(0, 1, 8));
+ TreeSet<Integer> c = new TreeSet<>(Arrays.asList(0, 2, 4));
+ assertEquals(2, aaiCreateTasks.calculateUnusedIndex(a, 0));
+ assertEquals(5, aaiCreateTasks.calculateUnusedIndex(a, 2));
+
+ assertEquals(4, aaiCreateTasks.calculateUnusedIndex(b, 2));
+ assertEquals(3, aaiCreateTasks.calculateUnusedIndex(b, 1));
+
+ assertEquals(5, aaiCreateTasks.calculateUnusedIndex(c, 2));
+ assertEquals(9, aaiCreateTasks.calculateUnusedIndex(c, 6));
+ assertEquals(1, aaiCreateTasks.calculateUnusedIndex(c, 0));
+
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasksTest.java
index 826f888818..855d935ae1 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasksTest.java
@@ -29,11 +29,9 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Optional;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
@@ -60,180 +58,191 @@ import org.onap.so.client.exception.BBObjectNotFoundException;
public class AAIDeleteTasksTest extends BaseTaskTest {
- private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/";
-
- @InjectMocks
- private AAIDeleteTasks aaiDeleteTasks = new AAIDeleteTasks();
-
- private L3Network network;
- private ServiceInstance serviceInstance;
- private GenericVnf genericVnf;
- private VfModule vfModule;
- private VolumeGroup volumeGroup;
- private CloudRegion cloudRegion;
- private Configuration configuration;
- private InstanceGroup instanceGroup;
-
- @Captor
- ArgumentCaptor<String> stringCaptor;
-
- @Before
- public void before() throws BBObjectNotFoundException {
- serviceInstance = setServiceInstance();
- genericVnf = setGenericVnf();
- vfModule = setVfModule();
- network = setL3Network();
- volumeGroup = setVolumeGroup();
- cloudRegion = setCloudRegion();
- configuration = setConfiguration();
- instanceGroup = setInstanceGroupVnf();
-
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID))).thenReturn(volumeGroup);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))).thenReturn(serviceInstance);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.CONFIGURATION_ID))).thenReturn(configuration);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.INSTANCE_GROUP_ID))).thenReturn(instanceGroup);
-
-
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
- }
-
- @Test
- public void deleteVfModuleTest() throws Exception {
-
- doNothing().when(aaiVfModuleResources).deleteVfModule(vfModule, genericVnf);
-
- aaiDeleteTasks.deleteVfModule(execution);
- verify(aaiVfModuleResources, times(1)).deleteVfModule(vfModule, genericVnf);
- }
-
- @Test
- public void deleteVfModuleExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(aaiVfModuleResources).deleteVfModule(vfModule, genericVnf);
- aaiDeleteTasks.deleteVfModule(execution);
- }
-
- @Test
- public void deleteServiceInstanceTest() throws Exception {
- doNothing().when(aaiServiceInstanceResources).deleteServiceInstance(serviceInstance);
-
- aaiDeleteTasks.deleteServiceInstance(execution);
-
- verify(aaiServiceInstanceResources, times(1)).deleteServiceInstance(serviceInstance);
- }
-
- @Test
- public void deleteServiceInstanceExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
-
- doThrow(RuntimeException.class).when(aaiServiceInstanceResources).deleteServiceInstance(serviceInstance);
-
- aaiDeleteTasks.deleteServiceInstance(execution);
- }
-
- @Test
- public void deleteVnfTest() throws Exception {
- doNothing().when(aaiVnfResources).deleteVnf(genericVnf);
- aaiDeleteTasks.deleteVnf(execution);
- verify(aaiVnfResources, times(1)).deleteVnf(genericVnf);
- }
-
- @Test
- public void deleteVnfTestException() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(aaiVnfResources).deleteVnf(genericVnf);
-
- aaiDeleteTasks.deleteVnf(execution);
- verify(aaiVnfResources, times(1)).deleteVnf(genericVnf);
- }
-
- @Test
- public void deleteNetworkTest() throws Exception {
- doNothing().when(aaiNetworkResources).deleteNetwork(network);
- aaiDeleteTasks.deleteNetwork(execution);
- verify(aaiNetworkResources, times(1)).deleteNetwork(network);
- }
-
- @Test
- public void deleteCollectionTest() throws Exception {
- doNothing().when(aaiNetworkResources).deleteCollection(serviceInstance.getCollection());
- aaiDeleteTasks.deleteCollection(execution);
- verify(aaiNetworkResources, times(1)).deleteCollection(serviceInstance.getCollection());
- }
-
- @Test
- public void deleteInstanceGroupTest() throws Exception {
- doNothing().when(aaiNetworkResources).deleteNetworkInstanceGroup(serviceInstance.getCollection().getInstanceGroup());
- aaiDeleteTasks.deleteInstanceGroup(execution);
- verify(aaiNetworkResources, times(1)).deleteNetworkInstanceGroup(serviceInstance.getCollection().getInstanceGroup());
- }
-
- @Test
- public void deleteVolumeGroupTest() {
- doNothing().when(aaiVolumeGroupResources).deleteVolumeGroup(volumeGroup, cloudRegion);
-
- aaiDeleteTasks.deleteVolumeGroup(execution);
-
- verify(aaiVolumeGroupResources, times(1)).deleteVolumeGroup(volumeGroup, cloudRegion);
- }
-
- @Test
- public void deleteVolumeGroupExceptionTest() {
- expectedException.expect(BpmnError.class);
-
- doThrow(RuntimeException.class).when(aaiVolumeGroupResources).deleteVolumeGroup(volumeGroup, cloudRegion);
-
- aaiDeleteTasks.deleteVolumeGroup(execution);
- }
-
- @Test
- public void deleteConfigurationTest() throws Exception {
- gBBInput = execution.getGeneralBuildingBlock();
- doNothing().when(aaiConfigurationResources).deleteConfiguration(configuration);
- aaiDeleteTasks.deleteConfiguration(execution);
- verify(aaiConfigurationResources, times(1)).deleteConfiguration(configuration);
- }
-
- @Test
- public void deleteInstanceGroupVnfTest() throws Exception {
- doNothing().when(aaiInstanceGroupResources).deleteInstanceGroup(instanceGroup);
- aaiDeleteTasks.deleteInstanceGroupVnf(execution);
- verify(aaiInstanceGroupResources, times(1)).deleteInstanceGroup(instanceGroup);
- }
-
- @Test
- public void deleteNetworkPolicyNeedToDeleteAllTest() throws Exception {
- execution.setVariable("contrailNetworkPolicyFqdnList", "ABC123,DEF456");
- final String content0 = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAaiNetworkPoliciesForDelete0.json")));
- AAIResultWrapper aaiResultWrapper0 = new AAIResultWrapper(content0);
- NetworkPolicies networkPolicies0 = aaiResultWrapper0.asBean(NetworkPolicies.class).get();
- final String content1 = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAaiNetworkPoliciesForDelete1.json")));
- AAIResultWrapper aaiResultWrapper1 = new AAIResultWrapper(content1);
- NetworkPolicies networkPolicies1 = aaiResultWrapper1.asBean(NetworkPolicies.class).get();
-
- doReturn(Optional.of(networkPolicies0),Optional.of(networkPolicies1)).when(aaiNetworkResources).getNetworkPolicies(any(AAIResourceUri.class));
- doNothing().when(aaiNetworkResources).deleteNetworkPolicy(any(String.class));
- aaiDeleteTasks.deleteNetworkPolicies(execution);
- verify(aaiNetworkResources, times(2)).deleteNetworkPolicy(stringCaptor.capture());
- assertEquals("testNetworkPolicyId0", stringCaptor.getAllValues().get(0));
- assertEquals("testNetworkPolicyId1", stringCaptor.getAllValues().get(1));
- }
-
- @Test
- public void deleteNetworkPolicyNeedToDeleteNoneTest() throws Exception {
- execution.setVariable("contrailNetworkPolicyFqdnList", "ABC123");
- Optional<NetworkPolicies> networkPolicies = Optional.empty();
- doReturn(networkPolicies).when(aaiNetworkResources).getNetworkPolicies(any(AAIResourceUri.class));
- aaiDeleteTasks.deleteNetworkPolicies(execution);
- verify(aaiNetworkResources, times(0)).deleteNetworkPolicy(any(String.class));
- }
-
- @Test
- public void deleteNetworkPolicyNoNetworkPoliciesTest() throws Exception {
- aaiDeleteTasks.deleteNetworkPolicies(execution);
- verify(aaiNetworkResources, times(0)).deleteNetworkPolicy(any(String.class));
- }
+ private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/";
+
+ @InjectMocks
+ private AAIDeleteTasks aaiDeleteTasks = new AAIDeleteTasks();
+
+ private L3Network network;
+ private ServiceInstance serviceInstance;
+ private GenericVnf genericVnf;
+ private VfModule vfModule;
+ private VolumeGroup volumeGroup;
+ private CloudRegion cloudRegion;
+ private Configuration configuration;
+ private InstanceGroup instanceGroup;
+
+ @Captor
+ ArgumentCaptor<String> stringCaptor;
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ serviceInstance = setServiceInstance();
+ genericVnf = setGenericVnf();
+ vfModule = setVfModule();
+ network = setL3Network();
+ volumeGroup = setVolumeGroup();
+ cloudRegion = setCloudRegion();
+ configuration = setConfiguration();
+ instanceGroup = setInstanceGroupVnf();
+
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
+ .thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID)))
+ .thenReturn(volumeGroup);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
+ .thenReturn(serviceInstance);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.CONFIGURATION_ID)))
+ .thenReturn(configuration);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.INSTANCE_GROUP_ID)))
+ .thenReturn(instanceGroup);
+
+
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
+ }
+
+ @Test
+ public void deleteVfModuleTest() throws Exception {
+
+ doNothing().when(aaiVfModuleResources).deleteVfModule(vfModule, genericVnf);
+
+ aaiDeleteTasks.deleteVfModule(execution);
+ verify(aaiVfModuleResources, times(1)).deleteVfModule(vfModule, genericVnf);
+ }
+
+ @Test
+ public void deleteVfModuleExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(aaiVfModuleResources).deleteVfModule(vfModule, genericVnf);
+ aaiDeleteTasks.deleteVfModule(execution);
+ }
+
+ @Test
+ public void deleteServiceInstanceTest() throws Exception {
+ doNothing().when(aaiServiceInstanceResources).deleteServiceInstance(serviceInstance);
+
+ aaiDeleteTasks.deleteServiceInstance(execution);
+
+ verify(aaiServiceInstanceResources, times(1)).deleteServiceInstance(serviceInstance);
+ }
+
+ @Test
+ public void deleteServiceInstanceExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ doThrow(RuntimeException.class).when(aaiServiceInstanceResources).deleteServiceInstance(serviceInstance);
+
+ aaiDeleteTasks.deleteServiceInstance(execution);
+ }
+
+ @Test
+ public void deleteVnfTest() throws Exception {
+ doNothing().when(aaiVnfResources).deleteVnf(genericVnf);
+ aaiDeleteTasks.deleteVnf(execution);
+ verify(aaiVnfResources, times(1)).deleteVnf(genericVnf);
+ }
+
+ @Test
+ public void deleteVnfTestException() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(aaiVnfResources).deleteVnf(genericVnf);
+
+ aaiDeleteTasks.deleteVnf(execution);
+ verify(aaiVnfResources, times(1)).deleteVnf(genericVnf);
+ }
+
+ @Test
+ public void deleteNetworkTest() throws Exception {
+ doNothing().when(aaiNetworkResources).deleteNetwork(network);
+ aaiDeleteTasks.deleteNetwork(execution);
+ verify(aaiNetworkResources, times(1)).deleteNetwork(network);
+ }
+
+ @Test
+ public void deleteCollectionTest() throws Exception {
+ doNothing().when(aaiNetworkResources).deleteCollection(serviceInstance.getCollection());
+ aaiDeleteTasks.deleteCollection(execution);
+ verify(aaiNetworkResources, times(1)).deleteCollection(serviceInstance.getCollection());
+ }
+
+ @Test
+ public void deleteInstanceGroupTest() throws Exception {
+ doNothing().when(aaiNetworkResources)
+ .deleteNetworkInstanceGroup(serviceInstance.getCollection().getInstanceGroup());
+ aaiDeleteTasks.deleteInstanceGroup(execution);
+ verify(aaiNetworkResources, times(1))
+ .deleteNetworkInstanceGroup(serviceInstance.getCollection().getInstanceGroup());
+ }
+
+ @Test
+ public void deleteVolumeGroupTest() {
+ doNothing().when(aaiVolumeGroupResources).deleteVolumeGroup(volumeGroup, cloudRegion);
+
+ aaiDeleteTasks.deleteVolumeGroup(execution);
+
+ verify(aaiVolumeGroupResources, times(1)).deleteVolumeGroup(volumeGroup, cloudRegion);
+ }
+
+ @Test
+ public void deleteVolumeGroupExceptionTest() {
+ expectedException.expect(BpmnError.class);
+
+ doThrow(RuntimeException.class).when(aaiVolumeGroupResources).deleteVolumeGroup(volumeGroup, cloudRegion);
+
+ aaiDeleteTasks.deleteVolumeGroup(execution);
+ }
+
+ @Test
+ public void deleteConfigurationTest() throws Exception {
+ gBBInput = execution.getGeneralBuildingBlock();
+ doNothing().when(aaiConfigurationResources).deleteConfiguration(configuration);
+ aaiDeleteTasks.deleteConfiguration(execution);
+ verify(aaiConfigurationResources, times(1)).deleteConfiguration(configuration);
+ }
+
+ @Test
+ public void deleteInstanceGroupVnfTest() throws Exception {
+ doNothing().when(aaiInstanceGroupResources).deleteInstanceGroup(instanceGroup);
+ aaiDeleteTasks.deleteInstanceGroupVnf(execution);
+ verify(aaiInstanceGroupResources, times(1)).deleteInstanceGroup(instanceGroup);
+ }
+
+ @Test
+ public void deleteNetworkPolicyNeedToDeleteAllTest() throws Exception {
+ execution.setVariable("contrailNetworkPolicyFqdnList", "ABC123,DEF456");
+ final String content0 = new String(
+ Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAaiNetworkPoliciesForDelete0.json")));
+ AAIResultWrapper aaiResultWrapper0 = new AAIResultWrapper(content0);
+ NetworkPolicies networkPolicies0 = aaiResultWrapper0.asBean(NetworkPolicies.class).get();
+ final String content1 = new String(
+ Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAaiNetworkPoliciesForDelete1.json")));
+ AAIResultWrapper aaiResultWrapper1 = new AAIResultWrapper(content1);
+ NetworkPolicies networkPolicies1 = aaiResultWrapper1.asBean(NetworkPolicies.class).get();
+
+ doReturn(Optional.of(networkPolicies0), Optional.of(networkPolicies1)).when(aaiNetworkResources)
+ .getNetworkPolicies(any(AAIResourceUri.class));
+ doNothing().when(aaiNetworkResources).deleteNetworkPolicy(any(String.class));
+ aaiDeleteTasks.deleteNetworkPolicies(execution);
+ verify(aaiNetworkResources, times(2)).deleteNetworkPolicy(stringCaptor.capture());
+ assertEquals("testNetworkPolicyId0", stringCaptor.getAllValues().get(0));
+ assertEquals("testNetworkPolicyId1", stringCaptor.getAllValues().get(1));
+ }
+
+ @Test
+ public void deleteNetworkPolicyNeedToDeleteNoneTest() throws Exception {
+ execution.setVariable("contrailNetworkPolicyFqdnList", "ABC123");
+ Optional<NetworkPolicies> networkPolicies = Optional.empty();
+ doReturn(networkPolicies).when(aaiNetworkResources).getNetworkPolicies(any(AAIResourceUri.class));
+ aaiDeleteTasks.deleteNetworkPolicies(execution);
+ verify(aaiNetworkResources, times(0)).deleteNetworkPolicy(any(String.class));
+ }
+
+ @Test
+ public void deleteNetworkPolicyNoNetworkPoliciesTest() throws Exception {
+ aaiDeleteTasks.deleteNetworkPolicies(execution);
+ verify(aaiNetworkResources, times(0)).deleteNetworkPolicy(any(String.class));
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java
index 05af58040a..7109ac8826 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java
@@ -32,9 +32,7 @@ import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import java.util.HashMap;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.hamcrest.Matchers;
import org.junit.Before;
@@ -59,613 +57,678 @@ import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf;
import org.onap.so.client.exception.BBObjectNotFoundException;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
-public class AAIUpdateTasksTest extends BaseTaskTest{
-
- @InjectMocks
- private AAIUpdateTasks aaiUpdateTasks = new AAIUpdateTasks();
-
- private L3Network network;
- private ServiceInstance serviceInstance;
- private VfModule vfModule;
- private GenericVnf genericVnf;
- private VolumeGroup volumeGroup;
- private CloudRegion cloudRegion;
- private Configuration configuration;
- private Subnet subnet;
-
- @Before
- public void before() throws BBObjectNotFoundException {
- serviceInstance = setServiceInstance();
- genericVnf = setGenericVnf();
- vfModule = setVfModule();
- volumeGroup = setVolumeGroup();
- cloudRegion = setCloudRegion();
- network = setL3Network();
- configuration = setConfiguration();
- subnet = buildSubnet();
-
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID))).thenReturn(volumeGroup);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))).thenReturn(serviceInstance);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.CONFIGURATION_ID))).thenReturn(configuration);
-
-
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
- }
-
- @Test
- public void updateOrchestrationStatusAssignedServiceTest() throws Exception {
- doNothing().when(aaiServiceInstanceResources).updateOrchestrationStatusServiceInstance(serviceInstance, OrchestrationStatus.ASSIGNED);
-
- aaiUpdateTasks.updateOrchestrationStatusAssignedService(execution);
-
- verify(aaiServiceInstanceResources, times(1)).updateOrchestrationStatusServiceInstance(serviceInstance, OrchestrationStatus.ASSIGNED);
- }
-
- @Test
- public void updateOrchestrationStatusAssignedServiceExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
-
- doThrow(RuntimeException.class).when(aaiServiceInstanceResources).updateOrchestrationStatusServiceInstance(serviceInstance, OrchestrationStatus.ASSIGNED);
-
- aaiUpdateTasks.updateOrchestrationStatusAssignedService(execution);
- }
-
- @Test
- public void updateOrchestrationStatusActiveServiceTest() throws Exception {
- doNothing().when(aaiServiceInstanceResources).updateOrchestrationStatusServiceInstance(serviceInstance, OrchestrationStatus.ACTIVE);
-
- aaiUpdateTasks.updateOrchestrationStatusActiveService(execution);
-
- verify(aaiServiceInstanceResources, times(1)).updateOrchestrationStatusServiceInstance(serviceInstance, OrchestrationStatus.ACTIVE);
- }
-
- @Test
- public void updateOrchestrationStatusActiveServiceExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
-
- doThrow(RuntimeException.class).when(aaiServiceInstanceResources).updateOrchestrationStatusServiceInstance(serviceInstance, OrchestrationStatus.ACTIVE);
-
- aaiUpdateTasks.updateOrchestrationStatusActiveService(execution);
- }
-
- @Test
- public void updateOrchestrationStatusAssignedVnfTest() throws Exception {
- doNothing().when(aaiVnfResources).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ASSIGNED);
-
- aaiUpdateTasks.updateOrchestrationStatusAssignedVnf(execution);
-
- verify(aaiVnfResources, times(1)).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ASSIGNED);
- }
-
- @Test
- public void updateOrchestrationStatusAssignedVnfExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
-
- doThrow(RuntimeException.class).when(aaiVnfResources).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ASSIGNED);
-
- aaiUpdateTasks.updateOrchestrationStatusAssignedVnf(execution);
- }
-
- @Test
- public void updateOrchestrationStatusActiveVnfTest() throws Exception {
- doNothing().when(aaiVnfResources).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ACTIVE);
-
- aaiUpdateTasks.updateOrchestrationStatusActiveVnf(execution);
-
- verify(aaiVnfResources, times(1)).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ACTIVE);
- }
-
- @Test
- public void updateOrchestrationStatusActiveVnfExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
-
- doThrow(RuntimeException.class).when(aaiVnfResources).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ACTIVE);
-
- aaiUpdateTasks.updateOrchestrationStatusActiveVnf(execution);
- }
-
- @Test
- public void updateOrchestrationStatusAssignVfModuleTest() throws Exception {
- doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED);
- aaiUpdateTasks.updateOrchestrationStatusAssignedVfModule(execution);
- verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED);
- assertEquals("", vfModule.getHeatStackId());
- }
-
- @Test
- public void updateOrchestrationStatusAssignVfModuleExceptionTest() throws Exception {
- doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED);
-
- expectedException.expect(BpmnError.class);
-
- aaiUpdateTasks.updateOrchestrationStatusAssignedVfModule(execution);
- }
-
- @Test
- public void updateOrchestrationStatusAssignedOrPendingActivationVfModuleNoMultiStageTest() throws Exception {
- execution.setVariable("aLaCarte", true);
- ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
- modelInfoGenericVnf.setMultiStageDesign("false");
- genericVnf.setModelInfoGenericVnf(modelInfoGenericVnf);
- doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED);
- aaiUpdateTasks.updateOrchestrationStatusAssignedOrPendingActivationVfModule(execution);
- verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED);
- assertEquals("", vfModule.getHeatStackId());
- }
-
- @Test
- public void updateOrchestrationStatusAssignedOrPendingActivationVfModuleMultiStageButNotAlacarteTest() throws Exception {
- execution.setVariable("aLaCarte", false);
- ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
- modelInfoGenericVnf.setMultiStageDesign("true");
- genericVnf.setModelInfoGenericVnf(modelInfoGenericVnf);
- doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED);
- aaiUpdateTasks.updateOrchestrationStatusAssignedOrPendingActivationVfModule(execution);
- verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED);
- assertEquals("", vfModule.getHeatStackId());
- }
-
- @Test
- public void updateOrchestrationStatusAssignedOrPendingActivationVfModuleWithMultiStageTest() throws Exception {
- execution.setVariable("aLaCarte", true);
- ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
- modelInfoGenericVnf.setMultiStageDesign("true");
- genericVnf.setModelInfoGenericVnf(modelInfoGenericVnf);
- doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.PENDING_ACTIVATION);
- aaiUpdateTasks.updateOrchestrationStatusAssignedOrPendingActivationVfModule(execution);
- verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.PENDING_ACTIVATION);
- assertEquals("", vfModule.getHeatStackId());
- }
-
- @Test
- public void updateOrchestrationStatusAssignedOrPendingActivationVfModuleExceptionTest() throws Exception {
- execution.setVariable("aLaCarte", true);
- doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED);
-
- expectedException.expect(BpmnError.class);
-
- aaiUpdateTasks.updateOrchestrationStatusAssignedOrPendingActivationVfModule(execution);
- }
-
- @Test
- public void updateOrchestrationStatusCreatedVfModuleTest() throws Exception {
- doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CREATED);
- aaiUpdateTasks.updateOrchestrationStatusCreatedVfModule(execution);
- verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CREATED);
- }
-
- @Test
- public void updateOrchestrationStatusCreatedVfModuleExceptionTest() throws Exception {
- doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CREATED);
-
- expectedException.expect(BpmnError.class);
-
- aaiUpdateTasks.updateOrchestrationStatusCreatedVfModule(execution);
- }
-
- @Test
- public void updateOrchestrationStatusPendingActivatefModuleTest() throws Exception {
- doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.PENDING_ACTIVATION);
-
- aaiUpdateTasks.updateOrchestrationStatusPendingActivationVfModule(execution);
-
- verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.PENDING_ACTIVATION);
- }
-
- @Test
- public void updateOrchestrationStatusPendingActivatefModuleExceptionTest() throws Exception {
- doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.PENDING_ACTIVATION);
-
- expectedException.expect(BpmnError.class);
-
- aaiUpdateTasks.updateOrchestrationStatusPendingActivationVfModule(execution);
- }
-
- @Test
- public void updateOrchestrationStatusDectivateVfModuleTest() throws Exception {
- doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CREATED);
-
- aaiUpdateTasks.updateOrchestrationStatusDeactivateVfModule(execution);
-
- verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CREATED);
- }
-
- @Test
- public void updateOrchestrationStatusDectivateVfModuleExceptionTest() throws Exception {
- doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CREATED);
-
- expectedException.expect(BpmnError.class);
-
- aaiUpdateTasks.updateOrchestrationStatusDeactivateVfModule(execution);
- }
-
- @Test
- public void updateHeatStackIdVfModuleTest() throws Exception {
- execution.setVariable("heatStackId", "newHeatStackId");
- doNothing().when(aaiVfModuleResources).updateHeatStackIdVfModule(vfModule, genericVnf);
-
- aaiUpdateTasks.updateHeatStackIdVfModule(execution);
-
- verify(aaiVfModuleResources, times(1)).updateHeatStackIdVfModule(vfModule, genericVnf);
- assertEquals("newHeatStackId", vfModule.getHeatStackId());
- }
-
- @Test
- public void updateHeatStackIdVfModuleToNullTest() throws Exception {
- execution.setVariable("heatStackId", null);
- doNothing().when(aaiVfModuleResources).updateHeatStackIdVfModule(vfModule, genericVnf);
-
- aaiUpdateTasks.updateHeatStackIdVfModule(execution);
-
- verify(aaiVfModuleResources, times(1)).updateHeatStackIdVfModule(vfModule, genericVnf);
- assertEquals(vfModule.getHeatStackId(), "");
- }
-
- @Test
- public void updateHeatStackIdVfModuleExceptionTest() throws Exception {
- doThrow(RuntimeException.class).when(aaiVfModuleResources).updateHeatStackIdVfModule(vfModule, genericVnf);
-
- expectedException.expect(BpmnError.class);
-
- aaiUpdateTasks.updateHeatStackIdVfModule(execution);
- }
-
- @Test
- public void updateOrchestrationStatusActiveVolumeGroupTest() throws Exception {
- doNothing().when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.ACTIVE);
-
- aaiUpdateTasks.updateOrchestrationStatusActiveVolumeGroup(execution);
-
- verify(aaiVolumeGroupResources, times(1)).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.ACTIVE);
- }
-
- @Test
- public void updateOrchestrationStatusActiveVolumeGroupExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.ACTIVE);
- aaiUpdateTasks.updateOrchestrationStatusActiveVolumeGroup(execution);
- }
-
- @Test
- public void updateOrchestrationStatusCreatedVolumeGroupTest() throws Exception {
- doNothing().when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.CREATED);
-
- aaiUpdateTasks.updateOrchestrationStatusCreatedVolumeGroup(execution);
-
- verify(aaiVolumeGroupResources, times(1)).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.CREATED);
- }
-
- @Test
- public void updateOrchestrationStatusCreatedVolumeGroupExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.CREATED);
- aaiUpdateTasks.updateOrchestrationStatusCreatedVolumeGroup(execution);
- }
-
- @Test
- public void test_updateOrchestrationStatusAssignedVolumeGroup() throws Exception {
- doNothing().when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.ASSIGNED);
-
- aaiUpdateTasks.updateOrchestrationStatusAssignedVolumeGroup(execution);
-
- verify(aaiVolumeGroupResources, times(1)).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.ASSIGNED);
- assertEquals("", volumeGroup.getHeatStackId());
- }
-
- @Test
- public void test_updateOrchestrationStatusAssignedVolumeGroup_exception() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.ASSIGNED);
- aaiUpdateTasks.updateOrchestrationStatusAssignedVolumeGroup(execution);
- }
- @Test
- public void updateHeatStackIdVolumeGroupTest() throws Exception {
- execution.setVariable("heatStackId", "newHeatStackId");
- doNothing().when(aaiVolumeGroupResources).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion);
-
- aaiUpdateTasks.updateHeatStackIdVolumeGroup(execution);
-
- verify(aaiVolumeGroupResources, times(1)).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion);
- assertEquals("newHeatStackId", volumeGroup.getHeatStackId());
- }
- @Test
- public void updateHeatStackIdVolumeGroupToNullTest() throws Exception {
- execution.setVariable("heatStackId", null);
- doNothing().when(aaiVolumeGroupResources).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion);
-
- aaiUpdateTasks.updateHeatStackIdVolumeGroup(execution);
-
- verify(aaiVolumeGroupResources, times(1)).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion);
- assertEquals(volumeGroup.getHeatStackId(), "");
- }
-
- @Test
- public void updateHeatStackIdVolumeGroupExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(aaiVolumeGroupResources).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion);
- aaiUpdateTasks.updateHeatStackIdVolumeGroup(execution);
- }
-
- @Test
- public void updateNetworkExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
-
- doThrow(RuntimeException.class).when(aaiNetworkResources).updateNetwork(network);
-
- aaiUpdateTasks.updateNetwork(execution, OrchestrationStatus.ACTIVE);
- }
-
- @Test
- public void updateOstatusActivedNetworkCollectionTest() throws Exception {
- doNothing().when(aaiCollectionResources).updateCollection(serviceInstance.getCollection());
- aaiUpdateTasks.updateOrchestrationStatusActiveNetworkCollection(execution);
- verify(aaiCollectionResources, times(1)).updateCollection(serviceInstance.getCollection());
- }
-
- @Test
- public void updateOstatusActiveNetworkColectionExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(aaiCollectionResources).updateCollection(serviceInstance.getCollection());
- aaiUpdateTasks.updateOrchestrationStatusActiveNetworkCollection(execution);
- }
-
- @Test
- public void updateOrchestrationStatusActivateVfModuleTest() throws Exception {
- doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ACTIVE);
-
- aaiUpdateTasks.updateOrchestrationStatusActivateVfModule(execution);
-
- verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ACTIVE);
- }
-
- @Test
- public void updateOrchestrationStatusActivateVfModuleExceptionTest() throws Exception {
- doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ACTIVE);
-
- expectedException.expect(BpmnError.class);
-
- aaiUpdateTasks.updateOrchestrationStatusActivateVfModule(execution);
- }
-
- @Test
- public void updateNetworkCreatedTest() throws Exception {
- CreateNetworkResponse createNetworkResponse = new CreateNetworkResponse();
- createNetworkResponse.setNetworkFqdn("testNetworkFqdn");
- createNetworkResponse.setNetworkStackId("testNetworkStackId");
- HashMap<String, String> subnetMap = new HashMap<>();
- subnetMap.put("testSubnetId", "testNeutronSubnetId");
- createNetworkResponse.setSubnetMap(subnetMap);
-
- network.getSubnets().add(subnet);
-
- execution.setVariable("createNetworkResponse", createNetworkResponse);
-
- doNothing().when(aaiNetworkResources).updateNetwork(network);
- doNothing().when(aaiNetworkResources).updateSubnet(network, subnet);
-
- aaiUpdateTasks.updateNetworkCreated(execution);
- verify(aaiNetworkResources, times(1)).updateNetwork(network);
- verify(aaiNetworkResources, times(1)).updateSubnet(network, subnet);
-
- assertEquals(createNetworkResponse.getNetworkFqdn(), network.getContrailNetworkFqdn());
- assertEquals(OrchestrationStatus.CREATED, network.getOrchestrationStatus());
- assertEquals(createNetworkResponse.getNetworkStackId(), network.getHeatStackId());
- assertEquals(createNetworkResponse.getNeutronNetworkId(), network.getNeutronNetworkId());
- String neutronSubnetId = createNetworkResponse.getSubnetMap().entrySet().iterator().next().getValue();
- assertEquals(neutronSubnetId, network.getSubnets().get(0).getNeutronSubnetId());
- }
-
- @Test
- public void updateNetworkUpdatedTest() throws Exception {
- UpdateNetworkResponse updateNetworkResponse = new UpdateNetworkResponse();
- updateNetworkResponse.setNeutronNetworkId("testNeutronNetworkId");
- HashMap<String, String> subnetMap = new HashMap<>();
- subnetMap.put("testSubnetId", "testNeutronSubnetId");
- updateNetworkResponse.setSubnetMap(subnetMap);
-
- network.getSubnets().add(subnet);
-
- execution.setVariable("updateNetworkResponse", updateNetworkResponse);
-
- doNothing().when(aaiNetworkResources).updateNetwork(network);
- doNothing().when(aaiNetworkResources).updateSubnet(network, subnet);
-
- aaiUpdateTasks.updateNetworkUpdated(execution);
- verify(aaiNetworkResources, times(1)).updateNetwork(network);
- verify(aaiNetworkResources, times(1)).updateSubnet(network, subnet);
-
- String neutronSubnetId = updateNetworkResponse.getSubnetMap().entrySet().iterator().next().getValue();
- assertEquals(neutronSubnetId, network.getSubnets().get(0).getNeutronSubnetId());
- }
-
- @Test
- public void updateOrchestrationStatusNetworkTest() {
- AAIUpdateTasks spy = Mockito.spy(new AAIUpdateTasks());
- doNothing().when(spy).updateNetwork(eq(execution), any());
- spy.updateOrchestrationStatusActiveNetwork(execution);
- verify(spy, times(1)).updateNetwork(execution, OrchestrationStatus.ACTIVE);
- spy.updateOrchestrationStatusAssignedNetwork(execution);
- verify(spy, times(1)).updateNetwork(execution, OrchestrationStatus.ASSIGNED);
- spy.updateOrchestrationStatusCreatedNetwork(execution);
- verify(spy, times(1)).updateNetwork(execution, OrchestrationStatus.CREATED);
- }
-
- @Test
- public void updateNetworkAAITest() {
-
- L3Network spy = spy(new L3Network());
- L3Network shallowCopy = mock(L3Network.class);
- Subnet mockSubnet = mock(Subnet.class);
- Subnet shallowCopySubnet = mock(Subnet.class);
- when(mockSubnet.shallowCopyId()).thenReturn(shallowCopySubnet);
- doReturn(shallowCopy).when(spy).shallowCopyId();
-
- doNothing().when(aaiNetworkResources).updateNetwork(network);
- doNothing().when(aaiNetworkResources).updateSubnet(network, subnet);
-
- spy.getSubnets().add(mockSubnet);
- aaiUpdateTasks.updateNetworkAAI(spy, OrchestrationStatus.CREATED);
-
- verify(shallowCopy, times(1)).setOrchestrationStatus(OrchestrationStatus.CREATED);
- verify(spy, times(1)).setOrchestrationStatus(OrchestrationStatus.CREATED);
- verify(shallowCopySubnet, times(1)).setOrchestrationStatus(OrchestrationStatus.CREATED);
- }
- @Test
- public void updateNetworkCreatedkExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(aaiNetworkResources).updateNetwork(network);
- aaiUpdateTasks.updateNetworkCreated(execution);
- }
-
- @Test
- public void updateObjectNetworkTest() {
- doNothing().when(aaiNetworkResources).updateNetwork(network);
-
- aaiUpdateTasks.updateObjectNetwork(execution);
-
- verify(aaiNetworkResources, times(1)).updateNetwork(network);
- }
-
- @Test
- public void updateObjectNetworkExceptionText() {
- expectedException.expect(BpmnError.class);
-
- doThrow(RuntimeException.class).when(aaiNetworkResources).updateNetwork(network);
-
- aaiUpdateTasks.updateObjectNetwork(execution);
- }
-
- @Test
- public void test_updateServiceInstance() {
- doNothing().when(aaiServiceInstanceResources).updateServiceInstance(serviceInstance);
- aaiUpdateTasks.updateServiceInstance(execution);
- verify(aaiServiceInstanceResources, times(1)).updateServiceInstance(serviceInstance);
- }
-
- @Test
- public void test_updateServiceInstance_exception() {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(aaiServiceInstanceResources).updateServiceInstance(serviceInstance);
- aaiUpdateTasks.updateServiceInstance(execution);
- }
-
- @Test
- public void updateObjectVnfTest() {
- doNothing().when(aaiVnfResources).updateObjectVnf(genericVnf);
-
- aaiUpdateTasks.updateObjectVnf(execution);
-
- verify(aaiVnfResources, times(1)).updateObjectVnf(genericVnf);
- }
-
- @Test
- public void updateObjectVnfExceptionTest() {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(aaiVnfResources).updateObjectVnf(genericVnf);
- aaiUpdateTasks.updateObjectVnf(execution);
- }
-
- @Test
- public void updateOrchestrationStatusDeleteVfModuleTest() throws Exception {
- doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED);
-
- aaiUpdateTasks.updateOrchestrationStatusDeleteVfModule(execution);
-
- verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED);
- assertEquals("", vfModule.getHeatStackId());
- }
-
- @Test
- public void updateModelVfModuleTest() {
- doNothing().when(aaiVfModuleResources).changeAssignVfModule(vfModule, genericVnf);
- aaiUpdateTasks.updateModelVfModule(execution);
- verify(aaiVfModuleResources, times(1)).changeAssignVfModule(vfModule, genericVnf);
- }
-
- @Test
- public void updateModelVfModuleExceptionTest() {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(aaiVfModuleResources).changeAssignVfModule(vfModule, genericVnf);
- aaiUpdateTasks.updateModelVfModule(execution);
- }
-
- @Test
- public void updateOrchestrationStatusDeactivateFabricConfigurationTest() throws Exception {
- gBBInput = execution.getGeneralBuildingBlock();
- doNothing().when(aaiConfigurationResources).updateOrchestrationStatusConfiguration(configuration, OrchestrationStatus.ASSIGNED);
-
- aaiUpdateTasks.updateOrchestrationStatusDeactivateFabricConfiguration(execution);
-
- verify(aaiConfigurationResources, times(1)).updateOrchestrationStatusConfiguration(configuration, OrchestrationStatus.ASSIGNED);
- }
- @Test
- public void updateOrchestrationStatusActivateFabricConfigurationTest() throws Exception {
- gBBInput = execution.getGeneralBuildingBlock();
- doNothing().when(aaiConfigurationResources).updateOrchestrationStatusConfiguration(configuration, OrchestrationStatus.ACTIVE);
-
- aaiUpdateTasks.updateOrchestrationStatusActivateFabricConfiguration(execution);
-
- verify(aaiConfigurationResources, times(1)).updateOrchestrationStatusConfiguration(configuration, OrchestrationStatus.ACTIVE);
- }
- @Test
- public void updateContrailServiceInstanceFqdnVfModuleTest() throws Exception {
- execution.setVariable("contrailServiceInstanceFqdn", "newContrailServiceInstanceFqdn");
- doNothing().when(aaiVfModuleResources).updateContrailServiceInstanceFqdnVfModule(vfModule, genericVnf);
-
- aaiUpdateTasks.updateContrailServiceInstanceFqdnVfModule(execution);
-
- verify(aaiVfModuleResources, times(1)).updateContrailServiceInstanceFqdnVfModule(vfModule, genericVnf);
- assertEquals("newContrailServiceInstanceFqdn", vfModule.getContrailServiceInstanceFqdn());
- }
- @Test
- public void updateContrailServiceInstanceFqdnVfModuleNoUpdateTest() throws Exception {
- aaiUpdateTasks.updateContrailServiceInstanceFqdnVfModule(execution);
- verify(aaiVfModuleResources, times(0)).updateContrailServiceInstanceFqdnVfModule(vfModule, genericVnf);
- }
- @Test
- public void updateIpv4OamAddressVnfTest() throws Exception {
- execution.setVariable("oamManagementV4Address", "newIpv4OamAddress");
- doNothing().when(aaiVnfResources).updateObjectVnf(genericVnf);
-
- aaiUpdateTasks.updateIpv4OamAddressVnf(execution);
-
- verify(aaiVnfResources, times(1)).updateObjectVnf(genericVnf);
- assertEquals("newIpv4OamAddress", genericVnf.getIpv4OamAddress());
- }
- @Test
- public void updateIpv4OamAddressVnfNoUpdateTest() throws Exception {
- aaiUpdateTasks.updateIpv4OamAddressVnf(execution);
- verify(aaiVnfResources, times(0)).updateObjectVnf(genericVnf);
- }
- @Test
- public void updateManagementV6AddressVnfTest() throws Exception {
- execution.setVariable("oamManagementV6Address", "newManagementV6Address");
- doNothing().when(aaiVnfResources).updateObjectVnf(genericVnf);
-
- aaiUpdateTasks.updateManagementV6AddressVnf(execution);
-
- verify(aaiVnfResources, times(1)).updateObjectVnf(genericVnf);
- assertEquals("newManagementV6Address", genericVnf.getManagementV6Address());
- }
- @Test
- public void updateManagementV6AddressVnfNoUpdateTest() throws Exception {
- aaiUpdateTasks.updateManagementV6AddressVnf(execution);
- verify(aaiVnfResources, times(0)).updateObjectVnf(genericVnf);
- }
-
- @Test
- public void updateOrchestrationStatusVnfConfigureTest() throws Exception {
- doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CONFIGURE);
-
- aaiUpdateTasks.updateOrchestrationStausConfigDeployConfigureVnf(execution);
- }
- @Test
- public void updateOrchestrationStatusVnfConfiguredTest() throws Exception {
- doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CONFIGURED);
-
- aaiUpdateTasks.updateOrchestrationStausConfigDeployConfiguredVnf(execution);
- }
+public class AAIUpdateTasksTest extends BaseTaskTest {
+
+ @InjectMocks
+ private AAIUpdateTasks aaiUpdateTasks = new AAIUpdateTasks();
+
+ private L3Network network;
+ private ServiceInstance serviceInstance;
+ private VfModule vfModule;
+ private GenericVnf genericVnf;
+ private VolumeGroup volumeGroup;
+ private CloudRegion cloudRegion;
+ private Configuration configuration;
+ private Subnet subnet;
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ serviceInstance = setServiceInstance();
+ genericVnf = setGenericVnf();
+ vfModule = setVfModule();
+ volumeGroup = setVolumeGroup();
+ cloudRegion = setCloudRegion();
+ network = setL3Network();
+ configuration = setConfiguration();
+ subnet = buildSubnet();
+
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
+ .thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID)))
+ .thenReturn(volumeGroup);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
+ .thenReturn(serviceInstance);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.CONFIGURATION_ID)))
+ .thenReturn(configuration);
+
+
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
+ }
+
+ @Test
+ public void updateOrchestrationStatusAssignedServiceTest() throws Exception {
+ doNothing().when(aaiServiceInstanceResources).updateOrchestrationStatusServiceInstance(serviceInstance,
+ OrchestrationStatus.ASSIGNED);
+
+ aaiUpdateTasks.updateOrchestrationStatusAssignedService(execution);
+
+ verify(aaiServiceInstanceResources, times(1)).updateOrchestrationStatusServiceInstance(serviceInstance,
+ OrchestrationStatus.ASSIGNED);
+ }
+
+ @Test
+ public void updateOrchestrationStatusAssignedServiceExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ doThrow(RuntimeException.class).when(aaiServiceInstanceResources)
+ .updateOrchestrationStatusServiceInstance(serviceInstance, OrchestrationStatus.ASSIGNED);
+
+ aaiUpdateTasks.updateOrchestrationStatusAssignedService(execution);
+ }
+
+ @Test
+ public void updateOrchestrationStatusActiveServiceTest() throws Exception {
+ doNothing().when(aaiServiceInstanceResources).updateOrchestrationStatusServiceInstance(serviceInstance,
+ OrchestrationStatus.ACTIVE);
+
+ aaiUpdateTasks.updateOrchestrationStatusActiveService(execution);
+
+ verify(aaiServiceInstanceResources, times(1)).updateOrchestrationStatusServiceInstance(serviceInstance,
+ OrchestrationStatus.ACTIVE);
+ }
+
+ @Test
+ public void updateOrchestrationStatusActiveServiceExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ doThrow(RuntimeException.class).when(aaiServiceInstanceResources)
+ .updateOrchestrationStatusServiceInstance(serviceInstance, OrchestrationStatus.ACTIVE);
+
+ aaiUpdateTasks.updateOrchestrationStatusActiveService(execution);
+ }
+
+ @Test
+ public void updateOrchestrationStatusAssignedVnfTest() throws Exception {
+ doNothing().when(aaiVnfResources).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ASSIGNED);
+
+ aaiUpdateTasks.updateOrchestrationStatusAssignedVnf(execution);
+
+ verify(aaiVnfResources, times(1)).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ASSIGNED);
+ }
+
+ @Test
+ public void updateOrchestrationStatusAssignedVnfExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ doThrow(RuntimeException.class).when(aaiVnfResources).updateOrchestrationStatusVnf(genericVnf,
+ OrchestrationStatus.ASSIGNED);
+
+ aaiUpdateTasks.updateOrchestrationStatusAssignedVnf(execution);
+ }
+
+ @Test
+ public void updateOrchestrationStatusActiveVnfTest() throws Exception {
+ doNothing().when(aaiVnfResources).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ACTIVE);
+
+ aaiUpdateTasks.updateOrchestrationStatusActiveVnf(execution);
+
+ verify(aaiVnfResources, times(1)).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ACTIVE);
+ }
+
+ @Test
+ public void updateOrchestrationStatusActiveVnfExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ doThrow(RuntimeException.class).when(aaiVnfResources).updateOrchestrationStatusVnf(genericVnf,
+ OrchestrationStatus.ACTIVE);
+
+ aaiUpdateTasks.updateOrchestrationStatusActiveVnf(execution);
+ }
+
+ @Test
+ public void updateOrchestrationStatusAssignVfModuleTest() throws Exception {
+ doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf,
+ OrchestrationStatus.ASSIGNED);
+ aaiUpdateTasks.updateOrchestrationStatusAssignedVfModule(execution);
+ verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf,
+ OrchestrationStatus.ASSIGNED);
+ assertEquals("", vfModule.getHeatStackId());
+ }
+
+ @Test
+ public void updateOrchestrationStatusAssignVfModuleExceptionTest() throws Exception {
+ doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule,
+ genericVnf, OrchestrationStatus.ASSIGNED);
+
+ expectedException.expect(BpmnError.class);
+
+ aaiUpdateTasks.updateOrchestrationStatusAssignedVfModule(execution);
+ }
+
+ @Test
+ public void updateOrchestrationStatusAssignedOrPendingActivationVfModuleNoMultiStageTest() throws Exception {
+ execution.setVariable("aLaCarte", true);
+ ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setMultiStageDesign("false");
+ genericVnf.setModelInfoGenericVnf(modelInfoGenericVnf);
+ doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf,
+ OrchestrationStatus.ASSIGNED);
+ aaiUpdateTasks.updateOrchestrationStatusAssignedOrPendingActivationVfModule(execution);
+ verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf,
+ OrchestrationStatus.ASSIGNED);
+ assertEquals("", vfModule.getHeatStackId());
+ }
+
+ @Test
+ public void updateOrchestrationStatusAssignedOrPendingActivationVfModuleMultiStageButNotAlacarteTest()
+ throws Exception {
+ execution.setVariable("aLaCarte", false);
+ ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setMultiStageDesign("true");
+ genericVnf.setModelInfoGenericVnf(modelInfoGenericVnf);
+ doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf,
+ OrchestrationStatus.ASSIGNED);
+ aaiUpdateTasks.updateOrchestrationStatusAssignedOrPendingActivationVfModule(execution);
+ verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf,
+ OrchestrationStatus.ASSIGNED);
+ assertEquals("", vfModule.getHeatStackId());
+ }
+
+ @Test
+ public void updateOrchestrationStatusAssignedOrPendingActivationVfModuleWithMultiStageTest() throws Exception {
+ execution.setVariable("aLaCarte", true);
+ ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setMultiStageDesign("true");
+ genericVnf.setModelInfoGenericVnf(modelInfoGenericVnf);
+ doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf,
+ OrchestrationStatus.PENDING_ACTIVATION);
+ aaiUpdateTasks.updateOrchestrationStatusAssignedOrPendingActivationVfModule(execution);
+ verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf,
+ OrchestrationStatus.PENDING_ACTIVATION);
+ assertEquals("", vfModule.getHeatStackId());
+ }
+
+ @Test
+ public void updateOrchestrationStatusAssignedOrPendingActivationVfModuleExceptionTest() throws Exception {
+ execution.setVariable("aLaCarte", true);
+ doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule,
+ genericVnf, OrchestrationStatus.ASSIGNED);
+
+ expectedException.expect(BpmnError.class);
+
+ aaiUpdateTasks.updateOrchestrationStatusAssignedOrPendingActivationVfModule(execution);
+ }
+
+ @Test
+ public void updateOrchestrationStatusCreatedVfModuleTest() throws Exception {
+ doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf,
+ OrchestrationStatus.CREATED);
+ aaiUpdateTasks.updateOrchestrationStatusCreatedVfModule(execution);
+ verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf,
+ OrchestrationStatus.CREATED);
+ }
+
+ @Test
+ public void updateOrchestrationStatusCreatedVfModuleExceptionTest() throws Exception {
+ doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule,
+ genericVnf, OrchestrationStatus.CREATED);
+
+ expectedException.expect(BpmnError.class);
+
+ aaiUpdateTasks.updateOrchestrationStatusCreatedVfModule(execution);
+ }
+
+ @Test
+ public void updateOrchestrationStatusPendingActivatefModuleTest() throws Exception {
+ doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf,
+ OrchestrationStatus.PENDING_ACTIVATION);
+
+ aaiUpdateTasks.updateOrchestrationStatusPendingActivationVfModule(execution);
+
+ verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf,
+ OrchestrationStatus.PENDING_ACTIVATION);
+ }
+
+ @Test
+ public void updateOrchestrationStatusPendingActivatefModuleExceptionTest() throws Exception {
+ doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule,
+ genericVnf, OrchestrationStatus.PENDING_ACTIVATION);
+
+ expectedException.expect(BpmnError.class);
+
+ aaiUpdateTasks.updateOrchestrationStatusPendingActivationVfModule(execution);
+ }
+
+ @Test
+ public void updateOrchestrationStatusDectivateVfModuleTest() throws Exception {
+ doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf,
+ OrchestrationStatus.CREATED);
+
+ aaiUpdateTasks.updateOrchestrationStatusDeactivateVfModule(execution);
+
+ verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf,
+ OrchestrationStatus.CREATED);
+ }
+
+ @Test
+ public void updateOrchestrationStatusDectivateVfModuleExceptionTest() throws Exception {
+ doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule,
+ genericVnf, OrchestrationStatus.CREATED);
+
+ expectedException.expect(BpmnError.class);
+
+ aaiUpdateTasks.updateOrchestrationStatusDeactivateVfModule(execution);
+ }
+
+ @Test
+ public void updateHeatStackIdVfModuleTest() throws Exception {
+ execution.setVariable("heatStackId", "newHeatStackId");
+ doNothing().when(aaiVfModuleResources).updateHeatStackIdVfModule(vfModule, genericVnf);
+
+ aaiUpdateTasks.updateHeatStackIdVfModule(execution);
+
+ verify(aaiVfModuleResources, times(1)).updateHeatStackIdVfModule(vfModule, genericVnf);
+ assertEquals("newHeatStackId", vfModule.getHeatStackId());
+ }
+
+ @Test
+ public void updateHeatStackIdVfModuleToNullTest() throws Exception {
+ execution.setVariable("heatStackId", null);
+ doNothing().when(aaiVfModuleResources).updateHeatStackIdVfModule(vfModule, genericVnf);
+
+ aaiUpdateTasks.updateHeatStackIdVfModule(execution);
+
+ verify(aaiVfModuleResources, times(1)).updateHeatStackIdVfModule(vfModule, genericVnf);
+ assertEquals(vfModule.getHeatStackId(), "");
+ }
+
+ @Test
+ public void updateHeatStackIdVfModuleExceptionTest() throws Exception {
+ doThrow(RuntimeException.class).when(aaiVfModuleResources).updateHeatStackIdVfModule(vfModule, genericVnf);
+
+ expectedException.expect(BpmnError.class);
+
+ aaiUpdateTasks.updateHeatStackIdVfModule(execution);
+ }
+
+ @Test
+ public void updateOrchestrationStatusActiveVolumeGroupTest() throws Exception {
+ doNothing().when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion,
+ OrchestrationStatus.ACTIVE);
+
+ aaiUpdateTasks.updateOrchestrationStatusActiveVolumeGroup(execution);
+
+ verify(aaiVolumeGroupResources, times(1)).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion,
+ OrchestrationStatus.ACTIVE);
+ }
+
+ @Test
+ public void updateOrchestrationStatusActiveVolumeGroupExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup,
+ cloudRegion, OrchestrationStatus.ACTIVE);
+ aaiUpdateTasks.updateOrchestrationStatusActiveVolumeGroup(execution);
+ }
+
+ @Test
+ public void updateOrchestrationStatusCreatedVolumeGroupTest() throws Exception {
+ doNothing().when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion,
+ OrchestrationStatus.CREATED);
+
+ aaiUpdateTasks.updateOrchestrationStatusCreatedVolumeGroup(execution);
+
+ verify(aaiVolumeGroupResources, times(1)).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion,
+ OrchestrationStatus.CREATED);
+ }
+
+ @Test
+ public void updateOrchestrationStatusCreatedVolumeGroupExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup,
+ cloudRegion, OrchestrationStatus.CREATED);
+ aaiUpdateTasks.updateOrchestrationStatusCreatedVolumeGroup(execution);
+ }
+
+ @Test
+ public void test_updateOrchestrationStatusAssignedVolumeGroup() throws Exception {
+ doNothing().when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion,
+ OrchestrationStatus.ASSIGNED);
+
+ aaiUpdateTasks.updateOrchestrationStatusAssignedVolumeGroup(execution);
+
+ verify(aaiVolumeGroupResources, times(1)).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion,
+ OrchestrationStatus.ASSIGNED);
+ assertEquals("", volumeGroup.getHeatStackId());
+ }
+
+ @Test
+ public void test_updateOrchestrationStatusAssignedVolumeGroup_exception() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup,
+ cloudRegion, OrchestrationStatus.ASSIGNED);
+ aaiUpdateTasks.updateOrchestrationStatusAssignedVolumeGroup(execution);
+ }
+
+ @Test
+ public void updateHeatStackIdVolumeGroupTest() throws Exception {
+ execution.setVariable("heatStackId", "newHeatStackId");
+ doNothing().when(aaiVolumeGroupResources).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion);
+
+ aaiUpdateTasks.updateHeatStackIdVolumeGroup(execution);
+
+ verify(aaiVolumeGroupResources, times(1)).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion);
+ assertEquals("newHeatStackId", volumeGroup.getHeatStackId());
+ }
+
+ @Test
+ public void updateHeatStackIdVolumeGroupToNullTest() throws Exception {
+ execution.setVariable("heatStackId", null);
+ doNothing().when(aaiVolumeGroupResources).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion);
+
+ aaiUpdateTasks.updateHeatStackIdVolumeGroup(execution);
+
+ verify(aaiVolumeGroupResources, times(1)).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion);
+ assertEquals(volumeGroup.getHeatStackId(), "");
+ }
+
+ @Test
+ public void updateHeatStackIdVolumeGroupExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(aaiVolumeGroupResources).updateHeatStackIdVolumeGroup(volumeGroup,
+ cloudRegion);
+ aaiUpdateTasks.updateHeatStackIdVolumeGroup(execution);
+ }
+
+ @Test
+ public void updateNetworkExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ doThrow(RuntimeException.class).when(aaiNetworkResources).updateNetwork(network);
+
+ aaiUpdateTasks.updateNetwork(execution, OrchestrationStatus.ACTIVE);
+ }
+
+ @Test
+ public void updateOstatusActivedNetworkCollectionTest() throws Exception {
+ doNothing().when(aaiCollectionResources).updateCollection(serviceInstance.getCollection());
+ aaiUpdateTasks.updateOrchestrationStatusActiveNetworkCollection(execution);
+ verify(aaiCollectionResources, times(1)).updateCollection(serviceInstance.getCollection());
+ }
+
+ @Test
+ public void updateOstatusActiveNetworkColectionExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(aaiCollectionResources).updateCollection(serviceInstance.getCollection());
+ aaiUpdateTasks.updateOrchestrationStatusActiveNetworkCollection(execution);
+ }
+
+ @Test
+ public void updateOrchestrationStatusActivateVfModuleTest() throws Exception {
+ doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf,
+ OrchestrationStatus.ACTIVE);
+
+ aaiUpdateTasks.updateOrchestrationStatusActivateVfModule(execution);
+
+ verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf,
+ OrchestrationStatus.ACTIVE);
+ }
+
+ @Test
+ public void updateOrchestrationStatusActivateVfModuleExceptionTest() throws Exception {
+ doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule,
+ genericVnf, OrchestrationStatus.ACTIVE);
+
+ expectedException.expect(BpmnError.class);
+
+ aaiUpdateTasks.updateOrchestrationStatusActivateVfModule(execution);
+ }
+
+ @Test
+ public void updateNetworkCreatedTest() throws Exception {
+ CreateNetworkResponse createNetworkResponse = new CreateNetworkResponse();
+ createNetworkResponse.setNetworkFqdn("testNetworkFqdn");
+ createNetworkResponse.setNetworkStackId("testNetworkStackId");
+ HashMap<String, String> subnetMap = new HashMap<>();
+ subnetMap.put("testSubnetId", "testNeutronSubnetId");
+ createNetworkResponse.setSubnetMap(subnetMap);
+
+ network.getSubnets().add(subnet);
+
+ execution.setVariable("createNetworkResponse", createNetworkResponse);
+
+ doNothing().when(aaiNetworkResources).updateNetwork(network);
+ doNothing().when(aaiNetworkResources).updateSubnet(network, subnet);
+
+ aaiUpdateTasks.updateNetworkCreated(execution);
+ verify(aaiNetworkResources, times(1)).updateNetwork(network);
+ verify(aaiNetworkResources, times(1)).updateSubnet(network, subnet);
+
+ assertEquals(createNetworkResponse.getNetworkFqdn(), network.getContrailNetworkFqdn());
+ assertEquals(OrchestrationStatus.CREATED, network.getOrchestrationStatus());
+ assertEquals(createNetworkResponse.getNetworkStackId(), network.getHeatStackId());
+ assertEquals(createNetworkResponse.getNeutronNetworkId(), network.getNeutronNetworkId());
+ String neutronSubnetId = createNetworkResponse.getSubnetMap().entrySet().iterator().next().getValue();
+ assertEquals(neutronSubnetId, network.getSubnets().get(0).getNeutronSubnetId());
+ }
+
+ @Test
+ public void updateNetworkUpdatedTest() throws Exception {
+ UpdateNetworkResponse updateNetworkResponse = new UpdateNetworkResponse();
+ updateNetworkResponse.setNeutronNetworkId("testNeutronNetworkId");
+ HashMap<String, String> subnetMap = new HashMap<>();
+ subnetMap.put("testSubnetId", "testNeutronSubnetId");
+ updateNetworkResponse.setSubnetMap(subnetMap);
+
+ network.getSubnets().add(subnet);
+
+ execution.setVariable("updateNetworkResponse", updateNetworkResponse);
+
+ doNothing().when(aaiNetworkResources).updateNetwork(network);
+ doNothing().when(aaiNetworkResources).updateSubnet(network, subnet);
+
+ aaiUpdateTasks.updateNetworkUpdated(execution);
+ verify(aaiNetworkResources, times(1)).updateNetwork(network);
+ verify(aaiNetworkResources, times(1)).updateSubnet(network, subnet);
+
+ String neutronSubnetId = updateNetworkResponse.getSubnetMap().entrySet().iterator().next().getValue();
+ assertEquals(neutronSubnetId, network.getSubnets().get(0).getNeutronSubnetId());
+ }
+
+ @Test
+ public void updateOrchestrationStatusNetworkTest() {
+ AAIUpdateTasks spy = Mockito.spy(new AAIUpdateTasks());
+ doNothing().when(spy).updateNetwork(eq(execution), any());
+ spy.updateOrchestrationStatusActiveNetwork(execution);
+ verify(spy, times(1)).updateNetwork(execution, OrchestrationStatus.ACTIVE);
+ spy.updateOrchestrationStatusAssignedNetwork(execution);
+ verify(spy, times(1)).updateNetwork(execution, OrchestrationStatus.ASSIGNED);
+ spy.updateOrchestrationStatusCreatedNetwork(execution);
+ verify(spy, times(1)).updateNetwork(execution, OrchestrationStatus.CREATED);
+ }
+
+ @Test
+ public void updateNetworkAAITest() {
+
+ L3Network spy = spy(new L3Network());
+ L3Network shallowCopy = mock(L3Network.class);
+ Subnet mockSubnet = mock(Subnet.class);
+ Subnet shallowCopySubnet = mock(Subnet.class);
+ when(mockSubnet.shallowCopyId()).thenReturn(shallowCopySubnet);
+ doReturn(shallowCopy).when(spy).shallowCopyId();
+
+ doNothing().when(aaiNetworkResources).updateNetwork(network);
+ doNothing().when(aaiNetworkResources).updateSubnet(network, subnet);
+
+ spy.getSubnets().add(mockSubnet);
+ aaiUpdateTasks.updateNetworkAAI(spy, OrchestrationStatus.CREATED);
+
+ verify(shallowCopy, times(1)).setOrchestrationStatus(OrchestrationStatus.CREATED);
+ verify(spy, times(1)).setOrchestrationStatus(OrchestrationStatus.CREATED);
+ verify(shallowCopySubnet, times(1)).setOrchestrationStatus(OrchestrationStatus.CREATED);
+ }
+
+ @Test
+ public void updateNetworkCreatedkExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(aaiNetworkResources).updateNetwork(network);
+ aaiUpdateTasks.updateNetworkCreated(execution);
+ }
+
+ @Test
+ public void updateObjectNetworkTest() {
+ doNothing().when(aaiNetworkResources).updateNetwork(network);
+
+ aaiUpdateTasks.updateObjectNetwork(execution);
+
+ verify(aaiNetworkResources, times(1)).updateNetwork(network);
+ }
+
+ @Test
+ public void updateObjectNetworkExceptionText() {
+ expectedException.expect(BpmnError.class);
+
+ doThrow(RuntimeException.class).when(aaiNetworkResources).updateNetwork(network);
+
+ aaiUpdateTasks.updateObjectNetwork(execution);
+ }
+
+ @Test
+ public void test_updateServiceInstance() {
+ doNothing().when(aaiServiceInstanceResources).updateServiceInstance(serviceInstance);
+ aaiUpdateTasks.updateServiceInstance(execution);
+ verify(aaiServiceInstanceResources, times(1)).updateServiceInstance(serviceInstance);
+ }
+
+ @Test
+ public void test_updateServiceInstance_exception() {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(aaiServiceInstanceResources).updateServiceInstance(serviceInstance);
+ aaiUpdateTasks.updateServiceInstance(execution);
+ }
+
+ @Test
+ public void updateObjectVnfTest() {
+ doNothing().when(aaiVnfResources).updateObjectVnf(genericVnf);
+
+ aaiUpdateTasks.updateObjectVnf(execution);
+
+ verify(aaiVnfResources, times(1)).updateObjectVnf(genericVnf);
+ }
+
+ @Test
+ public void updateObjectVnfExceptionTest() {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(aaiVnfResources).updateObjectVnf(genericVnf);
+ aaiUpdateTasks.updateObjectVnf(execution);
+ }
+
+ @Test
+ public void updateOrchestrationStatusDeleteVfModuleTest() throws Exception {
+ doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf,
+ OrchestrationStatus.ASSIGNED);
+
+ aaiUpdateTasks.updateOrchestrationStatusDeleteVfModule(execution);
+
+ verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf,
+ OrchestrationStatus.ASSIGNED);
+ assertEquals("", vfModule.getHeatStackId());
+ }
+
+ @Test
+ public void updateModelVfModuleTest() {
+ doNothing().when(aaiVfModuleResources).changeAssignVfModule(vfModule, genericVnf);
+ aaiUpdateTasks.updateModelVfModule(execution);
+ verify(aaiVfModuleResources, times(1)).changeAssignVfModule(vfModule, genericVnf);
+ }
+
+ @Test
+ public void updateModelVfModuleExceptionTest() {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(aaiVfModuleResources).changeAssignVfModule(vfModule, genericVnf);
+ aaiUpdateTasks.updateModelVfModule(execution);
+ }
+
+ @Test
+ public void updateOrchestrationStatusDeactivateFabricConfigurationTest() throws Exception {
+ gBBInput = execution.getGeneralBuildingBlock();
+ doNothing().when(aaiConfigurationResources).updateOrchestrationStatusConfiguration(configuration,
+ OrchestrationStatus.ASSIGNED);
+
+ aaiUpdateTasks.updateOrchestrationStatusDeactivateFabricConfiguration(execution);
+
+ verify(aaiConfigurationResources, times(1)).updateOrchestrationStatusConfiguration(configuration,
+ OrchestrationStatus.ASSIGNED);
+ }
+
+ @Test
+ public void updateOrchestrationStatusActivateFabricConfigurationTest() throws Exception {
+ gBBInput = execution.getGeneralBuildingBlock();
+ doNothing().when(aaiConfigurationResources).updateOrchestrationStatusConfiguration(configuration,
+ OrchestrationStatus.ACTIVE);
+
+ aaiUpdateTasks.updateOrchestrationStatusActivateFabricConfiguration(execution);
+
+ verify(aaiConfigurationResources, times(1)).updateOrchestrationStatusConfiguration(configuration,
+ OrchestrationStatus.ACTIVE);
+ }
+
+ @Test
+ public void updateContrailServiceInstanceFqdnVfModuleTest() throws Exception {
+ execution.setVariable("contrailServiceInstanceFqdn", "newContrailServiceInstanceFqdn");
+ doNothing().when(aaiVfModuleResources).updateContrailServiceInstanceFqdnVfModule(vfModule, genericVnf);
+
+ aaiUpdateTasks.updateContrailServiceInstanceFqdnVfModule(execution);
+
+ verify(aaiVfModuleResources, times(1)).updateContrailServiceInstanceFqdnVfModule(vfModule, genericVnf);
+ assertEquals("newContrailServiceInstanceFqdn", vfModule.getContrailServiceInstanceFqdn());
+ }
+
+ @Test
+ public void updateContrailServiceInstanceFqdnVfModuleNoUpdateTest() throws Exception {
+ aaiUpdateTasks.updateContrailServiceInstanceFqdnVfModule(execution);
+ verify(aaiVfModuleResources, times(0)).updateContrailServiceInstanceFqdnVfModule(vfModule, genericVnf);
+ }
+
+ @Test
+ public void updateIpv4OamAddressVnfTest() throws Exception {
+ execution.setVariable("oamManagementV4Address", "newIpv4OamAddress");
+ doNothing().when(aaiVnfResources).updateObjectVnf(genericVnf);
+
+ aaiUpdateTasks.updateIpv4OamAddressVnf(execution);
+
+ verify(aaiVnfResources, times(1)).updateObjectVnf(genericVnf);
+ assertEquals("newIpv4OamAddress", genericVnf.getIpv4OamAddress());
+ }
+
+ @Test
+ public void updateIpv4OamAddressVnfNoUpdateTest() throws Exception {
+ aaiUpdateTasks.updateIpv4OamAddressVnf(execution);
+ verify(aaiVnfResources, times(0)).updateObjectVnf(genericVnf);
+ }
+
+ @Test
+ public void updateManagementV6AddressVnfTest() throws Exception {
+ execution.setVariable("oamManagementV6Address", "newManagementV6Address");
+ doNothing().when(aaiVnfResources).updateObjectVnf(genericVnf);
+
+ aaiUpdateTasks.updateManagementV6AddressVnf(execution);
+
+ verify(aaiVnfResources, times(1)).updateObjectVnf(genericVnf);
+ assertEquals("newManagementV6Address", genericVnf.getManagementV6Address());
+ }
+
+ @Test
+ public void updateManagementV6AddressVnfNoUpdateTest() throws Exception {
+ aaiUpdateTasks.updateManagementV6AddressVnf(execution);
+ verify(aaiVnfResources, times(0)).updateObjectVnf(genericVnf);
+ }
+
+ @Test
+ public void updateOrchestrationStatusVnfConfigureTest() throws Exception {
+ doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf,
+ OrchestrationStatus.CONFIGURE);
+
+ aaiUpdateTasks.updateOrchestrationStausConfigDeployConfigureVnf(execution);
+ }
+
+ @Test
+ public void updateOrchestrationStatusVnfConfiguredTest() throws Exception {
+ doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf,
+ OrchestrationStatus.CONFIGURED);
+
+ aaiUpdateTasks.updateOrchestrationStausConfigDeployConfiguredVnf(execution);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivityTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivityTest.java
index ee7a9ad952..56ff813e73 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivityTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivityTest.java
@@ -22,14 +22,11 @@ package org.onap.so.bpmn.infrastructure.activity;
import static org.junit.Assert.assertEquals;
-
import java.nio.file.Files;
import java.nio.file.Paths;
-
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
import org.junit.Before;
-
import org.junit.Test;
import org.mockito.InjectMocks;
import org.onap.so.bpmn.BaseTaskTest;
@@ -38,40 +35,41 @@ import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
import org.springframework.beans.factory.annotation.Autowired;
public class ExecuteActivityTest extends BaseTaskTest {
- @InjectMocks
- protected ExecuteActivity executeActivity = new ExecuteActivity();
-
- private DelegateExecution execution;
-
- @Before
- public void before() throws Exception {
- execution = new DelegateExecutionFake();
- execution.setVariable("vnfType", "testVnfType");
- execution.setVariable("requestAction", "testRequestAction");
- execution.setVariable("mso-request-id", "testMsoRequestId");
- execution.setVariable("vnfId", "testVnfId");
- execution.setVariable("serviceInstanceId", "testServiceInstanceId");
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json")));
- execution.setVariable("bpmnRequest", bpmnRequest);
- }
-
- @Test
- public void buildBuildingBlock_Test(){
- BuildingBlock bb = executeActivity.buildBuildingBlock("testActivityName");
- assertEquals(bb.getBpmnFlowName(), "testActivityName");
- assertEquals(bb.getKey(), "");
- }
-
- @Test
- public void executeBuildingBlock_Test() throws Exception {
- BuildingBlock bb = executeActivity.buildBuildingBlock("testActivityName");
- ExecuteBuildingBlock ebb = executeActivity.buildExecuteBuildingBlock(execution, "testMsoRequestId", bb);
- assertEquals(ebb.getVnfType(), "testVnfType");
- assertEquals(ebb.getRequestAction(), "testRequestAction");
- assertEquals(ebb.getRequestId(), "testMsoRequestId");
- assertEquals(ebb.getWorkflowResourceIds().getVnfId(), "testVnfId");
- assertEquals(ebb.getWorkflowResourceIds().getServiceInstanceId(), "testServiceInstanceId");
- assertEquals(ebb.getBuildingBlock(), bb);
- }
-
+ @InjectMocks
+ protected ExecuteActivity executeActivity = new ExecuteActivity();
+
+ private DelegateExecution execution;
+
+ @Before
+ public void before() throws Exception {
+ execution = new DelegateExecutionFake();
+ execution.setVariable("vnfType", "testVnfType");
+ execution.setVariable("requestAction", "testRequestAction");
+ execution.setVariable("mso-request-id", "testMsoRequestId");
+ execution.setVariable("vnfId", "testVnfId");
+ execution.setVariable("serviceInstanceId", "testServiceInstanceId");
+ String bpmnRequest =
+ new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ }
+
+ @Test
+ public void buildBuildingBlock_Test() {
+ BuildingBlock bb = executeActivity.buildBuildingBlock("testActivityName");
+ assertEquals(bb.getBpmnFlowName(), "testActivityName");
+ assertEquals(bb.getKey(), "");
+ }
+
+ @Test
+ public void executeBuildingBlock_Test() throws Exception {
+ BuildingBlock bb = executeActivity.buildBuildingBlock("testActivityName");
+ ExecuteBuildingBlock ebb = executeActivity.buildExecuteBuildingBlock(execution, "testMsoRequestId", bb);
+ assertEquals(ebb.getVnfType(), "testVnfType");
+ assertEquals(ebb.getRequestAction(), "testRequestAction");
+ assertEquals(ebb.getRequestId(), "testMsoRequestId");
+ assertEquals(ebb.getWorkflowResourceIds().getVnfId(), "testVnfId");
+ assertEquals(ebb.getWorkflowResourceIds().getServiceInstanceId(), "testServiceInstanceId");
+ assertEquals(ebb.getBuildingBlock(), bb);
+ }
+
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterCreateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterCreateTasksTest.java
index 72f6a08ee7..00dfd4e236 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterCreateTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterCreateTasksTest.java
@@ -27,10 +27,8 @@ import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import java.util.Map;
import java.util.Optional;
-
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentMatchers;
@@ -47,61 +45,69 @@ import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
import org.onap.so.client.exception.BBObjectNotFoundException;
-public class NetworkAdapterCreateTasksTest extends BaseTaskTest{
- @InjectMocks
- private NetworkAdapterCreateTasks networkAdapterCreateTasks = new NetworkAdapterCreateTasks();
+public class NetworkAdapterCreateTasksTest extends BaseTaskTest {
+ @InjectMocks
+ private NetworkAdapterCreateTasks networkAdapterCreateTasks = new NetworkAdapterCreateTasks();
+
+ private ServiceInstance serviceInstance;
+ private RequestContext requestContext;
+ private CloudRegion cloudRegion;
+ private OrchestrationContext orchestrationContext;
+ private L3Network l3Network;
+ private Map<String, String> userInput;
+ private Customer customer;
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ customer = setCustomer();
+ serviceInstance = setServiceInstance();
+ l3Network = setL3Network();
+ userInput = setUserInput();
+ userInput.put("userInputKey1", "userInputValue1");
+ requestContext = setRequestContext();
+ cloudRegion = setCloudRegion();
+ orchestrationContext = setOrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(true);
+
+
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(l3Network);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
+ .thenReturn(serviceInstance);
- private ServiceInstance serviceInstance;
- private RequestContext requestContext;
- private CloudRegion cloudRegion;
- private OrchestrationContext orchestrationContext;
- private L3Network l3Network;
- private Map<String, String> userInput;
- private Customer customer;
+ }
- @Before
- public void before() throws BBObjectNotFoundException {
- customer = setCustomer();
- serviceInstance = setServiceInstance();
- l3Network = setL3Network();
- userInput = setUserInput();
- userInput.put("userInputKey1", "userInputValue1");
- requestContext = setRequestContext();
- cloudRegion = setCloudRegion();
- orchestrationContext = setOrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(true);
-
+ @Test
+ public void createNetworkTest() throws Exception {
+ String cloudRegionPo = "cloudRegionPo";
+ CreateNetworkRequest createNetworkRequest = new CreateNetworkRequest();
+ execution.setVariable("cloudRegionPo", cloudRegionPo);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(l3Network);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))).thenReturn(serviceInstance);
-
- }
-
- @Test
- public void createNetworkTest() throws Exception {
- String cloudRegionPo = "cloudRegionPo";
- CreateNetworkRequest createNetworkRequest = new CreateNetworkRequest();
- execution.setVariable("cloudRegionPo", cloudRegionPo);
+ doReturn(createNetworkRequest).when(networkAdapterObjectMapper).createNetworkRequestMapper(
+ isA(RequestContext.class), isA(CloudRegion.class), isA(OrchestrationContext.class),
+ isA(ServiceInstance.class), isA(L3Network.class), isA(Map.class), isA(String.class),
+ isA(Customer.class));
+ networkAdapterCreateTasks.createNetwork(execution);
+ verify(networkAdapterObjectMapper, times(1)).createNetworkRequestMapper(requestContext, cloudRegion,
+ orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, customer);
+ assertEquals(createNetworkRequest, execution.getVariable("networkAdapterRequest"));
+ }
- doReturn(createNetworkRequest).when(networkAdapterObjectMapper).createNetworkRequestMapper(isA(RequestContext.class), isA(CloudRegion.class), isA(OrchestrationContext.class), isA(ServiceInstance.class), isA(L3Network.class), isA(Map.class), isA(String.class), isA(Customer.class));
- networkAdapterCreateTasks.createNetwork(execution);
- verify(networkAdapterObjectMapper, times(1)).createNetworkRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, customer);
- assertEquals(createNetworkRequest, execution.getVariable("networkAdapterRequest"));
- }
-
- @Test
- public void rollbackCreateNetworkTest() throws Exception {
- CreateNetworkResponse createNetworkResponse = new CreateNetworkResponse();
- createNetworkResponse.setNetworkStackId("networkStackId");
- createNetworkResponse.setNetworkCreated(true);
- execution.setVariable("createNetworkResponse", createNetworkResponse);
- Optional<CreateNetworkResponse> oCreateNetworkResponse = Optional.of(createNetworkResponse);
+ @Test
+ public void rollbackCreateNetworkTest() throws Exception {
+ CreateNetworkResponse createNetworkResponse = new CreateNetworkResponse();
+ createNetworkResponse.setNetworkStackId("networkStackId");
+ createNetworkResponse.setNetworkCreated(true);
+ execution.setVariable("createNetworkResponse", createNetworkResponse);
+ Optional<CreateNetworkResponse> oCreateNetworkResponse = Optional.of(createNetworkResponse);
- String cloudRegionPo = "cloudRegionPo";
- execution.setVariable("cloudRegionPo", cloudRegionPo);
+ String cloudRegionPo = "cloudRegionPo";
+ execution.setVariable("cloudRegionPo", cloudRegionPo);
- doReturn(oCreateNetworkResponse).when(networkAdapterResources).rollbackCreateNetwork(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, createNetworkResponse);
- networkAdapterCreateTasks.rollbackCreateNetwork(execution);
- verify(networkAdapterResources, times(1)).rollbackCreateNetwork(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, createNetworkResponse);
- }
+ doReturn(oCreateNetworkResponse).when(networkAdapterResources).rollbackCreateNetwork(requestContext,
+ cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo,
+ createNetworkResponse);
+ networkAdapterCreateTasks.rollbackCreateNetwork(execution);
+ verify(networkAdapterResources, times(1)).rollbackCreateNetwork(requestContext, cloudRegion,
+ orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, createNetworkResponse);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterDeleteTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterDeleteTasksTest.java
index ceb4796443..eb481651f0 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterDeleteTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterDeleteTasksTest.java
@@ -27,9 +27,7 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import java.io.UnsupportedEncodingException;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
@@ -48,44 +46,48 @@ import org.onap.so.client.adapter.network.NetworkAdapterClientException;
import org.onap.so.client.exception.BBObjectNotFoundException;
-public class NetworkAdapterDeleteTasksTest extends BaseTaskTest{
-
- @InjectMocks
- private NetworkAdapterDeleteTasks networkAdapterDeleteTasks = new NetworkAdapterDeleteTasks();
+public class NetworkAdapterDeleteTasksTest extends BaseTaskTest {
+
+ @InjectMocks
+ private NetworkAdapterDeleteTasks networkAdapterDeleteTasks = new NetworkAdapterDeleteTasks();
- private ServiceInstance serviceInstance;
- private L3Network l3Network;
- private RequestContext requestContext;
- private CloudRegion cloudRegion;
+ private ServiceInstance serviceInstance;
+ private L3Network l3Network;
+ private RequestContext requestContext;
+ private CloudRegion cloudRegion;
- @Before
- public void before() throws BBObjectNotFoundException {
- serviceInstance = setServiceInstance();
- l3Network = setL3Network();
- requestContext = setRequestContext();
- cloudRegion = setCloudRegion();
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ serviceInstance = setServiceInstance();
+ l3Network = setL3Network();
+ requestContext = setRequestContext();
+ cloudRegion = setCloudRegion();
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(l3Network);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))).thenReturn(serviceInstance);
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
- }
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(l3Network);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
+ .thenReturn(serviceInstance);
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
+ }
- @Test
- public void test_deleteNetwork() throws UnsupportedEncodingException, NetworkAdapterClientException {
- DeleteNetworkRequest deleteNetworkRequest = new DeleteNetworkRequest();
- doReturn(deleteNetworkRequest).when(networkAdapterObjectMapper).deleteNetworkRequestMapper(requestContext, cloudRegion, serviceInstance, l3Network);
+ @Test
+ public void test_deleteNetwork() throws UnsupportedEncodingException, NetworkAdapterClientException {
+ DeleteNetworkRequest deleteNetworkRequest = new DeleteNetworkRequest();
+ doReturn(deleteNetworkRequest).when(networkAdapterObjectMapper).deleteNetworkRequestMapper(requestContext,
+ cloudRegion, serviceInstance, l3Network);
- networkAdapterDeleteTasks.deleteNetwork(execution);
- verify(networkAdapterObjectMapper, times(1)).deleteNetworkRequestMapper(requestContext, cloudRegion, serviceInstance, l3Network);
- }
+ networkAdapterDeleteTasks.deleteNetwork(execution);
+ verify(networkAdapterObjectMapper, times(1)).deleteNetworkRequestMapper(requestContext, cloudRegion,
+ serviceInstance, l3Network);
+ }
- @Test
- public void test_deleteNetwork_exception() throws UnsupportedEncodingException, NetworkAdapterClientException {
- expectedException.expect(BpmnError.class);
+ @Test
+ public void test_deleteNetwork_exception() throws UnsupportedEncodingException, NetworkAdapterClientException {
+ expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(networkAdapterObjectMapper).
- deleteNetworkRequestMapper(any(RequestContext.class), any(CloudRegion.class), any(ServiceInstance.class), eq(l3Network));
- networkAdapterDeleteTasks.deleteNetwork(execution);
- }
+ doThrow(RuntimeException.class).when(networkAdapterObjectMapper).deleteNetworkRequestMapper(
+ any(RequestContext.class), any(CloudRegion.class), any(ServiceInstance.class), eq(l3Network));
+ networkAdapterDeleteTasks.deleteNetwork(execution);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java
index c11dc822b4..d0cee42178 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java
@@ -23,15 +23,12 @@ package org.onap.so.bpmn.infrastructure.adapter.network.tasks;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
-
import javax.xml.bind.JAXBException;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
import org.junit.Before;
import org.junit.Test;
-
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.onap.so.adapters.nwrest.CreateNetworkResponse;
@@ -42,7 +39,6 @@ import org.onap.so.bpmn.BaseTaskTest;
import org.onap.so.client.exception.BadResponseException;
import org.onap.so.client.exception.ExceptionBuilder;
import org.onap.so.client.exception.MapperException;
-
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
@@ -55,69 +51,74 @@ import static org.mockito.Mockito.verify;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
public class NetworkAdapterRestV1Test extends BaseTaskTest {
-
- @InjectMocks
- NetworkAdapterRestV1 networkAdapterRestV1Tasks = new NetworkAdapterRestV1();
- @Mock
- ExceptionBuilder exceptionBuilder = new ExceptionBuilder();
- @Before
- public void setup(){
- delegateExecution = new DelegateExecutionFake();
- }
-
- @Test
- public void testUnmarshalXml() throws IOException, JAXBException {
- String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><createNetworkResponse><messageId>ec37c121-e3ec-4697-8adf-2d7dca7044fc</messageId><networkCreated>true</networkCreated><networkFqdn>someNetworkFqdn</networkFqdn><networkId>991ec7bf-c9c4-4ac1-bb9c-4b61645bddb3</networkId><networkStackId>someStackId</networkStackId><neutronNetworkId>9c47521a-2916-4018-b2bc-71ab767497e3</neutronNetworkId><rollback><cloudId>someCloudId</cloudId><modelCustomizationUuid>b7171cdd-8b05-459b-80ef-2093150e8983</modelCustomizationUuid><msoRequest><requestId>90b32315-176e-4dab-bcf1-80eb97a1c4f4</requestId><serviceInstanceId>71e7db22-7907-4d78-8fcc-8d89d28e90be</serviceInstanceId></msoRequest><networkCreated>true</networkCreated><networkStackId>someStackId</networkStackId><networkType>SomeNetworkType</networkType><neutronNetworkId>9c47521a-2916-4018-b2bc-71ab767497e3</neutronNetworkId><tenantId>b60da4f71c1d4b35b8113d4eca6deaa1</tenantId></rollback><subnetMap><entry><key>6b381fa9-48ce-4e16-9978-d75309565bb6</key><value>bc1d5537-860b-4894-8eba-6faff41e648c</value></entry></subnetMap></createNetworkResponse>";
- CreateNetworkResponse response = (CreateNetworkResponse) new NetworkAdapterRestV1().unmarshalXml(xml, CreateNetworkResponse.class);
- String returnedXml = response.toXmlString();
- System.out.println(returnedXml);
- }
-
- @Test
- public void testUnmarshalXmlUpdate() throws IOException, JAXBException {
- UpdateNetworkResponse expectedResponse = new UpdateNetworkResponse();
- expectedResponse.setMessageId("ec100bcc-2659-4aa4-b4d8-3255715c2a51");
- expectedResponse.setNetworkId("80de31e3-cc78-4111-a9d3-5b92bf0a39eb");
- Map<String,String>subnetMap = new HashMap<String,String>();
- subnetMap.put("95cd8437-25f1-4238-8720-cbfe7fa81476", "d8d16606-5d01-4822-b160-9a0d257303e0");
- expectedResponse.setSubnetMap(subnetMap);
- String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><updateNetworkResponse><messageId>ec100bcc-2659-4aa4-b4d8-3255715c2a51</messageId><networkId>80de31e3-cc78-4111-a9d3-5b92bf0a39eb</networkId><subnetMap><entry><key>95cd8437-25f1-4238-8720-cbfe7fa81476</key><value>d8d16606-5d01-4822-b160-9a0d257303e0</value></entry></subnetMap></updateNetworkResponse>";
- UpdateNetworkResponse response = (UpdateNetworkResponse) new NetworkAdapterRestV1().unmarshalXml(xml, UpdateNetworkResponse.class);
- assertThat(expectedResponse, sameBeanAs(response));
- }
-
- @Test
- public void processCallbackTest() throws MapperException, BadResponseException, IOException{
- UpdateNetworkRequest updateNetworkRequest = new UpdateNetworkRequest();
- UpdateNetworkResponse updateNetworkResponse = new UpdateNetworkResponse();
- updateNetworkResponse.setMessageId("messageId");
- updateNetworkResponse.setNetworkId("networkId");
- delegateExecution.setVariable("networkAdapterRequest", updateNetworkRequest);
- delegateExecution.setVariable("NetworkAResponse_MESSAGE", updateNetworkResponse.toXmlString());
-
- networkAdapterRestV1Tasks.processCallback(delegateExecution);
-
- assertThat(updateNetworkResponse,sameBeanAs(delegateExecution.getVariable("updateNetworkResponse")));
- }
-
- @Test
- public void processCallbackErrorTest() throws MapperException, BadResponseException, IOException{
- UpdateNetworkRequest updateNetworkRequest = new UpdateNetworkRequest();
- UpdateNetworkError updateNetworkResponse = new UpdateNetworkError();
- updateNetworkResponse.setMessageId("messageId");
- updateNetworkResponse.setMessage("test error message");
- delegateExecution.setVariable("networkAdapterRequest", updateNetworkRequest);
- delegateExecution.setVariable("NetworkAResponse_MESSAGE", updateNetworkResponse.toXmlString());
-
- doThrow(new BpmnError("MSOWorkflowException")).when(exceptionBuilder).buildAndThrowWorkflowException(any(DelegateExecution.class), anyInt(), any(String.class));
- try {
- networkAdapterRestV1Tasks.processCallback(delegateExecution);
- }
- catch (BpmnError be){
- assertEquals("MSOWorkflowException",be.getErrorCode());
- }
- assertNull(delegateExecution.getVariable("updateNetworkResponse"));
- verify(exceptionBuilder, times(1)).buildAndThrowWorkflowException(any(DelegateExecution.class), eq(7000), eq("test error message"));
- }
+ @InjectMocks
+ NetworkAdapterRestV1 networkAdapterRestV1Tasks = new NetworkAdapterRestV1();
+ @Mock
+ ExceptionBuilder exceptionBuilder = new ExceptionBuilder();
+
+ @Before
+ public void setup() {
+ delegateExecution = new DelegateExecutionFake();
+ }
+
+ @Test
+ public void testUnmarshalXml() throws IOException, JAXBException {
+ String xml =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><createNetworkResponse><messageId>ec37c121-e3ec-4697-8adf-2d7dca7044fc</messageId><networkCreated>true</networkCreated><networkFqdn>someNetworkFqdn</networkFqdn><networkId>991ec7bf-c9c4-4ac1-bb9c-4b61645bddb3</networkId><networkStackId>someStackId</networkStackId><neutronNetworkId>9c47521a-2916-4018-b2bc-71ab767497e3</neutronNetworkId><rollback><cloudId>someCloudId</cloudId><modelCustomizationUuid>b7171cdd-8b05-459b-80ef-2093150e8983</modelCustomizationUuid><msoRequest><requestId>90b32315-176e-4dab-bcf1-80eb97a1c4f4</requestId><serviceInstanceId>71e7db22-7907-4d78-8fcc-8d89d28e90be</serviceInstanceId></msoRequest><networkCreated>true</networkCreated><networkStackId>someStackId</networkStackId><networkType>SomeNetworkType</networkType><neutronNetworkId>9c47521a-2916-4018-b2bc-71ab767497e3</neutronNetworkId><tenantId>b60da4f71c1d4b35b8113d4eca6deaa1</tenantId></rollback><subnetMap><entry><key>6b381fa9-48ce-4e16-9978-d75309565bb6</key><value>bc1d5537-860b-4894-8eba-6faff41e648c</value></entry></subnetMap></createNetworkResponse>";
+ CreateNetworkResponse response =
+ (CreateNetworkResponse) new NetworkAdapterRestV1().unmarshalXml(xml, CreateNetworkResponse.class);
+ String returnedXml = response.toXmlString();
+ System.out.println(returnedXml);
+ }
+
+ @Test
+ public void testUnmarshalXmlUpdate() throws IOException, JAXBException {
+ UpdateNetworkResponse expectedResponse = new UpdateNetworkResponse();
+ expectedResponse.setMessageId("ec100bcc-2659-4aa4-b4d8-3255715c2a51");
+ expectedResponse.setNetworkId("80de31e3-cc78-4111-a9d3-5b92bf0a39eb");
+ Map<String, String> subnetMap = new HashMap<String, String>();
+ subnetMap.put("95cd8437-25f1-4238-8720-cbfe7fa81476", "d8d16606-5d01-4822-b160-9a0d257303e0");
+ expectedResponse.setSubnetMap(subnetMap);
+ String xml =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><updateNetworkResponse><messageId>ec100bcc-2659-4aa4-b4d8-3255715c2a51</messageId><networkId>80de31e3-cc78-4111-a9d3-5b92bf0a39eb</networkId><subnetMap><entry><key>95cd8437-25f1-4238-8720-cbfe7fa81476</key><value>d8d16606-5d01-4822-b160-9a0d257303e0</value></entry></subnetMap></updateNetworkResponse>";
+ UpdateNetworkResponse response =
+ (UpdateNetworkResponse) new NetworkAdapterRestV1().unmarshalXml(xml, UpdateNetworkResponse.class);
+ assertThat(expectedResponse, sameBeanAs(response));
+ }
+
+ @Test
+ public void processCallbackTest() throws MapperException, BadResponseException, IOException {
+ UpdateNetworkRequest updateNetworkRequest = new UpdateNetworkRequest();
+ UpdateNetworkResponse updateNetworkResponse = new UpdateNetworkResponse();
+ updateNetworkResponse.setMessageId("messageId");
+ updateNetworkResponse.setNetworkId("networkId");
+ delegateExecution.setVariable("networkAdapterRequest", updateNetworkRequest);
+ delegateExecution.setVariable("NetworkAResponse_MESSAGE", updateNetworkResponse.toXmlString());
+
+ networkAdapterRestV1Tasks.processCallback(delegateExecution);
+
+ assertThat(updateNetworkResponse, sameBeanAs(delegateExecution.getVariable("updateNetworkResponse")));
+ }
+
+ @Test
+ public void processCallbackErrorTest() throws MapperException, BadResponseException, IOException {
+ UpdateNetworkRequest updateNetworkRequest = new UpdateNetworkRequest();
+ UpdateNetworkError updateNetworkResponse = new UpdateNetworkError();
+ updateNetworkResponse.setMessageId("messageId");
+ updateNetworkResponse.setMessage("test error message");
+ delegateExecution.setVariable("networkAdapterRequest", updateNetworkRequest);
+ delegateExecution.setVariable("NetworkAResponse_MESSAGE", updateNetworkResponse.toXmlString());
+
+ doThrow(new BpmnError("MSOWorkflowException")).when(exceptionBuilder)
+ .buildAndThrowWorkflowException(any(DelegateExecution.class), anyInt(), any(String.class));
+ try {
+ networkAdapterRestV1Tasks.processCallback(delegateExecution);
+ } catch (BpmnError be) {
+ assertEquals("MSOWorkflowException", be.getErrorCode());
+ }
+ assertNull(delegateExecution.getVariable("updateNetworkResponse"));
+ verify(exceptionBuilder, times(1)).buildAndThrowWorkflowException(any(DelegateExecution.class), eq(7000),
+ eq("test error message"));
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterUpdateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterUpdateTasksTest.java
index 0406ce09a3..af97c3d038 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterUpdateTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterUpdateTasksTest.java
@@ -30,11 +30,9 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import java.io.UnsupportedEncodingException;
import java.util.Map;
import java.util.Optional;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
@@ -56,45 +54,49 @@ import org.onap.so.client.adapter.network.NetworkAdapterClientException;
import org.onap.so.client.exception.BBObjectNotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
-public class NetworkAdapterUpdateTasksTest extends BaseTaskTest{
- @InjectMocks
- private NetworkAdapterUpdateTasks networkAdapterUpdateTasks = new NetworkAdapterUpdateTasks();
-
- private ServiceInstance serviceInstance;
- private L3Network network;
- private RequestContext requestContext;
- private CloudRegion cloudRegion;
- private OrchestrationContext orchestrationContext;
- private Map<String, String> userInput;
- private Customer customer;
-
- @Before
- public void before() throws BBObjectNotFoundException {
- customer = setCustomer();
- serviceInstance = setServiceInstance();
- network = setL3Network();
- requestContext = setRequestContext();
- cloudRegion = setCloudRegion();
- orchestrationContext = setOrchestrationContext();
- userInput = setUserInput();
- userInput.put("userInputKey1", "userInputValue1");
-
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))).thenReturn(serviceInstance);
-
- }
-
- @Test
- public void updateNetworkTest() throws Exception {
- String cloudRegionPo = "cloudRegionPo";
- UpdateNetworkRequest updateNetworkRequest = new UpdateNetworkRequest();
- execution.setVariable("cloudRegionPo", cloudRegionPo);
+public class NetworkAdapterUpdateTasksTest extends BaseTaskTest {
+ @InjectMocks
+ private NetworkAdapterUpdateTasks networkAdapterUpdateTasks = new NetworkAdapterUpdateTasks();
+
+ private ServiceInstance serviceInstance;
+ private L3Network network;
+ private RequestContext requestContext;
+ private CloudRegion cloudRegion;
+ private OrchestrationContext orchestrationContext;
+ private Map<String, String> userInput;
+ private Customer customer;
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ customer = setCustomer();
+ serviceInstance = setServiceInstance();
+ network = setL3Network();
+ requestContext = setRequestContext();
+ cloudRegion = setCloudRegion();
+ orchestrationContext = setOrchestrationContext();
+ userInput = setUserInput();
+ userInput.put("userInputKey1", "userInputValue1");
+
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
+ .thenReturn(serviceInstance);
+
+ }
+
+ @Test
+ public void updateNetworkTest() throws Exception {
+ String cloudRegionPo = "cloudRegionPo";
+ UpdateNetworkRequest updateNetworkRequest = new UpdateNetworkRequest();
+ execution.setVariable("cloudRegionPo", cloudRegionPo);
+
+ doReturn(updateNetworkRequest).when(networkAdapterObjectMapper).createNetworkUpdateRequestMapper(
+ isA(RequestContext.class), isA(CloudRegion.class), isA(OrchestrationContext.class),
+ isA(ServiceInstance.class), isA(L3Network.class), isA(Map.class), isA(Customer.class));
+ networkAdapterUpdateTasks.updateNetwork(execution);
+ verify(networkAdapterObjectMapper, times(1)).createNetworkUpdateRequestMapper(requestContext, cloudRegion,
+ orchestrationContext, serviceInstance, network, userInput, customer);
+ assertEquals(updateNetworkRequest, execution.getVariable("networkAdapterRequest"));
+ }
- doReturn(updateNetworkRequest).when(networkAdapterObjectMapper).createNetworkUpdateRequestMapper(isA(RequestContext.class), isA(CloudRegion.class), isA(OrchestrationContext.class), isA(ServiceInstance.class), isA(L3Network.class), isA(Map.class), isA(Customer.class));
- networkAdapterUpdateTasks.updateNetwork(execution);
- verify(networkAdapterObjectMapper, times(1)).createNetworkUpdateRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, network, userInput, customer);
- assertEquals(updateNetworkRequest, execution.getVariable("networkAdapterRequest"));
- }
-
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterCreateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterCreateTasksTest.java
index 32b3201d11..13f2b81fd9 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterCreateTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterCreateTasksTest.java
@@ -28,7 +28,6 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Test;
import org.mockito.ArgumentMatchers;
@@ -47,178 +46,197 @@ import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
-public class VnfAdapterCreateTasksTest extends BaseTaskTest{
- @InjectMocks
- private VnfAdapterCreateTasks vnfAdapterCreateTasks = new VnfAdapterCreateTasks();
-
-
- @Test
- public void test_createVolumeGroupRequest() throws Exception {
- RequestContext requestContext = setRequestContext();
-
- ServiceInstance serviceInstance = setServiceInstance();
-
- GenericVnf genericVnf = setGenericVnf();
-
- VfModule vfModule = setVfModule();
- vfModule.setSelflink("vfModuleSelfLink");
- VolumeGroup volumeGroup = setVolumeGroup();
- volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
-
- CloudRegion cloudRegion = setCloudRegion();
-
- OrchestrationContext orchestrationContext = setOrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(true);
-
- String sdncVnfQueryResponse = "SDNCVnfQueryResponse";
+public class VnfAdapterCreateTasksTest extends BaseTaskTest {
+ @InjectMocks
+ private VnfAdapterCreateTasks vnfAdapterCreateTasks = new VnfAdapterCreateTasks();
+
+
+ @Test
+ public void test_createVolumeGroupRequest() throws Exception {
+ RequestContext requestContext = setRequestContext();
+
+ ServiceInstance serviceInstance = setServiceInstance();
+
+ GenericVnf genericVnf = setGenericVnf();
+
+ VfModule vfModule = setVfModule();
+ vfModule.setSelflink("vfModuleSelfLink");
+ VolumeGroup volumeGroup = setVolumeGroup();
+ volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
+
+ CloudRegion cloudRegion = setCloudRegion();
+
+ OrchestrationContext orchestrationContext = setOrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(true);
+
+ String sdncVnfQueryResponse = "SDNCVnfQueryResponse";
execution.setVariable("SDNCQueryResponse_" + vfModule.getVfModuleId(), sdncVnfQueryResponse);
CreateVolumeGroupRequest request = new CreateVolumeGroupRequest();
request.setVolumeGroupId("volumeGroupStackId");
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID))).thenReturn(volumeGroup);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
- doReturn(request).when(vnfAdapterVolumeGroupResources).createVolumeGroupRequest(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, volumeGroup, sdncVnfQueryResponse);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
+ .thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID)))
+ .thenReturn(volumeGroup);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
+ doReturn(request).when(vnfAdapterVolumeGroupResources).createVolumeGroupRequest(requestContext, cloudRegion,
+ orchestrationContext, serviceInstance, genericVnf, volumeGroup, sdncVnfQueryResponse);
vnfAdapterCreateTasks.createVolumeGroupRequest(execution);
-
- verify(vnfAdapterVolumeGroupResources, times(1)).createVolumeGroupRequest(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, volumeGroup, sdncVnfQueryResponse);
-
- assertEquals(request.toXmlString(), execution.getVariable("VNFREST_Request"));
- }
-
- @Test
- public void test_createVolumeGroupRequest_for_alaCarte_flow() throws Exception {
- RequestContext requestContext = setRequestContext();
- ServiceInstance serviceInstance = setServiceInstance();
- GenericVnf genericVnf = setGenericVnf();
- VolumeGroup volumeGroup = setVolumeGroup();
- volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
-
- VfModule vfModule = setVfModule();
- vfModule.setSelflink("vfModuleSelfLink");
-
- CloudRegion cloudRegion = setCloudRegion();
-
- OrchestrationContext orchestrationContext = setOrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(true);
+
+ verify(vnfAdapterVolumeGroupResources, times(1)).createVolumeGroupRequest(requestContext, cloudRegion,
+ orchestrationContext, serviceInstance, genericVnf, volumeGroup, sdncVnfQueryResponse);
+
+ assertEquals(request.toXmlString(), execution.getVariable("VNFREST_Request"));
+ }
+
+ @Test
+ public void test_createVolumeGroupRequest_for_alaCarte_flow() throws Exception {
+ RequestContext requestContext = setRequestContext();
+ ServiceInstance serviceInstance = setServiceInstance();
+ GenericVnf genericVnf = setGenericVnf();
+ VolumeGroup volumeGroup = setVolumeGroup();
+ volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
+
+ VfModule vfModule = setVfModule();
+ vfModule.setSelflink("vfModuleSelfLink");
+
+ CloudRegion cloudRegion = setCloudRegion();
+
+ OrchestrationContext orchestrationContext = setOrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(true);
CreateVolumeGroupRequest request = new CreateVolumeGroupRequest();
request.setVolumeGroupId("volumeGroupStackId");
-
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID))).thenReturn(volumeGroup);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
- doReturn(request).when(vnfAdapterVolumeGroupResources).createVolumeGroupRequest(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, volumeGroup, null);
-
- vnfAdapterCreateTasks.createVolumeGroupRequest(execution);
-
- verify(vnfAdapterVolumeGroupResources, times(1)).createVolumeGroupRequest(any(RequestContext.class),
- any(CloudRegion.class), any(OrchestrationContext.class), eq(serviceInstance), eq(genericVnf), eq(volumeGroup), ArgumentMatchers.isNull());
-
- assertEquals(request.toXmlString(), execution.getVariable("VNFREST_Request"));
- }
-
- @Test
- public void test_createVolumeGroupRequest_exception() throws Exception {
- doThrow(RuntimeException.class).when(extractPojosForBB).extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID));
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
- expectedException.expect(BpmnError.class);
-
- vnfAdapterCreateTasks.createVolumeGroupRequest(execution);
- }
-
- @Test
- public void test_createVfModule() throws Exception {
- RequestContext requestContext = setRequestContext();
-
- ServiceInstance serviceInstance = setServiceInstance();
-
- GenericVnf genericVnf = setGenericVnf();
-
- VfModule vfModule = setVfModule();
-
- CloudRegion cloudRegion = setCloudRegion();
-
- OrchestrationContext orchestrationContext = setOrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(true);
-
- CreateVfModuleRequest modRequest = new CreateVfModuleRequest();
- modRequest.setVfModuleId(vfModule.getVfModuleId());
- modRequest.setBaseVfModuleStackId("baseVfModuleStackId");
- modRequest.setVfModuleName(vfModule.getVfModuleName());
- CreateVfModuleRequest createVfModuleRequest = modRequest;
-
- String sdncVfModuleQueryResponse = "{someJson}";
- execution.setVariable("SDNCQueryResponse_" + vfModule.getVfModuleId(), sdncVfModuleQueryResponse);
-
- String sdncVnfQueryResponse = "{someJson}";
- execution.setVariable("SDNCQueryResponse_" + genericVnf.getVnfId(), sdncVnfQueryResponse);
-
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
-
- doReturn(createVfModuleRequest).when(vnfAdapterVfModuleResources).createVfModuleRequest(requestContext, cloudRegion, orchestrationContext, serviceInstance,
- genericVnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
-
- vnfAdapterCreateTasks.createVfModule(execution);
-
- verify(vnfAdapterVfModuleResources, times(1)).createVfModuleRequest(requestContext, cloudRegion, orchestrationContext, serviceInstance,
- genericVnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
-
- assertEquals(execution.getVariable("VNFREST_Request"), createVfModuleRequest.toXmlString());
- }
-
- @Test
- public void test_createVfModuleWithVolumeGroup() throws Exception {
- RequestContext requestContext = setRequestContext();
-
- ServiceInstance serviceInstance = setServiceInstance();
-
- GenericVnf genericVnf = setGenericVnf();
-
- VfModule vfModule = setVfModule();
-
- VolumeGroup volumeGroup = setVolumeGroup();
-
- CloudRegion cloudRegion = setCloudRegion();
-
- OrchestrationContext orchestrationContext = setOrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(true);
-
- CreateVfModuleRequest modRequest = new CreateVfModuleRequest();
- modRequest.setVfModuleId(vfModule.getVfModuleId());
- modRequest.setBaseVfModuleStackId("baseVfModuleStackId");
- modRequest.setVfModuleName(vfModule.getVfModuleName());
- CreateVfModuleRequest createVfModuleRequest = modRequest;
-
- String sdncVfModuleQueryResponse = "{someJson}";
- execution.setVariable("SDNCQueryResponse_" + vfModule.getVfModuleId(), sdncVfModuleQueryResponse);
-
- String sdncVnfQueryResponse = "{someJson}";
- execution.setVariable("SDNCQueryResponse_" + genericVnf.getVnfId(), sdncVnfQueryResponse);
-
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID))).thenReturn(volumeGroup);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
- doReturn(createVfModuleRequest).when(vnfAdapterVfModuleResources).createVfModuleRequest(requestContext, cloudRegion, orchestrationContext, serviceInstance,
- genericVnf, vfModule, volumeGroup, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
-
- vnfAdapterCreateTasks.createVfModule(execution);
-
- verify(vnfAdapterVfModuleResources, times(1)).createVfModuleRequest(requestContext, cloudRegion, orchestrationContext, serviceInstance,
- genericVnf, vfModule, volumeGroup, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
-
- assertEquals(execution.getVariable("VNFREST_Request"), createVfModuleRequest.toXmlString());
- }
-
- @Test
- public void createVfModuleExceptionTest() throws Exception {
- // run with no data setup, and it will throw a BBObjectNotFoundException
- doThrow(RuntimeException.class).when(extractPojosForBB).extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID));
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
- expectedException.expect(BpmnError.class);
- vnfAdapterCreateTasks.createVolumeGroupRequest(execution);
- }
+
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
+ .thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID)))
+ .thenReturn(volumeGroup);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
+ doReturn(request).when(vnfAdapterVolumeGroupResources).createVolumeGroupRequest(requestContext, cloudRegion,
+ orchestrationContext, serviceInstance, genericVnf, volumeGroup, null);
+
+ vnfAdapterCreateTasks.createVolumeGroupRequest(execution);
+
+ verify(vnfAdapterVolumeGroupResources, times(1)).createVolumeGroupRequest(any(RequestContext.class),
+ any(CloudRegion.class), any(OrchestrationContext.class), eq(serviceInstance), eq(genericVnf),
+ eq(volumeGroup), ArgumentMatchers.isNull());
+
+ assertEquals(request.toXmlString(), execution.getVariable("VNFREST_Request"));
+ }
+
+ @Test
+ public void test_createVolumeGroupRequest_exception() throws Exception {
+ doThrow(RuntimeException.class).when(extractPojosForBB).extractByKey(any(),
+ ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID));
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
+ expectedException.expect(BpmnError.class);
+
+ vnfAdapterCreateTasks.createVolumeGroupRequest(execution);
+ }
+
+ @Test
+ public void test_createVfModule() throws Exception {
+ RequestContext requestContext = setRequestContext();
+
+ ServiceInstance serviceInstance = setServiceInstance();
+
+ GenericVnf genericVnf = setGenericVnf();
+
+ VfModule vfModule = setVfModule();
+
+ CloudRegion cloudRegion = setCloudRegion();
+
+ OrchestrationContext orchestrationContext = setOrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(true);
+
+ CreateVfModuleRequest modRequest = new CreateVfModuleRequest();
+ modRequest.setVfModuleId(vfModule.getVfModuleId());
+ modRequest.setBaseVfModuleStackId("baseVfModuleStackId");
+ modRequest.setVfModuleName(vfModule.getVfModuleName());
+ CreateVfModuleRequest createVfModuleRequest = modRequest;
+
+ String sdncVfModuleQueryResponse = "{someJson}";
+ execution.setVariable("SDNCQueryResponse_" + vfModule.getVfModuleId(), sdncVfModuleQueryResponse);
+
+ String sdncVnfQueryResponse = "{someJson}";
+ execution.setVariable("SDNCQueryResponse_" + genericVnf.getVnfId(), sdncVnfQueryResponse);
+
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
+ .thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
+
+ doReturn(createVfModuleRequest).when(vnfAdapterVfModuleResources).createVfModuleRequest(requestContext,
+ cloudRegion, orchestrationContext, serviceInstance, genericVnf, vfModule, null, sdncVnfQueryResponse,
+ sdncVfModuleQueryResponse);
+
+ vnfAdapterCreateTasks.createVfModule(execution);
+
+ verify(vnfAdapterVfModuleResources, times(1)).createVfModuleRequest(requestContext, cloudRegion,
+ orchestrationContext, serviceInstance, genericVnf, vfModule, null, sdncVnfQueryResponse,
+ sdncVfModuleQueryResponse);
+
+ assertEquals(execution.getVariable("VNFREST_Request"), createVfModuleRequest.toXmlString());
+ }
+
+ @Test
+ public void test_createVfModuleWithVolumeGroup() throws Exception {
+ RequestContext requestContext = setRequestContext();
+
+ ServiceInstance serviceInstance = setServiceInstance();
+
+ GenericVnf genericVnf = setGenericVnf();
+
+ VfModule vfModule = setVfModule();
+
+ VolumeGroup volumeGroup = setVolumeGroup();
+
+ CloudRegion cloudRegion = setCloudRegion();
+
+ OrchestrationContext orchestrationContext = setOrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(true);
+
+ CreateVfModuleRequest modRequest = new CreateVfModuleRequest();
+ modRequest.setVfModuleId(vfModule.getVfModuleId());
+ modRequest.setBaseVfModuleStackId("baseVfModuleStackId");
+ modRequest.setVfModuleName(vfModule.getVfModuleName());
+ CreateVfModuleRequest createVfModuleRequest = modRequest;
+
+ String sdncVfModuleQueryResponse = "{someJson}";
+ execution.setVariable("SDNCQueryResponse_" + vfModule.getVfModuleId(), sdncVfModuleQueryResponse);
+
+ String sdncVnfQueryResponse = "{someJson}";
+ execution.setVariable("SDNCQueryResponse_" + genericVnf.getVnfId(), sdncVnfQueryResponse);
+
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
+ .thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID)))
+ .thenReturn(volumeGroup);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
+ doReturn(createVfModuleRequest).when(vnfAdapterVfModuleResources).createVfModuleRequest(requestContext,
+ cloudRegion, orchestrationContext, serviceInstance, genericVnf, vfModule, volumeGroup,
+ sdncVnfQueryResponse, sdncVfModuleQueryResponse);
+
+ vnfAdapterCreateTasks.createVfModule(execution);
+
+ verify(vnfAdapterVfModuleResources, times(1)).createVfModuleRequest(requestContext, cloudRegion,
+ orchestrationContext, serviceInstance, genericVnf, vfModule, volumeGroup, sdncVnfQueryResponse,
+ sdncVfModuleQueryResponse);
+
+ assertEquals(execution.getVariable("VNFREST_Request"), createVfModuleRequest.toXmlString());
+ }
+
+ @Test
+ public void createVfModuleExceptionTest() throws Exception {
+ // run with no data setup, and it will throw a BBObjectNotFoundException
+ doThrow(RuntimeException.class).when(extractPojosForBB).extractByKey(any(),
+ ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID));
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
+ expectedException.expect(BpmnError.class);
+ vnfAdapterCreateTasks.createVolumeGroupRequest(execution);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterDeleteTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterDeleteTasksTest.java
index efd2e7d849..c680978953 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterDeleteTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterDeleteTasksTest.java
@@ -28,7 +28,6 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
@@ -47,84 +46,97 @@ import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext;
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
-public class VnfAdapterDeleteTasksTest extends BaseTaskTest{
- @InjectMocks
- private VnfAdapterDeleteTasks vnfAdapterDeleteTasks = new VnfAdapterDeleteTasks();
-
- private VolumeGroup volumeGroup;
- private VfModule vfModule;
- private GenericVnf genericVnf;
- private RequestContext requestContext;
- private CloudRegion cloudRegion;
- private ServiceInstance serviceInstance;
- private OrchestrationContext orchestrationContext;
-
- @Before
- public void before() throws Exception {
- requestContext = setRequestContext();
-
- serviceInstance = setServiceInstance();
-
- cloudRegion = setCloudRegion();
-
- genericVnf = setGenericVnf();
-
- vfModule = setVfModule();
-
- volumeGroup = setVolumeGroup();
-
- orchestrationContext = setOrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(true);
-
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID))).thenReturn(volumeGroup);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))).thenReturn(serviceInstance);
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
- }
-
- @Test
- public void test_deleteVfModule() throws Exception {
- DeleteVfModuleRequest deleteVfModuleRequest = new DeleteVfModuleRequest();
- deleteVfModuleRequest.setVfModuleId("vfModuleId");
-
- doReturn(deleteVfModuleRequest).when(vnfAdapterVfModuleResources).deleteVfModuleRequest(requestContext, cloudRegion, serviceInstance, genericVnf, vfModule);
-
- vnfAdapterDeleteTasks.deleteVfModule(execution);
-
- verify(vnfAdapterVfModuleResources, times(1)).deleteVfModuleRequest(ArgumentMatchers.eq(requestContext), ArgumentMatchers.eq(cloudRegion), ArgumentMatchers.eq(serviceInstance), ArgumentMatchers.eq(genericVnf),ArgumentMatchers.eq(vfModule));
- assertEquals(execution.getVariable("VNFREST_Request"), deleteVfModuleRequest.toXmlString());
- }
-
- @Test
- public void deleteVfModuleExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
-
- doThrow(RuntimeException.class).when(vnfAdapterVfModuleResources).deleteVfModuleRequest(requestContext, cloudRegion, serviceInstance, genericVnf, vfModule);
-
- vnfAdapterDeleteTasks.deleteVfModule(execution);
- }
-
- @Test
- public void test_deleteVolumeGroup() throws Exception {
- DeleteVolumeGroupRequest deleteVolumeGroupRequest = new DeleteVolumeGroupRequest();
- deleteVolumeGroupRequest.setVolumeGroupId("volumeGroupId");
-
- doReturn(deleteVolumeGroupRequest).when(vnfAdapterVolumeGroupResources).deleteVolumeGroupRequest(requestContext, cloudRegion, serviceInstance, volumeGroup);
-
- vnfAdapterDeleteTasks.deleteVolumeGroup(execution);
-
- verify(vnfAdapterVolumeGroupResources, times(1)).deleteVolumeGroupRequest(ArgumentMatchers.eq(requestContext), ArgumentMatchers.eq(cloudRegion), ArgumentMatchers.eq(serviceInstance), ArgumentMatchers.eq(volumeGroup));
- assertEquals(execution.getVariable("VNFREST_Request"), deleteVolumeGroupRequest.toXmlString());
- }
-
- @Test
- public void deleteVolumeGroupExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
-
- doThrow(RuntimeException.class).when(vnfAdapterVolumeGroupResources).deleteVolumeGroupRequest(requestContext, cloudRegion, serviceInstance, volumeGroup);
-
- vnfAdapterDeleteTasks.deleteVolumeGroup(execution);
- }
+public class VnfAdapterDeleteTasksTest extends BaseTaskTest {
+ @InjectMocks
+ private VnfAdapterDeleteTasks vnfAdapterDeleteTasks = new VnfAdapterDeleteTasks();
+
+ private VolumeGroup volumeGroup;
+ private VfModule vfModule;
+ private GenericVnf genericVnf;
+ private RequestContext requestContext;
+ private CloudRegion cloudRegion;
+ private ServiceInstance serviceInstance;
+ private OrchestrationContext orchestrationContext;
+
+ @Before
+ public void before() throws Exception {
+ requestContext = setRequestContext();
+
+ serviceInstance = setServiceInstance();
+
+ cloudRegion = setCloudRegion();
+
+ genericVnf = setGenericVnf();
+
+ vfModule = setVfModule();
+
+ volumeGroup = setVolumeGroup();
+
+ orchestrationContext = setOrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(true);
+
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
+ .thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID)))
+ .thenReturn(volumeGroup);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
+ .thenReturn(serviceInstance);
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
+ }
+
+ @Test
+ public void test_deleteVfModule() throws Exception {
+ DeleteVfModuleRequest deleteVfModuleRequest = new DeleteVfModuleRequest();
+ deleteVfModuleRequest.setVfModuleId("vfModuleId");
+
+ doReturn(deleteVfModuleRequest).when(vnfAdapterVfModuleResources).deleteVfModuleRequest(requestContext,
+ cloudRegion, serviceInstance, genericVnf, vfModule);
+
+ vnfAdapterDeleteTasks.deleteVfModule(execution);
+
+ verify(vnfAdapterVfModuleResources, times(1)).deleteVfModuleRequest(ArgumentMatchers.eq(requestContext),
+ ArgumentMatchers.eq(cloudRegion), ArgumentMatchers.eq(serviceInstance), ArgumentMatchers.eq(genericVnf),
+ ArgumentMatchers.eq(vfModule));
+ assertEquals(execution.getVariable("VNFREST_Request"), deleteVfModuleRequest.toXmlString());
+ }
+
+ @Test
+ public void deleteVfModuleExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ doThrow(RuntimeException.class).when(vnfAdapterVfModuleResources).deleteVfModuleRequest(requestContext,
+ cloudRegion, serviceInstance, genericVnf, vfModule);
+
+ vnfAdapterDeleteTasks.deleteVfModule(execution);
+ }
+
+ @Test
+ public void test_deleteVolumeGroup() throws Exception {
+ DeleteVolumeGroupRequest deleteVolumeGroupRequest = new DeleteVolumeGroupRequest();
+ deleteVolumeGroupRequest.setVolumeGroupId("volumeGroupId");
+
+ doReturn(deleteVolumeGroupRequest).when(vnfAdapterVolumeGroupResources).deleteVolumeGroupRequest(requestContext,
+ cloudRegion, serviceInstance, volumeGroup);
+
+ vnfAdapterDeleteTasks.deleteVolumeGroup(execution);
+
+ verify(vnfAdapterVolumeGroupResources, times(1)).deleteVolumeGroupRequest(ArgumentMatchers.eq(requestContext),
+ ArgumentMatchers.eq(cloudRegion), ArgumentMatchers.eq(serviceInstance),
+ ArgumentMatchers.eq(volumeGroup));
+ assertEquals(execution.getVariable("VNFREST_Request"), deleteVolumeGroupRequest.toXmlString());
+ }
+
+ @Test
+ public void deleteVolumeGroupExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ doThrow(RuntimeException.class).when(vnfAdapterVolumeGroupResources).deleteVolumeGroupRequest(requestContext,
+ cloudRegion, serviceInstance, volumeGroup);
+
+ vnfAdapterDeleteTasks.deleteVolumeGroup(execution);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImplTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImplTest.java
index b515835f19..97a9388f8d 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImplTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImplTest.java
@@ -27,7 +27,6 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.when;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
@@ -46,173 +45,188 @@ import org.onap.so.client.exception.BBObjectNotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
public class VnfAdapterImplTest extends BaseTaskTest {
-
- @InjectMocks
- private VnfAdapterImpl vnfAdapterImpl = new VnfAdapterImpl();
-
- private RequestContext requestContext;
- private ServiceInstance serviceInstance;
- private GenericVnf genericVnf;
- private VfModule vfModule;
+
+ @InjectMocks
+ private VnfAdapterImpl vnfAdapterImpl = new VnfAdapterImpl();
+
+ private RequestContext requestContext;
+ private ServiceInstance serviceInstance;
+ private GenericVnf genericVnf;
+ private VfModule vfModule;
private VolumeGroup volumeGroup;
-
- private static final String VNF_ADAPTER_REST_DELETE_RESPONSE = FileUtil.readResourceFile("__files/VfModularity/VNFAdapterRestDeleteResponse.xml");
- private static final String VNF_ADAPTER_REST_CREATE_RESPONSE = FileUtil.readResourceFile("__files/VfModularity/VNFAdapterRestCreateCallback.xml");
- private static final String VNF_ADAPTER_VOLUME_CREATE_RESPONSE = FileUtil.readResourceFile("__files/VfModularity/CreateVfModuleVolumeCallbackResponse.xml");
- private static final String VNF_ADAPTER_VOLUME_DELETE_RESPONSE = FileUtil.readResourceFile("__files/VfModularity/DeleteVfModuleVolumeCallbackResponse.xml");
- private static final String TEST_VFMODULE_HEATSTACK_ID = "slowburn";
+
+ private static final String VNF_ADAPTER_REST_DELETE_RESPONSE =
+ FileUtil.readResourceFile("__files/VfModularity/VNFAdapterRestDeleteResponse.xml");
+ private static final String VNF_ADAPTER_REST_CREATE_RESPONSE =
+ FileUtil.readResourceFile("__files/VfModularity/VNFAdapterRestCreateCallback.xml");
+ private static final String VNF_ADAPTER_VOLUME_CREATE_RESPONSE =
+ FileUtil.readResourceFile("__files/VfModularity/CreateVfModuleVolumeCallbackResponse.xml");
+ private static final String VNF_ADAPTER_VOLUME_DELETE_RESPONSE =
+ FileUtil.readResourceFile("__files/VfModularity/DeleteVfModuleVolumeCallbackResponse.xml");
+ private static final String TEST_VFMODULE_HEATSTACK_ID = "slowburn";
private static final String TEST_VOLUME_HEATSTACK_ID = "testHeatStackId1";
private static final String TEST_CONTRAIL_SERVICE_INSTANCE_FQDN = "default-domain:MSOTest:MsoNW-RA";
private static final String TEST_OAM_MANAGEMENT_V4_ADDRESS = "127.0.0.1";
private static final String TEST_OAM_MANAGEMENT_V6_ADDRESS = "2000:abc:bce:1111";
- private static final String TEST_CONTRAIL_NETWORK_POLICY_FQDNS = "MSOTest:DefaultPolicyFQDN2,MSOTest:DefaultPolicyFQDN1";
-
- @Before
- public void before() throws BBObjectNotFoundException {
- requestContext = setRequestContext();
- serviceInstance = setServiceInstance();
- genericVnf = setGenericVnf();
- vfModule = setVfModule();
+ private static final String TEST_CONTRAIL_NETWORK_POLICY_FQDNS =
+ "MSOTest:DefaultPolicyFQDN2,MSOTest:DefaultPolicyFQDN1";
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ requestContext = setRequestContext();
+ serviceInstance = setServiceInstance();
+ genericVnf = setGenericVnf();
+ vfModule = setVfModule();
volumeGroup = setVolumeGroup();
- vfModule.setHeatStackId(null);
- volumeGroup.setHeatStackId(null);
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))).thenReturn(serviceInstance);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID))).thenReturn(volumeGroup);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
- }
-
- @Test
- public void preProcessVnfAdapterTest() {
- vnfAdapterImpl.preProcessVnfAdapter(execution);
-
- assertEquals(requestContext.getMsoRequestId(), execution.getVariable("mso-request-id"));
- assertEquals(serviceInstance.getServiceInstanceId(), execution.getVariable("mso-service-instance-id"));
- }
-
- @Test
- public void postProcessVnfAdapter_CreateResponseTest() {
- execution.setVariable("vnfAdapterRestV1Response", VNF_ADAPTER_REST_CREATE_RESPONSE);
- vnfAdapterImpl.postProcessVnfAdapter(execution);
- assertEquals(TEST_VFMODULE_HEATSTACK_ID, vfModule.getHeatStackId());
- assertEquals(TEST_CONTRAIL_SERVICE_INSTANCE_FQDN, vfModule.getContrailServiceInstanceFqdn());
- assertEquals(TEST_CONTRAIL_SERVICE_INSTANCE_FQDN, execution.getVariable("contrailServiceInstanceFqdn"));
- assertEquals(TEST_OAM_MANAGEMENT_V4_ADDRESS, genericVnf.getIpv4OamAddress());
- assertEquals(TEST_OAM_MANAGEMENT_V4_ADDRESS, execution.getVariable("oamManagementV4Address"));
- assertEquals(TEST_OAM_MANAGEMENT_V6_ADDRESS, genericVnf.getManagementV6Address());
- assertEquals(TEST_OAM_MANAGEMENT_V6_ADDRESS, execution.getVariable("oamManagementV6Address"));
- assertEquals(TEST_CONTRAIL_NETWORK_POLICY_FQDNS, execution.getVariable("contrailNetworkPolicyFqdnList"));
- }
-
-
- @Test
- public void postProcessVnfAdapter_CreateResponseTest_EmptyCreateVfModuleResponseTag() {
+ vfModule.setHeatStackId(null);
+ volumeGroup.setHeatStackId(null);
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
+ .thenReturn(serviceInstance);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID)))
+ .thenReturn(volumeGroup);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
+ .thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
+ }
+
+ @Test
+ public void preProcessVnfAdapterTest() {
+ vnfAdapterImpl.preProcessVnfAdapter(execution);
+
+ assertEquals(requestContext.getMsoRequestId(), execution.getVariable("mso-request-id"));
+ assertEquals(serviceInstance.getServiceInstanceId(), execution.getVariable("mso-service-instance-id"));
+ }
+
+ @Test
+ public void postProcessVnfAdapter_CreateResponseTest() {
+ execution.setVariable("vnfAdapterRestV1Response", VNF_ADAPTER_REST_CREATE_RESPONSE);
+ vnfAdapterImpl.postProcessVnfAdapter(execution);
+ assertEquals(TEST_VFMODULE_HEATSTACK_ID, vfModule.getHeatStackId());
+ assertEquals(TEST_CONTRAIL_SERVICE_INSTANCE_FQDN, vfModule.getContrailServiceInstanceFqdn());
+ assertEquals(TEST_CONTRAIL_SERVICE_INSTANCE_FQDN, execution.getVariable("contrailServiceInstanceFqdn"));
+ assertEquals(TEST_OAM_MANAGEMENT_V4_ADDRESS, genericVnf.getIpv4OamAddress());
+ assertEquals(TEST_OAM_MANAGEMENT_V4_ADDRESS, execution.getVariable("oamManagementV4Address"));
+ assertEquals(TEST_OAM_MANAGEMENT_V6_ADDRESS, genericVnf.getManagementV6Address());
+ assertEquals(TEST_OAM_MANAGEMENT_V6_ADDRESS, execution.getVariable("oamManagementV6Address"));
+ assertEquals(TEST_CONTRAIL_NETWORK_POLICY_FQDNS, execution.getVariable("contrailNetworkPolicyFqdnList"));
+ }
+
+
+ @Test
+ public void postProcessVnfAdapter_CreateResponseTest_EmptyCreateVfModuleResponseTag() {
expectedException.expect(BpmnError.class);
- execution.setVariable("vnfAdapterRestV1Response", "<vfModuleStackId></vfModuleStackId>");
- vnfAdapterImpl.postProcessVnfAdapter(execution);
- }
-
- @Test
- public void postProcessVnfAdapter_CreateResponseTest_EmptyVfModuleStackIdTag() {
- execution.setVariable("vnfAdapterRestV1Response", "<createVfModuleResponse></createVfModuleResponse>");
- vnfAdapterImpl.postProcessVnfAdapter(execution);
- assertNull(vfModule.getHeatStackId());
- }
-
- @Test
- public void postProcessVnfAdapter_CreateResponseTest_EmptyHeatStackId() {
- execution.setVariable("vnfAdapterRestV1Response", "<createVfModuleResponse><vfModuleStackId></vfModuleStackId></createVfModuleResponse>");
- vnfAdapterImpl.postProcessVnfAdapter(execution);
- assertNull(vfModule.getHeatStackId());
- }
-
- @Test
- public void postProcessVnfAdapter_CreateResponseTest_EmptyVfModuleOutputs() {
- execution.setVariable("vnfAdapterRestV1Response", "<createVfModuleResponse><vfModuleOutputs></vfModuleOutputs></createVfModuleResponse>");
- vnfAdapterImpl.postProcessVnfAdapter(execution);
- assertNull(vfModule.getHeatStackId());
- assertNull(vfModule.getContrailServiceInstanceFqdn());
- assertNull(execution.getVariable("contrailServiceInstanceFqdn"));
- assertNotEquals(TEST_OAM_MANAGEMENT_V4_ADDRESS, genericVnf.getIpv4OamAddress());
- assertNull(execution.getVariable("oamManagementV4Address"));
- assertNull(genericVnf.getManagementV6Address());
- assertNull(execution.getVariable("oamManagementV6Address"));
- assertNull(execution.getVariable("contrailNetworkPolicyFqdnList"));
- }
-
- @Test
- public void postProcessVnfAdapter_DeleteResponseTest() {
- vfModule.setHeatStackId(TEST_VFMODULE_HEATSTACK_ID);
- execution.setVariable("vnfAdapterRestV1Response", VNF_ADAPTER_REST_DELETE_RESPONSE);
- vnfAdapterImpl.postProcessVnfAdapter(execution);
- assertNull(vfModule.getHeatStackId());
- assertEquals(vfModule.getContrailServiceInstanceFqdn(), "");
- assertEquals(execution.getVariable("contrailServiceInstanceFqdn"), "");
- assertEquals(genericVnf.getIpv4OamAddress(), "");
- assertEquals(execution.getVariable("oamManagementV4Address"), "");
- assertEquals(genericVnf.getManagementV6Address(), "");
- assertEquals(execution.getVariable("oamManagementV6Address"), "");
- assertEquals(TEST_CONTRAIL_NETWORK_POLICY_FQDNS, execution.getVariable("contrailNetworkPolicyFqdnList"));
- }
-
- @Test
- public void postProcessVnfAdapter_DeleteResponseTest_EmptyVfModuleOutputs() {
- execution.setVariable("vnfAdapterRestV1Response", "<createVfModuleResponse><vfModuleOutputs></vfModuleOutputs></createVfModuleResponse>");
- vnfAdapterImpl.postProcessVnfAdapter(execution);
- assertNull(vfModule.getHeatStackId());
- assertNull(vfModule.getContrailServiceInstanceFqdn());
- assertNull(execution.getVariable("contrailServiceInstanceFqdn"));
- assertNull(execution.getVariable("oamManagementV4Address"));
- assertNull(execution.getVariable("oamManagementV6Address"));
- assertNull(execution.getVariable("contrailNetworkPolicyFqdnList"));
- }
-
- @Test
- public void postProcessVnfAdapter_ResponseNullTest() {
- execution.setVariable("vnfAdapterRestV1Response", null);
- vnfAdapterImpl.postProcessVnfAdapter(execution);
- assertNull(vfModule.getHeatStackId());
- }
-
- @Test
- public void postProcessVnfAdapter_ResponseEmptyTest() {
+ execution.setVariable("vnfAdapterRestV1Response", "<vfModuleStackId></vfModuleStackId>");
+ vnfAdapterImpl.postProcessVnfAdapter(execution);
+ }
+
+ @Test
+ public void postProcessVnfAdapter_CreateResponseTest_EmptyVfModuleStackIdTag() {
+ execution.setVariable("vnfAdapterRestV1Response", "<createVfModuleResponse></createVfModuleResponse>");
+ vnfAdapterImpl.postProcessVnfAdapter(execution);
+ assertNull(vfModule.getHeatStackId());
+ }
+
+ @Test
+ public void postProcessVnfAdapter_CreateResponseTest_EmptyHeatStackId() {
+ execution.setVariable("vnfAdapterRestV1Response",
+ "<createVfModuleResponse><vfModuleStackId></vfModuleStackId></createVfModuleResponse>");
+ vnfAdapterImpl.postProcessVnfAdapter(execution);
+ assertNull(vfModule.getHeatStackId());
+ }
+
+ @Test
+ public void postProcessVnfAdapter_CreateResponseTest_EmptyVfModuleOutputs() {
+ execution.setVariable("vnfAdapterRestV1Response",
+ "<createVfModuleResponse><vfModuleOutputs></vfModuleOutputs></createVfModuleResponse>");
+ vnfAdapterImpl.postProcessVnfAdapter(execution);
+ assertNull(vfModule.getHeatStackId());
+ assertNull(vfModule.getContrailServiceInstanceFqdn());
+ assertNull(execution.getVariable("contrailServiceInstanceFqdn"));
+ assertNotEquals(TEST_OAM_MANAGEMENT_V4_ADDRESS, genericVnf.getIpv4OamAddress());
+ assertNull(execution.getVariable("oamManagementV4Address"));
+ assertNull(genericVnf.getManagementV6Address());
+ assertNull(execution.getVariable("oamManagementV6Address"));
+ assertNull(execution.getVariable("contrailNetworkPolicyFqdnList"));
+ }
+
+ @Test
+ public void postProcessVnfAdapter_DeleteResponseTest() {
+ vfModule.setHeatStackId(TEST_VFMODULE_HEATSTACK_ID);
+ execution.setVariable("vnfAdapterRestV1Response", VNF_ADAPTER_REST_DELETE_RESPONSE);
+ vnfAdapterImpl.postProcessVnfAdapter(execution);
+ assertNull(vfModule.getHeatStackId());
+ assertEquals(vfModule.getContrailServiceInstanceFqdn(), "");
+ assertEquals(execution.getVariable("contrailServiceInstanceFqdn"), "");
+ assertEquals(genericVnf.getIpv4OamAddress(), "");
+ assertEquals(execution.getVariable("oamManagementV4Address"), "");
+ assertEquals(genericVnf.getManagementV6Address(), "");
+ assertEquals(execution.getVariable("oamManagementV6Address"), "");
+ assertEquals(TEST_CONTRAIL_NETWORK_POLICY_FQDNS, execution.getVariable("contrailNetworkPolicyFqdnList"));
+ }
+
+ @Test
+ public void postProcessVnfAdapter_DeleteResponseTest_EmptyVfModuleOutputs() {
+ execution.setVariable("vnfAdapterRestV1Response",
+ "<createVfModuleResponse><vfModuleOutputs></vfModuleOutputs></createVfModuleResponse>");
+ vnfAdapterImpl.postProcessVnfAdapter(execution);
+ assertNull(vfModule.getHeatStackId());
+ assertNull(vfModule.getContrailServiceInstanceFqdn());
+ assertNull(execution.getVariable("contrailServiceInstanceFqdn"));
+ assertNull(execution.getVariable("oamManagementV4Address"));
+ assertNull(execution.getVariable("oamManagementV6Address"));
+ assertNull(execution.getVariable("contrailNetworkPolicyFqdnList"));
+ }
+
+ @Test
+ public void postProcessVnfAdapter_ResponseNullTest() {
+ execution.setVariable("vnfAdapterRestV1Response", null);
+ vnfAdapterImpl.postProcessVnfAdapter(execution);
+ assertNull(vfModule.getHeatStackId());
+ }
+
+ @Test
+ public void postProcessVnfAdapter_ResponseEmptyTest() {
execution.setVariable("vnfAdapterRestV1Response", "");
- vnfAdapterImpl.postProcessVnfAdapter(execution);
+ vnfAdapterImpl.postProcessVnfAdapter(execution);
assertNull(vfModule.getHeatStackId());
- }
-
- @Test
- public void postProcessVnfAdapter_DeleteResponseTest_VfModuleDeletedFalse() {
- vfModule.setHeatStackId(TEST_VFMODULE_HEATSTACK_ID);
- execution.setVariable("vnfAdapterRestV1Response", "<deleteVfModuleResponse><vfModuleDeleted>false</vfModuleDeleted></deleteVfModuleResponse>");
- vnfAdapterImpl.postProcessVnfAdapter(execution);
- assertEquals(TEST_VFMODULE_HEATSTACK_ID, vfModule.getHeatStackId());
- }
-
- @Test
- public void postProcessVnfAdapter_DeleteResponseTest_EmptyDeleteVfModuleResponseTag() {
+ }
+
+ @Test
+ public void postProcessVnfAdapter_DeleteResponseTest_VfModuleDeletedFalse() {
+ vfModule.setHeatStackId(TEST_VFMODULE_HEATSTACK_ID);
+ execution.setVariable("vnfAdapterRestV1Response",
+ "<deleteVfModuleResponse><vfModuleDeleted>false</vfModuleDeleted></deleteVfModuleResponse>");
+ vnfAdapterImpl.postProcessVnfAdapter(execution);
+ assertEquals(TEST_VFMODULE_HEATSTACK_ID, vfModule.getHeatStackId());
+ }
+
+ @Test
+ public void postProcessVnfAdapter_DeleteResponseTest_EmptyDeleteVfModuleResponseTag() {
+ expectedException.expect(BpmnError.class);
+ execution.setVariable("vnfAdapterRestV1Response", "<vfModuleDeleted></vfModuleDeleted>");
+ vnfAdapterImpl.postProcessVnfAdapter(execution);
+ }
+
+ @Test
+ public void postProcessVnfAdapter_DeleteResponseTest_EmptyVfModuleDeletedTag() {
+ vfModule.setHeatStackId(TEST_VFMODULE_HEATSTACK_ID);
+ execution.setVariable("vnfAdapterRestV1Response", "<deleteVfModuleResponse></deleteVfModuleResponse>");
+ vnfAdapterImpl.postProcessVnfAdapter(execution);
+ assertEquals(TEST_VFMODULE_HEATSTACK_ID, vfModule.getHeatStackId());
+ }
+
+ @Test
+ public void preProcessVnfAdapterExceptionTest() throws BBObjectNotFoundException {
expectedException.expect(BpmnError.class);
- execution.setVariable("vnfAdapterRestV1Response", "<vfModuleDeleted></vfModuleDeleted>");
- vnfAdapterImpl.postProcessVnfAdapter(execution);
- }
-
- @Test
- public void postProcessVnfAdapter_DeleteResponseTest_EmptyVfModuleDeletedTag() {
- vfModule.setHeatStackId(TEST_VFMODULE_HEATSTACK_ID);
- execution.setVariable("vnfAdapterRestV1Response", "<deleteVfModuleResponse></deleteVfModuleResponse>");
- vnfAdapterImpl.postProcessVnfAdapter(execution);
- assertEquals(TEST_VFMODULE_HEATSTACK_ID, vfModule.getHeatStackId());
- }
-
- @Test
- public void preProcessVnfAdapterExceptionTest() throws BBObjectNotFoundException {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(extractPojosForBB).extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID));
-
- vnfAdapterImpl.preProcessVnfAdapter(execution);
- }
+ doThrow(RuntimeException.class).when(extractPojosForBB).extractByKey(any(),
+ ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID));
+
+ vnfAdapterImpl.preProcessVnfAdapter(execution);
+ }
@Test
public void postProcessVnfAdapter_CreateVolumeResponseTest() {
@@ -222,52 +236,54 @@ public class VnfAdapterImplTest extends BaseTaskTest {
}
@Test
- public void postProcessVnfAdapter_CreateVolumeEmptyResponseTest() {
+ public void postProcessVnfAdapter_CreateVolumeEmptyResponseTest() {
expectedException.expect(BpmnError.class);
execution.setVariable("vnfAdapterRestV1Response", "<createVolumeGroupResponse></createVolumeGroupResponse>");
vnfAdapterImpl.postProcessVnfAdapter(execution);
assertNull(volumeGroup.getHeatStackId());
}
-
+
@Test
- public void postProcessVnfAdapter_DeleteResponseTest_DeleteVolumeGroup() {
- volumeGroup.setHeatStackId(TEST_VOLUME_HEATSTACK_ID);
- execution.setVariable("vnfAdapterRestV1Response", VNF_ADAPTER_VOLUME_DELETE_RESPONSE);
- vnfAdapterImpl.postProcessVnfAdapter(execution);
- assertNull(volumeGroup.getHeatStackId());
- }
-
-
+ public void postProcessVnfAdapter_DeleteResponseTest_DeleteVolumeGroup() {
+ volumeGroup.setHeatStackId(TEST_VOLUME_HEATSTACK_ID);
+ execution.setVariable("vnfAdapterRestV1Response", VNF_ADAPTER_VOLUME_DELETE_RESPONSE);
+ vnfAdapterImpl.postProcessVnfAdapter(execution);
+ assertNull(volumeGroup.getHeatStackId());
+ }
+
+
+ @Test
+ public void postProcessVnfAdapter_DeleteResponseTest_VolumeGroupDeletedFalse() {
+ volumeGroup.setHeatStackId(TEST_VOLUME_HEATSTACK_ID);
+ execution.setVariable("vnfAdapterRestV1Response",
+ "<deleteVolumeGroupResponse><volumeGroupDeleted>false</volumeGroupDeleted></deleteVolumeGroupResponse>");
+ vnfAdapterImpl.postProcessVnfAdapter(execution);
+ assertEquals(TEST_VOLUME_HEATSTACK_ID, volumeGroup.getHeatStackId());
+ }
+
@Test
- public void postProcessVnfAdapter_DeleteResponseTest_VolumeGroupDeletedFalse() {
- volumeGroup.setHeatStackId(TEST_VOLUME_HEATSTACK_ID);
- execution.setVariable("vnfAdapterRestV1Response", "<deleteVolumeGroupResponse><volumeGroupDeleted>false</volumeGroupDeleted></deleteVolumeGroupResponse>");
- vnfAdapterImpl.postProcessVnfAdapter(execution);
- assertEquals(TEST_VOLUME_HEATSTACK_ID, volumeGroup.getHeatStackId());
- }
-
- @Test
- public void postProcessVnfAdapter_DeleteResponseTest_EmptyDeleteVolumeGroupResponseTag() {
+ public void postProcessVnfAdapter_DeleteResponseTest_EmptyDeleteVolumeGroupResponseTag() {
expectedException.expect(BpmnError.class);
- execution.setVariable("vnfAdapterRestV1Response", "<volumeGroupDeleted></volumeGroupDeleted>");
- vnfAdapterImpl.postProcessVnfAdapter(execution);
- }
-
- @Test
- public void postProcessVnfAdapter_DeleteResponseTest_EmptyVolumeGroupDeletedTag() {
- volumeGroup.setHeatStackId(TEST_VOLUME_HEATSTACK_ID);
- execution.setVariable("vnfAdapterRestV1Response", "<deleteVolumeGroupResponse></deleteVolumeGroupResponse>");
- vnfAdapterImpl.postProcessVnfAdapter(execution);
- assertEquals(TEST_VOLUME_HEATSTACK_ID, volumeGroup.getHeatStackId());
- }
-
- @Test
- public void postProcessVnfAdapterExceptionTest() throws BBObjectNotFoundException {
- doThrow(RuntimeException.class).when(extractPojosForBB).extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID));
-
- execution.setVariable("vnfAdapterRestV1Response", VNF_ADAPTER_REST_CREATE_RESPONSE);
- expectedException.expect(BpmnError.class);
-
- vnfAdapterImpl.postProcessVnfAdapter(execution);
- }
+ execution.setVariable("vnfAdapterRestV1Response", "<volumeGroupDeleted></volumeGroupDeleted>");
+ vnfAdapterImpl.postProcessVnfAdapter(execution);
+ }
+
+ @Test
+ public void postProcessVnfAdapter_DeleteResponseTest_EmptyVolumeGroupDeletedTag() {
+ volumeGroup.setHeatStackId(TEST_VOLUME_HEATSTACK_ID);
+ execution.setVariable("vnfAdapterRestV1Response", "<deleteVolumeGroupResponse></deleteVolumeGroupResponse>");
+ vnfAdapterImpl.postProcessVnfAdapter(execution);
+ assertEquals(TEST_VOLUME_HEATSTACK_ID, volumeGroup.getHeatStackId());
+ }
+
+ @Test
+ public void postProcessVnfAdapterExceptionTest() throws BBObjectNotFoundException {
+ doThrow(RuntimeException.class).when(extractPojosForBB).extractByKey(any(),
+ ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID));
+
+ execution.setVariable("vnfAdapterRestV1Response", VNF_ADAPTER_REST_CREATE_RESPONSE);
+ expectedException.expect(BpmnError.class);
+
+ vnfAdapterImpl.postProcessVnfAdapter(execution);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/EtsiVnfDeleteTaskTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/EtsiVnfDeleteTaskTest.java
index 5c76018ced..5233203c05 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/EtsiVnfDeleteTaskTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/EtsiVnfDeleteTaskTest.java
@@ -46,66 +46,66 @@ import com.google.common.base.Optional;
*/
public class EtsiVnfDeleteTaskTest extends BaseTaskTest {
- private static final String MODEL_INSTANCE_NAME = "MODEL_INSTANCE_NAME";
-
- private static final String VNF_ID = UUID.randomUUID().toString();
-
- private static final String VNF_NAME = "VNF_NAME";
-
- private static final String JOB_ID = UUID.randomUUID().toString();
-
- @Mock
- private VnfmAdapterServiceProvider mockedVnfmAdapterServiceProvider;
-
- @Mock
- private GeneralBuildingBlock buildingBlock;
-
- @Mock
- private RequestContext requestContext;
-
- private final BuildingBlockExecution stubbedxecution = new StubbedBuildingBlockExecution();
-
- @Test
- public void testInvokeVnfmAdapter() throws Exception {
- final EtsiVnfDeleteTask objUnderTest = getEtsiVnfDeleteTask();
- when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(getGenericVnf());
- when(mockedVnfmAdapterServiceProvider.invokeDeleteRequest(eq(VNF_ID))).thenReturn(getDeleteVnfResponse());
- objUnderTest.invokeVnfmAdapter(stubbedxecution);
- assertNotNull(stubbedxecution.getVariable(Constants.DELETE_VNF_RESPONSE_PARAM_NAME));
- }
-
- @Test
- public void testInvokeVnfmAdapterException() throws Exception {
- final EtsiVnfDeleteTask objUnderTest = getEtsiVnfDeleteTask();
- when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(getGenericVnf());
- when(mockedVnfmAdapterServiceProvider.invokeDeleteRequest(eq(VNF_ID))).thenReturn(Optional.absent());
- objUnderTest.invokeVnfmAdapter(stubbedxecution);
- assertNull(stubbedxecution.getVariable(Constants.DELETE_VNF_RESPONSE_PARAM_NAME));
- verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1212),
- any(Exception.class));
- }
-
- private Optional<DeleteVnfResponse> getDeleteVnfResponse() {
- final DeleteVnfResponse response = new DeleteVnfResponse();
- response.setJobId(JOB_ID);
- return Optional.of(response);
- }
-
- private GenericVnf getGenericVnf() {
- final GenericVnf genericVnf = new GenericVnf();
- genericVnf.setVnfId(VNF_ID);
- genericVnf.setModelInfoGenericVnf(getModelInfoGenericVnf());
- genericVnf.setVnfName(VNF_NAME);
- return genericVnf;
- }
-
- private ModelInfoGenericVnf getModelInfoGenericVnf() {
- final ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
- modelInfoGenericVnf.setModelInstanceName(MODEL_INSTANCE_NAME);
- return modelInfoGenericVnf;
- }
-
- private EtsiVnfDeleteTask getEtsiVnfDeleteTask() {
- return new EtsiVnfDeleteTask(exceptionUtil, extractPojosForBB, mockedVnfmAdapterServiceProvider);
- }
+ private static final String MODEL_INSTANCE_NAME = "MODEL_INSTANCE_NAME";
+
+ private static final String VNF_ID = UUID.randomUUID().toString();
+
+ private static final String VNF_NAME = "VNF_NAME";
+
+ private static final String JOB_ID = UUID.randomUUID().toString();
+
+ @Mock
+ private VnfmAdapterServiceProvider mockedVnfmAdapterServiceProvider;
+
+ @Mock
+ private GeneralBuildingBlock buildingBlock;
+
+ @Mock
+ private RequestContext requestContext;
+
+ private final BuildingBlockExecution stubbedxecution = new StubbedBuildingBlockExecution();
+
+ @Test
+ public void testInvokeVnfmAdapter() throws Exception {
+ final EtsiVnfDeleteTask objUnderTest = getEtsiVnfDeleteTask();
+ when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(getGenericVnf());
+ when(mockedVnfmAdapterServiceProvider.invokeDeleteRequest(eq(VNF_ID))).thenReturn(getDeleteVnfResponse());
+ objUnderTest.invokeVnfmAdapter(stubbedxecution);
+ assertNotNull(stubbedxecution.getVariable(Constants.DELETE_VNF_RESPONSE_PARAM_NAME));
+ }
+
+ @Test
+ public void testInvokeVnfmAdapterException() throws Exception {
+ final EtsiVnfDeleteTask objUnderTest = getEtsiVnfDeleteTask();
+ when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(getGenericVnf());
+ when(mockedVnfmAdapterServiceProvider.invokeDeleteRequest(eq(VNF_ID))).thenReturn(Optional.absent());
+ objUnderTest.invokeVnfmAdapter(stubbedxecution);
+ assertNull(stubbedxecution.getVariable(Constants.DELETE_VNF_RESPONSE_PARAM_NAME));
+ verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1212),
+ any(Exception.class));
+ }
+
+ private Optional<DeleteVnfResponse> getDeleteVnfResponse() {
+ final DeleteVnfResponse response = new DeleteVnfResponse();
+ response.setJobId(JOB_ID);
+ return Optional.of(response);
+ }
+
+ private GenericVnf getGenericVnf() {
+ final GenericVnf genericVnf = new GenericVnf();
+ genericVnf.setVnfId(VNF_ID);
+ genericVnf.setModelInfoGenericVnf(getModelInfoGenericVnf());
+ genericVnf.setVnfName(VNF_NAME);
+ return genericVnf;
+ }
+
+ private ModelInfoGenericVnf getModelInfoGenericVnf() {
+ final ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setModelInstanceName(MODEL_INSTANCE_NAME);
+ return modelInfoGenericVnf;
+ }
+
+ private EtsiVnfDeleteTask getEtsiVnfDeleteTask() {
+ return new EtsiVnfDeleteTask(exceptionUtil, extractPojosForBB, mockedVnfmAdapterServiceProvider);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/InputParameterRetrieverTaskTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/InputParameterRetrieverTaskTest.java
index 803b58b4b8..5805ea5ec1 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/InputParameterRetrieverTaskTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/InputParameterRetrieverTaskTest.java
@@ -24,12 +24,10 @@ import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.when;
-
import java.io.Serializable;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
-
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.Mockito;
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmCreateJobTaskTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmCreateJobTaskTest.java
index ed5fa94100..718418eae0 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmCreateJobTaskTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmCreateJobTaskTest.java
@@ -49,130 +49,131 @@ import com.google.common.base.Optional;
*/
public class MonitorVnfmCreateJobTaskTest extends BaseTaskTest {
- private static final String JOB_ID = UUID.randomUUID().toString();
-
- @Mock
- private VnfmAdapterServiceProvider mockedVnfmAdapterServiceProvider;
-
- private final BuildingBlockExecution stubbedxecution = new StubbedBuildingBlockExecution();
-
- @Test
- public void testGetCurrentOperationStatus() throws Exception {
- final MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask();
- stubbedxecution.setVariable(Constants.CREATE_VNF_RESPONSE_PARAM_NAME, getCreateVnfResponse());
- Optional<QueryJobResponse> queryJobResponse = getQueryJobResponse();
- queryJobResponse.get().setOperationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.STATUS_FOUND);
- queryJobResponse.get().setOperationState(OperationStateEnum.COMPLETED);
- when(mockedVnfmAdapterServiceProvider.getInstantiateOperationJobStatus(JOB_ID)).thenReturn(queryJobResponse);
- objUnderTest.getCurrentOperationStatus(stubbedxecution);
- final Optional<OperationStateEnum> operationState =
- stubbedxecution.getVariable(Constants.OPERATION_STATUS_PARAM_NAME);
- assertNotNull(operationState);
- assertEquals(OperationStateEnum.COMPLETED, operationState.get());
- }
-
- @Test
- public void testGetCurrentOperationStatusFailed() throws Exception {
- final MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask();
- stubbedxecution.setVariable(Constants.CREATE_VNF_RESPONSE_PARAM_NAME, getCreateVnfResponse());
- Optional<QueryJobResponse> queryJobResponse = getQueryJobResponse();
- queryJobResponse.get().setOperationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.CANNOT_RETRIEVE_STATUS);
- queryJobResponse.get().setOperationState(OperationStateEnum.FAILED);
- when(mockedVnfmAdapterServiceProvider.getInstantiateOperationJobStatus(JOB_ID)).thenReturn(queryJobResponse);
- objUnderTest.getCurrentOperationStatus(stubbedxecution);
- final Optional<OperationStateEnum> operationState =
- stubbedxecution.getVariable(Constants.OPERATION_STATUS_PARAM_NAME);
- assertNotNull(operationState);
- assertEquals(OperationStateEnum.FAILED, operationState.get());
- }
-
- @Test
- public void testGetCurrentOperationStatusEmpty() throws Exception {
- final MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask();
- stubbedxecution.setVariable(Constants.CREATE_VNF_RESPONSE_PARAM_NAME, getCreateVnfResponse());
- Optional<QueryJobResponse> queryJobResponse = getQueryJobResponse();
- queryJobResponse.get().setOperationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.STATUS_FOUND);
- when(mockedVnfmAdapterServiceProvider.getInstantiateOperationJobStatus(JOB_ID)).thenReturn(queryJobResponse);
- objUnderTest.getCurrentOperationStatus(stubbedxecution);
- final Optional<OperationStateEnum> operationState =
- stubbedxecution.getVariable(Constants.OPERATION_STATUS_PARAM_NAME);
- assertFalse(operationState.isPresent());
- }
-
- @Test
- public void testGetCurrentOperationStatusException() throws Exception {
- final MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask();
- stubbedxecution.setVariable(Constants.CREATE_VNF_RESPONSE_PARAM_NAME, getCreateVnfResponse());
- Optional<QueryJobResponse> queryJobResponse = getQueryJobResponse();
- queryJobResponse.get().setOperationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.STATUS_FOUND);
- when(mockedVnfmAdapterServiceProvider.getInstantiateOperationJobStatus(JOB_ID)).thenReturn(queryJobResponse);
- objUnderTest.getCurrentOperationStatus(stubbedxecution);
- final Optional<OperationStateEnum> operationState =
- stubbedxecution.getVariable(Constants.OPERATION_STATUS_PARAM_NAME);
- assertFalse(operationState.isPresent());
- }
-
- @Test
- public void testHasOperationFinished() throws Exception {
- final MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask();
- stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.of(OperationStateEnum.COMPLETED));
- assertTrue(objUnderTest.hasOperationFinished(stubbedxecution));
- }
-
- @Test
- public void testHasOperationPending() throws Exception {
- final MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask();
- stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.absent());
- assertFalse(objUnderTest.hasOperationFinished(stubbedxecution));
- }
-
- @Test
- public void testTimeOutLogFailue() throws Exception {
- final MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask();
- objUnderTest.timeOutLogFailue(stubbedxecution);
- verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1205),
- eq("Instantiation operation time out"));
- }
-
- @Test
- public void testCheckIfOperationWasSuccessful() throws Exception {
- stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.of(OperationStateEnum.COMPLETED));
- MonitorVnfmCreateJobTask objUnderTest = Mockito.spy(getEtsiVnfMonitorJobTask());
- objUnderTest.checkIfOperationWasSuccessful(stubbedxecution);
- verify(objUnderTest, times(1)).checkIfOperationWasSuccessful(stubbedxecution);
- }
-
- @Test
- public void testCheckIfOperationWasSuccessfulWithPending() throws Exception {
- final MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask();
- stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.of(OperationStateEnum.PROCESSING));
- objUnderTest.checkIfOperationWasSuccessful(stubbedxecution);
- verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1207), anyString());
- }
-
- @Test
- public void testCheckIfOperationWasSuccessfulEmpty() throws Exception {
- MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask();
- stubbedxecution.setVariable(Constants.CREATE_VNF_RESPONSE_PARAM_NAME, getCreateVnfResponse());
- stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.absent());
- objUnderTest.checkIfOperationWasSuccessful(stubbedxecution);
- verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1206), anyString());
- }
-
- private CreateVnfResponse getCreateVnfResponse() {
- final CreateVnfResponse response = new CreateVnfResponse();
- response.setJobId(JOB_ID);
- return response;
- }
-
- private Optional<QueryJobResponse> getQueryJobResponse() {
- final QueryJobResponse queryJobResponse = new QueryJobResponse();
- queryJobResponse.setId(JOB_ID);
- return Optional.of(queryJobResponse);
- }
-
- private MonitorVnfmCreateJobTask getEtsiVnfMonitorJobTask() {
- return new MonitorVnfmCreateJobTask(mockedVnfmAdapterServiceProvider, exceptionUtil);
- }
+ private static final String JOB_ID = UUID.randomUUID().toString();
+
+ @Mock
+ private VnfmAdapterServiceProvider mockedVnfmAdapterServiceProvider;
+
+ private final BuildingBlockExecution stubbedxecution = new StubbedBuildingBlockExecution();
+
+ @Test
+ public void testGetCurrentOperationStatus() throws Exception {
+ final MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask();
+ stubbedxecution.setVariable(Constants.CREATE_VNF_RESPONSE_PARAM_NAME, getCreateVnfResponse());
+ Optional<QueryJobResponse> queryJobResponse = getQueryJobResponse();
+ queryJobResponse.get().setOperationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.STATUS_FOUND);
+ queryJobResponse.get().setOperationState(OperationStateEnum.COMPLETED);
+ when(mockedVnfmAdapterServiceProvider.getInstantiateOperationJobStatus(JOB_ID)).thenReturn(queryJobResponse);
+ objUnderTest.getCurrentOperationStatus(stubbedxecution);
+ final Optional<OperationStateEnum> operationState =
+ stubbedxecution.getVariable(Constants.OPERATION_STATUS_PARAM_NAME);
+ assertNotNull(operationState);
+ assertEquals(OperationStateEnum.COMPLETED, operationState.get());
+ }
+
+ @Test
+ public void testGetCurrentOperationStatusFailed() throws Exception {
+ final MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask();
+ stubbedxecution.setVariable(Constants.CREATE_VNF_RESPONSE_PARAM_NAME, getCreateVnfResponse());
+ Optional<QueryJobResponse> queryJobResponse = getQueryJobResponse();
+ queryJobResponse.get()
+ .setOperationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.CANNOT_RETRIEVE_STATUS);
+ queryJobResponse.get().setOperationState(OperationStateEnum.FAILED);
+ when(mockedVnfmAdapterServiceProvider.getInstantiateOperationJobStatus(JOB_ID)).thenReturn(queryJobResponse);
+ objUnderTest.getCurrentOperationStatus(stubbedxecution);
+ final Optional<OperationStateEnum> operationState =
+ stubbedxecution.getVariable(Constants.OPERATION_STATUS_PARAM_NAME);
+ assertNotNull(operationState);
+ assertEquals(OperationStateEnum.FAILED, operationState.get());
+ }
+
+ @Test
+ public void testGetCurrentOperationStatusEmpty() throws Exception {
+ final MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask();
+ stubbedxecution.setVariable(Constants.CREATE_VNF_RESPONSE_PARAM_NAME, getCreateVnfResponse());
+ Optional<QueryJobResponse> queryJobResponse = getQueryJobResponse();
+ queryJobResponse.get().setOperationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.STATUS_FOUND);
+ when(mockedVnfmAdapterServiceProvider.getInstantiateOperationJobStatus(JOB_ID)).thenReturn(queryJobResponse);
+ objUnderTest.getCurrentOperationStatus(stubbedxecution);
+ final Optional<OperationStateEnum> operationState =
+ stubbedxecution.getVariable(Constants.OPERATION_STATUS_PARAM_NAME);
+ assertFalse(operationState.isPresent());
+ }
+
+ @Test
+ public void testGetCurrentOperationStatusException() throws Exception {
+ final MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask();
+ stubbedxecution.setVariable(Constants.CREATE_VNF_RESPONSE_PARAM_NAME, getCreateVnfResponse());
+ Optional<QueryJobResponse> queryJobResponse = getQueryJobResponse();
+ queryJobResponse.get().setOperationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.STATUS_FOUND);
+ when(mockedVnfmAdapterServiceProvider.getInstantiateOperationJobStatus(JOB_ID)).thenReturn(queryJobResponse);
+ objUnderTest.getCurrentOperationStatus(stubbedxecution);
+ final Optional<OperationStateEnum> operationState =
+ stubbedxecution.getVariable(Constants.OPERATION_STATUS_PARAM_NAME);
+ assertFalse(operationState.isPresent());
+ }
+
+ @Test
+ public void testHasOperationFinished() throws Exception {
+ final MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask();
+ stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.of(OperationStateEnum.COMPLETED));
+ assertTrue(objUnderTest.hasOperationFinished(stubbedxecution));
+ }
+
+ @Test
+ public void testHasOperationPending() throws Exception {
+ final MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask();
+ stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.absent());
+ assertFalse(objUnderTest.hasOperationFinished(stubbedxecution));
+ }
+
+ @Test
+ public void testTimeOutLogFailue() throws Exception {
+ final MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask();
+ objUnderTest.timeOutLogFailue(stubbedxecution);
+ verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1205),
+ eq("Instantiation operation time out"));
+ }
+
+ @Test
+ public void testCheckIfOperationWasSuccessful() throws Exception {
+ stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.of(OperationStateEnum.COMPLETED));
+ MonitorVnfmCreateJobTask objUnderTest = Mockito.spy(getEtsiVnfMonitorJobTask());
+ objUnderTest.checkIfOperationWasSuccessful(stubbedxecution);
+ verify(objUnderTest, times(1)).checkIfOperationWasSuccessful(stubbedxecution);
+ }
+
+ @Test
+ public void testCheckIfOperationWasSuccessfulWithPending() throws Exception {
+ final MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask();
+ stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.of(OperationStateEnum.PROCESSING));
+ objUnderTest.checkIfOperationWasSuccessful(stubbedxecution);
+ verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1207), anyString());
+ }
+
+ @Test
+ public void testCheckIfOperationWasSuccessfulEmpty() throws Exception {
+ MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask();
+ stubbedxecution.setVariable(Constants.CREATE_VNF_RESPONSE_PARAM_NAME, getCreateVnfResponse());
+ stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.absent());
+ objUnderTest.checkIfOperationWasSuccessful(stubbedxecution);
+ verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1206), anyString());
+ }
+
+ private CreateVnfResponse getCreateVnfResponse() {
+ final CreateVnfResponse response = new CreateVnfResponse();
+ response.setJobId(JOB_ID);
+ return response;
+ }
+
+ private Optional<QueryJobResponse> getQueryJobResponse() {
+ final QueryJobResponse queryJobResponse = new QueryJobResponse();
+ queryJobResponse.setId(JOB_ID);
+ return Optional.of(queryJobResponse);
+ }
+
+ private MonitorVnfmCreateJobTask getEtsiVnfMonitorJobTask() {
+ return new MonitorVnfmCreateJobTask(mockedVnfmAdapterServiceProvider, exceptionUtil);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmDeleteJobTaskTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmDeleteJobTaskTest.java
index e41c571765..a821de1cd1 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmDeleteJobTaskTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmDeleteJobTaskTest.java
@@ -50,124 +50,125 @@ import com.google.common.base.Optional;
*/
public class MonitorVnfmDeleteJobTaskTest extends BaseTaskTest {
- private static final String JOB_ID = UUID.randomUUID().toString();
-
- private MonitorVnfmDeleteJobTask objUnderTest;
-
- @Mock
- private VnfmAdapterServiceProvider mockedVnfmAdapterServiceProvider;
-
- private final BuildingBlockExecution stubbedxecution = new StubbedBuildingBlockExecution();
-
- @Before
- public void setUp() {
- objUnderTest = getEtsiVnfMonitorJobTask();
- stubbedxecution.setVariable(Constants.DELETE_VNF_RESPONSE_PARAM_NAME, getDeleteVnfResponse());
- }
-
- @Test
- public void testGetCurrentOperationStatus() throws Exception {
- Optional<QueryJobResponse> queryJobResponse = getQueryJobResponse();
- queryJobResponse.get().setOperationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.STATUS_FOUND);
- queryJobResponse.get().setOperationState(OperationStateEnum.COMPLETED);
- when(mockedVnfmAdapterServiceProvider.getInstantiateOperationJobStatus(JOB_ID)).thenReturn(queryJobResponse);
- objUnderTest.getCurrentOperationStatus(stubbedxecution);
- final Optional<OperationStateEnum> operationState =
- stubbedxecution.getVariable(Constants.OPERATION_STATUS_PARAM_NAME);
- assertNotNull(operationState);
- assertEquals(OperationStateEnum.COMPLETED, operationState.get());
- }
-
- @Test
- public void testGetCurrentOperationStatusFailed() throws Exception {
- Optional<QueryJobResponse> queryJobResponse = getQueryJobResponse();
- queryJobResponse.get().setOperationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.CANNOT_RETRIEVE_STATUS);
- queryJobResponse.get().setOperationState(OperationStateEnum.FAILED);
- when(mockedVnfmAdapterServiceProvider.getInstantiateOperationJobStatus(JOB_ID)).thenReturn(queryJobResponse);
- objUnderTest.getCurrentOperationStatus(stubbedxecution);
- final Optional<OperationStateEnum> operationState =
- stubbedxecution.getVariable(Constants.OPERATION_STATUS_PARAM_NAME);
- assertNotNull(operationState);
- assertEquals(OperationStateEnum.FAILED, operationState.get());
- }
-
- @Test
- public void testGetCurrentOperationStatusEmpty() throws Exception {
- Optional<QueryJobResponse> queryJobResponse = getQueryJobResponse();
- queryJobResponse.get().setOperationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.STATUS_FOUND);
- when(mockedVnfmAdapterServiceProvider.getInstantiateOperationJobStatus(JOB_ID)).thenReturn(queryJobResponse);
- objUnderTest.getCurrentOperationStatus(stubbedxecution);
- final Optional<OperationStateEnum> operationState =
- stubbedxecution.getVariable(Constants.OPERATION_STATUS_PARAM_NAME);
- assertFalse(operationState.isPresent());
- }
-
- @Test
- public void testGetCurrentOperationStatusException() throws Exception {
- Optional<QueryJobResponse> queryJobResponse = getQueryJobResponse();
- queryJobResponse.get().setOperationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.STATUS_FOUND);
- when(mockedVnfmAdapterServiceProvider.getInstantiateOperationJobStatus(JOB_ID)).thenReturn(queryJobResponse);
- objUnderTest.getCurrentOperationStatus(stubbedxecution);
- final Optional<OperationStateEnum> operationState =
- stubbedxecution.getVariable(Constants.OPERATION_STATUS_PARAM_NAME);
- assertFalse(operationState.isPresent());
- }
-
- @Test
- public void testHasOperationFinished() throws Exception {
- stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.of(OperationStateEnum.COMPLETED));
- assertTrue(objUnderTest.hasOperationFinished(stubbedxecution));
- }
-
- @Test
- public void testHasOperationPending() throws Exception {
- stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.absent());
- assertFalse(objUnderTest.hasOperationFinished(stubbedxecution));
- }
-
- @Test
- public void testTimeOutLogFailue() throws Exception {
- objUnderTest.timeOutLogFailue(stubbedxecution);
- verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1213),
- eq("Delete operation time out"));
- }
-
- @Test
- public void testCheckIfOperationWasSuccessful() throws Exception {
- stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.of(OperationStateEnum.COMPLETED));
- MonitorVnfmDeleteJobTask spyObject = Mockito.spy(objUnderTest);
- spyObject.checkIfOperationWasSuccessful(stubbedxecution);
- verify(spyObject, times(1)).checkIfOperationWasSuccessful(stubbedxecution);
- }
-
- @Test
- public void testCheckIfOperationWasSuccessfulWithPending() throws Exception {
- stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.of(OperationStateEnum.PROCESSING));
- objUnderTest.checkIfOperationWasSuccessful(stubbedxecution);
- verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1215), anyString());
- }
-
- @Test
- public void testCheckIfOperationWasSuccessfulEmpty() throws Exception {
- stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.absent());
- objUnderTest.checkIfOperationWasSuccessful(stubbedxecution);
- verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1214), anyString());
- }
-
- private DeleteVnfResponse getDeleteVnfResponse() {
- final DeleteVnfResponse response = new DeleteVnfResponse();
- response.setJobId(JOB_ID);
- return response;
- }
-
- private Optional<QueryJobResponse> getQueryJobResponse() {
- final QueryJobResponse queryJobResponse = new QueryJobResponse();
- queryJobResponse.setId(JOB_ID);
- return Optional.of(queryJobResponse);
- }
-
- private MonitorVnfmDeleteJobTask getEtsiVnfMonitorJobTask() {
- return new MonitorVnfmDeleteJobTask(mockedVnfmAdapterServiceProvider, exceptionUtil);
- }
+ private static final String JOB_ID = UUID.randomUUID().toString();
+
+ private MonitorVnfmDeleteJobTask objUnderTest;
+
+ @Mock
+ private VnfmAdapterServiceProvider mockedVnfmAdapterServiceProvider;
+
+ private final BuildingBlockExecution stubbedxecution = new StubbedBuildingBlockExecution();
+
+ @Before
+ public void setUp() {
+ objUnderTest = getEtsiVnfMonitorJobTask();
+ stubbedxecution.setVariable(Constants.DELETE_VNF_RESPONSE_PARAM_NAME, getDeleteVnfResponse());
+ }
+
+ @Test
+ public void testGetCurrentOperationStatus() throws Exception {
+ Optional<QueryJobResponse> queryJobResponse = getQueryJobResponse();
+ queryJobResponse.get().setOperationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.STATUS_FOUND);
+ queryJobResponse.get().setOperationState(OperationStateEnum.COMPLETED);
+ when(mockedVnfmAdapterServiceProvider.getInstantiateOperationJobStatus(JOB_ID)).thenReturn(queryJobResponse);
+ objUnderTest.getCurrentOperationStatus(stubbedxecution);
+ final Optional<OperationStateEnum> operationState =
+ stubbedxecution.getVariable(Constants.OPERATION_STATUS_PARAM_NAME);
+ assertNotNull(operationState);
+ assertEquals(OperationStateEnum.COMPLETED, operationState.get());
+ }
+
+ @Test
+ public void testGetCurrentOperationStatusFailed() throws Exception {
+ Optional<QueryJobResponse> queryJobResponse = getQueryJobResponse();
+ queryJobResponse.get()
+ .setOperationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.CANNOT_RETRIEVE_STATUS);
+ queryJobResponse.get().setOperationState(OperationStateEnum.FAILED);
+ when(mockedVnfmAdapterServiceProvider.getInstantiateOperationJobStatus(JOB_ID)).thenReturn(queryJobResponse);
+ objUnderTest.getCurrentOperationStatus(stubbedxecution);
+ final Optional<OperationStateEnum> operationState =
+ stubbedxecution.getVariable(Constants.OPERATION_STATUS_PARAM_NAME);
+ assertNotNull(operationState);
+ assertEquals(OperationStateEnum.FAILED, operationState.get());
+ }
+
+ @Test
+ public void testGetCurrentOperationStatusEmpty() throws Exception {
+ Optional<QueryJobResponse> queryJobResponse = getQueryJobResponse();
+ queryJobResponse.get().setOperationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.STATUS_FOUND);
+ when(mockedVnfmAdapterServiceProvider.getInstantiateOperationJobStatus(JOB_ID)).thenReturn(queryJobResponse);
+ objUnderTest.getCurrentOperationStatus(stubbedxecution);
+ final Optional<OperationStateEnum> operationState =
+ stubbedxecution.getVariable(Constants.OPERATION_STATUS_PARAM_NAME);
+ assertFalse(operationState.isPresent());
+ }
+
+ @Test
+ public void testGetCurrentOperationStatusException() throws Exception {
+ Optional<QueryJobResponse> queryJobResponse = getQueryJobResponse();
+ queryJobResponse.get().setOperationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.STATUS_FOUND);
+ when(mockedVnfmAdapterServiceProvider.getInstantiateOperationJobStatus(JOB_ID)).thenReturn(queryJobResponse);
+ objUnderTest.getCurrentOperationStatus(stubbedxecution);
+ final Optional<OperationStateEnum> operationState =
+ stubbedxecution.getVariable(Constants.OPERATION_STATUS_PARAM_NAME);
+ assertFalse(operationState.isPresent());
+ }
+
+ @Test
+ public void testHasOperationFinished() throws Exception {
+ stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.of(OperationStateEnum.COMPLETED));
+ assertTrue(objUnderTest.hasOperationFinished(stubbedxecution));
+ }
+
+ @Test
+ public void testHasOperationPending() throws Exception {
+ stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.absent());
+ assertFalse(objUnderTest.hasOperationFinished(stubbedxecution));
+ }
+
+ @Test
+ public void testTimeOutLogFailue() throws Exception {
+ objUnderTest.timeOutLogFailue(stubbedxecution);
+ verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1213),
+ eq("Delete operation time out"));
+ }
+
+ @Test
+ public void testCheckIfOperationWasSuccessful() throws Exception {
+ stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.of(OperationStateEnum.COMPLETED));
+ MonitorVnfmDeleteJobTask spyObject = Mockito.spy(objUnderTest);
+ spyObject.checkIfOperationWasSuccessful(stubbedxecution);
+ verify(spyObject, times(1)).checkIfOperationWasSuccessful(stubbedxecution);
+ }
+
+ @Test
+ public void testCheckIfOperationWasSuccessfulWithPending() throws Exception {
+ stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.of(OperationStateEnum.PROCESSING));
+ objUnderTest.checkIfOperationWasSuccessful(stubbedxecution);
+ verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1215), anyString());
+ }
+
+ @Test
+ public void testCheckIfOperationWasSuccessfulEmpty() throws Exception {
+ stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.absent());
+ objUnderTest.checkIfOperationWasSuccessful(stubbedxecution);
+ verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1214), anyString());
+ }
+
+ private DeleteVnfResponse getDeleteVnfResponse() {
+ final DeleteVnfResponse response = new DeleteVnfResponse();
+ response.setJobId(JOB_ID);
+ return response;
+ }
+
+ private Optional<QueryJobResponse> getQueryJobResponse() {
+ final QueryJobResponse queryJobResponse = new QueryJobResponse();
+ queryJobResponse.setId(JOB_ID);
+ return Optional.of(queryJobResponse);
+ }
+
+ private MonitorVnfmDeleteJobTask getEtsiVnfMonitorJobTask() {
+ return new MonitorVnfmDeleteJobTask(mockedVnfmAdapterServiceProvider, exceptionUtil);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmNodeJobTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmNodeJobTest.java
index aa3ab113a0..6b84f6a918 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmNodeJobTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmNodeJobTest.java
@@ -46,66 +46,66 @@ import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
*/
public class MonitorVnfmNodeJobTest extends BaseTaskTest {
- private static final String VNF_ID = UUID.randomUUID().toString();
-
- private static final String VNF_NAME = "VNF_NAME";
-
- private MonitorVnfmNodeTask objUnderTest;
-
- @Mock
- private VnfmAdapterServiceProvider mockedVnfmAdapterServiceProvider;
-
- private final BuildingBlockExecution stubbedxecution = new StubbedBuildingBlockExecution();
-
- @Before
- public void setUp() {
- objUnderTest = getEtsiVnfMonitorNodeJobTask();
- }
-
- @Test
- public void testGetNodeStatusCreate() throws Exception {
- GenericVnf vnf = getGenericVnf();
- vnf.setOrchestrationStatus(VNF_CREATED);
- when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(vnf);
- objUnderTest.getNodeStatus(stubbedxecution);
- assertTrue(stubbedxecution.getVariable(CREATE_VNF_NODE_STATUS));
- }
-
- @Test
- public void testGetNodeStatusDelete() throws Exception {
- GenericVnf vnf = getGenericVnf();
- vnf.setOrchestrationStatus(VNF_ASSIGNED);
- when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(vnf);
- objUnderTest.getNodeStatus(stubbedxecution);
- assertTrue(stubbedxecution.getVariable(DELETE_VNF_NODE_STATUS));
- }
-
- @Test
- public void testGetNodeStatusException() throws Exception {
- when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenThrow(RuntimeException.class);
- objUnderTest.getNodeStatus(stubbedxecution);
- assertNull(stubbedxecution.getVariable(CREATE_VNF_NODE_STATUS));
- assertNull(stubbedxecution.getVariable(DELETE_VNF_NODE_STATUS));
- verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1220),
- any(Exception.class));
- }
-
- @Test
- public void testTimeOutLogFailue() throws Exception {
- objUnderTest.timeOutLogFailue(stubbedxecution);
- verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1221),
- eq("Node operation time out"));
- }
-
- private GenericVnf getGenericVnf() {
- final GenericVnf genericVnf = new GenericVnf();
- genericVnf.setVnfId(VNF_ID);
- genericVnf.setVnfName(VNF_NAME);
- return genericVnf;
- }
-
- private MonitorVnfmNodeTask getEtsiVnfMonitorNodeJobTask() {
- return new MonitorVnfmNodeTask(extractPojosForBB, exceptionUtil);
- }
+ private static final String VNF_ID = UUID.randomUUID().toString();
+
+ private static final String VNF_NAME = "VNF_NAME";
+
+ private MonitorVnfmNodeTask objUnderTest;
+
+ @Mock
+ private VnfmAdapterServiceProvider mockedVnfmAdapterServiceProvider;
+
+ private final BuildingBlockExecution stubbedxecution = new StubbedBuildingBlockExecution();
+
+ @Before
+ public void setUp() {
+ objUnderTest = getEtsiVnfMonitorNodeJobTask();
+ }
+
+ @Test
+ public void testGetNodeStatusCreate() throws Exception {
+ GenericVnf vnf = getGenericVnf();
+ vnf.setOrchestrationStatus(VNF_CREATED);
+ when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(vnf);
+ objUnderTest.getNodeStatus(stubbedxecution);
+ assertTrue(stubbedxecution.getVariable(CREATE_VNF_NODE_STATUS));
+ }
+
+ @Test
+ public void testGetNodeStatusDelete() throws Exception {
+ GenericVnf vnf = getGenericVnf();
+ vnf.setOrchestrationStatus(VNF_ASSIGNED);
+ when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(vnf);
+ objUnderTest.getNodeStatus(stubbedxecution);
+ assertTrue(stubbedxecution.getVariable(DELETE_VNF_NODE_STATUS));
+ }
+
+ @Test
+ public void testGetNodeStatusException() throws Exception {
+ when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenThrow(RuntimeException.class);
+ objUnderTest.getNodeStatus(stubbedxecution);
+ assertNull(stubbedxecution.getVariable(CREATE_VNF_NODE_STATUS));
+ assertNull(stubbedxecution.getVariable(DELETE_VNF_NODE_STATUS));
+ verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1220),
+ any(Exception.class));
+ }
+
+ @Test
+ public void testTimeOutLogFailue() throws Exception {
+ objUnderTest.timeOutLogFailue(stubbedxecution);
+ verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1221),
+ eq("Node operation time out"));
+ }
+
+ private GenericVnf getGenericVnf() {
+ final GenericVnf genericVnf = new GenericVnf();
+ genericVnf.setVnfId(VNF_ID);
+ genericVnf.setVnfName(VNF_NAME);
+ return genericVnf;
+ }
+
+ private MonitorVnfmNodeTask getEtsiVnfMonitorNodeJobTask() {
+ return new MonitorVnfmNodeTask(extractPojosForBB, exceptionUtil);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/StubbedBuildingBlockExecution.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/StubbedBuildingBlockExecution.java
index 260585d208..84012e8b8d 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/StubbedBuildingBlockExecution.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/StubbedBuildingBlockExecution.java
@@ -38,63 +38,63 @@ import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
*/
public class StubbedBuildingBlockExecution implements BuildingBlockExecution {
- private static final String CLOUD_OWNER = "CLOUD_OWNER";
- private static final String LCP_CLOUD_REGIONID = "RegionOnce";
- private static final String TENANT_ID = UUID.randomUUID().toString();
- private final Map<String, Serializable> execution = new HashMap<>();
- private final GeneralBuildingBlock generalBuildingBlock;
+ private static final String CLOUD_OWNER = "CLOUD_OWNER";
+ private static final String LCP_CLOUD_REGIONID = "RegionOnce";
+ private static final String TENANT_ID = UUID.randomUUID().toString();
+ private final Map<String, Serializable> execution = new HashMap<>();
+ private final GeneralBuildingBlock generalBuildingBlock;
- StubbedBuildingBlockExecution() {
- generalBuildingBlock = getGeneralBuildingBlockValue();
- }
+ StubbedBuildingBlockExecution() {
+ generalBuildingBlock = getGeneralBuildingBlockValue();
+ }
- @Override
- public GeneralBuildingBlock getGeneralBuildingBlock() {
- return generalBuildingBlock;
- }
+ @Override
+ public GeneralBuildingBlock getGeneralBuildingBlock() {
+ return generalBuildingBlock;
+ }
- @SuppressWarnings("unchecked")
- @Override
- public <T> T getVariable(final String key) {
- return (T) execution.get(key);
- }
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> T getVariable(final String key) {
+ return (T) execution.get(key);
+ }
- @Override
- public <T> T getRequiredVariable(final String key) throws RequiredExecutionVariableExeception {
- return null;
- }
+ @Override
+ public <T> T getRequiredVariable(final String key) throws RequiredExecutionVariableExeception {
+ return null;
+ }
- @Override
- public void setVariable(final String key, final Serializable value) {
- execution.put(key, value);
- }
+ @Override
+ public void setVariable(final String key, final Serializable value) {
+ execution.put(key, value);
+ }
- @Override
- public Map<ResourceKey, String> getLookupMap() {
- return Collections.emptyMap();
- }
+ @Override
+ public Map<ResourceKey, String> getLookupMap() {
+ return Collections.emptyMap();
+ }
- @Override
- public String getFlowToBeCalled() {
- return null;
- }
+ @Override
+ public String getFlowToBeCalled() {
+ return null;
+ }
- public static String getTenantId() {
- return TENANT_ID;
- }
+ public static String getTenantId() {
+ return TENANT_ID;
+ }
- private GeneralBuildingBlock getGeneralBuildingBlockValue() {
- final GeneralBuildingBlock buildingBlock = new GeneralBuildingBlock();
- buildingBlock.setCloudRegion(getCloudRegion());
- return buildingBlock;
- }
+ private GeneralBuildingBlock getGeneralBuildingBlockValue() {
+ final GeneralBuildingBlock buildingBlock = new GeneralBuildingBlock();
+ buildingBlock.setCloudRegion(getCloudRegion());
+ return buildingBlock;
+ }
- private CloudRegion getCloudRegion() {
- final CloudRegion cloudRegion = new CloudRegion();
- cloudRegion.setCloudOwner(CLOUD_OWNER);
- cloudRegion.setLcpCloudRegionId(LCP_CLOUD_REGIONID);
- cloudRegion.setTenantId(TENANT_ID);
- return cloudRegion;
- }
+ private CloudRegion getCloudRegion() {
+ final CloudRegion cloudRegion = new CloudRegion();
+ cloudRegion.setCloudOwner(CLOUD_OWNER);
+ cloudRegion.setLcpCloudRegionId(LCP_CLOUD_REGIONID);
+ cloudRegion.setTenantId(TENANT_ID);
+ return cloudRegion;
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/TestConstants.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/TestConstants.java
index c4f19d6d1a..7b63e5f811 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/TestConstants.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/TestConstants.java
@@ -21,9 +21,7 @@
package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks;
import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.TestConstants.DUMMY_URL;
-
import java.util.UUID;
-
import org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.VnfmBasicHttpConfigProvider;
/**
@@ -36,7 +34,7 @@ public class TestConstants {
public static final String DUMMY_BASIC_AUTH = "Basic 123abc";
public static final String DUMMY_URL = "http://localhost:30406/so/vnfm-adapter/v1/";
public static final String EXPECTED_URL = DUMMY_URL + "vnfs/" + DUMMY_GENERIC_VND_ID;
-
+
public static final String DUMMY_JOB_ID = UUID.randomUUID().toString();
public static final String JOB_STATUS_EXPECTED_URL = DUMMY_URL + "jobs/" + DUMMY_JOB_ID;
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTaskConfigurationTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTaskConfigurationTest.java
index 5aaebea76e..75151d9c6a 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTaskConfigurationTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTaskConfigurationTest.java
@@ -22,7 +22,6 @@ package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks;
import static org.junit.Assert.assertNotNull;
import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.TestConstants.getVnfmBasicHttpConfigProvider;
-
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTaskTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTaskTest.java
index 22c4c15079..cfa5aaa4b8 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTaskTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTaskTest.java
@@ -51,131 +51,132 @@ import com.google.common.base.Optional;
*/
public class VnfmAdapterCreateVnfTaskTest extends BaseTaskTest {
- private static final String MODEL_INSTANCE_NAME = "MODEL_INSTANCE_NAME";
+ private static final String MODEL_INSTANCE_NAME = "MODEL_INSTANCE_NAME";
- private static final String CLOUD_OWNER = "CLOUD_OWNER";
+ private static final String CLOUD_OWNER = "CLOUD_OWNER";
- private static final String LCP_CLOUD_REGIONID = "RegionOnce";
+ private static final String LCP_CLOUD_REGIONID = "RegionOnce";
- private static final String VNF_ID = UUID.randomUUID().toString();
+ private static final String VNF_ID = UUID.randomUUID().toString();
- private static final String VNF_NAME = "VNF_NAME";
+ private static final String VNF_NAME = "VNF_NAME";
- private static final String JOB_ID = UUID.randomUUID().toString();
+ private static final String JOB_ID = UUID.randomUUID().toString();
- @Mock
- private VnfmAdapterServiceProvider mockedVnfmAdapterServiceProvider;
+ @Mock
+ private VnfmAdapterServiceProvider mockedVnfmAdapterServiceProvider;
- private final BuildingBlockExecution stubbedxecution = new StubbedBuildingBlockExecution();
+ private final BuildingBlockExecution stubbedxecution = new StubbedBuildingBlockExecution();
- @Test
- public void testBuildCreateVnfRequest_withValidValues_storesRequestInExecution() throws Exception {
+ @Test
+ public void testBuildCreateVnfRequest_withValidValues_storesRequestInExecution() throws Exception {
- final VnfmAdapterCreateVnfTask objUnderTest = getEtsiVnfInstantiateTask();
- stubbedxecution.setVariable(INPUT_PARAMETER, new InputParameter(Collections.emptyMap(), Collections.emptyList()));
+ final VnfmAdapterCreateVnfTask objUnderTest = getEtsiVnfInstantiateTask();
+ stubbedxecution.setVariable(INPUT_PARAMETER,
+ new InputParameter(Collections.emptyMap(), Collections.emptyList()));
- when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(getGenericVnf());
- objUnderTest.buildCreateVnfRequest(stubbedxecution);
+ when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(getGenericVnf());
+ objUnderTest.buildCreateVnfRequest(stubbedxecution);
- final CreateVnfRequest actual = stubbedxecution.getVariable(CREATE_VNF_REQUEST_PARAM_NAME);
- assertNotNull(actual);
- assertEquals(VNF_NAME + "." + MODEL_INSTANCE_NAME, actual.getName());
+ final CreateVnfRequest actual = stubbedxecution.getVariable(CREATE_VNF_REQUEST_PARAM_NAME);
+ assertNotNull(actual);
+ assertEquals(VNF_NAME + "." + MODEL_INSTANCE_NAME, actual.getName());
- final Tenant actualTenant = actual.getTenant();
- assertEquals(CLOUD_OWNER, actualTenant.getCloudOwner());
- assertEquals(LCP_CLOUD_REGIONID, actualTenant.getRegionName());
- assertEquals(StubbedBuildingBlockExecution.getTenantId(), actualTenant.getTenantId());
+ final Tenant actualTenant = actual.getTenant();
+ assertEquals(CLOUD_OWNER, actualTenant.getCloudOwner());
+ assertEquals(LCP_CLOUD_REGIONID, actualTenant.getRegionName());
+ assertEquals(StubbedBuildingBlockExecution.getTenantId(), actualTenant.getTenantId());
- }
+ }
- @Test
- public void testBuildCreateVnfRequest_extractPojosForBBThrowsException_exceptionBuilderCalled() throws Exception {
+ @Test
+ public void testBuildCreateVnfRequest_extractPojosForBBThrowsException_exceptionBuilderCalled() throws Exception {
- final VnfmAdapterCreateVnfTask objUnderTest = getEtsiVnfInstantiateTask();
+ final VnfmAdapterCreateVnfTask objUnderTest = getEtsiVnfInstantiateTask();
- when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenThrow(RuntimeException.class);
+ when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenThrow(RuntimeException.class);
- objUnderTest.buildCreateVnfRequest(stubbedxecution);
+ objUnderTest.buildCreateVnfRequest(stubbedxecution);
- final CreateVnfRequest actual = stubbedxecution.getVariable(CREATE_VNF_REQUEST_PARAM_NAME);
+ final CreateVnfRequest actual = stubbedxecution.getVariable(CREATE_VNF_REQUEST_PARAM_NAME);
- assertNull(actual);
- verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1200),
- any(Exception.class));
+ assertNull(actual);
+ verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1200),
+ any(Exception.class));
- }
+ }
- @Test
- public void testInvokeVnfmAdapter_validValues_storesResponseInExecution() throws Exception {
+ @Test
+ public void testInvokeVnfmAdapter_validValues_storesResponseInExecution() throws Exception {
- final VnfmAdapterCreateVnfTask objUnderTest = getEtsiVnfInstantiateTask();
+ final VnfmAdapterCreateVnfTask objUnderTest = getEtsiVnfInstantiateTask();
- stubbedxecution.setVariable(CREATE_VNF_REQUEST_PARAM_NAME, new CreateVnfRequest());
+ stubbedxecution.setVariable(CREATE_VNF_REQUEST_PARAM_NAME, new CreateVnfRequest());
- when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(getGenericVnf());
- when(mockedVnfmAdapterServiceProvider.invokeCreateInstantiationRequest(eq(VNF_ID), any(CreateVnfRequest.class)))
- .thenReturn(getCreateVnfResponse());
+ when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(getGenericVnf());
+ when(mockedVnfmAdapterServiceProvider.invokeCreateInstantiationRequest(eq(VNF_ID), any(CreateVnfRequest.class)))
+ .thenReturn(getCreateVnfResponse());
- objUnderTest.invokeVnfmAdapter(stubbedxecution);
+ objUnderTest.invokeVnfmAdapter(stubbedxecution);
- assertNotNull(stubbedxecution.getVariable(CREATE_VNF_RESPONSE_PARAM_NAME));
- }
+ assertNotNull(stubbedxecution.getVariable(CREATE_VNF_RESPONSE_PARAM_NAME));
+ }
- @Test
- public void testInvokeVnfmAdapter_invalidValues_storesResponseInExecution() throws Exception {
+ @Test
+ public void testInvokeVnfmAdapter_invalidValues_storesResponseInExecution() throws Exception {
- final VnfmAdapterCreateVnfTask objUnderTest = getEtsiVnfInstantiateTask();
+ final VnfmAdapterCreateVnfTask objUnderTest = getEtsiVnfInstantiateTask();
- stubbedxecution.setVariable(CREATE_VNF_REQUEST_PARAM_NAME, new CreateVnfRequest());
+ stubbedxecution.setVariable(CREATE_VNF_REQUEST_PARAM_NAME, new CreateVnfRequest());
- when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(getGenericVnf());
- when(mockedVnfmAdapterServiceProvider.invokeCreateInstantiationRequest(eq(VNF_ID), any(CreateVnfRequest.class)))
- .thenReturn(Optional.absent());
+ when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(getGenericVnf());
+ when(mockedVnfmAdapterServiceProvider.invokeCreateInstantiationRequest(eq(VNF_ID), any(CreateVnfRequest.class)))
+ .thenReturn(Optional.absent());
- objUnderTest.invokeVnfmAdapter(stubbedxecution);
+ objUnderTest.invokeVnfmAdapter(stubbedxecution);
- assertNull(stubbedxecution.getVariable(CREATE_VNF_RESPONSE_PARAM_NAME));
- verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1202),
- any(Exception.class));
- }
+ assertNull(stubbedxecution.getVariable(CREATE_VNF_RESPONSE_PARAM_NAME));
+ verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1202),
+ any(Exception.class));
+ }
- @Test
- public void testInvokeVnfmAdapter_extractPojosForBBThrowsException_exceptionBuilderCalled() throws Exception {
+ @Test
+ public void testInvokeVnfmAdapter_extractPojosForBBThrowsException_exceptionBuilderCalled() throws Exception {
- final VnfmAdapterCreateVnfTask objUnderTest = getEtsiVnfInstantiateTask();
+ final VnfmAdapterCreateVnfTask objUnderTest = getEtsiVnfInstantiateTask();
- when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenThrow(RuntimeException.class);
+ when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenThrow(RuntimeException.class);
- objUnderTest.invokeVnfmAdapter(stubbedxecution);
+ objUnderTest.invokeVnfmAdapter(stubbedxecution);
- assertNull(stubbedxecution.getVariable(CREATE_VNF_RESPONSE_PARAM_NAME));
- verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1202),
- any(Exception.class));
+ assertNull(stubbedxecution.getVariable(CREATE_VNF_RESPONSE_PARAM_NAME));
+ verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1202),
+ any(Exception.class));
- }
+ }
- private Optional<CreateVnfResponse> getCreateVnfResponse() {
- final CreateVnfResponse response = new CreateVnfResponse();
- response.setJobId(JOB_ID);
- return Optional.of(response);
- }
+ private Optional<CreateVnfResponse> getCreateVnfResponse() {
+ final CreateVnfResponse response = new CreateVnfResponse();
+ response.setJobId(JOB_ID);
+ return Optional.of(response);
+ }
- private GenericVnf getGenericVnf() {
- final GenericVnf genericVnf = new GenericVnf();
- genericVnf.setVnfId(VNF_ID);
- genericVnf.setModelInfoGenericVnf(getModelInfoGenericVnf());
- genericVnf.setVnfName(VNF_NAME);
- return genericVnf;
- }
+ private GenericVnf getGenericVnf() {
+ final GenericVnf genericVnf = new GenericVnf();
+ genericVnf.setVnfId(VNF_ID);
+ genericVnf.setModelInfoGenericVnf(getModelInfoGenericVnf());
+ genericVnf.setVnfName(VNF_NAME);
+ return genericVnf;
+ }
- private ModelInfoGenericVnf getModelInfoGenericVnf() {
- final ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
- modelInfoGenericVnf.setModelInstanceName(MODEL_INSTANCE_NAME);
- return modelInfoGenericVnf;
- }
+ private ModelInfoGenericVnf getModelInfoGenericVnf() {
+ final ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setModelInstanceName(MODEL_INSTANCE_NAME);
+ return modelInfoGenericVnf;
+ }
- private VnfmAdapterCreateVnfTask getEtsiVnfInstantiateTask() {
- return new VnfmAdapterCreateVnfTask(exceptionUtil, extractPojosForBB, mockedVnfmAdapterServiceProvider);
- }
+ private VnfmAdapterCreateVnfTask getEtsiVnfInstantiateTask() {
+ return new VnfmAdapterCreateVnfTask(exceptionUtil, extractPojosForBB, mockedVnfmAdapterServiceProvider);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImplTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImplTest.java
index 6f1b6f0bd2..7bd6435b60 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImplTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImplTest.java
@@ -52,242 +52,242 @@ import com.google.common.base.Optional;
@RunWith(MockitoJUnitRunner.class)
public class VnfmAdapterServiceProviderImplTest {
- private static final String EMPTY_JOB_ID = "";
-
- private static final CreateVnfRequest CREATE_VNF_REQUEST = new CreateVnfRequest();
-
- @Mock
- private HttpRestServiceProvider mockedHttpServiceProvider;
-
- @Mock
- private ResponseEntity<CreateVnfResponse> mockedResponseEntity;
-
- @Mock
- private ResponseEntity<DeleteVnfResponse> deleteVnfResponse;
- @Mock
- private ResponseEntity<QueryJobResponse> mockedQueryJobResponseResponseEntity;
-
- @Test
- public void testInvokeCreateInstantiationRequest_httpServiceProviderReturnsStatusAcceptedWithBody_validResponse() {
-
- when(mockedHttpServiceProvider.postHttpRequest(eq(CREATE_VNF_REQUEST), anyString(), eq(CreateVnfResponse.class)))
- .thenReturn(mockedResponseEntity);
- when(mockedResponseEntity.getStatusCode()).thenReturn(HttpStatus.ACCEPTED);
- when(mockedResponseEntity.hasBody()).thenReturn(true);
- final CreateVnfResponse response = getCreateVnfResponse(DUMMY_JOB_ID);
- when(mockedResponseEntity.getBody()).thenReturn(response);
- final VnfmAdapterServiceProvider objUnderTest =
- new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
- final Optional<CreateVnfResponse> actual =
- objUnderTest.invokeCreateInstantiationRequest(DUMMY_GENERIC_VND_ID, CREATE_VNF_REQUEST);
- assertTrue(actual.isPresent());
- assertEquals(actual.get(), response);
- }
-
- @Test
- public void testInvokeCreateInstantiationRequest_httpServiceProviderReturnsStatusAcceptedWithNoBody_noResponse() {
- assertWithStatuCode(HttpStatus.ACCEPTED);
- }
-
- @Test
- public void testInvokeCreateInstantiationRequest_httpServiceProviderReturnsStatusNotOkWithNoBody_noResponse() {
- assertWithStatuCode(HttpStatus.UNAUTHORIZED);
- }
-
-
- @Test
- public void testInvokeCreateInstantiationRequest_httpServiceProviderReturnsStatusAcceptedWithBodyWithInvalidJobId_noResponse() {
- assertWithJobId(null);
- assertWithJobId(EMPTY_JOB_ID);
- }
-
- @Test
- public void testInvokeCreateInstantiationRequest_httpServiceProviderThrowException_httpRestServiceProviderNotNull() {
-
- when(mockedHttpServiceProvider.postHttpRequest(eq(CREATE_VNF_REQUEST), anyString(), eq(CreateVnfResponse.class)))
- .thenThrow(RestProcessingException.class);
-
-
- final VnfmAdapterServiceProvider objUnderTest =
- new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
-
- final Optional<CreateVnfResponse> actual =
- objUnderTest.invokeCreateInstantiationRequest(DUMMY_GENERIC_VND_ID, CREATE_VNF_REQUEST);
- assertFalse(actual.isPresent());
-
- }
-
- @Test
- public void testInvokeDeleteRequest() {
- when(mockedHttpServiceProvider.deleteHttpRequest(anyString(), eq(DeleteVnfResponse.class)))
- .thenReturn(deleteVnfResponse);
- when(deleteVnfResponse.getStatusCode()).thenReturn(HttpStatus.ACCEPTED);
- when(deleteVnfResponse.hasBody()).thenReturn(true);
- final DeleteVnfResponse response = getDeleteVnfResponse(DUMMY_JOB_ID);
- when(deleteVnfResponse.getBody()).thenReturn(response);
- final VnfmAdapterServiceProvider objUnderTest =
- new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
- final Optional<DeleteVnfResponse> actual = objUnderTest.invokeDeleteRequest(DUMMY_GENERIC_VND_ID);
- assertTrue(actual.isPresent());
- }
-
- @Test
- public void testInvokeDeleteRequestNotAccepted() {
- when(mockedHttpServiceProvider.deleteHttpRequest(anyString(), eq(DeleteVnfResponse.class)))
- .thenReturn(deleteVnfResponse);
- when(deleteVnfResponse.getStatusCode()).thenReturn(HttpStatus.BAD_GATEWAY);
- final VnfmAdapterServiceProvider objUnderTest =
- new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
- final Optional<DeleteVnfResponse> actual = objUnderTest.invokeDeleteRequest(DUMMY_GENERIC_VND_ID);
- assertFalse(actual.isPresent());
- }
-
- @Test
- public void testInvokeDeleteRequestNoBody() {
- when(mockedHttpServiceProvider.deleteHttpRequest(anyString(), eq(DeleteVnfResponse.class)))
- .thenReturn(deleteVnfResponse);
- when(deleteVnfResponse.getStatusCode()).thenReturn(HttpStatus.ACCEPTED);
- when(deleteVnfResponse.hasBody()).thenReturn(false);
- final VnfmAdapterServiceProvider objUnderTest =
- new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
- final Optional<DeleteVnfResponse> actual = objUnderTest.invokeDeleteRequest(DUMMY_GENERIC_VND_ID);
- assertFalse(actual.isPresent());
- }
-
- @Test
- public void testInvokeDeleteRequestNoJobId() {
- when(mockedHttpServiceProvider.deleteHttpRequest(anyString(), eq(DeleteVnfResponse.class)))
- .thenReturn(deleteVnfResponse);
- when(deleteVnfResponse.getStatusCode()).thenReturn(HttpStatus.ACCEPTED);
- when(deleteVnfResponse.hasBody()).thenReturn(true);
- final DeleteVnfResponse response = getDeleteVnfResponse("");
- when(deleteVnfResponse.getBody()).thenReturn(response);
- final VnfmAdapterServiceProvider objUnderTest =
- new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
- final Optional<DeleteVnfResponse> actual = objUnderTest.invokeDeleteRequest(DUMMY_GENERIC_VND_ID);
- assertFalse(actual.isPresent());
- }
-
- @Test
- public void testInvokeDeleteRequestException() {
- when(mockedHttpServiceProvider.deleteHttpRequest(anyString(), eq(DeleteVnfResponse.class)))
- .thenThrow(RestProcessingException.class);
- final VnfmAdapterServiceProvider objUnderTest =
- new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
- final Optional<DeleteVnfResponse> actual = objUnderTest.invokeDeleteRequest(DUMMY_GENERIC_VND_ID);
- assertFalse(actual.isPresent());
- }
-
- @Test
- public void testGetInstantiateOperationJobStatus_httpServiceProviderReturnsStatusOkWithBody_validResponse() {
-
- when(mockedQueryJobResponseResponseEntity.getStatusCode()).thenReturn(HttpStatus.OK);
- when(mockedQueryJobResponseResponseEntity.hasBody()).thenReturn(true);
- when(mockedQueryJobResponseResponseEntity.getBody()).thenReturn(getQueryJobResponse());
-
- when(mockedHttpServiceProvider.getHttpResponse(eq(TestConstants.JOB_STATUS_EXPECTED_URL),
- eq(QueryJobResponse.class))).thenReturn(mockedQueryJobResponseResponseEntity);
-
- final VnfmAdapterServiceProvider objUnderTest =
- new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
-
- final Optional<QueryJobResponse> actual = objUnderTest.getInstantiateOperationJobStatus(DUMMY_JOB_ID);
- assertTrue(actual.isPresent());
- final QueryJobResponse actualQueryJobResponse = actual.get();
- assertNotNull(actualQueryJobResponse);
- }
-
- @Test
- public void testGetInstantiateOperationJobStatus_httpServiceProviderReturnsStatusOkWithOutBody_invalidResponse() {
-
- when(mockedQueryJobResponseResponseEntity.getStatusCode()).thenReturn(HttpStatus.OK);
- when(mockedQueryJobResponseResponseEntity.hasBody()).thenReturn(false);
-
- when(mockedHttpServiceProvider.getHttpResponse(eq(TestConstants.JOB_STATUS_EXPECTED_URL),
- eq(QueryJobResponse.class))).thenReturn(mockedQueryJobResponseResponseEntity);
-
- final VnfmAdapterServiceProvider objUnderTest =
- new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
-
- final Optional<QueryJobResponse> actual = objUnderTest.getInstantiateOperationJobStatus(DUMMY_JOB_ID);
- assertFalse(actual.isPresent());
- }
-
- @Test
- public void testGetInstantiateOperationJobStatus_httpServiceProviderReturnsStatusNotOkWithOutBody_invalidResponse() {
-
- when(mockedQueryJobResponseResponseEntity.getStatusCode()).thenReturn(HttpStatus.INTERNAL_SERVER_ERROR);
-
- when(mockedHttpServiceProvider.getHttpResponse(eq(TestConstants.JOB_STATUS_EXPECTED_URL),
- eq(QueryJobResponse.class))).thenReturn(mockedQueryJobResponseResponseEntity);
-
- final VnfmAdapterServiceProvider objUnderTest =
- new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
-
- final Optional<QueryJobResponse> actual = objUnderTest.getInstantiateOperationJobStatus(DUMMY_JOB_ID);
- assertFalse(actual.isPresent());
- }
-
- @Test
- public void testGetInstantiateOperationJobStatus_Exception() {
-
- when(mockedHttpServiceProvider.getHttpResponse(eq(TestConstants.JOB_STATUS_EXPECTED_URL),
- eq(QueryJobResponse.class))).thenThrow(RestProcessingException.class);
-
- final VnfmAdapterServiceProvider objUnderTest =
- new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
-
- final Optional<QueryJobResponse> actual = objUnderTest.getInstantiateOperationJobStatus(DUMMY_JOB_ID);
- assertFalse(actual.isPresent());
- }
-
- private QueryJobResponse getQueryJobResponse() {
- return new QueryJobResponse().id(DUMMY_JOB_ID).operationState(OperationStateEnum.COMPLETED);
-
- }
-
- private void assertWithJobId(final String jobId) {
- when(mockedHttpServiceProvider.postHttpRequest(eq(CREATE_VNF_REQUEST), anyString(), eq(CreateVnfResponse.class)))
- .thenReturn(mockedResponseEntity);
- when(mockedResponseEntity.getStatusCode()).thenReturn(HttpStatus.ACCEPTED);
- when(mockedResponseEntity.hasBody()).thenReturn(true);
- final CreateVnfResponse response = getCreateVnfResponse(jobId);
- when(mockedResponseEntity.getBody()).thenReturn(response);
-
-
- final VnfmAdapterServiceProvider objUnderTest =
- new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
-
- final Optional<CreateVnfResponse> actual =
- objUnderTest.invokeCreateInstantiationRequest(DUMMY_GENERIC_VND_ID, CREATE_VNF_REQUEST);
- assertFalse(actual.isPresent());
- }
-
- private void assertWithStatuCode(final HttpStatus status) {
- when(mockedHttpServiceProvider.postHttpRequest(eq(CREATE_VNF_REQUEST), anyString(), eq(CreateVnfResponse.class)))
- .thenReturn(mockedResponseEntity);
- when(mockedResponseEntity.getStatusCode()).thenReturn(status);
- when(mockedResponseEntity.hasBody()).thenReturn(false);
+ private static final String EMPTY_JOB_ID = "";
+
+ private static final CreateVnfRequest CREATE_VNF_REQUEST = new CreateVnfRequest();
+
+ @Mock
+ private HttpRestServiceProvider mockedHttpServiceProvider;
+
+ @Mock
+ private ResponseEntity<CreateVnfResponse> mockedResponseEntity;
+
+ @Mock
+ private ResponseEntity<DeleteVnfResponse> deleteVnfResponse;
+ @Mock
+ private ResponseEntity<QueryJobResponse> mockedQueryJobResponseResponseEntity;
+
+ @Test
+ public void testInvokeCreateInstantiationRequest_httpServiceProviderReturnsStatusAcceptedWithBody_validResponse() {
+
+ when(mockedHttpServiceProvider.postHttpRequest(eq(CREATE_VNF_REQUEST), anyString(),
+ eq(CreateVnfResponse.class))).thenReturn(mockedResponseEntity);
+ when(mockedResponseEntity.getStatusCode()).thenReturn(HttpStatus.ACCEPTED);
+ when(mockedResponseEntity.hasBody()).thenReturn(true);
+ final CreateVnfResponse response = getCreateVnfResponse(DUMMY_JOB_ID);
+ when(mockedResponseEntity.getBody()).thenReturn(response);
+ final VnfmAdapterServiceProvider objUnderTest =
+ new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
+ final Optional<CreateVnfResponse> actual =
+ objUnderTest.invokeCreateInstantiationRequest(DUMMY_GENERIC_VND_ID, CREATE_VNF_REQUEST);
+ assertTrue(actual.isPresent());
+ assertEquals(actual.get(), response);
+ }
+
+ @Test
+ public void testInvokeCreateInstantiationRequest_httpServiceProviderReturnsStatusAcceptedWithNoBody_noResponse() {
+ assertWithStatuCode(HttpStatus.ACCEPTED);
+ }
+
+ @Test
+ public void testInvokeCreateInstantiationRequest_httpServiceProviderReturnsStatusNotOkWithNoBody_noResponse() {
+ assertWithStatuCode(HttpStatus.UNAUTHORIZED);
+ }
+
+
+ @Test
+ public void testInvokeCreateInstantiationRequest_httpServiceProviderReturnsStatusAcceptedWithBodyWithInvalidJobId_noResponse() {
+ assertWithJobId(null);
+ assertWithJobId(EMPTY_JOB_ID);
+ }
+
+ @Test
+ public void testInvokeCreateInstantiationRequest_httpServiceProviderThrowException_httpRestServiceProviderNotNull() {
+
+ when(mockedHttpServiceProvider.postHttpRequest(eq(CREATE_VNF_REQUEST), anyString(),
+ eq(CreateVnfResponse.class))).thenThrow(RestProcessingException.class);
+
+
+ final VnfmAdapterServiceProvider objUnderTest =
+ new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
+
+ final Optional<CreateVnfResponse> actual =
+ objUnderTest.invokeCreateInstantiationRequest(DUMMY_GENERIC_VND_ID, CREATE_VNF_REQUEST);
+ assertFalse(actual.isPresent());
+
+ }
+
+ @Test
+ public void testInvokeDeleteRequest() {
+ when(mockedHttpServiceProvider.deleteHttpRequest(anyString(), eq(DeleteVnfResponse.class)))
+ .thenReturn(deleteVnfResponse);
+ when(deleteVnfResponse.getStatusCode()).thenReturn(HttpStatus.ACCEPTED);
+ when(deleteVnfResponse.hasBody()).thenReturn(true);
+ final DeleteVnfResponse response = getDeleteVnfResponse(DUMMY_JOB_ID);
+ when(deleteVnfResponse.getBody()).thenReturn(response);
+ final VnfmAdapterServiceProvider objUnderTest =
+ new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
+ final Optional<DeleteVnfResponse> actual = objUnderTest.invokeDeleteRequest(DUMMY_GENERIC_VND_ID);
+ assertTrue(actual.isPresent());
+ }
+
+ @Test
+ public void testInvokeDeleteRequestNotAccepted() {
+ when(mockedHttpServiceProvider.deleteHttpRequest(anyString(), eq(DeleteVnfResponse.class)))
+ .thenReturn(deleteVnfResponse);
+ when(deleteVnfResponse.getStatusCode()).thenReturn(HttpStatus.BAD_GATEWAY);
+ final VnfmAdapterServiceProvider objUnderTest =
+ new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
+ final Optional<DeleteVnfResponse> actual = objUnderTest.invokeDeleteRequest(DUMMY_GENERIC_VND_ID);
+ assertFalse(actual.isPresent());
+ }
+
+ @Test
+ public void testInvokeDeleteRequestNoBody() {
+ when(mockedHttpServiceProvider.deleteHttpRequest(anyString(), eq(DeleteVnfResponse.class)))
+ .thenReturn(deleteVnfResponse);
+ when(deleteVnfResponse.getStatusCode()).thenReturn(HttpStatus.ACCEPTED);
+ when(deleteVnfResponse.hasBody()).thenReturn(false);
+ final VnfmAdapterServiceProvider objUnderTest =
+ new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
+ final Optional<DeleteVnfResponse> actual = objUnderTest.invokeDeleteRequest(DUMMY_GENERIC_VND_ID);
+ assertFalse(actual.isPresent());
+ }
+
+ @Test
+ public void testInvokeDeleteRequestNoJobId() {
+ when(mockedHttpServiceProvider.deleteHttpRequest(anyString(), eq(DeleteVnfResponse.class)))
+ .thenReturn(deleteVnfResponse);
+ when(deleteVnfResponse.getStatusCode()).thenReturn(HttpStatus.ACCEPTED);
+ when(deleteVnfResponse.hasBody()).thenReturn(true);
+ final DeleteVnfResponse response = getDeleteVnfResponse("");
+ when(deleteVnfResponse.getBody()).thenReturn(response);
+ final VnfmAdapterServiceProvider objUnderTest =
+ new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
+ final Optional<DeleteVnfResponse> actual = objUnderTest.invokeDeleteRequest(DUMMY_GENERIC_VND_ID);
+ assertFalse(actual.isPresent());
+ }
+
+ @Test
+ public void testInvokeDeleteRequestException() {
+ when(mockedHttpServiceProvider.deleteHttpRequest(anyString(), eq(DeleteVnfResponse.class)))
+ .thenThrow(RestProcessingException.class);
+ final VnfmAdapterServiceProvider objUnderTest =
+ new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
+ final Optional<DeleteVnfResponse> actual = objUnderTest.invokeDeleteRequest(DUMMY_GENERIC_VND_ID);
+ assertFalse(actual.isPresent());
+ }
+
+ @Test
+ public void testGetInstantiateOperationJobStatus_httpServiceProviderReturnsStatusOkWithBody_validResponse() {
+
+ when(mockedQueryJobResponseResponseEntity.getStatusCode()).thenReturn(HttpStatus.OK);
+ when(mockedQueryJobResponseResponseEntity.hasBody()).thenReturn(true);
+ when(mockedQueryJobResponseResponseEntity.getBody()).thenReturn(getQueryJobResponse());
+
+ when(mockedHttpServiceProvider.getHttpResponse(eq(TestConstants.JOB_STATUS_EXPECTED_URL),
+ eq(QueryJobResponse.class))).thenReturn(mockedQueryJobResponseResponseEntity);
+
+ final VnfmAdapterServiceProvider objUnderTest =
+ new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
+
+ final Optional<QueryJobResponse> actual = objUnderTest.getInstantiateOperationJobStatus(DUMMY_JOB_ID);
+ assertTrue(actual.isPresent());
+ final QueryJobResponse actualQueryJobResponse = actual.get();
+ assertNotNull(actualQueryJobResponse);
+ }
+
+ @Test
+ public void testGetInstantiateOperationJobStatus_httpServiceProviderReturnsStatusOkWithOutBody_invalidResponse() {
+
+ when(mockedQueryJobResponseResponseEntity.getStatusCode()).thenReturn(HttpStatus.OK);
+ when(mockedQueryJobResponseResponseEntity.hasBody()).thenReturn(false);
+
+ when(mockedHttpServiceProvider.getHttpResponse(eq(TestConstants.JOB_STATUS_EXPECTED_URL),
+ eq(QueryJobResponse.class))).thenReturn(mockedQueryJobResponseResponseEntity);
+
+ final VnfmAdapterServiceProvider objUnderTest =
+ new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
+
+ final Optional<QueryJobResponse> actual = objUnderTest.getInstantiateOperationJobStatus(DUMMY_JOB_ID);
+ assertFalse(actual.isPresent());
+ }
+
+ @Test
+ public void testGetInstantiateOperationJobStatus_httpServiceProviderReturnsStatusNotOkWithOutBody_invalidResponse() {
+
+ when(mockedQueryJobResponseResponseEntity.getStatusCode()).thenReturn(HttpStatus.INTERNAL_SERVER_ERROR);
+
+ when(mockedHttpServiceProvider.getHttpResponse(eq(TestConstants.JOB_STATUS_EXPECTED_URL),
+ eq(QueryJobResponse.class))).thenReturn(mockedQueryJobResponseResponseEntity);
+
+ final VnfmAdapterServiceProvider objUnderTest =
+ new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
+
+ final Optional<QueryJobResponse> actual = objUnderTest.getInstantiateOperationJobStatus(DUMMY_JOB_ID);
+ assertFalse(actual.isPresent());
+ }
+
+ @Test
+ public void testGetInstantiateOperationJobStatus_Exception() {
+
+ when(mockedHttpServiceProvider.getHttpResponse(eq(TestConstants.JOB_STATUS_EXPECTED_URL),
+ eq(QueryJobResponse.class))).thenThrow(RestProcessingException.class);
+
+ final VnfmAdapterServiceProvider objUnderTest =
+ new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
+
+ final Optional<QueryJobResponse> actual = objUnderTest.getInstantiateOperationJobStatus(DUMMY_JOB_ID);
+ assertFalse(actual.isPresent());
+ }
+
+ private QueryJobResponse getQueryJobResponse() {
+ return new QueryJobResponse().id(DUMMY_JOB_ID).operationState(OperationStateEnum.COMPLETED);
+
+ }
+
+ private void assertWithJobId(final String jobId) {
+ when(mockedHttpServiceProvider.postHttpRequest(eq(CREATE_VNF_REQUEST), anyString(),
+ eq(CreateVnfResponse.class))).thenReturn(mockedResponseEntity);
+ when(mockedResponseEntity.getStatusCode()).thenReturn(HttpStatus.ACCEPTED);
+ when(mockedResponseEntity.hasBody()).thenReturn(true);
+ final CreateVnfResponse response = getCreateVnfResponse(jobId);
+ when(mockedResponseEntity.getBody()).thenReturn(response);
+
+
+ final VnfmAdapterServiceProvider objUnderTest =
+ new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
+
+ final Optional<CreateVnfResponse> actual =
+ objUnderTest.invokeCreateInstantiationRequest(DUMMY_GENERIC_VND_ID, CREATE_VNF_REQUEST);
+ assertFalse(actual.isPresent());
+ }
- final VnfmAdapterServiceProvider objUnderTest =
- new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
+ private void assertWithStatuCode(final HttpStatus status) {
+ when(mockedHttpServiceProvider.postHttpRequest(eq(CREATE_VNF_REQUEST), anyString(),
+ eq(CreateVnfResponse.class))).thenReturn(mockedResponseEntity);
+ when(mockedResponseEntity.getStatusCode()).thenReturn(status);
+ when(mockedResponseEntity.hasBody()).thenReturn(false);
- final Optional<CreateVnfResponse> actual =
- objUnderTest.invokeCreateInstantiationRequest(DUMMY_GENERIC_VND_ID, CREATE_VNF_REQUEST);
- assertFalse(actual.isPresent());
- }
+ final VnfmAdapterServiceProvider objUnderTest =
+ new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
- private CreateVnfResponse getCreateVnfResponse(final String jobId) {
- return new CreateVnfResponse().jobId(jobId);
- }
+ final Optional<CreateVnfResponse> actual =
+ objUnderTest.invokeCreateInstantiationRequest(DUMMY_GENERIC_VND_ID, CREATE_VNF_REQUEST);
+ assertFalse(actual.isPresent());
+ }
- private DeleteVnfResponse getDeleteVnfResponse(final String jobId) {
- final DeleteVnfResponse response = new DeleteVnfResponse();
- response.setJobId(jobId);
- return response;
- }
+ private CreateVnfResponse getCreateVnfResponse(final String jobId) {
+ return new CreateVnfResponse().jobId(jobId);
+ }
- private VnfmAdapterUrlProvider getVnfmAdapterUrlProvider() {
- return new VnfmAdapterUrlProvider(getVnfmBasicHttpConfigProvider());
- }
+ private DeleteVnfResponse getDeleteVnfResponse(final String jobId) {
+ final DeleteVnfResponse response = new DeleteVnfResponse();
+ response.setJobId(jobId);
+ return response;
+ }
+
+ private VnfmAdapterUrlProvider getVnfmAdapterUrlProvider() {
+ return new VnfmAdapterUrlProvider(getVnfmBasicHttpConfigProvider());
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterUrlProviderTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterUrlProviderTest.java
index 133f24bbe1..4bffb845f4 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterUrlProviderTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterUrlProviderTest.java
@@ -26,7 +26,6 @@ import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.TestConstants.D
import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.TestConstants.EXPECTED_URL;
import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.TestConstants.JOB_STATUS_EXPECTED_URL;
import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.TestConstants.getVnfmBasicHttpConfigProvider;
-
import org.junit.Test;
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParametersProviderImplTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParametersProviderImplTest.java
index d21942d08f..51e86c1fea 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParametersProviderImplTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParametersProviderImplTest.java
@@ -26,14 +26,12 @@ import static org.mockito.Mockito.when;
import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.FORWARD_SLASH;
import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.PRELOAD_VNFS_URL;
import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.TestConstants.DUMMY_GENERIC_VND_ID;
-
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.Map;
-
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/VnfParameterTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/VnfParameterTest.java
index 46018b8f39..c7c61f9a1d 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/VnfParameterTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/VnfParameterTest.java
@@ -20,7 +20,6 @@
package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.utils;
import org.junit.Test;
-
import nl.jqno.equalsverifier.EqualsVerifier;
import nl.jqno.equalsverifier.Warning;
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksIT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksIT.java
index 9cf1a1cdc9..e7a8b35db8 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksIT.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksIT.java
@@ -24,11 +24,9 @@ import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import java.util.HashMap;
import java.util.Optional;
import java.util.UUID;
-
import org.junit.Before;
import org.junit.Test;
import org.onap.appc.client.lcm.model.Action;
@@ -40,62 +38,66 @@ import org.onap.so.db.catalog.beans.ControllerSelectionReference;
import org.springframework.beans.factory.annotation.Autowired;
public class AppcRunTasksIT extends BaseIntegrationTest {
-
- @Autowired
- private AppcRunTasks appcRunTasks;
-
- private GenericVnf genericVnf;
- private RequestContext requestContext;
- private String msoRequestId;
- @Before
- public void before() {
- genericVnf = setGenericVnf();
- msoRequestId = UUID.randomUUID().toString();
- requestContext = setRequestContext();
- requestContext.setMsoRequestId(msoRequestId);
- gBBInput.setRequestContext(requestContext);
- }
-
- @Test
- public void preProcessActivityTest() throws Exception {
- appcRunTasks.preProcessActivity(execution);
- assertEquals(execution.getVariable("actionQuiesceTraffic"), Action.QuiesceTraffic);
- assertEquals(execution.getVariable("rollbackQuiesceTraffic"), false);
- }
-
- @Test
- public void runAppcCommandTest() throws Exception {
- Action action = Action.QuiesceTraffic;
- ControllerSelectionReference controllerSelectionReference = new ControllerSelectionReference();
- controllerSelectionReference.setControllerName("testName");
- controllerSelectionReference.setActionCategory(action.toString());
- controllerSelectionReference.setVnfType("testVnfType");
-
- doReturn(controllerSelectionReference).when(catalogDbClient).getControllerSelectionReferenceByVnfTypeAndActionCategory(genericVnf.getVnfType(), Action.QuiesceTraffic.toString());
-
- execution.setVariable("aicIdentity", "testAicIdentity");
-
- String vnfId = genericVnf.getVnfId();
- genericVnf.setIpv4OamAddress("testOamIpAddress");
- String payload = "{\"testName\":\"testValue\",}";
- RequestParameters requestParameters = new RequestParameters();
- requestParameters.setPayload(payload);
- gBBInput.getRequestContext().setRequestParameters(requestParameters);
-
- String controllerType = "testName";
- HashMap<String, String> payloadInfo = new HashMap<String, String>();
- payloadInfo.put("vnfName", "testVnfName1");
- payloadInfo.put("aicIdentity", "testAicIdentity");
- payloadInfo.put("vnfHostIpAddress", "testOamIpAddress");
- payloadInfo.put("vserverIdList", null);
- payloadInfo.put("vfModuleId", null);
- payloadInfo.put("identityUrl", null);
- payloadInfo.put("vmIdList", null);
-
- doNothing().when(appCClient).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
-
- appcRunTasks.runAppcCommand(execution, action);
- verify(appCClient, times(1)).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
- }
+ @Autowired
+ private AppcRunTasks appcRunTasks;
+
+ private GenericVnf genericVnf;
+ private RequestContext requestContext;
+ private String msoRequestId;
+
+ @Before
+ public void before() {
+ genericVnf = setGenericVnf();
+ msoRequestId = UUID.randomUUID().toString();
+ requestContext = setRequestContext();
+ requestContext.setMsoRequestId(msoRequestId);
+ gBBInput.setRequestContext(requestContext);
+ }
+
+ @Test
+ public void preProcessActivityTest() throws Exception {
+ appcRunTasks.preProcessActivity(execution);
+ assertEquals(execution.getVariable("actionQuiesceTraffic"), Action.QuiesceTraffic);
+ assertEquals(execution.getVariable("rollbackQuiesceTraffic"), false);
+ }
+
+ @Test
+ public void runAppcCommandTest() throws Exception {
+ Action action = Action.QuiesceTraffic;
+ ControllerSelectionReference controllerSelectionReference = new ControllerSelectionReference();
+ controllerSelectionReference.setControllerName("testName");
+ controllerSelectionReference.setActionCategory(action.toString());
+ controllerSelectionReference.setVnfType("testVnfType");
+
+ doReturn(controllerSelectionReference).when(catalogDbClient)
+ .getControllerSelectionReferenceByVnfTypeAndActionCategory(genericVnf.getVnfType(),
+ Action.QuiesceTraffic.toString());
+
+ execution.setVariable("aicIdentity", "testAicIdentity");
+
+ String vnfId = genericVnf.getVnfId();
+ genericVnf.setIpv4OamAddress("testOamIpAddress");
+ String payload = "{\"testName\":\"testValue\",}";
+ RequestParameters requestParameters = new RequestParameters();
+ requestParameters.setPayload(payload);
+ gBBInput.getRequestContext().setRequestParameters(requestParameters);
+
+ String controllerType = "testName";
+ HashMap<String, String> payloadInfo = new HashMap<String, String>();
+ payloadInfo.put("vnfName", "testVnfName1");
+ payloadInfo.put("aicIdentity", "testAicIdentity");
+ payloadInfo.put("vnfHostIpAddress", "testOamIpAddress");
+ payloadInfo.put("vserverIdList", null);
+ payloadInfo.put("vfModuleId", null);
+ payloadInfo.put("identityUrl", null);
+ payloadInfo.put("vmIdList", null);
+
+ doNothing().when(appCClient).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo,
+ controllerType);
+
+ appcRunTasks.runAppcCommand(execution, action);
+ verify(appCClient, times(1)).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo,
+ controllerType);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksTest.java
index a8518d9016..cf673c5eb5 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksTest.java
@@ -30,7 +30,6 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import org.junit.Test;
import org.mockito.InjectMocks;
import org.onap.appc.client.lcm.model.Action;
@@ -45,47 +44,45 @@ import org.onap.so.db.catalog.beans.ControllerSelectionReference;
public class AppcRunTasksTest extends BaseTaskTest {
- @InjectMocks
- private AppcRunTasks appcRunTasks = new AppcRunTasks();
-
- @Test
- public void mapRollbackVariablesTest() {
-
- BuildingBlockExecution mock = mock(BuildingBlockExecution.class);
-
- appcRunTasks.mapRollbackVariables(mock, Action.Lock, "1");
- verify(mock, times(0)).setVariable(any(String.class), any());
- appcRunTasks.mapRollbackVariables(mock, Action.Lock, "0");
- verify(mock, times(1)).setVariable("rollbackVnfLock", true);
- appcRunTasks.mapRollbackVariables(mock, Action.Unlock, "0");
- verify(mock, times(1)).setVariable("rollbackVnfLock", false);
- appcRunTasks.mapRollbackVariables(mock, Action.Start, "0");
- verify(mock, times(1)).setVariable("rollbackVnfStop", false);
- appcRunTasks.mapRollbackVariables(mock, Action.Stop, "0");
- verify(mock, times(1)).setVariable("rollbackVnfStop", true);
- appcRunTasks.mapRollbackVariables(mock, Action.QuiesceTraffic, "0");
- verify(mock, times(1)).setVariable("rollbackQuiesceTraffic", true);
- appcRunTasks.mapRollbackVariables(mock, Action.ResumeTraffic, "0");
- verify(mock, times(1)).setVariable("rollbackQuiesceTraffic", false);
- }
+ @InjectMocks
+ private AppcRunTasks appcRunTasks = new AppcRunTasks();
+
+ @Test
+ public void mapRollbackVariablesTest() {
+
+ BuildingBlockExecution mock = mock(BuildingBlockExecution.class);
+
+ appcRunTasks.mapRollbackVariables(mock, Action.Lock, "1");
+ verify(mock, times(0)).setVariable(any(String.class), any());
+ appcRunTasks.mapRollbackVariables(mock, Action.Lock, "0");
+ verify(mock, times(1)).setVariable("rollbackVnfLock", true);
+ appcRunTasks.mapRollbackVariables(mock, Action.Unlock, "0");
+ verify(mock, times(1)).setVariable("rollbackVnfLock", false);
+ appcRunTasks.mapRollbackVariables(mock, Action.Start, "0");
+ verify(mock, times(1)).setVariable("rollbackVnfStop", false);
+ appcRunTasks.mapRollbackVariables(mock, Action.Stop, "0");
+ verify(mock, times(1)).setVariable("rollbackVnfStop", true);
+ appcRunTasks.mapRollbackVariables(mock, Action.QuiesceTraffic, "0");
+ verify(mock, times(1)).setVariable("rollbackQuiesceTraffic", true);
+ appcRunTasks.mapRollbackVariables(mock, Action.ResumeTraffic, "0");
+ verify(mock, times(1)).setVariable("rollbackQuiesceTraffic", false);
+ }
@Test
public void runAppcCommandVnfNull() throws BBObjectNotFoundException {
execution.getLookupMap().put(ResourceKey.GENERIC_VNF_ID, "NULL-TEST");
fillRequiredAppcExecutionFields();
- when(extractPojosForBB.extractByKey(eq(execution), eq(ResourceKey.GENERIC_VNF_ID)))
- .thenReturn(null);
- when(catalogDbClient.getControllerSelectionReferenceByVnfTypeAndActionCategory(
- isNull(), eq(Action.Lock.toString()))).
- thenThrow(new IllegalArgumentException("name or values is null"));
+ when(extractPojosForBB.extractByKey(eq(execution), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(null);
+ when(catalogDbClient.getControllerSelectionReferenceByVnfTypeAndActionCategory(isNull(),
+ eq(Action.Lock.toString()))).thenThrow(new IllegalArgumentException("name or values is null"));
appcRunTasks.runAppcCommand(execution, Action.Lock);
// if vnf = null -> vnfType = null ->
- // IllegalArgumentException will be thrown in catalogDbClient.getControllerSelectionReferenceByVnfTypeAndActionCategory
- verify(exceptionUtil, times(1)).
- buildAndThrowWorkflowException(
- any(BuildingBlockExecution.class), eq(1002), eq("name or values is null"));
+ // IllegalArgumentException will be thrown in
+ // catalogDbClient.getControllerSelectionReferenceByVnfTypeAndActionCategory
+ verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1002),
+ eq("name or values is null"));
}
@Test
@@ -93,13 +90,12 @@ public class AppcRunTasksTest extends BaseTaskTest {
execution.getLookupMap().put(ResourceKey.GENERIC_VNF_ID, "EXCEPTION-TEST");
fillRequiredAppcExecutionFields();
when(extractPojosForBB.extractByKey(eq(execution), eq(ResourceKey.GENERIC_VNF_ID)))
- .thenThrow(new BBObjectNotFoundException());
+ .thenThrow(new BBObjectNotFoundException());
appcRunTasks.runAppcCommand(execution, Action.Lock);
- verify(exceptionUtil, times(1)).
- buildAndThrowWorkflowException(
- any(BuildingBlockExecution.class), eq(7000), eq("No valid VNF exists"));
+ verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000),
+ eq("No valid VNF exists"));
}
@Test
@@ -107,12 +103,10 @@ public class AppcRunTasksTest extends BaseTaskTest {
execution.getLookupMap().put(ResourceKey.GENERIC_VNF_ID, "SUCCESS-TEST");
fillRequiredAppcExecutionFields();
GenericVnf genericVnf = getTestGenericVnf();
- when(extractPojosForBB.extractByKey(eq(execution), eq(ResourceKey.GENERIC_VNF_ID)))
- .thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(eq(execution), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
mockReferenceResponse();
execution.getLookupMap().put(ResourceKey.VF_MODULE_ID, "VF-MODULE-ID-TEST");
- when(extractPojosForBB.extractByKey(eq(execution), eq(ResourceKey.VF_MODULE_ID)))
- .thenReturn(null);
+ when(extractPojosForBB.extractByKey(eq(execution), eq(ResourceKey.VF_MODULE_ID))).thenReturn(null);
when(appCClient.getErrorCode()).thenReturn("0");
appcRunTasks.runAppcCommand(execution, Action.Lock);
@@ -125,14 +119,12 @@ public class AppcRunTasksTest extends BaseTaskTest {
execution.getLookupMap().put(ResourceKey.GENERIC_VNF_ID, "SUCCESS-TEST");
fillRequiredAppcExecutionFields();
GenericVnf genericVnf = getTestGenericVnf();
- when(extractPojosForBB.extractByKey(eq(execution), eq(ResourceKey.GENERIC_VNF_ID)))
- .thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(eq(execution), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
mockReferenceResponse();
execution.getLookupMap().put(ResourceKey.VF_MODULE_ID, "VF-MODULE-ID-TEST");
VfModule vfModule = new VfModule();
vfModule.setVfModuleId("VF-MODULE-ID");
- when(extractPojosForBB.extractByKey(eq(execution), eq(ResourceKey.VF_MODULE_ID)))
- .thenReturn(vfModule);
+ when(extractPojosForBB.extractByKey(eq(execution), eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
when(appCClient.getErrorCode()).thenReturn("0");
appcRunTasks.runAppcCommand(execution, Action.Lock);
@@ -143,8 +135,8 @@ public class AppcRunTasksTest extends BaseTaskTest {
private void mockReferenceResponse() {
ControllerSelectionReference reference = new ControllerSelectionReference();
reference.setControllerName("TEST-CONTROLLER-NAME");
- when(catalogDbClient.getControllerSelectionReferenceByVnfTypeAndActionCategory(
- eq("TEST-VNF-TYPE"), eq(Action.Lock.toString()))).thenReturn(reference);
+ when(catalogDbClient.getControllerSelectionReferenceByVnfTypeAndActionCategory(eq("TEST-VNF-TYPE"),
+ eq(Action.Lock.toString()))).thenReturn(reference);
}
private void fillRequiredAppcExecutionFields() {
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/audit/AuditTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/audit/AuditTasksTest.java
index 3542d7fdb3..3bf24291ea 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/audit/AuditTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/audit/AuditTasksTest.java
@@ -23,7 +23,6 @@ import static com.shazam.shazamcrest.MatcherAssert.assertThat;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
-
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -38,37 +37,39 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.client.exception.BBObjectNotFoundException;
-public class AuditTasksTest extends BaseTaskTest{
-
- @InjectMocks
- private AuditTasks auditTasks = new AuditTasks();
- private ServiceInstance serviceInstance;
- private GenericVnf genericVnf;
- private VfModule vfModule;
+public class AuditTasksTest extends BaseTaskTest {
+
+ @InjectMocks
+ private AuditTasks auditTasks = new AuditTasks();
+ private ServiceInstance serviceInstance;
+ private GenericVnf genericVnf;
+ private VfModule vfModule;
+
+
+ @Rule
+ public final ExpectedException exception = ExpectedException.none();
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ serviceInstance = setServiceInstance();
+ genericVnf = setGenericVnf();
+ vfModule = setVfModule();
+ setCloudRegion();
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
+ .thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
+ .thenReturn(serviceInstance);
+ }
-
- @Rule
- public final ExpectedException exception = ExpectedException.none();
-
- @Before
- public void before() throws BBObjectNotFoundException {
- serviceInstance = setServiceInstance();
- genericVnf = setGenericVnf();
- vfModule = setVfModule();
- setCloudRegion();
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))).thenReturn(serviceInstance);
- }
-
- @Test
- public void setupAuditVariableTest() throws Exception {
- AuditInventory expectedAuditInventory = new AuditInventory();
- expectedAuditInventory.setCloudOwner("testCloudOwner");
- expectedAuditInventory.setCloudRegion("testLcpCloudRegionId");
- expectedAuditInventory.setHeatStackName("testVfModuleName1");
- expectedAuditInventory.setTenantId("testTenantId");
- auditTasks.setupAuditVariable(execution);
- assertThat((AuditInventory)execution.getVariable("auditInventory"), sameBeanAs(expectedAuditInventory));
- }
+ @Test
+ public void setupAuditVariableTest() throws Exception {
+ AuditInventory expectedAuditInventory = new AuditInventory();
+ expectedAuditInventory.setCloudOwner("testCloudOwner");
+ expectedAuditInventory.setCloudRegion("testLcpCloudRegionId");
+ expectedAuditInventory.setHeatStackName("testVfModuleName1");
+ expectedAuditInventory.setTenantId("testTenantId");
+ auditTasks.setupAuditVariable(execution);
+ assertThat((AuditInventory) execution.getVariable("auditInventory"), sameBeanAs(expectedAuditInventory));
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ActivateVfModuleTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ActivateVfModuleTest.java
index d1d167e561..0a880ad0e5 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ActivateVfModuleTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ActivateVfModuleTest.java
@@ -29,16 +29,18 @@ import org.mockito.InjectMocks;
import org.onap.so.bpmn.BaseTaskTest;
public class ActivateVfModuleTest extends BaseTaskTest {
-
- @InjectMocks
- private ActivateVfModule activateVfModule = new ActivateVfModule();
-
- @Test
- public void setWaitBeforeDurationTest() throws Exception {
- when(env.getProperty(ActivateVfModule.VF_MODULE_TIMER_DURATION_PATH, ActivateVfModule.DEFAULT_TIMER_DURATION)).thenReturn("PT300S");
- activateVfModule.setTimerDuration(execution);
- verify(env, times(1)).getProperty(ActivateVfModule.VF_MODULE_TIMER_DURATION_PATH, ActivateVfModule.DEFAULT_TIMER_DURATION);
- assertEquals("PT300S", (String) execution.getVariable("vfModuleActivateTimerDuration"));
- }
+
+ @InjectMocks
+ private ActivateVfModule activateVfModule = new ActivateVfModule();
+
+ @Test
+ public void setWaitBeforeDurationTest() throws Exception {
+ when(env.getProperty(ActivateVfModule.VF_MODULE_TIMER_DURATION_PATH, ActivateVfModule.DEFAULT_TIMER_DURATION))
+ .thenReturn("PT300S");
+ activateVfModule.setTimerDuration(execution);
+ verify(env, times(1)).getProperty(ActivateVfModule.VF_MODULE_TIMER_DURATION_PATH,
+ ActivateVfModule.DEFAULT_TIMER_DURATION);
+ assertEquals("PT300S", (String) execution.getVariable("vfModuleActivateTimerDuration"));
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetworkBBUtilsTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetworkBBUtilsTest.java
index e7f841fa47..8ca0e79c6e 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetworkBBUtilsTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetworkBBUtilsTest.java
@@ -20,7 +20,6 @@
package org.onap.so.bpmn.infrastructure.flowspecific.tasks;
import static org.junit.Assert.assertEquals;
-
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
@@ -28,34 +27,34 @@ import org.onap.so.bpmn.BaseTaskTest;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
public class AssignNetworkBBUtilsTest extends BaseTaskTest {
-
- @InjectMocks
- private AssignNetworkBBUtils nonMockAssignNetworkBBUtils = new AssignNetworkBBUtils();
-
- private CloudRegion cloudRegion;
-
- @Before
- public void before() {
- cloudRegion = setCloudRegion();
- }
-
- @Test
- public void getCloudRegionTest25() throws Exception {
- cloudRegion.setCloudRegionVersion("2.5");
-
- nonMockAssignNetworkBBUtils.getCloudRegion(execution);
-
- assertEquals(cloudRegion.getLcpCloudRegionId(), execution.getVariable("cloudRegionPo"));
- assertEquals("AAIAIC25", execution.getVariable("cloudRegionSdnc"));
- }
-
- @Test
- public void getCloudRegionTest30() throws Exception {
- cloudRegion.setCloudRegionVersion("3.0");
-
- nonMockAssignNetworkBBUtils.getCloudRegion(execution);
-
- assertEquals(cloudRegion.getLcpCloudRegionId(), execution.getVariable("cloudRegionPo"));
- assertEquals(cloudRegion.getLcpCloudRegionId(), execution.getVariable("cloudRegionSdnc"));
- }
+
+ @InjectMocks
+ private AssignNetworkBBUtils nonMockAssignNetworkBBUtils = new AssignNetworkBBUtils();
+
+ private CloudRegion cloudRegion;
+
+ @Before
+ public void before() {
+ cloudRegion = setCloudRegion();
+ }
+
+ @Test
+ public void getCloudRegionTest25() throws Exception {
+ cloudRegion.setCloudRegionVersion("2.5");
+
+ nonMockAssignNetworkBBUtils.getCloudRegion(execution);
+
+ assertEquals(cloudRegion.getLcpCloudRegionId(), execution.getVariable("cloudRegionPo"));
+ assertEquals("AAIAIC25", execution.getVariable("cloudRegionSdnc"));
+ }
+
+ @Test
+ public void getCloudRegionTest30() throws Exception {
+ cloudRegion.setCloudRegionVersion("3.0");
+
+ nonMockAssignNetworkBBUtils.getCloudRegion(execution);
+
+ assertEquals(cloudRegion.getLcpCloudRegionId(), execution.getVariable("cloudRegionPo"));
+ assertEquals(cloudRegion.getLcpCloudRegionId(), execution.getVariable("cloudRegionSdnc"));
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetworkTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetworkTest.java
index 19981bc45a..d7a5dbd8f0 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetworkTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetworkTest.java
@@ -24,7 +24,6 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.when;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
@@ -38,39 +37,40 @@ import org.onap.so.client.exception.BBObjectNotFoundException;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
public class AssignNetworkTest extends BaseTaskTest {
-
- @InjectMocks
- private AssignNetwork assignNetwork = new AssignNetwork();
-
- private L3Network network;
-
- @Before
- public void before() throws BBObjectNotFoundException {
- network = setL3Network();
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
- }
-
- @Test
- public void networkNotFoundTest() throws Exception {
- //network status to PRECREATED - when it was NOT found by name
- try {
- network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
- } catch(BBObjectNotFoundException e) {
- }
-
- network.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
- boolean networkFound = assignNetwork.networkFoundByName(execution);
- assertEquals(false, networkFound);
- }
- @Test
- public void networkFoundTest() throws Exception {
- try {
- network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
- } catch(BBObjectNotFoundException e) {
- }
- boolean networkFound = assignNetwork.networkFoundByName(execution);
- assertEquals(true, networkFound);
- }
+ @InjectMocks
+ private AssignNetwork assignNetwork = new AssignNetwork();
+
+ private L3Network network;
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ network = setL3Network();
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
+ }
+
+ @Test
+ public void networkNotFoundTest() throws Exception {
+ // network status to PRECREATED - when it was NOT found by name
+ try {
+ network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
+ } catch (BBObjectNotFoundException e) {
+ }
+
+ network.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
+ boolean networkFound = assignNetwork.networkFoundByName(execution);
+ assertEquals(false, networkFound);
+ }
+
+ @Test
+ public void networkFoundTest() throws Exception {
+ try {
+ network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
+ } catch (BBObjectNotFoundException e) {
+ }
+ boolean networkFound = assignNetwork.networkFoundByName(execution);
+ assertEquals(true, networkFound);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignVnfTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignVnfTest.java
index 834990db5a..06ad66e855 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignVnfTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignVnfTest.java
@@ -28,9 +28,7 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import java.util.List;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
@@ -48,94 +46,103 @@ import org.onap.so.client.aai.entities.AAIEdgeLabel;
import org.onap.so.client.exception.BBObjectNotFoundException;
public class AssignVnfTest extends BaseTaskTest {
- @InjectMocks
- private AssignVnf assignVnf = new AssignVnf();
-
- @Mock
- private AAIObjectInstanceNameGenerator aaiObjectInstanceNameGenerator = new AAIObjectInstanceNameGenerator();
-
- private InstanceGroup instanceGroup1;
- private InstanceGroup instanceGroup2;
- private InstanceGroup instanceGroup3;
- private InstanceGroup instanceGroup4;
- private GenericVnf genericVnf;
-
- @Before
- public void before() throws BBObjectNotFoundException {
- ModelInfoInstanceGroup modelVnfc = new ModelInfoInstanceGroup();
- modelVnfc.setType("VNFC");
- modelVnfc.setFunction("function");
-
- ModelInfoInstanceGroup modelNetworkInstanceGroup = new ModelInfoInstanceGroup();
- modelNetworkInstanceGroup.setType("L3-NETWORK");
- modelNetworkInstanceGroup.setFunction("function");
-
- instanceGroup1 = new InstanceGroup();
- instanceGroup1.setId("test-001");
- instanceGroup1.setModelInfoInstanceGroup(modelVnfc);
-
- instanceGroup2 = new InstanceGroup();
- instanceGroup2.setId("test-002");
- instanceGroup2.setModelInfoInstanceGroup(modelVnfc);
-
- instanceGroup3 = new InstanceGroup();
- instanceGroup3.setId("test-003");
- instanceGroup3.setModelInfoInstanceGroup(modelNetworkInstanceGroup);
-
- instanceGroup4 = new InstanceGroup();
- instanceGroup4.setId("test-004");
- instanceGroup4.setModelInfoInstanceGroup(modelNetworkInstanceGroup);
-
- genericVnf = setGenericVnf();
- genericVnf.setVnfName("vnfName");
-
-
- doNothing().when(aaiInstanceGroupResources).createInstanceGroup(isA(InstanceGroup.class));
- doNothing().when(aaiInstanceGroupResources).connectInstanceGroupToVnf(isA(InstanceGroup.class), isA(GenericVnf.class));
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
- }
-
- @Test
- public void createInstanceGroupsSunnyDayTest() throws Exception {
-
- List<InstanceGroup> instanceGroupList = genericVnf.getInstanceGroups();
- instanceGroupList.add(instanceGroup1);
- instanceGroupList.add(instanceGroup2);
- instanceGroupList.add(instanceGroup3);
- instanceGroupList.add(instanceGroup4);
-
-
- assignVnf.createInstanceGroups(execution);
- verify(aaiInstanceGroupResources, times(1)).createInstanceGroup(instanceGroup1);
- verify(aaiInstanceGroupResources, times(1)).createInstanceGroup(instanceGroup2);
- verify(aaiInstanceGroupResources, times(1)).connectInstanceGroupToVnf(instanceGroup1, genericVnf, AAIEdgeLabel.BELONGS_TO);
- verify(aaiInstanceGroupResources, times(1)).connectInstanceGroupToVnf(instanceGroup2, genericVnf, AAIEdgeLabel.BELONGS_TO);
- verify(aaiInstanceGroupResources, times(1)).connectInstanceGroupToVnf(instanceGroup3, genericVnf, AAIEdgeLabel.USES);
- verify(aaiInstanceGroupResources, times(1)).connectInstanceGroupToVnf(instanceGroup4, genericVnf, AAIEdgeLabel.USES);
- }
-
- @Test
- public void createVnfcInstanceGroupNoneTest() throws Exception {
- assignVnf.createInstanceGroups(execution);
-
-
- verify(aaiInstanceGroupResources, times(0)).createInstanceGroup(any(InstanceGroup.class));
- verify(aaiInstanceGroupResources, times(0)).connectInstanceGroupToVnf(any(InstanceGroup.class), any(GenericVnf.class));
- }
-
- @Test
- public void createVnfcInstanceGroupExceptionTest() throws Exception {
- List<InstanceGroup> instanceGroupList = genericVnf.getInstanceGroups();
- instanceGroupList.add(instanceGroup1);
- instanceGroupList.add(instanceGroup2);
- instanceGroupList.add(instanceGroup3);
- instanceGroupList.add(instanceGroup4);
- doThrow(RuntimeException.class).when(aaiInstanceGroupResources).createInstanceGroup(isA(InstanceGroup.class));
- expectedException.expect(BpmnError.class);
-
- genericVnf.setVnfId("test-999");
- assignVnf.createInstanceGroups(execution);
- }
+ @InjectMocks
+ private AssignVnf assignVnf = new AssignVnf();
+
+ @Mock
+ private AAIObjectInstanceNameGenerator aaiObjectInstanceNameGenerator = new AAIObjectInstanceNameGenerator();
+
+ private InstanceGroup instanceGroup1;
+ private InstanceGroup instanceGroup2;
+ private InstanceGroup instanceGroup3;
+ private InstanceGroup instanceGroup4;
+ private GenericVnf genericVnf;
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ ModelInfoInstanceGroup modelVnfc = new ModelInfoInstanceGroup();
+ modelVnfc.setType("VNFC");
+ modelVnfc.setFunction("function");
+
+ ModelInfoInstanceGroup modelNetworkInstanceGroup = new ModelInfoInstanceGroup();
+ modelNetworkInstanceGroup.setType("L3-NETWORK");
+ modelNetworkInstanceGroup.setFunction("function");
+
+ instanceGroup1 = new InstanceGroup();
+ instanceGroup1.setId("test-001");
+ instanceGroup1.setModelInfoInstanceGroup(modelVnfc);
+
+ instanceGroup2 = new InstanceGroup();
+ instanceGroup2.setId("test-002");
+ instanceGroup2.setModelInfoInstanceGroup(modelVnfc);
+
+ instanceGroup3 = new InstanceGroup();
+ instanceGroup3.setId("test-003");
+ instanceGroup3.setModelInfoInstanceGroup(modelNetworkInstanceGroup);
+
+ instanceGroup4 = new InstanceGroup();
+ instanceGroup4.setId("test-004");
+ instanceGroup4.setModelInfoInstanceGroup(modelNetworkInstanceGroup);
+
+ genericVnf = setGenericVnf();
+ genericVnf.setVnfName("vnfName");
+
+
+ doNothing().when(aaiInstanceGroupResources).createInstanceGroup(isA(InstanceGroup.class));
+ doNothing().when(aaiInstanceGroupResources).connectInstanceGroupToVnf(isA(InstanceGroup.class),
+ isA(GenericVnf.class));
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
+ .thenReturn(genericVnf);
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
+ }
+
+ @Test
+ public void createInstanceGroupsSunnyDayTest() throws Exception {
+
+ List<InstanceGroup> instanceGroupList = genericVnf.getInstanceGroups();
+ instanceGroupList.add(instanceGroup1);
+ instanceGroupList.add(instanceGroup2);
+ instanceGroupList.add(instanceGroup3);
+ instanceGroupList.add(instanceGroup4);
+
+
+ assignVnf.createInstanceGroups(execution);
+ verify(aaiInstanceGroupResources, times(1)).createInstanceGroup(instanceGroup1);
+ verify(aaiInstanceGroupResources, times(1)).createInstanceGroup(instanceGroup2);
+ verify(aaiInstanceGroupResources, times(1)).connectInstanceGroupToVnf(instanceGroup1, genericVnf,
+ AAIEdgeLabel.BELONGS_TO);
+ verify(aaiInstanceGroupResources, times(1)).connectInstanceGroupToVnf(instanceGroup2, genericVnf,
+ AAIEdgeLabel.BELONGS_TO);
+ verify(aaiInstanceGroupResources, times(1)).connectInstanceGroupToVnf(instanceGroup3, genericVnf,
+ AAIEdgeLabel.USES);
+ verify(aaiInstanceGroupResources, times(1)).connectInstanceGroupToVnf(instanceGroup4, genericVnf,
+ AAIEdgeLabel.USES);
+ }
+
+ @Test
+ public void createVnfcInstanceGroupNoneTest() throws Exception {
+ assignVnf.createInstanceGroups(execution);
+
+
+ verify(aaiInstanceGroupResources, times(0)).createInstanceGroup(any(InstanceGroup.class));
+ verify(aaiInstanceGroupResources, times(0)).connectInstanceGroupToVnf(any(InstanceGroup.class),
+ any(GenericVnf.class));
+ }
+
+ @Test
+ public void createVnfcInstanceGroupExceptionTest() throws Exception {
+ List<InstanceGroup> instanceGroupList = genericVnf.getInstanceGroups();
+ instanceGroupList.add(instanceGroup1);
+ instanceGroupList.add(instanceGroup2);
+ instanceGroupList.add(instanceGroup3);
+ instanceGroupList.add(instanceGroup4);
+ doThrow(RuntimeException.class).when(aaiInstanceGroupResources).createInstanceGroup(isA(InstanceGroup.class));
+ expectedException.expect(BpmnError.class);
+
+ genericVnf.setVnfId("test-999");
+ assignVnf.createInstanceGroups(execution);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CloudSiteCatalogUtilsTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CloudSiteCatalogUtilsTest.java
index 125c97109c..99516e69e3 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CloudSiteCatalogUtilsTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CloudSiteCatalogUtilsTest.java
@@ -25,64 +25,63 @@ import java.util.Optional;
import org.junit.Test;
import org.mockito.InjectMocks;
import org.onap.so.bpmn.BaseTaskTest;
-
import org.onap.so.db.catalog.beans.CloudIdentity;
import org.onap.so.db.catalog.beans.CloudSite;
public class CloudSiteCatalogUtilsTest extends BaseTaskTest {
-
- @InjectMocks
- private CloudSiteCatalogUtils cloudSiteCatalogUtils = new CloudSiteCatalogUtils();
-
- @Test
- public void testGetCloudSiteGetVersion30Test() throws Exception {
- CloudSite cloudSite = new CloudSite();
- String testCloudSiteId = "testCloudSiteId";
- cloudSite.setClli(testCloudSiteId);
- doReturn(cloudSite).when(catalogDbClient).getCloudSite(testCloudSiteId);
- Optional<CloudSite> actualCloudSite = cloudSiteCatalogUtils.getCloudSite(testCloudSiteId);
- assertEquals(actualCloudSite.get().getClli(), testCloudSiteId);
- }
-
- @Test
- public void testGetCloudSiteGetVersion25Test() throws Exception {
- CloudSite cloudSite = new CloudSite();
- String testCloudSiteId = "testCloudSiteId";
- cloudSite.setClli(testCloudSiteId);
- doReturn(null).when(catalogDbClient).getCloudSite(testCloudSiteId);
- doReturn(cloudSite).when(catalogDbClient).getCloudSiteByClliAndAicVersion(testCloudSiteId, "2.5");
- Optional<CloudSite> actualCloudSite = cloudSiteCatalogUtils.getCloudSite(testCloudSiteId);
- assertEquals(actualCloudSite.get().getClli(), testCloudSiteId);
- }
-
- @Test
- public void testGetIdentityUrlFromCloudSiteSuccessTest() throws Exception {
- CloudSite cloudSite = new CloudSite();
- String testCloudSiteId = "testCloudSiteId";
- String testIdentityUrl = "testIdentityUrl";
- delegateExecution.setVariable("lcpCloudRegionId", testCloudSiteId);
- cloudSite.setClli(testCloudSiteId);
- CloudIdentity cloudIdentity = new CloudIdentity();
- cloudIdentity.setIdentityUrl(testIdentityUrl);
- cloudSite.setIdentityService(cloudIdentity);
- doReturn(cloudSite).when(catalogDbClient).getCloudSite(testCloudSiteId);
- cloudSiteCatalogUtils.getIdentityUrlFromCloudSite(delegateExecution);
- String actualIdentityUrl = (String) delegateExecution.getVariable("identityUrl");
- assertEquals(testIdentityUrl, actualIdentityUrl);
- }
-
- @Test
- public void testGetIdentityUrlFromCloudSiteNoCloudIdProvidedTest() throws Exception {
- CloudSite cloudSite = new CloudSite();
- String testCloudSiteId = "testCloudSiteId";
- String testIdentityUrl = "testIdentityUrl";
- cloudSite.setClli(testCloudSiteId);
- CloudIdentity cloudIdentity = new CloudIdentity();
- cloudIdentity.setIdentityUrl(testIdentityUrl);
- cloudSite.setIdentityService(cloudIdentity);
- doReturn(cloudSite).when(catalogDbClient).getCloudSite(testCloudSiteId);
- cloudSiteCatalogUtils.getIdentityUrlFromCloudSite(delegateExecution);
- String actualIdentityUrl = (String) delegateExecution.getVariable("identityUrl");
- assertEquals(null, actualIdentityUrl);
- }
+
+ @InjectMocks
+ private CloudSiteCatalogUtils cloudSiteCatalogUtils = new CloudSiteCatalogUtils();
+
+ @Test
+ public void testGetCloudSiteGetVersion30Test() throws Exception {
+ CloudSite cloudSite = new CloudSite();
+ String testCloudSiteId = "testCloudSiteId";
+ cloudSite.setClli(testCloudSiteId);
+ doReturn(cloudSite).when(catalogDbClient).getCloudSite(testCloudSiteId);
+ Optional<CloudSite> actualCloudSite = cloudSiteCatalogUtils.getCloudSite(testCloudSiteId);
+ assertEquals(actualCloudSite.get().getClli(), testCloudSiteId);
+ }
+
+ @Test
+ public void testGetCloudSiteGetVersion25Test() throws Exception {
+ CloudSite cloudSite = new CloudSite();
+ String testCloudSiteId = "testCloudSiteId";
+ cloudSite.setClli(testCloudSiteId);
+ doReturn(null).when(catalogDbClient).getCloudSite(testCloudSiteId);
+ doReturn(cloudSite).when(catalogDbClient).getCloudSiteByClliAndAicVersion(testCloudSiteId, "2.5");
+ Optional<CloudSite> actualCloudSite = cloudSiteCatalogUtils.getCloudSite(testCloudSiteId);
+ assertEquals(actualCloudSite.get().getClli(), testCloudSiteId);
+ }
+
+ @Test
+ public void testGetIdentityUrlFromCloudSiteSuccessTest() throws Exception {
+ CloudSite cloudSite = new CloudSite();
+ String testCloudSiteId = "testCloudSiteId";
+ String testIdentityUrl = "testIdentityUrl";
+ delegateExecution.setVariable("lcpCloudRegionId", testCloudSiteId);
+ cloudSite.setClli(testCloudSiteId);
+ CloudIdentity cloudIdentity = new CloudIdentity();
+ cloudIdentity.setIdentityUrl(testIdentityUrl);
+ cloudSite.setIdentityService(cloudIdentity);
+ doReturn(cloudSite).when(catalogDbClient).getCloudSite(testCloudSiteId);
+ cloudSiteCatalogUtils.getIdentityUrlFromCloudSite(delegateExecution);
+ String actualIdentityUrl = (String) delegateExecution.getVariable("identityUrl");
+ assertEquals(testIdentityUrl, actualIdentityUrl);
+ }
+
+ @Test
+ public void testGetIdentityUrlFromCloudSiteNoCloudIdProvidedTest() throws Exception {
+ CloudSite cloudSite = new CloudSite();
+ String testCloudSiteId = "testCloudSiteId";
+ String testIdentityUrl = "testIdentityUrl";
+ cloudSite.setClli(testCloudSiteId);
+ CloudIdentity cloudIdentity = new CloudIdentity();
+ cloudIdentity.setIdentityUrl(testIdentityUrl);
+ cloudSite.setIdentityService(cloudIdentity);
+ doReturn(cloudSite).when(catalogDbClient).getCloudSite(testCloudSiteId);
+ cloudSiteCatalogUtils.getIdentityUrlFromCloudSite(delegateExecution);
+ String actualIdentityUrl = (String) delegateExecution.getVariable("identityUrl");
+ assertEquals(null, actualIdentityUrl);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigAssignVnfTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigAssignVnfTest.java
index 07983ccd50..7d96a18305 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigAssignVnfTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigAssignVnfTest.java
@@ -25,9 +25,7 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.when;
-
import java.util.UUID;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnfTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnfTest.java
index e5aa702dad..6f76c83c6f 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnfTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnfTest.java
@@ -1,23 +1,18 @@
/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2019 TechMahindra
-*=================================================================================
-* 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.
-* ============LICENSE_END=========================================================
-*/
+ * ============LICENSE_START======================================================= ONAP : SO
+ * ================================================================================ Copyright 2019 TechMahindra
+ * ================================================================================= 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.
+ * ============LICENSE_END=========================================================
+ */
package org.onap.so.bpmn.infrastructure.flowspecific.tasks;
@@ -26,9 +21,7 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.when;
-
import java.util.UUID;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
@@ -46,52 +39,55 @@ import org.onap.so.client.exception.BBObjectNotFoundException;
public class ConfigDeployVnfTest extends BaseTaskTest {
- @InjectMocks
- private ConfigDeployVnf configDeployVnf = new ConfigDeployVnf();
- @Mock
- AAIUpdateTasks aAIUpdateTasks = new AAIUpdateTasks();
-
-
- private GenericVnf genericVnf;
- private ServiceInstance serviceInstance;
- private RequestContext requestContext;
- private String msoRequestId;
-
- @Before
- public void before() throws BBObjectNotFoundException {
- genericVnf = setGenericVnf();
- serviceInstance = setServiceInstance();
- msoRequestId = UUID.randomUUID().toString();
- requestContext = setRequestContext();
- requestContext.setMsoRequestId(msoRequestId);
- gBBInput.setRequestContext(requestContext);
-
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
- when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
- when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))).thenReturn(serviceInstance);
- }
-
-
-
- @Test
- public void preProcessAbstractCDSProcessingTest() throws Exception {
-
- configDeployVnf.preProcessAbstractCDSProcessing(execution);
-
- assertTrue(true);
- }
-
- @Test
- public void updateAAIConfigureTaskTest() throws Exception {
-
- configDeployVnf.updateAAIConfigure(execution);
- assertTrue(true);
- }
-
- @Test
- public void updateAAIConfiguredTaskTest() throws Exception {
- configDeployVnf.updateAAIConfigured(execution);
- assertTrue(true);
- }
+ @InjectMocks
+ private ConfigDeployVnf configDeployVnf = new ConfigDeployVnf();
+ @Mock
+ AAIUpdateTasks aAIUpdateTasks = new AAIUpdateTasks();
+
+
+ private GenericVnf genericVnf;
+ private ServiceInstance serviceInstance;
+ private RequestContext requestContext;
+ private String msoRequestId;
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ genericVnf = setGenericVnf();
+ serviceInstance = setServiceInstance();
+ msoRequestId = UUID.randomUUID().toString();
+ requestContext = setRequestContext();
+ requestContext.setMsoRequestId(msoRequestId);
+ gBBInput.setRequestContext(requestContext);
+
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
+ .thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
+ .thenReturn(serviceInstance);
+ }
+
+
+
+ @Test
+ public void preProcessAbstractCDSProcessingTest() throws Exception {
+
+ configDeployVnf.preProcessAbstractCDSProcessing(execution);
+
+ assertTrue(true);
+ }
+
+ @Test
+ public void updateAAIConfigureTaskTest() throws Exception {
+
+ configDeployVnf.updateAAIConfigure(execution);
+ assertTrue(true);
+ }
+
+ @Test
+ public void updateAAIConfiguredTaskTest() throws Exception {
+ configDeployVnf.updateAAIConfigured(execution);
+ assertTrue(true);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOutTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOutTest.java
index 6390268a0c..4d43bbbce7 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOutTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOutTest.java
@@ -28,7 +28,6 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
@@ -37,7 +36,6 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
@@ -54,137 +52,153 @@ import org.onap.so.client.exception.BBObjectNotFoundException;
import org.onap.so.db.catalog.beans.ControllerSelectionReference;
public class ConfigurationScaleOutTest extends BaseTaskTest {
-
- @InjectMocks
- private ConfigurationScaleOut configurationScaleOut = new ConfigurationScaleOut();
-
- private GenericVnf genericVnf;
- private VfModule vfModule;
- private RequestContext requestContext;
- private String msoRequestId;
- private List<Map<String, String>> configurationParameters = new ArrayList<>();
- private Map<String, String> configParamsMap = new HashMap<>();
-
-
-
- @Before
- public void before() throws BBObjectNotFoundException {
- genericVnf = setGenericVnf();
- vfModule = setVfModule();
- msoRequestId = UUID.randomUUID().toString();
- requestContext = setRequestContext();
- requestContext.setMsoRequestId(msoRequestId);
- configParamsMap.put("availability-zone", "$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]");
- configParamsMap.put("vnf-id", "$.vnf-topology.vnf-topology-identifier-structure.vnf-id");
- configurationParameters.add(configParamsMap);
- requestContext.setConfigurationParameters(configurationParameters);
- gBBInput.setRequestContext(requestContext);
-
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
-
- }
-
- @Test
- public void setParamsForConfigurationScaleOutTest() throws Exception {
- ControllerSelectionReference controllerSelectionReference = new ControllerSelectionReference();
- controllerSelectionReference.setControllerName("testName");
- controllerSelectionReference.setActionCategory("testAction");
- controllerSelectionReference.setVnfType("testVnfType");
- String sdncResponse = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNCClientGetResponse.json")));
- String expectedPayload = "{\"request-parameters\":{\"vnf-host-ip-address\":\"10.222.22.2\","
- + "\"vf-module-id\":\"testVfModuleId1\"},\"configuration-parameters\""
- + ":{\"vnf-id\":\"66dac89b-2a5b-4cb9-b22e-a7e4488fb3db\",\"availability-zone\":\"AZ-MN02\"}}";
- execution.setVariable("SDNCQueryResponse_" + vfModule.getVfModuleId(), sdncResponse);
-
- doReturn(controllerSelectionReference).when(catalogDbClient).getControllerSelectionReferenceByVnfTypeAndActionCategory(genericVnf.getVnfType(), Action.ConfigScaleOut.toString());
-
- configurationScaleOut.setParamsForConfigurationScaleOut(execution);
-
- assertEquals(genericVnf.getVnfId(), execution.getVariable("vnfId"));
- assertEquals(genericVnf.getVnfName(), execution.getVariable("vnfName"));
- assertEquals("ConfigScaleOut", execution.getVariable("action"));
- assertEquals(requestContext.getMsoRequestId(), execution.getVariable("msoRequestId"));
- assertEquals(controllerSelectionReference.getControllerName(), execution.getVariable("controllerType"));
- assertEquals(vfModule.getVfModuleId(), execution.getVariable("vfModuleId"));
- assertEquals(expectedPayload, execution.getVariable("payload"));
- }
- @Test
- public void callAppcClientTest() throws Exception {
- Action action = Action.ConfigScaleOut;
- String vnfId = genericVnf.getVnfId();
- String controllerType = "testType";
- String payload = "{\"request-parameters\":{\"vnf-host-ip-address\":\"10.222.22.2\","
- + "\"vf-module-id\":\"testVfModuleId1\"},\"configuration-parameters\""
- + ":{\"vnf-id\":\"66dac89b-2a5b-4cb9-b22e-a7e4488fb3db\",\"availability-zone\":\"AZ-MN02\"}}";
- HashMap<String, String> payloadInfo = new HashMap<String, String>();
- payloadInfo.put("vnfName", "testVnfName");
- payloadInfo.put("vfModuleId", "testVfModuleId");
-
- execution.setVariable("action", Action.ConfigScaleOut.toString());
- execution.setVariable("msoRequestId", msoRequestId);
- execution.setVariable("controllerType", controllerType);
- execution.setVariable("vnfId", "testVnfId1");
- execution.setVariable("vnfName", "testVnfName");
- execution.setVariable("vfModuleId", "testVfModuleId");
- execution.setVariable("payload", payload);
-
- doNothing().when(appCClient).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
-
- configurationScaleOut.callAppcClient(execution);
- verify(appCClient, times(1)).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
- }
- @Test
- public void setParamsForConfigurationScaleOutBadPathTest() throws Exception {
- ControllerSelectionReference controllerSelectionReference = new ControllerSelectionReference();
- controllerSelectionReference.setControllerName("testName");
- controllerSelectionReference.setActionCategory("testAction");
- controllerSelectionReference.setVnfType("testVnfType");
- String sdncResponse = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNCClientResponseIncorrectPath.json")));
- String expectedPayload = "{\"request-parameters\":{\"vnf-host-ip-address\":\"10.222.22.2\","
- + "\"vf-module-id\":\"testVfModuleId1\"},\"configuration-parameters\""
- + ":{\"vnf-id\":\"66dac89b-2a5b-4cb9-b22e-a7e4488fb3db\",\"availability-zone\":null}}";
- execution.setVariable("SDNCQueryResponse_" + vfModule.getVfModuleId(), sdncResponse);
-
- doReturn(controllerSelectionReference).when(catalogDbClient).getControllerSelectionReferenceByVnfTypeAndActionCategory(genericVnf.getVnfType(), Action.ConfigScaleOut.toString());
-
- configurationScaleOut.setParamsForConfigurationScaleOut(execution);
-
- assertEquals(genericVnf.getVnfId(), execution.getVariable("vnfId"));
- assertEquals(genericVnf.getVnfName(), execution.getVariable("vnfName"));
- assertEquals("ConfigScaleOut", execution.getVariable("action"));
- assertEquals(requestContext.getMsoRequestId(), execution.getVariable("msoRequestId"));
- assertEquals(controllerSelectionReference.getControllerName(), execution.getVariable("controllerType"));
- assertEquals(vfModule.getVfModuleId(), execution.getVariable("vfModuleId"));
- assertEquals(expectedPayload, execution.getVariable("payload"));
- }
-
- @Test
- public void callAppcClientExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- Action action = Action.ConfigScaleOut;
- String vnfId = genericVnf.getVnfId();
- String controllerType = "testType";
- String payload = "{\"request-parameters\":{\"vnf-host-ip-address\":\"10.222.22.2\","
- + "\"vf-module-id\":\"testVfModuleId1\"},\"configuration-parameters\""
- + ":{\"vnf-id\":\"66dac89b-2a5b-4cb9-b22e-a7e4488fb3db\",\"availability-zone\":\"AZ-MN02\"}}";
- HashMap<String, String> payloadInfo = new HashMap<String, String>();
- payloadInfo.put("vnfName", "testVnfName");
- payloadInfo.put("vfModuleId", "testVfModuleId");
-
- execution.setVariable("action", Action.ConfigScaleOut.toString());
- execution.setVariable("msoRequestId", msoRequestId);
- execution.setVariable("controllerType", controllerType);
- execution.setVariable("vnfId", "testVnfId1");
- execution.setVariable("vnfName", "testVnfName");
- execution.setVariable("vfModuleId", "testVfModuleId");
- execution.setVariable("payload", payload);
-
-
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1002), eq("APPC Client Failed"));
- doThrow(new RuntimeException("APPC Client Failed")).when(appCClient).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
- configurationScaleOut.callAppcClient(execution);
- verify(appCClient, times(1)).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
- }
+
+ @InjectMocks
+ private ConfigurationScaleOut configurationScaleOut = new ConfigurationScaleOut();
+
+ private GenericVnf genericVnf;
+ private VfModule vfModule;
+ private RequestContext requestContext;
+ private String msoRequestId;
+ private List<Map<String, String>> configurationParameters = new ArrayList<>();
+ private Map<String, String> configParamsMap = new HashMap<>();
+
+
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ genericVnf = setGenericVnf();
+ vfModule = setVfModule();
+ msoRequestId = UUID.randomUUID().toString();
+ requestContext = setRequestContext();
+ requestContext.setMsoRequestId(msoRequestId);
+ configParamsMap.put("availability-zone",
+ "$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]");
+ configParamsMap.put("vnf-id", "$.vnf-topology.vnf-topology-identifier-structure.vnf-id");
+ configurationParameters.add(configParamsMap);
+ requestContext.setConfigurationParameters(configurationParameters);
+ gBBInput.setRequestContext(requestContext);
+
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
+ .thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
+
+ }
+
+ @Test
+ public void setParamsForConfigurationScaleOutTest() throws Exception {
+ ControllerSelectionReference controllerSelectionReference = new ControllerSelectionReference();
+ controllerSelectionReference.setControllerName("testName");
+ controllerSelectionReference.setActionCategory("testAction");
+ controllerSelectionReference.setVnfType("testVnfType");
+ String sdncResponse =
+ new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNCClientGetResponse.json")));
+ String expectedPayload = "{\"request-parameters\":{\"vnf-host-ip-address\":\"10.222.22.2\","
+ + "\"vf-module-id\":\"testVfModuleId1\"},\"configuration-parameters\""
+ + ":{\"vnf-id\":\"66dac89b-2a5b-4cb9-b22e-a7e4488fb3db\",\"availability-zone\":\"AZ-MN02\"}}";
+ execution.setVariable("SDNCQueryResponse_" + vfModule.getVfModuleId(), sdncResponse);
+
+ doReturn(controllerSelectionReference).when(catalogDbClient)
+ .getControllerSelectionReferenceByVnfTypeAndActionCategory(genericVnf.getVnfType(),
+ Action.ConfigScaleOut.toString());
+
+ configurationScaleOut.setParamsForConfigurationScaleOut(execution);
+
+ assertEquals(genericVnf.getVnfId(), execution.getVariable("vnfId"));
+ assertEquals(genericVnf.getVnfName(), execution.getVariable("vnfName"));
+ assertEquals("ConfigScaleOut", execution.getVariable("action"));
+ assertEquals(requestContext.getMsoRequestId(), execution.getVariable("msoRequestId"));
+ assertEquals(controllerSelectionReference.getControllerName(), execution.getVariable("controllerType"));
+ assertEquals(vfModule.getVfModuleId(), execution.getVariable("vfModuleId"));
+ assertEquals(expectedPayload, execution.getVariable("payload"));
+ }
+
+ @Test
+ public void callAppcClientTest() throws Exception {
+ Action action = Action.ConfigScaleOut;
+ String vnfId = genericVnf.getVnfId();
+ String controllerType = "testType";
+ String payload = "{\"request-parameters\":{\"vnf-host-ip-address\":\"10.222.22.2\","
+ + "\"vf-module-id\":\"testVfModuleId1\"},\"configuration-parameters\""
+ + ":{\"vnf-id\":\"66dac89b-2a5b-4cb9-b22e-a7e4488fb3db\",\"availability-zone\":\"AZ-MN02\"}}";
+ HashMap<String, String> payloadInfo = new HashMap<String, String>();
+ payloadInfo.put("vnfName", "testVnfName");
+ payloadInfo.put("vfModuleId", "testVfModuleId");
+
+ execution.setVariable("action", Action.ConfigScaleOut.toString());
+ execution.setVariable("msoRequestId", msoRequestId);
+ execution.setVariable("controllerType", controllerType);
+ execution.setVariable("vnfId", "testVnfId1");
+ execution.setVariable("vnfName", "testVnfName");
+ execution.setVariable("vfModuleId", "testVfModuleId");
+ execution.setVariable("payload", payload);
+
+ doNothing().when(appCClient).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo,
+ controllerType);
+
+ configurationScaleOut.callAppcClient(execution);
+ verify(appCClient, times(1)).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo,
+ controllerType);
+ }
+
+ @Test
+ public void setParamsForConfigurationScaleOutBadPathTest() throws Exception {
+ ControllerSelectionReference controllerSelectionReference = new ControllerSelectionReference();
+ controllerSelectionReference.setControllerName("testName");
+ controllerSelectionReference.setActionCategory("testAction");
+ controllerSelectionReference.setVnfType("testVnfType");
+ String sdncResponse = new String(
+ Files.readAllBytes(Paths.get("src/test/resources/__files/SDNCClientResponseIncorrectPath.json")));
+ String expectedPayload = "{\"request-parameters\":{\"vnf-host-ip-address\":\"10.222.22.2\","
+ + "\"vf-module-id\":\"testVfModuleId1\"},\"configuration-parameters\""
+ + ":{\"vnf-id\":\"66dac89b-2a5b-4cb9-b22e-a7e4488fb3db\",\"availability-zone\":null}}";
+ execution.setVariable("SDNCQueryResponse_" + vfModule.getVfModuleId(), sdncResponse);
+
+ doReturn(controllerSelectionReference).when(catalogDbClient)
+ .getControllerSelectionReferenceByVnfTypeAndActionCategory(genericVnf.getVnfType(),
+ Action.ConfigScaleOut.toString());
+
+ configurationScaleOut.setParamsForConfigurationScaleOut(execution);
+
+ assertEquals(genericVnf.getVnfId(), execution.getVariable("vnfId"));
+ assertEquals(genericVnf.getVnfName(), execution.getVariable("vnfName"));
+ assertEquals("ConfigScaleOut", execution.getVariable("action"));
+ assertEquals(requestContext.getMsoRequestId(), execution.getVariable("msoRequestId"));
+ assertEquals(controllerSelectionReference.getControllerName(), execution.getVariable("controllerType"));
+ assertEquals(vfModule.getVfModuleId(), execution.getVariable("vfModuleId"));
+ assertEquals(expectedPayload, execution.getVariable("payload"));
+ }
+
+ @Test
+ public void callAppcClientExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ Action action = Action.ConfigScaleOut;
+ String vnfId = genericVnf.getVnfId();
+ String controllerType = "testType";
+ String payload = "{\"request-parameters\":{\"vnf-host-ip-address\":\"10.222.22.2\","
+ + "\"vf-module-id\":\"testVfModuleId1\"},\"configuration-parameters\""
+ + ":{\"vnf-id\":\"66dac89b-2a5b-4cb9-b22e-a7e4488fb3db\",\"availability-zone\":\"AZ-MN02\"}}";
+ HashMap<String, String> payloadInfo = new HashMap<String, String>();
+ payloadInfo.put("vnfName", "testVnfName");
+ payloadInfo.put("vfModuleId", "testVfModuleId");
+
+ execution.setVariable("action", Action.ConfigScaleOut.toString());
+ execution.setVariable("msoRequestId", msoRequestId);
+ execution.setVariable("controllerType", controllerType);
+ execution.setVariable("vnfId", "testVnfId1");
+ execution.setVariable("vnfName", "testVnfName");
+ execution.setVariable("vfModuleId", "testVfModuleId");
+ execution.setVariable("payload", payload);
+
+
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1002), eq("APPC Client Failed"));
+ doThrow(new RuntimeException("APPC Client Failed")).when(appCClient).runAppCCommand(action, msoRequestId, vnfId,
+ Optional.of(payload), payloadInfo, controllerType);
+ configurationScaleOut.callAppcClient(execution);
+ verify(appCClient, times(1)).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo,
+ controllerType);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetworkCollectionTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetworkCollectionTest.java
index 423029c59b..f0889f62c0 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetworkCollectionTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetworkCollectionTest.java
@@ -18,6 +18,7 @@
* ============LICENSE_END=========================================================
*/
package org.onap.so.bpmn.infrastructure.flowspecific.tasks;
+
import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
@@ -26,10 +27,8 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import java.util.ArrayList;
import java.util.List;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
@@ -45,73 +44,84 @@ import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup;
import org.onap.so.client.exception.BBObjectNotFoundException;
-public class CreateNetworkCollectionTest extends BaseTaskTest{
- @InjectMocks
- private CreateNetworkCollection createNetworkCollection = new CreateNetworkCollection();
-
- private L3Network network;
- private ServiceInstance serviceInstance;
- private OrchestrationContext orchestrationContext;
- private CloudRegion cloudRegion;
-
- @Before
- public void before() throws BBObjectNotFoundException {
- serviceInstance = setServiceInstance();
- network = setL3Network();
- cloudRegion = setCloudRegion();
-
- List<L3Network> l3NetworkList = new ArrayList<L3Network>();
- l3NetworkList.add(network);
- ModelInfoInstanceGroup modelInfoInstanceGroup = new ModelInfoInstanceGroup();
- modelInfoInstanceGroup.setFunction("function");
- serviceInstance.getCollection().getInstanceGroup().setModelInfoInstanceGroup(modelInfoInstanceGroup);
-
- orchestrationContext = setOrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(true);
-
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))).thenReturn(serviceInstance);
- }
-
- @Test
- public void buildCreateNetworkRequestTest() throws Exception {
- createNetworkCollection.buildNetworkCollectionName(execution);
-
- assertEquals(serviceInstance.getServiceInstanceName() + "_" + serviceInstance.getCollection().getInstanceGroup().getModelInfoInstanceGroup().getFunction(), execution.getVariable("networkCollectionName"));
- }
-
- @Test(expected = BpmnError.class)
- public void buildCreateNetworkRequestInstanceGroupModelInfoFunctionNullExceptionTest() throws Exception {
- ModelInfoInstanceGroup modelInfoInstanceGroup = new ModelInfoInstanceGroup();
- serviceInstance.getCollection().getInstanceGroup().setModelInfoInstanceGroup(modelInfoInstanceGroup);
- createNetworkCollection.buildNetworkCollectionName(execution);
- }
-
- @Test(expected = BpmnError.class)
- public void buildCreateNetworkRequestInstanceGroupModelInfoNullTest() throws Exception {
- serviceInstance.getCollection().getInstanceGroup().setModelInfoInstanceGroup(null);
- createNetworkCollection.buildNetworkCollectionName(execution);
- }
-
- @Test
- public void connectCollectionToInstanceGroupTest() throws Exception {
- doNothing().when(aaiNetworkResources).connectNetworkCollectionInstanceGroupToNetworkCollection(serviceInstance.getCollection().getInstanceGroup(), serviceInstance.getCollection());
- createNetworkCollection.connectCollectionToInstanceGroup(execution);
- verify(aaiNetworkResources, times(1)).connectNetworkCollectionInstanceGroupToNetworkCollection(serviceInstance.getCollection().getInstanceGroup(), serviceInstance.getCollection());
- }
-
- @Test
- public void connectCollectionToServiceInstanceTest() throws Exception {
- doNothing().when(aaiNetworkResources).connectNetworkCollectionToServiceInstance(serviceInstance.getCollection(), serviceInstance);
- createNetworkCollection.connectCollectionToServiceInstance(execution);
- verify(aaiNetworkResources, times(1)).connectNetworkCollectionToServiceInstance(serviceInstance.getCollection(), serviceInstance);
- }
-
- @Test
- public void connectInstanceGroupToCloudRegionTest() throws Exception {
- doNothing().when(aaiNetworkResources).connectInstanceGroupToCloudRegion(serviceInstance.getCollection().getInstanceGroup(), cloudRegion);
- createNetworkCollection.connectInstanceGroupToCloudRegion(execution);
- verify(aaiNetworkResources, times(1)).connectInstanceGroupToCloudRegion(serviceInstance.getCollection().getInstanceGroup(), cloudRegion);
- }
+public class CreateNetworkCollectionTest extends BaseTaskTest {
+ @InjectMocks
+ private CreateNetworkCollection createNetworkCollection = new CreateNetworkCollection();
+
+ private L3Network network;
+ private ServiceInstance serviceInstance;
+ private OrchestrationContext orchestrationContext;
+ private CloudRegion cloudRegion;
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ serviceInstance = setServiceInstance();
+ network = setL3Network();
+ cloudRegion = setCloudRegion();
+
+ List<L3Network> l3NetworkList = new ArrayList<L3Network>();
+ l3NetworkList.add(network);
+ ModelInfoInstanceGroup modelInfoInstanceGroup = new ModelInfoInstanceGroup();
+ modelInfoInstanceGroup.setFunction("function");
+ serviceInstance.getCollection().getInstanceGroup().setModelInfoInstanceGroup(modelInfoInstanceGroup);
+
+ orchestrationContext = setOrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(true);
+
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
+ .thenReturn(serviceInstance);
+ }
+
+ @Test
+ public void buildCreateNetworkRequestTest() throws Exception {
+ createNetworkCollection.buildNetworkCollectionName(execution);
+
+ assertEquals(
+ serviceInstance.getServiceInstanceName() + "_"
+ + serviceInstance.getCollection().getInstanceGroup().getModelInfoInstanceGroup().getFunction(),
+ execution.getVariable("networkCollectionName"));
+ }
+
+ @Test(expected = BpmnError.class)
+ public void buildCreateNetworkRequestInstanceGroupModelInfoFunctionNullExceptionTest() throws Exception {
+ ModelInfoInstanceGroup modelInfoInstanceGroup = new ModelInfoInstanceGroup();
+ serviceInstance.getCollection().getInstanceGroup().setModelInfoInstanceGroup(modelInfoInstanceGroup);
+ createNetworkCollection.buildNetworkCollectionName(execution);
+ }
+
+ @Test(expected = BpmnError.class)
+ public void buildCreateNetworkRequestInstanceGroupModelInfoNullTest() throws Exception {
+ serviceInstance.getCollection().getInstanceGroup().setModelInfoInstanceGroup(null);
+ createNetworkCollection.buildNetworkCollectionName(execution);
+ }
+
+ @Test
+ public void connectCollectionToInstanceGroupTest() throws Exception {
+ doNothing().when(aaiNetworkResources).connectNetworkCollectionInstanceGroupToNetworkCollection(
+ serviceInstance.getCollection().getInstanceGroup(), serviceInstance.getCollection());
+ createNetworkCollection.connectCollectionToInstanceGroup(execution);
+ verify(aaiNetworkResources, times(1)).connectNetworkCollectionInstanceGroupToNetworkCollection(
+ serviceInstance.getCollection().getInstanceGroup(), serviceInstance.getCollection());
+ }
+
+ @Test
+ public void connectCollectionToServiceInstanceTest() throws Exception {
+ doNothing().when(aaiNetworkResources).connectNetworkCollectionToServiceInstance(serviceInstance.getCollection(),
+ serviceInstance);
+ createNetworkCollection.connectCollectionToServiceInstance(execution);
+ verify(aaiNetworkResources, times(1)).connectNetworkCollectionToServiceInstance(serviceInstance.getCollection(),
+ serviceInstance);
+ }
+
+ @Test
+ public void connectInstanceGroupToCloudRegionTest() throws Exception {
+ doNothing().when(aaiNetworkResources)
+ .connectInstanceGroupToCloudRegion(serviceInstance.getCollection().getInstanceGroup(), cloudRegion);
+ createNetworkCollection.connectInstanceGroupToCloudRegion(execution);
+ verify(aaiNetworkResources, times(1))
+ .connectInstanceGroupToCloudRegion(serviceInstance.getCollection().getInstanceGroup(), cloudRegion);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetworkTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetworkTest.java
index de1aa63f55..1e0ab20d97 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetworkTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetworkTest.java
@@ -26,9 +26,7 @@ import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import java.util.Map;
-
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentMatchers;
@@ -45,47 +43,51 @@ import org.onap.so.client.exception.BBObjectNotFoundException;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
import org.springframework.beans.factory.annotation.Autowired;
-public class CreateNetworkTest extends BaseTaskTest{
- @InjectMocks
- private CreateNetwork createNetwork = new CreateNetwork();
-
- private L3Network network;
- private ServiceInstance serviceInstance;
- private CloudRegion cloudRegion;
- private OrchestrationContext orchestrationContext;
- private Map<String, String> userInput;
- private RequestContext requestContext;
- private String cloudRegionPo = "testCloudRegionPo";
- private Customer customer;
-
- @Before
- public void before() throws BBObjectNotFoundException {
- customer = setCustomer();
- serviceInstance = setServiceInstance();
- network = setL3Network();
- cloudRegion = setCloudRegion();
- orchestrationContext = setOrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(true);
- requestContext = setRequestContext();
- userInput = setUserInput();
+public class CreateNetworkTest extends BaseTaskTest {
+ @InjectMocks
+ private CreateNetwork createNetwork = new CreateNetwork();
+
+ private L3Network network;
+ private ServiceInstance serviceInstance;
+ private CloudRegion cloudRegion;
+ private OrchestrationContext orchestrationContext;
+ private Map<String, String> userInput;
+ private RequestContext requestContext;
+ private String cloudRegionPo = "testCloudRegionPo";
+ private Customer customer;
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ customer = setCustomer();
+ serviceInstance = setServiceInstance();
+ network = setL3Network();
+ cloudRegion = setCloudRegion();
+ orchestrationContext = setOrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(true);
+ requestContext = setRequestContext();
+ userInput = setUserInput();
+
+ customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
+ .thenReturn(serviceInstance);
+ }
+
+ @Test
+ public void buildCreateNetworkRequestTest() throws Exception {
+ execution.setVariable("cloudRegionPo", cloudRegionPo);
+
+ CreateNetworkRequest expectedCreateNetworkRequest = new CreateNetworkRequest();
+
+ doReturn(expectedCreateNetworkRequest).when(networkAdapterObjectMapper).createNetworkRequestMapper(
+ requestContext, cloudRegion, orchestrationContext, serviceInstance, network, userInput, cloudRegionPo,
+ customer);
+
+ createNetwork.buildCreateNetworkRequest(execution);
+
+ verify(networkAdapterObjectMapper, times(1)).createNetworkRequestMapper(requestContext, cloudRegion,
+ orchestrationContext, serviceInstance, network, userInput, cloudRegionPo, customer);
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))).thenReturn(serviceInstance);
- }
-
- @Test
- public void buildCreateNetworkRequestTest() throws Exception {
- execution.setVariable("cloudRegionPo", cloudRegionPo);
-
- CreateNetworkRequest expectedCreateNetworkRequest = new CreateNetworkRequest();
-
- doReturn(expectedCreateNetworkRequest).when(networkAdapterObjectMapper).createNetworkRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, network, userInput, cloudRegionPo, customer);
-
- createNetwork.buildCreateNetworkRequest(execution);
-
- verify(networkAdapterObjectMapper, times(1)).createNetworkRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, network, userInput, cloudRegionPo, customer);
-
- assertThat(expectedCreateNetworkRequest, sameBeanAs(execution.getVariable("createNetworkRequest")));
- }
+ assertThat(expectedCreateNetworkRequest, sameBeanAs(execution.getVariable("createNetworkRequest")));
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheckTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheckTest.java
index 2386da743b..f23bbd8c91 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheckTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheckTest.java
@@ -28,11 +28,9 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import java.util.HashMap;
import java.util.Optional;
import java.util.UUID;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Ignore;
@@ -49,128 +47,140 @@ import org.onap.so.client.exception.BBObjectNotFoundException;
import org.onap.so.db.catalog.beans.ControllerSelectionReference;
public class GenericVnfHealthCheckTest extends BaseTaskTest {
-
- @InjectMocks
- private GenericVnfHealthCheck genericVnfHealthCheck = new GenericVnfHealthCheck();
-
- private GenericVnf genericVnf;
- private RequestContext requestContext;
- private String msoRequestId;
-
- @Before
- public void before() throws BBObjectNotFoundException {
- genericVnf = setGenericVnf();
- msoRequestId = UUID.randomUUID().toString();
- requestContext = setRequestContext();
- requestContext.setMsoRequestId(msoRequestId);
- gBBInput.setRequestContext(requestContext);
-
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
- }
-
- @Test
- public void setParamsForGenericVnfHealthCheckTest() throws Exception {
- ControllerSelectionReference controllerSelectionReference = new ControllerSelectionReference();
- controllerSelectionReference.setControllerName("testName");
- controllerSelectionReference.setActionCategory("testAction");
- controllerSelectionReference.setVnfType("testVnfType");
-
- doReturn(controllerSelectionReference).when(catalogDbClient).getControllerSelectionReferenceByVnfTypeAndActionCategory(genericVnf.getVnfType(), Action.HealthCheck.toString());
-
- genericVnfHealthCheck.setParamsForGenericVnfHealthCheck(execution);
-
- assertEquals(genericVnf.getVnfId(), execution.getVariable("vnfId"));
- assertEquals(genericVnf.getVnfName(), execution.getVariable("vnfName"));
- assertEquals(genericVnf.getIpv4OamAddress(), execution.getVariable("oamIpAddress"));
- assertEquals("HealthCheck", execution.getVariable("action"));
- assertEquals(requestContext.getMsoRequestId(), execution.getVariable("msoRequestId"));
- assertEquals(controllerSelectionReference.getControllerName(), execution.getVariable("controllerType"));
- }
- @Test
- public void callAppcClientTest() throws Exception {
- Action action = Action.HealthCheck;
- String vnfId = genericVnf.getVnfId();
- String payload = "{\"testName\":\"testValue\",}";
- String controllerType = "testType";
- HashMap<String, String> payloadInfo = new HashMap<String, String>();
- payloadInfo.put("vnfName", "testVnfName");
- payloadInfo.put("vfModuleId", "testVfModuleId");
- payloadInfo.put("oamIpAddress", "testOamIpAddress");
- payloadInfo.put("vnfHostIpAddress", "testOamIpAddress");
- execution.setVariable("action", Action.HealthCheck.toString());
- execution.setVariable("msoRequestId", msoRequestId);
- execution.setVariable("controllerType", controllerType);
- execution.setVariable("vnfId", "testVnfId1");
- execution.setVariable("vnfName", "testVnfName");
- execution.setVariable("vfModuleId", "testVfModuleId");
- execution.setVariable("oamIpAddress", "testOamIpAddress");
- execution.setVariable("vnfHostIpAddress", "testOamIpAddress");
- execution.setVariable("payload", payload);
-
- doNothing().when(appCClient).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
-
- genericVnfHealthCheck.callAppcClient(execution);
- verify(appCClient, times(1)).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
- }
-
- @Test
- public void callAppcClientExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- Action action = Action.HealthCheck;
- String vnfId = genericVnf.getVnfId();
- String payload = "{\"testName\":\"testValue\",}";
- String controllerType = "testType";
- HashMap<String, String> payloadInfo = new HashMap<String, String>();
- payloadInfo.put("vnfName", "testVnfName");
- payloadInfo.put("vfModuleId", "testVfModuleId");
- payloadInfo.put("oamIpAddress", "testOamIpAddress");
- payloadInfo.put("vnfHostIpAddress", "testOamIpAddress");
- execution.setVariable("action", Action.HealthCheck.toString());
- execution.setVariable("msoRequestId", msoRequestId);
- execution.setVariable("controllerType", controllerType);
- execution.setVariable("vnfId", "testVnfId1");
- execution.setVariable("vnfName", "testVnfName");
- execution.setVariable("vfModuleId", "testVfModuleId");
- execution.setVariable("oamIpAddress", "testOamIpAddress");
- execution.setVariable("vnfHostIpAddress", "testOamIpAddress");
- execution.setVariable("payload", payload);
-
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1002), eq("APPC Client Failed"));
- doThrow(new RuntimeException("APPC Client Failed")).when(appCClient).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
-
-
- genericVnfHealthCheck.callAppcClient(execution);
- verify(appCClient, times(1)).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
- }
-
- @Test
- @Ignore //The runAppCCommand method in not capable of throwing this exception
- public void callAppcClientTimeOutExceptionTest() {
- expectedException.expect(java.util.concurrent.TimeoutException.class);
- Action action = Action.HealthCheck;
- String vnfId = genericVnf.getVnfId();
- String payload = "{\"testName\":\"testValue\",}";
- String controllerType = "testType";
- HashMap<String, String> payloadInfo = new HashMap<String, String>();
- payloadInfo.put("vnfName", "testVnfName");
- payloadInfo.put("vfModuleId", "testVfModuleId");
- payloadInfo.put("oamIpAddress", "testOamIpAddress");
- payloadInfo.put("vnfHostIpAddress", "testOamIpAddress");
- execution.setVariable("action", Action.HealthCheck.toString());
- execution.setVariable("msoRequestId", msoRequestId);
- execution.setVariable("controllerType", controllerType);
- execution.setVariable("vnfId", "testVnfId1");
- execution.setVariable("vnfName", "testVnfName");
- execution.setVariable("vfModuleId", "testVfModuleId");
- execution.setVariable("oamIpAddress", "testOamIpAddress");
- execution.setVariable("vnfHostIpAddress", "testOamIpAddress");
- execution.setVariable("payload", payload);
-
- doThrow(java.util.concurrent.TimeoutException.class).when(appCClient).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
-
-
- genericVnfHealthCheck.callAppcClient(execution);
- verify(appCClient, times(1)).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
- }
+
+ @InjectMocks
+ private GenericVnfHealthCheck genericVnfHealthCheck = new GenericVnfHealthCheck();
+
+ private GenericVnf genericVnf;
+ private RequestContext requestContext;
+ private String msoRequestId;
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ genericVnf = setGenericVnf();
+ msoRequestId = UUID.randomUUID().toString();
+ requestContext = setRequestContext();
+ requestContext.setMsoRequestId(msoRequestId);
+ gBBInput.setRequestContext(requestContext);
+
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
+ .thenReturn(genericVnf);
+ }
+
+ @Test
+ public void setParamsForGenericVnfHealthCheckTest() throws Exception {
+ ControllerSelectionReference controllerSelectionReference = new ControllerSelectionReference();
+ controllerSelectionReference.setControllerName("testName");
+ controllerSelectionReference.setActionCategory("testAction");
+ controllerSelectionReference.setVnfType("testVnfType");
+
+ doReturn(controllerSelectionReference).when(catalogDbClient)
+ .getControllerSelectionReferenceByVnfTypeAndActionCategory(genericVnf.getVnfType(),
+ Action.HealthCheck.toString());
+
+ genericVnfHealthCheck.setParamsForGenericVnfHealthCheck(execution);
+
+ assertEquals(genericVnf.getVnfId(), execution.getVariable("vnfId"));
+ assertEquals(genericVnf.getVnfName(), execution.getVariable("vnfName"));
+ assertEquals(genericVnf.getIpv4OamAddress(), execution.getVariable("oamIpAddress"));
+ assertEquals("HealthCheck", execution.getVariable("action"));
+ assertEquals(requestContext.getMsoRequestId(), execution.getVariable("msoRequestId"));
+ assertEquals(controllerSelectionReference.getControllerName(), execution.getVariable("controllerType"));
+ }
+
+ @Test
+ public void callAppcClientTest() throws Exception {
+ Action action = Action.HealthCheck;
+ String vnfId = genericVnf.getVnfId();
+ String payload = "{\"testName\":\"testValue\",}";
+ String controllerType = "testType";
+ HashMap<String, String> payloadInfo = new HashMap<String, String>();
+ payloadInfo.put("vnfName", "testVnfName");
+ payloadInfo.put("vfModuleId", "testVfModuleId");
+ payloadInfo.put("oamIpAddress", "testOamIpAddress");
+ payloadInfo.put("vnfHostIpAddress", "testOamIpAddress");
+ execution.setVariable("action", Action.HealthCheck.toString());
+ execution.setVariable("msoRequestId", msoRequestId);
+ execution.setVariable("controllerType", controllerType);
+ execution.setVariable("vnfId", "testVnfId1");
+ execution.setVariable("vnfName", "testVnfName");
+ execution.setVariable("vfModuleId", "testVfModuleId");
+ execution.setVariable("oamIpAddress", "testOamIpAddress");
+ execution.setVariable("vnfHostIpAddress", "testOamIpAddress");
+ execution.setVariable("payload", payload);
+
+ doNothing().when(appCClient).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo,
+ controllerType);
+
+ genericVnfHealthCheck.callAppcClient(execution);
+ verify(appCClient, times(1)).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo,
+ controllerType);
+ }
+
+ @Test
+ public void callAppcClientExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ Action action = Action.HealthCheck;
+ String vnfId = genericVnf.getVnfId();
+ String payload = "{\"testName\":\"testValue\",}";
+ String controllerType = "testType";
+ HashMap<String, String> payloadInfo = new HashMap<String, String>();
+ payloadInfo.put("vnfName", "testVnfName");
+ payloadInfo.put("vfModuleId", "testVfModuleId");
+ payloadInfo.put("oamIpAddress", "testOamIpAddress");
+ payloadInfo.put("vnfHostIpAddress", "testOamIpAddress");
+ execution.setVariable("action", Action.HealthCheck.toString());
+ execution.setVariable("msoRequestId", msoRequestId);
+ execution.setVariable("controllerType", controllerType);
+ execution.setVariable("vnfId", "testVnfId1");
+ execution.setVariable("vnfName", "testVnfName");
+ execution.setVariable("vfModuleId", "testVfModuleId");
+ execution.setVariable("oamIpAddress", "testOamIpAddress");
+ execution.setVariable("vnfHostIpAddress", "testOamIpAddress");
+ execution.setVariable("payload", payload);
+
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1002), eq("APPC Client Failed"));
+ doThrow(new RuntimeException("APPC Client Failed")).when(appCClient).runAppCCommand(action, msoRequestId, vnfId,
+ Optional.of(payload), payloadInfo, controllerType);
+
+
+ genericVnfHealthCheck.callAppcClient(execution);
+ verify(appCClient, times(1)).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo,
+ controllerType);
+ }
+
+ @Test
+ @Ignore // The runAppCCommand method in not capable of throwing this exception
+ public void callAppcClientTimeOutExceptionTest() {
+ expectedException.expect(java.util.concurrent.TimeoutException.class);
+ Action action = Action.HealthCheck;
+ String vnfId = genericVnf.getVnfId();
+ String payload = "{\"testName\":\"testValue\",}";
+ String controllerType = "testType";
+ HashMap<String, String> payloadInfo = new HashMap<String, String>();
+ payloadInfo.put("vnfName", "testVnfName");
+ payloadInfo.put("vfModuleId", "testVfModuleId");
+ payloadInfo.put("oamIpAddress", "testOamIpAddress");
+ payloadInfo.put("vnfHostIpAddress", "testOamIpAddress");
+ execution.setVariable("action", Action.HealthCheck.toString());
+ execution.setVariable("msoRequestId", msoRequestId);
+ execution.setVariable("controllerType", controllerType);
+ execution.setVariable("vnfId", "testVnfId1");
+ execution.setVariable("vnfName", "testVnfName");
+ execution.setVariable("vfModuleId", "testVfModuleId");
+ execution.setVariable("oamIpAddress", "testOamIpAddress");
+ execution.setVariable("vnfHostIpAddress", "testOamIpAddress");
+ execution.setVariable("payload", payload);
+
+ doThrow(java.util.concurrent.TimeoutException.class).when(appCClient).runAppCCommand(action, msoRequestId,
+ vnfId, Optional.of(payload), payloadInfo, controllerType);
+
+
+ genericVnfHealthCheck.callAppcClient(execution);
+ verify(appCClient, times(1)).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo,
+ controllerType);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/NetworkBBUtilsTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/NetworkBBUtilsTest.java
index bf9be282d4..5eafb982e6 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/NetworkBBUtilsTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/NetworkBBUtilsTest.java
@@ -23,11 +23,9 @@ package org.onap.so.bpmn.infrastructure.flowspecific.tasks;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Optional;
-
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
@@ -38,82 +36,84 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.client.aai.entities.AAIResultWrapper;
import org.springframework.beans.factory.annotation.Autowired;
-public class NetworkBBUtilsTest extends BaseTaskTest{
- @InjectMocks
- private NetworkBBUtils networkBBUtils = new NetworkBBUtils();
-
- private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/Network/";
-
- private CloudRegion cloudRegion;
-
- @Before
- public void before() {
- cloudRegion = setCloudRegion();
- }
-
- @Test
- public void isRelationshipRelatedToExistsTrueTest() throws Exception {
- final String aaiResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "unassignNetworkBB_queryAAIResponse_.json")));
- AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(aaiResponse);
- Optional<L3Network> l3network = aaiResultWrapper.asBean(L3Network.class);
-
- boolean isVfModule = networkBBUtils.isRelationshipRelatedToExists(l3network, "vf-module");
- assertTrue(isVfModule);
-
- }
-
- @Test
- public void isRelationshipRelatedToExistsFalseTest() throws Exception {
- final String aaiResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAAIResponse.json")));
- AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(aaiResponse);
- Optional<L3Network> l3network = aaiResultWrapper.asBean(L3Network.class);
-
- boolean isVfModule = networkBBUtils.isRelationshipRelatedToExists(l3network, "vf-module");
- assertFalse(isVfModule);
-
- }
-
- @Test
- public void getCloudRegionSDNC25Test() throws Exception {
- cloudRegion.setCloudRegionVersion("2.5");
-
- NetworkBBUtils spyAssign = Mockito.spy(NetworkBBUtils.class);
- String cloudRegionId = spyAssign.getCloudRegion(execution, SourceSystem.SDNC);
- Mockito.verify(spyAssign).getCloudRegion(execution, SourceSystem.SDNC);
-
- assertEquals("AAIAIC25", cloudRegionId);
- }
-
- @Test
- public void getCloudRegionSDNC30Test() throws Exception {
- cloudRegion.setCloudRegionVersion("3.0");
-
- NetworkBBUtils spyAssign = Mockito.spy(NetworkBBUtils.class);
- String cloudRegionId = spyAssign.getCloudRegion(execution, SourceSystem.SDNC);
- Mockito.verify(spyAssign).getCloudRegion(execution, SourceSystem.SDNC);
-
- assertEquals(cloudRegion.getLcpCloudRegionId(), cloudRegionId);
- }
-
- @Test
- public void getCloudRegionPO25Test() throws Exception {
- cloudRegion.setCloudRegionVersion("2.5");
-
- NetworkBBUtils spyAssign = Mockito.spy(NetworkBBUtils.class);
- String cloudRegionId = spyAssign.getCloudRegion(execution, SourceSystem.PO);
- Mockito.verify(spyAssign).getCloudRegion(execution, SourceSystem.PO);
-
- assertEquals(cloudRegion.getLcpCloudRegionId(), cloudRegionId);
- }
-
- @Test
- public void getCloudRegionPO30Test() throws Exception {
- cloudRegion.setCloudRegionVersion("3.0");
-
- NetworkBBUtils spyAssignPO = Mockito.spy(NetworkBBUtils.class);
- String cloudRegionIdPO = spyAssignPO.getCloudRegion(execution, SourceSystem.PO);
- Mockito.verify(spyAssignPO).getCloudRegion(execution, SourceSystem.PO);
-
- assertEquals(cloudRegion.getLcpCloudRegionId(), cloudRegionIdPO);
- }
+public class NetworkBBUtilsTest extends BaseTaskTest {
+ @InjectMocks
+ private NetworkBBUtils networkBBUtils = new NetworkBBUtils();
+
+ private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/Network/";
+
+ private CloudRegion cloudRegion;
+
+ @Before
+ public void before() {
+ cloudRegion = setCloudRegion();
+ }
+
+ @Test
+ public void isRelationshipRelatedToExistsTrueTest() throws Exception {
+ final String aaiResponse = new String(
+ Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "unassignNetworkBB_queryAAIResponse_.json")));
+ AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(aaiResponse);
+ Optional<L3Network> l3network = aaiResultWrapper.asBean(L3Network.class);
+
+ boolean isVfModule = networkBBUtils.isRelationshipRelatedToExists(l3network, "vf-module");
+ assertTrue(isVfModule);
+
+ }
+
+ @Test
+ public void isRelationshipRelatedToExistsFalseTest() throws Exception {
+ final String aaiResponse =
+ new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAAIResponse.json")));
+ AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(aaiResponse);
+ Optional<L3Network> l3network = aaiResultWrapper.asBean(L3Network.class);
+
+ boolean isVfModule = networkBBUtils.isRelationshipRelatedToExists(l3network, "vf-module");
+ assertFalse(isVfModule);
+
+ }
+
+ @Test
+ public void getCloudRegionSDNC25Test() throws Exception {
+ cloudRegion.setCloudRegionVersion("2.5");
+
+ NetworkBBUtils spyAssign = Mockito.spy(NetworkBBUtils.class);
+ String cloudRegionId = spyAssign.getCloudRegion(execution, SourceSystem.SDNC);
+ Mockito.verify(spyAssign).getCloudRegion(execution, SourceSystem.SDNC);
+
+ assertEquals("AAIAIC25", cloudRegionId);
+ }
+
+ @Test
+ public void getCloudRegionSDNC30Test() throws Exception {
+ cloudRegion.setCloudRegionVersion("3.0");
+
+ NetworkBBUtils spyAssign = Mockito.spy(NetworkBBUtils.class);
+ String cloudRegionId = spyAssign.getCloudRegion(execution, SourceSystem.SDNC);
+ Mockito.verify(spyAssign).getCloudRegion(execution, SourceSystem.SDNC);
+
+ assertEquals(cloudRegion.getLcpCloudRegionId(), cloudRegionId);
+ }
+
+ @Test
+ public void getCloudRegionPO25Test() throws Exception {
+ cloudRegion.setCloudRegionVersion("2.5");
+
+ NetworkBBUtils spyAssign = Mockito.spy(NetworkBBUtils.class);
+ String cloudRegionId = spyAssign.getCloudRegion(execution, SourceSystem.PO);
+ Mockito.verify(spyAssign).getCloudRegion(execution, SourceSystem.PO);
+
+ assertEquals(cloudRegion.getLcpCloudRegionId(), cloudRegionId);
+ }
+
+ @Test
+ public void getCloudRegionPO30Test() throws Exception {
+ cloudRegion.setCloudRegionVersion("3.0");
+
+ NetworkBBUtils spyAssignPO = Mockito.spy(NetworkBBUtils.class);
+ String cloudRegionIdPO = spyAssignPO.getCloudRegion(execution, SourceSystem.PO);
+ Mockito.verify(spyAssignPO).getCloudRegion(execution, SourceSystem.PO);
+
+ assertEquals(cloudRegion.getLcpCloudRegionId(), cloudRegionIdPO);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/SniroHomingV2IT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/SniroHomingV2IT.java
index b50cd69f73..8d51ceb65f 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/SniroHomingV2IT.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/SniroHomingV2IT.java
@@ -29,11 +29,9 @@ import static org.junit.Assert.assertNotNull;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.json.JSONArray;
import org.json.JSONObject;
@@ -53,443 +51,542 @@ import org.onap.so.bpmn.servicedecomposition.homingobjects.Candidate;
import org.onap.so.bpmn.servicedecomposition.homingobjects.CandidateType;
import org.onap.so.client.exception.BadResponseException;
import org.onap.so.client.sniro.beans.SniroManagerRequest;
-
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
-public class SniroHomingV2IT extends BaseIntegrationTest{
+public class SniroHomingV2IT extends BaseIntegrationTest {
+
+ private ServiceInstance serviceInstance;
+
+ private RequestContext requestContext;
+
+ private Customer customer;
+ ObjectMapper mapper = new ObjectMapper();
+
+ private static final String RESOURCE_PATH = "__files/BuildingBlocks/SniroHoming/";
+
+
+ String mockResponse =
+ "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"corys cool\", \"requestStatus\": \"accepted\"}";
+
+ @Before
+ public void before() {
+ serviceInstance = setServiceInstance();
+ customer = setCustomer();
+ customer.setGlobalCustomerId("testCustomerId");
+ customer.setSubscriberName("testCustomerName");
+ customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
+
+ requestContext = setRequestContext();
+ requestContext.setMsoRequestId("testRequestId");
+ RequestParameters params = new RequestParameters();
+ params.setaLaCarte(false);
+ params.setSubscriptionServiceType("testSubscriptionServiceType");
+ requestContext.setRequestParameters(params);
+ }
+
+ public void beforeVpnBondingLink(String id) {
+ VpnBondingLink bondingLink = new VpnBondingLink();
+ bondingLink.setVpnBondingLinkId("testVpnBondingId" + id);
+ bondingLink.getServiceProxies().add(setServiceProxy("1", "transport"));
+ ServiceProxy sp2 = setServiceProxy("2", "infrastructure");
+ Candidate requiredCandidate = new Candidate();
+ requiredCandidate.setIdentifierType(CandidateType.VNF_ID);
+ List<String> c = new ArrayList<String>();
+ c.add("testVnfId");
+ requiredCandidate.setIdentifiers(c);
+ sp2.addRequiredCandidates(requiredCandidate);
+ bondingLink.getServiceProxies().add(sp2);
+ serviceInstance.getVpnBondingLinks().add(bondingLink);
+
+ }
+
+ public void beforeAllottedResource() {
+ serviceInstance.getAllottedResources().add(setAllottedResource("1"));
+ serviceInstance.getAllottedResources().add(setAllottedResource("2"));
+ serviceInstance.getAllottedResources().add(setAllottedResource("3"));
+ }
+
+ public void beforeVnf() {
+ setGenericVnf();
+ }
+
+ @Test(expected = Test.None.class)
+ public void testCallSniro_success_1VpnLink() throws BadResponseException, IOException {
+ beforeVpnBondingLink("1");
+
+ wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
+
+ sniroHoming.callSniro(execution);
+
+ String request = readResourceFile(RESOURCE_PATH + "SniroManagerRequest1Vpn.json");
+ request = request.replace("28080", wireMockPort);
+
+ ArgumentCaptor<SniroManagerRequest> argument = ArgumentCaptor.forClass(SniroManagerRequest.class);
+ verify(sniroClient, times(1)).postDemands(argument.capture());
+ assertEquals(request, argument.getValue().toJsonString());
+ }
+
+ @Test
+ public void testCallSniro_success_3VpnLink() throws JsonProcessingException, BadResponseException {
+ beforeVpnBondingLink("1");
+ beforeVpnBondingLink("2");
+ beforeVpnBondingLink("3");
+
+ wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
+
+ sniroHoming.callSniro(execution);
+
+ String request = readResourceFile(RESOURCE_PATH + "SniroManagerRequest3Vpn.json");
+ request = request.replace("28080", wireMockPort);
+
+ ArgumentCaptor<SniroManagerRequest> argument = ArgumentCaptor.forClass(SniroManagerRequest.class);
+ verify(sniroClient, times(1)).postDemands(argument.capture());
+ assertEquals(request, argument.getValue().toJsonString());
+ }
+
+ @Test
+ public void testCallSniro_success_3Allotteds() throws BadResponseException, JsonProcessingException {
+ beforeAllottedResource();
- private ServiceInstance serviceInstance;
+ wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
- private RequestContext requestContext;
+ sniroHoming.callSniro(execution);
- private Customer customer;
- ObjectMapper mapper = new ObjectMapper();
+ String request = readResourceFile(RESOURCE_PATH + "SniroManagerRequest3AR.json");
+ request = request.replace("28080", wireMockPort);
- private static final String RESOURCE_PATH = "__files/BuildingBlocks/SniroHoming/";
+ ArgumentCaptor<SniroManagerRequest> argument = ArgumentCaptor.forClass(SniroManagerRequest.class);
+ verify(sniroClient, times(1)).postDemands(argument.capture());
+ assertEquals(request, argument.getValue().toJsonString());
+ }
+ @Test
+ public void testCallSniro_success_1Vnf() throws JsonProcessingException, BadResponseException {
+ beforeVnf();
- String mockResponse = "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"corys cool\", \"requestStatus\": \"accepted\"}";
+ wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
- @Before
- public void before() {
- serviceInstance = setServiceInstance();
- customer = setCustomer();
- customer.setGlobalCustomerId("testCustomerId");
- customer.setSubscriberName("testCustomerName");
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
+ sniroHoming.callSniro(execution);
- requestContext = setRequestContext();
- requestContext.setMsoRequestId("testRequestId");
- RequestParameters params = new RequestParameters();
- params.setaLaCarte(false);
- params.setSubscriptionServiceType("testSubscriptionServiceType");
- requestContext.setRequestParameters(params);
- }
+ ArgumentCaptor<SniroManagerRequest> argument = ArgumentCaptor.forClass(SniroManagerRequest.class);
+ verify(sniroClient, times(1)).postDemands(argument.capture());
+ // TODO assertEquals(request, argument.getValue().toJsonString());
+ }
- public void beforeVpnBondingLink(String id){
- VpnBondingLink bondingLink = new VpnBondingLink();
- bondingLink.setVpnBondingLinkId("testVpnBondingId" + id);
- bondingLink.getServiceProxies().add(setServiceProxy("1", "transport"));
- ServiceProxy sp2 = setServiceProxy("2", "infrastructure");
- Candidate requiredCandidate = new Candidate();
- requiredCandidate.setIdentifierType(CandidateType.VNF_ID);
- List<String> c = new ArrayList<String>();
- c.add("testVnfId");
- requiredCandidate.setIdentifiers(c);
- sp2.addRequiredCandidates(requiredCandidate);
- bondingLink.getServiceProxies().add(sp2);
- serviceInstance.getVpnBondingLinks().add(bondingLink);
+ @Test
+ public void testCallSniro_success_3Allotteds1Vnf() throws JsonProcessingException, BadResponseException {
+ beforeAllottedResource();
+ beforeVnf();
- }
+ wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
- public void beforeAllottedResource(){
- serviceInstance.getAllottedResources().add(setAllottedResource("1"));
- serviceInstance.getAllottedResources().add(setAllottedResource("2"));
- serviceInstance.getAllottedResources().add(setAllottedResource("3"));
- }
+ sniroHoming.callSniro(execution);
- public void beforeVnf(){
- setGenericVnf();
- }
+ verify(sniroClient, times(1)).postDemands(isA(SniroManagerRequest.class));
+ }
@Test(expected = Test.None.class)
- public void testCallSniro_success_1VpnLink() throws BadResponseException, IOException{
- beforeVpnBondingLink("1");
-
- wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2"))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBody(mockResponse)));
-
- sniroHoming.callSniro(execution);
-
- String request = readResourceFile(RESOURCE_PATH + "SniroManagerRequest1Vpn.json");
- request = request.replace("28080", wireMockPort);
-
- ArgumentCaptor<SniroManagerRequest> argument = ArgumentCaptor.forClass(SniroManagerRequest.class);
- verify(sniroClient, times(1)).postDemands(argument.capture());
- assertEquals(request, argument.getValue().toJsonString());
- }
-
- @Test
- public void testCallSniro_success_3VpnLink() throws JsonProcessingException, BadResponseException{
- beforeVpnBondingLink("1");
- beforeVpnBondingLink("2");
- beforeVpnBondingLink("3");
-
- wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2"))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBody(mockResponse)));
-
- sniroHoming.callSniro(execution);
-
- String request = readResourceFile(RESOURCE_PATH + "SniroManagerRequest3Vpn.json");
- request = request.replace("28080", wireMockPort);
-
- ArgumentCaptor<SniroManagerRequest> argument = ArgumentCaptor.forClass(SniroManagerRequest.class);
- verify(sniroClient, times(1)).postDemands(argument.capture());
- assertEquals(request, argument.getValue().toJsonString());
- }
-
- @Test
- public void testCallSniro_success_3Allotteds() throws BadResponseException, JsonProcessingException{
- beforeAllottedResource();
-
- wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2"))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBody(mockResponse)));
-
- sniroHoming.callSniro(execution);
-
- String request = readResourceFile(RESOURCE_PATH + "SniroManagerRequest3AR.json");
- request = request.replace("28080", wireMockPort);
-
- ArgumentCaptor<SniroManagerRequest> argument = ArgumentCaptor.forClass(SniroManagerRequest.class);
- verify(sniroClient, times(1)).postDemands(argument.capture());
- assertEquals(request, argument.getValue().toJsonString());
- }
-
- @Test
- public void testCallSniro_success_1Vnf() throws JsonProcessingException, BadResponseException{
- beforeVnf();
-
- wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2"))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBody(mockResponse)));
-
- sniroHoming.callSniro(execution);
-
- ArgumentCaptor<SniroManagerRequest> argument = ArgumentCaptor.forClass(SniroManagerRequest.class);
- verify(sniroClient, times(1)).postDemands(argument.capture());
- //TODO assertEquals(request, argument.getValue().toJsonString());
- }
-
- @Test
- public void testCallSniro_success_3Allotteds1Vnf() throws JsonProcessingException, BadResponseException{
- beforeAllottedResource();
- beforeVnf();
-
- wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2"))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBody(mockResponse)));
-
- sniroHoming.callSniro(execution);
-
- verify(sniroClient, times(1)).postDemands(isA(SniroManagerRequest.class));
- }
-
- @Test(expected = Test.None.class)
- public void testProcessSolution_success_1VpnLink_1Solution(){
- beforeVpnBondingLink("1");
-
- JSONObject asyncResponse = new JSONObject();
- asyncResponse.put("transactionId", "testRequestId").put("requestId", "testRequestId").put("requestState", "completed");
- JSONArray solution1 = new JSONArray();
- solution1.put(new JSONObject().put("serviceResourceId", "testProxyId1").put("solution", new JSONObject()
- .put("identifierType", "serviceInstanceId").put("identifiers", new JSONArray().put("testServiceInstanceId1")))
- .put("assignmentInfo", new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "False"))
- .put(new JSONObject().put("key", "cloudOwner").put("value", "aic")).put(new JSONObject().put("key", "vnfHostName").put("value", "testVnfHostName1"))
- .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli1")).put(new JSONObject().put("key", "aicVersion").put("value", "3"))
- .put(new JSONObject().put("key", "vnfId").put("value", "testVnfId1")).put(new JSONObject().put("key", "cloudRegionId").put("value", "testSloudRegionId1"))));
- solution1.put(new JSONObject().put("serviceResourceId", "testProxyId2").put("solution", new JSONObject()
- .put("identifierType", "serviceInstanceId").put("identifiers", new JSONArray().put("testServiceInstanceId2")))
- .put("assignmentInfo", new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "False"))
- .put(new JSONObject().put("key", "cloudOwner").put("value", "aic")).put(new JSONObject().put("key", "primaryPnfName").put("value", "testPrimaryPnfName2"))
- .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli2")).put(new JSONObject().put("key", "aicVersion").put("value", "3"))
- .put(new JSONObject().put("key", "secondaryPnfName").put("value", "testSecondaryPnfName2")).put(new JSONObject().put("key", "cloudRegionId").put("value", "testSloudRegionId2"))));
-
- asyncResponse.put("solutions", new JSONObject().put("placementSolutions", new JSONArray().put(solution1)).put("licenseSolutions", new JSONArray()));
-
- sniroHoming.processSolution(execution, asyncResponse.toString());
-
- ServiceInstance si = execution.getGeneralBuildingBlock().getCustomer().getServiceSubscription().getServiceInstances().get(0);
-
- assertFalse(si.getVpnBondingLinks().isEmpty());
- VpnBondingLink link = si.getVpnBondingLinks().get(0);
- assertNotNull(link);
- assertFalse(link.getServiceProxies().isEmpty());
-
- assertEquals("testServiceInstanceId1", link.getServiceProxy("testProxyId1").getServiceInstance().getServiceInstanceId());
- assertNotNull(link.getServiceProxy("testProxyId1").getServiceInstance().getSolutionInfo());
- assertEquals("testVnfHostName1", link.getServiceProxy("testProxyId1").getServiceInstance().getVnfs().get(0).getVnfName());
-
- assertEquals("testServiceInstanceId2", link.getServiceProxy("testProxyId2").getServiceInstance().getServiceInstanceId());
- assertNotNull(link.getServiceProxy("testProxyId2").getServiceInstance().getSolutionInfo());
- assertFalse(link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().isEmpty());
- assertEquals("testPrimaryPnfName2", link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(0).getPnfName());
- assertEquals("primary", link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(0).getRole());
- assertEquals("testSecondaryPnfName2", link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(1).getPnfName());
- assertEquals("secondary", link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(1).getRole());
- }
-
- @Test
- public void testProcessSolution_success_1VpnLink_2Solutions(){
- beforeVpnBondingLink("1");
-
- JSONObject asyncResponse = new JSONObject();
- asyncResponse.put("transactionId", "testRequestId").put("requestId", "testRequestId").put("requestState", "completed");
- JSONArray solution1 = new JSONArray();
- solution1.put(new JSONObject().put("serviceResourceId", "testProxyId1").put("solution", new JSONObject()
- .put("identifierType", "serviceInstanceId").put("identifiers", new JSONArray().put("testServiceInstanceId1")))
- .put("assignmentInfo", new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "False"))
- .put(new JSONObject().put("key", "cloudOwner").put("value", "aic")).put(new JSONObject().put("key", "vnfHostName").put("value", "testVnfHostName1"))
- .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli1")).put(new JSONObject().put("key", "aicVersion").put("value", "3"))
- .put(new JSONObject().put("key", "vnfId").put("value", "testVnfId1")).put(new JSONObject().put("key", "cloudRegionId").put("value", "testSloudRegionId1"))));
- solution1.put(new JSONObject().put("serviceResourceId", "testProxyId2").put("solution", new JSONObject()
- .put("identifierType", "serviceInstanceId").put("identifiers", new JSONArray().put("testServiceInstanceId2")))
- .put("assignmentInfo", new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "False"))
- .put(new JSONObject().put("key", "cloudOwner").put("value", "aic")).put(new JSONObject().put("key", "primaryPnfName").put("value", "testPrimaryPnfName2"))
- .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli2")).put(new JSONObject().put("key", "aicVersion").put("value", "3"))
- .put(new JSONObject().put("key", "secondaryPnfName").put("value", "testSecondaryPnfName2")).put(new JSONObject().put("key", "cloudRegionId").put("value", "testSloudRegionId2"))));
-
- JSONArray solution2 = new JSONArray();
- solution2.put(new JSONObject().put("serviceResourceId", "testProxyId1").put("solution", new JSONObject()
- .put("identifierType", "serviceInstanceId").put("identifiers", new JSONArray().put("testServiceInstanceId3")))
- .put("assignmentInfo", new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "False"))
- .put(new JSONObject().put("key", "cloudOwner").put("value", "aic")).put(new JSONObject().put("key", "vnfHostName").put("value", "testVnfHostName3"))
- .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli3")).put(new JSONObject().put("key", "aicVersion").put("value", "3"))
- .put(new JSONObject().put("key", "vnfId").put("value", "testVnfId3")).put(new JSONObject().put("key", "cloudRegionId").put("value", "testSloudRegionId3"))));
- solution2.put(new JSONObject().put("serviceResourceId", "testProxyId2").put("solution", new JSONObject()
- .put("identifierType", "serviceInstanceId").put("identifiers", new JSONArray().put("testServiceInstanceId4")))
- .put("assignmentInfo", new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "False"))
- .put(new JSONObject().put("key", "cloudOwner").put("value", "aic")).put(new JSONObject().put("key", "primaryPnfName").put("value", "testPrimaryPnfName4"))
- .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli4")).put(new JSONObject().put("key", "aicVersion").put("value", "3"))
- .put(new JSONObject().put("key", "secondaryPnfName").put("value", "testSecondaryPnfName4")).put(new JSONObject().put("key", "cloudRegionId").put("value", "testSloudRegionId4"))));
-
- asyncResponse.put("solutions", new JSONObject().put("placementSolutions", new JSONArray().put(solution1).put(solution2)).put("licenseSolutions", new JSONArray()));
-
- sniroHoming.processSolution(execution, asyncResponse.toString());
-
- ServiceInstance si = execution.getGeneralBuildingBlock().getCustomer().getServiceSubscription().getServiceInstances().get(0);
-
- assertFalse(si.getVpnBondingLinks().isEmpty());
- VpnBondingLink link = si.getVpnBondingLinks().get(0);
- VpnBondingLink link2 = si.getVpnBondingLinks().get(1);
- assertNotNull(link);
- assertFalse(link.getServiceProxies().isEmpty());
-
- assertEquals("testServiceInstanceId1", link.getServiceProxy("testProxyId1").getServiceInstance().getServiceInstanceId());
- assertNotNull(link.getServiceProxy("testProxyId1").getServiceInstance().getSolutionInfo());
- assertEquals("testVnfHostName1", link.getServiceProxy("testProxyId1").getServiceInstance().getVnfs().get(0).getVnfName());
-
- assertEquals("testServiceInstanceId2", link.getServiceProxy("testProxyId2").getServiceInstance().getServiceInstanceId());
- assertNotNull(link.getServiceProxy("testProxyId2").getServiceInstance().getSolutionInfo());
- assertFalse(link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().isEmpty());
- assertEquals("testPrimaryPnfName2", link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(0).getPnfName());
- assertEquals("primary", link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(0).getRole());
- assertEquals("testSecondaryPnfName2", link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(1).getPnfName());
- assertEquals("secondary", link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(1).getRole());
-
- assertNotNull(link2);
- assertFalse(link2.getServiceProxies().isEmpty());
-
- assertEquals("testServiceInstanceId3", link2.getServiceProxy("testProxyId1").getServiceInstance().getServiceInstanceId());
- assertNotNull(link2.getServiceProxy("testProxyId1").getServiceInstance().getSolutionInfo());
- assertEquals("testVnfHostName3", link2.getServiceProxy("testProxyId1").getServiceInstance().getVnfs().get(0).getVnfName());
-
- assertEquals("testServiceInstanceId4", link2.getServiceProxy("testProxyId2").getServiceInstance().getServiceInstanceId());
- assertNotNull(link2.getServiceProxy("testProxyId2").getServiceInstance().getSolutionInfo());
- assertFalse(link2.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().isEmpty());
- assertEquals("testPrimaryPnfName4", link2.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(0).getPnfName());
- assertEquals("primary", link2.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(0).getRole());
- assertEquals("testSecondaryPnfName4", link2.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(1).getPnfName());
- assertEquals("secondary", link2.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(1).getRole());
-
- }
-
- @Test
- public void testProcessSolution_success_3VpnLink_2Solutions(){
- //TODO
- }
-
- @Test
- public void testProcessSolution_success_3Allotteds_1Solution(){
- beforeAllottedResource();
-
- JSONObject asyncResponse = new JSONObject();
- asyncResponse.put("transactionId", "testRequestId").put("requestId", "testRequestId").put("requestState", "completed");
- JSONArray solution1 = new JSONArray();
- solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId1").put("solution", new JSONObject()
- .put("identifierType", "serviceInstanceId").put("identifiers", new JSONArray().put("testServiceInstanceId1")))
- .put("assignmentInfo", new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "True"))
- .put(new JSONObject().put("key", "cloudOwner").put("value", "aic")).put(new JSONObject().put("key", "vnfHostName").put("value", "testVnfHostName1"))
- .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli1")).put(new JSONObject().put("key", "aicVersion").put("value", "3"))
- .put(new JSONObject().put("key", "vnfId").put("value", "testVnfId1")).put(new JSONObject().put("key", "cloudRegionId").put("value", "testCloudRegionId1"))));
- solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId2").put("solution", new JSONObject()
- .put("identifierType", "serviceInstanceId").put("identifiers", new JSONArray().put("testServiceInstanceId2")))
- .put("assignmentInfo", new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "True"))
- .put(new JSONObject().put("key", "cloudOwner").put("value", "aic")).put(new JSONObject().put("key", "vnfHostName").put("value", "testVnfHostName2"))
- .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli2")).put(new JSONObject().put("key", "aicVersion").put("value", "3"))
- .put(new JSONObject().put("key", "vnfId").put("value", "testVnfId1")).put(new JSONObject().put("key", "cloudRegionId").put("value", "testCloudRegionId2"))));
- solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId3").put("solution", new JSONObject()
- .put("identifierType", "cloudRegionId").put("identifiers", new JSONArray().put("testCloudRegionId3")))
- .put("assignmentInfo", new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "True"))
- .put(new JSONObject().put("key", "cloudOwner").put("value", "aic"))
- .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli2")).put(new JSONObject().put("key", "aicVersion").put("value", "3"))));
-
- asyncResponse.put("solutions", new JSONObject().put("placementSolutions", new JSONArray().put(solution1)).put("licenseSolutions", new JSONArray()));
-
- sniroHoming.processSolution(execution, asyncResponse.toString());
-
- ServiceInstance si = execution.getGeneralBuildingBlock().getCustomer().getServiceSubscription().getServiceInstances().get(0);
-
- assertFalse(si.getAllottedResources().isEmpty());
- AllottedResource ar = si.getAllottedResources().get(0);
- assertNotNull(ar);
- assertEquals("testServiceInstanceId1", ar.getParentServiceInstance().getServiceInstanceId());
- assertNotNull(ar.getParentServiceInstance().getSolutionInfo());
- assertEquals("testVnfHostName1", ar.getParentServiceInstance().getVnfs().get(0).getVnfName());
-
- AllottedResource ar2 = si.getAllottedResources().get(1);
- assertNotNull(ar2);
- assertEquals("testServiceInstanceId2", ar2.getParentServiceInstance().getServiceInstanceId());
- assertNotNull(ar2.getParentServiceInstance().getSolutionInfo());
- assertEquals("testVnfHostName2", ar2.getParentServiceInstance().getVnfs().get(0).getVnfName());
-
- AllottedResource ar3 = si.getAllottedResources().get(2);
- assertNotNull(ar3);
- assertNotNull(ar3.getParentServiceInstance().getSolutionInfo());
- assertEquals("testCloudRegionId3", ar3.getParentServiceInstance().getSolutionInfo().getTargetedCloudRegion().getLcpCloudRegionId());
- }
-
- @Test
- public void testProcessSolution_success_3Allotteds1Vnf_1Solution(){
- beforeVnf();
- beforeAllottedResource();
-
- JSONObject asyncResponse = new JSONObject();
- asyncResponse.put("transactionId", "testRequestId").put("requestId", "testRequestId").put("requestState", "completed");
- JSONArray solution1 = new JSONArray();
- JSONArray licenseSolution = new JSONArray();
- solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId1").put("solution", new JSONObject()
- .put("identifierType", "serviceInstanceId").put("identifiers", new JSONArray().put("testServiceInstanceId1")))
- .put("assignmentInfo", new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "True"))
- .put(new JSONObject().put("key", "cloudOwner").put("value", "aic")).put(new JSONObject().put("key", "vnfHostName").put("value", "testVnfHostName1"))
- .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli1")).put(new JSONObject().put("key", "aicVersion").put("value", "3"))
- .put(new JSONObject().put("key", "vnfId").put("value", "testVnfId1")).put(new JSONObject().put("key", "cloudRegionId").put("value", "testCloudRegionId1"))));
- solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId2").put("solution", new JSONObject()
- .put("identifierType", "serviceInstanceId").put("identifiers", new JSONArray().put("testServiceInstanceId2")))
- .put("assignmentInfo", new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "True"))
- .put(new JSONObject().put("key", "cloudOwner").put("value", "aic")).put(new JSONObject().put("key", "vnfHostName").put("value", "testVnfHostName2"))
- .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli2")).put(new JSONObject().put("key", "aicVersion").put("value", "3"))
- .put(new JSONObject().put("key", "vnfId").put("value", "testVnfId1")).put(new JSONObject().put("key", "cloudRegionId").put("value", "testCloudRegionId2"))));
- solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId3").put("solution", new JSONObject()
- .put("identifierType", "cloudRegionId").put("identifiers", new JSONArray().put("testCloudRegionId3")))
- .put("assignmentInfo", new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "True"))
- .put(new JSONObject().put("key", "cloudOwner").put("value", "aic")).put(new JSONObject().put("key", "aicClli").put("value", "testAicClli2"))
- .put(new JSONObject().put("key", "aicVersion").put("value", "3"))));
-
- licenseSolution.put(
- new JSONObject().put("serviceResourceId", "testVnfId1").put("entitlementPoolUUID", new JSONArray().put("f1d563e8-e714-4393-8f99-cc480144a05e").put("j1d563e8-e714-4393-8f99-cc480144a05e"))
- .put("licenseKeyGroupUUID", new JSONArray().put("s1d563e8-e714-4393-8f99-cc480144a05e").put("b1d563e8-e714-4393-8f99-cc480144a05e")));
-
- asyncResponse.put("solutions", new JSONObject().put("placementSolutions", new JSONArray().put(solution1)).put("licenseSolutions", licenseSolution));
-
- sniroHoming.processSolution(execution, asyncResponse.toString());
-
- ServiceInstance si = execution.getGeneralBuildingBlock().getCustomer().getServiceSubscription().getServiceInstances().get(0);
-
- assertFalse(si.getAllottedResources().isEmpty());
- AllottedResource ar = si.getAllottedResources().get(0);
- assertNotNull(ar);
- assertEquals("testServiceInstanceId1", ar.getParentServiceInstance().getServiceInstanceId());
- assertNotNull(ar.getParentServiceInstance().getSolutionInfo());
- assertEquals("testVnfHostName1", ar.getParentServiceInstance().getVnfs().get(0).getVnfName());
-
- AllottedResource ar2 = si.getAllottedResources().get(1);
- assertNotNull(ar2);
- assertEquals("testServiceInstanceId2", ar2.getParentServiceInstance().getServiceInstanceId());
- assertNotNull(ar2.getParentServiceInstance().getSolutionInfo());
- assertEquals("testVnfHostName2", ar2.getParentServiceInstance().getVnfs().get(0).getVnfName());
-
- AllottedResource ar3 = si.getAllottedResources().get(2);
- assertNotNull(ar3);
- assertNotNull(ar3.getParentServiceInstance().getSolutionInfo());
- assertEquals("testCloudRegionId3", ar3.getParentServiceInstance().getSolutionInfo().getTargetedCloudRegion().getLcpCloudRegionId());
-
- GenericVnf vnf = si.getVnfs().get(0);
- assertNotNull(vnf);
- assertNotNull(vnf.getLicense());
- assertEquals(2, vnf.getLicense().getEntitlementPoolUuids().size());
- assertEquals("s1d563e8-e714-4393-8f99-cc480144a05e", vnf.getLicense().getLicenseKeyGroupUuids().get(0));
-
- }
-
- @Test
- public void testProcessSolution_success_1Vnf_1Solution(){
- beforeVnf();
-
- JSONObject asyncResponse = new JSONObject();
- asyncResponse.put("transactionId", "testRequestId").put("requestId", "testRequestId").put("requestState", "completed");
- JSONArray licenseSolution = new JSONArray();
-
- licenseSolution.put(
- new JSONObject().put("serviceResourceId", "testVnfId1").put("entitlementPoolUUID", new JSONArray().put("f1d563e8-e714-4393-8f99-cc480144a05e").put("j1d563e8-e714-4393-8f99-cc480144a05e"))
- .put("licenseKeyGroupUUID", new JSONArray().put("s1d563e8-e714-4393-8f99-cc480144a05e").put("b1d563e8-e714-4393-8f99-cc480144a05e")));
-
- asyncResponse.put("solutions", new JSONObject().put("licenseSolutions", licenseSolution));
-
- sniroHoming.processSolution(execution, asyncResponse.toString());
-
- ServiceInstance si = execution.getGeneralBuildingBlock().getCustomer().getServiceSubscription().getServiceInstances().get(0);
-
- GenericVnf vnf = si.getVnfs().get(0);
- assertNotNull(vnf);
- assertNotNull(vnf.getLicense());
- assertEquals(2, vnf.getLicense().getEntitlementPoolUuids().size());
- assertEquals(2, vnf.getLicense().getLicenseKeyGroupUuids().size());
- assertEquals("f1d563e8-e714-4393-8f99-cc480144a05e", vnf.getLicense().getEntitlementPoolUuids().get(0));
- assertEquals("s1d563e8-e714-4393-8f99-cc480144a05e", vnf.getLicense().getLicenseKeyGroupUuids().get(0));
-
-
- }
-
- @Test(expected = BpmnError.class)
- public void testCallSniro_error_0Resources() throws BadResponseException, JsonProcessingException{
-
- sniroHoming.callSniro(execution);
-
- verify(sniroClient, times(0)).postDemands(isA(SniroManagerRequest.class));
- }
-
- @Test(expected = BpmnError.class)
- public void testCallSniro_error_badResponse() throws BadResponseException, JsonProcessingException{
- beforeAllottedResource();
-
- mockResponse = "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"\", \"requestStatus\": \"failed\"}";
- wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2"))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBody(mockResponse)));
-
- sniroHoming.callSniro(execution);
+ public void testProcessSolution_success_1VpnLink_1Solution() {
+ beforeVpnBondingLink("1");
+
+ JSONObject asyncResponse = new JSONObject();
+ asyncResponse.put("transactionId", "testRequestId").put("requestId", "testRequestId").put("requestState",
+ "completed");
+ JSONArray solution1 = new JSONArray();
+ solution1.put(new JSONObject().put("serviceResourceId", "testProxyId1")
+ .put("solution",
+ new JSONObject().put("identifierType", "serviceInstanceId").put("identifiers",
+ new JSONArray().put("testServiceInstanceId1")))
+ .put("assignmentInfo",
+ new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "False"))
+ .put(new JSONObject().put("key", "cloudOwner").put("value", "aic"))
+ .put(new JSONObject().put("key", "vnfHostName").put("value", "testVnfHostName1"))
+ .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli1"))
+ .put(new JSONObject().put("key", "aicVersion").put("value", "3"))
+ .put(new JSONObject().put("key", "vnfId").put("value", "testVnfId1"))
+ .put(new JSONObject().put("key", "cloudRegionId").put("value", "testSloudRegionId1"))));
+ solution1.put(new JSONObject().put("serviceResourceId", "testProxyId2")
+ .put("solution",
+ new JSONObject().put("identifierType", "serviceInstanceId").put("identifiers",
+ new JSONArray().put("testServiceInstanceId2")))
+ .put("assignmentInfo",
+ new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "False"))
+ .put(new JSONObject().put("key", "cloudOwner").put("value", "aic"))
+ .put(new JSONObject().put("key", "primaryPnfName").put("value", "testPrimaryPnfName2"))
+ .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli2"))
+ .put(new JSONObject().put("key", "aicVersion").put("value", "3"))
+ .put(new JSONObject().put("key", "secondaryPnfName").put("value",
+ "testSecondaryPnfName2"))
+ .put(new JSONObject().put("key", "cloudRegionId").put("value", "testSloudRegionId2"))));
+
+ asyncResponse.put("solutions", new JSONObject().put("placementSolutions", new JSONArray().put(solution1))
+ .put("licenseSolutions", new JSONArray()));
+
+ sniroHoming.processSolution(execution, asyncResponse.toString());
+
+ ServiceInstance si =
+ execution.getGeneralBuildingBlock().getCustomer().getServiceSubscription().getServiceInstances().get(0);
+
+ assertFalse(si.getVpnBondingLinks().isEmpty());
+ VpnBondingLink link = si.getVpnBondingLinks().get(0);
+ assertNotNull(link);
+ assertFalse(link.getServiceProxies().isEmpty());
+
+ assertEquals("testServiceInstanceId1",
+ link.getServiceProxy("testProxyId1").getServiceInstance().getServiceInstanceId());
+ assertNotNull(link.getServiceProxy("testProxyId1").getServiceInstance().getSolutionInfo());
+ assertEquals("testVnfHostName1",
+ link.getServiceProxy("testProxyId1").getServiceInstance().getVnfs().get(0).getVnfName());
+
+ assertEquals("testServiceInstanceId2",
+ link.getServiceProxy("testProxyId2").getServiceInstance().getServiceInstanceId());
+ assertNotNull(link.getServiceProxy("testProxyId2").getServiceInstance().getSolutionInfo());
+ assertFalse(link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().isEmpty());
+ assertEquals("testPrimaryPnfName2",
+ link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(0).getPnfName());
+ assertEquals("primary", link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(0).getRole());
+ assertEquals("testSecondaryPnfName2",
+ link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(1).getPnfName());
+ assertEquals("secondary", link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(1).getRole());
+ }
+
+ @Test
+ public void testProcessSolution_success_1VpnLink_2Solutions() {
+ beforeVpnBondingLink("1");
+
+ JSONObject asyncResponse = new JSONObject();
+ asyncResponse.put("transactionId", "testRequestId").put("requestId", "testRequestId").put("requestState",
+ "completed");
+ JSONArray solution1 = new JSONArray();
+ solution1.put(new JSONObject().put("serviceResourceId", "testProxyId1")
+ .put("solution",
+ new JSONObject().put("identifierType", "serviceInstanceId").put("identifiers",
+ new JSONArray().put("testServiceInstanceId1")))
+ .put("assignmentInfo",
+ new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "False"))
+ .put(new JSONObject().put("key", "cloudOwner").put("value", "aic"))
+ .put(new JSONObject().put("key", "vnfHostName").put("value", "testVnfHostName1"))
+ .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli1"))
+ .put(new JSONObject().put("key", "aicVersion").put("value", "3"))
+ .put(new JSONObject().put("key", "vnfId").put("value", "testVnfId1"))
+ .put(new JSONObject().put("key", "cloudRegionId").put("value", "testSloudRegionId1"))));
+ solution1.put(new JSONObject().put("serviceResourceId", "testProxyId2")
+ .put("solution",
+ new JSONObject().put("identifierType", "serviceInstanceId").put("identifiers",
+ new JSONArray().put("testServiceInstanceId2")))
+ .put("assignmentInfo",
+ new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "False"))
+ .put(new JSONObject().put("key", "cloudOwner").put("value", "aic"))
+ .put(new JSONObject().put("key", "primaryPnfName").put("value", "testPrimaryPnfName2"))
+ .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli2"))
+ .put(new JSONObject().put("key", "aicVersion").put("value", "3"))
+ .put(new JSONObject().put("key", "secondaryPnfName").put("value",
+ "testSecondaryPnfName2"))
+ .put(new JSONObject().put("key", "cloudRegionId").put("value", "testSloudRegionId2"))));
+
+ JSONArray solution2 = new JSONArray();
+ solution2.put(new JSONObject().put("serviceResourceId", "testProxyId1")
+ .put("solution",
+ new JSONObject().put("identifierType", "serviceInstanceId").put("identifiers",
+ new JSONArray().put("testServiceInstanceId3")))
+ .put("assignmentInfo",
+ new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "False"))
+ .put(new JSONObject().put("key", "cloudOwner").put("value", "aic"))
+ .put(new JSONObject().put("key", "vnfHostName").put("value", "testVnfHostName3"))
+ .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli3"))
+ .put(new JSONObject().put("key", "aicVersion").put("value", "3"))
+ .put(new JSONObject().put("key", "vnfId").put("value", "testVnfId3"))
+ .put(new JSONObject().put("key", "cloudRegionId").put("value", "testSloudRegionId3"))));
+ solution2.put(new JSONObject().put("serviceResourceId", "testProxyId2")
+ .put("solution",
+ new JSONObject().put("identifierType", "serviceInstanceId").put("identifiers",
+ new JSONArray().put("testServiceInstanceId4")))
+ .put("assignmentInfo",
+ new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "False"))
+ .put(new JSONObject().put("key", "cloudOwner").put("value", "aic"))
+ .put(new JSONObject().put("key", "primaryPnfName").put("value", "testPrimaryPnfName4"))
+ .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli4"))
+ .put(new JSONObject().put("key", "aicVersion").put("value", "3"))
+ .put(new JSONObject().put("key", "secondaryPnfName").put("value",
+ "testSecondaryPnfName4"))
+ .put(new JSONObject().put("key", "cloudRegionId").put("value", "testSloudRegionId4"))));
+
+ asyncResponse.put("solutions",
+ new JSONObject().put("placementSolutions", new JSONArray().put(solution1).put(solution2))
+ .put("licenseSolutions", new JSONArray()));
+
+ sniroHoming.processSolution(execution, asyncResponse.toString());
+
+ ServiceInstance si =
+ execution.getGeneralBuildingBlock().getCustomer().getServiceSubscription().getServiceInstances().get(0);
+
+ assertFalse(si.getVpnBondingLinks().isEmpty());
+ VpnBondingLink link = si.getVpnBondingLinks().get(0);
+ VpnBondingLink link2 = si.getVpnBondingLinks().get(1);
+ assertNotNull(link);
+ assertFalse(link.getServiceProxies().isEmpty());
+
+ assertEquals("testServiceInstanceId1",
+ link.getServiceProxy("testProxyId1").getServiceInstance().getServiceInstanceId());
+ assertNotNull(link.getServiceProxy("testProxyId1").getServiceInstance().getSolutionInfo());
+ assertEquals("testVnfHostName1",
+ link.getServiceProxy("testProxyId1").getServiceInstance().getVnfs().get(0).getVnfName());
+
+ assertEquals("testServiceInstanceId2",
+ link.getServiceProxy("testProxyId2").getServiceInstance().getServiceInstanceId());
+ assertNotNull(link.getServiceProxy("testProxyId2").getServiceInstance().getSolutionInfo());
+ assertFalse(link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().isEmpty());
+ assertEquals("testPrimaryPnfName2",
+ link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(0).getPnfName());
+ assertEquals("primary", link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(0).getRole());
+ assertEquals("testSecondaryPnfName2",
+ link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(1).getPnfName());
+ assertEquals("secondary", link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(1).getRole());
+
+ assertNotNull(link2);
+ assertFalse(link2.getServiceProxies().isEmpty());
+
+ assertEquals("testServiceInstanceId3",
+ link2.getServiceProxy("testProxyId1").getServiceInstance().getServiceInstanceId());
+ assertNotNull(link2.getServiceProxy("testProxyId1").getServiceInstance().getSolutionInfo());
+ assertEquals("testVnfHostName3",
+ link2.getServiceProxy("testProxyId1").getServiceInstance().getVnfs().get(0).getVnfName());
+
+ assertEquals("testServiceInstanceId4",
+ link2.getServiceProxy("testProxyId2").getServiceInstance().getServiceInstanceId());
+ assertNotNull(link2.getServiceProxy("testProxyId2").getServiceInstance().getSolutionInfo());
+ assertFalse(link2.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().isEmpty());
+ assertEquals("testPrimaryPnfName4",
+ link2.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(0).getPnfName());
+ assertEquals("primary", link2.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(0).getRole());
+ assertEquals("testSecondaryPnfName4",
+ link2.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(1).getPnfName());
+ assertEquals("secondary",
+ link2.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(1).getRole());
+
+ }
+
+ @Test
+ public void testProcessSolution_success_3VpnLink_2Solutions() {
+ // TODO
+ }
+
+ @Test
+ public void testProcessSolution_success_3Allotteds_1Solution() {
+ beforeAllottedResource();
+
+ JSONObject asyncResponse = new JSONObject();
+ asyncResponse.put("transactionId", "testRequestId").put("requestId", "testRequestId").put("requestState",
+ "completed");
+ JSONArray solution1 = new JSONArray();
+ solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId1")
+ .put("solution",
+ new JSONObject().put("identifierType", "serviceInstanceId").put("identifiers",
+ new JSONArray().put("testServiceInstanceId1")))
+ .put("assignmentInfo",
+ new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "True"))
+ .put(new JSONObject().put("key", "cloudOwner").put("value", "aic"))
+ .put(new JSONObject().put("key", "vnfHostName").put("value", "testVnfHostName1"))
+ .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli1"))
+ .put(new JSONObject().put("key", "aicVersion").put("value", "3"))
+ .put(new JSONObject().put("key", "vnfId").put("value", "testVnfId1"))
+ .put(new JSONObject().put("key", "cloudRegionId").put("value", "testCloudRegionId1"))));
+ solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId2")
+ .put("solution",
+ new JSONObject().put("identifierType", "serviceInstanceId").put("identifiers",
+ new JSONArray().put("testServiceInstanceId2")))
+ .put("assignmentInfo",
+ new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "True"))
+ .put(new JSONObject().put("key", "cloudOwner").put("value", "aic"))
+ .put(new JSONObject().put("key", "vnfHostName").put("value", "testVnfHostName2"))
+ .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli2"))
+ .put(new JSONObject().put("key", "aicVersion").put("value", "3"))
+ .put(new JSONObject().put("key", "vnfId").put("value", "testVnfId1"))
+ .put(new JSONObject().put("key", "cloudRegionId").put("value", "testCloudRegionId2"))));
+ solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId3")
+ .put("solution",
+ new JSONObject().put("identifierType", "cloudRegionId").put("identifiers",
+ new JSONArray().put("testCloudRegionId3")))
+ .put("assignmentInfo",
+ new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "True"))
+ .put(new JSONObject().put("key", "cloudOwner").put("value", "aic"))
+ .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli2"))
+ .put(new JSONObject().put("key", "aicVersion").put("value", "3"))));
+
+ asyncResponse.put("solutions", new JSONObject().put("placementSolutions", new JSONArray().put(solution1))
+ .put("licenseSolutions", new JSONArray()));
+
+ sniroHoming.processSolution(execution, asyncResponse.toString());
+
+ ServiceInstance si =
+ execution.getGeneralBuildingBlock().getCustomer().getServiceSubscription().getServiceInstances().get(0);
+
+ assertFalse(si.getAllottedResources().isEmpty());
+ AllottedResource ar = si.getAllottedResources().get(0);
+ assertNotNull(ar);
+ assertEquals("testServiceInstanceId1", ar.getParentServiceInstance().getServiceInstanceId());
+ assertNotNull(ar.getParentServiceInstance().getSolutionInfo());
+ assertEquals("testVnfHostName1", ar.getParentServiceInstance().getVnfs().get(0).getVnfName());
+
+ AllottedResource ar2 = si.getAllottedResources().get(1);
+ assertNotNull(ar2);
+ assertEquals("testServiceInstanceId2", ar2.getParentServiceInstance().getServiceInstanceId());
+ assertNotNull(ar2.getParentServiceInstance().getSolutionInfo());
+ assertEquals("testVnfHostName2", ar2.getParentServiceInstance().getVnfs().get(0).getVnfName());
+
+ AllottedResource ar3 = si.getAllottedResources().get(2);
+ assertNotNull(ar3);
+ assertNotNull(ar3.getParentServiceInstance().getSolutionInfo());
+ assertEquals("testCloudRegionId3",
+ ar3.getParentServiceInstance().getSolutionInfo().getTargetedCloudRegion().getLcpCloudRegionId());
+ }
+
+ @Test
+ public void testProcessSolution_success_3Allotteds1Vnf_1Solution() {
+ beforeVnf();
+ beforeAllottedResource();
+
+ JSONObject asyncResponse = new JSONObject();
+ asyncResponse.put("transactionId", "testRequestId").put("requestId", "testRequestId").put("requestState",
+ "completed");
+ JSONArray solution1 = new JSONArray();
+ JSONArray licenseSolution = new JSONArray();
+ solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId1")
+ .put("solution",
+ new JSONObject().put("identifierType", "serviceInstanceId").put("identifiers",
+ new JSONArray().put("testServiceInstanceId1")))
+ .put("assignmentInfo",
+ new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "True"))
+ .put(new JSONObject().put("key", "cloudOwner").put("value", "aic"))
+ .put(new JSONObject().put("key", "vnfHostName").put("value", "testVnfHostName1"))
+ .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli1"))
+ .put(new JSONObject().put("key", "aicVersion").put("value", "3"))
+ .put(new JSONObject().put("key", "vnfId").put("value", "testVnfId1"))
+ .put(new JSONObject().put("key", "cloudRegionId").put("value", "testCloudRegionId1"))));
+ solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId2")
+ .put("solution",
+ new JSONObject().put("identifierType", "serviceInstanceId").put("identifiers",
+ new JSONArray().put("testServiceInstanceId2")))
+ .put("assignmentInfo",
+ new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "True"))
+ .put(new JSONObject().put("key", "cloudOwner").put("value", "aic"))
+ .put(new JSONObject().put("key", "vnfHostName").put("value", "testVnfHostName2"))
+ .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli2"))
+ .put(new JSONObject().put("key", "aicVersion").put("value", "3"))
+ .put(new JSONObject().put("key", "vnfId").put("value", "testVnfId1"))
+ .put(new JSONObject().put("key", "cloudRegionId").put("value", "testCloudRegionId2"))));
+ solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId3")
+ .put("solution",
+ new JSONObject().put("identifierType", "cloudRegionId").put("identifiers",
+ new JSONArray().put("testCloudRegionId3")))
+ .put("assignmentInfo",
+ new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "True"))
+ .put(new JSONObject().put("key", "cloudOwner").put("value", "aic"))
+ .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli2"))
+ .put(new JSONObject().put("key", "aicVersion").put("value", "3"))));
+
+ licenseSolution.put(new JSONObject().put("serviceResourceId", "testVnfId1")
+ .put("entitlementPoolUUID",
+ new JSONArray().put("f1d563e8-e714-4393-8f99-cc480144a05e")
+ .put("j1d563e8-e714-4393-8f99-cc480144a05e"))
+ .put("licenseKeyGroupUUID", new JSONArray().put("s1d563e8-e714-4393-8f99-cc480144a05e")
+ .put("b1d563e8-e714-4393-8f99-cc480144a05e")));
+
+ asyncResponse.put("solutions", new JSONObject().put("placementSolutions", new JSONArray().put(solution1))
+ .put("licenseSolutions", licenseSolution));
+
+ sniroHoming.processSolution(execution, asyncResponse.toString());
+
+ ServiceInstance si =
+ execution.getGeneralBuildingBlock().getCustomer().getServiceSubscription().getServiceInstances().get(0);
+
+ assertFalse(si.getAllottedResources().isEmpty());
+ AllottedResource ar = si.getAllottedResources().get(0);
+ assertNotNull(ar);
+ assertEquals("testServiceInstanceId1", ar.getParentServiceInstance().getServiceInstanceId());
+ assertNotNull(ar.getParentServiceInstance().getSolutionInfo());
+ assertEquals("testVnfHostName1", ar.getParentServiceInstance().getVnfs().get(0).getVnfName());
+
+ AllottedResource ar2 = si.getAllottedResources().get(1);
+ assertNotNull(ar2);
+ assertEquals("testServiceInstanceId2", ar2.getParentServiceInstance().getServiceInstanceId());
+ assertNotNull(ar2.getParentServiceInstance().getSolutionInfo());
+ assertEquals("testVnfHostName2", ar2.getParentServiceInstance().getVnfs().get(0).getVnfName());
+
+ AllottedResource ar3 = si.getAllottedResources().get(2);
+ assertNotNull(ar3);
+ assertNotNull(ar3.getParentServiceInstance().getSolutionInfo());
+ assertEquals("testCloudRegionId3",
+ ar3.getParentServiceInstance().getSolutionInfo().getTargetedCloudRegion().getLcpCloudRegionId());
+
+ GenericVnf vnf = si.getVnfs().get(0);
+ assertNotNull(vnf);
+ assertNotNull(vnf.getLicense());
+ assertEquals(2, vnf.getLicense().getEntitlementPoolUuids().size());
+ assertEquals("s1d563e8-e714-4393-8f99-cc480144a05e", vnf.getLicense().getLicenseKeyGroupUuids().get(0));
+
+ }
+
+ @Test
+ public void testProcessSolution_success_1Vnf_1Solution() {
+ beforeVnf();
+
+ JSONObject asyncResponse = new JSONObject();
+ asyncResponse.put("transactionId", "testRequestId").put("requestId", "testRequestId").put("requestState",
+ "completed");
+ JSONArray licenseSolution = new JSONArray();
+
+ licenseSolution.put(new JSONObject().put("serviceResourceId", "testVnfId1")
+ .put("entitlementPoolUUID",
+ new JSONArray().put("f1d563e8-e714-4393-8f99-cc480144a05e")
+ .put("j1d563e8-e714-4393-8f99-cc480144a05e"))
+ .put("licenseKeyGroupUUID", new JSONArray().put("s1d563e8-e714-4393-8f99-cc480144a05e")
+ .put("b1d563e8-e714-4393-8f99-cc480144a05e")));
+
+ asyncResponse.put("solutions", new JSONObject().put("licenseSolutions", licenseSolution));
+
+ sniroHoming.processSolution(execution, asyncResponse.toString());
+
+ ServiceInstance si =
+ execution.getGeneralBuildingBlock().getCustomer().getServiceSubscription().getServiceInstances().get(0);
+
+ GenericVnf vnf = si.getVnfs().get(0);
+ assertNotNull(vnf);
+ assertNotNull(vnf.getLicense());
+ assertEquals(2, vnf.getLicense().getEntitlementPoolUuids().size());
+ assertEquals(2, vnf.getLicense().getLicenseKeyGroupUuids().size());
+ assertEquals("f1d563e8-e714-4393-8f99-cc480144a05e", vnf.getLicense().getEntitlementPoolUuids().get(0));
+ assertEquals("s1d563e8-e714-4393-8f99-cc480144a05e", vnf.getLicense().getLicenseKeyGroupUuids().get(0));
+
+
+ }
+
+ @Test(expected = BpmnError.class)
+ public void testCallSniro_error_0Resources() throws BadResponseException, JsonProcessingException {
+
+ sniroHoming.callSniro(execution);
+
+ verify(sniroClient, times(0)).postDemands(isA(SniroManagerRequest.class));
+ }
+
+ @Test(expected = BpmnError.class)
+ public void testCallSniro_error_badResponse() throws BadResponseException, JsonProcessingException {
+ beforeAllottedResource();
+
+ mockResponse =
+ "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"\", \"requestStatus\": \"failed\"}";
+ wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
+
+ sniroHoming.callSniro(execution);
- verify(sniroClient, times(1)).postDemands(isA(SniroManagerRequest.class));
- }
+ verify(sniroClient, times(1)).postDemands(isA(SniroManagerRequest.class));
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBBTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBBTest.java
index ecdf11bd05..bacc57758b 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBBTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBBTest.java
@@ -27,11 +27,9 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
-
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Optional;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
@@ -47,71 +45,77 @@ import org.onap.so.client.aai.entities.AAIResultWrapper;
import org.springframework.beans.factory.annotation.Autowired;
public class UnassignNetworkBBTest extends BaseTaskTest {
-
- @Mock
- private NetworkBBUtils networkBBUtils;
- @InjectMocks
- private UnassignNetworkBB unassignNetworkBB = new UnassignNetworkBB();
-
- private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/Network/";
- private L3Network network;
-
- @Before
- public void setup(){
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
- }
-
- @Test
- public void checkRelationshipRelatedToTrueTest() throws Exception {
- expectedException.expect(BpmnError.class);
- network = setL3Network();
- network.setNetworkId("testNetworkId1");
- final String aaiResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "unassignNetworkBB_queryAAIResponse_.json")));
- AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(aaiResponse);
- Optional<org.onap.aai.domain.yang.L3Network> l3network = aaiResultWrapper.asBean(org.onap.aai.domain.yang.L3Network.class);
-
- doReturn(network).when(extractPojosForBB).extractByKey(execution, ResourceKey.NETWORK_ID);
- doReturn(aaiResultWrapper).when(aaiNetworkResources).queryNetworkWrapperById(network);
-
- doReturn(true).when(networkBBUtils).isRelationshipRelatedToExists(any(Optional.class), eq("vf-module"));
-
- unassignNetworkBB.checkRelationshipRelatedTo(execution, "vf-module");
- assertThat(execution.getVariable("ErrorUnassignNetworkBB"), notNullValue());
- }
-
- @Test
- public void getCloudSdncRegion25Test() throws Exception {
- CloudRegion cloudRegion = setCloudRegion();
- cloudRegion.setCloudRegionVersion("2.5");
- doReturn("AAIAIC25").when(networkBBUtils).getCloudRegion(execution, SourceSystem.SDNC);
- unassignNetworkBB.getCloudSdncRegion(execution);
- assertEquals("AAIAIC25", execution.getVariable("cloudRegionSdnc"));
- }
-
- @Test
- public void getCloudSdncRegion30Test() throws Exception {
- CloudRegion cloudRegion = setCloudRegion();
- cloudRegion.setCloudRegionVersion("3.0");
- gBBInput.setCloudRegion(cloudRegion);
- doReturn(cloudRegion.getLcpCloudRegionId()).when(networkBBUtils).getCloudRegion(execution, SourceSystem.SDNC);
- unassignNetworkBB.getCloudSdncRegion(execution);
- assertEquals(cloudRegion.getLcpCloudRegionId(), execution.getVariable("cloudRegionSdnc"));
- }
-
- @Test
- public void errorEncounteredTest_rollback() throws Exception {
- expectedException.expect(BpmnError.class);
- execution.setVariable("ErrorUnassignNetworkBB", "Relationship's RelatedTo still exists in AAI, remove the relationship vf-module first.");
- execution.setVariable("isRollbackNeeded", true);
- unassignNetworkBB.errorEncountered(execution);
- }
-
- @Test
- public void errorEncounteredTest_noRollback() throws Exception {
- expectedException.expect(BpmnError.class);
- execution.setVariable("ErrorUnassignNetworkBB", "Relationship's RelatedTo still exists in AAI, remove the relationship vf-module first.");
- unassignNetworkBB.errorEncountered(execution);
- }
+ @Mock
+ private NetworkBBUtils networkBBUtils;
+
+ @InjectMocks
+ private UnassignNetworkBB unassignNetworkBB = new UnassignNetworkBB();
+
+ private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/Network/";
+ private L3Network network;
+
+ @Before
+ public void setup() {
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
+ }
+
+ @Test
+ public void checkRelationshipRelatedToTrueTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ network = setL3Network();
+ network.setNetworkId("testNetworkId1");
+ final String aaiResponse = new String(
+ Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "unassignNetworkBB_queryAAIResponse_.json")));
+ AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(aaiResponse);
+ Optional<org.onap.aai.domain.yang.L3Network> l3network =
+ aaiResultWrapper.asBean(org.onap.aai.domain.yang.L3Network.class);
+
+ doReturn(network).when(extractPojosForBB).extractByKey(execution, ResourceKey.NETWORK_ID);
+ doReturn(aaiResultWrapper).when(aaiNetworkResources).queryNetworkWrapperById(network);
+
+ doReturn(true).when(networkBBUtils).isRelationshipRelatedToExists(any(Optional.class), eq("vf-module"));
+
+ unassignNetworkBB.checkRelationshipRelatedTo(execution, "vf-module");
+ assertThat(execution.getVariable("ErrorUnassignNetworkBB"), notNullValue());
+ }
+
+ @Test
+ public void getCloudSdncRegion25Test() throws Exception {
+ CloudRegion cloudRegion = setCloudRegion();
+ cloudRegion.setCloudRegionVersion("2.5");
+ doReturn("AAIAIC25").when(networkBBUtils).getCloudRegion(execution, SourceSystem.SDNC);
+ unassignNetworkBB.getCloudSdncRegion(execution);
+ assertEquals("AAIAIC25", execution.getVariable("cloudRegionSdnc"));
+ }
+
+ @Test
+ public void getCloudSdncRegion30Test() throws Exception {
+ CloudRegion cloudRegion = setCloudRegion();
+ cloudRegion.setCloudRegionVersion("3.0");
+ gBBInput.setCloudRegion(cloudRegion);
+ doReturn(cloudRegion.getLcpCloudRegionId()).when(networkBBUtils).getCloudRegion(execution, SourceSystem.SDNC);
+ unassignNetworkBB.getCloudSdncRegion(execution);
+ assertEquals(cloudRegion.getLcpCloudRegionId(), execution.getVariable("cloudRegionSdnc"));
+ }
+
+ @Test
+ public void errorEncounteredTest_rollback() throws Exception {
+ expectedException.expect(BpmnError.class);
+ execution.setVariable("ErrorUnassignNetworkBB",
+ "Relationship's RelatedTo still exists in AAI, remove the relationship vf-module first.");
+ execution.setVariable("isRollbackNeeded", true);
+ unassignNetworkBB.errorEncountered(execution);
+ }
+
+ @Test
+ public void errorEncounteredTest_noRollback() throws Exception {
+ expectedException.expect(BpmnError.class);
+ execution.setVariable("ErrorUnassignNetworkBB",
+ "Relationship's RelatedTo still exists in AAI, remove the relationship vf-module first.");
+ unassignNetworkBB.errorEncountered(execution);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignVnfTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignVnfTest.java
index 394ffcf0ac..b4cb214483 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignVnfTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignVnfTest.java
@@ -28,7 +28,6 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
@@ -41,43 +40,46 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup;
-public class UnassignVnfTest extends BaseTaskTest{
- @InjectMocks
- private UnassignVnf unassignVnf = new UnassignVnf();
-
- @Before
- public void setup(){
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
-
- }
+public class UnassignVnfTest extends BaseTaskTest {
+ @InjectMocks
+ private UnassignVnf unassignVnf = new UnassignVnf();
+
+ @Before
+ public void setup() {
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
+
+ }
+
+ @Test
+ public void deleteInstanceGroupsSunnyDayTest() throws Exception {
+ GenericVnf genericVnf = setGenericVnf();
+
+ ModelInfoInstanceGroup modelVnfc = new ModelInfoInstanceGroup();
+ modelVnfc.setType("VNFC");
+
+ InstanceGroup instanceGroup1 = new InstanceGroup();
+ instanceGroup1.setId("test-001");
+ instanceGroup1.setModelInfoInstanceGroup(modelVnfc);
+ genericVnf.getInstanceGroups().add(instanceGroup1);
+
+ InstanceGroup instanceGroup2 = new InstanceGroup();
+ instanceGroup2.setId("test-002");
+ instanceGroup2.setModelInfoInstanceGroup(modelVnfc);
+ genericVnf.getInstanceGroups().add(instanceGroup2);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
+ .thenReturn(genericVnf);
+ unassignVnf.deleteInstanceGroups(execution);
+ verify(aaiInstanceGroupResources, times(1)).deleteInstanceGroup(eq(instanceGroup1));
+ verify(aaiInstanceGroupResources, times(1)).deleteInstanceGroup(eq(instanceGroup2));
+ }
+
+ @Test
+ public void deletecreateVnfcInstanceGroupExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
- @Test
- public void deleteInstanceGroupsSunnyDayTest() throws Exception {
- GenericVnf genericVnf = setGenericVnf();
-
- ModelInfoInstanceGroup modelVnfc = new ModelInfoInstanceGroup();
- modelVnfc.setType("VNFC");
-
- InstanceGroup instanceGroup1 = new InstanceGroup();
- instanceGroup1.setId("test-001");
- instanceGroup1.setModelInfoInstanceGroup(modelVnfc);
- genericVnf.getInstanceGroups().add(instanceGroup1);
-
- InstanceGroup instanceGroup2 = new InstanceGroup();
- instanceGroup2.setId("test-002");
- instanceGroup2.setModelInfoInstanceGroup(modelVnfc);
- genericVnf.getInstanceGroups().add(instanceGroup2);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
- unassignVnf.deleteInstanceGroups(execution);
- verify(aaiInstanceGroupResources, times(1)).deleteInstanceGroup(eq(instanceGroup1));
- verify(aaiInstanceGroupResources, times(1)).deleteInstanceGroup(eq(instanceGroup2));
- }
-
- @Test
- public void deletecreateVnfcInstanceGroupExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
-
- unassignVnf.deleteInstanceGroups(execution);
- }
+ unassignVnf.deleteInstanceGroups(execution);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasksTest.java
index 5e9565446f..f9ad473e5a 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasksTest.java
@@ -6,10 +6,8 @@ import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import java.util.HashMap;
import java.util.Map;
-
import org.camunda.bpm.engine.ProcessEngineServices;
import org.camunda.bpm.engine.TaskService;
import org.camunda.bpm.engine.delegate.DelegateExecution;
@@ -23,76 +21,76 @@ import org.onap.so.bpmn.BaseTaskTest;
import org.onap.so.db.request.beans.InfraActiveRequests;
public class ManualHandlingTasksTest extends BaseTaskTest {
- @InjectMocks
- protected ManualHandlingTasks manualHandlingTasks = new ManualHandlingTasks();
-
- @Mock
- TaskService taskService;
-
- @Mock
- private DelegateExecution mockExecution;
-
- @Mock
- ProcessEngineServices processEngineServices;
-
- @Mock
- private DelegateTask task;
-
- private DelegateExecution delegateExecution;
-
- @Before
- public void before() throws Exception {
- delegateExecution = new DelegateExecutionFake();
- }
-
- @Test
- public void setFalloutTaskVariables_Test () {
- when(task.getId()).thenReturn("taskId");
- when(task.getExecution()).thenReturn(mockExecution);
- when(mockExecution.getProcessEngineServices()).thenReturn(processEngineServices);
- when(processEngineServices.getTaskService()).thenReturn(taskService);
- manualHandlingTasks.setFalloutTaskVariables(task);
- verify(taskService, times(1)).setVariables(any(String.class), any(Map.class));
- }
-
- @Test
- public void setPauseTaskVariables_Test () {
- when(task.getId()).thenReturn("taskId");
- when(task.getExecution()).thenReturn(mockExecution);
- when(mockExecution.getProcessEngineServices()).thenReturn(processEngineServices);
- when(processEngineServices.getTaskService()).thenReturn(taskService);
- manualHandlingTasks.setPauseTaskVariables(task);
- verify(taskService, times(1)).setVariables(any(String.class), any(Map.class));
- }
-
- @Test
- public void completeTask_Test() throws Exception{
- when(task.getId()).thenReturn("taskId");
- when(task.getExecution()).thenReturn(mockExecution);
- Map<String, Object> taskVariables = new HashMap<String, Object>();
- taskVariables.put("responseValue", "resume");
- when(mockExecution.getProcessEngineServices()).thenReturn(processEngineServices);
- when(processEngineServices.getTaskService()).thenReturn(taskService);
- when(taskService.getVariables(any(String.class))).thenReturn(taskVariables);
- manualHandlingTasks.completeTask(task);
- verify(mockExecution, times(1)).setVariable("responseValueTask", "Resume");
- }
-
- @Test
- public void updateRequestDbStatus_Test() throws Exception{
- InfraActiveRequests mockedRequest = new InfraActiveRequests();
- delegateExecution.setVariable("msoRequestId", "testMsoRequestId");
- when(requestsDbClient.getInfraActiveRequestbyRequestId(any(String.class))).thenReturn(mockedRequest);
- doNothing().when(requestsDbClient).updateInfraActiveRequests(any(InfraActiveRequests.class));
- manualHandlingTasks.updateRequestDbStatus(delegateExecution, "IN_PROGRESS");
- verify(requestsDbClient, times(1)).updateInfraActiveRequests(any(InfraActiveRequests.class));
- assertEquals(mockedRequest.getRequestStatus(), "IN_PROGRESS");
- }
-
- @Test
- public void createExternalTicket_Test() throws Exception{
- delegateExecution.setVariable("msoRequestId", ("testMsoRequestId"));
- delegateExecution.setVariable("vnfType", "testVnfType");
- manualHandlingTasks.createExternalTicket(delegateExecution);
- }
+ @InjectMocks
+ protected ManualHandlingTasks manualHandlingTasks = new ManualHandlingTasks();
+
+ @Mock
+ TaskService taskService;
+
+ @Mock
+ private DelegateExecution mockExecution;
+
+ @Mock
+ ProcessEngineServices processEngineServices;
+
+ @Mock
+ private DelegateTask task;
+
+ private DelegateExecution delegateExecution;
+
+ @Before
+ public void before() throws Exception {
+ delegateExecution = new DelegateExecutionFake();
+ }
+
+ @Test
+ public void setFalloutTaskVariables_Test() {
+ when(task.getId()).thenReturn("taskId");
+ when(task.getExecution()).thenReturn(mockExecution);
+ when(mockExecution.getProcessEngineServices()).thenReturn(processEngineServices);
+ when(processEngineServices.getTaskService()).thenReturn(taskService);
+ manualHandlingTasks.setFalloutTaskVariables(task);
+ verify(taskService, times(1)).setVariables(any(String.class), any(Map.class));
+ }
+
+ @Test
+ public void setPauseTaskVariables_Test() {
+ when(task.getId()).thenReturn("taskId");
+ when(task.getExecution()).thenReturn(mockExecution);
+ when(mockExecution.getProcessEngineServices()).thenReturn(processEngineServices);
+ when(processEngineServices.getTaskService()).thenReturn(taskService);
+ manualHandlingTasks.setPauseTaskVariables(task);
+ verify(taskService, times(1)).setVariables(any(String.class), any(Map.class));
+ }
+
+ @Test
+ public void completeTask_Test() throws Exception {
+ when(task.getId()).thenReturn("taskId");
+ when(task.getExecution()).thenReturn(mockExecution);
+ Map<String, Object> taskVariables = new HashMap<String, Object>();
+ taskVariables.put("responseValue", "resume");
+ when(mockExecution.getProcessEngineServices()).thenReturn(processEngineServices);
+ when(processEngineServices.getTaskService()).thenReturn(taskService);
+ when(taskService.getVariables(any(String.class))).thenReturn(taskVariables);
+ manualHandlingTasks.completeTask(task);
+ verify(mockExecution, times(1)).setVariable("responseValueTask", "Resume");
+ }
+
+ @Test
+ public void updateRequestDbStatus_Test() throws Exception {
+ InfraActiveRequests mockedRequest = new InfraActiveRequests();
+ delegateExecution.setVariable("msoRequestId", "testMsoRequestId");
+ when(requestsDbClient.getInfraActiveRequestbyRequestId(any(String.class))).thenReturn(mockedRequest);
+ doNothing().when(requestsDbClient).updateInfraActiveRequests(any(InfraActiveRequests.class));
+ manualHandlingTasks.updateRequestDbStatus(delegateExecution, "IN_PROGRESS");
+ verify(requestsDbClient, times(1)).updateInfraActiveRequests(any(InfraActiveRequests.class));
+ assertEquals(mockedRequest.getRequestStatus(), "IN_PROGRESS");
+ }
+
+ @Test
+ public void createExternalTicket_Test() throws Exception {
+ delegateExecution.setVariable("msoRequestId", ("testMsoRequestId"));
+ delegateExecution.setVariable("vnfType", "testVnfType");
+ manualHandlingTasks.createExternalTicket(delegateExecution);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasksTest.java
index 67c48d1e91..f5785f94fd 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasksTest.java
@@ -27,7 +27,6 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentMatchers;
@@ -38,44 +37,50 @@ import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.client.exception.BBObjectNotFoundException;
public class NamingServiceCreateTasksTest extends BaseTaskTest {
- @InjectMocks
- private NamingServiceCreateTasks namingServiceCreateTasks = new NamingServiceCreateTasks();
-
- private InstanceGroup instanceGroup;
-
- @Before
- public void before() throws BBObjectNotFoundException {
- instanceGroup = setInstanceGroup();
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.INSTANCE_GROUP_ID))).thenReturn(instanceGroup);
- }
-
- @Test
- public void createInstanceGroupTest() throws Exception {
- String policyInstanceName = "policyInstanceName";
- String nfNamingCode = "nfNamingCode";
- String generatedName = "generatedInstanceGroupName";
- execution.setVariable(policyInstanceName, policyInstanceName);
- execution.setVariable(nfNamingCode, nfNamingCode);
- doReturn(generatedName).when(namingServiceResources).generateInstanceGroupName(instanceGroup, policyInstanceName, nfNamingCode);
-
- namingServiceCreateTasks.createInstanceGroupName(execution);
- verify(namingServiceResources, times(1)).generateInstanceGroupName(instanceGroup, policyInstanceName, nfNamingCode);
- assertEquals(instanceGroup.getInstanceGroupName(), generatedName);
- }
-
- @Test
- public void createInstanceGroupExceptionTest() throws Exception {
- expectedException.expect(BBObjectNotFoundException.class);
- lookupKeyMap.put(ResourceKey.INSTANCE_GROUP_ID, "notfound");
- doThrow(BBObjectNotFoundException.class).when(extractPojosForBB).extractByKey(any(),ArgumentMatchers.eq(ResourceKey.INSTANCE_GROUP_ID));
- String policyInstanceName = "policyInstanceName";
- String nfNamingCode = "nfNamingCode";
- execution.setVariable(policyInstanceName, policyInstanceName);
- execution.setVariable(nfNamingCode, nfNamingCode);
- doReturn("").when(namingServiceResources).generateInstanceGroupName(instanceGroup, policyInstanceName, nfNamingCode);
- namingServiceCreateTasks.createInstanceGroupName(execution);
- verify(namingServiceResources, times(1)).generateInstanceGroupName(instanceGroup, policyInstanceName, nfNamingCode);
-
- }
-
+ @InjectMocks
+ private NamingServiceCreateTasks namingServiceCreateTasks = new NamingServiceCreateTasks();
+
+ private InstanceGroup instanceGroup;
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ instanceGroup = setInstanceGroup();
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.INSTANCE_GROUP_ID)))
+ .thenReturn(instanceGroup);
+ }
+
+ @Test
+ public void createInstanceGroupTest() throws Exception {
+ String policyInstanceName = "policyInstanceName";
+ String nfNamingCode = "nfNamingCode";
+ String generatedName = "generatedInstanceGroupName";
+ execution.setVariable(policyInstanceName, policyInstanceName);
+ execution.setVariable(nfNamingCode, nfNamingCode);
+ doReturn(generatedName).when(namingServiceResources).generateInstanceGroupName(instanceGroup,
+ policyInstanceName, nfNamingCode);
+
+ namingServiceCreateTasks.createInstanceGroupName(execution);
+ verify(namingServiceResources, times(1)).generateInstanceGroupName(instanceGroup, policyInstanceName,
+ nfNamingCode);
+ assertEquals(instanceGroup.getInstanceGroupName(), generatedName);
+ }
+
+ @Test
+ public void createInstanceGroupExceptionTest() throws Exception {
+ expectedException.expect(BBObjectNotFoundException.class);
+ lookupKeyMap.put(ResourceKey.INSTANCE_GROUP_ID, "notfound");
+ doThrow(BBObjectNotFoundException.class).when(extractPojosForBB).extractByKey(any(),
+ ArgumentMatchers.eq(ResourceKey.INSTANCE_GROUP_ID));
+ String policyInstanceName = "policyInstanceName";
+ String nfNamingCode = "nfNamingCode";
+ execution.setVariable(policyInstanceName, policyInstanceName);
+ execution.setVariable(nfNamingCode, nfNamingCode);
+ doReturn("").when(namingServiceResources).generateInstanceGroupName(instanceGroup, policyInstanceName,
+ nfNamingCode);
+ namingServiceCreateTasks.createInstanceGroupName(execution);
+ verify(namingServiceResources, times(1)).generateInstanceGroupName(instanceGroup, policyInstanceName,
+ nfNamingCode);
+
+ }
+
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceDeleteTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceDeleteTasksTest.java
index 56226dfa96..758b8f4ffd 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceDeleteTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceDeleteTasksTest.java
@@ -26,7 +26,6 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentMatchers;
@@ -37,34 +36,36 @@ import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.client.exception.BBObjectNotFoundException;
public class NamingServiceDeleteTasksTest extends BaseTaskTest {
- @InjectMocks
- private NamingServiceDeleteTasks namingServiceDeleteTasks = new NamingServiceDeleteTasks();
-
- private InstanceGroup instanceGroup;
-
- @Before
- public void before() throws BBObjectNotFoundException {
- instanceGroup = setInstanceGroup();
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.INSTANCE_GROUP_ID))).thenReturn(instanceGroup);
- }
-
- @Test
- public void deleteInstanceGroupTest() throws Exception {
-
- doReturn("").when(namingServiceResources).deleteInstanceGroupName(instanceGroup);
-
- namingServiceDeleteTasks.deleteInstanceGroupName(execution);
- verify(namingServiceResources, times(1)).deleteInstanceGroupName(instanceGroup);
- }
-
- @Test
- public void deleteInstanceGroupExceptionTest() throws Exception {
- expectedException.expect(BBObjectNotFoundException.class);
- lookupKeyMap.put(ResourceKey.INSTANCE_GROUP_ID, "notfound");
- doThrow(BBObjectNotFoundException.class).when(extractPojosForBB).extractByKey(any(),ArgumentMatchers.eq(ResourceKey.INSTANCE_GROUP_ID));
- doReturn("").when(namingServiceResources).deleteInstanceGroupName(instanceGroup);
- namingServiceDeleteTasks.deleteInstanceGroupName(execution);
- verify(namingServiceResources, times(1)).deleteInstanceGroupName(instanceGroup);
- }
-
+ @InjectMocks
+ private NamingServiceDeleteTasks namingServiceDeleteTasks = new NamingServiceDeleteTasks();
+
+ private InstanceGroup instanceGroup;
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ instanceGroup = setInstanceGroup();
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.INSTANCE_GROUP_ID)))
+ .thenReturn(instanceGroup);
+ }
+
+ @Test
+ public void deleteInstanceGroupTest() throws Exception {
+
+ doReturn("").when(namingServiceResources).deleteInstanceGroupName(instanceGroup);
+
+ namingServiceDeleteTasks.deleteInstanceGroupName(execution);
+ verify(namingServiceResources, times(1)).deleteInstanceGroupName(instanceGroup);
+ }
+
+ @Test
+ public void deleteInstanceGroupExceptionTest() throws Exception {
+ expectedException.expect(BBObjectNotFoundException.class);
+ lookupKeyMap.put(ResourceKey.INSTANCE_GROUP_ID, "notfound");
+ doThrow(BBObjectNotFoundException.class).when(extractPojosForBB).extractByKey(any(),
+ ArgumentMatchers.eq(ResourceKey.INSTANCE_GROUP_ID));
+ doReturn("").when(namingServiceResources).deleteInstanceGroupName(instanceGroup);
+ namingServiceDeleteTasks.deleteInstanceGroupName(execution);
+ verify(namingServiceResources, times(1)).deleteInstanceGroupName(instanceGroup);
+ }
+
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTaskTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTaskTest.java
index cbd7605aa4..4eb1432bbf 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTaskTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTaskTest.java
@@ -29,7 +29,6 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
@@ -52,84 +51,98 @@ import org.onap.so.client.exception.BBObjectNotFoundException;
import org.onap.so.client.sdnc.beans.SDNCRequest;
import org.onap.so.client.sdnc.endpoint.SDNCTopology;
-public class SDNCActivateTaskTest extends BaseTaskTest{
-
- @InjectMocks
- private SDNCActivateTasks sdncActivateTasks = new SDNCActivateTasks();
-
- private L3Network network;
- private ServiceInstance serviceInstance;
- private RequestContext requestContext;
- private CloudRegion cloudRegion;
- private GenericVnf genericVnf;
- private VfModule vfModule;
- private Customer customer;
-
- @Before
- public void before() throws BBObjectNotFoundException {
- serviceInstance = setServiceInstance();
- network = setL3Network();
- genericVnf = setGenericVnf();
- vfModule = setVfModule();
- cloudRegion = setCloudRegion();
- requestContext = setRequestContext();
- customer = setCustomer();
+public class SDNCActivateTaskTest extends BaseTaskTest {
+
+ @InjectMocks
+ private SDNCActivateTasks sdncActivateTasks = new SDNCActivateTasks();
+
+ private L3Network network;
+ private ServiceInstance serviceInstance;
+ private RequestContext requestContext;
+ private CloudRegion cloudRegion;
+ private GenericVnf genericVnf;
+ private VfModule vfModule;
+ private Customer customer;
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ serviceInstance = setServiceInstance();
+ network = setL3Network();
+ genericVnf = setGenericVnf();
+ vfModule = setVfModule();
+ cloudRegion = setCloudRegion();
+ requestContext = setRequestContext();
+ customer = setCustomer();
+
+ customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
+ .thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
+ .thenReturn(serviceInstance);
+
+ }
+
+ @Test
+ public void activateVnfTest() throws Exception {
+ doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).activateVnf(genericVnf,
+ serviceInstance, customer, cloudRegion, requestContext);
+ sdncActivateTasks.activateVnf(execution);
+ verify(sdncVnfResources, times(1)).activateVnf(genericVnf, serviceInstance, customer, cloudRegion,
+ requestContext);
+ SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
+ assertEquals(SDNCTopology.VNF, sdncRequest.getTopology());
+ }
+
+ @Test
+ public void activateVnfTestException() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(sdncVnfResources).activateVnf(genericVnf, serviceInstance, customer,
+ cloudRegion, requestContext);
+ sdncActivateTasks.activateVnf(execution);
+ }
+
+ @Test
+ public void activateNetworkTest() throws Exception {
+ doReturn(new GenericResourceApiNetworkOperationInformation()).when(sdncNetworkResources).activateNetwork(
+ isA(L3Network.class), isA(ServiceInstance.class), isA(Customer.class), isA(RequestContext.class),
+ isA(CloudRegion.class));
+ sdncActivateTasks.activateNetwork(execution);
+ verify(sdncNetworkResources, times(1)).activateNetwork(network, serviceInstance, customer, requestContext,
+ cloudRegion);
+ SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
+ assertEquals(SDNCTopology.NETWORK, sdncRequest.getTopology());
+ }
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))).thenReturn(serviceInstance);
+ @Test
+ public void activateNetworkExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(sdncNetworkResources).activateNetwork(isA(L3Network.class),
+ isA(ServiceInstance.class), isA(Customer.class), isA(RequestContext.class), isA(CloudRegion.class));
+ sdncActivateTasks.activateNetwork(execution);
+ }
- }
+ @Test
+ public void activateVfModuleTest() throws Exception {
+ doReturn(new GenericResourceApiVfModuleOperationInformation()).when(sdncVfModuleResources)
+ .activateVfModule(vfModule, genericVnf, serviceInstance, customer, cloudRegion, requestContext);
+ sdncActivateTasks.activateVfModule(execution);
+ verify(sdncVfModuleResources, times(1)).activateVfModule(vfModule, genericVnf, serviceInstance, customer,
+ cloudRegion, requestContext);
+ SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
+ assertEquals(SDNCTopology.VFMODULE, sdncRequest.getTopology());
+ }
- @Test
- public void activateVnfTest() throws Exception {
- doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).activateVnf(genericVnf,serviceInstance, customer, cloudRegion,requestContext);
- sdncActivateTasks.activateVnf(execution);
- verify(sdncVnfResources, times(1)).activateVnf(genericVnf,serviceInstance, customer,cloudRegion,requestContext);
- SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
- assertEquals(SDNCTopology.VNF,sdncRequest.getTopology());
- }
-
- @Test
- public void activateVnfTestException() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(sdncVnfResources).activateVnf(genericVnf,serviceInstance, customer,cloudRegion,requestContext);
- sdncActivateTasks.activateVnf(execution);
- }
-
- @Test
- public void activateNetworkTest() throws Exception {
- doReturn(new GenericResourceApiNetworkOperationInformation()).when(sdncNetworkResources).activateNetwork(isA(L3Network.class), isA(ServiceInstance.class), isA(Customer.class), isA(RequestContext.class), isA(CloudRegion.class));
- sdncActivateTasks.activateNetwork(execution);
- verify(sdncNetworkResources, times(1)).activateNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
- SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
- assertEquals(SDNCTopology.NETWORK,sdncRequest.getTopology());
- }
-
- @Test
- public void activateNetworkExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(sdncNetworkResources).activateNetwork(isA(L3Network.class), isA(ServiceInstance.class), isA(Customer.class), isA(RequestContext.class), isA(CloudRegion.class));
- sdncActivateTasks.activateNetwork(execution);
- }
-
- @Test
- public void activateVfModuleTest() throws Exception {
- doReturn(new GenericResourceApiVfModuleOperationInformation()).when(sdncVfModuleResources).activateVfModule(vfModule, genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- sdncActivateTasks.activateVfModule(execution);
- verify(sdncVfModuleResources, times(1)).activateVfModule(vfModule, genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
- assertEquals(SDNCTopology.VFMODULE,sdncRequest.getTopology());
- }
-
- @Test
- public void activateVfModuleTestException() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(sdncVfModuleResources).activateVfModule(vfModule, genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- sdncActivateTasks.activateVfModule(execution);
- }
+ @Test
+ public void activateVfModuleTestException() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(sdncVfModuleResources).activateVfModule(vfModule, genericVnf,
+ serviceInstance, customer, cloudRegion, requestContext);
+ sdncActivateTasks.activateVfModule(execution);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasksTest.java
index b5509b1e12..7d8e94d1e9 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasksTest.java
@@ -28,7 +28,6 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
@@ -54,101 +53,117 @@ import org.onap.so.client.sdnc.beans.SDNCRequest;
import org.onap.so.client.sdnc.endpoint.SDNCTopology;
-public class SDNCAssignTasksTest extends BaseTaskTest{
- @InjectMocks
- private SDNCAssignTasks sdncAssignTasks = new SDNCAssignTasks();
+public class SDNCAssignTasksTest extends BaseTaskTest {
+ @InjectMocks
+ private SDNCAssignTasks sdncAssignTasks = new SDNCAssignTasks();
+
+ private L3Network network;
+ private ServiceInstance serviceInstance;
+ private RequestContext requestContext;
+ private CloudRegion cloudRegion;
+ private GenericVnf genericVnf;
+ private VfModule vfModule;
+ private VolumeGroup volumeGroup;
+ private Customer customer;
- private L3Network network;
- private ServiceInstance serviceInstance;
- private RequestContext requestContext;
- private CloudRegion cloudRegion;
- private GenericVnf genericVnf;
- private VfModule vfModule;
- private VolumeGroup volumeGroup;
- private Customer customer;
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ customer = setCustomer();
+ serviceInstance = setServiceInstance();
+ network = setL3Network();
+ cloudRegion = setCloudRegion();
+ requestContext = setRequestContext();
+ genericVnf = setGenericVnf();
+ vfModule = setVfModule();
+ volumeGroup = setVolumeGroup();
- @Before
- public void before() throws BBObjectNotFoundException {
- customer = setCustomer();
- serviceInstance = setServiceInstance();
- network = setL3Network();
- cloudRegion = setCloudRegion();
- requestContext = setRequestContext();
- genericVnf = setGenericVnf();
- vfModule = setVfModule();
- volumeGroup = setVolumeGroup();
-
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))).thenReturn(serviceInstance);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID))).thenReturn(volumeGroup);
- }
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
+ .thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
+ .thenReturn(serviceInstance);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID)))
+ .thenReturn(volumeGroup);
+ }
- @Test
- public void assignServiceInstanceTest() throws Exception {
- doReturn(new GenericResourceApiServiceOperationInformation()).when(sdncServiceInstanceResources).assignServiceInstance(serviceInstance, customer, requestContext);
- sdncAssignTasks.assignServiceInstance(execution);
- verify(sdncServiceInstanceResources, times(1)).assignServiceInstance(serviceInstance, customer, requestContext);
- SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
- assertEquals(SDNCTopology.SERVICE,sdncRequest.getTopology());
- }
+ @Test
+ public void assignServiceInstanceTest() throws Exception {
+ doReturn(new GenericResourceApiServiceOperationInformation()).when(sdncServiceInstanceResources)
+ .assignServiceInstance(serviceInstance, customer, requestContext);
+ sdncAssignTasks.assignServiceInstance(execution);
+ verify(sdncServiceInstanceResources, times(1)).assignServiceInstance(serviceInstance, customer, requestContext);
+ SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
+ assertEquals(SDNCTopology.SERVICE, sdncRequest.getTopology());
+ }
- @Test
- public void assignServiceInstanceExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(sdncServiceInstanceResources).assignServiceInstance(serviceInstance, customer, requestContext);
- sdncAssignTasks.assignServiceInstance(execution);
- }
+ @Test
+ public void assignServiceInstanceExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(sdncServiceInstanceResources).assignServiceInstance(serviceInstance,
+ customer, requestContext);
+ sdncAssignTasks.assignServiceInstance(execution);
+ }
- @Test
- public void assignVnfTest() throws Exception {
- doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).assignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext, false);
- execution.setVariable("generalBuildingBlock", gBBInput);
- sdncAssignTasks.assignVnf(execution);
- verify(sdncVnfResources, times(1)).assignVnf(genericVnf, serviceInstance,customer, cloudRegion, requestContext, false);
- SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
- assertEquals(SDNCTopology.VNF,sdncRequest.getTopology());
- }
+ @Test
+ public void assignVnfTest() throws Exception {
+ doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).assignVnf(genericVnf,
+ serviceInstance, customer, cloudRegion, requestContext, false);
+ execution.setVariable("generalBuildingBlock", gBBInput);
+ sdncAssignTasks.assignVnf(execution);
+ verify(sdncVnfResources, times(1)).assignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext,
+ false);
+ SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
+ assertEquals(SDNCTopology.VNF, sdncRequest.getTopology());
+ }
- @Test
- public void assignVnfExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(sdncVnfResources).assignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext, false);
- sdncAssignTasks.assignVnf(execution);
- }
+ @Test
+ public void assignVnfExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(sdncVnfResources).assignVnf(genericVnf, serviceInstance, customer,
+ cloudRegion, requestContext, false);
+ sdncAssignTasks.assignVnf(execution);
+ }
- @Test
- public void assignVfModuleTest() throws Exception {
- doReturn(new GenericResourceApiVfModuleOperationInformation()).when(sdncVfModuleResources).assignVfModule(vfModule, volumeGroup, genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- sdncAssignTasks.assignVfModule(execution);
- verify(sdncVfModuleResources, times(1)).assignVfModule(vfModule, volumeGroup, genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
- assertEquals(SDNCTopology.VFMODULE,sdncRequest.getTopology());
- }
+ @Test
+ public void assignVfModuleTest() throws Exception {
+ doReturn(new GenericResourceApiVfModuleOperationInformation()).when(sdncVfModuleResources).assignVfModule(
+ vfModule, volumeGroup, genericVnf, serviceInstance, customer, cloudRegion, requestContext);
+ sdncAssignTasks.assignVfModule(execution);
+ verify(sdncVfModuleResources, times(1)).assignVfModule(vfModule, volumeGroup, genericVnf, serviceInstance,
+ customer, cloudRegion, requestContext);
+ SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
+ assertEquals(SDNCTopology.VFMODULE, sdncRequest.getTopology());
+ }
- @Test
- public void assignVfModuleExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(sdncVfModuleResources).assignVfModule(vfModule, volumeGroup, genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- sdncAssignTasks.assignVfModule(execution);
- }
+ @Test
+ public void assignVfModuleExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(sdncVfModuleResources).assignVfModule(vfModule, volumeGroup, genericVnf,
+ serviceInstance, customer, cloudRegion, requestContext);
+ sdncAssignTasks.assignVfModule(execution);
+ }
- @Test
- public void assignNetworkTest() throws Exception {
- doReturn(new GenericResourceApiNetworkOperationInformation()).when(sdncNetworkResources).assignNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
- sdncAssignTasks.assignNetwork(execution);
- verify(sdncNetworkResources, times(1)).assignNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
- SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
- assertEquals(SDNCTopology.NETWORK,sdncRequest.getTopology());
- }
+ @Test
+ public void assignNetworkTest() throws Exception {
+ doReturn(new GenericResourceApiNetworkOperationInformation()).when(sdncNetworkResources).assignNetwork(network,
+ serviceInstance, customer, requestContext, cloudRegion);
+ sdncAssignTasks.assignNetwork(execution);
+ verify(sdncNetworkResources, times(1)).assignNetwork(network, serviceInstance, customer, requestContext,
+ cloudRegion);
+ SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
+ assertEquals(SDNCTopology.NETWORK, sdncRequest.getTopology());
+ }
- @Test
- public void assignNetworkExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(sdncNetworkResources).assignNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
- sdncAssignTasks.assignNetwork(execution);
- }
+ @Test
+ public void assignNetworkExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(sdncNetworkResources).assignNetwork(network, serviceInstance, customer,
+ requestContext, cloudRegion);
+ sdncAssignTasks.assignNetwork(execution);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasksTest.java
index be792115c9..1c1616a472 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasksTest.java
@@ -27,7 +27,6 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
@@ -48,61 +47,70 @@ import org.onap.so.client.exception.BBObjectNotFoundException;
import org.onap.so.client.sdnc.beans.SDNCRequest;
import org.onap.so.client.sdnc.endpoint.SDNCTopology;
-public class SDNCChangeAssignTasksTest extends BaseTaskTest{
- @InjectMocks
- private SDNCChangeAssignTasks sdncChangeAssignTasks = new SDNCChangeAssignTasks();
-
- private ServiceInstance serviceInstance;
- private RequestContext requestContext;
- private CloudRegion cloudRegion;
- private VfModule vfModule;
- private GenericVnf genericVnf;
- private Customer customer;
-
- @Before
- public void before() throws BBObjectNotFoundException {
- customer = setCustomer();
- serviceInstance = setServiceInstance();
- genericVnf = setGenericVnf();
- vfModule = setVfModule();
- cloudRegion = setCloudRegion();
- requestContext = setRequestContext();
+public class SDNCChangeAssignTasksTest extends BaseTaskTest {
+ @InjectMocks
+ private SDNCChangeAssignTasks sdncChangeAssignTasks = new SDNCChangeAssignTasks();
+
+ private ServiceInstance serviceInstance;
+ private RequestContext requestContext;
+ private CloudRegion cloudRegion;
+ private VfModule vfModule;
+ private GenericVnf genericVnf;
+ private Customer customer;
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ customer = setCustomer();
+ serviceInstance = setServiceInstance();
+ genericVnf = setGenericVnf();
+ vfModule = setVfModule();
+ cloudRegion = setCloudRegion();
+ requestContext = setRequestContext();
+
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
+ .thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
+ .thenReturn(serviceInstance);
+ }
+
+ @Test
+ public void changeModelVnfTest() throws Exception {
+ doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).changeModelVnf(genericVnf,
+ serviceInstance, customer, cloudRegion, requestContext);
+ sdncChangeAssignTasks.changeModelVnf(execution);
+ verify(sdncVnfResources, times(1)).changeModelVnf(genericVnf, serviceInstance, customer, cloudRegion,
+ requestContext);
+ SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
+ assertEquals(SDNCTopology.VNF, sdncRequest.getTopology());
+ }
+
+ @Test
+ public void changeModelVnfExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(sdncVnfResources).changeModelVnf(genericVnf, serviceInstance, customer,
+ cloudRegion, requestContext);
+ sdncChangeAssignTasks.changeModelVnf(execution);
+ }
+
+ @Test
+ public void changeAssignModelVfModuleTest() throws Exception {
+ doReturn(new GenericResourceApiVfModuleOperationInformation()).when(sdncVfModuleResources)
+ .changeAssignVfModule(vfModule, genericVnf, serviceInstance, customer, cloudRegion, requestContext);
+ sdncChangeAssignTasks.changeAssignModelVfModule(execution);
+ verify(sdncVfModuleResources, times(1)).changeAssignVfModule(vfModule, genericVnf, serviceInstance, customer,
+ cloudRegion, requestContext);
+ SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
+ assertEquals(SDNCTopology.VFMODULE, sdncRequest.getTopology());
+ }
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))).thenReturn(serviceInstance);
- }
-
- @Test
- public void changeModelVnfTest() throws Exception {
- doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).changeModelVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- sdncChangeAssignTasks.changeModelVnf(execution);
- verify(sdncVnfResources, times(1)).changeModelVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
- assertEquals(SDNCTopology.VNF,sdncRequest.getTopology());
- }
-
- @Test
- public void changeModelVnfExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(sdncVnfResources).changeModelVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- sdncChangeAssignTasks.changeModelVnf(execution);
- }
-
- @Test
- public void changeAssignModelVfModuleTest() throws Exception {
- doReturn(new GenericResourceApiVfModuleOperationInformation()).when(sdncVfModuleResources).changeAssignVfModule(vfModule, genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- sdncChangeAssignTasks.changeAssignModelVfModule(execution);
- verify(sdncVfModuleResources, times(1)).changeAssignVfModule(vfModule, genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
- assertEquals(SDNCTopology.VFMODULE,sdncRequest.getTopology());
- }
-
- @Test
- public void changeAssignModelVfModuleExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(sdncVfModuleResources).changeAssignVfModule(vfModule, genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- sdncChangeAssignTasks.changeAssignModelVfModule(execution);
- }
+ @Test
+ public void changeAssignModelVfModuleExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(sdncVfModuleResources).changeAssignVfModule(vfModule, genericVnf,
+ serviceInstance, customer, cloudRegion, requestContext);
+ sdncChangeAssignTasks.changeAssignModelVfModule(execution);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTaskTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTaskTest.java
index 18048da50d..08d4d196da 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTaskTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTaskTest.java
@@ -28,7 +28,6 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
@@ -53,97 +52,113 @@ import org.onap.so.client.sdnc.beans.SDNCRequest;
import org.onap.so.client.sdnc.endpoint.SDNCTopology;
public class SDNCDeactivateTaskTest extends BaseTaskTest {
- @InjectMocks
- private SDNCDeactivateTasks sdncDeactivateTasks = new SDNCDeactivateTasks();
-
- private ServiceInstance serviceInstance;
- private CloudRegion cloudRegion;
- private RequestContext requestContext;
- private GenericVnf genericVnf;
- private VfModule vfModule;
- private L3Network network;
- private Customer customer;
-
- @Before
- public void before() throws BBObjectNotFoundException {
- customer = setCustomer();
- serviceInstance = setServiceInstance();
- cloudRegion = setCloudRegion();
- requestContext = setRequestContext();
- genericVnf = setGenericVnf();
- vfModule = setVfModule();
- network = setL3Network();
-
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))).thenReturn(serviceInstance);
+ @InjectMocks
+ private SDNCDeactivateTasks sdncDeactivateTasks = new SDNCDeactivateTasks();
+
+ private ServiceInstance serviceInstance;
+ private CloudRegion cloudRegion;
+ private RequestContext requestContext;
+ private GenericVnf genericVnf;
+ private VfModule vfModule;
+ private L3Network network;
+ private Customer customer;
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ customer = setCustomer();
+ serviceInstance = setServiceInstance();
+ cloudRegion = setCloudRegion();
+ requestContext = setRequestContext();
+ genericVnf = setGenericVnf();
+ vfModule = setVfModule();
+ network = setL3Network();
+
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
+ .thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
+ .thenReturn(serviceInstance);
+
+ }
+
+ @Test
+ public void deactivateVfModuleTest() throws Exception {
+ doReturn(new GenericResourceApiVfModuleOperationInformation()).when(sdncVfModuleResources)
+ .deactivateVfModule(vfModule, genericVnf, serviceInstance, customer, cloudRegion, requestContext);
+ sdncDeactivateTasks.deactivateVfModule(execution);
+ verify(sdncVfModuleResources, times(1)).deactivateVfModule(vfModule, genericVnf, serviceInstance, customer,
+ cloudRegion, requestContext);
+ SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
+ assertEquals(SDNCTopology.VFMODULE, sdncRequest.getTopology());
+ }
+
+ @Test
+ public void deactivateVfModuleExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(sdncVfModuleResources).deactivateVfModule(vfModule, genericVnf,
+ serviceInstance, customer, cloudRegion, requestContext);
+ sdncDeactivateTasks.deactivateVfModule(execution);
+ }
+
+ @Test
+ public void deactivateVnfTest() throws Exception {
+ doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).deactivateVnf(genericVnf,
+ serviceInstance, customer, cloudRegion, requestContext);
+ sdncDeactivateTasks.deactivateVnf(execution);
+ verify(sdncVnfResources, times(1)).deactivateVnf(genericVnf, serviceInstance, customer, cloudRegion,
+ requestContext);
+ SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
+ assertEquals(SDNCTopology.VNF, sdncRequest.getTopology());
+ }
+
+ @Test
+ public void deactivateVnfExceptionTest() throws Exception {
+ doThrow(RuntimeException.class).when(sdncVnfResources).deactivateVnf(genericVnf, serviceInstance, customer,
+ cloudRegion, requestContext);
+ expectedException.expect(BpmnError.class);
+ sdncDeactivateTasks.deactivateVnf(execution);
+ }
+
+ @Test
+ public void deactivateServiceInstanceTest() throws Exception {
+ doReturn(new GenericResourceApiServiceOperationInformation()).when(sdncServiceInstanceResources)
+ .deactivateServiceInstance(serviceInstance, customer, requestContext);
+ sdncDeactivateTasks.deactivateServiceInstance(execution);
+ verify(sdncServiceInstanceResources, times(1)).deactivateServiceInstance(serviceInstance, customer,
+ requestContext);
+ SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
+ assertEquals(SDNCTopology.SERVICE, sdncRequest.getTopology());
+ }
+
+ @Test
+ public void deactivateServiceInstanceExceptionTest() throws Exception {
+ doThrow(RuntimeException.class).when(sdncServiceInstanceResources).deactivateServiceInstance(serviceInstance,
+ customer, requestContext);
+ expectedException.expect(BpmnError.class);
+ sdncDeactivateTasks.deactivateServiceInstance(execution);
+ }
+
+ @Test
+ public void test_deactivateNetwork() throws Exception {
+ doReturn(new GenericResourceApiNetworkOperationInformation()).when(sdncNetworkResources)
+ .deactivateNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
+ sdncDeactivateTasks.deactivateNetwork(execution);
+ verify(sdncNetworkResources, times(1)).deactivateNetwork(network, serviceInstance, customer, requestContext,
+ cloudRegion);
+ SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
+ assertEquals(SDNCTopology.NETWORK, sdncRequest.getTopology());
+ }
- }
-
- @Test
- public void deactivateVfModuleTest() throws Exception {
- doReturn(new GenericResourceApiVfModuleOperationInformation()).when(sdncVfModuleResources).deactivateVfModule(vfModule, genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- sdncDeactivateTasks.deactivateVfModule(execution);
- verify(sdncVfModuleResources, times(1)).deactivateVfModule(vfModule, genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
- assertEquals(SDNCTopology.VFMODULE,sdncRequest.getTopology());
- }
-
- @Test
- public void deactivateVfModuleExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(sdncVfModuleResources).deactivateVfModule(vfModule, genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- sdncDeactivateTasks.deactivateVfModule(execution);
- }
-
- @Test
- public void deactivateVnfTest() throws Exception {
- doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).deactivateVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- sdncDeactivateTasks.deactivateVnf(execution);
- verify(sdncVnfResources, times(1)).deactivateVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
- assertEquals(SDNCTopology.VNF,sdncRequest.getTopology());
- }
-
- @Test
- public void deactivateVnfExceptionTest() throws Exception {
- doThrow(RuntimeException.class).when(sdncVnfResources).deactivateVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- expectedException.expect(BpmnError.class);
- sdncDeactivateTasks.deactivateVnf(execution);
- }
-
- @Test
- public void deactivateServiceInstanceTest() throws Exception {
- doReturn(new GenericResourceApiServiceOperationInformation()).when(sdncServiceInstanceResources).deactivateServiceInstance(serviceInstance, customer, requestContext);
- sdncDeactivateTasks.deactivateServiceInstance(execution);
- verify(sdncServiceInstanceResources, times(1)).deactivateServiceInstance(serviceInstance, customer, requestContext);
- SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
- assertEquals(SDNCTopology.SERVICE,sdncRequest.getTopology());
- }
-
- @Test
- public void deactivateServiceInstanceExceptionTest() throws Exception {
- doThrow(RuntimeException.class).when(sdncServiceInstanceResources).deactivateServiceInstance(serviceInstance, customer, requestContext);
- expectedException.expect(BpmnError.class);
- sdncDeactivateTasks.deactivateServiceInstance(execution);
- }
-
- @Test
- public void test_deactivateNetwork() throws Exception {
- doReturn(new GenericResourceApiNetworkOperationInformation()).when(sdncNetworkResources).deactivateNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
- sdncDeactivateTasks.deactivateNetwork(execution);
- verify(sdncNetworkResources, times(1)).deactivateNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
- SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
- assertEquals(SDNCTopology.NETWORK,sdncRequest.getTopology());
- }
-
- @Test
- public void test_deactivateNetwork_exception() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(extractPojosForBB).extractByKey(any(),ArgumentMatchers.eq(ResourceKey.NETWORK_ID));
- sdncDeactivateTasks.deactivateNetwork(execution);
- verify(sdncNetworkResources, times(0)).deactivateNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
- }
+ @Test
+ public void test_deactivateNetwork_exception() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(extractPojosForBB).extractByKey(any(),
+ ArgumentMatchers.eq(ResourceKey.NETWORK_ID));
+ sdncDeactivateTasks.deactivateNetwork(execution);
+ verify(sdncNetworkResources, times(0)).deactivateNetwork(network, serviceInstance, customer, requestContext,
+ cloudRegion);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCQueryTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCQueryTasksTest.java
index 28551baa7a..3ea8474b24 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCQueryTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCQueryTasksTest.java
@@ -29,7 +29,6 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Rule;
@@ -45,95 +44,99 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.client.exception.BBObjectNotFoundException;
-public class SDNCQueryTasksTest extends BaseTaskTest{
- @InjectMocks
- private SDNCQueryTasks sdncQueryTasks = new SDNCQueryTasks();
-
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- private ServiceInstance serviceInstance;
- private GenericVnf genericVnf;
- private VfModule vfModule;
-
- @Before
- public void before() throws BBObjectNotFoundException {
- serviceInstance = setServiceInstance();
- genericVnf = setGenericVnf();
- vfModule = setVfModule();
-
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))).thenReturn(serviceInstance);
-
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
-
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
-
- }
-
- @Test
- public void queryVfModuleTest() throws Exception {
- String sdncQueryResponse = "response";
- vfModule.setSelflink("vfModuleSelfLink");
-
- doReturn(sdncQueryResponse).when(sdncVfModuleResources).queryVfModule(vfModule);
-
- assertNotEquals(sdncQueryResponse, execution.getVariable("SDNCQueryResponse_" + vfModule.getVfModuleId()));
- sdncQueryTasks.queryVfModule(execution);
- assertEquals(sdncQueryResponse, execution.getVariable("SDNCQueryResponse_" + vfModule.getVfModuleId()));
-
- verify(sdncVfModuleResources, times(1)).queryVfModule(vfModule);
- }
-
- @Test
- public void queryVnfTest() throws Exception {
- String sdncQueryResponse = "response";
-
- doReturn(sdncQueryResponse).when(sdncVnfResources).queryVnf(genericVnf);
-
- assertNotEquals(sdncQueryResponse, execution.getVariable("SDNCQueryResponse_" + genericVnf.getVnfId()));
- sdncQueryTasks.queryVnf(execution);
- assertEquals(sdncQueryResponse, execution.getVariable("SDNCQueryResponse_" + genericVnf.getVnfId()));
-
- verify(sdncVnfResources, times(1)).queryVnf(genericVnf);
- }
-
- @Test
- public void queryVfModuleForVolumeGroupTest() throws Exception {
- String sdncQueryResponse = "response";
- vfModule.setSelflink("vfModuleSelfLink");
-
- doReturn(sdncQueryResponse).when(sdncVfModuleResources).queryVfModule(vfModule);
-
- assertNotEquals(sdncQueryResponse, execution.getVariable("SDNCQueryResponse_" + vfModule.getVfModuleId()));
- sdncQueryTasks.queryVfModuleForVolumeGroup(execution);
- assertEquals(sdncQueryResponse, execution.getVariable("SDNCQueryResponse_" + vfModule.getVfModuleId()));
-
- verify(sdncVfModuleResources, times(1)).queryVfModule(vfModule);
- }
-
- @Test
- public void queryVfModuleForVolumeGroupNoSelfLinkExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
-
- vfModule.setSelflink("");
-
- sdncQueryTasks.queryVfModuleForVolumeGroup(execution);
- }
-
- @Test
- public void queryVfModuleForVolumeGroupVfObjectExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(extractPojosForBB).extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID));
- sdncQueryTasks.queryVfModuleForVolumeGroup(execution);
-
- verify(sdncVfModuleResources, times(0)).queryVfModule(any(VfModule.class));
- }
-
- @Test
- public void queryVfModuleForVolumeGroupNonVfObjectExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
-
- sdncQueryTasks.queryVfModuleForVolumeGroup(execution);
- }
+public class SDNCQueryTasksTest extends BaseTaskTest {
+ @InjectMocks
+ private SDNCQueryTasks sdncQueryTasks = new SDNCQueryTasks();
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ private ServiceInstance serviceInstance;
+ private GenericVnf genericVnf;
+ private VfModule vfModule;
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ serviceInstance = setServiceInstance();
+ genericVnf = setGenericVnf();
+ vfModule = setVfModule();
+
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
+ .thenReturn(serviceInstance);
+
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
+ .thenReturn(genericVnf);
+
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
+
+ }
+
+ @Test
+ public void queryVfModuleTest() throws Exception {
+ String sdncQueryResponse = "response";
+ vfModule.setSelflink("vfModuleSelfLink");
+
+ doReturn(sdncQueryResponse).when(sdncVfModuleResources).queryVfModule(vfModule);
+
+ assertNotEquals(sdncQueryResponse, execution.getVariable("SDNCQueryResponse_" + vfModule.getVfModuleId()));
+ sdncQueryTasks.queryVfModule(execution);
+ assertEquals(sdncQueryResponse, execution.getVariable("SDNCQueryResponse_" + vfModule.getVfModuleId()));
+
+ verify(sdncVfModuleResources, times(1)).queryVfModule(vfModule);
+ }
+
+ @Test
+ public void queryVnfTest() throws Exception {
+ String sdncQueryResponse = "response";
+
+ doReturn(sdncQueryResponse).when(sdncVnfResources).queryVnf(genericVnf);
+
+ assertNotEquals(sdncQueryResponse, execution.getVariable("SDNCQueryResponse_" + genericVnf.getVnfId()));
+ sdncQueryTasks.queryVnf(execution);
+ assertEquals(sdncQueryResponse, execution.getVariable("SDNCQueryResponse_" + genericVnf.getVnfId()));
+
+ verify(sdncVnfResources, times(1)).queryVnf(genericVnf);
+ }
+
+ @Test
+ public void queryVfModuleForVolumeGroupTest() throws Exception {
+ String sdncQueryResponse = "response";
+ vfModule.setSelflink("vfModuleSelfLink");
+
+ doReturn(sdncQueryResponse).when(sdncVfModuleResources).queryVfModule(vfModule);
+
+ assertNotEquals(sdncQueryResponse, execution.getVariable("SDNCQueryResponse_" + vfModule.getVfModuleId()));
+ sdncQueryTasks.queryVfModuleForVolumeGroup(execution);
+ assertEquals(sdncQueryResponse, execution.getVariable("SDNCQueryResponse_" + vfModule.getVfModuleId()));
+
+ verify(sdncVfModuleResources, times(1)).queryVfModule(vfModule);
+ }
+
+ @Test
+ public void queryVfModuleForVolumeGroupNoSelfLinkExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ vfModule.setSelflink("");
+
+ sdncQueryTasks.queryVfModuleForVolumeGroup(execution);
+ }
+
+ @Test
+ public void queryVfModuleForVolumeGroupVfObjectExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(extractPojosForBB).extractByKey(any(),
+ ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID));
+ sdncQueryTasks.queryVfModuleForVolumeGroup(execution);
+
+ verify(sdncVfModuleResources, times(0)).queryVfModule(any(VfModule.class));
+ }
+
+ @Test
+ public void queryVfModuleForVolumeGroupNonVfObjectExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ sdncQueryTasks.queryVfModuleForVolumeGroup(execution);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasksTest.java
index 043aad43b1..b5d34ea4c9 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasksTest.java
@@ -25,18 +25,14 @@ import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import java.io.IOException;
import java.io.StringReader;
import java.nio.file.Files;
import java.nio.file.Paths;
-
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.camunda.bpm.engine.delegate.DelegateExecution;
-
import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
import org.junit.Before;
import org.junit.Rule;
@@ -57,128 +53,133 @@ import org.onap.so.client.sdnc.beans.SDNCRequest;
import org.onap.so.client.sdnc.endpoint.SDNCTopology;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
-
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
@RunWith(MockitoJUnitRunner.class)
-public class SDNCRequestTasksTest extends SDNCRequestTasks{
-
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- @InjectMocks
- SDNCRequestTasks sndcRequestTasks = new SDNCRequestTasks();
-
- @Mock
- SDNCClient sdncClient;
-
- @Spy
- private ExceptionBuilder exceptionBuilder;
-
- protected DelegateExecution delegateExecution;
-
-
- @Before
- public void setup(){
- delegateExecution = new DelegateExecutionFake();
- delegateExecution.setVariable("SDNCRequest", createSDNCRequest());
- }
-
- @Test
- public void createCorrelationVariables_Test(){
- sndcRequestTasks.createCorrelationVariables(delegateExecution);
- assertEquals("correlationValue",delegateExecution.getVariable("correlationName_CORRELATOR"));
- }
-
- @Test
- public void callSDNC_Final_Test() throws MapperException, BadResponseException, IOException{
- final String sdncResponse = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNCClientPut200Response.json")));
- doReturn(sdncResponse).when(sdncClient).post(createSDNCRequest().getSDNCPayload(),SDNCTopology.CONFIGURATION);
- sndcRequestTasks.callSDNC(delegateExecution);
- assertEquals(true,delegateExecution.getVariable("isSDNCCompleted"));
- }
-
- @Test
- public void callSDNC_Not_Final_Test() throws MapperException, BadResponseException, IOException{
- final String sdncResponse = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNCClientPut200ResponseNotFinal.json")));
- doReturn(sdncResponse).when(sdncClient).post(createSDNCRequest().getSDNCPayload(),SDNCTopology.CONFIGURATION);
- sndcRequestTasks.callSDNC(delegateExecution);
- assertEquals(false,delegateExecution.getVariable("isSDNCCompleted"));
- }
-
- @Test
- public void callSDNC_Error_Test() throws MapperException, BadResponseException{
- doThrow(MapperException.class).when(sdncClient).post(createSDNCRequest().getSDNCPayload(),SDNCTopology.CONFIGURATION);
- doReturn("processKey").when(exceptionBuilder).getProcessKey(delegateExecution);
- expectedException.expect(BpmnError.class);
- sndcRequestTasks.callSDNC(delegateExecution);
- }
-
- @Test
- public void convertIndicatorToBoolean_True_Test() throws MapperException, BadResponseException{
- boolean testValue = sndcRequestTasks.convertIndicatorToBoolean("Y");
- assertEquals(true,testValue);
- }
-
- @Test
- public void convertIndicatorToBoolean_False_Test() throws MapperException, BadResponseException{
- boolean testValue = sndcRequestTasks.convertIndicatorToBoolean("N");
- assertEquals(false,testValue);
- }
-
- @Test
- public void HandleTimeout_Test() throws MapperException, BadResponseException{
- doReturn("processKey").when(exceptionBuilder).getProcessKey(delegateExecution);
- expectedException.expect(BpmnError.class);
- sndcRequestTasks.handleTimeOutException(delegateExecution);
- }
-
- @Test
- public void processCallBack_Final_Test() throws MapperException, BadResponseException, IOException{
- final String sdncResponse = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNC_Async_Request2.xml")));
- delegateExecution.setVariable("correlationName_MESSAGE", sdncResponse);
- sndcRequestTasks.processCallback(delegateExecution);
- assertEquals(true,delegateExecution.getVariable(IS_CALLBACK_COMPLETED));
- }
-
- @Test
- public void getXmlElementTest() throws Exception {
- final String sdncResponse = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNC_Async_Request2.xml")));
- DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance ();
+public class SDNCRequestTasksTest extends SDNCRequestTasks {
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ @InjectMocks
+ SDNCRequestTasks sndcRequestTasks = new SDNCRequestTasks();
+
+ @Mock
+ SDNCClient sdncClient;
+
+ @Spy
+ private ExceptionBuilder exceptionBuilder;
+
+ protected DelegateExecution delegateExecution;
+
+
+ @Before
+ public void setup() {
+ delegateExecution = new DelegateExecutionFake();
+ delegateExecution.setVariable("SDNCRequest", createSDNCRequest());
+ }
+
+ @Test
+ public void createCorrelationVariables_Test() {
+ sndcRequestTasks.createCorrelationVariables(delegateExecution);
+ assertEquals("correlationValue", delegateExecution.getVariable("correlationName_CORRELATOR"));
+ }
+
+ @Test
+ public void callSDNC_Final_Test() throws MapperException, BadResponseException, IOException {
+ final String sdncResponse =
+ new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNCClientPut200Response.json")));
+ doReturn(sdncResponse).when(sdncClient).post(createSDNCRequest().getSDNCPayload(), SDNCTopology.CONFIGURATION);
+ sndcRequestTasks.callSDNC(delegateExecution);
+ assertEquals(true, delegateExecution.getVariable("isSDNCCompleted"));
+ }
+
+ @Test
+ public void callSDNC_Not_Final_Test() throws MapperException, BadResponseException, IOException {
+ final String sdncResponse = new String(
+ Files.readAllBytes(Paths.get("src/test/resources/__files/SDNCClientPut200ResponseNotFinal.json")));
+ doReturn(sdncResponse).when(sdncClient).post(createSDNCRequest().getSDNCPayload(), SDNCTopology.CONFIGURATION);
+ sndcRequestTasks.callSDNC(delegateExecution);
+ assertEquals(false, delegateExecution.getVariable("isSDNCCompleted"));
+ }
+
+ @Test
+ public void callSDNC_Error_Test() throws MapperException, BadResponseException {
+ doThrow(MapperException.class).when(sdncClient).post(createSDNCRequest().getSDNCPayload(),
+ SDNCTopology.CONFIGURATION);
+ doReturn("processKey").when(exceptionBuilder).getProcessKey(delegateExecution);
+ expectedException.expect(BpmnError.class);
+ sndcRequestTasks.callSDNC(delegateExecution);
+ }
+
+ @Test
+ public void convertIndicatorToBoolean_True_Test() throws MapperException, BadResponseException {
+ boolean testValue = sndcRequestTasks.convertIndicatorToBoolean("Y");
+ assertEquals(true, testValue);
+ }
+
+ @Test
+ public void convertIndicatorToBoolean_False_Test() throws MapperException, BadResponseException {
+ boolean testValue = sndcRequestTasks.convertIndicatorToBoolean("N");
+ assertEquals(false, testValue);
+ }
+
+ @Test
+ public void HandleTimeout_Test() throws MapperException, BadResponseException {
+ doReturn("processKey").when(exceptionBuilder).getProcessKey(delegateExecution);
+ expectedException.expect(BpmnError.class);
+ sndcRequestTasks.handleTimeOutException(delegateExecution);
+ }
+
+ @Test
+ public void processCallBack_Final_Test() throws MapperException, BadResponseException, IOException {
+ final String sdncResponse =
+ new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNC_Async_Request2.xml")));
+ delegateExecution.setVariable("correlationName_MESSAGE", sdncResponse);
+ sndcRequestTasks.processCallback(delegateExecution);
+ assertEquals(true, delegateExecution.getVariable(IS_CALLBACK_COMPLETED));
+ }
+
+ @Test
+ public void getXmlElementTest() throws Exception {
+ final String sdncResponse =
+ new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNC_Async_Request2.xml")));
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db;
- db = dbf.newDocumentBuilder ();
- Document doc = db.parse (new InputSource(new StringReader(sdncResponse)));
-
+ db = dbf.newDocumentBuilder();
+ Document doc = db.parse(new InputSource(new StringReader(sdncResponse)));
+
String finalMessageIndicator = getXmlElement(doc, "/input/ack-final-indicator");
String responseCode = getXmlElement(doc, "/input/response-code");
- String responseMessage = getXmlElement(doc, "/input/response-message");
-
- assertEquals("Y", finalMessageIndicator);
- assertEquals("200", responseCode);
- assertEquals("Success", responseMessage);
- }
-
- public SDNCRequest createSDNCRequest(){
- SDNCRequest request = new SDNCRequest();
- request.setCorrelationName("correlationName");
- request.setCorrelationValue("correlationValue");
- request.setTopology(SDNCTopology.CONFIGURATION);
- ObjectMapper mapper = new ObjectMapper();
- try {
- GenericResourceApiServiceOperationInformation sdncReq =
- mapper.readValue(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNC_Client_Request.json")), GenericResourceApiServiceOperationInformation.class);
- request.setSDNCPayload(sdncReq);
- } catch (JsonParseException e) {
-
- } catch (JsonMappingException e) {
-
- } catch (IOException e) {
-
- }
-
- return request;
- }
-
+ String responseMessage = getXmlElement(doc, "/input/response-message");
+
+ assertEquals("Y", finalMessageIndicator);
+ assertEquals("200", responseCode);
+ assertEquals("Success", responseMessage);
+ }
+
+ public SDNCRequest createSDNCRequest() {
+ SDNCRequest request = new SDNCRequest();
+ request.setCorrelationName("correlationName");
+ request.setCorrelationValue("correlationValue");
+ request.setTopology(SDNCTopology.CONFIGURATION);
+ ObjectMapper mapper = new ObjectMapper();
+ try {
+ GenericResourceApiServiceOperationInformation sdncReq = mapper.readValue(
+ Files.readAllBytes(Paths.get("src/test/resources/__files/SDNC_Client_Request.json")),
+ GenericResourceApiServiceOperationInformation.class);
+ request.setSDNCPayload(sdncReq);
+ } catch (JsonParseException e) {
+
+ } catch (JsonMappingException e) {
+
+ } catch (IOException e) {
+
+ }
+
+ return request;
+ }
+
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasksTest.java
index 527fe0d916..c6ed1cca7a 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasksTest.java
@@ -30,7 +30,6 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
@@ -54,99 +53,111 @@ import org.onap.so.client.exception.BBObjectNotFoundException;
import org.onap.so.client.sdnc.beans.SDNCRequest;
import org.onap.so.client.sdnc.endpoint.SDNCTopology;
-public class SDNCUnassignTasksTest extends BaseTaskTest{
- @InjectMocks
- private SDNCUnassignTasks sdncUnassignTasks = new SDNCUnassignTasks();
-
- private ServiceInstance serviceInstance;
- private RequestContext requestContext;
- private GenericVnf genericVnf;
- private VfModule vfModule;
- private CloudRegion cloudRegion;
- private L3Network network;
- private Customer customer;
-
- @Before
- public void before() throws BBObjectNotFoundException {
- customer = setCustomer();
- serviceInstance = setServiceInstance();
- requestContext = setRequestContext();
- genericVnf = setGenericVnf();
- vfModule = setVfModule();
- cloudRegion = setCloudRegion();
- network = setL3Network();
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))).thenReturn(serviceInstance);
- }
-
- @Test
- public void unassignServiceInstanceTest() throws Exception {
- doReturn(new GenericResourceApiServiceOperationInformation()).when(sdncServiceInstanceResources).unassignServiceInstance(serviceInstance, customer, requestContext);
- sdncUnassignTasks.unassignServiceInstance(execution);
- verify(sdncServiceInstanceResources, times(1)).unassignServiceInstance(serviceInstance, customer, requestContext);
- SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
- assertEquals(SDNCTopology.SERVICE,sdncRequest.getTopology());
- }
-
-
-
- @Test
- public void unassignServiceInstanceExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(sdncServiceInstanceResources).unassignServiceInstance(serviceInstance, customer, requestContext);
- sdncUnassignTasks.unassignServiceInstance(execution);
- }
-
- @Test
- public void unassignVfModuleTest() throws Exception {
- doReturn(new GenericResourceApiVfModuleOperationInformation()).when(sdncVfModuleResources).unassignVfModule(vfModule, genericVnf, serviceInstance);
- sdncUnassignTasks.unassignVfModule(execution);
- verify(sdncVfModuleResources, times(1)).unassignVfModule(vfModule, genericVnf, serviceInstance);
- SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
- assertEquals(SDNCTopology.VFMODULE,sdncRequest.getTopology());
- }
-
-
-
-
- @Test
- public void unassignVfModuleExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(sdncVfModuleResources).unassignVfModule(vfModule, genericVnf, serviceInstance);
- sdncUnassignTasks.unassignVfModule(execution);
- }
-
- @Test
- public void unassignVnfTest() throws Exception {
- doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).unassignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- sdncUnassignTasks.unassignVnf(execution);
- verify(sdncVnfResources, times(1)).unassignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
- assertEquals(SDNCTopology.VNF,sdncRequest.getTopology());
- }
-
-
- @Test
- public void unassignVnfExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(sdncVnfResources).unassignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- sdncUnassignTasks.unassignVnf(execution);
- }
-
- @Test
- public void unassignNetworkTest() throws Exception {
- String cloudRegionSdnc = "AAIAIC25";
- cloudRegion.setCloudRegionVersion("2.5");
- execution.setVariable("cloudRegionSdnc", cloudRegionSdnc);
- doReturn(new GenericResourceApiNetworkOperationInformation()).when(sdncNetworkResources).unassignNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
- assertNotEquals(cloudRegionSdnc, cloudRegion.getLcpCloudRegionId());
- sdncUnassignTasks.unassignNetwork(execution);
- verify(sdncNetworkResources, times(1)).unassignNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
- assertEquals(cloudRegionSdnc, cloudRegion.getLcpCloudRegionId());
- SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
- assertEquals(SDNCTopology.NETWORK,sdncRequest.getTopology());
- }
+public class SDNCUnassignTasksTest extends BaseTaskTest {
+ @InjectMocks
+ private SDNCUnassignTasks sdncUnassignTasks = new SDNCUnassignTasks();
+
+ private ServiceInstance serviceInstance;
+ private RequestContext requestContext;
+ private GenericVnf genericVnf;
+ private VfModule vfModule;
+ private CloudRegion cloudRegion;
+ private L3Network network;
+ private Customer customer;
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ customer = setCustomer();
+ serviceInstance = setServiceInstance();
+ requestContext = setRequestContext();
+ genericVnf = setGenericVnf();
+ vfModule = setVfModule();
+ cloudRegion = setCloudRegion();
+ network = setL3Network();
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
+ .thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
+ .thenReturn(serviceInstance);
+ }
+
+ @Test
+ public void unassignServiceInstanceTest() throws Exception {
+ doReturn(new GenericResourceApiServiceOperationInformation()).when(sdncServiceInstanceResources)
+ .unassignServiceInstance(serviceInstance, customer, requestContext);
+ sdncUnassignTasks.unassignServiceInstance(execution);
+ verify(sdncServiceInstanceResources, times(1)).unassignServiceInstance(serviceInstance, customer,
+ requestContext);
+ SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
+ assertEquals(SDNCTopology.SERVICE, sdncRequest.getTopology());
+ }
+
+
+
+ @Test
+ public void unassignServiceInstanceExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(sdncServiceInstanceResources).unassignServiceInstance(serviceInstance,
+ customer, requestContext);
+ sdncUnassignTasks.unassignServiceInstance(execution);
+ }
+
+ @Test
+ public void unassignVfModuleTest() throws Exception {
+ doReturn(new GenericResourceApiVfModuleOperationInformation()).when(sdncVfModuleResources)
+ .unassignVfModule(vfModule, genericVnf, serviceInstance);
+ sdncUnassignTasks.unassignVfModule(execution);
+ verify(sdncVfModuleResources, times(1)).unassignVfModule(vfModule, genericVnf, serviceInstance);
+ SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
+ assertEquals(SDNCTopology.VFMODULE, sdncRequest.getTopology());
+ }
+
+
+
+ @Test
+ public void unassignVfModuleExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(sdncVfModuleResources).unassignVfModule(vfModule, genericVnf,
+ serviceInstance);
+ sdncUnassignTasks.unassignVfModule(execution);
+ }
+
+ @Test
+ public void unassignVnfTest() throws Exception {
+ doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).unassignVnf(genericVnf,
+ serviceInstance, customer, cloudRegion, requestContext);
+ sdncUnassignTasks.unassignVnf(execution);
+ verify(sdncVnfResources, times(1)).unassignVnf(genericVnf, serviceInstance, customer, cloudRegion,
+ requestContext);
+ SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
+ assertEquals(SDNCTopology.VNF, sdncRequest.getTopology());
+ }
+
+
+ @Test
+ public void unassignVnfExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(sdncVnfResources).unassignVnf(genericVnf, serviceInstance, customer,
+ cloudRegion, requestContext);
+ sdncUnassignTasks.unassignVnf(execution);
+ }
+
+ @Test
+ public void unassignNetworkTest() throws Exception {
+ String cloudRegionSdnc = "AAIAIC25";
+ cloudRegion.setCloudRegionVersion("2.5");
+ execution.setVariable("cloudRegionSdnc", cloudRegionSdnc);
+ doReturn(new GenericResourceApiNetworkOperationInformation()).when(sdncNetworkResources)
+ .unassignNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
+ assertNotEquals(cloudRegionSdnc, cloudRegion.getLcpCloudRegionId());
+ sdncUnassignTasks.unassignNetwork(execution);
+ verify(sdncNetworkResources, times(1)).unassignNetwork(network, serviceInstance, customer, requestContext,
+ cloudRegion);
+ assertEquals(cloudRegionSdnc, cloudRegion.getLcpCloudRegionId());
+ SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
+ assertEquals(SDNCTopology.NETWORK, sdncRequest.getTopology());
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/validations/CloudRegionOrchestrationValidatorTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/validations/CloudRegionOrchestrationValidatorTest.java
index 81ec388649..2fc3cf639c 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/validations/CloudRegionOrchestrationValidatorTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/validations/CloudRegionOrchestrationValidatorTest.java
@@ -27,7 +27,6 @@ import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import java.util.Optional;
import java.util.Set;
-
import org.junit.Before;
import org.junit.Test;
import org.onap.so.bpmn.common.BuildingBlockExecution;
@@ -35,83 +34,84 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
public class CloudRegionOrchestrationValidatorTest {
-
- private BuildingBlockExecution mockExecution;
- private CloudRegion cloudRegion;
-
- @Before
- public void setUp() {
- cloudRegion = new CloudRegion();
- cloudRegion.setCloudOwner("CloudOwner");
- cloudRegion.setLcpCloudRegionId("my-region-id");
- GeneralBuildingBlock gbb = new GeneralBuildingBlock();
- gbb.setCloudRegion(cloudRegion);
- mockExecution = mock(BuildingBlockExecution.class);
- doReturn(gbb).when(mockExecution).getGeneralBuildingBlock();
- }
-
- @Test
- public void validateDisabledTest() {
- cloudRegion.setOrchestrationDisabled(true);
- CloudRegionOrchestrationValidator validation = new CloudRegionOrchestrationValidator();
- Optional<String> result = validation.validate(mockExecution);
- assertEquals("Error: The request has failed due to orchestration currently disabled for the target cloud region my-region-id for cloud owner CloudOwner",
- result.get());
- }
-
- @Test
- public void validateNotDisabledTest() {
- cloudRegion.setOrchestrationDisabled(false);
- CloudRegionOrchestrationValidator validation = new CloudRegionOrchestrationValidator();
- Optional<String> result = validation.validate(mockExecution);
- assertFalse(result.isPresent());
- }
-
- @Test
- public void validateDisabledIsNullTest() {
- CloudRegionOrchestrationValidator validation = new CloudRegionOrchestrationValidator();
- Optional<String> result = validation.validate(mockExecution);
- assertFalse(result.isPresent());
- }
- @Test
- public void shouldRunForTest() {
- CloudRegionOrchestrationValidator validator = new CloudRegionOrchestrationValidator();
- assertTrue(validator.shouldRunFor("ActivateNetworkBB"));
- assertTrue(validator.shouldRunFor("AssignNetworkBB"));
- assertTrue(validator.shouldRunFor("CreateNetworkBB"));
- assertTrue(validator.shouldRunFor("DeactivateNetworkBB"));
- assertTrue(validator.shouldRunFor("DeleteNetworkBB"));
- assertTrue(validator.shouldRunFor("UnassignNetworkBB"));
- assertTrue(validator.shouldRunFor("UpdateNetworkBB"));
-
- assertTrue(validator.shouldRunFor("ActivateVnfBB"));
- assertTrue(validator.shouldRunFor("AssignVnfBB"));
- assertTrue(validator.shouldRunFor("UnassignVnfBB"));
- assertTrue(validator.shouldRunFor("DeactivateVnfBB"));
+ private BuildingBlockExecution mockExecution;
+ private CloudRegion cloudRegion;
+
+ @Before
+ public void setUp() {
+ cloudRegion = new CloudRegion();
+ cloudRegion.setCloudOwner("CloudOwner");
+ cloudRegion.setLcpCloudRegionId("my-region-id");
+ GeneralBuildingBlock gbb = new GeneralBuildingBlock();
+ gbb.setCloudRegion(cloudRegion);
+ mockExecution = mock(BuildingBlockExecution.class);
+ doReturn(gbb).when(mockExecution).getGeneralBuildingBlock();
+ }
+
+ @Test
+ public void validateDisabledTest() {
+ cloudRegion.setOrchestrationDisabled(true);
+ CloudRegionOrchestrationValidator validation = new CloudRegionOrchestrationValidator();
+ Optional<String> result = validation.validate(mockExecution);
+ assertEquals(
+ "Error: The request has failed due to orchestration currently disabled for the target cloud region my-region-id for cloud owner CloudOwner",
+ result.get());
+ }
+
+ @Test
+ public void validateNotDisabledTest() {
+ cloudRegion.setOrchestrationDisabled(false);
+ CloudRegionOrchestrationValidator validation = new CloudRegionOrchestrationValidator();
+ Optional<String> result = validation.validate(mockExecution);
+ assertFalse(result.isPresent());
+ }
+
+ @Test
+ public void validateDisabledIsNullTest() {
+ CloudRegionOrchestrationValidator validation = new CloudRegionOrchestrationValidator();
+ Optional<String> result = validation.validate(mockExecution);
+ assertFalse(result.isPresent());
+ }
+
+ @Test
+ public void shouldRunForTest() {
+ CloudRegionOrchestrationValidator validator = new CloudRegionOrchestrationValidator();
+ assertTrue(validator.shouldRunFor("ActivateNetworkBB"));
+ assertTrue(validator.shouldRunFor("AssignNetworkBB"));
+ assertTrue(validator.shouldRunFor("CreateNetworkBB"));
+ assertTrue(validator.shouldRunFor("DeactivateNetworkBB"));
+ assertTrue(validator.shouldRunFor("DeleteNetworkBB"));
+ assertTrue(validator.shouldRunFor("UnassignNetworkBB"));
+ assertTrue(validator.shouldRunFor("UpdateNetworkBB"));
+
+ assertTrue(validator.shouldRunFor("ActivateVnfBB"));
+ assertTrue(validator.shouldRunFor("AssignVnfBB"));
+ assertTrue(validator.shouldRunFor("UnassignVnfBB"));
+ assertTrue(validator.shouldRunFor("DeactivateVnfBB"));
+
+ assertTrue(validator.shouldRunFor("ActivateVfModuleBB"));
+ assertTrue(validator.shouldRunFor("AssignVfModuleBB"));
+ assertTrue(validator.shouldRunFor("CreateVfModuleBB"));
+ assertTrue(validator.shouldRunFor("DeactivateVfModuleBB"));
+ assertTrue(validator.shouldRunFor("DeleteVfModuleBB"));
+ assertTrue(validator.shouldRunFor("UnassignVfModuleBB"));
+
+ assertTrue(validator.shouldRunFor("ActivateVolumeGroupBB"));
+ assertTrue(validator.shouldRunFor("AssignVolumeGroupBB"));
+ assertTrue(validator.shouldRunFor("CreateVolumeGroupBB"));
+ assertTrue(validator.shouldRunFor("DeactivateVolumeGroupBB"));
+ assertTrue(validator.shouldRunFor("DeleteVolumeGroupBB"));
+ assertTrue(validator.shouldRunFor("UnassignVolumeGroupBB"));
+
+ assertTrue(validator.shouldRunFor("ActivateFabricConfigurationBB"));
+ assertTrue(validator.shouldRunFor("AssignFabricConfigurationBB"));
+ assertTrue(validator.shouldRunFor("UnassignFabricConfigurationBB"));
+ assertTrue(validator.shouldRunFor("DeactivateFabricConfigurationBB"));
- assertTrue(validator.shouldRunFor("ActivateVfModuleBB"));
- assertTrue(validator.shouldRunFor("AssignVfModuleBB"));
- assertTrue(validator.shouldRunFor("CreateVfModuleBB"));
- assertTrue(validator.shouldRunFor("DeactivateVfModuleBB"));
- assertTrue(validator.shouldRunFor("DeleteVfModuleBB"));
- assertTrue(validator.shouldRunFor("UnassignVfModuleBB"));
-
- assertTrue(validator.shouldRunFor("ActivateVolumeGroupBB"));
- assertTrue(validator.shouldRunFor("AssignVolumeGroupBB"));
- assertTrue(validator.shouldRunFor("CreateVolumeGroupBB"));
- assertTrue(validator.shouldRunFor("DeactivateVolumeGroupBB"));
- assertTrue(validator.shouldRunFor("DeleteVolumeGroupBB"));
- assertTrue(validator.shouldRunFor("UnassignVolumeGroupBB"));
-
- assertTrue(validator.shouldRunFor("ActivateFabricConfigurationBB"));
- assertTrue(validator.shouldRunFor("AssignFabricConfigurationBB"));
- assertTrue(validator.shouldRunFor("UnassignFabricConfigurationBB"));
- assertTrue(validator.shouldRunFor("DeactivateFabricConfigurationBB"));
-
- assertFalse(validator.shouldRunFor("AssignServiceInstanceBB"));
- assertFalse(validator.shouldRunFor("AAICheckVnfInMaintBB"));
- assertFalse(validator.shouldRunFor("ChangeModelVfModuleBB"));
- assertFalse(validator.shouldRunFor("CreateNetworkCollectionBB"));
- }
+ assertFalse(validator.shouldRunFor("AssignServiceInstanceBB"));
+ assertFalse(validator.shouldRunFor("AAICheckVnfInMaintBB"));
+ assertFalse(validator.shouldRunFor("ChangeModelVfModuleBB"));
+ assertFalse(validator.shouldRunFor("CreateNetworkCollectionBB"));
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/FlowCompletionTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/FlowCompletionTasksTest.java
index 3cf003d1ad..1bdde8f904 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/FlowCompletionTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/FlowCompletionTasksTest.java
@@ -26,7 +26,6 @@ import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
@@ -37,33 +36,33 @@ import org.springframework.beans.factory.annotation.Autowired;
public class FlowCompletionTasksTest extends BaseTaskTest {
- @InjectMocks
- protected FlowCompletionTasks flowCompletionTasks = new FlowCompletionTasks();
+ @InjectMocks
+ protected FlowCompletionTasks flowCompletionTasks = new FlowCompletionTasks();
+
+ @Before
+ public void before() {
+ setRequestContext();
+ }
+
+ @Test
+ public void updateRequestDbStatusComplete_Test() throws Exception {
+ InfraActiveRequests mockedRequest = new InfraActiveRequests();
+ when(requestsDbClient.getInfraActiveRequestbyRequestId(any(String.class))).thenReturn(mockedRequest);
+ doNothing().when(requestsDbClient).updateInfraActiveRequests(any(InfraActiveRequests.class));
+ flowCompletionTasks.updateRequestDbStatus(execution);
+ verify(requestsDbClient, times(1)).updateInfraActiveRequests(any(InfraActiveRequests.class));
+ assertEquals(mockedRequest.getRequestStatus(), "COMPLETE");
+ }
- @Before
- public void before() {
- setRequestContext();
- }
-
- @Test
- public void updateRequestDbStatusComplete_Test() throws Exception{
- InfraActiveRequests mockedRequest = new InfraActiveRequests();
- when(requestsDbClient.getInfraActiveRequestbyRequestId(any(String.class))).thenReturn(mockedRequest);
- doNothing().when(requestsDbClient).updateInfraActiveRequests(any(InfraActiveRequests.class));
- flowCompletionTasks.updateRequestDbStatus(execution);
- verify(requestsDbClient, times(1)).updateInfraActiveRequests(any(InfraActiveRequests.class));
- assertEquals(mockedRequest.getRequestStatus(), "COMPLETE");
- }
-
- @Test
- public void updateRequestDbStatusFailed_Test() throws Exception{
- WorkflowException workflowException = new WorkflowException("testProcessKey", 7000, "Error");
- execution.setVariable("WorkflowException", workflowException);
- InfraActiveRequests mockedRequest = new InfraActiveRequests();
- when(requestsDbClient.getInfraActiveRequestbyRequestId(any(String.class))).thenReturn(mockedRequest);
- doNothing().when(requestsDbClient).updateInfraActiveRequests(any(InfraActiveRequests.class));
- flowCompletionTasks.updateRequestDbStatus(execution);
- verify(requestsDbClient, times(1)).updateInfraActiveRequests(any(InfraActiveRequests.class));
- assertEquals(mockedRequest.getRequestStatus(), "FAILED");
- }
+ @Test
+ public void updateRequestDbStatusFailed_Test() throws Exception {
+ WorkflowException workflowException = new WorkflowException("testProcessKey", 7000, "Error");
+ execution.setVariable("WorkflowException", workflowException);
+ InfraActiveRequests mockedRequest = new InfraActiveRequests();
+ when(requestsDbClient.getInfraActiveRequestbyRequestId(any(String.class))).thenReturn(mockedRequest);
+ doNothing().when(requestsDbClient).updateInfraActiveRequests(any(InfraActiveRequests.class));
+ flowCompletionTasks.updateRequestDbStatus(execution);
+ verify(requestsDbClient, times(1)).updateInfraActiveRequests(any(InfraActiveRequests.class));
+ assertEquals(mockedRequest.getRequestStatus(), "FAILED");
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorTest.java
index 60d456e2b5..b371e3a48a 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorTest.java
@@ -26,11 +26,9 @@ import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.when;
-
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Ignore;
@@ -54,384 +52,434 @@ import org.springframework.beans.factory.annotation.Autowired;
@Ignore
public class OrchestrationStatusValidatorTest extends BaseTaskTest {
- @InjectMocks
- protected OrchestrationStatusValidator orchestrationStatusValidator = new OrchestrationStatusValidator();
-
-
-
- @Test
- public void test_validateOrchestrationStatus() throws Exception {
- String flowToBeCalled = "AssignServiceInstanceBB";
- setServiceInstance().setOrchestrationStatus(OrchestrationStatus.PRECREATED);
- execution.setVariable("aLaCarte", true);
- execution.setVariable("flowToBeCalled", flowToBeCalled);
-
- BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
- buildingBlockDetail.setBuildingBlockName("AssignServiceInstanceBB");
- buildingBlockDetail.setId(1);
- buildingBlockDetail.setResourceType(ResourceType.SERVICE);
- buildingBlockDetail.setTargetAction(OrchestrationAction.ASSIGN);
-
- doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
-
- OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = new OrchestrationStatusStateTransitionDirective();
- orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.CONTINUE);
- orchestrationStatusStateTransitionDirective.setId(1);
- orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
- orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.SERVICE);
- orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.ASSIGN);
-
- doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient).getOrchestrationStatusStateTransitionDirective(ResourceType.SERVICE, OrchestrationStatus.PRECREATED, OrchestrationAction.ASSIGN);
-
- orchestrationStatusValidator.validateOrchestrationStatus(execution);
-
- assertEquals(OrchestrationStatusValidationDirective.CONTINUE, execution.getVariable("orchestrationStatusValidationResult"));
- }
-
- @Test
- public void test_validateOrchestrationStatusConfiguration() throws Exception {
- lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "configurationId");
- String flowToBeCalled = "UnassignFabricConfigurationBB";
- ServiceInstance si = setServiceInstance();
- List<Configuration> configurations = new ArrayList<>();
- Configuration config = new Configuration();
-
- si.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
- config.setConfigurationId("configurationId");
- config.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
- configurations.add(config);
- si.setConfigurations(configurations);
-
- execution.setVariable("flowToBeCalled", flowToBeCalled);
- execution.setVariable("aLaCarte", true);
-
- BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
- buildingBlockDetail.setBuildingBlockName("UnassignFabricConfigurationBB");
- buildingBlockDetail.setId(1);
- buildingBlockDetail.setResourceType(ResourceType.CONFIGURATION);
- buildingBlockDetail.setTargetAction(OrchestrationAction.UNASSIGN);
-
- doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
-
- OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = new OrchestrationStatusStateTransitionDirective();
- orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS);
- orchestrationStatusStateTransitionDirective.setId(1);
- orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
- orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.CONFIGURATION);
- orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.UNASSIGN);
-
- doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient).getOrchestrationStatusStateTransitionDirective(ResourceType.CONFIGURATION, OrchestrationStatus.PRECREATED, OrchestrationAction.UNASSIGN);
-
- orchestrationStatusValidator.validateOrchestrationStatus(execution);
-
- assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS, execution.getVariable("orchestrationStatusValidationResult"));
- }
-
- @Test
- public void test_validateOrchestrationStatus_buildingBlockDetailNotFound() throws Exception {
- expectedException.expect(BpmnError.class);
-
- String flowToBeCalled = "AssignServiceInstanceBB";
-
- execution.setVariable("flowToBeCalled", flowToBeCalled);
-
- doReturn(null).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
-
- orchestrationStatusValidator.validateOrchestrationStatus(execution);
- }
-
- @Test
- public void test_validateOrchestrationStatus_orchestrationValidationFail() throws Exception {
- expectedException.expect(BpmnError.class);
-
- String flowToBeCalled = "AssignServiceInstanceBB";
-
- execution.setVariable("flowToBeCalled", flowToBeCalled);
-
- BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
- buildingBlockDetail.setBuildingBlockName("AssignServiceInstanceBB");
- buildingBlockDetail.setId(1);
- buildingBlockDetail.setResourceType(ResourceType.SERVICE);
- buildingBlockDetail.setTargetAction(OrchestrationAction.ASSIGN);
-
- doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
-
- OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = new OrchestrationStatusStateTransitionDirective();
- orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.FAIL);
- orchestrationStatusStateTransitionDirective.setId(1);
- orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
- orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.SERVICE);
- orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.ASSIGN);
-
- doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient).getOrchestrationStatusStateTransitionDirective(ResourceType.SERVICE, OrchestrationStatus.PRECREATED, OrchestrationAction.ASSIGN);
-
- orchestrationStatusValidator.validateOrchestrationStatus(execution);
- }
-
- @Test
- public void test_validateOrchestrationStatus_orchestrationValidationNotFound() throws Exception {
- expectedException.expect(BpmnError.class);
-
- String flowToBeCalled = "AssignServiceInstanceBB";
-
- execution.setVariable("flowToBeCalled", flowToBeCalled);
-
- BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
- buildingBlockDetail.setBuildingBlockName("AssignServiceInstanceBB");
- buildingBlockDetail.setId(1);
- buildingBlockDetail.setResourceType(ResourceType.SERVICE);
- buildingBlockDetail.setTargetAction(OrchestrationAction.ASSIGN);
-
- doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
-
- OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = new OrchestrationStatusStateTransitionDirective();
- orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.FAIL);
- orchestrationStatusStateTransitionDirective.setId(1);
- orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
- orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.SERVICE);
- orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.ASSIGN);
-
- doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient).getOrchestrationStatusStateTransitionDirective(ResourceType.NETWORK, OrchestrationStatus.PRECREATED, OrchestrationAction.ASSIGN);
-
- orchestrationStatusValidator.validateOrchestrationStatus(execution);
- }
-
- @Test
- public void test_validateOrchestrationStatus_unassignNotFound() throws Exception{
- String flowToBeCalled = "UnassignServiceInstanceBB";
-
- execution.setVariable("flowToBeCalled", flowToBeCalled);
- execution.setVariable("aLaCarte", true);
-
- BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
- buildingBlockDetail.setBuildingBlockName("UnassignServiceInstanceBB");
- buildingBlockDetail.setId(1);
- buildingBlockDetail.setResourceType(ResourceType.SERVICE);
- buildingBlockDetail.setTargetAction(OrchestrationAction.UNASSIGN);
-
- doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
-
- lookupKeyMap = new HashMap<ResourceKey, String>();
-
- orchestrationStatusValidator.validateOrchestrationStatus(execution);
-
- assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS,execution.getVariable("orchestrationStatusValidationResult"));
- }
-
- @Test
- public void test_validateOrchestrationStatusSecondStageOfMultiStageEnabledVfModule() throws Exception {
- String flowToBeCalled = "CreateVfModuleBB";
-
- execution.setVariable("orchestrationStatusValidationResult", OrchestrationStatusValidationDirective.SILENT_SUCCESS);
- execution.setVariable("aLaCarte", true);
- execution.setVariable("flowToBeCalled", flowToBeCalled);
-
- GenericVnf genericVnf = buildGenericVnf();
- ModelInfoGenericVnf modelInfoGenericVnf = genericVnf.getModelInfoGenericVnf();
- modelInfoGenericVnf.setMultiStageDesign("true");
- setGenericVnf().setModelInfoGenericVnf(modelInfoGenericVnf);
- setVfModule().setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
-
- BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
- buildingBlockDetail.setBuildingBlockName("CreateVfModuleBB");
- buildingBlockDetail.setId(1);
- buildingBlockDetail.setResourceType(ResourceType.VF_MODULE);
- buildingBlockDetail.setTargetAction(OrchestrationAction.CREATE);
-
- doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
-
- OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = new OrchestrationStatusStateTransitionDirective();
- orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.FAIL);
- orchestrationStatusStateTransitionDirective.setId(1);
- orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
- orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE);
- orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.CREATE);
-
- doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient).getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, OrchestrationStatus.PENDING_ACTIVATION, OrchestrationAction.CREATE);
-
- orchestrationStatusValidator.validateOrchestrationStatus(execution);
-
- assertEquals(OrchestrationStatusValidationDirective.CONTINUE, execution.getVariable("orchestrationStatusValidationResult"));
- }
-
-
- @Test
- public void test_validateOrchestrationStatusSecondStageOfMultiStageWrongPrevStatusVfModule() throws Exception {
- String flowToBeCalled = "CreateVfModuleBB";
-
- execution.setVariable("orchestrationStatusValidationResult", OrchestrationStatusValidationDirective.CONTINUE);
- execution.setVariable("aLaCarte", true);
- execution.setVariable("flowToBeCalled", flowToBeCalled);
-
- GenericVnf genericVnf = buildGenericVnf();
- ModelInfoGenericVnf modelInfoGenericVnf = genericVnf.getModelInfoGenericVnf();
- modelInfoGenericVnf.setMultiStageDesign("true");
- setGenericVnf().setModelInfoGenericVnf(modelInfoGenericVnf);
- setVfModule().setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
-
- BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
- buildingBlockDetail.setBuildingBlockName("CreateVfModuleBB");
- buildingBlockDetail.setId(1);
- buildingBlockDetail.setResourceType(ResourceType.VF_MODULE);
- buildingBlockDetail.setTargetAction(OrchestrationAction.CREATE);
-
- doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
-
- OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = new OrchestrationStatusStateTransitionDirective();
- orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS);
- orchestrationStatusStateTransitionDirective.setId(1);
- orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
- orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE);
- orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.CREATE);
-
- doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient).getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, OrchestrationStatus.PENDING_ACTIVATION, OrchestrationAction.CREATE);
-
- orchestrationStatusValidator.validateOrchestrationStatus(execution);
-
- assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS, execution.getVariable("orchestrationStatusValidationResult"));
- }
-
- @Test
- public void test_validateOrchestrationStatusSecondStageOfMultiStageDisabledVfModule() throws Exception {
- String flowToBeCalled = "CreateVfModuleBB";
-
- execution.setVariable("orchestrationStatusValidationResult", OrchestrationStatusValidationDirective.SILENT_SUCCESS);
- execution.setVariable("aLaCarte", true);
- execution.setVariable("flowToBeCalled", flowToBeCalled);
-
- GenericVnf genericVnf = buildGenericVnf();
- ModelInfoGenericVnf modelInfoGenericVnf = genericVnf.getModelInfoGenericVnf();
- modelInfoGenericVnf.setMultiStageDesign("false");
- setGenericVnf().setModelInfoGenericVnf(modelInfoGenericVnf);
- setVfModule().setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
-
- BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
- buildingBlockDetail.setBuildingBlockName("CreateVfModuleBB");
- buildingBlockDetail.setId(1);
- buildingBlockDetail.setResourceType(ResourceType.VF_MODULE);
- buildingBlockDetail.setTargetAction(OrchestrationAction.CREATE);
-
- doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
-
- OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = new OrchestrationStatusStateTransitionDirective();
- orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS);
- orchestrationStatusStateTransitionDirective.setId(1);
- orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
- orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE);
- orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.CREATE);
-
- doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient).getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, OrchestrationStatus.PENDING_ACTIVATION, OrchestrationAction.CREATE);
-
- orchestrationStatusValidator.validateOrchestrationStatus(execution);
-
- assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS, execution.getVariable("orchestrationStatusValidationResult"));
- }
-
- @Test
- public void test_validateOrchestrationStatusSecondStageOfMultiStageWrongOrchStatusVfModule() throws Exception {
- String flowToBeCalled = "CreateVfModuleBB";
-
- execution.setVariable("orchestrationStatusValidationResult", OrchestrationStatusValidationDirective.SILENT_SUCCESS);
- execution.setVariable("aLaCarte", true);
- execution.setVariable("flowToBeCalled", flowToBeCalled);
-
- GenericVnf genericVnf = buildGenericVnf();
- ModelInfoGenericVnf modelInfoGenericVnf = genericVnf.getModelInfoGenericVnf();
- modelInfoGenericVnf.setMultiStageDesign("true");
- setGenericVnf().setModelInfoGenericVnf(modelInfoGenericVnf);
- setVfModule().setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
-
- BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
- buildingBlockDetail.setBuildingBlockName("CreateVfModuleBB");
- buildingBlockDetail.setId(1);
- buildingBlockDetail.setResourceType(ResourceType.VF_MODULE);
- buildingBlockDetail.setTargetAction(OrchestrationAction.CREATE);
-
- doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
-
- OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = new OrchestrationStatusStateTransitionDirective();
- orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS);
- orchestrationStatusStateTransitionDirective.setId(1);
- orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
- orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE);
- orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.CREATE);
-
- doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient).getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, OrchestrationStatus.ASSIGNED, OrchestrationAction.CREATE);
-
- orchestrationStatusValidator.validateOrchestrationStatus(execution);
-
- assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS, execution.getVariable("orchestrationStatusValidationResult"));
- }
-
- @Test
- public void test_validateOrchestrationStatusSecondStageOfMultiStageWrongTargetActionVfModule() throws Exception {
- String flowToBeCalled = "CreateVfModuleBB";
-
- execution.setVariable("orchestrationStatusValidationResult", OrchestrationStatusValidationDirective.SILENT_SUCCESS);
- execution.setVariable("aLaCarte", true);
- execution.setVariable("flowToBeCalled", flowToBeCalled);
-
- GenericVnf genericVnf = buildGenericVnf();
- ModelInfoGenericVnf modelInfoGenericVnf = genericVnf.getModelInfoGenericVnf();
- modelInfoGenericVnf.setMultiStageDesign("true");
- setGenericVnf().setModelInfoGenericVnf(modelInfoGenericVnf);
- setVfModule().setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
-
- BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
- buildingBlockDetail.setBuildingBlockName("CreateVfModuleBB");
- buildingBlockDetail.setId(1);
- buildingBlockDetail.setResourceType(ResourceType.VF_MODULE);
- buildingBlockDetail.setTargetAction(OrchestrationAction.ACTIVATE);
-
- doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
-
- OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = new OrchestrationStatusStateTransitionDirective();
- orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS);
- orchestrationStatusStateTransitionDirective.setId(1);
- orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
- orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE);
- orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.ACTIVATE);
-
- doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient).getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, OrchestrationStatus.PENDING_ACTIVATION, OrchestrationAction.ACTIVATE);
-
- orchestrationStatusValidator.validateOrchestrationStatus(execution);
-
- assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS, execution.getVariable("orchestrationStatusValidationResult"));
- }
-
- @Test
- public void test_validateOrchestrationStatusSecondStageOfMultiStageWrongAlacarteValueVfModule() throws Exception {
- String flowToBeCalled = "CreateVfModuleBB";
-
- execution.setVariable("orchestrationStatusValidationResult", OrchestrationStatusValidationDirective.SILENT_SUCCESS);
- execution.setVariable("aLaCarte", false);
- execution.setVariable("flowToBeCalled", flowToBeCalled);
-
- GenericVnf genericVnf = buildGenericVnf();
- ModelInfoGenericVnf modelInfoGenericVnf = genericVnf.getModelInfoGenericVnf();
- modelInfoGenericVnf.setMultiStageDesign("true");
- setGenericVnf().setModelInfoGenericVnf(modelInfoGenericVnf);
- setVfModule().setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
-
- BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
- buildingBlockDetail.setBuildingBlockName("CreateVfModuleBB");
- buildingBlockDetail.setId(1);
- buildingBlockDetail.setResourceType(ResourceType.VF_MODULE);
- buildingBlockDetail.setTargetAction(OrchestrationAction.CREATE);
-
- doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
-
- OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = new OrchestrationStatusStateTransitionDirective();
- orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS);
- orchestrationStatusStateTransitionDirective.setId(1);
- orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
- orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE);
- orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.ACTIVATE);
-
- doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient).getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, OrchestrationStatus.PENDING_ACTIVATION, OrchestrationAction.CREATE);
-
- orchestrationStatusValidator.validateOrchestrationStatus(execution);
-
- assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS, execution.getVariable("orchestrationStatusValidationResult"));
- }
+ @InjectMocks
+ protected OrchestrationStatusValidator orchestrationStatusValidator = new OrchestrationStatusValidator();
+
+
+
+ @Test
+ public void test_validateOrchestrationStatus() throws Exception {
+ String flowToBeCalled = "AssignServiceInstanceBB";
+ setServiceInstance().setOrchestrationStatus(OrchestrationStatus.PRECREATED);
+ execution.setVariable("aLaCarte", true);
+ execution.setVariable("flowToBeCalled", flowToBeCalled);
+
+ BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
+ buildingBlockDetail.setBuildingBlockName("AssignServiceInstanceBB");
+ buildingBlockDetail.setId(1);
+ buildingBlockDetail.setResourceType(ResourceType.SERVICE);
+ buildingBlockDetail.setTargetAction(OrchestrationAction.ASSIGN);
+
+ doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
+
+ OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective =
+ new OrchestrationStatusStateTransitionDirective();
+ orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.CONTINUE);
+ orchestrationStatusStateTransitionDirective.setId(1);
+ orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
+ orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.SERVICE);
+ orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.ASSIGN);
+
+ doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient)
+ .getOrchestrationStatusStateTransitionDirective(ResourceType.SERVICE, OrchestrationStatus.PRECREATED,
+ OrchestrationAction.ASSIGN);
+
+ orchestrationStatusValidator.validateOrchestrationStatus(execution);
+
+ assertEquals(OrchestrationStatusValidationDirective.CONTINUE,
+ execution.getVariable("orchestrationStatusValidationResult"));
+ }
+
+ @Test
+ public void test_validateOrchestrationStatusConfiguration() throws Exception {
+ lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "configurationId");
+ String flowToBeCalled = "UnassignFabricConfigurationBB";
+ ServiceInstance si = setServiceInstance();
+ List<Configuration> configurations = new ArrayList<>();
+ Configuration config = new Configuration();
+
+ si.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
+ config.setConfigurationId("configurationId");
+ config.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
+ configurations.add(config);
+ si.setConfigurations(configurations);
+
+ execution.setVariable("flowToBeCalled", flowToBeCalled);
+ execution.setVariable("aLaCarte", true);
+
+ BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
+ buildingBlockDetail.setBuildingBlockName("UnassignFabricConfigurationBB");
+ buildingBlockDetail.setId(1);
+ buildingBlockDetail.setResourceType(ResourceType.CONFIGURATION);
+ buildingBlockDetail.setTargetAction(OrchestrationAction.UNASSIGN);
+
+ doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
+
+ OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective =
+ new OrchestrationStatusStateTransitionDirective();
+ orchestrationStatusStateTransitionDirective
+ .setFlowDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS);
+ orchestrationStatusStateTransitionDirective.setId(1);
+ orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
+ orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.CONFIGURATION);
+ orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.UNASSIGN);
+
+ doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient)
+ .getOrchestrationStatusStateTransitionDirective(ResourceType.CONFIGURATION,
+ OrchestrationStatus.PRECREATED, OrchestrationAction.UNASSIGN);
+
+ orchestrationStatusValidator.validateOrchestrationStatus(execution);
+
+ assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS,
+ execution.getVariable("orchestrationStatusValidationResult"));
+ }
+
+ @Test
+ public void test_validateOrchestrationStatus_buildingBlockDetailNotFound() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ String flowToBeCalled = "AssignServiceInstanceBB";
+
+ execution.setVariable("flowToBeCalled", flowToBeCalled);
+
+ doReturn(null).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
+
+ orchestrationStatusValidator.validateOrchestrationStatus(execution);
+ }
+
+ @Test
+ public void test_validateOrchestrationStatus_orchestrationValidationFail() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ String flowToBeCalled = "AssignServiceInstanceBB";
+
+ execution.setVariable("flowToBeCalled", flowToBeCalled);
+
+ BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
+ buildingBlockDetail.setBuildingBlockName("AssignServiceInstanceBB");
+ buildingBlockDetail.setId(1);
+ buildingBlockDetail.setResourceType(ResourceType.SERVICE);
+ buildingBlockDetail.setTargetAction(OrchestrationAction.ASSIGN);
+
+ doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
+
+ OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective =
+ new OrchestrationStatusStateTransitionDirective();
+ orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.FAIL);
+ orchestrationStatusStateTransitionDirective.setId(1);
+ orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
+ orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.SERVICE);
+ orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.ASSIGN);
+
+ doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient)
+ .getOrchestrationStatusStateTransitionDirective(ResourceType.SERVICE, OrchestrationStatus.PRECREATED,
+ OrchestrationAction.ASSIGN);
+
+ orchestrationStatusValidator.validateOrchestrationStatus(execution);
+ }
+
+ @Test
+ public void test_validateOrchestrationStatus_orchestrationValidationNotFound() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ String flowToBeCalled = "AssignServiceInstanceBB";
+
+ execution.setVariable("flowToBeCalled", flowToBeCalled);
+
+ BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
+ buildingBlockDetail.setBuildingBlockName("AssignServiceInstanceBB");
+ buildingBlockDetail.setId(1);
+ buildingBlockDetail.setResourceType(ResourceType.SERVICE);
+ buildingBlockDetail.setTargetAction(OrchestrationAction.ASSIGN);
+
+ doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
+
+ OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective =
+ new OrchestrationStatusStateTransitionDirective();
+ orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.FAIL);
+ orchestrationStatusStateTransitionDirective.setId(1);
+ orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
+ orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.SERVICE);
+ orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.ASSIGN);
+
+ doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient)
+ .getOrchestrationStatusStateTransitionDirective(ResourceType.NETWORK, OrchestrationStatus.PRECREATED,
+ OrchestrationAction.ASSIGN);
+
+ orchestrationStatusValidator.validateOrchestrationStatus(execution);
+ }
+
+ @Test
+ public void test_validateOrchestrationStatus_unassignNotFound() throws Exception {
+ String flowToBeCalled = "UnassignServiceInstanceBB";
+
+ execution.setVariable("flowToBeCalled", flowToBeCalled);
+ execution.setVariable("aLaCarte", true);
+
+ BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
+ buildingBlockDetail.setBuildingBlockName("UnassignServiceInstanceBB");
+ buildingBlockDetail.setId(1);
+ buildingBlockDetail.setResourceType(ResourceType.SERVICE);
+ buildingBlockDetail.setTargetAction(OrchestrationAction.UNASSIGN);
+
+ doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
+
+ lookupKeyMap = new HashMap<ResourceKey, String>();
+
+ orchestrationStatusValidator.validateOrchestrationStatus(execution);
+
+ assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS,
+ execution.getVariable("orchestrationStatusValidationResult"));
+ }
+
+ @Test
+ public void test_validateOrchestrationStatusSecondStageOfMultiStageEnabledVfModule() throws Exception {
+ String flowToBeCalled = "CreateVfModuleBB";
+
+ execution.setVariable("orchestrationStatusValidationResult",
+ OrchestrationStatusValidationDirective.SILENT_SUCCESS);
+ execution.setVariable("aLaCarte", true);
+ execution.setVariable("flowToBeCalled", flowToBeCalled);
+
+ GenericVnf genericVnf = buildGenericVnf();
+ ModelInfoGenericVnf modelInfoGenericVnf = genericVnf.getModelInfoGenericVnf();
+ modelInfoGenericVnf.setMultiStageDesign("true");
+ setGenericVnf().setModelInfoGenericVnf(modelInfoGenericVnf);
+ setVfModule().setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
+
+ BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
+ buildingBlockDetail.setBuildingBlockName("CreateVfModuleBB");
+ buildingBlockDetail.setId(1);
+ buildingBlockDetail.setResourceType(ResourceType.VF_MODULE);
+ buildingBlockDetail.setTargetAction(OrchestrationAction.CREATE);
+
+ doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
+
+ OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective =
+ new OrchestrationStatusStateTransitionDirective();
+ orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.FAIL);
+ orchestrationStatusStateTransitionDirective.setId(1);
+ orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
+ orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE);
+ orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.CREATE);
+
+ doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient)
+ .getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE,
+ OrchestrationStatus.PENDING_ACTIVATION, OrchestrationAction.CREATE);
+
+ orchestrationStatusValidator.validateOrchestrationStatus(execution);
+
+ assertEquals(OrchestrationStatusValidationDirective.CONTINUE,
+ execution.getVariable("orchestrationStatusValidationResult"));
+ }
+
+
+ @Test
+ public void test_validateOrchestrationStatusSecondStageOfMultiStageWrongPrevStatusVfModule() throws Exception {
+ String flowToBeCalled = "CreateVfModuleBB";
+
+ execution.setVariable("orchestrationStatusValidationResult", OrchestrationStatusValidationDirective.CONTINUE);
+ execution.setVariable("aLaCarte", true);
+ execution.setVariable("flowToBeCalled", flowToBeCalled);
+
+ GenericVnf genericVnf = buildGenericVnf();
+ ModelInfoGenericVnf modelInfoGenericVnf = genericVnf.getModelInfoGenericVnf();
+ modelInfoGenericVnf.setMultiStageDesign("true");
+ setGenericVnf().setModelInfoGenericVnf(modelInfoGenericVnf);
+ setVfModule().setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
+
+ BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
+ buildingBlockDetail.setBuildingBlockName("CreateVfModuleBB");
+ buildingBlockDetail.setId(1);
+ buildingBlockDetail.setResourceType(ResourceType.VF_MODULE);
+ buildingBlockDetail.setTargetAction(OrchestrationAction.CREATE);
+
+ doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
+
+ OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective =
+ new OrchestrationStatusStateTransitionDirective();
+ orchestrationStatusStateTransitionDirective
+ .setFlowDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS);
+ orchestrationStatusStateTransitionDirective.setId(1);
+ orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
+ orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE);
+ orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.CREATE);
+
+ doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient)
+ .getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE,
+ OrchestrationStatus.PENDING_ACTIVATION, OrchestrationAction.CREATE);
+
+ orchestrationStatusValidator.validateOrchestrationStatus(execution);
+
+ assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS,
+ execution.getVariable("orchestrationStatusValidationResult"));
+ }
+
+ @Test
+ public void test_validateOrchestrationStatusSecondStageOfMultiStageDisabledVfModule() throws Exception {
+ String flowToBeCalled = "CreateVfModuleBB";
+
+ execution.setVariable("orchestrationStatusValidationResult",
+ OrchestrationStatusValidationDirective.SILENT_SUCCESS);
+ execution.setVariable("aLaCarte", true);
+ execution.setVariable("flowToBeCalled", flowToBeCalled);
+
+ GenericVnf genericVnf = buildGenericVnf();
+ ModelInfoGenericVnf modelInfoGenericVnf = genericVnf.getModelInfoGenericVnf();
+ modelInfoGenericVnf.setMultiStageDesign("false");
+ setGenericVnf().setModelInfoGenericVnf(modelInfoGenericVnf);
+ setVfModule().setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
+
+ BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
+ buildingBlockDetail.setBuildingBlockName("CreateVfModuleBB");
+ buildingBlockDetail.setId(1);
+ buildingBlockDetail.setResourceType(ResourceType.VF_MODULE);
+ buildingBlockDetail.setTargetAction(OrchestrationAction.CREATE);
+
+ doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
+
+ OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective =
+ new OrchestrationStatusStateTransitionDirective();
+ orchestrationStatusStateTransitionDirective
+ .setFlowDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS);
+ orchestrationStatusStateTransitionDirective.setId(1);
+ orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
+ orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE);
+ orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.CREATE);
+
+ doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient)
+ .getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE,
+ OrchestrationStatus.PENDING_ACTIVATION, OrchestrationAction.CREATE);
+
+ orchestrationStatusValidator.validateOrchestrationStatus(execution);
+
+ assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS,
+ execution.getVariable("orchestrationStatusValidationResult"));
+ }
+
+ @Test
+ public void test_validateOrchestrationStatusSecondStageOfMultiStageWrongOrchStatusVfModule() throws Exception {
+ String flowToBeCalled = "CreateVfModuleBB";
+
+ execution.setVariable("orchestrationStatusValidationResult",
+ OrchestrationStatusValidationDirective.SILENT_SUCCESS);
+ execution.setVariable("aLaCarte", true);
+ execution.setVariable("flowToBeCalled", flowToBeCalled);
+
+ GenericVnf genericVnf = buildGenericVnf();
+ ModelInfoGenericVnf modelInfoGenericVnf = genericVnf.getModelInfoGenericVnf();
+ modelInfoGenericVnf.setMultiStageDesign("true");
+ setGenericVnf().setModelInfoGenericVnf(modelInfoGenericVnf);
+ setVfModule().setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
+
+ BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
+ buildingBlockDetail.setBuildingBlockName("CreateVfModuleBB");
+ buildingBlockDetail.setId(1);
+ buildingBlockDetail.setResourceType(ResourceType.VF_MODULE);
+ buildingBlockDetail.setTargetAction(OrchestrationAction.CREATE);
+
+ doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
+
+ OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective =
+ new OrchestrationStatusStateTransitionDirective();
+ orchestrationStatusStateTransitionDirective
+ .setFlowDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS);
+ orchestrationStatusStateTransitionDirective.setId(1);
+ orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
+ orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE);
+ orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.CREATE);
+
+ doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient)
+ .getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, OrchestrationStatus.ASSIGNED,
+ OrchestrationAction.CREATE);
+
+ orchestrationStatusValidator.validateOrchestrationStatus(execution);
+
+ assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS,
+ execution.getVariable("orchestrationStatusValidationResult"));
+ }
+
+ @Test
+ public void test_validateOrchestrationStatusSecondStageOfMultiStageWrongTargetActionVfModule() throws Exception {
+ String flowToBeCalled = "CreateVfModuleBB";
+
+ execution.setVariable("orchestrationStatusValidationResult",
+ OrchestrationStatusValidationDirective.SILENT_SUCCESS);
+ execution.setVariable("aLaCarte", true);
+ execution.setVariable("flowToBeCalled", flowToBeCalled);
+
+ GenericVnf genericVnf = buildGenericVnf();
+ ModelInfoGenericVnf modelInfoGenericVnf = genericVnf.getModelInfoGenericVnf();
+ modelInfoGenericVnf.setMultiStageDesign("true");
+ setGenericVnf().setModelInfoGenericVnf(modelInfoGenericVnf);
+ setVfModule().setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
+
+ BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
+ buildingBlockDetail.setBuildingBlockName("CreateVfModuleBB");
+ buildingBlockDetail.setId(1);
+ buildingBlockDetail.setResourceType(ResourceType.VF_MODULE);
+ buildingBlockDetail.setTargetAction(OrchestrationAction.ACTIVATE);
+
+ doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
+
+ OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective =
+ new OrchestrationStatusStateTransitionDirective();
+ orchestrationStatusStateTransitionDirective
+ .setFlowDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS);
+ orchestrationStatusStateTransitionDirective.setId(1);
+ orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
+ orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE);
+ orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.ACTIVATE);
+
+ doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient)
+ .getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE,
+ OrchestrationStatus.PENDING_ACTIVATION, OrchestrationAction.ACTIVATE);
+
+ orchestrationStatusValidator.validateOrchestrationStatus(execution);
+
+ assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS,
+ execution.getVariable("orchestrationStatusValidationResult"));
+ }
+
+ @Test
+ public void test_validateOrchestrationStatusSecondStageOfMultiStageWrongAlacarteValueVfModule() throws Exception {
+ String flowToBeCalled = "CreateVfModuleBB";
+
+ execution.setVariable("orchestrationStatusValidationResult",
+ OrchestrationStatusValidationDirective.SILENT_SUCCESS);
+ execution.setVariable("aLaCarte", false);
+ execution.setVariable("flowToBeCalled", flowToBeCalled);
+
+ GenericVnf genericVnf = buildGenericVnf();
+ ModelInfoGenericVnf modelInfoGenericVnf = genericVnf.getModelInfoGenericVnf();
+ modelInfoGenericVnf.setMultiStageDesign("true");
+ setGenericVnf().setModelInfoGenericVnf(modelInfoGenericVnf);
+ setVfModule().setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
+
+ BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
+ buildingBlockDetail.setBuildingBlockName("CreateVfModuleBB");
+ buildingBlockDetail.setId(1);
+ buildingBlockDetail.setResourceType(ResourceType.VF_MODULE);
+ buildingBlockDetail.setTargetAction(OrchestrationAction.CREATE);
+
+ doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
+
+ OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective =
+ new OrchestrationStatusStateTransitionDirective();
+ orchestrationStatusStateTransitionDirective
+ .setFlowDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS);
+ orchestrationStatusStateTransitionDirective.setId(1);
+ orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
+ orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE);
+ orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.ACTIVATE);
+
+ doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient)
+ .getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE,
+ OrchestrationStatus.PENDING_ACTIVATION, OrchestrationAction.CREATE);
+
+ orchestrationStatusValidator.validateOrchestrationStatus(execution);
+
+ assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS,
+ execution.getVariable("orchestrationStatusValidationResult"));
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorUnitTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorUnitTest.java
index 03b39f57e5..0da683de62 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorUnitTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorUnitTest.java
@@ -23,7 +23,6 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.when;
-
import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -41,25 +40,27 @@ import org.onap.so.db.catalog.client.CatalogDbClient;
@RunWith(MockitoJUnitRunner.class)
public class OrchestrationStatusValidatorUnitTest {
- @Mock
- private CatalogDbClient catalogDbClient;
-
- @InjectMocks
- private OrchestrationStatusValidator validator;
- @Test
- public void skipValidationTest() {
- BuildingBlockDetail bbDetail = new BuildingBlockDetail();
- bbDetail.setBuildingBlockName("customBB");
- bbDetail.setResourceType(ResourceType.NO_VALIDATE);
- bbDetail.setTargetAction(OrchestrationAction.CUSTOM);
- when(catalogDbClient.getBuildingBlockDetail("customBB")).thenReturn(bbDetail);
- BuildingBlockExecution execution = new DelegateExecutionImpl(new DelegateExecutionFake());
- execution.setVariable("flowToBeCalled", "customBB");
- execution.setVariable("aLaCarte", false);
- validator.validateOrchestrationStatus(execution);
-
-
- assertThat(execution.getVariable("orchestrationStatusValidationResult"), equalTo(OrchestrationStatusValidationDirective.VALIDATION_SKIPPED));
- }
-
+ @Mock
+ private CatalogDbClient catalogDbClient;
+
+ @InjectMocks
+ private OrchestrationStatusValidator validator;
+
+ @Test
+ public void skipValidationTest() {
+ BuildingBlockDetail bbDetail = new BuildingBlockDetail();
+ bbDetail.setBuildingBlockName("customBB");
+ bbDetail.setResourceType(ResourceType.NO_VALIDATE);
+ bbDetail.setTargetAction(OrchestrationAction.CUSTOM);
+ when(catalogDbClient.getBuildingBlockDetail("customBB")).thenReturn(bbDetail);
+ BuildingBlockExecution execution = new DelegateExecutionImpl(new DelegateExecutionFake());
+ execution.setVariable("flowToBeCalled", "customBB");
+ execution.setVariable("aLaCarte", false);
+ validator.validateOrchestrationStatus(execution);
+
+
+ assertThat(execution.getVariable("orchestrationStatusValidationResult"),
+ equalTo(OrchestrationStatusValidationDirective.VALIDATION_SKIPPED));
+ }
+
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java
index 14261e876d..a6ce88f164 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java
@@ -26,7 +26,6 @@ import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.when;
-
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
import org.junit.Before;
@@ -42,105 +41,105 @@ import org.onap.so.bpmn.core.WorkflowException;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
import org.onap.so.db.request.beans.InfraActiveRequests;
-public class WorkflowActionBBFailureTest extends BaseTaskTest {
+public class WorkflowActionBBFailureTest extends BaseTaskTest {
+
+ @Mock
+ protected WorkflowAction workflowAction;
+
+ @InjectMocks
+ @Spy
+ protected WorkflowActionBBFailure workflowActionBBFailure;
+
+ @Mock
+ InfraActiveRequests reqMock;
+
+ private DelegateExecution execution;
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ @Before
+ public void before() throws Exception {
+ execution = new DelegateExecutionFake();
+ org.onap.aai.domain.yang.ServiceInstance servInstance = new org.onap.aai.domain.yang.ServiceInstance();
+ servInstance.setServiceInstanceId("TEST");
+ when(bbSetupUtils.getAAIServiceInstanceByName(anyString(), isA(Customer.class))).thenReturn(servInstance);
+ workflowAction.setBbInputSetupUtils(bbSetupUtils);
+ workflowAction.setBbInputSetup(bbInputSetup);
+ }
+
+ @Test
+ public void updateRequestStatusToFailed_Null_Rollback() {
+ String reqId = "reqId123";
+ execution.setVariable("mso-request-id", reqId);
+ execution.setVariable("retryCount", 3);
+ execution.setVariable("handlingCode", "Success");
+ execution.setVariable("gCurrentSequence", 1);
+ WorkflowException we = new WorkflowException("WorkflowAction", 1231, "Error Case");
+ execution.setVariable("WorkflowException", we);
+
+ doReturn(reqMock).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId);
+ workflowActionBBFailure.updateRequestStatusToFailed(execution);
+ Mockito.verify(reqMock, Mockito.times(1)).setStatusMessage("Error Case");
+ Mockito.verify(reqMock, Mockito.times(1)).setRequestStatus("FAILED");
+ Mockito.verify(reqMock, Mockito.times(1)).setProgress(Long.valueOf(100));
+ Mockito.verify(reqMock, Mockito.times(1)).setLastModifiedBy("CamundaBPMN");
+ }
+
+ @Test
+ public void updateRequestStatusToFailed() {
+ execution.setVariable("mso-request-id", "123");
+ execution.setVariable("isRollbackComplete", false);
+ execution.setVariable("isRollback", false);
+ InfraActiveRequests req = new InfraActiveRequests();
+ WorkflowException wfe = new WorkflowException("processKey123", 1, "error in test case");
+ execution.setVariable("WorkflowException", wfe);
+ doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId("123");
+ doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
+ workflowActionBBFailure.updateRequestStatusToFailed(execution);
+ String errorMsg = (String) execution.getVariable("ErrorMessage");
+ assertEquals("error in test case", errorMsg);
+ }
+
+ @Test
+ public void updateRequestStatusToFailedRollback() {
+ execution.setVariable("mso-request-id", "123");
+ execution.setVariable("isRollbackComplete", false);
+ execution.setVariable("isRollback", true);
+ InfraActiveRequests req = new InfraActiveRequests();
+ WorkflowException wfe = new WorkflowException("processKey123", 1, "error in rollback");
+ execution.setVariable("WorkflowException", wfe);
+ doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId("123");
+ doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
+ workflowActionBBFailure.updateRequestStatusToFailed(execution);
+ String errorMsg = (String) execution.getVariable("RollbackErrorMessage");
+ assertEquals("error in rollback", errorMsg);
+ }
+
+ @Test
+ public void updateRequestStatusToFailedRollbackCompleted() {
+ execution.setVariable("mso-request-id", "123");
+ execution.setVariable("isRollbackComplete", true);
+ execution.setVariable("isRollback", true);
+ InfraActiveRequests req = new InfraActiveRequests();
+ doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId("123");
+ doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
+ workflowActionBBFailure.updateRequestStatusToFailed(execution);
+ String errorMsg = (String) execution.getVariable("RollbackErrorMessage");
+ assertEquals("Rollback has been completed successfully.", errorMsg);
+ }
- @Mock
- protected WorkflowAction workflowAction;
-
- @InjectMocks
- @Spy
- protected WorkflowActionBBFailure workflowActionBBFailure;
-
- @Mock
- InfraActiveRequests reqMock;
-
- private DelegateExecution execution;
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- @Before
- public void before() throws Exception {
- execution = new DelegateExecutionFake();
- org.onap.aai.domain.yang.ServiceInstance servInstance = new org.onap.aai.domain.yang.ServiceInstance();
- servInstance.setServiceInstanceId("TEST");
- when(bbSetupUtils.getAAIServiceInstanceByName(anyString(), isA(Customer.class))).thenReturn(servInstance);
- workflowAction.setBbInputSetupUtils(bbSetupUtils);
- workflowAction.setBbInputSetup(bbInputSetup);
- }
-
- @Test
- public void updateRequestStatusToFailed_Null_Rollback(){
- String reqId = "reqId123";
- execution.setVariable("mso-request-id", reqId);
- execution.setVariable("retryCount", 3);
- execution.setVariable("handlingCode","Success");
- execution.setVariable("gCurrentSequence",1);
- WorkflowException we = new WorkflowException("WorkflowAction",1231,"Error Case");
- execution.setVariable("WorkflowException",we);
-
- doReturn(reqMock).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId);
- workflowActionBBFailure.updateRequestStatusToFailed(execution);
- Mockito.verify( reqMock, Mockito.times(1)).setStatusMessage("Error Case");
- Mockito.verify( reqMock, Mockito.times(1)).setRequestStatus("FAILED");
- Mockito.verify( reqMock, Mockito.times(1)).setProgress(Long.valueOf(100));
- Mockito.verify( reqMock, Mockito.times(1)).setLastModifiedBy("CamundaBPMN");
- }
-
- @Test
- public void updateRequestStatusToFailed(){
- execution.setVariable("mso-request-id", "123");
- execution.setVariable("isRollbackComplete", false);
- execution.setVariable("isRollback", false);
- InfraActiveRequests req = new InfraActiveRequests();
- WorkflowException wfe = new WorkflowException("processKey123", 1, "error in test case");
- execution.setVariable("WorkflowException", wfe);
- doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId("123");
- doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
- workflowActionBBFailure.updateRequestStatusToFailed(execution);
- String errorMsg = (String) execution.getVariable("ErrorMessage");
- assertEquals("error in test case", errorMsg);
- }
-
- @Test
- public void updateRequestStatusToFailedRollback(){
- execution.setVariable("mso-request-id", "123");
- execution.setVariable("isRollbackComplete", false);
- execution.setVariable("isRollback", true);
- InfraActiveRequests req = new InfraActiveRequests();
- WorkflowException wfe = new WorkflowException("processKey123", 1, "error in rollback");
- execution.setVariable("WorkflowException", wfe);
- doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId("123");
- doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
- workflowActionBBFailure.updateRequestStatusToFailed(execution);
- String errorMsg = (String) execution.getVariable("RollbackErrorMessage");
- assertEquals("error in rollback", errorMsg);
- }
-
- @Test
- public void updateRequestStatusToFailedRollbackCompleted(){
- execution.setVariable("mso-request-id", "123");
- execution.setVariable("isRollbackComplete", true);
- execution.setVariable("isRollback", true);
- InfraActiveRequests req = new InfraActiveRequests();
- doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId("123");
- doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
- workflowActionBBFailure.updateRequestStatusToFailed(execution);
- String errorMsg = (String) execution.getVariable("RollbackErrorMessage");
- assertEquals("Rollback has been completed successfully.", errorMsg);
- }
-
- @Test
- public void updateRequestStatusToFailedNoWorkflowException(){
- execution.setVariable("mso-request-id", "123");
- execution.setVariable("isRollbackComplete", false);
- execution.setVariable("isRollback", false);
- execution.setVariable("WorkflowExceptionErrorMessage", "error in test case");
- InfraActiveRequests req = new InfraActiveRequests();
- doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId("123");
- doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
- workflowActionBBFailure.updateRequestStatusToFailed(execution);
- String errorMsg = (String) execution.getVariable("ErrorMessage");
- assertEquals("error in test case", errorMsg);
- }
+ @Test
+ public void updateRequestStatusToFailedNoWorkflowException() {
+ execution.setVariable("mso-request-id", "123");
+ execution.setVariable("isRollbackComplete", false);
+ execution.setVariable("isRollback", false);
+ execution.setVariable("WorkflowExceptionErrorMessage", "error in test case");
+ InfraActiveRequests req = new InfraActiveRequests();
+ doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId("123");
+ doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
+ workflowActionBBFailure.updateRequestStatusToFailed(execution);
+ String errorMsg = (String) execution.getVariable("ErrorMessage");
+ assertEquals("error in test case", errorMsg);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java
index c5b4a482b7..029562a6e9 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java
@@ -27,10 +27,8 @@ import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.when;
-
import java.util.ArrayList;
import java.util.List;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
@@ -51,314 +49,315 @@ import org.springframework.core.env.Environment;
public class WorkflowActionBBTasksTest extends BaseTaskTest {
- @Mock
- protected WorkflowAction workflowAction;
-
- @Mock
- protected WorkflowActionBBFailure workflowActionBBFailure;
-
- @InjectMocks
- @Spy
- protected WorkflowActionBBTasks workflowActionBBTasks;
-
- @Mock
- InfraActiveRequests reqMock;
-
- private DelegateExecution execution;
-
- @Mock
- protected Environment environment;
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- @Before
- public void before() throws Exception {
- execution = new DelegateExecutionFake();
- org.onap.aai.domain.yang.ServiceInstance servInstance = new org.onap.aai.domain.yang.ServiceInstance();
- servInstance.setServiceInstanceId("TEST");
- when(bbSetupUtils.getAAIServiceInstanceByName(anyString(), anyObject())).thenReturn(servInstance);
- workflowAction.setBbInputSetupUtils(bbSetupUtils);
- workflowAction.setBbInputSetup(bbInputSetup);
- }
-
- @Test
- public void selectBBTest() throws Exception{
- String gAction = "Delete-Network-Collection";
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("requestAction", gAction);
- execution.setVariable("gCurrentSequence", 0);
- execution.setVariable("homing", false);
- execution.setVariable("calledHoming", false);
- List<ExecuteBuildingBlock> flowsToExecute = new ArrayList();
- ExecuteBuildingBlock ebb = new ExecuteBuildingBlock();
- flowsToExecute.add(ebb);
- execution.setVariable("flowsToExecute", flowsToExecute);
- workflowActionBBTasks.selectBB(execution);
- boolean success = (boolean) execution.getVariable("completed");
- int currentSequence = (int) execution.getVariable("gCurrentSequence");
- assertEquals(true,success);
- assertEquals(1,currentSequence);
- }
-
- @Test
- public void select2BBTest() throws Exception{
- String gAction = "Delete-Network-Collection";
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("requestAction", gAction);
- execution.setVariable("gCurrentSequence", 0);
- execution.setVariable("homing", false);
- execution.setVariable("calledHoming", false);
- List<ExecuteBuildingBlock> flowsToExecute = new ArrayList();
- ExecuteBuildingBlock ebb = new ExecuteBuildingBlock();
- ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
- flowsToExecute.add(ebb);
- flowsToExecute.add(ebb2);
- execution.setVariable("flowsToExecute", flowsToExecute);
- workflowActionBBTasks.selectBB(execution);
- boolean success = (boolean) execution.getVariable("completed");
- int currentSequence = (int) execution.getVariable("gCurrentSequence");
- assertEquals(false,success);
- assertEquals(1,currentSequence);
- }
-
- @Test
- public void updateRequestStatusToCompleteTest() throws Exception{
- String reqId = "reqId123";
- execution.setVariable("mso-request-id", reqId);
- execution.setVariable("requestAction", "createInstance");
- execution.setVariable("resourceName", "Service");
- execution.setVariable("aLaCarte", true);
- InfraActiveRequests req = new InfraActiveRequests();
- doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId);
- doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
- workflowActionBBTasks.updateRequestStatusToComplete(execution);
- assertEquals("ALaCarte-Service-createInstance request was executed correctly.",execution.getVariable("finalStatusMessage"));
- }
-
- @Test
- public void rollbackExecutionPathTest(){
- execution.setVariable("handlingCode", "Rollback");
- execution.setVariable("isRollback", false);
- List<ExecuteBuildingBlock> flowsToExecute = new ArrayList();
- ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock();
- BuildingBlock bb1 = new BuildingBlock();
- bb1.setBpmnFlowName("AssignVfModuleBB");
- ebb1.setBuildingBlock(bb1);
- flowsToExecute.add(ebb1);
- ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
- BuildingBlock bb2 = new BuildingBlock();
- bb2.setBpmnFlowName("CreateVfModuleBB");
- ebb2.setBuildingBlock(bb2);
- flowsToExecute.add(ebb2);
- ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock();
- BuildingBlock bb3 = new BuildingBlock();
- bb3.setBpmnFlowName("ActivateVfModuleBB");
- ebb3.setBuildingBlock(bb3);
- flowsToExecute.add(ebb3);
-
- execution.setVariable("flowsToExecute", flowsToExecute);
- execution.setVariable("gCurrentSequence", 3);
- doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class));
-
- workflowActionBBTasks.rollbackExecutionPath(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEquals(ebbs.get(0).getBuildingBlock().getBpmnFlowName(),"DeactivateVfModuleBB");
- assertEquals(ebbs.get(1).getBuildingBlock().getBpmnFlowName(),"DeleteVfModuleBB");
- assertEquals(ebbs.get(2).getBuildingBlock().getBpmnFlowName(),"UnassignVfModuleBB");
- assertEquals(0,execution.getVariable("gCurrentSequence"));
- }
-
- @Test
- public void rollbackExecutionPathUnfinishedFlowTest(){
- execution.setVariable("handlingCode", "Rollback");
- execution.setVariable("isRollback", false);
- List<ExecuteBuildingBlock> flowsToExecute = new ArrayList();
- ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock();
- BuildingBlock bb1 = new BuildingBlock();
- bb1.setBpmnFlowName("AssignVfModuleBB");
- ebb1.setBuildingBlock(bb1);
- flowsToExecute.add(ebb1);
- ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
- BuildingBlock bb2 = new BuildingBlock();
- bb2.setBpmnFlowName("CreateVfModuleBB");
- ebb2.setBuildingBlock(bb2);
- flowsToExecute.add(ebb2);
- ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock();
- BuildingBlock bb3 = new BuildingBlock();
- bb3.setBpmnFlowName("ActivateVfModuleBB");
- ebb3.setBuildingBlock(bb3);
- flowsToExecute.add(ebb3);
-
- execution.setVariable("flowsToExecute", flowsToExecute);
- execution.setVariable("gCurrentSequence", 2);
- doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class));
-
- workflowActionBBTasks.rollbackExecutionPath(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEquals(ebbs.get(0).getBuildingBlock().getBpmnFlowName(),"DeleteVfModuleBB");
- assertEquals(ebbs.get(1).getBuildingBlock().getBpmnFlowName(),"UnassignVfModuleBB");
- assertEquals(0,execution.getVariable("gCurrentSequence"));
- assertEquals(0,execution.getVariable("retryCount"));
- }
-
- @Test
- public void rollbackExecutionTest(){
- execution.setVariable("handlingCode", "Rollback");
- execution.setVariable("isRollback", false);
- List<ExecuteBuildingBlock> flowsToExecute = new ArrayList();
- ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock();
- BuildingBlock bb1 = new BuildingBlock();
- bb1.setBpmnFlowName("AssignServiceInstanceBB");
- ebb1.setBuildingBlock(bb1);
- flowsToExecute.add(ebb1);
- ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
- BuildingBlock bb2 = new BuildingBlock();
- bb2.setBpmnFlowName("CreateNetworkCollectionBB");
- ebb2.setBuildingBlock(bb2);
- flowsToExecute.add(ebb2);
- ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock();
- BuildingBlock bb3 = new BuildingBlock();
- bb3.setBpmnFlowName("AssignNetworkBB");
- ebb3.setBuildingBlock(bb3);
- flowsToExecute.add(ebb3);
- ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock();
- BuildingBlock bb4 = new BuildingBlock();
- bb4.setBpmnFlowName("CreateNetworkBB");
- ebb4.setBuildingBlock(bb4);
- flowsToExecute.add(ebb4);
-
- execution.setVariable("flowsToExecute", flowsToExecute);
- execution.setVariable("gCurrentSequence", 3);
- doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class));
-
- workflowActionBBTasks.rollbackExecutionPath(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEquals(ebbs.get(0).getBuildingBlock().getBpmnFlowName(),"UnassignNetworkBB");
- assertEquals(ebbs.get(1).getBuildingBlock().getBpmnFlowName(),"DeleteNetworkCollectionBB");
- assertEquals(ebbs.get(2).getBuildingBlock().getBpmnFlowName(),"UnassignServiceInstanceBB");
- assertEquals(0,execution.getVariable("gCurrentSequence"));
- }
-
- @Test
- public void rollbackExecutionRollbackToAssignedTest(){
- execution.setVariable("isRollback", false);
- execution.setVariable("handlingCode", "RollbackToAssigned");
- List<ExecuteBuildingBlock> flowsToExecute = new ArrayList();
- ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock();
- BuildingBlock bb1 = new BuildingBlock();
- bb1.setBpmnFlowName("AssignVfModuleBB");
- ebb1.setBuildingBlock(bb1);
- flowsToExecute.add(ebb1);
- ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
- BuildingBlock bb2 = new BuildingBlock();
- bb2.setBpmnFlowName("CreateVfModuleBB");
- ebb2.setBuildingBlock(bb2);
- flowsToExecute.add(ebb2);
- ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock();
- BuildingBlock bb3 = new BuildingBlock();
- bb3.setBpmnFlowName("ActivateVfModuleBB");
- ebb3.setBuildingBlock(bb3);
- flowsToExecute.add(ebb3);
-
- execution.setVariable("flowsToExecute", flowsToExecute);
- execution.setVariable("gCurrentSequence", 2);
-
- workflowActionBBTasks.rollbackExecutionPath(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEquals("DeleteVfModuleBB",ebbs.get(0).getBuildingBlock().getBpmnFlowName());
- assertEquals(0,execution.getVariable("gCurrentSequence"));
- assertEquals(1,ebbs.size());
- }
-
- @Test
- public void rollbackExecutionRollbackToCreatedTest(){
- execution.setVariable("isRollback", false);
- execution.setVariable("handlingCode", "RollbackToCreated");
- List<ExecuteBuildingBlock> flowsToExecute = new ArrayList();
- ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock();
- BuildingBlock bb1 = new BuildingBlock();
- bb1.setBpmnFlowName("AssignVfModuleBB");
- ebb1.setBuildingBlock(bb1);
- flowsToExecute.add(ebb1);
- ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
- BuildingBlock bb2 = new BuildingBlock();
- bb2.setBpmnFlowName("CreateVfModuleBB");
- ebb2.setBuildingBlock(bb2);
- flowsToExecute.add(ebb2);
- ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock();
- BuildingBlock bb3 = new BuildingBlock();
- bb3.setBpmnFlowName("ActivateVfModuleBB");
- ebb3.setBuildingBlock(bb3);
- flowsToExecute.add(ebb3);
-
- execution.setVariable("flowsToExecute", flowsToExecute);
- execution.setVariable("gCurrentSequence", 3);
-
- workflowActionBBTasks.rollbackExecutionPath(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEquals("DeactivateVfModuleBB",ebbs.get(0).getBuildingBlock().getBpmnFlowName());
- assertEquals(0,execution.getVariable("gCurrentSequence"));
- assertEquals(1,ebbs.size());
- }
-
- @Test
- public void checkRetryStatusTest(){
- String reqId = "reqId123";
- execution.setVariable("mso-request-id", reqId);
- doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class));
- doReturn("6").when(environment).getProperty("mso.rainyDay.maxRetries");
- execution.setVariable("handlingCode","Retry");
- execution.setVariable("retryCount", 1);
- execution.setVariable("gCurrentSequence",1);
- InfraActiveRequests req = new InfraActiveRequests();
- doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId);
- workflowActionBBTasks.checkRetryStatus(execution);
- assertEquals(0,execution.getVariable("gCurrentSequence"));
- }
-
- @Test
- public void checkRetryStatusTestExceededMaxRetries(){
- String reqId = "reqId123";
- execution.setVariable("mso-request-id", reqId);
- doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class));
- doReturn("6").when(environment).getProperty("mso.rainyDay.maxRetries");
- execution.setVariable("handlingCode","Retry");
- execution.setVariable("retryCount", 6);
- execution.setVariable("gCurrentSequence",1);
- InfraActiveRequests req = new InfraActiveRequests();
- doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId);
- try{
- workflowActionBBTasks.checkRetryStatus(execution);
- } catch (BpmnError e) {
- WorkflowException exception = (WorkflowException) execution.getVariable("WorkflowException");
- assertEquals("Exceeded maximum retries. Ending flow with status Abort",exception.getErrorMessage());
- }
- }
-
- @Test
- public void checkRetryStatusNoRetryTest(){
- String reqId = "reqId123";
- execution.setVariable("mso-request-id", reqId);
- execution.setVariable("retryCount", 3);
- execution.setVariable("handlingCode","Success");
- execution.setVariable("gCurrentSequence",1);
- InfraActiveRequests req = new InfraActiveRequests();
- doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId);
- workflowActionBBTasks.checkRetryStatus(execution);
- assertEquals(0,execution.getVariable("retryCount"));
- }
-
- @Test
- public void updateInstanceId(){
- String reqId = "req123";
- String instanceId = "123123123";
- execution.setVariable("mso-request-id", reqId);
- execution.setVariable("resourceId", instanceId);
- execution.setVariable("resourceType", WorkflowType.SERVICE);
- doReturn(reqMock).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId);
- doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
- workflowActionBBTasks.updateInstanceId(execution);
- Mockito.verify( reqMock, Mockito.times(1)).setServiceInstanceId(instanceId);
- }
+ @Mock
+ protected WorkflowAction workflowAction;
+
+ @Mock
+ protected WorkflowActionBBFailure workflowActionBBFailure;
+
+ @InjectMocks
+ @Spy
+ protected WorkflowActionBBTasks workflowActionBBTasks;
+
+ @Mock
+ InfraActiveRequests reqMock;
+
+ private DelegateExecution execution;
+
+ @Mock
+ protected Environment environment;
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ @Before
+ public void before() throws Exception {
+ execution = new DelegateExecutionFake();
+ org.onap.aai.domain.yang.ServiceInstance servInstance = new org.onap.aai.domain.yang.ServiceInstance();
+ servInstance.setServiceInstanceId("TEST");
+ when(bbSetupUtils.getAAIServiceInstanceByName(anyString(), anyObject())).thenReturn(servInstance);
+ workflowAction.setBbInputSetupUtils(bbSetupUtils);
+ workflowAction.setBbInputSetup(bbInputSetup);
+ }
+
+ @Test
+ public void selectBBTest() throws Exception {
+ String gAction = "Delete-Network-Collection";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ execution.setVariable("gCurrentSequence", 0);
+ execution.setVariable("homing", false);
+ execution.setVariable("calledHoming", false);
+ List<ExecuteBuildingBlock> flowsToExecute = new ArrayList();
+ ExecuteBuildingBlock ebb = new ExecuteBuildingBlock();
+ flowsToExecute.add(ebb);
+ execution.setVariable("flowsToExecute", flowsToExecute);
+ workflowActionBBTasks.selectBB(execution);
+ boolean success = (boolean) execution.getVariable("completed");
+ int currentSequence = (int) execution.getVariable("gCurrentSequence");
+ assertEquals(true, success);
+ assertEquals(1, currentSequence);
+ }
+
+ @Test
+ public void select2BBTest() throws Exception {
+ String gAction = "Delete-Network-Collection";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ execution.setVariable("gCurrentSequence", 0);
+ execution.setVariable("homing", false);
+ execution.setVariable("calledHoming", false);
+ List<ExecuteBuildingBlock> flowsToExecute = new ArrayList();
+ ExecuteBuildingBlock ebb = new ExecuteBuildingBlock();
+ ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
+ flowsToExecute.add(ebb);
+ flowsToExecute.add(ebb2);
+ execution.setVariable("flowsToExecute", flowsToExecute);
+ workflowActionBBTasks.selectBB(execution);
+ boolean success = (boolean) execution.getVariable("completed");
+ int currentSequence = (int) execution.getVariable("gCurrentSequence");
+ assertEquals(false, success);
+ assertEquals(1, currentSequence);
+ }
+
+ @Test
+ public void updateRequestStatusToCompleteTest() throws Exception {
+ String reqId = "reqId123";
+ execution.setVariable("mso-request-id", reqId);
+ execution.setVariable("requestAction", "createInstance");
+ execution.setVariable("resourceName", "Service");
+ execution.setVariable("aLaCarte", true);
+ InfraActiveRequests req = new InfraActiveRequests();
+ doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId);
+ doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
+ workflowActionBBTasks.updateRequestStatusToComplete(execution);
+ assertEquals("ALaCarte-Service-createInstance request was executed correctly.",
+ execution.getVariable("finalStatusMessage"));
+ }
+
+ @Test
+ public void rollbackExecutionPathTest() {
+ execution.setVariable("handlingCode", "Rollback");
+ execution.setVariable("isRollback", false);
+ List<ExecuteBuildingBlock> flowsToExecute = new ArrayList();
+ ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock();
+ BuildingBlock bb1 = new BuildingBlock();
+ bb1.setBpmnFlowName("AssignVfModuleBB");
+ ebb1.setBuildingBlock(bb1);
+ flowsToExecute.add(ebb1);
+ ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
+ BuildingBlock bb2 = new BuildingBlock();
+ bb2.setBpmnFlowName("CreateVfModuleBB");
+ ebb2.setBuildingBlock(bb2);
+ flowsToExecute.add(ebb2);
+ ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock();
+ BuildingBlock bb3 = new BuildingBlock();
+ bb3.setBpmnFlowName("ActivateVfModuleBB");
+ ebb3.setBuildingBlock(bb3);
+ flowsToExecute.add(ebb3);
+
+ execution.setVariable("flowsToExecute", flowsToExecute);
+ execution.setVariable("gCurrentSequence", 3);
+ doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class));
+
+ workflowActionBBTasks.rollbackExecutionPath(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEquals(ebbs.get(0).getBuildingBlock().getBpmnFlowName(), "DeactivateVfModuleBB");
+ assertEquals(ebbs.get(1).getBuildingBlock().getBpmnFlowName(), "DeleteVfModuleBB");
+ assertEquals(ebbs.get(2).getBuildingBlock().getBpmnFlowName(), "UnassignVfModuleBB");
+ assertEquals(0, execution.getVariable("gCurrentSequence"));
+ }
+
+ @Test
+ public void rollbackExecutionPathUnfinishedFlowTest() {
+ execution.setVariable("handlingCode", "Rollback");
+ execution.setVariable("isRollback", false);
+ List<ExecuteBuildingBlock> flowsToExecute = new ArrayList();
+ ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock();
+ BuildingBlock bb1 = new BuildingBlock();
+ bb1.setBpmnFlowName("AssignVfModuleBB");
+ ebb1.setBuildingBlock(bb1);
+ flowsToExecute.add(ebb1);
+ ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
+ BuildingBlock bb2 = new BuildingBlock();
+ bb2.setBpmnFlowName("CreateVfModuleBB");
+ ebb2.setBuildingBlock(bb2);
+ flowsToExecute.add(ebb2);
+ ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock();
+ BuildingBlock bb3 = new BuildingBlock();
+ bb3.setBpmnFlowName("ActivateVfModuleBB");
+ ebb3.setBuildingBlock(bb3);
+ flowsToExecute.add(ebb3);
+
+ execution.setVariable("flowsToExecute", flowsToExecute);
+ execution.setVariable("gCurrentSequence", 2);
+ doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class));
+
+ workflowActionBBTasks.rollbackExecutionPath(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEquals(ebbs.get(0).getBuildingBlock().getBpmnFlowName(), "DeleteVfModuleBB");
+ assertEquals(ebbs.get(1).getBuildingBlock().getBpmnFlowName(), "UnassignVfModuleBB");
+ assertEquals(0, execution.getVariable("gCurrentSequence"));
+ assertEquals(0, execution.getVariable("retryCount"));
+ }
+
+ @Test
+ public void rollbackExecutionTest() {
+ execution.setVariable("handlingCode", "Rollback");
+ execution.setVariable("isRollback", false);
+ List<ExecuteBuildingBlock> flowsToExecute = new ArrayList();
+ ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock();
+ BuildingBlock bb1 = new BuildingBlock();
+ bb1.setBpmnFlowName("AssignServiceInstanceBB");
+ ebb1.setBuildingBlock(bb1);
+ flowsToExecute.add(ebb1);
+ ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
+ BuildingBlock bb2 = new BuildingBlock();
+ bb2.setBpmnFlowName("CreateNetworkCollectionBB");
+ ebb2.setBuildingBlock(bb2);
+ flowsToExecute.add(ebb2);
+ ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock();
+ BuildingBlock bb3 = new BuildingBlock();
+ bb3.setBpmnFlowName("AssignNetworkBB");
+ ebb3.setBuildingBlock(bb3);
+ flowsToExecute.add(ebb3);
+ ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock();
+ BuildingBlock bb4 = new BuildingBlock();
+ bb4.setBpmnFlowName("CreateNetworkBB");
+ ebb4.setBuildingBlock(bb4);
+ flowsToExecute.add(ebb4);
+
+ execution.setVariable("flowsToExecute", flowsToExecute);
+ execution.setVariable("gCurrentSequence", 3);
+ doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class));
+
+ workflowActionBBTasks.rollbackExecutionPath(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEquals(ebbs.get(0).getBuildingBlock().getBpmnFlowName(), "UnassignNetworkBB");
+ assertEquals(ebbs.get(1).getBuildingBlock().getBpmnFlowName(), "DeleteNetworkCollectionBB");
+ assertEquals(ebbs.get(2).getBuildingBlock().getBpmnFlowName(), "UnassignServiceInstanceBB");
+ assertEquals(0, execution.getVariable("gCurrentSequence"));
+ }
+
+ @Test
+ public void rollbackExecutionRollbackToAssignedTest() {
+ execution.setVariable("isRollback", false);
+ execution.setVariable("handlingCode", "RollbackToAssigned");
+ List<ExecuteBuildingBlock> flowsToExecute = new ArrayList();
+ ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock();
+ BuildingBlock bb1 = new BuildingBlock();
+ bb1.setBpmnFlowName("AssignVfModuleBB");
+ ebb1.setBuildingBlock(bb1);
+ flowsToExecute.add(ebb1);
+ ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
+ BuildingBlock bb2 = new BuildingBlock();
+ bb2.setBpmnFlowName("CreateVfModuleBB");
+ ebb2.setBuildingBlock(bb2);
+ flowsToExecute.add(ebb2);
+ ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock();
+ BuildingBlock bb3 = new BuildingBlock();
+ bb3.setBpmnFlowName("ActivateVfModuleBB");
+ ebb3.setBuildingBlock(bb3);
+ flowsToExecute.add(ebb3);
+
+ execution.setVariable("flowsToExecute", flowsToExecute);
+ execution.setVariable("gCurrentSequence", 2);
+
+ workflowActionBBTasks.rollbackExecutionPath(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEquals("DeleteVfModuleBB", ebbs.get(0).getBuildingBlock().getBpmnFlowName());
+ assertEquals(0, execution.getVariable("gCurrentSequence"));
+ assertEquals(1, ebbs.size());
+ }
+
+ @Test
+ public void rollbackExecutionRollbackToCreatedTest() {
+ execution.setVariable("isRollback", false);
+ execution.setVariable("handlingCode", "RollbackToCreated");
+ List<ExecuteBuildingBlock> flowsToExecute = new ArrayList();
+ ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock();
+ BuildingBlock bb1 = new BuildingBlock();
+ bb1.setBpmnFlowName("AssignVfModuleBB");
+ ebb1.setBuildingBlock(bb1);
+ flowsToExecute.add(ebb1);
+ ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
+ BuildingBlock bb2 = new BuildingBlock();
+ bb2.setBpmnFlowName("CreateVfModuleBB");
+ ebb2.setBuildingBlock(bb2);
+ flowsToExecute.add(ebb2);
+ ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock();
+ BuildingBlock bb3 = new BuildingBlock();
+ bb3.setBpmnFlowName("ActivateVfModuleBB");
+ ebb3.setBuildingBlock(bb3);
+ flowsToExecute.add(ebb3);
+
+ execution.setVariable("flowsToExecute", flowsToExecute);
+ execution.setVariable("gCurrentSequence", 3);
+
+ workflowActionBBTasks.rollbackExecutionPath(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEquals("DeactivateVfModuleBB", ebbs.get(0).getBuildingBlock().getBpmnFlowName());
+ assertEquals(0, execution.getVariable("gCurrentSequence"));
+ assertEquals(1, ebbs.size());
+ }
+
+ @Test
+ public void checkRetryStatusTest() {
+ String reqId = "reqId123";
+ execution.setVariable("mso-request-id", reqId);
+ doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class));
+ doReturn("6").when(environment).getProperty("mso.rainyDay.maxRetries");
+ execution.setVariable("handlingCode", "Retry");
+ execution.setVariable("retryCount", 1);
+ execution.setVariable("gCurrentSequence", 1);
+ InfraActiveRequests req = new InfraActiveRequests();
+ doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId);
+ workflowActionBBTasks.checkRetryStatus(execution);
+ assertEquals(0, execution.getVariable("gCurrentSequence"));
+ }
+
+ @Test
+ public void checkRetryStatusTestExceededMaxRetries() {
+ String reqId = "reqId123";
+ execution.setVariable("mso-request-id", reqId);
+ doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class));
+ doReturn("6").when(environment).getProperty("mso.rainyDay.maxRetries");
+ execution.setVariable("handlingCode", "Retry");
+ execution.setVariable("retryCount", 6);
+ execution.setVariable("gCurrentSequence", 1);
+ InfraActiveRequests req = new InfraActiveRequests();
+ doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId);
+ try {
+ workflowActionBBTasks.checkRetryStatus(execution);
+ } catch (BpmnError e) {
+ WorkflowException exception = (WorkflowException) execution.getVariable("WorkflowException");
+ assertEquals("Exceeded maximum retries. Ending flow with status Abort", exception.getErrorMessage());
+ }
+ }
+
+ @Test
+ public void checkRetryStatusNoRetryTest() {
+ String reqId = "reqId123";
+ execution.setVariable("mso-request-id", reqId);
+ execution.setVariable("retryCount", 3);
+ execution.setVariable("handlingCode", "Success");
+ execution.setVariable("gCurrentSequence", 1);
+ InfraActiveRequests req = new InfraActiveRequests();
+ doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId);
+ workflowActionBBTasks.checkRetryStatus(execution);
+ assertEquals(0, execution.getVariable("retryCount"));
+ }
+
+ @Test
+ public void updateInstanceId() {
+ String reqId = "req123";
+ String instanceId = "123123123";
+ execution.setVariable("mso-request-id", reqId);
+ execution.setVariable("resourceId", instanceId);
+ execution.setVariable("resourceType", WorkflowType.SERVICE);
+ doReturn(reqMock).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId);
+ doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
+ workflowActionBBTasks.updateInstanceId(execution);
+ Mockito.verify(reqMock, Mockito.times(1)).setServiceInstanceId(instanceId);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksUpdateReqDbTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksUpdateReqDbTest.java
index 0f106ad913..9c3f0c6f0b 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksUpdateReqDbTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksUpdateReqDbTest.java
@@ -26,10 +26,8 @@ import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.when;
-
import java.util.ArrayList;
import java.util.List;
-
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
import org.junit.Before;
@@ -43,52 +41,53 @@ import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
import org.onap.so.db.request.beans.InfraActiveRequests;
-public class WorkflowActionBBTasksUpdateReqDbTest extends BaseTaskTest{
+public class WorkflowActionBBTasksUpdateReqDbTest extends BaseTaskTest {
+
+ protected WorkflowAction workflowAction = new WorkflowAction();
+
+ @Spy
+ @InjectMocks
+ protected WorkflowActionBBTasks workflowActionBBTasks;
+
+ private DelegateExecution execution;
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ @Before
+ public void before() throws Exception {
+ execution = new DelegateExecutionFake();
+ org.onap.aai.domain.yang.ServiceInstance servInstance = new org.onap.aai.domain.yang.ServiceInstance();
+ servInstance.setServiceInstanceId("TEST");
+ when(bbSetupUtils.getAAIServiceInstanceByName(anyString(), any())).thenReturn(servInstance);
+ workflowAction.setBbInputSetupUtils(bbSetupUtils);
+ workflowAction.setBbInputSetup(bbInputSetup);
+ }
- protected WorkflowAction workflowAction = new WorkflowAction();
-
- @Spy
- @InjectMocks
- protected WorkflowActionBBTasks workflowActionBBTasks;
-
- private DelegateExecution execution;
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- @Before
- public void before() throws Exception {
- execution = new DelegateExecutionFake();
- org.onap.aai.domain.yang.ServiceInstance servInstance = new org.onap.aai.domain.yang.ServiceInstance();
- servInstance.setServiceInstanceId("TEST");
- when(bbSetupUtils.getAAIServiceInstanceByName(anyString(), any())).thenReturn(servInstance);
- workflowAction.setBbInputSetupUtils(bbSetupUtils);
- workflowAction.setBbInputSetup(bbInputSetup);
- }
-
- @Test
- public void getUpdatedRequestTest() throws Exception{
- List<ExecuteBuildingBlock> flowsToExecute = new ArrayList();
- ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock();
- BuildingBlock bb1 = new BuildingBlock();
- bb1.setBpmnFlowName("CreateNetworkBB");
- flowsToExecute.add(ebb1);
- ebb1.setBuildingBlock(bb1);
- ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
- BuildingBlock bb2 = new BuildingBlock();
- bb2.setBpmnFlowName("ActivateNetworkBB");
- flowsToExecute.add(ebb2);
- ebb2.setBuildingBlock(bb2);
- String requestId = "requestId";
- execution.setVariable("mso-request-id", requestId);
- execution.setVariable("flowsToExecute", flowsToExecute);
- int currentSequence = 2;
- String expectedStatusMessage = "Execution of CreateNetworkBB has completed successfully, next invoking ActivateNetworkBB (Execution Path progress: BBs completed = 1; BBs remaining = 1).";
- Long expectedLong = new Long(52);
- InfraActiveRequests mockedRequest = new InfraActiveRequests();
- doReturn(mockedRequest).when(requestsDbClient).getInfraActiveRequestbyRequestId(isA(String.class));
- InfraActiveRequests actual = workflowActionBBTasks.getUpdatedRequest(execution, currentSequence);
- assertEquals(expectedStatusMessage, actual.getFlowStatus());
- assertEquals(expectedLong, actual.getProgress());
- }
+ @Test
+ public void getUpdatedRequestTest() throws Exception {
+ List<ExecuteBuildingBlock> flowsToExecute = new ArrayList();
+ ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock();
+ BuildingBlock bb1 = new BuildingBlock();
+ bb1.setBpmnFlowName("CreateNetworkBB");
+ flowsToExecute.add(ebb1);
+ ebb1.setBuildingBlock(bb1);
+ ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
+ BuildingBlock bb2 = new BuildingBlock();
+ bb2.setBpmnFlowName("ActivateNetworkBB");
+ flowsToExecute.add(ebb2);
+ ebb2.setBuildingBlock(bb2);
+ String requestId = "requestId";
+ execution.setVariable("mso-request-id", requestId);
+ execution.setVariable("flowsToExecute", flowsToExecute);
+ int currentSequence = 2;
+ String expectedStatusMessage =
+ "Execution of CreateNetworkBB has completed successfully, next invoking ActivateNetworkBB (Execution Path progress: BBs completed = 1; BBs remaining = 1).";
+ Long expectedLong = new Long(52);
+ InfraActiveRequests mockedRequest = new InfraActiveRequests();
+ doReturn(mockedRequest).when(requestsDbClient).getInfraActiveRequestbyRequestId(isA(String.class));
+ InfraActiveRequests actual = workflowActionBBTasks.getUpdatedRequest(execution, currentSequence);
+ assertEquals(expectedStatusMessage, actual.getFlowStatus());
+ assertEquals(expectedLong, actual.getProgress());
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java
index 87e6daa58a..ad1238b86f 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java
@@ -30,7 +30,6 @@ import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Matchers.isA;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.when;
-
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.net.MalformedURLException;
@@ -97,687 +96,808 @@ import org.onap.so.serviceinstancebeans.SubscriberInfo;
import org.springframework.core.env.Environment;
public class WorkflowActionTest extends BaseTaskTest {
-
-
- @Mock
- protected Environment environment;
- @InjectMocks
- protected WorkflowAction workflowAction;
- private DelegateExecution execution;
-
-
- @InjectMocks
- @Spy
- protected WorkflowAction SPY_workflowAction;
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- private String RESOURCE_PATH = "src/test/resources/__files/";
-
- @Before
- public void before() throws Exception {
- execution = new DelegateExecutionFake();
- org.onap.aai.domain.yang.ServiceInstance servInstance = new org.onap.aai.domain.yang.ServiceInstance();
- servInstance.setServiceInstanceId("TEST");
- when(bbSetupUtils.getAAIServiceInstanceByName(anyString(), anyObject())).thenReturn(servInstance);
- workflowAction.setBbInputSetupUtils(bbSetupUtils);
- workflowAction.setBbInputSetup(bbInputSetup);
- }
- /**
- * ALACARTE TESTS
- */
- @Test
- public void selectExecutionListALaCarteNetworkCreateTest() throws Exception{
- String gAction = "createInstance";
- String resource = "Network";
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("requestAction", gAction);
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json")));
- execution.setVariable("bpmnRequest", bpmnRequest);
- execution.setVariable("aLaCarte", true);
- execution.setVariable("apiVersion", "7");
- execution.setVariable("requestUri", "v6/networks/123");
-
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = createFlowList("AssignNetwork1802BB","CreateNetworkBB","ActivateNetworkBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
-
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
- workflowAction.selectExecutionList(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEqualsBulkFlowName(ebbs,"AssignNetwork1802BB","CreateNetworkBB","ActivateNetworkBB");
- }
-
- @Test
- public void selectExecutionListALaCarteNetworkDeleteTest() throws Exception{
- String gAction = "deleteInstance";
- String resource = "Network";
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("requestAction", gAction);
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json")));
- execution.setVariable("bpmnRequest", bpmnRequest);
- execution.setVariable("aLaCarte", true);
- execution.setVariable("apiVersion", "7");
- execution.setVariable("requestUri", "v6/networks/123");
-
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = createFlowList("DeactivateNetworkBB","DeleteNetworkBB","UnassignNetwork1802BB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
-
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,true,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
- workflowAction.selectExecutionList(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEqualsBulkFlowName(ebbs,"DeactivateNetworkBB","DeleteNetworkBB","UnassignNetwork1802BB");
- }
-
- @Test
- public void selectExecutionListALaCarteServiceCreateTest() throws Exception{
- String gAction = "createInstance";
- String resource = "Service";
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("requestAction", gAction);
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json")));
- execution.setVariable("bpmnRequest", bpmnRequest);
- execution.setVariable("aLaCarte", true);
- execution.setVariable("apiVersion", "7");
- execution.setVariable("requestUri", "v6/serviceInstances/123");
-
-
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB","ActivateServiceInstanceBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
-
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,true,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
- workflowAction.selectExecutionList(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEqualsBulkFlowName(ebbs,"AssignServiceInstanceBB","ActivateServiceInstanceBB");
- }
-
- /**
- * SERVICE MACRO TESTS
- */
- @Test
- public void selectExecutionListServiceMacroAssignTest() throws Exception{
- String gAction = "assignInstance";
- String resource = "Service";
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("requestAction", gAction);
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json")));
- execution.setVariable("bpmnRequest", bpmnRequest);
- execution.setVariable("aLaCarte", false);
- execution.setVariable("apiVersion", "7");
- execution.setVariable("requestUri", "v6/serviceInstances/123");
-
-
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB","AssignNetworkBB","AssignVnfBB","AssignVolumeGroupBB","AssignVfModuleBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
-
- VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
- vfModuleCustomization.setModelCustomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f");
- HeatEnvironment volumeHeatEnv = new HeatEnvironment();
- vfModuleCustomization.setVolumeHeatEnv(volumeHeatEnv);
- org.onap.so.db.catalog.beans.VfModule vfModule = new org.onap.so.db.catalog.beans.VfModule();
- HeatTemplate volumeHeatTemplate = new HeatTemplate();
- vfModule.setVolumeHeatTemplate(volumeHeatTemplate);
- vfModuleCustomization.setVfModule(vfModule);
-
- VfModuleCustomization vfModuleCustomization2 = new VfModuleCustomization();
- vfModuleCustomization2.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
- HeatEnvironment heatEnvironment = new HeatEnvironment();
- vfModuleCustomization2.setHeatEnvironment(heatEnvironment);
- org.onap.so.db.catalog.beans.VfModule vfModule2 = new org.onap.so.db.catalog.beans.VfModule();
- HeatTemplate moduleHeatTemplate = new HeatTemplate();
- vfModule2.setModuleHeatTemplate(moduleHeatTemplate);
- vfModuleCustomization2.setVfModule(vfModule2);
-
- VfModuleCustomization vfModuleCustomization3 = vfModuleCustomization2;
- vfModuleCustomization3.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
-
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,false,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
- when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f")).thenReturn(vfModuleCustomization);
- when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8")).thenReturn(vfModuleCustomization2);
- when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("da4d4327-fb7d-4311-ac7a-be7ba60cf969")).thenReturn(vfModuleCustomization3);
- workflowAction.selectExecutionList(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEqualsBulkFlowName(ebbs,"AssignServiceInstanceBB","AssignVnfBB","AssignVolumeGroupBB","AssignVfModuleBB","AssignVfModuleBB","AssignVfModuleBB");
- }
-
- @Test
- public void selectExecutionListServiceMacroAssignNoCloudTest() throws Exception{
- String gAction = "assignInstance";
- String resource = "Service";
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("requestAction", gAction);
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssignNoCloud.json")));
- execution.setVariable("bpmnRequest", bpmnRequest);
- execution.setVariable("aLaCarte", false);
- execution.setVariable("apiVersion", "7");
- execution.setVariable("requestUri", "v6/serviceInstances/123");
-
-
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB","AssignNetworkBB","AssignVnfBB","AssignVolumeGroupBB","AssignVfModuleBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
-
- VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
- vfModuleCustomization.setModelCustomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f");
- HeatEnvironment volumeHeatEnv = new HeatEnvironment();
- vfModuleCustomization.setVolumeHeatEnv(volumeHeatEnv);
- org.onap.so.db.catalog.beans.VfModule vfModule = new org.onap.so.db.catalog.beans.VfModule();
- HeatTemplate volumeHeatTemplate = new HeatTemplate();
- vfModule.setVolumeHeatTemplate(volumeHeatTemplate);
- vfModuleCustomization.setVfModule(vfModule);
-
- VfModuleCustomization vfModuleCustomization2 = new VfModuleCustomization();
- vfModuleCustomization2.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
- HeatEnvironment heatEnvironment = new HeatEnvironment();
- vfModuleCustomization2.setHeatEnvironment(heatEnvironment);
- org.onap.so.db.catalog.beans.VfModule vfModule2 = new org.onap.so.db.catalog.beans.VfModule();
- HeatTemplate moduleHeatTemplate = new HeatTemplate();
- vfModule2.setModuleHeatTemplate(moduleHeatTemplate);
- vfModuleCustomization2.setVfModule(vfModule2);
-
- VfModuleCustomization vfModuleCustomization3 = vfModuleCustomization2;
- vfModuleCustomization3.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
-
- when(environment.getProperty("org.onap.so.cloud-owner")).thenReturn("att-aic");
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,false,"att-aic")).thenReturn(northBoundRequest);
- when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f")).thenReturn(vfModuleCustomization);
- when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8")).thenReturn(vfModuleCustomization2);
- when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("da4d4327-fb7d-4311-ac7a-be7ba60cf969")).thenReturn(vfModuleCustomization3);
- workflowAction.selectExecutionList(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEqualsBulkFlowName(ebbs,"AssignServiceInstanceBB","AssignVnfBB","AssignVolumeGroupBB","AssignVfModuleBB","AssignVfModuleBB","AssignVfModuleBB");
- }
-
- @Test
- public void selectExecutionListServiceMacroActivateTest() throws Exception{
- String gAction = "activateInstance";
- String resource = "Service";
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("requestAction", gAction);
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json")));
- execution.setVariable("bpmnRequest", bpmnRequest);
- execution.setVariable("aLaCarte", false);
- execution.setVariable("apiVersion", "7");
- execution.setVariable("requestUri", "v6/serviceInstances/si0");
-
-
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = createFlowList("CreateNetworkBB","ActivateNetworkBB","CreateVolumeGroupBB","ActivateVolumeGroupBB","CreateVfModuleBB","ActivateVfModuleBB"
- ,"ActivateVnfBB","ActivateServiceInstanceBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
-
- ServiceInstance serviceInstanceAAI = new ServiceInstance();
- serviceInstanceAAI.setServiceInstanceId("si0");
- org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO = new org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance();
- org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf = new org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf();
- vnf.setVnfId("vnf0");
-
- org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
- vfModule.setVfModuleId("vfModule0");
- vnf.getVfModules().add(vfModule);
- org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule2 = new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
- vfModule2.setVfModuleId("vfModule1");
- vnf.getVfModules().add(vfModule2);
-
- org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup volumeGroup = new org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup();
- volumeGroup.setVolumeGroupId("volumeGroup0");
- vnf.getVolumeGroups().add(volumeGroup);
-
- serviceInstanceMSO.getVnfs().add(vnf);
-
- doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("si0");
- doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,false,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
- workflowAction.selectExecutionList(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEqualsBulkFlowName(ebbs,"CreateVolumeGroupBB","ActivateVolumeGroupBB","CreateVfModuleBB","CreateVfModuleBB","ActivateVfModuleBB","ActivateVfModuleBB","ActivateVnfBB","ActivateServiceInstanceBB");
- assertEquals("volumeGroup0", ebbs.get(0).getWorkflowResourceIds().getVolumeGroupId());
- assertEquals("volumeGroup0", ebbs.get(1).getWorkflowResourceIds().getVolumeGroupId());
- assertEquals("vfModule0", ebbs.get(2).getWorkflowResourceIds().getVfModuleId());
- assertEquals("vfModule1", ebbs.get(3).getWorkflowResourceIds().getVfModuleId());
- assertEquals("vfModule0", ebbs.get(4).getWorkflowResourceIds().getVfModuleId());
- assertEquals("vfModule1", ebbs.get(5).getWorkflowResourceIds().getVfModuleId());
- assertEquals("vnf0", ebbs.get(6).getWorkflowResourceIds().getVnfId());
- assertEquals("si0", ebbs.get(7).getWorkflowResourceIds().getServiceInstanceId());
-
- }
-
- @Test
- public void selectExecutionListServiceMacroDeactivateTest() throws Exception{
- String gAction = "deactivateInstance";
- String resource = "Service";
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("requestAction", gAction);
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json")));
- execution.setVariable("bpmnRequest", bpmnRequest);
- execution.setVariable("aLaCarte", false);
- execution.setVariable("apiVersion", "7");
- execution.setVariable("requestUri", "v6/serviceInstances/123");
-
-
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = createFlowList("DeactivateServiceInstanceBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
-
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,false,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
- workflowAction.selectExecutionList(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEquals(ebbs.get(0).getBuildingBlock().getBpmnFlowName(),"DeactivateServiceInstanceBB");
- }
-
- @Test
- public void selectExecutionListServiceMacroEmptyServiceTest() throws Exception{
- String gAction = "createInstance";
- String resource = "Service";
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("requestAction", gAction);
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json")));
- execution.setVariable("bpmnRequest", bpmnRequest);
- execution.setVariable("aLaCarte", false);
- execution.setVariable("apiVersion", "7");
- execution.setVariable("requestUri", "v6/serviceInstances/123");
-
-
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- northBoundRequest.setIsToplevelflow(true);
- List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB","CreateNetworkCollectionBB","AssignNetworkBB","AssignVnfBB","AssignVolumeGroupBB","AssignVfModuleBB"
- ,"CreateNetworkBB","ActivateNetworkBB","CreateVolumeGroupBB","ActivateVolumeGroupBB","CreateVfModuleBB","ActivateVfModuleBB","AssignFabricConfigurationBB","ActivateFabricConfigurationBB"
- ,"ActivateVnfBB","ActivateNetworkCollectionBB","ActivateServiceInstanceBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
-
- Service service = new Service();
- doReturn(service).when(catalogDbClient).getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a");
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,false,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
- workflowAction.selectExecutionList(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEqualsBulkFlowName(ebbs,"AssignServiceInstanceBB","ActivateServiceInstanceBB");
- }
-
- @Test
- public void selectExecutionListServiceMacroCreateJustNetworkTest() throws Exception{
- String gAction = "createInstance";
- String resource = "Service";
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("requestAction", gAction);
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json")));
- execution.setVariable("bpmnRequest", bpmnRequest);
- execution.setVariable("aLaCarte", false);
- execution.setVariable("apiVersion", "7");
- execution.setVariable("requestUri", "v6/serviceInstances/123");
-
-
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- northBoundRequest.setIsToplevelflow(true);
- List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB","CreateNetworkCollectionBB","AssignNetworkBB","AssignVnfBB","AssignVolumeGroupBB","AssignVfModuleBB"
- ,"CreateNetworkBB","ActivateNetworkBB","CreateVolumeGroupBB","ActivateVolumeGroupBB","CreateVfModuleBB","ActivateVfModuleBB","AssignFabricConfigurationBB","ActivateFabricConfigurationBB"
- ,"ActivateVnfBB","ActivateNetworkCollectionBB","ActivateServiceInstanceBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
-
- Service service = new Service();
- NetworkResourceCustomization networkCustomization = new NetworkResourceCustomization();
- networkCustomization.setModelCustomizationUUID("1234");
- service.getNetworkCustomizations().add(networkCustomization);
- doReturn(service).when(catalogDbClient).getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a");
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,false,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
- workflowAction.selectExecutionList(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEqualsBulkFlowName(ebbs,"AssignServiceInstanceBB","AssignNetworkBB","CreateNetworkBB","ActivateNetworkBB","ActivateServiceInstanceBB");
- }
-
- @Test
- public void selectExecutionListServiceMacroCreateWithNetworkCollectionTest() throws Exception{
- String gAction = "createInstance";
- String resource = "Service";
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("requestAction", gAction);
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json")));
- execution.setVariable("bpmnRequest", bpmnRequest);
- execution.setVariable("aLaCarte", false);
- execution.setVariable("apiVersion", "7");
- execution.setVariable("requestUri", "v6/serviceInstances/123");
-
-
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- northBoundRequest.setIsToplevelflow(true);
- List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB","CreateNetworkCollectionBB","AssignNetworkBB","AssignVnfBB","AssignVolumeGroupBB","AssignVfModuleBB"
- ,"CreateNetworkBB","ActivateNetworkBB","CreateVolumeGroupBB","ActivateVolumeGroupBB","CreateVfModuleBB","ActivateVfModuleBB","AssignFabricConfigurationBB","ActivateFabricConfigurationBB"
- ,"ActivateVnfBB","ActivateNetworkCollectionBB","ActivateServiceInstanceBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
-
- Service service = new Service();
- List<NetworkResourceCustomization> networkCustomizations = new ArrayList<>();
- NetworkResourceCustomization networkCust = new NetworkResourceCustomization();
- networkCust.setModelCustomizationUUID("123");
- networkCustomizations.add(networkCust);
- service.setNetworkCustomizations(networkCustomizations);
- NetworkCollectionResourceCustomization collectionResourceCustomization = new NetworkCollectionResourceCustomization();
- collectionResourceCustomization.setModelCustomizationUUID("123");
-
- CollectionResource collectionResource = new CollectionResource();
- collectionResource.setToscaNodeType("NetworkCollection");
- InstanceGroup instanceGroup = new InstanceGroup();
- instanceGroup.setToscaNodeType("NetworkCollectionResource");
- instanceGroup.setCollectionNetworkResourceCustomizations(new ArrayList<>());
- CollectionNetworkResourceCustomization collectionNetworkResourceCust = new CollectionNetworkResourceCustomization();
- collectionNetworkResourceCust.setModelCustomizationUUID("123");
- collectionNetworkResourceCust.setNetworkResourceCustomization(collectionResourceCustomization);
- instanceGroup.getCollectionNetworkResourceCustomizations().add(collectionNetworkResourceCust );
- List<CollectionResourceInstanceGroupCustomization> collectionInstanceGroupCustomizations = new ArrayList<>();
- CollectionResourceInstanceGroupCustomization collectionInstanceGroupCustomization = new CollectionResourceInstanceGroupCustomization();
- collectionInstanceGroupCustomization.setModelCustomizationUUID("123");
- collectionInstanceGroupCustomization.setSubInterfaceNetworkQuantity(3);
- collectionInstanceGroupCustomizations.add(collectionInstanceGroupCustomization);
- collectionInstanceGroupCustomization.setInstanceGroup(instanceGroup);
- collectionInstanceGroupCustomization.setCollectionResourceCust(collectionResourceCustomization);
- instanceGroup.setCollectionInstanceGroupCustomizations(collectionInstanceGroupCustomizations);
- collectionResource.setInstanceGroup(instanceGroup);
- collectionResourceCustomization.setCollectionResource(collectionResource);;
- service.getCollectionResourceCustomizations().add(collectionResourceCustomization);
- doReturn(service).when(catalogDbClient).getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a");
- doReturn(collectionResourceCustomization).when(catalogDbClient).getNetworkCollectionResourceCustomizationByID("123");
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,false,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
- workflowAction.selectExecutionList(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEqualsBulkFlowName(ebbs,"AssignServiceInstanceBB","CreateNetworkCollectionBB","AssignNetworkBB","CreateNetworkBB","ActivateNetworkBB","AssignNetworkBB","CreateNetworkBB","ActivateNetworkBB"
- ,"AssignNetworkBB","CreateNetworkBB","ActivateNetworkBB","ActivateNetworkCollectionBB","ActivateServiceInstanceBB");
- assertEquals("Network id not empty", !ebbs.get(2).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
- assertEquals("Network id not empty", !ebbs.get(3).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
- assertEquals("Network id not empty", !ebbs.get(4).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
- assertEquals("Network id same for AssignNetworkBB CreateNetworkBB ActivateNetworkBB",
- ebbs.get(2).getWorkflowResourceIds().getNetworkId() == ebbs.get(3).getWorkflowResourceIds().getNetworkId()
- && ebbs.get(3).getWorkflowResourceIds().getNetworkId() == ebbs.get(4).getWorkflowResourceIds().getNetworkId(), true);
- assertEquals("Network id not empty", !ebbs.get(5).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
- assertEquals("Network id not empty", !ebbs.get(6).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
- assertEquals("Network id not empty", !ebbs.get(7).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
- assertEquals("Network id same for AssignNetworkBB CreateNetworkBB ActivateNetworkBB",
- ebbs.get(5).getWorkflowResourceIds().getNetworkId() == ebbs.get(6).getWorkflowResourceIds().getNetworkId()
- && ebbs.get(6).getWorkflowResourceIds().getNetworkId() == ebbs.get(7).getWorkflowResourceIds().getNetworkId(), true);
- assertEquals("Network id not empty", !ebbs.get(8).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
- assertEquals("Network id not empty", !ebbs.get(9).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
- assertEquals("Network id not empty", !ebbs.get(10).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
- assertEquals("Network id same for AssignNetworkBB CreateNetworkBB ActivateNetworkBB",
- ebbs.get(8).getWorkflowResourceIds().getNetworkId() == ebbs.get(9).getWorkflowResourceIds().getNetworkId()
- && ebbs.get(9).getWorkflowResourceIds().getNetworkId() == ebbs.get(10).getWorkflowResourceIds().getNetworkId(), true);
- }
-
- @Test
- public void selectExecutionListServiceMacroCreateWithUserParams() throws Exception{
- String gAction = "createInstance";
- String resource = "Service";
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("requestAction", gAction);
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json")));
- execution.setVariable("bpmnRequest", bpmnRequest);
- execution.setVariable("aLaCarte", false);
- execution.setVariable("apiVersion", "7");
- execution.setVariable("requestUri", "v6/serviceInstances/123");
-
-
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB","CreateNetworkCollectionBB","AssignNetworkBB","AssignVnfBB","AssignVolumeGroupBB","AssignVfModuleBB"
- ,"CreateNetworkBB","ActivateNetworkBB","CreateVolumeGroupBB","ActivateVolumeGroupBB","CreateVfModuleBB","ActivateVfModuleBB","AssignFabricConfigurationBB","ActivateFabricConfigurationBB"
- ,"ActivateVnfBB","ActivateNetworkCollectionBB","ActivateServiceInstanceBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
-
- Service service = new Service();
- service.setModelUUID("3c40d244-808e-42ca-b09a-256d83d19d0a");
-
- VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
- vfModuleCustomization.setModelCustomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f");
- HeatEnvironment volumeHeatEnv = new HeatEnvironment();
- vfModuleCustomization.setVolumeHeatEnv(volumeHeatEnv);
- org.onap.so.db.catalog.beans.VfModule vfModule = new org.onap.so.db.catalog.beans.VfModule();
- HeatTemplate volumeHeatTemplate = new HeatTemplate();
- vfModule.setVolumeHeatTemplate(volumeHeatTemplate);
- vfModuleCustomization.setVfModule(vfModule);
-
- VfModuleCustomization vfModuleCustomization2 = new VfModuleCustomization();
- vfModuleCustomization2.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
- HeatEnvironment heatEnvironment = new HeatEnvironment();
- vfModuleCustomization2.setHeatEnvironment(heatEnvironment);
- org.onap.so.db.catalog.beans.VfModule vfModule2 = new org.onap.so.db.catalog.beans.VfModule();
- HeatTemplate moduleHeatTemplate = new HeatTemplate();
- vfModule2.setModuleHeatTemplate(moduleHeatTemplate);
- vfModuleCustomization2.setVfModule(vfModule2);
-
- VfModuleCustomization vfModuleCustomization3 = vfModuleCustomization2;
- vfModuleCustomization3.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
-
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,false,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
- when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f")).thenReturn(vfModuleCustomization);
- when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8")).thenReturn(vfModuleCustomization2);
- when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("da4d4327-fb7d-4311-ac7a-be7ba60cf969")).thenReturn(vfModuleCustomization3);
- when(catalogDbClient.getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a")).thenReturn(service);
- workflowAction.selectExecutionList(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEqualsBulkFlowName(ebbs,"AssignServiceInstanceBB","AssignVnfBB","AssignVolumeGroupBB","AssignVfModuleBB","AssignVfModuleBB","AssignVfModuleBB","CreateVolumeGroupBB"
- ,"ActivateVolumeGroupBB","CreateVfModuleBB","CreateVfModuleBB","CreateVfModuleBB","ActivateVfModuleBB","ActivateVfModuleBB","ActivateVfModuleBB","ActivateVnfBB","ActivateServiceInstanceBB");
- assertEquals(3,ebbs.get(0).getWorkflowResourceIds().getServiceInstanceId().length());
- int randomUUIDLength = UUID.randomUUID().toString().length();
- assertEquals(randomUUIDLength,ebbs.get(1).getWorkflowResourceIds().getVnfId().length());
- assertEquals(randomUUIDLength,ebbs.get(2).getWorkflowResourceIds().getVolumeGroupId().length());
- assertEquals(randomUUIDLength,ebbs.get(3).getWorkflowResourceIds().getVfModuleId().length());
- assertEquals(randomUUIDLength,ebbs.get(4).getWorkflowResourceIds().getVfModuleId().length());
- assertEquals(randomUUIDLength,ebbs.get(5).getWorkflowResourceIds().getVfModuleId().length());
- assertEquals(randomUUIDLength,ebbs.get(6).getWorkflowResourceIds().getVolumeGroupId().length());
- assertEquals(randomUUIDLength,ebbs.get(7).getWorkflowResourceIds().getVolumeGroupId().length());
- assertEquals(randomUUIDLength,ebbs.get(8).getWorkflowResourceIds().getVfModuleId().length());
- assertEquals(randomUUIDLength,ebbs.get(9).getWorkflowResourceIds().getVfModuleId().length());
- assertEquals(randomUUIDLength,ebbs.get(10).getWorkflowResourceIds().getVfModuleId().length());
- assertEquals(randomUUIDLength,ebbs.get(11).getWorkflowResourceIds().getVfModuleId().length());
- assertEquals(randomUUIDLength,ebbs.get(12).getWorkflowResourceIds().getVfModuleId().length());
- assertEquals(randomUUIDLength,ebbs.get(13).getWorkflowResourceIds().getVfModuleId().length());
- assertEquals(randomUUIDLength,ebbs.get(14).getWorkflowResourceIds().getVnfId().length());
- assertEquals(3,ebbs.get(0).getWorkflowResourceIds().getServiceInstanceId().length());
- assertEquals(true, execution.getVariable("homing"));
- }
-
- @Test
- public void selectExecutionListServiceMacroDeleteTest() throws Exception{
- String gAction = "deleteInstance";
- String resource = "Service";
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("requestAction", gAction);
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json")));
- execution.setVariable("bpmnRequest", bpmnRequest);
- execution.setVariable("aLaCarte", false);
- execution.setVariable("apiVersion", "7");
- execution.setVariable("requestUri", "v6/serviceInstances/123");
-
-
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB","DeleteVfModuleBB","DeactivateVolumeGroupBB","DeleteVolumeGroupBB","DeactivateVnfBB","DeactivateNetworkBB"
- ,"DeleteNetworkBB","DeleteNetworkCollectionBB","DeactivateServiceInstanceBB","UnassignVfModuleBB","UnassignVolumeGroupBB","UnassignVnfBB","UnassignNetworkBB","UnassignServiceInstanceBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
-
- ServiceInstance serviceInstanceAAI = new ServiceInstance();
- serviceInstanceAAI.setServiceInstanceId("aaisi123");
- org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO = new org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance();
- org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf = new org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf();
- vnf.setVnfId("vnfId123");
-
- org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
- vfModule.setVfModuleId("vfModule1");
- vnf.getVfModules().add(vfModule);
- org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule2 = new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
- vfModule2.setVfModuleId("vfModule2");
- vnf.getVfModules().add(vfModule2);
-
- org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup volumeGroup = new org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup();
- volumeGroup.setVolumeGroupId("vg123");
- vnf.getVolumeGroups().add(volumeGroup);
-
- serviceInstanceMSO.getVnfs().add(vnf);
-
- doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("123");
- doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,false,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
- workflowAction.selectExecutionList(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEqualsBulkFlowName(ebbs,"DeactivateVfModuleBB","DeactivateVfModuleBB","DeleteVfModuleBB","DeleteVfModuleBB","DeactivateVolumeGroupBB","DeleteVolumeGroupBB","DeactivateVnfBB"
- ,"DeactivateServiceInstanceBB","UnassignVfModuleBB","UnassignVfModuleBB","UnassignVolumeGroupBB","UnassignVnfBB","UnassignServiceInstanceBB");
- }
-
- @Test
- public void selectExecutionListServiceMacroUnassignTest() throws Exception{
- String gAction = "unassignInstance";
- String resource = "Service";
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("requestAction", gAction);
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json")));
- execution.setVariable("bpmnRequest", bpmnRequest);
- execution.setVariable("aLaCarte", false);
- execution.setVariable("apiVersion", "7");
- execution.setVariable("requestUri", "v6/serviceInstances/123");
-
-
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = createFlowList("UnassignVfModuleBB","UnassignVolumeGroupBB","UnassignVnfBB","UnassignNetworkBB","UnassignServiceInstanceBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
-
- ServiceInstance serviceInstanceAAI = new ServiceInstance();
- serviceInstanceAAI.setServiceInstanceId("aaisi123");
- org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO = new org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance();
- org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf = new org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf();
- vnf.setVnfId("vnfId123");
-
- org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
- vfModule.setVfModuleId("vfModule1");
- vnf.getVfModules().add(vfModule);
- org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule2 = new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
- vfModule2.setVfModuleId("vfModule2");
- vnf.getVfModules().add(vfModule2);
-
- org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup volumeGroup = new org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup();
- volumeGroup.setVolumeGroupId("vg123");
- vnf.getVolumeGroups().add(volumeGroup);
-
- serviceInstanceMSO.getVnfs().add(vnf);
-
- doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("123");
- doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,false,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
- workflowAction.selectExecutionList(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEqualsBulkFlowName(ebbs,"UnassignVfModuleBB","UnassignVfModuleBB","UnassignVolumeGroupBB","UnassignVnfBB","UnassignServiceInstanceBB");
- }
-
- @Test
- public void selectExecutionListServiceMacroDeleteNetworkCollectionTest() throws Exception{
- String gAction = "deleteInstance";
- String resource = "Service";
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("requestAction", gAction);
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json")));
- execution.setVariable("bpmnRequest", bpmnRequest);
- execution.setVariable("aLaCarte", false);
- execution.setVariable("apiVersion", "7");
- execution.setVariable("requestUri", "v6/serviceInstances/123");
-
-
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB","DeleteVfModuleBB","DeactivateVolumeGroupBB","DeleteVolumeGroupBB","DeactivateVnfBB","DeactivateNetworkBB"
- ,"DeleteNetworkBB","DeleteNetworkCollectionBB","DeactivateServiceInstanceBB","UnassignVfModuleBB","UnassignVolumeGroupBB","UnassignVnfBB","UnassignNetworkBB","UnassignServiceInstanceBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
-
- ServiceInstance serviceInstanceAAI = new ServiceInstance();
- serviceInstanceAAI.setServiceInstanceId("aaisi123");
- org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO = new org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance();
-
- org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network network = new org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network();
- network.setNetworkId("123");
- serviceInstanceMSO.getNetworks().add(network);
- org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network network2 = new org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network();
- network2.setNetworkId("321");
- serviceInstanceMSO.getNetworks().add(network2);
-
- Collection collection = new Collection();
- serviceInstanceMSO.setCollection(collection);
-
- doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("123");
- doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,false,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
- workflowAction.selectExecutionList(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEqualsBulkFlowName(ebbs,"DeactivateNetworkBB","DeleteNetworkBB","UnassignNetworkBB","DeactivateNetworkBB","DeleteNetworkBB","UnassignNetworkBB","DeleteNetworkCollectionBB"
- ,"DeactivateServiceInstanceBB","UnassignServiceInstanceBB");
- }
-
+
+
+ @Mock
+ protected Environment environment;
+ @InjectMocks
+ protected WorkflowAction workflowAction;
+ private DelegateExecution execution;
+
+
+ @InjectMocks
+ @Spy
+ protected WorkflowAction SPY_workflowAction;
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private String RESOURCE_PATH = "src/test/resources/__files/";
+
+ @Before
+ public void before() throws Exception {
+ execution = new DelegateExecutionFake();
+ org.onap.aai.domain.yang.ServiceInstance servInstance = new org.onap.aai.domain.yang.ServiceInstance();
+ servInstance.setServiceInstanceId("TEST");
+ when(bbSetupUtils.getAAIServiceInstanceByName(anyString(), anyObject())).thenReturn(servInstance);
+ workflowAction.setBbInputSetupUtils(bbSetupUtils);
+ workflowAction.setBbInputSetup(bbInputSetup);
+ }
+
+ /**
+ * ALACARTE TESTS
+ */
+ @Test
+ public void selectExecutionListALaCarteNetworkCreateTest() throws Exception {
+ String gAction = "createInstance";
+ String resource = "Network";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest =
+ new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", true);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri", "v6/networks/123");
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows =
+ createFlowList("AssignNetwork1802BB", "CreateNetworkBB", "ActivateNetworkBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEqualsBulkFlowName(ebbs, "AssignNetwork1802BB", "CreateNetworkBB", "ActivateNetworkBB");
+ }
+
+ @Test
+ public void selectExecutionListALaCarteNetworkDeleteTest() throws Exception {
+ String gAction = "deleteInstance";
+ String resource = "Network";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest =
+ new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", true);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri", "v6/networks/123");
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows =
+ createFlowList("DeactivateNetworkBB", "DeleteNetworkBB", "UnassignNetwork1802BB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEqualsBulkFlowName(ebbs, "DeactivateNetworkBB", "DeleteNetworkBB", "UnassignNetwork1802BB");
+ }
+
+ @Test
+ public void selectExecutionListALaCarteServiceCreateTest() throws Exception {
+ String gAction = "createInstance";
+ String resource = "Service";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest =
+ new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", true);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri", "v6/serviceInstances/123");
+
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB", "ActivateServiceInstanceBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEqualsBulkFlowName(ebbs, "AssignServiceInstanceBB", "ActivateServiceInstanceBB");
+ }
+
+ /**
+ * SERVICE MACRO TESTS
+ */
+ @Test
+ public void selectExecutionListServiceMacroAssignTest() throws Exception {
+ String gAction = "assignInstance";
+ String resource = "Service";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest =
+ new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", false);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri", "v6/serviceInstances/123");
+
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB", "AssignNetworkBB", "AssignVnfBB",
+ "AssignVolumeGroupBB", "AssignVfModuleBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
+ vfModuleCustomization.setModelCustomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f");
+ HeatEnvironment volumeHeatEnv = new HeatEnvironment();
+ vfModuleCustomization.setVolumeHeatEnv(volumeHeatEnv);
+ org.onap.so.db.catalog.beans.VfModule vfModule = new org.onap.so.db.catalog.beans.VfModule();
+ HeatTemplate volumeHeatTemplate = new HeatTemplate();
+ vfModule.setVolumeHeatTemplate(volumeHeatTemplate);
+ vfModuleCustomization.setVfModule(vfModule);
+
+ VfModuleCustomization vfModuleCustomization2 = new VfModuleCustomization();
+ vfModuleCustomization2.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
+ HeatEnvironment heatEnvironment = new HeatEnvironment();
+ vfModuleCustomization2.setHeatEnvironment(heatEnvironment);
+ org.onap.so.db.catalog.beans.VfModule vfModule2 = new org.onap.so.db.catalog.beans.VfModule();
+ HeatTemplate moduleHeatTemplate = new HeatTemplate();
+ vfModule2.setModuleHeatTemplate(moduleHeatTemplate);
+ vfModuleCustomization2.setVfModule(vfModule2);
+
+ VfModuleCustomization vfModuleCustomization3 = vfModuleCustomization2;
+ vfModuleCustomization3.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
+
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f"))
+ .thenReturn(vfModuleCustomization);
+ when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8"))
+ .thenReturn(vfModuleCustomization2);
+ when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("da4d4327-fb7d-4311-ac7a-be7ba60cf969"))
+ .thenReturn(vfModuleCustomization3);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEqualsBulkFlowName(ebbs, "AssignServiceInstanceBB", "AssignVnfBB", "AssignVolumeGroupBB",
+ "AssignVfModuleBB", "AssignVfModuleBB", "AssignVfModuleBB");
+ }
+
+ @Test
+ public void selectExecutionListServiceMacroAssignNoCloudTest() throws Exception {
+ String gAction = "assignInstance";
+ String resource = "Service";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest = new String(
+ Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssignNoCloud.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", false);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri", "v6/serviceInstances/123");
+
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB", "AssignNetworkBB", "AssignVnfBB",
+ "AssignVolumeGroupBB", "AssignVfModuleBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
+ vfModuleCustomization.setModelCustomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f");
+ HeatEnvironment volumeHeatEnv = new HeatEnvironment();
+ vfModuleCustomization.setVolumeHeatEnv(volumeHeatEnv);
+ org.onap.so.db.catalog.beans.VfModule vfModule = new org.onap.so.db.catalog.beans.VfModule();
+ HeatTemplate volumeHeatTemplate = new HeatTemplate();
+ vfModule.setVolumeHeatTemplate(volumeHeatTemplate);
+ vfModuleCustomization.setVfModule(vfModule);
+
+ VfModuleCustomization vfModuleCustomization2 = new VfModuleCustomization();
+ vfModuleCustomization2.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
+ HeatEnvironment heatEnvironment = new HeatEnvironment();
+ vfModuleCustomization2.setHeatEnvironment(heatEnvironment);
+ org.onap.so.db.catalog.beans.VfModule vfModule2 = new org.onap.so.db.catalog.beans.VfModule();
+ HeatTemplate moduleHeatTemplate = new HeatTemplate();
+ vfModule2.setModuleHeatTemplate(moduleHeatTemplate);
+ vfModuleCustomization2.setVfModule(vfModule2);
+
+ VfModuleCustomization vfModuleCustomization3 = vfModuleCustomization2;
+ vfModuleCustomization3.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
+
+ when(environment.getProperty("org.onap.so.cloud-owner")).thenReturn("att-aic");
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ false, "att-aic")).thenReturn(northBoundRequest);
+ when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f"))
+ .thenReturn(vfModuleCustomization);
+ when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8"))
+ .thenReturn(vfModuleCustomization2);
+ when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("da4d4327-fb7d-4311-ac7a-be7ba60cf969"))
+ .thenReturn(vfModuleCustomization3);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEqualsBulkFlowName(ebbs, "AssignServiceInstanceBB", "AssignVnfBB", "AssignVolumeGroupBB",
+ "AssignVfModuleBB", "AssignVfModuleBB", "AssignVfModuleBB");
+ }
+
+ @Test
+ public void selectExecutionListServiceMacroActivateTest() throws Exception {
+ String gAction = "activateInstance";
+ String resource = "Service";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest = new String(Files
+ .readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", false);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri", "v6/serviceInstances/si0");
+
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows =
+ createFlowList("CreateNetworkBB", "ActivateNetworkBB", "CreateVolumeGroupBB", "ActivateVolumeGroupBB",
+ "CreateVfModuleBB", "ActivateVfModuleBB", "ActivateVnfBB", "ActivateServiceInstanceBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ ServiceInstance serviceInstanceAAI = new ServiceInstance();
+ serviceInstanceAAI.setServiceInstanceId("si0");
+ org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance();
+ org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf();
+ vnf.setVnfId("vnf0");
+
+ org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
+ vfModule.setVfModuleId("vfModule0");
+ vnf.getVfModules().add(vfModule);
+ org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule2 =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
+ vfModule2.setVfModuleId("vfModule1");
+ vnf.getVfModules().add(vfModule2);
+
+ org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup volumeGroup =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup();
+ volumeGroup.setVolumeGroupId("volumeGroup0");
+ vnf.getVolumeGroups().add(volumeGroup);
+
+ serviceInstanceMSO.getVnfs().add(vnf);
+
+ doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("si0");
+ doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEqualsBulkFlowName(ebbs, "CreateVolumeGroupBB", "ActivateVolumeGroupBB", "CreateVfModuleBB",
+ "CreateVfModuleBB", "ActivateVfModuleBB", "ActivateVfModuleBB", "ActivateVnfBB",
+ "ActivateServiceInstanceBB");
+ assertEquals("volumeGroup0", ebbs.get(0).getWorkflowResourceIds().getVolumeGroupId());
+ assertEquals("volumeGroup0", ebbs.get(1).getWorkflowResourceIds().getVolumeGroupId());
+ assertEquals("vfModule0", ebbs.get(2).getWorkflowResourceIds().getVfModuleId());
+ assertEquals("vfModule1", ebbs.get(3).getWorkflowResourceIds().getVfModuleId());
+ assertEquals("vfModule0", ebbs.get(4).getWorkflowResourceIds().getVfModuleId());
+ assertEquals("vfModule1", ebbs.get(5).getWorkflowResourceIds().getVfModuleId());
+ assertEquals("vnf0", ebbs.get(6).getWorkflowResourceIds().getVnfId());
+ assertEquals("si0", ebbs.get(7).getWorkflowResourceIds().getServiceInstanceId());
+
+ }
+
+ @Test
+ public void selectExecutionListServiceMacroDeactivateTest() throws Exception {
+ String gAction = "deactivateInstance";
+ String resource = "Service";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest = new String(Files
+ .readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", false);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri", "v6/serviceInstances/123");
+
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows = createFlowList("DeactivateServiceInstanceBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEquals(ebbs.get(0).getBuildingBlock().getBpmnFlowName(), "DeactivateServiceInstanceBB");
+ }
+
+ @Test
+ public void selectExecutionListServiceMacroEmptyServiceTest() throws Exception {
+ String gAction = "createInstance";
+ String resource = "Service";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest = new String(Files
+ .readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", false);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri", "v6/serviceInstances/123");
+
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ northBoundRequest.setIsToplevelflow(true);
+ List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB", "CreateNetworkCollectionBB",
+ "AssignNetworkBB", "AssignVnfBB", "AssignVolumeGroupBB", "AssignVfModuleBB", "CreateNetworkBB",
+ "ActivateNetworkBB", "CreateVolumeGroupBB", "ActivateVolumeGroupBB", "CreateVfModuleBB",
+ "ActivateVfModuleBB", "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB", "ActivateVnfBB",
+ "ActivateNetworkCollectionBB", "ActivateServiceInstanceBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ Service service = new Service();
+ doReturn(service).when(catalogDbClient).getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a");
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEqualsBulkFlowName(ebbs, "AssignServiceInstanceBB", "ActivateServiceInstanceBB");
+ }
+
+ @Test
+ public void selectExecutionListServiceMacroCreateJustNetworkTest() throws Exception {
+ String gAction = "createInstance";
+ String resource = "Service";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest = new String(Files
+ .readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", false);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri", "v6/serviceInstances/123");
+
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ northBoundRequest.setIsToplevelflow(true);
+ List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB", "CreateNetworkCollectionBB",
+ "AssignNetworkBB", "AssignVnfBB", "AssignVolumeGroupBB", "AssignVfModuleBB", "CreateNetworkBB",
+ "ActivateNetworkBB", "CreateVolumeGroupBB", "ActivateVolumeGroupBB", "CreateVfModuleBB",
+ "ActivateVfModuleBB", "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB", "ActivateVnfBB",
+ "ActivateNetworkCollectionBB", "ActivateServiceInstanceBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ Service service = new Service();
+ NetworkResourceCustomization networkCustomization = new NetworkResourceCustomization();
+ networkCustomization.setModelCustomizationUUID("1234");
+ service.getNetworkCustomizations().add(networkCustomization);
+ doReturn(service).when(catalogDbClient).getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a");
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEqualsBulkFlowName(ebbs, "AssignServiceInstanceBB", "AssignNetworkBB", "CreateNetworkBB",
+ "ActivateNetworkBB", "ActivateServiceInstanceBB");
+ }
+
+ @Test
+ public void selectExecutionListServiceMacroCreateWithNetworkCollectionTest() throws Exception {
+ String gAction = "createInstance";
+ String resource = "Service";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest = new String(Files
+ .readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", false);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri", "v6/serviceInstances/123");
+
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ northBoundRequest.setIsToplevelflow(true);
+ List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB", "CreateNetworkCollectionBB",
+ "AssignNetworkBB", "AssignVnfBB", "AssignVolumeGroupBB", "AssignVfModuleBB", "CreateNetworkBB",
+ "ActivateNetworkBB", "CreateVolumeGroupBB", "ActivateVolumeGroupBB", "CreateVfModuleBB",
+ "ActivateVfModuleBB", "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB", "ActivateVnfBB",
+ "ActivateNetworkCollectionBB", "ActivateServiceInstanceBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ Service service = new Service();
+ List<NetworkResourceCustomization> networkCustomizations = new ArrayList<>();
+ NetworkResourceCustomization networkCust = new NetworkResourceCustomization();
+ networkCust.setModelCustomizationUUID("123");
+ networkCustomizations.add(networkCust);
+ service.setNetworkCustomizations(networkCustomizations);
+ NetworkCollectionResourceCustomization collectionResourceCustomization =
+ new NetworkCollectionResourceCustomization();
+ collectionResourceCustomization.setModelCustomizationUUID("123");
+
+ CollectionResource collectionResource = new CollectionResource();
+ collectionResource.setToscaNodeType("NetworkCollection");
+ InstanceGroup instanceGroup = new InstanceGroup();
+ instanceGroup.setToscaNodeType("NetworkCollectionResource");
+ instanceGroup.setCollectionNetworkResourceCustomizations(new ArrayList<>());
+ CollectionNetworkResourceCustomization collectionNetworkResourceCust =
+ new CollectionNetworkResourceCustomization();
+ collectionNetworkResourceCust.setModelCustomizationUUID("123");
+ collectionNetworkResourceCust.setNetworkResourceCustomization(collectionResourceCustomization);
+ instanceGroup.getCollectionNetworkResourceCustomizations().add(collectionNetworkResourceCust);
+ List<CollectionResourceInstanceGroupCustomization> collectionInstanceGroupCustomizations = new ArrayList<>();
+ CollectionResourceInstanceGroupCustomization collectionInstanceGroupCustomization =
+ new CollectionResourceInstanceGroupCustomization();
+ collectionInstanceGroupCustomization.setModelCustomizationUUID("123");
+ collectionInstanceGroupCustomization.setSubInterfaceNetworkQuantity(3);
+ collectionInstanceGroupCustomizations.add(collectionInstanceGroupCustomization);
+ collectionInstanceGroupCustomization.setInstanceGroup(instanceGroup);
+ collectionInstanceGroupCustomization.setCollectionResourceCust(collectionResourceCustomization);
+ instanceGroup.setCollectionInstanceGroupCustomizations(collectionInstanceGroupCustomizations);
+ collectionResource.setInstanceGroup(instanceGroup);
+ collectionResourceCustomization.setCollectionResource(collectionResource);;
+ service.getCollectionResourceCustomizations().add(collectionResourceCustomization);
+ doReturn(service).when(catalogDbClient).getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a");
+ doReturn(collectionResourceCustomization).when(catalogDbClient)
+ .getNetworkCollectionResourceCustomizationByID("123");
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEqualsBulkFlowName(ebbs, "AssignServiceInstanceBB", "CreateNetworkCollectionBB", "AssignNetworkBB",
+ "CreateNetworkBB", "ActivateNetworkBB", "AssignNetworkBB", "CreateNetworkBB", "ActivateNetworkBB",
+ "AssignNetworkBB", "CreateNetworkBB", "ActivateNetworkBB", "ActivateNetworkCollectionBB",
+ "ActivateServiceInstanceBB");
+ assertEquals("Network id not empty", !ebbs.get(2).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
+ assertEquals("Network id not empty", !ebbs.get(3).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
+ assertEquals("Network id not empty", !ebbs.get(4).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
+ assertEquals("Network id same for AssignNetworkBB CreateNetworkBB ActivateNetworkBB",
+ ebbs.get(2).getWorkflowResourceIds().getNetworkId() == ebbs.get(3).getWorkflowResourceIds()
+ .getNetworkId()
+ && ebbs.get(3).getWorkflowResourceIds().getNetworkId() == ebbs.get(4).getWorkflowResourceIds()
+ .getNetworkId(),
+ true);
+ assertEquals("Network id not empty", !ebbs.get(5).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
+ assertEquals("Network id not empty", !ebbs.get(6).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
+ assertEquals("Network id not empty", !ebbs.get(7).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
+ assertEquals("Network id same for AssignNetworkBB CreateNetworkBB ActivateNetworkBB",
+ ebbs.get(5).getWorkflowResourceIds().getNetworkId() == ebbs.get(6).getWorkflowResourceIds()
+ .getNetworkId()
+ && ebbs.get(6).getWorkflowResourceIds().getNetworkId() == ebbs.get(7).getWorkflowResourceIds()
+ .getNetworkId(),
+ true);
+ assertEquals("Network id not empty", !ebbs.get(8).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
+ assertEquals("Network id not empty", !ebbs.get(9).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
+ assertEquals("Network id not empty", !ebbs.get(10).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
+ assertEquals("Network id same for AssignNetworkBB CreateNetworkBB ActivateNetworkBB",
+ ebbs.get(8).getWorkflowResourceIds().getNetworkId() == ebbs.get(9).getWorkflowResourceIds()
+ .getNetworkId()
+ && ebbs.get(9).getWorkflowResourceIds().getNetworkId() == ebbs.get(10).getWorkflowResourceIds()
+ .getNetworkId(),
+ true);
+ }
+
+ @Test
+ public void selectExecutionListServiceMacroCreateWithUserParams() throws Exception {
+ String gAction = "createInstance";
+ String resource = "Service";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest =
+ new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", false);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri", "v6/serviceInstances/123");
+
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB", "CreateNetworkCollectionBB",
+ "AssignNetworkBB", "AssignVnfBB", "AssignVolumeGroupBB", "AssignVfModuleBB", "CreateNetworkBB",
+ "ActivateNetworkBB", "CreateVolumeGroupBB", "ActivateVolumeGroupBB", "CreateVfModuleBB",
+ "ActivateVfModuleBB", "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB", "ActivateVnfBB",
+ "ActivateNetworkCollectionBB", "ActivateServiceInstanceBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ Service service = new Service();
+ service.setModelUUID("3c40d244-808e-42ca-b09a-256d83d19d0a");
+
+ VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
+ vfModuleCustomization.setModelCustomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f");
+ HeatEnvironment volumeHeatEnv = new HeatEnvironment();
+ vfModuleCustomization.setVolumeHeatEnv(volumeHeatEnv);
+ org.onap.so.db.catalog.beans.VfModule vfModule = new org.onap.so.db.catalog.beans.VfModule();
+ HeatTemplate volumeHeatTemplate = new HeatTemplate();
+ vfModule.setVolumeHeatTemplate(volumeHeatTemplate);
+ vfModuleCustomization.setVfModule(vfModule);
+
+ VfModuleCustomization vfModuleCustomization2 = new VfModuleCustomization();
+ vfModuleCustomization2.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
+ HeatEnvironment heatEnvironment = new HeatEnvironment();
+ vfModuleCustomization2.setHeatEnvironment(heatEnvironment);
+ org.onap.so.db.catalog.beans.VfModule vfModule2 = new org.onap.so.db.catalog.beans.VfModule();
+ HeatTemplate moduleHeatTemplate = new HeatTemplate();
+ vfModule2.setModuleHeatTemplate(moduleHeatTemplate);
+ vfModuleCustomization2.setVfModule(vfModule2);
+
+ VfModuleCustomization vfModuleCustomization3 = vfModuleCustomization2;
+ vfModuleCustomization3.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
+
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f"))
+ .thenReturn(vfModuleCustomization);
+ when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8"))
+ .thenReturn(vfModuleCustomization2);
+ when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("da4d4327-fb7d-4311-ac7a-be7ba60cf969"))
+ .thenReturn(vfModuleCustomization3);
+ when(catalogDbClient.getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a")).thenReturn(service);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEqualsBulkFlowName(ebbs, "AssignServiceInstanceBB", "AssignVnfBB", "AssignVolumeGroupBB",
+ "AssignVfModuleBB", "AssignVfModuleBB", "AssignVfModuleBB", "CreateVolumeGroupBB",
+ "ActivateVolumeGroupBB", "CreateVfModuleBB", "CreateVfModuleBB", "CreateVfModuleBB",
+ "ActivateVfModuleBB", "ActivateVfModuleBB", "ActivateVfModuleBB", "ActivateVnfBB",
+ "ActivateServiceInstanceBB");
+ assertEquals(3, ebbs.get(0).getWorkflowResourceIds().getServiceInstanceId().length());
+ int randomUUIDLength = UUID.randomUUID().toString().length();
+ assertEquals(randomUUIDLength, ebbs.get(1).getWorkflowResourceIds().getVnfId().length());
+ assertEquals(randomUUIDLength, ebbs.get(2).getWorkflowResourceIds().getVolumeGroupId().length());
+ assertEquals(randomUUIDLength, ebbs.get(3).getWorkflowResourceIds().getVfModuleId().length());
+ assertEquals(randomUUIDLength, ebbs.get(4).getWorkflowResourceIds().getVfModuleId().length());
+ assertEquals(randomUUIDLength, ebbs.get(5).getWorkflowResourceIds().getVfModuleId().length());
+ assertEquals(randomUUIDLength, ebbs.get(6).getWorkflowResourceIds().getVolumeGroupId().length());
+ assertEquals(randomUUIDLength, ebbs.get(7).getWorkflowResourceIds().getVolumeGroupId().length());
+ assertEquals(randomUUIDLength, ebbs.get(8).getWorkflowResourceIds().getVfModuleId().length());
+ assertEquals(randomUUIDLength, ebbs.get(9).getWorkflowResourceIds().getVfModuleId().length());
+ assertEquals(randomUUIDLength, ebbs.get(10).getWorkflowResourceIds().getVfModuleId().length());
+ assertEquals(randomUUIDLength, ebbs.get(11).getWorkflowResourceIds().getVfModuleId().length());
+ assertEquals(randomUUIDLength, ebbs.get(12).getWorkflowResourceIds().getVfModuleId().length());
+ assertEquals(randomUUIDLength, ebbs.get(13).getWorkflowResourceIds().getVfModuleId().length());
+ assertEquals(randomUUIDLength, ebbs.get(14).getWorkflowResourceIds().getVnfId().length());
+ assertEquals(3, ebbs.get(0).getWorkflowResourceIds().getServiceInstanceId().length());
+ assertEquals(true, execution.getVariable("homing"));
+ }
+
+ @Test
+ public void selectExecutionListServiceMacroDeleteTest() throws Exception {
+ String gAction = "deleteInstance";
+ String resource = "Service";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest = new String(Files
+ .readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", false);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri", "v6/serviceInstances/123");
+
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB",
+ "DeactivateVolumeGroupBB", "DeleteVolumeGroupBB", "DeactivateVnfBB", "DeactivateNetworkBB",
+ "DeleteNetworkBB", "DeleteNetworkCollectionBB", "DeactivateServiceInstanceBB", "UnassignVfModuleBB",
+ "UnassignVolumeGroupBB", "UnassignVnfBB", "UnassignNetworkBB", "UnassignServiceInstanceBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ ServiceInstance serviceInstanceAAI = new ServiceInstance();
+ serviceInstanceAAI.setServiceInstanceId("aaisi123");
+ org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance();
+ org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf();
+ vnf.setVnfId("vnfId123");
+
+ org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
+ vfModule.setVfModuleId("vfModule1");
+ vnf.getVfModules().add(vfModule);
+ org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule2 =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
+ vfModule2.setVfModuleId("vfModule2");
+ vnf.getVfModules().add(vfModule2);
+
+ org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup volumeGroup =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup();
+ volumeGroup.setVolumeGroupId("vg123");
+ vnf.getVolumeGroups().add(volumeGroup);
+
+ serviceInstanceMSO.getVnfs().add(vnf);
+
+ doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("123");
+ doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEqualsBulkFlowName(ebbs, "DeactivateVfModuleBB", "DeactivateVfModuleBB", "DeleteVfModuleBB",
+ "DeleteVfModuleBB", "DeactivateVolumeGroupBB", "DeleteVolumeGroupBB", "DeactivateVnfBB",
+ "DeactivateServiceInstanceBB", "UnassignVfModuleBB", "UnassignVfModuleBB", "UnassignVolumeGroupBB",
+ "UnassignVnfBB", "UnassignServiceInstanceBB");
+ }
+
+ @Test
+ public void selectExecutionListServiceMacroUnassignTest() throws Exception {
+ String gAction = "unassignInstance";
+ String resource = "Service";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest = new String(Files
+ .readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", false);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri", "v6/serviceInstances/123");
+
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows = createFlowList("UnassignVfModuleBB", "UnassignVolumeGroupBB",
+ "UnassignVnfBB", "UnassignNetworkBB", "UnassignServiceInstanceBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ ServiceInstance serviceInstanceAAI = new ServiceInstance();
+ serviceInstanceAAI.setServiceInstanceId("aaisi123");
+ org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance();
+ org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf();
+ vnf.setVnfId("vnfId123");
+
+ org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
+ vfModule.setVfModuleId("vfModule1");
+ vnf.getVfModules().add(vfModule);
+ org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule2 =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
+ vfModule2.setVfModuleId("vfModule2");
+ vnf.getVfModules().add(vfModule2);
+
+ org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup volumeGroup =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup();
+ volumeGroup.setVolumeGroupId("vg123");
+ vnf.getVolumeGroups().add(volumeGroup);
+
+ serviceInstanceMSO.getVnfs().add(vnf);
+
+ doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("123");
+ doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEqualsBulkFlowName(ebbs, "UnassignVfModuleBB", "UnassignVfModuleBB", "UnassignVolumeGroupBB",
+ "UnassignVnfBB", "UnassignServiceInstanceBB");
+ }
+
@Test
- public void selectExecutionListVnfMacroRecreateTest() throws Exception{
+ public void selectExecutionListServiceMacroDeleteNetworkCollectionTest() throws Exception {
+ String gAction = "deleteInstance";
+ String resource = "Service";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest = new String(Files
+ .readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", false);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri", "v6/serviceInstances/123");
+
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB",
+ "DeactivateVolumeGroupBB", "DeleteVolumeGroupBB", "DeactivateVnfBB", "DeactivateNetworkBB",
+ "DeleteNetworkBB", "DeleteNetworkCollectionBB", "DeactivateServiceInstanceBB", "UnassignVfModuleBB",
+ "UnassignVolumeGroupBB", "UnassignVnfBB", "UnassignNetworkBB", "UnassignServiceInstanceBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ ServiceInstance serviceInstanceAAI = new ServiceInstance();
+ serviceInstanceAAI.setServiceInstanceId("aaisi123");
+ org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance();
+
+ org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network network =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network();
+ network.setNetworkId("123");
+ serviceInstanceMSO.getNetworks().add(network);
+ org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network network2 =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network();
+ network2.setNetworkId("321");
+ serviceInstanceMSO.getNetworks().add(network2);
+
+ Collection collection = new Collection();
+ serviceInstanceMSO.setCollection(collection);
+
+ doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("123");
+ doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEqualsBulkFlowName(ebbs, "DeactivateNetworkBB", "DeleteNetworkBB", "UnassignNetworkBB",
+ "DeactivateNetworkBB", "DeleteNetworkBB", "UnassignNetworkBB", "DeleteNetworkCollectionBB",
+ "DeactivateServiceInstanceBB", "UnassignServiceInstanceBB");
+ }
+
+ @Test
+ public void selectExecutionListVnfMacroRecreateTest() throws Exception {
String gAction = "recreateInstance";
String resource = "Vnf";
execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
execution.setVariable("requestAction", gAction);
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/VnfMacroReplace.json")));
- execution.setVariable("bpmnRequest", bpmnRequest);
+ String bpmnRequest =
+ new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/VnfMacroReplace.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
execution.setVariable("aLaCarte", false);
execution.setVariable("apiVersion", "7");
execution.setVariable("requestUri", "v7/serviceInstances/123/vnfs/1234/recreate");
execution.setVariable("serviceInstanceId", "123");
execution.setVariable("vnfId", "1234");
-
+
NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = createFlowList("AAICheckVnfInMaintBB","AAISetVnfInMaintBB","DeactivateFabricConfigurationBB", "UnassignFabricConfigurationBB", "DeactivateVfModuleBB","DeleteVfModuleBB","DeactivateVnfBB","CreateVfModuleBB"
- ,"ActivateVfModuleBB","AssignFabricConfigurationBB","ActivateFabricConfigurationBB","ActivateVnfBB","SDNOVnfHealthCheckBB","AAIUnsetVnfInMaintBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
-
+ List<OrchestrationFlow> orchFlows = createFlowList("AAICheckVnfInMaintBB", "AAISetVnfInMaintBB",
+ "DeactivateFabricConfigurationBB", "UnassignFabricConfigurationBB", "DeactivateVfModuleBB",
+ "DeleteVfModuleBB", "DeactivateVnfBB", "CreateVfModuleBB", "ActivateVfModuleBB",
+ "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB", "ActivateVnfBB", "SDNOVnfHealthCheckBB",
+ "AAIUnsetVnfInMaintBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
ServiceInstance serviceInstanceAAI = new ServiceInstance();
serviceInstanceAAI.setServiceInstanceId("123");
- org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO = new org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance();
- org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf = new org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf();
+ org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance();
+ org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf();
vnf.setVnfId("1234");
-
- org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
+
+ org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
vfModule.setVfModuleId("vfModule1");
vnf.getVfModules().add(vfModule);
- org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule2 = new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
+ org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule2 =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
vfModule2.setVfModuleId("vfModule2");
vnf.getVfModules().add(vfModule2);
-
+
serviceInstanceMSO.getVnfs().add(vnf);
-
+
doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("123");
doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,false,"cloud-owner")).thenReturn(northBoundRequest);
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ false, "cloud-owner")).thenReturn(northBoundRequest);
workflowAction.selectExecutionList(execution);
List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEqualsBulkFlowName(ebbs,"AAICheckVnfInMaintBB","AAISetVnfInMaintBB","DeactivateVfModuleBB","DeactivateVfModuleBB","DeleteVfModuleBB","DeleteVfModuleBB","DeactivateVnfBB"
- ,"CreateVfModuleBB","CreateVfModuleBB","ActivateVfModuleBB","ActivateVfModuleBB","ActivateVnfBB","SDNOVnfHealthCheckBB","AAIUnsetVnfInMaintBB");
+ assertEqualsBulkFlowName(ebbs, "AAICheckVnfInMaintBB", "AAISetVnfInMaintBB", "DeactivateVfModuleBB",
+ "DeactivateVfModuleBB", "DeleteVfModuleBB", "DeleteVfModuleBB", "DeactivateVnfBB", "CreateVfModuleBB",
+ "CreateVfModuleBB", "ActivateVfModuleBB", "ActivateVfModuleBB", "ActivateVnfBB", "SDNOVnfHealthCheckBB",
+ "AAIUnsetVnfInMaintBB");
}
-
+
@Test
- public void selectExecutionListVnfMacroReplaceTest() throws Exception{
+ public void selectExecutionListVnfMacroReplaceTest() throws Exception {
String gAction = "replaceInstance";
String resource = "Vnf";
execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
execution.setVariable("requestAction", gAction);
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/VnfMacroReplace.json")));
- execution.setVariable("bpmnRequest", bpmnRequest);
+ String bpmnRequest =
+ new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/VnfMacroReplace.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
execution.setVariable("aLaCarte", false);
execution.setVariable("apiVersion", "7");
execution.setVariable("requestUri", "v7/serviceInstances/123/vnfs/1234/replace");
execution.setVariable("serviceInstanceId", "123");
execution.setVariable("vnfId", "1234");
-
+
NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = createFlowList("AAICheckVnfInMaintBB","AAISetVnfInMaintBB","DeactivateFabricConfigurationBB","UnassignFabricConfigurationBB","DeactivateVfModuleBB","DeleteVfModuleBB"
- ,"DeactivateVnfBB","ChangeModelVfModuleBB","CreateVfModuleBB","ActivateVfModuleBB","AssignFabricConfigurationBB","ActivateFabricConfigurationBB","ChangeModelVnfBB","ActivateVnfBB","ChangeModelServiceInstanceBB","SDNOVnfHealthCheckBB","AAIUnsetVnfInMaintBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
+ List<OrchestrationFlow> orchFlows = createFlowList("AAICheckVnfInMaintBB", "AAISetVnfInMaintBB",
+ "DeactivateFabricConfigurationBB", "UnassignFabricConfigurationBB", "DeactivateVfModuleBB",
+ "DeleteVfModuleBB", "DeactivateVnfBB", "ChangeModelVfModuleBB", "CreateVfModuleBB",
+ "ActivateVfModuleBB", "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB",
+ "ChangeModelVnfBB", "ActivateVnfBB", "ChangeModelServiceInstanceBB", "SDNOVnfHealthCheckBB",
+ "AAIUnsetVnfInMaintBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
ServiceInstance serviceInstanceAAI = new ServiceInstance();
serviceInstanceAAI.setServiceInstanceId("123");
- org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO = new org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance();
- org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf = new org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf();
+ org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance();
+ org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf();
vnf.setVnfId("1234");
- org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
+ org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
vfModule.setVfModuleId("vfModule1");
vnf.getVfModules().add(vfModule);
- org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule2 = new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
+ org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule2 =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
vfModule2.setVfModuleId("vfModule2");
vnf.getVfModules().add(vfModule2);
serviceInstanceMSO.getVnfs().add(vnf);
@@ -792,647 +912,716 @@ public class WorkflowActionTest extends BaseTaskTest {
config.setConfigurationId("configId");
Optional<Configuration> configOp = Optional.of(config);
Optional<Relationships> relationshipsOp = Optional.of(relationships);
-
+
doReturn(relationshipsOp).when(workflowActionUtils).extractRelationshipsVnfc(isA(Relationships.class));
doReturn(configOp).when(workflowActionUtils).extractRelationshipsConfiguration(isA(Relationships.class));
doReturn(vfModuleAAI).when(bbSetupUtils).getAAIVfModule("1234", "vfModule2");
doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("123");
doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,false,"cloud-owner")).thenReturn(northBoundRequest);
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ false, "cloud-owner")).thenReturn(northBoundRequest);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEqualsBulkFlowName(ebbs, "AAICheckVnfInMaintBB", "AAISetVnfInMaintBB", "DeactivateFabricConfigurationBB",
+ "UnassignFabricConfigurationBB", "DeactivateVfModuleBB", "DeactivateVfModuleBB", "DeleteVfModuleBB",
+ "DeleteVfModuleBB", "DeactivateVnfBB", "ChangeModelVfModuleBB", "ChangeModelVfModuleBB",
+ "CreateVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", "ActivateVfModuleBB",
+ "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB", "ChangeModelVnfBB", "ActivateVnfBB",
+ "ChangeModelServiceInstanceBB", "SDNOVnfHealthCheckBB", "AAIUnsetVnfInMaintBB");
+ }
+
+ @Ignore
+ @Test
+ public void selectExecutionListNetworkCollectionMacroCreate() throws Exception {
+ String gAction = "createInstance";
+ String resource = "NetworkCollection";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest = new String(
+ Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/CreateNetworkCollection.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", false);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri", "v6/serviceInstances/123/networkCollections/123");
+
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows = createFlowList("CreateNetworkCollectionBB", "AssignNetworkBB",
+ "CreateNetworkBB", "ActivateNetworkBB", "ActivateNetworkCollectionBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ Service service = new Service();
+ CollectionResourceCustomization collectionResourceCustomization = new CollectionResourceCustomization();
+ CollectionResource collectionResource = new CollectionResource();
+ collectionResource.setToscaNodeType("Data NetworkCollection Data");
+ collectionResourceCustomization.setCollectionResource(collectionResource);
+ service.getCollectionResourceCustomizations().add(collectionResourceCustomization);
+
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ when(catalogDbClient.getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a")).thenReturn(service);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEqualsBulkFlowName(ebbs, "CreateNetworkCollectionBB", "AssignNetworkBB", "CreateNetworkBB",
+ "ActivateNetworkBB", "AssignNetworkBB", "CreateNetworkBB", "ActivateNetworkBB",
+ "ActivateNetworkCollectionBB");
+ }
+
+ @Ignore
+ @Test
+ public void selectExecutionListNetworkCollectionMacroDelete() throws Exception {
+ String gAction = "deleteInstance";
+ String resource = "NetworkCollection";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest = new String(
+ Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/CreateNetworkCollection.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", false);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri", "v6/serviceInstances/123/networkCollections/123");
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows = createFlowList("DeactivateNetworkBB", "DeleteNetworkBB",
+ "UnassignNetworkBB", "DeactivateNetworkCollectionBB", "DeleteNetworkCollectionBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ Service service = new Service();
+ CollectionResourceCustomization collectionResourceCustomization = new CollectionResourceCustomization();
+ CollectionResource collectionResource = new CollectionResource();
+ collectionResource.setToscaNodeType("Data NetworkCollection Data");
+ collectionResourceCustomization.setCollectionResource(collectionResource);
+ service.getCollectionResourceCustomizations().add(collectionResourceCustomization);
+
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ when(catalogDbClient.getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a")).thenReturn(service);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEqualsBulkFlowName(ebbs, "DeactivateNetworkBB", "DeleteNetworkBB", "UnassignNetworkBB",
+ "DeactivateNetworkBB", "DeleteNetworkBB", "UnassignNetworkBB", "DeactivateNetworkCollectionBB",
+ "DeleteNetworkCollectionBB");
+ }
+
+ @Test
+ public void selectExecutionListALaCarteVfModuleNoFabricCreateTest() throws Exception {
+ String gAction = "createInstance";
+ String resource = "VfModule";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest =
+ new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", true);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri",
+ "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules");
+
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows = createFlowList("AssignVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB",
+ "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEqualsBulkFlowName(ebbs, "AssignVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB");
+ }
+
+ @Test
+ public void selectExecutionListALaCarteVfModuleFabricCreateTest() throws Exception {
+ String gAction = "createInstance";
+ String resource = "VfModule";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest =
+ new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", true);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri",
+ "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules");
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows = createFlowList("AssignVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB",
+ "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ List<CvnfcCustomization> cvnfcCustomizations = new ArrayList<CvnfcCustomization>();
+ CvnfcCustomization cvnfcCustomization = new CvnfcCustomization();
+ CvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization =
+ new CvnfcConfigurationCustomization();
+ ConfigurationResource configurationResource = new ConfigurationResource();
+ configurationResource.setToscaNodeType("FabricConfiguration");
+ vnfVfmoduleCvnfcConfigurationCustomization.setConfigurationResource(configurationResource);
+ vnfVfmoduleCvnfcConfigurationCustomization.setModelInstanceName("modelInstanceName1");
+ vnfVfmoduleCvnfcConfigurationCustomization.setCvnfcCustomization(cvnfcCustomization);
+ Set<CvnfcConfigurationCustomization> custSet = new HashSet<CvnfcConfigurationCustomization>();
+ custSet.add(vnfVfmoduleCvnfcConfigurationCustomization);
+ cvnfcCustomization.setCvnfcConfigurationCustomization(custSet);
+ cvnfcCustomization.setDescription("description");
+ cvnfcCustomizations.add(cvnfcCustomization);
+
+ CvnfcCustomization cvnfcCustomization2 = new CvnfcCustomization();
+ CvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization2 =
+ new CvnfcConfigurationCustomization();
+ ConfigurationResource configurationResource2 = new ConfigurationResource();
+ configurationResource2.setToscaNodeType("FabricConfiguration");
+ vnfVfmoduleCvnfcConfigurationCustomization2.setConfigurationResource(configurationResource2);
+ vnfVfmoduleCvnfcConfigurationCustomization2.setModelInstanceName("modelInstanceName2");
+ vnfVfmoduleCvnfcConfigurationCustomization2.setCvnfcCustomization(cvnfcCustomization2);
+ Set<CvnfcConfigurationCustomization> custSet2 = new HashSet<CvnfcConfigurationCustomization>();
+ custSet2.add(vnfVfmoduleCvnfcConfigurationCustomization2);
+ cvnfcCustomization2.setCvnfcConfigurationCustomization(custSet2);
+ cvnfcCustomization2.setDescription("description2");
+ cvnfcCustomizations.add(cvnfcCustomization2);
+
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ // when(catalogDbClient.getCvnfcCustomizationByVnfCustomizationUUIDAndVfModuleCustomizationUUID("fc25201d-36d6-43a3-8d39-fdae88e526ae",
+ // "9a6d01fd-19a7-490a-9800-460830a12e0b")).thenReturn(cvnfcCustomizations);
workflowAction.selectExecutionList(execution);
List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEqualsBulkFlowName(ebbs,"AAICheckVnfInMaintBB","AAISetVnfInMaintBB", "DeactivateFabricConfigurationBB", "UnassignFabricConfigurationBB", "DeactivateVfModuleBB","DeactivateVfModuleBB","DeleteVfModuleBB","DeleteVfModuleBB","DeactivateVnfBB"
- ,"ChangeModelVfModuleBB" ,"ChangeModelVfModuleBB" , "CreateVfModuleBB","CreateVfModuleBB", "ActivateVfModuleBB","ActivateVfModuleBB", "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB", "ChangeModelVnfBB", "ActivateVnfBB","ChangeModelServiceInstanceBB","SDNOVnfHealthCheckBB","AAIUnsetVnfInMaintBB");
+ assertEqualsBulkFlowName(ebbs, "AssignVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB",
+ "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB", "AssignFabricConfigurationBB",
+ "ActivateFabricConfigurationBB");
+ }
+
+ @Test
+ public void selectExecutionListALaCarteVfModuleFabricDeleteTest() throws Exception {
+ String gAction = "deleteInstance";
+ String resource = "VfModule";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest =
+ new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", true);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri",
+ "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules");
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB",
+ "UnassignVfModuleBB", "DeactivateFabricConfigurationBB", "UnassignFabricConfigurationBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+
+ org.onap.aai.domain.yang.GenericVnf vnf = new org.onap.aai.domain.yang.GenericVnf();
+ vnf.setVnfId("vnf0");
+ vnf.setModelCustomizationId("modelCustomizationId");
+ when(bbSetupUtils.getAAIGenericVnf(anyObject())).thenReturn(vnf);
+
+ org.onap.aai.domain.yang.VfModule vfModule = new org.onap.aai.domain.yang.VfModule();
+ vfModule.setModelCustomizationId("modelCustomizationId");
+ when(bbSetupUtils.getAAIVfModule(anyObject(), anyObject())).thenReturn(vfModule);
+
+ List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>();
+ org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc();
+ vnfc.setModelInvariantId("modelInvariantId");
+ vnfc.setVnfcName("testVnfcName");
+ vnfcs.add(vnfc);
+ doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(anyObject(), anyObject(), anyObject(),
+ anyObject());
+
+ List<org.onap.aai.domain.yang.Configuration> configurations =
+ new ArrayList<org.onap.aai.domain.yang.Configuration>();
+ org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration();
+ configuration.setConfigurationId("configurationId");
+ configuration.setModelCustomizationId("modelCustimizationId");
+ configuration.setConfigurationName("testConfigurationName");
+ configurations.add(configuration);
+ doReturn(configurations).when(SPY_workflowAction).getRelatedResourcesInVnfc(anyObject(), anyObject(),
+ anyObject());
+
+ doReturn("testName").when(SPY_workflowAction).getVnfcNameForConfiguration(anyObject());
+
+ SPY_workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEqualsBulkFlowName(ebbs, "DeactivateFabricConfigurationBB", "UnassignFabricConfigurationBB",
+ "DeactivateVfModuleBB", "DeleteVfModuleBB", "UnassignVfModuleBB");
}
-
- @Ignore
- @Test
- public void selectExecutionListNetworkCollectionMacroCreate() throws Exception{
- String gAction = "createInstance";
- String resource = "NetworkCollection";
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("requestAction", gAction);
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/CreateNetworkCollection.json")));
- execution.setVariable("bpmnRequest", bpmnRequest);
- execution.setVariable("aLaCarte", false);
- execution.setVariable("apiVersion", "7");
- execution.setVariable("requestUri", "v6/serviceInstances/123/networkCollections/123");
-
-
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = createFlowList("CreateNetworkCollectionBB","AssignNetworkBB","CreateNetworkBB","ActivateNetworkBB","ActivateNetworkCollectionBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
-
- Service service = new Service();
- CollectionResourceCustomization collectionResourceCustomization = new CollectionResourceCustomization();
- CollectionResource collectionResource = new CollectionResource();
- collectionResource.setToscaNodeType("Data NetworkCollection Data");
- collectionResourceCustomization.setCollectionResource(collectionResource);
- service.getCollectionResourceCustomizations().add(collectionResourceCustomization);
-
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,false,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
- when(catalogDbClient.getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a")).thenReturn(service);
- workflowAction.selectExecutionList(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEqualsBulkFlowName(ebbs,"CreateNetworkCollectionBB","AssignNetworkBB","CreateNetworkBB","ActivateNetworkBB","AssignNetworkBB","CreateNetworkBB","ActivateNetworkBB","ActivateNetworkCollectionBB");
- }
-
- @Ignore
- @Test
- public void selectExecutionListNetworkCollectionMacroDelete() throws Exception{
- String gAction = "deleteInstance";
- String resource = "NetworkCollection";
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("requestAction", gAction);
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/CreateNetworkCollection.json")));
- execution.setVariable("bpmnRequest", bpmnRequest);
- execution.setVariable("aLaCarte", false);
- execution.setVariable("apiVersion", "7");
- execution.setVariable("requestUri", "v6/serviceInstances/123/networkCollections/123");
-
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = createFlowList("DeactivateNetworkBB","DeleteNetworkBB","UnassignNetworkBB","DeactivateNetworkCollectionBB","DeleteNetworkCollectionBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
-
- Service service = new Service();
- CollectionResourceCustomization collectionResourceCustomization = new CollectionResourceCustomization();
- CollectionResource collectionResource = new CollectionResource();
- collectionResource.setToscaNodeType("Data NetworkCollection Data");
- collectionResourceCustomization.setCollectionResource(collectionResource);
- service.getCollectionResourceCustomizations().add(collectionResourceCustomization);
-
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,false,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
- when(catalogDbClient.getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a")).thenReturn(service);
- workflowAction.selectExecutionList(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEqualsBulkFlowName(ebbs,"DeactivateNetworkBB","DeleteNetworkBB","UnassignNetworkBB","DeactivateNetworkBB","DeleteNetworkBB","UnassignNetworkBB","DeactivateNetworkCollectionBB"
- ,"DeleteNetworkCollectionBB");
- }
-
- @Test
- public void selectExecutionListALaCarteVfModuleNoFabricCreateTest() throws Exception{
- String gAction = "createInstance";
- String resource = "VfModule";
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("requestAction", gAction);
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json")));
- execution.setVariable("bpmnRequest", bpmnRequest);
- execution.setVariable("aLaCarte", true);
- execution.setVariable("apiVersion", "7");
- execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules");
-
-
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = createFlowList("AssignVfModuleBB","CreateVfModuleBB","ActivateVfModuleBB","AssignFabricConfigurationBB","ActivateFabricConfigurationBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
-
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,true,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
- workflowAction.selectExecutionList(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEqualsBulkFlowName(ebbs,"AssignVfModuleBB","CreateVfModuleBB","ActivateVfModuleBB");
- }
-
- @Test
- public void selectExecutionListALaCarteVfModuleFabricCreateTest() throws Exception{
- String gAction = "createInstance";
- String resource = "VfModule";
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("requestAction", gAction);
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json")));
- execution.setVariable("bpmnRequest", bpmnRequest);
- execution.setVariable("aLaCarte", true);
- execution.setVariable("apiVersion", "7");
- execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules");
-
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = createFlowList("AssignVfModuleBB","CreateVfModuleBB","ActivateVfModuleBB","AssignFabricConfigurationBB","ActivateFabricConfigurationBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
-
- List<CvnfcCustomization> cvnfcCustomizations = new ArrayList<CvnfcCustomization>();
- CvnfcCustomization cvnfcCustomization = new CvnfcCustomization();
- CvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization = new CvnfcConfigurationCustomization();
- ConfigurationResource configurationResource = new ConfigurationResource();
- configurationResource.setToscaNodeType("FabricConfiguration");
- vnfVfmoduleCvnfcConfigurationCustomization.setConfigurationResource(configurationResource);
- vnfVfmoduleCvnfcConfigurationCustomization.setModelInstanceName("modelInstanceName1");
- vnfVfmoduleCvnfcConfigurationCustomization.setCvnfcCustomization(cvnfcCustomization);
- Set<CvnfcConfigurationCustomization> custSet = new HashSet<CvnfcConfigurationCustomization>();
- custSet.add(vnfVfmoduleCvnfcConfigurationCustomization);
- cvnfcCustomization.setCvnfcConfigurationCustomization(custSet);
- cvnfcCustomization.setDescription("description");
- cvnfcCustomizations.add(cvnfcCustomization);
-
- CvnfcCustomization cvnfcCustomization2 = new CvnfcCustomization();
- CvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization2 = new CvnfcConfigurationCustomization();
- ConfigurationResource configurationResource2 = new ConfigurationResource();
- configurationResource2.setToscaNodeType("FabricConfiguration");
- vnfVfmoduleCvnfcConfigurationCustomization2.setConfigurationResource(configurationResource2);
- vnfVfmoduleCvnfcConfigurationCustomization2.setModelInstanceName("modelInstanceName2");
- vnfVfmoduleCvnfcConfigurationCustomization2.setCvnfcCustomization(cvnfcCustomization2);
- Set<CvnfcConfigurationCustomization> custSet2 = new HashSet<CvnfcConfigurationCustomization>();
- custSet2.add(vnfVfmoduleCvnfcConfigurationCustomization2);
- cvnfcCustomization2.setCvnfcConfigurationCustomization(custSet2);
- cvnfcCustomization2.setDescription("description2");
- cvnfcCustomizations.add(cvnfcCustomization2);
-
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,true,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
- //when(catalogDbClient.getCvnfcCustomizationByVnfCustomizationUUIDAndVfModuleCustomizationUUID("fc25201d-36d6-43a3-8d39-fdae88e526ae", "9a6d01fd-19a7-490a-9800-460830a12e0b")).thenReturn(cvnfcCustomizations);
- workflowAction.selectExecutionList(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEqualsBulkFlowName(ebbs,"AssignVfModuleBB","CreateVfModuleBB","ActivateVfModuleBB","AssignFabricConfigurationBB","ActivateFabricConfigurationBB", "AssignFabricConfigurationBB","ActivateFabricConfigurationBB");
- }
-
- @Test
- public void selectExecutionListALaCarteVfModuleFabricDeleteTest() throws Exception{
- String gAction = "deleteInstance";
- String resource = "VfModule";
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("requestAction", gAction);
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json")));
- execution.setVariable("bpmnRequest", bpmnRequest);
- execution.setVariable("aLaCarte", true);
- execution.setVariable("apiVersion", "7");
- execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules");
-
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB","DeleteVfModuleBB","UnassignVfModuleBB","DeactivateFabricConfigurationBB","UnassignFabricConfigurationBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
-
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,true,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
-
- org.onap.aai.domain.yang.GenericVnf vnf = new org.onap.aai.domain.yang.GenericVnf();
- vnf.setVnfId("vnf0");
- vnf.setModelCustomizationId("modelCustomizationId");
- when(bbSetupUtils.getAAIGenericVnf(anyObject())).thenReturn(vnf);
-
- org.onap.aai.domain.yang.VfModule vfModule = new org.onap.aai.domain.yang.VfModule();
- vfModule.setModelCustomizationId("modelCustomizationId");
- when(bbSetupUtils.getAAIVfModule(anyObject(), anyObject())).thenReturn(vfModule);
-
- List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>();
- org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc();
- vnfc.setModelInvariantId("modelInvariantId");
- vnfc.setVnfcName("testVnfcName");
- vnfcs.add(vnfc);
- doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(anyObject(), anyObject(), anyObject(), anyObject());
-
- List<org.onap.aai.domain.yang.Configuration> configurations = new ArrayList<org.onap.aai.domain.yang.Configuration>();
- org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration();
- configuration.setConfigurationId("configurationId");
- configuration.setModelCustomizationId("modelCustimizationId");
- configuration.setConfigurationName("testConfigurationName");
- configurations.add(configuration);
- doReturn(configurations).when(SPY_workflowAction).getRelatedResourcesInVnfc(anyObject(), anyObject(), anyObject());
-
- doReturn("testName").when(SPY_workflowAction).getVnfcNameForConfiguration(anyObject());
-
- SPY_workflowAction.selectExecutionList(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEqualsBulkFlowName(ebbs,"DeactivateFabricConfigurationBB","UnassignFabricConfigurationBB","DeactivateVfModuleBB","DeleteVfModuleBB","UnassignVfModuleBB");
- }
-
- @Test
- public void selectExecutionListALaCarteVfModuleNoFabricDeleteTest() throws Exception{
- String gAction = "deleteInstance";
- String resource = "VfModule";
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("requestAction", gAction);
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json")));
- execution.setVariable("bpmnRequest", bpmnRequest);
- execution.setVariable("aLaCarte", true);
- execution.setVariable("apiVersion", "7");
- execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules");
-
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB","DeleteVfModuleBB","UnassignVfModuleBB","DeactivateFabricConfigurationBB","UnassignFabricConfigurationBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
-
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,true,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
-
- org.onap.aai.domain.yang.GenericVnf vnf = new org.onap.aai.domain.yang.GenericVnf();
- vnf.setVnfId("vnf0");
- vnf.setModelCustomizationId("modelCustomizationId");
- when(bbSetupUtils.getAAIGenericVnf(anyObject())).thenReturn(vnf);
-
- org.onap.aai.domain.yang.VfModule vfModule = new org.onap.aai.domain.yang.VfModule();
- vfModule.setModelCustomizationId("modelCustomizationId");
- when(bbSetupUtils.getAAIVfModule(anyObject(), anyObject())).thenReturn(vfModule);
-
- List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>();
- org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc();
- vnfc.setModelInvariantId("modelInvariantId");
- vnfc.setVnfcName("testVnfcName");
- vnfcs.add(vnfc);
- doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(anyObject(), anyObject(), anyObject(), anyObject());
-
- List<org.onap.aai.domain.yang.Configuration> configurations = new ArrayList<org.onap.aai.domain.yang.Configuration>();
- org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration();
- doReturn(configurations).when(SPY_workflowAction).getRelatedResourcesInVnfc(anyObject(), anyObject(), anyObject());
-
- doReturn("testName").when(SPY_workflowAction).getVnfcNameForConfiguration(anyObject());
-
- SPY_workflowAction.selectExecutionList(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEqualsBulkFlowName(ebbs,"DeactivateVfModuleBB","DeleteVfModuleBB","UnassignVfModuleBB");
- }
-
- @Test
- public void getRelatedResourcesInVfModuleTest() throws Exception{
- org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc();
- vnfc.setModelInvariantId("modelInvariantId");
- vnfc.setVnfcName("testVnfcName");
-
- String vfncPayload = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "/BuildingBlocks/vnfcResponse.json")));
- AAIResultWrapper vfncWrapper = new AAIResultWrapper(vfncPayload);
-
- String configurationPayload = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "/BuildingBlocks/configurationResponse.json")));
- AAIResultWrapper configurationWrapper = new AAIResultWrapper(configurationPayload);
- List<AAIResultWrapper> configurationResultWrappers = new ArrayList<AAIResultWrapper>();
- configurationResultWrappers.add(configurationWrapper);
-
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VNFC, vnfc.getVnfcName());
- when(bbSetupUtils.getAAIResourceDepthOne(uri)).thenReturn(vfncWrapper);
-
- doReturn(configurationResultWrappers).when(SPY_workflowAction).getResultWrappersFromRelationships(anyObject(),anyObject());
- List<org.onap.aai.domain.yang.Configuration> configurationsList = SPY_workflowAction.getRelatedResourcesInVnfc(vnfc, org.onap.aai.domain.yang.Configuration.class, AAIObjectType.CONFIGURATION);
- assertEquals(1,configurationsList.size());
- assertEquals("testConfigurationId",configurationsList.get(0).getConfigurationId());
- }
-
- /**
- * WorkflowActionBB Tests
- */
-
- @Test
- public void pluralTest() {
- List<String> items = Arrays.asList(
- "serviceInstances, Service",
- "vnfs, Vnf",
- "vfModules, VfModule",
- "networks, Network",
- "invalidNames, invalidNames");
- items.forEach(item -> {
- String[] split = item.split(",");
- String type = split[0].trim();
- String expected = split[1].trim();
- assertThat(workflowAction.convertTypeFromPlural(type), equalTo(expected));
- });
- }
-
- @Test
- public void sortExecutionPathByObjectForVlanTaggingCreateTest() throws Exception{
- List<ExecuteBuildingBlock> executeFlows = new ArrayList<>();
- ExecuteBuildingBlock ebb = new ExecuteBuildingBlock();
- BuildingBlock bb = new BuildingBlock();
- bb.setBpmnFlowName("AssignNetworkBB");
- bb.setKey("0");
- ebb.setBuildingBlock(bb);
- executeFlows.add(ebb);
- ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
- BuildingBlock bb2 = new BuildingBlock();
- bb2.setBpmnFlowName("AssignNetworkBB");
- bb2.setKey("1");
- ebb2.setBuildingBlock(bb2);
- executeFlows.add(ebb2);
- ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock();
- BuildingBlock bb3 = new BuildingBlock();
- bb3.setBpmnFlowName("CreateNetworkBB");
- bb3.setKey("0");
- ebb3.setBuildingBlock(bb3);
- executeFlows.add(ebb3);
- ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock();
- BuildingBlock bb4 = new BuildingBlock();
- bb4.setBpmnFlowName("CreateNetworkBB");
- bb4.setKey("1");
- ebb4.setBuildingBlock(bb4);
- executeFlows.add(ebb4);
- ExecuteBuildingBlock ebb5 = new ExecuteBuildingBlock();
- BuildingBlock bb5 = new BuildingBlock();
- bb5.setBpmnFlowName("ActivateNetworkBB");
- bb5.setKey("0");
- ebb5.setBuildingBlock(bb5);
- executeFlows.add(ebb5);
- ExecuteBuildingBlock ebb6 = new ExecuteBuildingBlock();
- BuildingBlock bb6 = new BuildingBlock();
- bb6.setBpmnFlowName("ActivateNetworkBB");
- bb6.setKey("1");
- ebb6.setBuildingBlock(bb6);
- executeFlows.add(ebb6);
-
- List<ExecuteBuildingBlock> sorted = workflowAction.sortExecutionPathByObjectForVlanTagging(executeFlows,"createInstance");
- assertEqualsBulkFlowName(sorted,"AssignNetworkBB","CreateNetworkBB","ActivateNetworkBB","AssignNetworkBB","CreateNetworkBB","ActivateNetworkBB");
- }
-
- @Test
- public void sortExecutionPathByObjectForVlanTaggingDeleteTest() throws Exception{
- List<ExecuteBuildingBlock> executeFlows = new ArrayList<>();
- ExecuteBuildingBlock ebb = new ExecuteBuildingBlock();
- BuildingBlock bb = new BuildingBlock();
- bb.setBpmnFlowName("DeactivateNetworkBB");
- bb.setKey("0");
- ebb.setBuildingBlock(bb);
- executeFlows.add(ebb);
- ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
- BuildingBlock bb2 = new BuildingBlock();
- bb2.setBpmnFlowName("DeactivateNetworkBB");
- bb2.setKey("1");
- ebb2.setBuildingBlock(bb2);
- executeFlows.add(ebb2);
- ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock();
- BuildingBlock bb3 = new BuildingBlock();
- bb3.setBpmnFlowName("DeleteNetworkBB");
- bb3.setKey("0");
- ebb3.setBuildingBlock(bb3);
- executeFlows.add(ebb3);
- ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock();
- BuildingBlock bb4 = new BuildingBlock();
- bb4.setBpmnFlowName("DeleteNetworkBB");
- bb4.setKey("1");
- ebb4.setBuildingBlock(bb4);
- executeFlows.add(ebb4);
- ExecuteBuildingBlock ebb5 = new ExecuteBuildingBlock();
- BuildingBlock bb5 = new BuildingBlock();
- bb5.setBpmnFlowName("UnassignNetworkBB");
- bb5.setKey("0");
- ebb5.setBuildingBlock(bb5);
- executeFlows.add(ebb5);
- ExecuteBuildingBlock ebb6 = new ExecuteBuildingBlock();
- BuildingBlock bb6 = new BuildingBlock();
- bb6.setBpmnFlowName("UnassignNetworkBB");
- bb6.setKey("1");
- ebb6.setBuildingBlock(bb6);
- executeFlows.add(ebb6);
-
- List<ExecuteBuildingBlock> sorted = workflowAction.sortExecutionPathByObjectForVlanTagging(executeFlows,"deleteInstance");
- assertEqualsBulkFlowName(sorted,"DeactivateNetworkBB","DeleteNetworkBB","UnassignNetworkBB","DeactivateNetworkBB","DeleteNetworkBB","UnassignNetworkBB");
- }
- @Test
- public void queryNorthBoundRequestCatalogDbNestedTest() throws MalformedURLException {
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = createFlowList("AAICheckVnfInMaintBB","AAISetVnfInMaintBB","VNF-Macro-Replace","SDNOVnfHealthCheckBB","AAIUnsetVnfInMaintBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
- List<OrchestrationFlow> macroFlows = createFlowList("DeactivateVfModuleBB","DeleteVfModuleBB","DeactivateVnfBB","CreateVfModuleBB","ActivateVfModuleBB","ActivateVnfBB");
-
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner("replaceInstance","Vnf",false,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
- when(catalogDbClient.getOrchestrationFlowByAction("VNF-Macro-Replace")).thenReturn(macroFlows);
- List<OrchestrationFlow> flows = workflowAction.queryNorthBoundRequestCatalogDb(execution, "replaceInstance", WorkflowType.VNF, false,"my-custom-cloud-owner");
- assertEquals(flows.get(0).getFlowName(),"AAICheckVnfInMaintBB");
- assertEquals(flows.get(1).getFlowName(),"AAISetVnfInMaintBB");
- assertEquals(flows.get(2).getFlowName(),"DeactivateVfModuleBB");
- assertEquals(flows.get(3).getFlowName(),"DeleteVfModuleBB");
- assertEquals(flows.get(4).getFlowName(),"DeactivateVnfBB");
- assertEquals(flows.get(5).getFlowName(),"CreateVfModuleBB");
- assertEquals(flows.get(6).getFlowName(),"ActivateVfModuleBB");
- assertEquals(flows.get(7).getFlowName(),"ActivateVnfBB");
- assertEquals(flows.get(8).getFlowName(),"SDNOVnfHealthCheckBB");
- assertEquals(flows.get(9).getFlowName(),"AAIUnsetVnfInMaintBB");
- }
-
- @Test
- public void queryNorthBoundRequestCatalogDbTransportTest() throws MalformedURLException {
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwnerAndServiceType("createInstance","Service",true,"my-custom-cloud-owner","TRANSPORT")).thenReturn(northBoundRequest);
-
- List<OrchestrationFlow> flows = workflowAction.queryNorthBoundRequestCatalogDb(execution, "createInstance", WorkflowType.SERVICE, true,"my-custom-cloud-owner","TRANSPORT");
- assertEquals(flows.get(0).getFlowName(),"AssignServiceInstanceBB");
- }
-
- @Test
- public void extractResourceIdAndTypeFromUriTest(){
- String uri = "/v6/serviceInstances/123";
- String uri2 = "/v6/serviceInstances/123/vnfs/1234";
- String uri3 = "/v6/serviceInstances";
- String uri4 = "/v6/serviceInstances/assign";
- String uri5 = "'/v6/serviceInstances/123/vnfs";
- String uri6 = "/v6/serviceInstances/123/vnfs/1234/someAction";
- String uri7 = "/v6/serviceInstances/123/vnfs/1234/vfModules/5678/replace";
- String uri8 = "/v6/serviceInstances/123/vnfs/1234/vfModules/scaleOut";
- Resource expected1 = new Resource(WorkflowType.SERVICE, "123", true);
- Resource expected2 = new Resource(WorkflowType.VNF, "1234", false);
- Resource expected3 = new Resource(WorkflowType.VNF, "1234", false);
- Resource expected4 = new Resource(WorkflowType.VFMODULE, "5678", false);
- Resource result = workflowAction.extractResourceIdAndTypeFromUri(uri);
- assertEquals(expected1.getResourceId(),result.getResourceId());
- assertEquals(expected1.getResourceType(),result.getResourceType());
- result = workflowAction.extractResourceIdAndTypeFromUri(uri2);
- assertEquals(expected2.getResourceId(),result.getResourceId());
- assertEquals(expected2.getResourceType(),result.getResourceType());
- result = workflowAction.extractResourceIdAndTypeFromUri(uri3);
- assertEquals("Service", result.getResourceType().toString());
- assertEquals(UUID.randomUUID().toString().length(),result.getResourceId().length());
- result = workflowAction.extractResourceIdAndTypeFromUri(uri4);
- assertEquals("Service", result.getResourceType().toString());
- assertEquals(UUID.randomUUID().toString().length(),result.getResourceId().length());
- result = workflowAction.extractResourceIdAndTypeFromUri(uri5);
- assertEquals("Vnf", result.getResourceType().toString());
- assertEquals(UUID.randomUUID().toString().length(),result.getResourceId().length());
- result = workflowAction.extractResourceIdAndTypeFromUri(uri6);
- assertEquals(expected3.getResourceId(),result.getResourceId());
- assertEquals(expected3.getResourceType(),result.getResourceType());
- result = workflowAction.extractResourceIdAndTypeFromUri(uri7);
- assertEquals(expected4.getResourceId(),result.getResourceId());
- assertEquals(expected4.getResourceType(),result.getResourceType());
- result = workflowAction.extractResourceIdAndTypeFromUri(uri8);
- assertEquals(UUID.randomUUID().toString().length(),result.getResourceId().length());
+
+ @Test
+ public void selectExecutionListALaCarteVfModuleNoFabricDeleteTest() throws Exception {
+ String gAction = "deleteInstance";
+ String resource = "VfModule";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest =
+ new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", true);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri",
+ "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules");
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB",
+ "UnassignVfModuleBB", "DeactivateFabricConfigurationBB", "UnassignFabricConfigurationBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+
+ org.onap.aai.domain.yang.GenericVnf vnf = new org.onap.aai.domain.yang.GenericVnf();
+ vnf.setVnfId("vnf0");
+ vnf.setModelCustomizationId("modelCustomizationId");
+ when(bbSetupUtils.getAAIGenericVnf(anyObject())).thenReturn(vnf);
+
+ org.onap.aai.domain.yang.VfModule vfModule = new org.onap.aai.domain.yang.VfModule();
+ vfModule.setModelCustomizationId("modelCustomizationId");
+ when(bbSetupUtils.getAAIVfModule(anyObject(), anyObject())).thenReturn(vfModule);
+
+ List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>();
+ org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc();
+ vnfc.setModelInvariantId("modelInvariantId");
+ vnfc.setVnfcName("testVnfcName");
+ vnfcs.add(vnfc);
+ doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(anyObject(), anyObject(), anyObject(),
+ anyObject());
+
+ List<org.onap.aai.domain.yang.Configuration> configurations =
+ new ArrayList<org.onap.aai.domain.yang.Configuration>();
+ org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration();
+ doReturn(configurations).when(SPY_workflowAction).getRelatedResourcesInVnfc(anyObject(), anyObject(),
+ anyObject());
+
+ doReturn("testName").when(SPY_workflowAction).getVnfcNameForConfiguration(anyObject());
+
+ SPY_workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEqualsBulkFlowName(ebbs, "DeactivateVfModuleBB", "DeleteVfModuleBB", "UnassignVfModuleBB");
+ }
+
+ @Test
+ public void getRelatedResourcesInVfModuleTest() throws Exception {
+ org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc();
+ vnfc.setModelInvariantId("modelInvariantId");
+ vnfc.setVnfcName("testVnfcName");
+
+ String vfncPayload =
+ new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "/BuildingBlocks/vnfcResponse.json")));
+ AAIResultWrapper vfncWrapper = new AAIResultWrapper(vfncPayload);
+
+ String configurationPayload =
+ new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "/BuildingBlocks/configurationResponse.json")));
+ AAIResultWrapper configurationWrapper = new AAIResultWrapper(configurationPayload);
+ List<AAIResultWrapper> configurationResultWrappers = new ArrayList<AAIResultWrapper>();
+ configurationResultWrappers.add(configurationWrapper);
+
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VNFC, vnfc.getVnfcName());
+ when(bbSetupUtils.getAAIResourceDepthOne(uri)).thenReturn(vfncWrapper);
+
+ doReturn(configurationResultWrappers).when(SPY_workflowAction).getResultWrappersFromRelationships(anyObject(),
+ anyObject());
+ List<org.onap.aai.domain.yang.Configuration> configurationsList = SPY_workflowAction.getRelatedResourcesInVnfc(
+ vnfc, org.onap.aai.domain.yang.Configuration.class, AAIObjectType.CONFIGURATION);
+ assertEquals(1, configurationsList.size());
+ assertEquals("testConfigurationId", configurationsList.get(0).getConfigurationId());
+ }
+
+ /**
+ * WorkflowActionBB Tests
+ */
+
+ @Test
+ public void pluralTest() {
+ List<String> items = Arrays.asList("serviceInstances, Service", "vnfs, Vnf", "vfModules, VfModule",
+ "networks, Network", "invalidNames, invalidNames");
+ items.forEach(item -> {
+ String[] split = item.split(",");
+ String type = split[0].trim();
+ String expected = split[1].trim();
+ assertThat(workflowAction.convertTypeFromPlural(type), equalTo(expected));
+ });
+ }
+
+ @Test
+ public void sortExecutionPathByObjectForVlanTaggingCreateTest() throws Exception {
+ List<ExecuteBuildingBlock> executeFlows = new ArrayList<>();
+ ExecuteBuildingBlock ebb = new ExecuteBuildingBlock();
+ BuildingBlock bb = new BuildingBlock();
+ bb.setBpmnFlowName("AssignNetworkBB");
+ bb.setKey("0");
+ ebb.setBuildingBlock(bb);
+ executeFlows.add(ebb);
+ ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
+ BuildingBlock bb2 = new BuildingBlock();
+ bb2.setBpmnFlowName("AssignNetworkBB");
+ bb2.setKey("1");
+ ebb2.setBuildingBlock(bb2);
+ executeFlows.add(ebb2);
+ ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock();
+ BuildingBlock bb3 = new BuildingBlock();
+ bb3.setBpmnFlowName("CreateNetworkBB");
+ bb3.setKey("0");
+ ebb3.setBuildingBlock(bb3);
+ executeFlows.add(ebb3);
+ ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock();
+ BuildingBlock bb4 = new BuildingBlock();
+ bb4.setBpmnFlowName("CreateNetworkBB");
+ bb4.setKey("1");
+ ebb4.setBuildingBlock(bb4);
+ executeFlows.add(ebb4);
+ ExecuteBuildingBlock ebb5 = new ExecuteBuildingBlock();
+ BuildingBlock bb5 = new BuildingBlock();
+ bb5.setBpmnFlowName("ActivateNetworkBB");
+ bb5.setKey("0");
+ ebb5.setBuildingBlock(bb5);
+ executeFlows.add(ebb5);
+ ExecuteBuildingBlock ebb6 = new ExecuteBuildingBlock();
+ BuildingBlock bb6 = new BuildingBlock();
+ bb6.setBpmnFlowName("ActivateNetworkBB");
+ bb6.setKey("1");
+ ebb6.setBuildingBlock(bb6);
+ executeFlows.add(ebb6);
+
+ List<ExecuteBuildingBlock> sorted =
+ workflowAction.sortExecutionPathByObjectForVlanTagging(executeFlows, "createInstance");
+ assertEqualsBulkFlowName(sorted, "AssignNetworkBB", "CreateNetworkBB", "ActivateNetworkBB", "AssignNetworkBB",
+ "CreateNetworkBB", "ActivateNetworkBB");
+ }
+
+ @Test
+ public void sortExecutionPathByObjectForVlanTaggingDeleteTest() throws Exception {
+ List<ExecuteBuildingBlock> executeFlows = new ArrayList<>();
+ ExecuteBuildingBlock ebb = new ExecuteBuildingBlock();
+ BuildingBlock bb = new BuildingBlock();
+ bb.setBpmnFlowName("DeactivateNetworkBB");
+ bb.setKey("0");
+ ebb.setBuildingBlock(bb);
+ executeFlows.add(ebb);
+ ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
+ BuildingBlock bb2 = new BuildingBlock();
+ bb2.setBpmnFlowName("DeactivateNetworkBB");
+ bb2.setKey("1");
+ ebb2.setBuildingBlock(bb2);
+ executeFlows.add(ebb2);
+ ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock();
+ BuildingBlock bb3 = new BuildingBlock();
+ bb3.setBpmnFlowName("DeleteNetworkBB");
+ bb3.setKey("0");
+ ebb3.setBuildingBlock(bb3);
+ executeFlows.add(ebb3);
+ ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock();
+ BuildingBlock bb4 = new BuildingBlock();
+ bb4.setBpmnFlowName("DeleteNetworkBB");
+ bb4.setKey("1");
+ ebb4.setBuildingBlock(bb4);
+ executeFlows.add(ebb4);
+ ExecuteBuildingBlock ebb5 = new ExecuteBuildingBlock();
+ BuildingBlock bb5 = new BuildingBlock();
+ bb5.setBpmnFlowName("UnassignNetworkBB");
+ bb5.setKey("0");
+ ebb5.setBuildingBlock(bb5);
+ executeFlows.add(ebb5);
+ ExecuteBuildingBlock ebb6 = new ExecuteBuildingBlock();
+ BuildingBlock bb6 = new BuildingBlock();
+ bb6.setBpmnFlowName("UnassignNetworkBB");
+ bb6.setKey("1");
+ ebb6.setBuildingBlock(bb6);
+ executeFlows.add(ebb6);
+
+ List<ExecuteBuildingBlock> sorted =
+ workflowAction.sortExecutionPathByObjectForVlanTagging(executeFlows, "deleteInstance");
+ assertEqualsBulkFlowName(sorted, "DeactivateNetworkBB", "DeleteNetworkBB", "UnassignNetworkBB",
+ "DeactivateNetworkBB", "DeleteNetworkBB", "UnassignNetworkBB");
+ }
+
+ @Test
+ public void queryNorthBoundRequestCatalogDbNestedTest() throws MalformedURLException {
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows = createFlowList("AAICheckVnfInMaintBB", "AAISetVnfInMaintBB",
+ "VNF-Macro-Replace", "SDNOVnfHealthCheckBB", "AAIUnsetVnfInMaintBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+ List<OrchestrationFlow> macroFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB",
+ "DeactivateVnfBB", "CreateVfModuleBB", "ActivateVfModuleBB", "ActivateVnfBB");
+
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner("replaceInstance",
+ "Vnf", false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ when(catalogDbClient.getOrchestrationFlowByAction("VNF-Macro-Replace")).thenReturn(macroFlows);
+ List<OrchestrationFlow> flows = workflowAction.queryNorthBoundRequestCatalogDb(execution, "replaceInstance",
+ WorkflowType.VNF, false, "my-custom-cloud-owner");
+ assertEquals(flows.get(0).getFlowName(), "AAICheckVnfInMaintBB");
+ assertEquals(flows.get(1).getFlowName(), "AAISetVnfInMaintBB");
+ assertEquals(flows.get(2).getFlowName(), "DeactivateVfModuleBB");
+ assertEquals(flows.get(3).getFlowName(), "DeleteVfModuleBB");
+ assertEquals(flows.get(4).getFlowName(), "DeactivateVnfBB");
+ assertEquals(flows.get(5).getFlowName(), "CreateVfModuleBB");
+ assertEquals(flows.get(6).getFlowName(), "ActivateVfModuleBB");
+ assertEquals(flows.get(7).getFlowName(), "ActivateVnfBB");
+ assertEquals(flows.get(8).getFlowName(), "SDNOVnfHealthCheckBB");
+ assertEquals(flows.get(9).getFlowName(), "AAIUnsetVnfInMaintBB");
+ }
+
+ @Test
+ public void queryNorthBoundRequestCatalogDbTransportTest() throws MalformedURLException {
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwnerAndServiceType(
+ "createInstance", "Service", true, "my-custom-cloud-owner", "TRANSPORT")).thenReturn(northBoundRequest);
+
+ List<OrchestrationFlow> flows = workflowAction.queryNorthBoundRequestCatalogDb(execution, "createInstance",
+ WorkflowType.SERVICE, true, "my-custom-cloud-owner", "TRANSPORT");
+ assertEquals(flows.get(0).getFlowName(), "AssignServiceInstanceBB");
+ }
+
+ @Test
+ public void extractResourceIdAndTypeFromUriTest() {
+ String uri = "/v6/serviceInstances/123";
+ String uri2 = "/v6/serviceInstances/123/vnfs/1234";
+ String uri3 = "/v6/serviceInstances";
+ String uri4 = "/v6/serviceInstances/assign";
+ String uri5 = "'/v6/serviceInstances/123/vnfs";
+ String uri6 = "/v6/serviceInstances/123/vnfs/1234/someAction";
+ String uri7 = "/v6/serviceInstances/123/vnfs/1234/vfModules/5678/replace";
+ String uri8 = "/v6/serviceInstances/123/vnfs/1234/vfModules/scaleOut";
+ Resource expected1 = new Resource(WorkflowType.SERVICE, "123", true);
+ Resource expected2 = new Resource(WorkflowType.VNF, "1234", false);
+ Resource expected3 = new Resource(WorkflowType.VNF, "1234", false);
+ Resource expected4 = new Resource(WorkflowType.VFMODULE, "5678", false);
+ Resource result = workflowAction.extractResourceIdAndTypeFromUri(uri);
+ assertEquals(expected1.getResourceId(), result.getResourceId());
+ assertEquals(expected1.getResourceType(), result.getResourceType());
+ result = workflowAction.extractResourceIdAndTypeFromUri(uri2);
+ assertEquals(expected2.getResourceId(), result.getResourceId());
+ assertEquals(expected2.getResourceType(), result.getResourceType());
+ result = workflowAction.extractResourceIdAndTypeFromUri(uri3);
+ assertEquals("Service", result.getResourceType().toString());
+ assertEquals(UUID.randomUUID().toString().length(), result.getResourceId().length());
+ result = workflowAction.extractResourceIdAndTypeFromUri(uri4);
+ assertEquals("Service", result.getResourceType().toString());
+ assertEquals(UUID.randomUUID().toString().length(), result.getResourceId().length());
+ result = workflowAction.extractResourceIdAndTypeFromUri(uri5);
+ assertEquals("Vnf", result.getResourceType().toString());
+ assertEquals(UUID.randomUUID().toString().length(), result.getResourceId().length());
+ result = workflowAction.extractResourceIdAndTypeFromUri(uri6);
+ assertEquals(expected3.getResourceId(), result.getResourceId());
+ assertEquals(expected3.getResourceType(), result.getResourceType());
+ result = workflowAction.extractResourceIdAndTypeFromUri(uri7);
+ assertEquals(expected4.getResourceId(), result.getResourceId());
+ assertEquals(expected4.getResourceType(), result.getResourceType());
+ result = workflowAction.extractResourceIdAndTypeFromUri(uri8);
+ assertEquals(UUID.randomUUID().toString().length(), result.getResourceId().length());
assertEquals("VfModule", result.getResourceType().toString());
-
- }
-
- @Test
- public void extractResourceIdAndTypeFromUriInvalidTypeTest() {
- this.expectedException.expect(IllegalArgumentException.class);
- this.expectedException.expectMessage(containsString("Uri could not be parsed. No type found."));
- workflowAction.extractResourceIdAndTypeFromUri("/v6/serviceInstances/123/vnfs/1234/vfmodules/5678/replace");
- }
-
- @Test
- public void extractResourceIdAndTypeFromUriInvalidUriTest() {
- this.expectedException.expect(IllegalArgumentException.class);
- this.expectedException.expectMessage(containsString("Uri could not be parsed:"));
- workflowAction.extractResourceIdAndTypeFromUri("something that doesn't match anything");
- }
-
- @Test
- public void populateResourceIdsFromApiHandlerTest(){
- execution.setVariable("serviceInstanceId", "123");
- execution.setVariable("vnfId", "888");
- WorkflowResourceIds x = workflowAction.populateResourceIdsFromApiHandler(execution);
- assertEquals("123",x.getServiceInstanceId());
- assertEquals("888",x.getVnfId());
- assertNull(x.getVolumeGroupId());
- }
-
- @Test
- public void validateResourceIdInAAITest() throws Exception{
- //SI
- RequestDetails reqDetails = new RequestDetails();
- SubscriberInfo subInfo = new SubscriberInfo();
- subInfo.setGlobalSubscriberId("id123");
- reqDetails.setSubscriberInfo(subInfo);
- RequestParameters reqParams = new RequestParameters();
- reqParams.setSubscriptionServiceType("subServiceType123");
- reqDetails.setRequestParameters(reqParams );
- WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
- ServiceInstance si = new ServiceInstance();
- si.setServiceInstanceId("siId123");
- Optional<ServiceInstance> siOp = Optional.of(si);
- when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "siName123")).thenReturn(siOp);
- when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "111111")).thenReturn(Optional.empty());
- String id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.SERVICE, "siName123", reqDetails, workflowResourceIds);
- assertEquals("siId123",id);
- String id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.SERVICE, "111111", reqDetails, workflowResourceIds);
- assertEquals("generatedId123",id2);
-
- //Network
- L3Network network = new L3Network();
- network.setNetworkId("id123");
- network.setNetworkName("name123");
- workflowResourceIds.setServiceInstanceId("siId123");
- Optional<L3Network> opNetwork = Optional.of(network);
- when(bbSetupUtils.getRelatedNetworkByNameFromServiceInstance("siId123","name123")).thenReturn(opNetwork);
- when(bbSetupUtils.getRelatedNetworkByNameFromServiceInstance("siId123","111111")).thenReturn(Optional.empty());
- id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.NETWORK, "name123", reqDetails, workflowResourceIds);
- assertEquals("id123",id);
- id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.NETWORK, "111111", reqDetails, workflowResourceIds);
- assertEquals("generatedId123",id2);
-
- //Vnf
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("id123");
- vnf.setVnfName("vnfName123");
- Optional<GenericVnf> opVnf = Optional.of(vnf);
- when(bbSetupUtils.getRelatedVnfByNameFromServiceInstance("siId123","name123")).thenReturn(opVnf);
- when(bbSetupUtils.getRelatedVnfByNameFromServiceInstance("siId123","111111")).thenReturn(Optional.empty());
- id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VNF, "name123", reqDetails, workflowResourceIds);
- assertEquals("id123",id);
- id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VNF, "111111", reqDetails, workflowResourceIds);
- assertEquals("generatedId123",id2);
-
- //VfModule
- VfModules vfModules = new VfModules();
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("id123");
- vfModule.setVfModuleName("name123");
- vfModules.getVfModule().add(vfModule);
- vnf.setVfModules(vfModules);
- workflowResourceIds.setVnfId("id123");
- when(bbSetupUtils.getAAIGenericVnf("id123")).thenReturn(vnf);
- id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VFMODULE, "name123", reqDetails, workflowResourceIds);
- assertEquals("id123",id);
-
- GenericVnf vnf2 = new GenericVnf();
- VfModules vfModules2 = new VfModules();
- VfModule vfModule2 = new VfModule();
- vfModule2.setVfModuleId("id123");
- vfModule2.setVfModuleName("name123");
- vfModules2.getVfModule().add(vfModule2);
- vnf2.setVfModules(vfModules2);
- workflowResourceIds.setVnfId("id111");
- when(bbSetupUtils.getAAIGenericVnf("id111")).thenReturn(vnf2);
- id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VFMODULE, "111111", reqDetails, workflowResourceIds);
- assertEquals("generatedId123",id2);
-
- //VolumeGroup
- VolumeGroup volumeGroup = new VolumeGroup();
- volumeGroup.setVolumeGroupId("id123");
- volumeGroup.setVolumeGroupName("name123");
- workflowResourceIds.setVnfId("id123");
- Optional<VolumeGroup> opVolumeGroup = Optional.of(volumeGroup);
- when(bbSetupUtils.getRelatedVolumeGroupByNameFromVnf("id123","name123")).thenReturn(opVolumeGroup);
- id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VOLUMEGROUP, "name123", reqDetails, workflowResourceIds);
- assertEquals("id123",id);
-
- workflowResourceIds.setVnfId("id444");
- when(bbSetupUtils.getAAIGenericVnf("id444")).thenReturn(vnf);
- when(bbSetupUtils.getRelatedVolumeGroupByNameFromVfModule("id123", "id123","111111")).thenReturn(opVolumeGroup);
- when(bbSetupUtils.getRelatedVolumeGroupByNameFromVnf("id444","111111")).thenReturn(Optional.empty());
- id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VOLUMEGROUP, "111111", reqDetails, workflowResourceIds);
- assertEquals("id123",id2);
- }
-
- @Test
- public void handleRuntimeExceptionTest(){
- execution.setVariable("BPMN_javaExpMsg", "test runtime error message");
- execution.setVariable("testProcessKey", "testProcessKeyValue");
- try{
- workflowAction.handleRuntimeException(execution);
- } catch (BpmnError wfe) {
- assertEquals("MSOWorkflowException",wfe.getErrorCode());
- }
- }
-
- @Ignore
- @Test
- public void traverseCatalogDbServiceMultipleNetworkTest() throws IOException{
- execution.setVariable("testProcessKey", "testProcessKeyValue");
- Service service = new Service();
- List<NetworkResourceCustomization> networkCustomizations = new ArrayList<>();
- NetworkResourceCustomization networkCust = new NetworkResourceCustomization();
- networkCust.setModelCustomizationUUID("123");
- networkCustomizations.add(networkCust);
- service.setNetworkCustomizations(networkCustomizations);
- NetworkCollectionResourceCustomization collectionResourceCustomization = new NetworkCollectionResourceCustomization();
- collectionResourceCustomization.setModelCustomizationUUID("123");
- CollectionResource collectionResource = new CollectionResource();
- collectionResource.setToscaNodeType("NetworkCollection");
- InstanceGroup instanceGroup = new InstanceGroup();
- List<CollectionResourceInstanceGroupCustomization> collectionInstanceGroupCustomizations = new ArrayList<>();
- CollectionResourceInstanceGroupCustomization collectionInstanceGroupCustomization = new CollectionResourceInstanceGroupCustomization();
- collectionInstanceGroupCustomization.setSubInterfaceNetworkQuantity(3);
- collectionInstanceGroupCustomizations.add(collectionInstanceGroupCustomization);
- instanceGroup.setCollectionInstanceGroupCustomizations(collectionInstanceGroupCustomizations);
- collectionResource.setInstanceGroup(instanceGroup);
- collectionResourceCustomization.setCollectionResource(collectionResource);;
- service.setModelUUID("abc");
- service.getCollectionResourceCustomizations().add(collectionResourceCustomization);
- service.getCollectionResourceCustomizations().add(collectionResourceCustomization);
- doReturn(service).when(catalogDbClient).getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a");
- doReturn(collectionResourceCustomization).when(catalogDbClient).getNetworkCollectionResourceCustomizationByID("123");
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json")));
- ObjectMapper mapper = new ObjectMapper();
- ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class);
- List<Resource> resourceCounter = new ArrayList<>();
- thrown.expect(BpmnError.class);
- workflowAction.traverseCatalogDbService(execution, sIRequest, resourceCounter);
- }
-
- @Test
- public void sortVfModulesByBaseFirstTest(){
- List<Resource> resources = new ArrayList<>();
- Resource resource1 = new Resource(WorkflowType.VFMODULE,"111",false);
- resource1.setBaseVfModule(false);
- resources.add(resource1);
- Resource resource2 = new Resource(WorkflowType.VFMODULE,"222",false);
- resource2.setBaseVfModule(false);
- resources.add(resource2);
- Resource resource3 = new Resource(WorkflowType.VFMODULE,"333",false);
- resource3.setBaseVfModule(true);
- resources.add(resource3);
- List<Resource> result = workflowAction.sortVfModulesByBaseFirst(resources);
- assertEquals("333",result.get(0).getResourceId());
- assertEquals("222",result.get(1).getResourceId());
- assertEquals("111",result.get(2).getResourceId());
- }
-
- @Test
- public void sortVfModulesByBaseLastTest(){
- List<Resource> resources = new ArrayList<>();
- Resource resource1 = new Resource(WorkflowType.VFMODULE,"111",false);
- resource1.setBaseVfModule(true);
- resources.add(resource1);
- Resource resource2 = new Resource(WorkflowType.VFMODULE,"222",false);
- resource2.setBaseVfModule(false);
- resources.add(resource2);
- Resource resource3 = new Resource(WorkflowType.VFMODULE,"333",false);
- resource3.setBaseVfModule(false);
- resources.add(resource3);
- List<Resource> result = workflowAction.sortVfModulesByBaseLast(resources);
- assertEquals("333",result.get(0).getResourceId());
- assertEquals("222",result.get(1).getResourceId());
- assertEquals("111",result.get(2).getResourceId());
- }
+
+ }
+
+ @Test
+ public void extractResourceIdAndTypeFromUriInvalidTypeTest() {
+ this.expectedException.expect(IllegalArgumentException.class);
+ this.expectedException.expectMessage(containsString("Uri could not be parsed. No type found."));
+ workflowAction.extractResourceIdAndTypeFromUri("/v6/serviceInstances/123/vnfs/1234/vfmodules/5678/replace");
+ }
+
+ @Test
+ public void extractResourceIdAndTypeFromUriInvalidUriTest() {
+ this.expectedException.expect(IllegalArgumentException.class);
+ this.expectedException.expectMessage(containsString("Uri could not be parsed:"));
+ workflowAction.extractResourceIdAndTypeFromUri("something that doesn't match anything");
+ }
+
+ @Test
+ public void populateResourceIdsFromApiHandlerTest() {
+ execution.setVariable("serviceInstanceId", "123");
+ execution.setVariable("vnfId", "888");
+ WorkflowResourceIds x = workflowAction.populateResourceIdsFromApiHandler(execution);
+ assertEquals("123", x.getServiceInstanceId());
+ assertEquals("888", x.getVnfId());
+ assertNull(x.getVolumeGroupId());
+ }
+
+ @Test
+ public void validateResourceIdInAAITest() throws Exception {
+ // SI
+ RequestDetails reqDetails = new RequestDetails();
+ SubscriberInfo subInfo = new SubscriberInfo();
+ subInfo.setGlobalSubscriberId("id123");
+ reqDetails.setSubscriberInfo(subInfo);
+ RequestParameters reqParams = new RequestParameters();
+ reqParams.setSubscriptionServiceType("subServiceType123");
+ reqDetails.setRequestParameters(reqParams);
+ WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
+ ServiceInstance si = new ServiceInstance();
+ si.setServiceInstanceId("siId123");
+ Optional<ServiceInstance> siOp = Optional.of(si);
+ when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "siName123")).thenReturn(siOp);
+ when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "111111"))
+ .thenReturn(Optional.empty());
+ String id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.SERVICE, "siName123",
+ reqDetails, workflowResourceIds);
+ assertEquals("siId123", id);
+ String id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.SERVICE, "111111",
+ reqDetails, workflowResourceIds);
+ assertEquals("generatedId123", id2);
+
+ // Network
+ L3Network network = new L3Network();
+ network.setNetworkId("id123");
+ network.setNetworkName("name123");
+ workflowResourceIds.setServiceInstanceId("siId123");
+ Optional<L3Network> opNetwork = Optional.of(network);
+ when(bbSetupUtils.getRelatedNetworkByNameFromServiceInstance("siId123", "name123")).thenReturn(opNetwork);
+ when(bbSetupUtils.getRelatedNetworkByNameFromServiceInstance("siId123", "111111")).thenReturn(Optional.empty());
+ id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.NETWORK, "name123", reqDetails,
+ workflowResourceIds);
+ assertEquals("id123", id);
+ id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.NETWORK, "111111", reqDetails,
+ workflowResourceIds);
+ assertEquals("generatedId123", id2);
+
+ // Vnf
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("id123");
+ vnf.setVnfName("vnfName123");
+ Optional<GenericVnf> opVnf = Optional.of(vnf);
+ when(bbSetupUtils.getRelatedVnfByNameFromServiceInstance("siId123", "name123")).thenReturn(opVnf);
+ when(bbSetupUtils.getRelatedVnfByNameFromServiceInstance("siId123", "111111")).thenReturn(Optional.empty());
+ id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VNF, "name123", reqDetails,
+ workflowResourceIds);
+ assertEquals("id123", id);
+ id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VNF, "111111", reqDetails,
+ workflowResourceIds);
+ assertEquals("generatedId123", id2);
+
+ // VfModule
+ VfModules vfModules = new VfModules();
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("id123");
+ vfModule.setVfModuleName("name123");
+ vfModules.getVfModule().add(vfModule);
+ vnf.setVfModules(vfModules);
+ workflowResourceIds.setVnfId("id123");
+ when(bbSetupUtils.getAAIGenericVnf("id123")).thenReturn(vnf);
+ id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VFMODULE, "name123", reqDetails,
+ workflowResourceIds);
+ assertEquals("id123", id);
+
+ GenericVnf vnf2 = new GenericVnf();
+ VfModules vfModules2 = new VfModules();
+ VfModule vfModule2 = new VfModule();
+ vfModule2.setVfModuleId("id123");
+ vfModule2.setVfModuleName("name123");
+ vfModules2.getVfModule().add(vfModule2);
+ vnf2.setVfModules(vfModules2);
+ workflowResourceIds.setVnfId("id111");
+ when(bbSetupUtils.getAAIGenericVnf("id111")).thenReturn(vnf2);
+ id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VFMODULE, "111111", reqDetails,
+ workflowResourceIds);
+ assertEquals("generatedId123", id2);
+
+ // VolumeGroup
+ VolumeGroup volumeGroup = new VolumeGroup();
+ volumeGroup.setVolumeGroupId("id123");
+ volumeGroup.setVolumeGroupName("name123");
+ workflowResourceIds.setVnfId("id123");
+ Optional<VolumeGroup> opVolumeGroup = Optional.of(volumeGroup);
+ when(bbSetupUtils.getRelatedVolumeGroupByNameFromVnf("id123", "name123")).thenReturn(opVolumeGroup);
+ id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VOLUMEGROUP, "name123", reqDetails,
+ workflowResourceIds);
+ assertEquals("id123", id);
+
+ workflowResourceIds.setVnfId("id444");
+ when(bbSetupUtils.getAAIGenericVnf("id444")).thenReturn(vnf);
+ when(bbSetupUtils.getRelatedVolumeGroupByNameFromVfModule("id123", "id123", "111111"))
+ .thenReturn(opVolumeGroup);
+ when(bbSetupUtils.getRelatedVolumeGroupByNameFromVnf("id444", "111111")).thenReturn(Optional.empty());
+ id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VOLUMEGROUP, "111111", reqDetails,
+ workflowResourceIds);
+ assertEquals("id123", id2);
+ }
+
+ @Test
+ public void handleRuntimeExceptionTest() {
+ execution.setVariable("BPMN_javaExpMsg", "test runtime error message");
+ execution.setVariable("testProcessKey", "testProcessKeyValue");
+ try {
+ workflowAction.handleRuntimeException(execution);
+ } catch (BpmnError wfe) {
+ assertEquals("MSOWorkflowException", wfe.getErrorCode());
+ }
+ }
+
+ @Ignore
+ @Test
+ public void traverseCatalogDbServiceMultipleNetworkTest() throws IOException {
+ execution.setVariable("testProcessKey", "testProcessKeyValue");
+ Service service = new Service();
+ List<NetworkResourceCustomization> networkCustomizations = new ArrayList<>();
+ NetworkResourceCustomization networkCust = new NetworkResourceCustomization();
+ networkCust.setModelCustomizationUUID("123");
+ networkCustomizations.add(networkCust);
+ service.setNetworkCustomizations(networkCustomizations);
+ NetworkCollectionResourceCustomization collectionResourceCustomization =
+ new NetworkCollectionResourceCustomization();
+ collectionResourceCustomization.setModelCustomizationUUID("123");
+ CollectionResource collectionResource = new CollectionResource();
+ collectionResource.setToscaNodeType("NetworkCollection");
+ InstanceGroup instanceGroup = new InstanceGroup();
+ List<CollectionResourceInstanceGroupCustomization> collectionInstanceGroupCustomizations = new ArrayList<>();
+ CollectionResourceInstanceGroupCustomization collectionInstanceGroupCustomization =
+ new CollectionResourceInstanceGroupCustomization();
+ collectionInstanceGroupCustomization.setSubInterfaceNetworkQuantity(3);
+ collectionInstanceGroupCustomizations.add(collectionInstanceGroupCustomization);
+ instanceGroup.setCollectionInstanceGroupCustomizations(collectionInstanceGroupCustomizations);
+ collectionResource.setInstanceGroup(instanceGroup);
+ collectionResourceCustomization.setCollectionResource(collectionResource);;
+ service.setModelUUID("abc");
+ service.getCollectionResourceCustomizations().add(collectionResourceCustomization);
+ service.getCollectionResourceCustomizations().add(collectionResourceCustomization);
+ doReturn(service).when(catalogDbClient).getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a");
+ doReturn(collectionResourceCustomization).when(catalogDbClient)
+ .getNetworkCollectionResourceCustomizationByID("123");
+ String bpmnRequest = new String(Files
+ .readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json")));
+ ObjectMapper mapper = new ObjectMapper();
+ ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class);
+ List<Resource> resourceCounter = new ArrayList<>();
+ thrown.expect(BpmnError.class);
+ workflowAction.traverseCatalogDbService(execution, sIRequest, resourceCounter);
+ }
+
+ @Test
+ public void sortVfModulesByBaseFirstTest() {
+ List<Resource> resources = new ArrayList<>();
+ Resource resource1 = new Resource(WorkflowType.VFMODULE, "111", false);
+ resource1.setBaseVfModule(false);
+ resources.add(resource1);
+ Resource resource2 = new Resource(WorkflowType.VFMODULE, "222", false);
+ resource2.setBaseVfModule(false);
+ resources.add(resource2);
+ Resource resource3 = new Resource(WorkflowType.VFMODULE, "333", false);
+ resource3.setBaseVfModule(true);
+ resources.add(resource3);
+ List<Resource> result = workflowAction.sortVfModulesByBaseFirst(resources);
+ assertEquals("333", result.get(0).getResourceId());
+ assertEquals("222", result.get(1).getResourceId());
+ assertEquals("111", result.get(2).getResourceId());
+ }
+
+ @Test
+ public void sortVfModulesByBaseLastTest() {
+ List<Resource> resources = new ArrayList<>();
+ Resource resource1 = new Resource(WorkflowType.VFMODULE, "111", false);
+ resource1.setBaseVfModule(true);
+ resources.add(resource1);
+ Resource resource2 = new Resource(WorkflowType.VFMODULE, "222", false);
+ resource2.setBaseVfModule(false);
+ resources.add(resource2);
+ Resource resource3 = new Resource(WorkflowType.VFMODULE, "333", false);
+ resource3.setBaseVfModule(false);
+ resources.add(resource3);
+ List<Resource> result = workflowAction.sortVfModulesByBaseLast(resources);
+ assertEquals("333", result.get(0).getResourceId());
+ assertEquals("222", result.get(1).getResourceId());
+ assertEquals("111", result.get(2).getResourceId());
+ }
@Test
public void findCatalogNetworkCollectionTest() {
@@ -1468,35 +1657,34 @@ public class WorkflowActionTest extends BaseTaskTest {
doReturn(networkCustomization2).when(catalogDbClient).getNetworkCollectionResourceCustomizationByID("321");
workflowAction.findCatalogNetworkCollection(execution, service);
assertEquals("Found multiple Network Collections in the Service model, only one per Service is supported.",
- execution.getVariable("WorkflowActionErrorMessage"));
+ execution.getVariable("WorkflowActionErrorMessage"));
}
@Test
- public void verifyLackOfNullPointerExceptionForNullResource(){
- ExecuteBuildingBlock result = null;
- try {
- result = workflowAction
- .buildExecuteBuildingBlock(new OrchestrationFlow(), null, null, null, null, null, false,
- null, null, null, false, null, true);
- }catch (NullPointerException e){
- fail("NullPointerException should not be thrown when 'resource' is null");
- }
- assertNotNull(result);
+ public void verifyLackOfNullPointerExceptionForNullResource() {
+ ExecuteBuildingBlock result = null;
+ try {
+ result = workflowAction.buildExecuteBuildingBlock(new OrchestrationFlow(), null, null, null, null, null,
+ false, null, null, null, false, null, true);
+ } catch (NullPointerException e) {
+ fail("NullPointerException should not be thrown when 'resource' is null");
+ }
+ assertNotNull(result);
}
- private List<OrchestrationFlow> createFlowList (String... flowNames){
- List<OrchestrationFlow> result = new ArrayList<>();
- for(String flowName : flowNames){
- OrchestrationFlow orchFlow = new OrchestrationFlow();
- orchFlow.setFlowName(flowName);
- result.add(orchFlow);
- }
- return result;
- }
-
- private void assertEqualsBulkFlowName (List<ExecuteBuildingBlock> ebbs, String... flowNames){
- for(int i = 0; i<ebbs.size(); i++){
- assertEquals(ebbs.get(i).getBuildingBlock().getBpmnFlowName(),flowNames[i]);
- }
- }
+ private List<OrchestrationFlow> createFlowList(String... flowNames) {
+ List<OrchestrationFlow> result = new ArrayList<>();
+ for (String flowName : flowNames) {
+ OrchestrationFlow orchFlow = new OrchestrationFlow();
+ orchFlow.setFlowName(flowName);
+ result.add(orchFlow);
+ }
+ return result;
+ }
+
+ private void assertEqualsBulkFlowName(List<ExecuteBuildingBlock> ebbs, String... flowNames) {
+ for (int i = 0; i < ebbs.size(); i++) {
+ assertEquals(ebbs.get(i).getBuildingBlock().getBpmnFlowName(), flowNames[i]);
+ }
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java
index ada8a237e7..34ad1b0fd4 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java
@@ -31,7 +31,6 @@ import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
@@ -39,7 +38,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -65,57 +63,59 @@ import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
@RunWith(MockitoJUnitRunner.class)
public class WorkflowActionUnitTest {
- private final static String JSON_FILE_LOCATION = "src/test/resources/__files/Macro/";
-
- @Mock
- private CatalogDbClient catalogDbClient;
- @Mock
- private BBInputSetup bbInputSetup;
- @Mock
- private BBInputSetupUtils bbInputSetupUtils;
- @Mock
- private ExceptionBuilder exceptionBuilder;
- @Mock
- private AAIConfigurationResources aaiConfigurationResources;
-
- @InjectMocks
- @Spy
- private WorkflowAction workflowAction;
-
- @Test
- public void traverseCatalogDbForConfigurationTest() {
-
- CvnfcCustomization cvnfcCustomization = new CvnfcCustomization();
- CvnfcConfigurationCustomization vfModuleCustomization = new CvnfcConfigurationCustomization();
- ConfigurationResource configuration = new ConfigurationResource();
- configuration.setToscaNodeType("FabricConfiguration");
- configuration.setModelUUID("my-uuid");
- vfModuleCustomization.setConfigurationResource(configuration);
- cvnfcCustomization.setCvnfcConfigurationCustomization(Collections.singleton(vfModuleCustomization));
- List<CvnfcCustomization> cvnfcCustomizations = Arrays.asList(cvnfcCustomization);
- // when(catalogDbClient.getCvnfcCustomizationByVnfCustomizationUUIDAndVfModuleCustomizationUUID(any(String.class), any(String.class)))
- // .thenReturn(cvnfcCustomizations);
-
- // List<CvnfcConfigurationCustomization> results = workflowAction.traverseCatalogDbForConfiguration("myVnfCustomizationId", "myVfModuleCustomizationId");
-
- //assertThat(results, is(Arrays.asList(vfModuleCustomization)));
-
- }
-
- private String getJson(String filename) throws IOException {
- return new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + filename)));
- }
-
- private List<OrchestrationFlow> createFlowList(String... myList) {
-
- List<OrchestrationFlow> result = new ArrayList<>();
- for (String name : myList) {
- OrchestrationFlow flow = new OrchestrationFlow();
- flow.setFlowName(name);
- result.add(flow);
- }
-
- return result;
-
- }
+ private final static String JSON_FILE_LOCATION = "src/test/resources/__files/Macro/";
+
+ @Mock
+ private CatalogDbClient catalogDbClient;
+ @Mock
+ private BBInputSetup bbInputSetup;
+ @Mock
+ private BBInputSetupUtils bbInputSetupUtils;
+ @Mock
+ private ExceptionBuilder exceptionBuilder;
+ @Mock
+ private AAIConfigurationResources aaiConfigurationResources;
+
+ @InjectMocks
+ @Spy
+ private WorkflowAction workflowAction;
+
+ @Test
+ public void traverseCatalogDbForConfigurationTest() {
+
+ CvnfcCustomization cvnfcCustomization = new CvnfcCustomization();
+ CvnfcConfigurationCustomization vfModuleCustomization = new CvnfcConfigurationCustomization();
+ ConfigurationResource configuration = new ConfigurationResource();
+ configuration.setToscaNodeType("FabricConfiguration");
+ configuration.setModelUUID("my-uuid");
+ vfModuleCustomization.setConfigurationResource(configuration);
+ cvnfcCustomization.setCvnfcConfigurationCustomization(Collections.singleton(vfModuleCustomization));
+ List<CvnfcCustomization> cvnfcCustomizations = Arrays.asList(cvnfcCustomization);
+ // when(catalogDbClient.getCvnfcCustomizationByVnfCustomizationUUIDAndVfModuleCustomizationUUID(any(String.class),
+ // any(String.class)))
+ // .thenReturn(cvnfcCustomizations);
+
+ // List<CvnfcConfigurationCustomization> results =
+ // workflowAction.traverseCatalogDbForConfiguration("myVnfCustomizationId", "myVfModuleCustomizationId");
+
+ // assertThat(results, is(Arrays.asList(vfModuleCustomization)));
+
+ }
+
+ private String getJson(String filename) throws IOException {
+ return new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + filename)));
+ }
+
+ private List<OrchestrationFlow> createFlowList(String... myList) {
+
+ List<OrchestrationFlow> result = new ArrayList<>();
+ for (String name : myList) {
+ OrchestrationFlow flow = new OrchestrationFlow();
+ flow.setFlowName(name);
+ result.add(flow);
+ }
+
+ return result;
+
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/sdno/tasks/SDNOHealthCheckTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/sdno/tasks/SDNOHealthCheckTasksTest.java
index 329f2cf8c1..c235902561 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/sdno/tasks/SDNOHealthCheckTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/sdno/tasks/SDNOHealthCheckTasksTest.java
@@ -27,7 +27,6 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
@@ -47,62 +46,66 @@ import org.onap.so.client.orchestration.SDNOHealthCheckResources;
@RunWith(MockitoJUnitRunner.Silent.class)
public class SDNOHealthCheckTasksTest extends TestDataSetup {
-
- @InjectMocks
- protected SDNOHealthCheckTasks sdnoHealthCheckTasks = new SDNOHealthCheckTasks();
-
- @Mock
- SDNOHealthCheckResources MOCK_sdnoHealthCheckResources;
-
-
- @Mock
- private ExceptionBuilder exceptionUtil;
-
- @Mock
- private ExtractPojosForBB extractPojosForBB;
-
-
- private RequestContext requestContext;
- private GenericVnf genericVnf;
-
- @Before
- public void before() throws BBObjectNotFoundException {
- genericVnf = setGenericVnf();
- requestContext = setRequestContext();
- when(extractPojosForBB.extractByKey(any(),any())).thenReturn(genericVnf);
-
- }
-
- @Test
- public void sdnoHealthCheckTest() throws Exception {
- doReturn(true).when(MOCK_sdnoHealthCheckResources).healthCheck(genericVnf, requestContext);
- sdnoHealthCheckTasks.sdnoHealthCheck(execution);
- verify(MOCK_sdnoHealthCheckResources, times(1)).healthCheck(genericVnf, requestContext);
- }
-
- @Test
- public void sdnoHealthCheckNoResponseTest() throws Exception {
-
- doReturn(false).when(MOCK_sdnoHealthCheckResources).healthCheck(genericVnf, requestContext);
- try {
- sdnoHealthCheckTasks.sdnoHealthCheck(execution);
- } catch (Exception e) {
- verify(MOCK_sdnoHealthCheckResources, times(1)).healthCheck(genericVnf, requestContext);
- verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
- }
-
- }
-
- @Test
- public void sdnoHealthCheckExceptionTest() throws Exception {
- doThrow(new Exception("Unknown Error")).when(MOCK_sdnoHealthCheckResources).healthCheck(genericVnf, requestContext);
- doThrow(new BpmnError("Unknown Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
- try {
- sdnoHealthCheckTasks.sdnoHealthCheck(execution);
- } catch (Exception e) {
- verify(MOCK_sdnoHealthCheckResources, times(1)).healthCheck(genericVnf, requestContext);
- verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
- }
-
- }
+
+ @InjectMocks
+ protected SDNOHealthCheckTasks sdnoHealthCheckTasks = new SDNOHealthCheckTasks();
+
+ @Mock
+ SDNOHealthCheckResources MOCK_sdnoHealthCheckResources;
+
+
+ @Mock
+ private ExceptionBuilder exceptionUtil;
+
+ @Mock
+ private ExtractPojosForBB extractPojosForBB;
+
+
+ private RequestContext requestContext;
+ private GenericVnf genericVnf;
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ genericVnf = setGenericVnf();
+ requestContext = setRequestContext();
+ when(extractPojosForBB.extractByKey(any(), any())).thenReturn(genericVnf);
+
+ }
+
+ @Test
+ public void sdnoHealthCheckTest() throws Exception {
+ doReturn(true).when(MOCK_sdnoHealthCheckResources).healthCheck(genericVnf, requestContext);
+ sdnoHealthCheckTasks.sdnoHealthCheck(execution);
+ verify(MOCK_sdnoHealthCheckResources, times(1)).healthCheck(genericVnf, requestContext);
+ }
+
+ @Test
+ public void sdnoHealthCheckNoResponseTest() throws Exception {
+
+ doReturn(false).when(MOCK_sdnoHealthCheckResources).healthCheck(genericVnf, requestContext);
+ try {
+ sdnoHealthCheckTasks.sdnoHealthCheck(execution);
+ } catch (Exception e) {
+ verify(MOCK_sdnoHealthCheckResources, times(1)).healthCheck(genericVnf, requestContext);
+ verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000),
+ any(String.class));
+ }
+
+ }
+
+ @Test
+ public void sdnoHealthCheckExceptionTest() throws Exception {
+ doThrow(new Exception("Unknown Error")).when(MOCK_sdnoHealthCheckResources).healthCheck(genericVnf,
+ requestContext);
+ doThrow(new BpmnError("Unknown Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
+ try {
+ sdnoHealthCheckTasks.sdnoHealthCheck(execution);
+ } catch (Exception e) {
+ verify(MOCK_sdnoHealthCheckResources, times(1)).healthCheck(genericVnf, requestContext);
+ verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000),
+ any(String.class));
+ }
+
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java
index d5b529288f..821e70a8c8 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java
@@ -24,13 +24,11 @@ import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
-
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
-
import org.junit.Test;
import org.onap.aai.domain.yang.RouteTargets;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection;
@@ -60,562 +58,581 @@ import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
-
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
public class AAIObjectMapperTest {
- private AAIObjectMapper aaiObjectMapper = new AAIObjectMapper();
- private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/";
-
-
- @Test
- public void mapConfigurationTest() {
- Configuration configuration = new Configuration();
- configuration.setConfigurationId("configId");
- configuration.setConfigurationName("VNR");
- configuration.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
- configuration.setManagementOption("managementOption");
- ModelInfoConfiguration modelInfoConfiguration = new ModelInfoConfiguration();
- modelInfoConfiguration.setModelCustomizationId("modelCustId");
- modelInfoConfiguration.setModelInvariantId("modelInvariantId");
- modelInfoConfiguration.setModelVersionId("modelVersionId");
- modelInfoConfiguration.setConfigurationType("5G");
- modelInfoConfiguration.setConfigurationRole("ConfigurationRole");
- configuration.setModelInfoConfiguration(modelInfoConfiguration);
-
- org.onap.aai.domain.yang.Configuration expectedConfiguration = new org.onap.aai.domain.yang.Configuration();
- expectedConfiguration.setConfigurationId(configuration.getConfigurationId());
- expectedConfiguration.setConfigurationName(configuration.getConfigurationName());
- expectedConfiguration.setConfigurationType(configuration.getModelInfoConfiguration().getConfigurationType());
- expectedConfiguration.setOrchestrationStatus(configuration.getOrchestrationStatus().toString());
- expectedConfiguration.setManagementOption(configuration.getManagementOption());
- expectedConfiguration.setModelInvariantId(configuration.getModelInfoConfiguration().getModelInvariantId());
- expectedConfiguration.setModelVersionId(configuration.getModelInfoConfiguration().getModelVersionId());
- expectedConfiguration.setModelCustomizationId(configuration.getModelInfoConfiguration().getModelCustomizationId());
- expectedConfiguration.setConfigurationSubType(configuration.getModelInfoConfiguration().getConfigurationRole());
- expectedConfiguration.setConfigPolicyName(configuration.getModelInfoConfiguration().getPolicyName());
-
- org.onap.aai.domain.yang.Configuration actualConfiguration = aaiObjectMapper.mapConfiguration(configuration);
-
- assertThat(actualConfiguration, sameBeanAs(expectedConfiguration));
- }
-
- @Test
- public void mapVolumeGroupTest() throws Exception {
- VolumeGroup volumeGroup = new VolumeGroup();
- volumeGroup.setHeatStackId("heatStackId");
- volumeGroup.setModelInfoVfModule(new ModelInfoVfModule());
- volumeGroup.getModelInfoVfModule().setModelCustomizationUUID("modelCustomizationId");
- volumeGroup.setOrchestrationStatus(OrchestrationStatus.ACTIVE);
- volumeGroup.setVnfType("vnfType");
- volumeGroup.setVolumeGroupId("volumeGroupId");
- volumeGroup.setVolumeGroupName("volumeGroupName");
-
- org.onap.aai.domain.yang.VolumeGroup expectedVolumeGroup = new org.onap.aai.domain.yang.VolumeGroup();
- expectedVolumeGroup.setHeatStackId(volumeGroup.getHeatStackId());
- expectedVolumeGroup.setModelCustomizationId(volumeGroup.getModelInfoVfModule().getModelCustomizationUUID());
- expectedVolumeGroup.setOrchestrationStatus(volumeGroup.getOrchestrationStatus().toString());
- expectedVolumeGroup.setVfModuleModelCustomizationId(volumeGroup.getModelInfoVfModule().getModelCustomizationUUID());
- expectedVolumeGroup.setVnfType(volumeGroup.getVnfType());
- expectedVolumeGroup.setVolumeGroupId(volumeGroup.getVolumeGroupId());
- expectedVolumeGroup.setVolumeGroupName(volumeGroup.getVolumeGroupName());
-
- org.onap.aai.domain.yang.VolumeGroup actualVolumeGroup = aaiObjectMapper.mapVolumeGroup(volumeGroup);
-
- assertThat(actualVolumeGroup, sameBeanAs(expectedVolumeGroup));
- }
-
- @Test
- public void serviceInstanceMap() {
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("SIID");
- serviceInstance.setServiceInstanceName("SINAME");
- serviceInstance.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setServiceType("SITYPE");
- modelInfoServiceInstance.setServiceRole("SIROLE");
- modelInfoServiceInstance.setModelInvariantUuid("MIUUID");
- modelInfoServiceInstance.setModelUuid("MUUID");
- modelInfoServiceInstance.setEnvironmentContext("EC");
- modelInfoServiceInstance.setWorkloadContext("WC");
- serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
-
- org.onap.aai.domain.yang.ServiceInstance AAIServiceInstance = aaiObjectMapper.mapServiceInstance(serviceInstance);
-
- assertEquals(AAIServiceInstance.getServiceInstanceId(),serviceInstance.getServiceInstanceId());
- assertEquals(AAIServiceInstance.getServiceInstanceName(),serviceInstance.getServiceInstanceName());
- assertEquals(AAIServiceInstance.getOrchestrationStatus().toString(),serviceInstance.getOrchestrationStatus().toString());
- assertEquals(AAIServiceInstance.getServiceType(),serviceInstance.getModelInfoServiceInstance().getServiceType());
- assertEquals(AAIServiceInstance.getServiceRole(),serviceInstance.getModelInfoServiceInstance().getServiceRole());
- assertEquals(AAIServiceInstance.getModelInvariantId(),serviceInstance.getModelInfoServiceInstance().getModelInvariantUuid());
- assertEquals(AAIServiceInstance.getModelVersionId(),serviceInstance.getModelInfoServiceInstance().getModelUuid());
- assertEquals(AAIServiceInstance.getEnvironmentContext(),serviceInstance.getModelInfoServiceInstance().getEnvironmentContext());
- assertEquals(AAIServiceInstance.getWorkloadContext(),serviceInstance.getModelInfoServiceInstance().getWorkloadContext());
- }
-
- @Test
- public void projectMap(){
- Project project = new Project();
- project.setProjectName("abc");
-
- org.onap.aai.domain.yang.Project AAIProject = aaiObjectMapper.mapProject(project);
-
- assertEquals(AAIProject.getProjectName(),project.getProjectName());
- }
-
- @Test
- public void serviceSubscriptionMap(){
+ private AAIObjectMapper aaiObjectMapper = new AAIObjectMapper();
+ private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/";
+
+
+ @Test
+ public void mapConfigurationTest() {
+ Configuration configuration = new Configuration();
+ configuration.setConfigurationId("configId");
+ configuration.setConfigurationName("VNR");
+ configuration.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
+ configuration.setManagementOption("managementOption");
+ ModelInfoConfiguration modelInfoConfiguration = new ModelInfoConfiguration();
+ modelInfoConfiguration.setModelCustomizationId("modelCustId");
+ modelInfoConfiguration.setModelInvariantId("modelInvariantId");
+ modelInfoConfiguration.setModelVersionId("modelVersionId");
+ modelInfoConfiguration.setConfigurationType("5G");
+ modelInfoConfiguration.setConfigurationRole("ConfigurationRole");
+ configuration.setModelInfoConfiguration(modelInfoConfiguration);
+
+ org.onap.aai.domain.yang.Configuration expectedConfiguration = new org.onap.aai.domain.yang.Configuration();
+ expectedConfiguration.setConfigurationId(configuration.getConfigurationId());
+ expectedConfiguration.setConfigurationName(configuration.getConfigurationName());
+ expectedConfiguration.setConfigurationType(configuration.getModelInfoConfiguration().getConfigurationType());
+ expectedConfiguration.setOrchestrationStatus(configuration.getOrchestrationStatus().toString());
+ expectedConfiguration.setManagementOption(configuration.getManagementOption());
+ expectedConfiguration.setModelInvariantId(configuration.getModelInfoConfiguration().getModelInvariantId());
+ expectedConfiguration.setModelVersionId(configuration.getModelInfoConfiguration().getModelVersionId());
+ expectedConfiguration
+ .setModelCustomizationId(configuration.getModelInfoConfiguration().getModelCustomizationId());
+ expectedConfiguration.setConfigurationSubType(configuration.getModelInfoConfiguration().getConfigurationRole());
+ expectedConfiguration.setConfigPolicyName(configuration.getModelInfoConfiguration().getPolicyName());
+
+ org.onap.aai.domain.yang.Configuration actualConfiguration = aaiObjectMapper.mapConfiguration(configuration);
+
+ assertThat(actualConfiguration, sameBeanAs(expectedConfiguration));
+ }
+
+ @Test
+ public void mapVolumeGroupTest() throws Exception {
+ VolumeGroup volumeGroup = new VolumeGroup();
+ volumeGroup.setHeatStackId("heatStackId");
+ volumeGroup.setModelInfoVfModule(new ModelInfoVfModule());
+ volumeGroup.getModelInfoVfModule().setModelCustomizationUUID("modelCustomizationId");
+ volumeGroup.setOrchestrationStatus(OrchestrationStatus.ACTIVE);
+ volumeGroup.setVnfType("vnfType");
+ volumeGroup.setVolumeGroupId("volumeGroupId");
+ volumeGroup.setVolumeGroupName("volumeGroupName");
+
+ org.onap.aai.domain.yang.VolumeGroup expectedVolumeGroup = new org.onap.aai.domain.yang.VolumeGroup();
+ expectedVolumeGroup.setHeatStackId(volumeGroup.getHeatStackId());
+ expectedVolumeGroup.setModelCustomizationId(volumeGroup.getModelInfoVfModule().getModelCustomizationUUID());
+ expectedVolumeGroup.setOrchestrationStatus(volumeGroup.getOrchestrationStatus().toString());
+ expectedVolumeGroup
+ .setVfModuleModelCustomizationId(volumeGroup.getModelInfoVfModule().getModelCustomizationUUID());
+ expectedVolumeGroup.setVnfType(volumeGroup.getVnfType());
+ expectedVolumeGroup.setVolumeGroupId(volumeGroup.getVolumeGroupId());
+ expectedVolumeGroup.setVolumeGroupName(volumeGroup.getVolumeGroupName());
+
+ org.onap.aai.domain.yang.VolumeGroup actualVolumeGroup = aaiObjectMapper.mapVolumeGroup(volumeGroup);
+
+ assertThat(actualVolumeGroup, sameBeanAs(expectedVolumeGroup));
+ }
+
+ @Test
+ public void serviceInstanceMap() {
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("SIID");
+ serviceInstance.setServiceInstanceName("SINAME");
+ serviceInstance.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setServiceType("SITYPE");
+ modelInfoServiceInstance.setServiceRole("SIROLE");
+ modelInfoServiceInstance.setModelInvariantUuid("MIUUID");
+ modelInfoServiceInstance.setModelUuid("MUUID");
+ modelInfoServiceInstance.setEnvironmentContext("EC");
+ modelInfoServiceInstance.setWorkloadContext("WC");
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+
+ org.onap.aai.domain.yang.ServiceInstance AAIServiceInstance =
+ aaiObjectMapper.mapServiceInstance(serviceInstance);
+
+ assertEquals(AAIServiceInstance.getServiceInstanceId(), serviceInstance.getServiceInstanceId());
+ assertEquals(AAIServiceInstance.getServiceInstanceName(), serviceInstance.getServiceInstanceName());
+ assertEquals(AAIServiceInstance.getOrchestrationStatus().toString(),
+ serviceInstance.getOrchestrationStatus().toString());
+ assertEquals(AAIServiceInstance.getServiceType(),
+ serviceInstance.getModelInfoServiceInstance().getServiceType());
+ assertEquals(AAIServiceInstance.getServiceRole(),
+ serviceInstance.getModelInfoServiceInstance().getServiceRole());
+ assertEquals(AAIServiceInstance.getModelInvariantId(),
+ serviceInstance.getModelInfoServiceInstance().getModelInvariantUuid());
+ assertEquals(AAIServiceInstance.getModelVersionId(),
+ serviceInstance.getModelInfoServiceInstance().getModelUuid());
+ assertEquals(AAIServiceInstance.getEnvironmentContext(),
+ serviceInstance.getModelInfoServiceInstance().getEnvironmentContext());
+ assertEquals(AAIServiceInstance.getWorkloadContext(),
+ serviceInstance.getModelInfoServiceInstance().getWorkloadContext());
+ }
+
+ @Test
+ public void projectMap() {
+ Project project = new Project();
+ project.setProjectName("abc");
+
+ org.onap.aai.domain.yang.Project AAIProject = aaiObjectMapper.mapProject(project);
+
+ assertEquals(AAIProject.getProjectName(), project.getProjectName());
+ }
+
+ @Test
+ public void serviceSubscriptionMap() {
ServiceSubscription serviceSubscription = new ServiceSubscription();
serviceSubscription.setServiceType("IP-FLEX");
serviceSubscription.setTempUbSubAccountId("Account-ID");
- org.onap.aai.domain.yang.ServiceSubscription serviceSubscriptionMapped = aaiObjectMapper.mapServiceSubscription(serviceSubscription);
+ org.onap.aai.domain.yang.ServiceSubscription serviceSubscriptionMapped =
+ aaiObjectMapper.mapServiceSubscription(serviceSubscription);
assertNotNull(serviceSubscriptionMapped);
- assertEquals(serviceSubscription.getTempUbSubAccountId(),serviceSubscriptionMapped.getTempUbSubAccountId());
- assertEquals(serviceSubscription.getServiceType(),serviceSubscriptionMapped.getServiceType());
+ assertEquals(serviceSubscription.getTempUbSubAccountId(), serviceSubscriptionMapped.getTempUbSubAccountId());
+ assertEquals(serviceSubscription.getServiceType(), serviceSubscriptionMapped.getServiceType());
+ }
+
+ @Test
+ public void owningEntityMap() {
+ OwningEntity oe = new OwningEntity();
+ oe.setOwningEntityId("abc");
+ oe.setOwningEntityName("bbb");
+
+ org.onap.aai.domain.yang.OwningEntity AAIOwningEntity = aaiObjectMapper.mapOwningEntity(oe);
+
+ assertEquals(AAIOwningEntity.getOwningEntityId(), oe.getOwningEntityId());
+ assertEquals(AAIOwningEntity.getOwningEntityName(), oe.getOwningEntityName());
+
+ }
+
+ @Test
+ public void vnfMap() {
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("a");
+ vnf.setVnfName("b");
+ vnf.setServiceId("c");
+ vnf.setVnfType("d");
+ vnf.setProvStatus("e");
+ vnf.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
+ ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setModelCustomizationUuid("f");
+ modelInfoGenericVnf.setModelInvariantUuid("g");
+ modelInfoGenericVnf.setModelUuid("h");
+ modelInfoGenericVnf.setNfRole("i");
+ modelInfoGenericVnf.setNfType("j");
+ modelInfoGenericVnf.setNfFunction("k");
+ modelInfoGenericVnf.setNfNamingCode("l");
+ vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
+
+ org.onap.aai.domain.yang.GenericVnf AAIVnf = aaiObjectMapper.mapVnf(vnf);
+
+ assertEquals(AAIVnf.getVnfId(), vnf.getVnfId());
+ assertEquals(AAIVnf.getVnfName(), vnf.getVnfName());
+ assertEquals(AAIVnf.getServiceId(), vnf.getServiceId());
+ assertEquals(AAIVnf.getVnfType(), vnf.getVnfType());
+ assertEquals(AAIVnf.getProvStatus(), vnf.getProvStatus());
+ assertEquals(AAIVnf.getOrchestrationStatus().toString(), vnf.getOrchestrationStatus().toString());
+ assertEquals(AAIVnf.getModelCustomizationId(), vnf.getModelInfoGenericVnf().getModelCustomizationUuid());
+ assertEquals(AAIVnf.getModelInvariantId(), vnf.getModelInfoGenericVnf().getModelInvariantUuid());
+ assertEquals(AAIVnf.getModelVersionId(), vnf.getModelInfoGenericVnf().getModelUuid());
+ assertEquals(AAIVnf.getModelVersionId(), vnf.getModelInfoGenericVnf().getModelUuid());
+ assertEquals(AAIVnf.getNfType(), vnf.getModelInfoGenericVnf().getNfType());
+ assertEquals(AAIVnf.getNfFunction(), vnf.getModelInfoGenericVnf().getNfFunction());
+ assertEquals(AAIVnf.getNfNamingCode(), vnf.getModelInfoGenericVnf().getNfNamingCode());
+ }
+
+ @Test
+ public void vfModuleMap() throws Exception {
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("a");
+ vfModule.setVfModuleName("b");
+ vfModule.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
+ ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
+ modelInfoVfModule.setModelCustomizationUUID("f");
+ modelInfoVfModule.setModelInvariantUUID("g");
+ modelInfoVfModule.setModelUUID("h");
+ modelInfoVfModule.setIsBaseBoolean(false);
+ vfModule.setModelInfoVfModule(modelInfoVfModule);
+
+ org.onap.aai.domain.yang.VfModule AAIVfModule = aaiObjectMapper.mapVfModule(vfModule);
+
+ String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiVfModuleMap.json")));
+
+ ObjectMapper omapper = new ObjectMapper();
+ org.onap.aai.domain.yang.VfModule reqMapper1 =
+ omapper.readValue(jsonToCompare, org.onap.aai.domain.yang.VfModule.class);
+
+ assertThat(reqMapper1, sameBeanAs(AAIVfModule));
+
+ }
+
+ @Test
+ public void vfModuleBaseMap() throws Exception {
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("a");
+ vfModule.setVfModuleName("b");
+ vfModule.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
+ ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
+ modelInfoVfModule.setModelCustomizationUUID("f");
+ modelInfoVfModule.setModelInvariantUUID("g");
+ modelInfoVfModule.setModelUUID("h");
+ modelInfoVfModule.setIsBaseBoolean(true);
+ vfModule.setModelInfoVfModule(modelInfoVfModule);
+
+ org.onap.aai.domain.yang.VfModule AAIVfModule = aaiObjectMapper.mapVfModule(vfModule);
+
+ String jsonToCompare =
+ new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiVfModuleBaseMap.json")));
+
+ ObjectMapper omapper = new ObjectMapper();
+ org.onap.aai.domain.yang.VfModule reqMapper1 =
+ omapper.readValue(jsonToCompare, org.onap.aai.domain.yang.VfModule.class);
+
+ assertThat(reqMapper1, sameBeanAs(AAIVfModule));
+
+ }
+
+ @Test
+ public void testMapInstanceGroup() {
+ InstanceGroup instanceGroup = new InstanceGroup();
+ instanceGroup.setId("test-id");
+ instanceGroup.setDescription("test-description");
+ instanceGroup.setInstanceGroupName("test-instanceGroupName");
+ instanceGroup.setResourceVersion("test-resourceVersion");
+
+ ModelInfoInstanceGroup model = new ModelInfoInstanceGroup();
+ model.setFunction("test-function");
+ model.setInstanceGroupRole("SUB-INTERFACE");
+ model.setType("VNFC");
+ model.setModelInvariantUUID("modelInvariantUUID-000");
+ model.setModelUUID("modelUUID-000");
+ model.setDescription("test-description");
+ model.setInstanceGroupRole("SUB-INTERFACE");
+
+ instanceGroup.setModelInfoInstanceGroup(model);
+
+
+ org.onap.aai.domain.yang.InstanceGroup aaiInstanceGroup = aaiObjectMapper.mapInstanceGroup(instanceGroup);
+
+ try {
+ com.fasterxml.jackson.databind.ObjectMapper mapper = new com.fasterxml.jackson.databind.ObjectMapper();
+ String json = mapper.writeValueAsString(aaiInstanceGroup);
+ System.out.println("GGG - json:\n" + json);
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ assertEquals(aaiInstanceGroup.getId(), instanceGroup.getId());
+ assertEquals(aaiInstanceGroup.getDescription(), instanceGroup.getDescription());
+ assertEquals(aaiInstanceGroup.getInstanceGroupRole(),
+ instanceGroup.getModelInfoInstanceGroup().getInstanceGroupRole());
+ assertEquals(aaiInstanceGroup.getModelInvariantId(),
+ instanceGroup.getModelInfoInstanceGroup().getModelInvariantUUID());
+ assertEquals(aaiInstanceGroup.getModelVersionId(), instanceGroup.getModelInfoInstanceGroup().getModelUUID());
+ assertEquals(aaiInstanceGroup.getResourceVersion(), instanceGroup.getResourceVersion());
+ assertEquals(aaiInstanceGroup.getInstanceGroupType(), instanceGroup.getModelInfoInstanceGroup().getType());
+ assertEquals(aaiInstanceGroup.getInstanceGroupRole(),
+ instanceGroup.getModelInfoInstanceGroup().getInstanceGroupRole());
+ }
+
+ @Test
+ public void mapCustomerTest() {
+ Customer customer = new Customer();
+ customer.setGlobalCustomerId("globalCustomerId");
+ customer.setSubscriberName("subscriberName");
+ customer.setSubscriberType("subscriberType");
+
+ org.onap.aai.domain.yang.Customer expectedCustomer = new org.onap.aai.domain.yang.Customer();
+ expectedCustomer.setGlobalCustomerId("globalCustomerId");
+ expectedCustomer.setSubscriberName("subscriberName");
+ expectedCustomer.setSubscriberType("subscriberType");
+
+ org.onap.aai.domain.yang.Customer actualCustomer = aaiObjectMapper.mapCustomer(customer);
+
+ assertThat(actualCustomer, sameBeanAs(expectedCustomer));
+ }
+
+ @Test
+ public void networkMap() throws Exception {
+ L3Network l3Network = new L3Network();
+ l3Network.setNetworkId("networkId");
+ l3Network.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
+ l3Network.setNetworkName("networkName");
+ l3Network.setNetworkRole("networkRole");
+ l3Network.setNetworkTechnology("networkTechnology");
+ l3Network.setNeutronNetworkId("neutronNetworkId");
+ l3Network.setNetworkRoleInstance(0L);
+ l3Network.setContrailNetworkFqdn("contrailNetworkFqdn");
+ l3Network.setIsBoundToVpn(false);
+ l3Network.setIsCascaded(false);
+ l3Network.setIsSharedNetwork(false);
+ l3Network.setHeatStackId("heatStackId");
+ l3Network.setOperationalStatus("operationalStatus");
+ l3Network.setPhysicalNetworkName("physicalNetworkName");
+ l3Network.setIsProviderNetwork(false);
+ l3Network.setSelflink("selflink");
+ l3Network.setServiceId("serviceId");
+
+ ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
+ modelInfoNetwork.setModelCustomizationUUID("modelCustomizationUUID");
+ modelInfoNetwork.setModelInvariantUUID("modelInvariantUUID");
+ modelInfoNetwork.setModelUUID("modelUUID");
+
+ l3Network.setModelInfoNetwork(modelInfoNetwork);
+
+ org.onap.aai.domain.yang.L3Network aaiL3Network = aaiObjectMapper.mapNetwork(l3Network);
+
+ ObjectMapper omapper = new ObjectMapper();
+ org.onap.aai.domain.yang.L3Network network =
+ omapper.readValue(getJson("aaiL3NetworkMapped.json"), org.onap.aai.domain.yang.L3Network.class);
+
+ com.shazam.shazamcrest.MatcherAssert.assertThat(aaiL3Network, sameBeanAs(network));
+
+ }
+
+ @Test
+ public void mapCollectionTest() {
+ Collection networkCollection = new Collection();
+ networkCollection.setId("networkCollectionId");
+ ModelInfoCollection modelInfoCollection = new ModelInfoCollection();
+ modelInfoCollection.setCollectionFunction("networkCollectionFunction");
+ modelInfoCollection.setCollectionRole("networkCollectionRole");
+ modelInfoCollection.setCollectionType("networkCollectionType");
+ modelInfoCollection.setModelCustomizationUUID("modelCustomizationUUID");
+ modelInfoCollection.setModelVersionId("modelVersionId");
+ modelInfoCollection.setModelInvariantUUID("modelInvariantUUID");
+ networkCollection.setModelInfoCollection(modelInfoCollection);
+ networkCollection.setName("networkCollectionName");
+
+ org.onap.aai.domain.yang.Collection expectedCollection = new org.onap.aai.domain.yang.Collection();
+ expectedCollection.setCollectionId("networkCollectionId");
+ expectedCollection.setCollectionType("networkCollectionType");
+ expectedCollection.setCollectionCustomizationId("modelCustomizationUUID");
+ expectedCollection.setModelVersionId("modelVersionId");
+ expectedCollection.setModelInvariantId("modelInvariantUUID");
+ expectedCollection.setCollectionFunction("networkCollectionFunction");
+ expectedCollection.setCollectionRole("networkCollectionRole");
+ expectedCollection.setCollectionName("networkCollectionName");
+
+ org.onap.aai.domain.yang.Collection actualCollection = aaiObjectMapper.mapCollection(networkCollection);
+
+ assertThat(actualCollection, sameBeanAs(expectedCollection));
+ }
+
+ /*
+ * Helper method to load JSON data
+ */
+ private String getJson(String filename) throws IOException {
+ return new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + filename)));
+ }
+
+ @Test
+ public void mapNetworkTest() throws Exception {
+ L3Network l3Network = new L3Network();
+ ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
+ modelInfoNetwork.setModelCustomizationUUID("modelCustomization_id");
+ modelInfoNetwork.setModelInvariantUUID("modelInvariant_id");
+ modelInfoNetwork.setModelUUID("modelCustomization_id");
+ modelInfoNetwork.setNetworkType("CONTRAIL_EXTERNAL");
+ modelInfoNetwork.setNetworkRole("dmz_direct");
+ modelInfoNetwork.setNetworkTechnology("contrail");
+ l3Network.setModelInfoNetwork(modelInfoNetwork);
+ l3Network.setNetworkId("TESTING_ID");
+ l3Network.setNetworkName("TESTING_NAME");
+ l3Network.setIsBoundToVpn(true);
+ l3Network.setServiceId("a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb");
+ l3Network.setNetworkRoleInstance(1L);
+ l3Network.setOrchestrationStatus(OrchestrationStatus.CREATED);
+ l3Network.setHeatStackId("heatStack_id");
+ l3Network.setContrailNetworkFqdn("contrailNetwork_fqdn");
+ l3Network.setWidgetModelId("widgetModel_id");
+ l3Network.setWidgetModelVersion("widgetModel_version");
+ l3Network.setPhysicalNetworkName("physicalNetwork_name");
+ l3Network.setIsProviderNetwork(true);
+ l3Network.setIsSharedNetwork(false);
+ l3Network.setIsExternalNetwork(true);
+ l3Network.setSelflink("self_link");
+ l3Network.setOperationalStatus("operationalStatus");
+
+ List<Subnet> subnets = new ArrayList<Subnet>();
+ Subnet subnet1 = new Subnet();
+ subnet1.setSubnetId("57e9a1ff-d14f-4071-a828-b19ae98eb2fc");
+ subnet1.setSubnetName("subnetName");
+ subnet1.setGatewayAddress("192.168.52.1");
+ subnet1.setNetworkStartAddress("192.168.52.0");
+ subnet1.setCidrMask("24");
+ subnet1.setIpVersion("4");
+ subnet1.setOrchestrationStatus(OrchestrationStatus.CREATED);
+ subnet1.setIpAssignmentDirection("true");
+ subnet1.setDhcpEnabled(true);
+ subnet1.setDhcpStart("dhcpStart");
+ subnet1.setDhcpEnd("dhcpEnd");
+ subnet1.setSubnetRole("subnetRole");
+ subnet1.setIpAssignmentDirection("true");
+ subnet1.setSubnetSequence(new Integer(3));
+
+ List<HostRoute> hostRoutes = new ArrayList<HostRoute>();
+ HostRoute hostRoute1 = new HostRoute();
+ hostRoute1.setHostRouteId("string");
+ hostRoute1.setRoutePrefix("192.10.16.0/24");
+ hostRoute1.setNextHop("192.10.16.100/24");
+ hostRoute1.setNextHopType("ip-address");
+ HostRoute hostRoute2 = new HostRoute();
+ hostRoute2.setHostRouteId("string");
+ hostRoute2.setRoutePrefix("192.110.17.0/24");
+ hostRoute2.setNextHop("192.110.17.110/24");
+ hostRoute2.setNextHopType("ip-address");
+ hostRoutes.add(hostRoute1);
+ hostRoutes.add(hostRoute2);
+ subnet1.getHostRoutes().addAll(hostRoutes);
+
+ subnets.add(subnet1);
+ subnets.add(subnet1);
+ l3Network.getSubnets().addAll(subnets);
+
+ List<CtagAssignment> ctagAssignments = new ArrayList<CtagAssignment>();
+ CtagAssignment ctagAssignment1 = new CtagAssignment();
+ ctagAssignment1.setVlanIdInner(1L);
+ ctagAssignments.add(ctagAssignment1);
+ l3Network.getCtagAssignments().addAll(ctagAssignments);
+
+ List<SegmentationAssignment> segmentationAssignments = new ArrayList<SegmentationAssignment>();
+ SegmentationAssignment segmentationAssignment1 = new SegmentationAssignment();
+ segmentationAssignment1.setSegmentationId("segmentationId1");
+ SegmentationAssignment segmentationAssignment2 = new SegmentationAssignment();
+ segmentationAssignment2.setSegmentationId("segmentationId2");
+ segmentationAssignments.add(segmentationAssignment1);
+ segmentationAssignments.add(segmentationAssignment2);
+ l3Network.getSegmentationAssignments().addAll(segmentationAssignments);
+
+ AAIObjectMapper l3NetworkMapper = new AAIObjectMapper();
+ org.onap.aai.domain.yang.L3Network v12L3Network = l3NetworkMapper.mapNetwork(l3Network);
+
+ String jsonToCompare =
+ new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiL3NetworkMapped_to_aai.json")));
+ ObjectMapper omapper = new ObjectMapper();
+ org.onap.aai.domain.yang.L3Network network =
+ omapper.readValue(jsonToCompare, org.onap.aai.domain.yang.L3Network.class);
+
+ ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
+ String jsonGenerated = ow.writeValueAsString(v12L3Network);
+ String jsonExpected = ow.writeValueAsString(network);
+ assertEquals(jsonExpected, jsonGenerated);
+
+ }
+
+ @Test
+ public void mapToAAISubNetsTest() throws Exception {
+ List<Subnet> subnets = new ArrayList<Subnet>();
+ Subnet subnet1 = new Subnet();
+ subnet1.setSubnetId("57e9a1ff-d14f-4071-a828-b19ae98eb2fc");
+ subnet1.setSubnetName("subnetName");
+ subnet1.setGatewayAddress("192.168.52.1");
+ subnet1.setNetworkStartAddress("192.168.52.0");
+ subnet1.setCidrMask("24");
+ subnet1.setIpVersion("4");
+ subnet1.setOrchestrationStatus(OrchestrationStatus.CREATED);
+ subnet1.setIpAssignmentDirection("true");
+ subnet1.setDhcpEnabled(true);
+ subnet1.setDhcpStart("dhcpStart");
+ subnet1.setDhcpEnd("dhcpEnd");
+ subnet1.setSubnetRole("subnetRole");
+ subnet1.setIpAssignmentDirection("true");
+ subnet1.setSubnetSequence(new Integer(3));
+
+ List<HostRoute> hostRoutes = new ArrayList<HostRoute>();
+ HostRoute hostRoute1 = new HostRoute();
+ hostRoute1.setHostRouteId("string");
+ hostRoute1.setRoutePrefix("192.10.16.0/24");
+ hostRoute1.setNextHop("192.10.16.100/24");
+ hostRoute1.setNextHopType("ip-address");
+ HostRoute hostRoute2 = new HostRoute();
+ hostRoute2.setHostRouteId("string");
+ hostRoute2.setRoutePrefix("192.110.17.0/24");
+ hostRoute2.setNextHop("192.110.17.110/24");
+ hostRoute2.setNextHopType("ip-address");
+ hostRoutes.add(hostRoute1);
+ hostRoutes.add(hostRoute2);
+ subnet1.getHostRoutes().addAll(hostRoutes);
+
+ subnets.add(subnet1);
+ subnets.add(subnet1);
+
+ AAIObjectMapper aaiObjectMapper = new AAIObjectMapper();
+ org.onap.aai.domain.yang.Subnets v12Subnets = aaiObjectMapper.mapToAAISubNets(subnets);
+
+ assertEquals(subnets.get(0).getDhcpEnd(), v12Subnets.getSubnet().get(0).getDhcpEnd());
+ assertEquals(subnets.get(0).getCidrMask(), v12Subnets.getSubnet().get(0).getCidrMask());
+
+ String jsonToCompare =
+ new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiSubnetsMapped_to_aai.json")));
+ ObjectMapper omapper = new ObjectMapper();
+ org.onap.aai.domain.yang.Subnets subnet =
+ omapper.readValue(jsonToCompare, org.onap.aai.domain.yang.Subnets.class);
+ ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
+ String jsonGenerated = ow.writeValueAsString(v12Subnets);
+ String jsonExpected = ow.writeValueAsString(subnet);
+ assertEquals(jsonExpected, jsonGenerated);
}
- @Test
- public void owningEntityMap(){
- OwningEntity oe = new OwningEntity();
- oe.setOwningEntityId("abc");
- oe.setOwningEntityName("bbb");
-
- org.onap.aai.domain.yang.OwningEntity AAIOwningEntity = aaiObjectMapper.mapOwningEntity(oe);
-
- assertEquals(AAIOwningEntity.getOwningEntityId(),oe.getOwningEntityId());
- assertEquals(AAIOwningEntity.getOwningEntityName(),oe.getOwningEntityName());
-
- }
-
- @Test
- public void vnfMap(){
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("a");
- vnf.setVnfName("b");
- vnf.setServiceId("c");
- vnf.setVnfType("d");
- vnf.setProvStatus("e");
- vnf.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
- ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
- modelInfoGenericVnf.setModelCustomizationUuid("f");
- modelInfoGenericVnf.setModelInvariantUuid("g");
- modelInfoGenericVnf.setModelUuid("h");
- modelInfoGenericVnf.setNfRole("i");
- modelInfoGenericVnf.setNfType("j");
- modelInfoGenericVnf.setNfFunction("k");
- modelInfoGenericVnf.setNfNamingCode("l");
- vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
-
- org.onap.aai.domain.yang.GenericVnf AAIVnf = aaiObjectMapper.mapVnf(vnf);
-
- assertEquals(AAIVnf.getVnfId(),vnf.getVnfId());
- assertEquals(AAIVnf.getVnfName(),vnf.getVnfName());
- assertEquals(AAIVnf.getServiceId(),vnf.getServiceId());
- assertEquals(AAIVnf.getVnfType(),vnf.getVnfType());
- assertEquals(AAIVnf.getProvStatus(),vnf.getProvStatus());
- assertEquals(AAIVnf.getOrchestrationStatus().toString(),vnf.getOrchestrationStatus().toString());
- assertEquals(AAIVnf.getModelCustomizationId(),vnf.getModelInfoGenericVnf().getModelCustomizationUuid());
- assertEquals(AAIVnf.getModelInvariantId(),vnf.getModelInfoGenericVnf().getModelInvariantUuid());
- assertEquals(AAIVnf.getModelVersionId(),vnf.getModelInfoGenericVnf().getModelUuid());
- assertEquals(AAIVnf.getModelVersionId(),vnf.getModelInfoGenericVnf().getModelUuid());
- assertEquals(AAIVnf.getNfType(),vnf.getModelInfoGenericVnf().getNfType());
- assertEquals(AAIVnf.getNfFunction(),vnf.getModelInfoGenericVnf().getNfFunction());
- assertEquals(AAIVnf.getNfNamingCode(),vnf.getModelInfoGenericVnf().getNfNamingCode());
- }
-
- @Test
- public void vfModuleMap() throws Exception {
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("a");
- vfModule.setVfModuleName("b");
- vfModule.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
- ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
- modelInfoVfModule.setModelCustomizationUUID("f");
- modelInfoVfModule.setModelInvariantUUID("g");
- modelInfoVfModule.setModelUUID("h");
- modelInfoVfModule.setIsBaseBoolean(false);
- vfModule.setModelInfoVfModule(modelInfoVfModule);
-
- org.onap.aai.domain.yang.VfModule AAIVfModule = aaiObjectMapper.mapVfModule(vfModule);
-
- String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiVfModuleMap.json")));
-
- ObjectMapper omapper = new ObjectMapper();
- org.onap.aai.domain.yang.VfModule reqMapper1 = omapper.readValue(
- jsonToCompare,
- org.onap.aai.domain.yang.VfModule.class);
-
- assertThat(reqMapper1, sameBeanAs(AAIVfModule));
-
- }
-
- @Test
- public void vfModuleBaseMap() throws Exception {
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("a");
- vfModule.setVfModuleName("b");
- vfModule.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
- ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
- modelInfoVfModule.setModelCustomizationUUID("f");
- modelInfoVfModule.setModelInvariantUUID("g");
- modelInfoVfModule.setModelUUID("h");
- modelInfoVfModule.setIsBaseBoolean(true);
- vfModule.setModelInfoVfModule(modelInfoVfModule);
-
- org.onap.aai.domain.yang.VfModule AAIVfModule = aaiObjectMapper.mapVfModule(vfModule);
-
- String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiVfModuleBaseMap.json")));
-
- ObjectMapper omapper = new ObjectMapper();
- org.onap.aai.domain.yang.VfModule reqMapper1 = omapper.readValue(
- jsonToCompare,
- org.onap.aai.domain.yang.VfModule.class);
-
- assertThat(reqMapper1, sameBeanAs(AAIVfModule));
-
- }
-
- @Test
- public void testMapInstanceGroup() {
- InstanceGroup instanceGroup = new InstanceGroup();
- instanceGroup.setId("test-id");
- instanceGroup.setDescription("test-description");
- instanceGroup.setInstanceGroupName("test-instanceGroupName");
- instanceGroup.setResourceVersion("test-resourceVersion");
-
- ModelInfoInstanceGroup model = new ModelInfoInstanceGroup();
- model.setFunction("test-function");
- model.setInstanceGroupRole("SUB-INTERFACE");
- model.setType("VNFC");
- model.setModelInvariantUUID("modelInvariantUUID-000");
- model.setModelUUID("modelUUID-000");
- model.setDescription("test-description");
- model.setInstanceGroupRole("SUB-INTERFACE");
-
- instanceGroup.setModelInfoInstanceGroup(model);
-
-
- org.onap.aai.domain.yang.InstanceGroup aaiInstanceGroup = aaiObjectMapper.mapInstanceGroup(instanceGroup);
-
- try {
- com.fasterxml.jackson.databind.ObjectMapper mapper = new com.fasterxml.jackson.databind.ObjectMapper();
- String json = mapper.writeValueAsString(aaiInstanceGroup);
- System.out.println("GGG - json:\n" + json);
-
- }
- catch(Exception e) {
- e.printStackTrace();
- }
-
- assertEquals(aaiInstanceGroup.getId(), instanceGroup.getId());
- assertEquals(aaiInstanceGroup.getDescription(), instanceGroup.getDescription());
- assertEquals(aaiInstanceGroup.getInstanceGroupRole(), instanceGroup.getModelInfoInstanceGroup().getInstanceGroupRole());
- assertEquals(aaiInstanceGroup.getModelInvariantId(), instanceGroup.getModelInfoInstanceGroup().getModelInvariantUUID());
- assertEquals(aaiInstanceGroup.getModelVersionId(), instanceGroup.getModelInfoInstanceGroup().getModelUUID());
- assertEquals(aaiInstanceGroup.getResourceVersion(), instanceGroup.getResourceVersion());
- assertEquals(aaiInstanceGroup.getInstanceGroupType(), instanceGroup.getModelInfoInstanceGroup().getType());
- assertEquals(aaiInstanceGroup.getInstanceGroupRole(), instanceGroup.getModelInfoInstanceGroup().getInstanceGroupRole());
- }
-
- @Test
- public void mapCustomerTest() {
- Customer customer = new Customer();
- customer.setGlobalCustomerId("globalCustomerId");
- customer.setSubscriberName("subscriberName");
- customer.setSubscriberType("subscriberType");
-
- org.onap.aai.domain.yang.Customer expectedCustomer = new org.onap.aai.domain.yang.Customer();
- expectedCustomer.setGlobalCustomerId("globalCustomerId");
- expectedCustomer.setSubscriberName("subscriberName");
- expectedCustomer.setSubscriberType("subscriberType");
-
- org.onap.aai.domain.yang.Customer actualCustomer = aaiObjectMapper.mapCustomer(customer);
-
- assertThat(actualCustomer, sameBeanAs(expectedCustomer));
- }
-
- @Test
- public void networkMap() throws Exception {
- L3Network l3Network = new L3Network();
- l3Network.setNetworkId("networkId");
- l3Network.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
- l3Network.setNetworkName("networkName");
- l3Network.setNetworkRole("networkRole");
- l3Network.setNetworkTechnology("networkTechnology");
- l3Network.setNeutronNetworkId("neutronNetworkId");
- l3Network.setNetworkRoleInstance(0L);
- l3Network.setContrailNetworkFqdn("contrailNetworkFqdn");
- l3Network.setIsBoundToVpn(false);
- l3Network.setIsCascaded(false);
- l3Network.setIsSharedNetwork(false);
- l3Network.setHeatStackId("heatStackId");
- l3Network.setOperationalStatus("operationalStatus");
- l3Network.setPhysicalNetworkName("physicalNetworkName");
- l3Network.setIsProviderNetwork(false);
- l3Network.setSelflink("selflink");
- l3Network.setServiceId("serviceId");
-
- ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
- modelInfoNetwork.setModelCustomizationUUID("modelCustomizationUUID");
- modelInfoNetwork.setModelInvariantUUID("modelInvariantUUID");
- modelInfoNetwork.setModelUUID("modelUUID");
-
- l3Network.setModelInfoNetwork(modelInfoNetwork);
-
- org.onap.aai.domain.yang.L3Network aaiL3Network = aaiObjectMapper.mapNetwork(l3Network);
-
- ObjectMapper omapper = new ObjectMapper();
- org.onap.aai.domain.yang.L3Network network = omapper.readValue(
- getJson("aaiL3NetworkMapped.json"),
- org.onap.aai.domain.yang.L3Network.class);
-
- com.shazam.shazamcrest.MatcherAssert.assertThat(aaiL3Network, sameBeanAs(network));
-
- }
-
- @Test
- public void mapCollectionTest() {
- Collection networkCollection = new Collection();
- networkCollection.setId("networkCollectionId");
- ModelInfoCollection modelInfoCollection = new ModelInfoCollection();
- modelInfoCollection.setCollectionFunction("networkCollectionFunction");
- modelInfoCollection.setCollectionRole("networkCollectionRole");
- modelInfoCollection.setCollectionType("networkCollectionType");
- modelInfoCollection.setModelCustomizationUUID("modelCustomizationUUID");
- modelInfoCollection.setModelVersionId("modelVersionId");
- modelInfoCollection.setModelInvariantUUID("modelInvariantUUID");
- networkCollection.setModelInfoCollection(modelInfoCollection);
- networkCollection.setName("networkCollectionName");
-
- org.onap.aai.domain.yang.Collection expectedCollection = new org.onap.aai.domain.yang.Collection();
- expectedCollection.setCollectionId("networkCollectionId");
- expectedCollection.setCollectionType("networkCollectionType");
- expectedCollection.setCollectionCustomizationId("modelCustomizationUUID");
- expectedCollection.setModelVersionId("modelVersionId");
- expectedCollection.setModelInvariantId("modelInvariantUUID");
- expectedCollection.setCollectionFunction("networkCollectionFunction");
- expectedCollection.setCollectionRole("networkCollectionRole");
- expectedCollection.setCollectionName("networkCollectionName");
-
- org.onap.aai.domain.yang.Collection actualCollection = aaiObjectMapper.mapCollection(networkCollection);
-
- assertThat(actualCollection, sameBeanAs(expectedCollection));
- }
-
- /*
- * Helper method to load JSON data
- */
- private String getJson(String filename) throws IOException {
- return new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + filename)));
- }
-
- @Test
- public void mapNetworkTest() throws Exception {
- L3Network l3Network = new L3Network();
- ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
- modelInfoNetwork.setModelCustomizationUUID("modelCustomization_id");
- modelInfoNetwork.setModelInvariantUUID("modelInvariant_id");
- modelInfoNetwork.setModelUUID("modelCustomization_id");
- modelInfoNetwork.setNetworkType("CONTRAIL_EXTERNAL");
- modelInfoNetwork.setNetworkRole("dmz_direct");
- modelInfoNetwork.setNetworkTechnology("contrail");
- l3Network.setModelInfoNetwork(modelInfoNetwork);
- l3Network.setNetworkId("TESTING_ID");
- l3Network.setNetworkName("TESTING_NAME");
- l3Network.setIsBoundToVpn(true);
- l3Network.setServiceId("a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb");
- l3Network.setNetworkRoleInstance(1L);
- l3Network.setOrchestrationStatus(OrchestrationStatus.CREATED);
- l3Network.setHeatStackId("heatStack_id");
- l3Network.setContrailNetworkFqdn("contrailNetwork_fqdn");
- l3Network.setWidgetModelId("widgetModel_id");
- l3Network.setWidgetModelVersion("widgetModel_version");
- l3Network.setPhysicalNetworkName("physicalNetwork_name");
- l3Network.setIsProviderNetwork(true);
- l3Network.setIsSharedNetwork(false);
- l3Network.setIsExternalNetwork(true);
- l3Network.setSelflink("self_link");
- l3Network.setOperationalStatus("operationalStatus");
-
- List<Subnet> subnets = new ArrayList<Subnet>();
- Subnet subnet1 = new Subnet();
- subnet1.setSubnetId("57e9a1ff-d14f-4071-a828-b19ae98eb2fc");
- subnet1.setSubnetName("subnetName");
- subnet1.setGatewayAddress("192.168.52.1");
- subnet1.setNetworkStartAddress("192.168.52.0");
- subnet1.setCidrMask("24");
- subnet1.setIpVersion("4");
- subnet1.setOrchestrationStatus(OrchestrationStatus.CREATED);
- subnet1.setIpAssignmentDirection("true");
- subnet1.setDhcpEnabled(true);
- subnet1.setDhcpStart("dhcpStart");
- subnet1.setDhcpEnd("dhcpEnd");
- subnet1.setSubnetRole("subnetRole");
- subnet1.setIpAssignmentDirection("true");
- subnet1.setSubnetSequence(new Integer(3));
-
- List<HostRoute> hostRoutes = new ArrayList<HostRoute>();
- HostRoute hostRoute1 = new HostRoute();
- hostRoute1.setHostRouteId("string");
- hostRoute1.setRoutePrefix("192.10.16.0/24");
- hostRoute1.setNextHop("192.10.16.100/24");
- hostRoute1.setNextHopType("ip-address");
- HostRoute hostRoute2 = new HostRoute();
- hostRoute2.setHostRouteId("string");
- hostRoute2.setRoutePrefix("192.110.17.0/24");
- hostRoute2.setNextHop("192.110.17.110/24");
- hostRoute2.setNextHopType("ip-address");
- hostRoutes.add(hostRoute1);
- hostRoutes.add(hostRoute2);
- subnet1.getHostRoutes().addAll(hostRoutes);
-
- subnets.add(subnet1);
- subnets.add(subnet1);
- l3Network.getSubnets().addAll(subnets);
-
- List<CtagAssignment> ctagAssignments = new ArrayList<CtagAssignment>();
- CtagAssignment ctagAssignment1 = new CtagAssignment();
- ctagAssignment1.setVlanIdInner(1L);
- ctagAssignments.add(ctagAssignment1);
- l3Network.getCtagAssignments().addAll(ctagAssignments);
-
- List<SegmentationAssignment> segmentationAssignments = new ArrayList<SegmentationAssignment>();
- SegmentationAssignment segmentationAssignment1 = new SegmentationAssignment();
- segmentationAssignment1.setSegmentationId("segmentationId1");
- SegmentationAssignment segmentationAssignment2 = new SegmentationAssignment();
- segmentationAssignment2.setSegmentationId("segmentationId2");
- segmentationAssignments.add(segmentationAssignment1);
- segmentationAssignments.add(segmentationAssignment2);
- l3Network.getSegmentationAssignments().addAll(segmentationAssignments);
-
- AAIObjectMapper l3NetworkMapper = new AAIObjectMapper();
- org.onap.aai.domain.yang.L3Network v12L3Network = l3NetworkMapper.mapNetwork(l3Network);
-
- String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiL3NetworkMapped_to_aai.json")));
- ObjectMapper omapper = new ObjectMapper();
- org.onap.aai.domain.yang.L3Network network = omapper.readValue(jsonToCompare,
- org.onap.aai.domain.yang.L3Network.class);
-
- ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
- String jsonGenerated = ow.writeValueAsString(v12L3Network);
- String jsonExpected = ow.writeValueAsString(network);
- assertEquals(jsonExpected, jsonGenerated);
-
- }
-
- @Test
- public void mapToAAISubNetsTest() throws Exception {
- List<Subnet> subnets = new ArrayList<Subnet>();
- Subnet subnet1 = new Subnet();
- subnet1.setSubnetId("57e9a1ff-d14f-4071-a828-b19ae98eb2fc");
- subnet1.setSubnetName("subnetName");
- subnet1.setGatewayAddress("192.168.52.1");
- subnet1.setNetworkStartAddress("192.168.52.0");
- subnet1.setCidrMask("24");
- subnet1.setIpVersion("4");
- subnet1.setOrchestrationStatus(OrchestrationStatus.CREATED);
- subnet1.setIpAssignmentDirection("true");
- subnet1.setDhcpEnabled(true);
- subnet1.setDhcpStart("dhcpStart");
- subnet1.setDhcpEnd("dhcpEnd");
- subnet1.setSubnetRole("subnetRole");
- subnet1.setIpAssignmentDirection("true");
- subnet1.setSubnetSequence(new Integer(3));
-
- List<HostRoute> hostRoutes = new ArrayList<HostRoute>();
- HostRoute hostRoute1 = new HostRoute();
- hostRoute1.setHostRouteId("string");
- hostRoute1.setRoutePrefix("192.10.16.0/24");
- hostRoute1.setNextHop("192.10.16.100/24");
- hostRoute1.setNextHopType("ip-address");
- HostRoute hostRoute2 = new HostRoute();
- hostRoute2.setHostRouteId("string");
- hostRoute2.setRoutePrefix("192.110.17.0/24");
- hostRoute2.setNextHop("192.110.17.110/24");
- hostRoute2.setNextHopType("ip-address");
- hostRoutes.add(hostRoute1);
- hostRoutes.add(hostRoute2);
- subnet1.getHostRoutes().addAll(hostRoutes);
-
- subnets.add(subnet1);
- subnets.add(subnet1);
-
- AAIObjectMapper aaiObjectMapper = new AAIObjectMapper();
- org.onap.aai.domain.yang.Subnets v12Subnets = aaiObjectMapper.mapToAAISubNets(subnets);
-
- assertEquals(subnets.get(0).getDhcpEnd(), v12Subnets.getSubnet().get(0).getDhcpEnd());
- assertEquals(subnets.get(0).getCidrMask(), v12Subnets.getSubnet().get(0).getCidrMask());
-
- String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiSubnetsMapped_to_aai.json")));
- ObjectMapper omapper = new ObjectMapper();
- org.onap.aai.domain.yang.Subnets subnet = omapper.readValue(jsonToCompare,
- org.onap.aai.domain.yang.Subnets.class);
- ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
- String jsonGenerated = ow.writeValueAsString(v12Subnets);
- String jsonExpected = ow.writeValueAsString(subnet);
- assertEquals(jsonExpected, jsonGenerated);
- }
-
- @Test
- public void mapToAAICtagAssignmentListTest() throws Exception {
- List<CtagAssignment> ctagAssignments = new ArrayList<CtagAssignment>();
- CtagAssignment ctagAssignment1 = new CtagAssignment();
- ctagAssignment1.setVlanIdInner(1L);
- ctagAssignments.add(ctagAssignment1);
-
- AAIObjectMapper aaiObjectMapper = new AAIObjectMapper();
- org.onap.aai.domain.yang.CtagAssignments v12CtagAssingments = aaiObjectMapper.mapToAAICtagAssignmentList(ctagAssignments);
-
- assertEquals(new Long(ctagAssignments.get(0).getVlanIdInner().longValue()), new Long(v12CtagAssingments.getCtagAssignment().get(0).getVlanIdInner()));
-
- String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiCtagAssingmentsMapped_to_aai.json")));
- ObjectMapper omapper = new ObjectMapper();
- org.onap.aai.domain.yang.CtagAssignments ctagAssignment = omapper.readValue(jsonToCompare,
- org.onap.aai.domain.yang.CtagAssignments.class);
- ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
- String jsonGenerated = ow.writeValueAsString(v12CtagAssingments);
- String jsonExpected = ow.writeValueAsString(ctagAssignment);
- assertEquals(jsonExpected, jsonGenerated);
- }
-
- @Test
- public void mapToAAISegmentationAssignmentListTest() throws Exception {
- List<SegmentationAssignment> segmentationAssignments = new ArrayList<SegmentationAssignment>();
- SegmentationAssignment segmentationAssignment1 = new SegmentationAssignment();
- segmentationAssignment1.setSegmentationId("segmentationId1");
- SegmentationAssignment segmentationAssignment2 = new SegmentationAssignment();
- segmentationAssignment2.setSegmentationId("segmentationId2");
- segmentationAssignments.add(segmentationAssignment1);
- segmentationAssignments.add(segmentationAssignment2);
-
- AAIObjectMapper aaiObjectMapper = new AAIObjectMapper();
- org.onap.aai.domain.yang.SegmentationAssignments v12SegmentationAssignments = aaiObjectMapper.mapToAAISegmentationAssignmentList(segmentationAssignments);
-
- assertEquals(segmentationAssignments.get(0).getSegmentationId(), v12SegmentationAssignments.getSegmentationAssignment().get(0).getSegmentationId());
- assertEquals(segmentationAssignments.get(1).getSegmentationId(), v12SegmentationAssignments.getSegmentationAssignment().get(1).getSegmentationId());
-
- String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiSegmentationAssignmentsMapped_to_aai.json")));
- ObjectMapper omapper = new ObjectMapper();
- org.onap.aai.domain.yang.SegmentationAssignments segmentationAssignment = omapper.readValue(jsonToCompare,
- org.onap.aai.domain.yang.SegmentationAssignments.class);
- ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
- String jsonGenerated = ow.writeValueAsString(v12SegmentationAssignments);
- String jsonExpected = ow.writeValueAsString(segmentationAssignment);
- assertEquals(jsonExpected, jsonGenerated);
-
- }
+ @Test
+ public void mapToAAICtagAssignmentListTest() throws Exception {
+ List<CtagAssignment> ctagAssignments = new ArrayList<CtagAssignment>();
+ CtagAssignment ctagAssignment1 = new CtagAssignment();
+ ctagAssignment1.setVlanIdInner(1L);
+ ctagAssignments.add(ctagAssignment1);
+
+ AAIObjectMapper aaiObjectMapper = new AAIObjectMapper();
+ org.onap.aai.domain.yang.CtagAssignments v12CtagAssingments =
+ aaiObjectMapper.mapToAAICtagAssignmentList(ctagAssignments);
+
+ assertEquals(new Long(ctagAssignments.get(0).getVlanIdInner().longValue()),
+ new Long(v12CtagAssingments.getCtagAssignment().get(0).getVlanIdInner()));
+
+ String jsonToCompare =
+ new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiCtagAssingmentsMapped_to_aai.json")));
+ ObjectMapper omapper = new ObjectMapper();
+ org.onap.aai.domain.yang.CtagAssignments ctagAssignment =
+ omapper.readValue(jsonToCompare, org.onap.aai.domain.yang.CtagAssignments.class);
+ ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
+ String jsonGenerated = ow.writeValueAsString(v12CtagAssingments);
+ String jsonExpected = ow.writeValueAsString(ctagAssignment);
+ assertEquals(jsonExpected, jsonGenerated);
+ }
+
+ @Test
+ public void mapToAAISegmentationAssignmentListTest() throws Exception {
+ List<SegmentationAssignment> segmentationAssignments = new ArrayList<SegmentationAssignment>();
+ SegmentationAssignment segmentationAssignment1 = new SegmentationAssignment();
+ segmentationAssignment1.setSegmentationId("segmentationId1");
+ SegmentationAssignment segmentationAssignment2 = new SegmentationAssignment();
+ segmentationAssignment2.setSegmentationId("segmentationId2");
+ segmentationAssignments.add(segmentationAssignment1);
+ segmentationAssignments.add(segmentationAssignment2);
+
+ AAIObjectMapper aaiObjectMapper = new AAIObjectMapper();
+ org.onap.aai.domain.yang.SegmentationAssignments v12SegmentationAssignments =
+ aaiObjectMapper.mapToAAISegmentationAssignmentList(segmentationAssignments);
+
+ assertEquals(segmentationAssignments.get(0).getSegmentationId(),
+ v12SegmentationAssignments.getSegmentationAssignment().get(0).getSegmentationId());
+ assertEquals(segmentationAssignments.get(1).getSegmentationId(),
+ v12SegmentationAssignments.getSegmentationAssignment().get(1).getSegmentationId());
+
+ String jsonToCompare = new String(
+ Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiSegmentationAssignmentsMapped_to_aai.json")));
+ ObjectMapper omapper = new ObjectMapper();
+ org.onap.aai.domain.yang.SegmentationAssignments segmentationAssignment =
+ omapper.readValue(jsonToCompare, org.onap.aai.domain.yang.SegmentationAssignments.class);
+ ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
+ String jsonGenerated = ow.writeValueAsString(v12SegmentationAssignments);
+ String jsonExpected = ow.writeValueAsString(segmentationAssignment);
+ assertEquals(jsonExpected, jsonGenerated);
+
+ }
@Test
public void mapVpnBindingTest() {
- VpnBinding vpnBinding = new VpnBinding();
- vpnBinding.setVpnId("testVpnId");
- vpnBinding.setVpnName("testVpn");
- vpnBinding.setVpnPlatform("AVPN");
- vpnBinding.setCustomerVpnId("testCustomerVpnId");
- vpnBinding.setVpnType("testVpnType");
- vpnBinding.setVpnRegion("testVpnRegion");
- vpnBinding.setRouteDistinguisher("testRD");
+ VpnBinding vpnBinding = new VpnBinding();
+ vpnBinding.setVpnId("testVpnId");
+ vpnBinding.setVpnName("testVpn");
+ vpnBinding.setVpnPlatform("AVPN");
+ vpnBinding.setCustomerVpnId("testCustomerVpnId");
+ vpnBinding.setVpnType("testVpnType");
+ vpnBinding.setVpnRegion("testVpnRegion");
+ vpnBinding.setRouteDistinguisher("testRD");
RouteTarget routeTarget = new RouteTarget();
routeTarget.setRouteTargetRole("testRtRole");
routeTarget.setGlobalRouteTarget("testGrt");
@@ -659,7 +676,7 @@ public class AAIObjectMapperTest {
assertThat(actualRouteTarget, sameBeanAs(expectedRouteTarget));
}
-
+
@Test
public void mapSubnetTest() {
Subnet subnet = new Subnet();
@@ -671,24 +688,24 @@ public class AAIObjectMapperTest {
expectedSubnet.setSubnetId("testSubnetId");
expectedSubnet.setOrchestrationStatus("Pending");
expectedSubnet.setNeutronSubnetId("testNeutronSubnetId");
-
+
org.onap.aai.domain.yang.Subnet actualSubnet = aaiObjectMapper.mapSubnet(subnet);
assertThat(actualSubnet, sameBeanAs(expectedSubnet));
}
-
+
@Test
public void mapNetworkPolicyTest() {
NetworkPolicy networkPolicy = new NetworkPolicy();
networkPolicy.setNetworkPolicyId("testNetworkPolicyId");
networkPolicy.setNetworkPolicyFqdn("testNetworkPolicyFqdn");
- networkPolicy.setHeatStackId("testHeatStackId");
+ networkPolicy.setHeatStackId("testHeatStackId");
org.onap.aai.domain.yang.NetworkPolicy expectedNetworkPolicy = new org.onap.aai.domain.yang.NetworkPolicy();
expectedNetworkPolicy.setNetworkPolicyId("testNetworkPolicyId");
expectedNetworkPolicy.setNetworkPolicyFqdn("testNetworkPolicyFqdn");
- expectedNetworkPolicy.setHeatStackId("testHeatStackId");
-
+ expectedNetworkPolicy.setHeatStackId("testHeatStackId");
+
org.onap.aai.domain.yang.NetworkPolicy actualNetworkPolicy = aaiObjectMapper.mapNetworkPolicy(networkPolicy);
assertThat(actualNetworkPolicy, sameBeanAs(expectedNetworkPolicy));
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/NetworkAdapterClientIT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/NetworkAdapterClientIT.java
index fe9e1c1608..251ab2cb74 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/NetworkAdapterClientIT.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/NetworkAdapterClientIT.java
@@ -29,9 +29,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.put;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-
import javax.ws.rs.core.Response;
-
import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.so.BaseIntegrationTest;
@@ -51,197 +49,196 @@ import org.onap.so.adapters.nwrest.UpdateNetworkRequest;
import org.onap.so.adapters.nwrest.UpdateNetworkResponse;
import org.onap.so.client.policy.JettisonStyleMapperProvider;
import org.onap.so.openstack.beans.NetworkRollback;
-
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
-public class NetworkAdapterClientIT extends BaseIntegrationTest{
-
- private static final String TESTING_ID = "___TESTING___";
- private static final String AAI_NETWORK_ID = "test";
- private static final String REST_ENDPOINT = "/networks/rest/v1/networks";
-
- private NetworkAdapterClientImpl client = new NetworkAdapterClientImpl();
- private ObjectMapper mapper = new JettisonStyleMapperProvider().getMapper();
-
- @BeforeClass
- public static void setUp() {
- System.setProperty("mso.config.path", "src/test/resources");
- }
-
- @Test
- public void createNetworkTest() throws NetworkAdapterClientException, JsonProcessingException {
- CreateNetworkRequest request = new CreateNetworkRequest();
- request.setCloudSiteId(TESTING_ID);
-
- CreateNetworkResponse mockResponse = new CreateNetworkResponse();
- mockResponse.setNetworkCreated(true);
- wireMockServer.stubFor(post(urlPathEqualTo(REST_ENDPOINT))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
-
- CreateNetworkResponse response = client.createNetwork(request);
- assertEquals("Testing CreateVfModule response", true, response.getNetworkCreated());
- }
-
- @Test(expected = NetworkAdapterClientException.class)
- public void createNetworkTestThrowException() throws NetworkAdapterClientException, JsonProcessingException {
- CreateNetworkRequest request = new CreateNetworkRequest();
- request.setCloudSiteId(TESTING_ID);
-
- CreateNetworkError mockResponse = new CreateNetworkError();
- mockResponse.setMessage("Error in create network");
- wireMockServer.stubFor(post(urlPathEqualTo(REST_ENDPOINT))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
-
- client.createNetwork(request);
- }
-
- @Test
- public void deleteNetworkTest() throws NetworkAdapterClientException, JsonProcessingException {
- DeleteNetworkRequest request = new DeleteNetworkRequest();
- request.setCloudSiteId(TESTING_ID);
-
- DeleteNetworkResponse mockResponse = new DeleteNetworkResponse();
- mockResponse.setNetworkDeleted(true);
-
- wireMockServer.stubFor(delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
-
- DeleteNetworkResponse response = client.deleteNetwork(AAI_NETWORK_ID, request);
- assertEquals("Testing DeleteVfModule response", true, response.getNetworkDeleted());
- }
-
- @Test(expected = NetworkAdapterClientException.class)
- public void deleteNetworkTestThrowException() throws NetworkAdapterClientException, JsonProcessingException {
- DeleteNetworkRequest request = new DeleteNetworkRequest();
- request.setCloudSiteId(TESTING_ID);
-
- DeleteNetworkError mockResponse = new DeleteNetworkError();
- mockResponse.setMessage("Error in delete network");
- wireMockServer.stubFor(delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
-
- client.deleteNetwork(AAI_NETWORK_ID, request);
- }
-
- @Test
- public void rollbackNetworkTest() throws NetworkAdapterClientException, JsonProcessingException {
- RollbackNetworkRequest request = new RollbackNetworkRequest();
- NetworkRollback rollback = new NetworkRollback();
- rollback.setCloudId(TESTING_ID);
- request.setNetworkRollback(rollback);
-
- RollbackNetworkResponse mockResponse = new RollbackNetworkResponse();
- mockResponse.setNetworkRolledBack(true);
-
- wireMockServer.stubFor(delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
-
- RollbackNetworkResponse response = client.rollbackNetwork(AAI_NETWORK_ID, request);
- assertEquals("Testing DeleteVfModule response", true, response.getNetworkRolledBack());
- }
-
- @Test(expected = NetworkAdapterClientException.class)
- public void rollbackNetworkTestThrowException() throws NetworkAdapterClientException, JsonProcessingException {
- RollbackNetworkRequest request = new RollbackNetworkRequest();
- NetworkRollback rollback = new NetworkRollback();
- rollback.setCloudId(TESTING_ID);
- request.setNetworkRollback(rollback);
-
- RollbackNetworkError mockResponse = new RollbackNetworkError();
- mockResponse.setMessage("Error in rollback network");
-
- wireMockServer.stubFor(delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
-
- client.rollbackNetwork(AAI_NETWORK_ID, request);
- }
-
- @Test
- public void queryNetworkTest() throws NetworkAdapterClientException, JsonProcessingException {
- QueryNetworkResponse mockResponse = new QueryNetworkResponse();
- mockResponse.setNetworkExists(true);
-
- wireMockServer.stubFor(get(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID)).withQueryParam("cloudSiteId", equalTo(TESTING_ID))
- .withQueryParam("tenantId", equalTo(TESTING_ID))
- .withQueryParam("networkStackId", equalTo("networkStackId")).withQueryParam("skipAAI", equalTo("true"))
- .withQueryParam("msoRequest.requestId", equalTo("testRequestId"))
- .withQueryParam("msoRequest.serviceInstanceId", equalTo("serviceInstanceId"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
-
- QueryNetworkResponse response = client.queryNetwork(AAI_NETWORK_ID, TESTING_ID, TESTING_ID, "networkStackId",
- true, "testRequestId", "serviceInstanceId");
- assertEquals("Testing QueryVfModule response", true, response.getNetworkExists());
- }
-
- @Test(expected = NetworkAdapterClientException.class)
- public void queryNetworkTestThrowException() throws NetworkAdapterClientException, JsonProcessingException {
- QueryNetworkError mockResponse = new QueryNetworkError();
- mockResponse.setMessage("Error in query network");
-
- wireMockServer.stubFor(get(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID)).withQueryParam("cloudSiteId", equalTo(TESTING_ID))
- .withQueryParam("tenantId", equalTo(TESTING_ID))
- .withQueryParam("networkStackId", equalTo("networkStackId")).withQueryParam("skipAAI", equalTo("true"))
- .withQueryParam("msoRequest.requestId", equalTo("testRequestId"))
- .withQueryParam("msoRequest.serviceInstanceId", equalTo("serviceInstanceId"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
-
- client.queryNetwork(AAI_NETWORK_ID, TESTING_ID, TESTING_ID, "networkStackId",
- true, "testRequestId", "serviceInstanceId");
- }
-
- @Test
- public void updateNetworkTest() throws NetworkAdapterClientException, JsonProcessingException {
- UpdateNetworkRequest request = new UpdateNetworkRequest();
- request.setCloudSiteId(TESTING_ID);
- request.setNetworkId("test1");
-
- UpdateNetworkResponse mockResponse = new UpdateNetworkResponse();
- mockResponse.setNetworkId("test1");
- wireMockServer.stubFor(put(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
-
- UpdateNetworkResponse response = client.updateNetwork(AAI_NETWORK_ID, request);
- assertEquals("Testing UpdateVfModule response", "test1", response.getNetworkId());
- }
-
- @Test
- public void updateNetworkTestAsync() throws NetworkAdapterClientException, JsonProcessingException {
- UpdateNetworkRequest request = new UpdateNetworkRequest();
- request.setCloudSiteId(TESTING_ID);
- request.setNetworkId("test1");
-
- UpdateNetworkResponse mockResponse = new UpdateNetworkResponse();
- mockResponse.setNetworkId("test1");
- wireMockServer.stubFor(put(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
-
- Response response = client.updateNetworkAsync(AAI_NETWORK_ID, request);
- assertNotNull(response.getEntity());
- }
-
- @Test(expected = NetworkAdapterClientException.class)
- public void updateNetworkTestThrowException() throws NetworkAdapterClientException, JsonProcessingException {
- UpdateNetworkRequest request = new UpdateNetworkRequest();
- request.setCloudSiteId(TESTING_ID);
- request.setNetworkId("test1");
-
- UpdateNetworkError mockResponse = new UpdateNetworkError();
- mockResponse.setMessage("Error in update network");
- wireMockServer.stubFor(put(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
-
- client.updateNetwork(AAI_NETWORK_ID, request);
- }
+public class NetworkAdapterClientIT extends BaseIntegrationTest {
+
+ private static final String TESTING_ID = "___TESTING___";
+ private static final String AAI_NETWORK_ID = "test";
+ private static final String REST_ENDPOINT = "/networks/rest/v1/networks";
+
+ private NetworkAdapterClientImpl client = new NetworkAdapterClientImpl();
+ private ObjectMapper mapper = new JettisonStyleMapperProvider().getMapper();
+
+ @BeforeClass
+ public static void setUp() {
+ System.setProperty("mso.config.path", "src/test/resources");
+ }
+
+ @Test
+ public void createNetworkTest() throws NetworkAdapterClientException, JsonProcessingException {
+ CreateNetworkRequest request = new CreateNetworkRequest();
+ request.setCloudSiteId(TESTING_ID);
+
+ CreateNetworkResponse mockResponse = new CreateNetworkResponse();
+ mockResponse.setNetworkCreated(true);
+ wireMockServer.stubFor(post(urlPathEqualTo(REST_ENDPOINT))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
+
+ CreateNetworkResponse response = client.createNetwork(request);
+ assertEquals("Testing CreateVfModule response", true, response.getNetworkCreated());
+ }
+
+ @Test(expected = NetworkAdapterClientException.class)
+ public void createNetworkTestThrowException() throws NetworkAdapterClientException, JsonProcessingException {
+ CreateNetworkRequest request = new CreateNetworkRequest();
+ request.setCloudSiteId(TESTING_ID);
+
+ CreateNetworkError mockResponse = new CreateNetworkError();
+ mockResponse.setMessage("Error in create network");
+ wireMockServer.stubFor(post(urlPathEqualTo(REST_ENDPOINT))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
+
+ client.createNetwork(request);
+ }
+
+ @Test
+ public void deleteNetworkTest() throws NetworkAdapterClientException, JsonProcessingException {
+ DeleteNetworkRequest request = new DeleteNetworkRequest();
+ request.setCloudSiteId(TESTING_ID);
+
+ DeleteNetworkResponse mockResponse = new DeleteNetworkResponse();
+ mockResponse.setNetworkDeleted(true);
+
+ wireMockServer.stubFor(delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
+
+ DeleteNetworkResponse response = client.deleteNetwork(AAI_NETWORK_ID, request);
+ assertEquals("Testing DeleteVfModule response", true, response.getNetworkDeleted());
+ }
+
+ @Test(expected = NetworkAdapterClientException.class)
+ public void deleteNetworkTestThrowException() throws NetworkAdapterClientException, JsonProcessingException {
+ DeleteNetworkRequest request = new DeleteNetworkRequest();
+ request.setCloudSiteId(TESTING_ID);
+
+ DeleteNetworkError mockResponse = new DeleteNetworkError();
+ mockResponse.setMessage("Error in delete network");
+ wireMockServer.stubFor(delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
+
+ client.deleteNetwork(AAI_NETWORK_ID, request);
+ }
+
+ @Test
+ public void rollbackNetworkTest() throws NetworkAdapterClientException, JsonProcessingException {
+ RollbackNetworkRequest request = new RollbackNetworkRequest();
+ NetworkRollback rollback = new NetworkRollback();
+ rollback.setCloudId(TESTING_ID);
+ request.setNetworkRollback(rollback);
+
+ RollbackNetworkResponse mockResponse = new RollbackNetworkResponse();
+ mockResponse.setNetworkRolledBack(true);
+
+ wireMockServer.stubFor(delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
+
+ RollbackNetworkResponse response = client.rollbackNetwork(AAI_NETWORK_ID, request);
+ assertEquals("Testing DeleteVfModule response", true, response.getNetworkRolledBack());
+ }
+
+ @Test(expected = NetworkAdapterClientException.class)
+ public void rollbackNetworkTestThrowException() throws NetworkAdapterClientException, JsonProcessingException {
+ RollbackNetworkRequest request = new RollbackNetworkRequest();
+ NetworkRollback rollback = new NetworkRollback();
+ rollback.setCloudId(TESTING_ID);
+ request.setNetworkRollback(rollback);
+
+ RollbackNetworkError mockResponse = new RollbackNetworkError();
+ mockResponse.setMessage("Error in rollback network");
+
+ wireMockServer.stubFor(delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
+
+ client.rollbackNetwork(AAI_NETWORK_ID, request);
+ }
+
+ @Test
+ public void queryNetworkTest() throws NetworkAdapterClientException, JsonProcessingException {
+ QueryNetworkResponse mockResponse = new QueryNetworkResponse();
+ mockResponse.setNetworkExists(true);
+
+ wireMockServer.stubFor(get(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
+ .withQueryParam("cloudSiteId", equalTo(TESTING_ID)).withQueryParam("tenantId", equalTo(TESTING_ID))
+ .withQueryParam("networkStackId", equalTo("networkStackId")).withQueryParam("skipAAI", equalTo("true"))
+ .withQueryParam("msoRequest.requestId", equalTo("testRequestId"))
+ .withQueryParam("msoRequest.serviceInstanceId", equalTo("serviceInstanceId"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
+
+ QueryNetworkResponse response = client.queryNetwork(AAI_NETWORK_ID, TESTING_ID, TESTING_ID, "networkStackId",
+ true, "testRequestId", "serviceInstanceId");
+ assertEquals("Testing QueryVfModule response", true, response.getNetworkExists());
+ }
+
+ @Test(expected = NetworkAdapterClientException.class)
+ public void queryNetworkTestThrowException() throws NetworkAdapterClientException, JsonProcessingException {
+ QueryNetworkError mockResponse = new QueryNetworkError();
+ mockResponse.setMessage("Error in query network");
+
+ wireMockServer.stubFor(get(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
+ .withQueryParam("cloudSiteId", equalTo(TESTING_ID)).withQueryParam("tenantId", equalTo(TESTING_ID))
+ .withQueryParam("networkStackId", equalTo("networkStackId")).withQueryParam("skipAAI", equalTo("true"))
+ .withQueryParam("msoRequest.requestId", equalTo("testRequestId"))
+ .withQueryParam("msoRequest.serviceInstanceId", equalTo("serviceInstanceId"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
+
+ client.queryNetwork(AAI_NETWORK_ID, TESTING_ID, TESTING_ID, "networkStackId", true, "testRequestId",
+ "serviceInstanceId");
+ }
+
+ @Test
+ public void updateNetworkTest() throws NetworkAdapterClientException, JsonProcessingException {
+ UpdateNetworkRequest request = new UpdateNetworkRequest();
+ request.setCloudSiteId(TESTING_ID);
+ request.setNetworkId("test1");
+
+ UpdateNetworkResponse mockResponse = new UpdateNetworkResponse();
+ mockResponse.setNetworkId("test1");
+ wireMockServer.stubFor(put(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
+
+ UpdateNetworkResponse response = client.updateNetwork(AAI_NETWORK_ID, request);
+ assertEquals("Testing UpdateVfModule response", "test1", response.getNetworkId());
+ }
+
+ @Test
+ public void updateNetworkTestAsync() throws NetworkAdapterClientException, JsonProcessingException {
+ UpdateNetworkRequest request = new UpdateNetworkRequest();
+ request.setCloudSiteId(TESTING_ID);
+ request.setNetworkId("test1");
+
+ UpdateNetworkResponse mockResponse = new UpdateNetworkResponse();
+ mockResponse.setNetworkId("test1");
+ wireMockServer.stubFor(put(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
+
+ Response response = client.updateNetworkAsync(AAI_NETWORK_ID, request);
+ assertNotNull(response.getEntity());
+ }
+
+ @Test(expected = NetworkAdapterClientException.class)
+ public void updateNetworkTestThrowException() throws NetworkAdapterClientException, JsonProcessingException {
+ UpdateNetworkRequest request = new UpdateNetworkRequest();
+ request.setCloudSiteId(TESTING_ID);
+ request.setNetworkId("test1");
+
+ UpdateNetworkError mockResponse = new UpdateNetworkError();
+ mockResponse.setMessage("Error in update network");
+ wireMockServer.stubFor(put(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
+
+ client.updateNetwork(AAI_NETWORK_ID, request);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java
index 4bdbd1a846..ccd677c80e 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java
@@ -24,7 +24,6 @@ import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.*;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doReturn;
-
import java.io.UnsupportedEncodingException;
import java.nio.file.Files;
import java.nio.file.Paths;
@@ -33,7 +32,6 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
@@ -62,314 +60,329 @@ import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork;
import org.onap.so.entity.MsoRequest;
import org.onap.so.openstack.beans.NetworkRollback;
-
import com.fasterxml.jackson.databind.ObjectMapper;
-public class NetworkAdapterObjectMapperTest extends TestDataSetup{
-
- private NetworkAdapterObjectMapper SPY_networkAdapterObjectMapper = Mockito.spy(NetworkAdapterObjectMapper.class);
-
- private L3Network l3Network;
- private RequestContext requestContext;
- private ServiceInstance serviceInstance;
- private CloudRegion cloudRegion;
- private OrchestrationContext orchestrationContext;
- private Customer customer;
- Map<String, String> userInput;
-
- private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/NetworkMapper/";
-
- @Before
- public void before() {
- requestContext = setRequestContext();
-
- customer = buildCustomer();
-
- serviceInstance = setServiceInstance();
-
- cloudRegion = setCloudRegion();
-
- orchestrationContext = setOrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(false);
-
- userInput = setUserInput();
-
- l3Network = setL3Network();
-
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
- }
-
- @Test
- public void buildCreateNetworkRequestFromBbobjectTest() throws Exception {
-
- String cloudRegionPo = "cloudRegionPo";
- CreateNetworkRequest expectedCreateNetworkRequest = new CreateNetworkRequest();
-
- expectedCreateNetworkRequest.setCloudSiteId(cloudRegionPo);
- expectedCreateNetworkRequest.setTenantId(cloudRegion.getTenantId());
- expectedCreateNetworkRequest.setNetworkId(l3Network.getNetworkId());
- expectedCreateNetworkRequest.setNetworkName(l3Network.getNetworkName());
- expectedCreateNetworkRequest.setNetworkType(l3Network.getNetworkType());
- expectedCreateNetworkRequest.setBackout(false);
- expectedCreateNetworkRequest.setFailIfExists(true);
- expectedCreateNetworkRequest.setNetworkTechnology("CONTRAIL");
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId(requestContext.getMsoRequestId());
- msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
- expectedCreateNetworkRequest.setMsoRequest(msoRequest);
- expectedCreateNetworkRequest.setSkipAAI(true);
- HashMap<String, String> networkParams = new HashMap<String, String>();
- networkParams.put("shared", "true");
- networkParams.put("external", "false");
- networkParams.put("testUserInputKey", "testUserInputValue");
- expectedCreateNetworkRequest.setNetworkParams(networkParams);
-
- expectedCreateNetworkRequest.setNotificationUrl("endpoint/NetworkAResponse/messageId");
-
- Subnet openstackSubnet = new Subnet();
- HostRoute hostRoute = new HostRoute();
- hostRoute.setHostRouteId("hostRouteId");
- hostRoute.setNextHop("nextHop");
- hostRoute.setRoutePrefix("routePrefix");
- openstackSubnet.getHostRoutes().add(hostRoute);
- List<Subnet> subnetList = new ArrayList<Subnet>();
- subnetList.add(openstackSubnet);
- l3Network.getSubnets().add(openstackSubnet);
- l3Network.setNetworkTechnology("Contrail");
- l3Network.setIsSharedNetwork(true);
- l3Network.setIsExternalNetwork(false);
-
- doReturn("endpoint/").when(SPY_networkAdapterObjectMapper).getEndpoint();
- doReturn("messageId").when(SPY_networkAdapterObjectMapper).getRandomUuid();
-
- CreateNetworkRequest createNetworkRequest = SPY_networkAdapterObjectMapper.createNetworkRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, customer);
-
- assertThat(createNetworkRequest, sameBeanAs(expectedCreateNetworkRequest).ignoring("contrailRequest").ignoring("contrailNetwork").ignoring("providerVlanNetwork").ignoring("subnets").ignoring("messageId"));
- }
-
- @Test
- public void createNetworkRollbackRequestMapperTest() throws Exception {
-
- String cloudRegionPo = "cloudRegionPo";
- RollbackNetworkRequest expectedRollbackNetworkRequest = new RollbackNetworkRequest();
-
- expectedRollbackNetworkRequest.setMessageId(requestContext.getMsoRequestId());
- NetworkRollback networkRollback = new NetworkRollback();
- networkRollback.setCloudId(cloudRegionPo);
- networkRollback.setNetworkCreated(true);
- networkRollback.setNetworkId(l3Network.getNetworkId());
- networkRollback.setNetworkType(l3Network.getNetworkType());
- networkRollback.setTenantId(cloudRegion.getTenantId());
- expectedRollbackNetworkRequest.setNetworkRollback(networkRollback);
- expectedRollbackNetworkRequest.setSkipAAI(true);
-
- CreateNetworkResponse createNetworkResponse = new CreateNetworkResponse();
- createNetworkResponse.setNetworkCreated(true);
-
- RollbackNetworkRequest rollbackNetworkRequest = SPY_networkAdapterObjectMapper.createNetworkRollbackRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, createNetworkResponse);
-
- assertThat(rollbackNetworkRequest, sameBeanAs(expectedRollbackNetworkRequest).ignoring("contrailNetwork").ignoring("providerVlanNetwork").ignoring("subnets").ignoring("networkParams").ignoring("messageId"));
- }
-
- @Test
- public void updateNetworkRequestMapperTest() throws UnsupportedEncodingException {
- org.onap.so.openstack.beans.Subnet subnet = new org.onap.so.openstack.beans.Subnet();
- subnet.setSubnetId("subnetId");
- subnet.setHostRoutes(new ArrayList<org.onap.so.openstack.beans.HostRoute>());
-
- List<org.onap.so.openstack.beans.Subnet> subnets = new ArrayList<>();
- subnets.add(subnet);
-
- ProviderVlanNetwork providerVlanNetwork = new ProviderVlanNetwork("physicalNetworkName", new ArrayList<Integer>());
-
- List<String> policyFqdns = Arrays.asList("networkPolicyFqdn");
-
- org.onap.so.openstack.beans.RouteTarget expectedRouteTarget = new org.onap.so.openstack.beans.RouteTarget();
- expectedRouteTarget.setRouteTarget("globalRouteTarget");
-
- ContrailNetwork contrailNetwork = new ContrailNetwork();
- contrailNetwork.setPolicyFqdns(policyFqdns);
- contrailNetwork.setRouteTableFqdns(new ArrayList<String>());
- contrailNetwork.setRouteTargets(new ArrayList<org.onap.so.openstack.beans.RouteTarget>());
- contrailNetwork.getRouteTargets().add(expectedRouteTarget);
- contrailNetwork.getRouteTableFqdns().add("routeTableReferenceFqdn");
-
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setServiceInstanceId("testServiceInstanceId1");
-
- ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
- modelInfoNetwork.setNetworkType("networkType");
- modelInfoNetwork.setModelCustomizationUUID("modelCustomizationUuid");
- modelInfoNetwork.setModelVersion("modelVersion");
-
- Subnet actualSubnet = new Subnet();
- actualSubnet.setSubnetId("subnetId");
- actualSubnet.setDhcpEnabled(false);
- actualSubnet.setIpVersion("4");
-
- RouteTarget routeTarget = new RouteTarget();
- routeTarget.setGlobalRouteTarget("globalRouteTarget");
-
- VpnBinding vpnBinding = new VpnBinding();
- vpnBinding.setVpnId("vpnId");
- vpnBinding.getRouteTargets().add(routeTarget);
-
- Customer customer = new Customer();
- customer.getVpnBindings().add(vpnBinding);
- ServiceSubscription serviceSubscription = new ServiceSubscription();
- customer.setServiceSubscription(serviceSubscription);
- // set Customer on service instance
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
-
- NetworkPolicy networkPolicy = new NetworkPolicy();
- networkPolicy.setNetworkPolicyId("networkPolicyId");
- networkPolicy.setNetworkPolicyFqdn("networkPolicyFqdn");
-
- RouteTableReference routeTableReference = new RouteTableReference();
- routeTableReference.setRouteTableReferenceFqdn("routeTableReferenceFqdn");
-
- l3Network.setModelInfoNetwork(modelInfoNetwork);
- l3Network.setPhysicalNetworkName("physicalNetworkName");
- l3Network.getSubnets().add(actualSubnet);
- l3Network.getNetworkPolicies().add(networkPolicy);
- l3Network.getContrailNetworkRouteTableReferences().add(routeTableReference);
- l3Network.setIsSharedNetwork(false);
- l3Network.setIsExternalNetwork(false);
- HashMap<String, String> networkParams = new HashMap<String, String>();
- networkParams.put("shared", "false");
- networkParams.put("external", "false");
- networkParams.put("testUserInputKey", "testUserInputValue");
-
- UpdateNetworkRequest expectedUpdateNetworkRequest = new UpdateNetworkRequest();
- expectedUpdateNetworkRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
- expectedUpdateNetworkRequest.setTenantId(cloudRegion.getTenantId());
- expectedUpdateNetworkRequest.setNetworkId(l3Network.getNetworkId());
- expectedUpdateNetworkRequest.setNetworkStackId(l3Network.getHeatStackId());
- expectedUpdateNetworkRequest.setNetworkName(l3Network.getNetworkName());
- expectedUpdateNetworkRequest.setNetworkType(l3Network.getModelInfoNetwork().getNetworkType());
- expectedUpdateNetworkRequest.setNetworkTypeVersion(l3Network.getModelInfoNetwork().getModelVersion());
- expectedUpdateNetworkRequest.setModelCustomizationUuid(l3Network.getModelInfoNetwork().getModelCustomizationUUID());
- expectedUpdateNetworkRequest.setSubnets(subnets);
- expectedUpdateNetworkRequest.setProviderVlanNetwork(providerVlanNetwork);
- expectedUpdateNetworkRequest.setContrailNetwork(contrailNetwork);
- expectedUpdateNetworkRequest.setNetworkParams(networkParams);
- expectedUpdateNetworkRequest.setMsoRequest(msoRequest);
- expectedUpdateNetworkRequest.setSkipAAI(true);
- expectedUpdateNetworkRequest.setBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled()));
- expectedUpdateNetworkRequest.setMessageId("messageId");
- expectedUpdateNetworkRequest.setNotificationUrl("http://localhost:28080/mso/WorkflowMesssage/NetworkAResponse/messageId");
-
- doReturn("messageId").when(SPY_networkAdapterObjectMapper).getRandomUuid();
- doReturn("http://localhost:28080/mso/WorkflowMesssage").when(SPY_networkAdapterObjectMapper).getEndpoint();
- UpdateNetworkRequest actualUpdateNetworkRequest = SPY_networkAdapterObjectMapper.createNetworkUpdateRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, customer);
-
- assertThat(actualUpdateNetworkRequest, sameBeanAs(expectedUpdateNetworkRequest).ignoring("msoRequest.requestId"));
- }
-
- @Test
- public void deleteNetworkRequestMapperTest() throws Exception {
- DeleteNetworkRequest expectedDeleteNetworkRequest = new DeleteNetworkRequest();
-
- String messageId = "messageId";
- expectedDeleteNetworkRequest.setMessageId(messageId);
- doReturn(messageId).when(SPY_networkAdapterObjectMapper).getRandomUuid();
-
- ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
- l3Network.setModelInfoNetwork(modelInfoNetwork);
- modelInfoNetwork.setModelCustomizationUUID("modelCustomizationUuid");
- expectedDeleteNetworkRequest.setModelCustomizationUuid(modelInfoNetwork.getModelCustomizationUUID());
-
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId(requestContext.getMsoRequestId());
- msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
- expectedDeleteNetworkRequest.setMsoRequest(msoRequest);
-
- expectedDeleteNetworkRequest.setNetworkId(l3Network.getNetworkId());
-
- l3Network.setHeatStackId("heatStackId");
- expectedDeleteNetworkRequest.setNetworkStackId(l3Network.getHeatStackId());
-
- expectedDeleteNetworkRequest.setNetworkType(l3Network.getNetworkType());
-
- expectedDeleteNetworkRequest.setSkipAAI(true);
-
- expectedDeleteNetworkRequest.setTenantId(cloudRegion.getTenantId());
-
- expectedDeleteNetworkRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
-
- expectedDeleteNetworkRequest.setNotificationUrl("endpoint/NetworkAResponse/messageId");
-
- doReturn("endpoint/").when(SPY_networkAdapterObjectMapper).getEndpoint();
- doReturn("messageId").when(SPY_networkAdapterObjectMapper).getRandomUuid();
-
- DeleteNetworkRequest deleteNetworkRequest = SPY_networkAdapterObjectMapper.deleteNetworkRequestMapper(requestContext, cloudRegion, serviceInstance, l3Network);
-
- assertThat(expectedDeleteNetworkRequest, sameBeanAs(deleteNetworkRequest));
- }
-
- @Test
- public void deleteNetworkRequestNoHeatIdMapperTest() throws Exception {
- DeleteNetworkRequest expectedDeleteNetworkRequest = new DeleteNetworkRequest();
-
- String messageId = "messageId";
- expectedDeleteNetworkRequest.setMessageId(messageId);
- doReturn(messageId).when(SPY_networkAdapterObjectMapper).getRandomUuid();
-
- ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
- l3Network.setModelInfoNetwork(modelInfoNetwork);
- modelInfoNetwork.setModelCustomizationUUID("modelCustomizationUuid");
- expectedDeleteNetworkRequest.setModelCustomizationUuid(modelInfoNetwork.getModelCustomizationUUID());
-
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId(requestContext.getMsoRequestId());
- msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
- expectedDeleteNetworkRequest.setMsoRequest(msoRequest);
-
- expectedDeleteNetworkRequest.setNetworkId(l3Network.getNetworkId());
-
- l3Network.setNetworkName("heatStackId");
- expectedDeleteNetworkRequest.setNetworkStackId("heatStackId");
-
- expectedDeleteNetworkRequest.setNetworkType(l3Network.getNetworkType());
-
- expectedDeleteNetworkRequest.setSkipAAI(true);
-
- expectedDeleteNetworkRequest.setTenantId(cloudRegion.getTenantId());
-
- expectedDeleteNetworkRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
-
- expectedDeleteNetworkRequest.setNotificationUrl("endpoint/NetworkAResponse/messageId");
-
- doReturn("endpoint/").when(SPY_networkAdapterObjectMapper).getEndpoint();
- doReturn("messageId").when(SPY_networkAdapterObjectMapper).getRandomUuid();
- DeleteNetworkRequest deleteNetworkRequest = SPY_networkAdapterObjectMapper.deleteNetworkRequestMapper(requestContext, cloudRegion, serviceInstance, l3Network);
-
- assertThat(expectedDeleteNetworkRequest, sameBeanAs(deleteNetworkRequest));
- }
-
- @Test
- public void buildOpenstackSubnetListTest() throws Exception {
-
- ObjectMapper omapper = new ObjectMapper();
- String bbJson = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "generalBB.json")));
- org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock gbb = omapper.readValue(
- bbJson,
- org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock.class);
- L3Network myNetwork = gbb.getServiceInstance().getNetworks().get(0);
-
- String expectedCreateNetworkRequestJson = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "createNetworkRequest.json")));
- org.onap.so.adapters.nwrest.CreateNetworkRequest expectedCreateNetworkRequest = omapper.readValue(
- expectedCreateNetworkRequestJson,
- org.onap.so.adapters.nwrest.CreateNetworkRequest.class);
-
- String cloudRegionPo = "cloudRegionPo";
-
- expectedCreateNetworkRequest.setNotificationUrl("endpoint/NetworkAResponse/messageId");
-
- doReturn("endpoint/").when(SPY_networkAdapterObjectMapper).getEndpoint();
- doReturn("messageId").when(SPY_networkAdapterObjectMapper).getRandomUuid();
- CreateNetworkRequest createNetworkRequest = SPY_networkAdapterObjectMapper.createNetworkRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, myNetwork, userInput, cloudRegionPo, customer);
- //ignoring dynamic fields and networkParams that throws parsing exception on json file load
- assertThat(createNetworkRequest, sameBeanAs(expectedCreateNetworkRequest).ignoring("messageId").ignoring("msoRequest.requestId").ignoring("networkParams"));
- }
+public class NetworkAdapterObjectMapperTest extends TestDataSetup {
+
+ private NetworkAdapterObjectMapper SPY_networkAdapterObjectMapper = Mockito.spy(NetworkAdapterObjectMapper.class);
+
+ private L3Network l3Network;
+ private RequestContext requestContext;
+ private ServiceInstance serviceInstance;
+ private CloudRegion cloudRegion;
+ private OrchestrationContext orchestrationContext;
+ private Customer customer;
+ Map<String, String> userInput;
+
+ private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/NetworkMapper/";
+
+ @Before
+ public void before() {
+ requestContext = setRequestContext();
+
+ customer = buildCustomer();
+
+ serviceInstance = setServiceInstance();
+
+ cloudRegion = setCloudRegion();
+
+ orchestrationContext = setOrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(false);
+
+ userInput = setUserInput();
+
+ l3Network = setL3Network();
+
+ customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
+ }
+
+ @Test
+ public void buildCreateNetworkRequestFromBbobjectTest() throws Exception {
+
+ String cloudRegionPo = "cloudRegionPo";
+ CreateNetworkRequest expectedCreateNetworkRequest = new CreateNetworkRequest();
+
+ expectedCreateNetworkRequest.setCloudSiteId(cloudRegionPo);
+ expectedCreateNetworkRequest.setTenantId(cloudRegion.getTenantId());
+ expectedCreateNetworkRequest.setNetworkId(l3Network.getNetworkId());
+ expectedCreateNetworkRequest.setNetworkName(l3Network.getNetworkName());
+ expectedCreateNetworkRequest.setNetworkType(l3Network.getNetworkType());
+ expectedCreateNetworkRequest.setBackout(false);
+ expectedCreateNetworkRequest.setFailIfExists(true);
+ expectedCreateNetworkRequest.setNetworkTechnology("CONTRAIL");
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId(requestContext.getMsoRequestId());
+ msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
+ expectedCreateNetworkRequest.setMsoRequest(msoRequest);
+ expectedCreateNetworkRequest.setSkipAAI(true);
+ HashMap<String, String> networkParams = new HashMap<String, String>();
+ networkParams.put("shared", "true");
+ networkParams.put("external", "false");
+ networkParams.put("testUserInputKey", "testUserInputValue");
+ expectedCreateNetworkRequest.setNetworkParams(networkParams);
+
+ expectedCreateNetworkRequest.setNotificationUrl("endpoint/NetworkAResponse/messageId");
+
+ Subnet openstackSubnet = new Subnet();
+ HostRoute hostRoute = new HostRoute();
+ hostRoute.setHostRouteId("hostRouteId");
+ hostRoute.setNextHop("nextHop");
+ hostRoute.setRoutePrefix("routePrefix");
+ openstackSubnet.getHostRoutes().add(hostRoute);
+ List<Subnet> subnetList = new ArrayList<Subnet>();
+ subnetList.add(openstackSubnet);
+ l3Network.getSubnets().add(openstackSubnet);
+ l3Network.setNetworkTechnology("Contrail");
+ l3Network.setIsSharedNetwork(true);
+ l3Network.setIsExternalNetwork(false);
+
+ doReturn("endpoint/").when(SPY_networkAdapterObjectMapper).getEndpoint();
+ doReturn("messageId").when(SPY_networkAdapterObjectMapper).getRandomUuid();
+
+ CreateNetworkRequest createNetworkRequest =
+ SPY_networkAdapterObjectMapper.createNetworkRequestMapper(requestContext, cloudRegion,
+ orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, customer);
+
+ assertThat(createNetworkRequest, sameBeanAs(expectedCreateNetworkRequest).ignoring("contrailRequest")
+ .ignoring("contrailNetwork").ignoring("providerVlanNetwork").ignoring("subnets").ignoring("messageId"));
+ }
+
+ @Test
+ public void createNetworkRollbackRequestMapperTest() throws Exception {
+
+ String cloudRegionPo = "cloudRegionPo";
+ RollbackNetworkRequest expectedRollbackNetworkRequest = new RollbackNetworkRequest();
+
+ expectedRollbackNetworkRequest.setMessageId(requestContext.getMsoRequestId());
+ NetworkRollback networkRollback = new NetworkRollback();
+ networkRollback.setCloudId(cloudRegionPo);
+ networkRollback.setNetworkCreated(true);
+ networkRollback.setNetworkId(l3Network.getNetworkId());
+ networkRollback.setNetworkType(l3Network.getNetworkType());
+ networkRollback.setTenantId(cloudRegion.getTenantId());
+ expectedRollbackNetworkRequest.setNetworkRollback(networkRollback);
+ expectedRollbackNetworkRequest.setSkipAAI(true);
+
+ CreateNetworkResponse createNetworkResponse = new CreateNetworkResponse();
+ createNetworkResponse.setNetworkCreated(true);
+
+ RollbackNetworkRequest rollbackNetworkRequest = SPY_networkAdapterObjectMapper
+ .createNetworkRollbackRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance,
+ l3Network, userInput, cloudRegionPo, createNetworkResponse);
+
+ assertThat(rollbackNetworkRequest, sameBeanAs(expectedRollbackNetworkRequest).ignoring("contrailNetwork")
+ .ignoring("providerVlanNetwork").ignoring("subnets").ignoring("networkParams").ignoring("messageId"));
+ }
+
+ @Test
+ public void updateNetworkRequestMapperTest() throws UnsupportedEncodingException {
+ org.onap.so.openstack.beans.Subnet subnet = new org.onap.so.openstack.beans.Subnet();
+ subnet.setSubnetId("subnetId");
+ subnet.setHostRoutes(new ArrayList<org.onap.so.openstack.beans.HostRoute>());
+
+ List<org.onap.so.openstack.beans.Subnet> subnets = new ArrayList<>();
+ subnets.add(subnet);
+
+ ProviderVlanNetwork providerVlanNetwork =
+ new ProviderVlanNetwork("physicalNetworkName", new ArrayList<Integer>());
+
+ List<String> policyFqdns = Arrays.asList("networkPolicyFqdn");
+
+ org.onap.so.openstack.beans.RouteTarget expectedRouteTarget = new org.onap.so.openstack.beans.RouteTarget();
+ expectedRouteTarget.setRouteTarget("globalRouteTarget");
+
+ ContrailNetwork contrailNetwork = new ContrailNetwork();
+ contrailNetwork.setPolicyFqdns(policyFqdns);
+ contrailNetwork.setRouteTableFqdns(new ArrayList<String>());
+ contrailNetwork.setRouteTargets(new ArrayList<org.onap.so.openstack.beans.RouteTarget>());
+ contrailNetwork.getRouteTargets().add(expectedRouteTarget);
+ contrailNetwork.getRouteTableFqdns().add("routeTableReferenceFqdn");
+
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setServiceInstanceId("testServiceInstanceId1");
+
+ ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
+ modelInfoNetwork.setNetworkType("networkType");
+ modelInfoNetwork.setModelCustomizationUUID("modelCustomizationUuid");
+ modelInfoNetwork.setModelVersion("modelVersion");
+
+ Subnet actualSubnet = new Subnet();
+ actualSubnet.setSubnetId("subnetId");
+ actualSubnet.setDhcpEnabled(false);
+ actualSubnet.setIpVersion("4");
+
+ RouteTarget routeTarget = new RouteTarget();
+ routeTarget.setGlobalRouteTarget("globalRouteTarget");
+
+ VpnBinding vpnBinding = new VpnBinding();
+ vpnBinding.setVpnId("vpnId");
+ vpnBinding.getRouteTargets().add(routeTarget);
+
+ Customer customer = new Customer();
+ customer.getVpnBindings().add(vpnBinding);
+ ServiceSubscription serviceSubscription = new ServiceSubscription();
+ customer.setServiceSubscription(serviceSubscription);
+ // set Customer on service instance
+ customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
+
+ NetworkPolicy networkPolicy = new NetworkPolicy();
+ networkPolicy.setNetworkPolicyId("networkPolicyId");
+ networkPolicy.setNetworkPolicyFqdn("networkPolicyFqdn");
+
+ RouteTableReference routeTableReference = new RouteTableReference();
+ routeTableReference.setRouteTableReferenceFqdn("routeTableReferenceFqdn");
+
+ l3Network.setModelInfoNetwork(modelInfoNetwork);
+ l3Network.setPhysicalNetworkName("physicalNetworkName");
+ l3Network.getSubnets().add(actualSubnet);
+ l3Network.getNetworkPolicies().add(networkPolicy);
+ l3Network.getContrailNetworkRouteTableReferences().add(routeTableReference);
+ l3Network.setIsSharedNetwork(false);
+ l3Network.setIsExternalNetwork(false);
+ HashMap<String, String> networkParams = new HashMap<String, String>();
+ networkParams.put("shared", "false");
+ networkParams.put("external", "false");
+ networkParams.put("testUserInputKey", "testUserInputValue");
+
+ UpdateNetworkRequest expectedUpdateNetworkRequest = new UpdateNetworkRequest();
+ expectedUpdateNetworkRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
+ expectedUpdateNetworkRequest.setTenantId(cloudRegion.getTenantId());
+ expectedUpdateNetworkRequest.setNetworkId(l3Network.getNetworkId());
+ expectedUpdateNetworkRequest.setNetworkStackId(l3Network.getHeatStackId());
+ expectedUpdateNetworkRequest.setNetworkName(l3Network.getNetworkName());
+ expectedUpdateNetworkRequest.setNetworkType(l3Network.getModelInfoNetwork().getNetworkType());
+ expectedUpdateNetworkRequest.setNetworkTypeVersion(l3Network.getModelInfoNetwork().getModelVersion());
+ expectedUpdateNetworkRequest
+ .setModelCustomizationUuid(l3Network.getModelInfoNetwork().getModelCustomizationUUID());
+ expectedUpdateNetworkRequest.setSubnets(subnets);
+ expectedUpdateNetworkRequest.setProviderVlanNetwork(providerVlanNetwork);
+ expectedUpdateNetworkRequest.setContrailNetwork(contrailNetwork);
+ expectedUpdateNetworkRequest.setNetworkParams(networkParams);
+ expectedUpdateNetworkRequest.setMsoRequest(msoRequest);
+ expectedUpdateNetworkRequest.setSkipAAI(true);
+ expectedUpdateNetworkRequest.setBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled()));
+ expectedUpdateNetworkRequest.setMessageId("messageId");
+ expectedUpdateNetworkRequest
+ .setNotificationUrl("http://localhost:28080/mso/WorkflowMesssage/NetworkAResponse/messageId");
+
+ doReturn("messageId").when(SPY_networkAdapterObjectMapper).getRandomUuid();
+ doReturn("http://localhost:28080/mso/WorkflowMesssage").when(SPY_networkAdapterObjectMapper).getEndpoint();
+ UpdateNetworkRequest actualUpdateNetworkRequest =
+ SPY_networkAdapterObjectMapper.createNetworkUpdateRequestMapper(requestContext, cloudRegion,
+ orchestrationContext, serviceInstance, l3Network, userInput, customer);
+
+ assertThat(actualUpdateNetworkRequest,
+ sameBeanAs(expectedUpdateNetworkRequest).ignoring("msoRequest.requestId"));
+ }
+
+ @Test
+ public void deleteNetworkRequestMapperTest() throws Exception {
+ DeleteNetworkRequest expectedDeleteNetworkRequest = new DeleteNetworkRequest();
+
+ String messageId = "messageId";
+ expectedDeleteNetworkRequest.setMessageId(messageId);
+ doReturn(messageId).when(SPY_networkAdapterObjectMapper).getRandomUuid();
+
+ ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
+ l3Network.setModelInfoNetwork(modelInfoNetwork);
+ modelInfoNetwork.setModelCustomizationUUID("modelCustomizationUuid");
+ expectedDeleteNetworkRequest.setModelCustomizationUuid(modelInfoNetwork.getModelCustomizationUUID());
+
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId(requestContext.getMsoRequestId());
+ msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
+ expectedDeleteNetworkRequest.setMsoRequest(msoRequest);
+
+ expectedDeleteNetworkRequest.setNetworkId(l3Network.getNetworkId());
+
+ l3Network.setHeatStackId("heatStackId");
+ expectedDeleteNetworkRequest.setNetworkStackId(l3Network.getHeatStackId());
+
+ expectedDeleteNetworkRequest.setNetworkType(l3Network.getNetworkType());
+
+ expectedDeleteNetworkRequest.setSkipAAI(true);
+
+ expectedDeleteNetworkRequest.setTenantId(cloudRegion.getTenantId());
+
+ expectedDeleteNetworkRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
+
+ expectedDeleteNetworkRequest.setNotificationUrl("endpoint/NetworkAResponse/messageId");
+
+ doReturn("endpoint/").when(SPY_networkAdapterObjectMapper).getEndpoint();
+ doReturn("messageId").when(SPY_networkAdapterObjectMapper).getRandomUuid();
+
+ DeleteNetworkRequest deleteNetworkRequest = SPY_networkAdapterObjectMapper
+ .deleteNetworkRequestMapper(requestContext, cloudRegion, serviceInstance, l3Network);
+
+ assertThat(expectedDeleteNetworkRequest, sameBeanAs(deleteNetworkRequest));
+ }
+
+ @Test
+ public void deleteNetworkRequestNoHeatIdMapperTest() throws Exception {
+ DeleteNetworkRequest expectedDeleteNetworkRequest = new DeleteNetworkRequest();
+
+ String messageId = "messageId";
+ expectedDeleteNetworkRequest.setMessageId(messageId);
+ doReturn(messageId).when(SPY_networkAdapterObjectMapper).getRandomUuid();
+
+ ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
+ l3Network.setModelInfoNetwork(modelInfoNetwork);
+ modelInfoNetwork.setModelCustomizationUUID("modelCustomizationUuid");
+ expectedDeleteNetworkRequest.setModelCustomizationUuid(modelInfoNetwork.getModelCustomizationUUID());
+
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId(requestContext.getMsoRequestId());
+ msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
+ expectedDeleteNetworkRequest.setMsoRequest(msoRequest);
+
+ expectedDeleteNetworkRequest.setNetworkId(l3Network.getNetworkId());
+
+ l3Network.setNetworkName("heatStackId");
+ expectedDeleteNetworkRequest.setNetworkStackId("heatStackId");
+
+ expectedDeleteNetworkRequest.setNetworkType(l3Network.getNetworkType());
+
+ expectedDeleteNetworkRequest.setSkipAAI(true);
+
+ expectedDeleteNetworkRequest.setTenantId(cloudRegion.getTenantId());
+
+ expectedDeleteNetworkRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
+
+ expectedDeleteNetworkRequest.setNotificationUrl("endpoint/NetworkAResponse/messageId");
+
+ doReturn("endpoint/").when(SPY_networkAdapterObjectMapper).getEndpoint();
+ doReturn("messageId").when(SPY_networkAdapterObjectMapper).getRandomUuid();
+ DeleteNetworkRequest deleteNetworkRequest = SPY_networkAdapterObjectMapper
+ .deleteNetworkRequestMapper(requestContext, cloudRegion, serviceInstance, l3Network);
+
+ assertThat(expectedDeleteNetworkRequest, sameBeanAs(deleteNetworkRequest));
+ }
+
+ @Test
+ public void buildOpenstackSubnetListTest() throws Exception {
+
+ ObjectMapper omapper = new ObjectMapper();
+ String bbJson = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "generalBB.json")));
+ org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock gbb =
+ omapper.readValue(bbJson, org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock.class);
+ L3Network myNetwork = gbb.getServiceInstance().getNetworks().get(0);
+
+ String expectedCreateNetworkRequestJson =
+ new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "createNetworkRequest.json")));
+ org.onap.so.adapters.nwrest.CreateNetworkRequest expectedCreateNetworkRequest = omapper
+ .readValue(expectedCreateNetworkRequestJson, org.onap.so.adapters.nwrest.CreateNetworkRequest.class);
+
+ String cloudRegionPo = "cloudRegionPo";
+
+ expectedCreateNetworkRequest.setNotificationUrl("endpoint/NetworkAResponse/messageId");
+
+ doReturn("endpoint/").when(SPY_networkAdapterObjectMapper).getEndpoint();
+ doReturn("messageId").when(SPY_networkAdapterObjectMapper).getRandomUuid();
+ CreateNetworkRequest createNetworkRequest =
+ SPY_networkAdapterObjectMapper.createNetworkRequestMapper(requestContext, cloudRegion,
+ orchestrationContext, serviceInstance, myNetwork, userInput, cloudRegionPo, customer);
+ // ignoring dynamic fields and networkParams that throws parsing exception on json file load
+ assertThat(createNetworkRequest, sameBeanAs(expectedCreateNetworkRequest).ignoring("messageId")
+ .ignoring("msoRequest.requestId").ignoring("networkParams"));
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfAdapterClientIT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfAdapterClientIT.java
index 90e99eb0ad..7fb1db9d98 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfAdapterClientIT.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfAdapterClientIT.java
@@ -28,7 +28,6 @@ import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.put;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static org.junit.Assert.assertEquals;
-
import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.so.BaseIntegrationTest;
@@ -44,182 +43,179 @@ import org.onap.so.adapters.vnfrest.UpdateVfModuleResponse;
import org.onap.so.adapters.vnfrest.VfModuleExceptionResponse;
import org.onap.so.adapters.vnfrest.VfModuleRollback;
import org.onap.so.client.policy.JettisonStyleMapperProvider;
-
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
-public class VnfAdapterClientIT extends BaseIntegrationTest{
-
- private static final String TESTING_ID = "___TESTING___";
- private static final String AAI_VNF_ID = "test";
- private static final String AAI_VF_MODULE_ID = "test";
- private static final String REST_ENDPOINT = "/services/rest/v1/vnfs";
-
- private VnfAdapterClientImpl client = new VnfAdapterClientImpl();
- private ObjectMapper mapper = new JettisonStyleMapperProvider().getMapper();
-
- @BeforeClass
- public static void setUp() {
- System.setProperty("mso.config.path", "src/test/resources");
- }
-
- @Test
- public void createVfModuleTest() throws JsonProcessingException, VnfAdapterClientException {
- CreateVfModuleRequest request = new CreateVfModuleRequest();
- request.setCloudSiteId(TESTING_ID);
-
- CreateVfModuleResponse mockResponse = new CreateVfModuleResponse();
- mockResponse.setVfModuleCreated(true);
- wireMockServer.stubFor(post(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
-
- CreateVfModuleResponse response = client.createVfModule(AAI_VNF_ID, request);
- assertEquals("Testing CreateVfModule response", true, response.getVfModuleCreated());
- }
-
- @Test(expected = VnfAdapterClientException.class)
- public void createVfModuleTestThrowException() throws JsonProcessingException, VnfAdapterClientException {
- CreateVfModuleRequest request = new CreateVfModuleRequest();
- request.setCloudSiteId(TESTING_ID);
-
- VfModuleExceptionResponse mockResponse = new VfModuleExceptionResponse();
- mockResponse.setMessage("Error in create Vf module");
- wireMockServer.stubFor(post(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
-
- client.createVfModule(AAI_VNF_ID, request);
- }
-
- @Test
- public void rollbackVfModuleTest() throws JsonProcessingException, VnfAdapterClientException {
- RollbackVfModuleRequest request = new RollbackVfModuleRequest();
- VfModuleRollback rollback = new VfModuleRollback();
- rollback.setCloudSiteId(TESTING_ID);
- request.setVfModuleRollback(rollback);
-
- RollbackVfModuleResponse mockResponse = new RollbackVfModuleResponse();
- mockResponse.setVfModuleRolledback(true);
- wireMockServer.stubFor(
- delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID + "/rollback"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
-
- RollbackVfModuleResponse response = client.rollbackVfModule(AAI_VNF_ID, AAI_VF_MODULE_ID, request);
- assertEquals("Testing RollbackVfModule response", true, response.getVfModuleRolledback());
- }
-
- @Test(expected = VnfAdapterClientException.class)
- public void rollbackVfModuleTestThrowException() throws JsonProcessingException, VnfAdapterClientException {
- RollbackVfModuleRequest request = new RollbackVfModuleRequest();
- VfModuleRollback rollback = new VfModuleRollback();
- rollback.setCloudSiteId(TESTING_ID);
- request.setVfModuleRollback(rollback);
-
- VfModuleExceptionResponse mockResponse = new VfModuleExceptionResponse();
- mockResponse.setMessage("Error in rollback Vf module");
- wireMockServer.stubFor(
- delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID + "/rollback"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
-
- client.rollbackVfModule(AAI_VNF_ID, AAI_VF_MODULE_ID, request);
- }
-
- @Test
- public void deleteVfModuleTest() throws JsonProcessingException, VnfAdapterClientException {
- DeleteVfModuleRequest request = new DeleteVfModuleRequest();
- request.setCloudSiteId(TESTING_ID);
-
- DeleteVfModuleResponse mockResponse = new DeleteVfModuleResponse();
- mockResponse.setVfModuleDeleted(true);
- wireMockServer.stubFor(delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
-
- DeleteVfModuleResponse response = client.deleteVfModule(AAI_VNF_ID, AAI_VF_MODULE_ID, request);
- assertEquals("Testing DeleteVfModule response", true, response.getVfModuleDeleted());
- }
-
- @Test(expected = VnfAdapterClientException.class)
- public void deleteVfModuleTestThrowException() throws JsonProcessingException, VnfAdapterClientException {
- DeleteVfModuleRequest request = new DeleteVfModuleRequest();
- request.setCloudSiteId(TESTING_ID);
-
- VfModuleExceptionResponse mockResponse = new VfModuleExceptionResponse();
- mockResponse.setMessage("Error in delete Vf module");
- wireMockServer.stubFor(delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
-
- client.deleteVfModule(AAI_VNF_ID, AAI_VF_MODULE_ID, request);
- }
-
- @Test
- public void updateVfModuleTest() throws JsonProcessingException, VnfAdapterClientException {
- UpdateVfModuleRequest request = new UpdateVfModuleRequest();
- request.setCloudSiteId(TESTING_ID);
- request.setVfModuleId("test1");
-
- UpdateVfModuleResponse mockResponse = new UpdateVfModuleResponse();
- mockResponse.setVfModuleId("test1");
- wireMockServer.stubFor(put(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
-
- UpdateVfModuleResponse response = client.updateVfModule(AAI_VNF_ID, AAI_VF_MODULE_ID, request);
- assertEquals("Testing UpdateVfModule response", "test1", response.getVfModuleId());
- }
-
- @Test(expected = VnfAdapterClientException.class)
- public void updateVfModuleTestThrowException() throws JsonProcessingException, VnfAdapterClientException {
- UpdateVfModuleRequest request = new UpdateVfModuleRequest();
- request.setCloudSiteId(TESTING_ID);
- request.setVfModuleId("test1");
-
- VfModuleExceptionResponse mockResponse = new VfModuleExceptionResponse();
- mockResponse.setMessage("Error in update Vf module");
- wireMockServer.stubFor(put(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
-
- client.updateVfModule(AAI_VNF_ID, AAI_VF_MODULE_ID, request);
- }
-
- @Test
- public void queryVfModuleTest() throws JsonProcessingException, VnfAdapterClientException {
- QueryVfModuleResponse mockResponse = new QueryVfModuleResponse();
- mockResponse.setVnfId(AAI_VNF_ID);
- mockResponse.setVfModuleId(AAI_VF_MODULE_ID);
- wireMockServer.stubFor(get(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID))
- .withQueryParam("cloudSiteId", equalTo(TESTING_ID))
- .withQueryParam("tenantId", equalTo(TESTING_ID))
- .withQueryParam("vfModuleName", equalTo("someName"))
- .withQueryParam("skipAAI", equalTo("true"))
- .withQueryParam("msoRequest.requestId", equalTo("testRequestId"))
- .withQueryParam("msoRequest.serviceInstanceId", equalTo("serviceInstanceId"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
- QueryVfModuleResponse response = client.queryVfModule(AAI_VNF_ID, AAI_VF_MODULE_ID, TESTING_ID, TESTING_ID,
- "someName", true, "testRequestId", "serviceInstanceId");
- assertEquals("Testing QueryVfModule response", AAI_VF_MODULE_ID, response.getVfModuleId());
- }
-
- @Test(expected = VnfAdapterClientException.class)
- public void queryVfModuleTestThrowException() throws JsonProcessingException, VnfAdapterClientException {
- VfModuleExceptionResponse mockResponse = new VfModuleExceptionResponse();
- mockResponse.setMessage("Error in update Vf module");
- wireMockServer.stubFor(get(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID))
- .withQueryParam("cloudSiteId", equalTo(TESTING_ID))
- .withQueryParam("tenantId", equalTo(TESTING_ID))
- .withQueryParam("vfModuleName", equalTo("someName"))
- .withQueryParam("skipAAI", equalTo("true"))
- .withQueryParam("msoRequest.requestId", equalTo("testRequestId"))
- .withQueryParam("msoRequest.serviceInstanceId", equalTo("serviceInstanceId"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
- client.queryVfModule(AAI_VNF_ID, AAI_VF_MODULE_ID, TESTING_ID, TESTING_ID,
- "someName", true, "testRequestId", "serviceInstanceId");
- }
+public class VnfAdapterClientIT extends BaseIntegrationTest {
+
+ private static final String TESTING_ID = "___TESTING___";
+ private static final String AAI_VNF_ID = "test";
+ private static final String AAI_VF_MODULE_ID = "test";
+ private static final String REST_ENDPOINT = "/services/rest/v1/vnfs";
+
+ private VnfAdapterClientImpl client = new VnfAdapterClientImpl();
+ private ObjectMapper mapper = new JettisonStyleMapperProvider().getMapper();
+
+ @BeforeClass
+ public static void setUp() {
+ System.setProperty("mso.config.path", "src/test/resources");
+ }
+
+ @Test
+ public void createVfModuleTest() throws JsonProcessingException, VnfAdapterClientException {
+ CreateVfModuleRequest request = new CreateVfModuleRequest();
+ request.setCloudSiteId(TESTING_ID);
+
+ CreateVfModuleResponse mockResponse = new CreateVfModuleResponse();
+ mockResponse.setVfModuleCreated(true);
+ wireMockServer.stubFor(post(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
+
+ CreateVfModuleResponse response = client.createVfModule(AAI_VNF_ID, request);
+ assertEquals("Testing CreateVfModule response", true, response.getVfModuleCreated());
+ }
+
+ @Test(expected = VnfAdapterClientException.class)
+ public void createVfModuleTestThrowException() throws JsonProcessingException, VnfAdapterClientException {
+ CreateVfModuleRequest request = new CreateVfModuleRequest();
+ request.setCloudSiteId(TESTING_ID);
+
+ VfModuleExceptionResponse mockResponse = new VfModuleExceptionResponse();
+ mockResponse.setMessage("Error in create Vf module");
+ wireMockServer.stubFor(post(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
+
+ client.createVfModule(AAI_VNF_ID, request);
+ }
+
+ @Test
+ public void rollbackVfModuleTest() throws JsonProcessingException, VnfAdapterClientException {
+ RollbackVfModuleRequest request = new RollbackVfModuleRequest();
+ VfModuleRollback rollback = new VfModuleRollback();
+ rollback.setCloudSiteId(TESTING_ID);
+ request.setVfModuleRollback(rollback);
+
+ RollbackVfModuleResponse mockResponse = new RollbackVfModuleResponse();
+ mockResponse.setVfModuleRolledback(true);
+ wireMockServer.stubFor(delete(
+ urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID + "/rollback"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
+
+ RollbackVfModuleResponse response = client.rollbackVfModule(AAI_VNF_ID, AAI_VF_MODULE_ID, request);
+ assertEquals("Testing RollbackVfModule response", true, response.getVfModuleRolledback());
+ }
+
+ @Test(expected = VnfAdapterClientException.class)
+ public void rollbackVfModuleTestThrowException() throws JsonProcessingException, VnfAdapterClientException {
+ RollbackVfModuleRequest request = new RollbackVfModuleRequest();
+ VfModuleRollback rollback = new VfModuleRollback();
+ rollback.setCloudSiteId(TESTING_ID);
+ request.setVfModuleRollback(rollback);
+
+ VfModuleExceptionResponse mockResponse = new VfModuleExceptionResponse();
+ mockResponse.setMessage("Error in rollback Vf module");
+ wireMockServer.stubFor(delete(
+ urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID + "/rollback"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
+
+ client.rollbackVfModule(AAI_VNF_ID, AAI_VF_MODULE_ID, request);
+ }
+
+ @Test
+ public void deleteVfModuleTest() throws JsonProcessingException, VnfAdapterClientException {
+ DeleteVfModuleRequest request = new DeleteVfModuleRequest();
+ request.setCloudSiteId(TESTING_ID);
+
+ DeleteVfModuleResponse mockResponse = new DeleteVfModuleResponse();
+ mockResponse.setVfModuleDeleted(true);
+ wireMockServer
+ .stubFor(delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
+
+ DeleteVfModuleResponse response = client.deleteVfModule(AAI_VNF_ID, AAI_VF_MODULE_ID, request);
+ assertEquals("Testing DeleteVfModule response", true, response.getVfModuleDeleted());
+ }
+
+ @Test(expected = VnfAdapterClientException.class)
+ public void deleteVfModuleTestThrowException() throws JsonProcessingException, VnfAdapterClientException {
+ DeleteVfModuleRequest request = new DeleteVfModuleRequest();
+ request.setCloudSiteId(TESTING_ID);
+
+ VfModuleExceptionResponse mockResponse = new VfModuleExceptionResponse();
+ mockResponse.setMessage("Error in delete Vf module");
+ wireMockServer
+ .stubFor(delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
+
+ client.deleteVfModule(AAI_VNF_ID, AAI_VF_MODULE_ID, request);
+ }
+
+ @Test
+ public void updateVfModuleTest() throws JsonProcessingException, VnfAdapterClientException {
+ UpdateVfModuleRequest request = new UpdateVfModuleRequest();
+ request.setCloudSiteId(TESTING_ID);
+ request.setVfModuleId("test1");
+
+ UpdateVfModuleResponse mockResponse = new UpdateVfModuleResponse();
+ mockResponse.setVfModuleId("test1");
+ wireMockServer.stubFor(put(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
+
+ UpdateVfModuleResponse response = client.updateVfModule(AAI_VNF_ID, AAI_VF_MODULE_ID, request);
+ assertEquals("Testing UpdateVfModule response", "test1", response.getVfModuleId());
+ }
+
+ @Test(expected = VnfAdapterClientException.class)
+ public void updateVfModuleTestThrowException() throws JsonProcessingException, VnfAdapterClientException {
+ UpdateVfModuleRequest request = new UpdateVfModuleRequest();
+ request.setCloudSiteId(TESTING_ID);
+ request.setVfModuleId("test1");
+
+ VfModuleExceptionResponse mockResponse = new VfModuleExceptionResponse();
+ mockResponse.setMessage("Error in update Vf module");
+ wireMockServer.stubFor(put(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
+
+ client.updateVfModule(AAI_VNF_ID, AAI_VF_MODULE_ID, request);
+ }
+
+ @Test
+ public void queryVfModuleTest() throws JsonProcessingException, VnfAdapterClientException {
+ QueryVfModuleResponse mockResponse = new QueryVfModuleResponse();
+ mockResponse.setVnfId(AAI_VNF_ID);
+ mockResponse.setVfModuleId(AAI_VF_MODULE_ID);
+ wireMockServer.stubFor(get(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID))
+ .withQueryParam("cloudSiteId", equalTo(TESTING_ID)).withQueryParam("tenantId", equalTo(TESTING_ID))
+ .withQueryParam("vfModuleName", equalTo("someName")).withQueryParam("skipAAI", equalTo("true"))
+ .withQueryParam("msoRequest.requestId", equalTo("testRequestId"))
+ .withQueryParam("msoRequest.serviceInstanceId", equalTo("serviceInstanceId"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
+ QueryVfModuleResponse response = client.queryVfModule(AAI_VNF_ID, AAI_VF_MODULE_ID, TESTING_ID, TESTING_ID,
+ "someName", true, "testRequestId", "serviceInstanceId");
+ assertEquals("Testing QueryVfModule response", AAI_VF_MODULE_ID, response.getVfModuleId());
+ }
+
+ @Test(expected = VnfAdapterClientException.class)
+ public void queryVfModuleTestThrowException() throws JsonProcessingException, VnfAdapterClientException {
+ VfModuleExceptionResponse mockResponse = new VfModuleExceptionResponse();
+ mockResponse.setMessage("Error in update Vf module");
+ wireMockServer.stubFor(get(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID))
+ .withQueryParam("cloudSiteId", equalTo(TESTING_ID)).withQueryParam("tenantId", equalTo(TESTING_ID))
+ .withQueryParam("vfModuleName", equalTo("someName")).withQueryParam("skipAAI", equalTo("true"))
+ .withQueryParam("msoRequest.requestId", equalTo("testRequestId"))
+ .withQueryParam("msoRequest.serviceInstanceId", equalTo("serviceInstanceId"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
+ client.queryVfModule(AAI_VNF_ID, AAI_VF_MODULE_ID, TESTING_ID, TESTING_ID, "someName", true, "testRequestId",
+ "serviceInstanceId");
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterClientIT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterClientIT.java
index 4a006f8b66..282d7a04f9 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterClientIT.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterClientIT.java
@@ -25,10 +25,8 @@ import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
-
import javax.ws.rs.InternalServerErrorException;
import javax.ws.rs.core.UriBuilder;
-
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.MockitoAnnotations;
@@ -44,169 +42,170 @@ import org.onap.so.adapters.vnfrest.UpdateVolumeGroupResponse;
import org.onap.so.client.adapter.rest.AdapterRestClient;
import org.onap.so.BaseIntegrationTest;
-public class VnfVolumeAdapterClientIT extends BaseIntegrationTest{
-
- private static final String TESTING_ID = "___TESTING___";
- private static final String AAI_VOLUME_GROUP_ID = "test";
- private static final String CLOUD_SITE_ID = "test";
- private static final String TENANT_ID = "test";
- private static final String VOLUME_GROUP_STACK_ID = "test";
- private static final boolean SKIP_AAI = true;
- private static final String REQUEST_ID = "test";
- private static final String SERVICE_INSTANCE_ID = "test";
-
- @Test
- public void createVolumeGroupTest() throws VnfAdapterClientException {
- CreateVolumeGroupRequest request = new CreateVolumeGroupRequest();
- request.setCloudSiteId(TESTING_ID);
-
- CreateVolumeGroupResponse mockResponse = new CreateVolumeGroupResponse();
- mockResponse.setVolumeGroupCreated(true);
-
- VnfVolumeAdapterClientImpl client = spy(VnfVolumeAdapterClientImpl.class);
- AdapterRestClient mockClient = mock(AdapterRestClient.class);
-
- doReturn(mockClient).when(client).getAdapterRestClient("");
- when(mockClient.post(request, CreateVolumeGroupResponse.class)).thenReturn(mockResponse);
-
- CreateVolumeGroupResponse response = client.createVNFVolumes(request);
- assertEquals("Testing CreateVolumeGroup response", mockResponse.getVolumeGroupCreated(),
- response.getVolumeGroupCreated());
- }
-
- @Test(expected = VnfAdapterClientException.class)
- public void createVolumeGroupTestThrowException() throws VnfAdapterClientException {
- CreateVolumeGroupRequest request = new CreateVolumeGroupRequest();
- request.setCloudSiteId(TESTING_ID);
-
- CreateVolumeGroupResponse mockResponse = new CreateVolumeGroupResponse();
- mockResponse.setVolumeGroupCreated(true);
-
- VnfVolumeAdapterClientImpl client = spy(VnfVolumeAdapterClientImpl.class);
- AdapterRestClient mockClient = mock(AdapterRestClient.class);
-
- doReturn(mockClient).when(client).getAdapterRestClient("");
- when(mockClient.post(request, CreateVolumeGroupResponse.class)).thenThrow(new InternalServerErrorException("Error in create volume group"));
-
- client.createVNFVolumes(request);
- }
-
- @Test
- public void deleteVolumeGroupTest() throws VnfAdapterClientException {
- DeleteVolumeGroupRequest request = new DeleteVolumeGroupRequest();
- request.setCloudSiteId(TESTING_ID);
-
- DeleteVolumeGroupResponse mockResponse = new DeleteVolumeGroupResponse();
- mockResponse.setVolumeGroupDeleted(true);
-
- VnfVolumeAdapterClientImpl client = spy(VnfVolumeAdapterClientImpl.class);
- AdapterRestClient mockClient = mock(AdapterRestClient.class);
- doReturn(mockClient).when(client).getAdapterRestClient("/" + AAI_VOLUME_GROUP_ID);
- when(mockClient.delete(request, DeleteVolumeGroupResponse.class)).thenReturn(mockResponse);
- MockitoAnnotations.initMocks(this);
-
- DeleteVolumeGroupResponse response = client.deleteVNFVolumes(AAI_VOLUME_GROUP_ID, request);
- assertEquals("Testing DeleteVolumeGroup response", mockResponse.getVolumeGroupDeleted(),
- response.getVolumeGroupDeleted());
- }
-
- @Test(expected = VnfAdapterClientException.class)
- public void deleteVolumeGroupTestThrowException() throws VnfAdapterClientException {
- DeleteVolumeGroupRequest request = new DeleteVolumeGroupRequest();
- request.setCloudSiteId(TESTING_ID);
-
- DeleteVolumeGroupResponse mockResponse = new DeleteVolumeGroupResponse();
- mockResponse.setVolumeGroupDeleted(true);
-
- VnfVolumeAdapterClientImpl client = spy(VnfVolumeAdapterClientImpl.class);
- AdapterRestClient mockClient = mock(AdapterRestClient.class);
- doReturn(mockClient).when(client).getAdapterRestClient("/" + AAI_VOLUME_GROUP_ID);
- when(mockClient.delete(request, DeleteVolumeGroupResponse.class))
- .thenThrow(new InternalServerErrorException("Error in delete volume group"));
- MockitoAnnotations.initMocks(this);
-
- client.deleteVNFVolumes(AAI_VOLUME_GROUP_ID, request);
- }
-
- @Test
- public void rollbackVolumeGroupTest() throws VnfAdapterClientException {
- RollbackVolumeGroupRequest request = new RollbackVolumeGroupRequest();
-
- RollbackVolumeGroupResponse mockResponse = new RollbackVolumeGroupResponse();
- mockResponse.setVolumeGroupRolledBack(true);
-
- VnfVolumeAdapterClientImpl client = spy(VnfVolumeAdapterClientImpl.class);
- AdapterRestClient mockClient = mock(AdapterRestClient.class);
- doReturn(mockClient).when(client).getAdapterRestClient("/" + AAI_VOLUME_GROUP_ID + "/rollback");
- when(mockClient.delete(request, RollbackVolumeGroupResponse.class)).thenReturn(mockResponse);
- MockitoAnnotations.initMocks(this);
-
- RollbackVolumeGroupResponse response = client.rollbackVNFVolumes(AAI_VOLUME_GROUP_ID, request);
- assertEquals("Testing RollbackVolumeGroup response", mockResponse.getVolumeGroupRolledBack(),
- response.getVolumeGroupRolledBack());
- }
-
- @Test(expected = VnfAdapterClientException.class)
- public void rollbackVolumeGroupTestThrowException() throws VnfAdapterClientException {
- RollbackVolumeGroupRequest request = new RollbackVolumeGroupRequest();
-
- RollbackVolumeGroupResponse mockResponse = new RollbackVolumeGroupResponse();
- mockResponse.setVolumeGroupRolledBack(true);
-
- VnfVolumeAdapterClientImpl client = spy(VnfVolumeAdapterClientImpl.class);
- AdapterRestClient mockClient = mock(AdapterRestClient.class);
- doReturn(mockClient).when(client).getAdapterRestClient("/" + AAI_VOLUME_GROUP_ID + "/rollback");
- when(mockClient.delete(request, RollbackVolumeGroupResponse.class))
- .thenThrow(new InternalServerErrorException("Error in rollback volume group"));
- MockitoAnnotations.initMocks(this);
-
- client.rollbackVNFVolumes(AAI_VOLUME_GROUP_ID, request);
- }
-
- @Test
- public void updateVolumeGroupTest() throws VnfAdapterClientException {
- UpdateVolumeGroupRequest request = new UpdateVolumeGroupRequest();
-
- UpdateVolumeGroupResponse mockResponse = new UpdateVolumeGroupResponse();
- mockResponse.setVolumeGroupId(AAI_VOLUME_GROUP_ID);
-
- VnfVolumeAdapterClientImpl client = spy(VnfVolumeAdapterClientImpl.class);
- AdapterRestClient mockClient = mock(AdapterRestClient.class);
- doReturn(mockClient).when(client).getAdapterRestClient("/" + AAI_VOLUME_GROUP_ID);
- when(mockClient.put(request, UpdateVolumeGroupResponse.class)).thenReturn(mockResponse);
- MockitoAnnotations.initMocks(this);
-
- UpdateVolumeGroupResponse response = client.updateVNFVolumes(AAI_VOLUME_GROUP_ID, request);
- assertEquals("Testing DeleteVfModule response", mockResponse.getVolumeGroupId(), response.getVolumeGroupId());
- }
-
- @Test(expected = VnfAdapterClientException.class)
- public void updateVolumeGroupTestThrowException() throws VnfAdapterClientException {
- UpdateVolumeGroupRequest request = new UpdateVolumeGroupRequest();
-
- UpdateVolumeGroupResponse mockResponse = new UpdateVolumeGroupResponse();
- mockResponse.setVolumeGroupId(AAI_VOLUME_GROUP_ID);
-
- VnfVolumeAdapterClientImpl client = spy(VnfVolumeAdapterClientImpl.class);
- AdapterRestClient mockClient = mock(AdapterRestClient.class);
- doReturn(mockClient).when(client).getAdapterRestClient("/" + AAI_VOLUME_GROUP_ID);
- when(mockClient.put(request, UpdateVolumeGroupResponse.class))
- .thenThrow(new InternalServerErrorException("Error in update volume group"));
- MockitoAnnotations.initMocks(this);
-
- client.updateVNFVolumes(AAI_VOLUME_GROUP_ID, request);
- }
-
- public void buildQueryPathTest() {
- String expectedOutput = "/" + AAI_VOLUME_GROUP_ID + "?cloudSiteId=" + CLOUD_SITE_ID + "&tenantId=" + TENANT_ID
- + "&volumeGroupStackId=" + VOLUME_GROUP_STACK_ID + "&skipAAI=" + SKIP_AAI + "&msoRequest.requestId="
- + REQUEST_ID + "&msoRequest.serviceInstanceId=" + SERVICE_INSTANCE_ID;
- VnfVolumeAdapterClientImpl client = new VnfVolumeAdapterClientImpl();
- assertEquals("Test build query path", expectedOutput, client.buildQueryPath(AAI_VOLUME_GROUP_ID, CLOUD_SITE_ID,
- TENANT_ID, VOLUME_GROUP_STACK_ID, SKIP_AAI, REQUEST_ID, SERVICE_INSTANCE_ID));
- }
-
- protected UriBuilder getUri(String path) {
- return UriBuilder.fromPath(path);
- }
+public class VnfVolumeAdapterClientIT extends BaseIntegrationTest {
+
+ private static final String TESTING_ID = "___TESTING___";
+ private static final String AAI_VOLUME_GROUP_ID = "test";
+ private static final String CLOUD_SITE_ID = "test";
+ private static final String TENANT_ID = "test";
+ private static final String VOLUME_GROUP_STACK_ID = "test";
+ private static final boolean SKIP_AAI = true;
+ private static final String REQUEST_ID = "test";
+ private static final String SERVICE_INSTANCE_ID = "test";
+
+ @Test
+ public void createVolumeGroupTest() throws VnfAdapterClientException {
+ CreateVolumeGroupRequest request = new CreateVolumeGroupRequest();
+ request.setCloudSiteId(TESTING_ID);
+
+ CreateVolumeGroupResponse mockResponse = new CreateVolumeGroupResponse();
+ mockResponse.setVolumeGroupCreated(true);
+
+ VnfVolumeAdapterClientImpl client = spy(VnfVolumeAdapterClientImpl.class);
+ AdapterRestClient mockClient = mock(AdapterRestClient.class);
+
+ doReturn(mockClient).when(client).getAdapterRestClient("");
+ when(mockClient.post(request, CreateVolumeGroupResponse.class)).thenReturn(mockResponse);
+
+ CreateVolumeGroupResponse response = client.createVNFVolumes(request);
+ assertEquals("Testing CreateVolumeGroup response", mockResponse.getVolumeGroupCreated(),
+ response.getVolumeGroupCreated());
+ }
+
+ @Test(expected = VnfAdapterClientException.class)
+ public void createVolumeGroupTestThrowException() throws VnfAdapterClientException {
+ CreateVolumeGroupRequest request = new CreateVolumeGroupRequest();
+ request.setCloudSiteId(TESTING_ID);
+
+ CreateVolumeGroupResponse mockResponse = new CreateVolumeGroupResponse();
+ mockResponse.setVolumeGroupCreated(true);
+
+ VnfVolumeAdapterClientImpl client = spy(VnfVolumeAdapterClientImpl.class);
+ AdapterRestClient mockClient = mock(AdapterRestClient.class);
+
+ doReturn(mockClient).when(client).getAdapterRestClient("");
+ when(mockClient.post(request, CreateVolumeGroupResponse.class))
+ .thenThrow(new InternalServerErrorException("Error in create volume group"));
+
+ client.createVNFVolumes(request);
+ }
+
+ @Test
+ public void deleteVolumeGroupTest() throws VnfAdapterClientException {
+ DeleteVolumeGroupRequest request = new DeleteVolumeGroupRequest();
+ request.setCloudSiteId(TESTING_ID);
+
+ DeleteVolumeGroupResponse mockResponse = new DeleteVolumeGroupResponse();
+ mockResponse.setVolumeGroupDeleted(true);
+
+ VnfVolumeAdapterClientImpl client = spy(VnfVolumeAdapterClientImpl.class);
+ AdapterRestClient mockClient = mock(AdapterRestClient.class);
+ doReturn(mockClient).when(client).getAdapterRestClient("/" + AAI_VOLUME_GROUP_ID);
+ when(mockClient.delete(request, DeleteVolumeGroupResponse.class)).thenReturn(mockResponse);
+ MockitoAnnotations.initMocks(this);
+
+ DeleteVolumeGroupResponse response = client.deleteVNFVolumes(AAI_VOLUME_GROUP_ID, request);
+ assertEquals("Testing DeleteVolumeGroup response", mockResponse.getVolumeGroupDeleted(),
+ response.getVolumeGroupDeleted());
+ }
+
+ @Test(expected = VnfAdapterClientException.class)
+ public void deleteVolumeGroupTestThrowException() throws VnfAdapterClientException {
+ DeleteVolumeGroupRequest request = new DeleteVolumeGroupRequest();
+ request.setCloudSiteId(TESTING_ID);
+
+ DeleteVolumeGroupResponse mockResponse = new DeleteVolumeGroupResponse();
+ mockResponse.setVolumeGroupDeleted(true);
+
+ VnfVolumeAdapterClientImpl client = spy(VnfVolumeAdapterClientImpl.class);
+ AdapterRestClient mockClient = mock(AdapterRestClient.class);
+ doReturn(mockClient).when(client).getAdapterRestClient("/" + AAI_VOLUME_GROUP_ID);
+ when(mockClient.delete(request, DeleteVolumeGroupResponse.class))
+ .thenThrow(new InternalServerErrorException("Error in delete volume group"));
+ MockitoAnnotations.initMocks(this);
+
+ client.deleteVNFVolumes(AAI_VOLUME_GROUP_ID, request);
+ }
+
+ @Test
+ public void rollbackVolumeGroupTest() throws VnfAdapterClientException {
+ RollbackVolumeGroupRequest request = new RollbackVolumeGroupRequest();
+
+ RollbackVolumeGroupResponse mockResponse = new RollbackVolumeGroupResponse();
+ mockResponse.setVolumeGroupRolledBack(true);
+
+ VnfVolumeAdapterClientImpl client = spy(VnfVolumeAdapterClientImpl.class);
+ AdapterRestClient mockClient = mock(AdapterRestClient.class);
+ doReturn(mockClient).when(client).getAdapterRestClient("/" + AAI_VOLUME_GROUP_ID + "/rollback");
+ when(mockClient.delete(request, RollbackVolumeGroupResponse.class)).thenReturn(mockResponse);
+ MockitoAnnotations.initMocks(this);
+
+ RollbackVolumeGroupResponse response = client.rollbackVNFVolumes(AAI_VOLUME_GROUP_ID, request);
+ assertEquals("Testing RollbackVolumeGroup response", mockResponse.getVolumeGroupRolledBack(),
+ response.getVolumeGroupRolledBack());
+ }
+
+ @Test(expected = VnfAdapterClientException.class)
+ public void rollbackVolumeGroupTestThrowException() throws VnfAdapterClientException {
+ RollbackVolumeGroupRequest request = new RollbackVolumeGroupRequest();
+
+ RollbackVolumeGroupResponse mockResponse = new RollbackVolumeGroupResponse();
+ mockResponse.setVolumeGroupRolledBack(true);
+
+ VnfVolumeAdapterClientImpl client = spy(VnfVolumeAdapterClientImpl.class);
+ AdapterRestClient mockClient = mock(AdapterRestClient.class);
+ doReturn(mockClient).when(client).getAdapterRestClient("/" + AAI_VOLUME_GROUP_ID + "/rollback");
+ when(mockClient.delete(request, RollbackVolumeGroupResponse.class))
+ .thenThrow(new InternalServerErrorException("Error in rollback volume group"));
+ MockitoAnnotations.initMocks(this);
+
+ client.rollbackVNFVolumes(AAI_VOLUME_GROUP_ID, request);
+ }
+
+ @Test
+ public void updateVolumeGroupTest() throws VnfAdapterClientException {
+ UpdateVolumeGroupRequest request = new UpdateVolumeGroupRequest();
+
+ UpdateVolumeGroupResponse mockResponse = new UpdateVolumeGroupResponse();
+ mockResponse.setVolumeGroupId(AAI_VOLUME_GROUP_ID);
+
+ VnfVolumeAdapterClientImpl client = spy(VnfVolumeAdapterClientImpl.class);
+ AdapterRestClient mockClient = mock(AdapterRestClient.class);
+ doReturn(mockClient).when(client).getAdapterRestClient("/" + AAI_VOLUME_GROUP_ID);
+ when(mockClient.put(request, UpdateVolumeGroupResponse.class)).thenReturn(mockResponse);
+ MockitoAnnotations.initMocks(this);
+
+ UpdateVolumeGroupResponse response = client.updateVNFVolumes(AAI_VOLUME_GROUP_ID, request);
+ assertEquals("Testing DeleteVfModule response", mockResponse.getVolumeGroupId(), response.getVolumeGroupId());
+ }
+
+ @Test(expected = VnfAdapterClientException.class)
+ public void updateVolumeGroupTestThrowException() throws VnfAdapterClientException {
+ UpdateVolumeGroupRequest request = new UpdateVolumeGroupRequest();
+
+ UpdateVolumeGroupResponse mockResponse = new UpdateVolumeGroupResponse();
+ mockResponse.setVolumeGroupId(AAI_VOLUME_GROUP_ID);
+
+ VnfVolumeAdapterClientImpl client = spy(VnfVolumeAdapterClientImpl.class);
+ AdapterRestClient mockClient = mock(AdapterRestClient.class);
+ doReturn(mockClient).when(client).getAdapterRestClient("/" + AAI_VOLUME_GROUP_ID);
+ when(mockClient.put(request, UpdateVolumeGroupResponse.class))
+ .thenThrow(new InternalServerErrorException("Error in update volume group"));
+ MockitoAnnotations.initMocks(this);
+
+ client.updateVNFVolumes(AAI_VOLUME_GROUP_ID, request);
+ }
+
+ public void buildQueryPathTest() {
+ String expectedOutput = "/" + AAI_VOLUME_GROUP_ID + "?cloudSiteId=" + CLOUD_SITE_ID + "&tenantId=" + TENANT_ID
+ + "&volumeGroupStackId=" + VOLUME_GROUP_STACK_ID + "&skipAAI=" + SKIP_AAI + "&msoRequest.requestId="
+ + REQUEST_ID + "&msoRequest.serviceInstanceId=" + SERVICE_INSTANCE_ID;
+ VnfVolumeAdapterClientImpl client = new VnfVolumeAdapterClientImpl();
+ assertEquals("Test build query path", expectedOutput, client.buildQueryPath(AAI_VOLUME_GROUP_ID, CLOUD_SITE_ID,
+ TENANT_ID, VOLUME_GROUP_STACK_ID, SKIP_AAI, REQUEST_ID, SERVICE_INSTANCE_ID));
+ }
+
+ protected UriBuilder getUri(String path) {
+ return UriBuilder.fromPath(path);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterRestPropertiesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterRestPropertiesTest.java
index df48596893..63c73322a5 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterRestPropertiesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterRestPropertiesTest.java
@@ -21,26 +21,24 @@
package org.onap.so.client.adapter.vnf;
import static org.junit.Assert.assertEquals;
-
import java.net.MalformedURLException;
-
import org.junit.Test;
-public class VnfVolumeAdapterRestPropertiesTest{
- private VnfVolumeAdapterRestProperties props = new VnfVolumeAdapterRestProperties();
-
- @Test
- public void testGetAuth(){
- assertEquals("mso.adapters.po.auth", VnfVolumeAdapterRestProperties.authProp);
- }
-
- @Test
- public void testGetKey(){
- assertEquals("mso.msoKey", VnfVolumeAdapterRestProperties.keyProp);
- }
-
- @Test
- public void testGetUrl() throws MalformedURLException{
- assertEquals("mso.adapters.volume-groups.rest.endpoint", VnfVolumeAdapterRestProperties.endpointProp);
- }
+public class VnfVolumeAdapterRestPropertiesTest {
+ private VnfVolumeAdapterRestProperties props = new VnfVolumeAdapterRestProperties();
+
+ @Test
+ public void testGetAuth() {
+ assertEquals("mso.adapters.po.auth", VnfVolumeAdapterRestProperties.authProp);
+ }
+
+ @Test
+ public void testGetKey() {
+ assertEquals("mso.msoKey", VnfVolumeAdapterRestProperties.keyProp);
+ }
+
+ @Test
+ public void testGetUrl() throws MalformedURLException {
+ assertEquals("mso.adapters.volume-groups.rest.endpoint", VnfVolumeAdapterRestProperties.endpointProp);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapperTest.java
index 5169663add..4450e4a9f4 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapperTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapperTest.java
@@ -26,14 +26,12 @@ import static org.junit.Assert.assertThat;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.reset;
-
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
@@ -55,282 +53,294 @@ import org.onap.so.db.catalog.beans.OrchestrationStatus;
import org.onap.so.entity.MsoRequest;
public class VnfAdapterObjectMapperTest {
- private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/";
-
- @Spy
- private VnfAdapterObjectMapper vnfAdapterObjectMapper = new VnfAdapterObjectMapper();
-
- @Before
- public void before() {
- MockitoAnnotations.initMocks(this);
-
- }
-
- @After
- public void after() {
- reset(vnfAdapterObjectMapper);
- }
-
- @Test
- public void test_createVolumeGroupRequestMapper() throws Exception {
- RequestContext requestContext = new RequestContext();
- requestContext.setMsoRequestId("msoRequestId");
-
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
-
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setModelVersion("modelVersion");
- serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
-
- GenericVnf genericVnf = new GenericVnf();
- genericVnf.setVnfId("vnfId");
- genericVnf.setVnfName("vnfName");
- genericVnf.setVnfType("vnfType");
- serviceInstance.getVnfs().add(genericVnf);
-
- ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
- modelInfoVfModule.setModelName("modelName");
- modelInfoVfModule.setModelCustomizationUUID("modelCustomizationUUID");
-
- VolumeGroup volumeGroup = new VolumeGroup();
- volumeGroup.setVolumeGroupId("volumeGroupId");
- volumeGroup.setVolumeGroupName("volumeGroupName");
- volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
- volumeGroup.setModelInfoVfModule(modelInfoVfModule);
-
- serviceInstance.getVnfs().get(0).getVolumeGroups().add(volumeGroup);
-
-
- CloudRegion cloudRegion = new CloudRegion();
- cloudRegion.setLcpCloudRegionId("lcpCloudRegionId");
- cloudRegion.setTenantId("tenantId");
-
- OrchestrationContext orchestrationContext = new OrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(true);
-
- String sdncVfModuleQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
-
- CreateVolumeGroupRequest expectedCreateVolumeGroupRequest = new CreateVolumeGroupRequest();
-
- expectedCreateVolumeGroupRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
- expectedCreateVolumeGroupRequest.setTenantId(cloudRegion.getTenantId());
- expectedCreateVolumeGroupRequest.setVolumeGroupId(volumeGroup.getVolumeGroupId());
- expectedCreateVolumeGroupRequest.setVolumeGroupName(volumeGroup.getVolumeGroupName());
- expectedCreateVolumeGroupRequest.setVnfType(genericVnf.getVnfType());
- expectedCreateVolumeGroupRequest.setVnfVersion(serviceInstance.getModelInfoServiceInstance().getModelVersion());
- expectedCreateVolumeGroupRequest.setVfModuleType(volumeGroup.getModelInfoVfModule().getModelName());
- expectedCreateVolumeGroupRequest.setModelCustomizationUuid(volumeGroup.getModelInfoVfModule().getModelCustomizationUUID());
-
- Map<String, Object> volumeGroupParams = new HashMap<>();
- volumeGroupParams.put("vnf_id", genericVnf.getVnfId());
- volumeGroupParams.put("vnf_name", genericVnf.getVnfName());
- volumeGroupParams.put("vf_module_id", volumeGroup.getVolumeGroupId());
- volumeGroupParams.put("vf_module_name", volumeGroup.getVolumeGroupName());
- volumeGroupParams.put("paramOne", "paramOneValue");
- volumeGroupParams.put("paramTwo", "paramTwoValue");
- volumeGroupParams.put("paramThree", "paramThreeValue");
- expectedCreateVolumeGroupRequest.setVolumeGroupParams(volumeGroupParams);
-
- expectedCreateVolumeGroupRequest.setSkipAAI(true);
- expectedCreateVolumeGroupRequest.setSuppressBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled()));
- expectedCreateVolumeGroupRequest.setFailIfExists(true);
-
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId(requestContext.getMsoRequestId());
- msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
- expectedCreateVolumeGroupRequest.setMsoRequest(msoRequest);
-
- expectedCreateVolumeGroupRequest.setMessageId("messageId");
- expectedCreateVolumeGroupRequest.setNotificationUrl("endpoint/VNFAResponse/messageId");
-
- doReturn("endpoint/").when(vnfAdapterObjectMapper).getProperty(isA(String.class));
- doReturn("messageId").when(vnfAdapterObjectMapper).getRandomUuid();
-
- CreateVolumeGroupRequest actualCreateVolumeGroupRequest = vnfAdapterObjectMapper.createVolumeGroupRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, volumeGroup, sdncVfModuleQueryResponse);
-
- assertThat(actualCreateVolumeGroupRequest, sameBeanAs(expectedCreateVolumeGroupRequest));
- }
-
- @Test
- public void test_createVolumeGroupRequestMapper_for_alaCarte_flow() throws Exception {
- RequestContext requestContext = new RequestContext();
- requestContext.setMsoRequestId("msoRequestId");
-
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
-
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setModelVersion("modelVersion");
- serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
-
- GenericVnf genericVnf = new GenericVnf();
- genericVnf.setVnfId("vnfId");
- genericVnf.setVnfName("vnfName");
- genericVnf.setVnfType("vnfType");
- serviceInstance.getVnfs().add(genericVnf);
-
-
- ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
- modelInfoVfModule.setModelName("modelName");
- modelInfoVfModule.setModelCustomizationUUID("modelCustomizationUUID");
-
- VolumeGroup volumeGroup = new VolumeGroup();
- volumeGroup.setVolumeGroupId("volumeGroupId");
- volumeGroup.setVolumeGroupName("volumeGroupName");
- volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
- volumeGroup.setModelInfoVfModule(modelInfoVfModule);
- serviceInstance.getVnfs().get(0).getVolumeGroups().add(volumeGroup);
-
- CloudRegion cloudRegion = new CloudRegion();
- cloudRegion.setLcpCloudRegionId("lcpCloudRegionId");
- cloudRegion.setTenantId("tenantId");
-
- OrchestrationContext orchestrationContext = new OrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(true);
-
- CreateVolumeGroupRequest expectedCreateVolumeGroupRequest = new CreateVolumeGroupRequest();
-
- expectedCreateVolumeGroupRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
- expectedCreateVolumeGroupRequest.setTenantId(cloudRegion.getTenantId());
- expectedCreateVolumeGroupRequest.setVolumeGroupId(volumeGroup.getVolumeGroupId());
- expectedCreateVolumeGroupRequest.setVolumeGroupName(volumeGroup.getVolumeGroupName());
- expectedCreateVolumeGroupRequest.setVnfType(genericVnf.getVnfType());
- expectedCreateVolumeGroupRequest.setVnfVersion(serviceInstance.getModelInfoServiceInstance().getModelVersion());
- expectedCreateVolumeGroupRequest.setVfModuleType(volumeGroup.getModelInfoVfModule().getModelName());
- expectedCreateVolumeGroupRequest.setModelCustomizationUuid(volumeGroup.getModelInfoVfModule().getModelCustomizationUUID());
-
- Map<String, Object> volumeGroupParams = new HashMap<>();
- volumeGroupParams.put("vnf_id", genericVnf.getVnfId());
- volumeGroupParams.put("vnf_name", genericVnf.getVnfName());
- volumeGroupParams.put("vf_module_id", volumeGroup.getVolumeGroupId());
- volumeGroupParams.put("vf_module_name", volumeGroup.getVolumeGroupName());
-
- expectedCreateVolumeGroupRequest.setVolumeGroupParams(volumeGroupParams);
-
- expectedCreateVolumeGroupRequest.setSkipAAI(true);
- expectedCreateVolumeGroupRequest.setSuppressBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled()));
- expectedCreateVolumeGroupRequest.setFailIfExists(true);
-
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId(requestContext.getMsoRequestId());
- msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
- expectedCreateVolumeGroupRequest.setMsoRequest(msoRequest);
-
- expectedCreateVolumeGroupRequest.setMessageId("messageId");
- expectedCreateVolumeGroupRequest.setNotificationUrl("endpoint/VNFAResponse/messageId");
-
- doReturn("endpoint/").when(vnfAdapterObjectMapper).getProperty(isA(String.class));
- doReturn("messageId").when(vnfAdapterObjectMapper).getRandomUuid();
-
- CreateVolumeGroupRequest actualCreateVolumeGroupRequest = vnfAdapterObjectMapper.createVolumeGroupRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, volumeGroup, null);
-
- assertThat(actualCreateVolumeGroupRequest, sameBeanAs(expectedCreateVolumeGroupRequest));
- }
-
- @Test
- public void test_deleteVolumeGroupHeatIdRequestMapper() throws Exception{
- this.test_deleteVolumeGroupRequestMapper("heatStackId");
- }
-
- @Test
- public void test_deleteVolumeGroupNoHeatIdRequestMapper() throws Exception{
- this.test_deleteVolumeGroupRequestMapper(null);
- }
-
- private void test_deleteVolumeGroupRequestMapper(String heatStackId) throws Exception {
- DeleteVolumeGroupRequest expectedDeleteVolumeGroupRequest = new DeleteVolumeGroupRequest();
-
- CloudRegion cloudRegion = new CloudRegion();
- cloudRegion.setLcpCloudRegionId("lcpCloudRegionId");
- expectedDeleteVolumeGroupRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
-
- cloudRegion.setTenantId("tenantId");
- expectedDeleteVolumeGroupRequest.setTenantId(cloudRegion.getTenantId());
-
- VolumeGroup volumeGroup = new VolumeGroup();
- volumeGroup.setVolumeGroupId("volumeGroupId");
- expectedDeleteVolumeGroupRequest.setVolumeGroupId(volumeGroup.getVolumeGroupId());
-
- if (heatStackId != null){
- volumeGroup.setHeatStackId("heatStackId");
- expectedDeleteVolumeGroupRequest.setVolumeGroupStackId(volumeGroup.getHeatStackId());
- } else {
- volumeGroup.setVolumeGroupName("volumeGroupName");
- expectedDeleteVolumeGroupRequest.setVolumeGroupStackId(volumeGroup.getVolumeGroupName());
- }
-
- expectedDeleteVolumeGroupRequest.setSkipAAI(true);
-
- MsoRequest msoRequest = new MsoRequest();
- RequestContext requestContext = new RequestContext();
- requestContext.setMsoRequestId("msoRequestId");
- msoRequest.setRequestId(requestContext.getMsoRequestId());
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
- expectedDeleteVolumeGroupRequest.setMsoRequest(msoRequest);
-
- String messageId = "messageId";
- String endpoint = "endpoint";
- doReturn(messageId).when(vnfAdapterObjectMapper).getRandomUuid();
- doReturn(endpoint).when(vnfAdapterObjectMapper).getProperty(isA(String.class));
- expectedDeleteVolumeGroupRequest.setMessageId(messageId);
- expectedDeleteVolumeGroupRequest.setNotificationUrl(endpoint + "/VNFAResponse/" + messageId);
-
- DeleteVolumeGroupRequest actualDeleteVolumeGroupRequest = vnfAdapterObjectMapper.deleteVolumeGroupRequestMapper(requestContext, cloudRegion, serviceInstance, volumeGroup);
-
- assertThat(actualDeleteVolumeGroupRequest, sameBeanAs(expectedDeleteVolumeGroupRequest));
- }
-
- @Test
- public void test_createVolumeGroupParams() throws Exception {
- GenericVnf genericVnf = new GenericVnf();
- genericVnf.setVnfId("vnfId");
- genericVnf.setVnfName("vnfName");
-
- RequestContext requestContext = new RequestContext();
-
- VolumeGroup volumeGroup = new VolumeGroup();
- volumeGroup.setVolumeGroupId("volumeGroupId");
- volumeGroup.setVolumeGroupName("volumeGroupName");
-
- String sdncVfModuleQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
-
- Map<String, String> expectedVolumeGroupParams = new HashMap<>();
- expectedVolumeGroupParams.put("vnf_id", genericVnf.getVnfId());
- expectedVolumeGroupParams.put("vnf_name", genericVnf.getVnfName());
- expectedVolumeGroupParams.put("vf_module_id", volumeGroup.getVolumeGroupId());
- expectedVolumeGroupParams.put("vf_module_name", volumeGroup.getVolumeGroupName());
- expectedVolumeGroupParams.put("paramOne", "paramOneValue");
- expectedVolumeGroupParams.put("paramTwo", "paramTwoValue");
- expectedVolumeGroupParams.put("paramThree", "paramThreeValue");
-
- Map<String, Object> actualVolumeGroupParams = vnfAdapterObjectMapper.createVolumeGroupParams(requestContext,genericVnf, volumeGroup, sdncVfModuleQueryResponse);
-
- assertEquals(expectedVolumeGroupParams, actualVolumeGroupParams);
- }
-
- @Test
- public void test_createVolumeGroupParams_without_sdncResponse() throws Exception {
- GenericVnf genericVnf = new GenericVnf();
- genericVnf.setVnfId("vnfId");
- genericVnf.setVnfName("vnfName");
-
- VolumeGroup volumeGroup = new VolumeGroup();
- volumeGroup.setVolumeGroupId("volumeGroupId");
- volumeGroup.setVolumeGroupName("volumeGroupName");
-
- Map<String, String> expectedVolumeGroupParams = new HashMap<>();
- expectedVolumeGroupParams.put("vnf_id", genericVnf.getVnfId());
- expectedVolumeGroupParams.put("vnf_name", genericVnf.getVnfName());
- expectedVolumeGroupParams.put("vf_module_id", volumeGroup.getVolumeGroupId());
- expectedVolumeGroupParams.put("vf_module_name", volumeGroup.getVolumeGroupName());
- RequestContext requestContext = new RequestContext();
- Map<String, Object> actualVolumeGroupParams = vnfAdapterObjectMapper.createVolumeGroupParams(requestContext,genericVnf, volumeGroup, null);
-
- assertEquals(expectedVolumeGroupParams, actualVolumeGroupParams);
- }
+ private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/";
+
+ @Spy
+ private VnfAdapterObjectMapper vnfAdapterObjectMapper = new VnfAdapterObjectMapper();
+
+ @Before
+ public void before() {
+ MockitoAnnotations.initMocks(this);
+
+ }
+
+ @After
+ public void after() {
+ reset(vnfAdapterObjectMapper);
+ }
+
+ @Test
+ public void test_createVolumeGroupRequestMapper() throws Exception {
+ RequestContext requestContext = new RequestContext();
+ requestContext.setMsoRequestId("msoRequestId");
+
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelVersion("modelVersion");
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+
+ GenericVnf genericVnf = new GenericVnf();
+ genericVnf.setVnfId("vnfId");
+ genericVnf.setVnfName("vnfName");
+ genericVnf.setVnfType("vnfType");
+ serviceInstance.getVnfs().add(genericVnf);
+
+ ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
+ modelInfoVfModule.setModelName("modelName");
+ modelInfoVfModule.setModelCustomizationUUID("modelCustomizationUUID");
+
+ VolumeGroup volumeGroup = new VolumeGroup();
+ volumeGroup.setVolumeGroupId("volumeGroupId");
+ volumeGroup.setVolumeGroupName("volumeGroupName");
+ volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
+ volumeGroup.setModelInfoVfModule(modelInfoVfModule);
+
+ serviceInstance.getVnfs().get(0).getVolumeGroups().add(volumeGroup);
+
+
+ CloudRegion cloudRegion = new CloudRegion();
+ cloudRegion.setLcpCloudRegionId("lcpCloudRegionId");
+ cloudRegion.setTenantId("tenantId");
+
+ OrchestrationContext orchestrationContext = new OrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(true);
+
+ String sdncVfModuleQueryResponse = new String(Files
+ .readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
+
+ CreateVolumeGroupRequest expectedCreateVolumeGroupRequest = new CreateVolumeGroupRequest();
+
+ expectedCreateVolumeGroupRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
+ expectedCreateVolumeGroupRequest.setTenantId(cloudRegion.getTenantId());
+ expectedCreateVolumeGroupRequest.setVolumeGroupId(volumeGroup.getVolumeGroupId());
+ expectedCreateVolumeGroupRequest.setVolumeGroupName(volumeGroup.getVolumeGroupName());
+ expectedCreateVolumeGroupRequest.setVnfType(genericVnf.getVnfType());
+ expectedCreateVolumeGroupRequest.setVnfVersion(serviceInstance.getModelInfoServiceInstance().getModelVersion());
+ expectedCreateVolumeGroupRequest.setVfModuleType(volumeGroup.getModelInfoVfModule().getModelName());
+ expectedCreateVolumeGroupRequest
+ .setModelCustomizationUuid(volumeGroup.getModelInfoVfModule().getModelCustomizationUUID());
+
+ Map<String, Object> volumeGroupParams = new HashMap<>();
+ volumeGroupParams.put("vnf_id", genericVnf.getVnfId());
+ volumeGroupParams.put("vnf_name", genericVnf.getVnfName());
+ volumeGroupParams.put("vf_module_id", volumeGroup.getVolumeGroupId());
+ volumeGroupParams.put("vf_module_name", volumeGroup.getVolumeGroupName());
+ volumeGroupParams.put("paramOne", "paramOneValue");
+ volumeGroupParams.put("paramTwo", "paramTwoValue");
+ volumeGroupParams.put("paramThree", "paramThreeValue");
+ expectedCreateVolumeGroupRequest.setVolumeGroupParams(volumeGroupParams);
+
+ expectedCreateVolumeGroupRequest.setSkipAAI(true);
+ expectedCreateVolumeGroupRequest
+ .setSuppressBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled()));
+ expectedCreateVolumeGroupRequest.setFailIfExists(true);
+
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId(requestContext.getMsoRequestId());
+ msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
+ expectedCreateVolumeGroupRequest.setMsoRequest(msoRequest);
+
+ expectedCreateVolumeGroupRequest.setMessageId("messageId");
+ expectedCreateVolumeGroupRequest.setNotificationUrl("endpoint/VNFAResponse/messageId");
+
+ doReturn("endpoint/").when(vnfAdapterObjectMapper).getProperty(isA(String.class));
+ doReturn("messageId").when(vnfAdapterObjectMapper).getRandomUuid();
+
+ CreateVolumeGroupRequest actualCreateVolumeGroupRequest =
+ vnfAdapterObjectMapper.createVolumeGroupRequestMapper(requestContext, cloudRegion, orchestrationContext,
+ serviceInstance, genericVnf, volumeGroup, sdncVfModuleQueryResponse);
+
+ assertThat(actualCreateVolumeGroupRequest, sameBeanAs(expectedCreateVolumeGroupRequest));
+ }
+
+ @Test
+ public void test_createVolumeGroupRequestMapper_for_alaCarte_flow() throws Exception {
+ RequestContext requestContext = new RequestContext();
+ requestContext.setMsoRequestId("msoRequestId");
+
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelVersion("modelVersion");
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+
+ GenericVnf genericVnf = new GenericVnf();
+ genericVnf.setVnfId("vnfId");
+ genericVnf.setVnfName("vnfName");
+ genericVnf.setVnfType("vnfType");
+ serviceInstance.getVnfs().add(genericVnf);
+
+
+ ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
+ modelInfoVfModule.setModelName("modelName");
+ modelInfoVfModule.setModelCustomizationUUID("modelCustomizationUUID");
+
+ VolumeGroup volumeGroup = new VolumeGroup();
+ volumeGroup.setVolumeGroupId("volumeGroupId");
+ volumeGroup.setVolumeGroupName("volumeGroupName");
+ volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
+ volumeGroup.setModelInfoVfModule(modelInfoVfModule);
+ serviceInstance.getVnfs().get(0).getVolumeGroups().add(volumeGroup);
+
+ CloudRegion cloudRegion = new CloudRegion();
+ cloudRegion.setLcpCloudRegionId("lcpCloudRegionId");
+ cloudRegion.setTenantId("tenantId");
+
+ OrchestrationContext orchestrationContext = new OrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(true);
+
+ CreateVolumeGroupRequest expectedCreateVolumeGroupRequest = new CreateVolumeGroupRequest();
+
+ expectedCreateVolumeGroupRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
+ expectedCreateVolumeGroupRequest.setTenantId(cloudRegion.getTenantId());
+ expectedCreateVolumeGroupRequest.setVolumeGroupId(volumeGroup.getVolumeGroupId());
+ expectedCreateVolumeGroupRequest.setVolumeGroupName(volumeGroup.getVolumeGroupName());
+ expectedCreateVolumeGroupRequest.setVnfType(genericVnf.getVnfType());
+ expectedCreateVolumeGroupRequest.setVnfVersion(serviceInstance.getModelInfoServiceInstance().getModelVersion());
+ expectedCreateVolumeGroupRequest.setVfModuleType(volumeGroup.getModelInfoVfModule().getModelName());
+ expectedCreateVolumeGroupRequest
+ .setModelCustomizationUuid(volumeGroup.getModelInfoVfModule().getModelCustomizationUUID());
+
+ Map<String, Object> volumeGroupParams = new HashMap<>();
+ volumeGroupParams.put("vnf_id", genericVnf.getVnfId());
+ volumeGroupParams.put("vnf_name", genericVnf.getVnfName());
+ volumeGroupParams.put("vf_module_id", volumeGroup.getVolumeGroupId());
+ volumeGroupParams.put("vf_module_name", volumeGroup.getVolumeGroupName());
+
+ expectedCreateVolumeGroupRequest.setVolumeGroupParams(volumeGroupParams);
+
+ expectedCreateVolumeGroupRequest.setSkipAAI(true);
+ expectedCreateVolumeGroupRequest
+ .setSuppressBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled()));
+ expectedCreateVolumeGroupRequest.setFailIfExists(true);
+
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId(requestContext.getMsoRequestId());
+ msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
+ expectedCreateVolumeGroupRequest.setMsoRequest(msoRequest);
+
+ expectedCreateVolumeGroupRequest.setMessageId("messageId");
+ expectedCreateVolumeGroupRequest.setNotificationUrl("endpoint/VNFAResponse/messageId");
+
+ doReturn("endpoint/").when(vnfAdapterObjectMapper).getProperty(isA(String.class));
+ doReturn("messageId").when(vnfAdapterObjectMapper).getRandomUuid();
+
+ CreateVolumeGroupRequest actualCreateVolumeGroupRequest = vnfAdapterObjectMapper.createVolumeGroupRequestMapper(
+ requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, volumeGroup, null);
+
+ assertThat(actualCreateVolumeGroupRequest, sameBeanAs(expectedCreateVolumeGroupRequest));
+ }
+
+ @Test
+ public void test_deleteVolumeGroupHeatIdRequestMapper() throws Exception {
+ this.test_deleteVolumeGroupRequestMapper("heatStackId");
+ }
+
+ @Test
+ public void test_deleteVolumeGroupNoHeatIdRequestMapper() throws Exception {
+ this.test_deleteVolumeGroupRequestMapper(null);
+ }
+
+ private void test_deleteVolumeGroupRequestMapper(String heatStackId) throws Exception {
+ DeleteVolumeGroupRequest expectedDeleteVolumeGroupRequest = new DeleteVolumeGroupRequest();
+
+ CloudRegion cloudRegion = new CloudRegion();
+ cloudRegion.setLcpCloudRegionId("lcpCloudRegionId");
+ expectedDeleteVolumeGroupRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
+
+ cloudRegion.setTenantId("tenantId");
+ expectedDeleteVolumeGroupRequest.setTenantId(cloudRegion.getTenantId());
+
+ VolumeGroup volumeGroup = new VolumeGroup();
+ volumeGroup.setVolumeGroupId("volumeGroupId");
+ expectedDeleteVolumeGroupRequest.setVolumeGroupId(volumeGroup.getVolumeGroupId());
+
+ if (heatStackId != null) {
+ volumeGroup.setHeatStackId("heatStackId");
+ expectedDeleteVolumeGroupRequest.setVolumeGroupStackId(volumeGroup.getHeatStackId());
+ } else {
+ volumeGroup.setVolumeGroupName("volumeGroupName");
+ expectedDeleteVolumeGroupRequest.setVolumeGroupStackId(volumeGroup.getVolumeGroupName());
+ }
+
+ expectedDeleteVolumeGroupRequest.setSkipAAI(true);
+
+ MsoRequest msoRequest = new MsoRequest();
+ RequestContext requestContext = new RequestContext();
+ requestContext.setMsoRequestId("msoRequestId");
+ msoRequest.setRequestId(requestContext.getMsoRequestId());
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
+ expectedDeleteVolumeGroupRequest.setMsoRequest(msoRequest);
+
+ String messageId = "messageId";
+ String endpoint = "endpoint";
+ doReturn(messageId).when(vnfAdapterObjectMapper).getRandomUuid();
+ doReturn(endpoint).when(vnfAdapterObjectMapper).getProperty(isA(String.class));
+ expectedDeleteVolumeGroupRequest.setMessageId(messageId);
+ expectedDeleteVolumeGroupRequest.setNotificationUrl(endpoint + "/VNFAResponse/" + messageId);
+
+ DeleteVolumeGroupRequest actualDeleteVolumeGroupRequest = vnfAdapterObjectMapper
+ .deleteVolumeGroupRequestMapper(requestContext, cloudRegion, serviceInstance, volumeGroup);
+
+ assertThat(actualDeleteVolumeGroupRequest, sameBeanAs(expectedDeleteVolumeGroupRequest));
+ }
+
+ @Test
+ public void test_createVolumeGroupParams() throws Exception {
+ GenericVnf genericVnf = new GenericVnf();
+ genericVnf.setVnfId("vnfId");
+ genericVnf.setVnfName("vnfName");
+
+ RequestContext requestContext = new RequestContext();
+
+ VolumeGroup volumeGroup = new VolumeGroup();
+ volumeGroup.setVolumeGroupId("volumeGroupId");
+ volumeGroup.setVolumeGroupName("volumeGroupName");
+
+ String sdncVfModuleQueryResponse = new String(Files
+ .readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
+
+ Map<String, String> expectedVolumeGroupParams = new HashMap<>();
+ expectedVolumeGroupParams.put("vnf_id", genericVnf.getVnfId());
+ expectedVolumeGroupParams.put("vnf_name", genericVnf.getVnfName());
+ expectedVolumeGroupParams.put("vf_module_id", volumeGroup.getVolumeGroupId());
+ expectedVolumeGroupParams.put("vf_module_name", volumeGroup.getVolumeGroupName());
+ expectedVolumeGroupParams.put("paramOne", "paramOneValue");
+ expectedVolumeGroupParams.put("paramTwo", "paramTwoValue");
+ expectedVolumeGroupParams.put("paramThree", "paramThreeValue");
+
+ Map<String, Object> actualVolumeGroupParams = vnfAdapterObjectMapper.createVolumeGroupParams(requestContext,
+ genericVnf, volumeGroup, sdncVfModuleQueryResponse);
+
+ assertEquals(expectedVolumeGroupParams, actualVolumeGroupParams);
+ }
+
+ @Test
+ public void test_createVolumeGroupParams_without_sdncResponse() throws Exception {
+ GenericVnf genericVnf = new GenericVnf();
+ genericVnf.setVnfId("vnfId");
+ genericVnf.setVnfName("vnfName");
+
+ VolumeGroup volumeGroup = new VolumeGroup();
+ volumeGroup.setVolumeGroupId("volumeGroupId");
+ volumeGroup.setVolumeGroupName("volumeGroupName");
+
+ Map<String, String> expectedVolumeGroupParams = new HashMap<>();
+ expectedVolumeGroupParams.put("vnf_id", genericVnf.getVnfId());
+ expectedVolumeGroupParams.put("vnf_name", genericVnf.getVnfName());
+ expectedVolumeGroupParams.put("vf_module_id", volumeGroup.getVolumeGroupId());
+ expectedVolumeGroupParams.put("vf_module_name", volumeGroup.getVolumeGroupName());
+ RequestContext requestContext = new RequestContext();
+ Map<String, Object> actualVolumeGroupParams =
+ vnfAdapterObjectMapper.createVolumeGroupParams(requestContext, genericVnf, volumeGroup, null);
+
+ assertEquals(expectedVolumeGroupParams, actualVolumeGroupParams);
+ }
@Test
public void test_createVolumeGroupParams_with_user_params() throws Exception {
@@ -351,7 +361,8 @@ public class VnfAdapterObjectMapperTest {
volumeGroup.setVolumeGroupId("volumeGroupId");
volumeGroup.setVolumeGroupName("volumeGroupName");
- String sdncVfModuleQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
+ String sdncVfModuleQueryResponse = new String(Files
+ .readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
Map<String, String> expectedVolumeGroupParams = new HashMap<>();
expectedVolumeGroupParams.put("vnf_id", genericVnf.getVnfId());
@@ -363,25 +374,26 @@ public class VnfAdapterObjectMapperTest {
expectedVolumeGroupParams.put("paramThree", "paramThreeValue");
expectedVolumeGroupParams.put("userParamKey", "userParamValue");
- Map<String, Object> actualVolumeGroupParams = vnfAdapterObjectMapper.createVolumeGroupParams(requestContext,genericVnf, volumeGroup, sdncVfModuleQueryResponse);
+ Map<String, Object> actualVolumeGroupParams = vnfAdapterObjectMapper.createVolumeGroupParams(requestContext,
+ genericVnf, volumeGroup, sdncVfModuleQueryResponse);
assertEquals(expectedVolumeGroupParams, actualVolumeGroupParams);
}
- @Test
- public void test_createMsoRequest() {
- RequestContext requestContext = new RequestContext();
- requestContext.setMsoRequestId("msoRequestId");
-
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
-
- MsoRequest expectedMsoRequest = new MsoRequest();
- expectedMsoRequest.setRequestId(requestContext.getMsoRequestId());
- expectedMsoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
-
- MsoRequest actualMsoRequest = vnfAdapterObjectMapper.createMsoRequest(requestContext, serviceInstance);
-
- assertThat(expectedMsoRequest, sameBeanAs(actualMsoRequest));
- }
+ @Test
+ public void test_createMsoRequest() {
+ RequestContext requestContext = new RequestContext();
+ requestContext.setMsoRequestId("msoRequestId");
+
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+
+ MsoRequest expectedMsoRequest = new MsoRequest();
+ expectedMsoRequest.setRequestId(requestContext.getMsoRequestId());
+ expectedMsoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
+
+ MsoRequest actualMsoRequest = vnfAdapterObjectMapper.createMsoRequest(requestContext, serviceInstance);
+
+ assertThat(expectedMsoRequest, sameBeanAs(actualMsoRequest));
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java
index 00e5c10f73..5a8e57135a 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java
@@ -23,13 +23,11 @@ package org.onap.so.client.adapter.vnf.mapper;
import static com.shazam.shazamcrest.MatcherAssert.assertThat;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertEquals;
-
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
-
import org.junit.Before;
import org.junit.Test;
import org.onap.sdnc.northbound.client.model.GenericResourceApiVmNetworkData;
@@ -45,820 +43,831 @@ import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule;
-
import com.fasterxml.jackson.databind.ObjectMapper;
public class VnfAdapterVfModuleObjectMapperPayloadTest {
- private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/";
-
- private VnfAdapterVfModuleObjectMapper vfModuleObjectMapper = new VnfAdapterVfModuleObjectMapper();
- private ObjectMapper omapper = new ObjectMapper();
- @Before
- public void setUp() {
- vfModuleObjectMapper.vnfAdapterObjectMapperUtils = new VnfAdapterObjectMapperUtils();
- vfModuleObjectMapper.init();
-
- }
- @Test
- public void createVfModuleRequestMapperTest() throws Exception {
-
- // prepare and set service instance
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
- modelInfoServiceInstance.setModelName("serviceModelName");
- modelInfoServiceInstance.setModelUuid("serviceModelUuid");
- modelInfoServiceInstance.setModelVersion("serviceModelVersion");
- modelInfoServiceInstance.setEnvironmentContext("environmentContext");
- modelInfoServiceInstance.setWorkloadContext("workloadContext");
- serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
-
- RequestContext requestContext = new RequestContext();
- Map<String, Object> userParams = new HashMap<>();
- userParams.put("key1", "value2");
- requestContext.setMsoRequestId("requestId");
- requestContext.setUserParams(userParams);
- requestContext.setProductFamilyId("productFamilyId");
-
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("vnfId");
- vnf.setVnfType("vnfType");
- vnf.setVnfName("vnfName");
- ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
- modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
- modelInfoGenericVnf.setModelName("vnfModelName");
- modelInfoGenericVnf.setModelVersion("vnfModelVersion");
- modelInfoGenericVnf.setModelUuid("vnfModelUuid");
- modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
- vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
-
- Integer vfModuleIndex = 1;
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("vfModuleId");
- vfModule.setVfModuleName("vfModuleName");
- vfModule.setModuleIndex(vfModuleIndex);
- ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
- modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
- modelInfoVfModule.setModelName("vfModuleModelName");
- modelInfoVfModule.setModelVersion("vfModuleModelVersion");
- modelInfoVfModule.setModelUUID("vfModuleModelUuid");
- modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
- vfModule.setModelInfoVfModule(modelInfoVfModule);
- HashMap<String, String> cloudParams = new HashMap<String, String>();
- cloudParams.put("key3", "value3");
- vfModule.setCloudParams(cloudParams);
-
- CloudRegion cloudRegion = new CloudRegion();
- cloudRegion.setLcpCloudRegionId("cloudRegionId");
- cloudRegion.setTenantId("tenantId");
-
- OrchestrationContext orchestrationContext = new OrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(false);
-
- String sdncVnfQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopology.json")));
- String sdncVfModuleQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
-
- CreateVfModuleRequest vfModuleVNFAdapterRequest = vfModuleObjectMapper.createVfModuleRequestMapper(
- requestContext, cloudRegion, orchestrationContext, serviceInstance,
- vnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
-
-
- String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleRequest.json")));
-
- CreateVfModuleRequest reqMapper1 = omapper.readValue(
- jsonToCompare,
- CreateVfModuleRequest.class);
-
- assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl"));
- }
-
- @Test
- public void createVfModuleWithFalseRollbackRequestMapperTest() throws Exception {
-
- // prepare and set service instance
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
- modelInfoServiceInstance.setModelName("serviceModelName");
- modelInfoServiceInstance.setModelUuid("serviceModelUuid");
- modelInfoServiceInstance.setModelVersion("serviceModelVersion");
- modelInfoServiceInstance.setEnvironmentContext("environmentContext");
- modelInfoServiceInstance.setWorkloadContext("workloadContext");
- serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
-
- RequestContext requestContext = new RequestContext();
- Map<String, Object> userParams = new HashMap<>();
- userParams.put("key1", "value2");
- requestContext.setMsoRequestId("requestId");
- requestContext.setUserParams(userParams);
- requestContext.setProductFamilyId("productFamilyId");
-
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("vnfId");
- vnf.setVnfType("vnfType");
- vnf.setVnfName("vnfName");
- ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
- modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
- modelInfoGenericVnf.setModelName("vnfModelName");
- modelInfoGenericVnf.setModelVersion("vnfModelVersion");
- modelInfoGenericVnf.setModelUuid("vnfModelUuid");
- modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
- vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
-
- Integer vfModuleIndex = 1;
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("vfModuleId");
- vfModule.setVfModuleName("vfModuleName");
- vfModule.setModuleIndex(vfModuleIndex);
- ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
- modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
- modelInfoVfModule.setModelName("vfModuleModelName");
- modelInfoVfModule.setModelVersion("vfModuleModelVersion");
- modelInfoVfModule.setModelUUID("vfModuleModelUuid");
- modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
- vfModule.setModelInfoVfModule(modelInfoVfModule);
- HashMap<String, String> cloudParams = new HashMap<String, String>();
- cloudParams.put("key3", "value3");
- vfModule.setCloudParams(cloudParams);
-
- CloudRegion cloudRegion = new CloudRegion();
- cloudRegion.setLcpCloudRegionId("cloudRegionId");
- cloudRegion.setTenantId("tenantId");
-
- OrchestrationContext orchestrationContext = new OrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(true);
-
- String sdncVnfQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopology.json")));
- String sdncVfModuleQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
-
- CreateVfModuleRequest vfModuleVNFAdapterRequest = vfModuleObjectMapper.createVfModuleRequestMapper(
- requestContext, cloudRegion, orchestrationContext, serviceInstance,
- vnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
-
-
- String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleRequestTrueBackout.json")));
-
- CreateVfModuleRequest reqMapper1 = omapper.readValue(
- jsonToCompare,
- CreateVfModuleRequest.class);
-
- assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl"));
- }
-
- @Test
- public void createVfModuleRequestWithNoEnvironmentAndWorkloadContextMapperTest() throws Exception {
-
- // prepare and set service instance
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
- modelInfoServiceInstance.setModelName("serviceModelName");
- modelInfoServiceInstance.setModelUuid("serviceModelUuid");
- modelInfoServiceInstance.setModelVersion("serviceModelVersion");
- modelInfoServiceInstance.setEnvironmentContext(null);
- serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
-
- RequestContext requestContext = new RequestContext();
- Map<String, Object> userParams = new HashMap<>();
- userParams.put("key1", "value2");
- requestContext.setMsoRequestId("requestId");
- requestContext.setUserParams(userParams);
- requestContext.setProductFamilyId("productFamilyId");
-
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("vnfId");
- vnf.setVnfType("vnfType");
- vnf.setVnfName("vnfName");
- ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
- modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
- modelInfoGenericVnf.setModelName("vnfModelName");
- modelInfoGenericVnf.setModelVersion("vnfModelVersion");
- modelInfoGenericVnf.setModelUuid("vnfModelUuid");
- modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
- vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
-
- Integer vfModuleIndex = 1;
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("vfModuleId");
- vfModule.setVfModuleName("vfModuleName");
- vfModule.setModuleIndex(vfModuleIndex);
- ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
- modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
- modelInfoVfModule.setModelName("vfModuleModelName");
- modelInfoVfModule.setModelVersion("vfModuleModelVersion");
- modelInfoVfModule.setModelUUID("vfModuleModelUuid");
- modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
- vfModule.setModelInfoVfModule(modelInfoVfModule);
-
- CloudRegion cloudRegion = new CloudRegion();
- cloudRegion.setLcpCloudRegionId("cloudRegionId");
- cloudRegion.setTenantId("tenantId");
-
- OrchestrationContext orchestrationContext = new OrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(false);
-
- String sdncVnfQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopology.json")));
- String sdncVfModuleQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
-
- CreateVfModuleRequest vfModuleVNFAdapterRequest = vfModuleObjectMapper.createVfModuleRequestMapper(
- requestContext, cloudRegion, orchestrationContext, serviceInstance,
- vnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
-
-
- String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleWithNoEnvironmentAndWorkloadContextRequest.json")));
-
- CreateVfModuleRequest reqMapper1 = omapper.readValue(
- jsonToCompare,
- CreateVfModuleRequest.class);
-
- assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl"));
- }
-
- @Test
- public void createVfModuleAddonRequestMapperTest() throws Exception {
-
- // prepare and set service instance
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
- modelInfoServiceInstance.setModelName("serviceModelName");
- modelInfoServiceInstance.setModelUuid("serviceModelUuid");
- modelInfoServiceInstance.setModelVersion("serviceModelVersion");
- modelInfoServiceInstance.setEnvironmentContext("environmentContext");
- modelInfoServiceInstance.setWorkloadContext("workloadContext");
- serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
-
- //
- RequestContext requestContext = new RequestContext();
- Map<String, Object> userParams = new HashMap<>();
- userParams.put("key1", "value2");
- requestContext.setMsoRequestId("requestId");
- requestContext.setUserParams(userParams);
- requestContext.setProductFamilyId("productFamilyId");
-
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("vnfId");
- vnf.setVnfType("vnfType");
- vnf.setVnfName("vnfName");
- ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
- modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
- modelInfoGenericVnf.setModelName("vnfModelName");
- modelInfoGenericVnf.setModelVersion("vnfModelVersion");
- modelInfoGenericVnf.setModelUuid("vnfModelUuid");
- modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
- vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
-
- Integer vfModuleIndex = 1;
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("vfModuleId");
- vfModule.setVfModuleName("vfModuleName");
- vfModule.setModuleIndex(vfModuleIndex);
- ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
- modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
- modelInfoVfModule.setModelName("vfModuleModelName");
- modelInfoVfModule.setModelVersion("vfModuleModelVersion");
- modelInfoVfModule.setModelUUID("vfModuleModelUuid");
- modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
- vfModule.setModelInfoVfModule(modelInfoVfModule);
-
- VfModule baseVfModule = new VfModule();
- baseVfModule.setVfModuleId("baseVfModuleId");
- baseVfModule.setHeatStackId("baseVfModuleStackId");
- ModelInfoVfModule baseModelInfoVfModule = new ModelInfoVfModule();
- baseModelInfoVfModule.setIsBaseBoolean(true);
- baseVfModule.setModelInfoVfModule(baseModelInfoVfModule);
- vnf.getVfModules().add(baseVfModule);
-
- CloudRegion cloudRegion = new CloudRegion();
- cloudRegion.setLcpCloudRegionId("cloudRegionId");
- cloudRegion.setTenantId("tenantId");
-
- OrchestrationContext orchestrationContext = new OrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(false);
-
- String sdncVnfQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopology.json")));
- String sdncVfModuleQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
-
- CreateVfModuleRequest vfModuleVNFAdapterRequest = vfModuleObjectMapper.createVfModuleRequestMapper(
- requestContext, cloudRegion, orchestrationContext, serviceInstance,
- vnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
-
-
- String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleAddonRequest.json")));
-
- CreateVfModuleRequest reqMapper1 = omapper.readValue(
- jsonToCompare,
- CreateVfModuleRequest.class);
-
- assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl"));
- }
-
- @Test
- public void createVfModuleWithVolumeGroupRequestMapperTest() throws Exception {
-
- // prepare and set service instance
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
- modelInfoServiceInstance.setModelName("serviceModelName");
- modelInfoServiceInstance.setModelUuid("serviceModelUuid");
- modelInfoServiceInstance.setModelVersion("serviceModelVersion");
- modelInfoServiceInstance.setEnvironmentContext("environmentContext");
- modelInfoServiceInstance.setWorkloadContext("workloadContext");
- serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
-
- //
- RequestContext requestContext = new RequestContext();
- Map<String, Object> userParams = new HashMap<>();
- userParams.put("key1", "value2");
- requestContext.setMsoRequestId("requestId");
- requestContext.setUserParams(userParams);
- requestContext.setProductFamilyId("productFamilyId");
-
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("vnfId");
- vnf.setVnfType("vnfType");
- vnf.setVnfName("vnfName");
- ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
- modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
- modelInfoGenericVnf.setModelName("vnfModelName");
- modelInfoGenericVnf.setModelVersion("vnfModelVersion");
- modelInfoGenericVnf.setModelUuid("vnfModelUuid");
- modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
- vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
-
- Integer vfModuleIndex = 1;
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("vfModuleId");
- vfModule.setVfModuleName("vfModuleName");
- vfModule.setModuleIndex(vfModuleIndex);
- ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
- modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
- modelInfoVfModule.setModelName("vfModuleModelName");
- modelInfoVfModule.setModelVersion("vfModuleModelVersion");
- modelInfoVfModule.setModelUUID("vfModuleModelUuid");
- modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
- vfModule.setModelInfoVfModule(modelInfoVfModule);
-
- VolumeGroup volumeGroup = new VolumeGroup();
- volumeGroup.setVolumeGroupId("volumeGroupId");
- volumeGroup.setHeatStackId("volumeGroupStackId");
-
- CloudRegion cloudRegion = new CloudRegion();
- cloudRegion.setLcpCloudRegionId("cloudRegionId");
- cloudRegion.setTenantId("tenantId");
-
- OrchestrationContext orchestrationContext = new OrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(false);
-
- String sdncVnfQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopology.json")));
- String sdncVfModuleQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
-
- CreateVfModuleRequest vfModuleVNFAdapterRequest = vfModuleObjectMapper.createVfModuleRequestMapper(
- requestContext, cloudRegion, orchestrationContext, serviceInstance,
- vnf, vfModule, volumeGroup, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
-
-
- String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleWithVolumeGroupRequest.json")));
-
- CreateVfModuleRequest reqMapper1 = omapper.readValue(
- jsonToCompare,
- CreateVfModuleRequest.class);
-
- assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl"));
- }
-
- @Test
- public void createVfModuleWithSingleAvailabilityZoneRequestMapperTest() throws Exception {
-
- // prepare and set service instance
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
- modelInfoServiceInstance.setModelName("serviceModelName");
- modelInfoServiceInstance.setModelUuid("serviceModelUuid");
- modelInfoServiceInstance.setModelVersion("serviceModelVersion");
- modelInfoServiceInstance.setEnvironmentContext("environmentContext");
- modelInfoServiceInstance.setWorkloadContext("workloadContext");
- serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
-
- RequestContext requestContext = new RequestContext();
- Map<String, Object> userParams = new HashMap<>();
- userParams.put("key1", "value2");
- requestContext.setMsoRequestId("requestId");
- requestContext.setUserParams(userParams);
- requestContext.setProductFamilyId("productFamilyId");
-
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("vnfId");
- vnf.setVnfType("vnfType");
- vnf.setVnfName("vnfName");
- ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
- modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
- modelInfoGenericVnf.setModelName("vnfModelName");
- modelInfoGenericVnf.setModelVersion("vnfModelVersion");
- modelInfoGenericVnf.setModelUuid("vnfModelUuid");
- modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
- vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
-
- Integer vfModuleIndex = 1;
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("vfModuleId");
- vfModule.setVfModuleName("vfModuleName");
- vfModule.setModuleIndex(vfModuleIndex);
- ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
- modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
- modelInfoVfModule.setModelName("vfModuleModelName");
- modelInfoVfModule.setModelVersion("vfModuleModelVersion");
- modelInfoVfModule.setModelUUID("vfModuleModelUuid");
- modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
- vfModule.setModelInfoVfModule(modelInfoVfModule);
-
- CloudRegion cloudRegion = new CloudRegion();
- cloudRegion.setLcpCloudRegionId("cloudRegionId");
- cloudRegion.setTenantId("tenantId");
-
- OrchestrationContext orchestrationContext = new OrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(false);
-
- String sdncVnfQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopologyWithSingletonArray.json")));
- String sdncVfModuleQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
-
- CreateVfModuleRequest vfModuleVNFAdapterRequest = vfModuleObjectMapper.createVfModuleRequestMapper(
- requestContext, cloudRegion, orchestrationContext, serviceInstance,
- vnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
-
-
- String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleRequestWithSingleAvailabilityZone.json")));
-
- CreateVfModuleRequest reqMapper1 = omapper.readValue(
- jsonToCompare,
- CreateVfModuleRequest.class);
-
- assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl"));
- }
-
- @Test
- public void createVfModuleRequestMapperWithCloudResourcesTest() throws Exception {
-
- // prepare and set service instance
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
- modelInfoServiceInstance.setModelName("serviceModelName");
- modelInfoServiceInstance.setModelUuid("serviceModelUuid");
- modelInfoServiceInstance.setModelVersion("serviceModelVersion");
- modelInfoServiceInstance.setEnvironmentContext("environmentContext");
- modelInfoServiceInstance.setWorkloadContext("workloadContext");
- serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
-
- RequestContext requestContext = new RequestContext();
- Map<String, Object> userParams = new HashMap<>();
- userParams.put("key1", "value1");
- requestContext.setMsoRequestId("requestId");
- requestContext.setUserParams(userParams);
- requestContext.setProductFamilyId("productFamilyId");
-
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("vnfId");
- vnf.setVnfType("vnfType");
- vnf.setVnfName("vnfName");
- ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
- modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
- modelInfoGenericVnf.setModelName("vnfModelName");
- modelInfoGenericVnf.setModelVersion("vnfModelVersion");
- modelInfoGenericVnf.setModelUuid("vnfModelUuid");
- modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
- vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
-
- Integer vfModuleIndex = 1;
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("vfModuleId");
- vfModule.setVfModuleName("vfModuleName");
- vfModule.setModuleIndex(vfModuleIndex);
- ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
- modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
- modelInfoVfModule.setModelName("vfModuleModelName");
- modelInfoVfModule.setModelVersion("vfModuleModelVersion");
- modelInfoVfModule.setModelUUID("vfModuleModelUuid");
- modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
- vfModule.setModelInfoVfModule(modelInfoVfModule);
-
- CloudRegion cloudRegion = new CloudRegion();
- cloudRegion.setLcpCloudRegionId("cloudRegionId");
- cloudRegion.setTenantId("tenantId");
-
- OrchestrationContext orchestrationContext = new OrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(false);
-
- String sdncVnfQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopologyWithCloudResources.json")));
- String sdncVfModuleQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopologyWithCloudResources.json")));
-
- CreateVfModuleRequest vfModuleVNFAdapterRequest = vfModuleObjectMapper.createVfModuleRequestMapper(
- requestContext, cloudRegion, orchestrationContext, serviceInstance,
- vnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
-
-
- String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleRequestWithCloudResources.json")));
-
- CreateVfModuleRequest reqMapper1 = omapper.readValue(
- jsonToCompare,
- CreateVfModuleRequest.class);
-
- assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl"));
- }
-
- @Test
- public void createVfModuleRequestMapperDhcpDisabledTest() throws Exception {
- // prepare and set service instance
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
- modelInfoServiceInstance.setModelName("serviceModelName");
- modelInfoServiceInstance.setModelUuid("serviceModelUuid");
- modelInfoServiceInstance.setModelVersion("serviceModelVersion");
- modelInfoServiceInstance.setEnvironmentContext("environmentContext");
- modelInfoServiceInstance.setWorkloadContext("workloadContext");
- serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
-
- RequestContext requestContext = new RequestContext();
- Map<String, Object> userParams = new HashMap<>();
- userParams.put("key1", "value1");
- requestContext.setMsoRequestId("requestId");
- requestContext.setUserParams(userParams);
- requestContext.setProductFamilyId("productFamilyId");
-
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("vnfId");
- vnf.setVnfType("vnfType");
- vnf.setVnfName("vnfName");
- ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
- modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
- modelInfoGenericVnf.setModelName("vnfModelName");
- modelInfoGenericVnf.setModelVersion("vnfModelVersion");
- modelInfoGenericVnf.setModelUuid("vnfModelUuid");
- modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
- vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
-
- Integer vfModuleIndex = 1;
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("vfModuleId");
- vfModule.setVfModuleName("vfModuleName");
- vfModule.setModuleIndex(vfModuleIndex);
- ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
- modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
- modelInfoVfModule.setModelName("vfModuleModelName");
- modelInfoVfModule.setModelVersion("vfModuleModelVersion");
- modelInfoVfModule.setModelUUID("vfModuleModelUuid");
- modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
- vfModule.setModelInfoVfModule(modelInfoVfModule);
-
- CloudRegion cloudRegion = new CloudRegion();
- cloudRegion.setLcpCloudRegionId("cloudRegionId");
- cloudRegion.setTenantId("tenantId");
-
- OrchestrationContext orchestrationContext = new OrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(false);
-
- String sdncVnfQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopologySubnetDhcpDisabled.json")));
- String sdncVfModuleQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
-
- CreateVfModuleRequest vfModuleVNFAdapterRequest = vfModuleObjectMapper.createVfModuleRequestMapper(
- requestContext, cloudRegion, orchestrationContext, serviceInstance,
- vnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
-
-
- String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleRequestDhcpDisabled.json")));
-
- CreateVfModuleRequest reqMapper1 = omapper.readValue(
- jsonToCompare,
- CreateVfModuleRequest.class);
-
- assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl"));
- }
-
- @Test
- public void createVfModuleRequestMapperMultipleDhcpTest() throws Exception {
- // prepare and set service instance
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
- modelInfoServiceInstance.setModelName("serviceModelName");
- modelInfoServiceInstance.setModelUuid("serviceModelUuid");
- modelInfoServiceInstance.setModelVersion("serviceModelVersion");
- modelInfoServiceInstance.setEnvironmentContext("environmentContext");
- modelInfoServiceInstance.setWorkloadContext("workloadContext");
- serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
-
- RequestContext requestContext = new RequestContext();
- Map<String, Object> userParams = new HashMap<>();
- userParams.put("key1", "value1");
- requestContext.setMsoRequestId("requestId");
- requestContext.setUserParams(userParams);
- requestContext.setProductFamilyId("productFamilyId");
-
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("vnfId");
- vnf.setVnfType("vnfType");
- vnf.setVnfName("vnfName");
- ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
- modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
- modelInfoGenericVnf.setModelName("vnfModelName");
- modelInfoGenericVnf.setModelVersion("vnfModelVersion");
- modelInfoGenericVnf.setModelUuid("vnfModelUuid");
- modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
- vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
-
- Integer vfModuleIndex = 1;
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("vfModuleId");
- vfModule.setVfModuleName("vfModuleName");
- vfModule.setModuleIndex(vfModuleIndex);
- ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
- modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
- modelInfoVfModule.setModelName("vfModuleModelName");
- modelInfoVfModule.setModelVersion("vfModuleModelVersion");
- modelInfoVfModule.setModelUUID("vfModuleModelUuid");
- modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
- vfModule.setModelInfoVfModule(modelInfoVfModule);
-
- CloudRegion cloudRegion = new CloudRegion();
- cloudRegion.setLcpCloudRegionId("cloudRegionId");
- cloudRegion.setTenantId("tenantId");
-
- OrchestrationContext orchestrationContext = new OrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(false);
-
- String sdncVnfQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopologySubnetMultipleDhcp.json")));
- String sdncVfModuleQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
-
- CreateVfModuleRequest vfModuleVNFAdapterRequest = vfModuleObjectMapper.createVfModuleRequestMapper(
- requestContext, cloudRegion, orchestrationContext, serviceInstance,
- vnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
-
-
- String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleRequestMultipleDhcp.json")));
-
- CreateVfModuleRequest reqMapper1 = omapper.readValue(
- jsonToCompare,
- CreateVfModuleRequest.class);
-
- assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl"));
- }
-
- @Test
- public void createVfModuleRequestMapperWithNullUserParamsTest() throws Exception {
-
- // prepare and set service instance
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
- modelInfoServiceInstance.setModelName("serviceModelName");
- modelInfoServiceInstance.setModelUuid("serviceModelUuid");
- modelInfoServiceInstance.setModelVersion("serviceModelVersion");
- modelInfoServiceInstance.setEnvironmentContext("environmentContext");
- modelInfoServiceInstance.setWorkloadContext("workloadContext");
- serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
-
- RequestContext requestContext = new RequestContext();
- requestContext.setMsoRequestId("requestId");
- requestContext.setProductFamilyId("productFamilyId");
-
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("vnfId");
- vnf.setVnfType("vnfType");
- vnf.setVnfName("vnfName");
- ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
- modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
- modelInfoGenericVnf.setModelName("vnfModelName");
- modelInfoGenericVnf.setModelVersion("vnfModelVersion");
- modelInfoGenericVnf.setModelUuid("vnfModelUuid");
- modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
- vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
-
- Integer vfModuleIndex = 1;
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("vfModuleId");
- vfModule.setVfModuleName("vfModuleName");
- vfModule.setModuleIndex(vfModuleIndex);
- ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
- modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
- modelInfoVfModule.setModelName("vfModuleModelName");
- modelInfoVfModule.setModelVersion("vfModuleModelVersion");
- modelInfoVfModule.setModelUUID("vfModuleModelUuid");
- modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
- vfModule.setModelInfoVfModule(modelInfoVfModule);
-
- CloudRegion cloudRegion = new CloudRegion();
- cloudRegion.setLcpCloudRegionId("cloudRegionId");
- cloudRegion.setTenantId("tenantId");
-
- OrchestrationContext orchestrationContext = new OrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(false);
-
- String sdncVnfQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopology.json")));
- String sdncVfModuleQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
-
- CreateVfModuleRequest vfModuleVNFAdapterRequest = vfModuleObjectMapper.createVfModuleRequestMapper(
- requestContext, cloudRegion, orchestrationContext, serviceInstance,
- vnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
-
-
- String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleRequestNoUserParams.json")));
-
- CreateVfModuleRequest reqMapper1 = omapper.readValue(
- jsonToCompare,
- CreateVfModuleRequest.class);
-
- assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl"));
- }
-
- @Test
- public void DeleteVfModuleRequestMapperTest() throws Exception {
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
- modelInfoServiceInstance.setModelName("serviceModelName");
- modelInfoServiceInstance.setModelUuid("serviceModelUuid");
- modelInfoServiceInstance.setModelVersion("serviceModelVersion");
- modelInfoServiceInstance.setEnvironmentContext("environmentContext");
- modelInfoServiceInstance.setWorkloadContext("workloadContext");
- serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
-
- RequestContext requestContext = new RequestContext();
- Map<String, Object> userParams = new HashMap<>();
- userParams.put("key1", "value1");
- requestContext.setMsoRequestId("requestId");
- requestContext.setUserParams(userParams);
- requestContext.setProductFamilyId("productFamilyId");
-
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("vnfId");
- vnf.setVnfType("vnfType");
- vnf.setVnfName("vnfName");
- ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
- modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
- modelInfoGenericVnf.setModelName("vnfModelName");
- modelInfoGenericVnf.setModelVersion("vnfModelVersion");
- modelInfoGenericVnf.setModelUuid("vnfModelUuid");
- modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
- vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
-
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("vfModuleId");
- vfModule.setVfModuleName("vfModuleName");
- ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
- modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
- modelInfoVfModule.setModelName("vfModuleModelName");
- modelInfoVfModule.setModelVersion("vfModuleModelVersion");
- modelInfoVfModule.setModelUUID("vfModuleModelUuid");
- modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
- vfModule.setModelInfoVfModule(modelInfoVfModule);
-
- CloudRegion cloudRegion = new CloudRegion();
- cloudRegion.setLcpCloudRegionId("cloudRegionId");
- cloudRegion.setTenantId("tenantId");
-
- OrchestrationContext orchestrationContext = new OrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(false);
-
- DeleteVfModuleRequest vfModuleVNFAdapterRequest = vfModuleObjectMapper.deleteVfModuleRequestMapper(
- requestContext, cloudRegion, serviceInstance,
- vnf, vfModule);
-
-
- String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterDeleteVfModuleRequest.json")));
-
- DeleteVfModuleRequest reqMapper1 = omapper.readValue(
- jsonToCompare,
- DeleteVfModuleRequest.class);
-
- assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl").ignoring("vfModuleStackId"));
- }
-
- @Test
- public void networkCloudParamsTest() throws IOException {
-
- String json = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "grApiVmNetworkSubSectionWith5GParams.json")));
- GenericResourceApiVmNetworkData network = omapper.readValue(json, GenericResourceApiVmNetworkData.class);
- Map<String, Object> paramsMap = new HashMap<>();
- vfModuleObjectMapper.buildVlanInformation(paramsMap, network, "testKey", "testType");
-
- assertEquals("1,3", paramsMap.get("testKey_testType_private_vlans"));
- assertEquals("2,3", paramsMap.get("testKey_testType_public_vlans"));
- assertEquals("1,2,3", paramsMap.get("testKey_testType_guest_vlans"));
- assertEquals("my-segemntation-id", paramsMap.get("testKey_testType_vlan_filter"));
- }
+ private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/";
+
+ private VnfAdapterVfModuleObjectMapper vfModuleObjectMapper = new VnfAdapterVfModuleObjectMapper();
+ private ObjectMapper omapper = new ObjectMapper();
+
+ @Before
+ public void setUp() {
+ vfModuleObjectMapper.vnfAdapterObjectMapperUtils = new VnfAdapterObjectMapperUtils();
+ vfModuleObjectMapper.init();
+
+ }
+
+ @Test
+ public void createVfModuleRequestMapperTest() throws Exception {
+
+ // prepare and set service instance
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
+ modelInfoServiceInstance.setModelName("serviceModelName");
+ modelInfoServiceInstance.setModelUuid("serviceModelUuid");
+ modelInfoServiceInstance.setModelVersion("serviceModelVersion");
+ modelInfoServiceInstance.setEnvironmentContext("environmentContext");
+ modelInfoServiceInstance.setWorkloadContext("workloadContext");
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+
+ RequestContext requestContext = new RequestContext();
+ Map<String, Object> userParams = new HashMap<>();
+ userParams.put("key1", "value2");
+ requestContext.setMsoRequestId("requestId");
+ requestContext.setUserParams(userParams);
+ requestContext.setProductFamilyId("productFamilyId");
+
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("vnfId");
+ vnf.setVnfType("vnfType");
+ vnf.setVnfName("vnfName");
+ ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
+ modelInfoGenericVnf.setModelName("vnfModelName");
+ modelInfoGenericVnf.setModelVersion("vnfModelVersion");
+ modelInfoGenericVnf.setModelUuid("vnfModelUuid");
+ modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
+ vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
+
+ Integer vfModuleIndex = 1;
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("vfModuleId");
+ vfModule.setVfModuleName("vfModuleName");
+ vfModule.setModuleIndex(vfModuleIndex);
+ ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
+ modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
+ modelInfoVfModule.setModelName("vfModuleModelName");
+ modelInfoVfModule.setModelVersion("vfModuleModelVersion");
+ modelInfoVfModule.setModelUUID("vfModuleModelUuid");
+ modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
+ vfModule.setModelInfoVfModule(modelInfoVfModule);
+ HashMap<String, String> cloudParams = new HashMap<String, String>();
+ cloudParams.put("key3", "value3");
+ vfModule.setCloudParams(cloudParams);
+
+ CloudRegion cloudRegion = new CloudRegion();
+ cloudRegion.setLcpCloudRegionId("cloudRegionId");
+ cloudRegion.setTenantId("tenantId");
+
+ OrchestrationContext orchestrationContext = new OrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(false);
+
+ String sdncVnfQueryResponse = new String(
+ Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopology.json")));
+ String sdncVfModuleQueryResponse = new String(Files
+ .readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
+
+ CreateVfModuleRequest vfModuleVNFAdapterRequest =
+ vfModuleObjectMapper.createVfModuleRequestMapper(requestContext, cloudRegion, orchestrationContext,
+ serviceInstance, vnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
+
+
+ String jsonToCompare =
+ new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleRequest.json")));
+
+ CreateVfModuleRequest reqMapper1 = omapper.readValue(jsonToCompare, CreateVfModuleRequest.class);
+
+ assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl"));
+ }
+
+ @Test
+ public void createVfModuleWithFalseRollbackRequestMapperTest() throws Exception {
+
+ // prepare and set service instance
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
+ modelInfoServiceInstance.setModelName("serviceModelName");
+ modelInfoServiceInstance.setModelUuid("serviceModelUuid");
+ modelInfoServiceInstance.setModelVersion("serviceModelVersion");
+ modelInfoServiceInstance.setEnvironmentContext("environmentContext");
+ modelInfoServiceInstance.setWorkloadContext("workloadContext");
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+
+ RequestContext requestContext = new RequestContext();
+ Map<String, Object> userParams = new HashMap<>();
+ userParams.put("key1", "value2");
+ requestContext.setMsoRequestId("requestId");
+ requestContext.setUserParams(userParams);
+ requestContext.setProductFamilyId("productFamilyId");
+
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("vnfId");
+ vnf.setVnfType("vnfType");
+ vnf.setVnfName("vnfName");
+ ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
+ modelInfoGenericVnf.setModelName("vnfModelName");
+ modelInfoGenericVnf.setModelVersion("vnfModelVersion");
+ modelInfoGenericVnf.setModelUuid("vnfModelUuid");
+ modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
+ vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
+
+ Integer vfModuleIndex = 1;
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("vfModuleId");
+ vfModule.setVfModuleName("vfModuleName");
+ vfModule.setModuleIndex(vfModuleIndex);
+ ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
+ modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
+ modelInfoVfModule.setModelName("vfModuleModelName");
+ modelInfoVfModule.setModelVersion("vfModuleModelVersion");
+ modelInfoVfModule.setModelUUID("vfModuleModelUuid");
+ modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
+ vfModule.setModelInfoVfModule(modelInfoVfModule);
+ HashMap<String, String> cloudParams = new HashMap<String, String>();
+ cloudParams.put("key3", "value3");
+ vfModule.setCloudParams(cloudParams);
+
+ CloudRegion cloudRegion = new CloudRegion();
+ cloudRegion.setLcpCloudRegionId("cloudRegionId");
+ cloudRegion.setTenantId("tenantId");
+
+ OrchestrationContext orchestrationContext = new OrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(true);
+
+ String sdncVnfQueryResponse = new String(
+ Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopology.json")));
+ String sdncVfModuleQueryResponse = new String(Files
+ .readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
+
+ CreateVfModuleRequest vfModuleVNFAdapterRequest =
+ vfModuleObjectMapper.createVfModuleRequestMapper(requestContext, cloudRegion, orchestrationContext,
+ serviceInstance, vnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
+
+
+ String jsonToCompare = new String(
+ Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleRequestTrueBackout.json")));
+
+ CreateVfModuleRequest reqMapper1 = omapper.readValue(jsonToCompare, CreateVfModuleRequest.class);
+
+ assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl"));
+ }
+
+ @Test
+ public void createVfModuleRequestWithNoEnvironmentAndWorkloadContextMapperTest() throws Exception {
+
+ // prepare and set service instance
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
+ modelInfoServiceInstance.setModelName("serviceModelName");
+ modelInfoServiceInstance.setModelUuid("serviceModelUuid");
+ modelInfoServiceInstance.setModelVersion("serviceModelVersion");
+ modelInfoServiceInstance.setEnvironmentContext(null);
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+
+ RequestContext requestContext = new RequestContext();
+ Map<String, Object> userParams = new HashMap<>();
+ userParams.put("key1", "value2");
+ requestContext.setMsoRequestId("requestId");
+ requestContext.setUserParams(userParams);
+ requestContext.setProductFamilyId("productFamilyId");
+
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("vnfId");
+ vnf.setVnfType("vnfType");
+ vnf.setVnfName("vnfName");
+ ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
+ modelInfoGenericVnf.setModelName("vnfModelName");
+ modelInfoGenericVnf.setModelVersion("vnfModelVersion");
+ modelInfoGenericVnf.setModelUuid("vnfModelUuid");
+ modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
+ vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
+
+ Integer vfModuleIndex = 1;
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("vfModuleId");
+ vfModule.setVfModuleName("vfModuleName");
+ vfModule.setModuleIndex(vfModuleIndex);
+ ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
+ modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
+ modelInfoVfModule.setModelName("vfModuleModelName");
+ modelInfoVfModule.setModelVersion("vfModuleModelVersion");
+ modelInfoVfModule.setModelUUID("vfModuleModelUuid");
+ modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
+ vfModule.setModelInfoVfModule(modelInfoVfModule);
+
+ CloudRegion cloudRegion = new CloudRegion();
+ cloudRegion.setLcpCloudRegionId("cloudRegionId");
+ cloudRegion.setTenantId("tenantId");
+
+ OrchestrationContext orchestrationContext = new OrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(false);
+
+ String sdncVnfQueryResponse = new String(
+ Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopology.json")));
+ String sdncVfModuleQueryResponse = new String(Files
+ .readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
+
+ CreateVfModuleRequest vfModuleVNFAdapterRequest =
+ vfModuleObjectMapper.createVfModuleRequestMapper(requestContext, cloudRegion, orchestrationContext,
+ serviceInstance, vnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
+
+
+ String jsonToCompare = new String(Files.readAllBytes(Paths
+ .get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleWithNoEnvironmentAndWorkloadContextRequest.json")));
+
+ CreateVfModuleRequest reqMapper1 = omapper.readValue(jsonToCompare, CreateVfModuleRequest.class);
+
+ assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl"));
+ }
+
+ @Test
+ public void createVfModuleAddonRequestMapperTest() throws Exception {
+
+ // prepare and set service instance
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
+ modelInfoServiceInstance.setModelName("serviceModelName");
+ modelInfoServiceInstance.setModelUuid("serviceModelUuid");
+ modelInfoServiceInstance.setModelVersion("serviceModelVersion");
+ modelInfoServiceInstance.setEnvironmentContext("environmentContext");
+ modelInfoServiceInstance.setWorkloadContext("workloadContext");
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+
+ //
+ RequestContext requestContext = new RequestContext();
+ Map<String, Object> userParams = new HashMap<>();
+ userParams.put("key1", "value2");
+ requestContext.setMsoRequestId("requestId");
+ requestContext.setUserParams(userParams);
+ requestContext.setProductFamilyId("productFamilyId");
+
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("vnfId");
+ vnf.setVnfType("vnfType");
+ vnf.setVnfName("vnfName");
+ ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
+ modelInfoGenericVnf.setModelName("vnfModelName");
+ modelInfoGenericVnf.setModelVersion("vnfModelVersion");
+ modelInfoGenericVnf.setModelUuid("vnfModelUuid");
+ modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
+ vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
+
+ Integer vfModuleIndex = 1;
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("vfModuleId");
+ vfModule.setVfModuleName("vfModuleName");
+ vfModule.setModuleIndex(vfModuleIndex);
+ ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
+ modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
+ modelInfoVfModule.setModelName("vfModuleModelName");
+ modelInfoVfModule.setModelVersion("vfModuleModelVersion");
+ modelInfoVfModule.setModelUUID("vfModuleModelUuid");
+ modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
+ vfModule.setModelInfoVfModule(modelInfoVfModule);
+
+ VfModule baseVfModule = new VfModule();
+ baseVfModule.setVfModuleId("baseVfModuleId");
+ baseVfModule.setHeatStackId("baseVfModuleStackId");
+ ModelInfoVfModule baseModelInfoVfModule = new ModelInfoVfModule();
+ baseModelInfoVfModule.setIsBaseBoolean(true);
+ baseVfModule.setModelInfoVfModule(baseModelInfoVfModule);
+ vnf.getVfModules().add(baseVfModule);
+
+ CloudRegion cloudRegion = new CloudRegion();
+ cloudRegion.setLcpCloudRegionId("cloudRegionId");
+ cloudRegion.setTenantId("tenantId");
+
+ OrchestrationContext orchestrationContext = new OrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(false);
+
+ String sdncVnfQueryResponse = new String(
+ Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopology.json")));
+ String sdncVfModuleQueryResponse = new String(Files
+ .readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
+
+ CreateVfModuleRequest vfModuleVNFAdapterRequest =
+ vfModuleObjectMapper.createVfModuleRequestMapper(requestContext, cloudRegion, orchestrationContext,
+ serviceInstance, vnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
+
+
+ String jsonToCompare = new String(
+ Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleAddonRequest.json")));
+
+ CreateVfModuleRequest reqMapper1 = omapper.readValue(jsonToCompare, CreateVfModuleRequest.class);
+
+ assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl"));
+ }
+
+ @Test
+ public void createVfModuleWithVolumeGroupRequestMapperTest() throws Exception {
+
+ // prepare and set service instance
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
+ modelInfoServiceInstance.setModelName("serviceModelName");
+ modelInfoServiceInstance.setModelUuid("serviceModelUuid");
+ modelInfoServiceInstance.setModelVersion("serviceModelVersion");
+ modelInfoServiceInstance.setEnvironmentContext("environmentContext");
+ modelInfoServiceInstance.setWorkloadContext("workloadContext");
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+
+ //
+ RequestContext requestContext = new RequestContext();
+ Map<String, Object> userParams = new HashMap<>();
+ userParams.put("key1", "value2");
+ requestContext.setMsoRequestId("requestId");
+ requestContext.setUserParams(userParams);
+ requestContext.setProductFamilyId("productFamilyId");
+
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("vnfId");
+ vnf.setVnfType("vnfType");
+ vnf.setVnfName("vnfName");
+ ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
+ modelInfoGenericVnf.setModelName("vnfModelName");
+ modelInfoGenericVnf.setModelVersion("vnfModelVersion");
+ modelInfoGenericVnf.setModelUuid("vnfModelUuid");
+ modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
+ vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
+
+ Integer vfModuleIndex = 1;
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("vfModuleId");
+ vfModule.setVfModuleName("vfModuleName");
+ vfModule.setModuleIndex(vfModuleIndex);
+ ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
+ modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
+ modelInfoVfModule.setModelName("vfModuleModelName");
+ modelInfoVfModule.setModelVersion("vfModuleModelVersion");
+ modelInfoVfModule.setModelUUID("vfModuleModelUuid");
+ modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
+ vfModule.setModelInfoVfModule(modelInfoVfModule);
+
+ VolumeGroup volumeGroup = new VolumeGroup();
+ volumeGroup.setVolumeGroupId("volumeGroupId");
+ volumeGroup.setHeatStackId("volumeGroupStackId");
+
+ CloudRegion cloudRegion = new CloudRegion();
+ cloudRegion.setLcpCloudRegionId("cloudRegionId");
+ cloudRegion.setTenantId("tenantId");
+
+ OrchestrationContext orchestrationContext = new OrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(false);
+
+ String sdncVnfQueryResponse = new String(
+ Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopology.json")));
+ String sdncVfModuleQueryResponse = new String(Files
+ .readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
+
+ CreateVfModuleRequest vfModuleVNFAdapterRequest =
+ vfModuleObjectMapper.createVfModuleRequestMapper(requestContext, cloudRegion, orchestrationContext,
+ serviceInstance, vnf, vfModule, volumeGroup, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
+
+
+ String jsonToCompare = new String(Files
+ .readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleWithVolumeGroupRequest.json")));
+
+ CreateVfModuleRequest reqMapper1 = omapper.readValue(jsonToCompare, CreateVfModuleRequest.class);
+
+ assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl"));
+ }
+
+ @Test
+ public void createVfModuleWithSingleAvailabilityZoneRequestMapperTest() throws Exception {
+
+ // prepare and set service instance
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
+ modelInfoServiceInstance.setModelName("serviceModelName");
+ modelInfoServiceInstance.setModelUuid("serviceModelUuid");
+ modelInfoServiceInstance.setModelVersion("serviceModelVersion");
+ modelInfoServiceInstance.setEnvironmentContext("environmentContext");
+ modelInfoServiceInstance.setWorkloadContext("workloadContext");
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+
+ RequestContext requestContext = new RequestContext();
+ Map<String, Object> userParams = new HashMap<>();
+ userParams.put("key1", "value2");
+ requestContext.setMsoRequestId("requestId");
+ requestContext.setUserParams(userParams);
+ requestContext.setProductFamilyId("productFamilyId");
+
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("vnfId");
+ vnf.setVnfType("vnfType");
+ vnf.setVnfName("vnfName");
+ ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
+ modelInfoGenericVnf.setModelName("vnfModelName");
+ modelInfoGenericVnf.setModelVersion("vnfModelVersion");
+ modelInfoGenericVnf.setModelUuid("vnfModelUuid");
+ modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
+ vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
+
+ Integer vfModuleIndex = 1;
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("vfModuleId");
+ vfModule.setVfModuleName("vfModuleName");
+ vfModule.setModuleIndex(vfModuleIndex);
+ ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
+ modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
+ modelInfoVfModule.setModelName("vfModuleModelName");
+ modelInfoVfModule.setModelVersion("vfModuleModelVersion");
+ modelInfoVfModule.setModelUUID("vfModuleModelUuid");
+ modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
+ vfModule.setModelInfoVfModule(modelInfoVfModule);
+
+ CloudRegion cloudRegion = new CloudRegion();
+ cloudRegion.setLcpCloudRegionId("cloudRegionId");
+ cloudRegion.setTenantId("tenantId");
+
+ OrchestrationContext orchestrationContext = new OrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(false);
+
+ String sdncVnfQueryResponse = new String(Files.readAllBytes(
+ Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopologyWithSingletonArray.json")));
+ String sdncVfModuleQueryResponse = new String(Files
+ .readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
+
+ CreateVfModuleRequest vfModuleVNFAdapterRequest =
+ vfModuleObjectMapper.createVfModuleRequestMapper(requestContext, cloudRegion, orchestrationContext,
+ serviceInstance, vnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
+
+
+ String jsonToCompare = new String(Files.readAllBytes(
+ Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleRequestWithSingleAvailabilityZone.json")));
+
+ CreateVfModuleRequest reqMapper1 = omapper.readValue(jsonToCompare, CreateVfModuleRequest.class);
+
+ assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl"));
+ }
+
+ @Test
+ public void createVfModuleRequestMapperWithCloudResourcesTest() throws Exception {
+
+ // prepare and set service instance
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
+ modelInfoServiceInstance.setModelName("serviceModelName");
+ modelInfoServiceInstance.setModelUuid("serviceModelUuid");
+ modelInfoServiceInstance.setModelVersion("serviceModelVersion");
+ modelInfoServiceInstance.setEnvironmentContext("environmentContext");
+ modelInfoServiceInstance.setWorkloadContext("workloadContext");
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+
+ RequestContext requestContext = new RequestContext();
+ Map<String, Object> userParams = new HashMap<>();
+ userParams.put("key1", "value1");
+ requestContext.setMsoRequestId("requestId");
+ requestContext.setUserParams(userParams);
+ requestContext.setProductFamilyId("productFamilyId");
+
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("vnfId");
+ vnf.setVnfType("vnfType");
+ vnf.setVnfName("vnfName");
+ ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
+ modelInfoGenericVnf.setModelName("vnfModelName");
+ modelInfoGenericVnf.setModelVersion("vnfModelVersion");
+ modelInfoGenericVnf.setModelUuid("vnfModelUuid");
+ modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
+ vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
+
+ Integer vfModuleIndex = 1;
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("vfModuleId");
+ vfModule.setVfModuleName("vfModuleName");
+ vfModule.setModuleIndex(vfModuleIndex);
+ ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
+ modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
+ modelInfoVfModule.setModelName("vfModuleModelName");
+ modelInfoVfModule.setModelVersion("vfModuleModelVersion");
+ modelInfoVfModule.setModelUUID("vfModuleModelUuid");
+ modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
+ vfModule.setModelInfoVfModule(modelInfoVfModule);
+
+ CloudRegion cloudRegion = new CloudRegion();
+ cloudRegion.setLcpCloudRegionId("cloudRegionId");
+ cloudRegion.setTenantId("tenantId");
+
+ OrchestrationContext orchestrationContext = new OrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(false);
+
+ String sdncVnfQueryResponse = new String(Files.readAllBytes(
+ Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopologyWithCloudResources.json")));
+ String sdncVfModuleQueryResponse = new String(Files.readAllBytes(Paths
+ .get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopologyWithCloudResources.json")));
+
+ CreateVfModuleRequest vfModuleVNFAdapterRequest =
+ vfModuleObjectMapper.createVfModuleRequestMapper(requestContext, cloudRegion, orchestrationContext,
+ serviceInstance, vnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
+
+
+ String jsonToCompare = new String(Files.readAllBytes(
+ Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleRequestWithCloudResources.json")));
+
+ CreateVfModuleRequest reqMapper1 = omapper.readValue(jsonToCompare, CreateVfModuleRequest.class);
+
+ assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl"));
+ }
+
+ @Test
+ public void createVfModuleRequestMapperDhcpDisabledTest() throws Exception {
+ // prepare and set service instance
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
+ modelInfoServiceInstance.setModelName("serviceModelName");
+ modelInfoServiceInstance.setModelUuid("serviceModelUuid");
+ modelInfoServiceInstance.setModelVersion("serviceModelVersion");
+ modelInfoServiceInstance.setEnvironmentContext("environmentContext");
+ modelInfoServiceInstance.setWorkloadContext("workloadContext");
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+
+ RequestContext requestContext = new RequestContext();
+ Map<String, Object> userParams = new HashMap<>();
+ userParams.put("key1", "value1");
+ requestContext.setMsoRequestId("requestId");
+ requestContext.setUserParams(userParams);
+ requestContext.setProductFamilyId("productFamilyId");
+
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("vnfId");
+ vnf.setVnfType("vnfType");
+ vnf.setVnfName("vnfName");
+ ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
+ modelInfoGenericVnf.setModelName("vnfModelName");
+ modelInfoGenericVnf.setModelVersion("vnfModelVersion");
+ modelInfoGenericVnf.setModelUuid("vnfModelUuid");
+ modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
+ vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
+
+ Integer vfModuleIndex = 1;
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("vfModuleId");
+ vfModule.setVfModuleName("vfModuleName");
+ vfModule.setModuleIndex(vfModuleIndex);
+ ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
+ modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
+ modelInfoVfModule.setModelName("vfModuleModelName");
+ modelInfoVfModule.setModelVersion("vfModuleModelVersion");
+ modelInfoVfModule.setModelUUID("vfModuleModelUuid");
+ modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
+ vfModule.setModelInfoVfModule(modelInfoVfModule);
+
+ CloudRegion cloudRegion = new CloudRegion();
+ cloudRegion.setLcpCloudRegionId("cloudRegionId");
+ cloudRegion.setTenantId("tenantId");
+
+ OrchestrationContext orchestrationContext = new OrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(false);
+
+ String sdncVnfQueryResponse = new String(Files.readAllBytes(
+ Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopologySubnetDhcpDisabled.json")));
+ String sdncVfModuleQueryResponse = new String(Files
+ .readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
+
+ CreateVfModuleRequest vfModuleVNFAdapterRequest =
+ vfModuleObjectMapper.createVfModuleRequestMapper(requestContext, cloudRegion, orchestrationContext,
+ serviceInstance, vnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
+
+
+ String jsonToCompare = new String(
+ Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleRequestDhcpDisabled.json")));
+
+ CreateVfModuleRequest reqMapper1 = omapper.readValue(jsonToCompare, CreateVfModuleRequest.class);
+
+ assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl"));
+ }
+
+ @Test
+ public void createVfModuleRequestMapperMultipleDhcpTest() throws Exception {
+ // prepare and set service instance
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
+ modelInfoServiceInstance.setModelName("serviceModelName");
+ modelInfoServiceInstance.setModelUuid("serviceModelUuid");
+ modelInfoServiceInstance.setModelVersion("serviceModelVersion");
+ modelInfoServiceInstance.setEnvironmentContext("environmentContext");
+ modelInfoServiceInstance.setWorkloadContext("workloadContext");
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+
+ RequestContext requestContext = new RequestContext();
+ Map<String, Object> userParams = new HashMap<>();
+ userParams.put("key1", "value1");
+ requestContext.setMsoRequestId("requestId");
+ requestContext.setUserParams(userParams);
+ requestContext.setProductFamilyId("productFamilyId");
+
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("vnfId");
+ vnf.setVnfType("vnfType");
+ vnf.setVnfName("vnfName");
+ ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
+ modelInfoGenericVnf.setModelName("vnfModelName");
+ modelInfoGenericVnf.setModelVersion("vnfModelVersion");
+ modelInfoGenericVnf.setModelUuid("vnfModelUuid");
+ modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
+ vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
+
+ Integer vfModuleIndex = 1;
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("vfModuleId");
+ vfModule.setVfModuleName("vfModuleName");
+ vfModule.setModuleIndex(vfModuleIndex);
+ ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
+ modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
+ modelInfoVfModule.setModelName("vfModuleModelName");
+ modelInfoVfModule.setModelVersion("vfModuleModelVersion");
+ modelInfoVfModule.setModelUUID("vfModuleModelUuid");
+ modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
+ vfModule.setModelInfoVfModule(modelInfoVfModule);
+
+ CloudRegion cloudRegion = new CloudRegion();
+ cloudRegion.setLcpCloudRegionId("cloudRegionId");
+ cloudRegion.setTenantId("tenantId");
+
+ OrchestrationContext orchestrationContext = new OrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(false);
+
+ String sdncVnfQueryResponse = new String(Files.readAllBytes(
+ Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopologySubnetMultipleDhcp.json")));
+ String sdncVfModuleQueryResponse = new String(Files
+ .readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
+
+ CreateVfModuleRequest vfModuleVNFAdapterRequest =
+ vfModuleObjectMapper.createVfModuleRequestMapper(requestContext, cloudRegion, orchestrationContext,
+ serviceInstance, vnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
+
+
+ String jsonToCompare = new String(
+ Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleRequestMultipleDhcp.json")));
+
+ CreateVfModuleRequest reqMapper1 = omapper.readValue(jsonToCompare, CreateVfModuleRequest.class);
+
+ assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl"));
+ }
+
+ @Test
+ public void createVfModuleRequestMapperWithNullUserParamsTest() throws Exception {
+
+ // prepare and set service instance
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
+ modelInfoServiceInstance.setModelName("serviceModelName");
+ modelInfoServiceInstance.setModelUuid("serviceModelUuid");
+ modelInfoServiceInstance.setModelVersion("serviceModelVersion");
+ modelInfoServiceInstance.setEnvironmentContext("environmentContext");
+ modelInfoServiceInstance.setWorkloadContext("workloadContext");
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+
+ RequestContext requestContext = new RequestContext();
+ requestContext.setMsoRequestId("requestId");
+ requestContext.setProductFamilyId("productFamilyId");
+
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("vnfId");
+ vnf.setVnfType("vnfType");
+ vnf.setVnfName("vnfName");
+ ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
+ modelInfoGenericVnf.setModelName("vnfModelName");
+ modelInfoGenericVnf.setModelVersion("vnfModelVersion");
+ modelInfoGenericVnf.setModelUuid("vnfModelUuid");
+ modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
+ vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
+
+ Integer vfModuleIndex = 1;
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("vfModuleId");
+ vfModule.setVfModuleName("vfModuleName");
+ vfModule.setModuleIndex(vfModuleIndex);
+ ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
+ modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
+ modelInfoVfModule.setModelName("vfModuleModelName");
+ modelInfoVfModule.setModelVersion("vfModuleModelVersion");
+ modelInfoVfModule.setModelUUID("vfModuleModelUuid");
+ modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
+ vfModule.setModelInfoVfModule(modelInfoVfModule);
+
+ CloudRegion cloudRegion = new CloudRegion();
+ cloudRegion.setLcpCloudRegionId("cloudRegionId");
+ cloudRegion.setTenantId("tenantId");
+
+ OrchestrationContext orchestrationContext = new OrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(false);
+
+ String sdncVnfQueryResponse = new String(
+ Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopology.json")));
+ String sdncVfModuleQueryResponse = new String(Files
+ .readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
+
+ CreateVfModuleRequest vfModuleVNFAdapterRequest =
+ vfModuleObjectMapper.createVfModuleRequestMapper(requestContext, cloudRegion, orchestrationContext,
+ serviceInstance, vnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
+
+
+ String jsonToCompare = new String(
+ Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleRequestNoUserParams.json")));
+
+ CreateVfModuleRequest reqMapper1 = omapper.readValue(jsonToCompare, CreateVfModuleRequest.class);
+
+ assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl"));
+ }
+
+ @Test
+ public void DeleteVfModuleRequestMapperTest() throws Exception {
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
+ modelInfoServiceInstance.setModelName("serviceModelName");
+ modelInfoServiceInstance.setModelUuid("serviceModelUuid");
+ modelInfoServiceInstance.setModelVersion("serviceModelVersion");
+ modelInfoServiceInstance.setEnvironmentContext("environmentContext");
+ modelInfoServiceInstance.setWorkloadContext("workloadContext");
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+
+ RequestContext requestContext = new RequestContext();
+ Map<String, Object> userParams = new HashMap<>();
+ userParams.put("key1", "value1");
+ requestContext.setMsoRequestId("requestId");
+ requestContext.setUserParams(userParams);
+ requestContext.setProductFamilyId("productFamilyId");
+
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("vnfId");
+ vnf.setVnfType("vnfType");
+ vnf.setVnfName("vnfName");
+ ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
+ modelInfoGenericVnf.setModelName("vnfModelName");
+ modelInfoGenericVnf.setModelVersion("vnfModelVersion");
+ modelInfoGenericVnf.setModelUuid("vnfModelUuid");
+ modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
+ vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
+
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("vfModuleId");
+ vfModule.setVfModuleName("vfModuleName");
+ ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
+ modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
+ modelInfoVfModule.setModelName("vfModuleModelName");
+ modelInfoVfModule.setModelVersion("vfModuleModelVersion");
+ modelInfoVfModule.setModelUUID("vfModuleModelUuid");
+ modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
+ vfModule.setModelInfoVfModule(modelInfoVfModule);
+
+ CloudRegion cloudRegion = new CloudRegion();
+ cloudRegion.setLcpCloudRegionId("cloudRegionId");
+ cloudRegion.setTenantId("tenantId");
+
+ OrchestrationContext orchestrationContext = new OrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(false);
+
+ DeleteVfModuleRequest vfModuleVNFAdapterRequest = vfModuleObjectMapper
+ .deleteVfModuleRequestMapper(requestContext, cloudRegion, serviceInstance, vnf, vfModule);
+
+
+ String jsonToCompare =
+ new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterDeleteVfModuleRequest.json")));
+
+ DeleteVfModuleRequest reqMapper1 = omapper.readValue(jsonToCompare, DeleteVfModuleRequest.class);
+
+ assertThat(vfModuleVNFAdapterRequest,
+ sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl").ignoring("vfModuleStackId"));
+ }
+
+ @Test
+ public void networkCloudParamsTest() throws IOException {
+
+ String json = new String(
+ Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "grApiVmNetworkSubSectionWith5GParams.json")));
+ GenericResourceApiVmNetworkData network = omapper.readValue(json, GenericResourceApiVmNetworkData.class);
+ Map<String, Object> paramsMap = new HashMap<>();
+ vfModuleObjectMapper.buildVlanInformation(paramsMap, network, "testKey", "testType");
+
+ assertEquals("1,3", paramsMap.get("testKey_testType_private_vlans"));
+ assertEquals("2,3", paramsMap.get("testKey_testType_public_vlans"));
+ assertEquals("1,2,3", paramsMap.get("testKey_testType_guest_vlans"));
+ assertEquals("my-segemntation-id", paramsMap.get("testKey_testType_vlan_filter"));
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperTest.java
index 81d30e33c5..d6ab3db094 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperTest.java
@@ -26,11 +26,9 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doNothing;
-
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
-
import org.junit.Before;
import org.junit.Test;
import org.mockito.MockitoAnnotations;
@@ -45,80 +43,81 @@ import org.onap.so.entity.MsoRequest;
public class VnfAdapterVfModuleObjectMapperTest {
- @Spy
- private VnfAdapterVfModuleObjectMapper mapper = new VnfAdapterVfModuleObjectMapper();
-
- @Before
- public void before() {
- MockitoAnnotations.initMocks(this);
- }
-
- @Test
- public void createVnfcSubInterfaceKeyTest() {
-
- assertEquals("type_0_subint_role_port_0", mapper.createVnfcSubInterfaceKey("type", 0, "role", 0));
- }
-
- @Test
- public void createGlobalVnfcSubInterfaceKeyTest() {
-
- assertEquals("type_subint_role_port_0", mapper.createGlobalVnfcSubInterfaceKey("type", "role", 0));
- }
-
- @Test
- public void addPairToMapTest() {
- Map<String, Object> map = new HashMap<>();
-
- mapper.addPairToMap(map, "test", "_key", Arrays.asList("a", "b"));
-
- assertEquals("a,b", map.get("test_key"));
-
- mapper.addPairToMap(map, "test", "_key2", Arrays.asList());
-
- assertThat(map.containsKey("test_key2"), equalTo(false));
-
- mapper.addPairToMap(map, "test", "_key3", "myVal");
-
- assertEquals("myVal", map.get("test_key3"));
-
- }
-
- @Test
- public void test_deleteVfModuleNoHeatIdRequestMapper() throws Exception {
- DeleteVfModuleRequest expectedDeleteVfModuleRequest = new DeleteVfModuleRequest();
-
- CloudRegion cloudRegion = new CloudRegion();
- cloudRegion.setLcpCloudRegionId("lcpCloudRegionId");
- expectedDeleteVfModuleRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
-
- cloudRegion.setTenantId("tenantId");
- expectedDeleteVfModuleRequest.setTenantId(cloudRegion.getTenantId());
-
- GenericVnf genericVnf = new GenericVnf();
- VfModule vfModule = new VfModule();
- vfModule.setHeatStackId("heatStackId");
- expectedDeleteVfModuleRequest.setVfModuleStackId("heatStackId");
- expectedDeleteVfModuleRequest.setSkipAAI(true);
-
- MsoRequest msoRequest = new MsoRequest();
- RequestContext requestContext = new RequestContext();
- requestContext.setMsoRequestId("msoRequestId");
- msoRequest.setRequestId(requestContext.getMsoRequestId());
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
- expectedDeleteVfModuleRequest.setMsoRequest(msoRequest);
-
- String messageId = "messageId";
- String endpoint = "endpoint";
- doNothing().when(mapper).setIdAndUrl(any());
- expectedDeleteVfModuleRequest.setMessageId(messageId);
- expectedDeleteVfModuleRequest.setNotificationUrl(endpoint + "/VNFAResponse/" + messageId);
-
- DeleteVfModuleRequest actualDeleteVfModuleRequest = mapper.deleteVfModuleRequestMapper(requestContext, cloudRegion,
- serviceInstance, genericVnf, vfModule);
-
- assertThat(actualDeleteVfModuleRequest, sameBeanAs(expectedDeleteVfModuleRequest).ignoring("messageId").ignoring("notificationUrl"));
- }
-
+ @Spy
+ private VnfAdapterVfModuleObjectMapper mapper = new VnfAdapterVfModuleObjectMapper();
+
+ @Before
+ public void before() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void createVnfcSubInterfaceKeyTest() {
+
+ assertEquals("type_0_subint_role_port_0", mapper.createVnfcSubInterfaceKey("type", 0, "role", 0));
+ }
+
+ @Test
+ public void createGlobalVnfcSubInterfaceKeyTest() {
+
+ assertEquals("type_subint_role_port_0", mapper.createGlobalVnfcSubInterfaceKey("type", "role", 0));
+ }
+
+ @Test
+ public void addPairToMapTest() {
+ Map<String, Object> map = new HashMap<>();
+
+ mapper.addPairToMap(map, "test", "_key", Arrays.asList("a", "b"));
+
+ assertEquals("a,b", map.get("test_key"));
+
+ mapper.addPairToMap(map, "test", "_key2", Arrays.asList());
+
+ assertThat(map.containsKey("test_key2"), equalTo(false));
+
+ mapper.addPairToMap(map, "test", "_key3", "myVal");
+
+ assertEquals("myVal", map.get("test_key3"));
+
+ }
+
+ @Test
+ public void test_deleteVfModuleNoHeatIdRequestMapper() throws Exception {
+ DeleteVfModuleRequest expectedDeleteVfModuleRequest = new DeleteVfModuleRequest();
+
+ CloudRegion cloudRegion = new CloudRegion();
+ cloudRegion.setLcpCloudRegionId("lcpCloudRegionId");
+ expectedDeleteVfModuleRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
+
+ cloudRegion.setTenantId("tenantId");
+ expectedDeleteVfModuleRequest.setTenantId(cloudRegion.getTenantId());
+
+ GenericVnf genericVnf = new GenericVnf();
+ VfModule vfModule = new VfModule();
+ vfModule.setHeatStackId("heatStackId");
+ expectedDeleteVfModuleRequest.setVfModuleStackId("heatStackId");
+ expectedDeleteVfModuleRequest.setSkipAAI(true);
+
+ MsoRequest msoRequest = new MsoRequest();
+ RequestContext requestContext = new RequestContext();
+ requestContext.setMsoRequestId("msoRequestId");
+ msoRequest.setRequestId(requestContext.getMsoRequestId());
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
+ expectedDeleteVfModuleRequest.setMsoRequest(msoRequest);
+
+ String messageId = "messageId";
+ String endpoint = "endpoint";
+ doNothing().when(mapper).setIdAndUrl(any());
+ expectedDeleteVfModuleRequest.setMessageId(messageId);
+ expectedDeleteVfModuleRequest.setNotificationUrl(endpoint + "/VNFAResponse/" + messageId);
+
+ DeleteVfModuleRequest actualDeleteVfModuleRequest =
+ mapper.deleteVfModuleRequestMapper(requestContext, cloudRegion, serviceInstance, genericVnf, vfModule);
+
+ assertThat(actualDeleteVfModuleRequest,
+ sameBeanAs(expectedDeleteVfModuleRequest).ignoring("messageId").ignoring("notificationUrl"));
+ }
+
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingClientResponseValidatorTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingClientResponseValidatorTest.java
index 7c58038f65..f50916c0be 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingClientResponseValidatorTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingClientResponseValidatorTest.java
@@ -21,10 +21,8 @@
package org.onap.so.client.namingservice;
import static org.junit.Assert.assertEquals;
-
import java.util.ArrayList;
import java.util.List;
-
import org.junit.Test;
import org.onap.namingservice.model.NameGenDeleteResponse;
import org.onap.namingservice.model.NameGenResponse;
@@ -35,70 +33,70 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
public class NamingClientResponseValidatorTest extends TestDataSetup {
-
- private NamingClientResponseValidator responseValidator = new NamingClientResponseValidator();
- private String instanceGroupName = "generatedInstanceGroupName";
-
- @Test
- public void validateNameGenResponseSuccessTest() throws BadResponseException {
- NameGenResponse name = new NameGenResponse();
- Respelement respElement = new Respelement();
- respElement.setResourceName("instance-group-name");
- respElement.setResourceValue(instanceGroupName);
- List<Respelement> respList = new ArrayList<Respelement>();
- respList.add(respElement);
- name.setElements(respList);
- ResponseEntity<NameGenResponse> resp = new ResponseEntity<>(name, null, HttpStatus.OK);
-
- String actual = responseValidator.validateNameGenResponse(resp);
-
- assertEquals(actual, "generatedInstanceGroupName");
- }
-
- @Test
- public void validateNameGenResponseNoNameGeneratedTest() throws BadResponseException {
- NameGenResponse name = new NameGenResponse();
- Respelement respElement = new Respelement();
- respElement.setResourceName("instance-group");
- respElement.setResourceValue(instanceGroupName);
- List<Respelement> respList = new ArrayList<Respelement>();
- respList.add(respElement);
- name.setElements(respList);
- ResponseEntity<NameGenResponse> resp = new ResponseEntity<>(name, null, HttpStatus.OK);
-
- String actual = responseValidator.validateNameGenResponse(resp);
-
- assertEquals(actual, "");
- }
-
- @Test
- public void validateNameGenResponseBadStatusTest() throws BadResponseException {
- NameGenResponse name = new NameGenResponse();
-
- ResponseEntity<NameGenResponse> resp = new ResponseEntity<>(name, null, HttpStatus.NOT_FOUND);
-
- expectedException.expect(BadResponseException.class);
- responseValidator.validateNameGenResponse(resp);
- }
-
- @Test
- public void validateNameGenDeleteResponseSuccessTest() throws BadResponseException {
- NameGenDeleteResponse name = new NameGenDeleteResponse();
- ResponseEntity<NameGenDeleteResponse> resp = new ResponseEntity<>(name, null, HttpStatus.OK);
-
- String actual = responseValidator.validateNameGenDeleteResponse(resp);
-
- assertEquals(actual, "");
- }
-
- @Test
- public void validateNameGenDeleteResponseBadStatusTest() throws BadResponseException {
- NameGenDeleteResponse name = new NameGenDeleteResponse();
-
- ResponseEntity<NameGenDeleteResponse> resp = new ResponseEntity<>(name, null, HttpStatus.NOT_FOUND);
-
- expectedException.expect(BadResponseException.class);
- responseValidator.validateNameGenDeleteResponse(resp);
- }
-
+
+ private NamingClientResponseValidator responseValidator = new NamingClientResponseValidator();
+ private String instanceGroupName = "generatedInstanceGroupName";
+
+ @Test
+ public void validateNameGenResponseSuccessTest() throws BadResponseException {
+ NameGenResponse name = new NameGenResponse();
+ Respelement respElement = new Respelement();
+ respElement.setResourceName("instance-group-name");
+ respElement.setResourceValue(instanceGroupName);
+ List<Respelement> respList = new ArrayList<Respelement>();
+ respList.add(respElement);
+ name.setElements(respList);
+ ResponseEntity<NameGenResponse> resp = new ResponseEntity<>(name, null, HttpStatus.OK);
+
+ String actual = responseValidator.validateNameGenResponse(resp);
+
+ assertEquals(actual, "generatedInstanceGroupName");
+ }
+
+ @Test
+ public void validateNameGenResponseNoNameGeneratedTest() throws BadResponseException {
+ NameGenResponse name = new NameGenResponse();
+ Respelement respElement = new Respelement();
+ respElement.setResourceName("instance-group");
+ respElement.setResourceValue(instanceGroupName);
+ List<Respelement> respList = new ArrayList<Respelement>();
+ respList.add(respElement);
+ name.setElements(respList);
+ ResponseEntity<NameGenResponse> resp = new ResponseEntity<>(name, null, HttpStatus.OK);
+
+ String actual = responseValidator.validateNameGenResponse(resp);
+
+ assertEquals(actual, "");
+ }
+
+ @Test
+ public void validateNameGenResponseBadStatusTest() throws BadResponseException {
+ NameGenResponse name = new NameGenResponse();
+
+ ResponseEntity<NameGenResponse> resp = new ResponseEntity<>(name, null, HttpStatus.NOT_FOUND);
+
+ expectedException.expect(BadResponseException.class);
+ responseValidator.validateNameGenResponse(resp);
+ }
+
+ @Test
+ public void validateNameGenDeleteResponseSuccessTest() throws BadResponseException {
+ NameGenDeleteResponse name = new NameGenDeleteResponse();
+ ResponseEntity<NameGenDeleteResponse> resp = new ResponseEntity<>(name, null, HttpStatus.OK);
+
+ String actual = responseValidator.validateNameGenDeleteResponse(resp);
+
+ assertEquals(actual, "");
+ }
+
+ @Test
+ public void validateNameGenDeleteResponseBadStatusTest() throws BadResponseException {
+ NameGenDeleteResponse name = new NameGenDeleteResponse();
+
+ ResponseEntity<NameGenDeleteResponse> resp = new ResponseEntity<>(name, null, HttpStatus.NOT_FOUND);
+
+ expectedException.expect(BadResponseException.class);
+ responseValidator.validateNameGenDeleteResponse(resp);
+ }
+
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingClientTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingClientTest.java
index 4bae5b40e4..8a387a88a4 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingClientTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingClientTest.java
@@ -25,11 +25,9 @@ import static com.github.tomakehurst.wiremock.client.WireMock.delete;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static org.junit.Assert.assertTrue;
-
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
-
import org.apache.http.HttpStatus;
import org.junit.Rule;
import org.junit.Test;
@@ -41,78 +39,78 @@ import org.onap.namingservice.model.NameGenRequest;
import org.onap.so.BaseIntegrationTest;
import org.onap.so.client.exception.BadResponseException;
import org.springframework.beans.factory.annotation.Autowired;
-
import com.fasterxml.jackson.core.JsonProcessingException;
-public class NamingClientTest extends BaseIntegrationTest{
- @Autowired
- NamingClient client;
- @Autowired
- NamingRequestObjectBuilder requestBuilder;
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- @Test
- public void assignNameGenRequest() throws BadResponseException, IOException{
- wireMockServer.stubFor(post(urlPathEqualTo("/web/service/v1/genNetworkElementName"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("NamingClient/AssignResponse.json")
- .withStatus(HttpStatus.SC_ACCEPTED)));
-
- NameGenRequest request = assignSetup();
- String response = client.postNameGenRequest(request);
- assertTrue(response.equals("$vnf-name"));
- }
- @Test
- public void assignNameGenRequestError() throws BadResponseException, IOException{
- wireMockServer.stubFor(post(urlPathEqualTo("/web/service/v1/genNetworkElementName"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("NamingClient/ErrorResponse.json")
- .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
-
- thrown.expect(BadResponseException.class);
- thrown.expectMessage("Error from Naming Service: External Key is required and must be unique");
- NameGenRequest request = assignSetup();
- client.postNameGenRequest(request);
- }
- @Test
- public void unassignNameGenRequest() throws BadResponseException, IOException{
- wireMockServer.stubFor(delete(urlPathEqualTo("/web/service/v1/genNetworkElementName"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("NamingClient/UnassignResponse.json")
- .withStatus(HttpStatus.SC_ACCEPTED)));
-
- String response = client.deleteNameGenRequest(unassignSetup());
- assertTrue(response.equals(""));
- }
- @Test
- public void unassignNameGenRequestError() throws BadResponseException, IOException{
- wireMockServer.stubFor(delete(urlPathEqualTo("/web/service/v1/genNetworkElementName"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("NamingClient/ErrorResponse.json")
- .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
-
- thrown.expect(BadResponseException.class);
- thrown.expectMessage("Error from Naming Service: External Key is required and must be unique");
- client.deleteNameGenRequest(unassignSetup());
- }
-
- public NameGenRequest assignSetup() throws JsonProcessingException{
- NameGenRequest request = new NameGenRequest();
- List<Element> elements = new ArrayList<>();
- Element testElement = new Element();
- testElement = requestBuilder.elementMapper("SomeUniqueValue", "SDNC_Policy.Config_MS_1806SRIOV_VNATJson.4.xml", "VNF", "nfNamingCode", "vnf_name");
- elements.add(testElement);
- request = requestBuilder.nameGenRequestMapper(elements);
- return request;
- }
- public NameGenDeleteRequest unassignSetup() throws JsonProcessingException{
- NameGenDeleteRequest request = new NameGenDeleteRequest();
- List<Deleteelement> deleteElements = new ArrayList<>();
- Deleteelement testElement = new Deleteelement();
- testElement = requestBuilder.deleteElementMapper("instanceGroupId");
- deleteElements.add(testElement);
- request = requestBuilder.nameGenDeleteRequestMapper(deleteElements);
- return request;
- }
+public class NamingClientTest extends BaseIntegrationTest {
+ @Autowired
+ NamingClient client;
+ @Autowired
+ NamingRequestObjectBuilder requestBuilder;
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ @Test
+ public void assignNameGenRequest() throws BadResponseException, IOException {
+ wireMockServer.stubFor(post(urlPathEqualTo("/web/service/v1/genNetworkElementName"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("NamingClient/AssignResponse.json").withStatus(HttpStatus.SC_ACCEPTED)));
+
+ NameGenRequest request = assignSetup();
+ String response = client.postNameGenRequest(request);
+ assertTrue(response.equals("$vnf-name"));
+ }
+
+ @Test
+ public void assignNameGenRequestError() throws BadResponseException, IOException {
+ wireMockServer.stubFor(post(urlPathEqualTo("/web/service/v1/genNetworkElementName")).willReturn(aResponse()
+ .withHeader("Content-Type", "application/json").withBodyFile("NamingClient/ErrorResponse.json")
+ .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
+
+ thrown.expect(BadResponseException.class);
+ thrown.expectMessage("Error from Naming Service: External Key is required and must be unique");
+ NameGenRequest request = assignSetup();
+ client.postNameGenRequest(request);
+ }
+
+ @Test
+ public void unassignNameGenRequest() throws BadResponseException, IOException {
+ wireMockServer.stubFor(delete(urlPathEqualTo("/web/service/v1/genNetworkElementName"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("NamingClient/UnassignResponse.json").withStatus(HttpStatus.SC_ACCEPTED)));
+
+ String response = client.deleteNameGenRequest(unassignSetup());
+ assertTrue(response.equals(""));
+ }
+
+ @Test
+ public void unassignNameGenRequestError() throws BadResponseException, IOException {
+ wireMockServer.stubFor(delete(urlPathEqualTo("/web/service/v1/genNetworkElementName")).willReturn(aResponse()
+ .withHeader("Content-Type", "application/json").withBodyFile("NamingClient/ErrorResponse.json")
+ .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
+
+ thrown.expect(BadResponseException.class);
+ thrown.expectMessage("Error from Naming Service: External Key is required and must be unique");
+ client.deleteNameGenRequest(unassignSetup());
+ }
+
+ public NameGenRequest assignSetup() throws JsonProcessingException {
+ NameGenRequest request = new NameGenRequest();
+ List<Element> elements = new ArrayList<>();
+ Element testElement = new Element();
+ testElement = requestBuilder.elementMapper("SomeUniqueValue", "SDNC_Policy.Config_MS_1806SRIOV_VNATJson.4.xml",
+ "VNF", "nfNamingCode", "vnf_name");
+ elements.add(testElement);
+ request = requestBuilder.nameGenRequestMapper(elements);
+ return request;
+ }
+
+ public NameGenDeleteRequest unassignSetup() throws JsonProcessingException {
+ NameGenDeleteRequest request = new NameGenDeleteRequest();
+ List<Deleteelement> deleteElements = new ArrayList<>();
+ Deleteelement testElement = new Deleteelement();
+ testElement = requestBuilder.deleteElementMapper("instanceGroupId");
+ deleteElements.add(testElement);
+ request = requestBuilder.nameGenDeleteRequestMapper(deleteElements);
+ return request;
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingRequestObjectBuilderTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingRequestObjectBuilderTest.java
index 6cb4987bee..bec588b6d3 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingRequestObjectBuilderTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingRequestObjectBuilderTest.java
@@ -22,10 +22,8 @@ package org.onap.so.client.namingservice;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertThat;
-
import java.util.ArrayList;
import java.util.List;
-
import org.junit.Test;
import org.onap.namingservice.model.Deleteelement;
import org.onap.namingservice.model.Element;
@@ -34,72 +32,76 @@ import org.onap.namingservice.model.NameGenRequest;
import org.onap.so.client.namingservice.NamingRequestObjectBuilder;
public class NamingRequestObjectBuilderTest {
-
- private NamingRequestObjectBuilder mapper = new NamingRequestObjectBuilder();
- private String instanceGroupId = "95cbbe59-1017-4c13-b4e8-d824e54def3e";
- private String policyInstanceName = "MSO_Policy.Config_MS_VNFInstanceGroup";
- private String namingType = "InstanceGroup";
- private String nfNamingCode = "NamingCode";
- private String instanceGroupName = "InstanceGroupName";
-
- @Test
- public void elementMapperTest(){
- // Expected element
- Element expected = new Element();
- expected.put("external-key", instanceGroupId);
- expected.put("policy-instance-name", policyInstanceName);
- expected.put("naming-type", namingType);
- expected.put("resource-name", instanceGroupName);
- expected.put("nf-naming-code", nfNamingCode);
-
- // Actual element
- Element actual = mapper.elementMapper(instanceGroupId, policyInstanceName, namingType, nfNamingCode, instanceGroupName);
-
- assertThat(actual, sameBeanAs(expected));
- }
- @Test
- public void deleteElementMapperTest(){
- // Expected Deleteelement
- Deleteelement expected = new Deleteelement();
- expected.setExternalKey(instanceGroupId);
-
- // Actual Deleteelement
- Deleteelement actual = mapper.deleteElementMapper(instanceGroupId);
-
- assertThat(actual, sameBeanAs(expected));
- }
- @Test
- public void nameGenRequestMapper(){
- // Expected NameGenRequest
- NameGenRequest expected = new NameGenRequest();
- List<Element> elements = new ArrayList<>();
- Element element = new Element();
- element.setExternalKey(instanceGroupId);
- element.setPolicyInstanceName(policyInstanceName);
- element.setNamingType(namingType);
- element.setResourceName(instanceGroupName);
- element.setNamingIngredientsZeroOrMore(nfNamingCode);
- elements.add(element);
- expected.setElements(elements);
-
- //Actual NameGenRequest
- NameGenRequest actual = mapper.nameGenRequestMapper(elements);
-
- assertThat(actual, sameBeanAs(expected));
- }
- @Test
- public void nameGenDeleteRequestMapper(){
- // Expected NameGenDeleteRequest
- NameGenDeleteRequest expected = new NameGenDeleteRequest();
- List<Deleteelement> deleteElements = new ArrayList<>();
- Deleteelement deleteElement = new Deleteelement();
- deleteElement.setExternalKey(instanceGroupId);
- deleteElements.add(deleteElement);
- expected.setElements(deleteElements);
-
- // Actual NameGenDeleteRequest
- NameGenDeleteRequest actual = mapper.nameGenDeleteRequestMapper(deleteElements);
-
- assertThat(actual, sameBeanAs(expected));
- }
+
+ private NamingRequestObjectBuilder mapper = new NamingRequestObjectBuilder();
+ private String instanceGroupId = "95cbbe59-1017-4c13-b4e8-d824e54def3e";
+ private String policyInstanceName = "MSO_Policy.Config_MS_VNFInstanceGroup";
+ private String namingType = "InstanceGroup";
+ private String nfNamingCode = "NamingCode";
+ private String instanceGroupName = "InstanceGroupName";
+
+ @Test
+ public void elementMapperTest() {
+ // Expected element
+ Element expected = new Element();
+ expected.put("external-key", instanceGroupId);
+ expected.put("policy-instance-name", policyInstanceName);
+ expected.put("naming-type", namingType);
+ expected.put("resource-name", instanceGroupName);
+ expected.put("nf-naming-code", nfNamingCode);
+
+ // Actual element
+ Element actual =
+ mapper.elementMapper(instanceGroupId, policyInstanceName, namingType, nfNamingCode, instanceGroupName);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void deleteElementMapperTest() {
+ // Expected Deleteelement
+ Deleteelement expected = new Deleteelement();
+ expected.setExternalKey(instanceGroupId);
+
+ // Actual Deleteelement
+ Deleteelement actual = mapper.deleteElementMapper(instanceGroupId);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void nameGenRequestMapper() {
+ // Expected NameGenRequest
+ NameGenRequest expected = new NameGenRequest();
+ List<Element> elements = new ArrayList<>();
+ Element element = new Element();
+ element.setExternalKey(instanceGroupId);
+ element.setPolicyInstanceName(policyInstanceName);
+ element.setNamingType(namingType);
+ element.setResourceName(instanceGroupName);
+ element.setNamingIngredientsZeroOrMore(nfNamingCode);
+ elements.add(element);
+ expected.setElements(elements);
+
+ // Actual NameGenRequest
+ NameGenRequest actual = mapper.nameGenRequestMapper(elements);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void nameGenDeleteRequestMapper() {
+ // Expected NameGenDeleteRequest
+ NameGenDeleteRequest expected = new NameGenDeleteRequest();
+ List<Deleteelement> deleteElements = new ArrayList<>();
+ Deleteelement deleteElement = new Deleteelement();
+ deleteElement.setExternalKey(instanceGroupId);
+ deleteElements.add(deleteElement);
+ expected.setElements(deleteElements);
+
+ // Actual NameGenDeleteRequest
+ NameGenDeleteRequest actual = mapper.nameGenDeleteRequestMapper(deleteElements);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/oof/OofClientTestIT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/oof/OofClientTestIT.java
index c4e50412a9..ce7d557254 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/oof/OofClientTestIT.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/oof/OofClientTestIT.java
@@ -24,7 +24,6 @@ import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static org.junit.Assert.assertEquals;
-
import org.junit.Test;
import org.onap.so.BaseIntegrationTest;
import org.onap.so.client.exception.BadResponseException;
@@ -38,9 +37,7 @@ import org.onap.so.client.oof.beans.ResourceModelInfo;
import org.onap.so.client.oof.beans.ServiceInfo;
import org.onap.so.client.oof.beans.SubscriberInfo;
import org.springframework.beans.factory.annotation.Autowired;
-
import com.fasterxml.jackson.core.JsonProcessingException;
-
import java.util.ArrayList;
import java.util.List;
@@ -52,7 +49,8 @@ public class OofClientTestIT extends BaseIntegrationTest {
@Test
public void testPostDemands_success() throws BadResponseException, JsonProcessingException {
- String mockResponse = "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"status\", \"requestStatus\": \"accepted\"}";
+ String mockResponse =
+ "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"status\", \"requestStatus\": \"accepted\"}";
ModelInfo modelInfo = new ModelInfo();
modelInfo.setModelCustomizationName("modelCustomizationName-Service");
@@ -118,102 +116,73 @@ public class OofClientTestIT extends BaseIntegrationTest {
oofRequest.setServiceInformation(serviceInfo);
oofRequest.setLicenseInformation("");
- wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement"))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBody(mockResponse)));
+ wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
client.postDemands(oofRequest);
String oofRequestOutput = oofRequest.toJsonString();
- assertEquals("{\n" +
- " \"requestInfo\" : {\n" +
- " \"transactionId\" : \"transactionId\",\n" +
- " \"requestId\" : \"requestId\",\n" +
- " \"callbackUrl\" : \"callBackUrl\",\n" +
- " \"sourceId\" : \"sourceId\",\n" +
- " \"requestType\" : \"requestType\",\n" +
- " \"numSolutions\" : 1,\n" +
- " \"optimizers\" : [ \"optimizer1\", \"optimizer2\" ],\n" +
- " \"timeout\" : 30\n" +
- " },\n" +
- " \"serviceInfo\" : {\n" +
- " \"serviceInstanceId\" : \"serviceInstanceId\",\n" +
- " \"serviceName\" : \"serviceName\",\n" +
- " \"modelInfo\" : {\n" +
- " \"modelType\" : \"modelType-Service\",\n" +
- " \"modelInvariantId\" : \"modelInvariantId-Service\",\n" +
- " \"modelVersionId\" : \"modelVersionId-Service\",\n" +
- " \"modelName\" : \"modelName-Service\",\n" +
- " \"modelVersion\" : \"modelVersion-Service\",\n" +
- " \"modelCustomizationName\" : \"modelCustomizationName-Service\"\n" +
- " }\n" +
- " },\n" +
- " \"placementInfo\" : {\n" +
- " \"requestParameters\" : {\n" +
- " \"customerLatitude\" : \"customerLatitude\",\n" +
- " \"customerLongitude\" : \"customerLongitude\",\n" +
- " \"customerName\" : \"customerName\"\n" +
- " },\n" +
- " \"subscriberInfo\" : {\n" +
- " \"globalSubscriberId\" : \"globalSubscriberId\",\n" +
- " \"subscriberName\" : \"subscriberName\",\n" +
- " \"subscriberCommonSiteId\" : \"subscriberCommonSiteId\"\n" +
- " },\n" +
- " \"placementDemands\" : [ {\n" +
- " \"resourceModuleName\" : \"resourceModuleName\",\n" +
- " \"serviceResourceId\" : \"serviceResourceId\",\n" +
- " \"tenantId\" : \"tenantId\",\n" +
- " \"resourceModelInfo\" : {\n" +
- " \"modelType\" : \"modelType\",\n" +
- " \"modelInvariantId\" : \"invarianteId\",\n" +
- " \"modelVersionId\" : \"versionId\",\n" +
- " \"modelName\" : \"modelName\",\n" +
- " \"modelVersion\" : \"version\",\n" +
- " \"modelCustomizationName\" : \"modelCustomizationName\"\n" +
- " }\n" +
- " } ]\n" +
- " },\n" +
- " \"licenseInfo\" : \"\"\n" +
- "}", oofRequestOutput);
+ assertEquals("{\n" + " \"requestInfo\" : {\n" + " \"transactionId\" : \"transactionId\",\n"
+ + " \"requestId\" : \"requestId\",\n" + " \"callbackUrl\" : \"callBackUrl\",\n"
+ + " \"sourceId\" : \"sourceId\",\n" + " \"requestType\" : \"requestType\",\n"
+ + " \"numSolutions\" : 1,\n" + " \"optimizers\" : [ \"optimizer1\", \"optimizer2\" ],\n"
+ + " \"timeout\" : 30\n" + " },\n" + " \"serviceInfo\" : {\n"
+ + " \"serviceInstanceId\" : \"serviceInstanceId\",\n" + " \"serviceName\" : \"serviceName\",\n"
+ + " \"modelInfo\" : {\n" + " \"modelType\" : \"modelType-Service\",\n"
+ + " \"modelInvariantId\" : \"modelInvariantId-Service\",\n"
+ + " \"modelVersionId\" : \"modelVersionId-Service\",\n"
+ + " \"modelName\" : \"modelName-Service\",\n"
+ + " \"modelVersion\" : \"modelVersion-Service\",\n"
+ + " \"modelCustomizationName\" : \"modelCustomizationName-Service\"\n" + " }\n" + " },\n"
+ + " \"placementInfo\" : {\n" + " \"requestParameters\" : {\n"
+ + " \"customerLatitude\" : \"customerLatitude\",\n"
+ + " \"customerLongitude\" : \"customerLongitude\",\n"
+ + " \"customerName\" : \"customerName\"\n" + " },\n" + " \"subscriberInfo\" : {\n"
+ + " \"globalSubscriberId\" : \"globalSubscriberId\",\n"
+ + " \"subscriberName\" : \"subscriberName\",\n"
+ + " \"subscriberCommonSiteId\" : \"subscriberCommonSiteId\"\n" + " },\n"
+ + " \"placementDemands\" : [ {\n" + " \"resourceModuleName\" : \"resourceModuleName\",\n"
+ + " \"serviceResourceId\" : \"serviceResourceId\",\n" + " \"tenantId\" : \"tenantId\",\n"
+ + " \"resourceModelInfo\" : {\n" + " \"modelType\" : \"modelType\",\n"
+ + " \"modelInvariantId\" : \"invarianteId\",\n" + " \"modelVersionId\" : \"versionId\",\n"
+ + " \"modelName\" : \"modelName\",\n" + " \"modelVersion\" : \"version\",\n"
+ + " \"modelCustomizationName\" : \"modelCustomizationName\"\n" + " }\n" + " } ]\n"
+ + " },\n" + " \"licenseInfo\" : \"\"\n" + "}", oofRequestOutput);
}
@Test
public void testAsyncResponse_success() throws BadResponseException, JsonProcessingException {
- String mockResponse = "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"status\", \"requestStatus\": \"accepted\"}";
+ String mockResponse =
+ "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"status\", \"requestStatus\": \"accepted\"}";
- wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement"))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBody(mockResponse)));
+ wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
client.postDemands(new OofRequest());
}
@Test(expected = BadResponseException.class)
public void testPostDemands_error_failed() throws JsonProcessingException, BadResponseException {
- String mockResponse = "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"missing data\", \"requestStatus\": \"failed\"}";
+ String mockResponse =
+ "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"missing data\", \"requestStatus\": \"failed\"}";
- wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement"))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBody(mockResponse)));
+ wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
client.postDemands(new OofRequest());
- //TODO assertEquals("missing data", );
+ // TODO assertEquals("missing data", );
}
@Test(expected = BadResponseException.class)
public void testPostDemands_error_noMessage() throws JsonProcessingException, BadResponseException {
- String mockResponse = "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"\", \"requestStatus\": \"failed\"}";
+ String mockResponse =
+ "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"\", \"requestStatus\": \"failed\"}";
- wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement"))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBody(mockResponse)));
+ wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
client.postDemands(new OofRequest());
@@ -222,12 +191,11 @@ public class OofClientTestIT extends BaseIntegrationTest {
@Test(expected = BadResponseException.class)
public void testPostDemands_error_noStatus() throws JsonProcessingException, BadResponseException {
- String mockResponse = "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"missing data\", \"requestStatus\": null}";
+ String mockResponse =
+ "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"missing data\", \"requestStatus\": null}";
- wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement"))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBody(mockResponse)));
+ wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
client.postDemands(new OofRequest());
@@ -238,10 +206,8 @@ public class OofClientTestIT extends BaseIntegrationTest {
public void testPostDemands_error_empty() throws JsonProcessingException, BadResponseException {
String mockResponse = "{ }";
- wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement"))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBody(mockResponse)));
+ wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
client.postDemands(new OofRequest());
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAICollectionResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAICollectionResourcesTest.java
index 8bf3de5c4e..7c40995d48 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAICollectionResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAICollectionResourcesTest.java
@@ -26,7 +26,6 @@ import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -43,42 +42,47 @@ import org.onap.so.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.client.aai.mapper.AAIObjectMapper;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
-public class AAICollectionResourcesTest extends BaseTaskTest{
-
- @InjectMocks
- private AAICollectionResources aaiCollectionResources = new AAICollectionResources();
-
-
- private Collection networkCollection;
-
- @Before
- public void before() {
- networkCollection = buildCollection();
- doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
- }
-
- @Test
- public void createCollectionTest() throws Exception {
- networkCollection.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
- doReturn(new org.onap.aai.domain.yang.Collection()).when(MOCK_aaiObjectMapper).mapCollection(networkCollection);
-
- aaiCollectionResources.createCollection(networkCollection);
-
- assertEquals(OrchestrationStatus.INVENTORIED, networkCollection.getOrchestrationStatus());
- verify(MOCK_aaiResourcesClient, times(1)).create(eq(AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, networkCollection.getId())), isA(org.onap.aai.domain.yang.Collection.class));
- }
-
- @Test
- public void updateCollectionTest() throws Exception {
- doReturn(new org.onap.aai.domain.yang.Collection()).when(MOCK_aaiObjectMapper).mapCollection(networkCollection);
- aaiCollectionResources.updateCollection(networkCollection);
- verify(MOCK_aaiResourcesClient, times(1)).update(eq(AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, networkCollection.getId())), isA(org.onap.aai.domain.yang.Collection.class));
- }
-
- @Test
- public void deleteCollectionTest() throws Exception {
- aaiCollectionResources.deleteCollection(networkCollection);
- verify(MOCK_aaiResourcesClient, times(1)).delete(eq(AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, networkCollection.getId())));
- }
-
+public class AAICollectionResourcesTest extends BaseTaskTest {
+
+ @InjectMocks
+ private AAICollectionResources aaiCollectionResources = new AAICollectionResources();
+
+
+ private Collection networkCollection;
+
+ @Before
+ public void before() {
+ networkCollection = buildCollection();
+ doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
+ }
+
+ @Test
+ public void createCollectionTest() throws Exception {
+ networkCollection.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
+ doReturn(new org.onap.aai.domain.yang.Collection()).when(MOCK_aaiObjectMapper).mapCollection(networkCollection);
+
+ aaiCollectionResources.createCollection(networkCollection);
+
+ assertEquals(OrchestrationStatus.INVENTORIED, networkCollection.getOrchestrationStatus());
+ verify(MOCK_aaiResourcesClient, times(1)).create(
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, networkCollection.getId())),
+ isA(org.onap.aai.domain.yang.Collection.class));
+ }
+
+ @Test
+ public void updateCollectionTest() throws Exception {
+ doReturn(new org.onap.aai.domain.yang.Collection()).when(MOCK_aaiObjectMapper).mapCollection(networkCollection);
+ aaiCollectionResources.updateCollection(networkCollection);
+ verify(MOCK_aaiResourcesClient, times(1)).update(
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, networkCollection.getId())),
+ isA(org.onap.aai.domain.yang.Collection.class));
+ }
+
+ @Test
+ public void deleteCollectionTest() throws Exception {
+ aaiCollectionResources.deleteCollection(networkCollection);
+ verify(MOCK_aaiResourcesClient, times(1))
+ .delete(eq(AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, networkCollection.getId())));
+ }
+
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIConfigurationResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIConfigurationResourcesTest.java
index 4bf445949a..2e1a40dd22 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIConfigurationResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIConfigurationResourcesTest.java
@@ -27,9 +27,7 @@ import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import java.util.Optional;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -57,32 +55,32 @@ import org.onap.so.bpmn.common.data.TestDataSetup;
@RunWith(MockitoJUnitRunner.Silent.class)
-public class AAIConfigurationResourcesTest extends TestDataSetup{
-
-
-
- private Configuration configuration;
+public class AAIConfigurationResourcesTest extends TestDataSetup {
+
+
+
+ private Configuration configuration;
private ServiceProxy serviceProxy;
private ServiceInstance serviceInstance;
private GenericVnf genericVnf;
private VpnBinding vpnBinding;
private VfModule vfModule;
-
- @Mock
- protected AAIResourcesClient MOCK_aaiResourcesClient;
-
+
+ @Mock
+ protected AAIResourcesClient MOCK_aaiResourcesClient;
+
@Mock
protected AAIObjectMapper MOCK_aaiObjectMapper;
-
+
@Mock
protected InjectionHelper MOCK_injectionHelper;
-
+
@InjectMocks
- private AAIConfigurationResources aaiConfigurationResources = new AAIConfigurationResources();
-
+ private AAIConfigurationResources aaiConfigurationResources = new AAIConfigurationResources();
+
@Before
public void before() {
- configuration = buildConfiguration();
+ configuration = buildConfiguration();
serviceProxy = buildServiceProxy();
serviceInstance = buildServiceInstance();
genericVnf = buildGenericVnf();
@@ -90,62 +88,73 @@ public class AAIConfigurationResourcesTest extends TestDataSetup{
vpnBinding = buildVpnBinding();
doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
}
-
+
@Test
public void createConfigurationTest() {
- doReturn(new org.onap.aai.domain.yang.Configuration()).when(MOCK_aaiObjectMapper).mapConfiguration(configuration);
- doNothing().when(MOCK_aaiResourcesClient).create(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.Configuration.class));
-
+ doReturn(new org.onap.aai.domain.yang.Configuration()).when(MOCK_aaiObjectMapper)
+ .mapConfiguration(configuration);
+ doNothing().when(MOCK_aaiResourcesClient).create(isA(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.Configuration.class));
+
aaiConfigurationResources.createConfiguration(configuration);
-
+
assertEquals(OrchestrationStatus.ASSIGNED, configuration.getOrchestrationStatus());
- verify(MOCK_aaiResourcesClient, times(1)).create(any(AAIResourceUri.class), isA(org.onap.aai.domain.yang.Configuration.class));
+ verify(MOCK_aaiResourcesClient, times(1)).create(any(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.Configuration.class));
}
@Test
- public void updateConfigurationTest() {
- doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.Configuration.class));
+ public void updateConfigurationTest() {
+ doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.Configuration.class));
configuration.setConfigurationType("VNR");
configuration.setOrchestrationStatus(OrchestrationStatus.ACTIVE);
aaiConfigurationResources.updateConfiguration(configuration);
- verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class),ArgumentMatchers.isNull());
+ verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), ArgumentMatchers.isNull());
}
@Test
public void connectConfigurationToServiceInstanceTest() {
doNothing().when(MOCK_aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class));
- aaiConfigurationResources.connectConfigurationToServiceInstance(configuration.getConfigurationId(), serviceInstance.getServiceInstanceId());
+ aaiConfigurationResources.connectConfigurationToServiceInstance(configuration.getConfigurationId(),
+ serviceInstance.getServiceInstanceId());
verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
}
-
+
@Test
public void connectConfigurationToServiceInstanceWithEdgeTest() {
- doNothing().when(MOCK_aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class), any(AAIEdgeLabel.class));
- aaiConfigurationResources.connectConfigurationToServiceInstance(configuration.getConfigurationId(), serviceInstance.getServiceInstanceId(), AAIEdgeLabel.USES);
- verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class), any(AAIEdgeLabel.class));
+ doNothing().when(MOCK_aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class),
+ any(AAIEdgeLabel.class));
+ aaiConfigurationResources.connectConfigurationToServiceInstance(configuration.getConfigurationId(),
+ serviceInstance.getServiceInstanceId(), AAIEdgeLabel.USES);
+ verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class),
+ any(AAIEdgeLabel.class));
}
-
+
@Test
- public void disconnectConfigurationToServiceInstanceTest(){
+ public void disconnectConfigurationToServiceInstanceTest() {
doNothing().when(MOCK_aaiResourcesClient).disconnect(isA(AAIResourceUri.class), isA(AAIResourceUri.class));
- aaiConfigurationResources.disconnectConfigurationToServiceInstance("TEST_CONFIGURATION_ID", "TEST_SERVICE_INSTANCE_ID");
+ aaiConfigurationResources.disconnectConfigurationToServiceInstance("TEST_CONFIGURATION_ID",
+ "TEST_SERVICE_INSTANCE_ID");
verify(MOCK_aaiResourcesClient, times(1)).disconnect(any(AAIResourceUri.class), any(AAIResourceUri.class));
}
@Test
public void connectConfigurationToGenericVnfTest() {
doNothing().when(MOCK_aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class));
- aaiConfigurationResources.connectConfigurationToGenericVnf(configuration.getConfigurationId(), genericVnf.getVnfId());
+ aaiConfigurationResources.connectConfigurationToGenericVnf(configuration.getConfigurationId(),
+ genericVnf.getVnfId());
verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
}
-
+
@Test
public void connectConfigurationToVfModuleTest() {
doNothing().when(MOCK_aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class));
- aaiConfigurationResources.connectConfigurationToVfModule(configuration.getConfigurationId(), vfModule.getVfModuleId(),genericVnf.getVnfId());
+ aaiConfigurationResources.connectConfigurationToVfModule(configuration.getConfigurationId(),
+ vfModule.getVfModuleId(), genericVnf.getVnfId());
verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
}
-
+
@Test
public void connectConfigurationToVnfcTest() {
doNothing().when(MOCK_aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class));
@@ -156,17 +165,22 @@ public class AAIConfigurationResourcesTest extends TestDataSetup{
@Test
public void connectConfigurationToVpnBindingTest() {
doNothing().when(MOCK_aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class));
- aaiConfigurationResources.connectConfigurationToVpnBinding(configuration.getConfigurationId(), vpnBinding.getVpnId());
+ aaiConfigurationResources.connectConfigurationToVpnBinding(configuration.getConfigurationId(),
+ vpnBinding.getVpnId());
verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
}
@Test
- public void getConfigurationFromRelatedLinkTest () {
- Optional<org.onap.aai.domain.yang.Configuration> configuration = Optional.of(new org.onap.aai.domain.yang.Configuration());
+ public void getConfigurationFromRelatedLinkTest() {
+ Optional<org.onap.aai.domain.yang.Configuration> configuration =
+ Optional.of(new org.onap.aai.domain.yang.Configuration());
configuration.get().setConfigurationId("config1");
- doReturn(configuration).when(MOCK_aaiResourcesClient).get(eq(org.onap.aai.domain.yang.Configuration.class),isA(AAIResourceUri.class));
- aaiConfigurationResources.getConfigurationFromRelatedLink("http://localhost:8090/aai/v12/network/configurations/configuration/config1");
- verify(MOCK_aaiResourcesClient, times(1)).get(eq(org.onap.aai.domain.yang.Configuration.class),isA(AAIResourceUri.class));
+ doReturn(configuration).when(MOCK_aaiResourcesClient).get(eq(org.onap.aai.domain.yang.Configuration.class),
+ isA(AAIResourceUri.class));
+ aaiConfigurationResources.getConfigurationFromRelatedLink(
+ "http://localhost:8090/aai/v12/network/configurations/configuration/config1");
+ verify(MOCK_aaiResourcesClient, times(1)).get(eq(org.onap.aai.domain.yang.Configuration.class),
+ isA(AAIResourceUri.class));
}
@Test
@@ -174,24 +188,28 @@ public class AAIConfigurationResourcesTest extends TestDataSetup{
Configuration vrfConfiguration = buildConfiguration();
Configuration vnrConfiguration = buildConfiguration();
doNothing().when(MOCK_aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class));
- aaiConfigurationResources.connectVrfConfigurationToVnrConfiguration(vrfConfiguration.getConfigurationId(),vnrConfiguration.getConfigurationId());
+ aaiConfigurationResources.connectVrfConfigurationToVnrConfiguration(vrfConfiguration.getConfigurationId(),
+ vnrConfiguration.getConfigurationId());
verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
}
@Test
public void connectConfigurationToPnfObjectTest() throws Exception {
doNothing().when(MOCK_aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class));
-
- Pnf primaryPnf = serviceProxy.getServiceInstance().getPnfs().stream().filter(o -> o.getRole().equals("Primary")).findFirst().get();
-
- aaiConfigurationResources.connectConfigurationToPnfObject(primaryPnf.getPnfId(), configuration.getConfigurationId());
+
+ Pnf primaryPnf = serviceProxy.getServiceInstance().getPnfs().stream().filter(o -> o.getRole().equals("Primary"))
+ .findFirst().get();
+
+ aaiConfigurationResources.connectConfigurationToPnfObject(primaryPnf.getPnfId(),
+ configuration.getConfigurationId());
verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
}
@Test
public void getConfigurationTest() {
AAIResourceUri aaiResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, "configurationId");
- doReturn(Optional.of(new org.onap.aai.domain.yang.Configuration())).when(MOCK_aaiResourcesClient).get(org.onap.aai.domain.yang.Configuration.class, aaiResourceUri);
+ doReturn(Optional.of(new org.onap.aai.domain.yang.Configuration())).when(MOCK_aaiResourcesClient)
+ .get(org.onap.aai.domain.yang.Configuration.class, aaiResourceUri);
aaiConfigurationResources.getConfiguration("configurationId");
verify(MOCK_aaiResourcesClient, times(1)).get(org.onap.aai.domain.yang.Configuration.class, aaiResourceUri);
}
@@ -203,13 +221,14 @@ public class AAIConfigurationResourcesTest extends TestDataSetup{
aaiConfigurationResources.deleteConfiguration("configurationId");
verify(MOCK_aaiResourcesClient, times(1)).delete(aaiResourceUri);
}
-
+
@Test
- public void updateOrchestrationStatusConfigurationTest() throws Exception {
- configuration.setOrchestrationStatus(OrchestrationStatus.ACTIVE);
- doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.Configuration.class));
- aaiConfigurationResources.updateOrchestrationStatusConfiguration(configuration,OrchestrationStatus.ACTIVE);
- verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), ArgumentMatchers.isNull());
- assertEquals(OrchestrationStatus.ACTIVE, configuration.getOrchestrationStatus());
- }
-} \ No newline at end of file
+ public void updateOrchestrationStatusConfigurationTest() throws Exception {
+ configuration.setOrchestrationStatus(OrchestrationStatus.ACTIVE);
+ doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.Configuration.class));
+ aaiConfigurationResources.updateOrchestrationStatusConfiguration(configuration, OrchestrationStatus.ACTIVE);
+ verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), ArgumentMatchers.isNull());
+ assertEquals(OrchestrationStatus.ACTIVE, configuration.getOrchestrationStatus());
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIInstanceGroupResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIInstanceGroupResourcesTest.java
index 58bcc8b1aa..8c0d27f799 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIInstanceGroupResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIInstanceGroupResourcesTest.java
@@ -28,9 +28,7 @@ import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import java.util.Optional;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -49,75 +47,88 @@ import org.onap.so.client.aai.entities.uri.AAIResourceUri;
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.client.aai.mapper.AAIObjectMapper;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
+
@RunWith(MockitoJUnitRunner.Silent.class)
-public class AAIInstanceGroupResourcesTest extends TestDataSetup{
-
- @InjectMocks
- private AAIInstanceGroupResources aaiInstanceGroupResources = new AAIInstanceGroupResources();
-
- private InstanceGroup instanceGroup;
- private GenericVnf vnf;
- private ServiceInstance serviceInstance;
-
- @Mock
- protected AAIResourcesClient MOCK_aaiResourcesClient;
-
+public class AAIInstanceGroupResourcesTest extends TestDataSetup {
+
+ @InjectMocks
+ private AAIInstanceGroupResources aaiInstanceGroupResources = new AAIInstanceGroupResources();
+
+ private InstanceGroup instanceGroup;
+ private GenericVnf vnf;
+ private ServiceInstance serviceInstance;
+
+ @Mock
+ protected AAIResourcesClient MOCK_aaiResourcesClient;
+
@Mock
protected AAIObjectMapper MOCK_aaiObjectMapper;
-
+
@Mock
protected InjectionHelper MOCK_injectionHelper;
-
- @Before
- public void before() {
- instanceGroup = buildInstanceGroup();
- vnf = buildGenericVnf();
- serviceInstance = buildServiceInstance();
- doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
- }
-
- @Test
- public void createInstanceGroupTest() throws Exception {
- doReturn(new org.onap.aai.domain.yang.InstanceGroup()).when(MOCK_aaiObjectMapper).mapInstanceGroup(instanceGroup);
- aaiInstanceGroupResources.createInstanceGroup(instanceGroup);
- verify(MOCK_aaiResourcesClient, times(1)).createIfNotExists(eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId())), isA(Optional.class));
- }
-
- @Test
- public void deleteInstanceGroupTest() throws Exception {
- aaiInstanceGroupResources.deleteInstanceGroup(instanceGroup);
- verify(MOCK_aaiResourcesClient, times(1)).delete(eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId())));
- }
-
- @Test
- public void connectInstanceGroupTest() throws Exception {
- aaiInstanceGroupResources.connectInstanceGroupToVnf(instanceGroup, vnf);
- verify(MOCK_aaiResourcesClient, times(1)).connect(eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId())), eq(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId())));
- }
-
- @Test
- public void connectInstanceGroupWithEdgeTest() throws Exception {
- aaiInstanceGroupResources.connectInstanceGroupToVnf(instanceGroup, vnf, AAIEdgeLabel.BELONGS_TO);
- verify(MOCK_aaiResourcesClient, times(1)).connect(eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId())), eq(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId())), eq(AAIEdgeLabel.BELONGS_TO));
- }
-
- @Test
- public void existsTest() throws Exception {
- aaiInstanceGroupResources.exists(instanceGroup);
- verify(MOCK_aaiResourcesClient, times(1)).exists(eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId())));
- }
-
- @Test
- public void createInstanceGroupandConnectServiceInstanceTest() {
- doReturn(new org.onap.aai.domain.yang.InstanceGroup()).when(MOCK_aaiObjectMapper).mapInstanceGroup(instanceGroup);
- doReturn(MOCK_aaiResourcesClient).when(MOCK_aaiResourcesClient).createIfNotExists(isA(AAIResourceUri.class), any(Optional.class));
- doNothing().when(MOCK_aaiResourcesClient).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
-
- aaiInstanceGroupResources.createInstanceGroupandConnectServiceInstance(instanceGroup, serviceInstance);
-
- verify(MOCK_aaiObjectMapper, times(1)).mapInstanceGroup(instanceGroup);
- verify(MOCK_aaiResourcesClient, times(1)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class));
- verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
- }
-
+
+ @Before
+ public void before() {
+ instanceGroup = buildInstanceGroup();
+ vnf = buildGenericVnf();
+ serviceInstance = buildServiceInstance();
+ doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
+ }
+
+ @Test
+ public void createInstanceGroupTest() throws Exception {
+ doReturn(new org.onap.aai.domain.yang.InstanceGroup()).when(MOCK_aaiObjectMapper)
+ .mapInstanceGroup(instanceGroup);
+ aaiInstanceGroupResources.createInstanceGroup(instanceGroup);
+ verify(MOCK_aaiResourcesClient, times(1)).createIfNotExists(
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId())),
+ isA(Optional.class));
+ }
+
+ @Test
+ public void deleteInstanceGroupTest() throws Exception {
+ aaiInstanceGroupResources.deleteInstanceGroup(instanceGroup);
+ verify(MOCK_aaiResourcesClient, times(1))
+ .delete(eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId())));
+ }
+
+ @Test
+ public void connectInstanceGroupTest() throws Exception {
+ aaiInstanceGroupResources.connectInstanceGroupToVnf(instanceGroup, vnf);
+ verify(MOCK_aaiResourcesClient, times(1)).connect(
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId())),
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId())));
+ }
+
+ @Test
+ public void connectInstanceGroupWithEdgeTest() throws Exception {
+ aaiInstanceGroupResources.connectInstanceGroupToVnf(instanceGroup, vnf, AAIEdgeLabel.BELONGS_TO);
+ verify(MOCK_aaiResourcesClient, times(1)).connect(
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId())),
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId())),
+ eq(AAIEdgeLabel.BELONGS_TO));
+ }
+
+ @Test
+ public void existsTest() throws Exception {
+ aaiInstanceGroupResources.exists(instanceGroup);
+ verify(MOCK_aaiResourcesClient, times(1))
+ .exists(eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId())));
+ }
+
+ @Test
+ public void createInstanceGroupandConnectServiceInstanceTest() {
+ doReturn(new org.onap.aai.domain.yang.InstanceGroup()).when(MOCK_aaiObjectMapper)
+ .mapInstanceGroup(instanceGroup);
+ doReturn(MOCK_aaiResourcesClient).when(MOCK_aaiResourcesClient).createIfNotExists(isA(AAIResourceUri.class),
+ any(Optional.class));
+ doNothing().when(MOCK_aaiResourcesClient).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
+
+ aaiInstanceGroupResources.createInstanceGroupandConnectServiceInstance(instanceGroup, serviceInstance);
+
+ verify(MOCK_aaiObjectMapper, times(1)).mapInstanceGroup(instanceGroup);
+ verify(MOCK_aaiResourcesClient, times(1)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class));
+ verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
+ }
+
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java
index 8632a6afdd..d41148d784 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java
@@ -32,13 +32,11 @@ import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -68,328 +66,363 @@ import org.onap.so.client.aai.mapper.AAIObjectMapper;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
@RunWith(MockitoJUnitRunner.Silent.class)
-public class AAINetworkResourcesTest extends TestDataSetup{
-
- private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/";
-
- private L3Network network;
- private Collection collection;
- private InstanceGroup instanceGroup;
- private ServiceInstance serviceInstance;
- private CloudRegion cloudRegion;
- private Subnet subnet;
- private NetworkPolicy networkPolicy;
-
- @Mock
- protected AAIResourcesClient MOCK_aaiResourcesClient;
-
+public class AAINetworkResourcesTest extends TestDataSetup {
+
+ private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/";
+
+ private L3Network network;
+ private Collection collection;
+ private InstanceGroup instanceGroup;
+ private ServiceInstance serviceInstance;
+ private CloudRegion cloudRegion;
+ private Subnet subnet;
+ private NetworkPolicy networkPolicy;
+
+ @Mock
+ protected AAIResourcesClient MOCK_aaiResourcesClient;
+
@Mock
protected AAIObjectMapper MOCK_aaiObjectMapper;
-
+
@Mock
protected InjectionHelper MOCK_injectionHelper;
-
- @InjectMocks
- private AAINetworkResources aaiNetworkResources = new AAINetworkResources();
-
- @Before
- public void before() {
- network = buildL3Network();
-
- collection = buildCollection();
-
- List<L3Network> l3NetworkList = new ArrayList<L3Network>();
- l3NetworkList.add(network);
-
- instanceGroup = buildInstanceGroup();
-
- serviceInstance = buildServiceInstance();
-
- cloudRegion = buildCloudRegion();
-
- subnet = buildSubnet();
-
- networkPolicy = buildNetworkPolicy();
-
- doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
- }
-
-
- @Test
- public void updateNetworkTest() throws Exception {
-
- network.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
-
- doReturn(new org.onap.aai.domain.yang.L3Network()).when(MOCK_aaiObjectMapper).mapNetwork(network);
- doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.L3Network.class));
-
- aaiNetworkResources.updateNetwork(network);
-
- verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), isA(org.onap.aai.domain.yang.L3Network.class));
- assertEquals(OrchestrationStatus.ASSIGNED, network.getOrchestrationStatus());
- }
-
- @Test
- public void createNetworkConnectToServiceInstanceTest() throws Exception {
-
- network.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
-
- doReturn(new org.onap.aai.domain.yang.L3Network()).when(MOCK_aaiObjectMapper).mapNetwork(network);
- doReturn(MOCK_aaiResourcesClient).when(MOCK_aaiResourcesClient).createIfNotExists(any(AAIResourceUri.class), any(Optional.class));
- doNothing().when(MOCK_aaiResourcesClient).connect(isA(AAIResourceUri.class), any(AAIResourceUri.class));
-
- aaiNetworkResources.createNetworkConnectToServiceInstance(network, serviceInstance);
-
- assertEquals(OrchestrationStatus.INVENTORIED, network.getOrchestrationStatus());
+
+ @InjectMocks
+ private AAINetworkResources aaiNetworkResources = new AAINetworkResources();
+
+ @Before
+ public void before() {
+ network = buildL3Network();
+
+ collection = buildCollection();
+
+ List<L3Network> l3NetworkList = new ArrayList<L3Network>();
+ l3NetworkList.add(network);
+
+ instanceGroup = buildInstanceGroup();
+
+ serviceInstance = buildServiceInstance();
+
+ cloudRegion = buildCloudRegion();
+
+ subnet = buildSubnet();
+
+ networkPolicy = buildNetworkPolicy();
+
+ doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
+ }
+
+
+ @Test
+ public void updateNetworkTest() throws Exception {
+
+ network.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
+
+ doReturn(new org.onap.aai.domain.yang.L3Network()).when(MOCK_aaiObjectMapper).mapNetwork(network);
+ doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.L3Network.class));
+
+ aaiNetworkResources.updateNetwork(network);
+
+ verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.L3Network.class));
+ assertEquals(OrchestrationStatus.ASSIGNED, network.getOrchestrationStatus());
+ }
+
+ @Test
+ public void createNetworkConnectToServiceInstanceTest() throws Exception {
+
+ network.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
+
+ doReturn(new org.onap.aai.domain.yang.L3Network()).when(MOCK_aaiObjectMapper).mapNetwork(network);
+ doReturn(MOCK_aaiResourcesClient).when(MOCK_aaiResourcesClient).createIfNotExists(any(AAIResourceUri.class),
+ any(Optional.class));
+ doNothing().when(MOCK_aaiResourcesClient).connect(isA(AAIResourceUri.class), any(AAIResourceUri.class));
+
+ aaiNetworkResources.createNetworkConnectToServiceInstance(network, serviceInstance);
+
+ assertEquals(OrchestrationStatus.INVENTORIED, network.getOrchestrationStatus());
verify(MOCK_aaiResourcesClient, times(1)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class));
verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
- }
-
- @Test
- public void deleteNetworkTest() throws Exception {
-
- network.setOrchestrationStatus(OrchestrationStatus.INVENTORIED);
-
- doNothing().when(MOCK_aaiResourcesClient).delete(isA(AAIResourceUri.class));
-
- aaiNetworkResources.deleteNetwork(network);
-
- verify(MOCK_aaiResourcesClient, times(1)).delete(any(AAIResourceUri.class));
- }
-
- @Test
- public void getVpnBindingTest() throws Exception {
- final String content = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAaiVpnBinding.json")));
- AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(content);
- Optional<VpnBinding> oVpnBinding = Optional.empty();
- AAIResourceUri aaiUri = AAIUriFactory.createResourceUri(AAIObjectType.VPN_BINDING, "ModelInvariantUUID");
-
- doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIResourceUri.class));
- oVpnBinding = aaiNetworkResources.getVpnBinding(aaiUri);
- verify(MOCK_aaiResourcesClient, times(1)).get(any(AAIResourceUri.class));
-
- if (oVpnBinding.isPresent()) {
- VpnBinding vpnBinding = oVpnBinding.get();
- assertThat(aaiResultWrapper.asBean(VpnBinding.class).get(), sameBeanAs(vpnBinding));
- }
- }
-
- @Test
- public void getNetworkPolicyTest() throws Exception {
- final String content = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAaiNetworkPolicy.json")));
- AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(content);
- Optional<org.onap.aai.domain.yang.NetworkPolicy> oNetPolicy = Optional.empty();
- AAIResourceUri netPolicyUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, "ModelInvariantUUID");
-
- doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIResourceUri.class));
- oNetPolicy = aaiNetworkResources.getNetworkPolicy(netPolicyUri);
- verify(MOCK_aaiResourcesClient, times(1)).get(any(AAIResourceUri.class));
- if (oNetPolicy.isPresent()) {
- org.onap.aai.domain.yang.NetworkPolicy networkPolicy = oNetPolicy.get();
- assertThat(aaiResultWrapper.asBean(org.onap.aai.domain.yang.NetworkPolicy.class).get(), sameBeanAs(networkPolicy));
- }
- }
-
- @Test
- public void getNetworkPoliciesTest() throws Exception {
- final String content = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAaiNetworkPolicies.json")));
- AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(content);
- Optional<org.onap.aai.domain.yang.NetworkPolicies> oNetPolicies = Optional.empty();
- AAIResourceUri netPoliciesUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY);
-
- doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIResourceUri.class));
- oNetPolicies = aaiNetworkResources.getNetworkPolicies(netPoliciesUri);
- verify(MOCK_aaiResourcesClient, times(1)).get(any(AAIResourceUri.class));
- if (oNetPolicies.isPresent()) {
- org.onap.aai.domain.yang.NetworkPolicies networkPolicies = oNetPolicies.get();
- assertThat(aaiResultWrapper.asBean(org.onap.aai.domain.yang.NetworkPolicies.class).get(), sameBeanAs(networkPolicies));
- }
- }
-
- @Test
- public void getRouteTableTest() throws Exception {
- final String content = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAaiNetworkTableRefs.json")));
- AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(content);
- Optional<RouteTableReference> oRtref = Optional.empty();
- AAIResourceUri rTRefUri = AAIUriFactory.createResourceUri(AAIObjectType.ROUTE_TABLE_REFERENCE, "ModelInvariantUUID");
-
- doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIResourceUri.class));
- oRtref = aaiNetworkResources.getRouteTable(rTRefUri);
- verify(MOCK_aaiResourcesClient, times(1)).get(any(AAIResourceUri.class));
-
- if (oRtref.isPresent()) {
- RouteTableReference rTref = oRtref.get();
- assertThat(aaiResultWrapper.asBean(RouteTableReference.class).get(), sameBeanAs(rTref));
- }
- }
-
- @Test
- public void queryNetworkByIdTest() throws Exception {
- final String content = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiQueryAAIResponse-Wrapper.json")));
- AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(content);
- L3Network network = new L3Network();
- network.setNetworkId("0384d743-f69b-4cc8-9aa8-c3ae66662c44");
- network.setNetworkName("Dev_Bindings_1802_020118");
- network.setOrchestrationStatus(OrchestrationStatus.CREATED);
-
- doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIResourceUri.class));
- Optional<org.onap.aai.domain.yang.L3Network> l3NetworkOpt = aaiNetworkResources.queryNetworkById(network);
- org.onap.aai.domain.yang.L3Network l3Network = l3NetworkOpt.isPresent() ? l3NetworkOpt.get() : null;
-
- verify(MOCK_aaiResourcesClient, times(1)).get(isA(AAIResourceUri.class));
- assertNotNull(l3Network);
- assertEquals("0384d743-f69b-4cc8-9aa8-c3ae66662c44", l3Network.getNetworkId());
- assertEquals("Dev_Bindings_1802_020118", l3Network.getNetworkName());
- }
-
- @Test
- public void queryNetworkWrapperByIdTest() throws Exception {
- final String content = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiQueryAAIResponse-Wrapper.json")));
- AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(content);
- L3Network network = new L3Network();
- network.setNetworkId("0384d743-f69b-4cc8-9aa8-c3ae66662c44");
- network.setNetworkName("Dev_Bindings_1802_020118");
- network.setOrchestrationStatus(OrchestrationStatus.CREATED);
-
- doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIResourceUri.class));
- AAIResultWrapper result = aaiNetworkResources.queryNetworkWrapperById(network);
-
- verify(MOCK_aaiResourcesClient, times(1)).get(isA(AAIResourceUri.class));
- assertEquals(aaiResultWrapper.getJson(), result.getJson());
- assertNotNull(result);
- Optional<Relationships> resultNetworkRelationships = result.getRelationships();
- assertTrue(resultNetworkRelationships.isPresent());
- Optional<org.onap.aai.domain.yang.L3Network> aaiL3Network = result.asBean(org.onap.aai.domain.yang.L3Network.class);
- assertEquals(network.getNetworkId(),aaiL3Network.get().getNetworkId());
- assertEquals(network.getNetworkName(),aaiL3Network.get().getNetworkName());
-
-
- }
-
- @Test
- public void createNetworkCollectionTest() throws Exception {
-
- doNothing().when(MOCK_aaiResourcesClient).create(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.Collection.class));
- doReturn(new org.onap.aai.domain.yang.Collection()).when(MOCK_aaiObjectMapper).mapCollection(collection);
- collection.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
-
- aaiNetworkResources.createNetworkCollection(collection);
- assertEquals(OrchestrationStatus.INVENTORIED, collection.getOrchestrationStatus());
- verify(MOCK_aaiResourcesClient, times(1)).create(any(AAIResourceUri.class), isA(org.onap.aai.domain.yang.Collection.class));
- }
-
- @Test
- public void createNetworkInstanceGroupTest() throws Exception {
- doReturn(new org.onap.aai.domain.yang.InstanceGroup()).when(MOCK_aaiObjectMapper).mapInstanceGroup(instanceGroup);
- doNothing().when(MOCK_aaiResourcesClient).create(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.InstanceGroup.class));
- aaiNetworkResources.createNetworkInstanceGroup(instanceGroup);
- verify(MOCK_aaiResourcesClient, times(1)).create(any(AAIResourceUri.class), isA(org.onap.aai.domain.yang.InstanceGroup.class));
- }
-
- @Test
- public void connectNetworkToNetworkCollectionInstanceGroupTest() throws Exception {
- aaiNetworkResources.connectNetworkToNetworkCollectionInstanceGroup(network, instanceGroup);
- verify(MOCK_aaiResourcesClient, times(1)).connect(eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId())), eq(AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, network.getNetworkId())));
- }
-
- @Test
- public void connectNetworkToNetworkCollectionServiceInstanceTest() throws Exception {
- aaiNetworkResources.connectNetworkToNetworkCollectionServiceInstance(network, serviceInstance);
- verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), eq(AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, network.getNetworkId())));
- }
-
- @Test
- public void connectNetworkToCloudRegionTest() throws Exception {
- aaiNetworkResources.connectNetworkToCloudRegion(network, cloudRegion);
- verify(MOCK_aaiResourcesClient, times(1)).connect(eq(AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, network.getNetworkId())),eq(AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION,
- cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId())));
- }
-
- @Test
- public void connectNetworkToTenantTest() throws Exception {
- aaiNetworkResources.connectNetworkToTenant(network, cloudRegion);
- verify(MOCK_aaiResourcesClient, times(1)).connect(eq(AAIUriFactory.createResourceUri(AAIObjectType.TENANT,
- cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId(), cloudRegion.getTenantId())),
- eq(AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, network.getNetworkId())));
- }
-
- @Test
- public void connectNetworkCollectionInstanceGroupToNetworkCollectionTest() throws Exception {
- aaiNetworkResources.connectNetworkCollectionInstanceGroupToNetworkCollection(instanceGroup, collection);
- verify(MOCK_aaiResourcesClient, times(1)).connect(eq(AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, collection.getId())), eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId())));
- }
-
- @Test
- public void connectNetworkCollectionToServiceInstanceTest() throws Exception {
- aaiNetworkResources.connectNetworkCollectionToServiceInstance(collection, serviceInstance);
- verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
- }
-
- @Test
- public void deleteCollectionTest() throws Exception {
- doNothing().when(MOCK_aaiResourcesClient).delete(isA(AAIResourceUri.class));
- aaiNetworkResources.deleteCollection(collection);
- verify(MOCK_aaiResourcesClient, times(1)).delete(any(AAIResourceUri.class));
- }
-
- @Test
- public void deleteInstanceGroupTest() throws Exception {
- doNothing().when(MOCK_aaiResourcesClient).delete(isA(AAIResourceUri.class));
- aaiNetworkResources.deleteNetworkInstanceGroup(instanceGroup);
- verify(MOCK_aaiResourcesClient, times(1)).delete(any(AAIResourceUri.class));
- }
-
- @Test
- public void updateSubnetTest() throws Exception {
-
- doReturn(new org.onap.aai.domain.yang.Subnet()).when(MOCK_aaiObjectMapper).mapSubnet(subnet);
- doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.Subnet.class));
-
- aaiNetworkResources.updateSubnet(network, subnet);
-
- verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), isA(org.onap.aai.domain.yang.Subnet.class));
- }
-
- @Test
- public void connectInstanceGroupToCloudRegionTest() throws Exception {
- aaiNetworkResources.connectInstanceGroupToCloudRegion(instanceGroup, cloudRegion);
- verify(MOCK_aaiResourcesClient, times(1)).connect(
- eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId())),
- eq(AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId())),
- eq(AAIEdgeLabel.USES));
- }
-
- @Test
- public void getSubnetTest() throws Exception {
- final String content = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiSubnetsMapped_to_aai.json")));
- AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(content);
- Optional<org.onap.aai.domain.yang.Subnet> oSubnet = Optional.empty();
- AAIResourceUri subnetUri = AAIUriFactory.createResourceUri(AAIObjectType.SUBNET, "ModelInvariantUUID", "serviceModelVersionId");
-
- doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIResourceUri.class));
- oSubnet = aaiNetworkResources.getSubnet(subnetUri);
- verify(MOCK_aaiResourcesClient, times(1)).get(any(AAIResourceUri.class));
-
- if (oSubnet.isPresent()) {
- org.onap.aai.domain.yang.Subnet subnet = oSubnet.get();
- assertThat(aaiResultWrapper.asBean(org.onap.aai.domain.yang.Subnet.class).get(), sameBeanAs(subnet));
- }
- }
-
- @Test
- public void createNetworkPolicyTest() throws Exception {
- doNothing().when(MOCK_aaiResourcesClient).create(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.NetworkPolicy.class));
- doReturn(new org.onap.aai.domain.yang.NetworkPolicy()).when(MOCK_aaiObjectMapper).mapNetworkPolicy(networkPolicy);
- aaiNetworkResources.createNetworkPolicy(networkPolicy);
- verify(MOCK_aaiResourcesClient, times(1)).create(any(AAIResourceUri.class), isA(org.onap.aai.domain.yang.NetworkPolicy.class));
- }
-
- @Test
- public void deleteNetworkPolicyTest() throws Exception {
- doNothing().when(MOCK_aaiResourcesClient).delete(isA(AAIResourceUri.class));
- aaiNetworkResources.deleteNetworkPolicy(networkPolicy.getNetworkPolicyId());
- verify(MOCK_aaiResourcesClient, times(1)).delete(any(AAIResourceUri.class));
- }
-
+ }
+
+ @Test
+ public void deleteNetworkTest() throws Exception {
+
+ network.setOrchestrationStatus(OrchestrationStatus.INVENTORIED);
+
+ doNothing().when(MOCK_aaiResourcesClient).delete(isA(AAIResourceUri.class));
+
+ aaiNetworkResources.deleteNetwork(network);
+
+ verify(MOCK_aaiResourcesClient, times(1)).delete(any(AAIResourceUri.class));
+ }
+
+ @Test
+ public void getVpnBindingTest() throws Exception {
+ final String content =
+ new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAaiVpnBinding.json")));
+ AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(content);
+ Optional<VpnBinding> oVpnBinding = Optional.empty();
+ AAIResourceUri aaiUri = AAIUriFactory.createResourceUri(AAIObjectType.VPN_BINDING, "ModelInvariantUUID");
+
+ doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIResourceUri.class));
+ oVpnBinding = aaiNetworkResources.getVpnBinding(aaiUri);
+ verify(MOCK_aaiResourcesClient, times(1)).get(any(AAIResourceUri.class));
+
+ if (oVpnBinding.isPresent()) {
+ VpnBinding vpnBinding = oVpnBinding.get();
+ assertThat(aaiResultWrapper.asBean(VpnBinding.class).get(), sameBeanAs(vpnBinding));
+ }
+ }
+
+ @Test
+ public void getNetworkPolicyTest() throws Exception {
+ final String content =
+ new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAaiNetworkPolicy.json")));
+ AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(content);
+ Optional<org.onap.aai.domain.yang.NetworkPolicy> oNetPolicy = Optional.empty();
+ AAIResourceUri netPolicyUri =
+ AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, "ModelInvariantUUID");
+
+ doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIResourceUri.class));
+ oNetPolicy = aaiNetworkResources.getNetworkPolicy(netPolicyUri);
+ verify(MOCK_aaiResourcesClient, times(1)).get(any(AAIResourceUri.class));
+ if (oNetPolicy.isPresent()) {
+ org.onap.aai.domain.yang.NetworkPolicy networkPolicy = oNetPolicy.get();
+ assertThat(aaiResultWrapper.asBean(org.onap.aai.domain.yang.NetworkPolicy.class).get(),
+ sameBeanAs(networkPolicy));
+ }
+ }
+
+ @Test
+ public void getNetworkPoliciesTest() throws Exception {
+ final String content =
+ new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAaiNetworkPolicies.json")));
+ AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(content);
+ Optional<org.onap.aai.domain.yang.NetworkPolicies> oNetPolicies = Optional.empty();
+ AAIResourceUri netPoliciesUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY);
+
+ doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIResourceUri.class));
+ oNetPolicies = aaiNetworkResources.getNetworkPolicies(netPoliciesUri);
+ verify(MOCK_aaiResourcesClient, times(1)).get(any(AAIResourceUri.class));
+ if (oNetPolicies.isPresent()) {
+ org.onap.aai.domain.yang.NetworkPolicies networkPolicies = oNetPolicies.get();
+ assertThat(aaiResultWrapper.asBean(org.onap.aai.domain.yang.NetworkPolicies.class).get(),
+ sameBeanAs(networkPolicies));
+ }
+ }
+
+ @Test
+ public void getRouteTableTest() throws Exception {
+ final String content =
+ new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAaiNetworkTableRefs.json")));
+ AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(content);
+ Optional<RouteTableReference> oRtref = Optional.empty();
+ AAIResourceUri rTRefUri =
+ AAIUriFactory.createResourceUri(AAIObjectType.ROUTE_TABLE_REFERENCE, "ModelInvariantUUID");
+
+ doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIResourceUri.class));
+ oRtref = aaiNetworkResources.getRouteTable(rTRefUri);
+ verify(MOCK_aaiResourcesClient, times(1)).get(any(AAIResourceUri.class));
+
+ if (oRtref.isPresent()) {
+ RouteTableReference rTref = oRtref.get();
+ assertThat(aaiResultWrapper.asBean(RouteTableReference.class).get(), sameBeanAs(rTref));
+ }
+ }
+
+ @Test
+ public void queryNetworkByIdTest() throws Exception {
+ final String content =
+ new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiQueryAAIResponse-Wrapper.json")));
+ AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(content);
+ L3Network network = new L3Network();
+ network.setNetworkId("0384d743-f69b-4cc8-9aa8-c3ae66662c44");
+ network.setNetworkName("Dev_Bindings_1802_020118");
+ network.setOrchestrationStatus(OrchestrationStatus.CREATED);
+
+ doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIResourceUri.class));
+ Optional<org.onap.aai.domain.yang.L3Network> l3NetworkOpt = aaiNetworkResources.queryNetworkById(network);
+ org.onap.aai.domain.yang.L3Network l3Network = l3NetworkOpt.isPresent() ? l3NetworkOpt.get() : null;
+
+ verify(MOCK_aaiResourcesClient, times(1)).get(isA(AAIResourceUri.class));
+ assertNotNull(l3Network);
+ assertEquals("0384d743-f69b-4cc8-9aa8-c3ae66662c44", l3Network.getNetworkId());
+ assertEquals("Dev_Bindings_1802_020118", l3Network.getNetworkName());
+ }
+
+ @Test
+ public void queryNetworkWrapperByIdTest() throws Exception {
+ final String content =
+ new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiQueryAAIResponse-Wrapper.json")));
+ AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(content);
+ L3Network network = new L3Network();
+ network.setNetworkId("0384d743-f69b-4cc8-9aa8-c3ae66662c44");
+ network.setNetworkName("Dev_Bindings_1802_020118");
+ network.setOrchestrationStatus(OrchestrationStatus.CREATED);
+
+ doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIResourceUri.class));
+ AAIResultWrapper result = aaiNetworkResources.queryNetworkWrapperById(network);
+
+ verify(MOCK_aaiResourcesClient, times(1)).get(isA(AAIResourceUri.class));
+ assertEquals(aaiResultWrapper.getJson(), result.getJson());
+ assertNotNull(result);
+ Optional<Relationships> resultNetworkRelationships = result.getRelationships();
+ assertTrue(resultNetworkRelationships.isPresent());
+ Optional<org.onap.aai.domain.yang.L3Network> aaiL3Network =
+ result.asBean(org.onap.aai.domain.yang.L3Network.class);
+ assertEquals(network.getNetworkId(), aaiL3Network.get().getNetworkId());
+ assertEquals(network.getNetworkName(), aaiL3Network.get().getNetworkName());
+
+
+ }
+
+ @Test
+ public void createNetworkCollectionTest() throws Exception {
+
+ doNothing().when(MOCK_aaiResourcesClient).create(isA(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.Collection.class));
+ doReturn(new org.onap.aai.domain.yang.Collection()).when(MOCK_aaiObjectMapper).mapCollection(collection);
+ collection.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
+
+ aaiNetworkResources.createNetworkCollection(collection);
+ assertEquals(OrchestrationStatus.INVENTORIED, collection.getOrchestrationStatus());
+ verify(MOCK_aaiResourcesClient, times(1)).create(any(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.Collection.class));
+ }
+
+ @Test
+ public void createNetworkInstanceGroupTest() throws Exception {
+ doReturn(new org.onap.aai.domain.yang.InstanceGroup()).when(MOCK_aaiObjectMapper)
+ .mapInstanceGroup(instanceGroup);
+ doNothing().when(MOCK_aaiResourcesClient).create(isA(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.InstanceGroup.class));
+ aaiNetworkResources.createNetworkInstanceGroup(instanceGroup);
+ verify(MOCK_aaiResourcesClient, times(1)).create(any(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.InstanceGroup.class));
+ }
+
+ @Test
+ public void connectNetworkToNetworkCollectionInstanceGroupTest() throws Exception {
+ aaiNetworkResources.connectNetworkToNetworkCollectionInstanceGroup(network, instanceGroup);
+ verify(MOCK_aaiResourcesClient, times(1)).connect(
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId())),
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, network.getNetworkId())));
+ }
+
+ @Test
+ public void connectNetworkToNetworkCollectionServiceInstanceTest() throws Exception {
+ aaiNetworkResources.connectNetworkToNetworkCollectionServiceInstance(network, serviceInstance);
+ verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class),
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, network.getNetworkId())));
+ }
+
+ @Test
+ public void connectNetworkToCloudRegionTest() throws Exception {
+ aaiNetworkResources.connectNetworkToCloudRegion(network, cloudRegion);
+ verify(MOCK_aaiResourcesClient, times(1)).connect(
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, network.getNetworkId())),
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, cloudRegion.getCloudOwner(),
+ cloudRegion.getLcpCloudRegionId())));
+ }
+
+ @Test
+ public void connectNetworkToTenantTest() throws Exception {
+ aaiNetworkResources.connectNetworkToTenant(network, cloudRegion);
+ verify(MOCK_aaiResourcesClient, times(1)).connect(
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.TENANT, cloudRegion.getCloudOwner(),
+ cloudRegion.getLcpCloudRegionId(), cloudRegion.getTenantId())),
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, network.getNetworkId())));
+ }
+
+ @Test
+ public void connectNetworkCollectionInstanceGroupToNetworkCollectionTest() throws Exception {
+ aaiNetworkResources.connectNetworkCollectionInstanceGroupToNetworkCollection(instanceGroup, collection);
+ verify(MOCK_aaiResourcesClient, times(1)).connect(
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, collection.getId())),
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId())));
+ }
+
+ @Test
+ public void connectNetworkCollectionToServiceInstanceTest() throws Exception {
+ aaiNetworkResources.connectNetworkCollectionToServiceInstance(collection, serviceInstance);
+ verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
+ }
+
+ @Test
+ public void deleteCollectionTest() throws Exception {
+ doNothing().when(MOCK_aaiResourcesClient).delete(isA(AAIResourceUri.class));
+ aaiNetworkResources.deleteCollection(collection);
+ verify(MOCK_aaiResourcesClient, times(1)).delete(any(AAIResourceUri.class));
+ }
+
+ @Test
+ public void deleteInstanceGroupTest() throws Exception {
+ doNothing().when(MOCK_aaiResourcesClient).delete(isA(AAIResourceUri.class));
+ aaiNetworkResources.deleteNetworkInstanceGroup(instanceGroup);
+ verify(MOCK_aaiResourcesClient, times(1)).delete(any(AAIResourceUri.class));
+ }
+
+ @Test
+ public void updateSubnetTest() throws Exception {
+
+ doReturn(new org.onap.aai.domain.yang.Subnet()).when(MOCK_aaiObjectMapper).mapSubnet(subnet);
+ doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.Subnet.class));
+
+ aaiNetworkResources.updateSubnet(network, subnet);
+
+ verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.Subnet.class));
+ }
+
+ @Test
+ public void connectInstanceGroupToCloudRegionTest() throws Exception {
+ aaiNetworkResources.connectInstanceGroupToCloudRegion(instanceGroup, cloudRegion);
+ verify(MOCK_aaiResourcesClient, times(1)).connect(
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId())),
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, cloudRegion.getCloudOwner(),
+ cloudRegion.getLcpCloudRegionId())),
+ eq(AAIEdgeLabel.USES));
+ }
+
+ @Test
+ public void getSubnetTest() throws Exception {
+ final String content =
+ new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiSubnetsMapped_to_aai.json")));
+ AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(content);
+ Optional<org.onap.aai.domain.yang.Subnet> oSubnet = Optional.empty();
+ AAIResourceUri subnetUri =
+ AAIUriFactory.createResourceUri(AAIObjectType.SUBNET, "ModelInvariantUUID", "serviceModelVersionId");
+
+ doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIResourceUri.class));
+ oSubnet = aaiNetworkResources.getSubnet(subnetUri);
+ verify(MOCK_aaiResourcesClient, times(1)).get(any(AAIResourceUri.class));
+
+ if (oSubnet.isPresent()) {
+ org.onap.aai.domain.yang.Subnet subnet = oSubnet.get();
+ assertThat(aaiResultWrapper.asBean(org.onap.aai.domain.yang.Subnet.class).get(), sameBeanAs(subnet));
+ }
+ }
+
+ @Test
+ public void createNetworkPolicyTest() throws Exception {
+ doNothing().when(MOCK_aaiResourcesClient).create(isA(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.NetworkPolicy.class));
+ doReturn(new org.onap.aai.domain.yang.NetworkPolicy()).when(MOCK_aaiObjectMapper)
+ .mapNetworkPolicy(networkPolicy);
+ aaiNetworkResources.createNetworkPolicy(networkPolicy);
+ verify(MOCK_aaiResourcesClient, times(1)).create(any(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.NetworkPolicy.class));
+ }
+
+ @Test
+ public void deleteNetworkPolicyTest() throws Exception {
+ doNothing().when(MOCK_aaiResourcesClient).delete(isA(AAIResourceUri.class));
+ aaiNetworkResources.deleteNetworkPolicy(networkPolicy.getNetworkPolicyId());
+ verify(MOCK_aaiResourcesClient, times(1)).delete(any(AAIResourceUri.class));
+ }
+
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIServiceInstanceResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIServiceInstanceResourcesTest.java
index a4b59f1f81..14df832754 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIServiceInstanceResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIServiceInstanceResourcesTest.java
@@ -28,9 +28,7 @@ import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import java.util.Optional;
-
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
@@ -51,36 +49,36 @@ import org.onap.so.client.aai.mapper.AAIObjectMapper;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
@RunWith(MockitoJUnitRunner.Silent.class)
-public class AAIServiceInstanceResourcesTest extends TestDataSetup{
-
+public class AAIServiceInstanceResourcesTest extends TestDataSetup {
+
@InjectMocks
private AAIServiceInstanceResources aaiServiceInstanceResources = new AAIServiceInstanceResources();
-
+
@Mock
- protected AAIResourcesClient MOCK_aaiResourcesClient;
-
+ protected AAIResourcesClient MOCK_aaiResourcesClient;
+
@Mock
protected AAIObjectMapper MOCK_aaiObjectMapper;
-
+
@Mock
protected InjectionHelper MOCK_injectionHelper;
-
+
private ServiceInstance serviceInstance;
private ServiceSubscription serviceSubscription;
private Customer customer;
private Project project;
private OwningEntity owningEntity;
-
+
@Before
public void before() {
- serviceInstance = buildServiceInstance();
- serviceSubscription = buildServiceSubscription();
- customer = buildCustomer();
- project = buildProject();
- owningEntity = buildOwningEntity();
- doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
+ serviceInstance = buildServiceInstance();
+ serviceSubscription = buildServiceSubscription();
+ customer = buildCustomer();
+ project = buildProject();
+ owningEntity = buildOwningEntity();
+ doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
}
-
+
@Test
public void deleteServiceInstanceSuccessTest() throws Exception {
aaiServiceInstanceResources.deleteServiceInstance(serviceInstance);
@@ -104,34 +102,37 @@ public class AAIServiceInstanceResourcesTest extends TestDataSetup{
public void createServiceSubscriptionTest() {
serviceSubscription.setServiceType("IP-FLEX");
customer.setServiceSubscription(serviceSubscription);
- doReturn(new org.onap.aai.domain.yang.ServiceSubscription()).when(MOCK_aaiObjectMapper).mapServiceSubscription(customer.getServiceSubscription());
+ doReturn(new org.onap.aai.domain.yang.ServiceSubscription()).when(MOCK_aaiObjectMapper)
+ .mapServiceSubscription(customer.getServiceSubscription());
aaiServiceInstanceResources.createServiceSubscription(customer);
verify(MOCK_aaiResourcesClient, times(1)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class));
}
@Test
public void createServiceInstanceTest() {
- serviceSubscription.setServiceType("testSubscriberType");
+ serviceSubscription.setServiceType("testSubscriberType");
customer.setServiceSubscription(serviceSubscription);
- doReturn(new org.onap.aai.domain.yang.ServiceInstance()).when(MOCK_aaiObjectMapper).mapServiceInstance(serviceInstance);
+ doReturn(new org.onap.aai.domain.yang.ServiceInstance()).when(MOCK_aaiObjectMapper)
+ .mapServiceInstance(serviceInstance);
serviceInstance.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
-
+
aaiServiceInstanceResources.createServiceInstance(serviceInstance, customer);
-
+
assertEquals(OrchestrationStatus.INVENTORIED, serviceInstance.getOrchestrationStatus());
verify(MOCK_aaiResourcesClient, times(1)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class));
}
@Test
public void createProjectTest() {
- doReturn(new org.onap.aai.domain.yang.Project()).when(MOCK_aaiObjectMapper).mapProject(project);
+ doReturn(new org.onap.aai.domain.yang.Project()).when(MOCK_aaiObjectMapper).mapProject(project);
aaiServiceInstanceResources.createProject(project);
verify(MOCK_aaiResourcesClient, times(1)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class));
}
@Test
public void createProjectandConnectServiceInstanceTest() {
- doReturn(MOCK_aaiResourcesClient).when(MOCK_aaiResourcesClient).createIfNotExists(any(AAIResourceUri.class), any(Optional.class));
+ doReturn(MOCK_aaiResourcesClient).when(MOCK_aaiResourcesClient).createIfNotExists(any(AAIResourceUri.class),
+ any(Optional.class));
doNothing().when(MOCK_aaiResourcesClient).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
doReturn(new org.onap.aai.domain.yang.Project()).when(MOCK_aaiObjectMapper).mapProject(project);
aaiServiceInstanceResources.createProjectandConnectServiceInstance(project, serviceInstance);
@@ -141,7 +142,7 @@ public class AAIServiceInstanceResourcesTest extends TestDataSetup{
@Test
public void createOwningEntityTest() {
- doReturn(new org.onap.aai.domain.yang.OwningEntity()).when(MOCK_aaiObjectMapper).mapOwningEntity(owningEntity);
+ doReturn(new org.onap.aai.domain.yang.OwningEntity()).when(MOCK_aaiObjectMapper).mapOwningEntity(owningEntity);
aaiServiceInstanceResources.createOwningEntity(owningEntity);
verify(MOCK_aaiResourcesClient, times(1)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class));
}
@@ -160,7 +161,8 @@ public class AAIServiceInstanceResourcesTest extends TestDataSetup{
@Test
public void createOwningEntityandConnectServiceInstanceTest() {
- doReturn(MOCK_aaiResourcesClient).when(MOCK_aaiResourcesClient).createIfNotExists(any(AAIResourceUri.class), any(Optional.class));
+ doReturn(MOCK_aaiResourcesClient).when(MOCK_aaiResourcesClient).createIfNotExists(any(AAIResourceUri.class),
+ any(Optional.class));
doNothing().when(MOCK_aaiResourcesClient).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
doReturn(new org.onap.aai.domain.yang.OwningEntity()).when(MOCK_aaiObjectMapper).mapOwningEntity(owningEntity);
aaiServiceInstanceResources.createOwningEntityandConnectServiceInstance(owningEntity, serviceInstance);
@@ -171,14 +173,17 @@ public class AAIServiceInstanceResourcesTest extends TestDataSetup{
@Test
@Ignore
public void updateOrchestrationStatusServiceInstanceTest() {
- aaiServiceInstanceResources.updateOrchestrationStatusServiceInstance(serviceInstance, OrchestrationStatus.ACTIVE);
- verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), any(org.onap.aai.domain.yang.ServiceInstance.class));
+ aaiServiceInstanceResources.updateOrchestrationStatusServiceInstance(serviceInstance,
+ OrchestrationStatus.ACTIVE);
+ verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class),
+ any(org.onap.aai.domain.yang.ServiceInstance.class));
}
@Test
@Ignore
public void test_updateServiceInstance() {
aaiServiceInstanceResources.updateServiceInstance(serviceInstance);
- verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), any(org.onap.aai.domain.yang.ServiceInstance.class));
+ verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class),
+ any(org.onap.aai.domain.yang.ServiceInstance.class));
}
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVfModuleResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVfModuleResourcesTest.java
index a8200caf79..ae3ebeddbd 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVfModuleResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVfModuleResourcesTest.java
@@ -27,9 +27,7 @@ import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import java.util.Optional;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -49,106 +47,111 @@ import org.onap.so.client.aai.mapper.AAIObjectMapper;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
@RunWith(MockitoJUnitRunner.Silent.class)
-public class AAIVfModuleResourcesTest extends TestDataSetup{
- @InjectMocks
- private AAIVfModuleResources aaiVfModuleResources = new AAIVfModuleResources();
-
- private VfModule vfModule;
- private GenericVnf vnf;
-
- @Mock
- protected AAIResourcesClient MOCK_aaiResourcesClient;
-
- @Mock
- protected AAIObjectMapper MOCK_aaiObjectMapper;
-
- @Mock
- protected InjectionHelper MOCK_injectionHelper;
-
- @Before
- public void before() {
- vfModule = buildVfModule();
- vnf = buildGenericVnf();
- doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
- }
-
- @Test
- public void updateOrchestrationStatusVfModuleTest() throws Exception {
- vfModule.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
-
- doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.VfModule.class));
-
- aaiVfModuleResources.updateOrchestrationStatusVfModule(vfModule, vnf, OrchestrationStatus.ACTIVE);
-
- verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class),ArgumentMatchers.isNull());
-
- assertEquals(OrchestrationStatus.ACTIVE, vfModule.getOrchestrationStatus());
- }
-
- @Test
- public void createVfModuleTest() throws Exception {
- vfModule.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
-
- doReturn(new org.onap.aai.domain.yang.VfModule()).when(MOCK_aaiObjectMapper).mapVfModule(vfModule);
- doReturn(MOCK_aaiResourcesClient).when(MOCK_aaiResourcesClient).createIfNotExists(isA(AAIResourceUri.class), any(Optional.class));
- aaiVfModuleResources.createVfModule(vfModule, vnf);
-
- verify(MOCK_aaiResourcesClient, times(1)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class));
- assertEquals(OrchestrationStatus.INVENTORIED, vfModule.getOrchestrationStatus());
- }
-
- @Test
- public void deleteVfModuleTest() throws Exception {
- doNothing().when(MOCK_aaiResourcesClient).delete(isA(AAIResourceUri.class));
-
- aaiVfModuleResources.deleteVfModule(vfModule, vnf);
-
- verify(MOCK_aaiResourcesClient, times(1)).delete(any(AAIResourceUri.class));
- }
-
- @Test
- public void changeAssignVfModuleTest() throws Exception {
- doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.VfModule.class));
-
- aaiVfModuleResources.changeAssignVfModule(vfModule, vnf);
-
- verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), ArgumentMatchers.isNull());
- }
-
- @Test
- public void connectVfModuleToVolumeGroupTest() throws Exception {
- VolumeGroup volumeGroup = buildVolumeGroup();
- volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
-
- CloudRegion cloudRegion = buildCloudRegion();
-
- aaiVfModuleResources.connectVfModuleToVolumeGroup(vnf, vfModule, volumeGroup, cloudRegion);
- verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
- }
-
- @Test
- public void updateHeatStackIdVfModuleTest() throws Exception {
- vfModule.setHeatStackId("testHeatStackId");
-
- doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.VfModule.class));
-
- aaiVfModuleResources.updateHeatStackIdVfModule(vfModule, vnf);
-
- verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class),ArgumentMatchers.isNull());
-
- assertEquals("testHeatStackId", vfModule.getHeatStackId());
- }
-
- @Test
- public void updateContrailServiceInstanceFqdnVfModuleTest() throws Exception {
- vfModule.setContrailServiceInstanceFqdn("testContrailServiceInstanceFqdn");
-
- doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.VfModule.class));
-
- aaiVfModuleResources.updateContrailServiceInstanceFqdnVfModule(vfModule, vnf);
-
- verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class),ArgumentMatchers.isNull());
-
- assertEquals("testContrailServiceInstanceFqdn", vfModule.getContrailServiceInstanceFqdn());
- }
+public class AAIVfModuleResourcesTest extends TestDataSetup {
+ @InjectMocks
+ private AAIVfModuleResources aaiVfModuleResources = new AAIVfModuleResources();
+
+ private VfModule vfModule;
+ private GenericVnf vnf;
+
+ @Mock
+ protected AAIResourcesClient MOCK_aaiResourcesClient;
+
+ @Mock
+ protected AAIObjectMapper MOCK_aaiObjectMapper;
+
+ @Mock
+ protected InjectionHelper MOCK_injectionHelper;
+
+ @Before
+ public void before() {
+ vfModule = buildVfModule();
+ vnf = buildGenericVnf();
+ doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
+ }
+
+ @Test
+ public void updateOrchestrationStatusVfModuleTest() throws Exception {
+ vfModule.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
+
+ doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.VfModule.class));
+
+ aaiVfModuleResources.updateOrchestrationStatusVfModule(vfModule, vnf, OrchestrationStatus.ACTIVE);
+
+ verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), ArgumentMatchers.isNull());
+
+ assertEquals(OrchestrationStatus.ACTIVE, vfModule.getOrchestrationStatus());
+ }
+
+ @Test
+ public void createVfModuleTest() throws Exception {
+ vfModule.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
+
+ doReturn(new org.onap.aai.domain.yang.VfModule()).when(MOCK_aaiObjectMapper).mapVfModule(vfModule);
+ doReturn(MOCK_aaiResourcesClient).when(MOCK_aaiResourcesClient).createIfNotExists(isA(AAIResourceUri.class),
+ any(Optional.class));
+ aaiVfModuleResources.createVfModule(vfModule, vnf);
+
+ verify(MOCK_aaiResourcesClient, times(1)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class));
+ assertEquals(OrchestrationStatus.INVENTORIED, vfModule.getOrchestrationStatus());
+ }
+
+ @Test
+ public void deleteVfModuleTest() throws Exception {
+ doNothing().when(MOCK_aaiResourcesClient).delete(isA(AAIResourceUri.class));
+
+ aaiVfModuleResources.deleteVfModule(vfModule, vnf);
+
+ verify(MOCK_aaiResourcesClient, times(1)).delete(any(AAIResourceUri.class));
+ }
+
+ @Test
+ public void changeAssignVfModuleTest() throws Exception {
+ doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.VfModule.class));
+
+ aaiVfModuleResources.changeAssignVfModule(vfModule, vnf);
+
+ verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), ArgumentMatchers.isNull());
+ }
+
+ @Test
+ public void connectVfModuleToVolumeGroupTest() throws Exception {
+ VolumeGroup volumeGroup = buildVolumeGroup();
+ volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
+
+ CloudRegion cloudRegion = buildCloudRegion();
+
+ aaiVfModuleResources.connectVfModuleToVolumeGroup(vnf, vfModule, volumeGroup, cloudRegion);
+ verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
+ }
+
+ @Test
+ public void updateHeatStackIdVfModuleTest() throws Exception {
+ vfModule.setHeatStackId("testHeatStackId");
+
+ doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.VfModule.class));
+
+ aaiVfModuleResources.updateHeatStackIdVfModule(vfModule, vnf);
+
+ verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), ArgumentMatchers.isNull());
+
+ assertEquals("testHeatStackId", vfModule.getHeatStackId());
+ }
+
+ @Test
+ public void updateContrailServiceInstanceFqdnVfModuleTest() throws Exception {
+ vfModule.setContrailServiceInstanceFqdn("testContrailServiceInstanceFqdn");
+
+ doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.VfModule.class));
+
+ aaiVfModuleResources.updateContrailServiceInstanceFqdnVfModule(vfModule, vnf);
+
+ verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), ArgumentMatchers.isNull());
+
+ assertEquals("testContrailServiceInstanceFqdn", vfModule.getContrailServiceInstanceFqdn());
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVnfResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVnfResourcesTest.java
index d499bcd36e..cdc601c1e4 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVnfResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVnfResourcesTest.java
@@ -29,10 +29,8 @@ import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import java.io.IOException;
import java.util.Optional;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -58,159 +56,175 @@ import org.onap.so.db.catalog.beans.OrchestrationStatus;
@RunWith(MockitoJUnitRunner.Silent.class)
public class AAIVnfResourcesTest extends TestDataSetup {
- private GenericVnf genericVnf;
-
- private ServiceInstance serviceInstance;
-
- private CloudRegion cloudRegion;
-
- @Mock
- protected AAIResourcesClient MOCK_aaiResourcesClient;
-
- @Mock
- protected AAIObjectMapper MOCK_aaiObjectMapper;
-
- @Mock
- protected InjectionHelper MOCK_injectionHelper;
-
- @Mock
- protected AAIValidatorImpl MOCK_aaiValidatorImpl;
-
- @InjectMocks
- AAIVnfResources aaiVnfResources = new AAIVnfResources();
-
- @Before
- public void before() {
- serviceInstance = buildServiceInstance();
- genericVnf = buildGenericVnf();
- cloudRegion = buildCloudRegion();
- doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
- }
-
- @Test
- public void createVnfandConnectServiceInstanceTest() {
- doReturn(new org.onap.aai.domain.yang.GenericVnf()).when(MOCK_aaiObjectMapper).mapVnf(genericVnf);
- doReturn(MOCK_aaiResourcesClient).when(MOCK_aaiResourcesClient).createIfNotExists(isA(AAIResourceUri.class), any(Optional.class));
- doNothing().when(MOCK_aaiResourcesClient).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
- genericVnf.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
-
- aaiVnfResources.createVnfandConnectServiceInstance(genericVnf, serviceInstance);
-
- assertEquals(OrchestrationStatus.INVENTORIED, genericVnf.getOrchestrationStatus());
- verify(MOCK_aaiObjectMapper, times(1)).mapVnf(genericVnf);
- verify(MOCK_aaiResourcesClient, times(1)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class));
- verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
- }
-
- @Test
- public void createPlatformandConnectVnfTest() {
- Platform platform = new Platform();
- platform.setPlatformName("a123");
- doNothing().when(MOCK_aaiResourcesClient).connect(isA(AAIResourceUri.class),isA(AAIResourceUri.class));
- doReturn(MOCK_aaiResourcesClient).when(MOCK_aaiResourcesClient).createIfNotExists(isA(AAIResourceUri.class), any(Optional.class));
- aaiVnfResources.createPlatformandConnectVnf(platform, genericVnf);
- verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class),isA(AAIResourceUri.class));
- }
-
- @Test
- public void createLineOfBusinessandConnectVnfTest() {
- LineOfBusiness lob = new LineOfBusiness();
- lob.setLineOfBusinessName("a123");
- doNothing().when(MOCK_aaiResourcesClient).connect(isA(AAIResourceUri.class),isA(AAIResourceUri.class));
- doReturn(MOCK_aaiResourcesClient).when(MOCK_aaiResourcesClient).createIfNotExists(isA(AAIResourceUri.class), any(Optional.class));
- aaiVnfResources.createLineOfBusinessandConnectVnf(lob, genericVnf);
- verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class),isA(AAIResourceUri.class));
- }
-
- @Test
- public void deleteVnfTest() {
- doNothing().when(MOCK_aaiResourcesClient).delete(isA(AAIResourceUri.class));
-
- aaiVnfResources.deleteVnf(genericVnf);
-
- verify(MOCK_aaiResourcesClient, times(1)).delete(any(AAIResourceUri.class));
- }
-
- @Test
- public void updateOrchestrationStatusVnfTest() {
- doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.Vnf.class));
-
- aaiVnfResources.updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ACTIVE);
-
- verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), ArgumentMatchers.isNull());
-
- assertEquals(OrchestrationStatus.ACTIVE, genericVnf.getOrchestrationStatus());
- }
-
- @Test
- public void updateObjectVnfTest() {
- doReturn(new org.onap.aai.domain.yang.GenericVnf()).when(MOCK_aaiObjectMapper).mapVnf(genericVnf);
- doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.GenericVnf.class));
-
- aaiVnfResources.updateObjectVnf(genericVnf);
-
- verify(MOCK_aaiObjectMapper, times(1)).mapVnf(genericVnf);
- verify(MOCK_aaiResourcesClient, times(1)).update(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.GenericVnf.class));
- }
-
- @Test
- public void getGenericVnfTest () {
- Optional<org.onap.aai.domain.yang.GenericVnf> vnf = Optional.of(new org.onap.aai.domain.yang.GenericVnf());
- vnf.get().setVnfId("vnfId");
- doReturn(vnf).when(MOCK_aaiResourcesClient).get(eq(org.onap.aai.domain.yang.GenericVnf.class),isA(AAIResourceUri.class));
- aaiVnfResources.getGenericVnf("vnfId");
- verify(MOCK_aaiResourcesClient, times(1)).get(eq(org.onap.aai.domain.yang.GenericVnf.class),isA(AAIResourceUri.class));
- }
-
- @Test
- public void checkInMaintFlagTest () {
- Optional<org.onap.aai.domain.yang.GenericVnf> vnf = Optional.of(new org.onap.aai.domain.yang.GenericVnf());
- vnf.get().setVnfId("vnfId");
- vnf.get().setInMaint(true);
- doReturn(vnf).when(MOCK_aaiResourcesClient).get(eq(org.onap.aai.domain.yang.GenericVnf.class),isA(AAIResourceUri.class));
- boolean inMaintFlag = aaiVnfResources.checkInMaintFlag("vnfId");
- verify(MOCK_aaiResourcesClient, times(1)).get(eq(org.onap.aai.domain.yang.GenericVnf.class),isA(AAIResourceUri.class));
- assertEquals(inMaintFlag, true);
- }
-
- @Test
- public void connectVnfToTenantTest() throws Exception {
- aaiVnfResources.connectVnfToTenant(genericVnf, cloudRegion);
- verify(MOCK_aaiResourcesClient, times(1)).connect(eq(AAIUriFactory.createResourceUri(AAIObjectType.TENANT,
- cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId(), cloudRegion.getTenantId())),
- eq(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, genericVnf.getVnfId())));
- }
-
- @Test
- public void connectVnfToCloudRegionTest() throws Exception {
- aaiVnfResources.connectVnfToCloudRegion(genericVnf, cloudRegion);
- verify(MOCK_aaiResourcesClient, times(1)).connect(eq(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, genericVnf.getVnfId())),
- eq(AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION,
- cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId())));
- }
-
-
- @Test
- public void checkVnfClosedLoopDisabledFlagTest () {
- Optional<org.onap.aai.domain.yang.GenericVnf> vnf = Optional.of(new org.onap.aai.domain.yang.GenericVnf());
- vnf.get().setVnfId("vnfId");
- vnf.get().setIsClosedLoopDisabled(true);
- doReturn(vnf).when(MOCK_aaiResourcesClient).get(eq(org.onap.aai.domain.yang.GenericVnf.class),isA(AAIResourceUri.class));
- boolean isCheckVnfClosedLoopDisabledFlag = aaiVnfResources.checkVnfClosedLoopDisabledFlag("vnfId");
- verify(MOCK_aaiResourcesClient, times(1)).get(eq(org.onap.aai.domain.yang.GenericVnf.class),isA(AAIResourceUri.class));
- assertEquals(isCheckVnfClosedLoopDisabledFlag, true);
- }
-
- @Test
- public void checkVnfPserversLockedFlagTest () throws IOException {
-
- Optional<org.onap.aai.domain.yang.GenericVnf> vnf = Optional.of(new org.onap.aai.domain.yang.GenericVnf());
- vnf.get().setVnfId("vnfId");
- doReturn(vnf).when(MOCK_aaiResourcesClient).get(eq(org.onap.aai.domain.yang.GenericVnf.class),isA(AAIResourceUri.class));
- doReturn(true).when(MOCK_aaiValidatorImpl).isPhysicalServerLocked("vnfId");
- boolean isVnfPserversLockedFlag = aaiVnfResources.checkVnfPserversLockedFlag("vnfId");
- verify(MOCK_aaiResourcesClient, times(1)).get(eq(org.onap.aai.domain.yang.GenericVnf.class),isA(AAIResourceUri.class));
- verify(MOCK_aaiValidatorImpl, times(1)).isPhysicalServerLocked(isA(String.class));
- assertTrue(isVnfPserversLockedFlag);
- }
+ private GenericVnf genericVnf;
+
+ private ServiceInstance serviceInstance;
+
+ private CloudRegion cloudRegion;
+
+ @Mock
+ protected AAIResourcesClient MOCK_aaiResourcesClient;
+
+ @Mock
+ protected AAIObjectMapper MOCK_aaiObjectMapper;
+
+ @Mock
+ protected InjectionHelper MOCK_injectionHelper;
+
+ @Mock
+ protected AAIValidatorImpl MOCK_aaiValidatorImpl;
+
+ @InjectMocks
+ AAIVnfResources aaiVnfResources = new AAIVnfResources();
+
+ @Before
+ public void before() {
+ serviceInstance = buildServiceInstance();
+ genericVnf = buildGenericVnf();
+ cloudRegion = buildCloudRegion();
+ doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
+ }
+
+ @Test
+ public void createVnfandConnectServiceInstanceTest() {
+ doReturn(new org.onap.aai.domain.yang.GenericVnf()).when(MOCK_aaiObjectMapper).mapVnf(genericVnf);
+ doReturn(MOCK_aaiResourcesClient).when(MOCK_aaiResourcesClient).createIfNotExists(isA(AAIResourceUri.class),
+ any(Optional.class));
+ doNothing().when(MOCK_aaiResourcesClient).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
+ genericVnf.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
+
+ aaiVnfResources.createVnfandConnectServiceInstance(genericVnf, serviceInstance);
+
+ assertEquals(OrchestrationStatus.INVENTORIED, genericVnf.getOrchestrationStatus());
+ verify(MOCK_aaiObjectMapper, times(1)).mapVnf(genericVnf);
+ verify(MOCK_aaiResourcesClient, times(1)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class));
+ verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
+ }
+
+ @Test
+ public void createPlatformandConnectVnfTest() {
+ Platform platform = new Platform();
+ platform.setPlatformName("a123");
+ doNothing().when(MOCK_aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class));
+ doReturn(MOCK_aaiResourcesClient).when(MOCK_aaiResourcesClient).createIfNotExists(isA(AAIResourceUri.class),
+ any(Optional.class));
+ aaiVnfResources.createPlatformandConnectVnf(platform, genericVnf);
+ verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), isA(AAIResourceUri.class));
+ }
+
+ @Test
+ public void createLineOfBusinessandConnectVnfTest() {
+ LineOfBusiness lob = new LineOfBusiness();
+ lob.setLineOfBusinessName("a123");
+ doNothing().when(MOCK_aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class));
+ doReturn(MOCK_aaiResourcesClient).when(MOCK_aaiResourcesClient).createIfNotExists(isA(AAIResourceUri.class),
+ any(Optional.class));
+ aaiVnfResources.createLineOfBusinessandConnectVnf(lob, genericVnf);
+ verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), isA(AAIResourceUri.class));
+ }
+
+ @Test
+ public void deleteVnfTest() {
+ doNothing().when(MOCK_aaiResourcesClient).delete(isA(AAIResourceUri.class));
+
+ aaiVnfResources.deleteVnf(genericVnf);
+
+ verify(MOCK_aaiResourcesClient, times(1)).delete(any(AAIResourceUri.class));
+ }
+
+ @Test
+ public void updateOrchestrationStatusVnfTest() {
+ doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.Vnf.class));
+
+ aaiVnfResources.updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ACTIVE);
+
+ verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), ArgumentMatchers.isNull());
+
+ assertEquals(OrchestrationStatus.ACTIVE, genericVnf.getOrchestrationStatus());
+ }
+
+ @Test
+ public void updateObjectVnfTest() {
+ doReturn(new org.onap.aai.domain.yang.GenericVnf()).when(MOCK_aaiObjectMapper).mapVnf(genericVnf);
+ doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.GenericVnf.class));
+
+ aaiVnfResources.updateObjectVnf(genericVnf);
+
+ verify(MOCK_aaiObjectMapper, times(1)).mapVnf(genericVnf);
+ verify(MOCK_aaiResourcesClient, times(1)).update(isA(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.GenericVnf.class));
+ }
+
+ @Test
+ public void getGenericVnfTest() {
+ Optional<org.onap.aai.domain.yang.GenericVnf> vnf = Optional.of(new org.onap.aai.domain.yang.GenericVnf());
+ vnf.get().setVnfId("vnfId");
+ doReturn(vnf).when(MOCK_aaiResourcesClient).get(eq(org.onap.aai.domain.yang.GenericVnf.class),
+ isA(AAIResourceUri.class));
+ aaiVnfResources.getGenericVnf("vnfId");
+ verify(MOCK_aaiResourcesClient, times(1)).get(eq(org.onap.aai.domain.yang.GenericVnf.class),
+ isA(AAIResourceUri.class));
+ }
+
+ @Test
+ public void checkInMaintFlagTest() {
+ Optional<org.onap.aai.domain.yang.GenericVnf> vnf = Optional.of(new org.onap.aai.domain.yang.GenericVnf());
+ vnf.get().setVnfId("vnfId");
+ vnf.get().setInMaint(true);
+ doReturn(vnf).when(MOCK_aaiResourcesClient).get(eq(org.onap.aai.domain.yang.GenericVnf.class),
+ isA(AAIResourceUri.class));
+ boolean inMaintFlag = aaiVnfResources.checkInMaintFlag("vnfId");
+ verify(MOCK_aaiResourcesClient, times(1)).get(eq(org.onap.aai.domain.yang.GenericVnf.class),
+ isA(AAIResourceUri.class));
+ assertEquals(inMaintFlag, true);
+ }
+
+ @Test
+ public void connectVnfToTenantTest() throws Exception {
+ aaiVnfResources.connectVnfToTenant(genericVnf, cloudRegion);
+ verify(MOCK_aaiResourcesClient, times(1)).connect(
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.TENANT, cloudRegion.getCloudOwner(),
+ cloudRegion.getLcpCloudRegionId(), cloudRegion.getTenantId())),
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, genericVnf.getVnfId())));
+ }
+
+ @Test
+ public void connectVnfToCloudRegionTest() throws Exception {
+ aaiVnfResources.connectVnfToCloudRegion(genericVnf, cloudRegion);
+ verify(MOCK_aaiResourcesClient, times(1)).connect(
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, genericVnf.getVnfId())),
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, cloudRegion.getCloudOwner(),
+ cloudRegion.getLcpCloudRegionId())));
+ }
+
+
+ @Test
+ public void checkVnfClosedLoopDisabledFlagTest() {
+ Optional<org.onap.aai.domain.yang.GenericVnf> vnf = Optional.of(new org.onap.aai.domain.yang.GenericVnf());
+ vnf.get().setVnfId("vnfId");
+ vnf.get().setIsClosedLoopDisabled(true);
+ doReturn(vnf).when(MOCK_aaiResourcesClient).get(eq(org.onap.aai.domain.yang.GenericVnf.class),
+ isA(AAIResourceUri.class));
+ boolean isCheckVnfClosedLoopDisabledFlag = aaiVnfResources.checkVnfClosedLoopDisabledFlag("vnfId");
+ verify(MOCK_aaiResourcesClient, times(1)).get(eq(org.onap.aai.domain.yang.GenericVnf.class),
+ isA(AAIResourceUri.class));
+ assertEquals(isCheckVnfClosedLoopDisabledFlag, true);
+ }
+
+ @Test
+ public void checkVnfPserversLockedFlagTest() throws IOException {
+
+ Optional<org.onap.aai.domain.yang.GenericVnf> vnf = Optional.of(new org.onap.aai.domain.yang.GenericVnf());
+ vnf.get().setVnfId("vnfId");
+ doReturn(vnf).when(MOCK_aaiResourcesClient).get(eq(org.onap.aai.domain.yang.GenericVnf.class),
+ isA(AAIResourceUri.class));
+ doReturn(true).when(MOCK_aaiValidatorImpl).isPhysicalServerLocked("vnfId");
+ boolean isVnfPserversLockedFlag = aaiVnfResources.checkVnfPserversLockedFlag("vnfId");
+ verify(MOCK_aaiResourcesClient, times(1)).get(eq(org.onap.aai.domain.yang.GenericVnf.class),
+ isA(AAIResourceUri.class));
+ verify(MOCK_aaiValidatorImpl, times(1)).isPhysicalServerLocked(isA(String.class));
+ assertTrue(isVnfPserversLockedFlag);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVolumeGroupResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVolumeGroupResourcesTest.java
index 6a44ed649e..2bdcf30a4c 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVolumeGroupResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVolumeGroupResourcesTest.java
@@ -27,7 +27,6 @@ import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -46,101 +45,105 @@ import org.onap.so.client.aai.mapper.AAIObjectMapper;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
@RunWith(MockitoJUnitRunner.Silent.class)
-public class AAIVolumeGroupResourcesTest extends TestDataSetup{
- @InjectMocks
- private AAIVolumeGroupResources aaiVolumeGroupResources = new AAIVolumeGroupResources();
+public class AAIVolumeGroupResourcesTest extends TestDataSetup {
+ @InjectMocks
+ private AAIVolumeGroupResources aaiVolumeGroupResources = new AAIVolumeGroupResources();
+
+ private CloudRegion cloudRegion;
+ private VolumeGroup volumeGroup;
+
+ @Mock
+ protected AAIResourcesClient MOCK_aaiResourcesClient;
+
+ @Mock
+ protected AAIObjectMapper MOCK_aaiObjectMapper;
+
+ @Mock
+ protected InjectionHelper MOCK_injectionHelper;
+
+ @Before
+ public void before() {
+ cloudRegion = buildCloudRegion();
+ volumeGroup = buildVolumeGroup();
+ doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
+ }
+
+
- private CloudRegion cloudRegion;
- private VolumeGroup volumeGroup;
+ @Test
+ public void updateOrchestrationStatusVolumeGroupTest() throws Exception {
+ volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
- @Mock
- protected AAIResourcesClient MOCK_aaiResourcesClient;
+ doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.VolumeGroup.class));
- @Mock
- protected AAIObjectMapper MOCK_aaiObjectMapper;
+ aaiVolumeGroupResources.updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion,
+ OrchestrationStatus.ACTIVE);
- @Mock
- protected InjectionHelper MOCK_injectionHelper;
+ verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), ArgumentMatchers.isNull());
- @Before
- public void before() {
- cloudRegion = buildCloudRegion();
- volumeGroup = buildVolumeGroup();
- doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
- }
+ assertEquals(OrchestrationStatus.ACTIVE, volumeGroup.getOrchestrationStatus());
+ }
+ @Test
+ public void createVolumeGroupTest() throws Exception {
+ volumeGroup.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
+ doNothing().when(MOCK_aaiResourcesClient).create(isA(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.VolumeGroup.class));
- @Test
- public void updateOrchestrationStatusVolumeGroupTest() throws Exception {
- volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
+ aaiVolumeGroupResources.createVolumeGroup(volumeGroup, cloudRegion);
- doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.VolumeGroup.class));
+ verify(MOCK_aaiResourcesClient, times(1)).create(any(AAIResourceUri.class), ArgumentMatchers.isNull());
- aaiVolumeGroupResources.updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.ACTIVE);
+ assertEquals(OrchestrationStatus.ASSIGNED, volumeGroup.getOrchestrationStatus());
+ }
- verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), ArgumentMatchers.isNull());
+ @Test
+ public void connectVolumeGroupToVnfTest() throws Exception {
- assertEquals(OrchestrationStatus.ACTIVE, volumeGroup.getOrchestrationStatus());
- }
+ volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
- @Test
- public void createVolumeGroupTest() throws Exception {
- volumeGroup.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
+ doNothing().when(MOCK_aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class));
- doNothing().when(MOCK_aaiResourcesClient).create(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.VolumeGroup.class));
+ aaiVolumeGroupResources.connectVolumeGroupToTenant(volumeGroup, cloudRegion);
- aaiVolumeGroupResources.createVolumeGroup(volumeGroup, cloudRegion);
+ verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
+ }
- verify(MOCK_aaiResourcesClient, times(1)).create(any(AAIResourceUri.class), ArgumentMatchers.isNull());
+ @Test
+ public void connectVolumeGroupToTenantTest() throws Exception {
+ GenericVnf genericVnf = buildGenericVnf();
- assertEquals(OrchestrationStatus.ASSIGNED, volumeGroup.getOrchestrationStatus());
- }
+ volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
- @Test
- public void connectVolumeGroupToVnfTest() throws Exception {
-
- volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
-
- doNothing().when(MOCK_aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class));
+ doNothing().when(MOCK_aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class));
- aaiVolumeGroupResources.connectVolumeGroupToTenant(volumeGroup, cloudRegion);
+ aaiVolumeGroupResources.connectVolumeGroupToVnf(genericVnf, volumeGroup, cloudRegion);
- verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
- }
-
- @Test
- public void connectVolumeGroupToTenantTest() throws Exception {
- GenericVnf genericVnf = buildGenericVnf();
+ verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
+ }
- volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
+ @Test
+ public void deleteVolumeGroupTest() {
+ doNothing().when(MOCK_aaiResourcesClient).delete(isA(AAIResourceUri.class));
- doNothing().when(MOCK_aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class));
+ aaiVolumeGroupResources.deleteVolumeGroup(volumeGroup, cloudRegion);
- aaiVolumeGroupResources.connectVolumeGroupToVnf(genericVnf, volumeGroup, cloudRegion);
+ verify(MOCK_aaiResourcesClient, times(1)).delete(any(AAIResourceUri.class));
+ }
- verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
- }
+ @Test
+ public void updateHeatStackIdVolumeGroupTest() throws Exception {
+ volumeGroup.setHeatStackId("testVolumeHeatStackId");
- @Test
- public void deleteVolumeGroupTest() {
- doNothing().when(MOCK_aaiResourcesClient).delete(isA(AAIResourceUri.class));
+ doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.VolumeGroup.class));
- aaiVolumeGroupResources.deleteVolumeGroup(volumeGroup, cloudRegion);
+ aaiVolumeGroupResources.updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion);
- verify(MOCK_aaiResourcesClient, times(1)).delete(any(AAIResourceUri.class));
- }
-
- @Test
- public void updateHeatStackIdVolumeGroupTest() throws Exception {
- volumeGroup.setHeatStackId("testVolumeHeatStackId");
-
- doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.VolumeGroup.class));
-
- aaiVolumeGroupResources.updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion);
+ verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), ArgumentMatchers.isNull());
- verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), ArgumentMatchers.isNull());
-
- assertEquals("testVolumeHeatStackId", volumeGroup.getHeatStackId());
- }
+ assertEquals("testVolumeHeatStackId", volumeGroup.getHeatStackId());
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVpnBindingResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVpnBindingResourcesTest.java
index c50b084df2..0cbdee396f 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVpnBindingResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVpnBindingResourcesTest.java
@@ -29,9 +29,7 @@ import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import java.util.Optional;
-
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
@@ -42,76 +40,84 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding;
import org.onap.so.client.aai.entities.uri.AAIResourceUri;
-public class AAIVpnBindingResourcesTest extends BaseTaskTest{
-
- @InjectMocks
- private AAIVpnBindingResources aaiVpnBindingResources = new AAIVpnBindingResources();
-
- private Customer customer;
-
- @Before
- public void before() {
- customer = buildCustomer();
- doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
- }
-
- @Test
- public void createCustomerTest() {
- org.onap.aai.domain.yang.Customer mappedCustomer = new org.onap.aai.domain.yang.Customer();
- mappedCustomer.setGlobalCustomerId(customer.getGlobalCustomerId());
-
- doReturn(mappedCustomer).when(MOCK_aaiObjectMapper).mapCustomer(customer);
- doNothing().when(MOCK_aaiResourcesClient).create(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.Customer.class));
-
- aaiVpnBindingResources.createCustomer(customer);
-
- verify(MOCK_aaiResourcesClient, times(1)).create(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.Customer.class));
- verify(MOCK_aaiObjectMapper, times(1)).mapCustomer(customer);
- }
-
- @Test
- public void getVpnBindingTest () {
- org.onap.aai.domain.yang.VpnBinding vpnBinding = new org.onap.aai.domain.yang.VpnBinding();
- vpnBinding.setVpnId("vnfId");
- when(MOCK_aaiResourcesClient.get(eq(org.onap.aai.domain.yang.VpnBinding.class),isA(AAIResourceUri.class))).thenReturn(Optional.of(vpnBinding));
- aaiVpnBindingResources.getVpnBinding("vpnId");
- verify(MOCK_aaiResourcesClient, times(1)).get(eq(org.onap.aai.domain.yang.VpnBinding.class),isA(AAIResourceUri.class));
- }
+public class AAIVpnBindingResourcesTest extends BaseTaskTest {
+
+ @InjectMocks
+ private AAIVpnBindingResources aaiVpnBindingResources = new AAIVpnBindingResources();
+
+ private Customer customer;
+
+ @Before
+ public void before() {
+ customer = buildCustomer();
+ doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
+ }
+
+ @Test
+ public void createCustomerTest() {
+ org.onap.aai.domain.yang.Customer mappedCustomer = new org.onap.aai.domain.yang.Customer();
+ mappedCustomer.setGlobalCustomerId(customer.getGlobalCustomerId());
+
+ doReturn(mappedCustomer).when(MOCK_aaiObjectMapper).mapCustomer(customer);
+ doNothing().when(MOCK_aaiResourcesClient).create(isA(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.Customer.class));
+
+ aaiVpnBindingResources.createCustomer(customer);
+
+ verify(MOCK_aaiResourcesClient, times(1)).create(isA(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.Customer.class));
+ verify(MOCK_aaiObjectMapper, times(1)).mapCustomer(customer);
+ }
+
+ @Test
+ public void getVpnBindingTest() {
+ org.onap.aai.domain.yang.VpnBinding vpnBinding = new org.onap.aai.domain.yang.VpnBinding();
+ vpnBinding.setVpnId("vnfId");
+ when(MOCK_aaiResourcesClient.get(eq(org.onap.aai.domain.yang.VpnBinding.class), isA(AAIResourceUri.class)))
+ .thenReturn(Optional.of(vpnBinding));
+ aaiVpnBindingResources.getVpnBinding("vpnId");
+ verify(MOCK_aaiResourcesClient, times(1)).get(eq(org.onap.aai.domain.yang.VpnBinding.class),
+ isA(AAIResourceUri.class));
+ }
@Test
public void existsCustomerTest() {
- when(MOCK_aaiResourcesClient.exists(isA(AAIResourceUri.class))).thenReturn(true);
- boolean isCustomerExist = aaiVpnBindingResources.existsCustomer(customer);
- verify(MOCK_aaiResourcesClient, times(1)).exists(isA(AAIResourceUri.class));
- assertEquals(true,isCustomerExist);
- }
+ when(MOCK_aaiResourcesClient.exists(isA(AAIResourceUri.class))).thenReturn(true);
+ boolean isCustomerExist = aaiVpnBindingResources.existsCustomer(customer);
+ verify(MOCK_aaiResourcesClient, times(1)).exists(isA(AAIResourceUri.class));
+ assertEquals(true, isCustomerExist);
+ }
@Test
public void getVpnBindingByCustomerVpnIdTest() {
- when(MOCK_aaiResourcesClient.get(eq(VpnBindings.class),isA(AAIResourceUri.class))).thenReturn(Optional.of(new VpnBindings()));
- Optional<VpnBindings> vpnBindings = aaiVpnBindingResources.getVpnBindingByCustomerVpnId("testCustomerVpnId");
- assertNotNull(vpnBindings.get());
- verify(MOCK_aaiResourcesClient, times(1)).get(eq(org.onap.aai.domain.yang.VpnBindings.class),isA(AAIResourceUri.class));
- }
-
- @Test
- public void createVpnBindingTest() {
- doNothing().when(MOCK_aaiResourcesClient).create(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.VpnBinding.class));
- org.onap.aai.domain.yang.VpnBinding mappedVpnBinding = new org.onap.aai.domain.yang.VpnBinding();
- mappedVpnBinding.setVpnName("test");
-
- doReturn(mappedVpnBinding).when(MOCK_aaiObjectMapper).mapVpnBinding(isA(VpnBinding.class));
- VpnBinding vpnBinding = buildVpnBinding();
- aaiVpnBindingResources.createVpnBinding(vpnBinding);
-
- verify(MOCK_aaiResourcesClient, times(1)).create(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.VpnBinding.class));
- verify(MOCK_aaiObjectMapper, times(1)).mapVpnBinding(isA(VpnBinding.class));
- }
-
- @Test
- public void connectCustomerToVpnBinding() {
- doNothing().when(MOCK_aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class));
- aaiVpnBindingResources.connectCustomerToVpnBinding("testCustId","testVpnId");
- verify(MOCK_aaiResourcesClient,times(1)).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class));
- }
+ when(MOCK_aaiResourcesClient.get(eq(VpnBindings.class), isA(AAIResourceUri.class)))
+ .thenReturn(Optional.of(new VpnBindings()));
+ Optional<VpnBindings> vpnBindings = aaiVpnBindingResources.getVpnBindingByCustomerVpnId("testCustomerVpnId");
+ assertNotNull(vpnBindings.get());
+ verify(MOCK_aaiResourcesClient, times(1)).get(eq(org.onap.aai.domain.yang.VpnBindings.class),
+ isA(AAIResourceUri.class));
+ }
+
+ @Test
+ public void createVpnBindingTest() {
+ doNothing().when(MOCK_aaiResourcesClient).create(isA(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.VpnBinding.class));
+ org.onap.aai.domain.yang.VpnBinding mappedVpnBinding = new org.onap.aai.domain.yang.VpnBinding();
+ mappedVpnBinding.setVpnName("test");
+
+ doReturn(mappedVpnBinding).when(MOCK_aaiObjectMapper).mapVpnBinding(isA(VpnBinding.class));
+ VpnBinding vpnBinding = buildVpnBinding();
+ aaiVpnBindingResources.createVpnBinding(vpnBinding);
+
+ verify(MOCK_aaiResourcesClient, times(1)).create(isA(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.VpnBinding.class));
+ verify(MOCK_aaiObjectMapper, times(1)).mapVpnBinding(isA(VpnBinding.class));
+ }
+
+ @Test
+ public void connectCustomerToVpnBinding() {
+ doNothing().when(MOCK_aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class));
+ aaiVpnBindingResources.connectCustomerToVpnBinding("testCustId", "testVpnId");
+ verify(MOCK_aaiResourcesClient, times(1)).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class));
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/NamingServiceResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/NamingServiceResourcesTest.java
index 629e98abb2..195c89a651 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/NamingServiceResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/NamingServiceResourcesTest.java
@@ -26,9 +26,7 @@ import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import java.util.List;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -49,57 +47,58 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@RunWith(MockitoJUnitRunner.Silent.class)
-public class NamingServiceResourcesTest extends TestDataSetup{
- @InjectMocks
- private NamingServiceResources namingServiceResources = new NamingServiceResources();
-
- private InstanceGroup instanceGroup;
-
- @Mock
- protected NamingRequestObjectBuilder MOCK_namingRequestObjectBuilder;
-
- @Mock
- protected NamingClient MOCK_namingClient;
-
- @Before
- public void before() {
- instanceGroup = buildInstanceGroup();
- }
-
- @Test
- public void generateInstanceGroupNameTest() throws Exception {
- NameGenResponse name = new NameGenResponse();
- ResponseEntity<NameGenResponse> resp = new ResponseEntity<>(name, null, HttpStatus.OK);
- Element element = new Element();
-
- NameGenRequest req = new NameGenRequest();
- doReturn(element).when(MOCK_namingRequestObjectBuilder).elementMapper(isA(String.class), isA(String.class),
- isA(String.class), isA(String.class), isA(String.class));
- doReturn("generatedInstanceGroupName").when(MOCK_namingClient).postNameGenRequest(isA(NameGenRequest.class));
- doReturn(req).when(MOCK_namingRequestObjectBuilder).nameGenRequestMapper(isA(List.class));
-
- String generatedName = namingServiceResources.generateInstanceGroupName(instanceGroup, "policyInstanceName", "nfNamingCode");
-
- verify(MOCK_namingClient, times(1)).postNameGenRequest(any(NameGenRequest.class));
- assertEquals(generatedName, "generatedInstanceGroupName");
- }
-
- @Test
- public void deleteInstanceGroupNameTest() throws Exception {
- NameGenDeleteResponse name = new NameGenDeleteResponse();
- ResponseEntity<NameGenDeleteResponse> resp = new ResponseEntity<>(name, null, HttpStatus.OK);
- Deleteelement deleteElement = new Deleteelement();
- deleteElement.setExternalKey(instanceGroup.getId());
- NameGenDeleteRequest req = new NameGenDeleteRequest();
- doReturn(deleteElement).when(MOCK_namingRequestObjectBuilder).deleteElementMapper(isA(String.class));
- doReturn("").when(MOCK_namingClient).deleteNameGenRequest(isA(NameGenDeleteRequest.class));
- doReturn(req).when(MOCK_namingRequestObjectBuilder).nameGenDeleteRequestMapper(isA(List.class));
-
- namingServiceResources.deleteInstanceGroupName(instanceGroup);
-
- verify(MOCK_namingClient, times(1)).deleteNameGenRequest(any(NameGenDeleteRequest.class));
-
- }
-
-
+public class NamingServiceResourcesTest extends TestDataSetup {
+ @InjectMocks
+ private NamingServiceResources namingServiceResources = new NamingServiceResources();
+
+ private InstanceGroup instanceGroup;
+
+ @Mock
+ protected NamingRequestObjectBuilder MOCK_namingRequestObjectBuilder;
+
+ @Mock
+ protected NamingClient MOCK_namingClient;
+
+ @Before
+ public void before() {
+ instanceGroup = buildInstanceGroup();
+ }
+
+ @Test
+ public void generateInstanceGroupNameTest() throws Exception {
+ NameGenResponse name = new NameGenResponse();
+ ResponseEntity<NameGenResponse> resp = new ResponseEntity<>(name, null, HttpStatus.OK);
+ Element element = new Element();
+
+ NameGenRequest req = new NameGenRequest();
+ doReturn(element).when(MOCK_namingRequestObjectBuilder).elementMapper(isA(String.class), isA(String.class),
+ isA(String.class), isA(String.class), isA(String.class));
+ doReturn("generatedInstanceGroupName").when(MOCK_namingClient).postNameGenRequest(isA(NameGenRequest.class));
+ doReturn(req).when(MOCK_namingRequestObjectBuilder).nameGenRequestMapper(isA(List.class));
+
+ String generatedName =
+ namingServiceResources.generateInstanceGroupName(instanceGroup, "policyInstanceName", "nfNamingCode");
+
+ verify(MOCK_namingClient, times(1)).postNameGenRequest(any(NameGenRequest.class));
+ assertEquals(generatedName, "generatedInstanceGroupName");
+ }
+
+ @Test
+ public void deleteInstanceGroupNameTest() throws Exception {
+ NameGenDeleteResponse name = new NameGenDeleteResponse();
+ ResponseEntity<NameGenDeleteResponse> resp = new ResponseEntity<>(name, null, HttpStatus.OK);
+ Deleteelement deleteElement = new Deleteelement();
+ deleteElement.setExternalKey(instanceGroup.getId());
+ NameGenDeleteRequest req = new NameGenDeleteRequest();
+ doReturn(deleteElement).when(MOCK_namingRequestObjectBuilder).deleteElementMapper(isA(String.class));
+ doReturn("").when(MOCK_namingClient).deleteNameGenRequest(isA(NameGenDeleteRequest.class));
+ doReturn(req).when(MOCK_namingRequestObjectBuilder).nameGenDeleteRequestMapper(isA(List.class));
+
+ namingServiceResources.deleteInstanceGroupName(instanceGroup);
+
+ verify(MOCK_namingClient, times(1)).deleteNameGenRequest(any(NameGenDeleteRequest.class));
+
+ }
+
+
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/NetworkAdapterResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/NetworkAdapterResourcesTest.java
index 1ff9d2af2d..96e2a74297 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/NetworkAdapterResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/NetworkAdapterResourcesTest.java
@@ -26,13 +26,11 @@ import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -61,159 +59,182 @@ import org.onap.so.client.adapter.network.NetworkAdapterClientImpl;
import org.onap.so.client.adapter.network.mapper.NetworkAdapterObjectMapper;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
import org.onap.so.entity.MsoRequest;
-
import com.shazam.shazamcrest.matcher.Matchers;
@RunWith(MockitoJUnitRunner.Silent.class)
-public class NetworkAdapterResourcesTest extends TestDataSetup{
-
- @InjectMocks
- private NetworkAdapterResources networkAdapterResources = new NetworkAdapterResources();
-
- @Mock
- protected NetworkAdapterClientImpl MOCK_networkAdapterClient;
-
- @Mock
- protected NetworkAdapterObjectMapper MOCK_networkAdapterObjectMapper;
-
- private L3Network l3Network;
- private RequestContext requestContext;
- private ServiceInstance serviceInstance;
- private CloudRegion cloudRegion;
- private OrchestrationContext orchestrationContext;
- private Customer customer;
- Map<String, String> userInput;
-
- @Before
- public void before() {
- requestContext = buildRequestContext();
-
- customer = buildCustomer();
-
- serviceInstance = buildServiceInstance();
-
- cloudRegion = buildCloudRegion();
-
- orchestrationContext = buildOrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(true);
-
- userInput = buildUserInput();
-
- l3Network = buildL3Network();
- }
-
- @Test
- public void createNetworTest() throws Exception {
- String cloudRegionPo = "cloudRegionPo";
- CreateNetworkRequest expectedCreateNetworkRequest = new CreateNetworkRequest();
-
- expectedCreateNetworkRequest.setCloudSiteId(cloudRegionPo);
- expectedCreateNetworkRequest.setTenantId(cloudRegion.getTenantId());
- expectedCreateNetworkRequest.setNetworkId(l3Network.getNetworkId());
- expectedCreateNetworkRequest.setNetworkName(l3Network.getNetworkName());
- expectedCreateNetworkRequest.setBackout(false);
- expectedCreateNetworkRequest.setFailIfExists(true);
-
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId(requestContext.getMsoRequestId());
- msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
- expectedCreateNetworkRequest.setMsoRequest(msoRequest);
- expectedCreateNetworkRequest.setSkipAAI(true);
-
- Subnet openstackSubnet = new Subnet();
- HostRoute hostRoute = new HostRoute();
- hostRoute.setHostRouteId("hostRouteId");
- hostRoute.setNextHop("nextHop");
- hostRoute.setRoutePrefix("routePrefix");
- openstackSubnet.getHostRoutes().add(hostRoute);
- List<Subnet> subnetList = new ArrayList<Subnet>();
- subnetList.add(openstackSubnet);
- l3Network.getSubnets().add(openstackSubnet);
-
- l3Network.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
-
- CreateNetworkRequest createNetworkRequest = new CreateNetworkRequest();
- createNetworkRequest.setCloudSiteId("cloudSiteId");
-
- CreateNetworkResponse expectedCreateNetworkResponse = new CreateNetworkResponse();
- expectedCreateNetworkResponse.setNetworkStackId("networkStackId");
- expectedCreateNetworkResponse.setNetworkCreated(true);
-
-
- doReturn(expectedCreateNetworkResponse).when(MOCK_networkAdapterClient).createNetwork(isA(CreateNetworkRequest.class));
-
- doReturn(createNetworkRequest).when(MOCK_networkAdapterObjectMapper).createNetworkRequestMapper(isA(RequestContext.class), isA(CloudRegion.class), isA(OrchestrationContext.class), isA(ServiceInstance.class), isA(L3Network.class), isA(Map.class), isA(String.class), isA(Customer.class));
-
- CreateNetworkResponse actualCreateNetwrokResponse = (networkAdapterResources.createNetwork(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, customer)).get();
-
- verify(MOCK_networkAdapterClient, times(1)).createNetwork(createNetworkRequest);
-
- verify(MOCK_networkAdapterObjectMapper, times(1)).createNetworkRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, customer);
-
- assertThat(expectedCreateNetworkResponse, Matchers.sameBeanAs(actualCreateNetwrokResponse));
- }
-
- @Test
- public void rollbackCreateNetworkTest() throws Exception {
- String cloudRegionPo = "cloudRegionPo";
- RollbackNetworkResponse expectedRollbackNetworkResponse = new RollbackNetworkResponse();
- expectedRollbackNetworkResponse.setMessageId("messageId");
- expectedRollbackNetworkResponse.setNetworkRolledBack(true);
-
- RollbackNetworkRequest rollbackNetworkRequest = new RollbackNetworkRequest();
- rollbackNetworkRequest.setMessageId("messageId");
-
- RollbackNetworkResponse rollbackNetworkResponse = new RollbackNetworkResponse();
- rollbackNetworkResponse.setMessageId("messageId");
- rollbackNetworkResponse.setNetworkRolledBack(true);
-
- CreateNetworkResponse createNetworkResponse = new CreateNetworkResponse();
- createNetworkResponse.setMessageId("messageId");
-
- doReturn(rollbackNetworkResponse).when(MOCK_networkAdapterClient).rollbackNetwork(isA(String.class), isA(RollbackNetworkRequest.class));
-
- doReturn(rollbackNetworkRequest).when(MOCK_networkAdapterObjectMapper).createNetworkRollbackRequestMapper(isA(RequestContext.class), isA(CloudRegion.class), isA(OrchestrationContext.class), isA(ServiceInstance.class), isA(L3Network.class), isA(Map.class), isA(String.class), isA(CreateNetworkResponse.class));
-
- RollbackNetworkResponse actualRollbackCreateNetwrokResponse = (networkAdapterResources.rollbackCreateNetwork(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, createNetworkResponse)).get();
-
- verify(MOCK_networkAdapterClient, times(1)).rollbackNetwork(l3Network.getNetworkId(), rollbackNetworkRequest);
-
- verify(MOCK_networkAdapterObjectMapper, times(1)).createNetworkRollbackRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, createNetworkResponse);
-
- assertThat(expectedRollbackNetworkResponse, Matchers.sameBeanAs(actualRollbackCreateNetwrokResponse));
- }
-
- @Test
- public void updateNetworkTest() throws UnsupportedEncodingException, NetworkAdapterClientException {
-
- doReturn(new UpdateNetworkRequest()).when(MOCK_networkAdapterObjectMapper).createNetworkUpdateRequestMapper(isA(RequestContext.class), isA(CloudRegion.class), isA(OrchestrationContext.class), isA(ServiceInstance.class), isA(L3Network.class), isA(Map.class), isA(Customer.class));
-
- doReturn(new UpdateNetworkResponse()).when(MOCK_networkAdapterClient).updateNetwork(isA(String.class), isA(UpdateNetworkRequest.class));
-
- Optional<UpdateNetworkResponse> actualUpdateNetworkResponse = networkAdapterResources.updateNetwork(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, customer);
-
-
- verify(MOCK_networkAdapterObjectMapper, times(1)).createNetworkUpdateRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, customer);
- verify(MOCK_networkAdapterClient, times(1)).updateNetwork(isA(String.class), isA(UpdateNetworkRequest.class));
- assertNotNull(actualUpdateNetworkResponse);
- }
-
- @Test
- public void deleteNetwork_DeleteAction_Test() throws UnsupportedEncodingException, NetworkAdapterClientException {
-
- DeleteNetworkRequest deleteNetworkRequest = new DeleteNetworkRequest();
- doReturn(deleteNetworkRequest).when(MOCK_networkAdapterObjectMapper).deleteNetworkRequestMapper(requestContext, cloudRegion, serviceInstance, l3Network);
-
- DeleteNetworkResponse expectedDeleteNetworkResponse = new DeleteNetworkResponse();
-
- doReturn(expectedDeleteNetworkResponse).when(MOCK_networkAdapterClient).deleteNetwork(l3Network.getNetworkId(), deleteNetworkRequest);
-
- Optional<DeleteNetworkResponse> actualODeleteNetworkResponse = networkAdapterResources.deleteNetwork(requestContext, cloudRegion, serviceInstance, l3Network);
- DeleteNetworkResponse actualDeleteNetworkResponse = actualODeleteNetworkResponse.get();
-
- verify(MOCK_networkAdapterObjectMapper, times(1)).deleteNetworkRequestMapper(requestContext, cloudRegion, serviceInstance, l3Network);
- verify(MOCK_networkAdapterClient, times(1)).deleteNetwork(l3Network.getNetworkId(), deleteNetworkRequest);
- assertThat(expectedDeleteNetworkResponse, Matchers.sameBeanAs(actualDeleteNetworkResponse));
- }
+public class NetworkAdapterResourcesTest extends TestDataSetup {
+
+ @InjectMocks
+ private NetworkAdapterResources networkAdapterResources = new NetworkAdapterResources();
+
+ @Mock
+ protected NetworkAdapterClientImpl MOCK_networkAdapterClient;
+
+ @Mock
+ protected NetworkAdapterObjectMapper MOCK_networkAdapterObjectMapper;
+
+ private L3Network l3Network;
+ private RequestContext requestContext;
+ private ServiceInstance serviceInstance;
+ private CloudRegion cloudRegion;
+ private OrchestrationContext orchestrationContext;
+ private Customer customer;
+ Map<String, String> userInput;
+
+ @Before
+ public void before() {
+ requestContext = buildRequestContext();
+
+ customer = buildCustomer();
+
+ serviceInstance = buildServiceInstance();
+
+ cloudRegion = buildCloudRegion();
+
+ orchestrationContext = buildOrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(true);
+
+ userInput = buildUserInput();
+
+ l3Network = buildL3Network();
+ }
+
+ @Test
+ public void createNetworTest() throws Exception {
+ String cloudRegionPo = "cloudRegionPo";
+ CreateNetworkRequest expectedCreateNetworkRequest = new CreateNetworkRequest();
+
+ expectedCreateNetworkRequest.setCloudSiteId(cloudRegionPo);
+ expectedCreateNetworkRequest.setTenantId(cloudRegion.getTenantId());
+ expectedCreateNetworkRequest.setNetworkId(l3Network.getNetworkId());
+ expectedCreateNetworkRequest.setNetworkName(l3Network.getNetworkName());
+ expectedCreateNetworkRequest.setBackout(false);
+ expectedCreateNetworkRequest.setFailIfExists(true);
+
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId(requestContext.getMsoRequestId());
+ msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
+ expectedCreateNetworkRequest.setMsoRequest(msoRequest);
+ expectedCreateNetworkRequest.setSkipAAI(true);
+
+ Subnet openstackSubnet = new Subnet();
+ HostRoute hostRoute = new HostRoute();
+ hostRoute.setHostRouteId("hostRouteId");
+ hostRoute.setNextHop("nextHop");
+ hostRoute.setRoutePrefix("routePrefix");
+ openstackSubnet.getHostRoutes().add(hostRoute);
+ List<Subnet> subnetList = new ArrayList<Subnet>();
+ subnetList.add(openstackSubnet);
+ l3Network.getSubnets().add(openstackSubnet);
+
+ l3Network.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
+
+ CreateNetworkRequest createNetworkRequest = new CreateNetworkRequest();
+ createNetworkRequest.setCloudSiteId("cloudSiteId");
+
+ CreateNetworkResponse expectedCreateNetworkResponse = new CreateNetworkResponse();
+ expectedCreateNetworkResponse.setNetworkStackId("networkStackId");
+ expectedCreateNetworkResponse.setNetworkCreated(true);
+
+
+ doReturn(expectedCreateNetworkResponse).when(MOCK_networkAdapterClient)
+ .createNetwork(isA(CreateNetworkRequest.class));
+
+ doReturn(createNetworkRequest).when(MOCK_networkAdapterObjectMapper).createNetworkRequestMapper(
+ isA(RequestContext.class), isA(CloudRegion.class), isA(OrchestrationContext.class),
+ isA(ServiceInstance.class), isA(L3Network.class), isA(Map.class), isA(String.class),
+ isA(Customer.class));
+
+ CreateNetworkResponse actualCreateNetwrokResponse =
+ (networkAdapterResources.createNetwork(requestContext, cloudRegion, orchestrationContext,
+ serviceInstance, l3Network, userInput, cloudRegionPo, customer)).get();
+
+ verify(MOCK_networkAdapterClient, times(1)).createNetwork(createNetworkRequest);
+
+ verify(MOCK_networkAdapterObjectMapper, times(1)).createNetworkRequestMapper(requestContext, cloudRegion,
+ orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, customer);
+
+ assertThat(expectedCreateNetworkResponse, Matchers.sameBeanAs(actualCreateNetwrokResponse));
+ }
+
+ @Test
+ public void rollbackCreateNetworkTest() throws Exception {
+ String cloudRegionPo = "cloudRegionPo";
+ RollbackNetworkResponse expectedRollbackNetworkResponse = new RollbackNetworkResponse();
+ expectedRollbackNetworkResponse.setMessageId("messageId");
+ expectedRollbackNetworkResponse.setNetworkRolledBack(true);
+
+ RollbackNetworkRequest rollbackNetworkRequest = new RollbackNetworkRequest();
+ rollbackNetworkRequest.setMessageId("messageId");
+
+ RollbackNetworkResponse rollbackNetworkResponse = new RollbackNetworkResponse();
+ rollbackNetworkResponse.setMessageId("messageId");
+ rollbackNetworkResponse.setNetworkRolledBack(true);
+
+ CreateNetworkResponse createNetworkResponse = new CreateNetworkResponse();
+ createNetworkResponse.setMessageId("messageId");
+
+ doReturn(rollbackNetworkResponse).when(MOCK_networkAdapterClient).rollbackNetwork(isA(String.class),
+ isA(RollbackNetworkRequest.class));
+
+ doReturn(rollbackNetworkRequest).when(MOCK_networkAdapterObjectMapper).createNetworkRollbackRequestMapper(
+ isA(RequestContext.class), isA(CloudRegion.class), isA(OrchestrationContext.class),
+ isA(ServiceInstance.class), isA(L3Network.class), isA(Map.class), isA(String.class),
+ isA(CreateNetworkResponse.class));
+
+ RollbackNetworkResponse actualRollbackCreateNetwrokResponse =
+ (networkAdapterResources.rollbackCreateNetwork(requestContext, cloudRegion, orchestrationContext,
+ serviceInstance, l3Network, userInput, cloudRegionPo, createNetworkResponse)).get();
+
+ verify(MOCK_networkAdapterClient, times(1)).rollbackNetwork(l3Network.getNetworkId(), rollbackNetworkRequest);
+
+ verify(MOCK_networkAdapterObjectMapper, times(1)).createNetworkRollbackRequestMapper(requestContext,
+ cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo,
+ createNetworkResponse);
+
+ assertThat(expectedRollbackNetworkResponse, Matchers.sameBeanAs(actualRollbackCreateNetwrokResponse));
+ }
+
+ @Test
+ public void updateNetworkTest() throws UnsupportedEncodingException, NetworkAdapterClientException {
+
+ doReturn(new UpdateNetworkRequest()).when(MOCK_networkAdapterObjectMapper).createNetworkUpdateRequestMapper(
+ isA(RequestContext.class), isA(CloudRegion.class), isA(OrchestrationContext.class),
+ isA(ServiceInstance.class), isA(L3Network.class), isA(Map.class), isA(Customer.class));
+
+ doReturn(new UpdateNetworkResponse()).when(MOCK_networkAdapterClient).updateNetwork(isA(String.class),
+ isA(UpdateNetworkRequest.class));
+
+ Optional<UpdateNetworkResponse> actualUpdateNetworkResponse = networkAdapterResources.updateNetwork(
+ requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, customer);
+
+
+ verify(MOCK_networkAdapterObjectMapper, times(1)).createNetworkUpdateRequestMapper(requestContext, cloudRegion,
+ orchestrationContext, serviceInstance, l3Network, userInput, customer);
+ verify(MOCK_networkAdapterClient, times(1)).updateNetwork(isA(String.class), isA(UpdateNetworkRequest.class));
+ assertNotNull(actualUpdateNetworkResponse);
+ }
+
+ @Test
+ public void deleteNetwork_DeleteAction_Test() throws UnsupportedEncodingException, NetworkAdapterClientException {
+
+ DeleteNetworkRequest deleteNetworkRequest = new DeleteNetworkRequest();
+ doReturn(deleteNetworkRequest).when(MOCK_networkAdapterObjectMapper).deleteNetworkRequestMapper(requestContext,
+ cloudRegion, serviceInstance, l3Network);
+
+ DeleteNetworkResponse expectedDeleteNetworkResponse = new DeleteNetworkResponse();
+
+ doReturn(expectedDeleteNetworkResponse).when(MOCK_networkAdapterClient).deleteNetwork(l3Network.getNetworkId(),
+ deleteNetworkRequest);
+
+ Optional<DeleteNetworkResponse> actualODeleteNetworkResponse =
+ networkAdapterResources.deleteNetwork(requestContext, cloudRegion, serviceInstance, l3Network);
+ DeleteNetworkResponse actualDeleteNetworkResponse = actualODeleteNetworkResponse.get();
+
+ verify(MOCK_networkAdapterObjectMapper, times(1)).deleteNetworkRequestMapper(requestContext, cloudRegion,
+ serviceInstance, l3Network);
+ verify(MOCK_networkAdapterClient, times(1)).deleteNetwork(l3Network.getNetworkId(), deleteNetworkRequest);
+ assertThat(expectedDeleteNetworkResponse, Matchers.sameBeanAs(actualDeleteNetworkResponse));
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCConfigurationResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCConfigurationResourcesTest.java
index 0023066949..9049fe1965 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCConfigurationResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCConfigurationResourcesTest.java
@@ -24,10 +24,8 @@ import static org.junit.Assert.assertNotNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;
-
import java.net.URI;
import java.net.URISyntaxException;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -50,17 +48,17 @@ import org.onap.so.client.sdnc.beans.SDNCSvcAction;
import org.onap.so.client.sdnc.mapper.GCTopologyOperationRequestMapper;
@RunWith(MockitoJUnitRunner.Silent.class)
-public class SDNCConfigurationResourcesTest extends TestDataSetup{
-
- @InjectMocks
+public class SDNCConfigurationResourcesTest extends TestDataSetup {
+
+ @InjectMocks
private SDNCConfigurationResources sdncConfigurationResources = new SDNCConfigurationResources();
-
- @Mock
- private GCTopologyOperationRequestMapper MOCK_gcTopologyMapper ;
-
- @Mock
- protected SDNCClient MOCK_sdncClient;
-
+
+ @Mock
+ private GCTopologyOperationRequestMapper MOCK_gcTopologyMapper;
+
+ @Mock
+ protected SDNCClient MOCK_sdncClient;
+
private RequestContext requestContext;
private ServiceInstance serviceInstance;
private VpnBondingLink vpnBondingLink;
@@ -68,45 +66,55 @@ public class SDNCConfigurationResourcesTest extends TestDataSetup{
private Customer customer;
@Before
- public void setUp(){
- customer = buildCustomer();
+ public void setUp() {
+ customer = buildCustomer();
requestContext = buildRequestContext();
serviceInstance = buildServiceInstance();
- vpnBondingLink = buildVpnBondingLink();
+ vpnBondingLink = buildVpnBondingLink();
vnf = vpnBondingLink.getInfrastructureServiceProxy().getServiceInstance().getVnfs().get(0);
}
@Test
public void activateVnrConfigurationTest() throws BadResponseException, MapperException, URISyntaxException {
- GenericResourceApiGcTopologyOperationInformation response = sdncConfigurationResources.activateVnrConfiguration(serviceInstance,requestContext,customer,vpnBondingLink.getVnrConfiguration(),vnf,"uuid",new URI("http://localhost"));
- verify(MOCK_gcTopologyMapper).assignOrActivateVnrReqMapper(
- eq(SDNCSvcAction.ACTIVATE), eq(GenericResourceApiRequestActionEnumeration.CREATEGENERICCONFIGURATIONINSTANCE),
- eq(serviceInstance), eq(requestContext), eq(customer), any(Configuration.class), any(GenericVnf.class), any(String.class), any(URI.class));
+ GenericResourceApiGcTopologyOperationInformation response =
+ sdncConfigurationResources.activateVnrConfiguration(serviceInstance, requestContext, customer,
+ vpnBondingLink.getVnrConfiguration(), vnf, "uuid", new URI("http://localhost"));
+ verify(MOCK_gcTopologyMapper).assignOrActivateVnrReqMapper(eq(SDNCSvcAction.ACTIVATE),
+ eq(GenericResourceApiRequestActionEnumeration.CREATEGENERICCONFIGURATIONINSTANCE), eq(serviceInstance),
+ eq(requestContext), eq(customer), any(Configuration.class), any(GenericVnf.class), any(String.class),
+ any(URI.class));
}
@Test
public void assignVnrConfigurationTest() throws BadResponseException, MapperException, URISyntaxException {
- GenericResourceApiGcTopologyOperationInformation response = sdncConfigurationResources.assignVnrConfiguration(serviceInstance,requestContext,customer,vpnBondingLink.getVnrConfiguration(),vnf,"uuid",new URI("http://localhost"));
- verify(MOCK_gcTopologyMapper).assignOrActivateVnrReqMapper(
- eq(SDNCSvcAction.ASSIGN), eq(GenericResourceApiRequestActionEnumeration.CREATEGENERICCONFIGURATIONINSTANCE),
- eq(serviceInstance), eq(requestContext), eq(customer), any(Configuration.class), any(GenericVnf.class), any(String.class), any(URI.class));
+ GenericResourceApiGcTopologyOperationInformation response =
+ sdncConfigurationResources.assignVnrConfiguration(serviceInstance, requestContext, customer,
+ vpnBondingLink.getVnrConfiguration(), vnf, "uuid", new URI("http://localhost"));
+ verify(MOCK_gcTopologyMapper).assignOrActivateVnrReqMapper(eq(SDNCSvcAction.ASSIGN),
+ eq(GenericResourceApiRequestActionEnumeration.CREATEGENERICCONFIGURATIONINSTANCE), eq(serviceInstance),
+ eq(requestContext), eq(customer), any(Configuration.class), any(GenericVnf.class), any(String.class),
+ any(URI.class));
}
@Test
- public void unAssignVnrConfigurationTest() throws BadResponseException, MapperException , URISyntaxException{
- GenericResourceApiGcTopologyOperationInformation response = sdncConfigurationResources.unAssignVnrConfiguration(serviceInstance,requestContext,vpnBondingLink.getVnrConfiguration(),"uuid",new URI("http://localhost"));
- verify(MOCK_gcTopologyMapper).deactivateOrUnassignVnrReqMapper(
- eq(SDNCSvcAction.UNASSIGN), eq(serviceInstance), eq(requestContext), any(Configuration.class), any(String.class), any(URI.class));
+ public void unAssignVnrConfigurationTest() throws BadResponseException, MapperException, URISyntaxException {
+ GenericResourceApiGcTopologyOperationInformation response =
+ sdncConfigurationResources.unAssignVnrConfiguration(serviceInstance, requestContext,
+ vpnBondingLink.getVnrConfiguration(), "uuid", new URI("http://localhost"));
+ verify(MOCK_gcTopologyMapper).deactivateOrUnassignVnrReqMapper(eq(SDNCSvcAction.UNASSIGN), eq(serviceInstance),
+ eq(requestContext), any(Configuration.class), any(String.class), any(URI.class));
}
@Test
- public void deactivateVnrConfigurationTest() throws BadResponseException, MapperException , URISyntaxException{
- GenericResourceApiGcTopologyOperationInformation response = sdncConfigurationResources.deactivateVnrConfiguration(serviceInstance,requestContext,vpnBondingLink.getVnrConfiguration(),"uuid",new URI("http://localhost"));
- verify(MOCK_gcTopologyMapper).deactivateOrUnassignVnrReqMapper(
- eq(SDNCSvcAction.DEACTIVATE), eq(serviceInstance), eq(requestContext), any(Configuration.class), any(String.class), any(URI.class));
+ public void deactivateVnrConfigurationTest() throws BadResponseException, MapperException, URISyntaxException {
+ GenericResourceApiGcTopologyOperationInformation response =
+ sdncConfigurationResources.deactivateVnrConfiguration(serviceInstance, requestContext,
+ vpnBondingLink.getVnrConfiguration(), "uuid", new URI("http://localhost"));
+ verify(MOCK_gcTopologyMapper).deactivateOrUnassignVnrReqMapper(eq(SDNCSvcAction.DEACTIVATE),
+ eq(serviceInstance), eq(requestContext), any(Configuration.class), any(String.class), any(URI.class));
}
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCNetworkResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCNetworkResourcesTest.java
index f275f3c484..327bae5749 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCNetworkResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCNetworkResourcesTest.java
@@ -23,7 +23,6 @@ package org.onap.so.client.orchestration;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -48,122 +47,122 @@ import org.onap.so.client.sdnc.mapper.NetworkTopologyOperationRequestMapper;
@RunWith(MockitoJUnitRunner.Silent.class)
public class SDNCNetworkResourcesTest extends TestDataSetup {
- @InjectMocks
- private SDNCNetworkResources sdncNetworkResources;
-
- @Mock
- protected SDNCClient MOCK_sdncClient;
-
- @Mock
- protected NetworkTopologyOperationRequestMapper MOCK_networkTopologyOperationRequestMapper;
-
- private L3Network network;
- private ServiceInstance serviceInstance;
- private Customer customer;
- private RequestContext requestContext;
- private CloudRegion cloudRegion;
-
- @Before
- public void before() {
- network = buildL3Network();
-
- customer = buildCustomer();
-
- serviceInstance = buildServiceInstance();
-
- requestContext = buildRequestContext();
-
- cloudRegion = new CloudRegion();
- }
-
- @Test
- public void assignNetworkTest() throws Exception {
- doReturn(new GenericResourceApiNetworkOperationInformation()).when(MOCK_networkTopologyOperationRequestMapper)
- .reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,
- GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance,
- customer, requestContext, cloudRegion);
- sdncNetworkResources.assignNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
- verify(MOCK_networkTopologyOperationRequestMapper, times(1)).reqMapper(
- SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,
- GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, customer,
- requestContext, cloudRegion);
- }
-
- @Test
- public void rollbackAssignNetworkTest() throws Exception {
- doReturn(new GenericResourceApiNetworkOperationInformation()).when(MOCK_networkTopologyOperationRequestMapper)
- .reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN,
- GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance,
- customer, requestContext, cloudRegion);
- sdncNetworkResources.rollbackAssignNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
- verify(MOCK_networkTopologyOperationRequestMapper, times(1)).reqMapper(
- SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN,
- GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, customer,
- requestContext, cloudRegion);
- }
-
- @Test
- public void activateNetworkTest() throws Exception {
- doReturn(new GenericResourceApiNetworkOperationInformation()).when(MOCK_networkTopologyOperationRequestMapper)
- .reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ACTIVATE,
- GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance,
- customer, requestContext, cloudRegion);
- sdncNetworkResources.activateNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
- verify(MOCK_networkTopologyOperationRequestMapper, times(1)).reqMapper(
- SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ACTIVATE,
- GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, customer,
- requestContext, cloudRegion);
- }
-
- @Test
- public void deleteNetworkTest() throws Exception {
- doReturn(new GenericResourceApiNetworkOperationInformation()).when(MOCK_networkTopologyOperationRequestMapper)
- .reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.DELETE,
- GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance,
- customer, requestContext, cloudRegion);
- sdncNetworkResources.deleteNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
- verify(MOCK_networkTopologyOperationRequestMapper, times(1)).reqMapper(
- SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.DELETE,
- GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, customer,
- requestContext, cloudRegion);
- }
-
- @Test
- public void test_deactivateNetwork() throws MapperException, BadResponseException {
- doReturn(new GenericResourceApiNetworkOperationInformation()).when(MOCK_networkTopologyOperationRequestMapper)
- .reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.DEACTIVATE,
- GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance,
- customer, requestContext, cloudRegion);
- sdncNetworkResources.deactivateNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
- verify(MOCK_networkTopologyOperationRequestMapper, times(1)).reqMapper(
- SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.DEACTIVATE,
- GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, customer,
- requestContext, cloudRegion);
- }
-
- @Test
- public void changeAssignNetworkTest() throws MapperException, BadResponseException {
- doReturn(new GenericResourceApiNetworkOperationInformation()).when(MOCK_networkTopologyOperationRequestMapper)
- .reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.CHANGE_ASSIGN,
- GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance,
- customer, requestContext, cloudRegion);
- sdncNetworkResources.changeAssignNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
- verify(MOCK_networkTopologyOperationRequestMapper, times(1)).reqMapper(
- SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.CHANGE_ASSIGN,
- GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, customer,
- requestContext, cloudRegion);
- }
-
- @Test
- public void unassignNetwork_Test() throws Exception {
- doReturn(new GenericResourceApiNetworkOperationInformation()).when(MOCK_networkTopologyOperationRequestMapper)
- .reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN,
- GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance,
- customer, requestContext, cloudRegion);
- sdncNetworkResources.unassignNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
- verify(MOCK_networkTopologyOperationRequestMapper, times(1)).reqMapper(
- SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN,
- GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, customer,
- requestContext, cloudRegion);
- }
-} \ No newline at end of file
+ @InjectMocks
+ private SDNCNetworkResources sdncNetworkResources;
+
+ @Mock
+ protected SDNCClient MOCK_sdncClient;
+
+ @Mock
+ protected NetworkTopologyOperationRequestMapper MOCK_networkTopologyOperationRequestMapper;
+
+ private L3Network network;
+ private ServiceInstance serviceInstance;
+ private Customer customer;
+ private RequestContext requestContext;
+ private CloudRegion cloudRegion;
+
+ @Before
+ public void before() {
+ network = buildL3Network();
+
+ customer = buildCustomer();
+
+ serviceInstance = buildServiceInstance();
+
+ requestContext = buildRequestContext();
+
+ cloudRegion = new CloudRegion();
+ }
+
+ @Test
+ public void assignNetworkTest() throws Exception {
+ doReturn(new GenericResourceApiNetworkOperationInformation()).when(MOCK_networkTopologyOperationRequestMapper)
+ .reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,
+ GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance,
+ customer, requestContext, cloudRegion);
+ sdncNetworkResources.assignNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
+ verify(MOCK_networkTopologyOperationRequestMapper, times(1)).reqMapper(
+ SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,
+ GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, customer,
+ requestContext, cloudRegion);
+ }
+
+ @Test
+ public void rollbackAssignNetworkTest() throws Exception {
+ doReturn(new GenericResourceApiNetworkOperationInformation()).when(MOCK_networkTopologyOperationRequestMapper)
+ .reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN,
+ GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance,
+ customer, requestContext, cloudRegion);
+ sdncNetworkResources.rollbackAssignNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
+ verify(MOCK_networkTopologyOperationRequestMapper, times(1)).reqMapper(
+ SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN,
+ GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, customer,
+ requestContext, cloudRegion);
+ }
+
+ @Test
+ public void activateNetworkTest() throws Exception {
+ doReturn(new GenericResourceApiNetworkOperationInformation()).when(MOCK_networkTopologyOperationRequestMapper)
+ .reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ACTIVATE,
+ GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance,
+ customer, requestContext, cloudRegion);
+ sdncNetworkResources.activateNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
+ verify(MOCK_networkTopologyOperationRequestMapper, times(1)).reqMapper(
+ SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ACTIVATE,
+ GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, customer,
+ requestContext, cloudRegion);
+ }
+
+ @Test
+ public void deleteNetworkTest() throws Exception {
+ doReturn(new GenericResourceApiNetworkOperationInformation()).when(MOCK_networkTopologyOperationRequestMapper)
+ .reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.DELETE,
+ GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance,
+ customer, requestContext, cloudRegion);
+ sdncNetworkResources.deleteNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
+ verify(MOCK_networkTopologyOperationRequestMapper, times(1)).reqMapper(
+ SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.DELETE,
+ GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, customer,
+ requestContext, cloudRegion);
+ }
+
+ @Test
+ public void test_deactivateNetwork() throws MapperException, BadResponseException {
+ doReturn(new GenericResourceApiNetworkOperationInformation()).when(MOCK_networkTopologyOperationRequestMapper)
+ .reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.DEACTIVATE,
+ GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance,
+ customer, requestContext, cloudRegion);
+ sdncNetworkResources.deactivateNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
+ verify(MOCK_networkTopologyOperationRequestMapper, times(1)).reqMapper(
+ SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.DEACTIVATE,
+ GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, customer,
+ requestContext, cloudRegion);
+ }
+
+ @Test
+ public void changeAssignNetworkTest() throws MapperException, BadResponseException {
+ doReturn(new GenericResourceApiNetworkOperationInformation()).when(MOCK_networkTopologyOperationRequestMapper)
+ .reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.CHANGE_ASSIGN,
+ GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance,
+ customer, requestContext, cloudRegion);
+ sdncNetworkResources.changeAssignNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
+ verify(MOCK_networkTopologyOperationRequestMapper, times(1)).reqMapper(
+ SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.CHANGE_ASSIGN,
+ GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, customer,
+ requestContext, cloudRegion);
+ }
+
+ @Test
+ public void unassignNetwork_Test() throws Exception {
+ doReturn(new GenericResourceApiNetworkOperationInformation()).when(MOCK_networkTopologyOperationRequestMapper)
+ .reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN,
+ GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance,
+ customer, requestContext, cloudRegion);
+ sdncNetworkResources.unassignNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
+ verify(MOCK_networkTopologyOperationRequestMapper, times(1)).reqMapper(
+ SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN,
+ GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, customer,
+ requestContext, cloudRegion);
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCServiceInstanceResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCServiceInstanceResourcesTest.java
index 509dc1de0d..ad05ac0072 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCServiceInstanceResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCServiceInstanceResourcesTest.java
@@ -26,7 +26,6 @@ import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -46,84 +45,121 @@ import org.onap.so.client.sdnc.beans.SDNCSvcOperation;
import org.onap.so.client.sdnc.mapper.ServiceTopologyOperationMapper;
@RunWith(MockitoJUnitRunner.Silent.class)
-public class SDNCServiceInstanceResourcesTest extends TestDataSetup{
-
- @InjectMocks
+public class SDNCServiceInstanceResourcesTest extends TestDataSetup {
+
+ @InjectMocks
private SDNCServiceInstanceResources sdncServiceInstanceResources;
- @Mock
- protected ServiceTopologyOperationMapper MOCK_serviceTopologyOperationMapper;
- private RequestContext requestContext;
- private ServiceInstance serviceInstance;
- private Customer customer;
-
- @Before
- public void before() {
- requestContext = buildRequestContext();
- serviceInstance = buildServiceInstance();
- customer = buildCustomer();
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
- }
-
- @Test
- public void assignServiceInstanceSuccessTest() throws Exception {
- doReturn(new GenericResourceApiServiceOperationInformation()).when(MOCK_serviceTopologyOperationMapper).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.ASSIGN), eq(GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
- sdncServiceInstanceResources.assignServiceInstance(serviceInstance, customer, requestContext);
- verify(MOCK_serviceTopologyOperationMapper, times(1)).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.ASSIGN), eq(GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
- }
-
- @Test
- public void assignServiceInstanceExceptionTest() throws Exception {
- expectedException.expect(Exception.class);
- doThrow(Exception.class).when(MOCK_serviceTopologyOperationMapper).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.ASSIGN), eq(GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
- sdncServiceInstanceResources.assignServiceInstance(serviceInstance, customer, requestContext);
- }
-
- @Test
- public void deleteServiceInstanceSuccessTest() throws Exception {
- doReturn(new GenericResourceApiServiceOperationInformation()).when(MOCK_serviceTopologyOperationMapper).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DELETE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
- sdncServiceInstanceResources.deleteServiceInstance(serviceInstance, customer, requestContext);
- verify(MOCK_serviceTopologyOperationMapper, times(1)).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DELETE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
- }
-
- @Test
- public void deleteServiceInstanceExceptionTest() throws Exception {
- expectedException.expect(Exception.class);
- doThrow(Exception.class).when(MOCK_serviceTopologyOperationMapper).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DELETE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
- sdncServiceInstanceResources.deleteServiceInstance(serviceInstance, customer, requestContext);
- }
-
- @Test
- public void unassignServiceInstanceSuccessTest() throws Exception {
- doReturn(new GenericResourceApiServiceOperationInformation()).when(MOCK_serviceTopologyOperationMapper).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DELETE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
- sdncServiceInstanceResources.unassignServiceInstance(serviceInstance, customer, requestContext);
- verify(MOCK_serviceTopologyOperationMapper, times(1)).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DELETE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
- }
-
- @Test
- public void unassignServiceInstanceExceptionTest() throws Exception {
- expectedException.expect(Exception.class);
- doThrow(Exception.class).when(MOCK_serviceTopologyOperationMapper).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DELETE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
- sdncServiceInstanceResources.unassignServiceInstance(serviceInstance,customer, requestContext);
- }
+ @Mock
+ protected ServiceTopologyOperationMapper MOCK_serviceTopologyOperationMapper;
+ private RequestContext requestContext;
+ private ServiceInstance serviceInstance;
+ private Customer customer;
+
+ @Before
+ public void before() {
+ requestContext = buildRequestContext();
+ serviceInstance = buildServiceInstance();
+ customer = buildCustomer();
+ customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
+ }
+
+ @Test
+ public void assignServiceInstanceSuccessTest() throws Exception {
+ doReturn(new GenericResourceApiServiceOperationInformation()).when(MOCK_serviceTopologyOperationMapper)
+ .reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.ASSIGN),
+ eq(GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE),
+ any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
+ sdncServiceInstanceResources.assignServiceInstance(serviceInstance, customer, requestContext);
+ verify(MOCK_serviceTopologyOperationMapper, times(1)).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION),
+ eq(SDNCSvcAction.ASSIGN), eq(GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE),
+ any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
+ }
+
+ @Test
+ public void assignServiceInstanceExceptionTest() throws Exception {
+ expectedException.expect(Exception.class);
+ doThrow(Exception.class).when(MOCK_serviceTopologyOperationMapper).reqMapper(
+ eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.ASSIGN),
+ eq(GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE), any(ServiceInstance.class),
+ any(Customer.class), any(RequestContext.class));
+ sdncServiceInstanceResources.assignServiceInstance(serviceInstance, customer, requestContext);
+ }
+
+ @Test
+ public void deleteServiceInstanceSuccessTest() throws Exception {
+ doReturn(new GenericResourceApiServiceOperationInformation()).when(MOCK_serviceTopologyOperationMapper)
+ .reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DELETE),
+ eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE),
+ any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
+ sdncServiceInstanceResources.deleteServiceInstance(serviceInstance, customer, requestContext);
+ verify(MOCK_serviceTopologyOperationMapper, times(1)).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION),
+ eq(SDNCSvcAction.DELETE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE),
+ any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
+ }
+
+ @Test
+ public void deleteServiceInstanceExceptionTest() throws Exception {
+ expectedException.expect(Exception.class);
+ doThrow(Exception.class).when(MOCK_serviceTopologyOperationMapper).reqMapper(
+ eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DELETE),
+ eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class),
+ any(Customer.class), any(RequestContext.class));
+ sdncServiceInstanceResources.deleteServiceInstance(serviceInstance, customer, requestContext);
+ }
+
+ @Test
+ public void unassignServiceInstanceSuccessTest() throws Exception {
+ doReturn(new GenericResourceApiServiceOperationInformation()).when(MOCK_serviceTopologyOperationMapper)
+ .reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DELETE),
+ eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE),
+ any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
+ sdncServiceInstanceResources.unassignServiceInstance(serviceInstance, customer, requestContext);
+ verify(MOCK_serviceTopologyOperationMapper, times(1)).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION),
+ eq(SDNCSvcAction.DELETE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE),
+ any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
+ }
+
+ @Test
+ public void unassignServiceInstanceExceptionTest() throws Exception {
+ expectedException.expect(Exception.class);
+ doThrow(Exception.class).when(MOCK_serviceTopologyOperationMapper).reqMapper(
+ eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DELETE),
+ eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class),
+ any(Customer.class), any(RequestContext.class));
+ sdncServiceInstanceResources.unassignServiceInstance(serviceInstance, customer, requestContext);
+ }
+
+ @Test
+ public void deactivateServiceInstanceSuccessTest() throws Exception {
+ doReturn(new GenericResourceApiServiceOperationInformation()).when(MOCK_serviceTopologyOperationMapper)
+ .reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DEACTIVATE),
+ eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE),
+ any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
+ sdncServiceInstanceResources.deactivateServiceInstance(serviceInstance, customer, requestContext);
+ verify(MOCK_serviceTopologyOperationMapper, times(1)).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION),
+ eq(SDNCSvcAction.DEACTIVATE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE),
+ any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
+ }
- @Test
- public void deactivateServiceInstanceSuccessTest() throws Exception {
- doReturn(new GenericResourceApiServiceOperationInformation()).when(MOCK_serviceTopologyOperationMapper).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DEACTIVATE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
- sdncServiceInstanceResources.deactivateServiceInstance(serviceInstance, customer, requestContext);
- verify(MOCK_serviceTopologyOperationMapper, times(1)).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DEACTIVATE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
- }
-
- @Test
- public void deactivateServiceInstanceExceptionTest() throws Exception {
- expectedException.expect(Exception.class);
- doThrow(Exception.class).when(MOCK_serviceTopologyOperationMapper).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DEACTIVATE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
- sdncServiceInstanceResources.deactivateServiceInstance(serviceInstance, customer, requestContext);
- }
+ @Test
+ public void deactivateServiceInstanceExceptionTest() throws Exception {
+ expectedException.expect(Exception.class);
+ doThrow(Exception.class).when(MOCK_serviceTopologyOperationMapper).reqMapper(
+ eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DEACTIVATE),
+ eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class),
+ any(Customer.class), any(RequestContext.class));
+ sdncServiceInstanceResources.deactivateServiceInstance(serviceInstance, customer, requestContext);
+ }
- @Test
- public void test_changeModelServiceInstance() throws MapperException, BadResponseException {
- doReturn(new GenericResourceApiServiceOperationInformation()).when(MOCK_serviceTopologyOperationMapper).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.CHANGE_ASSIGN), eq(GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
- sdncServiceInstanceResources.changeModelServiceInstance(serviceInstance, customer, requestContext);
- verify(MOCK_serviceTopologyOperationMapper, times(1)).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.CHANGE_ASSIGN), eq(GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
- }
+ @Test
+ public void test_changeModelServiceInstance() throws MapperException, BadResponseException {
+ doReturn(new GenericResourceApiServiceOperationInformation()).when(MOCK_serviceTopologyOperationMapper)
+ .reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.CHANGE_ASSIGN),
+ eq(GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE),
+ any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
+ sdncServiceInstanceResources.changeModelServiceInstance(serviceInstance, customer, requestContext);
+ verify(MOCK_serviceTopologyOperationMapper, times(1)).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION),
+ eq(SDNCSvcAction.CHANGE_ASSIGN), eq(GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE),
+ any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVfModuleResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVfModuleResourcesTest.java
index 7d05758129..2b45a3302c 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVfModuleResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVfModuleResourcesTest.java
@@ -23,7 +23,6 @@ package org.onap.so.client.orchestration;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -46,77 +45,87 @@ import org.onap.so.client.sdnc.beans.SDNCSvcOperation;
import org.onap.so.client.sdnc.mapper.VfModuleTopologyOperationRequestMapper;;
@RunWith(MockitoJUnitRunner.Silent.class)
-public class SDNCVfModuleResourcesTest extends TestDataSetup{
+public class SDNCVfModuleResourcesTest extends TestDataSetup {
+
+ @InjectMocks
+ private SDNCVfModuleResources sdncVfModuleResources;
+
+ @Mock
+ protected VfModuleTopologyOperationRequestMapper vfModuleTopologyMapper;
+
+ private VfModule vfModule;
+ private GenericVnf vnf;
+ private ServiceInstance serviceInstance;
+ private VolumeGroup volumeGroup;
+ private Customer customer;
+ private CloudRegion cloudRegion;
+ private RequestContext requestContext;
+ private GenericResourceApiVfModuleOperationInformation sdncReq;
+
+ @Before
+ public void before() {
+ vfModule = buildVfModule();
+ vnf = buildGenericVnf();
+ serviceInstance = buildServiceInstance();
+ volumeGroup = buildVolumeGroup();
+ customer = buildCustomer();
+ cloudRegion = buildCloudRegion();
+ requestContext = buildRequestContext();
+ sdncReq = new GenericResourceApiVfModuleOperationInformation();
+ }
+
+ @Test
+ public void assignVfModuleTest() throws MapperException {
+ doReturn(sdncReq).when(vfModuleTopologyMapper).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION,
+ SDNCSvcAction.ASSIGN, vfModule, volumeGroup, vnf, serviceInstance, customer, cloudRegion,
+ requestContext, null);
+ sdncVfModuleResources.assignVfModule(vfModule, volumeGroup, vnf, serviceInstance, customer, cloudRegion,
+ requestContext);
+ verify(vfModuleTopologyMapper, times(1)).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION,
+ SDNCSvcAction.ASSIGN, vfModule, volumeGroup, vnf, serviceInstance, customer, cloudRegion,
+ requestContext, null);
+ }
+
+ @Test
+ public void unassignVfModuleTest() throws MapperException {
+ doReturn(sdncReq).when(vfModuleTopologyMapper).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION,
+ SDNCSvcAction.UNASSIGN, vfModule, null, vnf, serviceInstance, null, null, null, null);
+ sdncVfModuleResources.unassignVfModule(vfModule, vnf, serviceInstance);
+ verify(vfModuleTopologyMapper, times(1)).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION,
+ SDNCSvcAction.UNASSIGN, vfModule, null, vnf, serviceInstance, null, null, null, null);
+ }
+
+ @Test
+ public void activateVfModuleTest() throws MapperException {
+ doReturn(sdncReq).when(vfModuleTopologyMapper).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION,
+ SDNCSvcAction.ACTIVATE, vfModule, null, vnf, serviceInstance, customer, cloudRegion, requestContext,
+ null);
+ sdncVfModuleResources.activateVfModule(vfModule, vnf, serviceInstance, customer, cloudRegion, requestContext);
+ verify(vfModuleTopologyMapper, times(1)).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION,
+ SDNCSvcAction.ACTIVATE, vfModule, null, vnf, serviceInstance, customer, cloudRegion, requestContext,
+ null);
+ }
+
+ @Test
+ public void deactivateVfModuleTest() throws MapperException {
+ doReturn(sdncReq).when(vfModuleTopologyMapper).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION,
+ SDNCSvcAction.DEACTIVATE, vfModule, null, vnf, serviceInstance, customer, cloudRegion, requestContext,
+ null);
+ sdncVfModuleResources.deactivateVfModule(vfModule, vnf, serviceInstance, customer, cloudRegion, requestContext);
+ verify(vfModuleTopologyMapper, times(1)).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION,
+ SDNCSvcAction.DEACTIVATE, vfModule, null, vnf, serviceInstance, customer, cloudRegion, requestContext,
+ null);
+ }
- @InjectMocks
- private SDNCVfModuleResources sdncVfModuleResources;
-
- @Mock
- protected VfModuleTopologyOperationRequestMapper vfModuleTopologyMapper;
-
- private VfModule vfModule;
- private GenericVnf vnf;
- private ServiceInstance serviceInstance;
- private VolumeGroup volumeGroup;
- private Customer customer;
- private CloudRegion cloudRegion;
- private RequestContext requestContext;
- private GenericResourceApiVfModuleOperationInformation sdncReq;
-
- @Before
- public void before() {
- vfModule = buildVfModule();
- vnf = buildGenericVnf();
- serviceInstance = buildServiceInstance();
- volumeGroup = buildVolumeGroup();
- customer = buildCustomer();
- cloudRegion = buildCloudRegion();
- requestContext = buildRequestContext();
- sdncReq = new GenericResourceApiVfModuleOperationInformation();
- }
-
- @Test
- public void assignVfModuleTest() throws MapperException {
- doReturn(sdncReq).when(vfModuleTopologyMapper).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, vfModule,
- volumeGroup, vnf, serviceInstance, customer, cloudRegion, requestContext, null);
- sdncVfModuleResources.assignVfModule(vfModule, volumeGroup, vnf, serviceInstance, customer, cloudRegion, requestContext);
- verify(vfModuleTopologyMapper, times(1)).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, vfModule,
- volumeGroup, vnf, serviceInstance, customer, cloudRegion, requestContext, null);
- }
-
- @Test
- public void unassignVfModuleTest() throws MapperException {
- doReturn(sdncReq).when(vfModuleTopologyMapper).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN, vfModule, null,
- vnf, serviceInstance, null, null, null, null);
- sdncVfModuleResources.unassignVfModule(vfModule, vnf, serviceInstance);
- verify(vfModuleTopologyMapper, times(1)).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN, vfModule, null,
- vnf, serviceInstance, null, null, null, null);
- }
-
- @Test
- public void activateVfModuleTest() throws MapperException {
- doReturn(sdncReq).when(vfModuleTopologyMapper).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ACTIVATE, vfModule, null,
- vnf, serviceInstance, customer, cloudRegion, requestContext, null);
- sdncVfModuleResources.activateVfModule(vfModule, vnf, serviceInstance, customer, cloudRegion, requestContext);
- verify(vfModuleTopologyMapper, times(1)).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ACTIVATE, vfModule, null,
- vnf, serviceInstance, customer, cloudRegion, requestContext, null);
- }
-
- @Test
- public void deactivateVfModuleTest() throws MapperException {
- doReturn(sdncReq).when(vfModuleTopologyMapper).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.DEACTIVATE, vfModule, null,
- vnf, serviceInstance, customer, cloudRegion, requestContext, null);
- sdncVfModuleResources.deactivateVfModule(vfModule, vnf, serviceInstance, customer, cloudRegion, requestContext);
- verify(vfModuleTopologyMapper, times(1)).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.DEACTIVATE, vfModule, null,
- vnf, serviceInstance, customer, cloudRegion, requestContext, null);
- }
-
- @Test
- public void changeAssignVfModuleTest() throws MapperException, BadResponseException {
- doReturn(sdncReq).when(vfModuleTopologyMapper).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.CHANGE_ASSIGN, vfModule,
- null, vnf, serviceInstance, customer, cloudRegion, requestContext, null);
- sdncVfModuleResources.changeAssignVfModule(vfModule, vnf, serviceInstance, customer, cloudRegion, requestContext);
- verify(vfModuleTopologyMapper, times(1)).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.CHANGE_ASSIGN, vfModule,
- null, vnf, serviceInstance, customer, cloudRegion, requestContext, null);
- }
+ @Test
+ public void changeAssignVfModuleTest() throws MapperException, BadResponseException {
+ doReturn(sdncReq).when(vfModuleTopologyMapper).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION,
+ SDNCSvcAction.CHANGE_ASSIGN, vfModule, null, vnf, serviceInstance, customer, cloudRegion,
+ requestContext, null);
+ sdncVfModuleResources.changeAssignVfModule(vfModule, vnf, serviceInstance, customer, cloudRegion,
+ requestContext);
+ verify(vfModuleTopologyMapper, times(1)).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION,
+ SDNCSvcAction.CHANGE_ASSIGN, vfModule, null, vnf, serviceInstance, customer, cloudRegion,
+ requestContext, null);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVnfResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVnfResourcesTest.java
index 9bbf790ecb..4c0e2b873f 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVnfResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVnfResourcesTest.java
@@ -28,7 +28,6 @@ import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -51,103 +50,148 @@ import org.onap.so.client.sdnc.beans.SDNCSvcOperation;
import org.onap.so.client.sdnc.mapper.VnfTopologyOperationRequestMapper;
@RunWith(MockitoJUnitRunner.Silent.class)
-public class SDNCVnfResourcesTest extends TestDataSetup{
- @InjectMocks
- private SDNCVnfResources sdncVnfResources;
-
- @Mock
- protected VnfTopologyOperationRequestMapper MOCK_vnfTopologyOperationRequestMapper;
-
- @Mock
- protected SDNCClient MOCK_sdncClient;
-
- private GenericVnf genericVnf;
- private ServiceInstance serviceInstance;
- private Customer customer;
- private CloudRegion cloudRegion;
- private RequestContext requestContext;
- private GenericResourceApiVnfOperationInformation sdncReq;
-
- @Before
- public void before() {
- serviceInstance = buildServiceInstance();
- genericVnf = buildGenericVnf();
- customer = buildCustomer();
- cloudRegion = buildCloudRegion();
- requestContext = buildRequestContext();
- sdncReq = new GenericResourceApiVnfOperationInformation();
- }
-
- @Test
- public void assignVnfTest() {
- doReturn(sdncReq).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(isA(SDNCSvcOperation.class), isA(SDNCSvcAction.class),isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class), isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class), anyBoolean());
- sdncVnfResources.assignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext, false);
- verify(MOCK_vnfTopologyOperationRequestMapper, times(1)).reqMapper(isA(SDNCSvcOperation.class), isA(SDNCSvcAction.class),isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class), isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class), anyBoolean());
- }
-
- @Test
- public void activateVnfTest() {
- doReturn(sdncReq).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(isA(SDNCSvcOperation.class), isA(SDNCSvcAction.class),isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class), isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class), anyBoolean());
- sdncVnfResources.activateVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- verify(MOCK_vnfTopologyOperationRequestMapper, times(1)).reqMapper(isA(SDNCSvcOperation.class), isA(SDNCSvcAction.class),isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class), isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class), anyBoolean());
- }
-
- @Test
- public void deleteVnfTest() {
- doReturn(sdncReq).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(isA(SDNCSvcOperation.class), isA(SDNCSvcAction.class),isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class), isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class), anyBoolean());
- sdncVnfResources.deleteVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- verify(MOCK_vnfTopologyOperationRequestMapper, times(1)).reqMapper(isA(SDNCSvcOperation.class), isA(SDNCSvcAction.class),isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class), isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class), anyBoolean());
- }
-
- @Test
- public void queryVnfTest() throws MapperException, BadResponseException {
- doReturn("test").when(MOCK_sdncClient).get(isA(String.class));
- genericVnf.setSelflink("testSelflink");
- sdncVnfResources.queryVnf(genericVnf);
- verify(MOCK_sdncClient, times(1)).get(isA(String.class));
- }
-
- @Test
- public void queryVnfWithResourcePrefixTest() throws MapperException, BadResponseException {
- doReturn("test").when(MOCK_sdncClient).get(isA(String.class));
- genericVnf.setSelflink("restconf/test:testSelflink");
- sdncVnfResources.queryVnf(genericVnf);
- verify(MOCK_sdncClient, times(1)).get(isA(String.class));
- }
-
- @Test
- public void changeModelVnfTest() {
- doReturn(sdncReq).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(isA(SDNCSvcOperation.class), isA(SDNCSvcAction.class),isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class), isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class), anyBoolean());
- sdncVnfResources.changeModelVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- verify(MOCK_vnfTopologyOperationRequestMapper, times(1)).reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.CHANGE_ASSIGN,GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, genericVnf, serviceInstance, customer, cloudRegion, requestContext, false);
- }
-
- @Test
- public void deactivateVnfSuccessTest() {
- doReturn(sdncReq).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(eq(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DEACTIVATE),isA(GenericResourceApiRequestActionEnumeration.class), any(GenericVnf.class),any(ServiceInstance.class), any(Customer.class), any(CloudRegion.class),any(RequestContext.class), anyBoolean());
- sdncVnfResources.deactivateVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- verify(MOCK_vnfTopologyOperationRequestMapper, times(1)).reqMapper(eq(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DEACTIVATE),isA(GenericResourceApiRequestActionEnumeration.class), any(GenericVnf.class),any(ServiceInstance.class), any(Customer.class), any(CloudRegion.class),any(RequestContext.class), anyBoolean());
-
- }
-
- @Test
- public void deactivateVnfExceptionTest() {
- expectedException.expect(Exception.class);
- doThrow(Exception.class).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(eq(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DEACTIVATE),isA(GenericResourceApiRequestActionEnumeration.class), any(GenericVnf.class),any(ServiceInstance.class), any(Customer.class), any(CloudRegion.class),any(RequestContext.class), anyBoolean());
- sdncVnfResources.deactivateVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- }
-
- @Test
- public void unassignVnfSuccessTest() throws Exception {
- doReturn(sdncReq).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(eq(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION), eq(SDNCSvcAction.UNASSIGN),isA(GenericResourceApiRequestActionEnumeration.class), any(GenericVnf.class),any(ServiceInstance.class), any(Customer.class), any(CloudRegion.class),any(RequestContext.class), anyBoolean());
- sdncVnfResources.unassignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- verify(MOCK_vnfTopologyOperationRequestMapper, times(1)).reqMapper(eq(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION), eq(SDNCSvcAction.UNASSIGN),isA(GenericResourceApiRequestActionEnumeration.class), any(GenericVnf.class),any(ServiceInstance.class), any(Customer.class), any(CloudRegion.class),any(RequestContext.class), anyBoolean());
- }
-
- @Test
- public void unassignVnfExceptionTest() throws Exception {
- expectedException.expect(Exception.class);
- doThrow(Exception.class).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(eq(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION), eq(SDNCSvcAction.UNASSIGN),isA(GenericResourceApiRequestActionEnumeration.class), any(GenericVnf.class),any(ServiceInstance.class), any(Customer.class), any(CloudRegion.class),any(RequestContext.class), anyBoolean());
- sdncVnfResources.unassignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- }
+public class SDNCVnfResourcesTest extends TestDataSetup {
+ @InjectMocks
+ private SDNCVnfResources sdncVnfResources;
+
+ @Mock
+ protected VnfTopologyOperationRequestMapper MOCK_vnfTopologyOperationRequestMapper;
+
+ @Mock
+ protected SDNCClient MOCK_sdncClient;
+
+ private GenericVnf genericVnf;
+ private ServiceInstance serviceInstance;
+ private Customer customer;
+ private CloudRegion cloudRegion;
+ private RequestContext requestContext;
+ private GenericResourceApiVnfOperationInformation sdncReq;
+
+ @Before
+ public void before() {
+ serviceInstance = buildServiceInstance();
+ genericVnf = buildGenericVnf();
+ customer = buildCustomer();
+ cloudRegion = buildCloudRegion();
+ requestContext = buildRequestContext();
+ sdncReq = new GenericResourceApiVnfOperationInformation();
+ }
+
+ @Test
+ public void assignVnfTest() {
+ doReturn(sdncReq).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(isA(SDNCSvcOperation.class),
+ isA(SDNCSvcAction.class), isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class),
+ isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class),
+ anyBoolean());
+ sdncVnfResources.assignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext, false);
+ verify(MOCK_vnfTopologyOperationRequestMapper, times(1)).reqMapper(isA(SDNCSvcOperation.class),
+ isA(SDNCSvcAction.class), isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class),
+ isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class),
+ anyBoolean());
+ }
+
+ @Test
+ public void activateVnfTest() {
+ doReturn(sdncReq).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(isA(SDNCSvcOperation.class),
+ isA(SDNCSvcAction.class), isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class),
+ isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class),
+ anyBoolean());
+ sdncVnfResources.activateVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
+ verify(MOCK_vnfTopologyOperationRequestMapper, times(1)).reqMapper(isA(SDNCSvcOperation.class),
+ isA(SDNCSvcAction.class), isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class),
+ isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class),
+ anyBoolean());
+ }
+
+ @Test
+ public void deleteVnfTest() {
+ doReturn(sdncReq).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(isA(SDNCSvcOperation.class),
+ isA(SDNCSvcAction.class), isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class),
+ isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class),
+ anyBoolean());
+ sdncVnfResources.deleteVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
+ verify(MOCK_vnfTopologyOperationRequestMapper, times(1)).reqMapper(isA(SDNCSvcOperation.class),
+ isA(SDNCSvcAction.class), isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class),
+ isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class),
+ anyBoolean());
+ }
+
+ @Test
+ public void queryVnfTest() throws MapperException, BadResponseException {
+ doReturn("test").when(MOCK_sdncClient).get(isA(String.class));
+ genericVnf.setSelflink("testSelflink");
+ sdncVnfResources.queryVnf(genericVnf);
+ verify(MOCK_sdncClient, times(1)).get(isA(String.class));
+ }
+
+ @Test
+ public void queryVnfWithResourcePrefixTest() throws MapperException, BadResponseException {
+ doReturn("test").when(MOCK_sdncClient).get(isA(String.class));
+ genericVnf.setSelflink("restconf/test:testSelflink");
+ sdncVnfResources.queryVnf(genericVnf);
+ verify(MOCK_sdncClient, times(1)).get(isA(String.class));
+ }
+
+ @Test
+ public void changeModelVnfTest() {
+ doReturn(sdncReq).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(isA(SDNCSvcOperation.class),
+ isA(SDNCSvcAction.class), isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class),
+ isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class),
+ anyBoolean());
+ sdncVnfResources.changeModelVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
+ verify(MOCK_vnfTopologyOperationRequestMapper, times(1)).reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION,
+ SDNCSvcAction.CHANGE_ASSIGN, GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, genericVnf,
+ serviceInstance, customer, cloudRegion, requestContext, false);
+ }
+
+ @Test
+ public void deactivateVnfSuccessTest() {
+ doReturn(sdncReq).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(
+ eq(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DEACTIVATE),
+ isA(GenericResourceApiRequestActionEnumeration.class), any(GenericVnf.class),
+ any(ServiceInstance.class), any(Customer.class), any(CloudRegion.class), any(RequestContext.class),
+ anyBoolean());
+ sdncVnfResources.deactivateVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
+ verify(MOCK_vnfTopologyOperationRequestMapper, times(1)).reqMapper(eq(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION),
+ eq(SDNCSvcAction.DEACTIVATE), isA(GenericResourceApiRequestActionEnumeration.class),
+ any(GenericVnf.class), any(ServiceInstance.class), any(Customer.class), any(CloudRegion.class),
+ any(RequestContext.class), anyBoolean());
+
+ }
+
+ @Test
+ public void deactivateVnfExceptionTest() {
+ expectedException.expect(Exception.class);
+ doThrow(Exception.class).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(
+ eq(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DEACTIVATE),
+ isA(GenericResourceApiRequestActionEnumeration.class), any(GenericVnf.class),
+ any(ServiceInstance.class), any(Customer.class), any(CloudRegion.class), any(RequestContext.class),
+ anyBoolean());
+ sdncVnfResources.deactivateVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
+ }
+
+ @Test
+ public void unassignVnfSuccessTest() throws Exception {
+ doReturn(sdncReq).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(
+ eq(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION), eq(SDNCSvcAction.UNASSIGN),
+ isA(GenericResourceApiRequestActionEnumeration.class), any(GenericVnf.class),
+ any(ServiceInstance.class), any(Customer.class), any(CloudRegion.class), any(RequestContext.class),
+ anyBoolean());
+ sdncVnfResources.unassignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
+ verify(MOCK_vnfTopologyOperationRequestMapper, times(1)).reqMapper(eq(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION),
+ eq(SDNCSvcAction.UNASSIGN), isA(GenericResourceApiRequestActionEnumeration.class),
+ any(GenericVnf.class), any(ServiceInstance.class), any(Customer.class), any(CloudRegion.class),
+ any(RequestContext.class), anyBoolean());
+ }
+
+ @Test
+ public void unassignVnfExceptionTest() throws Exception {
+ expectedException.expect(Exception.class);
+ doThrow(Exception.class).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(
+ eq(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION), eq(SDNCSvcAction.UNASSIGN),
+ isA(GenericResourceApiRequestActionEnumeration.class), any(GenericVnf.class),
+ any(ServiceInstance.class), any(Customer.class), any(CloudRegion.class), any(RequestContext.class),
+ anyBoolean());
+ sdncVnfResources.unassignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNOHealthCheckResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNOHealthCheckResourcesTest.java
index 46d87c7ca3..265bb5d3b5 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNOHealthCheckResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNOHealthCheckResourcesTest.java
@@ -24,9 +24,7 @@ import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.ArgumentMatchers.any;
-
import java.util.UUID;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -40,29 +38,29 @@ import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
import org.onap.so.client.sdno.SDNOValidator;
@RunWith(MockitoJUnitRunner.Silent.class)
-public class SDNOHealthCheckResourcesTest extends TestDataSetup{
- @InjectMocks
- private SDNOHealthCheckResources sdnoHealthCheckResources = new SDNOHealthCheckResources();
-
- private GenericVnf genericVnf;
- private RequestContext requestContext;
-
- @Mock
- protected SDNOValidator MOCK_sdnoValidator;
-
- @Mock
- protected InjectionHelper MOCK_injectionHelper;
-
- @Before
- public void before() {
- genericVnf = buildGenericVnf();
- requestContext = buildRequestContext();
- doReturn(MOCK_sdnoValidator).when(MOCK_injectionHelper).getSdnoValidator();
- }
-
- @Test
- public void healthCheckTest() throws Exception {
- doReturn(true).when(MOCK_sdnoValidator).healthDiagnostic(any(String.class), any(UUID.class), any(String.class));
- assertTrue(sdnoHealthCheckResources.healthCheck(genericVnf, requestContext));
- }
+public class SDNOHealthCheckResourcesTest extends TestDataSetup {
+ @InjectMocks
+ private SDNOHealthCheckResources sdnoHealthCheckResources = new SDNOHealthCheckResources();
+
+ private GenericVnf genericVnf;
+ private RequestContext requestContext;
+
+ @Mock
+ protected SDNOValidator MOCK_sdnoValidator;
+
+ @Mock
+ protected InjectionHelper MOCK_injectionHelper;
+
+ @Before
+ public void before() {
+ genericVnf = buildGenericVnf();
+ requestContext = buildRequestContext();
+ doReturn(MOCK_sdnoValidator).when(MOCK_injectionHelper).getSdnoValidator();
+ }
+
+ @Test
+ public void healthCheckTest() throws Exception {
+ doReturn(true).when(MOCK_sdnoValidator).healthDiagnostic(any(String.class), any(UUID.class), any(String.class));
+ assertTrue(sdnoHealthCheckResources.healthCheck(genericVnf, requestContext));
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/VnfAdapterVfModuleResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/VnfAdapterVfModuleResourcesTest.java
index 2de4f11801..4cebd2cde5 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/VnfAdapterVfModuleResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/VnfAdapterVfModuleResourcesTest.java
@@ -26,7 +26,6 @@ import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -48,94 +47,102 @@ import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule;
import org.onap.so.client.adapter.vnf.mapper.VnfAdapterVfModuleObjectMapper;
@RunWith(MockitoJUnitRunner.Silent.class)
-public class VnfAdapterVfModuleResourcesTest extends TestDataSetup{
- @InjectMocks
- private VnfAdapterVfModuleResources vnfAdapterVfModuleResources = new VnfAdapterVfModuleResources();
-
- @Mock
- protected VnfAdapterVfModuleObjectMapper MOCK_vnfAdapterVfModuleObjectMapper;
-
- private RequestContext requestContext;
- private ServiceInstance serviceInstance;
- private ModelInfoServiceInstance modelInfoServiceInstance;
- private GenericVnf genericVnf;
- private VfModule vfModule;
- private VolumeGroup volumeGroup;
- private ModelInfoVfModule modelInfoVfModule;
- private CloudRegion cloudRegion;
- private OrchestrationContext orchestrationContext;
- private CreateVfModuleRequest createVfModuleRequest;
- private String sdncVnfQueryResponse;
- private String sdncVfModuleQueryResponse;
- private DeleteVfModuleRequest deleteVfModuleRequest;
-
- @Before
- public void before() {
- requestContext = buildRequestContext();
-
- serviceInstance = buildServiceInstance();
-
- genericVnf = buildGenericVnf();
-
- vfModule = buildVfModule();
-
- cloudRegion = buildCloudRegion();
-
- orchestrationContext = buildOrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(true);
-
- sdncVnfQueryResponse = new String();
- sdncVfModuleQueryResponse = new String();
-
- createVfModuleRequest = new CreateVfModuleRequest();
- createVfModuleRequest.setCloudSiteId("cloudSiteId");
-
- deleteVfModuleRequest = new DeleteVfModuleRequest();
- deleteVfModuleRequest.setCloudSiteId("cloudSiteId");
- }
-
- @Test
- public void test_createVfModule() throws Exception {
- doReturn(createVfModuleRequest).when(MOCK_vnfAdapterVfModuleObjectMapper).createVfModuleRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance,
- genericVnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
-
- CreateVfModuleRequest actualCreateVfModuleRequest = vnfAdapterVfModuleResources.createVfModuleRequest(requestContext, cloudRegion, orchestrationContext, serviceInstance,
- genericVnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
-
- verify(MOCK_vnfAdapterVfModuleObjectMapper, times(1)).createVfModuleRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance,
- genericVnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
-
- assertNotNull(createVfModuleRequest);
- assertNotNull(actualCreateVfModuleRequest);
- assertEquals(createVfModuleRequest, actualCreateVfModuleRequest);
- }
-
- @Test
- public void test_createVfModuleWithVolumeGroup() throws Exception {
- volumeGroup = buildVolumeGroup();
- doReturn(createVfModuleRequest).when(MOCK_vnfAdapterVfModuleObjectMapper).createVfModuleRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance,
- genericVnf, vfModule, volumeGroup, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
-
- CreateVfModuleRequest actualCreateVfModuleRequest = vnfAdapterVfModuleResources.createVfModuleRequest(requestContext, cloudRegion, orchestrationContext, serviceInstance,
- genericVnf, vfModule, volumeGroup, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
-
- verify(MOCK_vnfAdapterVfModuleObjectMapper, times(1)).createVfModuleRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance,
- genericVnf, vfModule, volumeGroup, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
-
- assertNotNull(createVfModuleRequest);
- assertNotNull(actualCreateVfModuleRequest);
- assertEquals(createVfModuleRequest, actualCreateVfModuleRequest);
- }
-
- @Test
- public void test_deleteVfModule() throws Exception {
- doReturn(deleteVfModuleRequest).when(MOCK_vnfAdapterVfModuleObjectMapper).deleteVfModuleRequestMapper(isA(RequestContext.class), isA(CloudRegion.class), isA(ServiceInstance.class),
- isA(GenericVnf.class), isA(VfModule.class));
-
- DeleteVfModuleRequest actualDeleteVfModuleRequest = vnfAdapterVfModuleResources.deleteVfModuleRequest(requestContext, cloudRegion, serviceInstance,
- genericVnf, vfModule);
-
- verify(MOCK_vnfAdapterVfModuleObjectMapper, times(1)).deleteVfModuleRequestMapper(requestContext, cloudRegion, serviceInstance, genericVnf, vfModule);
- assertEquals(deleteVfModuleRequest, actualDeleteVfModuleRequest);
- }
+public class VnfAdapterVfModuleResourcesTest extends TestDataSetup {
+ @InjectMocks
+ private VnfAdapterVfModuleResources vnfAdapterVfModuleResources = new VnfAdapterVfModuleResources();
+
+ @Mock
+ protected VnfAdapterVfModuleObjectMapper MOCK_vnfAdapterVfModuleObjectMapper;
+
+ private RequestContext requestContext;
+ private ServiceInstance serviceInstance;
+ private ModelInfoServiceInstance modelInfoServiceInstance;
+ private GenericVnf genericVnf;
+ private VfModule vfModule;
+ private VolumeGroup volumeGroup;
+ private ModelInfoVfModule modelInfoVfModule;
+ private CloudRegion cloudRegion;
+ private OrchestrationContext orchestrationContext;
+ private CreateVfModuleRequest createVfModuleRequest;
+ private String sdncVnfQueryResponse;
+ private String sdncVfModuleQueryResponse;
+ private DeleteVfModuleRequest deleteVfModuleRequest;
+
+ @Before
+ public void before() {
+ requestContext = buildRequestContext();
+
+ serviceInstance = buildServiceInstance();
+
+ genericVnf = buildGenericVnf();
+
+ vfModule = buildVfModule();
+
+ cloudRegion = buildCloudRegion();
+
+ orchestrationContext = buildOrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(true);
+
+ sdncVnfQueryResponse = new String();
+ sdncVfModuleQueryResponse = new String();
+
+ createVfModuleRequest = new CreateVfModuleRequest();
+ createVfModuleRequest.setCloudSiteId("cloudSiteId");
+
+ deleteVfModuleRequest = new DeleteVfModuleRequest();
+ deleteVfModuleRequest.setCloudSiteId("cloudSiteId");
+ }
+
+ @Test
+ public void test_createVfModule() throws Exception {
+ doReturn(createVfModuleRequest).when(MOCK_vnfAdapterVfModuleObjectMapper).createVfModuleRequestMapper(
+ requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, vfModule, null,
+ sdncVnfQueryResponse, sdncVfModuleQueryResponse);
+
+ CreateVfModuleRequest actualCreateVfModuleRequest =
+ vnfAdapterVfModuleResources.createVfModuleRequest(requestContext, cloudRegion, orchestrationContext,
+ serviceInstance, genericVnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
+
+ verify(MOCK_vnfAdapterVfModuleObjectMapper, times(1)).createVfModuleRequestMapper(requestContext, cloudRegion,
+ orchestrationContext, serviceInstance, genericVnf, vfModule, null, sdncVnfQueryResponse,
+ sdncVfModuleQueryResponse);
+
+ assertNotNull(createVfModuleRequest);
+ assertNotNull(actualCreateVfModuleRequest);
+ assertEquals(createVfModuleRequest, actualCreateVfModuleRequest);
+ }
+
+ @Test
+ public void test_createVfModuleWithVolumeGroup() throws Exception {
+ volumeGroup = buildVolumeGroup();
+ doReturn(createVfModuleRequest).when(MOCK_vnfAdapterVfModuleObjectMapper).createVfModuleRequestMapper(
+ requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, vfModule, volumeGroup,
+ sdncVnfQueryResponse, sdncVfModuleQueryResponse);
+
+ CreateVfModuleRequest actualCreateVfModuleRequest = vnfAdapterVfModuleResources.createVfModuleRequest(
+ requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, vfModule, volumeGroup,
+ sdncVnfQueryResponse, sdncVfModuleQueryResponse);
+
+ verify(MOCK_vnfAdapterVfModuleObjectMapper, times(1)).createVfModuleRequestMapper(requestContext, cloudRegion,
+ orchestrationContext, serviceInstance, genericVnf, vfModule, volumeGroup, sdncVnfQueryResponse,
+ sdncVfModuleQueryResponse);
+
+ assertNotNull(createVfModuleRequest);
+ assertNotNull(actualCreateVfModuleRequest);
+ assertEquals(createVfModuleRequest, actualCreateVfModuleRequest);
+ }
+
+ @Test
+ public void test_deleteVfModule() throws Exception {
+ doReturn(deleteVfModuleRequest).when(MOCK_vnfAdapterVfModuleObjectMapper).deleteVfModuleRequestMapper(
+ isA(RequestContext.class), isA(CloudRegion.class), isA(ServiceInstance.class), isA(GenericVnf.class),
+ isA(VfModule.class));
+
+ DeleteVfModuleRequest actualDeleteVfModuleRequest = vnfAdapterVfModuleResources
+ .deleteVfModuleRequest(requestContext, cloudRegion, serviceInstance, genericVnf, vfModule);
+
+ verify(MOCK_vnfAdapterVfModuleObjectMapper, times(1)).deleteVfModuleRequestMapper(requestContext, cloudRegion,
+ serviceInstance, genericVnf, vfModule);
+ assertEquals(deleteVfModuleRequest, actualDeleteVfModuleRequest);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/VnfAdapterVolumeGroupResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/VnfAdapterVolumeGroupResourcesTest.java
index b1812a3da9..b23c5bca87 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/VnfAdapterVolumeGroupResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/VnfAdapterVolumeGroupResourcesTest.java
@@ -24,7 +24,6 @@ import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -46,74 +45,81 @@ import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
import org.onap.so.client.adapter.vnf.VnfVolumeAdapterClientImpl;
import org.onap.so.client.adapter.vnf.mapper.VnfAdapterObjectMapper;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
-
import com.shazam.shazamcrest.matcher.Matchers;
@RunWith(MockitoJUnitRunner.Silent.class)
-public class VnfAdapterVolumeGroupResourcesTest extends TestDataSetup {
- @InjectMocks
- private VnfAdapterVolumeGroupResources vnfAdapterVolumeGroupResources;
-
- @Mock
- protected VnfAdapterObjectMapper MOCK_vnfAdapterObjectMapper;
-
- @Mock
- protected VnfVolumeAdapterClientImpl MOCK_vnfVolumeAdapterClient;
-
- private RequestContext requestContext;
- private ServiceInstance serviceInstance;
- private GenericVnf genericVnf;
- private VfModule vfModule;
- private VolumeGroup volumeGroup;
- private CloudRegion cloudRegion;
- private OrchestrationContext orchestrationContext;
-
- @Before
- public void before() {
- requestContext = buildRequestContext();
- serviceInstance = buildServiceInstance();
- genericVnf = buildGenericVnf();
- serviceInstance.getVnfs().add(genericVnf);
- vfModule = buildVfModule();
- genericVnf.getVfModules().add(vfModule);
- volumeGroup = buildVolumeGroup();
- serviceInstance.getVnfs().get(0).getVolumeGroups().add(volumeGroup);
- cloudRegion = buildCloudRegion();
- orchestrationContext = buildOrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(true);
- }
-
- @Test
- public void test_createVolumeGroup() throws Exception {
- volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
-
- CreateVolumeGroupRequest createVolumeGroupRequest = new CreateVolumeGroupRequest();
- createVolumeGroupRequest.setCloudSiteId("cloudSiteId");
-
- CreateVolumeGroupResponse expectedCreateVolumeGroupResponse = new CreateVolumeGroupResponse();
- expectedCreateVolumeGroupResponse.setVolumeGroupStackId("volumeGroupStackId");
- expectedCreateVolumeGroupResponse.setVolumeGroupCreated(true);
-
- String sdncVfModuleQueryResponse = "sdncVfModuleQueryResponse";
-
- doReturn(createVolumeGroupRequest).when(MOCK_vnfAdapterObjectMapper).createVolumeGroupRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, volumeGroup, sdncVfModuleQueryResponse);
-
- CreateVolumeGroupRequest actualCreateVolumeGroupResponse = vnfAdapterVolumeGroupResources.createVolumeGroupRequest(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, volumeGroup, sdncVfModuleQueryResponse);
-
- verify(MOCK_vnfAdapterObjectMapper, times(1)).createVolumeGroupRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, volumeGroup, sdncVfModuleQueryResponse);
-
- assertThat(createVolumeGroupRequest, Matchers.sameBeanAs(actualCreateVolumeGroupResponse));
- }
-
- @Test
- public void test_deleteVolumeGroup() throws Exception {
- DeleteVolumeGroupRequest deleteVolumeGroupRequest = new DeleteVolumeGroupRequest();
- doReturn(deleteVolumeGroupRequest).when(MOCK_vnfAdapterObjectMapper).deleteVolumeGroupRequestMapper(requestContext, cloudRegion, serviceInstance, volumeGroup);
-
- DeleteVolumeGroupRequest expectedDeleteVolumeGroupRequest = new DeleteVolumeGroupRequest();
- DeleteVolumeGroupRequest actualDeleteVolumeGroupRequest = vnfAdapterVolumeGroupResources.deleteVolumeGroupRequest(requestContext, cloudRegion, serviceInstance, volumeGroup);
-
- verify(MOCK_vnfAdapterObjectMapper, times(1)).deleteVolumeGroupRequestMapper(requestContext, cloudRegion, serviceInstance, volumeGroup);
- assertThat(expectedDeleteVolumeGroupRequest, Matchers.sameBeanAs(actualDeleteVolumeGroupRequest));
- }
+public class VnfAdapterVolumeGroupResourcesTest extends TestDataSetup {
+ @InjectMocks
+ private VnfAdapterVolumeGroupResources vnfAdapterVolumeGroupResources;
+
+ @Mock
+ protected VnfAdapterObjectMapper MOCK_vnfAdapterObjectMapper;
+
+ @Mock
+ protected VnfVolumeAdapterClientImpl MOCK_vnfVolumeAdapterClient;
+
+ private RequestContext requestContext;
+ private ServiceInstance serviceInstance;
+ private GenericVnf genericVnf;
+ private VfModule vfModule;
+ private VolumeGroup volumeGroup;
+ private CloudRegion cloudRegion;
+ private OrchestrationContext orchestrationContext;
+
+ @Before
+ public void before() {
+ requestContext = buildRequestContext();
+ serviceInstance = buildServiceInstance();
+ genericVnf = buildGenericVnf();
+ serviceInstance.getVnfs().add(genericVnf);
+ vfModule = buildVfModule();
+ genericVnf.getVfModules().add(vfModule);
+ volumeGroup = buildVolumeGroup();
+ serviceInstance.getVnfs().get(0).getVolumeGroups().add(volumeGroup);
+ cloudRegion = buildCloudRegion();
+ orchestrationContext = buildOrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(true);
+ }
+
+ @Test
+ public void test_createVolumeGroup() throws Exception {
+ volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
+
+ CreateVolumeGroupRequest createVolumeGroupRequest = new CreateVolumeGroupRequest();
+ createVolumeGroupRequest.setCloudSiteId("cloudSiteId");
+
+ CreateVolumeGroupResponse expectedCreateVolumeGroupResponse = new CreateVolumeGroupResponse();
+ expectedCreateVolumeGroupResponse.setVolumeGroupStackId("volumeGroupStackId");
+ expectedCreateVolumeGroupResponse.setVolumeGroupCreated(true);
+
+ String sdncVfModuleQueryResponse = "sdncVfModuleQueryResponse";
+
+ doReturn(createVolumeGroupRequest).when(MOCK_vnfAdapterObjectMapper).createVolumeGroupRequestMapper(
+ requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, volumeGroup,
+ sdncVfModuleQueryResponse);
+
+ CreateVolumeGroupRequest actualCreateVolumeGroupResponse =
+ vnfAdapterVolumeGroupResources.createVolumeGroupRequest(requestContext, cloudRegion,
+ orchestrationContext, serviceInstance, genericVnf, volumeGroup, sdncVfModuleQueryResponse);
+
+ verify(MOCK_vnfAdapterObjectMapper, times(1)).createVolumeGroupRequestMapper(requestContext, cloudRegion,
+ orchestrationContext, serviceInstance, genericVnf, volumeGroup, sdncVfModuleQueryResponse);
+
+ assertThat(createVolumeGroupRequest, Matchers.sameBeanAs(actualCreateVolumeGroupResponse));
+ }
+
+ @Test
+ public void test_deleteVolumeGroup() throws Exception {
+ DeleteVolumeGroupRequest deleteVolumeGroupRequest = new DeleteVolumeGroupRequest();
+ doReturn(deleteVolumeGroupRequest).when(MOCK_vnfAdapterObjectMapper)
+ .deleteVolumeGroupRequestMapper(requestContext, cloudRegion, serviceInstance, volumeGroup);
+
+ DeleteVolumeGroupRequest expectedDeleteVolumeGroupRequest = new DeleteVolumeGroupRequest();
+ DeleteVolumeGroupRequest actualDeleteVolumeGroupRequest = vnfAdapterVolumeGroupResources
+ .deleteVolumeGroupRequest(requestContext, cloudRegion, serviceInstance, volumeGroup);
+
+ verify(MOCK_vnfAdapterObjectMapper, times(1)).deleteVolumeGroupRequestMapper(requestContext, cloudRegion,
+ serviceInstance, volumeGroup);
+ assertThat(expectedDeleteVolumeGroupRequest, Matchers.sameBeanAs(actualDeleteVolumeGroupRequest));
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/policy/CommonObjectMapperProviderTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/policy/CommonObjectMapperProviderTest.java
index e3f6a1829e..2ff0d1d281 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/policy/CommonObjectMapperProviderTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/policy/CommonObjectMapperProviderTest.java
@@ -22,9 +22,7 @@ package org.onap.so.client.policy;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-
import org.junit.Test;
-
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -43,4 +41,4 @@ public class CommonObjectMapperProviderTest {
assertFalse(context.isEnabled(SerializationFeature.WRAP_ROOT_VALUE));
assertFalse(context.isEnabled(DeserializationFeature.UNWRAP_ROOT_VALUE));
}
-} \ No newline at end of file
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java
index 2636aec4a7..9c736b7634 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java
@@ -21,9 +21,7 @@
package org.onap.so.client.sdn.common;
import static org.junit.Assert.assertEquals;
-
import java.util.LinkedHashMap;
-
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
@@ -33,9 +31,9 @@ import org.onap.so.client.exception.MapperException;
import org.onap.so.client.sdnc.SdnCommonTasks;
-public class SdnCommonTasksTest{
+public class SdnCommonTasksTest {
+
-
SdnCommonTasks sdnCommonTasks = new SdnCommonTasks();
@Rule
@@ -60,7 +58,7 @@ public class SdnCommonTasksTest{
@Test
public void validateSDNResponseTest() throws BadResponseException {
- String jsonResponse = "{\"output\":{\"response-code\":\"0\",\"response-message\":\"success\"}}";
+ String jsonResponse = "{\"output\":{\"response-code\":\"0\",\"response-message\":\"success\"}}";
LinkedHashMap<String, Object> responseMap = new LinkedHashMap<>();
LinkedHashMap<String, Object> output = new LinkedHashMap<>();
output.put("response-code", "0");
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientIT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientIT.java
index 70f196db8c..0b338bde1d 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientIT.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientIT.java
@@ -25,11 +25,9 @@ import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
-
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
-
import org.junit.Test;
import org.onap.so.BaseIntegrationTest;
import org.onap.so.client.exception.BadResponseException;
@@ -38,43 +36,43 @@ import org.onap.so.client.sdnc.endpoint.SDNCTopology;
import org.skyscreamer.jsonassert.JSONAssert;
public class SDNCClientIT extends BaseIntegrationTest {
- private final static String JSON_FILE_LOCATION = "src/test/resources/__files/";
-
+ private final static String JSON_FILE_LOCATION = "src/test/resources/__files/";
+
@Test
public void getTest() throws BadResponseException, MapperException, IOException {
- String responseJson = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "SDNCClientGetResponse.json")));
- String queryLink = "/topologyQuery";
-
- wireMockServer.stubFor(get(urlEqualTo(queryLink))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json").withBody(responseJson)));
+ String responseJson =
+ new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "SDNCClientGetResponse.json")));
+ String queryLink = "/topologyQuery";
+
+ wireMockServer.stubFor(get(urlEqualTo(queryLink)).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(responseJson)));
String response = SPY_sdncClient.get(queryLink);
JSONAssert.assertEquals(responseJson, response, false);
}
-
+
@Test(expected = BadResponseException.class)
public void post404Test() throws BadResponseException, MapperException, IOException {
- String responseJson = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "SDNCClientPut404Response.json")));
-
- String queryLink = "/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation/";
-
- wireMockServer.stubFor(post(urlMatching(queryLink))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json").withBody(responseJson)));
-
+ String responseJson =
+ new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "SDNCClientPut404Response.json")));
+
+ String queryLink = "/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation/";
+
+ wireMockServer.stubFor(post(urlMatching(queryLink)).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(responseJson)));
+
SPY_sdncClient.post("", SDNCTopology.NETWORK);
}
-
+
@Test
public void post200Test() throws BadResponseException, MapperException, IOException {
- String responseJson = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "SDNCClientPut200Response.json")));
-
- String queryLink = "/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation/";
-
- wireMockServer.stubFor(post(urlMatching(queryLink))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json").withBody(responseJson)));
-
+ String responseJson =
+ new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "SDNCClientPut200Response.json")));
+
+ String queryLink = "/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation/";
+
+ wireMockServer.stubFor(post(urlMatching(queryLink)).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(responseJson)));
+
String response = SPY_sdncClient.post("", SDNCTopology.NETWORK);
JSONAssert.assertEquals(responseJson, response, true);
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapperTest.java
index 302bb551c3..0eb0304cdf 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapperTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapperTest.java
@@ -25,7 +25,6 @@ import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -47,11 +46,11 @@ import org.onap.so.client.sdnc.beans.SDNCSvcAction;
@RunWith(MockitoJUnitRunner.Silent.class)
public class GCTopologyOperationRequestMapperTest extends TestDataSetup {
-
- @Spy
- private GeneralTopologyObjectMapper generalTopologyObjectMapper;
-
- @InjectMocks
+
+ @Spy
+ private GeneralTopologyObjectMapper generalTopologyObjectMapper;
+
+ @InjectMocks
private GCTopologyOperationRequestMapper genObjMapper = new GCTopologyOperationRequestMapper();
@Test
@@ -63,8 +62,9 @@ public class GCTopologyOperationRequestMapperTest extends TestDataSetup {
Configuration Configuration = new Configuration();
Configuration.setConfigurationId("ConfigurationId");
Configuration.setConfigurationType("VLAN-NETWORK-RECEPTOR");
- GenericResourceApiGcTopologyOperationInformation genericInfo = genObjMapper.deactivateOrUnassignVnrReqMapper
- (SDNCSvcAction.UNASSIGN, serviceInstance, requestContext, Configuration,"uuid",new URI("http://localhost"));
+ GenericResourceApiGcTopologyOperationInformation genericInfo =
+ genObjMapper.deactivateOrUnassignVnrReqMapper(SDNCSvcAction.UNASSIGN, serviceInstance, requestContext,
+ Configuration, "uuid", new URI("http://localhost"));
Assert.assertNotNull(genericInfo);
Assert.assertNotNull(genericInfo.getRequestInformation());
@@ -73,9 +73,9 @@ public class GCTopologyOperationRequestMapperTest extends TestDataSetup {
Assert.assertNotNull(genericInfo.getServiceInformation());
Assert.assertEquals("ConfigurationId", genericInfo.getConfigurationInformation().getConfigurationId());
Assert.assertEquals("VLAN-NETWORK-RECEPTOR", genericInfo.getConfigurationInformation().getConfigurationType());
- Assert.assertEquals("uuid",genericInfo.getSdncRequestHeader().getSvcRequestId());
- Assert.assertEquals("http://localhost",genericInfo.getSdncRequestHeader().getSvcNotificationUrl());
- Assert.assertEquals("MsoRequestId",genericInfo.getRequestInformation().getRequestId());
+ Assert.assertEquals("uuid", genericInfo.getSdncRequestHeader().getSvcRequestId());
+ Assert.assertEquals("http://localhost", genericInfo.getSdncRequestHeader().getSvcNotificationUrl());
+ Assert.assertEquals("MsoRequestId", genericInfo.getRequestInformation().getRequestId());
}
@@ -99,8 +99,8 @@ public class GCTopologyOperationRequestMapperTest extends TestDataSetup {
}
private Map<String, Object> getUserParams() {
- Map<String,Object> userParams = new HashMap<>();
- userParams.put("lppCustomerId","lppCustomerId");
+ Map<String, Object> userParams = new HashMap<>();
+ userParams.put("lppCustomerId", "lppCustomerId");
return userParams;
}
@@ -148,7 +148,7 @@ public class GCTopologyOperationRequestMapperTest extends TestDataSetup {
return ipv4subnet;
}
- private ServiceInstance buildServiceInstance(GenericVnf vnf) {
+ private ServiceInstance buildServiceInstance(GenericVnf vnf) {
ServiceInstance serviceInstance = new ServiceInstance();
serviceInstance.setServiceInstanceId("ServiceInstanceId");
List<GenericVnf> vnfs = serviceInstance.getVnfs();
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapperTest.java
index 630bccee9d..88a291e68b 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapperTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapperTest.java
@@ -27,10 +27,8 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
-
import java.util.HashMap;
import java.util.Map;
-
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
@@ -66,365 +64,383 @@ import org.onap.so.client.exception.MapperException;
import org.onap.so.client.sdnc.beans.SDNCSvcAction;
-public class GeneralTopologyObjectMapperTest extends TestDataSetup {
- @InjectMocks
- private GeneralTopologyObjectMapper genObjMapper = new GeneralTopologyObjectMapper();
-
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- @Before
- public void before() {
-
- }
-
- @After
- public void after() {
-
- }
-
- @Test
- public void testBuildServiceInformation() {
- // prepare and set service instance
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
- modelInfoServiceInstance.setModelName("serviceModelName");
- modelInfoServiceInstance.setModelUuid("serviceModelUuid");
- modelInfoServiceInstance.setModelVersion("serviceModelVersion");
-
- serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
- // prepare Customer object
- Customer customer = new Customer();
- customer.setGlobalCustomerId("globalCustomerId");
- ServiceSubscription serviceSubscription = new ServiceSubscription();
- serviceSubscription.setServiceType("productFamilyId");
- customer.setServiceSubscription(serviceSubscription);
- // set Customer on service instance
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
- //
- RequestContext requestContext = new RequestContext();
- Map<String, Object> userParams = new HashMap<>();
- userParams.put("key1", "value1");
- requestContext.setUserParams(userParams);
- requestContext.setProductFamilyId("productFamilyId");
-
- GenericResourceApiServiceinformationServiceInformation serviceInfo = genObjMapper.buildServiceInformation(serviceInstance, requestContext, customer, true);
-
- assertEquals("serviceModelInvariantUuid", serviceInfo.getOnapModelInformation().getModelInvariantUuid());
- assertEquals("serviceModelName", serviceInfo.getOnapModelInformation().getModelName());
- assertEquals("serviceModelUuid", serviceInfo.getOnapModelInformation().getModelUuid());
- assertEquals("serviceModelVersion", serviceInfo.getOnapModelInformation().getModelVersion());
- assertNull(serviceInfo.getOnapModelInformation().getModelCustomizationUuid());
- assertEquals("serviceInstanceId", serviceInfo.getServiceInstanceId());
- assertEquals("serviceInstanceId", serviceInfo.getServiceId());
- assertEquals("globalCustomerId", serviceInfo.getGlobalCustomerId());
- assertEquals("productFamilyId", serviceInfo.getSubscriptionServiceType());
- }
-
- @Test
- public void buildSdncRequestHeaderActivateTest() {
- GenericResourceApiSdncrequestheaderSdncRequestHeader requestHeader = genObjMapper.buildSdncRequestHeader(SDNCSvcAction.ACTIVATE, "sdncReqId");
-
- assertEquals(GenericResourceApiSvcActionEnumeration.ACTIVATE, requestHeader.getSvcAction());
- assertEquals("sdncReqId", requestHeader.getSvcRequestId());
- }
-
- @Test
- public void buildSdncRequestHeaderAssignTest() {
- GenericResourceApiSdncrequestheaderSdncRequestHeader requestHeader = genObjMapper.buildSdncRequestHeader(SDNCSvcAction.ASSIGN, "sdncReqId");
-
- assertEquals(GenericResourceApiSvcActionEnumeration.ASSIGN, requestHeader.getSvcAction());
- assertEquals("sdncReqId", requestHeader.getSvcRequestId());
- }
-
- @Test
- public void buildSdncRequestHeaderDeactivateTest() {
- GenericResourceApiSdncrequestheaderSdncRequestHeader requestHeader = genObjMapper.buildSdncRequestHeader(SDNCSvcAction.DEACTIVATE, "sdncReqId");
-
- assertEquals(GenericResourceApiSvcActionEnumeration.DEACTIVATE, requestHeader.getSvcAction());
- assertEquals("sdncReqId", requestHeader.getSvcRequestId());
- }
-
- @Test
- public void buildSdncRequestHeaderDeleteTest() {
- GenericResourceApiSdncrequestheaderSdncRequestHeader requestHeader = genObjMapper.buildSdncRequestHeader(SDNCSvcAction.DELETE, "sdncReqId");
-
- assertEquals(GenericResourceApiSvcActionEnumeration.DELETE, requestHeader.getSvcAction());
- assertEquals("sdncReqId", requestHeader.getSvcRequestId());
- }
-
- @Test
- public void buildSdncRequestHeaderChangeAssignTest() {
- GenericResourceApiSdncrequestheaderSdncRequestHeader requestHeader = genObjMapper.buildSdncRequestHeader(SDNCSvcAction.CHANGE_ASSIGN, "sdncReqId");
-
- assertEquals(GenericResourceApiSvcActionEnumeration.CHANGEASSIGN, requestHeader.getSvcAction());
- assertEquals("sdncReqId", requestHeader.getSvcRequestId());
- }
-
- @Test
- public void buildConfigurationInformationTest_excludesOnapModelInfo() {
- Configuration configuration = new Configuration();
- configuration.setConfigurationId("testConfigurationId");
- configuration.setConfigurationType("VNR");
- configuration.setConfigurationName("VNRCONF");
- GenericResourceApiConfigurationinformationConfigurationInformation configurationInformation =genObjMapper.buildConfigurationInformation(configuration,false);
- assertEquals(configuration.getConfigurationId(),configurationInformation.getConfigurationId());
- assertEquals(configuration.getConfigurationType(),configurationInformation.getConfigurationType());
- assertEquals(configuration.getConfigurationName(),configurationInformation.getConfigurationName());
- assertNull(configurationInformation.getOnapModelInformation());
- }
-
- @Test
- public void buildConfigurationInformationTest_includesOnapModelInfo() {
- Configuration configuration = new Configuration();
- configuration.setConfigurationId("testConfigurationId");
- configuration.setConfigurationType("VNR");
- configuration.setConfigurationName("VNRCONF");
- ModelInfoConfiguration modelInfoConfiguration = new ModelInfoConfiguration();
- modelInfoConfiguration.setModelVersionId("modelVersionId");
- modelInfoConfiguration.setModelInvariantId("modelInvariantId");
- modelInfoConfiguration.setModelCustomizationId("modelCustomizationId");
- configuration.setModelInfoConfiguration(modelInfoConfiguration);
-
- GenericResourceApiConfigurationinformationConfigurationInformation configurationInformation = genObjMapper.buildConfigurationInformation(configuration,true);
-
- assertEquals(configuration.getConfigurationId(),configurationInformation.getConfigurationId());
- assertEquals(configuration.getConfigurationType(),configurationInformation.getConfigurationType());
- assertEquals(configuration.getConfigurationName(),configurationInformation.getConfigurationName());
- assertNotNull(configurationInformation.getOnapModelInformation());
- assertEquals(configuration.getModelInfoConfiguration().getModelVersionId(),configurationInformation.getOnapModelInformation().getModelUuid());
- assertEquals(configuration.getModelInfoConfiguration().getModelInvariantId(),configurationInformation.getOnapModelInformation().getModelInvariantUuid());
- assertEquals(configuration.getModelInfoConfiguration().getModelCustomizationId(),configurationInformation.getOnapModelInformation().getModelCustomizationUuid());
-
- }
-
- @Test
- public void buildGcRequestInformationTest() {
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("TestVnfId");
- GenericResourceApiGcrequestinputGcRequestInput gcRequestInput = genObjMapper.buildGcRequestInformation(vnf,null);
- assertNotNull(gcRequestInput);
- assertEquals(vnf.getVnfId(),gcRequestInput.getVnfId());
- assertNull(gcRequestInput.getInputParameters());
- }
-
- @Test
- public void buildGcRequestInformationTest_withInputParams() {
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("TestVnfId");
- GenericResourceApiParam genericResourceApiParam =new GenericResourceApiParam();
- genericResourceApiParam.addParamItem(new GenericResourceApiParamParam());
- GenericResourceApiGcrequestinputGcRequestInput gcRequestInput = genObjMapper.buildGcRequestInformation(vnf,genericResourceApiParam);
- assertNotNull(gcRequestInput);
- assertEquals(vnf.getVnfId(),gcRequestInput.getVnfId());
- assertNotNull(gcRequestInput.getInputParameters());
- }
-
- @Test
- public void buildVnfInformationTest_withNullData() {
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("TestVnfId");
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- GenericResourceApiVnfinformationVnfInformation gcRequestInput = genObjMapper.buildVnfInformation(vnf,serviceInstance,true);
- assertNotNull(gcRequestInput);
- assertNull(vnf.getModelInfoGenericVnf());
- assertNull(gcRequestInput.getOnapModelInformation());
- assertEquals(vnf.getVnfId(),gcRequestInput.getVnfId());
- assertNotNull(gcRequestInput.getVnfId());
- }
-
- @Test
- public void buildNetworkInformationTest() {
-
- L3Network network = new L3Network();
- ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
- modelInfoNetwork.setModelInvariantUUID("my-uuid");
- modelInfoNetwork.setModelName("my-model-name");
- modelInfoNetwork.setModelVersion("my-model-version");
- modelInfoNetwork.setModelUUID("my-model-uuid");
- modelInfoNetwork.setModelCustomizationUUID("my-customization-uuid");
- network.setModelInfoNetwork(modelInfoNetwork);
- network.setNetworkId("my-network-id");
- network.setNetworkType("my-network-type");
- network.setNetworkTechnology("my-network-technology");
-
- GenericResourceApiNetworkinformationNetworkInformation networkInformation = new GenericResourceApiNetworkinformationNetworkInformation();
- GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation = new GenericResourceApiOnapmodelinformationOnapModelInformation();
- networkInformation.setNetworkId("my-network-id");
- networkInformation.setNetworkType("my-network-type");
- networkInformation.networkTechnology("my-network-technology");
- networkInformation.setFromPreload(null);
- onapModelInformation.setModelInvariantUuid("my-uuid");
- onapModelInformation.setModelName("my-model-name");
- onapModelInformation.setModelVersion("my-model-version");
- onapModelInformation.setModelUuid("my-model-uuid");
- onapModelInformation.setModelCustomizationUuid("my-customization-uuid");
- networkInformation.setOnapModelInformation(onapModelInformation);
-
- assertThat(networkInformation, sameBeanAs(genObjMapper.buildNetworkInformation(network)));
-
- }
-
- @Test
- public void buildNetworkInformationNoModelTest() {
-
- L3Network network = new L3Network();
- network.setNetworkId("my-network-id");
- network.setNetworkType("my-network-type");
- network.setNetworkTechnology("my-network-technology");
-
- GenericResourceApiNetworkinformationNetworkInformation networkInformation = new GenericResourceApiNetworkinformationNetworkInformation();
- networkInformation.setNetworkId("my-network-id");
- networkInformation.setNetworkType("my-network-type");
- networkInformation.networkTechnology("my-network-technology");
- networkInformation.setFromPreload(null);
-
-
- assertThat(networkInformation, sameBeanAs(genObjMapper.buildNetworkInformation(network)));
-
- }
-
-
- @Test
- public void buildVfModuleInformationTest_withNoModelIsFromPreload() {
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("TestVfModuleId");
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- GenericVnf genericVnf = new GenericVnf();
- genericVnf.setVnfId("TestVnfId");
- RequestContext requestContext = new RequestContext();
- RequestParameters requestParameters = new RequestParameters();
- requestParameters.setUsePreload(true);
- requestContext.setRequestParameters(requestParameters);
- GenericResourceApiVfmoduleinformationVfModuleInformation gcRequestInput = null;
- try {
- gcRequestInput = genObjMapper.buildVfModuleInformation(vfModule, genericVnf, serviceInstance, requestContext, false);
- }
- catch (MapperException ex) {
-
- }
- assertNotNull(gcRequestInput);
- assertNull(vfModule.getModelInfoVfModule());
- assertNull(gcRequestInput.getOnapModelInformation());
- assertEquals(vfModule.getVfModuleId(),gcRequestInput.getVfModuleId());
- assertNotNull(gcRequestInput.getVfModuleId());
- assertTrue(gcRequestInput.getFromPreload());
- }
-
- @Test
- public void buildVfModuleInformationTest_withNoModelIsNotFromPreload() {
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("TestVfModuleId");
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- GenericVnf genericVnf = new GenericVnf();
- genericVnf.setVnfId("TestVnfId");
- RequestContext requestContext = new RequestContext();
- RequestParameters requestParameters = new RequestParameters();
- requestParameters.setUsePreload(false);
- requestContext.setRequestParameters(requestParameters);
- GenericResourceApiVfmoduleinformationVfModuleInformation gcRequestInput = null;
- try {
- gcRequestInput = genObjMapper.buildVfModuleInformation(vfModule, genericVnf, serviceInstance, requestContext, false);
- }
- catch (MapperException ex) {
-
- }
- assertNotNull(gcRequestInput);
- assertNull(vfModule.getModelInfoVfModule());
- assertNull(gcRequestInput.getOnapModelInformation());
- assertEquals(vfModule.getVfModuleId(),gcRequestInput.getVfModuleId());
- assertNotNull(gcRequestInput.getVfModuleId());
- assertFalse(gcRequestInput.getFromPreload());
- }
-
- @Test
- public void buildVfModuleInformationTest_withNoModelNoRequestContext() {
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("TestVfModuleId");
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- GenericVnf genericVnf = new GenericVnf();
- genericVnf.setVnfId("TestVnfId");
- GenericResourceApiVfmoduleinformationVfModuleInformation gcRequestInput = null;
- try {
- gcRequestInput = genObjMapper.buildVfModuleInformation(vfModule, genericVnf, serviceInstance, null, false);
- }
- catch (MapperException ex) {
-
- }
- assertNotNull(gcRequestInput);
- assertNull(vfModule.getModelInfoVfModule());
- assertNull(gcRequestInput.getOnapModelInformation());
- assertEquals(vfModule.getVfModuleId(),gcRequestInput.getVfModuleId());
- assertNotNull(gcRequestInput.getVfModuleId());
- assertTrue(gcRequestInput.getFromPreload());
- }
-
- @Test
- public void buildVfModuleInformationTest_withNoModelNoRequestParameters() {
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("TestVfModuleId");
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- GenericVnf genericVnf = new GenericVnf();
- genericVnf.setVnfId("TestVnfId");
- RequestContext requestContext = new RequestContext();
- GenericResourceApiVfmoduleinformationVfModuleInformation gcRequestInput = null;
- try {
- gcRequestInput = genObjMapper.buildVfModuleInformation(vfModule, genericVnf, serviceInstance, requestContext, false);
- }
- catch (MapperException ex) {
-
- }
- assertNotNull(gcRequestInput);
- assertNull(vfModule.getModelInfoVfModule());
- assertNull(gcRequestInput.getOnapModelInformation());
- assertEquals(vfModule.getVfModuleId(),gcRequestInput.getVfModuleId());
- assertNotNull(gcRequestInput.getVfModuleId());
- assertTrue(gcRequestInput.getFromPreload());
- }
-
- @Test
- public void buildVfModuleInformationTest_withModel() {
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("TestVfModuleId");
- ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
- modelInfoVfModule.setModelInvariantUUID("testModelInvariantUUID");
- modelInfoVfModule.setModelName("testModelName");
- modelInfoVfModule.setModelVersion("testModelVersion");
- modelInfoVfModule.setModelUUID("testModelUUID");
- modelInfoVfModule.setModelCustomizationUUID("testModelCustomizationUUID");
- vfModule.setModelInfoVfModule(modelInfoVfModule);
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- GenericVnf genericVnf = new GenericVnf();
- genericVnf.setVnfId("TestVnfId");
- RequestContext requestContext = new RequestContext();
- RequestParameters requestParameters = new RequestParameters();
- requestParameters.setUsePreload(true);
- requestContext.setRequestParameters(requestParameters);
- GenericResourceApiVfmoduleinformationVfModuleInformation gcRequestInput = null;
- try {
- gcRequestInput = genObjMapper.buildVfModuleInformation(vfModule, genericVnf, serviceInstance, requestContext, true);
- }
- catch (MapperException ex) {
-
- }
- assertNotNull(gcRequestInput);
- assertNotNull(vfModule.getModelInfoVfModule());
- assertNotNull(gcRequestInput.getOnapModelInformation());
- assertEquals(modelInfoVfModule.getModelInvariantUUID(), gcRequestInput.getOnapModelInformation().getModelInvariantUuid());
- assertEquals(modelInfoVfModule.getModelName(), gcRequestInput.getOnapModelInformation().getModelName());
- assertEquals(modelInfoVfModule.getModelVersion(), gcRequestInput.getOnapModelInformation().getModelVersion());
- assertEquals(modelInfoVfModule.getModelUUID(), gcRequestInput.getOnapModelInformation().getModelUuid());
- assertEquals(modelInfoVfModule.getModelCustomizationUUID(), gcRequestInput.getOnapModelInformation().getModelCustomizationUuid());
- assertEquals(vfModule.getVfModuleId(),gcRequestInput.getVfModuleId());
- assertNotNull(gcRequestInput.getVfModuleId());
- assertTrue(gcRequestInput.getFromPreload());
- }
+public class GeneralTopologyObjectMapperTest extends TestDataSetup {
+ @InjectMocks
+ private GeneralTopologyObjectMapper genObjMapper = new GeneralTopologyObjectMapper();
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ @Before
+ public void before() {
+
+ }
+
+ @After
+ public void after() {
+
+ }
+
+ @Test
+ public void testBuildServiceInformation() {
+ // prepare and set service instance
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
+ modelInfoServiceInstance.setModelName("serviceModelName");
+ modelInfoServiceInstance.setModelUuid("serviceModelUuid");
+ modelInfoServiceInstance.setModelVersion("serviceModelVersion");
+
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+ // prepare Customer object
+ Customer customer = new Customer();
+ customer.setGlobalCustomerId("globalCustomerId");
+ ServiceSubscription serviceSubscription = new ServiceSubscription();
+ serviceSubscription.setServiceType("productFamilyId");
+ customer.setServiceSubscription(serviceSubscription);
+ // set Customer on service instance
+ customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
+ //
+ RequestContext requestContext = new RequestContext();
+ Map<String, Object> userParams = new HashMap<>();
+ userParams.put("key1", "value1");
+ requestContext.setUserParams(userParams);
+ requestContext.setProductFamilyId("productFamilyId");
+
+ GenericResourceApiServiceinformationServiceInformation serviceInfo =
+ genObjMapper.buildServiceInformation(serviceInstance, requestContext, customer, true);
+
+ assertEquals("serviceModelInvariantUuid", serviceInfo.getOnapModelInformation().getModelInvariantUuid());
+ assertEquals("serviceModelName", serviceInfo.getOnapModelInformation().getModelName());
+ assertEquals("serviceModelUuid", serviceInfo.getOnapModelInformation().getModelUuid());
+ assertEquals("serviceModelVersion", serviceInfo.getOnapModelInformation().getModelVersion());
+ assertNull(serviceInfo.getOnapModelInformation().getModelCustomizationUuid());
+ assertEquals("serviceInstanceId", serviceInfo.getServiceInstanceId());
+ assertEquals("serviceInstanceId", serviceInfo.getServiceId());
+ assertEquals("globalCustomerId", serviceInfo.getGlobalCustomerId());
+ assertEquals("productFamilyId", serviceInfo.getSubscriptionServiceType());
+ }
+
+ @Test
+ public void buildSdncRequestHeaderActivateTest() {
+ GenericResourceApiSdncrequestheaderSdncRequestHeader requestHeader =
+ genObjMapper.buildSdncRequestHeader(SDNCSvcAction.ACTIVATE, "sdncReqId");
+
+ assertEquals(GenericResourceApiSvcActionEnumeration.ACTIVATE, requestHeader.getSvcAction());
+ assertEquals("sdncReqId", requestHeader.getSvcRequestId());
+ }
+
+ @Test
+ public void buildSdncRequestHeaderAssignTest() {
+ GenericResourceApiSdncrequestheaderSdncRequestHeader requestHeader =
+ genObjMapper.buildSdncRequestHeader(SDNCSvcAction.ASSIGN, "sdncReqId");
+
+ assertEquals(GenericResourceApiSvcActionEnumeration.ASSIGN, requestHeader.getSvcAction());
+ assertEquals("sdncReqId", requestHeader.getSvcRequestId());
+ }
+
+ @Test
+ public void buildSdncRequestHeaderDeactivateTest() {
+ GenericResourceApiSdncrequestheaderSdncRequestHeader requestHeader =
+ genObjMapper.buildSdncRequestHeader(SDNCSvcAction.DEACTIVATE, "sdncReqId");
+
+ assertEquals(GenericResourceApiSvcActionEnumeration.DEACTIVATE, requestHeader.getSvcAction());
+ assertEquals("sdncReqId", requestHeader.getSvcRequestId());
+ }
+
+ @Test
+ public void buildSdncRequestHeaderDeleteTest() {
+ GenericResourceApiSdncrequestheaderSdncRequestHeader requestHeader =
+ genObjMapper.buildSdncRequestHeader(SDNCSvcAction.DELETE, "sdncReqId");
+
+ assertEquals(GenericResourceApiSvcActionEnumeration.DELETE, requestHeader.getSvcAction());
+ assertEquals("sdncReqId", requestHeader.getSvcRequestId());
+ }
+
+ @Test
+ public void buildSdncRequestHeaderChangeAssignTest() {
+ GenericResourceApiSdncrequestheaderSdncRequestHeader requestHeader =
+ genObjMapper.buildSdncRequestHeader(SDNCSvcAction.CHANGE_ASSIGN, "sdncReqId");
+
+ assertEquals(GenericResourceApiSvcActionEnumeration.CHANGEASSIGN, requestHeader.getSvcAction());
+ assertEquals("sdncReqId", requestHeader.getSvcRequestId());
+ }
+
+ @Test
+ public void buildConfigurationInformationTest_excludesOnapModelInfo() {
+ Configuration configuration = new Configuration();
+ configuration.setConfigurationId("testConfigurationId");
+ configuration.setConfigurationType("VNR");
+ configuration.setConfigurationName("VNRCONF");
+ GenericResourceApiConfigurationinformationConfigurationInformation configurationInformation =
+ genObjMapper.buildConfigurationInformation(configuration, false);
+ assertEquals(configuration.getConfigurationId(), configurationInformation.getConfigurationId());
+ assertEquals(configuration.getConfigurationType(), configurationInformation.getConfigurationType());
+ assertEquals(configuration.getConfigurationName(), configurationInformation.getConfigurationName());
+ assertNull(configurationInformation.getOnapModelInformation());
+ }
+
+ @Test
+ public void buildConfigurationInformationTest_includesOnapModelInfo() {
+ Configuration configuration = new Configuration();
+ configuration.setConfigurationId("testConfigurationId");
+ configuration.setConfigurationType("VNR");
+ configuration.setConfigurationName("VNRCONF");
+ ModelInfoConfiguration modelInfoConfiguration = new ModelInfoConfiguration();
+ modelInfoConfiguration.setModelVersionId("modelVersionId");
+ modelInfoConfiguration.setModelInvariantId("modelInvariantId");
+ modelInfoConfiguration.setModelCustomizationId("modelCustomizationId");
+ configuration.setModelInfoConfiguration(modelInfoConfiguration);
+
+ GenericResourceApiConfigurationinformationConfigurationInformation configurationInformation =
+ genObjMapper.buildConfigurationInformation(configuration, true);
+
+ assertEquals(configuration.getConfigurationId(), configurationInformation.getConfigurationId());
+ assertEquals(configuration.getConfigurationType(), configurationInformation.getConfigurationType());
+ assertEquals(configuration.getConfigurationName(), configurationInformation.getConfigurationName());
+ assertNotNull(configurationInformation.getOnapModelInformation());
+ assertEquals(configuration.getModelInfoConfiguration().getModelVersionId(),
+ configurationInformation.getOnapModelInformation().getModelUuid());
+ assertEquals(configuration.getModelInfoConfiguration().getModelInvariantId(),
+ configurationInformation.getOnapModelInformation().getModelInvariantUuid());
+ assertEquals(configuration.getModelInfoConfiguration().getModelCustomizationId(),
+ configurationInformation.getOnapModelInformation().getModelCustomizationUuid());
+
+ }
+
+ @Test
+ public void buildGcRequestInformationTest() {
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("TestVnfId");
+ GenericResourceApiGcrequestinputGcRequestInput gcRequestInput =
+ genObjMapper.buildGcRequestInformation(vnf, null);
+ assertNotNull(gcRequestInput);
+ assertEquals(vnf.getVnfId(), gcRequestInput.getVnfId());
+ assertNull(gcRequestInput.getInputParameters());
+ }
+
+ @Test
+ public void buildGcRequestInformationTest_withInputParams() {
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("TestVnfId");
+ GenericResourceApiParam genericResourceApiParam = new GenericResourceApiParam();
+ genericResourceApiParam.addParamItem(new GenericResourceApiParamParam());
+ GenericResourceApiGcrequestinputGcRequestInput gcRequestInput =
+ genObjMapper.buildGcRequestInformation(vnf, genericResourceApiParam);
+ assertNotNull(gcRequestInput);
+ assertEquals(vnf.getVnfId(), gcRequestInput.getVnfId());
+ assertNotNull(gcRequestInput.getInputParameters());
+ }
+
+ @Test
+ public void buildVnfInformationTest_withNullData() {
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("TestVnfId");
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ GenericResourceApiVnfinformationVnfInformation gcRequestInput =
+ genObjMapper.buildVnfInformation(vnf, serviceInstance, true);
+ assertNotNull(gcRequestInput);
+ assertNull(vnf.getModelInfoGenericVnf());
+ assertNull(gcRequestInput.getOnapModelInformation());
+ assertEquals(vnf.getVnfId(), gcRequestInput.getVnfId());
+ assertNotNull(gcRequestInput.getVnfId());
+ }
+
+ @Test
+ public void buildNetworkInformationTest() {
+
+ L3Network network = new L3Network();
+ ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
+ modelInfoNetwork.setModelInvariantUUID("my-uuid");
+ modelInfoNetwork.setModelName("my-model-name");
+ modelInfoNetwork.setModelVersion("my-model-version");
+ modelInfoNetwork.setModelUUID("my-model-uuid");
+ modelInfoNetwork.setModelCustomizationUUID("my-customization-uuid");
+ network.setModelInfoNetwork(modelInfoNetwork);
+ network.setNetworkId("my-network-id");
+ network.setNetworkType("my-network-type");
+ network.setNetworkTechnology("my-network-technology");
+
+ GenericResourceApiNetworkinformationNetworkInformation networkInformation =
+ new GenericResourceApiNetworkinformationNetworkInformation();
+ GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation =
+ new GenericResourceApiOnapmodelinformationOnapModelInformation();
+ networkInformation.setNetworkId("my-network-id");
+ networkInformation.setNetworkType("my-network-type");
+ networkInformation.networkTechnology("my-network-technology");
+ networkInformation.setFromPreload(null);
+ onapModelInformation.setModelInvariantUuid("my-uuid");
+ onapModelInformation.setModelName("my-model-name");
+ onapModelInformation.setModelVersion("my-model-version");
+ onapModelInformation.setModelUuid("my-model-uuid");
+ onapModelInformation.setModelCustomizationUuid("my-customization-uuid");
+ networkInformation.setOnapModelInformation(onapModelInformation);
+
+ assertThat(networkInformation, sameBeanAs(genObjMapper.buildNetworkInformation(network)));
+
+ }
+
+ @Test
+ public void buildNetworkInformationNoModelTest() {
+
+ L3Network network = new L3Network();
+ network.setNetworkId("my-network-id");
+ network.setNetworkType("my-network-type");
+ network.setNetworkTechnology("my-network-technology");
+
+ GenericResourceApiNetworkinformationNetworkInformation networkInformation =
+ new GenericResourceApiNetworkinformationNetworkInformation();
+ networkInformation.setNetworkId("my-network-id");
+ networkInformation.setNetworkType("my-network-type");
+ networkInformation.networkTechnology("my-network-technology");
+ networkInformation.setFromPreload(null);
+
+
+ assertThat(networkInformation, sameBeanAs(genObjMapper.buildNetworkInformation(network)));
+
+ }
+
+
+ @Test
+ public void buildVfModuleInformationTest_withNoModelIsFromPreload() {
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("TestVfModuleId");
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ GenericVnf genericVnf = new GenericVnf();
+ genericVnf.setVnfId("TestVnfId");
+ RequestContext requestContext = new RequestContext();
+ RequestParameters requestParameters = new RequestParameters();
+ requestParameters.setUsePreload(true);
+ requestContext.setRequestParameters(requestParameters);
+ GenericResourceApiVfmoduleinformationVfModuleInformation gcRequestInput = null;
+ try {
+ gcRequestInput =
+ genObjMapper.buildVfModuleInformation(vfModule, genericVnf, serviceInstance, requestContext, false);
+ } catch (MapperException ex) {
+
+ }
+ assertNotNull(gcRequestInput);
+ assertNull(vfModule.getModelInfoVfModule());
+ assertNull(gcRequestInput.getOnapModelInformation());
+ assertEquals(vfModule.getVfModuleId(), gcRequestInput.getVfModuleId());
+ assertNotNull(gcRequestInput.getVfModuleId());
+ assertTrue(gcRequestInput.getFromPreload());
+ }
+
+ @Test
+ public void buildVfModuleInformationTest_withNoModelIsNotFromPreload() {
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("TestVfModuleId");
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ GenericVnf genericVnf = new GenericVnf();
+ genericVnf.setVnfId("TestVnfId");
+ RequestContext requestContext = new RequestContext();
+ RequestParameters requestParameters = new RequestParameters();
+ requestParameters.setUsePreload(false);
+ requestContext.setRequestParameters(requestParameters);
+ GenericResourceApiVfmoduleinformationVfModuleInformation gcRequestInput = null;
+ try {
+ gcRequestInput =
+ genObjMapper.buildVfModuleInformation(vfModule, genericVnf, serviceInstance, requestContext, false);
+ } catch (MapperException ex) {
+
+ }
+ assertNotNull(gcRequestInput);
+ assertNull(vfModule.getModelInfoVfModule());
+ assertNull(gcRequestInput.getOnapModelInformation());
+ assertEquals(vfModule.getVfModuleId(), gcRequestInput.getVfModuleId());
+ assertNotNull(gcRequestInput.getVfModuleId());
+ assertFalse(gcRequestInput.getFromPreload());
+ }
+
+ @Test
+ public void buildVfModuleInformationTest_withNoModelNoRequestContext() {
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("TestVfModuleId");
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ GenericVnf genericVnf = new GenericVnf();
+ genericVnf.setVnfId("TestVnfId");
+ GenericResourceApiVfmoduleinformationVfModuleInformation gcRequestInput = null;
+ try {
+ gcRequestInput = genObjMapper.buildVfModuleInformation(vfModule, genericVnf, serviceInstance, null, false);
+ } catch (MapperException ex) {
+
+ }
+ assertNotNull(gcRequestInput);
+ assertNull(vfModule.getModelInfoVfModule());
+ assertNull(gcRequestInput.getOnapModelInformation());
+ assertEquals(vfModule.getVfModuleId(), gcRequestInput.getVfModuleId());
+ assertNotNull(gcRequestInput.getVfModuleId());
+ assertTrue(gcRequestInput.getFromPreload());
+ }
+
+ @Test
+ public void buildVfModuleInformationTest_withNoModelNoRequestParameters() {
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("TestVfModuleId");
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ GenericVnf genericVnf = new GenericVnf();
+ genericVnf.setVnfId("TestVnfId");
+ RequestContext requestContext = new RequestContext();
+ GenericResourceApiVfmoduleinformationVfModuleInformation gcRequestInput = null;
+ try {
+ gcRequestInput =
+ genObjMapper.buildVfModuleInformation(vfModule, genericVnf, serviceInstance, requestContext, false);
+ } catch (MapperException ex) {
+
+ }
+ assertNotNull(gcRequestInput);
+ assertNull(vfModule.getModelInfoVfModule());
+ assertNull(gcRequestInput.getOnapModelInformation());
+ assertEquals(vfModule.getVfModuleId(), gcRequestInput.getVfModuleId());
+ assertNotNull(gcRequestInput.getVfModuleId());
+ assertTrue(gcRequestInput.getFromPreload());
+ }
+
+ @Test
+ public void buildVfModuleInformationTest_withModel() {
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("TestVfModuleId");
+ ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
+ modelInfoVfModule.setModelInvariantUUID("testModelInvariantUUID");
+ modelInfoVfModule.setModelName("testModelName");
+ modelInfoVfModule.setModelVersion("testModelVersion");
+ modelInfoVfModule.setModelUUID("testModelUUID");
+ modelInfoVfModule.setModelCustomizationUUID("testModelCustomizationUUID");
+ vfModule.setModelInfoVfModule(modelInfoVfModule);
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ GenericVnf genericVnf = new GenericVnf();
+ genericVnf.setVnfId("TestVnfId");
+ RequestContext requestContext = new RequestContext();
+ RequestParameters requestParameters = new RequestParameters();
+ requestParameters.setUsePreload(true);
+ requestContext.setRequestParameters(requestParameters);
+ GenericResourceApiVfmoduleinformationVfModuleInformation gcRequestInput = null;
+ try {
+ gcRequestInput =
+ genObjMapper.buildVfModuleInformation(vfModule, genericVnf, serviceInstance, requestContext, true);
+ } catch (MapperException ex) {
+
+ }
+ assertNotNull(gcRequestInput);
+ assertNotNull(vfModule.getModelInfoVfModule());
+ assertNotNull(gcRequestInput.getOnapModelInformation());
+ assertEquals(modelInfoVfModule.getModelInvariantUUID(),
+ gcRequestInput.getOnapModelInformation().getModelInvariantUuid());
+ assertEquals(modelInfoVfModule.getModelName(), gcRequestInput.getOnapModelInformation().getModelName());
+ assertEquals(modelInfoVfModule.getModelVersion(), gcRequestInput.getOnapModelInformation().getModelVersion());
+ assertEquals(modelInfoVfModule.getModelUUID(), gcRequestInput.getOnapModelInformation().getModelUuid());
+ assertEquals(modelInfoVfModule.getModelCustomizationUUID(),
+ gcRequestInput.getOnapModelInformation().getModelCustomizationUuid());
+ assertEquals(vfModule.getVfModuleId(), gcRequestInput.getVfModuleId());
+ assertNotNull(gcRequestInput.getVfModuleId());
+ assertTrue(gcRequestInput.getFromPreload());
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapperTest.java
index 1bfa78ad6d..76e915781f 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapperTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapperTest.java
@@ -25,13 +25,11 @@ import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
-
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -52,174 +50,183 @@ import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance;
import org.onap.so.client.sdnc.beans.SDNCSvcAction;
import org.onap.so.client.sdnc.beans.SDNCSvcOperation;
-
import com.fasterxml.jackson.databind.ObjectMapper;
@RunWith(MockitoJUnitRunner.class)
public class NetworkTopologyOperationRequestMapperTest {
- private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/";
-
- private ServiceInstance serviceInstance;
- private ServiceInstance serviceInstanceNoCollection;
- private Customer customer;
- private RequestContext requestContext;
- private L3Network network;
- private CloudRegion cloudRegion;
-
- @Spy
- private GeneralTopologyObjectMapper generalTopologyObjectMapper;
-
- @InjectMocks
- private NetworkTopologyOperationRequestMapper mapper = new NetworkTopologyOperationRequestMapper();
-
- @Before
- public void before() {
- // prepare and set service instance
- serviceInstance = new ServiceInstance();
- serviceInstanceNoCollection = new ServiceInstance();
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setModelInvariantUuid("modelInvariantUuid");
- modelInfoServiceInstance.setModelName("modelName");
- modelInfoServiceInstance.setModelUuid("modelUuid");
- modelInfoServiceInstance.setModelVersion("modelVersion");
- serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
- serviceInstanceNoCollection.setModelInfoServiceInstance(modelInfoServiceInstance);
- // prepare Customer object
- customer = new Customer();
- customer.setGlobalCustomerId("globalCustomerId");
- //serviceInstance.setCustomer(customer);
- // set Customer on service instance
- ServiceSubscription serviceSubscription = new ServiceSubscription();
- serviceSubscription.setServiceType("productFamilyId");
- customer.setServiceSubscription(serviceSubscription);
-
- // set Customer on service instance
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
- customer.getServiceSubscription().getServiceInstances().add(serviceInstanceNoCollection);
- //
- InstanceGroup networkInstanceGroup = new InstanceGroup();
- networkInstanceGroup.setId("networkInstanceGroupId");
- networkInstanceGroup.setInstanceGroupFunction("instanceGroupFunction");
- Collection networkCollection = new Collection();
- networkCollection.setInstanceGroup(networkInstanceGroup);
- serviceInstance.setCollection(networkCollection);
- //
- requestContext = new RequestContext();
- Map<String, Object> userParams = new HashMap<>();
- userParams.put("key1", "value1");
- requestContext.setUserParams(userParams);
- requestContext.setProductFamilyId("productFamilyId");
- requestContext.setMsoRequestId("MsoRequestId");
-
- network = new L3Network();
- network.setNetworkId("TEST_NETWORK_ID");
- network.setNetworkName("TEST_NETWORK_NAME");
- ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
- modelInfoNetwork.setModelInvariantUUID("modelInvariantUuid");
- modelInfoNetwork.setModelName("modelName");
- modelInfoNetwork.setModelVersion("modelVersion");
- modelInfoNetwork.setModelUUID("modelUuid");
- modelInfoNetwork.setModelCustomizationUUID("modelCustomizationUUID");
- network.setModelInfoNetwork(modelInfoNetwork);
-
- cloudRegion = new CloudRegion();
- }
-
- @Test
- public void createGenericResourceApiNetworkOperationInformationTest() throws Exception {
-
- GenericResourceApiNetworkOperationInformation networkSDNCrequest = mapper.reqMapper(
- SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, customer,
- requestContext, cloudRegion);
-
- ObjectMapper omapper = new ObjectMapper();
- GenericResourceApiNetworkOperationInformation reqMapper1 = omapper.readValue(
- getJson("genericResourceApiNetworkOperationInformation.json"),
- GenericResourceApiNetworkOperationInformation.class);
-
- assertThat(networkSDNCrequest, sameBeanAs(reqMapper1).ignoring("sdncRequestHeader.svcRequestId")
- .ignoring("requestInformation.requestId"));
- assertEquals("MsoRequestId", networkSDNCrequest.getRequestInformation().getRequestId());
- }
-
- @Test
- public void createGenericResourceApiNetworkOperationInformationReqContextNullTest() throws Exception {
-
- RequestContext rc = new RequestContext();
- rc.setMsoRequestId(null);
- GenericResourceApiNetworkOperationInformation networkSDNCrequest = mapper.reqMapper(
- SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, customer,
- rc, cloudRegion);
- assertNotNull(networkSDNCrequest.getRequestInformation().getRequestId());
- GenericResourceApiNetworkOperationInformation networkSDNCrequest2 = mapper.reqMapper(
- SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, customer,
- null, cloudRegion);
- assertNotNull(networkSDNCrequest2.getRequestInformation().getRequestId());
- }
-
- @Test
- public void reqMapperTest() throws Exception {
-
- GenericResourceApiNetworkOperationInformation networkSDNCrequest = mapper.reqMapper(
- SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, customer,
- requestContext, cloudRegion);
-
- assertNull(networkSDNCrequest.getServiceInformation().getOnapModelInformation().getModelCustomizationUuid());
- assertEquals("modelCustomizationUUID", networkSDNCrequest.getNetworkInformation().getOnapModelInformation().getModelCustomizationUuid());
- }
-
- @Test
- public void reqMapperNoCollectionTest() throws Exception {
- GenericResourceApiNetworkOperationInformation networkSDNCrequest = mapper.reqMapper(
- SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstanceNoCollection, customer,
- requestContext, cloudRegion);
-
- assertNull(networkSDNCrequest.getServiceInformation().getOnapModelInformation().getModelCustomizationUuid());
- assertEquals("modelCustomizationUUID", networkSDNCrequest.getNetworkInformation().getOnapModelInformation().getModelCustomizationUuid());
- }
- @Test
- public void createGenericResourceApiNetworkOperationInformation_UnassignTest() throws Exception {
-
- NetworkTopologyOperationRequestMapper mapperUnassign = mapper;
- GenericResourceApiNetworkOperationInformation networkSDNCrequestUnassign = mapperUnassign.reqMapper(
- SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN, GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, customer,
- requestContext, cloudRegion);
-
- ObjectMapper omapperUnassign = new ObjectMapper();
- GenericResourceApiNetworkOperationInformation reqMapperUnassign = omapperUnassign.readValue(
- getJson("genericResourceApiNetworkOperationInformationUnAssign.json"),
- GenericResourceApiNetworkOperationInformation.class);
-
- assertThat(reqMapperUnassign, sameBeanAs(networkSDNCrequestUnassign).ignoring("sdncRequestHeader.svcRequestId")
- .ignoring("requestInformation.requestId"));
- assertEquals("MsoRequestId", networkSDNCrequestUnassign.getRequestInformation().getRequestId());
-
- }
-
- @Test
- public void createGenericResourceApiNetworkOperationInformationNoNetworkNameTest() throws Exception {
-
- //set network name NULL
- network.setNetworkName(null);
- GenericResourceApiNetworkOperationInformation networkSDNCrequest = mapper.reqMapper(
- SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, customer,
- requestContext, cloudRegion);
-
- ObjectMapper omapper = new ObjectMapper();
- GenericResourceApiNetworkOperationInformation reqMapper1 = omapper.readValue(
- getJson("genericResourceApiNetworkOperationInformationNoNetworkName.json"),
- GenericResourceApiNetworkOperationInformation.class);
-
- assertThat(reqMapper1, sameBeanAs(networkSDNCrequest).ignoring("sdncRequestHeader.svcRequestId")
- .ignoring("requestInformation.requestId"));
- }
-
- /*
- * Helper method to load JSON data
- */
- private String getJson(String filename) throws IOException {
- return new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + filename)));
- }
+ private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/";
+
+ private ServiceInstance serviceInstance;
+ private ServiceInstance serviceInstanceNoCollection;
+ private Customer customer;
+ private RequestContext requestContext;
+ private L3Network network;
+ private CloudRegion cloudRegion;
+
+ @Spy
+ private GeneralTopologyObjectMapper generalTopologyObjectMapper;
+
+ @InjectMocks
+ private NetworkTopologyOperationRequestMapper mapper = new NetworkTopologyOperationRequestMapper();
+
+ @Before
+ public void before() {
+ // prepare and set service instance
+ serviceInstance = new ServiceInstance();
+ serviceInstanceNoCollection = new ServiceInstance();
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelInvariantUuid("modelInvariantUuid");
+ modelInfoServiceInstance.setModelName("modelName");
+ modelInfoServiceInstance.setModelUuid("modelUuid");
+ modelInfoServiceInstance.setModelVersion("modelVersion");
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+ serviceInstanceNoCollection.setModelInfoServiceInstance(modelInfoServiceInstance);
+ // prepare Customer object
+ customer = new Customer();
+ customer.setGlobalCustomerId("globalCustomerId");
+ // serviceInstance.setCustomer(customer);
+ // set Customer on service instance
+ ServiceSubscription serviceSubscription = new ServiceSubscription();
+ serviceSubscription.setServiceType("productFamilyId");
+ customer.setServiceSubscription(serviceSubscription);
+
+ // set Customer on service instance
+ customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
+ customer.getServiceSubscription().getServiceInstances().add(serviceInstanceNoCollection);
+ //
+ InstanceGroup networkInstanceGroup = new InstanceGroup();
+ networkInstanceGroup.setId("networkInstanceGroupId");
+ networkInstanceGroup.setInstanceGroupFunction("instanceGroupFunction");
+ Collection networkCollection = new Collection();
+ networkCollection.setInstanceGroup(networkInstanceGroup);
+ serviceInstance.setCollection(networkCollection);
+ //
+ requestContext = new RequestContext();
+ Map<String, Object> userParams = new HashMap<>();
+ userParams.put("key1", "value1");
+ requestContext.setUserParams(userParams);
+ requestContext.setProductFamilyId("productFamilyId");
+ requestContext.setMsoRequestId("MsoRequestId");
+
+ network = new L3Network();
+ network.setNetworkId("TEST_NETWORK_ID");
+ network.setNetworkName("TEST_NETWORK_NAME");
+ ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
+ modelInfoNetwork.setModelInvariantUUID("modelInvariantUuid");
+ modelInfoNetwork.setModelName("modelName");
+ modelInfoNetwork.setModelVersion("modelVersion");
+ modelInfoNetwork.setModelUUID("modelUuid");
+ modelInfoNetwork.setModelCustomizationUUID("modelCustomizationUUID");
+ network.setModelInfoNetwork(modelInfoNetwork);
+
+ cloudRegion = new CloudRegion();
+ }
+
+ @Test
+ public void createGenericResourceApiNetworkOperationInformationTest() throws Exception {
+
+ GenericResourceApiNetworkOperationInformation networkSDNCrequest =
+ mapper.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,
+ GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance,
+ customer, requestContext, cloudRegion);
+
+ ObjectMapper omapper = new ObjectMapper();
+ GenericResourceApiNetworkOperationInformation reqMapper1 =
+ omapper.readValue(getJson("genericResourceApiNetworkOperationInformation.json"),
+ GenericResourceApiNetworkOperationInformation.class);
+
+ assertThat(networkSDNCrequest, sameBeanAs(reqMapper1).ignoring("sdncRequestHeader.svcRequestId")
+ .ignoring("requestInformation.requestId"));
+ assertEquals("MsoRequestId", networkSDNCrequest.getRequestInformation().getRequestId());
+ }
+
+ @Test
+ public void createGenericResourceApiNetworkOperationInformationReqContextNullTest() throws Exception {
+
+ RequestContext rc = new RequestContext();
+ rc.setMsoRequestId(null);
+ GenericResourceApiNetworkOperationInformation networkSDNCrequest =
+ mapper.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,
+ GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance,
+ customer, rc, cloudRegion);
+ assertNotNull(networkSDNCrequest.getRequestInformation().getRequestId());
+ GenericResourceApiNetworkOperationInformation networkSDNCrequest2 =
+ mapper.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,
+ GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance,
+ customer, null, cloudRegion);
+ assertNotNull(networkSDNCrequest2.getRequestInformation().getRequestId());
+ }
+
+ @Test
+ public void reqMapperTest() throws Exception {
+
+ GenericResourceApiNetworkOperationInformation networkSDNCrequest =
+ mapper.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,
+ GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance,
+ customer, requestContext, cloudRegion);
+
+ assertNull(networkSDNCrequest.getServiceInformation().getOnapModelInformation().getModelCustomizationUuid());
+ assertEquals("modelCustomizationUUID",
+ networkSDNCrequest.getNetworkInformation().getOnapModelInformation().getModelCustomizationUuid());
+ }
+
+ @Test
+ public void reqMapperNoCollectionTest() throws Exception {
+ GenericResourceApiNetworkOperationInformation networkSDNCrequest =
+ mapper.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,
+ GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network,
+ serviceInstanceNoCollection, customer, requestContext, cloudRegion);
+
+ assertNull(networkSDNCrequest.getServiceInformation().getOnapModelInformation().getModelCustomizationUuid());
+ assertEquals("modelCustomizationUUID",
+ networkSDNCrequest.getNetworkInformation().getOnapModelInformation().getModelCustomizationUuid());
+ }
+
+ @Test
+ public void createGenericResourceApiNetworkOperationInformation_UnassignTest() throws Exception {
+
+ NetworkTopologyOperationRequestMapper mapperUnassign = mapper;
+ GenericResourceApiNetworkOperationInformation networkSDNCrequestUnassign =
+ mapperUnassign.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN,
+ GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance,
+ customer, requestContext, cloudRegion);
+
+ ObjectMapper omapperUnassign = new ObjectMapper();
+ GenericResourceApiNetworkOperationInformation reqMapperUnassign =
+ omapperUnassign.readValue(getJson("genericResourceApiNetworkOperationInformationUnAssign.json"),
+ GenericResourceApiNetworkOperationInformation.class);
+
+ assertThat(reqMapperUnassign, sameBeanAs(networkSDNCrequestUnassign).ignoring("sdncRequestHeader.svcRequestId")
+ .ignoring("requestInformation.requestId"));
+ assertEquals("MsoRequestId", networkSDNCrequestUnassign.getRequestInformation().getRequestId());
+
+ }
+
+ @Test
+ public void createGenericResourceApiNetworkOperationInformationNoNetworkNameTest() throws Exception {
+
+ // set network name NULL
+ network.setNetworkName(null);
+ GenericResourceApiNetworkOperationInformation networkSDNCrequest =
+ mapper.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,
+ GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance,
+ customer, requestContext, cloudRegion);
+
+ ObjectMapper omapper = new ObjectMapper();
+ GenericResourceApiNetworkOperationInformation reqMapper1 =
+ omapper.readValue(getJson("genericResourceApiNetworkOperationInformationNoNetworkName.json"),
+ GenericResourceApiNetworkOperationInformation.class);
+
+ assertThat(reqMapper1, sameBeanAs(networkSDNCrequest).ignoring("sdncRequestHeader.svcRequestId")
+ .ignoring("requestInformation.requestId"));
+ }
+
+ /*
+ * Helper method to load JSON data
+ */
+ private String getJson(String filename) throws IOException {
+ return new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + filename)));
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapperTest.java
index 1919ef437b..f4006ab5d5 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapperTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapperTest.java
@@ -24,12 +24,10 @@ import static com.shazam.shazamcrest.MatcherAssert.assertThat;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
-
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
@@ -42,7 +40,6 @@ import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance;
import org.onap.so.client.sdnc.beans.SDNCSvcAction;
import org.onap.so.client.sdnc.beans.SDNCSvcOperation;
-
import org.onap.sdnc.northbound.client.model.GenericResourceApiOnapmodelinformationOnapModelInformation;
import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration;
import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation;
@@ -51,54 +48,56 @@ import com.fasterxml.jackson.databind.ObjectMapper;
@RunWith(MockitoJUnitRunner.class)
public class ServiceTopologyOperationMapperTest {
- @Spy
- private GeneralTopologyObjectMapper generalTopologyObjectMapper;
-
- @InjectMocks
- private ServiceTopologyOperationMapper mapper = new ServiceTopologyOperationMapper();
+ @Spy
+ private GeneralTopologyObjectMapper generalTopologyObjectMapper;
+
+ @InjectMocks
+ private ServiceTopologyOperationMapper mapper = new ServiceTopologyOperationMapper();
- @Test
- public void reqMapperTest() throws Exception {
- // prepare and set service instance
- ServiceInstance serviceInstance = new ServiceInstance();
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setModelInvariantUuid("modelInvariantUuid");
- modelInfoServiceInstance.setModelName("modelName");
- modelInfoServiceInstance.setModelUuid("modelUuid");
- modelInfoServiceInstance.setModelVersion("modelVersion");
- serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+ @Test
+ public void reqMapperTest() throws Exception {
+ // prepare and set service instance
+ ServiceInstance serviceInstance = new ServiceInstance();
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelInvariantUuid("modelInvariantUuid");
+ modelInfoServiceInstance.setModelName("modelName");
+ modelInfoServiceInstance.setModelUuid("modelUuid");
+ modelInfoServiceInstance.setModelVersion("modelVersion");
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
- // prepare Customer object
- Customer customer = new Customer();
- customer.setGlobalCustomerId("globalCustomerId");
+ // prepare Customer object
+ Customer customer = new Customer();
+ customer.setGlobalCustomerId("globalCustomerId");
- customer.setServiceSubscription(new ServiceSubscription());
- // set Customer on service instance
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
+ customer.setServiceSubscription(new ServiceSubscription());
+ // set Customer on service instance
+ customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
- //prepare RequestContext
- RequestContext requestContext = new RequestContext();
- Map<String, Object> userParams = new HashMap<>();
- userParams.put("key1", "value1");
- requestContext.setUserParams(userParams);
- requestContext.setProductFamilyId("productFamilyId");
- requestContext.setMsoRequestId("MsoRequestId");
+ // prepare RequestContext
+ RequestContext requestContext = new RequestContext();
+ Map<String, Object> userParams = new HashMap<>();
+ userParams.put("key1", "value1");
+ requestContext.setUserParams(userParams);
+ requestContext.setProductFamilyId("productFamilyId");
+ requestContext.setMsoRequestId("MsoRequestId");
- GenericResourceApiServiceOperationInformation serviceOpInformation = mapper.reqMapper(
- SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE, serviceInstance, customer,
- requestContext);
- GenericResourceApiServiceOperationInformation serviceOpInformationNullReqContext = mapper.reqMapper(
- SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE, serviceInstance, customer,
- null);
+ GenericResourceApiServiceOperationInformation serviceOpInformation =
+ mapper.reqMapper(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,
+ GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE, serviceInstance, customer,
+ requestContext);
+ GenericResourceApiServiceOperationInformation serviceOpInformationNullReqContext = mapper.reqMapper(
+ SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,
+ GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE, serviceInstance, customer, null);
- String jsonToCompare = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/BuildingBlocks/genericResourceApiEcompModelInformation.json")));
+ String jsonToCompare = new String(Files.readAllBytes(
+ Paths.get("src/test/resources/__files/BuildingBlocks/genericResourceApiEcompModelInformation.json")));
- ObjectMapper omapper = new ObjectMapper();
- GenericResourceApiOnapmodelinformationOnapModelInformation reqMapper1 = omapper.readValue(jsonToCompare,
- GenericResourceApiOnapmodelinformationOnapModelInformation.class);
+ ObjectMapper omapper = new ObjectMapper();
+ GenericResourceApiOnapmodelinformationOnapModelInformation reqMapper1 =
+ omapper.readValue(jsonToCompare, GenericResourceApiOnapmodelinformationOnapModelInformation.class);
- assertThat(reqMapper1, sameBeanAs(serviceOpInformation.getServiceInformation().getOnapModelInformation()));
- assertEquals("MsoRequestId", serviceOpInformation.getRequestInformation().getRequestId());
- assertNotNull(serviceOpInformationNullReqContext.getRequestInformation().getRequestId());
- }
+ assertThat(reqMapper1, sameBeanAs(serviceOpInformation.getServiceInformation().getOnapModelInformation()));
+ assertEquals("MsoRequestId", serviceOpInformation.getRequestInformation().getRequestId());
+ assertNotNull(serviceOpInformationNullReqContext.getRequestInformation().getRequestId());
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java
index 7fce8c48c8..275e9f7dbb 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java
@@ -25,14 +25,12 @@ import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
-
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
@@ -55,283 +53,284 @@ import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule;
import org.onap.so.client.exception.MapperException;
import org.onap.so.client.sdnc.beans.SDNCSvcAction;
import org.onap.so.client.sdnc.beans.SDNCSvcOperation;
-
import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation;
import com.fasterxml.jackson.databind.ObjectMapper;
@RunWith(MockitoJUnitRunner.class)
public class VfModuleTopologyOperationRequestMapperTest {
- private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/";
- private final static String ERRORMESSAGE = "VF Module model info is null for testVfModuleId";
-
- @Spy
- private GeneralTopologyObjectMapper generalTopologyObjectMapper;
-
- @InjectMocks
- private VfModuleTopologyOperationRequestMapper mapper = new VfModuleTopologyOperationRequestMapper();
-
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- @Test
- public void assignGenericResourceApiVfModuleInformationTest() throws Exception {
-
- // prepare and set service instance
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
- modelInfoServiceInstance.setModelName("serviceModelName");
- modelInfoServiceInstance.setModelUuid("serviceModelUuid");
- modelInfoServiceInstance.setModelVersion("serviceModelVersion");
- serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
- // prepare Customer object
- Customer customer = new Customer();
- customer.setGlobalCustomerId("globalCustomerId");
- ServiceSubscription serviceSubscription = new ServiceSubscription();
- serviceSubscription.setServiceType("productFamilyId");
- customer.setServiceSubscription(serviceSubscription);
-
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
- //
- RequestContext requestContext = new RequestContext();
- Map<String,Object> userParams = new HashMap<>();
- userParams.put("key1", "value1");
- requestContext.setUserParams(userParams);
- requestContext.setProductFamilyId("productFamilyId");
- RequestParameters requestParameters = new RequestParameters();
- requestParameters.setUsePreload(true);
- requestContext.setRequestParameters(requestParameters);
- requestContext.setMsoRequestId("MsoRequestId");
-
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("testVnfId");
- vnf.setVnfType("testVnfType");
- vnf.setVnfName("testVnfName");
- ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
- modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
- modelInfoGenericVnf.setModelName("vnfModelName");
- modelInfoGenericVnf.setModelVersion("vnfModelVersion");
- modelInfoGenericVnf.setModelUuid("vnfModelUuid");
- modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
- vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
-
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("testVfModuleId");
- vfModule.setVfModuleName("testVfModuleName");
- ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
- modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
- modelInfoVfModule.setModelName("vfModuleModelName");
- modelInfoVfModule.setModelVersion("vfModuleModelVersion");
- modelInfoVfModule.setModelUUID("vfModuleModelUuid");
- modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
- vfModule.setModelInfoVfModule(modelInfoVfModule);
- HashMap<String, String> cloudParams = new HashMap<String, String>();
- cloudParams.put("key2", "value2");
- vfModule.setCloudParams(cloudParams);
-
- VolumeGroup volumeGroup = new VolumeGroup();
- volumeGroup.setVolumeGroupId("volumeGroupId");
- volumeGroup.setVolumeGroupName("volumeGroupName");
-
- CloudRegion cloudRegion = new CloudRegion();
-
- GenericResourceApiVfModuleOperationInformation vfModuleSDNCrequest = mapper.reqMapper(
- SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, vfModule, volumeGroup, vnf, serviceInstance, customer,
- cloudRegion, requestContext, null);
-
- String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleOperationInformationAssign.json")));
-
- ObjectMapper omapper = new ObjectMapper();
- GenericResourceApiVfModuleOperationInformation reqMapper1 = omapper.readValue(
- jsonToCompare,
- GenericResourceApiVfModuleOperationInformation.class);
-
- assertThat(reqMapper1, sameBeanAs(vfModuleSDNCrequest).ignoring("sdncRequestHeader.svcRequestId")
- .ignoring("requestInformation.requestId"));
- assertEquals("MsoRequestId", vfModuleSDNCrequest.getRequestInformation().getRequestId());
- }
-
- @Test
- public void unassignGenericResourceApiVfModuleInformationTest() throws Exception {
-
- // prepare and set service instance
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
-
- // prepare and set vnf instance
-
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("testVnfId");
- vnf.setVnfType("testVnfType");
-
- // prepare and set vf module instance
-
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("testVfModuleId");
- vfModule.setVfModuleName("testVfModuleName");
-
- RequestContext requestContext = new RequestContext();
- requestContext.setMsoRequestId("MsoRequestId");
-
- GenericResourceApiVfModuleOperationInformation vfModuleSDNCrequest = mapper.reqMapper(
- SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN, vfModule, null, vnf, serviceInstance, null,
- null, requestContext, null);
-
- String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleOperationInformationUnassign.json")));
-
- ObjectMapper omapper = new ObjectMapper();
- GenericResourceApiVfModuleOperationInformation reqMapper1 = omapper.readValue(
- jsonToCompare,
- GenericResourceApiVfModuleOperationInformation.class);
-
- assertThat(reqMapper1, sameBeanAs(vfModuleSDNCrequest).ignoring("sdncRequestHeader.svcRequestId")
- .ignoring("requestInformation.requestId"));
- assertEquals("MsoRequestId", vfModuleSDNCrequest.getRequestInformation().getRequestId());
- }
-
- @Test
- public void unassignGenericResourceApiVfModuleInformationNullMsoReqIdTest() throws Exception {
-
- // prepare and set service instance
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
-
- // prepare and set vnf instance
-
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("testVnfId");
- vnf.setVnfType("testVnfType");
-
- // prepare and set vf module instance
-
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("testVfModuleId");
- vfModule.setVfModuleName("testVfModuleName");
-
- RequestContext requestContext = new RequestContext();
-
- GenericResourceApiVfModuleOperationInformation vfModuleSDNCrequest = mapper.reqMapper(
- SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN, vfModule, null, vnf, serviceInstance, null,
- null, requestContext, null);
-
- assertNotNull(vfModuleSDNCrequest.getRequestInformation().getRequestId());
- }
-
- @Test
- public void reqMapperTest() throws Exception {
-
- // prepare and set service instance
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
- modelInfoServiceInstance.setModelName("serviceModelName");
- modelInfoServiceInstance.setModelUuid("serviceModelUuid");
- modelInfoServiceInstance.setModelVersion("serviceModelVersion");
-
- serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
- // prepare Customer object
- Customer customer = new Customer();
- customer.setGlobalCustomerId("globalCustomerId");
- customer.setServiceSubscription(new ServiceSubscription());
- // set Customer on service instance
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
- //
- RequestContext requestContext = new RequestContext();
- RequestParameters requestParameters = new RequestParameters();
- HashMap<String,Object> userParams1 = new HashMap<>();
- userParams1.put("key1", "value1");
- List<Map<String,Object>> userParams = new ArrayList<>();
- userParams.add(userParams1);
-
- requestParameters.setUserParams(userParams);
- requestContext.setRequestParameters(requestParameters);
- requestContext.setProductFamilyId("productFamilyId");
-
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("testVnfId");
- vnf.setVnfType("testVnfType");
- ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
- modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
- modelInfoGenericVnf.setModelName("vnfModelName");
- modelInfoGenericVnf.setModelVersion("vnfModelVersion");
- modelInfoGenericVnf.setModelUuid("vnfModelUuid");
- modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
- vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
-
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("testVfModuleId");
- vfModule.setVfModuleName("testVfModuleName");
- ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
- modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
- modelInfoVfModule.setModelName("vfModuleModelName");
- modelInfoVfModule.setModelVersion("vfModuleModelVersion");
- modelInfoVfModule.setModelUUID("vfModuleModelUuid");
- modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
- vfModule.setModelInfoVfModule(modelInfoVfModule);
-
- CloudRegion cloudRegion = new CloudRegion();
-
- GenericResourceApiVfModuleOperationInformation vfModuleSDNCrequest = mapper.reqMapper(
- SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, vfModule, null, vnf, serviceInstance, customer,
- cloudRegion, requestContext, null);
-
- assertNull(vfModuleSDNCrequest.getServiceInformation().getOnapModelInformation().getModelCustomizationUuid());
- assertEquals("vnfModelCustomizationUuid", vfModuleSDNCrequest.getVnfInformation().getOnapModelInformation().getModelCustomizationUuid());
- assertEquals("vfModuleModelCustomizationUuid", vfModuleSDNCrequest.getVfModuleInformation().getOnapModelInformation().getModelCustomizationUuid());
- }
-
- @Test
- public void reqMapperNoModelInfoTest() throws Exception {
-
- // prepare and set service instance
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
- modelInfoServiceInstance.setModelName("serviceModelName");
- modelInfoServiceInstance.setModelUuid("serviceModelUuid");
- modelInfoServiceInstance.setModelVersion("serviceModelVersion");
-
- serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
- // prepare Customer object
- Customer customer = new Customer();
- customer.setGlobalCustomerId("globalCustomerId");
- customer.setServiceSubscription(new ServiceSubscription());
- // set Customer on service instance
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
- //
- RequestContext requestContext = new RequestContext();
- Map<String, Object> userParams = new HashMap<String, Object>();
- userParams.put("key1", "value1");
- requestContext.setUserParams(userParams);
- requestContext.setProductFamilyId("productFamilyId");
-
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("testVnfId");
- vnf.setVnfType("testVnfType");
- ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
- modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
- modelInfoGenericVnf.setModelName("vnfModelName");
- modelInfoGenericVnf.setModelVersion("vnfModelVersion");
- modelInfoGenericVnf.setModelUuid("vnfModelUuid");
- modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
- vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
-
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("testVfModuleId");
- vfModule.setVfModuleName("testVfModuleName");
- vfModule.setModelInfoVfModule(null);
-
- CloudRegion cloudRegion = new CloudRegion();
-
- expectedException.expect(MapperException.class);
- expectedException.expectMessage(ERRORMESSAGE);
-
- mapper.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, vfModule, null, vnf, serviceInstance, customer,
- cloudRegion, requestContext, null);
- }
+ private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/";
+ private final static String ERRORMESSAGE = "VF Module model info is null for testVfModuleId";
+
+ @Spy
+ private GeneralTopologyObjectMapper generalTopologyObjectMapper;
+
+ @InjectMocks
+ private VfModuleTopologyOperationRequestMapper mapper = new VfModuleTopologyOperationRequestMapper();
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ @Test
+ public void assignGenericResourceApiVfModuleInformationTest() throws Exception {
+
+ // prepare and set service instance
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
+ modelInfoServiceInstance.setModelName("serviceModelName");
+ modelInfoServiceInstance.setModelUuid("serviceModelUuid");
+ modelInfoServiceInstance.setModelVersion("serviceModelVersion");
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+ // prepare Customer object
+ Customer customer = new Customer();
+ customer.setGlobalCustomerId("globalCustomerId");
+ ServiceSubscription serviceSubscription = new ServiceSubscription();
+ serviceSubscription.setServiceType("productFamilyId");
+ customer.setServiceSubscription(serviceSubscription);
+
+ customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
+ //
+ RequestContext requestContext = new RequestContext();
+ Map<String, Object> userParams = new HashMap<>();
+ userParams.put("key1", "value1");
+ requestContext.setUserParams(userParams);
+ requestContext.setProductFamilyId("productFamilyId");
+ RequestParameters requestParameters = new RequestParameters();
+ requestParameters.setUsePreload(true);
+ requestContext.setRequestParameters(requestParameters);
+ requestContext.setMsoRequestId("MsoRequestId");
+
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("testVnfId");
+ vnf.setVnfType("testVnfType");
+ vnf.setVnfName("testVnfName");
+ ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
+ modelInfoGenericVnf.setModelName("vnfModelName");
+ modelInfoGenericVnf.setModelVersion("vnfModelVersion");
+ modelInfoGenericVnf.setModelUuid("vnfModelUuid");
+ modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
+ vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
+
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("testVfModuleId");
+ vfModule.setVfModuleName("testVfModuleName");
+ ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
+ modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
+ modelInfoVfModule.setModelName("vfModuleModelName");
+ modelInfoVfModule.setModelVersion("vfModuleModelVersion");
+ modelInfoVfModule.setModelUUID("vfModuleModelUuid");
+ modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
+ vfModule.setModelInfoVfModule(modelInfoVfModule);
+ HashMap<String, String> cloudParams = new HashMap<String, String>();
+ cloudParams.put("key2", "value2");
+ vfModule.setCloudParams(cloudParams);
+
+ VolumeGroup volumeGroup = new VolumeGroup();
+ volumeGroup.setVolumeGroupId("volumeGroupId");
+ volumeGroup.setVolumeGroupName("volumeGroupName");
+
+ CloudRegion cloudRegion = new CloudRegion();
+
+ GenericResourceApiVfModuleOperationInformation vfModuleSDNCrequest =
+ mapper.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, vfModule,
+ volumeGroup, vnf, serviceInstance, customer, cloudRegion, requestContext, null);
+
+ String jsonToCompare = new String(Files.readAllBytes(
+ Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleOperationInformationAssign.json")));
+
+ ObjectMapper omapper = new ObjectMapper();
+ GenericResourceApiVfModuleOperationInformation reqMapper1 =
+ omapper.readValue(jsonToCompare, GenericResourceApiVfModuleOperationInformation.class);
+
+ assertThat(reqMapper1, sameBeanAs(vfModuleSDNCrequest).ignoring("sdncRequestHeader.svcRequestId")
+ .ignoring("requestInformation.requestId"));
+ assertEquals("MsoRequestId", vfModuleSDNCrequest.getRequestInformation().getRequestId());
+ }
+
+ @Test
+ public void unassignGenericResourceApiVfModuleInformationTest() throws Exception {
+
+ // prepare and set service instance
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+
+ // prepare and set vnf instance
+
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("testVnfId");
+ vnf.setVnfType("testVnfType");
+
+ // prepare and set vf module instance
+
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("testVfModuleId");
+ vfModule.setVfModuleName("testVfModuleName");
+
+ RequestContext requestContext = new RequestContext();
+ requestContext.setMsoRequestId("MsoRequestId");
+
+ GenericResourceApiVfModuleOperationInformation vfModuleSDNCrequest =
+ mapper.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN, vfModule, null,
+ vnf, serviceInstance, null, null, requestContext, null);
+
+ String jsonToCompare = new String(Files.readAllBytes(
+ Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleOperationInformationUnassign.json")));
+
+ ObjectMapper omapper = new ObjectMapper();
+ GenericResourceApiVfModuleOperationInformation reqMapper1 =
+ omapper.readValue(jsonToCompare, GenericResourceApiVfModuleOperationInformation.class);
+
+ assertThat(reqMapper1, sameBeanAs(vfModuleSDNCrequest).ignoring("sdncRequestHeader.svcRequestId")
+ .ignoring("requestInformation.requestId"));
+ assertEquals("MsoRequestId", vfModuleSDNCrequest.getRequestInformation().getRequestId());
+ }
+
+ @Test
+ public void unassignGenericResourceApiVfModuleInformationNullMsoReqIdTest() throws Exception {
+
+ // prepare and set service instance
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+
+ // prepare and set vnf instance
+
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("testVnfId");
+ vnf.setVnfType("testVnfType");
+
+ // prepare and set vf module instance
+
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("testVfModuleId");
+ vfModule.setVfModuleName("testVfModuleName");
+
+ RequestContext requestContext = new RequestContext();
+
+ GenericResourceApiVfModuleOperationInformation vfModuleSDNCrequest =
+ mapper.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN, vfModule, null,
+ vnf, serviceInstance, null, null, requestContext, null);
+
+ assertNotNull(vfModuleSDNCrequest.getRequestInformation().getRequestId());
+ }
+
+ @Test
+ public void reqMapperTest() throws Exception {
+
+ // prepare and set service instance
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
+ modelInfoServiceInstance.setModelName("serviceModelName");
+ modelInfoServiceInstance.setModelUuid("serviceModelUuid");
+ modelInfoServiceInstance.setModelVersion("serviceModelVersion");
+
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+ // prepare Customer object
+ Customer customer = new Customer();
+ customer.setGlobalCustomerId("globalCustomerId");
+ customer.setServiceSubscription(new ServiceSubscription());
+ // set Customer on service instance
+ customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
+ //
+ RequestContext requestContext = new RequestContext();
+ RequestParameters requestParameters = new RequestParameters();
+ HashMap<String, Object> userParams1 = new HashMap<>();
+ userParams1.put("key1", "value1");
+ List<Map<String, Object>> userParams = new ArrayList<>();
+ userParams.add(userParams1);
+
+ requestParameters.setUserParams(userParams);
+ requestContext.setRequestParameters(requestParameters);
+ requestContext.setProductFamilyId("productFamilyId");
+
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("testVnfId");
+ vnf.setVnfType("testVnfType");
+ ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
+ modelInfoGenericVnf.setModelName("vnfModelName");
+ modelInfoGenericVnf.setModelVersion("vnfModelVersion");
+ modelInfoGenericVnf.setModelUuid("vnfModelUuid");
+ modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
+ vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
+
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("testVfModuleId");
+ vfModule.setVfModuleName("testVfModuleName");
+ ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
+ modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
+ modelInfoVfModule.setModelName("vfModuleModelName");
+ modelInfoVfModule.setModelVersion("vfModuleModelVersion");
+ modelInfoVfModule.setModelUUID("vfModuleModelUuid");
+ modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
+ vfModule.setModelInfoVfModule(modelInfoVfModule);
+
+ CloudRegion cloudRegion = new CloudRegion();
+
+ GenericResourceApiVfModuleOperationInformation vfModuleSDNCrequest =
+ mapper.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, vfModule, null,
+ vnf, serviceInstance, customer, cloudRegion, requestContext, null);
+
+ assertNull(vfModuleSDNCrequest.getServiceInformation().getOnapModelInformation().getModelCustomizationUuid());
+ assertEquals("vnfModelCustomizationUuid",
+ vfModuleSDNCrequest.getVnfInformation().getOnapModelInformation().getModelCustomizationUuid());
+ assertEquals("vfModuleModelCustomizationUuid",
+ vfModuleSDNCrequest.getVfModuleInformation().getOnapModelInformation().getModelCustomizationUuid());
+ }
+
+ @Test
+ public void reqMapperNoModelInfoTest() throws Exception {
+
+ // prepare and set service instance
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
+ modelInfoServiceInstance.setModelName("serviceModelName");
+ modelInfoServiceInstance.setModelUuid("serviceModelUuid");
+ modelInfoServiceInstance.setModelVersion("serviceModelVersion");
+
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+ // prepare Customer object
+ Customer customer = new Customer();
+ customer.setGlobalCustomerId("globalCustomerId");
+ customer.setServiceSubscription(new ServiceSubscription());
+ // set Customer on service instance
+ customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
+ //
+ RequestContext requestContext = new RequestContext();
+ Map<String, Object> userParams = new HashMap<String, Object>();
+ userParams.put("key1", "value1");
+ requestContext.setUserParams(userParams);
+ requestContext.setProductFamilyId("productFamilyId");
+
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("testVnfId");
+ vnf.setVnfType("testVnfType");
+ ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
+ modelInfoGenericVnf.setModelName("vnfModelName");
+ modelInfoGenericVnf.setModelVersion("vnfModelVersion");
+ modelInfoGenericVnf.setModelUuid("vnfModelUuid");
+ modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
+ vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
+
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("testVfModuleId");
+ vfModule.setVfModuleName("testVfModuleName");
+ vfModule.setModelInfoVfModule(null);
+
+ CloudRegion cloudRegion = new CloudRegion();
+
+ expectedException.expect(MapperException.class);
+ expectedException.expectMessage(ERRORMESSAGE);
+
+ mapper.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, vfModule, null, vnf,
+ serviceInstance, customer, cloudRegion, requestContext, null);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java
index 64b532fd07..cecf34ea10 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java
@@ -23,12 +23,10 @@ package org.onap.so.client.sdnc.mapper;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
-
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
-
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
@@ -47,101 +45,107 @@ import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance;
import org.onap.so.client.sdnc.beans.SDNCSvcAction;
import org.onap.so.client.sdnc.beans.SDNCSvcOperation;
-
import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration;
import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation;
@RunWith(MockitoJUnitRunner.class)
public class VnfTopologyOperationRequestMapperTest {
- @Spy
- private GeneralTopologyObjectMapper generalTopologyObjectMapper;
-
- @InjectMocks
- private VnfTopologyOperationRequestMapper mapper = new VnfTopologyOperationRequestMapper();
-
- @Test
- public void reqMapperTest() throws Exception {
- // prepare and set service instance
- ServiceInstance serviceInstance = new ServiceInstance();
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setModelInvariantUuid("modelInvariantUuid");
- modelInfoServiceInstance.setModelName("modelName");
- modelInfoServiceInstance.setModelUuid("modelUuid");
- modelInfoServiceInstance.setModelVersion("modelVersion");
- serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
-
- //prepare VNF
- ModelInfoGenericVnf genericVnf = new ModelInfoGenericVnf();
- genericVnf.setModelInvariantUuid("vnfModelInvariantUUID");
- genericVnf.setModelVersion("vnfModelVersion");
- genericVnf.setModelName("vnfModelName");
- genericVnf.setModelUuid("vnfModelUUID");
- genericVnf.setModelCustomizationUuid("vnfModelCustomizationUUID");
-
- ModelInfoInstanceGroup modelL3Network = new ModelInfoInstanceGroup();
- modelL3Network.setType("L3-NETWORK");
-
- InstanceGroup instanceGroup1 = new InstanceGroup();
- instanceGroup1.setId("l3-network-ig-111");
- instanceGroup1.setModelInfoInstanceGroup(modelL3Network);
-
- InstanceGroup instanceGroup2 = new InstanceGroup();
- instanceGroup2.setId("l3-network-ig-222");
- instanceGroup2.setModelInfoInstanceGroup(modelL3Network);
-
- GenericVnf vnf = new GenericVnf();
- vnf.setModelInfoGenericVnf(genericVnf);
- vnf.setVnfId("vnfId");
- vnf.setVnfType("vnfType");
- vnf.getInstanceGroups().add(instanceGroup1);
- vnf.getInstanceGroups().add(instanceGroup2);
- License license = new License();
- List<String> entitlementPoolUuids = new ArrayList<>();
- entitlementPoolUuids.add("entitlementPoolUuid");
- List<String> licenseKeyGroupUuids = new ArrayList<>();
- licenseKeyGroupUuids.add("licenseKeyGroupUuid");
- license.setEntitlementPoolUuids(entitlementPoolUuids);
- license.setLicenseKeyGroupUuids(licenseKeyGroupUuids);
- vnf.setLicense(license);
-
- // prepare Customer object
- Customer customer = new Customer();
- customer.setGlobalCustomerId("globalCustomerId");
-
- ServiceSubscription serviceSubscription = new ServiceSubscription();
- serviceSubscription.setServiceType("productFamilyId");
- customer.setServiceSubscription(serviceSubscription);
-
- // set Customer on service instance
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
-
-
- //prepare RequestContext
- RequestContext requestContext = new RequestContext();
- Map<String, Object> userParams = new HashMap<>();
- userParams.put("key1", "value1");
- requestContext.setUserParams(userParams);
- requestContext.setProductFamilyId("productFamilyId");
- requestContext.setMsoRequestId("MsoRequestId");
-
- CloudRegion cloudRegion = new CloudRegion();
-
- GenericResourceApiVnfOperationInformation vnfOpInformation = mapper.reqMapper(
- SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer,
- cloudRegion, requestContext,true);
- GenericResourceApiVnfOperationInformation vnfOpInformationNullReqContext = mapper.reqMapper(
- SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer,
- cloudRegion, null,true);
-
- assertNull(vnfOpInformation.getServiceInformation().getOnapModelInformation().getModelCustomizationUuid());
- assertEquals("vnfModelCustomizationUUID", vnfOpInformation.getVnfInformation().getOnapModelInformation().getModelCustomizationUuid());
- assertEquals(2, vnfOpInformation.getVnfRequestInput().getVnfNetworkInstanceGroupIds().size());
- assertEquals("l3-network-ig-111", vnfOpInformation.getVnfRequestInput().getVnfNetworkInstanceGroupIds().get(0).getVnfNetworkInstanceGroupId());
- assertEquals("l3-network-ig-222", vnfOpInformation.getVnfRequestInput().getVnfNetworkInstanceGroupIds().get(1).getVnfNetworkInstanceGroupId());
- assertEquals("entitlementPoolUuid", vnfOpInformation.getVnfRequestInput().getVnfInputParameters().getParam().get(1).getValue());
- assertEquals("licenseKeyGroupUuid", vnfOpInformation.getVnfRequestInput().getVnfInputParameters().getParam().get(2).getValue());
- assertEquals("MsoRequestId", vnfOpInformation.getRequestInformation().getRequestId());
- assertNotNull(vnfOpInformationNullReqContext.getRequestInformation().getRequestId());
- }
+ @Spy
+ private GeneralTopologyObjectMapper generalTopologyObjectMapper;
+
+ @InjectMocks
+ private VnfTopologyOperationRequestMapper mapper = new VnfTopologyOperationRequestMapper();
+
+ @Test
+ public void reqMapperTest() throws Exception {
+ // prepare and set service instance
+ ServiceInstance serviceInstance = new ServiceInstance();
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelInvariantUuid("modelInvariantUuid");
+ modelInfoServiceInstance.setModelName("modelName");
+ modelInfoServiceInstance.setModelUuid("modelUuid");
+ modelInfoServiceInstance.setModelVersion("modelVersion");
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+
+ // prepare VNF
+ ModelInfoGenericVnf genericVnf = new ModelInfoGenericVnf();
+ genericVnf.setModelInvariantUuid("vnfModelInvariantUUID");
+ genericVnf.setModelVersion("vnfModelVersion");
+ genericVnf.setModelName("vnfModelName");
+ genericVnf.setModelUuid("vnfModelUUID");
+ genericVnf.setModelCustomizationUuid("vnfModelCustomizationUUID");
+
+ ModelInfoInstanceGroup modelL3Network = new ModelInfoInstanceGroup();
+ modelL3Network.setType("L3-NETWORK");
+
+ InstanceGroup instanceGroup1 = new InstanceGroup();
+ instanceGroup1.setId("l3-network-ig-111");
+ instanceGroup1.setModelInfoInstanceGroup(modelL3Network);
+
+ InstanceGroup instanceGroup2 = new InstanceGroup();
+ instanceGroup2.setId("l3-network-ig-222");
+ instanceGroup2.setModelInfoInstanceGroup(modelL3Network);
+
+ GenericVnf vnf = new GenericVnf();
+ vnf.setModelInfoGenericVnf(genericVnf);
+ vnf.setVnfId("vnfId");
+ vnf.setVnfType("vnfType");
+ vnf.getInstanceGroups().add(instanceGroup1);
+ vnf.getInstanceGroups().add(instanceGroup2);
+ License license = new License();
+ List<String> entitlementPoolUuids = new ArrayList<>();
+ entitlementPoolUuids.add("entitlementPoolUuid");
+ List<String> licenseKeyGroupUuids = new ArrayList<>();
+ licenseKeyGroupUuids.add("licenseKeyGroupUuid");
+ license.setEntitlementPoolUuids(entitlementPoolUuids);
+ license.setLicenseKeyGroupUuids(licenseKeyGroupUuids);
+ vnf.setLicense(license);
+
+ // prepare Customer object
+ Customer customer = new Customer();
+ customer.setGlobalCustomerId("globalCustomerId");
+
+ ServiceSubscription serviceSubscription = new ServiceSubscription();
+ serviceSubscription.setServiceType("productFamilyId");
+ customer.setServiceSubscription(serviceSubscription);
+
+ // set Customer on service instance
+ customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
+
+
+ // prepare RequestContext
+ RequestContext requestContext = new RequestContext();
+ Map<String, Object> userParams = new HashMap<>();
+ userParams.put("key1", "value1");
+ requestContext.setUserParams(userParams);
+ requestContext.setProductFamilyId("productFamilyId");
+ requestContext.setMsoRequestId("MsoRequestId");
+
+ CloudRegion cloudRegion = new CloudRegion();
+
+ GenericResourceApiVnfOperationInformation vnfOpInformation =
+ mapper.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,
+ GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer,
+ cloudRegion, requestContext, true);
+ GenericResourceApiVnfOperationInformation vnfOpInformationNullReqContext =
+ mapper.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,
+ GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer,
+ cloudRegion, null, true);
+
+ assertNull(vnfOpInformation.getServiceInformation().getOnapModelInformation().getModelCustomizationUuid());
+ assertEquals("vnfModelCustomizationUUID",
+ vnfOpInformation.getVnfInformation().getOnapModelInformation().getModelCustomizationUuid());
+ assertEquals(2, vnfOpInformation.getVnfRequestInput().getVnfNetworkInstanceGroupIds().size());
+ assertEquals("l3-network-ig-111", vnfOpInformation.getVnfRequestInput().getVnfNetworkInstanceGroupIds().get(0)
+ .getVnfNetworkInstanceGroupId());
+ assertEquals("l3-network-ig-222", vnfOpInformation.getVnfRequestInput().getVnfNetworkInstanceGroupIds().get(1)
+ .getVnfNetworkInstanceGroupId());
+ assertEquals("entitlementPoolUuid",
+ vnfOpInformation.getVnfRequestInput().getVnfInputParameters().getParam().get(1).getValue());
+ assertEquals("licenseKeyGroupUuid",
+ vnfOpInformation.getVnfRequestInput().getVnfInputParameters().getParam().get(2).getValue());
+ assertEquals("MsoRequestId", vnfOpInformation.getRequestInformation().getRequestId());
+ assertNotNull(vnfOpInformationNullReqContext.getRequestInformation().getRequestId());
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sniro/SniroClientTestIT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sniro/SniroClientTestIT.java
index 722180f54b..56c52388f8 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sniro/SniroClientTestIT.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sniro/SniroClientTestIT.java
@@ -23,14 +23,12 @@ package org.onap.so.client.sniro;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
-
import org.junit.Test;
import org.onap.so.BaseIntegrationTest;
import org.onap.so.client.exception.BadResponseException;
import org.onap.so.client.sniro.beans.SniroConductorRequest;
import org.onap.so.client.sniro.beans.SniroManagerRequest;
import org.springframework.beans.factory.annotation.Autowired;
-
import com.fasterxml.jackson.core.JsonProcessingException;
@@ -42,108 +40,96 @@ public class SniroClientTestIT extends BaseIntegrationTest {
@Test(expected = Test.None.class)
public void testPostDemands_success() throws BadResponseException, JsonProcessingException {
- String mockResponse = "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"corys cool\", \"requestStatus\": \"accepted\"}";
+ String mockResponse =
+ "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"corys cool\", \"requestStatus\": \"accepted\"}";
- wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2"))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBody(mockResponse)));
+ wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
- client.postDemands(new SniroManagerRequest());
+ client.postDemands(new SniroManagerRequest());
}
@Test(expected = BadResponseException.class)
public void testPostDemands_error_failed() throws JsonProcessingException, BadResponseException {
- String mockResponse = "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"missing data\", \"requestStatus\": \"failed\"}";
+ String mockResponse =
+ "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"missing data\", \"requestStatus\": \"failed\"}";
- wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2"))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBody(mockResponse)));
+ wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
- client.postDemands(new SniroManagerRequest());
+ client.postDemands(new SniroManagerRequest());
- //TODO assertEquals("missing data", );
+ // TODO assertEquals("missing data", );
}
@Test(expected = BadResponseException.class)
public void testPostDemands_error_noMessage() throws JsonProcessingException, BadResponseException {
- String mockResponse = "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"\", \"requestStatus\": \"failed\"}";
+ String mockResponse =
+ "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"\", \"requestStatus\": \"failed\"}";
- wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2"))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBody(mockResponse)));
+ wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
- client.postDemands(new SniroManagerRequest());
+ client.postDemands(new SniroManagerRequest());
}
@Test(expected = BadResponseException.class)
public void testPostDemands_error_noStatus() throws JsonProcessingException, BadResponseException {
- String mockResponse = "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"missing data\", \"requestStatus\": null}";
+ String mockResponse =
+ "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"missing data\", \"requestStatus\": null}";
- wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2"))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBody(mockResponse)));
+ wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
- client.postDemands(new SniroManagerRequest());
+ client.postDemands(new SniroManagerRequest());
}
@Test(expected = BadResponseException.class)
public void testPostDemands_error_empty() throws JsonProcessingException, BadResponseException {
- String mockResponse = "{ }";
+ String mockResponse = "{ }";
- wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2"))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBody(mockResponse)));
+ wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
- client.postDemands(new SniroManagerRequest());
+ client.postDemands(new SniroManagerRequest());
}
@Test(expected = Test.None.class)
public void testPostRelease_success() throws BadResponseException, JsonProcessingException {
String mockResponse = "{\"status\": \"success\", \"message\": \"corys cool\"}";
- wireMockServer.stubFor(post(urlEqualTo("/v1/release-orders"))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBody(mockResponse)));
+ wireMockServer.stubFor(post(urlEqualTo("/v1/release-orders")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
- client.postRelease(new SniroConductorRequest());
+ client.postRelease(new SniroConductorRequest());
}
@Test(expected = BadResponseException.class)
public void testPostRelease_error_failed() throws BadResponseException, JsonProcessingException {
String mockResponse = "{\"status\": \"failure\", \"message\": \"corys cool\"}";
- wireMockServer.stubFor(post(urlEqualTo("/v1/release-orders"))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBody(mockResponse)));
+ wireMockServer.stubFor(post(urlEqualTo("/v1/release-orders")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
- client.postRelease(new SniroConductorRequest());
+ client.postRelease(new SniroConductorRequest());
}
@Test(expected = BadResponseException.class)
public void testPostRelease_error_noStatus() throws BadResponseException, JsonProcessingException {
String mockResponse = "{\"status\": \"\", \"message\": \"corys cool\"}";
- wireMockServer.stubFor(post(urlEqualTo("/v1/release-orders"))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBody(mockResponse)));
+ wireMockServer.stubFor(post(urlEqualTo("/v1/release-orders")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
- client.postRelease(new SniroConductorRequest());
+ client.postRelease(new SniroConductorRequest());
}
@@ -151,12 +137,10 @@ public class SniroClientTestIT extends BaseIntegrationTest {
public void testPostRelease_error_noMessage() throws BadResponseException, JsonProcessingException {
String mockResponse = "{\"status\": \"failure\", \"message\": null}";
- wireMockServer.stubFor(post(urlEqualTo("/v1/release-orders"))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBody(mockResponse)));
+ wireMockServer.stubFor(post(urlEqualTo("/v1/release-orders")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
- client.postRelease(new SniroConductorRequest());
+ client.postRelease(new SniroConductorRequest());
}
@@ -164,12 +148,10 @@ public class SniroClientTestIT extends BaseIntegrationTest {
public void testPostRelease_error_empty() throws BadResponseException, JsonProcessingException {
String mockResponse = "{ }";
- wireMockServer.stubFor(post(urlEqualTo("/v1/release-orders"))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBody(mockResponse)));
+ wireMockServer.stubFor(post(urlEqualTo("/v1/release-orders")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
- client.postRelease(new SniroConductorRequest());
+ client.postRelease(new SniroConductorRequest());
}