summaryrefslogtreecommitdiffstats
path: root/vid-app-common/src
diff options
context:
space:
mode:
Diffstat (limited to 'vid-app-common/src')
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java44
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/AaiClientInterface.java29
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/KeyValueModel.java (renamed from vid-app-common/src/main/java/org/onap/vid/job/command/BaseInstantiationCommand.java)32
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/RelatedToProperty.java59
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/Relationship.java8
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/RelationshipData.java32
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/ModelVersions.kt3
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/util/AAITreeConverter.java95
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/util/AAITreeNodeUtils.java49
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/local/LocalAsdcClient.java19
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/parser/ToscaParserImpl2.java101
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/parser/VidNotionsBuilder.java142
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/changeManagement/CloudConfiguration.java20
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/AaiController.java15
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/AaiServiceInstanceStandardQueryController.java120
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/AsyncInstantiationController.java69
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/MsoController.java35
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/WebConfig.java20
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/dal/AsyncInstantiationRepository.kt147
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/dao/JobRequest.java111
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/exceptions/AbortingException.java28
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/exceptions/AccessDeniedException.java (renamed from vid-app-common/src/main/java/org/onap/vid/job/command/ResourceInProgressStatusCommand.java)35
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/exceptions/TryAgainException.java28
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/Job.java13
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/JobAdapter.java8
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/JobCommand.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/JobException.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/JobType.java28
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/JobsBrokerService.java5
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/NextCommand.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/ALaCarteServiceCommand.kt96
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/AggregateStateCommand.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/BaseInProgressStatusCommand.java115
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/BaseRootCommand.java61
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/BaseWatchingCommand.java90
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/CommandBase.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/CommandParentData.java37
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/CommandUtils.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/ExpiryChecker.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/HttpCallCommand.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/InProgressStatusService.java21
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/InstanceGroupCommand.kt34
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/InstanceGroupInstantiationCommand.java67
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/InstanceGroupMemberCommand.kt63
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/JobCommandFactory.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/MacroServiceCommand.kt98
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/MsoRequestBuilder.kt411
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/MsoResultHandlerService.kt27
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/NetworkCommand.kt65
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/NetworkInstantiationCommand.java61
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/NoOpCommand.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/ResourceCommand.kt172
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/ResourceInstantiationCommand.java107
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/ResourceWithChildrenInProgressCommand.java85
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/RootServiceCommand.kt98
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/ServiceInProgressStatusCommand.java120
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/ServiceInstantiationCommand.java126
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/VfmoduleCommand.kt106
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/VfmoduleInstantiationCommand.java64
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/VnfCommand.kt140
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/VnfInProgressStatusCommand.java107
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/VnfInstantiationCommand.java70
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/VolumeGroupCommand.kt94
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/VolumeGroupInProgressStatusCommand.java85
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/VolumeGroupInstantiationCommand.java103
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/WatchChildrenJobsBL.kt6
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/WatchingCommand.java53
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/WatchingCommandBaseModule.java113
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/impl/DeleteOldJobsSchedulerInitializer.java96
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/impl/DeleteOldJobsWorker.java (renamed from vid-app-common/src/main/java/org/onap/vid/job/command/MacroServiceInstantiationCommand.java)41
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/impl/JobAdapterImpl.java25
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/impl/JobDaoImpl.java28
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/impl/JobData.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/impl/JobSchedulerInitializer.java27
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/impl/JobSharedData.java18
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/impl/JobWorker.java31
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/impl/JobsBrokerServiceInDatabaseImpl.java144
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/Action.java8
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/JobAuditStatus.java100
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/ModelUtil.java7
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/ResourceInfo.java144
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/ServiceInfo.java161
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/ServiceModel.java75
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/VersionAndFeatures.kt12
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/VidNotions.kt25
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/aaiTree/AAITreeNode.java50
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/aaiTree/AbstractNode.java8
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/aaiTree/CollectionResource.kt15
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/aaiTree/InstanceGroup.kt23
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/aaiTree/NCF.kt12
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Network.java116
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Node.java33
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/aaiTree/NodeType.java82
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/aaiTree/RelatedVnf.java34
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/aaiTree/ServiceInstance.java35
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/aaiTree/VfModule.java9
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Vnf.java18
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/aaiTree/VnfGroup.java72
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/aaiTree/VnfGroup.kt10
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/aaiTree/VpnBinding.kt50
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Vrf.java65
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/errorReport/ReportCreationParameters.java1
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/BaseResource.java86
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/InstanceGroup.java34
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/InstanceGroupMember.java54
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/Network.java42
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/ServiceInstantiation.java62
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/VfModule.java49
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/Vnf.java52
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/VrfEntry.kt6
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java11
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java149
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoUtil.java33
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/model/AddOrRemoveInstanceGroupMemberRequestDetails.java51
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/model/BaseResourceInstantiationRequestDetails.java35
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/model/CloudConfiguration.java192
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/model/CloudConfiguration.kt12
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/model/ServiceInstantiationPre1806RequestDetails.java51
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/model/ServiceInstantiationRequestDetails.java8
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/model/VfModuleInstantiationRequestDetails.java16
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/rest/AsyncRequestStatus.java5
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestStatus.java8
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/properties/Features.java23
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/properties/VidProperties.java93
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/AAIServiceTree.java124
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/AAITreeNodeBuilder.java341
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/AaiService.java2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java47
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogic.java66
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogicImpl.java711
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/AuditService.java24
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/AuditServiceImpl.java189
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/CloudOwnerService.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/RoleGenaratorServiceImpl.java2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/VersionService.kt66
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/utils/KotlinUtils.kt2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/utils/Tree.kt12
-rw-r--r--vid-app-common/src/main/resources/1712_ADIOD.zipbin89573 -> 0 bytes
-rw-r--r--vid-app-common/src/main/resources/2f80c596.zipbin87488 -> 0 bytes
-rw-r--r--vid-app-common/src/main/resources/adiod.zipbin79927 -> 0 bytes
-rw-r--r--vid-app-common/src/main/resources/csar317927061915233480.zipbin63104 -> 0 bytes
-rw-r--r--vid-app-common/src/main/resources/csar3933948645405128424.zipbin103891 -> 0 bytes
-rw-r--r--vid-app-common/src/main/resources/mso_get_manual_task_by_request_id.json23
-rw-r--r--vid-app-common/src/main/resources/pnf.zipbin33397 -> 0 bytes
-rw-r--r--vid-app-common/src/main/resources/service-David-csar.csarbin29894 -> 0 bytes
-rw-r--r--vid-app-common/src/main/resources/service-DemoService1-csar.csarbin37635 -> 0 bytes
-rw-r--r--vid-app-common/src/main/resources/service-VdbeSrv-csar.zipbin70825 -> 0 bytes
-rw-r--r--vid-app-common/src/main/resources/service-vf-csar.zipbin58363 -> 0 bytes
-rw-r--r--vid-app-common/src/main/resources/service-vf-with-annotations.zipbin118031 -> 0 bytes
-rw-r--r--vid-app-common/src/main/resources/service-vl-csar.zipbin34965 -> 0 bytes
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js4
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/AAITreeConverterTest.java134
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/AaiClientTest.java184
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/AaiResponseTranslatorTest.java6
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/asdc/parser/ToscaParserImpl2Test.java86
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/asdc/parser/ToscaParserInflatorTest.java29
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/asdc/parser/VidNotionsBuilderTest.java340
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/changeManagement/WorkflowRequestDetailTest.java6
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/config/DataSourceConfig.java2
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/config/JobAdapterConfig.java25
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/config/JobCommandsConfigWithMockedMso.java175
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java56
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/controller/AaiServiceInstanceStandardQueryControllerTest.java26
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/controller/LocalWebConfig.java5
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/controller/MsoControllerNewTest.java12
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/controller/MsoControllerTest.java5
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/controller/ToscaParserMockHelper.java20
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/controller/VidControllerTest.java2
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/dal/AsyncInstantiationRepositoryTest.java103
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/job/command/CommandUtilsTest.java4
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/job/command/InProgressStatusServiceTest.java83
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/job/command/InstanceGroupCommandTest.java71
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/job/command/JobCommandFactoryTest.java8
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/job/command/MacroServiceCommandTest.java136
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/job/command/MsoResultHandlerServiceTest.java95
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/job/command/ResourceCommandTest.java258
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/job/command/ResourceInProgressStatusCommandTest.java60
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/job/command/ServiceInProgressStatusCommandTest.java157
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/job/command/WatchChildrenJobsBLTest.java6
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/job/command/WatchingCommandTest.java97
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/job/impl/AsyncInstantiationIntegrationTest.java1020
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/job/impl/DeleteOldJobsSchedulerInitializerTest.java55
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/job/impl/DeleteOldJobsWorkerTest.java (renamed from vid-app-common/src/main/java/org/onap/vid/job/command/ALaCarteServiceInstantiationCommand.java)36
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/job/impl/JobAdapterTest.java43
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/job/impl/JobWorkerTest.java13
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/model/JobAuditStatusTest.java12
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/model/aaiTree/VpnBindingKtTest.kt16
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java181
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/MsoOperationalEnvironmentTest.java17
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientNewTest.java36
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestDetailsTest.java23
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/AAITreeNodeBuilderTest.java469
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/AaiServiceImplTest.java1354
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java119
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBusinessLogicTest.java1105
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/AuditServiceImplTest.java99
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/JobsBrokerServiceTest.java390
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/PortDetailsTranslatorTest.java10
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/RoleGenaratorServiceImplTest.java4
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java51
-rw-r--r--vid-app-common/src/test/resources/WEB-INF/conf/system.properties108
-rw-r--r--vid-app-common/src/test/resources/cr-csar.JSON7
-rw-r--r--vid-app-common/src/test/resources/csars/1712_PASQUALE.zipbin0 -> 87747 bytes
-rw-r--r--vid-app-common/src/test/resources/csars/csarTransportWithPnfs.zipbin0 -> 33722 bytes
-rw-r--r--vid-app-common/src/test/resources/csars/service-AmpPhSvc-csar.zip (renamed from vid-app-common/src/main/resources/service-AmpPhSvc-csar.zip)bin67661 -> 56568 bytes
-rw-r--r--vid-app-common/src/test/resources/csars/service-Infravpn-csar.zipbin0 -> 36957 bytes
-rw-r--r--vid-app-common/src/test/resources/csars/service-JennyVtsbcVlanSvc-csar.zipbin0 -> 181221 bytes
-rw-r--r--vid-app-common/src/test/resources/csars/service-MsoExampleService-csar.zip (renamed from vid-app-common/src/main/resources/service-MsoExampleService-csar.zip)bin30033 -> 30033 bytes
-rw-r--r--vid-app-common/src/test/resources/csars/service-ServicecontainerContainsPprobe.zip (renamed from vid-app-common/src/main/resources/service-ServicecontainerContainsPprobe.zip)bin32759 -> 31473 bytes
-rw-r--r--vid-app-common/src/test/resources/csars/service-Servicecontainermultiplepprobes-csar.zip (renamed from vid-app-common/src/main/resources/service-Servicecontainermultiplepprobes-csar.zip)bin32750 -> 31463 bytes
-rw-r--r--vid-app-common/src/test/resources/csars/service-VdorotheaSrv-csar.zipbin0 -> 67068 bytes
-rw-r--r--vid-app-common/src/test/resources/csars/service-fabric-configuration.zipbin0 -> 82131 bytes
-rw-r--r--vid-app-common/src/test/resources/csars/service-vf-csar.zipbin0 -> 46618 bytes
-rw-r--r--vid-app-common/src/test/resources/csars/service-vf-with-annotations.zipbin0 -> 83322 bytes
-rw-r--r--vid-app-common/src/test/resources/csars/service-vl-csar.zipbin0 -> 33677 bytes
-rw-r--r--vid-app-common/src/test/resources/csars/service-vnf-grouping-csar.zipbin0 -> 71009 bytes
-rw-r--r--vid-app-common/src/test/resources/csars/vLoadBalancerMS-with-policy.TOSCA.zip (renamed from vid-app-common/src/main/resources/vLoadBalancerMS-with-policy.TOSCA.zip)bin108776 -> 108776 bytes
-rw-r--r--vid-app-common/src/test/resources/fabric-configuration.json11
-rw-r--r--vid-app-common/src/test/resources/fabric-real-sriov-configuration.json2
-rw-r--r--vid-app-common/src/test/resources/getTopology/network.json79
-rw-r--r--vid-app-common/src/test/resources/getTopology/serviceWithCR/CR.json62
-rw-r--r--vid-app-common/src/test/resources/getTopology/serviceWithCR/getTopologyWithCR.json95
-rw-r--r--vid-app-common/src/test/resources/getTopology/serviceWithCR/instanceGroup-NCF.json43
-rw-r--r--vid-app-common/src/test/resources/getTopology/serviceWithCR/service-design-and-creation.json1057
-rw-r--r--vid-app-common/src/test/resources/getTopology/serviceWithCR/serviceWithCR.json38
-rw-r--r--vid-app-common/src/test/resources/getTopology/serviceWithCR/serviceWithCRModel.json72
-rw-r--r--vid-app-common/src/test/resources/getTopology/vfModule.json66
-rw-r--r--vid-app-common/src/test/resources/getTopology/vnf.json160
-rw-r--r--vid-app-common/src/test/resources/orchestrationRequestsByServiceInstanceId.json4
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/VnfGroupCreate1Delete1None1Request.json123
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/VnfGroupCreate3Delete1None1Request.json171
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/VnfGroupCreate3Delete1None1RequestResolvedForRetry.json176
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/bulk_alacarte_service_request.json2
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/bulk_alacarte_service_request_naming_false.json2
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/bulk_macro_service_request.json4
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/bulk_service_request_ecomp_naming.json4
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/bulk_service_request_no_vfmodule_ecomp_naming.json4
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/bulk_service_request_unique_names.json4
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/bulk_vnf_request.json2
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/bulk_vnf_request_without_instance_name.json2
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/instance_group_instantiation_request.json5
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/mso_request_create_configuration.json2
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/mso_service_instantiation.json4
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/networkDelete1Create1Request.json117
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/network_instantiation_request.json7
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/network_instantiation_request_without_instance_name.json5
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/pre_1806_macro_service_instantiation_request.json47
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/pre_1806_macro_without_cloudConfiguration.json42
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/resume/feRequestResumeMacroService.json107
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/resume/msoResponseGetRequestsOfServiceInstance.json62
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/vfModuleDelete1Create1None1Request.json139
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/vfmodule/replace_vfmodule.json52
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/vfmodule/replace_vfmodule_fe_input.json92
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/vfmodule_instantiation_request.json5
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/vfmodule_instantiation_request_without_instance_name.json5
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/vfmodule_instantiation_request_without_volume_group.json5
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/vnf/bulk_vnf_request.json49
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/vnf/bulk_vnf_request_without_cloud_owner.json48
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/vnf/bulk_vnf_request_without_instance_name.json48
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/vnf/vnf_without_lob_expected.json46
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/vnf/vnf_without_lob_user_input.json24
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/vnfDelete1Create1Request.json240
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/volumegroup_instantiation_request.json5
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/vrfEntry/service_with_vrf_entry_fe_input.json81
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/vrfEntry/service_with_vrf_instantiation_request.json59
-rw-r--r--vid-app-common/src/test/resources/policy-configuration-by-policy-false.JSON42
-rw-r--r--vid-app-common/src/test/resources/policy-configuration-csar.JSON49
-rw-r--r--vid-app-common/src/test/resources/responses/aai/getCloudRegionAndTenantByVnfId.json12
-rw-r--r--vid-app-common/src/test/resources/responses/mso/multipleOrchestrationRequestsServiceInstance.json300
-rw-r--r--vid-app-common/src/test/resources/responses/mso/orchestrationRequestsVnf.json2
-rw-r--r--vid-app-common/src/test/resources/sdcservices.json (renamed from vid-app-common/src/main/resources/sdcservices.json)118
-rw-r--r--vid-app-common/src/test/resources/vLoadBalancerMS-with-policy.TOSCA.json2
-rw-r--r--vid-app-common/src/test/resources/vf-csar.JSON11
-rw-r--r--vid-app-common/src/test/resources/vf-with-annotation-csar.json223
-rw-r--r--vid-app-common/src/test/resources/vf-with-vfcInstanceGroups.json31
-rw-r--r--vid-app-common/src/test/resources/vl-csar.JSON7
-rw-r--r--vid-app-common/src/test/resources/vnf-grouping-csar.json24
278 files changed, 13530 insertions, 6631 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java
index 4ef6fbd24..015ede893 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java
@@ -21,11 +21,13 @@
package org.onap.vid.aai;
import static java.util.Collections.emptyList;
+import static java.util.Comparator.comparing;
import static java.util.stream.Collectors.toMap;
import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;
import static org.apache.commons.lang3.StringUtils.equalsIgnoreCase;
import static org.apache.commons.lang3.StringUtils.isEmpty;
+import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
@@ -37,6 +39,7 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.function.Function;
+import java.util.stream.Stream;
import javax.inject.Inject;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;
@@ -49,6 +52,7 @@ import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.vid.aai.exceptions.InvalidAAIResponseException;
+import org.onap.vid.aai.model.*;
import org.onap.vid.aai.model.AaiGetAicZone.AicZones;
import org.onap.vid.aai.model.AaiGetInstanceGroupsByCloudRegion;
import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.AaiGetNetworkCollectionDetails;
@@ -117,6 +121,7 @@ public class AaiClient implements AaiClientInterface {
private static final String GET_SERVICE_MODELS_RESPONSE_BODY = "{\"start\" : \"service-design-and-creation/models/\", \"query\" : \"query/serviceModels-byDistributionStatus?distributionStatus=DISTRIBUTION_COMPLETE_OK\"}";
+
@Inject
public AaiClient(AAIRestInterface restController, PortDetailsTranslator portDetailsTranslator, CacheProvider cacheProvider) {
this.restController = restController;
@@ -425,8 +430,8 @@ public class AaiClient implements AaiClientInterface {
}
@Override
- public AaiResponse getSubscriberData(String subscriberId) {
- String depth = "2";
+ public AaiResponse getSubscriberData(String subscriberId, boolean omitServiceInstances) {
+ String depth = omitServiceInstances ? "1" : "2";
AaiResponse subscriberDataResponse;
Response resp = doAaiGet(BUSINESS_CUSTOMERS_CUSTOMER + subscriberId + "?depth=" + depth, false);
subscriberDataResponse = processAaiResponse(resp, Services.class, null);
@@ -434,6 +439,41 @@ public class AaiClient implements AaiClientInterface {
}
@Override
+ public ModelVer getLatestVersionByInvariantId(String modelInvariantId) {
+ if (modelInvariantId.isEmpty()) {
+ throw new GenericUncheckedException("no invariant-id provided to getLatestVersionByInvariantId; request is rejected");
+ }
+
+ // add the modelInvariantId to the payload
+ StringBuilder payload = new StringBuilder(GET_SERVICE_MODELS_RESPONSE_BODY);
+ payload.insert(50, modelInvariantId);
+
+ Response response = doAaiPut("service-design-and-creation/models/model/", payload.toString(),false);
+ AaiResponse<ModelVersions> aaiResponse = processAaiResponse(response, ModelVersions.class, null, VidObjectMapperType.FASTERXML);
+ Stream<ModelVer> modelVerStream = toModelVerStream(aaiResponse.getT());
+ return maxModelVer(modelVerStream);
+
+ }
+
+ protected Stream<ModelVer> toModelVerStream(ModelVersions modelVersions) {
+
+ return Stream.of(modelVersions)
+ .map(ModelVersions::getResults)
+ .flatMap(java.util.Collection::stream)
+ .flatMap(map -> map.entrySet().stream())
+ .filter(kv -> StringUtils.equals(kv.getKey(), "model-ver"))
+ .map(Map.Entry::getValue);
+
+ }
+
+ protected ModelVer maxModelVer(Stream<ModelVer> modelVerStream) {
+ return modelVerStream
+ .filter(modelVer -> StringUtils.isNotEmpty(modelVer.getModelVersion()))
+ .max(comparing(ModelVer::getModelVersion, comparing(DefaultArtifactVersion::new)))
+ .orElseThrow(() -> new GenericUncheckedException("Could not find any version"));
+ }
+
+ @Override
public AaiResponse getServices() {
Response resp = doAaiGet("service-design-and-creation/services", false);
return processAaiResponse(resp, GetServicesAAIRespone.class, null);
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClientInterface.java b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClientInterface.java
index 5f69b8769..1061ae5f5 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClientInterface.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClientInterface.java
@@ -7,9 +7,9 @@
* 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.
@@ -21,30 +21,37 @@
package org.onap.vid.aai;
import com.fasterxml.jackson.databind.JsonNode;
-import java.net.URI;
-import java.util.List;
-import java.util.Map;
-import javax.ws.rs.core.Response;
import org.onap.vid.aai.model.AaiGetOperationalEnvironments.OperationalEnvironmentList;
import org.onap.vid.aai.model.AaiGetPnfs.Pnf;
import org.onap.vid.aai.model.AaiGetTenatns.GetTenantsResponse;
+import org.onap.vid.aai.model.ModelVer;
import org.onap.vid.aai.model.PortDetailsTranslator;
import org.onap.vid.aai.model.Properties;
import org.onap.vid.aai.model.ResourceType;
-import org.onap.vid.services.ProbeInterface;
import org.onap.vid.model.SubscriberList;
+import org.onap.vid.model.probes.ExternalComponentStatus;
+import org.onap.vid.services.ProbeInterface;
+import org.springframework.http.HttpMethod;
+
+import javax.ws.rs.core.Response;
+import java.net.URI;
+import java.util.List;
+import java.util.Map;
+
/**
* Created by Oren on 7/4/17.
*/
-public interface AaiClientInterface extends ProbeInterface {
+public interface AaiClientInterface extends ProbeInterface {
boolean isNodeTypeExistsByName(String name, ResourceType type);
<T> T typedAaiGet(URI path, Class<T> clz);
+ <T> T typedAaiRest(URI path, Class<T> clz, String payload, HttpMethod method, boolean propagateExceptions);
+
AaiResponse<SubscriberList> getAllSubscribers();
- AaiResponse getSubscriberData(String subscriberId);
+ AaiResponse getSubscriberData(String subscriberId, boolean omitServiceInstances);
AaiResponse getServices();
@@ -68,10 +75,12 @@ public interface AaiClientInterface extends ProbeInterface {
Response getVersionByInvariantId(List<String> modelInvariantId);
+ ModelVer getLatestVersionByInvariantId(String modelInvariantId);
+
AaiResponse getServicesByProjectNames(List<String> projectNames);
AaiResponse getServiceModelsByDistributionStatus();
-
+
AaiResponse getPNFData(String globalCustomerId, String serviceType, String modelVersionId, String modelInvariantId, String cloudRegion, String equipVendor, String equipModel);
AaiResponse<Pnf> getSpecificPnf(String pnfId);
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/BaseInstantiationCommand.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/KeyValueModel.java
index 20d71ab29..6e0e1c06a 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/BaseInstantiationCommand.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/KeyValueModel.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,21 +18,25 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.vid.job.command;
+package org.onap.vid.aai.model.AaiGetNetworkCollectionDetails;
-import org.onap.vid.job.impl.JobSharedData;
+public abstract class KeyValueModel {
+ private String key;
+ private String value;
-import java.util.Map;
-
-
-public abstract class BaseInstantiationCommand extends CommandBase{
+ public String getKey() {
+ return key;
+ }
+ public String getValue() {
+ return value;
+ }
+ public void setKey(String key) {
+ this.key = key;
+ }
+ public void setValue(String value) {
+ this.value = value;
+ }
- protected CommandParentData commandParentData = new CommandParentData();
- protected BaseInstantiationCommand init(JobSharedData sharedData, Map<String, Object> commandData) {
- super.init(sharedData);
- commandParentData.initParentData(commandData);
- return this;
- }
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/RelatedToProperty.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/RelatedToProperty.java
index d53d90fd4..7c5287770 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/RelatedToProperty.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/RelatedToProperty.java
@@ -7,9 +7,9 @@
* 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.
@@ -25,33 +25,30 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
@JsonIgnoreProperties(ignoreUnknown = true)
-public class RelatedToProperty {
-
- public String getPropertyKey() {
- return propertyKey;
- }
-
-
- public void setPropertyKey(String propertyKey) {
- this.propertyKey = propertyKey;
- }
-
-
- public String getPropertyValue() {
- return propertyValue;
- }
-
-
- public void setPropertyValue(String propertyValue) {
- this.propertyValue = propertyValue;
- }
-
-
- @JsonProperty("property-key")
- public String propertyKey;
-
-
- @JsonProperty("property-value")
- public String propertyValue;
-
+public class RelatedToProperty extends KeyValueModel {
+
+ @Override
+ @JsonProperty("property-key")
+ public String getKey() {
+ return super.getKey();
+ }
+
+ @Override
+ @JsonProperty("property-key")
+ public void setKey(String propertyKey) {
+ super.setKey(propertyKey);
+ }
+
+ @Override
+ @JsonProperty("property-value")
+ public String getValue() {
+ return super.getValue();
+ }
+
+ @Override
+ @JsonProperty("property-value")
+ public void setValue(String propertyValue) {
+ super.setValue(propertyValue);
+ }
}
+
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/Relationship.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/Relationship.java
index 4de11500e..110e922c1 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/Relationship.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/Relationship.java
@@ -7,9 +7,9 @@
* 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.
@@ -31,13 +31,13 @@ public class Relationship {
@JsonProperty("related-to")
public String relatedTo;
-
+
@JsonProperty("related-link")
public String relatedLink;
@JsonProperty("relationship-label")
public String relationshipLabel;
-
+
@JsonProperty("relationship-data")
public List<RelationshipData> relationshipData;
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/RelationshipData.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/RelationshipData.java
index cba7f43cb..f480ef8d0 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/RelationshipData.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/RelationshipData.java
@@ -7,9 +7,9 @@
* 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.
@@ -24,26 +24,26 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
@JsonIgnoreProperties(ignoreUnknown = true)
-public class RelationshipData {
+public class RelationshipData extends KeyValueModel {
+
+ @Override
@JsonProperty("relationship-key")
- public String getRelationshipKey() {
- return relationshipKey;
+ public String getKey() {
+ return super.getKey();
}
+ @Override
@JsonProperty("relationship-key")
- public void setRelationshipKey(String relationshipKey) {
- this.relationshipKey = relationshipKey;
+ public void setKey(String relationshipKey) {
+ super.setKey(relationshipKey);
}
+ @Override
@JsonProperty("relationship-value")
- public String getRelationshipValue() {
- return relationshipValue;
+ public String getValue() {
+ return super.getValue();
}
+ @Override
@JsonProperty("relationship-value")
- public void setRelationshipValue(String relationshipValue) {
- this.relationshipValue = relationshipValue;
+ public void setValue(String relationshipValue) {
+ super.setValue(relationshipValue);
}
-
- public String relationshipKey;
-
- public String relationshipValue;
-
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/ModelVersions.kt b/vid-app-common/src/main/java/org/onap/vid/aai/model/ModelVersions.kt
new file mode 100644
index 000000000..c4aa45d55
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/ModelVersions.kt
@@ -0,0 +1,3 @@
+package org.onap.vid.aai.model
+
+data class ModelVersions(val results: List<Map<String, ModelVer>>)
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/util/AAITreeConverter.java b/vid-app-common/src/main/java/org/onap/vid/aai/util/AAITreeConverter.java
index 5be26a0ec..48736bc01 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/util/AAITreeConverter.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/util/AAITreeConverter.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,36 +20,43 @@
package org.onap.vid.aai.util;
-import org.apache.commons.lang3.StringUtils;
-import org.onap.vid.model.aaiTree.*;
-import org.onap.vid.mso.model.ModelInfo;
-import org.onap.vid.services.AAITreeNodeBuilder;
-import org.springframework.stereotype.Component;
-
-import java.util.Objects;
-
import static java.util.function.Function.identity;
import static java.util.stream.Collectors.counting;
import static java.util.stream.Collectors.groupingBy;
import static org.onap.vid.asdc.parser.ToscaParserImpl2.Constants.A_LA_CARTE;
+import java.util.Map;
+import java.util.Objects;
+import org.apache.commons.lang3.StringUtils;
+import org.onap.vid.model.aaiTree.AAITreeNode;
+import org.onap.vid.model.aaiTree.CollectionResource;
+import org.onap.vid.model.aaiTree.Network;
+import org.onap.vid.model.aaiTree.Node;
+import org.onap.vid.model.aaiTree.NodeType;
+import org.onap.vid.model.aaiTree.ServiceInstance;
+import org.onap.vid.model.aaiTree.Vnf;
+import org.onap.vid.model.aaiTree.VnfGroup;
+import org.onap.vid.model.aaiTree.Vrf;
+import org.onap.vid.mso.model.ModelInfo;
+import org.springframework.stereotype.Component;
+
@Component
public class AAITreeConverter {
public static final String VNF_TYPE = "vnf-type";
public static final String NETWORK_TYPE = "network-type";
+ public static final String NETWORK_ROLE = "network-role";
+ public static final String PHYSICAL_NETWORK_NAME = "physical-network-name";
+ public static final String SERVICE_INSTANCE = "service-instance";
+ public static final String TENANT = "tenant";
+ public static final String VPN_BINDING = "vpn-binding";
public static final String IS_BASE_VF_MODULE = "is-base-vf-module";
+ public static final String SERVICE_INSTANCE_SERVICE_INSTANCE_NAME = "service-instance.service-instance-name";
+ public static final String SERVICE_INSTANCE_SERVICE_INSTANCE_ID = "service-instance.service-instance-id";
+ public static final String TENANT_TENANT_NAME = "tenant.tenant-name";
- public enum ModelType {
- service,
- vnf,
- network,
- instanceGroup,
- vfModule
- }
-
- public ServiceInstance convertTreeToUIModel(AAITreeNode rootNode, String globalCustomerId, String serviceType, String instantiationType) {
+ public ServiceInstance convertTreeToUIModel(AAITreeNode rootNode, String globalCustomerId, String serviceType, String instantiationType, String instanceRole, String instanceType) {
ServiceInstance serviceInstance = new ServiceInstance();
serviceInstance.setInstanceId(rootNode.getId());
serviceInstance.setInstanceName(rootNode.getName());
@@ -58,46 +65,60 @@ public class AAITreeConverter {
serviceInstance.setSubscriptionServiceType(serviceType);
serviceInstance.setIsALaCarte(StringUtils.equals(instantiationType, A_LA_CARTE));
- serviceInstance.setModelInfo(createModelInfo(rootNode, ModelType.service));
+ serviceInstance.setModelInfo(createModelInfo(rootNode));
//set children: vnf, network,group
rootNode.getChildren().forEach(child -> {
- if (child.getType().equals(AAITreeNodeBuilder.GENERIC_VNF)) {
+ if (child.getType() == NodeType.GENERIC_VNF) {
serviceInstance.getVnfs().put(child.getUniqueNodeKey(), Vnf.from(child));
- } else if (child.getType().equals(AAITreeNodeBuilder.NETWORK)) {
+ } else if (child.getType() == NodeType.NETWORK) {
serviceInstance.getNetworks().put(child.getUniqueNodeKey(), Network.from(child));
- } else if (child.getType().equals(AAITreeNodeBuilder.INSTANCE_GROUP)) {
- serviceInstance.getVnfGroups().put(child.getUniqueNodeKey(), VnfGroup.from(child));
+ } else if (child.getType() == NodeType.INSTANCE_GROUP) {
+ serviceInstance.getVnfGroups().put(child.getUniqueNodeKey(), new VnfGroup(child));
+ } else if (child.getType() == NodeType.COLLECTION_RESOURCE) {
+ serviceInstance.getCollectionResources().put(child.getUniqueNodeKey(), new CollectionResource(child));
+ } else if (isChildVrf(instanceType, instanceRole, child)){
+ serviceInstance.getVrfs().put(child.getUniqueNodeKey(), Vrf.from(child));
}
});
serviceInstance.setExistingVNFCounterMap(
- serviceInstance.getVnfs().entrySet().stream()
- .map(k -> k.getValue().getModelInfo().getModelVersionId())
- .collect(groupingBy(identity(), counting()))
+ getExistingCounterMap(serviceInstance.getVnfs())
);
serviceInstance.setExistingNetworksCounterMap(
- serviceInstance.getNetworks().entrySet().stream()
- .map(k -> k.getValue().getModelInfo().getModelVersionId())
- .filter(Objects::nonNull)
- .collect(groupingBy(identity(), counting()))
+ getExistingCounterMap(serviceInstance.getNetworks())
);
serviceInstance.setExistingVnfGroupCounterMap(
- serviceInstance.getVnfGroups().entrySet().stream()
- .map(k -> k.getValue().getModelInfo().getModelVersionId())
- .filter(Objects::nonNull)
- .collect(groupingBy(identity(), counting()))
+ getExistingCounterMap(serviceInstance.getVnfGroups())
+ );
+
+ serviceInstance.setExistingVRFCounterMap(
+ getExistingCounterMap(serviceInstance.getVrfs())
);
return serviceInstance;
}
- private static ModelInfo createModelInfo(AAITreeNode aaiNode, ModelType modelType) {
+ protected boolean isChildVrf(String instanceType, String serviceRole, AAITreeNode child) {
+ return child.getType() == NodeType.CONFIGURATION && StringUtils.equalsIgnoreCase(instanceType, "BONDING") && StringUtils.equalsIgnoreCase(serviceRole, "INFRASTRUCTURE-VPN");
+ }
+
+ private <T extends Node> Map<String, Long> getExistingCounterMap(Map<String, T> nodeList) {
+ return nodeList.entrySet().stream()
+ .map(k -> {
+ ModelInfo modelInfo = k.getValue().getModelInfo();
+ return StringUtils.defaultIfEmpty(modelInfo.getModelCustomizationId(), modelInfo.getModelVersionId());
+ })
+ .filter(Objects::nonNull)
+ .collect(groupingBy(identity(), counting()));
+ }
+
+ private static ModelInfo createModelInfo(AAITreeNode aaiNode) {
ModelInfo modelInfo = new ModelInfo();
- modelInfo.setModelType(modelType.name());
+ modelInfo.setModelType(aaiNode.getType().getModelType());
modelInfo.setModelName(aaiNode.getModelName());
modelInfo.setModelVersion(aaiNode.getModelVersion());
modelInfo.setModelVersionId(aaiNode.getModelVersionId());
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/util/AAITreeNodeUtils.java b/vid-app-common/src/main/java/org/onap/vid/aai/util/AAITreeNodeUtils.java
new file mode 100644
index 000000000..7ff6f280f
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/util/AAITreeNodeUtils.java
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.vid.aai.util;
+
+import java.util.List;
+import java.util.Optional;
+import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.KeyValueModel;
+import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.Relationship;
+import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.RelationshipList;
+
+public class AAITreeNodeUtils {
+
+ private AAITreeNodeUtils() {
+ }
+
+ public static Optional<Relationship> findFirstRelationshipByRelatedTo(RelationshipList relationshipList, String relatedTo) {
+ if (relationshipList==null || relationshipList.getRelationship()==null) {
+ return Optional.empty();
+ }
+ return relationshipList.getRelationship().stream().filter(x->relatedTo.equals(x.getRelatedTo())).findFirst();
+ }
+
+ public static <T extends KeyValueModel> Optional<String> findFirstValue(List<T> data, String key) {
+ if (data==null || data.isEmpty()) {
+ return Optional.empty();
+ }
+ Optional<T> optValue = data.stream().filter(x->key.equals(x.getKey())).findFirst();
+ return optValue.map(KeyValueModel::getValue);
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/local/LocalAsdcClient.java b/vid-app-common/src/main/java/org/onap/vid/asdc/local/LocalAsdcClient.java
index 7cfd094df..ce1bbe930 100644
--- a/vid-app-common/src/main/java/org/onap/vid/asdc/local/LocalAsdcClient.java
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/local/LocalAsdcClient.java
@@ -25,13 +25,6 @@ import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.joshworks.restclient.http.HttpResponse;
-import org.json.JSONArray;
-import org.json.JSONObject;
-import org.onap.vid.asdc.AsdcCatalogException;
-import org.onap.vid.asdc.AsdcClient;
-import org.onap.vid.asdc.beans.Service;
-import org.onap.vid.exceptions.GenericUncheckedException;
-
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
@@ -39,6 +32,12 @@ import java.net.URLDecoder;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.UUID;
+import org.json.JSONArray;
+import org.json.JSONObject;
+import org.onap.vid.asdc.AsdcCatalogException;
+import org.onap.vid.asdc.AsdcClient;
+import org.onap.vid.asdc.beans.Service;
+import org.onap.vid.exceptions.GenericUncheckedException;
/**
* The Class LocalAsdcClient.
@@ -147,14 +146,14 @@ public class LocalAsdcClient implements AsdcClient {
return null;
}
ClassLoader classLoader = getClass().getClassLoader();
- File file = new File(classLoader.getResource(toscaModelURL).getFile());
try {
+ File file = new File(classLoader.getResource(toscaModelURL).getFile());
//using URLDecoder.decode to convert special characters from %XX to real character
//see https://stackoverflow.com/questions/32251251/java-classloader-getresource-with-special-characters-in-path
return Paths.get(URLDecoder.decode(file.getPath(), "UTF-8"));
- } catch (UnsupportedEncodingException e) {
- throw new GenericUncheckedException(e);
+ } catch (RuntimeException | UnsupportedEncodingException e) {
+ throw new GenericUncheckedException("Can't find " + toscaModelURL, e);
}
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/parser/ToscaParserImpl2.java b/vid-app-common/src/main/java/org/onap/vid/asdc/parser/ToscaParserImpl2.java
index c702cf40a..735ba437c 100644
--- a/vid-app-common/src/main/java/org/onap/vid/asdc/parser/ToscaParserImpl2.java
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/parser/ToscaParserImpl2.java
@@ -7,9 +7,9 @@
* 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.
@@ -22,6 +22,8 @@ package org.onap.vid.asdc.parser;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.tuple.Pair;
+import org.jetbrains.annotations.Nullable;
import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
import org.onap.sdc.tosca.parser.enums.FilterType;
import org.onap.sdc.tosca.parser.enums.SdcTypes;
@@ -29,7 +31,6 @@ import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory;
import org.onap.sdc.toscaparser.api.Group;
import org.onap.sdc.toscaparser.api.*;
-import org.onap.sdc.toscaparser.api.elements.Metadata;
import org.onap.sdc.toscaparser.api.parameters.Input;
import org.onap.vid.asdc.beans.Service;
import org.onap.vid.model.*;
@@ -66,6 +67,7 @@ public class ToscaParserImpl2 {
public static final String VF_MODULE_MODEL_NAME = "vfModuleModelName";
public static final String GET_INPUT = "get_input";
public static final String TYPE = "type";
+ public static final String QUANTITY = "quantity";
public static final String INSTANTIATION_TYPE = "instantiationType";
//instantiation type
@@ -106,8 +108,16 @@ public class ToscaParserImpl2 {
public static final String VNF_GROUP = "VnfGroup";
+ public static final String VRF_NODE_TYPE = "org.openecomp.nodes.VRFEntry";
+
+ public static final String PORT_MIRRORING_CONFIGURATION_NODE_TYPE = "org.openecomp.nodes.PortMirroringConfiguration";
+
+ public static final String PORT_MIRRORING_CONFIGURATION_BY_POLICY_NODE_TYPE = "org.openecomp.nodes.PortMirroringConfigurationByPolicy";
+
public static final String NAMING_POLICY_TYPE = "org.openecomp.policies.External";
+ public static final String SCALING_POLICY_TYPE = "org.openecomp.policies.scaling.Fixed";
+
public static final String ECOMP_GENERATED_NAMING_PROPERTY = "ecomp_generated_naming";
}
@@ -119,6 +129,7 @@ public class ToscaParserImpl2 {
ServiceModel serviceModel = new ServiceModel();
ISdcCsarHelper sdcCsarHelper = getSdcCsarHelper(path);
List<String> policiesTargets = extractNamingPoliciesTargets(sdcCsarHelper);
+ Map<String, Integer> scalingPolicies = extractScalingPolicyOfGroup(sdcCsarHelper);
serviceModel.setService(extractServiceFromCsar(asdcServiceMetadata, sdcCsarHelper));
serviceModel.setVolumeGroups(extractVolumeGroups(sdcCsarHelper));
@@ -128,9 +139,10 @@ public class ToscaParserImpl2 {
serviceModel.setServiceProxies(extractServiceProxyFromCsar(sdcCsarHelper, policiesTargets));
serviceModel.setNetworks(extractNetworksFromCsar(sdcCsarHelper, policiesTargets));
serviceModel.setPnfs(extractPnfsFromCsar(sdcCsarHelper, policiesTargets));
- serviceModel.setCollectionResource(extractCRFromCsar(sdcCsarHelper, policiesTargets));
+ serviceModel.setCollectionResources(extractCRFromCsar(sdcCsarHelper, policiesTargets));
serviceModel.setFabricConfigurations(extractFabricConfigFromCsar(sdcCsarHelper, policiesTargets));
- serviceModel.setVnfGroups(extractVnfGroupsFromCsar(sdcCsarHelper, policiesTargets));
+ serviceModel.setVnfGroups(extractVnfGroupsFromCsar(sdcCsarHelper, policiesTargets, scalingPolicies));
+ serviceModel.setVrfs(extractVrfsFromCsar(sdcCsarHelper, policiesTargets));
serviceModel.getService().setVidNotions(vidNotionsBuilder.buildVidNotions(sdcCsarHelper, serviceModel));
return serviceModel;
}
@@ -248,7 +260,7 @@ public class ToscaParserImpl2 {
vnf.setVfModules(getVfModulesFromVF(csarHelper, vnf.getCustomizationUuid()));
vnf.setVolumeGroups(getVolumeGroupsFromVF(csarHelper, vnf.getCustomizationUuid()));
vnf.setVfcInstanceGroups(getVfcInstanceGroup(csarHelper, nodeTemplate));
- if (ToscaNamingPolicy.getEcompNamingValueForNode(nodeTemplate, "nf_naming").equals("true")) {
+ if ("true".equals(ToscaNamingPolicy.getEcompNamingValueForNode(nodeTemplate, "nf_naming"))) {
setEcompNamingProperty(vnf.getProperties(), "true");
}
vnfsMaps.put(nodeTemplate.getName(), vnf);
@@ -291,7 +303,8 @@ public class ToscaParserImpl2 {
}
private Map<String, PortMirroringConfig> extractPortMirroringConfigFromCsar(ISdcCsarHelper csarHelper, List<String> policiesTargets) {
- List<NodeTemplate> nodeTemplates = csarHelper.getServiceNodeTemplateBySdcType(SdcTypes.CONFIGURATION);//TODO change to
+ List<NodeTemplate> nodeTemplates = csarHelper.getServiceNodeTemplatesByType(Constants.PORT_MIRRORING_CONFIGURATION_NODE_TYPE);
+ nodeTemplates.addAll(csarHelper.getServiceNodeTemplatesByType(Constants.PORT_MIRRORING_CONFIGURATION_BY_POLICY_NODE_TYPE));
Map<String, PortMirroringConfig> configMaps = new HashMap<>();
for (NodeTemplate nodeTemplate : nodeTemplates) {
@@ -379,7 +392,7 @@ public class ToscaParserImpl2 {
Network newNetwork = new Network();
populateNodeFromNodeTemplate(nodeTemplate, csarHelper, newNetwork, policiesTargets);
newNetwork.setModelCustomizationName(nodeTemplate.getName());
- if (ToscaNamingPolicy.getEcompNamingValueForNode(nodeTemplate, "exVL_naming").equals("true")) {
+ if ("true".equals(ToscaNamingPolicy.getEcompNamingValueForNode(nodeTemplate, "exVL_naming"))) {
setEcompNamingProperty(newNetwork.getProperties(), "true");
}
networksMap.put(nodeTemplate.getName(), newNetwork);
@@ -389,14 +402,7 @@ public class ToscaParserImpl2 {
private Map<String, Node> extractPnfsFromCsar(ISdcCsarHelper csarHelper, List<String> policiesTargets) {
List<NodeTemplate> nodeTemplates = csarHelper.getServiceNodeTemplateBySdcType(SdcTypes.PNF);
- HashMap<String, Node> pnfHashMap = new HashMap<>();
-
- for (NodeTemplate nodeTemplate : nodeTemplates) {
- Node pnf = new Node();
- populateNodeFromNodeTemplate(nodeTemplate, csarHelper, pnf, policiesTargets);
- pnfHashMap.put(nodeTemplate.getName(), pnf);
- }
- return pnfHashMap;
+ return this.extractNodesFromCsar(csarHelper,policiesTargets,nodeTemplates);
}
private Map<String, VfModule> extractVfModuleFromCsar(ISdcCsarHelper csarHelper) {
@@ -426,7 +432,7 @@ public class ToscaParserImpl2 {
for (org.onap.sdc.toscaparser.api.parameters.Input input : inputList) {
//Set only inputs without annotation to the service level
if ( input.getAnnotations() == null )
- inputs.put(input.getName(), convertInput(input, new org.onap.vid.asdc.beans.tosca.Input(), null));
+ inputs.put(input.getName(), convertInput(input, new org.onap.vid.asdc.beans.tosca.Input()));
}
return inputs;
}
@@ -546,7 +552,7 @@ public class ToscaParserImpl2 {
}
- public static boolean isModuleTypeIsBaseObjectSafe(Object vfModuleTypeValue) {
+ public static boolean isModuleTypeIsBaseObjectSafe(@Nullable Object vfModuleTypeValue) {
return (vfModuleTypeValue instanceof String) && (isModuleTypeIsBase((String) vfModuleTypeValue));
}
@@ -567,7 +573,7 @@ public class ToscaParserImpl2 {
for (Input input : inputs) {
if ( input.getName().equals(key) ) {
org.onap.vid.asdc.beans.tosca.Input localInput = new org.onap.vid.asdc.beans.tosca.Input();
- localInput = convertInput(input, localInput, nodeTemplate);
+ localInput = convertInput(input, localInput);
String name = property.getKey();
commandPropertyMap.put(name, extractCommands(name, key));
inputMap.put(name, localInput);
@@ -582,23 +588,13 @@ public class ToscaParserImpl2 {
return inputKey.substring(inputKey.indexOf(':') + 1);
}
- private org.onap.vid.asdc.beans.tosca.Input convertInput(Input parserInput, org.onap.vid.asdc.beans.tosca.Input localInput, NodeTemplate nodeTemplate){
+ private org.onap.vid.asdc.beans.tosca.Input convertInput(Input parserInput, org.onap.vid.asdc.beans.tosca.Input localInput) {
localInput.setDefault(parserInput.getDefault());
localInput.setDescription(parserInput.getDescription());
localInput.setRequired(parserInput.isRequired());
localInput.setType(parserInput.getType());
localInput.setConstraints(parserInput.getConstraints());
// localInput.setentry_schema()
-
- //if inputs of inner nodeTemplate - tell its details
- if(nodeTemplate != null) {
- Metadata metadata = nodeTemplate.getMetaData();
- localInput.setTemplateName(metadata.getValue("name"));
- localInput.setTemplateUUID(metadata.getValue("UUID"));
- localInput.setTemplateInvariantUUID(metadata.getValue("invariantUUID"));
- localInput.setTemplateCustomizationUUID(metadata.getValue("customizationUUID"));
- }
-
return localInput;
}
@@ -626,15 +622,30 @@ public class ToscaParserImpl2 {
return validatedInstantiationType;
}
- private Map<String, ResourceGroup> extractVnfGroupsFromCsar(ISdcCsarHelper csarHelper, List<String> policiesTargets) {
+ private Map<String, Node> extractVrfsFromCsar(ISdcCsarHelper csarHelper, List<String> policiesTargets) {
+ List<NodeTemplate> nodeTemplates = csarHelper.getServiceNodeTemplatesByType(Constants.VRF_NODE_TYPE);
+ return this.extractNodesFromCsar(csarHelper,policiesTargets,nodeTemplates);
+ }
+
+ private Map<String, Node> extractNodesFromCsar(ISdcCsarHelper csarHelper, List<String> policiesTargets, List<NodeTemplate> nodeTemplates){
+ HashMap<String, Node> nodeHashMap = new HashMap<>();
+ for (NodeTemplate nodeTemplate : nodeTemplates) {
+ Node node = new Node();
+ populateNodeFromNodeTemplate(nodeTemplate, csarHelper, node, policiesTargets);
+ nodeHashMap.put(nodeTemplate.getName(), node);
+ }
+ return nodeHashMap;
+ }
+
+ private Map<String, ResourceGroup> extractVnfGroupsFromCsar(ISdcCsarHelper csarHelper, List<String> policiesTargets, Map<String, Integer> scalingPolicies) {
List<Group> resourceGroups = csarHelper.getGroupsOfTopologyTemplateByToscaGroupType(Constants.RESOURCE_GROUP_TYPE);
return resourceGroups.stream()
.filter(group -> group.getProperties().get(Constants.RESOURCE_GROUP_CONTAINED_TYPE).getValue().equals("VF"))
- .collect(toMap(Group::getName, group -> parseResourceGroup(group, csarHelper, policiesTargets)));
+ .collect(toMap(Group::getName, group -> parseResourceGroup(group, csarHelper, policiesTargets, scalingPolicies)));
}
- private ResourceGroup parseResourceGroup(Group group, ISdcCsarHelper csarHelper, List<String> policiesTargets) {
+ private ResourceGroup parseResourceGroup(Group group, ISdcCsarHelper csarHelper, List<String> policiesTargets, Map<String, Integer> scalingPolicies) {
return new ResourceGroup(
Constants.VNF_GROUP,
group.getMetadata().getValue(Constants.INVARIANT_UUID),
@@ -642,16 +653,19 @@ public class ToscaParserImpl2 {
group.getMetadata().getValue(Constants.VERSION),
group.getMetadata().getValue(Constants.NAME),
group.getMetadata().getValue(Constants.NAME),
- getPropertiesOfResourceGroup(group.getProperties(), policiesTargets.contains(group.getName())),
+ getPropertiesOfResourceGroup(group.getProperties(), policiesTargets.contains(group.getName()), scalingPolicies.get(group.getName())),
csarHelper.getGroupMembersFromTopologyTemplate(group.getName()).stream()
.collect(toMap(NodeTemplate::getName, node -> getServiceProxyFromNodeTemplate(node, csarHelper, policiesTargets)))
);
}
- private Map<String, Object> getPropertiesOfResourceGroup(Map<String, Property> properties, boolean hasPolicyTarget) {
+ private Map<String, Object> getPropertiesOfResourceGroup(Map<String, Property> properties, boolean hasPolicyTarget, Integer qty) {
Map<String, Object> propertiesMap = properties.entrySet().stream()
.collect(toMap(Map.Entry::getKey, e -> e.getValue().getValue()));
propertiesMap.put(Constants.ECOMP_GENERATED_NAMING_PROPERTY, String.valueOf(hasPolicyTarget));
+ if (qty != null) {
+ propertiesMap.put(Constants.QUANTITY, qty);
+ }
return propertiesMap;
}
@@ -660,9 +674,22 @@ public class ToscaParserImpl2 {
List<Policy> policies = csarHelper.getPoliciesOfTopologyTemplateByToscaPolicyType(Constants.NAMING_POLICY_TYPE);
return policies.stream()
.filter(policy -> policy.getProperties().get(Constants.TYPE) != null &&
- policy.getProperties().get(Constants.TYPE).getValue() != null &&
+ policy.getProperties().get(Constants.TYPE).getValue() != null &&
StringUtils.equalsIgnoreCase(policy.getProperties().get(Constants.TYPE).getValue().toString(), "naming"))
.flatMap(policy -> policy.getTargets().stream())
.collect(toList());
}
-}
+
+ public Map<String, Integer> extractScalingPolicyOfGroup(ISdcCsarHelper csarHelper) {
+ return csarHelper.getPoliciesOfTopologyTemplateByToscaPolicyType(Constants.SCALING_POLICY_TYPE)
+ .stream()
+ .filter(policy -> policy.getProperties().containsKey(Constants.QUANTITY))
+ .flatMap(policy -> {
+ Integer qty = Integer.parseInt(policy.getProperties().get(Constants.QUANTITY).getValue().toString());
+ return policy
+ .getTargets().stream()
+ .map(target -> Pair.of(target, qty));
+ })
+ .collect(toMap(Pair::getKey, Pair::getValue));
+ }
+} \ No newline at end of file
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/parser/VidNotionsBuilder.java b/vid-app-common/src/main/java/org/onap/vid/asdc/parser/VidNotionsBuilder.java
index a28695211..c9c2649ae 100644
--- a/vid-app-common/src/main/java/org/onap/vid/asdc/parser/VidNotionsBuilder.java
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/parser/VidNotionsBuilder.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,36 +20,75 @@
package org.onap.vid.asdc.parser;
+import static org.apache.commons.lang3.StringUtils.equalsAnyIgnoreCase;
+import static org.apache.commons.lang3.StringUtils.equalsIgnoreCase;
+import static org.apache.commons.lang3.StringUtils.isEmpty;
+
+import com.google.common.collect.ImmutableMap;
+import java.util.Map;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
+import org.jetbrains.annotations.Nullable;
import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
import org.onap.sdc.toscaparser.api.NodeTemplate;
+import org.onap.sdc.toscaparser.api.elements.Metadata;
import org.onap.vid.model.ServiceModel;
import org.onap.vid.model.VidNotions;
import org.onap.vid.properties.Features;
import org.togglz.core.manager.FeatureManager;
-import static org.apache.commons.lang3.StringUtils.equalsAnyIgnoreCase;
-import static org.apache.commons.lang3.StringUtils.equalsIgnoreCase;
-
public class VidNotionsBuilder {
private final FeatureManager featureManager;
+ //map of service type that are always macro services, and their relevant featureFlag
+ private static final Map<VidNotions.ModelCategory, Features> macroServicesByModelCategory = ImmutableMap.of(
+ VidNotions.ModelCategory.INFRASTRUCTURE_VPN, Features.FLAG_1908_INFRASTRUCTURE_VPN,
+ VidNotions.ModelCategory.Transport, Features.FLAG_1908_TRANSPORT_SERVICE_NEW_INSTANTIATION_UI,
+ VidNotions.ModelCategory.SERVICE_WITH_COLLECTION_RESOURCE, Features.FLAG_1908_COLLECTION_RESOURCE_NEW_INSTANTIATION_UI
+ );
+
public VidNotionsBuilder(FeatureManager featureManager) {
this.featureManager = featureManager;
}
- public VidNotions buildVidNotions(ISdcCsarHelper csarHelper, ServiceModel serviceModel) {
- final VidNotions.InstantiationUI instantiationUI = suggestInstantiationUI(csarHelper);
+ VidNotions buildVidNotions(ISdcCsarHelper csarHelper, ServiceModel serviceModel) {
+ VidNotions.ModelCategory modelCategory = suggestModelCategory(csarHelper, serviceModel);
+ return new VidNotions(
+ suggestInstantiationUI(csarHelper, serviceModel),
+ modelCategory,
+ suggestViewEditUI(csarHelper, serviceModel),
+ suggestInstantiationType(serviceModel, modelCategory));
+ }
- return new VidNotions(instantiationUI, suggestModelCategory(csarHelper), suggestViewEditUI(csarHelper, serviceModel));
+ private boolean isMacroTypeByModelCategory(VidNotions.ModelCategory modelCategory) {
+ Features featureOfMacroType = macroServicesByModelCategory.get(modelCategory);
+ //if featureOfMacroType is null this service is not a macro by its type
+ return (featureOfMacroType!=null && featureManager.isActive(featureOfMacroType));
+ }
+
+ VidNotions.InstantiationType suggestInstantiationType(ServiceModel serviceModel, VidNotions.ModelCategory modelCategory) {
+ if (isMacroTypeByModelCategory(modelCategory)) {
+ return VidNotions.InstantiationType.Macro;
+ }
+ if (serviceModel==null || serviceModel.getService()==null || isEmpty(serviceModel.getService().getInstantiationType())) {
+ return VidNotions.InstantiationType.ClientConfig;
+ }
+ String instantiationType = serviceModel.getService().getInstantiationType();
+ if (instantiationType.equals(ToscaParserImpl2.Constants.MACRO)) {
+ return VidNotions.InstantiationType.Macro;
+ }
+ if (instantiationType.equals(ToscaParserImpl2.Constants.A_LA_CARTE)) {
+ return VidNotions.InstantiationType.ALaCarte;
+ }
+
+ return VidNotions.InstantiationType.ClientConfig;
}
//UI route a-la-carte services to old UI only if InstantiationUI is LEGACY
//So any other value for InstantiationUI other than LEGACY make UI to route
//a-la-carte services to new UI
- VidNotions.InstantiationUI suggestInstantiationUI(ISdcCsarHelper csarHelper) {
+ VidNotions.InstantiationUI suggestInstantiationUI(ISdcCsarHelper csarHelper, ServiceModel serviceModel) {
if(featureManager.isActive(Features.FLAG_EXP_ANY_ALACARTE_NEW_INSTANTIATION_UI) && isALaCarte(csarHelper)) {
return VidNotions.InstantiationUI.ANY_ALACARTE_NEW_UI;
}
@@ -57,42 +96,91 @@ public class VidNotionsBuilder {
return VidNotions.InstantiationUI.SERVICE_WITH_VNF_GROUPING;
}
if (featureManager.isActive(Features.FLAG_5G_IN_NEW_INSTANTIATION_UI)) {
- if (isUuidExactlyHardCoded1ffce89fef3f(csarHelper)) {
- return VidNotions.InstantiationUI.SERVICE_UUID_IS_1ffce89f_ef3f_4cbb_8b37_82134590c5de;
- } else if (isALaCarte(csarHelper) && hasAnyNetworkWithPropertyNetworkTechnologyEqualsStandardSriovOrOvs(csarHelper)) {
- return VidNotions.InstantiationUI.NETWORK_WITH_PROPERTY_NETWORK_TECHNOLOGY_EQUALS_STANDARD_SRIOV_OR_OVS;
- } else if (isALaCarte(csarHelper) && hasFabricConfiguration(csarHelper)) {
- return VidNotions.InstantiationUI.SERVICE_WITH_FABRIC_CONFIGURATION;
- }
+ VidNotions.InstantiationUI instantiationUI = determine5GInstantiationUI(csarHelper);
+ if ( instantiationUI != null ) return instantiationUI;
+ }
+ if (featureManager.isActive(Features.FLAG_1908_TRANSPORT_SERVICE_NEW_INSTANTIATION_UI) && isTransportService(csarHelper)){
+ return VidNotions.InstantiationUI.TRANSPORT_SERVICE;
+ }
+ if (featureManager.isActive(Features.FLAG_1908_COLLECTION_RESOURCE_NEW_INSTANTIATION_UI) && isServiceWithCollectionResource(serviceModel)){
+ return VidNotions.InstantiationUI.SERVICE_WITH_COLLECTION_RESOURCE;
+ }
+ if (featureManager.isActive(Features.FLAG_1908_INFRASTRUCTURE_VPN) && isInfraStructureVpn(csarHelper)){
+ return VidNotions.InstantiationUI.INFRASTRUCTURE_VPN;
+ }
+ if (featureManager.isActive(Features.FLAG_1908_A_LA_CARTE_VNF_NEW_INSTANTIATION_UI) && isVnfServiceRole(csarHelper)){
+ return VidNotions.InstantiationUI.A_LA_CARTE_VNF_SERVICE_ROLE;
}
-
return VidNotions.InstantiationUI.LEGACY;
}
- VidNotions.ModelCategory suggestModelCategory(ISdcCsarHelper csarHelper) {
+ private boolean isVnfServiceRole(ISdcCsarHelper csarHelper) {
+ final String serviceRole = csarHelper.getServiceMetadata().getValue(ToscaParserImpl2.Constants.SERVICE_ROLE );
+ return StringUtils.equalsIgnoreCase("VNF" , serviceRole);
+ }
+
+ @Nullable
+ private VidNotions.InstantiationUI determine5GInstantiationUI(ISdcCsarHelper csarHelper) {
+ if (isUuidExactlyHardCoded1ffce89fef3f(csarHelper)) {
+ return VidNotions.InstantiationUI.SERVICE_UUID_IS_1ffce89f_ef3f_4cbb_8b37_82134590c5de;
+ } else if (isALaCarte(csarHelper) && hasAnyNetworkWithPropertyNetworkTechnologyEqualsStandardSriovOrOvs(csarHelper)) {
+ return VidNotions.InstantiationUI.NETWORK_WITH_PROPERTY_NETWORK_TECHNOLOGY_EQUALS_STANDARD_SRIOV_OR_OVS;
+ } else if (isALaCarte(csarHelper) && hasFabricConfiguration(csarHelper)) {
+ return VidNotions.InstantiationUI.SERVICE_WITH_FABRIC_CONFIGURATION;
+ }
+ return null;
+ }
+
+ private boolean isTransportService(ISdcCsarHelper csarHelper) {
+ return ("TRANSPORT".equalsIgnoreCase(csarHelper.getServiceMetadata().getValue(ToscaParserImpl2.Constants.SERVICE_TYPE)));
+ }
+
+ private boolean isServiceWithCollectionResource(ServiceModel serviceModel){
+ return MapUtils.isNotEmpty(serviceModel.getCollectionResources());
+ }
+
+ private boolean isInfraStructureVpn(ISdcCsarHelper csarHelper) {
+ Metadata serviceMetadata = csarHelper.getServiceMetadata();
+ return ("BONDING".equalsIgnoreCase(serviceMetadata.getValue(ToscaParserImpl2.Constants.SERVICE_TYPE)) &&
+ "INFRASTRUCTURE-VPN".equalsIgnoreCase(serviceMetadata.getValue(ToscaParserImpl2.Constants.SERVICE_ROLE)));
+ }
+
+ VidNotions.ModelCategory suggestModelCategory(ISdcCsarHelper csarHelper, ServiceModel serviceModel) {
if (isALaCarte(csarHelper) && hasAnyNetworkWithPropertyNetworkTechnologyEqualsStandardSriovOrOvs(csarHelper)){
return VidNotions.ModelCategory.IS_5G_PROVIDER_NETWORK_MODEL;
- } else if(isALaCarte(csarHelper) && hasFabricConfiguration(csarHelper)) {
+ }
+ if(isALaCarte(csarHelper) && hasFabricConfiguration(csarHelper)) {
return VidNotions.ModelCategory.IS_5G_FABRIC_CONFIGURATION_MODEL;
- } else {
- return VidNotions.ModelCategory.OTHER;
}
+ if (isInfraStructureVpn(csarHelper)) {
+ return VidNotions.ModelCategory.INFRASTRUCTURE_VPN;
+ }
+ if (isTransportService(csarHelper)) {
+ return VidNotions.ModelCategory.Transport;
+ }
+ if (isServiceWithCollectionResource(serviceModel)) {
+ return VidNotions.ModelCategory.SERVICE_WITH_COLLECTION_RESOURCE;
+ }
+ return VidNotions.ModelCategory.OTHER;
}
VidNotions.InstantiationUI suggestViewEditUI(ISdcCsarHelper csarHelper, ServiceModel serviceModel) {
- if (!featureManager.isActive(Features.FLAG_ASYNC_INSTANTIATION)){
- return VidNotions.InstantiationUI.LEGACY;
- }
if (featureManager.isActive(Features.FLAG_1902_VNF_GROUPING) && isGrouping(csarHelper)) {
return VidNotions.InstantiationUI.SERVICE_WITH_VNF_GROUPING;
}
+ if (featureManager.isActive(Features.FLAG_1908_COLLECTION_RESOURCE_NEW_INSTANTIATION_UI) &&
+ featureManager.isActive(Features.FLAG_1908_RESUME_MACRO_SERVICE) &&
+ isServiceWithCollectionResource(serviceModel)) {
+ return VidNotions.InstantiationUI.SERVICE_WITH_COLLECTION_RESOURCE;
+ }
+
if (featureManager.isActive(Features.FLAG_1902_NEW_VIEW_EDIT)) {
if (isMacro(serviceModel) && !isMacroExcludedFromAsyncFlow(serviceModel)) {
return VidNotions.InstantiationUI.MACRO_SERVICE;
}
- VidNotions.InstantiationUI instantiationUISuggestion = suggestInstantiationUI(csarHelper);
+ VidNotions.InstantiationUI instantiationUISuggestion = suggestInstantiationUI(csarHelper, serviceModel);
if (instantiationUISuggestion!=VidNotions.InstantiationUI.LEGACY) {
return instantiationUISuggestion;
}
@@ -137,10 +225,8 @@ public class VidNotionsBuilder {
boolean isMacroExcludedFromAsyncFlow(ServiceModel serviceModel) {
return (MapUtils.isNotEmpty(serviceModel.getPnfs()) ||
- MapUtils.isNotEmpty(serviceModel.getCollectionResource()) ||
+ MapUtils.isNotEmpty(serviceModel.getCollectionResources()) ||
(MapUtils.isNotEmpty(serviceModel.getNetworks()) && !featureManager.isActive(Features.FLAG_NETWORK_TO_ASYNC_INSTANTIATION)));
-
-
}
private boolean isGrouping(ISdcCsarHelper csarHelper) {
diff --git a/vid-app-common/src/main/java/org/onap/vid/changeManagement/CloudConfiguration.java b/vid-app-common/src/main/java/org/onap/vid/changeManagement/CloudConfiguration.java
index da4fd0aa5..f24e2615f 100644
--- a/vid-app-common/src/main/java/org/onap/vid/changeManagement/CloudConfiguration.java
+++ b/vid-app-common/src/main/java/org/onap/vid/changeManagement/CloudConfiguration.java
@@ -7,9 +7,9 @@
* 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.
@@ -27,8 +27,8 @@ import java.util.Map;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
-"lcpCloudRegionId",
-"tenantId"
+ "lcpCloudRegionId",
+ "tenantId"
})
public class CloudConfiguration {
@JsonProperty("lcpCloudRegionId")
@@ -40,32 +40,32 @@ public class CloudConfiguration {
@JsonProperty("lcpCloudRegionId")
public String getLcpCloudRegionId() {
- return lcpCloudRegionId;
+ return lcpCloudRegionId;
}
@JsonProperty("lcpCloudRegionId")
public void setLcpCloudRegionId(String lcpCloudRegionId) {
- this.lcpCloudRegionId = lcpCloudRegionId;
+ this.lcpCloudRegionId = lcpCloudRegionId;
}
@JsonProperty("tenantId")
public String getTenantId() {
- return tenantId;
+ return tenantId;
}
@JsonProperty("tenantId")
public void setTenantId(String tenantId) {
- this.tenantId = tenantId;
+ this.tenantId = tenantId;
}
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
- return this.additionalProperties;
+ return this.additionalProperties;
}
@JsonAnySetter
public void setAdditionalProperty(String name, Object value) {
- this.additionalProperties.put(name, value);
+ this.additionalProperties.put(name, value);
}
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/AaiController.java b/vid-app-common/src/main/java/org/onap/vid/controller/AaiController.java
index 4a4f3d300..eee2acc51 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/AaiController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/AaiController.java
@@ -50,6 +50,7 @@ import org.onap.vid.aai.model.AaiGetPnfs.Pnf;
import org.onap.vid.aai.model.AaiGetTenatns.GetTenantsResponse;
import org.onap.vid.aai.util.AAIRestInterface;
import org.onap.vid.model.VersionByInvariantIdsRequest;
+import org.onap.vid.properties.Features;
import org.onap.vid.roles.Role;
import org.onap.vid.roles.RoleProvider;
import org.onap.vid.roles.RoleValidator;
@@ -68,6 +69,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.HandlerMapping;
import org.springframework.web.servlet.ModelAndView;
+import org.togglz.core.manager.FeatureManager;
@RestController
@@ -80,17 +82,22 @@ public class AaiController extends RestrictedBaseController {
private AAIRestInterface aaiRestInterface;
private RoleProvider roleProvider;
private SystemPropertiesWrapper systemPropertiesWrapper;
+ private FeatureManager featureManager;
+
@Autowired
public AaiController(AaiService aaiService,
AAIRestInterface aaiRestInterface,
RoleProvider roleProvider,
- SystemPropertiesWrapper systemPropertiesWrapper) {
+ SystemPropertiesWrapper systemPropertiesWrapper,
+ FeatureManager featureManager
+ ) {
this.aaiService = aaiService;
this.aaiRestInterface = aaiRestInterface;
this.roleProvider = roleProvider;
this.systemPropertiesWrapper = systemPropertiesWrapper;
+ this.featureManager = featureManager;
}
@RequestMapping(value = {"/subscriberSearch"}, method = RequestMethod.GET)
@@ -261,13 +268,13 @@ public class AaiController extends RestrictedBaseController {
}
@RequestMapping(value = "/aai_sub_details/{subscriberId}", method = RequestMethod.GET)
- public ResponseEntity<String> GetSubscriberDetails(HttpServletRequest request,
- @PathVariable("subscriberId") String subscriberId) throws IOException {
+ public ResponseEntity<String> getSubscriberDetails(HttpServletRequest request, @PathVariable("subscriberId") String subscriberId,
+ @RequestParam(value="omitServiceInstances", required = false, defaultValue = "false") boolean omitServiceInstances) throws IOException {
ObjectMapper objectMapper = new ObjectMapper();
ResponseEntity responseEntity;
List<Role> roles = roleProvider.getUserRoles(request);
RoleValidator roleValidator = RoleValidator.by(roles);
- AaiResponse subscriberData = aaiService.getSubscriberData(subscriberId, roleValidator);
+ AaiResponse subscriberData = aaiService.getSubscriberData(subscriberId, roleValidator, featureManager.isActive(Features.FLAG_1906_AAI_SUB_DETAILS_REDUCE_DEPTH) && omitServiceInstances);
String httpMessage = subscriberData.getT() != null ?
objectMapper.writeValueAsString(subscriberData.getT()) :
subscriberData.getErrorMessage();
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/AaiServiceInstanceStandardQueryController.java b/vid-app-common/src/main/java/org/onap/vid/controller/AaiServiceInstanceStandardQueryController.java
index 8f56f7795..015f8dc96 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/AaiServiceInstanceStandardQueryController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/AaiServiceInstanceStandardQueryController.java
@@ -21,48 +21,54 @@
package org.onap.vid.controller;
-import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.Network;
-import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.ServiceInstance;
-import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.Vlan;
-import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.Vnf;
-import org.onap.vid.aai.util.ServiceInstanceStandardQuery;
+import static java.util.stream.Collectors.toList;
+
+import com.google.common.collect.ImmutableMap;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Objects;
+import java.util.UUID;
+import javax.servlet.http.HttpServletRequest;
+import org.apache.commons.text.StrSubstitutor;
import org.onap.vid.asdc.AsdcCatalogException;
import org.onap.vid.exceptions.GenericUncheckedException;
import org.onap.vid.model.ServiceModel;
import org.onap.vid.model.VidNotions;
+import org.onap.vid.model.aaiTree.AAITreeNode;
+import org.onap.vid.model.aaiTree.NodeType;
import org.onap.vid.properties.Features;
+import org.onap.vid.services.AAIServiceTree;
import org.onap.vid.services.VidService;
-import org.onap.vid.utils.Multival;
+import org.onap.vid.utils.Tree;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpMethod;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.togglz.core.manager.FeatureManager;
-import javax.servlet.http.HttpServletRequest;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.UUID;
-
-import static java.util.stream.Collectors.toList;
-
@RestController
@RequestMapping(AaiServiceInstanceStandardQueryController.AAI_STANDARD_QUERY)
public class AaiServiceInstanceStandardQueryController extends VidRestrictedBaseController {
- public static final String AAI_STANDARD_QUERY = "aai/standardQuery";
+ static final String AAI_STANDARD_QUERY = "aai/standardQuery";
+ private static final String SERVICE_INSTANCE_URI_TEMPLATE = "" +
+ "business/customers/customer/${global-customer-id}" +
+ "/service-subscriptions/service-subscription/${service-type}" +
+ "/service-instances/service-instance/${service-instance-id}";
- private final ServiceInstanceStandardQuery serviceInstanceStandardQuery;
private final FeatureManager featureManager;
private final VidService sdcService;
+ private final AAIServiceTree aaiServiceTree;
@Autowired
- public AaiServiceInstanceStandardQueryController(FeatureManager featureManager, ServiceInstanceStandardQuery serviceInstanceStandardQuery, VidService sdcService) {
+ public AaiServiceInstanceStandardQueryController(FeatureManager featureManager,
+ VidService sdcService, AAIServiceTree aaiServiceTree) {
this.featureManager = featureManager;
- this.serviceInstanceStandardQuery = serviceInstanceStandardQuery;
this.sdcService = sdcService;
+ this.aaiServiceTree = aaiServiceTree;
}
@RequestMapping(value = "vlansByNetworks", method = RequestMethod.GET)
@@ -80,54 +86,50 @@ public class AaiServiceInstanceStandardQueryController extends VidRestrictedBase
return new VlansByNetworksHierarchy();
}
- final ServiceInstance serviceInstance =
- serviceInstanceStandardQuery.fetchServiceInstance(globalCustomerId, serviceType, serviceInstanceId);
+ Tree<AAIServiceTree.AaiRelationship> pathsToSearch = new Tree<>(new AAIServiceTree.AaiRelationship(NodeType.SERVICE_INSTANCE));
+ pathsToSearch.addPath(AAIServiceTree.toAaiRelationshipList(NodeType.GENERIC_VNF, NodeType.NETWORK, NodeType.VLAN_TAG));
+ pathsToSearch.addPath(AAIServiceTree.toAaiRelationshipList(NodeType.NETWORK, NodeType.VLAN_TAG));
- Multival<ServiceInstance, Multival<Vnf, Multival<Network, Vlan>>> l3NetworksWithVlansForVnfForService = fetchVnfsForService(serviceInstance);
- Multival<ServiceInstance, Multival<Network, Vlan>> l3NetworksWithVlansForService = fetchNetworksForService(serviceInstance);
+ AAITreeNode aaiTree = aaiServiceTree.buildAAITree(getServiceInstanceUri(globalCustomerId, serviceType, serviceInstanceId),
+ null, HttpMethod.GET, pathsToSearch, false).get(0);
// translate to response's format
return new VlansByNetworksHierarchy(
- l3NetworksWithVlansForService.getValues().stream().map(this::translateNetworksFormat
- ).collect(toList()),
-
- l3NetworksWithVlansForVnfForService.getValues().stream().map(vnfWithNetworks ->
- new VnfVlansByNetworks(vnfWithNetworks.getKey().getVnfId(),
- vnfWithNetworks.getValues().stream().map(this::translateNetworksFormat
- ).collect(toList())
- )
- ).collect(toList())
+ aaiTree.getChildren().stream()
+ .filter(child -> child.getType() == NodeType.NETWORK)
+ .map(this::translateNetworksFormat)
+ .collect(toList()),
+
+ aaiTree.getChildren().stream()
+ .filter(child -> child.getType() == NodeType.GENERIC_VNF)
+ .map(vnf -> new VnfVlansByNetworks(vnf.getId(),
+ vnf.getChildren().stream()
+ .map(this::translateNetworksFormat)
+ .collect(toList())
+ ))
+ .collect(toList())
);
}
- private Multival<ServiceInstance, Multival<Vnf, Multival<Network, Vlan>>> fetchVnfsForService(ServiceInstance serviceInstance) {
- final Multival<ServiceInstance, Vnf> vnfsForService =
- serviceInstanceStandardQuery.fetchRelatedVnfs(serviceInstance);
-
- final Multival<ServiceInstance, Multival<Vnf, Network>> vnfsWithL3NetworksForService =
- vnfsForService.mapEachVal(vnf -> serviceInstanceStandardQuery.fetchRelatedL3Networks("vnf", vnf));
-
- return vnfsWithL3NetworksForService.mapEachVal(vnfMulti->
- vnfMulti.mapEachVal(serviceInstanceStandardQuery::fetchRelatedVlanTags)
- );
+ private String getServiceInstanceUri(String globalCustomerId, String serviceType, String serviceInstanceId) {
+ return new StrSubstitutor(ImmutableMap.of(
+ "global-customer-id", globalCustomerId,
+ "service-type", serviceType,
+ "service-instance-id", serviceInstanceId
+ )).replace(SERVICE_INSTANCE_URI_TEMPLATE);
}
- private Multival<ServiceInstance, Multival<Network, Vlan>> fetchNetworksForService(ServiceInstance serviceInstance) {
- final Multival<ServiceInstance, Network> l3NetworksForService =
- serviceInstanceStandardQuery.fetchRelatedL3Networks("service", serviceInstance);
-
- return l3NetworksForService.mapEachVal(serviceInstanceStandardQuery::fetchRelatedVlanTags);
- }
-
- private NetworksToVlans translateNetworksFormat(Multival<Network, Vlan> networkWithVlan) {
+ private NetworksToVlans translateNetworksFormat(AAITreeNode networkWithVlan) {
return new NetworksToVlans(
- networkWithVlan.getKey().getNetworkId(),
- networkWithVlan.getKey().getNetworkName(),
- networkWithVlan.getKey().getNetworkType(),
- networkWithVlan.getKey().getOrchestrationStatus(),
- networkWithVlan.getValues().stream().map(
- vlan -> new NetworksToVlans.Vlan(vlan.getVlanIdInner())
+ networkWithVlan.getId(),
+ networkWithVlan.getName(),
+ Objects.toString(networkWithVlan.getAdditionalProperties().get("network-type"), null),
+ networkWithVlan.getOrchestrationStatus(),
+ networkWithVlan.getChildren().stream().map(
+ vlan -> new NetworksToVlans.Vlan(
+ Objects.toString(vlan.getAdditionalProperties().get("vlan-id-outer"), null)
+ )
).collect(toList())
);
}
@@ -138,8 +140,8 @@ public class AaiServiceInstanceStandardQueryController extends VidRestrictedBase
throw new GenericUncheckedException("Internal error while fetching Service Model: " + sdcModelUuid);
}
VidNotions.ModelCategory serviceModelCategory = serviceModel.getService().getVidNotions().getModelCategory();
- return serviceModelCategory.equals(VidNotions.ModelCategory.IS_5G_PROVIDER_NETWORK_MODEL) ||
- serviceModelCategory.equals(VidNotions.ModelCategory.IS_5G_FABRIC_CONFIGURATION_MODEL);
+ return (serviceModelCategory == VidNotions.ModelCategory.IS_5G_PROVIDER_NETWORK_MODEL) ||
+ (serviceModelCategory == VidNotions.ModelCategory.IS_5G_FABRIC_CONFIGURATION_MODEL);
}
protected static class VlansByNetworksHierarchy {
@@ -182,10 +184,10 @@ public class AaiServiceInstanceStandardQueryController extends VidRestrictedBase
}
private static class Vlan {
- public final String vlanIdInner;
+ public final String vlanIdOuter;
- private Vlan(String vlanIdInner) {
- this.vlanIdInner = vlanIdInner;
+ private Vlan(String vlanIdOuter) {
+ this.vlanIdOuter = vlanIdOuter;
}
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/AsyncInstantiationController.java b/vid-app-common/src/main/java/org/onap/vid/controller/AsyncInstantiationController.java
index 081e3c640..01b005c4b 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/AsyncInstantiationController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/AsyncInstantiationController.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,25 +20,28 @@
package org.onap.vid.controller;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.vid.exceptions.AccessDeniedException;
import org.onap.vid.exceptions.OperationNotAllowedException;
import org.onap.vid.model.ExceptionResponse;
import org.onap.vid.model.JobAuditStatus;
import org.onap.vid.model.ServiceInfo;
import org.onap.vid.model.serviceInstantiation.ServiceInstantiation;
import org.onap.vid.mso.MsoResponseWrapper2;
+import org.onap.vid.properties.Features;
+import org.onap.vid.roles.RoleProvider;
import org.onap.vid.services.AsyncInstantiationBusinessLogic;
import org.onap.vid.services.AuditService;
import org.onap.vid.utils.SystemPropertiesWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
+import org.togglz.core.manager.FeatureManager;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.UUID;
+import static org.onap.vid.utils.KotlinUtilsKt.JACKSON_OBJECT_MAPPER;
import static org.springframework.http.HttpStatus.METHOD_NOT_ALLOWED;
@@ -51,14 +54,18 @@ public class AsyncInstantiationController extends VidRestrictedBaseController {
protected final AsyncInstantiationBusinessLogic asyncInstantiationBL;
private final SystemPropertiesWrapper systemPropertiesWrapper;
- protected ObjectMapper objectMapper = new ObjectMapper();
+ private final RoleProvider roleProvider;
+
+ private final FeatureManager featureManager;
@Autowired
protected AuditService auditService;
@Autowired
- public AsyncInstantiationController(AsyncInstantiationBusinessLogic asyncInstantiationBL, SystemPropertiesWrapper systemPropertiesWrapper) {
+ public AsyncInstantiationController(AsyncInstantiationBusinessLogic asyncInstantiationBL, RoleProvider roleProvider, FeatureManager featureManager, SystemPropertiesWrapper systemPropertiesWrapper) {
this.asyncInstantiationBL = asyncInstantiationBL;
+ this.roleProvider = roleProvider;
+ this.featureManager = featureManager;
this.systemPropertiesWrapper = systemPropertiesWrapper;
}
@@ -82,14 +89,25 @@ public class AsyncInstantiationController extends VidRestrictedBaseController {
public MsoResponseWrapper2<List<String>> createBulkOfServices(@RequestBody ServiceInstantiation request, HttpServletRequest httpServletRequest) {
//Push to DB according the model
try {
- LOGGER.debug(EELFLoggerDelegate.debugLogger, "incoming ServiceInstantiation request: "+ objectMapper.writeValueAsString(request));
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "incoming ServiceInstantiation request: "+ JACKSON_OBJECT_MAPPER.writeValueAsString(request));
}
catch (Exception e) {
LOGGER.error(EELFLoggerDelegate.errorLogger, "failed to log incoming ServiceInstantiation request ", e);
}
String userId = new ControllersUtils(systemPropertiesWrapper).extractUserId(httpServletRequest);
- List<UUID> uuids = asyncInstantiationBL.pushBulkJob(request, userId);
+ throwExceptionIfAccessDenied(request, httpServletRequest, userId);
+ List<UUID> uuids = asyncInstantiationBL.pushBulkJob(request, userId);
+ return new MsoResponseWrapper2(200, uuids);
+ }
+
+
+
+ @RequestMapping(value = "retryJobWithChangedData/{jobId}", method = RequestMethod.POST)
+ public MsoResponseWrapper2<List<String>> retryJobWithChangedData(@RequestBody ServiceInstantiation request, @PathVariable(value="jobId") UUID jobId, HttpServletRequest httpServletRequest) {
+
+ String userId = new ControllersUtils(systemPropertiesWrapper).extractUserId(httpServletRequest);
+ List<UUID> uuids = asyncInstantiationBL.retryJob(request, jobId, userId);
return new MsoResponseWrapper2(200, uuids);
}
@@ -105,7 +123,7 @@ public class AsyncInstantiationController extends VidRestrictedBaseController {
@RequestMapping(value = "auditStatus/{jobId}", method = RequestMethod.GET)
public List<JobAuditStatus> getJobAuditStatus(HttpServletRequest request, @PathVariable(value="jobId") UUID jobId, @RequestParam(value="source") JobAuditStatus.SourceStatus source){
- return asyncInstantiationBL.getAuditStatuses(jobId, source);
+ return auditService.getAuditStatuses(jobId, source);
}
@RequestMapping(value = "auditStatus/{jobId}/mso", method = RequestMethod.GET)
@@ -114,7 +132,7 @@ public class AsyncInstantiationController extends VidRestrictedBaseController {
@RequestParam(value="requestId", required = false) UUID requestId,
@RequestParam(value="serviceInstanceId", required = false) UUID serviceInstanceId){
if (serviceInstanceId != null) {
- return auditService.getAuditStatusFromMsoByServiceInstanceId(jobId, serviceInstanceId);
+ return auditService.getAuditStatusFromMsoByInstanceId(JobAuditStatus.ResourceTypeFilter.SERVICE, serviceInstanceId, jobId);
}
if (requestId != null){
return auditService.getAuditStatusFromMsoByRequestId(jobId, requestId);
@@ -123,5 +141,36 @@ public class AsyncInstantiationController extends VidRestrictedBaseController {
}
+ @RequestMapping(value = "auditStatus/{type}/{instanceId}/mso", method = RequestMethod.GET)
+ public List<JobAuditStatus> getAuditStatusFromMsoByInstanceId(HttpServletRequest request,
+ @PathVariable(value="type") JobAuditStatus.ResourceTypeFilter resourceTypeFilter,
+ @PathVariable(value="instanceId") UUID instanceId) {
+ return auditService.getAuditStatusFromMsoByInstanceId(resourceTypeFilter, instanceId, null);
+ }
+
+ @RequestMapping(value = "/bulkForRetry/{jobId}", method = RequestMethod.GET)
+ public ServiceInstantiation getBulkForRetry(HttpServletRequest request, @PathVariable(value="jobId") UUID jobId) {
+ return asyncInstantiationBL.getBulkForRetry(jobId);
+ }
+
+ @RequestMapping(value = "retry/{jobId}", method = RequestMethod.POST)
+ public MsoResponseWrapper2<List<UUID>> retryJobRequest(HttpServletRequest httpServletRequest,
+ @PathVariable(value="jobId") UUID jobId) {
+
+ String userId = new ControllersUtils(systemPropertiesWrapper).extractUserId(httpServletRequest);
+ List<UUID> uuids = asyncInstantiationBL.retryJob(jobId, userId);
+ return new MsoResponseWrapper2(200, uuids);
+ }
+
+ @RequestMapping(value = "/auditStatusForRetry/{trackById}", method = RequestMethod.GET)
+ public JobAuditStatus getResourceAuditStatus(HttpServletRequest request, @PathVariable(value="trackById") String trackById) {
+ return auditService.getResourceAuditStatus(trackById);
+ }
+
+ private void throwExceptionIfAccessDenied(ServiceInstantiation request, HttpServletRequest httpServletRequest, String userId) {
+ if (featureManager.isActive(Features.FLAG_1906_INSTANTIATION_API_USER_VALIDATION) && !roleProvider.getUserRolesValidator(httpServletRequest).isServicePermitted(request.getGlobalSubscriberId(), request.getSubscriptionServiceType())) {
+ throw new AccessDeniedException(String.format("User %s is not allowed to make this request", userId));
+ }
+ }
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java b/vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java
index 8d5fbbdbb..20cf6f038 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java
@@ -56,8 +56,8 @@ public class MsoConfig {
@Bean
- public MsoBusinessLogic getMsoBusinessLogic(MsoInterface msoClient, FeatureManager featureManager){
- return new MsoBusinessLogicImpl(msoClient, featureManager);
+ public MsoBusinessLogic getMsoBusinessLogic(MsoInterface msoClient){
+ return new MsoBusinessLogicImpl(msoClient);
}
@Bean
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/MsoController.java b/vid-app-common/src/main/java/org/onap/vid/controller/MsoController.java
index db3a21910..fc718f0d2 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/MsoController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/MsoController.java
@@ -20,9 +20,9 @@
package org.onap.vid.controller;
+import static org.onap.vid.utils.KotlinUtilsKt.JACKSON_OBJECT_MAPPER;
import static org.onap.vid.utils.Logging.getMethodName;
-import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.List;
@@ -31,10 +31,14 @@ import javax.servlet.http.HttpServletResponse;
import org.onap.portalsdk.core.controller.RestrictedBaseController;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.vid.model.ExceptionResponse;
+import org.onap.vid.model.RequestReferencesContainer;
import org.onap.vid.model.SoftDeleteRequest;
import org.onap.vid.mso.MsoBusinessLogic;
import org.onap.vid.mso.MsoResponseWrapper;
import org.onap.vid.mso.MsoResponseWrapper2;
+import org.onap.vid.mso.RestMsoImplementation;
+import org.onap.vid.mso.RestObject;
+import org.onap.vid.mso.rest.MsoRestClientNew;
import org.onap.vid.mso.rest.Request;
import org.onap.vid.mso.rest.RequestDetails;
import org.onap.vid.mso.rest.RequestDetailsWrapper;
@@ -82,11 +86,13 @@ public class MsoController extends RestrictedBaseController {
public static final String START_LOG = " start";
private final MsoBusinessLogic msoBusinessLogic;
+ private final RestMsoImplementation restMso;
private final CloudOwnerService cloudOwnerService;
@Autowired
- public MsoController(MsoBusinessLogic msoBusinessLogic, CloudOwnerService cloudOwnerService) {
+ public MsoController(MsoBusinessLogic msoBusinessLogic, MsoRestClientNew msoClientInterface, CloudOwnerService cloudOwnerService) {
this.msoBusinessLogic = msoBusinessLogic;
+ this.restMso = msoClientInterface;
this.cloudOwnerService = cloudOwnerService;
}
@@ -678,30 +684,35 @@ public class MsoController extends RestrictedBaseController {
@RequestMapping(value = "/mso_activate_fabric_configuration/{serviceInstanceId}", method = RequestMethod.POST)
public MsoResponseWrapper2 activateFabricConfiguration(
- @PathVariable("serviceInstanceId") String serviceInstanceId,
- @RequestBody RequestDetails requestDetails) {
+ @PathVariable("serviceInstanceId") String serviceInstanceId ,
+ @RequestBody RequestDetails requestDetails) {
String methodName = "activateFabricConfiguration";
LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
- return msoBusinessLogic.activateFabricConfiguration(serviceInstanceId, requestDetails);
+ String path = msoBusinessLogic.getActivateFabricConfigurationPath(serviceInstanceId);
+ RestObject<RequestReferencesContainer> msoResponse = restMso.PostForObject(requestDetails, path, RequestReferencesContainer.class);
+
+ return new MsoResponseWrapper2<>(msoResponse);
}
@RequestMapping(value = "/mso_vfmodule_soft_delete/{serviceInstanceId}/{vnfInstanceId}/{vfModuleInstanceId}", method = RequestMethod.POST)
public MsoResponseWrapper2 deactivateAndCloudDelete(
- @PathVariable("serviceInstanceId") String serviceInstanceId,
- @PathVariable("vnfInstanceId") String vnfInstanceId,
- @PathVariable("vfModuleInstanceId") String vfModuleInstanceId,
- @RequestBody SoftDeleteRequest softDeleteRequest) {
+ @PathVariable("serviceInstanceId") String serviceInstanceId,
+ @PathVariable("vnfInstanceId") String vnfInstanceId,
+ @PathVariable("vfModuleInstanceId") String vfModuleInstanceId,
+ @RequestBody SoftDeleteRequest softDeleteRequest) {
String methodName = "deactivateAndCloudDelete";
LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
+ String path = msoBusinessLogic.getDeactivateAndCloudDeletePath(serviceInstanceId, vnfInstanceId, vfModuleInstanceId);
RequestDetails requestDetails = msoBusinessLogic.buildRequestDetailsForSoftDelete(softDeleteRequest);
cloudOwnerService.enrichRequestWithCloudOwner(requestDetails);
- return msoBusinessLogic
- .deactivateAndCloudDelete(serviceInstanceId, vnfInstanceId, vfModuleInstanceId, requestDetails);
+ RestObject<RequestReferencesContainer> msoResponse = restMso.PostForObject(new org.onap.vid.changeManagement.RequestDetailsWrapper<>(requestDetails), path, RequestReferencesContainer.class);
+
+ return new MsoResponseWrapper2<>(msoResponse);
}
/**
@@ -723,7 +734,7 @@ public class MsoController extends RestrictedBaseController {
exceptionResponse.setException(e.getClass().toString().replaceFirst("^.*\\.", ""));
exceptionResponse.setMessage(e.getMessage());
- response.getWriter().write(new ObjectMapper().writeValueAsString(exceptionResponse));
+ response.getWriter().write(JACKSON_OBJECT_MAPPER.writeValueAsString(exceptionResponse));
response.flushBuffer();
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/WebConfig.java b/vid-app-common/src/main/java/org/onap/vid/controller/WebConfig.java
index 8d55c62c6..6f4ce4ddb 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/WebConfig.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/WebConfig.java
@@ -21,6 +21,8 @@
package org.onap.vid.controller;
+import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;
+
import static org.apache.commons.lang3.StringUtils.isEmpty;
import com.fasterxml.jackson.core.JsonProcessingException;
@@ -29,6 +31,7 @@ import io.joshworks.restclient.http.mapper.ObjectMapper;
import java.io.File;
import java.io.IOException;
import javax.servlet.ServletContext;
+import java.util.concurrent.Executors;
import org.onap.portalsdk.core.util.SystemProperties;
import org.onap.vid.aai.AaiClient;
import org.onap.vid.aai.AaiClientInterface;
@@ -54,6 +57,7 @@ import org.onap.vid.asdc.rest.SdcRestClient;
import org.onap.vid.client.SyncRestClient;
import org.onap.vid.client.SyncRestClientInterface;
import org.onap.vid.properties.AsdcClientConfiguration;
+import org.onap.vid.properties.VidProperties;
import org.onap.vid.scheduler.SchedulerService;
import org.onap.vid.scheduler.SchedulerServiceImpl;
import org.onap.vid.services.AAIServiceTree;
@@ -73,6 +77,12 @@ import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+import javax.servlet.ServletContext;
+import java.io.File;
+import java.io.IOException;
+import java.util.concurrent.ExecutorService;
+
@EnableSwagger2
@Configuration
public class WebConfig {
@@ -95,8 +105,8 @@ public class WebConfig {
@Bean
public AaiService getAaiService(AaiClientInterface aaiClient, AaiOverTLSClientInterface aaiOverTLSClient,
- AaiResponseTranslator aaiResponseTranslator, AAITreeNodeBuilder aaiTreeNode, AAIServiceTree aaiServiceTree) {
- return new AaiServiceImpl(aaiClient, aaiOverTLSClient, aaiResponseTranslator, aaiTreeNode, aaiServiceTree);
+ AaiResponseTranslator aaiResponseTranslator, AAITreeNodeBuilder aaiTreeNode, AAIServiceTree aaiServiceTree, ExecutorService executorService) {
+ return new AaiServiceImpl(aaiClient, aaiOverTLSClient, aaiResponseTranslator, aaiTreeNode, aaiServiceTree, executorService);
}
@Bean
@@ -223,4 +233,10 @@ public class WebConfig {
.paths(PathSelectors.any())
.build();
}
+
+ @Bean
+ public ExecutorService executorService() {
+ int threadsCount = defaultIfNull(Integer.parseInt(SystemProperties.getProperty(VidProperties.VID_THREAD_COUNT)), 1);
+ return Executors.newFixedThreadPool(threadsCount);
+ }
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/dal/AsyncInstantiationRepository.kt b/vid-app-common/src/main/java/org/onap/vid/dal/AsyncInstantiationRepository.kt
new file mode 100644
index 000000000..79c7297a3
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/dal/AsyncInstantiationRepository.kt
@@ -0,0 +1,147 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.vid.dal
+
+import org.onap.portalsdk.core.domain.support.DomainVo
+import org.onap.portalsdk.core.service.DataAccessService
+import org.onap.vid.dao.JobRequest
+import org.onap.vid.exceptions.GenericUncheckedException
+import org.onap.vid.exceptions.NotFoundException
+import org.onap.vid.job.Job
+import org.onap.vid.model.JobAuditStatus
+import org.onap.vid.model.ResourceInfo
+import org.onap.vid.model.ServiceInfo
+import org.onap.vid.model.serviceInstantiation.ServiceInstantiation
+import org.onap.vid.utils.DaoUtils
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.stereotype.Repository
+import java.sql.Timestamp
+import java.time.LocalDateTime
+import java.util.*
+import kotlin.collections.HashMap
+
+@Repository
+class AsyncInstantiationRepository @Autowired constructor(val dataAccessService:DataAccessService) {
+
+ fun addJobRequest(jobUuid: UUID, request:ServiceInstantiation) {
+ save(JobRequest(jobUuid, request))
+ }
+
+ fun getJobRequest(jobUuid: UUID):ServiceInstantiation? {
+ return getSingleItem(JobRequest::class.java, "JOB_ID", jobUuid).request
+ }
+
+ fun saveResourceInfo(resource:ResourceInfo) {
+ save(resource)
+ }
+
+ fun getResourceInfoByRootJobId(rootJobId: UUID): Map<String, ResourceInfo> {
+ val resourceInfoList:List<ResourceInfo> = getResultList(ResourceInfo::class.java, "ROOT_JOB_ID", rootJobId)
+
+ if (resourceInfoList.isEmpty()) {
+ throw GenericUncheckedException("Failed to retrieve resource info with rootJobId " + rootJobId + " from ResourceInfo table. no resource found")
+ }
+ return resourceInfoList.fold(HashMap(), { accumulator, item ->
+ accumulator.put(item.trackById, item); accumulator})
+ }
+
+ fun getResourceInfoByTrackId(trackById: String):ResourceInfo {
+ return getSingleItem(ResourceInfo::class.java, "TRACK_BY_ID", trackById)
+ }
+
+ fun saveServiceInfo(serviceInfo: ServiceInfo) {
+ save(serviceInfo)
+ }
+
+ fun getServiceInfoByJobId(jobUuid: UUID): ServiceInfo {
+ return getSingleItem(ServiceInfo::class.java, "jobId", jobUuid)
+ }
+
+ fun getServiceInfoByTemplateIdAndJobStatus(templateId: UUID, jobStatus: Job.JobStatus): List<ServiceInfo> {
+ return getResultList(ServiceInfo::class.java, mapOf("templateId" to templateId, "jobStatus" to jobStatus), "AND")
+ }
+
+ fun getAllServicesInfo(): List<ServiceInfo> {
+ return dataAccessService.getList(ServiceInfo::class.java, filterByCreationDateAndNotDeleted(), orderByCreatedDateAndStatus(), null) as List<ServiceInfo>
+ }
+
+ private fun filterByCreationDateAndNotDeleted(): String {
+ val minus3Months = LocalDateTime.now().minusMonths(3)
+ val filterDate = Timestamp.valueOf(minus3Months)
+ return " WHERE" +
+ " hidden = false" +
+ " and deleted_at is null" + // don't fetch deleted
+
+ " and created >= '" + filterDate + "' "
+ }
+
+ private fun orderByCreatedDateAndStatus(): String {
+ return " createdBulkDate DESC ,\n" +
+ " (CASE jobStatus\n" +
+ " WHEN 'COMPLETED' THEN 0\n" +
+ " WHEN 'FAILED' THEN 0\n" +
+ " WHEN 'COMPLETED_WITH_ERRORS' THEN 0\n" +
+ " WHEN 'IN_PROGRESS' THEN 1\n" +
+ " WHEN 'PAUSE' THEN 2\n" +
+ " WHEN 'PENDING' THEN 3\n" +
+ " WHEN 'STOPPED' THEN 3 END),\n" +
+ " statusModifiedDate "
+ }
+
+ fun getAuditStatuses(jobUUID: UUID, source: JobAuditStatus.SourceStatus): List<JobAuditStatus> {
+ // order by ORDINAL.
+ // CREATED_DATE is kept for backward compatibility: when all Ordinals are zero
+ return getResultList(JobAuditStatus::class.java, mapOf("SOURCE" to source, "JOB_ID" to jobUUID), "AND", " ORDINAL, CREATED_DATE ")
+ }
+
+ fun addJobAudiStatus(jobAuditStatus:JobAuditStatus) {
+ save(jobAuditStatus)
+ }
+
+ private fun <T: DomainVo> save(item:T) {
+ dataAccessService.saveDomainObject(item, DaoUtils.getPropsMap())
+ }
+
+ private fun <T> getSingleItem(className:Class<T>, filterKey:String, filterValue:Any): T {
+ val resultList:List<T> = getResultList(className, filterKey, filterValue)
+ if (resultList.size < 1) {
+ throw NotFoundException("Failed to retrieve $className with $filterKey $filterValue from table. no resource found")
+ }else if (resultList.size > 1) {
+ throw GenericUncheckedException("Failed to retrieve $className with $filterKey $filterValue from table. found more than 1 resources")
+ }
+ return resultList[0]
+ }
+
+ private fun <T> getResultList(className:Class<T>, filterKey:String, filterValue:Any): List<T> {
+ return getResultList(className, mapOf(filterKey to filterValue), "AND", null)
+ }
+
+ private fun <T> getResultList(className:Class<T>, filters: Map<String, Any>, conditionType: String): List<T> {
+ return getResultList(className, filters, conditionType, null)
+ }
+
+ private fun <T> getResultList(className:Class<T>, filters: Map<String, Any>, conditionType: String, orderBy: String?): List<T> {
+ var condition:String = filters
+ .map{f -> f.key + " = '" + f.value + "'"}
+ .joinToString(" $conditionType ")
+ return dataAccessService.getList(className, " WHERE $condition", orderBy, null) as List<T>
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/dao/JobRequest.java b/vid-app-common/src/main/java/org/onap/vid/dao/JobRequest.java
new file mode 100644
index 000000000..eb4035836
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/dao/JobRequest.java
@@ -0,0 +1,111 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.vid.dao;
+
+import static org.onap.vid.utils.KotlinUtilsKt.JACKSON_OBJECT_MAPPER;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import java.io.IOException;
+import java.util.Objects;
+import java.util.UUID;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import org.hibernate.annotations.DynamicUpdate;
+import org.hibernate.annotations.SelectBeforeUpdate;
+import org.hibernate.annotations.Type;
+import org.onap.vid.model.VidBaseEntity;
+import org.onap.vid.model.serviceInstantiation.ServiceInstantiation;
+
+
+@DynamicUpdate
+@SelectBeforeUpdate
+@Entity
+@Table(name = "vid_job_request")
+public class JobRequest extends VidBaseEntity {
+
+ private UUID jobId;
+ private ServiceInstantiation request;
+
+
+ public JobRequest(UUID jobId, ServiceInstantiation request) {
+ this.jobId = jobId;
+ this.request = request;
+ }
+
+ public JobRequest() {
+ }
+
+ @Id
+ @Column(name = "JOB_ID", columnDefinition = "CHAR(36)")
+ @Type(type = "org.hibernate.type.UUIDCharType")
+ public UUID getJobId() {
+ return jobId;
+ }
+
+ public void setJobId(UUID jobId) {
+ this.jobId = jobId;
+ }
+
+ @Transient
+ public ServiceInstantiation getRequest() {
+ return request;
+ }
+
+ public void setRequest(ServiceInstantiation request) {
+ this.request = request;
+ }
+
+ //the columnDefinition is used only in UT
+ @Column(name = "REQUEST", columnDefinition = "VARCHAR(30000)")
+ public String getRequestRaw() {
+ try {
+ return JACKSON_OBJECT_MAPPER.writeValueAsString(request);
+ } catch (JsonProcessingException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void setRequestRaw(String raw) {
+ try {
+ this.request = JACKSON_OBJECT_MAPPER.readValue(raw, ServiceInstantiation.class);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof JobRequest)) return false;
+ JobRequest that = (JobRequest) o;
+ return Objects.equals(getJobId(), that.getJobId()) &&
+ Objects.equals(getRequest(), that.getRequest());
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(getJobId(), getRequest());
+ }
+}
+
diff --git a/vid-app-common/src/main/java/org/onap/vid/exceptions/AbortingException.java b/vid-app-common/src/main/java/org/onap/vid/exceptions/AbortingException.java
new file mode 100644
index 000000000..22c312513
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/exceptions/AbortingException.java
@@ -0,0 +1,28 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.vid.exceptions;
+
+public class AbortingException extends RuntimeException {
+
+ public AbortingException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/ResourceInProgressStatusCommand.java b/vid-app-common/src/main/java/org/onap/vid/exceptions/AccessDeniedException.java
index 123d38bd0..e82bfbc9d 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/ResourceInProgressStatusCommand.java
+++ b/vid-app-common/src/main/java/org/onap/vid/exceptions/AccessDeniedException.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,34 +18,11 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.vid.job.command;
+package org.onap.vid.exceptions;
-import org.onap.vid.job.Job;
-import org.onap.vid.job.NextCommand;
-import org.onap.vid.job.impl.JobSharedData;
-import org.springframework.beans.factory.config.ConfigurableBeanFactory;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-
-@Component
-@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-public class ResourceInProgressStatusCommand extends BaseInProgressStatusCommand {
-
- public ResourceInProgressStatusCommand() {
- }
-
- ResourceInProgressStatusCommand(JobSharedData sharedData, String requestId, String instanceId) {
- init(sharedData, requestId, instanceId);
- }
-
- @Override
- protected ExpiryChecker getExpiryChecker() {
- return x->false;
- }
-
- @Override
- protected NextCommand processJobStatus(Job.JobStatus jobStatus) {
- return new NextCommand(jobStatus, this);
+public class AccessDeniedException extends GenericUncheckedException {
+ public AccessDeniedException(String message) {
+ super(message);
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/exceptions/TryAgainException.java b/vid-app-common/src/main/java/org/onap/vid/exceptions/TryAgainException.java
new file mode 100644
index 000000000..f46e7e3b5
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/exceptions/TryAgainException.java
@@ -0,0 +1,28 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.vid.exceptions;
+
+public class TryAgainException extends RuntimeException {
+
+ public TryAgainException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/Job.java b/vid-app-common/src/main/java/org/onap/vid/job/Job.java
index 3825c2cde..197e03b7b 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/Job.java
+++ b/vid-app-common/src/main/java/org/onap/vid/job/Job.java
@@ -7,9 +7,9 @@
* 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.
@@ -23,8 +23,11 @@ package org.onap.vid.job;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.onap.vid.job.impl.JobSharedData;
+import java.util.List;
import java.util.Map;
import java.util.UUID;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
public interface Job {
@@ -63,7 +66,9 @@ public interface Job {
STOPPED(true, true),
COMPLETED_WITH_ERRORS(true, true),
COMPLETED_WITH_NO_ACTION(true, false),
- CREATING(false);
+ CREATING(false),
+ PENDING_RESOURCE(false),
+ ;
private final Boolean finalStatus;
public Boolean isFinal(){return finalStatus;}
@@ -83,5 +88,7 @@ public interface Job {
this.failure = failure;
}
+ public static final List<JobStatus> FINAL_STATUS = Stream.of(JobStatus.values()).filter(JobStatus::isFinal).collect(Collectors.toList());
+
}
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/JobAdapter.java b/vid-app-common/src/main/java/org/onap/vid/job/JobAdapter.java
index cd2ab8e4b..53b8a3028 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/JobAdapter.java
+++ b/vid-app-common/src/main/java/org/onap/vid/job/JobAdapter.java
@@ -7,9 +7,9 @@
* 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.
@@ -32,9 +32,9 @@ import java.util.UUID;
public interface JobAdapter {
JobModel toModel(Job job);
- Job createServiceInstantiationJob(JobType jobType, AsyncJobRequest request, UUID templateId, String userId, String optimisticUniqueServiceInstanceName, Integer indexInBulk);
+ Job createServiceInstantiationJob(JobType jobType, AsyncJobRequest request, UUID templateId, String userId, String testApi, String optimisticUniqueServiceInstanceName, Integer indexInBulk);
- Job createChildJob(JobType jobType, Job.JobStatus jobStatus, AsyncJobRequest request, JobSharedData parentSharedData, Map<String, Object> jobData);
+ Job createChildJob(JobType jobType, AsyncJobRequest request, JobSharedData parentSharedData, Map<String, Object> jobData, int indexInBulk);
// Marks types that are an AsyncJob payload
interface AsyncJobRequest {
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/JobCommand.java b/vid-app-common/src/main/java/org/onap/vid/job/JobCommand.java
index 9d49df003..dfeacae66 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/JobCommand.java
+++ b/vid-app-common/src/main/java/org/onap/vid/job/JobCommand.java
@@ -7,9 +7,9 @@
* 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.
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/JobException.java b/vid-app-common/src/main/java/org/onap/vid/job/JobException.java
index 0ae0b1b98..eb2fecc8e 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/JobException.java
+++ b/vid-app-common/src/main/java/org/onap/vid/job/JobException.java
@@ -7,9 +7,9 @@
* 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.
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/JobType.java b/vid-app-common/src/main/java/org/onap/vid/job/JobType.java
index 7576c430f..b0cfa7a58 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/JobType.java
+++ b/vid-app-common/src/main/java/org/onap/vid/job/JobType.java
@@ -7,9 +7,9 @@
* 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.
@@ -32,26 +32,20 @@ public enum JobType {
HttpCall(HttpCallCommand.class),
AggregateState(AggregateStateCommand.class),
- ServiceInstantiation(MacroServiceInstantiationCommand.class),
- MacroServiceInstantiation(MacroServiceInstantiationCommand.class),
- ALaCarteServiceInstantiation(ALaCarteServiceInstantiationCommand.class),
+ ServiceInstantiation(MacroServiceCommand.class),
+ MacroServiceInstantiation(MacroServiceCommand.class),
+ ALaCarteServiceInstantiation(ALaCarteServiceCommand.class),
ALaCarteService(ALaCarteServiceCommand.class),
- VnfInstantiation(VnfInstantiationCommand.class),
- VfmoduleInstantiation(VfmoduleInstantiationCommand.class),
- VolumeGroupInstantiation(VolumeGroupInstantiationCommand.class),
- VolumeGroupInProgressStatus(VolumeGroupInProgressStatusCommand.class),
- NetworkInstantiation(NetworkInstantiationCommand.class),
- InstanceGroupInstantiation(InstanceGroupInstantiationCommand.class),
+ VnfInstantiation(VnfCommand.class),
+ VfmoduleInstantiation(VfmoduleCommand.class),
+ VolumeGroupInstantiation(VolumeGroupCommand.class),
+ NetworkInstantiation(NetworkCommand.class),
InstanceGroup(InstanceGroupCommand.class),
- InProgressStatus(ServiceInProgressStatusCommand.class),
- ResourceInProgressStatus(ResourceInProgressStatusCommand.class),
- VnfInProgressStatus(VnfInProgressStatusCommand.class),
- Watching(WatchingCommand.class),
- WatchingBaseModule(WatchingCommandBaseModule.class),
+ InstanceGroupMember(InstanceGroupMemberCommand.class),
NoOp(NoOpCommand.class);
private static final Map<Class, JobType> REVERSE_MAP = Stream.of(values())
- .filter(not(jobType -> jobType.equals(ServiceInstantiation)))
+ .filter(not(jobType -> (jobType == ServiceInstantiation) || (jobType == ALaCarteServiceInstantiation)))
.collect(Collectors.toMap(t -> t.getCommandClass(), t -> t));
private final Class commandClass;
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/JobsBrokerService.java b/vid-app-common/src/main/java/org/onap/vid/job/JobsBrokerService.java
index 5da3b309a..6c3eeb9a4 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/JobsBrokerService.java
+++ b/vid-app-common/src/main/java/org/onap/vid/job/JobsBrokerService.java
@@ -7,9 +7,9 @@
* 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.
@@ -40,4 +40,5 @@ public interface JobsBrokerService {
boolean mute(UUID jobId);
+ void deleteOldFinalJobs(long secondsAgo);
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/NextCommand.java b/vid-app-common/src/main/java/org/onap/vid/job/NextCommand.java
index 966158fb9..298a3f439 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/NextCommand.java
+++ b/vid-app-common/src/main/java/org/onap/vid/job/NextCommand.java
@@ -7,9 +7,9 @@
* 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.
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/ALaCarteServiceCommand.kt b/vid-app-common/src/main/java/org/onap/vid/job/command/ALaCarteServiceCommand.kt
index 29897aceb..9bef3c11b 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/ALaCarteServiceCommand.kt
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/ALaCarteServiceCommand.kt
@@ -7,9 +7,9 @@
* 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.
@@ -21,14 +21,16 @@
package org.onap.vid.job.command
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate
-import org.onap.vid.changeManagement.RequestDetailsWrapper
-import org.onap.vid.job.*
-import org.onap.vid.model.Action
+import org.onap.vid.job.Job
+import org.onap.vid.job.JobAdapter
+import org.onap.vid.job.JobCommand
+import org.onap.vid.job.JobsBrokerService
+import org.onap.vid.model.serviceInstantiation.BaseResource
import org.onap.vid.model.serviceInstantiation.ServiceInstantiation
import org.onap.vid.mso.RestMsoImplementation
-import org.onap.vid.mso.model.ServiceDeletionRequestDetails
import org.onap.vid.properties.VidProperties
import org.onap.vid.services.AsyncInstantiationBusinessLogic
+import org.onap.vid.services.AuditService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.config.ConfigurableBeanFactory
import org.springframework.context.annotation.Scope
@@ -38,6 +40,8 @@ import java.time.ZonedDateTime
import java.time.temporal.ChronoUnit
import java.util.*
+const val UNIQUE_INSTANCE_NAME = "optimisticUniqueServiceInstanceName"
+
class ServiceExpiryChecker : ExpiryChecker {
override fun isExpired(jobStartTime: ZonedDateTime?): Boolean {
@@ -48,22 +52,20 @@ class ServiceExpiryChecker : ExpiryChecker {
}
}
-
@Component
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
class ALaCarteServiceCommand @Autowired constructor(
inProgressStatusService: InProgressStatusService,
watchChildrenJobsBL: WatchChildrenJobsBL,
private val asyncInstantiationBL: AsyncInstantiationBusinessLogic,
- private val jobsBrokerService: JobsBrokerService,
+ jobsBrokerService: JobsBrokerService,
+ private val msoRequestBuilder: MsoRequestBuilder,
msoResultHandlerService: MsoResultHandlerService,
- private val jobAdapter: JobAdapter,
- restMso: RestMsoImplementation
-) : ResourceCommand(restMso, inProgressStatusService, msoResultHandlerService, watchChildrenJobsBL), JobCommand {
-
- override fun getExpiryChecker(): ExpiryChecker {
- return ServiceExpiryChecker();
- }
+ jobAdapter: JobAdapter,
+ restMso: RestMsoImplementation,
+ auditService: AuditService
+) : RootServiceCommand(restMso, inProgressStatusService, msoResultHandlerService,
+ watchChildrenJobsBL, jobsBrokerService, jobAdapter, asyncInstantiationBL, auditService, msoRequestBuilder), JobCommand {
companion object {
private val LOGGER = EELFLoggerDelegate.getLogger(ALaCarteServiceCommand::class.java)
@@ -74,69 +76,27 @@ class ALaCarteServiceCommand @Autowired constructor(
}
override fun createChildren(): Job.JobStatus {
- val dataForChild = buildDataForChild(getRequest())//.plus(ACTION_PHASE to actionPhase)
-
- val childJobType = when (actionPhase) {
- Action.Create -> JobType.InstanceGroupInstantiation
- Action.Delete -> JobType.InstanceGroup
- else -> return Job.JobStatus.COMPLETED
- }
+ val dataForChild = buildDataForChild(getRequest(), actionPhase)
- childJobs = getRequest().vnfGroups
- .map { jobAdapter.createChildJob(childJobType, Job.JobStatus.CREATING, it.value, sharedData, dataForChild) }
- .map { jobsBrokerService.add(it) }
- .map { it.toString() }
+ childJobs = pushChildrenJobsToBroker(getRequest().children, dataForChild)
return Job.JobStatus.COMPLETED_WITH_NO_ACTION
}
- private fun buildDataForChild(request: ServiceInstantiation): Map<String, Any> {
- val commandParentData = CommandParentData()
- commandParentData.addInstanceId(CommandParentData.CommandDataKey.SERVICE_INSTANCE_ID, request.instanceId)
+ override fun addMyselfToChildrenData(commandParentData: CommandParentData, request: BaseResource) {
+ val instanceId = getActualInstanceId(request)
+ commandParentData.addInstanceId(CommandParentData.CommandDataKey.SERVICE_INSTANCE_ID, instanceId)
commandParentData.addModelInfo(CommandParentData.CommandDataKey.SERVICE_MODEL_INFO, request.modelInfo)
- return commandParentData.parentData
}
- override fun planCreateMyselfRestCall(commandParentData: CommandParentData, request: JobAdapter.AsyncJobRequest, userId: String): MsoRestCallPlan {
- TODO("not implemented")
- }
-
- override fun planDeleteMyselfRestCall(commandParentData: CommandParentData, request: JobAdapter.AsyncJobRequest, userId: String): MsoRestCallPlan {
- val requestDetailsWrapper = generateServiceDeletionRequest()
- val path = asyncInstantiationBL.getServiceDeletionPath(getRequest().instanceId)
- return MsoRestCallPlan(HttpMethod.DELETE, path, Optional.of(requestDetailsWrapper), Optional.empty(),
- "delete instance with id ${getRequest().instanceId}")
-
- }
+ override fun planCreateMyselfRestCall(commandParentData: CommandParentData, request: JobAdapter.AsyncJobRequest, userId: String, testApi: String?): MsoRestCallPlan {
+ val instantiatePath = asyncInstantiationBL.getServiceInstantiationPath(request as ServiceInstantiation)
- override fun handleInProgressStatus(jobStatus: Job.JobStatus): Job.JobStatus {
- if (jobStatus==Job.JobStatus.FAILED) {
- asyncInstantiationBL.handleFailedInstantiation(sharedData.jobUuid)
- return jobStatus
- }
+ val requestDetailsWrapper = msoRequestBuilder.generateALaCarteServiceInstantiationRequest(
+ request, optimisticUniqueServiceInstanceName, userId)
- asyncInstantiationBL.updateServiceInfoAndAuditStatus(sharedData.jobUuid, jobStatus)
- return if (jobStatus == Job.JobStatus.PAUSE) Job.JobStatus.IN_PROGRESS else jobStatus
- }
-
-
- private fun generateServiceDeletionRequest(): RequestDetailsWrapper<ServiceDeletionRequestDetails> {
- return asyncInstantiationBL.generateALaCarteServiceDeletionRequest(
- sharedData.jobUuid, getRequest(), sharedData.userId
- )
- }
-
- override fun getExternalInProgressStatus() = Job.JobStatus.IN_PROGRESS
-
- override fun isServiceCommand(): Boolean = true
-
- override fun onFinal(jobStatus: Job.JobStatus) {
- asyncInstantiationBL.updateServiceInfoAndAuditStatus(sharedData.jobUuid, jobStatus)
- }
+ val actionDescription = "create service instance"
- override fun onInitial(phase: Action) {
- if (phase== Action.Delete) {
- asyncInstantiationBL.updateServiceInfoAndAuditStatus(sharedData.jobUuid, Job.JobStatus.IN_PROGRESS)
- }
+ return MsoRestCallPlan(HttpMethod.POST, instantiatePath, Optional.of(requestDetailsWrapper), Optional.empty(), actionDescription)
}
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/AggregateStateCommand.java b/vid-app-common/src/main/java/org/onap/vid/job/command/AggregateStateCommand.java
index e64c304cb..34861d0ef 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/AggregateStateCommand.java
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/AggregateStateCommand.java
@@ -7,9 +7,9 @@
* 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.
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/BaseInProgressStatusCommand.java b/vid-app-common/src/main/java/org/onap/vid/job/command/BaseInProgressStatusCommand.java
deleted file mode 100644
index d21973dc2..000000000
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/BaseInProgressStatusCommand.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * 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.vid.job.command;
-
-import com.google.common.collect.ImmutableMap;
-import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.onap.vid.job.*;
-import org.onap.vid.job.impl.JobSharedData;
-import org.onap.vid.mso.RestMsoImplementation;
-import org.onap.vid.mso.RestObject;
-import org.onap.vid.mso.rest.AsyncRequestStatus;
-import org.onap.vid.services.AsyncInstantiationBusinessLogic;
-import org.togglz.core.manager.FeatureManager;
-
-import javax.inject.Inject;
-import java.util.Map;
-
-public abstract class BaseInProgressStatusCommand extends BaseInstantiationCommand implements JobCommand {
- private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(BaseInProgressStatusCommand.class);
-
- @Inject
- protected AsyncInstantiationBusinessLogic asyncInstantiationBL;
-
- @Inject
- protected JobsBrokerService jobsBrokerService;
-
- @Inject
- protected JobAdapter jobAdapter;
-
- @Inject
- protected RestMsoImplementation restMso;
-
- @Inject
- protected FeatureManager featureManager;
-
- @Inject
- protected InProgressStatusService inProgressStatusService;
-
-
- protected String requestId;
-
- protected String instanceId;
-
-
- @Override
- public NextCommand call() {
-
- try {
- Job.JobStatus jobStatus = inProgressStatusService.call(getExpiryChecker(), getSharedData(), requestId);
- return processJobStatus(jobStatus);
- } catch (javax.ws.rs.ProcessingException e) {
- // Retry when we can't connect MSO during getStatus
- LOGGER.error(EELFLoggerDelegate.errorLogger, "Cannot get orchestration status for {}, will retry: {}", requestId, e, e);
- return new NextCommand(Job.JobStatus.IN_PROGRESS, this);
- } catch (InProgressStatusService.BadResponseFromMso e) {
- return handleFailedMsoResponse(e.getMsoResponse());
- }
- catch (RuntimeException e) {
- LOGGER.error(EELFLoggerDelegate.errorLogger, "Cannot get orchestration status for {}, stopping: {}", requestId, e, e);
- return new NextCommand(Job.JobStatus.STOPPED, this);
- }
- }
-
- protected abstract ExpiryChecker getExpiryChecker();
-
- abstract NextCommand processJobStatus(Job.JobStatus jobStatus);
-
- private NextCommand handleFailedMsoResponse(RestObject<AsyncRequestStatus> msoResponse) {
- inProgressStatusService.handleFailedMsoResponse(getSharedData().getJobUuid(), requestId, msoResponse);
- return new NextCommand(Job.JobStatus.IN_PROGRESS, this);
- }
-
- @Override
- public BaseInProgressStatusCommand init(JobSharedData sharedData, Map<String, Object> commandData) {
- return init(sharedData, (String) commandData.get("requestId"), (String) commandData.get("instanceId"));
- }
-
-
- protected BaseInProgressStatusCommand init(JobSharedData sharedData,
- String requestId,
- String instanceId) {
- init(sharedData);
- this.requestId = requestId;
- this.instanceId = instanceId;
- return this;
- }
-
- @Override
- public Map<String, Object> getData() {
- return ImmutableMap.of(
- "requestId", requestId,
- "instanceId", instanceId
- );
- }
-
-
-}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/BaseRootCommand.java b/vid-app-common/src/main/java/org/onap/vid/job/command/BaseRootCommand.java
deleted file mode 100644
index 4b81a9412..000000000
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/BaseRootCommand.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * 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.vid.job.command;
-
-import org.onap.vid.job.NextCommand;
-import org.onap.vid.job.impl.JobSharedData;
-import org.onap.vid.model.RequestReferencesContainer;
-import org.onap.vid.model.serviceInstantiation.ServiceInstantiation;
-import org.onap.vid.mso.RestObject;
-
-import javax.inject.Inject;
-
-
-public abstract class BaseRootCommand extends CommandBase{
-
- @Inject
- private MsoResultHandlerService msoResultHandlerService;
-
- @Override
- protected CommandBase init(JobSharedData sharedData) {
- super.init(sharedData);
- return this;
- }
-
- protected ServiceInstantiation getRequest() {
- return msoResultHandlerService.getRequest(getSharedData());
- }
-
- protected NextCommand handleRootResponse(RestObject<RequestReferencesContainer> msoResponse){
- MsoResult msoResult = msoResultHandlerService.handleRootResponse(getSharedData().getJobUuid(), msoResponse);
- return new NextCommand(msoResult.getJobStatus(),
- (msoResult.getMsoResourceIds()!=null) ?
- new ServiceInProgressStatusCommand(getSharedData(), msoResult.getMsoResourceIds()) :
- null
- );
-
- }
-
- protected NextCommand handleCommandFailed() {
- return new NextCommand(msoResultHandlerService.handleRootCommandFailed(getSharedData().getJobUuid()).getJobStatus());
- }
-
-}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/BaseWatchingCommand.java b/vid-app-common/src/main/java/org/onap/vid/job/command/BaseWatchingCommand.java
deleted file mode 100644
index a0b7cd784..000000000
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/BaseWatchingCommand.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * 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.vid.job.command;
-
-import org.apache.commons.lang3.ObjectUtils;
-import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.onap.vid.job.Job;
-import org.onap.vid.job.JobCommand;
-import org.onap.vid.job.NextCommand;
-import org.onap.vid.job.impl.JobSharedData;
-import org.onap.vid.services.AsyncInstantiationBusinessLogic;
-
-import javax.inject.Inject;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public abstract class BaseWatchingCommand extends BaseInstantiationCommand implements JobCommand {
-
- private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(BaseWatchingCommand.class);
-
- @Inject
- protected AsyncInstantiationBusinessLogic asyncInstantiationBL;
-
- @Inject
- private WatchChildrenJobsBL watchChildrenJobsBL;
-
- private List<String> childrenJobsIds;
-
- protected boolean isService;
-
- public BaseWatchingCommand() {}
-
- public BaseWatchingCommand(JobSharedData sharedData, List<String> childrenJobsIds, boolean isService) {
- init(sharedData, childrenJobsIds, isService);
- }
-
- @Override
- public NextCommand call() {
- Job.JobStatus cumulativeJobsStatus = watchChildrenJobsBL.cumulateJobStatus(
- watchChildrenJobsBL.retrieveChildrenJobsStatus(childrenJobsIds),
- Job.JobStatus.COMPLETED);
- return getNextCommand(cumulativeJobsStatus);
- }
-
- protected abstract NextCommand getNextCommand(Job.JobStatus cumulativeJobsStatus);
-
- @Override
- public BaseWatchingCommand init(JobSharedData sharedData, Map<String, Object> commandData) {
- return init(
- sharedData,
- (List<String>) commandData.get("childrenJobs"),
- (boolean) commandData.get("isService")
- );
- }
-
- protected BaseWatchingCommand init(JobSharedData sharedData, List<String> childrenJobsIds, boolean isService) {
- super.init(sharedData);
- this.childrenJobsIds = ObjectUtils.defaultIfNull(childrenJobsIds, new ArrayList<>());
- this.isService = isService;
- return this;
- }
-
- @Override
- public Map<String, Object> getData() {
- Map<String, Object> data = new HashMap<>();
- data.put("childrenJobs", childrenJobsIds);
- data.put("isService", isService);
- return data;
- }
-}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/CommandBase.java b/vid-app-common/src/main/java/org/onap/vid/job/command/CommandBase.java
index a13e4dc38..a9b524e01 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/CommandBase.java
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/CommandBase.java
@@ -7,9 +7,9 @@
* 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.
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/CommandParentData.java b/vid-app-common/src/main/java/org/onap/vid/job/command/CommandParentData.java
index 35f631183..744b2fe39 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/CommandParentData.java
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/CommandParentData.java
@@ -7,9 +7,9 @@
* 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.
@@ -21,12 +21,15 @@
package org.onap.vid.job.command;
import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import org.onap.vid.model.Action;
import org.onap.vid.mso.model.ModelInfo;
import java.util.HashMap;
import java.util.Map;
+import static java.util.Collections.emptyMap;
+import static org.onap.vid.utils.KotlinUtilsKt.JACKSON_OBJECT_MAPPER;
+
public class CommandParentData {
@@ -36,6 +39,7 @@ public class CommandParentData {
VNF_INSTANCE_ID,
VNF_MODEL_INFO,
VG_INSTANCE_ID,
+ VNF_GROUP_INSTANCE_ID,
;
}
@@ -49,32 +53,30 @@ public class CommandParentData {
new TypeReference<Map<CommandDataKey, ModelInfo>> () {};
- private ObjectMapper objectMapper = new ObjectMapper();
-
private Map<CommandDataKey,ModelInfo> getModelInfosByCommandData(Map<String, Object> commandData) {
- Object object = commandData.get(RESOURCE_MODEL_INFOS);
- if (object != null) {
- return objectMapper.convertValue(object, mapCommandKeyToModelInfo);
- }
- return null;
+ Object object = commandData.getOrDefault(RESOURCE_MODEL_INFOS, emptyMap());
+ return JACKSON_OBJECT_MAPPER.convertValue(object, mapCommandKeyToModelInfo);
}
private Map<CommandDataKey,String> getInstanceIdsByCommandData(Map<String, Object> commandData) {
- Object object = commandData.get(RESOURCE_INSTANCE_IDS);
- if (object != null) {
- return objectMapper.convertValue(object, mapCommandKeyToString);
- }
- return null;
+ Object object = commandData.getOrDefault(RESOURCE_INSTANCE_IDS, emptyMap());
+ return JACKSON_OBJECT_MAPPER.convertValue(object, mapCommandKeyToString);
}
public Map<String, Object> getParentData() {
Map<String, Object> data = new HashMap<>();
data.put(RESOURCE_INSTANCE_IDS, resourceInstancesIds);
data.put(RESOURCE_MODEL_INFOS, resourceModelInfos);
+
+ if (actionPhase != null) {
+ data.put(ResourceCommandKt.ACTION_PHASE, actionPhase);
+ }
+
return data;
}
private Map<CommandDataKey, String> resourceInstancesIds = new HashMap<>();
private Map<CommandDataKey, ModelInfo> resourceModelInfos = new HashMap<>();
+ private Action actionPhase = null;
public void addModelInfo(CommandDataKey modelInfoKey, ModelInfo modelInfo) {
resourceModelInfos.put(modelInfoKey, modelInfo);
@@ -83,6 +85,11 @@ public class CommandParentData {
public void addInstanceId(CommandDataKey instanceIdKey, String instanceId) {
resourceInstancesIds.put(instanceIdKey, instanceId);
}
+
+ public void setActionPhase(Action actionPhase) {
+ this.actionPhase = actionPhase;
+ }
+
public ModelInfo getModelInfo(CommandDataKey modelInfoKey) {
return resourceModelInfos.get(modelInfoKey);
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/CommandUtils.java b/vid-app-common/src/main/java/org/onap/vid/job/command/CommandUtils.java
index e9936ed4c..0fe7255c4 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/CommandUtils.java
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/CommandUtils.java
@@ -7,9 +7,9 @@
* 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.
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/ExpiryChecker.java b/vid-app-common/src/main/java/org/onap/vid/job/command/ExpiryChecker.java
index c41963d14..5d608255a 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/ExpiryChecker.java
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/ExpiryChecker.java
@@ -7,9 +7,9 @@
* 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.
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/HttpCallCommand.java b/vid-app-common/src/main/java/org/onap/vid/job/command/HttpCallCommand.java
index 21c10ffac..9dc88dfea 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/HttpCallCommand.java
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/HttpCallCommand.java
@@ -7,9 +7,9 @@
* 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.
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/InProgressStatusService.java b/vid-app-common/src/main/java/org/onap/vid/job/command/InProgressStatusService.java
index 842a1bd17..3d1d78f8b 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/InProgressStatusService.java
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/InProgressStatusService.java
@@ -7,9 +7,9 @@
* 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.
@@ -26,10 +26,12 @@ import org.onap.vid.job.impl.JobSharedData;
import org.onap.vid.mso.RestMsoImplementation;
import org.onap.vid.mso.RestObject;
import org.onap.vid.mso.rest.AsyncRequestStatus;
+import org.onap.vid.properties.Features;
import org.onap.vid.services.AsyncInstantiationBusinessLogic;
import org.onap.vid.services.AuditService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import org.togglz.core.manager.FeatureManager;
import java.time.ZonedDateTime;
import java.time.format.DateTimeParseException;
@@ -48,30 +50,37 @@ public class InProgressStatusService {
private final AuditService auditService;
+ private final FeatureManager featureManager;
+
@Autowired
- public InProgressStatusService(AsyncInstantiationBusinessLogic asyncInstantiationBL, RestMsoImplementation restMso, AuditService auditService) {
+ public InProgressStatusService(AsyncInstantiationBusinessLogic asyncInstantiationBL, RestMsoImplementation restMso, AuditService auditService, FeatureManager featureManager) {
this.asyncInstantiationBL = asyncInstantiationBL;
this.restMso = restMso;
this.auditService = auditService;
+ this.featureManager = featureManager;
}
public Job.JobStatus call(ExpiryChecker expiryChecker, JobSharedData sharedData, String requestId) {
RestObject<AsyncRequestStatus> asyncRequestStatus = getAsyncRequestStatus(requestId);
- asyncInstantiationBL.auditMsoStatus(sharedData.getRootJobId(), asyncRequestStatus.get().request);
+ auditService.auditMsoStatus(sharedData.getRootJobId(), asyncRequestStatus.get().request);
Job.JobStatus jobStatus = asyncInstantiationBL.calcStatus(asyncRequestStatus.get());
ZonedDateTime jobStartTime = getZonedDateTime(asyncRequestStatus, requestId);
jobStatus = expiryChecker.isExpired(jobStartTime) ? Job.JobStatus.FAILED : jobStatus;
+ asyncInstantiationBL.updateResourceInfo(sharedData, jobStatus, asyncRequestStatus.get());
return jobStatus;
}
- private RestObject<AsyncRequestStatus> getAsyncRequestStatus(String requestId) {
- String path = asyncInstantiationBL.getOrchestrationRequestsPath()+"/"+requestId;
+ RestObject<AsyncRequestStatus> getAsyncRequestStatus(String requestId) {
+ String path = asyncInstantiationBL.getOrchestrationRequestsPath() + "/" + requestId +
+ (featureManager.isActive(Features.FLAG_1908_RESUME_MACRO_SERVICE) ? "?format=detail" : "");
RestObject<AsyncRequestStatus> msoResponse = restMso.GetForObject(path, AsyncRequestStatus.class);
+
if (msoResponse.getStatusCode() >= 400 || msoResponse.get() == null) {
throw new BadResponseFromMso(msoResponse);
}
+
return msoResponse;
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/InstanceGroupCommand.kt b/vid-app-common/src/main/java/org/onap/vid/job/command/InstanceGroupCommand.kt
index e81fcd34e..26fb9aa09 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/InstanceGroupCommand.kt
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/InstanceGroupCommand.kt
@@ -7,9 +7,9 @@
* 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.
@@ -24,6 +24,8 @@ import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate
import org.onap.vid.job.Job
import org.onap.vid.job.JobAdapter
import org.onap.vid.job.JobCommand
+import org.onap.vid.job.JobsBrokerService
+import org.onap.vid.model.serviceInstantiation.BaseResource
import org.onap.vid.model.serviceInstantiation.InstanceGroup
import org.onap.vid.mso.RestMsoImplementation
import org.onap.vid.services.AsyncInstantiationBusinessLogic
@@ -39,29 +41,42 @@ import java.util.*
class InstanceGroupCommand @Autowired constructor(
private val asyncInstantiationBL: AsyncInstantiationBusinessLogic,
restMso: RestMsoImplementation,
+ private val msoRequestBuilder: MsoRequestBuilder,
msoResultHandlerService: MsoResultHandlerService,
inProgressStatusService:InProgressStatusService,
- watchChildrenJobsBL: WatchChildrenJobsBL
-) : ResourceCommand(restMso, inProgressStatusService, msoResultHandlerService, watchChildrenJobsBL), JobCommand {
+ watchChildrenJobsBL: WatchChildrenJobsBL,
+ jobsBrokerService: JobsBrokerService,
+ jobAdapter: JobAdapter
+ ) : ResourceCommand(restMso, inProgressStatusService, msoResultHandlerService,
+ watchChildrenJobsBL, jobsBrokerService, jobAdapter), JobCommand {
companion object {
private val LOGGER = EELFLoggerDelegate.getLogger(InstanceGroupCommand::class.java)
}
override fun createChildren(): Job.JobStatus {
+ val dataForChild = buildDataForChild(getRequest(), actionPhase)
+
+ childJobs = pushChildrenJobsToBroker(getRequest().vnfGroupMembers.values, dataForChild);
+
return Job.JobStatus.COMPLETED_WITH_NO_ACTION
}
- override fun planCreateMyselfRestCall(commandParentData: CommandParentData, request: JobAdapter.AsyncJobRequest, userId: String): MsoRestCallPlan {
+ override fun addMyselfToChildrenData(commandParentData: CommandParentData, request: BaseResource) {
+ commandParentData.addInstanceId(CommandParentData.CommandDataKey.VNF_GROUP_INSTANCE_ID, request.instanceId)
+ }
+
+ override fun planCreateMyselfRestCall(commandParentData: CommandParentData, request: JobAdapter.AsyncJobRequest, userId: String, testApi: String?): MsoRestCallPlan {
val serviceInstanceId = commandParentData.getInstanceId(CommandParentData.CommandDataKey.SERVICE_INSTANCE_ID)
val serviceModelInfo = commandParentData.getModelInfo(CommandParentData.CommandDataKey.SERVICE_MODEL_INFO)
val instantiatePath = asyncInstantiationBL.getInstanceGroupInstantiationPath()
- val requestDetailsWrapper = asyncInstantiationBL.generateInstanceGroupInstantiationRequest(
+ val requestDetailsWrapper = msoRequestBuilder.generateInstanceGroupInstantiationRequest(
request as InstanceGroup,
serviceModelInfo, serviceInstanceId,
- userId
+ userId,
+ testApi
)
val actionDescription = "create instance group in $serviceInstanceId"
@@ -76,4 +91,7 @@ class InstanceGroupCommand @Autowired constructor(
}
-}
+ override fun getRequest(): InstanceGroup {
+ return sharedData.request as InstanceGroup
+ }
+} \ No newline at end of file
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/InstanceGroupInstantiationCommand.java b/vid-app-common/src/main/java/org/onap/vid/job/command/InstanceGroupInstantiationCommand.java
deleted file mode 100644
index 6d9ddd499..000000000
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/InstanceGroupInstantiationCommand.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * 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.vid.job.command;//package org.onap.vid.job.command;
-
-import org.onap.vid.changeManagement.RequestDetailsWrapper;
-import org.onap.vid.job.JobAdapter;
-import org.onap.vid.job.command.CommandParentData.CommandDataKey;
-import org.onap.vid.model.Action;
-import org.onap.vid.model.serviceInstantiation.InstanceGroup;
-import org.onap.vid.mso.model.InstanceGroupInstantiationRequestDetails;
-import org.onap.vid.services.AsyncInstantiationBusinessLogic;
-import org.springframework.beans.factory.config.ConfigurableBeanFactory;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-
-import javax.inject.Inject;
-
-@Component
-@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-public class InstanceGroupInstantiationCommand extends ResourceInstantiationCommand {
-
- @Inject
- private AsyncInstantiationBusinessLogic asyncInstantiationBL;
-
- @Override
- protected String getRequestPath() {
- return asyncInstantiationBL.getInstanceGroupInstantiationPath();
- }
-
- @Override
- protected RequestDetailsWrapper<InstanceGroupInstantiationRequestDetails> generateMSORequest(JobAdapter.AsyncJobRequest request, String userId) {
- return asyncInstantiationBL.generateInstanceGroupInstantiationRequest(
- (InstanceGroup) getSharedData().getRequest(),
- commandParentData.getModelInfo(CommandDataKey.SERVICE_MODEL_INFO),
- commandParentData.getInstanceId(CommandDataKey.SERVICE_INSTANCE_ID),
- getSharedData().getUserId()
- );
- }
-
- @Override
- protected String getJobAuditMSOStatus() {
- return "INSTANCE_GROUP_REQUESTED";
- }
-
- @Override
- protected boolean shouldInstantiateMyself() {
- return Action.Create == ((InstanceGroup) getSharedData().getRequest()).getAction();
- }
-}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/InstanceGroupMemberCommand.kt b/vid-app-common/src/main/java/org/onap/vid/job/command/InstanceGroupMemberCommand.kt
new file mode 100644
index 000000000..d8e9297a3
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/InstanceGroupMemberCommand.kt
@@ -0,0 +1,63 @@
+package org.onap.vid.job.command
+
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate
+import org.onap.vid.job.Job
+import org.onap.vid.job.JobAdapter
+import org.onap.vid.job.JobCommand
+import org.onap.vid.job.JobsBrokerService
+import org.onap.vid.model.serviceInstantiation.InstanceGroupMember
+import org.onap.vid.mso.RestMsoImplementation
+import org.onap.vid.services.AsyncInstantiationBusinessLogic
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
+import org.springframework.http.HttpMethod
+import org.springframework.stereotype.Component
+import java.util.*
+
+@Component
+@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+class InstanceGroupMemberCommand @Autowired constructor(
+ private val asyncInstantiationBL: AsyncInstantiationBusinessLogic,
+ restMso: RestMsoImplementation,
+ private val msoRequestBuilder: MsoRequestBuilder,
+ msoResultHandlerService: MsoResultHandlerService,
+ inProgressStatusService:InProgressStatusService,
+ watchChildrenJobsBL: WatchChildrenJobsBL,
+ jobsBrokerService: JobsBrokerService,
+ jobAdapter: JobAdapter
+) : ResourceCommand(restMso, inProgressStatusService, msoResultHandlerService,
+ watchChildrenJobsBL, jobsBrokerService, jobAdapter), JobCommand {
+
+ companion object {
+ private val LOGGER = EELFLoggerDelegate.getLogger(InstanceGroupMemberCommand::class.java)
+ }
+
+ override fun createChildren(): Job.JobStatus {
+ return Job.JobStatus.COMPLETED_WITH_NO_ACTION
+ }
+
+ override fun planCreateMyselfRestCall(commandParentData: CommandParentData, request: JobAdapter.AsyncJobRequest, userId: String, testApi: String?): MsoRestCallPlan {
+ val instanceGroupId = commandParentData.getInstanceId(CommandParentData.CommandDataKey.VNF_GROUP_INSTANCE_ID)
+
+ val instantiatePath = asyncInstantiationBL.getInstanceGroupMemberInstantiationPath(instanceGroupId)
+
+ val requestDetailsWrapper = msoRequestBuilder.generateInstanceGroupMemberRequest(getRequest().instanceId, userId)
+
+ val actionDescription = "add instance group member ${getRequest().instanceId} to instance group $instanceGroupId"
+
+ return MsoRestCallPlan(HttpMethod.POST, instantiatePath, Optional.of(requestDetailsWrapper), Optional.empty(), actionDescription)
+ }
+
+ override fun planDeleteMyselfRestCall(commandParentData: CommandParentData, request: JobAdapter.AsyncJobRequest, userId: String): MsoRestCallPlan {
+ val instanceGroupId = commandParentData.getInstanceId(CommandParentData.CommandDataKey.VNF_GROUP_INSTANCE_ID)
+ val path = asyncInstantiationBL.getInstanceGroupMemberDeletePath(instanceGroupId)
+ val requestDetailsWrapper = msoRequestBuilder.generateInstanceGroupMemberRequest(getRequest().instanceId, userId)
+ return MsoRestCallPlan(HttpMethod.POST, path, Optional.of(requestDetailsWrapper), Optional.of(userId),
+ "delete instance group member ${getRequest().instanceId} from instance group $instanceGroupId")
+ }
+
+ override fun getRequest(): InstanceGroupMember {
+ return sharedData.request as InstanceGroupMember
+ }
+} \ No newline at end of file
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/JobCommandFactory.java b/vid-app-common/src/main/java/org/onap/vid/job/command/JobCommandFactory.java
index 9f9a62201..32828ad5c 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/JobCommandFactory.java
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/JobCommandFactory.java
@@ -7,9 +7,9 @@
* 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.
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/MacroServiceCommand.kt b/vid-app-common/src/main/java/org/onap/vid/job/command/MacroServiceCommand.kt
new file mode 100644
index 000000000..8ce73d713
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/MacroServiceCommand.kt
@@ -0,0 +1,98 @@
+package org.onap.vid.job.command
+
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate
+import org.onap.vid.aai.ExceptionWithRequestInfo
+import org.onap.vid.changeManagement.RequestDetailsWrapper
+import org.onap.vid.exceptions.AbortingException
+import org.onap.vid.exceptions.MaxRetriesException
+import org.onap.vid.exceptions.TryAgainException
+import org.onap.vid.job.Job
+import org.onap.vid.job.JobAdapter
+import org.onap.vid.job.JobCommand
+import org.onap.vid.job.JobsBrokerService
+import org.onap.vid.model.Action
+import org.onap.vid.model.VidNotions.ModelCategory.*
+import org.onap.vid.model.serviceInstantiation.ServiceInstantiation
+import org.onap.vid.mso.RestMsoImplementation
+import org.onap.vid.services.AsyncInstantiationBusinessLogic
+import org.onap.vid.services.AuditService
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
+import org.springframework.http.HttpMethod
+import org.springframework.stereotype.Component
+import java.util.*
+
+@Component
+@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+class MacroServiceCommand @Autowired constructor(
+ inProgressStatusService: InProgressStatusService,
+ watchChildrenJobsBL: WatchChildrenJobsBL,
+ private val asyncInstantiationBL: AsyncInstantiationBusinessLogic,
+ jobsBrokerService: JobsBrokerService,
+ private val msoRequestBuilder: MsoRequestBuilder,
+ msoResultHandlerService: MsoResultHandlerService,
+ jobAdapter: JobAdapter,
+ restMso: RestMsoImplementation,
+ auditService: AuditService
+) : RootServiceCommand(restMso, inProgressStatusService, msoResultHandlerService,
+ watchChildrenJobsBL, jobsBrokerService, jobAdapter, asyncInstantiationBL, auditService, msoRequestBuilder), JobCommand {
+
+
+ companion object {
+ private val Logger = EELFLoggerDelegate.getLogger(MacroServiceCommand::class.java)
+ }
+
+ override fun createChildren(): Job.JobStatus {
+ return Job.JobStatus.COMPLETED_WITH_NO_ACTION
+ }
+
+ private val pre1806Models = setOf(Transport, INFRASTRUCTURE_VPN, SERVICE_WITH_COLLECTION_RESOURCE);
+
+ override fun planCreateMyselfRestCall(commandParentData: CommandParentData, request: JobAdapter.AsyncJobRequest, userId: String, testApi: String?): MsoRestCallPlan {
+ try {
+ val instantiatePath = asyncInstantiationBL.getServiceInstantiationPath(request as ServiceInstantiation)
+
+ val requestDetailsWrapper = generateRequest(sharedData.jobUuid, request, optimisticUniqueServiceInstanceName, userId)
+
+ val actionDescription = "create macro service instance"
+
+ return MsoRestCallPlan(HttpMethod.POST, instantiatePath, Optional.of(requestDetailsWrapper), Optional.empty(), actionDescription)
+ }
+
+ //Aai return bad response while checking names uniqueness
+ catch (exception : ExceptionWithRequestInfo) {
+ Logger.error("Failed to check name uniqueness in AAI. VID will try again later", exception)
+ throw TryAgainException(exception);
+ }
+
+ //Vid reached to max retries while trying to find unique name in AAI
+ catch (exception : MaxRetriesException) {
+ Logger.error("Failed to find unused name in AAI", exception)
+ throw AbortingException(exception);
+ }
+ }
+
+ private fun generateRequest(jobUuid: UUID?, request: ServiceInstantiation, optimisticUniqueServiceInstanceName: String, userId: String): RequestDetailsWrapper<out Any> {
+ // for transport or for infrastructure VPN - send the pre 1806 request
+ if (shouldUsePre1806Request(request)){
+ return msoRequestBuilder.generateMacroServicePre1806InstantiationRequest(request, userId)
+ }
+ return msoRequestBuilder.generateMacroServiceInstantiationRequest(jobUuid, request, optimisticUniqueServiceInstanceName, userId)
+ }
+
+ protected fun shouldUsePre1806Request(request: ServiceInstantiation): Boolean {
+ return (request.vidNotions != null && pre1806Models.contains(request.vidNotions.modelCategory))
+ }
+
+
+ override fun handleInProgressStatus(jobStatus: Job.JobStatus): Job.JobStatus {
+ asyncInstantiationBL.updateServiceInfoAndAuditStatus(sharedData.jobUuid, jobStatus)
+ return if (jobStatus==Job.JobStatus.PAUSE) Job.JobStatus.IN_PROGRESS else jobStatus
+ }
+
+ override fun isDescendantHasAction(phase: Action): Boolean {
+ return false
+ }
+
+} \ No newline at end of file
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/MsoRequestBuilder.kt b/vid-app-common/src/main/java/org/onap/vid/job/command/MsoRequestBuilder.kt
new file mode 100644
index 000000000..c8502b1e5
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/MsoRequestBuilder.kt
@@ -0,0 +1,411 @@
+package org.onap.vid.job.command
+
+import com.google.common.collect.ImmutableList
+import org.apache.commons.lang3.ObjectUtils.defaultIfNull
+import org.apache.commons.lang3.StringUtils
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate
+import org.onap.vid.aai.AaiClientInterface
+import org.onap.vid.aai.ExceptionWithRequestInfo
+import org.onap.vid.aai.model.ResourceType
+import org.onap.vid.changeManagement.RequestDetailsWrapper
+import org.onap.vid.model.serviceInstantiation.*
+import org.onap.vid.mso.model.*
+import org.onap.vid.mso.model.BaseResourceInstantiationRequestDetails.*
+import org.onap.vid.mso.model.VfModuleInstantiationRequestDetails.UserParamMap
+import org.onap.vid.mso.rest.SubscriberInfo
+import org.onap.vid.services.AsyncInstantiationBusinessLogic
+import org.onap.vid.services.CloudOwnerService
+import org.onap.vid.utils.JACKSON_OBJECT_MAPPER
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.stereotype.Service
+import org.togglz.core.manager.FeatureManager
+import java.util.*
+import java.util.Collections.emptyList
+import java.util.stream.Collectors
+
+@Service
+class MsoRequestBuilder
+@Autowired constructor(private val asyncInstantiationBL: AsyncInstantiationBusinessLogic,
+ private val cloudOwnerService: CloudOwnerService,
+ private val aaiClient: AaiClientInterface,
+ private val featureManager: FeatureManager) {
+
+ companion object {
+ private val LOGGER = EELFLoggerDelegate.getLogger(MsoRequestBuilder::class.java)
+ private const val VID_SOURCE = "VID"
+ }
+
+ fun generateALaCarteServiceInstantiationRequest(payload: ServiceInstantiation, optimisticUniqueServiceInstanceName: String, userId: String): RequestDetailsWrapper<ServiceInstantiationRequestDetails> {
+ val userParams = generateUserParamList()
+
+ val requestParameters = ServiceInstantiationRequestDetails.RequestParameters(payload.subscriptionServiceType, true, userParams, payload.testApi)
+
+ val requestDetails = generateServiceInstantiationRequestDetails(payload, requestParameters, optimisticUniqueServiceInstanceName, userId)
+
+ return RequestDetailsWrapper(requestDetails)
+ }
+
+ fun generateServiceDeletionRequest(payload: ServiceInstantiation, userId: String): RequestDetailsWrapper<ServiceDeletionRequestDetails> {
+
+ val requestParameters = ServiceDeletionRequestDetails.RequestParameters(payload.isALaCarte, payload.testApi)
+
+ val requestInfo = ServiceDeletionRequestDetails.RequestInfo(
+ VID_SOURCE,
+ userId)
+
+ val requestDetails = ServiceDeletionRequestDetails(payload.modelInfo, requestInfo, requestParameters)
+
+ return RequestDetailsWrapper(requestDetails)
+ }
+
+ fun generateMacroServiceInstantiationRequest(jobId: UUID?, payload: ServiceInstantiation, optimisticUniqueServiceInstanceName: String, userId: String): RequestDetailsWrapper<ServiceInstantiationRequestDetails> {
+ val serviceInstanceName = generateServiceName(jobId, payload, optimisticUniqueServiceInstanceName)
+
+ val serviceInstantiationServiceList = generateServiceInstantiationServicesList(payload, serviceInstanceName, createServiceInstantiationVnfList(jobId, payload))
+
+ val requestParameters = ServiceInstantiationRequestDetails.RequestParameters(payload.subscriptionServiceType, false, serviceInstantiationServiceList)
+
+ val requestDetails = generateServiceInstantiationRequestDetails(payload, requestParameters, serviceInstanceName, userId)
+
+ return RequestDetailsWrapper(requestDetails)
+ }
+
+ fun generateNetworkInstantiationRequest(networkDetails: Network, serviceModelInfo: ModelInfo, serviceInstanceId: String, userId: String, testApi: String?): RequestDetailsWrapper<NetworkInstantiationRequestDetails> {
+ val requestInfo = generateRequestInfo(networkDetails.instanceName, ResourceType.L3_NETWORK, networkDetails.isRollbackOnFailure, networkDetails.productFamilyId, userId)
+ val cloudConfiguration = generateCloudConfiguration(networkDetails.lcpCloudRegionId, networkDetails.tenantId)
+ val platform = Platform(networkDetails.platformName)
+ val lineOfBusiness = LineOfBusiness.of(networkDetails.lineOfBusiness)
+ val requestParameters = BaseResourceInstantiationRequestDetails.RequestParameters(generateUserParamList(), testApi)
+ val relatedInstanceList = generateRelatedInstances(mapOf(serviceInstanceId to serviceModelInfo))
+ return RequestDetailsWrapper(NetworkInstantiationRequestDetails(networkDetails.modelInfo, cloudConfiguration, requestInfo, platform, lineOfBusiness, relatedInstanceList, requestParameters))
+ }
+
+ fun generateVnfInstantiationRequest(vnfDetails: Vnf, serviceModelInfo: ModelInfo, serviceInstanceId: String, userId: String, testApi: String?): RequestDetailsWrapper<VnfInstantiationRequestDetails> {
+ val requestInfo = generateRequestInfo(vnfDetails.instanceName, ResourceType.GENERIC_VNF, vnfDetails.isRollbackOnFailure, vnfDetails.productFamilyId, userId)
+ val cloudConfiguration = generateCloudConfiguration(vnfDetails.lcpCloudRegionId, vnfDetails.tenantId)
+ val platform = Platform(vnfDetails.platformName)
+ val lineOfBusiness = LineOfBusiness.of(vnfDetails.lineOfBusiness)
+ val requestParameters = BaseResourceInstantiationRequestDetails.RequestParameters(generateUserParamList(), testApi)
+ val relatedInstanceList = generateRelatedInstances(mapOf(serviceInstanceId to serviceModelInfo))
+ return RequestDetailsWrapper(VnfInstantiationRequestDetails(vnfDetails.modelInfo, cloudConfiguration, requestInfo, platform, lineOfBusiness, relatedInstanceList, requestParameters))
+ }
+
+ fun generateDeleteVnfRequest(vnfDetails: Vnf, userId: String): RequestDetailsWrapper<VnfInstantiationRequestDetails> {
+ val requestInfo = generateRequestInfo(null, null, null, null, userId)
+ val cloudConfiguration = generateCloudConfiguration(vnfDetails.lcpCloudRegionId, vnfDetails.tenantId)
+ return RequestDetailsWrapper(VnfInstantiationRequestDetails(vnfDetails.modelInfo, cloudConfiguration, requestInfo, null, null, null, null))
+ }
+
+ fun generateVfModuleInstantiationRequest(vfModuleDetails: VfModule, serviceModelInfo: ModelInfo, serviceInstanceId: String, vnfModelInfo: ModelInfo, vnfInstanceId: String, vgInstanceId: String?, userId: String, testApi: String?): RequestDetailsWrapper<VfModuleInstantiationRequestDetails> {
+ val requestInfo = generateRequestInfo(vfModuleDetails.instanceName, ResourceType.VF_MODULE, vfModuleDetails.isRollbackOnFailure, null, userId)
+
+ //cloud configuration
+ val cloudConfiguration = generateCloudConfiguration(vfModuleDetails.lcpCloudRegionId, vfModuleDetails.tenantId)
+
+ //request parameters
+ val userParams = aggregateAllInstanceParams(extractActualInstanceParams(vfModuleDetails.instanceParams), vfModuleDetails.supplementaryParams)
+ val requestParameters = VfModuleInstantiationRequestDetails.RequestParametersVfModule(userParams, vfModuleDetails.isUsePreload, testApi)
+
+ //related instance list
+ val relatedInstanceList = generateRelatedInstances(mapOf(serviceInstanceId to serviceModelInfo, vnfInstanceId to vnfModelInfo))
+ if (StringUtils.isNotEmpty(vgInstanceId)) {
+ val volumeGroupModel = ModelInfo()
+ volumeGroupModel.modelType = "volumeGroup"
+ relatedInstanceList.add(RelatedInstance(volumeGroupModel, vgInstanceId, vfModuleDetails.volumeGroupInstanceName))
+ }
+ return RequestDetailsWrapper(VfModuleInstantiationRequestDetails(vfModuleDetails.modelInfo, cloudConfiguration, requestInfo, relatedInstanceList, requestParameters))
+ }
+
+ fun generateVolumeGroupInstantiationRequest(vfModuleDetails: VfModule, serviceModelInfo: ModelInfo, serviceInstanceId: String, vnfModelInfo: ModelInfo, vnfInstanceId: String, userId: String, testApi: String?): RequestDetailsWrapper<VolumeGroupRequestDetails> {
+ val requestInfo = generateRequestInfo(vfModuleDetails.volumeGroupInstanceName, ResourceType.VOLUME_GROUP, vfModuleDetails.isRollbackOnFailure, null, userId)
+ val cloudConfiguration = generateCloudConfiguration(vfModuleDetails.lcpCloudRegionId, vfModuleDetails.tenantId)
+ val userParams = aggregateAllInstanceParams(extractActualInstanceParams(vfModuleDetails.instanceParams), vfModuleDetails.supplementaryParams)
+ val requestParameters = VfModuleInstantiationRequestDetails.RequestParametersVfModule(userParams, vfModuleDetails.isUsePreload, testApi)
+ val relatedInstances = generateRelatedInstances(mapOf(serviceInstanceId to serviceModelInfo, vnfInstanceId to vnfModelInfo))
+
+ vfModuleDetails.modelInfo.modelType = "volumeGroup"
+ return RequestDetailsWrapper(VolumeGroupRequestDetails(vfModuleDetails.modelInfo, cloudConfiguration, requestInfo, relatedInstances, requestParameters))
+ }
+
+ fun generateInstanceGroupInstantiationRequest(instanceGroupDetails: InstanceGroup, serviceModelInfo: ModelInfo, serviceInstanceId: String, userId: String, testApi: String?): RequestDetailsWrapper<InstanceGroupInstantiationRequestDetails> {
+ val requestInfo = generateRequestInfo(instanceGroupDetails.instanceName, ResourceType.INSTANCE_GROUP, instanceGroupDetails.isRollbackOnFailure, null, userId)
+ val requestParameters = BaseResourceInstantiationRequestDetails.RequestParameters(generateUserParamList(), testApi)
+ val relatedInstanceList = generateRelatedInstances(mapOf(serviceInstanceId to serviceModelInfo))
+ return RequestDetailsWrapper(InstanceGroupInstantiationRequestDetails(instanceGroupDetails.modelInfo, requestInfo, relatedInstanceList, requestParameters))
+ }
+
+ fun generateInstanceGroupMemberRequest(instanceGroupMemberId: String, userId: String): RequestDetailsWrapper<AddOrRemoveInstanceGroupMemberRequestDetails> {
+ val requestInfo = generateRequestInfo(null, null, null, null, userId)
+ val modelInfo = ModelInfo()
+ modelInfo.modelType = "vnf"
+ val relatedInstanceList = generateRelatedInstances(mapOf(instanceGroupMemberId to modelInfo))
+ return RequestDetailsWrapper(AddOrRemoveInstanceGroupMemberRequestDetails(requestInfo, relatedInstanceList))
+ }
+
+ fun generateDeleteNetworkRequest(networkDetails: Network, userId: String): RequestDetailsWrapper<NetworkInstantiationRequestDetails> {
+ val requestInfo = generateRequestInfo(null, null, null, null, userId)
+ val cloudConfiguration = generateCloudConfiguration(networkDetails.lcpCloudRegionId, networkDetails.tenantId)
+ return RequestDetailsWrapper(NetworkInstantiationRequestDetails(networkDetails.modelInfo, cloudConfiguration, requestInfo, null, null, null, null))
+ }
+
+ fun generateDeleteVfModuleRequest(vfModuleDetails: VfModule, userId: String): RequestDetailsWrapper<VfModuleInstantiationRequestDetails> {
+ val requestInfo = generateRequestInfo(null, null, null, null, userId)
+ val cloudConfiguration = generateCloudConfiguration(vfModuleDetails.lcpCloudRegionId, vfModuleDetails.tenantId)
+ return RequestDetailsWrapper(VfModuleInstantiationRequestDetails(vfModuleDetails.modelInfo, cloudConfiguration, requestInfo, null, null))
+ }
+
+ private fun generateServiceName(jobId: UUID?, payload: ServiceInstantiation, optimisticUniqueServiceInstanceName: String): String? {
+ var serviceInstanceName: String? = null
+ if (StringUtils.isNotEmpty(optimisticUniqueServiceInstanceName)) {
+ serviceInstanceName = peekServiceName(jobId, payload, optimisticUniqueServiceInstanceName)
+ }
+ return serviceInstanceName
+ }
+
+ private fun peekServiceName(jobId: UUID?, payload: ServiceInstantiation, optimisticUniqueServiceInstanceName: String): String {
+ val serviceInstanceName: String
+ // unique name already exist in service info. If it's free in AAI we use it
+ if (isNameFreeInAai(optimisticUniqueServiceInstanceName, ResourceType.SERVICE_INSTANCE)) {
+ serviceInstanceName = optimisticUniqueServiceInstanceName
+ } else {
+ serviceInstanceName = asyncInstantiationBL.getUniqueName(payload.instanceName, ResourceType.SERVICE_INSTANCE)
+ }//otherwise we used the original service instance name (from payload) to get a new unique name from DB and AAI
+
+ //update serviceInfo with new name if needed
+ try {
+ asyncInstantiationBL.updateServiceInfo(jobId) { x -> x.serviceInstanceName = serviceInstanceName }
+ } catch (e: Exception) {
+ LOGGER.error("Failed updating service name {} in serviceInfo", serviceInstanceName, e)
+ }
+
+ return serviceInstanceName
+ }
+
+ @Throws(ExceptionWithRequestInfo::class)
+ private fun isNameFreeInAai(name: String, resourceType: ResourceType): Boolean {
+ return !aaiClient.isNodeTypeExistsByName(name, resourceType)
+ }
+
+ private fun generateServiceInstantiationServicesList(payload: ServiceInstantiation, serviceInstanceName: String?, vnfList: ServiceInstantiationRequestDetails.ServiceInstantiationVnfList): List<ServiceInstantiationRequestDetails.ServiceInstantiationService> {
+ val serviceInstantiationServiceList = LinkedList<ServiceInstantiationRequestDetails.ServiceInstantiationService>()
+ val unFilteredInstanceParams = defaultIfNull<List<MutableMap<String, String>>>(payload.instanceParams, emptyList())
+ val filteredInstanceParams = removeUnNeededParams(unFilteredInstanceParams)
+ val serviceInstantiationService = ServiceInstantiationRequestDetails.ServiceInstantiationService(
+ payload.modelInfo,
+ serviceInstanceName,
+ filteredInstanceParams,
+ vnfList
+ )
+ serviceInstantiationServiceList.add(serviceInstantiationService)
+ return serviceInstantiationServiceList
+ }
+
+ private fun removeUnNeededParams(instanceParams: List<MutableMap<String, String>>?): List<MutableMap<String, String>> {
+ val keysToRemove = mutableListOf<String>()
+ if (instanceParams.isNullOrEmpty()) {
+ return emptyList()
+ }
+
+ for (key in instanceParams[0].keys) {
+ for (paramToIgnore in AsyncInstantiationBusinessLogic.PARAMS_TO_IGNORE)
+ if (key.equals(paramToIgnore, ignoreCase = true)) {
+ keysToRemove.add(key)
+ }
+ }
+
+ val result : MutableMap<String, String> = instanceParams[0].entries.stream()
+ .filter { entry -> !keysToRemove.contains(entry.key) }
+ .collect(Collectors.toMap({it.key}, {it.value}))
+
+ return if (result.isEmpty()) emptyList() else listOf(result)
+ }
+
+ private fun createServiceInstantiationVnfList(jobId: UUID?, payload: ServiceInstantiation): ServiceInstantiationRequestDetails.ServiceInstantiationVnfList {
+ val cloudConfiguration = generateCloudConfiguration(payload.lcpCloudRegionId, payload.tenantId)
+ val isBulk = asyncInstantiationBL.isPartOfBulk(jobId)
+
+ val vnfs = payload.vnfs
+ val vnfList = mutableListOf<ServiceInstantiationRequestDetails.ServiceInstantiationVnf>()
+ for (vnf in vnfs.values) {
+ val vfModules = vnf.vfModules
+ val convertedUnFilteredVfModules = convertVfModuleMapToList(vfModules)
+ val filteredVfModules = filterInstanceParamsFromVfModuleAndUniqueNames(convertedUnFilteredVfModules, isBulk)
+ val serviceInstantiationVnf = ServiceInstantiationRequestDetails.ServiceInstantiationVnf(
+ vnf.modelInfo,
+ cloudConfiguration,
+ vnf.platformName,
+ vnf.lineOfBusiness,
+ payload.productFamilyId,
+ buildVnfInstanceParams(vnf.instanceParams, filteredVfModules),
+ filteredVfModules,
+ getUniqueNameIfNeeded(vnf.instanceName, ResourceType.GENERIC_VNF, isBulk)
+ )
+ vnfList.add(serviceInstantiationVnf)
+ }
+
+ return ServiceInstantiationRequestDetails.ServiceInstantiationVnfList(vnfList)
+ }
+
+ private fun convertVfModuleMapToList(vfModules: Map<String, Map<String, VfModule>>): List<VfModuleMacro> {
+ return vfModules.values.stream().flatMap { vfModule ->
+ vfModule.values.stream().map { item ->
+ val aggregatedParams = aggregateAllInstanceParams(extractActualInstanceParams(item.instanceParams), item.supplementaryParams)
+ val aggregatedParamsConverted = JACKSON_OBJECT_MAPPER.convertValue(aggregatedParams, List::class.java)
+
+ VfModuleMacro(
+ item.modelInfo,
+ item.instanceName,
+ item.volumeGroupInstanceName,
+ aggregatedParamsConverted as List<Map<String, String>>)
+ }
+ }.collect(Collectors.toList<VfModuleMacro>())
+ }
+
+ fun aggregateAllInstanceParams(instanceParams: Map<String, String>?, supplementaryParams: Map<String, String>?): List<VfModuleInstantiationRequestDetails.UserParamMap<String, String>> {
+ var instanceParamsFinal: Map<String, String> = instanceParams ?: emptyMap()
+ val supplementaryParamsFinal: Map<String, String> = supplementaryParams ?: emptyMap()
+
+ if (!(instanceParamsFinal.isEmpty() && supplementaryParamsFinal.isEmpty())) {
+ //remove duplicate keys from instanceParams if exist in supplementaryParams
+ instanceParamsFinal = instanceParamsFinal.entries.stream()
+ .filter { m -> !supplementaryParamsFinal.containsKey(m.key) }
+ .collect(Collectors.toMap({ it.key }, { it.value }))
+
+ //aggregate the 2 collections and format them as UserParamMap
+ val aggregatedParams = UserParamMap<String, String>()
+ aggregatedParams.putAll(instanceParamsFinal)
+ aggregatedParams.putAll(supplementaryParamsFinal)
+
+ return mutableListOf(aggregatedParams)
+ }
+
+ return emptyList()
+ }
+
+ //Make sure we always get a one Map from InstanceParams
+ private fun extractActualInstanceParams(originalInstanceParams: List<MutableMap<String, String>>?): MutableMap<String, String> {
+ return if (originalInstanceParams.isNullOrEmpty() || originalInstanceParams[0].isNullOrEmpty()) {
+ mutableMapOf()
+ } else originalInstanceParams[0]
+ }
+
+ private fun filterInstanceParamsFromVfModuleAndUniqueNames(unFilteredVfModules: List<VfModuleMacro>, isBulk: Boolean): List<VfModuleMacro> {
+ return unFilteredVfModules.stream().map { vfModule ->
+ VfModuleMacro(
+ vfModule.modelInfo,
+ getUniqueNameIfNeeded(vfModule.instanceName, ResourceType.VF_MODULE, isBulk),
+ getUniqueNameIfNeeded(vfModule.volumeGroupInstanceName, ResourceType.VOLUME_GROUP, isBulk),
+ removeUnNeededParams(vfModule.instanceParams))
+ }
+ .collect(Collectors.toList<VfModuleMacro>())
+ }
+
+ fun buildVnfInstanceParams(currentVnfInstanceParams: List<MutableMap<String, String>>, vfModules: List<VfModuleMacro>): List<Map<String, String>> {
+ val filteredVnfInstanceParams = removeUnNeededParams(currentVnfInstanceParams)
+
+ val vnfInstanceParams = extractActualInstanceParams(filteredVnfInstanceParams)
+ vfModules.stream()
+ .map { x -> extractActualInstanceParams(x.instanceParams) }
+ .forEach { vnfInstanceParams.putAll(it) }
+ return if (vnfInstanceParams.isEmpty()) emptyList() else ImmutableList.of(vnfInstanceParams)
+ }
+
+ private fun generateServiceInstantiationRequestDetails(payload: ServiceInstantiation, requestParameters: ServiceInstantiationRequestDetails.RequestParameters, serviceInstanceName: String?, userId: String): ServiceInstantiationRequestDetails {
+ val requestInfo = ServiceInstantiationRequestDetails.RequestInfo(serviceInstanceName,
+ payload.productFamilyId,
+ VID_SOURCE,
+ payload.isRollbackOnFailure,
+ userId)
+ val owningEntity = ServiceInstantiationRequestDetails.ServiceInstantiationOwningEntity(payload.owningEntityId, payload.owningEntityName)
+ val subscriberInfo = generateSubscriberInfo(payload)
+ val project = if (payload.projectName != null) ServiceInstantiationRequestDetails.Project(payload.projectName) else null
+ return ServiceInstantiationRequestDetails(payload.modelInfo, owningEntity, subscriberInfo, project, requestInfo, requestParameters)
+ }
+
+ private fun generateSubscriberInfo(payload: ServiceInstantiation): SubscriberInfo {
+ val subscriberInfo = SubscriberInfo()
+ subscriberInfo.globalSubscriberId = payload.globalSubscriberId
+ return subscriberInfo
+ }
+
+ private fun generateCloudConfiguration(lcpCloudRegionId: String?, tenantId: String?): CloudConfiguration {
+ val cloudConfiguration = CloudConfiguration(lcpCloudRegionId, tenantId)
+ if(lcpCloudRegionId != null){
+ cloudOwnerService.enrichCloudConfigurationWithCloudOwner(cloudConfiguration, lcpCloudRegionId)
+ }
+ return cloudConfiguration
+ }
+
+ private fun generateRelatedInstances(relatedInstances: Map<String, ModelInfo>): MutableList<RelatedInstance> {
+ return relatedInstances.entries.stream()
+ .map { RelatedInstance(it.value, it.key) }
+ .collect(Collectors.toList())
+ }
+
+ private fun generateRequestInfo(instanceName: String?, resourceType: ResourceType?, rollbackOnFailure: Boolean?, productFamilyId: String?, userId: String) : BaseResourceInstantiationRequestDetails.RequestInfo {
+ return BaseResourceInstantiationRequestDetails.RequestInfo(
+ if (resourceType == null) null else getUniqueNameIfNeeded(instanceName, resourceType, false),
+ productFamilyId,
+ VID_SOURCE,
+ rollbackOnFailure,
+ userId)
+
+ }
+
+ private fun getUniqueNameIfNeeded(name: String?, resourceType: ResourceType, isBulk: Boolean): String? {
+ return if (StringUtils.isNotEmpty(name)) {
+ if (isBulk) asyncInstantiationBL.getUniqueName(name, resourceType) else name
+ } else {
+ null
+ }
+ }
+
+ private fun generateUserParamList(): List<ServiceInstantiationRequestDetails.UserParamNameAndValue> {
+ return emptyList()
+ }
+
+ fun generateMacroServicePre1806InstantiationRequest(payload: ServiceInstantiation, userId: String): RequestDetailsWrapper<ServiceInstantiationRequestDetails> {
+ val requestInfo = ServiceInstantiationRequestDetails.RequestInfo(payload.instanceName, payload.productFamilyId, VID_SOURCE, payload.isRollbackOnFailure, userId)
+ val userParams = generateUserParamsNameAndValue(payload.instanceParams)
+ val requestParameters = ServiceInstantiationRequestDetails.RequestParameters(payload.subscriptionServiceType, false, userParams)
+ val subscriberInfo = generateSubscriberInfoPre1806(payload)
+ val project = if (payload.projectName != null) ServiceInstantiationRequestDetails.Project(payload.projectName) else null
+ val owningEntity = ServiceInstantiationRequestDetails.ServiceInstantiationOwningEntity(payload.owningEntityId, payload.owningEntityName)
+ val cloudConfiguration = generateCloudConfiguration(payload.lcpCloudRegionId, payload.tenantId)
+ val relatedInstanceList = generateRelatedInstanceListForVrfEntry(payload.vrfs)
+
+ return RequestDetailsWrapper(ServiceInstantiationPre1806RequestDetails(
+ payload.modelInfo,
+ owningEntity,
+ subscriberInfo,
+ project,
+ requestInfo,
+ requestParameters,
+ cloudConfiguration,
+ relatedInstanceList))
+ }
+
+ private fun generateUserParamsNameAndValue(instanceParams: List<Map<String, String>>): List<ServiceInstantiationRequestDetails.UserParamNameAndValue> {
+ if (instanceParams == null){
+ return emptyList()
+ }
+ return instanceParams.getOrElse(0, {emptyMap()}).map{x-> ServiceInstantiationRequestDetails.UserParamNameAndValue(x.key, x.value)}
+ }
+
+ private fun generateSubscriberInfoPre1806(payload: ServiceInstantiation): SubscriberInfo {
+ val subscriberInfo = SubscriberInfo()
+ subscriberInfo.globalSubscriberId = payload.globalSubscriberId
+ subscriberInfo.subscriberName = payload.subscriberName
+ return subscriberInfo
+ }
+
+ private fun generateRelatedInstanceListForVrfEntry(vrfEntries: MutableMap<String, VrfEntry>): List<RelatedInstance> {
+ //fe send map of vrfs, with maps of networks and vpns, but actually we expect to only one vpn and one network
+ return if (vrfEntries.isEmpty() || vrfEntries.values.first().vpns.isEmpty() || vrfEntries.values.first().networks.isEmpty()) emptyList()
+ else {
+ val vpn = vrfEntries.values.first().vpns.values.first()
+ val network = vrfEntries.values.first().networks.values.first()
+ listOf(vpn, network).map { RelatedInstance(it.modelInfo, it.instanceId, it.instanceName) }
+ }
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/MsoResultHandlerService.kt b/vid-app-common/src/main/java/org/onap/vid/job/command/MsoResultHandlerService.kt
index e1e9b1397..50eada64f 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/MsoResultHandlerService.kt
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/MsoResultHandlerService.kt
@@ -7,9 +7,9 @@
* 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.
@@ -44,43 +44,42 @@ class MsoResultHandlerService
return jobSharedData.request as ServiceInstantiation
}
- fun handleRootResponse(jobUUID: UUID, msoResponse: RestObject<RequestReferencesContainer>): MsoResult {
+ fun handleRootResponse(sharedData: JobSharedData, msoResponse: RestObject<RequestReferencesContainer>): MsoResult {
+ val jobUUID:UUID = sharedData.jobUuid
return if (msoResponse.statusCode in 200..399) {
val jobStatus = Job.JobStatus.IN_PROGRESS
val msoResourceIds = MsoResourceIds(msoResponse.get().requestReferences.requestId, msoResponse.get().requestReferences.instanceId)
- asyncInstantiationBL.auditVidStatus(jobUUID, jobStatus)
+ auditService.auditVidStatus(jobUUID, jobStatus)
setInitialRequestAuditStatusFromMso(jobUUID, msoResourceIds.requestId)
asyncInstantiationBL.updateServiceInfo(jobUUID) { x ->
x.jobStatus = jobStatus
x.serviceInstanceId = msoResourceIds.instanceId
x.msoRequestId = UUID.fromString(msoResourceIds.requestId)
}
- MsoResult(jobStatus, msoResourceIds)
+ asyncInstantiationBL.addResourceInfo(sharedData, jobStatus, msoResourceIds.instanceId)
+ MsoResult(Job.JobStatus.COMPLETED_WITH_NO_ACTION, msoResourceIds)
} else {
auditService.setFailedAuditStatusFromMso(jobUUID, null, msoResponse.statusCode, msoResponse.raw)
- handleRootCommandFailed(jobUUID)
+ asyncInstantiationBL.addFailedResourceInfo(sharedData, msoResponse)
+ return MsoResult(Job.JobStatus.FAILED)
}
}
- fun handleResponse(msoResponse: RestObject<RequestReferencesContainer>, actionDescription: String): MsoResult {
+ fun handleResponse(sharedData: JobSharedData, msoResponse: RestObject<RequestReferencesContainer>, actionDescription: String): MsoResult {
return if (msoResponse.statusCode in 200..399) {
val msoResourceIds = MsoResourceIds(msoResponse.get().requestReferences.requestId, msoResponse.get().requestReferences.instanceId)
LOGGER.debug("Successfully sent $actionDescription. Request id: ${msoResourceIds.requestId}")
+ asyncInstantiationBL.addResourceInfo(sharedData, Job.JobStatus.IN_PROGRESS, msoResourceIds.instanceId)
MsoResult(Job.JobStatus.COMPLETED_WITH_NO_ACTION, msoResourceIds)
} else {
LOGGER.debug("Failed to $actionDescription. Details: ${msoResponse.raw}")
+ asyncInstantiationBL.addFailedResourceInfo(sharedData, msoResponse)
MsoResult(Job.JobStatus.FAILED)
}
}
-
- fun handleRootCommandFailed(jobUUID: UUID): MsoResult {
- asyncInstantiationBL.handleFailedInstantiation(jobUUID)
- return MsoResult(Job.JobStatus.FAILED)
- }
-
private fun setInitialRequestAuditStatusFromMso(jobUUID: UUID, requestId: String) {
val initialMsoRequestStatus = "REQUESTED"
- asyncInstantiationBL.auditMsoStatus(jobUUID, initialMsoRequestStatus, requestId, null)
+ auditService.auditMsoStatus(jobUUID, initialMsoRequestStatus, requestId, null)
}
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/NetworkCommand.kt b/vid-app-common/src/main/java/org/onap/vid/job/command/NetworkCommand.kt
new file mode 100644
index 000000000..bc4de7ccd
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/NetworkCommand.kt
@@ -0,0 +1,65 @@
+package org.onap.vid.job.command
+
+import org.onap.vid.job.Job
+import org.onap.vid.job.JobAdapter
+import org.onap.vid.job.JobCommand
+import org.onap.vid.job.JobsBrokerService
+import org.onap.vid.model.Action
+import org.onap.vid.model.serviceInstantiation.Network
+import org.onap.vid.mso.RestMsoImplementation
+import org.onap.vid.services.AsyncInstantiationBusinessLogic
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
+import org.springframework.http.HttpMethod
+import org.springframework.stereotype.Component
+import java.util.*
+
+
+@Component
+@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+class NetworkCommand @Autowired constructor(
+ private val asyncInstantiationBL: AsyncInstantiationBusinessLogic,
+ restMso: RestMsoImplementation,
+ private val msoRequestBuilder: MsoRequestBuilder,
+ msoResultHandlerService: MsoResultHandlerService,
+ inProgressStatusService:InProgressStatusService,
+ watchChildrenJobsBL: WatchChildrenJobsBL,
+ jobsBrokerService: JobsBrokerService,
+ jobAdapter: JobAdapter
+ ) : ResourceCommand(restMso, inProgressStatusService, msoResultHandlerService,
+ watchChildrenJobsBL, jobsBrokerService, jobAdapter), JobCommand {
+ override fun createChildren(): Job.JobStatus {
+ return Job.JobStatus.COMPLETED_WITH_NO_ACTION
+ }
+
+ override fun planCreateMyselfRestCall(commandParentData: CommandParentData, request: JobAdapter.AsyncJobRequest, userId: String, testApi: String?): MsoRestCallPlan {
+ val serviceInstanceId = commandParentData.getInstanceId(CommandParentData.CommandDataKey.SERVICE_INSTANCE_ID)
+ val serviceModelInfo = commandParentData.getModelInfo(CommandParentData.CommandDataKey.SERVICE_MODEL_INFO)
+
+ val instantiatePath = asyncInstantiationBL.getNetworkInstantiationPath(serviceInstanceId)
+ val requestDetailsWrapper = msoRequestBuilder.generateNetworkInstantiationRequest(
+ request as Network,
+ serviceModelInfo,
+ serviceInstanceId,
+ userId,
+ testApi
+ )
+
+ val actionDescription = "create network in $serviceInstanceId"
+
+ return MsoRestCallPlan(HttpMethod.POST, instantiatePath, Optional.of(requestDetailsWrapper), Optional.empty(), actionDescription)
+ }
+
+ override fun planDeleteMyselfRestCall(commandParentData: CommandParentData, request: JobAdapter.AsyncJobRequest, userId: String): MsoRestCallPlan {
+ val serviceInstanceId = commandParentData.getInstanceId(CommandParentData.CommandDataKey.SERVICE_INSTANCE_ID)
+ val path = asyncInstantiationBL.getNetworkDeletePath(serviceInstanceId, getRequest().instanceId)
+ val requestDetailsWrapper = msoRequestBuilder.generateDeleteNetworkRequest(getRequest() as Network, userId)
+ return MsoRestCallPlan(HttpMethod.DELETE, path, Optional.of(requestDetailsWrapper), Optional.of(userId),
+ "delete network ${getRequest().instanceId} from service instance $serviceInstanceId")
+ }
+
+ override fun isDescendantHasAction(phase: Action): Boolean {
+ return false
+ }
+} \ No newline at end of file
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/NetworkInstantiationCommand.java b/vid-app-common/src/main/java/org/onap/vid/job/command/NetworkInstantiationCommand.java
deleted file mode 100644
index 2b7f79c15..000000000
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/NetworkInstantiationCommand.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * 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.vid.job.command;
-
-import org.onap.vid.changeManagement.RequestDetailsWrapper;
-import org.onap.vid.job.JobAdapter;
-import org.onap.vid.job.command.CommandParentData.CommandDataKey;
-import org.onap.vid.model.serviceInstantiation.Network;
-import org.onap.vid.mso.model.NetworkInstantiationRequestDetails;
-import org.onap.vid.services.AsyncInstantiationBusinessLogic;
-import org.springframework.beans.factory.config.ConfigurableBeanFactory;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-
-import javax.inject.Inject;
-
-@Component
-@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-public class NetworkInstantiationCommand extends ResourceInstantiationCommand {
-
- @Inject
- private AsyncInstantiationBusinessLogic asyncInstantiationBL;
-
- @Override
- protected String getRequestPath() {
- return asyncInstantiationBL.getNetworkInstantiationPath(commandParentData.getInstanceId(CommandDataKey.SERVICE_INSTANCE_ID));
- }
-
- @Override
- protected RequestDetailsWrapper<NetworkInstantiationRequestDetails> generateMSORequest(JobAdapter.AsyncJobRequest request, String userId) {
- return asyncInstantiationBL.generateNetworkInstantiationRequest(
- (Network) getSharedData().getRequest(),
- commandParentData.getModelInfo(CommandDataKey.SERVICE_MODEL_INFO),
- commandParentData.getInstanceId(CommandDataKey.SERVICE_INSTANCE_ID),
- getSharedData().getUserId()
- );
- }
-
- @Override
- protected String getJobAuditMSOStatus() {
- return "NETWORK_REQUESTED";
- }
-}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/NoOpCommand.java b/vid-app-common/src/main/java/org/onap/vid/job/command/NoOpCommand.java
index 9be37bbf2..4cc54e5d7 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/NoOpCommand.java
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/NoOpCommand.java
@@ -7,9 +7,9 @@
* 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.
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/ResourceCommand.kt b/vid-app-common/src/main/java/org/onap/vid/job/command/ResourceCommand.kt
index 7f3a05be8..0e9ab7b7a 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/ResourceCommand.kt
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/ResourceCommand.kt
@@ -7,9 +7,9 @@
* 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.
@@ -20,14 +20,14 @@
package org.onap.vid.job.command
+
import com.fasterxml.jackson.module.kotlin.convertValue
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate
import org.onap.vid.changeManagement.RequestDetailsWrapper
-import org.onap.vid.job.Job
+import org.onap.vid.exceptions.AbortingException
+import org.onap.vid.exceptions.TryAgainException
+import org.onap.vid.job.*
import org.onap.vid.job.Job.JobStatus
-import org.onap.vid.job.JobAdapter
-import org.onap.vid.job.JobCommand
-import org.onap.vid.job.NextCommand
import org.onap.vid.job.impl.JobSharedData
import org.onap.vid.model.Action
import org.onap.vid.model.RequestReferencesContainer
@@ -38,6 +38,7 @@ import org.onap.vid.utils.getEnumFromMapOfStrings
import org.springframework.http.HttpMethod
import java.util.*
+
const val INTERNAL_STATE = "internalState"
const val ACTION_PHASE = "actionPhase"
const val CHILD_JOBS = "childJobs"
@@ -51,7 +52,9 @@ enum class InternalState constructor(val immediate:Boolean=false) {
DELETE_MYSELF,
CREATE_MYSELF,
IN_PROGRESS,
- TERMINAL
+ TERMINAL,
+ RESUME_MYSELF,
+ REPLACE_MYSELF,
}
data class NextInternalState(val nextActionPhase: Action, val nextInternalState: InternalState)
@@ -69,8 +72,10 @@ abstract class ResourceCommand(
protected val restMso: RestMsoImplementation,
protected val inProgressStatusService: InProgressStatusService,
protected val msoResultHandlerService: MsoResultHandlerService,
- protected val watchChildrenJobsBL: WatchChildrenJobsBL
-) : CommandBase(), JobCommand {
+ protected val watchChildrenJobsBL: WatchChildrenJobsBL,
+ private val jobsBrokerService: JobsBrokerService,
+ private val jobAdapter: JobAdapter
+ ) : CommandBase(), JobCommand {
companion object {
private val Logger = EELFLoggerDelegate.getLogger(ResourceCommand::class.java)
@@ -78,7 +83,7 @@ abstract class ResourceCommand(
abstract fun createChildren():JobStatus
- abstract fun planCreateMyselfRestCall(commandParentData: CommandParentData, request: JobAdapter.AsyncJobRequest, userId: String): MsoRestCallPlan
+ abstract fun planCreateMyselfRestCall(commandParentData: CommandParentData, request: JobAdapter.AsyncJobRequest, userId: String, testApi: String?): MsoRestCallPlan
abstract fun planDeleteMyselfRestCall(commandParentData: CommandParentData, request: JobAdapter.AsyncJobRequest, userId: String): MsoRestCallPlan
@@ -86,23 +91,28 @@ abstract class ResourceCommand(
Pair(InternalState.CREATING_CHILDREN, ::createChildren),
Pair(InternalState.WATCHING, ::watchChildren),
Pair(InternalState.CREATE_MYSELF, ::createMyself),
+ Pair(InternalState.RESUME_MYSELF, ::resumeMyself),
Pair(InternalState.DELETE_MYSELF, ::deleteMyself),
- Pair(InternalState.IN_PROGRESS, ::inProgress)
+ Pair(InternalState.IN_PROGRESS, ::inProgress),
+ Pair(InternalState.REPLACE_MYSELF, ::replaceMyself)
)
private lateinit var internalState:InternalState
protected lateinit var actionPhase: Action
- private var commandParentData: CommandParentData = CommandParentData()
- private var msoResourceIds: MsoResourceIds = EMPTY_MSO_RESOURCE_ID
+ protected var commandParentData: CommandParentData = CommandParentData()
+ protected var msoResourceIds: MsoResourceIds = EMPTY_MSO_RESOURCE_ID
protected var childJobs:List<String> = emptyList()
private lateinit var cumulativeStatus:JobStatus
override fun call(): NextCommand {
- var jobStatus:JobStatus = invokeCommand()
+ var jobStatus:JobStatus = if (internalState!=InternalState.TERMINAL) invokeCommand() else cumulativeStatus
jobStatus = comulateStatusAndUpdatePropertyIfFinal(jobStatus)
- Logger.debug("command for job ${sharedData.jobUuid} invoked and finished with jobStatus $jobStatus")
+ try {
+ Logger.debug("job: ${this.javaClass.simpleName} ${sharedData.jobUuid} $actionPhase ${getActionType()} $internalState $jobStatus $childJobs")
+ } catch (e:Exception) { /* do nothing. Just failed to log...*/}
+
if (shallStopJob(jobStatus)) {
onFinal(jobStatus)
return NextCommand(jobStatus)
@@ -133,7 +143,17 @@ abstract class ResourceCommand(
protected open fun getExternalInProgressStatus() = JobStatus.RESOURCE_IN_PROGRESS
private fun invokeCommand(): JobStatus {
- return commandByInternalState.getOrDefault (internalState, ::throwIllegalState).invoke()
+ return try {
+ commandByInternalState.getOrDefault(internalState, ::throwIllegalState).invoke()
+ }
+ catch (exception: TryAgainException) {
+ Logger.warn("caught TryAgainException. Set job status to IN_PROGRESS")
+ JobStatus.IN_PROGRESS
+ }
+ catch (exception: AbortingException) {
+ Logger.error("caught AbortingException. Set job status to FAILED")
+ JobStatus.FAILED;
+ }
}
private fun throwIllegalState():JobStatus {
@@ -177,7 +197,7 @@ abstract class ResourceCommand(
InternalState.DELETE_MYSELF -> InternalState.IN_PROGRESS
InternalState.IN_PROGRESS -> {
- if (jobStatus == Job.JobStatus.COMPLETED) InternalState.TERMINAL else InternalState.IN_PROGRESS
+ if (jobStatus == JobStatus.COMPLETED) InternalState.TERMINAL else InternalState.IN_PROGRESS
}
else -> InternalState.TERMINAL
@@ -187,10 +207,28 @@ abstract class ResourceCommand(
protected fun calcNextStateCreatePhase(jobStatus: JobStatus, internalState: InternalState): InternalState {
return when (internalState) {
- InternalState.CREATE_MYSELF -> InternalState.IN_PROGRESS
+ InternalState.CREATE_MYSELF -> when (jobStatus) {
+ JobStatus.IN_PROGRESS -> InternalState.CREATE_MYSELF
+ else -> InternalState.IN_PROGRESS
+ }
+
+ InternalState.RESUME_MYSELF -> when (jobStatus) {
+ JobStatus.IN_PROGRESS -> InternalState.RESUME_MYSELF
+ else -> InternalState.IN_PROGRESS
+ }
+
+ InternalState.REPLACE_MYSELF -> when (jobStatus) {
+ JobStatus.IN_PROGRESS -> InternalState.REPLACE_MYSELF
+ else -> InternalState.IN_PROGRESS
+ }
InternalState.IN_PROGRESS -> {
- if (jobStatus == Job.JobStatus.COMPLETED) InternalState.CREATING_CHILDREN else InternalState.IN_PROGRESS
+ when {
+ jobStatus != JobStatus.COMPLETED -> InternalState.IN_PROGRESS
+ isDescendantHasAction(Action.Create) -> InternalState.CREATING_CHILDREN
+ isDescendantHasAction(Action.Replace) -> InternalState.CREATING_CHILDREN
+ else -> InternalState.TERMINAL
+ }
}
InternalState.CREATING_CHILDREN -> InternalState.WATCHING
@@ -202,7 +240,6 @@ abstract class ResourceCommand(
}
}
-
else -> InternalState.TERMINAL
}
}
@@ -214,7 +251,7 @@ abstract class ResourceCommand(
MSO_RESOURCE_ID to msoResourceIds,
CHILD_JOBS to childJobs,
CUMULATIVE_STATUS to cumulativeStatus
- )
+ ) + commandParentData.parentData
}
override fun init(sharedData: JobSharedData, commandData: Map<String, Any>): ResourceCommand {
@@ -232,13 +269,24 @@ abstract class ResourceCommand(
return this
}
- private fun calcInitialState(commandData: Map<String, Any>, phase: Action):InternalState {
+ fun calcInitialState(commandData: Map<String, Any>, phase: Action):InternalState {
val status:InternalState = getEnumFromMapOfStrings(commandData, INTERNAL_STATE, InternalState.INITIAL)
if (status == InternalState.INITIAL) {
onInitial(phase)
return when (phase) {
- Action.Delete -> InternalState.CREATING_CHILDREN
- Action.Create -> if (isNeedToCreateMyself()) InternalState.CREATE_MYSELF else InternalState.CREATING_CHILDREN
+ Action.Delete -> when {
+ isDescendantHasAction(phase) -> InternalState.CREATING_CHILDREN
+ isNeedToDeleteMyself() -> InternalState.DELETE_MYSELF
+ else -> InternalState.TERMINAL
+ }
+ Action.Create -> when {
+ isNeedToCreateMyself() -> InternalState.CREATE_MYSELF
+ isNeedToResumeMySelf() -> InternalState.RESUME_MYSELF
+ isNeedToReplaceMySelf() -> InternalState.REPLACE_MYSELF
+ isDescendantHasAction(phase) -> InternalState.CREATING_CHILDREN
+ isDescendantHasAction(Action.Replace) -> InternalState.CREATING_CHILDREN
+ else -> InternalState.TERMINAL
+ }
else -> throw IllegalStateException("state $internalState is not supported yet")
}
}
@@ -269,7 +317,11 @@ abstract class ResourceCommand(
protected open fun isNeedToCreateMyself(): Boolean = getActionType() == Action.Create
- protected open fun inProgress(): Job.JobStatus {
+ protected open fun isNeedToResumeMySelf(): Boolean = getActionType() == Action.Resume
+
+ protected open fun isNeedToReplaceMySelf(): Boolean = false
+
+ protected open fun inProgress(): JobStatus {
val requestId:String = msoResourceIds.requestId;
return try {
val jobStatus = inProgressStatusService.call(getExpiryChecker(), sharedData, requestId)
@@ -277,29 +329,35 @@ abstract class ResourceCommand(
} catch (e: javax.ws.rs.ProcessingException) {
// Retry when we can't connect MSO during getStatus
Logger.error(EELFLoggerDelegate.errorLogger, "Cannot get orchestration status for {}, will retry: {}", requestId, e, e)
- Job.JobStatus.IN_PROGRESS;
+ JobStatus.IN_PROGRESS;
} catch (e: InProgressStatusService.BadResponseFromMso) {
inProgressStatusService.handleFailedMsoResponse(sharedData.jobUuid, requestId, e.msoResponse)
- Job.JobStatus.IN_PROGRESS
+ JobStatus.IN_PROGRESS
} catch (e: RuntimeException) {
Logger.error(EELFLoggerDelegate.errorLogger, "Cannot get orchestration status for {}, stopping: {}", requestId, e, e)
- Job.JobStatus.STOPPED
+ JobStatus.STOPPED
}
}
- fun createMyself(): Job.JobStatus {
- val createMyselfCommand = planCreateMyselfRestCall(commandParentData, sharedData.request, sharedData.userId)
-
+ fun createMyself(): JobStatus {
+ val createMyselfCommand = planCreateMyselfRestCall(commandParentData, sharedData.request, sharedData.userId, sharedData.testApi)
return executeAndHandleMsoInstanceRequest(createMyselfCommand)
}
- fun deleteMyself(): Job.JobStatus {
- val deleteMyselfCommand = planDeleteMyselfRestCall(commandParentData, sharedData.request, sharedData.userId)
+ protected open fun resumeMyself(): JobStatus {
+ throw NotImplementedError("Resume is not implemented for this command " + this.javaClass)
+ }
+
+ protected open fun replaceMyself(): JobStatus {
+ throw NotImplementedError("Replace is not implemented for this command " + this.javaClass)
+ }
+ fun deleteMyself(): JobStatus {
+ val deleteMyselfCommand = planDeleteMyselfRestCall(commandParentData, sharedData.request, sharedData.userId)
return executeAndHandleMsoInstanceRequest(deleteMyselfCommand)
}
- private fun executeAndHandleMsoInstanceRequest(restCallPlan: MsoRestCallPlan): JobStatus {
+ protected fun executeAndHandleMsoInstanceRequest(restCallPlan: MsoRestCallPlan): JobStatus {
val msoResponse = restMso.restCall(
restCallPlan.httpMethod,
RequestReferencesContainer::class.java,
@@ -309,9 +367,9 @@ abstract class ResourceCommand(
)
val msoResult = if (isServiceCommand()) {
- msoResultHandlerService.handleRootResponse(sharedData.jobUuid, msoResponse)
+ msoResultHandlerService.handleRootResponse(sharedData, msoResponse)
} else {
- msoResultHandlerService.handleResponse(msoResponse, restCallPlan.actionDescription)
+ msoResultHandlerService.handleResponse(sharedData, msoResponse, restCallPlan.actionDescription)
}
this.msoResourceIds = msoResult.msoResourceIds
@@ -321,14 +379,14 @@ abstract class ResourceCommand(
protected open fun getExpiryChecker(): ExpiryChecker = ExpiryChecker {false}
protected open fun handleInProgressStatus(jobStatus: JobStatus): JobStatus {
- return if (jobStatus == Job.JobStatus.PAUSE) Job.JobStatus.IN_PROGRESS else jobStatus
+ return if (jobStatus == JobStatus.PAUSE) JobStatus.IN_PROGRESS else jobStatus
}
protected open fun watchChildren():JobStatus {
return watchChildrenJobsBL.retrieveChildrenJobsStatus(childJobs)
}
- private fun comulateStatusAndUpdatePropertyIfFinal(internalStateStatus: JobStatus): JobStatus {
+ protected fun comulateStatusAndUpdatePropertyIfFinal(internalStateStatus: JobStatus): JobStatus {
val status = watchChildrenJobsBL.cumulateJobStatus(internalStateStatus, cumulativeStatus)
//we want to update cumulativeStatus only for final status
@@ -338,6 +396,44 @@ abstract class ResourceCommand(
return status
}
+
+ protected fun buildDataForChild(request: BaseResource, actionPhase: Action): Map<String, Any> {
+ addMyselfToChildrenData(commandParentData, request)
+ commandParentData.setActionPhase(actionPhase)
+ return commandParentData.parentData
+ }
+
+ protected open fun addMyselfToChildrenData(commandParentData: CommandParentData, request: BaseResource) {
+ // Nothing by default
+ }
+
+ protected open fun isDescendantHasAction(phase:Action):Boolean = isDescendantHasAction(getRequest(), phase, true )
+
+
+ @JvmOverloads
+ fun isDescendantHasAction(request: BaseResource, phase: Action, isFirstLevel:Boolean=true): Boolean {
+ if (!isFirstLevel && request.action == phase) {
+ return true;
+ }
+
+ return request.children.map {this.isDescendantHasAction(it, phase, false)}.any {it}
+ }
+
+ protected fun getActualInstanceId(request: BaseResource):String =
+ if (getActionType() == Action.Create) msoResourceIds.instanceId else request.instanceId
+
+
+ protected fun pushChildrenJobsToBroker(children:Collection<BaseResource>,
+ dataForChild: Map<String, Any>,
+ jobType: JobType?=null): List<String> {
+ var counter = 0;
+ return children
+ .map {Pair(it, counter++)}
+ .map { jobAdapter.createChildJob(jobType ?: it.first.jobType, it.first, sharedData, dataForChild, it.second) }
+ .map { jobsBrokerService.add(it) }
+ .map { it.toString() }
+ }
+
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/ResourceInstantiationCommand.java b/vid-app-common/src/main/java/org/onap/vid/job/command/ResourceInstantiationCommand.java
deleted file mode 100644
index 98980a35d..000000000
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/ResourceInstantiationCommand.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * 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.vid.job.command;
-
-import org.onap.vid.changeManagement.RequestDetailsWrapper;
-import org.onap.vid.job.Job;
-import org.onap.vid.job.JobAdapter;
-import org.onap.vid.job.JobCommand;
-import org.onap.vid.job.NextCommand;
-import org.onap.vid.job.impl.JobSharedData;
-import org.onap.vid.model.RequestReferencesContainer;
-import org.onap.vid.mso.RestMsoImplementation;
-import org.onap.vid.mso.RestObject;
-import org.onap.vid.mso.model.BaseResourceInstantiationRequestDetails;
-import org.onap.vid.services.AsyncInstantiationBusinessLogic;
-import org.onap.vid.services.AuditService;
-import org.springframework.beans.factory.config.ConfigurableBeanFactory;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-
-import javax.inject.Inject;
-import java.util.Map;
-
-
-@Component
-@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-public abstract class ResourceInstantiationCommand extends BaseInstantiationCommand implements JobCommand {
-
-
- @Inject
- protected RestMsoImplementation restMso;
-
- @Inject
- private AsyncInstantiationBusinessLogic asyncInstantiationBL;
-
- @Inject
- private AuditService auditService;
-
- @Override
- public ResourceInstantiationCommand init(JobSharedData sharedData, Map<String, Object> commandData) {
- super.init(sharedData, commandData);
- return this;
- }
-
- @Override
- public Map<String, Object> getData() {
- return commandParentData.getParentData();
- }
-
- @Override
- public NextCommand call() {
- if (!shouldInstantiateMyself()) {
- return new NextCommand(Job.JobStatus.COMPLETED_WITH_NO_ACTION);
- }
-
- RequestDetailsWrapper<? extends BaseResourceInstantiationRequestDetails> requestDetailsWrapper = generateMSORequest(
- getSharedData().getRequest(),
- getSharedData().getUserId()
- );
- String instantiatePath = getRequestPath();
-
- RestObject<RequestReferencesContainer> msoResponse = restMso.PostForObject(requestDetailsWrapper,
- instantiatePath, RequestReferencesContainer.class);
-
- if (msoResponse.getStatusCode() >= 200 && msoResponse.getStatusCode() < 400) {
- String requestId = msoResponse.get().getRequestReferences().getRequestId();
- String instanceId = msoResponse.get().getRequestReferences().getInstanceId();
- asyncInstantiationBL.auditMsoStatus(getSharedData().getRootJobId(), getJobAuditMSOStatus(), requestId, null);
- return getNextCommand(requestId, instanceId);
- }
- else {
- auditService.setFailedAuditStatusFromMso(getSharedData().getRootJobId(), null, msoResponse.getStatusCode(), msoResponse.getRaw());
- return new NextCommand(Job.JobStatus.FAILED);
- }
- }
- protected NextCommand getNextCommand(String requestId, String instanceId){
- return new NextCommand(Job.JobStatus.RESOURCE_IN_PROGRESS, new ResourceInProgressStatusCommand(getSharedData(), requestId, instanceId));
- }
-
- protected boolean shouldInstantiateMyself() {
- return true;
- }
-
- protected abstract String getRequestPath();
- protected abstract RequestDetailsWrapper<? extends BaseResourceInstantiationRequestDetails> generateMSORequest(JobAdapter.AsyncJobRequest request, String userId);
- protected abstract String getJobAuditMSOStatus();
-}
-
-
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/ResourceWithChildrenInProgressCommand.java b/vid-app-common/src/main/java/org/onap/vid/job/command/ResourceWithChildrenInProgressCommand.java
deleted file mode 100644
index 0a345c52c..000000000
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/ResourceWithChildrenInProgressCommand.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * 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.vid.job.command;
-
-import org.onap.vid.job.Job;
-import org.onap.vid.job.NextCommand;
-import org.onap.vid.job.impl.JobSharedData;
-
-import java.util.HashMap;
-import java.util.Map;
-
-
-public class ResourceWithChildrenInProgressCommand extends BaseInProgressStatusCommand {
-
- public ResourceWithChildrenInProgressCommand() {
- }
-
- public ResourceWithChildrenInProgressCommand(JobSharedData sharedData,
- String requestId,
- String instanceId,
- CommandParentData commandParentData) {
- init(sharedData, requestId, instanceId, commandParentData);
- }
-
- protected BaseInProgressStatusCommand init(JobSharedData sharedData,
- String requestId,
- String instanceId,
- CommandParentData commandParentData) {
- init(sharedData, requestId, instanceId);
- this.commandParentData= commandParentData;
- return this;
- }
-
-
- @Override
- public Map<String, Object> getData() {
- Map<String, Object> data = new HashMap<>(super.getData());
- data.putAll(buildDataForChild());
- return data;
- }
-
- @Override
- public BaseInProgressStatusCommand init(JobSharedData sharedData, Map<String, Object> commandData) {
- return init(
- sharedData,
- (String) commandData.get("requestId"),
- (String) commandData.get("instanceId"),
- commandParentData.initParentData(commandData));
- }
-
- protected Map<String, Object> buildDataForChild() {
- return commandParentData.getParentData();
- }
-
-
-
- @Override
- protected NextCommand processJobStatus(Job.JobStatus jobStatus) {
- return new NextCommand(jobStatus, this);
- }
-
- @Override
- protected ExpiryChecker getExpiryChecker() {
- return x->false;
- }
-
-}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/RootServiceCommand.kt b/vid-app-common/src/main/java/org/onap/vid/job/command/RootServiceCommand.kt
new file mode 100644
index 000000000..c4680b2bd
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/RootServiceCommand.kt
@@ -0,0 +1,98 @@
+package org.onap.vid.job.command
+
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate
+import org.onap.vid.job.Job
+import org.onap.vid.job.JobAdapter
+import org.onap.vid.job.JobCommand
+import org.onap.vid.job.JobsBrokerService
+import org.onap.vid.job.impl.JobSharedData
+import org.onap.vid.model.Action
+import org.onap.vid.model.serviceInstantiation.ServiceInstantiation
+import org.onap.vid.mso.RestMsoImplementation
+import org.onap.vid.services.AsyncInstantiationBusinessLogic
+import org.onap.vid.services.AuditService
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.http.HttpMethod
+import java.util.*
+
+abstract class RootServiceCommand @Autowired constructor(
+ restMso: RestMsoImplementation,
+ inProgressStatusService: InProgressStatusService,
+ msoResultHandlerService: MsoResultHandlerService,
+ watchChildrenJobsBL: WatchChildrenJobsBL,
+ jobsBrokerService: JobsBrokerService,
+ jobAdapter: JobAdapter,
+ private val asyncInstantiationBL: AsyncInstantiationBusinessLogic,
+ private val auditService: AuditService,
+ private val msoRequestBuilder: MsoRequestBuilder
+) : ResourceCommand(restMso, inProgressStatusService, msoResultHandlerService,
+ watchChildrenJobsBL, jobsBrokerService, jobAdapter), JobCommand {
+
+ lateinit var optimisticUniqueServiceInstanceName: String
+
+ companion object {
+ private val LOGGER = EELFLoggerDelegate.getLogger(RootServiceCommand::class.java)
+ }
+
+ final override fun onInitial(phase: Action) {
+ if (phase== Action.Delete) {
+ asyncInstantiationBL.updateServiceInfoAndAuditStatus(sharedData.jobUuid, Job.JobStatus.IN_PROGRESS)
+ }
+ }
+
+ final override fun getExternalInProgressStatus() = Job.JobStatus.IN_PROGRESS
+
+ final override fun getData(): Map<String, Any?> {
+ return super.getData() + mapOf(UNIQUE_INSTANCE_NAME to optimisticUniqueServiceInstanceName)
+ }
+
+ final override fun onFinal(jobStatus: Job.JobStatus) {
+ asyncInstantiationBL.updateServiceInfoAndAuditStatus(sharedData.jobUuid, jobStatus)
+ if (jobStatus.isFailure) {
+ asyncInstantiationBL.handleFailedInstantiation(sharedData.jobUuid)
+ }
+ }
+
+ final override fun init(sharedData: JobSharedData, commandData: Map<String, Any>): ResourceCommand {
+ optimisticUniqueServiceInstanceName = commandData.getOrDefault(UNIQUE_INSTANCE_NAME, "") as String
+ return super<ResourceCommand>.init(sharedData, commandData)
+ }
+
+ final override fun isServiceCommand(): Boolean = true
+
+ final override fun getExpiryChecker(): ExpiryChecker {
+ return ServiceExpiryChecker()
+ }
+
+ override fun resumeMyself(): Job.JobStatus {
+ val requestType = "createInstance"
+ val scope = "service"
+ val serviceInstanceId = getActualInstanceId(getRequest())
+ try {
+ val requests = auditService.retrieveRequestsFromMsoByServiceIdAndRequestTypeAndScope(serviceInstanceId, requestType, scope)
+ if (requests.isEmpty() || requests[0].requestId == null) {
+ LOGGER.error("Failed to retrieve requestId with type: $type, scope: $scope for service instanceId $serviceInstanceId ")
+ return Job.JobStatus.FAILED
+ }
+ val createMyselfCommand = planResumeMyselfRestCall(requests[0].requestId, sharedData.userId)
+ return executeAndHandleMsoInstanceRequest(createMyselfCommand)
+ } catch (exception: Exception) {
+ LOGGER.error("Failed to resume instanceId $serviceInstanceId ", exception)
+ return Job.JobStatus.FAILED
+ }
+ }
+
+ private fun planResumeMyselfRestCall(requestId: String, userId: String): MsoRestCallPlan {
+ val path = asyncInstantiationBL.getResumeRequestPath(requestId)
+ return MsoRestCallPlan(HttpMethod.POST, path, Optional.empty(), Optional.of(userId), "resume request $requestId")
+ }
+
+ override fun planDeleteMyselfRestCall(commandParentData: CommandParentData, request: JobAdapter.AsyncJobRequest, userId: String): MsoRestCallPlan {
+ val requestDetailsWrapper = msoRequestBuilder.generateServiceDeletionRequest(
+ request as ServiceInstantiation, userId
+ )
+ val path = asyncInstantiationBL.getServiceDeletionPath(request.instanceId)
+ return MsoRestCallPlan(HttpMethod.DELETE, path, Optional.of(requestDetailsWrapper), Optional.empty(),
+ "delete instance with id ${request.instanceId}")
+ }
+} \ No newline at end of file
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/ServiceInProgressStatusCommand.java b/vid-app-common/src/main/java/org/onap/vid/job/command/ServiceInProgressStatusCommand.java
deleted file mode 100644
index 6fd22132f..000000000
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/ServiceInProgressStatusCommand.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * 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.vid.job.command;
-
-import org.apache.commons.collections.MapUtils;
-import org.onap.vid.job.Job;
-import org.onap.vid.job.Job.JobStatus;
-import org.onap.vid.job.JobCommand;
-import org.onap.vid.job.JobType;
-import org.onap.vid.job.NextCommand;
-import org.onap.vid.job.command.CommandParentData.CommandDataKey;
-import org.onap.vid.job.impl.JobSharedData;
-import org.onap.vid.model.serviceInstantiation.ServiceInstantiation;
-import org.onap.vid.properties.Features;
-import org.springframework.beans.factory.config.ConfigurableBeanFactory;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-@Component
-@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-public class ServiceInProgressStatusCommand extends BaseInProgressStatusCommand {
-
- public ServiceInProgressStatusCommand() {
- }
-
- ServiceInProgressStatusCommand(JobSharedData sharedData, MsoResourceIds msoResourceIds) {
- init(sharedData, msoResourceIds.getRequestId(), msoResourceIds.getInstanceId());
- }
-
- @Override
- protected ExpiryChecker getExpiryChecker() {
- return new ServiceExpiryChecker();
- }
-
- protected NextCommand processJobStatus(Job.JobStatus jobStatus) {
- JobCommand jobCommand = this;
- Job.JobStatus nextJobStatus = jobStatus;
- switch (jobStatus) {
- case FAILED:
- asyncInstantiationBL.handleFailedInstantiation(getSharedData().getJobUuid());
- return new NextCommand(nextJobStatus, jobCommand);
- case PAUSE:
- nextJobStatus = Job.JobStatus.IN_PROGRESS;
- break;
- case COMPLETED:
- ServiceInstantiation request = (ServiceInstantiation) getSharedData().getRequest();
- if (isNeedToCreateChildJobs(request)) {
- List<String> childrenJobs = getChildJobs(request);
- nextJobStatus = Job.JobStatus.IN_PROGRESS;
- jobCommand = new WatchingCommand(getSharedData(), childrenJobs, true);
- return new NextCommand(nextJobStatus, jobCommand);
- }
- break;
- default: // for sonar
- }
- asyncInstantiationBL.updateServiceInfoAndAuditStatus(getSharedData().getJobUuid(), jobStatus);
- return new NextCommand(nextJobStatus, jobCommand);
- }
-
- private List<String> getChildJobs(ServiceInstantiation request) {
- Map<String, Object> dataForChild = buildDataForChild(request);
-
- Stream<String> vnfJobs = request.getVnfs().values().stream().map(
- vnf -> jobsBrokerService.add(
- jobAdapter.createChildJob(JobType.VnfInstantiation, JobStatus.CREATING , vnf, getSharedData(), dataForChild)).toString()
- );
-
- Stream<String> networkJobs = request.getNetworks().values().stream().map(
- network -> jobsBrokerService.add(
- jobAdapter.createChildJob(JobType.NetworkInstantiation, JobStatus.CREATING , network, getSharedData(), dataForChild)).toString()
- );
-
- Stream<String> instanceGroupJobs = request.getVnfGroups().values().stream().map(
- instanceGroup -> jobsBrokerService.add(
- jobAdapter.createChildJob(JobType.InstanceGroupInstantiation, JobStatus.CREATING , instanceGroup, getSharedData(), dataForChild)).toString()
- );
-
- return Stream.of(vnfJobs, networkJobs, instanceGroupJobs)
- .reduce(Stream::concat)
- .orElseGet(Stream::empty)
- .collect(Collectors.toList());
- }
-
- public boolean isNeedToCreateChildJobs(ServiceInstantiation request) {
- return featureManager.isActive(Features.FLAG_ASYNC_ALACARTE_VNF) && request.isALaCarte() &&
- (
- MapUtils.isNotEmpty(request.getVnfs()) || MapUtils.isNotEmpty(request.getNetworks()) ||
- (featureManager.isActive(Features.FLAG_1902_VNF_GROUPING) && MapUtils.isNotEmpty(request.getVnfGroups()))
- );
- }
-
- protected Map<String, Object> buildDataForChild(ServiceInstantiation request) {
- commandParentData.addInstanceId(CommandDataKey.SERVICE_INSTANCE_ID, this.instanceId);
- commandParentData.addModelInfo(CommandDataKey.SERVICE_MODEL_INFO, request.getModelInfo());
- return commandParentData.getParentData();
- }
-}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/ServiceInstantiationCommand.java b/vid-app-common/src/main/java/org/onap/vid/job/command/ServiceInstantiationCommand.java
deleted file mode 100644
index 414379b0d..000000000
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/ServiceInstantiationCommand.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * 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.vid.job.command;
-
-import com.google.common.collect.ImmutableMap;
-import org.apache.commons.lang3.ObjectUtils;
-import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.onap.vid.aai.ExceptionWithRequestInfo;
-import org.onap.vid.changeManagement.RequestDetailsWrapper;
-import org.onap.vid.exceptions.MaxRetriesException;
-import org.onap.vid.job.Job;
-import org.onap.vid.job.JobCommand;
-import org.onap.vid.job.NextCommand;
-import org.onap.vid.job.impl.JobSharedData;
-import org.onap.vid.model.RequestReferencesContainer;
-import org.onap.vid.model.serviceInstantiation.ServiceInstantiation;
-import org.onap.vid.mso.RestMsoImplementation;
-import org.onap.vid.mso.RestObject;
-import org.onap.vid.mso.model.ServiceInstantiationRequestDetails;
-import org.onap.vid.services.AsyncInstantiationBusinessLogic;
-
-import javax.inject.Inject;
-import java.util.Map;
-
-
-public abstract class ServiceInstantiationCommand extends BaseRootCommand implements JobCommand {
-
- private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(ServiceInstantiationCommand.class);
-
- @Inject
- protected AsyncInstantiationBusinessLogic asyncInstantiationBL;
-
- @Inject
- private RestMsoImplementation restMso;
-
- protected String optimisticUniqueServiceInstanceName;
-
- public ServiceInstantiationCommand() {
- }
-
- @Override
- public NextCommand call() {
- RequestDetailsWrapper<ServiceInstantiationRequestDetails> requestDetailsWrapper ;
- try {
- requestDetailsWrapper = generateServiceInstantiationRequest();
- }
-
- //Aai return bad response while checking names uniqueness
- catch (ExceptionWithRequestInfo exception) {
- return handleAaiNameUniquenessBadResponse(exception);
- }
-
- //Vid reached to max retries while trying to find unique name in AAI
- catch (MaxRetriesException exception) {
- return handleMaxRetryInNameUniqueness(exception);
- }
-
- String path = asyncInstantiationBL.getServiceInstantiationPath(getRequest());
-
- RestObject<RequestReferencesContainer> msoResponse = restMso.PostForObject(requestDetailsWrapper,
- path, RequestReferencesContainer.class);
-
- return handleRootResponse(msoResponse);
-
- }
-
- @Override
- protected ServiceInstantiation getRequest() {
- return (ServiceInstantiation) getSharedData().getRequest();
- }
-
- protected abstract RequestDetailsWrapper<ServiceInstantiationRequestDetails> generateServiceInstantiationRequest();
-
- private NextCommand handleMaxRetryInNameUniqueness(MaxRetriesException exception) {
- LOGGER.error("Failed to find unused name in AAI. Set the job to FAILED ", exception);
- return handleCommandFailed();
- }
-
- private NextCommand handleAaiNameUniquenessBadResponse(ExceptionWithRequestInfo exception) {
- LOGGER.error("Failed to check name uniqueness in AAI. VID will try again later", exception);
- //put the job in_progress so we will keep trying to check name uniqueness in AAI
- //And then send the request to MSO
- return new NextCommand(Job.JobStatus.IN_PROGRESS, this);
- }
-
- @Override
- public ServiceInstantiationCommand init(JobSharedData sharedData, Map<String, Object> commandData) {
-
- return init(
- sharedData,
- (String) commandData.get("optimisticUniqueServiceInstanceName")
- );
- }
-
- protected ServiceInstantiationCommand init(JobSharedData sharedData, String optimisticUniqueServiceInstanceName) {
- init(sharedData);
- this.optimisticUniqueServiceInstanceName = ObjectUtils.defaultIfNull(optimisticUniqueServiceInstanceName,
- (getRequest()).getInstanceName());
- return this;
- }
-
- @Override
- public Map<String, Object> getData() {
- return ImmutableMap.of(
- "optimisticUniqueServiceInstanceName", optimisticUniqueServiceInstanceName
- );
- }
-}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/VfmoduleCommand.kt b/vid-app-common/src/main/java/org/onap/vid/job/command/VfmoduleCommand.kt
new file mode 100644
index 000000000..af52fa049
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/VfmoduleCommand.kt
@@ -0,0 +1,106 @@
+package org.onap.vid.job.command
+
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate
+import org.onap.vid.job.Job
+import org.onap.vid.job.JobAdapter
+import org.onap.vid.job.JobCommand
+import org.onap.vid.job.JobsBrokerService
+import org.onap.vid.model.Action
+import org.onap.vid.model.serviceInstantiation.VfModule
+import org.onap.vid.mso.RestMsoImplementation
+import org.onap.vid.services.AsyncInstantiationBusinessLogic
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
+import org.springframework.http.HttpMethod
+import org.springframework.stereotype.Component
+import java.util.*
+
+@Component
+@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+class VfmoduleCommand @Autowired constructor(
+ private val asyncInstantiationBL: AsyncInstantiationBusinessLogic,
+ restMso: RestMsoImplementation,
+ private val msoRequestBuilder: MsoRequestBuilder,
+ msoResultHandlerService: MsoResultHandlerService,
+ inProgressStatusService:InProgressStatusService,
+ watchChildrenJobsBL: WatchChildrenJobsBL,
+ jobsBrokerService: JobsBrokerService,
+ jobAdapter: JobAdapter
+) : ResourceCommand(restMso, inProgressStatusService, msoResultHandlerService,
+ watchChildrenJobsBL, jobsBrokerService, jobAdapter), JobCommand {
+
+ companion object {
+ private val LOGGER = EELFLoggerDelegate.getLogger(VfmoduleCommand::class.java)
+ }
+
+ override fun createChildren(): Job.JobStatus {
+ return Job.JobStatus.COMPLETED_WITH_NO_ACTION
+ }
+
+ override fun planCreateMyselfRestCall(commandParentData: CommandParentData, request: JobAdapter.AsyncJobRequest, userId: String, testApi: String?): MsoRestCallPlan {
+ val serviceInstanceId = commandParentData.getInstanceId(CommandParentData.CommandDataKey.SERVICE_INSTANCE_ID)
+ val serviceModelInfo = commandParentData.getModelInfo(CommandParentData.CommandDataKey.SERVICE_MODEL_INFO)
+ val vnfModelInfo = commandParentData.getModelInfo(CommandParentData.CommandDataKey.VNF_MODEL_INFO)
+ val vnfInstanceId = commandParentData.getInstanceId(CommandParentData.CommandDataKey.VNF_INSTANCE_ID)
+ val vgInstaceId = commandParentData.getInstanceId(CommandParentData.CommandDataKey.VG_INSTANCE_ID)
+
+ val instantiatePath = asyncInstantiationBL.getVfmoduleInstantiationPath(serviceInstanceId, vnfInstanceId)
+
+ val requestDetailsWrapper = msoRequestBuilder.generateVfModuleInstantiationRequest(
+ request as VfModule,
+ serviceModelInfo, serviceInstanceId, vnfModelInfo, vnfInstanceId, vgInstaceId, userId, testApi)
+
+ val actionDescription = "create vfmodule in $vnfInstanceId"
+
+ return MsoRestCallPlan(HttpMethod.POST, instantiatePath, Optional.of(requestDetailsWrapper), Optional.empty(), actionDescription)
+
+ }
+
+ override fun planDeleteMyselfRestCall(commandParentData: CommandParentData, request: JobAdapter.AsyncJobRequest, userId: String): MsoRestCallPlan {
+ val serviceInstanceId = commandParentData.getInstanceId(CommandParentData.CommandDataKey.SERVICE_INSTANCE_ID)
+ val vnfInstanceId = commandParentData.getInstanceId(CommandParentData.CommandDataKey.VNF_INSTANCE_ID)
+
+ val path = asyncInstantiationBL.getVfModuleDeletePath(serviceInstanceId, vnfInstanceId, getRequest().instanceId)
+ val requestDetailsWrapper = msoRequestBuilder.generateDeleteVfModuleRequest(getRequest(), userId)
+ return MsoRestCallPlan(HttpMethod.DELETE, path, Optional.of(requestDetailsWrapper), Optional.of(userId),
+ "delete vfmodule ${getRequest().instanceId} from service instance $serviceInstanceId and vnf $vnfInstanceId")
+ }
+
+ override fun getRequest(): VfModule {
+ return sharedData.request as VfModule
+ }
+
+ override fun isDescendantHasAction(phase: Action): Boolean {
+ return false
+ }
+
+ private fun planReplaceMyselfRestCall(commandParentData: CommandParentData, request: JobAdapter.AsyncJobRequest, userId: String, testApi: String?): MsoRestCallPlan {
+ val serviceInstanceId = commandParentData.getInstanceId(CommandParentData.CommandDataKey.SERVICE_INSTANCE_ID)
+ val serviceModelInfo = commandParentData.getModelInfo(CommandParentData.CommandDataKey.SERVICE_MODEL_INFO)
+ val vnfModelInfo = commandParentData.getModelInfo(CommandParentData.CommandDataKey.VNF_MODEL_INFO)
+ val vnfInstanceId = commandParentData.getInstanceId(CommandParentData.CommandDataKey.VNF_INSTANCE_ID)
+ val replacePath = asyncInstantiationBL.getVfModuleReplacePath(serviceInstanceId, vnfInstanceId, getRequest().instanceId)
+
+ val requestDetailsWrapper = msoRequestBuilder.generateVfModuleInstantiationRequest(
+ request as VfModule, serviceModelInfo, serviceInstanceId,vnfModelInfo, vnfInstanceId,null,userId, testApi)
+
+ val actionDescription = "replace vfmodule ${request.instanceId}"
+
+ return MsoRestCallPlan(HttpMethod.POST, replacePath, Optional.of(requestDetailsWrapper), Optional.of(userId), actionDescription)
+ }
+
+ override fun replaceMyself(): Job.JobStatus {
+ try {
+ val replaceMyselfCommand = planReplaceMyselfRestCall(commandParentData, sharedData.request, sharedData.userId, sharedData.testApi )
+ return executeAndHandleMsoInstanceRequest(replaceMyselfCommand)
+ } catch (exception: Exception) {
+ LOGGER.error("Failed to replace instanceId ${getRequest().instanceId} ", exception)
+ return Job.JobStatus.FAILED
+ }
+ }
+
+ override fun isNeedToReplaceMySelf(): Boolean {
+ return getActionType() == Action.Replace
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/VfmoduleInstantiationCommand.java b/vid-app-common/src/main/java/org/onap/vid/job/command/VfmoduleInstantiationCommand.java
deleted file mode 100644
index 75bf97f8d..000000000
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/VfmoduleInstantiationCommand.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * 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.vid.job.command;
-
-import org.onap.vid.changeManagement.RequestDetailsWrapper;
-import org.onap.vid.job.JobAdapter;
-import org.onap.vid.job.command.CommandParentData.CommandDataKey;
-import org.onap.vid.model.serviceInstantiation.VfModule;
-import org.onap.vid.mso.model.VfModuleInstantiationRequestDetails;
-import org.onap.vid.services.AsyncInstantiationBusinessLogic;
-import org.springframework.beans.factory.config.ConfigurableBeanFactory;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-
-import javax.inject.Inject;
-
-@Component
-@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-public class VfmoduleInstantiationCommand extends ResourceInstantiationCommand {
- @Inject
- private AsyncInstantiationBusinessLogic asyncInstantiationBL;
-
- @Override
- protected String getRequestPath() {
- return asyncInstantiationBL.getVfmoduleInstantiationPath(commandParentData.getInstanceId(CommandDataKey.SERVICE_INSTANCE_ID),commandParentData.getInstanceId(CommandDataKey.VNF_INSTANCE_ID));
- }
-
- @Override
- protected RequestDetailsWrapper<VfModuleInstantiationRequestDetails> generateMSORequest(JobAdapter.AsyncJobRequest request, String userId) {
- return asyncInstantiationBL.generateVfModuleInstantiationRequest(
- (VfModule) getSharedData().getRequest(),
- commandParentData.getModelInfo(CommandDataKey.SERVICE_MODEL_INFO),
- commandParentData.getInstanceId(CommandDataKey.SERVICE_INSTANCE_ID),
- commandParentData.getModelInfo(CommandDataKey.VNF_MODEL_INFO),
- commandParentData.getInstanceId(CommandDataKey.VNF_INSTANCE_ID),
- commandParentData.getInstanceId(CommandDataKey.VG_INSTANCE_ID),
- getSharedData().getUserId()
- );
- }
-
- @Override
- protected String getJobAuditMSOStatus() {
- return "VF_MODULE_REQUESTED";
- }
-
-}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/VnfCommand.kt b/vid-app-common/src/main/java/org/onap/vid/job/command/VnfCommand.kt
new file mode 100644
index 000000000..a89e196de
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/VnfCommand.kt
@@ -0,0 +1,140 @@
+package org.onap.vid.job.command
+
+import org.apache.commons.collections.MapUtils
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate
+import org.onap.vid.asdc.AsdcCatalogException
+import org.onap.vid.job.*
+import org.onap.vid.job.impl.JobSharedData
+import org.onap.vid.model.Action
+import org.onap.vid.model.serviceInstantiation.BaseResource
+import org.onap.vid.model.serviceInstantiation.VfModule
+import org.onap.vid.model.serviceInstantiation.Vnf
+import org.onap.vid.mso.RestMsoImplementation
+import org.onap.vid.properties.Features
+import org.onap.vid.services.AsyncInstantiationBusinessLogic
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
+import org.springframework.http.HttpMethod
+import org.springframework.stereotype.Component
+import org.togglz.core.manager.FeatureManager
+import java.util.*
+import java.util.stream.Collectors
+import kotlin.properties.Delegates
+
+const val NEED_TO_CREATE_BASE_MODULE = "needToCreateBaseModule"
+
+@Component
+@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+class VnfCommand @Autowired constructor(
+ private val asyncInstantiationBL: AsyncInstantiationBusinessLogic,
+ restMso: RestMsoImplementation,
+ private val msoRequestBuilder: MsoRequestBuilder,
+ msoResultHandlerService: MsoResultHandlerService,
+ inProgressStatusService:InProgressStatusService,
+ watchChildrenJobsBL: WatchChildrenJobsBL,
+ jobsBrokerService: JobsBrokerService,
+ jobAdapter: JobAdapter,
+ private val featureManager: FeatureManager
+) : ResourceCommand(restMso, inProgressStatusService, msoResultHandlerService,
+ watchChildrenJobsBL, jobsBrokerService, jobAdapter), JobCommand {
+
+ private var needToCreateBaseModule:Boolean by Delegates.notNull<Boolean>()
+
+ override fun getData(): Map<String, Any?> {
+ return super.getData() + mapOf(NEED_TO_CREATE_BASE_MODULE to needToCreateBaseModule)
+ }
+
+ override fun init(sharedData: JobSharedData, commandData: Map<String, Any>): ResourceCommand {
+ super<ResourceCommand>.init(sharedData, commandData)
+ needToCreateBaseModule = commandData.getOrDefault(NEED_TO_CREATE_BASE_MODULE, actionPhase != Action.Delete) as Boolean
+ return this
+ }
+
+
+ override fun createChildren(): Job.JobStatus {
+ val request:Vnf = getRequest()
+ if(isNeedToCreateChildJobs()){
+ val dataForChild = buildDataForChild(request, actionPhase)
+ val vfModules:List<VfModule> = request.vfModules.values.stream().flatMap { vfKey -> vfKey.values.stream() }.collect(Collectors.toList<VfModule>())
+
+ try {
+ childJobs = pushChildrenJobsToBroker(vfModules.filter { filterModuleByNeedToCreateBase(it) }, dataForChild, JobType.VolumeGroupInstantiation)
+ } catch (e: AsdcCatalogException) {
+ LOGGER.error("Failed to retrieve service definitions from SDC, for VfModule is BaseModule.. Error: " + e.message , e)
+ return Job.JobStatus.FAILED
+ }
+ }
+
+ return Job.JobStatus.COMPLETED_WITH_NO_ACTION
+ }
+
+ private fun filterModuleByNeedToCreateBase(it: VfModule):Boolean {
+ return needToCreateBaseModule ==
+ commandUtils.isVfModuleBaseModule(
+ commandParentData.getModelInfo(CommandParentData.CommandDataKey.SERVICE_MODEL_INFO).getModelVersionId(),
+ it.modelInfo.modelVersionId)
+ }
+
+ override fun planCreateMyselfRestCall(commandParentData: CommandParentData, request: JobAdapter.AsyncJobRequest, userId: String, testApi: String?): MsoRestCallPlan {
+ val serviceInstanceId = commandParentData.getInstanceId(CommandParentData.CommandDataKey.SERVICE_INSTANCE_ID)
+ val serviceModelInfo = commandParentData.getModelInfo(CommandParentData.CommandDataKey.SERVICE_MODEL_INFO)
+
+ val instantiatePath = asyncInstantiationBL.getVnfInstantiationPath(serviceInstanceId)
+
+ val requestDetailsWrapper = msoRequestBuilder.generateVnfInstantiationRequest(
+ request as Vnf,
+ serviceModelInfo, serviceInstanceId,
+ userId,
+ testApi
+ )
+
+ val actionDescription = "create vnf in $serviceInstanceId"
+
+ return MsoRestCallPlan(HttpMethod.POST, instantiatePath, Optional.of(requestDetailsWrapper), Optional.empty(), actionDescription)
+
+ }
+
+ override fun addMyselfToChildrenData(commandParentData: CommandParentData, request: BaseResource) {
+ commandParentData.addModelInfo(CommandParentData.CommandDataKey.VNF_MODEL_INFO, request.modelInfo);
+ commandParentData.addInstanceId(CommandParentData.CommandDataKey.VNF_INSTANCE_ID, getActualInstanceId(request))
+ }
+
+ override fun getRequest(): Vnf {
+ return sharedData.request as Vnf
+ }
+
+ private fun isNeedToCreateChildJobs(): Boolean {
+ return featureManager.isActive(Features.FLAG_ASYNC_ALACARTE_VFMODULE) &&
+ MapUtils.isNotEmpty(getRequest().vfModules)
+ }
+
+ override fun planDeleteMyselfRestCall(commandParentData: CommandParentData, request: JobAdapter.AsyncJobRequest, userId: String): MsoRestCallPlan {
+ val serviceInstanceId = commandParentData.getInstanceId(CommandParentData.CommandDataKey.SERVICE_INSTANCE_ID)
+ val path = asyncInstantiationBL.getVnfDeletionPath(serviceInstanceId, getRequest().instanceId)
+ val requestDetailsWrapper = msoRequestBuilder.generateDeleteVnfRequest(getRequest(), userId)
+ return MsoRestCallPlan(HttpMethod.DELETE, path, Optional.of(requestDetailsWrapper), Optional.of(userId),
+ "delete vnf ${getRequest().instanceId} from service $serviceInstanceId")
+
+ }
+
+ companion object {
+ private val LOGGER = EELFLoggerDelegate.getLogger(VnfCommand::class.java)
+ }
+
+ //in Delete phase - we delete all non-base vf-modules first, before base vf-module
+ //in Create phase - we create base vf-module first, and then all the others
+ override fun watchChildren(): Job.JobStatus {
+ val childrenStatus:Job.JobStatus = comulateStatusAndUpdatePropertyIfFinal(watchChildrenJobsBL.retrieveChildrenJobsStatus(childJobs))
+ if (!childrenStatus.isFinal ||
+ childrenStatus.isFailure ||
+ (actionPhase == Action.Create && !needToCreateBaseModule) ||
+ (actionPhase == Action.Delete && needToCreateBaseModule)) {
+ return childrenStatus
+ }
+
+ needToCreateBaseModule = !needToCreateBaseModule;
+ createChildren()
+ return Job.JobStatus.IN_PROGRESS
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/VnfInProgressStatusCommand.java b/vid-app-common/src/main/java/org/onap/vid/job/command/VnfInProgressStatusCommand.java
deleted file mode 100644
index 832c575db..000000000
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/VnfInProgressStatusCommand.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * 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.vid.job.command;
-
-import org.apache.commons.collections.MapUtils;
-import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.onap.vid.asdc.AsdcCatalogException;
-import org.onap.vid.job.Job;
-import org.onap.vid.job.JobType;
-import org.onap.vid.job.NextCommand;
-import org.onap.vid.job.command.CommandParentData.CommandDataKey;
-import org.onap.vid.job.impl.JobSharedData;
-import org.onap.vid.model.serviceInstantiation.BaseResource;
-import org.onap.vid.model.serviceInstantiation.VfModule;
-import org.onap.vid.model.serviceInstantiation.Vnf;
-import org.onap.vid.properties.Features;
-import org.springframework.beans.factory.config.ConfigurableBeanFactory;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-@Component
-@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-public class VnfInProgressStatusCommand extends ResourceWithChildrenInProgressCommand {
- private static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(VnfInProgressStatusCommand.class);
-
- public VnfInProgressStatusCommand(JobSharedData sharedData,
- String requestId,
- String instanceId,
- CommandParentData commandParentData) {
- super(sharedData, requestId, instanceId, commandParentData);
- }
-
- public VnfInProgressStatusCommand() {
- }
-
- @Override
- protected NextCommand processJobStatus(Job.JobStatus jobStatus) {
- if (jobStatus == Job.JobStatus.FAILED) {
- return new NextCommand(jobStatus);
- }
-
- Vnf request = (Vnf) getSharedData().getRequest();
-
- if (isNeedToCreateChildJobs(jobStatus, request)) {
- commandParentData.addInstanceId(CommandDataKey.VNF_INSTANCE_ID, instanceId);
- commandParentData.addModelInfo(CommandDataKey.VNF_MODEL_INFO, request.getModelInfo());
- //create volume group of base module job
- Map<String, Object> dataForChild = buildDataForChild();
- List<VfModule> vfModules = request.getVfModules().values().stream().flatMap(vfKey -> vfKey.values().stream()).collect(Collectors.toList());
- List<String> vgBaseJobs = new ArrayList<>();
- for( VfModule vfModule : vfModules){
- try {
- if(commandUtils.isVfModuleBaseModule(commandParentData.getModelInfo(CommandDataKey.SERVICE_MODEL_INFO).getModelVersionId(), vfModule.getModelInfo().getModelVersionId())) {
- vgBaseJobs.add(jobsBrokerService.add(
- jobAdapter.createChildJob(JobType.VolumeGroupInstantiation, Job.JobStatus.CREATING, vfModule, getSharedData(), dataForChild)).toString());
- }
- } catch (AsdcCatalogException e) {
- LOG.error("Failed to retrieve service definitions from SDC, for VfModule is BaseModule. Error: "+e.getMessage() , e);
- return new NextCommand(Job.JobStatus.COMPLETED_WITH_ERRORS);
- }
- }
- return new NextCommand(Job.JobStatus.RESOURCE_IN_PROGRESS, new WatchingCommandBaseModule(getSharedData(), vgBaseJobs, false, commandParentData));
- }
-
- //in case of JobStatus.PAUSE we leave the job itself as IN_PROGRESS, for keep tracking job progress
- if (jobStatus == Job.JobStatus.PAUSE) {
- return new NextCommand(Job.JobStatus.RESOURCE_IN_PROGRESS, this);
- }
- return new NextCommand(jobStatus, this);
- }
-
-
- protected boolean isNeedToCreateChildJobs(Job.JobStatus jobStatus, BaseResource request) {
- return featureManager.isActive(Features.FLAG_ASYNC_ALACARTE_VFMODULE) &&
- jobStatus == Job.JobStatus.COMPLETED &&
- MapUtils.isNotEmpty(((Vnf)request).getVfModules());
- }
-
-
- @Override
- protected ExpiryChecker getExpiryChecker() {
- return x->false;
- }
-}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/VnfInstantiationCommand.java b/vid-app-common/src/main/java/org/onap/vid/job/command/VnfInstantiationCommand.java
deleted file mode 100644
index d3bfde3b6..000000000
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/VnfInstantiationCommand.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * 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.vid.job.command;
-
-import org.onap.vid.changeManagement.RequestDetailsWrapper;
-import org.onap.vid.job.Job;
-import org.onap.vid.job.JobAdapter;
-import org.onap.vid.job.NextCommand;
-import org.onap.vid.job.command.CommandParentData.CommandDataKey;
-import org.onap.vid.model.serviceInstantiation.Vnf;
-import org.onap.vid.mso.model.VnfInstantiationRequestDetails;
-import org.onap.vid.services.AsyncInstantiationBusinessLogic;
-import org.springframework.beans.factory.config.ConfigurableBeanFactory;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-
-import javax.inject.Inject;
-
-@Component
-@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-public class VnfInstantiationCommand extends ResourceInstantiationCommand {
-
- @Inject
- private AsyncInstantiationBusinessLogic asyncInstantiationBL;
-
- @Override
- protected String getRequestPath() {
- return asyncInstantiationBL.getVnfInstantiationPath( commandParentData.getInstanceId(CommandDataKey.SERVICE_INSTANCE_ID));
- }
-
- @Override
- protected RequestDetailsWrapper<VnfInstantiationRequestDetails> generateMSORequest(JobAdapter.AsyncJobRequest request, String userId) {
- return asyncInstantiationBL.generateVnfInstantiationRequest(
- (Vnf) getSharedData().getRequest(),
- commandParentData.getModelInfo(CommandDataKey.SERVICE_MODEL_INFO),
- commandParentData.getInstanceId(CommandDataKey.SERVICE_INSTANCE_ID),
- getSharedData().getUserId()
- );
- }
-
- @Override
- protected String getJobAuditMSOStatus() {
- return "VNF_REQUESTED";
- }
-
- @Override
- protected NextCommand getNextCommand(String requestId, String instanceId) {
- return new NextCommand(Job.JobStatus.RESOURCE_IN_PROGRESS,
- new VnfInProgressStatusCommand(getSharedData(), requestId, instanceId, commandParentData));
- }
-
-}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/VolumeGroupCommand.kt b/vid-app-common/src/main/java/org/onap/vid/job/command/VolumeGroupCommand.kt
new file mode 100644
index 000000000..4da1dad15
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/VolumeGroupCommand.kt
@@ -0,0 +1,94 @@
+package org.onap.vid.job.command
+
+import org.apache.commons.lang3.StringUtils.isNotEmpty
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate
+import org.onap.vid.job.*
+import org.onap.vid.model.Action
+import org.onap.vid.model.serviceInstantiation.BaseResource
+import org.onap.vid.model.serviceInstantiation.VfModule
+import org.onap.vid.mso.RestMsoImplementation
+import org.onap.vid.services.AsyncInstantiationBusinessLogic
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
+import org.springframework.http.HttpMethod
+import org.springframework.stereotype.Component
+import java.util.*
+
+@Component
+@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+class VolumeGroupCommand @Autowired constructor(
+ private val asyncInstantiationBL: AsyncInstantiationBusinessLogic,
+ restMso: RestMsoImplementation,
+ private val msoRequestBuilder: MsoRequestBuilder,
+ msoResultHandlerService: MsoResultHandlerService,
+ inProgressStatusService:InProgressStatusService,
+ watchChildrenJobsBL: WatchChildrenJobsBL,
+ jobsBrokerService: JobsBrokerService,
+ jobAdapter: JobAdapter
+) : ResourceCommand(restMso, inProgressStatusService, msoResultHandlerService,
+ watchChildrenJobsBL, jobsBrokerService, jobAdapter), JobCommand {
+
+ companion object {
+ private val LOGGER = EELFLoggerDelegate.getLogger(VolumeGroupCommand::class.java)
+ }
+
+ override fun createChildren(): Job.JobStatus {
+ val request: VfModule = getRequest()
+ val dataForChild = buildDataForChild(request, actionPhase)
+
+ childJobs = pushChildrenJobsToBroker(listOf(request), dataForChild, JobType.VfmoduleInstantiation)
+
+ return Job.JobStatus.COMPLETED_WITH_NO_ACTION
+ }
+
+ override fun planCreateMyselfRestCall(commandParentData: CommandParentData, request: JobAdapter.AsyncJobRequest, userId: String, testApi: String?): MsoRestCallPlan {
+
+ val serviceInstanceId = commandParentData.getInstanceId(CommandParentData.CommandDataKey.SERVICE_INSTANCE_ID)
+ val serviceModelInfo = commandParentData.getModelInfo(CommandParentData.CommandDataKey.SERVICE_MODEL_INFO)
+ val vnfInstanceId = commandParentData.getInstanceId(CommandParentData.CommandDataKey.VNF_INSTANCE_ID)
+ val vnfModelInfo = commandParentData.getModelInfo(CommandParentData.CommandDataKey.VNF_MODEL_INFO)
+
+ val instantiatePath = asyncInstantiationBL.getVolumeGroupInstantiationPath(serviceInstanceId,vnfInstanceId)
+
+ val requestDetailsWrapper = msoRequestBuilder.generateVolumeGroupInstantiationRequest(
+ request as VfModule,
+ serviceModelInfo, serviceInstanceId,
+ vnfModelInfo,vnfInstanceId,
+ userId,
+ testApi
+ )
+
+ val actionDescription = "create volumeGroup in $vnfInstanceId"
+
+ return MsoRestCallPlan(HttpMethod.POST, instantiatePath, Optional.of(requestDetailsWrapper), Optional.empty(), actionDescription)
+ }
+
+ override fun planDeleteMyselfRestCall(commandParentData: CommandParentData, request: JobAdapter.AsyncJobRequest, userId: String): MsoRestCallPlan {
+ TODO("not implemented")
+ }
+
+ override fun isNeedToCreateMyself(): Boolean {
+ return super.isNeedToCreateMyself() && isNotEmpty(getRequest().volumeGroupInstanceName)
+ }
+
+ override fun isNeedToDeleteMyself(): Boolean {
+ return false
+ }
+
+ override fun getRequest(): VfModule {
+ return sharedData.request as VfModule
+ }
+
+ override fun isDescendantHasAction(phase: Action): Boolean {
+ return phase == getRequest().action
+ }
+
+ override fun addMyselfToChildrenData(commandParentData: CommandParentData, request: BaseResource) {
+ commandParentData.addInstanceId(CommandParentData.CommandDataKey.VG_INSTANCE_ID, getActualInstanceId(request));
+ }
+
+ override fun replaceMyself(): Job.JobStatus {
+ return Job.JobStatus.COMPLETED
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/VolumeGroupInProgressStatusCommand.java b/vid-app-common/src/main/java/org/onap/vid/job/command/VolumeGroupInProgressStatusCommand.java
deleted file mode 100644
index 9c4d7b825..000000000
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/VolumeGroupInProgressStatusCommand.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * 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.vid.job.command;
-
-import org.onap.vid.job.Job;
-import org.onap.vid.job.JobType;
-import org.onap.vid.job.NextCommand;
-import org.onap.vid.job.command.CommandParentData.CommandDataKey;
-import org.onap.vid.job.impl.JobSharedData;
-import org.onap.vid.model.serviceInstantiation.VfModule;
-import org.springframework.beans.factory.config.ConfigurableBeanFactory;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
-@Component
-@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-public class VolumeGroupInProgressStatusCommand extends ResourceWithChildrenInProgressCommand {
-
- public VolumeGroupInProgressStatusCommand(
- JobSharedData sharedData,
- String requestId,
- String instanceId,
- CommandParentData parentData) {
- super(sharedData, requestId, instanceId, parentData);
- }
-
- public VolumeGroupInProgressStatusCommand() {
- }
-
- @Override
- protected NextCommand processJobStatus(Job.JobStatus jobStatus) {
- if (jobStatus == Job.JobStatus.FAILED) {
- return new NextCommand(Job.JobStatus.FAILED);
- }
- VfModule request = (VfModule) getSharedData().getRequest();
-
- if (jobStatus == Job.JobStatus.COMPLETED) {
- //vf module creation
- Map<String, Object> dataForChild = buildDataForChild();
- List<String> vfModuleJob = Arrays.asList(jobsBrokerService.add(
- jobAdapter.createChildJob(JobType.VfmoduleInstantiation, Job.JobStatus.CREATING , request, getSharedData(), dataForChild)).toString());
-
- return new NextCommand(Job.JobStatus.RESOURCE_IN_PROGRESS, new WatchingCommand(getSharedData(), vfModuleJob, false));
- }
-
- //in case of JobStatus.PAUSE we leave the job itself as IN_PROGRESS, for keep tracking job progress
- if (jobStatus == Job.JobStatus.PAUSE) {
- return new NextCommand(Job.JobStatus.RESOURCE_IN_PROGRESS, this);
- }
- return new NextCommand(jobStatus, this);
- }
-
- @Override
- protected Map<String, Object> buildDataForChild() {
- commandParentData.addInstanceId(CommandDataKey.VG_INSTANCE_ID, this.instanceId);
- return super.buildDataForChild();
- }
-
- @Override
- protected ExpiryChecker getExpiryChecker() {
- return x->false;
- }
-}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/VolumeGroupInstantiationCommand.java b/vid-app-common/src/main/java/org/onap/vid/job/command/VolumeGroupInstantiationCommand.java
deleted file mode 100644
index eff12ec73..000000000
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/VolumeGroupInstantiationCommand.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * 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.vid.job.command;
-
-
-import org.apache.commons.lang3.StringUtils;
-import org.onap.vid.changeManagement.RequestDetailsWrapper;
-import org.onap.vid.job.*;
-import org.onap.vid.job.command.CommandParentData.CommandDataKey;
-import org.onap.vid.model.serviceInstantiation.VfModule;
-import org.onap.vid.mso.model.VolumeGroupRequestDetails;
-import org.onap.vid.services.AsyncInstantiationBusinessLogic;
-import org.springframework.beans.factory.config.ConfigurableBeanFactory;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-
-import javax.inject.Inject;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-@Component
-@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-public class VolumeGroupInstantiationCommand extends ResourceInstantiationCommand {
- @Inject
- private AsyncInstantiationBusinessLogic asyncInstantiationBL;
-
- @Inject
- protected JobsBrokerService jobsBrokerService;
-
- @Inject
- protected JobAdapter jobAdapter;
-
- @Override
- protected String getRequestPath() {
- return asyncInstantiationBL.getVolumeGroupInstantiationPath(commandParentData.getInstanceId(CommandDataKey.SERVICE_INSTANCE_ID),commandParentData.getInstanceId(CommandDataKey.VNF_INSTANCE_ID));
- }
-
- @Override
- protected RequestDetailsWrapper<VolumeGroupRequestDetails> generateMSORequest(JobAdapter.AsyncJobRequest request, String userId) {
- return asyncInstantiationBL.generateVolumeGroupInstantiationRequest(
- (VfModule) getSharedData().getRequest(),
- commandParentData.getModelInfo(CommandDataKey.SERVICE_MODEL_INFO),
- commandParentData.getInstanceId(CommandDataKey.SERVICE_INSTANCE_ID),
- commandParentData.getModelInfo(CommandDataKey.VNF_MODEL_INFO),
- commandParentData.getInstanceId(CommandDataKey.VNF_INSTANCE_ID),
- getSharedData().getUserId()
- );
- }
-
- @Override
- protected NextCommand getNextCommand(String requestId, String instanceId){
- return new NextCommand(
- Job.JobStatus.RESOURCE_IN_PROGRESS,
- new VolumeGroupInProgressStatusCommand(getSharedData(), requestId, instanceId, commandParentData)
- );
- }
-
- @Override
- protected String getJobAuditMSOStatus() {
- return "VOLUME_GROUP_REQUESTED";
- }
-
- @Override
- public NextCommand call() {
- String vgName = ((VfModule)getSharedData().getRequest()).getVolumeGroupInstanceName();
- if(StringUtils.isNotEmpty(vgName)){
- return super.call();//create volume group
- }else {
- //go to vf module creation
- VfModule request = (VfModule) getSharedData().getRequest();
- Map<String, Object> dataForChild = buildDataForChild();
- List<String> vfModuleJob = Collections.singletonList(jobsBrokerService.add(
- jobAdapter.createChildJob(JobType.VfmoduleInstantiation, Job.JobStatus.CREATING, request, getSharedData(), dataForChild)).toString());
-
- return new NextCommand(Job.JobStatus.RESOURCE_IN_PROGRESS, new WatchingCommand(getSharedData(), vfModuleJob, false));
- }
-
- }
-
- private Map<String, Object> buildDataForChild() {
- return commandParentData.getParentData();
- }
-
-}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/WatchChildrenJobsBL.kt b/vid-app-common/src/main/java/org/onap/vid/job/command/WatchChildrenJobsBL.kt
index 7cebe2188..194fe4ba2 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/WatchChildrenJobsBL.kt
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/WatchChildrenJobsBL.kt
@@ -7,9 +7,9 @@
* 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.
@@ -21,11 +21,11 @@
package org.onap.vid.job.command
import org.apache.commons.lang3.StringUtils
-import org.onap.portalsdk.core.service.DataAccessService
import org.onap.vid.job.Job
import org.onap.vid.job.Job.JobStatus.*
import org.onap.vid.job.impl.JobDaoImpl
import org.onap.vid.utils.DaoUtils
+import org.onap.portalsdk.core.service.DataAccessService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Service
import java.util.*
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/WatchingCommand.java b/vid-app-common/src/main/java/org/onap/vid/job/command/WatchingCommand.java
deleted file mode 100644
index 758cb56d7..000000000
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/WatchingCommand.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * 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.vid.job.command;
-
-import org.onap.vid.job.Job;
-import org.onap.vid.job.NextCommand;
-import org.onap.vid.job.impl.JobSharedData;
-import org.springframework.beans.factory.config.ConfigurableBeanFactory;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-
-import java.util.List;
-
-@Component
-@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-public class WatchingCommand extends BaseWatchingCommand {
-
- public WatchingCommand() {}
-
- public WatchingCommand(JobSharedData sharedData, List<String> childrenJobsIds, boolean isService) {
- super(sharedData, childrenJobsIds, isService);
- }
-
- protected NextCommand getNextCommand(Job.JobStatus cumulativeJobsStatus) {
- if (cumulativeJobsStatus==Job.JobStatus.IN_PROGRESS) {
- return (isService) ? new NextCommand(Job.JobStatus.IN_PROGRESS, this)
- : new NextCommand(Job.JobStatus.RESOURCE_IN_PROGRESS, this);
- }
- if (isService) {
- asyncInstantiationBL.updateServiceInfoAndAuditStatus(getSharedData().getJobUuid(), cumulativeJobsStatus);
- }
- return new NextCommand(cumulativeJobsStatus);
- }
-
-}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/WatchingCommandBaseModule.java b/vid-app-common/src/main/java/org/onap/vid/job/command/WatchingCommandBaseModule.java
deleted file mode 100644
index 258811a01..000000000
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/WatchingCommandBaseModule.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * 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.vid.job.command;
-
-import com.google.common.collect.ImmutableMap;
-import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.onap.vid.asdc.AsdcCatalogException;
-import org.onap.vid.job.*;
-import org.onap.vid.job.command.CommandParentData.CommandDataKey;
-import org.onap.vid.job.impl.JobSharedData;
-import org.onap.vid.model.serviceInstantiation.VfModule;
-import org.onap.vid.model.serviceInstantiation.Vnf;
-import org.springframework.beans.factory.config.ConfigurableBeanFactory;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-
-import javax.inject.Inject;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-@Component
-@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-public class WatchingCommandBaseModule extends BaseWatchingCommand {
- @Inject
- protected JobsBrokerService jobsBrokerService;
-
- @Inject
- protected JobAdapter jobAdapter;
- private static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(WatchingCommandBaseModule.class);
-
- public WatchingCommandBaseModule(
- JobSharedData sharedData,
- List<String> childrenJobsIds,
- boolean isService,
- CommandParentData commandParentData) {
- super(sharedData, childrenJobsIds, isService);
- this.commandParentData = commandParentData;
- }
-
- public WatchingCommandBaseModule() {
-
- }
-
- @Override
- protected NextCommand getNextCommand(Job.JobStatus cumulativeJobsStatus) {
-
- if (cumulativeJobsStatus== Job.JobStatus.IN_PROGRESS) {
- return new NextCommand(Job.JobStatus.RESOURCE_IN_PROGRESS, this);
- }
-
- if(cumulativeJobsStatus==Job.JobStatus.FAILED || cumulativeJobsStatus==Job.JobStatus.COMPLETED_WITH_ERRORS){
- return new NextCommand(Job.JobStatus.COMPLETED_WITH_ERRORS);
- }
- Vnf request = (Vnf) getSharedData().getRequest();
- Map<String, Object> dataForChild = buildDataForChild();
- //Create non-base Volume groups job
- List<VfModule> vfModules = request.getVfModules().values().stream().flatMap(vfKey -> vfKey.values().stream()).collect(Collectors.toList());
- List<String> vgNonBaseJobs = new ArrayList<>();
- for( VfModule vfModule : vfModules){
- try {
- if(!commandUtils.isVfModuleBaseModule(commandParentData.getModelInfo(CommandDataKey.SERVICE_MODEL_INFO).getModelVersionId(), vfModule.getModelInfo().getModelVersionId())) {
- vgNonBaseJobs.add(jobsBrokerService.add(
- jobAdapter.createChildJob(JobType.VolumeGroupInstantiation, Job.JobStatus.CREATING, vfModule, getSharedData(), dataForChild)).toString());
- }
- } catch (AsdcCatalogException e) {
- LOG.error("Failed to retrieve service definitions from SDC, for VfModule is BaseModule. Error: "+e.getMessage() , e);
- return new NextCommand(Job.JobStatus.COMPLETED_WITH_ERRORS);
- }
- }
- return new NextCommand(Job.JobStatus.RESOURCE_IN_PROGRESS, new WatchingCommand(getSharedData(), vgNonBaseJobs, false));
- }
-
- @Override
- public WatchingCommandBaseModule init(JobSharedData sharedData, Map<String, Object> commandData) {
- super.init(sharedData, commandData);
- commandParentData.initParentData(commandData);
- return this;
- }
-
- protected Map<String, Object> buildDataForChild() {
- return commandParentData.getParentData();
- }
-
- @Override
- public Map<String, Object> getData() {
- return ImmutableMap.<String, Object>builder()
- .putAll(super.getData())
- .putAll(commandParentData.getParentData())
- .build();
- }
-
-
-}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/impl/DeleteOldJobsSchedulerInitializer.java b/vid-app-common/src/main/java/org/onap/vid/job/impl/DeleteOldJobsSchedulerInitializer.java
new file mode 100644
index 000000000..ad4b8c95a
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/job/impl/DeleteOldJobsSchedulerInitializer.java
@@ -0,0 +1,96 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.vid.job.impl;
+
+
+import static org.quartz.CronScheduleBuilder.dailyAtHourAndMinute;
+
+import com.google.common.collect.ImmutableMap;
+import java.util.Random;
+import java.util.concurrent.TimeUnit;
+import javax.annotation.PostConstruct;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.vid.exceptions.GenericUncheckedException;
+import org.onap.vid.job.JobsBrokerService;
+import org.quartz.JobBuilder;
+import org.quartz.JobDataMap;
+import org.quartz.JobDetail;
+import org.quartz.SchedulerException;
+import org.quartz.Trigger;
+import org.quartz.TriggerBuilder;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.quartz.SchedulerFactoryBean;
+import org.springframework.stereotype.Component;
+
+@Component
+public class DeleteOldJobsSchedulerInitializer {
+
+ private JobsBrokerService jobsBrokerService;
+ private SchedulerFactoryBean schedulerFactoryBean;
+ private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(DeleteOldJobsSchedulerInitializer.class);
+
+ @Autowired
+ public DeleteOldJobsSchedulerInitializer(
+ JobsBrokerService jobsBrokerService,
+ SchedulerFactoryBean schedulerFactoryBean
+ ) {
+ this.jobsBrokerService = jobsBrokerService;
+ this.schedulerFactoryBean = schedulerFactoryBean;
+ }
+
+ @PostConstruct
+ public void init() {
+ try {
+ JobDetail jobDetail = createJobDetail();
+ Trigger deleteOldJobsTrigger = createTrigger();
+ schedulerFactoryBean.getScheduler().scheduleJob(jobDetail, deleteOldJobsTrigger);
+ } catch (SchedulerException e) {
+ logger.error(EELFLoggerDelegate.errorLogger, "Failed to schedule trigger for delete old jobs: {}", e.getMessage());
+ throw new GenericUncheckedException(e);
+ }
+ }
+
+ JobDetail createJobDetail() {
+ int days = Integer.parseInt(SystemProperties.getProperty("vid.asyncJob.howLongToKeepOldJobsInDays"));
+ long secondsAgo = TimeUnit.DAYS.toSeconds(days);
+ return JobBuilder.newJob().ofType(DeleteOldJobsWorker.class)
+ .withIdentity("DeleteOldJobsWorker")
+ .withDescription("worker that delete old vid jobs from DB")
+ .setJobData(new JobDataMap(ImmutableMap.of(
+ "jobsBrokerService", jobsBrokerService,
+ "secondsAgo", secondsAgo
+ )))
+ .build();
+ }
+
+ Trigger createTrigger() {
+ int minutes = new Random(System.nanoTime()).nextInt(59);
+ int hours = 6;
+ logger.info("trigger for DeleteOldJobs is {}:{} ", hours, minutes);
+
+ return TriggerBuilder.newTrigger()
+ .withIdentity("DeleteOldJobsTrigger")
+ .withDescription("Trigger to run delete old vid jobs worker")
+ .withSchedule(dailyAtHourAndMinute(hours, minutes))
+ .build();
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/MacroServiceInstantiationCommand.java b/vid-app-common/src/main/java/org/onap/vid/job/impl/DeleteOldJobsWorker.java
index 6687a2c2e..d60ddab8d 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/MacroServiceInstantiationCommand.java
+++ b/vid-app-common/src/main/java/org/onap/vid/job/impl/DeleteOldJobsWorker.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,29 +18,32 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.vid.job.command;
+package org.onap.vid.job.impl;
-import org.onap.vid.changeManagement.RequestDetailsWrapper;
-import org.onap.vid.job.JobCommand;
-import org.onap.vid.mso.model.ServiceInstantiationRequestDetails;
-import org.springframework.beans.factory.config.ConfigurableBeanFactory;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.vid.job.JobsBrokerService;
+import org.quartz.JobExecutionContext;
+import org.springframework.scheduling.quartz.QuartzJobBean;
+public class DeleteOldJobsWorker extends QuartzJobBean {
-@Component
-@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-public class MacroServiceInstantiationCommand extends ServiceInstantiationCommand implements JobCommand {
+ private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(DeleteOldJobsWorker.class);
- public MacroServiceInstantiationCommand() {
- // empty constructor
- }
+ private JobsBrokerService jobsBrokerService;
+ private long secondsAgo;
@Override
- protected RequestDetailsWrapper<ServiceInstantiationRequestDetails> generateServiceInstantiationRequest() {
- return asyncInstantiationBL.generateMacroServiceInstantiationRequest(
- getSharedData().getJobUuid(), getRequest(), optimisticUniqueServiceInstanceName, getSharedData().getUserId()
- );
+ protected void executeInternal(JobExecutionContext context) {
+ LOGGER.info("delete old final jobs that has finished before {} seconds", secondsAgo);
+ jobsBrokerService.deleteOldFinalJobs(secondsAgo);
+ }
+
+ //the following methods are used by quartz to inject members
+ public void setJobsBrokerService(JobsBrokerService jobsBrokerService) {
+ this.jobsBrokerService = jobsBrokerService;
}
+ public void setSecondsAgo(long secondsAgo) {
+ this.secondsAgo = secondsAgo;
+ }
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/impl/JobAdapterImpl.java b/vid-app-common/src/main/java/org/onap/vid/job/impl/JobAdapterImpl.java
index 9ea1f1326..1bf0f43ee 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/impl/JobAdapterImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/job/impl/JobAdapterImpl.java
@@ -7,9 +7,9 @@
* 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.
@@ -25,7 +25,10 @@ import org.onap.vid.job.Job;
import org.onap.vid.job.JobAdapter;
import org.onap.vid.job.JobType;
import org.onap.vid.model.JobModel;
+import org.onap.vid.properties.Features;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+import org.togglz.core.manager.FeatureManager;
import java.util.Map;
import java.util.UUID;
@@ -33,6 +36,14 @@ import java.util.UUID;
@Component
public class JobAdapterImpl implements JobAdapter {
+ private final FeatureManager featureManager;
+
+ @Autowired
+ public JobAdapterImpl(FeatureManager featureManager) {
+ this.featureManager = featureManager;
+ }
+
+
@Override
public JobModel toModel(Job job) {
JobModel jobModel = new JobModel();
@@ -43,9 +54,9 @@ public class JobAdapterImpl implements JobAdapter {
}
@Override
- public Job createServiceInstantiationJob(JobType jobType, AsyncJobRequest request, UUID templateId, String userId, String optimisticUniqueServiceInstanceName, Integer indexInBulk){
+ public Job createServiceInstantiationJob(JobType jobType, AsyncJobRequest request, UUID templateId, String userId, String testApi, String optimisticUniqueServiceInstanceName, Integer indexInBulk){
JobDaoImpl job = createJob(jobType, Job.JobStatus.PENDING , userId);
- job.setSharedData(new JobSharedData(job.getUuid(), userId, request));
+ job.setSharedData(new JobSharedData(job.getUuid(), userId, request, testApi));
job.setTypeAndData(jobType, ImmutableMap.of(
"optimisticUniqueServiceInstanceName", optimisticUniqueServiceInstanceName
));
@@ -55,10 +66,14 @@ public class JobAdapterImpl implements JobAdapter {
}
@Override
- public Job createChildJob(JobType jobType, Job.JobStatus jobStatus, AsyncJobRequest request, JobSharedData parentSharedData, Map<String, Object> jobData) {
+ public Job createChildJob(JobType jobType, AsyncJobRequest request, JobSharedData parentSharedData, Map<String, Object> jobData, int indexInBulk) {
+ Job.JobStatus jobStatus = featureManager.isActive(Features.FLAG_EXP_CREATE_RESOURCES_IN_PARALLEL) ?
+ Job.JobStatus.CREATING : Job.JobStatus.PENDING_RESOURCE;
JobDaoImpl job = createJob(jobType, jobStatus , parentSharedData.getUserId());
job.setSharedData(new JobSharedData(job.getUuid(), request, parentSharedData));
job.setTypeAndData(jobType, jobData);
+ job.setTemplateId(parentSharedData.jobUuid);
+ job.setIndexInBulk(indexInBulk);
return job;
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/impl/JobDaoImpl.java b/vid-app-common/src/main/java/org/onap/vid/job/impl/JobDaoImpl.java
index 5cddd4d0f..7d78d4580 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/impl/JobDaoImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/job/impl/JobDaoImpl.java
@@ -7,9 +7,9 @@
* 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.
@@ -23,7 +23,6 @@ package org.onap.vid.job.impl;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.MoreObjects;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;
@@ -41,6 +40,8 @@ import java.util.Map;
import java.util.Objects;
import java.util.UUID;
+import static org.onap.vid.utils.KotlinUtilsKt.JACKSON_OBJECT_MAPPER;
+
/*
The following 2 annotations let hibernate to update only fields that actually have been changed.
DynamicUpdate tell hibernate to update only dirty fields.
@@ -52,7 +53,6 @@ import java.util.UUID;
@Table(name = "vid_job")
public class JobDaoImpl extends VidBaseEntity implements Job {
- private static ObjectMapper objectMapper = new ObjectMapper();
private Job.JobStatus status;
private JobType type;
private JobData data = new JobData();
@@ -63,6 +63,7 @@ public class JobDaoImpl extends VidBaseEntity implements Job {
private Integer age = 0;
private Integer indexInBulk = 0;
private Date deletedAt;
+ private String build;
@Id
@Column(name = "JOB_ID", columnDefinition = "CHAR(36)")
@@ -107,7 +108,7 @@ public class JobDaoImpl extends VidBaseEntity implements Job {
@Column(name = "JOB_DATA", columnDefinition = "VARCHAR(30000)")
public String getDataRaw() {
try {
- return objectMapper.writeValueAsString(data);
+ return JACKSON_OBJECT_MAPPER.writeValueAsString(data);
} catch (JsonProcessingException e) {
throw new GenericUncheckedException(e);
}
@@ -115,7 +116,7 @@ public class JobDaoImpl extends VidBaseEntity implements Job {
public void setDataRaw(String data) {
try {
- this.data = objectMapper.readValue(data, JobData.class);
+ this.data = JACKSON_OBJECT_MAPPER.readValue(data, JobData.class);
} catch (IOException e) {
throw new JobException("Error parsing job's data", uuid, e);
}
@@ -202,6 +203,15 @@ public class JobDaoImpl extends VidBaseEntity implements Job {
this.deletedAt = deletedAt;
}
+ @Column(name = "BUILD", columnDefinition = "VARCHAR(100)")
+ public String getBuild() {
+ return build;
+ }
+
+ public void setBuild(String build) {
+ this.build = build;
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) return true;
@@ -220,15 +230,15 @@ public class JobDaoImpl extends VidBaseEntity implements Job {
return MoreObjects.toStringHelper(this)
.add("status", status)
.add("type", type)
+ .add("data", data)
.add("templateId", templateId)
.add("uuid", uuid)
.add("takenBy", takenBy)
.add("userId", userId)
.add("age", age)
- .add("created", created)
- .add("modified", modified)
+ .add("indexInBulk", indexInBulk)
.add("deletedAt", deletedAt)
- .add("data", data)
+ .add("build", build)
.toString();
}
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/impl/JobData.java b/vid-app-common/src/main/java/org/onap/vid/job/impl/JobData.java
index c8e128e60..113fde38c 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/impl/JobData.java
+++ b/vid-app-common/src/main/java/org/onap/vid/job/impl/JobData.java
@@ -7,9 +7,9 @@
* 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.
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/impl/JobSchedulerInitializer.java b/vid-app-common/src/main/java/org/onap/vid/job/impl/JobSchedulerInitializer.java
index 234c10614..b3ab75b23 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/impl/JobSchedulerInitializer.java
+++ b/vid-app-common/src/main/java/org/onap/vid/job/impl/JobSchedulerInitializer.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,13 +20,13 @@
package org.onap.vid.job.impl;
+import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.vid.exceptions.GenericUncheckedException;
import org.onap.vid.job.Job;
import org.onap.vid.job.JobsBrokerService;
import org.onap.vid.job.command.JobCommandFactory;
-import org.onap.vid.properties.Features;
import org.quartz.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
@@ -34,6 +34,7 @@ import org.springframework.stereotype.Component;
import org.togglz.core.manager.FeatureManager;
import javax.annotation.PostConstruct;
+import java.util.List;
import static org.quartz.SimpleScheduleBuilder.simpleSchedule;
@@ -51,24 +52,26 @@ public class JobSchedulerInitializer {
JobsBrokerService jobsBrokerService,
SchedulerFactoryBean schedulerFactoryBean,
FeatureManager featureManager,
- JobCommandFactory JobCommandFactory
+ JobCommandFactory jobCommandFactory
) {
this.jobsBrokerService = jobsBrokerService;
this.schedulerFactoryBean = schedulerFactoryBean;
this.featureManager = featureManager;
- this.jobCommandFactory = JobCommandFactory;
+ this.jobCommandFactory = jobCommandFactory;
}
+ public static final List<Job.JobStatus> WORKERS_TOPICS = ImmutableList.of(
+ Job.JobStatus.PENDING,
+ Job.JobStatus.CREATING,
+ Job.JobStatus.IN_PROGRESS,
+ Job.JobStatus.RESOURCE_IN_PROGRESS,
+ Job.JobStatus.PENDING_RESOURCE
+ );
+
@PostConstruct
public void init() {
- if (!featureManager.isActive(Features.FLAG_ASYNC_JOBS)) {
- return;
- }
- scheduleJobWorker(Job.JobStatus.PENDING, 1);
- scheduleJobWorker(Job.JobStatus.CREATING, 1);
- scheduleJobWorker(Job.JobStatus.IN_PROGRESS, 1);
- scheduleJobWorker(Job.JobStatus.RESOURCE_IN_PROGRESS, 1);
+ WORKERS_TOPICS.forEach(topic->scheduleJobWorker(topic, 1));
}
private void scheduleJobWorker(Job.JobStatus topic, int intervalInSeconds) {
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/impl/JobSharedData.java b/vid-app-common/src/main/java/org/onap/vid/job/impl/JobSharedData.java
index 66a04996e..f420f4f3e 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/impl/JobSharedData.java
+++ b/vid-app-common/src/main/java/org/onap/vid/job/impl/JobSharedData.java
@@ -7,9 +7,9 @@
* 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.
@@ -32,6 +32,7 @@ public class JobSharedData {
protected String userId;
protected Class requestType;
protected UUID rootJobId;
+ protected String testApi;
@JsonTypeInfo(use=JsonTypeInfo.Id.CLASS, property="class")
protected JobAdapter.AsyncJobRequest request;
@@ -39,16 +40,17 @@ public class JobSharedData {
public JobSharedData() {
}
- public JobSharedData(UUID jobUuid, String userId, JobAdapter.AsyncJobRequest request) {
+ public JobSharedData(UUID jobUuid, String userId, JobAdapter.AsyncJobRequest request, String testApi) {
this.jobUuid = jobUuid;
this.userId = userId;
this.requestType = request.getClass();
this.request = request;
this.rootJobId = jobUuid;
+ this.testApi = testApi;
}
public JobSharedData(UUID jobUuid, JobAdapter.AsyncJobRequest request, JobSharedData parentData) {
- this(jobUuid, parentData.getUserId(), request);
+ this(jobUuid, parentData.getUserId(), request, parentData.getTestApi());
rootJobId = parentData.getRootJobId() != null ? parentData.getRootJobId() : parentData.getJobUuid();
}
@@ -85,6 +87,14 @@ public class JobSharedData {
return rootJobId;
}
+ public String getTestApi() {
+ return testApi;
+ }
+
+ public void setTestApi(String testApi) {
+ this.testApi = testApi;
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) return true;
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/impl/JobWorker.java b/vid-app-common/src/main/java/org/onap/vid/job/impl/JobWorker.java
index 5b5d1e13d..0b277b4d2 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/impl/JobWorker.java
+++ b/vid-app-common/src/main/java/org/onap/vid/job/impl/JobWorker.java
@@ -7,9 +7,9 @@
* 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.
@@ -25,17 +25,17 @@ import org.apache.commons.lang3.exception.ExceptionUtils;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.vid.job.*;
import org.onap.vid.job.command.JobCommandFactory;
-import org.onap.vid.properties.Features;
import org.quartz.JobExecutionContext;
import org.springframework.scheduling.quartz.QuartzJobBean;
import org.springframework.stereotype.Component;
-import org.togglz.core.manager.FeatureManager;
import java.util.Optional;
import java.util.UUID;
import static org.onap.vid.job.Job.JobStatus.FAILED;
import static org.onap.vid.job.Job.JobStatus.STOPPED;
+import static org.onap.vid.job.command.ResourceCommandKt.ACTION_PHASE;
+import static org.onap.vid.job.command.ResourceCommandKt.INTERNAL_STATE;
@Component
public class JobWorker extends QuartzJobBean {
@@ -43,7 +43,6 @@ public class JobWorker extends QuartzJobBean {
private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(JobWorker.class);
private JobsBrokerService jobsBrokerService;
- private FeatureManager featureManager;
private JobCommandFactory jobCommandFactory;
private Job.JobStatus topic;
@@ -51,10 +50,6 @@ public class JobWorker extends QuartzJobBean {
protected void executeInternal(JobExecutionContext context) {
Optional<Job> job;
- if (!isMsoNewApiActive()) {
- return;
- }
-
job = pullJob();
while (job.isPresent()) {
@@ -85,10 +80,16 @@ public class JobWorker extends QuartzJobBean {
}
protected Job executeJobAndGetNext(Job job) {
- LOGGER.debug(EELFLoggerDelegate.debugLogger, "going to execute job {} of {}: {}/{}",
+ Object internalState = job.getData().get(INTERNAL_STATE);
+ Object actionPhase = job.getData().get(ACTION_PHASE);
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "going to execute job {} of {}: {}/{} {}/{}",
StringUtils.substring(String.valueOf(job.getUuid()), 0, 8),
StringUtils.substring(String.valueOf(job.getTemplateId()), 0, 8),
- job.getStatus(), job.getType());
+ job.getStatus(),
+ job.getType(),
+ actionPhase,
+ internalState
+ );
NextCommand nextCommand = executeCommandAndGetNext(job);
@@ -128,10 +129,6 @@ public class JobWorker extends QuartzJobBean {
return job;
}
- private boolean isMsoNewApiActive() {
- return featureManager.isActive(Features.FLAG_ASYNC_INSTANTIATION);
- }
-
private void tryMutingJobFromException(Exception e) {
// If there's JobException in the stack, read job uuid from
// the exception, and mute it in DB.
@@ -158,10 +155,6 @@ public class JobWorker extends QuartzJobBean {
this.jobsBrokerService = jobsBrokerService;
}
- public void setFeatureManager(FeatureManager featureManager) {
- this.featureManager = featureManager;
- }
-
public void setJobCommandFactory(JobCommandFactory jobCommandFactory) {
this.jobCommandFactory = jobCommandFactory;
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/impl/JobsBrokerServiceInDatabaseImpl.java b/vid-app-common/src/main/java/org/onap/vid/job/impl/JobsBrokerServiceInDatabaseImpl.java
index 59ca43743..74a729494 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/impl/JobsBrokerServiceInDatabaseImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/job/impl/JobsBrokerServiceInDatabaseImpl.java
@@ -7,9 +7,9 @@
* 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.
@@ -22,6 +22,7 @@ package org.onap.vid.job.impl;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.SessionFactory;
+import org.jetbrains.annotations.NotNull;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.portalsdk.core.service.DataAccessService;
import org.onap.portalsdk.core.util.SystemProperties;
@@ -30,18 +31,19 @@ import org.onap.vid.exceptions.OperationNotAllowedException;
import org.onap.vid.job.Job;
import org.onap.vid.job.JobsBrokerService;
import org.onap.vid.properties.VidProperties;
+import org.onap.vid.services.VersionService;
import org.onap.vid.utils.DaoUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
-import java.nio.ByteBuffer;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.*;
+import java.util.stream.Collectors;
-import static org.onap.vid.job.Job.JobStatus.CREATING;
+import static org.onap.vid.job.Job.JobStatus.*;
@Service
public class JobsBrokerServiceInDatabaseImpl implements JobsBrokerService {
@@ -54,15 +56,20 @@ public class JobsBrokerServiceInDatabaseImpl implements JobsBrokerService {
private int maxOpenedInstantiationRequestsToMso;
private int pollingIntervalSeconds;
+ private final VersionService versionService;
+
@Autowired
- public JobsBrokerServiceInDatabaseImpl(DataAccessService dataAccessService, SessionFactory sessionFactory,
+ public JobsBrokerServiceInDatabaseImpl(DataAccessService dataAccessService,
+ SessionFactory sessionFactory,
@Value("0") int maxOpenedInstantiationRequestsToMso,
- @Value("10") int pollingIntervalSeconds) {
+ @Value("10") int pollingIntervalSeconds,
+ VersionService versionService) {
// tha @Value will inject conservative defaults; overridden in @PostConstruct from configuration
this.dataAccessService = dataAccessService;
this.sessionFactory = sessionFactory;
this.maxOpenedInstantiationRequestsToMso = maxOpenedInstantiationRequestsToMso;
this.pollingIntervalSeconds = pollingIntervalSeconds;
+ this.versionService = versionService;
}
@PostConstruct
@@ -78,6 +85,7 @@ public class JobsBrokerServiceInDatabaseImpl implements JobsBrokerService {
@Override
public UUID add(Job job) {
final JobDaoImpl jobDao = castToJobDaoImpl(job);
+ jobDao.setBuild(versionService.retrieveBuildNumber());
dataAccessService.saveDomainObject(jobDao, DaoUtils.getPropsMap());
return job.getUuid();
}
@@ -120,7 +128,11 @@ public class JobsBrokerServiceInDatabaseImpl implements JobsBrokerService {
}
private java.sql.Timestamp nowMinusInterval() {
- return Timestamp.valueOf(LocalDateTime.now().minusSeconds(pollingIntervalSeconds));
+ return nowMinusInterval(pollingIntervalSeconds);
+ }
+
+ private java.sql.Timestamp nowMinusInterval(long seconds) {
+ return Timestamp.valueOf(LocalDateTime.now().minusSeconds(seconds));
}
private String selectQueryByJobStatus(Job.JobStatus topic){
@@ -130,17 +142,23 @@ public class JobsBrokerServiceInDatabaseImpl implements JobsBrokerService {
"select * from VID_JOB" +
" where" +
// select only non-deleted in-progress jobs
- " JOB_STATUS = '" + topic + "'" +
- " and TAKEN_BY is null" +
- " and DELETED_AT is null" +
+ filterByStatusNotTakenNotDeleted(topic) +
// give some breath, don't select jos that were recently reached
- intervalCondition +
+ intervalCondition +
// take the oldest handled one
" order by MODIFIED_DATE ASC" +
// select only one result
" limit 1";
}
+ @NotNull
+ private String filterByStatusNotTakenNotDeleted(Job.JobStatus topic) {
+ return " JOB_STATUS = '" + topic + "'" +
+ " and TAKEN_BY is null" +
+ " and DELETED_AT is null "+
+ " and BUILD = '"+ versionService.retrieveBuildNumber() +"'";
+ }
+
private String sqlQueryForTopic(Job.JobStatus topic) {
switch (topic) {
case IN_PROGRESS:
@@ -148,44 +166,73 @@ public class JobsBrokerServiceInDatabaseImpl implements JobsBrokerService {
case CREATING:
return selectQueryByJobStatus(topic);
case PENDING:
- return "" +
- // select only pending jobs
- "select vid_job.* from VID_JOB " +
- // select users have in_progress jobs
- "left join \n" +
- " (select user_Id, 1 as has_any_in_progress_job from VID_JOB where JOB_STATUS = 'IN_PROGRESS' or TAKEN_BY IS NOT NULL \n" +
- "group by user_id) users_have_any_in_progress_job_tbl\n" +
- "on vid_job.user_id = users_have_any_in_progress_job_tbl.user_id " +
- "where JOB_STATUS = 'PENDING' and TAKEN_BY is null" +
- // job is not deleted
- " AND DELETED_AT is null and (\n" +
- // limit in-progress to some amount
- "select sum(CASE WHEN JOB_STATUS='IN_PROGRESS' or (JOB_STATUS='PENDING' and TAKEN_BY IS NOT NULL) THEN 1 ELSE 0 END) as in_progress\n" +
- "from VID_JOB ) <" + maxOpenedInstantiationRequestsToMso + " \n " +
- // don't take jobs from templates that already in-progress/failed
- "and TEMPLATE_Id not in \n" +
- "(select TEMPLATE_Id from vid_job where" +
- " TEMPLATE_Id IS NOT NULL and("+
- " (JOB_STATUS='FAILED' and DELETED_AT is null)" + // failed but not deleted
- " or JOB_STATUS='IN_PROGRESS'" +
- " or TAKEN_BY IS NOT NULL))" + " \n " +
- // prefer older jobs, but the earlier in each bulk
- "order by has_any_in_progress_job, CREATED_DATE, INDEX_IN_BULK " +
- // select only one result
- "limit 1";
+ return selectQueryForPendingJob();
+ case PENDING_RESOURCE:
+ return selectQueryForPendingResource();
default:
throw new GenericUncheckedException("Unsupported topic to pull from: " + topic);
}
}
+ @NotNull
+ private String selectQueryForPendingJob() {
+ return "" +
+ // select only pending jobs
+ "select vid_job.* from VID_JOB " +
+ // select users have in_progress jobs
+ "left join \n" +
+ " (select user_Id, 1 as has_any_in_progress_job from VID_JOB where JOB_STATUS = 'IN_PROGRESS' or TAKEN_BY IS NOT NULL \n" +
+ "group by user_id) users_have_any_in_progress_job_tbl\n" +
+ "on vid_job.user_id = users_have_any_in_progress_job_tbl.user_id " +
+ "where "+filterByStatusNotTakenNotDeleted(Job.JobStatus.PENDING)+" and (\n" +
+ // limit in-progress to some amount
+ "select sum(CASE WHEN JOB_STATUS='IN_PROGRESS' or (JOB_STATUS='PENDING' and TAKEN_BY IS NOT NULL) THEN 1 ELSE 0 END) as in_progress\n" +
+ "from VID_JOB ) <" + maxOpenedInstantiationRequestsToMso + " \n " +
+ // don't take jobs from templates that already in-progress/failed
+ "and TEMPLATE_Id not in \n" +
+ "(select TEMPLATE_Id from vid_job where" +
+ " TEMPLATE_Id IS NOT NULL and("+
+ " (JOB_STATUS='FAILED' and DELETED_AT is null)" + // failed but not deleted
+ " or JOB_STATUS='IN_PROGRESS'" +
+ " or TAKEN_BY IS NOT NULL))" + " \n " +
+ // prefer older jobs, but the earlier in each bulk
+ "order by has_any_in_progress_job, CREATED_DATE, INDEX_IN_BULK " +
+ // select only one result
+ "limit 1";
+ }
- private byte[] getUuidAsByteArray(UUID owner) {
- ByteBuffer bb = ByteBuffer.wrap(new byte[16]);
- bb.putLong(owner.getMostSignificantBits());
- bb.putLong(owner.getLeastSignificantBits());
- return bb.array();
+ @NotNull
+ private String selectQueryForPendingResource() {
+ return "select * from vid_job as JOB left join \n" +
+ //count jobs
+ "(select template_id,count(*) as in_progress_count from vid_job \n" +
+ String.format("where (\n"+
+ " (\n"+
+ //with job_status IN_PROGRESS or RESOURCE_IN_PROGRESS
+ " (job_status in ('%s','%s') and DELETED_AT is NULL) \n",IN_PROGRESS, RESOURCE_IN_PROGRESS)+
+ //or that with job_status PENDING_RESOURCE that are taken
+ String.format(" or (JOB_STATUS='%s' and TAKEN_BY IS NOT NULL)\n )\n", PENDING_RESOURCE) +
+ //with template ID and are not deleted
+ " and TEMPLATE_ID IS NOT NULL and DELETED_AT is NULL\n)\n" +
+ //join them to vid_job by template_id
+ "group by template_id)\n"+
+ "as COUNTER on COUNTER.template_id=JOB.template_id \n" +
+
+ "where (\n"+
+ //select jobs with job_status PENDING_RESOURCE that are nit taken and not deleted
+ filterByStatusNotTakenNotDeleted(PENDING_RESOURCE) + "\n" +
+ //that have no count in the counter (no other in progress job with same templateId)
+ " and in_progress_count is NULL \n" +
+ //and that have valid templateId
+ " and JOB.template_id is not NULL \n"+
+ ")\n" +
+ //INDEX_IN_BULK is for order them inside same templateId,
+ //template_id - for order between different templateId (just to be deterministic)
+ "order by INDEX_IN_BULK,JOB.template_id \n" +
+ "limit 1;";
}
+
@Override
public void pushBack(Job job) {
final JobDaoImpl remoteDaoJob = (JobDaoImpl) dataAccessService.getDomainObject(JobDaoImpl.class, job.getUuid(), null);
@@ -253,7 +300,7 @@ public class JobsBrokerServiceInDatabaseImpl implements JobsBrokerService {
throw new OperationNotAllowedException("Service does not exist");
}
- if (!remoteDaoJob.getStatus().equals(Job.JobStatus.PENDING) && !remoteDaoJob.getStatus().equals(Job.JobStatus.STOPPED) || !StringUtils.isEmpty(remoteDaoJob.getTakenBy()) ) {
+ if ((remoteDaoJob.getStatus() != Job.JobStatus.PENDING) && (remoteDaoJob.getStatus() != Job.JobStatus.STOPPED) || !StringUtils.isEmpty(remoteDaoJob.getTakenBy()) ) {
logger.debug(EELFLoggerDelegate.debugLogger,"jobId {}: Service status does not allow deletion from the queue, status = {}", jobId, remoteDaoJob.getStatus() +
", takenBy " + remoteDaoJob.getTakenBy());
throw new OperationNotAllowedException("Service status does not allow deletion from the queue");
@@ -290,4 +337,17 @@ public class JobsBrokerServiceInDatabaseImpl implements JobsBrokerService {
return updatedEntities != 0;
}
+
+ private static String sqlListOfFinalStatus =
+ String.format("(%s)",
+ FINAL_STATUS.stream().
+ map(x->String.format("'%s'",x)).
+ collect(Collectors.joining(","))
+ );
+
+ @Override
+ public void deleteOldFinalJobs(long secondsAgo) {
+ String select = String.format(" MODIFIED_DATE <= '%s' and JOB_STATUS in %s", nowMinusInterval(secondsAgo), sqlListOfFinalStatus);
+ dataAccessService.deleteDomainObjects(JobDaoImpl.class, select, null);
+ }
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/Action.java b/vid-app-common/src/main/java/org/onap/vid/model/Action.java
index ebaa691af..c0d4fae6a 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/Action.java
+++ b/vid-app-common/src/main/java/org/onap/vid/model/Action.java
@@ -7,9 +7,9 @@
* 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.
@@ -23,7 +23,9 @@ package org.onap.vid.model;
public enum Action {
Create(ServiceInfo.ServiceAction.INSTANTIATE),
Delete(ServiceInfo.ServiceAction.DELETE),
- None(ServiceInfo.ServiceAction.UPDATE);
+ None(ServiceInfo.ServiceAction.UPDATE),
+ Resume(ServiceInfo.ServiceAction.RESUME),
+ Replace(ServiceInfo.ServiceAction.REPLACE);
private final ServiceInfo.ServiceAction serviceAction;
Action(ServiceInfo.ServiceAction serviceAction){
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/JobAuditStatus.java b/vid-app-common/src/main/java/org/onap/vid/model/JobAuditStatus.java
index 49e25ecb0..645934530 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/JobAuditStatus.java
+++ b/vid-app-common/src/main/java/org/onap/vid/model/JobAuditStatus.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,6 +20,21 @@
package org.onap.vid.model;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.TimeZone;
+import java.util.UUID;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Transient;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
@@ -29,14 +44,6 @@ import org.hibernate.annotations.Type;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.vid.job.Job.JobStatus;
-import javax.persistence.*;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.TimeZone;
-import java.util.UUID;
-
/*
The following 2 annotations let hibernate to update only fields that actually have been changed.
DynamicUpdate tell hibernate to update only dirty fields.
@@ -54,43 +61,40 @@ public class JobAuditStatus extends VidBaseEntity {
public JobAuditStatus(){}
- public JobAuditStatus(UUID jobId, String jobStatus, SourceStatus source){
+ private JobAuditStatus(UUID jobId, String instanceName, String instanceType, String jobStatus,
+ SourceStatus source, UUID requestId, String additionalInfo, Date date, int ordinal) {
this.jobId = jobId;
+ this.instanceName = instanceName;
+ this.instanceType = instanceType;
this.jobStatus = jobStatus;
this.source = source;
+ this.requestId = requestId;
+ setAdditionalInfo(additionalInfo);
+ this.ordinal = ordinal;
+ this.created = date;
}
- public JobAuditStatus(UUID jobId, String jobStatus, SourceStatus source, Date date){
- this(jobId, jobStatus, source);
- this.created = date;
+ public JobAuditStatus(UUID jobId, String jobStatus, SourceStatus source){
+ this(jobId, null, null, jobStatus, source, null, null, null, 0);
}
public JobAuditStatus(UUID jobId, String jobStatus, SourceStatus source, UUID requestId, String additionalInfo) {
- this(jobId, jobStatus, source);
- this.requestId = requestId;
- setAdditionalInfo(additionalInfo);
+ this(jobId, null, null, jobStatus, source, requestId, additionalInfo, null, 0);
}
- public JobAuditStatus(UUID jobId, String jobStatus, SourceStatus source, UUID requestId, String additionalInfo, Date date){
- this(jobId, jobStatus, source, requestId, additionalInfo);
- this.created = date;
+ public JobAuditStatus(String instanceName, String jobStatus, UUID requestId, String additionalInfo, String date, String instanceType) {
+ this(null, instanceName, instanceType, jobStatus, null, requestId, additionalInfo, null, 0);
+ this.created = dateStringToDate(date);
}
- public JobAuditStatus(String instanceName, String jobStatus, UUID requestId, String additionalInfo) {
- this.instanceName = instanceName;
- this.jobStatus = jobStatus;
- this.requestId = requestId;
- this.additionalInfo = additionalInfo;
-
+ public static JobAuditStatus createForTest(UUID jobId, String jobStatus, SourceStatus source, Date date, int ordinal) {
+ return new JobAuditStatus(jobId, null, null, jobStatus, source, null, null, date, ordinal);
}
- public JobAuditStatus(String instanceName, String jobStatus, UUID requestId, String additionalInfo, String date, String instanceType) {
- this(instanceName, jobStatus, requestId, additionalInfo);
- this.created = dateStringToDate(date);
- this.instanceType = instanceType;
+ public static JobAuditStatus createForTest(UUID jobId, String jobStatus, SourceStatus source, UUID requestId, String additionalInfo, Date date) {
+ return new JobAuditStatus(jobId, null, null, jobStatus, source, requestId, additionalInfo, date, 0);
}
-
private Date dateStringToDate(String dateAsString){
if (StringUtils.isEmpty(dateAsString)) {
return null;
@@ -121,6 +125,7 @@ public class JobAuditStatus extends VidBaseEntity {
.append(source, that.source)
.append(requestId, that.requestId)
.append(additionalInfo, that.additionalInfo)
+ // ordinal is not part of equality (similarly to "created" field)
.isEquals();
}
@@ -132,6 +137,7 @@ public class JobAuditStatus extends VidBaseEntity {
.append(source)
.append(requestId)
.append(additionalInfo)
+ // ordinal is not part of equality (similarly to "created" field)
.toHashCode();
}
@@ -140,6 +146,25 @@ public class JobAuditStatus extends VidBaseEntity {
VID
}
+ public enum ResourceTypeFilter {
+ SERVICE("serviceInstanceId"),
+ VNF("vnfInstanceId"),
+ VFMODULE("vfModuleInstanceId"),
+ NETWORK("networkInstanceId"),
+ VNFGROUP("instanceGroupId");
+
+ private final String filterBy;
+
+ ResourceTypeFilter(String filterBy) {
+ this.filterBy = filterBy;
+ }
+
+ public String getFilterBy() {
+ return filterBy;
+ }
+ }
+
+
private UUID jobId;
private String instanceName;
private String instanceType;
@@ -147,6 +172,7 @@ public class JobAuditStatus extends VidBaseEntity {
private SourceStatus source;
private UUID requestId;
private String additionalInfo;
+ private int ordinal;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -206,6 +232,18 @@ public class JobAuditStatus extends VidBaseEntity {
this.additionalInfo = StringUtils.substring(additionalInfo, 0, MAX_ADDITIONAL_INFO_LENGTH);
}
+ @Column(name = "ORDINAL", columnDefinition = "INT")
+ public int getOrdinal() {
+ // Ordinal allows sorting audit statuses by
+ // insertion order, regardless of "created"
+ // field
+ return ordinal;
+ }
+
+ public void setOrdinal(int ordinal) {
+ this.ordinal = ordinal;
+ }
+
@Transient
public String getInstanceName() {
return instanceName;
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/ModelUtil.java b/vid-app-common/src/main/java/org/onap/vid/model/ModelUtil.java
index 98514f0c1..45e100fb1 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/ModelUtil.java
+++ b/vid-app-common/src/main/java/org/onap/vid/model/ModelUtil.java
@@ -18,15 +18,8 @@
* ============LICENSE_END=========================================================
*/
-/**
- *
- */
package org.onap.vid.model;
-/**
- * The Class ModelUtil.
- *
- */
public class ModelUtil {
/**
* Gets the tags for the given element according to the configured namespace
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/ResourceInfo.java b/vid-app-common/src/main/java/org/onap/vid/model/ResourceInfo.java
new file mode 100644
index 000000000..deda23f37
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/ResourceInfo.java
@@ -0,0 +1,144 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.vid.model;
+
+import static org.onap.vid.utils.KotlinUtilsKt.JACKSON_OBJECT_MAPPER;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import java.io.IOException;
+import java.util.Objects;
+import java.util.UUID;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import org.hibernate.annotations.DynamicUpdate;
+import org.hibernate.annotations.SelectBeforeUpdate;
+import org.hibernate.annotations.Type;
+import org.onap.vid.exceptions.GenericUncheckedException;
+import org.onap.vid.job.Job;
+import org.onap.vid.job.JobException;
+import org.onap.vid.mso.rest.AsyncRequestStatus;
+
+@DynamicUpdate
+@SelectBeforeUpdate
+@Entity
+@Table(name = "vid_resource_info")
+public class ResourceInfo extends VidBaseEntity {
+
+ private String trackById;
+ private UUID rootJobId;
+ private String instanceId;
+ private Job.JobStatus jobStatus;
+ private AsyncRequestStatus errorMessage;
+
+ public ResourceInfo(){}
+
+ public ResourceInfo(String trackById, UUID rootJobId, String instanceId, Job.JobStatus jobStatus, AsyncRequestStatus errorMessage) {
+ this.trackById = trackById;
+ this.rootJobId = rootJobId;
+ this.instanceId = instanceId;
+ this.jobStatus = jobStatus;
+ this.errorMessage = errorMessage;
+ }
+
+ @Id
+ @Column(name = "TRACK_BY_ID", columnDefinition = "CHAR(36)")
+ public String getTrackById() {
+ return trackById;
+ }
+
+ @Column(name = "ROOT_JOB_ID", columnDefinition = "CHAR(36)")
+ @Type(type="org.hibernate.type.UUIDCharType")
+ public UUID getRootJobId() {
+ return rootJobId;
+ }
+
+ @Column(name="JOB_STATUS")
+ @Enumerated(EnumType.STRING)
+ public Job.JobStatus getJobStatus() {
+ return jobStatus;
+ }
+
+ @Column(name="INSTANCE_ID")
+ public String getInstanceId() {
+ return instanceId;
+ }
+
+ public void setTrackById(String trackById) {
+ this.trackById = trackById;
+ }
+
+ public void setRootJobId(UUID rootJobId) {
+ this.rootJobId = rootJobId;
+ }
+
+ public void setInstanceId(String instanceId) {
+ this.instanceId = instanceId;
+ }
+ public void setJobStatus(Job.JobStatus jobStatus) {
+ this.jobStatus = jobStatus;
+ }
+
+ @Column(name = "ERROR_MESSAGE", columnDefinition = "VARCHAR(30000)")
+ public String getErrorMessageRaw() {
+ try {
+ return JACKSON_OBJECT_MAPPER.writeValueAsString(errorMessage);
+ } catch (JsonProcessingException e) {
+ throw new GenericUncheckedException(e);
+ }
+ }
+
+ public void setErrorMessageRaw(String failedMessage) {
+ try {
+ this.errorMessage = JACKSON_OBJECT_MAPPER.readValue(failedMessage, AsyncRequestStatus.class);
+ } catch (IOException e) {
+ throw new JobException("Error parsing mso failed message", rootJobId, e);
+ }
+ }
+
+ @Transient
+ public AsyncRequestStatus getErrorMessage() {
+ return this.errorMessage;
+ }
+
+ public void setErrorMessage(AsyncRequestStatus errorMessage) {
+ this.errorMessage = errorMessage;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ ResourceInfo that = (ResourceInfo) o;
+ return Objects.equals(trackById, that.trackById) &&
+ Objects.equals(instanceId, that.instanceId) &&
+ jobStatus == that.jobStatus;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(trackById, instanceId, jobStatus);
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/ServiceInfo.java b/vid-app-common/src/main/java/org/onap/vid/model/ServiceInfo.java
index 3b49eedca..1e1e6c2a7 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/ServiceInfo.java
+++ b/vid-app-common/src/main/java/org/onap/vid/model/ServiceInfo.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,22 +18,22 @@
* ============LICENSE_END=========================================================
*/
- package org.onap.vid.model;
+package org.onap.vid.model;
- import com.fasterxml.jackson.annotation.JsonProperty;
- import org.hibernate.annotations.DynamicUpdate;
- import org.hibernate.annotations.SelectBeforeUpdate;
- import org.hibernate.annotations.Type;
- import org.onap.portalsdk.core.domain.support.DomainVo;
- import org.onap.vid.job.Job;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.hibernate.annotations.DynamicUpdate;
+import org.hibernate.annotations.SelectBeforeUpdate;
+import org.hibernate.annotations.Type;
+import org.onap.portalsdk.core.domain.support.DomainVo;
+import org.onap.vid.job.Job;
- import javax.persistence.*;
- import java.io.Serializable;
- import java.util.Date;
- import java.util.Objects;
- import java.util.Set;
- import java.util.UUID;
+import javax.persistence.*;
+import java.io.Serializable;
+import java.util.Date;
+import java.util.Objects;
+import java.util.Set;
+import java.util.UUID;
/*
The following 2 annotations let hibernate to update only fields that actually have been changed.
@@ -49,11 +49,9 @@ public class ServiceInfo extends DomainVo {
public enum ServiceAction {
INSTANTIATE,
DELETE,
- UPDATE
- }
-
- public void setUserId(String userId) {
- this.userId = userId;
+ UPDATE,
+ RESUME,
+ REPLACE
}
private UUID jobId;
@@ -65,6 +63,7 @@ public class ServiceInfo extends DomainVo {
private Date statusModifiedDate;
private boolean hidden;
private boolean pause;
+ private boolean retryEnabled;
private Date deletedAt;
private String owningEntityId;
private String owningEntityName;
@@ -90,7 +89,12 @@ public class ServiceInfo extends DomainVo {
}
- public ServiceInfo(String userId, Boolean aLaCarte, Job.JobStatus jobStatus, boolean pause, UUID jobId, UUID templateId, String owningEntityId, String owningEntityName, String project, String aicZoneId, String aicZoneName, String tenantId, String tenantName, String regionId, String regionName, String serviceType, String subscriberName, String subscriberId, String serviceInstanceId, String serviceInstanceName, String serviceModelId, String serviceModelName, String serviceModelVersion, Date createdBulkDate, ServiceAction action) {
+ public ServiceInfo(String userId, Boolean aLaCarte, Job.JobStatus jobStatus, boolean pause, UUID jobId, UUID templateId,
+ String owningEntityId, String owningEntityName, String project, String aicZoneId, String aicZoneName,
+ String tenantId, String tenantName, String regionId, String regionName, String serviceType,
+ String subscriberName, String subscriberId, String serviceInstanceId, String serviceInstanceName,
+ String serviceModelId, String serviceModelName, String serviceModelVersion, Date createdBulkDate,
+ ServiceAction action, boolean retryEnabled) {
this.userId = userId;
this.aLaCarte = aLaCarte;
this.jobStatus = jobStatus;
@@ -116,6 +120,7 @@ public class ServiceInfo extends DomainVo {
this.serviceModelVersion = serviceModelVersion;
this.createdBulkDate = createdBulkDate;
this.action = action;
+ this.retryEnabled = retryEnabled;
}
@Column(name = "JOB_ID", columnDefinition = "CHAR(36)")
@@ -168,6 +173,12 @@ public class ServiceInfo extends DomainVo {
return pause;
}
+ @Column(name="IS_RETRY_ENABLED")
+ @JsonProperty("isRetryEnabled")
+ public boolean isRetryEnabled() {
+ return retryEnabled;
+ }
+
@Column(name="OWNING_ENTITY_ID")
public String getOwningEntityId() {
return owningEntityId;
@@ -260,8 +271,8 @@ public class ServiceInfo extends DomainVo {
@Column(name="DELETED_AT")
public Date getDeletedAt() {
- return deletedAt;
- }
+ return deletedAt;
+ }
@Column(name="ACTION")
@Enumerated(EnumType.STRING)
@@ -319,6 +330,9 @@ public class ServiceInfo extends DomainVo {
return super.getAuditTrail();
}
+ public void setUserId(String userId) {
+ this.userId = userId;
+ }
public void setJobId(UUID jobId) {
this.jobId = jobId;
}
@@ -351,6 +365,10 @@ public class ServiceInfo extends DomainVo {
this.pause = pause;
}
+ public void setRetryEnabled(boolean retryEnabled) {
+ this.retryEnabled = retryEnabled;
+ }
+
public void setOwningEntityId(String owningEntityId) {
this.owningEntityId = owningEntityId;
}
@@ -424,55 +442,54 @@ public class ServiceInfo extends DomainVo {
}
public void setDeletedAt(Date deletedAt) {
- this.deletedAt = deletedAt;
- }
+ this.deletedAt = deletedAt;
+ }
public void setAction(ServiceAction action) { this.action = action; }
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof ServiceInfo)) return false;
- ServiceInfo that = (ServiceInfo) o;
- return isHidden() == that.isHidden() &&
- isPause() == that.isPause() &&
- isALaCarte() == that.isALaCarte() &&
- Objects.equals(getDeletedAt(), that.getDeletedAt()) &&
- Objects.equals(getJobId(), that.getJobId()) &&
- Objects.equals(getTemplateId(), that.getTemplateId()) &&
- Objects.equals(getUserId(), that.getUserId()) &&
- Objects.equals(getMsoRequestId(), that.getMsoRequestId()) &&
- getJobStatus() == that.getJobStatus() &&
- Objects.equals(getStatusModifiedDate(), that.getStatusModifiedDate()) &&
- Objects.equals(getOwningEntityId(), that.getOwningEntityId()) &&
- Objects.equals(getOwningEntityName(), that.getOwningEntityName()) &&
- Objects.equals(getProject(), that.getProject()) &&
- Objects.equals(getAicZoneId(), that.getAicZoneId()) &&
- Objects.equals(getAicZoneName(), that.getAicZoneName()) &&
- Objects.equals(getTenantId(), that.getTenantId()) &&
- Objects.equals(getTenantName(), that.getTenantName()) &&
- Objects.equals(getRegionId(), that.getRegionId()) &&
- Objects.equals(getRegionName(), that.getRegionName()) &&
- Objects.equals(getServiceType(), that.getServiceType()) &&
- Objects.equals(getSubscriberName(), that.getSubscriberName()) &&
- Objects.equals(getSubscriberId(), that.getSubscriberId()) &&
- Objects.equals(getServiceInstanceId(), that.getServiceInstanceId()) &&
- Objects.equals(getServiceInstanceName(), that.getServiceInstanceName()) &&
- Objects.equals(getServiceModelId(), that.getServiceModelId()) &&
- Objects.equals(getServiceModelName(), that.getServiceModelName()) &&
- Objects.equals(getServiceModelVersion(), that.getServiceModelVersion()) &&
- Objects.equals(getCreatedBulkDate(), that.getCreatedBulkDate()) &&
- Objects.equals(getAction(), that.getAction());
- }
-
- @Override
- public int hashCode() {
-
- return Objects.hash(getJobId(), getTemplateId(), getUserId(), getMsoRequestId(), isALaCarte(), getJobStatus(), getStatusModifiedDate(),
- isHidden(), isPause(), getDeletedAt(), getOwningEntityId(), getOwningEntityName(), getProject(),
- getAicZoneId(), getAicZoneName(), getTenantId(), getTenantName(), getRegionId(),
- getRegionName(), getServiceType(), getSubscriberName(), getSubscriberId(), getServiceInstanceId(),
- getServiceInstanceName(), getServiceModelId(), getServiceModelName(),
- getServiceModelVersion(), getCreatedBulkDate(), getAction());
- }
- }
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof ServiceInfo)) return false;
+ ServiceInfo that = (ServiceInfo) o;
+ return aLaCarte == that.aLaCarte &&
+ isHidden() == that.isHidden() &&
+ isPause() == that.isPause() &&
+ isRetryEnabled() == that.isRetryEnabled() &&
+ Objects.equals(getJobId(), that.getJobId()) &&
+ Objects.equals(getTemplateId(), that.getTemplateId()) &&
+ Objects.equals(getUserId(), that.getUserId()) &&
+ Objects.equals(getMsoRequestId(), that.getMsoRequestId()) &&
+ getJobStatus() == that.getJobStatus() &&
+ Objects.equals(getStatusModifiedDate(), that.getStatusModifiedDate()) &&
+ Objects.equals(getDeletedAt(), that.getDeletedAt()) &&
+ Objects.equals(getOwningEntityId(), that.getOwningEntityId()) &&
+ Objects.equals(getOwningEntityName(), that.getOwningEntityName()) &&
+ Objects.equals(getProject(), that.getProject()) &&
+ Objects.equals(getAicZoneId(), that.getAicZoneId()) &&
+ Objects.equals(getAicZoneName(), that.getAicZoneName()) &&
+ Objects.equals(getTenantId(), that.getTenantId()) &&
+ Objects.equals(getTenantName(), that.getTenantName()) &&
+ Objects.equals(getRegionId(), that.getRegionId()) &&
+ Objects.equals(getRegionName(), that.getRegionName()) &&
+ Objects.equals(getServiceType(), that.getServiceType()) &&
+ Objects.equals(getSubscriberName(), that.getSubscriberName()) &&
+ Objects.equals(getSubscriberId(), that.getSubscriberId()) &&
+ Objects.equals(getServiceInstanceId(), that.getServiceInstanceId()) &&
+ Objects.equals(getServiceInstanceName(), that.getServiceInstanceName()) &&
+ Objects.equals(getServiceModelId(), that.getServiceModelId()) &&
+ Objects.equals(getServiceModelName(), that.getServiceModelName()) &&
+ Objects.equals(getServiceModelVersion(), that.getServiceModelVersion()) &&
+ Objects.equals(getCreatedBulkDate(), that.getCreatedBulkDate()) &&
+ getAction() == that.getAction();
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(getJobId(), getTemplateId(), getUserId(), getMsoRequestId(), aLaCarte, getJobStatus(),
+ getStatusModifiedDate(), isHidden(), isPause(), isRetryEnabled(), getDeletedAt(), getOwningEntityId(), getOwningEntityName(),
+ getProject(), getAicZoneId(), getAicZoneName(), getTenantId(), getTenantName(), getRegionId(), getRegionName(), getServiceType(),
+ getSubscriberName(), getSubscriberId(), getServiceInstanceId(), getServiceInstanceName(), getServiceModelId(), getServiceModelName(),
+ getServiceModelVersion(), getCreatedBulkDate(), getAction());
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/ServiceModel.java b/vid-app-common/src/main/java/org/onap/vid/model/ServiceModel.java
index c1e403587..121c7e4c1 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/ServiceModel.java
+++ b/vid-app-common/src/main/java/org/onap/vid/model/ServiceModel.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* VID
* ================================================================================
- * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* 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.
@@ -40,14 +40,14 @@ public class ServiceModel {
/** The service. */
private Service service;
-
+
/** The vnfs. */
private Map<String, VNF> vnfs;
-
+
/** The networks. */
private Map<String, Network> networks;
- private Map<String, CR> collectionResource;
+ private Map<String, CR> collectionResources;
/** Port Mirroring Configuration node templates */
private Map<String, PortMirroringConfig> configurations;
@@ -60,12 +60,12 @@ public class ServiceModel {
/**
* The vf modules. The VNF also has vfmodules but the vfmodules at the service level may have additional info
- * that is not present in the VNF, like the vf module customization String
+ * that is not present in the VNF, like the vf module customization String
*/
private Map<String, VfModule> vfModules;
- /**
- * The volume groups. The VNF also has volume groups but the volume groups will be populated at the service level
- * for newer models
+ /**
+ * The volume groups. The VNF also has volume groups but the volume groups will be populated at the service level
+ * for newer models
*/
private Map<String, VolumeGroup> volumeGroups;
@@ -74,12 +74,15 @@ public class ServiceModel {
/** Resource groups of VF (VNF) type. */
private Map<String, ResourceGroup> vnfGroups;
-
+
+ /** The vrfs */
+ private Map<String, Node> vrfs;
+
/**
* Instantiates a new service model.
*/
public ServiceModel() {}
-
+
/**
* Gets the service.
*
@@ -140,6 +143,10 @@ public class ServiceModel {
return vnfGroups;
}
+ public Map<String, Node> getVrfs() {
+ return vrfs;
+ }
+
/**
* Sets the service.
*
@@ -230,12 +237,16 @@ public class ServiceModel {
this.vnfGroups = vnfGroups;
}
- public Map<String, CR> getCollectionResource() {
- return collectionResource;
+ public void setVrfs(Map<String, Node> vrfs) {
+ this.vrfs = vrfs;
}
- public void setCollectionResource(Map<String, CR> collectionResource) {
- this.collectionResource = collectionResource;
+ public Map<String, CR> getCollectionResources() {
+ return collectionResources;
+ }
+
+ public void setCollectionResources(Map<String, CR> collectionResources) {
+ this.collectionResources = collectionResources;
}
public Map<String, Node> getFabricConfigurations() {
@@ -254,9 +265,9 @@ public class ServiceModel {
* @return the service
*/
public static Service extractService(ToscaModel serviceToscaModel, org.onap.vid.asdc.beans.Service asdcServiceMetadata) {
-
+
final Service service = new Service();
-
+
service.setCategory(serviceToscaModel.getMetadata().getCategory());
service.setInvariantUuid(serviceToscaModel.getMetadata().getInvariantUUID());
service.setName(serviceToscaModel.getMetadata().getName());
@@ -274,18 +285,18 @@ public class ServiceModel {
public static void extractGroups (ToscaModel serviceToscaModel,ServiceModel serviceModel) {
// Get the groups. The groups may duplicate the groups that are in the VNF model and have
// additional data like the VF module customization String>
-
+
final Map<String, VfModule> vfModules = new HashMap<> ();
final Map<String, VolumeGroup> volumeGroups = new HashMap<> ();
-
+
String asdcModelNamespace = VidProperties.getAsdcModelNamespace();
- String vfModuleTag = asdcModelNamespace + ModelConstants.VF_MODULE;
-
+ String vfModuleTag = asdcModelNamespace + ModelConstants.VF_MODULE;
+
for (Entry<String, Group> component : serviceToscaModel.gettopology_template().getGroups().entrySet()) {
final Group group = component.getValue();
final String type = group.getType();
final String customizationName = component.getKey();
-
+
if (type.startsWith(vfModuleTag)) {
VfModule vfMod = VfModule.extractVfModule(customizationName, group);
vfModules.put(customizationName, vfMod);
@@ -298,14 +309,14 @@ public class ServiceModel {
// add this point vfModules and volume groups are disconnected from VNF
serviceModel.setVfModules (vfModules);
serviceModel.setVolumeGroups (volumeGroups);
-
+
}
/**
* Populate the vf modules and volume groups that we may have under the service level under each VNF.
*/
public void associateGroups() {
String methodName = "associateGroups()";
- LOG.debug(EELFLoggerDelegate.debugLogger, methodName + " start");
+ LOG.debug(EELFLoggerDelegate.debugLogger, methodName + " start");
// go through the vnfs, get the vnf normalized name and look for a vf module with a customization name that starts
// with vnf + ".."
String vnfCustomizationName = null;
@@ -319,13 +330,13 @@ public class ServiceModel {
LOG.debug(EELFLoggerDelegate.debugLogger, methodName +
" VNF customizationName=" + vnfCustomizationName + "normalized customization name=" + normalizedVnfCustomizationName);
-
+
// now check to see if there is a vf module with customization name that starts with normalizedVnfCustomizationName
if (!MapUtils.isEmpty(getVolumeGroups())) {
for (Entry<String, VfModule> vfModuleComponent : getVfModules().entrySet()) {
vfModuleCustomizationName = vfModuleComponent.getValue().getModelCustomizationName();
-
+
LOG.debug(EELFLoggerDelegate.debugLogger, methodName +
" VF Module customizationName=" + vfModuleCustomizationName );
if ( vfModuleCustomizationName.startsWith(normalizedVnfCustomizationName + ".." )) {
@@ -335,7 +346,7 @@ public class ServiceModel {
}
}
}
-
+
}
@@ -346,14 +357,14 @@ public class ServiceModel {
(tmpVnf.getVfModules()).put(vfModuleComponent.getKey(), vfModuleComponent.getValue());
LOG.debug(EELFLoggerDelegate.debugLogger, methodName +
- " Associated VF Module customizationName=" + vfModuleComponent.getKey() + " with VNF customization name=" + vnfCustomizationName);
+ " Associated VF Module customizationName=" + vfModuleComponent.getKey() + " with VNF customization name=" + vnfCustomizationName);
// now find if this vf module has volume groups, if so, find the volume group with the same customization name and put it under the VNF
if ( vfModuleComponent.getValue().isVolumeGroupAllowed() ) {
if (isVolumeGroupsContainsVfModuleCustomName(vfModuleCustomizationName)) {
- (vnfComponent.getValue().getVolumeGroups()).put(vfModuleCustomizationName, (getVolumeGroups()).get(vfModuleCustomizationName));
- }
- }
+ (vnfComponent.getValue().getVolumeGroups()).put(vfModuleCustomizationName, (getVolumeGroups()).get(vfModuleCustomizationName));
+ }
+ }
}
private boolean isVolumeGroupsContainsVfModuleCustomName(String vfModuleCustomizationName) {
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/VersionAndFeatures.kt b/vid-app-common/src/main/java/org/onap/vid/model/VersionAndFeatures.kt
new file mode 100644
index 000000000..730e382d3
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/VersionAndFeatures.kt
@@ -0,0 +1,12 @@
+package org.onap.vid.model
+
+data class VersionAndFeatures(
+ val features:String,
+ val build:String,
+ val displayVersion:String
+) {
+ companion object {
+ val unknown: VersionAndFeatures = VersionAndFeatures("unknown", "unknown", "unknown")
+ }
+}
+
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/VidNotions.kt b/vid-app-common/src/main/java/org/onap/vid/model/VidNotions.kt
index 7f06bfe2f..f67d8fbd9 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/VidNotions.kt
+++ b/vid-app-common/src/main/java/org/onap/vid/model/VidNotions.kt
@@ -7,9 +7,9 @@
* 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.
@@ -26,7 +26,10 @@ import com.fasterxml.jackson.annotation.JsonValue
import com.google.common.base.CaseFormat
class VidNotions(@get:JsonInclude(JsonInclude.Include.NON_NULL)
- val instantiationUI: InstantiationUI, val modelCategory: ModelCategory, val viewEditUI: InstantiationUI) {
+ val instantiationUI: InstantiationUI,
+ val modelCategory: ModelCategory,
+ val viewEditUI: InstantiationUI,
+ val instantiationType: InstantiationType) {
enum class InstantiationUI {
NETWORK_WITH_PROPERTY_NETWORK_TECHNOLOGY_EQUALS_STANDARD_SRIOV_OR_OVS,
SERVICE_WITH_FABRIC_CONFIGURATION,
@@ -34,7 +37,12 @@ class VidNotions(@get:JsonInclude(JsonInclude.Include.NON_NULL)
SERVICE_UUID_IS_1ffce89f_ef3f_4cbb_8b37_82134590c5de,
ANY_ALACARTE_NEW_UI,
MACRO_SERVICE,
- SERVICE_WITH_VNF_GROUPING;
+ SERVICE_WITH_VNF_GROUPING,
+ TRANSPORT_SERVICE,
+ SERVICE_WITH_COLLECTION_RESOURCE,
+ A_LA_CARTE_VNF_SERVICE_ROLE,
+ INFRASTRUCTURE_VPN
+ ;
@JsonValue
fun toLowerCamel(): String {
@@ -48,7 +56,16 @@ class VidNotions(@get:JsonInclude(JsonInclude.Include.NON_NULL)
IS_5G_PROVIDER_NETWORK_MODEL,
@JsonProperty("5G Fabric Configuration")
IS_5G_FABRIC_CONFIGURATION_MODEL,
+ Transport,
+ SERVICE_WITH_COLLECTION_RESOURCE,
+ INFRASTRUCTURE_VPN,
@JsonProperty("other")
OTHER
}
+
+ enum class InstantiationType {
+ Macro,
+ ALaCarte,
+ ClientConfig
+ }
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/AAITreeNode.java b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/AAITreeNode.java
index 4b16b3122..f092c9ae6 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/AAITreeNode.java
+++ b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/AAITreeNode.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,17 +20,19 @@
package org.onap.vid.model.aaiTree;
+import com.fasterxml.jackson.annotation.JsonIgnore;
import org.apache.commons.lang3.StringUtils;
+import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.RelationshipList;
+import org.onap.vid.mso.model.CloudConfiguration;
import java.util.*;
public class AAITreeNode {
- private String type;
- private int uniqueNumber;
+ private NodeType type;
private String orchestrationStatus;
private String provStatus;
- private Boolean inMaint = null;
+ private boolean inMaint;
private String modelVersionId;
private String modelCustomizationId;
private String modelInvariantId;
@@ -41,25 +43,19 @@ public class AAITreeNode {
private String modelCustomizationName;
private final List<AAITreeNode> children = Collections.synchronizedList(new LinkedList<>());
private Map<String, Object> additionalProperties = new HashMap<>();
+ private CloudConfiguration cloudConfiguration;
+ private RelationshipList relationshipList;
private String keyInModel;
private AAITreeNode parent;
- public String getType() {
+ public NodeType getType() {
return type;
}
- public void setType(String type) {
+ public void setType(NodeType type) {
this.type = type;
}
- public int getUniqueNumber() {
- return uniqueNumber;
- }
-
- public void setUniqueNumber(int uniqueNumber) {
- this.uniqueNumber = uniqueNumber;
- }
-
public String getOrchestrationStatus() {
return orchestrationStatus;
}
@@ -76,11 +72,11 @@ public class AAITreeNode {
this.provStatus = provStatus;
}
- public Boolean getInMaint() {
+ public boolean getInMaint() {
return inMaint;
}
- public void setInMaint(Boolean inMaint) {
+ public void setInMaint(boolean inMaint) {
this.inMaint = inMaint;
}
@@ -169,7 +165,7 @@ public class AAITreeNode {
}
public String getUniqueNodeKey() {
- return getNodeKey() + ":" + String.format("%03d", this.uniqueNumber);
+ return this.id;
}
public void setKeyInModel(String keyInModel) {
@@ -180,6 +176,8 @@ public class AAITreeNode {
return keyInModel;
}
+ //prevent cyclic serialization of parent and children
+ @JsonIgnore
public AAITreeNode getParent() {
return parent;
}
@@ -188,6 +186,22 @@ public class AAITreeNode {
this.parent = parent;
}
+ public CloudConfiguration getCloudConfiguration() {
+ return cloudConfiguration;
+ }
+
+ public void setCloudConfiguration(CloudConfiguration cloudConfiguration) {
+ this.cloudConfiguration = cloudConfiguration;
+ }
+
+ public RelationshipList getRelationshipList() {
+ return relationshipList;
+ }
+
+ public void setRelationshipList(RelationshipList relationshipList) {
+ this.relationshipList = relationshipList;
+ }
+
public void addChildren(List<AAITreeNode> children) {
for (AAITreeNode child : children) {
child.setParent(this);
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/AbstractNode.java b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/AbstractNode.java
index 64e953e17..a0fa60e97 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/AbstractNode.java
+++ b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/AbstractNode.java
@@ -7,9 +7,9 @@
* 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.
@@ -32,6 +32,7 @@ public abstract class AbstractNode {
protected String productFamilyId;
protected String lcpCloudRegionId;
protected String tenantId;
+ protected String cloudOwner;
protected ModelInfo modelInfo;
public AbstractNode() {
@@ -70,4 +71,7 @@ public abstract class AbstractNode {
return modelInfo;
}
+ public String getCloudOwner() {
+ return cloudOwner;
+ }
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/CollectionResource.kt b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/CollectionResource.kt
new file mode 100644
index 000000000..054618dd5
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/CollectionResource.kt
@@ -0,0 +1,15 @@
+package org.onap.vid.model.aaiTree
+
+import org.apache.commons.lang.StringUtils
+
+fun isNfc(node: AAITreeNode): Boolean {
+ return node.type == NodeType.INSTANCE_GROUP &&
+ node.additionalProperties["instance-group-type"] != null &&
+ StringUtils.equalsIgnoreCase(node.additionalProperties["instance-group-type"].toString(), "L3-NETWORK")
+}
+
+class CollectionResource(node: AAITreeNode) : Node(node) {
+
+ val ncfs: Map<String, NCF> = node.children.filter { isNfc(it) }.map { it.uniqueNodeKey to NCF(it) }.toMap()
+
+} \ No newline at end of file
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/InstanceGroup.kt b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/InstanceGroup.kt
new file mode 100644
index 000000000..490853aa1
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/InstanceGroup.kt
@@ -0,0 +1,23 @@
+package org.onap.vid.model.aaiTree
+
+open class InstanceGroup(aaiNode: AAITreeNode) : Node(aaiNode) {
+ var instanceGroupRole: String? = null
+ var instanceGroupFunction: String? = null
+
+ init {
+ val INSTANCE_GROUP_TYPE = "instance-group-type"
+ val INSTANCE_GROUP_ROLE = "instance-group-role"
+ val INSTANCE_GROUP_FUNCTION = "instance-group-function"
+
+ if (aaiNode.additionalProperties[INSTANCE_GROUP_TYPE] != null) {
+ instanceType = aaiNode.additionalProperties[INSTANCE_GROUP_TYPE].toString()
+ }
+ if (aaiNode.additionalProperties[INSTANCE_GROUP_FUNCTION] != null) {
+ instanceGroupFunction = aaiNode.additionalProperties[INSTANCE_GROUP_FUNCTION].toString()
+ }
+ if (aaiNode.additionalProperties[INSTANCE_GROUP_ROLE] != null) {
+ instanceGroupRole = aaiNode.additionalProperties[INSTANCE_GROUP_ROLE].toString()
+ }
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/NCF.kt b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/NCF.kt
new file mode 100644
index 000000000..6d407da4c
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/NCF.kt
@@ -0,0 +1,12 @@
+package org.onap.vid.model.aaiTree
+
+import org.apache.commons.lang.StringUtils
+
+class NCF(node: AAITreeNode) : InstanceGroup(node) {
+ val numberOfNetworks: Int = if (node.relationshipList != null && node.relationshipList.relationship != null) {
+ node.relationshipList.relationship
+ .filter { StringUtils.equalsIgnoreCase(it.relatedTo, "L3-NETWORK") }
+ .count()
+ } else 0
+}
+
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Network.java b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Network.java
index e80e57520..6b3023332 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Network.java
+++ b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Network.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,21 +20,121 @@
package org.onap.vid.model.aaiTree;
-import org.onap.vid.aai.util.AAITreeConverter;
-
+import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;
+import static org.onap.vid.aai.util.AAITreeConverter.NETWORK_ROLE;
import static org.onap.vid.aai.util.AAITreeConverter.NETWORK_TYPE;
+import static org.onap.vid.aai.util.AAITreeConverter.PHYSICAL_NETWORK_NAME;
+import static org.onap.vid.aai.util.AAITreeConverter.SERVICE_INSTANCE;
+import static org.onap.vid.aai.util.AAITreeConverter.SERVICE_INSTANCE_SERVICE_INSTANCE_ID;
+import static org.onap.vid.aai.util.AAITreeConverter.SERVICE_INSTANCE_SERVICE_INSTANCE_NAME;
+import static org.onap.vid.aai.util.AAITreeConverter.TENANT;
+import static org.onap.vid.aai.util.AAITreeConverter.TENANT_TENANT_NAME;
+import static org.onap.vid.aai.util.AAITreeConverter.VPN_BINDING;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import org.apache.commons.collections.CollectionUtils;
+import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.Relationship;
+import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.RelationshipList;
+import org.onap.vid.aai.util.AAITreeNodeUtils;
+@JsonInclude(NON_NULL)
public class Network extends Node {
- public Network(AAITreeNode node) {
- super(node, AAITreeConverter.ModelType.network);
+ private String role;
+ private String physicalName;
+ private String serviceName;
+ private String serviceUUID;
+ private String tenantName;
+ private Boolean isBoundToVpn;
+ private RouteTarget routeTarget;
+
+ public Network(){}
+
+ private Network(AAITreeNode node) {
+ super(node);
+ fillCloudConfigurationProperties(this, node.getCloudConfiguration());
}
public static Network from(AAITreeNode node) {
Network network = new Network(node);
- if (node.getAdditionalProperties().get(NETWORK_TYPE) != null) {
- network.setInstanceType(node.getAdditionalProperties().get(NETWORK_TYPE).toString());
+ network.setInstanceType(readValueAsStringFromAdditionalProperties(node, NETWORK_TYPE));
+ network.setRole(readValueAsStringFromAdditionalProperties(node, NETWORK_ROLE));
+ network.setPhysicalName(readValueAsStringFromAdditionalProperties(node, PHYSICAL_NETWORK_NAME));
+ RelationshipList relationshipList = node.getRelationshipList();
+ Relationship serviceInstanceRelationship = AAITreeNodeUtils.findFirstRelationshipByRelatedTo(relationshipList, SERVICE_INSTANCE).orElse(null);
+ if (serviceInstanceRelationship != null) {
+ network.setServiceName(AAITreeNodeUtils.findFirstValue(serviceInstanceRelationship.getRelatedToPropertyList(), SERVICE_INSTANCE_SERVICE_INSTANCE_NAME).orElse(null));
+ network.setServiceUUID(AAITreeNodeUtils.findFirstValue(serviceInstanceRelationship.getRelationDataList(), SERVICE_INSTANCE_SERVICE_INSTANCE_ID).orElse(null));
}
+ AAITreeNodeUtils.findFirstRelationshipByRelatedTo(relationshipList, TENANT).ifPresent(
+ tenantRelationship -> network.setTenantName(AAITreeNodeUtils.findFirstValue(tenantRelationship.getRelatedToPropertyList(), TENANT_TENANT_NAME).orElse(null))
+ );
+ // We are ignoring "is-bound-to-vpn" parameter from additionalProperties because there is a requirement to define vpn binding presence from by related-to: vpn-binding
+ network.setBoundToVpn(AAITreeNodeUtils.findFirstRelationshipByRelatedTo(relationshipList, VPN_BINDING).isPresent());
+
+ //get the route target
+ node.getChildren().stream()
+ .filter(x->x.getType()== NodeType.VPN_BINDING) // get all VPN_BINDING related to the network
+ .map(x->VpnBindingKt.from(x)) // create VPN_BINDING nodes
+ .filter(x-> CollectionUtils.isNotEmpty(x.getRouteTargets())) // get the RouteTargets that are not empty
+ .findFirst() // get the first one
+ .ifPresent(x->network.setRouteTarget(x.getRouteTargets().get(0))); // If there is a route target - add it to the network
return network;
}
+
+ public String getRole() {
+ return role;
+ }
+
+ public void setRole(String role) {
+ this.role = role;
+ }
+
+ public String getPhysicalName() {
+ return physicalName;
+ }
+
+ public void setPhysicalName(String physicalName) {
+ this.physicalName = physicalName;
+ }
+
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+ public String getServiceUUID() {
+ return serviceUUID;
+ }
+
+ public void setServiceUUID(String serviceUUID) {
+ this.serviceUUID = serviceUUID;
+ }
+
+ public String getTenantName() {
+ return tenantName;
+ }
+
+ public void setTenantName(String tenantName) {
+ this.tenantName = tenantName;
+ }
+
+ public Boolean isBoundToVpn() {
+ return isBoundToVpn;
+ }
+
+ public void setBoundToVpn(Boolean boundToVpn) {
+ isBoundToVpn = boundToVpn;
+ }
+
+ public RouteTarget getRouteTarget() {
+ return routeTarget;
+ }
+
+ public void setRouteTarget(RouteTarget routeTarget) {
+ this.routeTarget = routeTarget;
+ }
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Node.java b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Node.java
index 5ce5eec43..435f70f1a 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Node.java
+++ b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Node.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,9 +20,12 @@
package org.onap.vid.model.aaiTree;
-import org.onap.vid.aai.util.AAITreeConverter;
+import org.onap.vid.mso.model.CloudConfiguration;
import org.onap.vid.mso.model.ModelInfo;
+import java.util.Objects;
+import java.util.UUID;
+
public class Node extends AbstractNode {
private String instanceType;
@@ -38,7 +41,11 @@ public class Node extends AbstractNode {
private final String trackById;
- public Node(AAITreeNode aaiNode, AAITreeConverter.ModelType modelType) {
+ public Node() {
+ trackById = UUID.randomUUID().toString();
+ }
+
+ public Node(AAITreeNode aaiNode) {
super();
this.instanceId = aaiNode.getId();
this.instanceName = aaiNode.getName();
@@ -46,11 +53,13 @@ public class Node extends AbstractNode {
this.provStatus = aaiNode.getProvStatus();
this.inMaint = aaiNode.getInMaint();
this.uuid = aaiNode.getModelVersionId();
- this.originalName = aaiNode.getModelCustomizationName();
+ this.originalName = aaiNode.getKeyInModel();
this.trackById = aaiNode.getUniqueNodeKey();
ModelInfo nodeModelInfo = new ModelInfo();
- nodeModelInfo.setModelType(modelType.name());
+ if (aaiNode.getType() != null) {
+ nodeModelInfo.setModelType(aaiNode.getType().getModelType());
+ }
nodeModelInfo.setModelName(aaiNode.getModelName());
nodeModelInfo.setModelVersion(aaiNode.getModelVersion());
nodeModelInfo.setModelVersionId(aaiNode.getModelVersionId());
@@ -156,4 +165,16 @@ public class Node extends AbstractNode {
public String getTrackById() {
return trackById;
}
+
+ public static void fillCloudConfigurationProperties(AbstractNode that, CloudConfiguration cloudConfiguration) {
+ if (cloudConfiguration !=null) {
+ that.lcpCloudRegionId = cloudConfiguration.getLcpCloudRegionId();
+ that.tenantId = cloudConfiguration.getTenantId();
+ that.cloudOwner = cloudConfiguration.getCloudOwner();
+ }
+ }
+
+ public static String readValueAsStringFromAdditionalProperties(AAITreeNode node, String key) {
+ return Objects.toString(node.getAdditionalProperties().get(key), null);
+ }
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/NodeType.java b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/NodeType.java
new file mode 100644
index 000000000..5e1228f9f
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/NodeType.java
@@ -0,0 +1,82 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.vid.model.aaiTree;
+
+public enum NodeType {
+ SERVICE_INSTANCE("service-instance", "service-instance-id", "service-instance-name", "service"),
+ GENERIC_VNF ("generic-vnf", "vnf-id", "vnf-name", "vnf"),
+ NETWORK ("l3-network", "network-id", "network-name", "network"),
+ FAILURE ("failure_node", NodeType.NONE, NodeType.NONE, NodeType.NONE),
+ COLLECTION_RESOURCE ("collection", "collection-id", "collection-name", "collection"),
+ CONFIGURATION ("configuration", "configuration-id", "configuration-name", "configuration"),
+ PNF ("pnf", "pnf-id", "pnf-name", "pnf"),
+ VF_MODULE ("vf-module", "vf-module-id", "vf-module-name", "vfModule"),
+ INSTANCE_GROUP ("instance-group", "id", "instance-group-name", "instanceGroup"),
+ PORT ("l-interface", "interface-id", "interface-name", "connectionPoint"),
+ VOLUME_GROUP ("volume-group", "volume-group-id", "volume-group-name", "volumeGroup"),
+ VLAN_TAG("vlan-tag", "vlan-tag-id", NodeType.NONE, NodeType.NONE),
+ VPN_BINDING("vpn-binding", "vpn-id", "vpn-name", "vpnBinding"),
+ ;
+
+ private String type;
+ private String id;
+ private String name;
+ private String modelType;
+
+ public static final String NONE = "";
+
+ NodeType(String type, String id, String name, String modelType) {
+ this.type = type;
+ this.id = id;
+ this.name = name;
+ this.modelType = modelType;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getModelType() {
+ return modelType;
+ }
+
+ public static NodeType fromString(String type) {
+ for (NodeType nodeType : NodeType.values()) {
+ if (nodeType.type.equalsIgnoreCase(type)) {
+ return nodeType;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public String toString() {
+ return this.type;
+ }
+} \ No newline at end of file
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/RelatedVnf.java b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/RelatedVnf.java
index 37dc45afd..febd8e0fd 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/RelatedVnf.java
+++ b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/RelatedVnf.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,10 +20,10 @@
package org.onap.vid.model.aaiTree;
-import org.onap.vid.aai.util.AAITreeConverter;
-
import static org.onap.vid.aai.util.AAITreeConverter.VNF_TYPE;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
public class RelatedVnf extends Node {
private String serviceInstanceId;
@@ -55,13 +55,15 @@ public class RelatedVnf extends Node {
}
public RelatedVnf(AAITreeNode node) {
- super(node, AAITreeConverter.ModelType.vnf);
+ super(node);
}
public static RelatedVnf from(AAITreeNode node) {
RelatedVnf vnf = new RelatedVnf(node);
- vnf.setServiceInstanceId(node.getParent().getId());
- vnf.setServiceInstanceName(node.getParent().getName());
+ if (node.getParent() != null && node.getParent().getType() == NodeType.SERVICE_INSTANCE) {
+ vnf.setServiceInstanceId(node.getParent().getId());
+ vnf.setServiceInstanceName(node.getParent().getName());
+ }
if (node.getAdditionalProperties().get(VNF_TYPE) != null) {
vnf.setInstanceType(node.getAdditionalProperties().get(VNF_TYPE).toString());
@@ -69,4 +71,22 @@ public class RelatedVnf extends Node {
return vnf;
}
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this)
+ .append("serviceInstanceId", serviceInstanceId)
+ .append("serviceInstanceName", serviceInstanceName)
+ .append("tenantName", tenantName)
+ .append("action", action)
+ .append("instanceName", instanceName)
+ .append("instanceId", instanceId)
+ .append("orchStatus", orchStatus)
+ .append("productFamilyId", productFamilyId)
+ .append("lcpCloudRegionId", lcpCloudRegionId)
+ .append("tenantId", tenantId)
+ .append("cloudOwner", cloudOwner)
+ .append("modelInfo", modelInfo)
+ .toString();
+ }
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/ServiceInstance.java b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/ServiceInstance.java
index 111e98b25..923be132f 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/ServiceInstance.java
+++ b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/ServiceInstance.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,10 +20,9 @@
package org.onap.vid.model.aaiTree;
-import org.onap.vid.mso.model.ModelInfo;
-
import java.util.HashMap;
import java.util.Map;
+import org.onap.vid.mso.model.ModelInfo;
public class ServiceInstance extends AbstractNode {
@@ -43,13 +42,17 @@ public class ServiceInstance extends AbstractNode {
private Map<String, Vnf> vnfs = new HashMap<>();
private Map<String, Network> networks = new HashMap<>();
+ private Map<String, Vrf> vrfs = new HashMap<>();
+
private Map<String, VnfGroup> vnfGroups = new HashMap<>();
+ private Map<String, CollectionResource> collectionResources = new HashMap<>();
private int validationCounter;
private Map<String, Long> existingVNFCounterMap;
private Map<String, Long> existingNetworksCounterMap;
private Map<String, Long> existingVnfGroupCounterMap;
+ private Map<String, Long> existingVRFCounterMap;
public void setInstanceName(String instanceName) {
this.instanceName = instanceName;
@@ -175,6 +178,14 @@ public class ServiceInstance extends AbstractNode {
this.networks = networks;
}
+ public Map<String, CollectionResource> getCollectionResources() {
+ return collectionResources;
+ }
+
+ public void setCollectionResources(Map<String, CollectionResource> collectionResources) {
+ this.collectionResources = collectionResources;
+ }
+
public Map<String, VnfGroup> getVnfGroups() { return vnfGroups; }
public void setVnfGroups(Map<String, VnfGroup> vnfGroups) { this.vnfGroups = vnfGroups; }
@@ -210,4 +221,20 @@ public class ServiceInstance extends AbstractNode {
public void setExistingVnfGroupCounterMap(Map<String, Long> existingVnfGroupCounterMap) {
this.existingVnfGroupCounterMap = existingVnfGroupCounterMap;
}
+
+ public Map<String, Vrf> getVrfs() {
+ return vrfs;
+ }
+
+ public void setVrfs(Map<String, Vrf> vrfs) {
+ this.vrfs = vrfs;
+ }
+
+ public Map<String, Long> getExistingVRFCounterMap() {
+ return existingVRFCounterMap;
+ }
+
+ public void setExistingVRFCounterMap(Map<String, Long> existingVRFCounterMap) {
+ this.existingVRFCounterMap = existingVRFCounterMap;
+ }
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/VfModule.java b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/VfModule.java
index 2a4c83b2a..0db27eaa4 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/VfModule.java
+++ b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/VfModule.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,8 +20,6 @@
package org.onap.vid.model.aaiTree;
-import org.onap.vid.aai.util.AAITreeConverter;
-
import static org.onap.vid.aai.util.AAITreeConverter.IS_BASE_VF_MODULE;
public class VfModule extends Node {
@@ -30,7 +28,8 @@ public class VfModule extends Node {
private String volumeGroupName;
public VfModule(AAITreeNode node) {
- super(node, AAITreeConverter.ModelType.vfModule);
+ super(node);
+ fillCloudConfigurationProperties(this, node.getCloudConfiguration());
}
public boolean getIsBase() {
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Vnf.java b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Vnf.java
index 03c1508f9..2df5bdcf6 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Vnf.java
+++ b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Vnf.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,21 +20,19 @@
package org.onap.vid.model.aaiTree;
-import org.onap.vid.aai.util.AAITreeConverter;
-import org.onap.vid.services.AAITreeNodeBuilder;
+import static org.onap.vid.aai.util.AAITreeConverter.VNF_TYPE;
import java.util.HashMap;
import java.util.Map;
-import static org.onap.vid.aai.util.AAITreeConverter.VNF_TYPE;
-
public class Vnf extends Node {
private Map<String, Map<String, VfModule>> vfModules = new HashMap<>();
private Map<String, Network> networks = new HashMap<>();
public Vnf(AAITreeNode node) {
- super(node, AAITreeConverter.ModelType.vnf);
+ super(node);
+ fillCloudConfigurationProperties(this, node.getCloudConfiguration());
}
public Map<String, Map<String, VfModule>> getVfModules() {
@@ -60,11 +58,11 @@ public class Vnf extends Node {
}
node.getChildren().forEach(child -> {
- if (child.getType().equals(AAITreeNodeBuilder.VF_MODULE)) {
+ if (child.getType() == NodeType.VF_MODULE) {
vnf.getVfModules().putIfAbsent(child.getNodeKey(), new HashMap<>());
vnf.getVfModules().get(child.getNodeKey())
- .put(child.getUniqueNodeKey(), VfModule.from(child));
- } else if (child.getType().equals(AAITreeNodeBuilder.NETWORK)) {
+ .put(child.getUniqueNodeKey(), VfModule.from(child));
+ } else if (child.getType() == NodeType.NETWORK) {
vnf.getNetworks().put(child.getUniqueNodeKey(), Network.from(child));
}
});
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/VnfGroup.java b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/VnfGroup.java
deleted file mode 100644
index 21e5ca45e..000000000
--- a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/VnfGroup.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * 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.vid.model.aaiTree;
-
-import org.onap.vid.aai.util.AAITreeConverter;
-
-
-public class VnfGroup extends Node {
-
- public static final String INSTANCE_GROUP_TYPE = "instance-group-type";
- public static final String INSTANCE_GROUP_ROLE = "instance-group-role";
- public static final String INSTANCE_GROUP_FUNCTION = "instance-group-function";
-
- private String instanceGroupRole;
- private String instanceGroupFunction;
-
-
- public VnfGroup(AAITreeNode node) {
- super(node, AAITreeConverter.ModelType.instanceGroup);
- }
-
- public static VnfGroup from(AAITreeNode node) {
- VnfGroup vnfGroup = new VnfGroup(node);
- if (node.getAdditionalProperties().get(INSTANCE_GROUP_TYPE) != null) {
- vnfGroup.setInstanceType(node.getAdditionalProperties().get(INSTANCE_GROUP_TYPE).toString());
- }
- if (node.getAdditionalProperties().get(INSTANCE_GROUP_FUNCTION) != null) {
- vnfGroup.setInstanceGroupFunction(node.getAdditionalProperties().get(INSTANCE_GROUP_FUNCTION).toString());
- }
- if (node.getAdditionalProperties().get(INSTANCE_GROUP_ROLE) != null) {
- vnfGroup.setInstanceGroupRole(node.getAdditionalProperties().get(INSTANCE_GROUP_ROLE).toString());
- }
-
- return vnfGroup;
- }
-
- public String getInstanceGroupRole() {
- return instanceGroupRole;
- }
-
- public void setInstanceGroupRole(String instanceGroupRole) {
- this.instanceGroupRole = instanceGroupRole;
- }
-
- public String getInstanceGroupFunction() {
- return instanceGroupFunction;
- }
-
- public void setInstanceGroupFunction(String instanceGroupFunction) {
- this.instanceGroupFunction = instanceGroupFunction;
- }
-
-
-}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/VnfGroup.kt b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/VnfGroup.kt
new file mode 100644
index 000000000..47a6c98be
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/VnfGroup.kt
@@ -0,0 +1,10 @@
+package org.onap.vid.model.aaiTree
+
+class VnfGroup(node: AAITreeNode) : InstanceGroup(node) {
+
+ val vnfs: Map<String, RelatedVnf> = node.children
+ .filter { it.type == NodeType.GENERIC_VNF }
+ .map { it.uniqueNodeKey to RelatedVnf.from(it) }
+ .toMap()
+
+} \ No newline at end of file
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/VpnBinding.kt b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/VpnBinding.kt
new file mode 100644
index 000000000..d43bf26f0
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/VpnBinding.kt
@@ -0,0 +1,50 @@
+package org.onap.vid.model.aaiTree
+
+import com.fasterxml.jackson.annotation.JsonAlias
+import com.fasterxml.jackson.annotation.JsonCreator
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties
+import com.fasterxml.jackson.annotation.JsonInclude
+import com.fasterxml.jackson.core.type.TypeReference
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate
+import org.onap.vid.utils.JACKSON_OBJECT_MAPPER
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+class VpnBinding(aaiNode: AAITreeNode) : Node(aaiNode) {
+ @JsonCreator
+ constructor() : this(AAITreeNode())
+ var region: String? = null
+ var customerId: String? = null
+ var routeTargets: List<RouteTarget>? = null
+}
+
+val LOGGER: EELFLoggerDelegate = EELFLoggerDelegate.getLogger(VpnBinding::class.java)
+
+fun from(node: AAITreeNode): VpnBinding {
+ val vpnBinding = VpnBinding(node)
+ vpnBinding.platformName = Node.readValueAsStringFromAdditionalProperties(node, "vpn-platform")
+ vpnBinding.instanceType = Node.readValueAsStringFromAdditionalProperties(node, "vpn-type")
+ vpnBinding.region = Node.readValueAsStringFromAdditionalProperties(node, "vpn-region")
+ vpnBinding.customerId = Node.readValueAsStringFromAdditionalProperties(node, "customer-vpn-id")
+
+ vpnBinding.routeTargets = try {
+ JACKSON_OBJECT_MAPPER.convertValue(
+ node.additionalProperties.getOrDefault("route-targets", emptyList<RouteTarget>()),
+ object : TypeReference<List<RouteTarget>>() {})
+ } catch (exception: Exception) {
+ LOGGER.error("Failed to parse route-targets of vpn with id:${vpnBinding.instanceId}", exception)
+ listOf(RouteTarget("ParsingFailure", "ParsingFailure"))
+ }
+
+ return vpnBinding
+}
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+data class RouteTarget(
+
+ @JsonAlias("global-route-target")
+ val globalRouteTarget: String? = null,
+
+ @JsonAlias("route-target-role")
+ val routeTargetRole: String? = null
+)
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Vrf.java b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Vrf.java
new file mode 100644
index 000000000..d6ef7ab0e
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Vrf.java
@@ -0,0 +1,65 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.vid.model.aaiTree;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class Vrf extends Node {
+
+ private Map<String, Network> networks = new HashMap<>();
+ private Map<String, VpnBinding> vpns = new HashMap<>();
+
+
+ public Vrf(AAITreeNode node){
+ super(node);
+ }
+
+ public static Vrf from(AAITreeNode node) {
+ Vrf vrf = new Vrf(node);
+
+ node.getChildren().forEach(child -> {
+ if (child.getType() == NodeType.NETWORK) {
+ vrf.getNetworks().put(child.getUniqueNodeKey(), Network.from(child));
+ }
+ if (child.getType() == NodeType.VPN_BINDING) {
+ vrf.getVpns().put(child.getUniqueNodeKey(), VpnBindingKt.from(child));
+ }
+ });
+ return vrf;
+ }
+
+ public Map<String, Network> getNetworks() {
+ return networks;
+ }
+
+ public void setNetworks(Map<String, Network> networks) {
+ this.networks = networks;
+ }
+
+ public Map<String, VpnBinding> getVpns() {
+ return vpns;
+ }
+
+ public void setVpns(Map<String, VpnBinding> vpns) {
+ this.vpns = vpns;
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/errorReport/ReportCreationParameters.java b/vid-app-common/src/main/java/org/onap/vid/model/errorReport/ReportCreationParameters.java
index babbf8906..e7b7fa67d 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/errorReport/ReportCreationParameters.java
+++ b/vid-app-common/src/main/java/org/onap/vid/model/errorReport/ReportCreationParameters.java
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.vid.model.errorReport;
public class ReportCreationParameters {
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/BaseResource.java b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/BaseResource.java
index fe9ebc037..926dc3cdc 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/BaseResource.java
+++ b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/BaseResource.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,25 +20,29 @@
package org.onap.vid.model.serviceInstantiation;
+import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.collect.ImmutableMap;
import org.apache.commons.lang3.StringUtils;
import org.onap.vid.job.JobAdapter;
+import org.onap.vid.job.JobType;
import org.onap.vid.model.Action;
import org.onap.vid.mso.model.ModelInfo;
+import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
public abstract class BaseResource implements JobAdapter.AsyncJobRequest {
- protected final String instanceId;
+ protected String instanceId;
+
protected ModelInfo modelInfo;
protected String instanceName;
- protected final Action action;
+ protected Action action;
protected String lcpCloudRegionId;
@@ -48,13 +52,21 @@ public abstract class BaseResource implements JobAdapter.AsyncJobRequest {
protected boolean rollbackOnFailure;
- private static final Map<String, Action> actionStingToEnumMap = ImmutableMap.of(
- "Delete", Action.Delete,
- "Create", Action.Create,
- "None", Action.None,
- "Update_Delete", Action.Delete,
- "None_Delete", Action.Delete
- );
+ protected String trackById;
+
+ protected Boolean isFailed;
+
+ protected String statusMessage;
+
+ private static final Map<String, Action> actionStingToEnumMap = ImmutableMap.<String, Action>builder()
+ .put("Delete", Action.Delete)
+ .put("Create", Action.Create)
+ .put("None", Action.None)
+ .put("Update_Delete", Action.Delete)
+ .put("None_Delete", Action.Delete)
+ .put("Resume", Action.Resume)
+ .put("Replace", Action.Replace)
+ .build();
protected BaseResource(@JsonProperty("modelInfo") ModelInfo modelInfo,
@@ -65,16 +77,22 @@ public abstract class BaseResource implements JobAdapter.AsyncJobRequest {
@JsonProperty("tenantId") String tenantId,
@JsonProperty("instanceParams") List<Map<String, String>> instanceParams,
@JsonProperty("rollbackOnFailure") boolean rollbackOnFailure,
- @JsonProperty("instanceId") String instanceId) {
+ @JsonProperty("instanceId") String instanceId,
+ @JsonProperty("trackById") String trackById,
+ @JsonProperty("isFailed") Boolean isFailed,
+ @JsonProperty("statusMessage") String statusMessage) {
this.modelInfo = modelInfo;
this.modelInfo.setModelType(getModelType());
this.rollbackOnFailure = rollbackOnFailure;
- this.instanceName = StringUtils.defaultString(instanceName, "");;
+ this.instanceName = StringUtils.defaultString(instanceName, "");
this.action = actionStringToEnum(action);
this.lcpCloudRegionId = StringUtils.isNotEmpty(legacyRegion) ? legacyRegion : lcpCloudRegionId;
this.tenantId = tenantId;
this.instanceParams = instanceParams;
this.instanceId = instanceId;
+ this.trackById = trackById;
+ this.isFailed = isFailed!= null ? isFailed: false;
+ this.statusMessage = statusMessage;
}
private Action actionStringToEnum(String actionAsString) {
@@ -90,7 +108,7 @@ public abstract class BaseResource implements JobAdapter.AsyncJobRequest {
}
public Action getAction() {
- return action;
+ return (action == null ? Action.Create : action);
}
public String getLcpCloudRegionId() {
@@ -105,11 +123,49 @@ public abstract class BaseResource implements JobAdapter.AsyncJobRequest {
return instanceParams == null ? Collections.emptyList() : instanceParams;
}
- public boolean isRollbackOnFailure() { return rollbackOnFailure; }
+ public boolean isRollbackOnFailure() { return rollbackOnFailure; }
public String getInstanceId() {
return instanceId;
}
protected abstract String getModelType();
+
+ public String getTrackById() {
+ return trackById;
+ }
+
+ public void setTrackById(String trackById) {
+ this.trackById = trackById;
+ }
+
+ public Boolean getIsFailed() {
+ return isFailed;
+ }
+
+ public void setIsFailed(Boolean isFailed) {
+ this.isFailed = isFailed;
+ }
+
+ public void setInstanceId(String instanceId) {
+ this.instanceId = instanceId;
+ }
+
+ public void setAction(Action action) {
+ this.action = action;
+ }
+
+ public String getStatusMessage() {
+ return statusMessage;
+ }
+
+ public void setStatusMessage(String statusMessage) {
+ this.statusMessage = statusMessage;
+ }
+
+ @JsonIgnore
+ public abstract Collection<? extends BaseResource> getChildren();
+
+ @JsonIgnore
+ public abstract JobType getJobType();
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/InstanceGroup.java b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/InstanceGroup.java
index 3fda8429b..b945f1327 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/InstanceGroup.java
+++ b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/InstanceGroup.java
@@ -7,9 +7,9 @@
* 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.
@@ -22,21 +22,47 @@ package org.onap.vid.model.serviceInstantiation;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.onap.vid.job.JobAdapter;
+import org.onap.vid.job.JobType;
import org.onap.vid.mso.model.ModelInfo;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+
public class InstanceGroup extends BaseResource implements JobAdapter.AsyncJobRequest {
+ private final Map<String, InstanceGroupMember> vnfGroupMembers;
+
public InstanceGroup(@JsonProperty("modelInfo") ModelInfo modelInfo,
@JsonProperty("instanceName") String instanceName,
@JsonProperty("action") String action,
@JsonProperty("rollbackOnFailure") boolean rollbackOnFailure,
- @JsonProperty("instanceId") String instanceId) {
+ @JsonProperty("instanceId") String instanceId,
+ @JsonProperty("vnfs") Map<String, InstanceGroupMember> vnfGroupMembers,
+ @JsonProperty("trackById") String trackById,
+ @JsonProperty("isFailed") Boolean isFailed,
+ @JsonProperty("statusMessage") String statusMessage) {
- super(modelInfo, instanceName, action, null, null, null, null, rollbackOnFailure, instanceId);
+ super(modelInfo, instanceName, action, null, null, null, null, rollbackOnFailure, instanceId, trackById, isFailed, statusMessage);
+ this.vnfGroupMembers = vnfGroupMembers;
}
@Override
protected String getModelType() {
return "instanceGroup";
}
+
+ @Override
+ public Collection<InstanceGroupMember> getChildren() {
+ return getVnfGroupMembers().values();
+ }
+
+ public Map<String, InstanceGroupMember> getVnfGroupMembers() {
+ return vnfGroupMembers == null ? Collections.emptyMap() : vnfGroupMembers;
+ }
+
+ @Override
+ public JobType getJobType() {
+ return JobType.InstanceGroup;
+ }
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/InstanceGroupMember.java b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/InstanceGroupMember.java
new file mode 100644
index 000000000..7bfaf02b1
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/InstanceGroupMember.java
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.vid.model.serviceInstantiation;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.Collection;
+import java.util.Collections;
+import org.onap.vid.job.JobAdapter;
+import org.onap.vid.job.JobType;
+import org.onap.vid.mso.model.ModelInfo;
+
+public class InstanceGroupMember extends BaseResource implements JobAdapter.AsyncJobRequest{
+
+ public InstanceGroupMember(@JsonProperty("instanceId") String instanceId,
+ @JsonProperty("action") String action,
+ @JsonProperty("trackById") String trackById,
+ @JsonProperty("isFailed") Boolean isFailed,
+ @JsonProperty("statusMessage") String statusMessage) {
+ super(new ModelInfo(), null, action, null, null, null, null, false, instanceId, trackById, isFailed, statusMessage);
+ }
+
+ @Override
+ protected String getModelType() {
+ return "vnf";
+ }
+
+ @Override
+ public Collection<BaseResource> getChildren() {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public JobType getJobType() {
+ return JobType.InstanceGroupMember;
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/Network.java b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/Network.java
index addd7e1ee..797e28a02 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/Network.java
+++ b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/Network.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* VID
* ================================================================================
- * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* 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.
@@ -22,8 +22,11 @@ package org.onap.vid.model.serviceInstantiation;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.onap.vid.job.JobAdapter;
+import org.onap.vid.job.JobType;
import org.onap.vid.mso.model.ModelInfo;
+import java.util.Collection;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -36,19 +39,22 @@ public class Network extends BaseResource implements JobAdapter.AsyncJobRequest
private final String lineOfBusiness;
public Network(@JsonProperty("modelInfo") ModelInfo modelInfo,
- @JsonProperty("productFamilyId") String productFamilyId,
- @JsonProperty("instanceName") String instanceName,
+ @JsonProperty("productFamilyId") String productFamilyId,
+ @JsonProperty("instanceName") String instanceName,
@JsonProperty("action") String action,
- @JsonProperty("platformName") String platformName,
- @JsonProperty("lcpCloudRegionId") String lcpCloudRegionId,
+ @JsonProperty("platformName") String platformName,
+ @JsonProperty("lcpCloudRegionId") String lcpCloudRegionId,
@JsonProperty("legacyRegion") String legacyRegion,
- @JsonProperty("tenantId") String tenantId,
- @JsonProperty("instanceParams") List<Map<String, String>> instanceParams,
- @JsonProperty("lineOfBusinessName") String lineOfBusiness,
- @JsonProperty("rollbackOnFailure") boolean rollbackOnFailure,
- @JsonProperty("instanceId") String instanceId) {
+ @JsonProperty("tenantId") String tenantId,
+ @JsonProperty("instanceParams") List<Map<String, String>> instanceParams,
+ @JsonProperty("lineOfBusinessName") String lineOfBusiness,
+ @JsonProperty("rollbackOnFailure") boolean rollbackOnFailure,
+ @JsonProperty("instanceId") String instanceId,
+ @JsonProperty("trackById") String trackById,
+ @JsonProperty("isFailed") Boolean isFailed,
+ @JsonProperty("statusMessage") String statusMessage) {
- super(modelInfo, instanceName, action, lcpCloudRegionId, legacyRegion, tenantId, instanceParams, rollbackOnFailure, instanceId);
+ super(modelInfo, instanceName, action, lcpCloudRegionId, legacyRegion, tenantId, instanceParams, rollbackOnFailure, instanceId, trackById, isFailed, statusMessage);
this.productFamilyId = productFamilyId;
this.platformName = platformName;
this.lineOfBusiness = lineOfBusiness;
@@ -71,4 +77,14 @@ public class Network extends BaseResource implements JobAdapter.AsyncJobRequest
return "network";
}
+ @Override
+ public Collection<BaseResource> getChildren() {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public JobType getJobType() {
+ return JobType.NetworkInstantiation;
+ }
+
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/ServiceInstantiation.java b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/ServiceInstantiation.java
index 5d963134b..afc8534a1 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/ServiceInstantiation.java
+++ b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/ServiceInstantiation.java
@@ -7,9 +7,9 @@
* 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.
@@ -21,12 +21,18 @@
package org.onap.vid.model.serviceInstantiation;
import com.fasterxml.jackson.annotation.JsonProperty;
+import org.apache.commons.lang3.ObjectUtils;
import org.onap.vid.job.JobAdapter;
+import org.onap.vid.job.JobType;
+import org.onap.vid.model.VidNotions;
import org.onap.vid.mso.model.ModelInfo;
+import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
public class ServiceInstantiation extends BaseResource implements JobAdapter.AsyncJobRequest {
@@ -58,12 +64,15 @@ public class ServiceInstantiation extends BaseResource implements JobAdapter.Asy
private final boolean isPause;
- private final int bulkSize;
+ private int bulkSize;
private final String testApi;
private final boolean isALaCarte;
+ private final VidNotions vidNotions;
+ private Map<String, VrfEntry> vrfs;
+
public ServiceInstantiation(@JsonProperty("modelInfo") ModelInfo modelInfo,
@JsonProperty("owningEntityId") String owningEntityId,
@JsonProperty("owningEntityName") String owningEntityName,
@@ -82,6 +91,7 @@ public class ServiceInstantiation extends BaseResource implements JobAdapter.Asy
@JsonProperty("vnfs") Map<String, Vnf> vnfs,
@JsonProperty("networks") Map<String, Network> networks,
@JsonProperty("vnfGroups") Map<String, InstanceGroup> vnfGroups,
+ @JsonProperty("vrfs") Map<String, VrfEntry> vrfs,
@JsonProperty("instanceParams") List<Map<String, String>> instanceParams,
@JsonProperty("pause") boolean isPause,
@JsonProperty("bulkSize") int bulkSize,
@@ -89,9 +99,12 @@ public class ServiceInstantiation extends BaseResource implements JobAdapter.Asy
@JsonProperty("isALaCarte") boolean isALaCarte,
@JsonProperty("testApi") String testApi,
@JsonProperty("instanceId") String instanceId,
- @JsonProperty("action") String action
- ) {
- super(modelInfo, instanceName, action, lcpCloudRegionId, legacyRegion, tenantId, instanceParams, rollbackOnFailure, instanceId);
+ @JsonProperty("action") String action,
+ @JsonProperty("trackById") String trackById,
+ @JsonProperty("isFailed") Boolean isFailed,
+ @JsonProperty("statusMessage") String statusMessage,
+ @JsonProperty("vidNotions") VidNotions vidNotions) {
+ super(modelInfo, instanceName, action, lcpCloudRegionId, legacyRegion, tenantId, instanceParams, rollbackOnFailure, instanceId, trackById, isFailed, statusMessage);
this.owningEntityId = owningEntityId;
this.owningEntityName = owningEntityName;
this.projectName = projectName;
@@ -105,12 +118,15 @@ public class ServiceInstantiation extends BaseResource implements JobAdapter.Asy
this.vnfs = vnfs;
this.networks = networks;
this.vnfGroups = vnfGroups;
+ this.vrfs = vrfs;
this.isPause = isPause;
this.bulkSize = bulkSize;
this.isALaCarte = isALaCarte;
this.testApi = isALaCarte ? testApi : null;
+ this.vidNotions = vidNotions;
}
+
public String getOwningEntityId() {
return owningEntityId;
}
@@ -152,15 +168,19 @@ public class ServiceInstantiation extends BaseResource implements JobAdapter.Asy
}
public Map<String, Vnf> getVnfs() {
- return vnfs == null ? Collections.emptyMap() : vnfs;
+ return emptyMapIfNull(vnfs);
}
public Map<String, Network> getNetworks() {
- return networks == null ? Collections.emptyMap() : networks;
+ return emptyMapIfNull(networks);
}
public Map<String, InstanceGroup> getVnfGroups() {
- return vnfGroups == null ? Collections.emptyMap() : vnfGroups;
+ return emptyMapIfNull(vnfGroups);
+ }
+
+ public Map<String, VrfEntry> getVrfs() {
+ return emptyMapIfNull(vrfs);
}
public boolean isPause() {
@@ -169,11 +189,24 @@ public class ServiceInstantiation extends BaseResource implements JobAdapter.Asy
public int getBulkSize() { return bulkSize; }
+ public void setBulkSize(int bulkSize) {
+ this.bulkSize = bulkSize;
+ }
+
+ public VidNotions getVidNotions() {
+ return vidNotions;
+ }
+
@Override
protected String getModelType() {
return "service";
}
+ @Override
+ public Collection<BaseResource> getChildren() {
+ return Stream.of(getNetworks().values(), getVnfs().values(), getVnfGroups().values()).flatMap(Collection::stream).collect(Collectors.toList());
+ }
+
@JsonProperty("isALaCarte")
public boolean isALaCarte() {
return isALaCarte;
@@ -183,4 +216,13 @@ public class ServiceInstantiation extends BaseResource implements JobAdapter.Asy
return this.testApi;
}
-}
+ @Override
+ public JobType getJobType() {
+ return JobType.ALaCarteService;
+ }
+
+ private <T> Map<String, T> emptyMapIfNull(Map<String, T> map) {
+ return ObjectUtils.defaultIfNull(map, Collections.emptyMap());
+ }
+
+} \ No newline at end of file
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/VfModule.java b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/VfModule.java
index b56f116cd..97b23af20 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/VfModule.java
+++ b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/VfModule.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* VID
* ================================================================================
- * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* 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.
@@ -23,8 +23,11 @@ package org.onap.vid.model.serviceInstantiation;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.onap.vid.job.JobAdapter;
+import org.onap.vid.job.JobType;
import org.onap.vid.mso.model.ModelInfo;
+import java.util.Collection;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -37,22 +40,25 @@ import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;
public class VfModule extends BaseResource implements JobAdapter.AsyncJobRequest {
@JsonInclude(NON_NULL) private final String volumeGroupInstanceName;
- private boolean usePreload;
+ @JsonInclude(NON_NULL) private Boolean usePreload;
private Map<String, String> supplementaryParams;
public VfModule( @JsonProperty("modelInfo") ModelInfo modelInfo,
- @JsonProperty("instanceName") String instanceName,
- @JsonProperty("volumeGroupName") String volumeGroupInstanceName,
+ @JsonProperty("instanceName") String instanceName,
+ @JsonProperty("volumeGroupName") String volumeGroupInstanceName,
@JsonProperty("action") String action,
- @JsonProperty("lcpCloudRegionId") String lcpCloudRegionId,
- @JsonProperty("legacyRegion") String legacyRegion,
- @JsonProperty("tenantId") String tenantId,
- @JsonProperty("instanceParams") List<Map<String, String>> instanceParams,
- @JsonProperty("supplementaryFileContent") Map<String, String> supplementaryParams,
- @JsonProperty("rollbackOnFailure") boolean rollbackOnFailure,
- @JsonProperty("sdncPreLoad") boolean usePreload,
- @JsonProperty("instanceId") String instanceId) {
- super(modelInfo, instanceName, action, lcpCloudRegionId, legacyRegion, tenantId, instanceParams, rollbackOnFailure, instanceId);
+ @JsonProperty("lcpCloudRegionId") String lcpCloudRegionId,
+ @JsonProperty("legacyRegion") String legacyRegion,
+ @JsonProperty("tenantId") String tenantId,
+ @JsonProperty("instanceParams") List<Map<String, String>> instanceParams,
+ @JsonProperty("supplementaryFileContent") Map<String, String> supplementaryParams,
+ @JsonProperty("rollbackOnFailure") boolean rollbackOnFailure,
+ @JsonProperty("sdncPreLoad") Boolean usePreload,
+ @JsonProperty("instanceId") String instanceId,
+ @JsonProperty("trackById") String trackById,
+ @JsonProperty("isFailed") Boolean isFailed,
+ @JsonProperty("statusMessage") String statusMessage) {
+ super(modelInfo, instanceName, action, lcpCloudRegionId, legacyRegion, tenantId, instanceParams, rollbackOnFailure, instanceId, trackById, isFailed, statusMessage);
this.volumeGroupInstanceName = volumeGroupInstanceName;
this.usePreload = usePreload;
this.supplementaryParams = supplementaryParams;
@@ -62,7 +68,8 @@ public class VfModule extends BaseResource implements JobAdapter.AsyncJobRequest
return volumeGroupInstanceName;
}
- public boolean isUsePreload() {
+ public Boolean isUsePreload() {
+
return usePreload;
}
@@ -75,5 +82,13 @@ public class VfModule extends BaseResource implements JobAdapter.AsyncJobRequest
return "vfModule";
}
+ @Override
+ public Collection<BaseResource> getChildren() {
+ return Collections.emptyList();
+ }
-}
+ @Override
+ public JobType getJobType() {
+ return JobType.VfmoduleInstantiation;
+ }
+} \ No newline at end of file
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/Vnf.java b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/Vnf.java
index 2619533a7..0da3f0695 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/Vnf.java
+++ b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/Vnf.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* VID
* ================================================================================
- * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* 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.
@@ -23,10 +23,12 @@ package org.onap.vid.model.serviceInstantiation;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.onap.vid.job.JobAdapter;
+import org.onap.vid.job.JobType;
import org.onap.vid.mso.model.ModelInfo;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
+
+import static java.util.stream.Collectors.toList;
/**
* The Class VNF.
@@ -42,24 +44,27 @@ public class Vnf extends BaseResource implements JobAdapter.AsyncJobRequest {
private final Map<String, Map<String, VfModule>> vfModules;
public Vnf(@JsonProperty("modelInfo") ModelInfo modelInfo,
- @JsonProperty("productFamilyId") String productFamilyId,
- @JsonProperty("instanceName") String instanceName,
+ @JsonProperty("productFamilyId") String productFamilyId,
+ @JsonProperty("instanceName") String instanceName,
@JsonProperty("action") String action,
- @JsonProperty("platformName") String platformName,
- @JsonProperty("lcpCloudRegionId") String lcpCloudRegionId,
- @JsonProperty("legacyRegion") String legacyRegion,
- @JsonProperty("tenantId") String tenantId,
- @JsonProperty("instanceParams") List<Map<String, String>> instanceParams,
- @JsonProperty("lineOfBusinessName") String lineOfBusiness,
- @JsonProperty("rollbackOnFailure") boolean rollbackOnFailure,
+ @JsonProperty("platformName") String platformName,
+ @JsonProperty("lcpCloudRegionId") String lcpCloudRegionId,
+ @JsonProperty("legacyRegion") String legacyRegion,
+ @JsonProperty("tenantId") String tenantId,
+ @JsonProperty("instanceParams") List<Map<String, String>> instanceParams,
+ @JsonProperty("lineOfBusinessName") String lineOfBusiness,
+ @JsonProperty("rollbackOnFailure") boolean rollbackOnFailure,
@JsonProperty("instanceId") String instanceId,
- @JsonProperty("vfModules") Map<String, Map<String, VfModule>> vfModules) {
+ @JsonProperty("vfModules") Map<String, Map<String, VfModule>> vfModules,
+ @JsonProperty("trackById") String trackById,
+ @JsonProperty("isFailed") Boolean isFailed,
+ @JsonProperty("statusMessage") String statusMessage) {
- super(modelInfo, instanceName, action, lcpCloudRegionId, legacyRegion, tenantId, instanceParams, rollbackOnFailure, instanceId);
+ super(modelInfo, instanceName, action, lcpCloudRegionId, legacyRegion, tenantId, instanceParams, rollbackOnFailure, instanceId, trackById, isFailed, statusMessage);
this.productFamilyId = productFamilyId;
this.platformName = platformName;
this.lineOfBusiness = lineOfBusiness;
- this.vfModules = vfModules;
+ this.vfModules = vfModules==null ? Collections.emptyMap() : vfModules;
}
public String getProductFamilyId() {
@@ -82,4 +87,17 @@ public class Vnf extends BaseResource implements JobAdapter.AsyncJobRequest {
protected String getModelType() {
return "vnf";
}
+
+ @Override
+ public Collection<BaseResource> getChildren() {
+ return getVfModules().values().stream()
+ .filter(Objects::nonNull)
+ .flatMap(x->x.values().stream())
+ .collect(toList());
+ }
+
+ @Override
+ public JobType getJobType() {
+ return JobType.VnfInstantiation;
+ }
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/VrfEntry.kt b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/VrfEntry.kt
new file mode 100644
index 000000000..5c9ac9095
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/VrfEntry.kt
@@ -0,0 +1,6 @@
+package org.onap.vid.model.serviceInstantiation
+
+import org.onap.vid.model.aaiTree.Network
+import org.onap.vid.model.aaiTree.VpnBinding
+
+data class VrfEntry(val networks: Map<String, Network>, val vpns: Map<String, VpnBinding>)
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java
index cc3231582..949fdab70 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java
@@ -21,10 +21,11 @@
package org.onap.vid.mso;
+import java.util.List;
+import java.util.UUID;
import org.onap.vid.changeManagement.RequestDetailsWrapper;
import org.onap.vid.changeManagement.WorkflowRequestDetail;
import org.onap.vid.controller.OperationalEnvironmentController;
-import org.onap.vid.services.ProbeInterface;
import org.onap.vid.model.SOWorkflowList;
import org.onap.vid.model.SoftDeleteRequest;
import org.onap.vid.mso.model.OperationalEnvironmentActivateInfo;
@@ -33,9 +34,7 @@ import org.onap.vid.mso.rest.OperationalEnvironment.OperationEnvironmentRequestD
import org.onap.vid.mso.rest.Request;
import org.onap.vid.mso.rest.RequestDetails;
import org.onap.vid.mso.rest.Task;
-
-import java.util.List;
-import java.util.UUID;
+import org.onap.vid.services.ProbeInterface;
public interface MsoBusinessLogic extends ProbeInterface {
@@ -137,9 +136,5 @@ public interface MsoBusinessLogic extends ProbeInterface {
RequestDetails buildRequestDetailsForSoftDelete(SoftDeleteRequest softDeleteRequest);
- MsoResponseWrapper2 deactivateAndCloudDelete(String serviceInstanceId, String vnfInstanceId, String vfModuleInstanceId, RequestDetails requestDetails);
-
- MsoResponseWrapper2 activateFabricConfiguration(String serviceInstanceId, RequestDetails requestDetails);
-
SOWorkflowList getWorkflowListByModelId(String modelVersionId);
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java
index 4cb495e2f..9146e8f1b 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java
@@ -20,6 +20,24 @@
*/
package org.onap.vid.mso;
+import static com.fasterxml.jackson.module.kotlin.ExtensionsKt.jacksonObjectMapper;
+import static java.util.stream.Collectors.collectingAndThen;
+import static java.util.stream.Collectors.toList;
+import static org.apache.commons.lang.StringUtils.upperCase;
+import static org.onap.vid.changeManagement.ChangeManagementRequest.MsoChangeManagementRequest;
+import static org.onap.vid.controller.MsoController.CONFIGURATION_ID;
+import static org.onap.vid.controller.MsoController.REQUEST_TYPE;
+import static org.onap.vid.controller.MsoController.SVC_INSTANCE_ID;
+import static org.onap.vid.controller.MsoController.VNF_INSTANCE_ID;
+import static org.onap.vid.controller.MsoController.WORKFLOW_ID;
+import static org.onap.vid.mso.MsoProperties.MSO_REST_API_CLOUD_RESOURCES_REQUEST_STATUS;
+import static org.onap.vid.mso.MsoProperties.MSO_REST_API_OPERATIONAL_ENVIRONMENT_ACTIVATE;
+import static org.onap.vid.mso.MsoProperties.MSO_REST_API_OPERATIONAL_ENVIRONMENT_CREATE;
+import static org.onap.vid.mso.MsoProperties.MSO_REST_API_OPERATIONAL_ENVIRONMENT_DEACTIVATE;
+import static org.onap.vid.mso.MsoProperties.MSO_REST_API_WORKFLOW_SPECIFICATIONS;
+import static org.onap.vid.utils.KotlinUtilsKt.JACKSON_OBJECT_MAPPER;
+import static org.onap.vid.utils.Logging.debugRequestDetails;
+
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import com.fasterxml.jackson.databind.DeserializationFeature;
@@ -27,6 +45,18 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import io.joshworks.restclient.http.HttpResponse;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.UUID;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import javax.ws.rs.BadRequestException;
import org.apache.commons.collections4.ListUtils;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.portalsdk.core.util.SystemProperties;
@@ -35,7 +65,6 @@ import org.onap.vid.changeManagement.RequestDetailsWrapper;
import org.onap.vid.changeManagement.WorkflowRequestDetail;
import org.onap.vid.controller.OperationalEnvironmentController;
import org.onap.vid.exceptions.GenericUncheckedException;
-import org.onap.vid.model.RequestReferencesContainer;
import org.onap.vid.model.SOWorkflowList;
import org.onap.vid.model.SoftDeleteRequest;
import org.onap.vid.model.probes.ExternalComponentStatus;
@@ -58,37 +87,6 @@ import org.onap.vid.mso.rest.TaskList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
-import org.togglz.core.manager.FeatureManager;
-
-import javax.ws.rs.BadRequestException;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.UUID;
-import java.util.regex.Pattern;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import static java.util.stream.Collectors.collectingAndThen;
-import static java.util.stream.Collectors.toList;
-import static org.apache.commons.lang.StringUtils.upperCase;
-import static org.onap.vid.changeManagement.ChangeManagementRequest.MsoChangeManagementRequest;
-import static org.onap.vid.controller.MsoController.CONFIGURATION_ID;
-import static org.onap.vid.controller.MsoController.REQUEST_TYPE;
-import static org.onap.vid.controller.MsoController.SVC_INSTANCE_ID;
-import static org.onap.vid.controller.MsoController.VNF_INSTANCE_ID;
-import static org.onap.vid.controller.MsoController.WORKFLOW_ID;
-import static org.onap.vid.mso.MsoProperties.MSO_REST_API_CLOUD_RESOURCES_REQUEST_STATUS;
-import static org.onap.vid.mso.MsoProperties.MSO_REST_API_OPERATIONAL_ENVIRONMENT_ACTIVATE;
-import static org.onap.vid.mso.MsoProperties.MSO_REST_API_OPERATIONAL_ENVIRONMENT_CREATE;
-import static org.onap.vid.mso.MsoProperties.MSO_REST_API_OPERATIONAL_ENVIRONMENT_DEACTIVATE;
-import static org.onap.vid.mso.MsoProperties.MSO_REST_API_WORKFLOW_SPECIFICATIONS;
-import static org.onap.vid.properties.Features.FLAG_UNASSIGN_SERVICE;
-import static org.onap.vid.utils.Logging.debugRequestDetails;
public class MsoBusinessLogicImpl implements MsoBusinessLogic {
@@ -120,12 +118,10 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
* This should be replaced with mso client factory.
*/
private final MsoInterface msoClientInterface;
- FeatureManager featureManager;
@Autowired
- public MsoBusinessLogicImpl(MsoInterface msoClientInterface, FeatureManager featureManager) {
+ public MsoBusinessLogicImpl(MsoInterface msoClientInterface) {
this.msoClientInterface = msoClientInterface;
- this.featureManager = featureManager;
}
public static String validateEndpointPath(String endpointEnvVariable) {
@@ -168,17 +164,19 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
public MsoResponseWrapper createNwInstance(RequestDetails requestDetails, String serviceInstanceId) {
logInvocationInDebug("createNwInstance");
- String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_NETWORK_INSTANCE);
+ String endpoint;
+ endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_NETWORK_INSTANCE);
- String nw_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId);
- return msoClientInterface.createNwInstance(requestDetails, nw_endpoint);
+ String nwEndpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId);
+ return msoClientInterface.createNwInstance(requestDetails, nwEndpoint);
}
@Override
public MsoResponseWrapper createVolumeGroupInstance(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) {
logInvocationInDebug("createVolumeGroupInstance");
- String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VOLUME_GROUP_INSTANCE);
+ String endpoint;
+ endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VOLUME_GROUP_INSTANCE);
String vnfEndpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId);
vnfEndpoint = vnfEndpoint.replaceFirst(VNF_INSTANCE_ID, vnfInstanceId);
@@ -192,10 +190,10 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VF_MODULE_INSTANCE);
- String partial_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId);
- String vf_module_endpoint = partial_endpoint.replaceFirst(VNF_INSTANCE_ID, vnfInstanceId);
+ String partialEndpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId);
+ String vfModuleEndpoint = partialEndpoint.replaceFirst(VNF_INSTANCE_ID, vnfInstanceId);
- return msoClientInterface.createVfModuleInstance(requestDetails, vf_module_endpoint);
+ return msoClientInterface.createVfModuleInstance(requestDetails, vfModuleEndpoint);
}
@Override
@@ -259,19 +257,15 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
logInvocationInDebug("deleteSvcInstance");
String endpoint;
- if (featureManager.isActive(FLAG_UNASSIGN_SERVICE)) {
- endpoint = validateEndpointPath(MsoProperties.MSO_DELETE_OR_UNASSIGN_REST_API_SVC_INSTANCE);
- if (shouldUnassignService(serviceStatus)) {
- logger.debug(EELFLoggerDelegate.debugLogger, "unassign service");
- String svc_endpoint = endpoint + "/" + serviceInstanceId + "/unassign";
- return msoClientInterface.unassignSvcInstance(requestDetails, svc_endpoint);
- }
- } else {
- endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_SVC_INSTANCE);
+ endpoint = validateEndpointPath(MsoProperties.MSO_DELETE_OR_UNASSIGN_REST_API_SVC_INSTANCE);
+ if (shouldUnassignService(serviceStatus)){
+ logger.debug(EELFLoggerDelegate.debugLogger, "unassign service");
+ String svcEndpoint = endpoint + "/" + serviceInstanceId + "/unassign";
+ return msoClientInterface.unassignSvcInstance(requestDetails, svcEndpoint);
}
- String svc_endpoint = endpoint + "/" + serviceInstanceId;
- return msoClientInterface.deleteSvcInstance(requestDetails, svc_endpoint);
+ String svcEndpoint = endpoint + "/" + serviceInstanceId;
+ return msoClientInterface.deleteSvcInstance(requestDetails, svcEndpoint);
}
private boolean shouldUnassignService(String serviceStatus) {
@@ -294,10 +288,10 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
logInvocationInDebug("deleteVfModule");
String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VF_MODULE_INSTANCE);
- String vf__modules_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId).replaceFirst(VNF_INSTANCE_ID, vnfInstanceId);
- String delete_vf_endpoint = vf__modules_endpoint + '/' + vfModuleId;
+ String vfModulesEndpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId).replaceFirst(VNF_INSTANCE_ID, vnfInstanceId);
+ String deleteVfEndpoint = vfModulesEndpoint + '/' + vfModuleId;
- return msoClientInterface.deleteVfModule(requestDetails, delete_vf_endpoint);
+ return msoClientInterface.deleteVfModule(requestDetails, deleteVfEndpoint);
}
@Override
@@ -305,11 +299,11 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
logInvocationInDebug("deleteVolumeGroupInstance");
String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VOLUME_GROUP_INSTANCE);
- String svc_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId);
- String vnfEndpoint = svc_endpoint.replaceFirst(VNF_INSTANCE_ID, vnfInstanceId);
- String delete_volume_group_endpoint = vnfEndpoint + "/" + volumeGroupId;
+ String svcEndpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId);
+ String vnfEndpoint = svcEndpoint.replaceFirst(VNF_INSTANCE_ID, vnfInstanceId);
+ String deleteVolumeGroupEndpoint = vnfEndpoint + "/" + volumeGroupId;
- return msoClientInterface.deleteVolumeGroupInstance(requestDetails, delete_volume_group_endpoint);
+ return msoClientInterface.deleteVolumeGroupInstance(requestDetails, deleteVolumeGroupEndpoint);
}
@Override
@@ -317,10 +311,10 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
logInvocationInDebug("deleteNwInstance");
String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_NETWORK_INSTANCE);
- String svc_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId);
- String delete_nw_endpoint = svc_endpoint + "/" + networkInstanceId;
+ String svcEndpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId);
+ String deleteNwEndpoint = svcEndpoint + "/" + networkInstanceId;
- return msoClientInterface.deleteNwInstance(requestDetails, delete_nw_endpoint);
+ return msoClientInterface.deleteNwInstance(requestDetails, deleteNwEndpoint);
}
@Override
@@ -400,7 +394,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
private List<RequestWrapper> deserializeOrchestrationRequestsJson(String orchestrationRequestsJson) {
logInvocationInDebug("deserializeOrchestrationRequestsJson");
- ObjectMapper mapper = new ObjectMapper();
+ ObjectMapper mapper = jacksonObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.configure(DeserializationFeature.READ_ENUMS_USING_TO_STRING, true);
RequestList requestList;
@@ -423,7 +417,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
String path = p + "?originalRequestId=" + originalRequestId;
RestObject<String> restObjStr = new RestObject<>();
- String str = new String();
+ String str = "";
restObjStr.set(str);
MsoResponseWrapper msoResponseWrapper = msoClientInterface.getManualTasksByRequestId(str, "", path, restObjStr);
@@ -438,9 +432,8 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
private List<Task> deserializeManualTasksJson(String manualTasksJson) {
logInvocationInDebug("deserializeManualTasksJson");
- ObjectMapper mapper = new ObjectMapper();
try {
- TaskList taskList = mapper.readValue(manualTasksJson, TaskList.class);
+ TaskList taskList = JACKSON_OBJECT_MAPPER.readValue(manualTasksJson, TaskList.class);
return taskList.getTaskList();
} catch (IOException e) {
throw new GenericUncheckedException(e);
@@ -457,7 +450,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
String path = p + "/" + taskId + "/complete";
RestObject<String> restObjStr = new RestObject<>();
- String str = new String();
+ String str = "";
restObjStr.set(str);
return msoClientInterface.completeManualTask(requestDetails, str, "", path, restObjStr);
@@ -561,9 +554,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
requestInfo.setRequestorId(softDeleteRequest.getUserId());
requestDetails.setRequestInfo(requestInfo);
- CloudConfiguration cloudConfiguration = new CloudConfiguration();
- cloudConfiguration.setTenantId(softDeleteRequest.getTenantId());
- cloudConfiguration.setLcpCloudRegionId(softDeleteRequest.getLcpCloudRegionId());
+ CloudConfiguration cloudConfiguration = new CloudConfiguration(softDeleteRequest.getLcpCloudRegionId(), softDeleteRequest.getTenantId(), null);
requestDetails.setCloudConfiguration(cloudConfiguration);
ModelInfo modelInfo = new ModelInfo();
@@ -578,18 +569,6 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
}
@Override
- public MsoResponseWrapper2 deactivateAndCloudDelete(String serviceInstanceId, String vnfInstanceId, String vfModuleInstanceId, RequestDetails requestDetails) {
- String path = getDeactivateAndCloudDeletePath(serviceInstanceId, vnfInstanceId, vfModuleInstanceId);
- return new MsoResponseWrapper2<>(msoClientInterface.post(path, requestDetails, RequestReferencesContainer.class));
- }
-
- @Override
- public MsoResponseWrapper2 activateFabricConfiguration(String serviceInstanceId, RequestDetails requestDetails) {
- String path = getActivateFabricConfigurationPath(serviceInstanceId);
- return new MsoResponseWrapper2<>(msoClientInterface.post(path, requestDetails, RequestReferencesContainer.class));
- }
-
- @Override
public SOWorkflowList getWorkflowListByModelId(String modelVersionId) {
logInvocationInDebug("getWorkflowListByModelId");
String pathTemplate = validateEndpointPath(MSO_REST_API_WORKFLOW_SPECIFICATIONS);
@@ -634,7 +613,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
}
Object payloadRaw = requestDetails.getRequestParameters().getAdditionalProperties().get("payload");
try {
- return objectMapper.readValue((String) payloadRaw, Map.class);
+ return JACKSON_OBJECT_MAPPER.readValue((String) payloadRaw, Map.class);
} catch (Exception exception) {
throw new BadRequestException(message);
}
@@ -912,7 +891,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
}
}
- enum RequestType {
+ public enum RequestType {
CREATE_INSTANCE("createInstance"),
DELETE_INSTANCE("deleteInstance"),
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoUtil.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoUtil.java
index 562182a3c..fcc20fafd 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/MsoUtil.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoUtil.java
@@ -21,15 +21,20 @@
package org.onap.vid.mso;
+import static org.onap.vid.utils.KotlinUtilsKt.JACKSON_OBJECT_MAPPER;
+
+import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.joshworks.restclient.http.HttpResponse;
+import java.io.IOException;
+import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
-
+import org.onap.vid.exceptions.GenericUncheckedException;
public class MsoUtil {
- final static ObjectMapper objectMapper = new ObjectMapper();
+ static final ObjectMapper objectMapper = new ObjectMapper();
private MsoUtil() {
}
@@ -48,12 +53,30 @@ public class MsoUtil {
T body = httpResponse.getBody();
String entityStr = body instanceof String ? (String) body : objectMapper.writeValueAsString(httpResponse.getBody());
msoResponseWrapper.setEntity(entityStr);
- }
- catch(JsonProcessingException e)
- {
+ } catch(JsonProcessingException e) {
ExceptionUtils.rethrow(e);
}
}
return msoResponseWrapper;
}
+
+ public static String formatExceptionAdditionalInfo(int statusCode, String msoResponse) {
+ String errorMsg = "Http Code:" + statusCode;
+ if (!StringUtils.isEmpty(msoResponse)) {
+ String filteredJson;
+ try {
+ filteredJson = StringUtils.defaultIfEmpty(
+ JACKSON_OBJECT_MAPPER.readTree(msoResponse).path("serviceException").toString().replaceAll("[\\{\\}]","") ,
+ msoResponse
+ );
+ } catch (JsonParseException e) {
+ filteredJson = msoResponse;
+ } catch (IOException e) {
+ throw new GenericUncheckedException(e);
+ }
+
+ errorMsg = errorMsg + ", " + filteredJson;
+ }
+ return errorMsg;
+ }
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/model/AddOrRemoveInstanceGroupMemberRequestDetails.java b/vid-app-common/src/main/java/org/onap/vid/mso/model/AddOrRemoveInstanceGroupMemberRequestDetails.java
new file mode 100644
index 000000000..f6b8a4241
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/model/AddOrRemoveInstanceGroupMemberRequestDetails.java
@@ -0,0 +1,51 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.vid.mso.model;
+
+import java.util.List;
+
+/*
+Based on this model:
+{
+ "requestDetails": {
+ "requestInfo": {
+ "source": "VID",
+ "requestorId": "az2016"
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "{the to be removed/added as member vnf-id}",
+ "modelInfo": {
+ "modelType": "vnf"
+ }
+ }
+ }
+ ]
+ }
+}
+*/
+
+public class AddOrRemoveInstanceGroupMemberRequestDetails extends BaseResourceInstantiationRequestDetails {
+ public AddOrRemoveInstanceGroupMemberRequestDetails(RequestInfo requestInfo, List<RelatedInstance> relatedInstanceList) {
+ super(null, null, requestInfo, null, null, relatedInstanceList, null);
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/model/BaseResourceInstantiationRequestDetails.java b/vid-app-common/src/main/java/org/onap/vid/mso/model/BaseResourceInstantiationRequestDetails.java
index c6eb53832..43f5b0070 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/model/BaseResourceInstantiationRequestDetails.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/model/BaseResourceInstantiationRequestDetails.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,15 +20,15 @@
package org.onap.vid.mso.model;
+import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_EMPTY;
+import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;
+
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeName;
-
import java.util.List;
-import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;
-
@JsonInclude(NON_NULL)
public class BaseResourceInstantiationRequestDetails {
@@ -83,21 +83,21 @@ public class BaseResourceInstantiationRequestDetails {
this.requestParameters = requestParameters;
}
- public static class RequestInfo {
+ public static class RequestInfo {
- @JsonInclude(NON_NULL) public final String instanceName;
- @JsonInclude(NON_NULL) public final String productFamilyId;
+ @JsonInclude(NON_EMPTY) public final String instanceName;
+ @JsonInclude(NON_EMPTY) public final String productFamilyId;
public final String source;
- public final boolean suppressRollback;
+ @JsonInclude(NON_NULL) public final Boolean suppressRollback;
public final String requestorId;
- public RequestInfo(String instanceName, String productFamilyId, String source, boolean rollbackOnFailure, String requestorId) {
+ public RequestInfo(String instanceName, String productFamilyId, String source, Boolean rollbackOnFailure, String requestorId) {
this.instanceName = instanceName;
this.productFamilyId = productFamilyId;
this.source = source;
this.requestorId = requestorId;
// in the FE we are asking for "RollbackOnFailure" but to MSO we are passing the negative value "suppressRollback"
- this.suppressRollback = !rollbackOnFailure;
+ this.suppressRollback = rollbackOnFailure != null ? (!rollbackOnFailure) : null;
}
}
@@ -120,9 +120,13 @@ public class BaseResourceInstantiationRequestDetails {
public static class LineOfBusiness{
public final String lineOfBusinessName;
- public LineOfBusiness(String lineOfBusiness) {
+ private LineOfBusiness(String lineOfBusiness) {
this.lineOfBusinessName = lineOfBusiness;
}
+
+ public static LineOfBusiness of(String lineOfBusiness) {
+ return lineOfBusiness==null ? null : new LineOfBusiness(lineOfBusiness);
+ }
}
@JsonTypeName("relatedInstance")
@@ -150,13 +154,18 @@ public class BaseResourceInstantiationRequestDetails {
public static class RequestParameters {
public final List<? extends UserParamTypes> userParams;
- public RequestParameters(List<? extends UserParamTypes> userParams) {
+ @JsonInclude(NON_NULL) public final String testApi;
+ public RequestParameters(List<? extends UserParamTypes> userParams, String testApi) {
this.userParams = userParams;
+ this.testApi = testApi;
}
public List<? extends UserParamTypes> getUserParams() {
return userParams;
}
+ public String getTestApi() {
+ return testApi;
+ }
}
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/model/CloudConfiguration.java b/vid-app-common/src/main/java/org/onap/vid/mso/model/CloudConfiguration.java
deleted file mode 100644
index 2e0991755..000000000
--- a/vid-app-common/src/main/java/org/onap/vid/mso/model/CloudConfiguration.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * 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.vid.mso.model;
-
-import com.fasterxml.jackson.annotation.*;
-import org.apache.commons.lang.builder.EqualsBuilder;
-import org.apache.commons.lang.builder.HashCodeBuilder;
-import org.apache.commons.lang.builder.ToStringBuilder;
-
-import java.util.HashMap;
-import java.util.Map;
-
-
-/**
- * fields communicating the cloud configuration in a standard way
- *
- */
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonPropertyOrder({
- "nodeLocation",
- "lcpCloudRegionId",
- "tenantId",
- "cloudOwner"
-})
-public class CloudConfiguration {
-
- /**
- * Location identifier for the node
- *
- */
- @JsonProperty("nodeLocation")
- private String nodeLocation;
- /**
- * LCP Node Location identifier
- *
- */
- @JsonProperty("lcpCloudRegionId")
- private String lcpCloudRegionId;
- /**
- * Openstack tenant id
- *
- */
- @JsonProperty("tenantId")
- private String tenantId;
- /**
- * the cloud owner
- *
- */
- @JsonProperty("cloudOwner")
- private String cloudOwner;
- @JsonIgnore
- private Map<String, Object> additionalProperties = new HashMap<>();
-
- /**
- * Location identifier for the node
- *
- * @return
- * The nodeLocation
- */
- @JsonProperty("nodeLocation")
- public String getNodeLocation() {
- return nodeLocation;
- }
-
- /**
- * Location identifier for the node
- *
- * @param nodeLocation
- * The nodeLocation
- */
- @JsonProperty("nodeLocation")
- public void setNodeLocation(String nodeLocation) {
- this.nodeLocation = nodeLocation;
- }
-
- /**
- * LCP Node Location identifier
- *
- * @return
- * The lcpCloudRegionId
- */
- @JsonProperty("lcpCloudRegionId")
- public String getLcpCloudRegionId() {
- return lcpCloudRegionId;
- }
-
- /**
- * LCP Node Location identifier
- *
- * @param lcpCloudRegionId
- * The lcpCloudRegionId
- */
- @JsonProperty("lcpCloudRegionId")
- public void setLcpCloudRegionId(String lcpCloudRegionId) {
- this.lcpCloudRegionId = lcpCloudRegionId;
- }
-
- /**
- * Openstack tenant id
- *
- * @return
- * The tenantId
- */
- @JsonProperty("tenantId")
- public String getTenantId() {
- return tenantId;
- }
-
- /**
- * Openstack tenant id
- *
- * @param tenantId
- * The tenantId
- */
- @JsonProperty("tenantId")
- public void setTenantId(String tenantId) {
- this.tenantId = tenantId;
- }
-
- /**
- * the cloud owner
- *
- * @return
- * The cloudOwner
- */
- @JsonProperty("cloudOwner")
- public String getCloudOwner() {
- return cloudOwner;
- }
-
- /**
- * the cloud owner
- *
- * @param cloudOwner
- * The cloudOwner
- */
- @JsonProperty("cloudOwner")
- public void setCloudOwner(String cloudOwner) {
- this.cloudOwner = cloudOwner;
- }
-
- @Override
- public String toString() {
- return ToStringBuilder.reflectionToString(this);
- }
-
- @JsonAnyGetter
- public Map<String, Object> getAdditionalProperties() {
- return this.additionalProperties;
- }
-
- @JsonAnySetter
- public void setAdditionalProperty(String name, Object value) {
- this.additionalProperties.put(name, value);
- }
-
- @Override
- public int hashCode() {
- return new HashCodeBuilder().append(nodeLocation).append(lcpCloudRegionId).append(tenantId).append(cloudOwner).append(additionalProperties).toHashCode();
- }
-
- @Override
- public boolean equals(Object other) {
- if (other == this) {
- return true;
- }
- if (!(other instanceof CloudConfiguration)) {
- return false;
- }
- CloudConfiguration rhs = ((CloudConfiguration) other);
- return new EqualsBuilder().append(nodeLocation, rhs.nodeLocation).append(lcpCloudRegionId, rhs.lcpCloudRegionId).append(tenantId, rhs.tenantId).append(cloudOwner, rhs.cloudOwner).append(additionalProperties, rhs.additionalProperties).isEquals();
- }
-
-}
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/model/CloudConfiguration.kt b/vid-app-common/src/main/java/org/onap/vid/mso/model/CloudConfiguration.kt
new file mode 100644
index 000000000..d603e5b87
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/model/CloudConfiguration.kt
@@ -0,0 +1,12 @@
+package org.onap.vid.mso.model
+
+import com.fasterxml.jackson.annotation.JsonInclude
+
+@JsonInclude(JsonInclude.Include.NON_EMPTY)
+//tenantId and might be null for supporting create configuration API (port mirroring)
+//cloudOwner might because MSO enable it and it might be used in some flows (default value in MSO "irma-aic")
+data class CloudConfiguration @JvmOverloads constructor(
+ var lcpCloudRegionId: String? = null,
+ var tenantId:String? = null,
+ var cloudOwner: String? = null
+) \ No newline at end of file
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/model/ServiceInstantiationPre1806RequestDetails.java b/vid-app-common/src/main/java/org/onap/vid/mso/model/ServiceInstantiationPre1806RequestDetails.java
new file mode 100644
index 000000000..effc10a08
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/model/ServiceInstantiationPre1806RequestDetails.java
@@ -0,0 +1,51 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.vid.mso.model;
+
+import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_EMPTY;
+import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;
+import static org.onap.vid.mso.model.BaseResourceInstantiationRequestDetails.RelatedInstance;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import java.util.List;
+import org.apache.commons.lang3.StringUtils;
+import org.onap.vid.mso.rest.SubscriberInfo;
+
+public class ServiceInstantiationPre1806RequestDetails extends ServiceInstantiationRequestDetails {
+
+ @JsonInclude(NON_NULL)
+ public final CloudConfiguration cloudConfiguration;
+ @JsonInclude(NON_EMPTY)
+ public final List<RelatedInstance> relatedInstanceList;
+
+ public ServiceInstantiationPre1806RequestDetails(ModelInfo modelInfo, ServiceInstantiationOwningEntity owningEntity,
+ SubscriberInfo subscriberInfo, Project project, RequestInfo requestInfo,
+ RequestParameters requestParameters, CloudConfiguration cloudConfiguration,
+ List<RelatedInstance> relatedInstanceList) {
+ super(modelInfo, owningEntity, subscriberInfo, project, requestInfo, requestParameters);
+ if ((cloudConfiguration != null) && (!StringUtils.isEmpty(cloudConfiguration.getLcpCloudRegionId())) && (!StringUtils.isEmpty(cloudConfiguration.getTenantId()))){
+ this.cloudConfiguration = cloudConfiguration;
+ } else {
+ this.cloudConfiguration = null;
+ }
+ this.relatedInstanceList = relatedInstanceList;
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/model/ServiceInstantiationRequestDetails.java b/vid-app-common/src/main/java/org/onap/vid/mso/model/ServiceInstantiationRequestDetails.java
index 700f43857..8f8dd681a 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/model/ServiceInstantiationRequestDetails.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/model/ServiceInstantiationRequestDetails.java
@@ -76,8 +76,8 @@ public class ServiceInstantiationRequestDetails {
public static class RequestInfo {
- @JsonInclude(NON_NULL) public final String instanceName;
- @JsonInclude(NON_NULL) public final String productFamilyId;
+ @JsonInclude(NON_EMPTY) public final String instanceName;
+ @JsonInclude(NON_EMPTY) public final String productFamilyId;
public final String source;
public final boolean suppressRollback;
public final String requestorId;
@@ -150,7 +150,7 @@ public class ServiceInstantiationRequestDetails {
private static class ServiceInstantiationServiceInner implements UserParamTypes {
public ModelInfo modelInfo = new ModelInfo();
- @JsonInclude(NON_NULL)
+ @JsonInclude(NON_EMPTY)
public String instanceName;
public List<Map<String, String>> instanceParams;
public ServiceInstantiationVnfList resources;
@@ -182,7 +182,7 @@ public class ServiceInstantiationRequestDetails {
public final String productFamilyId;
public final List<Map<String, String>> instanceParams;
@JsonInclude(NON_EMPTY) public final List<VfModuleMacro> vfModules;
- @JsonInclude(NON_NULL) public final String instanceName;
+ @JsonInclude(NON_EMPTY) public final String instanceName;
public ServiceInstantiationVnf(ModelInfo modelInfo, CloudConfiguration cloudConfiguration, String platform, String lineOfBusiness, String productFamilyId, List<Map<String, String>> instanceParams, List<VfModuleMacro> vfModules, String instanceName) {
this.modelInfo = modelInfo;
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/model/VfModuleInstantiationRequestDetails.java b/vid-app-common/src/main/java/org/onap/vid/mso/model/VfModuleInstantiationRequestDetails.java
index 4e6f074c2..3b6cd1d3d 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/model/VfModuleInstantiationRequestDetails.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/model/VfModuleInstantiationRequestDetails.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,8 +20,10 @@
package org.onap.vid.mso.model;
-import com.fasterxml.jackson.annotation.JsonProperty;
+import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -109,14 +111,14 @@ public class VfModuleInstantiationRequestDetails extends BaseResourceInstantiati
}
public static class RequestParametersVfModule extends BaseResourceInstantiationRequestDetails.RequestParameters {
- private final boolean usePreload;
+ @JsonInclude(NON_NULL) private final Boolean usePreload;
- public RequestParametersVfModule(List<? extends UserParamTypes> userParams, boolean usePreload) {
- super(userParams);
+ public RequestParametersVfModule(List<? extends UserParamTypes> userParams, Boolean usePreload, String testApi) {
+ super(userParams, testApi);
this.usePreload = usePreload;
}
- public boolean isUsePreload() {
+ public Boolean isUsePreload() {
return usePreload;
}
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/AsyncRequestStatus.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/AsyncRequestStatus.java
index 12bf20549..61e0d3af6 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/rest/AsyncRequestStatus.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/AsyncRequestStatus.java
@@ -7,9 +7,9 @@
* 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.
@@ -53,6 +53,7 @@ public class AsyncRequestStatus {
public String requestId;
public String requestScope;
+ public String requestType;
/**
* The instance ids.
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestStatus.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestStatus.java
index 031eaec23..29356aa4d 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestStatus.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestStatus.java
@@ -43,6 +43,14 @@ import java.util.Map;
})
public class RequestStatus {
+ public RequestStatus() {}
+
+ public RequestStatus(String requestState, String statusMessage, String timestamp) {
+ this.requestState = requestState;
+ this.statusMessage = statusMessage;
+ this.timestamp = timestamp;
+ }
+
/**
* percentage complete estimate from 0 to 100
*
diff --git a/vid-app-common/src/main/java/org/onap/vid/properties/Features.java b/vid-app-common/src/main/java/org/onap/vid/properties/Features.java
index ea047d698..c96efe6f5 100644
--- a/vid-app-common/src/main/java/org/onap/vid/properties/Features.java
+++ b/vid-app-common/src/main/java/org/onap/vid/properties/Features.java
@@ -29,22 +29,17 @@ public enum Features implements Feature {
* Use /docs/feature-flags.md for details
*/
- FLAG_ASYNC_JOBS,
CREATE_INSTANCE_TEST,
EMPTY_DRAWING_BOARD_TEST,
FLAG_ADD_MSO_TESTAPI_FIELD,
- FLAG_ASYNC_INSTANTIATION,
FLAG_SERVICE_MODEL_CACHE,
- FLAG_UNASSIGN_SERVICE,
FLAG_NETWORK_TO_ASYNC_INSTANTIATION,
- FLAG_COLLECTION_RESOURCE_SUPPORT,
FLAG_SHOW_ASSIGNMENTS,
+ FLAG_UNASSIGN_SERVICE,
FLAG_FABRIC_CONFIGURATION_ASSIGNMENTS,
FLAG_SHOW_VERIFY_SERVICE, // AKA POMBA
- FLAG_DUPLICATE_VNF,
FLAG_DEFAULT_VNF,
FLAG_SETTING_DEFAULTS_IN_DRAWING_BOARD,
- FLAG_PNP_INSTANTIATION,
FLAG_RESTRICTED_SELECT,
FLAG_5G_IN_NEW_INSTANTIATION_UI,
FLAG_ASYNC_ALACARTE_VNF,
@@ -52,7 +47,6 @@ public enum Features implements Feature {
FLAG_PRESENT_PROVIDER_NETWORKS_ASSOCIATIONS,
FLAG_ASYNC_ALACARTE_VFMODULE,
FLAG_SUPPLEMENTARY_FILE,
- FLAG_SHIFT_VFMODULE_PARAMS_TO_VNF,
FLAG_EXP_ANY_ALACARTE_NEW_INSTANTIATION_UI,
FLAG_1810_CR_LET_SELECTING_COLLECTOR_TYPE_UNCONDITIONALLY,
FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST,
@@ -62,10 +56,25 @@ public enum Features implements Feature {
FLAG_1902_NEW_VIEW_EDIT,
FLAG_EXP_USE_DEFAULT_HOST_NAME_VERIFIER,
FLAG_1902_VNF_GROUPING,
+ FLAG_1902_RETRY_JOB,
+ FLAG_VF_MODULE_RESUME_STATUS_CREATE,
+ FLAG_EXP_CREATE_RESOURCES_IN_PARALLEL,
+ FLAG_1906_COMPONENT_INFO,
+ FLAG_1906_INSTANTIATION_API_USER_VALIDATION,
+ FLAG_1906_AAI_SUB_DETAILS_REDUCE_DEPTH,
+ FLAG_1908_TRANSPORT_SERVICE_NEW_INSTANTIATION_UI,
+ FLAG_1908_COLLECTION_RESOURCE_NEW_INSTANTIATION_UI,
+ FLAG_1908_INFRASTRUCTURE_VPN,
+ FLAG_1908_RESUME_MACRO_SERVICE,
+ FLAG_1908_RELEASE_TENANT_ISOLATION,
+ FLAG_1908_A_LA_CARTE_VNF_NEW_INSTANTIATION_UI,
+ FLAG_FLASH_REPLACE_VF_MODULE,
+ FLAG_PNP_INSTANTIATION,
FLAG_HANDLE_SO_WORKFLOWS,
FLAG_CREATE_ERROR_REPORTS
;
+
public boolean isActive() {
return FeatureContext.getFeatureManager().isActive(this);
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/properties/VidProperties.java b/vid-app-common/src/main/java/org/onap/vid/properties/VidProperties.java
index 24b72fdff..8331886c0 100644
--- a/vid-app-common/src/main/java/org/onap/vid/properties/VidProperties.java
+++ b/vid-app-common/src/main/java/org/onap/vid/properties/VidProperties.java
@@ -7,9 +7,9 @@
* 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.
@@ -21,9 +21,9 @@
package org.onap.vid.properties;
import org.apache.commons.lang3.StringUtils;
+import org.onap.vid.model.ModelConstants;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.portalsdk.core.util.SystemProperties;
-import org.onap.vid.model.ModelConstants;
/**
* The Class VidProperties.
*/
@@ -38,59 +38,62 @@ public class VidProperties extends SystemProperties {
/** The Constant VID_TRUSTSTORE_FILENAME. */
public static final String VID_TRUSTSTORE_FILENAME = "vid.truststore.filename";
-
+
/** The Constant VID_TRUSTSTORE_PASSWD_X. */
public static final String VID_TRUSTSTORE_PASSWD_X = "vid.truststore.passwd.x";
-
+
/** The Constant FILESEPARATOR. */
public static final String FILESEPARATOR = (System.getProperty("file.separator") == null) ? "/" : System.getProperty("file.separator");
-
+
/** The Constant LOG. */
private static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(VidProperties.class);
- public static final String VID_JOB_MAX_HOURS_IN_PROGRESS = "vid.asyncJob.maxHoursInProgress";
+ public static final String VID_JOB_MAX_HOURS_IN_PROGRESS = "vid.asyncJob.maxHoursInProgress";
+
+ public static final String VID_THREAD_COUNT = "vid.thread.count";
+ public static final String VID_THREAD_TIMEOUT = "vid.thread.timeout";
/**
* Gets the asdc model namespace prefix property
- *
+ *
* @return the property value or a default value
*/
public static String getAsdcModelNamespace() {
String methodName = "getAsdcModelNamespace ";
String asdcModelNamespace = ModelConstants.DEFAULT_ASDC_MODEL_NAMESPACE;
- try {
- asdcModelNamespace = SystemProperties.getProperty(ModelConstants.ASDC_MODEL_NAMESPACE);
- if ( asdcModelNamespace == null || asdcModelNamespace.isEmpty()) {
- asdcModelNamespace = ModelConstants.DEFAULT_ASDC_MODEL_NAMESPACE;
- }
- }
- catch ( Exception e ) {
- LOG.error (EELFLoggerDelegate.errorLogger, methodName + "unable to find the value, using the default "
- + ModelConstants.DEFAULT_ASDC_MODEL_NAMESPACE);
- asdcModelNamespace = ModelConstants.DEFAULT_ASDC_MODEL_NAMESPACE;
- }
- return (asdcModelNamespace);
+ try {
+ asdcModelNamespace = SystemProperties.getProperty(ModelConstants.ASDC_MODEL_NAMESPACE);
+ if ( asdcModelNamespace == null || asdcModelNamespace.isEmpty()) {
+ asdcModelNamespace = ModelConstants.DEFAULT_ASDC_MODEL_NAMESPACE;
+ }
+ }
+ catch ( Exception e ) {
+ LOG.error (EELFLoggerDelegate.errorLogger, methodName + "unable to find the value, using the default "
+ + ModelConstants.DEFAULT_ASDC_MODEL_NAMESPACE);
+ asdcModelNamespace = ModelConstants.DEFAULT_ASDC_MODEL_NAMESPACE;
+ }
+ return (asdcModelNamespace);
}
/**
* Gets the specified property value. If the property is not defined, returns a default value.
- *
+ *
* @return the property value or a default value
*/
public static String getPropertyWithDefault ( String propName, String defaultValue ) {
String methodName = "getPropertyWithDefault ";
String propValue = defaultValue;
- try {
- propValue = SystemProperties.getProperty(propName);
- if ( propValue == null || propValue.isEmpty()) {
- propValue = defaultValue;
- }
- }
- catch ( Exception e ) {
- LOG.error (EELFLoggerDelegate.errorLogger, methodName + "unable to find the value, using the default "
- + defaultValue);
- propValue = defaultValue;
- }
- return (propValue);
+ try {
+ propValue = SystemProperties.getProperty(propName);
+ if ( propValue == null || propValue.isEmpty()) {
+ propValue = defaultValue;
+ }
+ }
+ catch ( Exception e ) {
+ LOG.error (EELFLoggerDelegate.errorLogger, methodName + "unable to find the value, using the default "
+ + defaultValue);
+ propValue = defaultValue;
+ }
+ return (propValue);
}
public static long getLongProperty(String key) {
@@ -98,16 +101,16 @@ public class VidProperties extends SystemProperties {
}
public static long getLongProperty(String key, long defaultValue) {
- if (!containsProperty(key)) {
- LOG.debug(EELFLoggerDelegate.debugLogger, "No such property: {}. {} value is used", key, defaultValue);
- return defaultValue;
- }
- String configValue = getProperty(key);
- if (StringUtils.isNumeric(configValue)) {
- return Long.parseLong(configValue);
- } else {
- LOG.debug(EELFLoggerDelegate.debugLogger, "{} property value is not valid: {}. {} value is used", key, configValue, defaultValue);
- return defaultValue;
- }
- }
+ if (!containsProperty(key)) {
+ LOG.debug(EELFLoggerDelegate.debugLogger, "No such property: {}. {} value is used", key, defaultValue);
+ return defaultValue;
+ }
+ String configValue = getProperty(key);
+ if (StringUtils.isNumeric(configValue)) {
+ return Long.parseLong(configValue);
+ } else {
+ LOG.debug(EELFLoggerDelegate.debugLogger, "{} property value is not valid: {}. {} value is used", key, configValue, defaultValue);
+ return defaultValue;
+ }
+ }
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/AAIServiceTree.java b/vid-app-common/src/main/java/org/onap/vid/services/AAIServiceTree.java
index 6199c4e58..d62d5d5d4 100644
--- a/vid-app-common/src/main/java/org/onap/vid/services/AAIServiceTree.java
+++ b/vid-app-common/src/main/java/org/onap/vid/services/AAIServiceTree.java
@@ -7,9 +7,9 @@
* 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.
@@ -21,7 +21,6 @@
package org.onap.vid.services;
import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableList;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.vid.aai.AaiClientInterface;
@@ -31,21 +30,24 @@ import org.onap.vid.asdc.parser.ServiceModelInflator;
import org.onap.vid.exceptions.GenericUncheckedException;
import org.onap.vid.model.ServiceModel;
import org.onap.vid.model.aaiTree.AAITreeNode;
+import org.onap.vid.model.aaiTree.NodeType;
import org.onap.vid.model.aaiTree.ServiceInstance;
import org.onap.vid.utils.Tree;
+import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import javax.ws.rs.core.Response;
import java.util.*;
-import java.util.concurrent.*;
-import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.ConcurrentSkipListSet;
+import java.util.concurrent.ExecutorService;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
-import static java.lang.Thread.sleep;
import static java.util.Comparator.comparing;
import static java.util.stream.Collectors.toSet;
import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;
-import static org.onap.vid.services.AAITreeNodeBuilder.*;
+import static org.onap.vid.utils.KotlinUtilsKt.JACKSON_OBJECT_MAPPER;
@Component
public class AAIServiceTree {
@@ -60,38 +62,58 @@ public class AAIServiceTree {
private final ServiceModelInflator serviceModelInflator;
- private final ObjectMapper mapper = new ObjectMapper();
+ private final ExecutorService executorService;
private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(AAIServiceTree.class);
public static final Tree<AaiRelationship> AAI_TREE_PATHS =
- new Tree<>(new AaiRelationship(SERVICE_INSTANCE));
+ new Tree<>(new AaiRelationship(NodeType.SERVICE_INSTANCE));
static {
- AAI_TREE_PATHS.addPath(toAaiRelationshipList(GENERIC_VNF, VG));
- AAI_TREE_PATHS.addPath(toAaiRelationshipList(NETWORK));
- AAI_TREE_PATHS.addPath(toAaiRelationshipList(GENERIC_VNF, NETWORK));
- AAI_TREE_PATHS.addPath(toAaiRelationshipList(INSTANCE_GROUP));
+ AAI_TREE_PATHS.addPath(toAaiRelationshipList(NodeType.GENERIC_VNF, NodeType.VOLUME_GROUP));
+ AAI_TREE_PATHS.addPath(toAaiRelationshipList(NodeType.GENERIC_VNF, NodeType.VF_MODULE));
+ AAI_TREE_PATHS.addPath(toAaiRelationshipList(NodeType.GENERIC_VNF, NodeType.NETWORK, NodeType.VPN_BINDING));
+ AAI_TREE_PATHS.addPath(toAaiRelationshipList(NodeType.NETWORK, NodeType.VPN_BINDING));
+ AAI_TREE_PATHS.addPath(toAaiRelationshipList(NodeType.INSTANCE_GROUP, NodeType.GENERIC_VNF));
+ AAI_TREE_PATHS.addPath(toAaiRelationshipList(NodeType.COLLECTION_RESOURCE, NodeType.INSTANCE_GROUP));
+ AAI_TREE_PATHS.addPath(toAaiRelationshipList(NodeType.CONFIGURATION, NodeType.NETWORK, NodeType.VPN_BINDING));
+ AAI_TREE_PATHS.addPath(toAaiRelationshipList(NodeType.CONFIGURATION, NodeType.VPN_BINDING));
+ }
+
+ public static List<AAIServiceTree.AaiRelationship> toAaiRelationshipList(NodeType... types) {
+ return Stream.of(types).map(AAIServiceTree.AaiRelationship::new).collect(Collectors.toList());
}
@Inject
public AAIServiceTree(AaiClientInterface aaiClient, AAITreeNodeBuilder aaiTreeNodeBuilder,
AAITreeConverter aaiTreeConverter, VidService sdcService,
- ServiceModelInflator serviceModelInflator) {
+ ServiceModelInflator serviceModelInflator, ExecutorService executorService) {
this.aaiClient = aaiClient;
this.aaiTreeNodeBuilder = aaiTreeNodeBuilder;
this.aaiTreeConverter = aaiTreeConverter;
this.sdcService = sdcService;
this.serviceModelInflator = serviceModelInflator;
+ this.executorService = executorService;
+ }
+
+ List<AAITreeNode> buildAAITreeForUniqueResource(String getUrl, NodeType nodeType) {
+ return buildAAITreeForUniqueResourceFromCustomQuery(getUrl, null, HttpMethod.GET, nodeType);
+ }
+
+ List<AAITreeNode> buildAAITreeForUniqueResourceFromCustomQuery(String url, String payload, HttpMethod method, NodeType nodeType) {
+ Tree<AAIServiceTree.AaiRelationship> pathsToSearch = new Tree<>(new AAIServiceTree.AaiRelationship(nodeType));
+ return buildAAITree(url, payload, method, pathsToSearch, false);
}
- public List<AAITreeNode> buildAAITree(String getUrl, Tree<AaiRelationship> pathsToSearch) {
+ public List<AAITreeNode> buildAAITree(String url, String payload, HttpMethod method, Tree<AaiRelationship> pathsToSearch, boolean enrichWithModelVersion) {
ConcurrentSkipListSet<AAITreeNode> nodesAccumulator = createNodesAccumulator();
- List<AAITreeNode> aaiTreeNodes = fetchAAITree(getUrl, pathsToSearch, nodesAccumulator, true);
+ List<AAITreeNode> aaiTreeNodes = fetchAAITree(url, payload, method, pathsToSearch, nodesAccumulator);
- enrichNodesWithModelVersionAndModelName(nodesAccumulator);
+ if (enrichWithModelVersion) {
+ enrichNodesWithModelVersionAndModelName(nodesAccumulator);
+ }
return aaiTreeNodes;
}
@@ -105,7 +127,7 @@ public class AAIServiceTree {
//Used later to get the nodes UUID
ConcurrentSkipListSet<AAITreeNode> nodesAccumulator = createNodesAccumulator();
- AAITreeNode aaiTree = fetchAAITree(getURL, AAI_TREE_PATHS, nodesAccumulator, false).get(0);
+ AAITreeNode aaiTree = fetchAAITree(getURL, null, HttpMethod.GET, AAI_TREE_PATHS, nodesAccumulator).get(0);
//Populate nodes with model-name & model-version (from aai)
enrichNodesWithModelVersionAndModelName(nodesAccumulator);
@@ -115,28 +137,28 @@ public class AAIServiceTree {
//Populate nodes with model-customization-name (from sdc model)
enrichNodesWithModelCustomizationName(nodesAccumulator, serviceModel);
- return aaiTreeConverter.convertTreeToUIModel(aaiTree, globalCustomerId, serviceType, getInstantiationType(serviceModel));
+ return aaiTreeConverter.convertTreeToUIModel(aaiTree, globalCustomerId, serviceType, getInstantiationType(serviceModel), getInstanceRole(serviceModel), getInstanceType(serviceModel));
}
- private List<AAITreeNode> fetchAAITree(String getUrl, Tree<AaiRelationship> pathsToSearch,
- ConcurrentSkipListSet<AAITreeNode> nodesAccumulator, boolean partialTreeOnTimeout) {
- ThreadPoolExecutor threadPool = getThreadPool();
-
- List<AAITreeNode> aaiTree = aaiTreeNodeBuilder.buildNode(SERVICE_INSTANCE,
- getUrl, defaultIfNull(nodesAccumulator, createNodesAccumulator()),
- threadPool, new ConcurrentLinkedQueue<>(),
- new AtomicInteger(0), pathsToSearch);
-
- boolean timeoutOccurred = waitForTreeFetch(threadPool);
+ private String getInstanceType(ServiceModel serviceModel){
+ if (serviceModel != null && serviceModel.getService() != null) {
+ return serviceModel.getService().getServiceType();
+ }
+ return "";
+ }
- if (timeoutOccurred) {
- if (!partialTreeOnTimeout) {
- throw new GenericUncheckedException("Timeout on fetchAAITree. Fetched " + nodesAccumulator.size() + " nodes for url: " + getUrl);
- }
- LOGGER.warn(EELFLoggerDelegate.errorLogger, "Timeout on fetchAAITree for url: " + getUrl);
+ private String getInstanceRole(ServiceModel serviceModel) {
+ if (serviceModel != null && serviceModel.getService() != null) {
+ return serviceModel.getService().getServiceRole();
}
+ return "";
+ }
- return aaiTree;
+ private List<AAITreeNode> fetchAAITree(String url, String payload, HttpMethod method, Tree<AaiRelationship> pathsToSearch,
+ ConcurrentSkipListSet<AAITreeNode> nodesAccumulator) {
+ return aaiTreeNodeBuilder.buildNode(NodeType.fromString(pathsToSearch.getRootValue().type),
+ url, payload, method, defaultIfNull(nodesAccumulator, createNodesAccumulator()),
+ executorService, pathsToSearch);
}
private ConcurrentSkipListSet<AAITreeNode> createNodesAccumulator() {
@@ -204,12 +226,12 @@ public class AAIServiceTree {
private JsonNode getModels(AaiClientInterface aaiClient, Collection<String> invariantIDs) {
Response response = aaiClient.getVersionByInvariantId(ImmutableList.copyOf(invariantIDs));
try {
- JsonNode responseJson = mapper.readTree(response.readEntity(String.class));
+ JsonNode responseJson = JACKSON_OBJECT_MAPPER.readTree(response.readEntity(String.class));
return responseJson.get("model");
} catch (Exception e) {
LOGGER.error(EELFLoggerDelegate.errorLogger, "Failed to getVersionByInvariantId from A&AI", e);
}
- return mapper.createObjectNode();
+ return JACKSON_OBJECT_MAPPER.createObjectNode();
}
private Set<String> getModelInvariantIds(Collection<AAITreeNode> nodes) {
@@ -219,30 +241,6 @@ public class AAIServiceTree {
.collect(toSet());
}
- private boolean waitForTreeFetch(ThreadPoolExecutor threadPool) {
- int timer = 60;
- try {
- //Stop fetching information if it takes more than 1 minute
- while (threadPool.getActiveCount() != 0 &&
- timer > 0) {
- sleep(1000);
- timer--;
- }
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- throw new GenericUncheckedException(e);
- }
- threadPool.shutdown();
- return (timer == 0);
- }
-
- private ThreadPoolExecutor getThreadPool() {
- //Use at least one thread, and never more than 75% of the available thread.
- int cores = Math.max((int)(Runtime.getRuntime().availableProcessors() * 0.75), 1);
- BlockingQueue<Runnable> queue = new LinkedBlockingQueue<>();
- return new ThreadPoolExecutor(1, cores, 10, TimeUnit.SECONDS, queue);
- }
-
public static class AaiRelationship {
public final String type;
@@ -251,6 +249,10 @@ public class AAIServiceTree {
this.type = type;
}
+ public AaiRelationship(NodeType nodeType) {
+ this.type = nodeType.getType();
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) return true;
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/AAITreeNodeBuilder.java b/vid-app-common/src/main/java/org/onap/vid/services/AAITreeNodeBuilder.java
index e06088264..d53eba8d3 100644
--- a/vid-app-common/src/main/java/org/onap/vid/services/AAITreeNodeBuilder.java
+++ b/vid-app-common/src/main/java/org/onap/vid/services/AAITreeNodeBuilder.java
@@ -7,9 +7,9 @@
* 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.
@@ -21,66 +21,49 @@
package org.onap.vid.services;
import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableList;
import org.apache.commons.lang3.StringUtils;
-import org.jetbrains.annotations.NotNull;
+import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.apache.commons.lang3.tuple.Pair;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.portalsdk.core.util.SystemProperties;
import org.onap.vid.aai.AaiClientInterface;
import org.onap.vid.aai.ExceptionWithRequestInfo;
import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.Relationship;
+import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.RelationshipData;
import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.RelationshipList;
+import org.onap.vid.aai.util.AAITreeNodeUtils;
+import org.onap.vid.exceptions.GenericUncheckedException;
import org.onap.vid.model.aaiTree.AAITreeNode;
import org.onap.vid.model.aaiTree.FailureAAITreeNode;
+import org.onap.vid.model.aaiTree.NodeType;
+import org.onap.vid.mso.model.CloudConfiguration;
+import org.onap.vid.properties.VidProperties;
import org.onap.vid.utils.Streams;
import org.onap.vid.utils.Tree;
import org.onap.vid.utils.Unchecked;
+import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentLinkedQueue;
-import java.util.concurrent.ConcurrentSkipListSet;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.atomic.AtomicInteger;
+import java.util.*;
+import java.util.concurrent.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static java.util.stream.Collectors.*;
+import static org.onap.vid.utils.KotlinUtilsKt.JACKSON_OBJECT_MAPPER;
import static org.onap.vid.utils.Streams.not;
@Component
public class AAITreeNodeBuilder {
+ private static final String RESULTS = "results";
private AaiClientInterface aaiClient;
- private final ObjectMapper mapper = new ObjectMapper();
-
private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(AAITreeNodeBuilder.class);
- //List of all the node types the tree should include
- public static final String SERVICE_INSTANCE = "service-instance";
- public static final String GENERIC_VNF = "generic-vnf";
- public static final String NETWORK = "l3-network";
- public static final String FAILURE = "failure_node";
- public static final String COLLECTION_RESOURCE = "collection";
- public static final String CONFIGURATION = "configuration";
- public static final String PNF = "pnf";
- public static final String VF_MODULE = "vf-module";
- public static final String INSTANCE_GROUP = "instance-group";
- public static final String PORT = "l-interface";
- public static final String VG = "volume-group";
- public static final String VLAN_TAG = "vlan-tag";
-
- //Hashmap that defines the node-type and the tag that should be used to find it's ID key in the JSON.
- private static HashMap<String, String> nodeTypeToIdKeyMap = generateTypeToIdKeyMap();
-
- //Hashmap that defines the node-type and the tag that should be used to find it's NAMR key in the JSON.
- private static HashMap<String, String> nodeTypeToNameKeyMap = generateTypeToNameKeyMap();
public enum AAIBaseProperties {
ORCHESTRATION_STATUS("orchestration-status"),
@@ -102,63 +85,121 @@ public class AAITreeNodeBuilder {
}
}
- public static List<AAIServiceTree.AaiRelationship> toAaiRelationshipList(String... types) {
- return Stream.of(types).map(AAIServiceTree.AaiRelationship::new).collect(Collectors.toList());
- }
-
@Inject
public AAITreeNodeBuilder(AaiClientInterface aaiClient) {
this.aaiClient = aaiClient;
}
- public List<AAITreeNode> buildNode(String nodeType,
- String requestURL,
- ConcurrentSkipListSet<AAITreeNode> nodesAccumulator, ExecutorService threadPool,
- ConcurrentLinkedQueue<String> visitedNodes,
- AtomicInteger nodesCounter,
- Tree<AAIServiceTree.AaiRelationship> pathsTree) {
+ List<AAITreeNode> buildNode(NodeType nodeType,
+ String requestURL,
+ String payload,
+ HttpMethod method,
+ ConcurrentSkipListSet<AAITreeNode> nodesAccumulator,
+ ExecutorService threadPool,
+ Tree<AAIServiceTree.AaiRelationship> pathsTree) {
- JsonNode topLevelJson = aaiClient.typedAaiGet(Unchecked.toURI(requestURL), JsonNode.class);
+ JsonNode jsonNode = aaiClient.typedAaiRest(Unchecked.toURI(requestURL), JsonNode.class, payload, method, false);
- if (topLevelJson.has(nodeType) && topLevelJson.get(nodeType).isArray()) {
- return Streams.fromIterable(topLevelJson.get(nodeType))
- .map(item -> parseNodeAndGetChildren(nodeType, requestURL, item,
- nodesAccumulator, threadPool, visitedNodes, nodesCounter, pathsTree))
- .collect(toList());
- } else {
- return ImmutableList.of(parseNodeAndGetChildren(nodeType, requestURL, topLevelJson,
- nodesAccumulator, threadPool, visitedNodes, nodesCounter, pathsTree));
+ List<Pair<AAITreeNode, List<Relationship>>> nodes = getNodesWithRelationships(jsonNode, nodeType, nodesAccumulator, pathsTree);
+
+ String timeout = SystemProperties.getProperty(VidProperties.VID_THREAD_TIMEOUT);
+ long timeoutNum = Long.parseLong(StringUtils.defaultIfEmpty(timeout, "30"));
+
+ for (Pair<AAITreeNode, List<Relationship>> entry : nodes) {
+ fetchChildrenAsync(threadPool, nodesAccumulator, entry.getKey(), entry.getValue(), pathsTree, timeoutNum);
+
+ if (getNextLevelInPathsTree(pathsTree, NodeType.VF_MODULE.getType()) != null) {
+ getRelatedVfModules(threadPool, nodesAccumulator, requestURL, entry.getKey());
+ }
}
+
+ return nodes.stream()
+ .map(Pair::getKey)
+ .collect(Collectors.toList());
}
- private AAITreeNode parseNodeAndGetChildren(String nodeType,
- String requestURL,
- JsonNode topLevelJson,
- ConcurrentSkipListSet<AAITreeNode> nodesAccumulator, ExecutorService threadPool,
- ConcurrentLinkedQueue<String> visitedNodes,
- AtomicInteger nodesCounter,
- Tree<AAIServiceTree.AaiRelationship> pathsTree) {
- AAITreeNode node = jsonToAaiNode(nodeType, topLevelJson, nodesAccumulator, nodesCounter);
-
- RelationshipList relationships = mapper.convertValue(topLevelJson.get(AAIBaseProperties.RELATIONSHIP_LIST.getAaiKey()), RelationshipList.class);
- if (relationships != null) {
- getChildren(threadPool, nodesAccumulator, relationships.getRelationship(), visitedNodes, node, nodesCounter, pathsTree);
- }
- if (StringUtils.equals(node.getType(), GENERIC_VNF)) {
- getRelatedVfModules(threadPool, nodesAccumulator, requestURL, node, nodesCounter);
+ private List<Pair<AAITreeNode, List<Relationship>>> getNodesWithRelationships(JsonNode jsonNode, NodeType nodeType,
+ ConcurrentSkipListSet<AAITreeNode> nodesAccumulator,
+ Tree<AAIServiceTree.AaiRelationship> pathsTree) {
+ if (isListOfKeyResults(jsonNode)) {
+ return Streams.fromIterable(jsonNode.get(RESULTS))
+ .filter(item -> item.has(nodeType.getType()))
+ .map(item -> item.get(nodeType.getType()))
+ .map(item -> parseNodeAndFilterRelationships(item, nodeType, nodesAccumulator, pathsTree))
+ .collect(Collectors.toList());
+ } else if (isArray(jsonNode, nodeType)) {
+ return Streams.fromIterable(jsonNode.get(nodeType.getType()))
+ .map(item -> parseNodeAndFilterRelationships(item, nodeType, nodesAccumulator, pathsTree))
+ .collect(Collectors.toList());
+ } else {
+ return ImmutableList.of(parseNodeAndFilterRelationships(jsonNode, nodeType, nodesAccumulator, pathsTree));
}
- return node;
}
- private AAITreeNode jsonToAaiNode(String nodeType, JsonNode topLevelJson, ConcurrentSkipListSet<AAITreeNode> nodesAccumulator, AtomicInteger nodesCounter) {
- AAITreeNode node = fillNodeMetaData(nodeType, topLevelJson, nodesCounter);
+ Pair<AAITreeNode, List<Relationship>> parseNodeAndFilterRelationships(JsonNode jsonNode, NodeType nodeType,
+ ConcurrentSkipListSet<AAITreeNode> nodesAccumulator,
+ Tree<AAIServiceTree.AaiRelationship> pathsTree) {
+ AAITreeNode node = createAaiNode(nodeType, jsonNode, nodesAccumulator);
+
+ enrichPlacementData(node);
+
+ List<Relationship> filteredRelationships = getFilteredRelationships(jsonNode, pathsTree);
+
+ return ImmutablePair.of(node, filteredRelationships);
+ }
+
+ boolean isArray(JsonNode json, NodeType nodeType) {
+ return json != null && json.has(nodeType.getType()) && json.get(nodeType.getType()).isArray();
+ }
+
+ boolean isListOfKeyResults(JsonNode jsonNode) {
+ return jsonNode != null && jsonNode.has(RESULTS) && jsonNode.get(RESULTS).isArray();
+ }
+
+ AAITreeNode createAaiNode(NodeType nodeType, JsonNode jsonNode, ConcurrentSkipListSet<AAITreeNode> nodesAccumulator) {
+ AAITreeNode node = jsonNodeToAaiNode(nodeType, jsonNode);
nodesAccumulator.add(node);
return node;
}
- private void getRelatedVfModules(ExecutorService threadPool, ConcurrentSkipListSet<AAITreeNode> nodesAccumulator, String parentURL, AAITreeNode parentNode, AtomicInteger nodesCounter) {
+ private void addChildren(AAITreeNode node, Future<List<AAITreeNode>> children) {
+ try {
+ node.addChildren(children.get());
+ } catch (Exception e) {
+ node.getChildren().add(createFailureNode(e));
+ }
+ }
+
+ private Map<String,String> convertRelationshipDataToMap(List<RelationshipData> relationshipData) {
+ return relationshipData.stream().collect(
+ Collectors.toMap(RelationshipData::getKey, RelationshipData::getValue));
+ }
+
+ void enrichPlacementData(AAITreeNode node){
+ Optional<Relationship> tenantRelationShip = AAITreeNodeUtils.findFirstRelationshipByRelatedTo(node.getRelationshipList(), "tenant");
+ enrichPlacementDataUsingTenantInfo(node, tenantRelationShip);
+ }
+
+ void enrichPlacementDataUsingTenantInfo(AAITreeNode node, Optional<Relationship> tenantRelationShip) {
+ //no tenant relationship in this node - so no placement data
+ if (!tenantRelationShip.isPresent()) {
+ return;
+ }
+ try {
+ Map<String, String> relationshipsDataMap = convertRelationshipDataToMap(tenantRelationShip.get().getRelationDataList());
+ node.setCloudConfiguration(new CloudConfiguration(
+ relationshipsDataMap.get("cloud-region.cloud-region-id"),
+ relationshipsDataMap.get("tenant.tenant-id"),
+ relationshipsDataMap.get("cloud-region.cloud-owner")));
+ }
+ catch (Exception exception) {
+ LOGGER.error("Failed to extract placement form tenant relationship of {}:{}", node.getType(), node.getId(), exception);
+ }
+ }
+
+ private void getRelatedVfModules(ExecutorService threadPool, ConcurrentSkipListSet<AAITreeNode> nodesAccumulator, String parentURL, AAITreeNode parentNode) {
/*
VNFs do not report their direct related-to vf-modules, so try
directly fetching a resource URI.
@@ -166,73 +207,100 @@ public class AAITreeNodeBuilder {
threadPool.execute(() -> {
// the response is an array of vf-modules
- final JsonNode topLevelJson;
+ final JsonNode jsonNode;
try {
- topLevelJson = aaiClient.typedAaiGet(Unchecked.toURI(parentURL + "/vf-modules"), JsonNode.class);
+ jsonNode = aaiClient.typedAaiGet(Unchecked.toURI(parentURL + "/vf-modules"), JsonNode.class);
} catch (ExceptionWithRequestInfo e) {
if (e.getHttpCode().equals(404)) {
// it's ok, as we're just optimistically fetching
- // the /vf-modules uri; 404 says this time it was
- // a bad guess
+ // the /vf-modules uri; 404 says this time it was a bad guess
return;
} else {
throw e;
}
}
- if (topLevelJson != null) {
- parentNode.getChildren().addAll(
- Streams.fromIterable(topLevelJson.get(VF_MODULE))
- .map(vfModuleNode -> jsonToAaiNode(VF_MODULE, vfModuleNode, nodesAccumulator, nodesCounter))
- .collect(toList())
- );
+ if (isArray(jsonNode, NodeType.VF_MODULE)) {
+
+ //create list of AAITreeNode represent the VfModules from AAI result
+ List<AAITreeNode> vfModules = Streams.fromIterable(jsonNode.get(NodeType.VF_MODULE.getType()))
+ .map(vfModuleNode -> createAaiNode(NodeType.VF_MODULE, vfModuleNode, nodesAccumulator))
+ .collect(toList());
+ //enrich each of the VfModule with placement info
+ vfModules.forEach(vfModule-> enrichPlacementDataUsingTenantInfo(
+ vfModule,
+ AAITreeNodeUtils.findFirstRelationshipByRelatedTo(vfModule.getRelationshipList(), "vserver")
+ ));
+ //add all VfModules to children list of parent node
+ parentNode.getChildren().addAll(vfModules);
} else {
LOGGER.error(EELFLoggerDelegate.errorLogger, "Failed to get vf-modules for vnf " + parentNode.getId());
}
});
}
- private void getChildren(ExecutorService threadPool, ConcurrentSkipListSet<AAITreeNode> nodesAccumulator,
- List<Relationship> relationships, ConcurrentLinkedQueue<String> visitedNodes, AAITreeNode parent, AtomicInteger nodesCounter, Tree<AAIServiceTree.AaiRelationship> pathsTree) {
- for (Relationship relationship : relationships) {
- createChildNode(threadPool, nodesAccumulator, relationship, visitedNodes, parent, nodesCounter, pathsTree);
+ List<Relationship> getFilteredRelationships(JsonNode json, Tree<AAIServiceTree.AaiRelationship> pathsTree) {
+ RelationshipList relationshipList = JACKSON_OBJECT_MAPPER.convertValue(json.get(AAIBaseProperties.RELATIONSHIP_LIST.getAaiKey()), RelationshipList.class);
+ if (relationshipList != null) {
+ return relationshipList.getRelationship().stream()
+ .filter(rel -> getNextLevelInPathsTree(pathsTree, rel.getRelatedTo()) != null)
+ .filter(rel -> !Objects.equals(rel.getRelatedTo(), NodeType.VF_MODULE.getType())) // vf-modules are handled separately
+ .collect(toList());
}
+
+ return Collections.emptyList();
}
- private void createChildNode(ExecutorService threadPool, ConcurrentSkipListSet<AAITreeNode> nodesAccumulator,
- Relationship relationship, ConcurrentLinkedQueue<String> visitedNodes, AAITreeNode parent, AtomicInteger nodesCounter, Tree<AAIServiceTree.AaiRelationship> pathsTree) {
- String newNodeType = relationship.getRelatedTo();
- Tree<AAIServiceTree.AaiRelationship> subTree = pathsTree.getSubTree(new AAIServiceTree.AaiRelationship(newNodeType));
- if (subTree!=null) {
- String newNodeUrl = relationship.getRelatedLink();
- if (!visitedNodes.contains(newNodeUrl)) {
- visitedNodes.add(newNodeUrl);
- threadPool.execute(() -> {
- try {
- parent.addChildren(buildNode(newNodeType, newNodeUrl, nodesAccumulator, threadPool, visitedNodes, nodesCounter, subTree));
- } catch (Exception e) {
- parent.getChildren().add(createFailureNode(e));
- }
- }
- );
+ void fetchChildrenAsync(ExecutorService threadPool, ConcurrentSkipListSet<AAITreeNode> nodesAccumulator,
+ AAITreeNode node, List<Relationship> relationships, Tree<AAIServiceTree.AaiRelationship> pathsTree, long timeout) {
+
+ if (!relationships.isEmpty()) {
+ List<Callable<List<AAITreeNode>>> tasks = relationships.stream()
+ .map(relationship ->
+ (Callable<List<AAITreeNode>>) () ->
+ getChildNode(threadPool, nodesAccumulator, relationship.getRelatedTo(),
+ relationship.getRelatedLink(), pathsTree))
+ .collect(Collectors.toList());
+
+ try {
+ int depth = pathsTree.getChildrenDepth();
+ threadPool.invokeAll(tasks, timeout * depth, TimeUnit.SECONDS)
+ .forEach(future ->
+ addChildren(node, future)
+ );
+ } catch (Exception e) {
+ throw new GenericUncheckedException(e);
}
}
}
- private AAITreeNode fillNodeMetaData(String nodeType, JsonNode model, @NotNull AtomicInteger nodesCounter) {
+ private List<AAITreeNode> getChildNode(ExecutorService threadPool, ConcurrentSkipListSet<AAITreeNode> nodesAccumulator,
+ String childNodeType, String childNodeUrl,
+ Tree<AAIServiceTree.AaiRelationship> pathsTree) {
+
+ Tree<AAIServiceTree.AaiRelationship> subTree = getNextLevelInPathsTree(pathsTree, childNodeType);
+
+ return buildNode(NodeType.fromString(childNodeType), childNodeUrl, null, HttpMethod.GET, nodesAccumulator, threadPool, subTree);
+ }
+
+ Tree<AAIServiceTree.AaiRelationship> getNextLevelInPathsTree(Tree<AAIServiceTree.AaiRelationship> pathsTree, String nodeType) {
+ return pathsTree.getSubTree(new AAIServiceTree.AaiRelationship(nodeType));
+ }
+
+ //ADD TEST
+ private AAITreeNode jsonNodeToAaiNode(NodeType nodeType, JsonNode jsonNode) {
AAITreeNode node = new AAITreeNode();
node.setType(nodeType);
- node.setUniqueNumber(nodesCounter.getAndIncrement());
- node.setOrchestrationStatus(getStringDataFromJsonIfExists(model, AAIBaseProperties.ORCHESTRATION_STATUS.getAaiKey()));
- node.setProvStatus(getStringDataFromJsonIfExists(model, AAIBaseProperties.PROV_STATUS.getAaiKey()));
- node.setInMaint(getBooleanDataFromJsonIfExists(model, AAIBaseProperties.IN_MAINT.getAaiKey()));
- node.setModelVersionId(getStringDataFromJsonIfExists(model, AAIBaseProperties.MODEL_VERSION_ID.getAaiKey()));
- node.setModelCustomizationId(getStringDataFromJsonIfExists(model, AAIBaseProperties.MODEL_CUSTOMIZATION_ID.getAaiKey()));
- node.setModelInvariantId(getStringDataFromJsonIfExists(model, AAIBaseProperties.MODEL_INVARIANT_ID.getAaiKey()));
- node.setId(getStringDataFromJsonIfExists(model, nodeTypeToIdKeyMap.get(nodeType)));
- node.setName(getStringDataFromJsonIfExists(model, nodeTypeToNameKeyMap.get(nodeType)));
- node.setAdditionalProperties(aggregateAllOtherProperties(model, nodeType));
-
+ node.setOrchestrationStatus(getStringDataFromJsonIfExists(jsonNode, AAIBaseProperties.ORCHESTRATION_STATUS.getAaiKey()));
+ node.setProvStatus(getStringDataFromJsonIfExists(jsonNode, AAIBaseProperties.PROV_STATUS.getAaiKey()));
+ node.setInMaint(getBooleanDataFromJsonIfExists(jsonNode, AAIBaseProperties.IN_MAINT.getAaiKey()));
+ node.setModelVersionId(getStringDataFromJsonIfExists(jsonNode, AAIBaseProperties.MODEL_VERSION_ID.getAaiKey()));
+ node.setModelCustomizationId(getStringDataFromJsonIfExists(jsonNode, AAIBaseProperties.MODEL_CUSTOMIZATION_ID.getAaiKey()));
+ node.setModelInvariantId(getStringDataFromJsonIfExists(jsonNode, AAIBaseProperties.MODEL_INVARIANT_ID.getAaiKey()));
+ node.setId(getStringDataFromJsonIfExists(jsonNode, nodeType.getId()));
+ node.setName(getStringDataFromJsonIfExists(jsonNode, nodeType.getName()));
+ node.setAdditionalProperties(aggregateAllOtherProperties(jsonNode, nodeType));
+ node.setRelationshipList(JACKSON_OBJECT_MAPPER.convertValue(jsonNode.get(AAIBaseProperties.RELATIONSHIP_LIST.getAaiKey()), RelationshipList.class));
return node;
}
@@ -241,7 +309,7 @@ public class AAITreeNodeBuilder {
}
private String getStringDataFromJsonIfExists(JsonNode model, String key) {
- if (model.has(key)) {
+ if (!NodeType.NONE.equals(key) && model.has(key)) {
return model.get(key).asText();
}
return null;
@@ -254,48 +322,17 @@ public class AAITreeNodeBuilder {
return false;
}
- private Map<String, Object> aggregateAllOtherProperties(JsonNode model, String nodeType) {
+ Map<String, Object> aggregateAllOtherProperties(JsonNode model, NodeType nodeType) {
Set<String> ignoreProperties = Stream.of(AAIBaseProperties.values())
.map(AAIBaseProperties::getAaiKey).collect(toSet());
-
return Streams.fromIterator(model.fields())
- .filter(not(field -> StringUtils.equals(field.getKey(), nodeTypeToIdKeyMap.get(nodeType))))
- .filter(not(field -> StringUtils.equals(field.getKey(), nodeTypeToNameKeyMap.get(nodeType))))
+ .filter(not(field -> StringUtils.equals(field.getKey(), nodeType.getId())))
+ .filter(not(field -> StringUtils.equals(field.getKey(), nodeType.getName())))
.filter(not(field -> ignoreProperties.contains(field.getKey())))
- .collect(toMap(Map.Entry::getKey, v -> v.getValue().asText()));
- }
-
- private static HashMap<String, String> generateTypeToIdKeyMap() {
- HashMap<String, String> result = new HashMap<>();
- result.put(SERVICE_INSTANCE, "service-instance-id");
- result.put(GENERIC_VNF, "vnf-id");
- result.put(NETWORK, "network-id");
- result.put(COLLECTION_RESOURCE, "collection-id");
- result.put(CONFIGURATION, "configuration-id");
- result.put(PNF, "pnf-id");
- result.put(VF_MODULE, "vf-module-id");
- result.put(INSTANCE_GROUP, "id");
- result.put(PORT, "l-interface-id");
- result.put(VG, "volume-group-id");
- result.put(VLAN_TAG, "vlan-id");
-
- return result;
+ .collect(toMap(Map.Entry::getKey, v -> ifTextualGetAsText(v.getValue())));
}
- private static HashMap<String, String> generateTypeToNameKeyMap() {
- HashMap<String, String> result = new HashMap<>();
- result.put(SERVICE_INSTANCE, "service-instance-name");
- result.put(GENERIC_VNF, "vnf-name");
- result.put(NETWORK, "network-name");
- result.put(COLLECTION_RESOURCE, "collection-name");
- result.put(CONFIGURATION, "configuration-name");
- result.put(PNF, "pnf-name");
- result.put(VF_MODULE, "vf-module-name");
- result.put(INSTANCE_GROUP, "instance-group-name");
- result.put(PORT, "l-interface-name");
- result.put(VG, "volume-group-name");
- result.put(VLAN_TAG, "vlan-name");
-
- return result;
+ private Object ifTextualGetAsText(JsonNode jsonNode) {
+ return jsonNode.isTextual() ? jsonNode.asText() : jsonNode;
}
-}
+} \ No newline at end of file
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/AaiService.java b/vid-app-common/src/main/java/org/onap/vid/services/AaiService.java
index 910b34112..76efbd0ea 100644
--- a/vid-app-common/src/main/java/org/onap/vid/services/AaiService.java
+++ b/vid-app-common/src/main/java/org/onap/vid/services/AaiService.java
@@ -48,7 +48,7 @@ public interface AaiService {
SubscriberFilteredResults getFullSubscriberList(RoleValidator roleValidator);
- AaiResponse getSubscriberData(String subscriberId, RoleValidator roleValidator);
+ AaiResponse getSubscriberData(String subscriberId, RoleValidator roleValidator, boolean omitServiceInstances);
AaiResponse getServiceInstanceSearchResults(String subscriberId, String instanceIdentifier, RoleValidator roleProvider, List<String> owningEntities, List<String> projects);
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java
index d01f0f7ad..961f11096 100644
--- a/vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java
@@ -24,6 +24,7 @@ package org.onap.vid.services;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.joshworks.restclient.http.HttpResponse;
+import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpStatus;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.vid.aai.*;
@@ -39,16 +40,19 @@ import org.onap.vid.exceptions.GenericUncheckedException;
import org.onap.vid.model.ServiceInstanceSearchResult;
import org.onap.vid.model.SubscriberList;
import org.onap.vid.model.aaiTree.AAITreeNode;
+import org.onap.vid.model.aaiTree.NodeType;
import org.onap.vid.model.aaiTree.RelatedVnf;
import org.onap.vid.roles.RoleValidator;
import org.onap.vid.utils.Intersection;
import org.onap.vid.utils.Tree;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpMethod;
import javax.ws.rs.core.Response;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.*;
+import java.util.concurrent.ExecutorService;
import java.util.stream.Collectors;
/**
@@ -68,6 +72,8 @@ public class AaiServiceImpl implements AaiService {
private AaiResponseTranslator aaiResponseTranslator;
private AAITreeNodeBuilder aaiTreeNode;
private AAIServiceTree aaiServiceTree;
+ private ExecutorService executorService;
+
private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(AaiServiceImpl.class);
@@ -77,13 +83,15 @@ public class AaiServiceImpl implements AaiService {
AaiOverTLSClientInterface aaiOverTLSClient,
AaiResponseTranslator aaiResponseTranslator,
AAITreeNodeBuilder aaiTreeNode,
- AAIServiceTree aaiServiceTree)
+ AAIServiceTree aaiServiceTree,
+ ExecutorService executorService)
{
this.aaiClient = aaiClient;
this.aaiOverTLSClient = aaiOverTLSClient;
this.aaiResponseTranslator = aaiResponseTranslator;
this.aaiTreeNode = aaiTreeNode;
this.aaiServiceTree = aaiServiceTree;
+ this.executorService = executorService;
}
private List<Service> convertModelToService(Model model) {
@@ -220,8 +228,8 @@ public class AaiServiceImpl implements AaiService {
}
@Override
- public AaiResponse getSubscriberData(String subscriberId, RoleValidator roleValidator) {
- AaiResponse<Services> subscriberResponse = aaiClient.getSubscriberData(subscriberId);
+ public AaiResponse getSubscriberData(String subscriberId, RoleValidator roleValidator, boolean omitServiceInstances) {
+ AaiResponse<Services> subscriberResponse = aaiClient.getSubscriberData(subscriberId, omitServiceInstances);
String subscriberGlobalId = subscriberResponse.getT().globalCustomerId;
for (ServiceSubscription serviceSubscription : subscriberResponse.getT().serviceSubscriptions.serviceSubscription) {
String serviceType = serviceSubscription.serviceType;
@@ -254,7 +262,7 @@ public class AaiServiceImpl implements AaiService {
private List<ServiceInstanceSearchResult> getServicesBySubscriber(String subscriberId, String instanceIdentifier, RoleValidator roleValidator) {
- AaiResponse<Services> subscriberResponse = aaiClient.getSubscriberData(subscriberId);
+ AaiResponse<Services> subscriberResponse = aaiClient.getSubscriberData(subscriberId, false);
String subscriberGlobalId = subscriberResponse.getT().globalCustomerId;
String subscriberName = subscriberResponse.getT().subscriberName;
ServiceSubscriptions serviceSubscriptions = subscriberResponse.getT().serviceSubscriptions;
@@ -483,26 +491,37 @@ public class AaiServiceImpl implements AaiService {
@Override
public List<RelatedVnf> searchGroupMembers(String globalCustomerId, String serviceType, String invariantId, String groupType, String groupRole) {
String getURL = "business/customers/customer/" +
- globalCustomerId + "/service-subscriptions/service-subscription/" +
- serviceType + "/service-instances?model-invariant-id=" + invariantId;
+ globalCustomerId + "/service-subscriptions/service-subscription/" +
+ serviceType + "/service-instances?model-invariant-id=" + invariantId;
- Tree<AAIServiceTree.AaiRelationship> pathsToSearch = new Tree<>(new AAIServiceTree.AaiRelationship(AAITreeNodeBuilder.SERVICE_INSTANCE));
- pathsToSearch.addPath(AAITreeNodeBuilder.toAaiRelationshipList(AAITreeNodeBuilder.GENERIC_VNF, AAITreeNodeBuilder.INSTANCE_GROUP));
+ Tree<AAIServiceTree.AaiRelationship> pathsToSearch = new Tree<>(new AAIServiceTree.AaiRelationship(NodeType.SERVICE_INSTANCE));
+ pathsToSearch.addPath(AAIServiceTree.toAaiRelationshipList(NodeType.GENERIC_VNF, NodeType.INSTANCE_GROUP));
//get all vnfs related to service-instances from the model-invariant-id
- List<AAITreeNode> aaiTree = aaiServiceTree.buildAAITree(getURL, pathsToSearch);
+ List<AAITreeNode> aaiTree = aaiServiceTree.buildAAITree(getURL, null, HttpMethod.GET, pathsToSearch, true);
//filter by instance-group-role & instance-group-type properties (from getAdditionalProperties)
//only vnfs has related instance-group with the same groupType & groupRole - are filtered out.
List<AAITreeNode> filteredVnfs = filterByInstanceGroupRoleAndType(aaiTree, groupRole, groupType);
//convert vnfs to expected result
- return filteredVnfs.stream()
+ List<RelatedVnf> convertedVnfs = filteredVnfs.stream()
.map(RelatedVnf::from)
- .map(this::enrichRelatedVnfWithCloudRegionAndTenant)
.collect(Collectors.toList());
+
+ try {
+ return executorService.submit(() ->
+ convertedVnfs.parallelStream()
+ .map(this::enrichRelatedVnfWithCloudRegionAndTenant)
+ .collect(Collectors.toList())
+ ).get();
+ } catch (Exception e) {
+ LOGGER.error(EELFLoggerDelegate.errorLogger, "Search group Members - Failed to enrich vnf with cloud region", e);
+ return convertedVnfs;
+ }
}
+
private List<AAITreeNode> filterByInstanceGroupRoleAndType(List<AAITreeNode> aaiTree, String groupRole, String groupType) {
return aaiTree.stream()
@@ -544,10 +563,10 @@ public class AaiServiceImpl implements AaiService {
}
private void getInstanceGroupInfoFromRelationship(org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.Relationship relationship, List<InstanceGroupInfo> instanceGroupInfoList) {
- if(relationship.getRelatedTo().equals("instance-group")){
+ if(StringUtils.equals(relationship.getRelatedTo(),"instance-group")){
for(org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.RelatedToProperty relatedToProperty: relationship.getRelatedToPropertyList()){
- if(relatedToProperty.getPropertyKey().equals("instance-group.instance-group-name")){
- instanceGroupInfoList.add(new InstanceGroupInfo(relatedToProperty.getPropertyValue()));
+ if(StringUtils.equals(relatedToProperty.getKey(),"instance-group.instance-group-name")){
+ instanceGroupInfoList.add(new InstanceGroupInfo(relatedToProperty.getValue()));
}
}
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogic.java b/vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogic.java
index 603f13867..1202fc9e3 100644
--- a/vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogic.java
+++ b/vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogic.java
@@ -7,9 +7,9 @@
* 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.
@@ -21,17 +21,15 @@
package org.onap.vid.services;
import org.onap.vid.aai.model.ResourceType;
-import org.onap.vid.changeManagement.RequestDetailsWrapper;
import org.onap.vid.job.Job;
-import org.onap.vid.model.JobAuditStatus;
+import org.onap.vid.job.impl.JobSharedData;
import org.onap.vid.model.ServiceInfo;
-import org.onap.vid.model.serviceInstantiation.*;
-import org.onap.vid.mso.model.*;
+import org.onap.vid.model.serviceInstantiation.ServiceInstantiation;
+import org.onap.vid.mso.RestObject;
import org.onap.vid.mso.rest.AsyncRequestStatus;
import java.util.Arrays;
import java.util.List;
-import java.util.Map;
import java.util.UUID;
import java.util.function.Consumer;
@@ -43,23 +41,7 @@ public interface AsyncInstantiationBusinessLogic {
List<UUID> pushBulkJob(ServiceInstantiation request, String userId);
- RequestDetailsWrapper<ServiceInstantiationRequestDetails> generateMacroServiceInstantiationRequest(UUID uuid, ServiceInstantiation details, String optimisticUniqueServiceInstanceName, String userId);
-
- RequestDetailsWrapper<ServiceInstantiationRequestDetails> generateALaCarteServiceInstantiationRequest(UUID uuid, ServiceInstantiation details, String optimisticUniqueServiceInstanceName, String userId);
-
- RequestDetailsWrapper<ServiceDeletionRequestDetails> generateALaCarteServiceDeletionRequest(UUID uuid, ServiceInstantiation details, String userId);
-
- RequestDetailsWrapper<VnfInstantiationRequestDetails> generateVnfInstantiationRequest(Vnf vnfDetails, ModelInfo serviceModelInfo, String serviceInstanceId, String userId);
-
- RequestDetailsWrapper<VfModuleInstantiationRequestDetails> generateVfModuleInstantiationRequest(VfModule vfModuleDetails, ModelInfo serviceModelInfo, String serviceInstanceId, ModelInfo vnfModelInfo, String vnfInstanceId, String vgInstanceId, String userId);
-
- RequestDetailsWrapper<VolumeGroupRequestDetails> generateVolumeGroupInstantiationRequest(VfModule vfModuleDetails, ModelInfo serviceModelInfo, String serviceInstanceId, ModelInfo vnfModelInfo, String vnfInstanceId, String userId);
-
- RequestDetailsWrapper<NetworkInstantiationRequestDetails> generateNetworkInstantiationRequest(Network networkDetails, ModelInfo serviceModelInfo, String serviceInstanceId, String userId);
-
- RequestDetailsWrapper<InstanceGroupInstantiationRequestDetails> generateInstanceGroupInstantiationRequest(InstanceGroup request, ModelInfo serviceModelInfo, String serviceInstanceId, String userId);
-
- List<Map<String,String>> buildVnfInstanceParams(List<Map<String, String>> currentVnfInstanceParams, List<VfModuleMacro> vfModules);
+ boolean isPartOfBulk(UUID jobId);
String getServiceInstantiationPath(ServiceInstantiation serviceInstantiationRequest);
@@ -67,32 +49,34 @@ public interface AsyncInstantiationBusinessLogic {
String getVnfInstantiationPath(String serviceInstanceId);
+ String getVnfDeletionPath(String serviceInstanceId, String vnfInstanceId);
+
String getNetworkInstantiationPath(String serviceInstanceId);
String getVfmoduleInstantiationPath(String serviceInstanceId, String vnfInstanceId);
+ String getVfModuleReplacePath(String serviceInstanceId, String vnfInstanceId, String vfModuleInstanceId);
+
+ String getVfModuleDeletePath(String serviceInstanceId, String vnfInstanceId, String vfModuleInstanceId);
+
String getVolumeGroupInstantiationPath(String serviceInstanceId, String vnfInstanceId);
String getInstanceGroupInstantiationPath();
+ String getInstanceGroupMemberInstantiationPath(String vnfGroupInstanceId);
+
String getInstanceGroupDeletePath(String instanceGroupId);
- String getOrchestrationRequestsPath();
+ String getInstanceGroupMemberDeletePath(String vnfGroupInstanceId);
- ServiceInfo getServiceInfoByJobId(UUID jobUUID);
+ String getNetworkDeletePath(String serviceInstanceId, String networkInstanceId);
- List<JobAuditStatus> getAuditStatuses(UUID jobUUID, JobAuditStatus.SourceStatus source);
+ String getOrchestrationRequestsPath();
ServiceInfo updateServiceInfo(UUID jobUUID, Consumer<ServiceInfo> serviceUpdater);
ServiceInfo updateServiceInfoAndAuditStatus(UUID jobUuid, Job.JobStatus jobStatus);
- void auditVidStatus(UUID jobUUID, Job.JobStatus jobStatus);
-
- void auditMsoStatus(UUID jobUUID, AsyncRequestStatus.Request msoRequestStatus);
-
- void auditMsoStatus(UUID jobUUID, String jobStatus, String requestId, String additionalInfo);
-
Job.JobStatus calcStatus(AsyncRequestStatus asyncRequestStatus);
void handleFailedInstantiation(UUID jobUUID);
@@ -109,5 +93,21 @@ public interface AsyncInstantiationBusinessLogic {
String getUniqueName(String name, ResourceType resourceType);
+ ServiceInstantiation prepareServiceToBeUnique(ServiceInstantiation serviceInstantiation);
+
+ ServiceInstantiation enrichBulkForRetry(ServiceInstantiation serviceInstantiation, UUID jobId);
+
+ List<UUID> retryJob(UUID jobId, String userId);
+
+ List<UUID> retryJob(ServiceInstantiation request, UUID oldJobId, String userId);
+
+ void addResourceInfo(JobSharedData sharedData, Job.JobStatus jobStatus, String instanceId);
+
+ void addFailedResourceInfo(JobSharedData sharedData, RestObject msoResponse);
+
+ void updateResourceInfo(JobSharedData sharedData, Job.JobStatus jobStatus, AsyncRequestStatus message);
+
+ ServiceInstantiation getBulkForRetry(UUID jobId);
+ String getResumeRequestPath(String requestId);
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogicImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogicImpl.java
index 73056db71..92a6d5fd7 100644
--- a/vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogicImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogicImpl.java
@@ -20,18 +20,28 @@
package org.onap.vid.services;
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.common.collect.ImmutableList;
+import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;
+import static org.onap.vid.controller.MsoController.SVC_INSTANCE_ID;
+import static org.onap.vid.controller.MsoController.VNF_INSTANCE_ID;
+import static org.onap.vid.utils.KotlinUtilsKt.JACKSON_OBJECT_MAPPER;
+
import com.google.common.collect.ImmutableMap;
+import java.io.IOException;
+import java.time.ZonedDateTime;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.function.Consumer;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.SessionFactory;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.onap.portalsdk.core.service.DataAccessService;
import org.onap.vid.aai.AaiClientInterface;
import org.onap.vid.aai.ExceptionWithRequestInfo;
import org.onap.vid.aai.model.ResourceType;
-import org.onap.vid.changeManagement.RequestDetailsWrapper;
+import org.onap.vid.dal.AsyncInstantiationRepository;
import org.onap.vid.exceptions.DbFailureUncheckedException;
import org.onap.vid.exceptions.GenericUncheckedException;
import org.onap.vid.exceptions.MaxRetriesException;
@@ -41,37 +51,26 @@ import org.onap.vid.job.Job.JobStatus;
import org.onap.vid.job.JobAdapter;
import org.onap.vid.job.JobType;
import org.onap.vid.job.JobsBrokerService;
+import org.onap.vid.job.impl.JobSharedData;
import org.onap.vid.model.Action;
-import org.onap.vid.model.JobAuditStatus;
import org.onap.vid.model.NameCounter;
+import org.onap.vid.model.ResourceInfo;
import org.onap.vid.model.ServiceInfo;
-import org.onap.vid.model.serviceInstantiation.*;
+import org.onap.vid.model.serviceInstantiation.BaseResource;
+import org.onap.vid.model.serviceInstantiation.ServiceInstantiation;
import org.onap.vid.mso.MsoBusinessLogicImpl;
import org.onap.vid.mso.MsoProperties;
-import org.onap.vid.mso.model.*;
-import org.onap.vid.mso.model.ServiceInstantiationRequestDetails.RequestParameters;
-import org.onap.vid.mso.model.ServiceInstantiationRequestDetails.*;
-import org.onap.vid.mso.model.VfModuleInstantiationRequestDetails.RequestParametersVfModule;
-import org.onap.vid.mso.model.VfModuleInstantiationRequestDetails.UserParamMap;
+import org.onap.vid.mso.MsoUtil;
+import org.onap.vid.mso.RestObject;
import org.onap.vid.mso.rest.AsyncRequestStatus;
-import org.onap.vid.mso.rest.SubscriberInfo;
+import org.onap.vid.mso.rest.RequestStatus;
import org.onap.vid.properties.Features;
import org.onap.vid.utils.DaoUtils;
+import org.onap.vid.utils.TimeUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.togglz.core.manager.FeatureManager;
-import java.sql.Timestamp;
-import java.time.LocalDateTime;
-import java.util.*;
-import java.util.function.Consumer;
-import java.util.stream.Collectors;
-
-import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;
-import static org.onap.vid.controller.MsoController.SVC_INSTANCE_ID;
-import static org.onap.vid.controller.MsoController.VNF_INSTANCE_ID;
-import static org.onap.vid.utils.Logging.debugRequestDetails;
-
@Service
public class AsyncInstantiationBusinessLogicImpl implements
AsyncInstantiationBusinessLogic {
@@ -79,9 +78,6 @@ public class AsyncInstantiationBusinessLogicImpl implements
private static final int MAX_RETRIES_GETTING_COUNTER = 100;
private static final int MAX_RETRIES_GETTING_FREE_NAME_FROM_AAI = 10000;
public static final String NAME_FOR_CHECK_AAI_STATUS = "NAME_FOR_CHECK_AAI_STATUS";
- private static final String VID_SOURCE = "VID";
-
- private final DataAccessService dataAccessService;
private final JobAdapter jobAdapter;
@@ -89,12 +85,17 @@ public class AsyncInstantiationBusinessLogicImpl implements
private final CloudOwnerService cloudOwnerService;
+ private final AsyncInstantiationRepository asyncInstantiationRepository;
+
private SessionFactory sessionFactory;
private AaiClientInterface aaiClient;
private FeatureManager featureManager;
+ private AuditService auditService;
+
+
private int maxRetriesGettingFreeNameFromAai = MAX_RETRIES_GETTING_FREE_NAME_FROM_AAI;
private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(AsyncInstantiationBusinessLogicImpl.class);
@@ -107,51 +108,34 @@ public class AsyncInstantiationBusinessLogicImpl implements
.put("pending", JobStatus.IN_PROGRESS)
.put("pendingmanualtask", JobStatus.PAUSE)
.put("unlocked", JobStatus.IN_PROGRESS)
+ .put("aborted", JobStatus.COMPLETED_WITH_ERRORS)
+ .put("rolledback", JobStatus.FAILED)
+ .put("rolledbacktoassigned", JobStatus.FAILED)
+ .put("rolledbacktocreated", JobStatus.FAILED)
.build();
@Autowired
- public AsyncInstantiationBusinessLogicImpl(DataAccessService dataAccessService,
- JobAdapter jobAdapter,
+ public AsyncInstantiationBusinessLogicImpl(JobAdapter jobAdapter,
JobsBrokerService jobService,
SessionFactory sessionFactory,
AaiClientInterface aaiClient,
FeatureManager featureManager,
- CloudOwnerService cloudOwnerService) {
- this.dataAccessService = dataAccessService;
+ CloudOwnerService cloudOwnerService, AsyncInstantiationRepository asyncInstantiationRepository,
+ AuditService auditService) {
this.jobAdapter = jobAdapter;
this.jobService = jobService;
this.sessionFactory = sessionFactory;
this.aaiClient = aaiClient;
this.featureManager = featureManager;
this.cloudOwnerService = cloudOwnerService;
+ this.asyncInstantiationRepository = asyncInstantiationRepository;
+ this.auditService = auditService;
}
@Override
public List<ServiceInfo> getAllServicesInfo() {
- return dataAccessService.getList(ServiceInfo.class, filterByCreationDateAndNotDeleted(), orderByCreatedDateAndStatus(), null);
- }
-
- private String filterByCreationDateAndNotDeleted() {
- LocalDateTime minus3Months = LocalDateTime.now().minusMonths(3);
- Timestamp filterDate = Timestamp.valueOf(minus3Months);
- return " where" +
- " hidden = false" +
- " and deleted_at is null" + // don't fetch deleted
- " and created >= '" + filterDate + "' ";
- }
-
- private String orderByCreatedDateAndStatus() {
- return " createdBulkDate DESC ,\n" +
- " (CASE jobStatus\n" +
- " WHEN 'COMPLETED' THEN 0\n" +
- " WHEN 'FAILED' THEN 0\n" +
- " WHEN 'COMPLETED_WITH_ERRORS' THEN 0\n" +
- " WHEN 'IN_PROGRESS' THEN 1\n" +
- " WHEN 'PAUSE' THEN 2\n" +
- " WHEN 'PENDING' THEN 3\n" +
- " WHEN 'STOPPED' THEN 3 END),\n" +
- " statusModifiedDate ";
+ return asyncInstantiationRepository.getAllServicesInfo();
}
JobType getJobType(ServiceInstantiation request) {
@@ -171,19 +155,26 @@ public class AsyncInstantiationBusinessLogicImpl implements
@Override
public List<UUID> pushBulkJob(ServiceInstantiation request, String userId) {
+
List<UUID> uuids = new ArrayList<>();
Date createdBulkDate = Calendar.getInstance().getTime();
int bulkSize = request.getBulkSize();
UUID templateId = UUID.randomUUID();
for (int i = 0; i < bulkSize; i++) {
- ServiceInfo.ServiceAction serviceAction = getAction(request);
- JobType jobType = getJobType(request);
- final String optimisticUniqueServiceInstanceName = getOptimisticUniqueServiceInstanceName(request);
- Job job = jobAdapter.createServiceInstantiationJob(jobType, request, templateId, userId, optimisticUniqueServiceInstanceName, i);
- UUID jobId = jobService.add(job);
- dataAccessService.saveDomainObject(createServiceInfo(userId, request, jobId, templateId, createdBulkDate, optimisticUniqueServiceInstanceName, serviceAction), DaoUtils.getPropsMap());
- auditVidStatus(jobId, job.getStatus());
+ ServiceInstantiation requestPerJob = prepareServiceToBeUnique(request);
+ ServiceInfo.ServiceAction serviceAction = getAction(requestPerJob);
+ JobType jobType = getJobType(requestPerJob);
+ final String optimisticUniqueServiceInstanceName = bulkSize>1 ? //only bulk with more than 1 service need to get multiple names
+ getOptimisticUniqueServiceInstanceName(requestPerJob.getInstanceName()) : requestPerJob.getInstanceName();
+ Job job = jobAdapter.createServiceInstantiationJob(jobType, requestPerJob, templateId, userId, request.getTestApi(), optimisticUniqueServiceInstanceName, i);
+ UUID jobId = job.getUuid();
+
+ asyncInstantiationRepository.saveServiceInfo(createServiceInfo(userId, requestPerJob, jobId, templateId, createdBulkDate, optimisticUniqueServiceInstanceName, serviceAction));
+ asyncInstantiationRepository.addJobRequest(jobId, requestPerJob);
+ auditService.auditVidStatus(jobId, job.getStatus());
uuids.add(jobId);
+
+ jobService.add(job);
}
return uuids;
}
@@ -197,8 +188,8 @@ public class AsyncInstantiationBusinessLogicImpl implements
}
- private String getOptimisticUniqueServiceInstanceName(ServiceInstantiation request) {
- return StringUtils.isNotEmpty(request.getInstanceName()) ? getUniqueNameFromDbOnly(request.getInstanceName()) : request.getInstanceName();
+ private String getOptimisticUniqueServiceInstanceName(String instanceName) {
+ return StringUtils.isNotEmpty(instanceName) ? getUniqueNameFromDbOnly(instanceName) : instanceName;
}
protected ServiceInfo createServiceInfo(String userId, ServiceInstantiation serviceInstantiation, UUID jobId, UUID templateId, Date createdBulkDate, String optimisticUniqueServiceInstanceName, ServiceInfo.ServiceAction serviceAction) {
@@ -224,359 +215,32 @@ public class AsyncInstantiationBusinessLogicImpl implements
serviceInstantiation.getModelInfo().getModelName(),
serviceInstantiation.getModelInfo().getModelVersion(),
createdBulkDate,
- serviceAction
- );
- }
-
-
- @Override
- public RequestDetailsWrapper<ServiceInstantiationRequestDetails> generateMacroServiceInstantiationRequest(UUID jobId, ServiceInstantiation payload, String optimisticUniqueServiceInstanceName, String userId) {
- String serviceInstanceName = generateServiceName(jobId, payload, optimisticUniqueServiceInstanceName);
-
- List<ServiceInstantiationService> serviceInstantiationServiceList = generateServiceInstantiationServicesList(payload, serviceInstanceName, createServiceInstantiationVnfList(payload));
-
- RequestParameters requestParameters = new RequestParameters(payload.getSubscriptionServiceType(), false, serviceInstantiationServiceList);
-
- ServiceInstantiationRequestDetails requestDetails = generateServiceInstantiationRequestDetails(payload,requestParameters,serviceInstanceName, userId);
-
- RequestDetailsWrapper<ServiceInstantiationRequestDetails> requestDetailsWrapper = new RequestDetailsWrapper<>(requestDetails);
- debugRequestDetails(requestDetailsWrapper, logger);
-
- return requestDetailsWrapper;
+ serviceAction,
+ false);
}
@Override
- public RequestDetailsWrapper<ServiceInstantiationRequestDetails> generateALaCarteServiceInstantiationRequest(UUID jobId, ServiceInstantiation payload, String optimisticUniqueServiceInstanceName, String userId) {
- String serviceInstanceName = generateServiceName(jobId, payload, optimisticUniqueServiceInstanceName);
-
- List<UserParamNameAndValue> userParams = generateUserParamList();
-
- RequestParameters requestParameters = new RequestParameters(payload.getSubscriptionServiceType(), true, userParams, payload.getTestApi());
-
- ServiceInstantiationRequestDetails requestDetails = generateServiceInstantiationRequestDetails(payload,requestParameters,serviceInstanceName, userId);
-
- RequestDetailsWrapper<ServiceInstantiationRequestDetails> requestDetailsWrapper = new RequestDetailsWrapper<>(requestDetails);
- debugRequestDetails(requestDetailsWrapper, logger);
- return requestDetailsWrapper;
- }
-
-
- @Override
- public RequestDetailsWrapper<ServiceDeletionRequestDetails> generateALaCarteServiceDeletionRequest(UUID jobId, ServiceInstantiation payload, String userId){
-
- ServiceDeletionRequestDetails.RequestParameters requestParameters = new ServiceDeletionRequestDetails.RequestParameters( true, payload.getTestApi());
-
- ServiceDeletionRequestDetails.RequestInfo requestInfo = new ServiceDeletionRequestDetails.RequestInfo(
- VID_SOURCE,
- userId);
-
- ServiceDeletionRequestDetails requestDetails = new ServiceDeletionRequestDetails(payload.getModelInfo(), requestInfo, requestParameters);
-
- RequestDetailsWrapper<ServiceDeletionRequestDetails> requestDetailsWrapper = new RequestDetailsWrapper<>(requestDetails);
- debugRequestDetails(requestDetailsWrapper, logger);
- return requestDetailsWrapper;
+ public boolean isPartOfBulk(UUID jobId) {
+ if (jobId == null) {
+ return false;
}
-
- @Override
- public RequestDetailsWrapper<VnfInstantiationRequestDetails> generateVnfInstantiationRequest(Vnf vnfDetails, ModelInfo serviceModelInfo, String serviceInstanceId, String userId) {
-
- VnfInstantiationRequestDetails.RequestInfo requestInfo = new VnfInstantiationRequestDetails.RequestInfo(
- getUniqueNameIfNeeded(vnfDetails.getInstanceName(), ResourceType.GENERIC_VNF),
- vnfDetails.getProductFamilyId(),
- VID_SOURCE,
- vnfDetails.isRollbackOnFailure(),
- userId);
- CloudConfiguration cloudConfiguration = generateCloudConfiguration(vnfDetails.getLcpCloudRegionId(), vnfDetails.getTenantId());
- VnfInstantiationRequestDetails.Platform platform = new VnfInstantiationRequestDetails.Platform(vnfDetails.getPlatformName());
- VnfInstantiationRequestDetails.LineOfBusiness lineOfBusiness = new VnfInstantiationRequestDetails.LineOfBusiness(vnfDetails.getLineOfBusiness());
- VnfInstantiationRequestDetails.RequestParameters requestParameters = new VnfInstantiationRequestDetails.RequestParameters(generateUserParamList());
- VnfInstantiationRequestDetails.RelatedInstance serviceInstance = new VnfInstantiationRequestDetails.RelatedInstance(serviceModelInfo, serviceInstanceId);
- List<VnfInstantiationRequestDetails.RelatedInstance> relatedInstanceList = new ArrayList<>();
- relatedInstanceList.add(serviceInstance);
- return new RequestDetailsWrapper<>(new VnfInstantiationRequestDetails(vnfDetails.getModelInfo(), cloudConfiguration, requestInfo, platform, lineOfBusiness, relatedInstanceList, requestParameters));
+ ServiceInfo serviceInfo = asyncInstantiationRepository.getServiceInfoByJobId(jobId);
+ UUID templateId = serviceInfo.getTemplateId();
+ if (templateId != null) {
+ return getNumberOfJobsInBulk(templateId) > 1;
}
+ return false;
- @Override
- public RequestDetailsWrapper<VfModuleInstantiationRequestDetails> generateVfModuleInstantiationRequest(VfModule vfModuleDetails, ModelInfo serviceModelInfo, String serviceInstanceId, ModelInfo vnfModelInfo, String vnfInstanceId, String vgInstanceId, String userId) {
-
- VfModuleInstantiationRequestDetails.RequestInfo requestInfo = new VfModuleInstantiationRequestDetails.RequestInfo(
- getUniqueNameIfNeeded(vfModuleDetails.getInstanceName(), ResourceType.VF_MODULE),
- null,
- VID_SOURCE,
- vfModuleDetails.isRollbackOnFailure(),
- userId);
-
- //cloud configuration
- CloudConfiguration cloudConfiguration = generateCloudConfiguration(vfModuleDetails.getLcpCloudRegionId(), vfModuleDetails.getTenantId());
-
- //request parameters
- List<UserParamMap<String, String>> userParams = aggregateAllInstanceParams(extractActualInstanceParams(vfModuleDetails.getInstanceParams()), vfModuleDetails.getSupplementaryParams());
- RequestParametersVfModule requestParameters = new RequestParametersVfModule(userParams, vfModuleDetails.isUsePreload());
-
- //related instance list
- VfModuleInstantiationRequestDetails.RelatedInstance serviceInstance = new VfModuleInstantiationRequestDetails.RelatedInstance(serviceModelInfo, serviceInstanceId);
- VfModuleInstantiationRequestDetails.RelatedInstance vnfInstance = new VfModuleInstantiationRequestDetails.RelatedInstance(vnfModelInfo, vnfInstanceId);
- List<VfModuleInstantiationRequestDetails.RelatedInstance> relatedInstanceList = new ArrayList<>();
- relatedInstanceList.add(serviceInstance);
- relatedInstanceList.add(vnfInstance);
- if (vgInstanceId != null) {
- ModelInfo volumeGroupModel = new ModelInfo();
- volumeGroupModel.setModelType("volumeGroup");
- VfModuleInstantiationRequestDetails.RelatedInstance volumeGroupInstance = new VfModuleInstantiationRequestDetails.RelatedInstance(volumeGroupModel, vgInstanceId, vfModuleDetails.getVolumeGroupInstanceName());
- relatedInstanceList.add(volumeGroupInstance);
- }
-
- return new RequestDetailsWrapper<>(new VfModuleInstantiationRequestDetails(vfModuleDetails.getModelInfo(), cloudConfiguration, requestInfo, relatedInstanceList, requestParameters));
}
- protected CloudConfiguration generateCloudConfiguration(String lcpCloudRegionId, String tenantId) {
- CloudConfiguration cloudConfiguration = new CloudConfiguration();
- cloudConfiguration.setLcpCloudRegionId(lcpCloudRegionId);
- cloudConfiguration.setTenantId(tenantId);
- cloudOwnerService.enrichCloudConfigurationWithCloudOwner(cloudConfiguration, lcpCloudRegionId);
- return cloudConfiguration;
- }
-
- @Override
- public RequestDetailsWrapper<VolumeGroupRequestDetails> generateVolumeGroupInstantiationRequest(VfModule vfModuleDetails, ModelInfo serviceModelInfo, String serviceInstanceId, ModelInfo vnfModelInfo, String vnfInstanceId, String userId) {
- VolumeGroupRequestDetails.RequestInfo requestInfo = new VolumeGroupRequestDetails.RequestInfo(
- getUniqueNameIfNeeded(vfModuleDetails.getVolumeGroupInstanceName(), ResourceType.VOLUME_GROUP),
- null,
- VID_SOURCE,
- vfModuleDetails.isRollbackOnFailure(),
- userId);
- CloudConfiguration cloudConfiguration = generateCloudConfiguration(vfModuleDetails.getLcpCloudRegionId(), vfModuleDetails.getTenantId());
-
- List<UserParamMap<String, String>> userParams = aggregateAllInstanceParams(extractActualInstanceParams(vfModuleDetails.getInstanceParams()), vfModuleDetails.getSupplementaryParams());
- RequestParametersVfModule requestParameters = new RequestParametersVfModule(userParams, vfModuleDetails.isUsePreload());
-
- VfModuleInstantiationRequestDetails.RelatedInstance serviceInstance = new VfModuleInstantiationRequestDetails.RelatedInstance(serviceModelInfo, serviceInstanceId);
- VfModuleInstantiationRequestDetails.RelatedInstance vnfInstance = new VfModuleInstantiationRequestDetails.RelatedInstance(vnfModelInfo, vnfInstanceId);
- List<VfModuleInstantiationRequestDetails.RelatedInstance> relatedInstancs = ImmutableList.of(serviceInstance, vnfInstance);
-
- ModelInfo modelInfo = vfModuleDetails.getModelInfo();
- modelInfo.setModelType("volumeGroup");
- return new RequestDetailsWrapper<>(new VolumeGroupRequestDetails(modelInfo, cloudConfiguration, requestInfo, relatedInstancs, requestParameters));
- }
-
- protected List<UserParamMap<String, String>> aggregateAllInstanceParams(Map<String, String> instanceParams, Map<String, String> supplementaryParams) {
- Map<String, String> instanceParamsFinal = defaultIfNull(instanceParams, new HashMap<>());
- Map<String, String> supplementaryParamsFinal = defaultIfNull(supplementaryParams, new HashMap<>());
-
- if (!(instanceParamsFinal.isEmpty() && supplementaryParamsFinal.isEmpty())) {
- //remove duplicate keys from instanceParams if exist in supplementaryParams
- instanceParamsFinal = instanceParams.entrySet().stream().filter(m->
- !supplementaryParamsFinal.containsKey(m.getKey())
- ).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
-
- //aggregate the 2 collections and format them as UserParamMap
- UserParamMap<String, String> aggregatedParams = new UserParamMap<>();
- aggregatedParams.putAll(instanceParamsFinal);
- aggregatedParams.putAll(supplementaryParamsFinal);
-
- return ImmutableList.of(aggregatedParams);
- }
-
- return Collections.emptyList();
- }
-
- @Override
- public RequestDetailsWrapper<NetworkInstantiationRequestDetails> generateNetworkInstantiationRequest(Network networkDetails, ModelInfo serviceModelInfo, String serviceInstanceId, String userId) {
-
- NetworkInstantiationRequestDetails.RequestInfo requestInfo = new NetworkInstantiationRequestDetails.RequestInfo(
- getUniqueNameIfNeeded(networkDetails.getInstanceName(), ResourceType.L3_NETWORK),
- networkDetails.getProductFamilyId(),
- VID_SOURCE,
- networkDetails.isRollbackOnFailure(),
- userId);
- CloudConfiguration cloudConfiguration = generateCloudConfiguration(networkDetails.getLcpCloudRegionId(), networkDetails.getTenantId());
- NetworkInstantiationRequestDetails.Platform platform = new NetworkInstantiationRequestDetails.Platform(networkDetails.getPlatformName());
- NetworkInstantiationRequestDetails.LineOfBusiness lineOfBusiness = new NetworkInstantiationRequestDetails.LineOfBusiness(networkDetails.getLineOfBusiness());
- NetworkInstantiationRequestDetails.RequestParameters requestParameters = new NetworkInstantiationRequestDetails.RequestParameters(generateUserParamList());
- NetworkInstantiationRequestDetails.RelatedInstance serviceInstance = new NetworkInstantiationRequestDetails.RelatedInstance(serviceModelInfo, serviceInstanceId);
- List<NetworkInstantiationRequestDetails.RelatedInstance> relatedInstanceList = new ArrayList<>();
- relatedInstanceList.add(serviceInstance);
- return new RequestDetailsWrapper<>(new NetworkInstantiationRequestDetails(networkDetails.getModelInfo(), cloudConfiguration, requestInfo, platform, lineOfBusiness, relatedInstanceList, requestParameters));
- }
-
- @Override
- public RequestDetailsWrapper<InstanceGroupInstantiationRequestDetails> generateInstanceGroupInstantiationRequest(InstanceGroup instanceGroupDetails, ModelInfo serviceModelInfo, String serviceInstanceId, String userId) {
- InstanceGroupInstantiationRequestDetails.RequestInfo requestInfo = new InstanceGroupInstantiationRequestDetails.RequestInfo(
- getUniqueNameIfNeeded(instanceGroupDetails.getInstanceName(), ResourceType.INSTANCE_GROUP),
- null,
- "VID",
- instanceGroupDetails.isRollbackOnFailure(),
- userId);
- InstanceGroupInstantiationRequestDetails.RequestParameters requestParameters = new InstanceGroupInstantiationRequestDetails.RequestParameters(generateUserParamList());
- InstanceGroupInstantiationRequestDetails.RelatedInstance serviceInstance = new InstanceGroupInstantiationRequestDetails.RelatedInstance(serviceModelInfo, serviceInstanceId);
- List<InstanceGroupInstantiationRequestDetails.RelatedInstance> relatedInstanceList = ImmutableList.of(serviceInstance);
- return new RequestDetailsWrapper<>(new InstanceGroupInstantiationRequestDetails(instanceGroupDetails.getModelInfo(), requestInfo, relatedInstanceList, requestParameters));
- }
-
- // TODO
- private List<UserParamNameAndValue> generateUserParamList() {
- return Collections.emptyList();
- }
-
- protected List<ServiceInstantiationService> generateServiceInstantiationServicesList(ServiceInstantiation payload, String serviceInstanceName, ServiceInstantiationVnfList vnfList) {
- List<ServiceInstantiationService> serviceInstantiationServiceList = new LinkedList<>();
- List<Map<String, String>> unFilteredInstanceParams = defaultIfNull(payload.getInstanceParams(), Collections.emptyList());
- List<Map<String, String>> filteredInstanceParams = removeUnNeededParams(unFilteredInstanceParams);
- ServiceInstantiationService serviceInstantiationService = new ServiceInstantiationService(
- payload.getModelInfo(),
- serviceInstanceName,
- filteredInstanceParams,
- vnfList
+ private int getNumberOfJobsInBulk(UUID templateId) {
+ String hqlSelectJob = "from JobDaoImpl where templateId = :templateId";
+ return DaoUtils.tryWithSessionAndTransaction(sessionFactory, session ->
+ session.createQuery(hqlSelectJob)
+ .setText("templateId", templateId.toString())
+ .list()
+ .size()
);
- serviceInstantiationServiceList.add(serviceInstantiationService);
- return serviceInstantiationServiceList;
- }
-
- private ServiceInstantiationRequestDetails generateServiceInstantiationRequestDetails(ServiceInstantiation payload, RequestParameters requestParameters, String serviceInstanceName, String userId) {
- ServiceInstantiationRequestDetails.RequestInfo requestInfo = new ServiceInstantiationRequestDetails.RequestInfo(serviceInstanceName,
- payload.getProductFamilyId(),
- VID_SOURCE,
- payload.isRollbackOnFailure(),
- userId);
- ServiceInstantiationOwningEntity owningEntity = new ServiceInstantiationOwningEntity(payload.getOwningEntityId(), payload.getOwningEntityName());
- SubscriberInfo subscriberInfo = generateSubscriberInfo(payload);
- Project project = payload.getProjectName() != null ? new Project(payload.getProjectName()) : null;
- return new ServiceInstantiationRequestDetails(payload.getModelInfo(), owningEntity, subscriberInfo, project, requestInfo, requestParameters);
- }
-
-
- protected SubscriberInfo generateSubscriberInfo(ServiceInstantiation payload) {
- SubscriberInfo subscriberInfo = new SubscriberInfo();
- subscriberInfo.setGlobalSubscriberId(payload.getGlobalSubscriberId());
- return subscriberInfo;
- }
-
- protected String generateServiceName(UUID jobId, ServiceInstantiation payload, String optimisticUniqueServiceInstanceName) {
- String serviceInstanceName = null;
- if(StringUtils.isNotEmpty(optimisticUniqueServiceInstanceName)) {
- serviceInstanceName = peekServiceName(jobId, payload, optimisticUniqueServiceInstanceName);
- }
- return serviceInstanceName;
- }
-
- protected String peekServiceName(UUID jobId, ServiceInstantiation payload, String optimisticUniqueServiceInstanceName) {
- String serviceInstanceName;
- // unique name already exist in service info. If it's free in AAI we use it
- if (isNameFreeInAai(optimisticUniqueServiceInstanceName, ResourceType.SERVICE_INSTANCE)) {
- serviceInstanceName = optimisticUniqueServiceInstanceName;
- }
- //otherwise we used the original service instance name (from payload) to get a new unique name from DB and AAI
- else {
- serviceInstanceName = getUniqueName(payload.getInstanceName(), ResourceType.SERVICE_INSTANCE);
- }
-
- //update serviceInfo with new name if needed
- try {
- updateServiceInfo(jobId, x -> x.setServiceInstanceName(serviceInstanceName));
- } catch (Exception e) {
- logger.error("Failed updating service name {} in serviceInfo", serviceInstanceName, e);
- }
-
- return serviceInstanceName;
- }
-
- @Override
- public List<Map<String,String>> buildVnfInstanceParams(List<Map<String, String>> currentVnfInstanceParams, List<VfModuleMacro> vfModules){
- List<Map<String, String>> filteredVnfInstanceParams = removeUnNeededParams(currentVnfInstanceParams);
-
- if (!featureManager.isActive(Features.FLAG_SHIFT_VFMODULE_PARAMS_TO_VNF)) {
- return filteredVnfInstanceParams;
- }
-
- Map<String,String> vnfInstanceParams = extractActualInstanceParams(filteredVnfInstanceParams);
- vfModules.stream()
- .map(x->extractActualInstanceParams(x.getInstanceParams()))
- .forEach(vnfInstanceParams::putAll);
- return vnfInstanceParams.isEmpty() ? Collections.emptyList() : ImmutableList.of(vnfInstanceParams);
- }
-
- //Make sure we always get a one Map from InstanceParams
- private Map<String, String> extractActualInstanceParams(List<Map<String, String>> originalInstanceParams) {
- if (originalInstanceParams==null || originalInstanceParams.isEmpty() || originalInstanceParams.get(0)==null) {
- return new HashMap<>();
- }
- return originalInstanceParams.get(0);
- }
-
- private List<Map<String, String>> removeUnNeededParams(List<Map<String, String>> instanceParams) {
- List<String> keysToRemove = new ArrayList<>();
- if (instanceParams == null || instanceParams.isEmpty()) {
- return Collections.emptyList();
- }
-
- for (String key : instanceParams.get(0).keySet()) {
- for (String paramToIgnore : PARAMS_TO_IGNORE)
- if ((key.equalsIgnoreCase(paramToIgnore))) {
- keysToRemove.add(key);
- }
- }
-
- Map<String, String> result = instanceParams.get(0).entrySet().stream()
- .filter(entry->!keysToRemove.contains(entry.getKey()))
- .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
-
- return result.isEmpty() ? Collections.emptyList() : Collections.singletonList(result);
- }
-
- private ServiceInstantiationVnfList createServiceInstantiationVnfList(ServiceInstantiation payload) {
- CloudConfiguration cloudConfiguration = generateCloudConfiguration(payload.getLcpCloudRegionId(), payload.getTenantId());
-
- Map<String, Vnf> vnfs = payload.getVnfs();
- List<ServiceInstantiationVnf> vnfList = new ArrayList<>();
- for (Vnf vnf : vnfs.values()) {
- Map<String, Map<String, VfModule>> vfModules = vnf.getVfModules();
- List<VfModuleMacro> convertedUnFilteredVfModules = convertVfModuleMapToList(vfModules);
- List<VfModuleMacro> filteredVfModules = filterInstanceParamsFromVfModuleAndUniqueNames(convertedUnFilteredVfModules);
- ServiceInstantiationVnf serviceInstantiationVnf = new ServiceInstantiationVnf(
- vnf.getModelInfo(),
- cloudConfiguration,
- vnf.getPlatformName(),
- vnf.getLineOfBusiness(),
- payload.getProductFamilyId(),
- buildVnfInstanceParams(vnf.getInstanceParams(), filteredVfModules),
- filteredVfModules,
- getUniqueNameIfNeeded(vnf.getInstanceName(), ResourceType.GENERIC_VNF)
- );
- vnfList.add(serviceInstantiationVnf);
- }
-
- return new ServiceInstantiationVnfList(vnfList);
- }
-
- private List<VfModuleMacro> convertVfModuleMapToList(Map<String, Map<String, VfModule>> vfModules) {
- ObjectMapper mapper = new ObjectMapper();
- return vfModules.values().stream().flatMap(vfModule ->
- vfModule.values().stream().map(item -> {
- List<UserParamMap<String, String>> aggregatedParams = aggregateAllInstanceParams(extractActualInstanceParams(item.getInstanceParams()), item.getSupplementaryParams());
- List<Map<String, String>> aggregatedParamsConverted = mapper.convertValue(aggregatedParams, new TypeReference<List<Map>>(){});
-
- return new VfModuleMacro(
- item.getModelInfo(),
- item.getInstanceName(),
- item.getVolumeGroupInstanceName(),
- aggregatedParamsConverted);
- }
- )
- ).collect(Collectors.toList());
- }
-
- private List<VfModuleMacro> filterInstanceParamsFromVfModuleAndUniqueNames(List<VfModuleMacro> unFilteredVfModules) {
- return unFilteredVfModules.stream().map(vfModule ->
- new VfModuleMacro(
- vfModule.getModelInfo(),
- getUniqueNameIfNeeded(vfModule.getInstanceName(), ResourceType.VF_MODULE),
- getUniqueNameIfNeeded(vfModule.getVolumeGroupInstanceName(), ResourceType.VOLUME_GROUP),
- removeUnNeededParams(vfModule.getInstanceParams())))
- .collect(Collectors.toList());
- }
-
- private String getUniqueNameIfNeeded(String name, ResourceType resourceType) {
- return StringUtils.isNotEmpty(name) ? getUniqueName(name, resourceType) : null;
}
@Override
@@ -600,6 +264,13 @@ public class AsyncInstantiationBusinessLogicImpl implements
}
@Override
+ public String getVnfDeletionPath(String serviceInstanceId, String vnfInstanceId) {
+ return (MsoBusinessLogicImpl.validateEndpointPath(MsoProperties.MSO_REST_API_VNF_INSTANCE)
+ + '/' + vnfInstanceId)
+ .replaceFirst(SVC_INSTANCE_ID, serviceInstanceId).replaceFirst(VNF_INSTANCE_ID, vnfInstanceId);
+ }
+
+ @Override
public String getNetworkInstantiationPath(String serviceInstanceId) {
return MsoBusinessLogicImpl.validateEndpointPath(MsoProperties.MSO_REST_API_NETWORK_INSTANCE).
replaceFirst(SVC_INSTANCE_ID, serviceInstanceId);
@@ -613,6 +284,24 @@ public class AsyncInstantiationBusinessLogicImpl implements
}
@Override
+ public String getVfModuleReplacePath(String serviceInstanceId, String vnfInstanceId, String vfModuleInstanceId)
+ {
+ return MsoBusinessLogicImpl.validateEndpointPath(MsoProperties.MSO_REST_API_VF_MODULE_INSTANCE)
+ .replaceFirst(SVC_INSTANCE_ID, serviceInstanceId)
+ .replaceFirst(VNF_INSTANCE_ID, vnfInstanceId)
+ + "/" + vfModuleInstanceId
+ + "/replace";
+ }
+
+ @Override
+ public String getVfModuleDeletePath(String serviceInstanceId, String vnfInstanceId, String vfModuleInstanceId) {
+ return MsoBusinessLogicImpl.validateEndpointPath(MsoProperties.MSO_REST_API_VF_MODULE_INSTANCE)
+ .replaceFirst(SVC_INSTANCE_ID, serviceInstanceId)
+ .replaceFirst(VNF_INSTANCE_ID, vnfInstanceId)
+ + "/" + vfModuleInstanceId;
+ }
+
+ @Override
public String getVolumeGroupInstantiationPath(String serviceInstanceId, String vnfInstanceId) {
return MsoBusinessLogicImpl.validateEndpointPath(MsoProperties.MSO_REST_API_VOLUME_GROUP_INSTANCE)
.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId)
@@ -625,79 +314,64 @@ public class AsyncInstantiationBusinessLogicImpl implements
}
@Override
- public String getInstanceGroupDeletePath(String instanceGroupId) {
+ public String getInstanceGroupMemberInstantiationPath(String vnfGroupInstanceId) {
return MsoBusinessLogicImpl.validateEndpointPath(MsoProperties.MSO_REST_API_INSTANCE_GROUP)
- + '/' + instanceGroupId;
+ + '/' + vnfGroupInstanceId + "/addMembers";
}
@Override
- public String getOrchestrationRequestsPath() {
- return MsoBusinessLogicImpl.validateEndpointPath(MsoProperties.MSO_REST_API_GET_ORC_REQ);
+ public String getInstanceGroupDeletePath(String instanceGroupId) {
+ return MsoBusinessLogicImpl.validateEndpointPath(MsoProperties.MSO_REST_API_INSTANCE_GROUP)
+ + '/' + instanceGroupId;
}
@Override
- public ServiceInfo updateServiceInfo(UUID jobUUID, Consumer<ServiceInfo> serviceUpdater) {
- ServiceInfo serviceInfo = getServiceInfoByJobId(jobUUID);
- serviceUpdater.accept(serviceInfo);
- dataAccessService.saveDomainObject(serviceInfo, DaoUtils.getPropsMap());
- return serviceInfo;
+ public String getInstanceGroupMemberDeletePath(String vnfGroupInstanceId){
+ return MsoBusinessLogicImpl.validateEndpointPath(MsoProperties.MSO_REST_API_INSTANCE_GROUP)
+ + '/' + vnfGroupInstanceId + "/removeMembers";
}
@Override
- public ServiceInfo updateServiceInfoAndAuditStatus(UUID jobUuid, JobStatus jobStatus) {
- auditVidStatus(jobUuid,jobStatus);
- return updateServiceInfo(jobUuid, x -> setServiceInfoStatus(x, jobStatus));
- }
-
- private void setServiceInfoStatus(ServiceInfo serviceInfo, JobStatus jobStatus) {
- serviceInfo.setJobStatus(jobStatus);
- serviceInfo.setStatusModifiedDate(new Date());
- }
-
- public ServiceInfo getServiceInfoByJobId(UUID jobUUID) {
- List<ServiceInfo> serviceInfoList = dataAccessService.getList(ServiceInfo.class, String.format(" where jobId = '%s' ", jobUUID), null, null);
- if (serviceInfoList.size() != 1) {
- throw new GenericUncheckedException("Failed to retrieve job with uuid " + jobUUID + " from ServiceInfo table. Instances found: " + serviceInfoList.size());
- }
- return serviceInfoList.get(0);
+ public String getNetworkDeletePath(String serviceInstanceId, String networkInstanceId) {
+ return (MsoBusinessLogicImpl.validateEndpointPath(MsoProperties.MSO_REST_API_NETWORK_INSTANCE)
+ + "/" + networkInstanceId)
+ .replaceFirst(SVC_INSTANCE_ID, serviceInstanceId);
}
- public List<JobAuditStatus> getAuditStatuses(UUID jobUUID, JobAuditStatus.SourceStatus source) {
- return dataAccessService.getList(
- JobAuditStatus.class,
- String.format(" where SOURCE = '%s' and JOB_ID = '%s'",source, jobUUID),
- " CREATED_DATE ", null);
- }
-
- private JobAuditStatus getLatestAuditStatus(UUID jobUUID, JobAuditStatus.SourceStatus source){
- List<JobAuditStatus> list = getAuditStatuses(jobUUID,source);
- return !list.isEmpty() ? list.get(list.size()-1) : null;
+ @Override
+ public String getResumeRequestPath(String requestId) {
+ return MsoBusinessLogicImpl.validateEndpointPath("mso.restapi.resume.orc.req")
+ .replaceFirst("<request_id>", requestId);
}
@Override
- public void auditVidStatus(UUID jobUUID, JobStatus jobStatus){
- JobAuditStatus vidStatus = new JobAuditStatus(jobUUID, jobStatus.toString(), JobAuditStatus.SourceStatus.VID);
- auditStatus(vidStatus);
+ public String getOrchestrationRequestsPath() {
+ return MsoBusinessLogicImpl.validateEndpointPath(MsoProperties.MSO_REST_API_GET_ORC_REQ);
}
@Override
- public void auditMsoStatus(UUID jobUUID, AsyncRequestStatus.Request msoRequestStatus){
- auditMsoStatus(jobUUID, msoRequestStatus.requestStatus.getRequestState(), msoRequestStatus.requestId, msoRequestStatus.requestStatus.getStatusMessage());
+ public ServiceInfo updateServiceInfo(UUID jobUUID, Consumer<ServiceInfo> serviceUpdater) {
+ ServiceInfo serviceInfo = asyncInstantiationRepository.getServiceInfoByJobId(jobUUID);
+ serviceUpdater.accept(serviceInfo);
+ asyncInstantiationRepository.saveServiceInfo(serviceInfo);
+ return serviceInfo;
}
@Override
- public void auditMsoStatus(UUID jobUUID, String jobStatus, String requestId, String additionalInfo){
- JobAuditStatus msoStatus = new JobAuditStatus(jobUUID, jobStatus, JobAuditStatus.SourceStatus.MSO,
- requestId != null ? UUID.fromString(requestId) : null,
- additionalInfo);
- auditStatus(msoStatus);
+ public ServiceInfo updateServiceInfoAndAuditStatus(UUID jobUuid, JobStatus jobStatus) {
+ auditService.auditVidStatus(jobUuid, jobStatus);
+ return updateServiceInfo(jobUuid, x -> setServiceInfoStatus(x, jobStatus));
}
- private void auditStatus(JobAuditStatus jobAuditStatus){
- JobAuditStatus latestStatus = getLatestAuditStatus(jobAuditStatus.getJobId(), jobAuditStatus.getSource());
- if (latestStatus == null || !latestStatus.equals(jobAuditStatus))
- dataAccessService.saveDomainObject(jobAuditStatus, DaoUtils.getPropsMap());
+ private boolean isRetryEnabledForStatus(JobStatus jobStatus) {
+ return featureManager.isActive(Features.FLAG_1902_RETRY_JOB) &&
+ (jobStatus==JobStatus.COMPLETED_WITH_ERRORS || jobStatus==JobStatus.FAILED);
+ }
+ private void setServiceInfoStatus(ServiceInfo serviceInfo, JobStatus jobStatus) {
+ serviceInfo.setJobStatus(jobStatus);
+ serviceInfo.setStatusModifiedDate(new Date());
+ serviceInfo.setRetryEnabled(isRetryEnabledForStatus(jobStatus));
}
public Job.JobStatus calcStatus(AsyncRequestStatus asyncRequestStatus) {
@@ -708,13 +382,8 @@ public class AsyncInstantiationBusinessLogicImpl implements
@Override
public void handleFailedInstantiation(UUID jobUUID) {
- ServiceInfo serviceInfo = updateServiceInfoAndAuditStatus(jobUUID, JobStatus.FAILED);
- List<ServiceInfo> serviceInfoList = dataAccessService.getList(
- ServiceInfo.class,
- String.format(" where templateId = '%s' and jobStatus = '%s'",
- serviceInfo.getTemplateId(),
- JobStatus.PENDING),
- null, null);
+ ServiceInfo serviceInfo = asyncInstantiationRepository.getServiceInfoByJobId(jobUUID);
+ List<ServiceInfo> serviceInfoList = asyncInstantiationRepository.getServiceInfoByTemplateIdAndJobStatus(serviceInfo.getTemplateId(), JobStatus.PENDING);
serviceInfoList.forEach(si -> updateServiceInfoAndAuditStatus(si.getJobId(), JobStatus.STOPPED));
}
@@ -727,16 +396,16 @@ public class AsyncInstantiationBusinessLogicImpl implements
@Override
public void hideServiceInfo(UUID jobUUID) {
- ServiceInfo serviceInfo = getServiceInfoByJobId(jobUUID);
+ ServiceInfo serviceInfo = asyncInstantiationRepository.getServiceInfoByJobId(jobUUID);
if (!serviceInfo.getJobStatus().isFinal()) {
- String message = String.format( "jobId %s: Service status does not allow hide service, status = %s",
+ String message = String.format("jobId %s: Service status does not allow hide service, status = %s",
serviceInfo.getJobId(),
serviceInfo.getJobStatus());
logger.error(EELFLoggerDelegate.errorLogger, message);
throw new OperationNotAllowedException(message);
}
serviceInfo.setHidden(true);
- dataAccessService.saveDomainObject(serviceInfo, DaoUtils.getPropsMap());
+ asyncInstantiationRepository.saveServiceInfo(serviceInfo);
}
@Override
@@ -818,7 +487,84 @@ public class AsyncInstantiationBusinessLogicImpl implements
}
}
- throw new MaxRetriesException("find unused name for "+name, getMaxRetriesGettingFreeNameFromAai());
+ throw new MaxRetriesException("can't find unused name for "+name, getMaxRetriesGettingFreeNameFromAai());
+ }
+
+ @Override
+ public ServiceInstantiation prepareServiceToBeUnique(ServiceInstantiation serviceInstantiation) {
+ try {
+ ServiceInstantiation clonedServiceInstantiation = JACKSON_OBJECT_MAPPER.readValue(
+ JACKSON_OBJECT_MAPPER.writeValueAsBytes(serviceInstantiation), ServiceInstantiation.class);
+ clonedServiceInstantiation.setBulkSize(1);
+ return replaceAllTrackById(clonedServiceInstantiation);
+ } catch (IOException e) {
+ throw new GenericUncheckedException(e);
+ }
+
+ }
+
+ private<T extends BaseResource> T replaceAllTrackById(T resource) {
+ resource.setTrackById(UUID.randomUUID().toString());
+ resource.getChildren().forEach(this::replaceAllTrackById);
+ return resource;
+ }
+
+ @Override
+ public List<UUID> retryJob(ServiceInstantiation request, UUID jobId, String userId ) {
+ updateServiceInfo(jobId, si->si.setRetryEnabled(false));
+ return pushBulkJob(request, userId);
+ }
+
+ @Override
+ public List<UUID> retryJob(UUID jobId, String userId) {
+ ServiceInstantiation serviceInstantiationRequest = asyncInstantiationRepository.getJobRequest(jobId);
+ enrichBulkForRetry(serviceInstantiationRequest, jobId);
+
+ try {
+ logger.debug(EELFLoggerDelegate.debugLogger, "retry ServiceInstantiation request: "+
+ JACKSON_OBJECT_MAPPER.writeValueAsString(serviceInstantiationRequest));
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, "failed to log retry of ServiceInstantiation request ", e);
+ }
+ return retryJob(serviceInstantiationRequest, jobId, userId);
+ }
+
+ @Override
+ public ServiceInstantiation getBulkForRetry(UUID jobId) {
+ return enrichBulkForRetry( asyncInstantiationRepository.getJobRequest(jobId), jobId);
+ }
+
+ @Override
+ public void addResourceInfo(JobSharedData sharedData, Job.JobStatus jobStatus, String instanceId) {
+ String trackById = ((BaseResource) sharedData.getRequest()).getTrackById();
+ ResourceInfo resourceInfo = new ResourceInfo(trackById, sharedData.getRootJobId(), instanceId, jobStatus, null);
+ asyncInstantiationRepository.saveResourceInfo(resourceInfo);
+ }
+
+ @Override
+ public void addFailedResourceInfo(JobSharedData sharedData, RestObject msoResponse) {
+ String trackById = ((BaseResource) sharedData.getRequest()).getTrackById();
+ String errorMessage = MsoUtil.formatExceptionAdditionalInfo(msoResponse.getStatusCode(), msoResponse.getRaw());
+ AsyncRequestStatus asyncRequestStatus = convertMessageToAsyncRequestStatus(errorMessage);
+ ResourceInfo resourceInfo = new ResourceInfo(trackById, sharedData.getRootJobId(), null, JobStatus.FAILED, asyncRequestStatus);
+
+ asyncInstantiationRepository.saveResourceInfo(resourceInfo);
+ }
+
+ @Override
+ public void updateResourceInfo(JobSharedData sharedData, JobStatus jobStatus, AsyncRequestStatus message) {
+ ResourceInfo resourceInfo = asyncInstantiationRepository.getResourceInfoByTrackId(((BaseResource) sharedData.getRequest()).getTrackById());
+ resourceInfo.setJobStatus(jobStatus);
+ if (jobStatus.isFailure()) {
+ resourceInfo.setErrorMessage(message);
+ }
+ asyncInstantiationRepository.saveResourceInfo(resourceInfo);
+ }
+
+ public AsyncRequestStatus convertMessageToAsyncRequestStatus(String message) {
+ RequestStatus requestStatus = new RequestStatus("FAILED", message, TimeUtils.zonedDateTimeToString(ZonedDateTime.now()));
+ AsyncRequestStatus.Request request = new AsyncRequestStatus.Request(requestStatus);
+ return new AsyncRequestStatus(request);
}
protected String getUniqueNameFromDbOnly(String name) {
@@ -835,4 +581,35 @@ public class AsyncInstantiationBusinessLogicImpl implements
return !aaiClient.isNodeTypeExistsByName(name, resourceType);
}
+ @Override
+ public ServiceInstantiation enrichBulkForRetry(ServiceInstantiation serviceInstantiation, UUID jobId){
+ Map<String, ResourceInfo> resourceInfoByTrackId = asyncInstantiationRepository.getResourceInfoByRootJobId(jobId);
+
+ return setResourceStatus(resourceInfoByTrackId, serviceInstantiation);
+ }
+
+ protected String readStatusMsg(ResourceInfo resourceInfo){
+ if(resourceInfo!=null && resourceInfo.getErrorMessage()!=null && resourceInfo.getErrorMessage().request != null &&resourceInfo.getErrorMessage().request.requestStatus != null ) {
+ return resourceInfo.getErrorMessage().request.requestStatus.getStatusMessage();
+ }
+ return null;
+ }
+
+ private<T extends BaseResource> T setResourceStatus(Map<String, ResourceInfo> resourceInfoByTrackId, T resource) {
+ ResourceInfo resourceInfo = resourceInfoByTrackId.get(resource.getTrackById());
+ if(resourceInfo != null) {
+ boolean failed = resourceInfo.getJobStatus().isFailure();
+ resource.setIsFailed(failed);
+ resource.setStatusMessage(readStatusMsg(resourceInfo));
+ if (!failed) {
+ // if(resource.getAction().equals(Action.Delete)){
+ // TODO not yet implemented- completed after delete should remove the node
+ resource.setAction(Action.None);
+ resource.setInstanceId(resourceInfo.getInstanceId());
+ }
+ }
+ resource.getChildren().forEach(child -> setResourceStatus(resourceInfoByTrackId, child));
+ return resource;
+ }
+
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/AuditService.java b/vid-app-common/src/main/java/org/onap/vid/services/AuditService.java
index ef60c321d..6370b1862 100644
--- a/vid-app-common/src/main/java/org/onap/vid/services/AuditService.java
+++ b/vid-app-common/src/main/java/org/onap/vid/services/AuditService.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,19 +20,31 @@
package org.onap.vid.services;
-import org.onap.vid.model.JobAuditStatus;
-
import java.util.List;
import java.util.UUID;
+import org.onap.vid.job.Job;
+import org.onap.vid.model.JobAuditStatus;
+import org.onap.vid.mso.rest.AsyncRequestStatus;
public interface AuditService {
void setFailedAuditStatusFromMso(UUID jobUuid, String requestId, int statusCode, String msoResponse);
-
List<JobAuditStatus> getAuditStatusFromMsoByRequestId(UUID jobId, UUID requestId);
- List<JobAuditStatus> getAuditStatusFromMsoByServiceInstanceId(UUID jobId, UUID serviceInstanceId);
+ List<JobAuditStatus> getAuditStatusFromMsoByInstanceId(JobAuditStatus.ResourceTypeFilter resourceTypeFilter, UUID instanceId, UUID jobId);
List<JobAuditStatus> getAuditStatusFromMsoByJobId(UUID jobId);
+
+ void auditVidStatus(UUID jobUUID, Job.JobStatus jobStatus);
+
+ void auditMsoStatus(UUID jobUUID, AsyncRequestStatus.Request msoRequestStatus);
+
+ void auditMsoStatus(UUID jobUUID, String jobStatus, String requestId, String additionalInfo);
+
+ List<AsyncRequestStatus.Request> retrieveRequestsFromMsoByServiceIdAndRequestTypeAndScope(String instanceId, String requestType, String modelType);
+
+ List<JobAuditStatus> getAuditStatuses(UUID jobUUID, JobAuditStatus.SourceStatus source);
+
+ JobAuditStatus getResourceAuditStatus(String trackById);
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/AuditServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/AuditServiceImpl.java
index 7fb126e23..287a771d3 100644
--- a/vid-app-common/src/main/java/org/onap/vid/services/AuditServiceImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/services/AuditServiceImpl.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,22 +20,20 @@
package org.onap.vid.services;
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.apache.commons.lang3.StringUtils;
-import org.onap.vid.exceptions.GenericUncheckedException;
+import static org.apache.commons.lang3.ObjectUtils.notEqual;
+
+import org.jetbrains.annotations.NotNull;
+import org.onap.vid.dal.AsyncInstantiationRepository;
+import org.onap.vid.job.Job;
import org.onap.vid.model.JobAuditStatus;
-import org.onap.vid.mso.MsoBusinessLogicImpl;
-import org.onap.vid.mso.MsoProperties;
-import org.onap.vid.mso.RestMsoImplementation;
-import org.onap.vid.mso.RestObject;
+import org.onap.vid.mso.*;
import org.onap.vid.mso.rest.AsyncRequestStatus;
import org.onap.vid.mso.rest.AsyncRequestStatusList;
import org.springframework.stereotype.Service;
import javax.inject.Inject;
-import java.io.IOException;
import java.util.List;
+import java.util.Objects;
import java.util.UUID;
import java.util.stream.Collectors;
@@ -43,41 +41,20 @@ import java.util.stream.Collectors;
@Service
public class AuditServiceImpl implements AuditService{
- private final AsyncInstantiationBusinessLogic asyncInstantiationBL;
private final RestMsoImplementation restMso;
+ private final AsyncInstantiationRepository asyncInstantiationRepository;
@Inject
- public AuditServiceImpl(AsyncInstantiationBusinessLogic asyncInstantiationBL, RestMsoImplementation restMso) {
- this.asyncInstantiationBL = asyncInstantiationBL;
+ public AuditServiceImpl(RestMsoImplementation restMso, AsyncInstantiationRepository asyncInstantiationRepository) {
this.restMso = restMso;
+ this.asyncInstantiationRepository = asyncInstantiationRepository;
}
@Override
public void setFailedAuditStatusFromMso(UUID jobUuid, String requestId, int statusCode, String msoResponse){
final String failedMsoRequestStatus = "FAILED";
- String additionalInfo = formatExceptionAdditionalInfo(statusCode, msoResponse);
- asyncInstantiationBL.auditMsoStatus(jobUuid, failedMsoRequestStatus, requestId, additionalInfo);
- }
-
- private String formatExceptionAdditionalInfo(int statusCode, String msoResponse) {
- String errorMsg = "Http Code:" + statusCode;
- if (!StringUtils.isEmpty(msoResponse)) {
- String filteredJson;
- try {
- ObjectMapper objectMapper = new ObjectMapper();
- filteredJson = StringUtils.defaultIfEmpty(
- objectMapper.readTree(msoResponse).path("serviceException").toString().replaceAll("[\\{\\}]","") ,
- msoResponse
- );
- } catch (JsonParseException e) {
- filteredJson = msoResponse;
- } catch (IOException e) {
- throw new GenericUncheckedException(e);
- }
-
- errorMsg = errorMsg + ", " + filteredJson;
- }
- return errorMsg;
+ String additionalInfo = MsoUtil.formatExceptionAdditionalInfo(statusCode, msoResponse);
+ auditMsoStatus(jobUuid, failedMsoRequestStatus, requestId, additionalInfo);
}
@Override
@@ -87,64 +64,133 @@ public class AuditServiceImpl implements AuditService{
}
@Override
- public List<JobAuditStatus> getAuditStatusFromMsoByServiceInstanceId(UUID jobId, UUID serviceInstanceId) {
- String filter = "serviceInstanceId:EQUALS:" + serviceInstanceId;
- return getAuditStatusFromMso(jobId, filter, serviceInstanceId);
+ public List<JobAuditStatus> getAuditStatusFromMsoByInstanceId(JobAuditStatus.ResourceTypeFilter resourceTypeFilter, UUID instanceId, UUID jobId) {
+ String filter = resourceTypeFilter.getFilterBy() + ":EQUALS:" + instanceId;
+ return getAuditStatusFromMso(jobId, filter, instanceId);
}
@Override
public List<JobAuditStatus> getAuditStatusFromMsoByJobId(UUID jobId) {
- List<JobAuditStatus> auditStatuses = asyncInstantiationBL.getAuditStatuses(jobId, JobAuditStatus.SourceStatus.MSO);
+ List<JobAuditStatus> auditStatuses = getAuditStatuses(jobId, JobAuditStatus.SourceStatus.MSO);
String instanceName = getInstanceNameFromServiceInfo(jobId);
auditStatuses.stream().forEach(status ->
- status.setInstanceName(instanceName)
+ status.setInstanceName(instanceName)
);
return auditStatuses;
}
+ @Override
+ public void auditVidStatus(UUID jobUUID, Job.JobStatus jobStatus){
+ JobAuditStatus vidStatus = new JobAuditStatus(jobUUID, jobStatus.toString(), JobAuditStatus.SourceStatus.VID);
+ auditStatus(vidStatus);
+ }
+ @Override
+ public void auditMsoStatus(UUID jobUUID, AsyncRequestStatus.Request msoRequestStatus){
+ auditMsoStatus(jobUUID, msoRequestStatus.requestStatus.getRequestState(), msoRequestStatus.requestId, msoRequestStatus.requestStatus.getStatusMessage());
+ }
+
+ @Override
+ public void auditMsoStatus(UUID jobUUID, String jobStatus, String requestId, String additionalInfo){
+ JobAuditStatus msoStatus = new JobAuditStatus(jobUUID, jobStatus, JobAuditStatus.SourceStatus.MSO,
+ requestId != null ? UUID.fromString(requestId) : null,
+ additionalInfo);
+ auditStatus(msoStatus);
+ }
- private List<JobAuditStatus> getAuditStatusFromMso(UUID jobId, String filter, UUID serviceInstanceId) {
+ private void auditStatus(JobAuditStatus jobAuditStatus){
+ JobAuditStatus latestStatus = getLatestAuditStatus(jobAuditStatus.getJobId(), jobAuditStatus.getSource());
+ if (notEqual(jobAuditStatus, latestStatus)) {
+ jobAuditStatus.setOrdinal(nextOrdinalAfter(latestStatus));
+ asyncInstantiationRepository.addJobAudiStatus(jobAuditStatus);
+ }
+ }
+
+ protected int nextOrdinalAfter(JobAuditStatus jobAuditStatus) {
+ return jobAuditStatus == null ? 0 : (jobAuditStatus.getOrdinal() + 1);
+ }
+
+ private JobAuditStatus getLatestAuditStatus(UUID jobUUID, JobAuditStatus.SourceStatus source){
+ List<JobAuditStatus> list = getAuditStatuses(jobUUID, source);
+ return !list.isEmpty() ? list.get(list.size()-1) : null;
+ }
+
+ public List<JobAuditStatus> getAuditStatuses(UUID jobUUID, JobAuditStatus.SourceStatus source) {
+ return asyncInstantiationRepository.getAuditStatuses(jobUUID, source);
+ }
+
+ @Override
+ //modelType is requestScope in MSO response
+ public List<AsyncRequestStatus.Request> retrieveRequestsFromMsoByServiceIdAndRequestTypeAndScope(String instanceId, String requestType, String modelType) {
+ String filter = JobAuditStatus.ResourceTypeFilter.SERVICE.getFilterBy() + ":EQUALS:" + instanceId;
+ List<AsyncRequestStatus> msoStatuses = getAsyncRequestStatusListFromMso(filter);
+ return msoStatuses.stream()
+ .filter(x -> Objects.equals(x.request.requestType, requestType) && Objects.equals(x.request.requestScope, modelType))
+ .map(x -> x.request)
+ .collect(Collectors.toList());
+ }
+
+ private List<JobAuditStatus> getAuditStatusFromMso(UUID jobId, String filter, UUID instanceId) {
+
+ List<AsyncRequestStatus> msoStatuses = getAsyncRequestStatusListFromMso(filter);
+
+ //add service name from service info for each audit status (in case that serviceInstanceId is null all statuses belong to service)
+ String userInstanceName = (instanceId == null && jobId != null) ? getInstanceNameFromServiceInfo(jobId) : null;
+ return convertMsoResponseStatusToJobAuditStatus(msoStatuses, userInstanceName);
+ }
+
+ @NotNull
+ private List<AsyncRequestStatus> getAsyncRequestStatusListFromMso(String filter) {
String path = MsoBusinessLogicImpl.validateEndpointPath(MsoProperties.MSO_REST_API_GET_ORC_REQS) + "filter=" + filter;
RestObject<AsyncRequestStatusList> msoResponse = restMso.GetForObject(path , AsyncRequestStatusList.class);
if (msoResponse.getStatusCode() >= 400 || msoResponse.get() == null) {
throw new BadResponseFromMso(msoResponse);
}
-
- //add service name from service info for each audit status (in case that serviceInstanceId is null all statuses belong to service)
- String userInstanceName = serviceInstanceId == null ? getInstanceNameFromServiceInfo(jobId): null;
- return convertMsoResponseStatusToJobAuditStatus(msoResponse.get().getRequestList(), userInstanceName);
+ return msoResponse.get().getRequestList();
}
private String getInstanceNameFromServiceInfo(UUID jobId) {
- return asyncInstantiationBL.getServiceInfoByJobId(jobId).getServiceInstanceName();
+ return asyncInstantiationRepository.getServiceInfoByJobId(jobId).getServiceInstanceName();
}
protected List<JobAuditStatus> convertMsoResponseStatusToJobAuditStatus(List<AsyncRequestStatus> msoStatuses, String defaultName){
- return msoStatuses.stream().map(status -> {
- UUID requestId = null;
- String instanceName = defaultName;
- String jobStatus = null;
- String additionalInfo = null;
- String created = null;
- String instanceType = null;
-
- AsyncRequestStatus.Request request = status.request;
- if(request != null) {
+ return msoStatuses.stream().map(status ->
+ convertAsyncRequestStatusToJobAuditStatus(status, defaultName)
+ ).collect(Collectors.toList());
+ }
+
+ private JobAuditStatus convertAsyncRequestStatusToJobAuditStatus(AsyncRequestStatus status, String defaultName){
+ if (status == null) {
+ return null;
+ }
+
+ UUID requestId = null;
+ String instanceName = defaultName;
+ String jobStatus = null;
+ String additionalInfo = null;
+ String created = null;
+ String instanceType = null;
+
+ AsyncRequestStatus.Request request = status.request;
+ if(request != null) {
+ if (request.requestId != null) {
requestId = UUID.fromString(request.requestId);
- instanceName = extractInstanceName(instanceName, request);
- instanceType = request.requestScope;
- if(request.requestStatus != null) {
- jobStatus = request.requestStatus.getRequestState();
- additionalInfo = request.requestStatus.getStatusMessage();
- if(!request.requestStatus.getAdditionalProperties().isEmpty()) {
- created = request.requestStatus.getAdditionalProperties().get("finishTime") != null? request.requestStatus.getAdditionalProperties().get("finishTime").toString() : request.requestStatus.getTimestamp();
- }
+ }
+ instanceName = extractInstanceName(instanceName, request);
+ instanceType = request.requestScope;
+ if(request.requestStatus != null) {
+ jobStatus = request.requestStatus.getRequestState();
+ additionalInfo = request.requestStatus.getStatusMessage();
+ if(!request.requestStatus.getAdditionalProperties().isEmpty() &&
+ request.requestStatus.getAdditionalProperties().get("finishTime") != null) {
+ created = request.requestStatus.getAdditionalProperties().get("finishTime").toString();
+ } else {
+ created = request.requestStatus.getTimestamp();
}
}
- return new JobAuditStatus(instanceName, jobStatus, requestId, additionalInfo, created, instanceType);
- }).collect(Collectors.toList());
+ }
+ return new JobAuditStatus(instanceName, jobStatus, requestId, additionalInfo, created, instanceType);
}
private String extractInstanceName(String instanceName, AsyncRequestStatus.Request request) {
@@ -154,6 +200,13 @@ public class AuditServiceImpl implements AuditService{
return instanceName;
}
+ @Override
+ public JobAuditStatus getResourceAuditStatus(String trackById) {
+ AsyncRequestStatus asyncRequestStatus = asyncInstantiationRepository.getResourceInfoByTrackId(trackById).getErrorMessage();
+ return convertAsyncRequestStatusToJobAuditStatus(asyncRequestStatus, null);
+ }
+
+
public static class BadResponseFromMso extends RuntimeException {
private final RestObject<AsyncRequestStatusList> msoResponse;
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/CloudOwnerService.java b/vid-app-common/src/main/java/org/onap/vid/services/CloudOwnerService.java
index 199fff0c7..f6b82c734 100644
--- a/vid-app-common/src/main/java/org/onap/vid/services/CloudOwnerService.java
+++ b/vid-app-common/src/main/java/org/onap/vid/services/CloudOwnerService.java
@@ -7,9 +7,9 @@
* 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.
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/RoleGenaratorServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/RoleGenaratorServiceImpl.java
index 790dbfa55..a24a72e46 100644
--- a/vid-app-common/src/main/java/org/onap/vid/services/RoleGenaratorServiceImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/services/RoleGenaratorServiceImpl.java
@@ -71,7 +71,7 @@ public class RoleGenaratorServiceImpl implements RoleGeneratorService {
String availableRoles="";
HashMap<String,String> servicesNames = new HashMap<>();
for (Subscriber subscriber: subscribers.customer) {
- AaiResponse<Services> subscriberResponse = client.getSubscriberData(subscriber.globalCustomerId);
+ AaiResponse<Services> subscriberResponse = client.getSubscriberData(subscriber.globalCustomerId, true);
for(ServiceSubscription service: subscriberResponse.getT().serviceSubscriptions.serviceSubscription) {
servicesNames.put(service.serviceType,"");
String roleName = "'" + subscriber.subscriberName + ModelConstants.ROLE_DELIMITER + service.serviceType + "'";
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/VersionService.kt b/vid-app-common/src/main/java/org/onap/vid/services/VersionService.kt
new file mode 100644
index 000000000..2fb3e0c08
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/services/VersionService.kt
@@ -0,0 +1,66 @@
+package org.onap.vid.services
+
+import com.fasterxml.jackson.module.kotlin.readValue
+import org.apache.commons.lang3.StringUtils
+import org.apache.commons.lang3.StringUtils.substringAfterLast
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate
+import org.onap.portalsdk.core.util.SystemProperties
+import org.onap.vid.model.VersionAndFeatures
+import org.onap.vid.utils.JACKSON_OBJECT_MAPPER
+import org.springframework.stereotype.Service
+import java.util.regex.Pattern
+import javax.inject.Inject
+import javax.servlet.ServletContext
+
+@Service
+class VersionService
+@Inject
+constructor(internal var servletContext: ServletContext) {
+
+ private val Logger = EELFLoggerDelegate.getLogger(VersionService::class.java)
+
+ private val versionAndFeatures: VersionAndFeatures by lazy {
+ loadVersionAndFeatures()
+ }
+
+ private fun readBuildNumber(): String {
+ val resource = servletContext.getResource("/app/vid/scripts/constants/version.json")
+ return JACKSON_OBJECT_MAPPER.readValue<Map<String, String>>(resource)["Version"]!!
+ }
+
+ //protected so can be easily tested in UT
+ protected fun readFeatureSet(): String {
+ return SystemProperties.getProperty("features.set.filename")
+ }
+
+ //protected so can be easily tested in UT
+ protected fun buildDisplayVersion(features: String, build: String): String {
+ val matcher = Pattern.compile("([^/]+?)(\\.features|$)").matcher(features)
+ val majorByFeatures = if (matcher.find()) matcher.group(1) else features
+
+ val buildByVersion = StringUtils.defaultIfBlank(substringAfterLast(build, "."), build)
+
+ return StringUtils.join(majorByFeatures, ".", buildByVersion)
+ }
+
+ fun retrieveVersionAndFeatures(): VersionAndFeatures {
+ return try {
+ versionAndFeatures
+ } catch (exception: Exception) {
+ Logger.error("Failed to read build number or feature properties settings from version file", exception)
+ VersionAndFeatures.unknown
+ }
+ }
+
+ private fun loadVersionAndFeatures(): VersionAndFeatures {
+ val featureSet = readFeatureSet();
+ val build = readBuildNumber();
+ val displayVersion = buildDisplayVersion(featureSet, build)
+ return VersionAndFeatures(featureSet, build, displayVersion)
+ }
+
+ //might throw an exception
+ fun retrieveBuildNumber(): String {
+ return versionAndFeatures.build
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/utils/KotlinUtils.kt b/vid-app-common/src/main/java/org/onap/vid/utils/KotlinUtils.kt
index 6866477c3..cf532624c 100644
--- a/vid-app-common/src/main/java/org/onap/vid/utils/KotlinUtils.kt
+++ b/vid-app-common/src/main/java/org/onap/vid/utils/KotlinUtils.kt
@@ -27,4 +27,4 @@ inline fun <reified E: Enum<E>> getEnumFromMapOfStrings(map: Map<String, Any>, k
return java.lang.Enum.valueOf(E::class.java, (map.getOrDefault(key, defaultValue.name) as String))
}
-val JACKSON_OBJECT_MAPPER: ObjectMapper = jacksonObjectMapper()
+@JvmField val JACKSON_OBJECT_MAPPER: ObjectMapper = jacksonObjectMapper()
diff --git a/vid-app-common/src/main/java/org/onap/vid/utils/Tree.kt b/vid-app-common/src/main/java/org/onap/vid/utils/Tree.kt
index 35e913d16..62453756f 100644
--- a/vid-app-common/src/main/java/org/onap/vid/utils/Tree.kt
+++ b/vid-app-common/src/main/java/org/onap/vid/utils/Tree.kt
@@ -7,9 +7,9 @@
* 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.
@@ -41,6 +41,14 @@ data class Tree<T>(private val root:Node<T>) {
}
}
+ fun getChildrenDepth(): Int {
+ return getMaxDepth(root) - 1
+ }
+
+ private fun getMaxDepth(level:Node<T>): Int {
+ return (level.children.map{getMaxDepth(it.value)}.max() ?: 0) + 1
+ }
+
fun getSubTree(vararg path: T): Tree<T>? {
return getSubTree(path.asList())
}
diff --git a/vid-app-common/src/main/resources/1712_ADIOD.zip b/vid-app-common/src/main/resources/1712_ADIOD.zip
deleted file mode 100644
index de8fa7eb4..000000000
--- a/vid-app-common/src/main/resources/1712_ADIOD.zip
+++ /dev/null
Binary files differ
diff --git a/vid-app-common/src/main/resources/2f80c596.zip b/vid-app-common/src/main/resources/2f80c596.zip
deleted file mode 100644
index 95161faac..000000000
--- a/vid-app-common/src/main/resources/2f80c596.zip
+++ /dev/null
Binary files differ
diff --git a/vid-app-common/src/main/resources/adiod.zip b/vid-app-common/src/main/resources/adiod.zip
deleted file mode 100644
index 6e024234a..000000000
--- a/vid-app-common/src/main/resources/adiod.zip
+++ /dev/null
Binary files differ
diff --git a/vid-app-common/src/main/resources/csar317927061915233480.zip b/vid-app-common/src/main/resources/csar317927061915233480.zip
deleted file mode 100644
index d30f49f4d..000000000
--- a/vid-app-common/src/main/resources/csar317927061915233480.zip
+++ /dev/null
Binary files differ
diff --git a/vid-app-common/src/main/resources/csar3933948645405128424.zip b/vid-app-common/src/main/resources/csar3933948645405128424.zip
deleted file mode 100644
index 549a5218e..000000000
--- a/vid-app-common/src/main/resources/csar3933948645405128424.zip
+++ /dev/null
Binary files differ
diff --git a/vid-app-common/src/main/resources/mso_get_manual_task_by_request_id.json b/vid-app-common/src/main/resources/mso_get_manual_task_by_request_id.json
deleted file mode 100644
index 004280bce..000000000
--- a/vid-app-common/src/main/resources/mso_get_manual_task_by_request_id.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
- "taskList":[
- {
- "taskId":"daf4dd84-b77a-42da-a051-3239b7a9392c",
- "type":"fallout",
- "nfRole":"vSCP",
- "subscriptionServiceType":"Mobility",
- "originalRequestId":"za1234d1-5a33-55df-13ab-12abad84e335",
- "originalRequestorId":"ss835w",
- "errorSource":"A&AI",
- "errorCode":"404",
- "errorMessage":"Failed in A&AI 404",
- "buildingBlockName":"DoCreateVfModule",
- "buildingBlockStep":"invokeA&AI:getTenant",
- "validResponses":[
- "rollback",
- "abort",
- "skip",
- "retry"
- ]
- }
- ]
-} \ No newline at end of file
diff --git a/vid-app-common/src/main/resources/pnf.zip b/vid-app-common/src/main/resources/pnf.zip
deleted file mode 100644
index 541d89ecf..000000000
--- a/vid-app-common/src/main/resources/pnf.zip
+++ /dev/null
Binary files differ
diff --git a/vid-app-common/src/main/resources/service-David-csar.csar b/vid-app-common/src/main/resources/service-David-csar.csar
deleted file mode 100644
index fcf1c647b..000000000
--- a/vid-app-common/src/main/resources/service-David-csar.csar
+++ /dev/null
Binary files differ
diff --git a/vid-app-common/src/main/resources/service-DemoService1-csar.csar b/vid-app-common/src/main/resources/service-DemoService1-csar.csar
deleted file mode 100644
index 0e34dc5ce..000000000
--- a/vid-app-common/src/main/resources/service-DemoService1-csar.csar
+++ /dev/null
Binary files differ
diff --git a/vid-app-common/src/main/resources/service-VdbeSrv-csar.zip b/vid-app-common/src/main/resources/service-VdbeSrv-csar.zip
deleted file mode 100644
index 0b8db2789..000000000
--- a/vid-app-common/src/main/resources/service-VdbeSrv-csar.zip
+++ /dev/null
Binary files differ
diff --git a/vid-app-common/src/main/resources/service-vf-csar.zip b/vid-app-common/src/main/resources/service-vf-csar.zip
deleted file mode 100644
index f0b0a98d7..000000000
--- a/vid-app-common/src/main/resources/service-vf-csar.zip
+++ /dev/null
Binary files differ
diff --git a/vid-app-common/src/main/resources/service-vf-with-annotations.zip b/vid-app-common/src/main/resources/service-vf-with-annotations.zip
deleted file mode 100644
index 79c5fb0ce..000000000
--- a/vid-app-common/src/main/resources/service-vf-with-annotations.zip
+++ /dev/null
Binary files differ
diff --git a/vid-app-common/src/main/resources/service-vl-csar.zip b/vid-app-common/src/main/resources/service-vl-csar.zip
deleted file mode 100644
index dfe0b8370..000000000
--- a/vid-app-common/src/main/resources/service-vl-csar.zip
+++ /dev/null
Binary files differ
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js
index d5040b138..d9bc828fe 100644
--- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js
@@ -696,8 +696,8 @@
  - lcpCloudRegionId == 'rdm5b'
  - tenantId == '0675e0709bd7444a9e13eba8b40edb3c'
- "url": "https://aai-conexus-e2e.ecomp.cci.att.com:8443/aai/v10/cloud-infrastructure/cloud-regions/cloud-region/att-aic/rdm5b/tenants/tenant/0675e0709bd7444a9e13eba8b40edb3c/vservers/vserver/932b330d-733e-427d-a519-14eebd261f70"
- "url": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/att-aic/rdm5b/tenants/tenant/0675e0709bd7444a9e13eba8b40edb3c/vservers/vserver/932b330d-733e-427d-a519-14eebd261f70"
+ "url": "https://aai-conexus-e2e.ecomp.cci.att.com:8443/aai/v10/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/rdm5b/tenants/tenant/0675e0709bd7444a9e13eba8b40edb3c/vservers/vserver/932b330d-733e-427d-a519-14eebd261f70"
+ "url": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/rdm5b/tenants/tenant/0675e0709bd7444a9e13eba8b40edb3c/vservers/vserver/932b330d-733e-427d-a519-14eebd261f70"
*/
var cloudRegionMatch = url.match(/\/cloud-regions\/cloud-region\/[^\/]+\/([^\/]+)/);
diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/AAITreeConverterTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/AAITreeConverterTest.java
index 5bdfd1207..560e6cb5f 100644
--- a/vid-app-common/src/test/java/org/onap/vid/aai/AAITreeConverterTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/aai/AAITreeConverterTest.java
@@ -25,17 +25,16 @@ import org.mockito.InjectMocks;
import org.mockito.MockitoAnnotations;
import org.onap.vid.aai.util.AAITreeConverter;
import org.onap.vid.model.Action;
-import org.onap.vid.model.aaiTree.AAITreeNode;
-import org.onap.vid.model.aaiTree.Network;
+import org.onap.vid.model.aaiTree.*;
import org.onap.vid.model.aaiTree.ServiceInstance;
-import org.onap.vid.model.aaiTree.VfModule;
-import org.onap.vid.model.aaiTree.Vnf;
+import org.onap.vid.mso.model.CloudConfiguration;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.util.List;
+import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.emptyOrNullString;
import static org.hamcrest.Matchers.hasKey;
@@ -43,6 +42,7 @@ import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.onap.vid.asdc.parser.ToscaParserImpl2.Constants.A_LA_CARTE;
+import static org.testng.Assert.assertNull;
public class AAITreeConverterTest {
@@ -59,28 +59,41 @@ public class AAITreeConverterTest {
AAITreeNode aaiTree = generateAaiTreeToConvert(0, 0);
- ServiceInstance result = aaiTreeConverter.convertTreeToUIModel(aaiTree, "global-customer-id", "service-type", A_LA_CARTE);
+ ServiceInstance result = aaiTreeConverter.convertTreeToUIModel(aaiTree, "global-customer-id", "service-type", A_LA_CARTE, "", "");
assertService(result, 0, 0, true);
}
@Test
- public void testConvertTreeToUIModel_MultipleChildren() throws Exception {
+ public void testConvertTreeToUIModel_MultipleChildren() {
AAITreeNode aaiTree = generateAaiTreeToConvert(2, 2);
- ServiceInstance serviceInstance = aaiTreeConverter.convertTreeToUIModel(aaiTree, "global-customer-id", "service-type", null);
+ ServiceInstance serviceInstance = aaiTreeConverter.convertTreeToUIModel(aaiTree, "global-customer-id", "service-type", null, "", "");
assertService(serviceInstance, 2, 2, false);
int nodesCounter = 0;
assertThat(serviceInstance.getVnfs().entrySet(), hasSize(2));
- assertVnf(serviceInstance.getVnfs().get("vnf-model-version-id:00"+(nodesCounter++)), 0, 0, false);
- assertVnf(serviceInstance.getVnfs().get("vnf-model-version-id:00"+(nodesCounter++)), 0, 0, false);
+ assertVnf(serviceInstance.getVnfs().get("vnf-instance-id" + (nodesCounter++)), 0, 0);
+ assertVnf(serviceInstance.getVnfs().get("vnf-instance-id" + (nodesCounter++)), 0, 0);
assertThat(serviceInstance.getNetworks().entrySet(), hasSize(2));
- assertNetwork(serviceInstance.getNetworks().get("network-model-version-id:00"+(nodesCounter++)), false);
- assertNetwork(serviceInstance.getNetworks().get("network-model-version-id:00"+(nodesCounter)), false);
+ assertNetwork(serviceInstance.getNetworks().get("network-instance-id" + (nodesCounter++)), false);
+ assertNetwork(serviceInstance.getNetworks().get("network-instance-id" + (nodesCounter++)), false);
+
+ assertThat(serviceInstance.getVnfGroups().size(), equalTo(1));
+ assertThat(serviceInstance.getVnfGroups().get("vnf-group-id" + (nodesCounter++)).getInstanceId(), startsWith("vnf-group-id"));
+
+ assertThat(serviceInstance.getCollectionResources().size(), equalTo(1));
+ CollectionResource cr = serviceInstance.getCollectionResources().get("cr-id" + (nodesCounter++));
+ assertThat(cr.getInstanceId(), startsWith("cr-id"));
+
+ assertThat(cr.getNcfs().size(), equalTo(1));
+ assertThat(cr.getNcfs().get("ncf-id").getInstanceId(), startsWith("ncf-id"));
+
+ assertThat(serviceInstance.getExistingVNFCounterMap().get("vnf-model-customization-id"), equalTo(2L));
+ assertThat(serviceInstance.getExistingNetworksCounterMap().get("network-model-customization-id"), equalTo(2L));
}
@DataProvider
@@ -99,7 +112,7 @@ public class AAITreeConverterTest {
int nodesCounter = 0;
for (Boolean customizationName: vfModules) {
- vnfTreeNode.getChildren().add(createVfModule(nodesCounter++, customizationName));
+ vnfTreeNode.getChildren().add(createVfModule(customizationName));
}
for (Boolean customizationName: networks) {
@@ -108,24 +121,21 @@ public class AAITreeConverterTest {
Vnf actualVnf = Vnf.from(vnfTreeNode);
- assertVnf(actualVnf, vfModules.size(), networks.size(), false);
+ assertVnf(actualVnf, vfModules.size(), networks.size());
nodesCounter = 0;
for (Boolean customizationName: vfModules) {
String key = customizationName ? "vfModule key in model" : "vfModule-model-version-id";
assertThat(actualVnf.getVfModules(), hasKey(key));
- assertThat(actualVnf.getVfModules().get(key), hasKey(key + ":00" + nodesCounter));
- VfModule actualVfModule = actualVnf.getVfModules().get(key).get(key + ":00" + nodesCounter);
+ assertThat(actualVnf.getVfModules().get(key), hasKey("vfModule-instance-id"));
+ VfModule actualVfModule = actualVnf.getVfModules().get(key).get("vfModule-instance-id");
assertVfModule(actualVfModule, customizationName);
- nodesCounter++;
}
for (Boolean customizationName: networks) {
- String key = customizationName ? "network key in model" : "network-model-version-id";
-
- assertThat(actualVnf.getNetworks(), hasKey(key + ":00" + nodesCounter));
- Network actualNetwork = actualVnf.getNetworks().get(key + ":00" + nodesCounter);
+ assertThat(actualVnf.getNetworks(), hasKey("network-instance-id" + nodesCounter));
+ Network actualNetwork = actualVnf.getNetworks().get("network-instance-id" + nodesCounter);
assertNetwork(actualNetwork, customizationName);
nodesCounter++;
}
@@ -142,45 +152,79 @@ public class AAITreeConverterTest {
private AAITreeNode createVnf(int uniqueNumber, boolean hasCustomizationName) {
AAITreeNode vnfTreeNode = new AAITreeNode();
- vnfTreeNode.setId("vnf-instance-id");
+ vnfTreeNode.setId("vnf-instance-id" + uniqueNumber);
vnfTreeNode.setName("vnf-instance-name");
- vnfTreeNode.setType("generic-vnf");
+ vnfTreeNode.setType(NodeType.GENERIC_VNF);
vnfTreeNode.setModelVersionId("vnf-model-version-id");
+ vnfTreeNode.setModelCustomizationId("vnf-model-customization-id");
if (hasCustomizationName) {
vnfTreeNode.setModelCustomizationName("vnf model customization name");
vnfTreeNode.setKeyInModel("vnf key in model");
}
- vnfTreeNode.setUniqueNumber(uniqueNumber);
return vnfTreeNode;
}
- private AAITreeNode createVfModule(int uniqueNumber, boolean hasCustomizationName) {
+ private AAITreeNode createVnfGroup(int uniqueNumber) {
+ AAITreeNode treeNode = new AAITreeNode();
+ treeNode.setId("vnf-group-id" + uniqueNumber);
+ treeNode.setType(NodeType.INSTANCE_GROUP);
+ treeNode.getAdditionalProperties().put("instance-group-type", "vnfGroup-type");
+ return treeNode;
+ }
+
+ private AAITreeNode createCollectionResource(int uniqueNumber) {
+ AAITreeNode treeNode = new AAITreeNode();
+ treeNode.setId("cr-id" + uniqueNumber);
+ treeNode.setType(NodeType.COLLECTION_RESOURCE);
+ treeNode.getChildren().add(createNCF());
+ return treeNode;
+ }
+
+ private AAITreeNode createNCF() {
+ AAITreeNode treeNode = new AAITreeNode();
+ treeNode.setId("ncf-id");
+ treeNode.setType(NodeType.INSTANCE_GROUP);
+ treeNode.getAdditionalProperties().put("instance-group-type", "L3-NETWORK");
+ return treeNode;
+ }
+
+ @Test
+ public void givenPlacementIsNull_whenConvertToNetwork_relevantFieldsAreAlsoNull() {
+ AAITreeNode aaiTreeNode = new AAITreeNode();
+ aaiTreeNode.setType(NodeType.NETWORK);
+ Network actualNetwork = Network.from(aaiTreeNode);
+ assertNull(actualNetwork.getCloudOwner());
+ assertNull(actualNetwork.getLcpCloudRegionId());
+ assertNull(actualNetwork.getTenantId());
+ }
+
+ private AAITreeNode createVfModule(boolean hasCustomizationName) {
AAITreeNode vfModuleTreeNode = new AAITreeNode();
vfModuleTreeNode.setId("vfModule-instance-id");
vfModuleTreeNode.setName("vfModule-instance-name");
- vfModuleTreeNode.setType("vf-module");
+ vfModuleTreeNode.setType(NodeType.VF_MODULE);
vfModuleTreeNode.setModelVersionId("vfModule-model-version-id");
+ vfModuleTreeNode.setModelCustomizationId("vfModule-model-customization-id");
if (hasCustomizationName) {
vfModuleTreeNode.setModelCustomizationName("vfModule model customization name");
vfModuleTreeNode.setKeyInModel("vfModule key in model");
}
- vfModuleTreeNode.setUniqueNumber(uniqueNumber);
-
+ vfModuleTreeNode.setCloudConfiguration(new CloudConfiguration("lcpRegion2", "tenant3", "cloudOwner1"));
return vfModuleTreeNode;
}
private AAITreeNode createNetwork(int uniqueNumber, boolean hasCustomizationName) {
AAITreeNode networkTreeNode = new AAITreeNode();
- networkTreeNode.setId("network-instance-id");
+ networkTreeNode.setId("network-instance-id" + uniqueNumber);
networkTreeNode.setName("network-instance-name");
- networkTreeNode.setType("l3-network");
+ networkTreeNode.setType(NodeType.NETWORK);
networkTreeNode.setModelVersionId("network-model-version-id");
+ networkTreeNode.setModelCustomizationId("network-model-customization-id");
if (hasCustomizationName) {
networkTreeNode.setModelCustomizationName("network model customization name");
networkTreeNode.setKeyInModel("network key in model");
}
- networkTreeNode.setUniqueNumber(uniqueNumber);
-
+ networkTreeNode.setCloudConfiguration(new CloudConfiguration("auk51a", "b530fc990b6d4334bd45518bebca6a51", "att-nc"));
return networkTreeNode;
}
@@ -196,17 +240,16 @@ public class AAITreeConverterTest {
assertThat(serviceInstance.getIsALaCarte(), is(isALaCarte));
}
- private void assertVnf(Vnf actualVnf, int expectedVfModules, int expectedNetworks, boolean hasCustomizationName) {
- assertThat(actualVnf.getInstanceId(), is("vnf-instance-id"));
+ private void assertVnf(Vnf actualVnf, int expectedVfModules, int expectedNetworks) {
+ assertThat(actualVnf.getInstanceId(), containsString("vnf-instance-id"));
assertThat(actualVnf.getInstanceName(), is("vnf-instance-name"));
assertThat(actualVnf.getAction(), is(Action.None));
assertThat(actualVnf.getModelInfo().getModelType(), is("vnf"));
assertThat(actualVnf.getModelInfo().getModelVersionId(), is("vnf-model-version-id"));
assertThat(actualVnf.getVfModules().entrySet(), hasSize(expectedVfModules));
assertThat(actualVnf.getNetworks().entrySet(), hasSize(expectedNetworks));
- assertThat(actualVnf.getTrackById(), is(not(emptyOrNullString())));
- String expectedCustomizationName = hasCustomizationName ? "vnf model customization name" : null;
- assertThat(actualVnf.getModelInfo().getModelCustomizationName(), is(expectedCustomizationName));
+ assertThat(actualVnf.getTrackById(), containsString("vnf-instance-id"));
+ assertNull(actualVnf.getModelInfo().getModelCustomizationName());
}
private void assertVfModule(VfModule actualVfModule, boolean hasCustomizationName) {
@@ -215,20 +258,27 @@ public class AAITreeConverterTest {
assertThat(actualVfModule.getAction(), is(Action.None));
assertThat(actualVfModule.getModelInfo().getModelType(), is("vfModule"));
assertThat(actualVfModule.getModelInfo().getModelVersionId(), is("vfModule-model-version-id"));
- assertThat(actualVfModule.getTrackById(), is(not(emptyOrNullString())));
+ assertThat(actualVfModule.getTrackById(), is("vfModule-instance-id"));
String expectedCustomizationName = hasCustomizationName ? "vfModule model customization name" : null;
assertThat(actualVfModule.getModelInfo().getModelCustomizationName(), is(expectedCustomizationName));
+ assertThat(actualVfModule.getCloudOwner(), is("cloudOwner1"));
+ assertThat(actualVfModule.getLcpCloudRegionId(), is("lcpRegion2"));
+ assertThat(actualVfModule.getTenantId(), is("tenant3"));
}
private void assertNetwork(Network actualNetwork, boolean hasCustomizationName) {
- assertThat(actualNetwork.getInstanceId(), is("network-instance-id"));
+ assertThat(actualNetwork.getInstanceId(), containsString("network-instance-id"));
assertThat(actualNetwork.getInstanceName(), is("network-instance-name"));
assertThat(actualNetwork.getAction(), is(Action.None));
assertThat(actualNetwork.getModelInfo().getModelType(), is("network"));
assertThat(actualNetwork.getModelInfo().getModelVersionId(), is("network-model-version-id"));
- assertThat(actualNetwork.getTrackById(), is(not(emptyOrNullString())));
+ assertThat(actualNetwork.getTrackById(), containsString("network-instance-id"));
String expectedCustomizationName = hasCustomizationName ? "network model customization name" : null;
assertThat(actualNetwork.getModelInfo().getModelCustomizationName(), is(expectedCustomizationName));
+ assertThat(actualNetwork.getCloudOwner(), is("att-nc"));
+ assertThat(actualNetwork.getLcpCloudRegionId(), is("auk51a"));
+ assertThat(actualNetwork.getTenantId(), is("b530fc990b6d4334bd45518bebca6a51"));
+
}
private AAITreeNode generateAaiTreeToConvert(int numberOfVnfs, int numberOfNetworks) {
@@ -236,6 +286,7 @@ public class AAITreeConverterTest {
AAITreeNode aaiTree = new AAITreeNode();
aaiTree.setId("service-instance-id");
aaiTree.setName("service-instance-name");
+ aaiTree.setType(NodeType.SERVICE_INSTANCE);
for (int i = 0; i < numberOfVnfs; i++) {
aaiTree.getChildren().add(createVnf(counter++, false));
@@ -245,6 +296,9 @@ public class AAITreeConverterTest {
aaiTree.getChildren().add(createNetwork(counter++, false));
}
+ aaiTree.getChildren().add(createVnfGroup(counter++));
+ aaiTree.getChildren().add(createCollectionResource(counter++));
+
return aaiTree;
}
-}
+} \ No newline at end of file
diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/AaiClientTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/AaiClientTest.java
index fdeeb0076..b2d8e85fa 100644
--- a/vid-app-common/src/test/java/org/onap/vid/aai/AaiClientTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/aai/AaiClientTest.java
@@ -20,9 +20,51 @@
package org.onap.vid.aai;
+import static java.util.stream.Collectors.toList;
+import static org.apache.commons.lang3.StringUtils.equalsIgnoreCase;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.either;
+import static org.hamcrest.Matchers.hasProperty;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.sameInstance;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyBoolean;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.argThat;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.isNull;
+import static org.mockito.ArgumentMatchers.nullable;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.onap.vid.utils.KotlinUtilsKt.JACKSON_OBJECT_MAPPER;
+import static org.onap.vid.utils.Unchecked.toURI;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.fail;
+
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableList;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.URI;
+import java.security.cert.CertificateException;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.function.BiConsumer;
+import java.util.function.Function;
+import java.util.stream.Stream;
+import javax.crypto.BadPaddingException;
+import javax.net.ssl.SSLHandshakeException;
+import javax.servlet.ServletContext;
+import javax.ws.rs.ProcessingException;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.core.Response;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.apache.commons.lang3.exception.ExceptionUtils;
@@ -32,10 +74,20 @@ import org.apache.http.HttpStatus;
import org.mockito.Mockito;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.portalsdk.core.util.SystemProperties;
-import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.RelatedToProperty;
import org.onap.vid.aai.model.AaiGetTenatns.GetTenantsResponse;
-import org.onap.vid.aai.model.*;
-import org.onap.vid.aai.util.*;
+import org.onap.vid.aai.model.CustomQuerySimpleResult;
+import org.onap.vid.aai.model.ModelVer;
+import org.onap.vid.aai.model.ModelVersions;
+import org.onap.vid.aai.model.PortDetailsTranslator;
+import org.onap.vid.aai.model.Properties;
+import org.onap.vid.aai.model.RelatedToProperty;
+import org.onap.vid.aai.model.ResourceType;
+import org.onap.vid.aai.model.SimpleResult;
+import org.onap.vid.aai.util.AAIRestInterface;
+import org.onap.vid.aai.util.CacheProvider;
+import org.onap.vid.aai.util.HttpsAuthClient;
+import org.onap.vid.aai.util.ServletRequestHelper;
+import org.onap.vid.aai.util.SystemPropertyHelper;
import org.onap.vid.controller.LocalWebConfig;
import org.onap.vid.exceptions.GenericUncheckedException;
import org.onap.vid.model.Subscriber;
@@ -55,37 +107,6 @@ import org.testng.annotations.Test;
import sun.security.provider.certpath.SunCertPathBuilderException;
import sun.security.validator.ValidatorException;
-import javax.crypto.BadPaddingException;
-import javax.net.ssl.SSLHandshakeException;
-import javax.servlet.ServletContext;
-import javax.ws.rs.ProcessingException;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.core.Response;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.net.URI;
-import java.security.cert.CertificateException;
-import java.util.ArrayList;
-import java.util.Map;
-import java.util.function.BiConsumer;
-import java.util.function.Function;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import static org.apache.commons.lang3.StringUtils.equalsIgnoreCase;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.*;
-import static org.mockito.ArgumentMatchers.nullable;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyBoolean;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Matchers.argThat;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Matchers.isNull;
-import static org.mockito.Mockito.*;
-import static org.onap.vid.utils.Unchecked.toURI;
-import static org.testng.Assert.*;
-
@ContextConfiguration(classes = {LocalWebConfig.class, SystemProperties.class})
@WebAppConfiguration
public class AaiClientTest {
@@ -345,7 +366,7 @@ public class AaiClientTest {
Assert.assertTrue(response.t.length> 0);
- Assert.assertEquals(tenants[0].cloudOwner,"att-aic-cloud-owner");
+ Assert.assertEquals(tenants[0].cloudOwner,"irma-aic-cloud-owner");
}
final String tenantResponseRaw ="" +
@@ -355,10 +376,10 @@ public class AaiClientTest {
"\"relationship-list\": {" +
"\"relationship\": [{" +
"\"related-to\": \"tenant\"," +
- "\"related-link\": \"/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant/092eb9e8e4b7412e8787dd091bc58e86\"," +
+ "\"related-link\": \"/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/AAIAIC25/tenants/tenant/092eb9e8e4b7412e8787dd091bc58e86\"," +
"\"relationship-data\": [{" +
"\"relationship-key\": \"cloud-region.cloud-owner\"," +
- "\"relationship-value\": \"att-aic-cloud-owner\"" +
+ "\"relationship-value\": \"irma-aic-cloud-owner\"" +
"}," +
"{" +
"\"relationship-key\": \"cloud-region.cloud-region-id\"," +
@@ -427,11 +448,11 @@ public class AaiClientTest {
" {" +
" \"related-to\": \"volume-group\"," +
" \"relationship-label\": \"org.onap.relationships.inventory.Uses\"," +
- " \"related-link\": \"/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/att-aic/rdm5b/volume-groups/volume-group/66013ebe-0c81-44b9-a24f-7c6acba73a39\"," +
+ " \"related-link\": \"/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/rdm5b/volume-groups/volume-group/66013ebe-0c81-44b9-a24f-7c6acba73a39\"," +
" \"relationship-data\": [" +
" {" +
" \"relationship-key\": \"cloud-region.cloud-owner\"," +
- " \"relationship-value\": \"att-aic\"" +
+ " \"relationship-value\": \"irma-aic\"" +
" }," +
" {" +
" \"relationship-key\": \"cloud-region.cloud-region-id\"," +
@@ -446,11 +467,11 @@ public class AaiClientTest {
" {" +
" \"related-to\": \"vserver\"," +
" \"relationship-label\": \"org.onap.relationships.inventory.Uses\"," +
- " \"related-link\": \"/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/att-aic/rdm5b/tenants/tenant/db1818f7f2e34862b378bfb2cc520f91/vservers/vserver/5eef9f6d-9933-4bc6-9a1a-862d61309437\"," +
+ " \"related-link\": \"/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/rdm5b/tenants/tenant/db1818f7f2e34862b378bfb2cc520f91/vservers/vserver/5eef9f6d-9933-4bc6-9a1a-862d61309437\"," +
" \"relationship-data\": [" +
" {" +
" \"relationship-key\": \"cloud-region.cloud-owner\"," +
- " \"relationship-value\": \"att-aic\"" +
+ " \"relationship-value\": \"irma-aic\"" +
" }," +
" {" +
" \"relationship-key\": \"cloud-region.cloud-region-id\"," +
@@ -490,7 +511,7 @@ public class AaiClientTest {
GetTenantsResponse tenant = aaiClientMock.getHomingDataByVfModule("vnfInstanceId", "vfModuleId");
- Assert.assertEquals(tenant.cloudOwner,"att-aic");
+ Assert.assertEquals(tenant.cloudOwner,"irma-aic" );
Assert.assertEquals(tenant.cloudRegionID,"rdm5b");
Assert.assertEquals(tenant.tenantID,"db1818f7f2e34862b378bfb2cc520f91");
@@ -601,7 +622,7 @@ public class AaiClientTest {
// double each case to propagateExceptions = true/false, to verify that "don't propagate" really still work
ImmutableList.of(l.getLeft(), l.getRight(), true).toArray(),
ImmutableList.of(l.getLeft(), l.getRight(), false).toArray()
- )).collect(Collectors.toList()).toArray(new Object[][]{});
+ )).collect(toList()).toArray(new Object[][]{});
}
private static UncheckedBiConsumer<HttpsAuthClient, Client> mockExceptionOnClientProvider(Exception e) {
@@ -734,6 +755,83 @@ public class AaiClientTest {
};
}
+ @Test
+ public void testGetLatestVersionByInvariantId() throws IOException {
+
+ ModelVersions modelVersions = JACKSON_OBJECT_MAPPER.readValue("" +
+ "{\n" +
+ " \"results\": [\n" +
+ " {\n" +
+ " \"model\": {\n" +
+ " \"model-invariant-id\": \"f6342be5-d66b-4d03-a1aa-c82c3094c4ea\",\n" +
+ " \"model-type\": \"service\",\n" +
+ " \"resource-version\": \"1534274421300\"\n" +
+ " }\n" +
+ " },\n" +
+ " {\n" +
+ " \"model-ver\": {\n" +
+ " \"model-version-id\": \"a92f899d-a3ec-465b-baed-1663b0a5aee1\",\n" +
+ " \"model-name\": \"NCM_VLAN_SVC_ym161f\",\n" +
+ " \"model-version\": \"bbb\",\n" +
+ " \"distribution-status\": \"DISTRIBUTION_COMPLETE_OK\",\n" +
+ " \"model-description\": \"Network Collection service for vLAN tagging\",\n" +
+ " \"resource-version\": \"1534788756086\"\n" +
+ " }\n" +
+ " },\n" +
+ " {\n" +
+ " \"model-ver\": {\n" +
+ " \"model-version-id\": \"d2fda667-e92e-4cfa-9620-5da5de01a319\",\n" +
+ " \"model-name\": \"NCM_VLAN_SVC_ym161f\",\n" +
+ " \"model-version\": \"aaa\",\n" +
+ " \"distribution-status\": \"DISTRIBUTION_COMPLETE_OK\",\n" +
+ " \"model-description\": \"Network Collection service for vLAN tagging\",\n" +
+ " \"resource-version\": \"1534444087221\"\n" +
+ " }\n" +
+ " }]}", ModelVersions.class);
+
+
+ final AaiClient aaiClient = new AaiClient(null, null, null);
+
+ assertThat(aaiClient.toModelVerStream(modelVersions).collect(toList()),
+ containsInAnyOrder(
+ hasProperty("modelVersionId", is("a92f899d-a3ec-465b-baed-1663b0a5aee1")),
+ hasProperty("modelVersionId", is("d2fda667-e92e-4cfa-9620-5da5de01a319"))
+ ));
+
+ }
+
+ @DataProvider
+ public static Object[][] versionsDataProvider() {
+ return new Object[][] {
+ { Stream.of("10","20","30"), "30" },
+ { Stream.of("10","20","20"), "20" },
+ { Stream.of("c","b","a"), "c" },
+ { Stream.of("1.0","2.0","1.8"), "2.0" },
+ { Stream.of("1.0.7","2.0.2","2.0.9"), "2.0.9" },
+ { Stream.of("0","0","0"), "0" },
+ { Stream.of("","10"), "10" },
+
+ };
+ }
+
+ @Test(dataProvider = "versionsDataProvider")
+ public void maxModelVer(Stream<String> input, String expected) {
+ Stream<ModelVer> modelVerStream = input.map(version -> {
+ ModelVer mv = new ModelVer();
+ mv.setModelVersion(version);
+ return mv;
+ });
+
+ final AaiClient aaiClient = new AaiClient(null, null, null);
+
+ assertThat(aaiClient.maxModelVer(modelVerStream), hasProperty("modelVersion", is(expected)));
+ }
+
+ @Test(expectedExceptions = GenericUncheckedException.class)
+ public void maxModelVerException() {
+ final AaiClient aaiClient = new AaiClient(null, null, null);
+ aaiClient.maxModelVer(Stream.of(new ModelVer()));
+ }
@Test(dataProvider = "cloudRegionAndTenantDataProvider")
public void getCloudRegionAndTenantByVnfId(String tenantName, String cloudRegionId) throws JsonProcessingException {
SimpleResult tenant = new SimpleResult();
diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/AaiResponseTranslatorTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/AaiResponseTranslatorTest.java
index 12f7429eb..045488605 100644
--- a/vid-app-common/src/test/java/org/onap/vid/aai/AaiResponseTranslatorTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/aai/AaiResponseTranslatorTest.java
@@ -45,9 +45,9 @@ public class AaiResponseTranslatorTest {
" \"results\": [{" +
" \"id\": \"2979590232\"," +
" \"node-type\": \"cloud-region\"," +
- " \"url\": \"/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/att-aic/SDNO-S-BcloudReg-E1802\"," +
+ " \"url\": \"/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/SDNO-S-BcloudReg-E1802\"," +
" \"properties\": {" +
- " \"cloud-owner\": \"att-aic\"," +
+ " \"cloud-owner\": \"irma-aic\"," +
" \"cloud-region-id\": \"THE-EXPECTED-REGION-ID\"," +
" \"sriov-automation\": false," +
" \"resource-version\": \"1513631040564\"" +
@@ -122,7 +122,7 @@ public class AaiResponseTranslatorTest {
"{" +
" \"results\": [{" +
" \"node-type\": \"cloud-region\"," +
- " \"url\": \"/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/att-aic/SDNO-S-BcloudReg-E1802\"," +
+ " \"url\": \"/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/SDNO-S-BcloudReg-E1802\"," +
" \"properties\": {" +
" \"resource-version\": \"1513631040564\"" +
" }" +
diff --git a/vid-app-common/src/test/java/org/onap/vid/asdc/parser/ToscaParserImpl2Test.java b/vid-app-common/src/test/java/org/onap/vid/asdc/parser/ToscaParserImpl2Test.java
index 91c480526..92d78d43e 100644
--- a/vid-app-common/src/test/java/org/onap/vid/asdc/parser/ToscaParserImpl2Test.java
+++ b/vid-app-common/src/test/java/org/onap/vid/asdc/parser/ToscaParserImpl2Test.java
@@ -20,11 +20,33 @@
package org.onap.vid.asdc.parser;
+import static com.google.common.collect.Lists.newArrayList;
+import static org.hamcrest.Matchers.aMapWithSize;
+import static org.hamcrest.Matchers.allOf;
+import static org.hamcrest.Matchers.hasKey;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.onap.vid.asdc.parser.ToscaParserImpl2.Constants.ECOMP_GENERATED_NAMING_PROPERTY;
+import static org.onap.vid.testUtils.TestUtils.assertJsonStringEqualsIgnoreNulls;
+
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.UUID;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
import net.javacrumbs.jsonunit.JsonAssert;
import org.apache.commons.io.IOUtils;
import org.apache.log4j.LogManager;
@@ -43,7 +65,19 @@ import org.onap.vid.asdc.AsdcCatalogException;
import org.onap.vid.asdc.AsdcClient;
import org.onap.vid.asdc.local.LocalAsdcClient;
import org.onap.vid.controller.ToscaParserMockHelper;
-import org.onap.vid.model.*;
+import org.onap.vid.model.CR;
+import org.onap.vid.model.Network;
+import org.onap.vid.model.NetworkCollection;
+import org.onap.vid.model.Node;
+import org.onap.vid.model.PortMirroringConfig;
+import org.onap.vid.model.ResourceGroup;
+import org.onap.vid.model.Service;
+import org.onap.vid.model.ServiceModel;
+import org.onap.vid.model.ServiceProxy;
+import org.onap.vid.model.VNF;
+import org.onap.vid.model.VfModule;
+import org.onap.vid.model.VidNotions;
+import org.onap.vid.model.VolumeGroup;
import org.onap.vid.properties.Features;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
@@ -52,22 +86,6 @@ import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.togglz.core.manager.FeatureManager;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.file.Path;
-import java.util.*;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import static com.google.common.collect.Lists.newArrayList;
-import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-import static org.onap.vid.asdc.parser.ToscaParserImpl2.Constants.ECOMP_GENERATED_NAMING_PROPERTY;
-import static org.onap.vid.testUtils.TestUtils.assertJsonStringEqualsIgnoreNulls;
-
public class ToscaParserImpl2Test {
private final String myUUID = "myUUID";
@@ -101,7 +119,7 @@ public class ToscaParserImpl2Test {
@Test(dataProvider = "expectedServiceModel")
public void assertEqualsBetweenServices(String uuid, ToscaParserMockHelper mockHelper) throws Exception {
- Service expectedService = mockHelper.getNewServiceModel().getService();
+ Service expectedService = mockHelper.getServiceModel().getService();
Service actualService = toscaParserImpl2.makeServiceModel(getCsarPath(mockHelper.getUuid()), getServiceByUuid(mockHelper.getUuid())).getService();
assertJsonStringEqualsIgnoreNulls(om.writeValueAsString(expectedService), om.writeValueAsString(actualService));
}
@@ -111,12 +129,12 @@ public class ToscaParserImpl2Test {
final Path csarPath = getCsarPath(mockHelper.getUuid());
log.info("Comparing for csar " + csarPath);
ServiceModel actualServiceModel = toscaParserImpl2.makeServiceModel(csarPath, getServiceByUuid(mockHelper.getUuid()));
- assertJsonStringEqualsIgnoreNulls(om.writeValueAsString(mockHelper.getNewServiceModel()), om.writeValueAsString(actualServiceModel));
+ assertJsonStringEqualsIgnoreNulls(om.writeValueAsString(mockHelper.getServiceModel()), om.writeValueAsString(actualServiceModel));
}
@Test(dataProvider = "expectedServiceModel")
public void assertEqualsBetweenNetworkNodes(String uuid, ToscaParserMockHelper mockHelper) throws Exception {
- Map<String, Network> expectedNetworksMap = mockHelper.getNewServiceModel().getNetworks();
+ Map<String, Network> expectedNetworksMap = mockHelper.getServiceModel().getNetworks();
Map<String, Network> actualNetworksMap = toscaParserImpl2.makeServiceModel(getCsarPath(mockHelper.getUuid()), getServiceByUuid(mockHelper.getUuid())).getNetworks();
for (Map.Entry<String, Network> entry : expectedNetworksMap.entrySet()) {
Network expectedNetwork = entry.getValue();
@@ -130,7 +148,7 @@ public class ToscaParserImpl2Test {
//Because we are not supporting the old flow, the JSON are different by definition.
@Test(dataProvider = "expectedServiceModel")
public void assertEqualsBetweenVnfsOfTosca(String uuid, ToscaParserMockHelper mockHelper) throws Exception {
- Map<String, VNF> expectedVnfsMap = mockHelper.getNewServiceModel().getVnfs();
+ Map<String, VNF> expectedVnfsMap = mockHelper.getServiceModel().getVnfs();
Map<String, VNF> actualVnfsMap = toscaParserImpl2.makeServiceModel(getCsarPath(mockHelper.getUuid()), getServiceByUuid(mockHelper.getUuid())).getVnfs();
for (Map.Entry<String, VNF> entry : expectedVnfsMap.entrySet()) {
VNF expectedVnf = entry.getValue();
@@ -142,10 +160,12 @@ public class ToscaParserImpl2Test {
}
}
+
+
@Test(dataProvider = "expectedServiceModel")
public void assertEqualsBetweenCollectionResourcesOfTosca(String uuid, ToscaParserMockHelper mockHelper) throws Exception {
- Map<String, CR> expectedVnfsMap = mockHelper.getNewServiceModel().getCollectionResource();
- Map<String, CR> actualCRsMap = toscaParserImpl2.makeServiceModel(getCsarPath(mockHelper.getUuid()), getServiceByUuid(mockHelper.getUuid())).getCollectionResource();
+ Map<String, CR> expectedVnfsMap = mockHelper.getServiceModel().getCollectionResources();
+ Map<String, CR> actualCRsMap = toscaParserImpl2.makeServiceModel(getCsarPath(mockHelper.getUuid()), getServiceByUuid(mockHelper.getUuid())).getCollectionResources();
if(!actualCRsMap.isEmpty()) {
for (Map.Entry<String, CR> entry : expectedVnfsMap.entrySet()) {
CR expectedCR = entry.getValue();
@@ -201,28 +221,28 @@ public class ToscaParserImpl2Test {
@Test(dataProvider = "expectedServiceModel")
public void assertEqualsBetweenVolumeGroups(String uuid, ToscaParserMockHelper mockHelper) throws Exception {
Map<String, VolumeGroup> actualVolumeGroups = toscaParserImpl2.makeServiceModel(getCsarPath(mockHelper.getUuid()), getServiceByUuid(mockHelper.getUuid())).getVolumeGroups();
- Map<String, VolumeGroup> expectedVolumeGroups = mockHelper.getNewServiceModel().getVolumeGroups();
+ Map<String, VolumeGroup> expectedVolumeGroups = mockHelper.getServiceModel().getVolumeGroups();
assertJsonStringEqualsIgnoreNulls(om.writeValueAsString(expectedVolumeGroups), om.writeValueAsString(actualVolumeGroups));
}
@Test(dataProvider = "expectedServiceModel")
public void assertEqualsBetweenVfModules(String uuid, ToscaParserMockHelper mockHelper) throws Exception {
Map<String, VfModule> actualVfModules = toscaParserImpl2.makeServiceModel(getCsarPath(mockHelper.getUuid()), getServiceByUuid(mockHelper.getUuid())).getVfModules();
- Map<String, VfModule> expectedVfModules = mockHelper.getNewServiceModel().getVfModules();
+ Map<String, VfModule> expectedVfModules = mockHelper.getServiceModel().getVfModules();
assertJsonStringEqualsIgnoreNulls(om.writeValueAsString(expectedVfModules), om.writeValueAsString(actualVfModules));
}
@Test(dataProvider = "expectedServiceModel")
public void assertEqualsBetweenPolicyConfigurationNodes(String uuid, ToscaParserMockHelper mockHelper) throws Exception {
Map<String, PortMirroringConfig> actualConfigurations = toscaParserImpl2.makeServiceModel(getCsarPath(mockHelper.getUuid()), getServiceByUuid(mockHelper.getUuid())).getConfigurations();
- Map<String, PortMirroringConfig> expectedConfigurations = mockHelper.getNewServiceModel().getConfigurations();
+ Map<String, PortMirroringConfig> expectedConfigurations = mockHelper.getServiceModel().getConfigurations();
JsonAssert.assertJsonEquals(actualConfigurations, expectedConfigurations);
}
@Test
public void assertEqualsBetweenPolicyConfigurationByPolicyFalse() throws Exception {
ToscaParserMockHelper mockHelper = new ToscaParserMockHelper(Constants.configurationByPolicyFalseUuid, Constants.configurationByPolicyFalseFilePath);
- Map<String, PortMirroringConfig> expectedConfigurations = mockHelper.getNewServiceModel().getConfigurations();
+ Map<String, PortMirroringConfig> expectedConfigurations = mockHelper.getServiceModel().getConfigurations();
Map<String, PortMirroringConfig> actualConfigurations = toscaParserImpl2.makeServiceModel(getCsarPath(mockHelper.getUuid()), getServiceByUuid(mockHelper.getUuid())).getConfigurations();
setPprobeServiceProxy(expectedConfigurations);
@@ -250,7 +270,7 @@ public class ToscaParserImpl2Test {
final ToscaParserMockHelper mockHelper = new ToscaParserMockHelper("90fe6842-aa76-4b68-8329-5c86ff564407", "empty.json");
final ServiceModel serviceModel = toscaParserImpl2.makeServiceModel(getCsarPath(mockHelper.getUuid()), getServiceByUuid(mockHelper.getUuid()));
- assertJsonStringEqualsIgnoreNulls("{ vfModules: { 201712488_adiodvpe10..201712488AdiodVpe1..ADIOD_vRE_BV..module-1: { inputs: { availability_zone_0: { } } } } }", om.writeValueAsString(serviceModel));
+ assertJsonStringEqualsIgnoreNulls("{ vfModules: { 201712488_pasqualevpe10..201712488PasqualeVpe1..PASQUALE_vRE_BV..module-1: { inputs: { availability_zone_0: { } } } } }", om.writeValueAsString(serviceModel));
}
@Test
@@ -260,7 +280,7 @@ public class ToscaParserImpl2Test {
assertJsonStringEqualsIgnoreNulls("" +
"{ vnfs: " +
- " { \"201712-488_ADIOD-vPE-1 0\": " +
+ " { \"201712-488_PASQUALE-vPE-1 0\": " +
" { properties: { " +
" ecomp_generated_naming: \"true\", " +
" nf_naming: \"{naming_policy=SDNC_Policy.Config_MS_1806SRIOV_VPE_ADIoDJson, ecomp_generated_naming=true}\" " +
@@ -278,14 +298,14 @@ public class ToscaParserImpl2Test {
@Test(dataProvider = "expectedServiceModel")
public void assertEqualsBetweenServiceProxyNodes(String uuid, ToscaParserMockHelper mockHelper) throws Exception {
Map<String, ServiceProxy> actualServiceProxies = toscaParserImpl2.makeServiceModel(getCsarPath(mockHelper.getUuid()), getServiceByUuid(mockHelper.getUuid())).getServiceProxies();
- Map<String, ServiceProxy> expectedServiceProxies = mockHelper.getNewServiceModel().getServiceProxies();
+ Map<String, ServiceProxy> expectedServiceProxies = mockHelper.getServiceModel().getServiceProxies();
JsonAssert.assertJsonEquals(actualServiceProxies, expectedServiceProxies);
}
@Test(dataProvider = "expectedServiceModel")
public void assertEqualsBetweenVnfGroups(String uuid, ToscaParserMockHelper mockHelper) throws Exception {
Map<String, ResourceGroup> actualVnfGroups = toscaParserImpl2.makeServiceModel(getCsarPath(mockHelper.getUuid()), getServiceByUuid(mockHelper.getUuid())).getVnfGroups();
- Map<String, ResourceGroup> expectedVnfGroups = mockHelper.getNewServiceModel().getVnfGroups();
+ Map<String, ResourceGroup> expectedVnfGroups = mockHelper.getServiceModel().getVnfGroups();
JsonAssert.assertJsonEquals(actualVnfGroups, expectedVnfGroups);
}
@@ -342,7 +362,7 @@ public class ToscaParserImpl2Test {
static final String vfWithAnnotationUuid = "f4d84bb4-a416-4b4e-997e-0059973630b9";
static final String vlUuid = "cb49608f-5a24-4789-b0f7-2595473cb997";
static final String crUuid = "76f27dfe-33e5-472f-8e0b-acf524adc4f0";
- static final String vfWithVfcGroup = "6bce7302-70bd-4057-b48e-8d5b99e686ca"; //service-VdbeSrv-csar.zip
+ static final String vfWithVfcGroup = "6bce7302-70bd-4057-b48e-8d5b99e686ca"; //service-VdorotheaSrv-csar.zip
// public static final String PNFUuid = "68101369-6f08-4e99-9a28-fa6327d344f3";
static final String vfFilePath = "vf-csar.JSON";
static final String vlFilePath = "vl-csar.JSON";
@@ -358,6 +378,8 @@ public class ToscaParserImpl2Test {
//public static final String vnfGroupingUuid = "4117a0b6-e234-467d-b5b9-fe2f68c8b0fc";
//public static final String vnfGroupingFilePath = "vnf-grouping-csar.json";
+ public static final String QUANTITY = "quantity";
+
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/asdc/parser/ToscaParserInflatorTest.java b/vid-app-common/src/test/java/org/onap/vid/asdc/parser/ToscaParserInflatorTest.java
index 4c5cc9787..d6c080d55 100644
--- a/vid-app-common/src/test/java/org/onap/vid/asdc/parser/ToscaParserInflatorTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/asdc/parser/ToscaParserInflatorTest.java
@@ -20,7 +20,16 @@
package org.onap.vid.asdc.parser;
+import static java.util.Collections.emptyMap;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
import com.google.common.collect.ImmutableMap;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Path;
+import java.util.Map;
+import java.util.UUID;
import org.apache.commons.io.IOUtils;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
@@ -41,16 +50,6 @@ import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.file.Path;
-import java.util.Map;
-import java.util.UUID;
-
-import static java.util.Collections.emptyMap;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
-
public class ToscaParserInflatorTest {
private static final Logger log = LogManager.getLogger(ToscaParserInflatorTest.class);
@@ -83,15 +82,15 @@ public class ToscaParserInflatorTest {
@Test
public void inflateFabricConfigurationModel_allIdsAreGiven() throws Exception {
- final String fabricConfigurationUuid = "90fe6842-aa76-4b68-8329-5c86ff564407";
+ final String fabricConfigurationUuid = "12344bb4-a416-4b4e-997e-0059973630b9";
final Map<String, Names> inflated = inflateModelByUuid(fabricConfigurationUuid);
// see vf-with-annotation-csar.json
assertThat(inflated, is(ImmutableMap.of(
- "8df1892c-377d-460b-8a8d-fc8a116e9d92", doubleName("201712-488_ADIOD-vPE-1 0"),
- "8d521692-7661-4296-b77e-a2058bb62e87", new Names("201712488AdiodVpe1..ADIOD_vRE_BV..module-1", "201712488_adiodvpe10..201712488AdiodVpe1..ADIOD_vRE_BV..module-1"),
- "79fbee20-7fba-4166-ae4b-b94c869e7d8b", new Names("201712488AdiodVpe1..ADIOD_vPFE_BV..module-2","201712488_adiodvpe10..201712488AdiodVpe1..ADIOD_vPFE_BV..module-2"),
- "806505b8-7a7c-47a2-acef-b4d26fe95a92", new Names("201712488AdiodVpe1..ADIOD_base_vPE_BV..module-0","201712488_adiodvpe10..201712488AdiodVpe1..ADIOD_base_vPE_BV..module-0")
+ "ea81d6f7-0861-44a7-b7d5-d173b562c350", doubleName("2017-488_PASQUALE-vPE 0"),
+ "a5d8df05-11cb-4351-96e0-b6d4168ea4df", new Names("2017488PasqualeVpe..PASQUALE_vRE_BV..module-1", "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vRE_BV..module-1"),
+ "b3e8b26e-cff0-49fc-a4e6-f3e16c8440fe", new Names("2017488PasqualeVpe..PASQUALE_vPFE_BV..module-2","2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vPFE_BV..module-2"),
+ "040e591e-5d30-4e0d-850f-7266e5a8e013", new Names("2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0","2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0")
)));
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/asdc/parser/VidNotionsBuilderTest.java b/vid-app-common/src/test/java/org/onap/vid/asdc/parser/VidNotionsBuilderTest.java
index 788f78084..edaf7125f 100644
--- a/vid-app-common/src/test/java/org/onap/vid/asdc/parser/VidNotionsBuilderTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/asdc/parser/VidNotionsBuilderTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -30,28 +30,35 @@ import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
-import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory;
import org.onap.sdc.toscaparser.api.NodeTemplate;
import org.onap.sdc.toscaparser.api.Property;
import org.onap.sdc.toscaparser.api.elements.Metadata;
import org.onap.vid.model.*;
import org.onap.vid.properties.Features;
+import org.onap.vid.testUtils.TestUtils;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.togglz.core.manager.FeatureManager;
-import java.util.LinkedHashMap;
-import java.util.UUID;
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.*;
import java.util.function.BiConsumer;
+import static java.util.Collections.emptyList;
+import static java.util.Collections.emptyMap;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasProperty;
import static org.hamcrest.Matchers.is;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import static org.testng.Assert.assertEquals;
+import static org.onap.vid.model.VidNotions.*;
+import static org.testng.AssertJUnit.assertEquals;
public class VidNotionsBuilderTest {
@@ -61,6 +68,10 @@ public class VidNotionsBuilderTest {
@Mock
private FeatureManager featureManagerMock;
+ private ServiceModel serviceModel;
+
+ private ISdcCsarHelper csarHelper;
+
@BeforeClass
public void initMocks() {
MockitoAnnotations.initMocks(this);
@@ -75,12 +86,12 @@ public class VidNotionsBuilderTest {
public void VLNetworkWithPropertyNetworkTechnologyOVS_UIHintIsPositive() {
ISdcCsarHelper csarHelper = mockForNonLegacyInstantiationUI();
- assertThat(vidNotionsBuilder.suggestInstantiationUI(csarHelper), is(VidNotions.InstantiationUI.NETWORK_WITH_PROPERTY_NETWORK_TECHNOLOGY_EQUALS_STANDARD_SRIOV_OR_OVS));
- assertThat(vidNotionsBuilder.suggestModelCategory(csarHelper) , is(VidNotions.ModelCategory.IS_5G_PROVIDER_NETWORK_MODEL));
+ assertThat(vidNotionsBuilder.suggestInstantiationUI(csarHelper, serviceModel), is(InstantiationUI.NETWORK_WITH_PROPERTY_NETWORK_TECHNOLOGY_EQUALS_STANDARD_SRIOV_OR_OVS));
+ assertThat(vidNotionsBuilder.suggestModelCategory(csarHelper, serviceModel) , is(ModelCategory.IS_5G_PROVIDER_NETWORK_MODEL));
}
@NotNull
- protected ISdcCsarHelper mockForNonLegacyInstantiationUI() {
+ private ISdcCsarHelper mockForNonLegacyInstantiationUI() {
ISdcCsarHelper csarHelper = ToscaParserImpl2Test.getMockedSdcCsarHelper(UUID.randomUUID().toString());
NodeTemplate nodeTemplate = mock(NodeTemplate.class);
@@ -98,15 +109,16 @@ public class VidNotionsBuilderTest {
@DataProvider
public static Object[][] anyAlacarteDataProvider() {
return new Object[][] {
- {"A-La-Carte", VidNotions.InstantiationUI.ANY_ALACARTE_NEW_UI},
- {"Macro", VidNotions.InstantiationUI.LEGACY},
+ {"A-La-Carte", InstantiationUI.ANY_ALACARTE_NEW_UI},
+ {"Macro", InstantiationUI.LEGACY},
};
}
@Test(dataProvider = "anyAlacarteDataProvider")
- public void FLAG_EXP_ANY_ALACARTE_NEW_INSTANTIATION_UI_is_active_UIHintIsPositive(String instantiationType, VidNotions.InstantiationUI expectedInstantiationUI) {
+ public void FLAG_EXP_ANY_ALACARTE_NEW_INSTANTIATION_UI_is_active_UIHintIsPositive(String instantiationType, InstantiationUI expectedInstantiationUI) {
+ initServiceModelAndscarHelperWithMocks();
+
when(featureManagerMock.isActive(Features.FLAG_EXP_ANY_ALACARTE_NEW_INSTANTIATION_UI)).thenReturn(true);
- ISdcCsarHelper csarHelper = ToscaParserImpl2Test.getMockedSdcCsarHelper(UUID.randomUUID().toString());
when(csarHelper.getServiceMetadata()).thenReturn(new Metadata(ImmutableMap.of(
"instantiationType", instantiationType
)));
@@ -119,12 +131,12 @@ public class VidNotionsBuilderTest {
when(csarHelper.getServiceVlList()).thenReturn(ImmutableList.of(nodeTemplate));
- assertThat(vidNotionsBuilder.suggestInstantiationUI(csarHelper), is(expectedInstantiationUI));
+ assertThat(vidNotionsBuilder.suggestInstantiationUI(csarHelper, serviceModel), is(expectedInstantiationUI));
}
@Test
public void VLNetworkWithPropertyNetworkTechnologyNot5G_UIHintIsNegative() {
- ISdcCsarHelper csarHelper = ToscaParserImpl2Test.getMockedSdcCsarHelper(UUID.randomUUID().toString());
+ initServiceModelAndscarHelperWithMocks();
NodeTemplate nodeTemplate = mock(NodeTemplate.class);
@@ -135,85 +147,91 @@ public class VidNotionsBuilderTest {
when(csarHelper.getServiceVlList()).thenReturn(ImmutableList.of(nodeTemplate));
- assertThat(vidNotionsBuilder.suggestInstantiationUI(csarHelper), is(VidNotions.InstantiationUI.LEGACY));
- assertThat(vidNotionsBuilder.suggestModelCategory(csarHelper) , is(VidNotions.ModelCategory.OTHER));
+ assertThat(vidNotionsBuilder.suggestInstantiationUI(csarHelper, serviceModel), is(InstantiationUI.LEGACY));
+ assertThat(vidNotionsBuilder.suggestModelCategory(csarHelper, serviceModel) , is(ModelCategory.OTHER));
}
@Test
- public void withoutMocks_givenZippedToscaFile_hasAnyNetworkWithPropertyEqualsToAnyOfYieldsTrue() throws SdcToscaParserException {
- SdcToscaParserFactory factory = SdcToscaParserFactory.getInstance();
- ISdcCsarHelper csarHelper = factory.getSdcCsarHelper(getClass().getClassLoader().getResource("service-vl-csar.zip").getPath(),false);
-
+ public void withoutMocks_givenZippedToscaFile_hasAnyNetworkWithPropertyEqualsToAnyOfYieldsTrue() throws SdcToscaParserException, IOException {
+ initServiceModelAndscarHelperWithRealCsar("/csars/service-vl-csar.zip");
assertThat(vidNotionsBuilder.isALaCarte(csarHelper), is(false));
assertThat(vidNotionsBuilder.hasAnyNetworkWithPropertyEqualsToAnyOf(csarHelper, "unexpected_property_name"), is(false));
assertThat(vidNotionsBuilder.hasAnyNetworkWithPropertyEqualsToAnyOf(csarHelper, "network_technology","Standard-SR-IOV"), is(true));
- assertThat(vidNotionsBuilder.suggestInstantiationUI(csarHelper), is(VidNotions.InstantiationUI.LEGACY));
+ assertThat(vidNotionsBuilder.suggestInstantiationUI(csarHelper, serviceModel), is(InstantiationUI.LEGACY));
}
- //@Test
- //public void withoutMocks_givenZippedToscaFile_hasFabricConfigurationYieldsTrue() throws SdcToscaParserException {
- // SdcToscaParserFactory factory = SdcToscaParserFactory.getInstance();
- // ISdcCsarHelper csarHelper = factory.getSdcCsarHelper(getClass().getClassLoader().getResource("service-fabric-configuration.zip").getPath(),false);
- //
- // assertThat(vidNotionsBuilder.isALaCarte(csarHelper), is(false));
- // assertThat(vidNotionsBuilder.hasFabricConfiguration(csarHelper), is(true));
- // assertThat(vidNotionsBuilder.suggestInstantiationUI(csarHelper), is(VidNotions.InstantiationUI.LEGACY));
- //}
+ @Test
+ public void withoutMocks_givenZippedToscaFile_hasFabricConfigurationYieldsTrue() throws SdcToscaParserException, IOException {
+ initServiceModelAndscarHelperWithRealCsar("/csars/service-fabric-configuration.zip");
+ assertThat(vidNotionsBuilder.isALaCarte(csarHelper), is(false));
+ assertThat(vidNotionsBuilder.hasFabricConfiguration(csarHelper), is(true));
+ assertThat(vidNotionsBuilder.suggestInstantiationUI(csarHelper, serviceModel), is(InstantiationUI.LEGACY));
+ }
+
+ @Test(dataProvider = "trueAndFalse", dataProviderClass = TestUtils.class)
+ public void withoutMocks_givenZippedToscaFileOfTransportService_InstantiationUIAndCategoryAreRight(boolean flagValue) throws SdcToscaParserException, IOException {
+ initServiceModelAndscarHelperWithRealCsar("/csars/csarTransportWithPnfs.zip");
+ when(featureManagerMock.isActive(Features.FLAG_1908_TRANSPORT_SERVICE_NEW_INSTANTIATION_UI)).thenReturn(flagValue);
+
+ assertThat(vidNotionsBuilder.isALaCarte(csarHelper), is(false));
+ assertThat(vidNotionsBuilder.suggestInstantiationUI(csarHelper, serviceModel), is(flagValue ? InstantiationUI.TRANSPORT_SERVICE : InstantiationUI.LEGACY));
+ assertThat(vidNotionsBuilder.suggestModelCategory(csarHelper, serviceModel), is(ModelCategory.Transport));
+ }
+
+ @Test(dataProvider = "trueAndFalse", dataProviderClass = TestUtils.class)
+ public void withoutMocks_givenZippedToscaFileOfInfraStructureVpn_InstantiationUIIsRight(boolean flagValue) throws SdcToscaParserException, IOException {
+ initServiceModelAndscarHelperWithRealCsar("/csars/service-Infravpn-csar.zip");
+ when(featureManagerMock.isActive(Features.FLAG_1908_INFRASTRUCTURE_VPN)).thenReturn(flagValue);
+ assertThat(vidNotionsBuilder.suggestInstantiationUI(csarHelper, serviceModel), is(flagValue ? InstantiationUI.INFRASTRUCTURE_VPN : InstantiationUI.LEGACY));
+ assertThat(vidNotionsBuilder.suggestModelCategory(csarHelper, serviceModel), is(ModelCategory.INFRASTRUCTURE_VPN));
+ }
@Test
public void uuidIsExactly1ffce89fEtc_UIHintIsPositive() {
- ISdcCsarHelper csarHelper = ToscaParserImpl2Test.getMockedSdcCsarHelper(UUID.randomUUID().toString());
+ initServiceModelAndscarHelperWithMocks();
when(csarHelper.getServiceMetadata()).thenReturn(new Metadata(ImmutableMap.of(
"UUID", "95eb2c44-bff2-4e8b-ad5d-8266870b7717"
)));
when(featureManagerMock.isActive(Features.FLAG_5G_IN_NEW_INSTANTIATION_UI)).thenReturn(true);
- assertThat(vidNotionsBuilder.suggestInstantiationUI(csarHelper), is(VidNotions.InstantiationUI.SERVICE_UUID_IS_1ffce89f_ef3f_4cbb_8b37_82134590c5de));
- }
-
-
- @DataProvider
- public static Object[][] trueAndFalse() {
- return new Object[][] {{true}, {false}};
+ assertThat(vidNotionsBuilder.suggestInstantiationUI(csarHelper, serviceModel), is(InstantiationUI.SERVICE_UUID_IS_1ffce89f_ef3f_4cbb_8b37_82134590c5de));
}
- @Test(dataProvider = "trueAndFalse")
+ @Test(dataProvider = "trueAndFalse", dataProviderClass = TestUtils.class)
public void buildVidNotions_nullByFlag(boolean flagValue) {
- ISdcCsarHelper csarHelper = ToscaParserImpl2Test.getMockedSdcCsarHelper(UUID.randomUUID().toString());
+ initServiceModelAndscarHelperWithMocks();
when(featureManagerMock.isActive(Features.FLAG_5G_IN_NEW_INSTANTIATION_UI)).thenReturn(flagValue);
- assertThat(vidNotionsBuilder.buildVidNotions(csarHelper, null), hasProperty("instantiationUI", is(VidNotions.InstantiationUI.LEGACY)));
+ assertThat(vidNotionsBuilder.buildVidNotions(csarHelper, serviceModel), hasProperty("instantiationUI", is(InstantiationUI.LEGACY)));
}
@DataProvider
public static Object[][] ServiceRoleTypesDataProvider() {
return new Object[][] {
- {"gROUPING", VidNotions.InstantiationUI.SERVICE_WITH_VNF_GROUPING},
- {"", VidNotions.InstantiationUI.LEGACY},
+ {"gROUPING", InstantiationUI.SERVICE_WITH_VNF_GROUPING},
+ {"", InstantiationUI.LEGACY},
};
}
@Test(dataProvider = "ServiceRoleTypesDataProvider")
- public void testGetViewEditUITypeForResourceGroup(String serviceRole, VidNotions.InstantiationUI expectedViewEditUI) {
- when(featureManagerMock.isActive(Features.FLAG_ASYNC_INSTANTIATION)).thenReturn(true);
+ public void testGetViewEditUITypeForResourceGroup(String serviceRole, InstantiationUI expectedViewEditUI) {
+ initServiceModelAndscarHelperWithMocks();
when(featureManagerMock.isActive(Features.FLAG_1902_VNF_GROUPING)).thenReturn(true);
- ISdcCsarHelper csarHelper = ToscaParserImpl2Test.getMockedSdcCsarHelper(UUID.randomUUID().toString());
when(csarHelper.getServiceMetadata()).thenReturn(new Metadata(ImmutableMap.of(
"serviceRole", serviceRole
)));
- assertThat(vidNotionsBuilder.suggestViewEditUI(csarHelper, null), is(expectedViewEditUI));
+ assertThat(vidNotionsBuilder.suggestViewEditUI(csarHelper, serviceModel), is(expectedViewEditUI));
}
@DataProvider
public static Object[][] macroToViewEditDataProvider() {
return new Object[][] {
- {"macro service + not excluded + needed flags are open", true, false, true, true, VidNotions.InstantiationUI.MACRO_SERVICE},
- {"not macro service", false, false, true, true, VidNotions.InstantiationUI.LEGACY},
- {"macro that shall be excluded because it has pnf", true, true, true, true, VidNotions.InstantiationUI.LEGACY},
- {"macro service + FLAG_ASYNC_INSTANTIATION off", true, false, false, true, VidNotions.InstantiationUI.LEGACY},
- {"macro service + FLAG_1902_NEW_VIEW_EDIT off", true, false, true, false, VidNotions.InstantiationUI.LEGACY},
+ {"macro service + not excluded + needed flags are open", true, false, true, InstantiationUI.MACRO_SERVICE},
+ {"not macro service", false, true, true, InstantiationUI.LEGACY},
+ {"macro that shall be excluded because it has pnf", true, true, true, InstantiationUI.LEGACY},
+ {"macro service + FLAG_1902_NEW_VIEW_EDIT off", true, false, false, InstantiationUI.LEGACY},
};
}
@@ -222,19 +240,16 @@ public class VidNotionsBuilderTest {
String testDescription,
boolean isMacro,
boolean isExcluded,
- boolean isFlagAsyncInstantiationActive,
boolean isFlag1902NewViewEdit,
- VidNotions.InstantiationUI expectedViewEditUi) {
+ InstantiationUI expectedViewEditUi) {
- ISdcCsarHelper csarHelper = mock(ISdcCsarHelper.class);
- ServiceModel serviceModel = mock(ServiceModel.class);
+ initServiceModelAndscarHelperWithMocks();
//mock for is Macro
String instantiationType = isMacro ? ToscaParserImpl2.Constants.MACRO : ToscaParserImpl2.Constants.A_LA_CARTE;
Service service = mock(Service.class);
when(serviceModel.getService()).thenReturn(service);
when(service.getInstantiationType()).thenReturn(instantiationType);
- when(featureManagerMock.isActive(Features.FLAG_ASYNC_INSTANTIATION)).thenReturn(isFlagAsyncInstantiationActive);
when(featureManagerMock.isActive(Features.FLAG_1902_NEW_VIEW_EDIT)).thenReturn(isFlag1902NewViewEdit);
//mock for isExcluded
@@ -242,17 +257,16 @@ public class VidNotionsBuilderTest {
when(serviceModel.getPnfs()).thenReturn(ImmutableMap.of("a", mock(Node.class)));
}
- VidNotions.InstantiationUI result = vidNotionsBuilder.suggestViewEditUI(csarHelper, serviceModel);
+ InstantiationUI result = vidNotionsBuilder.suggestViewEditUI(csarHelper, serviceModel);
assertEquals(expectedViewEditUi, result);
}
@DataProvider
public static Object[][] instantiationUIToViewEditDataProvider() {
return new Object[][] {
- {"network cloud(5G) service + needed flags are open", true, true, true, VidNotions.InstantiationUI.NETWORK_WITH_PROPERTY_NETWORK_TECHNOLOGY_EQUALS_STANDARD_SRIOV_OR_OVS},
- {"mocked service + needed flags are open", false, true, true, VidNotions.InstantiationUI.LEGACY},
- {"network cloud(5G) service + FLAG_ASYNC_INSTANTIATION is off", true, false, true, VidNotions.InstantiationUI.LEGACY},
- {"network cloud(5G) service + FLAG_1902_NEW_VIEW_EDIT is off", true, true, false, VidNotions.InstantiationUI.LEGACY},
+ {"network cloud(5G) service + needed flags are open", true, true, InstantiationUI.NETWORK_WITH_PROPERTY_NETWORK_TECHNOLOGY_EQUALS_STANDARD_SRIOV_OR_OVS},
+ {"mocked service + needed flags are open", false, true, InstantiationUI.LEGACY},
+ {"network cloud(5G) service + FLAG_1902_NEW_VIEW_EDIT is off", true, false, InstantiationUI.LEGACY},
};
}
@@ -261,12 +275,10 @@ public class VidNotionsBuilderTest {
public void whenInstantiationUIIsNotLegacy_viewEditIsRight(
String testDescription,
boolean isInstantiationUINotLegacy,
- boolean isFlagAsyncInstantiationActive,
boolean isFlag1902NewViewEdit,
- VidNotions.InstantiationUI expectedViewEditUi) {
+ InstantiationUI expectedViewEditUi) {
ISdcCsarHelper csarHelper = isInstantiationUINotLegacy ? mockForNonLegacyInstantiationUI() : mock(ISdcCsarHelper.class);
- when(featureManagerMock.isActive(Features.FLAG_ASYNC_INSTANTIATION)).thenReturn(isFlagAsyncInstantiationActive);
when(featureManagerMock.isActive(Features.FLAG_1902_NEW_VIEW_EDIT)).thenReturn(isFlag1902NewViewEdit);
ServiceModel serviceModel = mock(ServiceModel.class);
@@ -274,7 +286,7 @@ public class VidNotionsBuilderTest {
when(serviceModel.getService()).thenReturn(service);
when(service.getInstantiationType()).thenReturn(ToscaParserImpl2.Constants.A_LA_CARTE);
- VidNotions.InstantiationUI result = vidNotionsBuilder.suggestViewEditUI(csarHelper, serviceModel);
+ InstantiationUI result = vidNotionsBuilder.suggestViewEditUI(csarHelper, serviceModel);
assertEquals(expectedViewEditUi, result);
}
@@ -282,7 +294,7 @@ public class VidNotionsBuilderTest {
public static Object[][] mockerForMacroExcluded() {
return new Object[][] {
{"service with pnfs", (BiConsumer<ServiceModel, FeatureManager>) (serviceModel, fm)->when(serviceModel.getPnfs()).thenReturn(ImmutableMap.of("a", mock(Node.class))), true},
- {"service with collection resource", (BiConsumer<ServiceModel, FeatureManager>) (serviceModel, fm)->when(serviceModel.getCollectionResource()).thenReturn(ImmutableMap.of("a", mock(CR.class))), true},
+ {"service with collection resource", (BiConsumer<ServiceModel, FeatureManager>) (serviceModel, fm) -> when(serviceModel.getCollectionResources()).thenReturn(ImmutableMap.of("a", mock(CR.class))), true},
{"service with network + FLAG_NETWORK_TO_ASYNC_INSTANTIATION false ", (BiConsumer<ServiceModel, FeatureManager>) (serviceModel, fm)->{
when(serviceModel.getNetworks()).thenReturn(ImmutableMap.of("a", mock(Network.class)));
when(fm.isActive(Features.FLAG_NETWORK_TO_ASYNC_INSTANTIATION)).thenReturn(false);}
@@ -290,7 +302,7 @@ public class VidNotionsBuilderTest {
{"service with network + FLAG_NETWORK_TO_ASYNC_INSTANTIATION true", (BiConsumer<ServiceModel, FeatureManager>) (serviceModel, fm)->{
when(serviceModel.getNetworks()).thenReturn(ImmutableMap.of("a", mock(Network.class)));
when(fm.isActive(Features.FLAG_NETWORK_TO_ASYNC_INSTANTIATION)).thenReturn(true);}
- , false},
+ , false},
{"empty service + FLAG_NETWORK_TO_ASYNC_INSTANTIATION false", (BiConsumer<ServiceModel, FeatureManager>) (serviceModel, fm)->when(fm.isActive(Features.FLAG_NETWORK_TO_ASYNC_INSTANTIATION)).thenReturn(false), false},
};
}
@@ -302,9 +314,197 @@ public class VidNotionsBuilderTest {
assertEquals(shallBeExcluded, vidNotionsBuilder.isMacroExcludedFromAsyncFlow(serviceModel));
}
+ @DataProvider
+ public static Object[][] toscaParserInstantiationTypeToVidNotion() {
+ return new Object[][] {
+ {ToscaParserImpl2.Constants.MACRO, InstantiationType.Macro},
+ {ToscaParserImpl2.Constants.A_LA_CARTE, InstantiationType.ALaCarte},
+ {ToscaParserImpl2.Constants.CLIENT_CONFIG, InstantiationType.ClientConfig},
+ {"I dont know", InstantiationType.ClientConfig},
+ {"", InstantiationType.ClientConfig}
+ };
+ }
+
+ @Test(dataProvider="toscaParserInstantiationTypeToVidNotion")
+ public void testSuggestInstantiationTypeWhenInstantiationUiLegacy(String toscaParserInstantiationType, InstantiationType expectedInstantiationType) {
+ ServiceModel serviceModel = mock(ServiceModel.class);
+ Service service = mock(Service.class);
+ when(serviceModel.getService()).thenReturn(service);
+ when(service.getInstantiationType()).thenReturn(toscaParserInstantiationType);
+ assertEquals(expectedInstantiationType, vidNotionsBuilder.suggestInstantiationType(serviceModel, ModelCategory.OTHER));
+ }
+
+ @DataProvider
+ public static Object[][] instantiationUIAndFeatureFlagsForInstantiationType() {
+ return new Object[][] {
+ {ModelCategory.Transport, Features.FLAG_1908_TRANSPORT_SERVICE_NEW_INSTANTIATION_UI, true, InstantiationType.Macro},
+ {ModelCategory.Transport, Features.FLAG_1908_TRANSPORT_SERVICE_NEW_INSTANTIATION_UI, false, InstantiationType.ALaCarte},
+ {ModelCategory.INFRASTRUCTURE_VPN, Features.FLAG_1908_INFRASTRUCTURE_VPN, true, InstantiationType.Macro},
+ {ModelCategory.INFRASTRUCTURE_VPN, Features.FLAG_1908_INFRASTRUCTURE_VPN, false, InstantiationType.ALaCarte},
+ {ModelCategory.OTHER, Features.FLAG_1908_INFRASTRUCTURE_VPN, true, InstantiationType.ALaCarte}, //not mapped InstantiationUI
+ };
+ }
+ @Test(dataProvider="instantiationUIAndFeatureFlagsForInstantiationType")
+ public void testSuggestInstantiationTypeByModelCategoryAndFeatureFlags(
+ ModelCategory instantiationUI,
+ Features featureFlag,
+ boolean isFeatureOn,
+ InstantiationType expectedInstantiationType) {
+ ServiceModel serviceModel = mock(ServiceModel.class);
+ Service service = mock(Service.class);
+ when(serviceModel.getService()).thenReturn(service);
+ when(service.getInstantiationType()).thenReturn(ToscaParserImpl2.Constants.A_LA_CARTE);
+ when(featureManagerMock.isActive(featureFlag)).thenReturn(isFeatureOn);
+ assertEquals(expectedInstantiationType, vidNotionsBuilder.suggestInstantiationType(serviceModel, instantiationUI));
+ }
+ @DataProvider
+ public static Object[][] FLAG_1908_COLLECTION_RESOURCE_NEW_INSTANTIATION_UIValueAndCollectionResourceForVidNotions() {
+ return new Object[][] {
+ {true, ImmutableMap.of("Some string", mock(CR.class)), InstantiationUI.SERVICE_WITH_COLLECTION_RESOURCE, ModelCategory.SERVICE_WITH_COLLECTION_RESOURCE},
+ {true, Collections.EMPTY_MAP, InstantiationUI.LEGACY, ModelCategory.OTHER},
+ {true, null, InstantiationUI.LEGACY, ModelCategory.OTHER},
+ {false, ImmutableMap.of("Some string", mock(CR.class)), InstantiationUI.LEGACY, ModelCategory.SERVICE_WITH_COLLECTION_RESOURCE},
+ {false, Collections.EMPTY_MAP, InstantiationUI.LEGACY, ModelCategory.OTHER},
+ {false, null, InstantiationUI.LEGACY, ModelCategory.OTHER}
+ };
+ }
+ @Test(dataProvider="FLAG_1908_COLLECTION_RESOURCE_NEW_INSTANTIATION_UIValueAndCollectionResourceForVidNotions")
+ public void testSuggestInstantiationUiAndModelCategoryByCollectionResourceAndFeatureFlag_FLAG_1908_COLLECTION_RESOURCE_NEW_INSTANTIATION_UI(
+ boolean featureFlagValue,
+ Map<String, CR> collectionResource,
+ VidNotions.InstantiationUI expectedInstantiationUi,
+ VidNotions.ModelCategory expectedModelCategory) {
+ initServiceModelAndscarHelperWithMocks();
+ Service service = mock(Service.class);
+ when(service.getInstantiationType()).thenReturn(ToscaParserImpl2.Constants.MACRO);
+ when(serviceModel.getService()).thenReturn(service);
+ when(serviceModel.getCollectionResources()).thenReturn(collectionResource);
+ when(featureManagerMock.isActive(Features.FLAG_1908_COLLECTION_RESOURCE_NEW_INSTANTIATION_UI)).thenReturn(featureFlagValue);
+ VidNotions vidNotions = vidNotionsBuilder.buildVidNotions(csarHelper, serviceModel);
+ assertEquals(expectedInstantiationUi, vidNotions.getInstantiationUI());
+ assertEquals(expectedModelCategory, vidNotions.getModelCategory());
+ assertEquals(InstantiationUI.LEGACY, vidNotions.getViewEditUI());
+ assertEquals(InstantiationType.Macro, vidNotions.getInstantiationType());
+ }
-}
+ @DataProvider
+ public static Object[][] givenCollectionResourceServiceDataProvider() {
+ return new Object[][]{
+ {false, true, InstantiationUI.LEGACY},
+ {true, false, InstantiationUI.LEGACY},
+ {true, true, InstantiationUI.SERVICE_WITH_COLLECTION_RESOURCE}
+ };
+ }
+
+ @Test(dataProvider = "givenCollectionResourceServiceDataProvider")
+ public void givenCollectionResourceService_whenSuggestViewEdit_thenResultAccordingFeatureFlag(
+ boolean crFlag, boolean resumeFlag, VidNotions.InstantiationUI expectedViewEditUi) {
+
+ //mock service with CR
+ ServiceModel mockServiceModel = mock(ServiceModel.class);
+ when(mockServiceModel.getCollectionResources()).thenReturn(ImmutableMap.of("a", mock(CR.class)));
+
+ //mock feature flags
+ when(featureManagerMock.isActive(Features.FLAG_1908_COLLECTION_RESOURCE_NEW_INSTANTIATION_UI)).thenReturn(crFlag);
+ when(featureManagerMock.isActive(Features.FLAG_1908_RESUME_MACRO_SERVICE)).thenReturn(resumeFlag);
+
+ assertEquals(expectedViewEditUi, vidNotionsBuilder.suggestViewEditUI(mock(ISdcCsarHelper.class), mockServiceModel));
+ }
+
+ @Test
+ public void whenServiceModelIsNull_thenInstantiationTypeIsClientConfig() {
+ assertEquals( InstantiationType.ClientConfig, vidNotionsBuilder.suggestInstantiationType(null, ModelCategory.OTHER));
+ }
+
+ @Test
+ public void whenServiceInServiceModelIsNull_thenInstantiationTypeIsClientConfig() {
+ assertEquals( InstantiationType.ClientConfig, vidNotionsBuilder.suggestInstantiationType(mock(ServiceModel.class), ModelCategory.OTHER));
+ }
+
+ @Test
+ public void whenInstantiationTypeInServiceModelIsNull_thenInstantiationTypeIsClientConfig() {
+ initServiceModelAndscarHelperWithMocks();
+ Service service = mock(Service.class);
+ when(serviceModel.getService()).thenReturn(service);
+ when(service.getInstantiationType()).thenReturn(null);
+ assertEquals( InstantiationType.ClientConfig, vidNotionsBuilder.suggestInstantiationType(serviceModel, ModelCategory.OTHER));
+ }
+
+ private void initServiceModelAndscarHelperWithRealCsar(String path) throws SdcToscaParserException, IOException {
+ Path csarPath = Paths.get(new File(getClass().getResource(path).getPath()).getCanonicalPath());
+ ToscaParserImpl2 toscaParser = new ToscaParserImpl2(vidNotionsBuilder);
+ org.onap.vid.asdc.beans.Service asdcServiceMetadata = mock(org.onap.vid.asdc.beans.Service.class);
+ when(asdcServiceMetadata.getVersion()).thenReturn("versions");
+ serviceModel = toscaParser.makeServiceModel(csarPath, asdcServiceMetadata);
+ csarHelper = toscaParser.getSdcCsarHelper(csarPath);
+ }
+
+ private void initServiceModelAndscarHelperWithMocks() {
+ csarHelper = ToscaParserImpl2Test.getMockedSdcCsarHelper(UUID.randomUUID().toString());
+ serviceModel = mock(ServiceModel.class);
+ }
+
+ @DataProvider
+ public static Object[][] VnfNcIndicationDataProvider() {
+ return new Object[][] {
+ {true, "VNF", InstantiationUI.A_LA_CARTE_VNF_SERVICE_ROLE},
+ {false, "VNF", InstantiationUI.LEGACY},
+ {false, "notVNF", InstantiationUI.LEGACY},
+ {true, null, InstantiationUI.LEGACY},
+ {true, "notVNF", InstantiationUI.LEGACY},
+ {true, "vnf", InstantiationUI.A_LA_CARTE_VNF_SERVICE_ROLE},
+ };
+ }
+
+ @Test (dataProvider = "VnfNcIndicationDataProvider")
+ public void whenServiceRoleVnf_thenInstantiationTypeNewUI(boolean flagOn, String serviceRole, InstantiationUI expectedViewEditUi){
+ initServiceModelAndscarHelperWithMocks();
+
+ when(featureManagerMock.isActive(Features.FLAG_1908_A_LA_CARTE_VNF_NEW_INSTANTIATION_UI)).thenReturn(flagOn);
+
+ when(csarHelper.getServiceMetadata()).thenReturn(new Metadata(serviceRole == null ?
+ emptyMap() : ImmutableMap.of(ToscaParserImpl2.Constants.SERVICE_ROLE, serviceRole)
+ ));
+
+ assertEquals(expectedViewEditUi, vidNotionsBuilder.suggestInstantiationUI(csarHelper, serviceModel));
+ }
+
+ private static NodeTemplate mockNodeTemplateChild(boolean withFabricConfiguration) {
+ NodeTemplate child = mock(NodeTemplate.class);
+ when(child.getType()).thenReturn(withFabricConfiguration ? ToscaParserImpl2.Constants.FABRIC_CONFIGURATION_TYPE : "nothing");
+ return child;
+ }
+
+ private static ISdcCsarHelper mockServiceNodeTemplates(ISdcCsarHelper csarHelper, ImmutableList<NodeTemplate> children) {
+ when(csarHelper.getNodeTemplateChildren(any())).thenReturn(children);
+
+ NodeTemplate parent = mock(NodeTemplate.class);
+ List<NodeTemplate> nodeTemplates = ImmutableList.of(parent);
+
+ when(csarHelper.getServiceNodeTemplates()).thenReturn(nodeTemplates);
+ return csarHelper;
+ }
+
+ @DataProvider
+ public static Object[][] csarHelpersForFabricConfiguration() {
+ ISdcCsarHelper csarHelperWithNoNodes = mock(ISdcCsarHelper.class);
+ when(csarHelperWithNoNodes.getServiceNodeTemplates()).thenReturn(emptyList());
+
+ return new Object[][] {
+ { "zero nodes", false, csarHelperWithNoNodes },
+ { "single node with no child", false, mockServiceNodeTemplates(mock(ISdcCsarHelper.class), ImmutableList.of()) },
+ { "single node with single fabric child", true, mockServiceNodeTemplates(mock(ISdcCsarHelper.class), ImmutableList.of(mockNodeTemplateChild(true))) },
+ { "single node with single fabric child and single non-fabric", true, mockServiceNodeTemplates(mock(ISdcCsarHelper.class), ImmutableList.of(
+ mockNodeTemplateChild(true), mockNodeTemplateChild(true))) },
+ };
+ }
+
+ @Test (dataProvider = "csarHelpersForFabricConfiguration")
+ public void hasFabricConfiguration(String desc, boolean shouldHaveFabricConfiguration, ISdcCsarHelper csarHelper) {
+ assertThat(desc, vidNotionsBuilder.hasFabricConfiguration(csarHelper), is(shouldHaveFabricConfiguration));
+ }
+} \ No newline at end of file
diff --git a/vid-app-common/src/test/java/org/onap/vid/changeManagement/WorkflowRequestDetailTest.java b/vid-app-common/src/test/java/org/onap/vid/changeManagement/WorkflowRequestDetailTest.java
index 38f15d7e5..fbaa763cf 100644
--- a/vid-app-common/src/test/java/org/onap/vid/changeManagement/WorkflowRequestDetailTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/changeManagement/WorkflowRequestDetailTest.java
@@ -19,15 +19,17 @@
*/
package org.onap.vid.changeManagement;
-import org.testng.annotations.Test;
-
import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
import static org.hamcrest.MatcherAssert.assertThat;
+import org.onap.vid.testUtils.TestUtils;
+import org.testng.annotations.Test;
+
public class WorkflowRequestDetailTest {
@Test
public void shouldHaveProperSettersAndGetters() {
+ TestUtils.registerCloudConfigurationValueGenerator();
assertThat(WorkflowRequestDetail.class, hasValidGettersAndSetters());
}
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/config/DataSourceConfig.java b/vid-app-common/src/test/java/org/onap/vid/config/DataSourceConfig.java
index 43adc8cf1..15f849a58 100644
--- a/vid-app-common/src/test/java/org/onap/vid/config/DataSourceConfig.java
+++ b/vid-app-common/src/test/java/org/onap/vid/config/DataSourceConfig.java
@@ -63,7 +63,7 @@ public class DataSourceConfig {
Resource[] mappingLocations = {
new ClassPathResource("WEB-INF/fusion/orm/Fusion.hbm.xml"),
new ClassPathResource("WEB-INF/fusion/orm/Workflow.hbm.xml"),
- new ClassPathResource("WEB-INF/fusion/orm/RNoteBookIntegration.hbm.xml")
+// new ClassPathResource("WEB-INF/fusion/orm/RNoteBookIntegration.hbm.xml")
};
sessionFactory.setHibernateProperties(properties);
diff --git a/vid-app-common/src/test/java/org/onap/vid/config/JobAdapterConfig.java b/vid-app-common/src/test/java/org/onap/vid/config/JobAdapterConfig.java
index 7462a32b2..149fad354 100644
--- a/vid-app-common/src/test/java/org/onap/vid/config/JobAdapterConfig.java
+++ b/vid-app-common/src/test/java/org/onap/vid/config/JobAdapterConfig.java
@@ -7,9 +7,9 @@
* 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.
@@ -21,33 +21,26 @@
package org.onap.vid.config;
-import org.hibernate.SessionFactory;
+import org.mockito.Mockito;
import org.onap.vid.job.JobAdapter;
-import org.onap.vid.job.JobsBrokerService;
import org.onap.vid.job.impl.JobAdapterImpl;
-import org.onap.vid.job.impl.JobsBrokerServiceInDatabaseImpl;
-import org.onap.vid.properties.VidProperties;
-import org.onap.portalsdk.core.service.DataAccessService;
-import org.onap.portalsdk.core.util.SystemProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
+import org.togglz.core.manager.FeatureManager;
@Configuration
@EnableTransactionManagement
public class JobAdapterConfig {
@Bean
- public JobAdapter jobAdapter() {
- return new JobAdapterImpl();
+ public FeatureManager featureManager() {
+ return Mockito.mock(FeatureManager.class);
}
@Bean
- public JobsBrokerService jobsBrokerService(DataAccessService dataAccessService, SessionFactory sessionFactory) {
- int maxOpenedInstantiationRequestsToMso = Integer.parseInt(SystemProperties.getProperty(VidProperties.MSO_MAX_OPENED_INSTANTIATION_REQUESTS));
- int pollingIntervalSeconds = Integer.parseInt(SystemProperties.getProperty(VidProperties.MSO_ASYNC_POLLING_INTERVAL_SECONDS));
-
- return new JobsBrokerServiceInDatabaseImpl(dataAccessService, sessionFactory, maxOpenedInstantiationRequestsToMso, pollingIntervalSeconds);
+ public JobAdapter jobAdapter(FeatureManager featureManager) {
+ return new JobAdapterImpl(featureManager);
}
-}
+} \ No newline at end of file
diff --git a/vid-app-common/src/test/java/org/onap/vid/config/JobCommandsConfigWithMockedMso.java b/vid-app-common/src/test/java/org/onap/vid/config/JobCommandsConfigWithMockedMso.java
index 1fc46eeb9..c4f788689 100644
--- a/vid-app-common/src/test/java/org/onap/vid/config/JobCommandsConfigWithMockedMso.java
+++ b/vid-app-common/src/test/java/org/onap/vid/config/JobCommandsConfigWithMockedMso.java
@@ -28,6 +28,7 @@ import org.onap.vid.aai.util.HttpsAuthClient;
import org.onap.vid.aai.util.SSLContextProvider;
import org.onap.vid.aai.util.ServletRequestHelper;
import org.onap.vid.aai.util.SystemPropertyHelper;
+import org.onap.vid.dal.AsyncInstantiationRepository;
import org.onap.vid.job.JobAdapter;
import org.onap.vid.job.JobsBrokerService;
import org.onap.vid.job.command.*;
@@ -52,8 +53,13 @@ public class JobCommandsConfigWithMockedMso {
}
@Bean
- public JobsBrokerService jobsBrokerService(DataAccessService dataAccessService, SessionFactory sessionFactory) {
- return new JobsBrokerServiceInDatabaseImpl(dataAccessService, sessionFactory, 200, 0);
+ public VersionService versionService() {
+ return Mockito.mock(VersionService.class);
+ }
+
+ @Bean
+ public JobsBrokerService jobsBrokerService(DataAccessService dataAccessService, SessionFactory sessionFactory, VersionService versionService) {
+ return new JobsBrokerServiceInDatabaseImpl(dataAccessService, sessionFactory, 200, 0,versionService);
}
@Bean
@@ -76,9 +82,10 @@ public class JobCommandsConfigWithMockedMso {
return new HttpsAuthClient("some random path", systemPropertyHelper, sslContextProvider, featureManager);
}
+
@Bean
- public JobAdapter jobAdapter() {
- return new JobAdapterImpl();
+ public JobAdapter jobAdapter(FeatureManager featureManager) {
+ return new JobAdapterImpl(featureManager);
}
@Bean
@@ -100,119 +107,159 @@ public class JobCommandsConfigWithMockedMso {
}
@Bean
- public AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic(DataAccessService dataAccessService,
- JobAdapter jobAdapter,
- JobsBrokerService jobsBrokerService,
- SessionFactory sessionFactory,
- AaiClientInterface aaiClient,
- FeatureManager featureManager,
- CloudOwnerService cloudOwnerService) {
- return new AsyncInstantiationBusinessLogicImpl(dataAccessService, jobAdapter, jobsBrokerService, sessionFactory, aaiClient, featureManager, cloudOwnerService);
+ public MsoRequestBuilder msoRequestHandlerService(AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic,
+ CloudOwnerService cloudOwnerService,
+ AaiClientInterface aaiClient,
+ FeatureManager featureManager) {
+ return new MsoRequestBuilder(asyncInstantiationBusinessLogic, cloudOwnerService, aaiClient, featureManager);
}
-
@Bean
- @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
- public MacroServiceInstantiationCommand serviceInstantiationCommand() {
- return new MacroServiceInstantiationCommand();
+ public AsyncInstantiationRepository asyncInstantiationRepository(DataAccessService dataAccessService) {
+ return new AsyncInstantiationRepository(dataAccessService);
}
@Bean
- @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
- public ServiceInProgressStatusCommand inProgressStatusCommand() {
- return new ServiceInProgressStatusCommand();
+ public AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic(JobAdapter jobAdapter,
+ JobsBrokerService jobsBrokerService,
+ SessionFactory sessionFactory,
+ AaiClientInterface aaiClient,
+ FeatureManager featureManager,
+ CloudOwnerService cloudOwnerService,
+ AsyncInstantiationRepository asyncInstantiationRepository,
+ AuditService auditService) {
+ return new AsyncInstantiationBusinessLogicImpl(jobAdapter, jobsBrokerService, sessionFactory, aaiClient, featureManager, cloudOwnerService, asyncInstantiationRepository, auditService);
}
- @Bean
- @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
- public ALaCarteServiceInstantiationCommand aLaCarteServiceInstantiationCommand() {
- return new ALaCarteServiceInstantiationCommand();
- }
@Bean
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public ALaCarteServiceCommand aLaCarteServiceCommand(
AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic,
JobsBrokerService jobsBrokerService,
+ MsoRequestBuilder msoRequestBuilder,
MsoResultHandlerService msoResultHandlerService,
JobAdapter jobAdapter,
InProgressStatusService inProgressStatusService,
WatchChildrenJobsBL watchChildrenJobsBL,
- RestMsoImplementation restMso) {
- return new ALaCarteServiceCommand(inProgressStatusService, watchChildrenJobsBL, asyncInstantiationBusinessLogic, jobsBrokerService, msoResultHandlerService, jobAdapter, restMso);
+ RestMsoImplementation restMso,
+ AuditService auditService) {
+ return new ALaCarteServiceCommand(inProgressStatusService, watchChildrenJobsBL, asyncInstantiationBusinessLogic, jobsBrokerService, msoRequestBuilder, msoResultHandlerService, jobAdapter, restMso, auditService);
}
@Bean
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
- public InstanceGroupCommand instanceGroupCommand(
+ public MacroServiceCommand macroServiceCommand(
AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic,
- MsoResultHandlerService msoResultHandlerService, InProgressStatusService inProgressStatusService,
+ JobsBrokerService jobsBrokerService,
+ MsoRequestBuilder msoRequestBuilder,
+ MsoResultHandlerService msoResultHandlerService,
+ JobAdapter jobAdapter,
+ InProgressStatusService inProgressStatusService,
WatchChildrenJobsBL watchChildrenJobsBL,
- RestMsoImplementation restMso) {
- return new InstanceGroupCommand(asyncInstantiationBusinessLogic, restMso, msoResultHandlerService, inProgressStatusService, watchChildrenJobsBL);
+ RestMsoImplementation restMso,
+ AuditService auditService) {
+ return new MacroServiceCommand(inProgressStatusService, watchChildrenJobsBL, asyncInstantiationBusinessLogic, jobsBrokerService, msoRequestBuilder, msoResultHandlerService, jobAdapter, restMso, auditService);
}
- @Bean
- @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
- public VnfInstantiationCommand vnfInstantiationCommand() {
- return new VnfInstantiationCommand();
- }
@Bean
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
- public VolumeGroupInstantiationCommand volumeGroupInstantiationCommand() {
- return new VolumeGroupInstantiationCommand();
- }
-
- @Bean
- @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
- public WatchingCommandBaseModule watchingCommandBaseModule() {
- return new WatchingCommandBaseModule();
+ public NetworkCommand networkCommand(
+ AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic,
+ RestMsoImplementation restMso,
+ MsoRequestBuilder msoRequestBuilder,
+ MsoResultHandlerService msoResultHandlerService,
+ InProgressStatusService inProgressStatusService,
+ WatchChildrenJobsBL watchChildrenJobsBL,
+ JobsBrokerService jobsBrokerService,
+ JobAdapter jobAdapter) {
+ return new NetworkCommand(asyncInstantiationBusinessLogic, restMso, msoRequestBuilder, msoResultHandlerService,
+ inProgressStatusService, watchChildrenJobsBL, jobsBrokerService, jobAdapter);
}
-
@Bean
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
- public VolumeGroupInProgressStatusCommand volumeGroupInProgressStatusCommand() {
- return new VolumeGroupInProgressStatusCommand();
+ public InstanceGroupCommand instanceGroupCommand(
+ AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic,
+ MsoRequestBuilder msoRequestBuilder,
+ MsoResultHandlerService msoResultHandlerService,
+ InProgressStatusService inProgressStatusService,
+ WatchChildrenJobsBL watchChildrenJobsBL,
+ RestMsoImplementation restMso,
+ JobsBrokerService jobsBrokerService,
+ JobAdapter jobAdapter) {
+ return new InstanceGroupCommand(asyncInstantiationBusinessLogic, restMso, msoRequestBuilder, msoResultHandlerService, inProgressStatusService, watchChildrenJobsBL, jobsBrokerService, jobAdapter);
}
@Bean
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
- public VfmoduleInstantiationCommand vfmoduleInstantiationCommand() {
- return new VfmoduleInstantiationCommand();
+ public InstanceGroupMemberCommand instanceGroupMemberCommand (
+ AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic,
+ MsoRequestBuilder msoRequestBuilder,
+ MsoResultHandlerService msoResultHandlerService,
+ InProgressStatusService inProgressStatusService,
+ WatchChildrenJobsBL watchChildrenJobsBL,
+ RestMsoImplementation restMso,
+ JobsBrokerService jobsBrokerService,
+ JobAdapter jobAdapter) {
+ return new InstanceGroupMemberCommand(asyncInstantiationBusinessLogic, restMso, msoRequestBuilder, msoResultHandlerService, inProgressStatusService,
+ watchChildrenJobsBL, jobsBrokerService, jobAdapter);
}
- @Bean
- @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
- public WatchingCommand watchingCommandCommand() {
- return new WatchingCommand();
- }
@Bean
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
- public ResourceInProgressStatusCommand resourceInProgressStatusCommand() {
- return new ResourceInProgressStatusCommand();
+ public VnfCommand VnfCommand(
+ AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic,
+ RestMsoImplementation restMso,
+ MsoRequestBuilder msoRequestBuilder,
+ MsoResultHandlerService msoResultHandlerService,
+ InProgressStatusService inProgressStatusService,
+ WatchChildrenJobsBL watchChildrenJobsBL,
+ JobsBrokerService jobsBrokerService,
+ JobAdapter jobAdapter,
+ FeatureManager featureManager) {
+ return new VnfCommand(asyncInstantiationBusinessLogic, restMso, msoRequestBuilder, msoResultHandlerService,
+ inProgressStatusService, watchChildrenJobsBL, jobsBrokerService ,jobAdapter,
+ featureManager);
}
@Bean
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
- public VnfInProgressStatusCommand vnfInProgressStatusCommand() {
- return new VnfInProgressStatusCommand();
+ public VolumeGroupCommand volumeGroupCommand(
+ AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic,
+ RestMsoImplementation restMso,
+ MsoRequestBuilder msoRequestBuilder,
+ MsoResultHandlerService msoResultHandlerService,
+ InProgressStatusService inProgressStatusService,
+ WatchChildrenJobsBL watchChildrenJobsBL,
+ JobsBrokerService jobsBrokerService,
+ JobAdapter jobAdapter) {
+ return new VolumeGroupCommand(asyncInstantiationBusinessLogic, restMso, msoRequestBuilder, msoResultHandlerService,
+ inProgressStatusService, watchChildrenJobsBL, jobsBrokerService ,jobAdapter);
}
@Bean
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
- public InstanceGroupInstantiationCommand instanceGroupInstantiationCommand() {
- return new InstanceGroupInstantiationCommand();
+ public VfmoduleCommand VfmoduleCommand(
+ AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic,
+ RestMsoImplementation restMso,
+ MsoRequestBuilder msoRequestBuilder,
+ MsoResultHandlerService msoResultHandlerService,
+ InProgressStatusService inProgressStatusService,
+ WatchChildrenJobsBL watchChildrenJobsBL,
+ JobsBrokerService jobsBrokerService,
+ JobAdapter jobAdapter) {
+ return new VfmoduleCommand(asyncInstantiationBusinessLogic, restMso, msoRequestBuilder, msoResultHandlerService,
+ inProgressStatusService, watchChildrenJobsBL, jobsBrokerService, jobAdapter);
}
-
@Bean
- public AuditService auditService(AsyncInstantiationBusinessLogic asyncInstantiationBL, RestMsoImplementation msoClient) {
- return new AuditServiceImpl(asyncInstantiationBL, msoClient);
+ public AuditService auditService(RestMsoImplementation msoClient, AsyncInstantiationRepository asyncInstantiationRepository) {
+ return new AuditServiceImpl(msoClient, asyncInstantiationRepository);
}
@Bean
- public InProgressStatusService inProgressStatusService(AsyncInstantiationBusinessLogic asyncInstantiationBL, RestMsoImplementation restMso, AuditService auditService) {
- return new InProgressStatusService(asyncInstantiationBL, restMso, auditService);
+ public InProgressStatusService inProgressStatusService(AsyncInstantiationBusinessLogic asyncInstantiationBL, RestMsoImplementation restMso, AuditService auditService, FeatureManager featureManager) {
+ return new InProgressStatusService(asyncInstantiationBL, restMso, auditService, featureManager);
}
@Bean
diff --git a/vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java b/vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java
index a60aa7ea6..2377c8055 100644
--- a/vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java
@@ -21,8 +21,14 @@
package org.onap.vid.controller;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyBoolean;
+import static org.mockito.ArgumentMatchers.argThat;
+import static org.mockito.ArgumentMatchers.booleanThat;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
@@ -34,13 +40,16 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
+import java.io.IOException;
import java.util.Map;
import java.util.UUID;
+import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.Response;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
import org.mockito.junit.MockitoJUnitRunner;
import org.onap.vid.aai.AaiResponse;
import org.onap.vid.aai.AaiResponseTranslator.PortMirroringConfigData;
@@ -53,14 +62,18 @@ import org.onap.vid.aai.model.PortDetailsTranslator.PortDetails;
import org.onap.vid.aai.model.PortDetailsTranslator.PortDetailsError;
import org.onap.vid.aai.model.PortDetailsTranslator.PortDetailsOk;
import org.onap.vid.aai.util.AAIRestInterface;
+import org.onap.vid.properties.Features;
+import org.onap.vid.roles.Role;
import org.onap.vid.model.VersionByInvariantIdsRequest;
import org.onap.vid.roles.RoleProvider;
+import org.onap.vid.roles.RoleValidator;
import org.onap.vid.services.AaiService;
import org.onap.vid.utils.SystemPropertiesWrapper;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
+import org.togglz.core.manager.FeatureManager;
@RunWith(MockitoJUnitRunner.class)
public class AaiControllerTest {
@@ -76,12 +89,16 @@ public class AaiControllerTest {
private RoleProvider roleProvider;
@Mock
private SystemPropertiesWrapper systemPropertiesWrapper;
+
+ @Mock
+ private FeatureManager featureManager;
+
private MockMvc mockMvc;
private AaiController aaiController;
@Before
public void setUp() {
- aaiController = new AaiController(aaiService, aaiRestInterface, roleProvider, systemPropertiesWrapper);
+ aaiController = new AaiController(aaiService, aaiRestInterface, roleProvider, systemPropertiesWrapper, featureManager);
mockMvc = MockMvcBuilders.standaloneSetup(aaiController).build();
}
@@ -248,5 +265,42 @@ public class AaiControllerTest {
.andExpect(status().isOk())
.andExpect(content().string(expectedResponse));
}
+
+ @Test
+ public void getSubscriberDetailsOmitServiceInstances_reduceDepthEnabledAndOmitQueryParam() throws IOException {
+ getSubscriberDetailsOmitServiceInstances("some subscriber id",
+ true, true, true);
+ }
+
+ @Test
+ public void getSubscriberDetailsOmitServiceInstances_reduceDepthDisabledAndOmitQueryParam() throws IOException {
+ getSubscriberDetailsOmitServiceInstances("another-subscriber-id-123",
+ false, true, false);
+ }
+
+ @Test
+ public void getSubscriberDetailsOmitServiceInstances_reduceDepthDisabled() throws IOException {
+ getSubscriberDetailsOmitServiceInstances("123-456-789-123-345-567-6",
+ false, false, false);
+ }
+
+ @Test
+ public void getSubscriberDetailsOmitServiceInstances_reduceDepthEnabled() throws IOException {
+ getSubscriberDetailsOmitServiceInstances("0000000000000000000000000",
+ true, false, false);
+ }
+
+ private void getSubscriberDetailsOmitServiceInstances(String subscriberId, boolean isFlag1906AaiSubDetailsReduceDepthEnabled,
+ boolean omitServiceInstancesQueryParam, boolean omitServiceInstancesExpectedGetSubscriberDataParam) throws IOException {
+ when(featureManager.isActive(Features.FLAG_1906_AAI_SUB_DETAILS_REDUCE_DEPTH)).thenReturn(isFlag1906AaiSubDetailsReduceDepthEnabled);
+ HttpServletRequest request = mock(HttpServletRequest.class);
+ when(roleProvider.getUserRoles(request)).thenReturn(ImmutableList.of(mock(Role.class), mock(Role.class)));
+ AaiResponse subscriberData = mock(AaiResponse.class);
+ when(subscriberData.getT()).thenReturn(null);
+ when(subscriberData.getHttpCode()).thenReturn(200);
+ when(aaiService.getSubscriberData(any(), any(), anyBoolean())).thenReturn(subscriberData);
+ aaiController.getSubscriberDetails(request, subscriberId, omitServiceInstancesQueryParam);
+ verify(aaiService).getSubscriberData(argThat(subscriberId::equals), any(RoleValidator.class), booleanThat(b -> omitServiceInstancesExpectedGetSubscriberDataParam == b));
+ }
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/controller/AaiServiceInstanceStandardQueryControllerTest.java b/vid-app-common/src/test/java/org/onap/vid/controller/AaiServiceInstanceStandardQueryControllerTest.java
index 2a8db9650..b036b4794 100644
--- a/vid-app-common/src/test/java/org/onap/vid/controller/AaiServiceInstanceStandardQueryControllerTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/controller/AaiServiceInstanceStandardQueryControllerTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,18 +20,20 @@
package org.onap.vid.controller;
-import org.mockito.Answers;
+import com.google.common.collect.ImmutableList;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.onap.vid.aai.util.ServiceInstanceStandardQuery;
import org.onap.vid.asdc.AsdcCatalogException;
import org.onap.vid.model.Service;
import org.onap.vid.model.ServiceModel;
import org.onap.vid.model.VidNotions;
import org.onap.vid.model.VidNotions.ModelCategory;
+import org.onap.vid.model.aaiTree.AAITreeNode;
import org.onap.vid.properties.Features;
+import org.onap.vid.services.AAIServiceTree;
import org.onap.vid.services.VidService;
+import org.springframework.http.HttpMethod;
import org.springframework.mock.web.MockHttpServletRequest;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
@@ -56,8 +58,9 @@ public class AaiServiceInstanceStandardQueryControllerTest {
@Mock
private VidService sdcService;
- @Mock(answer = Answers.RETURNS_MOCKS)
- private ServiceInstanceStandardQuery serviceInstanceStandardQuery;
+ @Mock
+ private AAIServiceTree aaiServiceTree;
+
//Don't use initMocks with @BeforeMethod
//because AaiServiceInstanceStandardQueryController contains final members that can not be injected twice
@@ -69,7 +72,7 @@ public class AaiServiceInstanceStandardQueryControllerTest {
@AfterMethod
public void resetMocks() {
- reset(sdcService, featureManager, serviceInstanceStandardQuery);
+ reset(sdcService, featureManager);
}
@Test
@@ -80,13 +83,14 @@ public class AaiServiceInstanceStandardQueryControllerTest {
// - assert that AAI was accessed
when(featureManager.isActive(Features.FLAG_PRESENT_PROVIDER_NETWORKS_ASSOCIATIONS)).thenReturn(true);
+ when(aaiServiceTree.buildAAITree(any(), any(), any(HttpMethod.class), any(), anyBoolean())).thenReturn(ImmutableList.of(mock(AAITreeNode.class)));
final UUID randomModelUuid = UUID.randomUUID();
mockServiceModel(ModelCategory.IS_5G_PROVIDER_NETWORK_MODEL, randomModelUuid);
doGetNetworksToVlansByServiceInstance(randomModelUuid);
- verify(serviceInstanceStandardQuery).fetchServiceInstance(any(), any(), any());
+ verify(aaiServiceTree).buildAAITree(any(), any(), any(HttpMethod.class), any(), anyBoolean());
}
@Test
@@ -103,7 +107,7 @@ public class AaiServiceInstanceStandardQueryControllerTest {
mockServiceModel(ModelCategory.OTHER, randomModelUuid);
assertThat(doGetNetworksToVlansByServiceInstance(randomModelUuid).serviceNetworks, hasSize(0));
- verifyZeroInteractions(serviceInstanceStandardQuery);
+ verifyZeroInteractions(aaiServiceTree);
}
@Test
@@ -123,7 +127,7 @@ public class AaiServiceInstanceStandardQueryControllerTest {
Service mockedService = mock(Service.class);
when(mockedModel.getService()).thenReturn(mockedService);
when(mockedService.getVidNotions()).thenReturn(
- new VidNotions(instantiationUI, modelCategory, VidNotions.InstantiationUI.LEGACY)
+ new VidNotions(instantiationUI, modelCategory, VidNotions.InstantiationUI.LEGACY, VidNotions.InstantiationType.ALaCarte)
);
when(sdcService.getService(randomModelUuid.toString())).thenReturn(mockedModel);
@@ -137,4 +141,4 @@ public class AaiServiceInstanceStandardQueryControllerTest {
"my service type",
"my instance id");
}
-}
+} \ No newline at end of file
diff --git a/vid-app-common/src/test/java/org/onap/vid/controller/LocalWebConfig.java b/vid-app-common/src/test/java/org/onap/vid/controller/LocalWebConfig.java
index 7e50c8959..701f1c62a 100644
--- a/vid-app-common/src/test/java/org/onap/vid/controller/LocalWebConfig.java
+++ b/vid-app-common/src/test/java/org/onap/vid/controller/LocalWebConfig.java
@@ -44,6 +44,7 @@ import org.togglz.core.manager.FeatureManager;
import javax.servlet.ServletContext;
import java.io.File;
+import java.util.concurrent.ExecutorService;
@Configuration
public class LocalWebConfig {
@@ -66,8 +67,8 @@ public class LocalWebConfig {
@Bean
public AaiService getAaiService(AaiClientInterface aaiClient, AaiOverTLSClientInterface aaiOverTLSClient,
- AaiResponseTranslator aaiResponseTranslator, AAITreeNodeBuilder aaiTreeNode, AAIServiceTree aaiServiceTree) {
- return new AaiServiceImpl(aaiClient, aaiOverTLSClient, aaiResponseTranslator, aaiTreeNode, aaiServiceTree);
+ AaiResponseTranslator aaiResponseTranslator, AAITreeNodeBuilder aaiTreeNode, AAIServiceTree aaiServiceTree, ExecutorService executorService) {
+ return new AaiServiceImpl(aaiClient, aaiOverTLSClient, aaiResponseTranslator, aaiTreeNode, aaiServiceTree, executorService);
}
@Bean
diff --git a/vid-app-common/src/test/java/org/onap/vid/controller/MsoControllerNewTest.java b/vid-app-common/src/test/java/org/onap/vid/controller/MsoControllerNewTest.java
index a5222dd04..43edeebe9 100644
--- a/vid-app-common/src/test/java/org/onap/vid/controller/MsoControllerNewTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/controller/MsoControllerNewTest.java
@@ -20,24 +20,24 @@
package org.onap.vid.controller;
+import static org.mockito.Mockito.mock;
+
+import javax.servlet.http.HttpServletRequest;
import org.junit.Test;
import org.onap.vid.mso.MsoBusinessLogicImpl;
import org.onap.vid.mso.MsoInterface;
+import org.onap.vid.mso.rest.MsoRestClientNew;
import org.onap.vid.mso.rest.RequestDetails;
import org.onap.vid.mso.rest.RequestDetailsWrapper;
import org.onap.vid.services.CloudOwnerServiceImpl;
import org.springframework.http.ResponseEntity;
-import org.togglz.core.manager.FeatureManager;
-
-import javax.servlet.http.HttpServletRequest;
-
-import static org.mockito.Mockito.mock;
public class MsoControllerNewTest {
private MsoController createTestSubject() {
try {
- return new MsoController(new MsoBusinessLogicImpl(mock(MsoInterface.class),mock(FeatureManager.class)), new CloudOwnerServiceImpl(null, null));
+ return new MsoController(new MsoBusinessLogicImpl(mock(MsoInterface.class)), mock(MsoRestClientNew.class),
+ new CloudOwnerServiceImpl(null, null));
} catch (Exception e) {
return null;
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/controller/MsoControllerTest.java b/vid-app-common/src/test/java/org/onap/vid/controller/MsoControllerTest.java
index 02ab287be..a1b45590c 100644
--- a/vid-app-common/src/test/java/org/onap/vid/controller/MsoControllerTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/controller/MsoControllerTest.java
@@ -46,6 +46,7 @@ import org.junit.Before;
import org.junit.Test;
import org.onap.vid.mso.MsoBusinessLogic;
import org.onap.vid.mso.MsoResponseWrapper;
+import org.onap.vid.mso.rest.MsoRestClientNew;
import org.onap.vid.mso.rest.Request;
import org.onap.vid.mso.rest.RequestDetails;
import org.onap.vid.mso.rest.Task;
@@ -66,12 +67,14 @@ public class MsoControllerTest {
private MockMvc mockMvc;
private MsoBusinessLogic msoBusinessLogic;
private CloudOwnerService cloudService;
+ private MsoRestClientNew msoRestClient;
@Before
public void setUp() {
msoBusinessLogic = mock(MsoBusinessLogic.class);
cloudService = mock(CloudOwnerService.class);
- MsoController msoController = new MsoController(msoBusinessLogic, cloudService);
+ msoRestClient = mock(MsoRestClientNew.class);
+ MsoController msoController = new MsoController(msoBusinessLogic, msoRestClient, cloudService);
mockMvc = MockMvcBuilders.standaloneSetup(msoController).build();
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/controller/ToscaParserMockHelper.java b/vid-app-common/src/test/java/org/onap/vid/controller/ToscaParserMockHelper.java
index 2eedee9d7..9e77e99e3 100644
--- a/vid-app-common/src/test/java/org/onap/vid/controller/ToscaParserMockHelper.java
+++ b/vid-app-common/src/test/java/org/onap/vid/controller/ToscaParserMockHelper.java
@@ -22,25 +22,21 @@ package org.onap.vid.controller;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.module.kotlin.KotlinModule;
-import org.apache.commons.io.IOUtils;
-import org.apache.log4j.LogManager;
-import org.apache.log4j.Logger;
-import org.onap.vid.model.NewServiceModel;
-
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
+import org.apache.commons.io.IOUtils;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.Logger;
+import org.onap.vid.model.ServiceModel;
-/**
- * Created by moriya1 on 04/07/2017.
- */
public class ToscaParserMockHelper {
private static final Logger logger = LogManager.getLogger(ToscaParserMockHelper.class);
private static final ObjectMapper om = new ObjectMapper();
private final String uuid;
private final String filePath;
- private final NewServiceModel newServiceModel;
+ private final ServiceModel serviceModel;
public ToscaParserMockHelper(String uuid, String filePath) throws IOException {
this.uuid = uuid;
@@ -50,7 +46,7 @@ public class ToscaParserMockHelper {
logger.info(jsonFile);
String expectedJsonAsString = IOUtils.toString(jsonFile, StandardCharsets.UTF_8.name());
om.registerModule(new KotlinModule());
- this.newServiceModel = om.readValue(expectedJsonAsString, NewServiceModel.class);
+ this.serviceModel = om.readValue(expectedJsonAsString, ServiceModel.class);
}
public String getUuid() {
@@ -61,7 +57,7 @@ public class ToscaParserMockHelper {
return filePath;
}
- public NewServiceModel getNewServiceModel() {
- return newServiceModel;
+ public ServiceModel getServiceModel() {
+ return serviceModel;
}
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/controller/VidControllerTest.java b/vid-app-common/src/test/java/org/onap/vid/controller/VidControllerTest.java
index 39d3cddc7..484f4a034 100644
--- a/vid-app-common/src/test/java/org/onap/vid/controller/VidControllerTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/controller/VidControllerTest.java
@@ -178,7 +178,7 @@ public class VidControllerTest {
private ServiceModel createServiceModel(int i) {
ServiceModel model = new ServiceModel();
- model.setCollectionResource(ImmutableMap.of("resKey" + i, new CR()));
+ model.setCollectionResources(ImmutableMap.of("resKey" + i, new CR()));
model.setNetworks(ImmutableMap.of("network" + i, new Network()));
model.setPnfs(ImmutableMap.of("pnf" + i, new Node()));
model.setServiceProxies(ImmutableMap.of("servProxy" + i, new ServiceProxy()));
diff --git a/vid-app-common/src/test/java/org/onap/vid/dal/AsyncInstantiationRepositoryTest.java b/vid-app-common/src/test/java/org/onap/vid/dal/AsyncInstantiationRepositoryTest.java
new file mode 100644
index 000000000..be5a44e82
--- /dev/null
+++ b/vid-app-common/src/test/java/org/onap/vid/dal/AsyncInstantiationRepositoryTest.java
@@ -0,0 +1,103 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.vid.dal;
+
+import static net.javacrumbs.jsonunit.JsonMatchers.jsonEquals;
+import static net.javacrumbs.jsonunit.core.Option.IGNORING_ARRAY_ORDER;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
+import static org.hamcrest.core.IsEqual.equalTo;
+
+import com.google.common.collect.ImmutableList;
+import java.time.ZonedDateTime;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.stream.Collectors;
+import javax.inject.Inject;
+import org.onap.portalsdk.core.service.DataAccessService;
+import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.vid.config.DataSourceConfig;
+import org.onap.vid.config.MockedAaiClientAndFeatureManagerConfig;
+import org.onap.vid.job.Job;
+import org.onap.vid.model.ResourceInfo;
+import org.onap.vid.model.serviceInstantiation.ServiceInstantiation;
+import org.onap.vid.mso.rest.AsyncRequestStatus;
+import org.onap.vid.mso.rest.RequestStatus;
+import org.onap.vid.services.AsyncInstantiationBaseTest;
+import org.onap.vid.utils.TimeUtils;
+import org.springframework.test.context.ContextConfiguration;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+@ContextConfiguration(classes = {DataSourceConfig.class, SystemProperties.class, MockedAaiClientAndFeatureManagerConfig.class})
+public class AsyncInstantiationRepositoryTest extends AsyncInstantiationBaseTest {
+
+ @Inject
+ private DataAccessService dataAccessService;
+
+ @BeforeClass
+ void initServicesInfoService() {
+ createInstanceParamsMaps();
+ }
+
+ @Test
+ public void whenSaveNewRequest_thenRequestIsRetrieved() {
+ AsyncInstantiationRepository underTest = new AsyncInstantiationRepository(dataAccessService);
+ ServiceInstantiation serviceInstantiation = generateALaCarteWithVnfsServiceInstantiationPayload();
+ UUID jobUuid = UUID.randomUUID();
+ underTest.addJobRequest(jobUuid, serviceInstantiation);
+ ServiceInstantiation stored = underTest.getJobRequest(jobUuid);
+ assertThat(stored, jsonEquals(serviceInstantiation).when(IGNORING_ARRAY_ORDER));
+ }
+
+ private AsyncRequestStatus createAsyncRequestStatus(String message, String requestState){
+ RequestStatus requestStatus = new RequestStatus(requestState, message, TimeUtils.zonedDateTimeToString(ZonedDateTime.now()));
+ AsyncRequestStatus.Request request = new AsyncRequestStatus.Request(requestStatus);
+ return new AsyncRequestStatus(request);
+ }
+
+ @Test
+ public void getResourceInfoByRootJobId_returnsMapOfjobIdResources(){
+ AsyncInstantiationRepository underTest = new AsyncInstantiationRepository(dataAccessService);
+ UUID jobId1= UUID.randomUUID();
+ UUID jobId2= UUID.randomUUID();
+ AsyncRequestStatus errorMessage= createAsyncRequestStatus("MSO failed resource", "FAILED");
+ List<ResourceInfo> requestInfoList= ImmutableList.of(
+ new ResourceInfo("aaaaaa",jobId1, "64f3123a-f9a8-4591-b481-d662134bcb52", Job.JobStatus.COMPLETED, null),
+ new ResourceInfo("bbbbbb",jobId1, "65f3123a-f9a8-4591-b481-kodj9ig87gdu", Job.JobStatus.COMPLETED_WITH_ERRORS, null),
+ new ResourceInfo("dddddd",jobId1, null, Job.JobStatus.FAILED, null),
+ new ResourceInfo("cccccc",jobId1, null, Job.JobStatus.FAILED, errorMessage),
+ new ResourceInfo("eeeeee",jobId2, null, Job.JobStatus.FAILED, null),
+ new ResourceInfo("ffffff",jobId2, "66f3123a-f9a8-4591-b481-ghfgh6767567", Job.JobStatus.COMPLETED, null)
+ );
+ for(ResourceInfo info: requestInfoList){
+ underTest.saveResourceInfo(info);
+ }
+ Map<String, ResourceInfo> storedByTrackId = underTest.getResourceInfoByRootJobId(jobId1);
+ assertThat(storedByTrackId.values(), hasSize(4));
+ assertThat(storedByTrackId.get("aaaaaa").getInstanceId(), equalTo("64f3123a-f9a8-4591-b481-d662134bcb52"));
+ assertThat(storedByTrackId.get("cccccc").getErrorMessage().request.requestStatus.getStatusMessage(), equalTo("MSO failed resource"));
+ assertThat(storedByTrackId.get("cccccc").getErrorMessage().request.requestStatus.getRequestState(), equalTo("FAILED"));
+ assertThat(storedByTrackId.get("dddddd").getErrorMessage(), equalTo(null));
+ assertThat(storedByTrackId.values(), jsonEquals(requestInfoList.stream().filter(i-> i.getRootJobId().equals(jobId1)).collect(Collectors.toList())).when(IGNORING_ARRAY_ORDER));
+ }
+}
diff --git a/vid-app-common/src/test/java/org/onap/vid/job/command/CommandUtilsTest.java b/vid-app-common/src/test/java/org/onap/vid/job/command/CommandUtilsTest.java
index da300bf3e..ee43d1f72 100644
--- a/vid-app-common/src/test/java/org/onap/vid/job/command/CommandUtilsTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/job/command/CommandUtilsTest.java
@@ -7,9 +7,9 @@
* 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.
diff --git a/vid-app-common/src/test/java/org/onap/vid/job/command/InProgressStatusServiceTest.java b/vid-app-common/src/test/java/org/onap/vid/job/command/InProgressStatusServiceTest.java
index c8772ee76..125d2ed4c 100644
--- a/vid-app-common/src/test/java/org/onap/vid/job/command/InProgressStatusServiceTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/job/command/InProgressStatusServiceTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,8 +20,10 @@
package org.onap.vid.job.command;
+import org.jetbrains.annotations.NotNull;
import org.mockito.InjectMocks;
import org.mockito.Mock;
+import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.onap.vid.job.Job;
import org.onap.vid.job.impl.JobSharedData;
@@ -29,11 +31,16 @@ import org.onap.vid.model.serviceInstantiation.ServiceInstantiation;
import org.onap.vid.mso.RestMsoImplementation;
import org.onap.vid.mso.RestObject;
import org.onap.vid.mso.rest.AsyncRequestStatus;
-import org.onap.vid.services.AsyncInstantiationBaseTest;
+import org.onap.vid.properties.Features;
import org.onap.vid.services.AsyncInstantiationBusinessLogic;
+import org.onap.vid.services.AuditService;
+import org.onap.vid.services.AsyncInstantiationBaseTest;
+import org.onap.vid.testUtils.TestUtils;
import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
+import org.togglz.core.manager.FeatureManager;
import java.util.UUID;
import java.util.stream.Stream;
@@ -51,6 +58,12 @@ public class InProgressStatusServiceTest {
@Mock
private AsyncInstantiationBusinessLogic asyncInstantiationBL;
+ @Mock
+ private AuditService auditService;
+
+ @Mock
+ private FeatureManager featureManager;
+
@InjectMocks
private InProgressStatusService inProgressStatusService;
@@ -59,10 +72,16 @@ public class InProgressStatusServiceTest {
MockitoAnnotations.initMocks(this);
}
+ @BeforeMethod
+ public void resetMocks() {
+ Mockito.reset(restMso);
+ Mockito.reset(asyncInstantiationBL);
+ }
+
@DataProvider
public static Object[][] jobStatuses() {
return Stream.of(Job.JobStatus.values())
- .map(student -> new Object[] { student })
+ .map(status -> new Object[] { status })
.toArray(Object[][]::new);
}
@@ -71,16 +90,14 @@ public class InProgressStatusServiceTest {
UUID jobUuid = UUID.randomUUID();
String userId = "mockedUserID";
+ String testApi = "mockedTestApi";
String requestId = UUID.randomUUID().toString();
ServiceInstantiation serviceInstantiation = mock(ServiceInstantiation.class);
when(asyncInstantiationBL.getOrchestrationRequestsPath()).thenReturn("");
- RestObject<AsyncRequestStatus> msoResponse = mock(RestObject.class);
AsyncRequestStatus requestStatus = AsyncInstantiationBaseTest.asyncRequestStatusResponse("");
-
- when(msoResponse.getStatusCode()).thenReturn(200);
- when(msoResponse.get()).thenReturn(requestStatus);
+ RestObject<AsyncRequestStatus> msoResponse = createMockedAsyncRequestStatus(requestStatus, 200);
when(restMso.GetForObject(contains(requestId), eq(AsyncRequestStatus.class))).thenReturn(msoResponse);
when(asyncInstantiationBL.calcStatus(any())).thenReturn(expectedJobStatus);
@@ -88,16 +105,60 @@ public class InProgressStatusServiceTest {
ExpiryChecker expiryChecker = mock(ExpiryChecker.class);
when(expiryChecker.isExpired(any())).thenReturn(false);
- JobSharedData sharedData = new JobSharedData(jobUuid, userId, serviceInstantiation);
+ JobSharedData sharedData = new JobSharedData(jobUuid, userId, serviceInstantiation, testApi);
Job.JobStatus actualJobStatus = inProgressStatusService.call(expiryChecker, sharedData, requestId);
assertEquals(expectedJobStatus, actualJobStatus);
- verify(asyncInstantiationBL).auditMsoStatus(eq(jobUuid), same(requestStatus.request));
-
+ verify(auditService).auditMsoStatus(eq(jobUuid), same(requestStatus.request));
+ verify(asyncInstantiationBL).updateResourceInfo(eq(sharedData), eq(expectedJobStatus), eq(requestStatus));
//verify we don't update service info during this case, which shall stay in_progress
verify(asyncInstantiationBL, never()).updateServiceInfo(any(), any());
+ }
+
+ @NotNull
+ protected RestObject<AsyncRequestStatus> createMockedAsyncRequestStatus(AsyncRequestStatus requestStatus, int statusCode) {
+ RestObject<AsyncRequestStatus> msoResponse = mock(RestObject.class);
+ when(msoResponse.getStatusCode()).thenReturn(statusCode);
+ when(msoResponse.get()).thenReturn(requestStatus);
+ return msoResponse;
+ }
+
+ @Test(dataProvider = "trueAndFalse", dataProviderClass = TestUtils.class)
+ public void whenGetAsyncRequestStatus_thenRightResponseReturned(boolean isResumeFlagActive) {
+ String requestId = "abcRequest";
+ String baseMso = "/fakeBase/v15";
+
+ when(asyncInstantiationBL.getOrchestrationRequestsPath()).thenReturn(baseMso);
+ when(featureManager.isActive(Features.FLAG_1908_RESUME_MACRO_SERVICE)).thenReturn(isResumeFlagActive);
+
+ AsyncRequestStatus requestStatus = AsyncInstantiationBaseTest.asyncRequestStatusResponse("");
+ RestObject<AsyncRequestStatus> mockedResponse = createMockedAsyncRequestStatus(requestStatus, 399);
+ String path = baseMso + "/" + requestId + (isResumeFlagActive ? "?format=detail" : "");
+ when(restMso.GetForObject(eq(path), eq(AsyncRequestStatus.class))).thenReturn(mockedResponse);
+
+ assertEquals(mockedResponse, inProgressStatusService.getAsyncRequestStatus(requestId));
+ }
+
+ @DataProvider
+ public static Object[][] getAsyncReturnErrorDataProvider() {
+ return new Object[][]{
+ {AsyncInstantiationBaseTest.asyncRequestStatusResponse("xyz"), 400},
+ {AsyncInstantiationBaseTest.asyncRequestStatusResponse("xyz"), 401},
+ {AsyncInstantiationBaseTest.asyncRequestStatusResponse("xyz"), 500},
+ {null, 200},
+ };
+ }
+
+ @Test(dataProvider = "getAsyncReturnErrorDataProvider", expectedExceptions = InProgressStatusService.BadResponseFromMso.class)
+ public void whenGetAsyncReturnError_thenExceptionIsThrown(AsyncRequestStatus requestStatus, int statusCode) {
+ String requestId = "abcRequest";
+ String baseMso = "/fakeBase/v15";
+ when(asyncInstantiationBL.getOrchestrationRequestsPath()).thenReturn(baseMso);
+ RestObject<AsyncRequestStatus> mockedResponse = createMockedAsyncRequestStatus(requestStatus, statusCode);
+ when(restMso.GetForObject(eq(baseMso + "/" + requestId), eq(AsyncRequestStatus.class))).thenReturn(mockedResponse);
+ inProgressStatusService.getAsyncRequestStatus(requestId);
}
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/job/command/InstanceGroupCommandTest.java b/vid-app-common/src/test/java/org/onap/vid/job/command/InstanceGroupCommandTest.java
index b4a5c64f5..c68c5f754 100644
--- a/vid-app-common/src/test/java/org/onap/vid/job/command/InstanceGroupCommandTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/job/command/InstanceGroupCommandTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,29 +20,35 @@
package org.onap.vid.job.command;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.eq;
-import static org.mockito.Mockito.only;
-import static org.mockito.Mockito.same;
-import static org.mockito.Mockito.verify;
-
import com.google.common.collect.ImmutableMap;
-import java.util.Optional;
+import org.apache.commons.beanutils.BeanUtils;
import org.mockito.Answers;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import org.onap.vid.job.JobAdapter;
+import org.onap.vid.job.JobsBrokerService;
import org.onap.vid.job.impl.JobSharedData;
+import org.onap.vid.model.Action;
import org.onap.vid.model.RequestReferencesContainer;
import org.onap.vid.model.serviceInstantiation.InstanceGroup;
import org.onap.vid.mso.RestMsoImplementation;
import org.onap.vid.mso.model.ModelInfo;
import org.onap.vid.services.AsyncInstantiationBusinessLogic;
-import org.onap.vid.testUtils.TestUtils;
import org.springframework.http.HttpMethod;
import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
+import java.util.Optional;
+import java.util.Set;
+
+import static java.util.function.Function.identity;
+import static java.util.stream.Collectors.toMap;
+import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.*;
+
public class InstanceGroupCommandTest {
@Mock(answer = Answers.RETURNS_MOCKS)
@@ -53,11 +59,20 @@ public class InstanceGroupCommandTest {
@Mock(answer = Answers.RETURNS_MOCKS)
MsoResultHandlerService msoResultHandlerService;
+ @Mock(answer = Answers.RETURNS_MOCKS)
+ MsoRequestBuilder msoRequestBuilder;
+
@Mock WatchChildrenJobsBL watchChildrenJobsBL;
@Mock(answer = Answers.RETURNS_MOCKS)
AsyncInstantiationBusinessLogic asyncInstantiationBL;
+ @Mock(answer = Answers.RETURNS_MOCKS)
+ JobsBrokerService jobsBrokerService;
+
+ @Mock(answer = Answers.RETURNS_MOCKS)
+ JobAdapter jobAdapter;
+
@Mock InProgressStatusService inProgressStatusService;
@InjectMocks
@@ -68,29 +83,41 @@ public class InstanceGroupCommandTest {
command = null;
MockitoAnnotations.initMocks(this);
}
-
- @Test
- public void createMyself_callsMso() {
- final ModelInfo serviceModelInfo = setStrings(new ModelInfo());
+ @DataProvider
+ public static Object[][] testApis() {
+ return new Object[][]{
+ {"VNF_API"}, {null}};
+ }
+ @Test(dataProvider = "testApis")
+ public void createMyself_callsMso(String testApi) {
+ final ModelInfo serviceModelInfo = setRandomStrings(new ModelInfo());
final String serviceInstanceId = "service-instance-id";
final String userId = "ff3223";
- command.init(new JobSharedData(
- null, userId, instanceGroupRequest
- ), ImmutableMap.of(
+ when(instanceGroupRequest.getAction()).thenReturn(Action.Delete);
+
+ JobSharedData sharedData = new JobSharedData(
+ null, userId, instanceGroupRequest, testApi);
+ command.init(sharedData, ImmutableMap.of(
"resourceModelInfos", ImmutableMap.of("SERVICE_MODEL_INFO", serviceModelInfo),
"resourceInstancesIds", ImmutableMap.of("SERVICE_INSTANCE_ID", serviceInstanceId)
));
command.createMyself();
- verify(asyncInstantiationBL).generateInstanceGroupInstantiationRequest(
- same(instanceGroupRequest), eq(serviceModelInfo), eq(serviceInstanceId), eq(userId));
+ verify(msoRequestBuilder).generateInstanceGroupInstantiationRequest(
+ same(instanceGroupRequest), eq(serviceModelInfo), eq(serviceInstanceId), eq(userId), eq(testApi));
verify(restMso, only()).restCall(eq(HttpMethod.POST), eq(RequestReferencesContainer.class), any(), any(), eq(Optional.empty()));
-
}
- private ModelInfo setStrings(ModelInfo object) {
- return TestUtils.setStringsInStringProperties(object);
+ private ModelInfo setRandomStrings(ModelInfo object) {
+ try {
+ Set<String> fields = BeanUtils.describe(object).keySet();
+ BeanUtils.populate(object,
+ fields.stream().collect(toMap(identity(), s -> randomAlphanumeric(4))));
+ return object;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
}
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/job/command/JobCommandFactoryTest.java b/vid-app-common/src/test/java/org/onap/vid/job/command/JobCommandFactoryTest.java
index d7389ad0a..72336e5a9 100644
--- a/vid-app-common/src/test/java/org/onap/vid/job/command/JobCommandFactoryTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/job/command/JobCommandFactoryTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -105,7 +105,7 @@ public class JobCommandFactoryTest {
final UUID uuid = UUID.randomUUID();
final Map<String, Object> data = ImmutableMap.of("foo", "bar");
- final JobSharedData sharedData = new JobSharedData(uuid, "userid", new MockedRequest(1,"a"));
+ final JobSharedData sharedData = new JobSharedData(uuid, "userid", new MockedRequest(1,"a"), "testApi");
when(job.getType()).thenReturn(jobType);
when(job.getUuid()).thenReturn(uuid);
@@ -119,4 +119,4 @@ public class JobCommandFactoryTest {
assertThat(command, equalTo(mockCommand));
}
-}
+} \ No newline at end of file
diff --git a/vid-app-common/src/test/java/org/onap/vid/job/command/MacroServiceCommandTest.java b/vid-app-common/src/test/java/org/onap/vid/job/command/MacroServiceCommandTest.java
new file mode 100644
index 000000000..e4771611c
--- /dev/null
+++ b/vid-app-common/src/test/java/org/onap/vid/job/command/MacroServiceCommandTest.java
@@ -0,0 +1,136 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.vid.job.command;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.onap.vid.model.VidNotions.ModelCategory.INFRASTRUCTURE_VPN;
+import static org.onap.vid.model.VidNotions.ModelCategory.IS_5G_FABRIC_CONFIGURATION_MODEL;
+import static org.onap.vid.model.VidNotions.ModelCategory.IS_5G_PROVIDER_NETWORK_MODEL;
+import static org.onap.vid.model.VidNotions.ModelCategory.OTHER;
+import static org.onap.vid.model.VidNotions.ModelCategory.SERVICE_WITH_COLLECTION_RESOURCE;
+import static org.onap.vid.model.VidNotions.ModelCategory.Transport;
+import static org.testng.AssertJUnit.assertEquals;
+
+import com.google.common.collect.ImmutableList;
+import java.util.Collections;
+import java.util.List;
+import java.util.UUID;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.onap.vid.job.Job;
+import org.onap.vid.job.JobAdapter;
+import org.onap.vid.job.JobsBrokerService;
+import org.onap.vid.job.impl.JobSharedData;
+import org.onap.vid.model.Action;
+import org.onap.vid.model.VidNotions;
+import org.onap.vid.model.serviceInstantiation.BaseResource;
+import org.onap.vid.model.serviceInstantiation.ServiceInstantiation;
+import org.onap.vid.mso.RestMsoImplementation;
+import org.onap.vid.mso.rest.AsyncRequestStatus;
+import org.onap.vid.services.AsyncInstantiationBusinessLogic;
+import org.onap.vid.services.AuditService;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+public class MacroServiceCommandTest {
+
+ @Mock
+ private InProgressStatusService inProgressStatusService;
+
+ @Mock
+ private WatchChildrenJobsBL watchChildrenJobsB;
+
+ @Mock
+ private AsyncInstantiationBusinessLogic asyncInstantiationBL;
+
+ @Mock
+ private JobsBrokerService jobsBrokerService;
+
+ @Mock
+ private MsoRequestBuilder msoRequestBuilder;
+
+ @Mock
+ private MsoResultHandlerService msoResultHandlerService;
+
+ @Mock
+ private JobAdapter jobAdapter;
+
+ @Mock
+ private RestMsoImplementation restMso;
+
+ @Mock
+ private AuditService auditService;
+
+ @InjectMocks
+ private MacroServiceCommand macroServiceCommand;
+
+ @DataProvider
+ public static Object[][] modelCategoryPre1806DataProvider() {
+ return new Object[][]{
+ {IS_5G_PROVIDER_NETWORK_MODEL, false},
+ {IS_5G_FABRIC_CONFIGURATION_MODEL, false},
+ {Transport, true},
+ {SERVICE_WITH_COLLECTION_RESOURCE, true},
+ {INFRASTRUCTURE_VPN, true},
+ {OTHER, false},
+ };
+ }
+
+ @BeforeClass
+ public void initMocks() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test(dataProvider = "modelCategoryPre1806DataProvider")
+ public void testShouldUsePre1806Request(VidNotions.ModelCategory modelCategory, boolean expectedResult) {
+ ServiceInstantiation serviceInstantiation = mock(ServiceInstantiation.class);
+ VidNotions vidNotions = mock(VidNotions.class);
+ when(serviceInstantiation.getVidNotions()).thenReturn(vidNotions);
+ when(vidNotions.getModelCategory()).thenReturn(modelCategory);
+ assertEquals(macroServiceCommand.shouldUsePre1806Request(serviceInstantiation), expectedResult);
+ }
+
+ @DataProvider
+ public static Object[][] MsoFilteredRequestsDataProvider() {
+ return new Object[][]{
+ {Collections.EMPTY_LIST},
+ {ImmutableList.of(new AsyncRequestStatus.Request())}
+ };
+ }
+
+ @Test(dataProvider = "MsoFilteredRequestsDataProvider")
+ public void givenResumeAction_whenCantRetrieveRequestIdFromMSO_thenJobIsFailed(List<AsyncRequestStatus.Request> requests) {
+ String instanceId = UUID.randomUUID().toString();
+ BaseResource baseResource = mock(BaseResource.class);
+ when(baseResource.getInstanceId()).thenReturn(instanceId);
+ when(baseResource.getAction()).thenReturn(Action.Resume);
+ macroServiceCommand.init(new JobSharedData(null, null, baseResource, null));
+ when(auditService.retrieveRequestsFromMsoByServiceIdAndRequestTypeAndScope(eq(instanceId), any(), any()))
+ .thenReturn(requests);
+ assertEquals(macroServiceCommand.resumeMyself(), Job.JobStatus.FAILED);
+ }
+
+}
diff --git a/vid-app-common/src/test/java/org/onap/vid/job/command/MsoResultHandlerServiceTest.java b/vid-app-common/src/test/java/org/onap/vid/job/command/MsoResultHandlerServiceTest.java
new file mode 100644
index 000000000..5f958016b
--- /dev/null
+++ b/vid-app-common/src/test/java/org/onap/vid/job/command/MsoResultHandlerServiceTest.java
@@ -0,0 +1,95 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.vid.job.command;
+
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.verify;
+import static org.onap.vid.job.impl.AsyncInstantiationIntegrationTest.createResponse;
+import static org.testng.AssertJUnit.assertEquals;
+
+import java.util.UUID;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.onap.vid.job.Job;
+import org.onap.vid.job.impl.JobSharedData;
+import org.onap.vid.model.RequestReferencesContainer;
+import org.onap.vid.mso.RestObject;
+import org.onap.vid.services.AsyncInstantiationBusinessLogic;
+import org.onap.vid.services.AuditService;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+public class MsoResultHandlerServiceTest {
+
+ @Mock
+ private AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic;
+
+ @Mock
+ private AuditService auditService;
+
+ @InjectMocks
+ private MsoResultHandlerService underTest;
+
+ @BeforeClass
+ public void initMocks() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @DataProvider
+ public static Object[][] okStatusCodes() {
+ return new Object[][]{
+ {200}, {202} , {300}, {399}
+ };
+ }
+
+ @Test(dataProvider = "okStatusCodes")
+ public void whenOkResponseFromMso_getResultsWithIdsAndCompleteWithNoAction(int statusCode) {
+ String instanceId = UUID.randomUUID().toString();
+ String requestId = UUID.randomUUID().toString();
+ JobSharedData sharedData = new JobSharedData();
+ RestObject<RequestReferencesContainer> msoResponse = createResponse(statusCode, instanceId, requestId);
+ MsoResult expectedResult = new MsoResult(Job.JobStatus.COMPLETED_WITH_NO_ACTION, new MsoResourceIds(requestId, instanceId));
+ MsoResult actualMsoResult = underTest.handleResponse(sharedData, msoResponse, "test desc");
+ assertEquals(expectedResult, actualMsoResult);
+ verify(asyncInstantiationBusinessLogic).addResourceInfo(eq(sharedData), eq(Job.JobStatus.IN_PROGRESS), eq(instanceId));
+ }
+
+ @DataProvider
+ public static Object[][] notOkStatusCodes() {
+ return new Object[][]{
+ {199}, {400} , {404}, {500}
+ };
+ }
+
+ @Test(dataProvider = "notOkStatusCodes")
+ public void whenNotOkFromMso_getResultsWithFailedStatus(int statusCode) {
+ Mockito.reset(asyncInstantiationBusinessLogic);
+ JobSharedData sharedData = new JobSharedData();
+ RestObject<RequestReferencesContainer> msoResponse = createResponse(statusCode);
+ MsoResult expectedResult = new MsoResult(Job.JobStatus.FAILED);
+ MsoResult actualMsoResult = underTest.handleResponse(new JobSharedData(), msoResponse, "test desc");
+ assertEquals(expectedResult, actualMsoResult);
+ verify(asyncInstantiationBusinessLogic).addFailedResourceInfo(eq(sharedData), eq(msoResponse));
+ }
+}
diff --git a/vid-app-common/src/test/java/org/onap/vid/job/command/ResourceCommandTest.java b/vid-app-common/src/test/java/org/onap/vid/job/command/ResourceCommandTest.java
index 9f252c5e8..2780e1515 100644
--- a/vid-app-common/src/test/java/org/onap/vid/job/command/ResourceCommandTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/job/command/ResourceCommandTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,29 +20,38 @@
package org.onap.vid.job.command;
+import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.jetbrains.annotations.NotNull;
+import org.onap.vid.exceptions.AbortingException;
import org.onap.vid.exceptions.GenericUncheckedException;
+import org.onap.vid.exceptions.TryAgainException;
import org.onap.vid.job.Job;
import org.onap.vid.job.JobAdapter;
+import org.onap.vid.job.JobsBrokerService;
import org.onap.vid.job.NextCommand;
import org.onap.vid.job.impl.JobSharedData;
import org.onap.vid.model.Action;
-import org.onap.vid.model.serviceInstantiation.BaseResource;
+import org.onap.vid.model.serviceInstantiation.*;
import org.onap.vid.mso.RestMsoImplementation;
+import org.onap.vid.mso.model.ModelInfo;
import org.springframework.http.HttpMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import javax.ws.rs.ProcessingException;
-import java.util.Collections;
-import java.util.Optional;
+import java.util.*;
+import java.util.stream.Collectors;
import java.util.stream.Stream;
+import static java.util.Collections.emptyList;
+import static org.mockito.AdditionalAnswers.returnsFirstArg;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.*;
import static org.onap.vid.job.command.ResourceCommandKt.ACTION_PHASE;
import static org.onap.vid.job.command.ResourceCommandKt.INTERNAL_STATE;
+import static org.onap.vid.job.command.ResourceCommandTest.FakeResourceCreator.*;
+import static org.onap.vid.model.Action.*;
import static org.onap.vid.utils.Logging.getMethodCallerName;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
@@ -54,18 +63,32 @@ public class ResourceCommandTest {
public static class MockCommand extends ResourceCommand {
public MockCommand(InternalState mockState, Action mockPhase, Job.JobStatus mockedJobStatus) {
- super(mock(RestMsoImplementation.class, RETURNS_MOCKS), mock(InProgressStatusService.class), mock(MsoResultHandlerService.class, RETURNS_MOCKS), mock(WatchChildrenJobsBL.class));
+ this(mockState, mockPhase, mockedJobStatus, false);
+ }
+ public MockCommand(InternalState mockState, Action mockPhase, Job.JobStatus mockedJobStatus, boolean lateInit) {
+ super(
+ mock(RestMsoImplementation.class, RETURNS_MOCKS),
+ mock(InProgressStatusService.class),
+ mock(MsoResultHandlerService.class, RETURNS_MOCKS),
+ mock(WatchChildrenJobsBL.class),
+ mock(JobsBrokerService.class, RETURNS_MOCKS),
+ mock(JobAdapter.class, RETURNS_MOCKS));
this.mockedJobStatus = mockedJobStatus;
this.mockState = mockState;
this.mockPhase = mockPhase;
- if (mockState==InternalState.INITIAL) {
- init(mock(JobSharedData.class), Collections.emptyMap());
+ if (!lateInit) {
+ init();
}
- else {
+ when(this.getWatchChildrenJobsBL().cumulateJobStatus(any(), any())).thenReturn(mockedJobStatus);
+ }
+
+ protected void init() {
+ if (mockState == InternalState.INITIAL) {
+ init(mock(JobSharedData.class), Collections.emptyMap());
+ } else {
init(mock(JobSharedData.class), ImmutableMap.of(INTERNAL_STATE, mockState.name(), ACTION_PHASE, mockPhase.name()));
}
- when(this.getWatchChildrenJobsBL().cumulateJobStatus(any(), any())).thenReturn(mockedJobStatus);
}
private final Job.JobStatus mockedJobStatus;
@@ -76,7 +99,7 @@ public class ResourceCommandTest {
@NotNull
@Override
public Job.JobStatus createChildren() {
- if (mockState == InternalState.CREATING_CHILDREN || (mockState == InternalState.INITIAL && mockPhase== Action.Delete))
+ if (mockState == InternalState.CREATING_CHILDREN || (mockState == InternalState.INITIAL && mockPhase== Delete))
return mockedJobStatus;
throw (new RuntimeException("Not expected to call "+getMethodCallerName()));
}
@@ -95,7 +118,7 @@ public class ResourceCommandTest {
@NotNull
@Override
- public MsoRestCallPlan planCreateMyselfRestCall(@NotNull CommandParentData commandParentData, @NotNull JobAdapter.AsyncJobRequest request, @NotNull String userId) {
+ public MsoRestCallPlan planCreateMyselfRestCall(@NotNull CommandParentData commandParentData, @NotNull JobAdapter.AsyncJobRequest request, @NotNull String userId, String testApi) {
return mockedPlanOrThrow(InternalState.CREATE_MYSELF);
}
@@ -109,16 +132,19 @@ public class ResourceCommandTest {
public static class MockCommandTestingStateMachine extends MockCommand {
private final JobSharedData sharedData;
+ private final boolean isDescendantHasAction;
public MockCommandTestingStateMachine(InternalState mockState, Action mockPhase, Job.JobStatus mockedJobStatus, boolean mockedNeedToDeleteMySelf) {
- this(mockState, mockPhase, mockedJobStatus, mockedNeedToDeleteMySelf, false);
+ this(mockState, mockPhase, mockedJobStatus, mockedNeedToDeleteMySelf, false, true);
}
- public MockCommandTestingStateMachine(InternalState mockState, Action mockPhase, Job.JobStatus mockedJobStatus, boolean mockedNeedToDeleteMySelf, boolean isService) {
- super(mockState, mockPhase, mockedJobStatus);
+ public MockCommandTestingStateMachine(InternalState mockState, Action mockPhase, Job.JobStatus mockedJobStatus, boolean mockedNeedToDeleteMySelf, boolean isService, boolean isDescendantHasAction) {
+ super(mockState, mockPhase, mockedJobStatus, true);
this.mockedNeedToDeleteMySelf = mockedNeedToDeleteMySelf;
this.isService = isService;
this.sharedData = mock(JobSharedData.class, RETURNS_MOCKS);
+ this.isDescendantHasAction = isDescendantHasAction;
+ init();
}
protected final boolean mockedNeedToDeleteMySelf;
@@ -150,6 +176,11 @@ public class ResourceCommandTest {
public JobSharedData getSharedData() {
return sharedData;
}
+
+ @Override
+ protected boolean isDescendantHasAction(@NotNull Action phase) {
+ return isDescendantHasAction;
+ }
}
@DataProvider
@@ -171,28 +202,28 @@ public class ResourceCommandTest {
InternalState internalState, Job.JobStatus jobStatus, InternalState expectedState) {
//there is no meaning to the constructor inputs here
- MockCommandTestingStateMachine underTest = new MockCommandTestingStateMachine(InternalState.TERMINAL, Action.Delete, Job.JobStatus.FAILED, true);
+ MockCommandTestingStateMachine underTest = new MockCommandTestingStateMachine(InternalState.TERMINAL, Delete, Job.JobStatus.FAILED, true);
assertEquals(expectedState, underTest.calcNextStateDeletePhase(jobStatus, internalState));
}
@Test
public void whenNoNeedToDeleteMyself_internalStateMovesFromWatchingToTerminal() {
- MockCommandTestingStateMachine underTest = new MockCommandTestingStateMachine(InternalState.WATCHING, Action.Delete, Job.JobStatus.COMPLETED, false);
+ MockCommandTestingStateMachine underTest = new MockCommandTestingStateMachine(InternalState.WATCHING, Delete, Job.JobStatus.COMPLETED, false);
assertEquals(InternalState.TERMINAL, underTest.calcNextStateDeletePhase(Job.JobStatus.COMPLETED, InternalState.WATCHING));
}
@DataProvider
public static Object[][] testShallStopJobDataProvider() {
return new Object[][]{
- {Job.JobStatus.IN_PROGRESS, Action.None, false, false},
- {Job.JobStatus.COMPLETED_WITH_NO_ACTION, Action.None, false, false},
- {Job.JobStatus.COMPLETED, Action.None, false, false},
- {Job.JobStatus.FAILED, Action.None, false, true},
- {Job.JobStatus.COMPLETED_WITH_ERRORS, Action.None, false, true},
- {Job.JobStatus.COMPLETED_WITH_ERRORS, Action.None, true, false},
- {Job.JobStatus.FAILED, Action.None, true, false},
- {Job.JobStatus.FAILED, Action.Delete, true, true},
- {Job.JobStatus.FAILED, Action.Create, true, true},
+ {Job.JobStatus.IN_PROGRESS, None, false, false},
+ {Job.JobStatus.COMPLETED_WITH_NO_ACTION, None, false, false},
+ {Job.JobStatus.COMPLETED, None, false, false},
+ {Job.JobStatus.FAILED, None, false, true},
+ {Job.JobStatus.COMPLETED_WITH_ERRORS, None, false, true},
+ {Job.JobStatus.COMPLETED_WITH_ERRORS, None, true, false},
+ {Job.JobStatus.FAILED, None, true, false},
+ {Job.JobStatus.FAILED, Delete, true, true},
+ {Job.JobStatus.FAILED, Create, true, true},
};
}
@@ -200,7 +231,7 @@ public class ResourceCommandTest {
@Test(dataProvider = "testShallStopJobDataProvider")
public void testShallStopJob(Job.JobStatus jobStatus, Action action, boolean isService, boolean expectedResult) {
//in this test, there is no meaning to constructor parameters besides isService
- MockCommandTestingStateMachine underTest = new MockCommandTestingStateMachine(InternalState.WATCHING, Action.Delete, Job.JobStatus.COMPLETED, false, isService);
+ MockCommandTestingStateMachine underTest = new MockCommandTestingStateMachine(InternalState.WATCHING, Delete, Job.JobStatus.COMPLETED, false, isService, true);
BaseResource mockedRequest = mock(BaseResource.class);
when(underTest.getSharedData().getRequest()).thenReturn(mockedRequest);
@@ -209,6 +240,94 @@ public class ResourceCommandTest {
assertEquals(expectedResult, underTest.shallStopJob(jobStatus));
}
+ public static class FakeResourceCreator {
+
+ public static<T> Map<String, T> convertToMap(List<T> list) {
+ if (list==null) {
+ return null;
+ }
+ return list.stream().collect(Collectors.toMap(x-> UUID.randomUUID().toString(), x->x));
+ }
+
+ static ServiceInstantiation createService(List<Vnf> vnfs, List<Network> networks, List<InstanceGroup> vnfGroups) {
+ return new ServiceInstantiation(mock(ModelInfo.class), null, null, null, null, null, null, null, null, null, null, null, null, null, null,
+ convertToMap(vnfs),
+ convertToMap(networks),
+ convertToMap(vnfGroups),
+ null,
+ null, false, 1, false,false,null, null, null, null, null, null, null);
+ }
+
+ public static ServiceInstantiation createServiceWith2InstancesInEachLevel(Action action) {
+ return createService(
+ ImmutableList.of(
+ createVnf(ImmutableList.of(createVfModule(action), createVfModule(action)), action),
+ createVnf(ImmutableList.of(createVfModule(action), createVfModule(action)), action)),
+ ImmutableList.of(
+ createNetwork(action),
+ createNetwork(action)),
+ ImmutableList.of(
+ createGroup(ImmutableList.of(createMember(action), createMember(action)), action),
+ createGroup(ImmutableList.of(createMember(action), createMember(action)), action))
+ );
+ }
+
+ static InstanceGroup createGroup(List<InstanceGroupMember> groupMembers, Action action) {
+ return new InstanceGroup(mock(ModelInfo.class), null, action.name(), false, null, convertToMap(groupMembers), null, null, null);
+ }
+
+ static InstanceGroupMember createMember(Action action) {
+ return new InstanceGroupMember(null, action.toString(), null, null, null);
+ }
+
+ static Vnf createVnf(List<VfModule> vfModules, Action action) {
+ Map<String, Map<String, VfModule>> vfModulesMap = new HashMap<>();
+ vfModulesMap.put("abc",convertToMap(vfModules));
+
+ return new Vnf(mock(ModelInfo.class), null, null, action.toString(), null, null, null, null, null, null, false, null, vfModulesMap, null, null, null);
+ }
+
+ static Vnf createVnf(Action action) {
+ return new Vnf(mock(ModelInfo.class), null, null, action.toString(), null, null, null, null, null, null, false, null,null, null, null, null);
+ }
+
+ static VfModule createVfModule(Action action) {
+ return new VfModule(mock(ModelInfo.class), null, null, action.toString(), null, null, null, null, null, false, false, null, null, null, null);
+ }
+
+ static Network createNetwork(Action action) {
+ return new Network(mock(ModelInfo.class), null, null, action.toString(), null, null, null, null, null, null, false, null, null, null, null);
+ }
+ }
+
+ @DataProvider
+ public static Object[][] testIsDescendantHasActionDataProvider() {
+ return new Object[][]{
+ {"empty service", Create, false, createService(emptyList(), emptyList(), emptyList())},
+ {"instance group with None", Create, false, createService(emptyList(), emptyList(), ImmutableList.of(createGroup(emptyList(), None)))},
+ {"instance group with Create", Create, true, createService(emptyList(), emptyList(), ImmutableList.of(createGroup(emptyList(), Create)))},
+ {"instance group None + member Delete", Delete, true, createService(emptyList(), emptyList(), ImmutableList.of(createGroup(ImmutableList.of(createMember(Delete)), None)))},
+ {"instance group None + member Create", Delete, false, createService(emptyList(), emptyList(), ImmutableList.of(createGroup(ImmutableList.of(createMember(Create)), None)))},
+ {"instance group None + member Create + member Delete", Delete, true,
+ createService(emptyList(), emptyList(), ImmutableList.of(createGroup(ImmutableList.of(createMember(Create), createMember(Delete)), None)))},
+ {"vnf Create", Delete, false, createService(ImmutableList.of(createVnf(emptyList(), Create)), emptyList(),emptyList())},
+ {"vnf Create", Create, true, createService(ImmutableList.of(createVnf(emptyList(), Create)), emptyList(),emptyList())},
+ {"vnf Create null VfModules internal map", Create, false, createService(ImmutableList.of(createVnf(null, Delete)), emptyList(),emptyList())},
+ {"vnf Delete with null VfModules", Create, false, createService(ImmutableList.of(createVnf(Delete)), emptyList(),emptyList())},
+ {"vnf None + VfModule Create", Create, true, createService(ImmutableList.of(createVnf(ImmutableList.of(createVfModule(Create)), None)), emptyList(),emptyList())},
+ {"vnf None + VfModule None", Create, false, createService(ImmutableList.of(createVnf(ImmutableList.of(createVfModule(None)), None)), emptyList(),emptyList())},
+ {"network Create", Create, true, createService(emptyList(), ImmutableList.of(createNetwork(Create)), emptyList())},
+ {"network Delete", Create, false, createService(emptyList(), ImmutableList.of(createNetwork(Delete)), emptyList())},
+ };
+ }
+
+ @Test(dataProvider = "testIsDescendantHasActionDataProvider")
+ public void testIsDescendantHasAction(String desc, Action action, boolean expectedResult, BaseResource request) {
+ //in this test, there is no meaning to constructor parameters
+ MockCommand underTest = new MockCommand(InternalState.WATCHING, Delete, Job.JobStatus.COMPLETED);
+ assertEquals(expectedResult, underTest.isDescendantHasAction(request, action));
+ }
+
@DataProvider
public static Object[][] testCallDataProvider() {
return new Object[][]{
@@ -235,7 +354,7 @@ public class ResourceCommandTest {
String description, InternalState internalState, Job.JobStatus currentStateResult,
InternalState expectedNextState, Job.JobStatus expectedNextStatus) {
- MockCommandTestingStateMachine underTest = new MockCommandTestingStateMachine(internalState, Action.Delete, currentStateResult, true);
+ MockCommandTestingStateMachine underTest = new MockCommandTestingStateMachine(internalState, Delete, currentStateResult, true);
NextCommand nextCommand = underTest.call();
assertEquals(expectedNextStatus, nextCommand.getStatus());
@@ -250,12 +369,6 @@ public class ResourceCommandTest {
}
}
- @Test(expectedExceptions = IllegalStateException.class)
- public void whenCommandInUnMappedState_exceptionIsThrown() {
- MockCommandTestingStateMachine underTest = new MockCommandTestingStateMachine(InternalState.TERMINAL, Action.Delete, Job.JobStatus.COMPLETED, true);
- underTest.call();
- }
-
@DataProvider
public static Object[][] InProgressDataProvider() {
return Stream.of(Job.JobStatus.values())
@@ -266,7 +379,7 @@ public class ResourceCommandTest {
@Test(dataProvider = "InProgressDataProvider")
public void whenGetResultFromMso_InProgressReturnThem(Job.JobStatus mockedJobStatus) {
Job.JobStatus expectedJobStatus = (mockedJobStatus== Job.JobStatus.PAUSE) ? Job.JobStatus.IN_PROGRESS : mockedJobStatus;
- MockCommand underTest = new MockCommand(InternalState.IN_PROGRESS, Action.Delete, mockedJobStatus);
+ MockCommand underTest = new MockCommand(InternalState.IN_PROGRESS, Delete, mockedJobStatus);
when(underTest.getInProgressStatusService().call(any(), any(), any())).thenReturn(mockedJobStatus);
assertEquals(expectedJobStatus, underTest.inProgress());
}
@@ -282,22 +395,22 @@ public class ResourceCommandTest {
@Test(dataProvider = "InProgressExceptionsDataProvider")
public void whenInProgressStatusServiceThrowException_InProgressReturnStatus(Exception exception, Job.JobStatus expectedJobStatus) {
- MockCommand underTest = new MockCommand(InternalState.IN_PROGRESS, Action.Delete, expectedJobStatus);
+ MockCommand underTest = new MockCommand(InternalState.IN_PROGRESS, Delete, expectedJobStatus);
when(underTest.getInProgressStatusService().call(any(), any(), any())).thenThrow(exception);
assertEquals(expectedJobStatus, underTest.inProgress());
}
@DataProvider
public static Object[][] testIsNeedToDeleteMySelfDataProvider() {
- return Stream.of(Action.values())
+ return Stream.of(values())
.map(status -> new Object[] { status })
.toArray(Object[][]::new);
}
@Test(dataProvider = "testIsNeedToDeleteMySelfDataProvider")
public void testIsNeedToDeleteMySelf(Action action) {
- boolean expectedResult = (action== Action.Delete);
- MockCommand underTest = new MockCommand(InternalState.DELETE_MYSELF, Action.Delete, Job.JobStatus.IN_PROGRESS);
+ boolean expectedResult = (action== Delete);
+ MockCommand underTest = new MockCommand(InternalState.DELETE_MYSELF, Delete, Job.JobStatus.IN_PROGRESS);
BaseResource mockedBaseResource = mock(BaseResource.class);
when(underTest.getSharedData().getRequest()).thenReturn(mockedBaseResource);
when(mockedBaseResource.getAction()).thenReturn(action);
@@ -315,9 +428,74 @@ public class ResourceCommandTest {
@Test(dataProvider = "testWatchingDataProvider")
public void testWatching(String desc, Job.JobStatus childrenJobsStatus, Job.JobStatus expectedJobStatus) {
- MockCommand underTest = new MockCommand(InternalState.WATCHING, Action.Delete, Job.JobStatus.IN_PROGRESS);
+ MockCommand underTest = new MockCommand(InternalState.WATCHING, Delete, Job.JobStatus.IN_PROGRESS);
when(underTest.getWatchChildrenJobsBL().retrieveChildrenJobsStatus(any())).thenReturn(childrenJobsStatus);
assertEquals(expectedJobStatus, underTest.watchChildren());
}
+ @DataProvider
+ public static Object[][] testCalcInitialStateDataProvider() {
+ return new Object[][]{
+ {Delete, true, Delete, InternalState.CREATING_CHILDREN},
+ {Delete, false, Delete, InternalState.DELETE_MYSELF},
+ {Delete, false, Create, InternalState.TERMINAL},
+ {Delete, true, Create, InternalState.CREATING_CHILDREN},
+ {Create, true, Create, InternalState.CREATE_MYSELF},
+ {Create, false, Create, InternalState.CREATE_MYSELF},
+ {Create, false, Delete, InternalState.TERMINAL},
+ {Create, true, Delete, InternalState.CREATING_CHILDREN},
+ {Create, true, Resume, InternalState.RESUME_MYSELF},
+ {Delete, false, Resume, InternalState.TERMINAL},
+ };
+ }
+
+ @Test(dataProvider = "testCalcInitialStateDataProvider")
+ public void testCalcInitialState(Action phase, boolean isDescendantHasAction, Action action, InternalState expectedState) {
+ ResourceCommand underTest = mock(ResourceCommand.class);
+ when(underTest.calcInitialState(any(), any())).thenCallRealMethod();
+ when(underTest.isDescendantHasAction(eq(phase))).thenReturn(isDescendantHasAction);
+ when(underTest.getActionType()).thenReturn(action);
+ when(underTest.isNeedToDeleteMyself()).thenCallRealMethod();
+ when(underTest.isNeedToCreateMyself()).thenCallRealMethod();
+ when(underTest.isNeedToResumeMySelf()).thenCallRealMethod();
+
+ Map<String, String> commandData = ImmutableMap.of(INTERNAL_STATE, InternalState.INITIAL.name());
+ assertEquals(expectedState, underTest.calcInitialState(commandData, phase));
+ }
+
+
+ //throw exception when call to create children
+ //create children is just example, it could be any other method that called by ResourceCommand.invokeCommand
+ public static class MockCommandThrowExceptionOnCreateChildren extends MockCommandTestingStateMachine {
+
+ private final RuntimeException exceptionToThrow;
+
+ public MockCommandThrowExceptionOnCreateChildren(RuntimeException exceptionToThrow) {
+ super(InternalState.CREATING_CHILDREN, Delete, Job.JobStatus.COMPLETED, true);
+ this.exceptionToThrow = exceptionToThrow;
+ doAnswer(returnsFirstArg()).when(this.getWatchChildrenJobsBL()).cumulateJobStatus(any(), any());
+ }
+
+ @NotNull
+ @Override
+ public Job.JobStatus createChildren() {
+ throw exceptionToThrow;
+ }
+ }
+
+ @DataProvider
+ public static Object[][] exceptionAndStateProvider() {
+ return new Object[][]{
+ {new TryAgainException(new Exception()), Job.JobStatus.RESOURCE_IN_PROGRESS},
+ {new AbortingException(new Exception()), Job.JobStatus.FAILED},
+ };
+ }
+
+ @Test(dataProvider = "exceptionAndStateProvider")
+ public void whenKnownExceptionThrownInCommandInvocation_thenStateIsAsExpected(RuntimeException exception, Job.JobStatus expectedNextStatus) {
+ MockCommandTestingStateMachine underTest = new MockCommandThrowExceptionOnCreateChildren(exception);
+ NextCommand nextCommand = underTest.call();
+ assertEquals(expectedNextStatus, nextCommand.getStatus());
+ }
+
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/job/command/ResourceInProgressStatusCommandTest.java b/vid-app-common/src/test/java/org/onap/vid/job/command/ResourceInProgressStatusCommandTest.java
deleted file mode 100644
index 5b036f587..000000000
--- a/vid-app-common/src/test/java/org/onap/vid/job/command/ResourceInProgressStatusCommandTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * 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.vid.job.command;
-
-import org.mockito.InjectMocks;
-import org.mockito.MockitoAnnotations;
-import org.onap.vid.job.Job;
-import org.onap.vid.job.NextCommand;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.Is.is;
-
-
-public class ResourceInProgressStatusCommandTest {
-
- @InjectMocks
- private ResourceInProgressStatusCommand commandUnderTest = new ResourceInProgressStatusCommand();
-
- @BeforeMethod
- public void initMocks() {
- MockitoAnnotations.initMocks(this);
- }
-
- @DataProvider
- public static Object[][] givenStatusToExpectedStatus() {
- return new Object[][]{
- {Job.JobStatus.IN_PROGRESS, Job.JobStatus.IN_PROGRESS},
- {Job.JobStatus.FAILED, Job.JobStatus.FAILED},
- {Job.JobStatus.COMPLETED, Job.JobStatus.COMPLETED}
- };
- }
-
- @Test(dataProvider = "givenStatusToExpectedStatus")
- public void whenGetStatusFromMso_returnExpectedNextCommand(Job.JobStatus jobStatus, Job.JobStatus expectedNextStatus) {
- NextCommand nextCommand = commandUnderTest.processJobStatus(jobStatus);
- assertThat(nextCommand.getStatus(), is(expectedNextStatus));
- assertThat(nextCommand.getCommand(), is(commandUnderTest));
- }
-}
diff --git a/vid-app-common/src/test/java/org/onap/vid/job/command/ServiceInProgressStatusCommandTest.java b/vid-app-common/src/test/java/org/onap/vid/job/command/ServiceInProgressStatusCommandTest.java
index 31dbc9f6d..787ff608d 100644
--- a/vid-app-common/src/test/java/org/onap/vid/job/command/ServiceInProgressStatusCommandTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/job/command/ServiceInProgressStatusCommandTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,22 +20,22 @@
package org.onap.vid.job.command;
+import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.mockito.ArgumentCaptor;
-import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.onap.portalsdk.core.util.SystemProperties;
import org.onap.vid.job.*;
import org.onap.vid.job.impl.JobSharedData;
+import org.onap.vid.model.Action;
import org.onap.vid.model.serviceInstantiation.Network;
import org.onap.vid.model.serviceInstantiation.ServiceInstantiation;
import org.onap.vid.model.serviceInstantiation.Vnf;
-import org.onap.vid.mso.model.ModelInfo;
+import org.onap.vid.mso.RestMsoImplementation;
import org.onap.vid.properties.Features;
import org.onap.vid.properties.VidProperties;
import org.onap.vid.services.AsyncInstantiationBusinessLogic;
-import org.springframework.core.env.Environment;
+import org.onap.vid.services.AuditService;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
@@ -47,10 +47,9 @@ import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;
import java.util.Arrays;
-import java.util.Map;
-import java.util.TreeMap;
import java.util.UUID;
+import static java.util.Collections.emptyList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.core.Is.is;
@@ -58,7 +57,11 @@ import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.*;
import static org.onap.vid.job.Job.JobStatus.*;
+import static org.onap.vid.job.command.ResourceCommandKt.*;
+import static org.onap.vid.job.command.ResourceCommandTest.FakeResourceCreator.*;
+import static org.onap.vid.model.Action.Create;
import static org.onap.vid.testUtils.TestUtils.testWithSystemProperty;
+import static org.testng.AssertJUnit.assertEquals;
public class ServiceInProgressStatusCommandTest {
@@ -79,44 +82,28 @@ public class ServiceInProgressStatusCommandTest {
private JobSharedData sharedData;
@Mock
- private Environment environment;
-
- @Mock
private ServiceInstantiation request;
@Mock
private InProgressStatusService inProgressStatusService;
- @InjectMocks
- private ServiceInProgressStatusCommand command = new ServiceInProgressStatusCommand();
+ @Mock
+ private WatchChildrenJobsBL watchChildrenJobsBL;
- @DataProvider
- public static Object[][] isNeedToCreateChildJobsDataProvider() {
- return new Object[][]{
- {new TreeMap<String,Vnf>() , true, true, false},
- {null , true, true, false},
- {ImmutableMap.of("a",mock(Vnf.class)), false, true, false},
- {ImmutableMap.of("a",mock(Vnf.class)), true, false, false},
- {ImmutableMap.of("a",mock(Vnf.class)), true, true, true},
- };
- }
+ @Mock
+ private MsoResultHandlerService msoResultHandlerService;
+
+ @Mock
+ private MsoRequestBuilder msoRequestBuilder;
+
+ @Mock
+ private RestMsoImplementation restMsoImplementation;
+
+ @Mock
+ private AuditService auditService;
+
+ private ALaCarteServiceCommand command;
- @DataProvider
- public static Object[][] processJobStatusData() {
- return new Object[][]{
- /* {MSO jobStatus, jobStartTime, isNeedToCreateChildJobs(), property vid.job.max.hoursInProgress, expected nextCommand.getStatus() } */
- {IN_PROGRESS, false, IN_PROGRESS},
- {FAILED, false, FAILED},
- {PAUSE, false, IN_PROGRESS},
- {COMPLETED, false, COMPLETED},
- {COMPLETED, true, IN_PROGRESS},
- {RESOURCE_IN_PROGRESS, false, RESOURCE_IN_PROGRESS},
- {PENDING, false, PENDING},
- {STOPPED, false, STOPPED},
- {COMPLETED_WITH_ERRORS, false, COMPLETED_WITH_ERRORS},
- {CREATING, false, CREATING}
- };
- }
@DataProvider
public static Object[][] isExpiredJobStatusData() {
@@ -138,32 +125,31 @@ public class ServiceInProgressStatusCommandTest {
@BeforeMethod
public void initMocks() {
MockitoAnnotations.initMocks(this);
- }
-
- @Test(dataProvider = "isNeedToCreateChildJobsDataProvider" )
- public void testIsNeedToCreateChildJobs(Map<String, Vnf> serviceVnfs, boolean isALaCarte,
- boolean isFeatureEnabled, boolean expected) {
- MockitoAnnotations.initMocks(this);
- ServiceInstantiation serviceInstantiation = mock(ServiceInstantiation.class);
- when(serviceInstantiation.getVnfs()).thenReturn(serviceVnfs);
- when(serviceInstantiation.isALaCarte()).thenReturn(isALaCarte);
- when(featureManager.isActive(Features.FLAG_ASYNC_ALACARTE_VNF)).thenReturn(isFeatureEnabled);
- assertThat(command.isNeedToCreateChildJobs(serviceInstantiation), is(expected));
+ command = new ALaCarteServiceCommand(
+ inProgressStatusService,
+ watchChildrenJobsBL,
+ asyncInstantiationBL,
+ jobsBrokerService,
+ msoRequestBuilder,
+ msoResultHandlerService,
+ jobAdapter,
+ restMsoImplementation,
+ auditService
+ );
}
@Test
public void whenGetFromMsoCompletedAndALaCarte_generateNewJobsForVnfs() {
UUID uuid = UUID.randomUUID();
String userId = "mockedUserID";
- Vnf vnf1 = mock(Vnf.class);
- Vnf vnf2 = mock(Vnf.class);
- Network network1 = mock(Network.class);
- ServiceInstantiation serviceInstantiation = mock(ServiceInstantiation.class);
- when(serviceInstantiation.getVnfs()).thenReturn(ImmutableMap.of("a", vnf1, "b", vnf2));
- when(serviceInstantiation.getNetworks()).thenReturn(ImmutableMap.of("c", network1));
- when(serviceInstantiation.isALaCarte()).thenReturn(true);
- when(serviceInstantiation.getModelInfo()).thenReturn(new ModelInfo());
-
+ String testApi = "VNF_API";
+ Vnf vnf1 = createVnf(emptyList(), Create);
+ Vnf vnf2 = createVnf(emptyList(), Create);
+ Network network = createNetwork(Create);
+ ServiceInstantiation serviceInstantiation = createService(
+ ImmutableList.of(vnf1, vnf2),
+ ImmutableList.of(network),
+ emptyList());
when(featureManager.isActive(Features.FLAG_ASYNC_ALACARTE_VNF)).thenReturn(true);
UUID uuid1 = UUID.fromString("12345678-1234-1234-1234-123456789012");
@@ -171,15 +157,25 @@ public class ServiceInProgressStatusCommandTest {
UUID uuid3 = UUID.fromString("12345678-1234-1234-1234-123456789014");
when(jobsBrokerService.add(any())).thenReturn(uuid1).thenReturn(uuid2).thenReturn(uuid3);
- JobSharedData sharedData = new JobSharedData(uuid, userId, serviceInstantiation);
- command.init(sharedData, "", "");
+ JobSharedData sharedData = new JobSharedData(uuid, userId, serviceInstantiation, testApi);
+ command.init(sharedData, ImmutableMap.of(
+ ACTION_PHASE, Action.Create.name(),
+ INTERNAL_STATE, InternalState.IN_PROGRESS.name()
+ ));
when(inProgressStatusService.call(any(), eq(sharedData), any())).thenReturn(Job.JobStatus.COMPLETED);
+ when(watchChildrenJobsBL.cumulateJobStatus(Job.JobStatus.COMPLETED, COMPLETED_WITH_NO_ACTION)).thenReturn(COMPLETED);
+ when(watchChildrenJobsBL.cumulateJobStatus(Job.JobStatus.COMPLETED_WITH_NO_ACTION, COMPLETED)).thenReturn(COMPLETED);
+ when(msoResultHandlerService.getRequest(eq(sharedData))).thenReturn(serviceInstantiation);
NextCommand nextCommand = command.call();
+ assertEquals(IN_PROGRESS, nextCommand.getStatus());
+ nextCommand = nextCommand.getCommand().call();
ArgumentCaptor<JobAdapter.AsyncJobRequest> argumentCaptor = ArgumentCaptor.forClass(JobAdapter.AsyncJobRequest.class);
- verify(jobAdapter, times(2)).createChildJob(eq(JobType.VnfInstantiation), eq(Job.JobStatus.CREATING), argumentCaptor.capture(), eq(sharedData), any());
- verify(jobAdapter, times(1)).createChildJob(eq(JobType.NetworkInstantiation), eq(Job.JobStatus.CREATING), argumentCaptor.capture(), eq(sharedData), any());
- assertThat(argumentCaptor.getAllValues(), containsInAnyOrder(vnf1, vnf2, network1));
+ verify(jobAdapter, times(1)).createChildJob(eq(JobType.NetworkInstantiation), argumentCaptor.capture(), eq(sharedData), any(), eq(0));
+ verify(jobAdapter, times(1)).createChildJob(eq(JobType.VnfInstantiation), argumentCaptor.capture(), eq(sharedData), any(), eq(1));
+ verify(jobAdapter, times(1)).createChildJob(eq(JobType.VnfInstantiation), argumentCaptor.capture(), eq(sharedData), any(), eq(2));
+
+ assertThat(argumentCaptor.getAllValues(), containsInAnyOrder(vnf1, vnf2, network));
verify(jobsBrokerService, times(3)).add(any());
@@ -187,41 +183,14 @@ public class ServiceInProgressStatusCommandTest {
verify(asyncInstantiationBL, never()).updateServiceInfo(any(), any());
assertThat(nextCommand.getStatus(), is(Job.JobStatus.IN_PROGRESS));
- assertThat(nextCommand.getCommand().getType(), is(new WatchingCommand().getType()));
- assertThat(nextCommand.getCommand().getData().get("childrenJobs"), is(Arrays.asList(uuid1.toString(), uuid2.toString(), uuid3.toString())));
- assertThat(nextCommand.getCommand().getData().get("isService"), is(true));
- }
-
- @Test(dataProvider = "processJobStatusData")
- public void processJobStatusTest(Job.JobStatus jobStatus, boolean isNeedToCreateChildJobs, Job.JobStatus expectedStatus) {
-
- when(featureManager.isActive(Features.FLAG_ASYNC_ALACARTE_VNF)).thenReturn(true);
- // All mocks under are used for isNeedToCreateChildJobs=true case
- when(sharedData.getRequest()).thenReturn(request);
- when(request.isALaCarte()).thenReturn(true);
- Map vnfs = mock(Map.class);
- ModelInfo modelInfo = mock(ModelInfo.class);
-
- // if vnfs.isEmpty -> isNeedToCreateChildJobs will return false
- when(vnfs.isEmpty()).thenReturn(!isNeedToCreateChildJobs);
-
- when(request.getVnfs()).thenReturn(vnfs);
- when(request.getModelInfo()).thenReturn(modelInfo);
- command.instanceId = "MockInstId";
-
- NextCommand nextCommand = command.processJobStatus(jobStatus);
- Assert.assertEquals(nextCommand.getStatus(), expectedStatus);
- if (isNeedToCreateChildJobs) {
- Assert.assertEquals(nextCommand.getCommand().getClass(), WatchingCommand.class);
- } else {
- Assert.assertEquals(nextCommand.getCommand(), command);
- }
+ assertThat(nextCommand.getCommand().getType(), is(JobType.ALaCarteService));
+ assertThat(nextCommand.getCommand().getData().get(CHILD_JOBS), is(Arrays.asList(uuid1.toString(), uuid2.toString(), uuid3.toString())));
}
@Test(dataProvider = "isExpiredJobStatusData")
public void isExpiredJobStatusTest(ZonedDateTime jobStartTime, String configValue, boolean expectedResult) throws Exception {
testWithSystemProperty(VidProperties.VID_JOB_MAX_HOURS_IN_PROGRESS, configValue, ()->
- Assert.assertEquals(command.getExpiryChecker().isExpired(jobStartTime), expectedResult)
+ Assert.assertEquals(command.getExpiryChecker().isExpired(jobStartTime), expectedResult)
);
}
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/job/command/WatchChildrenJobsBLTest.java b/vid-app-common/src/test/java/org/onap/vid/job/command/WatchChildrenJobsBLTest.java
index 630c46438..a9a961db8 100644
--- a/vid-app-common/src/test/java/org/onap/vid/job/command/WatchChildrenJobsBLTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/job/command/WatchChildrenJobsBLTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -23,10 +23,10 @@ package org.onap.vid.job.command;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.onap.portalsdk.core.service.DataAccessService;
import org.onap.vid.job.Job.JobStatus;
import org.onap.vid.job.impl.JobDaoImpl;
import org.onap.vid.utils.DaoUtils;
+import org.onap.portalsdk.core.service.DataAccessService;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
diff --git a/vid-app-common/src/test/java/org/onap/vid/job/command/WatchingCommandTest.java b/vid-app-common/src/test/java/org/onap/vid/job/command/WatchingCommandTest.java
deleted file mode 100644
index cc0e66007..000000000
--- a/vid-app-common/src/test/java/org/onap/vid/job/command/WatchingCommandTest.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * 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.vid.job.command;
-
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.onap.portalsdk.core.service.DataAccessService;
-import org.onap.vid.job.Job;
-import org.onap.vid.job.NextCommand;
-import org.onap.vid.job.impl.JobSharedData;
-import org.onap.vid.model.serviceInstantiation.ServiceInstantiation;
-import org.onap.vid.services.AsyncInstantiationBusinessLogic;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-import java.util.List;
-import java.util.UUID;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.Is.is;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.*;
-
-public class WatchingCommandTest {
-
- @Mock
- private AsyncInstantiationBusinessLogic asyncInstantiationBL;
-
- @Mock
- private DataAccessService dataAccessService;
-
- @Mock
- private WatchChildrenJobsBL watchChildrenJobsBL;
-
- @InjectMocks
- private WatchingCommand watchingCommand = new WatchingCommand();
-
-
-
- @BeforeClass
- public void initMocks() {
- MockitoAnnotations.initMocks(this);
- }
-
- @DataProvider
- public static Object[][] testWatchingDataProvider() {
- return new Object[][]{
- {"all children final, no failed child, is service", Job.JobStatus.COMPLETED, true, Job.JobStatus.COMPLETED},
- {"all children final, there is failed child, is service", Job.JobStatus.COMPLETED_WITH_ERRORS, true, Job.JobStatus.COMPLETED_WITH_ERRORS},
- {"not all children final, is service", Job.JobStatus.IN_PROGRESS, true, Job.JobStatus.IN_PROGRESS},
- {"all children final, no failed child, not service", Job.JobStatus.COMPLETED, false, Job.JobStatus.COMPLETED},
- {"all children final, there is failed child, not service", Job.JobStatus.COMPLETED_WITH_ERRORS, false, Job.JobStatus.COMPLETED_WITH_ERRORS},
- {"not all children final, not service", Job.JobStatus.IN_PROGRESS, false, Job.JobStatus.RESOURCE_IN_PROGRESS},
- };
- }
-
-
-
- @Test(dataProvider = "testWatchingDataProvider")
- public void whenGetChildrenStatus_thenJobStatusAsExpected(String desc, Job.JobStatus childrenComulativeStatus, boolean isService, Job.JobStatus expectedCommandStatus) {
- UUID jobUUID = UUID.randomUUID();
- JobSharedData sharedData = new JobSharedData(jobUUID, "mockedUserID", mock(ServiceInstantiation.class));
- List<String> uuids = mock(List.class);
- watchingCommand.init(sharedData, uuids, isService);
- when(watchChildrenJobsBL.retrieveChildrenJobsStatus(eq(uuids))).thenReturn(childrenComulativeStatus);
- when(watchChildrenJobsBL.cumulateJobStatus(eq(childrenComulativeStatus),eq(Job.JobStatus.COMPLETED))).thenReturn(childrenComulativeStatus);
-
- //execute command and verify
- NextCommand nextCommand = watchingCommand.call();
- assertThat(nextCommand.getStatus(), is(expectedCommandStatus));
- if (!expectedCommandStatus.equals(Job.JobStatus.IN_PROGRESS) && isService) {
- verify(asyncInstantiationBL).updateServiceInfoAndAuditStatus(jobUUID, expectedCommandStatus);
- } else {
- verify(asyncInstantiationBL, never()).updateServiceInfoAndAuditStatus(jobUUID, expectedCommandStatus);
- }
- }
-}
diff --git a/vid-app-common/src/test/java/org/onap/vid/job/impl/AsyncInstantiationIntegrationTest.java b/vid-app-common/src/test/java/org/onap/vid/job/impl/AsyncInstantiationIntegrationTest.java
index 0b1fff3b2..498708d06 100644
--- a/vid-app-common/src/test/java/org/onap/vid/job/impl/AsyncInstantiationIntegrationTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/job/impl/AsyncInstantiationIntegrationTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,43 +20,55 @@
package org.onap.vid.job.impl;
+import com.fasterxml.jackson.databind.JsonNode;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.mutable.MutableInt;
+import org.jetbrains.annotations.NotNull;
+import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
+import org.mockito.hamcrest.MockitoHamcrest;
import org.onap.portalsdk.core.service.DataAccessService;
import org.onap.portalsdk.core.util.SystemProperties;
import org.onap.vid.asdc.AsdcCatalogException;
-import org.onap.vid.config.DataSourceConfig;
-import org.onap.vid.config.JobCommandsConfigWithMockedMso;
-import org.onap.vid.config.MockedAaiClientAndFeatureManagerConfig;
+import org.onap.vid.changeManagement.RequestDetailsWrapper;
import org.onap.vid.job.Job;
import org.onap.vid.job.Job.JobStatus;
import org.onap.vid.job.JobType;
import org.onap.vid.job.JobsBrokerService;
import org.onap.vid.job.command.CommandUtils;
import org.onap.vid.job.command.InternalState;
-import org.onap.vid.model.Action;
-import org.onap.vid.model.NameCounter;
-import org.onap.vid.model.RequestReferencesContainer;
-import org.onap.vid.model.ServiceInfo;
+import org.onap.vid.model.*;
+import org.onap.vid.model.serviceInstantiation.BaseResource;
+import org.onap.vid.model.serviceInstantiation.InstanceGroup;
import org.onap.vid.model.serviceInstantiation.ServiceInstantiation;
import org.onap.vid.mso.RestMsoImplementation;
import org.onap.vid.mso.RestObject;
import org.onap.vid.mso.model.RequestReferences;
import org.onap.vid.mso.rest.AsyncRequestStatus;
+import org.onap.vid.mso.rest.AsyncRequestStatusList;
import org.onap.vid.properties.Features;
-import org.onap.vid.services.AsyncInstantiationBaseTest;
import org.onap.vid.services.AsyncInstantiationBusinessLogic;
+import org.onap.vid.services.AuditService;
+import org.onap.vid.services.VersionService;
import org.onap.vid.utils.DaoUtils;
+import org.onap.vid.config.DataSourceConfig;
+import org.onap.vid.config.JobCommandsConfigWithMockedMso;
+import org.onap.vid.config.MockedAaiClientAndFeatureManagerConfig;
+import org.onap.vid.services.AsyncInstantiationBaseTest;
+import org.onap.vid.testUtils.TestUtils;
+import org.springframework.http.HttpMethod;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
import org.togglz.core.manager.FeatureManager;
import javax.inject.Inject;
import javax.ws.rs.ProcessingException;
+import java.io.IOException;
import java.lang.reflect.Method;
import java.util.*;
import java.util.function.BiConsumer;
@@ -66,7 +78,8 @@ import java.util.stream.IntStream;
import java.util.stream.Stream;
import static java.util.stream.Collectors.*;
-import static net.javacrumbs.jsonunit.JsonMatchers.jsonPartEquals;
+import static net.javacrumbs.jsonunit.JsonAssert.assertJsonEquals;
+import static net.javacrumbs.jsonunit.JsonMatchers.*;
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasProperty;
@@ -77,7 +90,7 @@ import static org.mockito.ArgumentMatchers.endsWith;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*;
import static org.onap.vid.job.Job.JobStatus.*;
-import static org.onap.vid.model.JobAuditStatus.SourceStatus.MSO;
+import static org.onap.vid.job.impl.JobSchedulerInitializer.WORKERS_TOPICS;
import static org.onap.vid.model.JobAuditStatus.SourceStatus.VID;
import static org.testng.AssertJUnit.*;
@@ -97,6 +110,9 @@ public class AsyncInstantiationIntegrationTest extends AsyncInstantiationBaseTes
public static String SERVICE_INSTANCE_ID = UUID.randomUUID().toString();
@Inject
+ private VersionService versionService;
+
+ @Inject
private JobsBrokerService jobsBrokerService;
@Inject
@@ -109,6 +125,9 @@ public class AsyncInstantiationIntegrationTest extends AsyncInstantiationBaseTes
private AsyncInstantiationBusinessLogic asyncInstantiationBL;
@Inject
+ private AuditService auditService;
+
+ @Inject
private RestMsoImplementation restMso;
@Inject
@@ -120,6 +139,7 @@ public class AsyncInstantiationIntegrationTest extends AsyncInstantiationBaseTes
@BeforeClass
void initServicesInfoService() {
createInstanceParamsMaps();
+ when(versionService.retrieveBuildNumber()).thenReturn("fakeBuild");
}
@BeforeMethod
@@ -131,10 +151,12 @@ public class AsyncInstantiationIntegrationTest extends AsyncInstantiationBaseTes
@BeforeMethod
void defineMocks() {
+ Mockito.reset(restMso);
+ Mockito.reset(aaiClient);
mockAaiClientAnyNameFree();
}
- //@Test
+ @Test
public void whenPushNewBulk_thenAllServicesAreInPending() {
pushMacroBulk();
@@ -144,8 +166,8 @@ public class AsyncInstantiationIntegrationTest extends AsyncInstantiationBaseTes
private List<UUID> pushMacroBulk() {
ServiceInstantiation serviceInstantiation = generateMockMacroServiceInstantiationPayload(false,
- createVnfList(instanceParamsMapWithoutParams, Collections.EMPTY_LIST, true),
- 3, true,PROJECT_NAME, true);
+ createVnfList(instanceParamsMapWithoutParams, Collections.EMPTY_LIST, true),
+ 3, true,PROJECT_NAME, true);
return asyncInstantiationBL.pushBulkJob(serviceInstantiation, USER_ID);
}
@@ -167,6 +189,10 @@ public class AsyncInstantiationIntegrationTest extends AsyncInstantiationBaseTes
return createResponse(statusCode, SERVICE_INSTANCE_ID, REQUEST_ID);
}
+ public static RestObject<RequestReferencesContainer> createResponseRandomIds(int statusCode) {
+ return createResponse(statusCode, UUID.randomUUID().toString(), UUID.randomUUID().toString());
+ }
+
public static RestObject<RequestReferencesContainer> createResponse(int statusCode, String instanceId, String requestId) {
RequestReferences requestReferences = new RequestReferences();
requestReferences.setRequestId(requestId);
@@ -180,7 +206,7 @@ public class AsyncInstantiationIntegrationTest extends AsyncInstantiationBaseTes
ImmutableList<String> statusesToStrings(JobStatus... jobStatuses) {
return Stream.of(jobStatuses).map(
- Enum::toString).collect(ImmutableList.toImmutableList());
+ Enum::toString).collect(ImmutableList.toImmutableList());
}
/*
@@ -190,81 +216,85 @@ public class AsyncInstantiationIntegrationTest extends AsyncInstantiationBaseTes
Make sure service state is Completed successfully once we got from MSO complete, and that next job is peeked.
Once a service in the bulk is failed, other services moved to Stopped, and no other jobs from the bulk are peeked.
*/
- //@Test
+ @Test
public void testStatusesOfMacroServiceInBulkDuringBulkLifeCycle() {
- when(restMso.PostForObject(any(), any(), eq(RequestReferencesContainer.class))).thenReturn(createResponse(200));
+
+ final String SERVICE_REQUEST_ID = UUID.randomUUID().toString();
+ final String SERVICE_INSTANCE_ID = UUID.randomUUID().toString();
+ final String SERVICE2_REQUEST_ID = UUID.randomUUID().toString();
+ final String SERVICE2_INSTANCE_ID = UUID.randomUUID().toString();
+
+ when(restMso.restCall(eq(HttpMethod.POST), eq(RequestReferencesContainer.class), any(), any(), eq(Optional.empty())))
+ .thenReturn(createResponse(200, SERVICE_INSTANCE_ID, SERVICE_REQUEST_ID));
+
ImmutableList<ImmutableList<String>> expectedStatusesForVid = ImmutableList.of(
- statusesToStrings(PENDING, IN_PROGRESS, COMPLETED),
- statusesToStrings(PENDING, IN_PROGRESS, FAILED),
- statusesToStrings(PENDING, STOPPED)
+ statusesToStrings(PENDING, IN_PROGRESS, COMPLETED),
+ statusesToStrings(PENDING, IN_PROGRESS, FAILED),
+ statusesToStrings(PENDING, STOPPED)
);
ImmutableList<ImmutableList<String>> expectedStatusesForMso = ImmutableList.of(
- ImmutableList.of(REQUESTED, IN_PROGRESS_STR, "not a state", FAILED_STR ,COMPLETE_STR),
- ImmutableList.of(REQUESTED, FAILED_STR),
- ImmutableList.of()
+ ImmutableList.of(REQUESTED, IN_PROGRESS_STR, "not a state", FAILED_STR ,COMPLETE_STR),
+ ImmutableList.of(REQUESTED, FAILED_STR),
+ ImmutableList.of()
);
List<UUID> uuids = pushMacroBulk();
- pullPendingJobAndAssertJobStatus(JobStatus.IN_PROGRESS, PENDING);
-
+ UUID firstJobUuid = uuids.get(0);
+ UUID secondJobUuid = uuids.get(1);
//assert that when get ProcessingException from restMso, status remain the same
- when(restMso.GetForObject(any(), eq(AsyncRequestStatus.class))).thenThrow(new ProcessingException("fake message"));
- Job job = pullJobProcessAndPushBack(JobStatus.IN_PROGRESS, JobStatus.IN_PROGRESS);
- UUID firstHandledJobUUID = job.getUuid();
- listServicesAndAssertStatus(JobStatus.IN_PROGRESS, PENDING, job);
+ when(restMso.GetForObject(endsWith(SERVICE_REQUEST_ID), eq(AsyncRequestStatus.class))).thenThrow(new ProcessingException("fake message"));
+ processJobsCountTimesAndAssertStatus(firstJobUuid, 10, IN_PROGRESS, PENDING);
//assert that when get IN_PROGRESS status from restMso, status remain IN_PROGRESS
- when(restMso.GetForObject(any(), eq(AsyncRequestStatus.class))).thenReturn(asyncRequestStatusResponseAsRestObject(IN_PROGRESS_STR));
- job = pullJobProcessAndPushBack(JobStatus.IN_PROGRESS, JobStatus.IN_PROGRESS);
- listServicesAndAssertStatus(JobStatus.IN_PROGRESS, PENDING, job);
+ when(restMso.GetForObject(endsWith(SERVICE_REQUEST_ID), eq(AsyncRequestStatus.class))).thenReturn(asyncRequestStatusResponseAsRestObject(IN_PROGRESS_STR));
+ processJobsCountTimesAndAssertStatus(firstJobUuid, 10, IN_PROGRESS, PENDING);
//assert that when get unrecognized status from restMso, status remain IN_PROGRESS
- when(restMso.GetForObject(any(), eq(AsyncRequestStatus.class))).thenReturn(asyncRequestStatusResponseAsRestObject("not a state"));
- job = pullJobProcessAndPushBack(JobStatus.IN_PROGRESS, JobStatus.IN_PROGRESS);
- listServicesAndAssertStatus(JobStatus.IN_PROGRESS, PENDING, job);
+ when(restMso.GetForObject(endsWith(SERVICE_REQUEST_ID), eq(AsyncRequestStatus.class))).thenReturn(asyncRequestStatusResponseAsRestObject("not a state"));
+ processJobsCountTimesAndAssertStatus(firstJobUuid, 10, IN_PROGRESS, PENDING);
//assert that when get non 200 status code during IN_PROGRESS, status remain IN_PROGRESS
- when(restMso.GetForObject(any(), eq(AsyncRequestStatus.class))).thenReturn(asyncRequestStatusResponseAsRestObject(COMPLETE_STR, 404));
- job = pullJobProcessAndPushBack(JobStatus.IN_PROGRESS, JobStatus.IN_PROGRESS);
- listServicesAndAssertStatus(JobStatus.IN_PROGRESS, PENDING, job);
+ when(restMso.GetForObject(endsWith(SERVICE_REQUEST_ID), eq(AsyncRequestStatus.class))).thenReturn(asyncRequestStatusResponseAsRestObject(COMPLETE_STR, 404));
+ processJobsCountTimesAndAssertStatus(firstJobUuid, 10, IN_PROGRESS, PENDING);
//when get job COMPLETE from MSO, service status become COMPLETED
- when(restMso.GetForObject(any(), eq(AsyncRequestStatus.class))).
- thenReturn(asyncRequestStatusResponseAsRestObject(COMPLETE_STR));
- job = pullJobProcessAndPushBack(JobStatus.IN_PROGRESS, COMPLETED);
- List<ServiceInfo> serviceInfoList = listServicesAndAssertStatus(COMPLETED, PENDING, job);
-
-
+ when(restMso.GetForObject(endsWith(SERVICE_REQUEST_ID), eq(AsyncRequestStatus.class))).thenReturn(asyncRequestStatusResponseAsRestObject(COMPLETE_STR));
+ pullJobProcessAndPushBack(JobStatus.IN_PROGRESS, COMPLETED);
+ List<ServiceInfo> serviceInfoList = listServicesAndAssertStatus(COMPLETED, PENDING, firstJobUuid);
+
+
//for use later in the test
Map<UUID, JobStatus> expectedJobStatusMap = serviceInfoList.stream().collect(
- Collectors.toMap(ServiceInfo::getJobId, x-> PENDING));
- expectedJobStatusMap.put(job.getUuid(), COMPLETED);
+ Collectors.toMap(ServiceInfo::getJobId, x-> PENDING));
+ expectedJobStatusMap.put(firstJobUuid, COMPLETED);
//when handling another PENDING job, statuses are : COMPLETED, IN_PROGRESS, PENDING
- job = pullJobProcessAndPushBack(PENDING, JobStatus.IN_PROGRESS);
- assertThat(job.getUuid(), not(equalTo(firstHandledJobUUID))); //assert different job was handled now
- expectedJobStatusMap.put(job.getUuid(), JobStatus.IN_PROGRESS);
+ when(restMso.restCall(eq(HttpMethod.POST), eq(RequestReferencesContainer.class), any(), any(), eq(Optional.empty())))
+ .thenReturn(createResponse(200, SERVICE2_INSTANCE_ID, SERVICE2_REQUEST_ID));
+ when(restMso.GetForObject(endsWith(SERVICE2_REQUEST_ID), eq(AsyncRequestStatus.class))).thenReturn(asyncRequestStatusResponseAsRestObject(IN_PROGRESS_STR));
+ processJobsCountTimes(10);
+
+ expectedJobStatusMap.put(secondJobUuid, JobStatus.IN_PROGRESS);
listServicesAndAssertStatus(expectedJobStatusMap);
+
//when get FAILED status from MSO statuses are : COMPLETED, FAILED, STOPPED
- when(restMso.GetForObject(any(), eq(AsyncRequestStatus.class))).
- thenReturn(asyncRequestStatusResponseAsRestObject(FAILED_STR));
- job = pullJobProcessAndPushBack(JobStatus.IN_PROGRESS, JobStatus.FAILED);
- expectedJobStatusMap.put(job.getUuid(), JobStatus.FAILED);
+ when(restMso.GetForObject(any(), eq(AsyncRequestStatus.class))).thenReturn(asyncRequestStatusResponseAsRestObject(FAILED_STR));
+ pullJobProcessAndPushBack(JobStatus.IN_PROGRESS, JobStatus.FAILED);
+ expectedJobStatusMap.put(secondJobUuid, JobStatus.FAILED);
expectedJobStatusMap = expectedJobStatusMap.entrySet().stream().collect(Collectors.toMap(
- e -> e.getKey(), e -> e.getValue() == PENDING ? JobStatus.STOPPED : e.getValue()
+ e -> e.getKey(), e -> e.getValue() == PENDING ? JobStatus.STOPPED : e.getValue()
));
listServicesAndAssertStatus(expectedJobStatusMap);
IntStream.range(0, uuids.size()).forEach(i -> {
UUID uuid = uuids.get(i);
- List<String> msoStatuses = asyncInstantiationBL.getAuditStatuses(uuid, MSO).stream().map(x -> x.getJobStatus()).collect(Collectors.toList());
- List<String> vidStatuses = asyncInstantiationBL.getAuditStatuses(uuid, VID).stream().map(x -> x.getJobStatus()).collect(Collectors.toList());
- assertThat(msoStatuses, is(expectedStatusesForMso.get(i)));
+ List<String> vidStatuses = auditService.getAuditStatuses(uuid, VID).stream().map(x -> x.getJobStatus()).collect(Collectors.toList());
assertThat(vidStatuses, is(expectedStatusesForVid.get(i)));
});
- //
+
+ //assert no more jobs to pull
assertFalse(jobsBrokerService.pull(PENDING, randomUuid()).isPresent());
assertFalse(jobsBrokerService.pull(JobStatus.IN_PROGRESS, randomUuid()).isPresent());
}
@@ -273,8 +303,8 @@ public class AsyncInstantiationIntegrationTest extends AsyncInstantiationBaseTes
@DataProvider
public static Object[][] AlaCarteStatuses(Method test) {
return new Object[][]{
- {COMPLETE_STR, JobStatus.COMPLETED, JobStatus.COMPLETED},
- {FAILED_STR, JobStatus.COMPLETED_WITH_ERRORS, JobStatus.FAILED},
+ {COMPLETE_STR, JobStatus.COMPLETED},
+ {FAILED_STR, JobStatus.COMPLETED_WITH_ERRORS},
};
}
@@ -285,8 +315,8 @@ public class AsyncInstantiationIntegrationTest extends AsyncInstantiationBaseTes
Make sure service state is Completed successfully once we got from MSO complete for the vnf job.
status Creating
*/
- //@Test(dataProvider = "AlaCarteStatuses")
- public void testStatusesOfServiceDuringALaCarteLifeCycleIgnoringVfModules(String msoVnfStatus, JobStatus expectedServiceStatus, JobStatus expectedVnfStatus) {
+ @Test(dataProvider = "AlaCarteStatuses")
+ public void testStatusesOfServiceDuringALaCarteLifeCycleIgnoringVfModules(String msoVnfStatus, JobStatus expectedServiceStatus) {
/*
[v] + push alacarte with 1 vnf
[v] verify STATUS pending
@@ -305,6 +335,7 @@ public class AsyncInstantiationIntegrationTest extends AsyncInstantiationBaseTes
* not looking on audit (yet)
*/
+ reset(restMso);
when(featureManager.isActive(Features.FLAG_ASYNC_ALACARTE_VNF)).thenReturn(true);
when(featureManager.isActive(Features.FLAG_ASYNC_ALACARTE_VFMODULE)).thenReturn(false);
final String SERVICE_REQUEST_ID = UUID.randomUUID().toString();
@@ -315,39 +346,22 @@ public class AsyncInstantiationIntegrationTest extends AsyncInstantiationBaseTes
//push alacarte with 1 vnf, verify STATUS pending
UUID uuid = pushALaCarteWithVnf();
singleServicesAndAssertStatus(JobStatus.PENDING, uuid);
-
//mock mso to answer 200 of create service instance request, verify STATUS in progress
- when(restMso.PostForObject(any(), endsWith("serviceInstances"), eq(RequestReferencesContainer.class))).thenReturn(
- createResponse(200, SERVICE_INSTANCE_ID, SERVICE_REQUEST_ID));
- pullJobProcessAndPushBackWithTypeAssertion(JobStatus.PENDING, JobStatus.IN_PROGRESS, JobType.InProgressStatus);
- singleServicesAndAssertStatus(JobStatus.IN_PROGRESS, uuid);
-
+ when(restMso.restCall(eq(HttpMethod.POST), eq(RequestReferencesContainer.class), any(), endsWith("serviceInstances"), any())).thenReturn(
+ createResponse(200, SERVICE_INSTANCE_ID, SERVICE_REQUEST_ID));
//mock mso to answer COMPLETE for service instance create, job status shall remain IN_PROGRESS and type shall be Watching
- reset(restMso);
when(restMso.GetForObject(endsWith(SERVICE_REQUEST_ID), eq(AsyncRequestStatus.class))).
- thenReturn(asyncRequestStatusResponseAsRestObject(COMPLETE_STR));
- pullJobProcessAndPushBackWithTypeAssertion(JobStatus.IN_PROGRESS, JobStatus.IN_PROGRESS, JobType.Watching);
- singleServicesAndAssertStatus(JobStatus.IN_PROGRESS, uuid);
-
+ thenReturn(asyncRequestStatusResponseAsRestObject(COMPLETE_STR));
//mock mso to answer 200 of create vnf instance request, pull+execute vnf job, STATUS resource in progress
- reset(restMso);
- when(restMso.PostForObject(any(), endsWith(SERVICE_INSTANCE_ID + "/vnfs"), eq(RequestReferencesContainer.class))).thenReturn(
- createResponse(200, UUID.randomUUID().toString(), VNF_REQUEST_ID));
- pullJobProcessAndPushBackWithTypeAssertion(JobStatus.CREATING, JobStatus.RESOURCE_IN_PROGRESS, JobType.VnfInProgressStatus);
-
- //verify service job STATUS in progress
- pullJobProcessAndPushBackWithTypeAssertion(JobStatus.IN_PROGRESS, JobStatus.IN_PROGRESS, JobType.Watching);
- singleServicesAndAssertStatus(JobStatus.IN_PROGRESS, uuid);
-
- //mock mso to answer msoVnfStatus (COMPLETE/FAILED) for vnf creation status,
- //job status shall be final (COMPLETE/COMPLETE_WITH_ERRORS)
- reset(restMso);
+ when(restMso.restCall(eq(HttpMethod.POST), eq(RequestReferencesContainer.class), any(), endsWith(SERVICE_INSTANCE_ID + "/vnfs"), any())).thenReturn(
+ createResponse(200, UUID.randomUUID().toString(), VNF_REQUEST_ID));
when(restMso.GetForObject(endsWith(VNF_REQUEST_ID), eq(AsyncRequestStatus.class))).thenReturn(
- asyncRequestStatusResponseAsRestObject(msoVnfStatus));
- pullJobProcessAndPushBack(JobStatus.RESOURCE_IN_PROGRESS, expectedVnfStatus, false);
- singleServicesAndAssertStatus(JobStatus.IN_PROGRESS, uuid);
- pullJobProcessAndPushBack(JobStatus.IN_PROGRESS, expectedServiceStatus, true);
- singleServicesAndAssertStatus(expectedServiceStatus, uuid);
+ asyncRequestStatusResponseAsRestObject(msoVnfStatus));
+
+ processJobsCountTimesAndAssertStatus(uuid, 100, expectedServiceStatus);
+ verify(restMso, times(1)).restCall(eq(HttpMethod.POST), any(), any(), eq("/serviceInstantiation/v7/serviceInstances"), any());
+ verify(restMso, times(1)).restCall(eq(HttpMethod.POST), any(), any(), endsWith(SERVICE_INSTANCE_ID + "/vnfs"), any());
+ verify(restMso, times(2)).GetForObject(any(), any());
}
@@ -361,13 +375,11 @@ public class AsyncInstantiationIntegrationTest extends AsyncInstantiationBaseTes
And union these tests to single one.
*/
- //@Test
+ @Test
public void testALaCarteLifeCycle1Vnf2VfModules() {
String msoVnfStatus = COMPLETE_STR;
- JobStatus expectedServiceStatus = IN_PROGRESS;
- JobStatus expectedVnfStatus = RESOURCE_IN_PROGRESS;
when(featureManager.isActive(Features.FLAG_ASYNC_ALACARTE_VNF)).thenReturn(true);
when(featureManager.isActive(Features.FLAG_ASYNC_ALACARTE_VFMODULE)).thenReturn(true);
final String SERVICE_REQUEST_ID = UUID.randomUUID().toString();
@@ -383,39 +395,27 @@ public class AsyncInstantiationIntegrationTest extends AsyncInstantiationBaseTes
//push alacarte with 1 vnf, verify STATUS pending
UUID uuid = pushALaCarteWithVnf();
singleServicesAndAssertStatus(JobStatus.PENDING, uuid);
+ reset(restMso);
/*---------- service -----------*/
//mock mso to answer 200 of create service instance request, verify STATUS in progress
- when(restMso.PostForObject(any(), endsWith("serviceInstances"), eq(RequestReferencesContainer.class))).thenReturn(
- createResponse(200, SERVICE_INSTANCE_ID, SERVICE_REQUEST_ID));
- pullJobProcessAndPushBackWithTypeAssertion(JobStatus.PENDING, JobStatus.IN_PROGRESS, JobType.InProgressStatus);
- singleServicesAndAssertStatus(JobStatus.IN_PROGRESS, uuid);
+ when(restMso.restCall(eq(HttpMethod.POST), eq(RequestReferencesContainer.class), any(), endsWith("serviceInstances"), any())).thenReturn(
+ createResponse(200, SERVICE_INSTANCE_ID, SERVICE_REQUEST_ID));
- //mock mso to answer COMPLETE for service instance create, job status shall remain IN_PROGRESS and type shall be Watching
- reset(restMso);
+ //mock mso to answer COMPLETE for service instance create
when(restMso.GetForObject(endsWith(SERVICE_REQUEST_ID), eq(AsyncRequestStatus.class))).
- thenReturn(asyncRequestStatusResponseAsRestObject(COMPLETE_STR));
- pullJobProcessAndPushBackWithTypeAssertion(JobStatus.IN_PROGRESS, JobStatus.IN_PROGRESS, JobType.Watching);
- singleServicesAndAssertStatus(JobStatus.IN_PROGRESS, uuid);
+ thenReturn(asyncRequestStatusResponseAsRestObject(COMPLETE_STR));
/*---------- vnf -----------*/
- //mock mso to answer 200 of create vnf instance request, pull+execute vnf job, STATUS resource in progress
- reset(restMso);
- when(restMso.PostForObject(any(), endsWith(SERVICE_INSTANCE_ID + "/vnfs"), eq(RequestReferencesContainer.class))).thenReturn(
- createResponse(200, VNF_INSTANCE_ID, VNF_REQUEST_ID));
- pullJobProcessAndPushBackWithTypeAssertion(JobStatus.CREATING, JobStatus.RESOURCE_IN_PROGRESS, JobType.VnfInProgressStatus);
-
- //verify service job STATUS in progress
- pullJobProcessAndPushBackWithTypeAssertion(JobStatus.IN_PROGRESS, JobStatus.IN_PROGRESS, JobType.Watching);
- singleServicesAndAssertStatus(JobStatus.IN_PROGRESS, uuid);
+ //mock mso to answer 200 of create vnf instance request
+ when(restMso.restCall(eq(HttpMethod.POST), eq(RequestReferencesContainer.class), any(), endsWith(SERVICE_INSTANCE_ID + "/vnfs"), any())).thenReturn(
+ createResponse(200, VNF_INSTANCE_ID, VNF_REQUEST_ID));
//mock mso to answer msoVnfStatus (COMPLETE/FAILED) for vnf creation status,
- //job status shall be final (COMPLETE/COMPLETE_WITH_ERRORS)
- reset(restMso);
when(restMso.GetForObject(endsWith(VNF_REQUEST_ID), eq(AsyncRequestStatus.class))).
- thenReturn(asyncRequestStatusResponseAsRestObject(COMPLETE_STR));
+ thenReturn(asyncRequestStatusResponseAsRestObject(COMPLETE_STR));
try {
reset(commandUtils);
@@ -425,113 +425,164 @@ public class AsyncInstantiationIntegrationTest extends AsyncInstantiationBaseTes
}
- pullJobProcessAndPushBackWithTypeAssertion(JobStatus.RESOURCE_IN_PROGRESS, JobStatus.RESOURCE_IN_PROGRESS, JobType.WatchingBaseModule);
- singleServicesAndAssertStatus(JobStatus.IN_PROGRESS, uuid);
- pullJobProcessAndPushBack(JobStatus.IN_PROGRESS, JobStatus.IN_PROGRESS, true);
- singleServicesAndAssertStatus(JobStatus.IN_PROGRESS, uuid);
-
/*---------- vf Module without volume group name (base) -----------*/
- //vg name not exist, so vf module created immediately
- pullJobProcessAndPushBackWithTypeAssertion(JobStatus.CREATING, JobStatus.RESOURCE_IN_PROGRESS, JobType.Watching);
+ //mock mso to answer 200 of create vfModule instance request, pull+execute volumeGroup job, STATUS resource in progress
+ when(restMso.restCall(eq(HttpMethod.POST), eq(RequestReferencesContainer.class), any(), endsWith(SERVICE_INSTANCE_ID + "/vnfs/" + VNF_INSTANCE_ID + "/vfModules"), any())).thenReturn(
+ createResponse(200, UUID.randomUUID().toString(), VG_REQUEST_ID));
+ //mock mso to answer for vf module orchestration request
+ when(restMso.GetForObject(endsWith(VF_MODULE_REQUEST_ID), eq(AsyncRequestStatus.class))).thenReturn(
+ asyncRequestStatusResponseAsRestObject(COMPLETE_STR));
+
+ when(restMso.restCall(eq(HttpMethod.POST), eq(RequestReferencesContainer.class), any(), endsWith(SERVICE_INSTANCE_ID + "/vnfs/" + VNF_INSTANCE_ID + "/volumeGroups"), any())).thenReturn(
+ createResponse(200, VG_INSTANCE_ID, VG_REQUEST_ID));
+ //mock mso to answer for volume group orchestration request
+ when(restMso.GetForObject(endsWith(VG_REQUEST_ID), eq(AsyncRequestStatus.class))).thenReturn(
+ asyncRequestStatusResponseAsRestObject(msoVnfStatus));
- //verify vnf/volumeGroup job STATUS still watching with resource in progress
- pullMultipleJobsFindExpectedProcessAndPushBack(JobStatus.RESOURCE_IN_PROGRESS, JobType.Watching, JobStatus.RESOURCE_IN_PROGRESS, JobType.Watching);
+ /*---------- vfModule -----------*/
//mock mso to answer 200 of create vfModule instance request, pull+execute volumeGroup job, STATUS resource in progress
- reset(restMso);
- when(restMso.PostForObject(any(), endsWith(SERVICE_INSTANCE_ID + "/vnfs/" + VNF_INSTANCE_ID + "/vfModules"), eq(RequestReferencesContainer.class))).thenReturn(
- createResponse(200, UUID.randomUUID().toString(), VF_MODULE_REQUEST_ID));
- pullJobProcessAndPushBackWithTypeAssertion(JobStatus.CREATING, JobStatus.RESOURCE_IN_PROGRESS, JobType.ResourceInProgressStatus);
+ when(restMso.restCall(eq(HttpMethod.POST), eq(RequestReferencesContainer.class), any(), endsWith(SERVICE_INSTANCE_ID + "/vnfs/" + VNF_INSTANCE_ID + "/vfModules"), any())).thenReturn(
+ createResponse(200, UUID.randomUUID().toString(), VF_MODULE_REQUEST_ID2));
//mock mso to answer for vf module orchestration request
- reset(restMso);
- when(restMso.GetForObject(endsWith(VF_MODULE_REQUEST_ID), eq(AsyncRequestStatus.class))).thenReturn(
- asyncRequestStatusResponseAsRestObject(COMPLETE_STR));
- pullMultipleJobsFindExpectedProcessAndPushBack(JobStatus.RESOURCE_IN_PROGRESS, JobType.ResourceInProgressStatus, JobStatus.COMPLETED, JobType.ResourceInProgressStatus);
-
- //verify volume group become completed
- pullMultipleJobsFindExpectedProcessAndPushBack(JobStatus.RESOURCE_IN_PROGRESS, JobType.Watching, JobStatus.COMPLETED, JobType.Watching);
+ when(restMso.GetForObject(endsWith(VF_MODULE_REQUEST_ID2), eq(AsyncRequestStatus.class))).thenReturn(
+ asyncRequestStatusResponseAsRestObject(COMPLETE_STR));
+
+ processJobsCountTimesAndAssertStatus(uuid, 200, COMPLETED);
+ verify(restMso, times(1)).restCall(eq(HttpMethod.POST), any(), any(), eq("/serviceInstantiation/v7/serviceInstances"), any());
+ verify(restMso, times(1)).restCall(eq(HttpMethod.POST), any(), any(), endsWith(SERVICE_INSTANCE_ID + "/vnfs"), any());
+ verify(restMso, times(1)).restCall(eq(HttpMethod.POST), any(), any(), endsWith(SERVICE_INSTANCE_ID + "/vnfs/" + VNF_INSTANCE_ID + "/volumeGroups"), any());
+ verify(restMso, times(2)).restCall(eq(HttpMethod.POST), any(), any(), endsWith(SERVICE_INSTANCE_ID + "/vnfs/" + VNF_INSTANCE_ID + "/vfModules"), any());
+ verify(restMso, times(5)).GetForObject(any(), any());
+ }
- //vnf become watching after volume group completed, and new volume group created
- pullMultipleJobsFindExpectedProcessAndPushBack(JobStatus.RESOURCE_IN_PROGRESS, JobType.WatchingBaseModule, JobStatus.RESOURCE_IN_PROGRESS, JobType.Watching);
+ @Test
+ public void testALaCarteLifeCycle2Networks() {
- /*---------- volume group & vf module (non base) -----------*/
+ //Create Service with 2 networks, and make sure they created in sequence (and not in parallel)
+ //Config MSO to response 200 only to first network creation. And answer 500 for second one.
+ //Then MSO return in_progress some times (like 10 times), and then return COMPLETE.
+ //Only when MSO return COMPLETE for first network, config MSO to return 200 for second network creation
- /*---------- volume group -----------*/
+ final String SERVICE_REQUEST_ID = UUID.randomUUID().toString();
+ final String SERVICE_INSTANCE_ID = UUID.randomUUID().toString();
+ final String NETWORK_REQUEST_ID1 = UUID.randomUUID().toString();
+ final String NETWORK_INSTANCE_ID1 = UUID.randomUUID().toString();
+ //TODO use them later for different networks
+ final String NETWORK_REQUEST_ID2 = UUID.randomUUID().toString();
+ final String NETWORK_INSTANCE_ID2 = UUID.randomUUID().toString();
- //mock mso to answer 200 of create volumeGroup instance request, pull+execute volumeGroup job, STATUS resource in progress
- reset(restMso);
- when(restMso.PostForObject(any(), endsWith(SERVICE_INSTANCE_ID + "/vnfs/" + VNF_INSTANCE_ID + "/volumeGroups"), eq(RequestReferencesContainer.class))).thenReturn(
- createResponse(200, VG_INSTANCE_ID, VG_REQUEST_ID));
- pullJobProcessAndPushBackWithTypeAssertion(JobStatus.CREATING, JobStatus.RESOURCE_IN_PROGRESS, JobType.VolumeGroupInProgressStatus);
- //verify vnf job STATUS still watching with resource in progress
- pullMultipleJobsFindExpectedProcessAndPushBack(JobStatus.RESOURCE_IN_PROGRESS, JobType.Watching, JobStatus.RESOURCE_IN_PROGRESS, JobType.Watching);
+ NetworkDetails networkDetails1 = new NetworkDetails("LukaDoncic", "1");
+ NetworkDetails networkDetails2 = new NetworkDetails("KevinDurant", "2");
- //mock mso to answer for volume group orchestration request
reset(restMso);
- when(restMso.GetForObject(endsWith(VG_REQUEST_ID), eq(AsyncRequestStatus.class))).thenReturn(
- asyncRequestStatusResponseAsRestObject(msoVnfStatus));
- pullMultipleJobsFindExpectedProcessAndPushBack(JobStatus.RESOURCE_IN_PROGRESS, JobType.VolumeGroupInProgressStatus, JobStatus.RESOURCE_IN_PROGRESS, JobType.Watching);
- /*---------- vfModule -----------*/
+ /*---------- service -----------*/
- //mock mso to answer 200 of create vfModule instance request, pull+execute volumeGroup job, STATUS resource in progress
- reset(restMso);
- when(restMso.PostForObject(any(), endsWith(SERVICE_INSTANCE_ID + "/vnfs/" + VNF_INSTANCE_ID + "/vfModules"), eq(RequestReferencesContainer.class))).thenReturn(
- createResponse(200, UUID.randomUUID().toString(), VF_MODULE_REQUEST_ID2));
- pullJobProcessAndPushBackWithTypeAssertion(JobStatus.CREATING, JobStatus.RESOURCE_IN_PROGRESS, JobType.ResourceInProgressStatus);
+ //mock mso to answer 200 of create service instance request, verify STATUS in progress
+ when(restMso.restCall(eq(HttpMethod.POST), eq(RequestReferencesContainer.class), any(), endsWith("serviceInstances"), any())).thenReturn(
+ createResponse(200, SERVICE_INSTANCE_ID, SERVICE_REQUEST_ID));
- //mock mso to answer for vf module orchestration request
- reset(restMso);
- when(restMso.GetForObject(endsWith(VF_MODULE_REQUEST_ID2), eq(AsyncRequestStatus.class))).thenReturn(
- asyncRequestStatusResponseAsRestObject(COMPLETE_STR));
- pullMultipleJobsFindExpectedProcessAndPushBack(JobStatus.RESOURCE_IN_PROGRESS, JobType.ResourceInProgressStatus, JobStatus.COMPLETED, JobType.ResourceInProgressStatus);
+ //mock mso to answer COMPLETE for service instance create
+ when(restMso.GetForObject(endsWith(SERVICE_REQUEST_ID), eq(AsyncRequestStatus.class))).
+ thenReturn(asyncRequestStatusResponseAsRestObject(COMPLETE_STR));
+
+ final MutableInt secondNetworkCode = new MutableInt(500);
+ final MutableInt inProgressCount = new MutableInt(0);
+
+ /*---------- network 1-----------*/
+
+ //mock mso to answer 200 of first create network instance request
+ when(restMso.restCall(eq(HttpMethod.POST), eq(RequestReferencesContainer.class),
+ MockitoHamcrest.argThat(jsonPartMatches("requestDetails.requestInfo.instanceName", equalTo(networkDetails1.name))) ,
+ endsWith(SERVICE_INSTANCE_ID + "/networks"), any())).thenReturn(
+ createResponse(200, NETWORK_INSTANCE_ID1, NETWORK_REQUEST_ID1));
+
+ //mock mso to answer IN_PROGRESS 10 times, and only then COMPLETE for first network
+ //Once COMPLETE, second network creation will return 200
+ when(restMso.GetForObject(endsWith(NETWORK_REQUEST_ID1), eq(AsyncRequestStatus.class))).
+ thenAnswer(x->{
+ String status;
+ if (inProgressCount.getValue()<10) {
+ status = IN_PROGRESS_STR;
+ } else {
+ secondNetworkCode.setValue(200);
+ status = COMPLETE_STR;
+ }
+ inProgressCount.add(1);
+ return asyncRequestStatusResponseAsRestObject(status);
+ });
+
+ /*---------- network 2-----------*/
+
+ //mock MSO to return status code of secondNetworkCode (500 and 200 after first one COMPLETED)
+ when(restMso.restCall(eq(HttpMethod.POST), eq(RequestReferencesContainer.class),
+ MockitoHamcrest.argThat(jsonPartMatches("requestDetails.requestInfo.instanceName", equalTo(networkDetails2.name))) ,
+ endsWith(SERVICE_INSTANCE_ID + "/networks"), any())).thenAnswer(x->
+ createResponse(secondNetworkCode.intValue(), NETWORK_INSTANCE_ID2, NETWORK_REQUEST_ID2));
+
+// when(restMso.restCall(eq(HttpMethod.POST), eq(RequestReferencesContainer.class), any() , endsWith(SERVICE_INSTANCE_ID + "/networks"), any())).thenReturn(
+// createResponse(200, NETWORK_INSTANCE_ID1, NETWORK_REQUEST_ID1));
+ //mock mso to answer COMPLETE for network creation status,
+
+ when(restMso.GetForObject(endsWith(NETWORK_REQUEST_ID2), eq(AsyncRequestStatus.class))).
+ thenReturn(asyncRequestStatusResponseAsRestObject(COMPLETE_STR));
+
+
+ /*---------- Create request and process it -----------*/
+ //push alacarte with 2 networks, verify STATUS pending
+ when(featureManager.isActive(Features.FLAG_EXP_CREATE_RESOURCES_IN_PARALLEL)).thenReturn(false);
+ ServiceInstantiation serviceInstantiation = generateALaCarteWithNetworksPayload(ImmutableList.of(networkDetails1, networkDetails2));
+ UUID uuid = asyncInstantiationBL.pushBulkJob(serviceInstantiation, USER_ID).get(0);
+ singleServicesAndAssertStatus(JobStatus.PENDING, uuid);
- //execute twice - 1 for parent volume group, 1 for parent vnf
- pullAllJobProcessAndPushBackByType(JobStatus.RESOURCE_IN_PROGRESS, JobType.Watching , JobStatus.COMPLETED);
+ processJobsCountTimesAndAssertStatus(uuid, 200, COMPLETED);
- singleServicesAndAssertStatus(JobStatus.IN_PROGRESS, uuid);
- pullJobProcessAndPushBack(JobStatus.IN_PROGRESS, JobStatus.COMPLETED, true);
- singleServicesAndAssertStatus(JobStatus.COMPLETED, uuid);
+ //validate the mso request id is the right one
+ List<ServiceInfo> serviceInfoList = asyncInstantiationBL.getAllServicesInfo();
+ ServiceInfo serviceInfo = serviceInfoList.get(0);
+ assertThat(serviceInfo.getMsoRequestId(), is(UUID.fromString(SERVICE_REQUEST_ID)));
+
+ /*---------- verify -----------*/
+ verify(restMso, times(1)).restCall(eq(HttpMethod.POST), any(), any(), eq("/serviceInstantiation/v7/serviceInstances"), any());
+ verify(restMso, times(2)).restCall(eq(HttpMethod.POST), any(), any(), endsWith(SERVICE_INSTANCE_ID + "/networks"), any());
+ //get status
+ verify(restMso, times(1)).GetForObject(endsWith(SERVICE_REQUEST_ID), any());
+ verify(restMso, times(11)).GetForObject(endsWith(NETWORK_REQUEST_ID1), any());
+ verify(restMso, times(1)).GetForObject(endsWith(NETWORK_REQUEST_ID2), any());
}
- //@Test
+ @Test
public void testBadAaiResponseForSearchNamesAndBackToNormal() {
when(aaiClient.isNodeTypeExistsByName(any(), any())).thenThrow(aaiNodeQueryBadResponseException());
- pushMacroBulk(); //JOB shall become IN_PROGRESS but service info is still pending
- Job job = pullJobProcessAndPushBack(PENDING, JobStatus.IN_PROGRESS, true);
- listServicesAndAssertStatus(PENDING, PENDING, job);
+ when(restMso.restCall(eq(HttpMethod.POST), eq(RequestReferencesContainer.class), any(), any(), eq(Optional.empty()))).thenReturn(createResponse(200));
+ when(restMso.GetForObject(any(), eq(AsyncRequestStatus.class))).
+ thenReturn(asyncRequestStatusResponseAsRestObject(COMPLETE_STR));
- //JOB shall remain in IN_PROGRESS
- job = pullJobProcessAndPushBack( JobStatus.IN_PROGRESS, JobStatus.IN_PROGRESS, true);
- //make sure the job command is still ServiceInstantiation
- assertThat(job.getType(), is(JobType.MacroServiceInstantiation));
- listServicesAndAssertStatus(PENDING, PENDING, job);
+ List<UUID> uuids = pushMacroBulk();
+ processJobsCountTimesAndAssertStatus(uuids.get(0), 5, IN_PROGRESS, PENDING); //JOB shall become IN_PROGRESS but service info is still pending
//simulate AAI back to normal, AAI return name is free, and MSO return good response
Mockito.reset(aaiClient); // must forget the "thenThrow"
when(aaiClient.isNodeTypeExistsByName(any(), any())).thenReturn(false);
- when(restMso.PostForObject(any(),any(), eq(RequestReferencesContainer.class))).thenReturn(createResponse(200));
- job = pullJobProcessAndPushBack( JobStatus.IN_PROGRESS, JobStatus.IN_PROGRESS, true);
- listServicesAndAssertStatus(JobStatus.IN_PROGRESS, PENDING, job);
+ processJobsCountTimesAndAssertStatus(uuids.get(0), 30, COMPLETED, COMPLETED);
- //when get job COMPLETE from MSO, service status become COMPLETED
- when(restMso.GetForObject(any(), eq(AsyncRequestStatus.class))).
- thenReturn(asyncRequestStatusResponseAsRestObject(COMPLETE_STR));
- job = pullJobProcessAndPushBack(JobStatus.IN_PROGRESS, COMPLETED);
- listServicesAndAssertStatus(COMPLETED, PENDING, job);
}
- //@Test
+ @Test
public void testAaiResponseNameUsedTillMaxRetries() {
when(aaiClient.isNodeTypeExistsByName(any(), any())).thenReturn(true);
+ //simulate MSO to return good result, for making sure we failed because of AAI error
+ when(restMso.restCall(eq(HttpMethod.POST), eq(RequestReferencesContainer.class), any(), any(), eq(Optional.empty()))).thenReturn(createResponse(200));
+ when(restMso.GetForObject(any(), eq(AsyncRequestStatus.class))).
+ thenReturn(asyncRequestStatusResponseAsRestObject(COMPLETE_STR));
+
asyncInstantiationBL.setMaxRetriesGettingFreeNameFromAai(10);
- pushMacroBulk();
- //JOB shall become IN_PROGRESS but service info is still pending
- Job job = pullJobProcessAndPushBack(PENDING, JobStatus.FAILED, true);
- listServicesAndAssertStatus(JobStatus.FAILED, JobStatus.STOPPED, job);
+ List<UUID> uuids = pushMacroBulk();
+ processJobsCountTimesAndAssertStatus(uuids.get(0), 20, FAILED, STOPPED);
}
private Job pullJobProcessAndPushBack(JobStatus topic, JobStatus expectedNextJobStatus) {
@@ -559,22 +610,23 @@ public class AsyncInstantiationIntegrationTest extends AsyncInstantiationBaseTes
return job.get();
}
+ private void simplePullJobProcessAndPushBack(JobStatus topic) {
+ Optional<Job> optionalJob = jobsBrokerService.pull(topic, randomUuid());
+ optionalJob.ifPresent(job->{
+ Job nextJob = jobWorker.executeJobAndGetNext(job);
+ jobsBrokerService.pushBack(nextJob);
+ });
+ }
+
private Job pullJobProcessAndPushBackWithTypeAssertion(JobStatus topic, JobStatus expectedNextJobStatus,
- JobType expectedNextJobType) {
+ JobType expectedNextJobType) {
Job job = pullJobProcessAndPushBack(topic, expectedNextJobStatus, false);
assertThat("job not ok: " + job.getData(), job.getType(), is(expectedNextJobType));
return job;
}
private Job pullJobProcessAndPushBackWithTypeAssertion(JobStatus topic, JobStatus expectedNextJobStatus,
- JobType expectedNextJobType, int retries) {
- return retryWithAssertionsLimit(retries, () -> {
- return pullJobProcessAndPushBackWithTypeAssertion(topic, expectedNextJobStatus, expectedNextJobType);
- });
- }
-
- private Job pullJobProcessAndPushBackWithTypeAssertion(JobStatus topic, JobStatus expectedNextJobStatus,
- JobType expectedNextJobType, Action actionPhase, InternalState internalState, int retries) {
+ JobType expectedNextJobType, Action actionPhase, InternalState internalState, int retries) {
return retryWithAssertionsLimit(retries, () -> {
Job job = pullJobProcessAndPushBackWithTypeAssertion(topic, expectedNextJobStatus, expectedNextJobType);
assertThat("job not ok: " + job.getData(), job.getData(), is(jsonPartEquals("actionPhase", actionPhase.name())));
@@ -598,49 +650,11 @@ public class AsyncInstantiationIntegrationTest extends AsyncInstantiationBaseTes
// No success:
throw new AssertionError("No luck while all of these assertion errors: " + history.stream()
- .map(Throwable::getMessage)
- .map(s -> s.replace('\n', ' '))
- .map(s -> s.replaceAll("\\s{2,}"," "))
- .distinct()
- .collect(joining("\n ", "\n ", "")), history.peek());
- }
-
- private Job pullMultipleJobsFindExpectedProcessAndPushBack(JobStatus topic, JobType expectedCurrentJobType, JobStatus expectedNextJobStatus,
- JobType expectedNextJobType) {
- List<Job> pulledJobs = new ArrayList<>();
- Job lastJob = null;
- while (lastJob == null || lastJob.getType() != expectedCurrentJobType) {
- lastJob = pullJob(topic, false).get();
- if (lastJob.getType() != expectedCurrentJobType) {
- pulledJobs.add(lastJob);
- }
- }
-
- Job nextJob = jobWorker.executeJobAndGetNext(lastJob);
- assertThat(nextJob.getStatus(), is(expectedNextJobStatus));
- assertThat(nextJob.getType(), is(expectedNextJobType));
-
- jobsBrokerService.pushBack(nextJob);
- assertThat(jobsBrokerService.peek(nextJob.getUuid()).getStatus(), is(expectedNextJobStatus));
-
- pulledJobs.forEach(job ->
- jobsBrokerService.pushBack(job)
- );
-
- return nextJob;
- }
-
- private void pullAllJobProcessAndPushBackByType(JobStatus topic, JobType commandType, JobStatus expectedFinalStatus) {
- Map<UUID, JobStatus> jobStatusMap = new HashMap<>();
- Optional<Job> job = pullJob(topic, false);
- for (int i=0; i<1000 && job.isPresent() && job.get().getType() == commandType; i++) {
- Job nextJob = jobWorker.executeJobAndGetNext(job.get());
- jobStatusMap.put(nextJob.getUuid(), nextJob.getStatus());
- jobsBrokerService.pushBack(nextJob);
- job = jobsBrokerService.pull(topic, UUID.randomUUID().toString());
- }
- assertThat(jobStatusMap.values(), everyItem(is(expectedFinalStatus)));
-
+ .map(Throwable::getMessage)
+ .map(s -> s.replace('\n', ' '))
+ .map(s -> s.replaceAll("\\s{2,}"," "))
+ .distinct()
+ .collect(joining("\n ", "\n ", "")), history.peek());
}
private Optional<Job> pullJob(JobStatus topic, boolean pullingAssertion) {
@@ -665,49 +679,37 @@ public class AsyncInstantiationIntegrationTest extends AsyncInstantiationBaseTes
}
- //@Test
+ @Test
public void whenPushNewBulk_andGetNoResponseFromMsoOnCreation_thenServiceMoveToFailedAndOtherToStopped() {
- when(restMso.PostForObject(any(), any(), eq(RequestReferencesContainer.class))).thenReturn(createResponse(500));
- pushBulkPullPendingJobAndAssertJobStatus(JobStatus.FAILED, JobStatus.STOPPED);
+ when(restMso.restCall(eq(HttpMethod.POST), eq(RequestReferencesContainer.class), any(), any(), eq(Optional.empty()))).thenReturn(createResponse(500));
+ //assert that when get ProcessingException from restMso, status remain the same
+ List<UUID> uuids = pushMacroBulk();
+ processJobsCountTimesAndAssertStatus(uuids.get(0), 30, JobStatus.FAILED, JobStatus.STOPPED);
}
- //@Test
+ @Test
public void whenMsoStatusIsPendingManualTask_ThenJobStatusIsPaused() {
- when(restMso.PostForObject(any(), any(), eq(RequestReferencesContainer.class))).thenReturn(createResponse(200));
-
- Job firstJob = pushBulkPullPendingJobAndAssertJobStatus(JobStatus.IN_PROGRESS, PENDING);
+ when(restMso.restCall(eq(HttpMethod.POST), eq(RequestReferencesContainer.class), any(), any(), eq(Optional.empty()))).thenReturn(createResponse(200));
+ when(restMso.GetForObject(any(), eq(AsyncRequestStatus.class))).
+ thenReturn(asyncRequestStatusResponseAsRestObject(PENDING_MANUAL_TASK));
//assert that when get ProcessingException from restMso, status remain the same
- when(restMso.GetForObject(any(), eq(AsyncRequestStatus.class))).
- thenReturn(asyncRequestStatusResponseAsRestObject(PENDING_MANUAL_TASK));
- Job job = pullJobProcessAndPushBack(JobStatus.IN_PROGRESS, JobStatus.IN_PROGRESS);
- listServicesAndAssertStatus(PAUSE, PENDING, job);
+ List<UUID> uuids = pushMacroBulk();
+ processJobsCountTimesAndAssertStatus(uuids.get(0), 30, PAUSE, PENDING);
- //The paused job is pulled and remain in pause state. Other jobs from bulk remain pending
- job = pullJobProcessAndPushBack(JobStatus.IN_PROGRESS, JobStatus.IN_PROGRESS);
- listServicesAndAssertStatus(PAUSE, PENDING, job);
//the job get IN_PROGRESS response (simulate activate operation) and status changed to IN_PROGRESS
when(restMso.GetForObject(any(), eq(AsyncRequestStatus.class))).
- thenReturn(asyncRequestStatusResponseAsRestObject(IN_PROGRESS_STR));
- job = pullJobProcessAndPushBack(JobStatus.IN_PROGRESS, JobStatus.IN_PROGRESS);
- listServicesAndAssertStatus(JobStatus.IN_PROGRESS, PENDING, job);
+ thenReturn(asyncRequestStatusResponseAsRestObject(IN_PROGRESS_STR));
+ processJobsCountTimesAndAssertStatus(uuids.get(0), 30, IN_PROGRESS, PENDING);
+ //the job get COMPLETE response this job is copmpleted and then also other jobs
when(restMso.GetForObject(any(), eq(AsyncRequestStatus.class))).
- thenReturn(asyncRequestStatusResponseAsRestObject(COMPLETE_STR));
- job = pullJobProcessAndPushBack(JobStatus.IN_PROGRESS, COMPLETED);
- listServicesAndAssertStatus(COMPLETED, PENDING, job);
-
- //Pulling PENDING job return another job
- assertThat(jobsBrokerService.pull(PENDING, randomUuid()).get().getUuid(), not(equalTo(job.getUuid())));
-
-
- ImmutableList<String> expectedStatusesForMso = ImmutableList.of(REQUESTED, PENDING_MANUAL_TASK, IN_PROGRESS_STR, COMPLETE_STR);
- List<String> msoStatuses = asyncInstantiationBL.getAuditStatuses(firstJob.getUuid(), MSO).stream().map(x -> x.getJobStatus()).collect(Collectors.toList());
- assertThat(msoStatuses, is(expectedStatusesForMso));
+ thenReturn(asyncRequestStatusResponseAsRestObject(COMPLETE_STR));
+ processJobsCountTimesAndAssertStatus(uuids.get(0), 200, COMPLETED, COMPLETED);
ImmutableList<String> expectedStatusesForVid = statusesToStrings(PENDING, IN_PROGRESS, PAUSE, IN_PROGRESS, COMPLETED);
- List<String> vidStatuses = asyncInstantiationBL.getAuditStatuses(firstJob.getUuid(), VID).stream().map(x -> x.getJobStatus()).collect(Collectors.toList());
+ List<String> vidStatuses = auditService.getAuditStatuses(uuids.get(0), VID).stream().map(x -> x.getJobStatus()).collect(Collectors.toList());
assertThat(vidStatuses, is(expectedStatusesForVid));
}
@@ -718,65 +720,76 @@ public class AsyncInstantiationIntegrationTest extends AsyncInstantiationBaseTes
private Job pullPendingJobAndAssertJobStatus(JobStatus pulledJobStatus, JobStatus otherJobsStatus) {
Job job = pullJobProcessAndPushBack(PENDING, pulledJobStatus, false);
- listServicesAndAssertStatus(pulledJobStatus, otherJobsStatus, job);
+ listServicesAndAssertStatus(pulledJobStatus, otherJobsStatus, job.getUuid());
return job;
}
- //@Test
+ @Test
public void test2BulksLifeCyclesAreIndependent() {
- pushMacroBulk();
- when(restMso.PostForObject(any(), any(), eq(RequestReferencesContainer.class))).thenReturn(createResponse(200));
- //push 2nd job, then when pulling first job the job become in_progress, other jobs (from 2 bulks) remain pending
- Job firstJob = pushBulkPullPendingJobAndAssertJobStatus(JobStatus.IN_PROGRESS, PENDING);
- //assert we can pull another job from pending from other template id
- Job secondJob = pullJobProcessAndPushBack(PENDING, JobStatus.IN_PROGRESS, false);
- assertThat(firstJob.getTemplateId(), not(equalTo(secondJob.getTemplateId())));
-
- //assert no more PENDING jobs to pull
- assertFalse(jobsBrokerService.pull(PENDING, randomUuid()).isPresent());
-
- //when get FAILED status from MSO statuses for failed bulk are: FAILED, STOPPED, for other bulk: IN_PROGRESS, 2 pending
- when(restMso.GetForObject(any(), eq(AsyncRequestStatus.class))).
- thenReturn(asyncRequestStatusResponseAsRestObject(FAILED_STR));
- Job failedJob = pullJobProcessAndPushBack(JobStatus.IN_PROGRESS, JobStatus.FAILED, false);
+ final String SERVICE1_REQUEST_ID = UUID.randomUUID().toString();
+ final String SERVICE1_INSTANCE_ID = UUID.randomUUID().toString();
+ final String SERVICE2_REQUEST_ID = UUID.randomUUID().toString();
+ final String SERVICE2_INSTANCE_ID = UUID.randomUUID().toString();
+ final String SERVICE3_4_REQUEST_ID = UUID.randomUUID().toString();
+ final String SERVICE3_4_INSTANCE_ID = UUID.randomUUID().toString();
+
+
+ //create first bulk and make one job in progress
+ List<UUID> firstBulksIDs = pushMacroBulk();
+ when(restMso.restCall(eq(HttpMethod.POST), eq(RequestReferencesContainer.class), any(), any(), eq(Optional.empty())))
+ .thenReturn(createResponse(200, SERVICE1_INSTANCE_ID, SERVICE1_REQUEST_ID));
+ when(restMso.GetForObject(endsWith(SERVICE1_REQUEST_ID), eq(AsyncRequestStatus.class))).
+ thenReturn(asyncRequestStatusResponseAsRestObject(IN_PROGRESS_STR));
+ processJobsCountTimesAndAssertStatus(firstBulksIDs.get(0), 30, IN_PROGRESS, PENDING);
+
+ //create 2nd bulk, then when pulling first job the job become in_progress, other jobs (from 2 bulks) remain pending
+ when(restMso.restCall(eq(HttpMethod.POST), eq(RequestReferencesContainer.class), any(), any(), eq(Optional.empty())))
+ .thenReturn(createResponse(200, SERVICE2_INSTANCE_ID, SERVICE2_REQUEST_ID));
+ when(restMso.GetForObject(endsWith(SERVICE2_REQUEST_ID), eq(AsyncRequestStatus.class))).
+ thenReturn(asyncRequestStatusResponseAsRestObject(IN_PROGRESS_STR));
+ List<UUID> secondBulksIDs = pushMacroBulk();
+ processJobsCountTimes(30);
+ Map<JobStatus, Long> statusCount = getJobStatusesCount();
+ assertThat(statusCount.get(IN_PROGRESS), is(2L));
+ assertThat(statusCount.get(PENDING), is(4L));
+
+ //return failed to first job
+ //first bulk statuses shall be: FAILED, STOPPED, STOPPED
+ //second bulk statuses shall be: IN_PROGRESS, PENDING, PENDING
+ when(restMso.GetForObject(endsWith(SERVICE1_REQUEST_ID), eq(AsyncRequestStatus.class))).
+ thenReturn(asyncRequestStatusResponseAsRestObject(FAILED_STR));
+ processJobsCountTimes(30);
Map<UUID, List<ServiceInfo>> servicesByTemplateId =
- asyncInstantiationBL.getAllServicesInfo()
- .stream().collect(groupingBy(ServiceInfo::getTemplateId));
- assertServicesStatus(servicesByTemplateId.get(failedJob.getTemplateId()), JobStatus.FAILED, JobStatus.STOPPED, failedJob);
- Job successJob = failedJob.getUuid().equals(firstJob.getUuid()) ? secondJob : firstJob;
- assertServicesStatus(servicesByTemplateId.get(successJob.getTemplateId()), JobStatus.IN_PROGRESS, PENDING, successJob);
-
- //yet no more PENDING jobs to pull
- assertFalse(jobsBrokerService.pull(PENDING, randomUuid()).isPresent());
-
- //assert that job from non failed bulk can progress.
- //When completed, failed bulk statuses: FAILED, STOPPED. Succeeded bulk statuses are : COMPLETED, 2 pending
- when(restMso.GetForObject(any(), eq(AsyncRequestStatus.class))).
- thenReturn(asyncRequestStatusResponseAsRestObject(COMPLETE_STR));
- pullJobProcessAndPushBack(JobStatus.IN_PROGRESS, COMPLETED, false);
- servicesByTemplateId =
- asyncInstantiationBL.getAllServicesInfo()
- .stream().collect(groupingBy(ServiceInfo::getTemplateId));
- assertServicesStatus(servicesByTemplateId.get(failedJob.getTemplateId()), JobStatus.FAILED, JobStatus.STOPPED, failedJob);
- assertServicesStatus(servicesByTemplateId.get(successJob.getTemplateId()), COMPLETED, PENDING, successJob);
-
- //advance other jobs of succeeded bulk till al of them reach to COMPLETED
- pullJobProcessAndPushBack(PENDING, JobStatus.IN_PROGRESS, false);
- pullJobProcessAndPushBack(JobStatus.IN_PROGRESS, COMPLETED, false);
- pullJobProcessAndPushBack(PENDING, JobStatus.IN_PROGRESS, false);
- pullJobProcessAndPushBack(JobStatus.IN_PROGRESS, COMPLETED, false);
- servicesByTemplateId =
- asyncInstantiationBL.getAllServicesInfo()
- .stream().collect(groupingBy(ServiceInfo::getTemplateId));
- assertServicesStatus(servicesByTemplateId.get(failedJob.getTemplateId()), JobStatus.FAILED, JobStatus.STOPPED, failedJob);
- assertServicesStatus(servicesByTemplateId.get(successJob.getTemplateId()), COMPLETED, COMPLETED, successJob);
-
+ asyncInstantiationBL.getAllServicesInfo()
+ .stream().collect(groupingBy(ServiceInfo::getTemplateId));
+ ServiceInfo failedJob = asyncInstantiationBL.getAllServicesInfo().stream().filter(x->x.getJobId().equals(firstBulksIDs.get(0))).findFirst().get();
+ assertServicesStatus(servicesByTemplateId.get(failedJob.getTemplateId()), JobStatus.FAILED, JobStatus.STOPPED, failedJob.getJobId());
+ ServiceInfo successJob = asyncInstantiationBL.getAllServicesInfo().stream().filter(x->x.getJobId().equals(secondBulksIDs.get(0))).findFirst().get();
+ assertServicesStatus(servicesByTemplateId.get(successJob.getTemplateId()), JobStatus.IN_PROGRESS, PENDING, successJob.getJobId());
+
+ //return completed to all other jobs
+ when(restMso.restCall(eq(HttpMethod.POST), eq(RequestReferencesContainer.class), any(), any(), eq(Optional.empty())))
+ .thenReturn(createResponse(200, SERVICE3_4_INSTANCE_ID, SERVICE3_4_REQUEST_ID));
+ when(restMso.GetForObject(endsWith(SERVICE2_REQUEST_ID), eq(AsyncRequestStatus.class))).
+ thenReturn(asyncRequestStatusResponseAsRestObject(COMPLETE_STR));
+ when(restMso.GetForObject(endsWith(SERVICE3_4_REQUEST_ID), eq(AsyncRequestStatus.class))).
+ thenReturn(asyncRequestStatusResponseAsRestObject(COMPLETE_STR));
+
+ processJobsCountTimes(30);
+ servicesByTemplateId = asyncInstantiationBL.getAllServicesInfo().stream().collect(groupingBy(ServiceInfo::getTemplateId));
+ assertServicesStatus(servicesByTemplateId.get(failedJob.getTemplateId()), JobStatus.FAILED, JobStatus.STOPPED, failedJob.getJobId());
+ assertServicesStatus(servicesByTemplateId.get(successJob.getTemplateId()), COMPLETED, COMPLETED, successJob.getJobId());
//assert no more PENDING jobs nor IN_PROGRESS jobs to pull
assertFalse(jobsBrokerService.pull(PENDING, randomUuid()).isPresent());
assertFalse(jobsBrokerService.pull(JobStatus.IN_PROGRESS, randomUuid()).isPresent());
}
+ protected Map<JobStatus, Long> getJobStatusesCount() {
+ return asyncInstantiationBL.getAllServicesInfo().stream().collect(groupingBy(ServiceInfo::getJobStatus, counting()));
+ }
+
+ @Test
public void deploy2NewGroupsToServiceWith1ExistingGroup() {
/*
@@ -795,18 +808,7 @@ public class AsyncInstantiationIntegrationTest extends AsyncInstantiationBaseTes
[v] + pull+execute (should NOT post to MSO)
[v] verify STATUS in progress; TYPE watching
...
- [v] verify job#2 *new* GROUP job STATUS completed with no action TYPE group INTERNAL STATE terminal PHASE delete
- [v] verify job#3 *new* GROUP job STATUS completed with no action TYPE group INTERNAL STATE terminal PHASE delete
- [v] verify job#4 *new* GROUP job STATUS completed with no action TYPE group INTERNAL STATE terminal PHASE delete
- [v] + pull+execute job#1 (should NOT post to MSO)
- [v] verify STATUS in progress; TYPE watching
- [v] verify job#5 *new* GROUP job STATUS creating TYPE group INTERNAL STATE initial PHASE create
- [v] verify job#6 *new* GROUP job STATUS creating TYPE group INTERNAL STATE initial PHASE create
- [v] verify job#7 *new* GROUP job STATUS creating TYPE group INTERNAL STATE initial PHASE create
-
- [v] + pull+execute job#5 (should NOT post to MSO)
- [v] verify job#5 STATUS completed with no action TYPE group INTERNAL STATE terminal PHASE create
[v] + pull+execute job#1
[v] verify job#1 STATUS in progress; TYPE watching
@@ -845,70 +847,265 @@ public class AsyncInstantiationIntegrationTest extends AsyncInstantiationBaseTes
singleServicesAndAssertStatus(PENDING, uuid);
// take from pending, put in-progress -> 3 delete-child were born
- pullJobProcessAndPushBackWithTypeAssertion(PENDING, IN_PROGRESS, JobType.ALaCarteService, Action.Delete, InternalState.WATCHING, 1);
- verifyQueueSizes(ImmutableMap.of(
- IN_PROGRESS, 1, CREATING, 3
- ));
-
- Stream.of(1, 2, 3).forEach(i -> {
- // take each child creating, put in-progress
- verify_Job1InProgress.accept(Action.Delete, IN_PROGRESS);
- pullJobProcessAndPushBackWithTypeAssertion(CREATING, RESOURCE_IN_PROGRESS, JobType.InstanceGroup, Action.Delete, null, 1);
-
- // execute each in-progress -> job is completed
- verify_Job1InProgress.accept(Action.Delete, IN_PROGRESS);
- pullJobProcessAndPushBackWithTypeAssertion(RESOURCE_IN_PROGRESS, COMPLETED/*_WITH_NO_ACTION*/, JobType.InstanceGroup,1);
- });
+ pullJobProcessAndPushBackWithTypeAssertion(PENDING, IN_PROGRESS, JobType.ALaCarteService, Action.Create, InternalState.INITIAL, 1);
verifyQueueSizes(ImmutableMap.of(
- IN_PROGRESS, 1, COMPLETED, 3
+ IN_PROGRESS, 1
));
// take job #1 from phase delete to phase create -> 3 create-child were born
verify_Job1InProgress.accept(Action.Create, IN_PROGRESS);
verifyQueueSizes(ImmutableMap.of(
- IN_PROGRESS, 1, CREATING, 3, COMPLETED, 3
+ IN_PROGRESS, 1, PENDING_RESOURCE, 3
));
// prepare MSO mock
- when(restMso.PostForObject(any(), endsWith("instanceGroups"), eq(RequestReferencesContainer.class)))
- .thenReturn(createResponse(200, GROUP1_INSTANCE_ID, GROUP1_REQUEST_ID))
- .thenReturn(createResponse(200, GROUP2_INSTANCE_ID, GROUP2_REQUEST_ID))
- .thenReturn(null);
+ when(restMso.restCall(eq(HttpMethod.POST), eq(RequestReferencesContainer.class), any(), endsWith("instanceGroups"), eq(Optional.empty())))
+ .thenReturn(createResponse(200, GROUP1_INSTANCE_ID, GROUP1_REQUEST_ID))
+ .thenReturn(createResponse(200, GROUP2_INSTANCE_ID, GROUP2_REQUEST_ID))
+ .thenReturn(null);
when(restMso.GetForObject(argThat(uri -> StringUtils.endsWithAny(uri, GROUP1_REQUEST_ID, GROUP2_REQUEST_ID)), eq(AsyncRequestStatus.class))).
- thenReturn(asyncRequestStatusResponseAsRestObject(COMPLETE_STR));
+ thenReturn(asyncRequestStatusResponseAsRestObject(COMPLETE_STR));
- // take first "none" child from creating to completed
+ // take first "none" child from creating to COMPLETED_WITH_NO_ACTION
// note there's no concrete mechanism that makes the first child be
- // the "action=None" case, but that's what happens, and following line
+ // the "action=None" case, but that's what happens, and following lines
// relies on that fact.
- pullJobProcessAndPushBackWithTypeAssertion(CREATING, COMPLETED_WITH_NO_ACTION, JobType.InstanceGroupInstantiation, 1);
+ pullJobProcessAndPushBackWithTypeAssertion(PENDING_RESOURCE, COMPLETED_WITH_NO_ACTION, JobType.InstanceGroup, Action.Create, null, 1);
// take each of next two children from creating to in-progress, then to completed
// verify job #1 is watching, and MSO is getting requests
Stream.of(1, 2).forEach(i -> {
verify_Job1InProgress.accept(Action.Create, IN_PROGRESS);
- pullJobProcessAndPushBackWithTypeAssertion(CREATING, RESOURCE_IN_PROGRESS, JobType.ResourceInProgressStatus);
- verify(restMso, times(i)).PostForObject(any(), any(), any());
+ pullJobProcessAndPushBackWithTypeAssertion(PENDING_RESOURCE, RESOURCE_IN_PROGRESS, JobType.InstanceGroup, Action.Create, InternalState.IN_PROGRESS, 1);
+ verify(restMso, times(i)).restCall(any(), any(), any(), any(), any());
verify_Job1InProgress.accept(Action.Create, IN_PROGRESS);
- pullJobProcessAndPushBackWithTypeAssertion(RESOURCE_IN_PROGRESS, COMPLETED, JobType.ResourceInProgressStatus);
+ pullJobProcessAndPushBackWithTypeAssertion(RESOURCE_IN_PROGRESS, COMPLETED, JobType.InstanceGroup, Action.Create, null, 3);
verify(restMso, times(i)).GetForObject(any(), any());
});
// job #1 is done as all children are done
verify_Job1InProgress.accept(Action.Create, COMPLETED);
- verifyQueueSizes(ImmutableMap.of(COMPLETED, 7));
+ verifyQueueSizes(ImmutableMap.of(COMPLETED, 3, COMPLETED_WITH_NO_ACTION, 1));
+ }
+
+ @DataProvider
+ public static Object[][] createAndDeleteIntegrationTestDataProvider(Method test) {
+ return new Object[][]{
+ {"create and delete both bad http code", createResponse(400), createResponse(500), null, null, FAILED, 0},
+ {"create and delete success and status is success ", createResponseRandomIds(202), createResponseRandomIds(202),
+ asyncRequestStatusResponseAsRestObject(COMPLETE_STR), asyncRequestStatusResponseAsRestObject(COMPLETE_STR), COMPLETED, 2},
+ {"create and delete success, create status FAILED, delete status COMPLETED", createResponseRandomIds(202), createResponseRandomIds(202),
+ asyncRequestStatusResponseAsRestObject(FAILED_STR), asyncRequestStatusResponseAsRestObject(COMPLETE_STR), COMPLETED_WITH_ERRORS, 2},
+ {"create and delete success, create status FAILED, delete status FAILED", createResponseRandomIds(202), createResponseRandomIds(202),
+ asyncRequestStatusResponseAsRestObject(FAILED_STR), asyncRequestStatusResponseAsRestObject(FAILED_STR), FAILED, 2},
+ {"create success but delete failed and status is success ", createResponseRandomIds(202), createResponseRandomIds(400),
+ asyncRequestStatusResponseAsRestObject(COMPLETE_STR), null, COMPLETED_WITH_ERRORS, 1},
+ {"delete success but create failed and status is success ", createResponseRandomIds(400), createResponseRandomIds(202),
+ null, asyncRequestStatusResponseAsRestObject(COMPLETE_STR), COMPLETED_WITH_ERRORS, 1},
+ {"delete success but create failed and status of delete is FAILED ", createResponseRandomIds(400), createResponseRandomIds(202),
+ null, asyncRequestStatusResponseAsRestObject(FAILED_STR), FAILED, 1}
+ };
+ }
+
+ //this test is going along with AsyncInstantiationALaCarteApiTest.viewEditVnfGroup__verifyStatusAndAudit API test
+ //The API test has only the happy flow scenario, while this test also test additional MSO responses (mostly non happy)
+ @Test(dataProvider="createAndDeleteIntegrationTestDataProvider")
+ public void vnfGropingIntegrationTest(
+ String desc,
+ RestObject<RequestReferencesContainer> createGroupResponse,
+ RestObject<RequestReferencesContainer> deleteGroupResponse,
+ RestObject<AsyncRequestStatus> createStatusResponse,
+ RestObject<AsyncRequestStatus> deleteStatusResponse,
+ JobStatus expectedJobStatus,
+ int getStatusCounter) throws IOException {
+
+ UUID jobUUID = createAndDeleteIntegrationTest("/payload_jsons/VnfGroupCreate1Delete1None1Request.json",
+ "/serviceInstantiation/v7/instanceGroups",
+ createGroupResponse,
+ "/serviceInstantiation/v7/instanceGroups/VNF_GROUP1_INSTANCE_ID",
+ deleteGroupResponse,
+ createStatusResponse,
+ deleteStatusResponse,
+ expectedJobStatus,
+ getStatusCounter);
+
+ ServiceInstantiation bulkForRetry = asyncInstantiationBL.getBulkForRetry(jobUUID);
+ InstanceGroup vnfGroupShouldBeDeleted = bulkForRetry.getVnfGroups().get("groupingservicefortest..ResourceInstanceGroup..0:001");
+ InstanceGroup vnfGroupShouldBeCreated = bulkForRetry.getVnfGroups().get("groupingservicefortest..ResourceInstanceGroup..0");
+
+ if (deleteStatusResponse == null || deleteStatusResponse.get().request.requestStatus.getRequestState().equals(FAILED_STR)) {
+ assertThat(vnfGroupShouldBeDeleted.getAction(), equalTo(Action.Delete));
+ assertErrorForResource(vnfGroupShouldBeDeleted, deleteGroupResponse, deleteStatusResponse);
+ }
+
+ if (createStatusResponse == null || createStatusResponse.get().request.requestStatus.getRequestState().equals(FAILED_STR)) {
+ assertThat(vnfGroupShouldBeCreated.getAction(), equalTo(Action.Create));
+ assertErrorForResource(vnfGroupShouldBeCreated, createGroupResponse, createStatusResponse);
+ }
+ }
+
+ //this test is going along with AsyncInstantiationALaCarteApiTest3.delete1Create1VnfFromService API test
+ //The API test has only the happy flow scenario, while this test also test additional MSO responses (mostly non happy)
+ @Test(dataProvider="createAndDeleteIntegrationTestDataProvider")
+ public void vnfsIntegrationTest(
+ String desc,
+ RestObject<RequestReferencesContainer> createVnfResponse,
+ RestObject<RequestReferencesContainer> deleteVnfResponse,
+ RestObject<AsyncRequestStatus> createStatusResponse,
+ RestObject<AsyncRequestStatus> deleteStatusResponse,
+ JobStatus expectedJobStatus,
+ int getStatusCounter) throws IOException {
+
+ createAndDeleteIntegrationTest("/payload_jsons/vnfDelete1Create1Request.json",
+ "/serviceInstantiation/v7/serviceInstances/f8791436-8d55-4fde-b4d5-72dd2cf13cfb/vnfs",
+ createVnfResponse,
+ "/serviceInstantiation/v7/serviceInstances/f8791436-8d55-4fde-b4d5-72dd2cf13cfb/vnfs/VNF_INSTANCE_ID",
+ deleteVnfResponse,
+ createStatusResponse,
+ deleteStatusResponse,
+ expectedJobStatus,
+ getStatusCounter);
+ }
+
+ @Test(dataProvider="createAndDeleteIntegrationTestDataProvider")
+ public void vfModulesIntegrationTest(
+ String desc,
+ RestObject<RequestReferencesContainer> createVfModuleResponse,
+ RestObject<RequestReferencesContainer> deleteVfModuleResponse,
+ RestObject<AsyncRequestStatus> createStatusResponse,
+ RestObject<AsyncRequestStatus> deleteStatusResponse,
+ JobStatus expectedJobStatus,
+ int getStatusCounter) throws IOException, AsdcCatalogException {
+
+ when(featureManager.isActive(Features.FLAG_ASYNC_ALACARTE_VFMODULE)).thenReturn(true);
+ reset(commandUtils);
+ when(commandUtils.isVfModuleBaseModule("6b528779-44a3-4472-bdff-9cd15ec93450", "f8360508-3f17-4414-a2ed-6bc71161e8db")).thenReturn(true);
+ when(commandUtils.isVfModuleBaseModule("6b528779-44a3-4472-bdff-9cd15ec93450", "25284168-24bb-4698-8cb4-3f509146eca5")).thenReturn(false);
+
+ createAndDeleteIntegrationTest("/payload_jsons/vfModuleDelete1Create1None1Request.json",
+ "/serviceInstantiation/v7/serviceInstances/f8791436-8d55-4fde-b4d5-72dd2cf13cfb/vnfs/VNF_INSTANCE_ID/vfModules",
+ createVfModuleResponse,
+ "/serviceInstantiation/v7/serviceInstances/f8791436-8d55-4fde-b4d5-72dd2cf13cfb/vnfs/VNF_INSTANCE_ID/vfModules/VF_MODULE_INSTANCE_ID",
+ deleteVfModuleResponse,
+ createStatusResponse,
+ deleteStatusResponse,
+ expectedJobStatus,
+ getStatusCounter);
+ }
+
+ //this test is going along with AsyncInstantiationALaCarteApiTest.delete1Create1NetworkFromService API test
+ //The API test has only the happy flow scenario, while this test also test additional MSO responses (mostly non happy)
+ @Test(dataProvider="createAndDeleteIntegrationTestDataProvider")
+ public void networksIntegrationTest(
+ String desc,
+ RestObject<RequestReferencesContainer> createNetworkResponse,
+ RestObject<RequestReferencesContainer> deleteNetworkResponse,
+ RestObject<AsyncRequestStatus> createStatusResponse,
+ RestObject<AsyncRequestStatus> deleteStatusResponse,
+ JobStatus expectedJobStatus,
+ int getStatusCounter) throws IOException {
+
+ createAndDeleteIntegrationTest("/payload_jsons/networkDelete1Create1Request.json",
+ "/serviceInstantiation/v7/serviceInstances/f8791436-8d55-4fde-b4d5-72dd2cf13cfb/networks",
+ createNetworkResponse,
+ "/serviceInstantiation/v7/serviceInstances/f8791436-8d55-4fde-b4d5-72dd2cf13cfb/networks/NETWORK_INSTANCE_ID",
+ deleteNetworkResponse,
+ createStatusResponse,
+ deleteStatusResponse,
+ expectedJobStatus,
+ getStatusCounter);
}
+ private UUID createAndDeleteIntegrationTest(String payload,
+ String createPath,
+ RestObject<RequestReferencesContainer> createResponse,
+ String deletePath,
+ RestObject<RequestReferencesContainer> deleteResponse,
+ RestObject<AsyncRequestStatus> createStatusResponse,
+ RestObject<AsyncRequestStatus> deleteStatusResponse,
+ JobStatus expectedJobStatus,
+ int getStatusCounter) throws IOException {
+ UUID jobUUID = asyncInstantiationBL.pushBulkJob(
+ TestUtils.readJsonResourceFileAsObject(payload, ServiceInstantiation.class), "userId")
+ .get(0);
+
+ when(restMso.restCall(eq(HttpMethod.POST), eq(RequestReferencesContainer.class), any(), eq(createPath), any())).thenReturn(createResponse);
+ when(restMso.restCall(eq(HttpMethod.DELETE), eq(RequestReferencesContainer.class), any(), eq(deletePath), any())).thenReturn(deleteResponse);
+ if (createStatusResponse!=null) {
+ when(restMso.GetForObject(endsWith(createResponse.get().getRequestReferences().getRequestId()), eq(AsyncRequestStatus.class))).thenReturn(createStatusResponse);
+ }
+ if (deleteStatusResponse!=null) {
+ when(restMso.GetForObject(endsWith(deleteResponse.get().getRequestReferences().getRequestId()), eq(AsyncRequestStatus.class))).thenReturn(deleteStatusResponse);
+ }
+
+ processJobsCountTimesAndAssertStatus(jobUUID, 40, expectedJobStatus);
+
+ verify(restMso, times(1)).restCall(eq(HttpMethod.POST), any(), any(), eq(createPath), any());
+ verify(restMso, times(1)).restCall(eq(HttpMethod.DELETE), any(), any(), eq(deletePath), any());
+ verify(restMso, times(getStatusCounter)).GetForObject(any(), any());
+
+ return jobUUID;
+ }
+
+ @Test
+ public void whenCreateTransportService_thanExpectedPre1806MacroRequestSent() throws IOException {
+ UUID jobUUID = asyncInstantiationBL.pushBulkJob(generatePre1806MacroTransportServiceInstantiationPayload(null, null),"az2016").get(0);
+ RestObject<RequestReferencesContainer> createResponse = createResponseRandomIds(202);
+
+ when(restMso.restCall(eq(HttpMethod.POST), eq(RequestReferencesContainer.class), any(), eq("/serviceInstantiation/v7/serviceInstances"), any()))
+ .thenReturn(createResponse);
+ when(restMso.GetForObject(endsWith(createResponse.get().getRequestReferences().getRequestId()), eq(AsyncRequestStatus.class)))
+ .thenReturn(asyncRequestStatusResponseAsRestObject(COMPLETE_STR));
+ processJobsCountTimesAndAssertStatus(jobUUID, 20, COMPLETED);
+
+ JsonNode expectedJson = TestUtils.readJsonResourceFileAsObject("/payload_jsons/pre_1806_macro_without_cloudConfiguration.json", JsonNode.class);
+ ArgumentCaptor<RequestDetailsWrapper> requestCaptor = ArgumentCaptor.forClass(RequestDetailsWrapper.class);
+ verify(restMso).restCall(any(), any(), requestCaptor.capture(), any(), any());
+ requestCaptor.getAllValues().forEach(x->assertJsonEquals(expectedJson, x));
+ }
+
+ private void assertErrorForResource(BaseResource resource,
+ RestObject<RequestReferencesContainer> deleteOrCreateResponse,
+ RestObject<AsyncRequestStatus> statusResponse) {
+ JobAuditStatus auditStatus = auditService.getResourceAuditStatus(resource.getTrackById());
+ assertThat(auditStatus, is(notNullValue()));
+ assertThat(auditStatus.getJobStatus(), equalTo(FAILED_STR));
+ if (statusResponse == null) {
+ String errorMessage = "Http Code:" + deleteOrCreateResponse.getStatusCode() + ", " + RAW_DATA_FROM_MSO;
+ assertThat(auditStatus.getAdditionalInfo(), equalTo(errorMessage));
+ assertThat(auditStatus.getRequestId(), is(nullValue()));
+ } else {
+ assertThat(auditStatus.getRequestId().toString(), equalTo(statusResponse.get().request.requestId));
+ }
+ }
+
+ protected void processJobsCountTimesAndAssertStatus(UUID serviceJobId, int times, JobStatus expectedStatus) {
+ processJobsCountTimes(times);
+ singleServicesAndAssertStatus(expectedStatus, serviceJobId);
+ }
+
+ private void processJobsCountTimes(int times) {
+ for (int i = 0; i < times; i++) {
+ WORKERS_TOPICS.forEach(this::simplePullJobProcessAndPushBack);
+ }
+ }
+
+ protected void processJobsCountTimesAndAssertStatus(UUID serviceJobId, int times, JobStatus expectedStatus, JobStatus otherJobsStatus) {
+ processJobsCountTimes(times);
+ listServicesAndAssertStatus(expectedStatus, otherJobsStatus, serviceJobId);
+ }
+
+
private void verifyQueueSizes(ImmutableMap<JobStatus, Integer> expected) {
final Collection<Job> peek = jobsBrokerService.peek();
final Map<JobStatus, Long> jobTypes = peek.stream().collect(groupingBy(Job::getStatus, counting()));
- assertThat(jobTypes, is(expected));
+ assertThat(jobTypes, jsonEquals(expected));
}
- private List<ServiceInfo> listServicesAndAssertStatus(JobStatus pulledJobStatus, JobStatus otherJobsStatus, Job job) {
+ private List<ServiceInfo> listServicesAndAssertStatus(JobStatus pulledJobStatus, JobStatus otherJobsStatus, UUID jobUUID) {
List<ServiceInfo> serviceInfoList = asyncInstantiationBL.getAllServicesInfo();
- assertServicesStatus(serviceInfoList, pulledJobStatus, otherJobsStatus, job);
+ assertServicesStatus(serviceInfoList, pulledJobStatus, otherJobsStatus, jobUUID);
return serviceInfoList;
}
@@ -922,9 +1119,15 @@ public class AsyncInstantiationIntegrationTest extends AsyncInstantiationBaseTes
return serviceInfo;
}
- private void assertServicesStatus(List<ServiceInfo> serviceInfoList, JobStatus pulledJobStatus, JobStatus otherJobsStatus, Job job) {
+ private boolean isServiceOnStatus(JobStatus expectedStatus) {
+ List<ServiceInfo> serviceInfoList = asyncInstantiationBL.getAllServicesInfo();
+ assertEquals(1, serviceInfoList.size());
+ return serviceInfoList.get(0).getJobStatus()==expectedStatus;
+ }
+
+ private void assertServicesStatus(List<ServiceInfo> serviceInfoList, JobStatus pulledJobStatus, JobStatus otherJobsStatus, UUID jobUUID) {
serviceInfoList.forEach(si->{
- if (si.getJobId().equals(job.getUuid())) {
+ if (si.getJobId().equals(jobUUID)) {
assertThat(si.getJobStatus(), is(pulledJobStatus));
}
else {
@@ -935,11 +1138,104 @@ public class AsyncInstantiationIntegrationTest extends AsyncInstantiationBaseTes
private void listServicesAndAssertStatus(Map<UUID, JobStatus> expectedJobStatusMap) {
Map<UUID, JobStatus> actualStatuses = asyncInstantiationBL.getAllServicesInfo()
- .stream().collect(Collectors.toMap(ServiceInfo::getJobId, ServiceInfo::getJobStatus));
+ .stream().collect(Collectors.toMap(ServiceInfo::getJobId, ServiceInfo::getJobStatus));
assertThat(actualStatuses.entrySet(), equalTo(expectedJobStatusMap.entrySet()));
}
private String randomUuid() {
return UUID.randomUUID().toString();
}
+
+ @Test
+ public void whenResumeService_thanExpectedResumeRequestSent() throws IOException {
+ String instanceId = "a565e6ad-75d1-4493-98f1-33234b5c17e2"; //from feRequestResumeMacroService.json
+ String originalRequestId = "894089b8-f7f4-418d-81da-34186fd32670"; //from msoResponseGetRequestsOfServiceInstance.json
+ String resumeRequestId = randomUuid();
+ String userId = TestUtils.generateRandomAlphaNumeric(6);
+
+ //prepare mocks for get all requests for instance id
+ RestObject<AsyncRequestStatusList> getRequestByIdResponse = createAsyncRequestStatusListByInstanceId();
+ when(restMso.GetForObject(
+ eq("/orchestrationRequests/v7?filter=serviceInstanceId:EQUALS:" + instanceId),
+ eq(AsyncRequestStatusList.class)))
+ .thenReturn(getRequestByIdResponse);
+
+ //prepare mocks resume request
+ when(restMso.restCall(eq(HttpMethod.POST), eq(RequestReferencesContainer.class), isNull(), eq(String.format("/orchestrationRequests/v7/%s/resume", originalRequestId)), eq(Optional.of(userId))))
+ .thenReturn(createResponse(202, instanceId, resumeRequestId));
+
+ //prepare mocks for get resume status
+ when(restMso.GetForObject(eq("/orchestrationRequests/v7/" + resumeRequestId), eq(AsyncRequestStatus.class)))
+ .thenReturn(asyncRequestStatusResponseAsRestObject(IN_PROGRESS_STR),
+ asyncRequestStatusResponseAsRestObject(IN_PROGRESS_STR),
+ asyncRequestStatusResponseAsRestObject(COMPLETE_STR));
+
+
+ UUID jobUUID = asyncInstantiationBL.pushBulkJob(generateResumeMacroPayload(), userId).get(0);
+ processJobsCountTimesAndAssertStatus(jobUUID, 20, COMPLETED);
+ verify(restMso).GetForObject(
+ eq("/orchestrationRequests/v7?filter=serviceInstanceId:EQUALS:" + instanceId),
+ eq(AsyncRequestStatusList.class));
+ verify(restMso).restCall(eq(HttpMethod.POST), eq(RequestReferencesContainer.class), isNull(), eq(String.format("/orchestrationRequests/v7/%s/resume", originalRequestId)), eq(Optional.of(userId)));
+ verify(restMso, times(3)).GetForObject(eq("/orchestrationRequests/v7/" + resumeRequestId), eq(AsyncRequestStatus.class));
+ }
+
+ @Test
+ public void givenResumeRequest_whenMsoReturnBadResponse_thanJobIsFailed() throws IOException {
+ //there is no mocks for restMSO which means restMso return bad response...
+ UUID jobUUID = asyncInstantiationBL.pushBulkJob(generateResumeMacroPayload(), "abc").get(0);
+ processJobsCountTimesAndAssertStatus(jobUUID, 20, FAILED);
+ }
+
+ @NotNull
+ private RestObject<AsyncRequestStatusList> createAsyncRequestStatusListByInstanceId() throws IOException {
+ AsyncRequestStatusList asyncRequestStatusList = TestUtils.readJsonResourceFileAsObject(
+ "/payload_jsons/resume/msoResponseGetRequestsOfServiceInstance.json",
+ AsyncRequestStatusList.class);
+ RestObject<AsyncRequestStatusList> getRequestByIdResponse = new RestObject<>();
+ getRequestByIdResponse.set(asyncRequestStatusList);
+ getRequestByIdResponse.setStatusCode(200);
+ return getRequestByIdResponse;
+ }
+
+ private ServiceInstantiation generateResumeMacroPayload() throws IOException {
+ return TestUtils.readJsonResourceFileAsObject("/payload_jsons/resume/feRequestResumeMacroService.json", ServiceInstantiation.class);
+ }
+
+ @Test
+ public void whenUpgradingAvfModule_thanExpectedReplaceRequestSent() throws IOException {
+ String instanceId = "5d49c3b1-fc90-4762-8c98-e800170baa55"; //from feRequestResumeMacroService.json
+ String replaceRequestId = randomUuid();
+ String userId = "az2016";
+
+
+ //prepare mocks resume request
+ when(restMso.restCall(eq(HttpMethod.POST), eq(RequestReferencesContainer.class), any(), eq("/serviceInstantiation/v7/serviceInstances/e9993045-cc96-4f3f-bf9a-71b2a400a956/vnfs/5c9c2896-1fe6-4055-b7ec-d0a01e5f9bf5/vfModules/5d49c3b1-fc90-4762-8c98-e800170baa55/replace"), eq(Optional.of(userId))))
+ .thenReturn(createResponse(202, instanceId, replaceRequestId));
+
+
+ when(restMso.GetForObject(eq("/orchestrationRequests/v7/" + replaceRequestId), eq(AsyncRequestStatus.class)))
+ .thenReturn(asyncRequestStatusResponseAsRestObject(IN_PROGRESS_STR),
+ asyncRequestStatusResponseAsRestObject(IN_PROGRESS_STR),
+ asyncRequestStatusResponseAsRestObject(COMPLETE_STR));
+
+ ///orchestrationRequests/v7/0174b25a-dd81-45b7-b4af-0057bcc30857
+
+ when(featureManager.isActive(Features.FLAG_ASYNC_ALACARTE_VFMODULE)).thenReturn(true);
+ enableAddCloudOwnerOnMsoRequest();
+
+ UUID jobUUID = asyncInstantiationBL.pushBulkJob(generateReplaceVfModulePayload(), userId).get(0);
+ processJobsCountTimesAndAssertStatus(jobUUID, 20, COMPLETED);
+
+
+
+ JsonNode expectedJson = TestUtils.readJsonResourceFileAsObject("/payload_jsons/vfmodule/replace_vfmodule.json", JsonNode.class);
+ ArgumentCaptor<RequestDetailsWrapper> requestCaptor = ArgumentCaptor.forClass(RequestDetailsWrapper.class);
+ verify(restMso).restCall(eq(HttpMethod.POST), eq(RequestReferencesContainer.class), requestCaptor.capture(), eq("/serviceInstantiation/v7/serviceInstances/e9993045-cc96-4f3f-bf9a-71b2a400a956/vnfs/5c9c2896-1fe6-4055-b7ec-d0a01e5f9bf5/vfModules/5d49c3b1-fc90-4762-8c98-e800170baa55/replace"), eq(Optional.of(userId)));
+ requestCaptor.getAllValues().forEach(x->assertJsonEquals(expectedJson, x));
+ }
+
+ private ServiceInstantiation generateReplaceVfModulePayload() throws IOException {
+ return TestUtils.readJsonResourceFileAsObject("/payload_jsons/vfmodule/replace_vfmodule_fe_input.json", ServiceInstantiation.class);
+ }
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/job/impl/DeleteOldJobsSchedulerInitializerTest.java b/vid-app-common/src/test/java/org/onap/vid/job/impl/DeleteOldJobsSchedulerInitializerTest.java
new file mode 100644
index 000000000..4944efa69
--- /dev/null
+++ b/vid-app-common/src/test/java/org/onap/vid/job/impl/DeleteOldJobsSchedulerInitializerTest.java
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.vid.job.impl;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.matchesPattern;
+import static org.mockito.Mockito.mock;
+import static org.onap.vid.testUtils.TestUtils.testWithSystemProperty;
+import static org.testng.Assert.assertEquals;
+
+import org.onap.vid.job.JobsBrokerService;
+import org.quartz.JobDetail;
+import org.quartz.impl.triggers.CronTriggerImpl;
+import org.testng.annotations.Test;
+
+public class DeleteOldJobsSchedulerInitializerTest {
+
+ @Test
+ public void testCreateJobDetail() throws Exception {
+ testWithSystemProperty("vid.asyncJob.howLongToKeepOldJobsInDays", "7", ()-> {
+ JobsBrokerService mockBroker = mock(JobsBrokerService.class);
+ DeleteOldJobsSchedulerInitializer underTest = new DeleteOldJobsSchedulerInitializer(mockBroker, null);
+ JobDetail jobDetail = underTest.createJobDetail();
+ assertEquals(DeleteOldJobsWorker.class, jobDetail.getJobClass());
+ assertEquals(mockBroker, jobDetail.getJobDataMap().get("jobsBrokerService"));
+ assertEquals(604800L, jobDetail.getJobDataMap().get("secondsAgo"));
+ });
+ }
+
+ @Test
+ public void testCreateTrigger() {
+ DeleteOldJobsSchedulerInitializer underTest = new DeleteOldJobsSchedulerInitializer(null, null);
+ CronTriggerImpl trigger = (CronTriggerImpl) underTest.createTrigger();
+ assertThat(trigger.getCronExpression(), matchesPattern("0 [1-5]?[0-9] 6 \\? \\* \\*"));
+ }
+
+} \ No newline at end of file
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/ALaCarteServiceInstantiationCommand.java b/vid-app-common/src/test/java/org/onap/vid/job/impl/DeleteOldJobsWorkerTest.java
index 38d5ede8a..229e0cab1 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/ALaCarteServiceInstantiationCommand.java
+++ b/vid-app-common/src/test/java/org/onap/vid/job/impl/DeleteOldJobsWorkerTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,24 +18,26 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.vid.job.command;
+package org.onap.vid.job.impl;
-import org.onap.vid.changeManagement.RequestDetailsWrapper;
-import org.onap.vid.job.JobCommand;
-import org.onap.vid.mso.model.ServiceInstantiationRequestDetails;
-import org.springframework.beans.factory.config.ConfigurableBeanFactory;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import org.onap.vid.job.JobsBrokerService;
+import org.quartz.JobExecutionException;
+import org.testng.annotations.Test;
-@Component
-@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-public class ALaCarteServiceInstantiationCommand extends ServiceInstantiationCommand implements JobCommand {
+public class DeleteOldJobsWorkerTest {
- @Override
- protected RequestDetailsWrapper<ServiceInstantiationRequestDetails> generateServiceInstantiationRequest() {
- return asyncInstantiationBL.generateALaCarteServiceInstantiationRequest(
- getSharedData().getJobUuid(), getRequest(), optimisticUniqueServiceInstanceName, getSharedData().getUserId()
- );
+ @Test
+ public void whenExecuteInternal_thenCallToDeleteOldFinalJobs() throws JobExecutionException {
+ JobsBrokerService mockBroker = mock(JobsBrokerService.class);
+ long secondsAgo = 42L;
+ DeleteOldJobsWorker underTest = new DeleteOldJobsWorker();
+ underTest.setJobsBrokerService(mockBroker);
+ underTest.setSecondsAgo(secondsAgo);
+ underTest.executeInternal(null);
+ verify(mockBroker).deleteOldFinalJobs(secondsAgo);
}
+
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/job/impl/JobAdapterTest.java b/vid-app-common/src/test/java/org/onap/vid/job/impl/JobAdapterTest.java
index f6785c37d..4e11b7e8b 100644
--- a/vid-app-common/src/test/java/org/onap/vid/job/impl/JobAdapterTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/job/impl/JobAdapterTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -26,10 +26,15 @@ import org.onap.vid.job.Job;
import org.onap.vid.job.JobAdapter;
import org.onap.vid.job.JobType;
import org.onap.vid.job.command.JobCommandFactoryTest;
+import org.onap.vid.properties.Features;
+import org.onap.vid.testUtils.TestUtils;
import org.testng.annotations.Test;
+import org.togglz.core.manager.FeatureManager;
import java.util.UUID;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotEquals;
import static org.testng.AssertJUnit.assertNotNull;
@@ -38,12 +43,14 @@ public class JobAdapterTest {
@Test
public void testCreateServiceInstantiationJob() {
- JobAdapter jobAdapter = new JobAdapterImpl();
+ FeatureManager featureManager = mock(FeatureManager.class);
+ JobAdapter jobAdapter = new JobAdapterImpl(featureManager);
JobType jobType = JobType.NoOp;
JobAdapter.AsyncJobRequest request = new JobCommandFactoryTest.MockedRequest(42,"nothing");
UUID templateId = UUID.randomUUID();
String userId = "ou012t";
+ String testApi = "VNF_API";
String optimisticUniqueServiceInstanceName = "optimisticUniqueServiceInstanceName";
int indexInBulk = RandomUtils.nextInt();
Job job = jobAdapter.createServiceInstantiationJob(
@@ -51,6 +58,7 @@ public class JobAdapterTest {
request,
templateId,
userId,
+ testApi,
optimisticUniqueServiceInstanceName,
indexInBulk
);
@@ -59,6 +67,7 @@ public class JobAdapterTest {
assertEquals(job.getSharedData().getRequest(), request);
assertEquals(job.getSharedData().getRequestType(), request.getClass());
assertEquals(job.getSharedData().getUserId(), userId);
+ assertEquals(job.getSharedData().getTestApi(), testApi);
assertEquals(job.getSharedData().getJobUuid(), job.getUuid());
assertEquals(job.getSharedData().getRootJobId(), job.getUuid());
assertNotNull(job.getUuid());
@@ -68,13 +77,16 @@ public class JobAdapterTest {
assertEquals(job.getStatus(), Job.JobStatus.PENDING);
}
- @Test
- public void testCreateChildJob() {
-
- JobAdapter jobAdapter = new JobAdapterImpl();
+ @Test(dataProvider = "trueAndFalse", dataProviderClass = TestUtils.class)
+ public void testCreateChildJob(boolean isFlagExpCreateResourcesInParallel) {
+ FeatureManager featureManager = mock(FeatureManager.class);
+ when(featureManager.isActive(Features.FLAG_EXP_CREATE_RESOURCES_IN_PARALLEL)).thenReturn(isFlagExpCreateResourcesInParallel);
+ Job.JobStatus expectedJobStatus = isFlagExpCreateResourcesInParallel ? Job.JobStatus.CREATING : Job.JobStatus.PENDING_RESOURCE;
+ JobAdapter jobAdapter = new JobAdapterImpl(featureManager);
UUID templateId = UUID.randomUUID();
String userId = "ou012t";
+ String testApi = "VNF_API";
String optimisticUniqueServiceInstanceName = "optimisticUniqueServiceInstanceName";
int indexInBulk = RandomUtils.nextInt();
Job grandJob = jobAdapter.createServiceInstantiationJob(
@@ -82,39 +94,44 @@ public class JobAdapterTest {
new JobCommandFactoryTest.MockedRequest(99, "anything"),
templateId,
userId,
+ testApi,
optimisticUniqueServiceInstanceName,
indexInBulk
);
- Job.JobStatus jobStatus = Job.JobStatus.PAUSE;
JobType jobType = JobType.NoOp;
JobAdapter.AsyncJobRequest request = new JobCommandFactoryTest.MockedRequest(42,"nothing");
- Job parentJob = jobAdapter.createChildJob(jobType, jobStatus, request, grandJob.getSharedData(), ImmutableMap.of());
+ Job parentJob = jobAdapter.createChildJob(jobType, request, grandJob.getSharedData(), ImmutableMap.of(), 1);
assertEquals(parentJob.getType(), jobType);
assertEquals(parentJob.getSharedData().getRequest(), request);
assertEquals(parentJob.getSharedData().getRequestType(), request.getClass());
assertEquals(parentJob.getSharedData().getUserId(), userId);
+ assertEquals(parentJob.getSharedData().getTestApi(), testApi);
assertEquals(parentJob.getSharedData().getJobUuid(), parentJob.getUuid());
assertNotNull(parentJob.getUuid());
assertNotEquals(parentJob.getUuid(), grandJob.getUuid());
- assertEquals(parentJob.getStatus(), jobStatus);
+ assertEquals(parentJob.getStatus(), expectedJobStatus);
+ assertEquals(parentJob.getTemplateId(), grandJob.getUuid());
+ assertEquals(parentJob.getIndexInBulk().intValue(), 1);
assertEquals(parentJob.getSharedData().getRootJobId(), grandJob.getUuid());
- Job.JobStatus jobStatus2 = Job.JobStatus.IN_PROGRESS;
JobType jobType2 = JobType.AggregateState;
JobAdapter.AsyncJobRequest request2 = new JobCommandFactoryTest.MockedRequest(66,"abc");
- Job job = jobAdapter.createChildJob(jobType2, jobStatus2, request2, parentJob.getSharedData(), ImmutableMap.of());
+ Job job = jobAdapter.createChildJob(jobType2, request2, parentJob.getSharedData(), ImmutableMap.of(), 0);
assertEquals(job.getType(), jobType2);
assertEquals(job.getSharedData().getRequest(), request2);
assertEquals(job.getSharedData().getRequestType(), request2.getClass());
assertEquals(job.getSharedData().getUserId(), userId);
+ assertEquals(job.getSharedData().getTestApi(), testApi);
assertEquals(job.getSharedData().getJobUuid(), job.getUuid());
assertNotNull(job.getUuid());
assertNotEquals(job.getUuid(), parentJob.getUuid());
- assertEquals(job.getStatus(), jobStatus2);
+ assertEquals(job.getStatus(), expectedJobStatus);
assertEquals(job.getSharedData().getRootJobId(), grandJob.getUuid());
+ assertEquals(job.getTemplateId(), parentJob.getUuid());
+ assertEquals(job.getIndexInBulk().intValue(), 0);
}
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/job/impl/JobWorkerTest.java b/vid-app-common/src/test/java/org/onap/vid/job/impl/JobWorkerTest.java
index dc44d1520..e234ee969 100644
--- a/vid-app-common/src/test/java/org/onap/vid/job/impl/JobWorkerTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/job/impl/JobWorkerTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -33,6 +33,7 @@ import org.onap.vid.job.command.HttpCallCommand;
import org.onap.vid.job.command.JobCommandFactory;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import org.togglz.core.manager.FeatureManager;
import java.util.Map;
import java.util.UUID;
@@ -51,6 +52,9 @@ public class JobWorkerTest {
@Mock
private JobCommandFactory jobCommandFactory;
+ @Mock
+ private FeatureManager featureManager;
+
private final JobCommand jobCommand = mock(JobCommand.class);
private Job jobUnderTest;
private JobAdapter.AsyncJobRequest originalData;
@@ -68,11 +72,12 @@ public class JobWorkerTest {
};
originalType = JobType.MacroServiceInstantiation;
- jobUnderTest = new JobAdapterImpl().createServiceInstantiationJob(
+ jobUnderTest = new JobAdapterImpl(featureManager).createServiceInstantiationJob(
originalType,
originalData,
UUID.randomUUID(),
"my user id",
+ "VNF_API",
"optimisticUniqueServiceInstanceName",
RandomUtils.nextInt()
);
@@ -119,4 +124,4 @@ public class JobWorkerTest {
assertThat(nextJob, jobMatcher);
assertThat(jobAfter, equalTo(jobBefore));
}
-}
+} \ No newline at end of file
diff --git a/vid-app-common/src/test/java/org/onap/vid/model/JobAuditStatusTest.java b/vid-app-common/src/test/java/org/onap/vid/model/JobAuditStatusTest.java
index 2c41120ad..2f9e31ea6 100644
--- a/vid-app-common/src/test/java/org/onap/vid/model/JobAuditStatusTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/model/JobAuditStatusTest.java
@@ -35,11 +35,11 @@ public class JobAuditStatusTest {
@DataProvider
public static Object[][] AdditionalInfoSizes() {
return new Object[][]{
- {5, 5},
- {1999,1999},
- {2000, 2000},
- {2001, 2000},
- {10000, 2000}
+ {5, 5},
+ {1999,1999},
+ {2000, 2000},
+ {2001, 2000},
+ {10000, 2000}
};
}
@@ -53,7 +53,7 @@ public class JobAuditStatusTest {
@Test(dataProvider = "AdditionalInfoSizes")
public void testAdditionalInfoMaxLengthInConstructor(int originalSize, int finalSize) {
final String additionalInfo = StringUtils.repeat("a", originalSize);
- JobAuditStatus jobAuditStatus = new JobAuditStatus(UUID.randomUUID(), "myJobStatus", JobAuditStatus.SourceStatus.MSO, UUID.randomUUID(), additionalInfo, new Date());
+ JobAuditStatus jobAuditStatus = JobAuditStatus.createForTest(UUID.randomUUID(), "myJobStatus", JobAuditStatus.SourceStatus.MSO, UUID.randomUUID(), additionalInfo, new Date());
assertThat(jobAuditStatus.getAdditionalInfo().length(), is(finalSize));
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/model/aaiTree/VpnBindingKtTest.kt b/vid-app-common/src/test/java/org/onap/vid/model/aaiTree/VpnBindingKtTest.kt
new file mode 100644
index 000000000..90c61d759
--- /dev/null
+++ b/vid-app-common/src/test/java/org/onap/vid/model/aaiTree/VpnBindingKtTest.kt
@@ -0,0 +1,16 @@
+package org.onap.vid.model.aaiTree
+
+import org.testng.Assert.assertEquals
+import org.testng.annotations.Test
+
+class VpnBindingKtTest {
+
+ @Test
+ fun whenFailedToParseRouteTarget_DefaultValuesAreReturned() {
+ val aaiTreeNode = AAITreeNode();
+ aaiTreeNode.type = NodeType.VPN_BINDING
+ aaiTreeNode.additionalProperties["route-targets"] = 3 //just an object that can't be parsed into list of route targets
+ val vpnBinding = from(aaiTreeNode);
+ assertEquals(vpnBinding.routeTargets, listOf(RouteTarget("ParsingFailure", "ParsingFailure")))
+ }
+} \ No newline at end of file
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java
index 207e63579..4ddbc0f41 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java
@@ -21,82 +21,77 @@
package org.onap.vid.mso;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
+import static org.assertj.core.api.Assertions.tuple;
+import static org.hamcrest.Matchers.allOf;
+import static org.hamcrest.Matchers.hasEntry;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyBoolean;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.argThat;
+import static org.mockito.ArgumentMatchers.endsWith;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.isA;
+import static org.mockito.BDDMockito.given;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+import static org.onap.vid.controller.MsoController.CONFIGURATION_ID;
+import static org.onap.vid.controller.MsoController.REQUEST_TYPE;
+import static org.onap.vid.controller.MsoController.SVC_INSTANCE_ID;
+import static org.onap.vid.controller.MsoController.VNF_INSTANCE_ID;
+import static org.onap.vid.mso.MsoBusinessLogicImpl.validateEndpointPath;
+
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.Lists;
import com.google.gson.Gson;
import io.joshworks.restclient.http.HttpResponse;
+import java.io.IOException;
+import java.net.URL;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.stream.Collectors;
+import javax.ws.rs.BadRequestException;
import org.apache.commons.io.IOUtils;
import org.jetbrains.annotations.NotNull;
-import org.mockito.hamcrest.MockitoHamcrest;
-import org.onap.vid.changeManagement.WorkflowRequestDetail;
-import org.onap.vid.model.SOWorkflowList;
-import org.onap.vid.model.probes.ExternalComponentStatus;
-import org.onap.vid.mso.rest.RequestList;
-import org.onap.vid.mso.rest.RequestWrapper;
-import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
import org.mockito.ArgumentMatcher;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import org.mockito.hamcrest.MockitoHamcrest;
import org.onap.portalsdk.core.util.SystemProperties;
import org.onap.vid.changeManagement.ChangeManagementRequest;
+import org.onap.vid.changeManagement.WorkflowRequestDetail;
import org.onap.vid.controller.OperationalEnvironmentController;
import org.onap.vid.exceptions.GenericUncheckedException;
-import org.onap.vid.model.RequestReferencesContainer;
+import org.onap.vid.model.SOWorkflowList;
import org.onap.vid.model.SoftDeleteRequest;
+import org.onap.vid.model.probes.ExternalComponentStatus;
import org.onap.vid.mso.model.CloudConfiguration;
import org.onap.vid.mso.model.ModelInfo;
import org.onap.vid.mso.model.OperationalEnvironmentActivateInfo;
import org.onap.vid.mso.model.OperationalEnvironmentDeactivateInfo;
import org.onap.vid.mso.model.RequestInfo;
import org.onap.vid.mso.model.RequestParameters;
-import org.onap.vid.mso.model.RequestReferences;
import org.onap.vid.mso.rest.OperationalEnvironment.OperationEnvironmentRequestDetails;
import org.onap.vid.mso.rest.Request;
import org.onap.vid.mso.rest.RequestDetails;
import org.onap.vid.mso.rest.RequestDetailsWrapper;
+import org.onap.vid.mso.rest.RequestList;
+import org.onap.vid.mso.rest.RequestWrapper;
import org.onap.vid.mso.rest.Task;
-import org.onap.vid.properties.Features;
import org.springframework.http.HttpStatus;
import org.springframework.test.context.ContextConfiguration;
-import org.togglz.core.manager.FeatureManager;
-
-import javax.ws.rs.BadRequestException;
-import java.io.IOException;
-import java.net.URL;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import java.util.stream.Collectors;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.tuple;
-import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
-import static org.hamcrest.Matchers.allOf;
-import static org.hamcrest.Matchers.hasEntry;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyBoolean;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.ArgumentMatchers.argThat;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.ArgumentMatchers.isA;
-import static org.mockito.ArgumentMatchers.endsWith;
-import static org.mockito.BDDMockito.given;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.mock;
-import static org.onap.vid.controller.MsoController.CONFIGURATION_ID;
-import static org.onap.vid.controller.MsoController.REQUEST_TYPE;
-import static org.onap.vid.controller.MsoController.SVC_INSTANCE_ID;
-import static org.onap.vid.controller.MsoController.VNF_INSTANCE_ID;
-import static org.onap.vid.mso.MsoBusinessLogicImpl.validateEndpointPath;
+import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
@ContextConfiguration(classes = {SystemProperties.class})
public class MsoBusinessLogicImplTest extends AbstractTestNGSpringContextTests {
@@ -104,9 +99,6 @@ public class MsoBusinessLogicImplTest extends AbstractTestNGSpringContextTests {
private static final ObjectMapper objectMapper = new ObjectMapper();
@Mock
- private FeatureManager featureManager;
-
- @Mock
private MsoInterface msoInterface;
@Mock
@@ -126,7 +118,7 @@ public class MsoBusinessLogicImplTest extends AbstractTestNGSpringContextTests {
@BeforeClass
public void setUp() {
MockitoAnnotations.initMocks(this);
- msoBusinessLogic = new MsoBusinessLogicImpl(msoInterface, featureManager);
+ msoBusinessLogic = new MsoBusinessLogicImpl(msoInterface);
}
@Test
@@ -282,39 +274,48 @@ public class MsoBusinessLogicImplTest extends AbstractTestNGSpringContextTests {
assertThat(response).isEqualToComparingFieldByField(expectedResponse);
}
- @Test
- public void shouldProperlyDeleteSvcInstanceWithProperParametersAndFalseFeatureFlag() {
+ @DataProvider
+ public Object[][] deleteSvcInstanceShouldDelete() {
+ return new Object[][]{{"Active"}, {"unexpected-status"}};
+ }
+
+ @DataProvider
+ public Object[][] deleteSvcInstanceShouldUnassign() {
+ return new Object[][]{{"Created"}, {"Pendingdelete"}, {"pending-Delete"}, {"Assigned"}};
+ }
+
+
+ @Test(dataProvider = "deleteSvcInstanceShouldDelete")
+ public void shouldProperlyDeleteSvcInstanceWithProperParametersShouldDelete(String status) {
// given
- String endpointTemplate = "/serviceInstances/v5/%s";
+ String endpointTemplate = "/serviceInstantiation/v7/serviceInstances/%s";
String serviceInstanceId = "3f93c7cb-2fd0-4557-9514-e189b7b04f9d";
String svcEndpoint = String.format(endpointTemplate, serviceInstanceId);
RequestDetails requestDetails = new RequestDetails();
MsoResponseWrapper expectedResponse = createOkResponse();
given(msoInterface.deleteSvcInstance(requestDetails, svcEndpoint)).willReturn(expectedResponse);
- given(featureManager.isActive(Features.FLAG_UNASSIGN_SERVICE)).willReturn(false);
// when
MsoResponseWrapper msoResponseWrapper = msoBusinessLogic
- .deleteSvcInstance(requestDetails, serviceInstanceId, "unAssignOrDeleteParams");
+ .deleteSvcInstance(requestDetails, serviceInstanceId, status);
// then
assertThat(msoResponseWrapper).isEqualToComparingFieldByField(expectedResponse);
}
- @Test
- public void shouldProperlyDeleteSvcInstanceWithProperParametersAndTrueFeatureFlag() {
+ @Test(dataProvider = "deleteSvcInstanceShouldUnassign")
+ public void shouldProperlyDeleteSvcInstanceWithProperParametersShouldUnassign(String status) {
// given
- String endpointTemplate = "/serviceInstantiation/v5/serviceInstances/%s/unassign";
+ String endpointTemplate = "/serviceInstantiation/v7/serviceInstances/%s/unassign";
String serviceInstanceId = "3f93c7cb-2fd0-4557-9514-e189b7b04f9d";
String svcEndpoint = String.format(endpointTemplate, serviceInstanceId);
RequestDetails requestDetails = new RequestDetails();
MsoResponseWrapper expectedResponse = createOkResponse();
given(msoInterface.unassignSvcInstance(requestDetails, svcEndpoint)).willReturn(expectedResponse);
- given(featureManager.isActive(Features.FLAG_UNASSIGN_SERVICE)).willReturn(true);
// when
MsoResponseWrapper msoResponseWrapper = msoBusinessLogic
- .deleteSvcInstance(requestDetails, serviceInstanceId, "assigned");
+ .deleteSvcInstance(requestDetails, serviceInstanceId, status);
// then
assertThat(msoResponseWrapper).isEqualToComparingFieldByField(expectedResponse);
@@ -323,7 +324,7 @@ public class MsoBusinessLogicImplTest extends AbstractTestNGSpringContextTests {
@Test
public void shouldProperlyDeleteVnfWithProperParameters() {
// when
- String endpointTemplate = "/serviceInstances/v5/%s/vnfs/%s";
+ String endpointTemplate = "/serviceInstantiation/v7/serviceInstances/%s/vnfs/%s";
String serviceInstanceId = "3f93c7cb-2fd0-4557-9514-e189b7b04f9d";
String vnfInstanceId = "testVnfInstanceTempId";
String vnfEndpoint = String.format(endpointTemplate, serviceInstanceId, vnfInstanceId);
@@ -342,7 +343,7 @@ public class MsoBusinessLogicImplTest extends AbstractTestNGSpringContextTests {
@Test
public void shouldProperlyDeleteVfModuleWithProperParameters() {
// when
- String endpointTemplate = "/serviceInstances/v7/%s/vnfs/%s/vfModules/%s";
+ String endpointTemplate = "/serviceInstantiation/v7/serviceInstances/%s/vnfs/%s/vfModules/%s";
String serviceInstanceId = "3f93c7cb-2fd0-4557-9514-e189b7b04f9d";
String vnfInstanceId = "testVnfInstanceTempId";
String vfModuleId = "testVfModuleId";
@@ -906,58 +907,6 @@ public class MsoBusinessLogicImplTest extends AbstractTestNGSpringContextTests {
}
@Test
- public void shouldProperlyDeactivateAndCloudDeleteWithProperParameters() {
- // given
- String serviceInstanceId = "testServiceId";
- String vnfInstanceId = "testVnfInstanceId";
- String vfModuleInstanceId = "testVfModuleInstanceId";
- RequestDetails requestDetails = new RequestDetails();
-
- String path = msoBusinessLogic.getDeactivateAndCloudDeletePath(serviceInstanceId, vnfInstanceId, vfModuleInstanceId);
-
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("testInstance");
- requestReferences.setRequestId("testRequest");
-
- HttpResponse<RequestReferencesContainer> expectedResponse = HttpResponse.fallback(new RequestReferencesContainer(requestReferences));
-
- MsoResponseWrapper2 responseWrapped = new MsoResponseWrapper2<>(expectedResponse);
-
- given(msoInterface.post(eq(path), any(RequestDetails.class), eq(RequestReferencesContainer.class))).willReturn(expectedResponse);
-
- // when
- MsoResponseWrapper2 response = msoBusinessLogic.deactivateAndCloudDelete(serviceInstanceId, vnfInstanceId, vfModuleInstanceId, requestDetails);
-
- // then
- assertThat(response).isEqualToComparingFieldByField(responseWrapped);
- }
-
- @Test
- public void shouldProperlyActivateFabricConfigurationWithProperParameters() {
- // given
- String serviceInstanceId = "testServiceId";
- RequestDetails requestDetails = new RequestDetails();
-
- String path = msoBusinessLogic.getActivateFabricConfigurationPath(serviceInstanceId);
-
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("testInstance");
- requestReferences.setRequestId("testRequest");
-
- HttpResponse<RequestReferencesContainer> expectedResponse = HttpResponse.fallback(new RequestReferencesContainer(requestReferences));
-
- MsoResponseWrapper2 responseWrapped = new MsoResponseWrapper2<>(expectedResponse);
-
- given(msoInterface.post(eq(path), any(RequestDetails.class), eq(RequestReferencesContainer.class))).willReturn(expectedResponse);
-
- // when
- MsoResponseWrapper2 response = msoBusinessLogic.activateFabricConfiguration(serviceInstanceId, requestDetails);
-
- // then
- assertThat(response).isEqualToComparingFieldByField(responseWrapped);
- }
-
- @Test
public void shouldProperlyUpdateVnfSoftwareWithProperParameters() {
// given
String serviceInstanceId = "testServiceId";
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/MsoOperationalEnvironmentTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/MsoOperationalEnvironmentTest.java
index 891192c75..0ea5f2947 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/MsoOperationalEnvironmentTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/MsoOperationalEnvironmentTest.java
@@ -25,6 +25,13 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableListMultimap;
+import java.io.IOException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
import org.apache.commons.io.IOUtils;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
@@ -40,17 +47,9 @@ import org.skyscreamer.jsonassert.JSONCompareMode;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
-import java.io.IOException;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
public class MsoOperationalEnvironmentTest {
- private MsoBusinessLogic msoBusinessLogic = new MsoBusinessLogicImpl(null,null);
+ private MsoBusinessLogic msoBusinessLogic = new MsoBusinessLogicImpl(null);
private static final Logger logger = LogManager.getLogger(MsoOperationalEnvironmentTest.class);
@Test(dataProvider = "getOperationalEnvironmentActivationPermutations")
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientNewTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientNewTest.java
index d4abfae38..6cf7d487e 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientNewTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientNewTest.java
@@ -38,8 +38,8 @@ import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
-import java.util.Properties;
import java.util.UUID;
+import org.apache.commons.configuration.PropertiesConfiguration;
import org.glassfish.grizzly.http.util.HttpStatus;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -61,7 +61,7 @@ public class MsoRestClientNewTest {
private static StubServer server;
private static StubServer securedServer;
- private static Properties props = new Properties();
+ private static PropertiesConfiguration props = new PropertiesConfiguration();
private static String msoCreateServiceInstanceJson;
private static String msoScaleOutVfModule;
private final static String CREATE_INSTANCE_RESPONSE_STR =
@@ -76,7 +76,7 @@ public class MsoRestClientNewTest {
@BeforeClass
- public static void start() throws IOException {
+ public static void start() throws Exception {
server = new StubServer().run();
securedServer = new StubServer().secured().run();
@@ -109,7 +109,7 @@ public class MsoRestClientNewTest {
@Test
public void testCreateSvcInstance() throws Exception {
- String endpoint = props.getProperty(MsoProperties.MSO_REST_API_CONFIGURATIONS);
+ String endpoint = props.getString(MsoProperties.MSO_REST_API_CONFIGURATIONS);
endpoint = endpoint.replace(MsoController.SVC_INSTANCE_ID, SERVICE_INSTANCE_ID);
try (MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
server,
@@ -122,7 +122,7 @@ public class MsoRestClientNewTest {
@Test
public void testCreateVnf() throws Exception {
- String endpoint = props.getProperty(MsoProperties.MSO_REST_API_VNF_INSTANCE);
+ String endpoint = props.getString(MsoProperties.MSO_REST_API_VNF_INSTANCE);
endpoint = endpoint.replace(MsoController.SVC_INSTANCE_ID, SERVICE_INSTANCE_ID);
try (MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
server,
@@ -136,7 +136,7 @@ public class MsoRestClientNewTest {
@Test
public void testCreateNwInstance() throws Exception {
- String endpoint = props.getProperty(MsoProperties.MSO_REST_API_NETWORK_INSTANCE);
+ String endpoint = props.getString(MsoProperties.MSO_REST_API_NETWORK_INSTANCE);
String nw_endpoint = endpoint.replaceFirst(MsoController.SVC_INSTANCE_ID, SERVICE_INSTANCE_ID);
try (MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
server,
@@ -149,7 +149,7 @@ public class MsoRestClientNewTest {
@Test
public void testCreateVolumeGroupInstance() throws Exception {
- String endpoint = props.getProperty(MsoProperties.MSO_REST_API_VOLUME_GROUP_INSTANCE);
+ String endpoint = props.getString(MsoProperties.MSO_REST_API_VOLUME_GROUP_INSTANCE);
String vnf_endpoint = endpoint.replaceFirst(MsoController.SVC_INSTANCE_ID, SERVICE_INSTANCE_ID);
vnf_endpoint = vnf_endpoint.replaceFirst(MsoController.VNF_INSTANCE_ID, SAMPLE_VNF_INSTANCE_ID);
try (MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
@@ -163,7 +163,7 @@ public class MsoRestClientNewTest {
@Test
public void testCreateVfModuleInstance() throws Exception {
- String endpoint = props.getProperty(MsoProperties.MSO_REST_API_VF_MODULE_INSTANCE);
+ String endpoint = props.getString(MsoProperties.MSO_REST_API_VF_MODULE_INSTANCE);
String partial_endpoint = endpoint.replaceFirst(MsoController.SVC_INSTANCE_ID, SERVICE_INSTANCE_ID);
String vf_module_endpoint =
partial_endpoint.replaceFirst(MsoController.VNF_INSTANCE_ID, SAMPLE_VNF_INSTANCE_ID);
@@ -195,7 +195,7 @@ public class MsoRestClientNewTest {
@Ignore
@Test
public void testDeleteSvcInstance() throws Exception {
- String endpoint = props.getProperty(MsoProperties.MSO_REST_API_SVC_INSTANCE);
+ String endpoint = props.getString(MsoProperties.MSO_REST_API_SVC_INSTANCE);
endpoint = endpoint.replaceFirst(MsoController.SVC_INSTANCE_ID, SERVICE_INSTANCE_ID);
@@ -211,7 +211,7 @@ public class MsoRestClientNewTest {
@Ignore
@Test
public void testDeleteVnf() throws Exception {
- String endpoint = props.getProperty(MsoProperties.MSO_REST_API_VNF_INSTANCE);
+ String endpoint = props.getString(MsoProperties.MSO_REST_API_VNF_INSTANCE);
endpoint = endpoint.replaceFirst(MsoController.SVC_INSTANCE_ID, SERVICE_INSTANCE_ID);
try (MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
@@ -226,7 +226,7 @@ public class MsoRestClientNewTest {
@Ignore
@Test
public void testDeleteVfModule() throws Exception {
- String endpoint = props.getProperty(MsoProperties.MSO_REST_API_VF_MODULE_INSTANCE);
+ String endpoint = props.getString(MsoProperties.MSO_REST_API_VF_MODULE_INSTANCE);
String part_endpoint = endpoint.replaceFirst(MsoController.SVC_INSTANCE_ID, SERVICE_INSTANCE_ID);
String vf_modules_endpoint = part_endpoint.replaceFirst(MsoController.VNF_INSTANCE_ID, SAMPLE_VNF_INSTANCE_ID);
String delete_vf_endpoint = vf_modules_endpoint + '/' + SAMPLE_VNF_MODULE_ID;
@@ -243,7 +243,7 @@ public class MsoRestClientNewTest {
@Ignore
@Test
public void testDeleteVolumeGroupInstance() throws Exception {
- String endpoint = props.getProperty(MsoProperties.MSO_REST_API_VOLUME_GROUP_INSTANCE);
+ String endpoint = props.getString(MsoProperties.MSO_REST_API_VOLUME_GROUP_INSTANCE);
String svc_endpoint = endpoint.replaceFirst(MsoController.SVC_INSTANCE_ID, SERVICE_INSTANCE_ID);
String vnf_endpoint = svc_endpoint.replaceFirst(MsoController.VNF_INSTANCE_ID, SAMPLE_VNF_INSTANCE_ID);
String delete_volume_group_endpoint = vnf_endpoint + "/" + SAMPLE_VNF_MODULE_ID;
@@ -260,7 +260,7 @@ public class MsoRestClientNewTest {
@Ignore
@Test
public void testDeleteNwInstance() throws Exception {
- String endpoint = props.getProperty(MsoProperties.MSO_REST_API_NETWORK_INSTANCE);
+ String endpoint = props.getString(MsoProperties.MSO_REST_API_NETWORK_INSTANCE);
String svc_endpoint = endpoint.replaceFirst(MsoController.SVC_INSTANCE_ID, SERVICE_INSTANCE_ID);
String delete_nw_endpoint = svc_endpoint + "/" + SAMPLE_NETWORK_INSTANCE_ID;
@@ -275,7 +275,7 @@ public class MsoRestClientNewTest {
@Test
public void testGetOrchestrationRequest() {
- String p = props.getProperty(MsoProperties.MSO_REST_API_GET_ORC_REQ);
+ String p = props.getString(MsoProperties.MSO_REST_API_GET_ORC_REQ);
String path = p + "/" + SAMPLE_REQUEST_ID;
try(MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
@@ -289,7 +289,7 @@ public class MsoRestClientNewTest {
@Test
public void testGetManualTasksByRequestId() {
- String p = props.getProperty(MsoProperties.MSO_REST_API_GET_ORC_REQ);
+ String p = props.getString(MsoProperties.MSO_REST_API_GET_ORC_REQ);
String path = p + "/" + UUID.randomUUID();
String validResponse = ""
+ "{ "
@@ -376,7 +376,7 @@ public class MsoRestClientNewTest {
@Test
public void testSetConfigurationActiveStatus() throws Exception {
- String endpoint = "/serviceInstances/v5/<service_instance_id>/configurations/<configuration_id>";
+ String endpoint = "/serviceInstances/v7/<service_instance_id>/configurations/<configuration_id>";
endpoint = endpoint.replace(MsoController.SVC_INSTANCE_ID, SERVICE_INSTANCE_ID);
endpoint = endpoint.replace(MsoController.CONFIGURATION_ID, SAMPLE_CONFIGURATION_ID);
endpoint = endpoint + "/activate";
@@ -448,7 +448,7 @@ public class MsoRestClientNewTest {
@Test
public void testRemoveRelationshipFromServiceInstance() throws Exception {
- String serviceEndpoint = props.getProperty(MsoProperties.MSO_REST_API_SVC_INSTANCE);
+ String serviceEndpoint = props.getString(MsoProperties.MSO_REST_API_SVC_INSTANCE);
String removeRelationshipsPath = serviceEndpoint + "/" + SERVICE_INSTANCE_ID + "/removeRelationships";
try (MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
@@ -476,7 +476,7 @@ public class MsoRestClientNewTest {
}
@Test
public void testScaleOutVfModule() throws IOException {
- String serviceEndpoint = props.getProperty(MsoProperties.MSO_REST_API_VF_MODULE_SCALE_OUT);
+ String serviceEndpoint = props.getString(MsoProperties.MSO_REST_API_VF_MODULE_SCALE_OUT);
String partial_endpoint = serviceEndpoint.replaceFirst(SVC_INSTANCE_ID, SERVICE_INSTANCE_ID);
String vf_module_endpoint = partial_endpoint.replaceFirst(VNF_INSTANCE_ID, SAMPLE_VNF_INSTANCE_ID);
try (MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestDetailsTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestDetailsTest.java
index 575ceab7c..7f30b0f2d 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestDetailsTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestDetailsTest.java
@@ -20,23 +20,24 @@
package org.onap.vid.mso.rest;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanEqualsExcluding;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSettersExcluding;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.testng.AssertJUnit.assertEquals;
+
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
import org.assertj.core.api.AssertionsForClassTypes;
import org.onap.vid.exceptions.NotFoundException;
+import org.onap.vid.testUtils.TestUtils;
+import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanEqualsExcluding;
-import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSettersExcluding;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.testng.AssertJUnit.assertEquals;
-
public class RequestDetailsTest {
@@ -48,6 +49,10 @@ public class RequestDetailsTest {
private static final ImmutableList<String> LCP_CLOUD_REGION_ID_PATH =
ImmutableList.of("requestDetails", "cloudConfiguration", "lcpCloudRegionId");
+ @BeforeClass
+ public static void registerValueGenerator() {
+ TestUtils.registerCloudConfigurationValueGenerator();
+ }
@BeforeMethod
public void setUp() {
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/AAITreeNodeBuilderTest.java b/vid-app-common/src/test/java/org/onap/vid/services/AAITreeNodeBuilderTest.java
index 9cd9ebae8..c2a3f5d61 100644
--- a/vid-app-common/src/test/java/org/onap/vid/services/AAITreeNodeBuilderTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/services/AAITreeNodeBuilderTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,77 +20,100 @@
package org.onap.vid.services;
+import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.util.concurrent.MoreExecutors;
+
+import org.apache.commons.lang3.tuple.Pair;
+import org.jetbrains.annotations.NotNull;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import org.mockito.stubbing.Answer;
import org.onap.vid.aai.AaiClientInterface;
+import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.Relationship;
+import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.RelationshipList;
+import org.onap.vid.exceptions.GenericUncheckedException;
import org.onap.vid.model.aaiTree.AAITreeNode;
+import org.onap.vid.model.aaiTree.NodeType;
+import org.onap.vid.mso.model.CloudConfiguration;
+import org.onap.vid.utils.Tree;
import org.onap.vid.utils.Unchecked;
-import org.testng.Assert;
-import org.testng.annotations.BeforeTest;
+import org.onap.vid.testUtils.TestUtils;
+import org.springframework.http.HttpMethod;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.io.IOException;
import java.util.HashMap;
-import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
import java.util.concurrent.ConcurrentSkipListSet;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
import static java.util.Comparator.comparing;
+import static net.javacrumbs.jsonunit.JsonMatchers.jsonEquals;
+import static net.javacrumbs.jsonunit.core.Option.IGNORING_ARRAY_ORDER;
+import static net.javacrumbs.jsonunit.core.Option.IGNORING_EXTRA_FIELDS;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.empty;
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.when;
import static org.onap.vid.services.AAIServiceTree.AAI_TREE_PATHS;
+import static org.onap.vid.utils.KotlinUtilsKt.JACKSON_OBJECT_MAPPER;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
public class AAITreeNodeBuilderTest {
- AAITreeNodeBuilder aaiTreeNodeBuilder;
+ private AAITreeNodeBuilder aaiTreeNodeBuilder;
@Mock
- AaiClientInterface aaiClientMock;
+ private AaiClientInterface aaiClientMock;
- @Mock
- ThreadPoolExecutor threadPoolMock;
+ private ExecutorService executorService;
+ private static final ObjectMapper mapper = new ObjectMapper();
- @BeforeTest
+ @BeforeClass
public void initMocks() {
MockitoAnnotations.initMocks(this);
aaiTreeNodeBuilder = new AAITreeNodeBuilder(aaiClientMock);
+ executorService = MoreExecutors.newDirectExecutorService();
}
- @Test
- public void buildNode_buildGroupNode_NodeIsAsExpected(){
+ private void buildNodeAndAssert(JsonNode inputNode, AAITreeNode expectedNode, NodeType nodeType){
ConcurrentSkipListSet<AAITreeNode> nodesAccumulator = new ConcurrentSkipListSet<>(comparing(AAITreeNode::getUniqueNodeKey));
- ConcurrentLinkedQueue<String> visitedNodes = new ConcurrentLinkedQueue<>();
- when(aaiClientMock.typedAaiGet(Unchecked.toURI("anyUrl"), JsonNode.class)).thenReturn(createGroupJson());
-
- AAITreeNode groupNode = aaiTreeNodeBuilder.buildNode("instance-group",
+ when(aaiClientMock.typedAaiRest(Unchecked.toURI("anyUrl"), JsonNode.class, null, HttpMethod.GET, false)).thenReturn(inputNode);
+ AAITreeNode actualNode = aaiTreeNodeBuilder.buildNode(
+ nodeType,
"anyUrl",
+ null,
+ HttpMethod.GET,
nodesAccumulator,
- threadPoolMock,
- visitedNodes,
- new AtomicInteger(0),
- AAI_TREE_PATHS).get(0);
-
- AAITreeNode expectedGroupNode = createExpectedGroupNode();
- assertNodeIsAsExpected(expectedGroupNode,groupNode);
+ executorService,
+ AAI_TREE_PATHS.getSubTree(new AAIServiceTree.AaiRelationship(nodeType))
+ ).get(0);
+ assertThat(actualNode, jsonEquals(expectedNode).when(IGNORING_ARRAY_ORDER, IGNORING_EXTRA_FIELDS).whenIgnoringPaths("relationshipList","children[0].relationshipList"));
}
- private void assertNodeIsAsExpected(AAITreeNode expectedGroupNode, AAITreeNode groupNode) {
- Assert.assertEquals(groupNode.getId(), expectedGroupNode.getId());
- Assert.assertEquals(groupNode.getType(), expectedGroupNode.getType());
- Assert.assertEquals(groupNode.getName(), expectedGroupNode.getName());
- Assert.assertEquals(groupNode.getModelVersionId(), expectedGroupNode.getModelVersionId());
- Assert.assertEquals(groupNode.getModelInvariantId(), expectedGroupNode.getModelInvariantId());
- Assert.assertEquals(groupNode.getInMaint(), expectedGroupNode.getInMaint());
- Assert.assertEquals(groupNode.getAdditionalProperties(), expectedGroupNode.getAdditionalProperties());
+ @Test
+ public void buildNode_buildGroupNode_NodeIsAsExpected() {
+ buildNodeAndAssert(createGroupJson(), createExpectedGroupNode(), NodeType.INSTANCE_GROUP);
}
private AAITreeNode createExpectedGroupNode() {
AAITreeNode expectedNode = new AAITreeNode();
expectedNode.setId("c4fcf022-31a0-470a-b5b8-c18335b7af32");
- expectedNode.setType("instance-group");
+ expectedNode.setType(NodeType.INSTANCE_GROUP);
expectedNode.setName("Test vE-Flex");
expectedNode.setModelVersionId("Test vE-Flex");
expectedNode.setModelInvariantId("dd182d7d-6949-4b90-b3cc-5befe400742e");
@@ -103,8 +126,6 @@ public class AAITreeNodeBuilderTest {
additionalProperties.put("resource-version","1533315433086");
additionalProperties.put("instance-group-function","vTSBC Customer Landing Network Collection");
expectedNode.setAdditionalProperties(additionalProperties);
-
-
return expectedNode;
}
@@ -125,22 +146,7 @@ public class AAITreeNodeBuilderTest {
" \"inMaint\": \"false\"," +
" \"instance-group-function\": \"vTSBC Customer Landing Network Collection\"," +
" \"relationship-list\": {" +
- " \"relationship\": [{" +
- " \"related-to\": \"generic-vnf\"," +
- " \"relationship-label\": \"org.onap.relationships.inventory.MemberOf\" ," +
- " \"related-link\": \"/aai/v14/network/generic-vnfs/generic-vnf/8c54c369-2876-4423-9b33-80f783f29082\" ," +
- " \"relationship-data\": [{" +
- " \"relationship-key\": \"generic-vnf.vnf-id\"," +
- " \"relationship-value\": \"8c54c369-2876-4423-9b33-80f783f29082\"" +
- " }" +
- " ]," +
- " \"related-to-property\": [{" +
- " \"property-key\": \"generic-vnf.vnf-name\"," +
- " \"property-value\": \"zrdm5bffad01\"" +
- " }" +
- " ]" +
- " }" +
- " ]" +
+ " \"relationship\": []" +
" }" +
" }");
} catch (IOException e) {
@@ -148,4 +154,363 @@ public class AAITreeNodeBuilderTest {
}
return groupNode;
}
+
+ @Test
+ public void whenReadNetworkNode_thenNodeIsAsExpected() throws IOException {
+ JsonNode mockedAaiResponse = TestUtils.readJsonResourceFileAsObject("/getTopology/network.json", JsonNode.class);
+
+ AAITreeNode expectedNetworkNode = new AAITreeNode();
+ expectedNetworkNode.setId("94c86b39-bbbf-4027-8120-ff37c6d2493a");
+ expectedNetworkNode.setName("AUK51a_oam_calea_net_1");
+ expectedNetworkNode.setOrchestrationStatus("Assigned");
+ expectedNetworkNode.setModelInvariantId("b9a9b549-0ee4-49fc-b4f2-5edc6701da68");
+ expectedNetworkNode.setModelVersionId("77010093-df36-4dcb-8428-c3d02bf3f88d");
+ expectedNetworkNode.setModelCustomizationId("e5f33853-f84c-4cdd-99f2-93846957aa18");
+ expectedNetworkNode.setType(NodeType.NETWORK);
+ expectedNetworkNode.setCloudConfiguration(new CloudConfiguration("auk51a", "b530fc990b6d4334bd45518bebca6a51", "att-nc"));
+
+ buildNodeAndAssert(mockedAaiResponse, expectedNetworkNode, NodeType.NETWORK);
+ }
+
+ @Test
+ public void whenCloudRegionMissing_otherPlacementFieldsReadAsExpected() throws IOException {
+
+ AAITreeNode node = new AAITreeNode();
+ Optional<Relationship> tenantRelationShip = Optional.of(
+ JACKSON_OBJECT_MAPPER.readValue("{" +
+ " \"related-to\": \"tenant\"," +
+ " \"relationship-label\": \"org.onap.relationships.inventory.Uses\"," +
+ " \"related-link\": \"/aai/v14/cloud-infrastructure/cloud-regions/cloud-region/att-nc/auk51a/tenants/tenant/b530fc990b6d4334bd45518bebca6a51\"," +
+ " \"relationship-data\": [{" +
+ " \"relationship-key\": \"cloud-region.cloud-owner\"," +
+ " \"relationship-value\": \"att-nc\"" +
+ " }, {" +
+ " \"relationship-key\": \"tenant.tenant-id\"," +
+ " \"relationship-value\": \"b530fc990b6d4334bd45518bebca6a51\"" +
+ " }" +
+ " ]," +
+ " \"related-to-property\": [{" +
+ " \"property-key\": \"tenant.tenant-name\"," +
+ " \"property-value\": \"ecomp_ispt\"" +
+ " }" +
+ " ]" +
+ " }", Relationship.class)
+ );
+ aaiTreeNodeBuilder.enrichPlacementDataUsingTenantInfo(node, tenantRelationShip);
+ assertEquals(new CloudConfiguration(null, "b530fc990b6d4334bd45518bebca6a51", "att-nc"), node.getCloudConfiguration());
+ }
+
+ @Test
+ public void whenTenantMissing_otherPlacementFieldsReadAsExpected() throws IOException {
+
+ AAITreeNode node = new AAITreeNode();
+ Optional<Relationship> tenantRelationShip = Optional.of(
+ JACKSON_OBJECT_MAPPER.readValue("{" +
+ " \"related-to\": \"tenant\"," +
+ " \"relationship-label\": \"org.onap.relationships.inventory.Uses\"," +
+ " \"related-link\": \"/aai/v14/cloud-infrastructure/cloud-regions/cloud-region/att-nc/auk51a/tenants/tenant/b530fc990b6d4334bd45518bebca6a51\"," +
+ " \"relationship-data\": [{" +
+ " \"relationship-key\": \"cloud-region.cloud-owner\"," +
+ " \"relationship-value\": \"att-nc\"" +
+ " }, {" +
+ " \"relationship-key\": \"cloud-region.cloud-region-id\"," +
+ " \"relationship-value\": \"auk51a\"" +
+ " }" +
+ " ]," +
+ " \"related-to-property\": [{" +
+ " \"property-key\": \"tenant.tenant-name\"," +
+ " \"property-value\": \"ecomp_ispt\"" +
+ " }" +
+ " ]" +
+ " }", Relationship.class)
+ );
+ aaiTreeNodeBuilder.enrichPlacementDataUsingTenantInfo(node, tenantRelationShip);
+ assertEquals(new CloudConfiguration("auk51a", null, "att-nc"), node.getCloudConfiguration());
+ }
+
+ @Test
+ public void whenCloudOwnerMissing_otherPlacementFieldsReadAsExpected() throws IOException {
+
+ AAITreeNode node = new AAITreeNode();
+ Optional<Relationship> tenantRelationShip = Optional.of(
+ JACKSON_OBJECT_MAPPER.readValue("{" +
+ " \"related-to\": \"tenant\"," +
+ " \"relationship-label\": \"org.onap.relationships.inventory.Uses\"," +
+ " \"related-link\": \"/aai/v14/cloud-infrastructure/cloud-regions/cloud-region/att-nc/auk51a/tenants/tenant/b530fc990b6d4334bd45518bebca6a51\"," +
+ " \"relationship-data\": [{" +
+ " \"relationship-key\": \"tenant.tenant-id\"," +
+ " \"relationship-value\": \"b530fc990b6d4334bd45518bebca6a51\"" +
+ " }, {" +
+ " \"relationship-key\": \"cloud-region.cloud-region-id\"," +
+ " \"relationship-value\": \"auk51a\"" +
+ " }" +
+ " ]," +
+ " \"related-to-property\": [{" +
+ " \"property-key\": \"tenant.tenant-name\"," +
+ " \"property-value\": \"ecomp_ispt\"" +
+ " }" +
+ " ]" +
+ " }", Relationship.class)
+ );
+ aaiTreeNodeBuilder.enrichPlacementDataUsingTenantInfo(node, tenantRelationShip);
+ assertEquals(new CloudConfiguration("auk51a", "b530fc990b6d4334bd45518bebca6a51", null), node.getCloudConfiguration());
+ }
+
+ @Test
+ public void whenThereIsNoTenantRelationship_thenPlacementIsNull() throws IOException {
+ AAITreeNode node = new AAITreeNode();
+ aaiTreeNodeBuilder.enrichPlacementData(node);
+ assertNull(node.getCloudConfiguration());
+ }
+
+
+ @Test
+ public void whenReadVnfNodeWithVfModule_thenNodeIsAsExpected() throws IOException {
+ JsonNode mockedAaiGetVnfResponse = TestUtils.readJsonResourceFileAsObject("/getTopology/vnf.json", JsonNode.class);
+
+ //add mock for vfModule of the VNF
+ JsonNode mockedAaiGetVfModuleResponse = TestUtils.readJsonResourceFileAsObject("/getTopology/vfModule.json", JsonNode.class);
+ when(aaiClientMock.typedAaiGet(Unchecked.toURI("anyUrl/vf-modules"), JsonNode.class)).thenReturn(mockedAaiGetVfModuleResponse);
+
+ CloudConfiguration expectedCloudConfiguration = new CloudConfiguration("dyh3b", "c8035f5ee95d4c62bbc8074c044122b9", "irma-aic");
+
+ AAITreeNode expectedVnfNode = createExpectedVnfTreeNode(expectedCloudConfiguration);
+
+ AAITreeNode expectedVfModule = new AAITreeNode();
+ expectedVfModule.setId("2cb6d41e-2bef-4cb2-80ce-c7815bcdcf4e");
+ expectedVfModule.setName("dyh3brarf8000v_base");
+ expectedVfModule.setOrchestrationStatus("Active");
+ expectedVfModule.setModelInvariantId("3ecca473-b0c0-46ae-b0b7-bd2969d8b79f");
+ expectedVfModule.setModelVersionId("5c35b764-e266-4498-af87-a88c4ba92dc4");
+ expectedVfModule.setModelCustomizationId("06b4ece0-f6f8-4003-b445-653418292101");
+ expectedVfModule.setType(NodeType.VF_MODULE);
+ expectedVfModule.setInMaint(false);
+ expectedVfModule.setCloudConfiguration(expectedCloudConfiguration);
+
+ expectedVnfNode.addChildren(ImmutableList.of(expectedVfModule));
+
+ buildNodeAndAssert(mockedAaiGetVnfResponse, expectedVnfNode, NodeType.GENERIC_VNF);
+ }
+
+ @NotNull
+ public static AAITreeNode createExpectedVnfTreeNode(CloudConfiguration expectedCloudConfiguration) {
+ AAITreeNode expectedVnfNode = new AAITreeNode();
+ expectedVnfNode.setId("9a7a4dc1-8e5f-43fe-a360-7734c5f51382");
+ expectedVnfNode.setName("dyh3brarf8000v");
+ expectedVnfNode.setOrchestrationStatus("Active");
+ expectedVnfNode.setModelInvariantId("b711997f-36b3-4a9b-8b37-71a0fc2ebd6d");
+ expectedVnfNode.setModelVersionId("7f23e4f7-e44c-44df-b066-4cedc6950bfe");
+ expectedVnfNode.setModelCustomizationId("401350be-0f56-481c-86d8-f32d573fec26");
+ expectedVnfNode.setType(NodeType.GENERIC_VNF);
+ expectedVnfNode.setInMaint(true);
+ expectedVnfNode.setProvStatus("PREPROV");
+ expectedVnfNode.setCloudConfiguration(expectedCloudConfiguration);
+ return expectedVnfNode;
+ }
+
+ @DataProvider
+ public static Object[][] isArrayDataProvider() {
+ return new Object[][] {
+ {"Json Array", buildArrayJson(NodeType.GENERIC_VNF), true},
+ {"Json Object", buildOneLevelJson(NodeType.GENERIC_VNF), false},
+ {"Json Array with another node type", buildArrayJson(NodeType.SERVICE_INSTANCE), false},
+ {"null json", null, false}
+ };
+ }
+
+ @Test(dataProvider = "isArrayDataProvider")
+ public void IsArrayType(String description, JsonNode jsonNode, boolean expectedResult) {
+ boolean isArray = aaiTreeNodeBuilder.isArray(jsonNode, NodeType.GENERIC_VNF);
+ assertEquals(expectedResult, isArray);
+ }
+
+ @Test
+ public void jsonToAaiNodeTest() {
+ NodeType nodeType = NodeType.SERVICE_INSTANCE;
+ JsonNode node = buildOneLevelJson(nodeType);
+ ConcurrentSkipListSet<AAITreeNode> nodesAccumulator = new ConcurrentSkipListSet<>(comparing(AAITreeNode::getUniqueNodeKey));
+
+ AAITreeNode aaiTreeNode = aaiTreeNodeBuilder.createAaiNode(nodeType, node, nodesAccumulator);
+
+ assertEquals("any-instance-id", aaiTreeNode.getId());
+ assertEquals("any-instance-name", aaiTreeNode.getName());
+ assertTrue(nodesAccumulator.contains(aaiTreeNode));
+ }
+
+ @Test
+ public void getNextLevelInPathsTreeTest() {
+ Tree<AAIServiceTree.AaiRelationship> firstLevelTree = getPathsTree();
+
+ Tree<AAIServiceTree.AaiRelationship> secondLevelTree = aaiTreeNodeBuilder.getNextLevelInPathsTree(firstLevelTree, NodeType.GENERIC_VNF.getType());
+ assertEquals(NodeType.GENERIC_VNF.getType(), secondLevelTree.getRootValue().type);
+
+ Tree<AAIServiceTree.AaiRelationship> thirdLevelTree = aaiTreeNodeBuilder.getNextLevelInPathsTree(secondLevelTree, NodeType.INSTANCE_GROUP.getType());
+ assertEquals(NodeType.INSTANCE_GROUP.getType(), thirdLevelTree.getRootValue().type);
+ }
+
+ @Test
+ public void getNextLevelInPathsTreeTest_givenIrrelevantNode_expectedNull() {
+ Tree<AAIServiceTree.AaiRelationship> pathsTree = getPathsTree();
+
+ Tree<AAIServiceTree.AaiRelationship> subTree = aaiTreeNodeBuilder.getNextLevelInPathsTree(pathsTree, NodeType.INSTANCE_GROUP.getType());
+
+ assertNull(subTree);
+ }
+
+ @Test
+ public void getRelationships_given2Relationships_expect1filtered() {
+ NodeType firstRelationship = NodeType.GENERIC_VNF;
+ NodeType secondRelationship = NodeType.INSTANCE_GROUP;
+ JsonNode jsonNode = buildOneLevelJson(NodeType.SERVICE_INSTANCE, firstRelationship, secondRelationship);
+
+ List<Relationship> relationships = aaiTreeNodeBuilder.getFilteredRelationships(jsonNode, getPathsTree());
+
+ assertEquals(1, relationships.size());
+ assertEquals(firstRelationship.getType(), relationships.get(0).getRelatedTo());
+ }
+
+ @Test
+ public void getRelationships_givenNoRelationships_expectedEmptyListTest() {
+ JsonNode jsonNode = buildOneLevelJson(NodeType.SERVICE_INSTANCE);
+
+ List<Relationship> relationships = aaiTreeNodeBuilder.getFilteredRelationships(jsonNode, getPathsTree());
+
+ assertThat(relationships, is(empty()));
+ }
+
+ @Test
+ public void getRelationships_given2RelationshipsNotExistInTreePaths_expectAllFiltered() {
+ NodeType firstRelationship = NodeType.CONFIGURATION;
+ NodeType secondRelationship = NodeType.INSTANCE_GROUP;
+ JsonNode jsonNode = buildOneLevelJson(NodeType.SERVICE_INSTANCE, firstRelationship, secondRelationship);
+
+ List<Relationship> relationships = aaiTreeNodeBuilder.getFilteredRelationships(jsonNode, getPathsTree());
+
+ assertThat(relationships, is(empty()));
+ }
+
+ @Test
+ public void aggregateAllOtherPropertiesTest() {
+ NodeType nodeType = NodeType.SERVICE_INSTANCE;
+ JsonNode jsonNode = buildOneLevelJson(nodeType, NodeType.GENERIC_VNF, NodeType.GENERIC_VNF);
+ ((ObjectNode) jsonNode).put("nf-role", "any-value");
+
+ Map<String, Object> additionalProps = aaiTreeNodeBuilder.aggregateAllOtherProperties(jsonNode, nodeType);
+ assertThat(additionalProps, is(ImmutableMap.of(
+ "nf-role", "any-value")));
+ }
+
+ @Test
+ public void parseNodeAndFilterRelationshipsTest() {
+ NodeType nodeType = NodeType.SERVICE_INSTANCE;
+ JsonNode jsonNode = buildOneLevelJson(NodeType.SERVICE_INSTANCE, NodeType.GENERIC_VNF, NodeType.NETWORK, NodeType.VF_MODULE);
+ ConcurrentSkipListSet<AAITreeNode> nodesAccumulator = new ConcurrentSkipListSet<>(comparing(AAITreeNode::getUniqueNodeKey));
+
+ Pair<AAITreeNode, List<Relationship>> resultNode = aaiTreeNodeBuilder.parseNodeAndFilterRelationships(jsonNode, nodeType,
+ nodesAccumulator, getPathsTree());
+
+ assertEquals(nodeType, resultNode.getKey().getType());
+ assertEquals(2, resultNode.getValue().size());
+ assertEquals(NodeType.GENERIC_VNF.getType(), resultNode.getValue().get(0).getRelatedTo());
+ assertEquals(NodeType.NETWORK.getType(), resultNode.getValue().get(1).getRelatedTo());
+ }
+
+ @Test(expectedExceptions = GenericUncheckedException.class ,expectedExceptionsMessageRegExp = "AAI node fetching failed.")
+ public void fetchChildrenAsyncTest_given2children_expected1Ok1Timeout() {
+ ConcurrentSkipListSet<AAITreeNode> nodesAccumulator = new ConcurrentSkipListSet<>(comparing(AAITreeNode::getUniqueNodeKey));
+ ExecutorService threadPool = Executors.newFixedThreadPool(5);
+
+ AAITreeNode rootNode = createExpectedGroupNode();
+ JsonNode relationshipJson = getRelationships(NodeType.GENERIC_VNF, NodeType.NETWORK);
+ List<Relationship> relationships = mapper.convertValue(relationshipJson, RelationshipList.class).getRelationship();
+
+ when(aaiClientMock.typedAaiRest(Unchecked.toURI(relationships.get(0).getRelatedLink()), JsonNode.class, null, HttpMethod.GET, false))
+ .thenReturn(buildOneLevelJson(NodeType.GENERIC_VNF));
+
+ when(aaiClientMock.typedAaiRest(Unchecked.toURI(relationships.get(1).getRelatedLink()), JsonNode.class, null, HttpMethod.GET, false))
+ .thenAnswer((Answer<JsonNode>) invocation -> {
+ Thread.sleep(2000);
+ return buildOneLevelJson(NodeType.NETWORK);
+ });
+
+ aaiTreeNodeBuilder.fetchChildrenAsync(threadPool, nodesAccumulator, rootNode, relationships, getPathsTree(), 1);
+
+ assertEquals(2, rootNode.getChildren().size());
+ assertEquals(NodeType.GENERIC_VNF, rootNode.getChildren().get(0).getType());
+ assertEquals(NodeType.NETWORK, rootNode.getChildren().get(1).getType());
+ }
+
+ @DataProvider
+ public Object[][] testIsListOfKeyResultsDataProvider() {
+ return new Object[][]{
+ {"Node has results with several values",
+ "{\"results\":[{\"l3-network\":{}},{\"l3-network\":{}},{\"l3-network\":{}}]}",
+ true},
+ {"Node has results with no values",
+ "{\"results\":[]}",
+ true},
+ {"Node has results, but it isn't an array",
+ "{\"results\":{\"some-field\":{}}}",
+ false},
+ {"Node doesn't have results",
+ "{\"l3-network\":[{},{}]}",
+ false},
+ {"Node is null",
+ "null",
+ false},
+ };
+ }
+
+ @Test(dataProvider = "testIsListOfKeyResultsDataProvider")
+ public void testIsListOfKeyResults(String testCase, String input, boolean expectedResult) throws IOException {
+ assertEquals(testCase + ": " + input,
+ expectedResult, aaiTreeNodeBuilder.isListOfKeyResults(new ObjectMapper().readTree(input)));
+ }
+
+ private Tree<AAIServiceTree.AaiRelationship> getPathsTree() {
+ Tree<AAIServiceTree.AaiRelationship> pathsTree = new Tree<>(new AAIServiceTree.AaiRelationship(NodeType.SERVICE_INSTANCE));
+ pathsTree.addPath(AAIServiceTree.toAaiRelationshipList(NodeType.GENERIC_VNF, NodeType.INSTANCE_GROUP));
+ pathsTree.addPath(AAIServiceTree.toAaiRelationshipList(NodeType.NETWORK));
+
+ return pathsTree;
+ }
+
+ private static JsonNode buildOneLevelJson(NodeType nodeType, NodeType...relationships) {
+ ObjectNode objectNode = mapper.createObjectNode();
+ objectNode.put(nodeType.getId(), "any-instance-id");
+ objectNode.put(nodeType.getName(), "any-instance-name");
+ if (relationships.length > 0 ) {
+ objectNode.putPOJO("relationship-list", getRelationships(relationships));
+ }
+ return objectNode;
+ }
+
+ private static JsonNode buildArrayJson(NodeType nodeType) {
+ ObjectNode objectNode = mapper.createObjectNode();
+ ArrayNode arrayNode = objectNode.putArray(nodeType.getType());
+ arrayNode.add(buildOneLevelJson(nodeType));
+ arrayNode.add(buildOneLevelJson(nodeType));
+
+ return objectNode;
+ }
+
+ private static JsonNode getRelationship(String nodeType) {
+ ObjectNode relationship = mapper.createObjectNode();
+ relationship.put("related-to", nodeType);
+ relationship.put("relationship-label", "org.onap.relationships.inventory.ComposedOf");
+ relationship.put("related-link", "/aai/v12/network/" + nodeType + "s/" + nodeType + "/cf6f60cd-808d-44e6-978b-c663e00dba8d");
+ return relationship;
+ }
+
+ private static JsonNode getRelationships(NodeType...nodeTypes) {
+ ObjectNode relationshipList = mapper.createObjectNode();
+ ArrayNode relationships = relationshipList.putArray("relationship");
+
+ for (NodeType nodeType: nodeTypes) {
+ relationships.add(getRelationship(nodeType.getType()));
+ }
+
+ return relationshipList;
+ }
+
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/AaiServiceImplTest.java b/vid-app-common/src/test/java/org/onap/vid/services/AaiServiceImplTest.java
index bb47180e4..09a53684f 100644
--- a/vid-app-common/src/test/java/org/onap/vid/services/AaiServiceImplTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/services/AaiServiceImplTest.java
@@ -21,16 +21,36 @@
package org.onap.vid.services;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyBoolean;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.isNull;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.onap.vid.model.aaiTree.NodeType.SERVICE_INSTANCE;
+
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.joshworks.restclient.http.HttpResponse;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import javax.ws.rs.core.Response;
import org.apache.http.HttpStatus;
import org.jetbrains.annotations.NotNull;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
+import org.mockito.Spy;
import org.mockito.junit.MockitoJUnitRunner;
import org.onap.vid.aai.AaiClientInterface;
import org.onap.vid.aai.AaiGetVnfResponse;
@@ -70,721 +90,711 @@ import org.onap.vid.model.aaiTree.AAITreeNode;
import org.onap.vid.model.aaiTree.RelatedVnf;
import org.onap.vid.model.aaiTree.ServiceInstance;
import org.onap.vid.roles.RoleValidator;
-
-import javax.ws.rs.core.Response;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
+import org.springframework.http.HttpMethod;
@RunWith(MockitoJUnitRunner.class)
public class AaiServiceImplTest {
- private static final String GLOBAL_CUSTOMER_ID = "GLOBAL_CUSTOMER_ID";
- private static final String CLOUD_REGION_ID = "CLOUD_REGION_ID";
- private static final String VNF_TYPE = "VNF_TYPE";
- private static final String TENANT_ID = "TENANT_ID";
- private static final String TENANT_NAME = "TENANT_NAME";
- private static final String SERVICE_TYPE = "SERVICE_TYPE";
- private static final String CORRECT_VALUE = "CORRECT_VALUE";
- private static final String SUBSCRIBER_ID = "SUBSCRIBER_ID_EXPECTED";
- private static final String STATUS_TEXT = "STATUS_TEXT";
- private static final String GLOBAL_SUBSCRIBER_ID = "GLOBAL_SUBSCRIBER_ID";
- private static final String GLOBAL_SUBSCRIBER_ID_NULL_RESPONSE = "ID_NULL";
- private static final String VNF_INSTANCE_ID_OK = "VNF_INSTANCE_ID_OK";
- private static final String VNF_INSTANCE_ID_FAIL = "VNF_INSTANCE_ID_FAIL";
- private static final String PARENT_NAME = "PARENT_NAME";
- private static final String PARENT_ID = "PARENT_ID";
- private static final String INVARIANT_ID = "INVARIANT_ID";
- private static final String GROUP_TYPE_FAILING = "GROUP_TYPE_FAILING";
- private static final String GROUP_ROLE_OK = "GROUP_ROLE_OK";
- private static final String GROUP_ROLE_FAILING = "GROUP_ROLE_FAILING";
- private static final String group_type_ok = "GROUP_TYPE_OK";
- private static final String CLOUD_TYPE = "CLOUD_TYPE";
-
- @Mock
- private HttpResponse<SubscriberList> responseAllSubscribers;
- @Mock
- private AaiResponse<OperationalEnvironmentList> aaiResponseOpEnvList;
- @Mock
- private AaiResponse aaiResponse;
- @Mock
- private AaiResponse<JsonNode> aaiResponseJsonNode;
- @Mock
- private RoleValidator roleValidator;
-
- @Mock
- private AaiClientInterface aaiClient;
- @Mock
- private AaiOverTLSClientInterface aaiOverTLSClient;
- @Mock
- private AaiResponseTranslator aaiResponseTranslator;
- @Mock
- private AAIServiceTree aaiServiceTree;
-
- @InjectMocks
- private AaiServiceImpl aaiService;
-
-
- @Test
- public void shouldGetFullSubscriberListWithoutValidator() {
- when(aaiOverTLSClient.getAllSubscribers()).thenReturn(responseAllSubscribers);
-
- HttpResponse<SubscriberList> actualResponse = aaiService.getFullSubscriberList();
-
- assertThat(actualResponse).isEqualTo(responseAllSubscribers);
- }
-
- @Test
- public void shouldGetFullSubscriberListWithValidator() {
- Subscriber subscriber = createSubscriber();
- SubscriberList subscriberList = new SubscriberList(Collections.singletonList(subscriber));
-
- when(aaiOverTLSClient.getAllSubscribers()).thenReturn(responseAllSubscribers);
- when(responseAllSubscribers.getBody()).thenReturn(subscriberList);
- when(responseAllSubscribers.getStatusText()).thenReturn(STATUS_TEXT);
- when(responseAllSubscribers.getStatus()).thenReturn(HttpStatus.SC_OK);
- SubscriberFilteredResults expectedSubscribers = new SubscriberFilteredResults(roleValidator, subscriberList,
- STATUS_TEXT, HttpStatus.SC_OK);
-
- SubscriberFilteredResults actualSubscribers = aaiService.getFullSubscriberList(roleValidator);
-
- assertThat(actualSubscribers.getHttpCode()).isEqualTo(expectedSubscribers.getHttpCode());
- assertThat(actualSubscribers.getErrorMessage()).isEqualTo(expectedSubscribers.getErrorMessage());
- }
-
- @Test
- public void shouldGetOperationalEnvironments() {
- when(aaiClient.getOperationalEnvironments(anyString(), anyString()))
- .thenReturn(aaiResponseOpEnvList);
-
- AaiResponse<OperationalEnvironmentList> expectedEnvList =
- aaiService.getOperationalEnvironments(anyString(), anyString());
-
- assertThat(expectedEnvList).isEqualTo(aaiResponseOpEnvList);
- }
-
- @Test
- public void shouldGetSubscriberData() {
- Services services = createAaiResponseServices();
- AaiResponse<Services> aaiResponseServices = new AaiResponse<>(services, null, HttpStatus.SC_OK);
-
- when(aaiClient.getSubscriberData(SUBSCRIBER_ID)).thenReturn(aaiResponseServices);
- when(roleValidator.isServicePermitted(eq(GLOBAL_CUSTOMER_ID), anyString())).thenReturn(Boolean.TRUE);
-
- AaiResponse actualResponse = aaiService.getSubscriberData(SUBSCRIBER_ID, roleValidator);
- List<ServiceSubscription> actualServiceSubscriptions = ((AaiResponse<Services>) actualResponse)
- .getT().serviceSubscriptions.serviceSubscription;
-
- assertThat(actualResponse).isEqualTo(aaiResponseServices);
- assertThat(actualServiceSubscriptions).allMatch(s -> s.isPermitted);
- }
-
- @Test
- public void shouldGetServiceInstanceEmptySearchResults() {
- ServiceInstancesSearchResults serviceInstancesSearchResults = new ServiceInstancesSearchResults();
- AaiResponse<ServiceInstancesSearchResults> emptyResponse = new AaiResponse<>(serviceInstancesSearchResults,
- null, HttpStatus.SC_OK);
-
- AaiResponse actualResponse = aaiService.getServiceInstanceSearchResults(null, null,
- null, null, null);
-
- assertThat(actualResponse).isEqualToComparingFieldByFieldRecursively(emptyResponse);
- }
-
- @Test
- public void shouldGetVersionByInvariantId() {
- Response response = mock(Response.class);
- when(aaiClient.getVersionByInvariantId(any())).thenReturn(response);
-
- Response actualResponse = aaiService.getVersionByInvariantId(any());
-
- assertThat(actualResponse).isEqualTo(response);
- }
-
- @Test
- public void shouldGetSpecificPnf() {
- AaiResponse<Pnf> expectedResponse = new AaiResponse<>(Pnf.builder().build(), null, HttpStatus.SC_OK);
- when(aaiClient.getSpecificPnf(anyString())).thenReturn(expectedResponse);
-
- AaiResponse<Pnf> actualResponse = aaiService.getSpecificPnf(anyString());
-
- assertThat(actualResponse).isEqualTo(expectedResponse);
- }
-
- @Test
- public void shouldGetPnfData() {
- when(aaiClient.getPNFData(anyString(), anyString(), anyString(), anyString(), anyString(), anyString(),
- anyString())).thenReturn(aaiResponse);
-
- AaiResponse actualResponse = aaiService.getPNFData(anyString(), anyString(), anyString(), anyString(),
- anyString(), anyString(), anyString());
-
- assertThat(actualResponse).isEqualTo(aaiResponse);
- }
-
- @Test
- public void shouldGetServices() {
- org.onap.vid.aai.model.AaiGetServicesRequestModel.Service s1 =
- createService("ID1", "V1", "D1");
- org.onap.vid.aai.model.AaiGetServicesRequestModel.Service s2 =
- createService("ID2", "V2", "D2");
-
- GetServicesAAIRespone services = new GetServicesAAIRespone();
- services.service = Arrays.asList(s1, s2);
-
- AaiResponse<GetServicesAAIRespone> aaiResponseServices =
- new AaiResponse<>(services, null, HttpStatus.SC_OK);
-
- when(aaiClient.getServices()).thenReturn(aaiResponseServices);
-
- Object actualObjectOfResponse = aaiService.getServices(roleValidator).getT();
-
- assertThat(actualObjectOfResponse).isNotNull();
- assertThat(((GetServicesAAIRespone) actualObjectOfResponse).service).allMatch(s -> s.isPermitted);
- }
-
- @Test
- public void shouldGetTenants() {
- GetTenantsResponse tenant1 = new GetTenantsResponse("REGION_ID1", "CLOUD_OWNER1",
- "TENANT_NAME1", "TENANT_ID1", true);
- GetTenantsResponse tenant2 = new GetTenantsResponse("REGION_ID2", "CLOUD_OWNER2",
- "TENANT_NAME2", "TENANT_ID2", false);
- GetTenantsResponse[] tenants = {tenant1, tenant2};
- AaiResponse<GetTenantsResponse[]> aaiGetTenantsResponse = new AaiResponse<>(tenants,
- null, HttpStatus.SC_OK);
-
- when(aaiClient.getTenants(anyString(), anyString())).thenReturn(aaiGetTenantsResponse);
- when(roleValidator.isTenantPermitted(anyString(), anyString(), anyString()))
- .thenReturn(Boolean.TRUE);
-
- GetTenantsResponse[] actualResponses = aaiService
- .getTenants(anyString(), anyString(), roleValidator).getT();
-
- assertThat(actualResponses).isNotNull();
- assertThat(actualResponses.length).isEqualTo(2);
- assertThat(actualResponses).allMatch(tenant -> tenant.isPermitted);
- }
-
- @Test
- public void shouldGetVNFDataWithoutFiltering() {
- when(aaiClient.getVNFData(anyString(), anyString(), anyString())).thenReturn(aaiResponse);
-
- AaiResponse actualResponse = aaiService.getVNFData(anyString(), anyString(), anyString());
+ private static final String GLOBAL_CUSTOMER_ID = "GLOBAL_CUSTOMER_ID";
+ private static final String CLOUD_REGION_ID = "CLOUD_REGION_ID";
+ private static final String VNF_TYPE = "VNF_TYPE";
+ private static final String TENANT_ID = "TENANT_ID";
+ private static final String TENANT_NAME = "TENANT_NAME";
+ private static final String SERVICE_TYPE = "SERVICE_TYPE";
+ private static final String CORRECT_VALUE = "CORRECT_VALUE";
+ private static final String SUBSCRIBER_ID = "SUBSCRIBER_ID_EXPECTED";
+ private static final String STATUS_TEXT = "STATUS_TEXT";
+ private static final String GLOBAL_SUBSCRIBER_ID = "GLOBAL_SUBSCRIBER_ID";
+ private static final String GLOBAL_SUBSCRIBER_ID_NULL_RESPONSE = "ID_NULL";
+ private static final String VNF_INSTANCE_ID_OK = "VNF_INSTANCE_ID_OK";
+ private static final String VNF_INSTANCE_ID_FAIL = "VNF_INSTANCE_ID_FAIL";
+ private static final String PARENT_NAME = "PARENT_NAME";
+ private static final String PARENT_ID = "PARENT_ID";
+ private static final String INVARIANT_ID = "INVARIANT_ID";
+ private static final String GROUP_TYPE_FAILING = "GROUP_TYPE_FAILING";
+ private static final String GROUP_ROLE_OK = "GROUP_ROLE_OK";
+ private static final String GROUP_ROLE_FAILING = "GROUP_ROLE_FAILING";
+ private static final String group_type_ok = "GROUP_TYPE_OK";
+ private static final String CLOUD_TYPE = "CLOUD_TYPE";
+
+ @Mock
+ private HttpResponse<SubscriberList> responseAllSubscribers;
+ @Mock
+ private AaiResponse<OperationalEnvironmentList> aaiResponseOpEnvList;
+ @Mock
+ private AaiResponse aaiResponse;
+ @Mock
+ private AaiResponse<JsonNode> aaiResponseJsonNode;
+ @Mock
+ private RoleValidator roleValidator;
+
+ @Mock
+ private AaiClientInterface aaiClient;
+ @Mock
+ private AaiOverTLSClientInterface aaiOverTLSClient;
+ @Mock
+ private AaiResponseTranslator aaiResponseTranslator;
+ @Mock
+ private AAIServiceTree aaiServiceTree;
+ @Spy
+ private ExecutorService executorService = Executors.newFixedThreadPool(1);
+
+ @InjectMocks
+ private AaiServiceImpl aaiService;
+
+ @Test
+ public void shouldGetFullSubscriberListWithoutValidator() {
+ when(aaiOverTLSClient.getAllSubscribers()).thenReturn(responseAllSubscribers);
+
+ HttpResponse<SubscriberList> actualResponse = aaiService.getFullSubscriberList();
+
+ assertThat(actualResponse).isEqualTo(responseAllSubscribers);
+ }
+
+ @Test
+ public void shouldGetFullSubscriberListWithValidator() {
+ Subscriber subscriber = createSubscriber();
+ SubscriberList subscriberList = new SubscriberList(Collections.singletonList(subscriber));
+
+ when(aaiOverTLSClient.getAllSubscribers()).thenReturn(responseAllSubscribers);
+ when(responseAllSubscribers.getBody()).thenReturn(subscriberList);
+ when(responseAllSubscribers.getStatusText()).thenReturn(STATUS_TEXT);
+ when(responseAllSubscribers.getStatus()).thenReturn(HttpStatus.SC_OK);
+ SubscriberFilteredResults expectedSubscribers = new SubscriberFilteredResults(roleValidator, subscriberList,
+ STATUS_TEXT, HttpStatus.SC_OK);
+
+ SubscriberFilteredResults actualSubscribers = aaiService.getFullSubscriberList(roleValidator);
+
+ assertThat(actualSubscribers.getHttpCode()).isEqualTo(expectedSubscribers.getHttpCode());
+ assertThat(actualSubscribers.getErrorMessage()).isEqualTo(expectedSubscribers.getErrorMessage());
+ }
+
+ @Test
+ public void shouldGetOperationalEnvironments() {
+ when(aaiClient.getOperationalEnvironments(anyString(), anyString()))
+ .thenReturn(aaiResponseOpEnvList);
+
+ AaiResponse<OperationalEnvironmentList> expectedEnvList =
+ aaiService.getOperationalEnvironments(anyString(), anyString());
+
+ assertThat(expectedEnvList).isEqualTo(aaiResponseOpEnvList);
+ }
+
+ @Test
+ public void shouldGetSubscriberData() {
+ Services services = createAaiResponseServices();
+ AaiResponse<Services> aaiResponseServices = new AaiResponse<>(services, null, HttpStatus.SC_OK);
+
+ when(aaiClient.getSubscriberData(SUBSCRIBER_ID, false)).thenReturn(aaiResponseServices);
+ when(roleValidator.isServicePermitted(eq(GLOBAL_CUSTOMER_ID), anyString())).thenReturn(Boolean.TRUE);
+
+ AaiResponse actualResponse = aaiService.getSubscriberData(SUBSCRIBER_ID, roleValidator, false);
+ List<ServiceSubscription> actualServiceSubscriptions = ((AaiResponse<Services>) actualResponse)
+ .getT().serviceSubscriptions.serviceSubscription;
+
+ assertThat(actualResponse).isEqualTo(aaiResponseServices);
+ assertThat(actualServiceSubscriptions).allMatch(s -> s.isPermitted);
+ }
+
+ @Test
+ public void shouldGetServiceInstanceEmptySearchResults() {
+ ServiceInstancesSearchResults serviceInstancesSearchResults = new ServiceInstancesSearchResults();
+ AaiResponse<ServiceInstancesSearchResults> emptyResponse = new AaiResponse<>(serviceInstancesSearchResults,
+ null, HttpStatus.SC_OK);
+
+ AaiResponse actualResponse = aaiService.getServiceInstanceSearchResults(null, null,
+ null, null, null);
+
+ assertThat(actualResponse).isEqualToComparingFieldByFieldRecursively(emptyResponse);
+ }
+
+ @Test
+ public void shouldGetVersionByInvariantId() {
+ Response response = mock(Response.class);
+ when(aaiClient.getVersionByInvariantId(any())).thenReturn(response);
+
+ Response actualResponse = aaiService.getVersionByInvariantId(any());
+
+ assertThat(actualResponse).isEqualTo(response);
+ }
+
+ @Test
+ public void shouldGetSpecificPnf() {
+ AaiResponse<Pnf> expectedResponse = new AaiResponse<>(Pnf.builder().build(), null, HttpStatus.SC_OK);
+ when(aaiClient.getSpecificPnf(anyString())).thenReturn(expectedResponse);
+
+ AaiResponse<Pnf> actualResponse = aaiService.getSpecificPnf(anyString());
- assertThat(actualResponse).isEqualTo(aaiResponse);
- }
+ assertThat(actualResponse).isEqualTo(expectedResponse);
+ }
- @Test
- public void shouldGetVNFDataWithFiltering() {
- VnfResult vnfResult1 = createVnfResult("ID1", "generic-vnf");
- VnfResult vnfResult2 = createVnfResult("ID2", "service-instance");
- VnfResult vnfResult3 = createVnfResult("ID3", "anything-else");
+ @Test
+ public void shouldGetPnfData() {
+ when(aaiClient.getPNFData(anyString(), anyString(), anyString(), anyString(), anyString(), anyString(),
+ anyString())).thenReturn(aaiResponse);
- List<VnfResult> vnfResults = Arrays.asList(vnfResult1, vnfResult2, vnfResult3);
- AaiResponse<AaiGetVnfResponse> aaiResponseGetVnfResponse = createAaiResponseVnfResponse(vnfResults);
+ AaiResponse actualResponse = aaiService.getPNFData(anyString(), anyString(), anyString(), anyString(),
+ anyString(), anyString(), anyString());
- vnfResults = Arrays.asList(vnfResult1, vnfResult2);
- AaiResponse<AaiGetVnfResponse> expectedResponseWithReturnedVnfs = createAaiResponseVnfResponse(vnfResults);
- AaiResponse expectedResponseWithoutReturnedVnfs = new AaiResponse();
+ assertThat(actualResponse).isEqualTo(aaiResponse);
+ }
- when(aaiClient.getVNFData(GLOBAL_SUBSCRIBER_ID, SERVICE_TYPE)).thenReturn(aaiResponseGetVnfResponse);
- when(aaiClient.getVNFData(GLOBAL_SUBSCRIBER_ID_NULL_RESPONSE, SERVICE_TYPE)).thenReturn(null);
+ @Test
+ public void shouldGetServices() {
+ org.onap.vid.aai.model.AaiGetServicesRequestModel.Service s1 =
+ createService("ID1", "V1", "D1");
+ org.onap.vid.aai.model.AaiGetServicesRequestModel.Service s2 =
+ createService("ID2", "V2", "D2");
- AaiResponse<AaiGetVnfResponse> actualResponseWithReturnedVnfs =
- aaiService.getVNFData(GLOBAL_SUBSCRIBER_ID, SERVICE_TYPE);
- AaiResponse<AaiGetVnfResponse> actualResponseWithoutReturnedVnfs =
- aaiService.getVNFData(GLOBAL_SUBSCRIBER_ID_NULL_RESPONSE, SERVICE_TYPE);
+ GetServicesAAIRespone services = new GetServicesAAIRespone();
+ services.service = Arrays.asList(s1, s2);
- assertThat(actualResponseWithReturnedVnfs)
- .isEqualToComparingFieldByFieldRecursively(expectedResponseWithReturnedVnfs);
- assertThat(actualResponseWithoutReturnedVnfs)
- .isEqualToComparingFieldByField(expectedResponseWithoutReturnedVnfs);
- }
+ AaiResponse<GetServicesAAIRespone> aaiResponseServices =
+ new AaiResponse<>(services, null, HttpStatus.SC_OK);
- @Test
- public void shouldGetAaiZones() {
- when(aaiClient.getAllAicZones()).thenReturn(aaiResponse);
+ when(aaiClient.getServices()).thenReturn(aaiResponseServices);
- AaiResponse actualResponse = aaiService.getAaiZones();
+ Object actualObjectOfResponse = aaiService.getServices(roleValidator).getT();
- assertThat(actualResponse).isEqualTo(aaiResponse);
- }
-
- @Test
- public void shouldGetAicZoneForPnf() {
- ServiceRelationships relationsService = createServiceRelationships();
- AaiResponse<ServiceRelationships> expectedServiceInstanceResp =
- new AaiResponse<>(relationsService, null, HttpStatus.SC_OK);
- AaiResponse<String> expectedResponse = new AaiResponse<>(CORRECT_VALUE, null, HttpStatus.SC_OK);
+ assertThat(actualObjectOfResponse).isNotNull();
+ assertThat(((GetServicesAAIRespone) actualObjectOfResponse).service).allMatch(s -> s.isPermitted);
+ }
- when(aaiClient.getServiceInstance(anyString(), anyString(), anyString()))
- .thenReturn(expectedServiceInstanceResp);
+ @Test
+ public void shouldGetTenants() {
+ GetTenantsResponse tenant1 = new GetTenantsResponse("REGION_ID1", "CLOUD_OWNER1",
+ "TENANT_NAME1", "TENANT_ID1", true);
+ GetTenantsResponse tenant2 = new GetTenantsResponse("REGION_ID2", "CLOUD_OWNER2",
+ "TENANT_NAME2", "TENANT_ID2", false);
+ GetTenantsResponse[] tenants = {tenant1, tenant2};
+ AaiResponse<GetTenantsResponse[]> aaiGetTenantsResponse = new AaiResponse<>(tenants,
+ null, HttpStatus.SC_OK);
- AaiResponse actualResponse = aaiService.getAicZoneForPnf(anyString(), anyString(), anyString());
+ when(aaiClient.getTenants(anyString(), anyString())).thenReturn(aaiGetTenantsResponse);
+ when(roleValidator.isTenantPermitted(anyString(), anyString(), anyString()))
+ .thenReturn(Boolean.TRUE);
- assertThat(actualResponse).isEqualToComparingFieldByField(expectedResponse);
- }
+ GetTenantsResponse[] actualResponses = aaiService
+ .getTenants(anyString(), anyString(), roleValidator).getT();
- @Test
- public void shouldGetNodeTemplateInstances() {
- when(aaiClient.getNodeTemplateInstances(anyString(), anyString(), anyString(),
- anyString(), anyString())).thenReturn(aaiResponse);
+ assertThat(actualResponses).isNotNull();
+ assertThat(actualResponses.length).isEqualTo(2);
+ assertThat(actualResponses).allMatch(tenant -> tenant.isPermitted);
+ }
- AaiResponse expectedResponse = aaiService.getNodeTemplateInstances(anyString(), anyString(), anyString(),
- anyString(), anyString());
+ @Test
+ public void shouldGetVNFDataWithoutFiltering() {
+ when(aaiClient.getVNFData(anyString(), anyString(), anyString())).thenReturn(aaiResponse);
- assertThat(expectedResponse).isEqualTo(aaiResponse);
- }
+ AaiResponse actualResponse = aaiService.getVNFData(anyString(), anyString(), anyString());
- @Test
- public void shouldGetNetworkCollectionDetails() {
- when(aaiClient.getNetworkCollectionDetails(anyString())).thenReturn(aaiResponse);
-
- AaiResponse expectedResponse = aaiService.getNetworkCollectionDetails(anyString());
+ assertThat(actualResponse).isEqualTo(aaiResponse);
+ }
- assertThat(expectedResponse).isEqualTo(aaiResponse);
- }
+ @Test
+ public void shouldGetVNFDataWithFiltering() {
+ VnfResult vnfResult1 = createVnfResult("ID1", "generic-vnf");
+ VnfResult vnfResult2 = createVnfResult("ID2", "service-instance");
+ VnfResult vnfResult3 = createVnfResult("ID3", "anything-else");
- @Test
- public void shouldGetInstanceGroupsByCloudRegion() {
- AaiGetInstanceGroupsByCloudRegion aaiGetInstanceGroupsByCloudRegion =
- mock(AaiGetInstanceGroupsByCloudRegion.class);
- AaiResponse<AaiGetInstanceGroupsByCloudRegion> expectedResponse =
- new AaiResponse<>(aaiGetInstanceGroupsByCloudRegion, null, HttpStatus.SC_OK);
+ List<VnfResult> vnfResults = Arrays.asList(vnfResult1, vnfResult2, vnfResult3);
+ AaiResponse<AaiGetVnfResponse> aaiResponseGetVnfResponse = createAaiResponseVnfResponse(vnfResults);
- when(aaiClient.getInstanceGroupsByCloudRegion(anyString(), anyString(), anyString()))
- .thenReturn(expectedResponse);
- AaiResponse<AaiGetInstanceGroupsByCloudRegion> actualResponse =
- aaiService.getInstanceGroupsByCloudRegion(anyString(), anyString(), anyString());
+ vnfResults = Arrays.asList(vnfResult1, vnfResult2);
+ AaiResponse<AaiGetVnfResponse> expectedResponseWithReturnedVnfs = createAaiResponseVnfResponse(vnfResults);
+ AaiResponse expectedResponseWithoutReturnedVnfs = new AaiResponse();
- assertThat(actualResponse).isEqualTo(expectedResponse);
- }
+ when(aaiClient.getVNFData(GLOBAL_SUBSCRIBER_ID, SERVICE_TYPE)).thenReturn(aaiResponseGetVnfResponse);
+ when(aaiClient.getVNFData(GLOBAL_SUBSCRIBER_ID_NULL_RESPONSE, SERVICE_TYPE)).thenReturn(null);
- @Test
- public void shouldGetServicesByDistributionStatus() {
- Result resultWithModelType = createResult("MODEL_TYPE1", "1");
- Result resultWithEmptyModelType = createResult(null, "2");
- Result resultWithoutModel = new Result();
- resultWithoutModel.setModel(null);
- Result resultWithoutValidModel = createResultWithoutValidModel();
- List<Result> results = Arrays.asList(resultWithModelType, resultWithEmptyModelType, resultWithoutModel,
- resultWithoutValidModel);
+ AaiResponse<AaiGetVnfResponse> actualResponseWithReturnedVnfs =
+ aaiService.getVNFData(GLOBAL_SUBSCRIBER_ID, SERVICE_TYPE);
+ AaiResponse<AaiGetVnfResponse> actualResponseWithoutReturnedVnfs =
+ aaiService.getVNFData(GLOBAL_SUBSCRIBER_ID_NULL_RESPONSE, SERVICE_TYPE);
- GetServiceModelsByDistributionStatusResponse serviceModels = new GetServiceModelsByDistributionStatusResponse();
- serviceModels.setResults(results);
+ assertThat(actualResponseWithReturnedVnfs)
+ .isEqualToComparingFieldByFieldRecursively(expectedResponseWithReturnedVnfs);
+ assertThat(actualResponseWithoutReturnedVnfs)
+ .isEqualToComparingFieldByField(expectedResponseWithoutReturnedVnfs);
+ }
- AaiResponse<GetServiceModelsByDistributionStatusResponse> serviceModelsByDistributionStatusResponse
- = new AaiResponse<>(serviceModels, null, HttpStatus.SC_OK);
+ @Test
+ public void shouldGetAaiZones() {
+ when(aaiClient.getAllAicZones()).thenReturn(aaiResponse);
- Service[] expectedServices = {
- createService("MODEL_TYPE1", "1"),
- createService("", "2")
- };
+ AaiResponse actualResponse = aaiService.getAaiZones();
- when(aaiClient.getServiceModelsByDistributionStatus()).thenReturn(serviceModelsByDistributionStatusResponse);
- Collection<Service> actualServices = aaiService.getServicesByDistributionStatus();
+ assertThat(actualResponse).isEqualTo(aaiResponse);
+ }
+
+ @Test
+ public void shouldGetAicZoneForPnf() {
+ ServiceRelationships relationsService = createServiceRelationships();
+ AaiResponse<ServiceRelationships> expectedServiceInstanceResp =
+ new AaiResponse<>(relationsService, null, HttpStatus.SC_OK);
+ AaiResponse<String> expectedResponse = new AaiResponse<>(CORRECT_VALUE, null, HttpStatus.SC_OK);
+
+ when(aaiClient.getServiceInstance(anyString(), anyString(), anyString()))
+ .thenReturn(expectedServiceInstanceResp);
+
+ AaiResponse actualResponse = aaiService.getAicZoneForPnf(anyString(), anyString(), anyString());
- assertThat(actualServices)
- .hasSize(2)
- .usingFieldByFieldElementComparator()
- .containsExactly(expectedServices);
- }
+ assertThat(actualResponse).isEqualToComparingFieldByField(expectedResponse);
+ }
+
+ @Test
+ public void shouldGetNodeTemplateInstances() {
+ when(aaiClient.getNodeTemplateInstances(anyString(), anyString(), anyString(),
+ anyString(), anyString())).thenReturn(aaiResponse);
+
+ AaiResponse expectedResponse = aaiService.getNodeTemplateInstances(anyString(), anyString(), anyString(),
+ anyString(), anyString());
+
+ assertThat(expectedResponse).isEqualTo(aaiResponse);
+ }
- @Test
- public void shouldReturnEmptyListOfServices() {
- AaiResponse<GetServiceModelsByDistributionStatusResponse> emptyResponse
- = new AaiResponse<>(null, null, HttpStatus.SC_OK);
+ @Test
+ public void shouldGetNetworkCollectionDetails() {
+ when(aaiClient.getNetworkCollectionDetails(anyString())).thenReturn(aaiResponse);
+
+ AaiResponse expectedResponse = aaiService.getNetworkCollectionDetails(anyString());
+
+ assertThat(expectedResponse).isEqualTo(aaiResponse);
+ }
+
+ @Test
+ public void shouldGetInstanceGroupsByCloudRegion() {
+ AaiGetInstanceGroupsByCloudRegion aaiGetInstanceGroupsByCloudRegion =
+ mock(AaiGetInstanceGroupsByCloudRegion.class);
+ AaiResponse<AaiGetInstanceGroupsByCloudRegion> expectedResponse =
+ new AaiResponse<>(aaiGetInstanceGroupsByCloudRegion, null, HttpStatus.SC_OK);
- when(aaiClient.getServiceModelsByDistributionStatus()).thenReturn(emptyResponse);
- Collection<Service> actualServices = aaiService.getServicesByDistributionStatus();
+ when(aaiClient.getInstanceGroupsByCloudRegion(anyString(), anyString(), anyString()))
+ .thenReturn(expectedResponse);
+ AaiResponse<AaiGetInstanceGroupsByCloudRegion> actualResponse =
+ aaiService.getInstanceGroupsByCloudRegion(anyString(), anyString(), anyString());
- assertThat(actualServices).isEqualTo(Collections.EMPTY_LIST);
- }
+ assertThat(actualResponse).isEqualTo(expectedResponse);
+ }
- @Test
- public void shouldGetServiceInstanceAssociatedPnfs() {
- ServiceRelationships relationsList = createServiceRelationships();
- LogicalLinkResponse logicalLinkResponse = new LogicalLinkResponse();
- logicalLinkResponse.setRelationshipList(relationsList.getRelationshipList());
+ @Test
+ public void shouldGetServicesByDistributionStatus() {
+ Result resultWithModelType = createResult("MODEL_TYPE1", "1");
+ Result resultWithEmptyModelType = createResult(null, "2");
+ Result resultWithoutModel = new Result();
+ resultWithoutModel.setModel(null);
+ Result resultWithoutValidModel = createResultWithoutValidModel();
+ List<Result> results = Arrays.asList(resultWithModelType, resultWithEmptyModelType, resultWithoutModel,
+ resultWithoutValidModel);
- AaiResponse<LogicalLinkResponse> aaiResponseLogicalLinkResponse =
- new AaiResponse<>(logicalLinkResponse, null, HttpStatus.SC_OK);
- AaiResponse<ServiceRelationships> aaiResponseServiceRelations =
- new AaiResponse<>(relationsList, null, HttpStatus.SC_OK);
+ GetServiceModelsByDistributionStatusResponse serviceModels = new GetServiceModelsByDistributionStatusResponse();
+ serviceModels.setResults(results);
- when(aaiClient.getServiceInstance(anyString(), anyString(), anyString()))
- .thenReturn(aaiResponseServiceRelations);
- when(aaiClient.getLogicalLink(anyString())).thenReturn(aaiResponseLogicalLinkResponse);
+ AaiResponse<GetServiceModelsByDistributionStatusResponse> serviceModelsByDistributionStatusResponse
+ = new AaiResponse<>(serviceModels, null, HttpStatus.SC_OK);
+
+ Service[] expectedServices = {
+ createService("MODEL_TYPE1", "1"),
+ createService("", "2")
+ };
+
+ when(aaiClient.getServiceModelsByDistributionStatus()).thenReturn(serviceModelsByDistributionStatusResponse);
+ Collection<Service> actualServices = aaiService.getServicesByDistributionStatus();
+
+ assertThat(actualServices)
+ .hasSize(2)
+ .usingFieldByFieldElementComparator()
+ .containsExactly(expectedServices);
+ }
+ @Test
+ public void shouldReturnEmptyListOfServices() {
+ AaiResponse<GetServiceModelsByDistributionStatusResponse> emptyResponse
+ = new AaiResponse<>(null, null, HttpStatus.SC_OK);
- List<String> expectedPnfs = Collections.singletonList(CORRECT_VALUE);
- List<String> actualPnfs = aaiService.getServiceInstanceAssociatedPnfs(anyString(), anyString(), anyString());
+ when(aaiClient.getServiceModelsByDistributionStatus()).thenReturn(emptyResponse);
+ Collection<Service> actualServices = aaiService.getServicesByDistributionStatus();
- assertThat(actualPnfs).isEqualTo(expectedPnfs);
- }
+ assertThat(actualServices).isEqualTo(Collections.EMPTY_LIST);
+ }
- @Test
- public void shouldGetPortMirroringConfigData() {
- AaiResponseTranslator.PortMirroringConfigData expectedData
- = mock(AaiResponseTranslator.PortMirroringConfigData.class);
+ @Test
+ public void shouldGetServiceInstanceAssociatedPnfs() {
+ ServiceRelationships relationsList = createServiceRelationships();
+ LogicalLinkResponse logicalLinkResponse = new LogicalLinkResponse();
+ logicalLinkResponse.setRelationshipList(relationsList.getRelationshipList());
- when(aaiClient.getCloudRegionAndSourceByPortMirroringConfigurationId(anyString())).thenReturn(aaiResponseJsonNode);
- when(aaiResponseTranslator.extractPortMirroringConfigData(aaiResponseJsonNode)).thenReturn(expectedData);
+ AaiResponse<LogicalLinkResponse> aaiResponseLogicalLinkResponse =
+ new AaiResponse<>(logicalLinkResponse, null, HttpStatus.SC_OK);
+ AaiResponse<ServiceRelationships> aaiResponseServiceRelations =
+ new AaiResponse<>(relationsList, null, HttpStatus.SC_OK);
+
+ when(aaiClient.getServiceInstance(anyString(), anyString(), anyString()))
+ .thenReturn(aaiResponseServiceRelations);
+ when(aaiClient.getLogicalLink(anyString())).thenReturn(aaiResponseLogicalLinkResponse);
- AaiResponseTranslator.PortMirroringConfigData actualData = aaiService.getPortMirroringConfigData(anyString());
- assertThat(actualData).isEqualTo(expectedData);
- }
+ List<String> expectedPnfs = Collections.singletonList(CORRECT_VALUE);
+ List<String> actualPnfs = aaiService.getServiceInstanceAssociatedPnfs(anyString(), anyString(), anyString());
+ assertThat(actualPnfs).isEqualTo(expectedPnfs);
+ }
- @Test
- public void shouldGetInstanceGroupsByVnfInstanceId() {
- List<InstanceGroupInfo> instanceGroupInfo = Collections.singletonList(new InstanceGroupInfo(CORRECT_VALUE));
- AaiGetRelatedInstanceGroupsByVnfId relatedInstanceGroups = new AaiGetRelatedInstanceGroupsByVnfId();
- relatedInstanceGroups.setRelationshipList(createRelationshipList());
-
- AaiResponse<AaiGetRelatedInstanceGroupsByVnfId> correctCodeResponse =
- new AaiResponse<>(relatedInstanceGroups, null, HttpStatus.SC_OK);
-
- AaiResponse<List<InstanceGroupInfo>> expectedCorrectCodeResponse =
- new AaiResponse<>(instanceGroupInfo, null, HttpStatus.SC_OK);
- AaiResponse<AaiGetRelatedInstanceGroupsByVnfId> expectedIncorrectCodeResponse =
- new AaiResponse<>(relatedInstanceGroups, null, HttpStatus.SC_PAYMENT_REQUIRED);
- List<InstanceGroupInfo> expectedCorrectResponseObject = expectedCorrectCodeResponse.getT();
-
- when(aaiClient.getInstanceGroupsByVnfInstanceId(VNF_INSTANCE_ID_OK)).thenReturn(correctCodeResponse);
- when(aaiClient.getInstanceGroupsByVnfInstanceId(VNF_INSTANCE_ID_FAIL)).thenReturn(expectedIncorrectCodeResponse);
-
- AaiResponse actualCorrectCodeResponse = aaiService.getInstanceGroupsByVnfInstanceId(VNF_INSTANCE_ID_OK);
- AaiResponse actualIncorrectCodeResponse = aaiService.getInstanceGroupsByVnfInstanceId(VNF_INSTANCE_ID_FAIL);
-
- List<InstanceGroupInfo> actualCorrectResponseObject =
- (List<InstanceGroupInfo>) actualCorrectCodeResponse.getT();
-
- assertThat(actualCorrectResponseObject)
- .usingFieldByFieldElementComparator()
- .hasSameElementsAs(expectedCorrectResponseObject);
-
- assertThat(actualIncorrectCodeResponse).isEqualTo(expectedIncorrectCodeResponse);
- }
-
- @Test
- public void shouldGetHomingDataByVfModule() {
- GetTenantsResponse expectedResponse = new GetTenantsResponse();
- when(aaiClient.getHomingDataByVfModule(anyString(), anyString())).thenReturn(expectedResponse);
-
- GetTenantsResponse actualResponse = aaiService.getHomingDataByVfModule(anyString(), anyString());
- assertThat(actualResponse).isEqualTo(expectedResponse);
- }
-
- @Test
- public void shouldSearchGroupMembers() {
- Properties properties = createProperties();
- Map<String, Properties> regionsAndTenants = createRegionsAndTenantsMap(properties);
-
- AAITreeNode validTreeNode = new AAITreeNode();
- addAdditionalPropertiesToAaiTreeNode(validTreeNode);
- List<AAITreeNode> validNodes = Arrays.asList(validTreeNode, validTreeNode);
-
- AAITreeNode validBranch = createTree(validNodes);
- addAdditionalPropertiesToAaiTreeNode(validBranch);
- List<AAITreeNode> testedBranches = Collections.singletonList(validBranch);
-
- AAITreeNode testedTree = createTree(testedBranches);
-
- RelatedVnf expectedVnf = createExpectedVnf(validBranch);
- List<RelatedVnf> expectedResult = Collections.singletonList(expectedVnf);
-
- when(aaiServiceTree.buildAAITree(anyString(), any())).thenReturn(Collections.singletonList(testedTree));
- when(aaiClient.getCloudRegionAndTenantByVnfId(anyString())).thenReturn(regionsAndTenants);
-
- List<RelatedVnf> actualGroupMembers = aaiService.searchGroupMembers(GLOBAL_CUSTOMER_ID, SERVICE_TYPE,
- INVARIANT_ID, GROUP_TYPE_FAILING, GROUP_ROLE_FAILING);
-
- assertThat(actualGroupMembers)
- .usingFieldByFieldElementComparator()
- .hasSameElementsAs(expectedResult);
- }
-
- @Test
- public void shouldGetPortMirroringSourcePorts() {
- PortDetailsTranslator.PortDetails details = mock(PortDetailsTranslator.PortDetails.class);
- List<PortDetailsTranslator.PortDetails> expectedDetailsList = Arrays.asList(
- details, details, details
- );
-
- when(aaiClient.getPortMirroringSourcePorts(anyString())).thenReturn(expectedDetailsList);
- List<PortDetailsTranslator.PortDetails> actualDetails = aaiService.getPortMirroringSourcePorts(anyString());
-
- assertThat(actualDetails).isEqualTo(expectedDetailsList);
- }
-
- @Test
- public void shouldGetAAIServiceTree() throws JsonProcessingException {
- ServiceInstance serviceInstance = mock(ServiceInstance.class);
- String expectedResult = new ObjectMapper().writeValueAsString(serviceInstance);
-
- when(aaiServiceTree.getServiceInstanceTopology(anyString(), anyString(), anyString()))
- .thenReturn(serviceInstance);
- String actualResult = aaiService.getAAIServiceTree(anyString(), anyString(), anyString());
-
- assertThat(actualResult).isEqualTo(expectedResult);
- }
-
- @NotNull
- private Map<String, Properties> createRegionsAndTenantsMap(Properties properties) {
- Map<String, Properties> regionsAndTenants = new HashMap<>();
- regionsAndTenants.put("tenant", properties);
- regionsAndTenants.put("cloud-region", properties);
- return regionsAndTenants;
- }
-
- private Properties createProperties() {
- Properties properties = new Properties();
- properties.setTenantId(TENANT_ID);
- properties.setTenantName(TENANT_NAME);
- properties.setCloudRegionId(CLOUD_REGION_ID);
- return properties;
- }
-
- @NotNull
- private RelatedVnf createExpectedVnf(AAITreeNode validBranch) {
- RelatedVnf expectedVnf = RelatedVnf.from(validBranch);
- expectedVnf.setTenantId(TENANT_ID);
- expectedVnf.setTenantName(TENANT_NAME);
- expectedVnf.setLcpCloudRegionId(CLOUD_REGION_ID);
- expectedVnf.setServiceInstanceId(PARENT_ID);
- expectedVnf.setServiceInstanceName(PARENT_NAME);
- expectedVnf.setInstanceType(VNF_TYPE);
-
- return expectedVnf;
- }
-
-
- private AAITreeNode createTree(List<AAITreeNode> children) {
- AAITreeNode tree = new AAITreeNode();
- tree.addChildren(children);
- tree.setId(PARENT_ID);
- tree.setName(PARENT_NAME);
- return tree;
- }
-
- private void addAdditionalPropertiesToAaiTreeNode(AAITreeNode tree) {
- Map<String, Object> additionalProperties = new HashMap<>();
- additionalProperties.put("instance-group-role", GROUP_ROLE_OK);
- additionalProperties.put("instance-group-type", group_type_ok);
- additionalProperties.put("vnf-type", VNF_TYPE);
- additionalProperties.put("cloud-region", CLOUD_TYPE);
- tree.setAdditionalProperties(additionalProperties);
- }
-
- private org.onap.vid.asdc.beans.Service createService(String category, String suffix) {
- return new Service.ServiceBuilder()
- .setUuid("MODELVER_VERSION_ID" + suffix)
- .setInvariantUUID("MODEL_INVARIANT_NAME" + suffix)
- .setCategory(category)
- .setVersion("MODELVER_VERSION" + suffix)
- .setName("MODELVER_NAME" + suffix)
- .setDistributionStatus("MODELVER_DIST_STATUS" + suffix)
- .setToscaModelURL(null)
- .setLifecycleState(null)
- .setArtifacts(null)
- .setResources(null)
- .build();
- }
-
- @NotNull
- private Result createResultWithoutValidModel() {
- ModelVers modelVers = new ModelVers();
- modelVers.setModelVer(Collections.singletonList(new ModelVer()));
-
- Model model = new Model();
- model.setModelVers(modelVers);
-
- Result result1 = new Result();
- result1.setModel(model);
- return result1;
- }
-
- @NotNull
- private Result createResult(String modelType, String suffix) {
- ModelVer modelVer = new ModelVer();
- modelVer.setModelVersionId("MODELVER_VERSION_ID" + suffix);
- modelVer.setModelVersion("MODELVER_VERSION" + suffix);
- modelVer.setModelName("MODELVER_NAME" + suffix);
- modelVer.setDistributionStatus("MODELVER_DIST_STATUS" + suffix);
-
- ModelVers modelVers = new ModelVers();
- modelVers.setModelVer(Collections.singletonList(modelVer));
-
- Model model = new Model();
- model.setModelType(modelType);
- model.setModelInvariantId("MODEL_INVARIANT_NAME" + suffix);
- model.setModelVers(modelVers);
-
- Result result = new Result();
- result.setModel(model);
- return result;
- }
-
- @NotNull
- private ServiceRelationships createServiceRelationships() {
- RelationshipList relationsList = createRelationshipList(CORRECT_VALUE);
- ServiceRelationships relationsService = new ServiceRelationships();
- relationsService.setRelationshipList(relationsList);
- return relationsService;
- }
-
- @NotNull
- private RelationshipList createRelationshipList(String expectedValue) {
- List<RelationshipData> relationsDataList = createRelationshipDataList(expectedValue);
- return createRelationshipList(relationsDataList);
- }
-
- @NotNull
- private RelationshipList createRelationshipList(List<RelationshipData> relationsDataList) {
- Relationship relation1 = crateRelationship("any", relationsDataList);
- Relationship relation2 = crateRelationship("zone", relationsDataList);
- Relationship relation3 = crateRelationship("logical-link", relationsDataList);
- Relationship relation4 = crateRelationship("lag-interface", relationsDataList);
- Relationship relation5 = crateRelationship("pnf", relationsDataList);
-
- RelationshipList relationsList = new RelationshipList();
- relationsList.setRelationship(Arrays.asList(relation1, relation2, relation3, relation4, relation5));
- return relationsList;
- }
-
- @NotNull
- private List<RelationshipData> createRelationshipDataList(String expectedValue) {
- RelationshipData relationData1 = createRelationshipData("any-key", "incorrect_key");
- RelationshipData relationData2 = createRelationshipData("zone.zone-id", expectedValue);
- RelationshipData relationData3 = createRelationshipData("logical-link.link-name", expectedValue);
- RelationshipData relationData4 = createRelationshipData("pnf.pnf-name", expectedValue);
-
- return Arrays.asList(relationData1, relationData2, relationData3, relationData4);
- }
-
- @NotNull
- private Relationship crateRelationship(String relatedTo, List<RelationshipData> relationsDataList) {
- Relationship relation = new Relationship();
- relation.setRelatedTo(relatedTo);
- relation.setRelationDataList(relationsDataList);
- return relation;
- }
-
- @NotNull
- private RelationshipData createRelationshipData(String key, String value) {
- RelationshipData relationData = new RelationshipData();
- relationData.setRelationshipKey(key);
- relationData.setRelationshipValue(value);
- return relationData;
- }
-
- private org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.RelationshipList createRelationshipList() {
- RelatedToProperty property1 =
- createRelatedToProperty("instance-group.instance-group-name", CORRECT_VALUE);
- RelatedToProperty property2 =
- createRelatedToProperty("anything-key", "anything-value");
- List<RelatedToProperty> properties = Arrays.asList(property1, property2);
-
- org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.Relationship relationship1 =
- createRelationship("instance-group", properties);
- org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.Relationship relationship2 =
- createRelationship("any-key", properties);
-
- List<org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.Relationship> relationships =
- Arrays.asList(relationship1, relationship2);
-
- org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.RelationshipList relationshipList =
- new org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.RelationshipList();
- relationshipList.setRelationship(relationships);
-
- return relationshipList;
- }
-
- @NotNull
- private org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.Relationship createRelationship(String relatedTo,
- List<RelatedToProperty> relatedToPropertyList) {
- org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.Relationship relationship1 =
- new org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.Relationship();
- relationship1.setRelatedTo(relatedTo);
- relationship1.setRelatedToPropertyList(relatedToPropertyList);
- return relationship1;
- }
-
- @NotNull
- private RelatedToProperty createRelatedToProperty(String key, String value) {
- RelatedToProperty prop = new RelatedToProperty();
- prop.setPropertyKey(key);
- prop.setPropertyValue(value);
- return prop;
- }
-
- @NotNull
- private AaiResponse<AaiGetVnfResponse> createAaiResponseVnfResponse(List<VnfResult> vnfResults) {
- AaiGetVnfResponse vnfResponse = new AaiGetVnfResponse();
- vnfResponse.setResults(vnfResults);
- return new AaiResponse<>(vnfResponse, null, HttpStatus.SC_OK);
- }
-
- private VnfResult createVnfResult(String id, String nodeType) {
- VnfResult result = new VnfResult();
- result.setJsonId(id);
- result.setJsonNodeType(nodeType);
- return result;
- }
-
-
- private org.onap.vid.aai.model.AaiGetServicesRequestModel.Service createService(String serviceId,
- String resourceVersion,
- String serviceDescription) {
- org.onap.vid.aai.model.AaiGetServicesRequestModel.Service service
- = new org.onap.vid.aai.model.AaiGetServicesRequestModel.Service();
- service.isPermitted = false;
- service.resourceVersion = resourceVersion;
- service.serviceDescription = serviceDescription;
- service.serviceId = serviceId;
- return service;
- }
-
- @NotNull
- private Services createAaiResponseServices() {
- ServiceSubscription sub1 = new ServiceSubscription();
- sub1.isPermitted = false;
- sub1.serviceType = "serviceSubsType1";
-
- ServiceSubscription sub2 = new ServiceSubscription();
- sub2.isPermitted = true;
- sub2.serviceType = "serviceSubsType2";
-
- ServiceSubscriptions serviceSubs = new ServiceSubscriptions();
- serviceSubs.serviceSubscription = Collections.singletonList(sub2);
-
- Services services = new Services();
- services.globalCustomerId = GLOBAL_CUSTOMER_ID;
- services.resourceVersion = "v-1";
- services.subscriberName = "name-1";
- services.subscriberType = "type-1";
- services.serviceSubscriptions = serviceSubs;
- return services;
- }
-
- @NotNull
- private Subscriber createSubscriber() {
- Subscriber subscriber = new Subscriber();
- subscriber.globalCustomerId = "id-1";
- subscriber.resourceVersion = "v-1";
- subscriber.subscriberName = "name-1";
- subscriber.subscriberType = "type-1";
- return subscriber;
- }
+ @Test
+ public void shouldGetPortMirroringConfigData() {
+ AaiResponseTranslator.PortMirroringConfigData expectedData
+ = mock(AaiResponseTranslator.PortMirroringConfigData.class);
+
+ when(aaiClient.getCloudRegionAndSourceByPortMirroringConfigurationId(anyString()))
+ .thenReturn(aaiResponseJsonNode);
+ when(aaiResponseTranslator.extractPortMirroringConfigData(aaiResponseJsonNode)).thenReturn(expectedData);
+
+ AaiResponseTranslator.PortMirroringConfigData actualData = aaiService.getPortMirroringConfigData(anyString());
+ assertThat(actualData).isEqualTo(expectedData);
+ }
+
+
+ @Test
+ public void shouldGetInstanceGroupsByVnfInstanceId() {
+ List<InstanceGroupInfo> instanceGroupInfo = Collections.singletonList(new InstanceGroupInfo(CORRECT_VALUE));
+ AaiGetRelatedInstanceGroupsByVnfId relatedInstanceGroups = new AaiGetRelatedInstanceGroupsByVnfId();
+ relatedInstanceGroups.setRelationshipList(createRelationshipList());
+
+ AaiResponse<AaiGetRelatedInstanceGroupsByVnfId> correctCodeResponse =
+ new AaiResponse<>(relatedInstanceGroups, null, HttpStatus.SC_OK);
+
+ AaiResponse<List<InstanceGroupInfo>> expectedCorrectCodeResponse =
+ new AaiResponse<>(instanceGroupInfo, null, HttpStatus.SC_OK);
+ AaiResponse<AaiGetRelatedInstanceGroupsByVnfId> expectedIncorrectCodeResponse =
+ new AaiResponse<>(relatedInstanceGroups, null, HttpStatus.SC_PAYMENT_REQUIRED);
+ List<InstanceGroupInfo> expectedCorrectResponseObject = expectedCorrectCodeResponse.getT();
+
+ when(aaiClient.getInstanceGroupsByVnfInstanceId(VNF_INSTANCE_ID_OK)).thenReturn(correctCodeResponse);
+ when(aaiClient.getInstanceGroupsByVnfInstanceId(VNF_INSTANCE_ID_FAIL))
+ .thenReturn(expectedIncorrectCodeResponse);
+
+ AaiResponse actualCorrectCodeResponse = aaiService.getInstanceGroupsByVnfInstanceId(VNF_INSTANCE_ID_OK);
+ AaiResponse actualIncorrectCodeResponse = aaiService.getInstanceGroupsByVnfInstanceId(VNF_INSTANCE_ID_FAIL);
+
+ List<InstanceGroupInfo> actualCorrectResponseObject =
+ (List<InstanceGroupInfo>) actualCorrectCodeResponse.getT();
+
+ assertThat(actualCorrectResponseObject)
+ .usingFieldByFieldElementComparator()
+ .hasSameElementsAs(expectedCorrectResponseObject);
+
+ assertThat(actualIncorrectCodeResponse).isEqualTo(expectedIncorrectCodeResponse);
+ }
+
+ @Test
+ public void shouldGetHomingDataByVfModule() {
+ GetTenantsResponse expectedResponse = new GetTenantsResponse();
+ when(aaiClient.getHomingDataByVfModule(anyString(), anyString())).thenReturn(expectedResponse);
+
+ GetTenantsResponse actualResponse = aaiService.getHomingDataByVfModule(anyString(), anyString());
+ assertThat(actualResponse).isEqualTo(expectedResponse);
+ }
+
+ @Test
+ public void shouldSearchGroupMembers() {
+ Properties properties = createProperties();
+ Map<String, Properties> regionsAndTenants = createRegionsAndTenantsMap(properties);
+
+ AAITreeNode validTreeNode = new AAITreeNode();
+ addAdditionalPropertiesToAaiTreeNode(validTreeNode);
+ List<AAITreeNode> validNodes = Arrays.asList(validTreeNode, validTreeNode);
+
+ AAITreeNode validBranch = createTree(validNodes);
+ addAdditionalPropertiesToAaiTreeNode(validBranch);
+ List<AAITreeNode> testedBranches = Collections.singletonList(validBranch);
+
+ AAITreeNode testedTree = createTree(testedBranches);
+
+ RelatedVnf expectedVnf = createExpectedVnf(validBranch);
+ List<RelatedVnf> expectedResult = Collections.singletonList(expectedVnf);
+
+ when(aaiServiceTree.buildAAITree(anyString(), isNull(), eq(HttpMethod.GET), any(), anyBoolean()))
+ .thenReturn(Collections.singletonList(testedTree));
+ when(aaiClient.getCloudRegionAndTenantByVnfId(anyString())).thenReturn(regionsAndTenants);
+
+ List<RelatedVnf> actualGroupMembers = aaiService.searchGroupMembers(GLOBAL_CUSTOMER_ID, SERVICE_TYPE,
+ INVARIANT_ID, GROUP_TYPE_FAILING, GROUP_ROLE_FAILING);
+
+ assertThat(actualGroupMembers)
+ .usingFieldByFieldElementComparator()
+ .hasSameElementsAs(expectedResult);
+ }
+
+ @Test
+ public void shouldGetPortMirroringSourcePorts() {
+ PortDetailsTranslator.PortDetails details = mock(PortDetailsTranslator.PortDetails.class);
+ List<PortDetailsTranslator.PortDetails> expectedDetailsList = Arrays.asList(
+ details, details, details
+ );
+
+ when(aaiClient.getPortMirroringSourcePorts(anyString())).thenReturn(expectedDetailsList);
+ List<PortDetailsTranslator.PortDetails> actualDetails = aaiService.getPortMirroringSourcePorts(anyString());
+
+ assertThat(actualDetails).isEqualTo(expectedDetailsList);
+ }
+
+ @Test
+ public void shouldGetAAIServiceTree() throws JsonProcessingException {
+ ServiceInstance serviceInstance = mock(ServiceInstance.class);
+ String expectedResult = new ObjectMapper().writeValueAsString(serviceInstance);
+
+ when(aaiServiceTree.getServiceInstanceTopology(anyString(), anyString(), anyString()))
+ .thenReturn(serviceInstance);
+ String actualResult = aaiService.getAAIServiceTree(anyString(), anyString(), anyString());
+
+ assertThat(actualResult).isEqualTo(expectedResult);
+ }
+
+ @NotNull
+ private Map<String, Properties> createRegionsAndTenantsMap(Properties properties) {
+ Map<String, Properties> regionsAndTenants = new HashMap<>();
+ regionsAndTenants.put("tenant", properties);
+ regionsAndTenants.put("cloud-region", properties);
+ return regionsAndTenants;
+ }
+
+ private Properties createProperties() {
+ Properties properties = new Properties();
+ properties.setTenantId(TENANT_ID);
+ properties.setTenantName(TENANT_NAME);
+ properties.setCloudRegionId(CLOUD_REGION_ID);
+ return properties;
+ }
+
+ @NotNull
+ private RelatedVnf createExpectedVnf(AAITreeNode validBranch) {
+ RelatedVnf expectedVnf = RelatedVnf.from(validBranch);
+ expectedVnf.setTenantId(TENANT_ID);
+ expectedVnf.setTenantName(TENANT_NAME);
+ expectedVnf.setLcpCloudRegionId(CLOUD_REGION_ID);
+ expectedVnf.setServiceInstanceId(PARENT_ID);
+ expectedVnf.setServiceInstanceName(PARENT_NAME);
+ expectedVnf.setInstanceType(VNF_TYPE);
+
+ return expectedVnf;
+ }
+
+
+ private AAITreeNode createTree(List<AAITreeNode> children) {
+ AAITreeNode tree = new AAITreeNode();
+ tree.addChildren(children);
+ tree.setId(PARENT_ID);
+ tree.setName(PARENT_NAME);
+ tree.setType(SERVICE_INSTANCE);
+ return tree;
+ }
+
+ private void addAdditionalPropertiesToAaiTreeNode(AAITreeNode tree) {
+ Map<String, Object> additionalProperties = new HashMap<>();
+ additionalProperties.put("instance-group-role", GROUP_ROLE_OK);
+ additionalProperties.put("instance-group-type", group_type_ok);
+ additionalProperties.put("vnf-type", VNF_TYPE);
+ additionalProperties.put("cloud-region", CLOUD_TYPE);
+ tree.setAdditionalProperties(additionalProperties);
+ }
+
+ private org.onap.vid.asdc.beans.Service createService(String category, String suffix) {
+ return new Service.ServiceBuilder()
+ .setUuid("MODELVER_VERSION_ID" + suffix)
+ .setInvariantUUID("MODEL_INVARIANT_NAME" + suffix)
+ .setCategory(category)
+ .setVersion("MODELVER_VERSION" + suffix)
+ .setName("MODELVER_NAME" + suffix)
+ .setDistributionStatus("MODELVER_DIST_STATUS" + suffix)
+ .setToscaModelURL(null)
+ .setLifecycleState(null)
+ .setArtifacts(null)
+ .setResources(null)
+ .build();
+ }
+
+ @NotNull
+ private Result createResultWithoutValidModel() {
+ ModelVers modelVers = new ModelVers();
+ modelVers.setModelVer(Collections.singletonList(new ModelVer()));
+
+ Model model = new Model();
+ model.setModelVers(modelVers);
+
+ Result result1 = new Result();
+ result1.setModel(model);
+ return result1;
+ }
+
+ @NotNull
+ private Result createResult(String modelType, String suffix) {
+ ModelVer modelVer = new ModelVer();
+ modelVer.setModelVersionId("MODELVER_VERSION_ID" + suffix);
+ modelVer.setModelVersion("MODELVER_VERSION" + suffix);
+ modelVer.setModelName("MODELVER_NAME" + suffix);
+ modelVer.setDistributionStatus("MODELVER_DIST_STATUS" + suffix);
+
+ ModelVers modelVers = new ModelVers();
+ modelVers.setModelVer(Collections.singletonList(modelVer));
+
+ Model model = new Model();
+ model.setModelType(modelType);
+ model.setModelInvariantId("MODEL_INVARIANT_NAME" + suffix);
+ model.setModelVers(modelVers);
+
+ Result result = new Result();
+ result.setModel(model);
+ return result;
+ }
+
+ @NotNull
+ private ServiceRelationships createServiceRelationships() {
+ RelationshipList relationsList = createRelationshipList(CORRECT_VALUE);
+ ServiceRelationships relationsService = new ServiceRelationships();
+ relationsService.setRelationshipList(relationsList);
+ return relationsService;
+ }
+
+ @NotNull
+ private RelationshipList createRelationshipList(String expectedValue) {
+ List<RelationshipData> relationsDataList = createRelationshipDataList(expectedValue);
+ return createRelationshipList(relationsDataList);
+ }
+
+ @NotNull
+ private RelationshipList createRelationshipList(List<RelationshipData> relationsDataList) {
+ Relationship relation1 = crateRelationship("any", relationsDataList);
+ Relationship relation2 = crateRelationship("zone", relationsDataList);
+ Relationship relation3 = crateRelationship("logical-link", relationsDataList);
+ Relationship relation4 = crateRelationship("lag-interface", relationsDataList);
+ Relationship relation5 = crateRelationship("pnf", relationsDataList);
+
+ RelationshipList relationsList = new RelationshipList();
+ relationsList.setRelationship(Arrays.asList(relation1, relation2, relation3, relation4, relation5));
+ return relationsList;
+ }
+
+ @NotNull
+ private List<RelationshipData> createRelationshipDataList(String expectedValue) {
+ RelationshipData relationData1 = createRelationshipData("any-key", "incorrect_key");
+ RelationshipData relationData2 = createRelationshipData("zone.zone-id", expectedValue);
+ RelationshipData relationData3 = createRelationshipData("logical-link.link-name", expectedValue);
+ RelationshipData relationData4 = createRelationshipData("pnf.pnf-name", expectedValue);
+
+ return Arrays.asList(relationData1, relationData2, relationData3, relationData4);
+ }
+
+ @NotNull
+ private Relationship crateRelationship(String relatedTo, List<RelationshipData> relationsDataList) {
+ Relationship relation = new Relationship();
+ relation.setRelatedTo(relatedTo);
+ relation.setRelationDataList(relationsDataList);
+ return relation;
+ }
+
+ @NotNull
+ private RelationshipData createRelationshipData(String key, String value) {
+ RelationshipData relationData = new RelationshipData();
+ relationData.setRelationshipKey(key);
+ relationData.setRelationshipValue(value);
+ return relationData;
+ }
+
+ private org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.RelationshipList createRelationshipList() {
+ RelatedToProperty property1 =
+ createRelatedToProperty("instance-group.instance-group-name", CORRECT_VALUE);
+ RelatedToProperty property2 =
+ createRelatedToProperty("anything-key", "anything-value");
+ List<RelatedToProperty> properties = Arrays.asList(property1, property2);
+
+ org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.Relationship relationship1 =
+ createRelationship("instance-group", properties);
+ org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.Relationship relationship2 =
+ createRelationship("any-key", properties);
+
+ List<org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.Relationship> relationships =
+ Arrays.asList(relationship1, relationship2);
+
+ org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.RelationshipList relationshipList =
+ new org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.RelationshipList();
+ relationshipList.setRelationship(relationships);
+
+ return relationshipList;
+ }
+
+ @NotNull
+ private org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.Relationship createRelationship(String relatedTo,
+ List<RelatedToProperty> relatedToPropertyList) {
+ org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.Relationship relationship1 =
+ new org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.Relationship();
+ relationship1.setRelatedTo(relatedTo);
+ relationship1.setRelatedToPropertyList(relatedToPropertyList);
+ return relationship1;
+ }
+
+ @NotNull
+ private RelatedToProperty createRelatedToProperty(String key, String value) {
+ RelatedToProperty prop = new RelatedToProperty();
+ prop.setKey(key);
+ prop.setValue(value);
+ return prop;
+ }
+
+ @NotNull
+ private AaiResponse<AaiGetVnfResponse> createAaiResponseVnfResponse(List<VnfResult> vnfResults) {
+ AaiGetVnfResponse vnfResponse = new AaiGetVnfResponse();
+ vnfResponse.setResults(vnfResults);
+ return new AaiResponse<>(vnfResponse, null, HttpStatus.SC_OK);
+ }
+
+ private VnfResult createVnfResult(String id, String nodeType) {
+ VnfResult result = new VnfResult();
+ result.setJsonId(id);
+ result.setJsonNodeType(nodeType);
+ return result;
+ }
+
+
+ private org.onap.vid.aai.model.AaiGetServicesRequestModel.Service createService(String serviceId,
+ String resourceVersion,
+ String serviceDescription) {
+ org.onap.vid.aai.model.AaiGetServicesRequestModel.Service service
+ = new org.onap.vid.aai.model.AaiGetServicesRequestModel.Service();
+ service.isPermitted = false;
+ service.resourceVersion = resourceVersion;
+ service.serviceDescription = serviceDescription;
+ service.serviceId = serviceId;
+ return service;
+ }
+
+ @NotNull
+ private Services createAaiResponseServices() {
+ ServiceSubscription sub1 = new ServiceSubscription();
+ sub1.isPermitted = false;
+ sub1.serviceType = "serviceSubsType1";
+
+ ServiceSubscription sub2 = new ServiceSubscription();
+ sub2.isPermitted = true;
+ sub2.serviceType = "serviceSubsType2";
+
+ ServiceSubscriptions serviceSubs = new ServiceSubscriptions();
+ serviceSubs.serviceSubscription = Collections.singletonList(sub2);
+
+ Services services = new Services();
+ services.globalCustomerId = GLOBAL_CUSTOMER_ID;
+ services.resourceVersion = "v-1";
+ services.subscriberName = "name-1";
+ services.subscriberType = "type-1";
+ services.serviceSubscriptions = serviceSubs;
+ return services;
+ }
+
+ @NotNull
+ private Subscriber createSubscriber() {
+ Subscriber subscriber = new Subscriber();
+ subscriber.globalCustomerId = "id-1";
+ subscriber.resourceVersion = "v-1";
+ subscriber.subscriberName = "name-1";
+ subscriber.subscriberType = "type-1";
+ return subscriber;
+ }
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java b/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java
index 401a56c58..4cab99816 100644
--- a/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java
@@ -25,11 +25,16 @@ import com.google.common.collect.ImmutableMap;
import org.onap.vid.aai.AaiClientInterface;
import org.onap.vid.aai.ExceptionWithRequestInfo;
import org.onap.vid.model.Action;
+import org.onap.vid.model.VidNotions;
+import org.onap.vid.model.VidNotions.InstantiationType;
+import org.onap.vid.model.VidNotions.InstantiationUI;
+import org.onap.vid.model.VidNotions.ModelCategory;
import org.onap.vid.model.serviceInstantiation.*;
import org.onap.vid.mso.RestObject;
import org.onap.vid.mso.model.ModelInfo;
import org.onap.vid.mso.rest.AsyncRequestStatus;
import org.onap.vid.mso.rest.RequestStatus;
+import org.onap.vid.properties.Features;
import org.onap.vid.utils.TimeUtils;
import org.springframework.http.HttpMethod;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
@@ -38,14 +43,18 @@ import org.togglz.core.manager.FeatureManager;
import javax.inject.Inject;
import java.time.ZonedDateTime;
import java.util.*;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import static java.util.Collections.emptyList;
import static java.util.Collections.emptyMap;
-import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.when;
public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests {
public static final String OWNING_ENTITY_ID = "038d99af-0427-42c2-9d15-971b99b9b489";
+ public static final String JULIO_ERICKSON = "JULIO ERICKSON";
public static final String PACKET_CORE = "PACKET CORE";
public static final String PROJECT_NAME = "{some project name}";
public static final String SUBSCRIBER_ID = "{some subscriber id}";
@@ -98,7 +107,7 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests
return new ServiceInstantiation ( modelInfo,
AsyncInstantiationBusinessLogicTest.OWNING_ENTITY_ID,
- AsyncInstantiationBusinessLogicTest.PACKET_CORE,
+ AsyncInstantiationBusinessLogicTest.JULIO_ERICKSON,
projectName,
AsyncInstantiationBusinessLogicTest.SUBSCRIBER_ID,
AsyncInstantiationBusinessLogicTest.SUBSCRIBER_NAME,
@@ -114,6 +123,7 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests
vnfs,
networks,
vnfGroups,
+ null,
instanceParams,
isPause,
bulkSize,
@@ -121,8 +131,8 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests
isAlacarte,
testApi,
instanceId,
- action.name()
- );
+ action.name(),
+ UUID.randomUUID().toString(), null, null, null);
}
private List<Map<String,String>> createInstanceParams() {
@@ -146,10 +156,12 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests
if (isAlacarte) {
vfModuleInfo.setModelInvariantId("22222222-f63c-463e-ba94-286933b895f9");
vfModuleInfo.setModelVersion("10.0");
- return new VfModule(vfModuleInfo, instanceName, volumeGroupInstanceName, Action.Create.name(), "mdt1", null, "88a6ca3ee0394ade9403f075db23167e", instanceParams, supplementaryParams, false, true, null);
+ return new VfModule(vfModuleInfo, instanceName, volumeGroupInstanceName, Action.Create.name(), "mdt1", null,
+ "88a6ca3ee0394ade9403f075db23167e", instanceParams, supplementaryParams, false, true, null, UUID.randomUUID().toString(), null, null);
}
- return new VfModule(vfModuleInfo, instanceName, volumeGroupInstanceName, Action.Create.name(), null, null, null, instanceParams, supplementaryParams, false, false, null);
+ return new VfModule(vfModuleInfo, instanceName, volumeGroupInstanceName, Action.Create.name(), null, null, null,
+ instanceParams, supplementaryParams, false, false, null, UUID.randomUUID().toString(), null, null);
}
protected ModelInfo createVnfModelInfo(boolean isAlacarte) {
@@ -167,19 +179,20 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests
return vnfModelInfo;
}
- private ModelInfo createNetworkModelInfo(boolean isAlacarte) {
- ModelInfo vnfModelInfo = new ModelInfo();
- vnfModelInfo.setModelType("network");
- vnfModelInfo.setModelName("2016-73_MOW-AVPN-vPE-BV-L");
- vnfModelInfo.setModelVersionId("7f40c192-f63c-463e-ba94-286933b895f8");
- vnfModelInfo.setModelCustomizationName("2016-73_MOW-AVPN-vPE-BV-L 0");
- vnfModelInfo.setModelCustomizationId("ab153b6e-c364-44c0-bef6-1f2982117f04");
+ private ModelInfo createNetworkModelInfo(boolean isAlacarte, String modelCustomizationId)
+ {
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelType("network");
+ modelInfo.setModelName("2016-73_MOW-AVPN-vPE-BV-L");
+ modelInfo.setModelVersionId("7f40c192-f63c-463e-ba94-286933b895f8");
+ modelInfo.setModelCustomizationName("2016-73_MOW-AVPN-vPE-BV-L 0");
+ modelInfo.setModelCustomizationId(modelCustomizationId);
//added two conditional fields according to MSO AID - needed only in alacarte
if (isAlacarte) {
- vnfModelInfo.setModelInvariantId("11111111-f63c-463e-ba94-286933b895f9");
- vnfModelInfo.setModelVersion("10.0");
+ modelInfo.setModelInvariantId("11111111-f63c-463e-ba94-286933b895f9");
+ modelInfo.setModelVersion("10.0");
}
- return vnfModelInfo;
+ return modelInfo;
}
private ModelInfo createModelInfo() {
@@ -214,21 +227,33 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests
vfModules.get(vfModuleModelName).put(vfModuleModelName + ":002", vfModule2);
Vnf vnf = new Vnf(vnfModelInfo, "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", (isUserProvidedNaming ? VNF_NAME : null), Action.Create.name(),
- "platformName", "mdt1", null, "88a6ca3ee0394ade9403f075db23167e", vnfInstanceParams,"lineOfBusinessName" , false, null, vfModules);
+ "platformName", "mdt1", null, "88a6ca3ee0394ade9403f075db23167e", vnfInstanceParams,"lineOfBusinessName" , false, null, vfModules,
+ UUID.randomUUID().toString(), null, null);
vnfs.put(vnf.getModelInfo().getModelName(), vnf);
return vnfs;
}
- protected Map<String, Network> createNetworkList(List vnfInstanceParams, boolean isUserProvidedNaming, boolean isALaCarte) {
- Map<String, Network> networks = new HashMap<>();
- ModelInfo networkModelInfo = createNetworkModelInfo(isALaCarte);
+ public static class NetworkDetails {
+
+ public NetworkDetails(String name, String modelCustomizationId) {
+ this.name = name;
+ this.modelCustomizationId = modelCustomizationId;
+ }
+
+ public String name;
+ public String modelCustomizationId;
+ }
- Network network = new Network(networkModelInfo, "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", isUserProvidedNaming ? VNF_NAME : null, Action.Create.name(),
- "platformName", "mdt1", null, "88a6ca3ee0394ade9403f075db23167e", vnfInstanceParams,"lineOfBusinessName" , false, null);
- networks.put(network.getModelInfo().getModelName(), network);
- return networks;
+ protected Map<String, Network> createNetworkList(List instanceParams, List<NetworkDetails> networkDetails, boolean isALaCarte) {
+ Stream<Network> networkStream = networkDetails.stream().map(
+ details->new Network(createNetworkModelInfo(isALaCarte, details.modelCustomizationId), "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ details.name, Action.Create.name(),
+ "platformName", "mdt1", null, "88a6ca3ee0394ade9403f075db23167e", instanceParams,"lineOfBusinessName" ,
+ false, null, UUID.randomUUID().toString(), null, null));
+// I can't tell why compiler don't like the statement if it's only one line...
+ return networkStream.collect(Collectors.toMap(network -> network.getModelInfo().getModelCustomizationId(), network -> network));
}
protected InstanceGroup createInstanceGroup(boolean isUserProvidedNaming, Action action) {
@@ -241,7 +266,7 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests
modelInfo.setModelInvariantId("11111111-f63c-463e-ba94-286933b895f9");
modelInfo.setModelVersion("10.0");
- return new InstanceGroup(modelInfo, (isUserProvidedNaming ? VNF_GROUP_NAME : null), action.name(), false, null);
+ return new InstanceGroup(modelInfo, (isUserProvidedNaming ? VNF_GROUP_NAME : null), action.name(), false, null, emptyMap(), UUID.randomUUID().toString(), null, null);
}
protected ModelInfo createServiceModelInfo() {
@@ -277,11 +302,11 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests
return asyncRequestStatus;
}
- protected RestObject<AsyncRequestStatus> asyncRequestStatusResponseAsRestObject(String msoStatus) {
+ public static RestObject<AsyncRequestStatus> asyncRequestStatusResponseAsRestObject(String msoStatus) {
return asyncRequestStatusResponseAsRestObject(msoStatus, 200);
}
- protected RestObject<AsyncRequestStatus> asyncRequestStatusResponseAsRestObject(String msoStatus, int httpStatusCode) {
+ public static RestObject<AsyncRequestStatus> asyncRequestStatusResponseAsRestObject(String msoStatus, int httpStatusCode) {
RestObject<AsyncRequestStatus> restObject = new RestObject<>();
restObject.set(asyncRequestStatusResponse(msoStatus));
restObject.setStatusCode(httpStatusCode);
@@ -302,6 +327,12 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests
return serviceInstantiation;
}
+ protected ServiceInstantiation generateALaCarteWithNetworksPayload(List<NetworkDetails> networkDetails) {
+ Map<String, Network> networks = createNetworkList(emptyList(), networkDetails, true);
+ ServiceInstantiation serviceInstantiation = generateMockALaCarteServiceInstantiationPayload(false, emptyMap(), networks, emptyMap(), 1, true, PROJECT_NAME, false, "VNF_API");
+ return serviceInstantiation;
+ }
+
protected ServiceInstantiation generateALaCarteUpdateWith1ExistingGroup2NewGroupsPayload() {
final InstanceGroup instanceGroup1 = createInstanceGroup(true, Action.None);
final InstanceGroup instanceGroup2 = createInstanceGroup(false, Action.Create);
@@ -315,4 +346,38 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests
1, true, PROJECT_NAME, false, true, "VNF_API",
Action.None, "1234567890");
}
+
+ protected void enableAddCloudOwnerOnMsoRequest() {
+ enableAddCloudOwnerOnMsoRequest(true);
+ }
+
+ protected void enableAddCloudOwnerOnMsoRequest(boolean isActive) {
+ // always turn on the feature flag
+ when(featureManager.isActive(Features.FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST)).thenReturn(isActive);
+ when(aaiClient.getCloudOwnerByCloudRegionId(anyString())).thenReturn("irma-aic");
+ }
+
+ protected ServiceInstantiation generateALaCarteServiceInstantiationPayload() {
+ return generateMockALaCarteServiceInstantiationPayload(false, Collections.EMPTY_MAP, Collections.EMPTY_MAP, Collections.EMPTY_MAP, 1, true, PROJECT_NAME, false, "VNF_API");
+ }
+
+ protected ServiceInstantiation generateMacroMockServiceInstantiationPayload(boolean isPause, Map<String, Vnf> vnfs) {
+ return generateMockMacroServiceInstantiationPayload(isPause, vnfs, 1, true, PROJECT_NAME, false);
+ }
+
+ protected ServiceInstantiation generatePre1806MacroTransportServiceInstantiationPayload(String tenantId, String lcpCloudRegionId) {
+ List<Map<String, String>> instanceParams = ImmutableList.of(ImmutableMap.of("someUserParam","someValue", "anotherUserParam","anotherValue"));
+ ServiceInstantiation serviceInstantiation = new ServiceInstantiation(createServiceModelInfo(), "038d99af-0427-42c2-9d15-971b99b9b489",
+ "JULIO ERICKSON", "some_project_name", "some_subscriber_id", "some_subscriber_name",
+ "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", null, "MOG", lcpCloudRegionId, null, tenantId,
+ null, null, null, Collections.EMPTY_MAP, Collections.EMPTY_MAP, Collections.EMPTY_MAP, Collections.EMPTY_MAP, instanceParams, false, 1, false, false,
+ null, null, null, null, null, null,
+ new VidNotions(InstantiationUI.TRANSPORT_SERVICE, ModelCategory.Transport, InstantiationUI.TRANSPORT_SERVICE, InstantiationType.Macro)
+ );
+ return serviceInstantiation;
+ }
+
+ protected void mockAaiClientAaiStatusOK() {
+ when(aaiClient.isNodeTypeExistsByName(eq(AsyncInstantiationBusinessLogicImpl.NAME_FOR_CHECK_AAI_STATUS), any())).thenReturn(false);
+ }
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBusinessLogicTest.java b/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBusinessLogicTest.java
index 21b8f3f00..e2d182c06 100644
--- a/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBusinessLogicTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBusinessLogicTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,69 +20,13 @@
package org.onap.vid.services;
-import static com.google.common.collect.Maps.newHashMap;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.contains;
-import static org.hamcrest.Matchers.hasItem;
-import static org.hamcrest.Matchers.hasItems;
-import static org.hamcrest.Matchers.hasProperty;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.matchesPattern;
-import static org.hamcrest.Matchers.not;
-import static org.hamcrest.core.Every.everyItem;
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.anyInt;
-import static org.mockito.Mockito.anyString;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.eq;
-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 static org.onap.vid.job.Job.JobStatus.COMPLETED;
-import static org.onap.vid.job.Job.JobStatus.FAILED;
-import static org.onap.vid.job.Job.JobStatus.IN_PROGRESS;
-import static org.onap.vid.job.Job.JobStatus.PAUSE;
-import static org.onap.vid.job.Job.JobStatus.PENDING;
-import static org.onap.vid.job.Job.JobStatus.STOPPED;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertTrue;
-
-import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
-import java.io.IOException;
-import java.lang.reflect.Method;
-import java.net.URL;
-import java.time.Instant;
-import java.time.LocalDateTime;
-import java.time.ZoneId;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-import java.util.UUID;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.stream.Collectors;
-import java.util.stream.IntStream;
-import javax.inject.Inject;
-import net.javacrumbs.jsonunit.JsonAssert;
import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.time.DateUtils;
import org.hibernate.SessionFactory;
+import org.jetbrains.annotations.NotNull;
import org.json.JSONException;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
@@ -97,48 +41,64 @@ import org.onap.vid.aai.model.ResourceType;
import org.onap.vid.changeManagement.RequestDetailsWrapper;
import org.onap.vid.config.DataSourceConfig;
import org.onap.vid.config.MockedAaiClientAndFeatureManagerConfig;
-import org.onap.vid.exceptions.GenericUncheckedException;
+import org.onap.vid.dal.AsyncInstantiationRepository;
import org.onap.vid.exceptions.MaxRetriesException;
+import org.onap.vid.exceptions.NotFoundException;
import org.onap.vid.exceptions.OperationNotAllowedException;
import org.onap.vid.job.Job;
import org.onap.vid.job.Job.JobStatus;
import org.onap.vid.job.JobAdapter;
import org.onap.vid.job.JobType;
import org.onap.vid.job.JobsBrokerService;
+import org.onap.vid.job.command.MsoRequestBuilder;
+import org.onap.vid.job.command.ResourceCommandTest.FakeResourceCreator;
import org.onap.vid.job.impl.JobDaoImpl;
import org.onap.vid.job.impl.JobSharedData;
-import org.onap.vid.model.Action;
-import org.onap.vid.model.JobAuditStatus;
-import org.onap.vid.model.JobAuditStatus.SourceStatus;
-import org.onap.vid.model.NameCounter;
-import org.onap.vid.model.ServiceInfo;
-import org.onap.vid.model.serviceInstantiation.InstanceGroup;
-import org.onap.vid.model.serviceInstantiation.Network;
+import org.onap.vid.model.*;
+import org.onap.vid.model.serviceInstantiation.BaseResource;
import org.onap.vid.model.serviceInstantiation.ServiceInstantiation;
-import org.onap.vid.model.serviceInstantiation.VfModule;
import org.onap.vid.model.serviceInstantiation.Vnf;
import org.onap.vid.mso.MsoOperationalEnvironmentTest;
-import org.onap.vid.mso.model.InstanceGroupInstantiationRequestDetails;
+import org.onap.vid.mso.RestObject;
import org.onap.vid.mso.model.ModelInfo;
-import org.onap.vid.mso.model.NetworkInstantiationRequestDetails;
-import org.onap.vid.mso.model.ServiceDeletionRequestDetails;
import org.onap.vid.mso.model.ServiceInstantiationRequestDetails;
-import org.onap.vid.mso.model.VfModuleInstantiationRequestDetails;
-import org.onap.vid.mso.model.VfModuleMacro;
-import org.onap.vid.mso.model.VnfInstantiationRequestDetails;
-import org.onap.vid.mso.model.VolumeGroupRequestDetails;
import org.onap.vid.mso.rest.AsyncRequestStatus;
+import org.onap.vid.mso.rest.RequestStatus;
import org.onap.vid.properties.Features;
import org.onap.vid.testUtils.TestUtils;
import org.onap.vid.utils.DaoUtils;
+import org.onap.vid.utils.TimeUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
+import org.testng.annotations.*;
+
+import javax.inject.Inject;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.time.*;
+import java.util.Optional;
+import java.util.*;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+
+import static net.javacrumbs.jsonunit.JsonAssert.assertJsonEquals;
+import static net.javacrumbs.jsonunit.JsonAssert.whenIgnoringPaths;
+import static net.javacrumbs.jsonunit.JsonMatchers.jsonEquals;
+import static net.javacrumbs.jsonunit.core.Option.IGNORING_ARRAY_ORDER;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.*;
+import static org.hamcrest.core.Every.everyItem;
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.*;
+import static org.onap.vid.job.Job.JobStatus.*;
+import static org.onap.vid.testUtils.TestUtils.generateRandomAlphaNumeric;
+import static org.testng.Assert.*;
@ContextConfiguration(classes = {DataSourceConfig.class, SystemProperties.class, MockedAaiClientAndFeatureManagerConfig.class})
public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseTest {
@@ -152,24 +112,42 @@ public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseT
@Mock
private JobsBrokerService jobsBrokerServiceMock;
+ private AsyncInstantiationRepository asyncInstantiationRepository;
+
+ private AuditService auditService;
@Autowired
private SessionFactory sessionFactory;
private AsyncInstantiationBusinessLogicImpl asyncInstantiationBL;
+ protected MsoRequestBuilder msoRequestBuilder;
+
private int serviceCount = 0;
private static final String UPDATE_SERVICE_INFO_EXCEPTION_MESSAGE =
- "Failed to retrieve job with uuid .* from ServiceInfo table. Instances found: .*";
+ "Failed to retrieve class .*ServiceInfo with jobId .* from table. no resource found";
private static final String DELETE_SERVICE_INFO_STATUS_EXCEPTION_MESSAGE =
"Service status does not allow deletion from the queue";
+ private String uuidRegex = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
+ private org.hamcrest.Matcher uuidRegexMatcher = is(matchesPattern(uuidRegex));
+
+
@BeforeClass
void initServicesInfoService() {
MockitoAnnotations.initMocks(this);
- asyncInstantiationBL = new AsyncInstantiationBusinessLogicImpl(dataAccessService, jobAdapterMock, jobsBrokerServiceMock, sessionFactory, aaiClient, featureManager, cloudOwnerService);
+ AsyncInstantiationRepository realAsyncInstantiationRepository = new AsyncInstantiationRepository(dataAccessService);
+ asyncInstantiationRepository = spy(realAsyncInstantiationRepository);
+
+ auditService = new AuditServiceImpl(null, asyncInstantiationRepository);
+
+ AsyncInstantiationBusinessLogicImpl realAsyncInstantiationBL = new AsyncInstantiationBusinessLogicImpl(jobAdapterMock, jobsBrokerServiceMock, sessionFactory, aaiClient, featureManager, cloudOwnerService, asyncInstantiationRepository, auditService);
+ asyncInstantiationBL = Mockito.spy(realAsyncInstantiationBL);
+
+ msoRequestBuilder = new MsoRequestBuilder(asyncInstantiationBL, cloudOwnerService, aaiClient, featureManager);
+
createInstanceParamsMaps();
}
@@ -182,16 +160,6 @@ public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseT
enableAddCloudOwnerOnMsoRequest();
}
- private void enableAddCloudOwnerOnMsoRequest() {
- enableAddCloudOwnerOnMsoRequest(true);
- }
-
- private void enableAddCloudOwnerOnMsoRequest(boolean isActive) {
- // always turn on the feature flag
- when(featureManager.isActive(Features.FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST)).thenReturn(isActive);
- when(aaiClient.getCloudOwnerByCloudRegionId(anyString())).thenReturn("att-aic");
- }
-
@BeforeMethod
void resetServiceCount() {
serviceCount = 0;
@@ -215,13 +183,13 @@ public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseT
uuid = UUID.randomUUID();
addNewJob(uuid);
createdDate = NOW.minusYears(1);
- addNewServiceInfo(uuid, userId, "Old", createdDate, createdDate, COMPLETED, false);
+ addNewServiceInfo(uuid, userId, "Old", createdDate, createdDate, COMPLETED, false, false);
uuid = UUID.randomUUID();
addNewJob(uuid);
createdDate = NOW.minusDays(20);
modifiedDate = NOW.minusDays(19);
- addNewServiceInfo(uuid, userId, "Hidden", createdDate, modifiedDate, PAUSE, true);
+ addNewServiceInfo(uuid, userId, "Hidden", createdDate, modifiedDate, PAUSE, true, false);
createNewTestServicesInfo(String.valueOf(userId));
}
@@ -236,20 +204,20 @@ public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseT
addNewJob(uuid);
createdDate = NOW.minusDays(40);
- addNewServiceInfo(uuid, userId, "service instance 5", createdDate, createdDate, COMPLETED, false);
- addNewServiceInfo(uuid, userId, "service instance 6", createdDate, createdDate, STOPPED, false);
+ addNewServiceInfo(uuid, userId, "service instance 5", createdDate, createdDate, COMPLETED, false, false);
+ addNewServiceInfo(uuid, userId, "service instance 6", createdDate, createdDate, STOPPED, false, false);
uuid = UUID.randomUUID();
addNewJob(uuid);
createdDate = NOW.minusDays(20);
modifiedDate = NOW.minusDays(10);
- addNewServiceInfo(uuid, userId, "service instance 4", createdDate, modifiedDate, STOPPED, false);
- addNewServiceInfo(uuid, userId, "service instance 2", createdDate, modifiedDate, COMPLETED, false);
- addNewServiceInfo(uuid, userId, "service instance 3", createdDate, modifiedDate, PAUSE, false);
+ addNewServiceInfo(uuid, userId, "service instance 4", createdDate, modifiedDate, STOPPED, false, false);
+ addNewServiceInfo(uuid, userId, "service instance 2", createdDate, modifiedDate, COMPLETED, false, false);
+ addNewServiceInfo(uuid, userId, "service instance 3", createdDate, modifiedDate, PAUSE, false, false);
modifiedDate = NOW.minusDays(19);
- addNewServiceInfo(uuid, userId, "service instance 1", createdDate, modifiedDate, FAILED, false);
+ addNewServiceInfo(uuid, userId, "service instance 1", createdDate, modifiedDate, FAILED, false, false);
// Job to a different user
@@ -257,7 +225,7 @@ public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseT
addNewJob(uuid);
createdDate = NOW.minusMonths(2);
- addNewServiceInfo(uuid, "2221", "service instance 7", createdDate, createdDate, COMPLETED, false);
+ addNewServiceInfo(uuid, "2221", "service instance 7", createdDate, createdDate, COMPLETED, false, false);
}
@@ -269,7 +237,7 @@ public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseT
uuid = UUID.randomUUID();
addNewJob(uuid, status);
- addNewServiceInfo(uuid, null, "service instance 1", NOW, NOW, status, false);
+ addNewServiceInfo(uuid, null, "service instance 1", NOW, NOW, status, false, false);
return uuid;
@@ -292,7 +260,7 @@ public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseT
.toLocalDateTime();
}
- private void addNewServiceInfo(UUID uuid, String userId, String serviceName, LocalDateTime createDate, LocalDateTime statusModifiedDate, Job.JobStatus status, boolean isHidden) {
+ private void addNewServiceInfo(UUID uuid, String userId, String serviceName, LocalDateTime createDate, LocalDateTime statusModifiedDate, JobStatus status, boolean isHidden, boolean retryEnabled) {
ServiceInfo serviceInfo = new ServiceInfo();
serviceInfo.setJobId(uuid);
serviceInfo.setUserId(userId);
@@ -302,6 +270,7 @@ public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseT
serviceInfo.setPause(false);
serviceInfo.setOwningEntityId("1234");
serviceInfo.setCreatedBulkDate(toDate(createDate));
+ serviceInfo.setRetryEnabled(retryEnabled);
serviceInfo.setHidden(isHidden);
dataAccessService.saveDomainObject(serviceInfo, getPropsMap());
@@ -334,6 +303,39 @@ public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseT
dataAccessService.saveDomainObject(jobDao, getPropsMap());
}
+ private ServiceInstantiation addOriginalService(UUID jobId, String userID){
+ addNewServiceInfo(jobId, userID, "name", LocalDateTime.now(), LocalDateTime.now(), COMPLETED_WITH_ERRORS, false, true);
+ assertThat(asyncInstantiationRepository.getServiceInfoByJobId(jobId).isRetryEnabled(), is(true));
+ ServiceInstantiation originalServiceInstantiation = prepareServiceInstantiation(true, 1);
+ doReturn(originalServiceInstantiation).when(asyncInstantiationRepository).getJobRequest(jobId);
+ return originalServiceInstantiation;
+ }
+
+ private void assertRetryDisabled(UUID jobId){
+ assertThat(asyncInstantiationRepository.getServiceInfoByJobId(jobId).isRetryEnabled(), is(false));
+ }
+
+ private void assertNewJobExistsAsExpectedAfterRetry(List<UUID> newJobIds, ServiceInstantiation expectedServiceInstantiation, UUID jobId, String userId){
+ assertThat(newJobIds, hasSize(1));
+ assertThat(newJobIds.get(0), not(equalTo(jobId)));
+
+ ArgumentCaptor<ServiceInstantiation> requestsCaptor = ArgumentCaptor.forClass(ServiceInstantiation.class);
+ ArgumentCaptor<UUID> uuidsCaptor = ArgumentCaptor.forClass(UUID.class);
+ ArgumentCaptor<JobType> jobTypeCaptor = ArgumentCaptor.forClass(JobType.class);
+
+ verify(asyncInstantiationRepository).addJobRequest(uuidsCaptor.capture(), requestsCaptor.capture());
+ verify(jobAdapterMock).createServiceInstantiationJob(jobTypeCaptor.capture(), requestsCaptor.capture(), uuidsCaptor.capture(), eq(userId), any(), anyString(), anyInt());
+ verify(jobsBrokerServiceMock).add(any());
+
+ requestsCaptor.getAllValues().forEach(x->assertJsonEquals(expectedServiceInstantiation, x, whenIgnoringPaths(
+ "trackById",
+ "vnfs.2016-73_MOW-AVPN-vPE-BV-L.trackById",
+ "vnfs.2016-73_MOW-AVPN-vPE-BV-L.vfModules.201673MowAvpnVpeBvL..AVPN_base_vPE_BV..module-0.201673MowAvpnVpeBvL..AVPN_base_vPE_BV..module-0:001.trackById",
+ "vnfs.2016-73_MOW-AVPN-vPE-BV-L.vfModules.201673MowAvpnVpeBvL..AVPN_base_vPE_BV..module-0.201673MowAvpnVpeBvL..AVPN_base_vPE_BV..module-0:002.trackById"
+ )));
+
+ }
+
@Test
public void testServiceInfoAreOrderedAsExpected() {
int userId = 2222;
@@ -344,6 +346,12 @@ public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseT
}
@Test
+ public void whenNewServiceInfoCreated_isRetryEnablesIsFalse() {
+ UUID uuid = createServicesInfoWithDefaultValues(PENDING);
+ assertFalse(asyncInstantiationRepository.getServiceInfoByJobId(uuid).isRetryEnabled());
+ }
+
+ @Test
public void testServiceInfoAreFilteredAsExpected() {
int userId = 2222;
createNewTestServicesInfoForFilter(String.valueOf(userId));
@@ -364,9 +372,9 @@ public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseT
defineMocks();
ServiceInstantiation serviceInstantiationPayload = generateMockMacroServiceInstantiationPayload(isPause, createVnfList(vfModuleInstanceParamsMap, vnfInstanceParams, true), 2, true, PROJECT_NAME, false);
final URL resource = this.getClass().getResource("/payload_jsons/bulk_service_request_unique_names.json");
- when(jobAdapterMock.createServiceInstantiationJob(any(), any(), any(), any(), anyString(), any())).thenAnswer(invocation -> {
+ when(jobAdapterMock.createServiceInstantiationJob(any(), any(), any(), any(), any(), anyString(), any())).thenAnswer(invocation -> {
Object[] args = invocation.getArguments();
- return new MockedJob((String)args[4]);
+ return new MockedJob((String)args[5]);
});
when(jobsBrokerServiceMock.add(any(MockedJob.class))).thenAnswer((Answer<UUID>) invocation -> {
@@ -376,13 +384,13 @@ public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseT
return job.getUuid();
});
- when(featureManager.isActive(Features.FLAG_SHIFT_VFMODULE_PARAMS_TO_VNF)).thenReturn(true);
+ when(asyncInstantiationBL.isPartOfBulk(any())).thenReturn(true);
List<UUID> uuids = asyncInstantiationBL.pushBulkJob(serviceInstantiationPayload, "az2016");
for (int i = 0; i < 2; i++) {
UUID currentUuid = uuids.get(i);
RequestDetailsWrapper<ServiceInstantiationRequestDetails> result =
- asyncInstantiationBL.generateMacroServiceInstantiationRequest(currentUuid, serviceInstantiationPayload,
+ msoRequestBuilder.generateMacroServiceInstantiationRequest(currentUuid, serviceInstantiationPayload,
MockedJob.getJob(currentUuid).getOptimisticUniqueServiceInstanceName(), "az2016");
String unique = i==0 ? "" : String.format("_00%s", i);
String expected = IOUtils.toString(resource, "UTF-8")
@@ -403,7 +411,9 @@ public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseT
}
protected void verifySearchNodeTypeByName(String unique, String resourceName, ResourceType serviceInstance) {
- verify(aaiClient, times(1)).isNodeTypeExistsByName(resourceName + unique, serviceInstance);
+ String uniqueName = resourceName + unique;
+ verify(aaiClient, times(1)).isNodeTypeExistsByName(uniqueName, serviceInstance);
+ when(aaiClient.isNodeTypeExistsByName(uniqueName, serviceInstance)).thenReturn(true);
}
private HashMap<String, Object> getPropsMap() {
@@ -423,25 +433,115 @@ public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseT
@Test(dataProvider="dataProviderForInstanceNames")
public void pushBulkJob_bulkWithSize3_instancesNamesAreExactlyAsExpected(boolean isUserProvidedNaming, List<String> expectedNames) {
- int bulkSize = 3;
+ final ServiceInstantiation request = prepareServiceInstantiation(isUserProvidedNaming, 3);
+
+
+ asyncInstantiationBL.pushBulkJob(request, "myUserId");
+ List<ServiceInfo> serviceInfoList = dataAccessService.getList(ServiceInfo.class, getPropsMap());
+ assertEquals(serviceInfoList.stream().map(ServiceInfo::getServiceInstanceName).collect(Collectors.toList()), expectedNames);
+ }
+
+ protected ServiceInstantiation prepareServiceInstantiation(String projectName, boolean isUserProvidedNaming, int bulkSize) {
final ServiceInstantiation request = generateMockMacroServiceInstantiationPayload(
false,
createVnfList(instanceParamsMapWithoutParams, Collections.EMPTY_LIST, true),
- bulkSize, isUserProvidedNaming, PROJECT_NAME, true
+ bulkSize, isUserProvidedNaming, projectName, true
);
// in "createServiceInstantiationJob()" we will probe the service, with the generated names
configureMockitoWithMockedJob();
+ return request;
+ }
+ protected ServiceInstantiation prepareServiceInstantiation(boolean isUserProvidedNaming, int bulkSize) {
+ return prepareServiceInstantiation(PROJECT_NAME, isUserProvidedNaming, bulkSize);
+ }
- asyncInstantiationBL.pushBulkJob(request, "myUserId");
- List<ServiceInfo> serviceInfoList = dataAccessService.getList(ServiceInfo.class, getPropsMap());
- assertEquals(serviceInfoList.stream().map(ServiceInfo::getServiceInstanceName).collect(Collectors.toList()), expectedNames);
+
+ @Test
+ public void whenPushBulkJob_thenJobRequestIsSaveInJobRequestDb() {
+ Mockito.reset(asyncInstantiationRepository);
+ int bulkSize = 3;
+ final ServiceInstantiation request = prepareServiceInstantiation(true, bulkSize);
+ when(jobsBrokerServiceMock.add(any())).thenReturn(UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID());
+ List<UUID> jobIds = asyncInstantiationBL.pushBulkJob(request, "abc");
+
+ ArgumentCaptor<JobAdapter.AsyncJobRequest> asyncJobRequestCaptor = ArgumentCaptor.forClass(JobAdapter.AsyncJobRequest.class);
+ ArgumentCaptor<ServiceInstantiation> requestsCaptor = ArgumentCaptor.forClass(ServiceInstantiation.class);
+ ArgumentCaptor<UUID> uuidsCaptor = ArgumentCaptor.forClass(UUID.class);
+ verify(asyncInstantiationRepository, times(bulkSize)).addJobRequest(uuidsCaptor.capture(), requestsCaptor.capture());
+ verify(jobsBrokerServiceMock, times(bulkSize)).add(any());
+ verify(jobAdapterMock, times(bulkSize)).createServiceInstantiationJob(any(), asyncJobRequestCaptor.capture(), any(), any(), any(), any(), any());
+
+ //verify that all for each job we saved an row in jobRequest table
+ assertThat(uuidsCaptor.getAllValues(), containsInAnyOrder(jobIds.toArray()));
+
+ //assert that each real job we created with the adaptor, request is save in jobRequest table
+ assertThat(requestsCaptor.getAllValues(), containsInAnyOrder(asyncJobRequestCaptor.getAllValues().toArray()));
+
+ assertThat(requestsCaptor.getAllValues(),everyItem(hasProperty("bulkSize", is(1))));
+
+ //assert that the requests that save in DB are the same as original request expect of the trackById
+ requestsCaptor.getAllValues().forEach(x->assertJsonEquals(request, x, whenIgnoringPaths(
+ "bulkSize",
+ "trackById",
+ "vnfs.2016-73_MOW-AVPN-vPE-BV-L.trackById",
+ "vnfs.2016-73_MOW-AVPN-vPE-BV-L.vfModules.201673MowAvpnVpeBvL..AVPN_base_vPE_BV..module-0.201673MowAvpnVpeBvL..AVPN_base_vPE_BV..module-0:001.trackById",
+ "vnfs.2016-73_MOW-AVPN-vPE-BV-L.vfModules.201673MowAvpnVpeBvL..AVPN_base_vPE_BV..module-0.201673MowAvpnVpeBvL..AVPN_base_vPE_BV..module-0:002.trackById"
+ )));
+
+ //assert that each trackById on all bulk jobs is unique
+ Set<String> usedUUID = new HashSet<>();
+ requestsCaptor.getAllValues().forEach(x->assertTrackByIdRecursively(x, uuidRegexMatcher, usedUUID));
+ }
+
+ @Test
+ public void whenRetryJob_prevJobRetryIsDisabled() {
+ reset(asyncInstantiationRepository);
+ UUID jobId = UUID.randomUUID();
+ String userID = generateRandomAlphaNumeric(8);
+ addOriginalService(jobId, userID);
+ doReturn(mock(Map.class)).when(asyncInstantiationRepository).getResourceInfoByRootJobId(jobId);
+ asyncInstantiationBL.retryJob(jobId, userID);
+ assertRetryDisabled(jobId);
+ }
+
+ @Test
+ public void whenRetryJobWithEditedData_prevJobRetryIsDisabled() {
+ reset(asyncInstantiationRepository);
+ UUID jobId = UUID.randomUUID();
+ String userID = generateRandomAlphaNumeric(8);
+ addOriginalService(jobId, userID);
+ ServiceInstantiation editedServiceInstantiation = prepareServiceInstantiation("editedProjectName", true, 1);
+ asyncInstantiationBL.retryJob(editedServiceInstantiation, jobId, userID);
+ assertRetryDisabled(jobId);
+ }
+
+ @Test
+ public void retryJobWithEditedData_expectedNewJobDifferentData() {
+ reset(asyncInstantiationRepository);
+ UUID jobId = UUID.randomUUID();
+ String userID = generateRandomAlphaNumeric(8);
+ addOriginalService(jobId, userID);
+ ServiceInstantiation editedServiceInstantiation = prepareServiceInstantiation("editedProjectName", true, 1);
+ List<UUID> newJobIds = asyncInstantiationBL.retryJob(editedServiceInstantiation, jobId, userID);
+ assertNewJobExistsAsExpectedAfterRetry(newJobIds, editedServiceInstantiation, jobId, userID);
+ }
+
+ @Test
+ public void retryJob_expectedNewJob() {
+ reset(asyncInstantiationRepository);
+ UUID jobId = UUID.randomUUID();
+ String userID = "az2016";
+ ServiceInstantiation originalServiceInstantiation = addOriginalService(jobId, userID);
+ doReturn(mock(Map.class)).when(asyncInstantiationRepository).getResourceInfoByRootJobId(jobId);
+ List<UUID> newJobIds = asyncInstantiationBL.retryJob(jobId, userID);
+ assertNewJobExistsAsExpectedAfterRetry(newJobIds, originalServiceInstantiation, jobId, userID);
}
- @Test(dataProvider = "aLaCarteAndMacroPayload")
+ @Test (dataProvider = "aLaCarteAndMacroPayload")
public void generateMockServiceInstantiationPayload_serializeBackAndForth_sourceShouldBeTheSame(ServiceInstantiation serviceInstantiationPayload) throws IOException {
ObjectMapper mapper = new ObjectMapper();
final String asString = mapper.writeValueAsString(serviceInstantiationPayload);
@@ -449,7 +549,7 @@ public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseT
final ServiceInstantiation asObject = mapper.readValue(asString, ServiceInstantiation.class);
final String asString2 = mapper.writeValueAsString(asObject);
- JsonAssert.assertJsonEquals(asString, asString2);
+ assertJsonEquals(asString, asString2);
}
@DataProvider
@@ -517,10 +617,6 @@ public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseT
};
}
- private ServiceInstantiation generateMacroMockServiceInstantiationPayload(boolean isPause, Map<String, Vnf> vnfs) {
- return generateMockMacroServiceInstantiationPayload(isPause, vnfs, 1, true, PROJECT_NAME, false);
- }
-
@Test
public void testUpdateServiceInfo_WithExistingServiceInfo_ServiceInfoIsUpdated() {
UUID uuid = createFakedJobAndServiceInfo();
@@ -550,12 +646,12 @@ public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseT
return uuid;
}
- @Test(expectedExceptions = GenericUncheckedException.class, expectedExceptionsMessageRegExp = UPDATE_SERVICE_INFO_EXCEPTION_MESSAGE)
+ @Test(expectedExceptions = NotFoundException.class, expectedExceptionsMessageRegExp = UPDATE_SERVICE_INFO_EXCEPTION_MESSAGE)
public void testUpdateServiceInfo_WithNonExisting_ThrowException() {
asyncInstantiationBL.updateServiceInfo(UUID.randomUUID(), x -> x.setServiceInstanceName("not matter"));
}
- @Test(expectedExceptions = GenericUncheckedException.class, expectedExceptionsMessageRegExp = UPDATE_SERVICE_INFO_EXCEPTION_MESSAGE)
+ @Test(expectedExceptions = NotFoundException.class, expectedExceptionsMessageRegExp = UPDATE_SERVICE_INFO_EXCEPTION_MESSAGE)
public void testUpdateServiceInfo_WithDoubleServiceWithSameJobUuid_ThrowException() {
UUID uuid = createFakedJobAndServiceInfo();
ServiceInfo serviceInfo = new ServiceInfo();
@@ -584,219 +680,10 @@ public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseT
@Test
public void testCreateVnfEndpoint_useProvidedInstanceId() {
String path = asyncInstantiationBL.getVnfInstantiationPath("myGreatId");
- assertThat(path, matchesPattern("/serviceInstances/v./myGreatId/vnfs"));
- }
-
- @Test
- public void createServiceInfo_WithUserProvidedNamingFalse_ServiceInfoIsAsExpected() throws IOException {
- createMacroServiceInfo_WithUserProvidedNamingFalse_ServiceInfoIsAsExpected(true);
- }
-
- @Test
- public void createServiceInfo_WithUserProvidedNamingFalseAndNoVfmodules_ServiceInfoIsAsExpected() throws IOException {
- createMacroServiceInfo_WithUserProvidedNamingFalse_ServiceInfoIsAsExpected(false);
- }
-
- private void createMacroServiceInfo_WithUserProvidedNamingFalse_ServiceInfoIsAsExpected(boolean withVfmodules) throws IOException {
- when(featureManager.isActive(Features.FLAG_SHIFT_VFMODULE_PARAMS_TO_VNF)).thenReturn(true);
-
- ServiceInstantiation serviceInstantiationPayload = generateMockMacroServiceInstantiationPayload(true,
- createVnfList(vfModuleInstanceParamsMapWithParamsToRemove, Collections.EMPTY_LIST, false),
- 1,
- false, PROJECT_NAME, true);
- URL resource;
- if (withVfmodules) {
- resource = this.getClass().getResource("/payload_jsons/bulk_service_request_ecomp_naming.json");
- } else {
- // remove the vf modules
- serviceInstantiationPayload.getVnfs().values().forEach(vnf -> vnf.getVfModules().clear());
- resource = this.getClass().getResource("/payload_jsons/bulk_service_request_no_vfmodule_ecomp_naming.json");
- }
-
- RequestDetailsWrapper<ServiceInstantiationRequestDetails> result =
- asyncInstantiationBL.generateMacroServiceInstantiationRequest(null, serviceInstantiationPayload, serviceInstantiationPayload.getInstanceName(), "az2016");
-
- String expected = IOUtils.toString(resource, "UTF-8");
- MsoOperationalEnvironmentTest.assertThatExpectationIsLikeObject(expected, result);
- }
-
- @Test
- public void createALaCarteService_WithUserProvidedNamingFalse_RequestDetailsIsAsExpected() throws IOException {
- ServiceInstantiation serviceInstantiationPayload = generateMockALaCarteServiceInstantiationPayload(false,
- newHashMap(),
- newHashMap(),
- newHashMap(),
- 1,
- false, PROJECT_NAME, true, null);
-
- RequestDetailsWrapper<ServiceInstantiationRequestDetails> result =
- asyncInstantiationBL.generateALaCarteServiceInstantiationRequest(null, serviceInstantiationPayload, serviceInstantiationPayload.getInstanceName(), "az2016");
-
- URL resource = this.getClass().getResource("/payload_jsons/bulk_alacarte_service_request_naming_false.json");
- String expected = IOUtils.toString(resource, "UTF-8");
- MsoOperationalEnvironmentTest.assertThatExpectationIsLikeObject(expected, result);
- }
-
- @Test
- public void generateALaCarteServiceInstantiationRequest_withVnfList_HappyFllow() throws IOException {
- ServiceInstantiation serviceInstantiationPayload = generateALaCarteWithVnfsServiceInstantiationPayload();
- RequestDetailsWrapper<ServiceInstantiationRequestDetails> result =
- asyncInstantiationBL.generateALaCarteServiceInstantiationRequest(null, serviceInstantiationPayload, serviceInstantiationPayload.getInstanceName(), "az2016");
-
- String serviceExpected = IOUtils.toString(this.getClass().getResource("/payload_jsons/bulk_alacarte_service_request.json"), "UTF-8");
- MsoOperationalEnvironmentTest.assertThatExpectationIsLikeObject(serviceExpected, result);
+ assertThat(path, equalTo("/serviceInstantiation/v7/serviceInstances/myGreatId/vnfs"));
}
- @Test(dataProvider = "createVnfParameters")
- public void createVnfRequestDetails_detailsAreAsExpected(boolean isFlagAddCloudOwnerActive, boolean isUserProvidedNaming, String file) throws IOException {
- final List<Vnf> vnfList = new ArrayList<>(createVnfList(new HashMap<>(), null, isUserProvidedNaming, true).values());
- ModelInfo siModelInfo = createServiceModelInfo();
- String serviceInstanceId = "aa3514e3-5a33-55df-13ab-12abad84e7aa";
-
- //we validate that the asyncInstantiationBL call to getUniqueName by simulate that aai retrun that original
- //vnf name is used, and only next picked name is free.
- Mockito.reset(aaiClient);
- mockAaiClientAaiStatusOK();
- when(aaiClient.isNodeTypeExistsByName(eq(VNF_NAME), eq(ResourceType.GENERIC_VNF))).thenReturn(true);
- when(aaiClient.isNodeTypeExistsByName(eq(VNF_NAME+"_001"), eq(ResourceType.GENERIC_VNF))).thenReturn(false);
- enableAddCloudOwnerOnMsoRequest(isFlagAddCloudOwnerActive);
-
- String expected = IOUtils.toString(this.getClass().getResource(file), "UTF-8");
- final RequestDetailsWrapper<VnfInstantiationRequestDetails> result = asyncInstantiationBL.generateVnfInstantiationRequest(vnfList.get(0), siModelInfo, serviceInstanceId, "pa0916");
- MsoOperationalEnvironmentTest.assertThatExpectationIsLikeObject(expected, result);
- }
-
- @DataProvider
- public static Object[][] createVnfParameters() {
- return new Object[][]{
- {true, true, "/payload_jsons/bulk_vnf_request.json"},
- {false, true, "/payload_jsons/bulk_vnf_request_without_cloud_owner.json"},
- {true, false, "/payload_jsons/bulk_vnf_request_without_instance_name.json"},
- };
- }
-
- @DataProvider
- public static Object[][] vfModuleRequestDetails(Method test) {
- return new Object[][]{
- {"cc3514e3-5a33-55df-13ab-12abad84e7cc", true, "/payload_jsons/vfmodule_instantiation_request.json"},
- {null, true, "/payload_jsons/vfmodule_instantiation_request_without_volume_group.json"},
- {null, false, "/payload_jsons/vfmodule_instantiation_request_without_instance_name.json"}
- };
- }
-
- @Test(dataProvider = "vfModuleRequestDetails")
- public void createVfModuleRequestDetails_detailsAreAsExpected(String volumeGroupInstanceId, boolean isUserProvidedNaming, String fileName) throws IOException {
-
- ModelInfo siModelInfo = createServiceModelInfo();
- ModelInfo vnfModelInfo = createVnfModelInfo(true);
- List<Map<String, String>> instanceParams = ImmutableList.of(ImmutableMap.of("vmx_int_net_len", "24",
- "vre_a_volume_size_0" , "120"));
- Map<String, String> supplementaryParams = ImmutableMap.of("vre_a_volume_size_0" , "100",
- "availability_zone_0" , "mtpocdv-kvm-az01");
- VfModule vfModule = createVfModule("201673MowAvpnVpeBvL..AVPN_vRE_BV..module-1", "56e2b103-637c-4d1a-adc8-3a7f4a6c3240",
- "72d9d1cd-f46d-447a-abdb-451d6fb05fa8", instanceParams, supplementaryParams,
- (isUserProvidedNaming ? "vmxnjr001_AVPN_base_vRE_BV_expansion": null), "myVgName", true);
-
- String serviceInstanceId = "aa3514e3-5a33-55df-13ab-12abad84e7aa";
- String vnfInstanceId = "bb3514e3-5a33-55df-13ab-12abad84e7bb";
-
- Mockito.reset(aaiClient);
- mockAaiClientAaiStatusOK();
- enableAddCloudOwnerOnMsoRequest();
- when(aaiClient.isNodeTypeExistsByName(eq("vmxnjr001_AVPN_base_vRE_BV_expansion"), eq(ResourceType.VF_MODULE))).thenReturn(false);
-
- String expected = IOUtils.toString(this.getClass().getResource(fileName), "UTF-8");
- final RequestDetailsWrapper<VfModuleInstantiationRequestDetails> result = asyncInstantiationBL.generateVfModuleInstantiationRequest(
- vfModule, siModelInfo, serviceInstanceId,
- vnfModelInfo, vnfInstanceId, volumeGroupInstanceId, "pa0916");
- MsoOperationalEnvironmentTest.assertThatExpectationIsLikeObject(expected, result);
- }
-
- @DataProvider
- public static Object[][] expectedAggregatedParams() {
- return new Object[][]{
- {ImmutableMap.of("a", "b", "c", "d"), ImmutableMap.of("e", "f", "g", "h"), ImmutableList.of(ImmutableMap.of("c", "d", "a", "b", "e", "f", "g", "h"))},
- {ImmutableMap.of("a", "b", "c", "g"), ImmutableMap.of("c", "d", "e", "f"), ImmutableList.of(ImmutableMap.of("a", "b", "c", "d", "e", "f"))},
- {ImmutableMap.of(), ImmutableMap.of("c", "d", "e", "f"), ImmutableList.of(ImmutableMap.of("c", "d", "e", "f"))},
- {ImmutableMap.of("a", "b", "c", "g"), ImmutableMap.of(), ImmutableList.of(ImmutableMap.of("a", "b", "c", "g"))},
- {ImmutableMap.of(), ImmutableMap.of(), ImmutableList.of()},
- {null, ImmutableMap.of(), ImmutableList.of()},
- {ImmutableMap.of(), null, ImmutableList.of()},
- };
- }
-
- @Test(dataProvider = "expectedAggregatedParams")
- public void testAggregateInstanceParamsAndSuppFile(Map<String, String> instanceParams, Map<String, String> suppParams, List<VfModuleInstantiationRequestDetails.UserParamMap<String, String>> expected) {
- List<VfModuleInstantiationRequestDetails.UserParamMap<String, String>> aggParams = ((AsyncInstantiationBusinessLogicImpl)asyncInstantiationBL).aggregateAllInstanceParams(instanceParams, suppParams);
- assertThat("Aggregated params are not as expected", aggParams, equalTo(expected));
- }
-
- @DataProvider
- public static Object[][] expectedNetworkRequestDetailsParameters() {
- return new Object[][]{
- {true, "/payload_jsons/network_instantiation_request.json"},
- {false, "/payload_jsons/network_instantiation_request_without_instance_name.json"}
- };
- }
-
- @Test(dataProvider = "expectedNetworkRequestDetailsParameters")
- public void createNetworkRequestDetails_detailsAreAsExpected(boolean isUserProvidedNaming, String filePath) throws IOException {
-
- final List<Network> networksList = new ArrayList<>(createNetworkList(null, isUserProvidedNaming, true).values());
- ModelInfo siModelInfo = createServiceModelInfo();
- String serviceInstanceId = "aa3514e3-5a33-55df-13ab-12abad84e7aa";
-
- Mockito.reset(aaiClient);
- mockAaiClientAaiStatusOK();
- enableAddCloudOwnerOnMsoRequest();
- when(aaiClient.isNodeTypeExistsByName(eq(VNF_NAME), eq(ResourceType.L3_NETWORK))).thenReturn(true);
- when(aaiClient.isNodeTypeExistsByName(eq(VNF_NAME+"_001"), eq(ResourceType.L3_NETWORK))).thenReturn(false);
-
- String expected = IOUtils.toString(this.getClass().getResource(filePath), "UTF-8");
- final RequestDetailsWrapper<NetworkInstantiationRequestDetails> result = asyncInstantiationBL.generateNetworkInstantiationRequest(networksList.get(0), siModelInfo, serviceInstanceId, "pa0916");
- MsoOperationalEnvironmentTest.assertThatExpectationIsLikeObject(expected, result);
- }
-
- @Test
- public void createInstanceGroupRequestDetails_detailsAreAsExpected() throws IOException {
-
- final InstanceGroup instanceGroup = createInstanceGroup(true, Action.Create);
- ModelInfo siModelInfo = createServiceModelInfo();
- String serviceInstanceId = "aa3514e3-5a33-55df-13ab-12abad84e7aa";
-
- Mockito.reset(aaiClient);
- mockAaiClientAaiStatusOK();
- enableAddCloudOwnerOnMsoRequest();
- when(aaiClient.isNodeTypeExistsByName(eq(VNF_GROUP_NAME), eq(ResourceType.INSTANCE_GROUP))).thenReturn(true);
- when(aaiClient.isNodeTypeExistsByName(eq(VNF_GROUP_NAME+"_001"), eq(ResourceType.INSTANCE_GROUP))).thenReturn(false);
-
- String expected = IOUtils.toString(this.getClass().getResource("/payload_jsons/instance_group_instantiation_request.json"), "UTF-8");
- final RequestDetailsWrapper<InstanceGroupInstantiationRequestDetails> result = asyncInstantiationBL.generateInstanceGroupInstantiationRequest(instanceGroup, siModelInfo, serviceInstanceId, "az2018");
- MsoOperationalEnvironmentTest.assertThatExpectationIsLikeObject(expected, result);
- }
-
- @Test
- public void checkIfNullProjectNameSentToMso(){
- ServiceInstantiation serviceInstantiationPayload = generateMockMacroServiceInstantiationPayload(true,
- createVnfList(vfModuleInstanceParamsMapWithParamsToRemove, Collections.EMPTY_LIST, false),
- 1,
- false,null,false);
- RequestDetailsWrapper<ServiceInstantiationRequestDetails> result =
- asyncInstantiationBL.generateMacroServiceInstantiationRequest(null, serviceInstantiationPayload, serviceInstantiationPayload.getInstanceName(), "az2016");
- JsonNode jsonNode = new ObjectMapper().valueToTree(result.requestDetails);
- Assert.assertTrue(jsonNode.get("project").isNull());
- serviceInstantiationPayload = generateMockMacroServiceInstantiationPayload(true,
- createVnfList(vfModuleInstanceParamsMapWithParamsToRemove, Collections.EMPTY_LIST, false),
- 1,
- false,"not null",false);
- result = asyncInstantiationBL.generateMacroServiceInstantiationRequest(null, serviceInstantiationPayload, serviceInstantiationPayload.getInstanceName(), "az2016");
- jsonNode = new ObjectMapper().valueToTree(result.requestDetails);
- Assert.assertTrue(jsonNode.get("project").get("projectName").asText().equalsIgnoreCase("not null"));
-
-
-
- }
@Test
public void pushBulkJob_macroServiceverifyCreatedDateBehavior_createdDateIsTheSameForAllServicesInSameBulk() {
@@ -853,7 +740,9 @@ public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseT
Mockito.reset(jobAdapterMock);
final Job job = mock(Job.class);
when(job.getStatus()).thenReturn(PENDING);
- when(jobAdapterMock.createServiceInstantiationJob(any(), any(), any(), any(), any(), any())).thenReturn(job);
+ when(job.getUuid()).thenReturn(UUID.fromString("db2c5ed9-1c19-41ce-9cb7-edf0d878cdeb"));
+ when(jobAdapterMock.createServiceInstantiationJob(any(), any(), any(), any(), any(), any(), any())).thenReturn(job);
+ when(jobsBrokerServiceMock.add(job)).thenReturn(UUID.randomUUID());
}
@DataProvider
@@ -869,7 +758,11 @@ public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseT
{"Paused", JobStatus.PAUSE},
{"Pause", JobStatus.PAUSE},
{"PENDING_MANUAL_TASK", JobStatus.PAUSE},
- {"UNLOCKED", JobStatus.IN_PROGRESS}
+ {"UNLOCKED", JobStatus.IN_PROGRESS},
+ {"AbORtEd", COMPLETED_WITH_ERRORS},
+ {"RoLlED_baCK", FAILED},
+ {"ROllED_BAcK_To_ASsIGnED", FAILED},
+ {"rOLLED_bACK_tO_CrEATeD", FAILED},
};
}
@@ -879,131 +772,6 @@ public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseT
assertThat(asyncInstantiationBL.calcStatus(asyncRequestStatus), equalTo(expectedJobStatus));
}
- private void createNewAuditStatus(JobAuditStatus auditStatus)
- {
- Date createdDate= auditStatus.getCreated();
- dataAccessService.saveDomainObject(auditStatus, getPropsMap());
- setDateToStatus(auditStatus.getSource(), auditStatus.getJobStatus(), createdDate);
- }
-
-
-
- private static final String MSO_ARBITRARY_STATUS = "completed mso status";
-
- @DataProvider
- public static Object[][] auditStatuses(Method test) {
- return new Object[][]{
- {
- SourceStatus.VID,
- new String[]{ JobStatus.PENDING.toString(), JobStatus.IN_PROGRESS.toString()}
- },
- { SourceStatus.MSO,
- new String[]{ JobStatus.IN_PROGRESS.toString(), MSO_ARBITRARY_STATUS }
- }
- };
-
- }
-
- private void setDateToStatus(SourceStatus source, String status, Date date) {
- List<JobAuditStatus> jobAuditStatusList = dataAccessService.getList(JobAuditStatus.class, getPropsMap());
- DaoUtils.tryWithSessionAndTransaction(sessionFactory, session -> {
- jobAuditStatusList.stream()
- .filter(auditStatus -> source.equals(auditStatus.getSource()) && status.equals(auditStatus.getJobStatus()))
- .forEach(auditStatus -> {
- auditStatus.setCreated(date);
- session.saveOrUpdate(auditStatus);
- });
- return 1;
- });
- }
-
-
- @Test(dataProvider = "auditStatuses")
- public void givenSomeAuditStatuses_getStatusesOfSpecificSourceAndJobId_getSortedResultsMatchingToParameters(SourceStatus expectedSource, String [] expectedSortedStatuses){
- UUID jobUuid = UUID.randomUUID();
- List<JobAuditStatus> auditStatusList = com.google.common.collect.ImmutableList.of(
- new JobAuditStatus(jobUuid, IN_PROGRESS.toString(), SourceStatus.VID, toDate(LocalDateTime.now().minusHours(2))),
- new JobAuditStatus(jobUuid, IN_PROGRESS.toString(), SourceStatus.MSO, UUID.randomUUID(),"",toDate(LocalDateTime.now().minusHours(30))),
- new JobAuditStatus(jobUuid, MSO_ARBITRARY_STATUS, SourceStatus.MSO, UUID.randomUUID(),"",toDate(LocalDateTime.now().minusHours(3))),
- new JobAuditStatus(jobUuid, PENDING.toString(), SourceStatus.VID, toDate(LocalDateTime.now().minusHours(3))),
- new JobAuditStatus(UUID.randomUUID(), PENDING.toString(), SourceStatus.VID, toDate(LocalDateTime.now().minusHours(3))));
- auditStatusList.forEach((auditStatus) -> createNewAuditStatus(auditStatus));
- List<JobAuditStatus> statuses = asyncInstantiationBL.getAuditStatuses(jobUuid, expectedSource);
- List<String> statusesList = statuses.stream().map(status -> status.getJobStatus()).collect(Collectors.toList());
- Assert.assertTrue(statuses.stream().allMatch(status -> (status.getSource().equals(expectedSource)&& status.getJobId().equals(jobUuid))),"Only statuses of " + expectedSource + " for " + jobUuid + " should be returned. Returned statuses: " + String.join(",", statusesList ));
- assertThat(statusesList, contains(expectedSortedStatuses));
- }
-
-
-
- @Test
- public void addSomeVidStatuses_getThem_verifyGetInsertedWithoutDuplicates(){
- ImmutableList<JobStatus> statusesToBeInserted = ImmutableList.of(PENDING, IN_PROGRESS, IN_PROGRESS, COMPLETED);
- UUID jobUuid = UUID.randomUUID();
- statusesToBeInserted.forEach(status->
- {
- asyncInstantiationBL.auditVidStatus(jobUuid, status);
- });
- List<String> statusesFromDB = asyncInstantiationBL.getAuditStatuses(jobUuid, SourceStatus.VID).stream().map(auditStatus -> auditStatus.getJobStatus()).collect(Collectors.toList());
- List<String> statusesWithoutDuplicates = statusesToBeInserted.stream().distinct().map(x -> x.toString()).collect(Collectors.toList());
- assertThat(statusesFromDB, is(statusesWithoutDuplicates));
- }
-
- @DataProvider
- public static Object[][] msoAuditStatuses(Method test) {
- UUID jobUuid = UUID.randomUUID();
- UUID requestId = UUID.randomUUID();
- return new Object[][]{
- {
- jobUuid,
- ImmutableList.of(
- new JobAuditStatus(jobUuid, PENDING.toString(), SourceStatus.MSO, null, null),
- new JobAuditStatus(jobUuid, IN_PROGRESS.toString(), SourceStatus.MSO, requestId, null),
- new JobAuditStatus(jobUuid, IN_PROGRESS.toString(), SourceStatus.MSO, requestId, null),
- new JobAuditStatus(jobUuid, IN_PROGRESS.toString(), SourceStatus.MSO, requestId, null),
- new JobAuditStatus(jobUuid, COMPLETED.toString(), SourceStatus.MSO, requestId, null)),
- ImmutableList.of(PENDING.toString(), IN_PROGRESS.toString(), COMPLETED.toString()),
- "All distinct statuses should be without duplicates"
- },
- {
- jobUuid,
- ImmutableList.of(
- new JobAuditStatus(jobUuid, PENDING.toString(), SourceStatus.MSO, null, null),
- new JobAuditStatus(jobUuid, IN_PROGRESS.toString(), SourceStatus.MSO, requestId, null),
- new JobAuditStatus(jobUuid, IN_PROGRESS.toString(), SourceStatus.MSO, requestId, "aa"),
- new JobAuditStatus(jobUuid, IN_PROGRESS.toString(), SourceStatus.MSO, requestId, "aa"),
- new JobAuditStatus(jobUuid, IN_PROGRESS.toString(), SourceStatus.MSO, UUID.randomUUID(), "aa"),
- new JobAuditStatus(jobUuid, COMPLETED.toString(), SourceStatus.MSO, requestId, null)),
- ImmutableList.of(PENDING.toString(), IN_PROGRESS.toString(), IN_PROGRESS.toString(),IN_PROGRESS.toString(), COMPLETED.toString()),
- "Statuses should be without duplicates only with same requestId and additionalInfo"
-
- }
- };
- }
-
- @Test(dataProvider = "msoAuditStatuses")
- public void addSomeMsoStatuses_getThem_verifyGetInsertedWithoutDuplicates(UUID jobUuid, ImmutableList<JobAuditStatus> msoStatuses, ImmutableList<String> expectedStatuses, String assertionReason) {
- msoStatuses.forEach(status -> {
- asyncInstantiationBL.auditMsoStatus(status.getJobId(), status.getJobStatus(), status.getRequestId() != null ? status.getRequestId().toString() : null, status.getAdditionalInfo());
- });
- List<String> statusesFromDB = asyncInstantiationBL.getAuditStatuses(jobUuid, SourceStatus.MSO).stream().map(auditStatus -> auditStatus.getJobStatus()).collect(Collectors.toList());
- assertThat( assertionReason, statusesFromDB, is(expectedStatuses));
- }
-
- @Test
- public void addSameStatusOfVidAndMso_verifyThatBothWereAdded(){
- UUID jobUuid = UUID.randomUUID();
- JobStatus sameStatus = IN_PROGRESS;
- asyncInstantiationBL.auditMsoStatus(jobUuid, sameStatus.toString(),null,null);
- asyncInstantiationBL.auditVidStatus(jobUuid, sameStatus);
- List<JobAuditStatus> list = dataAccessService.getList(
- JobAuditStatus.class,
- String.format(" where JOB_ID = '%s'", jobUuid),
- null, null);
- Assert.assertEquals(list.size(),2);
- assertThat(list,everyItem(hasProperty("jobStatus", is(sameStatus.toString()))));
- }
-
@DataProvider
public static Object[][] msoRequestStatusFiles(Method test) {
return new Object[][]{
@@ -1026,7 +794,7 @@ public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseT
doNothing().when(jobsBrokerServiceMock).delete(any());
UUID uuid = createServicesInfoWithDefaultValues(PENDING);
asyncInstantiationBL.deleteJob(uuid);
- assertNotNull(asyncInstantiationBL.getServiceInfoByJobId(uuid).getDeletedAt(), "service info wasn't deleted");
+ assertNotNull(asyncInstantiationRepository.getServiceInfoByJobId(uuid).getDeletedAt(), "service info wasn't deleted");
}
@Test(expectedExceptions = IllegalStateException.class, expectedExceptionsMessageRegExp = DELETE_SERVICE_INFO_STATUS_EXCEPTION_MESSAGE)
@@ -1036,7 +804,7 @@ public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseT
try {
asyncInstantiationBL.deleteJob(uuid);
} catch (Exception e) {
- assertNull(asyncInstantiationBL.getServiceInfoByJobId(uuid).getDeletedAt(), "service info shouldn't deleted");
+ assertNull(asyncInstantiationRepository.getServiceInfoByJobId(uuid).getDeletedAt(), "service info shouldn't deleted");
throw e;
}
}
@@ -1081,7 +849,7 @@ public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseT
try {
asyncInstantiationBL.hideServiceInfo(uuid);
} catch (Exception e) {
- assertFalse(asyncInstantiationBL.getServiceInfoByJobId(uuid).isHidden(), "service info shouldn't be hidden");
+ assertFalse(asyncInstantiationRepository.getServiceInfoByJobId(uuid).isHidden(), "service info shouldn't be hidden");
throw e;
}
}
@@ -1126,16 +894,23 @@ public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseT
assertThat(asyncInstantiationBL.getUniqueName(name, type), equalTo(name+"_001"));
}
+ @Test(enabled = false) //skip till we will handle macro bulk again...
+ public void whenNamedNotInUsedInAai_getSameNameTwice() {
+ String name = someCommonStepsAndGetName();
+ ResourceType type = ResourceType.GENERIC_VNF;
+ when(aaiClient.isNodeTypeExistsByName(name, type)).thenReturn(false);
+ assertThat(asyncInstantiationBL.getUniqueName(name, type), equalTo(name));
+ assertThat(asyncInstantiationBL.getUniqueName(name, type), equalTo(name));
+ when(aaiClient.isNodeTypeExistsByName(name, type)).thenReturn(true);
+ assertThat(asyncInstantiationBL.getUniqueName(name, type), equalTo(name+"_001"));
+ }
+
private String someCommonStepsAndGetName() {
mockAaiClientAaiStatusOK();
return UUID.randomUUID().toString();
}
- private void mockAaiClientAaiStatusOK() {
- when(aaiClient.isNodeTypeExistsByName(eq(AsyncInstantiationBusinessLogicImpl.NAME_FOR_CHECK_AAI_STATUS), any())).thenReturn(false);
- }
-
- @Test(expectedExceptions=ExceptionWithRequestInfo.class)
+ @Test(expectedExceptions= ExceptionWithRequestInfo.class)
public void whenAaiBadResponseCode_throwInvalidAAIResponseException() {
String name = someCommonStepsAndGetName();
ResourceType type = ResourceType.SERVICE_INSTANCE;
@@ -1171,7 +946,7 @@ public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseT
ArgumentCaptor<JobType> argumentCaptor = ArgumentCaptor.forClass(JobType.class);
asyncInstantiationBL.pushBulkJob(request, "myUserId");
- verify(jobAdapterMock).createServiceInstantiationJob(argumentCaptor.capture(),any(),any(),anyString(), anyString(), anyInt());
+ verify(jobAdapterMock).createServiceInstantiationJob(argumentCaptor.capture(),any(),any(),anyString(), anyString(), anyString(), anyInt());
assertTrue(argumentCaptor.getValue().equals(JobType.ALaCarteServiceInstantiation));
}
@@ -1184,198 +959,285 @@ public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseT
ArgumentCaptor<JobType> argumentCaptor = ArgumentCaptor.forClass(JobType.class);
asyncInstantiationBL.pushBulkJob(request, "myUserId");
- verify(jobAdapterMock).createServiceInstantiationJob(argumentCaptor.capture(),any(),any(),anyString(), anyString(), anyInt());
+ verify(jobAdapterMock).createServiceInstantiationJob(argumentCaptor.capture(),any(),any(),anyString(), any(), anyString(), anyInt());
assertTrue(argumentCaptor.getValue().equals(JobType.MacroServiceInstantiation));
}
- @Test
- public void generateALaCarteServiceInstantiationRequest_verifyRequestIsAsExpected() throws IOException {
- ServiceInstantiation serviceInstantiationPayload = generateALaCarteServiceInstantiationPayload();
- final URL resource = this.getClass().getResource("/payload_jsons/bulk_alacarte_service_request.json");
- RequestDetailsWrapper<ServiceInstantiationRequestDetails> result =
- asyncInstantiationBL.generateALaCarteServiceInstantiationRequest(null, serviceInstantiationPayload, serviceInstantiationPayload.getInstanceName(), "az2016");
- String expected = IOUtils.toString(resource, "UTF-8");
- MsoOperationalEnvironmentTest.assertThatExpectationIsLikeObject(expected, result);
- }
+
@Test
- public void generateALaCarteServiceDeletionRequest_verifyRequestIsAsExpected() throws IOException {
- final URL resource = this.getClass().getResource("/payload_jsons/bulk_alacarte_service_deletion_request.json");
- String expected = IOUtils.toString(resource, "UTF-8");
+ public void getALaCarteServiceDeletionPath_verifyPathIsAsExpected() {
- ServiceInstantiation serviceDeletionPayload = generateALaCarteServiceDeletionPayload();
- RequestDetailsWrapper<ServiceDeletionRequestDetails> result =
- asyncInstantiationBL.generateALaCarteServiceDeletionRequest(null, serviceDeletionPayload, "az2016");
+ String expected = "/serviceInstantiation/v7/serviceInstances/f36f5734-e9df-4fbf-9f35-61be13f028a1";
- MsoOperationalEnvironmentTest.assertThatExpectationIsLikeObject(expected, result);
+ String result = asyncInstantiationBL.getServiceDeletionPath("f36f5734-e9df-4fbf-9f35-61be13f028a1");
+
+ assertThat(expected,equalTo(result));
}
@Test
- public void getALaCarteServiceDeletionPath_verifyPathIsAsExpected() throws IOException {
+ public void getResumeRequestPath_verifyPathIsAsExpected() {
- String expected = "/serviceInstantiation/v./serviceInstances/f36f5734-e9df-4fbf-9f35-61be13f028a1";
+ String expected = "/orchestrationRequests/v7/rq1234d1-5a33-55df-13ab-12abad84e333/resume";
- String result = asyncInstantiationBL.getServiceDeletionPath("f36f5734-e9df-4fbf-9f35-61be13f028a1");
+ String result = asyncInstantiationBL.getResumeRequestPath("rq1234d1-5a33-55df-13ab-12abad84e333");
- assertThat(result, matchesPattern(expected));
+ assertThat(expected, equalTo(result));
}
@Test
public void getInstanceGroupsDeletionPath_verifyPathIsAsExpected() {
-
assertEquals(asyncInstantiationBL.getInstanceGroupDeletePath("9aada4af-0f9b-424f-ae21-e693bd3e005b"),
"/serviceInstantiation/v7/instanceGroups/9aada4af-0f9b-424f-ae21-e693bd3e005b");
}
+ @Test
+ public void whenLcpRegionNotEmpty_thenCloudRegionIdOfResourceIsLegacy() {
+ String legacyCloudRegion = "legacyCloudRegion";
+ Vnf vnf = new Vnf(new ModelInfo(), null, null, Action.Create.name(), null, "anyCloudRegion", legacyCloudRegion,
+ null, null, null, false, null, null, UUID.randomUUID().toString(), null, null);
+ assertThat(vnf.getLcpCloudRegionId(), equalTo(legacyCloudRegion));
+ }
+
+ @Test
+ public void whenLcpRegionNotEmpty_thenCloudRegionIdOfServiceIsLegacy() {
+ String legacyCloudRegion = "legacyCloudRegion";
+ ServiceInstantiation service = new ServiceInstantiation(new ModelInfo(), null, null, null, null, null, null,
+ null, null, "anyCloudRegion", legacyCloudRegion, null, null, null, null, null, null, null, null, null,
+ false, 1,false, false, null, null, Action.Create.name(), UUID.randomUUID().toString(), null, null, null);
+ assertThat(service.getLcpCloudRegionId(), equalTo(legacyCloudRegion));
+ }
+
@DataProvider
- public static Object[][] testBuildVnfInstanceParamsDataProvider(Method test) {
+ public static Object[][] getJobTypeByRequest_verifyResultAsExpectedDataProvider() {
return new Object[][]{
- {
- Collections.EMPTY_LIST,
- ImmutableList.of(
- ImmutableList.of(ImmutableMap.of("k1","v1","k2","v2")),
- ImmutableList.of(ImmutableMap.of("k3","v3","k2","v2"))
- ),
- true,
- ImmutableList.of(ImmutableMap.of("k1","v1","k2","v2","k3","v3"))
- },
- {
- ImmutableList.of(ImmutableMap.of("j1", "w1", "k1","v1", "vnf_name","w2", "vf_module_name","w3")), //vnf_name, vf_module_name are excluded
- ImmutableList.of(
- ImmutableList.of(ImmutableMap.of("k1","v1","k2","v2")),
- ImmutableList.of(ImmutableMap.of("k3","v3","k2","v2")),
- ImmutableList.of(Collections.EMPTY_MAP),
- Collections.singletonList(null)
- ),
- true,
- ImmutableList.of(ImmutableMap.of("k1","v1","k2","v2","k3","v3","j1", "w1"))
- },
- {
- Collections.EMPTY_LIST,
- Arrays.asList(null, null),
- true,
- Collections.EMPTY_LIST //mso is expect to empty list and not list with empty map
- },
- {
- ImmutableList.of(Collections.EMPTY_MAP),
- ImmutableList.of(
- ImmutableList.of(Collections.EMPTY_MAP),
- ImmutableList.of(Collections.EMPTY_MAP)
- ),
- true,
- Collections.EMPTY_LIST //mso is expect to empty list and not list with empty map
- },
- {
- Collections.EMPTY_LIST,
- ImmutableList.of(
- ImmutableList.of(ImmutableMap.of("k1","v1","k2","v2")),
- ImmutableList.of(ImmutableMap.of("k3","v3","k2","v2"))
- ),
- false,
- Collections.EMPTY_LIST //mso is expect to empty list and not list with empty map
- },
- {
- ImmutableList.of(ImmutableMap.of("j1", "w1", "k1","v1", "vnf_name","w2", "vf_module_name","w3")),
- ImmutableList.of(
- ImmutableList.of(Collections.EMPTY_MAP)
- ),
- false,
- ImmutableList.of(ImmutableMap.of("j1", "w1", "k1","v1"))
- },
- {
- ImmutableList.of(ImmutableMap.of("vnf_name","w2", "vf_module_name", "w3", "j2", "w2", "j4","w4")),
- ImmutableList.of(
- ImmutableList.of(ImmutableMap.of("k1","v1","k2","v2")),
- ImmutableList.of(ImmutableMap.of("k3","v3","k2","v2"))
- ),
- false,
- ImmutableList.of(ImmutableMap.of("j2", "w2", "j4","w4"))
- },
-
+ {false, Action.Create, JobType.MacroServiceInstantiation},
+ {true, Action.Create, JobType.ALaCarteServiceInstantiation},
+ {true, Action.Delete, JobType.ALaCarteService},
};
}
- @Test(dataProvider="testBuildVnfInstanceParamsDataProvider")
- public void testBuildVnfInstanceParams(List<Map<String, String>> currentVnfInstanceParams,
- List<List<Map<String, String>>> vfModulesInstanceParams,
- boolean isFeatureActive,
- List<Map<String,String>> expectedResult){
- when(featureManager.isActive(Features.FLAG_SHIFT_VFMODULE_PARAMS_TO_VNF)).thenReturn(isFeatureActive);
- List<VfModuleMacro> vfModules =
- vfModulesInstanceParams.stream().map(params-> new VfModuleMacro(new ModelInfo(), null, null, params)).collect(Collectors.toList());
- List<Map<String,String>> actual = asyncInstantiationBL.buildVnfInstanceParams(currentVnfInstanceParams, vfModules);
- assertThat(actual, equalTo(expectedResult));
+ @Test(dataProvider = "getJobTypeByRequest_verifyResultAsExpectedDataProvider")
+ public void getJobTypeByRequest_verifyResultAsExpected(boolean isALaCarte, Action action, JobType expectedJobType) {
+ ServiceInstantiation service = createServiceWithIsALaCarteAndAction(isALaCarte, action);
+ assertThat(asyncInstantiationBL.getJobType(service), equalTo(expectedJobType));
+ }
+ @NotNull
+ protected ServiceInstantiation createServiceWithIsALaCarteAndAction(boolean isALaCarte, Action action) {
+ return new ServiceInstantiation(new ModelInfo(), null, null, null, null, null, null,
+ null, null, null, null, null, null, null, null, null, null, null, null, null,
+ false, 1, false, isALaCarte, null, null, action.name(),
+ UUID.randomUUID().toString(), null, null, null);
}
- @Test
- public void whenLcpRegionNotEmpty_thenCloudRegionIdOfResourceIsLegacy() {
- String legacyCloudRegion = "legacyCloudRegion";
- Vnf vnf = new Vnf(new ModelInfo(), null, null, Action.Create.name(), null, "anyCloudRegion", legacyCloudRegion, null, null, null, false, null, null);
- assertThat(vnf.getLcpCloudRegionId(), equalTo(legacyCloudRegion));
+ @DataProvider
+ public static Object[][] isRetryEnabledForStatusDataProvider(Method test) {
+ return new Object[][]{
+ {FAILED, true, true},
+ {COMPLETED_WITH_ERRORS, true, true},
+ {COMPLETED_WITH_NO_ACTION, true, false},
+ {COMPLETED, true, false},
+ {IN_PROGRESS, true, false},
+ {FAILED, false, false},
+ {COMPLETED_WITH_ERRORS, false, false},
+ {COMPLETED, false, false},
+ };
+ }
+ @Test(dataProvider = "isRetryEnabledForStatusDataProvider")
+ public void whenUpdateServiceInfoAndAuditStatus_thenServiceInfoRowIsUpdatedAndIsRetryIsRight(
+ JobStatus jobStatus, boolean isRetryfeatureEnabled, boolean expectedIsRetry) {
+ when(featureManager.isActive(Features.FLAG_1902_RETRY_JOB)).thenReturn(isRetryfeatureEnabled);
+ UUID uuid = createFakedJobAndServiceInfo();
+ asyncInstantiationBL.updateServiceInfoAndAuditStatus(uuid, jobStatus);
+ ServiceInfo serviceInfo = ((List<ServiceInfo>)dataAccessService.getList(ServiceInfo.class, getPropsMap())).
+ stream().filter(x->x.getJobId().equals(uuid)).findFirst().get();
+ assertEquals(jobStatus, serviceInfo.getJobStatus());
+
+ //we don't test serviceInfo.getStatusModifiedDate() because it's too complicated
+ assertEquals(expectedIsRetry, serviceInfo.isRetryEnabled());
}
@Test
- public void whenLcpRegionNotEmpty_thenCloudRegionIdOfServiceIsLegacy() {
- String legacyCloudRegion = "legacyCloudRegion";
- ServiceInstantiation service = new ServiceInstantiation(new ModelInfo(), null, null, null, null, null, null,
- null, null, "anyCloudRegion", legacyCloudRegion, null, null, null, null, null, null, null, null,
- false, 1,false, false, null, null, Action.Create.name());
- assertThat(service.getLcpCloudRegionId(), equalTo(legacyCloudRegion));
+ public void givenServiceWithNullTrackByIds_whenReplaceTrackByIds_thenAllLevelsHasTrackByIdWithUUID() {
+ ServiceInstantiation serviceInstantiation = FakeResourceCreator.createServiceWith2InstancesInEachLevel(Action.Create);
+ //assert for the given that all trackById are null
+ assertTrackByIdRecursively(serviceInstantiation, is(nullValue()), new HashSet<>());
+ ServiceInstantiation modifiedServiceInstantiation = asyncInstantiationBL.prepareServiceToBeUnique(serviceInstantiation);
+ assertTrackByIdRecursively(modifiedServiceInstantiation, uuidRegexMatcher, new HashSet<>());
+ }
+
+ private void assertTrackByIdRecursively(BaseResource baseResource, org.hamcrest.Matcher matcher, Set<String> usedUuids) {
+ assertThat(baseResource.getTrackById(), matcher);
+ if (baseResource.getTrackById()!=null) {
+ assertThat(usedUuids, not(hasItem(baseResource.getTrackById())));
+ usedUuids.add(baseResource.getTrackById());
+ }
+ baseResource.getChildren().forEach(x->assertTrackByIdRecursively(x, matcher, usedUuids));
}
@Test
- public void createVolumeGroup_verifyResultAsExpected() throws IOException {
- final URL resource = this.getClass().getResource("/payload_jsons/volumegroup_instantiation_request.json");
- VfModule vfModule = createVfModule("201673MowAvpnVpeBvL..AVPN_vRE_BV..module-1",
- "56e2b103-637c-4d1a-adc8-3a7f4a6c3240",
- "72d9d1cd-f46d-447a-abdb-451d6fb05fa8",
- Collections.emptyList(),
- Collections.emptyMap(),
- "vmxnjr001_AVPN_base_vRE_BV_expansion",
- "myVgName",
- true);
- vfModule.getModelInfo().setModelInvariantId("ff5256d2-5a33-55df-13ab-12abad84e7ff");
- vfModule.getModelInfo().setModelVersion("1");
- ModelInfo vnfModelInfo = createVnfModelInfo(true);
- RequestDetailsWrapper<VolumeGroupRequestDetails> result =
- asyncInstantiationBL.generateVolumeGroupInstantiationRequest(vfModule,
- createServiceModelInfo(),
- "ff3514e3-5a33-55df-13ab-12abad84e7ff",
- vnfModelInfo,
- "vnfInstanceId",
- "az2016");
- String expected = IOUtils.toString(resource, "UTF-8");
- MsoOperationalEnvironmentTest.assertThatExpectationIsLikeObject(expected, result);
+ public void givenServicefromDB_returnsTheBulkRequest() throws IOException {
+ ServiceInstantiation serviceInstantiation = TestUtils.readJsonResourceFileAsObject("/payload_jsons/VnfGroupCreate3Delete1None1Request.json", ServiceInstantiation.class);
+ UUID jobId = UUID.randomUUID();
+ doReturn(serviceInstantiation).when(asyncInstantiationRepository).getJobRequest(jobId);
+ doReturn(mock(Map.class)).when(asyncInstantiationRepository).getResourceInfoByRootJobId(jobId);
+ ServiceInstantiation modifiedServiceInstantiation = asyncInstantiationBL.getBulkForRetry(jobId);
+ assertThat(modifiedServiceInstantiation, jsonEquals(serviceInstantiation).when(IGNORING_ARRAY_ORDER));
}
@Test
- public void getJobTypeByRequest_verifyResultAsExpected(){
- ServiceInstantiation service = new ServiceInstantiation(new ModelInfo(), null, null, null, null, null, null,
- null, null, null, null, null, null, null, null, null, null, null, null,
- false, 1,false, false, null, null, Action.Create.name());
- JobType jobType = asyncInstantiationBL.getJobType(service) ;
- assertThat(jobType, equalTo(JobType.MacroServiceInstantiation));
- service = new ServiceInstantiation(new ModelInfo(), null, null, null, null, null, null,
- null, null, null, null, null, null, null, null, null, null, null, null,
- false, 1,false, true, null, null, Action.Create.name());
- jobType = asyncInstantiationBL.getJobType(service);
- assertThat(jobType, equalTo(JobType.ALaCarteServiceInstantiation));
- service = new ServiceInstantiation(new ModelInfo(), null, null, null, null, null, null,
- null, null, null, null, null, null, null, null, null, null, null, null,
- false, 1,false, true, null, null, Action.Delete.name());
- jobType = asyncInstantiationBL.getJobType(service);
- assertThat(jobType, equalTo(JobType.ALaCarteService));
+ public void givenServiceFromDB_returnsResolvedData() throws IOException {
+ ServiceInstantiation serviceInstantiation = TestUtils.readJsonResourceFileAsObject("/payload_jsons/VnfGroupCreate3Delete1None1Request.json", ServiceInstantiation.class);
+ ServiceInstantiation expectedServiceInstantiation = TestUtils.readJsonResourceFileAsObject("/payload_jsons/VnfGroupCreate3Delete1None1RequestResolvedForRetry.json", ServiceInstantiation.class);
+ UUID jobId = UUID.randomUUID();
+ AsyncRequestStatus asyncRequestStatus = TestUtils.readJsonResourceFileAsObject(
+ "/responses/mso/orchestrationRequestsVnf.json",
+ AsyncRequestStatus.class);
+ Map<String, ResourceInfo> mockedResourceInfoMap = ImmutableMap.of(
+ "groupingservicefortest..ResourceInstanceGroup..0:001", new ResourceInfo("groupingservicefortest..ResourceInstanceGroup..0:001",jobId,"VNF_GROUP1_INSTANCE_ID", COMPLETED, asyncRequestStatus),// TODO case: delete completed
+ "ag5aav86u4j", new ResourceInfo("ag5aav86u4j",jobId, null, FAILED, asyncRequestStatus),// case: failed
+ "asedrftjko", new ResourceInfo("asedrftjko",jobId, "VNF_GROUP1_INSTANCE_ID_3", COMPLETED, asyncRequestStatus),//case: completed after retry failed
+ "rgedfdged4", new ResourceInfo("rgedfdged4", jobId,"VNF_GROUP1_INSTANCE_ID_4", COMPLETED, asyncRequestStatus ));// case: create completed
+
+ doReturn(mockedResourceInfoMap).when(asyncInstantiationRepository).getResourceInfoByRootJobId(jobId);
+ ServiceInstantiation modifiedServiceInstantiation = asyncInstantiationBL.enrichBulkForRetry(serviceInstantiation,jobId);
+ assertThat(modifiedServiceInstantiation, jsonEquals(expectedServiceInstantiation).when(IGNORING_ARRAY_ORDER));
+ }
+
+ @DataProvider
+ public static Object[][] readStatusMsgDataProvider(Method test) throws IOException {
+ AsyncRequestStatus asyncRequestStatus = TestUtils.readJsonResourceFileAsObject(
+ "/responses/mso/orchestrationRequestsVnf.json",
+ AsyncRequestStatus.class);
+ return new Object[][]{
+ {null, null},
+ {new AsyncRequestStatus(), null},
+ {new AsyncRequestStatus(new AsyncRequestStatus.Request()), null},
+ {new AsyncRequestStatus(new AsyncRequestStatus.Request(new RequestStatus())), null},
+ {asyncRequestStatus, "Vnf has been created successfully."}
+ };
+ }
+
+ @Test(dataProvider = "readStatusMsgDataProvider")
+ public void resourceInfoReadStatusMsg_returnsStatusMsgOrNull(AsyncRequestStatus asyncRequestStatus, String expected) {
+ ResourceInfo resourceInfo = new ResourceInfo("groupingservicefortest..ResourceInstanceGroup..0:001",UUID.randomUUID(),"VNF_GROUP1_INSTANCE_ID", COMPLETED, asyncRequestStatus);
+ String msg= asyncInstantiationBL.readStatusMsg(resourceInfo);
+ assertThat(msg, equalTo( expected));
+ }
+
+ @Test
+ public void testAddResourceInfoForOkResponse() {
+ reset(asyncInstantiationRepository);
+ String serviceInstanceId = "service-instance-id";
+ UUID jobUuid = UUID.randomUUID();
+
+ asyncInstantiationBL.addResourceInfo(prepareSharedDataForAddResourceInfo(jobUuid), JobStatus.IN_PROGRESS, serviceInstanceId);
+
+ ArgumentCaptor<ResourceInfo> resourceInfoCaptor = ArgumentCaptor.forClass(ResourceInfo.class);
+ verify(asyncInstantiationRepository).saveResourceInfo(resourceInfoCaptor.capture());
+
+ ResourceInfo resourceInfo = resourceInfoCaptor.getValue();
+ assertResourceInfoValues(resourceInfo, serviceInstanceId, jobUuid, JobStatus.IN_PROGRESS);
+ assertThat(resourceInfo.getErrorMessage(), is(nullValue()));
+ }
+
+ private JobSharedData prepareSharedDataForAddResourceInfo(UUID jobUuid) {
+ ServiceInstantiation serviceInstantiation = mock(ServiceInstantiation.class);
+ when(serviceInstantiation.getTrackById()).thenReturn("track-by-id");
+ return new JobSharedData(jobUuid, "", serviceInstantiation, "");
+ }
+
+ private void assertResourceInfoValues(ResourceInfo resourceInfo, String serviceInstanceId, UUID jobUuid, JobStatus jobStatus) {
+ assertThat(resourceInfo.getInstanceId(), equalTo(serviceInstanceId));
+ assertThat(resourceInfo.getJobStatus(), equalTo(jobStatus));
+ assertThat(resourceInfo.getRootJobId(), equalTo(jobUuid));
+ assertThat(resourceInfo.getTrackById(), equalTo("track-by-id"));
+ }
+
+ @DataProvider
+ public static Object[][] addResourceInfoWithError() {
+ String message = "Failed to create service instance";
+ return new Object[][]{
+ {500, message},
+ {199, "{\"serviceException\":{\"messageId\":\"SVC2000\",\"text\":\"Error: " + message + "\"}}"}
+ };
}
- protected ServiceInstantiation generateALaCarteServiceInstantiationPayload() {
- return generateMockALaCarteServiceInstantiationPayload(false, Collections.EMPTY_MAP, Collections.EMPTY_MAP, Collections.EMPTY_MAP, 1, true, PROJECT_NAME, false, "VNF_API");
+ @Test(dataProvider = "addResourceInfoWithError")
+ public void testAddResourceInfoForErrorResponse(int errorCode, String errorMessage) {
+ reset(asyncInstantiationRepository);
+ UUID jobUuid = UUID.randomUUID();
+
+ RestObject restObject = mock(RestObject.class);
+ when(restObject.getStatusCode()).thenReturn(errorCode);
+ when(restObject.getRaw()).thenReturn(errorMessage);
+ asyncInstantiationBL.addFailedResourceInfo(prepareSharedDataForAddResourceInfo(jobUuid), restObject);
+
+ ArgumentCaptor<ResourceInfo> resourceInfoCaptor = ArgumentCaptor.forClass(ResourceInfo.class);
+ verify(asyncInstantiationRepository).saveResourceInfo(resourceInfoCaptor.capture());
+
+ ResourceInfo resourceInfo = resourceInfoCaptor.getValue();
+ assertResourceInfoValues(resourceInfo, null, jobUuid, JobStatus.FAILED);
+ assertThat(resourceInfo.getErrorMessage().request.requestStatus.getStatusMessage(), containsString("Failed to create service instance"));
+ assertThat(resourceInfo.getErrorMessage().request.requestStatus.getStatusMessage(), containsString(String.valueOf(errorCode)));
+ ZonedDateTime parsedDate = TimeUtils.parseZonedDateTime(resourceInfo.getErrorMessage().request.requestStatus.getTimestamp());
+ assertThat(parsedDate.toLocalDate(), is(LocalDate.now()));
+
+ doReturn(resourceInfo).when(asyncInstantiationRepository).getResourceInfoByTrackId(any());
+ JobAuditStatus jobAuditStatus = auditService.getResourceAuditStatus(resourceInfo.getTrackById());
+ assertThat(jobAuditStatus.getJobStatus(), equalTo("FAILED"));
+ assertThat(jobAuditStatus.getAdditionalInfo(), containsString("Failed to create service instance"));
+ assertThat(jobAuditStatus.getAdditionalInfo(), containsString(String.valueOf(errorCode)));
+ assertTrue(DateUtils.isSameDay(jobAuditStatus.getCreatedDate(), new Date()));
}
- private ServiceInstantiation generateALaCarteServiceDeletionPayload() {
- return generateMockALaCarteServiceDeletionPayload(false, Collections.EMPTY_MAP, Collections.EMPTY_MAP, Collections.EMPTY_MAP, 1, true, PROJECT_NAME, false, "VNF_API", "1234567890");
+ @DataProvider
+ public static Object[][] updateResourceInfoParameters() {
+ return new Object[][] {
+ {JobStatus.COMPLETED, "Instance was created successfully"},
+ {JobStatus.FAILED, "Failed to create instance"}
+ };
+ }
+
+ @Test(dataProvider = "updateResourceInfoParameters")
+ public void testUpdateResourceInfo(JobStatus jobStatus, String message) {
+ reset(asyncInstantiationRepository);
+ UUID jobUuid = UUID.randomUUID();
+ JobSharedData sharedData = new JobSharedData(jobUuid, "", mock(ServiceInstantiation.class),"");
+
+ ResourceInfo resourceInfoMock = new ResourceInfo();
+ resourceInfoMock.setTrackById(UUID.randomUUID().toString());
+ doReturn(resourceInfoMock).when(asyncInstantiationRepository).getResourceInfoByTrackId(any());
+
+ AsyncRequestStatus asyncRequestStatus = asyncInstantiationBL.convertMessageToAsyncRequestStatus(message);
+
+ asyncInstantiationBL.updateResourceInfo(sharedData, jobStatus, asyncRequestStatus);
+
+ ArgumentCaptor<ResourceInfo> resourceInfoCaptor = ArgumentCaptor.forClass(ResourceInfo.class);
+ verify(asyncInstantiationRepository).saveResourceInfo(resourceInfoCaptor.capture());
+
+ ResourceInfo resourceInfo = resourceInfoCaptor.getValue();
+ assertThat(resourceInfo.getJobStatus(), equalTo(jobStatus));
+ if (jobStatus == JobStatus.FAILED) {
+ assertThat(resourceInfo.getErrorMessage(), is(not(nullValue())));
+ assertThat(resourceInfo.getErrorMessage().request.requestStatus.getStatusMessage(), equalTo(message));
+ ZonedDateTime parsedDate = TimeUtils.parseZonedDateTime(resourceInfo.getErrorMessage().request.requestStatus.getTimestamp());
+ assertThat(parsedDate.toLocalDate(), is(LocalDate.now()));
+ } else {
+ assertThat(resourceInfo.getErrorMessage(), is(nullValue()));
+ }
+
+ JobAuditStatus jobAuditStatus = auditService.getResourceAuditStatus(resourceInfo.getTrackById());
+ if (jobStatus == JobStatus.FAILED) {
+ assertThat(jobAuditStatus.getJobStatus(), equalTo("FAILED"));
+ assertThat(jobAuditStatus.getAdditionalInfo(), equalTo(message));
+ } else {
+ assertThat(jobAuditStatus, is(nullValue()));
+ }
+
}
static class MockedJob implements Job {
@@ -1426,7 +1288,7 @@ public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseT
@Override
public JobSharedData getSharedData() {
- return new JobSharedData(uuid, "", null);
+ return new JobSharedData(uuid, "", null,"");
}
@Override
@@ -1463,4 +1325,13 @@ public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseT
return optimisticUniqueServiceInstanceName;
}
}
+
+
+ @Test
+ public void testGetVfModuleReplacePath_asMSOexpected()
+ {
+ String path = asyncInstantiationBL.getVfModuleReplacePath("myService", "myVNF", "myVFModule");
+ assertThat(path, equalTo("/serviceInstantiation/v7/serviceInstances/myService/vnfs/myVNF/vfModules/myVFModule/replace"));
+
+ }
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/AuditServiceImplTest.java b/vid-app-common/src/test/java/org/onap/vid/services/AuditServiceImplTest.java
index bdb2a2834..ce5840bfc 100644
--- a/vid-app-common/src/test/java/org/onap/vid/services/AuditServiceImplTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/services/AuditServiceImplTest.java
@@ -19,71 +19,88 @@
*/
package org.onap.vid.services;
-import org.glassfish.grizzly.http.util.HttpStatus;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.onap.vid.dal.AsyncInstantiationRepository;
import org.onap.vid.model.JobAuditStatus;
+import org.onap.vid.mso.RestMsoImplementation;
+import org.onap.vid.mso.RestObject;
+import org.onap.vid.mso.rest.AsyncRequestStatus;
import org.onap.vid.mso.rest.AsyncRequestStatusList;
import org.onap.vid.testUtils.TestUtils;
-import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.io.IOException;
-import java.util.Date;
import java.util.List;
-import java.util.UUID;
-import static java.util.stream.Collectors.toList;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.*;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.MockitoAnnotations.initMocks;
+import static org.hamcrest.Matchers.equalTo;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.when;
public class AuditServiceImplTest {
+
+ @Mock
+ private RestMsoImplementation restMso;
@Mock
- private AsyncInstantiationBusinessLogic asyncInstantiationBL;
+ private AsyncInstantiationRepository asyncInstantiationRepository;
@InjectMocks
private AuditServiceImpl auditService;
- @BeforeClass
- public void init() {
- initMocks(this);
+ @BeforeMethod
+ public void setUp() {
+ restMso = null;
+ asyncInstantiationRepository = null;
+ auditService = null;
+ MockitoAnnotations.initMocks(this);
}
@Test
- public void setFailedAuditStatusFromMsoTest() {
-
- UUID jobUuid = UUID.randomUUID();
- String requestId = "1";
- int statusCode = HttpStatus.OK_200.getStatusCode();
- String msoResponse = "{}";
-
- auditService.setFailedAuditStatusFromMso(jobUuid, requestId, statusCode, msoResponse);
-
- verify(asyncInstantiationBL, times(1))
- .auditMsoStatus(
- Mockito.any(UUID.class),
- Mockito.anyString(),
- Mockito.anyString(),
- Mockito.anyString());
+ public void testGetRequestsIdsByServiceIdAndRequestTypeAndScope() throws Exception {
+
+ String instanceId = "d40c8a82-cc04-45e5-a0f6-0c9394c8f8d2";
+ //the request id in multipleOrchestrationRequestsServiceInstance.json
+ String expectedRequestId = "fab854bf-e53c-415e-b3cc-b6fcce8414b2";
+ String msoBasePath = "/someMsoPath/v2019?";
+
+ AsyncRequestStatusList asyncRequestStatusList = TestUtils.readJsonResourceFileAsObject(
+ "/responses/mso/multipleOrchestrationRequestsServiceInstance.json",
+ AsyncRequestStatusList.class);
+ RestObject<AsyncRequestStatusList> msoResponse = new RestObject<>();
+ msoResponse.set(asyncRequestStatusList);
+ msoResponse.setStatusCode(200);
+ when(restMso.GetForObject(eq(msoBasePath + "filter=serviceInstanceId:EQUALS:" + instanceId),
+ eq(AsyncRequestStatusList.class)))
+ .thenReturn(msoResponse);
+ TestUtils.testWithSystemProperty("mso.restapi.get.orc.reqs", msoBasePath, () -> {
+ List<AsyncRequestStatus.Request> result = auditService
+ .retrieveRequestsFromMsoByServiceIdAndRequestTypeAndScope(instanceId, "createInstance", "service");
+ assertThat(result.size(), equalTo(1));
+ assertThat(result.get(0).requestId, equalTo(expectedRequestId));
+ assertThat(result.get(0).startTime, equalTo("Mon, 04 Mar 2019 20:47:15 GMT"));
+ });
}
@Test
- public void testConvertMsoResponseStatusToJobAuditStatus_missingDateFromMso_shouldNoError() throws IOException {
- final AsyncRequestStatusList asyncRequestStatusList = TestUtils.readJsonResourceFileAsObject("/orchestrationRequestsByServiceInstanceId.json", AsyncRequestStatusList.class);
-
- AuditServiceImpl auditService = new AuditServiceImpl(null, null);
-
- final List<JobAuditStatus> jobAuditStatuses = auditService.convertMsoResponseStatusToJobAuditStatus(asyncRequestStatusList.getRequestList(), "foo");
-
- final List<Date> dates = jobAuditStatuses.stream().map(JobAuditStatus::getCreatedDate).collect(toList());
- final List<String> statuses = jobAuditStatuses.stream().map(JobAuditStatus::getJobStatus).collect(toList());
+ public void nextOrdinalAfter_givenNull_returnZero() {
+ assertThat(
+ auditService.nextOrdinalAfter(null),
+ equalTo(0)
+ );
+ }
- assertThat(dates, containsInAnyOrder(notNullValue(), notNullValue(), nullValue()));
- assertThat(statuses, containsInAnyOrder("COMPLETE", "COMPLETE", "IN_PROGRESS"));
+ @Test
+ public void nextOrdinalAfter_givenX_returnXplus1() {
+ final int x = 6;
+ final JobAuditStatus jobAuditStatus = new JobAuditStatus();
+ jobAuditStatus.setOrdinal(x);
+
+ assertThat(
+ auditService.nextOrdinalAfter(jobAuditStatus),
+ equalTo(x + 1)
+ );
}
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/JobsBrokerServiceTest.java b/vid-app-common/src/test/java/org/onap/vid/services/JobsBrokerServiceTest.java
index 85cf23edd..40546e967 100644
--- a/vid-app-common/src/test/java/org/onap/vid/services/JobsBrokerServiceTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/services/JobsBrokerServiceTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -21,57 +21,22 @@
package org.onap.vid.services;
-import static java.util.concurrent.TimeUnit.MILLISECONDS;
-import static java.util.stream.Collectors.toList;
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.both;
-import static org.hamcrest.Matchers.containsInAnyOrder;
-import static org.onap.vid.job.Job.JobStatus.COMPLETED;
-import static org.onap.vid.job.Job.JobStatus.CREATING;
-import static org.onap.vid.job.Job.JobStatus.FAILED;
-import static org.onap.vid.job.Job.JobStatus.IN_PROGRESS;
-import static org.onap.vid.job.Job.JobStatus.PAUSE;
-import static org.onap.vid.job.Job.JobStatus.PENDING;
-import static org.onap.vid.job.Job.JobStatus.RESOURCE_IN_PROGRESS;
-import static org.onap.vid.job.Job.JobStatus.STOPPED;
-import static org.onap.vid.utils.Streams.not;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.AssertJUnit.assertEquals;
-
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
-import java.lang.reflect.Method;
-import java.time.LocalDateTime;
-import java.time.ZoneId;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-import java.util.Optional;
-import java.util.Set;
-import java.util.UUID;
-import java.util.concurrent.ConcurrentSkipListSet;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeoutException;
-import java.util.stream.IntStream;
-import java.util.stream.Stream;
-import javax.inject.Inject;
import org.apache.commons.lang.RandomStringUtils;
import org.apache.commons.lang3.RandomUtils;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
+import org.apache.commons.lang3.tuple.Pair;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.hibernate.SessionFactory;
+import org.jetbrains.annotations.NotNull;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
import org.onap.portalsdk.core.domain.support.DomainVo;
import org.onap.portalsdk.core.service.DataAccessService;
import org.onap.portalsdk.core.util.SystemProperties;
-import org.onap.vid.config.DataSourceConfig;
-import org.onap.vid.config.JobAdapterConfig;
import org.onap.vid.exceptions.GenericUncheckedException;
import org.onap.vid.exceptions.OperationNotAllowedException;
import org.onap.vid.job.Job;
@@ -80,8 +45,12 @@ import org.onap.vid.job.JobType;
import org.onap.vid.job.JobsBrokerService;
import org.onap.vid.job.command.JobCommandFactoryTest;
import org.onap.vid.job.impl.JobDaoImpl;
+import org.onap.vid.job.impl.JobSchedulerInitializer;
import org.onap.vid.job.impl.JobsBrokerServiceInDatabaseImpl;
+import org.onap.vid.services.VersionService;
import org.onap.vid.utils.DaoUtils;
+import org.onap.vid.config.DataSourceConfig;
+import org.onap.vid.config.JobAdapterConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.Assert;
@@ -90,6 +59,31 @@ import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
+import javax.inject.Inject;
+import java.lang.reflect.Method;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.util.*;
+import java.util.concurrent.*;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+import java.util.stream.Stream;
+
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static java.util.stream.Collectors.toList;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.both;
+import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.mockito.Mockito.when;
+import static org.onap.vid.job.Job.JobStatus.*;
+import static org.onap.vid.utils.Streams.not;
+import static org.onap.vid.testUtils.TestUtils.generateRandomAlphaNumeric;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertFalse;
+
@ContextConfiguration(classes = {DataSourceConfig.class, SystemProperties.class, JobAdapterConfig.class})
public class JobsBrokerServiceTest extends AbstractTestNGSpringContextTests {
@@ -101,7 +95,7 @@ public class JobsBrokerServiceTest extends AbstractTestNGSpringContextTests {
private final Set<Long> threadsIds = new ConcurrentSkipListSet<>();
- private final long FEW = 1000;
+ private final long FEW = 500;
private final String JOBS_SHOULD_MATCH = "the jobs that added and those that pulled must be the same";
private final String JOBS_PEEKED_SHOULD_MATCH = "the jobs that added and those that peeked must be the same";
@@ -116,6 +110,23 @@ public class JobsBrokerServiceTest extends AbstractTestNGSpringContextTests {
@Inject
private SessionFactory sessionFactory;
+ @Mock
+ private VersionService versionService;
+
+ @AfterMethod
+ public void threadsCounter() {
+ logger.info("participating threads count: " + threadsIds.size());
+ threadsIds.clear();
+ }
+
+ @BeforeMethod
+ public void initializeBroker() {
+ MockitoAnnotations.initMocks(this);
+ when(versionService.retrieveBuildNumber()).thenReturn("aBuildNumber");
+ broker = new JobsBrokerServiceInDatabaseImpl(dataAccessService, sessionFactory, 200, 0, versionService);
+ ((JobsBrokerServiceInDatabaseImpl) broker).deleteAll();
+ }
+
/*
- pulling jobs is limited to inserted ones
- putting back allows getting the job again
@@ -147,6 +158,7 @@ public class JobsBrokerServiceTest extends AbstractTestNGSpringContextTests {
new JobCommandFactoryTest.MockedRequest(42,"nothing") ,
UUID.randomUUID(),
userId,
+ null,
"optimisticUniqueServiceInstanceName",
RandomUtils.nextInt());
}
@@ -234,18 +246,6 @@ public class JobsBrokerServiceTest extends AbstractTestNGSpringContextTests {
threadsIds.add(Thread.currentThread().getId());
}
- @AfterMethod
- public void threadsCounter() {
- logger.info("participating threads count: " + threadsIds.size());
- threadsIds.clear();
- }
-
- @BeforeMethod
- public void initializeBroker() {
- broker = new JobsBrokerServiceInDatabaseImpl(dataAccessService, sessionFactory, 200, 0);
- ((JobsBrokerServiceInDatabaseImpl) broker).deleteAll();
- }
-
@Test
public void givenSingleJob_getIt_verifySameJob() {
final Job originalJob = waitForFutureJob(newJobAsync(broker));
@@ -254,6 +254,51 @@ public class JobsBrokerServiceTest extends AbstractTestNGSpringContextTests {
assertThat(JOBS_SHOULD_MATCH, retrievedJob, is(originalJob));
}
+ @DataProvider
+ public static Object[][] allTopics() {
+ return JobSchedulerInitializer.WORKERS_TOPICS.stream()
+ .map(topic -> new Object[] { topic })
+ .toArray(Object[][]::new);
+ }
+
+ @Test(dataProvider = "allTopics")
+ public void givenJobFromSameBuild_pullJobs_jobIsPulled(Job.JobStatus topic) {
+ when(versionService.retrieveBuildNumber()).thenReturn("someVersion");
+ Job mockedJob = createMockJob("user id", topic);
+ UUID uuid = broker.add(mockedJob);
+ assertEquals(uuid, broker.pull(topic, UUID.randomUUID().toString()).get().getUuid());
+ }
+
+
+ @Test(dataProvider = "allTopics")
+ public void givenJobFromOtherBuild_pullJobs_noneIsPulled(Job.JobStatus topic) {
+ when(versionService.retrieveBuildNumber()).thenReturn("old");
+ Job mockedJob = createMockJob("user id", topic);
+ broker.add(mockedJob);
+ when(versionService.retrieveBuildNumber()).thenReturn("new");
+ assertFalse(broker.pull(topic, UUID.randomUUID().toString()).isPresent());
+ }
+
+ @Test
+ public void givenJobWithNullBuildAndJobWithRealBuild_pullJobs_jobsWithNonNullIsPulled() {
+ Job.JobStatus topic = PENDING;
+
+ //push job with null build
+ when(versionService.retrieveBuildNumber()).thenReturn(null);
+ broker.add(createMockJob("user id", topic));
+
+ //push job with "aBuild" build
+ when(versionService.retrieveBuildNumber()).thenReturn("aBuild");
+ UUID newJobId = broker.add(createMockJob("user id", topic));
+
+ //pull jobs while current build is still "aBuild". Only the non null build is pulled
+ assertEquals(newJobId, broker.pull(topic, UUID.randomUUID().toString()).get().getUuid());
+
+ //no more jobs to pull
+ assertFalse(broker.pull(topic, UUID.randomUUID().toString()).isPresent());
+ }
+
+
@Test
public void givenManyJobs_getJobsAndPushThemBack_alwaysSeeAllOfThemWithPeek() throws InterruptedException {
final List<Job> originalJobs = putALotOfJobs(broker);
@@ -346,10 +391,10 @@ public class JobsBrokerServiceTest extends AbstractTestNGSpringContextTests {
() -> createNewJob(14, UUID.randomUUID(), "userId", STOPPED,null, oldestDate),
() -> createNewJob(22, UUID.randomUUID(), "userId", PENDING,null, oldestDate),
() -> createNewJob(33, UUID.randomUUID(), "userId", PENDING,null, LocalDateTime.now().minusHours(2))),
- 6,
- 5,
- PENDING,
- "Broker should pull the only pending - first pending job by oldest job - ignore deleted,completed, failed, in-progress and stopped statuses"
+ 6,
+ 5,
+ PENDING,
+ "Broker should pull the only pending - first pending job by oldest job - ignore deleted,completed, failed, in-progress and stopped statuses"
},
{ImmutableList.of(
(Jobber)() -> createNewJob(11, UUID.randomUUID(), "userId", IN_PROGRESS, UUID.randomUUID().toString(), oldestDate),
@@ -374,7 +419,7 @@ public class JobsBrokerServiceTest extends AbstractTestNGSpringContextTests {
() -> createNewJob(22, UUID.randomUUID(), "userId", PENDING, UUID.randomUUID().toString(), oldestDate),
() -> createNewJob(33, UUID.randomUUID(), "userId", PENDING, null, LocalDateTime.now().minusHours(2)),
() -> createNewJob(12, UUID.randomUUID(), "userId", RESOURCE_IN_PROGRESS, UUID.randomUUID().toString(), oldestDate)
- ),
+ ),
3,
2,
PENDING,
@@ -411,10 +456,10 @@ public class JobsBrokerServiceTest extends AbstractTestNGSpringContextTests {
(Jobber)() -> createNewJob(11, sameTemplate, "userId", FAILED, null, oldestDate, DELETED),
() -> createNewJob(22, sameTemplate, "userId", STOPPED,null, oldestDate),
() -> createNewJob(33, sameTemplate, "userId", PENDING,null, LocalDateTime.now().minusHours(2))),
- 3,
- 2,
- PENDING,
- "Broker should pull pending job when there is another job from this template that was deleted, although failed"
+ 3,
+ 2,
+ PENDING,
+ "Broker should pull pending job when there is another job from this template that was deleted, although failed"
},
{ ImmutableList.of(
(Jobber)() -> createNewJob(11, UUID.randomUUID(), "userA", IN_PROGRESS, null, oldestDate),
@@ -475,10 +520,10 @@ public class JobsBrokerServiceTest extends AbstractTestNGSpringContextTests {
() -> createNewJob(33, UUID.randomUUID(), "userId", IN_PROGRESS, null, LocalDateTime.now().minusHours(2)),
() -> createNewJob(16, UUID.randomUUID(), "userId", RESOURCE_IN_PROGRESS, null, oldestDate)
),
- 20,
- 6,
- IN_PROGRESS,
- "Broker with in progress topic should pull only in-progress jobs - first in-progress job by oldest date - ignore all other statuses"
+ 20,
+ 6,
+ IN_PROGRESS,
+ "Broker with in progress topic should pull only in-progress jobs - first in-progress job by oldest date - ignore all other statuses"
},
{ImmutableList.of(
(Jobber)() -> createNewJob(11, UUID.randomUUID(), "userId", COMPLETED, null, oldestDate),
@@ -541,14 +586,9 @@ public class JobsBrokerServiceTest extends AbstractTestNGSpringContextTests {
@Test(dataProvider = "jobs")
public void givenSomeJobs_pullNextJob_returnNextOrNothingAsExpected(List<Jobber> jobbers, int msoLimit, int expectedIndexSelected, Job.JobStatus topic, String assertionReason) {
- JobsBrokerServiceInDatabaseImpl broker = new JobsBrokerServiceInDatabaseImpl(dataAccessService, sessionFactory, msoLimit, 20);
- final List<JobDaoImpl> jobs = jobbers.stream().map(Jobber::toJob).collect(toList());
- for (JobDaoImpl job : jobs) {
- Date modifiedDate = job.getModified();
- broker.add(job);
- setModifiedDateToJob(job.getUuid(), modifiedDate);
- }
- Optional<Job> nextJob = broker.pull(topic, UUID.randomUUID().toString());
+ JobsBrokerServiceInDatabaseImpl aBroker = new JobsBrokerServiceInDatabaseImpl(dataAccessService, sessionFactory, msoLimit, 20, versionService);
+ final List<JobDaoImpl> jobs = addJobsWithModifiedDate(jobbers, aBroker);
+ Optional<Job> nextJob = aBroker.pull(topic, UUID.randomUUID().toString());
boolean shouldAnyBeSelected = expectedIndexSelected >= 0;
String pulledJobDesc = nextJob.map(job -> ". pulled job: " + job.toString()).orElse(". no job pulled");
Assert.assertEquals(nextJob.isPresent(), shouldAnyBeSelected, assertionReason+pulledJobDesc);
@@ -557,10 +597,206 @@ public class JobsBrokerServiceTest extends AbstractTestNGSpringContextTests {
}
}
+ @NotNull
+ protected List<JobDaoImpl> addJobsWithModifiedDate(List<Jobber> jobbers, JobsBrokerService broker) {
+ final List<JobDaoImpl> jobs = jobbers.stream().map(Jobber::toJob).collect(toList());
+ return addJobsWithModifiedDateByJobDao(jobs, broker);
+ }
+
+ @NotNull
+ private List<JobDaoImpl> addJobsWithModifiedDateByJobDao(List<JobDaoImpl> jobs, JobsBrokerService broker) {
+ for (JobDaoImpl job : jobs) {
+ Date modifiedDate = job.getModified();
+ broker.add(job);
+ setModifiedDateToJob(job.getUuid(), modifiedDate);
+ }
+ return jobs;
+ }
+
+ @DataProvider
+ public static Object[][] jobsForTestingPendingResource(Method test) {
+ UUID templateId1 = UUID.fromString("311a9196-bbc5-47a1-8b11-bf0f9db1c7ca");
+ UUID templateId2 = UUID.fromString("4f1522f9-642e-49f7-af75-a2f344085bcc");
+ return new Object[][]{
+ {ImmutableList.of( (Jobber)
+ () -> createNewJob(12, templateId1, "userId", PENDING_RESOURCE, null, LocalDateTime.now().minusSeconds(1), false),
+ () -> createNewJob(1, templateId2, "userId", CREATING, null, LocalDateTime.now().minusSeconds(1), false),
+ () -> createNewJob(2, UUID.randomUUID(), "userId", RESOURCE_IN_PROGRESS, null, LocalDateTime.now().minusSeconds(1), false),
+ () -> createNewJob(3, UUID.randomUUID(), "userId", IN_PROGRESS, null, LocalDateTime.now().minusSeconds(1), false),
+ () -> createNewJob(4, UUID.randomUUID(), "userId", COMPLETED, null, LocalDateTime.now().minusSeconds(1), false)
+ ),
+ 0,
+ "given there is only one in the queue in PENDING_RESOURCE and no other job with same templateId, then this job is selected"
+ },
+ {ImmutableList.of( (Jobber)
+ () -> createNewJob(2, templateId1, "userId", PENDING_RESOURCE, null, LocalDateTime.now().minusSeconds(1), false),
+ () -> createNewJob(3, templateId1, "userId", PENDING_RESOURCE, null, LocalDateTime.now().minusSeconds(2), false),
+ () -> createNewJob(1, templateId1, "userId", PENDING_RESOURCE, null, LocalDateTime.now(), false)
+ ),
+ 2,
+ "given multiple jobs with same templateId in PENDING_RESOURCE, then job with lowest indexInBulk is selected"
+ },
+ {ImmutableList.of( (Jobber)
+ () -> createNewJob(1, templateId2, "userId", PENDING_RESOURCE, null, LocalDateTime.now().minusSeconds(1), false),
+ () -> createNewJob(1, templateId1, "userId", PENDING_RESOURCE, null, LocalDateTime.now(), false)
+ ),
+ 1,
+ "given multiple jobs with same indexInBulk, then job with lowest templateId is selected"
+ },
+ {ImmutableList.of( (Jobber)
+ () -> createNewJob(1, templateId1, "userId", PENDING_RESOURCE, null, LocalDateTime.now(), false),
+ () -> createNewJob(2, templateId2, "userId", PENDING_RESOURCE, null, LocalDateTime.now().minusSeconds(1), false)
+ ),
+ 0,
+ "given multiple jobs with different indexInBulk and different templateId, then job with lowest indexInBulk is selected"
+ },
+ {ImmutableList.of( (Jobber)
+ () -> createNewJob(5, templateId1, "userId", PENDING_RESOURCE, null, LocalDateTime.now().minusMinutes(2), false),
+ () -> createNewJob(1, templateId1, "userId", PENDING_RESOURCE, "123", LocalDateTime.now(), false)
+ ),
+ -1,
+ "given there is already taken job with same templateId, then no job is selected"
+ },
+ {ImmutableList.of( (Jobber)
+ () -> createNewJob(2, templateId1, "userId", PENDING_RESOURCE, null, LocalDateTime.now().minusMinutes(2), false),
+ () -> createNewJob(1, templateId1, "userId", PENDING_RESOURCE, "123", LocalDateTime.now(), false),
+ () -> createNewJob(9, templateId2, "userId", PENDING_RESOURCE, null, LocalDateTime.now(), false),
+ () -> createNewJob(8, templateId2, "userId", PENDING_RESOURCE, null, LocalDateTime.now(), false)
+ ),
+ 3,
+ "given 4 jobs, 2 jobs templateId1 but one of them is taken, and 2 jobs with templateId2, then select job with templateId2"
+ },
+ {ImmutableList.of( (Jobber)
+ () -> createNewJob(5, templateId1, "userId", PENDING_RESOURCE, null, LocalDateTime.now().minusMinutes(1), false),
+ () -> createNewJob(1, templateId1, "userId", PENDING_RESOURCE, "123", LocalDateTime.now(), true)
+ ),
+ 0,
+ "given 2 jobs with same templateId, one of them is taken but deleted, then the other job is selected"
+ },
+ {ImmutableList.of( (Jobber)
+ () -> createNewJob(5, templateId1, "userId", PENDING_RESOURCE, null, LocalDateTime.now().minusMinutes(1), false),
+ () -> createNewJob(1, templateId1, "userId", IN_PROGRESS, null, LocalDateTime.now(), false)
+ ),
+ -1,
+ "given 2 jobs with same templateId, one of them is IN_PROGRESS, then no job is selected"
+ },
+ {ImmutableList.of( (Jobber)
+ () -> createNewJob(5, templateId1, "userId", PENDING_RESOURCE, null, LocalDateTime.now().minusMinutes(1), false),
+ () -> createNewJob(1, templateId1, "userId", RESOURCE_IN_PROGRESS, null, LocalDateTime.now(), false)
+ ),
+ -1,
+ "given 2 jobs with same templateId, one of them is RESOURCE_IN_PROGRESS, then no job is selected"
+ },
+ {ImmutableList.of( (Jobber)
+ () -> createNewJob(6, templateId1, "userId", PENDING_RESOURCE, null, LocalDateTime.now().minusMinutes(2), false),
+ () -> createNewJob(5, templateId1, "userId", PENDING_RESOURCE, null, LocalDateTime.now().minusMinutes(1), false),
+ () -> createNewJob(1, templateId1, "userId", RESOURCE_IN_PROGRESS, null, LocalDateTime.now(), true)
+ ),
+ 1,
+ "given 3 jobs with same templateId, one of them is RESOURCE_IN_PROGRESS but deleted, then other job with lowest indexInBulk is selected"
+ },
+ {ImmutableList.of( (Jobber)
+ () -> createNewJob(6, templateId1, "userId", PENDING_RESOURCE, null, LocalDateTime.now().minusMinutes(2), false),
+ () -> createNewJob(5, templateId1, "userId", PENDING_RESOURCE, null, LocalDateTime.now().minusMinutes(1), false),
+ () -> createNewJob(1, templateId1, "userId", RESOURCE_IN_PROGRESS, null, LocalDateTime.now(), false),
+ () -> createNewJob(12, templateId2, "userId", PENDING_RESOURCE, null, LocalDateTime.now().minusMinutes(2), false),
+ () -> createNewJob(11, templateId2, "userId", PENDING_RESOURCE, null, LocalDateTime.now(), false)
+ ),
+ 4,
+ "given 5 jobs, 3 with templateId1 that one of them is RESOURCE_IN_PROGRESS,"+
+ "2 with templateId2 both in PENDING_RESOURCE, then job with lowest indexInBulk from templateId2 is selected"
+
+ },
+ {ImmutableList.of( (Jobber)
+ () -> createNewJob(6, templateId1, "userId", PENDING_RESOURCE, null, LocalDateTime.now().minusMinutes(2), true)
+ ),
+ -1,
+ "given 1 job in PENDING_RESOURCE but it's deleted, then no job is selected"
+ },
+ {ImmutableList.of( (Jobber)
+ () -> createNewJob(20, templateId1, "userId", PENDING_RESOURCE, null, LocalDateTime.now().minusSeconds(1), false),
+ () -> createNewJob(1, templateId1, "userId", CREATING, null, LocalDateTime.now().minusSeconds(1), false),
+ () -> createNewJob(2, templateId1, "userId", COMPLETED, null, LocalDateTime.now().minusSeconds(1), false),
+ () -> createNewJob(3, templateId1, "userId", FAILED, null, LocalDateTime.now().minusSeconds(1), false),
+ () -> createNewJob(4, templateId1, "userId", COMPLETED_WITH_ERRORS, null, LocalDateTime.now().minusSeconds(1), false),
+ () -> createNewJob(5, templateId1, "userId", STOPPED, null, LocalDateTime.now().minusSeconds(1), false),
+ () -> createNewJob(6, templateId1, "userId", PAUSE, null, LocalDateTime.now().minusSeconds(1), false)
+ ),
+ 0,
+ "given multiple jobs with same templateId, 1 in PENDING_RESOURCE, and other are not in progress, "+
+ "then the job in PENDING_RESOURCE is selected"
+ },
+ {ImmutableList.of( (Jobber)
+ () -> createNewJob(1, UUID.randomUUID(), "userId", CREATING, null, LocalDateTime.now().minusSeconds(1), false),
+ () -> createNewJob(2, UUID.randomUUID(), "userId", COMPLETED, null, LocalDateTime.now().minusSeconds(1), false),
+ () -> createNewJob(3, UUID.randomUUID(), "userId", FAILED, null, LocalDateTime.now().minusSeconds(1), false),
+ () -> createNewJob(4, UUID.randomUUID(), "userId", COMPLETED_WITH_ERRORS, null, LocalDateTime.now().minusSeconds(1), false),
+ () -> createNewJob(5, UUID.randomUUID(), "userId", IN_PROGRESS, null, LocalDateTime.now().minusSeconds(1), false),
+ () -> createNewJob(6, UUID.randomUUID(), "userId", RESOURCE_IN_PROGRESS, null, LocalDateTime.now().minusSeconds(1), false)
+ ),
+ -1,
+ "given there is no job in PENDING_RESOURCE state, then no job is selected"
+ },
+ {ImmutableList.of( (Jobber)
+ () -> createNewJob(6, null, "userId", PENDING_RESOURCE, null, LocalDateTime.now().minusMinutes(2), false)
+ ),
+ -1,
+ "given there is 1 job in PENDING_RESOURCE but without templateId, then no job is selected"
+ },
+ };
+ }
+
+ @Test(dataProvider = "jobsForTestingPendingResource")
+ public void givenSomeJobs_pullPendingResource_returnNextOrNothingAsExpected(List<Jobber> jobbers, int expectedIndexSelected, String assertionReason) {
+ givenSomeJobs_pullNextJob_returnNextOrNothingAsExpected(jobbers, 1, expectedIndexSelected, PENDING_RESOURCE, assertionReason);
+ }
+
+ public static JobDaoImpl createNewJob(Job.JobStatus status, String takenBy, long secondsOffset, boolean deleted) {
+ return createNewJob(1, UUID.randomUUID(), "af456", status, takenBy, LocalDateTime.now().minusSeconds(secondsOffset), deleted);
+ }
+
+ @Test
+ public void givenSomeJobs_deleteOldFinalJobs_onlyExpectedJobsAreDeleted() {
+ long seconds = 999;
+ final List<Pair<JobDaoImpl,Boolean>> jobs = ImmutableList.of(
+ //not final
+ Pair.of(createNewJob(IN_PROGRESS, null, seconds+1, false), true),
+ Pair.of(createNewJob(RESOURCE_IN_PROGRESS, null, seconds+1, false), true),
+ Pair.of(createNewJob(PENDING, null, seconds+1, false), true),
+ Pair.of(createNewJob(CREATING, null, seconds+1, false), true),
+ Pair.of(createNewJob(PENDING_RESOURCE, null, seconds+1, false), true),
+ Pair.of(createNewJob(PAUSE, null, seconds+1, false), true),
+
+ //final
+ Pair.of(createNewJob(COMPLETED, null, seconds+1, false), false),
+ Pair.of(createNewJob(FAILED, null, seconds+1, false), false),
+ Pair.of(createNewJob(STOPPED, null, seconds+1, false), false),
+ Pair.of(createNewJob(COMPLETED_WITH_ERRORS, null, seconds+1, true), false),
+ Pair.of(createNewJob(COMPLETED_WITH_NO_ACTION, generateRandomAlphaNumeric(5), seconds+1, true), false),
+
+ //final but not old
+ Pair.of(createNewJob(COMPLETED, generateRandomAlphaNumeric(5), seconds-2, false), true),
+ Pair.of(createNewJob(COMPLETED, generateRandomAlphaNumeric(5), seconds-400, false), true),
+ Pair.of(createNewJob(COMPLETED, generateRandomAlphaNumeric(5), 0, false), true)
+ );
+ addJobsWithModifiedDateByJobDao(jobs.stream().map(Pair::getLeft).collect(Collectors.toList()), broker);
+ assertEquals(jobs.size(), broker.peek().size());
+
+ broker.deleteOldFinalJobs(seconds);
+ Stream<Pair<UUID, Job.JobStatus>> expectedJobs = jobs.stream()
+ .filter(Pair::getRight)
+ .map(x -> Pair.of(
+ x.getLeft().getUuid(),
+ x.getLeft().getStatus()
+ ));
+ assertThat(broker.peek().stream().map(x->Pair.of(x.getUuid(), x.getStatus())).collect(Collectors.toList()),
+ containsInAnyOrder(expectedJobs.toArray()));
+ }
+
@DataProvider
public Object[][] topics() {
return Arrays.stream(Job.JobStatus.values())
- .filter(not(t -> ImmutableList.of(PENDING, IN_PROGRESS, CREATING, RESOURCE_IN_PROGRESS).contains(t)))
+ .filter(not(t -> ImmutableList.of(PENDING, IN_PROGRESS, CREATING, RESOURCE_IN_PROGRESS, PENDING_RESOURCE).contains(t)))
.map(v -> new Object[]{v}).collect(toList()).toArray(new Object[][]{});
}
@@ -660,7 +896,7 @@ public class JobsBrokerServiceTest extends AbstractTestNGSpringContextTests {
}
@Test(dataProvider = "jobStatusesForSuccessDelete", expectedExceptions = NoJobException.class)
- public void givenOneJob_deleteIt_canPeekOnItButCantPull(Job.JobStatus status) {
+ public void givenOneJob_deleteIt_canPeekOnItButCantPull(Job.JobStatus status) {
final Job job = waitForFutureJob(newJobAsync(broker, status));
broker.delete(job.getUuid());
assertNotNull(((JobDaoImpl) broker.peek(job.getUuid())).getDeletedAt(), "job should be deleted");
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/PortDetailsTranslatorTest.java b/vid-app-common/src/test/java/org/onap/vid/services/PortDetailsTranslatorTest.java
index 117e4442f..33b8c7e3a 100644
--- a/vid-app-common/src/test/java/org/onap/vid/services/PortDetailsTranslatorTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/services/PortDetailsTranslatorTest.java
@@ -53,7 +53,7 @@ public class PortDetailsTranslatorTest {
" {" +
" \"id\": \"4876980240\"," +
" \"node-type\": \"l-interface\"," +
- " \"url\": \"/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/att-aic/rdm5b/tenants/tenant/460f35aeb53542dc9f77105066483e83/vservers/vserver/15e46e2f-4b98-4e06-9644-f0e6e35cc79a/l-interfaces/l-interface/zrdm5bfprbVLBA005-vlbagent_aff_int_pktmirror_1_port-dr5jhyxva5ib\"," +
+ " \"url\": \"/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/rdm5b/tenants/tenant/460f35aeb53542dc9f77105066483e83/vservers/vserver/15e46e2f-4b98-4e06-9644-f0e6e35cc79a/l-interfaces/l-interface/zrdm5bfprbVLBA005-vlbagent_aff_int_pktmirror_1_port-dr5jhyxva5ib\"," +
" \"properties\": {" +
" \"interface-name\": \"zrdm5bfprbVLBA005-vlbagent_aff_int_pktmirror_1_port-dr5jhyxva5ib\"," +
" \"selflink\": \"https://network-aic.rdm5b.cci.att.com:9696/v2.0/ports/6de7bf87-6faa-4984-9492-18d1188b3d4a\"," +
@@ -89,7 +89,7 @@ public class PortDetailsTranslatorTest {
" {" +
" \"id\": \"4876980240\"," +
" \"node-type\": \"l-interface\"," +
- " \"url\": \"/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/att-aic/rdm5b/tenants/tenant/460f35aeb53542dc9f77105066483e83/vservers/vserver/15e46e2f-4b98-4e06-9644-f0e6e35cc79a/l-interfaces/l-interface/zrdm5bfprbVLBA005-vlbagent_aff_int_pktmirror_1_port-dr5jhyxva5ib\"," +
+ " \"url\": \"/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/rdm5b/tenants/tenant/460f35aeb53542dc9f77105066483e83/vservers/vserver/15e46e2f-4b98-4e06-9644-f0e6e35cc79a/l-interfaces/l-interface/zrdm5bfprbVLBA005-vlbagent_aff_int_pktmirror_1_port-dr5jhyxva5ib\"," +
" \"properties\": {" +
" \"interface-name\": null," +
" \"selflink\": \"https://network-aic.rdm5b.cci.att.com:9696/v2.0/ports/6de7bf87-6faa-4984-9492-18d1188b3d4a\"," +
@@ -122,7 +122,7 @@ public class PortDetailsTranslatorTest {
" {" +
" \"id\": \"4876980240\"," +
" \"node-type\": \"l-interface\"," +
- " \"url\": \"/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/att-aic/rdm5b/tenants/tenant/460f35aeb53542dc9f77105066483e83/vservers/vserver/15e46e2f-4b98-4e06-9644-f0e6e35cc79a/l-interfaces/l-interface/zrdm5bfprbVLBA005-vlbagent_aff_int_pktmirror_1_port-dr5jhyxva5ib\"," +
+ " \"url\": \"/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/rdm5b/tenants/tenant/460f35aeb53542dc9f77105066483e83/vservers/vserver/15e46e2f-4b98-4e06-9644-f0e6e35cc79a/l-interfaces/l-interface/zrdm5bfprbVLBA005-vlbagent_aff_int_pktmirror_1_port-dr5jhyxva5ib\"," +
" \"properties\": {" +
" \"interface-name\": \"zrdm5bfprbVLBA005-vlbagent_aff_int_pktmirror_1_port-dr5jhyxva5ib\"," +
" \"selflink\": \"https://network-aic.rdm5b.cci.att.com:9696/v2.0/ports/6de7bf87-6faa-4984-9492-18d1188b3d4a\"," +
@@ -155,7 +155,7 @@ public class PortDetailsTranslatorTest {
" {" +
" \"id\": \"4876980240\"," +
" \"node-type\": \"l-interface\"," +
- " \"url\": \"/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/att-aic/rdm5b/tenants/tenant/460f35aeb53542dc9f77105066483e83/vservers/vserver/15e46e2f-4b98-4e06-9644-f0e6e35cc79a/l-interfaces/l-interface/zrdm5bfprbVLBA005-vlbagent_aff_int_pktmirror_1_port-dr5jhyxva5ib\"," +
+ " \"url\": \"/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/rdm5b/tenants/tenant/460f35aeb53542dc9f77105066483e83/vservers/vserver/15e46e2f-4b98-4e06-9644-f0e6e35cc79a/l-interfaces/l-interface/zrdm5bfprbVLBA005-vlbagent_aff_int_pktmirror_1_port-dr5jhyxva5ib\"," +
" \"properties\": {" +
" \"interface-name\": \"\"," +
" \"selflink\": \"https://network-aic.rdm5b.cci.att.com:9696/v2.0/ports/6de7bf87-6faa-4984-9492-18d1188b3d4a\"," +
@@ -188,7 +188,7 @@ public class PortDetailsTranslatorTest {
" {" +
" \"id\": \"4876980240\"," +
" \"node-type\": \"l-interface\"," +
- " \"url\": \"/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/att-aic/rdm5b/tenants/tenant/460f35aeb53542dc9f77105066483e83/vservers/vserver/15e46e2f-4b98-4e06-9644-f0e6e35cc79a/l-interfaces/l-interface/zrdm5bfprbVLBA005-vlbagent_aff_int_pktmirror_1_port-dr5jhyxva5ib\"," +
+ " \"url\": \"/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/rdm5b/tenants/tenant/460f35aeb53542dc9f77105066483e83/vservers/vserver/15e46e2f-4b98-4e06-9644-f0e6e35cc79a/l-interfaces/l-interface/zrdm5bfprbVLBA005-vlbagent_aff_int_pktmirror_1_port-dr5jhyxva5ib\"," +
" \"properties\": {" +
" \"interface-name\": \"zrdm5bfprbVLBA005-vlbagent_aff_int_pktmirror_1_port-dr5jhyxva5ib\"," +
" \"selflink\": \"https://network-aic.rdm5b.cci.att.com:9696/v2.0/ports/6de7bf87-6faa-4984-9492-18d1188b3d4a\"," +
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/RoleGenaratorServiceImplTest.java b/vid-app-common/src/test/java/org/onap/vid/services/RoleGenaratorServiceImplTest.java
index 2ad68dd93..2bf73eece 100644
--- a/vid-app-common/src/test/java/org/onap/vid/services/RoleGenaratorServiceImplTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/services/RoleGenaratorServiceImplTest.java
@@ -75,7 +75,7 @@ public class RoleGenaratorServiceImplTest {
ServiceSubscription serviceSubscription = createServiceSubscription();
AaiResponse<Services> subscriberResponse = createServicesAaiResponse(serviceSubscription);
- doReturn(subscriberResponse).when(aaiClientInterface).getSubscriberData(subscriber.globalCustomerId);
+ doReturn(subscriberResponse).when(aaiClientInterface).getSubscriberData(subscriber.globalCustomerId,false);
String result = testSubject.generateRoleScript(firstRun);
Assert.assertTrue(StringUtils.isNotBlank(result));
@@ -91,7 +91,7 @@ public class RoleGenaratorServiceImplTest {
ServiceSubscription serviceSubscription = createServiceSubscription();
AaiResponse<Services> subscriberResponse = createServicesAaiResponse(serviceSubscription);
- doReturn(subscriberResponse).when(aaiClientInterface).getSubscriberData(subscriber.globalCustomerId);
+ doReturn(subscriberResponse).when(aaiClientInterface).getSubscriberData(subscriber.globalCustomerId, false);
String result = testSubject.generateRoleScript(firstRun);
Assert.assertTrue(StringUtils.isNotBlank(result));
diff --git a/vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java b/vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java
index 756d17534..5fc583274 100644
--- a/vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java
+++ b/vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java
@@ -20,10 +20,14 @@
package org.onap.vid.testUtils;
+import static com.fasterxml.jackson.module.kotlin.ExtensionsKt.jacksonObjectMapper;
import static java.util.function.Function.identity;
import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toMap;
import static org.apache.commons.beanutils.PropertyUtils.getPropertyDescriptors;
+import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
+import static org.apache.commons.text.CharacterPredicates.DIGITS;
+import static org.apache.commons.text.CharacterPredicates.LETTERS;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.RETURNS_DEFAULTS;
import static org.mockito.Mockito.mock;
@@ -33,6 +37,7 @@ import static org.testng.Assert.fail;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.code.beanmatchers.BeanMatchers;
import com.google.common.collect.ImmutableList;
import java.beans.PropertyDescriptor;
import java.io.ByteArrayInputStream;
@@ -50,7 +55,9 @@ import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.apache.commons.beanutils.BeanUtils;
+import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.reflect.MethodUtils;
+import org.apache.commons.text.RandomStringGenerator;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.json.JSONArray;
@@ -62,8 +69,9 @@ import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.onap.portalsdk.core.util.SystemProperties;
import org.onap.vid.asdc.beans.Service;
+import org.onap.vid.mso.model.CloudConfiguration;
import org.springframework.core.env.Environment;
-import org.springframework.mock.env.MockEnvironment;
+import org.testng.annotations.DataProvider;
/**
* Created by Oren on 6/7/17.
@@ -127,13 +135,22 @@ public class TestUtils {
return readJsonResourceFileAsObject(pathInResource, valueType, false);
}
- public static <T> T readJsonResourceFileAsObject(String pathInResource, Class<T> valueType, boolean ignoreUnknownProperties)
- throws IOException {
- ObjectMapper objectMapper = new ObjectMapper();
- objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, ignoreUnknownProperties);
+ public static <T> T readJsonResourceFileAsObject(String pathInResource, Class<T> valueType,
+ boolean failOnUnknownProperties)
+ throws IOException {
+ ObjectMapper objectMapper = jacksonObjectMapper()
+ .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, failOnUnknownProperties);
return objectMapper.readValue(
- TestUtils.class.getResource(pathInResource),
- valueType);
+ TestUtils.class.getResource(pathInResource),
+ valueType);
+ }
+
+ public static String readFileAsString(String pathInResource) {
+ try {
+ return IOUtils.toString(TestUtils.class.getResource(pathInResource), "UTF-8");
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
}
public static String[] allPropertiesOf(Class<?> aClass) {
@@ -169,6 +186,12 @@ public class TestUtils {
}
}
+ public static void registerCloudConfigurationValueGenerator() {
+ BeanMatchers.registerValueGenerator(() -> new CloudConfiguration(
+ randomAlphabetic(7), randomAlphabetic(7), randomAlphabetic(7)
+ ), CloudConfiguration.class);
+ }
+
public static class JavaxRsClientMocks {
private final javax.ws.rs.client.Client fakeClient;
@@ -277,4 +300,18 @@ public class TestUtils {
}
}
+ private static RandomStringGenerator generator = new RandomStringGenerator.Builder()
+ .withinRange('0', 'z')
+ .filteredBy(LETTERS, DIGITS)
+ .build();
+
+ public static String generateRandomAlphaNumeric(int length) {
+ return generator.generate(length);
+ }
+
+ @DataProvider
+ public static Object[][] trueAndFalse() {
+ return new Object[][]{{true}, {false}};
+ }
+
}
diff --git a/vid-app-common/src/test/resources/WEB-INF/conf/system.properties b/vid-app-common/src/test/resources/WEB-INF/conf/system.properties
index 9cb5208da..bfd7ef985 100644
--- a/vid-app-common/src/test/resources/WEB-INF/conf/system.properties
+++ b/vid-app-common/src/test/resources/WEB-INF/conf/system.properties
@@ -1,23 +1,4 @@
-# Properties read by ECOMP Core library, epsdk-core.jar
-
-##########################################################################
-# The following properties should NOT be changed by partner applications.
-##########################################################################
-
-application_user_id = 30000
-post_default_role_id = 16
-clustered = true
-
-#Enable Fusion Mobile capabilities for the application
-mobile_enable = false
-
-# Cache config file is needed on the classpath
-cache_config_file_path = /WEB-INF/classes/cache.ccf
-cache_switch = 199
-cache_load_on_startup = false
-
-user_name = fullName
-decryption_key = AGLDdG4D04BKm2IxIWEr8o==
+#DB Info
#db.userName=XXXX
#db.password=XXXX
#db.connectionURL=jdbc:oracle:thin:@XXXX/XX
@@ -63,6 +44,21 @@ files_path = /opt/app/vid/license
#business_direct_menu_attribute_name = businessDirectMenuData
application_name = Virtual Infrastructure Deployment
+application_user_id = 30000
+post_default_role_id = 16
+clustered = true
+
+#Enable Fusion Mobile capabilities for the application
+mobile_enable = false
+
+# Cache config file is needed on the classpath
+cache_config_file_path = /WEB-INF/classes/cache.ccf
+cache_switch = 199
+cache_load_on_startup = false
+
+user_name = fullName
+
+decryption_key = AGLDdG4D04BKm2IxIWEr8o==
#element map files
@@ -113,7 +109,7 @@ contact_us_link = https://wiki.web.att.com/display/EcompPortal/ECOMP+Portal+Home
camunda_cockpit_link = https://cloopwf.client.research.att.com:8443/camunda/app/cockpit/default/#/dashboard
# An Unique 128-bit value defined to identify a specific version
# of an application deployed on a specific virtual machine.
-# This value must be generated and updated by the application
+# This value must be generated and updated by the application
# which is using the ECOMP SDK at the time of its deployment.
# Online Unique UUID generator - https://www.uuidgenerator.net/
instance_uuid=8da691c9-987d-43ed-a358-00ac2f35685d
@@ -129,6 +125,19 @@ guard_notebook_url=https://rcloud.research.att.com/mini.html?notebook=a06a9cf142
#ueb_app_key = sYH0NJnsKmJC1B2A
#ueb_app_secret = YOtknsT2wVFz9WISlSPDaAtd
+
+#Policy related properties
+#simulator
+policy.server.url=http://localhost:8080/pdp
+policy.get.config=/api/getConfig
+policy.ClientAuth=
+policy.client.mechId=
+policy.client.password=
+policy.username=
+policy.password=
+policy.Authorization=
+policy.environment=
+
#MSO related properties
#simulator
#mso.server.url=http://localhost:8089
@@ -145,47 +154,55 @@ mso.polling.interval.msecs=10000
mso.max.polls=10
mso.user.name=infraportal
mso.password.x=OBF:1ghz1kfx1j1w1m7w1i271e8q1eas1hzj1m4i1iyy1kch1gdz
-mso.restapi.svc.instance=/serviceInstances/v5
-mso.restapi.svc.instance.deleteAndUnassign=/serviceInstantiation/v5/serviceInstances
-mso.restapi.vnf.instance=/serviceInstances/v5/<service_instance_id>/vnfs
-mso.restapi.vnf.changemanagement.instance=/serviceInstances/v5/<service_instance_id>/vnfs/<vnf_instance_id>/<request_type>
-mso.restapi.network.instance=/serviceInstances/v5/<service_instance_id>/networks
-mso.restapi.vf.module.instance=/serviceInstances/v7/<service_instance_id>/vnfs/<vnf_instance_id>/vfModules
+mso.restapi.svc.instance=/serviceInstances/v7
+mso.restapi.svc.instance.deleteAndUnassign=/serviceInstantiation/v7/serviceInstances
+mso.restapi.vnf.instance=${mso.restapi.serviceInstantiationApiRoot}/serviceInstances/<service_instance_id>/vnfs
+mso.restapi.vnf.changemanagement.instance=/serviceInstances/v7/<service_instance_id>/vnfs/<vnf_instance_id>/<request_type>
+mso.restapi.network.instance=${mso.restapi.serviceInstantiationApiRoot}/serviceInstances/<service_instance_id>/networks
mso.restapi.vf.module.scaleout=/serviceInstantiation/v7/serviceInstances/<service_instance_id>/vnfs/<vnf_instance_id>/vfModules/scaleOut
+mso.restapi.vf.module.instance=${mso.restapi.serviceInstantiationApiRoot}/serviceInstances/<service_instance_id>/vnfs/<vnf_instance_id>/vfModules
mso.restapi.workflow.invoke=/instanceManagement/v1/serviceInstances/<service_instance_id>/vnfs/<vnf_instance_id>/workflows/<workflow_UUID>
-mso.restapi.volume.group.instance=/serviceInstances/v5/<service_instance_id>/vnfs/<vnf_instance_id>/volumeGroups
-mso.restapi.instance.group=/serviceInstantiation/v7/instanceGroups
-mso.restapi.get.orc.req=/orchestrationRequests/v5
-mso.restapi.get.orc.reqs=/orchestrationRequests/v5?
+mso.restapi.volume.group.instance=/serviceInstances/v7/<service_instance_id>/vnfs/<vnf_instance_id>/volumeGroups
+mso.restapi.instance.group=${mso.restapi.serviceInstantiationApiRoot}/instanceGroups
+mso.restapi.get.orc.req=/orchestrationRequests/v7
+mso.restapi.get.orc.reqs=/orchestrationRequests/v7?
+mso.restapi.resume.orc.req=/orchestrationRequests/v7/<request_id>/resume
mso.restapi.get.man.tasks=/tasks/v1
mso.restapi.configurations=/serviceInstances/v6/<service_instance_id>/configurations
mso.restapi.configuration.instance=${mso.restapi.configurations}<configuration_id>
+mso.restapi.changeManagement.workflowSpecifications=/workflowSpecifications/v1/workflows?vnfModelVersionId=<model_version_id>
+
+mso.restapi.serviceInstantiationApiRoot=/serviceInstantiation/v7
+mso.restapi.serviceInstanceCreate=${mso.restapi.serviceInstantiationApiRoot}/serviceInstances
+mso.restapi.serviceInstanceAssign=${mso.restapi.serviceInstantiationApiRoot}/serviceInstances/assign
-mso.restapi.operationalEnvironment.activate=${mso.restapi.operationalEnvironment}/activate
-mso.restapi.operationalEnvironment=${mso.restapi.cloudResourcesApiRoot}/operationalEnvironments/<operational_environment_id>
mso.restapi.cloudResourcesApiRoot=/cloudResources/v1
-mso.restapi.cloudResourcesRequestsApiRoot=/cloudResourcesRequests/v1
-mso.restapi.operationalEnvironment.cloudResourcesRequests.status=${mso.restapi.cloudResourcesRequestsApiRoot}?requestId=<request_id>
+mso.restapi.operationalEnvironment=${mso.restapi.cloudResourcesApiRoot}/operationalEnvironments/<operational_environment_id>
+
+mso.restapi.operationalEnvironment.activate=${mso.restapi.operationalEnvironment}/activate
mso.restapi.operationalEnvironment.deactivate=${mso.restapi.operationalEnvironment}/deactivate
mso.restapi.operationalEnvironment.create=${mso.restapi.cloudResourcesApiRoot}/operationalEnvironments
-mso.restapi.serviceInstantiationApiRoot=/serviceInstantiation/v7
-mso.restapi.serviceInstanceCreate=${mso.restapi.serviceInstantiationApiRoot}/serviceInstances
-mso.restapi.serviceInstanceAssign=${mso.restapi.serviceInstantiationApiRoot}/serviceInstances/assign
-mso.restapi.changeManagement.workflowSpecifications=/workflowSpecifications/v1/workflows?vnfModelVersionId=<model_version_id>
+mso.restapi.cloudResourcesRequestsApiRoot=/cloudResourcesRequests/v1
+mso.restapi.operationalEnvironment.cloudResourcesRequests.status=${mso.restapi.cloudResourcesRequestsApiRoot}?requestId=<request_id>
vid.truststore.filename=/opt/app/vid/etc/vid_keystore.jks
mso.dme2.client.timeout=30000
mso.dme2.client.read.timeout=120000
-scheduler.server.url=
+
+scheduler.server.url=http://localhost:8080/vidSimulator/scheduler
+
+##scheduler authentication credentials
+scheduler.user.name=test1
+scheduler.password=test2
+
scheduler.create.new.vnf.change.instance=/v1/ChangeManagement/schedules/
+scheduler.submit.new.vnf.change=/v1/ChangeManagement/schedules/{scheduleId}/approvals
+scheduler.delete.schedule=/v1/ChangeManagement/schedules/%s
scheduler.get.time.slots=/v1/ChangeManagement/schedules/
scheduler.get.schedules=/v1/ChangeManagement/schedules/scheduleDetails/
-
-#vid.truststore.filename=/Users/Oren/Downloads/vid_keystore2.jks
-
vid.truststore.passwd.x=OBF:1wgg1wfq1uus1uui1x131x0r1x1v1x1j1uvo1uve1wg81wfi
#mso.dme2.server.url=http://mso-api-handler-anap-v1.mso.ecomp.att.com/services/ecomp/mso?
mso.dme2.server.url=http://mso-api-handler-anap-v1.mso.ecomp.att.com/services/ecomp/mso?version=1607&envContext=TEST&routeOffer=st_mtsnj
@@ -203,3 +220,8 @@ mso.asyncPollingIntervalSeconds=0
# Only required for applications using WebJunction or FE/BE separation. For example:
# app_base_url = https://www.e-access.att.com/app_junction/app_context/
+vid.asyncJob.howLongToKeepOldJobsInDays=7
+
+# thread definition - count and timeout (in seconds)
+vid.thread.count=50
+vid.thread.timeout=30
diff --git a/vid-app-common/src/test/resources/cr-csar.JSON b/vid-app-common/src/test/resources/cr-csar.JSON
index b712cc779..97b39b2d2 100644
--- a/vid-app-common/src/test/resources/cr-csar.JSON
+++ b/vid-app-common/src/test/resources/cr-csar.JSON
@@ -21,7 +21,7 @@
"networks": {
},
- "collectionResource": {
+ "collectionResources": {
"MSO_Example 0": {
"uuid": "4f8068d9-fb13-49fc-9e39-634d2094b659",
"invariantUuid": "2fc1b3b8-b8ed-413e-add8-3d903cf2b458",
@@ -75,5 +75,8 @@
"pnfs": {
},
- "vnfGroups": {}
+ "vnfGroups": {},
+ "vrfs": {
+
+ }
} \ No newline at end of file
diff --git a/vid-app-common/src/test/resources/csars/1712_PASQUALE.zip b/vid-app-common/src/test/resources/csars/1712_PASQUALE.zip
new file mode 100644
index 000000000..bbfbd2368
--- /dev/null
+++ b/vid-app-common/src/test/resources/csars/1712_PASQUALE.zip
Binary files differ
diff --git a/vid-app-common/src/test/resources/csars/csarTransportWithPnfs.zip b/vid-app-common/src/test/resources/csars/csarTransportWithPnfs.zip
new file mode 100644
index 000000000..33225f9d6
--- /dev/null
+++ b/vid-app-common/src/test/resources/csars/csarTransportWithPnfs.zip
Binary files differ
diff --git a/vid-app-common/src/main/resources/service-AmpPhSvc-csar.zip b/vid-app-common/src/test/resources/csars/service-AmpPhSvc-csar.zip
index c1fb9e08a..d8969d65f 100644
--- a/vid-app-common/src/main/resources/service-AmpPhSvc-csar.zip
+++ b/vid-app-common/src/test/resources/csars/service-AmpPhSvc-csar.zip
Binary files differ
diff --git a/vid-app-common/src/test/resources/csars/service-Infravpn-csar.zip b/vid-app-common/src/test/resources/csars/service-Infravpn-csar.zip
new file mode 100644
index 000000000..403aacc8f
--- /dev/null
+++ b/vid-app-common/src/test/resources/csars/service-Infravpn-csar.zip
Binary files differ
diff --git a/vid-app-common/src/test/resources/csars/service-JennyVtsbcVlanSvc-csar.zip b/vid-app-common/src/test/resources/csars/service-JennyVtsbcVlanSvc-csar.zip
new file mode 100644
index 000000000..a04f6dbda
--- /dev/null
+++ b/vid-app-common/src/test/resources/csars/service-JennyVtsbcVlanSvc-csar.zip
Binary files differ
diff --git a/vid-app-common/src/main/resources/service-MsoExampleService-csar.zip b/vid-app-common/src/test/resources/csars/service-MsoExampleService-csar.zip
index 83131de5e..83131de5e 100644
--- a/vid-app-common/src/main/resources/service-MsoExampleService-csar.zip
+++ b/vid-app-common/src/test/resources/csars/service-MsoExampleService-csar.zip
Binary files differ
diff --git a/vid-app-common/src/main/resources/service-ServicecontainerContainsPprobe.zip b/vid-app-common/src/test/resources/csars/service-ServicecontainerContainsPprobe.zip
index fc74ba060..86b784b2c 100644
--- a/vid-app-common/src/main/resources/service-ServicecontainerContainsPprobe.zip
+++ b/vid-app-common/src/test/resources/csars/service-ServicecontainerContainsPprobe.zip
Binary files differ
diff --git a/vid-app-common/src/main/resources/service-Servicecontainermultiplepprobes-csar.zip b/vid-app-common/src/test/resources/csars/service-Servicecontainermultiplepprobes-csar.zip
index e0a533101..7882b641d 100644
--- a/vid-app-common/src/main/resources/service-Servicecontainermultiplepprobes-csar.zip
+++ b/vid-app-common/src/test/resources/csars/service-Servicecontainermultiplepprobes-csar.zip
Binary files differ
diff --git a/vid-app-common/src/test/resources/csars/service-VdorotheaSrv-csar.zip b/vid-app-common/src/test/resources/csars/service-VdorotheaSrv-csar.zip
new file mode 100644
index 000000000..5c5ee0fd6
--- /dev/null
+++ b/vid-app-common/src/test/resources/csars/service-VdorotheaSrv-csar.zip
Binary files differ
diff --git a/vid-app-common/src/test/resources/csars/service-fabric-configuration.zip b/vid-app-common/src/test/resources/csars/service-fabric-configuration.zip
new file mode 100644
index 000000000..c53e4f73f
--- /dev/null
+++ b/vid-app-common/src/test/resources/csars/service-fabric-configuration.zip
Binary files differ
diff --git a/vid-app-common/src/test/resources/csars/service-vf-csar.zip b/vid-app-common/src/test/resources/csars/service-vf-csar.zip
new file mode 100644
index 000000000..05d4fd3b4
--- /dev/null
+++ b/vid-app-common/src/test/resources/csars/service-vf-csar.zip
Binary files differ
diff --git a/vid-app-common/src/test/resources/csars/service-vf-with-annotations.zip b/vid-app-common/src/test/resources/csars/service-vf-with-annotations.zip
new file mode 100644
index 000000000..7473eeb3a
--- /dev/null
+++ b/vid-app-common/src/test/resources/csars/service-vf-with-annotations.zip
Binary files differ
diff --git a/vid-app-common/src/test/resources/csars/service-vl-csar.zip b/vid-app-common/src/test/resources/csars/service-vl-csar.zip
new file mode 100644
index 000000000..220e02fd5
--- /dev/null
+++ b/vid-app-common/src/test/resources/csars/service-vl-csar.zip
Binary files differ
diff --git a/vid-app-common/src/test/resources/csars/service-vnf-grouping-csar.zip b/vid-app-common/src/test/resources/csars/service-vnf-grouping-csar.zip
new file mode 100644
index 000000000..7f93dc83a
--- /dev/null
+++ b/vid-app-common/src/test/resources/csars/service-vnf-grouping-csar.zip
Binary files differ
diff --git a/vid-app-common/src/main/resources/vLoadBalancerMS-with-policy.TOSCA.zip b/vid-app-common/src/test/resources/csars/vLoadBalancerMS-with-policy.TOSCA.zip
index da749d247..da749d247 100644
--- a/vid-app-common/src/main/resources/vLoadBalancerMS-with-policy.TOSCA.zip
+++ b/vid-app-common/src/test/resources/csars/vLoadBalancerMS-with-policy.TOSCA.zip
Binary files differ
diff --git a/vid-app-common/src/test/resources/fabric-configuration.json b/vid-app-common/src/test/resources/fabric-configuration.json
index ff17ca049..cb4407386 100644
--- a/vid-app-common/src/test/resources/fabric-configuration.json
+++ b/vid-app-common/src/test/resources/fabric-configuration.json
@@ -2,13 +2,13 @@
"service": {
"uuid": "12344bb4-a416-4b4e-997e-0059973630b9",
"invariantUuid": "12343f9e-3244-4d8f-a8e0-0e5d7a29eda9",
- "name": "ADIOD vMX vPE_BV Service 488",
+ "name": "PASQUALE vMX vPE_BV Service 488",
"version": "1.0",
"toscaModelURL": null,
"category": "Network L1-3",
"serviceType": "",
"serviceRole": "",
- "description": "ADIOD vMX vPE based on Juniper 17.2 release. Updated with updated VF for v8.0 of VLM",
+ "description": "PASQUALE vMX vPE based on Juniper 17.2 release. Updated with updated VF for v8.0 of VLM",
"serviceEcompNaming": "true",
"instantiationType": "ClientConfig",
"inputs": {
@@ -21,7 +21,7 @@
"networks": {
},
- "collectionResource": {},
+ "collectionResources": {},
"configurations": {
},
@@ -48,5 +48,8 @@
"pnfs": {
},
- "vnfGroups": {}
+ "vnfGroups": {},
+ "vrfs": {
+
+ }
} \ No newline at end of file
diff --git a/vid-app-common/src/test/resources/fabric-real-sriov-configuration.json b/vid-app-common/src/test/resources/fabric-real-sriov-configuration.json
index d6efc2854..1b20c31fb 100644
--- a/vid-app-common/src/test/resources/fabric-real-sriov-configuration.json
+++ b/vid-app-common/src/test/resources/fabric-real-sriov-configuration.json
@@ -21,7 +21,7 @@
"networks": {
},
- "collectionResource": {},
+ "collectionResources": {},
"configurations": {
},
diff --git a/vid-app-common/src/test/resources/getTopology/network.json b/vid-app-common/src/test/resources/getTopology/network.json
new file mode 100644
index 000000000..ba9cf5ca6
--- /dev/null
+++ b/vid-app-common/src/test/resources/getTopology/network.json
@@ -0,0 +1,79 @@
+{
+ "network-id": "94c86b39-bbbf-4027-8120-ff37c6d2493a",
+ "network-name": "AUK51a_oam_calea_net_1",
+ "network-type": "SR-IOV-PROVIDER2-1",
+ "network-role": "oam_calea_net_1",
+ "network-technology": "STANDARD-SR-IOV",
+ "is-bound-to-vpn": false,
+ "resource-version": "1540925016770",
+ "orchestration-status": "Assigned",
+ "model-invariant-id": "b9a9b549-0ee4-49fc-b4f2-5edc6701da68",
+ "model-version-id": "77010093-df36-4dcb-8428-c3d02bf3f88d",
+ "model-customization-id": "e5f33853-f84c-4cdd-99f2-93846957aa18",
+ "physical-network-name": "sriovnet1",
+ "is-provider-network": true,
+ "is-shared-network": true,
+ "is-external-network": false,
+ "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/4b7cc8d1-f8ec-4461-ac43-5805e4ca3126/service-data/networks/network/94c86b39-bbbf-4027-8120-ff37c6d2493a/network-data/network-topology/",
+ "relationship-list": {
+ "relationship": [{
+ "related-to": "service-instance",
+ "relationship-label": "org.onap.relationships.inventory.ComposedOf",
+ "related-link": "/aai/v14/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/Emanuel/service-instances/service-instance/4b7cc8d1-f8ec-4461-ac43-5805e4ca3126",
+ "relationship-data": [{
+ "relationship-key": "customer.global-customer-id",
+ "relationship-value": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb"
+ }, {
+ "relationship-key": "service-subscription.service-type",
+ "relationship-value": "Emanuel"
+ }, {
+ "relationship-key": "service-instance.service-instance-id",
+ "relationship-value": "4b7cc8d1-f8ec-4461-ac43-5805e4ca3126"
+ }
+ ],
+ "related-to-property": [{
+ "property-key": "service-instance.service-instance-name",
+ "property-value": "AUK51a_oam_calea_net_service"
+ }
+ ]
+ }, {
+ "related-to": "tenant",
+ "relationship-label": "org.onap.relationships.inventory.Uses",
+ "related-link": "/aai/v14/cloud-infrastructure/cloud-regions/cloud-region/att-nc/auk51a/tenants/tenant/b530fc990b6d4334bd45518bebca6a51",
+ "relationship-data": [{
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "att-nc"
+ }, {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "auk51a"
+ }, {
+ "relationship-key": "tenant.tenant-id",
+ "relationship-value": "b530fc990b6d4334bd45518bebca6a51"
+ }
+ ],
+ "related-to-property": [{
+ "property-key": "tenant.tenant-name",
+ "property-value": "ecomp_ispt"
+ }
+ ]
+ }, {
+ "related-to": "cloud-region",
+ "relationship-label": "org.onap.relationships.inventory.Uses",
+ "related-link": "/aai/v14/cloud-infrastructure/cloud-regions/cloud-region/att-nc/auk51a",
+ "relationship-data": [{
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "att-nc"
+ }, {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "auk51a"
+ }
+ ],
+ "related-to-property": [{
+ "property-key": "cloud-region.owner-defined-type",
+ "property-value": "lcp"
+ }
+ ]
+ }
+ ]
+ }
+}
diff --git a/vid-app-common/src/test/resources/getTopology/serviceWithCR/CR.json b/vid-app-common/src/test/resources/getTopology/serviceWithCR/CR.json
new file mode 100644
index 000000000..26d598c6c
--- /dev/null
+++ b/vid-app-common/src/test/resources/getTopology/serviceWithCR/CR.json
@@ -0,0 +1,62 @@
+{
+ "collection-id": "84a351ae-3601-45e2-98df-878d6c816abc",
+ "model-invariant-id": "081ceb56-eb71-4566-a72d-3e7cbee5cdf1",
+ "model-version-id": "ce8c98bc-4691-44fb-8ff0-7a47487c11c4",
+ "collection-name": "NcmVlanSvcYm161f_77_vTSBC Customer Landing Network Collection",
+ "collection-type": "L3-NETWORK",
+ "collection-role": "SUB_INTERFACE",
+ "collection-function": "vTSBC_function",
+ "orchestration-status": "Active",
+ "collection-customization-id": "bac6ffe5-c851-495f-a64a-28751400ff03",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "service-instance",
+ "relationship-label": "org.onap.relationships.inventory.ComposedOf",
+ "related-link": "/aai/v14/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/Emanuel/service-instances/service-instance/a565e6ad-75d1-4493-98f1-33234b5c17e2",
+ "relationship-data": [
+ {
+ "relationship-key": "customer.global-customer-id",
+ "relationship-value": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb"
+ },
+ {
+ "relationship-key": "service-subscription.service-type",
+ "relationship-value": "Emanuel"
+ },
+ {
+ "relationship-key": "service-instance.service-instance-id",
+ "relationship-value": "a565e6ad-75d1-4493-98f1-33234b5c17e2"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "service-instance.service-instance-name",
+ "property-value": "NcmVlanSvcYm161f_77"
+ }
+ ]
+ },
+ {
+ "related-to": "instance-group",
+ "relationship-label": "org.onap.inventory.BelongsTo",
+ "related-link": "/aai/v14/network/instance-groups/instance-group/6b3536cf-3a12-457f-abb5-fa2203e0d923",
+ "relationship-data": [
+ {
+ "relationship-key": "instance-group.id",
+ "relationship-value": "6b3536cf-3a12-457f-abb5-fa2203e0d923"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "instance-group.description",
+ "property-value": "vTSBC Customer Landing Network Collection Desc"
+ },
+ {
+ "property-key": "instance-group.instance-group-name",
+ "property-value": "NcmVlanSvcYm161f_77_vTSBC Customer Landing Network Collection"
+ }
+ ]
+ }
+ ]
+ },
+ "resource-version": "1539158498209"
+}
diff --git a/vid-app-common/src/test/resources/getTopology/serviceWithCR/getTopologyWithCR.json b/vid-app-common/src/test/resources/getTopology/serviceWithCR/getTopologyWithCR.json
new file mode 100644
index 000000000..f038427c5
--- /dev/null
+++ b/vid-app-common/src/test/resources/getTopology/serviceWithCR/getTopologyWithCR.json
@@ -0,0 +1,95 @@
+{
+ "action": "None",
+ "instanceName": "NcmVlanSvcYm161f_77",
+ "instanceId": "a565e6ad-75d1-4493-98f1-33234b5c17e2",
+ "orchStatus": "Assigned",
+ "productFamilyId": null,
+ "lcpCloudRegionId": null,
+ "tenantId": null,
+ "cloudOwner": null,
+ "modelInfo": {
+ "modelInvariantId": "f6342be5-d66b-4d03-a1aa-c82c3094c4ea",
+ "modelVersionId": "6e0bec91-09f3-43aa-9cf3-e617cd0146be",
+ "modelName": "NCM_VLAN_SVC_ym161f",
+ "modelType": "service",
+ "modelVersion": "8.0"
+ },
+ "globalSubscriberId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "subscriptionServiceType": "Emanuel",
+ "owningEntityId": null,
+ "owningEntityName": null,
+ "tenantName": null,
+ "aicZoneId": null,
+ "aicZoneName": null,
+ "projectName": null,
+ "rollbackOnFailure": null,
+ "isALaCarte": false,
+ "vnfs": {},
+ "networks": {},
+ "vrfs": {},
+ "vnfGroups": {},
+ "collectionResources": {
+ "84a351ae-3601-45e2-98df-878d6c816abc": {
+ "action": "None",
+ "instanceName": "NcmVlanSvcYm161f_77_vTSBC Customer Landing Network Collection",
+ "instanceId": "84a351ae-3601-45e2-98df-878d6c816abc",
+ "orchStatus": "Active",
+ "productFamilyId": null,
+ "lcpCloudRegionId": null,
+ "tenantId": null,
+ "cloudOwner": null,
+ "modelInfo": {
+ "modelInvariantId": "081ceb56-eb71-4566-a72d-3e7cbee5cdf1",
+ "modelVersionId": "ce8c98bc-4691-44fb-8ff0-7a47487c11c4",
+ "modelName": "NCM_VLAN_ym161f",
+ "modelType": "collection",
+ "modelVersion": "5.0"
+ },
+ "instanceType": null,
+ "provStatus": null,
+ "inMaint": false,
+ "uuid": "ce8c98bc-4691-44fb-8ff0-7a47487c11c4",
+ "originalName": "NCM_VLAN_ym161f 0",
+ "legacyRegion": null,
+ "lineOfBusiness": null,
+ "platformName": null,
+ "trackById": "84a351ae-3601-45e2-98df-878d6c816abc",
+ "ncfs": {
+ "6b3536cf-3a12-457f-abb5-fa2203e0d923": {
+ "action": "None",
+ "instanceName": "NcmVlanSvcYm161f_77_vTSBC Customer Landing Network Collection",
+ "instanceId": "6b3536cf-3a12-457f-abb5-fa2203e0d923",
+ "orchStatus": null,
+ "productFamilyId": null,
+ "lcpCloudRegionId": null,
+ "tenantId": null,
+ "cloudOwner": null,
+ "modelInfo": {
+ "modelInvariantId": "868b109c-9481-4a18-891b-af974db7705a",
+ "modelVersionId": "dd182d7d-6949-4b90-b3cc-5befe400742e",
+ "modelName": "ncm_vlan_ym161f..NetworkCollection..0",
+ "modelType": "instanceGroup",
+ "modelVersion": "1"
+ },
+ "instanceType": "L3-NETWORK",
+ "provStatus": null,
+ "inMaint": false,
+ "uuid": "dd182d7d-6949-4b90-b3cc-5befe400742e",
+ "originalName": "ncm_vlan_ym161f..NetworkCollection..0",
+ "legacyRegion": null,
+ "lineOfBusiness": null,
+ "platformName": null,
+ "trackById": "6b3536cf-3a12-457f-abb5-fa2203e0d923",
+ "instanceGroupRole": "SUB_INTERFACE",
+ "instanceGroupFunction": "vTSBC Customer Landing Network Collection",
+ "numberOfNetworks": 1
+ }
+ }
+ }
+ },
+ "validationCounter": 0,
+ "existingVNFCounterMap": {},
+ "existingNetworksCounterMap": {},
+ "existingVnfGroupCounterMap": {},
+ "existingVRFCounterMap": {}
+}
diff --git a/vid-app-common/src/test/resources/getTopology/serviceWithCR/instanceGroup-NCF.json b/vid-app-common/src/test/resources/getTopology/serviceWithCR/instanceGroup-NCF.json
new file mode 100644
index 000000000..8c4d3f26c
--- /dev/null
+++ b/vid-app-common/src/test/resources/getTopology/serviceWithCR/instanceGroup-NCF.json
@@ -0,0 +1,43 @@
+{
+ "id": "6b3536cf-3a12-457f-abb5-fa2203e0d923",
+ "instance-group-role": "SUB_INTERFACE",
+ "model-invariant-id": "868b109c-9481-4a18-891b-af974db7705a",
+ "model-version-id": "dd182d7d-6949-4b90-b3cc-5befe400742e",
+ "description": "vTSBC Customer Landing Network Collection Desc",
+ "instance-group-type": "L3-NETWORK",
+ "resource-version": "1539158492730",
+ "instance-group-name": "NcmVlanSvcYm161f_77_vTSBC Customer Landing Network Collection",
+ "instance-group-function": "vTSBC Customer Landing Network Collection",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to-property": [
+ {
+ "property-value": "APPC-24595-T-IST-02AShared_cps_internal_net_1",
+ "property-key": "l3-network.network-name"
+ }
+ ],
+ "relationship-data": [
+ {
+ "relationship-value": "1fea0624-dac2-4997-904d-34ca1bc12fa9",
+ "relationship-key": "l3-network.network-id"
+ }
+ ],
+ "related-link": "/aai/v14/network/l3-networks/l3-network/1fea0624-dac2-4997-904d-34ca1bc12fa9",
+ "relationship-label": "org.onap.relationships.inventory.ComposedOf",
+ "related-to": "l3-network"
+ },
+ {
+ "related-to": "collection",
+ "relationship-label": "org.onap.inventory.BelongsTo",
+ "related-link": "/aai/v14/network/collections/collection/84a351ae-3601-45e2-98df-878d6c816abc",
+ "relationship-data": [
+ {
+ "relationship-key": "collection.collection-id",
+ "relationship-value": "84a351ae-3601-45e2-98df-878d6c816abc"
+ }
+ ]
+ }
+ ]
+ }
+} \ No newline at end of file
diff --git a/vid-app-common/src/test/resources/getTopology/serviceWithCR/service-design-and-creation.json b/vid-app-common/src/test/resources/getTopology/serviceWithCR/service-design-and-creation.json
new file mode 100644
index 000000000..d7bafebfe
--- /dev/null
+++ b/vid-app-common/src/test/resources/getTopology/serviceWithCR/service-design-and-creation.json
@@ -0,0 +1,1057 @@
+{
+ "model": [
+ {
+ "model-invariant-id": "f6342be5-d66b-4d03-a1aa-c82c3094c4ea",
+ "model-type": "service",
+ "resource-version": "1534274421300",
+ "model-vers": {
+ "model-ver": [
+ {
+ "model-version-id": "a92f899d-a3ec-465b-baed-1663b0a5aee1",
+ "model-name": "NCM_VLAN_SVC_ym161f",
+ "model-version": "3.0",
+ "distribution-status": "DISTRIBUTION_COMPLETE_OK",
+ "model-description": "Network Collection service for vLAN tagging",
+ "resource-version": "1534788756086",
+ "model-elements": {
+ "model-element": [
+ {
+ "model-element-uuid": "901e2641-c66c-4178-a6e8-cbe2877b0a2a",
+ "new-data-del-flag": "T",
+ "cardinality": "unbounded",
+ "resource-version": "1534463243387",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "model-ver",
+ "relationship-label": "org.onap.relationships.inventory.IsA",
+ "related-link": "/aai/v14/service-design-and-creation/models/model/82194af1-3c2c-485a-8f44-420e22a9eaa4/model-vers/model-ver/46b92144-923a-4d20-b85a-3cbd847668a9",
+ "relationship-data": [
+ {
+ "relationship-key": "model.model-invariant-id",
+ "relationship-value": "82194af1-3c2c-485a-8f44-420e22a9eaa4"
+ },
+ {
+ "relationship-key": "model-ver.model-version-id",
+ "relationship-value": "46b92144-923a-4d20-b85a-3cbd847668a9"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "model-ver.model-name",
+ "property-value": "service-instance"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ ]
+ }
+ },
+ {
+ "model-version-id": "d2fda667-e92e-4cfa-9620-5da5de01a319",
+ "model-name": "NCM_VLAN_SVC_ym161f",
+ "model-version": "1.0",
+ "distribution-status": "DISTRIBUTION_COMPLETE_OK",
+ "model-description": "Network Collection service for vLAN tagging",
+ "resource-version": "1534444087221",
+ "model-elements": {
+ "model-element": [
+ {
+ "model-element-uuid": "d291ed5e-4f50-4f57-956d-ce0e67a059e5",
+ "new-data-del-flag": "T",
+ "cardinality": "unbounded",
+ "resource-version": "1534274421311",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "model-ver",
+ "relationship-label": "org.onap.relationships.inventory.IsA",
+ "related-link": "/aai/v14/service-design-and-creation/models/model/82194af1-3c2c-485a-8f44-420e22a9eaa4/model-vers/model-ver/46b92144-923a-4d20-b85a-3cbd847668a9",
+ "relationship-data": [
+ {
+ "relationship-key": "model.model-invariant-id",
+ "relationship-value": "82194af1-3c2c-485a-8f44-420e22a9eaa4"
+ },
+ {
+ "relationship-key": "model-ver.model-version-id",
+ "relationship-value": "46b92144-923a-4d20-b85a-3cbd847668a9"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "model-ver.model-name",
+ "property-value": "service-instance"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ ]
+ }
+ },
+ {
+ "model-version-id": "d4a447e5-9791-47b9-b365-1abb19b4b626",
+ "model-name": "NCM_VLAN_SVC_ym161f",
+ "model-version": "4.0",
+ "model-description": "Network Collection service for vLAN tagging",
+ "resource-version": "1534863624237",
+ "model-elements": {
+ "model-element": [
+ {
+ "model-element-uuid": "0ef29f1f-836a-4fab-986c-5f1b96310a3d",
+ "new-data-del-flag": "T",
+ "cardinality": "unbounded",
+ "resource-version": "1534863624242",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "model-ver",
+ "relationship-label": "org.onap.relationships.inventory.IsA",
+ "related-link": "/aai/v14/service-design-and-creation/models/model/82194af1-3c2c-485a-8f44-420e22a9eaa4/model-vers/model-ver/46b92144-923a-4d20-b85a-3cbd847668a9",
+ "relationship-data": [
+ {
+ "relationship-key": "model.model-invariant-id",
+ "relationship-value": "82194af1-3c2c-485a-8f44-420e22a9eaa4"
+ },
+ {
+ "relationship-key": "model-ver.model-version-id",
+ "relationship-value": "46b92144-923a-4d20-b85a-3cbd847668a9"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "model-ver.model-name",
+ "property-value": "service-instance"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ ]
+ }
+ },
+ {
+ "model-version-id": "0e97a118-b1b6-40d5-bbad-98cdd51b1c48",
+ "model-name": "NCM_VLAN_SVC_ym161f",
+ "model-version": "11.0",
+ "distribution-status": "DISTRIBUTION_COMPLETE_OK",
+ "model-description": "Network Collection service for vLAN tagging",
+ "resource-version": "1550783120267",
+ "model-elements": {
+ "model-element": [
+ {
+ "model-element-uuid": "0ea8ac21-64b8-4489-9d62-12e625d66995",
+ "new-data-del-flag": "T",
+ "cardinality": "unbounded",
+ "resource-version": "1543961990189",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "model-ver",
+ "relationship-label": "org.onap.relationships.inventory.IsA",
+ "related-link": "/aai/v14/service-design-and-creation/models/model/82194af1-3c2c-485a-8f44-420e22a9eaa4/model-vers/model-ver/46b92144-923a-4d20-b85a-3cbd847668a9",
+ "relationship-data": [
+ {
+ "relationship-key": "model.model-invariant-id",
+ "relationship-value": "82194af1-3c2c-485a-8f44-420e22a9eaa4"
+ },
+ {
+ "relationship-key": "model-ver.model-version-id",
+ "relationship-value": "46b92144-923a-4d20-b85a-3cbd847668a9"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "model-ver.model-name",
+ "property-value": "service-instance"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ ]
+ }
+ },
+ {
+ "model-version-id": "46093d8f-6dfa-4332-9c00-7e822c681b59",
+ "model-name": "NCM_VLAN_SVC_ym161f",
+ "model-version": "7.0",
+ "distribution-status": "DISTRIBUTION_COMPLETE_OK",
+ "model-description": "Network Collection service for vLAN tagging",
+ "resource-version": "1534885144462",
+ "model-elements": {
+ "model-element": [
+ {
+ "model-element-uuid": "d74a5dff-ef7f-4e32-9c13-d82fb2c617c9",
+ "new-data-del-flag": "T",
+ "cardinality": "unbounded",
+ "resource-version": "1534885014144",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "model-ver",
+ "relationship-label": "org.onap.relationships.inventory.IsA",
+ "related-link": "/aai/v14/service-design-and-creation/models/model/82194af1-3c2c-485a-8f44-420e22a9eaa4/model-vers/model-ver/46b92144-923a-4d20-b85a-3cbd847668a9",
+ "relationship-data": [
+ {
+ "relationship-key": "model.model-invariant-id",
+ "relationship-value": "82194af1-3c2c-485a-8f44-420e22a9eaa4"
+ },
+ {
+ "relationship-key": "model-ver.model-version-id",
+ "relationship-value": "46b92144-923a-4d20-b85a-3cbd847668a9"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "model-ver.model-name",
+ "property-value": "service-instance"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ ]
+ }
+ },
+ {
+ "model-version-id": "12930bcc-5276-42bb-8ed6-1e43d7acae2c",
+ "model-name": "NCM_VLAN_SVC_ym161f",
+ "model-version": "10.0",
+ "distribution-status": "DISTRIBUTION_COMPLETE_OK",
+ "model-description": "Network Collection service for vLAN tagging",
+ "resource-version": "1539613511543",
+ "model-elements": {
+ "model-element": [
+ {
+ "model-element-uuid": "4d57798e-81b7-490e-bee8-48bd382a1349",
+ "new-data-del-flag": "T",
+ "cardinality": "unbounded",
+ "resource-version": "1539613450903",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "model-ver",
+ "relationship-label": "org.onap.relationships.inventory.IsA",
+ "related-link": "/aai/v14/service-design-and-creation/models/model/82194af1-3c2c-485a-8f44-420e22a9eaa4/model-vers/model-ver/46b92144-923a-4d20-b85a-3cbd847668a9",
+ "relationship-data": [
+ {
+ "relationship-key": "model.model-invariant-id",
+ "relationship-value": "82194af1-3c2c-485a-8f44-420e22a9eaa4"
+ },
+ {
+ "relationship-key": "model-ver.model-version-id",
+ "relationship-value": "46b92144-923a-4d20-b85a-3cbd847668a9"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "model-ver.model-name",
+ "property-value": "service-instance"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ ]
+ }
+ },
+ {
+ "model-version-id": "f8783bb2-6135-4c35-8320-64fa7deae76b",
+ "model-name": "NCM_VLAN_SVC_ym161f",
+ "model-version": "2.0",
+ "distribution-status": "DISTRIBUTION_COMPLETE_OK",
+ "model-description": "Network Collection service for vLAN tagging",
+ "resource-version": "1534450229751",
+ "model-elements": {
+ "model-element": [
+ {
+ "model-element-uuid": "c666f1dd-99ff-442a-9ba2-1ee2dabb9e25",
+ "new-data-del-flag": "T",
+ "cardinality": "unbounded",
+ "resource-version": "1534450167963",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "model-ver",
+ "relationship-label": "org.onap.relationships.inventory.IsA",
+ "related-link": "/aai/v14/service-design-and-creation/models/model/82194af1-3c2c-485a-8f44-420e22a9eaa4/model-vers/model-ver/46b92144-923a-4d20-b85a-3cbd847668a9",
+ "relationship-data": [
+ {
+ "relationship-key": "model.model-invariant-id",
+ "relationship-value": "82194af1-3c2c-485a-8f44-420e22a9eaa4"
+ },
+ {
+ "relationship-key": "model-ver.model-version-id",
+ "relationship-value": "46b92144-923a-4d20-b85a-3cbd847668a9"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "model-ver.model-name",
+ "property-value": "service-instance"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ ]
+ }
+ },
+ {
+ "model-version-id": "0148e4c5-629b-4fef-9728-1e13fd630679",
+ "model-name": "NCM_VLAN_SVC_ym161f",
+ "model-version": "9.0",
+ "distribution-status": "DISTRIBUTION_COMPLETE_OK",
+ "model-description": "Network Collection service for vLAN tagging",
+ "resource-version": "1537901614540",
+ "model-elements": {
+ "model-element": [
+ {
+ "model-element-uuid": "6ae6fd91-2086-470d-8c36-9d668c41fd32",
+ "new-data-del-flag": "T",
+ "cardinality": "unbounded",
+ "resource-version": "1537882880185",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "model-ver",
+ "relationship-label": "org.onap.relationships.inventory.IsA",
+ "related-link": "/aai/v14/service-design-and-creation/models/model/82194af1-3c2c-485a-8f44-420e22a9eaa4/model-vers/model-ver/46b92144-923a-4d20-b85a-3cbd847668a9",
+ "relationship-data": [
+ {
+ "relationship-key": "model.model-invariant-id",
+ "relationship-value": "82194af1-3c2c-485a-8f44-420e22a9eaa4"
+ },
+ {
+ "relationship-key": "model-ver.model-version-id",
+ "relationship-value": "46b92144-923a-4d20-b85a-3cbd847668a9"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "model-ver.model-name",
+ "property-value": "service-instance"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ ]
+ }
+ },
+ {
+ "model-version-id": "1ceab842-7ded-49f1-a129-dce2ecef8c71",
+ "model-name": "NCM_VLAN_SVC_ym161f",
+ "model-version": "6.0",
+ "distribution-status": "DISTRIBUTION_COMPLETE_OK",
+ "model-description": "Network Collection service for vLAN tagging",
+ "resource-version": "1534883213652",
+ "model-elements": {
+ "model-element": [
+ {
+ "model-element-uuid": "5ca853fc-2984-45c7-b2e7-8514a56785ba",
+ "new-data-del-flag": "T",
+ "cardinality": "unbounded",
+ "resource-version": "1534883154090",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "model-ver",
+ "relationship-label": "org.onap.relationships.inventory.IsA",
+ "related-link": "/aai/v14/service-design-and-creation/models/model/82194af1-3c2c-485a-8f44-420e22a9eaa4/model-vers/model-ver/46b92144-923a-4d20-b85a-3cbd847668a9",
+ "relationship-data": [
+ {
+ "relationship-key": "model.model-invariant-id",
+ "relationship-value": "82194af1-3c2c-485a-8f44-420e22a9eaa4"
+ },
+ {
+ "relationship-key": "model-ver.model-version-id",
+ "relationship-value": "46b92144-923a-4d20-b85a-3cbd847668a9"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "model-ver.model-name",
+ "property-value": "service-instance"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ ]
+ }
+ },
+ {
+ "model-version-id": "fd21f6b5-02f6-4ac0-9515-e1f01112da95",
+ "model-name": "NCM_VLAN_SVC_ym161f",
+ "model-version": "5.0",
+ "distribution-status": "DISTRIBUTION_COMPLETE_OK",
+ "model-description": "Network Collection service for vLAN tagging",
+ "resource-version": "1534872246413",
+ "model-elements": {
+ "model-element": [
+ {
+ "model-element-uuid": "0812b47d-7ef1-4a65-b6fb-9f3ff3bc3eee",
+ "new-data-del-flag": "T",
+ "cardinality": "unbounded",
+ "resource-version": "1534872174141",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "model-ver",
+ "relationship-label": "org.onap.relationships.inventory.IsA",
+ "related-link": "/aai/v14/service-design-and-creation/models/model/82194af1-3c2c-485a-8f44-420e22a9eaa4/model-vers/model-ver/46b92144-923a-4d20-b85a-3cbd847668a9",
+ "relationship-data": [
+ {
+ "relationship-key": "model.model-invariant-id",
+ "relationship-value": "82194af1-3c2c-485a-8f44-420e22a9eaa4"
+ },
+ {
+ "relationship-key": "model-ver.model-version-id",
+ "relationship-value": "46b92144-923a-4d20-b85a-3cbd847668a9"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "model-ver.model-name",
+ "property-value": "service-instance"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ ]
+ }
+ },
+ {
+ "model-version-id": "6e0bec91-09f3-43aa-9cf3-e617cd0146be",
+ "model-name": "NCM_VLAN_SVC_ym161f",
+ "model-version": "8.0",
+ "distribution-status": "DISTRIBUTION_COMPLETE_OK",
+ "model-description": "Network Collection service for vLAN tagging",
+ "resource-version": "1536098608209",
+ "model-elements": {
+ "model-element": [
+ {
+ "model-element-uuid": "a0247d2e-3843-4753-be2f-4c252c99390e",
+ "new-data-del-flag": "T",
+ "cardinality": "unbounded",
+ "resource-version": "1536098548388",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "model-ver",
+ "relationship-label": "org.onap.relationships.inventory.IsA",
+ "related-link": "/aai/v14/service-design-and-creation/models/model/82194af1-3c2c-485a-8f44-420e22a9eaa4/model-vers/model-ver/46b92144-923a-4d20-b85a-3cbd847668a9",
+ "relationship-data": [
+ {
+ "relationship-key": "model.model-invariant-id",
+ "relationship-value": "82194af1-3c2c-485a-8f44-420e22a9eaa4"
+ },
+ {
+ "relationship-key": "model-ver.model-version-id",
+ "relationship-value": "46b92144-923a-4d20-b85a-3cbd847668a9"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "model-ver.model-name",
+ "property-value": "service-instance"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }
+ ]
+ }
+ },
+ {
+ "model-invariant-id": "868b109c-9481-4a18-891b-af974db7705a",
+ "model-type": "resource",
+ "resource-version": "1534795610752",
+ "model-vers": {
+ "model-ver": [
+ {
+ "model-version-id": "dd182d7d-6949-4b90-b3cc-5befe400742e",
+ "model-name": "ncm_vlan_ym161f..NetworkCollection..0",
+ "model-version": "1",
+ "distribution-status": "DISTRIBUTION_COMPLETE_OK",
+ "resource-version": "1534795610763"
+ },
+ {
+ "model-version-id": "e5fc56b7-e14c-45e5-b127-978c36a921c0",
+ "model-name": "ncm_vlan_ym161f..NetworkCollection..0",
+ "model-version": "1",
+ "resource-version": "1543961989136",
+ "model-elements": {
+ "model-element": [
+ {
+ "model-element-uuid": "9001ff96-1142-49c6-af5b-df4e2b23a305",
+ "new-data-del-flag": "T",
+ "cardinality": "unbounded",
+ "resource-version": "1543961989136",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "model-ver",
+ "relationship-label": "org.onap.relationships.inventory.IsA",
+ "related-link": "/aai/v14/service-design-and-creation/models/model/3bf1e610-45f7-4ad6-b833-ca4c5ee6a3fd/model-vers/model-ver/8e6ee9dc-9017-444a-83b3-219edb018128",
+ "relationship-data": [
+ {
+ "relationship-key": "model.model-invariant-id",
+ "relationship-value": "3bf1e610-45f7-4ad6-b833-ca4c5ee6a3fd"
+ },
+ {
+ "relationship-key": "model-ver.model-version-id",
+ "relationship-value": "8e6ee9dc-9017-444a-83b3-219edb018128"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "model-ver.model-name",
+ "property-value": "instance-group"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "model-element",
+ "relationship-label": "org.onap.relationships.inventory.IsA",
+ "related-link": "/aai/v14/service-design-and-creation/models/model/081ceb56-eb71-4566-a72d-3e7cbee5cdf1/model-vers/model-ver/a580855f-8d1b-40d5-a75b-50709fbd17d3/model-elements/model-element/06014449-69d3-4aef-a96b-0a5130ba9483/model-elements/model-element/a050dc96-2c35-45c7-ba23-9279215d501e",
+ "relationship-data": [
+ {
+ "relationship-key": "model.model-invariant-id",
+ "relationship-value": "081ceb56-eb71-4566-a72d-3e7cbee5cdf1"
+ },
+ {
+ "relationship-key": "model-ver.model-version-id",
+ "relationship-value": "a580855f-8d1b-40d5-a75b-50709fbd17d3"
+ },
+ {
+ "relationship-key": "model-element.model-element-uuid",
+ "relationship-value": "06014449-69d3-4aef-a96b-0a5130ba9483"
+ },
+ {
+ "relationship-key": "model-element.model-element-uuid",
+ "relationship-value": "a050dc96-2c35-45c7-ba23-9279215d501e"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ ]
+ }
+ },
+ {
+ "model-invariant-id": "081ceb56-eb71-4566-a72d-3e7cbee5cdf1",
+ "model-type": "resource",
+ "resource-version": "1534788713816",
+ "model-vers": {
+ "model-ver": [
+ {
+ "model-version-id": "747d2a17-5771-4fd6-879d-c2e9e4c5cd4f",
+ "model-name": "NCM_VLAN_ym161f",
+ "model-version": "2.0",
+ "model-description": "Network Collection Service VF for VLAN TAgging",
+ "resource-version": "1534863623891",
+ "model-elements": {
+ "model-element": [
+ {
+ "model-element-uuid": "0dd28c63-cadf-48b2-afb0-a7bf7184ef5a",
+ "new-data-del-flag": "T",
+ "cardinality": "unbounded",
+ "resource-version": "1534863623895",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "model-ver",
+ "relationship-label": "org.onap.relationships.inventory.IsA",
+ "related-link": "/aai/v14/service-design-and-creation/models/model/425b2158-e51d-4509-9945-dad4556474a3/model-vers/model-ver/2a160989-b202-47dd-874b-4a0f275998f7",
+ "relationship-data": [
+ {
+ "relationship-key": "model.model-invariant-id",
+ "relationship-value": "425b2158-e51d-4509-9945-dad4556474a3"
+ },
+ {
+ "relationship-key": "model-ver.model-version-id",
+ "relationship-value": "2a160989-b202-47dd-874b-4a0f275998f7"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "model-ver.model-name",
+ "property-value": "cloud-region"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "model-element",
+ "relationship-label": "org.onap.relationships.inventory.IsA",
+ "related-link": "/aai/v14/service-design-and-creation/models/model/f6342be5-d66b-4d03-a1aa-c82c3094c4ea/model-vers/model-ver/d4a447e5-9791-47b9-b365-1abb19b4b626/model-elements/model-element/0ef29f1f-836a-4fab-986c-5f1b96310a3d/model-elements/model-element/700f890b-05c9-471a-b859-956655d28f47",
+ "relationship-data": [
+ {
+ "relationship-key": "model.model-invariant-id",
+ "relationship-value": "f6342be5-d66b-4d03-a1aa-c82c3094c4ea"
+ },
+ {
+ "relationship-key": "model-ver.model-version-id",
+ "relationship-value": "d4a447e5-9791-47b9-b365-1abb19b4b626"
+ },
+ {
+ "relationship-key": "model-element.model-element-uuid",
+ "relationship-value": "0ef29f1f-836a-4fab-986c-5f1b96310a3d"
+ },
+ {
+ "relationship-key": "model-element.model-element-uuid",
+ "relationship-value": "700f890b-05c9-471a-b859-956655d28f47"
+ }
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "model-version-id": "a580855f-8d1b-40d5-a75b-50709fbd17d3",
+ "model-name": "NCM_VLAN_ym161f",
+ "model-version": "6.0",
+ "model-description": "Network Collection Service VF for VLAN TAgging",
+ "resource-version": "1543961989670",
+ "model-elements": {
+ "model-element": [
+ {
+ "model-element-uuid": "06014449-69d3-4aef-a96b-0a5130ba9483",
+ "new-data-del-flag": "T",
+ "cardinality": "unbounded",
+ "resource-version": "1543961989670",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "model-ver",
+ "relationship-label": "org.onap.relationships.inventory.IsA",
+ "related-link": "/aai/v14/service-design-and-creation/models/model/8bac3599-9a1c-4b7f-80e5-c1838f744c23/model-vers/model-ver/3f908abc-3a15-40d0-b674-2a639e52884d",
+ "relationship-data": [
+ {
+ "relationship-key": "model.model-invariant-id",
+ "relationship-value": "8bac3599-9a1c-4b7f-80e5-c1838f744c23"
+ },
+ {
+ "relationship-key": "model-ver.model-version-id",
+ "relationship-value": "3f908abc-3a15-40d0-b674-2a639e52884d"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "model-ver.model-name",
+ "property-value": "collection"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "model-element",
+ "relationship-label": "org.onap.relationships.inventory.IsA",
+ "related-link": "/aai/v14/service-design-and-creation/models/model/f6342be5-d66b-4d03-a1aa-c82c3094c4ea/model-vers/model-ver/0e97a118-b1b6-40d5-bbad-98cdd51b1c48/model-elements/model-element/0ea8ac21-64b8-4489-9d62-12e625d66995/model-elements/model-element/d614653c-5f19-4668-ad98-cfbe012308e1",
+ "relationship-data": [
+ {
+ "relationship-key": "model.model-invariant-id",
+ "relationship-value": "f6342be5-d66b-4d03-a1aa-c82c3094c4ea"
+ },
+ {
+ "relationship-key": "model-ver.model-version-id",
+ "relationship-value": "0e97a118-b1b6-40d5-bbad-98cdd51b1c48"
+ },
+ {
+ "relationship-key": "model-element.model-element-uuid",
+ "relationship-value": "0ea8ac21-64b8-4489-9d62-12e625d66995"
+ },
+ {
+ "relationship-key": "model-element.model-element-uuid",
+ "relationship-value": "d614653c-5f19-4668-ad98-cfbe012308e1"
+ }
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "model-version-id": "b84e2233-37bf-4c8d-b613-eb8a8820b725",
+ "model-name": "NCM_VLAN_ym161f",
+ "model-version": "4.0",
+ "model-description": "Network Collection Service VF for VLAN TAgging",
+ "resource-version": "1534883153714",
+ "model-elements": {
+ "model-element": [
+ {
+ "model-element-uuid": "f7c3f5bb-777a-4d9f-9401-a652f5006152",
+ "new-data-del-flag": "T",
+ "cardinality": "unbounded",
+ "resource-version": "1534883153720",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "model-ver",
+ "relationship-label": "org.onap.relationships.inventory.IsA",
+ "related-link": "/aai/v14/service-design-and-creation/models/model/425b2158-e51d-4509-9945-dad4556474a3/model-vers/model-ver/2a160989-b202-47dd-874b-4a0f275998f7",
+ "relationship-data": [
+ {
+ "relationship-key": "model.model-invariant-id",
+ "relationship-value": "425b2158-e51d-4509-9945-dad4556474a3"
+ },
+ {
+ "relationship-key": "model-ver.model-version-id",
+ "relationship-value": "2a160989-b202-47dd-874b-4a0f275998f7"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "model-ver.model-name",
+ "property-value": "cloud-region"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "model-element",
+ "relationship-label": "org.onap.relationships.inventory.IsA",
+ "related-link": "/aai/v14/service-design-and-creation/models/model/f6342be5-d66b-4d03-a1aa-c82c3094c4ea/model-vers/model-ver/1ceab842-7ded-49f1-a129-dce2ecef8c71/model-elements/model-element/5ca853fc-2984-45c7-b2e7-8514a56785ba/model-elements/model-element/030553aa-8d82-4b03-a3dc-bc210daadd5e",
+ "relationship-data": [
+ {
+ "relationship-key": "model.model-invariant-id",
+ "relationship-value": "f6342be5-d66b-4d03-a1aa-c82c3094c4ea"
+ },
+ {
+ "relationship-key": "model-ver.model-version-id",
+ "relationship-value": "1ceab842-7ded-49f1-a129-dce2ecef8c71"
+ },
+ {
+ "relationship-key": "model-element.model-element-uuid",
+ "relationship-value": "5ca853fc-2984-45c7-b2e7-8514a56785ba"
+ },
+ {
+ "relationship-key": "model-element.model-element-uuid",
+ "relationship-value": "030553aa-8d82-4b03-a3dc-bc210daadd5e"
+ }
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "model-version-id": "5ededaad-905c-4356-b30d-471b0ae2a12a",
+ "model-name": "NCM_VLAN_ym161f",
+ "model-version": "3.0",
+ "model-description": "Network Collection Service VF for VLAN TAgging",
+ "resource-version": "1534872173817",
+ "model-elements": {
+ "model-element": [
+ {
+ "model-element-uuid": "31f558c6-d73a-43e4-aab0-c863ccd6b110",
+ "new-data-del-flag": "T",
+ "cardinality": "unbounded",
+ "resource-version": "1534872173821",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "model-ver",
+ "relationship-label": "org.onap.relationships.inventory.IsA",
+ "related-link": "/aai/v14/service-design-and-creation/models/model/425b2158-e51d-4509-9945-dad4556474a3/model-vers/model-ver/2a160989-b202-47dd-874b-4a0f275998f7",
+ "relationship-data": [
+ {
+ "relationship-key": "model.model-invariant-id",
+ "relationship-value": "425b2158-e51d-4509-9945-dad4556474a3"
+ },
+ {
+ "relationship-key": "model-ver.model-version-id",
+ "relationship-value": "2a160989-b202-47dd-874b-4a0f275998f7"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "model-ver.model-name",
+ "property-value": "cloud-region"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "model-element",
+ "relationship-label": "org.onap.relationships.inventory.IsA",
+ "related-link": "/aai/v14/service-design-and-creation/models/model/f6342be5-d66b-4d03-a1aa-c82c3094c4ea/model-vers/model-ver/fd21f6b5-02f6-4ac0-9515-e1f01112da95/model-elements/model-element/0812b47d-7ef1-4a65-b6fb-9f3ff3bc3eee/model-elements/model-element/110a5ba4-997b-45f0-8e53-d64d6b342be1",
+ "relationship-data": [
+ {
+ "relationship-key": "model.model-invariant-id",
+ "relationship-value": "f6342be5-d66b-4d03-a1aa-c82c3094c4ea"
+ },
+ {
+ "relationship-key": "model-ver.model-version-id",
+ "relationship-value": "fd21f6b5-02f6-4ac0-9515-e1f01112da95"
+ },
+ {
+ "relationship-key": "model-element.model-element-uuid",
+ "relationship-value": "0812b47d-7ef1-4a65-b6fb-9f3ff3bc3eee"
+ },
+ {
+ "relationship-key": "model-element.model-element-uuid",
+ "relationship-value": "110a5ba4-997b-45f0-8e53-d64d6b342be1"
+ }
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "model-version-id": "67b91dcd-4fa5-4111-80c9-60d524740667",
+ "model-name": "NCM_VLAN_ym161f",
+ "model-version": "1.0",
+ "model-description": "Network Collection Service VF for VLAN TAgging",
+ "resource-version": "1534788713822",
+ "model-elements": {
+ "model-element": [
+ {
+ "model-element-uuid": "6fdf228e-89ce-4cf6-9bd7-399aa1b690b3",
+ "new-data-del-flag": "T",
+ "cardinality": "unbounded",
+ "resource-version": "1534788713833",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "model-ver",
+ "relationship-label": "org.onap.relationships.inventory.IsA",
+ "related-link": "/aai/v14/service-design-and-creation/models/model/425b2158-e51d-4509-9945-dad4556474a3/model-vers/model-ver/2a160989-b202-47dd-874b-4a0f275998f7",
+ "relationship-data": [
+ {
+ "relationship-key": "model.model-invariant-id",
+ "relationship-value": "425b2158-e51d-4509-9945-dad4556474a3"
+ },
+ {
+ "relationship-key": "model-ver.model-version-id",
+ "relationship-value": "2a160989-b202-47dd-874b-4a0f275998f7"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "model-ver.model-name",
+ "property-value": "cloud-region"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ ]
+ }
+ },
+ {
+ "model-version-id": "ce8c98bc-4691-44fb-8ff0-7a47487c11c4",
+ "model-name": "NCM_VLAN_ym161f",
+ "model-version": "5.0",
+ "model-description": "Network Collection Service VF for VLAN TAgging",
+ "resource-version": "1534885013739",
+ "model-elements": {
+ "model-element": [
+ {
+ "model-element-uuid": "4bd10473-a9de-4399-abe7-c9b24e48e0ee",
+ "new-data-del-flag": "T",
+ "cardinality": "unbounded",
+ "resource-version": "1534885013745",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "model-ver",
+ "relationship-label": "org.onap.relationships.inventory.IsA",
+ "related-link": "/aai/v14/service-design-and-creation/models/model/425b2158-e51d-4509-9945-dad4556474a3/model-vers/model-ver/2a160989-b202-47dd-874b-4a0f275998f7",
+ "relationship-data": [
+ {
+ "relationship-key": "model.model-invariant-id",
+ "relationship-value": "425b2158-e51d-4509-9945-dad4556474a3"
+ },
+ {
+ "relationship-key": "model-ver.model-version-id",
+ "relationship-value": "2a160989-b202-47dd-874b-4a0f275998f7"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "model-ver.model-name",
+ "property-value": "cloud-region"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "model-element",
+ "relationship-label": "org.onap.relationships.inventory.IsA",
+ "related-link": "/aai/v14/service-design-and-creation/models/model/f6342be5-d66b-4d03-a1aa-c82c3094c4ea/model-vers/model-ver/12930bcc-5276-42bb-8ed6-1e43d7acae2c/model-elements/model-element/4d57798e-81b7-490e-bee8-48bd382a1349/model-elements/model-element/93eafb42-11b5-471d-8f8a-333408114a9a",
+ "relationship-data": [
+ {
+ "relationship-key": "model.model-invariant-id",
+ "relationship-value": "f6342be5-d66b-4d03-a1aa-c82c3094c4ea"
+ },
+ {
+ "relationship-key": "model-ver.model-version-id",
+ "relationship-value": "12930bcc-5276-42bb-8ed6-1e43d7acae2c"
+ },
+ {
+ "relationship-key": "model-element.model-element-uuid",
+ "relationship-value": "4d57798e-81b7-490e-bee8-48bd382a1349"
+ },
+ {
+ "relationship-key": "model-element.model-element-uuid",
+ "relationship-value": "93eafb42-11b5-471d-8f8a-333408114a9a"
+ }
+ ]
+ },
+ {
+ "related-to": "model-element",
+ "relationship-label": "org.onap.relationships.inventory.IsA",
+ "related-link": "/aai/v14/service-design-and-creation/models/model/f6342be5-d66b-4d03-a1aa-c82c3094c4ea/model-vers/model-ver/6e0bec91-09f3-43aa-9cf3-e617cd0146be/model-elements/model-element/a0247d2e-3843-4753-be2f-4c252c99390e/model-elements/model-element/cb986adf-5ca8-48a5-ac9b-b222d6d2e280",
+ "relationship-data": [
+ {
+ "relationship-key": "model.model-invariant-id",
+ "relationship-value": "f6342be5-d66b-4d03-a1aa-c82c3094c4ea"
+ },
+ {
+ "relationship-key": "model-ver.model-version-id",
+ "relationship-value": "6e0bec91-09f3-43aa-9cf3-e617cd0146be"
+ },
+ {
+ "relationship-key": "model-element.model-element-uuid",
+ "relationship-value": "a0247d2e-3843-4753-be2f-4c252c99390e"
+ },
+ {
+ "relationship-key": "model-element.model-element-uuid",
+ "relationship-value": "cb986adf-5ca8-48a5-ac9b-b222d6d2e280"
+ }
+ ]
+ },
+ {
+ "related-to": "model-element",
+ "relationship-label": "org.onap.relationships.inventory.IsA",
+ "related-link": "/aai/v14/service-design-and-creation/models/model/f6342be5-d66b-4d03-a1aa-c82c3094c4ea/model-vers/model-ver/0148e4c5-629b-4fef-9728-1e13fd630679/model-elements/model-element/6ae6fd91-2086-470d-8c36-9d668c41fd32/model-elements/model-element/a520808b-b8bc-4969-9eba-c85e2797f3dd",
+ "relationship-data": [
+ {
+ "relationship-key": "model.model-invariant-id",
+ "relationship-value": "f6342be5-d66b-4d03-a1aa-c82c3094c4ea"
+ },
+ {
+ "relationship-key": "model-ver.model-version-id",
+ "relationship-value": "0148e4c5-629b-4fef-9728-1e13fd630679"
+ },
+ {
+ "relationship-key": "model-element.model-element-uuid",
+ "relationship-value": "6ae6fd91-2086-470d-8c36-9d668c41fd32"
+ },
+ {
+ "relationship-key": "model-element.model-element-uuid",
+ "relationship-value": "a520808b-b8bc-4969-9eba-c85e2797f3dd"
+ }
+ ]
+ },
+ {
+ "related-to": "model-element",
+ "relationship-label": "org.onap.relationships.inventory.IsA",
+ "related-link": "/aai/v14/service-design-and-creation/models/model/ca26a7e6-064d-4e90-a5b9-32ffe819f826/model-vers/model-ver/e9a290ca-41f0-4117-a1b5-8b7cd5595ff7/model-elements/model-element/ff3fdeb9-24e9-406f-8761-1334c9ea29d1/model-elements/model-element/bc6ddc86-f948-4f47-a4e6-bededd8d5780",
+ "relationship-data": [
+ {
+ "relationship-key": "model.model-invariant-id",
+ "relationship-value": "ca26a7e6-064d-4e90-a5b9-32ffe819f826"
+ },
+ {
+ "relationship-key": "model-ver.model-version-id",
+ "relationship-value": "e9a290ca-41f0-4117-a1b5-8b7cd5595ff7"
+ },
+ {
+ "relationship-key": "model-element.model-element-uuid",
+ "relationship-value": "ff3fdeb9-24e9-406f-8761-1334c9ea29d1"
+ },
+ {
+ "relationship-key": "model-element.model-element-uuid",
+ "relationship-value": "bc6ddc86-f948-4f47-a4e6-bededd8d5780"
+ }
+ ]
+ },
+ {
+ "related-to": "model-element",
+ "relationship-label": "org.onap.relationships.inventory.IsA",
+ "related-link": "/aai/v14/service-design-and-creation/models/model/f6342be5-d66b-4d03-a1aa-c82c3094c4ea/model-vers/model-ver/46093d8f-6dfa-4332-9c00-7e822c681b59/model-elements/model-element/d74a5dff-ef7f-4e32-9c13-d82fb2c617c9/model-elements/model-element/f7bd32b4-bbbf-4788-9137-9dfa299e6111",
+ "relationship-data": [
+ {
+ "relationship-key": "model.model-invariant-id",
+ "relationship-value": "f6342be5-d66b-4d03-a1aa-c82c3094c4ea"
+ },
+ {
+ "relationship-key": "model-ver.model-version-id",
+ "relationship-value": "46093d8f-6dfa-4332-9c00-7e822c681b59"
+ },
+ {
+ "relationship-key": "model-element.model-element-uuid",
+ "relationship-value": "d74a5dff-ef7f-4e32-9c13-d82fb2c617c9"
+ },
+ {
+ "relationship-key": "model-element.model-element-uuid",
+ "relationship-value": "f7bd32b4-bbbf-4788-9137-9dfa299e6111"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }
+ ]
+}
diff --git a/vid-app-common/src/test/resources/getTopology/serviceWithCR/serviceWithCR.json b/vid-app-common/src/test/resources/getTopology/serviceWithCR/serviceWithCR.json
new file mode 100644
index 000000000..7b9672966
--- /dev/null
+++ b/vid-app-common/src/test/resources/getTopology/serviceWithCR/serviceWithCR.json
@@ -0,0 +1,38 @@
+{
+ "service-instance-id": "a565e6ad-75d1-4493-98f1-33234b5c17e2",
+ "service-instance-name": "NcmVlanSvcYm161f_77",
+ "service-type": "INFRASTRUCTURE",
+ "environment-context": "General_Revenue-Bearing",
+ "workload-context": "Production",
+ "model-invariant-id": "f6342be5-d66b-4d03-a1aa-c82c3094c4ea",
+ "model-version-id": "6e0bec91-09f3-43aa-9cf3-e617cd0146be",
+ "resource-version": "1539158502875",
+ "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/a565e6ad-75d1-4493-98f1-33234b5c17e2/service-data/service-topology/",
+ "orchestration-status": "Assigned",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "collection",
+ "relationship-label": "org.onap.relationships.inventory.ComposedOf",
+ "related-link": "/aai/v14/network/collections/collection/84a351ae-3601-45e2-98df-878d6c816abc",
+ "relationship-data": [
+ {
+ "relationship-key": "collection.collection-id",
+ "relationship-value": "84a351ae-3601-45e2-98df-878d6c816abc"
+ }
+ ]
+ },
+ {
+ "related-to": "owning-entity",
+ "relationship-label": "org.onap.relationships.inventory.BelongsTo",
+ "related-link": "/aai/v14/business/owning-entities/owning-entity/e4257a94-21cc-40c5-adc9-e6f4ff868e31",
+ "relationship-data": [
+ {
+ "relationship-key": "owning-entity.owning-entity-id",
+ "relationship-value": "e4257a94-21cc-40c5-adc9-e6f4ff868e31"
+ }
+ ]
+ }
+ ]
+ }
+} \ No newline at end of file
diff --git a/vid-app-common/src/test/resources/getTopology/serviceWithCR/serviceWithCRModel.json b/vid-app-common/src/test/resources/getTopology/serviceWithCR/serviceWithCRModel.json
new file mode 100644
index 000000000..6cca1cdc0
--- /dev/null
+++ b/vid-app-common/src/test/resources/getTopology/serviceWithCR/serviceWithCRModel.json
@@ -0,0 +1,72 @@
+{
+ "service": {
+ "uuid": "6e0bec91-09f3-43aa-9cf3-e617cd0146be",
+ "invariantUuid": "f6342be5-d66b-4d03-a1aa-c82c3094c4ea",
+ "name": "NCM_VLAN_SVC_ym161f",
+ "version": "8.0",
+ "toscaModelURL": null,
+ "category": "Network L4+",
+ "serviceType": "INFRASTRUCTURE",
+ "serviceRole": "",
+ "description": "Network Collection service for vLAN tagging",
+ "serviceEcompNaming": "true",
+ "instantiationType": "Macro",
+ "inputs": {},
+ "vidNotions": {
+ "instantiationType": "Macro",
+ "instantiationUI": "serviceWithCollectionResource",
+ "modelCategory": "other",
+ "viewEditUI": "serviceWithCollectionResource"
+ }
+ },
+ "vnfs": {},
+ "networks": {},
+ "collectionResources": {
+ "NCM_VLAN_ym161f 0": {
+ "uuid": "ce8c98bc-4691-44fb-8ff0-7a47487c11c4",
+ "invariantUuid": "081ceb56-eb71-4566-a72d-3e7cbee5cdf1",
+ "description": "Network Collection Service VF for VLAN TAgging",
+ "name": "NCM_VLAN_ym161f",
+ "version": "5.0",
+ "customizationUuid": "bac6ffe5-c851-495f-a64a-28751400ff03",
+ "inputs": {},
+ "commands": {},
+ "properties": {
+ "ncm_vlan_ym161f..Fixed..0_quantity": "3",
+ "cr_function": "vTSBC_function",
+ "ncm_vlan_ym161f..NetworkCollection..0_network_collection_description": "vTSBC Customer Landing Network Collection Desc",
+ "cr_role": "SUB_INTERFACE",
+ "cr_type": "L3-NETWORK",
+ "ecomp_generated_naming": "false",
+ "ncm_vlan_ym161f..NetworkCollection..0_network_collection_function": "vTSBC Customer Landing Network Collection"
+ },
+ "type": "CR",
+ "category": "Generic",
+ "subcategory": "Infrastructure",
+ "resourceVendor": "ATT",
+ "resourceVendorRelease": "201810",
+ "resourceVendorModelNumber": "294455b",
+ "customizationUUID": "bac6ffe5-c851-495f-a64a-28751400ff03",
+ "networksCollection": {
+ "ncm_vlan_ym161f..NetworkCollection..0": {
+ "uuid": "dd182d7d-6949-4b90-b3cc-5befe400742e",
+ "invariantUuid": "868b109c-9481-4a18-891b-af974db7705a",
+ "name": "ncm_vlan_ym161f..NetworkCollection..0",
+ "version": "1",
+ "networkCollectionProperties": {
+ "networkCollectionFunction": "vTSBC Customer Landing Network Collection",
+ "networkCollectionDescription": "vTSBC Customer Landing Network Collection Desc"
+ }
+ }
+ }
+ }
+ },
+ "configurations": {},
+ "fabricConfigurations": {},
+ "serviceProxies": {},
+ "vfModules": {},
+ "volumeGroups": {},
+ "pnfs": {},
+ "vnfGroups": {},
+ "vrfs": {}
+}
diff --git a/vid-app-common/src/test/resources/getTopology/vfModule.json b/vid-app-common/src/test/resources/getTopology/vfModule.json
new file mode 100644
index 000000000..3fd9c089e
--- /dev/null
+++ b/vid-app-common/src/test/resources/getTopology/vfModule.json
@@ -0,0 +1,66 @@
+{
+ "vf-module": [{
+ "vf-module-id": "2cb6d41e-2bef-4cb2-80ce-c7815bcdcf4e",
+ "vf-module-name": "dyh3brarf8000v_base",
+ "heat-stack-id": "dyh3brarf8000v_base/5a826d59-cafa-49fd-9860-dfc6eb7515ae",
+ "orchestration-status": "Active",
+ "is-base-vf-module": true,
+ "automated-assignment": false,
+ "resource-version": "1546547784901",
+ "model-invariant-id": "3ecca473-b0c0-46ae-b0b7-bd2969d8b79f",
+ "model-version-id": "5c35b764-e266-4498-af87-a88c4ba92dc4",
+ "model-customization-id": "06b4ece0-f6f8-4003-b445-653418292101",
+ "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/aea56040-8caf-41b3-a85b-97c44001499e/service-data/vnfs/vnf/9a7a4dc1-8e5f-43fe-a360-7734c5f51382/vnf-data/vf-modules/vf-module/2cb6d41e-2bef-4cb2-80ce-c7815bcdcf4e/vf-module-data/vf-module-topology/",
+ "relationship-list": {
+ "relationship": [{
+ "related-to": "l3-network",
+ "relationship-label": "org.onap.relationships.inventory.DependsOn",
+ "related-link": "/aai/v14/network/l3-networks/l3-network/974345f8-75d5-4ae2-be72-600930bcbe6b",
+ "relationship-data": [{
+ "relationship-key": "l3-network.network-id",
+ "relationship-value": "974345f8-75d5-4ae2-be72-600930bcbe6b"
+ }
+ ],
+ "related-to-property": [{
+ "property-key": "l3-network.network-name",
+ "property-value": "APP-C-24595-T-IST-05B_oam_protected_net_1"
+ }
+ ]
+ }, {
+ "related-to": "vnfc",
+ "relationship-label": "org.onap.relationships.inventory.Uses",
+ "related-link": "/aai/v14/network/vnfcs/vnfc/dyh3brarf8000vm001",
+ "relationship-data": [{
+ "relationship-key": "vnfc.vnfc-name",
+ "relationship-value": "dyh3brarf8000vm001"
+ }
+ ]
+ }, {
+ "related-to": "vserver",
+ "relationship-label": "org.onap.relationships.inventory.Uses",
+ "related-link": "/aai/v14/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/dyh3b/tenants/tenant/c8035f5ee95d4c62bbc8074c044122b9/vservers/vserver/3e3985e1-2369-4191-9721-7858a478ab6d",
+ "relationship-data": [{
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "irma-aic"
+ }, {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "dyh3b"
+ }, {
+ "relationship-key": "tenant.tenant-id",
+ "relationship-value": "c8035f5ee95d4c62bbc8074c044122b9"
+ }, {
+ "relationship-key": "vserver.vserver-id",
+ "relationship-value": "3e3985e1-2369-4191-9721-7858a478ab6d"
+ }
+ ],
+ "related-to-property": [{
+ "property-key": "vserver.vserver-name",
+ "property-value": "dyh3brarf8000vm001"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ ]
+}
diff --git a/vid-app-common/src/test/resources/getTopology/vnf.json b/vid-app-common/src/test/resources/getTopology/vnf.json
new file mode 100644
index 000000000..7b640dac1
--- /dev/null
+++ b/vid-app-common/src/test/resources/getTopology/vnf.json
@@ -0,0 +1,160 @@
+{
+ "vnf-id": "9a7a4dc1-8e5f-43fe-a360-7734c5f51382",
+ "vnf-name": "dyh3brarf8000v",
+ "vnf-type": "vRAR_1902_ap7134/vRAR_1902_ap7134 0",
+ "prov-status": "PREPROV",
+ "equipment-role": "vRAR",
+ "orchestration-status": "Active",
+ "in-maint": true,
+ "is-closed-loop-disabled": false,
+ "resource-version": "1547155053461",
+ "model-invariant-id": "b711997f-36b3-4a9b-8b37-71a0fc2ebd6d",
+ "model-version-id": "7f23e4f7-e44c-44df-b066-4cedc6950bfe",
+ "model-customization-id": "401350be-0f56-481c-86d8-f32d573fec26",
+ "nf-type": "REPORT",
+ "nf-function": "REVENUE-ASSURANCE",
+ "nf-role": "vRAR",
+ "nf-naming-code": "rarf",
+ "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/aea56040-8caf-41b3-a85b-97c44001499e/service-data/vnfs/vnf/9a7a4dc1-8e5f-43fe-a360-7734c5f51382/vnf-data/vnf-topology/",
+ "relationship-list": {
+ "relationship": [{
+ "related-to": "service-instance",
+ "relationship-label": "org.onap.relationships.inventory.ComposedOf",
+ "related-link": "/aai/v14/business/customers/customer/e433710f-9217-458d-a79d-1c7aff376d89/service-subscriptions/service-subscription/TYLER%20SILVIA/service-instances/service-instance/aea56040-8caf-41b3-a85b-97c44001499e",
+ "relationship-data": [{
+ "relationship-key": "customer.global-customer-id",
+ "relationship-value": "e433710f-9217-458d-a79d-1c7aff376d89"
+ }, {
+ "relationship-key": "service-subscription.service-type",
+ "relationship-value": "TYLER SILVIA"
+ }, {
+ "relationship-key": "service-instance.service-instance-id",
+ "relationship-value": "aea56040-8caf-41b3-a85b-97c44001499e"
+ }
+ ],
+ "related-to-property": [{
+ "property-key": "service-instance.service-instance-name",
+ "property-value": "vRAR_1902_un577h"
+ }
+ ]
+ }, {
+ "related-to": "vnfc",
+ "relationship-label": "org.onap.relationships.inventory.BelongsTo",
+ "related-link": "/aai/v14/network/vnfcs/vnfc/dyh3brarf8000vm001",
+ "relationship-data": [{
+ "relationship-key": "vnfc.vnfc-name",
+ "relationship-value": "dyh3brarf8000vm001"
+ }
+ ]
+ }, {
+ "related-to": "platform",
+ "relationship-label": "org.onap.relationships.inventory.Uses",
+ "related-link": "/aai/v14/business/platforms/platform/FIRSTNET-DEDICATED",
+ "relationship-data": [{
+ "relationship-key": "platform.platform-name",
+ "relationship-value": "FIRSTNET-DEDICATED"
+ }
+ ]
+ }, {
+ "related-to": "line-of-business",
+ "relationship-label": "org.onap.relationships.inventory.Uses",
+ "related-link": "/aai/v14/business/lines-of-business/line-of-business/FIRSTNET",
+ "relationship-data": [{
+ "relationship-key": "line-of-business.line-of-business-name",
+ "relationship-value": "LINDSEY"
+ }
+ ]
+ }, {
+ "related-to": "tenant",
+ "relationship-label": "org.onap.relationships.inventory.BelongsTo",
+ "related-link": "/aai/v14/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/dyh3b/tenants/tenant/c8035f5ee95d4c62bbc8074c044122b9",
+ "relationship-data": [{
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "irma-aic"
+ }, {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "dyh3b"
+ }, {
+ "relationship-key": "tenant.tenant-id",
+ "relationship-value": "c8035f5ee95d4c62bbc8074c044122b9"
+ }
+ ],
+ "related-to-property": [{
+ "property-key": "tenant.tenant-name",
+ "property-value": "APP-C-24595-T-IST-05B"
+ }
+ ]
+ }, {
+ "related-to": "vserver",
+ "relationship-label": "tosca.relationships.HostedOn",
+ "related-link": "/aai/v14/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/dyh3b/tenants/tenant/c8035f5ee95d4c62bbc8074c044122b9/vservers/vserver/3e3985e1-2369-4191-9721-7858a478ab6d",
+ "relationship-data": [{
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "irma-aic"
+ }, {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "dyh3b"
+ }, {
+ "relationship-key": "tenant.tenant-id",
+ "relationship-value": "c8035f5ee95d4c62bbc8074c044122b9"
+ }, {
+ "relationship-key": "vserver.vserver-id",
+ "relationship-value": "3e3985e1-2369-4191-9721-7858a478ab6d"
+ }
+ ],
+ "related-to-property": [{
+ "property-key": "vserver.vserver-name",
+ "property-value": "dyh3brarf8000vm001"
+ }
+ ]
+ }, {
+ "related-to": "availability-zone",
+ "relationship-label": "org.onap.relationships.inventory.Uses",
+ "related-link": "/aai/v14/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/dyh3b/availability-zones/availability-zone/dyh3b-kvm-az02",
+ "relationship-data": [{
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "irma-aic"
+ }, {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "dyh3b"
+ }, {
+ "relationship-key": "availability-zone.availability-zone-name",
+ "relationship-value": "dyh3b-kvm-az02"
+ }
+ ]
+ }, {
+ "related-to": "availability-zone",
+ "relationship-label": "org.onap.relationships.inventory.Uses",
+ "related-link": "/aai/v14/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/dyh3b/availability-zones/availability-zone/dyh3b-kvm-az01",
+ "relationship-data": [{
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "irma-aic"
+ }, {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "dyh3b"
+ }, {
+ "relationship-key": "availability-zone.availability-zone-name",
+ "relationship-value": "dyh3b-kvm-az01"
+ }
+ ]
+ }, {
+ "related-to": "cloud-region",
+ "relationship-label": "org.onap.relationships.inventory.LocatedIn",
+ "related-link": "/aai/v14/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/dyh3b",
+ "relationship-data": [{
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "irma-aic"
+ }, {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "dyh3b"
+ }
+ ],
+ "related-to-property": [{
+ "property-key": "cloud-region.owner-defined-type",
+ "property-value": "lcp"
+ }
+ ]
+ }
+ ]
+ }
+}
diff --git a/vid-app-common/src/test/resources/orchestrationRequestsByServiceInstanceId.json b/vid-app-common/src/test/resources/orchestrationRequestsByServiceInstanceId.json
index 34f18f7fb..d20fc6700 100644
--- a/vid-app-common/src/test/resources/orchestrationRequestsByServiceInstanceId.json
+++ b/vid-app-common/src/test/resources/orchestrationRequestsByServiceInstanceId.json
@@ -93,7 +93,7 @@
],
"cloudConfiguration": {
"tenantId": "460f35aeb53542dc9f77105066483e83",
- "cloudOwner": "att-aic",
+ "cloudOwner": "irma-aic" ,
"lcpCloudRegionId": "rdm5b"
},
"requestParameters": {},
@@ -177,7 +177,7 @@
],
"cloudConfiguration": {
"tenantId": "460f35aeb53542dc9f77105066483e83",
- "cloudOwner": "att-aic",
+ "cloudOwner": "irma-aic" ,
"lcpCloudRegionId": "rdm5b"
},
"requestParameters": {
diff --git a/vid-app-common/src/test/resources/payload_jsons/VnfGroupCreate1Delete1None1Request.json b/vid-app-common/src/test/resources/payload_jsons/VnfGroupCreate1Delete1None1Request.json
new file mode 100644
index 000000000..bc645452f
--- /dev/null
+++ b/vid-app-common/src/test/resources/payload_jsons/VnfGroupCreate1Delete1None1Request.json
@@ -0,0 +1,123 @@
+{
+ "action": "None",
+ "isDirty": true,
+ "trackById":"aabbcc",
+ "vnfs": {},
+ "instanceParams": [],
+ "validationCounter": 0,
+ "existingNames": {
+ "service_instance_name": "",
+ "vnf_group3_instance_name": ""
+ },
+ "existingVNFCounterMap": {},
+ "existingVnfGroupCounterMap": {
+ "daeb6568-cef8-417f-9075-ed259ce59f48": 3
+ },
+ "existingNetworksCounterMap": {},
+ "networks": {},
+ "vnfGroups": {
+ "groupingservicefortest..ResourceInstanceGroup..0:001": {
+ "originalName": "groupingservicefortest..ResourceInstanceGroup..0",
+ "trackById": "groupingservicefortest..ResourceInstanceGroup..0:001",
+ "instanceName": "VNF_GROUP1_INSTANCE_NAME",
+ "lcpCloudRegionId": null,
+ "legacyRegion": null,
+ "lineOfBusiness": null,
+ "action": "None_Delete",
+ "instanceId": "VNF_GROUP1_INSTANCE_ID",
+ "instanceType": "VNF_GROUP1_INSTANCE_TYPE",
+ "orchStatus": null,
+ "platformName": null,
+ "productFamilyId": null,
+ "provStatus": null,
+ "tenantId": null,
+ "inMaint": false,
+ "modelInfo": {
+ "modelType": "instanceGroup",
+ "modelCustomizationName": "groupingservicefortest..ResourceInstanceGroup..0",
+ "modelInvariantId": "4bb2e27e-ddab-4790-9c6d-1f731bc14a45",
+ "modelVersionId": "daeb6568-cef8-417f-9075-ed259ce59f48"
+ },
+ "uuid": "daeb6568-cef8-417f-9075-ed259ce59f48",
+ "instanceGroupRole": "VNF_GROUP1_INSTANCE_ROLE",
+ "instanceGroupFunction": "vTSBC Customer Landing Network Collection",
+ "vnfs":{}
+ },
+ "groupingservicefortest..ResourceInstanceGroup..0:002": {
+ "originalName": "groupingservicefortest..ResourceInstanceGroup..0",
+ "trackById": "groupingservicefortest..ResourceInstanceGroup..0:002",
+ "instanceName": "VNF_GROUP2_INSTANCE_NAME",
+ "lcpCloudRegionId": null,
+ "legacyRegion": null,
+ "lineOfBusiness": null,
+ "action": "None",
+ "instanceId": "VNF_GROUP2_INSTANCE_ID",
+ "instanceType": "VNF_GROUP2_INSTANCE_TYPE",
+ "orchStatus": null,
+ "platformName": null,
+ "productFamilyId": null,
+ "provStatus": null,
+ "inMaint": false,
+ "modelInfo": {
+ "modelType": "instanceGroup",
+ "modelCustomizationName": "groupingservicefortest..ResourceInstanceGroup..0",
+ "modelInvariantId": "4bb2e27e-ddab-4790-9c6d-1f731bc14a45",
+ "modelVersionId": "daeb6568-cef8-417f-9075-ed259ce59f48"
+ },
+ "uuid": "daeb6568-cef8-417f-9075-ed259ce59f48",
+ "tenantId": null,
+ "instanceGroupRole": "VNF_GROUP2_INSTANCE_ROLE",
+ "instanceGroupFunction": "vTSBC Customer Landing Network Collection",
+ "vnfs": {}
+ },
+ "groupingservicefortest..ResourceInstanceGroup..0": {
+ "action": "Create",
+ "inMaint": false,
+ "rollbackOnFailure": "true",
+ "originalName": "groupingservicefortest..ResourceInstanceGroup..0",
+ "isMissingData": false,
+ "trackById": "ag5aav86u4j",
+ "vnfGroupStoreKey": "groupingservicefortest..ResourceInstanceGroup..0",
+ "uuid": "daeb6568-cef8-417f-9075-ed259ce59f48",
+ "instanceName": "VNF_GROUP3_INSTANCE_NAME",
+ "modelInfo": {
+ "modelInvariantId": "4bb2e27e-ddab-4790-9c6d-1f731bc14a45",
+ "modelVersionId": "daeb6568-cef8-417f-9075-ed259ce59f48",
+ "modelName": "groupingservicefortest..ResourceInstanceGroup..0",
+ "modelVersion": "1",
+ "modelCustomizationName": "groupingservicefortest..ResourceInstanceGroup..0",
+ "uuid": "daeb6568-cef8-417f-9075-ed259ce59f48"
+ },
+ "instanceParams": [{}
+ ],
+ "vnfs":{}
+ }
+ },
+ "bulkSize": 1,
+ "instanceName": "SERVICE_INSTANCE_NAME",
+
+ "instanceId": "service-instance-id",
+ "orchStatus": "GARBAGE DATA",
+ "globalSubscriberId": "global-customer-id",
+ "subscriptionServiceType": "service-instance-type",
+ "owningEntityId": null,
+ "owningEntityName": null,
+ "productFamilyId": null,
+ "lcpCloudRegionId": null,
+ "tenantId": null,
+ "tenantName": null,
+ "aicZoneId": null,
+ "aicZoneName": null,
+ "projectName": null,
+ "rollbackOnFailure": false,
+ "isALaCarte": true,
+ "modelInfo": {
+ "modelInvariantId": "7ee41ce4-4827-44b0-a48e-2707a59905d2",
+ "modelVersionId": "4117a0b6-e234-467d-b5b9-fe2f68c8b0fc",
+ "modelName": "Grouping Service for Test",
+ "modelType": "service",
+ "modelVersion": "1.0"
+ },
+
+ "testApi": "VNF_API"
+}
diff --git a/vid-app-common/src/test/resources/payload_jsons/VnfGroupCreate3Delete1None1Request.json b/vid-app-common/src/test/resources/payload_jsons/VnfGroupCreate3Delete1None1Request.json
new file mode 100644
index 000000000..1906bc89f
--- /dev/null
+++ b/vid-app-common/src/test/resources/payload_jsons/VnfGroupCreate3Delete1None1Request.json
@@ -0,0 +1,171 @@
+{
+ "action": "None",
+ "isDirty": true,
+ "trackById":"aabbcc",
+ "vnfs": {},
+ "instanceParams": [],
+ "validationCounter": 0,
+ "existingNames": {
+ "service_instance_name": "",
+ "vnf_group3_instance_name": ""
+ },
+ "existingVNFCounterMap": {},
+ "existingVnfGroupCounterMap": {
+ "daeb6568-cef8-417f-9075-ed259ce59f48": 3
+ },
+ "existingNetworksCounterMap": {},
+ "networks": {},
+ "vnfGroups": {
+ "groupingservicefortest..ResourceInstanceGroup..0:001": {
+ "originalName": "groupingservicefortest..ResourceInstanceGroup..0",
+ "trackById": "groupingservicefortest..ResourceInstanceGroup..0:001",
+ "instanceName": "VNF_GROUP1_INSTANCE_NAME",
+ "lcpCloudRegionId": null,
+ "legacyRegion": null,
+ "lineOfBusiness": null,
+ "action": "None_Delete",
+ "instanceId": "VNF_GROUP1_INSTANCE_ID",
+ "instanceType": "VNF_GROUP1_INSTANCE_TYPE",
+ "orchStatus": null,
+ "platformName": null,
+ "productFamilyId": null,
+ "provStatus": null,
+ "tenantId": null,
+ "inMaint": false,
+ "modelInfo": {
+ "modelType": "instanceGroup",
+ "modelCustomizationName": "groupingservicefortest..ResourceInstanceGroup..0",
+ "modelInvariantId": "4bb2e27e-ddab-4790-9c6d-1f731bc14a45",
+ "modelVersionId": "daeb6568-cef8-417f-9075-ed259ce59f48"
+ },
+ "uuid": "daeb6568-cef8-417f-9075-ed259ce59f48",
+ "instanceGroupRole": "VNF_GROUP1_INSTANCE_ROLE",
+ "instanceGroupFunction": "vTSBC Customer Landing Network Collection",
+ "vnfs":{}
+ },
+ "groupingservicefortest..ResourceInstanceGroup..0:002": {
+ "originalName": "groupingservicefortest..ResourceInstanceGroup..0",
+ "trackById": "groupingservicefortest..ResourceInstanceGroup..0:002",
+ "instanceName": "VNF_GROUP2_INSTANCE_NAME",
+ "lcpCloudRegionId": null,
+ "legacyRegion": null,
+ "lineOfBusiness": null,
+ "action": "None",
+ "instanceId": "VNF_GROUP2_INSTANCE_ID",
+ "instanceType": "VNF_GROUP2_INSTANCE_TYPE",
+ "orchStatus": null,
+ "platformName": null,
+ "productFamilyId": null,
+ "provStatus": null,
+ "inMaint": false,
+ "modelInfo": {
+ "modelType": "instanceGroup",
+ "modelCustomizationName": "groupingservicefortest..ResourceInstanceGroup..0",
+ "modelInvariantId": "4bb2e27e-ddab-4790-9c6d-1f731bc14a45",
+ "modelVersionId": "daeb6568-cef8-417f-9075-ed259ce59f48"
+ },
+ "uuid": "daeb6568-cef8-417f-9075-ed259ce59f48",
+ "tenantId": null,
+ "instanceGroupRole": "VNF_GROUP2_INSTANCE_ROLE",
+ "instanceGroupFunction": "vTSBC Customer Landing Network Collection",
+ "vnfs": {}
+ },
+ "groupingservicefortest..ResourceInstanceGroup..0": {
+ "action": "Create",
+ "inMaint": false,
+ "rollbackOnFailure": "true",
+ "originalName": "groupingservicefortest..ResourceInstanceGroup..0",
+ "isMissingData": false,
+ "trackById": "ag5aav86u4j",
+ "vnfGroupStoreKey": "groupingservicefortest..ResourceInstanceGroup..0",
+ "uuid": "daeb6568-cef8-417f-9075-ed259ce59f48",
+ "instanceName": "VNF_GROUP3_INSTANCE_NAME",
+ "modelInfo": {
+ "modelInvariantId": "4bb2e27e-ddab-4790-9c6d-1f731bc14a45",
+ "modelVersionId": "daeb6568-cef8-417f-9075-ed259ce59f48",
+ "modelName": "groupingservicefortest..ResourceInstanceGroup..0",
+ "modelVersion": "1",
+ "modelCustomizationName": "groupingservicefortest..ResourceInstanceGroup..0",
+ "uuid": "daeb6568-cef8-417f-9075-ed259ce59f48"
+ },
+ "instanceParams": [{}
+ ],
+ "vnfs":{}
+ },
+ "groupingservicefortest..ResourceInstanceGroup..0:003": {
+ "action": "Create",
+ "isFailed": true,
+ "statusMessage": "failed!",
+ "inMaint": false,
+ "rollbackOnFailure": "true",
+ "originalName": "groupingservicefortest..ResourceInstanceGroup..0",
+ "isMissingData": false,
+ "trackById": "asedrftjko",
+ "vnfGroupStoreKey": "groupingservicefortest..ResourceInstanceGroup..0",
+ "uuid": "daeb6568-cef8-417f-9075-ed259ce59f48",
+ "instanceName": "VNF_GROUP4_INSTANCE_NAME",
+ "modelInfo": {
+ "modelInvariantId": "4bb2e27e-ddab-4790-9c6d-1f731bc14a45",
+ "modelVersionId": "daeb6568-cef8-417f-9075-ed259ce59f48",
+ "modelName": "groupingservicefortest..ResourceInstanceGroup..0",
+ "modelVersion": "1",
+ "modelCustomizationName": "groupingservicefortest..ResourceInstanceGroup..0",
+ "uuid": "daeb6568-cef8-417f-9075-ed259ce59f48"
+ },
+ "instanceParams": [{}
+ ],
+ "vnfs":{}
+ },
+ "groupingservicefortest..ResourceInstanceGroup..0:004": {
+ "action": "Create",
+ "isFailed": false,
+ "statusMessage": null,
+ "inMaint": false,
+ "rollbackOnFailure": "true",
+ "originalName": "groupingservicefortest..ResourceInstanceGroup..0",
+ "isMissingData": false,
+ "trackById": "rgedfdged4",
+ "vnfGroupStoreKey": "groupingservicefortest..ResourceInstanceGroup..0",
+ "uuid": "daeb6568-cef8-417f-9075-ed259ce59f48",
+ "instanceName": "VNF_GROUP5_INSTANCE_NAME",
+ "modelInfo": {
+ "modelInvariantId": "4bb2e27e-ddab-4790-9c6d-1f731bc14a45",
+ "modelVersionId": "daeb6568-cef8-417f-9075-ed259ce59f48",
+ "modelName": "groupingservicefortest..ResourceInstanceGroup..0",
+ "modelVersion": "1",
+ "modelCustomizationName": "groupingservicefortest..ResourceInstanceGroup..0",
+ "uuid": "daeb6568-cef8-417f-9075-ed259ce59f48"
+ },
+ "instanceParams": [{}
+ ],
+ "vnfs":{}
+ }
+ },
+ "bulkSize": 1,
+ "instanceName": "SERVICE_INSTANCE_NAME",
+
+ "instanceId": "service-instance-id",
+ "orchStatus": "GARBAGE DATA",
+ "globalSubscriberId": "global-customer-id",
+ "subscriptionServiceType": "service-instance-type",
+ "owningEntityId": null,
+ "owningEntityName": null,
+ "productFamilyId": null,
+ "lcpCloudRegionId": null,
+ "tenantId": null,
+ "tenantName": null,
+ "aicZoneId": null,
+ "aicZoneName": null,
+ "projectName": null,
+ "rollbackOnFailure": false,
+ "isALaCarte": true,
+ "modelInfo": {
+ "modelInvariantId": "7ee41ce4-4827-44b0-a48e-2707a59905d2",
+ "modelVersionId": "4117a0b6-e234-467d-b5b9-fe2f68c8b0fc",
+ "modelName": "Grouping Service for Test",
+ "modelType": "service",
+ "modelVersion": "1.0"
+ },
+
+ "testApi": "VNF_API"
+}
diff --git a/vid-app-common/src/test/resources/payload_jsons/VnfGroupCreate3Delete1None1RequestResolvedForRetry.json b/vid-app-common/src/test/resources/payload_jsons/VnfGroupCreate3Delete1None1RequestResolvedForRetry.json
new file mode 100644
index 000000000..6196cd797
--- /dev/null
+++ b/vid-app-common/src/test/resources/payload_jsons/VnfGroupCreate3Delete1None1RequestResolvedForRetry.json
@@ -0,0 +1,176 @@
+{
+ "action": "None",
+ "isDirty": true,
+ "trackById":"aabbcc",
+ "vnfs": {},
+ "instanceParams": [],
+ "validationCounter": 0,
+ "existingNames": {
+ "service_instance_name": "",
+ "vnf_group3_instance_name": ""
+ },
+ "existingVNFCounterMap": {},
+ "existingVnfGroupCounterMap": {
+ "daeb6568-cef8-417f-9075-ed259ce59f48": 3
+ },
+ "existingNetworksCounterMap": {},
+ "networks": {},
+ "vnfGroups": {
+ "groupingservicefortest..ResourceInstanceGroup..0:001": {
+ "originalName": "groupingservicefortest..ResourceInstanceGroup..0",
+ "trackById": "groupingservicefortest..ResourceInstanceGroup..0:001",
+ "instanceName": "VNF_GROUP1_INSTANCE_NAME",
+ "lcpCloudRegionId": null,
+ "legacyRegion": null,
+ "lineOfBusiness": null,
+ "action": "None",
+ "statusMessage": "Vnf has been created successfully.",
+ "instanceId": "VNF_GROUP1_INSTANCE_ID",
+ "instanceType": "VNF_GROUP1_INSTANCE_TYPE",
+ "orchStatus": null,
+ "platformName": null,
+ "productFamilyId": null,
+ "provStatus": null,
+ "tenantId": null,
+ "inMaint": false,
+ "modelInfo": {
+ "modelType": "instanceGroup",
+ "modelCustomizationName": "groupingservicefortest..ResourceInstanceGroup..0",
+ "modelInvariantId": "4bb2e27e-ddab-4790-9c6d-1f731bc14a45",
+ "modelVersionId": "daeb6568-cef8-417f-9075-ed259ce59f48"
+ },
+ "uuid": "daeb6568-cef8-417f-9075-ed259ce59f48",
+ "instanceGroupRole": "VNF_GROUP1_INSTANCE_ROLE",
+ "instanceGroupFunction": "vTSBC Customer Landing Network Collection",
+ "vnfs":{}
+ },
+ "groupingservicefortest..ResourceInstanceGroup..0:002": {
+ "originalName": "groupingservicefortest..ResourceInstanceGroup..0",
+ "trackById": "groupingservicefortest..ResourceInstanceGroup..0:002",
+ "instanceName": "VNF_GROUP2_INSTANCE_NAME",
+ "lcpCloudRegionId": null,
+ "legacyRegion": null,
+ "lineOfBusiness": null,
+ "action": "None",
+ "instanceId": "VNF_GROUP2_INSTANCE_ID",
+ "instanceType": "VNF_GROUP2_INSTANCE_TYPE",
+ "orchStatus": null,
+ "platformName": null,
+ "productFamilyId": null,
+ "provStatus": null,
+ "inMaint": false,
+ "modelInfo": {
+ "modelType": "instanceGroup",
+ "modelCustomizationName": "groupingservicefortest..ResourceInstanceGroup..0",
+ "modelInvariantId": "4bb2e27e-ddab-4790-9c6d-1f731bc14a45",
+ "modelVersionId": "daeb6568-cef8-417f-9075-ed259ce59f48"
+ },
+ "uuid": "daeb6568-cef8-417f-9075-ed259ce59f48",
+ "tenantId": null,
+ "instanceGroupRole": "VNF_GROUP2_INSTANCE_ROLE",
+ "instanceGroupFunction": "vTSBC Customer Landing Network Collection",
+ "vnfs": {}
+ },
+ "groupingservicefortest..ResourceInstanceGroup..0": {
+ "action": "Create",
+ "inMaint": false,
+ "rollbackOnFailure": "true",
+ "originalName": "groupingservicefortest..ResourceInstanceGroup..0",
+ "isMissingData": false,
+ "trackById": "ag5aav86u4j",
+ "vnfGroupStoreKey": "groupingservicefortest..ResourceInstanceGroup..0",
+ "uuid": "daeb6568-cef8-417f-9075-ed259ce59f48",
+ "instanceName": "VNF_GROUP3_INSTANCE_NAME",
+ "isFailed": true,
+ "statusMessage": "Vnf has been created successfully.",
+ "modelInfo": {
+ "modelInvariantId": "4bb2e27e-ddab-4790-9c6d-1f731bc14a45",
+ "modelVersionId": "daeb6568-cef8-417f-9075-ed259ce59f48",
+ "modelName": "groupingservicefortest..ResourceInstanceGroup..0",
+ "modelVersion": "1",
+ "modelCustomizationName": "groupingservicefortest..ResourceInstanceGroup..0",
+ "uuid": "daeb6568-cef8-417f-9075-ed259ce59f48"
+ },
+ "instanceParams": [{}
+ ],
+ "vnfs":{}
+ },
+ "groupingservicefortest..ResourceInstanceGroup..0:003": {
+ "action": "None",
+ "isFailed": false,
+ "instanceId": "VNF_GROUP1_INSTANCE_ID_3",
+ "statusMessage": "Vnf has been created successfully.",
+ "inMaint": false,
+ "rollbackOnFailure": "true",
+ "originalName": "groupingservicefortest..ResourceInstanceGroup..0",
+ "isMissingData": false,
+ "trackById": "asedrftjko",
+ "vnfGroupStoreKey": "groupingservicefortest..ResourceInstanceGroup..0",
+ "uuid": "daeb6568-cef8-417f-9075-ed259ce59f48",
+ "instanceName": "VNF_GROUP4_INSTANCE_NAME",
+ "modelInfo": {
+ "modelInvariantId": "4bb2e27e-ddab-4790-9c6d-1f731bc14a45",
+ "modelVersionId": "daeb6568-cef8-417f-9075-ed259ce59f48",
+ "modelName": "groupingservicefortest..ResourceInstanceGroup..0",
+ "modelVersion": "1",
+ "modelCustomizationName": "groupingservicefortest..ResourceInstanceGroup..0",
+ "uuid": "daeb6568-cef8-417f-9075-ed259ce59f48"
+ },
+ "instanceParams": [{}
+ ],
+ "vnfs":{}
+ },
+ "groupingservicefortest..ResourceInstanceGroup..0:004": {
+ "action": "None",
+ "isFailed": false,
+ "statusMessage": "Vnf has been created successfully.",
+ "instanceId": "VNF_GROUP1_INSTANCE_ID_4",
+ "inMaint": false,
+ "rollbackOnFailure": "true",
+ "originalName": "groupingservicefortest..ResourceInstanceGroup..0",
+ "isMissingData": false,
+ "trackById": "rgedfdged4",
+ "vnfGroupStoreKey": "groupingservicefortest..ResourceInstanceGroup..0",
+ "uuid": "daeb6568-cef8-417f-9075-ed259ce59f48",
+ "instanceName": "VNF_GROUP5_INSTANCE_NAME",
+ "modelInfo": {
+ "modelInvariantId": "4bb2e27e-ddab-4790-9c6d-1f731bc14a45",
+ "modelVersionId": "daeb6568-cef8-417f-9075-ed259ce59f48",
+ "modelName": "groupingservicefortest..ResourceInstanceGroup..0",
+ "modelVersion": "1",
+ "modelCustomizationName": "groupingservicefortest..ResourceInstanceGroup..0",
+ "uuid": "daeb6568-cef8-417f-9075-ed259ce59f48"
+ },
+ "instanceParams": [{}
+ ],
+ "vnfs":{}
+ }
+ },
+ "bulkSize": 1,
+ "instanceName": "SERVICE_INSTANCE_NAME",
+
+ "instanceId": "service-instance-id",
+ "orchStatus": "GARBAGE DATA",
+ "globalSubscriberId": "global-customer-id",
+ "subscriptionServiceType": "service-instance-type",
+ "owningEntityId": null,
+ "owningEntityName": null,
+ "productFamilyId": null,
+ "lcpCloudRegionId": null,
+ "tenantId": null,
+ "tenantName": null,
+ "aicZoneId": null,
+ "aicZoneName": null,
+ "projectName": null,
+ "rollbackOnFailure": false,
+ "isALaCarte": true,
+ "modelInfo": {
+ "modelInvariantId": "7ee41ce4-4827-44b0-a48e-2707a59905d2",
+ "modelVersionId": "4117a0b6-e234-467d-b5b9-fe2f68c8b0fc",
+ "modelName": "Grouping Service for Test",
+ "modelType": "service",
+ "modelVersion": "1.0"
+ },
+
+ "testApi": "VNF_API"
+}
diff --git a/vid-app-common/src/test/resources/payload_jsons/bulk_alacarte_service_request.json b/vid-app-common/src/test/resources/payload_jsons/bulk_alacarte_service_request.json
index 955685268..4e3fc1021 100644
--- a/vid-app-common/src/test/resources/payload_jsons/bulk_alacarte_service_request.json
+++ b/vid-app-common/src/test/resources/payload_jsons/bulk_alacarte_service_request.json
@@ -9,7 +9,7 @@
},
"owningEntity": {
"owningEntityId": "038d99af-0427-42c2-9d15-971b99b9b489",
- "owningEntityName": "PACKET CORE"
+ "owningEntityName": "JULIO ERICKSON"
},
"project": {
"projectName": "{some project name}"
diff --git a/vid-app-common/src/test/resources/payload_jsons/bulk_alacarte_service_request_naming_false.json b/vid-app-common/src/test/resources/payload_jsons/bulk_alacarte_service_request_naming_false.json
index be697ed88..5b1fdc1bd 100644
--- a/vid-app-common/src/test/resources/payload_jsons/bulk_alacarte_service_request_naming_false.json
+++ b/vid-app-common/src/test/resources/payload_jsons/bulk_alacarte_service_request_naming_false.json
@@ -9,7 +9,7 @@
},
"owningEntity": {
"owningEntityId": "038d99af-0427-42c2-9d15-971b99b9b489",
- "owningEntityName": "PACKET CORE"
+ "owningEntityName": "JULIO ERICKSON"
},
"subscriberInfo": {
"globalSubscriberId": "{some subscriber id}"
diff --git a/vid-app-common/src/test/resources/payload_jsons/bulk_macro_service_request.json b/vid-app-common/src/test/resources/payload_jsons/bulk_macro_service_request.json
index 917900c22..c0315d015 100644
--- a/vid-app-common/src/test/resources/payload_jsons/bulk_macro_service_request.json
+++ b/vid-app-common/src/test/resources/payload_jsons/bulk_macro_service_request.json
@@ -9,7 +9,7 @@
},
"owningEntity": {
"owningEntityId": "038d99af-0427-42c2-9d15-971b99b9b489",
- "owningEntityName": "PACKET CORE"
+ "owningEntityName": "JULIO ERICKSON"
},
"project": {
"projectName": "{some project name}"
@@ -51,7 +51,7 @@
},
"cloudConfiguration": {
"lcpCloudRegionId": "mdt1",
- "cloudOwner": "att-aic",
+ "cloudOwner": "irma-aic",
"tenantId": "88a6ca3ee0394ade9403f075db23167e"
},
"platform": {
diff --git a/vid-app-common/src/test/resources/payload_jsons/bulk_service_request_ecomp_naming.json b/vid-app-common/src/test/resources/payload_jsons/bulk_service_request_ecomp_naming.json
index 55765a86b..dd343f46e 100644
--- a/vid-app-common/src/test/resources/payload_jsons/bulk_service_request_ecomp_naming.json
+++ b/vid-app-common/src/test/resources/payload_jsons/bulk_service_request_ecomp_naming.json
@@ -9,7 +9,7 @@
},
"owningEntity": {
"owningEntityId": "038d99af-0427-42c2-9d15-971b99b9b489",
- "owningEntityName": "PACKET CORE"
+ "owningEntityName": "JULIO ERICKSON"
},
"project": {
"projectName": "{some project name}"
@@ -48,7 +48,7 @@
},
"cloudConfiguration": {
"lcpCloudRegionId": "mdt1",
- "cloudOwner": "att-aic",
+ "cloudOwner": "irma-aic",
"tenantId": "88a6ca3ee0394ade9403f075db23167e"
},
"platform": {
diff --git a/vid-app-common/src/test/resources/payload_jsons/bulk_service_request_no_vfmodule_ecomp_naming.json b/vid-app-common/src/test/resources/payload_jsons/bulk_service_request_no_vfmodule_ecomp_naming.json
index fdc81511c..0ef15d790 100644
--- a/vid-app-common/src/test/resources/payload_jsons/bulk_service_request_no_vfmodule_ecomp_naming.json
+++ b/vid-app-common/src/test/resources/payload_jsons/bulk_service_request_no_vfmodule_ecomp_naming.json
@@ -9,7 +9,7 @@
},
"owningEntity": {
"owningEntityId": "038d99af-0427-42c2-9d15-971b99b9b489",
- "owningEntityName": "PACKET CORE"
+ "owningEntityName": "JULIO ERICKSON"
},
"project": {
"projectName": "{some project name}"
@@ -48,7 +48,7 @@
},
"cloudConfiguration": {
"lcpCloudRegionId": "mdt1",
- "cloudOwner": "att-aic",
+ "cloudOwner": "irma-aic",
"tenantId": "88a6ca3ee0394ade9403f075db23167e"
},
"platform": {
diff --git a/vid-app-common/src/test/resources/payload_jsons/bulk_service_request_unique_names.json b/vid-app-common/src/test/resources/payload_jsons/bulk_service_request_unique_names.json
index 643c1043a..c4f40a9c0 100644
--- a/vid-app-common/src/test/resources/payload_jsons/bulk_service_request_unique_names.json
+++ b/vid-app-common/src/test/resources/payload_jsons/bulk_service_request_unique_names.json
@@ -9,7 +9,7 @@
},
"owningEntity": {
"owningEntityId": "038d99af-0427-42c2-9d15-971b99b9b489",
- "owningEntityName": "PACKET CORE"
+ "owningEntityName": "JULIO ERICKSON"
},
"project": {
"projectName": "{some project name}"
@@ -50,7 +50,7 @@
},
"cloudConfiguration": {
"lcpCloudRegionId": "mdt1",
- "cloudOwner": "att-aic",
+ "cloudOwner": "irma-aic",
"tenantId": "88a6ca3ee0394ade9403f075db23167e"
},
"platform": {
diff --git a/vid-app-common/src/test/resources/payload_jsons/bulk_vnf_request.json b/vid-app-common/src/test/resources/payload_jsons/bulk_vnf_request.json
index d7b6d8629..5aa0211d1 100644
--- a/vid-app-common/src/test/resources/payload_jsons/bulk_vnf_request.json
+++ b/vid-app-common/src/test/resources/payload_jsons/bulk_vnf_request.json
@@ -12,7 +12,7 @@
"cloudConfiguration": {
"lcpCloudRegionId": "mdt1",
"tenantId": "88a6ca3ee0394ade9403f075db23167e",
- "cloudOwner" : "att-aic"
+ "cloudOwner" : "irma-aic"
},
"requestInfo": {
"instanceName": "vmxnjr001_001",
diff --git a/vid-app-common/src/test/resources/payload_jsons/bulk_vnf_request_without_instance_name.json b/vid-app-common/src/test/resources/payload_jsons/bulk_vnf_request_without_instance_name.json
index 9921de59b..7322d8589 100644
--- a/vid-app-common/src/test/resources/payload_jsons/bulk_vnf_request_without_instance_name.json
+++ b/vid-app-common/src/test/resources/payload_jsons/bulk_vnf_request_without_instance_name.json
@@ -12,7 +12,7 @@
"cloudConfiguration": {
"lcpCloudRegionId": "mdt1",
"tenantId": "88a6ca3ee0394ade9403f075db23167e",
- "cloudOwner": "att-aic"
+ "cloudOwner": "irma-aic"
},
"requestInfo": {
"productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
diff --git a/vid-app-common/src/test/resources/payload_jsons/instance_group_instantiation_request.json b/vid-app-common/src/test/resources/payload_jsons/instance_group_instantiation_request.json
index 7072d3213..70e8f04ff 100644
--- a/vid-app-common/src/test/resources/payload_jsons/instance_group_instantiation_request.json
+++ b/vid-app-common/src/test/resources/payload_jsons/instance_group_instantiation_request.json
@@ -10,7 +10,7 @@
"modelCustomizationId": "ab153b6e-c364-44c0-bef6-1f2982117f04"
},
"requestInfo": {
- "instanceName": "VNF_GROUP_NAME_001",
+ "instanceName": "VNF_GROUP_NAME",
"source": "VID",
"suppressRollback": true,
"requestorId": "az2018"
@@ -30,7 +30,8 @@
}
],
"requestParameters": {
- "userParams": []
+ "userParams": [],
+ "testApi" : "VNF_API"
}
}
} \ No newline at end of file
diff --git a/vid-app-common/src/test/resources/payload_jsons/mso_request_create_configuration.json b/vid-app-common/src/test/resources/payload_jsons/mso_request_create_configuration.json
index e0942bae2..c4849f047 100644
--- a/vid-app-common/src/test/resources/payload_jsons/mso_request_create_configuration.json
+++ b/vid-app-common/src/test/resources/payload_jsons/mso_request_create_configuration.json
@@ -39,7 +39,7 @@
"modelType": "vnf",
"modelInvariantId": "a7eac2b3-8444-40ee-92e3-b3359b32445c",
"modelVersionId": "2a2ea15f-07c6-4b89-bfca-e8aba39a34d6",
- "modelName": "vmmeService2",
+ "modelName": "vflorenceService2",
"modelVersion": "1.0",
"modelCustomizationId": "060be63d-5f9c-4fd0-8ef7-830d5e8eca17"
}
diff --git a/vid-app-common/src/test/resources/payload_jsons/mso_service_instantiation.json b/vid-app-common/src/test/resources/payload_jsons/mso_service_instantiation.json
index 537b8d60c..926c435dc 100644
--- a/vid-app-common/src/test/resources/payload_jsons/mso_service_instantiation.json
+++ b/vid-app-common/src/test/resources/payload_jsons/mso_service_instantiation.json
@@ -13,7 +13,7 @@
},
"owningEntity": {
"owningEntityId": "038d99af-0427-42c2-9d15-971b99b9b489",
- "owningEntityName": "PACKET CORE"
+ "owningEntityName": "JULIO ERICKSON"
},
"project": {
"projectName": "TODO"
@@ -49,7 +49,7 @@
"modelVersion":"10.0"
},
"owningEntityId":"038d99af-0427-42c2-9d15-971b99b9b489",
- "owningEntityName":"PACKET CORE",
+ "owningEntityName":"JULIO ERICKSON",
"projectName":"{some project name}",
"globalSubscriberId":"{some subscriber id}",
"productFamilyId":"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
diff --git a/vid-app-common/src/test/resources/payload_jsons/networkDelete1Create1Request.json b/vid-app-common/src/test/resources/payload_jsons/networkDelete1Create1Request.json
new file mode 100644
index 000000000..cc35dcac7
--- /dev/null
+++ b/vid-app-common/src/test/resources/payload_jsons/networkDelete1Create1Request.json
@@ -0,0 +1,117 @@
+{
+ "action":"None",
+ "isDirty":true,
+ "vnfs":{
+
+ },
+ "instanceParams":[
+ {
+ "2017488_pasqualevpe0_ASN":"AV_vPE"
+ }
+ ],
+ "validationCounter":0,
+ "existingNames":{
+ "123":"",
+ "instancename":"",
+ "yoav":""
+ },
+ "existingVNFCounterMap":{
+
+ },
+ "existingVnfGroupCounterMap":{
+
+ },
+ "existingNetworksCounterMap":{
+ "94fdd893-4a36-4d70-b16a-ec29c54c184f":1
+ },
+ "networks":{
+ "ExtVL 0":{
+ "rollbackOnFailure":"false",
+ "productFamilyId":"36b4733a-53f4-4cc8-8ff0-9172e5fc4b8e",
+ "lcpCloudRegionId":"hvf6",
+ "tenantId":"229bcdc6eaeb4ca59d55221141d01f8e",
+ "lineOfBusiness":"zzz1",
+ "platformName":"platform",
+ "originalName":"ExtVL 0",
+ "modelInfo":{
+ "modelInvariantId":"379f816b-a7aa-422f-be30-17114ff50b7c",
+ "modelVersionId":"ddc3f20c-08b5-40fd-af72-c6d14636b986",
+ "modelName":"ExtVL",
+ "modelVersion":"37.0",
+ "modelType":"network",
+ "modelCustomizationId":"94fdd893-4a36-4d70-b16a-ec29c54c184f",
+ "modelCustomizationName":"ExtVL 0"
+ },
+ "instanceName":"ExtVL 0",
+ "instanceId":"NETWORK_INSTANCE_ID",
+ "action":"None_Delete"
+ },
+ "ExtVL 0_1":{
+ "action":"Create",
+ "inMaint":false,
+ "rollbackOnFailure":"true",
+ "originalName":"ExtVL 0",
+ "isMissingData":false,
+ "trackById":"r21vcx0szoc",
+ "networkStoreKey":"ExtVL 0_1",
+ "instanceName":"ExtVL",
+ "productFamilyId":"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "lcpCloudRegionId":"hvf6",
+ "tenantId":"229bcdc6eaeb4ca59d55221141d01f8e",
+ "platformName":"xxx1",
+ "lineOfBusiness":"zzz1",
+ "instanceParams":[
+ {
+
+ }
+ ],
+ "modelInfo":{
+ "modelInvariantId":"379f816b-a7aa-422f-be30-17114ff50b7c",
+ "modelVersionId":"ddc3f20c-08b5-40fd-af72-c6d14636b986",
+ "modelName":"ExtVL",
+ "modelVersion":"37.0",
+ "modelCustomizationId":"94fdd893-4a36-4d70-b16a-ec29c54c184f",
+ "modelCustomizationName":"ExtVL 0",
+ "uuid":"ddc3f20c-08b5-40fd-af72-c6d14636b986",
+ "modelUniqueId":"94fdd893-4a36-4d70-b16a-ec29c54c184f"
+ },
+ "uuid":"ddc3f20c-08b5-40fd-af72-c6d14636b986"
+ }
+ },
+ "vnfGroups":{
+
+ },
+ "bulkSize":1,
+ "instanceName":"InstanceName",
+ "globalSubscriberId":"e433710f-9217-458d-a79d-1c7aff376d89",
+ "subscriptionServiceType":"TYLER SILVIA",
+ "owningEntityId":"d61e6f2d-12fa-4cc2-91df-7c244011d6fc",
+ "productFamilyId":"17cc1042-527b-11e6-beb8-9e71128cae77",
+ "lcpCloudRegionId":"AAIAIC25",
+ "tenantId":"092eb9e8e4b7412e8787dd091bc58e86",
+ "aicZoneId":"JAG1",
+ "projectName":"WATKINS",
+ "rollbackOnFailure":true,
+ "aicZoneName":"YUDFJULP-JAG1",
+ "owningEntityName":"WayneHolland",
+ "testApi":"GR_API",
+ "tenantName":"USP-SIP-IC-24335-T-01",
+ "modelInfo":{
+ "modelInvariantId":"e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0",
+ "modelVersionId":"6b528779-44a3-4472-bdff-9cd15ec93450",
+ "modelName":"action-data",
+ "modelVersion":"1.0",
+ "uuid":"6b528779-44a3-4472-bdff-9cd15ec93450"
+ },
+ "isALaCarte":true,
+ "name":"action-data",
+ "version":"1.0",
+ "description":"",
+ "category":"",
+ "uuid":"6b528779-44a3-4472-bdff-9cd15ec93450",
+ "invariantUuid":"e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0",
+ "serviceType":"",
+ "serviceRole":"",
+ "isMultiStepDesign":false,
+ "instanceId":"f8791436-8d55-4fde-b4d5-72dd2cf13cfb"
+} \ No newline at end of file
diff --git a/vid-app-common/src/test/resources/payload_jsons/network_instantiation_request.json b/vid-app-common/src/test/resources/payload_jsons/network_instantiation_request.json
index 5a722ac4c..241ee07a9 100644
--- a/vid-app-common/src/test/resources/payload_jsons/network_instantiation_request.json
+++ b/vid-app-common/src/test/resources/payload_jsons/network_instantiation_request.json
@@ -12,10 +12,10 @@
"cloudConfiguration": {
"lcpCloudRegionId": "mdt1",
"tenantId": "88a6ca3ee0394ade9403f075db23167e",
- "cloudOwner" : "att-aic"
+ "cloudOwner" : "irma-aic"
},
"requestInfo": {
- "instanceName": "vmxnjr001_001",
+ "instanceName": "vmxnjr001",
"productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
"source": "VID",
"suppressRollback": true,
@@ -42,7 +42,8 @@
}
],
"requestParameters": {
- "userParams": []
+ "userParams": [],
+ "testApi" : "VNF_API"
}
}
} \ No newline at end of file
diff --git a/vid-app-common/src/test/resources/payload_jsons/network_instantiation_request_without_instance_name.json b/vid-app-common/src/test/resources/payload_jsons/network_instantiation_request_without_instance_name.json
index db55736c4..8b69e0beb 100644
--- a/vid-app-common/src/test/resources/payload_jsons/network_instantiation_request_without_instance_name.json
+++ b/vid-app-common/src/test/resources/payload_jsons/network_instantiation_request_without_instance_name.json
@@ -12,7 +12,7 @@
"cloudConfiguration": {
"lcpCloudRegionId": "mdt1",
"tenantId": "88a6ca3ee0394ade9403f075db23167e",
- "cloudOwner" : "att-aic"
+ "cloudOwner" : "irma-aic"
},
"requestInfo": {
"productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
@@ -41,7 +41,8 @@
}
],
"requestParameters": {
- "userParams": []
+ "userParams": [],
+ "testApi" : "VNF_API"
}
}
} \ No newline at end of file
diff --git a/vid-app-common/src/test/resources/payload_jsons/pre_1806_macro_service_instantiation_request.json b/vid-app-common/src/test/resources/payload_jsons/pre_1806_macro_service_instantiation_request.json
new file mode 100644
index 000000000..992323023
--- /dev/null
+++ b/vid-app-common/src/test/resources/payload_jsons/pre_1806_macro_service_instantiation_request.json
@@ -0,0 +1,47 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "service",
+ "modelInvariantId": "ff3514e3-5a33-55df-13ab-12abad84e7ff",
+ "modelVersionId": "fe6985cd-ea33-3346-ac12-ab121484a3fe",
+ "modelName": "sriov",
+ "modelVersion": "1.0"
+ },
+ "cloudConfiguration": {
+ "cloudOwner": "irma-aic",
+ "lcpCloudRegionId": "mdt1",
+ "tenantId": "88a6ca3ee0394ade9403f075db23167e"
+ },
+ "owningEntity": {
+ "owningEntityId": "038d99af-0427-42c2-9d15-971b99b9b489",
+ "owningEntityName": "JULIO ERICKSON"
+ },
+ "project": {
+ "projectName": "some_project_name"
+ },
+ "subscriberInfo": {
+ "globalSubscriberId": "some_subscriber_id",
+ "subscriberName": "some_subscriber_name"
+ },
+ "requestInfo": {
+ "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "source": "VID",
+ "suppressRollback": true,
+ "requestorId": "az2016"
+ },
+ "requestParameters": {
+ "subscriptionServiceType": "MOG",
+ "aLaCarte": false,
+ "userParams": [
+ {
+ "name": "someUserParam",
+ "value": "someValue"
+ },
+ {
+ "name": "anotherUserParam",
+ "value": "anotherValue"
+ }
+ ]
+ }
+ }
+} \ No newline at end of file
diff --git a/vid-app-common/src/test/resources/payload_jsons/pre_1806_macro_without_cloudConfiguration.json b/vid-app-common/src/test/resources/payload_jsons/pre_1806_macro_without_cloudConfiguration.json
new file mode 100644
index 000000000..472ccc90e
--- /dev/null
+++ b/vid-app-common/src/test/resources/payload_jsons/pre_1806_macro_without_cloudConfiguration.json
@@ -0,0 +1,42 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "service",
+ "modelInvariantId": "ff3514e3-5a33-55df-13ab-12abad84e7ff",
+ "modelVersionId": "fe6985cd-ea33-3346-ac12-ab121484a3fe",
+ "modelName": "sriov",
+ "modelVersion": "1.0"
+ },
+ "owningEntity": {
+ "owningEntityId": "038d99af-0427-42c2-9d15-971b99b9b489",
+ "owningEntityName": "JULIO ERICKSON"
+ },
+ "project": {
+ "projectName": "some_project_name"
+ },
+ "subscriberInfo": {
+ "globalSubscriberId": "some_subscriber_id",
+ "subscriberName": "some_subscriber_name"
+ },
+ "requestInfo": {
+ "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "source": "VID",
+ "suppressRollback": true,
+ "requestorId": "az2016"
+ },
+ "requestParameters": {
+ "subscriptionServiceType": "MOG",
+ "aLaCarte": false,
+ "userParams": [
+ {
+ "name": "someUserParam",
+ "value": "someValue"
+ },
+ {
+ "name": "anotherUserParam",
+ "value": "anotherValue"
+ }
+ ]
+ }
+ }
+} \ No newline at end of file
diff --git a/vid-app-common/src/test/resources/payload_jsons/resume/feRequestResumeMacroService.json b/vid-app-common/src/test/resources/payload_jsons/resume/feRequestResumeMacroService.json
new file mode 100644
index 000000000..c2c84dc9c
--- /dev/null
+++ b/vid-app-common/src/test/resources/payload_jsons/resume/feRequestResumeMacroService.json
@@ -0,0 +1,107 @@
+{
+ "isDirty": false,
+ "instanceParams": [],
+ "existingNames": {
+ "ncmvlansvcym161f_77": ""
+ },
+ "vidNotions": {
+ "instantiationType": "Macro",
+ "instantiationUI": "serviceWithCollectionResource",
+ "modelCategory": "other",
+ "viewEditUI": "serviceWithCollectionResource"
+ },
+ "bulkSize": 1,
+ "action": "Resume",
+ "instanceName": "NcmVlanSvcYm161f_77",
+ "instanceId": "a565e6ad-75d1-4493-98f1-33234b5c17e2",
+ "orchStatus": "Assigned",
+ "productFamilyId": null,
+ "lcpCloudRegionId": null,
+ "tenantId": null,
+ "cloudOwner": null,
+ "modelInfo": {
+ "modelInvariantId": "f6342be5-d66b-4d03-a1aa-c82c3094c4ea",
+ "modelVersionId": "6e0bec91-09f3-43aa-9cf3-e617cd0146be",
+ "modelName": "NCM_VLAN_SVC_ym161f",
+ "modelType": "service",
+ "modelVersion": "8.0"
+ },
+ "globalSubscriberId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "subscriptionServiceType": "Emanuel",
+ "owningEntityId": null,
+ "owningEntityName": null,
+ "tenantName": null,
+ "aicZoneId": null,
+ "aicZoneName": null,
+ "projectName": null,
+ "rollbackOnFailure": false,
+ "isALaCarte": false,
+ "vnfs": {},
+ "vrfs": {},
+ "networks": {},
+ "vnfGroups": {},
+ "validationCounter": 0,
+ "existingVNFCounterMap": {},
+ "existingVRFCounterMap": {},
+ "existingNetworksCounterMap": {},
+ "existingVnfGroupCounterMap": {},
+ "collectionResources": {
+ "84a351ae-3601-45e2-98df-878d6c816abc": {
+ "action": "None",
+ "instanceName": "NcmVlanSvcYm161f_77_vTSBC Customer Landing Network Collection",
+ "instanceId": "84a351ae-3601-45e2-98df-878d6c816abc",
+ "orchStatus": "Active",
+ "productFamilyId": null,
+ "lcpCloudRegionId": null,
+ "tenantId": null,
+ "cloudOwner": null,
+ "modelInfo": {
+ "modelInvariantId": "081ceb56-eb71-4566-a72d-3e7cbee5cdf1",
+ "modelVersionId": "ce8c98bc-4691-44fb-8ff0-7a47487c11c4",
+ "modelName": "NCM_VLAN_ym161f",
+ "modelType": "collection",
+ "modelVersion": "5.0"
+ },
+ "instanceType": null,
+ "provStatus": null,
+ "inMaint": false,
+ "uuid": "ce8c98bc-4691-44fb-8ff0-7a47487c11c4",
+ "originalName": "NCM_VLAN_ym161f 0",
+ "legacyRegion": null,
+ "lineOfBusiness": null,
+ "platformName": null,
+ "trackById": "84a351ae-3601-45e2-98df-878d6c816abc",
+ "ncfs": {
+ "6b3536cf-3a12-457f-abb5-fa2203e0d923": {
+ "action": "None",
+ "instanceName": "NcmVlanSvcYm161f_77_vTSBC Customer Landing Network Collection",
+ "instanceId": "6b3536cf-3a12-457f-abb5-fa2203e0d923",
+ "orchStatus": null,
+ "productFamilyId": null,
+ "lcpCloudRegionId": null,
+ "tenantId": null,
+ "cloudOwner": null,
+ "modelInfo": {
+ "modelInvariantId": "868b109c-9481-4a18-891b-af974db7705a",
+ "modelVersionId": "dd182d7d-6949-4b90-b3cc-5befe400742e",
+ "modelName": "ncm_vlan_ym161f..NetworkCollection..0",
+ "modelType": "instanceGroup",
+ "modelVersion": "1"
+ },
+ "instanceType": "L3-NETWORK",
+ "provStatus": null,
+ "inMaint": false,
+ "uuid": "dd182d7d-6949-4b90-b3cc-5befe400742e",
+ "originalName": "ncm_vlan_ym161f..NetworkCollection..0",
+ "legacyRegion": null,
+ "lineOfBusiness": null,
+ "platformName": null,
+ "trackById": "6b3536cf-3a12-457f-abb5-fa2203e0d923",
+ "instanceGroupRole": "SUB_INTERFACE",
+ "instanceGroupFunction": "vTSBC Customer Landing Network Collection",
+ "numberOfNetworks": 1
+ }
+ }
+ }
+ }
+}
diff --git a/vid-app-common/src/test/resources/payload_jsons/resume/msoResponseGetRequestsOfServiceInstance.json b/vid-app-common/src/test/resources/payload_jsons/resume/msoResponseGetRequestsOfServiceInstance.json
new file mode 100644
index 000000000..cb49dd8da
--- /dev/null
+++ b/vid-app-common/src/test/resources/payload_jsons/resume/msoResponseGetRequestsOfServiceInstance.json
@@ -0,0 +1,62 @@
+{
+ "requestList": [
+ {
+ "request": {
+ "requestId": "894089b8-f7f4-418d-81da-34186fd32670",
+ "startTime": "Wed, 10 Oct 2018 08:01:21 GMT",
+ "finishTime": "Wed, 10 Oct 2018 08:01:43 GMT",
+ "requestScope": "service",
+ "requestType": "createInstance",
+ "requestDetails": {
+ "modelInfo": {
+ "modelInvariantId": "f6342be5-d66b-4d03-a1aa-c82c3094c4ea",
+ "modelType": "service",
+ "modelName": "NCM_VLAN_SVC_ym161f",
+ "modelVersion": "8.0",
+ "modelVersionId": "6e0bec91-09f3-43aa-9cf3-e617cd0146be",
+ "modelUuid": "6e0bec91-09f3-43aa-9cf3-e617cd0146be",
+ "modelInvariantUuid": "f6342be5-d66b-4d03-a1aa-c82c3094c4ea"
+ },
+ "requestInfo": {
+ "productFamilyId": "db171b8f-115c-4992-a2e3-ee04cae357e0",
+ "source": "VID",
+ "suppressRollback": false,
+ "requestorId": "cs0554"
+ },
+ "subscriberInfo": {
+ "globalSubscriberId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb"
+ },
+ "cloudConfiguration": {
+ "tenantId": "d3b49834f7164cbe831bfbfa35ef649b",
+ "cloudOwner": "irma-aic",
+ "lcpCloudRegionId": "Two"
+ },
+ "requestParameters": {
+ "subscriptionServiceType": "Emanuel",
+ "userParams": [
+ {
+ "name": "aic_zone",
+ "value": "TTL58"
+ }
+ ],
+ "aLaCarte": false
+ },
+ "owningEntity": {
+ "owningEntityId": "e4257a94-21cc-40c5-adc9-e6f4ff868e31",
+ "owningEntityName": "EMANUEL-CORE"
+ }
+ },
+ "instanceReferences": {
+ "serviceInstanceId": "a565e6ad-75d1-4493-98f1-33234b5c17e2",
+ "requestorId": "cs0554"
+ },
+ "requestStatus": {
+ "requestState": "FAILED",
+ "statusMessage": "STATUS: Macro-Service-createInstance request was executed correctly.",
+ "percentProgress": 100,
+ "timestamp": "Wed, 10 Oct 2018 08:01:43 GMT"
+ }
+ }
+ }
+ ]
+}
diff --git a/vid-app-common/src/test/resources/payload_jsons/vfModuleDelete1Create1None1Request.json b/vid-app-common/src/test/resources/payload_jsons/vfModuleDelete1Create1None1Request.json
new file mode 100644
index 000000000..642c2aac9
--- /dev/null
+++ b/vid-app-common/src/test/resources/payload_jsons/vfModuleDelete1Create1None1Request.json
@@ -0,0 +1,139 @@
+{
+ "action": "None",
+ "isDirty": true,
+ "vnfs": {
+ "2017-488_PASQUALE-vPE 0": {
+ "vfModules": {
+ "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0": {
+ "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0uvfot": {
+ "instanceName": "VFinstancenameZERO",
+ "instanceId": "VF_MODULE_INSTANCE_ID",
+ "action": "Create",
+ "lcpCloudRegionId": "AAIAIC25",
+ "tenantId": "092eb9e8e4b7412e8787dd091bc58e86",
+ "modelInfo": {
+ "modelInvariantId": "b34833bb-6aa9-4ad6-a831-70b06367a091",
+ "modelVersionId": "f8360508-3f17-4414-a2ed-6bc71161e8db",
+ "modelName": "2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0",
+ "modelVersion": "5",
+ "modelCustomizationId": "a55961b2-2065-4ab0-a5b7-2fcee1c227e3",
+ "modelCustomizationName": "2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0",
+ "uuid": "f8360508-3f17-4414-a2ed-6bc71161e8db"
+ },
+ "uuid": "f8360508-3f17-4414-a2ed-6bc71161e8db",
+ "provStatus": "Prov Status",
+ "orchStatus": "Active",
+ "inMaint": true
+ }
+ },
+ "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vRE_BV..module-1": {
+ "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vRE_BV..module-1fshmc": {
+ "instanceName": "VFinstancename",
+ "instanceId": "VF_MODULE_INSTANCE_ID",
+ "action": "None_Delete",
+ "volumeGroupName": "VFinstancename_vol_abc",
+ "orchStatus": "Create",
+ "provStatus": "Prov Status",
+ "inMaint": false,
+ "lcpCloudRegionId": "AAIAIC25",
+ "tenantId": "092eb9e8e4b7412e8787dd091bc58e86",
+ "modelInfo": {
+ "modelInvariantId": "7253ff5c-97f0-4b8b-937c-77aeb4d79aa1",
+ "modelVersionId": "25284168-24bb-4698-8cb4-3f509146eca5",
+ "modelName": "2017488PasqualeVpe..PASQUALE_vRE_BV..module-1",
+ "modelVersion": "6",
+ "modelCustomizationId": "f7e7c365-60cf-49a9-9ebf-a1aa11b9d401",
+ "modelCustomizationName": "2017488PasqualeVpe..PASQUALE_vRE_BV..module-1",
+ "uuid": "25284168-24bb-4698-8cb4-3f509146eca5"
+ },
+ "uuid": "25284168-24bb-4698-8cb4-3f509146eca5"
+ }
+ },
+ "2017588_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vRE_BV..module-2": {
+ "2017588_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vRE_BV..module-2frgth": {
+ "instanceName": "VFinstancename",
+ "instanceId": "VF_MODULE_INSTANCE_ID1",
+ "action": "None",
+ "volumeGroupName": "VFinstancename_vol_abc",
+ "orchStatus": "Create",
+ "provStatus": "Prov Status",
+ "inMaint": false,
+ "lcpCloudRegionId": "AAIAIC25",
+ "tenantId": "092eb9e8e4b7412e8787dd091bc58e86",
+ "modelInfo": {
+ "modelInvariantId": "7253ff5c-97f0-4b8b-937c-77aeb4d79aa1",
+ "modelVersionId": "25284168-24bb-4698-8cb4-3f509146eca5",
+ "modelName": "2017488PasqualeVpe..PASQUALE_vRE_BV..module-1",
+ "modelVersion": "6",
+ "modelCustomizationId": "f7e7c365-60cf-49a9-9ebf-a1aa11b9d401",
+ "modelCustomizationName": "2017488PasqualeVpe..PASQUALE_vRE_BV..module-1",
+ "uuid": "25284168-24bb-4698-8cb4-3f509146eca5"
+ },
+ "uuid": "25284168-24bb-4698-8cb4-3f509146eca5"
+ }
+ }
+ },
+ "uuid": "69e09f68-8b63-4cc9-b9ff-860960b5db09",
+ "productFamilyId": "e433710f-9217-458d-a79d-1c7aff376d89",
+ "lcpCloudRegionId": "AAIAIC25",
+ "tenantId": "092eb9e8e4b7412e8787dd091bc58e86",
+ "lineOfBusiness": "ONAP",
+ "platformName": "platform",
+ "modelInfo": {
+ "modelInvariantId": "72e465fe-71b1-4e7b-b5ed-9496118ff7a8",
+ "modelVersionId": "69e09f68-8b63-4cc9-b9ff-860960b5db09",
+ "modelName": "2017-488_PASQUALE-vPE",
+ "modelVersion": "5.0",
+ "modelCustomizationId": "1da7b585-5e61-4993-b95e-8e6606c81e45",
+ "modelCustomizationName": "2017-488_PASQUALE-vPE 0",
+ "uuid": "69e09f68-8b63-4cc9-b9ff-860960b5db09"
+ },
+ "orchStatus": "Created",
+ "inMaint": false,
+ "instanceId": "VNF_INSTANCE_ID",
+ "instanceName": "2017488_PASQUALEvPEVNFinstancename",
+ "action": "None",
+ "legacyRegion": "some legacy region"
+ }
+ },
+ "instanceParams": [],
+ "validationCounter": 0,
+ "existingNames": {
+ "mcankinstancename": ""
+ },
+ "existingVNFCounterMap": {
+ "afacccf6-397d-45d6-b5ae-94c39734b168": 1,
+ "69e09f68-8b63-4cc9-b9ff-860960b5db09": 3,
+ "b3c76f73-eeb5-4fb6-9d31-72a889f1811c": 1
+ },
+ "existingVnfGroupCounterMap": {},
+ "existingNetworksCounterMap": {},
+ "networks": {},
+ "vnfGroups": {},
+ "bulkSize": 1,
+ "instanceId": "f8791436-8d55-4fde-b4d5-72dd2cf13cfb",
+ "instanceName": "mCaNkinstancename",
+ "globalSubscriberId": "e433710f-9217-458d-a79d-1c7aff376d89",
+ "subscriptionServiceType": "TYLER SILVIA",
+ "owningEntityId": "d61e6f2d-12fa-4cc2-91df-7c244011d6fc",
+ "productFamilyId": "e433710f-9217-458d-a79d-1c7aff376d89",
+ "lcpCloudRegionId": "hvf6",
+ "tenantId": "bae71557c5bb4d5aac6743a4e5f1d054",
+ "aicZoneId": "NFT1",
+ "projectName": "WATKINS",
+ "rollbackOnFailure": true,
+ "aicZoneName": "NFTJSSSS-NFT1",
+ "owningEntityName": "WayneHolland",
+ "tenantName": "AIN Web Tool-15-D-testalexandria",
+ "modelInfo": {
+ "modelInvariantId": "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0",
+ "modelVersionId": "6b528779-44a3-4472-bdff-9cd15ec93450",
+ "modelName": "action-data",
+ "modelVersion": "1.0",
+ "uuid": "6b528779-44a3-4472-bdff-9cd15ec93450"
+ },
+ "isALaCarte": true,
+ "orchStatus": "Active",
+ "modelInavariantId": "6b528779-44a3-4472-bdff-9cd15ec93450",
+ "testApi": "VNF_API"
+} \ No newline at end of file
diff --git a/vid-app-common/src/test/resources/payload_jsons/vfmodule/replace_vfmodule.json b/vid-app-common/src/test/resources/payload_jsons/vfmodule/replace_vfmodule.json
new file mode 100644
index 000000000..c3ab694aa
--- /dev/null
+++ b/vid-app-common/src/test/resources/payload_jsons/vfmodule/replace_vfmodule.json
@@ -0,0 +1,52 @@
+{
+ "requestDetails": {
+ "requestInfo": {
+ "source": "VID",
+ "requestorId": "az2016",
+ "instanceName": "replace_module",
+ "suppressRollback": false
+ },
+ "relatedInstanceList": [{
+ "relatedInstance": {
+ "instanceId": "e9993045-cc96-4f3f-bf9a-71b2a400a956",
+ "modelInfo": {
+ "modelVersionId": "bad955c3-29b2-4a27-932e-28e942cc6480",
+ "modelVersion": "1",
+ "modelName": "Vf zolson5bpxmc02092017-Service",
+ "modelInvariantId": "b16a9398-ffa3-4041-b78c-2956b8ad9c7b",
+ "modelType": "service"
+ }
+ }
+ }, {
+ "relatedInstance": {
+ "instanceId": "5c9c2896-1fe6-4055-b7ec-d0a01e5f9bf5",
+ "modelInfo": {
+ "modelName": "Vf zolson5bpxmc02092017-VF",
+ "modelVersion": "1",
+ "modelInvariantId": "23122c9b-dd7f-483f-bf0a-e069303db2f7",
+ "modelType": "vnf",
+ "modelCustomizationName": "Vf zolson5bpxmc02092017-VF 0",
+ "modelVersionId": "d326f424-2312-4dd6-b7fe-364fadbd1ef5",
+ "modelCustomizationId": "96c23a4a-6887-4b2c-9cce-1e4ea35eaade"
+ }
+ }
+ }],
+ "requestParameters": {
+ "userParams": [],
+ "testApi": "GR_API"
+ },
+ "modelInfo": {
+ "modelName": "VfZrdm5bpxmc02092017Vf..CORNELIUS_base..module-0",
+ "modelVersion": "1",
+ "modelInvariantId": "f7a867f2-596b-4f4a-a128-421e825a6190",
+ "modelType": "vfModule",
+ "modelVersionId": "eb5de6fb-9ecf-4009-b922-fae3a9ae7d46",
+ "modelCustomizationId": "074c64d0-7e13-4bcc-8bdb-ea922331102d"
+ },
+ "cloudConfiguration": {
+ "cloudOwner": "irma-aic",
+ "tenantId": "0422ffb57ba042c0800a29dc85ca70f8",
+ "lcpCloudRegionId": "regionOne"
+ }
+ }
+} \ No newline at end of file
diff --git a/vid-app-common/src/test/resources/payload_jsons/vfmodule/replace_vfmodule_fe_input.json b/vid-app-common/src/test/resources/payload_jsons/vfmodule/replace_vfmodule_fe_input.json
new file mode 100644
index 000000000..92ccfe541
--- /dev/null
+++ b/vid-app-common/src/test/resources/payload_jsons/vfmodule/replace_vfmodule_fe_input.json
@@ -0,0 +1,92 @@
+{
+ "action": "None",
+ "isDirty": true,
+ "vnfs": {
+ "Vf zolson5bpxmc02092017-VF 0": {
+ "vfModules": {
+ "VfZrdm5bpxmc02092017Vf..CORNELIUS_base..module-0": {
+ "VfZrdm5bpxmc02092017Vf..CORNELIUS_base..module-0-?": {
+ "instanceName": "replace_module",
+ "instanceId": "5d49c3b1-fc90-4762-8c98-e800170baa55",
+ "action": "Replace",
+ "orchStatus": "Create",
+ "provStatus": "Prov Status",
+ "inMaint": false,
+ "rollbackOnFailure": true,
+ "lcpCloudRegionId": "regionOne",
+ "tenantId": "0422ffb57ba042c0800a29dc85ca70f8",
+ "modelInfo": {
+ "modelInvariantId": "f7a867f2-596b-4f4a-a128-421e825a6190",
+ "modelVersionId": "eb5de6fb-9ecf-4009-b922-fae3a9ae7d46",
+ "modelName": "VfZrdm5bpxmc02092017Vf..CORNELIUS_base..module-0",
+ "modelVersion": "1",
+ "modelCustomizationId": "074c64d0-7e13-4bcc-8bdb-ea922331102d",
+ "uuid": "eb5de6fb-9ecf-4009-b922-fae3a9ae7d46"
+ },
+ "uuid": "eb5de6fb-9ecf-4009-b922-fae3a9ae7d46"
+ }
+ }
+ },
+ "uuid": "d326f424-2312-4dd6-b7fe-364fadbd1ef5",
+ "productFamilyId": "bad955c3-29b2-4a27-932e-28e942cc6480",
+ "lcpCloudRegionId": "regionOne",
+ "tenantId": "0422ffb57ba042c0800a29dc85ca70f8",
+ "lineOfBusiness": "ONAP",
+ "platformName": "platform",
+ "modelInfo": {
+ "modelInvariantId": "23122c9b-dd7f-483f-bf0a-e069303db2f7",
+ "modelVersionId": "d326f424-2312-4dd6-b7fe-364fadbd1ef5",
+ "modelName": "Vf zolson5bpxmc02092017-VF",
+ "modelVersion": "1",
+ "modelCustomizationId": "96c23a4a-6887-4b2c-9cce-1e4ea35eaade",
+ "modelCustomizationName": "Vf zolson5bpxmc02092017-VF 0",
+ "uuid": "d326f424-2312-4dd6-b7fe-364fadbd1ef5"
+ },
+ "orchStatus": "Created",
+ "inMaint": false,
+ "rollbackOnFailure": true,
+ "instanceId": "5c9c2896-1fe6-4055-b7ec-d0a01e5f9bf5",
+ "instanceName": "vnf_of_replace_module",
+ "action": "None",
+ "legacyRegion": "some legacy region"
+ }
+ },
+ "instanceParams": [],
+ "validationCounter": 0,
+ "existingNames": {
+ "mcankinstancename": ""
+ },
+ "existingVNFCounterMap": {
+ "d326f424-2312-4dd6-b7fe-364fadbd1ef5": 1
+ },
+ "existingVnfGroupCounterMap": {},
+ "existingNetworksCounterMap": {},
+ "networks": {},
+ "vnfGroups": {},
+ "bulkSize": 1,
+ "instanceId": "e9993045-cc96-4f3f-bf9a-71b2a400a956",
+ "instanceName": "service_of_replace_module",
+ "globalSubscriberId": "e433710f-9217-458d-a79d-1c7aff376d89",
+ "subscriptionServiceType": "TYLER SILVIA",
+ "owningEntityId": "d61e6f2d-12fa-4cc2-91df-7c244011d6fc",
+ "productFamilyId": "bad955c3-29b2-4a27-932e-28e942cc6480",
+ "lcpCloudRegionId": "regionOne",
+ "tenantId": "0422ffb57ba042c0800a29dc85ca70f8",
+ "aicZoneId": "NFT1",
+ "projectName": "WATKINS",
+ "rollbackOnFailure": true,
+ "aicZoneName": "NFTJSSSS-NFT1",
+ "owningEntityName": "WayneHolland",
+ "tenantName": "tenant_name",
+ "modelInfo": {
+ "modelInvariantId": "b16a9398-ffa3-4041-b78c-2956b8ad9c7b",
+ "modelVersionId": "bad955c3-29b2-4a27-932e-28e942cc6480",
+ "modelName": "Vf zolson5bpxmc02092017-Service",
+ "modelVersion": "1",
+ "uuid": "bad955c3-29b2-4a27-932e-28e942cc6480"
+ },
+ "isALaCarte": true,
+ "orchStatus": "Active",
+ "modelInavariantId": "b16a9398-ffa3-4041-b78c-2956b8ad9c7b",
+ "testApi": "GR_API"
+} \ No newline at end of file
diff --git a/vid-app-common/src/test/resources/payload_jsons/vfmodule_instantiation_request.json b/vid-app-common/src/test/resources/payload_jsons/vfmodule_instantiation_request.json
index 92f837faf..1bce76097 100644
--- a/vid-app-common/src/test/resources/payload_jsons/vfmodule_instantiation_request.json
+++ b/vid-app-common/src/test/resources/payload_jsons/vfmodule_instantiation_request.json
@@ -12,7 +12,7 @@
"cloudConfiguration": {
"lcpCloudRegionId": "mdt1",
"tenantId": "88a6ca3ee0394ade9403f075db23167e",
- "cloudOwner" : "att-aic"
+ "cloudOwner" : "irma-aic"
},
"requestInfo": {
"instanceName": "vmxnjr001_AVPN_base_vRE_BV_expansion",
@@ -63,7 +63,8 @@
"vre_a_volume_size_0" : "100",
"vmx_int_net_len" : "24",
"availability_zone_0": "mtpocdv-kvm-az01"
- }]
+ }],
+ "testApi" : "VNF_API"
}
}
}
diff --git a/vid-app-common/src/test/resources/payload_jsons/vfmodule_instantiation_request_without_instance_name.json b/vid-app-common/src/test/resources/payload_jsons/vfmodule_instantiation_request_without_instance_name.json
index 82df5b90a..1c0d2b981 100644
--- a/vid-app-common/src/test/resources/payload_jsons/vfmodule_instantiation_request_without_instance_name.json
+++ b/vid-app-common/src/test/resources/payload_jsons/vfmodule_instantiation_request_without_instance_name.json
@@ -12,7 +12,7 @@
"cloudConfiguration": {
"lcpCloudRegionId": "mdt1",
"tenantId": "88a6ca3ee0394ade9403f075db23167e",
- "cloudOwner" : "att-aic"
+ "cloudOwner" : "irma-aic"
},
"requestInfo": {
"source": "VID",
@@ -53,7 +53,8 @@
"vre_a_volume_size_0" : "100",
"vmx_int_net_len" : "24",
"availability_zone_0": "mtpocdv-kvm-az01"
- }]
+ }],
+ "testApi" : "VNF_API"
}
}
} \ No newline at end of file
diff --git a/vid-app-common/src/test/resources/payload_jsons/vfmodule_instantiation_request_without_volume_group.json b/vid-app-common/src/test/resources/payload_jsons/vfmodule_instantiation_request_without_volume_group.json
index cfa4c2652..3581a475a 100644
--- a/vid-app-common/src/test/resources/payload_jsons/vfmodule_instantiation_request_without_volume_group.json
+++ b/vid-app-common/src/test/resources/payload_jsons/vfmodule_instantiation_request_without_volume_group.json
@@ -12,7 +12,7 @@
"cloudConfiguration": {
"lcpCloudRegionId": "mdt1",
"tenantId": "88a6ca3ee0394ade9403f075db23167e",
- "cloudOwner" : "att-aic"
+ "cloudOwner" : "irma-aic"
},
"requestInfo": {
"instanceName": "vmxnjr001_AVPN_base_vRE_BV_expansion",
@@ -54,7 +54,8 @@
"vre_a_volume_size_0" : "100",
"vmx_int_net_len" : "24",
"availability_zone_0": "mtpocdv-kvm-az01"
- }]
+ }],
+ "testApi" : "VNF_API"
}
}
} \ No newline at end of file
diff --git a/vid-app-common/src/test/resources/payload_jsons/vnf/bulk_vnf_request.json b/vid-app-common/src/test/resources/payload_jsons/vnf/bulk_vnf_request.json
new file mode 100644
index 000000000..1ae0406a7
--- /dev/null
+++ b/vid-app-common/src/test/resources/payload_jsons/vnf/bulk_vnf_request.json
@@ -0,0 +1,49 @@
+ {
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "vnf",
+ "modelInvariantId": "11111111-f63c-463e-ba94-286933b895f9",
+ "modelVersionId": "7f40c192-f63c-463e-ba94-286933b895f8",
+ "modelName": "2016-73_MOW-AVPN-vPE-BV-L",
+ "modelVersion": "10.0",
+ "modelCustomizationName": "2016-73_MOW-AVPN-vPE-BV-L 0",
+ "modelCustomizationId": "ab153b6e-c364-44c0-bef6-1f2982117f04"
+ },
+ "cloudConfiguration": {
+ "lcpCloudRegionId": "mdt1",
+ "tenantId": "88a6ca3ee0394ade9403f075db23167e",
+ "cloudOwner" : "irma-aic"
+ },
+ "requestInfo": {
+ "instanceName": "vmxnjr001",
+ "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "source": "VID",
+ "suppressRollback": true,
+ "requestorId": "pa0916"
+ },
+ "platform": {
+ "platformName": "platformName"
+ },
+ "lineOfBusiness": {
+ "lineOfBusinessName": "lineOfBusinessName"
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "aa3514e3-5a33-55df-13ab-12abad84e7aa",
+ "modelInfo": {
+ "modelType": "service",
+ "modelInvariantId": "ff3514e3-5a33-55df-13ab-12abad84e7ff",
+ "modelVersionId": "fe6985cd-ea33-3346-ac12-ab121484a3fe",
+ "modelName": "sriov",
+ "modelVersion": "1.0"
+ }
+ }
+ }
+ ],
+ "requestParameters": {
+ "userParams": [],
+ "testApi" : "VNF_API"
+ }
+ }
+ } \ No newline at end of file
diff --git a/vid-app-common/src/test/resources/payload_jsons/vnf/bulk_vnf_request_without_cloud_owner.json b/vid-app-common/src/test/resources/payload_jsons/vnf/bulk_vnf_request_without_cloud_owner.json
new file mode 100644
index 000000000..191696490
--- /dev/null
+++ b/vid-app-common/src/test/resources/payload_jsons/vnf/bulk_vnf_request_without_cloud_owner.json
@@ -0,0 +1,48 @@
+ {
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "vnf",
+ "modelInvariantId": "11111111-f63c-463e-ba94-286933b895f9",
+ "modelVersionId": "7f40c192-f63c-463e-ba94-286933b895f8",
+ "modelName": "2016-73_MOW-AVPN-vPE-BV-L",
+ "modelVersion": "10.0",
+ "modelCustomizationName": "2016-73_MOW-AVPN-vPE-BV-L 0",
+ "modelCustomizationId": "ab153b6e-c364-44c0-bef6-1f2982117f04"
+ },
+ "cloudConfiguration": {
+ "lcpCloudRegionId": "mdt1",
+ "tenantId": "88a6ca3ee0394ade9403f075db23167e"
+ },
+ "requestInfo": {
+ "instanceName": "vmxnjr001",
+ "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "source": "VID",
+ "suppressRollback": true,
+ "requestorId": "pa0916"
+ },
+ "platform": {
+ "platformName": "platformName"
+ },
+ "lineOfBusiness": {
+ "lineOfBusinessName": "lineOfBusinessName"
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "aa3514e3-5a33-55df-13ab-12abad84e7aa",
+ "modelInfo": {
+ "modelType": "service",
+ "modelInvariantId": "ff3514e3-5a33-55df-13ab-12abad84e7ff",
+ "modelVersionId": "fe6985cd-ea33-3346-ac12-ab121484a3fe",
+ "modelName": "sriov",
+ "modelVersion": "1.0"
+ }
+ }
+ }
+ ],
+ "requestParameters": {
+ "userParams": [],
+ "testApi" : "VNF_API"
+ }
+ }
+ } \ No newline at end of file
diff --git a/vid-app-common/src/test/resources/payload_jsons/vnf/bulk_vnf_request_without_instance_name.json b/vid-app-common/src/test/resources/payload_jsons/vnf/bulk_vnf_request_without_instance_name.json
new file mode 100644
index 000000000..3b59e6d29
--- /dev/null
+++ b/vid-app-common/src/test/resources/payload_jsons/vnf/bulk_vnf_request_without_instance_name.json
@@ -0,0 +1,48 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "vnf",
+ "modelInvariantId": "11111111-f63c-463e-ba94-286933b895f9",
+ "modelVersionId": "7f40c192-f63c-463e-ba94-286933b895f8",
+ "modelName": "2016-73_MOW-AVPN-vPE-BV-L",
+ "modelVersion": "10.0",
+ "modelCustomizationName": "2016-73_MOW-AVPN-vPE-BV-L 0",
+ "modelCustomizationId": "ab153b6e-c364-44c0-bef6-1f2982117f04"
+ },
+ "cloudConfiguration": {
+ "lcpCloudRegionId": "mdt1",
+ "tenantId": "88a6ca3ee0394ade9403f075db23167e",
+ "cloudOwner": "irma-aic"
+ },
+ "requestInfo": {
+ "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "source": "VID",
+ "suppressRollback": true,
+ "requestorId": "pa0916"
+ },
+ "platform": {
+ "platformName": "platformName"
+ },
+ "lineOfBusiness": {
+ "lineOfBusinessName": "lineOfBusinessName"
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "aa3514e3-5a33-55df-13ab-12abad84e7aa",
+ "modelInfo": {
+ "modelType": "service",
+ "modelInvariantId": "ff3514e3-5a33-55df-13ab-12abad84e7ff",
+ "modelVersionId": "fe6985cd-ea33-3346-ac12-ab121484a3fe",
+ "modelName": "sriov",
+ "modelVersion": "1.0"
+ }
+ }
+ }
+ ],
+ "requestParameters": {
+ "userParams": [],
+ "testApi" : "VNF_API"
+ }
+ }
+} \ No newline at end of file
diff --git a/vid-app-common/src/test/resources/payload_jsons/vnf/vnf_without_lob_expected.json b/vid-app-common/src/test/resources/payload_jsons/vnf/vnf_without_lob_expected.json
new file mode 100644
index 000000000..11c5dcb63
--- /dev/null
+++ b/vid-app-common/src/test/resources/payload_jsons/vnf/vnf_without_lob_expected.json
@@ -0,0 +1,46 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelCustomizationName": "xbi test VID noFC HEAT 0",
+ "modelCustomizationId": "e9745411-1f7d-47e3-9857-47363cb9ff92",
+ "modelInvariantId": "77d3a011-affb-4166-89b2-c4be7bc4ff23",
+ "modelVersionId": "9bb0edd9-3631-455b-bdfd-979b2ab53d07",
+ "modelName": "xbi test VID noFC HEAT",
+ "modelType": "vnf",
+ "modelVersion": "1.0"
+ },
+ "cloudConfiguration": {
+ "lcpCloudRegionId": "olson52b",
+ "tenantId": "bbf14e449c954feea272e926a8c2b244",
+ "cloudOwner" : "irma-aic"
+ },
+ "requestInfo": {
+ "instanceName": "zolson52bfrwl01",
+ "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "source": "VID",
+ "suppressRollback": false,
+ "requestorId": "pa0916"
+ },
+ "platform": {
+ "platformName": "NETWORK-CLOUD"
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "aa3514e3-5a33-55df-13ab-12abad84e7aa",
+ "modelInfo": {
+ "modelType": "service",
+ "modelInvariantId": "ff3514e3-5a33-55df-13ab-12abad84e7ff",
+ "modelVersionId": "fe6985cd-ea33-3346-ac12-ab121484a3fe",
+ "modelName": "sriov",
+ "modelVersion": "1.0"
+ }
+ }
+ }
+ ],
+ "requestParameters": {
+ "userParams": [],
+ "testApi": "VNF_API"
+ }
+ }
+}
diff --git a/vid-app-common/src/test/resources/payload_jsons/vnf/vnf_without_lob_user_input.json b/vid-app-common/src/test/resources/payload_jsons/vnf/vnf_without_lob_user_input.json
new file mode 100644
index 000000000..60be0d13e
--- /dev/null
+++ b/vid-app-common/src/test/resources/payload_jsons/vnf/vnf_without_lob_user_input.json
@@ -0,0 +1,24 @@
+{
+ "modelInfo": {
+ "modelCustomizationName": "xbi test VID noFC HEAT 0",
+ "modelCustomizationId": "e9745411-1f7d-47e3-9857-47363cb9ff92",
+ "modelInvariantId": "77d3a011-affb-4166-89b2-c4be7bc4ff23",
+ "modelVersionId": "9bb0edd9-3631-455b-bdfd-979b2ab53d07",
+ "modelName": "xbi test VID noFC HEAT",
+ "modelType": "vnf",
+ "modelVersion": "1.0"
+ },
+ "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "instanceName": "zolson52bfrwl01",
+ "action": "Create",
+ "platformName": "NETWORK-CLOUD",
+ "lcpCloudRegionId": "olson52b",
+ "tenantId": "bbf14e449c954feea272e926a8c2b244",
+ "instanceParams": [{}],
+ "rollbackOnFailure": true,
+ "instanceId": null,
+ "vfModules": {},
+ "trackById": "449206d5-54a6-441f-b5c2-beacb2f2e1cc",
+ "isFailed": false,
+ "lineOfBusiness": null
+} \ No newline at end of file
diff --git a/vid-app-common/src/test/resources/payload_jsons/vnfDelete1Create1Request.json b/vid-app-common/src/test/resources/payload_jsons/vnfDelete1Create1Request.json
new file mode 100644
index 000000000..5cf7973be
--- /dev/null
+++ b/vid-app-common/src/test/resources/payload_jsons/vnfDelete1Create1Request.json
@@ -0,0 +1,240 @@
+{
+ "action": "None",
+ "isDirty": true,
+ "vnfs": {
+ "2017-388_PASQUALE-vPE 0": {
+ "vfModules": {},
+ "uuid": "afacccf6-397d-45d6-b5ae-94c39734b168",
+ "productFamilyId": "e433710f-9217-458d-a79d-1c7aff376d89",
+ "lcpCloudRegionId": "AAIAIC25",
+ "tenantId": "092eb9e8e4b7412e8787dd091bc58e86",
+ "lineOfBusiness": "ONAP",
+ "platformName": "platform",
+ "modelInfo": {
+ "modelInvariantId": "72e465fe-71b1-4e7b-b5ed-9496118ff7a8",
+ "modelVersionId": "afacccf6-397d-45d6-b5ae-94c39734b168",
+ "modelName": "2017-388_PASQUALE-vPE",
+ "modelVersion": "4.0",
+ "modelCustomizationId": "b3c76f73-eeb5-4fb6-9d31-72a889f1811c",
+ "modelCustomizationName": "2017-388_PASQUALE-vPE 0",
+ "uuid": "afacccf6-397d-45d6-b5ae-94c39734b168"
+ },
+ "instanceName": "2017388_PASQUALEvPEmCaNkinstanceName",
+ "action": "None",
+ "legacyRegion": "some legacy region"
+ },
+ "2017-488_PASQUALE-vPE 0": {
+ "vfModules": {},
+ "uuid": "69e09f68-8b63-4cc9-b9ff-860960b5db09",
+ "productFamilyId": "e433710f-9217-458d-a79d-1c7aff376d89",
+ "lcpCloudRegionId": "AAIAIC25",
+ "tenantId": "092eb9e8e4b7412e8787dd091bc58e86",
+ "lineOfBusiness": "ONAP",
+ "platformName": "platform",
+ "modelInfo": {
+ "modelInvariantId": "72e465fe-71b1-4e7b-b5ed-9496118ff7a8",
+ "modelVersionId": "69e09f68-8b63-4cc9-b9ff-860960b5db09",
+ "modelName": "2017-488_PASQUALE-vPE",
+ "modelVersion": "5.0",
+ "modelCustomizationId": "1da7b585-5e61-4993-b95e-8e6606c81e45",
+ "modelCustomizationName": "2017-488_PASQUALE-vPE 0",
+ "uuid": "69e09f68-8b63-4cc9-b9ff-860960b5db09"
+ },
+ "orchStatus": "Created",
+ "inMaint": false,
+ "instanceId": "VNF_INSTANCE_ID",
+ "instanceName": "2017488_PASQUALEvPEVNFinstancename",
+ "action": "None_Delete",
+ "legacyRegion": "some legacy region"
+ },
+ "2017-488_PASQUALE-vPE 0:0001": {
+ "vfModules": {
+ "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0": {
+ "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0uvfot": {
+ "instanceName": "VFinstancenameZERO_001",
+ "action": "None",
+ "provStatus": "Prov Status",
+ "inMaint": true,
+ "modelInfo": {
+ "modelInvariantId": "b34833bb-6aa9-4ad6-a831-70b06367a091",
+ "modelVersionId": "f8360508-3f17-4414-a2ed-6bc71161e8db",
+ "modelName": "2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0",
+ "modelVersion": "5",
+ "modelCustomizationId": "a55961b2-2065-4ab0-a5b7-2fcee1c227e3",
+ "modelCustomizationName": "2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0",
+ "uuid": "f8360508-3f17-4414-a2ed-6bc71161e8db"
+ },
+ "uuid": "f8360508-3f17-4414-a2ed-6bc71161e8db"
+ }
+ },
+ "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vRE_BV..module-1": {
+ "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vRE_BV..module-1fshmc": {
+ "instanceName": "VFinstancename_001",
+ "action": "None",
+ "volumeGroupName": "VFinstancename_vol_abc_001",
+ "modelInfo": {
+ "modelInvariantId": "7253ff5c-97f0-4b8b-937c-77aeb4d79aa1",
+ "modelVersionId": "25284168-24bb-4698-8cb4-3f509146eca5",
+ "modelName": "2017488PasqualeVpe..PASQUALE_vRE_BV..module-1",
+ "modelVersion": "6",
+ "modelCustomizationId": "f7e7c365-60cf-49a9-9ebf-a1aa11b9d401",
+ "modelCustomizationName": "2017488PasqualeVpe..PASQUALE_vRE_BV..module-1",
+ "uuid": "25284168-24bb-4698-8cb4-3f509146eca5"
+ },
+ "uuid": "25284168-24bb-4698-8cb4-3f509146eca5"
+ }
+ }
+ },
+ "uuid": "69e09f68-8b63-4cc9-b9ff-860960b5db09",
+ "productFamilyId": "e433710f-9217-458d-a79d-1c7aff376d89",
+ "lcpCloudRegionId": "AAIAIC25",
+ "tenantId": "092eb9e8e4b7412e8787dd091bc58e86",
+ "lineOfBusiness": "ONAP",
+ "platformName": "platform",
+ "modelInfo": {
+ "modelInvariantId": "72e465fe-71b1-4e7b-b5ed-9496118ff7a8",
+ "modelVersionId": "69e09f68-8b63-4cc9-b9ff-860960b5db09",
+ "modelName": "2017-488_PASQUALE-vPE",
+ "modelVersion": "5.0",
+ "modelCustomizationId": "1da7b585-5e61-4993-b95e-8e6606c81e45",
+ "modelCustomizationName": "2017-488_PASQUALE-vPE 0",
+ "uuid": "69e09f68-8b63-4cc9-b9ff-860960b5db09"
+ },
+ "instanceName": "2017488_PASQUALEvPEVNFinstancename_001",
+ "action": "None",
+ "legacyRegion": "some legacy region"
+ },
+ "2017-488_PASQUALE-vPE 0:0002": {
+ "vfModules": {
+ "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0": {
+ "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0uvfot": {
+ "instanceName": "VFinstancenameZERO_002",
+ "action": "None",
+ "modelInfo": {
+ "modelInvariantId": "b34833bb-6aa9-4ad6-a831-70b06367a091",
+ "modelVersionId": "f8360508-3f17-4414-a2ed-6bc71161e8db",
+ "modelName": "2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0",
+ "modelVersion": "5",
+ "modelCustomizationId": "a55961b2-2065-4ab0-a5b7-2fcee1c227e3",
+ "modelCustomizationName": "2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0",
+ "uuid": "f8360508-3f17-4414-a2ed-6bc71161e8db"
+ },
+ "uuid": "f8360508-3f17-4414-a2ed-6bc71161e8db"
+ }
+ },
+ "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vRE_BV..module-1": {
+ "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vRE_BV..module-1fshmc": {
+ "instanceName": "VFinstancename_002",
+ "action": "None",
+ "volumeGroupName": "VFinstancename_vol_abc_002",
+ "modelInfo": {
+ "modelInvariantId": "7253ff5c-97f0-4b8b-937c-77aeb4d79aa1",
+ "modelVersionId": "25284168-24bb-4698-8cb4-3f509146eca5",
+ "modelName": "2017488PasqualeVpe..PASQUALE_vRE_BV..module-1",
+ "modelVersion": "6",
+ "modelCustomizationId": "f7e7c365-60cf-49a9-9ebf-a1aa11b9d401",
+ "modelCustomizationName": "2017488PasqualeVpe..PASQUALE_vRE_BV..module-1",
+ "uuid": "25284168-24bb-4698-8cb4-3f509146eca5"
+ },
+ "uuid": "25284168-24bb-4698-8cb4-3f509146eca5"
+ }
+ }
+ },
+ "uuid": "69e09f68-8b63-4cc9-b9ff-860960b5db09",
+ "productFamilyId": "e433710f-9217-458d-a79d-1c7aff376d89",
+ "lcpCloudRegionId": "AAIAIC25",
+ "tenantId": "092eb9e8e4b7412e8787dd091bc58e86",
+ "lineOfBusiness": "ONAP",
+ "platformName": "platform",
+ "modelInfo": {
+ "modelInvariantId": "72e465fe-71b1-4e7b-b5ed-9496118ff7a8",
+ "modelVersionId": "69e09f68-8b63-4cc9-b9ff-860960b5db09",
+ "modelName": "2017-488_PASQUALE-vPE",
+ "modelVersion": "5.0",
+ "modelCustomizationId": "1da7b585-5e61-4993-b95e-8e6606c81e45",
+ "modelCustomizationName": "2017-488_PASQUALE-vPE 0",
+ "uuid": "69e09f68-8b63-4cc9-b9ff-860960b5db09"
+ },
+ "instanceName": "2017488_PASQUALEvPEVNFinstancename_002",
+ "action": "None",
+ "legacyRegion": "some legacy region"
+ },
+ "2017-388_PASQUALE-vPE 0_1": {
+ "action": "Create",
+ "inMaint": false,
+ "rollbackOnFailure": "true",
+ "originalName": "2017-388_PASQUALE-vPE 0",
+ "isMissingData": false,
+ "trackById": "wk10c4hh1oj",
+ "vfModules": {},
+ "vnfStoreKey": "2017-388_PASQUALE-vPE 0_1",
+ "instanceName": "2017388_PASQUALEvPEmCaNkinstanceName",
+ "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "lcpCloudRegionId": "hvf6",
+ "tenantId": "229bcdc6eaeb4ca59d55221141d01f8e",
+ "platformName": "xxx1",
+ "lineOfBusiness": "zzz1",
+ "instanceParams": [
+ {
+ "vnf_config_template_version": "17.2",
+ "bandwidth_units": "Gbps",
+ "bandwidth": "10",
+ "AIC_CLLI": "ATLMY8GA",
+ "ASN": "AV_vPE",
+ "vnf_instance_name": "mtnj309me6"
+ }
+ ],
+ "modelInfo": {
+ "modelInvariantId": "72e465fe-71b1-4e7b-b5ed-9496118ff7a8",
+ "modelVersionId": "afacccf6-397d-45d6-b5ae-94c39734b168",
+ "modelName": "2017-388_PASQUALE-vPE",
+ "modelVersion": "4.0",
+ "modelCustomizationId": "b3c76f73-eeb5-4fb6-9d31-72a889f1811c",
+ "modelCustomizationName": "2017-388_PASQUALE-vPE 0",
+ "uuid": "afacccf6-397d-45d6-b5ae-94c39734b168",
+ "modelUniqueId": "b3c76f73-eeb5-4fb6-9d31-72a889f1811c"
+ },
+ "uuid": "afacccf6-397d-45d6-b5ae-94c39734b168"
+ }
+ },
+ "instanceParams": [],
+ "validationCounter": 0,
+ "existingNames": {
+ "mcankinstancename": ""
+ },
+ "existingVNFCounterMap": {
+ "afacccf6-397d-45d6-b5ae-94c39734b168": 1,
+ "69e09f68-8b63-4cc9-b9ff-860960b5db09": 3,
+ "b3c76f73-eeb5-4fb6-9d31-72a889f1811c": 1
+ },
+ "existingVnfGroupCounterMap": {},
+ "existingNetworksCounterMap": {},
+ "networks": {},
+ "vnfGroups": {},
+ "bulkSize": 1,
+ "instanceId": "f8791436-8d55-4fde-b4d5-72dd2cf13cfb",
+ "instanceName": "mCaNkinstancename",
+ "globalSubscriberId": "e433710f-9217-458d-a79d-1c7aff376d89",
+ "subscriptionServiceType": "TYLER SILVIA",
+ "owningEntityId": "d61e6f2d-12fa-4cc2-91df-7c244011d6fc",
+ "productFamilyId": "e433710f-9217-458d-a79d-1c7aff376d89",
+ "lcpCloudRegionId": "hvf6",
+ "tenantId": "bae71557c5bb4d5aac6743a4e5f1d054",
+ "aicZoneId": "NFT1",
+ "projectName": "WATKINS",
+ "rollbackOnFailure": true,
+ "aicZoneName": "NFTJSSSS-NFT1",
+ "owningEntityName": "WayneHolland",
+ "tenantName": "AIN Web Tool-15-D-testalexandria",
+ "modelInfo": {
+ "modelInvariantId": "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0",
+ "modelVersionId": "6b528779-44a3-4472-bdff-9cd15ec93450",
+ "modelName": "action-data",
+ "modelVersion": "1.0",
+ "uuid": "6b528779-44a3-4472-bdff-9cd15ec93450"
+ },
+ "isALaCarte": true,
+ "orchStatus": "Active",
+ "modelInavariantId": "6b528779-44a3-4472-bdff-9cd15ec93450",
+ "testApi": "VNF_API"
+} \ No newline at end of file
diff --git a/vid-app-common/src/test/resources/payload_jsons/volumegroup_instantiation_request.json b/vid-app-common/src/test/resources/payload_jsons/volumegroup_instantiation_request.json
index 02d2d1e14..8d64ebefb 100644
--- a/vid-app-common/src/test/resources/payload_jsons/volumegroup_instantiation_request.json
+++ b/vid-app-common/src/test/resources/payload_jsons/volumegroup_instantiation_request.json
@@ -12,7 +12,7 @@
"cloudConfiguration": {
"lcpCloudRegionId": "mdt1",
"tenantId": "88a6ca3ee0394ade9403f075db23167e",
- "cloudOwner" : "att-aic"
+ "cloudOwner" : "irma-aic"
},
"requestInfo": {
"instanceName": "myVgName",
@@ -50,7 +50,8 @@
],
"requestParameters" : {
"userParams" : [ ],
- "usePreload" : true
+ "usePreload" : true,
+ "testApi" : "VNF_API"
}
}
}
diff --git a/vid-app-common/src/test/resources/payload_jsons/vrfEntry/service_with_vrf_entry_fe_input.json b/vid-app-common/src/test/resources/payload_jsons/vrfEntry/service_with_vrf_entry_fe_input.json
new file mode 100644
index 000000000..4f20cf19c
--- /dev/null
+++ b/vid-app-common/src/test/resources/payload_jsons/vrfEntry/service_with_vrf_entry_fe_input.json
@@ -0,0 +1,81 @@
+{
+ "action": "Create",
+ "isDirty": false,
+ "vnfs": {},
+ "vrfs": {
+ "vrf-1": {
+ "networks": {
+ "Network-1": {
+ "instanceName": "myBestNetwork",
+ "instanceId": "884b373f-41c0-4a96-9785-7f075cb4ae9d",
+ "modelInfo": {
+ "modelType": "network"
+ }
+ }
+ },
+ "vpns": {
+ "vpn-1": {
+ "instanceName": "justFakeVPN",
+ "instanceId": "7e971d5c-6ddf-4f02-be8a-95dcbc7daf83",
+ "modelInfo": {
+ "modelType": "vpnBinding"
+ }
+ }
+ }
+ }
+ },
+ "instanceParams": [
+ {}
+ ],
+ "validationCounter": 0,
+ "existingNames": {
+ "dfd": ""
+ },
+ "existingVNFCounterMap": {},
+ "existingVRFCounterMap": {},
+ "existingVnfGroupCounterMap": {},
+ "existingNetworksCounterMap": {},
+ "optionalGroupMembersMap": {},
+ "networks": {},
+ "vnfGroups": {},
+ "bulkSize": 1,
+ "instanceName": "dfd",
+ "productFamilyId": "ddf9cc0f-6331-4d35-bed0-a37f2d5e9cb3",
+ "globalSubscriberId": "e433710f-9217-458d-a79d-1c7aff376d89",
+ "subscriberName": "SILVIA ROBBINS",
+ "subscriptionServiceType": "TYLER SILVIA",
+ "owningEntityId": "d61e6f2d-12fa-4cc2-91df-7c244011d6fc",
+ "lcpCloudRegionId": "lcpCloudRegionId",
+ "tenantName": "tenantName",
+ "tenantId": "4b273bc5-0ae6-4088-aa5d-5a862d84cab2",
+ "projectName": "WATKINS",
+ "rollbackOnFailure": "true",
+ "aicZoneName": null,
+ "owningEntityName": "WayneHolland",
+ "testApi": "VNF_API",
+ "modelInfo": {
+ "modelInvariantId": "dfc2c44c-2429-44ca-ae26-1e6dc1f207fb",
+ "modelVersionId": "f028b2e2-7080-4b13-91b2-94944d4c42d8",
+ "modelName": "infraVPN",
+ "modelVersion": "1.0",
+ "uuid": "f028b2e2-7080-4b13-91b2-94944d4c42d8",
+ "modelUniqueId": "f028b2e2-7080-4b13-91b2-94944d4c42d8"
+ },
+ "isALaCarte": true,
+ "name": "infraVPN",
+ "version": "1.0",
+ "description": "ddd",
+ "category": "Network Service",
+ "uuid": "f028b2e2-7080-4b13-91b2-94944d4c42d8",
+ "invariantUuid": "dfc2c44c-2429-44ca-ae26-1e6dc1f207fb",
+ "serviceType": "BONDING",
+ "serviceRole": "INFRASTRUCTURE-VPN",
+ "vidNotions": {
+ "instantiationType": "Macro",
+ "instantiationUI": "infrastructureVpn",
+ "modelCategory": "INFRASTRUCTURE_VPN",
+ "viewEditUI": "legacy"
+ },
+ "isEcompGeneratedNaming": true,
+ "isMultiStepDesign": false
+} \ No newline at end of file
diff --git a/vid-app-common/src/test/resources/payload_jsons/vrfEntry/service_with_vrf_instantiation_request.json b/vid-app-common/src/test/resources/payload_jsons/vrfEntry/service_with_vrf_instantiation_request.json
new file mode 100644
index 000000000..2e64554a3
--- /dev/null
+++ b/vid-app-common/src/test/resources/payload_jsons/vrfEntry/service_with_vrf_instantiation_request.json
@@ -0,0 +1,59 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelInvariantId": "dfc2c44c-2429-44ca-ae26-1e6dc1f207fb",
+ "modelVersionId": "f028b2e2-7080-4b13-91b2-94944d4c42d8",
+ "modelName": "infraVPN",
+ "modelVersion": "1.0",
+ "modelType": "service"
+ },
+ "cloudConfiguration": {
+ "cloudOwner": "irma-aic",
+ "lcpCloudRegionId": "lcpCloudRegionId",
+ "tenantId": "4b273bc5-0ae6-4088-aa5d-5a862d84cab2"
+ },
+ "owningEntity": {
+ "owningEntityId": "d61e6f2d-12fa-4cc2-91df-7c244011d6fc",
+ "owningEntityName": "WayneHolland"
+ },
+ "project": {
+ "projectName": "WATKINS"
+ },
+ "subscriberInfo": {
+ "globalSubscriberId": "e433710f-9217-458d-a79d-1c7aff376d89",
+ "subscriberName": "SILVIA ROBBINS"
+ },
+ "requestInfo": {
+ "instanceName": "dfd",
+ "productFamilyId": "ddf9cc0f-6331-4d35-bed0-a37f2d5e9cb3",
+ "source": "VID",
+ "suppressRollback": false,
+ "requestorId": "az2016"
+ },
+ "requestParameters": {
+ "subscriptionServiceType": "TYLER SILVIA",
+ "aLaCarte": false,
+ "userParams": []
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "7e971d5c-6ddf-4f02-be8a-95dcbc7daf83",
+ "instanceName": "justFakeVPN",
+ "modelInfo": {
+ "modelType": "vpnBinding"
+ }
+ }
+ },
+ {
+ "relatedInstance": {
+ "instanceId": "884b373f-41c0-4a96-9785-7f075cb4ae9d",
+ "instanceName": "myBestNetwork",
+ "modelInfo": {
+ "modelType": "network"
+ }
+ }
+ }
+ ]
+ }
+} \ No newline at end of file
diff --git a/vid-app-common/src/test/resources/policy-configuration-by-policy-false.JSON b/vid-app-common/src/test/resources/policy-configuration-by-policy-false.JSON
index 4508599bc..6e073260e 100644
--- a/vid-app-common/src/test/resources/policy-configuration-by-policy-false.JSON
+++ b/vid-app-common/src/test/resources/policy-configuration-by-policy-false.JSON
@@ -34,8 +34,8 @@
"type": "Configuration",
"modelCustomizationName": "Port Mirroring Configuration By Policy 1",
"sourceNodes": [
- "vmmeservice2_proxy 2",
- "vmmeservice2_proxy 3"
+ "vflorenceservice2_proxy 2",
+ "vflorenceservice2_proxy 3"
],
"collectorNodes": [
"pprobeservice_proxy 5"
@@ -61,9 +61,9 @@
"type": "Configuration",
"modelCustomizationName": "Port Mirroring Configuration By Policy 0",
"sourceNodes": [
- "vmmeservice2_proxy 2",
- "vmmeservice_proxy 1",
- "vmmeservice_proxy 0"
+ "vflorenceservice2_proxy 2",
+ "vflorenceservice_proxy 1",
+ "vflorenceservice_proxy 0"
],
"collectorNodes": [
],
@@ -71,11 +71,11 @@
}
},
"serviceProxies": {
- "vmmeservice_proxy 0": {
+ "vflorenceservice_proxy 0": {
"uuid": "a32fee17-5b59-4c34-ba6f-6dd2f1c61fee",
"invariantUuid": "2933b574-d28d-45ea-bf22-4df2907e4a10",
- "description": "A Proxy for Service vmmeService",
- "name": "vmmeService Service Proxy",
+ "description": "A Proxy for Service vflorenceService",
+ "name": "vflorenceService Service Proxy",
"version": "1.0",
"customizationUuid": "d7cfe338-eeda-4217-ba13-f24b0811fb17",
"inputs": {},
@@ -84,13 +84,13 @@
"type": "Service Proxy",
"sourceModelUuid": "c3e6c9bd-b24d-458e-aa99-e0cadf70c5e5",
"sourceModelInvariant": "dd8a805d-3946-4f11-9831-e26cd6aec9a3",
- "sourceModelName": "vmmeService"
+ "sourceModelName": "vflorenceService"
},
- "vmmeservice_proxy 1": {
+ "vflorenceservice_proxy 1": {
"uuid": "a32fee17-5b59-4c34-ba6f-6dd2f1c61fee",
"invariantUuid": "2933b574-d28d-45ea-bf22-4df2907e4a10",
- "description": "A Proxy for Service vmmeService",
- "name": "vmmeService Service Proxy",
+ "description": "A Proxy for Service vflorenceService",
+ "name": "vflorenceService Service Proxy",
"version": "1.0",
"customizationUuid": "7a69f133-564c-4eb6-b93e-0a8281967efb",
"inputs": {},
@@ -99,13 +99,13 @@
"type": "Service Proxy",
"sourceModelUuid": "c3e6c9bd-b24d-458e-aa99-e0cadf70c5e5",
"sourceModelInvariant": "dd8a805d-3946-4f11-9831-e26cd6aec9a3",
- "sourceModelName": "vmmeService"
+ "sourceModelName": "vflorenceService"
},
- "vmmeservice2_proxy 3": {
+ "vflorenceservice2_proxy 3": {
"uuid": "a32fee17-5b59-4c34-ba6f-6dd2f1c61fee",
"invariantUuid": "2933b574-d28d-45ea-bf22-4df2907e4a10",
- "description": "A Proxy for Service vmmeService2",
- "name": "vmmeService2 Service Proxy",
+ "description": "A Proxy for Service vflorenceService2",
+ "name": "vflorenceService2 Service Proxy",
"version": "1.0",
"customizationUuid": "9d81c21f-e29c-44f6-b5f6-caa974ee078a",
"inputs": {},
@@ -114,7 +114,7 @@
"type": "Service Proxy",
"sourceModelUuid": "2a2ea15f-07c6-4b89-bfca-e8aba39a34d6",
"sourceModelInvariant": "a7eac2b3-8444-40ee-92e3-b3359b32445c",
- "sourceModelName": "vmmeService2"
+ "sourceModelName": "vflorenceService2"
},
"pprobeservice_proxy 4": {
"uuid": "a32fee17-5b59-4c34-ba6f-6dd2f1c61fee",
@@ -146,11 +146,11 @@
"sourceModelInvariant": "83b458fd-5dd3-419b-a9e3-7335814a0911",
"sourceModelName": "pProbeService"
},
- "vmmeservice2_proxy 2": {
+ "vflorenceservice2_proxy 2": {
"uuid": "a32fee17-5b59-4c34-ba6f-6dd2f1c61fee",
"invariantUuid": "2933b574-d28d-45ea-bf22-4df2907e4a10",
- "description": "A Proxy for Service vmmeService2",
- "name": "vmmeService2 Service Proxy",
+ "description": "A Proxy for Service vflorenceService2",
+ "name": "vflorenceService2 Service Proxy",
"version": "1.0",
"customizationUuid": "060be63d-5f9c-4fd0-8ef7-830d5e8eca17",
"inputs": {},
@@ -159,7 +159,7 @@
"type": "Service Proxy",
"sourceModelUuid": "2a2ea15f-07c6-4b89-bfca-e8aba39a34d6",
"sourceModelInvariant": "a7eac2b3-8444-40ee-92e3-b3359b32445c",
- "sourceModelName": "vmmeService2"
+ "sourceModelName": "vflorenceService2"
}
},
"vfModules": {},
diff --git a/vid-app-common/src/test/resources/policy-configuration-csar.JSON b/vid-app-common/src/test/resources/policy-configuration-csar.JSON
index 41f5f5cbf..d2614cb18 100644
--- a/vid-app-common/src/test/resources/policy-configuration-csar.JSON
+++ b/vid-app-common/src/test/resources/policy-configuration-csar.JSON
@@ -34,9 +34,9 @@
"type": "Configuration",
"modelCustomizationName": "Port Mirroring Configuration By Policy 1",
"sourceNodes": [
- "vmmeservice2_proxy 2",
- "vmmeservice2_proxy 3",
- "vmmeservice_proxy 1"
+ "vflorenceservice2_proxy 2",
+ "vflorenceservice2_proxy 3",
+ "vflorenceservice_proxy 1"
],
"collectorNodes": [
"pprobeservice_proxy 5"
@@ -62,9 +62,9 @@
"type": "Configuration",
"modelCustomizationName": "Port Mirroring Configuration By Policy 0",
"sourceNodes": [
- "vmmeservice2_proxy 2",
- "vmmeservice_proxy 1",
- "vmmeservice_proxy 0"
+ "vflorenceservice2_proxy 2",
+ "vflorenceservice_proxy 1",
+ "vflorenceservice_proxy 0"
],
"collectorNodes": [
"pprobeservice_proxy 4"
@@ -73,11 +73,11 @@
}
},
"serviceProxies": {
- "vmmeservice_proxy 0": {
+ "vflorenceservice_proxy 0": {
"uuid": "a32fee17-5b59-4c34-ba6f-6dd2f1c61fee",
"invariantUuid": "2933b574-d28d-45ea-bf22-4df2907e4a10",
- "description": "A Proxy for Service vmmeService",
- "name": "vmmeService Service Proxy",
+ "description": "A Proxy for Service vflorenceService",
+ "name": "vflorenceService Service Proxy",
"version": "1.0",
"customizationUuid": "d7cfe338-eeda-4217-ba13-f24b0811fb17",
"inputs": {},
@@ -88,13 +88,13 @@
"type": "Service Proxy",
"sourceModelUuid": "c3e6c9bd-b24d-458e-aa99-e0cadf70c5e5",
"sourceModelInvariant": "dd8a805d-3946-4f11-9831-e26cd6aec9a3",
- "sourceModelName": "vmmeService"
+ "sourceModelName": "vflorenceService"
},
- "vmmeservice_proxy 1": {
+ "vflorenceservice_proxy 1": {
"uuid": "a32fee17-5b59-4c34-ba6f-6dd2f1c61fee",
"invariantUuid": "2933b574-d28d-45ea-bf22-4df2907e4a10",
- "description": "A Proxy for Service vmmeService",
- "name": "vmmeService Service Proxy",
+ "description": "A Proxy for Service vflorenceService",
+ "name": "vflorenceService Service Proxy",
"version": "1.0",
"customizationUuid": "7a69f133-564c-4eb6-b93e-0a8281967efb",
"inputs": {},
@@ -105,13 +105,13 @@
"type": "Service Proxy",
"sourceModelUuid": "c3e6c9bd-b24d-458e-aa99-e0cadf70c5e5",
"sourceModelInvariant": "dd8a805d-3946-4f11-9831-e26cd6aec9a3",
- "sourceModelName": "vmmeService"
+ "sourceModelName": "vflorenceService"
},
- "vmmeservice2_proxy 3": {
+ "vflorenceservice2_proxy 3": {
"uuid": "a32fee17-5b59-4c34-ba6f-6dd2f1c61fee",
"invariantUuid": "2933b574-d28d-45ea-bf22-4df2907e4a10",
- "description": "A Proxy for Service vmmeService2",
- "name": "vmmeService2 Service Proxy",
+ "description": "A Proxy for Service vflorenceService2",
+ "name": "vflorenceService2 Service Proxy",
"version": "1.0",
"customizationUuid": "9d81c21f-e29c-44f6-b5f6-caa974ee078a",
"inputs": {},
@@ -122,7 +122,7 @@
"type": "Service Proxy",
"sourceModelUuid": "2a2ea15f-07c6-4b89-bfca-e8aba39a34d6",
"sourceModelInvariant": "a7eac2b3-8444-40ee-92e3-b3359b32445c",
- "sourceModelName": "vmmeService2"
+ "sourceModelName": "vflorenceService2"
},
"pprobeservice_proxy 4": {
"uuid": "a32fee17-5b59-4c34-ba6f-6dd2f1c61fee",
@@ -158,11 +158,11 @@
"sourceModelInvariant": "83b458fd-5dd3-419b-a9e3-7335814a0911",
"sourceModelName": "pProbeService"
},
- "vmmeservice2_proxy 2": {
+ "vflorenceservice2_proxy 2": {
"uuid": "a32fee17-5b59-4c34-ba6f-6dd2f1c61fee",
"invariantUuid": "2933b574-d28d-45ea-bf22-4df2907e4a10",
- "description": "A Proxy for Service vmmeService2",
- "name": "vmmeService2 Service Proxy",
+ "description": "A Proxy for Service vflorenceService2",
+ "name": "vflorenceService2 Service Proxy",
"version": "1.0",
"customizationUuid": "060be63d-5f9c-4fd0-8ef7-830d5e8eca17",
"inputs": {},
@@ -173,11 +173,14 @@
"type": "Service Proxy",
"sourceModelUuid": "2a2ea15f-07c6-4b89-bfca-e8aba39a34d6",
"sourceModelInvariant": "a7eac2b3-8444-40ee-92e3-b3359b32445c",
- "sourceModelName": "vmmeService2"
+ "sourceModelName": "vflorenceService2"
}
},
"vfModules": {},
"volumeGroups": {},
"pnfs": {},
- "vnfGroups": {}
+ "vnfGroups": {},
+ "vrfs": {
+
+ }
} \ No newline at end of file
diff --git a/vid-app-common/src/test/resources/responses/aai/getCloudRegionAndTenantByVnfId.json b/vid-app-common/src/test/resources/responses/aai/getCloudRegionAndTenantByVnfId.json
index 690be607b..bc3ab0a18 100644
--- a/vid-app-common/src/test/resources/responses/aai/getCloudRegionAndTenantByVnfId.json
+++ b/vid-app-common/src/test/resources/responses/aai/getCloudRegionAndTenantByVnfId.json
@@ -34,7 +34,7 @@
{
"id": "264798392",
"node-type": "vserver",
- "url": "/aai/v14/cloud-infrastructure/cloud-regions/cloud-region/att-aic/mtn23b/tenants/tenant/3e9a20a3e89e45f884e09df0cc2d2d2a/vservers/vserver/088c2bf0-80e2-4bdf-93ae-b2469fbeba84",
+ "url": "/aai/v14/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/mtn23b/tenants/tenant/3e9a20a3e89e45f884e09df0cc2d2d2a/vservers/vserver/088c2bf0-80e2-4bdf-93ae-b2469fbeba84",
"properties": {
"vserver-id": "088c2bf0-80e2-4bdf-93ae-b2469fbeba84",
"vserver-name": "zrdm3mogx01oam001",
@@ -49,7 +49,7 @@
"id": "211808464",
"relationship-label": "tosca.relationships.AttachesTo",
"node-type": "volume",
- "url": "/aai/v14/cloud-infrastructure/cloud-regions/cloud-region/att-aic/mtn23b/tenants/tenant/3e9a20a3e89e45f884e09df0cc2d2d2a/vservers/vserver/088c2bf0-80e2-4bdf-93ae-b2469fbeba84/volumes/volume/28e1246e-2aeb-4a59-bb51-f20fb8e93c42"
+ "url": "/aai/v14/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/mtn23b/tenants/tenant/3e9a20a3e89e45f884e09df0cc2d2d2a/vservers/vserver/088c2bf0-80e2-4bdf-93ae-b2469fbeba84/volumes/volume/28e1246e-2aeb-4a59-bb51-f20fb8e93c42"
}
]
},
@@ -75,7 +75,7 @@
{
"id": "8757432",
"node-type": "tenant",
- "url": "/aai/v14/cloud-infrastructure/cloud-regions/cloud-region/att-aic/mtn23b/tenants/tenant/3e9a20a3e89e45f884e09df0cc2d2d2a",
+ "url": "/aai/v14/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/mtn23b/tenants/tenant/3e9a20a3e89e45f884e09df0cc2d2d2a",
"properties": {
"tenant-id": "3e9a20a3e89e45f884e09df0cc2d2d2a",
"tenant-name": "APPC-24595-T-IST-02C",
@@ -93,9 +93,9 @@
{
"id": "302227536",
"node-type": "cloud-region",
- "url": "/aai/v14/cloud-infrastructure/cloud-regions/cloud-region/att-aic/mtn23b",
+ "url": "/aai/v14/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/mtn23b",
"properties": {
- "cloud-owner": "att-aic",
+ "cloud-owner": "irma-aic" ,
"cloud-region-id": "mtn23b",
"cloud-type": "openstack",
"owner-defined-type": "lcp",
@@ -111,7 +111,7 @@
"id": "2744328",
"relationship-label": "org.onap.relationships.inventory.BelongsTo",
"node-type": "tenant",
- "url": "/aai/v14/cloud-infrastructure/cloud-regions/cloud-region/att-aic/mtn23b/tenants/tenant/5452d6bd0cb34e99a3553d349456c642"
+ "url": "/aai/v14/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/mtn23b/tenants/tenant/5452d6bd0cb34e99a3553d349456c642"
}
]
}
diff --git a/vid-app-common/src/test/resources/responses/mso/multipleOrchestrationRequestsServiceInstance.json b/vid-app-common/src/test/resources/responses/mso/multipleOrchestrationRequestsServiceInstance.json
new file mode 100644
index 000000000..9708522a2
--- /dev/null
+++ b/vid-app-common/src/test/resources/responses/mso/multipleOrchestrationRequestsServiceInstance.json
@@ -0,0 +1,300 @@
+{
+ "requestList": [
+ {
+ "request": {
+ "requestId": "2543cd7c-ed76-4e94-83be-0cf0cc55bf23",
+ "startTime": "Mon, 04 Mar 2019 20:47:45 GMT",
+ "finishTime": "Mon, 04 Mar 2019 20:48:46 GMT",
+ "requestScope": "vnf",
+ "requestType": "createInstance",
+ "requestDetails": {
+ "modelInfo": {
+ "modelCustomizationName": "OAM_FRWL_5G_NC 0",
+ "modelInvariantId": "d5f2cc03-fad3-4a5a-bf36-6328771b3915",
+ "modelType": "vnf",
+ "modelName": "OAM_FRWL_5G_NC",
+ "modelVersion": "7.0",
+ "modelCustomizationUuid": "006ad5a0-b8c4-43f3-aa93-0fa379ea613d",
+ "modelVersionId": "f248be17-b66d-4ea0-bb24-51de6f62c240",
+ "modelCustomizationId": "006ad5a0-b8c4-43f3-aa93-0fa379ea613d",
+ "modelUuid": "f248be17-b66d-4ea0-bb24-51de6f62c240",
+ "modelInvariantUuid": "d5f2cc03-fad3-4a5a-bf36-6328771b3915",
+ "modelInstanceName": "OAM_FRWL_5G_NC 0"
+ },
+ "requestInfo": {
+ "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "source": "VID",
+ "instanceName": "zauk51bfrwl07",
+ "suppressRollback": false,
+ "requestorId": "pj8646"
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "d40c8a82-cc04-45e5-a0f6-0c9394c8f8d2",
+ "modelInfo": {
+ "modelInvariantId": "77ac5b6f-e31a-4477-b2c9-8a49ea58aee2",
+ "modelType": "service",
+ "modelName": "OAM_FRWL_5G_NC_SVC",
+ "modelVersion": "6.0",
+ "modelVersionId": "75a90831-a34f-4b81-8245-4f8b110f93fa",
+ "modelUuid": "75a90831-a34f-4b81-8245-4f8b110f93fa",
+ "modelInvariantUuid": "77ac5b6f-e31a-4477-b2c9-8a49ea58aee2"
+ }
+ }
+ }
+ ],
+ "cloudConfiguration": {
+ "tenantId": "e2a6af59d1cb43b2874e943bbbf8470a",
+ "cloudOwner": "att-nc",
+ "lcpCloudRegionId": "auk51b"
+ },
+ "requestParameters": {
+ "testApi": "GR_API"
+ },
+ "platform": {
+ "platformName": "NETWORK-CLOUD"
+ },
+ "lineOfBusiness": {
+ "lineOfBusinessName": "EMANUEL-CONSUMER"
+ }
+ },
+ "instanceReferences": {
+ "serviceInstanceId": "d40c8a82-cc04-45e5-a0f6-0c9394c8f8d2",
+ "vnfInstanceId": "05bedd02-b933-40f1-ad20-bab3197489a9",
+ "vnfInstanceName": "zauk51bfrwl07",
+ "requestorId": "pj8646"
+ },
+ "requestStatus": {
+ "requestState": "COMPLETE",
+ "statusMessage": "STATUS: ALaCarte-Vnf-createInstance request was executed correctly. FLOW STATUS: Successfully completed all Building Blocks",
+ "percentProgress": 100,
+ "timestamp": "Mon, 04 Mar 2019 20:48:46 GMT"
+ }
+ }
+ },
+ {
+ "request": {
+ "requestId": "fab854bf-e53c-415e-b3cc-b6fcce8414b2",
+ "startTime": "Mon, 04 Mar 2019 20:47:15 GMT",
+ "finishTime": "Mon, 04 Mar 2019 20:47:38 GMT",
+ "requestScope": "service",
+ "requestType": "createInstance",
+ "requestDetails": {
+ "modelInfo": {
+ "modelInvariantId": "77ac5b6f-e31a-4477-b2c9-8a49ea58aee2",
+ "modelType": "service",
+ "modelName": "OAM_FRWL_5G_NC_SVC",
+ "modelVersion": "6.0",
+ "modelVersionId": "75a90831-a34f-4b81-8245-4f8b110f93fa",
+ "modelUuid": "75a90831-a34f-4b81-8245-4f8b110f93fa",
+ "modelInvariantUuid": "77ac5b6f-e31a-4477-b2c9-8a49ea58aee2"
+ },
+ "requestInfo": {
+ "source": "VID",
+ "instanceName": "zauk51bfrwl07_vnf_service",
+ "suppressRollback": false,
+ "requestorId": "pj8646"
+ },
+ "subscriberInfo": {
+ "globalSubscriberId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb"
+ },
+ "requestParameters": {
+ "subscriptionServiceType": "Emanuel",
+ "aLaCarte": true,
+ "testApi": "GR_API"
+ },
+ "project": {
+ "projectName": "Kennedy"
+ },
+ "owningEntity": {
+ "owningEntityId": "e4257a94-21cc-40c5-adc9-e6f4ff868e31",
+ "owningEntityName": "EMANUEL-CORE"
+ }
+ },
+ "instanceReferences": {
+ "serviceInstanceId": "d40c8a82-cc04-45e5-a0f6-0c9394c8f8d2",
+ "serviceInstanceName": "zauk51bfrwl07_vnf_service",
+ "requestorId": "pj8646"
+ },
+ "requestStatus": {
+ "requestState": "COMPLETE",
+ "statusMessage": "STATUS: ALaCarte-Service-createInstance request was executed correctly. FLOW STATUS: Successfully completed all Building Blocks",
+ "percentProgress": 100,
+ "timestamp": "Mon, 04 Mar 2019 20:47:38 GMT"
+ }
+ }
+ },
+ {
+ "request": {
+ "requestId": "3eb7b323-b486-402e-931a-2ad296e6406b",
+ "startTime": "Mon, 04 Mar 2019 20:48:52 GMT",
+ "finishTime": "Mon, 04 Mar 2019 20:50:40 GMT",
+ "requestScope": "vfModule",
+ "requestType": "createInstance",
+ "requestDetails": {
+ "modelInfo": {
+ "modelCustomizationName": "OamFrwl5gNc..base_oam..module-0",
+ "modelInvariantId": "00b03b3e-454f-438c-87ca-5860f98e8dbc",
+ "modelType": "vfModule",
+ "modelName": "OamFrwl5gNc..base_oam..module-0",
+ "modelVersion": "3",
+ "modelCustomizationUuid": "53aef95c-92b5-48d7-912a-1f89d0eb6355",
+ "modelVersionId": "3fb037f3-d629-490f-af49-2bbb97a946be",
+ "modelCustomizationId": "53aef95c-92b5-48d7-912a-1f89d0eb6355",
+ "modelUuid": "3fb037f3-d629-490f-af49-2bbb97a946be",
+ "modelInvariantUuid": "00b03b3e-454f-438c-87ca-5860f98e8dbc",
+ "modelInstanceName": "OamFrwl5gNc..base_oam..module-0"
+ },
+ "requestInfo": {
+ "source": "VID",
+ "instanceName": "zauk51bfrwl07_base_1",
+ "suppressRollback": false,
+ "requestorId": "pj8646"
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "d40c8a82-cc04-45e5-a0f6-0c9394c8f8d2",
+ "modelInfo": {
+ "modelInvariantId": "77ac5b6f-e31a-4477-b2c9-8a49ea58aee2",
+ "modelType": "service",
+ "modelName": "OAM_FRWL_5G_NC_SVC",
+ "modelVersion": "6.0",
+ "modelVersionId": "75a90831-a34f-4b81-8245-4f8b110f93fa",
+ "modelUuid": "75a90831-a34f-4b81-8245-4f8b110f93fa",
+ "modelInvariantUuid": "77ac5b6f-e31a-4477-b2c9-8a49ea58aee2"
+ }
+ }
+ },
+ {
+ "relatedInstance": {
+ "instanceId": "05bedd02-b933-40f1-ad20-bab3197489a9",
+ "modelInfo": {
+ "modelCustomizationName": "OAM_FRWL_5G_NC 0",
+ "modelInvariantId": "d5f2cc03-fad3-4a5a-bf36-6328771b3915",
+ "modelType": "vnf",
+ "modelName": "OAM_FRWL_5G_NC",
+ "modelVersion": "7.0",
+ "modelCustomizationUuid": "006ad5a0-b8c4-43f3-aa93-0fa379ea613d",
+ "modelVersionId": "f248be17-b66d-4ea0-bb24-51de6f62c240",
+ "modelCustomizationId": "006ad5a0-b8c4-43f3-aa93-0fa379ea613d",
+ "modelUuid": "f248be17-b66d-4ea0-bb24-51de6f62c240",
+ "modelInvariantUuid": "d5f2cc03-fad3-4a5a-bf36-6328771b3915",
+ "modelInstanceName": "OAM_FRWL_5G_NC 0"
+ }
+ }
+ }
+ ],
+ "cloudConfiguration": {
+ "tenantId": "e2a6af59d1cb43b2874e943bbbf8470a",
+ "cloudOwner": "att-nc",
+ "lcpCloudRegionId": "auk51b"
+ },
+ "requestParameters": {
+ "usePreload": false,
+ "testApi": "GR_API"
+ }
+ },
+ "instanceReferences": {
+ "serviceInstanceId": "d40c8a82-cc04-45e5-a0f6-0c9394c8f8d2",
+ "vnfInstanceId": "05bedd02-b933-40f1-ad20-bab3197489a9",
+ "vfModuleInstanceId": "9276805f-07ba-43c0-a5f1-f327c1d72606",
+ "vfModuleInstanceName": "zauk51bfrwl07_base_1",
+ "requestorId": "pj8646"
+ },
+ "requestStatus": {
+ "requestState": "COMPLETE",
+ "statusMessage": "STATUS: ALaCarte-VfModule-createInstance request was executed correctly. FLOW STATUS: Successfully completed all Building Blocks",
+ "percentProgress": 100,
+ "timestamp": "Mon, 04 Mar 2019 20:50:40 GMT"
+ }
+ }
+ },
+ {
+ "request": {
+ "requestId": "74f5a2dc-1e80-4553-8fac-d30675e510be",
+ "startTime": "Mon, 04 Mar 2019 20:50:47 GMT",
+ "requestScope": "vfModule",
+ "requestType": "createInstance",
+ "requestDetails": {
+ "modelInfo": {
+ "modelCustomizationName": "OamFrwl5gNc..module_oam..module-1",
+ "modelInvariantId": "972a22a1-8cbf-45ce-8ff2-f0f33694695d",
+ "modelType": "vfModule",
+ "modelName": "OamFrwl5gNc..module_oam..module-1",
+ "modelVersion": "3",
+ "modelCustomizationUuid": "cf88008e-c4b6-48b8-99a9-44d850f3d8db",
+ "modelVersionId": "cea74dcd-1174-4f65-adff-87a355849275",
+ "modelCustomizationId": "cf88008e-c4b6-48b8-99a9-44d850f3d8db",
+ "modelUuid": "cea74dcd-1174-4f65-adff-87a355849275",
+ "modelInvariantUuid": "972a22a1-8cbf-45ce-8ff2-f0f33694695d",
+ "modelInstanceName": "OamFrwl5gNc..module_oam..module-1"
+ },
+ "requestInfo": {
+ "source": "VID",
+ "instanceName": "zauk51bfrwl07_mod_1",
+ "suppressRollback": false,
+ "requestorId": "pj8646"
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "d40c8a82-cc04-45e5-a0f6-0c9394c8f8d2",
+ "modelInfo": {
+ "modelInvariantId": "77ac5b6f-e31a-4477-b2c9-8a49ea58aee2",
+ "modelType": "service",
+ "modelName": "OAM_FRWL_5G_NC_SVC",
+ "modelVersion": "6.0",
+ "modelVersionId": "75a90831-a34f-4b81-8245-4f8b110f93fa",
+ "modelUuid": "75a90831-a34f-4b81-8245-4f8b110f93fa",
+ "modelInvariantUuid": "77ac5b6f-e31a-4477-b2c9-8a49ea58aee2"
+ }
+ }
+ },
+ {
+ "relatedInstance": {
+ "instanceId": "05bedd02-b933-40f1-ad20-bab3197489a9",
+ "modelInfo": {
+ "modelCustomizationName": "OAM_FRWL_5G_NC 0",
+ "modelInvariantId": "d5f2cc03-fad3-4a5a-bf36-6328771b3915",
+ "modelType": "vnf",
+ "modelName": "OAM_FRWL_5G_NC",
+ "modelVersion": "7.0",
+ "modelCustomizationUuid": "006ad5a0-b8c4-43f3-aa93-0fa379ea613d",
+ "modelVersionId": "f248be17-b66d-4ea0-bb24-51de6f62c240",
+ "modelCustomizationId": "006ad5a0-b8c4-43f3-aa93-0fa379ea613d",
+ "modelUuid": "f248be17-b66d-4ea0-bb24-51de6f62c240",
+ "modelInvariantUuid": "d5f2cc03-fad3-4a5a-bf36-6328771b3915",
+ "modelInstanceName": "OAM_FRWL_5G_NC 0"
+ }
+ }
+ }
+ ],
+ "cloudConfiguration": {
+ "tenantId": "e2a6af59d1cb43b2874e943bbbf8470a",
+ "cloudOwner": "att-nc",
+ "lcpCloudRegionId": "auk51b"
+ },
+ "requestParameters": {
+ "usePreload": true,
+ "testApi": "GR_API"
+ }
+ },
+ "instanceReferences": {
+ "serviceInstanceId": "d40c8a82-cc04-45e5-a0f6-0c9394c8f8d2",
+ "vnfInstanceId": "05bedd02-b933-40f1-ad20-bab3197489a9",
+ "vfModuleInstanceId": "73a01fe6-d9f9-4022-82f4-082c6d8cf520",
+ "vfModuleInstanceName": "zauk51bfrwl07_mod_1",
+ "requestorId": "pj8646"
+ },
+ "requestStatus": {
+ "requestState": "FAILED",
+ "statusMessage": "STATUS: Error from SDNC: No active l3-network found in AAI with network_name GRP-27529-T-IST-07A_N_oam_protected_net_1 FLOW STATUS: All Rollback flows have completed successfully ROLLBACK STATUS: Rollback has been completed successfully.",
+ "percentProgress": 100,
+ "timestamp": "Mon, 04 Mar 2019 20:51:14 GMT"
+ }
+ }
+ }
+ ]
+}
diff --git a/vid-app-common/src/test/resources/responses/mso/orchestrationRequestsVnf.json b/vid-app-common/src/test/resources/responses/mso/orchestrationRequestsVnf.json
index f83310427..e31f0e05e 100644
--- a/vid-app-common/src/test/resources/responses/mso/orchestrationRequestsVnf.json
+++ b/vid-app-common/src/test/resources/responses/mso/orchestrationRequestsVnf.json
@@ -42,7 +42,7 @@
],
"cloudConfiguration": {
"tenantId": "19dfa99ba1cc4948bb868eba9e0de7ab",
- "cloudOwner": "att-aic",
+ "cloudOwner": "irma-aic" ,
"lcpCloudRegionId": "test1"
},
"requestParameters": {
diff --git a/vid-app-common/src/main/resources/sdcservices.json b/vid-app-common/src/test/resources/sdcservices.json
index 12142aa9b..1ba13c9ae 100644
--- a/vid-app-common/src/main/resources/sdcservices.json
+++ b/vid-app-common/src/test/resources/sdcservices.json
@@ -3,10 +3,10 @@
{
"uuid": "6bce7302-70bd-4057-b48e-8d5b99e686ca",
"invariantUUID": "9aa04749-c02c-432d-a90c-18caa361c833",
- "name": "vDBE_srv",
+ "name": "vDOROTHEA_srv",
"version": "1.0",
- "toscaModelURL": "./service-VdbeSrv-csar.zip",
- "category": "Mobility",
+ "toscaModelURL": "./csars/service-VdorotheaSrv-csar.zip",
+ "category": "Emanuel",
"lifecycleState": "CERTIFIED",
"lastUpdaterUserId": "rg276b",
"lastUpdaterFullName": null,
@@ -17,10 +17,10 @@
{
"uuid": "76f27dfe-33e5-472f-8e0b-acf524adc4f0",
"invariantUUID": "c3618e16-bb5b-433a-a6e0-565ca79d8b65",
- "name": "4-27_vMME_Service",
+ "name": "4-27_vFLORENCE_Service",
"version": "1.0",
- "toscaModelURL": "./service-MsoExampleService-csar.zip",
- "category": "Mobility",
+ "toscaModelURL": "./csars/service-MsoExampleService-csar.zip",
+ "category": "Emanuel",
"lifecycleState": "CERTIFIED",
"lastUpdaterUserId": "rg276b",
"lastUpdaterFullName": null,
@@ -31,10 +31,10 @@
{
"uuid": "f4d84bb4-a416-4b4e-997e-0059973630b9",
"invariantUUID": "598e3f9e-3244-4d8f-a8e0-0e5d7a29eda9",
- "name": "ADIOD vMX vPE_BV Service 488",
+ "name": "PASQUALE vMX vPE_BV Service 488",
"version": "1.0",
- "toscaModelURL": "./service-vf-with-annotations.zip",
- "category": "Mobility",
+ "toscaModelURL": "./csars/service-vf-with-annotations.zip",
+ "category": "Emanuel",
"lifecycleState": "CERTIFIED",
"lastUpdaterUserId": "rg276b",
"lastUpdaterFullName": null,
@@ -45,10 +45,10 @@
{
"uuid": "48a52540-8772-4368-9cdb-1f124ea5c931",
"invariantUUID": "f430728a-4530-42be-a577-1206b9484cef",
- "name": "4-27_vMME_Service",
+ "name": "4-27_vFLORENCE_Service",
"version": "1.0",
- "toscaModelURL": "./service-vf-csar.zip",
- "category": "Mobility",
+ "toscaModelURL": "./csars/service-vf-csar.zip",
+ "category": "Emanuel",
"lifecycleState": "CERTIFIED",
"lastUpdaterUserId": "rg276b",
"lastUpdaterFullName": null,
@@ -59,10 +59,10 @@
{
"uuid": "cb49608f-5a24-4789-b0f7-2595473cb997",
"invariantUUID": "0311f998-9268-4fd6-bbba-afff15087b72",
- "name": "4-27_vMME_Service",
+ "name": "4-27_vFLORENCE_Service",
"version": "1.0",
- "toscaModelURL": "./service-vl-csar.zip",
- "category": "Mobility",
+ "toscaModelURL": "./csars/service-vl-csar.zip",
+ "category": "Emanuel",
"lifecycleState": "CERTIFIED",
"lastUpdaterUserId": "rg276b",
"lastUpdaterFullName": null,
@@ -75,7 +75,7 @@
"invariantUUID": "5461e83e-0b2a-465d-ab45-9d731894afd9",
"name": "vLoadBalancerMS",
"version": "1.0",
- "toscaModelURL": "./vLoadBalancerMS-with-policy.TOSCA.zip",
+ "toscaModelURL": "./csars/vLoadBalancerMS-with-policy.TOSCA.zip",
"category": "Network L4+",
"lifecycleState": "CERTIFIED",
"lastUpdaterUserId": "demo",
@@ -87,10 +87,10 @@
{
"uuid": "90fe6842-aa76-4b68-8329-5c86ff564407",
"invariantUUID": "0311f998-9268-4fd6-bbba-afff15087b72",
- "name": "4-27_vMME_Service",
+ "name": "4-27_vFLORENCE_Service",
"version": "1.0",
- "toscaModelURL": "./1712_ADIOD.zip",
- "category": "Mobility",
+ "toscaModelURL": "./csars/1712_PASQUALE.zip",
+ "category": "Emanuel",
"lifecycleState": "CERTIFIED",
"lastUpdaterUserId": "rg276b",
"lastUpdaterFullName": null,
@@ -101,10 +101,10 @@
{
"uuid": "73e1322a-8a9a-49dc-9558-b0c5c5770e4a",
"invariantUUID": "f430728a-4530-42be-a577-1206b9484cef",
- "name": "4-27_vMME_Service",
+ "name": "4-27_vFLORENCE_Service",
"version": "1.0",
- "toscaModelURL": "./pnf.zip",
- "category": "Mobility",
+ "toscaModelURL": "./csars/pnf.zip",
+ "category": "Emanuel",
"lifecycleState": "CERTIFIED",
"lastUpdaterUserId": "rg276b",
"lastUpdaterFullName": null,
@@ -117,8 +117,8 @@
"invariantUUID": "709d1be4-9a3f-4a29-8c4d-a20465e808a3",
"name": "Demo Service",
"version": "1.0",
- "toscaModelURL": "./service-DemoService1-csar.csar",
- "category": "Mobility",
+ "toscaModelURL": "./csars/service-DemoService1-csar.csar",
+ "category": "Emanuel",
"lifecycleState": "CERTIFIED",
"lastUpdaterUserId": "rg276b",
"lastUpdaterFullName": null,
@@ -129,10 +129,10 @@
{
"uuid": "32671332-a7ee-4df6-9609-db50ce5eaee7",
"invariantUUID": "598e3f9e-3244-4d8f-a8e0-0e5d7a29eda9",
- "name": "ADIOD vMX vPE_BV Service 488",
+ "name": "PASQUALE vMX vPE_BV Service 488",
"version": "1.0",
- "toscaModelURL": "./adiod.zip",
- "category": "Mobility",
+ "toscaModelURL": "./csars/pasquale.zip",
+ "category": "Emanuel",
"lifecycleState": "CERTIFIED",
"lastUpdaterUserId": "rg276b",
"lastUpdaterFullName": null,
@@ -145,8 +145,8 @@
"invariantUUID": "3d89efc0-19ca-4df7-9818-028e1fc6f708",
"name": "AMP PH SVC",
"version": "1.0",
- "toscaModelURL": "./service-AmpPhSvc-csar.zip",
- "category": "Mobility",
+ "toscaModelURL": "./csars/service-AmpPhSvc-csar.zip",
+ "category": "Emanuel",
"lifecycleState": "CERTIFIED",
"lastUpdaterUserId": "rg276b",
"lastUpdaterFullName": null,
@@ -159,8 +159,8 @@
"invariantUUID": "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0",
"name": "action-data",
"version": "1.0",
- "toscaModelURL": "./2f80c596.zip",
- "category": "Mobility",
+ "toscaModelURL": "./csars/2f80c596.zip",
+ "category": "Emanuel",
"lifecycleState": "CERTIFIED",
"lastUpdaterUserId": "rg276b",
"lastUpdaterFullName": null,
@@ -173,8 +173,8 @@
"invariantUUID": "b7d923c9-6175-41f1-91ba-4565c4953408",
"name": "Multiple pProbes",
"version": "1.0",
- "toscaModelURL": "./service-Servicecontainermultiplepprobes-csar.zip",
- "category": "Mobility",
+ "toscaModelURL": "./csars/service-Servicecontainermultiplepprobes-csar.zip",
+ "category": "Emanuel",
"lifecycleState": "CERTIFIED",
"lastUpdaterUserId": "rg276b",
"lastUpdaterFullName": null,
@@ -187,7 +187,7 @@
"invariantUUID": "b7d923c9-6175-41f1-91ba-4565c4955555",
"name": "ServiceContainerMultiplepProbes2",
"version": "2.0",
- "toscaModelURL": "./service-ServicecontainerContainsPprobe.zip",
+ "toscaModelURL": "./csars/service-ServicecontainerContainsPprobe.zip",
"category": "Network L1-3",
"lifecycleState": "CERTIFIED",
"lastUpdaterUserId": "rg276b",
@@ -201,8 +201,8 @@
"invariantUUID": "598e3f9e-3244-4d8f-a8e0-0e5d7a29eda9",
"name": "Fabric Configuration",
"version": "1.0",
- "toscaModelURL": "./service-fabric-configuration.zip",
- "category": "Mobility",
+ "toscaModelURL": "./csars/service-fabric-configuration.zip",
+ "category": "Emanuel",
"lifecycleState": "CERTIFIED",
"lastUpdaterUserId": "rg276b",
"lastUpdaterFullName": null,
@@ -215,7 +215,7 @@
"invariantUUID": "93518289-3049-450f-a22d-86108c250265",
"name": "jenny vTSBC vlan SVC",
"version": "1.0",
- "toscaModelURL": "./service-JennyVtsbcVlanSvc-csar.zip",
+ "toscaModelURL": "./csars/service-JennyVtsbcVlanSvc-csar.zip",
"category": "Network L1-3",
"lifecycleState": "CERTIFIED",
"lastUpdaterUserId": "rg276b",
@@ -225,11 +225,39 @@
"resources": null
},
{
+ "uuid": "2a53419b-3f85-4ad5-a9c9-d79905500a27",
+ "invariantUUID": "16972715-9d79-4fb0-9463-0253d45e1d48",
+ "name": "MNS VNN1B exn svc",
+ "version": "1.0",
+ "toscaModelURL": "./csars/service-MnsVnn1bExnSvc-csar.csar",
+ "category": "Emanuel",
+ "lifecycleState": "CERTIFIED",
+ "lastUpdaterUserId": "rg276b",
+ "lastUpdaterFullName": null,
+ "distributionStatus": "DISTRIBUTED",
+ "artifacts": null,
+ "resources": null
+ },
+ {
+ "uuid": "e32a5014-357f-4be4-b3f9-fecb0010811e",
+ "invariantUUID": "4e099102-fccb-4ee3-b51b-ebb51259dc50",
+ "name": "MNS VNN1B dmz svc",
+ "version": "1.0",
+ "toscaModelURL": "./csars/service-MnsVnn1bDmzSvc-csar.csar",
+ "category": "Emanuel",
+ "lifecycleState": "CERTIFIED",
+ "lastUpdaterUserId": "rg276b",
+ "lastUpdaterFullName": null,
+ "distributionStatus": "DISTRIBUTED",
+ "artifacts": null,
+ "resources": null
+ },
+ {
"uuid": "4117a0b6-e234-467d-b5b9-fe2f68c8b0fc",
"invariantUUID": "7ee41ce4-4827-44b0-a48e-2707a59905d2",
"name": "Grouping Service for Test",
"version": "1.0",
- "toscaModelURL": "./service-vnf-grouping-csar.zip",
+ "toscaModelURL": "./csars/service-vnf-grouping-csar.zip",
"category": "Network L4+",
"lifecycleState": "CERTIFIED",
"lastUpdaterUserId": "rg276b",
@@ -237,6 +265,20 @@
"distributionStatus": "DISTRIBUTED",
"artifacts": null,
"resources": null
+ },
+ {
+ "uuid": "f028b2e2-7080-4b13-91b2-94944d4c42d8",
+ "invariantUUID": "dfc2c44c-2429-44ca-ae26-1e6dc1f207fb",
+ "name": "infraVPN",
+ "version": "1.0",
+ "toscaModelURL": "./csars/service-Infravpn-csar.zip",
+ "category": "Network Service",
+ "lifecycleState": "CERTIFIED",
+ "lastUpdaterUserId": "rg276b",
+ "lastUpdaterFullName": null,
+ "distributionStatus": "DISTRIBUTED",
+ "artifacts": null,
+ "resources": null
}
]
} \ No newline at end of file
diff --git a/vid-app-common/src/test/resources/vLoadBalancerMS-with-policy.TOSCA.json b/vid-app-common/src/test/resources/vLoadBalancerMS-with-policy.TOSCA.json
index 8e29ff1d9..d066c2aba 100644
--- a/vid-app-common/src/test/resources/vLoadBalancerMS-with-policy.TOSCA.json
+++ b/vid-app-common/src/test/resources/vLoadBalancerMS-with-policy.TOSCA.json
@@ -167,7 +167,7 @@
}
},
"networks": {},
- "collectionResource": {},
+ "collectionResources": {},
"configurations": {},
"fabricConfigurations": {},
"serviceProxies": {},
diff --git a/vid-app-common/src/test/resources/vf-csar.JSON b/vid-app-common/src/test/resources/vf-csar.JSON
index c1b71b34f..591f06803 100644
--- a/vid-app-common/src/test/resources/vf-csar.JSON
+++ b/vid-app-common/src/test/resources/vf-csar.JSON
@@ -3,7 +3,7 @@
},
"service": {
- "category": "Mobility",
+ "category": "Emanuel",
"description": "Bla bla",
"serviceRole": null,
"serviceType": null,
@@ -96,10 +96,10 @@
"properties": {
"availability_zone_max_count": "get_input:greatdefect0_availability_zone_max_count",
"itc_flavor_name": "nv.c8r24d160",
- "itc_image_name": "NIMBUS_IXLA-ITC_8.20_EA_KVM_210117.qcow2",
+ "itc_image_name": "KENNEDY_IXLA-ITC_8.20_EA_KVM_210117.qcow2",
"itc_name_0": "get_input:greatdefect0_itc_name_0",
"itm_flavor_name": "nv.c2r4d50",
- "itm_image_name": "NIMBUS_IXLA-ITM_8.20.EA_KVM.qcow2",
+ "itm_image_name": "KENNEDY_IXLA-ITM_8.20.EA_KVM.qcow2",
"vf_module_id": "get_input:greatdefect0_vf_module_id",
"ecomp_generated_naming": "false"
},
@@ -178,5 +178,8 @@
"pnfs": {
},
- "vnfGroups": {}
+ "vnfGroups": {},
+ "vrfs": {
+
+ }
} \ No newline at end of file
diff --git a/vid-app-common/src/test/resources/vf-with-annotation-csar.json b/vid-app-common/src/test/resources/vf-with-annotation-csar.json
index db68313f1..17cb65251 100644
--- a/vid-app-common/src/test/resources/vf-with-annotation-csar.json
+++ b/vid-app-common/src/test/resources/vf-with-annotation-csar.json
@@ -2,17 +2,17 @@
"service": {
"uuid": "f4d84bb4-a416-4b4e-997e-0059973630b9",
"invariantUuid": "598e3f9e-3244-4d8f-a8e0-0e5d7a29eda9",
- "name": "ADIOD vMX vPE_BV Service 488",
+ "name": "PASQUALE vMX vPE_BV Service 488",
"version": "1.0",
"toscaModelURL": null,
"category": "Network L1-3",
"serviceType": "",
"serviceRole": "",
- "description": "ADIOD vMX vPE based on Juniper 17.2 release. Updated with updated VF for v8.0 of VLM",
+ "description": "PASQUALE vMX vPE based on Juniper 17.2 release. Updated with updated VF for v8.0 of VLM",
"serviceEcompNaming": "true",
"instantiationType": "Macro",
"inputs": {
- "2017488_adiodvpe0_ASN": {
+ "2017488_pasqualevpe0_ASN": {
"type": "string",
"description": "AV/PE",
"entry_schema": null,
@@ -26,11 +26,11 @@
}
},
"vnfs": {
- "2017-488_ADIOD-vPE 0": {
+ "2017-488_PASQUALE-vPE 0": {
"uuid": "ea81d6f7-0861-44a7-b7d5-d173b562c350",
"invariantUuid": "5be7e99e-8eb2-4d97-be63-8081ff3cd10e",
- "description": "Name ADIOD vPE Description The provider edge function for the ADIOD service supported by the Junipers VMX product Category Router Vendor Juniper Vendor Release Code 17.2 Owners Mary Fragale. Updated 9-25 to use v8.0 of the Juniper Valid 2 VLM",
- "name": "2017-488_ADIOD-vPE",
+ "description": "Name PASQUALE vPE Description The provider edge function for the PASQUALE service supported by the Junipers VMX product Category Router Vendor Juniper Vendor Release Code 17.2 Owners Mary Fragale. Updated 9-25 to use v8.0 of the Juniper Valid 2 VLM",
+ "name": "2017-488_PASQUALE-vPE",
"version": "9.0",
"customizationUuid": "41516cc6-5098-4b40-a619-f8d5f55fc4d8",
"inputs": {
@@ -41,21 +41,21 @@
},
"properties": {
"vmxvre_retype": "RE-VMX",
- "vnf_config_template_version": "get_input:2017488_adiodvpe0_vnf_config_template_version",
+ "vnf_config_template_version": "get_input:2017488_pasqualevpe0_vnf_config_template_version",
"sriov44_net_id": "48d399b3-11ee-48a8-94d2-f0ea94d6be8d",
"int_ctl_net_id": "2f323477-6936-4d01-ac53-d849430281d9",
"vmxvpfe_sriov41_0_port_mac": "00:11:22:EF:AC:DF",
"int_ctl_net_name": "VMX-INTXI",
- "vmx_int_ctl_prefix": "128.0.0.0",
+ "vmx_int_ctl_prefix": "10.0.0.10",
"sriov43_net_id": "da349ca1-6de9-4548-be88-2d88e99bfef5",
"sriov42_net_id": "760669ba-013d-4d9b-b0e7-4151fe2e6279",
"sriov41_net_id": "25ad52d5-c165-40f8-b3b0-ddfc2373280a",
"nf_type": "ROUTER",
- "vmxvpfe_int_ctl_ip_1": "128.0.0.16",
+ "vmxvpfe_int_ctl_ip_1": "10.0.0.10",
"is_AVPN_service": "false",
"vmx_RSG_name": "vREXI-affinity",
"vmx_int_ctl_forwarding": "l2",
- "vmxvre_oam_ip_0": "10.40.123.5",
+ "vmxvre_oam_ip_0": "10.0.0.10",
"vmxvpfe_sriov44_0_port_mac": "00:11:22:EF:AC:DF",
"vmxvpfe_sriov41_0_port_vlanstrip": "false",
"vmxvpfe_sriov42_0_port_vlanfilter": "4001",
@@ -83,10 +83,10 @@
"vmxvpfe_sriov42_0_port_unknownmulticastallow": "true",
"vmxvpfe_sriov44_0_port_vlanstrip": "false",
"vf_module_id": "123",
- "nf_function": "ADIOD vPE",
+ "nf_function": "PASQUALE vPE",
"vmxvpfe_sriov43_0_port_unknownmulticastallow": "true",
- "vmxvre_int_ctl_ip_0": "128.0.0.1",
- "AIC_CLLI": "get_input:2017488_adiodvpe0_AIC_CLLI",
+ "vmxvre_int_ctl_ip_0": "10.0.0.10",
+ "AIC_CLLI": "get_input:2017488_pasqualevpe0_AIC_CLLI",
"vnf_name": "mtnj309me6vre",
"vmxvpfe_sriov41_0_port_unknownunicastallow": "true",
"vmxvre_volume_type_1": "HITACHI",
@@ -94,24 +94,24 @@
"vmxvre_volume_type_0": "HITACHI",
"vmxvpfe_volume_type_0": "HITACHI",
"vmxvpfe_sriov43_0_port_broadcastallow": "true",
- "bandwidth_units": "get_input:2017488_adiodvpe0_bandwidth_units",
+ "bandwidth_units": "get_input:2017488_pasqualevpe0_bandwidth_units",
"vnf_id": "123",
"vmxvre_oam_prefix": "24",
- "availability_zone_0": "get_input:2017488_adiodvpe0_availability_zone_0",
- "ASN": "get_input:2017488_adiodvpe0_ASN",
+ "availability_zone_0": "get_input:2017488_pasqualevpe0_availability_zone_0",
+ "ASN": "get_input:2017488_pasqualevpe0_ASN",
"vmxvre_chassis_i2cid": "161",
"vmxvpfe_name_0": "vPFEXI",
- "bandwidth": "get_input:2017488_adiodvpe0_bandwidth",
+ "bandwidth": "get_input:2017488_pasqualevpe0_bandwidth",
"availability_zone_max_count": "1",
"vmxvre_volume_size_0": "45.0",
"vmxvre_volume_size_1": "50.0",
"vmxvpfe_sriov42_0_port_broadcastallow": "true",
- "vmxvre_oam_gateway": "10.40.123.1",
+ "vmxvre_oam_gateway": "10.0.0.10",
"vmxvre_volume_name_1": "vREXI_FAVolume",
"vmxvre_ore_present": "0",
"vmxvre_volume_name_0": "vREXI_FBVolume",
"vmxvre_type": "0",
- "vnf_instance_name": "get_input:2017488_adiodvpe0_vnf_instance_name",
+ "vnf_instance_name": "get_input:2017488_pasqualevpe0_vnf_instance_name",
"vmxvpfe_sriov41_0_port_unknownmulticastallow": "true",
"oam_net_id": "b95eeb1d-d55d-4827-abb4-8ebb94941429",
"vmx_int_ctl_len": "24",
@@ -126,32 +126,32 @@
"ecomp_generated_naming": "true"
},
"type": "VF",
- "modelCustomizationName": "2017-488_ADIOD-vPE 0",
+ "modelCustomizationName": "2017-488_PASQUALE-vPE 0",
"vfModules": {
- "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vRE_BV..module-1": {
+ "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vRE_BV..module-1": {
"uuid": "a5d8df05-11cb-4351-96e0-b6d4168ea4df",
"invariantUuid": "7253ff5c-97f0-4b8b-937c-77aeb4d79aa1",
"customizationUuid": "f3d97417-0c8d-424e-8ff7-b2eb4fbcecc3",
"description": null,
- "name": "2017488AdiodVpe..ADIOD_vRE_BV..module-1",
+ "name": "2017488PasqualeVpe..PASQUALE_vRE_BV..module-1",
"version": "8",
- "modelCustomizationName": "2017488AdiodVpe..ADIOD_vRE_BV..module-1",
+ "modelCustomizationName": "2017488PasqualeVpe..PASQUALE_vRE_BV..module-1",
"properties": {
"minCountInstances": 0,
"maxCountInstances": null,
"initialCount": 0,
- "vfModuleLabel": "ADIOD_vRE_BV",
+ "vfModuleLabel": "PASQUALE_vRE_BV",
"baseModule" : false
},
"inputs": {
"bandwidth_units": {
- "fromInputName": "2017488_adiodvpe0_bandwidth_units",
+ "fromInputName": "2017488_pasqualevpe0_bandwidth_units",
"type": "string",
"description": "Units of bandwidth",
"entry_schema": null,
"inputProperties": {
"sourceType": "HEAT",
- "vfModuleLabel": "ADIOD_vRE_BV",
+ "vfModuleLabel": "PASQUALE_vRE_BV",
"paramName": "bandwidth_units"
},
"constraints": null,
@@ -159,13 +159,13 @@
"default": "Gbps"
},
"bandwidth": {
- "fromInputName": "2017488_adiodvpe0_bandwidth",
+ "fromInputName": "2017488_pasqualevpe0_bandwidth",
"type": "string",
"description": "Requested VPE bandwidth",
"entry_schema": null,
"inputProperties": {
"sourceType": "HEAT",
- "vfModuleLabel": "ADIOD_vRE_BV",
+ "vfModuleLabel": "PASQUALE_vRE_BV",
"paramName": "bandwidth"
},
"constraints": null,
@@ -173,13 +173,13 @@
"default": "10"
},
"vnf_instance_name": {
- "fromInputName": "2017488_adiodvpe0_vnf_instance_name",
+ "fromInputName": "2017488_pasqualevpe0_vnf_instance_name",
"type": "string",
"description": "The hostname assigned to the vpe.",
"entry_schema": null,
"inputProperties": {
"sourceType": "HEAT",
- "vfModuleLabel": "ADIOD_vRE_BV",
+ "vfModuleLabel": "PASQUALE_vRE_BV",
"paramName": "vnf_instance_name"
},
"constraints": null,
@@ -187,13 +187,13 @@
"default": "mtnj309me6"
},
"vnf_config_template_version": {
- "fromInputName": "2017488_adiodvpe0_vnf_config_template_version",
+ "fromInputName": "2017488_pasqualevpe0_vnf_config_template_version",
"type": "string",
"description": "VPE Software Version",
"entry_schema": null,
"inputProperties": {
"sourceType": "HEAT",
- "vfModuleLabel": "ADIOD_vRE_BV",
+ "vfModuleLabel": "PASQUALE_vRE_BV",
"paramName": "vnf_config_template_version"
},
"constraints": null,
@@ -201,13 +201,13 @@
"default": "17.2"
},
"AIC_CLLI": {
- "fromInputName": "2017488_adiodvpe0_AIC_CLLI",
+ "fromInputName": "2017488_pasqualevpe0_AIC_CLLI",
"type": "string",
"description": "AIC Site CLLI",
"entry_schema": null,
"inputProperties": {
"sourceType": "HEAT",
- "vfModuleLabel": "ADIOD_vRE_BV",
+ "vfModuleLabel": "PASQUALE_vRE_BV",
"paramName": "AIC_CLLI"
},
"constraints": null,
@@ -217,19 +217,19 @@
},
"volumeGroupAllowed": true
},
- "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_base_vPE_BV..module-0": {
+ "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0": {
"uuid": "040e591e-5d30-4e0d-850f-7266e5a8e013",
"invariantUuid": "b34833bb-6aa9-4ad6-a831-70b06367a091",
"customizationUuid": "5c5f91f9-5e31-4120-b892-5536587ec258",
"description": null,
- "name": "2017488AdiodVpe..ADIOD_base_vPE_BV..module-0",
+ "name": "2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0",
"version": "6",
- "modelCustomizationName": "2017488AdiodVpe..ADIOD_base_vPE_BV..module-0",
+ "modelCustomizationName": "2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0",
"properties": {
"minCountInstances": 1,
"maxCountInstances": 1,
"initialCount": 1,
- "vfModuleLabel": "ADIOD_base_vPE_BV",
+ "vfModuleLabel": "PASQUALE_base_vPE_BV",
"baseModule" : true
},
"inputs": {
@@ -237,30 +237,30 @@
},
"volumeGroupAllowed": false
},
- "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vPFE_BV..module-2": {
+ "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vPFE_BV..module-2": {
"uuid": "b3e8b26e-cff0-49fc-a4e6-f3e16c8440fe",
"invariantUuid": "eff8cc59-53a1-4101-aed7-8cf24ecf8339",
"customizationUuid": "6e410843-257c-46d9-ba8a-8d94e1362452",
"description": null,
- "name": "2017488AdiodVpe..ADIOD_vPFE_BV..module-2",
+ "name": "2017488PasqualeVpe..PASQUALE_vPFE_BV..module-2",
"version": "8",
- "modelCustomizationName": "2017488AdiodVpe..ADIOD_vPFE_BV..module-2",
+ "modelCustomizationName": "2017488PasqualeVpe..PASQUALE_vPFE_BV..module-2",
"properties": {
"minCountInstances": 0,
"maxCountInstances": null,
"initialCount": 0,
- "vfModuleLabel": "ADIOD_vPFE_BV",
+ "vfModuleLabel": "PASQUALE_vPFE_BV",
"baseModule" : false
},
"inputs": {
"availability_zone_0": {
- "fromInputName": "2017488_adiodvpe0_availability_zone_0",
+ "fromInputName": "2017488_pasqualevpe0_availability_zone_0",
"type": "string",
"description": "The Availability Zone to launch the instance.",
"entry_schema": null,
"inputProperties": {
"sourceType": "HEAT",
- "vfModuleLabel": "ADIOD_vPFE_BV",
+ "vfModuleLabel": "PASQUALE_vPFE_BV",
"paramName": "availability_zone_0"
},
"constraints": null,
@@ -272,29 +272,29 @@
}
},
"volumeGroups": {
- "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vRE_BV..module-1": {
+ "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vRE_BV..module-1": {
"uuid": "a5d8df05-11cb-4351-96e0-b6d4168ea4df",
"invariantUuid": "7253ff5c-97f0-4b8b-937c-77aeb4d79aa1",
"customizationUuid": "f3d97417-0c8d-424e-8ff7-b2eb4fbcecc3",
"description": null,
- "name": "2017488AdiodVpe..ADIOD_vRE_BV..module-1",
+ "name": "2017488PasqualeVpe..PASQUALE_vRE_BV..module-1",
"version": "8",
- "modelCustomizationName": "2017488AdiodVpe..ADIOD_vRE_BV..module-1",
+ "modelCustomizationName": "2017488PasqualeVpe..PASQUALE_vRE_BV..module-1",
"properties": {
"minCountInstances": 0,
"maxCountInstances": null,
"initialCount": 0,
- "vfModuleLabel": "ADIOD_vRE_BV"
+ "vfModuleLabel": "PASQUALE_vRE_BV"
},
"inputs": {
"bandwidth_units": {
- "fromInputName": "2017488_adiodvpe0_bandwidth_units",
+ "fromInputName": "2017488_pasqualevpe0_bandwidth_units",
"type": "string",
"description": "Units of bandwidth",
"entry_schema": null,
"inputProperties": {
"sourceType": "HEAT",
- "vfModuleLabel": "ADIOD_vRE_BV",
+ "vfModuleLabel": "PASQUALE_vRE_BV",
"paramName": "bandwidth_units"
},
"constraints": null,
@@ -302,13 +302,13 @@
"default": "Gbps"
},
"bandwidth": {
- "fromInputName": "2017488_adiodvpe0_bandwidth",
+ "fromInputName": "2017488_pasqualevpe0_bandwidth",
"type": "string",
"description": "Requested VPE bandwidth",
"entry_schema": null,
"inputProperties": {
"sourceType": "HEAT",
- "vfModuleLabel": "ADIOD_vRE_BV",
+ "vfModuleLabel": "PASQUALE_vRE_BV",
"paramName": "bandwidth"
},
"constraints": null,
@@ -316,13 +316,13 @@
"default": "10"
},
"vnf_instance_name": {
- "fromInputName": "2017488_adiodvpe0_vnf_instance_name",
+ "fromInputName": "2017488_pasqualevpe0_vnf_instance_name",
"type": "string",
"description": "The hostname assigned to the vpe.",
"entry_schema": null,
"inputProperties": {
"sourceType": "HEAT",
- "vfModuleLabel": "ADIOD_vRE_BV",
+ "vfModuleLabel": "PASQUALE_vRE_BV",
"paramName": "vnf_instance_name"
},
"constraints": null,
@@ -330,13 +330,13 @@
"default": "mtnj309me6"
},
"vnf_config_template_version": {
- "fromInputName": "2017488_adiodvpe0_vnf_config_template_version",
+ "fromInputName": "2017488_pasqualevpe0_vnf_config_template_version",
"type": "string",
"description": "VPE Software Version",
"entry_schema": null,
"inputProperties": {
"sourceType": "HEAT",
- "vfModuleLabel": "ADIOD_vRE_BV",
+ "vfModuleLabel": "PASQUALE_vRE_BV",
"paramName": "vnf_config_template_version"
},
"constraints": null,
@@ -344,13 +344,13 @@
"default": "17.2"
},
"AIC_CLLI": {
- "fromInputName": "2017488_adiodvpe0_AIC_CLLI",
+ "fromInputName": "2017488_pasqualevpe0_AIC_CLLI",
"type": "string",
"description": "AIC Site CLLI",
"entry_schema": null,
"inputProperties": {
"sourceType": "HEAT",
- "vfModuleLabel": "ADIOD_vRE_BV",
+ "vfModuleLabel": "PASQUALE_vRE_BV",
"paramName": "AIC_CLLI"
},
"constraints": null,
@@ -359,29 +359,29 @@
}
}
},
- "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vPFE_BV..module-2": {
+ "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vPFE_BV..module-2": {
"uuid": "b3e8b26e-cff0-49fc-a4e6-f3e16c8440fe",
"invariantUuid": "eff8cc59-53a1-4101-aed7-8cf24ecf8339",
"customizationUuid": "6e410843-257c-46d9-ba8a-8d94e1362452",
"description": null,
- "name": "2017488AdiodVpe..ADIOD_vPFE_BV..module-2",
+ "name": "2017488PasqualeVpe..PASQUALE_vPFE_BV..module-2",
"version": "8",
- "modelCustomizationName": "2017488AdiodVpe..ADIOD_vPFE_BV..module-2",
+ "modelCustomizationName": "2017488PasqualeVpe..PASQUALE_vPFE_BV..module-2",
"properties": {
"minCountInstances": 0,
"maxCountInstances": null,
"initialCount": 0,
- "vfModuleLabel": "ADIOD_vPFE_BV"
+ "vfModuleLabel": "PASQUALE_vPFE_BV"
},
"inputs": {
"availability_zone_0": {
- "fromInputName": "2017488_adiodvpe0_availability_zone_0",
+ "fromInputName": "2017488_pasqualevpe0_availability_zone_0",
"type": "string",
"description": "The Availability Zone to launch the instance.",
"entry_schema": null,
"inputProperties": {
"sourceType": "HEAT",
- "vfModuleLabel": "ADIOD_vPFE_BV",
+ "vfModuleLabel": "PASQUALE_vPFE_BV",
"paramName": "availability_zone_0"
},
"constraints": null,
@@ -396,7 +396,7 @@
"networks": {
},
- "collectionResource": {
+ "collectionResources": {
},
"configurations": {
@@ -406,30 +406,30 @@
},
"vfModules": {
- "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vRE_BV..module-1": {
+ "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vRE_BV..module-1": {
"uuid": "a5d8df05-11cb-4351-96e0-b6d4168ea4df",
"invariantUuid": "7253ff5c-97f0-4b8b-937c-77aeb4d79aa1",
"customizationUuid": "f3d97417-0c8d-424e-8ff7-b2eb4fbcecc3",
"description": null,
- "name": "2017488AdiodVpe..ADIOD_vRE_BV..module-1",
+ "name": "2017488PasqualeVpe..PASQUALE_vRE_BV..module-1",
"version": "8",
- "modelCustomizationName": "2017488AdiodVpe..ADIOD_vRE_BV..module-1",
+ "modelCustomizationName": "2017488PasqualeVpe..PASQUALE_vRE_BV..module-1",
"properties": {
"minCountInstances": 0,
"maxCountInstances": null,
"initialCount": 0,
- "vfModuleLabel": "ADIOD_vRE_BV",
+ "vfModuleLabel": "PASQUALE_vRE_BV",
"baseModule" : false
},
"inputs": {
"bandwidth_units": {
- "fromInputName": "2017488_adiodvpe0_bandwidth_units",
+ "fromInputName": "2017488_pasqualevpe0_bandwidth_units",
"type": "string",
"description": "Units of bandwidth",
"entry_schema": null,
"inputProperties": {
"sourceType": "HEAT",
- "vfModuleLabel": "ADIOD_vRE_BV",
+ "vfModuleLabel": "PASQUALE_vRE_BV",
"paramName": "bandwidth_units"
},
"constraints": null,
@@ -437,13 +437,13 @@
"default": "Gbps"
},
"bandwidth": {
- "fromInputName": "2017488_adiodvpe0_bandwidth",
+ "fromInputName": "2017488_pasqualevpe0_bandwidth",
"type": "string",
"description": "Requested VPE bandwidth",
"entry_schema": null,
"inputProperties": {
"sourceType": "HEAT",
- "vfModuleLabel": "ADIOD_vRE_BV",
+ "vfModuleLabel": "PASQUALE_vRE_BV",
"paramName": "bandwidth"
},
"constraints": null,
@@ -451,13 +451,13 @@
"default": "10"
},
"vnf_instance_name": {
- "fromInputName": "2017488_adiodvpe0_vnf_instance_name",
+ "fromInputName": "2017488_pasqualevpe0_vnf_instance_name",
"type": "string",
"description": "The hostname assigned to the vpe.",
"entry_schema": null,
"inputProperties": {
"sourceType": "HEAT",
- "vfModuleLabel": "ADIOD_vRE_BV",
+ "vfModuleLabel": "PASQUALE_vRE_BV",
"paramName": "vnf_instance_name"
},
"constraints": null,
@@ -465,13 +465,13 @@
"default": "mtnj309me6"
},
"vnf_config_template_version": {
- "fromInputName": "2017488_adiodvpe0_vnf_config_template_version",
+ "fromInputName": "2017488_pasqualevpe0_vnf_config_template_version",
"type": "string",
"description": "VPE Software Version",
"entry_schema": null,
"inputProperties": {
"sourceType": "HEAT",
- "vfModuleLabel": "ADIOD_vRE_BV",
+ "vfModuleLabel": "PASQUALE_vRE_BV",
"paramName": "vnf_config_template_version"
},
"constraints": null,
@@ -479,13 +479,13 @@
"default": "17.2"
},
"AIC_CLLI": {
- "fromInputName": "2017488_adiodvpe0_AIC_CLLI",
+ "fromInputName": "2017488_pasqualevpe0_AIC_CLLI",
"type": "string",
"description": "AIC Site CLLI",
"entry_schema": null,
"inputProperties": {
"sourceType": "HEAT",
- "vfModuleLabel": "ADIOD_vRE_BV",
+ "vfModuleLabel": "PASQUALE_vRE_BV",
"paramName": "AIC_CLLI"
},
"constraints": null,
@@ -495,19 +495,19 @@
},
"volumeGroupAllowed": true
},
- "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_base_vPE_BV..module-0": {
+ "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0": {
"uuid": "040e591e-5d30-4e0d-850f-7266e5a8e013",
"invariantUuid": "b34833bb-6aa9-4ad6-a831-70b06367a091",
"customizationUuid": "5c5f91f9-5e31-4120-b892-5536587ec258",
"description": null,
- "name": "2017488AdiodVpe..ADIOD_base_vPE_BV..module-0",
+ "name": "2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0",
"version": "6",
- "modelCustomizationName": "2017488AdiodVpe..ADIOD_base_vPE_BV..module-0",
+ "modelCustomizationName": "2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0",
"properties": {
"minCountInstances": 1,
"maxCountInstances": 1,
"initialCount": 1,
- "vfModuleLabel": "ADIOD_base_vPE_BV",
+ "vfModuleLabel": "PASQUALE_base_vPE_BV",
"baseModule" : true
},
"inputs": {
@@ -515,30 +515,30 @@
},
"volumeGroupAllowed": false
},
- "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vPFE_BV..module-2": {
+ "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vPFE_BV..module-2": {
"uuid": "b3e8b26e-cff0-49fc-a4e6-f3e16c8440fe",
"invariantUuid": "eff8cc59-53a1-4101-aed7-8cf24ecf8339",
"customizationUuid": "6e410843-257c-46d9-ba8a-8d94e1362452",
"description": null,
- "name": "2017488AdiodVpe..ADIOD_vPFE_BV..module-2",
+ "name": "2017488PasqualeVpe..PASQUALE_vPFE_BV..module-2",
"version": "8",
- "modelCustomizationName": "2017488AdiodVpe..ADIOD_vPFE_BV..module-2",
+ "modelCustomizationName": "2017488PasqualeVpe..PASQUALE_vPFE_BV..module-2",
"properties": {
"minCountInstances": 0,
"maxCountInstances": null,
"initialCount": 0,
- "vfModuleLabel": "ADIOD_vPFE_BV",
+ "vfModuleLabel": "PASQUALE_vPFE_BV",
"baseModule" : false
},
"inputs": {
"availability_zone_0": {
- "fromInputName": "2017488_adiodvpe0_availability_zone_0",
+ "fromInputName": "2017488_pasqualevpe0_availability_zone_0",
"type": "string",
"description": "The Availability Zone to launch the instance.",
"entry_schema": null,
"inputProperties": {
"sourceType": "HEAT",
- "vfModuleLabel": "ADIOD_vPFE_BV",
+ "vfModuleLabel": "PASQUALE_vPFE_BV",
"paramName": "availability_zone_0"
},
"constraints": null,
@@ -550,30 +550,30 @@
}
},
"volumeGroups": {
- "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vRE_BV..module-1": {
+ "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vRE_BV..module-1": {
"uuid": "a5d8df05-11cb-4351-96e0-b6d4168ea4df",
"invariantUuid": "7253ff5c-97f0-4b8b-937c-77aeb4d79aa1",
"customizationUuid": "f3d97417-0c8d-424e-8ff7-b2eb4fbcecc3",
"description": null,
- "name": "2017488AdiodVpe..ADIOD_vRE_BV..module-1",
+ "name": "2017488PasqualeVpe..PASQUALE_vRE_BV..module-1",
"version": "8",
- "modelCustomizationName": "2017488AdiodVpe..ADIOD_vRE_BV..module-1",
+ "modelCustomizationName": "2017488PasqualeVpe..PASQUALE_vRE_BV..module-1",
"properties": {
"minCountInstances": 0,
"maxCountInstances": null,
"initialCount": 0,
- "vfModuleLabel": "ADIOD_vRE_BV",
+ "vfModuleLabel": "PASQUALE_vRE_BV",
"baseModule" : false
},
"inputs": {
"bandwidth_units": {
- "fromInputName": "2017488_adiodvpe0_bandwidth_units",
+ "fromInputName": "2017488_pasqualevpe0_bandwidth_units",
"type": "string",
"description": "Units of bandwidth",
"entry_schema": null,
"inputProperties": {
"sourceType": "HEAT",
- "vfModuleLabel": "ADIOD_vRE_BV",
+ "vfModuleLabel": "PASQUALE_vRE_BV",
"paramName": "bandwidth_units"
},
"constraints": null,
@@ -581,13 +581,13 @@
"default": "Gbps"
},
"bandwidth": {
- "fromInputName": "2017488_adiodvpe0_bandwidth",
+ "fromInputName": "2017488_pasqualevpe0_bandwidth",
"type": "string",
"description": "Requested VPE bandwidth",
"entry_schema": null,
"inputProperties": {
"sourceType": "HEAT",
- "vfModuleLabel": "ADIOD_vRE_BV",
+ "vfModuleLabel": "PASQUALE_vRE_BV",
"paramName": "bandwidth"
},
"constraints": null,
@@ -595,13 +595,13 @@
"default": "10"
},
"vnf_instance_name": {
- "fromInputName": "2017488_adiodvpe0_vnf_instance_name",
+ "fromInputName": "2017488_pasqualevpe0_vnf_instance_name",
"type": "string",
"description": "The hostname assigned to the vpe.",
"entry_schema": null,
"inputProperties": {
"sourceType": "HEAT",
- "vfModuleLabel": "ADIOD_vRE_BV",
+ "vfModuleLabel": "PASQUALE_vRE_BV",
"paramName": "vnf_instance_name"
},
"constraints": null,
@@ -609,13 +609,13 @@
"default": "mtnj309me6"
},
"vnf_config_template_version": {
- "fromInputName": "2017488_adiodvpe0_vnf_config_template_version",
+ "fromInputName": "2017488_pasqualevpe0_vnf_config_template_version",
"type": "string",
"description": "VPE Software Version",
"entry_schema": null,
"inputProperties": {
"sourceType": "HEAT",
- "vfModuleLabel": "ADIOD_vRE_BV",
+ "vfModuleLabel": "PASQUALE_vRE_BV",
"paramName": "vnf_config_template_version"
},
"constraints": null,
@@ -623,13 +623,13 @@
"default": "17.2"
},
"AIC_CLLI": {
- "fromInputName": "2017488_adiodvpe0_AIC_CLLI",
+ "fromInputName": "2017488_pasqualevpe0_AIC_CLLI",
"type": "string",
"description": "AIC Site CLLI",
"entry_schema": null,
"inputProperties": {
"sourceType": "HEAT",
- "vfModuleLabel": "ADIOD_vRE_BV",
+ "vfModuleLabel": "PASQUALE_vRE_BV",
"paramName": "AIC_CLLI"
},
"constraints": null,
@@ -638,30 +638,30 @@
}
}
},
- "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vPFE_BV..module-2": {
+ "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vPFE_BV..module-2": {
"uuid": "b3e8b26e-cff0-49fc-a4e6-f3e16c8440fe",
"invariantUuid": "eff8cc59-53a1-4101-aed7-8cf24ecf8339",
"customizationUuid": "6e410843-257c-46d9-ba8a-8d94e1362452",
"description": null,
- "name": "2017488AdiodVpe..ADIOD_vPFE_BV..module-2",
+ "name": "2017488PasqualeVpe..PASQUALE_vPFE_BV..module-2",
"version": "8",
- "modelCustomizationName": "2017488AdiodVpe..ADIOD_vPFE_BV..module-2",
+ "modelCustomizationName": "2017488PasqualeVpe..PASQUALE_vPFE_BV..module-2",
"properties": {
"minCountInstances": 0,
"maxCountInstances": null,
"initialCount": 0,
- "vfModuleLabel": "ADIOD_vPFE_BV",
+ "vfModuleLabel": "PASQUALE_vPFE_BV",
"baseModule" : false
},
"inputs": {
"availability_zone_0": {
- "fromInputName": "2017488_adiodvpe0_availability_zone_0",
+ "fromInputName": "2017488_pasqualevpe0_availability_zone_0",
"type": "string",
"description": "The Availability Zone to launch the instance.",
"entry_schema": null,
"inputProperties": {
"sourceType": "HEAT",
- "vfModuleLabel": "ADIOD_vPFE_BV",
+ "vfModuleLabel": "PASQUALE_vPFE_BV",
"paramName": "availability_zone_0"
},
"constraints": null,
@@ -674,5 +674,8 @@
"pnfs": {
},
- "vnfGroups": {}
+ "vnfGroups": {},
+ "vrfs": {
+
+ }
} \ No newline at end of file
diff --git a/vid-app-common/src/test/resources/vf-with-vfcInstanceGroups.json b/vid-app-common/src/test/resources/vf-with-vfcInstanceGroups.json
index 3b7e2e854..34e2d45b8 100644
--- a/vid-app-common/src/test/resources/vf-with-vfcInstanceGroups.json
+++ b/vid-app-common/src/test/resources/vf-with-vfcInstanceGroups.json
@@ -2,13 +2,13 @@
"service": {
"uuid": "6bce7302-70bd-4057-b48e-8d5b99e686ca",
"invariantUuid": "9aa04749-c02c-432d-a90c-18caa361c833",
- "name": "vDBE_srv",
+ "name": "vDOROTHEA_srv",
"version": "1.0",
"toscaModelURL": null,
"category": "Network L4+",
"serviceType": "",
"serviceRole": "",
- "description": "vDBE_srv",
+ "description": "vDOROTHEA_srv",
"serviceEcompNaming": "true",
"instantiationType": "A-La-Carte",
"inputs": {
@@ -16,11 +16,11 @@
}
},
"vnfs": {
- "vDBE 0": {
+ "vDOROTHEA 0": {
"uuid": "61535073-2e50-4141-9000-f66fea69b433",
"invariantUuid": "fcdf49ce-6f0b-4ca2-b676-a484e650e734",
- "description": "vDBE",
- "name": "vDBE",
+ "description": "vDOROTHEA",
+ "name": "vDOROTHEA",
"version": "0.2",
"customizationUuid": "882e5dcb-ba9f-4766-8cde-e326638107db",
"inputs": {
@@ -40,16 +40,16 @@
"untr_network_collection_function": "untraaa"
},
"type": "VF",
- "modelCustomizationName": "vDBE 0",
+ "modelCustomizationName": "vDOROTHEA 0",
"vfModules": {
- "vdbe0..Vdbe..main..module-0": {
+ "vdorothea0..Vdorothea..main..module-0": {
"uuid": "25a4d009-2f5a-44b4-b02a-62c584c15912",
"invariantUuid": "614afb1a-3e7e-44e9-90ab-424d0070c781",
"customizationUuid": "3443b341-7b0b-498c-a84a-a7ee736cba7e",
"description": null,
- "name": "Vdbe..main..module-0",
+ "name": "Vdorothea..main..module-0",
"version": "1",
- "modelCustomizationName": "Vdbe..main..module-0",
+ "modelCustomizationName": "Vdorothea..main..module-0",
"properties": {
"minCountInstances": 1,
"maxCountInstances": 1,
@@ -97,7 +97,7 @@
"networks": {
},
- "collectionResource": {
+ "collectionResources": {
},
"configurations": {
@@ -107,14 +107,14 @@
},
"vfModules": {
- "vdbe0..Vdbe..main..module-0": {
+ "vdorothea0..Vdorothea..main..module-0": {
"uuid": "25a4d009-2f5a-44b4-b02a-62c584c15912",
"invariantUuid": "614afb1a-3e7e-44e9-90ab-424d0070c781",
"customizationUuid": "3443b341-7b0b-498c-a84a-a7ee736cba7e",
"description": null,
- "name": "Vdbe..main..module-0",
+ "name": "Vdorothea..main..module-0",
"version": "1",
- "modelCustomizationName": "Vdbe..main..module-0",
+ "modelCustomizationName": "Vdorothea..main..module-0",
"properties": {
"minCountInstances": 1,
"maxCountInstances": 1,
@@ -134,5 +134,8 @@
"pnfs": {
},
- "vnfGroups": {}
+ "vnfGroups": {},
+ "vrfs": {
+
+ }
} \ No newline at end of file
diff --git a/vid-app-common/src/test/resources/vl-csar.JSON b/vid-app-common/src/test/resources/vl-csar.JSON
index 3de6ee460..cdf2125d4 100644
--- a/vid-app-common/src/test/resources/vl-csar.JSON
+++ b/vid-app-common/src/test/resources/vl-csar.JSON
@@ -75,7 +75,7 @@
"modelCustomizationName": "ExtVL 0"
}
},
- "collectionResource": {
+ "collectionResources": {
},
"configurations": {
@@ -93,5 +93,8 @@
"pnfs": {
},
- "vnfGroups": {}
+ "vnfGroups": {},
+ "vrfs": {
+
+ }
} \ No newline at end of file
diff --git a/vid-app-common/src/test/resources/vnf-grouping-csar.json b/vid-app-common/src/test/resources/vnf-grouping-csar.json
index 4c6f1d9c5..ebf2204bd 100644
--- a/vid-app-common/src/test/resources/vnf-grouping-csar.json
+++ b/vid-app-common/src/test/resources/vnf-grouping-csar.json
@@ -18,18 +18,18 @@
},
"networks": {
},
- "collectionResource": {
+ "collectionResources": {
},
"configurations": {
},
"fabricConfigurations": {
},
"serviceProxies": {
- "vdbe_svc_vprs_proxy 0": {
+ "vdorothea_svc_vprs_proxy 0": {
"uuid": "65fadfa8-a0d9-443f-95ad-836cd044e26c",
"invariantUuid": "f4baae0c-b3a5-4ca1-a777-afbffe7010bc",
- "description": "A Proxy for Service vDBE_Svc_vPRS",
- "name": "vDBE_Svc_vPRS Service Proxy",
+ "description": "A Proxy for Service vDOROTHEA_Svc_vPRS",
+ "name": "vDOROTHEA_Svc_vPRS Service Proxy",
"version": "1.0",
"customizationUuid": "bdb63d23-e132-4ce7-af2c-a493b4cafac9",
"inputs": {
@@ -42,7 +42,7 @@
"type": "Service Proxy",
"sourceModelUuid": "da7827a2-366d-4be6-8c68-a69153c61274",
"sourceModelInvariant": "24632e6b-584b-4f45-80d4-fefd75fd9f14",
- "sourceModelName": "vDBE_Svc_vPRS"
+ "sourceModelName": "vDOROTHEA_Svc_vPRS"
},
"tsbc0001vm001_svc_proxy 0": {
"uuid": "65fadfa8-a0d9-443f-95ad-836cd044e26c",
@@ -87,11 +87,11 @@
"ecomp_generated_naming": "true"
},
"members": {
- "vdbe_svc_vprs_proxy 0": {
+ "vdorothea_svc_vprs_proxy 0": {
"uuid": "65fadfa8-a0d9-443f-95ad-836cd044e26c",
"invariantUuid": "f4baae0c-b3a5-4ca1-a777-afbffe7010bc",
- "description": "A Proxy for Service vDBE_Svc_vPRS",
- "name": "vDBE_Svc_vPRS Service Proxy",
+ "description": "A Proxy for Service vDOROTHEA_Svc_vPRS",
+ "name": "vDOROTHEA_Svc_vPRS Service Proxy",
"version": "1.0",
"customizationUuid": "bdb63d23-e132-4ce7-af2c-a493b4cafac9",
"inputs": {},
@@ -102,7 +102,7 @@
"type": "Service Proxy",
"sourceModelUuid": "da7827a2-366d-4be6-8c68-a69153c61274",
"sourceModelInvariant": "24632e6b-584b-4f45-80d4-fefd75fd9f14",
- "sourceModelName": "vDBE_Svc_vPRS"
+ "sourceModelName": "vDOROTHEA_Svc_vPRS"
}
}
},
@@ -119,7 +119,8 @@
"function": "SIGNALING",
"description": "DDD1",
"type": "LOAD-GROUP",
- "ecomp_generated_naming": "true"
+ "ecomp_generated_naming": "true",
+ "quantity": 3
},
"members": {
"tsbc0001vm001_svc_proxy 0": {
@@ -141,5 +142,8 @@
}
}
}
+ },
+ "vrfs": {
+
}
} \ No newline at end of file