summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adapters/mso-adapter-utils/pom.xml18
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/AllTestsTestSuite.java32
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/BaseTest.java32
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/StubOpenStack.java76
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java37
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoKeystoneUtilsTest.java32
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoMulticloudUtilsTest.java43
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoNeutronUtilsTest.java22
-rw-r--r--adapters/mso-catalog-db-adapter/pom.xml18
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/AllTestsTestSuite.java32
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/CatalogDbAdapterBaseTest.java21
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java28
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CloudConfigTest.java6
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CvnfcCatalogDbQueryTest.java6
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/NetworkCollectionCatalogDbQueryTest.java6
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java6
-rw-r--r--adapters/mso-openstack-adapters/pom.xml18
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MSONetworkAdapterImplTest.java148
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImplTest.java77
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java62
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/TenantAdapterRestTest.java32
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/valet/ValetClientTest.java10
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/AllTestsTestSuite.java32
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/BaseRestTestUtils.java45
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImplTest.java45
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java172
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImplTest.java49
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java42
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImplTest.java46
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VnfAdapterRestTest.java72
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestTest.java44
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2Test.java44
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/bpmn/mock/StubOpenStack.java279
-rw-r--r--adapters/mso-requests-db-adapter/pom.xml18
-rw-r--r--adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/AllTestsTestSuite.java32
-rw-r--r--adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsSchedulerTest.java16
-rw-r--r--adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/InfraActiveRequestsRepositoryCustomControllerTest.java34
-rw-r--r--adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/RequestsAdapterBase.java14
-rw-r--r--adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/HealthCheckHandlerTest.java19
-rw-r--r--adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/MSORequestDBImplTest.java56
-rw-r--r--adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java6
-rw-r--r--adapters/mso-sdnc-adapter/pom.xml18
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/AllTestsTestSuite.java32
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/BaseTest.java8
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/SDNCRestClientTest.java5
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/BPRestCallbackTest.java12
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/SDNCConnectorTest.java13
-rw-r--r--adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/rest/VfcManagerTest.java157
-rw-r--r--asdc-controller/pom.xml21
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java4539
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/AllTestsTestSuite.java32
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/BaseTest.java5
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java7
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java3
-rw-r--r--bpmn/MSOCommonBPMN/pom.xml3
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy2
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy4
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy4
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV2.groovy4
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy4
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/DelegateExecutionImpl.java219
-rw-r--r--bpmn/MSOCommonBPMN/src/main/resources/subprocess/SDNCAdapterRestV1.bpmn3
-rw-r--r--bpmn/MSOCommonBPMN/src/main/resources/subprocess/SDNCAdapterRestV2.bpmn3
-rw-r--r--bpmn/MSOCommonBPMN/src/main/resources/subprocess/VnfAdapterRestV1.bpmn3
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModuleTest.groovy2
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SniroHomingV1Test.groovy3
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnfTest.groovy2
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModuleTest.groovy3
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BaseTest.java9
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/DelegateExecutionImplTest.java208
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/MockAAIDeleteGenericVnf.java9
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/MockAAIDeleteVfModule.java17
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/MockAAIGenericVnfSearch.java33
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/baseclient/BaseClientTest.java6
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/recipe/BpmnRestClientTest.java15
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilderTest.java22
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseAAI.java550
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseAPPC.java14
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseDatabase.java45
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseNetworkAdapter.java41
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseOof.java19
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponsePolicy.java32
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseSDNCAdapter.java43
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseSNIRO.java19
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseVNFAdapter.java88
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/BaseIntegrationTest.java6
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/CompleteMsoProcessIT.java2
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/ConfirmVolumeGroupNameIT.java6
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/ConfirmVolumeGroupTenantIT.java4
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/CreateAAIVfModuleIT.java66
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/CreateAAIVfModuleVolumeGroupIT.java10
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/DecomposeServiceIT.java4
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/DeleteAAIVfModuleIT.java56
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/FalloutHandlerIT.java5
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/GenerateVfModuleNameIT.java2
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/ManualHandlingIT.java2
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/MockAAIDeleteGenericVnf.java9
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/MockAAIDeleteVfModule.java17
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/MockAAIGenericVnfSearch.java33
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/OofHomingIT.java18
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/OofHomingTestIT.java18
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/PrepareUpdateAAIVfModuleIT.java16
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/RainyDayHandlerIT.java2
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/SDNCAdapterRestV2IT.java3
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/SniroHomingV1IT.java18
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/UpdateAAIGenericVnfIT.java16
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/UpdateAAIVfModuleIT.java14
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/VnfAdapterRestV1IT.java10
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/CreateVcpeResCustServiceIT.java205
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DeleteVcpeResCustServiceIT.java82
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceBRGIT.java84
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceBRGRollbackIT.java76
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceTXCIT.java82
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceTXCRollbackIT.java76
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoDeleteAllottedResourceBRGIT.java36
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoDeleteAllottedResourceTXCIT.java36
-rw-r--r--bpmn/so-bpmn-building-blocks/pom.xml3
-rw-r--r--bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/EtsiVnfDeleteBB.bpmn38
-rw-r--r--bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/EtsiVnfInstantiateBB.bpmn26
-rw-r--r--bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/MonitorVnfmCreateJob.bpmn160
-rw-r--r--bpmn/so-bpmn-infrastructure-common/pom.xml3
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstanceTest.groovy3
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfraTest.groovy3
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceRollbackTest.groovy5
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceTest.groovy3
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollbackTest.groovy3
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleTest.groovy3
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModulesTest.groovy3
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfTest.groovy3
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstanceTest.groovy3
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnfTest.groovy3
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleTest.groovy3
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2Test.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModulesTest.groovy3
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollbackTest.groovy3
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModuleTest.groovy3
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModulesTest.groovy3
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollbackTest.groovy24
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGTest.groovy18
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollbackTest.groovy24
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCTest.groovy18
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRGTest.groovy18
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXCTest.groovy18
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/pom.xml3
-rw-r--r--bpmn/so-bpmn-tasks/pom.xml3
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/Constants.java40
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/EtsiVnfDeleteTask.java84
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmCreateJobTask.java154
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProvider.java11
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImpl.java132
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterUrlProvider.java45
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapper.java13
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java4
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapper.java8
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapper.java8
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java6
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java8
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/BaseIntegrationTest.java8
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/EtsiVnfDeleteTaskTest.java111
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmCreateJobTaskTest.java178
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/StubbedBuildingBlockExecution.java100
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/TestConstants.java7
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTaskTest.java237
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImplTest.java350
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterUrlProviderTest.java12
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/SniroHomingV2IT.java16
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/NetworkAdapterClientIT.java26
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfAdapterClientIT.java26
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterClientIT.java2
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingClientTest.java9
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/oof/OofClientTestIT.java13
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientIT.java7
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapperTest.java1
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapperTest.java21
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapperTest.java8
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java37
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java7
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sniro/SniroClientTestIT.java21
-rw-r--r--common/src/main/java/org/onap/so/client/RestRequest.java5
-rw-r--r--common/src/main/java/org/onap/so/rest/service/HttpRestServiceProvider.java9
-rw-r--r--common/src/main/java/org/onap/so/rest/service/HttpRestServiceProviderImpl.java12
-rw-r--r--common/src/test/java/org/onap/so/client/HttpClientTest.java11
-rw-r--r--common/src/test/java/org/onap/so/client/aai/AAIConfigurationClientTest.java25
-rw-r--r--common/src/test/java/org/onap/so/client/aai/AAIResourcesClientTest.java2
-rw-r--r--common/src/test/java/org/onap/so/client/aai/AAIResourcesClientWithServiceInstanceUriTest.java5
-rw-r--r--common/src/test/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUriTest.java3
-rw-r--r--mso-api-handlers/mso-api-handler-infra/pom.xml1
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java206
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java1
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java14
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java567
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java712
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CustomWorkflowValidation.java64
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/BaseTest.java19
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/E2EServiceInstancesTest.java21
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/InstanceManagementTest.java180
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java6
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java21
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java21
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsTest.java330
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java626
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/TasksHandlerTest.java5
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestrationTest.java40
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestrationTest.java34
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelperTest.java11
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/SDCClientHelperTest.java5
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironmentTest.java38
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java119
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironmentTest.java35
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironmentTest.java40
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironmentTest.java37
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/CustomWorkflowValidationTest.java54
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/client/grm/GRMClientTest.java11
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/SuccessfulValidation/v1ExecuteCustomWorkflow.json18
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ExecuteCustomWorkflow.json18
-rw-r--r--pom.xml3
216 files changed, 8450 insertions, 6116 deletions
diff --git a/adapters/mso-adapter-utils/pom.xml b/adapters/mso-adapter-utils/pom.xml
index f94d5d60b8..ed76354792 100644
--- a/adapters/mso-adapter-utils/pom.xml
+++ b/adapters/mso-adapter-utils/pom.xml
@@ -55,6 +55,24 @@
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-test</id>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <includes>
+ <include>**/AllTestsTestSuite.java</include>
+ </includes>
+ <parallel>suites</parallel>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/AllTestsTestSuite.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/AllTestsTestSuite.java
new file mode 100644
index 0000000000..a74dbf614b
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/AllTestsTestSuite.java
@@ -0,0 +1,32 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 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.so;
+import org.junit.runner.RunWith;
+
+import com.googlecode.junittoolbox.SuiteClasses;
+import com.googlecode.junittoolbox.WildcardPatternSuite;
+
+@RunWith(WildcardPatternSuite.class)
+@SuiteClasses("**/*Test.class")
+public class AllTestsTestSuite {
+ // the class remains empty,
+ // used only as a holder for the above annotations
+}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/BaseTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/BaseTest.java
index 9cfdf53094..82b18d86ed 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/BaseTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/BaseTest.java
@@ -23,7 +23,16 @@
package org.onap.so;
-import com.github.tomakehurst.wiremock.client.WireMock;
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+
+import javax.ws.rs.core.MediaType;
+
import org.apache.http.HttpHeaders;
import org.apache.http.HttpStatus;
import org.junit.After;
@@ -33,20 +42,15 @@ import org.onap.so.db.catalog.beans.AuthenticationType;
import org.onap.so.db.catalog.beans.CloudIdentity;
import org.onap.so.db.catalog.beans.CloudSite;
import org.onap.so.db.catalog.beans.ServerType;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
-import javax.ws.rs.core.MediaType;
-import java.io.BufferedReader;
-import java.io.FileReader;
-import java.io.IOException;
-
-import static com.github.tomakehurst.wiremock.client.WireMock.*;
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+import com.github.tomakehurst.wiremock.WireMockServer;
+import com.github.tomakehurst.wiremock.client.WireMock;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@@ -56,10 +60,12 @@ public abstract class BaseTest extends TestDataSetup {
@Value("${wiremock.server.port}")
protected int wireMockPort;
+ @Autowired
+ protected WireMockServer wireMockServer;
@After
public void after() {
- WireMock.reset();
+ wireMockServer.resetAll();
}
protected static String getBody(String body, int port, String urlPath) throws IOException {
@@ -74,15 +80,15 @@ public abstract class BaseTest extends TestDataSetup {
}
private void mockCloud(CloudIdentity identity, CloudSite cloudSite) throws IOException {
- stubFor(get(urlPathEqualTo("/cloudSite/MTN13")).willReturn(aResponse()
+ wireMockServer.stubFor(get(urlPathEqualTo("/cloudSite/MTN13")).willReturn(aResponse()
.withBody(getBody(mapper.writeValueAsString(cloudSite),wireMockPort, ""))
.withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlPathEqualTo("/cloudSite/DEFAULT")).willReturn(aResponse()
+ wireMockServer.stubFor(get(urlPathEqualTo("/cloudSite/DEFAULT")).willReturn(aResponse()
.withBody(getBody(mapper.writeValueAsString(cloudSite),wireMockPort, ""))
.withHeader(HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlPathEqualTo("/cloudIdentity/mtn13")).willReturn(aResponse()
+ wireMockServer.stubFor(get(urlPathEqualTo("/cloudIdentity/mtn13")).willReturn(aResponse()
.withBody(getBody(mapper.writeValueAsString(identity),wireMockPort, ""))
.withHeader(HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_OK)));
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/StubOpenStack.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/StubOpenStack.java
index 0820076c66..ae3fb8271a 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/StubOpenStack.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/StubOpenStack.java
@@ -27,38 +27,40 @@ import static com.github.tomakehurst.wiremock.client.WireMock.delete;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.put;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
+
import org.apache.http.HttpStatus;
+import com.github.tomakehurst.wiremock.WireMockServer;
+
public class StubOpenStack {
- public static void mockOpenStackResponseAccess(int port) throws IOException {
- stubFor(post(urlPathEqualTo("/v2.0/tokens")).willReturn(aResponse().withHeader("Content-Type", "application/json")
+ public static void mockOpenStackResponseAccess(WireMockServer wireMockServer, int port) throws IOException {
+ wireMockServer.stubFor(post(urlPathEqualTo("/v2.0/tokens")).willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(getBodyFromFile("OpenstackResponse_Access.json", port, "/mockPublicUrl"))
.withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackResponseUnauthorized(int port) throws IOException {
- stubFor(
+ public static void mockOpenStackResponseUnauthorized(WireMockServer wireMockServer, int port) throws IOException {
+ wireMockServer.stubFor(
post(urlPathEqualTo("/v2.0/tokens"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(getBodyFromFile("OpenstackResponse_Access.json", port, "/mockPublicUrl"))
.withStatus(HttpStatus.SC_UNAUTHORIZED)));
}
- public static void mockOpenStackDelete(String id) {
- stubFor(delete(urlMatching("/mockPublicUrl/stacks/" + id)).willReturn(aResponse()
+ public static void mockOpenStackDelete(WireMockServer wireMockServer, String id) {
+ wireMockServer.stubFor(delete(urlMatching("/mockPublicUrl/stacks/" + id)).willReturn(aResponse()
.withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackGet(String id) {
- stubFor(
+ public static void mockOpenStackGet(WireMockServer wireMockServer, String id) {
+ wireMockServer.stubFor(
get(urlPathEqualTo("/mockPublicUrl/stacks/" + id))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBodyFile("OpenstackResponse_Stack_Created.json")
@@ -66,82 +68,82 @@ public class StubOpenStack {
}
- public static void mockOpenStackPostStack_200(String filename) {
- stubFor(post(urlPathEqualTo("/mockPublicUrl/stacks")).willReturn(aResponse()
+ public static void mockOpenStackPostStack_200(WireMockServer wireMockServer, String filename) {
+ wireMockServer.stubFor(post(urlPathEqualTo("/mockPublicUrl/stacks")).willReturn(aResponse()
.withHeader("Content-Type", "application/json")
.withBodyFile(filename).withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackPostTenantWithBodyFile_200() throws IOException {
- stubFor(post(urlPathEqualTo("/mockPublicUrl/tenants"))
+ public static void mockOpenStackPostTenantWithBodyFile_200(WireMockServer wireMockServer) throws IOException {
+ wireMockServer.stubFor(post(urlPathEqualTo("/mockPublicUrl/tenants"))
.willReturn(aResponse().withBodyFile("OpenstackResponse_Tenant.json").withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackGetTenantByName(String tenantName) throws IOException {
- stubFor(get(urlMatching("/mockPublicUrl/tenants/[?]name=" + tenantName))
+ public static void mockOpenStackGetTenantByName(WireMockServer wireMockServer, String tenantName) throws IOException {
+ wireMockServer.stubFor(get(urlMatching("/mockPublicUrl/tenants/[?]name=" + tenantName))
.willReturn(aResponse().withBodyFile("OpenstackResponse_Tenant.json").withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackGetTenantById(String tenantId) throws IOException {
- stubFor(get(urlPathEqualTo("/mockPublicUrl/tenants/tenantId"))
+ public static void mockOpenStackGetTenantById(WireMockServer wireMockServer, String tenantId) throws IOException {
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/tenants/tenantId"))
.willReturn(aResponse().withBodyFile("OpenstackResponse_Tenant.json").withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackDeleteTenantById_200(String tenantId) {
- stubFor(delete(urlPathEqualTo("/mockPublicUrl/tenants/" + tenantId)).willReturn(aResponse()
+ public static void mockOpenStackDeleteTenantById_200(WireMockServer wireMockServer, String tenantId) {
+ wireMockServer.stubFor(delete(urlPathEqualTo("/mockPublicUrl/tenants/" + tenantId)).willReturn(aResponse()
.withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackGetUserById(String user) {
- stubFor(get(urlPathEqualTo("/mockPublicUrl/users/" + user)).willReturn(aResponse()
+ public static void mockOpenStackGetUserById(WireMockServer wireMockServer, String user) {
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/users/" + user)).willReturn(aResponse()
.withHeader("Content-Type", "application/json")
.withBodyFile("OpenstackResponse_User.json").withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackGetUserByName(String userName) {
- stubFor(get(urlMatching("/mockPublicUrl/users/[?]name=" + userName)).willReturn(aResponse()
+ public static void mockOpenStackGetUserByName(WireMockServer wireMockServer, String userName) {
+ wireMockServer.stubFor(get(urlMatching("/mockPublicUrl/users/[?]name=" + userName)).willReturn(aResponse()
.withHeader("Content-Type", "application/json")
.withBodyFile("OpenstackResponse_User.json").withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackGetUserByName_500(String userName) {
- stubFor(get(urlMatching("/mockPublicUrl/users/[?]name=" + userName)).willReturn(aResponse()
+ public static void mockOpenStackGetUserByName_500(WireMockServer wireMockServer, String userName) {
+ wireMockServer.stubFor(get(urlMatching("/mockPublicUrl/users/[?]name=" + userName)).willReturn(aResponse()
.withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
}
- public static void mockOpenStackGetRoles_200(String roleFor) {
- stubFor(get(urlPathEqualTo("/mockPublicUrl/" + roleFor + "/roles")).willReturn(aResponse()
+ public static void mockOpenStackGetRoles_200(WireMockServer wireMockServer, String roleFor) {
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/" + roleFor + "/roles")).willReturn(aResponse()
.withHeader("Content-Type", "application/json")
.withBodyFile("OpenstackResponse_Roles.json").withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenstackPostNetwork(String responseFile) {
- stubFor(post(urlPathEqualTo("/mockPublicUrl/v2.0/networks")).willReturn(aResponse()
+ public static void mockOpenstackPostNetwork(WireMockServer wireMockServer, String responseFile) {
+ wireMockServer.stubFor(post(urlPathEqualTo("/mockPublicUrl/v2.0/networks")).willReturn(aResponse()
.withHeader("Content-Type", "application/json")
.withBodyFile(responseFile)
.withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenstackPutNetwork(String responseFile, String networkId) {
- stubFor(put(urlPathEqualTo("/mockPublicUrl/v2.0/networks/"+networkId)).willReturn(aResponse()
+ public static void mockOpenstackPutNetwork(WireMockServer wireMockServer, String responseFile, String networkId) {
+ wireMockServer.stubFor(put(urlPathEqualTo("/mockPublicUrl/v2.0/networks/"+networkId)).willReturn(aResponse()
.withHeader("Content-Type", "application/json")
.withBodyFile(responseFile)
.withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackGetNeutronNetwork(String filename,String networkId) {
- stubFor(get(urlPathEqualTo("/mockPublicUrl/v2.0/networks/"+ networkId))
+ public static void mockOpenStackGetNeutronNetwork(WireMockServer wireMockServer, String filename,String networkId) {
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/v2.0/networks/"+ networkId))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBodyFile(filename).withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackGetNeutronNetwork_500(String networkId) {
- stubFor(get(urlPathEqualTo("/mockPublicUrl/v2.0/networks/"+ networkId))
+ public static void mockOpenStackGetNeutronNetwork_500(WireMockServer wireMockServer, String networkId) {
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/v2.0/networks/"+ networkId))
.willReturn(aResponse().withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
}
- public static void mockOpenStackDeleteNeutronNetwork(String networkId) {
- stubFor(delete(urlPathEqualTo("/mockPublicUrl/v2.0/networks/" + networkId))
+ public static void mockOpenStackDeleteNeutronNetwork(WireMockServer wireMockServer, String networkId) {
+ wireMockServer.stubFor(delete(urlPathEqualTo("/mockPublicUrl/v2.0/networks/" + networkId))
.willReturn(aResponse().withStatus(HttpStatus.SC_OK)));
}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java
index c771a75976..925365f00e 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java
@@ -24,19 +24,17 @@ package org.onap.so.openstack.utils;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static com.shazam.shazamcrest.MatcherAssert.assertThat;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertNotNull;
-import com.woorea.openstack.heat.Heat;
-import com.woorea.openstack.heat.model.CreateStackParam;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+
import org.apache.http.HttpStatus;
import org.junit.Assert;
import org.junit.Test;
@@ -59,6 +57,9 @@ import org.onap.so.openstack.exceptions.MsoIOException;
import org.onap.so.openstack.exceptions.MsoOpenstackException;
import org.springframework.beans.factory.annotation.Autowired;
+import com.woorea.openstack.heat.Heat;
+import com.woorea.openstack.heat.model.CreateStackParam;
+
public class MsoHeatUtilsTest extends BaseTest{
@Autowired
@@ -94,10 +95,10 @@ public class MsoHeatUtilsTest extends BaseTest{
Map<String, Object> inputs = new HashMap<>();
boolean rollbackOnFailure = true;
- StubOpenStack.mockOpenStackResponseAccess(wireMockPort);
- StubOpenStack.mockOpenStackPostStack_200("OpenstackResponse_Stack_Created.json");
+ StubOpenStack.mockOpenStackResponseAccess(wireMockServer, wireMockPort);
+ StubOpenStack.mockOpenStackPostStack_200(wireMockServer, "OpenstackResponse_Stack_Created.json");
- stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/instanceName/stackId"))
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/instanceName/stackId"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBodyFile("OpenstackResponse_StackId.json")
.withStatus(HttpStatus.SC_OK)));
@@ -123,10 +124,10 @@ public class MsoHeatUtilsTest extends BaseTest{
cloudInfo.setTenantId("tenantId");
String instanceId = "instanceId";
- StubOpenStack.mockOpenStackResponseAccess(wireMockPort);
- StubOpenStack.mockOpenStackPostStack_200("OpenstackResponse_Stack_Created.json");
+ StubOpenStack.mockOpenStackResponseAccess(wireMockServer, wireMockPort);
+ StubOpenStack.mockOpenStackPostStack_200(wireMockServer, "OpenstackResponse_Stack_Created.json");
- stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/instanceId"))
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/instanceId"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBodyFile("OpenstackResponse_StackId.json")
.withStatus(HttpStatus.SC_OK)));
@@ -152,10 +153,10 @@ public class MsoHeatUtilsTest extends BaseTest{
int timeoutInMinutes = 1;
- StubOpenStack.mockOpenStackResponseAccess(wireMockPort);
- stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/instanceId")).willReturn(aResponse().withBodyFile("OpenstackResponse_StackId.json").withStatus(HttpStatus.SC_OK)));
- StubOpenStack.mockOpenStackDelete("name/da886914-efb2-4917-b335-c8381528d90b");
- stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/name/da886914-efb2-4917-b335-c8381528d90b")).willReturn(aResponse().withBodyFile("OpenstackResponse_Stack_DeleteComplete.json").withStatus(HttpStatus.SC_OK)));
+ StubOpenStack.mockOpenStackResponseAccess(wireMockServer, wireMockPort);
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/instanceId")).willReturn(aResponse().withBodyFile("OpenstackResponse_StackId.json").withStatus(HttpStatus.SC_OK)));
+ StubOpenStack.mockOpenStackDelete(wireMockServer, "name/da886914-efb2-4917-b335-c8381528d90b");
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/name/da886914-efb2-4917-b335-c8381528d90b")).willReturn(aResponse().withBodyFile("OpenstackResponse_Stack_DeleteComplete.json").withStatus(HttpStatus.SC_OK)));
VduInstance actual = heatUtils.deleteVdu(cloudInfo, instanceId, timeoutInMinutes);
@@ -195,7 +196,7 @@ public class MsoHeatUtilsTest extends BaseTest{
@Test
public final void getHeatClientSuccessTest() throws MsoException, IOException {
CloudSite cloudSite = getCloudSite(getCloudIdentity());
- StubOpenStack.mockOpenStackResponseAccess(wireMockPort);
+ StubOpenStack.mockOpenStackResponseAccess(wireMockServer, wireMockPort);
Heat heatClient = heatUtils.getHeatClient(cloudSite, "TEST-tenant");
assertNotNull(heatClient);
}
@@ -210,7 +211,7 @@ public class MsoHeatUtilsTest extends BaseTest{
@Test(expected = MsoAdapterException.class)
public final void getHeatClientOpenStackResponseException401Test() throws MsoException, IOException {
CloudSite cloudSite = getCloudSite(getCloudIdentity());
- StubOpenStack.mockOpenStackResponseUnauthorized(wireMockPort);
+ StubOpenStack.mockOpenStackResponseUnauthorized(wireMockServer, wireMockPort);
heatUtils.getHeatClient(cloudSite, "TEST-tenant");
}
@@ -226,9 +227,9 @@ public class MsoHeatUtilsTest extends BaseTest{
@Test
public final void createStackSuccessTest() throws MsoException, IOException {
CloudSite cloudSite = getCloudSite(getCloudIdentity());
- StubOpenStack.mockOpenStackResponseAccess(wireMockPort);
- StubOpenStack.mockOpenStackPostStack_200("OpenstackResponse_Stack_Created.json");
- StubOpenStack.mockOpenStackGet("TEST-stack/stackId");
+ StubOpenStack.mockOpenStackResponseAccess(wireMockServer, wireMockPort);
+ StubOpenStack.mockOpenStackPostStack_200(wireMockServer, "OpenstackResponse_Stack_Created.json");
+ StubOpenStack.mockOpenStackGet(wireMockServer, "TEST-stack/stackId");
StackInfo stackInfo = heatUtils.createStack(cloudSite.getId(), "CloudOwner", "tenantId", "TEST-stack", null,
"TEST-heat", new HashMap<>(), false, 1, "TEST-env",
new HashMap<>(), new HashMap<>(), false);
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoKeystoneUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoKeystoneUtilsTest.java
index 5100407633..3526a68ef6 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoKeystoneUtilsTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoKeystoneUtilsTest.java
@@ -39,15 +39,15 @@ public class MsoKeystoneUtilsTest extends BaseTest {
@Before
public void before() throws IOException {
- StubOpenStack.mockOpenStackResponseAccess(wireMockPort);
+ StubOpenStack.mockOpenStackResponseAccess(wireMockServer, wireMockPort);
}
@Test
public void createTenantTest() throws Exception {
- StubOpenStack.mockOpenStackPostTenantWithBodyFile_200();
+ StubOpenStack.mockOpenStackPostTenantWithBodyFile_200(wireMockServer);
- StubOpenStack.mockOpenStackGetUserById("john");
- StubOpenStack.mockOpenStackGetRoles_200("OS-KSADM");
+ StubOpenStack.mockOpenStackGetUserById(wireMockServer, "john");
+ StubOpenStack.mockOpenStackGetRoles_200(wireMockServer, "OS-KSADM");
String response = msoKeystoneUtils.createTenant("tenant", "MTN13", new HashMap<>(), true);
Assert.assertEquals("tenantId", response);
@@ -55,10 +55,10 @@ public class MsoKeystoneUtilsTest extends BaseTest {
@Test
public void createTenantTest_FindUserByName() throws Exception {
- StubOpenStack.mockOpenStackPostTenantWithBodyFile_200();
+ StubOpenStack.mockOpenStackPostTenantWithBodyFile_200(wireMockServer);
- StubOpenStack.mockOpenStackGetUserByName("john");
- StubOpenStack.mockOpenStackGetRoles_200("OS-KSADM");
+ StubOpenStack.mockOpenStackGetUserByName(wireMockServer, "john");
+ StubOpenStack.mockOpenStackGetRoles_200(wireMockServer, "OS-KSADM");
String response = msoKeystoneUtils.createTenant("tenant", "MTN13", new HashMap<>(), true);
Assert.assertEquals("tenantId", response);
@@ -67,15 +67,15 @@ public class MsoKeystoneUtilsTest extends BaseTest {
@Test
public void createTenantTest_Exception() throws Exception {
expectedException.expect(MsoException.class);
- StubOpenStack.mockOpenStackPostTenantWithBodyFile_200();
- StubOpenStack.mockOpenStackGetUserByName_500("john");
- StubOpenStack.mockOpenStackGetRoles_200("OS-KSADM");
+ StubOpenStack.mockOpenStackPostTenantWithBodyFile_200(wireMockServer);
+ StubOpenStack.mockOpenStackGetUserByName_500(wireMockServer, "john");
+ StubOpenStack.mockOpenStackGetRoles_200(wireMockServer, "OS-KSADM");
msoKeystoneUtils.createTenant("tenant", "Test", new HashMap<>(), true);
}
@Test
public void queryTenantTest() throws Exception {
- StubOpenStack.mockOpenStackGetTenantById("tenantId");
+ StubOpenStack.mockOpenStackGetTenantById(wireMockServer, "tenantId");
MsoTenant msoTenant = msoKeystoneUtils.queryTenant("tenantId", "MTN13");
@@ -84,7 +84,7 @@ public class MsoKeystoneUtilsTest extends BaseTest {
@Test
public void queryTenantByNameTest() throws Exception {
- StubOpenStack.mockOpenStackGetTenantByName("tenant");
+ StubOpenStack.mockOpenStackGetTenantByName(wireMockServer, "tenant");
MsoTenant msoTenant = msoKeystoneUtils.queryTenantByName("tenant", "MTN13");
@@ -93,8 +93,8 @@ public class MsoKeystoneUtilsTest extends BaseTest {
@Test
public void deleteTenantTest() throws Exception {
- StubOpenStack.mockOpenStackGetTenantById("tenantId");
- StubOpenStack.mockOpenStackDeleteTenantById_200("tenantId");
+ StubOpenStack.mockOpenStackGetTenantById(wireMockServer, "tenantId");
+ StubOpenStack.mockOpenStackDeleteTenantById_200(wireMockServer, "tenantId");
boolean result = msoKeystoneUtils.deleteTenant("tenantId", "MTN13");
Assert.assertTrue(result);
@@ -102,8 +102,8 @@ public class MsoKeystoneUtilsTest extends BaseTest {
@Test
public void deleteTenantByNameTest() throws Exception {
- StubOpenStack.mockOpenStackGetTenantByName("tenant");
- StubOpenStack.mockOpenStackDeleteTenantById_200("tenantId");
+ StubOpenStack.mockOpenStackGetTenantByName(wireMockServer, "tenant");
+ StubOpenStack.mockOpenStackDeleteTenantById_200(wireMockServer, "tenantId");
boolean result = msoKeystoneUtils.deleteTenantByName("tenant", "MTN13");
Assert.assertTrue(result);
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoMulticloudUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoMulticloudUtilsTest.java
index b2a69ded46..8b0efd8ade 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoMulticloudUtilsTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoMulticloudUtilsTest.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2019 Samsung Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -22,25 +24,31 @@ package org.onap.so.openstack.utils;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.when;
import java.io.IOException;
import java.util.HashMap;
import java.util.Optional;
+
import org.apache.http.HttpStatus;
import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.onap.so.BaseTest;
+import org.onap.so.adapters.vdu.CloudInfo;
+import org.onap.so.adapters.vdu.VduException;
+import org.onap.so.adapters.vdu.VduInstance;
import org.onap.so.adapters.vdu.VduModelInfo;
+import org.onap.so.adapters.vdu.VduStateType;
import org.onap.so.cloud.CloudConfig;
import org.onap.so.db.catalog.beans.CloudIdentity;
import org.onap.so.db.catalog.beans.CloudSite;
+import org.onap.so.openstack.beans.HeatStatus;
import org.onap.so.openstack.beans.StackInfo;
import org.onap.so.openstack.exceptions.MsoException;
import org.springframework.beans.factory.annotation.Autowired;
@@ -61,7 +69,7 @@ public class MsoMulticloudUtilsTest extends BaseTest {
@Test
public void createStackSuccess() throws MsoException, IOException {
- stubFor(post(urlPathEqualTo("/v2.0"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/v2.0"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(CREATE_STACK_RESPONSE)
.withStatus(HttpStatus.SC_CREATED)));
@@ -73,6 +81,33 @@ public class MsoMulticloudUtilsTest extends BaseTest {
}
@Test
+ public void deleteStack() throws MsoException {
+ StackInfo result = multicloudUtils.deleteStack("MTN13", "CloudOwner", "TEST-tenant", "instanceId");
+ assertNotNull(result);
+ assertTrue(HeatStatus.NOTFOUND == result.getStatus());
+ }
+
+ @Test
+ public void queryStack() throws MsoException {
+ StackInfo result = multicloudUtils.queryStack("MTN13", "CloudOwner", "TEST-tenant", "instanceId");
+ assertTrue(HeatStatus.NOTFOUND == result.getStatus());
+ }
+
+ @Test(expected = VduException.class)
+ public void updateVdu() throws MsoException {
+ multicloudUtils.updateVdu(new CloudInfo(), "instanceId", new HashMap<>(), new VduModelInfo(),
+ false);
+ }
+
+ @Test
+ public void deleteVdu() throws VduException {
+ CloudInfo cloudInfo = new CloudInfo("cloudSiteId", "cloudOwner", "tenantId", "tenantName");
+ VduInstance vduInstance = multicloudUtils.deleteVdu(cloudInfo, "instanceId", 3);
+ assertNotNull(vduInstance);
+ assertTrue(VduStateType.DELETED == vduInstance.getStatus().getState());
+ }
+
+ @Test
public void createStackMulticloudClientIsNull() {
try {
multicloudUtilsMock.cloudConfig = cloudConfigMock;
@@ -93,7 +128,7 @@ public class MsoMulticloudUtilsTest extends BaseTest {
@Test
public void createStackBadRequest() {
try {
- stubFor(post(urlPathEqualTo("/v2.0"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/v2.0"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withStatus(HttpStatus.SC_BAD_REQUEST)));
multicloudUtils.createStack("MTN13", "CloudOwner", "TEST-tenant", "TEST-stack", new VduModelInfo(),
@@ -108,7 +143,7 @@ public class MsoMulticloudUtilsTest extends BaseTest {
@Test
public void createStackEmptyResponseEntity() throws MsoException {
- stubFor(post(urlPathEqualTo("/v2.0"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/v2.0"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withStatus(HttpStatus.SC_CREATED)));
StackInfo result = multicloudUtils.createStack("MTN13", "CloudOwner", "TEST-tenant", "TEST-stack", new VduModelInfo(),
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoNeutronUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoNeutronUtilsTest.java
index f679e1f776..8c337865df 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoNeutronUtilsTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoNeutronUtilsTest.java
@@ -44,7 +44,7 @@ public class MsoNeutronUtilsTest extends BaseTest{
public void before() throws IOException {
vlans = new ArrayList<>();
vlans.add(3014);
- StubOpenStack.mockOpenStackResponseAccess(wireMockPort);
+ StubOpenStack.mockOpenStackResponseAccess(wireMockServer, wireMockPort);
}
@Test
@@ -56,7 +56,7 @@ public class MsoNeutronUtilsTest extends BaseTest{
@Test
public void createNetworkTest_NetworkTypeAsMultiProvider() throws Exception {
- StubOpenStack.mockOpenstackPostNetwork("OpenstackCreateNeutronNetworkResponse.json");
+ StubOpenStack.mockOpenstackPostNetwork(wireMockServer, "OpenstackCreateNeutronNetworkResponse.json");
NetworkInfo networkInfo = msoNeutronUtils.createNetwork("MTN13", "tenantId",
MsoNeutronUtils.NetworkType.MULTI_PROVIDER,"networkName","PROVIDER", vlans);
@@ -65,7 +65,7 @@ public class MsoNeutronUtilsTest extends BaseTest{
@Test
public void createNetworkTest() throws Exception {
- StubOpenStack.mockOpenstackPostNetwork("OpenstackCreateNeutronNetworkResponse.json");
+ StubOpenStack.mockOpenstackPostNetwork(wireMockServer, "OpenstackCreateNeutronNetworkResponse.json");
NetworkInfo networkInfo = msoNeutronUtils.createNetwork("MTN13", "tenantId",
MsoNeutronUtils.NetworkType.PROVIDER,"networkName","PROVIDER", vlans);
@@ -74,7 +74,7 @@ public class MsoNeutronUtilsTest extends BaseTest{
@Test
public void queryNetworkTest() throws Exception {
- StubOpenStack.mockOpenStackGetNeutronNetwork("GetNeutronNetwork.json", "43173f6a-d699-414b-888f-ab243dda6dfe");
+ StubOpenStack.mockOpenStackGetNeutronNetwork(wireMockServer, "GetNeutronNetwork.json", "43173f6a-d699-414b-888f-ab243dda6dfe");
NetworkInfo networkInfo = msoNeutronUtils.queryNetwork("43173f6a-d699-414b-888f-ab243dda6dfe", "tenantId","MTN13");
Assert.assertEquals("net1",networkInfo.getName());
@@ -89,15 +89,15 @@ public class MsoNeutronUtilsTest extends BaseTest{
@Test
public void queryNetworkTest_500() throws Exception {
expectedException.expect(MsoException.class);
- StubOpenStack.mockOpenStackGetNeutronNetwork_500("43173f6a-d699-414b-888f-ab243dda6dfe");
+ StubOpenStack.mockOpenStackGetNeutronNetwork_500(wireMockServer, "43173f6a-d699-414b-888f-ab243dda6dfe");
msoNeutronUtils.queryNetwork("43173f6a-d699-414b-888f-ab243dda6dfe", "tenantId","MTN13");
}
@Test
public void deleteNetworkkTest() throws Exception {
- StubOpenStack.mockOpenStackGetNeutronNetwork("GetNeutronNetwork.json", "43173f6a-d699-414b-888f-ab243dda6dfe");
- StubOpenStack.mockOpenStackDeleteNeutronNetwork("43173f6a-d699-414b-888f-ab243dda6dfe");
+ StubOpenStack.mockOpenStackGetNeutronNetwork(wireMockServer, "GetNeutronNetwork.json", "43173f6a-d699-414b-888f-ab243dda6dfe");
+ StubOpenStack.mockOpenStackDeleteNeutronNetwork(wireMockServer, "43173f6a-d699-414b-888f-ab243dda6dfe");
Boolean result = msoNeutronUtils.deleteNetwork("43173f6a-d699-414b-888f-ab243dda6dfe", "tenantId","MTN13");
Assert.assertTrue(result);
@@ -105,8 +105,8 @@ public class MsoNeutronUtilsTest extends BaseTest{
@Test
public void updateNetworkTest() throws Exception {
- StubOpenStack.mockOpenStackGetNeutronNetwork("GetNeutronNetwork.json", "43173f6a-d699-414b-888f-ab243dda6dfe");
- StubOpenStack.mockOpenstackPutNetwork("OpenstackCreateNeutronNetworkResponse.json", "43173f6a-d699-414b-888f-ab243dda6dfe");
+ StubOpenStack.mockOpenStackGetNeutronNetwork(wireMockServer, "GetNeutronNetwork.json", "43173f6a-d699-414b-888f-ab243dda6dfe");
+ StubOpenStack.mockOpenstackPutNetwork(wireMockServer, "OpenstackCreateNeutronNetworkResponse.json", "43173f6a-d699-414b-888f-ab243dda6dfe");
NetworkInfo networkInfo = msoNeutronUtils.updateNetwork("MTN13", "tenantId",
"43173f6a-d699-414b-888f-ab243dda6dfe",MsoNeutronUtils.NetworkType.PROVIDER,"PROVIDER", vlans);
@@ -115,8 +115,8 @@ public class MsoNeutronUtilsTest extends BaseTest{
@Test
public void updateNetworkTest_NetworkTypeAsMultiProvider() throws Exception {
- StubOpenStack.mockOpenStackGetNeutronNetwork("GetNeutronNetwork.json", "43173f6a-d699-414b-888f-ab243dda6dfe");
- StubOpenStack.mockOpenstackPutNetwork("OpenstackCreateNeutronNetworkResponse.json", "43173f6a-d699-414b-888f-ab243dda6dfe");
+ StubOpenStack.mockOpenStackGetNeutronNetwork(wireMockServer, "GetNeutronNetwork.json", "43173f6a-d699-414b-888f-ab243dda6dfe");
+ StubOpenStack.mockOpenstackPutNetwork(wireMockServer, "OpenstackCreateNeutronNetworkResponse.json", "43173f6a-d699-414b-888f-ab243dda6dfe");
NetworkInfo networkInfo = msoNeutronUtils.updateNetwork("MTN13", "tenantId",
"43173f6a-d699-414b-888f-ab243dda6dfe",MsoNeutronUtils.NetworkType.MULTI_PROVIDER,"PROVIDER", vlans);
diff --git a/adapters/mso-catalog-db-adapter/pom.xml b/adapters/mso-catalog-db-adapter/pom.xml
index 390c775cb2..1f6ea413ec 100644
--- a/adapters/mso-catalog-db-adapter/pom.xml
+++ b/adapters/mso-catalog-db-adapter/pom.xml
@@ -63,6 +63,24 @@
</compilerArgs>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-test</id>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <includes>
+ <include>**/AllTestsTestSuite.java</include>
+ </includes>
+ <parallel>suites</parallel>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
<pluginManagement>
<plugins>
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/AllTestsTestSuite.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/AllTestsTestSuite.java
new file mode 100644
index 0000000000..3c05f8164b
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/AllTestsTestSuite.java
@@ -0,0 +1,32 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 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.so.adapters.catalogdb;
+import org.junit.runner.RunWith;
+
+import com.googlecode.junittoolbox.SuiteClasses;
+import com.googlecode.junittoolbox.WildcardPatternSuite;
+
+@RunWith(WildcardPatternSuite.class)
+@SuiteClasses("**/*Test.class")
+public class AllTestsTestSuite {
+ // the class remains empty,
+ // used only as a holder for the above annotations
+}
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/CatalogDbAdapterBaseTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/CatalogDbAdapterBaseTest.java
new file mode 100644
index 0000000000..b2a20681d9
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/CatalogDbAdapterBaseTest.java
@@ -0,0 +1,21 @@
+package org.onap.so.adapters.catalogdb;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.web.server.LocalServerPort;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = CatalogDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+@ActiveProfiles("test")
+public class CatalogDbAdapterBaseTest {
+
+ @LocalServerPort
+ protected int port;
+
+
+ @Test
+ public void testNothing(){}
+}
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java
index a97029ef5b..bd8c5bc3e3 100644
--- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java
+++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java
@@ -20,7 +20,8 @@
package org.onap.so.adapters.catalogdb.catalogrest;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import static org.onap.so.logger.MdcConstants.ENDTIME;
import static org.onap.so.logger.MdcConstants.INVOCATION_ID;
import static org.onap.so.logger.MdcConstants.PARTNERNAME;
@@ -29,45 +30,29 @@ import static org.onap.so.logger.MdcConstants.RESPONSEDESC;
import static org.onap.so.logger.MdcConstants.SERVICE_NAME;
import static org.onap.so.logger.MdcConstants.STATUSCODE;
-
import java.io.IOException;
import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
+
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-
import org.json.JSONException;
-import org.junit.Before;
-import org.junit.BeforeClass;
import org.junit.Test;
-import org.junit.runner.RunWith;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
-import org.onap.so.adapters.catalogdb.CatalogDBApplication;
-
+import org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest;
import org.skyscreamer.jsonassert.JSONAssert;
import org.skyscreamer.jsonassert.JSONCompareMode;
-import org.springframework.boot.web.server.LocalServerPort;
-import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
-import org.springframework.test.annotation.DirtiesContext;
-import org.springframework.test.annotation.DirtiesContext.ClassMode;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.web.util.UriComponentsBuilder;
import ch.qos.logback.classic.spi.ILoggingEvent;
-@RunWith(SpringRunner.class)
-@SpringBootTest(classes = CatalogDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-@ActiveProfiles("test")
-public class CatalogDBRestTest {
+public class CatalogDBRestTest extends CatalogDbAdapterBaseTest {
private static final String ECOMP_MSO_CATALOG_V2_VF_MODULES = "ecomp/mso/catalog/v2/vfModules";
@@ -81,9 +66,6 @@ public class CatalogDBRestTest {
private static final String ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES = "ecomp/mso/catalog/v2/serviceResources";
- @LocalServerPort
- private int port;
-
TestRestTemplate restTemplate = new TestRestTemplate("test", "test");
HttpHeaders headers = new HttpHeaders();
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CloudConfigTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CloudConfigTest.java
index 5a6ab747c5..f2f06d7f3d 100644
--- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CloudConfigTest.java
+++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CloudConfigTest.java
@@ -27,6 +27,7 @@ import javax.ws.rs.core.Response;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.so.adapters.catalogdb.CatalogDBApplication;
+import org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest;
import org.onap.so.db.catalog.beans.AuthenticationType;
import org.onap.so.db.catalog.beans.CloudIdentity;
import org.onap.so.db.catalog.beans.CloudSite;
@@ -44,10 +45,7 @@ import org.springframework.web.util.UriComponentsBuilder;
import static com.shazam.shazamcrest.MatcherAssert.assertThat;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
-@RunWith(SpringRunner.class)
-@SpringBootTest(classes = CatalogDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-@ActiveProfiles("test")
-public class CloudConfigTest {
+public class CloudConfigTest extends CatalogDbAdapterBaseTest {
protected TestRestTemplate restTemplate = new TestRestTemplate("test", "test");
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CvnfcCatalogDbQueryTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CvnfcCatalogDbQueryTest.java
index 898e8eadf1..78ac4ca095 100644
--- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CvnfcCatalogDbQueryTest.java
+++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CvnfcCatalogDbQueryTest.java
@@ -36,6 +36,7 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.so.adapters.catalogdb.CatalogDBApplication;
+import org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest;
import org.onap.so.db.catalog.beans.ConfigurationResource;
import org.onap.so.db.catalog.beans.CvnfcCustomization;
import org.onap.so.db.catalog.beans.VfModule;
@@ -56,10 +57,7 @@ import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.beans.BeanUtils;
-@RunWith(SpringRunner.class)
-@SpringBootTest(classes = CatalogDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-@ActiveProfiles("test")
-public class CvnfcCatalogDbQueryTest {
+public class CvnfcCatalogDbQueryTest extends CatalogDbAdapterBaseTest {
@Autowired
private CvnfcCustomizationRepository cvnfcCustomizationRepository;
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/NetworkCollectionCatalogDbQueryTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/NetworkCollectionCatalogDbQueryTest.java
index 89a7ba3d17..e6a281a375 100644
--- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/NetworkCollectionCatalogDbQueryTest.java
+++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/NetworkCollectionCatalogDbQueryTest.java
@@ -35,6 +35,7 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.so.adapters.catalogdb.CatalogDBApplication;
+import org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest;
import org.onap.so.db.catalog.beans.BuildingBlockDetail;
import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization;
import org.onap.so.db.catalog.beans.CollectionResourceCustomization;
@@ -50,10 +51,7 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
-@RunWith(SpringRunner.class)
-@SpringBootTest(classes = CatalogDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-@ActiveProfiles("test")
-public class NetworkCollectionCatalogDbQueryTest {
+public class NetworkCollectionCatalogDbQueryTest extends CatalogDbAdapterBaseTest {
private static final Logger logger = LoggerFactory.getLogger(NetworkCollectionCatalogDbQueryTest.class);
private static final String NETWORKCOLLECTION = "NetworkCollection";
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java
index ea8cb5d616..461fce555f 100644
--- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java
+++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java
@@ -31,6 +31,7 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.so.adapters.catalogdb.CatalogDBApplication;
+import org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest;
import org.onap.so.db.catalog.beans.AuthenticationType;
import org.onap.so.db.catalog.beans.CloudIdentity;
import org.onap.so.db.catalog.beans.CloudSite;
@@ -59,10 +60,7 @@ import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
-@RunWith(SpringRunner.class)
-@SpringBootTest(classes = CatalogDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-@ActiveProfiles("test")
-public class CatalogDbClientTest {
+public class CatalogDbClientTest extends CatalogDbAdapterBaseTest {
public static final String MTN13 = "mtn13";
diff --git a/adapters/mso-openstack-adapters/pom.xml b/adapters/mso-openstack-adapters/pom.xml
index 73f50ed908..9c3ef2578f 100644
--- a/adapters/mso-openstack-adapters/pom.xml
+++ b/adapters/mso-openstack-adapters/pom.xml
@@ -37,6 +37,24 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-test</id>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <includes>
+ <include>**/AllTestsTestSuite.java</include>
+ </includes>
+ <parallel>suites</parallel>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
<!-- run the following plugin only when there's a wsdl change and you need to recompile the java classes
<plugin>
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MSONetworkAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MSONetworkAdapterImplTest.java
index 707af7b6be..7bfb8c1d76 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MSONetworkAdapterImplTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MSONetworkAdapterImplTest.java
@@ -64,9 +64,9 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils {
@Test
public void createNetworkByModelNameNeutronModeGetNetworkException() throws IOException{
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenstackGet("/mockPublicUrl/v2.0/networks",HttpStatus.SC_INTERNAL_SERVER_ERROR);
+ mockOpenstackGet(wireMockServer, "/mockPublicUrl/v2.0/networks",HttpStatus.SC_INTERNAL_SERVER_ERROR);
String uri = "/services/NetworkAdapter";
headers.set("X-ECOMP-RequestID", "123456789456127");
@@ -77,13 +77,13 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils {
@Test
public void createNetworkByModelNameNeutronModeCreateNetworkException() throws IOException{
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetNeutronNetwork_404("dvspg-VCE_VPE-mtjnj40avbc");
+ mockOpenStackGetNeutronNetwork_404(wireMockServer, "dvspg-VCE_VPE-mtjnj40avbc");
- mockOpenStackGetAllNeutronNetworks_404();
+ mockOpenStackGetAllNeutronNetworks_404(wireMockServer);
- mockOpenstackPost("/mockPublicUrl/v2.0/networks", HttpStatus.SC_INTERNAL_SERVER_ERROR);
+ mockOpenstackPost(wireMockServer, "/mockPublicUrl/v2.0/networks", HttpStatus.SC_INTERNAL_SERVER_ERROR);
String uri = "/services/NetworkAdapter";
headers.set("X-ECOMP-RequestID", "123456789456127");
@@ -94,13 +94,13 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils {
@Test
public void createNetworkByModelNameNeutronMode() throws IOException{
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetNeutronNetwork_404("dvspg-VCE_VPE-mtjnj40avbc");
+ mockOpenStackGetNeutronNetwork_404(wireMockServer, "dvspg-VCE_VPE-mtjnj40avbc");
- mockOpenStackGetAllNeutronNetworks_404();
+ mockOpenStackGetAllNeutronNetworks_404(wireMockServer);
- mockOpenStackPostNeutronNetwork_200("OpenstackCreateNeutronNetworkResponse.json");
+ mockOpenStackPostNeutronNetwork_200(wireMockServer, "OpenstackCreateNeutronNetworkResponse.json");
String uri = "/services/NetworkAdapter";
headers.set("X-ECOMP-RequestID", "123456789456127");
@@ -111,9 +111,9 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils {
@Test
public void createNetworkByModelNameAlreadyExistNeutronMode() throws IOException{
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetAllNeutronNetworks_200("OpenstackGetNeutronNetworks.json");
+ mockOpenStackGetAllNeutronNetworks_200(wireMockServer, "OpenstackGetNeutronNetworks.json");
String uri = "/services/NetworkAdapter";
headers.set("X-ECOMP-RequestID", "123456789456127");
@@ -124,9 +124,9 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils {
@Test
public void createNetworkByModelNameAlreadyExistNeutronModeFailIfExistTrue() throws IOException{
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetAllNeutronNetworks_200("OpenstackGetNeutronNetworks.json");
+ mockOpenStackGetAllNeutronNetworks_200(wireMockServer, "OpenstackGetNeutronNetworks.json");
String uri = "/services/NetworkAdapter";
headers.set("X-ECOMP-RequestID", "123456789456127");
@@ -137,13 +137,13 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils {
@Test
public void createNetworkByModelNameHeatMode() throws IOException{
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetStack_404("dvspg-VCE_VPE-mtjnj40avbc");
+ mockOpenStackGetStack_404(wireMockServer, "dvspg-VCE_VPE-mtjnj40avbc");
- mockOpenStackPostStack_200("OpenstackResponse_Stack.json");
+ mockOpenStackPostStack_200(wireMockServer, "OpenstackResponse_Stack.json");
- mockOpenStackGetStackCreated_200("OpenstackResponse_Stack_Created.json", "dvspg-VCE_VPE-mtjnj40avbc/stackId");
+ mockOpenStackGetStackCreated_200(wireMockServer, "OpenstackResponse_Stack_Created.json", "dvspg-VCE_VPE-mtjnj40avbc/stackId");
String uri = "/services/NetworkAdapter";
headers.set("X-ECOMP-RequestID", "123456789456127");
@@ -154,11 +154,11 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils {
@Test
public void createNetworkByModelNameAlreadyExistHeatMode() throws IOException{
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackPostStack_200("OpenstackResponse_Stack.json");
+ mockOpenStackPostStack_200(wireMockServer, "OpenstackResponse_Stack.json");
- mockOpenStackGetStackCreated_200("OpenstackResponse_Stack_Created.json", "dvspg-VCE_VPE-mtjnj40avbc");
+ mockOpenStackGetStackCreated_200(wireMockServer, "OpenstackResponse_Stack_Created.json", "dvspg-VCE_VPE-mtjnj40avbc");
String uri = "/services/NetworkAdapter";
headers.set("X-ECOMP-RequestID", "123456789456127");
@@ -169,9 +169,9 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils {
@Test
public void createNetworkByModelNameAlreadyExistHeatModeFailIfExistTrue() throws IOException{
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetStackCreated_200("OpenstackResponse_Stack_Created.json", "dvspg-VCE_VPE-mtjnj40avbc");
+ mockOpenStackGetStackCreated_200(wireMockServer, "OpenstackResponse_Stack_Created.json", "dvspg-VCE_VPE-mtjnj40avbc");
String uri = "/services/NetworkAdapter";
headers.set("X-ECOMP-RequestID", "123456789456127");
@@ -183,9 +183,9 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils {
@Test
public void createNetworkByModelNameHeatModeQueryNetworkException() throws IOException{
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenstackGet("/mockPublicUrl/stacks/dvspg-VCE_VPE-mtjnj40avbc",HttpStatus.SC_INTERNAL_SERVER_ERROR);
+ mockOpenstackGet(wireMockServer, "/mockPublicUrl/stacks/dvspg-VCE_VPE-mtjnj40avbc",HttpStatus.SC_INTERNAL_SERVER_ERROR);
String uri = "/services/NetworkAdapter";
headers.set("X-ECOMP-RequestID", "123456789456127");
@@ -196,11 +196,11 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils {
@Test
public void createNetworkByModelNameHeatModeCreateNetworkException() throws IOException{
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetStack_404("dvspg-VCE_VPE-mtjnj40avbc");
+ mockOpenStackGetStack_404(wireMockServer, "dvspg-VCE_VPE-mtjnj40avbc");
- mockOpenstackPost("/mockPublicUrl/stacks",HttpStatus.SC_INTERNAL_SERVER_ERROR);
+ mockOpenstackPost(wireMockServer, "/mockPublicUrl/stacks",HttpStatus.SC_INTERNAL_SERVER_ERROR);
String uri = "/services/NetworkAdapter";
headers.set("X-ECOMP-RequestID", "123456789456127");
@@ -211,11 +211,11 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils {
@Test
public void createNetworkByModelNameCloudSiteNotPresentError() throws IOException{
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackPostStack_200("OpenstackResponse_Stack.json");
+ mockOpenStackPostStack_200(wireMockServer, "OpenstackResponse_Stack.json");
- mockOpenStackGetStackCreated_200("OpenstackResponse_Stack_Created.json", "dvspg-VCE_VPE-mtjnj40avbc");
+ mockOpenStackGetStackCreated_200(wireMockServer, "OpenstackResponse_Stack_Created.json", "dvspg-VCE_VPE-mtjnj40avbc");
String uri = "/services/NetworkAdapter";
headers.set("X-ECOMP-RequestID", "123456789456127");
@@ -226,13 +226,13 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils {
@Test
public void deleteNetworkHeatModeSuccess() throws IOException{
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetStackDeleteOrUpdateComplete_200("OpenstackResponse_Stack_DeleteComplete.json");
+ mockOpenStackGetStackDeleteOrUpdateComplete_200(wireMockServer, "OpenstackResponse_Stack_DeleteComplete.json");
- mockOpenStackDeleteStack_200();
+ mockOpenStackDeleteStack_200(wireMockServer);
- mockOpenStackGetStackCreated_200("OpenstackResponse_Stack_Created.json", "43173f6a-d699-414b-888f-ab243dda6dfe");
+ mockOpenStackGetStackCreated_200(wireMockServer, "OpenstackResponse_Stack_Created.json", "43173f6a-d699-414b-888f-ab243dda6dfe");
String uri = "/services/NetworkAdapter";
headers.set("X-ECOMP-RequestID", "123456789456127");
@@ -243,13 +243,13 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils {
@Test
public void deleteNetworkDeleteStackException() throws IOException{
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetStackDeleteOrUpdateComplete_200("OpenstackResponse_Stack_DeleteComplete.json");
+ mockOpenStackGetStackDeleteOrUpdateComplete_200(wireMockServer, "OpenstackResponse_Stack_DeleteComplete.json");
- mockOpenStackDeleteStack_500();
+ mockOpenStackDeleteStack_500(wireMockServer);
- mockOpenStackGetStackCreated_200("OpenstackResponse_Stack_Created.json", "43173f6a-d699-414b-888f-ab243dda6dfe");
+ mockOpenStackGetStackCreated_200(wireMockServer, "OpenstackResponse_Stack_Created.json", "43173f6a-d699-414b-888f-ab243dda6dfe");
String uri = "/services/NetworkAdapter";
headers.set("X-ECOMP-RequestID", "123456789456127");
@@ -260,13 +260,13 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils {
@Test
public void deleteNetworkError() throws IOException{
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetStackDeleteOrUpdateComplete_200("OpenstackResponse_Stack_DeleteComplete.json");
+ mockOpenStackGetStackDeleteOrUpdateComplete_200(wireMockServer, "OpenstackResponse_Stack_DeleteComplete.json");
- mockOpenStackDeleteStack_200();
+ mockOpenStackDeleteStack_200(wireMockServer);
- mockOpenStackGetStackCreated_200("OpenstackResponse_Stack_Created.json", "43173f6a-d699-414b-888f-ab243dda6dfe");
+ mockOpenStackGetStackCreated_200(wireMockServer, "OpenstackResponse_Stack_Created.json", "43173f6a-d699-414b-888f-ab243dda6dfe");
String uri = "/services/NetworkAdapter";
headers.set("X-ECOMP-RequestID", "123456789456127");
@@ -278,11 +278,11 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils {
@Test
public void deleteNetworkNeureonMode() throws IOException{
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetNeutronNetwork("GetNeutronNetwork.json",NETWORK_ID,HttpStatus.SC_OK);
+ mockOpenStackGetNeutronNetwork(wireMockServer, "GetNeutronNetwork.json",NETWORK_ID,HttpStatus.SC_OK);
- mockOpenStackDeleteNeutronNetwork(NETWORK_ID,HttpStatus.SC_OK);
+ mockOpenStackDeleteNeutronNetwork(wireMockServer, NETWORK_ID,HttpStatus.SC_OK);
String uri = "/services/NetworkAdapter";
headers.set("X-ECOMP-RequestID", "123456789456127");
@@ -293,11 +293,11 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils {
@Test
public void deleteNetworkNeutronModeDeleteStackException() throws IOException{
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetNeutronNetwork("GetNeutronNetwork.json",NETWORK_ID,HttpStatus.SC_OK);
+ mockOpenStackGetNeutronNetwork(wireMockServer, "GetNeutronNetwork.json",NETWORK_ID,HttpStatus.SC_OK);
- mockOpenStackDeleteNeutronNetwork(NETWORK_ID,HttpStatus.SC_INTERNAL_SERVER_ERROR);
+ mockOpenStackDeleteNeutronNetwork(wireMockServer, NETWORK_ID,HttpStatus.SC_INTERNAL_SERVER_ERROR);
//mockOpenStackGetStackCreated_200("OpenstackResponse_Stack_Created.json", NETWORK_ID);
@@ -310,10 +310,10 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils {
@Test
public void updateNetworkNeutronModeSuccess() throws IOException{
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetNeutronNetwork("GetNeutronNetwork.json",NETWORK_ID,HttpStatus.SC_OK);
- mockOpenStackPutNeutronNetwork_200("OpenstackCreateNeutronNetworkResponse.json",NETWORK_ID);
+ mockOpenStackGetNeutronNetwork(wireMockServer, "GetNeutronNetwork.json",NETWORK_ID,HttpStatus.SC_OK);
+ mockOpenStackPutNeutronNetwork_200(wireMockServer, "OpenstackCreateNeutronNetworkResponse.json",NETWORK_ID);
String uri = "/services/NetworkAdapter";
headers.set("X-ECOMP-RequestID", "123456789456127");
@@ -324,10 +324,10 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils {
@Test
public void updateNetworkNeutronUpdateException() throws IOException{
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetNeutronNetwork("GetNeutronNetwork.json",NETWORK_ID,HttpStatus.SC_OK);
- mockOpenStackPutNeutronNetwork(NETWORK_ID,HttpStatus.SC_INTERNAL_SERVER_ERROR);
+ mockOpenStackGetNeutronNetwork(wireMockServer, "GetNeutronNetwork.json",NETWORK_ID,HttpStatus.SC_OK);
+ mockOpenStackPutNeutronNetwork(wireMockServer, NETWORK_ID,HttpStatus.SC_INTERNAL_SERVER_ERROR);
String uri = "/services/NetworkAdapter";
headers.set("X-ECOMP-RequestID", "123456789456127");
@@ -338,11 +338,11 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils {
@Test
public void updateNetworkHeatUpdateException() throws IOException{
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetStackCreated_200("OpenstackResponse_Stack_Created.json", NETWORK_NAME);
+ mockOpenStackGetStackCreated_200(wireMockServer, "OpenstackResponse_Stack_Created.json", NETWORK_NAME);
- mockOpenStackPutStack(NETWORK_ID,HttpStatus.SC_INTERNAL_SERVER_ERROR);
+ mockOpenStackPutStack(wireMockServer, NETWORK_ID,HttpStatus.SC_INTERNAL_SERVER_ERROR);
String uri = "/services/NetworkAdapter";
headers.set("X-ECOMP-RequestID", "123456789456127");
@@ -353,9 +353,9 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils {
@Test
public void updateNetworkHeatQueryException() throws IOException{
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetStack_500(NETWORK_NAME);
+ mockOpenStackGetStack_500(wireMockServer, NETWORK_NAME);
String uri = "/services/NetworkAdapter";
headers.set("X-ECOMP-RequestID", "123456789456127");
@@ -366,9 +366,9 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils {
@Test
public void updateNetworkHeatStackNotFound() throws IOException{
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetStack_404(NETWORK_NAME);
+ mockOpenStackGetStack_404(wireMockServer, NETWORK_NAME);
String uri = "/services/NetworkAdapter";
headers.set("X-ECOMP-RequestID", "123456789456127");
@@ -379,9 +379,9 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils {
@Test
public void updateNetworkNeutronQueryException() throws IOException{
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetNeutronNetwork(NETWORK_ID,HttpStatus.SC_INTERNAL_SERVER_ERROR);
+ mockOpenStackGetNeutronNetwork(wireMockServer, NETWORK_ID,HttpStatus.SC_INTERNAL_SERVER_ERROR);
String uri = "/services/NetworkAdapter";
headers.set("X-ECOMP-RequestID", "123456789456127");
@@ -392,9 +392,9 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils {
@Test
public void updateNetworkNeutronStackNotFound() throws IOException{
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetNeutronNetwork(NETWORK_ID,HttpStatus.SC_NOT_FOUND);
+ mockOpenStackGetNeutronNetwork(wireMockServer, NETWORK_ID,HttpStatus.SC_NOT_FOUND);
String uri = "/services/NetworkAdapter";
headers.set("X-ECOMP-RequestID", "123456789456127");
@@ -405,9 +405,9 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils {
@Test
public void queryNetworkHeatModesuccess() throws IOException{
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetStackCreated_200("OpenstackResponse_Stack_Created.json", NETWORK_ID);
+ mockOpenStackGetStackCreated_200(wireMockServer, "OpenstackResponse_Stack_Created.json", NETWORK_ID);
String uri = "/services/NetworkAdapter";
headers.set("X-ECOMP-RequestID", "123456789456127");
@@ -418,9 +418,9 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils {
@Test
public void queryNetworkHeatModeQueryException() throws IOException{
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetStack_500(NETWORK_ID);
+ mockOpenStackGetStack_500(wireMockServer, NETWORK_ID);
String uri = "/services/NetworkAdapter";
headers.set("X-ECOMP-RequestID", "123456789456127");
@@ -431,9 +431,9 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils {
@Test
public void queryNetworkNeutronModeSuccess() throws IOException{
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetNeutronNetwork("GetNeutronNetwork.json",NETWORK_ID,HttpStatus.SC_OK);
+ mockOpenStackGetNeutronNetwork(wireMockServer, "GetNeutronNetwork.json",NETWORK_ID,HttpStatus.SC_OK);
String uri = "/services/NetworkAdapter";
headers.set("X-ECOMP-RequestID", "123456789456127");
@@ -444,9 +444,9 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils {
@Test
public void queryNetworkNeutronModeException() throws IOException{
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetNeutronNetwork(NETWORK_ID,HttpStatus.SC_INTERNAL_SERVER_ERROR);
+ mockOpenStackGetNeutronNetwork(wireMockServer, NETWORK_ID,HttpStatus.SC_INTERNAL_SERVER_ERROR);
String uri = "/services/NetworkAdapter";
headers.set("X-ECOMP-RequestID", "123456789456127");
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImplTest.java
index f8dcddde04..21ca860b54 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImplTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImplTest.java
@@ -20,22 +20,9 @@
package org.onap.so.adapters.network;
-import org.apache.http.HttpStatus;
-import org.junit.Test;
-import org.onap.so.adapters.vnf.BaseRestTestUtils;
-import org.onap.so.entity.MsoRequest;
-import org.onap.so.openstack.beans.NetworkRollback;
-import org.onap.so.openstack.beans.Subnet;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.containing;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static org.onap.so.bpmn.mock.StubOpenStack.getBodyFromFile;
import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackCreatedVUSP_200;
@@ -45,6 +32,18 @@ import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackPostStacks_200;
import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackPutPublicUrlStackByNameAndID_NETWORK2_200;
import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackResponseAccessQueryNetwork;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import org.apache.http.HttpStatus;
+import org.junit.Test;
+import org.onap.so.adapters.vnf.BaseRestTestUtils;
+import org.onap.so.entity.MsoRequest;
+import org.onap.so.openstack.beans.NetworkRollback;
+import org.onap.so.openstack.beans.Subnet;
+import org.springframework.beans.factory.annotation.Autowired;
+
public class MsoNetworkAdapterAsyncImplTest extends BaseRestTestUtils {
@Autowired
MsoNetworkAdapterAsyncImpl impl;
@@ -57,12 +56,12 @@ public class MsoNetworkAdapterAsyncImplTest extends BaseRestTestUtils {
@Test
public void rollbackNetworkATest() throws IOException {
- stubFor(post(urlPathEqualTo("/v2.0/tokens"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/v2.0/tokens"))
.withRequestBody(containing("tenantId"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(getBodyFromFile("OpenstackResponse_Access.json", wireMockPort, "/mockPublicUrl"))
.withStatus(HttpStatus.SC_OK)));
- stubFor(post(urlPathEqualTo("/notificationUrl"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/notificationUrl"))
.withRequestBody(containing("<completed>true</completed>"))
.willReturn(aResponse()
.withBody("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:net=\"http://org.onap.so/networkNotify\">\n" +
@@ -79,12 +78,12 @@ public class MsoNetworkAdapterAsyncImplTest extends BaseRestTestUtils {
@Test
public void rollbackNetworkATest_NotifyException() throws IOException {
- stubFor(post(urlPathEqualTo("/v2.0/tokens"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/v2.0/tokens"))
.withRequestBody(containing("tenantId"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(getBodyFromFile("OpenstackResponse_Access.json", wireMockPort, "/mockPublicUrl"))
.withStatus(HttpStatus.SC_OK)));
- stubFor(post(urlPathEqualTo("/notificationUrl"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/notificationUrl"))
.withRequestBody(containing("<completed>true</completed>"))
.willReturn(aResponse()
.withStatus(HttpStatus.SC_NOT_FOUND)));
@@ -124,12 +123,12 @@ public class MsoNetworkAdapterAsyncImplTest extends BaseRestTestUtils {
@Test
public void deleteNetworkATest() throws IOException {
- stubFor(post(urlPathEqualTo("/v2.0/tokens"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/v2.0/tokens"))
.withRequestBody(containing("tenantId"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(getBodyFromFile("OpenstackResponse_Access.json", wireMockPort, "/mockPublicUrl"))
.withStatus(HttpStatus.SC_OK)));
- stubFor(post(urlPathEqualTo("/notificationUrl"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/notificationUrl"))
.withRequestBody(containing("<completed>true</completed>"))
.willReturn(aResponse()
.withBody("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:net=\"http://org.onap.so/networkNotify\">\n" +
@@ -146,12 +145,12 @@ public class MsoNetworkAdapterAsyncImplTest extends BaseRestTestUtils {
@Test
public void deleteNetworkATest_NotifyException() throws IOException {
- stubFor(post(urlPathEqualTo("/v2.0/tokens"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/v2.0/tokens"))
.withRequestBody(containing("tenantId"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(getBodyFromFile("OpenstackResponse_Access.json", wireMockPort, "/mockPublicUrl"))
.withStatus(HttpStatus.SC_OK)));
- stubFor(post(urlPathEqualTo("/notificationUrl"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/notificationUrl"))
.withRequestBody(containing("<completed>true</completed>"))
.willReturn(aResponse()
.withStatus(HttpStatus.SC_NOT_FOUND)));
@@ -167,15 +166,15 @@ public class MsoNetworkAdapterAsyncImplTest extends BaseRestTestUtils {
@Test
public void updateNetworkATest() throws IOException {
- stubFor(post(urlPathEqualTo("/v2.0/tokens"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/v2.0/tokens"))
.withRequestBody(containing("tenantId"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(getBodyFromFile("OpenstackResponse_Access.json", wireMockPort, "/mockPublicUrl"))
.withStatus(HttpStatus.SC_OK)));
- mockOpenStackGetStackCreated_200("OpenstackResponse_Stack_Created.json", "dvspg-VCE_VPE-mtjnj40avbc");
- mockOpenStackGetStackDeleteOrUpdateComplete_200("OpenstackResponse_Stack_UpdateComplete.json");
- mockOpenStackPutPublicUrlStackByNameAndID_NETWORK2_200();
- stubFor(post(urlPathEqualTo("/notificationUrl"))
+ mockOpenStackGetStackCreated_200(wireMockServer, "OpenstackResponse_Stack_Created.json", "dvspg-VCE_VPE-mtjnj40avbc");
+ mockOpenStackGetStackDeleteOrUpdateComplete_200(wireMockServer, "OpenstackResponse_Stack_UpdateComplete.json");
+ mockOpenStackPutPublicUrlStackByNameAndID_NETWORK2_200(wireMockServer);
+ wireMockServer.stubFor(post(urlPathEqualTo("/notificationUrl"))
.withRequestBody(containing("updateNetworkNotification"))
.willReturn(aResponse()
.withBody("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:net=\"http://org.onap.so/networkNotify\">\n" +
@@ -196,14 +195,14 @@ public class MsoNetworkAdapterAsyncImplTest extends BaseRestTestUtils {
@Test
public void updateNetworkATest_NotifyExcpetion() throws IOException {
- stubFor(post(urlPathEqualTo("/v2.0/tokens"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/v2.0/tokens"))
.withRequestBody(containing("tenantId"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(getBodyFromFile("OpenstackResponse_Access.json", wireMockPort, "/mockPublicUrl"))
.withStatus(HttpStatus.SC_OK)));
- mockOpenStackGetStackCreated_200("OpenstackResponse_Stack_Created.json", "dvspg-VCE_VPE-mtjnj40avbc");
- mockOpenStackGetStackDeleteOrUpdateComplete_200("OpenstackResponse_Stack_UpdateComplete.json");
- mockOpenStackPutPublicUrlStackByNameAndID_NETWORK2_200();
+ mockOpenStackGetStackCreated_200(wireMockServer, "OpenstackResponse_Stack_Created.json", "dvspg-VCE_VPE-mtjnj40avbc");
+ mockOpenStackGetStackDeleteOrUpdateComplete_200(wireMockServer, "OpenstackResponse_Stack_UpdateComplete.json");
+ mockOpenStackPutPublicUrlStackByNameAndID_NETWORK2_200(wireMockServer);
HashMap<String,String> networkParams = new HashMap<String,String>();
networkParams.put("shared", "true");
networkParams.put("external", "false");
@@ -220,19 +219,19 @@ public class MsoNetworkAdapterAsyncImplTest extends BaseRestTestUtils {
@Test
public void queryNetworkATest() throws IOException {
- mockOpenStackResponseAccessQueryNetwork(wireMockPort);
+ mockOpenStackResponseAccessQueryNetwork(wireMockServer, wireMockPort);
impl.queryNetworkA("mtn13", "tenantId", "networkId", "messageId", new MsoRequest(),
"http://localhost:"+wireMockPort+"/notificationUrl");
}
@Test
public void createNetworkATest() throws IOException {
- stubFor(post(urlPathEqualTo("/v2.0/tokens"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/v2.0/tokens"))
.withRequestBody(containing("tenantId"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(getBodyFromFile("OpenstackResponse_Access.json", wireMockPort, "/mockPublicUrl"))
.withStatus(HttpStatus.SC_OK)));
- stubFor(post(urlPathEqualTo("/notificationUrl"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/notificationUrl"))
.withRequestBody(containing("createNetworkNotification"))
.willReturn(aResponse()
.withBody("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:net=\"http://org.onap.so/networkNotify\">\n" +
@@ -243,9 +242,9 @@ public class MsoNetworkAdapterAsyncImplTest extends BaseRestTestUtils {
" </soapenv:Body>\n" +
"</soapenv:Envelope>")
.withStatus(HttpStatus.SC_OK)));
- mockOpenStackGetStackCreatedVUSP_200();
- mockOpenStackPostStacks_200();
- mockOpenStackPostStacks_200();
+ mockOpenStackGetStackCreatedVUSP_200(wireMockServer);
+ mockOpenStackPostStacks_200(wireMockServer);
+ mockOpenStackPostStacks_200(wireMockServer);
HashMap<String,String> networkParams = new HashMap<String,String>();
impl.createNetworkA("mtn13", "tenantId", "networkType", "3bdbb104-476c-483e-9f8b-c095b3d3068c", "vUSP-23804-T-01-dpa2b_EVUSP-CORE-VIF-TSIG0_net_0",
"physicalNetworkName", new ArrayList<>(), false, false, new ArrayList<>(), networkParams, "messageId",
@@ -254,13 +253,13 @@ public class MsoNetworkAdapterAsyncImplTest extends BaseRestTestUtils {
@Test
public void createNetworkATest_NotifyException() throws IOException {
- stubFor(post(urlPathEqualTo("/v2.0/tokens"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/v2.0/tokens"))
.withRequestBody(containing("tenantId"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(getBodyFromFile("OpenstackResponse_Access.json", wireMockPort, "/mockPublicUrl"))
.withStatus(HttpStatus.SC_OK)));
- mockOpenStackGetStackCreatedVUSP_200();
- mockOpenStackPostStacks_200();
+ mockOpenStackGetStackCreatedVUSP_200(wireMockServer);
+ mockOpenStackPostStacks_200(wireMockServer);
HashMap<String,String> networkParams = new HashMap<String,String>();
networkParams.put("shared", "true");
networkParams.put("external", "false");
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java
index 4e2d5e5da2..97392adeef 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java
@@ -102,13 +102,13 @@ public class NetworkAdapterRestTest extends BaseRestTestUtils {
request.setModelCustomizationUuid(MODEL_CUSTOMIZATION_UUID);
request.setNetworkTechnology(networkTechnology);
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackPostPublicUrlWithBodyFile_200();
+ mockOpenStackPostPublicUrlWithBodyFile_200(wireMockServer);
- mockOpenStackGetStackCreatedVUSP_200();
+ mockOpenStackGetStackCreatedVUSP_200(wireMockServer);
- mockOpenStackGetStackVUSP_404();
+ mockOpenStackGetStackVUSP_404(wireMockServer);
headers.add("Accept", MediaType.APPLICATION_JSON);
HttpEntity<CreateNetworkRequest> entity = new HttpEntity<CreateNetworkRequest>(request, headers);
@@ -127,13 +127,13 @@ public class NetworkAdapterRestTest extends BaseRestTestUtils {
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackPostPublicUrlWithBodyFile_200();
+ mockOpenStackPostPublicUrlWithBodyFile_200(wireMockServer);
- mockOpenStackGetStackCreatedAppC_200();
+ mockOpenStackGetStackCreatedAppC_200(wireMockServer);
- mockOpenStackGetStackAppC_404();
+ mockOpenStackGetStackAppC_404(wireMockServer);
headers.add("Content-Type", MediaType.APPLICATION_JSON);
headers.add("Accept", MediaType.APPLICATION_JSON);
@@ -170,13 +170,13 @@ public class NetworkAdapterRestTest extends BaseRestTestUtils {
request.setModelCustomizationUuid(MODEL_CUSTOMIZATION_UUID);
request.setNetworkStackId(NETWORK_ID);
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackPublicUrlStackByID_200(wireMockPort);
+ mockOpenStackPublicUrlStackByID_200(wireMockServer, wireMockPort);
- mockOpenStackGetPublicUrlStackByNameAndID_204(wireMockPort);
+ mockOpenStackGetPublicUrlStackByNameAndID_204(wireMockServer, wireMockPort);
- mockOpenStackDeletePublicUrlStackByNameAndID_204();
+ mockOpenStackDeletePublicUrlStackByNameAndID_204(wireMockServer);
headers.add("Accept", MediaType.APPLICATION_JSON);
@@ -203,13 +203,13 @@ public class NetworkAdapterRestTest extends BaseRestTestUtils {
msoReq.setRequestId(MSO_REQUEST_ID);
msoReq.setServiceInstanceId(MSO_SERVICE_INSTANCE_ID);
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackPublicUrlStackByID_200(wireMockPort);
+ mockOpenStackPublicUrlStackByID_200(wireMockServer, wireMockPort);
- mockOpenStackGetPublicUrlStackByNameAndID_204(wireMockPort);
+ mockOpenStackGetPublicUrlStackByNameAndID_204(wireMockServer, wireMockPort);
- mockOpenStackDeletePublicUrlStackByNameAndID_204();
+ mockOpenStackDeletePublicUrlStackByNameAndID_204(wireMockServer);
headers.add("Accept", MediaType.APPLICATION_JSON);
@@ -247,8 +247,8 @@ public class NetworkAdapterRestTest extends BaseRestTestUtils {
@Test
public void testQueryNetwork() throws IOException{
- mockOpenStackResponseAccess(wireMockPort);
- mockOpenStackGetStackVfModule_200();
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
+ mockOpenStackGetStackVfModule_200(wireMockServer);
headers.add("Accept", MediaType.APPLICATION_JSON);
HttpEntity<DeleteNetworkRequest> entity = new HttpEntity<DeleteNetworkRequest>(headers);
@@ -280,15 +280,15 @@ public class NetworkAdapterRestTest extends BaseRestTestUtils {
request.setModelCustomizationUuid(MODEL_CUSTOMIZATION_UUID);
request.setNetworkStackId(NETWORK_ID);
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackPublicUrlStackByName_200(wireMockPort);
+ mockOpenStackPublicUrlStackByName_200(wireMockServer, wireMockPort);
- mockOpenStackPublicUrlStackByID_200(wireMockPort);
+ mockOpenStackPublicUrlStackByID_200(wireMockServer, wireMockPort);
- mockOpenStackGetPublicUrlStackByNameAndID_200(wireMockPort);
+ mockOpenStackGetPublicUrlStackByNameAndID_200(wireMockServer, wireMockPort);
- mockOpenStackPutPublicUrlStackByNameAndID_200();
+ mockOpenStackPutPublicUrlStackByNameAndID_200(wireMockServer);
headers.add("Accept", MediaType.APPLICATION_JSON);
@@ -307,13 +307,13 @@ public class NetworkAdapterRestTest extends BaseRestTestUtils {
@Test
public void testCreateNetworkCNRC_JSON() throws JSONException, JsonParseException, JsonMappingException, IOException {
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackPostPublicUrlWithBodyFile_200();
+ mockOpenStackPostPublicUrlWithBodyFile_200(wireMockServer);
- mockOpenStackGetStackCreatedAppC_200();
+ mockOpenStackGetStackCreatedAppC_200(wireMockServer);
- mockOpenStackGetStackAppC_404();
+ mockOpenStackGetStackAppC_404(wireMockServer);
headers.add("Content-Type", MediaType.APPLICATION_JSON);
headers.add("Accept", MediaType.APPLICATION_JSON);
@@ -334,13 +334,13 @@ public class NetworkAdapterRestTest extends BaseRestTestUtils {
@Test
public void testCreateNetworkNC_Shared_JSON() throws JSONException, JsonParseException, JsonMappingException, IOException {
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackPostPublicUrlWithBodyFile_200();
+ mockOpenStackPostPublicUrlWithBodyFile_200(wireMockServer);
- mockOpenStackGetStackCreatedAppC_200();
+ mockOpenStackGetStackCreatedAppC_200(wireMockServer);
- mockOpenStackGetStackAppC_404();
+ mockOpenStackGetStackAppC_404(wireMockServer);
headers.add("Content-Type", MediaType.APPLICATION_JSON);
headers.add("Accept", MediaType.APPLICATION_JSON);
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/TenantAdapterRestTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/TenantAdapterRestTest.java
index 405118cb30..f24a5a5292 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/TenantAdapterRestTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/TenantAdapterRestTest.java
@@ -90,19 +90,19 @@ public class TenantAdapterRestTest extends BaseRestTestUtils {
request.setBackout(backout);
request.setFailIfExists(failIfExists);
- mockOpenStackResponseAccessAdmin(wireMockPort);
+ mockOpenStackResponseAccessAdmin(wireMockServer, wireMockPort);
- mockOpenStackGetTenantByName_404(tenantName);
+ mockOpenStackGetTenantByName_404(wireMockServer, tenantName);
- mockOpenStackPostTenantWithBodyFile_200();
+ mockOpenStackPostTenantWithBodyFile_200(wireMockServer);
- mockOpenStackGetUser_200("m93945");
+ mockOpenStackGetUser_200(wireMockServer, "m93945");
- mockOpenStackGetRoles_200("OS-KSADM");
+ mockOpenStackGetRoles_200(wireMockServer, "OS-KSADM");
- mockOpenStackPutRolesAdmin_200("OS-KSADM");
+ mockOpenStackPutRolesAdmin_200(wireMockServer, "OS-KSADM");
- mockOpenStackPostMetadata_200();
+ mockOpenStackPostMetadata_200(wireMockServer);
headers.add("Accept", MediaType.APPLICATION_JSON);
HttpEntity<CreateTenantRequest> entity = new HttpEntity<CreateTenantRequest>(request, headers);
@@ -141,13 +141,13 @@ public class TenantAdapterRestTest extends BaseRestTestUtils {
request.setBackout(backout);
request.setFailIfExists(failIfExists);
- mockOpenStackResponseAccessAdmin(wireMockPort);
+ mockOpenStackResponseAccessAdmin(wireMockServer, wireMockPort);
- mockOpenStackGetTenantByName_200(tenantName);
+ mockOpenStackGetTenantByName_200(wireMockServer, tenantName);
- mockOpenStackPostTenant_200();
+ mockOpenStackPostTenant_200(wireMockServer);
- mockOpenStackGetMetadata_200();
+ mockOpenStackGetMetadata_200(wireMockServer);
headers.add("Accept", MediaType.APPLICATION_JSON);
HttpEntity<CreateTenantRequest> entity = new HttpEntity<CreateTenantRequest>(request, headers);
@@ -180,11 +180,11 @@ public class TenantAdapterRestTest extends BaseRestTestUtils {
request.setTenantId(tenantId);
request.setMsoRequest(msoReq);
- mockOpenStackResponseAccessAdmin(wireMockPort);
+ mockOpenStackResponseAccessAdmin(wireMockServer, wireMockPort);
- mockOpenStackGetTenantById_200(tenantId);
+ mockOpenStackGetTenantById_200(wireMockServer, tenantId);
- mockOpenStackDeleteTenantById_200(tenantId);
+ mockOpenStackDeleteTenantById_200(wireMockServer, tenantId);
headers.add("Accept", MediaType.APPLICATION_JSON);
HttpEntity<DeleteTenantRequest> entity = new HttpEntity<DeleteTenantRequest>(request, headers);
@@ -218,9 +218,9 @@ public class TenantAdapterRestTest extends BaseRestTestUtils {
request.setTenantId(tenantId);
request.setMsoRequest(msoReq);
- mockOpenStackResponseAccessAdmin(wireMockPort);
+ mockOpenStackResponseAccessAdmin(wireMockServer, wireMockPort);
- mockOpenStackGetTenantById_404(tenantId);
+ mockOpenStackGetTenantById_404(wireMockServer, tenantId);
headers.add("Accept", MediaType.APPLICATION_JSON);
HttpEntity<DeleteTenantRequest> entity = new HttpEntity<DeleteTenantRequest>(request, headers);
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/valet/ValetClientTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/valet/ValetClientTest.java
index 8f6a18225d..0b83386ccc 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/valet/ValetClientTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/valet/ValetClientTest.java
@@ -59,7 +59,7 @@ public class ValetClientTest extends BaseRestTestUtils {
ValetCreateResponse vcr = mapper.readValue(new File("src/test/resources/__files/ValetCreateRequest.json"), ValetCreateResponse.class);
GenericValetResponse<ValetCreateResponse> expected = new GenericValetResponse<ValetCreateResponse>(HttpStatus.SC_OK, ValetClient.NO_STATUS_RETURNED, vcr);
- mockValetCreatePostResponse_200("requestId", mapper.writeValueAsString(vcr));
+ mockValetCreatePostResponse_200(wireMockServer, "requestId", mapper.writeValueAsString(vcr));
GenericValetResponse<ValetCreateResponse> actual = client.callValetCreateRequest("requestId", "regionId", "ownerId", "tenantId", "serviceInstanceId", "vnfId", "vnfName", "vfModuleId", "vfModuleName", "keystoneUrl", null);
@@ -71,7 +71,7 @@ public class ValetClientTest extends BaseRestTestUtils {
ValetUpdateResponse vur = mapper.readValue(new File("src/test/resources/__files/ValetCreateRequest.json"), ValetUpdateResponse.class);
GenericValetResponse<ValetUpdateResponse> expected = new GenericValetResponse<ValetUpdateResponse>(HttpStatus.SC_OK, ValetClient.NO_STATUS_RETURNED, vur);
- mockValetCreatePutResponse_200("requestId", mapper.writeValueAsString(vur));
+ mockValetCreatePutResponse_200(wireMockServer, "requestId", mapper.writeValueAsString(vur));
GenericValetResponse<ValetUpdateResponse> actual = client.callValetUpdateRequest("requestId", "regionId", "ownerId", "tenantId", "serviceInstanceId", "vnfId", "vnfName", "vfModuleId", "vfModuleName", "keystoneUrl", null);
@@ -83,7 +83,7 @@ public class ValetClientTest extends BaseRestTestUtils {
ValetDeleteResponse vdr = mapper.readValue(new File("src/test/resources/__files/ValetDeleteRequest.json"), ValetDeleteResponse.class);
GenericValetResponse<ValetDeleteResponse> expected = new GenericValetResponse<ValetDeleteResponse>(HttpStatus.SC_OK, ValetClient.NO_STATUS_RETURNED, vdr);
- mockValetDeleteDeleteResponse_200("requestId", mapper.writeValueAsString(vdr));
+ mockValetDeleteDeleteResponse_200(wireMockServer, "requestId", mapper.writeValueAsString(vdr));
GenericValetResponse<ValetDeleteResponse> actual = client.callValetDeleteRequest("requestId", "regionId", "ownerId", "tenantId", "vfModuleId", "vfModuleName");
@@ -95,7 +95,7 @@ public class ValetClientTest extends BaseRestTestUtils {
ValetConfirmResponse vcr = new ValetConfirmResponse();
GenericValetResponse<ValetConfirmResponse> expected = new GenericValetResponse<ValetConfirmResponse>(HttpStatus.SC_OK, ValetClient.NO_STATUS_RETURNED, vcr);
- mockValetConfirmPutRequest_200("requestId", "{}");
+ mockValetConfirmPutRequest_200(wireMockServer, "requestId", "{}");
GenericValetResponse<ValetConfirmResponse> actual = client.callValetConfirmRequest("requestId", "stackId");
@@ -107,7 +107,7 @@ public class ValetClientTest extends BaseRestTestUtils {
ValetRollbackResponse vrr = new ValetRollbackResponse();
GenericValetResponse<ValetRollbackResponse> expected = new GenericValetResponse<ValetRollbackResponse>(HttpStatus.SC_OK, ValetClient.NO_STATUS_RETURNED, vrr);
- mockValetRollbackPutRequest_200("requestId", "{}");
+ mockValetRollbackPutRequest_200(wireMockServer, "requestId", "{}");
GenericValetResponse<ValetRollbackResponse> actual = client.callValetRollbackRequest("requestId", "stackId", true, "error");
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/AllTestsTestSuite.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/AllTestsTestSuite.java
new file mode 100644
index 0000000000..f086653fea
--- /dev/null
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/AllTestsTestSuite.java
@@ -0,0 +1,32 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 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.so.adapters.vnf;
+import org.junit.runner.RunWith;
+
+import com.googlecode.junittoolbox.SuiteClasses;
+import com.googlecode.junittoolbox.WildcardPatternSuite;
+
+@RunWith(WildcardPatternSuite.class)
+@SuiteClasses("**/*Test.class")
+public class AllTestsTestSuite {
+ // the class remains empty,
+ // used only as a holder for the above annotations
+}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/BaseRestTestUtils.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/BaseRestTestUtils.java
index 017aa26758..b9edb68bb1 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/BaseRestTestUtils.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/BaseRestTestUtils.java
@@ -20,10 +20,17 @@
package org.onap.so.adapters.vnf;
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.JsonMappingException;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+
+import javax.ws.rs.core.MediaType;
+
import org.apache.http.HttpStatus;
import org.junit.Before;
import org.junit.Test;
@@ -37,25 +44,19 @@ import org.onap.so.db.catalog.beans.ServerType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
+import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock;
import org.springframework.http.HttpHeaders;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
-import javax.ws.rs.core.MediaType;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.reset;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.github.tomakehurst.wiremock.WireMockServer;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = MsoOpenstackAdaptersApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@@ -64,6 +65,10 @@ import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
public abstract class BaseRestTestUtils {
@Value("${wiremock.server.port}")
protected int wireMockPort;
+
+ @Autowired
+ protected WireMockServer wireMockServer;
+
@Autowired
CloudConfig cloudConfig;
@@ -112,7 +117,7 @@ public abstract class BaseRestTestUtils {
*/
@Before
public void setUp() throws Exception {
- reset();
+ wireMockServer.resetAll();
mapper = new ObjectMapper();
CloudIdentity identity = new CloudIdentity();
identity.setId("MTN13");
@@ -134,15 +139,15 @@ public abstract class BaseRestTestUtils {
identity.setIdentityServerType(ServerType.KEYSTONE);
cloudSite.setIdentityService(identity);
- stubFor(get(urlPathEqualTo("/cloudSite/MTN13")).willReturn(aResponse()
+ wireMockServer.stubFor(get(urlPathEqualTo("/cloudSite/MTN13")).willReturn(aResponse()
.withBody(getBody(mapper.writeValueAsString(cloudSite),wireMockPort, ""))
.withHeader(org.apache.http.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlPathEqualTo("/cloudSite/DEFAULT")).willReturn(aResponse()
+ wireMockServer.stubFor(get(urlPathEqualTo("/cloudSite/DEFAULT")).willReturn(aResponse()
.withBody(getBody(mapper.writeValueAsString(cloudSite),wireMockPort, ""))
.withHeader(org.apache.http.HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlPathEqualTo("/cloudIdentity/MTN13")).willReturn(aResponse()
+ wireMockServer.stubFor(get(urlPathEqualTo("/cloudIdentity/MTN13")).willReturn(aResponse()
.withBody(getBody(mapper.writeValueAsString(identity),wireMockPort, ""))
.withHeader(org.apache.http.HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_OK)));
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImplTest.java
index cbf252ec3a..02fbe2c530 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImplTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImplTest.java
@@ -21,33 +21,26 @@
package org.onap.so.adapters.vnf;
-import org.apache.http.HttpStatus;
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.onap.so.adapters.vnf.exceptions.VnfException;
-import org.onap.so.entity.MsoRequest;
-import org.onap.so.openstack.beans.VnfRollback;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.mock.mockito.SpyBean;
-
-import java.util.HashMap;
-import java.util.Map;
-
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.containing;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
-import static com.github.tomakehurst.wiremock.client.WireMock.verify;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.doThrow;
import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_200;
import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackResponseAccess;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.http.HttpStatus;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onap.so.entity.MsoRequest;
+import org.onap.so.openstack.beans.VnfRollback;
+import org.springframework.beans.factory.annotation.Autowired;
+
public class MsoVnfAdapterAsyncImplTest extends BaseRestTestUtils {
@Autowired
@@ -67,9 +60,9 @@ public class MsoVnfAdapterAsyncImplTest extends BaseRestTestUtils {
msoRequest.setRequestId("12345");
msoRequest.setServiceInstanceId("12345");
- mockOpenStackResponseAccess(wireMockPort);
- mockOpenStackGetStackVfModule_200();
- stubFor(post(urlPathEqualTo("/notify/adapterNotify/updateVnfNotificationRequest")).withRequestBody
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
+ mockOpenStackGetStackVfModule_200(wireMockServer);
+ wireMockServer.stubFor(post(urlPathEqualTo("/notify/adapterNotify/updateVnfNotificationRequest")).withRequestBody
(containing("messageId"))
.willReturn(aResponse().withStatus(HttpStatus.SC_OK)));
@@ -79,7 +72,7 @@ public class MsoVnfAdapterAsyncImplTest extends BaseRestTestUtils {
"volumeGroupHeatStackId|1", new HashMap<String, Object>(), Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, "messageId",
msoRequest, notificationUrl);
- verify(1,postRequestedFor(urlEqualTo("/notify/adapterNotify/updateVnfNotificationRequest")));
+ wireMockServer.verify(1,postRequestedFor(urlEqualTo("/notify/adapterNotify/updateVnfNotificationRequest")));
}
@Test
@@ -89,7 +82,7 @@ public class MsoVnfAdapterAsyncImplTest extends BaseRestTestUtils {
"volumeGroupHeatStackId|1", new HashMap<String, Object>(), Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, "messageId",
null, notificationUrl);
- verify(1,postRequestedFor(urlEqualTo("/notify/adapterNotify/updateVnfNotificationRequest")));
+ wireMockServer.verify(1,postRequestedFor(urlEqualTo("/notify/adapterNotify/updateVnfNotificationRequest")));
}
@@ -101,7 +94,7 @@ public class MsoVnfAdapterAsyncImplTest extends BaseRestTestUtils {
Map<String, Object> map = new HashMap<>();
map.put("key1", "value1");
- stubFor(post(urlPathEqualTo("/notify/adapterNotify/updateVnfNotificationRequest")).withRequestBody
+ wireMockServer.stubFor(post(urlPathEqualTo("/notify/adapterNotify/updateVnfNotificationRequest")).withRequestBody
(containing("messageId"))
.willReturn(aResponse().withStatus(HttpStatus.SC_OK)));
String notificationUrl = "http://localhost:"+wireMockPort+"/notify/adapterNotify/updateVnfNotificationRequest";
@@ -118,14 +111,14 @@ public class MsoVnfAdapterAsyncImplTest extends BaseRestTestUtils {
Map<String, Object> map = new HashMap<>();
map.put("key1", "value1");
- stubFor(post(urlPathEqualTo("/notify/adapterNotify/updateVnfNotificationRequest")).withRequestBody
+ wireMockServer.stubFor(post(urlPathEqualTo("/notify/adapterNotify/updateVnfNotificationRequest")).withRequestBody
(containing("messageId"))
.willReturn(aResponse().withStatus(HttpStatus.SC_OK)));
String notificationUrl = "http://localhost:"+wireMockPort+"/notify/adapterNotify/updateVnfNotificationRequest";
instance.updateVnfA("mdt1", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
"volumeGroupHeatStackId|1", map, "messageId", msoRequest,
notificationUrl);
- verify(1,postRequestedFor(urlEqualTo("/notify/adapterNotify/updateVnfNotificationRequest")));
+ wireMockServer.verify(1,postRequestedFor(urlEqualTo("/notify/adapterNotify/updateVnfNotificationRequest")));
}
@Test
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java
index 0816bc55a6..e40aab9ba1 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java
@@ -21,7 +21,23 @@
package org.onap.so.adapters.vnf;
-import com.github.tomakehurst.wiremock.client.WireMock;
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+import static org.mockito.Mockito.when;
+import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_200;
+import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_404;
+import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackPutStack;
+import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackResponseAccess;
+import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenstackGetWithResponse;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.ws.Holder;
+
import org.apache.http.HttpStatus;
import org.junit.Before;
import org.junit.Ignore;
@@ -38,8 +54,6 @@ import org.onap.so.db.catalog.beans.HeatTemplateParam;
import org.onap.so.db.catalog.beans.VfModule;
import org.onap.so.db.catalog.beans.VfModuleCustomization;
import org.onap.so.db.catalog.beans.VnfResource;
-import org.onap.so.db.catalog.data.repository.VFModuleCustomizationRepository;
-import org.onap.so.db.catalog.data.repository.VnfResourceRepository;
import org.onap.so.entity.MsoRequest;
import org.onap.so.openstack.beans.HeatStatus;
import org.onap.so.openstack.beans.StackInfo;
@@ -47,25 +61,8 @@ import org.onap.so.openstack.beans.VnfRollback;
import org.onap.so.openstack.exceptions.MsoException;
import org.onap.so.openstack.utils.MsoHeatUtils;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.mock.mockito.MockBean;
-import javax.xml.ws.Holder;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.when;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_404;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackPutStack;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackResponseAccess;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenstackGetWithResponse;
+import com.github.tomakehurst.wiremock.client.WireMock;
public class MsoVnfAdapterImplTest extends BaseRestTestUtils {
@@ -80,13 +77,6 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils {
String vnfName = "DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001/stackId";
- @Before
- public void before() throws Exception {
- MockitoAnnotations.initMocks(this);
- WireMock.reset();
- setUp();
- }
-
@Test
@Ignore
public void healthCheckVNFTest() {
@@ -99,8 +89,8 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils {
StackInfo info = new StackInfo();
info.setStatus(HeatStatus.CREATED);
- mockOpenStackResponseAccess(wireMockPort);
- mockOpenStackGetStackVfModule_200();
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
+ mockOpenStackGetStackVfModule_200(wireMockServer);
MsoRequest msoRequest = getMsoRequest();
@@ -115,9 +105,9 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils {
@Test
public void createVnfTest_HeatStatusUpdating() throws Exception {
expectedException.expect(VnfAlreadyExists.class);
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001/stackId"))
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001/stackId"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBodyFile("OpenstackResponse_Stack_Updating_VfModule.json")
.withStatus(HttpStatus.SC_OK)));
@@ -135,9 +125,9 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils {
@Test
public void createVnfTest_HeatStatusUpdated() throws Exception {
expectedException.expect(VnfAlreadyExists.class);
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001/stackId"))
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001/stackId"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBodyFile("OpenstackResponse_StackId.json")
.withStatus(HttpStatus.SC_OK)));
@@ -155,9 +145,9 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils {
@Test
public void createVnfTest_HeatStatusFailed() throws Exception {
expectedException.expect(VnfAlreadyExists.class);
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001/stackId"))
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001/stackId"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBodyFile("OpenstackResponse_Stack_Failed_VfModule.json")
.withStatus(HttpStatus.SC_OK)));
@@ -175,9 +165,9 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils {
@Test
public void createVnfTest_HeatStatusCreated() throws Exception {
expectedException.expect(VnfAlreadyExists.class);
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetStackVfModule_200();
+ mockOpenStackGetStackVfModule_200(wireMockServer);
MsoRequest msoRequest = getMsoRequest();
@@ -206,8 +196,8 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils {
@Test
public void createVnfTest_NestedHeatStatusNotFound() throws Exception {
expectedException.expect(VnfException.class);
- mockOpenStackResponseAccess(wireMockPort);
- mockOpenStackGetStackVfModule_404();
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
+ mockOpenStackGetStackVfModule_404(wireMockServer);
MsoRequest msoRequest = getMsoRequest();
@@ -222,9 +212,9 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils {
@Test
public void createVnfTest_ExceptionInGettingNestedHeat() throws Exception {
expectedException.expect(VnfException.class);
- mockOpenStackResponseAccess(wireMockPort);
- mockOpenStackGetStackVfModule_404();
- stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/volumeGroupHeatStackId"))
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
+ mockOpenStackGetStackVfModule_404(wireMockServer);
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/volumeGroupHeatStackId"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
@@ -241,9 +231,9 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils {
@Test
public void createVnfTest_NestedBaseHeatStatus_NotFound() throws Exception {
expectedException.expect(VnfException.class);
- mockOpenStackResponseAccess(wireMockPort);
- mockOpenStackGetStackVfModule_404();
- stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/volumeGroupHeatStackId"))
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
+ mockOpenStackGetStackVfModule_404(wireMockServer);
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/volumeGroupHeatStackId"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBodyFile("OpenstackResponse_Stack_Created_VfModule.json")
.withStatus(HttpStatus.SC_OK)));
@@ -261,10 +251,10 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils {
@Test
public void createVnfTest_ExceptionInGettingBaseNestedHeat() throws Exception {
expectedException.expect(VnfException.class);
- mockOpenStackResponseAccess(wireMockPort);
- mockOpenStackGetStackVfModule_404();
- stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/volumeGroupHeatStackId")).willReturn(aResponse().withBodyFile("OpenstackResponse_Stack_Created_VfModule.json").withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/baseVfHeatStackId")).willReturn(aResponse().withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
+ mockOpenStackGetStackVfModule_404(wireMockServer);
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/volumeGroupHeatStackId")).willReturn(aResponse().withBodyFile("OpenstackResponse_Stack_Created_VfModule.json").withStatus(HttpStatus.SC_OK)));
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/baseVfHeatStackId")).willReturn(aResponse().withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
MsoRequest msoRequest = getMsoRequest();
@@ -279,10 +269,10 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils {
@Test
public void createVnfTest_ExceptionInCreateStack() throws Exception {
expectedException.expect(VnfException.class);
- mockOpenStackResponseAccess(wireMockPort);
- mockOpenStackGetStackVfModule_404();
- stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/volumeGroupHeatStackId")).willReturn(aResponse().withBodyFile("OpenstackResponse_Stack_Created_VfModule.json").withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/baseVfHeatStackId")).willReturn(aResponse().withBodyFile("OpenstackResponse_Stack_Created_VfModule.json").withStatus(HttpStatus.SC_OK)));
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
+ mockOpenStackGetStackVfModule_404(wireMockServer);
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/volumeGroupHeatStackId")).willReturn(aResponse().withBodyFile("OpenstackResponse_Stack_Created_VfModule.json").withStatus(HttpStatus.SC_OK)));
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/baseVfHeatStackId")).willReturn(aResponse().withBodyFile("OpenstackResponse_Stack_Created_VfModule.json").withStatus(HttpStatus.SC_OK)));
VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
VfModule vfModule = new VfModule();
@@ -311,10 +301,10 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils {
@Test
public void createVnfTest_ModelCustUuidIsNull() throws Exception {
expectedException.expect(VnfException.class);
- mockOpenStackResponseAccess(wireMockPort);
- mockOpenStackGetStackVfModule_404();
- stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/volumeGroupHeatStackId")).willReturn(aResponse().withBodyFile("OpenstackResponse_Stack_Created_VfModule.json").withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/baseVfHeatStackId")).willReturn(aResponse().withBodyFile("OpenstackResponse_Stack_Created_VfModule.json").withStatus(HttpStatus.SC_OK)));
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
+ mockOpenStackGetStackVfModule_404(wireMockServer);
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/volumeGroupHeatStackId")).willReturn(aResponse().withBodyFile("OpenstackResponse_Stack_Created_VfModule.json").withStatus(HttpStatus.SC_OK)));
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/baseVfHeatStackId")).willReturn(aResponse().withBodyFile("OpenstackResponse_Stack_Created_VfModule.json").withStatus(HttpStatus.SC_OK)));
VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
VfModule vfModule = new VfModule();
@@ -348,10 +338,10 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils {
@Test
public void createVnfTest_HeatEnvironment_ContainsParameters() throws Exception {
expectedException.expect(VnfException.class);
- mockOpenStackResponseAccess(wireMockPort);
- mockOpenStackGetStackVfModule_404();
- stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/volumeGroupHeatStackId")).willReturn(aResponse().withBodyFile("OpenstackResponse_Stack_Created_VfModule.json").withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/baseVfHeatStackId")).willReturn(aResponse().withBodyFile("OpenstackResponse_Stack_Created_VfModule.json").withStatus(HttpStatus.SC_OK)));
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
+ mockOpenStackGetStackVfModule_404(wireMockServer);
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/volumeGroupHeatStackId")).willReturn(aResponse().withBodyFile("OpenstackResponse_Stack_Created_VfModule.json").withStatus(HttpStatus.SC_OK)));
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/baseVfHeatStackId")).willReturn(aResponse().withBodyFile("OpenstackResponse_Stack_Created_VfModule.json").withStatus(HttpStatus.SC_OK)));
MsoRequest msoRequest = getMsoRequest();
@@ -387,7 +377,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils {
public void updateVnfTest_HeatStackNotFound() throws Exception {
expectedException.expect(VnfNotFound.class);
MsoRequest msoRequest = getMsoRequest();
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
Map<String, Object> map = new HashMap<>();
map.put("key1", "value1");
instance.updateVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", vnfName, "VFMOD",
@@ -400,9 +390,9 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils {
public void updateVnfTest_ExceptionInGettingNestedHeatStack() throws Exception {
expectedException.expect(VnfException.class);
MsoRequest msoRequest = getMsoRequest();
- mockOpenStackResponseAccess(wireMockPort);
- mockOpenStackGetStackVfModule_200();
- stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/volumeGroupHeatStackId"))
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
+ mockOpenStackGetStackVfModule_200(wireMockServer);
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/volumeGroupHeatStackId"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
Map<String, Object> map = new HashMap<>();
@@ -417,9 +407,9 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils {
public void updateVnfTest_NestedHeatStackNotFound() throws Exception {
expectedException.expect(VnfException.class);
MsoRequest msoRequest = getMsoRequest();
- mockOpenStackResponseAccess(wireMockPort);
- mockOpenStackGetStackVfModule_200();
- stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/volumeGroupHeatStackId"))
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
+ mockOpenStackGetStackVfModule_200(wireMockServer);
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/volumeGroupHeatStackId"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withStatus(HttpStatus.SC_NOT_FOUND)));
Map<String, Object> map = new HashMap<>();
@@ -434,10 +424,10 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils {
public void updateVnfTest_ExceptionInGettingNestedBaseHeatStack() throws Exception {
expectedException.expect(VnfException.class);
MsoRequest msoRequest = getMsoRequest();
- mockOpenStackResponseAccess(wireMockPort);
- mockOpenStackGetStackVfModule_200();
- mockOpenstackGetWithResponse("/mockPublicUrl/stacks/volumeGroupHeatStackId",HttpStatus.SC_OK,"OpenstackResponse_Stack_Created_VfModule.json");
- mockOpenstackGetWithResponse("/mockPublicUrl/stacks/baseVfHeatStackId",HttpStatus.SC_INTERNAL_SERVER_ERROR,"OpenstackResponse_Stack_Created_VfModule.json");
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
+ mockOpenStackGetStackVfModule_200(wireMockServer);
+ mockOpenstackGetWithResponse(wireMockServer, "/mockPublicUrl/stacks/volumeGroupHeatStackId",HttpStatus.SC_OK,"OpenstackResponse_Stack_Created_VfModule.json");
+ mockOpenstackGetWithResponse(wireMockServer, "/mockPublicUrl/stacks/baseVfHeatStackId",HttpStatus.SC_INTERNAL_SERVER_ERROR,"OpenstackResponse_Stack_Created_VfModule.json");
Map<String, Object> map = new HashMap<>();
map.put("key1", "value1");
instance.updateVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", vnfName, "VFMOD",
@@ -450,10 +440,10 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils {
public void updateVnfTest_NestedBaseHeatStackNotFound() throws Exception {
expectedException.expect(VnfException.class);
MsoRequest msoRequest = getMsoRequest();
- mockOpenStackResponseAccess(wireMockPort);
- mockOpenStackGetStackVfModule_200();
- mockOpenstackGetWithResponse("/mockPublicUrl/stacks/volumeGroupHeatStackId",HttpStatus.SC_OK,"OpenstackResponse_Stack_Created_VfModule.json");
- mockOpenstackGetWithResponse("/mockPublicUrl/stacks/baseVfHeatStackId",HttpStatus.SC_NOT_FOUND,"OpenstackResponse_Stack_Created_VfModule.json");
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
+ mockOpenStackGetStackVfModule_200(wireMockServer);
+ mockOpenstackGetWithResponse(wireMockServer, "/mockPublicUrl/stacks/volumeGroupHeatStackId",HttpStatus.SC_OK,"OpenstackResponse_Stack_Created_VfModule.json");
+ mockOpenstackGetWithResponse(wireMockServer, "/mockPublicUrl/stacks/baseVfHeatStackId",HttpStatus.SC_NOT_FOUND,"OpenstackResponse_Stack_Created_VfModule.json");
Map<String, Object> map = new HashMap<>();
map.put("key1", "value1");
instance.updateVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", vnfName, "VFMOD",
@@ -466,10 +456,10 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils {
public void updateVnfTest_MissingParams() throws Exception {
expectedException.expect(VnfException.class);
MsoRequest msoRequest = getMsoRequest();
- mockOpenStackResponseAccess(wireMockPort);
- mockOpenStackGetStackVfModule_200();
- mockOpenstackGetWithResponse("/mockPublicUrl/stacks/volumeGroupHeatStackId",HttpStatus.SC_OK,"OpenstackResponse_Stack_Created_VfModule.json");
- mockOpenstackGetWithResponse("/mockPublicUrl/stacks/baseVfHeatStackId",HttpStatus.SC_OK,"OpenstackResponse_Stack_Created_VfModule.json");
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
+ mockOpenStackGetStackVfModule_200(wireMockServer);
+ mockOpenstackGetWithResponse(wireMockServer, "/mockPublicUrl/stacks/volumeGroupHeatStackId",HttpStatus.SC_OK,"OpenstackResponse_Stack_Created_VfModule.json");
+ mockOpenstackGetWithResponse(wireMockServer, "/mockPublicUrl/stacks/baseVfHeatStackId",HttpStatus.SC_OK,"OpenstackResponse_Stack_Created_VfModule.json");
Map<String, Object> map = new HashMap<>();
map.put("key1", "value1");
instance.updateVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", vnfName, "VFMOD",
@@ -482,10 +472,10 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils {
public void updateVnfTest_UpdateStackException() throws Exception {
expectedException.expect(VnfException.class);
MsoRequest msoRequest = getMsoRequest();
- mockOpenStackResponseAccess(wireMockPort);
- mockOpenStackGetStackVfModule_200();
- mockOpenstackGetWithResponse("/mockPublicUrl/stacks/volumeGroupHeatStackId",HttpStatus.SC_OK,"OpenstackResponse_Stack_Created_VfModule.json");
- mockOpenstackGetWithResponse("/mockPublicUrl/stacks/baseVfHeatStackId",HttpStatus.SC_OK,"OpenstackResponse_Stack_Created_VfModule.json");
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
+ mockOpenStackGetStackVfModule_200(wireMockServer);
+ mockOpenstackGetWithResponse(wireMockServer, "/mockPublicUrl/stacks/volumeGroupHeatStackId",HttpStatus.SC_OK,"OpenstackResponse_Stack_Created_VfModule.json");
+ mockOpenstackGetWithResponse(wireMockServer, "/mockPublicUrl/stacks/baseVfHeatStackId",HttpStatus.SC_OK,"OpenstackResponse_Stack_Created_VfModule.json");
VfModuleCustomization vfModuleCustomization = getVfModuleCustomization();
vfModuleCustomization.getVfModule().getModuleHeatTemplate().setParameters(new HashSet<>());
@@ -500,12 +490,12 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils {
@Test
public void updateVnfTest() throws Exception {
MsoRequest msoRequest = getMsoRequest();
- mockOpenStackResponseAccess(wireMockPort);
- mockOpenstackGetWithResponse("/mockPublicUrl/stacks/"+vnfName,HttpStatus.SC_OK,"OpenstackResponse_Stack_UpdateComplete.json");
- mockOpenstackGetWithResponse("/mockPublicUrl/stacks/volumeGroupHeatStackId",HttpStatus.SC_OK,"OpenstackResponse_Stack_Created_VfModule.json");
- mockOpenstackGetWithResponse("/mockPublicUrl/stacks/baseVfHeatStackId",HttpStatus.SC_OK,"OpenstackResponse_Stack_Created_VfModule.json");
- mockOpenStackPutStack("null/stackId", HttpStatus.SC_OK);
- mockOpenstackGetWithResponse("/mockPublicUrl/stacks/null/stackId",HttpStatus.SC_OK,"OpenstackResponse_Stack_UpdateComplete.json");
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
+ mockOpenstackGetWithResponse(wireMockServer, "/mockPublicUrl/stacks/"+vnfName,HttpStatus.SC_OK,"OpenstackResponse_Stack_UpdateComplete.json");
+ mockOpenstackGetWithResponse(wireMockServer, "/mockPublicUrl/stacks/volumeGroupHeatStackId",HttpStatus.SC_OK,"OpenstackResponse_Stack_Created_VfModule.json");
+ mockOpenstackGetWithResponse(wireMockServer, "/mockPublicUrl/stacks/baseVfHeatStackId",HttpStatus.SC_OK,"OpenstackResponse_Stack_Created_VfModule.json");
+ mockOpenStackPutStack(wireMockServer, "null/stackId", HttpStatus.SC_OK);
+ mockOpenstackGetWithResponse(wireMockServer, "/mockPublicUrl/stacks/null/stackId",HttpStatus.SC_OK,"OpenstackResponse_Stack_UpdateComplete.json");
VfModuleCustomization vfModuleCustomization = getVfModuleCustomization();
vfModuleCustomization.getVfModule().getModuleHeatTemplate().setParameters(new HashSet<>());
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImplTest.java
index fbb9a224b3..0ace6e4249 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImplTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImplTest.java
@@ -21,6 +21,17 @@
package org.onap.so.adapters.vnf;
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+import static org.junit.Assert.assertTrue;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.ws.Holder;
+
import org.apache.http.HttpStatus;
import org.junit.Before;
import org.junit.Rule;
@@ -33,12 +44,6 @@ import org.onap.so.entity.MsoRequest;
import org.onap.so.openstack.beans.VnfRollback;
import org.springframework.beans.factory.annotation.Autowired;
-import javax.xml.ws.Holder;
-import java.util.HashMap;
-import java.util.Map;
-
-import static com.github.tomakehurst.wiremock.client.WireMock.*;
-
public class MsoVnfCloudifyAdapterImplTest extends BaseRestTestUtils {
@Rule
@@ -62,15 +67,15 @@ public class MsoVnfCloudifyAdapterImplTest extends BaseRestTestUtils {
@Test
public void queryVnfExceptionTest() throws Exception {
- reset();
- expectedException.expect(VnfException.class);
MsoRequest msoRequest = new MsoRequest();
msoRequest.setRequestId("12345");
msoRequest.setServiceInstanceId("12345");
-
+ Holder <Map <String, String>> outputs = new Holder<>();
instance.queryVnf("siteid", "CloudOwner", "1234", "vfname",
msoRequest, new Holder<>(), new Holder<>(), new Holder<>(),
- new Holder<>());
+ outputs);
+
+ assertTrue(outputs.value.isEmpty());
}
@Test
@@ -78,19 +83,19 @@ public class MsoVnfCloudifyAdapterImplTest extends BaseRestTestUtils {
MsoRequest msoRequest = new MsoRequest();
msoRequest.setRequestId("12345");
msoRequest.setServiceInstanceId("12345");
- stubFor(get(urlPathEqualTo("/v2.0/api/v3/deployments/vfname")).willReturn(aResponse()
+ wireMockServer.stubFor(get(urlPathEqualTo("/v2.0/api/v3/deployments/vfname")).willReturn(aResponse()
.withBody("{ \"id\": \"123\" }")
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlPathEqualTo("/v2.0/api/v3/deployments/vfname/outputs")).willReturn(aResponse()
+ wireMockServer.stubFor(get(urlPathEqualTo("/v2.0/api/v3/deployments/vfname/outputs")).willReturn(aResponse()
.withBody("{ \"deployment_id\": \"123\",\"outputs\":{\"abc\":\"abc\"} }")
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlMatching("/v2.0/api/v3/executions?.*")).willReturn(aResponse()
+ wireMockServer.stubFor(get(urlMatching("/v2.0/api/v3/executions?.*")).willReturn(aResponse()
.withBody("{ \"items\": {\"id\": \"123\",\"workflow_id\":\"install\",\"status\":\"terminated\" } } ")
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlPathEqualTo("/v2.0/api/v3/tokens")).willReturn(aResponse()
+ wireMockServer.stubFor(get(urlPathEqualTo("/v2.0/api/v3/tokens")).willReturn(aResponse()
.withBodyFile("OpenstackResponse_Access.json")
.withStatus(HttpStatus.SC_OK)));
@@ -115,19 +120,19 @@ public class MsoVnfCloudifyAdapterImplTest extends BaseRestTestUtils {
MsoRequest msoRequest = new MsoRequest();
msoRequest.setRequestId("12345");
msoRequest.setServiceInstanceId("12345");
- stubFor(get(urlPathEqualTo("/v2.0/api/v3/deployments/vfname")).willReturn(aResponse()
+ wireMockServer.stubFor(get(urlPathEqualTo("/v2.0/api/v3/deployments/vfname")).willReturn(aResponse()
.withBody("{ \"id\": \"123\" }")
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlPathEqualTo("/v2.0/api/v3/deployments/vfname/outputs")).willReturn(aResponse()
+ wireMockServer.stubFor(get(urlPathEqualTo("/v2.0/api/v3/deployments/vfname/outputs")).willReturn(aResponse()
.withBody("{ \"deployment_id\": \"123\",\"outputs\":{\"abc\":\"abc\"} }")
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlMatching("/v2.0/api/v3/executions?.*")).willReturn(aResponse()
+ wireMockServer.stubFor(get(urlMatching("/v2.0/api/v3/executions?.*")).willReturn(aResponse()
.withBody("{ \"items\": {\"id\": \"123\",\"workflow_id\":\"install\",\"status\":\"terminated\" } } ")
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlPathEqualTo("/v2.0/api/v3/tokens")).willReturn(aResponse()
+ wireMockServer.stubFor(get(urlPathEqualTo("/v2.0/api/v3/tokens")).willReturn(aResponse()
.withBodyFile("OpenstackResponse_Access.json")
.withStatus(HttpStatus.SC_OK)));
@@ -225,19 +230,19 @@ public class MsoVnfCloudifyAdapterImplTest extends BaseRestTestUtils {
msoRequest.setRequestId("12345");
msoRequest.setServiceInstanceId("12345");
- stubFor(get(urlPathEqualTo("/v2.0/api/v3/deployments/vfname")).willReturn(aResponse()
+ wireMockServer.stubFor(get(urlPathEqualTo("/v2.0/api/v3/deployments/vfname")).willReturn(aResponse()
.withBody("{ \"id\": \"123\" }")
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlPathEqualTo("/v2.0/api/v3/deployments/vfname/outputs")).willReturn(aResponse()
+ wireMockServer.stubFor(get(urlPathEqualTo("/v2.0/api/v3/deployments/vfname/outputs")).willReturn(aResponse()
.withBody("{ \"deployment_id\": \"123\",\"outputs\":{\"abc\":\"abc\"} }")
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlMatching("/v2.0/api/v3/executions?.*")).willReturn(aResponse()
+ wireMockServer.stubFor(get(urlMatching("/v2.0/api/v3/executions?.*")).willReturn(aResponse()
.withBody("{ \"items\": {\"id\": \"123\",\"workflow_id\":\"install\",\"status\":\"terminated\" } } ")
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlPathEqualTo("/v2.0/api/v3/tokens")).willReturn(aResponse()
+ wireMockServer.stubFor(get(urlPathEqualTo("/v2.0/api/v3/tokens")).willReturn(aResponse()
.withBodyFile("OpenstackResponse_Access.json")
.withStatus(HttpStatus.SC_OK)));
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java
index 342a21a49c..152c23e9b8 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java
@@ -20,31 +20,25 @@
package org.onap.so.adapters.vnf;
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.delete;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.ws.Holder;
+
import org.apache.http.HttpStatus;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.onap.so.adapters.openstack.MsoOpenstackAdaptersApplication;
-import org.onap.so.adapters.vnf.exceptions.VnfException;
import org.onap.so.cloud.CloudConfig;
-import org.onap.so.db.catalog.beans.CloudSite;
import org.onap.so.entity.MsoRequest;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.web.server.LocalServerPort;
-
-import javax.xml.ws.Holder;
-import java.util.HashMap;
-import java.util.Map;
-
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.delete;
-import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.post;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
public class MsoVnfMulticloudAdapterImplTest extends BaseRestTestUtils{
@Rule
@@ -76,19 +70,19 @@ public class MsoVnfMulticloudAdapterImplTest extends BaseRestTestUtils{
msoRequest.setRequestId("12345");
msoRequest.setServiceInstanceId("12345");
- stubFor(get(urlPathEqualTo("/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload/vfname")).willReturn(aResponse()
+ wireMockServer.stubFor(get(urlPathEqualTo("/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload/vfname")).willReturn(aResponse()
//.withHeader()
.withStatus(HttpStatus.SC_NOT_FOUND)));
- stubFor(get(urlPathEqualTo("/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload/workload-id")).willReturn(aResponse()
+ wireMockServer.stubFor(get(urlPathEqualTo("/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload/workload-id")).willReturn(aResponse()
//.withHeader()
.withBodyFile("MulticloudResponse_Stack.json")
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlPathEqualTo("/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload/vfname/outputs")).willReturn(aResponse()
+ wireMockServer.stubFor(get(urlPathEqualTo("/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload/vfname/outputs")).willReturn(aResponse()
.withStatus(HttpStatus.SC_NOT_FOUND)));
- stubFor(post(urlPathEqualTo("/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload")).willReturn(aResponse()
+ wireMockServer.stubFor(post(urlPathEqualTo("/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload")).willReturn(aResponse()
.withBodyFile("MulticloudResponse_Stack_Create.json")
.withStatus(HttpStatus.SC_CREATED)));
@@ -101,11 +95,11 @@ public class MsoVnfMulticloudAdapterImplTest extends BaseRestTestUtils{
msoRequest.setRequestId("12345");
msoRequest.setServiceInstanceId("12345");
- stubFor(get(urlPathEqualTo("/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload/workload-id")).willReturn(aResponse()
+ wireMockServer.stubFor(get(urlPathEqualTo("/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload/workload-id")).willReturn(aResponse()
.withBodyFile("MulticloudResponse_Stack.json")
.withStatus(HttpStatus.SC_OK)));
- stubFor(delete(urlPathEqualTo("/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload/workload-id")).willReturn(aResponse()
+ wireMockServer.stubFor(delete(urlPathEqualTo("/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload/workload-id")).willReturn(aResponse()
.withStatus(HttpStatus.SC_NO_CONTENT)));
instance.deleteVfModule("MTN13", "CloudOwner", "123", "workload-id", msoRequest, new Holder<>());
@@ -117,7 +111,7 @@ public class MsoVnfMulticloudAdapterImplTest extends BaseRestTestUtils{
msoRequest.setRequestId("12345");
msoRequest.setServiceInstanceId("12345");
- stubFor(get(urlPathEqualTo("/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload/workload-id")).willReturn(aResponse()
+ wireMockServer.stubFor(get(urlPathEqualTo("/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload/workload-id")).willReturn(aResponse()
.withBodyFile("MulticloudResponse_Stack.json")
.withStatus(HttpStatus.SC_OK)));
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImplTest.java
index 3dcb52b8b7..50272dca20 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImplTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImplTest.java
@@ -20,6 +20,19 @@
package org.onap.so.adapters.vnf;
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.delete;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_200;
+import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_404;
+import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackResponseAccess;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.ws.Holder;
+
import org.apache.http.HttpStatus;
import org.junit.Rule;
import org.junit.Test;
@@ -29,19 +42,6 @@ import org.onap.so.entity.MsoRequest;
import org.onap.so.openstack.beans.VnfRollback;
import org.springframework.beans.factory.annotation.Autowired;
-import javax.xml.ws.Holder;
-import java.util.HashMap;
-import java.util.Map;
-
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.delete;
-import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_404;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackResponseAccess;
-
public class MsoVnfPluginAdapterImplTest extends BaseRestTestUtils {
@Rule
@@ -90,8 +90,8 @@ public class MsoVnfPluginAdapterImplTest extends BaseRestTestUtils {
@Test
public void createVfModule_INSTANTIATED() throws Exception {
- mockOpenStackResponseAccess(wireMockPort);
- mockOpenStackGetStackVfModule_200();
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
+ mockOpenStackGetStackVfModule_200(wireMockServer);
MsoRequest msoRequest = getMsoRequest();
Map<String, Object> map = new HashMap<>();
@@ -105,7 +105,7 @@ public class MsoVnfPluginAdapterImplTest extends BaseRestTestUtils {
@Test
public void createVfModule_queryVduNotFoundWithVolumeGroupId() throws Exception {
expectedException.expect(VnfException.class);
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
MsoRequest msoRequest = getMsoRequest();
Map<String, Object> map = new HashMap<>();
map.put("key1", "value1");
@@ -118,9 +118,9 @@ public class MsoVnfPluginAdapterImplTest extends BaseRestTestUtils {
@Test
public void createVfModule_CreateVduException() throws Exception {
expectedException.expect(VnfException.class);
- mockOpenStackResponseAccess(wireMockPort);
- mockOpenStackGetStackVfModule_404();
- stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/volumeGroupHeatStackId"))
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
+ mockOpenStackGetStackVfModule_404(wireMockServer);
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/volumeGroupHeatStackId"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBodyFile("OpenstackResponse_Stack_Created_VfModule.json")
.withStatus(HttpStatus.SC_OK)));
@@ -144,13 +144,13 @@ public class MsoVnfPluginAdapterImplTest extends BaseRestTestUtils {
@Test
public void deleteVfModule_DeleteVduException() throws Exception {
expectedException.expect(VnfException.class);
- mockOpenStackResponseAccess(wireMockPort);
- mockOpenStackGetStackVfModule_200();
- stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/vSAMP12"))
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
+ mockOpenStackGetStackVfModule_200(wireMockServer);
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/vSAMP12"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBodyFile("OpenstackResponse_Stack_Created_VfModule.json")
.withStatus(HttpStatus.SC_OK)));
- stubFor(delete(urlPathEqualTo("/mockPublicUrl/stacks/DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001/stackId"))
+ wireMockServer.stubFor(delete(urlPathEqualTo("/mockPublicUrl/stacks/DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001/stackId"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
MsoRequest msoRequest = getMsoRequest();
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VnfAdapterRestTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VnfAdapterRestTest.java
index 50bae8a074..bf00faa41b 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VnfAdapterRestTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VnfAdapterRestTest.java
@@ -107,13 +107,13 @@ public class VnfAdapterRestTest extends BaseRestTestUtils {
CreateVfModuleRequest request = populateCreateVfModuleRequest();
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetStackVfModule_404();
+ mockOpenStackGetStackVfModule_404(wireMockServer);
- mockOpenStackPostStacks_200();
+ mockOpenStackPostStacks_200(wireMockServer);
- mockOpenStackGetStackVfModule_200();
+ mockOpenStackGetStackVfModule_200(wireMockServer);
headers.add("Accept", MediaType.APPLICATION_JSON);
HttpEntity<CreateVfModuleRequest> entity = new HttpEntity<CreateVfModuleRequest>(request, headers);
@@ -141,10 +141,10 @@ public class VnfAdapterRestTest extends BaseRestTestUtils {
CreateVfModuleRequest request = populateCreateVfModuleRequest();
request.setNotificationUrl( createURLWithPort("/mso/WorkflowMesssage"));
- mockOpenStackResponseAccess(wireMockPort);
- mockOpenStackGetStackVfModule_404();
- mockOpenStackPostStacks_200();
- mockOpenStackGetStackVfModule_200();
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
+ mockOpenStackGetStackVfModule_404(wireMockServer);
+ mockOpenStackPostStacks_200(wireMockServer);
+ mockOpenStackGetStackVfModule_200(wireMockServer);
headers.add("Accept", MediaType.APPLICATION_JSON);
HttpEntity<CreateVfModuleRequest> entity = new HttpEntity<CreateVfModuleRequest>(request, headers);
@@ -204,13 +204,13 @@ public class VnfAdapterRestTest extends BaseRestTestUtils {
request.setVfModuleParams(vfModuleParams);
request.setMessageId(MESSAGE_ID);
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetStackVfModule_404();
+ mockOpenStackGetStackVfModule_404(wireMockServer);
- mockOpenStackPostStacks_200();
+ mockOpenStackPostStacks_200(wireMockServer);
- mockOpenStackGetStackVfModule_200();
+ mockOpenStackGetStackVfModule_200(wireMockServer);
headers.add("Accept", MediaType.APPLICATION_JSON);
@@ -272,15 +272,15 @@ public class VnfAdapterRestTest extends BaseRestTestUtils {
request.setVfModuleParams(vfModuleParams);
request.setMessageId(MESSAGE_ID);
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetStackVfModule_404();
+ mockOpenStackGetStackVfModule_404(wireMockServer);
- mockOpenStackGetStacks_404();
+ mockOpenStackGetStacks_404(wireMockServer);
- mockOpenStackPostStacks_200();
+ mockOpenStackPostStacks_200(wireMockServer);
- mockOpenStackGetStackVfModule_200();
+ mockOpenStackGetStackVfModule_200(wireMockServer);
headers.add("Accept", MediaType.APPLICATION_JSON);
HttpEntity<CreateVfModuleRequest> entity = new HttpEntity<CreateVfModuleRequest>(request, headers);
@@ -291,7 +291,7 @@ public class VnfAdapterRestTest extends BaseRestTestUtils {
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
- mockOpenStackGetStacksWithBody_200("DELETE_IN_PROGRESS");
+ mockOpenStackGetStacksWithBody_200(wireMockServer, "DELETE_IN_PROGRESS");
response = restTemplate.exchange(
createURLWithPort("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules"), HttpMethod.POST,
@@ -299,7 +299,7 @@ public class VnfAdapterRestTest extends BaseRestTestUtils {
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
- mockOpenStackGetStacksWithBody_200("DELETE_FAILED");
+ mockOpenStackGetStacksWithBody_200(wireMockServer, "DELETE_FAILED");
response = restTemplate.exchange(
createURLWithPort("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules"), HttpMethod.POST,
@@ -307,7 +307,7 @@ public class VnfAdapterRestTest extends BaseRestTestUtils {
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
- mockOpenStackGetStacksWithBody_200("UPDATE_COMPLETE");
+ mockOpenStackGetStacksWithBody_200(wireMockServer, "UPDATE_COMPLETE");
response = restTemplate.exchange(
createURLWithPort("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules"), HttpMethod.POST,
@@ -315,7 +315,7 @@ public class VnfAdapterRestTest extends BaseRestTestUtils {
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
- mockOpenStackGetStacksWithBody_404();
+ mockOpenStackGetStacksWithBody_404(wireMockServer);
response = restTemplate.exchange(
createURLWithPort("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules"), HttpMethod.POST,
@@ -341,15 +341,15 @@ public class VnfAdapterRestTest extends BaseRestTestUtils {
request.setVnfId(AAI_VNF_ID);
request.setMsoRequest(msoRequest);
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackPostStacks_200();
+ mockOpenStackPostStacks_200(wireMockServer);
- mockOpenStackGetStacksStackId_404();
+ mockOpenStackGetStacksStackId_404(wireMockServer);
- mockOpenStackGetPublicUrlStackByNameAndID_200(wireMockPort);
+ mockOpenStackGetPublicUrlStackByNameAndID_200(wireMockServer, wireMockPort);
- mockOpenStackDeletePublicUrlStackByNameAndID_204();
+ mockOpenStackDeletePublicUrlStackByNameAndID_204(wireMockServer);
headers.add("Accept", MediaType.APPLICATION_JSON);
@@ -408,15 +408,15 @@ public class VnfAdapterRestTest extends BaseRestTestUtils {
request.setBackout(backout);
request.setVfModuleParams(vfModuleParams);
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetStacksVfModuleWithLocationHeader_200(wireMockPort);
+ mockOpenStackGetStacksVfModuleWithLocationHeader_200(wireMockServer, wireMockPort);
- mockOpenStackGetStacksVfModule_200(wireMockPort);
+ mockOpenStackGetStacksVfModule_200(wireMockServer, wireMockPort);
- mockOpenStackGetStacksBaseStack_200(wireMockPort);
+ mockOpenStackGetStacksBaseStack_200(wireMockServer, wireMockPort);
- mockOpenStackPutStacks_200();
+ mockOpenStackPutStacks_200(wireMockServer);
UpdateVfModuleResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue(
new File("src/test/resources/__files/UpdateVfModuleResponse.json"), UpdateVfModuleResponse.class);
@@ -455,13 +455,13 @@ public class VnfAdapterRestTest extends BaseRestTestUtils {
RollbackVfModuleRequest request = new RollbackVfModuleRequest();
request.setVfModuleRollback(vfModuleRollback);
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetStacksStackId_200(wireMockPort);
+ mockOpenStackGetStacksStackId_200(wireMockServer, wireMockPort);
- mockOpenStackDeleteStacks();
+ mockOpenStackDeleteStacks(wireMockServer);
- mockOpenStackGetStacksVUSP_404();
+ mockOpenStackGetStacksVUSP_404(wireMockServer);
headers.add("Accept", MediaType.APPLICATION_JSON);
HttpEntity<RollbackVfModuleRequest> entity = new HttpEntity<RollbackVfModuleRequest>(request, headers);
@@ -489,7 +489,7 @@ public class VnfAdapterRestTest extends BaseRestTestUtils {
.build().toString();
System.out.println(testUri);
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
headers.add("Accept", MediaType.APPLICATION_JSON);
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestTest.java
index f602690a10..20372b81d9 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestTest.java
@@ -50,9 +50,9 @@ public class VolumeAdapterRestTest extends VolumeGroupAdapterCommon {
@Test
public void testCreateVNFVolumes() throws IOException {
- mockOpenStackResponseAccess(wireMockPort);
- mockOpenStackPostStacks_200();
- mockOpenStackGetStackVfModule_200();
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
+ mockOpenStackPostStacks_200(wireMockServer);
+ mockOpenStackGetStackVfModule_200(wireMockServer);
CreateVolumeGroupRequest request = buildCreateVfModuleRequest();
HttpEntity<CreateVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
@@ -65,9 +65,9 @@ public class VolumeAdapterRestTest extends VolumeGroupAdapterCommon {
@Test
public void testCreateVNFVolumesAsync() throws IOException {
- mockOpenStackResponseAccess(wireMockPort);
- mockOpenStackPostStacks_200();
- mockOpenStackGetStackVfModule_200();
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
+ mockOpenStackPostStacks_200(wireMockServer);
+ mockOpenStackGetStackVfModule_200(wireMockServer);
CreateVolumeGroupRequest request = buildCreateVfModuleRequest();
request.setNotificationUrl("http://localhost:8080");
@@ -80,7 +80,7 @@ public class VolumeAdapterRestTest extends VolumeGroupAdapterCommon {
@Test
public void testDeleteVNFVolumes() throws IOException {
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
DeleteVolumeGroupRequest request = buildDeleteVolumeGroupRequest();
HttpEntity<DeleteVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
ResponseEntity<DeleteVolumeGroupResponse> response = restTemplate.exchange(
@@ -91,7 +91,7 @@ public class VolumeAdapterRestTest extends VolumeGroupAdapterCommon {
@Test
public void testDeleteVNFVolumesAsync() throws IOException {
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
DeleteVolumeGroupRequest request = buildDeleteVolumeGroupRequest();
request.setNotificationUrl("http://localhost:8080");
HttpEntity<DeleteVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
@@ -103,7 +103,7 @@ public class VolumeAdapterRestTest extends VolumeGroupAdapterCommon {
@Test
public void testRollbackVNFVolumes() throws IOException {
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
RollbackVolumeGroupRequest request = buildRollbackVolumeGroupRequest();
HttpEntity<RollbackVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
ResponseEntity<RollbackVolumeGroupResponse> response = restTemplate.exchange(
@@ -114,7 +114,7 @@ public class VolumeAdapterRestTest extends VolumeGroupAdapterCommon {
@Test
public void testRollbackVNFVolumesAsync() throws IOException {
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
RollbackVolumeGroupRequest request = buildRollbackVolumeGroupRequest();
request.setNotificationUrl("http://localhost:8080");
HttpEntity<RollbackVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
@@ -126,8 +126,8 @@ public class VolumeAdapterRestTest extends VolumeGroupAdapterCommon {
@Test
public void testQueryVNFVolumes() throws IOException{
- mockOpenStackResponseAccess(wireMockPort);
- mockOpenStackGetStacksWithBody_200("UPDATE_COMPLETE");
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
+ mockOpenStackGetStacksWithBody_200(wireMockServer, "UPDATE_COMPLETE");
javax.ws.rs.core.UriBuilder builder = UriBuilder.fromPath("/services/rest/v1/volume-groups/" + VOLUME_GROUP_ID);
builder.queryParam("cloudSiteId", CLOUDSITE_ID).queryParam("tenantId", TENANT_ID)
.queryParam("volumeGroupStackId", VOUME_GROUP_NAME).queryParam("skipAAI", true)
@@ -142,8 +142,8 @@ public class VolumeAdapterRestTest extends VolumeGroupAdapterCommon {
@Test
public void testQueryVNFVolumesError() throws IOException{
- mockOpenStackResponseAccess(wireMockPort);
- mockOpenStackGetStacksWithBody_200("UPDATE_COMPLETE");
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
+ mockOpenStackGetStacksWithBody_200(wireMockServer, "UPDATE_COMPLETE");
javax.ws.rs.core.UriBuilder builder = UriBuilder.fromPath("/services/rest/v1/volume-groups/" + VOLUME_GROUP_ID);
builder.queryParam("tenantId", TENANT_ID)
.queryParam("volumeGroupStackId", VOUME_GROUP_NAME).queryParam("skipAAI", true)
@@ -158,10 +158,10 @@ public class VolumeAdapterRestTest extends VolumeGroupAdapterCommon {
@Test
public void testUpdateVNFVolumes() throws IOException {
- mockOpenStackResponseAccess(wireMockPort);
- mockOpenStackGetStacksWithBody_200("CREATE_COMPLETE");
- mockOpenStackPutStack(VOUME_GROUP_NAME+"/stackId",200);
- mockOpenStackGetStackWithBody_200("UPDATE_COMPLETE");
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
+ mockOpenStackGetStacksWithBody_200(wireMockServer, "CREATE_COMPLETE");
+ mockOpenStackPutStack(wireMockServer, VOUME_GROUP_NAME+"/stackId",200);
+ mockOpenStackGetStackWithBody_200(wireMockServer, "UPDATE_COMPLETE");
UpdateVolumeGroupRequest request = buildUpdateVolumeGroupRequest();
HttpEntity<UpdateVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
ResponseEntity<UpdateVolumeGroupResponse> response = restTemplate.exchange(
@@ -172,10 +172,10 @@ public class VolumeAdapterRestTest extends VolumeGroupAdapterCommon {
@Test
public void testUpdateVNFVolumesAsync() throws IOException {
- mockOpenStackResponseAccess(wireMockPort);
- mockOpenStackGetStacksWithBody_200("CREATE_COMPLETE");
- mockOpenStackPutStack(VOUME_GROUP_NAME+"/stackId",200);
- mockOpenStackGetStackWithBody_200("UPDATE_COMPLETE");
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
+ mockOpenStackGetStacksWithBody_200(wireMockServer, "CREATE_COMPLETE");
+ mockOpenStackPutStack(wireMockServer, VOUME_GROUP_NAME+"/stackId",200);
+ mockOpenStackGetStackWithBody_200(wireMockServer, "UPDATE_COMPLETE");
UpdateVolumeGroupRequest request = buildUpdateVolumeGroupRequest();
request.setNotificationUrl("http://localhost:8080");
HttpEntity<UpdateVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2Test.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2Test.java
index dba169c311..abdc2609a1 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2Test.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2Test.java
@@ -49,9 +49,9 @@ public class VolumeAdapterRestV2Test extends VolumeGroupAdapterCommon {
@Test
public void testCreateVNFVolumes() throws IOException {
- mockOpenStackResponseAccess(wireMockPort);
- mockOpenStackPostStacks_200();
- mockOpenStackGetStackVfModule_200();
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
+ mockOpenStackPostStacks_200(wireMockServer);
+ mockOpenStackGetStackVfModule_200(wireMockServer);
CreateVolumeGroupRequest request = buildCreateVfModuleRequest();
HttpEntity<CreateVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
@@ -64,9 +64,9 @@ public class VolumeAdapterRestV2Test extends VolumeGroupAdapterCommon {
@Test
public void testCreateVNFVolumesAsync() throws IOException {
- mockOpenStackResponseAccess(wireMockPort);
- mockOpenStackPostStacks_200();
- mockOpenStackGetStackVfModule_200();
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
+ mockOpenStackPostStacks_200(wireMockServer);
+ mockOpenStackGetStackVfModule_200(wireMockServer);
CreateVolumeGroupRequest request = buildCreateVfModuleRequest();
request.setNotificationUrl("http://localhost:8080");
HttpEntity<CreateVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
@@ -78,7 +78,7 @@ public class VolumeAdapterRestV2Test extends VolumeGroupAdapterCommon {
@Test
public void testDeleteVNFVolumes() throws IOException {
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
DeleteVolumeGroupRequest request = buildDeleteVolumeGroupRequest();
HttpEntity<DeleteVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
ResponseEntity<DeleteVolumeGroupResponse> response = restTemplate.exchange(
@@ -89,7 +89,7 @@ public class VolumeAdapterRestV2Test extends VolumeGroupAdapterCommon {
@Test
public void testDeleteVNFVolumesAsync() throws IOException {
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
DeleteVolumeGroupRequest request = buildDeleteVolumeGroupRequest();
request.setNotificationUrl("http://localhost:8080");
HttpEntity<DeleteVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
@@ -101,7 +101,7 @@ public class VolumeAdapterRestV2Test extends VolumeGroupAdapterCommon {
@Test
public void testRollbackVNFVolumes() throws IOException {
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
RollbackVolumeGroupRequest request = buildRollbackVolumeGroupRequest();
HttpEntity<RollbackVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
ResponseEntity<RollbackVolumeGroupResponse> response = restTemplate.exchange(
@@ -112,7 +112,7 @@ public class VolumeAdapterRestV2Test extends VolumeGroupAdapterCommon {
@Test
public void testRollbackVNFVolumesAsync() throws IOException {
- mockOpenStackResponseAccess(wireMockPort);
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
RollbackVolumeGroupRequest request = buildRollbackVolumeGroupRequest();
request.setNotificationUrl("http://localhost:8080");
HttpEntity<RollbackVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
@@ -124,8 +124,8 @@ public class VolumeAdapterRestV2Test extends VolumeGroupAdapterCommon {
@Test
public void testQueryVNFVolumes() throws IOException{
- mockOpenStackResponseAccess(wireMockPort);
- mockOpenStackGetStacksWithBody_200("UPDATE_COMPLETE");
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
+ mockOpenStackGetStacksWithBody_200(wireMockServer, "UPDATE_COMPLETE");
javax.ws.rs.core.UriBuilder builder = UriBuilder.fromPath("/services/rest/v2/volume-groups/" + VOLUME_GROUP_ID);
builder.queryParam("cloudSiteId", CLOUDSITE_ID).queryParam("tenantId", TENANT_ID)
.queryParam("volumeGroupStackId", VOUME_GROUP_NAME).queryParam("skipAAI", true)
@@ -140,8 +140,8 @@ public class VolumeAdapterRestV2Test extends VolumeGroupAdapterCommon {
@Test
public void testQueryVNFVolumesError() throws IOException{
- mockOpenStackResponseAccess(wireMockPort);
- mockOpenStackGetStacksWithBody_200("UPDATE_COMPLETE");
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
+ mockOpenStackGetStacksWithBody_200(wireMockServer, "UPDATE_COMPLETE");
javax.ws.rs.core.UriBuilder builder = UriBuilder.fromPath("/services/rest/v2/volume-groups/" + VOLUME_GROUP_ID);
builder.queryParam("tenantId", TENANT_ID)
.queryParam("volumeGroupStackId", VOUME_GROUP_NAME).queryParam("skipAAI", true)
@@ -155,10 +155,10 @@ public class VolumeAdapterRestV2Test extends VolumeGroupAdapterCommon {
}
@Test
public void testUpdateVNFVolumes() throws IOException {
- mockOpenStackResponseAccess(wireMockPort);
- mockOpenStackGetStacksWithBody_200("CREATE_COMPLETE");
- mockOpenStackPutStack(VOUME_GROUP_NAME+"/stackId",200);
- mockOpenStackGetStackWithBody_200("UPDATE_COMPLETE");
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
+ mockOpenStackGetStacksWithBody_200(wireMockServer, "CREATE_COMPLETE");
+ mockOpenStackPutStack(wireMockServer, VOUME_GROUP_NAME+"/stackId",200);
+ mockOpenStackGetStackWithBody_200(wireMockServer, "UPDATE_COMPLETE");
UpdateVolumeGroupRequest request = buildUpdateVolumeGroupRequest();
HttpEntity<UpdateVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
ResponseEntity<UpdateVolumeGroupResponse> response = restTemplate.exchange(
@@ -169,10 +169,10 @@ public class VolumeAdapterRestV2Test extends VolumeGroupAdapterCommon {
@Test
public void testUpdateVNFVolumesAsync() throws IOException {
- mockOpenStackResponseAccess(wireMockPort);
- mockOpenStackGetStacksWithBody_200("CREATE_COMPLETE");
- mockOpenStackPutStack(VOUME_GROUP_NAME+"/stackId",200);
- mockOpenStackGetStackWithBody_200("UPDATE_COMPLETE");
+ mockOpenStackResponseAccess(wireMockServer, wireMockPort);
+ mockOpenStackGetStacksWithBody_200(wireMockServer, "CREATE_COMPLETE");
+ mockOpenStackPutStack(wireMockServer, VOUME_GROUP_NAME+"/stackId",200);
+ mockOpenStackGetStackWithBody_200(wireMockServer, "UPDATE_COMPLETE");
UpdateVolumeGroupRequest request = buildUpdateVolumeGroupRequest();
request.setNotificationUrl("http://localhost:8080");
HttpEntity<UpdateVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/bpmn/mock/StubOpenStack.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/bpmn/mock/StubOpenStack.java
index 569a845caa..de12f2cfbe 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/bpmn/mock/StubOpenStack.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/bpmn/mock/StubOpenStack.java
@@ -27,7 +27,6 @@ import static com.github.tomakehurst.wiremock.client.WireMock.equalToJson;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.put;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
@@ -37,428 +36,430 @@ import java.io.IOException;
import org.apache.http.HttpStatus;
+import com.github.tomakehurst.wiremock.WireMockServer;
+
public class StubOpenStack {
private static final String NETWORK_NAME = "vUSP-23804-T-01-dpa2b_EVUSP-CORE-VIF-TSIG0_net_0";
private static final String NETWORK_ID = "da886914-efb2-4917-b335-c8381528d90b";
private static final String NETWORK_NAME_2 = "stackname";
private static final String NETWORK_ID_2 = "stackId";
- public static void mockOpenStackResponseAccess(int port) throws IOException {
- stubFor(post(urlPathEqualTo("/v2.0/tokens")).willReturn(aResponse().withHeader("Content-Type", "application/json")
+ public static void mockOpenStackResponseAccess(WireMockServer wireMockServer, int port) throws IOException {
+ wireMockServer.stubFor(post(urlPathEqualTo("/v2.0/tokens")).willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(getBodyFromFile("OpenstackResponse_Access.json", port, "/mockPublicUrl"))
.withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackResponseAccessMulticloud(int port) throws IOException {
- stubFor(post(urlPathEqualTo("/v2.0/tokens")).willReturn(aResponse().withHeader("Content-Type", "application/json")
+ public static void mockOpenStackResponseAccessMulticloud(WireMockServer wireMockServer, int port) throws IOException {
+ wireMockServer.stubFor(post(urlPathEqualTo("/v2.0/tokens")).willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(getBodyFromFile("OpenstackResponse_AccessMulticloud.json", port, "/mockPublicUrl"))
.withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackResponseAccessQueryNetwork(int port) throws IOException {
- stubFor(post(urlPathEqualTo("/v2.0/tokens"))
+ public static void mockOpenStackResponseAccessQueryNetwork(WireMockServer wireMockServer, int port) throws IOException {
+ wireMockServer.stubFor(post(urlPathEqualTo("/v2.0/tokens"))
.withRequestBody(containing("tenantId"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(getBodyFromFile("OpenstackResponse_Access_queryNetwork.json", port, "/mockPublicUrl"))
.withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackResponseAccessAdmin(int port) throws IOException {
- stubFor(post(urlPathEqualTo("/v2.0/tokens")).willReturn(aResponse().withHeader("Content-Type", "application/json")
+ public static void mockOpenStackResponseAccessAdmin(WireMockServer wireMockServer, int port) throws IOException {
+ wireMockServer.stubFor(post(urlPathEqualTo("/v2.0/tokens")).willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(getBodyFromFile("OpenstackResponse_Access_Admin.json", port, "/mockPublicUrl"))
.withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackPublicUrlStackByName_200(int port) throws IOException {
- stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/"+NETWORK_NAME)).willReturn(aResponse()
+ public static void mockOpenStackPublicUrlStackByName_200(WireMockServer wireMockServer, int port) throws IOException {
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/"+NETWORK_NAME)).willReturn(aResponse()
.withHeader("X-Openstack-Request-Id", "openstackRquest")
.withHeader("location", "http://localhost:" + port + "/mockPublicUrl/stacks/"+NETWORK_NAME)
.withBody(getBodyFromFile("OpenstackResponse_StackId.json", port, "/mockPublicUrl/stacks/" + NETWORK_NAME))
.withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackPublicUrlStackByID_200(int port) throws IOException {
- stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/"+NETWORK_ID)).willReturn(aResponse()
+ public static void mockOpenStackPublicUrlStackByID_200(WireMockServer wireMockServer, int port) throws IOException {
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/"+NETWORK_ID)).willReturn(aResponse()
.withHeader("X-Openstack-Request-Id", "openstackRquest")
.withHeader("location", "http://localhost:" + port + "/mockPublicUrl/stacks/"+NETWORK_NAME)
.withBody(getBodyFromFile("OpenstackResponse_StackId.json", port, "/mockPublicUrl/stacks/" + NETWORK_NAME))
.withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackGetPublicUrlStackByNameAndID_200(int port) throws IOException {
- stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/"+NETWORK_NAME+"/"+NETWORK_ID)).willReturn(aResponse()
+ public static void mockOpenStackGetPublicUrlStackByNameAndID_200(WireMockServer wireMockServer, int port) throws IOException {
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/"+NETWORK_NAME+"/"+NETWORK_ID)).willReturn(aResponse()
.withHeader("X-Openstack-Request-Id", "openstackRquest")
.withHeader("location", "http://localhost:" + port + "/mockPublicUrl/stacks/"+NETWORK_NAME)
.withBody(getBodyFromFile("OpenstackResponse_StackId.json", port, "/mockPublicUrl/stacks/" + NETWORK_NAME))
.withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackGetPublicUrlStackByNameAndID_204(int port) throws IOException {
- stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/"+NETWORK_NAME+"/"+NETWORK_ID)).willReturn(aResponse()
+ public static void mockOpenStackGetPublicUrlStackByNameAndID_204(WireMockServer wireMockServer, int port) throws IOException {
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/"+NETWORK_NAME+"/"+NETWORK_ID)).willReturn(aResponse()
.withHeader("X-Openstack-Request-Id", "openstackRquest")
.withHeader("location", "http://localhost:" + port + "/mockPublicUrl/stacks/"+NETWORK_NAME+"/"+NETWORK_ID)
.withBody(getBodyFromFile("OpenstackResponse_StackId.json", port, "/mockPublicUrl/stacks/" + NETWORK_NAME))
.withStatus(HttpStatus.SC_NOT_FOUND)));
}
- public static void mockOpenStackPutPublicUrlStackByNameAndID_200() {
- stubFor(put(urlPathEqualTo("/mockPublicUrl/stacks/"+NETWORK_NAME+"/"+NETWORK_ID)).willReturn(aResponse()
+ public static void mockOpenStackPutPublicUrlStackByNameAndID_200(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(put(urlPathEqualTo("/mockPublicUrl/stacks/"+NETWORK_NAME+"/"+NETWORK_ID)).willReturn(aResponse()
.withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackPutPublicUrlStackByNameAndID_NETWORK2_200() {
- stubFor(put(urlPathEqualTo("/mockPublicUrl/stacks/"+NETWORK_NAME_2+"/"+NETWORK_ID_2)).willReturn(aResponse()
+ public static void mockOpenStackPutPublicUrlStackByNameAndID_NETWORK2_200(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(put(urlPathEqualTo("/mockPublicUrl/stacks/"+NETWORK_NAME_2+"/"+NETWORK_ID_2)).willReturn(aResponse()
.withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackDeletePublicUrlStackByNameAndID_204() {
- stubFor(delete(urlPathEqualTo("/mockPublicUrl/stacks/"+NETWORK_NAME+"/"+NETWORK_ID)).willReturn(aResponse()
+ public static void mockOpenStackDeletePublicUrlStackByNameAndID_204(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(delete(urlPathEqualTo("/mockPublicUrl/stacks/"+NETWORK_NAME+"/"+NETWORK_ID)).willReturn(aResponse()
.withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_NO_CONTENT)));
}
- public static void mockOpenStackPostPublicUrlWithBodyFile_200() {
- stubFor(post(urlPathEqualTo("/mockPublicUrl/stacks"))
+ public static void mockOpenStackPostPublicUrlWithBodyFile_200(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(post(urlPathEqualTo("/mockPublicUrl/stacks"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBodyFile("OpenstackResponse_Stack.json").withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackGetStackCreatedAppC_200() {
- stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/APP-C-24595-T-IST-04AShared_untrusted_vDBE_net_3/stackId"))
+ public static void mockOpenStackGetStackCreatedAppC_200(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/APP-C-24595-T-IST-04AShared_untrusted_vDBE_net_3/stackId"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBodyFile("OpenstackResponse_Stack_Created.json").withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackGetStackAppC_404() {
- stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/APP-C-24595-T-IST-04AShared_untrusted_vDBE_net_3"))
+ public static void mockOpenStackGetStackAppC_404(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/APP-C-24595-T-IST-04AShared_untrusted_vDBE_net_3"))
.willReturn(aResponse().withStatus(HttpStatus.SC_NOT_FOUND)));
}
- public static void mockOpenStackGetStackCreatedVUSP_200() {
- stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/vUSP-23804-T-01-dpa2b_EVUSP-CORE-VIF-TSIG0_net_0/stackId"))
+ public static void mockOpenStackGetStackCreatedVUSP_200(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/vUSP-23804-T-01-dpa2b_EVUSP-CORE-VIF-TSIG0_net_0/stackId"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBodyFile("OpenstackResponse_Stack_Created.json").withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackGetStackVUSP_404() {
- stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/vUSP-23804-T-01-dpa2b_EVUSP-CORE-VIF-TSIG0_net_0"))
+ public static void mockOpenStackGetStackVUSP_404(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/vUSP-23804-T-01-dpa2b_EVUSP-CORE-VIF-TSIG0_net_0"))
.willReturn(aResponse().withStatus(HttpStatus.SC_NOT_FOUND)));
}
- public static void mockOpenStackPostStack_200(String filename) {
- stubFor(post(urlPathEqualTo("/mockPublicUrl/stacks")).willReturn(aResponse()
+ public static void mockOpenStackPostStack_200(WireMockServer wireMockServer, String filename) {
+ wireMockServer.stubFor(post(urlPathEqualTo("/mockPublicUrl/stacks")).willReturn(aResponse()
.withHeader("Content-Type", "application/json")
.withBodyFile(filename).withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackPostNeutronNetwork_200(String filename) {
- stubFor(post(urlPathEqualTo("/mockPublicUrl/v2.0/networks")).willReturn(aResponse()
+ public static void mockOpenStackPostNeutronNetwork_200(WireMockServer wireMockServer, String filename) {
+ wireMockServer.stubFor(post(urlPathEqualTo("/mockPublicUrl/v2.0/networks")).willReturn(aResponse()
.withHeader("Content-Type", "application/json")
.withBodyFile(filename).withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackPutNeutronNetwork_200(String filename,String networkId) {
- stubFor(put(urlPathEqualTo("/mockPublicUrl/v2.0/networks/"+networkId)).willReturn(aResponse()
+ public static void mockOpenStackPutNeutronNetwork_200(WireMockServer wireMockServer, String filename,String networkId) {
+ wireMockServer.stubFor(put(urlPathEqualTo("/mockPublicUrl/v2.0/networks/"+networkId)).willReturn(aResponse()
.withHeader("Content-Type", "application/json")
.withBodyFile(filename).withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackPutNeutronNetwork(String networkId, int responseCode) {
- stubFor(put(urlPathEqualTo("/mockPublicUrl/v2.0/networks/"+networkId)).willReturn(aResponse()
+ public static void mockOpenStackPutNeutronNetwork(WireMockServer wireMockServer, String networkId, int responseCode) {
+ wireMockServer.stubFor(put(urlPathEqualTo("/mockPublicUrl/v2.0/networks/"+networkId)).willReturn(aResponse()
.withHeader("Content-Type", "application/json")
.withStatus(responseCode)));
}
- public static void mockOpenStackGetAllNeutronNetworks_200(String filename){
- stubFor(get(urlPathEqualTo("/mockPublicUrl/v2.0/networks")).willReturn(aResponse()
+ public static void mockOpenStackGetAllNeutronNetworks_200(WireMockServer wireMockServer, String filename){
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/v2.0/networks")).willReturn(aResponse()
.withHeader("Content-Type", "application/json")
.withBodyFile(filename).withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackGetNeutronNetwork_404(String networkName) {
- stubFor(get(urlPathEqualTo("/mockPublicUrl/v2.0/networks/"+networkName)).willReturn(aResponse()
+ public static void mockOpenStackGetNeutronNetwork_404(WireMockServer wireMockServer, String networkName) {
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/v2.0/networks/"+networkName)).willReturn(aResponse()
.withHeader("Content-Type", "application/json")
.withStatus(HttpStatus.SC_NOT_FOUND)));
}
- public static void mockOpenStackGetAllNeutronNetworks_404() {
- stubFor(get(urlPathEqualTo("/mockPublicUrl/v2.0/networks")).willReturn(aResponse()
+ public static void mockOpenStackGetAllNeutronNetworks_404(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/v2.0/networks")).willReturn(aResponse()
.withHeader("Content-Type", "application/json")
.withStatus(HttpStatus.SC_NOT_FOUND)));
}
- public static void mockOpenstackGetWithResponse(String url,int responseCode, String responseFile) {
- stubFor(get(urlPathEqualTo(url)).willReturn(aResponse()
+ public static void mockOpenstackGetWithResponse(WireMockServer wireMockServer, String url,int responseCode, String responseFile) {
+ wireMockServer.stubFor(get(urlPathEqualTo(url)).willReturn(aResponse()
.withHeader("Content-Type", "application/json")
.withBodyFile(responseFile)
.withStatus(responseCode)));
}
- public static void mockOpenstackPostWithResponse(String url,int responseCode, String responseFile) {
- stubFor(post(urlPathEqualTo(url)).willReturn(aResponse()
+ public static void mockOpenstackPostWithResponse(WireMockServer wireMockServer, String url,int responseCode, String responseFile) {
+ wireMockServer.stubFor(post(urlPathEqualTo(url)).willReturn(aResponse()
.withHeader("Content-Type", "application/json")
.withBodyFile(responseFile)
.withStatus(responseCode)));
}
- public static void mockOpenstackGet(String url,int responseCode) {
- stubFor(get(urlPathEqualTo(url)).willReturn(aResponse()
+ public static void mockOpenstackGet(WireMockServer wireMockServer, String url,int responseCode) {
+ wireMockServer.stubFor(get(urlPathEqualTo(url)).willReturn(aResponse()
.withHeader("Content-Type", "application/json")
.withStatus(responseCode)));
}
- public static void mockOpenstackPost(String url,int responseCode) {
- stubFor(post(urlPathEqualTo(url)).willReturn(aResponse()
+ public static void mockOpenstackPost(WireMockServer wireMockServer, String url,int responseCode) {
+ wireMockServer.stubFor(post(urlPathEqualTo(url)).willReturn(aResponse()
.withHeader("Content-Type", "application/json")
.withStatus(responseCode)));
}
- public static void mockOpenStackGetStackVfModule_200() {
- stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001/stackId"))
+ public static void mockOpenStackGetStackVfModule_200(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001/stackId"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBodyFile("OpenstackResponse_Stack_Created_VfModule.json")
.withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackGetStackVfModule_404() {
- stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001"))
+ public static void mockOpenStackGetStackVfModule_404(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withStatus(HttpStatus.SC_NOT_FOUND)));
}
- public static void mockOpenStackPostStacks_200() {
- stubFor(post(urlPathEqualTo("/mockPublicUrl/stacks"))
+ public static void mockOpenStackPostStacks_200(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(post(urlPathEqualTo("/mockPublicUrl/stacks"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBodyFile("OpenstackResponse_Stack.json").withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackGetStacks_404() {
- stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/3d7ff7b4-720b-4604-be0a-1974fc58ed96"))
+ public static void mockOpenStackGetStacks_404(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/3d7ff7b4-720b-4604-be0a-1974fc58ed96"))
.willReturn(aResponse().withStatus(HttpStatus.SC_NOT_FOUND)));
}
- public static void mockOpenStackGetStacksWithBody_200(String replaceWith) throws IOException {
- stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001"))
+ public static void mockOpenStackGetStacksWithBody_200(WireMockServer wireMockServer, String replaceWith) throws IOException {
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(getBodyFromFileVnfAdapter(replaceWith))
.withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackGetStackWithBody_200(String replaceWith) throws IOException {
- stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001/stackId"))
+ public static void mockOpenStackGetStackWithBody_200(WireMockServer wireMockServer, String replaceWith) throws IOException {
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001/stackId"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(getBodyFromFileVnfAdapter(replaceWith))
.withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackGetStacksWithBody_404() throws IOException {
- stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001"))
+ public static void mockOpenStackGetStacksWithBody_404(WireMockServer wireMockServer) throws IOException {
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(getBodyFromFileVnfAdapter(null))
.withStatus(HttpStatus.SC_NOT_FOUND)));
}
- public static void mockOpenStackGetStacksStackId_404() {
- stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/stackId"))
+ public static void mockOpenStackGetStacksStackId_404(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/stackId"))
.willReturn(aResponse().withStatus(HttpStatus.SC_NOT_FOUND)));
}
- public static void mockOpenStackGetStacksVfModule_200(int port) throws IOException {
- stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001/DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001")).willReturn(aResponse()
+ public static void mockOpenStackGetStacksVfModule_200(WireMockServer wireMockServer, int port) throws IOException {
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001/DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001")).willReturn(aResponse()
.withHeader("X-Openstack-Request-Id", "openstackRquest")
.withBody(getBodyFromFile("OpenstackResponse_VnfStackId.json", port, "/mockPublicUrl/stacks/stackId")).withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackGetStacksVfModuleWithLocationHeader_200(int port) throws IOException {
- stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001")).willReturn(aResponse()
+ public static void mockOpenStackGetStacksVfModuleWithLocationHeader_200(WireMockServer wireMockServer, int port) throws IOException {
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001")).willReturn(aResponse()
.withHeader("X-Openstack-Request-Id", "openstackRquest")
.withHeader("location", "http://localhost:" + port + "/mockPublicUrl/stacks/DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001")
.withBody(getBodyFromFile("OpenstackResponse_VnfStackId.json", port, "/mockPublicUrl/stacks/stackId")).withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackGetStacksBaseStack_200(int port) throws IOException {
- stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/baseVfModuleStackId")).willReturn(aResponse()
+ public static void mockOpenStackGetStacksBaseStack_200(WireMockServer wireMockServer, int port) throws IOException {
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/baseVfModuleStackId")).willReturn(aResponse()
.withHeader("X-Openstack-Request-Id", "openstackRquest")
.withHeader("location", "http://localhost:" + port + "/mockPublicUrl/stacks/baseVfModuleStackId")
.withBody(getBodyFromFile("OpenstackResponse_VnfBaseStackId.json", port, "/mockPublicUrl/stacks/stackId")).withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackPutStacks_200() {
- stubFor(put(urlPathEqualTo("/mockPublicUrl/stacks/DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001/DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001")).willReturn(aResponse()
+ public static void mockOpenStackPutStacks_200(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(put(urlPathEqualTo("/mockPublicUrl/stacks/DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001/DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001")).willReturn(aResponse()
.withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackPutStack(String networkId,int responseCode) {
- stubFor(put(urlPathEqualTo("/mockPublicUrl/stacks/"+networkId))
+ public static void mockOpenStackPutStack(WireMockServer wireMockServer, String networkId,int responseCode) {
+ wireMockServer.stubFor(put(urlPathEqualTo("/mockPublicUrl/stacks/"+networkId))
.willReturn(aResponse()
.withHeader("Content-Type", "application/json")
.withStatus(responseCode)));
}
- public static void mockOpenStackGetStacksStackId_200(int port) throws IOException {
- stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/StackId")).willReturn(aResponse()
+ public static void mockOpenStackGetStacksStackId_200(WireMockServer wireMockServer, int port) throws IOException {
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/StackId")).willReturn(aResponse()
.withHeader("X-Openstack-Request-Id", "openstackRquest")
.withHeader("location", "http://localhost:" + port + "/mockPublicUrl/stacks/stackId")
.withBody(getBodyFromFile("OpenstackResponse_StackId.json", port, "/mockPublicUrl/stacks/stackId")).withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackDeleteStacks() {
- stubFor(delete(urlPathEqualTo("/mockPublicUrl/stacks/vUSP-23804-T-01-dpa2b_EVUSP-CORE-VIF-TSIG0_net_0/da886914-efb2-4917-b335-c8381528d90b"))
+ public static void mockOpenStackDeleteStacks(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(delete(urlPathEqualTo("/mockPublicUrl/stacks/vUSP-23804-T-01-dpa2b_EVUSP-CORE-VIF-TSIG0_net_0/da886914-efb2-4917-b335-c8381528d90b"))
.willReturn(aResponse().withHeader("X-Openstack-Request-Id", "openstackRquest")));
}
- public static void mockOpenStackGetStacksVUSP_404() {
- stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/vUSP-23804-T-01-dpa2b_EVUSP-CORE-VIF-TSIG0_net_0/da886914-efb2-4917-b335-c8381528d90b"))
+ public static void mockOpenStackGetStacksVUSP_404(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/vUSP-23804-T-01-dpa2b_EVUSP-CORE-VIF-TSIG0_net_0/da886914-efb2-4917-b335-c8381528d90b"))
.willReturn(aResponse()
.withHeader("X-Openstack-Request-Id", "openstackRquest")
.withStatus(HttpStatus.SC_NOT_FOUND)));
}
- public static void mockOpenStackGetStackCreated_200(String filename, String networkName) {
- stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/" + networkName))
+ public static void mockOpenStackGetStackCreated_200(WireMockServer wireMockServer, String filename, String networkName) {
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/" + networkName))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBodyFile(filename).withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackGetStack_404(String networkName) {
- stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/" + networkName))
+ public static void mockOpenStackGetStack_404(WireMockServer wireMockServer, String networkName) {
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/" + networkName))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withStatus(HttpStatus.SC_NOT_FOUND)));
}
- public static void mockOpenStackGetStack_500(String networkName) {
- stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/" + networkName))
+ public static void mockOpenStackGetStack_500(WireMockServer wireMockServer, String networkName) {
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/" + networkName))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
}
- public static void mockOpenStackGetStackDeleteOrUpdateComplete_200(String filename) {
- stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/" + NETWORK_NAME_2 + "/" + NETWORK_ID_2))
+ public static void mockOpenStackGetStackDeleteOrUpdateComplete_200(WireMockServer wireMockServer, String filename) {
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/" + NETWORK_NAME_2 + "/" + NETWORK_ID_2))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBodyFile(filename).withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackGetNeutronNetwork(String filename,String networkId,int status) {
- stubFor(get(urlPathEqualTo("/mockPublicUrl/v2.0/networks/"+ networkId))
+ public static void mockOpenStackGetNeutronNetwork(WireMockServer wireMockServer, String filename,String networkId,int status) {
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/v2.0/networks/"+ networkId))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBodyFile(filename).withStatus(status)));
}
- public static void mockOpenStackGetNeutronNetwork(String networkId,int status) {
- stubFor(get(urlPathEqualTo("/mockPublicUrl/v2.0/networks/"+ networkId))
+ public static void mockOpenStackGetNeutronNetwork(WireMockServer wireMockServer, String networkId,int status) {
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/v2.0/networks/"+ networkId))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withStatus(status)));
}
- public static void mockOpenStackDeleteStack_200() {
- stubFor(delete(urlPathEqualTo("/mockPublicUrl/stacks/" + NETWORK_NAME_2 + "/" + NETWORK_ID_2))
+ public static void mockOpenStackDeleteStack_200(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(delete(urlPathEqualTo("/mockPublicUrl/stacks/" + NETWORK_NAME_2 + "/" + NETWORK_ID_2))
.willReturn(aResponse().withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackDeleteStack_500() {
- stubFor(delete(urlPathEqualTo("/mockPublicUrl/stacks/" + NETWORK_NAME_2 + "/" + NETWORK_ID_2))
+ public static void mockOpenStackDeleteStack_500(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(delete(urlPathEqualTo("/mockPublicUrl/stacks/" + NETWORK_NAME_2 + "/" + NETWORK_ID_2))
.willReturn(aResponse().withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
}
- public static void mockOpenStackDeleteNeutronNetwork(String networkId,int responseCode) {
- stubFor(delete(urlPathEqualTo("/mockPublicUrl/v2.0/networks/" + networkId))
+ public static void mockOpenStackDeleteNeutronNetwork(WireMockServer wireMockServer, String networkId,int responseCode) {
+ wireMockServer.stubFor(delete(urlPathEqualTo("/mockPublicUrl/v2.0/networks/" + networkId))
.willReturn(aResponse().withStatus(responseCode)));
}
- public static void mockOpenStackPostMetadata_200() {
- stubFor(post(urlPathEqualTo("/mockPublicUrl/tenants/tenantId/metadata")).willReturn(aResponse()
+ public static void mockOpenStackPostMetadata_200(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(post(urlPathEqualTo("/mockPublicUrl/tenants/tenantId/metadata")).willReturn(aResponse()
.withHeader("Content-Type", "application/json")
.withBodyFile("OpenstackResponse_Metadata.json").withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackGetMetadata_200() {
- stubFor(get(urlPathEqualTo("/mockPublicUrl/tenants/tenantId/metadata")).willReturn(aResponse()
+ public static void mockOpenStackGetMetadata_200(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/tenants/tenantId/metadata")).willReturn(aResponse()
.withHeader("Content-Type", "application/json")
.withBodyFile("OpenstackResponse_Metadata.json").withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackPostTenantWithBodyFile_200() throws IOException {
- stubFor(post(urlPathEqualTo("/mockPublicUrl/tenants"))
+ public static void mockOpenStackPostTenantWithBodyFile_200(WireMockServer wireMockServer) throws IOException {
+ wireMockServer.stubFor(post(urlPathEqualTo("/mockPublicUrl/tenants"))
.withRequestBody(equalToJson(readFile("src/test/resources/__files/OpenstackRequest_Tenant.json"))).willReturn(aResponse()
.withHeader("Content-Type", "application/json")
.withBodyFile("OpenstackResponse_Tenant.json").withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackPostTenant_200() throws IOException {
- stubFor(post(urlPathEqualTo("/mockPublicUrl/tenants")).willReturn(aResponse()
+ public static void mockOpenStackPostTenant_200(WireMockServer wireMockServer) throws IOException {
+ wireMockServer.stubFor(post(urlPathEqualTo("/mockPublicUrl/tenants")).willReturn(aResponse()
.withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackGetTenantByName_200(String tenantName) {
- stubFor(get(urlEqualTo("/mockPublicUrl/tenants/?name=" + tenantName)).willReturn(aResponse()
+ public static void mockOpenStackGetTenantByName_200(WireMockServer wireMockServer, String tenantName) {
+ wireMockServer.stubFor(get(urlEqualTo("/mockPublicUrl/tenants/?name=" + tenantName)).willReturn(aResponse()
.withHeader("Content-Type", "application/json")
.withBodyFile("OpenstackResponse_Tenant.json").withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackGetTenantByName_404(String tenantName) {
- stubFor(get(urlEqualTo("/mockPublicUrl/tenants/?name=" + tenantName)).willReturn(aResponse()
+ public static void mockOpenStackGetTenantByName_404(WireMockServer wireMockServer, String tenantName) {
+ wireMockServer.stubFor(get(urlEqualTo("/mockPublicUrl/tenants/?name=" + tenantName)).willReturn(aResponse()
.withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_NOT_FOUND)));
}
- public static void mockOpenStackGetTenantById_200(String tenantId) {
- stubFor(get(urlPathEqualTo("/mockPublicUrl/tenants/" + tenantId)).willReturn(aResponse()
+ public static void mockOpenStackGetTenantById_200(WireMockServer wireMockServer, String tenantId) {
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/tenants/" + tenantId)).willReturn(aResponse()
.withHeader("Content-Type", "application/json")
.withBodyFile("OpenstackResponse_Tenant.json").withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackGetTenantById_404(String tenantId) {
- stubFor(get(urlPathEqualTo("/mockPublicUrl/tenants/" + tenantId)).willReturn(aResponse()
+ public static void mockOpenStackGetTenantById_404(WireMockServer wireMockServer, String tenantId) {
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/tenants/" + tenantId)).willReturn(aResponse()
.withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_NOT_FOUND)));
}
- public static void mockOpenStackDeleteTenantById_200(String tenantId) {
- stubFor(delete(urlPathEqualTo("/mockPublicUrl/tenants/" + tenantId)).willReturn(aResponse()
+ public static void mockOpenStackDeleteTenantById_200(WireMockServer wireMockServer, String tenantId) {
+ wireMockServer.stubFor(delete(urlPathEqualTo("/mockPublicUrl/tenants/" + tenantId)).willReturn(aResponse()
.withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackGetUser_200(String user) {
- stubFor(get(urlPathEqualTo("/mockPublicUrl/users/" + user)).willReturn(aResponse()
+ public static void mockOpenStackGetUser_200(WireMockServer wireMockServer, String user) {
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/users/" + user)).willReturn(aResponse()
.withHeader("Content-Type", "application/json")
.withBodyFile("OpenstackResponse_User.json").withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackGetRoles_200(String roleFor) {
- stubFor(get(urlPathEqualTo("/mockPublicUrl/" + roleFor + "/roles")).willReturn(aResponse()
+ public static void mockOpenStackGetRoles_200(WireMockServer wireMockServer, String roleFor) {
+ wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/" + roleFor + "/roles")).willReturn(aResponse()
.withHeader("Content-Type", "application/json")
.withBodyFile("OpenstackResponse_Roles.json").withStatus(HttpStatus.SC_OK)));
}
- public static void mockOpenStackPutRolesAdmin_200(String roleFor) {
- stubFor(put(urlPathEqualTo("/mockPublicUrl/tenants/tenantId/users/msoId/roles/" + roleFor + "/admin")).willReturn(aResponse()
+ public static void mockOpenStackPutRolesAdmin_200(WireMockServer wireMockServer, String roleFor) {
+ wireMockServer.stubFor(put(urlPathEqualTo("/mockPublicUrl/tenants/tenantId/users/msoId/roles/" + roleFor + "/admin")).willReturn(aResponse()
.withHeader("Content-Type", "application/json")
.withBody("").withStatus(HttpStatus.SC_OK)));
}
- public static void mockValetCreatePostResponse_200(String requestId, String body) {
- stubFor(post(urlEqualTo("/api/valet/placement/v1/?requestId=" + requestId))
+ public static void mockValetCreatePostResponse_200(WireMockServer wireMockServer, String requestId, String body) {
+ wireMockServer.stubFor(post(urlEqualTo("/api/valet/placement/v1/?requestId=" + requestId))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(body).withStatus(HttpStatus.SC_OK)));
}
- public static void mockValetCreatePutResponse_200(String requestId, String body) {
- stubFor(put(urlEqualTo("/api/valet/placement/v1/?requestId=" + requestId))
+ public static void mockValetCreatePutResponse_200(WireMockServer wireMockServer, String requestId, String body) {
+ wireMockServer.stubFor(put(urlEqualTo("/api/valet/placement/v1/?requestId=" + requestId))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(body).withStatus(HttpStatus.SC_OK)));
}
- public static void mockValetDeleteDeleteResponse_200(String requestId, String body) {
- stubFor(delete(urlEqualTo("/api/valet/placement/v1/?requestId=" + requestId))
+ public static void mockValetDeleteDeleteResponse_200(WireMockServer wireMockServer, String requestId, String body) {
+ wireMockServer.stubFor(delete(urlEqualTo("/api/valet/placement/v1/?requestId=" + requestId))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(body).withStatus(HttpStatus.SC_OK)));
}
- public static void mockValetConfirmPutRequest_200(String requestId, String body) {
- stubFor(put(urlPathEqualTo("/api/valet/placement/v1/" + requestId + "/confirm/"))
+ public static void mockValetConfirmPutRequest_200(WireMockServer wireMockServer, String requestId, String body) {
+ wireMockServer.stubFor(put(urlPathEqualTo("/api/valet/placement/v1/" + requestId + "/confirm/"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(body).withStatus(HttpStatus.SC_OK)));
}
- public static void mockValetRollbackPutRequest_200(String requestId, String body) {
- stubFor(put(urlPathEqualTo("/api/valet/placement/v1/" + requestId + "/rollback/"))
+ public static void mockValetRollbackPutRequest_200(WireMockServer wireMockServer, String requestId, String body) {
+ wireMockServer.stubFor(put(urlPathEqualTo("/api/valet/placement/v1/" + requestId + "/rollback/"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(body).withStatus(HttpStatus.SC_OK)));
}
diff --git a/adapters/mso-requests-db-adapter/pom.xml b/adapters/mso-requests-db-adapter/pom.xml
index a4761adf62..4be3935cf4 100644
--- a/adapters/mso-requests-db-adapter/pom.xml
+++ b/adapters/mso-requests-db-adapter/pom.xml
@@ -190,6 +190,24 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-test</id>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <includes>
+ <include>**/AllTestsTestSuite.java</include>
+ </includes>
+ <parallel>suites</parallel>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
<pluginManagement>
<plugins>
diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/AllTestsTestSuite.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/AllTestsTestSuite.java
new file mode 100644
index 0000000000..f15a93eaeb
--- /dev/null
+++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/AllTestsTestSuite.java
@@ -0,0 +1,32 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 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.so.adapters.requestsdb;
+import org.junit.runner.RunWith;
+
+import com.googlecode.junittoolbox.SuiteClasses;
+import com.googlecode.junittoolbox.WildcardPatternSuite;
+
+@RunWith(WildcardPatternSuite.class)
+@SuiteClasses("**/*Test.class")
+public class AllTestsTestSuite {
+ // the class remains empty,
+ // used only as a holder for the above annotations
+}
diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsSchedulerTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsSchedulerTest.java
index 1c7effd00a..4b783a781c 100644
--- a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsSchedulerTest.java
+++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsSchedulerTest.java
@@ -21,33 +21,19 @@
package org.onap.so.adapters.requestsdb;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
import java.util.List;
-import org.junit.Ignore;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.onap.so.adapters.requestsdb.application.MSORequestDBApplication;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.db.request.data.repository.ArchivedInfraRequestsRepository;
import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.data.domain.PageRequest;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
-@RunWith(SpringRunner.class)
-@SpringBootTest(classes = MSORequestDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-@ActiveProfiles("test")
-@Transactional
-public class ArchiveInfraRequestsSchedulerTest {
+public class ArchiveInfraRequestsSchedulerTest extends RequestsAdapterBase {
@Autowired
private ArchiveInfraRequestsScheduler scheduler;
diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/InfraActiveRequestsRepositoryCustomControllerTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/InfraActiveRequestsRepositoryCustomControllerTest.java
index 8fda355abb..c7804c8e0c 100644
--- a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/InfraActiveRequestsRepositoryCustomControllerTest.java
+++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/InfraActiveRequestsRepositoryCustomControllerTest.java
@@ -21,42 +21,34 @@
package org.onap.so.adapters.requestsdb;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import javax.ws.rs.core.MediaType;
+
import org.junit.Before;
-import org.junit.After;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.onap.so.adapters.requestsdb.application.MSORequestDBApplication;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.db.request.data.controller.InstanceNameDuplicateCheckRequest;
import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.web.server.LocalServerPort;
-import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
+import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.util.UriComponentsBuilder;
-import javax.ws.rs.core.MediaType;
-import java.util.List;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.UUID;
-import java.util.ArrayList;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-@RunWith(SpringRunner.class)
-@SpringBootTest(classes = MSORequestDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-@ActiveProfiles("test")
@Transactional
-public class InfraActiveRequestsRepositoryCustomControllerTest {
+public class InfraActiveRequestsRepositoryCustomControllerTest extends RequestsAdapterBase {
@LocalServerPort
private int port;
diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/RequestsAdapterBase.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/RequestsAdapterBase.java
new file mode 100644
index 0000000000..cb6feacfb2
--- /dev/null
+++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/RequestsAdapterBase.java
@@ -0,0 +1,14 @@
+package org.onap.so.adapters.requestsdb;
+
+import org.junit.runner.RunWith;
+import org.onap.so.adapters.requestsdb.application.MSORequestDBApplication;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = MSORequestDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+@ActiveProfiles("test")
+public class RequestsAdapterBase {
+
+}
diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/HealthCheckHandlerTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/HealthCheckHandlerTest.java
index 75c8f1af52..b911396370 100644
--- a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/HealthCheckHandlerTest.java
+++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/HealthCheckHandlerTest.java
@@ -20,32 +20,29 @@
package org.onap.so.adapters.requestsdb.adapters;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
import java.util.Map;
+
import javax.ws.rs.core.Response;
import org.json.JSONException;
import org.junit.Test;
-import org.junit.runner.RunWith;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
-import org.onap.so.adapters.requestsdb.application.MSORequestDBApplication;
+import org.onap.so.adapters.requestsdb.RequestsAdapterBase;
import org.onap.so.adapters.requestsdb.application.TestAppender;
-import org.springframework.boot.web.server.LocalServerPort;
-import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
+import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.junit4.SpringRunner;
+
import ch.qos.logback.classic.spi.ILoggingEvent;
-@RunWith(SpringRunner.class)
-@SpringBootTest(classes = MSORequestDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-@ActiveProfiles("test")
-public class HealthCheckHandlerTest {
+public class HealthCheckHandlerTest extends RequestsAdapterBase {
@LocalServerPort
private int port;
diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/MSORequestDBImplTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/MSORequestDBImplTest.java
index 963ef7c832..f6950d9777 100644
--- a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/MSORequestDBImplTest.java
+++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/MSORequestDBImplTest.java
@@ -29,17 +29,17 @@ import static org.junit.Assert.fail;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.junit.runner.RunWith;
-import org.onap.so.adapters.requestsdb.application.TestAppender;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.adapters.requestsdb.MsoRequestsDbAdapter;
import org.onap.so.adapters.requestsdb.RequestStatusType;
-import org.onap.so.adapters.requestsdb.application.MSORequestDBApplication;
+import org.onap.so.adapters.requestsdb.RequestsAdapterBase;
+import org.onap.so.adapters.requestsdb.application.TestAppender;
import org.onap.so.adapters.requestsdb.exceptions.MsoRequestsDbException;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.db.request.beans.OperationStatus;
@@ -48,19 +48,11 @@ import org.onap.so.db.request.data.repository.OperationStatusRepository;
import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository;
import org.onap.so.requestsdb.RequestsDbConstant;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.web.server.LocalServerPort;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.context.annotation.Bean;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringRunner;
+
import ch.qos.logback.classic.spi.ILoggingEvent;
-@RunWith(SpringRunner.class)
-@SpringBootTest(classes = MSORequestDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-@ActiveProfiles("test")
-public class MSORequestDBImplTest {
+public class MSORequestDBImplTest extends RequestsAdapterBase {
@LocalServerPort
private int port;
@@ -81,13 +73,34 @@ public class MSORequestDBImplTest {
}
@Before
- public void before(){
+ public void before() throws MsoRequestsDbException{
JaxWsProxyFactoryBean jaxWsProxyFactory = new JaxWsProxyFactoryBean();
jaxWsProxyFactory.setServiceClass(MsoRequestsDbAdapter.class);
jaxWsProxyFactory.setAddress("http://localhost:" + port + "/services/RequestsDbAdapter");
jaxWsProxyFactory.setUsername("bpel");
jaxWsProxyFactory.setPassword("mso-db-1507!");
dbAdapter = (MsoRequestsDbAdapter) jaxWsProxyFactory.create();
+
+ InfraActiveRequests testRequest = this.buildTestRequest();
+
+ dbAdapter.updateInfraRequest ( testRequest.getRequestId(),
+ testRequest.getLastModifiedBy(),
+ testRequest.getStatusMessage(),
+ testRequest.getResponseBody(),
+ RequestStatusType.valueOf(testRequest.getRequestStatus()),
+ testRequest.getProgress().toString(),
+ testRequest.getVnfOutputs(),
+ testRequest.getServiceInstanceId(),
+ testRequest.getNetworkId(),
+ testRequest.getVnfId(),
+ testRequest.getVfModuleId(),
+ testRequest.getVolumeGroupId(),
+ testRequest.getServiceInstanceName(),
+ testRequest.getConfigurationId(),
+ testRequest.getConfigurationName(),
+ testRequest.getVfModuleName());
+
+
}
private InfraActiveRequests buildTestRequest() {
@@ -108,8 +121,15 @@ public class MSORequestDBImplTest {
testRequest.setVfModuleId("c7d527b1-7a91-49fd-b97d-1c8c0f4a7992");
testRequest.setVfModuleModelName("vSAMP10aDEV::base::module-0");
testRequest.setVnfId("b92f60c8-8de3-46c1-8dc1-e4390ac2b005");
- testRequest.setRequestUrl("http://localhost:8080/onap/so/infra/serviceInstantiation/v7/serviceInstances");
-
+ testRequest.setRequestUrl("http://localhost:8080/onap/so/infra/serviceInstantiation/v7/serviceInstances");
+ testRequest.setVolumeGroupId("volumeGroupId");
+ testRequest.setServiceInstanceName("serviceInstanceName");
+ testRequest.setConfigurationId("configurationId");
+ testRequest.setConfigurationName("configurationName");
+ testRequest.setNetworkId("networkId");
+ testRequest.setResponseBody("responseBody");
+ testRequest.setVfModuleName("vfModuleName");
+ testRequest.setVnfOutputs("vnfOutputs");
return testRequest;
}
@@ -155,7 +175,7 @@ public class MSORequestDBImplTest {
fail("Null infraRequest");
// Then
- assertThat(infraRequest, sameBeanAs(testRequest).ignoring("requestBody").ignoring("endTime").ignoring("startTime").ignoring("modifyTime"));
+ assertEquals(clientRequestId, infraRequest.getClientRequestId());
}
@@ -221,6 +241,8 @@ public class MSORequestDBImplTest {
InfraActiveRequests infraRequest = dbAdapter.getInfraRequest(clientRequestId);
// Then
assertThat(infraRequest, sameBeanAs(testRequest).ignoring("requestBody").ignoring("endTime").ignoring("startTime").ignoring("modifyTime"));
+
+
}
@Test
diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java
index 304b025bf8..467cb1ed23 100644
--- a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java
+++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java
@@ -23,6 +23,7 @@ package org.onap.so.adapters.requestsdb.client;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.onap.so.adapters.requestsdb.RequestsAdapterBase;
import org.onap.so.adapters.requestsdb.application.MSORequestDBApplication;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.db.request.beans.OperationStatus;
@@ -47,10 +48,7 @@ import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertFalse;
-@RunWith(SpringRunner.class)
-@SpringBootTest(classes = MSORequestDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-@ActiveProfiles("test")
-public class RequestsDbClientTest {
+public class RequestsDbClientTest extends RequestsAdapterBase {
@Autowired
private RequestDbClientPortChanger requestsDbClient;
diff --git a/adapters/mso-sdnc-adapter/pom.xml b/adapters/mso-sdnc-adapter/pom.xml
index 8e94db1aa0..7f03879507 100644
--- a/adapters/mso-sdnc-adapter/pom.xml
+++ b/adapters/mso-sdnc-adapter/pom.xml
@@ -67,6 +67,24 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-test</id>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <includes>
+ <include>**/AllTestsTestSuite.java</include>
+ </includes>
+ <parallel>suites</parallel>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
<dependencyManagement>
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/AllTestsTestSuite.java b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/AllTestsTestSuite.java
new file mode 100644
index 0000000000..50a661a695
--- /dev/null
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/AllTestsTestSuite.java
@@ -0,0 +1,32 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 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.so.adapters.sdnc;
+import org.junit.runner.RunWith;
+
+import com.googlecode.junittoolbox.SuiteClasses;
+import com.googlecode.junittoolbox.WildcardPatternSuite;
+
+@RunWith(WildcardPatternSuite.class)
+@SuiteClasses("**/*Test.class")
+public class AllTestsTestSuite {
+ // the class remains empty,
+ // used only as a holder for the above annotations
+}
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/BaseTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/BaseTest.java
index 9716bb624a..29921934dd 100644
--- a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/BaseTest.java
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/BaseTest.java
@@ -24,6 +24,7 @@ import org.junit.After;
import org.junit.Rule;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
@@ -31,6 +32,8 @@ import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
+import com.github.tomakehurst.wiremock.WireMockServer;
+
@RunWith(SpringRunner.class)
@SpringBootTest(classes = SDNCAdapterApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles("test")
@@ -38,7 +41,10 @@ import org.springframework.test.context.junit4.SpringRunner;
public abstract class BaseTest {
@Rule
public ExpectedException expectedException = ExpectedException.none();
-
+
+ @Autowired
+ protected WireMockServer wireMockServer;
+
protected TestRestTemplate restTemplate = new TestRestTemplate("test", "test");
@Value("${wiremock.server.port}")
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/SDNCRestClientTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/SDNCRestClientTest.java
index 01fa3db960..76dd003883 100644
--- a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/SDNCRestClientTest.java
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/SDNCRestClientTest.java
@@ -26,13 +26,12 @@ import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import org.apache.http.HttpStatus;
import org.junit.Test;
import org.onap.so.adapters.sdnc.BaseTest;
import org.springframework.beans.factory.annotation.Autowired;
-import static com.github.tomakehurst.wiremock.client.WireMock.*;
-import static org.junit.Assert.assertTrue;
public class SDNCRestClientTest extends BaseTest {
@@ -48,7 +47,7 @@ public class SDNCRestClientTest extends BaseTest {
rt.setReqMethod("POST");
rt.setSdncUrl("http://localhost:" + wireMockPort + "/sdnc");
- stubFor(post(urlPathEqualTo("/sdnc"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/sdnc"))
.willReturn(aResponse().withHeader("Content-Type", "application/xml").withBody("").withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
SDNCResponse response = sdncClient.getSdncResp("", rt);
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/BPRestCallbackTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/BPRestCallbackTest.java
index 849374838a..f8685738e0 100644
--- a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/BPRestCallbackTest.java
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/BPRestCallbackTest.java
@@ -20,15 +20,17 @@
package org.onap.so.adapters.sdnc.sdncrest;
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
import org.apache.http.HttpStatus;
import org.junit.Test;
import org.onap.so.adapters.sdnc.BaseTest;
import org.springframework.beans.factory.annotation.Autowired;
-import static com.github.tomakehurst.wiremock.client.WireMock.*;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
public class BPRestCallbackTest extends BaseTest {
@Autowired
@@ -44,7 +46,7 @@ public class BPRestCallbackTest extends BaseTest {
"\t\t// </error>\n" +
"\t\t// </errors>";
- stubFor(post(urlPathEqualTo("/sdnc"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/sdnc"))
.willReturn(aResponse().withHeader("Content-Type", "application/xml").withBody(response).withStatus(HttpStatus.SC_MULTIPLE_CHOICES)));
boolean responseCommon = bpRestCallback.send("http://localhost:" + wireMockPort + "/sdnc", "Test");
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/SDNCConnectorTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/SDNCConnectorTest.java
index 23830ae3f3..1de281bde4 100644
--- a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/SDNCConnectorTest.java
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/SDNCConnectorTest.java
@@ -20,18 +20,17 @@
package org.onap.so.adapters.sdnc.sdncrest;
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+import static org.junit.Assert.assertNotNull;
+
import org.apache.http.HttpStatus;
import org.junit.Test;
import org.onap.so.adapters.sdnc.BaseTest;
import org.onap.so.adapters.sdncrest.SDNCResponseCommon;
import org.springframework.beans.factory.annotation.Autowired;
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.post;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
-import static org.junit.Assert.assertNotNull;
-import static com.github.tomakehurst.wiremock.client.WireMock.*;
-
public class SDNCConnectorTest extends BaseTest {
@Autowired
@@ -54,7 +53,7 @@ public class SDNCConnectorTest extends BaseTest {
rt.setReqMethod("POST");
rt.setSdncUrl("http://localhost:" + wireMockPort + "/sdnc");
- stubFor(post(urlPathEqualTo("/sdnc"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/sdnc"))
.willReturn(aResponse().withHeader("Content-Type", "application/xml").withBody(response).withStatus(HttpStatus.SC_MULTIPLE_CHOICES)));
SDNCResponseCommon responseCommon = sdncConnector.send(content, rt);
diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/rest/VfcManagerTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/rest/VfcManagerTest.java
new file mode 100644
index 0000000000..22e6def28d
--- /dev/null
+++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/rest/VfcManagerTest.java
@@ -0,0 +1,157 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (c) 2019 Samsung. 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.so.adapters.vfc.rest;
+
+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.so.adapters.vfc.constant.CommonConstant;
+import org.onap.so.adapters.vfc.model.NSResourceInputParameter;
+import org.onap.so.adapters.vfc.model.NsOperationKey;
+import org.onap.so.adapters.vfc.model.NsParameters;
+import org.onap.so.adapters.vfc.model.NsScaleParameters;
+import org.onap.so.adapters.vfc.model.RestfulResponse;
+import org.onap.so.adapters.vfc.util.RestfulUtil;
+import org.onap.so.db.request.beans.ResourceOperationStatus;
+import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository;
+import org.springframework.http.HttpStatus;
+
+import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+
+@RunWith(MockitoJUnitRunner.class)
+public class VfcManagerTest {
+
+ @Mock
+ private ResourceOperationStatusRepository resourceOperationStatusRepository;
+
+ @Mock
+ private RestfulUtil restfulUtil;
+
+ @InjectMocks
+ @Spy
+ private VfcManager vfcManager;
+
+ @Test
+ public void createNs() throws Exception {
+
+ NSResourceInputParameter segInput = new NSResourceInputParameter();
+ segInput.setNsOperationKey(new NsOperationKey());
+
+ RestfulResponse restfulResponse = new RestfulResponse();
+ restfulResponse.setStatus(HttpStatus.OK.value());
+ restfulResponse.setResponseContent("{\"" + CommonConstant.NS_INSTANCE_ID + "\": \"someNsInstanceId\"}");
+ when(restfulUtil.send(any(), any(), any())).thenReturn(restfulResponse);
+
+ RestfulResponse response = vfcManager.createNs(segInput);
+ assertEquals(HttpStatus.OK.value(), restfulResponse.getStatus());
+ }
+
+ @Test
+ public void deleteNs() throws Exception {
+
+ RestfulResponse restfulResponse = new RestfulResponse();
+ restfulResponse.setStatus(HttpStatus.OK.value());
+ restfulResponse.setResponseContent("{\"" + CommonConstant.NS_INSTANCE_ID + "\": \"someNsInstanceId\"}");
+ when(restfulUtil.send(any(), any(), any())).thenReturn(restfulResponse);
+
+ NsOperationKey nsOperationKey = new NsOperationKey();
+
+ RestfulResponse response = vfcManager.deleteNs(nsOperationKey, "someNsInstanceId");
+ assertEquals(HttpStatus.OK.value(), restfulResponse.getStatus());
+ }
+
+ @Test
+ public void instantiateNs() throws Exception {
+
+ RestfulResponse restfulResponse = new RestfulResponse();
+ restfulResponse.setStatus(HttpStatus.OK.value());
+ restfulResponse.setResponseContent("{\"" + CommonConstant.JOB_ID + "\": \"someJobId\"}");
+ when(restfulUtil.send(any(), any(), any())).thenReturn(restfulResponse);
+
+ NsParameters nsParameters = new NsParameters();
+ NSResourceInputParameter segInput = new NSResourceInputParameter();
+ segInput.setNsParameters(nsParameters);
+ segInput.setNsOperationKey(new NsOperationKey());
+
+ RestfulResponse response = vfcManager.instantiateNs("someNsInstanceId", segInput);
+ assertEquals(HttpStatus.OK.value(), restfulResponse.getStatus());
+ }
+
+ @Test
+ public void terminateNs() throws Exception {
+
+ NsOperationKey nsOperationKey = new NsOperationKey();
+
+ RestfulResponse restfulResponse = new RestfulResponse();
+ restfulResponse.setStatus(HttpStatus.OK.value());
+ restfulResponse.setResponseContent("{\"" + CommonConstant.JOB_ID + "\": \"someJobId\"}");
+ when(restfulUtil.send(any(), any(), any())).thenReturn(restfulResponse);
+
+ RestfulResponse response = vfcManager.terminateNs(nsOperationKey, "someNsInstanceId");
+ assertEquals(HttpStatus.OK.value(), response.getStatus());
+ }
+
+ @Test
+ public void getNsProgress() throws Exception {
+
+ NsOperationKey nsOperationKey = new NsOperationKey();
+ ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus();
+
+ RestfulResponse restfulResponse = new RestfulResponse();
+ restfulResponse.setStatus(HttpStatus.OK.value());
+ restfulResponse
+ .setResponseContent("{\"" + CommonConstant.JOB_ID + "\": \"someJobId\", " + "\"responseDescriptor\" : {}}");
+ when(restfulUtil.send(any(), any(), any())).thenReturn(restfulResponse);
+
+ when(resourceOperationStatusRepository.findOne(any()))
+ .thenReturn(java.util.Optional.ofNullable(resourceOperationStatus));
+
+ RestfulResponse response = vfcManager.getNsProgress(nsOperationKey, "someJobId");
+ assertEquals(HttpStatus.OK.value(), response.getStatus());
+ }
+
+ @Test
+ public void scaleNs() throws Exception {
+
+ ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus();
+ NSResourceInputParameter segInput = new NSResourceInputParameter();
+ NsScaleParameters nsScaleParameters = new NsScaleParameters();
+ segInput.setNsScaleParameters(nsScaleParameters);
+
+ RestfulResponse restfulResponse = new RestfulResponse();
+ restfulResponse.setStatus(HttpStatus.OK.value());
+ segInput.setNsOperationKey(new NsOperationKey());
+ restfulResponse.setResponseContent("{\"" + CommonConstant.JOB_ID + "\": \"someJobId\"}");
+ when(restfulUtil.send(any(), any(), any())).thenReturn(restfulResponse);
+
+ when(resourceOperationStatusRepository.findOne(any()))
+ .thenReturn(java.util.Optional.ofNullable(resourceOperationStatus));
+
+ RestfulResponse response = vfcManager.scaleNs("someNsInstanceId", segInput);
+ assertEquals(HttpStatus.OK.value(), restfulResponse.getStatus());
+ }
+
+}
diff --git a/asdc-controller/pom.xml b/asdc-controller/pom.xml
index 7b774a2cce..35fbf9108c 100644
--- a/asdc-controller/pom.xml
+++ b/asdc-controller/pom.xml
@@ -30,7 +30,6 @@
<version>0.7.7.201606060606</version>
<configuration>
<excludes>
- +
<exclude>**/resource-examples/**</exclude>
</excludes>
</configuration>
@@ -143,6 +142,24 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-test</id>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <includes>
+ <include>**/AllTestsTestSuite.java</include>
+ </includes>
+ <parallel>suites</parallel>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
<dependencies>
@@ -232,7 +249,7 @@
<groupId>org.antlr</groupId>
<artifactId>antlr4</artifactId>
<version>${antlr.version}</version>
-
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
index db639dad0a..3a29247d6e 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
@@ -10,9 +10,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,8 +24,6 @@
package org.onap.so.asdc.installer.heat;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
@@ -37,6 +35,7 @@ import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
+
import org.hibernate.exception.ConstraintViolationException;
import org.hibernate.exception.LockAcquisitionException;
import org.onap.sdc.api.notification.IArtifactInfo;
@@ -143,2323 +142,2227 @@ import org.springframework.orm.ObjectOptimisticLockingFailureException;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
@Component
public class ToscaResourceInstaller {
- protected static final String NODES_VRF_ENTRY = "org.openecomp.nodes.VRFEntry";
-
- protected static final String VLAN_NETWORK_RECEPTOR = "org.openecomp.nodes.VLANNetworkReceptor";
-
- protected static final String ALLOTTED_RESOURCE = "Allotted Resource";
-
- protected static final String MULTI_STAGE_DESIGN = "multi_stage_design";
-
- protected static final String SCALABLE = "scalable";
-
- protected static final String BASIC = "BASIC";
-
- protected static final String PROVIDER = "PROVIDER";
-
- protected static final String HEAT = "HEAT";
-
- protected static final String MANUAL_RECORD = "MANUAL_RECORD";
-
- protected static final String MSO = "SO";
-
- protected static final String SDNC_MODEL_NAME = "sdnc_model_name";
-
- protected static final String SDNC_MODEL_VERSION = "sdnc_model_version";
-
- private static String CUSTOMIZATION_UUID = "customizationUUID";
-
-
- @Autowired
- protected ServiceRepository serviceRepo;
-
- @Autowired
- protected InstanceGroupRepository instanceGroupRepo;
-
- @Autowired
- protected ServiceProxyResourceCustomizationRepository serviceProxyCustomizationRepo;
-
- @Autowired
- protected CollectionResourceRepository collectionRepo;
-
- @Autowired
- protected CollectionResourceCustomizationRepository collectionCustomizationRepo;
-
- @Autowired
- protected ConfigurationResourceCustomizationRepository configCustomizationRepo;
-
- @Autowired
- protected ConfigurationResourceRepository configRepo;
-
- @Autowired
- protected VnfResourceRepository vnfRepo;
-
- @Autowired
- protected VnfCustomizationRepository vnfCustomizationRepo;
-
- @Autowired
- protected VFModuleRepository vfModuleRepo;
-
- @Autowired
- protected VFModuleCustomizationRepository vfModuleCustomizationRepo;
-
- @Autowired
- protected VnfcInstanceGroupCustomizationRepository vnfcInstanceGroupCustomizationRepo;
-
- @Autowired
- protected VnfcCustomizationRepository vnfcCustomizationRepo;
-
- @Autowired
- protected CvnfcCustomizationRepository cvnfcCustomizationRepo;
-
- @Autowired
- protected AllottedResourceRepository allottedRepo;
-
- @Autowired
- protected AllottedResourceCustomizationRepository allottedCustomizationRepo;
-
- @Autowired
- protected NetworkResourceRepository networkRepo;
-
- @Autowired
- protected HeatTemplateRepository heatRepo;
-
- @Autowired
- protected NetworkResourceCustomizationRepository networkCustomizationRepo;
+ protected static final String NODES_VRF_ENTRY = "org.openecomp.nodes.VRFEntry";
+
+ protected static final String VLAN_NETWORK_RECEPTOR = "org.openecomp.nodes.VLANNetworkReceptor";
+
+ protected static final String ALLOTTED_RESOURCE = "Allotted Resource";
- @Autowired
- protected WatchdogComponentDistributionStatusRepository watchdogCDStatusRepository;
- @Autowired
- protected WatchdogDistributionStatusRepository watchdogDistributionStatusRepository;
- @Autowired
- protected WatchdogServiceModVerIdLookupRepository watchdogModVerIdLookupRepository;
-
- @Autowired
- protected TempNetworkHeatTemplateRepository tempNetworkLookupRepo;
-
- @Autowired
- protected ExternalServiceToInternalServiceRepository externalServiceToInternalServiceRepository;
-
- @Autowired
- protected PnfResourceRepository pnfResourceRepository;
-
- @Autowired
- protected PnfCustomizationRepository pnfCustomizationRepository;
-
- protected static final Logger logger = LoggerFactory.getLogger(ToscaResourceInstaller.class);
-
- public boolean isResourceAlreadyDeployed(VfResourceStructure vfResourceStruct) throws ArtifactInstallerException {
- boolean status = false;
- VfResourceStructure vfResourceStructure = vfResourceStruct;
- try {
- status = vfResourceStructure.isDeployedSuccessfully();
- } catch (RuntimeException e) {
- status = false;
- }
- try {
- Service existingService = serviceRepo
- .findOneByModelUUID(vfResourceStructure.getNotification().getServiceUUID());
- if (existingService != null) {
- status = true;
- }
- if (status) {
- logger.info(vfResourceStructure.getResourceInstance().getResourceInstanceName(),
- vfResourceStructure.getResourceInstance().getResourceCustomizationUUID(),
- vfResourceStructure.getNotification().getServiceName(),
- BigDecimalVersion.castAndCheckNotificationVersionToString(
- vfResourceStructure.getNotification().getServiceVersion()),
- vfResourceStructure.getNotification().getServiceUUID(),
- vfResourceStructure.getResourceInstance().getResourceName(), "", "");
- WatchdogComponentDistributionStatus wdStatus = new WatchdogComponentDistributionStatus(
- vfResourceStruct.getNotification().getDistributionID(), MSO);
- wdStatus.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name());
- watchdogCDStatusRepository.saveAndFlush(wdStatus);
- } else {
- logger.info(vfResourceStructure.getResourceInstance().getResourceInstanceName(),
- vfResourceStructure.getResourceInstance().getResourceCustomizationUUID(),
- vfResourceStructure.getNotification().getServiceName(),
- BigDecimalVersion.castAndCheckNotificationVersionToString(
- vfResourceStructure.getNotification().getServiceVersion()),
- vfResourceStructure.getNotification().getServiceUUID(),
- vfResourceStructure.getResourceInstance().getResourceName(), "", "");
- }
- return status;
- } catch (Exception e) {
- logger
- .error("{} {} {}", MessageEnum.ASDC_ARTIFACT_CHECK_EXC.toString(),
- ErrorCode.SchemaError.getValue(),
- "Exception - isResourceAlreadyDeployed");
- throw new ArtifactInstallerException("Exception caught during checking existence of the VNF Resource.", e);
- }
- }
-
- public void installTheComponentStatus(IStatusData iStatus) throws ArtifactInstallerException {
- logger.debug("Entering installTheComponentStatus for distributionId {} and ComponentName {}",
- iStatus.getDistributionID(), iStatus.getComponentName());
-
- try {
- WatchdogComponentDistributionStatus cdStatus = new WatchdogComponentDistributionStatus(
- iStatus.getDistributionID(),
- iStatus.getComponentName());
- cdStatus.setComponentDistributionStatus(iStatus.getStatus().toString());
- watchdogCDStatusRepository.save(cdStatus);
-
- } catch (Exception e) {
- logger.debug("Exception caught in installTheComponentStatus {}", e.getMessage());
- throw new ArtifactInstallerException("Exception caught in installTheComponentStatus " + e.getMessage());
- }
- }
-
- @Transactional(rollbackFor = {ArtifactInstallerException.class})
- public void installTheResource(ToscaResourceStructure toscaResourceStruct, ResourceStructure resourceStruct)
- throws ArtifactInstallerException {
- if (resourceStruct instanceof VfResourceStructure) {
- installTheVfResouce(toscaResourceStruct, (VfResourceStructure) resourceStruct);
- } else if (resourceStruct instanceof PnfResourceStructure) {
- installPnfResource(toscaResourceStruct, (PnfResourceStructure) resourceStruct);
- } else {
- logger.warn("Unrecognized resource type");
- }
- }
-
- private void installPnfResource(ToscaResourceStructure toscaResourceStruct, PnfResourceStructure resourceStruct)
- throws ArtifactInstallerException {
-
- // PCLO: in case of deployment failure, use a string that will represent
- // the type of artifact that failed...
- List<ASDCElementInfo> artifactListForLogging = new ArrayList<>();
- try {
- createToscaCsar(toscaResourceStruct);
- Service service = createService(toscaResourceStruct, resourceStruct);
-
- processResourceSequence(toscaResourceStruct, service);
- processPnfResources(toscaResourceStruct, service, resourceStruct);
- serviceRepo.save(service);
-
- WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus(
- resourceStruct.getNotification().getDistributionID(), MSO);
- status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name());
- watchdogCDStatusRepository.save(status);
-
- toscaResourceStruct.setSuccessfulDeployment();
-
- } catch (Exception e) {
- logger.debug("Exception :", e);
- WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus(
- resourceStruct.getNotification().getDistributionID(), MSO);
- status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_ERROR.name());
- watchdogCDStatusRepository.save(status);
- Throwable dbExceptionToCapture = e;
- while (!(dbExceptionToCapture instanceof ConstraintViolationException
- || dbExceptionToCapture instanceof LockAcquisitionException)
- && (dbExceptionToCapture.getCause() != null)) {
- dbExceptionToCapture = dbExceptionToCapture.getCause();
- }
-
- if (dbExceptionToCapture instanceof ConstraintViolationException
- || dbExceptionToCapture instanceof LockAcquisitionException) {
- logger.warn("{} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED.toString(),
- resourceStruct.getResourceInstance().getResourceName(),
- resourceStruct.getNotification().getServiceVersion(), ErrorCode.DataError.getValue(),
- "Exception - ASCDC Artifact already deployed", e);
- } else {
- String elementToLog = (!artifactListForLogging.isEmpty()
- ? artifactListForLogging.get(artifactListForLogging.size() - 1).toString()
- : "No element listed");
- logger.error("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_INSTALL_EXC.toString(), elementToLog,
- ErrorCode.DataError.getValue(),
- "Exception caught during installation of " + resourceStruct.getResourceInstance()
- .getResourceName()
- + ". Transaction rollback", e);
- throw new ArtifactInstallerException("Exception caught during installation of "
- + resourceStruct.getResourceInstance().getResourceName() + ". Transaction rollback.", e);
- }
- }
- }
-
- private void installTheVfResouce(ToscaResourceStructure toscaResourceStruct, VfResourceStructure resourceStruct)
- throws ArtifactInstallerException {
- VfResourceStructure vfResourceStructure = resourceStruct;
- extractHeatInformation(toscaResourceStruct, vfResourceStructure);
-
- // PCLO: in case of deployment failure, use a string that will represent
- // the type of artifact that failed...
- List<ASDCElementInfo> artifactListForLogging = new ArrayList<>();
- try {
- createToscaCsar(toscaResourceStruct);
- Service service = createService(toscaResourceStruct, resourceStruct);
-
- processResourceSequence(toscaResourceStruct, service);
- processVFResources(toscaResourceStruct, service, vfResourceStructure);
- List<NodeTemplate> allottedResourceList = toscaResourceStruct.getSdcCsarHelper().getAllottedResources();
- processAllottedResources(toscaResourceStruct, service, allottedResourceList);
- processNetworks(toscaResourceStruct, service);
- // process Network Collections
- processNetworkCollections(toscaResourceStruct, service);
- // Process Service Proxy & Configuration
- processServiceProxyAndConfiguration(toscaResourceStruct, service);
-
- serviceRepo.save(service);
-
- WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus(
- resourceStruct.getNotification().getDistributionID(), MSO);
- status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name());
- watchdogCDStatusRepository.save(status);
-
- toscaResourceStruct.setSuccessfulDeployment();
-
- } catch (Exception e) {
- logger.debug("Exception :", e);
- WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus(
- resourceStruct.getNotification().getDistributionID(), MSO);
- status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_ERROR.name());
- watchdogCDStatusRepository.save(status);
- Throwable dbExceptionToCapture = e;
- while (!(dbExceptionToCapture instanceof ConstraintViolationException
- || dbExceptionToCapture instanceof LockAcquisitionException)
- && (dbExceptionToCapture.getCause() != null)) {
- dbExceptionToCapture = dbExceptionToCapture.getCause();
- }
-
- if (dbExceptionToCapture instanceof ConstraintViolationException
- || dbExceptionToCapture instanceof LockAcquisitionException) {
- logger.warn("{} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED.toString(),
- vfResourceStructure.getResourceInstance().getResourceName(),
- vfResourceStructure.getNotification().getServiceVersion(), ErrorCode.DataError.getValue(),
- "Exception - ASCDC Artifact already deployed", e);
- } else {
- String elementToLog = (!artifactListForLogging.isEmpty()
- ? artifactListForLogging.get(artifactListForLogging.size() - 1).toString()
- : "No element listed");
- logger.error("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_INSTALL_EXC.toString(), elementToLog,
- ErrorCode.DataError.getValue(),
- "Exception caught during installation of " + vfResourceStructure.getResourceInstance()
- .getResourceName()
- + ". Transaction rollback", e);
- throw new ArtifactInstallerException("Exception caught during installation of "
- + vfResourceStructure.getResourceInstance().getResourceName() + ". Transaction rollback.", e);
- }
- }
- }
-
-
- List<NodeTemplate> getRequirementList(List<NodeTemplate> resultList, List<NodeTemplate> nodeTemplates,
- ISdcCsarHelper iSdcCsarHelper) {
-
- List<NodeTemplate> nodes = new ArrayList<NodeTemplate>();
- nodes.addAll(nodeTemplates);
-
- for (NodeTemplate nodeTemplate : nodeTemplates) {
- RequirementAssignments requirement = iSdcCsarHelper.getRequirementsOf(nodeTemplate);
- List<RequirementAssignment> reqAs = requirement.getAll();
- for (RequirementAssignment ra : reqAs) {
- String reqNode = ra.getNodeTemplateName();
- for (NodeTemplate rNode : resultList) {
- if (rNode.getName().equals(reqNode)) {
- if (!resultList.contains(nodeTemplate)) {
- resultList.add(nodeTemplate);
- }
- if (nodes.contains(nodeTemplate)) {
- nodes.remove(nodeTemplate);
- }
- break;
- }
- }
- }
- }
-
- if (!nodes.isEmpty()) {
- getRequirementList(resultList, nodes, iSdcCsarHelper);
- }
-
- return resultList;
- }
-
- // This method retrieve resource sequence from csar file
- void processResourceSequence(ToscaResourceStructure toscaResourceStructure, Service service) {
- List<String> resouceSequence = new ArrayList<String>();
- List<NodeTemplate> resultList = new ArrayList<NodeTemplate>();
-
- ISdcCsarHelper iSdcCsarHelper = toscaResourceStructure.getSdcCsarHelper();
- List<NodeTemplate> nodeTemplates = iSdcCsarHelper.getServiceNodeTemplates();
- List<NodeTemplate> nodes = new ArrayList<NodeTemplate>();
- nodes.addAll(nodeTemplates);
-
- for (NodeTemplate nodeTemplate : nodeTemplates) {
- RequirementAssignments requirement = iSdcCsarHelper.getRequirementsOf(nodeTemplate);
-
- if (requirement == null || requirement.getAll() == null || requirement.getAll().isEmpty()) {
- resultList.add(nodeTemplate);
- nodes.remove(nodeTemplate);
- }
- }
-
- resultList = getRequirementList(resultList, nodes, iSdcCsarHelper);
-
- for (NodeTemplate node : resultList) {
- String templateName = node.getMetaData().getValue("name");
- if (!resouceSequence.contains(templateName)) {
- resouceSequence.add(templateName);
- }
- }
-
- String resourceSeqStr = resouceSequence.stream().collect(Collectors.joining(","));
- service.setResourceOrder(resourceSeqStr);
- logger.debug(" resourceSeq for service uuid(" + service.getModelUUID() + ") : " + resourceSeqStr);
- }
-
- private static String getValue(Object value, List<Input> servInputs) {
- String output = null;
- if (value instanceof Map) {
- // currently this logic handles only one level of nesting.
- return ((LinkedHashMap) value).values().toArray()[0].toString();
- } else if (value instanceof GetInput) {
- String inputName = ((GetInput) value).getInputName();
-
- for (Input input : servInputs) {
- if (input.getName().equals(inputName)) {
- // keep both input name and default value
- // if service input does not supplies value the use default value
- String defaultValue = input.getDefault() != null ? (String) input.getDefault().toString() : "";
- output = inputName + "|" + defaultValue;// return default value
- }
- }
-
- } else {
- output = value != null ? value.toString() : "";
- }
- return output; // return property value
- }
-
- String getResourceInput(ToscaResourceStructure toscaResourceStructure, String resourceCustomizationUuid)
- throws ArtifactInstallerException {
- Map<String, String> resouceRequest = new HashMap<>();
- ISdcCsarHelper iSdcCsarHelper = toscaResourceStructure.getSdcCsarHelper();
-
- List<Input> serInput = iSdcCsarHelper.getServiceInputs();
- Optional<NodeTemplate> nodeTemplateOpt = iSdcCsarHelper.getServiceNodeTemplates().stream()
- .filter(e -> e.getMetaData().getValue(CUSTOMIZATION_UUID).equals(resourceCustomizationUuid)).findFirst();
- if (nodeTemplateOpt.isPresent()) {
- NodeTemplate nodeTemplate = nodeTemplateOpt.get();
- LinkedHashMap<String, Property> resourceProperties = nodeTemplate.getProperties();
-
- for (String key : resourceProperties.keySet()) {
- Property property = resourceProperties.get(key);
-
- String value = getValue(property.getValue(), serInput);
- resouceRequest.put(key, value);
- }
- }
-
- try {
- ObjectMapper objectMapper = new ObjectMapper();
- String jsonStr = objectMapper.writeValueAsString(resouceRequest);
-
- jsonStr = jsonStr.replace("\"", "\\\"");
- logger.debug(
- "resource request for resource customization id (" + resourceCustomizationUuid + ") : " + jsonStr);
- return jsonStr;
- } catch (JsonProcessingException e) {
- logger.error("resource input could not be deserialized for resource customization id ("
- + resourceCustomizationUuid + ")");
- throw new ArtifactInstallerException("resource input could not be parsed", e);
- }
- }
-
- protected void processNetworks(ToscaResourceStructure toscaResourceStruct,
- Service service) throws ArtifactInstallerException {
- List<NodeTemplate> nodeTemplatesVLList = toscaResourceStruct.getSdcCsarHelper().getServiceVlList();
-
- if (nodeTemplatesVLList != null) {
- for (NodeTemplate vlNode : nodeTemplatesVLList) {
- String networkResourceModelName = vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME);
-
- TempNetworkHeatTemplateLookup tempNetworkLookUp =
- tempNetworkLookupRepo.findFirstBynetworkResourceModelName(networkResourceModelName);
-
- if (tempNetworkLookUp != null) {
- HeatTemplate heatTemplate =
- heatRepo.findByArtifactUuid(tempNetworkLookUp.getHeatTemplateArtifactUuid());
- if (heatTemplate != null) {
- NetworkResourceCustomization networkCustomization =
- createNetwork(vlNode,
- toscaResourceStruct,
- heatTemplate,
- tempNetworkLookUp.getAicVersionMax(),
- tempNetworkLookUp.getAicVersionMin(),
- service);
- service.getNetworkCustomizations().add(networkCustomization);
- } else {
- throw new ArtifactInstallerException("No HeatTemplate found for artifactUUID: "
- + tempNetworkLookUp.getHeatTemplateArtifactUuid());
- }
- } else {
- NetworkResourceCustomization networkCustomization = createNetwork(vlNode,
- toscaResourceStruct,
- null,
- null,
- null,
- service);
- service.getNetworkCustomizations().add(networkCustomization);
- logger.debug("No NetworkResourceName found in TempNetworkHeatTemplateLookup for "
- + networkResourceModelName);
- }
-
- }
- }
- }
-
- protected void processAllottedResources(ToscaResourceStructure toscaResourceStruct, Service service,
- List<NodeTemplate> allottedResourceList) {
- if (allottedResourceList != null) {
- for (NodeTemplate allottedNode : allottedResourceList) {
- service.getAllottedCustomizations()
- .add(createAllottedResource(allottedNode, toscaResourceStruct, service));
- }
- }
- }
-
-
- protected ConfigurationResource getConfigurationResource(NodeTemplate nodeTemplate) {
- Metadata metadata = nodeTemplate.getMetaData();
- ConfigurationResource configResource = new ConfigurationResource();
- configResource.setModelName(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
- configResource.setModelInvariantUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
- configResource.setModelUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
- configResource.setModelVersion(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
- configResource.setDescription(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
- configResource.setToscaNodeType(nodeTemplate.getType());
- return configResource;
- }
-
- protected ConfigurationResourceCustomization getConfigurationResourceCustomization(NodeTemplate nodeTemplate,
- ToscaResourceStructure toscaResourceStructure,
- ServiceProxyResourceCustomization spResourceCustomization) {
- Metadata metadata = nodeTemplate.getMetaData();
-
- ConfigurationResource configResource = getConfigurationResource(nodeTemplate);
-
- ConfigurationResourceCustomization configCustomizationResource = new ConfigurationResourceCustomization();
-
- Set<ConfigurationResourceCustomization> configResourceCustomizationSet = new HashSet<>();
-
- configCustomizationResource
- .setModelCustomizationUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
- configCustomizationResource.setModelInstanceName(nodeTemplate.getName());
-
- configCustomizationResource.setNfFunction(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION));
- configCustomizationResource.setNfRole(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE));
- configCustomizationResource.setNfType(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE));
- configCustomizationResource
- .setServiceProxyResourceCustomizationUUID(spResourceCustomization.getModelCustomizationUUID());
-
- configCustomizationResource.setConfigurationResource(configResource);
- configResourceCustomizationSet.add(configCustomizationResource);
-
- configResource.setConfigurationResourceCustomization(configResourceCustomizationSet);
- return configCustomizationResource;
- }
-
-
- protected Optional<ConfigurationResourceCustomization> getVnrNodeTemplate(
- List<NodeTemplate> configurationNodeTemplatesList,
- ToscaResourceStructure toscaResourceStructure, ServiceProxyResourceCustomization spResourceCustomization) {
- Optional<ConfigurationResourceCustomization> configurationResourceCust = Optional.empty();
- for (NodeTemplate nodeTemplate : configurationNodeTemplatesList) {
- StatefulEntityType entityType = nodeTemplate.getTypeDefinition();
- String type = entityType.getType();
-
- if (VLAN_NETWORK_RECEPTOR.equals(type)) {
- configurationResourceCust = Optional.of(getConfigurationResourceCustomization(nodeTemplate,
- toscaResourceStructure, spResourceCustomization));
- break;
- }
- }
-
- return configurationResourceCust;
- }
-
- protected void processServiceProxyAndConfiguration(ToscaResourceStructure toscaResourceStruct, Service service) {
-
- List<NodeTemplate> serviceProxyResourceList = toscaResourceStruct.getSdcCsarHelper()
- .getServiceNodeTemplateBySdcType(SdcTypes.SERVICE_PROXY);
-
- List<NodeTemplate> configurationNodeTemplatesList = toscaResourceStruct.getSdcCsarHelper()
- .getServiceNodeTemplateBySdcType(SdcTypes.CONFIGURATION);
-
- List<ServiceProxyResourceCustomization> serviceProxyList = new ArrayList<ServiceProxyResourceCustomization>();
- List<ConfigurationResourceCustomization> configurationResourceList = new ArrayList<ConfigurationResourceCustomization>();
-
- ServiceProxyResourceCustomization serviceProxy = null;
-
- if (serviceProxyResourceList != null) {
- for (NodeTemplate spNode : serviceProxyResourceList) {
- serviceProxy = createServiceProxy(spNode, service, toscaResourceStruct);
- serviceProxyList.add(serviceProxy);
- Optional<ConfigurationResourceCustomization> vnrResourceCustomization = getVnrNodeTemplate(
- configurationNodeTemplatesList, toscaResourceStruct, serviceProxy);
-
- for (NodeTemplate configNode : configurationNodeTemplatesList) {
-
- List<RequirementAssignment> requirementsList = toscaResourceStruct.getSdcCsarHelper()
- .getRequirementsOf(configNode).getAll();
- for (RequirementAssignment requirement : requirementsList) {
- if (requirement.getNodeTemplateName().equals(spNode.getName())) {
- ConfigurationResourceCustomization configurationResource = createConfiguration(configNode,
- toscaResourceStruct, serviceProxy, vnrResourceCustomization);
-
- Optional<ConfigurationResourceCustomization> matchingObject = configurationResourceList
- .stream()
- .filter(configurationResourceCustomization -> configNode.getMetaData()
- .getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)
- .equals(configurationResource.getModelCustomizationUUID()))
- .findFirst();
- if (!matchingObject.isPresent()) {
- configurationResourceList.add(configurationResource);
- }
-
- break;
- }
- }
- }
-
- }
- }
-
- service.setConfigurationCustomizations(configurationResourceList);
- service.setServiceProxyCustomizations(serviceProxyList);
- }
-
- protected void processNetworkCollections(ToscaResourceStructure toscaResourceStruct, Service service) {
-
- List<NodeTemplate> networkCollectionList = toscaResourceStruct.getSdcCsarHelper()
- .getServiceNodeTemplateBySdcType(SdcTypes.CR);
-
- if (networkCollectionList != null) {
- for (NodeTemplate crNode : networkCollectionList) {
-
- createNetworkCollection(crNode, toscaResourceStruct, service);
- collectionRepo.saveAndFlush(toscaResourceStruct.getCatalogCollectionResource());
-
- List<NetworkInstanceGroup> networkInstanceGroupList = toscaResourceStruct
- .getCatalogNetworkInstanceGroup();
- for (NetworkInstanceGroup networkInstanceGroup : networkInstanceGroupList) {
- instanceGroupRepo.saveAndFlush(networkInstanceGroup);
- }
-
- }
- }
- service.getCollectionResourceCustomizations()
- .add(toscaResourceStruct.getCatalogCollectionResourceCustomization());
- }
-
-
- protected void processVFResources(ToscaResourceStructure toscaResourceStruct, Service service,
- VfResourceStructure vfResourceStructure)
- throws Exception {
- logger.debug("processVFResources");
-
- List<NodeTemplate> vfNodeTemplatesList = toscaResourceStruct.getSdcCsarHelper().getServiceVfList();
-
- for (NodeTemplate nodeTemplate : vfNodeTemplatesList) {
- Metadata metadata = nodeTemplate.getMetaData();
- String vfCustomizationCategory = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY);
- logger.debug("VF Category is : " + vfCustomizationCategory);
-
- // Do not treat Allotted Resources as VNF resources
- if (ALLOTTED_RESOURCE.equalsIgnoreCase(vfCustomizationCategory)) {
- continue;
- }
-
- String vfCustomizationUUID = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
- logger.debug("VFCustomizationUUID=" + vfCustomizationUUID);
-
- IResourceInstance vfNotificationResource = vfResourceStructure.getResourceInstance();
-
- // Make sure the VF ResourceCustomizationUUID from the notification and tosca
- // customizations match before comparing their VF Modules UUID's
- logger.debug("Checking if Notification VF ResourceCustomizationUUID: "
- + vfNotificationResource.getResourceCustomizationUUID() + " matches Tosca VF Customization UUID: "
- + vfCustomizationUUID);
-
- if (vfCustomizationUUID.equals(vfNotificationResource.getResourceCustomizationUUID())) {
- logger.debug("vfCustomizationUUID: " + vfCustomizationUUID
- + " matches vfNotificationResource CustomizationUUID");
-
- processVfModules(toscaResourceStruct, vfResourceStructure, service, nodeTemplate, metadata,
- vfCustomizationCategory);
- } else {
- logger.debug("Notification VF ResourceCustomizationUUID: "
- + vfNotificationResource.getResourceCustomizationUUID() + " doesn't match "
- + "Tosca VF Customization UUID: " + vfCustomizationUUID);
- }
- }
- }
-
- /**
- * This is used to process the PNF specific resource, including resource and resource_customization. {@link
- * IEntityDetails} based API is used to retrieve information. Please check {@link ISdcCsarHelper} for details.
- */
- protected void processPnfResources(ToscaResourceStructure toscaResourceStruct, Service service,
- PnfResourceStructure resourceStructure) throws Exception {
- logger.info("Processing PNF resource: {}", resourceStructure.getResourceInstance().getResourceUUID());
-
- ISdcCsarHelper sdcCsarHelper = toscaResourceStruct.getSdcCsarHelper();
- EntityQuery entityQuery = EntityQuery.newBuilder(SdcTypes.PNF).build();
- TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE).build();
-
- List<IEntityDetails> entityDetailsList = sdcCsarHelper.getEntity(entityQuery, topologyTemplateQuery, false);
- for (IEntityDetails entityDetails : entityDetailsList) {
- Metadata metadata = entityDetails.getMetadata();
- String customizationUUID = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
- String modelUuid = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID);
- String notifCustomizationUUID = resourceStructure.getResourceInstance().getResourceCustomizationUUID();
- if (customizationUUID != null && customizationUUID.equals(notifCustomizationUUID)) {
- logger.info("Resource customization UUID: {} is the same as notified resource customizationUUID: {}",
- customizationUUID, notifCustomizationUUID);
-
- if (checkExistingPnfResourceCutomization(customizationUUID)) {
- logger.info("Resource customization UUID: {} already deployed", customizationUUID);
- } else {
- PnfResource pnfResource = findExistingPnfResource(service, modelUuid);
- if (pnfResource == null) {
- pnfResource = createPnfResource(entityDetails);
- }
- PnfResourceCustomization pnfResourceCustomization = createPnfResourceCustomization(entityDetails,
- pnfResource);
- pnfResource.getPnfResourceCustomizations().add(pnfResourceCustomization);
- toscaResourceStruct.setPnfResourceCustomization(pnfResourceCustomization);
- service.getPnfCustomizations().add(pnfResourceCustomization);
- }
- } else {
- logger
- .warn("Resource customization UUID: {} is NOT the same as notified resource customizationUUID: {}",
- customizationUUID, notifCustomizationUUID);
- }
- }
- }
-
- private PnfResource findExistingPnfResource(Service service, String modelUuid) {
- PnfResource pnfResource = null;
- for (PnfResourceCustomization pnfResourceCustomization : service.getPnfCustomizations()) {
- if (pnfResourceCustomization.getPnfResources() != null && pnfResourceCustomization.getPnfResources()
- .getModelUUID().equals(modelUuid)) {
- pnfResource = pnfResourceCustomization.getPnfResources();
- }
- }
- if (pnfResource == null) {
- pnfResource = pnfResourceRepository.findById(modelUuid).orElse(pnfResource);
- }
- return pnfResource;
- }
-
- private boolean checkExistingPnfResourceCutomization(String customizationUUID) {
- return pnfCustomizationRepository.findById(customizationUUID).isPresent();
- }
-
- /**
- * Construct the {@link PnfResource} from {@link IEntityDetails} object.
- */
- private PnfResource createPnfResource(IEntityDetails entity) {
- PnfResource pnfResource = new PnfResource();
- Metadata metadata = entity.getMetadata();
- pnfResource.setModelInvariantUUID(
- testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
- pnfResource.setModelName(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
- pnfResource.setModelUUID(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
- pnfResource.setModelVersion(
- testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
- pnfResource.setDescription(
- testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
- pnfResource.setCategory(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY)));
- pnfResource.setSubCategory(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY)));
- pnfResource.setToscaNodeType(entity.getToscaType());
- return pnfResource;
- }
-
- /**
- * Construct the {@link PnfResourceCustomization} from {@link IEntityDetails} object.
- */
- private PnfResourceCustomization createPnfResourceCustomization(IEntityDetails entityDetails,
- PnfResource pnfResource) {
-
- PnfResourceCustomization pnfResourceCustomization = new PnfResourceCustomization();
- Metadata metadata = entityDetails.getMetadata();
- Map<String, Property> properties = entityDetails.getProperties();
- pnfResourceCustomization
- .setModelCustomizationUUID(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
- pnfResourceCustomization.setModelInstanceName(entityDetails.getName());
- pnfResourceCustomization
- .setNfFunction(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)));
- pnfResourceCustomization.setNfNamingCode(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFCODE)));
- pnfResourceCustomization.setNfRole(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFROLE)));
- pnfResourceCustomization.setNfType(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFTYPE)));
- pnfResourceCustomization.setMultiStageDesign(getStringValue(properties.get(MULTI_STAGE_DESIGN)));
- pnfResourceCustomization.setBlueprintName(getStringValue(properties.get(SDNC_MODEL_NAME)));
- pnfResourceCustomization.setBlueprintVersion(getStringValue(properties.get(SDNC_MODEL_VERSION)));
-
- pnfResourceCustomization.setPnfResources(pnfResource);
-
- return pnfResourceCustomization;
- }
-
- /**
- * Get value from {@link Property} and cast to String value. Return empty String if property is null value.
- */
- private String getStringValue(Property property) {
- if (null == property) {
- return "";
- }
- Object value = property.getValue();
- return String.valueOf(value);
- }
-
- protected void processVfModules(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStructure,
- Service service, NodeTemplate nodeTemplate, Metadata metadata, String vfCustomizationCategory)
- throws Exception {
-
- logger.debug("VF Category is : " + vfCustomizationCategory);
-
- VnfResourceCustomization vnfResource = createVnfResource(nodeTemplate, toscaResourceStruct, service);
-
- if (vfResourceStructure.getVfModuleStructure() != null && !vfResourceStructure.getVfModuleStructure()
- .isEmpty()) {
-
- String vfCustomizationUUID = toscaResourceStruct.getSdcCsarHelper()
- .getMetadataPropertyValue(metadata, SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
- logger.debug("VFCustomizationUUID=" + vfCustomizationUUID);
-
- IResourceInstance vfNotificationResource = vfResourceStructure.getResourceInstance();
-
- // Make sure the VF ResourceCustomizationUUID from the notification and tosca customizations match before comparing their VF Modules UUID's
- logger.debug("Checking if Notification VF ResourceCustomizationUUID: " + vfNotificationResource
- .getResourceCustomizationUUID() +
- " matches Tosca VF Customization UUID: " + vfCustomizationUUID);
-
- if (vfCustomizationUUID.equals(vfNotificationResource.getResourceCustomizationUUID())) {
-
- logger.debug("vfCustomizationUUID: " + vfCustomizationUUID
- + " matches vfNotificationResource CustomizationUUID");
-
- Set<CvnfcCustomization> existingCvnfcSet = new HashSet<CvnfcCustomization>();
- Set<VnfcCustomization> existingVnfcSet = new HashSet<VnfcCustomization>();
-
- for (VfModuleStructure vfModuleStructure : vfResourceStructure.getVfModuleStructure()) {
-
- logger.debug("vfModuleStructure:" + vfModuleStructure.toString());
- List<org.onap.sdc.toscaparser.api.Group> vfGroups = toscaResourceStruct
- .getSdcCsarHelper().getVfModulesByVf(vfCustomizationUUID);
- IVfModuleData vfMetadata = vfModuleStructure.getVfModuleMetadata();
-
- logger.debug("Comparing Vf_Modules_Metadata CustomizationUUID : " + vfMetadata
- .getVfModuleModelCustomizationUUID());
-
- Optional<org.onap.sdc.toscaparser.api.Group> matchingObject = vfGroups.stream()
- .peek(group -> logger.debug(
- "To Csar Group VFModuleModelCustomizationUUID " + group.getMetadata()
- .getValue("vfModuleModelCustomizationUUID")))
- .filter(group -> group.getMetadata().getValue("vfModuleModelCustomizationUUID")
- .equals(vfMetadata.getVfModuleModelCustomizationUUID()))
- .findFirst();
- if (matchingObject.isPresent()) {
- VfModuleCustomization vfModuleCustomization = createVFModuleResource(matchingObject.get(),
- nodeTemplate, toscaResourceStruct,
- vfResourceStructure, vfMetadata, vnfResource, service, existingCvnfcSet, existingVnfcSet);
- vfModuleCustomization.getVfModule().setVnfResources(vnfResource.getVnfResources());
- } else {
- throw new Exception(
- "Cannot find matching VFModule Customization in Csar for Vf_Modules_Metadata: " + vfMetadata
- .getVfModuleModelCustomizationUUID());
- }
-
- }
-
- } else {
- logger.debug("Notification VF ResourceCustomizationUUID: " + vfNotificationResource
- .getResourceCustomizationUUID() + " doesn't match " +
- "Tosca VF Customization UUID: " + vfCustomizationUUID);
- }
- }
-
- service.getVnfCustomizations().add(vnfResource);
- }
-
- public void processWatchdog(String distributionId, String servideUUID, Optional<String> distributionNotification,
- String consumerId) {
- WatchdogServiceModVerIdLookup modVerIdLookup = new WatchdogServiceModVerIdLookup(distributionId, servideUUID,
- distributionNotification, consumerId);
- watchdogModVerIdLookupRepository.saveAndFlush(modVerIdLookup);
-
- try {
-
- WatchdogDistributionStatus distributionStatus = new WatchdogDistributionStatus(distributionId);
- watchdogDistributionStatusRepository.saveAndFlush(distributionStatus);
-
- } catch (ObjectOptimisticLockingFailureException e) {
- logger.debug("ObjectOptimisticLockingFailureException in processWatchdog : " + e.toString());
- throw e;
- }
- }
-
- protected void extractHeatInformation(ToscaResourceStructure toscaResourceStruct,
- VfResourceStructure vfResourceStructure) {
- for (VfModuleArtifact vfModuleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
-
- switch (vfModuleArtifact.getArtifactInfo().getArtifactType()) {
- case ASDCConfiguration.HEAT:
- case ASDCConfiguration.HEAT_NESTED:
- createHeatTemplateFromArtifact(vfResourceStructure, toscaResourceStruct,
- vfModuleArtifact);
- break;
- case ASDCConfiguration.HEAT_VOL:
- createHeatTemplateFromArtifact(vfResourceStructure, toscaResourceStruct,
- vfModuleArtifact);
- VfModuleArtifact envModuleArtifact = getHeatEnvArtifactFromGeneratedArtifact(vfResourceStructure,
- vfModuleArtifact);
- createHeatEnvFromArtifact(vfResourceStructure, envModuleArtifact);
- break;
- case ASDCConfiguration.HEAT_ENV:
- createHeatEnvFromArtifact(vfResourceStructure, vfModuleArtifact);
- break;
- case ASDCConfiguration.HEAT_ARTIFACT:
- createHeatFileFromArtifact(vfResourceStructure, vfModuleArtifact,
- toscaResourceStruct);
- break;
- case ASDCConfiguration.HEAT_NET:
- case ASDCConfiguration.OTHER:
- logger.warn("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_TYPE_NOT_SUPPORT.toString(),
- vfModuleArtifact.getArtifactInfo().getArtifactType() + "(Artifact Name:" + vfModuleArtifact
- .getArtifactInfo()
- .getArtifactName() + ")", ErrorCode.DataError.getValue(),
- "Artifact type not supported");
- break;
- default:
- break;
-
- }
- }
- }
-
- protected VfModuleArtifact getHeatEnvArtifactFromGeneratedArtifact(VfResourceStructure vfResourceStructure,
- VfModuleArtifact vfModuleArtifact) {
- String artifactName = vfModuleArtifact.getArtifactInfo().getArtifactName();
- artifactName = artifactName.substring(0, artifactName.indexOf('.'));
- for (VfModuleArtifact moduleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
- if (moduleArtifact.getArtifactInfo().getArtifactName().contains(artifactName)
- && moduleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ENV)) {
- return moduleArtifact;
- }
- }
- return null;
- }
-
- public String verifyTheFilePrefixInArtifacts(String filebody, VfResourceStructure vfResourceStructure,
- List<String> listTypes) {
- String newFileBody = filebody;
- for (VfModuleArtifact moduleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
-
- if (listTypes.contains(moduleArtifact.getArtifactInfo().getArtifactType())) {
-
- newFileBody = verifyTheFilePrefixInString(newFileBody,
- moduleArtifact.getArtifactInfo().getArtifactName());
- }
- }
- return newFileBody;
- }
-
- public String verifyTheFilePrefixInString(final String body, final String filenameToVerify) {
-
- String needlePrefix = "file:///";
- String prefixedFilenameToVerify = needlePrefix + filenameToVerify;
-
- if ((body == null) || (body.length() == 0) || (filenameToVerify == null) || (filenameToVerify.length() == 0)) {
- return body;
- }
-
- StringBuilder sb = new StringBuilder(body.length());
-
- int currentIndex = 0;
- int startIndex = 0;
-
- while (currentIndex != -1) {
- startIndex = currentIndex;
- currentIndex = body.indexOf(prefixedFilenameToVerify, startIndex);
-
- if (currentIndex == -1) {
- break;
- }
- // We append from the startIndex up to currentIndex (start of File
- // Name)
- sb.append(body.substring(startIndex, currentIndex));
- sb.append(filenameToVerify);
-
- currentIndex += prefixedFilenameToVerify.length();
- }
-
- sb.append(body.substring(startIndex));
-
- return sb.toString();
- }
-
- protected void createHeatTemplateFromArtifact(VfResourceStructure vfResourceStructure,
- ToscaResourceStructure toscaResourceStruct, VfModuleArtifact vfModuleArtifact) {
- HeatTemplate heatTemplate = new HeatTemplate();
- List<String> typeList = new ArrayList<>();
- typeList.add(ASDCConfiguration.HEAT_NESTED);
- typeList.add(ASDCConfiguration.HEAT_ARTIFACT);
-
- heatTemplate.setTemplateBody(
- verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(), vfResourceStructure, typeList));
- heatTemplate.setTemplateName(vfModuleArtifact.getArtifactInfo().getArtifactName());
-
- if (vfModuleArtifact.getArtifactInfo().getArtifactTimeout() != null) {
- heatTemplate.setTimeoutMinutes(vfModuleArtifact.getArtifactInfo().getArtifactTimeout());
- } else {
- heatTemplate.setTimeoutMinutes(240);
- }
-
- heatTemplate.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
- heatTemplate.setVersion(BigDecimalVersion
- .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
- heatTemplate.setArtifactUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
-
- if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) {
- heatTemplate.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
- } else {
- heatTemplate.setArtifactChecksum(MANUAL_RECORD);
- }
-
- Set<HeatTemplateParam> heatParam = extractHeatTemplateParameters(
- vfModuleArtifact.getResult(), vfModuleArtifact.getArtifactInfo().getArtifactUUID());
- heatTemplate.setParameters(heatParam);
- vfModuleArtifact.setHeatTemplate(heatTemplate);
- }
-
- protected void createHeatEnvFromArtifact(VfResourceStructure vfResourceStructure,
- VfModuleArtifact vfModuleArtifact) {
- HeatEnvironment heatEnvironment = new HeatEnvironment();
- heatEnvironment.setName(vfModuleArtifact.getArtifactInfo().getArtifactName());
- List<String> typeList = new ArrayList<>();
- typeList.add(ASDCConfiguration.HEAT);
- typeList.add(ASDCConfiguration.HEAT_VOL);
- heatEnvironment.setEnvironment(
- verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(), vfResourceStructure, typeList));
- heatEnvironment.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
- heatEnvironment.setVersion(BigDecimalVersion
- .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
- heatEnvironment.setArtifactUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
-
- if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) {
- heatEnvironment.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
- } else {
- heatEnvironment.setArtifactChecksum(MANUAL_RECORD);
- }
- vfModuleArtifact.setHeatEnvironment(heatEnvironment);
- }
-
- protected void createHeatFileFromArtifact(VfResourceStructure vfResourceStructure,
- VfModuleArtifact vfModuleArtifact, ToscaResourceStructure toscaResourceStruct) {
-
- HeatFiles heatFile = new HeatFiles();
- heatFile.setAsdcUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
- heatFile.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
- heatFile.setFileBody(vfModuleArtifact.getResult());
- heatFile.setFileName(vfModuleArtifact.getArtifactInfo().getArtifactName());
- heatFile.setVersion(BigDecimalVersion
- .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
- toscaResourceStruct.setHeatFilesUUID(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
- if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) {
- heatFile.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
- } else {
- heatFile.setArtifactChecksum(MANUAL_RECORD);
- }
- vfModuleArtifact.setHeatFiles(heatFile);
- }
-
- protected Service createService(ToscaResourceStructure toscaResourceStructure,
- ResourceStructure resourceStructure) {
-
- Metadata serviceMetadata = toscaResourceStructure.getServiceMetadata();
-
- Service service = new Service();
-
- if (serviceMetadata != null) {
-
- if (toscaResourceStructure.getServiceVersion() != null) {
- service.setModelVersion(toscaResourceStructure.getServiceVersion());
- }
-
- service.setServiceType(serviceMetadata.getValue("serviceType"));
- service.setServiceRole(serviceMetadata.getValue("serviceRole"));
- service.setCategory(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY));
- service.setDescription(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
- service.setModelName(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
- service.setModelUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
- service.setEnvironmentContext(serviceMetadata.getValue("environmentContext"));
-
- if (resourceStructure != null) {
- service.setWorkloadContext(resourceStructure.getNotification().getWorkloadContext());
- }
-
- service.setModelInvariantUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
- service.setCsar(toscaResourceStructure.getCatalogToscaCsar());
- }
-
- toscaResourceStructure.setCatalogService(service);
- return service;
- }
-
- protected ServiceProxyResourceCustomization createServiceProxy(NodeTemplate nodeTemplate, Service service,
- ToscaResourceStructure toscaResourceStructure) {
-
- Metadata spMetadata = nodeTemplate.getMetaData();
-
- ServiceProxyResourceCustomization spCustomizationResource = new ServiceProxyResourceCustomization();
-
- Set<ServiceProxyResourceCustomization> serviceProxyCustomizationSet = new HashSet<>();
-
- spCustomizationResource.setModelName(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
- spCustomizationResource
- .setModelInvariantUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
- spCustomizationResource.setModelUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
- spCustomizationResource.setModelVersion(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
- spCustomizationResource.setDescription(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
-
- spCustomizationResource
- .setModelCustomizationUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
- spCustomizationResource.setModelInstanceName(nodeTemplate.getName());
- spCustomizationResource.setToscaNodeType(nodeTemplate.getType());
-
- String sourceServiceUUID = spMetadata.getValue("sourceModelUuid");
-
- Service sourceService = serviceRepo.findOneByModelUUID(sourceServiceUUID);
-
- spCustomizationResource.setSourceService(sourceService);
- spCustomizationResource.setToscaNodeType(nodeTemplate.getType());
- serviceProxyCustomizationSet.add(spCustomizationResource);
-
- toscaResourceStructure.setCatalogServiceProxyResourceCustomization(spCustomizationResource);
-
- return spCustomizationResource;
- }
-
- protected ConfigurationResourceCustomization createConfiguration(NodeTemplate nodeTemplate,
- ToscaResourceStructure toscaResourceStructure, ServiceProxyResourceCustomization spResourceCustomization,
- Optional<ConfigurationResourceCustomization> vnrResourceCustomization) {
-
- ConfigurationResourceCustomization configCustomizationResource = getConfigurationResourceCustomization(
- nodeTemplate,
- toscaResourceStructure, spResourceCustomization);
-
- ConfigurationResource configResource = getConfigurationResource(nodeTemplate);
-
- Set<ConfigurationResourceCustomization> configResourceCustomizationSet = new HashSet<>();
-
- StatefulEntityType entityType = nodeTemplate.getTypeDefinition();
- String type = entityType.getType();
-
- if (NODES_VRF_ENTRY.equals(type)) {
- configCustomizationResource.setConfigResourceCustomization(vnrResourceCustomization.orElse(null));
- }
-
- configCustomizationResource.setConfigurationResource(configResource);
-
- configResourceCustomizationSet.add(configCustomizationResource);
-
- configResource.setConfigurationResourceCustomization(configResourceCustomizationSet);
-
- toscaResourceStructure.setCatalogConfigurationResource(configResource);
-
- toscaResourceStructure.setCatalogConfigurationResourceCustomization(configCustomizationResource);
-
- return configCustomizationResource;
- }
-
- protected ConfigurationResource createFabricConfiguration(NodeTemplate nodeTemplate,
- ToscaResourceStructure toscaResourceStructure) {
-
- Metadata fabricMetadata = nodeTemplate.getMetaData();
-
- ConfigurationResource configResource = new ConfigurationResource();
-
- configResource.setModelName(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
- configResource.setModelInvariantUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
- configResource.setModelUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
- configResource.setModelVersion(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
- configResource.setDescription(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
- configResource.setToscaNodeType(nodeTemplate.getType());
-
- return configResource;
- }
-
- protected void createToscaCsar(ToscaResourceStructure toscaResourceStructure) {
- ToscaCsar toscaCsar = new ToscaCsar();
- if (toscaResourceStructure.getToscaArtifact().getArtifactChecksum() != null) {
- toscaCsar.setArtifactChecksum(toscaResourceStructure.getToscaArtifact().getArtifactChecksum());
- } else {
- toscaCsar.setArtifactChecksum(MANUAL_RECORD);
- }
- toscaCsar.setArtifactUUID(toscaResourceStructure.getToscaArtifact().getArtifactUUID());
- toscaCsar.setName(toscaResourceStructure.getToscaArtifact().getArtifactName());
- toscaCsar.setVersion(toscaResourceStructure.getToscaArtifact().getArtifactVersion());
- toscaCsar.setDescription(toscaResourceStructure.getToscaArtifact().getArtifactDescription());
- toscaCsar.setUrl(toscaResourceStructure.getToscaArtifact().getArtifactURL());
-
- toscaResourceStructure.setCatalogToscaCsar(toscaCsar);
- }
-
- protected VnfcCustomization findExistingVfc(Set<VnfcCustomization> vnfcCustomizations, String customizationUUID) {
- VnfcCustomization vnfcCustomization = null;
- for (VnfcCustomization vnfcCustom : vnfcCustomizations) {
- if (vnfcCustom != null && vnfcCustom.getModelCustomizationUUID().equals(customizationUUID)) {
- vnfcCustomization = vnfcCustom;
- }
- }
-
- if (vnfcCustomization == null) {
- vnfcCustomization = vnfcCustomizationRepo.findOneByModelCustomizationUUID(customizationUUID);
- }
-
- return vnfcCustomization;
- }
-
- protected CvnfcCustomization findExistingCvfc(Set<CvnfcCustomization> cvnfcCustomizations,
- String customizationUUID) {
- CvnfcCustomization cvnfcCustomization = null;
- for (CvnfcCustomization cvnfcCustom : cvnfcCustomizations) {
- if (cvnfcCustom != null && cvnfcCustom.getModelCustomizationUUID().equals(customizationUUID)) {
- cvnfcCustomization = cvnfcCustom;
- }
- }
-
- if (cvnfcCustomization == null) {
- cvnfcCustomization = cvnfcCustomizationRepo.findOneByModelCustomizationUUID(customizationUUID);
- }
-
- return cvnfcCustomization;
- }
-
- protected NetworkResourceCustomization createNetwork(NodeTemplate networkNodeTemplate,
- ToscaResourceStructure toscaResourceStructure, HeatTemplate heatTemplate, String aicMax, String aicMin,
- Service service) {
-
- NetworkResourceCustomization networkResourceCustomization = networkCustomizationRepo
- .findOneByModelCustomizationUUID(
- networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
-
- boolean networkUUIDsMatch = true;
- // Check to make sure the NetworkResourceUUID on the Customization record matches the NetworkResourceUUID from the distribution.
- // If not we'll update the Customization record with latest from the distribution
- if (networkResourceCustomization != null) {
- String existingNetworkModelUUID = networkResourceCustomization.getNetworkResource().getModelUUID();
- String latestNetworkModelUUID = networkNodeTemplate.getMetaData()
- .getValue(SdcPropertyNames.PROPERTY_NAME_UUID);
-
- if (!existingNetworkModelUUID.equals(latestNetworkModelUUID)) {
- networkUUIDsMatch = false;
- }
-
- }
-
- if (networkResourceCustomization != null && !networkUUIDsMatch) {
-
- NetworkResource networkResource = createNetworkResource(networkNodeTemplate, toscaResourceStructure,
- heatTemplate,
- aicMax, aicMin);
-
- networkResourceCustomization.setNetworkResource(networkResource);
-
- networkCustomizationRepo.saveAndFlush(networkResourceCustomization);
-
- } else if (networkResourceCustomization == null) {
- networkResourceCustomization = createNetworkResourceCustomization(networkNodeTemplate,
- toscaResourceStructure);
-
- NetworkResource networkResource = findExistingNetworkResource(service,
- networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
- if (networkResource == null) {
- networkResource = createNetworkResource(networkNodeTemplate, toscaResourceStructure, heatTemplate,
- aicMax, aicMin);
- }
-
- networkResource.addNetworkResourceCustomization(networkResourceCustomization);
- networkResourceCustomization.setNetworkResource(networkResource);
- }
-
- return networkResourceCustomization;
- }
-
- protected NetworkResource findExistingNetworkResource(Service service, String modelUUID) {
- NetworkResource networkResource = null;
- for (NetworkResourceCustomization networkCustom : service.getNetworkCustomizations()) {
- if (networkCustom.getNetworkResource() != null
- && networkCustom.getNetworkResource().getModelUUID().equals(modelUUID)) {
- networkResource = networkCustom.getNetworkResource();
- }
- }
- if (networkResource == null) {
- networkResource = networkRepo.findResourceByModelUUID(modelUUID);
- }
-
- return networkResource;
- }
-
- protected NetworkResourceCustomization createNetworkResourceCustomization(NodeTemplate networkNodeTemplate,
- ToscaResourceStructure toscaResourceStructure) {
- NetworkResourceCustomization networkResourceCustomization = new NetworkResourceCustomization();
- networkResourceCustomization.setModelInstanceName(
- testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
- networkResourceCustomization.setModelCustomizationUUID(
- testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
-
- networkResourceCustomization.setNetworkTechnology(
- testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
- SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY)));
- networkResourceCustomization.setNetworkType(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE)));
- networkResourceCustomization.setNetworkRole(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKROLE)));
- networkResourceCustomization.setNetworkScope(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE)));
- return networkResourceCustomization;
- }
-
- protected NetworkResource createNetworkResource(NodeTemplate networkNodeTemplate,
- ToscaResourceStructure toscaResourceStructure, HeatTemplate heatTemplate, String aicMax, String aicMin) {
- NetworkResource networkResource = new NetworkResource();
- String providerNetwork = toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(
- networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_ISPROVIDERNETWORK);
-
- if ("true".equalsIgnoreCase(providerNetwork)) {
- networkResource.setNeutronNetworkType(PROVIDER);
- } else {
- networkResource.setNeutronNetworkType(BASIC);
- }
-
- networkResource.setModelName(
- testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
-
- networkResource.setModelInvariantUUID(
- testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
- networkResource.setModelUUID(
- testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
- networkResource.setModelVersion(
- testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
-
- networkResource.setAicVersionMax(aicMax);
- networkResource.setAicVersionMin(aicMin);
- networkResource.setToscaNodeType(networkNodeTemplate.getType());
- networkResource.setDescription(
- testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
- networkResource.setOrchestrationMode(HEAT);
- networkResource.setHeatTemplate(heatTemplate);
- return networkResource;
- }
-
- protected CollectionNetworkResourceCustomization createNetworkCollection(NodeTemplate networkNodeTemplate,
- ToscaResourceStructure toscaResourceStructure, Service service) {
-
- CollectionNetworkResourceCustomization collectionNetworkResourceCustomization = new CollectionNetworkResourceCustomization();
-
- // **** Build Object to populate Collection_Resource table
- CollectionResource collectionResource = new CollectionResource();
-
- collectionResource
- .setModelName(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
- collectionResource.setModelInvariantUUID(
- networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
- collectionResource
- .setModelUUID(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
- collectionResource
- .setModelVersion(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
- collectionResource
- .setDescription(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
- collectionResource.setToscaNodeType(networkNodeTemplate.getType());
-
- toscaResourceStructure.setCatalogCollectionResource(collectionResource);
-
- // **** Build object to populate Collection_Resource_Customization table
- NetworkCollectionResourceCustomization ncfc = new NetworkCollectionResourceCustomization();
-
- ncfc.setFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
- "cr_function"));
- ncfc.setRole(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
- "cr_role"));
- ncfc.setType(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
- "cr_type"));
-
- ncfc.setModelInstanceName(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
- ncfc.setModelCustomizationUUID(
- networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
-
- Set<CollectionNetworkResourceCustomization> networkResourceCustomizationSet = new HashSet<>();
- networkResourceCustomizationSet.add(collectionNetworkResourceCustomization);
-
- ncfc.setNetworkResourceCustomization(networkResourceCustomizationSet);
-
- ncfc.setCollectionResource(collectionResource);
- toscaResourceStructure.setCatalogCollectionResourceCustomization(ncfc);
-
- //*** Build object to populate the Instance_Group table
- List<Group> groupList = toscaResourceStructure.getSdcCsarHelper()
- .getGroupsOfOriginOfNodeTemplateByToscaGroupType(networkNodeTemplate,
- "org.openecomp.groups.NetworkCollection");
-
- List<NetworkInstanceGroup> networkInstanceGroupList = new ArrayList<>();
-
- List<CollectionResourceInstanceGroupCustomization> collectionResourceInstanceGroupCustomizationList = new ArrayList<CollectionResourceInstanceGroupCustomization>();
-
- for (Group group : groupList) {
-
- NetworkInstanceGroup networkInstanceGroup = new NetworkInstanceGroup();
- Metadata instanceMetadata = group.getMetadata();
- networkInstanceGroup.setModelName(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
- networkInstanceGroup
- .setModelInvariantUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
- networkInstanceGroup.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
- networkInstanceGroup.setModelVersion(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
- networkInstanceGroup.setToscaNodeType(group.getType());
- networkInstanceGroup.setRole(SubType.SUB_INTERFACE.toString()); // Set
- // Role
- networkInstanceGroup.setType(InstanceGroupType.L3_NETWORK); // Set
- // type
- networkInstanceGroup.setCollectionResource(collectionResource);
-
- // ****Build object to populate
- // Collection_Resource_Instance_Group_Customization table
- CollectionResourceInstanceGroupCustomization crInstanceGroupCustomization = new CollectionResourceInstanceGroupCustomization();
- crInstanceGroupCustomization.setInstanceGroup(networkInstanceGroup);
- crInstanceGroupCustomization.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
- crInstanceGroupCustomization.setModelCustomizationUUID(
- networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
-
- // Loop through the template policy to find the subinterface_network_quantity property name. Then extract the value for it.
- List<Policy> policyList = toscaResourceStructure.getSdcCsarHelper()
- .getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(networkNodeTemplate,
- "org.openecomp.policies.scaling.Fixed");
-
- if (policyList != null) {
- for (Policy policy : policyList) {
- for (String policyNetworkCollection : policy.getTargets()) {
-
- if (policyNetworkCollection.equalsIgnoreCase(group.getName())) {
-
- Map<String, Object> propMap = policy.getPolicyProperties();
-
- if (propMap.get("quantity") != null) {
-
- String quantity = toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(networkNodeTemplate,
- getPropertyInput(propMap.get("quantity").toString()));
-
- if (quantity != null) {
- crInstanceGroupCustomization
- .setSubInterfaceNetworkQuantity(Integer.parseInt(quantity));
- }
-
- }
-
- }
- }
- }
- }
-
- crInstanceGroupCustomization.setDescription(
- toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
- instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)
- + "_network_collection_description"));
- crInstanceGroupCustomization.setFunction(
- toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
- instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)
- + "_network_collection_function"));
- crInstanceGroupCustomization.setCollectionResourceCust(ncfc);
- collectionResourceInstanceGroupCustomizationList.add(crInstanceGroupCustomization);
-
- networkInstanceGroup
- .setCollectionInstanceGroupCustomizations(collectionResourceInstanceGroupCustomizationList);
-
- networkInstanceGroupList.add(networkInstanceGroup);
-
- toscaResourceStructure.setCatalogNetworkInstanceGroup(networkInstanceGroupList);
-
- List<NodeTemplate> vlNodeList = toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplateBySdcType(networkNodeTemplate, SdcTypes.VL);
-
- List<CollectionNetworkResourceCustomization> collectionNetworkResourceCustomizationList = new ArrayList<>();
-
- //*****Build object to populate the NetworkResource table
- NetworkResource networkResource = new NetworkResource();
-
- for (NodeTemplate vlNodeTemplate : vlNodeList) {
-
- String providerNetwork = toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(
- vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_ISPROVIDERNETWORK);
-
- if ("true".equalsIgnoreCase(providerNetwork)) {
- networkResource.setNeutronNetworkType(PROVIDER);
- } else {
- networkResource.setNeutronNetworkType(BASIC);
- }
-
- networkResource
- .setModelName(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
-
- networkResource.setModelInvariantUUID(
- vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
- networkResource
- .setModelUUID(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
- networkResource
- .setModelVersion(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
-
- networkResource.setAicVersionMax(
- vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES));
-
- TempNetworkHeatTemplateLookup tempNetworkLookUp = tempNetworkLookupRepo
- .findFirstBynetworkResourceModelName(
- vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
-
- if (tempNetworkLookUp != null) {
-
- HeatTemplate heatTemplate = heatRepo
- .findByArtifactUuid(tempNetworkLookUp.getHeatTemplateArtifactUuid());
- networkResource.setHeatTemplate(heatTemplate);
-
- networkResource.setAicVersionMin(tempNetworkLookUp.getAicVersionMin());
-
- }
-
- networkResource.setToscaNodeType(vlNodeTemplate.getType());
- networkResource
- .setDescription(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
- networkResource.setOrchestrationMode(HEAT);
-
- // Build object to populate the
- // Collection_Network_Resource_Customization table
- for (NodeTemplate memberNode : group.getMemberNodes()) {
- collectionNetworkResourceCustomization.setModelInstanceName(memberNode.getName());
- }
-
- collectionNetworkResourceCustomization.setModelCustomizationUUID(
- vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
-
- collectionNetworkResourceCustomization.setNetworkTechnology(
- toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vlNodeTemplate,
- SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY));
- collectionNetworkResourceCustomization.setNetworkType(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE));
- collectionNetworkResourceCustomization.setNetworkRole(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKROLE));
- collectionNetworkResourceCustomization.setNetworkScope(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE));
- collectionNetworkResourceCustomization.setInstanceGroup(networkInstanceGroup);
- collectionNetworkResourceCustomization.setNetworkResource(networkResource);
- collectionNetworkResourceCustomization.setNetworkResourceCustomization(ncfc);
-
- collectionNetworkResourceCustomizationList.add(collectionNetworkResourceCustomization);
- }
-
- }
-
- return collectionNetworkResourceCustomization;
- }
-
- protected VnfcInstanceGroupCustomization createVNFCInstanceGroup(NodeTemplate vnfcNodeTemplate, Group group,
- VnfResourceCustomization vnfResourceCustomization, ToscaResourceStructure toscaResourceStructure) {
-
- Metadata instanceMetadata = group.getMetadata();
- // Populate InstanceGroup
- VFCInstanceGroup vfcInstanceGroup = new VFCInstanceGroup();
-
- vfcInstanceGroup.setModelName(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
- vfcInstanceGroup.setModelInvariantUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
- vfcInstanceGroup.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
- vfcInstanceGroup.setModelVersion(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
- vfcInstanceGroup.setToscaNodeType(group.getType());
- vfcInstanceGroup.setRole("SUB-INTERFACE"); // Set Role
- vfcInstanceGroup.setType(InstanceGroupType.VNFC); // Set type
-
- //Populate VNFCInstanceGroupCustomization
- VnfcInstanceGroupCustomization vfcInstanceGroupCustom = new VnfcInstanceGroupCustomization();
-
- vfcInstanceGroupCustom.setModelCustomizationUUID(vnfResourceCustomization.getModelCustomizationUUID());
- vfcInstanceGroupCustom.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
- vfcInstanceGroupCustom.setDescription(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
-
- String getInputName = null;
- String groupProperty = toscaResourceStructure.getSdcCsarHelper()
- .getGroupPropertyLeafValue(group, "vfc_instance_group_function");
- if (groupProperty != null) {
- int getInputIndex = groupProperty.indexOf("{get_input=");
- if (getInputIndex > -1) {
- getInputName = groupProperty.substring(getInputIndex + 11, groupProperty.length() - 1);
- }
- }
- vfcInstanceGroupCustom.setFunction(
- toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vnfcNodeTemplate, getInputName));
-
- vfcInstanceGroupCustom.setInstanceGroup(vfcInstanceGroup);
- vfcInstanceGroupCustom.setVnfResourceCust(vnfResourceCustomization);
-
- return vfcInstanceGroupCustom;
-
- }
-
- protected VfModuleCustomization createVFModuleResource(Group group, NodeTemplate vfTemplate,
- ToscaResourceStructure toscaResourceStructure, VfResourceStructure vfResourceStructure,
- IVfModuleData vfModuleData, VnfResourceCustomization vnfResource, Service service,
- Set<CvnfcCustomization> existingCvnfcSet, Set<VnfcCustomization> existingVnfcSet) {
-
- VfModuleCustomization vfModuleCustomization = findExistingVfModuleCustomization(vnfResource,
- vfModuleData.getVfModuleModelCustomizationUUID());
- if (vfModuleCustomization == null) {
- VfModule vfModule = findExistingVfModule(vnfResource,
- vfTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID));
- Metadata vfMetadata = group.getMetadata();
- if (vfModule == null) {
- vfModule = createVfModule(group, toscaResourceStructure, vfModuleData, vfMetadata);
- }
-
- vfModuleCustomization = createVfModuleCustomization(group, toscaResourceStructure, vfModule, vfModuleData);
- setHeatInformationForVfModule(toscaResourceStructure, vfResourceStructure, vfModule, vfModuleCustomization,
- vfMetadata);
- vfModuleCustomization.setVfModule(vfModule);
- vfModule.getVfModuleCustomization().add(vfModuleCustomization);
- vnfResource.getVfModuleCustomizations().add(vfModuleCustomization);
- } else {
- vfResourceStructure.setAlreadyDeployed(true);
- }
-
- //******************************************************************************************************************
- //* Extract VFC's and CVFC's then add them to VFModule
- //******************************************************************************************************************
-
- Set<VnfVfmoduleCvnfcConfigurationCustomization> vnfVfmoduleCvnfcConfigurationCustomizations = new HashSet<VnfVfmoduleCvnfcConfigurationCustomization>();
- Set<CvnfcCustomization> cvnfcCustomizations = new HashSet<CvnfcCustomization>();
- Set<VnfcCustomization> vnfcCustomizations = new HashSet<VnfcCustomization>();
-
- // Only set the CVNFC if this vfModule group is a member of it.
- List<NodeTemplate> groupMembers = toscaResourceStructure.getSdcCsarHelper()
- .getMembersOfVfModule(vfTemplate, group);
- String vfModuleMemberName = null;
-
- for (NodeTemplate node : groupMembers) {
- vfModuleMemberName = node.getName();
- }
-
- // Extract CVFC lists
- List<NodeTemplate> cvfcList = toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplateBySdcType(vfTemplate, SdcTypes.CVFC);
-
- for (NodeTemplate cvfcTemplate : cvfcList) {
-
- CvnfcCustomization existingCvnfcCustomization = findExistingCvfc(existingCvnfcSet,
- cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
-
- if (vfModuleMemberName != null && vfModuleMemberName.equalsIgnoreCase(cvfcTemplate.getName())) {
-
- //Extract associated VFC - Should always be just one
- List<NodeTemplate> vfcList = toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplateBySdcType(cvfcTemplate, SdcTypes.VFC);
-
- for (NodeTemplate vfcTemplate : vfcList) {
-
- VnfcCustomization vnfcCustomization = new VnfcCustomization();
- VnfcCustomization existingVnfcCustomization = null;
-
- existingVnfcCustomization = findExistingVfc(existingVnfcSet,
- vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
-
- if (existingVnfcCustomization == null) {
- vnfcCustomization = new VnfcCustomization();
- } else {
- vnfcCustomization = existingVnfcCustomization;
- }
-
- // Only Add Abstract VNFC's to our DB, ignore all others
- if (existingVnfcCustomization == null && vfcTemplate.getMetaData()
- .getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY).equalsIgnoreCase("Abstract")) {
- vnfcCustomization.setModelCustomizationUUID(
- vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
- vnfcCustomization.setModelInstanceName(vfcTemplate.getName());
- vnfcCustomization.setModelInvariantUUID(
- vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
- vnfcCustomization
- .setModelName(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
- vnfcCustomization
- .setModelUUID(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
-
- vnfcCustomization.setModelVersion(
- testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
- vnfcCustomization.setDescription(
- testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
- vnfcCustomization.setToscaNodeType(testNull(vfcTemplate.getType()));
-
- vnfcCustomizations.add(vnfcCustomization);
- existingVnfcSet.add(vnfcCustomization);
- }
-
- // This check is needed incase the VFC subcategory is something other than Abstract. In that case we want to skip adding that record to our DB.
- if (vnfcCustomization.getModelCustomizationUUID() != null) {
-
- CvnfcCustomization cvnfcCustomization = null;
-
- if (existingCvnfcCustomization != null) {
- cvnfcCustomization = existingCvnfcCustomization;
- } else {
-
- cvnfcCustomization = new CvnfcCustomization();
- cvnfcCustomization.setModelCustomizationUUID(
- cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
- cvnfcCustomization.setModelInstanceName(cvfcTemplate.getName());
- cvnfcCustomization.setModelInvariantUUID(
- cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
- cvnfcCustomization
- .setModelName(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
- cvnfcCustomization
- .setModelUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
-
- cvnfcCustomization.setModelVersion(
- testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
- cvnfcCustomization.setDescription(
- testNull(
- cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
- cvnfcCustomization.setToscaNodeType(testNull(cvfcTemplate.getType()));
-
- if (existingVnfcCustomization != null) {
- cvnfcCustomization.setVnfcCustomization(existingVnfcCustomization);
- } else {
- cvnfcCustomization.setVnfcCustomization(vnfcCustomization);
- }
-
- cvnfcCustomization.setNfcFunction(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(cvfcTemplate, "nfc_function"));
- cvnfcCustomization.setNfcNamingCode(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(cvfcTemplate, "nfc_naming_code"));
- cvnfcCustomization.setVfModuleCustomization(vfModuleCustomization);
- cvnfcCustomization.setVnfResourceCustomization(vnfResource);
-
- cvnfcCustomizations.add(cvnfcCustomization);
- existingCvnfcSet.add(cvnfcCustomization);
- }
-
- //*****************************************************************************************************************************************
- //* Extract Fabric Configuration
- //*****************************************************************************************************************************************
-
- List<NodeTemplate> fabricConfigList = toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplateBySdcType(vfTemplate, SdcTypes.CONFIGURATION);
-
- for (NodeTemplate fabricTemplate : fabricConfigList) {
-
- ConfigurationResource fabricConfig = null;
-
- ConfigurationResource existingConfig = findExistingConfiguration(service,
- fabricTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
-
- if (existingConfig == null) {
-
- fabricConfig = createFabricConfiguration(fabricTemplate, toscaResourceStructure);
-
- } else {
- fabricConfig = existingConfig;
- }
-
- VnfVfmoduleCvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization = createVfCnvfConfigCustomization(
- fabricTemplate, toscaResourceStructure,
- vnfResource, vfModuleCustomization, cvnfcCustomization, fabricConfig, vfTemplate,
- vfModuleMemberName);
-
- vnfVfmoduleCvnfcConfigurationCustomizations.add(vnfVfmoduleCvnfcConfigurationCustomization);
- }
-
- }
-
- }
-
- }
-
- }
-
- vfModuleCustomization.setCvnfcCustomization(cvnfcCustomizations);
- vfModuleCustomization
- .setVnfVfmoduleCvnfcConfigurationCustomization(vnfVfmoduleCvnfcConfigurationCustomizations);
-
- return vfModuleCustomization;
- }
-
- protected VnfVfmoduleCvnfcConfigurationCustomization createVfCnvfConfigCustomization(NodeTemplate fabricTemplate,
- ToscaResourceStructure toscaResourceStruct,
- VnfResourceCustomization vnfResource, VfModuleCustomization vfModuleCustomization,
- CvnfcCustomization cvnfcCustomization,
- ConfigurationResource configResource, NodeTemplate vfTemplate, String vfModuleMemberName) {
-
- Metadata fabricMetadata = fabricTemplate.getMetaData();
-
- VnfVfmoduleCvnfcConfigurationCustomization vfModuleToCvnfc = new VnfVfmoduleCvnfcConfigurationCustomization();
-
- vfModuleToCvnfc.setConfigurationResource(configResource);
- vfModuleToCvnfc.setCvnfcCustomization(cvnfcCustomization);
- vfModuleToCvnfc
- .setModelCustomizationUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
- vfModuleToCvnfc.setModelInstanceName(fabricTemplate.getName());
- vfModuleToCvnfc.setVfModuleCustomization(vfModuleCustomization);
- vfModuleToCvnfc.setVnfResourceCustomization(vnfResource);
-
- List<Policy> policyList = toscaResourceStruct.getSdcCsarHelper()
- .getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(vfTemplate, "org.openecomp.policies.External");
-
- if (policyList != null) {
- for (Policy policy : policyList) {
-
- for (String policyCvfcTarget : policy.getTargets()) {
-
- if (policyCvfcTarget.equalsIgnoreCase(vfModuleMemberName)) {
-
- Map<String, Object> propMap = policy.getPolicyProperties();
-
- if (propMap.get("type").toString().equalsIgnoreCase("Fabric Policy")) {
- vfModuleToCvnfc.setPolicyName(propMap.get("name").toString());
- }
- }
- }
- }
- }
-
- vfModuleToCvnfc.setConfigurationFunction(
- toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "function"));
- vfModuleToCvnfc.setConfigurationRole(
- toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "role"));
- vfModuleToCvnfc.setConfigurationType(
- toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "type"));
-
- return vfModuleToCvnfc;
- }
-
- protected ConfigurationResource findExistingConfiguration(Service service, String modelUUID) {
- ConfigurationResource configResource = null;
- for (ConfigurationResourceCustomization configurationResourceCustom : service
- .getConfigurationCustomizations()) {
- if (configurationResourceCustom.getConfigurationResource() != null
- && configurationResourceCustom.getConfigurationResource().getModelUUID().equals(modelUUID)) {
- configResource = configurationResourceCustom.getConfigurationResource();
- }
- }
- if (configResource == null) {
- configResource = configRepo.findResourceByModelUUID(modelUUID);
- }
-
- return configResource;
- }
-
- protected VfModuleCustomization findExistingVfModuleCustomization(VnfResourceCustomization vnfResource,
- String vfModuleModelCustomizationUUID) {
- VfModuleCustomization vfModuleCustomization = null;
- for (VfModuleCustomization vfModuleCustom : vnfResource.getVfModuleCustomizations()) {
- if (vfModuleCustom.getModelCustomizationUUID().equalsIgnoreCase(vfModuleModelCustomizationUUID)) {
- vfModuleCustomization = vfModuleCustom;
- }
- }
- if (vfModuleCustomization == null) {
- vfModuleCustomization = vfModuleCustomizationRepo
- .findByModelCustomizationUUID(vfModuleModelCustomizationUUID);
- }
-
- return vfModuleCustomization;
- }
-
- protected VfModule findExistingVfModule(VnfResourceCustomization vnfResource, String modelUUID) {
- VfModule vfModule = null;
- for (VfModuleCustomization vfModuleCustom : vnfResource.getVfModuleCustomizations()) {
- if (vfModuleCustom.getVfModule() != null && vfModuleCustom.getVfModule().getModelUUID().equals(modelUUID)) {
- vfModule = vfModuleCustom.getVfModule();
- }
- }
- if (vfModule == null) {
- vfModule = vfModuleRepo.findByModelUUID(modelUUID);
- }
-
- return vfModule;
- }
-
- protected VfModuleCustomization createVfModuleCustomization(Group group,
- ToscaResourceStructure toscaResourceStructure, VfModule vfModule, IVfModuleData vfModuleData) {
- VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
-
- vfModuleCustomization.setModelCustomizationUUID(vfModuleData.getVfModuleModelCustomizationUUID());
-
- vfModuleCustomization.setVfModule(vfModule);
-
- String initialCount = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
- SdcPropertyNames.PROPERTY_NAME_INITIALCOUNT);
- if (initialCount != null && initialCount.length() > 0) {
- vfModuleCustomization.setInitialCount(Integer.valueOf(initialCount));
- }
-
- vfModuleCustomization.setInitialCount(Integer.valueOf(toscaResourceStructure.getSdcCsarHelper()
- .getGroupPropertyLeafValue(group, SdcPropertyNames.PROPERTY_NAME_INITIALCOUNT)));
-
- String availabilityZoneCount = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
- SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT);
- if (availabilityZoneCount != null && availabilityZoneCount.length() > 0) {
- vfModuleCustomization.setAvailabilityZoneCount(Integer.valueOf(availabilityZoneCount));
- }
-
- vfModuleCustomization.setLabel(toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
- SdcPropertyNames.PROPERTY_NAME_VFMODULELABEL));
-
- String maxInstances = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
- SdcPropertyNames.PROPERTY_NAME_MAXVFMODULEINSTANCES);
- if (maxInstances != null && maxInstances.length() > 0) {
- vfModuleCustomization.setMaxInstances(Integer.valueOf(maxInstances));
- }
-
- String minInstances = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
- SdcPropertyNames.PROPERTY_NAME_MINVFMODULEINSTANCES);
- if (minInstances != null && minInstances.length() > 0) {
- vfModuleCustomization.setMinInstances(Integer.valueOf(minInstances));
- }
- return vfModuleCustomization;
- }
-
- protected VfModule createVfModule(Group group, ToscaResourceStructure toscaResourceStructure,
- IVfModuleData vfModuleData, Metadata vfMetadata) {
- VfModule vfModule = new VfModule();
- String vfModuleModelUUID = vfModuleData.getVfModuleModelUUID();
-
- if (vfModuleModelUUID == null) {
- vfModuleModelUUID = testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
- SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID));
- } else if (vfModuleModelUUID.indexOf('.') > -1) {
- vfModuleModelUUID = vfModuleModelUUID.substring(0, vfModuleModelUUID.indexOf('.'));
- }
-
- vfModule.setModelInvariantUUID(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID)));
- vfModule.setModelName(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
- SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELNAME)));
- vfModule.setModelUUID(vfModuleModelUUID);
- vfModule.setModelVersion(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
- SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELVERSION)));
- vfModule.setDescription(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
- SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
-
- String vfModuleType = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
- SdcPropertyNames.PROPERTY_NAME_VFMODULETYPE);
- if (vfModuleType != null && "Base".equalsIgnoreCase(vfModuleType)) {
- vfModule.setIsBase(true);
- } else {
- vfModule.setIsBase(false);
- }
- return vfModule;
- }
-
- protected void setHeatInformationForVfModule(ToscaResourceStructure toscaResourceStructure,
- VfResourceStructure vfResourceStructure, VfModule vfModule, VfModuleCustomization vfModuleCustomization,
- Metadata vfMetadata) {
-
- Optional<VfModuleStructure> matchingObject = vfResourceStructure.getVfModuleStructure().stream()
- .filter(vfModuleStruct -> vfModuleStruct.getVfModuleMetadata().getVfModuleModelUUID()
- .equalsIgnoreCase(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
- SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID)))
- .findFirst();
-
- if (matchingObject.isPresent()) {
- List<HeatFiles> heatFilesList = new ArrayList<>();
- List<HeatTemplate> volumeHeatChildTemplates = new ArrayList<HeatTemplate>();
- List<HeatTemplate> heatChildTemplates = new ArrayList<HeatTemplate>();
- HeatTemplate parentHeatTemplate = new HeatTemplate();
- String parentArtifactType = null;
- Set<String> artifacts = new HashSet<>(matchingObject.get().getVfModuleMetadata().getArtifacts());
- for (VfModuleArtifact vfModuleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
-
- List<HeatTemplate> childNestedHeatTemplates = new ArrayList<HeatTemplate>();
-
- if (artifacts.contains(vfModuleArtifact.getArtifactInfo().getArtifactUUID())) {
- checkVfModuleArtifactType(vfModule, vfModuleCustomization, heatFilesList, vfModuleArtifact,
- childNestedHeatTemplates, parentHeatTemplate, vfResourceStructure);
- }
-
- if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_NESTED)) {
- parentArtifactType = identifyParentOfNestedTemplate(matchingObject.get(), vfModuleArtifact);
-
- if (!childNestedHeatTemplates.isEmpty()) {
-
- if (parentArtifactType != null && parentArtifactType
- .equalsIgnoreCase(ASDCConfiguration.HEAT_VOL)) {
- volumeHeatChildTemplates.add(childNestedHeatTemplates.get(0));
- } else {
- heatChildTemplates.add(childNestedHeatTemplates.get(0));
- }
- }
- }
-
- }
- if (!heatFilesList.isEmpty()) {
- vfModule.setHeatFiles(heatFilesList);
- }
-
- // Set all Child Templates related to HEAT_VOLUME
- if (!volumeHeatChildTemplates.isEmpty()) {
- if (vfModule.getVolumeHeatTemplate() != null) {
- vfModule.getVolumeHeatTemplate().setChildTemplates(volumeHeatChildTemplates);
- } else {
- logger.debug("VolumeHeatTemplate not set in setHeatInformationForVfModule()");
- }
- }
-
- // Set all Child Templates related to HEAT
- if (!heatChildTemplates.isEmpty()) {
- if (vfModule.getModuleHeatTemplate() != null) {
- vfModule.getModuleHeatTemplate().setChildTemplates(heatChildTemplates);
- } else {
- logger.debug("ModuleHeatTemplate not set in setHeatInformationForVfModule()");
- }
- }
- }
- }
-
- protected void checkVfModuleArtifactType(VfModule vfModule, VfModuleCustomization vfModuleCustomization,
- List<HeatFiles> heatFilesList, VfModuleArtifact vfModuleArtifact, List<HeatTemplate> nestedHeatTemplates,
- HeatTemplate parentHeatTemplate, VfResourceStructure vfResourceStructure) {
- if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT)) {
- vfModuleArtifact.incrementDeployedInDB();
- vfModule.setModuleHeatTemplate(vfModuleArtifact.getHeatTemplate());
- } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_VOL)) {
- vfModule.setVolumeHeatTemplate(vfModuleArtifact.getHeatTemplate());
- VfModuleArtifact volVfModuleArtifact = this
- .getHeatEnvArtifactFromGeneratedArtifact(vfResourceStructure, vfModuleArtifact);
- vfModuleCustomization.setVolumeHeatEnv(volVfModuleArtifact.getHeatEnvironment());
- vfModuleArtifact.incrementDeployedInDB();
- } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ENV)) {
- if (vfModuleArtifact.getHeatEnvironment().getName().contains("volume")) {
- vfModuleCustomization.setVolumeHeatEnv(vfModuleArtifact.getHeatEnvironment());
- } else {
- vfModuleCustomization.setHeatEnvironment(vfModuleArtifact.getHeatEnvironment());
- }
- vfModuleArtifact.incrementDeployedInDB();
- } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ARTIFACT)) {
- heatFilesList.add(vfModuleArtifact.getHeatFiles());
- vfModuleArtifact.incrementDeployedInDB();
- } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_NESTED)) {
- nestedHeatTemplates.add(vfModuleArtifact.getHeatTemplate());
- vfModuleArtifact.incrementDeployedInDB();
- }
- }
-
- protected VnfResourceCustomization createVnfResource(NodeTemplate vfNodeTemplate,
- ToscaResourceStructure toscaResourceStructure, Service service) {
- VnfResourceCustomization vnfResourceCustomization = vnfCustomizationRepo.findOneByModelCustomizationUUID(
- vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
- if (vnfResourceCustomization == null) {
- VnfResource vnfResource = findExistingVnfResource(service,
- vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
-
- if (vnfResource == null) {
- vnfResource = createVnfResource(vfNodeTemplate);
- }
-
- vnfResourceCustomization = createVnfResourceCustomization(vfNodeTemplate, toscaResourceStructure,
- vnfResource);
- vnfResourceCustomization.setVnfResources(vnfResource);
- vnfResource.getVnfResourceCustomizations().add(vnfResourceCustomization);
-
- // Fetch VNFC Instance Group Info
- List<Group> groupList = toscaResourceStructure.getSdcCsarHelper()
- .getGroupsOfOriginOfNodeTemplateByToscaGroupType(vfNodeTemplate,
- "org.openecomp.groups.VfcInstanceGroup");
-
- for (Group group : groupList) {
-
- VnfcInstanceGroupCustomization vnfcInstanceGroupCustomization = createVNFCInstanceGroup(vfNodeTemplate,
- group, vnfResourceCustomization, toscaResourceStructure);
-
- vnfcInstanceGroupCustomizationRepo.saveAndFlush(vnfcInstanceGroupCustomization);
- }
- }
- return vnfResourceCustomization;
- }
-
- protected VnfResource findExistingVnfResource(Service service, String modelUUID) {
- VnfResource vnfResource = null;
- for (VnfResourceCustomization vnfResourceCustom : service.getVnfCustomizations()) {
- if (vnfResourceCustom.getVnfResources() != null
- && vnfResourceCustom.getVnfResources().getModelUUID().equals(modelUUID)) {
- vnfResource = vnfResourceCustom.getVnfResources();
- }
- }
- if (vnfResource == null) {
- vnfResource = vnfRepo.findResourceByModelUUID(modelUUID);
- }
-
- return vnfResource;
- }
-
- protected VnfResourceCustomization createVnfResourceCustomization(NodeTemplate vfNodeTemplate,
- ToscaResourceStructure toscaResourceStructure, VnfResource vnfResource) {
- VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization();
- vnfResourceCustomization.setModelCustomizationUUID(
- testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
- vnfResourceCustomization.setModelInstanceName(vfNodeTemplate.getName());
-
- vnfResourceCustomization.setNfFunction(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)));
- vnfResourceCustomization.setNfNamingCode(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vfNodeTemplate, "nf_naming_code")));
- vnfResourceCustomization.setNfRole(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE)));
- vnfResourceCustomization.setNfType(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE)));
-
- vnfResourceCustomization.setMultiStageDesign(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vfNodeTemplate, MULTI_STAGE_DESIGN));
-
- vnfResourceCustomization.setBlueprintName(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SDNC_MODEL_NAME)));
-
- vnfResourceCustomization.setBlueprintVersion(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SDNC_MODEL_VERSION)));
-
- vnfResourceCustomization.setVnfResources(vnfResource);
- vnfResourceCustomization.setAvailabilityZoneMaxCount(Integer.getInteger(
- vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT)));
-
- CapabilityAssignments vnfCustomizationCapability = toscaResourceStructure.getSdcCsarHelper()
- .getCapabilitiesOf(vfNodeTemplate);
-
- if (vnfCustomizationCapability != null) {
- CapabilityAssignment capAssign = vnfCustomizationCapability.getCapabilityByName(SCALABLE);
-
- if (capAssign != null) {
- vnfResourceCustomization.setMinInstances(Integer.getInteger(toscaResourceStructure.getSdcCsarHelper()
- .getCapabilityPropertyLeafValue(capAssign, SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
- vnfResourceCustomization.setMaxInstances(Integer.getInteger(toscaResourceStructure.getSdcCsarHelper()
- .getCapabilityPropertyLeafValue(capAssign, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
- }
-
- }
-
- toscaResourceStructure.setCatalogVnfResourceCustomization(vnfResourceCustomization);
-
- return vnfResourceCustomization;
- }
-
- protected VnfResource createVnfResource(NodeTemplate vfNodeTemplate) {
- VnfResource vnfResource = new VnfResource();
- vnfResource.setModelInvariantUUID(
- testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
- vnfResource.setModelName(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
- vnfResource.setModelUUID(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
-
- vnfResource.setModelVersion(
- testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
- vnfResource.setDescription(
- testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
- vnfResource.setOrchestrationMode(HEAT);
- vnfResource.setToscaNodeType(testNull(vfNodeTemplate.getType()));
- vnfResource.setAicVersionMax(
- testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
- vnfResource.setAicVersionMin(
- testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
- vnfResource.setCategory(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY));
- vnfResource.setSubCategory(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY));
-
- return vnfResource;
- }
-
- protected AllottedResourceCustomization createAllottedResource(NodeTemplate nodeTemplate,
- ToscaResourceStructure toscaResourceStructure, Service service) {
- AllottedResourceCustomization allottedResourceCustomization = allottedCustomizationRepo
- .findOneByModelCustomizationUUID(
- nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
-
- if (allottedResourceCustomization == null) {
- AllottedResource allottedResource = findExistingAllottedResource(service,
- nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
-
- if (allottedResource == null) {
- allottedResource = createAR(nodeTemplate);
- }
-
- toscaResourceStructure.setAllottedResource(allottedResource);
- allottedResourceCustomization = createAllottedResourceCustomization(nodeTemplate, toscaResourceStructure);
- allottedResourceCustomization.setAllottedResource(allottedResource);
- allottedResource.getAllotedResourceCustomization().add(allottedResourceCustomization);
- }
- return allottedResourceCustomization;
- }
-
- protected AllottedResource findExistingAllottedResource(Service service, String modelUUID) {
- AllottedResource allottedResource = null;
- for (AllottedResourceCustomization allottedResourceCustom : service.getAllottedCustomizations()) {
- if (allottedResourceCustom.getAllottedResource() != null
- && allottedResourceCustom.getAllottedResource().getModelUUID().equals(modelUUID)) {
- allottedResource = allottedResourceCustom.getAllottedResource();
- }
- }
- if (allottedResource == null) {
- allottedResource = allottedRepo.findResourceByModelUUID(modelUUID);
- }
-
- return allottedResource;
- }
-
- protected AllottedResourceCustomization createAllottedResourceCustomization(NodeTemplate nodeTemplate,
- ToscaResourceStructure toscaResourceStructure) {
- AllottedResourceCustomization allottedResourceCustomization = new AllottedResourceCustomization();
- allottedResourceCustomization.setModelCustomizationUUID(
- testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
- allottedResourceCustomization.setModelInstanceName(nodeTemplate.getName());
-
- allottedResourceCustomization.setNfFunction(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)));
- allottedResourceCustomization.setNfNamingCode(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(nodeTemplate, "nf_naming_code")));
- allottedResourceCustomization.setNfRole(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE)));
- allottedResourceCustomization.setNfType(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE)));
-
- List<NodeTemplate> vfcNodes = toscaResourceStructure.getSdcCsarHelper()
- .getVfcListByVf(allottedResourceCustomization.getModelCustomizationUUID());
-
- if (vfcNodes != null) {
- for (NodeTemplate vfcNode : vfcNodes) {
-
- allottedResourceCustomization.setProvidingServiceModelUUID(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_uuid"));
- allottedResourceCustomization.setProvidingServiceModelInvariantUUID(
- toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_invariant_uuid"));
- allottedResourceCustomization.setProvidingServiceModelName(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_name"));
- }
- }
-
- CapabilityAssignments arCustomizationCapability = toscaResourceStructure.getSdcCsarHelper()
- .getCapabilitiesOf(nodeTemplate);
-
- if (arCustomizationCapability != null) {
- CapabilityAssignment capAssign = arCustomizationCapability.getCapabilityByName(SCALABLE);
-
- if (capAssign != null) {
- allottedResourceCustomization.setMinInstances(
- Integer.getInteger(toscaResourceStructure.getSdcCsarHelper().getCapabilityPropertyLeafValue(
- capAssign, SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
- allottedResourceCustomization.setMaxInstances(
- Integer.getInteger(toscaResourceStructure.getSdcCsarHelper().getCapabilityPropertyLeafValue(
- capAssign, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
- }
- }
- return allottedResourceCustomization;
- }
-
- protected AllottedResource createAR(NodeTemplate nodeTemplate) {
- AllottedResource allottedResource = new AllottedResource();
- allottedResource
- .setModelUUID(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
- allottedResource.setModelInvariantUUID(
- testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
- allottedResource
- .setModelName(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
- allottedResource
- .setModelVersion(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
- allottedResource.setToscaNodeType(testNull(nodeTemplate.getType()));
- allottedResource.setSubcategory(
- testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY)));
- allottedResource
- .setDescription(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
- return allottedResource;
- }
-
- protected Set<HeatTemplateParam> extractHeatTemplateParameters(String yamlFile, String artifactUUID) {
- // Scan the payload downloadResult and extract the HeatTemplate
- // parameters
- YamlEditor yamlEditor = new YamlEditor(yamlFile.getBytes());
- return yamlEditor.getParameterList(artifactUUID);
- }
-
- protected String testNull(Object object) {
-
- if (object == null) {
- return null;
- } else if (object.equals("NULL")) {
- return null;
- } else if (object instanceof Integer) {
- return object.toString();
- } else if (object instanceof String) {
- return (String) object;
- } else {
- return "Type not recognized";
- }
- }
-
- protected static String identifyParentOfNestedTemplate(VfModuleStructure vfModuleStructure,
- VfModuleArtifact heatNestedArtifact) {
-
- if (vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT) != null && vfModuleStructure
- .getArtifactsMap().get(ASDCConfiguration.HEAT).get(0).getArtifactInfo().getRelatedArtifacts() != null) {
- for (IArtifactInfo unknownArtifact : vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT).get(0)
- .getArtifactInfo().getRelatedArtifacts()) {
- if (heatNestedArtifact.getArtifactInfo().getArtifactUUID().equals(unknownArtifact.getArtifactUUID())) {
- return ASDCConfiguration.HEAT;
- }
-
- }
- }
-
- if (vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL) != null
- && vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0).getArtifactInfo()
- .getRelatedArtifacts() != null) {
- for (IArtifactInfo unknownArtifact : vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL)
- .get(0).getArtifactInfo().getRelatedArtifacts()) {
- if (heatNestedArtifact.getArtifactInfo().getArtifactUUID().equals(unknownArtifact.getArtifactUUID())) {
- return ASDCConfiguration.HEAT_VOL;
- }
-
- }
- }
-
- // Does not belong to anything
- return null;
-
- }
-
- protected static String createVNFName(VfResourceStructure vfResourceStructure) {
-
- return vfResourceStructure.getNotification().getServiceName() + "/"
- + vfResourceStructure.getResourceInstance().getResourceInstanceName();
- }
-
- protected static String createVfModuleName(VfModuleStructure vfModuleStructure) {
-
- return createVNFName(vfModuleStructure.getParentVfResource()) + "::"
- + vfModuleStructure.getVfModuleMetadata().getVfModuleModelName();
- }
-
- protected String getPropertyInput(String propertyName) {
-
- String inputName = new String();
-
- if (propertyName != null) {
- int getInputIndex = propertyName.indexOf("{get_input=");
- if (getInputIndex > -1) {
- inputName = propertyName.substring(getInputIndex + 11, propertyName.length() - 1);
- }
- }
-
- return inputName;
- }
-
-
- protected static Timestamp getCurrentTimeStamp() {
-
- return new Timestamp(new Date().getTime());
- }
+ protected static final String MULTI_STAGE_DESIGN = "multi_stage_design";
+
+ protected static final String SCALABLE = "scalable";
+
+ protected static final String BASIC = "BASIC";
+
+ protected static final String PROVIDER = "PROVIDER";
+
+ protected static final String HEAT = "HEAT";
+
+ protected static final String MANUAL_RECORD = "MANUAL_RECORD";
+
+ protected static final String MSO = "SO";
+
+ protected static final String SDNC_MODEL_NAME = "sdnc_model_name";
+
+ protected static final String SDNC_MODEL_VERSION = "sdnc_model_version";
+
+ private static String CUSTOMIZATION_UUID = "customizationUUID";
+
+
+ @Autowired
+ protected ServiceRepository serviceRepo;
+
+ @Autowired
+ protected InstanceGroupRepository instanceGroupRepo;
+
+ @Autowired
+ protected ServiceProxyResourceCustomizationRepository serviceProxyCustomizationRepo;
+
+ @Autowired
+ protected CollectionResourceRepository collectionRepo;
+
+ @Autowired
+ protected CollectionResourceCustomizationRepository collectionCustomizationRepo;
+
+ @Autowired
+ protected ConfigurationResourceCustomizationRepository configCustomizationRepo;
+
+ @Autowired
+ protected ConfigurationResourceRepository configRepo;
+
+ @Autowired
+ protected VnfResourceRepository vnfRepo;
+
+ @Autowired
+ protected VnfCustomizationRepository vnfCustomizationRepo;
+
+ @Autowired
+ protected VFModuleRepository vfModuleRepo;
+
+ @Autowired
+ protected VFModuleCustomizationRepository vfModuleCustomizationRepo;
+
+ @Autowired
+ protected VnfcInstanceGroupCustomizationRepository vnfcInstanceGroupCustomizationRepo;
+
+ @Autowired
+ protected VnfcCustomizationRepository vnfcCustomizationRepo;
+
+ @Autowired
+ protected CvnfcCustomizationRepository cvnfcCustomizationRepo;
+
+ @Autowired
+ protected AllottedResourceRepository allottedRepo;
+
+ @Autowired
+ protected AllottedResourceCustomizationRepository allottedCustomizationRepo;
+
+ @Autowired
+ protected NetworkResourceRepository networkRepo;
+
+ @Autowired
+ protected HeatTemplateRepository heatRepo;
+
+ @Autowired
+ protected NetworkResourceCustomizationRepository networkCustomizationRepo;
+
+ @Autowired
+ protected WatchdogComponentDistributionStatusRepository watchdogCDStatusRepository;
+ @Autowired
+ protected WatchdogDistributionStatusRepository watchdogDistributionStatusRepository;
+ @Autowired
+ protected WatchdogServiceModVerIdLookupRepository watchdogModVerIdLookupRepository;
+
+ @Autowired
+ protected TempNetworkHeatTemplateRepository tempNetworkLookupRepo;
+
+ @Autowired
+ protected ExternalServiceToInternalServiceRepository externalServiceToInternalServiceRepository;
+
+ @Autowired
+ protected PnfResourceRepository pnfResourceRepository;
+
+ @Autowired
+ protected PnfCustomizationRepository pnfCustomizationRepository;
+
+ protected static final Logger logger = LoggerFactory.getLogger(ToscaResourceInstaller.class);
+
+ public boolean isResourceAlreadyDeployed(VfResourceStructure vfResourceStruct) throws ArtifactInstallerException {
+ boolean status = false;
+ VfResourceStructure vfResourceStructure = vfResourceStruct;
+ try {
+ status = vfResourceStructure.isDeployedSuccessfully();
+ } catch (RuntimeException e) {
+ status = false;
+ }
+ try {
+ Service existingService = serviceRepo.findOneByModelUUID(vfResourceStructure.getNotification().getServiceUUID());
+ if(existingService != null)
+ status = true;
+ if (status) {
+ logger.info(vfResourceStructure.getResourceInstance().getResourceInstanceName(),
+ vfResourceStructure.getResourceInstance().getResourceCustomizationUUID(),
+ vfResourceStructure.getNotification().getServiceName(),
+ BigDecimalVersion.castAndCheckNotificationVersionToString(
+ vfResourceStructure.getNotification().getServiceVersion()),
+ vfResourceStructure.getNotification().getServiceUUID(),
+ vfResourceStructure.getResourceInstance().getResourceName(), "", "");
+ WatchdogComponentDistributionStatus wdStatus = new WatchdogComponentDistributionStatus(vfResourceStruct.getNotification().getDistributionID(), MSO);
+ wdStatus.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name());
+ watchdogCDStatusRepository.saveAndFlush(wdStatus);
+ } else {
+ logger.info(vfResourceStructure.getResourceInstance().getResourceInstanceName(),
+ vfResourceStructure.getResourceInstance().getResourceCustomizationUUID(),
+ vfResourceStructure.getNotification().getServiceName(),
+ BigDecimalVersion.castAndCheckNotificationVersionToString(
+ vfResourceStructure.getNotification().getServiceVersion()),
+ vfResourceStructure.getNotification().getServiceUUID(),
+ vfResourceStructure.getResourceInstance().getResourceName(), "", "");
+ }
+ return status;
+ } catch (Exception e) {
+ logger
+ .error("{} {} {}", MessageEnum.ASDC_ARTIFACT_CHECK_EXC.toString(), ErrorCode.SchemaError.getValue(),
+ "Exception - isResourceAlreadyDeployed");
+ throw new ArtifactInstallerException("Exception caught during checking existence of the VNF Resource.", e);
+ }
+ }
+
+ public void installTheComponentStatus(IStatusData iStatus) throws ArtifactInstallerException {
+ logger.debug("Entering installTheComponentStatus for distributionId {} and ComponentName {}",
+ iStatus.getDistributionID(), iStatus.getComponentName());
+
+ try {
+ WatchdogComponentDistributionStatus cdStatus = new WatchdogComponentDistributionStatus(iStatus.getDistributionID(),
+ iStatus.getComponentName());
+ cdStatus.setComponentDistributionStatus(iStatus.getStatus().toString());
+ watchdogCDStatusRepository.save(cdStatus);
+
+ } catch (Exception e) {
+ logger.debug("Exception caught in installTheComponentStatus {}", e.getMessage());
+ throw new ArtifactInstallerException("Exception caught in installTheComponentStatus " + e.getMessage());
+ }
+ }
+
+ @Transactional(rollbackFor = {ArtifactInstallerException.class})
+ public void installTheResource(ToscaResourceStructure toscaResourceStruct, ResourceStructure resourceStruct)
+ throws ArtifactInstallerException {
+ if (resourceStruct instanceof VfResourceStructure) {
+ installTheVfResource(toscaResourceStruct, (VfResourceStructure) resourceStruct);
+ } else if (resourceStruct instanceof PnfResourceStructure) {
+ installPnfResource(toscaResourceStruct, (PnfResourceStructure) resourceStruct);
+ } else {
+ logger.warn("Unrecognized resource type");
+ }
+ }
+
+ private void installPnfResource(ToscaResourceStructure toscaResourceStruct, PnfResourceStructure resourceStruct)
+ throws ArtifactInstallerException {
+
+ // PCLO: in case of deployment failure, use a string that will represent
+ // the type of artifact that failed...
+ List<ASDCElementInfo> artifactListForLogging = new ArrayList<>();
+ try {
+ createToscaCsar(toscaResourceStruct);
+ Service service = createService(toscaResourceStruct, resourceStruct);
+
+ processResourceSequence(toscaResourceStruct, service);
+ processPnfResources(toscaResourceStruct, service, resourceStruct);
+ serviceRepo.save(service);
+
+ WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus(
+ resourceStruct.getNotification().getDistributionID(), MSO);
+ status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name());
+ watchdogCDStatusRepository.save(status);
+
+ toscaResourceStruct.setSuccessfulDeployment();
+
+ } catch (Exception e) {
+ logger.debug("Exception :", e);
+ WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus(
+ resourceStruct.getNotification().getDistributionID(), MSO);
+ status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_ERROR.name());
+ watchdogCDStatusRepository.save(status);
+ Throwable dbExceptionToCapture = e;
+ while (!(dbExceptionToCapture instanceof ConstraintViolationException
+ || dbExceptionToCapture instanceof LockAcquisitionException)
+ && (dbExceptionToCapture.getCause() != null)) {
+ dbExceptionToCapture = dbExceptionToCapture.getCause();
+ }
+
+ if (dbExceptionToCapture instanceof ConstraintViolationException
+ || dbExceptionToCapture instanceof LockAcquisitionException) {
+ logger.warn("{} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED.toString(),
+ resourceStruct.getResourceInstance().getResourceName(),
+ resourceStruct.getNotification().getServiceVersion(), ErrorCode.DataError.getValue(),
+ "Exception - ASCDC Artifact already deployed", e);
+ } else {
+ String elementToLog = (!artifactListForLogging.isEmpty()
+ ? artifactListForLogging.get(artifactListForLogging.size() - 1).toString()
+ : "No element listed");
+ logger.error("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_INSTALL_EXC.toString(), elementToLog,
+ ErrorCode.DataError.getValue(),
+ "Exception caught during installation of " + resourceStruct.getResourceInstance()
+ .getResourceName()
+ + ". Transaction rollback", e);
+ throw new ArtifactInstallerException("Exception caught during installation of "
+ + resourceStruct.getResourceInstance().getResourceName() + ". Transaction rollback.", e);
+ }
+ }
+ }
+ @Transactional(rollbackFor = { ArtifactInstallerException.class })
+ public void installTheVfResource(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStruct)
+ throws ArtifactInstallerException {
+ VfResourceStructure vfResourceStructure = vfResourceStruct;
+ extractHeatInformation(toscaResourceStruct, vfResourceStructure);
+
+ // PCLO: in case of deployment failure, use a string that will represent
+ // the type of artifact that failed...
+ List<ASDCElementInfo> artifactListForLogging = new ArrayList<>();
+ try {
+ createToscaCsar(toscaResourceStruct);
+ Service service = createService(toscaResourceStruct, vfResourceStruct);
+ List<NodeTemplate> vfNodeTemplatesList = toscaResourceStruct.getSdcCsarHelper().getServiceVfList();
+
+
+ for (NodeTemplate nodeTemplate : vfNodeTemplatesList) {
+
+ Metadata metadata = nodeTemplate.getMetaData();
+ String serviceType = toscaResourceStruct.getCatalogService().getServiceType();
+ String vfCustomizationCategory = toscaResourceStruct.getSdcCsarHelper()
+ .getMetadataPropertyValue(metadata, SdcPropertyNames.PROPERTY_NAME_CATEGORY);
+ processVfModules(toscaResourceStruct, vfResourceStructure, service, nodeTemplate, metadata,
+ vfCustomizationCategory);
+ }
+
+ processResourceSequence(toscaResourceStruct, service);
+ processVFResources(toscaResourceStruct, service, vfResourceStructure);
+ List<NodeTemplate> allottedResourceList = toscaResourceStruct.getSdcCsarHelper().getAllottedResources();
+ processAllottedResources(toscaResourceStruct, service, allottedResourceList);
+ processNetworks(toscaResourceStruct, service);
+ // process Network Collections
+ processNetworkCollections(toscaResourceStruct, service);
+ // Process Service Proxy & Configuration
+ processServiceProxyAndConfiguration(toscaResourceStruct, service);
+
+ serviceRepo.save(service);
+
+ WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus(vfResourceStruct.getNotification().getDistributionID(), MSO);
+ status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name());
+ watchdogCDStatusRepository.save(status);
+
+ toscaResourceStruct.setSuccessfulDeployment();
+
+ } catch (Exception e) {
+ logger.debug("Exception :", e);
+ WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus(vfResourceStruct.getNotification().getDistributionID(), MSO);
+ status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_ERROR.name());
+ watchdogCDStatusRepository.save(status);
+ Throwable dbExceptionToCapture = e;
+ while (!(dbExceptionToCapture instanceof ConstraintViolationException
+ || dbExceptionToCapture instanceof LockAcquisitionException)
+ && (dbExceptionToCapture.getCause() != null)) {
+ dbExceptionToCapture = dbExceptionToCapture.getCause();
+ }
+
+ if (dbExceptionToCapture instanceof ConstraintViolationException
+ || dbExceptionToCapture instanceof LockAcquisitionException) {
+ logger.warn("{} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED.toString(),
+ vfResourceStructure.getResourceInstance().getResourceName(),
+ vfResourceStructure.getNotification().getServiceVersion(), ErrorCode.DataError.getValue(),
+ "Exception - ASCDC Artifact already deployed", e);
+ } else {
+ String elementToLog = (!artifactListForLogging.isEmpty()
+ ? artifactListForLogging.get(artifactListForLogging.size() - 1).toString()
+ : "No element listed");
+ logger.error("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_INSTALL_EXC.toString(), elementToLog,
+ ErrorCode.DataError.getValue(),
+ "Exception caught during installation of " + vfResourceStructure.getResourceInstance().getResourceName()
+ + ". Transaction rollback", e);
+ throw new ArtifactInstallerException("Exception caught during installation of "
+ + vfResourceStructure.getResourceInstance().getResourceName() + ". Transaction rollback.", e);
+ }
+ }
+ }
+
+
+ List<NodeTemplate> getRequirementList(List<NodeTemplate> resultList, List<NodeTemplate> nodeTemplates,
+ ISdcCsarHelper iSdcCsarHelper) {
+
+ List<NodeTemplate> nodes = new ArrayList<NodeTemplate>();
+ nodes.addAll(nodeTemplates);
+
+ for (NodeTemplate nodeTemplate : nodeTemplates) {
+ RequirementAssignments requirement = iSdcCsarHelper.getRequirementsOf(nodeTemplate);
+ List<RequirementAssignment> reqAs = requirement.getAll();
+ for (RequirementAssignment ra : reqAs) {
+ String reqNode = ra.getNodeTemplateName();
+ for (NodeTemplate rNode : resultList) {
+ if (rNode.getName().equals(reqNode)) {
+ if(!resultList.contains(nodeTemplate)) {
+ resultList.add(nodeTemplate);
+ }
+ if(nodes.contains(nodeTemplate)) {
+ nodes.remove(nodeTemplate);
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ if (!nodes.isEmpty()) {
+ getRequirementList(resultList, nodes, iSdcCsarHelper);
+ }
+
+ return resultList;
+ }
+
+ // This method retrieve resource sequence from csar file
+ void processResourceSequence(ToscaResourceStructure toscaResourceStructure, Service service) {
+ List<String> resouceSequence = new ArrayList<String>();
+ List<NodeTemplate> resultList = new ArrayList<NodeTemplate>();
+
+ ISdcCsarHelper iSdcCsarHelper = toscaResourceStructure.getSdcCsarHelper();
+ List<NodeTemplate> nodeTemplates = iSdcCsarHelper.getServiceNodeTemplates();
+ List<NodeTemplate> nodes = new ArrayList<NodeTemplate>();
+ nodes.addAll(nodeTemplates);
+
+ for (NodeTemplate nodeTemplate : nodeTemplates) {
+ RequirementAssignments requirement = iSdcCsarHelper.getRequirementsOf(nodeTemplate);
+
+ if (requirement == null || requirement.getAll() == null || requirement.getAll().isEmpty()) {
+ resultList.add(nodeTemplate);
+ nodes.remove(nodeTemplate);
+ }
+ }
+
+ resultList = getRequirementList(resultList, nodes, iSdcCsarHelper);
+
+ for (NodeTemplate node : resultList) {
+ String templateName = node.getMetaData().getValue("name");
+ if (!resouceSequence.contains(templateName)) {
+ resouceSequence.add(templateName);
+ }
+ }
+
+ String resourceSeqStr = resouceSequence.stream().collect(Collectors.joining(","));
+ service.setResourceOrder(resourceSeqStr);
+ logger.debug(" resourceSeq for service uuid(" + service.getModelUUID() + ") : " + resourceSeqStr);
+ }
+
+ private static String getValue(Object value, List<Input> servInputs) {
+ String output = null;
+ if(value instanceof Map) {
+ // currently this logic handles only one level of nesting.
+ return ((LinkedHashMap) value).values().toArray()[0].toString();
+ } else if(value instanceof GetInput) {
+ String inputName = ((GetInput)value).getInputName();
+
+ for(Input input : servInputs) {
+ if(input.getName().equals(inputName)) {
+ // keep both input name and default value
+ // if service input does not supplies value the use default value
+ String defaultValue = input.getDefault() != null ? (String) input.getDefault().toString() : "";
+ output = inputName + "|" + defaultValue;// return default value
+ }
+ }
+
+ } else {
+ output = value != null ? value.toString() : "";
+ }
+ return output; // return property value
+ }
+
+ String getResourceInput(ToscaResourceStructure toscaResourceStructure, String resourceCustomizationUuid) throws ArtifactInstallerException {
+ Map<String, String> resouceRequest = new HashMap<>();
+ ISdcCsarHelper iSdcCsarHelper = toscaResourceStructure.getSdcCsarHelper();
+
+ List<Input> serInput = iSdcCsarHelper.getServiceInputs();
+ Optional<NodeTemplate> nodeTemplateOpt = iSdcCsarHelper.getServiceNodeTemplates().stream()
+ .filter(e -> e.getMetaData().getValue(CUSTOMIZATION_UUID).equals(resourceCustomizationUuid)).findFirst();
+ if(nodeTemplateOpt.isPresent()) {
+ NodeTemplate nodeTemplate = nodeTemplateOpt.get();
+ LinkedHashMap<String, Property> resourceProperties = nodeTemplate.getProperties();
+
+ for(String key : resourceProperties.keySet()) {
+ Property property = resourceProperties.get(key);
+
+ String value = getValue(property.getValue(), serInput);
+ resouceRequest.put(key, value);
+ }
+ }
+
+ try {
+ ObjectMapper objectMapper = new ObjectMapper();
+ String jsonStr = objectMapper.writeValueAsString(resouceRequest);
+
+ jsonStr = jsonStr.replace("\"", "\\\"");
+ logger.debug("resource request for resource customization id (" + resourceCustomizationUuid + ") : " + jsonStr);
+ return jsonStr;
+ } catch (JsonProcessingException e) {
+ logger.error("resource input could not be deserialized for resource customization id ("
+ + resourceCustomizationUuid + ")");
+ throw new ArtifactInstallerException("resource input could not be parsed", e);
+ }
+ }
+
+ protected void processNetworks (ToscaResourceStructure toscaResourceStruct,
+ Service service) throws ArtifactInstallerException {
+ List <NodeTemplate> nodeTemplatesVLList = toscaResourceStruct.getSdcCsarHelper ().getServiceVlList ();
+
+ if (nodeTemplatesVLList != null) {
+ for (NodeTemplate vlNode : nodeTemplatesVLList) {
+ String networkResourceModelName = vlNode.getMetaData ().getValue (SdcPropertyNames.PROPERTY_NAME_NAME);
+
+ TempNetworkHeatTemplateLookup tempNetworkLookUp =
+ tempNetworkLookupRepo.findFirstBynetworkResourceModelName (networkResourceModelName);
+
+ if (tempNetworkLookUp != null) {
+ HeatTemplate heatTemplate =
+ heatRepo.findByArtifactUuid (tempNetworkLookUp.getHeatTemplateArtifactUuid ());
+ if (heatTemplate != null) {
+ NetworkResourceCustomization networkCustomization =
+ createNetwork (vlNode,
+ toscaResourceStruct,
+ heatTemplate,
+ tempNetworkLookUp.getAicVersionMax (),
+ tempNetworkLookUp.getAicVersionMin (),
+ service);
+ service.getNetworkCustomizations ().add (networkCustomization);
+ } else {
+ throw new ArtifactInstallerException ("No HeatTemplate found for artifactUUID: "
+ + tempNetworkLookUp.getHeatTemplateArtifactUuid ());
+ }
+ } else {
+ NetworkResourceCustomization networkCustomization = createNetwork (vlNode,
+ toscaResourceStruct,
+ null,
+ null,
+ null,
+ service);
+ service.getNetworkCustomizations().add (networkCustomization);
+ logger.debug ("No NetworkResourceName found in TempNetworkHeatTemplateLookup for "
+ + networkResourceModelName);
+ }
+
+ }
+ }
+ }
+
+ protected void processAllottedResources(ToscaResourceStructure toscaResourceStruct, Service service,
+ List<NodeTemplate> allottedResourceList) {
+ if (allottedResourceList != null) {
+ for (NodeTemplate allottedNode : allottedResourceList) {
+ service.getAllottedCustomizations()
+ .add(createAllottedResource(allottedNode, toscaResourceStruct, service));
+ }
+ }
+ }
+
+
+ protected ConfigurationResource getConfigurationResource(NodeTemplate nodeTemplate) {
+ Metadata metadata = nodeTemplate.getMetaData();
+ ConfigurationResource configResource = new ConfigurationResource();
+ configResource.setModelName(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ configResource.setModelInvariantUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ configResource.setModelUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ configResource.setModelVersion(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
+ configResource.setDescription(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
+ configResource.setToscaNodeType(nodeTemplate.getType());
+ return configResource;
+ }
+
+ protected ConfigurationResourceCustomization getConfigurationResourceCustomization(NodeTemplate nodeTemplate, ToscaResourceStructure toscaResourceStructure,
+ ServiceProxyResourceCustomization spResourceCustomization ) {
+ Metadata metadata = nodeTemplate.getMetaData();
+
+ ConfigurationResource configResource = getConfigurationResource(nodeTemplate);
+
+ ConfigurationResourceCustomization configCustomizationResource = new ConfigurationResourceCustomization();
+
+ Set<ConfigurationResourceCustomization> configResourceCustomizationSet = new HashSet<>();
+
+ configCustomizationResource.setModelCustomizationUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+ configCustomizationResource.setModelInstanceName(nodeTemplate.getName());
+
+ configCustomizationResource.setNfFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION));
+ configCustomizationResource.setNfRole(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE));
+ configCustomizationResource.setNfType(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE));
+ configCustomizationResource.setServiceProxyResourceCustomizationUUID(spResourceCustomization.getModelCustomizationUUID());
+
+ configCustomizationResource.setConfigurationResource(configResource);
+ configResourceCustomizationSet.add(configCustomizationResource);
+
+ configResource.setConfigurationResourceCustomization(configResourceCustomizationSet);
+ return configCustomizationResource;
+ }
+
+
+ protected Optional<ConfigurationResourceCustomization> getVnrNodeTemplate(List<NodeTemplate> configurationNodeTemplatesList,
+ ToscaResourceStructure toscaResourceStructure, ServiceProxyResourceCustomization spResourceCustomization) {
+ Optional<ConfigurationResourceCustomization> configurationResourceCust = Optional.empty();
+ for (NodeTemplate nodeTemplate : configurationNodeTemplatesList) {
+ StatefulEntityType entityType = nodeTemplate.getTypeDefinition();
+ String type = entityType.getType();
+
+ if(VLAN_NETWORK_RECEPTOR.equals(type)) {
+ configurationResourceCust= Optional.of(getConfigurationResourceCustomization(nodeTemplate,
+ toscaResourceStructure,spResourceCustomization));
+ break;
+ }
+ }
+
+ return configurationResourceCust;
+ }
+
+ protected void processServiceProxyAndConfiguration(ToscaResourceStructure toscaResourceStruct, Service service) {
+
+ List<NodeTemplate> serviceProxyResourceList = toscaResourceStruct.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.SERVICE_PROXY);
+
+ List<NodeTemplate> configurationNodeTemplatesList = toscaResourceStruct.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.CONFIGURATION);
+
+ List<ServiceProxyResourceCustomization> serviceProxyList = new ArrayList<ServiceProxyResourceCustomization>();
+ List<ConfigurationResourceCustomization> configurationResourceList = new ArrayList<ConfigurationResourceCustomization>();
+
+ ServiceProxyResourceCustomization serviceProxy = null;
+
+ if (serviceProxyResourceList != null) {
+ for (NodeTemplate spNode : serviceProxyResourceList) {
+ serviceProxy = createServiceProxy(spNode, service, toscaResourceStruct);
+ serviceProxyList.add(serviceProxy);
+ Optional<ConfigurationResourceCustomization> vnrResourceCustomization = getVnrNodeTemplate(configurationNodeTemplatesList,toscaResourceStruct,serviceProxy);
+
+ for (NodeTemplate configNode : configurationNodeTemplatesList) {
+
+ List<RequirementAssignment> requirementsList = toscaResourceStruct.getSdcCsarHelper().getRequirementsOf(configNode).getAll();
+ for (RequirementAssignment requirement : requirementsList) {
+ if (requirement.getNodeTemplateName().equals(spNode.getName())) {
+ ConfigurationResourceCustomization configurationResource = createConfiguration(configNode, toscaResourceStruct, serviceProxy, vnrResourceCustomization);
+
+ Optional<ConfigurationResourceCustomization> matchingObject = configurationResourceList.stream()
+ .filter(configurationResourceCustomization -> configNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID).equals(configurationResource.getModelCustomizationUUID()))
+ .findFirst();
+ if(!matchingObject.isPresent()){
+ configurationResourceList.add(configurationResource);
+ }
+
+ break;
+ }
+ }
+ }
+
+ }
+ }
+
+ service.setConfigurationCustomizations(configurationResourceList);
+ service.setServiceProxyCustomizations(serviceProxyList);
+ }
+
+ protected void processNetworkCollections(ToscaResourceStructure toscaResourceStruct, Service service) {
+
+ List<NodeTemplate> networkCollectionList = toscaResourceStruct.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.CR);
+
+ if (networkCollectionList != null) {
+ for (NodeTemplate crNode : networkCollectionList) {
+
+ createNetworkCollection(crNode, toscaResourceStruct, service);
+ collectionRepo.saveAndFlush(toscaResourceStruct.getCatalogCollectionResource());
+
+ List<NetworkInstanceGroup> networkInstanceGroupList = toscaResourceStruct.getCatalogNetworkInstanceGroup();
+ for(NetworkInstanceGroup networkInstanceGroup : networkInstanceGroupList){
+ instanceGroupRepo.saveAndFlush(networkInstanceGroup);
+ }
+
+ }
+ }
+ service.getCollectionResourceCustomizations().add(toscaResourceStruct.getCatalogCollectionResourceCustomization());
+ }
+
+
+ protected void processVFResources (ToscaResourceStructure toscaResourceStruct, Service service, VfResourceStructure vfResourceStructure)
+ throws Exception{
+ logger.debug("processVFResources");
+
+ List<NodeTemplate> vfNodeTemplatesList = toscaResourceStruct.getSdcCsarHelper().getServiceVfList();
+// String servicecategory = toscaResourceStruct.getCatalogService().getCategory();
+// String serviceType = toscaResourceStruct.getCatalogService().getServiceType();
+
+ for (NodeTemplate nodeTemplate : vfNodeTemplatesList) {
+ Metadata metadata = nodeTemplate.getMetaData();
+ String vfCustomizationCategory = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY);
+ logger.debug("VF Category is : " + vfCustomizationCategory);
+
+ // Do not treat Allotted Resources as VNF resources
+ if(ALLOTTED_RESOURCE.equalsIgnoreCase(vfCustomizationCategory)){
+ continue;
+ }
+
+ String vfCustomizationUUID = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
+ logger.debug("VFCustomizationUUID=" + vfCustomizationUUID);
+
+ IResourceInstance vfNotificationResource = vfResourceStructure.getResourceInstance();
+
+ // Make sure the VF ResourceCustomizationUUID from the notification and tosca
+ // customizations match before comparing their VF Modules UUID's
+ logger.debug("Checking if Notification VF ResourceCustomizationUUID: "
+ + vfNotificationResource.getResourceCustomizationUUID() + " matches Tosca VF Customization UUID: "
+ + vfCustomizationUUID);
+
+ if (vfCustomizationUUID.equals(vfNotificationResource.getResourceCustomizationUUID())) {
+ logger.debug("vfCustomizationUUID: " + vfCustomizationUUID
+ + " matches vfNotificationResource CustomizationUUID");
+
+ processVfModules(toscaResourceStruct, vfResourceStructure, service, nodeTemplate, metadata,
+ vfCustomizationCategory);
+ } else {
+ logger.debug("Notification VF ResourceCustomizationUUID: "
+ + vfNotificationResource.getResourceCustomizationUUID() + " doesn't match "
+ + "Tosca VF Customization UUID: " + vfCustomizationUUID);
+ }
+ }
+ }
+
+ /**
+ * This is used to process the PNF specific resource, including resource and resource_customization. {@link
+ * IEntityDetails} based API is used to retrieve information. Please check {@link ISdcCsarHelper} for details.
+ */
+ protected void processPnfResources(ToscaResourceStructure toscaResourceStruct, Service service,
+ PnfResourceStructure resourceStructure) throws Exception {
+ logger.info("Processing PNF resource: {}", resourceStructure.getResourceInstance().getResourceUUID());
+
+ ISdcCsarHelper sdcCsarHelper = toscaResourceStruct.getSdcCsarHelper();
+ EntityQuery entityQuery = EntityQuery.newBuilder(SdcTypes.PNF).build();
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE).build();
+
+ List<IEntityDetails> entityDetailsList = sdcCsarHelper.getEntity(entityQuery, topologyTemplateQuery, false);
+ for (IEntityDetails entityDetails : entityDetailsList) {
+ Metadata metadata = entityDetails.getMetadata();
+ String customizationUUID = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
+ String modelUuid = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID);
+ String notifCustomizationUUID = resourceStructure.getResourceInstance().getResourceCustomizationUUID();
+ if (customizationUUID != null && customizationUUID.equals(notifCustomizationUUID)) {
+ logger.info("Resource customization UUID: {} is the same as notified resource customizationUUID: {}",
+ customizationUUID, notifCustomizationUUID);
+
+ if (checkExistingPnfResourceCutomization(customizationUUID)) {
+ logger.info("Resource customization UUID: {} already deployed", customizationUUID);
+ } else {
+ PnfResource pnfResource = findExistingPnfResource(service, modelUuid);
+ if (pnfResource == null) {
+ pnfResource = createPnfResource(entityDetails);
+ }
+ PnfResourceCustomization pnfResourceCustomization = createPnfResourceCustomization(entityDetails,
+ pnfResource);
+ pnfResource.getPnfResourceCustomizations().add(pnfResourceCustomization);
+ toscaResourceStruct.setPnfResourceCustomization(pnfResourceCustomization);
+ service.getPnfCustomizations().add(pnfResourceCustomization);
+ }
+ } else {
+ logger
+ .warn("Resource customization UUID: {} is NOT the same as notified resource customizationUUID: {}",
+ customizationUUID, notifCustomizationUUID);
+ }
+ }
+ }
+
+ private PnfResource findExistingPnfResource(Service service, String modelUuid) {
+ PnfResource pnfResource = null;
+ for (PnfResourceCustomization pnfResourceCustomization : service.getPnfCustomizations()) {
+ if (pnfResourceCustomization.getPnfResources() != null && pnfResourceCustomization.getPnfResources()
+ .getModelUUID().equals(modelUuid)) {
+ pnfResource = pnfResourceCustomization.getPnfResources();
+ }
+ }
+ if (pnfResource == null) {
+ pnfResource = pnfResourceRepository.findById(modelUuid).orElse(pnfResource);
+ }
+ return pnfResource;
+ }
+
+ private boolean checkExistingPnfResourceCutomization(String customizationUUID) {
+ return pnfCustomizationRepository.findById(customizationUUID).isPresent();
+ }
+
+ /**
+ * Construct the {@link PnfResource} from {@link IEntityDetails} object.
+ */
+ private PnfResource createPnfResource(IEntityDetails entity) {
+ PnfResource pnfResource = new PnfResource();
+ Metadata metadata = entity.getMetadata();
+ pnfResource.setModelInvariantUUID(
+ testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
+ pnfResource.setModelName(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
+ pnfResource.setModelUUID(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
+ pnfResource.setModelVersion(
+ testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
+ pnfResource.setDescription(
+ testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
+ pnfResource.setCategory(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY)));
+ pnfResource.setSubCategory(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY)));
+ pnfResource.setToscaNodeType(entity.getToscaType());
+ return pnfResource;
+ }
+
+ /**
+ * Construct the {@link PnfResourceCustomization} from {@link IEntityDetails} object.
+ */
+ private PnfResourceCustomization createPnfResourceCustomization(IEntityDetails entityDetails,
+ PnfResource pnfResource) {
+
+ PnfResourceCustomization pnfResourceCustomization = new PnfResourceCustomization();
+ Metadata metadata = entityDetails.getMetadata();
+ Map<String, Property> properties = entityDetails.getProperties();
+ pnfResourceCustomization
+ .setModelCustomizationUUID(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
+ pnfResourceCustomization.setModelInstanceName(entityDetails.getName());
+ pnfResourceCustomization
+ .setNfFunction(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)));
+ pnfResourceCustomization.setNfNamingCode(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFCODE)));
+ pnfResourceCustomization.setNfRole(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFROLE)));
+ pnfResourceCustomization.setNfType(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFTYPE)));
+ pnfResourceCustomization.setMultiStageDesign(getStringValue(properties.get(MULTI_STAGE_DESIGN)));
+ pnfResourceCustomization.setBlueprintName(getStringValue(properties.get(SDNC_MODEL_NAME)));
+ pnfResourceCustomization.setBlueprintVersion(getStringValue(properties.get(SDNC_MODEL_VERSION)));
+
+ pnfResourceCustomization.setPnfResources(pnfResource);
+
+ return pnfResourceCustomization;
+ }
+
+ /**
+ * Get value from {@link Property} and cast to String value. Return empty String if property is null value.
+ */
+ private String getStringValue(Property property) {
+ if (null == property) {
+ return "";
+ }
+ Object value = property.getValue();
+ return String.valueOf(value);
+ }
+
+ protected void processVfModules(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStructure,
+ Service service, NodeTemplate nodeTemplate, Metadata metadata, String vfCustomizationCategory) throws Exception {
+
+ logger.debug("VF Category is : " + vfCustomizationCategory);
+
+ if(vfResourceStructure.getVfModuleStructure() != null && !vfResourceStructure.getVfModuleStructure().isEmpty())
+ {
+
+ String vfCustomizationUUID = toscaResourceStruct.getSdcCsarHelper()
+ .getMetadataPropertyValue(metadata, SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
+ logger.debug("VFCustomizationUUID=" + vfCustomizationUUID);
+
+ IResourceInstance vfNotificationResource = vfResourceStructure.getResourceInstance();
+
+ // Make sure the VF ResourceCustomizationUUID from the notification and tosca customizations match before comparing their VF Modules UUID's
+ logger.debug("Checking if Notification VF ResourceCustomizationUUID: " + vfNotificationResource.getResourceCustomizationUUID() +
+ " matches Tosca VF Customization UUID: " + vfCustomizationUUID);
+
+ if(vfCustomizationUUID.equals(vfNotificationResource.getResourceCustomizationUUID())){
+
+ logger.debug("vfCustomizationUUID: " + vfCustomizationUUID + " matches vfNotificationResource CustomizationUUID");
+
+ VnfResourceCustomization vnfResource = createVnfResource(nodeTemplate, toscaResourceStruct, service);
+
+ Set<CvnfcCustomization> existingCvnfcSet = new HashSet<CvnfcCustomization>();
+ Set<VnfcCustomization> existingVnfcSet = new HashSet<VnfcCustomization>();
+
+ for (VfModuleStructure vfModuleStructure : vfResourceStructure.getVfModuleStructure()) {
+
+ logger.debug("vfModuleStructure:" + vfModuleStructure.toString());
+ List<org.onap.sdc.toscaparser.api.Group> vfGroups = toscaResourceStruct
+ .getSdcCsarHelper().getVfModulesByVf(vfCustomizationUUID);
+ IVfModuleData vfMetadata = vfModuleStructure.getVfModuleMetadata();
+
+ logger.debug("Comparing Vf_Modules_Metadata CustomizationUUID : " + vfMetadata.getVfModuleModelCustomizationUUID());
+
+ Optional<org.onap.sdc.toscaparser.api.Group> matchingObject = vfGroups.stream()
+ .peek(group -> logger.debug("To Csar Group VFModuleModelCustomizationUUID " + group.getMetadata().getValue("vfModuleModelCustomizationUUID")))
+ .filter(group -> group.getMetadata().getValue("vfModuleModelCustomizationUUID").equals(vfMetadata.getVfModuleModelCustomizationUUID()))
+ .findFirst();
+ if(matchingObject.isPresent()){
+ VfModuleCustomization vfModuleCustomization = createVFModuleResource(matchingObject.get(), nodeTemplate, toscaResourceStruct,
+ vfResourceStructure,vfMetadata, vnfResource, service, existingCvnfcSet, existingVnfcSet);
+ vfModuleCustomization.getVfModule().setVnfResources(vnfResource.getVnfResources());
+ }else
+ throw new Exception("Cannot find matching VFModule Customization in Csar for Vf_Modules_Metadata: " + vfMetadata.getVfModuleModelCustomizationUUID());
+
+ }
+ service.getVnfCustomizations().add(vnfResource);
+ } else{
+ logger.debug("Notification VF ResourceCustomizationUUID: " + vfNotificationResource.getResourceCustomizationUUID() + " doesn't match " +
+ "Tosca VF Customization UUID: " + vfCustomizationUUID);
+ }
+ }
+ }
+
+ public void processWatchdog(String distributionId, String servideUUID, Optional<String> distributionNotification,
+ String consumerId) {
+ WatchdogServiceModVerIdLookup modVerIdLookup = new WatchdogServiceModVerIdLookup(distributionId, servideUUID,
+ distributionNotification, consumerId);
+ watchdogModVerIdLookupRepository.saveAndFlush(modVerIdLookup);
+
+ try{
+
+ WatchdogDistributionStatus distributionStatus = new WatchdogDistributionStatus(distributionId);
+ watchdogDistributionStatusRepository.saveAndFlush(distributionStatus);
+
+ } catch(ObjectOptimisticLockingFailureException e){
+ logger.debug("ObjectOptimisticLockingFailureException in processWatchdog : " + e.toString());
+ throw e;
+ }
+ }
+
+ protected void extractHeatInformation(ToscaResourceStructure toscaResourceStruct,
+ VfResourceStructure vfResourceStructure) {
+ for (VfModuleArtifact vfModuleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
+
+ switch (vfModuleArtifact.getArtifactInfo().getArtifactType()) {
+ case ASDCConfiguration.HEAT:
+ case ASDCConfiguration.HEAT_NESTED:
+ createHeatTemplateFromArtifact(vfResourceStructure, toscaResourceStruct,
+ vfModuleArtifact);
+ break;
+ case ASDCConfiguration.HEAT_VOL:
+ createHeatTemplateFromArtifact(vfResourceStructure, toscaResourceStruct,
+ vfModuleArtifact);
+ VfModuleArtifact envModuleArtifact = getHeatEnvArtifactFromGeneratedArtifact(vfResourceStructure, vfModuleArtifact);
+ createHeatEnvFromArtifact(vfResourceStructure, envModuleArtifact);
+ break;
+ case ASDCConfiguration.HEAT_ENV:
+ createHeatEnvFromArtifact(vfResourceStructure, vfModuleArtifact);
+ break;
+ case ASDCConfiguration.HEAT_ARTIFACT:
+ createHeatFileFromArtifact(vfResourceStructure, vfModuleArtifact,
+ toscaResourceStruct);
+ break;
+ case ASDCConfiguration.HEAT_NET:
+ case ASDCConfiguration.OTHER:
+ logger.warn("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_TYPE_NOT_SUPPORT.toString(),
+ vfModuleArtifact.getArtifactInfo().getArtifactType() + "(Artifact Name:" + vfModuleArtifact.getArtifactInfo()
+ .getArtifactName() + ")", ErrorCode.DataError.getValue(), "Artifact type not supported");
+ break;
+ default:
+ break;
+
+ }
+ }
+ }
+
+ protected VfModuleArtifact getHeatEnvArtifactFromGeneratedArtifact(VfResourceStructure vfResourceStructure,
+ VfModuleArtifact vfModuleArtifact) {
+ String artifactName = vfModuleArtifact.getArtifactInfo().getArtifactName();
+ artifactName = artifactName.substring(0, artifactName.indexOf('.'));
+ for (VfModuleArtifact moduleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
+ if (moduleArtifact.getArtifactInfo().getArtifactName().contains(artifactName)
+ && moduleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ENV)) {
+ return moduleArtifact;
+ }
+ }
+ return null;
+ }
+
+ public String verifyTheFilePrefixInArtifacts(String filebody, VfResourceStructure vfResourceStructure,
+ List<String> listTypes) {
+ String newFileBody = filebody;
+ for (VfModuleArtifact moduleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
+
+ if (listTypes.contains(moduleArtifact.getArtifactInfo().getArtifactType())) {
+
+ newFileBody = verifyTheFilePrefixInString(newFileBody,
+ moduleArtifact.getArtifactInfo().getArtifactName());
+ }
+ }
+ return newFileBody;
+ }
+
+ public String verifyTheFilePrefixInString(final String body, final String filenameToVerify) {
+
+ String needlePrefix = "file:///";
+ String prefixedFilenameToVerify = needlePrefix + filenameToVerify;
+
+ if ((body == null) || (body.length() == 0) || (filenameToVerify == null) || (filenameToVerify.length() == 0)) {
+ return body;
+ }
+
+ StringBuilder sb = new StringBuilder(body.length());
+
+ int currentIndex = 0;
+ int startIndex = 0;
+
+ while (currentIndex != -1) {
+ startIndex = currentIndex;
+ currentIndex = body.indexOf(prefixedFilenameToVerify, startIndex);
+
+ if (currentIndex == -1) {
+ break;
+ }
+ // We append from the startIndex up to currentIndex (start of File
+ // Name)
+ sb.append(body.substring(startIndex, currentIndex));
+ sb.append(filenameToVerify);
+
+ currentIndex += prefixedFilenameToVerify.length();
+ }
+
+ sb.append(body.substring(startIndex));
+
+ return sb.toString();
+ }
+
+ protected void createHeatTemplateFromArtifact(VfResourceStructure vfResourceStructure,
+ ToscaResourceStructure toscaResourceStruct, VfModuleArtifact vfModuleArtifact) {
+ HeatTemplate heatTemplate = new HeatTemplate();
+ List<String> typeList = new ArrayList<>();
+ typeList.add(ASDCConfiguration.HEAT_NESTED);
+ typeList.add(ASDCConfiguration.HEAT_ARTIFACT);
+
+ heatTemplate.setTemplateBody(
+ verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(), vfResourceStructure, typeList));
+ heatTemplate.setTemplateName(vfModuleArtifact.getArtifactInfo().getArtifactName());
+
+ if (vfModuleArtifact.getArtifactInfo().getArtifactTimeout() != null) {
+ heatTemplate.setTimeoutMinutes(vfModuleArtifact.getArtifactInfo().getArtifactTimeout());
+ } else {
+ heatTemplate.setTimeoutMinutes(240);
+ }
+
+ heatTemplate.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
+ heatTemplate.setVersion(BigDecimalVersion
+ .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
+ heatTemplate.setArtifactUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
+
+ if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) {
+ heatTemplate.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
+ } else {
+ heatTemplate.setArtifactChecksum(MANUAL_RECORD);
+ }
+
+ Set<HeatTemplateParam> heatParam = extractHeatTemplateParameters(
+ vfModuleArtifact.getResult(), vfModuleArtifact.getArtifactInfo().getArtifactUUID());
+ heatTemplate.setParameters(heatParam);
+ vfModuleArtifact.setHeatTemplate(heatTemplate);
+ }
+
+ protected void createHeatEnvFromArtifact(VfResourceStructure vfResourceStructure,
+ VfModuleArtifact vfModuleArtifact) {
+ HeatEnvironment heatEnvironment = new HeatEnvironment();
+ heatEnvironment.setName(vfModuleArtifact.getArtifactInfo().getArtifactName());
+ List<String> typeList = new ArrayList<>();
+ typeList.add(ASDCConfiguration.HEAT);
+ typeList.add(ASDCConfiguration.HEAT_VOL);
+ heatEnvironment.setEnvironment(
+ verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(), vfResourceStructure, typeList));
+ heatEnvironment.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
+ heatEnvironment.setVersion(BigDecimalVersion
+ .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
+ heatEnvironment.setArtifactUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
+
+ if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) {
+ heatEnvironment.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
+ } else {
+ heatEnvironment.setArtifactChecksum(MANUAL_RECORD);
+ }
+ vfModuleArtifact.setHeatEnvironment(heatEnvironment);
+ }
+
+ protected void createHeatFileFromArtifact(VfResourceStructure vfResourceStructure,
+ VfModuleArtifact vfModuleArtifact, ToscaResourceStructure toscaResourceStruct) {
+
+ HeatFiles heatFile = new HeatFiles();
+ heatFile.setAsdcUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
+ heatFile.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
+ heatFile.setFileBody(vfModuleArtifact.getResult());
+ heatFile.setFileName(vfModuleArtifact.getArtifactInfo().getArtifactName());
+ heatFile.setVersion(BigDecimalVersion
+ .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
+ toscaResourceStruct.setHeatFilesUUID(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
+ if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) {
+ heatFile.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
+ } else {
+ heatFile.setArtifactChecksum(MANUAL_RECORD);
+ }
+ vfModuleArtifact.setHeatFiles(heatFile);
+ }
+
+ protected Service createService(ToscaResourceStructure toscaResourceStructure,
+ ResourceStructure resourceStructure) {
+
+ Metadata serviceMetadata = toscaResourceStructure.getServiceMetadata();
+
+ Service service = new Service();
+
+ if (serviceMetadata != null) {
+
+ if (toscaResourceStructure.getServiceVersion() != null) {
+ service.setModelVersion(toscaResourceStructure.getServiceVersion());
+ }
+
+ service.setServiceType(serviceMetadata.getValue("serviceType"));
+ service.setServiceRole(serviceMetadata.getValue("serviceRole"));
+ service.setCategory(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY));
+
+ service.setDescription(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
+ service.setModelName(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ service.setModelUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ service.setEnvironmentContext(serviceMetadata.getValue("environmentContext"));
+
+ if (resourceStructure != null)
+ service.setWorkloadContext(resourceStructure.getNotification().getWorkloadContext());
+
+ service.setModelInvariantUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ service.setCsar(toscaResourceStructure.getCatalogToscaCsar());
+ }
+
+
+ toscaResourceStructure.setCatalogService(service);
+ return service;
+ }
+
+ protected ServiceProxyResourceCustomization createServiceProxy(NodeTemplate nodeTemplate, Service service, ToscaResourceStructure toscaResourceStructure) {
+
+ Metadata spMetadata = nodeTemplate.getMetaData();
+
+ ServiceProxyResourceCustomization spCustomizationResource = new ServiceProxyResourceCustomization();
+
+ Set<ServiceProxyResourceCustomization> serviceProxyCustomizationSet = new HashSet<>();
+
+ spCustomizationResource.setModelName(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ spCustomizationResource.setModelInvariantUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ spCustomizationResource.setModelUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ spCustomizationResource.setModelVersion(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
+ spCustomizationResource.setDescription(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
+
+ spCustomizationResource.setModelCustomizationUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+ spCustomizationResource.setModelInstanceName(nodeTemplate.getName());
+ spCustomizationResource.setToscaNodeType(nodeTemplate.getType());
+
+ String sourceServiceUUID = spMetadata.getValue("sourceModelUuid");
+
+ Service sourceService = serviceRepo.findOneByModelUUID(sourceServiceUUID);
+
+ spCustomizationResource.setSourceService(sourceService);
+ spCustomizationResource.setToscaNodeType(nodeTemplate.getType());
+ serviceProxyCustomizationSet.add(spCustomizationResource);
+
+
+ toscaResourceStructure.setCatalogServiceProxyResourceCustomization(spCustomizationResource);
+
+ return spCustomizationResource;
+ }
+
+ protected ConfigurationResourceCustomization createConfiguration(NodeTemplate nodeTemplate,
+ ToscaResourceStructure toscaResourceStructure, ServiceProxyResourceCustomization spResourceCustomization,
+ Optional<ConfigurationResourceCustomization> vnrResourceCustomization) {
+
+ ConfigurationResourceCustomization configCustomizationResource = getConfigurationResourceCustomization(nodeTemplate,
+ toscaResourceStructure,spResourceCustomization);
+
+ ConfigurationResource configResource = getConfigurationResource(nodeTemplate);
+
+ Set<ConfigurationResourceCustomization> configResourceCustomizationSet = new HashSet<>();
+
+ StatefulEntityType entityType = nodeTemplate.getTypeDefinition();
+ String type = entityType.getType();
+
+ if(NODES_VRF_ENTRY.equals(type)) {
+ configCustomizationResource.setConfigResourceCustomization(vnrResourceCustomization.orElse(null));
+ }
+
+ configCustomizationResource.setConfigurationResource(configResource);
+
+ configResourceCustomizationSet.add(configCustomizationResource);
+
+ configResource.setConfigurationResourceCustomization(configResourceCustomizationSet);
+
+ toscaResourceStructure.setCatalogConfigurationResource(configResource);
+
+ toscaResourceStructure.setCatalogConfigurationResourceCustomization(configCustomizationResource);
+
+ return configCustomizationResource;
+ }
+
+ protected ConfigurationResource createFabricConfiguration(NodeTemplate nodeTemplate, ToscaResourceStructure toscaResourceStructure) {
+
+ Metadata fabricMetadata = nodeTemplate.getMetaData();
+
+ ConfigurationResource configResource = new ConfigurationResource();
+
+ configResource.setModelName(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ configResource.setModelInvariantUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ configResource.setModelUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ configResource.setModelVersion(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
+ configResource.setDescription(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
+ configResource.setToscaNodeType(nodeTemplate.getType());
+
+ return configResource;
+ }
+
+ protected void createToscaCsar(ToscaResourceStructure toscaResourceStructure) {
+ ToscaCsar toscaCsar = new ToscaCsar();
+ if (toscaResourceStructure.getToscaArtifact().getArtifactChecksum() != null) {
+ toscaCsar.setArtifactChecksum(toscaResourceStructure.getToscaArtifact().getArtifactChecksum());
+ } else {
+ toscaCsar.setArtifactChecksum(MANUAL_RECORD);
+ }
+ toscaCsar.setArtifactUUID(toscaResourceStructure.getToscaArtifact().getArtifactUUID());
+ toscaCsar.setName(toscaResourceStructure.getToscaArtifact().getArtifactName());
+ toscaCsar.setVersion(toscaResourceStructure.getToscaArtifact().getArtifactVersion());
+ toscaCsar.setDescription(toscaResourceStructure.getToscaArtifact().getArtifactDescription());
+ toscaCsar.setUrl(toscaResourceStructure.getToscaArtifact().getArtifactURL());
+
+ toscaResourceStructure.setCatalogToscaCsar(toscaCsar);
+ }
+
+ protected VnfcCustomization findExistingVfc(Set<VnfcCustomization> vnfcCustomizations, String customizationUUID) {
+ VnfcCustomization vnfcCustomization = null;
+ for(VnfcCustomization vnfcCustom : vnfcCustomizations){
+ if (vnfcCustom != null && vnfcCustom.getModelCustomizationUUID().equals(customizationUUID)) {
+ vnfcCustomization = vnfcCustom;
+ }
+ }
+
+ if(vnfcCustomization==null)
+ vnfcCustomization = vnfcCustomizationRepo.findOneByModelCustomizationUUID(customizationUUID);
+
+ return vnfcCustomization;
+ }
+
+ protected CvnfcCustomization findExistingCvfc(Set<CvnfcCustomization> cvnfcCustomizations, String customizationUUID) {
+ CvnfcCustomization cvnfcCustomization = null;
+ for(CvnfcCustomization cvnfcCustom : cvnfcCustomizations){
+ if (cvnfcCustom != null && cvnfcCustom.getModelCustomizationUUID().equals(customizationUUID)) {
+ cvnfcCustomization = cvnfcCustom;
+ }
+ }
+
+ if(cvnfcCustomization==null)
+ cvnfcCustomization = cvnfcCustomizationRepo.findOneByModelCustomizationUUID(customizationUUID);
+
+ return cvnfcCustomization;
+ }
+
+ protected NetworkResourceCustomization createNetwork(NodeTemplate networkNodeTemplate,
+ ToscaResourceStructure toscaResourceStructure, HeatTemplate heatTemplate, String aicMax, String aicMin,Service service) {
+
+ NetworkResourceCustomization networkResourceCustomization=networkCustomizationRepo.findOneByModelCustomizationUUID(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+
+ boolean networkUUIDsMatch = true;
+ // Check to make sure the NetworkResourceUUID on the Customization record matches the NetworkResourceUUID from the distribution.
+ // If not we'll update the Customization record with latest from the distribution
+ if(networkResourceCustomization != null){
+ String existingNetworkModelUUID = networkResourceCustomization.getNetworkResource().getModelUUID();
+ String latestNetworkModelUUID = networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID);
+
+ if(!existingNetworkModelUUID.equals(latestNetworkModelUUID)){
+ networkUUIDsMatch = false;
+ }
+
+ }
+
+ if (networkResourceCustomization!=null && !networkUUIDsMatch){
+
+ NetworkResource networkResource = createNetworkResource(networkNodeTemplate, toscaResourceStructure, heatTemplate,
+ aicMax, aicMin);
+
+ networkResourceCustomization.setNetworkResource(networkResource);
+
+ networkCustomizationRepo.saveAndFlush(networkResourceCustomization);
+
+ }
+ else if(networkResourceCustomization==null){
+ networkResourceCustomization = createNetworkResourceCustomization(networkNodeTemplate,
+ toscaResourceStructure);
+
+ NetworkResource networkResource = findExistingNetworkResource(service,
+ networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ if(networkResource == null)
+ networkResource = createNetworkResource(networkNodeTemplate, toscaResourceStructure, heatTemplate,
+ aicMax, aicMin);
+
+ networkResource.addNetworkResourceCustomization(networkResourceCustomization);
+ networkResourceCustomization.setNetworkResource(networkResource);
+ }
+
+ return networkResourceCustomization;
+ }
+
+ protected NetworkResource findExistingNetworkResource(Service service, String modelUUID) {
+ NetworkResource networkResource = null;
+ for(NetworkResourceCustomization networkCustom : service.getNetworkCustomizations()){
+ if (networkCustom.getNetworkResource() != null
+ && networkCustom.getNetworkResource().getModelUUID().equals(modelUUID)) {
+ networkResource = networkCustom.getNetworkResource();
+ }
+ }
+ if(networkResource==null)
+ networkResource = networkRepo.findResourceByModelUUID(modelUUID);
+
+ return networkResource;
+ }
+
+ protected NetworkResourceCustomization createNetworkResourceCustomization(NodeTemplate networkNodeTemplate,
+ ToscaResourceStructure toscaResourceStructure) {
+ NetworkResourceCustomization networkResourceCustomization = new NetworkResourceCustomization();
+ networkResourceCustomization.setModelInstanceName(
+ testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
+ networkResourceCustomization.setModelCustomizationUUID(
+ testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
+
+ networkResourceCustomization.setNetworkTechnology(
+ testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
+ SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY)));
+ networkResourceCustomization.setNetworkType(testNull(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE)));
+ networkResourceCustomization.setNetworkRole(testNull(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKROLE)));
+ networkResourceCustomization.setNetworkScope(testNull(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE)));
+ return networkResourceCustomization;
+ }
+
+ protected NetworkResource createNetworkResource(NodeTemplate networkNodeTemplate,
+ ToscaResourceStructure toscaResourceStructure, HeatTemplate heatTemplate, String aicMax, String aicMin) {
+ NetworkResource networkResource = new NetworkResource();
+ String providerNetwork = toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(
+ networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_ISPROVIDERNETWORK);
+
+ if ("true".equalsIgnoreCase(providerNetwork)) {
+ networkResource.setNeutronNetworkType(PROVIDER);
+ } else {
+ networkResource.setNeutronNetworkType(BASIC);
+ }
+
+ networkResource.setModelName(
+ testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
+
+ networkResource.setModelInvariantUUID(
+ testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
+ networkResource.setModelUUID(
+ testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
+ networkResource.setModelVersion(
+ testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
+
+ networkResource.setAicVersionMax(aicMax);
+ networkResource.setAicVersionMin(aicMin);
+ networkResource.setToscaNodeType(networkNodeTemplate.getType());
+ networkResource.setDescription(
+ testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
+ networkResource.setOrchestrationMode(HEAT);
+ networkResource.setHeatTemplate(heatTemplate);
+ return networkResource;
+ }
+
+ protected CollectionNetworkResourceCustomization createNetworkCollection(NodeTemplate networkNodeTemplate,
+ ToscaResourceStructure toscaResourceStructure, Service service) {
+
+ CollectionNetworkResourceCustomization collectionNetworkResourceCustomization = new CollectionNetworkResourceCustomization();
+
+ // **** Build Object to populate Collection_Resource table
+ CollectionResource collectionResource = new CollectionResource();
+
+ collectionResource
+ .setModelName(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ collectionResource.setModelInvariantUUID(
+ networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ collectionResource
+ .setModelUUID(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ collectionResource
+ .setModelVersion(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
+ collectionResource
+ .setDescription(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
+ collectionResource.setToscaNodeType(networkNodeTemplate.getType());
+
+ toscaResourceStructure.setCatalogCollectionResource(collectionResource);
+
+ // **** Build object to populate Collection_Resource_Customization table
+ NetworkCollectionResourceCustomization ncfc = new NetworkCollectionResourceCustomization();
+
+ ncfc.setFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
+ "cr_function"));
+ ncfc.setRole(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
+ "cr_role"));
+ ncfc.setType(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
+ "cr_type"));
+
+ ncfc.setModelInstanceName(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ ncfc.setModelCustomizationUUID(
+ networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+
+ Set<CollectionNetworkResourceCustomization> networkResourceCustomizationSet = new HashSet<>();
+ networkResourceCustomizationSet.add(collectionNetworkResourceCustomization);
+
+ ncfc.setNetworkResourceCustomization(networkResourceCustomizationSet);
+
+ ncfc.setCollectionResource(collectionResource);
+ toscaResourceStructure.setCatalogCollectionResourceCustomization(ncfc);
+
+ //*** Build object to populate the Instance_Group table
+ List<Group> groupList = toscaResourceStructure.getSdcCsarHelper()
+ .getGroupsOfOriginOfNodeTemplateByToscaGroupType(networkNodeTemplate,
+ "org.openecomp.groups.NetworkCollection");
+
+ List<NetworkInstanceGroup> networkInstanceGroupList = new ArrayList<>();
+
+ List<CollectionResourceInstanceGroupCustomization> collectionResourceInstanceGroupCustomizationList = new ArrayList<CollectionResourceInstanceGroupCustomization>();
+
+ for (Group group : groupList) {
+
+ NetworkInstanceGroup networkInstanceGroup = new NetworkInstanceGroup();
+ Metadata instanceMetadata = group.getMetadata();
+ networkInstanceGroup.setModelName(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ networkInstanceGroup
+ .setModelInvariantUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ networkInstanceGroup.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ networkInstanceGroup.setModelVersion(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
+ networkInstanceGroup.setToscaNodeType(group.getType());
+ networkInstanceGroup.setRole(SubType.SUB_INTERFACE.toString()); // Set
+ // Role
+ networkInstanceGroup.setType(InstanceGroupType.L3_NETWORK); // Set
+ // type
+ networkInstanceGroup.setCollectionResource(collectionResource);
+
+ // ****Build object to populate
+ // Collection_Resource_Instance_Group_Customization table
+ CollectionResourceInstanceGroupCustomization crInstanceGroupCustomization = new CollectionResourceInstanceGroupCustomization();
+ crInstanceGroupCustomization.setInstanceGroup(networkInstanceGroup);
+ crInstanceGroupCustomization.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ crInstanceGroupCustomization.setModelCustomizationUUID(
+ networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+
+ // Loop through the template policy to find the subinterface_network_quantity property name. Then extract the value for it.
+ List<Policy> policyList = toscaResourceStructure.getSdcCsarHelper().getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(networkNodeTemplate, "org.openecomp.policies.scaling.Fixed");
+
+ if(policyList != null){
+ for(Policy policy : policyList){
+ for(String policyNetworkCollection : policy.getTargets()){
+
+ if(policyNetworkCollection.equalsIgnoreCase(group.getName())){
+
+ Map<String, Object> propMap = policy.getPolicyProperties();
+
+ if(propMap.get("quantity") != null){
+
+ String quantity = toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate, getPropertyInput(propMap.get("quantity").toString()));
+
+ if(quantity != null){
+ crInstanceGroupCustomization.setSubInterfaceNetworkQuantity(Integer.parseInt(quantity));
+ }
+
+ }
+
+ }
+ }
+ }
+ }
+
+ crInstanceGroupCustomization.setDescription(
+ toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
+ instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)
+ + "_network_collection_description"));
+ crInstanceGroupCustomization.setFunction(
+ toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
+ instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)
+ + "_network_collection_function"));
+ crInstanceGroupCustomization.setCollectionResourceCust(ncfc);
+ collectionResourceInstanceGroupCustomizationList.add(crInstanceGroupCustomization);
+
+ networkInstanceGroup
+ .setCollectionInstanceGroupCustomizations(collectionResourceInstanceGroupCustomizationList);
+
+ networkInstanceGroupList.add(networkInstanceGroup);
+
+
+ toscaResourceStructure.setCatalogNetworkInstanceGroup(networkInstanceGroupList);
+
+ List<NodeTemplate> vlNodeList = toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplateBySdcType(networkNodeTemplate, SdcTypes.VL);
+
+ List<CollectionNetworkResourceCustomization> collectionNetworkResourceCustomizationList = new ArrayList<>();
+
+ //*****Build object to populate the NetworkResource table
+ NetworkResource networkResource = new NetworkResource();
+
+ for(NodeTemplate vlNodeTemplate : vlNodeList){
+
+ String providerNetwork = toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(
+ vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_ISPROVIDERNETWORK);
+
+ if ("true".equalsIgnoreCase(providerNetwork)) {
+ networkResource.setNeutronNetworkType(PROVIDER);
+ } else {
+ networkResource.setNeutronNetworkType(BASIC);
+ }
+
+ networkResource.setModelName(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+
+ networkResource.setModelInvariantUUID(
+ vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ networkResource.setModelUUID(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ networkResource
+ .setModelVersion(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
+
+ networkResource.setAicVersionMax(
+ vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES));
+
+ TempNetworkHeatTemplateLookup tempNetworkLookUp = tempNetworkLookupRepo.findFirstBynetworkResourceModelName(
+ vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+
+ if (tempNetworkLookUp != null ) {
+
+ HeatTemplate heatTemplate = heatRepo
+ .findByArtifactUuid(tempNetworkLookUp.getHeatTemplateArtifactUuid());
+ networkResource.setHeatTemplate(heatTemplate);
+
+ networkResource.setAicVersionMin(tempNetworkLookUp.getAicVersionMin());
+
+ }
+
+ networkResource.setToscaNodeType(vlNodeTemplate.getType());
+ networkResource
+ .setDescription(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
+ networkResource.setOrchestrationMode(HEAT);
+
+ // Build object to populate the
+ // Collection_Network_Resource_Customization table
+ for (NodeTemplate memberNode : group.getMemberNodes()) {
+ collectionNetworkResourceCustomization.setModelInstanceName(memberNode.getName());
+ }
+
+ collectionNetworkResourceCustomization.setModelCustomizationUUID(
+ vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+
+ collectionNetworkResourceCustomization.setNetworkTechnology(
+ toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vlNodeTemplate,
+ SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY));
+ collectionNetworkResourceCustomization.setNetworkType(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE));
+ collectionNetworkResourceCustomization.setNetworkRole(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKROLE));
+ collectionNetworkResourceCustomization.setNetworkScope(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE));
+ collectionNetworkResourceCustomization.setInstanceGroup(networkInstanceGroup);
+ collectionNetworkResourceCustomization.setNetworkResource(networkResource);
+ collectionNetworkResourceCustomization.setNetworkResourceCustomization(ncfc);
+
+ collectionNetworkResourceCustomizationList.add(collectionNetworkResourceCustomization);
+ }
+
+ }
+
+ return collectionNetworkResourceCustomization;
+ }
+
+ protected VnfcInstanceGroupCustomization createVNFCInstanceGroup(NodeTemplate vnfcNodeTemplate, Group group,
+ VnfResourceCustomization vnfResourceCustomization, ToscaResourceStructure toscaResourceStructure) {
+
+ Metadata instanceMetadata = group.getMetadata();
+ // Populate InstanceGroup
+ VFCInstanceGroup vfcInstanceGroup = new VFCInstanceGroup();
+
+ vfcInstanceGroup.setModelName(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ vfcInstanceGroup.setModelInvariantUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ vfcInstanceGroup.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ vfcInstanceGroup.setModelVersion(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
+ vfcInstanceGroup.setToscaNodeType(group.getType());
+ vfcInstanceGroup.setRole("SUB-INTERFACE"); // Set Role
+ vfcInstanceGroup.setType(InstanceGroupType.VNFC); // Set type
+
+ //Populate VNFCInstanceGroupCustomization
+ VnfcInstanceGroupCustomization vfcInstanceGroupCustom = new VnfcInstanceGroupCustomization();
+
+ vfcInstanceGroupCustom.setModelCustomizationUUID(vnfResourceCustomization.getModelCustomizationUUID());
+ vfcInstanceGroupCustom.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ vfcInstanceGroupCustom.setDescription(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
+
+ String getInputName = null;
+ String groupProperty = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group, "vfc_instance_group_function");
+ if (groupProperty != null) {
+ int getInputIndex = groupProperty.indexOf("{get_input=");
+ if (getInputIndex > -1) {
+ getInputName = groupProperty.substring(getInputIndex+11, groupProperty.length()-1);
+ }
+ }
+ vfcInstanceGroupCustom.setFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vnfcNodeTemplate, getInputName));
+
+ vfcInstanceGroupCustom.setInstanceGroup(vfcInstanceGroup);
+ vfcInstanceGroupCustom.setVnfResourceCust(vnfResourceCustomization);
+
+ return vfcInstanceGroupCustom;
+
+ }
+
+ protected VfModuleCustomization createVFModuleResource(Group group, NodeTemplate vfTemplate,
+ ToscaResourceStructure toscaResourceStructure, VfResourceStructure vfResourceStructure,
+ IVfModuleData vfModuleData, VnfResourceCustomization vnfResource, Service service, Set<CvnfcCustomization> existingCvnfcSet, Set<VnfcCustomization> existingVnfcSet) {
+
+ VfModuleCustomization vfModuleCustomization = findExistingVfModuleCustomization(vnfResource,
+ vfModuleData.getVfModuleModelCustomizationUUID());
+ if(vfModuleCustomization == null){
+ VfModule vfModule = findExistingVfModule(vnfResource,
+ vfTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID));
+ Metadata vfMetadata = group.getMetadata();
+ if(vfModule==null)
+ vfModule=createVfModule(group, toscaResourceStructure, vfModuleData, vfMetadata);
+
+ vfModuleCustomization = createVfModuleCustomization(group, toscaResourceStructure, vfModule, vfModuleData);
+ setHeatInformationForVfModule(toscaResourceStructure, vfResourceStructure, vfModule, vfModuleCustomization,
+ vfMetadata);
+ vfModuleCustomization.setVfModule(vfModule);
+ vfModule.getVfModuleCustomization().add(vfModuleCustomization);
+ vnfResource.getVfModuleCustomizations().add(vfModuleCustomization);
+ } else {
+ vfResourceStructure.setAlreadyDeployed(true);
+ }
+
+ //******************************************************************************************************************
+ //* Extract VFC's and CVFC's then add them to VFModule
+ //******************************************************************************************************************
+
+ Set<VnfVfmoduleCvnfcConfigurationCustomization> vnfVfmoduleCvnfcConfigurationCustomizations = new HashSet<VnfVfmoduleCvnfcConfigurationCustomization>();
+ Set<CvnfcCustomization> cvnfcCustomizations = new HashSet<CvnfcCustomization>();
+ Set<VnfcCustomization> vnfcCustomizations = new HashSet<VnfcCustomization>();
+
+ // Only set the CVNFC if this vfModule group is a member of it.
+ List<NodeTemplate> groupMembers = toscaResourceStructure.getSdcCsarHelper().getMembersOfVfModule(vfTemplate, group);
+ String vfModuleMemberName = null;
+
+ // Extract CVFC lists
+ List<NodeTemplate> cvfcList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(vfTemplate, SdcTypes.CVFC);
+
+ for(NodeTemplate cvfcTemplate : cvfcList) {
+
+ boolean cvnfcVfModuleNameMatch = false;
+
+ for(NodeTemplate node : groupMembers){
+ vfModuleMemberName = node.getName();
+
+ if(vfModuleMemberName.equalsIgnoreCase(cvfcTemplate.getName())){
+ cvnfcVfModuleNameMatch = true;
+ break;
+ }
+ }
+
+ if(vfModuleMemberName != null && cvnfcVfModuleNameMatch){
+
+ //Extract associated VFC - Should always be just one
+ List<NodeTemplate> vfcList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(cvfcTemplate, SdcTypes.VFC);
+
+ for(NodeTemplate vfcTemplate : vfcList) {
+
+ VnfcCustomization vnfcCustomization = new VnfcCustomization();
+ VnfcCustomization existingVnfcCustomization = null;
+
+ existingVnfcCustomization = findExistingVfc(existingVnfcSet, vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+
+ if(existingVnfcCustomization == null){
+ vnfcCustomization = new VnfcCustomization();
+ } else {
+ vnfcCustomization = existingVnfcCustomization;
+ }
+
+ // Only Add Abstract VNFC's to our DB, ignore all others
+ if(existingVnfcCustomization == null && vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY).equalsIgnoreCase("Abstract")){
+ vnfcCustomization.setModelCustomizationUUID(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+ vnfcCustomization.setModelInstanceName(vfcTemplate.getName());
+ vnfcCustomization.setModelInvariantUUID(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ vnfcCustomization.setModelName(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ vnfcCustomization.setModelUUID(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+
+ vnfcCustomization.setModelVersion(
+ testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
+ vnfcCustomization.setDescription(
+ testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
+ vnfcCustomization.setToscaNodeType(testNull(vfcTemplate.getType()));
+
+ vnfcCustomizations.add(vnfcCustomization);
+ existingVnfcSet.add(vnfcCustomization);
+ }
+
+ // This check is needed incase the VFC subcategory is something other than Abstract. In that case we want to skip adding that record to our DB.
+ if(vnfcCustomization.getModelCustomizationUUID() != null){
+
+ CvnfcCustomization cvnfcCustomization = new CvnfcCustomization();
+
+ cvnfcCustomization = new CvnfcCustomization();
+ cvnfcCustomization.setModelCustomizationUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+ cvnfcCustomization.setModelInstanceName(cvfcTemplate.getName());
+ cvnfcCustomization.setModelInvariantUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ cvnfcCustomization.setModelName(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ cvnfcCustomization.setModelUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+
+ cvnfcCustomization.setModelVersion(
+ testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
+ cvnfcCustomization.setDescription(
+ testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
+ cvnfcCustomization.setToscaNodeType(testNull(cvfcTemplate.getType()));
+
+ if(existingVnfcCustomization != null){
+ cvnfcCustomization.setVnfcCustomization(existingVnfcCustomization);
+ }else{
+ cvnfcCustomization.setVnfcCustomization(vnfcCustomization);
+ }
+
+ cvnfcCustomization.setNfcFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(cvfcTemplate, "nfc_function"));
+ cvnfcCustomization.setNfcNamingCode(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(cvfcTemplate, "nfc_naming_code"));
+ cvnfcCustomization.setVfModuleCustomization(vfModuleCustomization);
+ cvnfcCustomization.setVnfResourceCustomization(vnfResource);
+
+ cvnfcCustomizations.add(cvnfcCustomization);
+ existingCvnfcSet.add(cvnfcCustomization);
+
+ //*****************************************************************************************************************************************
+ //* Extract Fabric Configuration
+ //*****************************************************************************************************************************************
+
+ List<NodeTemplate> fabricConfigList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(vfTemplate, SdcTypes.CONFIGURATION);
+
+ for(NodeTemplate fabricTemplate : fabricConfigList) {
+
+ ConfigurationResource fabricConfig = null;
+
+ ConfigurationResource existingConfig = findExistingConfiguration(service, fabricTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+
+ if(existingConfig == null){
+
+ fabricConfig = createFabricConfiguration(fabricTemplate, toscaResourceStructure);
+
+ }else {
+ fabricConfig = existingConfig;
+ }
+
+ VnfVfmoduleCvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization = createVfCnvfConfigCustomization(fabricTemplate, toscaResourceStructure,
+ vnfResource, vfModuleCustomization, cvnfcCustomization, fabricConfig, vfTemplate, vfModuleMemberName);
+ vnfVfmoduleCvnfcConfigurationCustomizations.add(vnfVfmoduleCvnfcConfigurationCustomization);
+ }
+ cvnfcCustomization.setVnfVfmoduleCvnfcConfigurationCustomization(vnfVfmoduleCvnfcConfigurationCustomizations);
+ }
+
+ }
+
+ }
+ }
+ vfModuleCustomization.setCvnfcCustomization(cvnfcCustomizations);
+ vfModuleCustomization.setVnfVfmoduleCvnfcConfigurationCustomization(vnfVfmoduleCvnfcConfigurationCustomizations);
+
+ return vfModuleCustomization;
+ }
+
+ protected VnfVfmoduleCvnfcConfigurationCustomization createVfCnvfConfigCustomization(NodeTemplate fabricTemplate, ToscaResourceStructure toscaResourceStruct,
+ VnfResourceCustomization vnfResource, VfModuleCustomization vfModuleCustomization, CvnfcCustomization cvnfcCustomization,
+ ConfigurationResource configResource, NodeTemplate vfTemplate, String vfModuleMemberName) {
+
+ Metadata fabricMetadata = fabricTemplate.getMetaData();
+
+ VnfVfmoduleCvnfcConfigurationCustomization vfModuleToCvnfc = new VnfVfmoduleCvnfcConfigurationCustomization();
+
+ vfModuleToCvnfc.setConfigurationResource(configResource);
+ vfModuleToCvnfc.setCvnfcCustomization(cvnfcCustomization);
+ vfModuleToCvnfc.setModelCustomizationUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+ vfModuleToCvnfc.setModelInstanceName(fabricTemplate.getName());
+ vfModuleToCvnfc.setVfModuleCustomization(vfModuleCustomization);
+ vfModuleToCvnfc.setVnfResourceCustomization(vnfResource);
+
+ List<Policy> policyList = toscaResourceStruct.getSdcCsarHelper().getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(vfTemplate, "org.openecomp.policies.External");
+
+ if(policyList != null){
+ for(Policy policy : policyList){
+
+ for(String policyCvfcTarget : policy.getTargets()){
+
+ if(policyCvfcTarget.equalsIgnoreCase(vfModuleMemberName)){
+
+ Map<String, Object> propMap = policy.getPolicyProperties();
+
+ if(propMap.get("type").toString().equalsIgnoreCase("Fabric Policy")){
+ vfModuleToCvnfc.setPolicyName(propMap.get("name").toString());
+ }
+ }
+ }
+ }
+ }
+
+ vfModuleToCvnfc.setConfigurationFunction(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "function"));
+ vfModuleToCvnfc.setConfigurationRole(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "role"));
+ vfModuleToCvnfc.setConfigurationType(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "type"));
+
+ return vfModuleToCvnfc;
+ }
+
+ protected ConfigurationResource findExistingConfiguration(Service service, String modelUUID) {
+ ConfigurationResource configResource = null;
+ for(ConfigurationResourceCustomization configurationResourceCustom : service.getConfigurationCustomizations()){
+ if (configurationResourceCustom.getConfigurationResource() != null
+ && configurationResourceCustom.getConfigurationResource().getModelUUID().equals(modelUUID)) {
+ configResource = configurationResourceCustom.getConfigurationResource();
+ }
+ }
+ if(configResource==null)
+ configResource = configRepo.findResourceByModelUUID(modelUUID);
+
+ return configResource;
+ }
+
+ protected VfModuleCustomization findExistingVfModuleCustomization(VnfResourceCustomization vnfResource,
+ String vfModuleModelCustomizationUUID) {
+ VfModuleCustomization vfModuleCustomization = null;
+ for(VfModuleCustomization vfModuleCustom : vnfResource.getVfModuleCustomizations()){
+ if(vfModuleCustom.getModelCustomizationUUID().equalsIgnoreCase(vfModuleModelCustomizationUUID)){
+ vfModuleCustomization = vfModuleCustom;
+ }
+ }
+ if(vfModuleCustomization==null)
+ vfModuleCustomization = vfModuleCustomizationRepo
+ .findByModelCustomizationUUID(vfModuleModelCustomizationUUID);
+
+ return vfModuleCustomization;
+ }
+
+ protected VfModule findExistingVfModule(VnfResourceCustomization vnfResource, String modelUUID) {
+ VfModule vfModule = null;
+ for(VfModuleCustomization vfModuleCustom : vnfResource.getVfModuleCustomizations()){
+ if(vfModuleCustom.getVfModule() != null && vfModuleCustom.getVfModule().getModelUUID().equals(modelUUID)){
+ vfModule = vfModuleCustom.getVfModule();
+ }
+ }
+ if(vfModule==null)
+ vfModule = vfModuleRepo.findByModelUUID(modelUUID);
+
+ return vfModule;
+ }
+
+ protected VfModuleCustomization createVfModuleCustomization(Group group,
+ ToscaResourceStructure toscaResourceStructure, VfModule vfModule, IVfModuleData vfModuleData) {
+ VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
+
+ vfModuleCustomization.setModelCustomizationUUID(vfModuleData.getVfModuleModelCustomizationUUID());
+
+ vfModuleCustomization.setVfModule(vfModule);
+
+ String initialCount = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
+ SdcPropertyNames.PROPERTY_NAME_INITIALCOUNT);
+ if (initialCount != null && initialCount.length() > 0) {
+ vfModuleCustomization.setInitialCount(Integer.valueOf(initialCount));
+ }
+
+ vfModuleCustomization.setInitialCount(Integer.valueOf(toscaResourceStructure.getSdcCsarHelper()
+ .getGroupPropertyLeafValue(group, SdcPropertyNames.PROPERTY_NAME_INITIALCOUNT)));
+
+ String availabilityZoneCount = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
+ SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT);
+ if (availabilityZoneCount != null && availabilityZoneCount.length() > 0) {
+ vfModuleCustomization.setAvailabilityZoneCount(Integer.valueOf(availabilityZoneCount));
+ }
+
+ vfModuleCustomization.setLabel(toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
+ SdcPropertyNames.PROPERTY_NAME_VFMODULELABEL));
+
+ String maxInstances = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
+ SdcPropertyNames.PROPERTY_NAME_MAXVFMODULEINSTANCES);
+ if (maxInstances != null && maxInstances.length() > 0) {
+ vfModuleCustomization.setMaxInstances(Integer.valueOf(maxInstances));
+ }
+
+ String minInstances = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
+ SdcPropertyNames.PROPERTY_NAME_MINVFMODULEINSTANCES);
+ if (minInstances != null && minInstances.length() > 0) {
+ vfModuleCustomization.setMinInstances(Integer.valueOf(minInstances));
+ }
+ return vfModuleCustomization;
+ }
+
+ protected VfModule createVfModule(Group group, ToscaResourceStructure toscaResourceStructure,
+ IVfModuleData vfModuleData, Metadata vfMetadata) {
+ VfModule vfModule = new VfModule();
+ String vfModuleModelUUID = vfModuleData.getVfModuleModelUUID();
+
+ if(vfModuleModelUUID == null) {
+ vfModuleModelUUID = testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
+ SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID));
+ } else if (vfModuleModelUUID.indexOf('.') > -1) {
+ vfModuleModelUUID = vfModuleModelUUID.substring(0, vfModuleModelUUID.indexOf('.'));
+ }
+
+ vfModule.setModelInvariantUUID(testNull(toscaResourceStructure.getSdcCsarHelper()
+ .getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID)));
+ vfModule.setModelName(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
+ SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELNAME)));
+ vfModule.setModelUUID(vfModuleModelUUID);
+ vfModule.setModelVersion(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
+ SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELVERSION)));
+ vfModule.setDescription(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
+ SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
+
+ String vfModuleType = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
+ SdcPropertyNames.PROPERTY_NAME_VFMODULETYPE);
+ if (vfModuleType != null && "Base".equalsIgnoreCase(vfModuleType)) {
+ vfModule.setIsBase(true);
+ } else {
+ vfModule.setIsBase(false);
+ }
+ return vfModule;
+ }
+
+ protected void setHeatInformationForVfModule(ToscaResourceStructure toscaResourceStructure,
+ VfResourceStructure vfResourceStructure, VfModule vfModule, VfModuleCustomization vfModuleCustomization,
+ Metadata vfMetadata) {
+
+ Optional<VfModuleStructure> matchingObject = vfResourceStructure.getVfModuleStructure().stream()
+ .filter(vfModuleStruct -> vfModuleStruct.getVfModuleMetadata().getVfModuleModelUUID()
+ .equalsIgnoreCase(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
+ SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID)))
+ .findFirst();
+
+ if (matchingObject.isPresent()) {
+ List<HeatFiles> heatFilesList = new ArrayList<>();
+ List<HeatTemplate> volumeHeatChildTemplates = new ArrayList<HeatTemplate>();
+ List<HeatTemplate> heatChildTemplates = new ArrayList<HeatTemplate>();
+ HeatTemplate parentHeatTemplate = new HeatTemplate();
+ String parentArtifactType = null;
+ Set<String> artifacts = new HashSet<>(matchingObject.get().getVfModuleMetadata().getArtifacts());
+ for (VfModuleArtifact vfModuleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
+
+ List<HeatTemplate> childNestedHeatTemplates = new ArrayList<HeatTemplate>();
+
+ if (artifacts.contains(vfModuleArtifact.getArtifactInfo().getArtifactUUID())) {
+ checkVfModuleArtifactType(vfModule, vfModuleCustomization, heatFilesList, vfModuleArtifact,
+ childNestedHeatTemplates, parentHeatTemplate, vfResourceStructure);
+ }
+
+ if(vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_NESTED)){
+ parentArtifactType = identifyParentOfNestedTemplate(matchingObject.get(), vfModuleArtifact);
+
+ if(!childNestedHeatTemplates.isEmpty()){
+
+ if (parentArtifactType != null && parentArtifactType.equalsIgnoreCase(ASDCConfiguration.HEAT_VOL)) {
+ volumeHeatChildTemplates.add(childNestedHeatTemplates.get(0));
+ } else {
+ heatChildTemplates.add(childNestedHeatTemplates.get(0));
+ }
+ }
+ }
+
+ }
+ if(!heatFilesList.isEmpty()){
+ vfModule.setHeatFiles(heatFilesList);
+ }
+
+
+ // Set all Child Templates related to HEAT_VOLUME
+ if(!volumeHeatChildTemplates.isEmpty()){
+ if(vfModule.getVolumeHeatTemplate() != null){
+ vfModule.getVolumeHeatTemplate().setChildTemplates(volumeHeatChildTemplates);
+ }else{
+ logger.debug("VolumeHeatTemplate not set in setHeatInformationForVfModule()");
+ }
+ }
+
+ // Set all Child Templates related to HEAT
+ if(!heatChildTemplates.isEmpty()){
+ if(vfModule.getModuleHeatTemplate() != null){
+ vfModule.getModuleHeatTemplate().setChildTemplates(heatChildTemplates);
+ }else{
+ logger.debug("ModuleHeatTemplate not set in setHeatInformationForVfModule()");
+ }
+ }
+ }
+ }
+
+ protected void checkVfModuleArtifactType(VfModule vfModule, VfModuleCustomization vfModuleCustomization,
+ List<HeatFiles> heatFilesList, VfModuleArtifact vfModuleArtifact, List<HeatTemplate> nestedHeatTemplates,
+ HeatTemplate parentHeatTemplate, VfResourceStructure vfResourceStructure) {
+ if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT)) {
+ vfModuleArtifact.incrementDeployedInDB();
+ vfModule.setModuleHeatTemplate(vfModuleArtifact.getHeatTemplate());
+ } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_VOL)) {
+ vfModule.setVolumeHeatTemplate(vfModuleArtifact.getHeatTemplate());
+ VfModuleArtifact volVfModuleArtifact = this.getHeatEnvArtifactFromGeneratedArtifact(vfResourceStructure, vfModuleArtifact);
+ vfModuleCustomization.setVolumeHeatEnv(volVfModuleArtifact.getHeatEnvironment());
+ vfModuleArtifact.incrementDeployedInDB();
+ } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ENV)) {
+ if(vfModuleArtifact.getHeatEnvironment().getName().contains("volume")) {
+ vfModuleCustomization.setVolumeHeatEnv(vfModuleArtifact.getHeatEnvironment());
+ } else {
+ vfModuleCustomization.setHeatEnvironment(vfModuleArtifact.getHeatEnvironment());
+ }
+ vfModuleArtifact.incrementDeployedInDB();
+ } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ARTIFACT)) {
+ heatFilesList.add(vfModuleArtifact.getHeatFiles());
+ vfModuleArtifact.incrementDeployedInDB();
+ } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_NESTED)) {
+ nestedHeatTemplates.add(vfModuleArtifact.getHeatTemplate());
+ vfModuleArtifact.incrementDeployedInDB();
+ }
+ }
+
+ protected VnfResourceCustomization createVnfResource(NodeTemplate vfNodeTemplate,
+ ToscaResourceStructure toscaResourceStructure, Service service) {
+ VnfResourceCustomization vnfResourceCustomization = vnfCustomizationRepo.findOneByModelCustomizationUUID(
+ vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+ if(vnfResourceCustomization == null){
+ VnfResource vnfResource = findExistingVnfResource(service,
+ vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+
+ if(vnfResource==null)
+ vnfResource=createVnfResource(vfNodeTemplate);
+
+ vnfResourceCustomization = createVnfResourceCustomization(vfNodeTemplate, toscaResourceStructure,
+ vnfResource);
+ vnfResourceCustomization.setVnfResources(vnfResource);
+ vnfResource.getVnfResourceCustomizations().add(vnfResourceCustomization);
+
+ // Fetch VNFC Instance Group Info
+ List<Group> groupList = toscaResourceStructure.getSdcCsarHelper()
+ .getGroupsOfOriginOfNodeTemplateByToscaGroupType(vfNodeTemplate,
+ "org.openecomp.groups.VfcInstanceGroup");
+
+ for (Group group : groupList) {
+
+ VnfcInstanceGroupCustomization vnfcInstanceGroupCustomization = createVNFCInstanceGroup(vfNodeTemplate, group, vnfResourceCustomization, toscaResourceStructure);
+
+ vnfcInstanceGroupCustomizationRepo.saveAndFlush(vnfcInstanceGroupCustomization);
+ }
+ }
+ return vnfResourceCustomization;
+ }
+
+ protected VnfResource findExistingVnfResource(Service service, String modelUUID) {
+ VnfResource vnfResource = null;
+ for(VnfResourceCustomization vnfResourceCustom : service.getVnfCustomizations()){
+ if (vnfResourceCustom.getVnfResources() != null
+ && vnfResourceCustom.getVnfResources().getModelUUID().equals(modelUUID)) {
+ vnfResource = vnfResourceCustom.getVnfResources();
+ }
+ }
+ if(vnfResource==null)
+ vnfResource = vnfRepo.findResourceByModelUUID(modelUUID);
+
+ return vnfResource;
+ }
+
+ protected VnfResourceCustomization createVnfResourceCustomization(NodeTemplate vfNodeTemplate,
+ ToscaResourceStructure toscaResourceStructure, VnfResource vnfResource) {
+ VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization();
+ vnfResourceCustomization.setModelCustomizationUUID(
+ testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
+ vnfResourceCustomization.setModelInstanceName(vfNodeTemplate.getName());
+
+ vnfResourceCustomization.setNfFunction(testNull(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)));
+ vnfResourceCustomization.setNfNamingCode(testNull(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(vfNodeTemplate, "nf_naming_code")));
+ vnfResourceCustomization.setNfRole(testNull(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE)));
+ vnfResourceCustomization.setNfType(testNull(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE)));
+
+ vnfResourceCustomization.setMultiStageDesign(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(vfNodeTemplate, MULTI_STAGE_DESIGN));
+
+ vnfResourceCustomization.setBlueprintName(testNull(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SDNC_MODEL_NAME)));
+
+ vnfResourceCustomization.setBlueprintVersion(testNull(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SDNC_MODEL_VERSION)));
+
+ vnfResourceCustomization.setVnfResources(vnfResource);
+ vnfResourceCustomization.setAvailabilityZoneMaxCount(Integer.getInteger(
+ vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT)));
+
+ CapabilityAssignments vnfCustomizationCapability = toscaResourceStructure.getSdcCsarHelper()
+ .getCapabilitiesOf(vfNodeTemplate);
+
+ if (vnfCustomizationCapability != null) {
+ CapabilityAssignment capAssign = vnfCustomizationCapability.getCapabilityByName(SCALABLE);
+
+ if (capAssign != null) {
+ vnfResourceCustomization.setMinInstances(Integer.getInteger(toscaResourceStructure.getSdcCsarHelper()
+ .getCapabilityPropertyLeafValue(capAssign, SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
+ vnfResourceCustomization.setMaxInstances(Integer.getInteger(toscaResourceStructure.getSdcCsarHelper()
+ .getCapabilityPropertyLeafValue(capAssign, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
+ }
+
+ }
+
+ toscaResourceStructure.setCatalogVnfResourceCustomization(vnfResourceCustomization);
+
+ return vnfResourceCustomization;
+ }
+
+ protected VnfResource createVnfResource(NodeTemplate vfNodeTemplate) {
+ VnfResource vnfResource = new VnfResource();
+ vnfResource.setModelInvariantUUID(
+ testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
+ vnfResource.setModelName(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
+ vnfResource.setModelUUID(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
+
+ vnfResource.setModelVersion(
+ testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
+ vnfResource.setDescription(
+ testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
+ vnfResource.setOrchestrationMode(HEAT);
+ vnfResource.setToscaNodeType(testNull(vfNodeTemplate.getType()));
+ vnfResource.setAicVersionMax(
+ testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
+ vnfResource.setAicVersionMin(
+ testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
+ vnfResource.setCategory(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY));
+ vnfResource.setSubCategory(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY));
+
+ return vnfResource;
+ }
+
+ protected AllottedResourceCustomization createAllottedResource(NodeTemplate nodeTemplate,
+ ToscaResourceStructure toscaResourceStructure, Service service) {
+ AllottedResourceCustomization allottedResourceCustomization = allottedCustomizationRepo
+ .findOneByModelCustomizationUUID(
+ nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+
+ if(allottedResourceCustomization == null){
+ AllottedResource allottedResource = findExistingAllottedResource(service,
+ nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+
+ if(allottedResource==null)
+ allottedResource=createAR(nodeTemplate);
+
+ toscaResourceStructure.setAllottedResource(allottedResource);
+ allottedResourceCustomization = createAllottedResourceCustomization(nodeTemplate, toscaResourceStructure);
+ allottedResourceCustomization.setAllottedResource(allottedResource);
+ allottedResource.getAllotedResourceCustomization().add(allottedResourceCustomization);
+ }
+ return allottedResourceCustomization;
+ }
+
+ protected AllottedResource findExistingAllottedResource(Service service, String modelUUID) {
+ AllottedResource allottedResource = null;
+ for(AllottedResourceCustomization allottedResourceCustom : service.getAllottedCustomizations()){
+ if (allottedResourceCustom.getAllottedResource() != null
+ && allottedResourceCustom.getAllottedResource().getModelUUID().equals(modelUUID)) {
+ allottedResource = allottedResourceCustom.getAllottedResource();
+ }
+ }
+ if(allottedResource==null)
+ allottedResource = allottedRepo.findResourceByModelUUID(modelUUID);
+
+ return allottedResource;
+ }
+
+ protected AllottedResourceCustomization createAllottedResourceCustomization(NodeTemplate nodeTemplate,
+ ToscaResourceStructure toscaResourceStructure) {
+ AllottedResourceCustomization allottedResourceCustomization = new AllottedResourceCustomization();
+ allottedResourceCustomization.setModelCustomizationUUID(
+ testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
+ allottedResourceCustomization.setModelInstanceName(nodeTemplate.getName());
+
+
+ allottedResourceCustomization.setNfFunction(testNull(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)));
+ allottedResourceCustomization.setNfNamingCode(testNull(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(nodeTemplate, "nf_naming_code")));
+ allottedResourceCustomization.setNfRole(testNull(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE)));
+ allottedResourceCustomization.setNfType(testNull(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE)));
+
+ List<NodeTemplate> vfcNodes = toscaResourceStructure.getSdcCsarHelper().getVfcListByVf(allottedResourceCustomization.getModelCustomizationUUID());
+
+ if(vfcNodes != null){
+ for(NodeTemplate vfcNode : vfcNodes){
+
+ allottedResourceCustomization.setProvidingServiceModelUUID(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_uuid"));
+ allottedResourceCustomization.setProvidingServiceModelInvariantUUID(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_invariant_uuid"));
+ allottedResourceCustomization.setProvidingServiceModelName(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_name"));
+ }
+ }
+
+
+ CapabilityAssignments arCustomizationCapability = toscaResourceStructure.getSdcCsarHelper()
+ .getCapabilitiesOf(nodeTemplate);
+
+ if (arCustomizationCapability != null) {
+ CapabilityAssignment capAssign = arCustomizationCapability.getCapabilityByName(SCALABLE);
+
+ if (capAssign != null) {
+ allottedResourceCustomization.setMinInstances(
+ Integer.getInteger(toscaResourceStructure.getSdcCsarHelper().getCapabilityPropertyLeafValue(
+ capAssign, SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
+ allottedResourceCustomization.setMaxInstances(
+ Integer.getInteger(toscaResourceStructure.getSdcCsarHelper().getCapabilityPropertyLeafValue(
+ capAssign, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
+ }
+ }
+ return allottedResourceCustomization;
+ }
+
+ protected AllottedResource createAR(NodeTemplate nodeTemplate) {
+ AllottedResource allottedResource = new AllottedResource();
+ allottedResource
+ .setModelUUID(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
+ allottedResource.setModelInvariantUUID(
+ testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
+ allottedResource
+ .setModelName(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
+ allottedResource
+ .setModelVersion(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
+ allottedResource.setToscaNodeType(testNull(nodeTemplate.getType()));
+ allottedResource.setSubcategory(
+ testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY)));
+ allottedResource
+ .setDescription(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
+ return allottedResource;
+ }
+
+ protected Set<HeatTemplateParam> extractHeatTemplateParameters(String yamlFile, String artifactUUID) {
+ // Scan the payload downloadResult and extract the HeatTemplate
+ // parameters
+ YamlEditor yamlEditor = new YamlEditor(yamlFile.getBytes());
+ return yamlEditor.getParameterList(artifactUUID);
+ }
+
+ protected String testNull(Object object) {
+
+ if (object == null) {
+ return null;
+ } else if (object.equals("NULL")) {
+ return null;
+ } else if (object instanceof Integer) {
+ return object.toString();
+ } else if (object instanceof String) {
+ return (String) object;
+ } else {
+ return "Type not recognized";
+ }
+ }
+
+ protected static String identifyParentOfNestedTemplate(VfModuleStructure vfModuleStructure,
+ VfModuleArtifact heatNestedArtifact) {
+
+ if (vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT) != null && vfModuleStructure
+ .getArtifactsMap().get(ASDCConfiguration.HEAT).get(0).getArtifactInfo().getRelatedArtifacts() != null) {
+ for (IArtifactInfo unknownArtifact : vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT).get(0)
+ .getArtifactInfo().getRelatedArtifacts()) {
+ if (heatNestedArtifact.getArtifactInfo().getArtifactUUID().equals(unknownArtifact.getArtifactUUID())) {
+ return ASDCConfiguration.HEAT;
+ }
+
+ }
+ }
+
+ if (vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL) != null
+ && vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0).getArtifactInfo()
+ .getRelatedArtifacts() != null) {
+ for (IArtifactInfo unknownArtifact : vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL)
+ .get(0).getArtifactInfo().getRelatedArtifacts()) {
+ if (heatNestedArtifact.getArtifactInfo().getArtifactUUID().equals(unknownArtifact.getArtifactUUID())) {
+ return ASDCConfiguration.HEAT_VOL;
+ }
+
+ }
+ }
+
+ // Does not belong to anything
+ return null;
+
+ }
+
+ protected static String createVNFName(VfResourceStructure vfResourceStructure) {
+
+ return vfResourceStructure.getNotification().getServiceName() + "/"
+ + vfResourceStructure.getResourceInstance().getResourceInstanceName();
+ }
+
+ protected static String createVfModuleName(VfModuleStructure vfModuleStructure) {
+
+ return createVNFName(vfModuleStructure.getParentVfResource()) + "::"
+ + vfModuleStructure.getVfModuleMetadata().getVfModuleModelName();
+ }
+
+ protected String getPropertyInput(String propertyName){
+
+ String inputName = new String();
+
+ if (propertyName != null) {
+ int getInputIndex = propertyName.indexOf("{get_input=");
+ if (getInputIndex > -1) {
+ inputName = propertyName.substring(getInputIndex+11, propertyName.length()-1);
+ }
+ }
+
+ return inputName;
+ }
+
+
+ protected static Timestamp getCurrentTimeStamp() {
+
+ return new Timestamp(new Date().getTime());
+ }
}
+
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/AllTestsTestSuite.java b/asdc-controller/src/test/java/org/onap/so/asdc/AllTestsTestSuite.java
new file mode 100644
index 0000000000..a100f26d5a
--- /dev/null
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/AllTestsTestSuite.java
@@ -0,0 +1,32 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 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.so.asdc;
+import org.junit.runner.RunWith;
+
+import com.googlecode.junittoolbox.SuiteClasses;
+import com.googlecode.junittoolbox.WildcardPatternSuite;
+
+@RunWith(WildcardPatternSuite.class)
+@SuiteClasses("**/*Test.class")
+public class AllTestsTestSuite {
+ // the class remains empty,
+ // used only as a holder for the above annotations
+}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/BaseTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/BaseTest.java
index 74f0d60596..83d60aefea 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/BaseTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/BaseTest.java
@@ -29,6 +29,7 @@ import org.onap.so.asdc.installer.VfResourceStructure;
import org.onap.so.asdc.installer.heat.ToscaResourceInstaller;
import org.onap.so.asdc.tenantIsolation.WatchdogDistribution;
import org.onap.so.spring.SpringContextHelper;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.ConfigFileApplicationContextInitializer;
import org.springframework.boot.test.context.SpringBootTest;
@@ -39,6 +40,8 @@ import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
+import com.github.tomakehurst.wiremock.WireMockServer;
+
@RunWith(SpringRunner.class)
@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles("test")
@@ -53,6 +56,8 @@ public abstract class BaseTest {
protected WatchdogDistribution watchdogDistributionSpy;
@SpyBean
protected ToscaResourceInstaller toscaInstaller;
+ @Autowired
+ protected WireMockServer wireMockServer;
@Value("${wiremock.server.port}")
protected String wireMockPort;
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java
index c0c66123eb..03d0a0ff1e 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java
@@ -21,7 +21,6 @@ package org.onap.so.asdc.client;
import static com.github.tomakehurst.wiremock.client.WireMock.ok;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
@@ -31,9 +30,12 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
+
import javax.persistence.EntityNotFoundException;
+
import org.junit.After;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestName;
@@ -141,7 +143,7 @@ public class ASDCControllerITTest extends BaseTest {
String modelEndpoint = "/aai/v15/service-design-and-creation/models/model/" + serviceInvariantUuid
+ "/model-vers/model-ver/" + serviceUuid + "?depth=0";
- stubFor(post(urlEqualTo(modelEndpoint)).willReturn(ok()));
+ wireMockServer.stubFor(post(urlEqualTo(modelEndpoint)).willReturn(ok()));
}
/**
@@ -297,6 +299,7 @@ public class ASDCControllerITTest extends BaseTest {
* Testing with the service-Svc140-VF-csar.csar.
*/
@Test
+ @Ignore
public void treatNotification_ValidVnfResource_ExpectedOutput() {
/**
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java
index 546c4e2458..947da4f492 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java
@@ -22,7 +22,6 @@ package org.onap.so.asdc.client.test.rest;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching;
import static com.shazam.shazamcrest.MatcherAssert.assertThat;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
@@ -98,7 +97,7 @@ public class ASDCRestInterfaceTest extends BaseTest {
@Transactional
public void testAllottedResourceService() throws Exception {
- stubFor(post(urlPathMatching("/aai/.*"))
+ wireMockServer.stubFor(post(urlPathMatching("/aai/.*"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")));
diff --git a/bpmn/MSOCommonBPMN/pom.xml b/bpmn/MSOCommonBPMN/pom.xml
index b115d36a0a..4da7ba5339 100644
--- a/bpmn/MSOCommonBPMN/pom.xml
+++ b/bpmn/MSOCommonBPMN/pom.xml
@@ -155,6 +155,9 @@
</configuration>
</execution>
</executions>
+ <configuration>
+ <parallel>suites</parallel>
+ </configuration>
</plugin>
</plugins>
<pluginManagement>
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy
index 49acf37078..d17a3c42a6 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy
@@ -167,7 +167,7 @@ class OofHoming extends AbstractServiceTaskProcessor {
Response httpResponse = httpClient.post(oofRequest)
int responseCode = httpResponse.getStatus()
- logDebug("OOF sync response code is: " + responseCode)
+ logger.debug("OOF sync response code is: " + responseCode)
logger.debug( "*** Completed Homing Call OOF ***")
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy
index b68e979b3c..2f46630715 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy
@@ -518,9 +518,9 @@ class OofUtils {
Response response = client.post(request.getBody().toString())
int responseCode = response.getStatus()
- logDebug("CatalogDB response code is: " + responseCode)
+ logger.debug("CatalogDB response code is: " + responseCode)
String syncResponse = response.readEntity(String.class)
- logDebug("CatalogDB response is: " + syncResponse)
+ logger.debug("CatalogDB response is: " + syncResponse)
if(responseCode != 202){
exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from CatalogDB.")
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy
index 69d5f02df5..fdd53b2f05 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy
@@ -399,4 +399,8 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor {
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
}
}
+
+ public Logger getLogger() {
+ return logger;
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV2.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV2.groovy
index f91bf54edc..e56091ad65 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV2.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV2.groovy
@@ -294,4 +294,8 @@ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 {
exceptionUtil.buildWorkflowException(execution, 5300, msg)
}
}
+
+ public Logger getLogger() {
+ return logger;
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy
index aacd385a3b..9215eabc57 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy
@@ -450,4 +450,8 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor {
Node child = getChild(node, name)
return child == null ? null : child.text()
}
+
+ public Logger getLogger() {
+ return logger;
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/DelegateExecutionImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/DelegateExecutionImpl.java
index 1c1d6b73fd..39a209efa8 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/DelegateExecutionImpl.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/DelegateExecutionImpl.java
@@ -1,22 +1,22 @@
/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * 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
- *
+* ============LICENSE_START=======================================================
+* ONAP - SO
+* ================================================================================
+* 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+* ============LICENSE_END=========================================================
+*/
package org.onap.so.bpmn.common;
@@ -31,92 +31,107 @@ import org.onap.so.bpmn.common.exceptions.RequiredExecutionVariableExeception;
import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
public class DelegateExecutionImpl implements BuildingBlockExecution, Serializable {
- private final Map<String, Serializable> seedMap;
- private transient DelegateExecution execution;
- private static final String INVALID_INPUT_MISSING = "Expected variable of \"%s\" not found in execution";
- private static final String INVALID_INPUT_CLASS_CAST = "Expected variable of \"%s\" was the wrong object type in the execution";
-
- private static final String MISSING_MSG = "Execution variable \"gBBInput\" cannot be null when executing building blocks";
- private static final String MALFORMED_MSG = "Execution variable \"gBBInput\" must contain an element of type GeneralBuildingBlock";
-
- public DelegateExecutionImpl(Map<String, Serializable> seedMap) {
- this.seedMap = seedMap;
- }
-
- public DelegateExecutionImpl(DelegateExecution execution) {
- this.seedMap = new HashMap<>();
- execution.getVariables().forEach((key, value) -> {
- if (value instanceof Serializable) {
- seedMap.put(key, (Serializable)value);
- }
- });
- /* must occur for junit tests to work */
- this.execution = execution;
- }
- @Override
- public GeneralBuildingBlock getGeneralBuildingBlock() {
- try {
- GeneralBuildingBlock generalBuildingBlock = (GeneralBuildingBlock) execution.getVariable("gBBInput");
-
- if (generalBuildingBlock == null) {
- throw new MissingBuildingBlockInputException(MISSING_MSG);
- }
-
- return generalBuildingBlock;
- } catch (ClassCastException e) {
- throw new MalformedBuildingBlockInputException(MALFORMED_MSG, e);
- }
- }
-
- @Override
- public <T> T getVariable(String key) {
- return this.get(key);
- }
-
- @Override
- public <T> T getRequiredVariable(String key) throws RequiredExecutionVariableExeception {
- final T result;
-
- result = this.get(key);
- if (result == null) {
- throw new RequiredExecutionVariableExeception(String.format(INVALID_INPUT_MISSING, key));
-
- }
- return result;
- }
-
- @Override
- public void setVariable(String key, Serializable value) {
- this.execution.setVariable(key, value);
- }
-
- @Override
- public Map<ResourceKey, String> getLookupMap() {
- return this.get("lookupKeyMap");
- }
-
- @Override
- public String getFlowToBeCalled() {
- return this.get("flowToBeCalled");
- }
- public DelegateExecution getDelegateExecution() {
- return this.execution;
- }
-
- public void setDelegateExecution(DelegateExecution execution) {
- this.execution = execution;
- this.seedMap.forEach((key, value) -> {
- if (!execution.hasVariable(key)) {
- execution.setVariable(key, value);
- }
- });
- }
-
- protected <T> T get(String key) {
- final Object value = this.execution.getVariable(key);
-
- return (T)value;
- }
+ private static final long serialVersionUID = 5559067662634919395L;
+
+ @JsonProperty
+ private final Map<String, Serializable> seedMap;
+
+ private transient DelegateExecution execution;
+ private static final String INVALID_INPUT_MISSING = "Expected variable of \"%s\" not found in execution";
+
+ private static final String MISSING_MSG =
+ "Execution variable \"gBBInput\" cannot be null when executing building blocks";
+ private static final String MALFORMED_MSG =
+ "Execution variable \"gBBInput\" must contain an element of type GeneralBuildingBlock";
+
+ public DelegateExecutionImpl(final Map<String, Serializable> seedMap) {
+ this.seedMap = seedMap;
+ }
+
+ public DelegateExecutionImpl(final DelegateExecution execution) {
+ this.seedMap = new HashMap<>();
+ execution.getVariables().forEach((key, value) -> {
+ if (value instanceof Serializable) {
+ seedMap.put(key, (Serializable) value);
+ }
+ });
+ /* must occur for junit tests to work */
+ this.execution = execution;
+ }
+
+ @JsonIgnore
+ @Override
+ public GeneralBuildingBlock getGeneralBuildingBlock() {
+ try {
+ final GeneralBuildingBlock generalBuildingBlock = (GeneralBuildingBlock) execution.getVariable("gBBInput");
+
+ if (generalBuildingBlock == null) {
+ throw new MissingBuildingBlockInputException(MISSING_MSG);
+ }
+
+ return generalBuildingBlock;
+ } catch (final ClassCastException e) {
+ throw new MalformedBuildingBlockInputException(MALFORMED_MSG, e);
+ }
+ }
+
+ @Override
+ public <T> T getVariable(final String key) {
+ return this.get(key);
+ }
+
+ @Override
+ public <T> T getRequiredVariable(final String key) throws RequiredExecutionVariableExeception {
+ final T result;
+
+ result = this.get(key);
+ if (result == null) {
+ throw new RequiredExecutionVariableExeception(String.format(INVALID_INPUT_MISSING, key));
+
+ }
+ return result;
+ }
+
+ @Override
+ public void setVariable(final String key, final Serializable value) {
+ this.execution.setVariable(key, value);
+ }
+
+ @JsonIgnore
+ @Override
+ public Map<ResourceKey, String> getLookupMap() {
+ return this.get("lookupKeyMap");
+ }
+
+ @JsonIgnore
+ @Override
+ public String getFlowToBeCalled() {
+ return this.get("flowToBeCalled");
+ }
+
+ @JsonIgnore
+ public DelegateExecution getDelegateExecution() {
+ return this.execution;
+ }
+
+ public void setDelegateExecution(final DelegateExecution execution) {
+ this.execution = execution;
+ this.seedMap.forEach((key, value) -> {
+ if (!execution.hasVariable(key)) {
+ execution.setVariable(key, value);
+ }
+ });
+ }
+
+ @SuppressWarnings("unchecked")
+ protected <T> T get(final String key) {
+ final Object value = this.execution.getVariable(key);
+ return (T) value;
+ }
+
}
diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/SDNCAdapterRestV1.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/SDNCAdapterRestV1.bpmn
index 7a9a7f8308..e2da44d272 100644
--- a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/SDNCAdapterRestV1.bpmn
+++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/SDNCAdapterRestV1.bpmn
@@ -10,8 +10,7 @@ def statusCode = execution.getVariable('SDNCREST_sdncAdapterStatusCode')
String response = String.valueOf(execution.getVariable('SDNCREST_sdncAdapterResponse'))
def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
def processKey = sdncAdapterRestV1.getProcessKey(execution)
-sdncAdapterRestV1.logDebug(processKey + " received response from SDNCAdapter: statusCode=" + statusCode +
- " response=" + (response.isEmpty() ? "" : "\n") + response, isDebugLogEnabled)</bpmn2:script>
+sdncAdapterRestV1.getLogger().debug("{} received response from SDNCAdapter: statusCode= {} response={}", processKey, statusCode, (response.isEmpty() ? "" : "\n" + response))</bpmn2:script>
</bpmn2:scriptTask>
<bpmn2:scriptTask id="ScriptTask_3" name="Workflow Exception (no connection)" scriptFormat="groovy">
<bpmn2:incoming>SequenceFlow_17</bpmn2:incoming>
diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/SDNCAdapterRestV2.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/SDNCAdapterRestV2.bpmn
index cee6e43f93..a262801005 100644
--- a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/SDNCAdapterRestV2.bpmn
+++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/SDNCAdapterRestV2.bpmn
@@ -11,8 +11,7 @@ def statusCode = execution.getVariable('SDNCREST_sdncAdapterStatusCode')
String response = String.valueOf(execution.getVariable('SDNCREST_sdncAdapterResponse'))
def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
def processKey = sdncAdapterRestV2.getProcessKey(execution)
-sdncAdapterRestV2.logDebug(processKey + " received response from SDNCAdapter: statusCode=" + statusCode +
- " response=" + (response.isEmpty() ? "" : "\n") + response, isDebugLogEnabled)</bpmn2:script>
+sdncAdapterRestV2.getLogger().debug("{} received response from SDNCAdapter: statusCode= {} response={}", processKey, statusCode, (response.isEmpty() ? "" : "\n" + response))</bpmn2:script>
</bpmn2:scriptTask>
<bpmn2:scriptTask id="ScriptTask_3" name="Workflow Exception (no connection)" scriptFormat="groovy">
<bpmn2:incoming>SequenceFlow_17</bpmn2:incoming>
diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/VnfAdapterRestV1.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/VnfAdapterRestV1.bpmn
index cdd710d102..db93df9f09 100644
--- a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/VnfAdapterRestV1.bpmn
+++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/VnfAdapterRestV1.bpmn
@@ -10,8 +10,7 @@ def statusCode = execution.getVariable('VNFREST_vnfAdapterStatusCode')
String response = String.valueOf(execution.getVariable('VNFREST_vnfAdapterResponse'))
def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
def processKey = vnfAdapterRestV1.getProcessKey(execution)
-vnfAdapterRestV1.logDebug(processKey + " received response from VnfAdapter: statusCode=" + statusCode +
- " response=" + (response.isEmpty() ? "" : "\n") + response, isDebugLogEnabled)]]></bpmn2:script>
+vnfAdapterRestV1.getLogger().debug("{} received response from VnfAdapter: statusCode= {} response={}", processKey, statusCode, (response.isEmpty() ? "" : "\n" + response))]]></bpmn2:script>
</bpmn2:scriptTask>
<bpmn2:scriptTask id="ScriptTask_3" name="Workflow Exception (no connection)">
<bpmn2:incoming>SequenceFlow_17</bpmn2:incoming>
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModuleTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModuleTest.groovy
index 60385a7990..9a778a7380 100644
--- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModuleTest.groovy
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModuleTest.groovy
@@ -40,8 +40,6 @@ import static org.mockito.Mockito.*
@RunWith(MockitoJUnitRunner.class)
@Ignore
class PrepareUpdateAAIVfModuleTest {
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(28090)
@Captor
static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SniroHomingV1Test.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SniroHomingV1Test.groovy
index b093aaa491..e3942f0d2e 100644
--- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SniroHomingV1Test.groovy
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SniroHomingV1Test.groovy
@@ -70,9 +70,6 @@ class SniroHomingV1Test {
serviceDecomp.setVnfResources(vnfResourceList)
}
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(28090)
-
@Captor
static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnfTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnfTest.groovy
index 6a4d53654b..12c437fc0a 100644
--- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnfTest.groovy
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnfTest.groovy
@@ -48,8 +48,6 @@ import static org.mockito.Mockito.*
class UpdateAAIGenericVnfTest {
String getVfModuleResponse = FileUtil.readResourceFile("__files/VfModularity/GenericVnf.xml")
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(28090)
@Captor
static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModuleTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModuleTest.groovy
index 72bcfcf359..99b178c044 100644
--- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModuleTest.groovy
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModuleTest.groovy
@@ -50,9 +50,6 @@ class UpdateAAIVfModuleTest extends MsoGroovyTest {
@Spy
UpdateAAIVfModule updateAAIVfModule;
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(28090)
-
@Captor
static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BaseTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BaseTest.java
index 5d6f98c907..0f702fca2d 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BaseTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BaseTest.java
@@ -41,11 +41,11 @@ import org.onap.so.db.catalog.client.CatalogDbClient;
import org.onap.so.test.categories.SpringAware;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.boot.test.web.client.TestRestTemplate;
+import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock;
import org.springframework.http.HttpHeaders;
import org.springframework.test.context.ActiveProfiles;
@@ -54,7 +54,7 @@ import org.springframework.test.context.junit4.SpringRunner;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.github.tomakehurst.wiremock.client.WireMock;
+import com.github.tomakehurst.wiremock.WireMockServer;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@@ -77,6 +77,9 @@ public abstract class BaseTest extends BuildingBlockTestDataSetup {
@Autowired
private RepositoryService repositoryService;
+
+ @Autowired
+ protected WireMockServer wireMockServer;
/*
* Mocked for injection via autowiring
*/
@@ -118,7 +121,7 @@ public abstract class BaseTest extends BuildingBlockTestDataSetup {
@Before
public void baseTestBefore() {
- WireMock.reset();
+ wireMockServer.resetAll();
variables.put("gBuildingBlockExecution", execution);
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/DelegateExecutionImplTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/DelegateExecutionImplTest.java
index 32a18d5a7a..a30aadc1f8 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/DelegateExecutionImplTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/DelegateExecutionImplTest.java
@@ -20,19 +20,15 @@
package org.onap.so.bpmn.common;
-import static org.hamcrest.CoreMatchers.hasItems;
-import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
-import static org.mockito.ArgumentMatchers.contains;
+import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import java.io.Serializable;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -46,101 +42,115 @@ import org.onap.so.bpmn.common.exceptions.MissingBuildingBlockInputException;
import org.onap.so.bpmn.common.exceptions.RequiredExecutionVariableExeception;
import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
public class DelegateExecutionImplTest {
- @Rule
- public ExpectedException thrown= ExpectedException.none();
-
-
- @Test
- public void getVariable() throws RequiredExecutionVariableExeception {
- Map<String, Serializable> map = new HashMap<>();
- map.put("var1", "value1");
- map.put("var2", "value2");
- map.put("list1", (Serializable)Arrays.asList("value1", "value2"));
- DelegateExecutionImpl impl = create(map);
-
- assertEquals("value1", impl.getVariable("var1"));
- assertEquals("value2", impl.getRequiredVariable("var2"));
- assertThat(impl.getVariable("list1"), IsIterableContainingInOrder.contains("value1", "value2"));
-
- }
-
-
- @Test
- public void getRequiredVariableNotFound() throws RequiredExecutionVariableExeception {
- DelegateExecutionImpl impl = create();
-
- thrown.expect(RequiredExecutionVariableExeception.class);
- impl.getRequiredVariable("var1");
- }
-
-
- @Test
- public void setVariable() {
- DelegateExecutionImpl impl = create();
- impl.setVariable("var1", "value1");
-
- assertEquals("value1", impl.get("var1"));
- }
-
- @Test
- public void getGeneralBuildingBlock() {
- GeneralBuildingBlock gBB = mock(GeneralBuildingBlock.class);
- Map<String, Serializable> map = new HashMap<>();
- map.put("gBBInput", gBB);
- DelegateExecutionImpl impl = create(map);
-
- assertEquals(gBB, impl.getGeneralBuildingBlock());
- }
-
- @Test
- public void getGeneralBuildingBlockNotFound() {
-
- DelegateExecutionImpl impl = create();
-
- thrown.expect(MissingBuildingBlockInputException.class);
- impl.getGeneralBuildingBlock();
- }
-
- @Test
- public void getGeneralBuildingBlockCastException() {
- Map<String, Serializable> map = new HashMap<>();
- map.put("gBBInput", new DelegateExecutionFake());
- DelegateExecutionImpl impl = create(map);
-
- thrown.expect(MalformedBuildingBlockInputException.class);
- impl.getGeneralBuildingBlock();
- }
-
- @Test
- public void getDelegateExecution() {
- DelegateExecutionImpl impl = create();
-
- assertNotNull(impl.getDelegateExecution());
- }
-
- @Test
- public void getLookupMap() {
- Map<String, Serializable> lookup = new HashMap<>();
- Map<String, Serializable> map = new HashMap<>();
- map.put("lookupKeyMap", (Serializable) lookup);
- DelegateExecutionImpl impl = create(map);
-
- assertEquals(lookup, impl.getLookupMap());
- }
-
- private DelegateExecutionImpl create() {
- return create(new HashMap<String, Serializable>());
- }
-
- private DelegateExecutionImpl create(Map<String, Serializable> map) {
- DelegateExecutionFake fake = new DelegateExecutionFake();
-
- for (Entry<String, Serializable> entry : map.entrySet()) {
- fake.setVariable(entry.getKey(), entry.getValue());
- }
- return new DelegateExecutionImpl(fake);
- }
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+
+ @Test
+ public void getVariable() throws RequiredExecutionVariableExeception {
+ final Map<String, Serializable> map = new HashMap<>();
+ map.put("var1", "value1");
+ map.put("var2", "value2");
+ map.put("list1", (Serializable) Arrays.asList("value1", "value2"));
+ final DelegateExecutionImpl impl = create(map);
+
+ assertEquals("value1", impl.getVariable("var1"));
+ assertEquals("value2", impl.getRequiredVariable("var2"));
+ assertThat(impl.getVariable("list1"), IsIterableContainingInOrder.contains("value1", "value2"));
+
+ }
+
+
+ @Test
+ public void getRequiredVariableNotFound() throws RequiredExecutionVariableExeception {
+ final DelegateExecutionImpl impl = create();
+
+ thrown.expect(RequiredExecutionVariableExeception.class);
+ impl.getRequiredVariable("var1");
+ }
+
+
+ @Test
+ public void setVariable() {
+ final DelegateExecutionImpl impl = create();
+ impl.setVariable("var1", "value1");
+
+ assertEquals("value1", impl.get("var1"));
+ }
+
+ @Test
+ public void getGeneralBuildingBlock() {
+ final GeneralBuildingBlock gBB = mock(GeneralBuildingBlock.class);
+ final Map<String, Serializable> map = new HashMap<>();
+ map.put("gBBInput", gBB);
+ final DelegateExecutionImpl impl = create(map);
+
+ assertEquals(gBB, impl.getGeneralBuildingBlock());
+ }
+
+ @Test
+ public void getGeneralBuildingBlockNotFound() {
+ final DelegateExecutionImpl impl = create();
+ thrown.expect(MissingBuildingBlockInputException.class);
+ impl.getGeneralBuildingBlock();
+ }
+
+ @Test
+ public void getGeneralBuildingBlockCastException() {
+ final Map<String, Serializable> map = new HashMap<>();
+ map.put("gBBInput", new DelegateExecutionFake());
+ final DelegateExecutionImpl impl = create(map);
+
+ thrown.expect(MalformedBuildingBlockInputException.class);
+ impl.getGeneralBuildingBlock();
+ }
+
+ @Test
+ public void getDelegateExecution() {
+ final DelegateExecutionImpl impl = create();
+
+ assertNotNull(impl.getDelegateExecution());
+ }
+
+ @Test
+ public void getLookupMap() {
+ final Map<String, Serializable> lookup = new HashMap<>();
+ final Map<String, Serializable> map = new HashMap<>();
+ map.put("lookupKeyMap", (Serializable) lookup);
+ final DelegateExecutionImpl impl = create(map);
+
+ assertEquals(lookup, impl.getLookupMap());
+ }
+
+ @Test
+ public void testDelegateExecutionImpl_serializeDelegateExecutionImplObject_shouldNotThrowAnyExceptionWhenSerializing() {
+ final DelegateExecutionImpl objectUnderTest = create();
+
+ try {
+ final ObjectMapper objectMapper = new ObjectMapper();
+ objectMapper.writeValueAsString(objectUnderTest);
+ } catch (final JsonProcessingException e) {
+ fail("Should be possible to serialize DelegateExecutionImpl object");
+ }
+
+ }
+
+ private DelegateExecutionImpl create() {
+ return create(new HashMap<String, Serializable>());
+ }
+
+ private DelegateExecutionImpl create(final Map<String, Serializable> map) {
+ final DelegateExecutionFake fake = new DelegateExecutionFake();
+
+ for (final Entry<String, Serializable> entry : map.entrySet()) {
+ fake.setVariable(entry.getKey(), entry.getValue());
+ }
+ return new DelegateExecutionImpl(fake);
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/MockAAIDeleteGenericVnf.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/MockAAIDeleteGenericVnf.java
index 819962f16c..052fd5dc94 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/MockAAIDeleteGenericVnf.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/MockAAIDeleteGenericVnf.java
@@ -22,15 +22,16 @@ package org.onap.so.bpmn.common;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.delete;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
+import com.github.tomakehurst.wiremock.WireMockServer;
+
public class MockAAIDeleteGenericVnf {
- public MockAAIDeleteGenericVnf(){
- stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721/[?]resource-version=0000021"))
+ public MockAAIDeleteGenericVnf(WireMockServer wireMockServer){
+ wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721/[?]resource-version=0000021"))
.willReturn(aResponse()
.withStatus(200)));
- stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c718/[?]resource-version=0000018"))
+ wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c718/[?]resource-version=0000018"))
.willReturn(aResponse()
.withStatus(500)
.withHeader("Content-Type", "text/xml")
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/MockAAIDeleteVfModule.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/MockAAIDeleteVfModule.java
index 9cb10a0494..1cbe0b9244 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/MockAAIDeleteVfModule.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/MockAAIDeleteVfModule.java
@@ -23,31 +23,32 @@ package org.onap.so.bpmn.common;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.delete;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
+import com.github.tomakehurst.wiremock.WireMockServer;
+
public class MockAAIDeleteVfModule {
- public MockAAIDeleteVfModule()
+ public MockAAIDeleteVfModule(WireMockServer wireMockServer)
{
- stubFor(delete(urlMatching(
+ wireMockServer.stubFor(delete(urlMatching(
"/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a73/[?]resource-version=0000073"))
.willReturn(aResponse().withStatus(200)));
- stubFor(delete(urlMatching(
+ wireMockServer.stubFor(delete(urlMatching(
"/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c720/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a75/[?]resource-version=0000075"))
.willReturn(aResponse().withStatus(200)));
- stubFor(delete(urlMatching(
+ wireMockServer.stubFor(delete(urlMatching(
"/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c718/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a78/[?]resource-version=0000078"))
.willReturn(aResponse().withStatus(200)));
- stubFor(delete(urlMatching(
+ wireMockServer.stubFor(delete(urlMatching(
"/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c719/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a77/[?]resource-version=0000077"))
.willReturn(aResponse().withStatus(500).withHeader("Content-Type", "text/xml")
.withBodyFile("aaiFault.xml")));
- stubFor(get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy\\?network-policy-fqdn=.*"))
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy\\?network-policy-fqdn=.*"))
.willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
.withBodyFile("VfModularity/QueryNetworkPolicy_AAIResponse_Success.xml")));
- stubFor(delete(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/.*"))
+ wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/.*"))
.willReturn(aResponse().withStatus(200)));
}
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/MockAAIGenericVnfSearch.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/MockAAIGenericVnfSearch.java
index b46d528cc5..1d6337ffc4 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/MockAAIGenericVnfSearch.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/MockAAIGenericVnfSearch.java
@@ -22,30 +22,31 @@ package org.onap.so.bpmn.common;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
+import com.github.tomakehurst.wiremock.WireMockServer;
+
public class MockAAIGenericVnfSearch {
private static final String EOL = "\n";
- public MockAAIGenericVnfSearch(){
+ public MockAAIGenericVnfSearch(WireMockServer wireMockServer){
String body;
// The following stubs are for CreateAAIVfModule and UpdateAAIVfModule
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC23&depth=1"))
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC23&depth=1"))
.willReturn(aResponse()
.withStatus(500)
.withHeader("Content-Type", "text/xml")
.withBodyFile("aaiFault.xml")));
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC22&depth=1"))
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC22&depth=1"))
.willReturn(aResponse()
.withStatus(404)
.withHeader("Content-Type", "text/xml")
.withBody("Generic VNF Not Found")));
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/768073c7-f41f-4822-9323-b75962763d74[?]depth=1"))
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/768073c7-f41f-4822-9323-b75962763d74[?]depth=1"))
.willReturn(aResponse()
.withStatus(404)
.withHeader("Content-Type", "text/xml")
@@ -78,12 +79,12 @@ public class MockAAIGenericVnfSearch {
" <l-interfaces/>" + EOL +
" <lag-interfaces/>" + EOL +
"</generic-vnf>" + EOL;
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC21&depth=1"))
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC21&depth=1"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBody(body)));
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721[?]depth=1"))
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721[?]depth=1"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
@@ -126,12 +127,12 @@ public class MockAAIGenericVnfSearch {
" <l-interfaces/>" + EOL +
" <lag-interfaces/>" + EOL +
"</generic-vnf>" + EOL;
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC20&depth=1"))
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC20&depth=1"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBody(body)));
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/2f6aee38-1e2a-11e6-82d1-ffc7d9ee8aa4[?]depth=1"))
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/2f6aee38-1e2a-11e6-82d1-ffc7d9ee8aa4[?]depth=1"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
@@ -139,13 +140,13 @@ public class MockAAIGenericVnfSearch {
// The following stubs are for DeleteAAIVfModule
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c723[?]depth=1"))
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c723[?]depth=1"))
.willReturn(aResponse()
.withStatus(500)
.withHeader("Content-Type", "text/xml")
.withBodyFile("aaiFault.xml")));
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c722[?]depth=1"))
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c722[?]depth=1"))
.willReturn(aResponse()
.withStatus(404)
.withHeader("Content-Type", "text/xml")
@@ -178,7 +179,7 @@ public class MockAAIGenericVnfSearch {
" <l-interfaces/>" + EOL +
" <lag-interfaces/>" + EOL +
"</generic-vnf>" + EOL;
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721[?]depth=1"))
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721[?]depth=1"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
@@ -221,7 +222,7 @@ public class MockAAIGenericVnfSearch {
" <l-interfaces/>" + EOL +
" <lag-interfaces/>" + EOL +
"</generic-vnf>" + EOL;
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c720[?]depth=1"))
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c720[?]depth=1"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
@@ -264,7 +265,7 @@ public class MockAAIGenericVnfSearch {
" <l-interfaces/>" + EOL +
" <lag-interfaces/>" + EOL +
"</generic-vnf>" + EOL;
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c719[?]depth=1"))
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c719[?]depth=1"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
@@ -297,7 +298,7 @@ public class MockAAIGenericVnfSearch {
" <l-interfaces/>" + EOL +
" <lag-interfaces/>" + EOL +
"</generic-vnf>" + EOL;
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c718[?]depth=1"))
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c718[?]depth=1"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
@@ -330,7 +331,7 @@ public class MockAAIGenericVnfSearch {
" <l-interfaces/>" + EOL +
" <lag-interfaces/>" + EOL +
"</generic-vnf>" + EOL;
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a73"))
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a73"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/baseclient/BaseClientTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/baseclient/BaseClientTest.java
index f84a76468f..1be7c652b9 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/baseclient/BaseClientTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/baseclient/BaseClientTest.java
@@ -34,8 +34,6 @@ import org.junit.Test;
import org.onap.so.BaseTest;
import org.springframework.core.ParameterizedTypeReference;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
-
import wiremock.org.apache.http.entity.ContentType;
@@ -46,7 +44,7 @@ public class BaseClientTest extends BaseTest {
BaseClient<String, String> client = new BaseClient<>();
String response = "{\"hello\" : \"world\"}";
client.setTargetUrl(UriBuilder.fromUri("http://localhost/test").port(Integer.parseInt(wireMockPort)).build().toString());
- stubFor(get(urlEqualTo("/test"))
+ wireMockServer.stubFor(get(urlEqualTo("/test"))
.willReturn(aResponse().withStatus(200).withBody(response).withHeader("Content-Type", ContentType.APPLICATION_JSON.toString())));
String result = client.get("", new ParameterizedTypeReference<String>() {});
@@ -58,7 +56,7 @@ public class BaseClientTest extends BaseTest {
BaseClient<String, Map<String, Object>> client = new BaseClient<>();
String response = "{\"hello\" : \"world\"}";
client.setTargetUrl(UriBuilder.fromUri("http://localhost/test").port(Integer.parseInt(wireMockPort)).build().toString());
- stubFor(get(urlEqualTo("/test"))
+ wireMockServer.stubFor(get(urlEqualTo("/test"))
.willReturn(aResponse().withStatus(200).withBody(response).withHeader("Content-Type", ContentType.APPLICATION_JSON.toString())));
Map<String, Object> result = client.get("", new ParameterizedTypeReference<Map<String, Object>>() {});
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/recipe/BpmnRestClientTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/recipe/BpmnRestClientTest.java
index 85507afd3f..465ec416b5 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/recipe/BpmnRestClientTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/recipe/BpmnRestClientTest.java
@@ -20,16 +20,19 @@
package org.onap.so.bpmn.common.recipe;
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.IOException;
+
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.junit.Test;
import org.onap.so.BaseTest;
import org.springframework.beans.factory.annotation.Autowired;
-import java.io.IOException;
-
-import static com.github.tomakehurst.wiremock.client.WireMock.*;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
public class BpmnRestClientTest extends BaseTest{
@@ -38,7 +41,7 @@ public class BpmnRestClientTest extends BaseTest{
@Test
public void postTest() throws IOException, Exception{
- stubFor(post(urlPathMatching("/testRecipeUri"))
+ wireMockServer.stubFor(post(urlPathMatching("/testRecipeUri"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(org.springframework.http.HttpStatus.OK.value()).withBody("{}")));
HttpResponse httpResponse = bpmnRestClient.post(
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilderTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilderTest.java
index ddca319708..a074174f6e 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilderTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilderTest.java
@@ -19,23 +19,17 @@
*/
package org.onap.so.bpmn.common.resource;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.ok;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static org.junit.Assert.assertEquals;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.junit.Rule;
import org.junit.Test;
-import org.mockito.Mock;
import org.onap.so.BaseTest;
-import org.onap.so.bpmn.core.UrnPropertiesReader;
-import org.springframework.core.env.Environment;
-
-import static com.github.tomakehurst.wiremock.client.WireMock.*;
public class ResourceRequestBuilderTest extends BaseTest {
@@ -45,7 +39,7 @@ public class ResourceRequestBuilderTest extends BaseTest {
- stubFor(get(urlEqualTo("/ecomp/mso/catalog/v2/serviceResources?serviceModelUuid=c3954379-4efe-431c-8258-f84905b158e5"))
+ wireMockServer.stubFor(get(urlEqualTo("/ecomp/mso/catalog/v2/serviceResources?serviceModelUuid=c3954379-4efe-431c-8258-f84905b158e5"))
.willReturn(ok("{ \"serviceResources\" : {\n" +
"\t\"modelInfo\" : {\n" +
"\t\t\"modelName\" : \"demoVFWCL\",\n" +
@@ -137,7 +131,7 @@ public class ResourceRequestBuilderTest extends BaseTest {
@Test
public void getResourceInputDefaultValueTest() throws Exception {
- stubFor(get(urlEqualTo("/ecomp/mso/catalog/v2/serviceResources?serviceModelUuid=c3954379-4efe-431c-8258-f84905b158e5"))
+ wireMockServer.stubFor(get(urlEqualTo("/ecomp/mso/catalog/v2/serviceResources?serviceModelUuid=c3954379-4efe-431c-8258-f84905b158e5"))
.willReturn(ok("{ \"serviceResources\" : {\n" +
"\t\"modelInfo\" : {\n" +
"\t\t\"modelName\" : \"demoVFWCL\",\n" +
@@ -228,7 +222,7 @@ public class ResourceRequestBuilderTest extends BaseTest {
@Test
public void getResourceInputValueNoDefaultTest() throws Exception {
- stubFor(get(urlEqualTo("/ecomp/mso/catalog/v2/serviceResources?serviceModelUuid=c3954379-4efe-431c-8258-f84905b158e5"))
+ wireMockServer.stubFor(get(urlEqualTo("/ecomp/mso/catalog/v2/serviceResources?serviceModelUuid=c3954379-4efe-431c-8258-f84905b158e5"))
.willReturn(ok("{ \"serviceResources\" : {\n" +
"\t\"modelInfo\" : {\n" +
"\t\t\"modelName\" : \"demoVFWCL\",\n" +
@@ -319,7 +313,7 @@ public class ResourceRequestBuilderTest extends BaseTest {
@Test
public void getResourceSequenceTest() throws Exception {
- stubFor(get(urlEqualTo("/ecomp/mso/catalog/v2/serviceResources?serviceModelUuid=c3954379-4efe-431c-8258-f84905b158e5"))
+ wireMockServer.stubFor(get(urlEqualTo("/ecomp/mso/catalog/v2/serviceResources?serviceModelUuid=c3954379-4efe-431c-8258-f84905b158e5"))
.willReturn(ok("{ \"serviceResources\" : {\n" +
"\t\"modelInfo\" : {\n" +
"\t\t\"modelName\" : \"demoVFWCL\",\n" +
@@ -409,7 +403,7 @@ public class ResourceRequestBuilderTest extends BaseTest {
@Test
public void getResourceInputWithEmptyServiceResourcesTest() throws Exception {
- stubFor(get(urlEqualTo("/ecomp/mso/catalog/v2/serviceResources?serviceModelUuid=c3954379-4efe-431c-8258-f84905b158e5"))
+ wireMockServer.stubFor(get(urlEqualTo("/ecomp/mso/catalog/v2/serviceResources?serviceModelUuid=c3954379-4efe-431c-8258-f84905b158e5"))
.willReturn(ok("{ \"serviceResources\" : {\n" +
"\t\"modelInfo\" : {\n" +
"\t\t\"modelName\" : \"demoVFWCL\",\n" +
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseAAI.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseAAI.java
index 79b0d33062..80d8d928aa 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseAAI.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseAAI.java
@@ -20,17 +20,19 @@
package org.onap.so.bpmn.mock;
-import static com.github.tomakehurst.wiremock.client.WireMock.*;
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.containing;
import static com.github.tomakehurst.wiremock.client.WireMock.delete;
+import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.patch;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.put;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
+import com.github.tomakehurst.wiremock.WireMockServer;
+
/**
* Reusable Mock StubResponses for AAI Endpoints
@@ -46,40 +48,40 @@ public class StubResponseAAI {
/**
* Allotted Resource Mock StubResponses below
*/
- public static void MockGetAllottedResource(String globalCustId, String subscriptionType, String serviceInstanceId, String allottedResourceId, String responseFile) {
- stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId + "/allotted-resources/allotted-resource/" + allottedResourceId))
+ public static void MockGetAllottedResource(WireMockServer wireMockServer, String globalCustId, String subscriptionType, String serviceInstanceId, String allottedResourceId, String responseFile) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId + "/allotted-resources/allotted-resource/" + allottedResourceId))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBodyFile(responseFile)));
}
- public static void MockPutAllottedResource(String globalCustId, String subscriptionType, String serviceInstanceId, String allottedResourceId) {
- stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId + "/allotted-resources/allotted-resource/" + allottedResourceId))
+ public static void MockPutAllottedResource(WireMockServer wireMockServer, String globalCustId, String subscriptionType, String serviceInstanceId, String allottedResourceId) {
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId + "/allotted-resources/allotted-resource/" + allottedResourceId))
.willReturn(aResponse()
.withStatus(200)));
}
- public static void MockPutAllottedResource_500(String globalCustId, String subscriptionType, String serviceInstanceId, String allottedResourceId) {
- stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId + "/allotted-resources/allotted-resource/" + allottedResourceId))
+ public static void MockPutAllottedResource_500(WireMockServer wireMockServer, String globalCustId, String subscriptionType, String serviceInstanceId, String allottedResourceId) {
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId + "/allotted-resources/allotted-resource/" + allottedResourceId))
.willReturn(aResponse()
.withStatus(500)));
}
- public static void MockDeleteAllottedResource(String globalCustId, String subscriptionType, String serviceInstanceId, String allottedResourceId, String resourceVersion) {
- stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId + "/allotted-resources/allotted-resource/" + allottedResourceId + "[?]resource-version=" + resourceVersion))
+ public static void MockDeleteAllottedResource(WireMockServer wireMockServer, String globalCustId, String subscriptionType, String serviceInstanceId, String allottedResourceId, String resourceVersion) {
+ wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId + "/allotted-resources/allotted-resource/" + allottedResourceId + "[?]resource-version=" + resourceVersion))
.willReturn(aResponse()
.withStatus(204)));
}
- public static void MockPatchAllottedResource(String globalCustId, String subscriptionType, String serviceInstanceId, String allottedResourceId) {
- stubFor(patch(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId + "/allotted-resources/allotted-resource/" + allottedResourceId))
+ public static void MockPatchAllottedResource(WireMockServer wireMockServer, String globalCustId, String subscriptionType, String serviceInstanceId, String allottedResourceId) {
+ wireMockServer.stubFor(patch(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId + "/allotted-resources/allotted-resource/" + allottedResourceId))
.willReturn(aResponse()
.withStatus(200)));
}
- public static void MockQueryAllottedResourceById(String allottedResourceId, String responseFile){
- stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=allotted-resource[&]filter=id:EQUALS:" + allottedResourceId))
+ public static void MockQueryAllottedResourceById(WireMockServer wireMockServer, String allottedResourceId, String responseFile){
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=allotted-resource[&]filter=id:EQUALS:" + allottedResourceId))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
@@ -90,8 +92,8 @@ public class StubResponseAAI {
/**
* Service Instance Mock StubResponses below
*/
- public static void MockGetServiceInstance(String globalCustId, String subscriptionType, String serviceInstanceId) {
- stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId))
+ public static void MockGetServiceInstance(WireMockServer wireMockServer, String globalCustId, String subscriptionType, String serviceInstanceId) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")));
@@ -100,127 +102,127 @@ public class StubResponseAAI {
/**
* Service Instance Mock StubResponses below
*/
- public static void MockGetServiceInstance(String globalCustId, String subscriptionType, String serviceInstanceId, String responseFile) {
- stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId))
+ public static void MockGetServiceInstance(WireMockServer wireMockServer, String globalCustId, String subscriptionType, String serviceInstanceId, String responseFile) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBodyFile(responseFile)));
}
- public static void MockGetServiceInstance_404(String customer, String serviceSubscription, String serviceInstanceId){
- stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId))
+ public static void MockGetServiceInstance_404(WireMockServer wireMockServer, String customer, String serviceSubscription, String serviceInstanceId){
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId))
.willReturn(aResponse()
.withStatus(404)));
}
- public static void MockGetServiceInstance_500(String customer, String serviceSubscription, String serviceInstanceId){
- stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId))
+ public static void MockGetServiceInstance_500(WireMockServer wireMockServer, String customer, String serviceSubscription, String serviceInstanceId){
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId))
.willReturn(aResponse()
.withStatus(500)));
}
- public static void MockGetServiceInstance_500(String customer, String serviceSubscription, String serviceInstanceId, String responseFile){
- stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId))
+ public static void MockGetServiceInstance_500(WireMockServer wireMockServer, String customer, String serviceSubscription, String serviceInstanceId, String responseFile){
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId))
.willReturn(aResponse()
.withStatus(500)
.withHeader("Content-Type", "text/xml")
.withBodyFile(responseFile)));
}
- public static void MockNodeQueryServiceInstanceByName(String serviceInstanceName, String responseFile){
- stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance[&]filter=service-instance-name:EQUALS:" + serviceInstanceName))
+ public static void MockNodeQueryServiceInstanceByName(WireMockServer wireMockServer, String serviceInstanceName, String responseFile){
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance[&]filter=service-instance-name:EQUALS:" + serviceInstanceName))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBodyFile(responseFile)));
}
- public static void MockNodeQueryServiceInstanceByName_404(String serviceInstanceName){
- stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance&filter=service-instance-name:EQUALS:" + serviceInstanceName))
+ public static void MockNodeQueryServiceInstanceByName_404(WireMockServer wireMockServer, String serviceInstanceName){
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance&filter=service-instance-name:EQUALS:" + serviceInstanceName))
.willReturn(aResponse()
.withStatus(404)));
}
- public static void MockNodeQueryServiceInstanceByName_500(String serviceInstanceName){
- stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance&filter=service-instance-name:EQUALS:" + serviceInstanceName))
+ public static void MockNodeQueryServiceInstanceByName_500(WireMockServer wireMockServer, String serviceInstanceName){
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance&filter=service-instance-name:EQUALS:" + serviceInstanceName))
.willReturn(aResponse()
.withStatus(500)));
}
- public static void MockNodeQueryServiceInstanceById(String serviceInstanceId, String responseFile){
- stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance[&]filter=service-instance-id:EQUALS:" + serviceInstanceId))
+ public static void MockNodeQueryServiceInstanceById(WireMockServer wireMockServer, String serviceInstanceId, String responseFile){
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance[&]filter=service-instance-id:EQUALS:" + serviceInstanceId))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBodyFile(responseFile)));
}
- public static void MockNodeQueryServiceInstanceById_404(String serviceInstanceId){
- stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance&filter=service-instance-id:EQUALS:" + serviceInstanceId))
+ public static void MockNodeQueryServiceInstanceById_404(WireMockServer wireMockServer, String serviceInstanceId){
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance&filter=service-instance-id:EQUALS:" + serviceInstanceId))
.willReturn(aResponse()
.withStatus(404)));
}
- public static void MockNodeQueryServiceInstanceById_500(String serviceInstanceId){
- stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance&filter=service-instance-id:EQUALS:" + serviceInstanceId))
+ public static void MockNodeQueryServiceInstanceById_500(WireMockServer wireMockServer, String serviceInstanceId){
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance&filter=service-instance-id:EQUALS:" + serviceInstanceId))
.willReturn(aResponse()
.withStatus(500)));
}
- public static void MockDeleteServiceInstance(String customer, String serviceSubscription, String serviceInstanceId, String resourceVersion){
- stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId + "[?]resource-version=" + resourceVersion))
+ public static void MockDeleteServiceInstance(WireMockServer wireMockServer, String customer, String serviceSubscription, String serviceInstanceId, String resourceVersion){
+ wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId + "[?]resource-version=" + resourceVersion))
.willReturn(aResponse()
.withStatus(204)));
}
- public static void MockGetServiceInstance(String customer, String serviceSubscription, String serviceInstanceId, String resourceVersion, int statusCode){
- stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId + "[?]resource-version=" + resourceVersion))
+ public static void MockGetServiceInstance(WireMockServer wireMockServer, String customer, String serviceSubscription, String serviceInstanceId, String resourceVersion, int statusCode){
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId + "[?]resource-version=" + resourceVersion))
.willReturn(aResponse()
.withStatus(statusCode)));
}
- public static void MockGetServiceInstance(String customer, String serviceSubscription, int statusCode){
- stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription))
+ public static void MockGetServiceInstance(WireMockServer wireMockServer, String customer, String serviceSubscription, int statusCode){
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")));
}
- public static void MockDeleteServiceInstance(String customer, String serviceSubscription, String serviceInstanceId, String resourceVersion, int statusCode){
- stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId + "[?]resource-version=" + resourceVersion))
+ public static void MockDeleteServiceInstance(WireMockServer wireMockServer, String customer, String serviceSubscription, String serviceInstanceId, String resourceVersion, int statusCode){
+ wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId + "[?]resource-version=" + resourceVersion))
.willReturn(aResponse()
.withStatus(statusCode)));
}
- public static void MockDeleteServiceInstance(String customer, String serviceSubscription, String resourceVersion, int statusCode){
- stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "[?]resource-version=" +1234))
+ public static void MockDeleteServiceInstance(WireMockServer wireMockServer, String customer, String serviceSubscription, String resourceVersion, int statusCode){
+ wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "[?]resource-version=" +1234))
.willReturn(aResponse()
.withStatus(statusCode)));
}
- public static void MockDeleteServiceInstance_404(String customer, String serviceSubscription, String serviceInstanceId, String resourceVersion){
- stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId + "[?]resource-version=" + resourceVersion))
+ public static void MockDeleteServiceInstance_404(WireMockServer wireMockServer, String customer, String serviceSubscription, String serviceInstanceId, String resourceVersion){
+ wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId + "[?]resource-version=" + resourceVersion))
.willReturn(aResponse()
.withStatus(404)));
}
- public static void MockDeleteServiceInstance_500(String customer, String serviceSubscription, String serviceInstanceId, String resourceVersion){
- stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId + "[?]resource-version=" + resourceVersion))
+ public static void MockDeleteServiceInstance_500(WireMockServer wireMockServer, String customer, String serviceSubscription, String serviceInstanceId, String resourceVersion){
+ wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId + "[?]resource-version=" + resourceVersion))
.willReturn(aResponse()
.withStatus(500)));
}
- public static void MockPutServiceInstance(String globalCustId, String subscriptionType, String serviceInstanceId, String responseFile) {
- stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId))
+ public static void MockPutServiceInstance(WireMockServer wireMockServer, String globalCustId, String subscriptionType, String serviceInstanceId, String responseFile) {
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBodyFile(responseFile)));
}
- public static void MockPutServiceInstance_500(String globalCustId, String subscriptionType, String serviceInstanceId) {
- stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId))
+ public static void MockPutServiceInstance_500(WireMockServer wireMockServer, String globalCustId, String subscriptionType, String serviceInstanceId) {
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId))
.willReturn(aResponse()
.withStatus(500)));
}
@@ -228,34 +230,34 @@ public class StubResponseAAI {
/**
* Service-Subscription Mock StubResponses below
*/
- public static void MockGetServiceSubscription(String globalCustId, String subscriptionType, String responseFile) {
- stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType))
+ public static void MockGetServiceSubscription(WireMockServer wireMockServer, String globalCustId, String subscriptionType, String responseFile) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBodyFile(responseFile)));
}
- public static void MockDeleteServiceSubscription(String globalCustId, String subscriptionType, int statusCode) {
- stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType))
+ public static void MockDeleteServiceSubscription(WireMockServer wireMockServer, String globalCustId, String subscriptionType, int statusCode) {
+ wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType))
.willReturn(aResponse()
.withStatus(statusCode)));
}
- public static void MockDeleteServiceInstanceId(String globalCustId, String subscriptionType, String serviceInstanceId) {
- stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId))
+ public static void MockDeleteServiceInstanceId(WireMockServer wireMockServer, String globalCustId, String subscriptionType, String serviceInstanceId) {
+ wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId))
.willReturn(aResponse()
.withStatus(200)));
}
- public static void MockPutServiceSubscription(String globalCustId, String subscriptionType) {
- stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType))
+ public static void MockPutServiceSubscription(WireMockServer wireMockServer, String globalCustId, String subscriptionType) {
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType))
.willReturn(aResponse()
.withStatus(200)));
}
- public static void MockGetServiceSubscription(String globalCustId, String subscriptionType, int statusCode) {
- stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType))
+ public static void MockGetServiceSubscription(WireMockServer wireMockServer, String globalCustId, String subscriptionType, int statusCode) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType))
.willReturn(aResponse()
.withStatus(statusCode)));
}
@@ -263,28 +265,28 @@ public class StubResponseAAI {
/**
* Customer Mock StubResponses below
*/
- public static void MockGetCustomer(String globalCustId, String responseFile) {
- stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId))
+ public static void MockGetCustomer(WireMockServer wireMockServer, String globalCustId, String responseFile) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBodyFile(responseFile)));
}
- public static void MockDeleteCustomer(String globalCustId) {
- stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId))
+ public static void MockDeleteCustomer(WireMockServer wireMockServer, String globalCustId) {
+ wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId))
.willReturn(aResponse()
.withStatus(200)));
}
- public static void MockPutCustomer(String globalCustId) {
- stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId))
+ public static void MockPutCustomer(WireMockServer wireMockServer, String globalCustId) {
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId))
.willReturn(aResponse()
.withStatus(200)));
}
- public static void MockPutCustomer_500(String globalCustId) {
- stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId))
+ public static void MockPutCustomer_500(WireMockServer wireMockServer, String globalCustId) {
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId))
.willReturn(aResponse()
.withStatus(500)));
}
@@ -294,24 +296,24 @@ public class StubResponseAAI {
* Generic-Vnf Mock StubResponses below
*/
- public static void MockGetGenericVnfById(String vnfId, String responseFile){
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "[?]depth=1"))
+ public static void MockGetGenericVnfById(WireMockServer wireMockServer, String vnfId, String responseFile){
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "[?]depth=1"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBodyFile(responseFile)));
}
- public static void MockGetGenericVnfById(String vnfId, String responseFile, int statusCode){
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf" + vnfId))
+ public static void MockGetGenericVnfById(WireMockServer wireMockServer, String vnfId, String responseFile, int statusCode){
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf" + vnfId))
.willReturn(aResponse()
.withStatus(statusCode)
.withHeader("Content-Type", "text/xml")
.withBodyFile(responseFile)));
}
- public static void MockGetGenericVnfByIdWithPriority(String vnfId, int statusCode, String responseFile) {
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf" + vnfId))
+ public static void MockGetGenericVnfByIdWithPriority(WireMockServer wireMockServer, String vnfId, int statusCode, String responseFile) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf" + vnfId))
.atPriority(1)
.willReturn(aResponse()
.withStatus(statusCode)
@@ -319,8 +321,8 @@ public class StubResponseAAI {
.withBodyFile(responseFile)));
}
- public static void MockGetGenericVnfByIdWithPriority(String vnfId, String vfModuleId, int statusCode, String responseFile, int priority) {
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
+ public static void MockGetGenericVnfByIdWithPriority(WireMockServer wireMockServer, String vnfId, String vfModuleId, int statusCode, String responseFile, int priority) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
.atPriority(priority)
.willReturn(aResponse()
.withStatus(statusCode)
@@ -328,138 +330,138 @@ public class StubResponseAAI {
.withBodyFile(responseFile)));
}
- public static void MockGetGenericVnfByIdWithDepth(String vnfId, int depth, String responseFile){
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "[?]depth=" + depth))
+ public static void MockGetGenericVnfByIdWithDepth(WireMockServer wireMockServer, String vnfId, int depth, String responseFile){
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "[?]depth=" + depth))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBodyFile(responseFile)));
}
- public static void MockGetGenericVnfById_404(String vnfId){
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId))
+ public static void MockGetGenericVnfById_404(WireMockServer wireMockServer, String vnfId){
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId))
.willReturn(aResponse()
.withStatus(404)));
}
- public static void MockGetGenericVnfById_500(String vnfId){
- stubFor(get(urlMatching("/aai/v9/network/generic-vnfs/generic-vnf/" + vnfId + "[?]depth=1"))
+ public static void MockGetGenericVnfById_500(WireMockServer wireMockServer, String vnfId){
+ wireMockServer.stubFor(get(urlMatching("/aai/v9/network/generic-vnfs/generic-vnf/" + vnfId + "[?]depth=1"))
.withQueryParam("depth", equalTo("1"))
.willReturn(aResponse()
.withStatus(500)));
}
- public static void MockGetGenericVnfByName(String vnfName, String responseFile){
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=" + vnfName))
+ public static void MockGetGenericVnfByName(WireMockServer wireMockServer, String vnfName, String responseFile){
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=" + vnfName))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBodyFile(responseFile)));
}
- public static void MockGetGenericVnfByNameWithDepth(String vnfName, int depth, String responseFile){
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=" + vnfName + "[&]depth=" + depth))
+ public static void MockGetGenericVnfByNameWithDepth(WireMockServer wireMockServer, String vnfName, int depth, String responseFile){
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=" + vnfName + "[&]depth=" + depth))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBodyFile(responseFile)));
}
- public static void MockGetGenericVnfByName_404(String vnfName){
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=" + vnfName))
+ public static void MockGetGenericVnfByName_404(WireMockServer wireMockServer, String vnfName){
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=" + vnfName))
.willReturn(aResponse()
.withStatus(404)));
}
- public static void MockDeleteGenericVnf(String vnfId, String resourceVersion){
- stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "[?]resource-version=" + resourceVersion))
+ public static void MockDeleteGenericVnf(WireMockServer wireMockServer, String vnfId, String resourceVersion){
+ wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "[?]resource-version=" + resourceVersion))
.willReturn(aResponse()
.withStatus(204)));
}
- public static void MockDeleteGenericVnf(String vnfId, String resourceVersion, int statusCode){
- stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "[?]resource-version=" + resourceVersion))
+ public static void MockDeleteGenericVnf(WireMockServer wireMockServer, String vnfId, String resourceVersion, int statusCode){
+ wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "[?]resource-version=" + resourceVersion))
.willReturn(aResponse()
.withStatus(statusCode)));
}
- public static void MockDeleteGenericVnf_500(String vnfId, String resourceVersion){
- stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "[?]resource-version=" + resourceVersion))
+ public static void MockDeleteGenericVnf_500(WireMockServer wireMockServer, String vnfId, String resourceVersion){
+ wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "[?]resource-version=" + resourceVersion))
.willReturn(aResponse()
.withStatus(500)));
}
- public static void MockPutGenericVnf(String vnfId){
- stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId))
+ public static void MockPutGenericVnf(WireMockServer wireMockServer, String vnfId){
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId))
.willReturn(aResponse()
.withStatus(200)));
}
- public static void MockPutGenericVnf(String vnfId, String requestBodyContaining, int statusCode) {
- stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf" + vnfId))
+ public static void MockPutGenericVnf(WireMockServer wireMockServer, String vnfId, String requestBodyContaining, int statusCode) {
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf" + vnfId))
.withRequestBody(containing(requestBodyContaining))
.willReturn(aResponse()
.withStatus(statusCode)));
}
- public static void MockPutGenericVnf(String vnfId, int statusCode) {
- stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf" + vnfId))
+ public static void MockPutGenericVnf(WireMockServer wireMockServer, String vnfId, int statusCode) {
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf" + vnfId))
.willReturn(aResponse()
.withStatus(statusCode)));
}
- public static void MockPutGenericVnf_Bad(String vnfId, int statusCode){
- stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId))
+ public static void MockPutGenericVnf_Bad(WireMockServer wireMockServer, String vnfId, int statusCode){
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId))
.willReturn(aResponse()
.withStatus(statusCode)));
}
- public static void MockPatchGenericVnf(String vnfId){
- stubFor(patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId))
+ public static void MockPatchGenericVnf(WireMockServer wireMockServer, String vnfId){
+ wireMockServer.stubFor(patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId))
.willReturn(aResponse()
.withStatus(200)));
}
/**
* Vce Mock StubResponses below
*/
- public static void MockGetVceById(String vnfId, String responseFile){
- stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce/" + vnfId))
+ public static void MockGetVceById(WireMockServer wireMockServer, String vnfId, String responseFile){
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce/" + vnfId))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBodyFile(responseFile)));
}
- public static void MockGetVceByName(String vnfName, String responseFile){
- stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce[?]vnf-name=" + vnfName))
+ public static void MockGetVceByName(WireMockServer wireMockServer, String vnfName, String responseFile){
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce[?]vnf-name=" + vnfName))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBodyFile(responseFile)));
}
- public static void MockDeleteVce(String vnfId, String resourceVersion, int statusCode){
- stubFor(delete(urlMatching("/aai/v[0-9]+/network/vces/vce/" + vnfId + "[?]resource-version=" + resourceVersion))
+ public static void MockDeleteVce(WireMockServer wireMockServer, String vnfId, String resourceVersion, int statusCode){
+ wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/vces/vce/" + vnfId + "[?]resource-version=" + resourceVersion))
.willReturn(aResponse()
.withStatus(statusCode)));
}
- public static void MockPutVce(String vnfId){
- stubFor(put(urlMatching("/aai/v[0-9]+/network/vces/vce/" + vnfId))
+ public static void MockPutVce(WireMockServer wireMockServer, String vnfId){
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/vces/vce/" + vnfId))
.willReturn(aResponse()
.withStatus(200)));
}
- public static void MockGetGenericVceByNameWithDepth(String vnfName, int depth, String responseFile){
- stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce[?]vnf-name=" + vnfName + "[&]depth=" + depth))
+ public static void MockGetGenericVceByNameWithDepth(WireMockServer wireMockServer, String vnfName, int depth, String responseFile){
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce[?]vnf-name=" + vnfName + "[&]depth=" + depth))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBodyFile(responseFile)));
}
- public static void MockGetVceGenericQuery(String serviceInstanceName, int depth, int statusCode, String responseFile){
- stubFor(get(urlMatching("/aai/v[0-9]+/search/generic-query[?]key=service-instance.service-instance-name:" + serviceInstanceName + "[&]start-node-type=service-instance[&]include=vce[&]depth=" + depth))
+ public static void MockGetVceGenericQuery(WireMockServer wireMockServer, String serviceInstanceName, int depth, int statusCode, String responseFile){
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/search/generic-query[?]key=service-instance.service-instance-name:" + serviceInstanceName + "[&]start-node-type=service-instance[&]include=vce[&]depth=" + depth))
.willReturn(aResponse()
.withStatus(statusCode)
.withHeader("Content-Type", "text/xml")
@@ -469,16 +471,16 @@ public class StubResponseAAI {
/**
* Tenant Mock StubResponses below
*/
- public static void MockGetTenantGenericQuery(String customer, String serviceType, String responseFile) {
- stubFor(get(urlMatching("/aai/v[0-9]+/search/generic-query[?]key=customer.global-customer-id:" + customer + "&key=service-subscription.service-type:" + serviceType + "&start-node-type=service-subscription&include=tenant&include=service-subscription&depth=1"))
+ public static void MockGetTenantGenericQuery(WireMockServer wireMockServer, String customer, String serviceType, String responseFile) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/search/generic-query[?]key=customer.global-customer-id:" + customer + "&key=service-subscription.service-type:" + serviceType + "&start-node-type=service-subscription&include=tenant&include=service-subscription&depth=1"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBodyFile(responseFile)));
}
- public static void MockGetTenant(String tenantId, String responseFile) {
- stubFor(get(urlEqualTo("/aai/v2/cloud-infrastructure/tenants/tenant/" + tenantId))
+ public static void MockGetTenant(WireMockServer wireMockServer, String tenantId, String responseFile) {
+ wireMockServer.stubFor(get(urlEqualTo("/aai/v2/cloud-infrastructure/tenants/tenant/" + tenantId))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
@@ -488,169 +490,169 @@ public class StubResponseAAI {
/**
* Network Mock StubResponses below
*/
- public static void MockGetNetwork(String networkId, String responseFile, int statusCode) {
- stubFor(get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network/" + networkId))
+ public static void MockGetNetwork(WireMockServer wireMockServer, String networkId, String responseFile, int statusCode) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network/" + networkId))
.willReturn(aResponse()
.withStatus(statusCode)
.withHeader("Content-Type", "text/xml")
.withBodyFile(responseFile)));
}
- public static void MockGetNetworkByIdWithDepth(String networkId, String responseFile, String depth) {
- stubFor(get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network/" + networkId + "[?]depth=" + depth))
+ public static void MockGetNetworkByIdWithDepth(WireMockServer wireMockServer, String networkId, String responseFile, String depth) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network/" + networkId + "[?]depth=" + depth))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBodyFile(responseFile)));
}
- public static void MockGetNetworkCloudRegion(String responseFile, String cloudRegion) {
- stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/"+cloudRegion))
+ public static void MockGetNetworkCloudRegion(WireMockServer wireMockServer, String responseFile, String cloudRegion) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/"+cloudRegion))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBodyFile(responseFile)));
}
- public static void MockGetNetworkByName(String networkName, String responseFile) {
- stubFor(get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network[?]network-name="+networkName))
+ public static void MockGetNetworkByName(WireMockServer wireMockServer, String networkName, String responseFile) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network[?]network-name="+networkName))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBodyFile(responseFile)));
}
- public static void MockGetNetworkByName_404(String responseFile, String networkName) {
- stubFor(get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network[?]network-name="+networkName))
+ public static void MockGetNetworkByName_404(WireMockServer wireMockServer, String responseFile, String networkName) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network[?]network-name="+networkName))
.willReturn(aResponse()
.withStatus(404)
.withHeader("Content-Type", "text/xml")
.withBodyFile(responseFile)));
}
- public static void MockGetNetworkCloudRegion_404(String cloudRegion) {
- stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/"+cloudRegion))
+ public static void MockGetNetworkCloudRegion_404(WireMockServer wireMockServer, String cloudRegion) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/"+cloudRegion))
.willReturn(aResponse()
.withStatus(404)));
}
- public static void MockPutNetwork(String networkId, int statusCode, String responseFile) {
- stubFor(put(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network/" + networkId))
+ public static void MockPutNetwork(WireMockServer wireMockServer, String networkId, int statusCode, String responseFile) {
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network/" + networkId))
.willReturn(aResponse()
.withStatus(statusCode)
.withHeader("Content-Type", "text/xml")
.withBodyFile(responseFile)));
}
- public static void MockPutNetwork(String networkPolicyId, String responseFile, int statusCode) {
- stubFor(put(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/" + networkPolicyId))
+ public static void MockPutNetwork(WireMockServer wireMockServer, String networkPolicyId, String responseFile, int statusCode) {
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/" + networkPolicyId))
.willReturn(aResponse()
.withStatus(statusCode)
.withHeader("Content-Type", "text/xml")
.withBodyFile(responseFile)));
}
- public static void MockGetNetworkName(String networkPolicyName, String responseFile, int statusCode) {
- stubFor(get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network[?]network-name=" + networkPolicyName))
+ public static void MockGetNetworkName(WireMockServer wireMockServer, String networkPolicyName, String responseFile, int statusCode) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network[?]network-name=" + networkPolicyName))
.willReturn(aResponse()
.withStatus(statusCode)
.withHeader("Content-Type", "text/xml")
.withBodyFile(responseFile)));
}
- public static void MockGetNetworkVpnBinding(String responseFile, String vpnBinding) {
- stubFor(get(urlMatching("/aai/v[0-9]+/network/vpn-bindings/vpn-binding/"+vpnBinding + "[?]depth=all"))
+ public static void MockGetNetworkVpnBinding(WireMockServer wireMockServer, String responseFile, String vpnBinding) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/vpn-bindings/vpn-binding/"+vpnBinding + "[?]depth=all"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBodyFile(responseFile)));
}
- public static void MockGetNetworkPolicy(String responseFile, String policy) {
- stubFor(get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/"+policy + "[?]depth=all"))
+ public static void MockGetNetworkPolicy(WireMockServer wireMockServer, String responseFile, String policy) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/"+policy + "[?]depth=all"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBodyFile(responseFile)));
}
- public static void MockGetNetworkVpnBinding(String networkBindingId, String responseFile, int statusCode) {
- stubFor(get(urlMatching("/aai/v[0-9]+/network/vpn-bindings/vpn-binding/" + networkBindingId))
+ public static void MockGetNetworkVpnBinding(WireMockServer wireMockServer, String networkBindingId, String responseFile, int statusCode) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/vpn-bindings/vpn-binding/" + networkBindingId))
.willReturn(aResponse()
.withStatus(statusCode)
.withHeader("Content-Type", "text/xml")
.withBodyFile(responseFile)));
}
- public static void MockGetNetworkPolicy(String networkPolicy, String responseFile, int statusCode) {
- stubFor(get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/" + networkPolicy))
+ public static void MockGetNetworkPolicy(WireMockServer wireMockServer, String networkPolicy, String responseFile, int statusCode) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/" + networkPolicy))
.willReturn(aResponse()
.withStatus(statusCode)
.withHeader("Content-Type", "text/xml")
.withBodyFile(responseFile)));
}
- public static void MockGetNetworkTableReference(String responseFile, String tableReference) {
- stubFor(get(urlMatching("/aai/v[0-9]+/network/route-table-references/route-table-reference/"+tableReference + "[?]depth=all"))
+ public static void MockGetNetworkTableReference(WireMockServer wireMockServer, String responseFile, String tableReference) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/route-table-references/route-table-reference/"+tableReference + "[?]depth=all"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBodyFile(responseFile)));
}
- public static void MockPutNetworkIdWithDepth(String responseFile, String networkId, String depth) {
- stubFor(put(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network/"+networkId+"[?]depth="+depth ))
+ public static void MockPutNetworkIdWithDepth(WireMockServer wireMockServer, String responseFile, String networkId, String depth) {
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network/"+networkId+"[?]depth="+depth ))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBodyFile(responseFile)));
}
- public static void MockGetNetworkPolicyfqdn(String networkPolicy, String responseFile, int statusCode) {
- stubFor(get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy[?]network-policy-fqdn=" + networkPolicy))
+ public static void MockGetNetworkPolicyfqdn(WireMockServer wireMockServer, String networkPolicy, String responseFile, int statusCode) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy[?]network-policy-fqdn=" + networkPolicy))
.willReturn(aResponse()
.withStatus(statusCode)
.withHeader("Content-Type", "text/xml")
.withBodyFile(responseFile)));
}
- public static void MockGetNetworkRouteTable(String networkRouteId, String responseFile, int statusCode) {
- stubFor(get(urlMatching("/aai/v[0-9]+/network/route-table-references/route-table-reference/" + networkRouteId))
+ public static void MockGetNetworkRouteTable(WireMockServer wireMockServer, String networkRouteId, String responseFile, int statusCode) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/route-table-references/route-table-reference/" + networkRouteId))
.willReturn(aResponse()
.withStatus(statusCode)
.withHeader("Content-Type", "text/xml")
.withBodyFile(responseFile)));
}
- public static void MockPatchVfModuleId(String vnfId, String vfModuleId) {
- stubFor(patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
+ public static void MockPatchVfModuleId(WireMockServer wireMockServer, String vnfId, String vfModuleId) {
+ wireMockServer.stubFor(patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
.willReturn(aResponse()
.withStatus(200)));
}
/////////////
- public static void MockVNFAdapterRestVfModule() {
- stubFor(put(urlEqualTo("/vnfs/v1/vnfs/skask/vf-modules/supercool"))
+ public static void MockVNFAdapterRestVfModule(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(put(urlEqualTo("/vnfs/v1/vnfs/skask/vf-modules/supercool"))
.willReturn(aResponse()
.withStatus(202)
.withHeader("Content-Type", "application/xml")));
- stubFor(post(urlMatching("/vnfs/v1/vnfs/.*/vf-modules"))
+ wireMockServer.stubFor(post(urlMatching("/vnfs/v1/vnfs/.*/vf-modules"))
.willReturn(aResponse()
.withStatus(202)
.withHeader("Content-Type", "application/xml")));
- stubFor(post(urlEqualTo("/vnfs/v1/vnfs/skask/vf-modules"))
+ wireMockServer.stubFor(post(urlEqualTo("/vnfs/v1/vnfs/skask/vf-modules"))
.willReturn(aResponse()
.withStatus(202)
.withHeader("Content-Type", "application/xml")));
- stubFor(put(urlEqualTo("/vnfs/v1/volume-groups/78987"))
+ wireMockServer.stubFor(put(urlEqualTo("/vnfs/v1/volume-groups/78987"))
.willReturn(aResponse()
.withStatus(202)
.withHeader("Content-Type", "application/xml")));
}
- public static void MockDBUpdateVfModule(){
- stubFor(post(urlEqualTo("/dbadapters/RequestsDbAdapter"))
+ public static void MockDBUpdateVfModule(WireMockServer wireMockServer){
+ wireMockServer.stubFor(post(urlEqualTo("/dbadapters/RequestsDbAdapter"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
@@ -658,9 +660,9 @@ public class StubResponseAAI {
}
// start of mocks used locally and by other VF Module unit tests
- public static void MockSDNCAdapterVfModule() {
+ public static void MockSDNCAdapterVfModule(WireMockServer wireMockServer) {
// simplified the implementation to return "success" for all requests
- stubFor(post(urlEqualTo("/SDNCAdapter"))
+ wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter"))
// .withRequestBody(containing("SvcInstanceId><"))
.willReturn(aResponse()
.withStatus(200)
@@ -670,79 +672,79 @@ public class StubResponseAAI {
}
// start of mocks used locally and by other VF Module unit tests
- public static void MockAAIVfModule() {
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/supercool"))
+ public static void MockAAIVfModule(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/supercool"))
.atPriority(1)
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBodyFile("VfModularity/VfModule-supercool.xml")));
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/lukewarm"))
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/lukewarm"))
.atPriority(2)
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBodyFile("VfModularity/VfModule-lukewarm.xml")));
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/.*"))
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/.*"))
.atPriority(5)
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBodyFile("VfModularity/VfModule-new.xml")));
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask[?]depth=1"))
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask[?]depth=1"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBodyFile("VfModularity/GenericVnf.xml")));
- stubFor(patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/supercool"))
+ wireMockServer.stubFor(patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/supercool"))
// .withRequestBody(containing("PCRF"))
.willReturn(aResponse()
.withStatus(200)));
- stubFor(patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/.*"))
+ wireMockServer.stubFor(patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/.*"))
// .withRequestBody(containing("PCRF"))
.willReturn(aResponse()
.withStatus(200)));
// HTTP PUT stub still used by CreateAAIvfModuleVolumeGroup
- stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/.*"))
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/.*"))
.withRequestBody(containing("PCRF"))
.willReturn(aResponse()
.withStatus(200)));
// HTTP PUT stub still used by DoCreateVfModuleTest
- stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/.*"))
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/.*"))
.withRequestBody(containing("MODULELABEL"))
.willReturn(aResponse()
.withStatus(200)));
- stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/volume-groups/volume-group[?]volume-group-id=78987"))
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/volume-groups/volume-group[?]volume-group-id=78987"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBodyFile("VfModularity/ConfirmVolumeGroupTenantResponse.xml")));
- stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/volume-groups/volume-group[?]volume-group-id=78987"))
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/volume-groups/volume-group[?]volume-group-id=78987"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBodyFile("VfModularity/ConfirmVolumeGroupTenantResponse.xml")));
- stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/MDTWNJ21/volume-groups/volume-group/78987"))
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/MDTWNJ21/volume-groups/volume-group/78987"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBodyFile("VfModularity/VolumeGroup.xml")));
- stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/AAIAIC25/volume-groups/volume-group/78987"))
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/AAIAIC25/volume-groups/volume-group/78987"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBodyFile("VfModularity/VolumeGroup.xml")));
- stubFor(delete(urlMatching("/aai/v[0-9]+/cloud-infrastructure/volume-groups/volume-group/78987[?]resource-version=0000020"))
+ wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/cloud-infrastructure/volume-groups/volume-group/78987[?]resource-version=0000020"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBodyFile("DeleteCinderVolumeV1/DeleteVolumeId_AAIResponse_Success.xml")));
- stubFor(put(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/.*"))
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/.*"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBodyFile("VfModularity/AddNetworkPolicy_AAIResponse_Success.xml")));
- stubFor(patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/NEWvBNGModuleId"))
+ wireMockServer.stubFor(patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/NEWvBNGModuleId"))
.withRequestBody(containing("NEWvBNGModuleId"))
.willReturn(aResponse()
.withStatus(200)));
@@ -756,8 +758,8 @@ public class StubResponseAAI {
* Cloud infrastructure below
*/
- public static void MockGetCloudRegion(String cloudRegionId, int statusCode, String responseFile) {
- stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegionId))
+ public static void MockGetCloudRegion(WireMockServer wireMockServer, String cloudRegionId, int statusCode, String responseFile) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegionId))
.willReturn(aResponse()
.withStatus(statusCode)
.withHeader("Content-Type", "text/xml")
@@ -767,48 +769,48 @@ public class StubResponseAAI {
/**
* Volume Group StubResponse below
*/
- public static void MockGetVolumeGroupById(String cloudRegionId, String volumeGroupId, String responseFile) {
- MockGetVolumeGroupById(cloudRegionId, volumeGroupId, responseFile, 200);
+ public static void MockGetVolumeGroupById(WireMockServer wireMockServer, String cloudRegionId, String volumeGroupId, String responseFile) {
+ MockGetVolumeGroupById(wireMockServer, cloudRegionId, volumeGroupId, responseFile, 200);
}
- public static void MockGetVolumeGroupById(String cloudRegionId, String volumeGroupId, String responseFile, int responseCode) {
- stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegionId + "/volume-groups/volume-group/" + volumeGroupId))
+ public static void MockGetVolumeGroupById(WireMockServer wireMockServer, String cloudRegionId, String volumeGroupId, String responseFile, int responseCode) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegionId + "/volume-groups/volume-group/" + volumeGroupId))
.willReturn(aResponse()
.withStatus(responseCode)
.withHeader("Content-Type", "text/xml")
.withBodyFile(responseFile)));
}
- public static void MockPutVolumeGroupById(String cloudRegionId, String volumeGroupId, String responseFile, int statusCode) {
- stubFor(put(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegionId + "/volume-groups/volume-group/" + volumeGroupId))
+ public static void MockPutVolumeGroupById(WireMockServer wireMockServer, String cloudRegionId, String volumeGroupId, String responseFile, int statusCode) {
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegionId + "/volume-groups/volume-group/" + volumeGroupId))
.willReturn(aResponse()
.withStatus(statusCode)
.withHeader("Content-Type", "text/xml")
.withBodyFile(responseFile)));
}
- public static void MockGetVolumeGroupByName(String cloudRegionId, String volumeGroupName, String responseFile, int statusCode) {
- stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegionId + "/volume-groups[?]volume-group-name=" + volumeGroupName))
+ public static void MockGetVolumeGroupByName(WireMockServer wireMockServer, String cloudRegionId, String volumeGroupName, String responseFile, int statusCode) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegionId + "/volume-groups[?]volume-group-name=" + volumeGroupName))
.willReturn(aResponse()
.withStatus(statusCode)
.withHeader("Content-Type", "text/xml")
.withBodyFile(responseFile)));
}
- public static void MockDeleteVolumeGroupById(String cloudRegionId, String volumeGroupId, String resourceVersion, int statusCode) {
- stubFor(delete(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegionId + "/volume-groups/volume-group/" + volumeGroupId + "[?]resource-version=" + resourceVersion))
+ public static void MockDeleteVolumeGroupById(WireMockServer wireMockServer, String cloudRegionId, String volumeGroupId, String resourceVersion, int statusCode) {
+ wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegionId + "/volume-groups/volume-group/" + volumeGroupId + "[?]resource-version=" + resourceVersion))
.willReturn(aResponse()
.withStatus(statusCode)));
}
- public static void MockGetVolumeGroupByName_404(String cloudRegionId, String volumeGroupName) {
- stubFor(get(urlMatching("/aai/v9/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegionId + "/volume-groups[?]volume-group-name=" + volumeGroupName))
+ public static void MockGetVolumeGroupByName_404(WireMockServer wireMockServer, String cloudRegionId, String volumeGroupName) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v9/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegionId + "/volume-groups[?]volume-group-name=" + volumeGroupName))
.willReturn(aResponse()
.withStatus(404)));
}
- public static void MockDeleteVolumeGroup(String cloudRegionId, String volumeGroupId, String resourceVersion) {
- stubFor(delete(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegionId + "/volume-groups/volume-group/" + volumeGroupId + "[?]resource-version=" + resourceVersion))
+ public static void MockDeleteVolumeGroup(WireMockServer wireMockServer, String cloudRegionId, String volumeGroupId, String resourceVersion) {
+ wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegionId + "/volume-groups/volume-group/" + volumeGroupId + "[?]resource-version=" + resourceVersion))
.willReturn(aResponse()
.withStatus(200)));
}
@@ -817,103 +819,103 @@ public class StubResponseAAI {
* VF-Module StubResponse below
* @param statusCode TODO
*/
- public static void MockGetVfModuleId(String vnfId, String vfModuleId, String responseFile, int statusCode) {
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
+ public static void MockGetVfModuleId(WireMockServer wireMockServer, String vnfId, String vfModuleId, String responseFile, int statusCode) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
.willReturn(aResponse()
.withStatus(statusCode)
.withHeader("Content-Type", "text/xml")
.withBodyFile(responseFile)));
}
- public static void MockGetVfModuleByNameWithDepth(String vnfId, String vfModuleName, int depth, String responseFile, int statusCode) {
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module[?]vf-module-name=" + vfModuleName + "[?]depth=" + depth))
+ public static void MockGetVfModuleByNameWithDepth(WireMockServer wireMockServer, String vnfId, String vfModuleName, int depth, String responseFile, int statusCode) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module[?]vf-module-name=" + vfModuleName + "[?]depth=" + depth))
.willReturn(aResponse()
.withStatus(statusCode)
.withHeader("Content-Type", "text/xml")
.withBodyFile(responseFile)));
}
- public static void MockGetVfModuleByName(String vnfId, String vfModuleName, String responseFile, int statusCode) {
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module[?]vf-module-name=" + vfModuleName))
+ public static void MockGetVfModuleByName(WireMockServer wireMockServer, String vnfId, String vfModuleName, String responseFile, int statusCode) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module[?]vf-module-name=" + vfModuleName))
.willReturn(aResponse()
.withStatus(statusCode)
.withHeader("Content-Type", "text/xml")
.withBodyFile(responseFile)));
}
- public static void MockGetVfModuleIdNoResponse(String vnfId, String requestContaining, String vfModuleId) {
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
+ public static void MockGetVfModuleIdNoResponse(WireMockServer wireMockServer, String vnfId, String requestContaining, String vfModuleId) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
.withRequestBody(containing(requestContaining))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")));
}
- public static void MockPutVfModuleIdNoResponse(String vnfId, String requestContaining, String vfModuleId) {
- stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId +"/vf-modules/vf-module/" +vfModuleId))
+ public static void MockPutVfModuleIdNoResponse(WireMockServer wireMockServer, String vnfId, String requestContaining, String vfModuleId) {
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId +"/vf-modules/vf-module/" +vfModuleId))
.withRequestBody(containing(requestContaining))
.willReturn(aResponse()
.withStatus(200)));
}
- public static void MockPutVfModuleId(String vnfId, String vfModuleId) {
- stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
+ public static void MockPutVfModuleId(WireMockServer wireMockServer, String vnfId, String vfModuleId) {
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
.willReturn(aResponse()
.withStatus(200)));
}
- public static void MockPutVfModuleId(String vnfId, String vfModuleId, int returnCode) {
- stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
+ public static void MockPutVfModuleId(WireMockServer wireMockServer, String vnfId, String vfModuleId, int returnCode) {
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
.willReturn(aResponse()
.withStatus(returnCode)));
}
- public static void MockDeleteVfModuleId(String vnfId, String vfModuleId, String resourceVersion, int returnCode) {
- stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId + "/[?]resource-version=" + resourceVersion))
+ public static void MockDeleteVfModuleId(WireMockServer wireMockServer, String vnfId, String vfModuleId, String resourceVersion, int returnCode) {
+ wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId + "/[?]resource-version=" + resourceVersion))
.willReturn(aResponse()
.withStatus(returnCode)));
}
- public static void MockAAIVfModuleBadPatch(String endpoint, int statusCode) {
- stubFor(patch(urlMatching(endpoint))
+ public static void MockAAIVfModuleBadPatch(WireMockServer wireMockServer, String endpoint, int statusCode) {
+ wireMockServer.stubFor(patch(urlMatching(endpoint))
.willReturn(aResponse()
.withStatus(statusCode)));
}
/* AAI Pserver Queries */
- public static void MockGetPserverByVnfId(String vnfId, String responseFile, int statusCode) {
- stubFor(put(urlMatching("/aai/v1[0-9]/query.*"))
+ public static void MockGetPserverByVnfId(WireMockServer wireMockServer, String vnfId, String responseFile, int statusCode) {
+ wireMockServer.stubFor(put(urlMatching("/aai/v1[0-9]/query.*"))
.willReturn(aResponse()
.withStatus(statusCode)
.withHeader("Content-Type", "application/json")
.withBodyFile(responseFile)));
}
- public static void MockGetGenericVnfsByVnfId(String vnfId, String responseFile, int statusCode) {
- stubFor(get(urlMatching("/aai/v1[0-9]/network/generic-vnfs/.*"))
+ public static void MockGetGenericVnfsByVnfId(WireMockServer wireMockServer, String vnfId, String responseFile, int statusCode) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v1[0-9]/network/generic-vnfs/.*"))
.willReturn(aResponse()
.withStatus(statusCode)
.withHeader("Content-Type", "application/json; charset=utf-8")
.withBodyFile(responseFile)));
}
- public static void MockSetInMaintFlagByVnfId(String vnfId, int statusCode) {
- stubFor(patch(urlMatching("/aai/v1[0-9]/network/generic-vnfs/.*"))
+ public static void MockSetInMaintFlagByVnfId(WireMockServer wireMockServer, String vnfId, int statusCode) {
+ wireMockServer.stubFor(patch(urlMatching("/aai/v1[0-9]/network/generic-vnfs/.*"))
.willReturn(aResponse()
.withStatus(statusCode)
));
}
- public static void MockSetInMaintFlagByVnfId(String vnfId, String responseFile, int statusCode) {
- stubFor(post(urlMatching("/aai/v1[0-9]/network/generic-vnfs/.*"))
+ public static void MockSetInMaintFlagByVnfId(WireMockServer wireMockServer, String vnfId, String responseFile, int statusCode) {
+ wireMockServer.stubFor(post(urlMatching("/aai/v1[0-9]/network/generic-vnfs/.*"))
.willReturn(aResponse()
.withStatus(statusCode)
.withBodyFile(responseFile)
));
}
- public static void MockGetDefaultCloudRegionByCloudRegionId(String cloudRegionId, String responseFile, int statusCode) {
- stubFor(get(urlMatching("/aai/v1[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/"+cloudRegionId + ".*"))
+ public static void MockGetDefaultCloudRegionByCloudRegionId(WireMockServer wireMockServer, String cloudRegionId, String responseFile, int statusCode) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v1[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/"+cloudRegionId + ".*"))
.willReturn(aResponse()
.withStatus(statusCode)
.withHeader("Content-Type", "application/json; charset=utf-8")
@@ -922,152 +924,152 @@ public class StubResponseAAI {
//// Deprecated Stubs below - to be deleted once unit test that reference them are refactored to use common ones above ////
@Deprecated
- public static void MockGetVceById(){
- stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce/testVnfId123?depth=1"))
+ public static void MockGetVceById(WireMockServer wireMockServer){
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce/testVnfId123?depth=1"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBodyFile("GenericFlows/getVceResponse.xml")));
}
@Deprecated
- public static void MockGetVceByName(){
- stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce[?]vnf-name=testVnfName123"))
+ public static void MockGetVceByName(WireMockServer wireMockServer){
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce[?]vnf-name=testVnfName123"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBodyFile("GenericFlows/getVceByNameResponse.xml")));
}
@Deprecated
- public static void MockPutVce(){
- stubFor(put(urlMatching("/aai/v[0-9]+/network/vces/vce/testVnfId123"))
+ public static void MockPutVce(WireMockServer wireMockServer){
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/vces/vce/testVnfId123"))
.willReturn(aResponse()
.withStatus(200)));
}
@Deprecated
- public static void MockDeleteVce(){
- stubFor(delete(urlMatching("/aai/v[0-9]+/network/vces/vce/testVnfId123[?]resource-version=testReVer123"))
+ public static void MockDeleteVce(WireMockServer wireMockServer){
+ wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/vces/vce/testVnfId123[?]resource-version=testReVer123"))
.willReturn(aResponse()
.withStatus(204)));
}
@Deprecated
- public static void MockDeleteVce_404(){
- stubFor(delete(urlMatching("/aai/v[0-9]+/network/vces/vce/testVnfId123[?]resource-version=testReVer123"))
+ public static void MockDeleteVce_404(WireMockServer wireMockServer){
+ wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/vces/vce/testVnfId123[?]resource-version=testReVer123"))
.willReturn(aResponse()
.withStatus(404)));
}
@Deprecated
- public static void MockDeleteServiceSubscription(){
- stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET[?]resource-version=1234"))
+ public static void MockDeleteServiceSubscription(WireMockServer wireMockServer){
+ wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET[?]resource-version=1234"))
.willReturn(aResponse()
.withStatus(204)));
}
@Deprecated
- public static void MockGetServiceSubscription(){
- stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET"))
+ public static void MockGetServiceSubscription(WireMockServer wireMockServer){
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBodyFile("GenericFlows/getServiceSubscription.xml")));
}
@Deprecated
- public static void MockGetServiceSubscription_200Empty(){
- stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET[?]resource-version=1234"))
+ public static void MockGetServiceSubscription_200Empty(WireMockServer wireMockServer){
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET[?]resource-version=1234"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBody(" ")));
}
@Deprecated
- public static void MockGetServiceSubscription_404() {
- stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET"))
+ public static void MockGetServiceSubscription_404(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET"))
.willReturn(aResponse()
.withStatus(404)));
}
@Deprecated
- public static void MockGetGenericVnfById(){
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
+ public static void MockGetGenericVnfById(WireMockServer wireMockServer){
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBodyFile("GenericFlows/getGenericVnfByNameResponse.xml")));
}
@Deprecated
- public static void MockGetGenericVnfById_404(){
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
+ public static void MockGetGenericVnfById_404(WireMockServer wireMockServer){
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
.willReturn(aResponse()
.withStatus(404)));
}
@Deprecated
- public static void MockGetGenericVnfByName(){
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=testVnfName123"))
+ public static void MockGetGenericVnfByName(WireMockServer wireMockServer){
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=testVnfName123"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBodyFile("GenericFlows/getGenericVnfResponse.xml")));
}
@Deprecated
- public static void MockGetGenericVnfByName_hasRelationships(){
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=testVnfName123"))
+ public static void MockGetGenericVnfByName_hasRelationships(WireMockServer wireMockServer){
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=testVnfName123"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBodyFile("GenericFlows/getGenericVnfResponse_hasRelationships.xml")));
}
@Deprecated
- public static void MockGetGenericVnfById_hasRelationships(){
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
+ public static void MockGetGenericVnfById_hasRelationships(WireMockServer wireMockServer){
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBodyFile("GenericFlows/getGenericVnfResponse_hasRelationships.xml")));
}
@Deprecated
- public static void MockGetGenericVnfById_500(){
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
+ public static void MockGetGenericVnfById_500(WireMockServer wireMockServer){
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
.willReturn(aResponse()
.withStatus(500)));
}
@Deprecated
- public static void MockGetGenericVnfByName_404(){
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=testVnfName123"))
+ public static void MockGetGenericVnfByName_404(WireMockServer wireMockServer){
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=testVnfName123"))
.willReturn(aResponse()
.withStatus(404)));
}
@Deprecated
- public static void MockPutGenericVnf(){
- stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
+ public static void MockPutGenericVnf(WireMockServer wireMockServer){
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
.willReturn(aResponse()
.withStatus(200)));
}
@Deprecated
- public static void MockPutGenericVnf_400(){
- stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
+ public static void MockPutGenericVnf_400(WireMockServer wireMockServer){
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
.willReturn(aResponse()
.withStatus(400)));
}
@Deprecated
- public static void MockDeleteGenericVnf(){
- stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123[?]resource-version=testReVer123"))
+ public static void MockDeleteGenericVnf(WireMockServer wireMockServer){
+ wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123[?]resource-version=testReVer123"))
.willReturn(aResponse()
.withStatus(204)));
}
@Deprecated
- public static void MockDeleteGenericVnf_404(){
- stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123[?]resource-version=testReVer123"))
+ public static void MockDeleteGenericVnf_404(WireMockServer wireMockServer){
+ wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123[?]resource-version=testReVer123"))
.willReturn(aResponse()
.withStatus(404)));
}
@Deprecated
- public static void MockDeleteGenericVnf_500(){
- stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123[?]resource-version=testReVer123"))
+ public static void MockDeleteGenericVnf_500(WireMockServer wireMockServer){
+ wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123[?]resource-version=testReVer123"))
.willReturn(aResponse()
.withStatus(500)));
}
@Deprecated
- public static void MockDeleteGenericVnf_412(){
- stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123[[?]]resource-version=testReVer123"))
+ public static void MockDeleteGenericVnf_412(WireMockServer wireMockServer){
+ wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123[[?]]resource-version=testReVer123"))
.willReturn(aResponse()
.withStatus(412)));
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseAPPC.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseAPPC.java
index 58e7dcdaad..2f2cf45814 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseAPPC.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseAPPC.java
@@ -21,16 +21,12 @@
package org.onap.so.bpmn.mock;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.containing;
-import static com.github.tomakehurst.wiremock.client.WireMock.delete;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.post;
-import static com.github.tomakehurst.wiremock.client.WireMock.patch;
import static com.github.tomakehurst.wiremock.client.WireMock.put;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
+import com.github.tomakehurst.wiremock.WireMockServer;
+
/**
* Reusable Mock StubResponses for Policy
*
@@ -42,14 +38,14 @@ public class StubResponseAPPC {
}
// start of Policy mocks
- public static void MockAppcError() {
- stubFor(get(urlMatching("/events/.*"))
+ public static void MockAppcError(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(get(urlMatching("/events/.*"))
// .withRequestBody(containing("APPC"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBodyFile("APPC/appc_error.json")));
- stubFor(put(urlMatching("/events/.*"))
+ wireMockServer.stubFor(put(urlMatching("/events/.*"))
// .withRequestBody(containing("APPC"))
.willReturn(aResponse()
.withStatus(200)
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseDatabase.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseDatabase.java
index 6227b05d07..8fd745d765 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseDatabase.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseDatabase.java
@@ -21,11 +21,12 @@
package org.onap.so.bpmn.mock;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
+import com.github.tomakehurst.wiremock.WireMockServer;
+
/**
* Stub response class for Database stubs
* including database adapter, catalog db,
@@ -37,54 +38,54 @@ public class StubResponseDatabase {
}
- public static void MockUpdateRequestDB(String fileName){
- stubFor(post(urlEqualTo("/services/RequestsDbAdapter"))
+ public static void MockUpdateRequestDB(WireMockServer wireMockServer, String fileName){
+ wireMockServer.stubFor(post(urlEqualTo("/services/RequestsDbAdapter"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBodyFile(fileName)));
}
- public static void mockUpdateRequestDB(int statusCode, String reponseFile) {
- stubFor(post(urlEqualTo("/services/RequestsDbAdapter"))
+ public static void mockUpdateRequestDB(WireMockServer wireMockServer, int statusCode, String reponseFile) {
+ wireMockServer.stubFor(post(urlEqualTo("/services/RequestsDbAdapter"))
.willReturn(aResponse()
.withStatus(statusCode)
.withHeader("Content-Type", "text/xml")
.withBodyFile(reponseFile)));
}
- public static void MockGetAllottedResourcesByModelInvariantId(String modelInvariantId, String responseFile){
- stubFor(get(urlEqualTo("/v1/serviceAllottedResources?serviceModelInvariantUuid=" + modelInvariantId))
+ public static void MockGetAllottedResourcesByModelInvariantId(WireMockServer wireMockServer, String modelInvariantId, String responseFile){
+ wireMockServer.stubFor(get(urlEqualTo("/v1/serviceAllottedResources?serviceModelInvariantUuid=" + modelInvariantId))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBodyFile(responseFile)));
}
- public static void MockGetAllottedResourcesByModelInvariantId_500(String modelInvariantId, String responseFile){
- stubFor(get(urlEqualTo("/v1/serviceAllottedResources?serviceModelInvariantUuid=" + modelInvariantId))
+ public static void MockGetAllottedResourcesByModelInvariantId_500(WireMockServer wireMockServer, String modelInvariantId, String responseFile){
+ wireMockServer.stubFor(get(urlEqualTo("/v1/serviceAllottedResources?serviceModelInvariantUuid=" + modelInvariantId))
.willReturn(aResponse()
.withStatus(500)));
}
- public static void MockGetVnfCatalogDataCustomizationUuid(String vnfModelCustomizationUuid, String responseFile){
- stubFor(get(urlEqualTo("/v2/serviceVnfs?vnfModelCustomizationUuid=" + vnfModelCustomizationUuid))
+ public static void MockGetVnfCatalogDataCustomizationUuid(WireMockServer wireMockServer, String vnfModelCustomizationUuid, String responseFile){
+ wireMockServer.stubFor(get(urlEqualTo("/v2/serviceVnfs?vnfModelCustomizationUuid=" + vnfModelCustomizationUuid))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBodyFile(responseFile)));
}
- public static void MockGetVfModuleByModelNameCatalogData(String vfModuleModelName, String responseFile){
- stubFor(get(urlEqualTo("/v2/vfModules?vfModuleModelName=" + vfModuleModelName))
+ public static void MockGetVfModuleByModelNameCatalogData(WireMockServer wireMockServer, String vfModuleModelName, String responseFile){
+ wireMockServer.stubFor(get(urlEqualTo("/v2/vfModules?vfModuleModelName=" + vfModuleModelName))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBodyFile(responseFile)));
}
- public static void MockGetServiceResourcesCatalogData(String serviceModelInvariantUuid, String serviceModelVersion, String responseFile){
- stubFor(get(urlEqualTo("/ecomp/mso/catalog/v2/serviceResources?serviceModelInvariantUuid=" +
+ public static void MockGetServiceResourcesCatalogData(WireMockServer wireMockServer, String serviceModelInvariantUuid, String serviceModelVersion, String responseFile){
+ wireMockServer.stubFor(get(urlEqualTo("/ecomp/mso/catalog/v2/serviceResources?serviceModelInvariantUuid=" +
serviceModelInvariantUuid +
"&serviceModelVersion=" + serviceModelVersion))
.willReturn(aResponse()
@@ -93,24 +94,24 @@ public class StubResponseDatabase {
.withBodyFile(responseFile)));
}
- public static void MockGetServiceResourcesCatalogData(String serviceModelInvariantUuid, String responseFile){
- stubFor(get(urlEqualTo("/ecomp/mso/catalog/v2/serviceResources?serviceModelInvariantUuid=" + serviceModelInvariantUuid))
+ public static void MockGetServiceResourcesCatalogData(WireMockServer wireMockServer, String serviceModelInvariantUuid, String responseFile){
+ wireMockServer.stubFor(get(urlEqualTo("/ecomp/mso/catalog/v2/serviceResources?serviceModelInvariantUuid=" + serviceModelInvariantUuid))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBodyFile(responseFile)));
}
- public static void MockGetServiceResourcesCatalogDataByModelUuid(String serviceModelUuid, String responseFile){
- stubFor(get(urlEqualTo("/v2/serviceResources?serviceModelUuid=" + serviceModelUuid))
+ public static void MockGetServiceResourcesCatalogDataByModelUuid(WireMockServer wireMockServer, String serviceModelUuid, String responseFile){
+ wireMockServer.stubFor(get(urlEqualTo("/v2/serviceResources?serviceModelUuid=" + serviceModelUuid))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBodyFile(responseFile)));
}
- public static void MockPostRequestDB(){
- stubFor(post(urlEqualTo("/dbadapters/RequestsDbAdapter"))
+ public static void MockPostRequestDB(WireMockServer wireMockServer){
+ wireMockServer.stubFor(post(urlEqualTo("/dbadapters/RequestsDbAdapter"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")));
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseNetworkAdapter.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseNetworkAdapter.java
index d88509cb57..3e1567412a 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseNetworkAdapter.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseNetworkAdapter.java
@@ -22,12 +22,13 @@ package org.onap.so.bpmn.mock;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.containing;
+import static com.github.tomakehurst.wiremock.client.WireMock.delete;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.put;
-import static com.github.tomakehurst.wiremock.client.WireMock.delete;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
+import com.github.tomakehurst.wiremock.WireMockServer;
+
/**
* Please describe the StubResponseNetwork.java class
*
@@ -41,28 +42,28 @@ public class StubResponseNetworkAdapter {
}
- public static void MockNetworkAdapter() {
- stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
+ public static void MockNetworkAdapter(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
.willReturn(aResponse()
.withStatus(200)));
}
- public static void MockNetworkAdapter(String response) {
- stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
+ public static void MockNetworkAdapter(WireMockServer wireMockServer, String response) {
+ wireMockServer.stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBodyFile(response)));
}
- public static void MockNetworkAdapter_500() {
- stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
+ public static void MockNetworkAdapter_500(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
.willReturn(aResponse()
.withStatus(500)));
}
- public static void MockNetworkAdapterPost(String responseFile, String requestContaining) {
- stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
+ public static void MockNetworkAdapterPost(WireMockServer wireMockServer, String responseFile, String requestContaining) {
+ wireMockServer.stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
.withRequestBody(containing(requestContaining))
.willReturn(aResponse()
.withStatus(200)
@@ -70,16 +71,16 @@ public class StubResponseNetworkAdapter {
.withBodyFile(responseFile)));
}
- public static void MockNetworkAdapter(String networkId, int statusCode, String responseFile) {
- stubFor(delete(urlEqualTo("/networks/NetworkAdapter/" + networkId))
+ public static void MockNetworkAdapter(WireMockServer wireMockServer, String networkId, int statusCode, String responseFile) {
+ wireMockServer.stubFor(delete(urlEqualTo("/networks/NetworkAdapter/" + networkId))
.willReturn(aResponse()
.withStatus(statusCode)
.withHeader("Content-Type", "application/xml")
.withBodyFile(responseFile)));
}
- public static void MockNetworkAdapterContainingRequest(String requestContaining, int statusCode, String responseFile) {
- stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
+ public static void MockNetworkAdapterContainingRequest(WireMockServer wireMockServer, String requestContaining, int statusCode, String responseFile) {
+ wireMockServer.stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
.withRequestBody(containing(requestContaining))
.willReturn(aResponse()
.withStatus(statusCode)
@@ -87,8 +88,8 @@ public class StubResponseNetworkAdapter {
.withBodyFile(responseFile)));
}
- public static void MockPutNetworkAdapter(String networkId, String requestContaining, int statusCode, String responseFile) {
- stubFor(put(urlEqualTo("/networks/NetworkAdapter/" + networkId))
+ public static void MockPutNetworkAdapter(WireMockServer wireMockServer, String networkId, String requestContaining, int statusCode, String responseFile) {
+ wireMockServer.stubFor(put(urlEqualTo("/networks/NetworkAdapter/" + networkId))
.withRequestBody(containing(requestContaining))
.willReturn(aResponse()
.withStatus(statusCode)
@@ -96,16 +97,16 @@ public class StubResponseNetworkAdapter {
.withBodyFile(responseFile)));
}
- public static void MockNetworkAdapterRestRollbackDelete(String responseFile, String networkId) {
- stubFor(delete(urlEqualTo("/networks/NetworkAdapter/"+networkId+"/rollback"))
+ public static void MockNetworkAdapterRestRollbackDelete(WireMockServer wireMockServer, String responseFile, String networkId) {
+ wireMockServer.stubFor(delete(urlEqualTo("/networks/NetworkAdapter/"+networkId+"/rollback"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBodyFile(responseFile)));
}
- public static void MockNetworkAdapterRestPut(String responseFile, String networkId) {
- stubFor(put(urlEqualTo("/networks/NetworkAdapter/"+networkId))
+ public static void MockNetworkAdapterRestPut(WireMockServer wireMockServer, String responseFile, String networkId) {
+ wireMockServer.stubFor(put(urlEqualTo("/networks/NetworkAdapter/"+networkId))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseOof.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseOof.java
index 335fd94f5b..fe6c6a1396 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseOof.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseOof.java
@@ -22,9 +22,10 @@ package org.onap.so.bpmn.mock;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
+import com.github.tomakehurst.wiremock.WireMockServer;
+
/**
* StubResponseOof.java class
*/
@@ -34,30 +35,30 @@ public class StubResponseOof {
}
- public static void mockOof() {
- stubFor(post(urlEqualTo("/api/oof/v1/placement"))
+ public static void mockOof(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement"))
.willReturn(aResponse()
.withStatus(202)
.withHeader("Content-Type", "application/json")));
}
- public static void mockOof(String responseFile) {
- stubFor(post(urlEqualTo("/api/oof/v1/placement"))
+ public static void mockOof(WireMockServer wireMockServer, String responseFile) {
+ wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement"))
.willReturn(aResponse()
.withStatus(202)
.withHeader("Content-Type", "application/json")
.withBodyFile(responseFile)));
}
- public static void mockOof_400() {
- stubFor(post(urlEqualTo("/api/oof/v1/placement"))
+ public static void mockOof_400(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement"))
.willReturn(aResponse()
.withStatus(400)
.withHeader("Content-Type", "application/json")));
}
- public static void mockOof_500() {
- stubFor(post(urlEqualTo("/api/oof/v1/placement"))
+ public static void mockOof_500(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement"))
.willReturn(aResponse()
.withStatus(500)
.withHeader("Content-Type", "application/json")));
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponsePolicy.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponsePolicy.java
index 809616dff0..a6c7fa57f0 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponsePolicy.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponsePolicy.java
@@ -22,14 +22,10 @@ package org.onap.so.bpmn.mock;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.containing;
-import static com.github.tomakehurst.wiremock.client.WireMock.delete;
-import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
-import static com.github.tomakehurst.wiremock.client.WireMock.patch;
-import static com.github.tomakehurst.wiremock.client.WireMock.put;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
+
+import com.github.tomakehurst.wiremock.WireMockServer;
/**
* Reusable Mock StubResponses for Policy
@@ -42,36 +38,36 @@ public class StubResponsePolicy {
}
// start of Policy mocks
- public static void MockPolicyAbort() {
- stubFor(post(urlEqualTo("/pdp/api/getDecision"))
+ public static void MockPolicyAbort(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(post(urlEqualTo("/pdp/api/getDecision"))
.withRequestBody(containing("BB1"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBodyFile("policyAbortResponse.json")));
- stubFor(post(urlEqualTo("/pdp/api/getDecision"))
+ wireMockServer.stubFor(post(urlEqualTo("/pdp/api/getDecision"))
.withRequestBody(containing("UPDVnfI"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBodyFile("policyAbortResponse.json")));
- stubFor(post(urlEqualTo("/pdp/api/getDecision"))
+ wireMockServer.stubFor(post(urlEqualTo("/pdp/api/getDecision"))
.withRequestBody(containing("RPLVnfI"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBodyFile("policyAbortResponse.json")));
- stubFor(post(urlEqualTo("/pdp/api/getDecision"))
+ wireMockServer.stubFor(post(urlEqualTo("/pdp/api/getDecision"))
.withRequestBody(containing("VnfIPU"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBodyFile("policyAbortResponse.json")));
- stubFor(post(urlEqualTo("/pdp/api/getDecision"))
+ wireMockServer.stubFor(post(urlEqualTo("/pdp/api/getDecision"))
.withRequestBody(containing("VnfCU"))
.willReturn(aResponse()
.withStatus(200)
@@ -82,36 +78,36 @@ public class StubResponsePolicy {
}
- public static void MockPolicySkip() {
- stubFor(post(urlEqualTo("/pdp/api/getDecision"))
+ public static void MockPolicySkip(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(post(urlEqualTo("/pdp/api/getDecision"))
.withRequestBody(containing("BB1"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBodyFile("Policy/policySkipResponse.json")));
- stubFor(post(urlEqualTo("/pdp/api/getDecision"))
+ wireMockServer.stubFor(post(urlEqualTo("/pdp/api/getDecision"))
.withRequestBody(containing("UPDVnfI"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBodyFile("Policy/policySkipResponse.json")));
- stubFor(post(urlEqualTo("/pdp/api/getDecision"))
+ wireMockServer.stubFor(post(urlEqualTo("/pdp/api/getDecision"))
.withRequestBody(containing("RPLVnfI"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBodyFile("Policy/policySkipResponse.json")));
- stubFor(post(urlEqualTo("/pdp/api/getDecision"))
+ wireMockServer.stubFor(post(urlEqualTo("/pdp/api/getDecision"))
.withRequestBody(containing("VnfIPU"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBodyFile("Policy/policySkipResponse.json")));
- stubFor(post(urlEqualTo("/pdp/api/getDecision"))
+ wireMockServer.stubFor(post(urlEqualTo("/pdp/api/getDecision"))
.withRequestBody(containing("VnfCU"))
.willReturn(aResponse()
.withStatus(200)
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseSDNCAdapter.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseSDNCAdapter.java
index 66dc1f9910..10557ce091 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseSDNCAdapter.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseSDNCAdapter.java
@@ -23,10 +23,11 @@ package org.onap.so.bpmn.mock;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.containing;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
+import com.github.tomakehurst.wiremock.WireMockServer;
+
/**
* Please describe the StubResponseSDNC.java class
*/
@@ -36,43 +37,43 @@ public class StubResponseSDNCAdapter {
}
- public static void mockSDNCAdapter_500() {
- stubFor(post(urlEqualTo("/SDNCAdapter"))
+ public static void mockSDNCAdapter_500(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter"))
.willReturn(aResponse()
.withStatus(500)));
}
- public static void mockSDNCAdapter_500(String requestContaining) {
- stubFor(post(urlEqualTo("/SDNCAdapter"))
+ public static void mockSDNCAdapter_500(WireMockServer wireMockServer, String requestContaining) {
+ wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter"))
.withRequestBody(containing(requestContaining))
.willReturn(aResponse()
.withStatus(500)));
}
- public static void mockSDNCAdapter(int statusCode) {
- stubFor(post(urlMatching(".*/SDNCAdapter"))
+ public static void mockSDNCAdapter(WireMockServer wireMockServer, int statusCode) {
+ wireMockServer.stubFor(post(urlMatching(".*/SDNCAdapter"))
.willReturn(aResponse()
.withStatus(statusCode)));
}
- public static void mockSDNCAdapter(String endpoint, int statusCode, String responseFile) {
- stubFor(post(urlEqualTo(endpoint))
+ public static void mockSDNCAdapter(WireMockServer wireMockServer, String endpoint, int statusCode, String responseFile) {
+ wireMockServer.stubFor(post(urlEqualTo(endpoint))
.willReturn(aResponse()
.withStatus(statusCode)
.withHeader("Content-Type", "text/xml")
.withBodyFile(responseFile)));
}
- public static void mockSDNCAdapter(String responseFile) {
- stubFor(post(urlEqualTo("/SDNCAdapter"))
+ public static void mockSDNCAdapter(WireMockServer wireMockServer, String responseFile) {
+ wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBodyFile(responseFile)));
}
- public static void mockSDNCAdapter(String endpoint, String requestContaining, int statusCode, String responseFile) {
- stubFor(post(urlEqualTo(endpoint))
+ public static void mockSDNCAdapter(WireMockServer wireMockServer, String endpoint, String requestContaining, int statusCode, String responseFile) {
+ wireMockServer.stubFor(post(urlEqualTo(endpoint))
.withRequestBody(containing(requestContaining))
.willReturn(aResponse()
.withStatus(statusCode)
@@ -80,30 +81,30 @@ public class StubResponseSDNCAdapter {
.withBodyFile(responseFile)));
}
- public static void mockSDNCAdapterRest() {
- stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
+ public static void mockSDNCAdapterRest(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
.willReturn(aResponse()
.withStatus(202)
.withHeader("Content-Type", "application/json")));
}
- public static void mockSDNCAdapterRest_500() {
- stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
+ public static void mockSDNCAdapterRest_500(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
.willReturn(aResponse()
.withStatus(500)
.withHeader("Content-Type", "application/json")));
}
- public static void mockSDNCAdapterRest(String requestContaining) {
- stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
+ public static void mockSDNCAdapterRest(WireMockServer wireMockServer, String requestContaining) {
+ wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
.withRequestBody(containing(requestContaining))
.willReturn(aResponse()
.withStatus(202)
.withHeader("Content-Type", "application/json")));
}
- public static void mockSDNCAdapterRest_500(String requestContaining) {
- stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
+ public static void mockSDNCAdapterRest_500(WireMockServer wireMockServer, String requestContaining) {
+ wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
.withRequestBody(containing(requestContaining))
.willReturn(aResponse()
.withStatus(500)
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseSNIRO.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseSNIRO.java
index 22d3191821..f040a0973c 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseSNIRO.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseSNIRO.java
@@ -22,9 +22,10 @@ package org.onap.so.bpmn.mock;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
+import com.github.tomakehurst.wiremock.WireMockServer;
+
/**
* Please describe the StubResponseSNIRO.java class
*
@@ -35,30 +36,30 @@ public class StubResponseSNIRO {
}
- public static void mockSNIRO() {
- stubFor(post(urlEqualTo("/sniro/api/v2/placement"))
+ public static void mockSNIRO(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(post(urlEqualTo("/sniro/api/v2/placement"))
.willReturn(aResponse()
.withStatus(202)
.withHeader("Content-Type", "application/json")));
}
- public static void mockSNIRO(String responseFile) {
- stubFor(post(urlEqualTo("/sniro/api/v2/placement"))
+ public static void mockSNIRO(WireMockServer wireMockServer, String responseFile) {
+ wireMockServer.stubFor(post(urlEqualTo("/sniro/api/v2/placement"))
.willReturn(aResponse()
.withStatus(202)
.withHeader("Content-Type", "application/json")
.withBodyFile(responseFile)));
}
- public static void mockSNIRO_400() {
- stubFor(post(urlEqualTo("/sniro/api/v2/placement"))
+ public static void mockSNIRO_400(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(post(urlEqualTo("/sniro/api/v2/placement"))
.willReturn(aResponse()
.withStatus(400)
.withHeader("Content-Type", "application/json")));
}
- public static void mockSNIRO_500() {
- stubFor(post(urlEqualTo("/sniro/api/v2/placement"))
+ public static void mockSNIRO_500(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(post(urlEqualTo("/sniro/api/v2/placement"))
.willReturn(aResponse()
.withStatus(500)
.withHeader("Content-Type", "application/json")));
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseVNFAdapter.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseVNFAdapter.java
index 75283515af..e90d358ba8 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseVNFAdapter.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseVNFAdapter.java
@@ -21,161 +21,161 @@
package org.onap.so.bpmn.mock;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.containing;
import static com.github.tomakehurst.wiremock.client.WireMock.delete;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.put;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
+import com.github.tomakehurst.wiremock.WireMockServer;
+
/**
* Please describe the StubResponseVNF.java class
*/
public class StubResponseVNFAdapter {
- public static void mockVNFAdapter() {
- stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync"))
+ public static void mockVNFAdapter(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync"))
.willReturn(aResponse()
.withStatus(200)));
}
- public static void mockVNFAdapter(String responseFile) {
- stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync"))
+ public static void mockVNFAdapter(WireMockServer wireMockServer, String responseFile) {
+ wireMockServer.stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBodyFile(responseFile)));
}
- public static void mockVNFAdapter_500() {
- stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync"))
+ public static void mockVNFAdapter_500(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync"))
.willReturn(aResponse()
.withStatus(500)));
}
- public static void mockVNFPost(String vfModuleId, int statusCode, String vnfId) {
- stubFor(post(urlEqualTo("/services/rest/v1/vnfs" + vnfId + "/vf-modules" + vfModuleId))
+ public static void mockVNFPost(WireMockServer wireMockServer, String vfModuleId, int statusCode, String vnfId) {
+ wireMockServer.stubFor(post(urlEqualTo("/services/rest/v1/vnfs" + vnfId + "/vf-modules" + vfModuleId))
.willReturn(aResponse()
.withStatus(statusCode)
.withHeader("Content-Type", "application/xml")));
- stubFor(post(urlEqualTo("/services/rest/v1/vnfs/" + vnfId + "/vf-modules" + vfModuleId))
+ wireMockServer.stubFor(post(urlEqualTo("/services/rest/v1/vnfs/" + vnfId + "/vf-modules" + vfModuleId))
.willReturn(aResponse()
.withStatus(statusCode)
.withHeader("Content-Type", "application/xml")));
}
- public static void mockVNFPut(String vfModuleId, int statusCode) {
- stubFor(put(urlEqualTo("/services/rest/v1/vnfsvnfId/vf-modules" + vfModuleId))
+ public static void mockVNFPut(WireMockServer wireMockServer, String vfModuleId, int statusCode) {
+ wireMockServer.stubFor(put(urlEqualTo("/services/rest/v1/vnfsvnfId/vf-modules" + vfModuleId))
.willReturn(aResponse()
.withStatus(statusCode)
.withHeader("Content-Type", "application/xml")));
- stubFor(put(urlEqualTo("/services/rest/v1/vnfs/vnfId/vf-modules" + vfModuleId))
+ wireMockServer.stubFor(put(urlEqualTo("/services/rest/v1/vnfs/vnfId/vf-modules" + vfModuleId))
.willReturn(aResponse()
.withStatus(statusCode)
.withHeader("Content-Type", "application/xml")));
}
- public static void mockVNFPut(String vnfId, String vfModuleId, int statusCode) {
- stubFor(put(urlEqualTo("/services/rest/v1/vnfs" + vnfId + "/vf-modules" + vfModuleId))
+ public static void mockVNFPut(WireMockServer wireMockServer, String vnfId, String vfModuleId, int statusCode) {
+ wireMockServer.stubFor(put(urlEqualTo("/services/rest/v1/vnfs" + vnfId + "/vf-modules" + vfModuleId))
.willReturn(aResponse()
.withStatus(statusCode)
.withHeader("Content-Type", "application/xml")));
- stubFor(put(urlEqualTo("/services/rest/v1/vnfs/" + vnfId + "/vf-modules" + vfModuleId))
+ wireMockServer.stubFor(put(urlEqualTo("/services/rest/v1/vnfs/" + vnfId + "/vf-modules" + vfModuleId))
.willReturn(aResponse()
.withStatus(statusCode)
.withHeader("Content-Type", "application/xml")));
}
- public static void mockVNFDelete(String vnfId, String vfModuleId, int statusCode) {
- stubFor(delete(urlEqualTo("/services/rest/v1/vnfs" + vnfId + "/vf-modules" + vfModuleId))
+ public static void mockVNFDelete(WireMockServer wireMockServer, String vnfId, String vfModuleId, int statusCode) {
+ wireMockServer.stubFor(delete(urlEqualTo("/services/rest/v1/vnfs" + vnfId + "/vf-modules" + vfModuleId))
.willReturn(aResponse()
.withStatus(statusCode)
.withHeader("Content-Type", "application/xml")));
- stubFor(delete(urlEqualTo("/services/rest/v1/vnfs/" + vnfId + "/vf-modules" + vfModuleId))
+ wireMockServer.stubFor(delete(urlEqualTo("/services/rest/v1/vnfs/" + vnfId + "/vf-modules" + vfModuleId))
.willReturn(aResponse()
.withStatus(statusCode)
.withHeader("Content-Type", "application/xml")));
}
- public static void mockVNFRollbackDelete(String vfModuleId, int statusCode) {
- stubFor(delete(urlEqualTo("/services/rest/v1/vnfsvnfId/vf-modules" + vfModuleId + "/rollback"))
+ public static void mockVNFRollbackDelete(WireMockServer wireMockServer, String vfModuleId, int statusCode) {
+ wireMockServer.stubFor(delete(urlEqualTo("/services/rest/v1/vnfsvnfId/vf-modules" + vfModuleId + "/rollback"))
.willReturn(aResponse()
.withStatus(statusCode)
.withHeader("Content-Type", "application/xml")));
- stubFor(delete(urlEqualTo("/services/rest/v1/vnfs/vnfId/vf-modules" + vfModuleId + "/rollback"))
+ wireMockServer.stubFor(delete(urlEqualTo("/services/rest/v1/vnfs/vnfId/vf-modules" + vfModuleId + "/rollback"))
.willReturn(aResponse()
.withStatus(statusCode)
.withHeader("Content-Type", "application/xml")));
}
- public static void mockPutVNFVolumeGroup(String volumeGroupId, int statusCode) {
- stubFor(put(urlEqualTo("/vnfs/v1/volume-groups/" + volumeGroupId))
+ public static void mockPutVNFVolumeGroup(WireMockServer wireMockServer, String volumeGroupId, int statusCode) {
+ wireMockServer.stubFor(put(urlEqualTo("/vnfs/v1/volume-groups/" + volumeGroupId))
.willReturn(aResponse()
.withStatus(statusCode)
.withHeader("Content-Type", "application/xml")));
- stubFor(put(urlEqualTo("/vnfs/rest/v1/volume-groups/" + volumeGroupId))
+ wireMockServer.stubFor(put(urlEqualTo("/vnfs/rest/v1/volume-groups/" + volumeGroupId))
.willReturn(aResponse()
.withStatus(statusCode)
.withHeader("Content-Type", "application/xml")));
}
- public static void mockPutVNFVolumeGroupRollback(String volumeGroupId, int statusCode) {
- stubFor(delete(urlMatching("/vnfs/v1/volume-groups/" + volumeGroupId + "/rollback"))
+ public static void mockPutVNFVolumeGroupRollback(WireMockServer wireMockServer, String volumeGroupId, int statusCode) {
+ wireMockServer.stubFor(delete(urlMatching("/vnfs/v1/volume-groups/" + volumeGroupId + "/rollback"))
.willReturn(aResponse()
.withStatus(statusCode)
.withHeader("Content-Type", "application/xml")));
- stubFor(delete(urlMatching("/vnfs/rest/v1/volume-groups/" + volumeGroupId + "/rollback"))
+ wireMockServer.stubFor(delete(urlMatching("/vnfs/rest/v1/volume-groups/" + volumeGroupId + "/rollback"))
.willReturn(aResponse()
.withStatus(statusCode)
.withHeader("Content-Type", "application/xml")));
}
- public static void mockPostVNFVolumeGroup(int statusCode) {
- stubFor(post(urlEqualTo("/vnfs/v1/volume-groups"))
+ public static void mockPostVNFVolumeGroup(WireMockServer wireMockServer, int statusCode) {
+ wireMockServer.stubFor(post(urlEqualTo("/vnfs/v1/volume-groups"))
.willReturn(aResponse()
.withStatus(statusCode)
.withHeader("Content-Type", "application/xml")));
- stubFor(post(urlEqualTo("/vnfs/rest/v1/volume-groups"))
+ wireMockServer.stubFor(post(urlEqualTo("/vnfs/rest/v1/volume-groups"))
.willReturn(aResponse()
.withStatus(statusCode)
.withHeader("Content-Type", "application/xml")));
}
- public static void mockVNFAdapterRest(String vnfId) {
- stubFor(post(urlEqualTo("/services/rest/v1/vnfs" + vnfId + "/vf-modules"))
+ public static void mockVNFAdapterRest(WireMockServer wireMockServer, String vnfId) {
+ wireMockServer.stubFor(post(urlEqualTo("/services/rest/v1/vnfs" + vnfId + "/vf-modules"))
.willReturn(aResponse()
.withStatus(200)));
- stubFor(post(urlEqualTo("/services/rest/v1/vnfs/" + vnfId + "/vf-modules"))
+ wireMockServer.stubFor(post(urlEqualTo("/services/rest/v1/vnfs/" + vnfId + "/vf-modules"))
.willReturn(aResponse()
.withStatus(200)));
}
- public static void mockVNFAdapterRest_500(String vnfId) {
- stubFor(post(urlEqualTo("/services/rest/v1/vnfs" + vnfId + "/vf-modules"))
+ public static void mockVNFAdapterRest_500(WireMockServer wireMockServer, String vnfId) {
+ wireMockServer.stubFor(post(urlEqualTo("/services/rest/v1/vnfs" + vnfId + "/vf-modules"))
.willReturn(aResponse()
.withStatus(500)));
- stubFor(post(urlEqualTo("/services/rest/v1/vnfs/" + vnfId + "/vf-modules"))
+ wireMockServer.stubFor(post(urlEqualTo("/services/rest/v1/vnfs/" + vnfId + "/vf-modules"))
.willReturn(aResponse()
.withStatus(500)));
}
- public static void mockVfModuleDelete(String volumeGroupId) {
- stubFor(delete(urlMatching("/vnfs/v1/volume-groups/"+ volumeGroupId))
+ public static void mockVfModuleDelete(WireMockServer wireMockServer, String volumeGroupId) {
+ wireMockServer.stubFor(delete(urlMatching("/vnfs/v1/volume-groups/"+ volumeGroupId))
.willReturn(aResponse()
.withStatus(202)
.withHeader("Content-Type", "application/xml")));
- stubFor(delete(urlMatching("/vnfs/rest/v1/volume-groups/"+ volumeGroupId))
+ wireMockServer.stubFor(delete(urlMatching("/vnfs/rest/v1/volume-groups/"+ volumeGroupId))
.willReturn(aResponse()
.withStatus(202)
.withHeader("Content-Type", "application/xml")));
}
- public static void mockVfModuleDelete(String volumeGroupId, int statusCode) {
- stubFor(delete(urlMatching("/vnfs/v1/volume-groups/78987"))
+ public static void mockVfModuleDelete(WireMockServer wireMockServer, String volumeGroupId, int statusCode) {
+ wireMockServer.stubFor(delete(urlMatching("/vnfs/v1/volume-groups/78987"))
.willReturn(aResponse()
.withStatus(statusCode)
.withHeader("Content-Type", "application/xml")));
- stubFor(delete(urlMatching("/vnfs/rest/v1/volume-groups/78987"))
+ wireMockServer.stubFor(delete(urlMatching("/vnfs/rest/v1/volume-groups/78987"))
.willReturn(aResponse()
.withStatus(statusCode)
.withHeader("Content-Type", "application/xml")));
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/BaseIntegrationTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/BaseIntegrationTest.java
index b5511f67e3..fc21ff905d 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/BaseIntegrationTest.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/BaseIntegrationTest.java
@@ -32,6 +32,7 @@ import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
+import com.github.tomakehurst.wiremock.WireMockServer;
import com.github.tomakehurst.wiremock.client.WireMock;
@RunWith(SpringRunner.class)
@@ -46,9 +47,12 @@ public abstract class BaseIntegrationTest extends WorkflowTest {
@Value("${wiremock.server.port}")
protected String wiremockPort;
+ @Autowired
+ protected WireMockServer wireMockServer;
+
@After
public void baseAfterTest() {
- WireMock.reset();
+ wireMockServer.resetAll();
}
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/CompleteMsoProcessIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/CompleteMsoProcessIT.java
index 470cc2220d..f528205d17 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/CompleteMsoProcessIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/CompleteMsoProcessIT.java
@@ -38,7 +38,7 @@ import org.onap.so.BaseIntegrationTest;
public class CompleteMsoProcessIT extends BaseIntegrationTest {
private void executeFlow(String inputRequestFile) throws InterruptedException {
- mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
Map<String, Object> variables = new HashMap<>();
variables.put("CompleteMsoProcessRequest",inputRequestFile);
variables.put("mso-request-id", UUID.randomUUID().toString());
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/ConfirmVolumeGroupNameIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/ConfirmVolumeGroupNameIT.java
index 0ef856bb9d..cc3ca941e4 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/ConfirmVolumeGroupNameIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/ConfirmVolumeGroupNameIT.java
@@ -46,7 +46,7 @@ public class ConfirmVolumeGroupNameIT extends BaseIntegrationTest {
@Test
public void sunnyDay() throws Exception {
logStart();
- MockGetVolumeGroupById("MDTWNJ21", "VOLUME_GROUP_ID_1", "aai-volume-group-id-info.xml");
+ MockGetVolumeGroupById(wireMockServer, "MDTWNJ21", "VOLUME_GROUP_ID_1", "aai-volume-group-id-info.xml");
Map<String, Object> variables = new HashMap<>();
variables.put("isDebugLogEnabled","true");
@@ -72,7 +72,7 @@ public class ConfirmVolumeGroupNameIT extends BaseIntegrationTest {
logStart();
// does not exist would return a 404 from AAI
- MockGetVolumeGroupById("MDTWNJ21", "VOLUME_GROUP_ID_THAT_DOES_NOT_EXIST", "aai-volume-group-id-info.xml", 404);
+ MockGetVolumeGroupById(wireMockServer, "MDTWNJ21", "VOLUME_GROUP_ID_THAT_DOES_NOT_EXIST", "aai-volume-group-id-info.xml", 404);
Map<String, Object> variables = new HashMap<>();
variables.put("isDebugLogEnabled","true");
@@ -98,7 +98,7 @@ public class ConfirmVolumeGroupNameIT extends BaseIntegrationTest {
public void rainyDayNameDoesNotMatch() throws Exception {
logStart();
- MockGetVolumeGroupById("MDTWNJ21", "VOLUME_GROUP_ID_1", "aai-volume-group-id-info.xml", 200);
+ MockGetVolumeGroupById(wireMockServer, "MDTWNJ21", "VOLUME_GROUP_ID_1", "aai-volume-group-id-info.xml", 200);
Map<String, Object> variables = new HashMap<>();
variables.put("isDebugLogEnabled","true");
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/ConfirmVolumeGroupTenantIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/ConfirmVolumeGroupTenantIT.java
index af9ab7d3e4..fd1f7c1a2b 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/ConfirmVolumeGroupTenantIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/ConfirmVolumeGroupTenantIT.java
@@ -42,7 +42,7 @@ public class ConfirmVolumeGroupTenantIT extends BaseIntegrationTest {
@Test
public void testRemoveLayer3Service_success() throws Exception{
- MockGetVolumeGroupById("MDTWNJ21", "a8399879-31b3-4973-be26-0a0cbe776b58", "CRTGVNF_queryAAIResponseVolume.xml");
+ MockGetVolumeGroupById(wireMockServer, "MDTWNJ21", "a8399879-31b3-4973-be26-0a0cbe776b58", "CRTGVNF_queryAAIResponseVolume.xml");
Map<String, Object> variables = new HashMap<>();
setVariables(variables);
@@ -60,7 +60,7 @@ public class ConfirmVolumeGroupTenantIT extends BaseIntegrationTest {
@Test
public void testRemoveLayer3Service_idsNotMatch() throws Exception{
- MockGetVolumeGroupById("MDTWNJ21", "a8399879-31b3-4973-be26-0a0cbe776b58", "CRTGVNF_queryAAIResponseVolume_idsNotMatch.xml");
+ MockGetVolumeGroupById(wireMockServer, "MDTWNJ21", "a8399879-31b3-4973-be26-0a0cbe776b58", "CRTGVNF_queryAAIResponseVolume_idsNotMatch.xml");
Map<String, Object> variables = new HashMap<>();
setVariables(variables);
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/CreateAAIVfModuleIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/CreateAAIVfModuleIT.java
index f6284f3535..f6cd74a55b 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/CreateAAIVfModuleIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/CreateAAIVfModuleIT.java
@@ -25,10 +25,8 @@ package org.onap.so.bpmn.common;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.containing;
import static com.github.tomakehurst.wiremock.client.WireMock.put;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
-
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
@@ -40,6 +38,8 @@ import org.onap.so.bpmn.core.WorkflowException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.github.tomakehurst.wiremock.WireMockServer;
+
/**
* Unit test for CreateAAIVfModule.bpmn.
*/
@@ -51,9 +51,9 @@ public class CreateAAIVfModuleIT extends BaseIntegrationTest {
@Test
public void TestCreateGenericVnfSuccess_200() {
- new MockAAIGenericVnfSearch();
- MockAAICreateGenericVnf();
- MockAAIVfModulePUT(true);
+ new MockAAIGenericVnfSearch(wireMockServer);
+ MockAAICreateGenericVnf(wireMockServer);
+ MockAAIVfModulePUT(wireMockServer, true);
Map<String, Object> variables = new HashMap<>();
variables.put("mso-request-id", UUID.randomUUID().toString());
@@ -76,9 +76,9 @@ public class CreateAAIVfModuleIT extends BaseIntegrationTest {
@Test
public void TestCreateVfModuleSuccess_200() {
// create Add-on VF Module for existing Generic VNF
- new MockAAIGenericVnfSearch();
- MockAAICreateGenericVnf();
- MockAAIVfModulePUT(true);
+ new MockAAIGenericVnfSearch(wireMockServer);
+ MockAAICreateGenericVnf(wireMockServer);
+ MockAAIVfModulePUT(wireMockServer, true);
Map<String, Object> variables = new HashMap<>();
variables.put("mso-request-id", UUID.randomUUID().toString());
variables.put("isDebugLogEnabled","true");
@@ -98,9 +98,9 @@ public class CreateAAIVfModuleIT extends BaseIntegrationTest {
@Test
public void TestQueryGenericVnfFailure_5000() {
- new MockAAIGenericVnfSearch();
- MockAAICreateGenericVnf();
- MockAAIVfModulePUT(true);
+ new MockAAIGenericVnfSearch(wireMockServer);
+ MockAAICreateGenericVnf(wireMockServer);
+ MockAAIVfModulePUT(wireMockServer, true);
Map<String, Object> variables = new HashMap<>();
variables.put("mso-request-id", UUID.randomUUID().toString());
@@ -121,9 +121,9 @@ public class CreateAAIVfModuleIT extends BaseIntegrationTest {
@Test
public void TestCreateDupGenericVnfFailure_1002() {
- new MockAAIGenericVnfSearch();
- MockAAICreateGenericVnf();
- MockAAIVfModulePUT(true);
+ new MockAAIGenericVnfSearch(wireMockServer);
+ MockAAICreateGenericVnf(wireMockServer);
+ MockAAIVfModulePUT(wireMockServer, true);
Map<String, Object> variables = new HashMap<>();
variables.put("mso-request-id", UUID.randomUUID().toString());
@@ -144,9 +144,9 @@ public class CreateAAIVfModuleIT extends BaseIntegrationTest {
@Test
public void TestCreateDupVfModuleFailure_1002() {
- new MockAAIGenericVnfSearch();
- MockAAICreateGenericVnf();
- MockAAIVfModulePUT(true);
+ new MockAAIGenericVnfSearch(wireMockServer);
+ MockAAICreateGenericVnf(wireMockServer);
+ MockAAIVfModulePUT(wireMockServer, true);
Map<String, Object> variables = new HashMap<>();
variables.put("mso-request-id", UUID.randomUUID().toString());
@@ -167,9 +167,9 @@ public class CreateAAIVfModuleIT extends BaseIntegrationTest {
@Test
public void TestCreateGenericVnfFailure_5000() {
- new MockAAIGenericVnfSearch();
- MockAAICreateGenericVnf();
- MockAAIVfModulePUT(true);
+ new MockAAIGenericVnfSearch(wireMockServer);
+ MockAAICreateGenericVnf(wireMockServer);
+ MockAAIVfModulePUT(wireMockServer, true);
Map<String, Object> variables = new HashMap<>();
variables.put("mso-request-id", UUID.randomUUID().toString());
@@ -190,9 +190,9 @@ public class CreateAAIVfModuleIT extends BaseIntegrationTest {
@Test
public void TestCreateGenericVnfFailure_1002() {
- new MockAAIGenericVnfSearch();
- MockAAICreateGenericVnf();
- MockAAIVfModulePUT(true);
+ new MockAAIGenericVnfSearch(wireMockServer);
+ MockAAICreateGenericVnf(wireMockServer);
+ MockAAIVfModulePUT(wireMockServer, true);
Map<String, Object> variables = new HashMap<>();
variables.put("mso-request-id", UUID.randomUUID().toString());
@@ -213,9 +213,9 @@ public class CreateAAIVfModuleIT extends BaseIntegrationTest {
@Test
public void TestCreateVfModuleFailure_5000() {
- new MockAAIGenericVnfSearch();
- MockAAICreateGenericVnf();
- MockAAIVfModulePUT(true);
+ new MockAAIGenericVnfSearch(wireMockServer);
+ MockAAICreateGenericVnf(wireMockServer);
+ MockAAIVfModulePUT(wireMockServer, true);
Map<String, Object> variables = new HashMap<>();
variables.put("isDebugLogEnabled","true");
@@ -234,12 +234,12 @@ public class CreateAAIVfModuleIT extends BaseIntegrationTest {
logger.debug(exception.getErrorMessage());
}
- public static void MockAAICreateGenericVnf(){
- stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/.*"))
+ public static void MockAAICreateGenericVnf(WireMockServer wireMockServer){
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/.*"))
.withRequestBody(containing("<service-id>00000000-0000-0000-0000-000000000000</service-id>"))
.willReturn(aResponse()
.withStatus(201)));
- stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/.*"))
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/.*"))
.withRequestBody(containing("<service-id>99999999-9999-9999-9999-999999999999</service-id>"))
.willReturn(aResponse()
.withStatus(500)
@@ -248,18 +248,18 @@ public class CreateAAIVfModuleIT extends BaseIntegrationTest {
}
// start of mocks used locally and by other VF Module unit tests
- public static void MockAAIVfModulePUT(boolean isCreate){
- stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/.*/vf-modules/vf-module/.*"))
+ public static void MockAAIVfModulePUT(WireMockServer wireMockServer, boolean isCreate){
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/.*/vf-modules/vf-module/.*"))
.withRequestBody(containing("MMSC"))
.willReturn(aResponse()
.withStatus(isCreate ? 201 : 200)));
- stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/.*/vf-modules/vf-module/.*"))
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/.*/vf-modules/vf-module/.*"))
.withRequestBody(containing("PCRF"))
.willReturn(aResponse()
.withStatus(500)
.withHeader("Content-Type", "text/xml")
.withBodyFile("aaiFault.xml")));
- stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721"))
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721"))
.willReturn(aResponse()
.withStatus(200)));
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/CreateAAIVfModuleVolumeGroupIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/CreateAAIVfModuleVolumeGroupIT.java
index f72ca79dc6..39a7e0c74b 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/CreateAAIVfModuleVolumeGroupIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/CreateAAIVfModuleVolumeGroupIT.java
@@ -56,8 +56,8 @@ public class CreateAAIVfModuleVolumeGroupIT extends BaseIntegrationTest {
logStart();
String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml");
- MockGetGenericVnfByIdWithPriority("skask", "lukewarm", 200, "VfModularity/VfModule-lukewarm.xml", 2);
- MockPutVfModuleIdNoResponse("skask", "PCRF", "lukewarm");
+ MockGetGenericVnfByIdWithPriority(wireMockServer, "skask", "lukewarm", 200, "VfModularity/VfModule-lukewarm.xml", 2);
+ MockPutVfModuleIdNoResponse(wireMockServer, "skask", "PCRF", "lukewarm");
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
@@ -85,7 +85,7 @@ public class CreateAAIVfModuleVolumeGroupIT extends BaseIntegrationTest {
logStart();
String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml");
- MockGetVfModuleId("skask", ".*", "VfModularity/VfModule-supercool.xml", 404);
+ MockGetVfModuleId(wireMockServer, "skask", ".*", "VfModularity/VfModule-supercool.xml", 404);
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
@@ -112,8 +112,8 @@ public class CreateAAIVfModuleVolumeGroupIT extends BaseIntegrationTest {
logStart();
String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml");
- MockGetVfModuleId("skask", "lukewarm", "VfModularity/VfModule-lukewarm.xml", 200);
- MockPutVfModuleId("skask", "lukewarm", 404);
+ MockGetVfModuleId(wireMockServer, "skask", "lukewarm", "VfModularity/VfModule-lukewarm.xml", 200);
+ MockPutVfModuleId(wireMockServer, "skask", "lukewarm", 404);
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/DecomposeServiceIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/DecomposeServiceIT.java
index 7acaf449e3..3d15a4b29b 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/DecomposeServiceIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/DecomposeServiceIT.java
@@ -46,7 +46,7 @@ public class DecomposeServiceIT extends BaseIntegrationTest {
@Test
public void testDecomposeService_success() throws Exception{
- MockGetServiceResourcesCatalogData("cmw-123-456-789", "1.0", "/getCatalogServiceResourcesDataWithConfig.json");
+ MockGetServiceResourcesCatalogData(wireMockServer, "cmw-123-456-789", "1.0", "/getCatalogServiceResourcesDataWithConfig.json");
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
@@ -62,7 +62,7 @@ public class DecomposeServiceIT extends BaseIntegrationTest {
//@Test
@Test
public void testDecomposeService_success_partial() throws Exception{
- MockGetServiceResourcesCatalogData("cmw-123-456-789", "1.0", "/getCatalogServiceResourcesDataNoNetwork.json");
+ MockGetServiceResourcesCatalogData(wireMockServer, "cmw-123-456-789", "1.0", "/getCatalogServiceResourcesDataNoNetwork.json");
String businessKey = UUID.randomUUID().toString();
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/DeleteAAIVfModuleIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/DeleteAAIVfModuleIT.java
index f98e4477aa..99e4b8cbde 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/DeleteAAIVfModuleIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/DeleteAAIVfModuleIT.java
@@ -20,18 +20,10 @@
package org.onap.so.bpmn.common;
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.delete;
-import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
-
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-import org.camunda.bpm.engine.RuntimeService;
-import org.camunda.bpm.engine.test.Deployment;
import org.junit.Assert;
import org.junit.Test;
import org.onap.so.BaseIntegrationTest;
@@ -52,9 +44,9 @@ public class DeleteAAIVfModuleIT extends BaseIntegrationTest {
public void TestDeleteGenericVnfSuccess_200() {
// delete the Base Module and Generic Vnf
// vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c721, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a73
- new MockAAIGenericVnfSearch();
- new MockAAIDeleteGenericVnf();
- new MockAAIDeleteVfModule();
+ new MockAAIGenericVnfSearch(wireMockServer);
+ new MockAAIDeleteGenericVnf(wireMockServer);
+ new MockAAIDeleteVfModule(wireMockServer);
Map<String, Object> variables = new HashMap<>();
variables.put("isDebugLogEnabled","true");
@@ -86,9 +78,9 @@ public class DeleteAAIVfModuleIT extends BaseIntegrationTest {
" <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL +
"</vnf-request>" + EOL;
- new MockAAIGenericVnfSearch();
- new MockAAIDeleteGenericVnf();
- new MockAAIDeleteVfModule();
+ new MockAAIGenericVnfSearch(wireMockServer);
+ new MockAAIDeleteGenericVnf(wireMockServer);
+ new MockAAIDeleteVfModule(wireMockServer);
Map<String, Object> variables = new HashMap<>();
variables.put("isDebugLogEnabled","true");
@@ -119,9 +111,9 @@ public class DeleteAAIVfModuleIT extends BaseIntegrationTest {
" </vnf-inputs>" + EOL +
" <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL +
"</vnf-request>" + EOL;
- new MockAAIGenericVnfSearch();
- new MockAAIDeleteGenericVnf();
- new MockAAIDeleteVfModule();
+ new MockAAIGenericVnfSearch(wireMockServer);
+ new MockAAIDeleteGenericVnf(wireMockServer);
+ new MockAAIDeleteVfModule(wireMockServer);
Map<String, Object> variables = new HashMap<>();
variables.put("isDebugLogEnabled","true");
@@ -152,9 +144,9 @@ public class DeleteAAIVfModuleIT extends BaseIntegrationTest {
" </vnf-inputs>" + EOL +
" <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL +
"</vnf-request>" + EOL;
- new MockAAIGenericVnfSearch();
- new MockAAIDeleteGenericVnf();
- new MockAAIDeleteVfModule();
+ new MockAAIGenericVnfSearch(wireMockServer);
+ new MockAAIDeleteGenericVnf(wireMockServer);
+ new MockAAIDeleteVfModule(wireMockServer);
Map<String, Object> variables = new HashMap<>();
variables.put("isDebugLogEnabled","true");
@@ -185,9 +177,9 @@ public class DeleteAAIVfModuleIT extends BaseIntegrationTest {
" </vnf-inputs>" + EOL +
" <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL +
"</vnf-request>" + EOL;
- new MockAAIGenericVnfSearch();
- new MockAAIDeleteGenericVnf();
- new MockAAIDeleteVfModule();
+ new MockAAIGenericVnfSearch(wireMockServer);
+ new MockAAIDeleteGenericVnf(wireMockServer);
+ new MockAAIDeleteVfModule(wireMockServer);
Map<String, Object> variables = new HashMap<>();
variables.put("isDebugLogEnabled","true");
@@ -218,9 +210,9 @@ public class DeleteAAIVfModuleIT extends BaseIntegrationTest {
" </vnf-inputs>" + EOL +
" <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL +
"</vnf-request>" + EOL;
- new MockAAIGenericVnfSearch();
- new MockAAIDeleteGenericVnf();
- new MockAAIDeleteVfModule();
+ new MockAAIGenericVnfSearch(wireMockServer);
+ new MockAAIDeleteGenericVnf(wireMockServer);
+ new MockAAIDeleteVfModule(wireMockServer);
Map<String, Object> variables = new HashMap<>();
variables.put("isDebugLogEnabled","true");
@@ -251,9 +243,9 @@ public class DeleteAAIVfModuleIT extends BaseIntegrationTest {
" </vnf-inputs>" + EOL +
" <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL +
"</vnf-request>" + EOL;
- new MockAAIGenericVnfSearch();
- new MockAAIDeleteGenericVnf();
- new MockAAIDeleteVfModule();
+ new MockAAIGenericVnfSearch(wireMockServer);
+ new MockAAIDeleteGenericVnf(wireMockServer);
+ new MockAAIDeleteVfModule(wireMockServer);
Map<String, Object> variables = new HashMap<>();
variables.put("isDebugLogEnabled","true");
@@ -270,9 +262,9 @@ public class DeleteAAIVfModuleIT extends BaseIntegrationTest {
public void TestDeleteVfModuleFailure_1002_2() {
// failure attempting to delete a Vf Module that does not exist (A&AI returns 404)
// vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c720, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a76
- new MockAAIGenericVnfSearch();
- new MockAAIDeleteGenericVnf();
- new MockAAIDeleteVfModule();
+ new MockAAIGenericVnfSearch(wireMockServer);
+ new MockAAIDeleteGenericVnf(wireMockServer);
+ new MockAAIDeleteVfModule(wireMockServer);
Map<String, Object> variables = new HashMap<>();
variables.put("isDebugLogEnabled","true");
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/FalloutHandlerIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/FalloutHandlerIT.java
index f477926f99..88f8e5deb7 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/FalloutHandlerIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/FalloutHandlerIT.java
@@ -24,7 +24,6 @@ package org.onap.so.bpmn.common;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static org.onap.so.bpmn.common.BPMNUtil.waitForWorkflowToFinish;
@@ -48,12 +47,12 @@ public class FalloutHandlerIT extends BaseIntegrationTest {
private void setupMocks() {
- stubFor(post(urlEqualTo("/dbadapters/AttRequestsDbAdapter"))
+ wireMockServer.stubFor(post(urlEqualTo("/dbadapters/AttRequestsDbAdapter"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBody("<DbTag>Notified</DbTag>")));
- stubFor(post(urlEqualTo("/dbadapters/RequestsDbAdapter"))
+ wireMockServer.stubFor(post(urlEqualTo("/dbadapters/RequestsDbAdapter"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/GenerateVfModuleNameIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/GenerateVfModuleNameIT.java
index fa8823a5b4..7299e0602e 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/GenerateVfModuleNameIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/GenerateVfModuleNameIT.java
@@ -61,7 +61,7 @@ public class GenerateVfModuleNameIT extends BaseIntegrationTest {
" <vnf-params xmlns:tns=\"http://ecomp.att.com/mso/infra/vnf-request/v1\"/>" + EOL +
"</vnf-request>" + EOL;
- MockGetGenericVnfById(".*", "GenericFlows/getGenericVnfByNameResponse.xml");
+ MockGetGenericVnfById(wireMockServer, ".*", "GenericFlows/getGenericVnfByNameResponse.xml");
RuntimeService runtimeService = processEngine.getRuntimeService();
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("isDebugLogEnabled","true");
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/ManualHandlingIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/ManualHandlingIT.java
index 67ae7de928..53d29c51bf 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/ManualHandlingIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/ManualHandlingIT.java
@@ -46,7 +46,7 @@ public class ManualHandlingIT extends BaseIntegrationTest {
@Test
public void TestManualHandlingSuccess() {
- MockPostRequestDB();
+ MockPostRequestDB(wireMockServer);
Map<String, Object> variables = new HashMap<>();
variables.put("isDebugLogEnabled","true");
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/MockAAIDeleteGenericVnf.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/MockAAIDeleteGenericVnf.java
index 819962f16c..052fd5dc94 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/MockAAIDeleteGenericVnf.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/MockAAIDeleteGenericVnf.java
@@ -22,15 +22,16 @@ package org.onap.so.bpmn.common;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.delete;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
+import com.github.tomakehurst.wiremock.WireMockServer;
+
public class MockAAIDeleteGenericVnf {
- public MockAAIDeleteGenericVnf(){
- stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721/[?]resource-version=0000021"))
+ public MockAAIDeleteGenericVnf(WireMockServer wireMockServer){
+ wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721/[?]resource-version=0000021"))
.willReturn(aResponse()
.withStatus(200)));
- stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c718/[?]resource-version=0000018"))
+ wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c718/[?]resource-version=0000018"))
.willReturn(aResponse()
.withStatus(500)
.withHeader("Content-Type", "text/xml")
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/MockAAIDeleteVfModule.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/MockAAIDeleteVfModule.java
index 9cb10a0494..1cbe0b9244 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/MockAAIDeleteVfModule.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/MockAAIDeleteVfModule.java
@@ -23,31 +23,32 @@ package org.onap.so.bpmn.common;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.delete;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
+import com.github.tomakehurst.wiremock.WireMockServer;
+
public class MockAAIDeleteVfModule {
- public MockAAIDeleteVfModule()
+ public MockAAIDeleteVfModule(WireMockServer wireMockServer)
{
- stubFor(delete(urlMatching(
+ wireMockServer.stubFor(delete(urlMatching(
"/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a73/[?]resource-version=0000073"))
.willReturn(aResponse().withStatus(200)));
- stubFor(delete(urlMatching(
+ wireMockServer.stubFor(delete(urlMatching(
"/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c720/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a75/[?]resource-version=0000075"))
.willReturn(aResponse().withStatus(200)));
- stubFor(delete(urlMatching(
+ wireMockServer.stubFor(delete(urlMatching(
"/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c718/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a78/[?]resource-version=0000078"))
.willReturn(aResponse().withStatus(200)));
- stubFor(delete(urlMatching(
+ wireMockServer.stubFor(delete(urlMatching(
"/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c719/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a77/[?]resource-version=0000077"))
.willReturn(aResponse().withStatus(500).withHeader("Content-Type", "text/xml")
.withBodyFile("aaiFault.xml")));
- stubFor(get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy\\?network-policy-fqdn=.*"))
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy\\?network-policy-fqdn=.*"))
.willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
.withBodyFile("VfModularity/QueryNetworkPolicy_AAIResponse_Success.xml")));
- stubFor(delete(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/.*"))
+ wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/.*"))
.willReturn(aResponse().withStatus(200)));
}
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/MockAAIGenericVnfSearch.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/MockAAIGenericVnfSearch.java
index b46d528cc5..1d6337ffc4 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/MockAAIGenericVnfSearch.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/MockAAIGenericVnfSearch.java
@@ -22,30 +22,31 @@ package org.onap.so.bpmn.common;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
+import com.github.tomakehurst.wiremock.WireMockServer;
+
public class MockAAIGenericVnfSearch {
private static final String EOL = "\n";
- public MockAAIGenericVnfSearch(){
+ public MockAAIGenericVnfSearch(WireMockServer wireMockServer){
String body;
// The following stubs are for CreateAAIVfModule and UpdateAAIVfModule
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC23&depth=1"))
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC23&depth=1"))
.willReturn(aResponse()
.withStatus(500)
.withHeader("Content-Type", "text/xml")
.withBodyFile("aaiFault.xml")));
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC22&depth=1"))
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC22&depth=1"))
.willReturn(aResponse()
.withStatus(404)
.withHeader("Content-Type", "text/xml")
.withBody("Generic VNF Not Found")));
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/768073c7-f41f-4822-9323-b75962763d74[?]depth=1"))
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/768073c7-f41f-4822-9323-b75962763d74[?]depth=1"))
.willReturn(aResponse()
.withStatus(404)
.withHeader("Content-Type", "text/xml")
@@ -78,12 +79,12 @@ public class MockAAIGenericVnfSearch {
" <l-interfaces/>" + EOL +
" <lag-interfaces/>" + EOL +
"</generic-vnf>" + EOL;
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC21&depth=1"))
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC21&depth=1"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBody(body)));
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721[?]depth=1"))
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721[?]depth=1"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
@@ -126,12 +127,12 @@ public class MockAAIGenericVnfSearch {
" <l-interfaces/>" + EOL +
" <lag-interfaces/>" + EOL +
"</generic-vnf>" + EOL;
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC20&depth=1"))
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC20&depth=1"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBody(body)));
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/2f6aee38-1e2a-11e6-82d1-ffc7d9ee8aa4[?]depth=1"))
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/2f6aee38-1e2a-11e6-82d1-ffc7d9ee8aa4[?]depth=1"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
@@ -139,13 +140,13 @@ public class MockAAIGenericVnfSearch {
// The following stubs are for DeleteAAIVfModule
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c723[?]depth=1"))
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c723[?]depth=1"))
.willReturn(aResponse()
.withStatus(500)
.withHeader("Content-Type", "text/xml")
.withBodyFile("aaiFault.xml")));
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c722[?]depth=1"))
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c722[?]depth=1"))
.willReturn(aResponse()
.withStatus(404)
.withHeader("Content-Type", "text/xml")
@@ -178,7 +179,7 @@ public class MockAAIGenericVnfSearch {
" <l-interfaces/>" + EOL +
" <lag-interfaces/>" + EOL +
"</generic-vnf>" + EOL;
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721[?]depth=1"))
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721[?]depth=1"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
@@ -221,7 +222,7 @@ public class MockAAIGenericVnfSearch {
" <l-interfaces/>" + EOL +
" <lag-interfaces/>" + EOL +
"</generic-vnf>" + EOL;
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c720[?]depth=1"))
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c720[?]depth=1"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
@@ -264,7 +265,7 @@ public class MockAAIGenericVnfSearch {
" <l-interfaces/>" + EOL +
" <lag-interfaces/>" + EOL +
"</generic-vnf>" + EOL;
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c719[?]depth=1"))
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c719[?]depth=1"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
@@ -297,7 +298,7 @@ public class MockAAIGenericVnfSearch {
" <l-interfaces/>" + EOL +
" <lag-interfaces/>" + EOL +
"</generic-vnf>" + EOL;
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c718[?]depth=1"))
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c718[?]depth=1"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
@@ -330,7 +331,7 @@ public class MockAAIGenericVnfSearch {
" <l-interfaces/>" + EOL +
" <lag-interfaces/>" + EOL +
"</generic-vnf>" + EOL;
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a73"))
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a73"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/OofHomingIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/OofHomingIT.java
index 0c88b58b72..4d7a127a85 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/OofHomingIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/OofHomingIT.java
@@ -271,7 +271,7 @@ public class OofHomingIT extends BaseIntegrationTest {
@Test
public void testHoming_success_2AR1Vnf() throws Exception {
- mockOof();
+ mockOof(wireMockServer);
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
@@ -323,7 +323,7 @@ public class OofHomingIT extends BaseIntegrationTest {
@Test
public void testHoming_success_2AR1Vnf2Net() throws Exception {
- mockOof();
+ mockOof(wireMockServer);
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
@@ -398,7 +398,7 @@ public class OofHomingIT extends BaseIntegrationTest {
public void testHoming_success_vnfResourceList() throws Exception {
// Create a Service Decomposition
- MockGetServiceResourcesCatalogDataByModelUuid("2f7f309d-c842-4644-a2e4-34167be5eeb4",
+ MockGetServiceResourcesCatalogDataByModelUuid(wireMockServer, "2f7f309d-c842-4644-a2e4-34167be5eeb4",
"/BuildingBlocks/oofCatalogResp.json");
String busKey = UUID.randomUUID().toString();
Map<String, Object> vars = new HashMap<>();
@@ -413,7 +413,7 @@ public class OofHomingIT extends BaseIntegrationTest {
// Invoke Homing
- mockOof();
+ mockOof(wireMockServer);
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
@@ -479,7 +479,7 @@ public class OofHomingIT extends BaseIntegrationTest {
@Test
public void testHoming_success_existingLicense() throws Exception {
- mockOof();
+ mockOof(wireMockServer);
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<String, Object>();
@@ -549,7 +549,7 @@ public class OofHomingIT extends BaseIntegrationTest {
@Test
public void testHoming_error_badResponse() throws Exception {
- mockOof_500();
+ mockOof_500(wireMockServer);
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
@@ -568,7 +568,7 @@ public class OofHomingIT extends BaseIntegrationTest {
@Test
public void testHoming_error_oofNoSolution() throws Exception {
- mockOof();
+ mockOof(wireMockServer);
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
@@ -590,7 +590,7 @@ public class OofHomingIT extends BaseIntegrationTest {
@Test
public void testHoming_error_oofPolicyException() throws Exception {
- mockOof();
+ mockOof(wireMockServer);
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
@@ -613,7 +613,7 @@ public class OofHomingIT extends BaseIntegrationTest {
@Test
public void testHoming_error_oofServiceException() throws Exception {
- mockOof();
+ mockOof(wireMockServer);
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/OofHomingTestIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/OofHomingTestIT.java
index b370e6c48f..390f5294aa 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/OofHomingTestIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/OofHomingTestIT.java
@@ -279,7 +279,7 @@ public class OofHomingTestIT extends BaseIntegrationTest {
public void testHoming_success_2AR1Vnf() throws Exception {
- mockOof();
+ mockOof(wireMockServer);
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
@@ -332,7 +332,7 @@ public class OofHomingTestIT extends BaseIntegrationTest {
public void testHoming_success_2AR1Vnf2Net() throws Exception {
- mockOof();
+ mockOof(wireMockServer);
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
@@ -409,7 +409,7 @@ public class OofHomingTestIT extends BaseIntegrationTest {
public void testHoming_success_vnfResourceList() throws Exception {
// Create a Service Decomposition
- MockGetServiceResourcesCatalogDataByModelUuid("2f7f309d-c842-4644-a2e4-34167be5eeb4",
+ MockGetServiceResourcesCatalogDataByModelUuid(wireMockServer, "2f7f309d-c842-4644-a2e4-34167be5eeb4",
"/BuildingBlocks/oofCatalogResp.json");
String busKey = UUID.randomUUID().toString();
Map<String, Object> vars = new HashMap<>();
@@ -425,7 +425,7 @@ public class OofHomingTestIT extends BaseIntegrationTest {
// Invoke Homing
- mockOof();
+ mockOof(wireMockServer);
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
@@ -489,7 +489,7 @@ public class OofHomingTestIT extends BaseIntegrationTest {
@Test
public void testHoming_success_existingLicense() throws Exception {
- mockOof();
+ mockOof(wireMockServer);
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<String, Object>();
@@ -560,7 +560,7 @@ public class OofHomingTestIT extends BaseIntegrationTest {
@Test
public void testHoming_error_badResponse() throws Exception {
- mockOof_500();
+ mockOof_500(wireMockServer);
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
@@ -581,7 +581,7 @@ public class OofHomingTestIT extends BaseIntegrationTest {
@Test
public void testHoming_error_oofNoSolution() throws Exception {
- mockOof();
+ mockOof(wireMockServer);
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
@@ -604,7 +604,7 @@ public class OofHomingTestIT extends BaseIntegrationTest {
@Test
public void testHoming_error_oofPolicyException() throws Exception {
- mockOof();
+ mockOof(wireMockServer);
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
@@ -628,7 +628,7 @@ public class OofHomingTestIT extends BaseIntegrationTest {
@Test
public void testHoming_error_oofServiceException() throws Exception {
- mockOof();
+ mockOof(wireMockServer);
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/PrepareUpdateAAIVfModuleIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/PrepareUpdateAAIVfModuleIT.java
index 8b8abab6b2..c994173cd7 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/PrepareUpdateAAIVfModuleIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/PrepareUpdateAAIVfModuleIT.java
@@ -61,9 +61,9 @@ public class PrepareUpdateAAIVfModuleIT extends BaseIntegrationTest {
String prepareUpdateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/PrepareUpdateAAIVfModuleRequest.xml");
- MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml");
- MockPutGenericVnf("/skask/vf-modules/vf-module/supercool", "PCRF", 200);
- MockPatchVfModuleId("skask", "supercool");
+ MockGetGenericVnfByIdWithDepth(wireMockServer, "skask", 1, "VfModularity/GenericVnf.xml");
+ MockPutGenericVnf(wireMockServer, "/skask/vf-modules/vf-module/supercool", "PCRF", 200);
+ MockPatchVfModuleId(wireMockServer, "skask", "supercool");
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
@@ -95,7 +95,7 @@ public class PrepareUpdateAAIVfModuleIT extends BaseIntegrationTest {
logStart();
String prepareUpdateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/PrepareUpdateAAIVfModuleRequest.xml");
- MockGetGenericVnfById_404("skask[?]depth=1");
+ MockGetGenericVnfById_404(wireMockServer, "skask[?]depth=1");
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
@@ -128,7 +128,7 @@ public class PrepareUpdateAAIVfModuleIT extends BaseIntegrationTest {
String prepareUpdateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/PrepareUpdateAAIVfModuleRequest.xml").replaceFirst("supercool", "lukewarm");
- MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml");
+ MockGetGenericVnfByIdWithDepth(wireMockServer, "skask", 1, "VfModularity/GenericVnf.xml");
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
@@ -156,7 +156,7 @@ public class PrepareUpdateAAIVfModuleIT extends BaseIntegrationTest {
String prepareUpdateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/PrepareUpdateAAIVfModuleRequest.xml").replaceFirst("supercool", "notsocool");
- MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml");
+ MockGetGenericVnfByIdWithDepth(wireMockServer, "skask", 1, "VfModularity/GenericVnf.xml");
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
@@ -184,8 +184,8 @@ public class PrepareUpdateAAIVfModuleIT extends BaseIntegrationTest {
String prepareUpdateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/PrepareUpdateAAIVfModuleRequest.xml");
- MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml");
- MockAAIVfModuleBadPatch("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/supercool", 404);
+ MockGetGenericVnfByIdWithDepth(wireMockServer, "skask", 1, "VfModularity/GenericVnf.xml");
+ MockAAIVfModuleBadPatch(wireMockServer, "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/supercool", 404);
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/RainyDayHandlerIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/RainyDayHandlerIT.java
index 7b85edf49a..2f6d2ae85b 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/RainyDayHandlerIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/RainyDayHandlerIT.java
@@ -52,7 +52,7 @@ public class RainyDayHandlerIT extends BaseIntegrationTest {
variables.put("errorText", "update failed");
variables.put("vnfName", "vSAMP1");
- MockPolicyAbort();
+ MockPolicyAbort(wireMockServer);
String businessKey = UUID.randomUUID().toString();
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/SDNCAdapterRestV2IT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/SDNCAdapterRestV2IT.java
index 12e12dc7d6..bf3fefdf9c 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/SDNCAdapterRestV2IT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/SDNCAdapterRestV2IT.java
@@ -24,7 +24,6 @@ package org.onap.so.bpmn.common;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import java.io.IOException;
@@ -115,7 +114,7 @@ public class SDNCAdapterRestV2IT extends BaseIntegrationTest {
* Defines WireMock stubs needed by these tests.
*/
private void mocks() {
- stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc"))
+ wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc"))
.willReturn(aResponse()
.withStatus(202)
.withHeader("Content-Type", "application/json")));
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/SniroHomingV1IT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/SniroHomingV1IT.java
index 2205d01cca..c7ba702212 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/SniroHomingV1IT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/SniroHomingV1IT.java
@@ -140,7 +140,7 @@ public class SniroHomingV1IT extends BaseIntegrationTest {
public void testHoming_success_2AR1Vnf() throws Exception {
- mockSNIRO();
+ mockSNIRO(wireMockServer);
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
@@ -184,7 +184,7 @@ public class SniroHomingV1IT extends BaseIntegrationTest {
public void testHoming_success_2AR1Vnf2Net() throws Exception {
- mockSNIRO();
+ mockSNIRO(wireMockServer);
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
@@ -239,7 +239,7 @@ public class SniroHomingV1IT extends BaseIntegrationTest {
public void testHoming_success_vnfResourceList() throws Exception {
// Create a Service Decomposition
- MockGetServiceResourcesCatalogDataByModelUuid("2f7f309d-c842-4644-a2e4-34167be5eeb4", "/BuildingBlocks/catalogResp.json");
+ MockGetServiceResourcesCatalogDataByModelUuid(wireMockServer, "2f7f309d-c842-4644-a2e4-34167be5eeb4", "/BuildingBlocks/catalogResp.json");
String busKey = UUID.randomUUID().toString();
Map<String, Object> vars = new HashMap<>();
setVariablesForServiceDecomposition(vars, "testRequestId123", "ff5256d2-5a33-55df-13ab-12abad84e7ff");
@@ -251,7 +251,7 @@ public class SniroHomingV1IT extends BaseIntegrationTest {
// Invoke Homing
- mockSNIRO();
+ mockSNIRO(wireMockServer);
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
@@ -290,7 +290,7 @@ public class SniroHomingV1IT extends BaseIntegrationTest {
public void testHoming_success_existingLicense() throws Exception {
- mockSNIRO();
+ mockSNIRO(wireMockServer);
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<String, Object>();
@@ -351,7 +351,7 @@ public class SniroHomingV1IT extends BaseIntegrationTest {
@Test
public void testHoming_error_badResponse() throws Exception {
- mockSNIRO_500();
+ mockSNIRO_500(wireMockServer);
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
@@ -371,7 +371,7 @@ public class SniroHomingV1IT extends BaseIntegrationTest {
// 1802 merge
public void testHoming_error_sniroNoSolution() throws Exception {
- mockSNIRO();
+ mockSNIRO(wireMockServer);
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
@@ -392,7 +392,7 @@ public class SniroHomingV1IT extends BaseIntegrationTest {
@Test
public void testHoming_error_sniroPolicyException() throws Exception {
- mockSNIRO();
+ mockSNIRO(wireMockServer);
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
@@ -413,7 +413,7 @@ public class SniroHomingV1IT extends BaseIntegrationTest {
@Test
public void testHoming_error_sniroServiceException() throws Exception {
- mockSNIRO();
+ mockSNIRO(wireMockServer);
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/UpdateAAIGenericVnfIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/UpdateAAIGenericVnfIT.java
index 48790708f0..5015a1351a 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/UpdateAAIGenericVnfIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/UpdateAAIGenericVnfIT.java
@@ -62,9 +62,9 @@ public class UpdateAAIGenericVnfIT extends BaseIntegrationTest {
logStart();
String updateAAIGenericVnfRequest = FileUtil.readResourceFile("__files/VfModularity/UpdateAAIGenericVnfRequest.xml");
- MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml");
- MockPutGenericVnf("/skask", 200);
- MockPatchGenericVnf("skask");
+ MockGetGenericVnfByIdWithDepth(wireMockServer, "skask", 1, "VfModularity/GenericVnf.xml");
+ MockPutGenericVnf(wireMockServer, "/skask", 200);
+ MockPatchGenericVnf(wireMockServer, "skask");
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
@@ -95,7 +95,7 @@ public class UpdateAAIGenericVnfIT extends BaseIntegrationTest {
String updateAAIGenericVnfRequest = FileUtil.readResourceFile("__files/VfModularity/UpdateAAIGenericVnfRequest.xml");
updateAAIGenericVnfRequest = updateAAIGenericVnfRequest.replaceFirst("introvert", "extrovert");
- MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml");
+ MockGetGenericVnfByIdWithDepth(wireMockServer, "skask", 1, "VfModularity/GenericVnf.xml");
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
@@ -123,7 +123,7 @@ public class UpdateAAIGenericVnfIT extends BaseIntegrationTest {
String updateAAIGenericVnfRequest = FileUtil.readResourceFile("__files/VfModularity/UpdateAAIGenericVnfRequest.xml");
- MockGetGenericVnfById_404("skask[?]depth=1");
+ MockGetGenericVnfById_404(wireMockServer, "skask[?]depth=1");
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
@@ -153,9 +153,9 @@ public class UpdateAAIGenericVnfIT extends BaseIntegrationTest {
String updateAAIGenericVnfRequest = FileUtil.readResourceFile("__files/VfModularity/UpdateAAIGenericVnfRequest.xml");
- MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml");
- MockPutGenericVnf_Bad("skask", 404);
- MockAAIVfModuleBadPatch("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask", 404);
+ MockGetGenericVnfByIdWithDepth(wireMockServer, "skask", 1, "VfModularity/GenericVnf.xml");
+ MockPutGenericVnf_Bad(wireMockServer, "skask", 404);
+ MockAAIVfModuleBadPatch(wireMockServer, "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask", 404);
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/UpdateAAIVfModuleIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/UpdateAAIVfModuleIT.java
index 2ba5c7286e..0a3931a12f 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/UpdateAAIVfModuleIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/UpdateAAIVfModuleIT.java
@@ -61,9 +61,9 @@ public class UpdateAAIVfModuleIT extends BaseIntegrationTest {
logStart();
String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/UpdateAAIVfModuleRequest.xml");
- MockGetGenericVnfByIdWithPriority("/skask/vf-modules/vf-module/supercool", 200, "VfModularity/VfModule-supercool.xml");
- MockPutGenericVnf("/skask/vf-modules/vf-module/supercool", "PCRF", 200);
- MockPatchVfModuleId("skask", "supercool");
+ MockGetGenericVnfByIdWithPriority(wireMockServer, "/skask/vf-modules/vf-module/supercool", 200, "VfModularity/VfModule-supercool.xml");
+ MockPutGenericVnf(wireMockServer, "/skask/vf-modules/vf-module/supercool", "PCRF", 200);
+ MockPatchVfModuleId(wireMockServer, "skask", "supercool");
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
@@ -92,7 +92,7 @@ public class UpdateAAIVfModuleIT extends BaseIntegrationTest {
logStart();
String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/UpdateAAIVfModuleRequest.xml");
- MockGetGenericVnfById("/skask/vf-modules/vf-module/.*", "VfModularity/VfModule-supercool.xml", 404);
+ MockGetGenericVnfById(wireMockServer, "/skask/vf-modules/vf-module/.*", "VfModularity/VfModule-supercool.xml", 404);
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
@@ -121,9 +121,9 @@ public class UpdateAAIVfModuleIT extends BaseIntegrationTest {
logStart();
String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/UpdateAAIVfModuleRequest.xml");
- MockGetGenericVnfById_404("/skask/vf-modules/vf-module/supercool");
- MockGetGenericVnfById("/skask/vf-modules/vf-module/supercool", "VfModularity/VfModule-supercool.xml", 200);
- MockAAIVfModuleBadPatch("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/supercool", 404);
+ MockGetGenericVnfById_404(wireMockServer, "/skask/vf-modules/vf-module/supercool");
+ MockGetGenericVnfById(wireMockServer, "/skask/vf-modules/vf-module/supercool", "VfModularity/VfModule-supercool.xml", 200);
+ MockAAIVfModuleBadPatch(wireMockServer, "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/supercool", 404);
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/VnfAdapterRestV1IT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/VnfAdapterRestV1IT.java
index 1ef864b543..c0482a52ca 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/VnfAdapterRestV1IT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/VnfAdapterRestV1IT.java
@@ -247,7 +247,7 @@ public class VnfAdapterRestV1IT extends BaseIntegrationTest {
public void testCreateVfModuleSuccess() throws Exception {
logStart();
- mockVNFPost("", 202, "vnfId");
+ mockVNFPost(wireMockServer, "", 202, "vnfId");
String requestId = "dffbae0e-5588-4bd6-9749-b0f0adb52312";
String messageId = requestId + "-" + System.currentTimeMillis();
@@ -276,7 +276,7 @@ public class VnfAdapterRestV1IT extends BaseIntegrationTest {
public void testUpdateVfModuleSuccess() throws Exception {
logStart();
- mockVNFPut("/vfModuleId", 202);
+ mockVNFPut(wireMockServer, "/vfModuleId", 202);
String requestId = "dffbae0e-5588-4bd6-9749-b0f0adb52312";
String messageId = requestId + "-" + System.currentTimeMillis();
@@ -305,7 +305,7 @@ public class VnfAdapterRestV1IT extends BaseIntegrationTest {
public void testDeleteVfModuleSuccess() throws Exception {
logStart();
- mockVNFDelete("vnfId", "/vfModuleId", 202);
+ mockVNFDelete(wireMockServer, "vnfId", "/vfModuleId", 202);
String requestId = "dffbae0e-5588-4bd6-9749-b0f0adb52312";
String messageId = requestId + "-" + System.currentTimeMillis();
@@ -334,7 +334,7 @@ public class VnfAdapterRestV1IT extends BaseIntegrationTest {
public void testRollbackVfModuleSuccess() throws Exception {
logStart();
- mockVNFRollbackDelete("/vfModuleId", 202);
+ mockVNFRollbackDelete(wireMockServer, "/vfModuleId", 202);
String requestId = "dffbae0e-5588-4bd6-9749-b0f0adb52312";
String messageId = requestId + "-" + System.currentTimeMillis();
@@ -363,7 +363,7 @@ public class VnfAdapterRestV1IT extends BaseIntegrationTest {
public void testCreateVfModuleException() throws Exception {
logStart();
- mockVNFPost("", 202, "vnfId");
+ mockVNFPost(wireMockServer, "", 202, "vnfId");
String requestId = "dffbae0e-5588-4bd6-9749-b0f0adb52312";
String messageId = requestId + "-" + System.currentTimeMillis();
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/CreateVcpeResCustServiceIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/CreateVcpeResCustServiceIT.java
index 610930665c..aa65474acc 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/CreateVcpeResCustServiceIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/CreateVcpeResCustServiceIT.java
@@ -24,7 +24,6 @@ import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.put;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -101,43 +100,43 @@ public class CreateVcpeResCustServiceIT extends AbstractTestBase {
@Test
public void testCreateVcpeResCustService_Success() throws Exception {
System.out.println("starting: testCreateVcpeResCustService_Success\n");
- MockGetServiceResourcesCatalogData("uuid-miu-svc-011-abcdef", "2","VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json");
- MockGetServiceResourcesCatalogData("uuid-miu-svc-011-abcdef", "VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json");
- MockGetCustomer(CUST, "VCPE/CreateVcpeResCustService/getCustomer.xml");
- StubResponseOof.mockOof();
+ MockGetServiceResourcesCatalogData(wireMockServer, "uuid-miu-svc-011-abcdef", "2","VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json");
+ MockGetServiceResourcesCatalogData(wireMockServer, "uuid-miu-svc-011-abcdef", "VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json");
+ MockGetCustomer(wireMockServer, CUST, "VCPE/CreateVcpeResCustService/getCustomer.xml");
+ StubResponseOof.mockOof(wireMockServer);
// TODO: the SI should NOT have to be URL-encoded yet again!
- MockPutServiceInstance(CUST, SVC, INST.replace("%", "%25"), "GenericFlows/getServiceInstance.xml");
- MockGetServiceInstance(CUST, SVC, INST.replace("%", "%25"), "GenericFlows/getServiceInstance.xml");
+ MockPutServiceInstance(wireMockServer, CUST, SVC, INST.replace("%", "%25"), "GenericFlows/getServiceInstance.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, INST.replace("%", "%25"), "GenericFlows/getServiceInstance.xml");
- MockNodeQueryServiceInstanceById(INST, "GenericFlows/getSIUrlById.xml");
- MockNodeQueryServiceInstanceById(PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
- MockGetServiceInstance(CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
- MockGetServiceInstance(CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
- MockPutAllottedResource(CUST, SVC, PARENT_INST, ARID);
- MockPatchAllottedResource(CUST, SVC, PARENT_INST, ARID);
- MockGetGenericVnfByIdWithDepth(".*", 1, "VCPE/CreateVcpeResCustService/GenericVnf.xml");
-
- MockPutGenericVnf(".*");
- MockPatchGenericVnf(".*");
-
- MockGetGenericVnfByIdWithPriority(".*", ".*", 200, "VfModularity/VfModule-new.xml", 5);
- // MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml");
- MockPutVfModuleIdNoResponse(".*", "PCRF", ".*");
- MockPutNetwork(".*", "VfModularity/AddNetworkPolicy_AAIResponse_Success.xml", 200);
-
- MockGetNetworkPolicyfqdn(".*","CreateNetworkV2/createNetwork_queryNetworkPolicy_AAIResponse_Success.xml",200);
- MockNodeQueryServiceInstanceByName_404(".*");
-
- mockVNFPost("", 202, ".*");
-
- stubFor(post(urlMatching("/services/rest/v1/vnfs" + ".*" + "/vf-modules" )).willReturn(aResponse().withStatus(202)));
- stubFor(get(urlMatching(".*/business/owning-entities?.*")).willReturn(aResponse().withStatus(404)));
- stubFor(put(urlMatching(".*/business/owning-entities/owning-entity/.*")).willReturn(aResponse().withStatus(200)));
- stubFor(put(urlMatching(".*/business/owning-entities/owning-entity/038d99af-0427-42c2-9d15-971b99b9b489/relationship-list/relationship")).willReturn(aResponse().withStatus(200)));
- stubFor(put(urlMatching(".*/query?.*")).willReturn(aResponse().withStatus(200)));
- MockPostRequestDB();
- mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
- mockSDNCAdapter(200);
+ MockNodeQueryServiceInstanceById(wireMockServer, INST, "GenericFlows/getSIUrlById.xml");
+ MockNodeQueryServiceInstanceById(wireMockServer, PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
+ MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ MockGetGenericVnfByIdWithDepth(wireMockServer, ".*", 1, "VCPE/CreateVcpeResCustService/GenericVnf.xml");
+
+ MockPutGenericVnf(wireMockServer, ".*");
+ MockPatchGenericVnf(wireMockServer, ".*");
+
+ MockGetGenericVnfByIdWithPriority(wireMockServer, ".*", ".*", 200, "VfModularity/VfModule-new.xml", 5);
+ // MockGetGenericVnfByIdWithDepth(wireMockServer, "skask", 1, "VfModularity/GenericVnf.xml");
+ MockPutVfModuleIdNoResponse(wireMockServer, ".*", "PCRF", ".*");
+ MockPutNetwork(wireMockServer, ".*", "VfModularity/AddNetworkPolicy_AAIResponse_Success.xml", 200);
+
+ MockGetNetworkPolicyfqdn(wireMockServer, ".*","CreateNetworkV2/createNetwork_queryNetworkPolicy_AAIResponse_Success.xml",200);
+ MockNodeQueryServiceInstanceByName_404(wireMockServer, ".*");
+
+ mockVNFPost(wireMockServer, "", 202, ".*");
+
+ wireMockServer.stubFor(post(urlMatching("/services/rest/v1/vnfs" + ".*" + "/vf-modules" )).willReturn(aResponse().withStatus(202)));
+ wireMockServer.stubFor(get(urlMatching(".*/business/owning-entities?.*")).willReturn(aResponse().withStatus(404)));
+ wireMockServer.stubFor(put(urlMatching(".*/business/owning-entities/owning-entity/.*")).willReturn(aResponse().withStatus(200)));
+ wireMockServer.stubFor(put(urlMatching(".*/business/owning-entities/owning-entity/038d99af-0427-42c2-9d15-971b99b9b489/relationship-list/relationship")).willReturn(aResponse().withStatus(200)));
+ wireMockServer.stubFor(put(urlMatching(".*/query?.*")).willReturn(aResponse().withStatus(200)));
+ MockPostRequestDB(wireMockServer);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
+ mockSDNCAdapter(wireMockServer, 200);
Map<String, Object> variables = setupVariables();
@@ -195,33 +194,33 @@ public class CreateVcpeResCustServiceIT extends AbstractTestBase {
@Test
public void testCreateVcpeResCustService_NoParts() throws Exception {
System.out.println("starting: testCreateVcpeResCustService_NoParts\n" );
- MockGetServiceResourcesCatalogData("uuid-miu-svc-011-abcdef", "2", "VCPE/CreateVcpeResCustService/getCatalogServiceResourcesNoData.json");
- MockGetServiceResourcesCatalogData("uuid-miu-svc-011-abcdef", "VCPE/CreateVcpeResCustService/getCatalogServiceResourcesNoData.json");
- MockGetCustomer(CUST, "VCPE/CreateVcpeResCustService/getCustomer.xml");
+ MockGetServiceResourcesCatalogData(wireMockServer, "uuid-miu-svc-011-abcdef", "2", "VCPE/CreateVcpeResCustService/getCatalogServiceResourcesNoData.json");
+ MockGetServiceResourcesCatalogData(wireMockServer, "uuid-miu-svc-011-abcdef", "VCPE/CreateVcpeResCustService/getCatalogServiceResourcesNoData.json");
+ MockGetCustomer(wireMockServer, CUST, "VCPE/CreateVcpeResCustService/getCustomer.xml");
// TODO: the SI should NOT have to be URL-encoded yet again!
- MockPutServiceInstance(CUST, SVC, INST.replace("%", "%25"), "GenericFlows/getServiceInstance.xml");
- MockGetServiceInstance(CUST, SVC, INST.replace("%", "%25"), "GenericFlows/getServiceInstance.xml");
+ MockPutServiceInstance(wireMockServer, CUST, SVC, INST.replace("%", "%25"), "GenericFlows/getServiceInstance.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, INST.replace("%", "%25"), "GenericFlows/getServiceInstance.xml");
- MockNodeQueryServiceInstanceById(INST, "GenericFlows/getSIUrlById.xml");
- MockGetServiceInstance(CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
- MockNodeQueryServiceInstanceById(PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
- MockGetServiceInstance(CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
+ MockNodeQueryServiceInstanceById(wireMockServer, INST, "GenericFlows/getSIUrlById.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
+ MockNodeQueryServiceInstanceById(wireMockServer, PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
// TODO: should these really be PARENT_INST, or should they be INST?
- MockPutAllottedResource(CUST, SVC, PARENT_INST, ARID);
- MockPatchAllottedResource(CUST, SVC, PARENT_INST, ARID);
-
- mockSDNCAdapter(200);
- mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
-
- StubResponseOof.mockOof();
- stubFor(get(urlMatching(".*/business/owning-entities?.*")).willReturn(aResponse().withStatus(404)));
- stubFor(put(urlMatching(".*/business/owning-entities/owning-entity/.*")).willReturn(aResponse().withStatus(200)));
- stubFor(put(urlMatching(".*/business/owning-entities/owning-entity/038d99af-0427-42c2-9d15-971b99b9b489/relationship-list/relationship")).willReturn(aResponse().withStatus(200)));
- stubFor(put(urlMatching(".*/query?.*")).willReturn(aResponse().withStatus(200)));
- MockPostRequestDB();
- mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
+ MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
+
+ StubResponseOof.mockOof(wireMockServer);
+ wireMockServer.stubFor(get(urlMatching(".*/business/owning-entities?.*")).willReturn(aResponse().withStatus(404)));
+ wireMockServer.stubFor(put(urlMatching(".*/business/owning-entities/owning-entity/.*")).willReturn(aResponse().withStatus(200)));
+ wireMockServer.stubFor(put(urlMatching(".*/business/owning-entities/owning-entity/038d99af-0427-42c2-9d15-971b99b9b489/relationship-list/relationship")).willReturn(aResponse().withStatus(200)));
+ wireMockServer.stubFor(put(urlMatching(".*/query?.*")).willReturn(aResponse().withStatus(200)));
+ MockPostRequestDB(wireMockServer);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
Map<String, Object> variables = setupVariables();
@@ -253,30 +252,30 @@ public class CreateVcpeResCustServiceIT extends AbstractTestBase {
@Test
public void testCreateVcpeResCustService_Fault_NoRollback() throws Exception {
System.out.println("starting: testCreateVcpeResCustService_Fault_NoRollback\n");
- MockGetServiceResourcesCatalogData("uuid-miu-svc-011-abcdef", "2", "VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json");
- MockGetServiceResourcesCatalogData("uuid-miu-svc-011-abcdef", "VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json");
- MockGetCustomer(CUST, "VCPE/CreateVcpeResCustService/getCustomer.xml");
+ MockGetServiceResourcesCatalogData(wireMockServer, "uuid-miu-svc-011-abcdef", "2", "VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json");
+ MockGetServiceResourcesCatalogData(wireMockServer, "uuid-miu-svc-011-abcdef", "VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json");
+ MockGetCustomer(wireMockServer, CUST, "VCPE/CreateVcpeResCustService/getCustomer.xml");
// TODO: the SI should NOT have to be URL-encoded yet again!
- MockPutServiceInstance(CUST, SVC, INST.replace("%", "%25"), "GenericFlows/getServiceInstance.xml");
- MockGetServiceInstance(CUST, SVC, INST.replace("%", "%25"), "GenericFlows/getServiceInstance.xml");
+ MockPutServiceInstance(wireMockServer, CUST, SVC, INST.replace("%", "%25"), "GenericFlows/getServiceInstance.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, INST.replace("%", "%25"), "GenericFlows/getServiceInstance.xml");
- MockNodeQueryServiceInstanceById(INST, "GenericFlows/getSIUrlById.xml");
- MockNodeQueryServiceInstanceById(PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
- MockGetServiceInstance(CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
- MockGetServiceInstance_500(CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
- MockPutAllottedResource(CUST, SVC, PARENT_INST, ARID);
- MockPatchAllottedResource(CUST, SVC, PARENT_INST, ARID);
-
- mockSDNCAdapter(404);
- mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
-
- StubResponseOof.mockOof();
- stubFor(get(urlMatching(".*/business/owning-entities?.*")).willReturn(aResponse().withStatus(404)));
- stubFor(put(urlMatching(".*/business/owning-entities/owning-entity/.*")).willReturn(aResponse().withStatus(200)));
- stubFor(put(urlMatching(".*/business/owning-entities/owning-entity/038d99af-0427-42c2-9d15-971b99b9b489/relationship-list/relationship")).willReturn(aResponse().withStatus(200)));
- stubFor(put(urlMatching(".*/query?.*")).willReturn(aResponse().withStatus(200)));
- MockPostRequestDB();
+ MockNodeQueryServiceInstanceById(wireMockServer, INST, "GenericFlows/getSIUrlById.xml");
+ MockNodeQueryServiceInstanceById(wireMockServer, PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
+ MockGetServiceInstance_500(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
+ MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+
+ mockSDNCAdapter(wireMockServer, 404);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
+
+ StubResponseOof.mockOof(wireMockServer);
+ wireMockServer.stubFor(get(urlMatching(".*/business/owning-entities?.*")).willReturn(aResponse().withStatus(404)));
+ wireMockServer.stubFor(put(urlMatching(".*/business/owning-entities/owning-entity/.*")).willReturn(aResponse().withStatus(200)));
+ wireMockServer.stubFor(put(urlMatching(".*/business/owning-entities/owning-entity/038d99af-0427-42c2-9d15-971b99b9b489/relationship-list/relationship")).willReturn(aResponse().withStatus(200)));
+ wireMockServer.stubFor(put(urlMatching(".*/query?.*")).willReturn(aResponse().withStatus(200)));
+ MockPostRequestDB(wireMockServer);
Map<String, Object> variables = setupVariables();
@@ -305,33 +304,33 @@ public class CreateVcpeResCustServiceIT extends AbstractTestBase {
@Test
public void testCreateVcpeResCustService_Fault_Rollback() throws Exception {
System.out.println("starting: testCreateVcpeResCustService_Fault_Rollback\n");
- MockGetServiceResourcesCatalogData("uuid-miu-svc-011-abcdef", "2", "VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json");
- MockGetServiceResourcesCatalogData("uuid-miu-svc-011-abcdef", "VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json");
- MockGetCustomer(CUST, "VCPE/CreateVcpeResCustService/getCustomer.xml");
+ MockGetServiceResourcesCatalogData(wireMockServer, "uuid-miu-svc-011-abcdef", "2", "VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json");
+ MockGetServiceResourcesCatalogData(wireMockServer, "uuid-miu-svc-011-abcdef", "VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json");
+ MockGetCustomer(wireMockServer, CUST, "VCPE/CreateVcpeResCustService/getCustomer.xml");
// TODO: the SI should NOT have to be URL-encoded yet again!
- MockPutServiceInstance(CUST, SVC, INST.replace("%", "%25"), "GenericFlows/getServiceInstance.xml");
- MockGetServiceInstance(CUST, SVC, INST.replace("%", "%25"), "GenericFlows/getServiceInstance.xml");
+ MockPutServiceInstance(wireMockServer, CUST, SVC, INST.replace("%", "%25"), "GenericFlows/getServiceInstance.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, INST.replace("%", "%25"), "GenericFlows/getServiceInstance.xml");
- MockNodeQueryServiceInstanceById(INST, "GenericFlows/getSIUrlById.xml");
- MockNodeQueryServiceInstanceById(PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
- MockGetServiceInstance(CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
- MockGetServiceInstance(CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/CreateVcpeResCustService/arGetById.xml");
- MockGetAllottedResource(CUST, SVC, PARENT_INST, ARID, "VCPE/CreateVcpeResCustService/arGetById.xml");
- MockPutAllottedResource(CUST, SVC, PARENT_INST, ARID);
- MockPatchAllottedResource(CUST, SVC, PARENT_INST, ARID);
- MockDeleteAllottedResource(CUST, SVC, PARENT_INST, ARID, ARVERS);
-
- mockSDNCAdapter(200);
- mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
-
- StubResponseOof.mockOof();
- stubFor(get(urlMatching(".*/business/owning-entities?.*")).willReturn(aResponse().withStatus(404)));
- stubFor(put(urlMatching(".*/business/owning-entities/owning-entity/.*")).willReturn(aResponse().withStatus(200)));
- stubFor(put(urlMatching(".*/business/owning-entities/owning-entity/038d99af-0427-42c2-9d15-971b99b9b489/relationship-list/relationship")).willReturn(aResponse().withStatus(200)));
- stubFor(put(urlMatching(".*/query?.*")).willReturn(aResponse().withStatus(200)));
- MockPostRequestDB();
+ MockNodeQueryServiceInstanceById(wireMockServer, INST, "GenericFlows/getSIUrlById.xml");
+ MockNodeQueryServiceInstanceById(wireMockServer, PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/CreateVcpeResCustService/arGetById.xml");
+ MockGetAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID, "VCPE/CreateVcpeResCustService/arGetById.xml");
+ MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID, ARVERS);
+
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
+
+ StubResponseOof.mockOof(wireMockServer);
+ wireMockServer.stubFor(get(urlMatching(".*/business/owning-entities?.*")).willReturn(aResponse().withStatus(404)));
+ wireMockServer.stubFor(put(urlMatching(".*/business/owning-entities/owning-entity/.*")).willReturn(aResponse().withStatus(200)));
+ wireMockServer.stubFor(put(urlMatching(".*/business/owning-entities/owning-entity/038d99af-0427-42c2-9d15-971b99b9b489/relationship-list/relationship")).willReturn(aResponse().withStatus(200)));
+ wireMockServer.stubFor(put(urlMatching(".*/query?.*")).willReturn(aResponse().withStatus(200)));
+ MockPostRequestDB(wireMockServer);
String req = FileUtil.readResourceFile("__files/VCPE/CreateVcpeResCustService/requestRollback.json");
Map<String, Object> variables = setupVariables();
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DeleteVcpeResCustServiceIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DeleteVcpeResCustServiceIT.java
index ca81d99832..aaabf59e6b 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DeleteVcpeResCustServiceIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DeleteVcpeResCustServiceIT.java
@@ -20,22 +20,9 @@
package org.onap.so.bpmn.vcpe;
-import com.github.tomakehurst.wiremock.stubbing.Scenario;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.so.bpmn.common.BPMNUtil;
-import org.onap.so.bpmn.mock.FileUtil;
-
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.delete;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -51,6 +38,19 @@ import static org.onap.so.bpmn.mock.StubResponseAAI.MockQueryAllottedResourceByI
import static org.onap.so.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB;
import static org.onap.so.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.so.bpmn.common.BPMNUtil;
+import org.onap.so.bpmn.mock.FileUtil;
+
+import com.github.tomakehurst.wiremock.stubbing.Scenario;
+
public class DeleteVcpeResCustServiceIT extends AbstractTestBase {
private static final String PROCNAME = "DeleteVcpeResCustService";
@@ -77,7 +77,7 @@ public class DeleteVcpeResCustServiceIT extends AbstractTestBase {
@Test
public void testDeleteVcpeResCustService_Success() throws Exception {
logStart();
- MockNodeQueryServiceInstanceById(INST, "GenericFlows/getSIUrlById.xml");
+ MockNodeQueryServiceInstanceById(wireMockServer, INST, "GenericFlows/getSIUrlById.xml");
// TODO: use INST instead of DEC_INST
/*
@@ -85,15 +85,15 @@ public class DeleteVcpeResCustServiceIT extends AbstractTestBase {
* fail to URL-encode the SI id before performing the query so we'll
* add a stub for that case, too.
*/
- MockNodeQueryServiceInstanceById(DEC_INST, "GenericFlows/getSIUrlById.xml");
+ MockNodeQueryServiceInstanceById(wireMockServer, DEC_INST, "GenericFlows/getSIUrlById.xml");
/*
- * cannot use MockGetServiceInstance(), because we need to return
+ * cannot use MockGetServiceInstance(wireMockServer, ), because we need to return
* different responses as we traverse through the flow
*/
// initially, the SI includes the ARs
- stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + CUST + "/service-subscriptions/service-subscription/" + SVC + "/service-instances/service-instance/" + INST))
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + CUST + "/service-subscriptions/service-subscription/" + SVC + "/service-instances/service-instance/" + INST))
.inScenario("SI retrieval")
.whenScenarioStateIs(Scenario.STARTED)
.willReturn(aResponse()
@@ -103,7 +103,7 @@ public class DeleteVcpeResCustServiceIT extends AbstractTestBase {
.willSetStateTo("ARs Deleted"));
// once the ARs have been deleted, the SI should be empty
- stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + CUST + "/service-subscriptions/service-subscription/" + SVC + "/service-instances/service-instance/" + INST))
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + CUST + "/service-subscriptions/service-subscription/" + SVC + "/service-instances/service-instance/" + INST))
.inScenario("SI retrieval")
.whenScenarioStateIs("ARs Deleted")
.willReturn(aResponse()
@@ -112,34 +112,34 @@ public class DeleteVcpeResCustServiceIT extends AbstractTestBase {
.withBodyFile("VCPE/DeleteVcpeResCustService/getSIAfterDelArs.xml")));
// for BRG
- MockQueryAllottedResourceById(AR_BRG_ID, "VCPE/DeleteVcpeResCustService/getBRGArUrlById.xml");
- MockGetAllottedResource(CUST, SVC, INST, AR_BRG_ID, "VCPE/DeleteVcpeResCustService/arGetBRGById.xml");
- MockPatchAllottedResource(CUST, SVC, INST, AR_BRG_ID);
- MockDeleteAllottedResource(CUST, SVC, INST, AR_BRG_ID, ARVERS);
+ MockQueryAllottedResourceById(wireMockServer, AR_BRG_ID, "VCPE/DeleteVcpeResCustService/getBRGArUrlById.xml");
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, AR_BRG_ID, "VCPE/DeleteVcpeResCustService/arGetBRGById.xml");
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, AR_BRG_ID);
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, AR_BRG_ID, ARVERS);
// for TXC
- MockQueryAllottedResourceById(AR_TXC_ID, "VCPE/DeleteVcpeResCustService/getTXCArUrlById.xml");
- MockGetAllottedResource(CUST, SVC, INST, AR_TXC_ID, "VCPE/DeleteVcpeResCustService/arGetTXCById.xml");
- MockPatchAllottedResource(CUST, SVC, INST, AR_TXC_ID);
- MockDeleteAllottedResource(CUST, SVC, INST, AR_TXC_ID, ARVERS);
+ MockQueryAllottedResourceById(wireMockServer, AR_TXC_ID, "VCPE/DeleteVcpeResCustService/getTXCArUrlById.xml");
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, AR_TXC_ID, "VCPE/DeleteVcpeResCustService/arGetTXCById.xml");
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, AR_TXC_ID);
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, AR_TXC_ID, ARVERS);
//MockGetGenericVnfById("vnfX.*", "GenericFlows/getGenericVnfByNameResponse.xml");
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/.*"))
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/.*"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
.withBodyFile("GenericFlows/getGenericVnfByNameResponse.xml")));
- stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/.*"))
+ wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/.*"))
.willReturn(aResponse()
.withStatus(204)
.withHeader("Content-Type", "text/xml")));
- MockDeleteServiceInstance(CUST,SVC,INST,SVC);
+ MockDeleteServiceInstance(wireMockServer, CUST,SVC,INST,SVC);
- mockSDNCAdapter(200);
- mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = setupVariables(businessKey);
@@ -193,7 +193,7 @@ public class DeleteVcpeResCustServiceIT extends AbstractTestBase {
@Test
public void testDeleteVcpeResCustService_NoBRG_NoTXC_NoVNF() throws Exception {
logStart();
- MockNodeQueryServiceInstanceById(INST, "GenericFlows/getSIUrlById.xml");
+ MockNodeQueryServiceInstanceById(wireMockServer, INST, "GenericFlows/getSIUrlById.xml");
// TODO: use INST instead of DEC_INST
/*
@@ -201,12 +201,12 @@ public class DeleteVcpeResCustServiceIT extends AbstractTestBase {
* fail to URL-encode the SI id before performing the query so we'll
* add a stub for that case, too.
*/
- MockNodeQueryServiceInstanceById(DEC_INST, "GenericFlows/getSIUrlById.xml");
+ MockNodeQueryServiceInstanceById(wireMockServer, DEC_INST, "GenericFlows/getSIUrlById.xml");
- MockGetServiceInstance(CUST, SVC, INST, "VCPE/DeleteVcpeResCustService/getSIAfterDelArs.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "VCPE/DeleteVcpeResCustService/getSIAfterDelArs.xml");
- mockSDNCAdapter(200);
- mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = setupVariables(businessKey);
@@ -242,7 +242,7 @@ public class DeleteVcpeResCustServiceIT extends AbstractTestBase {
@Test
public void testDeleteVcpeResCustService_Fault() throws Exception {
logStart();
- MockNodeQueryServiceInstanceById(INST, "GenericFlows/getSIUrlById.xml");
+ MockNodeQueryServiceInstanceById(wireMockServer, INST, "GenericFlows/getSIUrlById.xml");
// TODO: use INST instead of DEC_INST
/*
@@ -250,14 +250,14 @@ public class DeleteVcpeResCustServiceIT extends AbstractTestBase {
* fail to URL-encode the SI id before performing the query so we'll
* add a stub for that case, too.
*/
- MockNodeQueryServiceInstanceById(DEC_INST, "GenericFlows/getSIUrlById.xml");
+ MockNodeQueryServiceInstanceById(wireMockServer, DEC_INST, "GenericFlows/getSIUrlById.xml");
- MockGetServiceInstance(CUST, SVC, INST, "VCPE/DeleteVcpeResCustService/getSIAfterDelArs.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "VCPE/DeleteVcpeResCustService/getSIAfterDelArs.xml");
// generate failure
- mockSDNCAdapter(404);
+ mockSDNCAdapter(wireMockServer, 404);
- mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = setupVariables(businessKey);
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceBRGIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceBRGIT.java
index 2b1b5a3bd0..da9b45c8c8 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceBRGIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceBRGIT.java
@@ -60,15 +60,15 @@ public class DoCreateAllottedResourceBRGIT extends AbstractTestBase {
* have a bug in that they don't URL-encode the SI id before using
* it in the query
*/
- MockNodeQueryServiceInstanceById(DEC_INST, "GenericFlows/getSIUrlById.xml");
- MockNodeQueryServiceInstanceById(DEC_PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
+ MockNodeQueryServiceInstanceById(wireMockServer, DEC_INST, "GenericFlows/getSIUrlById.xml");
+ MockNodeQueryServiceInstanceById(wireMockServer, DEC_PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
- MockGetServiceInstance(CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
- MockGetServiceInstance(CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
- MockPutAllottedResource(CUST, SVC, PARENT_INST, ARID);
- MockPatchAllottedResource(CUST, SVC, PARENT_INST, ARID);
- mockSDNCAdapter(200);
- mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
+ MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
Map<String, Object> variables = new HashMap<>();
setVariablesSuccess(variables,"testRequestId123");
@@ -99,15 +99,15 @@ public class DoCreateAllottedResourceBRGIT extends AbstractTestBase {
* have a bug in that they don't URL-encode the SI id before using
* it in the query
*/
- MockNodeQueryServiceInstanceById(DEC_INST, "GenericFlows/getNotFound.xml");
- MockNodeQueryServiceInstanceById(DEC_PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
-
- MockGetServiceInstance(CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
- MockGetServiceInstance(CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
- MockPutAllottedResource(CUST, SVC, PARENT_INST, ARID);
- MockPatchAllottedResource(CUST, SVC, PARENT_INST, ARID);
- mockSDNCAdapter(200);
- mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
+ MockNodeQueryServiceInstanceById(wireMockServer, DEC_INST, "GenericFlows/getNotFound.xml");
+ MockNodeQueryServiceInstanceById(wireMockServer, DEC_PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
+
+ MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
+ MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
Map<String, Object> variables = new HashMap<>();
setVariablesSuccess(variables,"testRequestId124");
@@ -133,16 +133,16 @@ public class DoCreateAllottedResourceBRGIT extends AbstractTestBase {
* have a bug in that they don't URL-encode the SI id before using
* it in the query
*/
- MockNodeQueryServiceInstanceById(DEC_INST, "GenericFlows/getSIUrlById.xml");
- MockNodeQueryServiceInstanceById(DEC_PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
+ MockNodeQueryServiceInstanceById(wireMockServer, DEC_INST, "GenericFlows/getSIUrlById.xml");
+ MockNodeQueryServiceInstanceById(wireMockServer, DEC_PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
- MockGetServiceInstance(CUST, SVC, INST, "VCPE/DoCreateAllottedResourceBRG/getSIandAR.xml");
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRG/getArBrg2.xml");
- MockGetServiceInstance(CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
- MockPutAllottedResource(CUST, SVC, PARENT_INST, ARID);
- MockPatchAllottedResource(CUST, SVC, PARENT_INST, ARID);
- mockSDNCAdapter(200);
- mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "VCPE/DoCreateAllottedResourceBRG/getSIandAR.xml");
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRG/getArBrg2.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
+ MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
Map<String, Object> variables = new HashMap<>();
setVariablesSuccess(variables,"testRequestId125");
@@ -174,15 +174,15 @@ public class DoCreateAllottedResourceBRGIT extends AbstractTestBase {
* have a bug in that they don't URL-encode the SI id before using
* it in the query
*/
- MockNodeQueryServiceInstanceById(DEC_INST, "GenericFlows/getSIUrlById.xml");
- MockNodeQueryServiceInstanceById(DEC_PARENT_INST, "GenericFlows/getNotFound.xml");
+ MockNodeQueryServiceInstanceById(wireMockServer, DEC_INST, "GenericFlows/getSIUrlById.xml");
+ MockNodeQueryServiceInstanceById(wireMockServer, DEC_PARENT_INST, "GenericFlows/getNotFound.xml");
- MockGetServiceInstance(CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
- MockGetServiceInstance(CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
- MockPutAllottedResource(CUST, SVC, PARENT_INST, ARID);
- MockPatchAllottedResource(CUST, SVC, PARENT_INST, ARID);
- mockSDNCAdapter(200);
- mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
+ MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
Map<String, Object> variables = new HashMap<>();
setVariablesSuccess(variables,"testRequestId126");
@@ -208,15 +208,15 @@ public class DoCreateAllottedResourceBRGIT extends AbstractTestBase {
* have a bug in that they don't URL-encode the SI id before using
* it in the query
*/
- MockNodeQueryServiceInstanceById(DEC_INST, "GenericFlows/getSIUrlById.xml");
- MockNodeQueryServiceInstanceById(DEC_PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
+ MockNodeQueryServiceInstanceById(wireMockServer, DEC_INST, "GenericFlows/getSIUrlById.xml");
+ MockNodeQueryServiceInstanceById(wireMockServer, DEC_PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
- MockGetServiceInstance(CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
- MockGetServiceInstance(CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
- MockPutAllottedResource(CUST, SVC, PARENT_INST, ARID);
- MockPatchAllottedResource(CUST, SVC, PARENT_INST, ARID);
- mockSDNCAdapter(404);
- mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
+ MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ mockSDNCAdapter(wireMockServer, 404);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
Map<String, Object> variables = new HashMap<>();
setVariablesSuccess(variables,"testRequestId127");
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceBRGRollbackIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceBRGRollbackIT.java
index a19dec1f98..f0d275c5cc 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceBRGRollbackIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceBRGRollbackIT.java
@@ -56,11 +56,11 @@ public class DoCreateAllottedResourceBRGRollbackIT extends AbstractTestBase {
@Test
public void testDoCreateAllottedResourceBRGRollback_Success() throws Exception {
logStart();
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml");
- MockPatchAllottedResource(CUST, SVC, INST, ARID);
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, ARVERS);
- mockSDNCAdapter(200);
- mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml");
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
@@ -86,11 +86,11 @@ public class DoCreateAllottedResourceBRGRollbackIT extends AbstractTestBase {
@Test
public void testDoCreateAllottedResourceBRGRollback_skipRollback() throws Exception {
logStart();
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml");
- MockPatchAllottedResource(CUST, SVC, INST, ARID);
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, ARVERS);
- mockSDNCAdapter(200);
- mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml");
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
@@ -115,9 +115,9 @@ public class DoCreateAllottedResourceBRGRollbackIT extends AbstractTestBase {
@Test
public void testDoCreateAllottedResourceBRGRollback_DoNotRollBack() throws Exception {
logStart();
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml");
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, ARVERS);
- mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml");
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
@@ -142,11 +142,11 @@ public class DoCreateAllottedResourceBRGRollbackIT extends AbstractTestBase {
@Test
public void testDoCreateAllottedResourceBRGRollback_NoDeactivate() throws Exception {
logStart();
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml");
- MockPatchAllottedResource(CUST, SVC, INST, ARID);
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, ARVERS);
- mockSDNCAdapter(200);
- mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml");
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
@@ -173,11 +173,11 @@ public class DoCreateAllottedResourceBRGRollbackIT extends AbstractTestBase {
@Test
public void testDoCreateAllottedResourceBRGRollback_NoDelete() throws Exception {
logStart();
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml");
- MockPatchAllottedResource(CUST, SVC, INST, ARID);
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, ARVERS);
- mockSDNCAdapter(200);
- mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml");
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
@@ -204,11 +204,11 @@ public class DoCreateAllottedResourceBRGRollbackIT extends AbstractTestBase {
@Test
public void testDoCreateAllottedResourceBRGRollback_NoUnassign() throws Exception {
logStart();
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml");
- MockPatchAllottedResource(CUST, SVC, INST, ARID);
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, ARVERS);
- mockSDNCAdapter(200);
- mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml");
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
@@ -238,12 +238,12 @@ public class DoCreateAllottedResourceBRGRollbackIT extends AbstractTestBase {
@Test
public void testDoCreateAllottedResourceBRGRollback_SubProcessError() throws Exception {
logStart();
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml");
- MockPatchAllottedResource(CUST, SVC, INST, ARID);
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, ARVERS);
- mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml");
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
- mockSDNCAdapter(404);
+ mockSDNCAdapter(wireMockServer, 404);
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
@@ -265,11 +265,11 @@ public class DoCreateAllottedResourceBRGRollbackIT extends AbstractTestBase {
@Test
public void testDoCreateAllottedResourceBRGRollback_JavaException() throws Exception {
logStart();
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml");
- MockPatchAllottedResource(CUST, SVC, INST, ARID);
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, ARVERS);
- mockSDNCAdapter(200);
- mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml");
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceTXCIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceTXCIT.java
index 473661c860..6ecec3240d 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceTXCIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceTXCIT.java
@@ -65,15 +65,15 @@ public class DoCreateAllottedResourceTXCIT extends AbstractTestBase {
* have a bug in that they don't URL-encode the SI id before using
* it in the query
*/
- MockNodeQueryServiceInstanceById(DEC_INST, "GenericFlows/getSIUrlById.xml");
- MockNodeQueryServiceInstanceById(DEC_PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
+ MockNodeQueryServiceInstanceById(wireMockServer, DEC_INST, "GenericFlows/getSIUrlById.xml");
+ MockNodeQueryServiceInstanceById(wireMockServer, DEC_PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
- MockGetServiceInstance(CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
- MockGetServiceInstance(CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
- MockPutAllottedResource(CUST, SVC, PARENT_INST, ARID);
- MockPatchAllottedResource(CUST, SVC, PARENT_INST, ARID);
- mockSDNCAdapter(200);
- mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
+ MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
Map<String, Object> variables = new HashMap<>();
setVariablesSuccess(variables, "testRequestId123");
@@ -108,15 +108,15 @@ public class DoCreateAllottedResourceTXCIT extends AbstractTestBase {
* have a bug in that they don't URL-encode the SI id before using
* it in the query
*/
- MockNodeQueryServiceInstanceById(DEC_INST, "GenericFlows/getNotFound.xml");
- MockNodeQueryServiceInstanceById(DEC_PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
+ MockNodeQueryServiceInstanceById(wireMockServer, DEC_INST, "GenericFlows/getNotFound.xml");
+ MockNodeQueryServiceInstanceById(wireMockServer, DEC_PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
- MockGetServiceInstance(CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
- MockGetServiceInstance(CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
- MockPutAllottedResource(CUST, SVC, PARENT_INST, ARID);
- MockPatchAllottedResource(CUST, SVC, PARENT_INST, ARID);
- mockSDNCAdapter(200);
- mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
+ MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
Map<String, Object> variables = new HashMap<>();
setVariablesSuccess(variables, "testRequestId123");
@@ -142,16 +142,16 @@ public class DoCreateAllottedResourceTXCIT extends AbstractTestBase {
* have a bug in that they don't URL-encode the SI id before using
* it in the query
*/
- MockNodeQueryServiceInstanceById(DEC_INST, "GenericFlows/getSIUrlById.xml");
- MockNodeQueryServiceInstanceById(DEC_PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
+ MockNodeQueryServiceInstanceById(wireMockServer, DEC_INST, "GenericFlows/getSIUrlById.xml");
+ MockNodeQueryServiceInstanceById(wireMockServer, DEC_PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
- MockGetServiceInstance(CUST, SVC, INST, "VCPE/DoCreateAllottedResourceTXC/getSIandAR.xml");
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXC/getArTxc2.xml");
- MockGetServiceInstance(CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
- MockPutAllottedResource(CUST, SVC, PARENT_INST, ARID);
- MockPatchAllottedResource(CUST, SVC, PARENT_INST, ARID);
- mockSDNCAdapter(200);
- mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "VCPE/DoCreateAllottedResourceTXC/getSIandAR.xml");
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXC/getArTxc2.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
+ MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
Map<String, Object> variables = new HashMap<>();
setVariablesSuccess(variables, "testRequestId123");
@@ -184,16 +184,16 @@ public class DoCreateAllottedResourceTXCIT extends AbstractTestBase {
* have a bug in that they don't URL-encode the SI id before using
* it in the query
*/
- MockNodeQueryServiceInstanceById(DEC_INST, "GenericFlows/getSIUrlById.xml");
+ MockNodeQueryServiceInstanceById(wireMockServer, DEC_INST, "GenericFlows/getSIUrlById.xml");
- MockNodeQueryServiceInstanceById(DEC_PARENT_INST, "GenericFlows/getNotFound.xml");
+ MockNodeQueryServiceInstanceById(wireMockServer, DEC_PARENT_INST, "GenericFlows/getNotFound.xml");
- MockGetServiceInstance(CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
- MockGetServiceInstance(CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
- MockPutAllottedResource(CUST, SVC, PARENT_INST, ARID);
- MockPatchAllottedResource(CUST, SVC, PARENT_INST, ARID);
- mockSDNCAdapter(200);
- mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
+ MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
Map<String, Object> variables = new HashMap<>();
setVariablesSuccess(variables, "testRequestId123");
@@ -219,15 +219,15 @@ public class DoCreateAllottedResourceTXCIT extends AbstractTestBase {
* have a bug in that they don't URL-encode the SI id before using
* it in the query
*/
- MockNodeQueryServiceInstanceById(DEC_INST, "GenericFlows/getSIUrlById.xml");
- MockNodeQueryServiceInstanceById(DEC_PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
+ MockNodeQueryServiceInstanceById(wireMockServer, DEC_INST, "GenericFlows/getSIUrlById.xml");
+ MockNodeQueryServiceInstanceById(wireMockServer, DEC_PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
- MockGetServiceInstance(CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
- MockGetServiceInstance(CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
- MockPutAllottedResource(CUST, SVC, PARENT_INST, ARID);
- MockPatchAllottedResource(CUST, SVC, PARENT_INST, ARID);
- mockSDNCAdapter(404);
- mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
+ MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ mockSDNCAdapter(wireMockServer, 404);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
Map<String, Object> variables = new HashMap<>();
setVariablesSuccess(variables, "testRequestId123");
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceTXCRollbackIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceTXCRollbackIT.java
index 8b47174b3b..4f81a4f725 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceTXCRollbackIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceTXCRollbackIT.java
@@ -56,11 +56,11 @@ public class DoCreateAllottedResourceTXCRollbackIT extends AbstractTestBase {
@Test
public void testDoCreateAllottedResourceTXCRollback_Success() throws Exception {
logStart();
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml");
- MockPatchAllottedResource(CUST, SVC, INST, ARID);
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, ARVERS);
- mockSDNCAdapter(200);
- mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml");
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
@@ -86,11 +86,11 @@ public class DoCreateAllottedResourceTXCRollbackIT extends AbstractTestBase {
@Test
public void testDoCreateAllottedResourceTXCRollback_skipRollback() throws Exception {
logStart();
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml");
- MockPatchAllottedResource(CUST, SVC, INST, ARID);
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, ARVERS);
- mockSDNCAdapter(200);
- mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml");
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
@@ -115,9 +115,9 @@ public class DoCreateAllottedResourceTXCRollbackIT extends AbstractTestBase {
@Test
public void testDoCreateAllottedResourceTXCRollback_DoNotRollBack() throws Exception {
logStart();
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml");
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, ARVERS);
- mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml");
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
@@ -142,11 +142,11 @@ public class DoCreateAllottedResourceTXCRollbackIT extends AbstractTestBase {
@Test
public void testDoCreateAllottedResourceTXCRollback_NoDeactivate() throws Exception {
logStart();
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml");
- MockPatchAllottedResource(CUST, SVC, INST, ARID);
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, ARVERS);
- mockSDNCAdapter(200);
- mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml");
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
@@ -173,11 +173,11 @@ public class DoCreateAllottedResourceTXCRollbackIT extends AbstractTestBase {
@Test
public void testDoCreateAllottedResourceTXCRollback_NoDelete() throws Exception {
logStart();
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml");
- MockPatchAllottedResource(CUST, SVC, INST, ARID);
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, ARVERS);
- mockSDNCAdapter(200);
- mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml");
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
@@ -204,11 +204,11 @@ public class DoCreateAllottedResourceTXCRollbackIT extends AbstractTestBase {
@Test
public void testDoCreateAllottedResourceTXCRollback_NoUnassign() throws Exception {
logStart();
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml");
- MockPatchAllottedResource(CUST, SVC, INST, ARID);
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, ARVERS);
- mockSDNCAdapter(200);
- mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml");
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
@@ -238,12 +238,12 @@ public class DoCreateAllottedResourceTXCRollbackIT extends AbstractTestBase {
@Test
public void testDoCreateAllottedResourceTXCRollback_SubProcessError() throws Exception {
logStart();
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml");
- MockPatchAllottedResource(CUST, SVC, INST, ARID);
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, ARVERS);
- mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml");
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
- mockSDNCAdapter(404);
+ mockSDNCAdapter(wireMockServer, 404);
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
@@ -265,11 +265,11 @@ public class DoCreateAllottedResourceTXCRollbackIT extends AbstractTestBase {
@Test
public void testDoCreateAllottedResourceTXCRollback_JavaException() throws Exception {
logStart();
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml");
- MockPatchAllottedResource(CUST, SVC, INST, ARID);
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, ARVERS);
- mockSDNCAdapter(200);
- mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml");
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoDeleteAllottedResourceBRGIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoDeleteAllottedResourceBRGIT.java
index 4edaf7d21f..42f32b8ecc 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoDeleteAllottedResourceBRGIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoDeleteAllottedResourceBRGIT.java
@@ -50,12 +50,12 @@ public class DoDeleteAllottedResourceBRGIT extends AbstractTestBase {
@Test
public void testDoDeleteAllottedResourceBRG_Success() {
logStart();
- MockQueryAllottedResourceById(ARID, "GenericFlows/getARUrlById.xml");
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml");
- MockPatchAllottedResource(CUST, SVC, INST, ARID);
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, ARVERS);
- mockSDNCAdapter(200);
- mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
+ MockQueryAllottedResourceById(wireMockServer, ARID, "GenericFlows/getARUrlById.xml");
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml");
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
@@ -79,12 +79,12 @@ public class DoDeleteAllottedResourceBRGIT extends AbstractTestBase {
@Test
public void testDoDeleteAllottedResourceBRG_ARNotInSDNC() {
logStart();
- MockQueryAllottedResourceById(ARID, "GenericFlows/getARUrlById.xml");
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml");
- MockPatchAllottedResource(CUST, SVC, INST, ARID);
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, ARVERS);
- mockSDNCAdapter(200);
- mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
+ MockQueryAllottedResourceById(wireMockServer, ARID, "GenericFlows/getARUrlById.xml");
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml");
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
String businessKey = UUID.randomUUID().toString();
Map<String, Object> variables = new HashMap<>();
@@ -109,13 +109,13 @@ public class DoDeleteAllottedResourceBRGIT extends AbstractTestBase {
@Test
public void testDoDeleteAllottedResourceBRG_SubProcessError() throws Exception {
logStart();
- MockQueryAllottedResourceById(ARID, "GenericFlows/getARUrlById.xml");
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml");
- MockPatchAllottedResource(CUST, SVC, INST, ARID);
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, ARVERS);
- mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
+ MockQueryAllottedResourceById(wireMockServer, ARID, "GenericFlows/getARUrlById.xml");
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml");
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
- mockSDNCAdapter(500);
+ mockSDNCAdapter(wireMockServer, 500);
Map<String, Object> variables = new HashMap<>();
setVariablesSuccess(variables);
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoDeleteAllottedResourceTXCIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoDeleteAllottedResourceTXCIT.java
index 520beaf07b..13ca58be03 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoDeleteAllottedResourceTXCIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoDeleteAllottedResourceTXCIT.java
@@ -50,12 +50,12 @@ public class DoDeleteAllottedResourceTXCIT extends AbstractTestBase {
@Test
public void testDoDeleteAllottedResourceTXC_Success() throws Exception {
logStart();
- MockQueryAllottedResourceById(ARID, "GenericFlows/getARUrlById.xml");
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml");
- MockPatchAllottedResource(CUST, SVC, INST, ARID);
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, ARVERS);
- mockSDNCAdapter(200);
- mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
+ MockQueryAllottedResourceById(wireMockServer, ARID, "GenericFlows/getARUrlById.xml");
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml");
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
Map<String, Object> variables = new HashMap<>();
setVariablesSuccess(variables);
@@ -78,12 +78,12 @@ public class DoDeleteAllottedResourceTXCIT extends AbstractTestBase {
@Test
public void testDoDeleteAllottedResourceTXC_ARNotInSDNC() throws Exception {
logStart();
- MockQueryAllottedResourceById(ARID, "GenericFlows/getARUrlById.xml");
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml");
- MockPatchAllottedResource(CUST, SVC, INST, ARID);
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, ARVERS);
- mockSDNCAdapter(200);
- mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
+ MockQueryAllottedResourceById(wireMockServer, ARID, "GenericFlows/getARUrlById.xml");
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml");
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
Map<String, Object> variables = new HashMap<>();
setVariablesSuccess(variables);
@@ -104,13 +104,13 @@ public class DoDeleteAllottedResourceTXCIT extends AbstractTestBase {
@Test
public void testDoDeleteAllottedResourceTXC_SubProcessError() throws Exception {
logStart();
- MockQueryAllottedResourceById(ARID, "GenericFlows/getARUrlById.xml");
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml");
- MockPatchAllottedResource(CUST, SVC, INST, ARID);
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, ARVERS);
- mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
+ MockQueryAllottedResourceById(wireMockServer, ARID, "GenericFlows/getARUrlById.xml");
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml");
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
- mockSDNCAdapter(500);
+ mockSDNCAdapter(wireMockServer, 500);
Map<String, Object> variables = new HashMap<>();
setVariablesSuccess(variables);
diff --git a/bpmn/so-bpmn-building-blocks/pom.xml b/bpmn/so-bpmn-building-blocks/pom.xml
index 0971a9d54e..09706746af 100644
--- a/bpmn/so-bpmn-building-blocks/pom.xml
+++ b/bpmn/so-bpmn-building-blocks/pom.xml
@@ -36,6 +36,9 @@
</configuration>
</execution>
</executions>
+ <configuration>
+ <parallel>suites</parallel>
+ </configuration>
</plugin>
</plugins>
diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/EtsiVnfDeleteBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/EtsiVnfDeleteBB.bpmn
new file mode 100644
index 0000000000..7f70cc5756
--- /dev/null
+++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/EtsiVnfDeleteBB.bpmn
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1as67q3" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="2.2.4">
+ <bpmn:process id="vnfmFoundCheck" name="vnfmFoundCheck" isExecutable="true">
+ <bpmn:startEvent id="StartEvent_0i3wi1x">
+ <bpmn:outgoing>SequenceFlow_01pwrcr</bpmn:outgoing>
+ </bpmn:startEvent>
+ <bpmn:serviceTask id="ServiceTask_1d5jbsa" name="&#10;Invoke VNFM Adaptor&#10;" camunda:asyncAfter="true" camunda:expression="${EtsiVnfDeleteTask.invokeVnfmAdapter(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
+ <bpmn:incoming>SequenceFlow_01pwrcr</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_1064iul</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:endEvent id="EndEvent_1khf4qw">
+ <bpmn:incoming>SequenceFlow_1064iul</bpmn:incoming>
+ </bpmn:endEvent>
+ <bpmn:sequenceFlow id="SequenceFlow_1064iul" sourceRef="ServiceTask_1d5jbsa" targetRef="EndEvent_1khf4qw" />
+ <bpmn:sequenceFlow id="SequenceFlow_01pwrcr" sourceRef="StartEvent_0i3wi1x" targetRef="ServiceTask_1d5jbsa" />
+ </bpmn:process>
+ <bpmndi:BPMNDiagram id="BPMNDiagram_1">
+ <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="vnfmFoundCheck">
+ <bpmndi:BPMNShape id="StartEvent_0i3wi1x_di" bpmnElement="StartEvent_0i3wi1x">
+ <dc:Bounds x="325" y="183" width="36" height="36" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="ServiceTask_1d5jbsa_di" bpmnElement="ServiceTask_1d5jbsa">
+ <dc:Bounds x="503" y="161" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="EndEvent_1khf4qw_di" bpmnElement="EndEvent_1khf4qw">
+ <dc:Bounds x="742" y="183" width="36" height="36" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="SequenceFlow_1064iul_di" bpmnElement="SequenceFlow_1064iul">
+ <di:waypoint x="603" y="201" />
+ <di:waypoint x="742" y="201" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="SequenceFlow_01pwrcr_di" bpmnElement="SequenceFlow_01pwrcr">
+ <di:waypoint x="361" y="201" />
+ <di:waypoint x="503" y="201" />
+ </bpmndi:BPMNEdge>
+ </bpmndi:BPMNPlane>
+ </bpmndi:BPMNDiagram>
+</bpmn:definitions>
diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/EtsiVnfInstantiateBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/EtsiVnfInstantiateBB.bpmn
index 9437d02b69..b248ea1f6a 100644
--- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/EtsiVnfInstantiateBB.bpmn
+++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/EtsiVnfInstantiateBB.bpmn
@@ -10,7 +10,7 @@
</bpmn:startEvent>
<bpmn:sequenceFlow id="SequenceFlow_016sgof" sourceRef="StartEvent_0ru3x55" targetRef="ServiceTask_1jf7hlc" />
<bpmn:endEvent id="EndEvent_001k15i">
- <bpmn:incoming>SequenceFlow_0hp0ka1</bpmn:incoming>
+ <bpmn:incoming>SequenceFlow_1owx4yu</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="SequenceFlow_0f0vsnv" sourceRef="ServiceTask_02e82t2" targetRef="ServiceTask_06ao4xu" />
<bpmn:serviceTask id="ServiceTask_06ao4xu" name="&#10;Invoke VNFM Adaptor&#10;" camunda:asyncAfter="true" camunda:expression="${VnfmAdapterCreateVnfTask.invokeVnfmAdapter(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
@@ -22,7 +22,18 @@
<bpmn:outgoing>SequenceFlow_18fsqzd</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:sequenceFlow id="SequenceFlow_18fsqzd" sourceRef="ServiceTask_1jf7hlc" targetRef="ServiceTask_02e82t2" />
- <bpmn:sequenceFlow id="SequenceFlow_0hp0ka1" sourceRef="ServiceTask_06ao4xu" targetRef="EndEvent_001k15i" />
+ <bpmn:sequenceFlow id="SequenceFlow_0hp0ka1" sourceRef="ServiceTask_06ao4xu" targetRef="CallActivity_0fuqfru" />
+ <bpmn:callActivity id="CallActivity_0fuqfru" name="Monitor Instantiation Job" calledElement="MonitorVnfmCreateJob">
+ <bpmn:extensionElements>
+ <camunda:in source="SDNCRequest" target="SDNCRequest" />
+ <camunda:out source="SDNCResponse" target="SDNCResponse" />
+ <camunda:out source="WorkflowException" target="WorkflowException" />
+ <camunda:in source="mso-request-id" target="mso-request-id" />
+ </bpmn:extensionElements>
+ <bpmn:incoming>SequenceFlow_0hp0ka1</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_1owx4yu</bpmn:outgoing>
+ </bpmn:callActivity>
+ <bpmn:sequenceFlow id="SequenceFlow_1owx4yu" sourceRef="CallActivity_0fuqfru" targetRef="EndEvent_001k15i" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="EtsiVnfInstantiateBB">
@@ -37,7 +48,7 @@
<di:waypoint x="332" y="267" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="EndEvent_001k15i_di" bpmnElement="EndEvent_001k15i">
- <dc:Bounds x="783" y="249" width="36" height="36" />
+ <dc:Bounds x="913" y="249" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_0f0vsnv_di" bpmnElement="SequenceFlow_0f0vsnv">
<di:waypoint x="580" y="267" />
@@ -55,7 +66,14 @@
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_0hp0ka1_di" bpmnElement="SequenceFlow_0hp0ka1">
<di:waypoint x="729" y="267" />
- <di:waypoint x="783" y="267" />
+ <di:waypoint x="770" y="267" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="CallActivity_0fuqfru_di" bpmnElement="CallActivity_0fuqfru">
+ <dc:Bounds x="770" y="227" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="SequenceFlow_1owx4yu_di" bpmnElement="SequenceFlow_1owx4yu">
+ <di:waypoint x="870" y="267" />
+ <di:waypoint x="913" y="267" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/MonitorVnfmCreateJob.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/MonitorVnfmCreateJob.bpmn
new file mode 100644
index 0000000000..fa9bf7ed3d
--- /dev/null
+++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/MonitorVnfmCreateJob.bpmn
@@ -0,0 +1,160 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_12gnsyw" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="2.0.3">
+ <bpmn:process id="MonitorVnfmCreateJob" name="MonitorVnfmCreateJob" isExecutable="true">
+ <bpmn:startEvent id="StartEvent_1">
+ <bpmn:outgoing>SequenceFlow_1x3tbl0</bpmn:outgoing>
+ </bpmn:startEvent>
+ <bpmn:endEvent id="EndEvent_0rf1gde">
+ <bpmn:incoming>SequenceFlow_1543qy7</bpmn:incoming>
+ </bpmn:endEvent>
+ <bpmn:subProcess id="SubProcess_19j0v63">
+ <bpmn:incoming>SequenceFlow_1x3tbl0</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_1v4yr3f</bpmn:outgoing>
+ <bpmn:startEvent id="StartEvent_01r97z2">
+ <bpmn:outgoing>SequenceFlow_0s1plu9</bpmn:outgoing>
+ </bpmn:startEvent>
+ <bpmn:exclusiveGateway id="ExclusiveGateway_1hkl6yy" default="SequenceFlow_1vmxw9g">
+ <bpmn:incoming>SequenceFlow_153a3kp</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_1vmxw9g</bpmn:outgoing>
+ <bpmn:outgoing>SequenceFlow_0is7myf</bpmn:outgoing>
+ </bpmn:exclusiveGateway>
+ <bpmn:intermediateCatchEvent id="IntermediateCatchEvent_1besn3n" name="Wait between checks" camunda:asyncAfter="true">
+ <bpmn:incoming>SequenceFlow_1vmxw9g</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_0etw572</bpmn:outgoing>
+ <bpmn:timerEventDefinition id="TimerEventDefinition_0qgh11t">
+ <bpmn:timeDuration xsi:type="bpmn:tFormalExpression">PT15S</bpmn:timeDuration>
+ </bpmn:timerEventDefinition>
+ </bpmn:intermediateCatchEvent>
+ <bpmn:endEvent id="EndEvent_1ohsce9">
+ <bpmn:incoming>SequenceFlow_0is7myf</bpmn:incoming>
+ </bpmn:endEvent>
+ <bpmn:sequenceFlow id="SequenceFlow_0s1plu9" sourceRef="StartEvent_01r97z2" targetRef="ServiceTask_17jlnng" />
+ <bpmn:sequenceFlow id="SequenceFlow_0etw572" sourceRef="IntermediateCatchEvent_1besn3n" targetRef="ServiceTask_17jlnng" />
+ <bpmn:serviceTask id="ServiceTask_17jlnng" name="&#10;Get Current Operation Status&#10;" camunda:asyncAfter="true" camunda:expression="${MonitorVnfmCreateJobTask.getCurrentOperationStatus(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
+ <bpmn:incoming>SequenceFlow_0etw572</bpmn:incoming>
+ <bpmn:incoming>SequenceFlow_0s1plu9</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_153a3kp</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:sequenceFlow id="SequenceFlow_1vmxw9g" sourceRef="ExclusiveGateway_1hkl6yy" targetRef="IntermediateCatchEvent_1besn3n" />
+ <bpmn:sequenceFlow id="SequenceFlow_0is7myf" sourceRef="ExclusiveGateway_1hkl6yy" targetRef="EndEvent_1ohsce9">
+ <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${MonitorVnfmCreateJobTask.hasOperationFinished(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}</bpmn:conditionExpression>
+ </bpmn:sequenceFlow>
+ <bpmn:sequenceFlow id="SequenceFlow_153a3kp" sourceRef="ServiceTask_17jlnng" targetRef="ExclusiveGateway_1hkl6yy" />
+ </bpmn:subProcess>
+ <bpmn:endEvent id="EndEvent_1w3t3t0" name="Timeout Exception">
+ <bpmn:incoming>SequenceFlow_0bcgtzj</bpmn:incoming>
+ <bpmn:terminateEventDefinition id="TerminateEventDefinition_0fjecl3" />
+ </bpmn:endEvent>
+ <bpmn:boundaryEvent id="BoundaryEvent_0xiabzp" name="Overall Wait" attachedToRef="SubProcess_19j0v63">
+ <bpmn:outgoing>SequenceFlow_1i1o9sh</bpmn:outgoing>
+ <bpmn:timerEventDefinition id="TimerEventDefinition_10kqw61">
+ <bpmn:timeDuration xsi:type="bpmn:tFormalExpression">PT3H</bpmn:timeDuration>
+ </bpmn:timerEventDefinition>
+ </bpmn:boundaryEvent>
+ <bpmn:sequenceFlow id="SequenceFlow_1v4yr3f" sourceRef="SubProcess_19j0v63" targetRef="ServiceTask_1gms128" />
+ <bpmn:sequenceFlow id="SequenceFlow_1i1o9sh" sourceRef="BoundaryEvent_0xiabzp" targetRef="ServiceTask_1s87b92" />
+ <bpmn:sequenceFlow id="SequenceFlow_1x3tbl0" sourceRef="StartEvent_1" targetRef="SubProcess_19j0v63" />
+ <bpmn:serviceTask id="ServiceTask_1s87b92" name="&#10;Time Out Log Failure&#10;" camunda:asyncAfter="true" camunda:expression="${MonitorVnfmCreateJobTask.timeOutLogFailue(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
+ <bpmn:incoming>SequenceFlow_1i1o9sh</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_0bcgtzj</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:sequenceFlow id="SequenceFlow_0bcgtzj" sourceRef="ServiceTask_1s87b92" targetRef="EndEvent_1w3t3t0" />
+ <bpmn:serviceTask id="ServiceTask_1gms128" name="&#10;Check if operation was successful&#10;" camunda:asyncAfter="true" camunda:expression="${MonitorVnfmCreateJobTask.checkIfOperationWasSuccessful(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
+ <bpmn:incoming>SequenceFlow_1v4yr3f</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_1543qy7</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:sequenceFlow id="SequenceFlow_1543qy7" sourceRef="ServiceTask_1gms128" targetRef="EndEvent_0rf1gde" />
+ </bpmn:process>
+ <bpmndi:BPMNDiagram id="BPMNDiagram_1">
+ <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="MonitorVnfmCreateJob">
+ <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
+ <dc:Bounds x="211" y="430" width="36" height="36" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="EndEvent_0rf1gde_di" bpmnElement="EndEvent_0rf1gde">
+ <dc:Bounds x="1152" y="200" width="36" height="36" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="SubProcess_19j0v63_di" bpmnElement="SubProcess_19j0v63" isExpanded="true">
+ <dc:Bounds x="351" y="348" width="523" height="200" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="EndEvent_1w3t3t0_di" bpmnElement="EndEvent_1w3t3t0">
+ <dc:Bounds x="1152" y="422" width="36" height="36" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="1145" y="382" width="49" height="27" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="BoundaryEvent_0xiabzp_di" bpmnElement="BoundaryEvent_0xiabzp">
+ <dc:Bounds x="856" y="422" width="36" height="36" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="844" y="461" width="60" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="SequenceFlow_1v4yr3f_di" bpmnElement="SequenceFlow_1v4yr3f">
+ <di:waypoint x="613" y="348" />
+ <di:waypoint x="613" y="218" />
+ <di:waypoint x="973" y="218" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="SequenceFlow_1i1o9sh_di" bpmnElement="SequenceFlow_1i1o9sh">
+ <di:waypoint x="892" y="440" />
+ <di:waypoint x="973" y="440" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="StartEvent_01r97z2_di" bpmnElement="StartEvent_01r97z2">
+ <dc:Bounds x="380" y="406" width="36" height="36" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="ExclusiveGateway_1hkl6yy_di" bpmnElement="ExclusiveGateway_1hkl6yy" isMarkerVisible="true">
+ <dc:Bounds x="659" y="399" width="50" height="50" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="IntermediateCatchEvent_1besn3n_di" bpmnElement="IntermediateCatchEvent_1besn3n">
+ <dc:Bounds x="600" y="478" width="36" height="36" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="587" y="521" width="66" height="27" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="EndEvent_1ohsce9_di" bpmnElement="EndEvent_1ohsce9">
+ <dc:Bounds x="772" y="406" width="36" height="36" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="SequenceFlow_1x3tbl0_di" bpmnElement="SequenceFlow_1x3tbl0">
+ <di:waypoint x="247" y="448" />
+ <di:waypoint x="351" y="448" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="ServiceTask_17jlnng_di" bpmnElement="ServiceTask_17jlnng">
+ <dc:Bounds x="475" y="384" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="SequenceFlow_0s1plu9_di" bpmnElement="SequenceFlow_0s1plu9">
+ <di:waypoint x="416" y="424" />
+ <di:waypoint x="475" y="424" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="SequenceFlow_0etw572_di" bpmnElement="SequenceFlow_0etw572">
+ <di:waypoint x="600" y="496" />
+ <di:waypoint x="536" y="496" />
+ <di:waypoint x="536" y="467" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="SequenceFlow_1vmxw9g_di" bpmnElement="SequenceFlow_1vmxw9g">
+ <di:waypoint x="684" y="449" />
+ <di:waypoint x="684" y="496" />
+ <di:waypoint x="636" y="496" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="SequenceFlow_0is7myf_di" bpmnElement="SequenceFlow_0is7myf">
+ <di:waypoint x="709" y="424" />
+ <di:waypoint x="772" y="424" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="SequenceFlow_153a3kp_di" bpmnElement="SequenceFlow_153a3kp">
+ <di:waypoint x="575" y="424" />
+ <di:waypoint x="659" y="424" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="ServiceTask_1s87b92_di" bpmnElement="ServiceTask_1s87b92">
+ <dc:Bounds x="973" y="400" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="SequenceFlow_0bcgtzj_di" bpmnElement="SequenceFlow_0bcgtzj">
+ <di:waypoint x="1073" y="440" />
+ <di:waypoint x="1152" y="440" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="ServiceTask_1gms128_di" bpmnElement="ServiceTask_1gms128">
+ <dc:Bounds x="973" y="178" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="SequenceFlow_1543qy7_di" bpmnElement="SequenceFlow_1543qy7">
+ <di:waypoint x="1073" y="218" />
+ <di:waypoint x="1152" y="218" />
+ </bpmndi:BPMNEdge>
+ </bpmndi:BPMNPlane>
+ </bpmndi:BPMNDiagram>
+</bpmn:definitions>
diff --git a/bpmn/so-bpmn-infrastructure-common/pom.xml b/bpmn/so-bpmn-infrastructure-common/pom.xml
index 9ba278a119..e3ba0284dc 100644
--- a/bpmn/so-bpmn-infrastructure-common/pom.xml
+++ b/bpmn/so-bpmn-infrastructure-common/pom.xml
@@ -138,6 +138,9 @@
</configuration>
</execution>
</executions>
+ <configuration>
+ <parallel>suites</parallel>
+ </configuration>
</plugin>
</plugins>
</pluginManagement>
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstanceTest.groovy
index ae40e9d7c6..101db4f021 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstanceTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstanceTest.groovy
@@ -41,9 +41,6 @@ import static org.mockito.Mockito.*
@RunWith(MockitoJUnitRunner.class)
class CreateCustomE2EServiceInstanceTest {
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(28090);
-
@Before
public void init() throws IOException {
MockitoAnnotations.initMocks(this);
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfraTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfraTest.groovy
index 77220da94f..c5fd377a72 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfraTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfraTest.groovy
@@ -44,9 +44,6 @@ class CreateVfModuleInfraTest {
def prefix = "CVFMI_"
def requestInfo = "<requestInfo><request-id>12345</request-id></requestInfo>"
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(28090)
-
@Captor
static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceRollbackTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceRollbackTest.groovy
index 5ee10bc931..9214b386eb 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceRollbackTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceRollbackTest.groovy
@@ -55,10 +55,7 @@ import org.apache.commons.lang3.*
@RunWith(MockitoJUnitRunner.class)
class DoCreateNetworkInstanceRollbackTest {
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(28090);
-
- def utils = new MsoUtils()
+ def utils = new MsoUtils()
String Prefix="CRENWKIR_"
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceTest.groovy
index b246caf40e..90c7b71a07 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceTest.groovy
@@ -41,9 +41,6 @@ class DoCreateServiceInstanceTest extends MsoGroovyTest{
def prefix = "DCRESI_"
@Rule
- public WireMockRule wireMockRule = new WireMockRule(28090)
-
- @Rule
public ExpectedException thrown = ExpectedException.none()
@Before
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollbackTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollbackTest.groovy
index fc5960b92f..dd18049b5f 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollbackTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollbackTest.groovy
@@ -62,9 +62,6 @@ class DoCreateVfModuleRollbackTest extends MsoGroovyTest{
@Spy
DoCreateVfModuleRollback doCreateVfModuleRollback
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(28090)
-
@Captor
static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleTest.groovy
index 30e3779b53..faa6a0e395 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleTest.groovy
@@ -47,9 +47,6 @@ import static org.mockito.Mockito.*
class DoCreateVfModuleTest {
def prefix = "DCVFM_"
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(28090)
-
@Captor
static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModulesTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModulesTest.groovy
index 47db6b3b7b..a8c818e69c 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModulesTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModulesTest.groovy
@@ -54,9 +54,6 @@ import static org.mockito.Mockito.*
@RunWith(MockitoJUnitRunner.class)
class DoCreateVnfAndModulesTest {
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(28090)
-
@Captor
static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfTest.groovy
index 9b421d8b63..d7ba10ad93 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfTest.groovy
@@ -44,9 +44,6 @@ import static org.mockito.Mockito.*
class DoCreateVnfTest {
def prefix = "DoCVNF_"
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(28090)
-
@Captor
static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstanceTest.groovy
index a8bdfb0633..ea79e0eadd 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstanceTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstanceTest.groovy
@@ -46,9 +46,6 @@ import static org.mockito.Mockito.*
@RunWith(MockitoJUnitRunner.class)
class DoDeleteServiceInstanceTest {
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(28090)
-
@Captor
static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnfTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnfTest.groovy
index cfdeee2c32..f356845a1e 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnfTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnfTest.groovy
@@ -54,9 +54,6 @@ import static org.mockito.Mockito.*
@RunWith(MockitoJUnitRunner.class)
class DoDeleteVfModuleFromVnfTest extends MsoGroovyTest {
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(28090);
-
@Captor
static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleTest.groovy
index 7776ab3fe6..b56e108faf 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleTest.groovy
@@ -61,9 +61,6 @@ class DoDeleteVfModuleTest extends MsoGroovyTest{
@Spy
DoDeleteVfModule doDeleteVfModule
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(28090);
-
@Captor
static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2Test.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2Test.groovy
index 94aec7a73f..eab1b89e10 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2Test.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2Test.groovy
@@ -56,8 +56,6 @@ import static org.mockito.Mockito.*
@RunWith(MockitoJUnitRunner.class)
class DoDeleteVfModuleVolumeV2Test extends MsoGroovyTest{
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(28090);
@Captor
static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModulesTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModulesTest.groovy
index f98d454eb0..9e4ab6f757 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModulesTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModulesTest.groovy
@@ -50,9 +50,6 @@ import static org.mockito.Mockito.*
@RunWith(MockitoJUnitRunner.class)
public class DoDeleteVnfAndModulesTest extends MsoGroovyTest{
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(28090);
-
@Captor
static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollbackTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollbackTest.groovy
index 0189d065df..7bc82c1ccc 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollbackTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollbackTest.groovy
@@ -52,9 +52,6 @@ import org.apache.commons.lang3.*
@RunWith(MockitoJUnitRunner.class)
class DoUpdateNetworkInstanceRollbackTest {
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(28090);
-
def utils = new MsoUtils()
String Prefix="UPDNETIR_"
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModuleTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModuleTest.groovy
index 59a2b0eda3..f16bc575a4 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModuleTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModuleTest.groovy
@@ -57,9 +57,6 @@ class DoUpdateVfModuleTest extends MsoGroovyTest{
@Captor
static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(28090)
-
@Spy
DoUpdateVfModule doUpdateVfModule
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModulesTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModulesTest.groovy
index a86029ea30..8e81e91228 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModulesTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModulesTest.groovy
@@ -47,9 +47,6 @@ class DoUpdateVnfAndModulesTest {
@Captor
static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(28090);
-
@Before
public void init() {
MockitoAnnotations.initMocks(this)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollbackTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollbackTest.groovy
index 41a862e00e..5c3521f5ba 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollbackTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollbackTest.groovy
@@ -238,8 +238,8 @@ class DoCreateAllottedResourceBRGRollbackTest extends GroovyTestBase {
ExecutionEntity mex = setupMock()
initUpdateAaiAROrchStatus(mex)
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml")
- MockPatchAllottedResource(CUST, SVC, INST, ARID)
+ MockGetAllottedResource(wireMockRule, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml")
+ MockPatchAllottedResource(wireMockRule, CUST, SVC, INST, ARID)
DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
DoCreateAllottedResourceBRGRollback.updateAaiAROrchStatus(mex, "success")
@@ -265,8 +265,8 @@ class DoCreateAllottedResourceBRGRollbackTest extends GroovyTestBase {
ExecutionEntity mex = setupMock()
initUpdateAaiAROrchStatus(mex)
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml")
- MockPatchAllottedResource(CUST, SVC, INST, ARID)
+ MockGetAllottedResource(wireMockRule, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml")
+ MockPatchAllottedResource(wireMockRule, CUST, SVC, INST, ARID)
when(mex.getVariable("aaiARPath")).thenReturn(null)
@@ -354,8 +354,8 @@ class DoCreateAllottedResourceBRGRollbackTest extends GroovyTestBase {
ExecutionEntity mex = setupMock()
initDeleteAaiAR(mex)
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml")
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
+ MockGetAllottedResource(wireMockRule, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml")
+ MockDeleteAllottedResource(wireMockRule, CUST, SVC, INST, ARID, VERS)
DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
DoCreateAllottedResourceBRGRollback.deleteAaiAR(mex)
@@ -366,8 +366,8 @@ class DoCreateAllottedResourceBRGRollbackTest extends GroovyTestBase {
ExecutionEntity mex = setupMock()
initDeleteAaiAR(mex)
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml")
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
+ MockGetAllottedResource(wireMockRule, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml")
+ MockDeleteAllottedResource(wireMockRule, CUST, SVC, INST, ARID, VERS)
when(mex.getVariable("aaiARPath")).thenReturn("")
@@ -381,8 +381,8 @@ class DoCreateAllottedResourceBRGRollbackTest extends GroovyTestBase {
ExecutionEntity mex = setupMock()
initDeleteAaiAR(mex)
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml")
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
+ MockGetAllottedResource(wireMockRule, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml")
+ MockDeleteAllottedResource(wireMockRule, CUST, SVC, INST, ARID, VERS)
when(mex.getVariable("aaiARPath")).thenThrow(new BpmnError("expected exception"))
@@ -396,8 +396,8 @@ class DoCreateAllottedResourceBRGRollbackTest extends GroovyTestBase {
ExecutionEntity mex = setupMock()
initDeleteAaiAR(mex)
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml")
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
+ MockGetAllottedResource(wireMockRule, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml")
+ MockDeleteAllottedResource(wireMockRule, CUST, SVC, INST, ARID, VERS)
when(mex.getVariable("aaiARPath")).thenThrow(new RuntimeException("expected exception"))
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGTest.groovy
index f094ef25fa..09244bedc4 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGTest.groovy
@@ -94,7 +94,7 @@ class DoCreateAllottedResourceBRGTest extends GroovyTestBase {
@Test
@Ignore
public void getAaiAR() {
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRG/getArBrg.xml")
+ MockGetAllottedResource(wireMockRule, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRG/getArBrg.xml")
ExecutionEntity mex = setupMock()
initGetAaiAR(mex)
@@ -107,7 +107,7 @@ class DoCreateAllottedResourceBRGTest extends GroovyTestBase {
@Test
public void getAaiAR_Duplicate() {
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRG/getArBrg.xml")
+ MockGetAllottedResource(wireMockRule, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRG/getArBrg.xml")
ExecutionEntity mex = setupMock()
initGetAaiAR(mex)
@@ -122,7 +122,7 @@ class DoCreateAllottedResourceBRGTest extends GroovyTestBase {
@Test
public void getAaiAR_NotActive() {
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRG/getArBrg.xml")
+ MockGetAllottedResource(wireMockRule, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRG/getArBrg.xml")
ExecutionEntity mex = setupMock()
initGetAaiAR(mex)
@@ -138,7 +138,7 @@ class DoCreateAllottedResourceBRGTest extends GroovyTestBase {
@Test
@Ignore
public void getAaiAR_NoStatus() {
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRG/getArBrg.xml")
+ MockGetAllottedResource(wireMockRule, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRG/getArBrg.xml")
ExecutionEntity mex = setupMock()
initGetAaiAR(mex)
@@ -205,7 +205,7 @@ class DoCreateAllottedResourceBRGTest extends GroovyTestBase {
when(mex.getVariable("PSI_resourceLink")).thenReturn(null)
- MockPutAllottedResource(CUST, SVC, INST, ARID)
+ MockPutAllottedResource(wireMockRule, CUST, SVC, INST, ARID)
DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
@@ -217,7 +217,7 @@ class DoCreateAllottedResourceBRGTest extends GroovyTestBase {
ExecutionEntity mex = setupMock()
initCreateAaiAr(mex)
- MockPutAllottedResource_500(CUST, SVC, INST, ARID)
+ MockPutAllottedResource_500(wireMockRule, CUST, SVC, INST, ARID)
DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
@@ -231,7 +231,7 @@ class DoCreateAllottedResourceBRGTest extends GroovyTestBase {
when(mex.getVariable("aai.endpoint")).thenThrow(new BpmnError("expected exception"))
- MockPutAllottedResource(CUST, SVC, INST, ARID)
+ MockPutAllottedResource(wireMockRule, CUST, SVC, INST, ARID)
DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
@@ -245,7 +245,7 @@ class DoCreateAllottedResourceBRGTest extends GroovyTestBase {
when(mex.getVariable("aai.endpoint")).thenThrow(new RuntimeException("expected exception"))
- MockPutAllottedResource(CUST, SVC, INST, ARID)
+ MockPutAllottedResource(wireMockRule, CUST, SVC, INST, ARID)
DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
@@ -621,7 +621,7 @@ class DoCreateAllottedResourceBRGTest extends GroovyTestBase {
@Test
@Ignore
public void updateAaiAROrchStatus() {
- MockPatchAllottedResource(CUST, SVC, INST, ARID)
+ MockPatchAllottedResource(wireMockRule, CUST, SVC, INST, ARID)
ExecutionEntity mex = setupMock()
initUpdateAaiAROrchStatus(mex)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollbackTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollbackTest.groovy
index a877ce42e7..e25f43f796 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollbackTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollbackTest.groovy
@@ -238,8 +238,8 @@ class DoCreateAllottedResourceTXCRollbackTest extends GroovyTestBase {
ExecutionEntity mex = setupMock()
initUpdateAaiAROrchStatus(mex)
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml")
- MockPatchAllottedResource(CUST, SVC, INST, ARID)
+ MockGetAllottedResource(wireMockRule, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml")
+ MockPatchAllottedResource(wireMockRule, CUST, SVC, INST, ARID)
DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
DoCreateAllottedResourceTXCRollback.updateAaiAROrchStatus(mex, "success")
@@ -265,8 +265,8 @@ class DoCreateAllottedResourceTXCRollbackTest extends GroovyTestBase {
ExecutionEntity mex = setupMock()
initUpdateAaiAROrchStatus(mex)
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml")
- MockPatchAllottedResource(CUST, SVC, INST, ARID)
+ MockGetAllottedResource(wireMockRule, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml")
+ MockPatchAllottedResource(wireMockRule, CUST, SVC, INST, ARID)
when(mex.getVariable("aaiARPath")).thenReturn(null)
@@ -354,8 +354,8 @@ class DoCreateAllottedResourceTXCRollbackTest extends GroovyTestBase {
ExecutionEntity mex = setupMock()
initDeleteAaiAR(mex)
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml")
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
+ MockGetAllottedResource(wireMockRule, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml")
+ MockDeleteAllottedResource(wireMockRule, CUST, SVC, INST, ARID, VERS)
DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
DoCreateAllottedResourceTXCRollback.deleteAaiAR(mex)
@@ -366,8 +366,8 @@ class DoCreateAllottedResourceTXCRollbackTest extends GroovyTestBase {
ExecutionEntity mex = setupMock()
initDeleteAaiAR(mex)
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml")
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
+ MockGetAllottedResource(wireMockRule, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml")
+ MockDeleteAllottedResource(wireMockRule, CUST, SVC, INST, ARID, VERS)
when(mex.getVariable("aaiARPath")).thenReturn("")
@@ -381,8 +381,8 @@ class DoCreateAllottedResourceTXCRollbackTest extends GroovyTestBase {
ExecutionEntity mex = setupMock()
initDeleteAaiAR(mex)
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml")
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
+ MockGetAllottedResource(wireMockRule, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml")
+ MockDeleteAllottedResource(wireMockRule, CUST, SVC, INST, ARID, VERS)
when(mex.getVariable("aaiARPath")).thenThrow(new BpmnError("expected exception"))
@@ -396,8 +396,8 @@ class DoCreateAllottedResourceTXCRollbackTest extends GroovyTestBase {
ExecutionEntity mex = setupMock()
initDeleteAaiAR(mex)
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml")
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
+ MockGetAllottedResource(wireMockRule, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml")
+ MockDeleteAllottedResource(wireMockRule, CUST, SVC, INST, ARID, VERS)
when(mex.getVariable("aaiARPath")).thenThrow(new RuntimeException("expected exception"))
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCTest.groovy
index b53e5fce21..901bdaf7b3 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCTest.groovy
@@ -93,7 +93,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
@Test
@Ignore
public void getAaiAR() {
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXC/getArTxc.xml")
+ MockGetAllottedResource(wireMockRule, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXC/getArTxc.xml")
ExecutionEntity mex = setupMock()
initGetAaiAR(mex)
@@ -107,7 +107,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
@Test
public void getAaiAR_Duplicate() {
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXC/getArTxc.xml")
+ MockGetAllottedResource(wireMockRule, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXC/getArTxc.xml")
ExecutionEntity mex = setupMock()
initGetAaiAR(mex)
@@ -122,7 +122,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
@Test
public void getAaiAR_NotActive() {
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXC/getArTxc.xml")
+ MockGetAllottedResource(wireMockRule, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXC/getArTxc.xml")
ExecutionEntity mex = setupMock()
initGetAaiAR(mex)
@@ -138,7 +138,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
@Test
@Ignore
public void getAaiAR_NoStatus() {
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXC/getArTxc.xml")
+ MockGetAllottedResource(wireMockRule, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXC/getArTxc.xml")
ExecutionEntity mex = setupMock()
initGetAaiAR(mex)
@@ -177,7 +177,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
when(mex.getVariable("PSI_resourceLink")).thenReturn(null)
- MockPutAllottedResource(CUST, SVC, INST, ARID)
+ MockPutAllottedResource(wireMockRule, CUST, SVC, INST, ARID)
DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
@@ -189,7 +189,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
ExecutionEntity mex = setupMock()
initCreateAaiAr(mex)
- MockPutAllottedResource_500(CUST, SVC, INST, ARID)
+ MockPutAllottedResource_500(wireMockRule, CUST, SVC, INST, ARID)
DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
@@ -203,7 +203,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
when(mex.getVariable("aai.endpoint")).thenThrow(new BpmnError("expected exception"))
- MockPutAllottedResource(CUST, SVC, INST, ARID)
+ MockPutAllottedResource(wireMockRule, CUST, SVC, INST, ARID)
DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
@@ -217,7 +217,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
when(mex.getVariable("aai.endpoint")).thenThrow(new RuntimeException("expected exception"))
- MockPutAllottedResource(CUST, SVC, INST, ARID)
+ MockPutAllottedResource(wireMockRule, CUST, SVC, INST, ARID)
DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
@@ -559,7 +559,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
@Test
@Ignore
public void updateAaiAROrchStatus() {
- MockPatchAllottedResource(CUST, SVC, INST, ARID)
+ MockPatchAllottedResource(wireMockRule, CUST, SVC, INST, ARID)
ExecutionEntity mex = setupMock()
initUpdateAaiAROrchStatus(mex)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRGTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRGTest.groovy
index e77c1dd9ed..ab9be8217d 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRGTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRGTest.groovy
@@ -132,7 +132,7 @@ class DoDeleteAllottedResourceBRGTest extends GroovyTestBase {
ExecutionEntity mex = setupMock()
initUpdateAaiAROrchStatus(mex)
- MockPatchAllottedResource(CUST, SVC, INST, ARID)
+ MockPatchAllottedResource(wireMockRule, CUST, SVC, INST, ARID)
DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
DoDeleteAllottedResourceBRG.updateAaiAROrchStatus(mex, "success")
@@ -412,8 +412,8 @@ class DoDeleteAllottedResourceBRGTest extends GroovyTestBase {
ExecutionEntity mex = setupMock()
initDeleteAaiAR(mex)
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml")
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
+ MockGetAllottedResource(wireMockRule, CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml")
+ MockDeleteAllottedResource(wireMockRule, CUST, SVC, INST, ARID, VERS)
DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
DoDeleteAllottedResourceBRG.deleteAaiAR(mex)
@@ -424,8 +424,8 @@ class DoDeleteAllottedResourceBRGTest extends GroovyTestBase {
ExecutionEntity mex = setupMock()
initDeleteAaiAR(mex)
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml")
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
+ MockGetAllottedResource(wireMockRule, CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml")
+ MockDeleteAllottedResource(wireMockRule, CUST, SVC, INST, ARID, VERS)
when(mex.getVariable("aaiARPath")).thenReturn("")
@@ -439,8 +439,8 @@ class DoDeleteAllottedResourceBRGTest extends GroovyTestBase {
ExecutionEntity mex = setupMock()
initDeleteAaiAR(mex)
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml")
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
+ MockGetAllottedResource(wireMockRule, CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml")
+ MockDeleteAllottedResource(wireMockRule, CUST, SVC, INST, ARID, VERS)
when(mex.getVariable("aaiARPath")).thenThrow(new BpmnError("expected exception"))
@@ -454,8 +454,8 @@ class DoDeleteAllottedResourceBRGTest extends GroovyTestBase {
ExecutionEntity mex = setupMock()
initDeleteAaiAR(mex)
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml")
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
+ MockGetAllottedResource(wireMockRule, CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml")
+ MockDeleteAllottedResource(wireMockRule, CUST, SVC, INST, ARID, VERS)
when(mex.getVariable("aaiARPath")).thenThrow(new RuntimeException("expected exception"))
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXCTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXCTest.groovy
index 23115874a2..6a75c145ff 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXCTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXCTest.groovy
@@ -132,7 +132,7 @@ class DoDeleteAllottedResourceTXCTest extends GroovyTestBase {
ExecutionEntity mex = setupMock()
initUpdateAaiAROrchStatus(mex)
- MockPatchAllottedResource(CUST, SVC, INST, ARID)
+ MockPatchAllottedResource(wireMockRule, CUST, SVC, INST, ARID)
DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
DoDeleteAllottedResourceTXC.updateAaiAROrchStatus(mex, "success")
@@ -412,8 +412,8 @@ class DoDeleteAllottedResourceTXCTest extends GroovyTestBase {
ExecutionEntity mex = setupMock()
initDeleteAaiAR(mex)
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml")
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
+ MockGetAllottedResource(wireMockRule, CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml")
+ MockDeleteAllottedResource(wireMockRule, CUST, SVC, INST, ARID, VERS)
DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
DoDeleteAllottedResourceTXC.deleteAaiAR(mex)
@@ -424,8 +424,8 @@ class DoDeleteAllottedResourceTXCTest extends GroovyTestBase {
ExecutionEntity mex = setupMock()
initDeleteAaiAR(mex)
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml")
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
+ MockGetAllottedResource(wireMockRule, CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml")
+ MockDeleteAllottedResource(wireMockRule, CUST, SVC, INST, ARID, VERS)
when(mex.getVariable("aaiARPath")).thenReturn("")
@@ -439,8 +439,8 @@ class DoDeleteAllottedResourceTXCTest extends GroovyTestBase {
ExecutionEntity mex = setupMock()
initDeleteAaiAR(mex)
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml")
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
+ MockGetAllottedResource(wireMockRule, CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml")
+ MockDeleteAllottedResource(wireMockRule, CUST, SVC, INST, ARID, VERS)
when(mex.getVariable("aaiARPath")).thenThrow(new BpmnError("expected exception"))
@@ -454,8 +454,8 @@ class DoDeleteAllottedResourceTXCTest extends GroovyTestBase {
ExecutionEntity mex = setupMock()
initDeleteAaiAR(mex)
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml")
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
+ MockGetAllottedResource(wireMockRule, CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml")
+ MockDeleteAllottedResource(wireMockRule, CUST, SVC, INST, ARID, VERS)
when(mex.getVariable("aaiARPath")).thenThrow(new RuntimeException("expected exception"))
diff --git a/bpmn/so-bpmn-infrastructure-flows/pom.xml b/bpmn/so-bpmn-infrastructure-flows/pom.xml
index b3275eb6ec..59b9027000 100644
--- a/bpmn/so-bpmn-infrastructure-flows/pom.xml
+++ b/bpmn/so-bpmn-infrastructure-flows/pom.xml
@@ -104,6 +104,9 @@
</configuration>
</execution>
</executions>
+ <configuration>
+ <parallel>suites</parallel>
+ </configuration>
</plugin>
</plugins>
</pluginManagement>
diff --git a/bpmn/so-bpmn-tasks/pom.xml b/bpmn/so-bpmn-tasks/pom.xml
index 8adffb29b5..14eb42ff79 100644
--- a/bpmn/so-bpmn-tasks/pom.xml
+++ b/bpmn/so-bpmn-tasks/pom.xml
@@ -43,6 +43,9 @@
</configuration>
</execution>
</executions>
+ <configuration>
+ <parallel>suites</parallel>
+ </configuration>
</plugin>
<plugin>
<groupId>io.swagger</groupId>
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/Constants.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/Constants.java
index 667ac133af..59f8be50c8 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/Constants.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/Constants.java
@@ -20,26 +20,40 @@
package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks;
+import static com.google.common.collect.Sets.newHashSet;
+import java.util.Set;
+import org.onap.vnfmadapter.v1.model.OperationStateEnum;
+import org.onap.vnfmadapter.v1.model.OperationStatusRetrievalStatusEnum;
+
/**
* @author waqas.ikram@est.tech
*/
public class Constants {
- public static final String CREATE_VNF_REQUEST_PARAM_NAME = "createVnfRequest";
- public static final String CREATE_VNF_RESPONSE_PARAM_NAME = "createVnfResponse";
-
- public static final String INPUT_PARAMETER = "inputParameter";
+ public static final String CREATE_VNF_REQUEST_PARAM_NAME = "createVnfRequest";
+ public static final String CREATE_VNF_RESPONSE_PARAM_NAME = "createVnfResponse";
+ public static final String INPUT_PARAMETER = "inputParameter";
+ public static final String DELETE_VNF_RESPONSE_PARAM_NAME = "deleteVnfResponse";
+
+
+ public static final String DOT = ".";
+ public static final String UNDERSCORE = "_";
+ public static final String SPACE = "\\s+";
+
+ public static final String VNFM_ADAPTER_DEFAULT_URL = "http://so-vnfm-adapter.onap:9092/so/vnfm-adapter/v1/";
+ public static final String VNFM_ADAPTER_DEFAULT_AUTH = "Basic dm5mbTpwYXNzd29yZDEk";
+
+ public static final String FORWARD_SLASH = "/";
+ public static final String PRELOAD_VNFS_URL = "/restconf/config/VNF-API:preload-vnfs/vnf-preload-list/";
+
- public static final String DOT = ".";
- public static final String UNDERSCORE = "_";
- public static final String SPACE = "\\s+";
+ public static final Set<OperationStateEnum> OPERATION_FINISHED_STATES =
+ newHashSet(OperationStateEnum.COMPLETED, OperationStateEnum.FAILED, OperationStateEnum.ROLLED_BACK);
- public static final String VNFM_ADAPTER_DEFAULT_URL = "http://so-vnfm-adapter.onap:9092/so/vnfm-adapter/v1/";
- public static final String VNFM_ADAPTER_DEFAULT_AUTH = "Basic dm5mbTpwYXNzd29yZDEk";
-
- public static final String FORWARD_SLASH = "/";
- public static final String PRELOAD_VNFS_URL = "/restconf/config/VNF-API:preload-vnfs/vnf-preload-list/";
+ public static final Set<OperationStatusRetrievalStatusEnum> OPERATION_RETRIEVAL_STATES = newHashSet(
+ OperationStatusRetrievalStatusEnum.STATUS_FOUND, OperationStatusRetrievalStatusEnum.WAITING_FOR_STATUS);
+ public static final String OPERATION_STATUS_PARAM_NAME = "operationStatus";
- private Constants() {}
+ private Constants() {}
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/EtsiVnfDeleteTask.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/EtsiVnfDeleteTask.java
new file mode 100644
index 0000000000..857c5cb6fe
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/EtsiVnfDeleteTask.java
@@ -0,0 +1,84 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks;
+
+import static org.onap.so.bpmn.servicedecomposition.entities.ResourceKey.GENERIC_VNF_ID;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
+import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.onap.vnfmadapter.v1.model.DeleteVnfResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import com.google.common.base.Optional;
+
+/**
+ *
+ * @author Lathishbabu Ganesan (lathishbabu.ganesan@est.tech)
+ */
+@Component
+public class EtsiVnfDeleteTask {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(EtsiVnfDeleteTask.class);
+ private final ExtractPojosForBB extractPojosForBB;
+ private final ExceptionBuilder exceptionUtil;
+ private final VnfmAdapterServiceProvider vnfmAdapterServiceProvider;
+
+ @Autowired
+ public EtsiVnfDeleteTask(final ExceptionBuilder exceptionUtil, final ExtractPojosForBB extractPojosForBB,
+ final VnfmAdapterServiceProvider vnfmAdapterServiceProvider) {
+ this.exceptionUtil = exceptionUtil;
+ this.extractPojosForBB = extractPojosForBB;
+ this.vnfmAdapterServiceProvider = vnfmAdapterServiceProvider;
+ }
+
+ /**
+ * Invoke VNFM adapter to delete the VNF
+ *
+ * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
+ */
+ public void invokeVnfmAdapter(final BuildingBlockExecution execution) {
+ try {
+ LOGGER.debug("Executing invokeVnfmAdapter ...");
+ final GenericVnf vnf = extractPojosForBB.extractByKey(execution, GENERIC_VNF_ID);
+
+ final Optional<DeleteVnfResponse> response = vnfmAdapterServiceProvider.invokeDeleteRequest(vnf.getVnfId());
+
+ if (!response.isPresent()) {
+ final String errorMessage = "Unexpected error while processing delete request";
+ LOGGER.error(errorMessage);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 1211, errorMessage);
+ }
+
+ final DeleteVnfResponse vnfResponse = response.get();
+
+ LOGGER.debug("Vnf delete response: {}", vnfResponse);
+ execution.setVariable(Constants.DELETE_VNF_RESPONSE_PARAM_NAME, vnfResponse);
+
+ LOGGER.debug("Finished executing invokeVnfmAdapter ...");
+ } catch (final Exception exception) {
+ LOGGER.error("Unable to invoke delete request", exception);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 1212, exception);
+ }
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmCreateJobTask.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmCreateJobTask.java
new file mode 100644
index 0000000000..f89931063c
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmCreateJobTask.java
@@ -0,0 +1,154 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Ericsson. 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks;
+
+import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.CREATE_VNF_RESPONSE_PARAM_NAME;
+import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.OPERATION_FINISHED_STATES;
+import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.OPERATION_RETRIEVAL_STATES;
+import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.OPERATION_STATUS_PARAM_NAME;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.onap.vnfmadapter.v1.model.CreateVnfResponse;
+import org.onap.vnfmadapter.v1.model.OperationStateEnum;
+import org.onap.vnfmadapter.v1.model.QueryJobResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import com.google.common.base.Optional;
+
+
+/**
+ * @author waqas.ikram@est.tech
+ *
+ */
+@Component
+public class MonitorVnfmCreateJobTask {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(MonitorVnfmCreateJobTask.class);
+ private final ExceptionBuilder exceptionUtil;
+ private final VnfmAdapterServiceProvider vnfmAdapterServiceProvider;
+
+ @Autowired
+ public MonitorVnfmCreateJobTask(final VnfmAdapterServiceProvider vnfmAdapterServiceProvider,
+ final ExceptionBuilder exceptionUtil) {
+ this.vnfmAdapterServiceProvider = vnfmAdapterServiceProvider;
+ this.exceptionUtil = exceptionUtil;
+ }
+
+ /**
+ * Get the current operation status of instantiation job
+ *
+ * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
+ */
+ public void getCurrentOperationStatus(final BuildingBlockExecution execution) {
+ LOGGER.debug("Executing getCurrentOperationStatus ...");
+ final CreateVnfResponse vnfInstantiateResponse = execution.getVariable(CREATE_VNF_RESPONSE_PARAM_NAME);
+ execution.setVariable(OPERATION_STATUS_PARAM_NAME, getOperationStatus(execution, vnfInstantiateResponse));
+ LOGGER.debug("Finished executing getCurrentOperationStatus ...");
+ }
+
+ /**
+ * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
+ * @return boolean to indicate whether job has competed or not
+ */
+ public boolean hasOperationFinished(final BuildingBlockExecution execution) {
+ LOGGER.debug("Executing hasOperationFinished ...");
+
+ final Optional<OperationStateEnum> operationStatusOption = execution.getVariable(OPERATION_STATUS_PARAM_NAME);
+ if (operationStatusOption != null && operationStatusOption.isPresent()) {
+ return OPERATION_FINISHED_STATES.contains(operationStatusOption.get());
+ }
+ LOGGER.debug("OperationStatus is not present yet... ");
+ LOGGER.debug("Finished executing hasOperationFinished ...");
+ return false;
+
+ }
+
+ /**
+ * Log and throw exception on timeout for job status
+ *
+ * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
+ */
+ public void timeOutLogFailue(final BuildingBlockExecution execution) {
+ final String message = "Instantiation operation time out";
+ LOGGER.error(message);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 1205, message);
+ }
+
+ /**
+ * Check the final status of instantiation throw exception if not completed successfully
+ *
+ * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
+ */
+ public void checkIfOperationWasSuccessful(final BuildingBlockExecution execution) {
+ LOGGER.debug("Executing checkIfOperationWasSuccessful ...");
+ final Optional<OperationStateEnum> operationStatusOption = execution.getVariable(OPERATION_STATUS_PARAM_NAME);
+ final CreateVnfResponse vnfInstantiateResponse = execution.getVariable(CREATE_VNF_RESPONSE_PARAM_NAME);
+ if (operationStatusOption == null || !operationStatusOption.isPresent()) {
+ final String message = "Unable to instantiate jobId: "
+ + (vnfInstantiateResponse != null ? vnfInstantiateResponse.getJobId() : "null")
+ + "Unable to retrieve OperationStatus";
+ LOGGER.error(message);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 1206, message);
+ }
+ if (operationStatusOption.isPresent()) {
+ final OperationStateEnum operationStatus = operationStatusOption.get();
+ if (operationStatus != OperationStateEnum.COMPLETED) {
+ final String message = "Unable to instantiate jobId: "
+ + (vnfInstantiateResponse != null ? vnfInstantiateResponse.getJobId() : "null") + " OperationStatus: "
+ + operationStatus;
+ LOGGER.error(message);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 1207, message);
+ }
+ LOGGER.debug("Successfully completed instatiation of job {}", vnfInstantiateResponse);
+ }
+ }
+
+ private Optional<OperationStateEnum> getOperationStatus(final BuildingBlockExecution execution,
+ final CreateVnfResponse vnfInstantiateResponse) {
+
+ final Optional<QueryJobResponse> instantiateOperationJobStatus =
+ vnfmAdapterServiceProvider.getInstantiateOperationJobStatus(vnfInstantiateResponse.getJobId());
+
+ if (instantiateOperationJobStatus.isPresent()) {
+ final QueryJobResponse queryJobResponse = instantiateOperationJobStatus.get();
+
+ if (!OPERATION_RETRIEVAL_STATES.contains(queryJobResponse.getOperationStatusRetrievalStatus())) {
+ final String message =
+ "Recevied invalid operation reterivel state: " + queryJobResponse.getOperationStatusRetrievalStatus();
+ LOGGER.error(message);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 1203, message);
+ }
+
+ if (queryJobResponse.getOperationState() != null) {
+ final OperationStateEnum operationStatus = queryJobResponse.getOperationState();
+ LOGGER.debug("Operation {} with {} and operation retrieval status : {}", queryJobResponse.getId(),
+ operationStatus, queryJobResponse.getOperationStatusRetrievalStatus());
+ return Optional.of(queryJobResponse.getOperationState());
+ }
+
+ LOGGER.debug("Operation {} without operationStatus and operation retrieval status :{}", queryJobResponse.getId(),
+ queryJobResponse.getOperationStatusRetrievalStatus());
+
+ }
+ return Optional.absent();
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProvider.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProvider.java
index 02303ef09d..1e785074f3 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProvider.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProvider.java
@@ -22,17 +22,22 @@ package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks;
import org.onap.vnfmadapter.v1.model.CreateVnfRequest;
import org.onap.vnfmadapter.v1.model.CreateVnfResponse;
-
+import org.onap.vnfmadapter.v1.model.DeleteVnfResponse;
+import org.onap.vnfmadapter.v1.model.QueryJobResponse;
import com.google.common.base.Optional;
/**
* Provide a service which interacts with VNFM adapter for instantiating, monitoring VNF
- *
+ *
* @author waqas.ikram@est.tech
*/
public interface VnfmAdapterServiceProvider {
- Optional<CreateVnfResponse> invokeCreateInstantiationRequest(final String vnfId, final CreateVnfRequest request);
+ Optional<CreateVnfResponse> invokeCreateInstantiationRequest(final String vnfId, final CreateVnfRequest request);
+
+ Optional<DeleteVnfResponse> invokeDeleteRequest(final String vnfId);
+
+ Optional<QueryJobResponse> getInstantiateOperationJobStatus(final String jobId);
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImpl.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImpl.java
index afdcccfd36..e8f4c08f38 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImpl.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImpl.java
@@ -25,13 +25,14 @@ import org.onap.so.rest.exceptions.RestProcessingException;
import org.onap.so.rest.service.HttpRestServiceProvider;
import org.onap.vnfmadapter.v1.model.CreateVnfRequest;
import org.onap.vnfmadapter.v1.model.CreateVnfResponse;
+import org.onap.vnfmadapter.v1.model.DeleteVnfResponse;
+import org.onap.vnfmadapter.v1.model.QueryJobResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
-
import com.google.common.base.Optional;
/**
@@ -40,50 +41,111 @@ import com.google.common.base.Optional;
@Service
public class VnfmAdapterServiceProviderImpl implements VnfmAdapterServiceProvider {
- private static final Logger LOGGER = LoggerFactory.getLogger(VnfmAdapterServiceProviderImpl.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(VnfmAdapterServiceProviderImpl.class);
+
+ private final VnfmAdapterUrlProvider urlProvider;
+ private final HttpRestServiceProvider httpServiceProvider;
+
+ @Autowired
+ public VnfmAdapterServiceProviderImpl(final VnfmAdapterUrlProvider urlProvider,
+ final HttpRestServiceProvider httpServiceProvider) {
+ this.urlProvider = urlProvider;
+ this.httpServiceProvider = httpServiceProvider;
+ }
+
+ @Override
+ public Optional<CreateVnfResponse> invokeCreateInstantiationRequest(final String vnfId,
+ final CreateVnfRequest request) {
+ try {
+ final String url = urlProvider.getCreateInstantiateUrl(vnfId);
+
+ final ResponseEntity<CreateVnfResponse> response =
+ httpServiceProvider.postHttpRequest(request, url, CreateVnfResponse.class);
+
+ final HttpStatus httpStatus = response.getStatusCode();
+ if (!(httpStatus.equals(HttpStatus.ACCEPTED)) && !(httpStatus.equals(HttpStatus.OK))) {
+ LOGGER.error("Unable to invoke HTTP POST using URL: {}, Response Code: {}", url, httpStatus.value());
+ return Optional.absent();
+ }
+
+ if (!response.hasBody()) {
+ LOGGER.error("Received response without body: {}", response);
+ return Optional.absent();
+ }
- private final VnfmAdapterUrlProvider urlProvider;
- private final HttpRestServiceProvider httpServiceProvider;
+ final CreateVnfResponse createVnfResponse = response.getBody();
- @Autowired
- public VnfmAdapterServiceProviderImpl(final VnfmAdapterUrlProvider urlProvider,
- final HttpRestServiceProvider httpServiceProvider) {
- this.urlProvider = urlProvider;
- this.httpServiceProvider = httpServiceProvider;
+ if (createVnfResponse.getJobId() == null || createVnfResponse.getJobId().isEmpty()) {
+ LOGGER.error("Received invalid instantiation response: {}", response);
+ return Optional.absent();
+ }
+
+ return Optional.of(createVnfResponse);
+ } catch (final RestProcessingException | InvalidRestRequestException httpInvocationException) {
+ LOGGER.error("Unexpected error while processing create and instantiation request", httpInvocationException);
+ return Optional.absent();
}
- @Override
- public Optional<CreateVnfResponse> invokeCreateInstantiationRequest(final String vnfId,
- final CreateVnfRequest request) {
- try {
- final String url = urlProvider.getCreateInstantiateUrl(vnfId);
+ }
+
+ @Override
+ public Optional<DeleteVnfResponse> invokeDeleteRequest(final String vnfId) {
+ try {
+ final String url = urlProvider.getDeleteUrl(vnfId);
+ LOGGER.debug("Will send request to vnfm adapter using url: {}", url);
+
+ final ResponseEntity<DeleteVnfResponse> response =
+ httpServiceProvider.deleteHttpRequest(url, DeleteVnfResponse.class);
+
+ LOGGER.debug("Response received: ", response);
- final ResponseEntity<CreateVnfResponse> response =
- httpServiceProvider.postHttpRequest(request, url, CreateVnfResponse.class);
+ final HttpStatus httpStatus = response.getStatusCode();
- final HttpStatus httpStatus = response.getStatusCode();
- if (!(httpStatus.equals(HttpStatus.ACCEPTED)) && !(httpStatus.equals(HttpStatus.OK))) {
- LOGGER.error("Unable to invoke HTTP POST using URL: {}, Response Code: {}", url, httpStatus.value());
- return Optional.absent();
- }
+ if (!(httpStatus.equals(HttpStatus.ACCEPTED)) && !(httpStatus.equals(HttpStatus.OK))) {
+ LOGGER.error("Unable to invoke HTTP DELETE using URL: {}, Response Code: {}", url, httpStatus.value());
+ return Optional.absent();
+ }
+
+ if (!response.hasBody()) {
+ LOGGER.error("Received response without body: {}", response);
+ return Optional.absent();
+ }
+ final DeleteVnfResponse deleteVnfResponse = response.getBody();
+
+ if (deleteVnfResponse.getJobId() == null || deleteVnfResponse.getJobId().isEmpty()) {
+ LOGGER.error("Received invalid delete response: {}", response);
+ return Optional.absent();
+ }
+ return Optional.of(deleteVnfResponse);
+ } catch (final RestProcessingException | InvalidRestRequestException httpInvocationException) {
+ LOGGER.error("Unexpected error while processing delete request", httpInvocationException);
+ return Optional.absent();
+ }
+ }
- if (!response.hasBody()) {
- LOGGER.error("Received response without body: {}", response);
- return Optional.absent();
- }
+ @Override
+ public Optional<QueryJobResponse> getInstantiateOperationJobStatus(final String jobId) {
+ try {
+ final String url = urlProvider.getJobStatusUrl(jobId);
- final CreateVnfResponse createVnfResponse = response.getBody();
+ final ResponseEntity<QueryJobResponse> response =
+ httpServiceProvider.getHttpResponse(url, QueryJobResponse.class);
- if (createVnfResponse.getJobId() == null || createVnfResponse.getJobId().isEmpty()) {
- LOGGER.error("Received invalid instantiation response: {}", response);
- return Optional.absent();
- }
+ final HttpStatus httpStatus = response.getStatusCode();
- return Optional.of(createVnfResponse);
- } catch (final RestProcessingException | InvalidRestRequestException httpInvocationException) {
- LOGGER.error("Unexpected error while processing create and instantiation request", httpInvocationException);
- return Optional.absent();
- }
+ if (!(httpStatus.equals(HttpStatus.ACCEPTED)) && !(httpStatus.equals(HttpStatus.OK))) {
+ LOGGER.error("Unable to invoke HTTP GET using URL: {}, Response Code: ", url, httpStatus.value());
+ return Optional.absent();
+ }
+ if (!response.hasBody()) {
+ LOGGER.error("Received response without body: {}", response);
+ return Optional.absent();
+ }
+ return Optional.of(response.getBody());
+ } catch (final RestProcessingException | InvalidRestRequestException httpInvocationException) {
+ LOGGER.error("Unexpected error while processing job request", httpInvocationException);
+ return Optional.absent();
}
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterUrlProvider.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterUrlProvider.java
index 03ee0712e7..97a7197373 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterUrlProvider.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterUrlProvider.java
@@ -21,7 +21,6 @@
package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks;
import java.net.URI;
-
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.util.UriComponentsBuilder;
@@ -36,23 +35,43 @@ import org.springframework.web.util.UriComponentsBuilder;
@Service
public class VnfmAdapterUrlProvider {
- private final URI baseUri;
+ private final URI baseUri;
- @Autowired
- public VnfmAdapterUrlProvider(final VnfmBasicHttpConfigProvider etsiVnfmAdapter) {
- this.baseUri = UriComponentsBuilder.fromHttpUrl(etsiVnfmAdapter.getUrl()).build().toUri();
- }
+ @Autowired
+ public VnfmAdapterUrlProvider(final VnfmBasicHttpConfigProvider etsiVnfmAdapter) {
+ this.baseUri = UriComponentsBuilder.fromHttpUrl(etsiVnfmAdapter.getUrl()).build().toUri();
+ }
+
+ /**
+ * Get VNFM create and instantiate URL
+ *
+ * @param vnfId The identifier of the VNF. This must be the vnf-id of an existing generic-vnf in
+ * AAI.
+ * @return VNFM create and instantiate URL
+ */
+ public String getCreateInstantiateUrl(final String vnfId) {
+ return UriComponentsBuilder.fromUri(baseUri).pathSegment("vnfs").pathSegment(vnfId).build().toString();
+ }
+
+ /**
+ * Get VNFM delete URL
+ *
+ * @param vnfId The identifier of the VNF. This must be the vnf-id of an existing generic-vnf in
+ * AAI.
+ * @return VNFM delete URL
+ */
+ public String getDeleteUrl(final String vnfId) {
+ return UriComponentsBuilder.fromUri(baseUri).pathSegment("vnfs").pathSegment(vnfId).build().toString();
+ }
/**
- * Get VNFM create and instantiate URL
+ * Get job status URL
*
- * @param vnfId The identifier of the VNF. This must be the vnf-id of an existing generic-vnf in
- * AAI.
- * @return VNFM create and instantiate URL
+ * @param jobId The instantiation job identifier
+ * @return job status URL
*/
- public String getCreateInstantiateUrl(final String vnfId) {
- return UriComponentsBuilder.fromUri(baseUri).pathSegment("vnfs").pathSegment(vnfId).build().toString();
+ public String getJobStatusUrl(final String jobId) {
+ return UriComponentsBuilder.fromUri(baseUri).pathSegment("jobs").pathSegment(jobId).build().toString();
}
-
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapper.java
index b11e2caafa..7b86756afa 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapper.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapper.java
@@ -21,6 +21,7 @@
package org.onap.so.client.sdnc.mapper;
import java.net.URI;
+import java.util.UUID;
import org.onap.sdnc.northbound.client.model.GenericResourceApiConfigurationinformationConfigurationInformation;
import org.onap.sdnc.northbound.client.model.GenericResourceApiGcTopologyOperationInformation;
@@ -52,9 +53,13 @@ public class GCTopologyOperationRequestMapper {
Configuration vnrConfiguration,
GenericVnf voiceVnf, String sdncReqId,URI callbackUri) {
+ String msoRequestId = UUID.randomUUID().toString();
+ if (requestContext != null && requestContext.getMsoRequestId() != null) {
+ msoRequestId = requestContext.getMsoRequestId();
+ }
GenericResourceApiGcTopologyOperationInformation req = new GenericResourceApiGcTopologyOperationInformation();
GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId,callbackUri.toString());
- GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper.buildGenericResourceApiRequestinformationRequestInformation(sdncReqId, reqAction);
+ GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper.buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, reqAction);
GenericResourceApiServiceinformationServiceInformation serviceInformation = generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, false);
GenericResourceApiConfigurationinformationConfigurationInformation configurationInformation = generalTopologyObjectMapper.buildConfigurationInformation(vnrConfiguration,true);
GenericResourceApiGcrequestinputGcRequestInput gcRequestInput = generalTopologyObjectMapper.buildGcRequestInformation(voiceVnf,null);
@@ -74,11 +79,15 @@ public class GCTopologyOperationRequestMapper {
RequestContext requestContext,
Configuration vnrConfiguration, String sdncReqId, URI callbackUri) {
+ String msoRequestId = null;
+ if (requestContext != null) {
+ msoRequestId = requestContext.getMsoRequestId();
+ }
GenericResourceApiGcTopologyOperationInformation req = new GenericResourceApiGcTopologyOperationInformation();
GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader =
generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId,callbackUri.toString());
GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper
- .buildGenericResourceApiRequestinformationRequestInformation(sdncReqId,
+ .buildGenericResourceApiRequestinformationRequestInformation(msoRequestId,
GenericResourceApiRequestActionEnumeration.DELETEGENERICCONFIGURATIONINSTANCE);
GenericResourceApiServiceinformationServiceInformation serviceInformation = new GenericResourceApiServiceinformationServiceInformation();
serviceInformation.setServiceInstanceId(serviceInstance.getServiceInstanceId());
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java
index b086b8a7ff..756e5b068e 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java
@@ -60,10 +60,10 @@ public class GeneralTopologyObjectMapper {
/*
* Build GenericResourceApiRequestinformationRequestInformation
*/
- public GenericResourceApiRequestinformationRequestInformation buildGenericResourceApiRequestinformationRequestInformation(String sdncReqId, GenericResourceApiRequestActionEnumeration requestAction){
+ public GenericResourceApiRequestinformationRequestInformation buildGenericResourceApiRequestinformationRequestInformation(String msoReqId, GenericResourceApiRequestActionEnumeration requestAction){
GenericResourceApiRequestinformationRequestInformation requestInformation = new GenericResourceApiRequestinformationRequestInformation();
- requestInformation.setRequestId(sdncReqId);
+ requestInformation.setRequestId(msoReqId);
requestInformation.setRequestAction(requestAction);
requestInformation.setSource("MSO");
return requestInformation;
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapper.java
index 188a228e5d..aef7e9e044 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapper.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapper.java
@@ -57,8 +57,12 @@ public class NetworkTopologyOperationRequestMapper {
Customer customer, RequestContext requestContext, CloudRegion cloudRegion) {
GenericResourceApiNetworkOperationInformation req = new GenericResourceApiNetworkOperationInformation();
String sdncReqId = UUID.randomUUID().toString();
+ String msoRequestId = UUID.randomUUID().toString();
+ if (requestContext != null && requestContext.getMsoRequestId() != null) {
+ msoRequestId = requestContext.getMsoRequestId();
+ }
GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId);
- GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper.buildGenericResourceApiRequestinformationRequestInformation(sdncReqId, reqAction);
+ GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper.buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, reqAction);
GenericResourceApiServiceinformationServiceInformation serviceInformation = generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, true);
GenericResourceApiNetworkinformationNetworkInformation networkInformation = generalTopologyObjectMapper.buildNetworkInformation(network);
GenericResourceApiNetworkrequestinputNetworkRequestInput networkRequestInput = buildNetworkRequestInput(network, serviceInstance, cloudRegion);
@@ -68,7 +72,7 @@ public class NetworkTopologyOperationRequestMapper {
req.setServiceInformation(serviceInformation);
req.setNetworkInformation(networkInformation);
- if (requestContext.getUserParams() != null) {
+ if (requestContext != null && requestContext.getUserParams() != null) {
for (Map.Entry<String, Object> entry : requestContext.getUserParams().entrySet()) {
GenericResourceApiParam networkInputParameters = new GenericResourceApiParam();
GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam();
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapper.java
index 505466b22c..cdb4ab96aa 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapper.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapper.java
@@ -49,9 +49,13 @@ public class ServiceTopologyOperationMapper{
SDNCSvcAction svcAction, GenericResourceApiRequestActionEnumeration resourceAction,ServiceInstance serviceInstance, Customer customer, RequestContext requestContext) {
String sdncReqId = UUID.randomUUID().toString();
+ String msoRequestId = UUID.randomUUID().toString();
+ if (requestContext != null && requestContext.getMsoRequestId() != null) {
+ msoRequestId = requestContext.getMsoRequestId();
+ }
GenericResourceApiServiceOperationInformation servOpInput = new GenericResourceApiServiceOperationInformation();
GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId);
- GenericResourceApiRequestinformationRequestInformation reqInfo = generalTopologyObjectMapper.buildGenericResourceApiRequestinformationRequestInformation(sdncReqId, resourceAction);
+ GenericResourceApiRequestinformationRequestInformation reqInfo = generalTopologyObjectMapper.buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, resourceAction);
GenericResourceApiServiceinformationServiceInformation servInfo = generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, true);
GenericResourceApiServicerequestinputServiceRequestInput servReqInfo = new GenericResourceApiServicerequestinputServiceRequestInput();
@@ -62,7 +66,7 @@ public class ServiceTopologyOperationMapper{
servOpInput.setServiceInformation(servInfo);
servOpInput.setServiceRequestInput(servReqInfo);
- if(requestContext.getUserParams()!=null){
+ if(requestContext != null && requestContext.getUserParams()!=null){
for (Map.Entry<String, Object> entry : requestContext.getUserParams().entrySet()) {
GenericResourceApiServicerequestinputServiceRequestInput serviceRequestInput = new GenericResourceApiServicerequestinputServiceRequestInput();
serviceRequestInput.setServiceInstanceName(serviceInstance.getServiceInstanceName());
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java
index b8c5fad41d..86c718d165 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java
@@ -96,8 +96,12 @@ public class VfModuleTopologyOperationRequestMapper {
}
String sdncReqId = UUID.randomUUID().toString();
+ String msoRequestId = UUID.randomUUID().toString();
+ if (requestContext != null && requestContext.getMsoRequestId() != null) {
+ msoRequestId = requestContext.getMsoRequestId();
+ }
- GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper.buildGenericResourceApiRequestinformationRequestInformation(sdncReqId,
+ GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper.buildGenericResourceApiRequestinformationRequestInformation(msoRequestId,
requestAction);
GenericResourceApiServiceinformationServiceInformation serviceInformation = generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, includeModelInformation);
GenericResourceApiVnfinformationVnfInformation vnfInformation = generalTopologyObjectMapper.buildVnfInformation(vnf, serviceInstance, includeModelInformation);
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java
index 7de393bb2f..85e5b85529 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java
@@ -59,11 +59,15 @@ public class VnfTopologyOperationRequestMapper {
GenericResourceApiRequestActionEnumeration requestAction, GenericVnf vnf, ServiceInstance serviceInstance,
Customer customer, CloudRegion cloudRegion, RequestContext requestContext, boolean homing) {
String sdncReqId = UUID.randomUUID().toString();
+ String msoRequestId = UUID.randomUUID().toString();
+ if (requestContext != null && requestContext.getMsoRequestId() != null) {
+ msoRequestId = requestContext.getMsoRequestId();
+ }
GenericResourceApiVnfOperationInformation req = new GenericResourceApiVnfOperationInformation();
GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = generalTopologyObjectMapper
.buildSdncRequestHeader(svcAction, sdncReqId);
GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper
- .buildGenericResourceApiRequestinformationRequestInformation(sdncReqId, requestAction);
+ .buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, requestAction);
GenericResourceApiServiceinformationServiceInformation serviceInformation = generalTopologyObjectMapper
.buildServiceInformation(serviceInstance, requestContext, customer, true);
GenericResourceApiVnfinformationVnfInformation vnfInformation = generalTopologyObjectMapper
@@ -84,7 +88,7 @@ public class VnfTopologyOperationRequestMapper {
req.setVnfInformation(vnfInformation);
GenericResourceApiParam vnfInputParameters = new GenericResourceApiParam();
- if (requestContext.getUserParams() != null) {
+ if (requestContext != null && requestContext.getUserParams() != null) {
for (Map.Entry<String, Object> entry : requestContext.getUserParams().entrySet()) {
GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam();
paramItem.setName(entry.getKey());
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/BaseIntegrationTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/BaseIntegrationTest.java
index 6500e3a850..aefe4c64bf 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/BaseIntegrationTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/BaseIntegrationTest.java
@@ -31,6 +31,7 @@ import org.onap.so.client.orchestration.SDNOHealthCheckResources;
import org.onap.so.client.sdnc.SDNCClient;
import org.onap.so.client.sniro.SniroClient;
import org.onap.so.db.catalog.client.CatalogDbClient;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
@@ -40,7 +41,7 @@ import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
-import com.github.tomakehurst.wiremock.client.WireMock;
+import com.github.tomakehurst.wiremock.WireMockServer;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@@ -69,10 +70,13 @@ public abstract class BaseIntegrationTest extends TestDataSetup {
@MockBean
protected CatalogDbClient catalogDbClient;
+
+ @Autowired
+ protected WireMockServer wireMockServer;
@Before
public void baseTestBefore() {
- WireMock.reset();
+ wireMockServer.resetAll();
}
public String readResourceFile(String fileName) {
InputStream stream;
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/EtsiVnfDeleteTaskTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/EtsiVnfDeleteTaskTest.java
new file mode 100644
index 0000000000..5c76018ced
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/EtsiVnfDeleteTaskTest.java
@@ -0,0 +1,111 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import java.util.UUID;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
+import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
+import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf;
+import org.onap.vnfmadapter.v1.model.DeleteVnfResponse;
+import com.google.common.base.Optional;
+
+/**
+ *
+ * @author Lathishbabu Ganesan (lathishbabu.ganesan@est.tech)
+ *
+ */
+public class EtsiVnfDeleteTaskTest extends BaseTaskTest {
+
+ private static final String MODEL_INSTANCE_NAME = "MODEL_INSTANCE_NAME";
+
+ private static final String VNF_ID = UUID.randomUUID().toString();
+
+ private static final String VNF_NAME = "VNF_NAME";
+
+ private static final String JOB_ID = UUID.randomUUID().toString();
+
+ @Mock
+ private VnfmAdapterServiceProvider mockedVnfmAdapterServiceProvider;
+
+ @Mock
+ private GeneralBuildingBlock buildingBlock;
+
+ @Mock
+ private RequestContext requestContext;
+
+ private final BuildingBlockExecution stubbedxecution = new StubbedBuildingBlockExecution();
+
+ @Test
+ public void testInvokeVnfmAdapter() throws Exception {
+ final EtsiVnfDeleteTask objUnderTest = getEtsiVnfDeleteTask();
+ when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(getGenericVnf());
+ when(mockedVnfmAdapterServiceProvider.invokeDeleteRequest(eq(VNF_ID))).thenReturn(getDeleteVnfResponse());
+ objUnderTest.invokeVnfmAdapter(stubbedxecution);
+ assertNotNull(stubbedxecution.getVariable(Constants.DELETE_VNF_RESPONSE_PARAM_NAME));
+ }
+
+ @Test
+ public void testInvokeVnfmAdapterException() throws Exception {
+ final EtsiVnfDeleteTask objUnderTest = getEtsiVnfDeleteTask();
+ when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(getGenericVnf());
+ when(mockedVnfmAdapterServiceProvider.invokeDeleteRequest(eq(VNF_ID))).thenReturn(Optional.absent());
+ objUnderTest.invokeVnfmAdapter(stubbedxecution);
+ assertNull(stubbedxecution.getVariable(Constants.DELETE_VNF_RESPONSE_PARAM_NAME));
+ verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1212),
+ any(Exception.class));
+ }
+
+ private Optional<DeleteVnfResponse> getDeleteVnfResponse() {
+ final DeleteVnfResponse response = new DeleteVnfResponse();
+ response.setJobId(JOB_ID);
+ return Optional.of(response);
+ }
+
+ private GenericVnf getGenericVnf() {
+ final GenericVnf genericVnf = new GenericVnf();
+ genericVnf.setVnfId(VNF_ID);
+ genericVnf.setModelInfoGenericVnf(getModelInfoGenericVnf());
+ genericVnf.setVnfName(VNF_NAME);
+ return genericVnf;
+ }
+
+ private ModelInfoGenericVnf getModelInfoGenericVnf() {
+ final ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setModelInstanceName(MODEL_INSTANCE_NAME);
+ return modelInfoGenericVnf;
+ }
+
+ private EtsiVnfDeleteTask getEtsiVnfDeleteTask() {
+ return new EtsiVnfDeleteTask(exceptionUtil, extractPojosForBB, mockedVnfmAdapterServiceProvider);
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmCreateJobTaskTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmCreateJobTaskTest.java
new file mode 100644
index 0000000000..ed5fa94100
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmCreateJobTaskTest.java
@@ -0,0 +1,178 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import java.util.UUID;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.vnfmadapter.v1.model.CreateVnfResponse;
+import org.onap.vnfmadapter.v1.model.OperationStateEnum;
+import org.onap.vnfmadapter.v1.model.OperationStatusRetrievalStatusEnum;
+import org.onap.vnfmadapter.v1.model.QueryJobResponse;
+import com.google.common.base.Optional;
+
+/**
+ *
+ * @author Lathishbabu Ganesan (lathishbabu.ganesan@est.tech)
+ *
+ */
+public class MonitorVnfmCreateJobTaskTest extends BaseTaskTest {
+
+ private static final String JOB_ID = UUID.randomUUID().toString();
+
+ @Mock
+ private VnfmAdapterServiceProvider mockedVnfmAdapterServiceProvider;
+
+ private final BuildingBlockExecution stubbedxecution = new StubbedBuildingBlockExecution();
+
+ @Test
+ public void testGetCurrentOperationStatus() throws Exception {
+ final MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask();
+ stubbedxecution.setVariable(Constants.CREATE_VNF_RESPONSE_PARAM_NAME, getCreateVnfResponse());
+ Optional<QueryJobResponse> queryJobResponse = getQueryJobResponse();
+ queryJobResponse.get().setOperationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.STATUS_FOUND);
+ queryJobResponse.get().setOperationState(OperationStateEnum.COMPLETED);
+ when(mockedVnfmAdapterServiceProvider.getInstantiateOperationJobStatus(JOB_ID)).thenReturn(queryJobResponse);
+ objUnderTest.getCurrentOperationStatus(stubbedxecution);
+ final Optional<OperationStateEnum> operationState =
+ stubbedxecution.getVariable(Constants.OPERATION_STATUS_PARAM_NAME);
+ assertNotNull(operationState);
+ assertEquals(OperationStateEnum.COMPLETED, operationState.get());
+ }
+
+ @Test
+ public void testGetCurrentOperationStatusFailed() throws Exception {
+ final MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask();
+ stubbedxecution.setVariable(Constants.CREATE_VNF_RESPONSE_PARAM_NAME, getCreateVnfResponse());
+ Optional<QueryJobResponse> queryJobResponse = getQueryJobResponse();
+ queryJobResponse.get().setOperationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.CANNOT_RETRIEVE_STATUS);
+ queryJobResponse.get().setOperationState(OperationStateEnum.FAILED);
+ when(mockedVnfmAdapterServiceProvider.getInstantiateOperationJobStatus(JOB_ID)).thenReturn(queryJobResponse);
+ objUnderTest.getCurrentOperationStatus(stubbedxecution);
+ final Optional<OperationStateEnum> operationState =
+ stubbedxecution.getVariable(Constants.OPERATION_STATUS_PARAM_NAME);
+ assertNotNull(operationState);
+ assertEquals(OperationStateEnum.FAILED, operationState.get());
+ }
+
+ @Test
+ public void testGetCurrentOperationStatusEmpty() throws Exception {
+ final MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask();
+ stubbedxecution.setVariable(Constants.CREATE_VNF_RESPONSE_PARAM_NAME, getCreateVnfResponse());
+ Optional<QueryJobResponse> queryJobResponse = getQueryJobResponse();
+ queryJobResponse.get().setOperationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.STATUS_FOUND);
+ when(mockedVnfmAdapterServiceProvider.getInstantiateOperationJobStatus(JOB_ID)).thenReturn(queryJobResponse);
+ objUnderTest.getCurrentOperationStatus(stubbedxecution);
+ final Optional<OperationStateEnum> operationState =
+ stubbedxecution.getVariable(Constants.OPERATION_STATUS_PARAM_NAME);
+ assertFalse(operationState.isPresent());
+ }
+
+ @Test
+ public void testGetCurrentOperationStatusException() throws Exception {
+ final MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask();
+ stubbedxecution.setVariable(Constants.CREATE_VNF_RESPONSE_PARAM_NAME, getCreateVnfResponse());
+ Optional<QueryJobResponse> queryJobResponse = getQueryJobResponse();
+ queryJobResponse.get().setOperationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.STATUS_FOUND);
+ when(mockedVnfmAdapterServiceProvider.getInstantiateOperationJobStatus(JOB_ID)).thenReturn(queryJobResponse);
+ objUnderTest.getCurrentOperationStatus(stubbedxecution);
+ final Optional<OperationStateEnum> operationState =
+ stubbedxecution.getVariable(Constants.OPERATION_STATUS_PARAM_NAME);
+ assertFalse(operationState.isPresent());
+ }
+
+ @Test
+ public void testHasOperationFinished() throws Exception {
+ final MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask();
+ stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.of(OperationStateEnum.COMPLETED));
+ assertTrue(objUnderTest.hasOperationFinished(stubbedxecution));
+ }
+
+ @Test
+ public void testHasOperationPending() throws Exception {
+ final MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask();
+ stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.absent());
+ assertFalse(objUnderTest.hasOperationFinished(stubbedxecution));
+ }
+
+ @Test
+ public void testTimeOutLogFailue() throws Exception {
+ final MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask();
+ objUnderTest.timeOutLogFailue(stubbedxecution);
+ verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1205),
+ eq("Instantiation operation time out"));
+ }
+
+ @Test
+ public void testCheckIfOperationWasSuccessful() throws Exception {
+ stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.of(OperationStateEnum.COMPLETED));
+ MonitorVnfmCreateJobTask objUnderTest = Mockito.spy(getEtsiVnfMonitorJobTask());
+ objUnderTest.checkIfOperationWasSuccessful(stubbedxecution);
+ verify(objUnderTest, times(1)).checkIfOperationWasSuccessful(stubbedxecution);
+ }
+
+ @Test
+ public void testCheckIfOperationWasSuccessfulWithPending() throws Exception {
+ final MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask();
+ stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.of(OperationStateEnum.PROCESSING));
+ objUnderTest.checkIfOperationWasSuccessful(stubbedxecution);
+ verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1207), anyString());
+ }
+
+ @Test
+ public void testCheckIfOperationWasSuccessfulEmpty() throws Exception {
+ MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask();
+ stubbedxecution.setVariable(Constants.CREATE_VNF_RESPONSE_PARAM_NAME, getCreateVnfResponse());
+ stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.absent());
+ objUnderTest.checkIfOperationWasSuccessful(stubbedxecution);
+ verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1206), anyString());
+ }
+
+ private CreateVnfResponse getCreateVnfResponse() {
+ final CreateVnfResponse response = new CreateVnfResponse();
+ response.setJobId(JOB_ID);
+ return response;
+ }
+
+ private Optional<QueryJobResponse> getQueryJobResponse() {
+ final QueryJobResponse queryJobResponse = new QueryJobResponse();
+ queryJobResponse.setId(JOB_ID);
+ return Optional.of(queryJobResponse);
+ }
+
+ private MonitorVnfmCreateJobTask getEtsiVnfMonitorJobTask() {
+ return new MonitorVnfmCreateJobTask(mockedVnfmAdapterServiceProvider, exceptionUtil);
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/StubbedBuildingBlockExecution.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/StubbedBuildingBlockExecution.java
new file mode 100644
index 0000000000..260585d208
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/StubbedBuildingBlockExecution.java
@@ -0,0 +1,100 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.common.exceptions.RequiredExecutionVariableExeception;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
+import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+
+/**
+ *
+ * @author Lathishbabu Ganesan (lathishbabu.ganesan@est.tech)
+ *
+ */
+public class StubbedBuildingBlockExecution implements BuildingBlockExecution {
+
+ private static final String CLOUD_OWNER = "CLOUD_OWNER";
+ private static final String LCP_CLOUD_REGIONID = "RegionOnce";
+ private static final String TENANT_ID = UUID.randomUUID().toString();
+ private final Map<String, Serializable> execution = new HashMap<>();
+ private final GeneralBuildingBlock generalBuildingBlock;
+
+ StubbedBuildingBlockExecution() {
+ generalBuildingBlock = getGeneralBuildingBlockValue();
+ }
+
+ @Override
+ public GeneralBuildingBlock getGeneralBuildingBlock() {
+ return generalBuildingBlock;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> T getVariable(final String key) {
+ return (T) execution.get(key);
+ }
+
+ @Override
+ public <T> T getRequiredVariable(final String key) throws RequiredExecutionVariableExeception {
+ return null;
+ }
+
+ @Override
+ public void setVariable(final String key, final Serializable value) {
+ execution.put(key, value);
+ }
+
+ @Override
+ public Map<ResourceKey, String> getLookupMap() {
+ return Collections.emptyMap();
+ }
+
+ @Override
+ public String getFlowToBeCalled() {
+ return null;
+ }
+
+ public static String getTenantId() {
+ return TENANT_ID;
+ }
+
+ private GeneralBuildingBlock getGeneralBuildingBlockValue() {
+ final GeneralBuildingBlock buildingBlock = new GeneralBuildingBlock();
+ buildingBlock.setCloudRegion(getCloudRegion());
+ return buildingBlock;
+ }
+
+ private CloudRegion getCloudRegion() {
+ final CloudRegion cloudRegion = new CloudRegion();
+ cloudRegion.setCloudOwner(CLOUD_OWNER);
+ cloudRegion.setLcpCloudRegionId(LCP_CLOUD_REGIONID);
+ cloudRegion.setTenantId(TENANT_ID);
+ return cloudRegion;
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/TestConstants.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/TestConstants.java
index 5451d4442f..c4f19d6d1a 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/TestConstants.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/TestConstants.java
@@ -20,6 +20,10 @@
package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks;
+import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.TestConstants.DUMMY_URL;
+
+import java.util.UUID;
+
import org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.VnfmBasicHttpConfigProvider;
/**
@@ -32,6 +36,9 @@ public class TestConstants {
public static final String DUMMY_BASIC_AUTH = "Basic 123abc";
public static final String DUMMY_URL = "http://localhost:30406/so/vnfm-adapter/v1/";
public static final String EXPECTED_URL = DUMMY_URL + "vnfs/" + DUMMY_GENERIC_VND_ID;
+
+ public static final String DUMMY_JOB_ID = UUID.randomUUID().toString();
+ public static final String JOB_STATUS_EXPECTED_URL = DUMMY_URL + "jobs/" + DUMMY_JOB_ID;
public static VnfmBasicHttpConfigProvider getVnfmBasicHttpConfigProvider() {
return getVnfmBasicHttpConfigProvider(DUMMY_URL, DUMMY_BASIC_AUTH);
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTaskTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTaskTest.java
index 20abe6ece1..22c4c15079 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTaskTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTaskTest.java
@@ -30,28 +30,19 @@ import static org.mockito.Mockito.when;
import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.CREATE_VNF_REQUEST_PARAM_NAME;
import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.CREATE_VNF_RESPONSE_PARAM_NAME;
import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.INPUT_PARAMETER;
-
-import java.io.Serializable;
import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
import java.util.UUID;
-
import org.junit.Test;
import org.mockito.Mock;
import org.onap.so.bpmn.BaseTaskTest;
import org.onap.so.bpmn.common.BuildingBlockExecution;
-import org.onap.so.bpmn.common.exceptions.RequiredExecutionVariableExeception;
import org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.utils.InputParameter;
-import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
-import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf;
import org.onap.vnfmadapter.v1.model.CreateVnfRequest;
import org.onap.vnfmadapter.v1.model.CreateVnfResponse;
import org.onap.vnfmadapter.v1.model.Tenant;
-
import com.google.common.base.Optional;
@@ -60,191 +51,131 @@ import com.google.common.base.Optional;
*/
public class VnfmAdapterCreateVnfTaskTest extends BaseTaskTest {
- private static final String MODEL_INSTANCE_NAME = "MODEL_INSTANCE_NAME";
-
- private static final String CLOUD_OWNER = "CLOUD_OWNER";
-
- private static final String LCP_CLOUD_REGIONID = "RegionOnce";
-
- private static final String TENANT_ID = UUID.randomUUID().toString();
-
- private static final String VNF_ID = UUID.randomUUID().toString();
-
- private static final String VNF_NAME = "VNF_NAME";
-
- private static final String JOB_ID = UUID.randomUUID().toString();
-
- @Mock
- private VnfmAdapterServiceProvider mockedVnfmAdapterServiceProvider;
-
- private final BuildingBlockExecution stubbedxecution = new StubbedBuildingBlockExecution();
-
- @Test
- public void testBuildCreateVnfRequest_withValidValues_storesRequestInExecution() throws Exception {
-
- final VnfmAdapterCreateVnfTask objUnderTest = getEtsiVnfInstantiateTask();
- stubbedxecution.setVariable(INPUT_PARAMETER,
- new InputParameter(Collections.emptyMap(), Collections.emptyList()));
-
- when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(getGenericVnf());
- objUnderTest.buildCreateVnfRequest(stubbedxecution);
-
- final CreateVnfRequest actual = stubbedxecution.getVariable(CREATE_VNF_REQUEST_PARAM_NAME);
- assertNotNull(actual);
- assertEquals(VNF_NAME + "." + MODEL_INSTANCE_NAME, actual.getName());
-
- final Tenant actualTenant = actual.getTenant();
- assertEquals(CLOUD_OWNER, actualTenant.getCloudOwner());
- assertEquals(LCP_CLOUD_REGIONID, actualTenant.getRegionName());
- assertEquals(TENANT_ID, actualTenant.getTenantId());
-
- }
+ private static final String MODEL_INSTANCE_NAME = "MODEL_INSTANCE_NAME";
- @Test
- public void testBuildCreateVnfRequest_extractPojosForBBThrowsException_exceptionBuilderCalled() throws Exception {
+ private static final String CLOUD_OWNER = "CLOUD_OWNER";
- final VnfmAdapterCreateVnfTask objUnderTest = getEtsiVnfInstantiateTask();
+ private static final String LCP_CLOUD_REGIONID = "RegionOnce";
- when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenThrow(RuntimeException.class);
+ private static final String VNF_ID = UUID.randomUUID().toString();
- objUnderTest.buildCreateVnfRequest(stubbedxecution);
+ private static final String VNF_NAME = "VNF_NAME";
- final CreateVnfRequest actual = stubbedxecution.getVariable(CREATE_VNF_REQUEST_PARAM_NAME);
+ private static final String JOB_ID = UUID.randomUUID().toString();
- assertNull(actual);
- verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1200),
- any(Exception.class));
+ @Mock
+ private VnfmAdapterServiceProvider mockedVnfmAdapterServiceProvider;
- }
+ private final BuildingBlockExecution stubbedxecution = new StubbedBuildingBlockExecution();
- @Test
- public void testInvokeVnfmAdapter_validValues_storesResponseInExecution() throws Exception {
+ @Test
+ public void testBuildCreateVnfRequest_withValidValues_storesRequestInExecution() throws Exception {
- final VnfmAdapterCreateVnfTask objUnderTest = getEtsiVnfInstantiateTask();
+ final VnfmAdapterCreateVnfTask objUnderTest = getEtsiVnfInstantiateTask();
+ stubbedxecution.setVariable(INPUT_PARAMETER, new InputParameter(Collections.emptyMap(), Collections.emptyList()));
- stubbedxecution.setVariable(CREATE_VNF_REQUEST_PARAM_NAME, new CreateVnfRequest());
+ when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(getGenericVnf());
+ objUnderTest.buildCreateVnfRequest(stubbedxecution);
- when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(getGenericVnf());
- when(mockedVnfmAdapterServiceProvider.invokeCreateInstantiationRequest(eq(VNF_ID), any(CreateVnfRequest.class)))
- .thenReturn(getCreateVnfResponse());
+ final CreateVnfRequest actual = stubbedxecution.getVariable(CREATE_VNF_REQUEST_PARAM_NAME);
+ assertNotNull(actual);
+ assertEquals(VNF_NAME + "." + MODEL_INSTANCE_NAME, actual.getName());
- objUnderTest.invokeVnfmAdapter(stubbedxecution);
+ final Tenant actualTenant = actual.getTenant();
+ assertEquals(CLOUD_OWNER, actualTenant.getCloudOwner());
+ assertEquals(LCP_CLOUD_REGIONID, actualTenant.getRegionName());
+ assertEquals(StubbedBuildingBlockExecution.getTenantId(), actualTenant.getTenantId());
- assertNotNull(stubbedxecution.getVariable(CREATE_VNF_RESPONSE_PARAM_NAME));
- }
+ }
- @Test
- public void testInvokeVnfmAdapter_invalidValues_storesResponseInExecution() throws Exception {
+ @Test
+ public void testBuildCreateVnfRequest_extractPojosForBBThrowsException_exceptionBuilderCalled() throws Exception {
- final VnfmAdapterCreateVnfTask objUnderTest = getEtsiVnfInstantiateTask();
+ final VnfmAdapterCreateVnfTask objUnderTest = getEtsiVnfInstantiateTask();
- stubbedxecution.setVariable(CREATE_VNF_REQUEST_PARAM_NAME, new CreateVnfRequest());
+ when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenThrow(RuntimeException.class);
- when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(getGenericVnf());
- when(mockedVnfmAdapterServiceProvider.invokeCreateInstantiationRequest(eq(VNF_ID), any(CreateVnfRequest.class)))
- .thenReturn(Optional.absent());
+ objUnderTest.buildCreateVnfRequest(stubbedxecution);
- objUnderTest.invokeVnfmAdapter(stubbedxecution);
+ final CreateVnfRequest actual = stubbedxecution.getVariable(CREATE_VNF_REQUEST_PARAM_NAME);
- assertNull(stubbedxecution.getVariable(CREATE_VNF_RESPONSE_PARAM_NAME));
- verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1202),
- any(Exception.class));
- }
+ assertNull(actual);
+ verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1200),
+ any(Exception.class));
+ }
- @Test
- public void testInvokeVnfmAdapter_extractPojosForBBThrowsException_exceptionBuilderCalled() throws Exception {
+ @Test
+ public void testInvokeVnfmAdapter_validValues_storesResponseInExecution() throws Exception {
- final VnfmAdapterCreateVnfTask objUnderTest = getEtsiVnfInstantiateTask();
+ final VnfmAdapterCreateVnfTask objUnderTest = getEtsiVnfInstantiateTask();
- when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenThrow(RuntimeException.class);
+ stubbedxecution.setVariable(CREATE_VNF_REQUEST_PARAM_NAME, new CreateVnfRequest());
- objUnderTest.invokeVnfmAdapter(stubbedxecution);
+ when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(getGenericVnf());
+ when(mockedVnfmAdapterServiceProvider.invokeCreateInstantiationRequest(eq(VNF_ID), any(CreateVnfRequest.class)))
+ .thenReturn(getCreateVnfResponse());
- assertNull(stubbedxecution.getVariable(CREATE_VNF_RESPONSE_PARAM_NAME));
- verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1202),
- any(Exception.class));
+ objUnderTest.invokeVnfmAdapter(stubbedxecution);
- }
+ assertNotNull(stubbedxecution.getVariable(CREATE_VNF_RESPONSE_PARAM_NAME));
+ }
- private Optional<CreateVnfResponse> getCreateVnfResponse() {
- final CreateVnfResponse response = new CreateVnfResponse();
- response.setJobId(JOB_ID);
- return Optional.of(response);
- }
+ @Test
+ public void testInvokeVnfmAdapter_invalidValues_storesResponseInExecution() throws Exception {
- private GenericVnf getGenericVnf() {
- final GenericVnf genericVnf = new GenericVnf();
- genericVnf.setVnfId(VNF_ID);
- genericVnf.setModelInfoGenericVnf(getModelInfoGenericVnf());
- genericVnf.setVnfName(VNF_NAME);
- return genericVnf;
- }
+ final VnfmAdapterCreateVnfTask objUnderTest = getEtsiVnfInstantiateTask();
- private ModelInfoGenericVnf getModelInfoGenericVnf() {
- final ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
- modelInfoGenericVnf.setModelInstanceName(MODEL_INSTANCE_NAME);
- return modelInfoGenericVnf;
- }
+ stubbedxecution.setVariable(CREATE_VNF_REQUEST_PARAM_NAME, new CreateVnfRequest());
- private VnfmAdapterCreateVnfTask getEtsiVnfInstantiateTask() {
- return new VnfmAdapterCreateVnfTask(exceptionUtil, extractPojosForBB, mockedVnfmAdapterServiceProvider);
- }
+ when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(getGenericVnf());
+ when(mockedVnfmAdapterServiceProvider.invokeCreateInstantiationRequest(eq(VNF_ID), any(CreateVnfRequest.class)))
+ .thenReturn(Optional.absent());
- private class StubbedBuildingBlockExecution implements BuildingBlockExecution {
+ objUnderTest.invokeVnfmAdapter(stubbedxecution);
- private final Map<String, Serializable> execution = new HashMap<>();
- private final GeneralBuildingBlock generalBuildingBlock;
+ assertNull(stubbedxecution.getVariable(CREATE_VNF_RESPONSE_PARAM_NAME));
+ verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1202),
+ any(Exception.class));
+ }
- StubbedBuildingBlockExecution() {
- generalBuildingBlock = getGeneralBuildingBlockValue();
- }
- @Override
- public GeneralBuildingBlock getGeneralBuildingBlock() {
- return generalBuildingBlock;
- }
+ @Test
+ public void testInvokeVnfmAdapter_extractPojosForBBThrowsException_exceptionBuilderCalled() throws Exception {
- @SuppressWarnings("unchecked")
- @Override
- public <T> T getVariable(final String key) {
- return (T) execution.get(key);
- }
+ final VnfmAdapterCreateVnfTask objUnderTest = getEtsiVnfInstantiateTask();
- @Override
- public <T> T getRequiredVariable(final String key) throws RequiredExecutionVariableExeception {
- return null;
- }
+ when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenThrow(RuntimeException.class);
- @Override
- public void setVariable(final String key, final Serializable value) {
- execution.put(key, value);
- }
+ objUnderTest.invokeVnfmAdapter(stubbedxecution);
- @Override
- public Map<ResourceKey, String> getLookupMap() {
- return Collections.emptyMap();
- }
+ assertNull(stubbedxecution.getVariable(CREATE_VNF_RESPONSE_PARAM_NAME));
+ verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1202),
+ any(Exception.class));
- @Override
- public String getFlowToBeCalled() {
- return null;
- }
+ }
- private GeneralBuildingBlock getGeneralBuildingBlockValue() {
- final GeneralBuildingBlock buildingBlock = new GeneralBuildingBlock();
- buildingBlock.setCloudRegion(getCloudRegion());
- return buildingBlock;
- }
+ private Optional<CreateVnfResponse> getCreateVnfResponse() {
+ final CreateVnfResponse response = new CreateVnfResponse();
+ response.setJobId(JOB_ID);
+ return Optional.of(response);
+ }
- private CloudRegion getCloudRegion() {
- final CloudRegion cloudRegion = new CloudRegion();
- cloudRegion.setCloudOwner(CLOUD_OWNER);
- cloudRegion.setLcpCloudRegionId(LCP_CLOUD_REGIONID);
- cloudRegion.setTenantId(TENANT_ID);
- return cloudRegion;
- }
+ private GenericVnf getGenericVnf() {
+ final GenericVnf genericVnf = new GenericVnf();
+ genericVnf.setVnfId(VNF_ID);
+ genericVnf.setModelInfoGenericVnf(getModelInfoGenericVnf());
+ genericVnf.setVnfName(VNF_NAME);
+ return genericVnf;
+ }
- }
+ private ModelInfoGenericVnf getModelInfoGenericVnf() {
+ final ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setModelInstanceName(MODEL_INSTANCE_NAME);
+ return modelInfoGenericVnf;
+ }
+ private VnfmAdapterCreateVnfTask getEtsiVnfInstantiateTask() {
+ return new VnfmAdapterCreateVnfTask(exceptionUtil, extractPojosForBB, mockedVnfmAdapterServiceProvider);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImplTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImplTest.java
index 0f443916c4..6f1b6f0bd2 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImplTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImplTest.java
@@ -22,29 +22,27 @@ package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.when;
import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.TestConstants.DUMMY_GENERIC_VND_ID;
+import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.TestConstants.DUMMY_JOB_ID;
import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.TestConstants.getVnfmBasicHttpConfigProvider;
-
-import java.util.UUID;
-
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
-import org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.VnfmAdapterServiceProvider;
-import org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.VnfmAdapterServiceProviderImpl;
-import org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.VnfmAdapterUrlProvider;
import org.onap.so.rest.exceptions.RestProcessingException;
import org.onap.so.rest.service.HttpRestServiceProvider;
import org.onap.vnfmadapter.v1.model.CreateVnfRequest;
import org.onap.vnfmadapter.v1.model.CreateVnfResponse;
+import org.onap.vnfmadapter.v1.model.DeleteVnfResponse;
+import org.onap.vnfmadapter.v1.model.OperationStateEnum;
+import org.onap.vnfmadapter.v1.model.QueryJobResponse;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
-
import com.google.common.base.Optional;
@@ -54,114 +52,242 @@ import com.google.common.base.Optional;
@RunWith(MockitoJUnitRunner.class)
public class VnfmAdapterServiceProviderImplTest {
- private static final String EMPTY_JOB_ID = "";
-
- private static final CreateVnfRequest CREATE_VNF_REQUEST = new CreateVnfRequest();
-
- private static final String DUMMY_JOB_ID = UUID.randomUUID().toString();
-
- @Mock
- private HttpRestServiceProvider mockedHttpServiceProvider;
-
- @Mock
- private ResponseEntity<CreateVnfResponse> mockedResponseEntity;
-
- @Test
- public void testInvokeCreateInstantiationRequest_httpServiceProviderReturnsStatusAcceptedWithBody_validResponse() {
-
- when(mockedHttpServiceProvider.postHttpRequest(eq(CREATE_VNF_REQUEST), anyString(),
- eq(CreateVnfResponse.class))).thenReturn(mockedResponseEntity);
- when(mockedResponseEntity.getStatusCode()).thenReturn(HttpStatus.ACCEPTED);
- when(mockedResponseEntity.hasBody()).thenReturn(true);
- final CreateVnfResponse response = getCreateVnfResponse(DUMMY_JOB_ID);
- when(mockedResponseEntity.getBody()).thenReturn(response);
-
-
- final VnfmAdapterServiceProvider objUnderTest =
- new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
-
- final Optional<CreateVnfResponse> actual =
- objUnderTest.invokeCreateInstantiationRequest(DUMMY_GENERIC_VND_ID, CREATE_VNF_REQUEST);
- assertTrue(actual.isPresent());
- assertEquals(actual.get(), response);
-
- }
-
- @Test
- public void testInvokeCreateInstantiationRequest_httpServiceProviderReturnsStatusAcceptedWithNoBody_noResponse() {
- assertWithStatuCode(HttpStatus.ACCEPTED);
- }
-
- @Test
- public void testInvokeCreateInstantiationRequest_httpServiceProviderReturnsStatusNotOkWithNoBody_noResponse() {
- assertWithStatuCode(HttpStatus.UNAUTHORIZED);
- }
-
-
- @Test
- public void testInvokeCreateInstantiationRequest_httpServiceProviderReturnsStatusAcceptedWithBodyWithInvalidJobId_noResponse() {
- assertWithJobId(null);
- assertWithJobId(EMPTY_JOB_ID);
- }
-
- @Test
- public void testInvokeCreateInstantiationRequest_httpServiceProviderThrowException_httpRestServiceProviderNotNull() {
-
- when(mockedHttpServiceProvider.postHttpRequest(eq(CREATE_VNF_REQUEST), anyString(),
- eq(CreateVnfResponse.class))).thenThrow(RestProcessingException.class);
-
-
- final VnfmAdapterServiceProvider objUnderTest =
- new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
-
- final Optional<CreateVnfResponse> actual =
- objUnderTest.invokeCreateInstantiationRequest(DUMMY_GENERIC_VND_ID, CREATE_VNF_REQUEST);
- assertFalse(actual.isPresent());
-
- }
-
-
- private void assertWithJobId(final String jobId) {
- when(mockedHttpServiceProvider.postHttpRequest(eq(CREATE_VNF_REQUEST), anyString(),
- eq(CreateVnfResponse.class))).thenReturn(mockedResponseEntity);
- when(mockedResponseEntity.getStatusCode()).thenReturn(HttpStatus.ACCEPTED);
- when(mockedResponseEntity.hasBody()).thenReturn(true);
- final CreateVnfResponse response = getCreateVnfResponse(jobId);
- when(mockedResponseEntity.getBody()).thenReturn(response);
-
-
- final VnfmAdapterServiceProvider objUnderTest =
- new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
-
- final Optional<CreateVnfResponse> actual =
- objUnderTest.invokeCreateInstantiationRequest(DUMMY_GENERIC_VND_ID, CREATE_VNF_REQUEST);
- assertFalse(actual.isPresent());
- }
-
- private void assertWithStatuCode(final HttpStatus status) {
- when(mockedHttpServiceProvider.postHttpRequest(eq(CREATE_VNF_REQUEST), anyString(),
- eq(CreateVnfResponse.class))).thenReturn(mockedResponseEntity);
- when(mockedResponseEntity.getStatusCode()).thenReturn(status);
- when(mockedResponseEntity.hasBody()).thenReturn(false);
-
- final VnfmAdapterServiceProvider objUnderTest =
- new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
-
- final Optional<CreateVnfResponse> actual =
- objUnderTest.invokeCreateInstantiationRequest(DUMMY_GENERIC_VND_ID, CREATE_VNF_REQUEST);
- assertFalse(actual.isPresent());
- }
+ private static final String EMPTY_JOB_ID = "";
+
+ private static final CreateVnfRequest CREATE_VNF_REQUEST = new CreateVnfRequest();
+
+ @Mock
+ private HttpRestServiceProvider mockedHttpServiceProvider;
+
+ @Mock
+ private ResponseEntity<CreateVnfResponse> mockedResponseEntity;
+
+ @Mock
+ private ResponseEntity<DeleteVnfResponse> deleteVnfResponse;
+ @Mock
+ private ResponseEntity<QueryJobResponse> mockedQueryJobResponseResponseEntity;
+
+ @Test
+ public void testInvokeCreateInstantiationRequest_httpServiceProviderReturnsStatusAcceptedWithBody_validResponse() {
+
+ when(mockedHttpServiceProvider.postHttpRequest(eq(CREATE_VNF_REQUEST), anyString(), eq(CreateVnfResponse.class)))
+ .thenReturn(mockedResponseEntity);
+ when(mockedResponseEntity.getStatusCode()).thenReturn(HttpStatus.ACCEPTED);
+ when(mockedResponseEntity.hasBody()).thenReturn(true);
+ final CreateVnfResponse response = getCreateVnfResponse(DUMMY_JOB_ID);
+ when(mockedResponseEntity.getBody()).thenReturn(response);
+ final VnfmAdapterServiceProvider objUnderTest =
+ new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
+ final Optional<CreateVnfResponse> actual =
+ objUnderTest.invokeCreateInstantiationRequest(DUMMY_GENERIC_VND_ID, CREATE_VNF_REQUEST);
+ assertTrue(actual.isPresent());
+ assertEquals(actual.get(), response);
+ }
+
+ @Test
+ public void testInvokeCreateInstantiationRequest_httpServiceProviderReturnsStatusAcceptedWithNoBody_noResponse() {
+ assertWithStatuCode(HttpStatus.ACCEPTED);
+ }
+
+ @Test
+ public void testInvokeCreateInstantiationRequest_httpServiceProviderReturnsStatusNotOkWithNoBody_noResponse() {
+ assertWithStatuCode(HttpStatus.UNAUTHORIZED);
+ }
+
+
+ @Test
+ public void testInvokeCreateInstantiationRequest_httpServiceProviderReturnsStatusAcceptedWithBodyWithInvalidJobId_noResponse() {
+ assertWithJobId(null);
+ assertWithJobId(EMPTY_JOB_ID);
+ }
+
+ @Test
+ public void testInvokeCreateInstantiationRequest_httpServiceProviderThrowException_httpRestServiceProviderNotNull() {
+
+ when(mockedHttpServiceProvider.postHttpRequest(eq(CREATE_VNF_REQUEST), anyString(), eq(CreateVnfResponse.class)))
+ .thenThrow(RestProcessingException.class);
+
+
+ final VnfmAdapterServiceProvider objUnderTest =
+ new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
+
+ final Optional<CreateVnfResponse> actual =
+ objUnderTest.invokeCreateInstantiationRequest(DUMMY_GENERIC_VND_ID, CREATE_VNF_REQUEST);
+ assertFalse(actual.isPresent());
+
+ }
+
+ @Test
+ public void testInvokeDeleteRequest() {
+ when(mockedHttpServiceProvider.deleteHttpRequest(anyString(), eq(DeleteVnfResponse.class)))
+ .thenReturn(deleteVnfResponse);
+ when(deleteVnfResponse.getStatusCode()).thenReturn(HttpStatus.ACCEPTED);
+ when(deleteVnfResponse.hasBody()).thenReturn(true);
+ final DeleteVnfResponse response = getDeleteVnfResponse(DUMMY_JOB_ID);
+ when(deleteVnfResponse.getBody()).thenReturn(response);
+ final VnfmAdapterServiceProvider objUnderTest =
+ new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
+ final Optional<DeleteVnfResponse> actual = objUnderTest.invokeDeleteRequest(DUMMY_GENERIC_VND_ID);
+ assertTrue(actual.isPresent());
+ }
+
+ @Test
+ public void testInvokeDeleteRequestNotAccepted() {
+ when(mockedHttpServiceProvider.deleteHttpRequest(anyString(), eq(DeleteVnfResponse.class)))
+ .thenReturn(deleteVnfResponse);
+ when(deleteVnfResponse.getStatusCode()).thenReturn(HttpStatus.BAD_GATEWAY);
+ final VnfmAdapterServiceProvider objUnderTest =
+ new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
+ final Optional<DeleteVnfResponse> actual = objUnderTest.invokeDeleteRequest(DUMMY_GENERIC_VND_ID);
+ assertFalse(actual.isPresent());
+ }
+
+ @Test
+ public void testInvokeDeleteRequestNoBody() {
+ when(mockedHttpServiceProvider.deleteHttpRequest(anyString(), eq(DeleteVnfResponse.class)))
+ .thenReturn(deleteVnfResponse);
+ when(deleteVnfResponse.getStatusCode()).thenReturn(HttpStatus.ACCEPTED);
+ when(deleteVnfResponse.hasBody()).thenReturn(false);
+ final VnfmAdapterServiceProvider objUnderTest =
+ new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
+ final Optional<DeleteVnfResponse> actual = objUnderTest.invokeDeleteRequest(DUMMY_GENERIC_VND_ID);
+ assertFalse(actual.isPresent());
+ }
+
+ @Test
+ public void testInvokeDeleteRequestNoJobId() {
+ when(mockedHttpServiceProvider.deleteHttpRequest(anyString(), eq(DeleteVnfResponse.class)))
+ .thenReturn(deleteVnfResponse);
+ when(deleteVnfResponse.getStatusCode()).thenReturn(HttpStatus.ACCEPTED);
+ when(deleteVnfResponse.hasBody()).thenReturn(true);
+ final DeleteVnfResponse response = getDeleteVnfResponse("");
+ when(deleteVnfResponse.getBody()).thenReturn(response);
+ final VnfmAdapterServiceProvider objUnderTest =
+ new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
+ final Optional<DeleteVnfResponse> actual = objUnderTest.invokeDeleteRequest(DUMMY_GENERIC_VND_ID);
+ assertFalse(actual.isPresent());
+ }
+
+ @Test
+ public void testInvokeDeleteRequestException() {
+ when(mockedHttpServiceProvider.deleteHttpRequest(anyString(), eq(DeleteVnfResponse.class)))
+ .thenThrow(RestProcessingException.class);
+ final VnfmAdapterServiceProvider objUnderTest =
+ new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
+ final Optional<DeleteVnfResponse> actual = objUnderTest.invokeDeleteRequest(DUMMY_GENERIC_VND_ID);
+ assertFalse(actual.isPresent());
+ }
+
+ @Test
+ public void testGetInstantiateOperationJobStatus_httpServiceProviderReturnsStatusOkWithBody_validResponse() {
+
+ when(mockedQueryJobResponseResponseEntity.getStatusCode()).thenReturn(HttpStatus.OK);
+ when(mockedQueryJobResponseResponseEntity.hasBody()).thenReturn(true);
+ when(mockedQueryJobResponseResponseEntity.getBody()).thenReturn(getQueryJobResponse());
+
+ when(mockedHttpServiceProvider.getHttpResponse(eq(TestConstants.JOB_STATUS_EXPECTED_URL),
+ eq(QueryJobResponse.class))).thenReturn(mockedQueryJobResponseResponseEntity);
+
+ final VnfmAdapterServiceProvider objUnderTest =
+ new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
+
+ final Optional<QueryJobResponse> actual = objUnderTest.getInstantiateOperationJobStatus(DUMMY_JOB_ID);
+ assertTrue(actual.isPresent());
+ final QueryJobResponse actualQueryJobResponse = actual.get();
+ assertNotNull(actualQueryJobResponse);
+ }
+
+ @Test
+ public void testGetInstantiateOperationJobStatus_httpServiceProviderReturnsStatusOkWithOutBody_invalidResponse() {
+
+ when(mockedQueryJobResponseResponseEntity.getStatusCode()).thenReturn(HttpStatus.OK);
+ when(mockedQueryJobResponseResponseEntity.hasBody()).thenReturn(false);
+
+ when(mockedHttpServiceProvider.getHttpResponse(eq(TestConstants.JOB_STATUS_EXPECTED_URL),
+ eq(QueryJobResponse.class))).thenReturn(mockedQueryJobResponseResponseEntity);
+
+ final VnfmAdapterServiceProvider objUnderTest =
+ new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
+
+ final Optional<QueryJobResponse> actual = objUnderTest.getInstantiateOperationJobStatus(DUMMY_JOB_ID);
+ assertFalse(actual.isPresent());
+ }
+
+ @Test
+ public void testGetInstantiateOperationJobStatus_httpServiceProviderReturnsStatusNotOkWithOutBody_invalidResponse() {
+
+ when(mockedQueryJobResponseResponseEntity.getStatusCode()).thenReturn(HttpStatus.INTERNAL_SERVER_ERROR);
+
+ when(mockedHttpServiceProvider.getHttpResponse(eq(TestConstants.JOB_STATUS_EXPECTED_URL),
+ eq(QueryJobResponse.class))).thenReturn(mockedQueryJobResponseResponseEntity);
+
+ final VnfmAdapterServiceProvider objUnderTest =
+ new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
+
+ final Optional<QueryJobResponse> actual = objUnderTest.getInstantiateOperationJobStatus(DUMMY_JOB_ID);
+ assertFalse(actual.isPresent());
+ }
+
+ @Test
+ public void testGetInstantiateOperationJobStatus_Exception() {
+
+ when(mockedHttpServiceProvider.getHttpResponse(eq(TestConstants.JOB_STATUS_EXPECTED_URL),
+ eq(QueryJobResponse.class))).thenThrow(RestProcessingException.class);
+
+ final VnfmAdapterServiceProvider objUnderTest =
+ new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
+
+ final Optional<QueryJobResponse> actual = objUnderTest.getInstantiateOperationJobStatus(DUMMY_JOB_ID);
+ assertFalse(actual.isPresent());
+ }
+
+ private QueryJobResponse getQueryJobResponse() {
+ return new QueryJobResponse().id(DUMMY_JOB_ID).operationState(OperationStateEnum.COMPLETED);
+
+ }
+
+ private void assertWithJobId(final String jobId) {
+ when(mockedHttpServiceProvider.postHttpRequest(eq(CREATE_VNF_REQUEST), anyString(), eq(CreateVnfResponse.class)))
+ .thenReturn(mockedResponseEntity);
+ when(mockedResponseEntity.getStatusCode()).thenReturn(HttpStatus.ACCEPTED);
+ when(mockedResponseEntity.hasBody()).thenReturn(true);
+ final CreateVnfResponse response = getCreateVnfResponse(jobId);
+ when(mockedResponseEntity.getBody()).thenReturn(response);
+
+
+ final VnfmAdapterServiceProvider objUnderTest =
+ new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
+
+ final Optional<CreateVnfResponse> actual =
+ objUnderTest.invokeCreateInstantiationRequest(DUMMY_GENERIC_VND_ID, CREATE_VNF_REQUEST);
+ assertFalse(actual.isPresent());
+ }
+
+ private void assertWithStatuCode(final HttpStatus status) {
+ when(mockedHttpServiceProvider.postHttpRequest(eq(CREATE_VNF_REQUEST), anyString(), eq(CreateVnfResponse.class)))
+ .thenReturn(mockedResponseEntity);
+ when(mockedResponseEntity.getStatusCode()).thenReturn(status);
+ when(mockedResponseEntity.hasBody()).thenReturn(false);
+ final VnfmAdapterServiceProvider objUnderTest =
+ new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
+ final Optional<CreateVnfResponse> actual =
+ objUnderTest.invokeCreateInstantiationRequest(DUMMY_GENERIC_VND_ID, CREATE_VNF_REQUEST);
+ assertFalse(actual.isPresent());
+ }
- private CreateVnfResponse getCreateVnfResponse(final String jobId) {
- final CreateVnfResponse response = new CreateVnfResponse();
- response.setJobId(jobId);
- return response;
- }
+ private CreateVnfResponse getCreateVnfResponse(final String jobId) {
+ return new CreateVnfResponse().jobId(jobId);
+ }
+ private DeleteVnfResponse getDeleteVnfResponse(final String jobId) {
+ final DeleteVnfResponse response = new DeleteVnfResponse();
+ response.setJobId(jobId);
+ return response;
+ }
- private VnfmAdapterUrlProvider getVnfmAdapterUrlProvider() {
- return new VnfmAdapterUrlProvider(getVnfmBasicHttpConfigProvider());
- }
+ private VnfmAdapterUrlProvider getVnfmAdapterUrlProvider() {
+ return new VnfmAdapterUrlProvider(getVnfmBasicHttpConfigProvider());
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterUrlProviderTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterUrlProviderTest.java
index cb93adca69..133f24bbe1 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterUrlProviderTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterUrlProviderTest.java
@@ -22,11 +22,12 @@ package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks;
import static org.junit.Assert.assertEquals;
import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.TestConstants.DUMMY_GENERIC_VND_ID;
+import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.TestConstants.DUMMY_JOB_ID;
import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.TestConstants.EXPECTED_URL;
+import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.TestConstants.JOB_STATUS_EXPECTED_URL;
import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.TestConstants.getVnfmBasicHttpConfigProvider;
import org.junit.Test;
-import org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.VnfmAdapterUrlProvider;
/**
@@ -41,9 +42,16 @@ public class VnfmAdapterUrlProviderTest {
final VnfmAdapterUrlProvider objUnderTest = new VnfmAdapterUrlProvider(getVnfmBasicHttpConfigProvider());
final String actual = objUnderTest.getCreateInstantiateUrl(DUMMY_GENERIC_VND_ID);
-
assertEquals(EXPECTED_URL, actual);
}
+ @Test
+ public void testGetJobStatuUrl_returnValidCreationInstantiationRequest() {
+ final VnfmAdapterUrlProvider objUnderTest = new VnfmAdapterUrlProvider(getVnfmBasicHttpConfigProvider());
+
+ final String actual = objUnderTest.getJobStatusUrl(DUMMY_JOB_ID);
+ assertEquals(JOB_STATUS_EXPECTED_URL, actual);
+
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/SniroHomingV2IT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/SniroHomingV2IT.java
index c4129a3b96..b50cd69f73 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/SniroHomingV2IT.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/SniroHomingV2IT.java
@@ -22,7 +22,6 @@ package org.onap.so.bpmn.infrastructure.flowspecific.tasks;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -41,6 +40,7 @@ import org.json.JSONObject;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
+import org.onap.so.BaseIntegrationTest;
import org.onap.so.bpmn.servicedecomposition.bbobjects.AllottedResource;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
@@ -53,7 +53,7 @@ import org.onap.so.bpmn.servicedecomposition.homingobjects.Candidate;
import org.onap.so.bpmn.servicedecomposition.homingobjects.CandidateType;
import org.onap.so.client.exception.BadResponseException;
import org.onap.so.client.sniro.beans.SniroManagerRequest;
-import org.onap.so.BaseIntegrationTest;
+
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -117,7 +117,7 @@ public class SniroHomingV2IT extends BaseIntegrationTest{
public void testCallSniro_success_1VpnLink() throws BadResponseException, IOException{
beforeVpnBondingLink("1");
- stubFor(post(urlEqualTo("/sniro/api/placement/v2"))
+ wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2"))
.willReturn(aResponse().withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(mockResponse)));
@@ -138,7 +138,7 @@ public class SniroHomingV2IT extends BaseIntegrationTest{
beforeVpnBondingLink("2");
beforeVpnBondingLink("3");
- stubFor(post(urlEqualTo("/sniro/api/placement/v2"))
+ wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2"))
.willReturn(aResponse().withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(mockResponse)));
@@ -157,7 +157,7 @@ public class SniroHomingV2IT extends BaseIntegrationTest{
public void testCallSniro_success_3Allotteds() throws BadResponseException, JsonProcessingException{
beforeAllottedResource();
- stubFor(post(urlEqualTo("/sniro/api/placement/v2"))
+ wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2"))
.willReturn(aResponse().withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(mockResponse)));
@@ -176,7 +176,7 @@ public class SniroHomingV2IT extends BaseIntegrationTest{
public void testCallSniro_success_1Vnf() throws JsonProcessingException, BadResponseException{
beforeVnf();
- stubFor(post(urlEqualTo("/sniro/api/placement/v2"))
+ wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2"))
.willReturn(aResponse().withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(mockResponse)));
@@ -193,7 +193,7 @@ public class SniroHomingV2IT extends BaseIntegrationTest{
beforeAllottedResource();
beforeVnf();
- stubFor(post(urlEqualTo("/sniro/api/placement/v2"))
+ wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2"))
.willReturn(aResponse().withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(mockResponse)));
@@ -482,7 +482,7 @@ public class SniroHomingV2IT extends BaseIntegrationTest{
beforeAllottedResource();
mockResponse = "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"\", \"requestStatus\": \"failed\"}";
- stubFor(post(urlEqualTo("/sniro/api/placement/v2"))
+ wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2"))
.willReturn(aResponse().withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(mockResponse)));
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/NetworkAdapterClientIT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/NetworkAdapterClientIT.java
index 1bcc464fa0..fe9e1c1608 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/NetworkAdapterClientIT.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/NetworkAdapterClientIT.java
@@ -21,15 +21,17 @@
package org.onap.so.client.adapter.network;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.delete;
import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.put;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+
import javax.ws.rs.core.Response;
+
import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.so.BaseIntegrationTest;
@@ -74,7 +76,7 @@ public class NetworkAdapterClientIT extends BaseIntegrationTest{
CreateNetworkResponse mockResponse = new CreateNetworkResponse();
mockResponse.setNetworkCreated(true);
- stubFor(post(urlPathEqualTo(REST_ENDPOINT))
+ wireMockServer.stubFor(post(urlPathEqualTo(REST_ENDPOINT))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
@@ -89,7 +91,7 @@ public class NetworkAdapterClientIT extends BaseIntegrationTest{
CreateNetworkError mockResponse = new CreateNetworkError();
mockResponse.setMessage("Error in create network");
- stubFor(post(urlPathEqualTo(REST_ENDPOINT))
+ wireMockServer.stubFor(post(urlPathEqualTo(REST_ENDPOINT))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
@@ -104,7 +106,7 @@ public class NetworkAdapterClientIT extends BaseIntegrationTest{
DeleteNetworkResponse mockResponse = new DeleteNetworkResponse();
mockResponse.setNetworkDeleted(true);
- stubFor(post(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
+ wireMockServer.stubFor(delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
@@ -119,7 +121,7 @@ public class NetworkAdapterClientIT extends BaseIntegrationTest{
DeleteNetworkError mockResponse = new DeleteNetworkError();
mockResponse.setMessage("Error in delete network");
- stubFor(post(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
+ wireMockServer.stubFor(delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
@@ -136,7 +138,7 @@ public class NetworkAdapterClientIT extends BaseIntegrationTest{
RollbackNetworkResponse mockResponse = new RollbackNetworkResponse();
mockResponse.setNetworkRolledBack(true);
- stubFor(post(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
+ wireMockServer.stubFor(delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
@@ -154,7 +156,7 @@ public class NetworkAdapterClientIT extends BaseIntegrationTest{
RollbackNetworkError mockResponse = new RollbackNetworkError();
mockResponse.setMessage("Error in rollback network");
- stubFor(post(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
+ wireMockServer.stubFor(delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
@@ -166,7 +168,7 @@ public class NetworkAdapterClientIT extends BaseIntegrationTest{
QueryNetworkResponse mockResponse = new QueryNetworkResponse();
mockResponse.setNetworkExists(true);
- stubFor(get(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID)).withQueryParam("cloudSiteId", equalTo(TESTING_ID))
+ wireMockServer.stubFor(get(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID)).withQueryParam("cloudSiteId", equalTo(TESTING_ID))
.withQueryParam("tenantId", equalTo(TESTING_ID))
.withQueryParam("networkStackId", equalTo("networkStackId")).withQueryParam("skipAAI", equalTo("true"))
.withQueryParam("msoRequest.requestId", equalTo("testRequestId"))
@@ -184,7 +186,7 @@ public class NetworkAdapterClientIT extends BaseIntegrationTest{
QueryNetworkError mockResponse = new QueryNetworkError();
mockResponse.setMessage("Error in query network");
- stubFor(get(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID)).withQueryParam("cloudSiteId", equalTo(TESTING_ID))
+ wireMockServer.stubFor(get(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID)).withQueryParam("cloudSiteId", equalTo(TESTING_ID))
.withQueryParam("tenantId", equalTo(TESTING_ID))
.withQueryParam("networkStackId", equalTo("networkStackId")).withQueryParam("skipAAI", equalTo("true"))
.withQueryParam("msoRequest.requestId", equalTo("testRequestId"))
@@ -204,7 +206,7 @@ public class NetworkAdapterClientIT extends BaseIntegrationTest{
UpdateNetworkResponse mockResponse = new UpdateNetworkResponse();
mockResponse.setNetworkId("test1");
- stubFor(put(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
+ wireMockServer.stubFor(put(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
@@ -220,7 +222,7 @@ public class NetworkAdapterClientIT extends BaseIntegrationTest{
UpdateNetworkResponse mockResponse = new UpdateNetworkResponse();
mockResponse.setNetworkId("test1");
- stubFor(put(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
+ wireMockServer.stubFor(put(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
@@ -236,7 +238,7 @@ public class NetworkAdapterClientIT extends BaseIntegrationTest{
UpdateNetworkError mockResponse = new UpdateNetworkError();
mockResponse.setMessage("Error in update network");
- stubFor(put(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
+ wireMockServer.stubFor(put(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfAdapterClientIT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfAdapterClientIT.java
index 3387920d40..90e99eb0ad 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfAdapterClientIT.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfAdapterClientIT.java
@@ -21,11 +21,11 @@
package org.onap.so.client.adapter.vnf;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.delete;
import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.put;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static org.junit.Assert.assertEquals;
@@ -70,7 +70,7 @@ public class VnfAdapterClientIT extends BaseIntegrationTest{
CreateVfModuleResponse mockResponse = new CreateVfModuleResponse();
mockResponse.setVfModuleCreated(true);
- stubFor(post(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules"))
+ wireMockServer.stubFor(post(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
@@ -85,7 +85,7 @@ public class VnfAdapterClientIT extends BaseIntegrationTest{
VfModuleExceptionResponse mockResponse = new VfModuleExceptionResponse();
mockResponse.setMessage("Error in create Vf module");
- stubFor(post(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules"))
+ wireMockServer.stubFor(post(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
@@ -101,8 +101,8 @@ public class VnfAdapterClientIT extends BaseIntegrationTest{
RollbackVfModuleResponse mockResponse = new RollbackVfModuleResponse();
mockResponse.setVfModuleRolledback(true);
- stubFor(
- post(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID + "/rollback"))
+ wireMockServer.stubFor(
+ delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID + "/rollback"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
@@ -119,8 +119,8 @@ public class VnfAdapterClientIT extends BaseIntegrationTest{
VfModuleExceptionResponse mockResponse = new VfModuleExceptionResponse();
mockResponse.setMessage("Error in rollback Vf module");
- stubFor(
- post(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID + "/rollback"))
+ wireMockServer.stubFor(
+ delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID + "/rollback"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
@@ -134,7 +134,7 @@ public class VnfAdapterClientIT extends BaseIntegrationTest{
DeleteVfModuleResponse mockResponse = new DeleteVfModuleResponse();
mockResponse.setVfModuleDeleted(true);
- stubFor(post(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID))
+ wireMockServer.stubFor(delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
@@ -149,7 +149,7 @@ public class VnfAdapterClientIT extends BaseIntegrationTest{
VfModuleExceptionResponse mockResponse = new VfModuleExceptionResponse();
mockResponse.setMessage("Error in delete Vf module");
- stubFor(post(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID))
+ wireMockServer.stubFor(delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
@@ -164,7 +164,7 @@ public class VnfAdapterClientIT extends BaseIntegrationTest{
UpdateVfModuleResponse mockResponse = new UpdateVfModuleResponse();
mockResponse.setVfModuleId("test1");
- stubFor(put(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID))
+ wireMockServer.stubFor(put(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
@@ -180,7 +180,7 @@ public class VnfAdapterClientIT extends BaseIntegrationTest{
VfModuleExceptionResponse mockResponse = new VfModuleExceptionResponse();
mockResponse.setMessage("Error in update Vf module");
- stubFor(put(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID))
+ wireMockServer.stubFor(put(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
@@ -192,7 +192,7 @@ public class VnfAdapterClientIT extends BaseIntegrationTest{
QueryVfModuleResponse mockResponse = new QueryVfModuleResponse();
mockResponse.setVnfId(AAI_VNF_ID);
mockResponse.setVfModuleId(AAI_VF_MODULE_ID);
- stubFor(get(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID))
+ wireMockServer.stubFor(get(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID))
.withQueryParam("cloudSiteId", equalTo(TESTING_ID))
.withQueryParam("tenantId", equalTo(TESTING_ID))
.withQueryParam("vfModuleName", equalTo("someName"))
@@ -210,7 +210,7 @@ public class VnfAdapterClientIT extends BaseIntegrationTest{
public void queryVfModuleTestThrowException() throws JsonProcessingException, VnfAdapterClientException {
VfModuleExceptionResponse mockResponse = new VfModuleExceptionResponse();
mockResponse.setMessage("Error in update Vf module");
- stubFor(get(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID))
+ wireMockServer.stubFor(get(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID))
.withQueryParam("cloudSiteId", equalTo(TESTING_ID))
.withQueryParam("tenantId", equalTo(TESTING_ID))
.withQueryParam("vfModuleName", equalTo("someName"))
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterClientIT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterClientIT.java
index 40b6498034..4a006f8b66 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterClientIT.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterClientIT.java
@@ -44,8 +44,6 @@ import org.onap.so.adapters.vnfrest.UpdateVolumeGroupResponse;
import org.onap.so.client.adapter.rest.AdapterRestClient;
import org.onap.so.BaseIntegrationTest;
-
-@RunWith(MockitoJUnitRunner.Silent.class)
public class VnfVolumeAdapterClientIT extends BaseIntegrationTest{
private static final String TESTING_ID = "___TESTING___";
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingClientTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingClientTest.java
index d6f8c70aa1..4bae5b40e4 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingClientTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingClientTest.java
@@ -23,7 +23,6 @@ package org.onap.so.client.namingservice;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.delete;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static org.junit.Assert.assertTrue;
@@ -55,7 +54,7 @@ public class NamingClientTest extends BaseIntegrationTest{
@Test
public void assignNameGenRequest() throws BadResponseException, IOException{
- stubFor(post(urlPathEqualTo("/web/service/v1/genNetworkElementName"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/web/service/v1/genNetworkElementName"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBodyFile("NamingClient/AssignResponse.json")
.withStatus(HttpStatus.SC_ACCEPTED)));
@@ -66,7 +65,7 @@ public class NamingClientTest extends BaseIntegrationTest{
}
@Test
public void assignNameGenRequestError() throws BadResponseException, IOException{
- stubFor(post(urlPathEqualTo("/web/service/v1/genNetworkElementName"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/web/service/v1/genNetworkElementName"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBodyFile("NamingClient/ErrorResponse.json")
.withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
@@ -78,7 +77,7 @@ public class NamingClientTest extends BaseIntegrationTest{
}
@Test
public void unassignNameGenRequest() throws BadResponseException, IOException{
- stubFor(delete(urlPathEqualTo("/web/service/v1/genNetworkElementName"))
+ wireMockServer.stubFor(delete(urlPathEqualTo("/web/service/v1/genNetworkElementName"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBodyFile("NamingClient/UnassignResponse.json")
.withStatus(HttpStatus.SC_ACCEPTED)));
@@ -88,7 +87,7 @@ public class NamingClientTest extends BaseIntegrationTest{
}
@Test
public void unassignNameGenRequestError() throws BadResponseException, IOException{
- stubFor(delete(urlPathEqualTo("/web/service/v1/genNetworkElementName"))
+ wireMockServer.stubFor(delete(urlPathEqualTo("/web/service/v1/genNetworkElementName"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBodyFile("NamingClient/ErrorResponse.json")
.withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/oof/OofClientTestIT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/oof/OofClientTestIT.java
index 0b33b1d187..05ba512c9d 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/oof/OofClientTestIT.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/oof/OofClientTestIT.java
@@ -22,7 +22,6 @@ package org.onap.so.client.oof;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import org.junit.Test;
@@ -44,7 +43,7 @@ public class OofClientTestIT extends BaseIntegrationTest {
public void testPostDemands_success() throws BadResponseException, JsonProcessingException {
String mockResponse = "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"status\", \"requestStatus\": \"accepted\"}";
- stubFor(post(urlEqualTo("/api/oof/v1/placement"))
+ wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement"))
.willReturn(aResponse().withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(mockResponse)));
@@ -56,7 +55,7 @@ public class OofClientTestIT extends BaseIntegrationTest {
public void testAsyncResponse_success() throws BadResponseException, JsonProcessingException {
String mockResponse = "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"status\", \"requestStatus\": \"accepted\"}";
- stubFor(post(urlEqualTo("/api/oof/v1/placement"))
+ wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement"))
.willReturn(aResponse().withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(mockResponse)));
@@ -68,7 +67,7 @@ public class OofClientTestIT extends BaseIntegrationTest {
public void testPostDemands_error_failed() throws JsonProcessingException, BadResponseException {
String mockResponse = "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"missing data\", \"requestStatus\": \"failed\"}";
- stubFor(post(urlEqualTo("/api/oof/v1/placement"))
+ wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement"))
.willReturn(aResponse().withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(mockResponse)));
@@ -84,7 +83,7 @@ public class OofClientTestIT extends BaseIntegrationTest {
public void testPostDemands_error_noMessage() throws JsonProcessingException, BadResponseException {
String mockResponse = "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"\", \"requestStatus\": \"failed\"}";
- stubFor(post(urlEqualTo("/api/oof/v1/placement"))
+ wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement"))
.willReturn(aResponse().withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(mockResponse)));
@@ -98,7 +97,7 @@ public class OofClientTestIT extends BaseIntegrationTest {
public void testPostDemands_error_noStatus() throws JsonProcessingException, BadResponseException {
String mockResponse = "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"missing data\", \"requestStatus\": null}";
- stubFor(post(urlEqualTo("/api/oof/v1/placement"))
+ wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement"))
.willReturn(aResponse().withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(mockResponse)));
@@ -112,7 +111,7 @@ public class OofClientTestIT extends BaseIntegrationTest {
public void testPostDemands_error_empty() throws JsonProcessingException, BadResponseException {
String mockResponse = "{ }";
- stubFor(post(urlEqualTo("/api/oof/v1/placement"))
+ wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement"))
.willReturn(aResponse().withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(mockResponse)));
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientIT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientIT.java
index 9117b8ea64..70f196db8c 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientIT.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientIT.java
@@ -23,7 +23,6 @@ package org.onap.so.client.sdnc;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
@@ -46,7 +45,7 @@ public class SDNCClientIT extends BaseIntegrationTest {
String responseJson = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "SDNCClientGetResponse.json")));
String queryLink = "/topologyQuery";
- stubFor(get(urlEqualTo(queryLink))
+ wireMockServer.stubFor(get(urlEqualTo(queryLink))
.willReturn(aResponse().withStatus(200)
.withHeader("Content-Type", "application/json").withBody(responseJson)));
String response = SPY_sdncClient.get(queryLink);
@@ -59,7 +58,7 @@ public class SDNCClientIT extends BaseIntegrationTest {
String queryLink = "/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation/";
- stubFor(post(urlMatching(queryLink))
+ wireMockServer.stubFor(post(urlMatching(queryLink))
.willReturn(aResponse().withStatus(200)
.withHeader("Content-Type", "application/json").withBody(responseJson)));
@@ -72,7 +71,7 @@ public class SDNCClientIT extends BaseIntegrationTest {
String queryLink = "/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation/";
- stubFor(post(urlMatching(queryLink))
+ wireMockServer.stubFor(post(urlMatching(queryLink))
.willReturn(aResponse().withStatus(200)
.withHeader("Content-Type", "application/json").withBody(responseJson)));
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapperTest.java
index 0ca80c75f7..302bb551c3 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapperTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapperTest.java
@@ -75,6 +75,7 @@ public class GCTopologyOperationRequestMapperTest extends TestDataSetup {
Assert.assertEquals("VLAN-NETWORK-RECEPTOR", genericInfo.getConfigurationInformation().getConfigurationType());
Assert.assertEquals("uuid",genericInfo.getSdncRequestHeader().getSvcRequestId());
Assert.assertEquals("http://localhost",genericInfo.getSdncRequestHeader().getSvcNotificationUrl());
+ Assert.assertEquals("MsoRequestId",genericInfo.getRequestInformation().getRequestId());
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapperTest.java
index 6a14f8b567..1bfa78ad6d 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapperTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapperTest.java
@@ -23,6 +23,7 @@ package org.onap.so.client.sdnc.mapper;
import static com.shazam.shazamcrest.MatcherAssert.assertThat;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import java.io.IOException;
@@ -109,6 +110,7 @@ public class NetworkTopologyOperationRequestMapperTest {
userParams.put("key1", "value1");
requestContext.setUserParams(userParams);
requestContext.setProductFamilyId("productFamilyId");
+ requestContext.setMsoRequestId("MsoRequestId");
network = new L3Network();
network.setNetworkId("TEST_NETWORK_ID");
@@ -138,8 +140,24 @@ public class NetworkTopologyOperationRequestMapperTest {
assertThat(networkSDNCrequest, sameBeanAs(reqMapper1).ignoring("sdncRequestHeader.svcRequestId")
.ignoring("requestInformation.requestId"));
+ assertEquals("MsoRequestId", networkSDNCrequest.getRequestInformation().getRequestId());
}
+
+ @Test
+ public void createGenericResourceApiNetworkOperationInformationReqContextNullTest() throws Exception {
+ RequestContext rc = new RequestContext();
+ rc.setMsoRequestId(null);
+ GenericResourceApiNetworkOperationInformation networkSDNCrequest = mapper.reqMapper(
+ SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, customer,
+ rc, cloudRegion);
+ assertNotNull(networkSDNCrequest.getRequestInformation().getRequestId());
+ GenericResourceApiNetworkOperationInformation networkSDNCrequest2 = mapper.reqMapper(
+ SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, customer,
+ null, cloudRegion);
+ assertNotNull(networkSDNCrequest2.getRequestInformation().getRequestId());
+ }
+
@Test
public void reqMapperTest() throws Exception {
@@ -175,7 +193,8 @@ public class NetworkTopologyOperationRequestMapperTest {
assertThat(reqMapperUnassign, sameBeanAs(networkSDNCrequestUnassign).ignoring("sdncRequestHeader.svcRequestId")
.ignoring("requestInformation.requestId"));
-
+ assertEquals("MsoRequestId", networkSDNCrequestUnassign.getRequestInformation().getRequestId());
+
}
@Test
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapperTest.java
index 0bf06a0bb0..1919ef437b 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapperTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapperTest.java
@@ -22,6 +22,8 @@ package org.onap.so.client.sdnc.mapper;
import static com.shazam.shazamcrest.MatcherAssert.assertThat;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import java.nio.file.Files;
import java.nio.file.Paths;
@@ -80,10 +82,14 @@ public class ServiceTopologyOperationMapperTest {
userParams.put("key1", "value1");
requestContext.setUserParams(userParams);
requestContext.setProductFamilyId("productFamilyId");
+ requestContext.setMsoRequestId("MsoRequestId");
GenericResourceApiServiceOperationInformation serviceOpInformation = mapper.reqMapper(
SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE, serviceInstance, customer,
requestContext);
+ GenericResourceApiServiceOperationInformation serviceOpInformationNullReqContext = mapper.reqMapper(
+ SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE, serviceInstance, customer,
+ null);
String jsonToCompare = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/BuildingBlocks/genericResourceApiEcompModelInformation.json")));
@@ -92,5 +98,7 @@ public class ServiceTopologyOperationMapperTest {
GenericResourceApiOnapmodelinformationOnapModelInformation.class);
assertThat(reqMapper1, sameBeanAs(serviceOpInformation.getServiceInformation().getOnapModelInformation()));
+ assertEquals("MsoRequestId", serviceOpInformation.getRequestInformation().getRequestId());
+ assertNotNull(serviceOpInformationNullReqContext.getRequestInformation().getRequestId());
}
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java
index 282f23caa7..7fce8c48c8 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java
@@ -23,6 +23,7 @@ package org.onap.so.client.sdnc.mapper;
import static com.shazam.shazamcrest.MatcherAssert.assertThat;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import java.nio.file.Files;
@@ -102,6 +103,7 @@ public class VfModuleTopologyOperationRequestMapperTest {
RequestParameters requestParameters = new RequestParameters();
requestParameters.setUsePreload(true);
requestContext.setRequestParameters(requestParameters);
+ requestContext.setMsoRequestId("MsoRequestId");
GenericVnf vnf = new GenericVnf();
vnf.setVnfId("testVnfId");
@@ -148,6 +150,7 @@ public class VfModuleTopologyOperationRequestMapperTest {
assertThat(reqMapper1, sameBeanAs(vfModuleSDNCrequest).ignoring("sdncRequestHeader.svcRequestId")
.ignoring("requestInformation.requestId"));
+ assertEquals("MsoRequestId", vfModuleSDNCrequest.getRequestInformation().getRequestId());
}
@Test
@@ -168,10 +171,13 @@ public class VfModuleTopologyOperationRequestMapperTest {
VfModule vfModule = new VfModule();
vfModule.setVfModuleId("testVfModuleId");
vfModule.setVfModuleName("testVfModuleName");
+
+ RequestContext requestContext = new RequestContext();
+ requestContext.setMsoRequestId("MsoRequestId");
GenericResourceApiVfModuleOperationInformation vfModuleSDNCrequest = mapper.reqMapper(
SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN, vfModule, null, vnf, serviceInstance, null,
- null, null, null);
+ null, requestContext, null);
String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleOperationInformationUnassign.json")));
@@ -182,6 +188,35 @@ public class VfModuleTopologyOperationRequestMapperTest {
assertThat(reqMapper1, sameBeanAs(vfModuleSDNCrequest).ignoring("sdncRequestHeader.svcRequestId")
.ignoring("requestInformation.requestId"));
+ assertEquals("MsoRequestId", vfModuleSDNCrequest.getRequestInformation().getRequestId());
+ }
+
+ @Test
+ public void unassignGenericResourceApiVfModuleInformationNullMsoReqIdTest() throws Exception {
+
+ // prepare and set service instance
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+
+ // prepare and set vnf instance
+
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("testVnfId");
+ vnf.setVnfType("testVnfType");
+
+ // prepare and set vf module instance
+
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("testVfModuleId");
+ vfModule.setVfModuleName("testVfModuleName");
+
+ RequestContext requestContext = new RequestContext();
+
+ GenericResourceApiVfModuleOperationInformation vfModuleSDNCrequest = mapper.reqMapper(
+ SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN, vfModule, null, vnf, serviceInstance, null,
+ null, requestContext, null);
+
+ assertNotNull(vfModuleSDNCrequest.getRequestInformation().getRequestId());
}
@Test
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java
index 229a8cf601..64b532fd07 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java
@@ -21,6 +21,7 @@
package org.onap.so.client.sdnc.mapper;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import java.util.ArrayList;
@@ -122,12 +123,16 @@ public class VnfTopologyOperationRequestMapperTest {
userParams.put("key1", "value1");
requestContext.setUserParams(userParams);
requestContext.setProductFamilyId("productFamilyId");
+ requestContext.setMsoRequestId("MsoRequestId");
CloudRegion cloudRegion = new CloudRegion();
GenericResourceApiVnfOperationInformation vnfOpInformation = mapper.reqMapper(
SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer,
cloudRegion, requestContext,true);
+ GenericResourceApiVnfOperationInformation vnfOpInformationNullReqContext = mapper.reqMapper(
+ SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer,
+ cloudRegion, null,true);
assertNull(vnfOpInformation.getServiceInformation().getOnapModelInformation().getModelCustomizationUuid());
assertEquals("vnfModelCustomizationUUID", vnfOpInformation.getVnfInformation().getOnapModelInformation().getModelCustomizationUuid());
@@ -136,5 +141,7 @@ public class VnfTopologyOperationRequestMapperTest {
assertEquals("l3-network-ig-222", vnfOpInformation.getVnfRequestInput().getVnfNetworkInstanceGroupIds().get(1).getVnfNetworkInstanceGroupId());
assertEquals("entitlementPoolUuid", vnfOpInformation.getVnfRequestInput().getVnfInputParameters().getParam().get(1).getValue());
assertEquals("licenseKeyGroupUuid", vnfOpInformation.getVnfRequestInput().getVnfInputParameters().getParam().get(2).getValue());
+ assertEquals("MsoRequestId", vnfOpInformation.getRequestInformation().getRequestId());
+ assertNotNull(vnfOpInformationNullReqContext.getRequestInformation().getRequestId());
}
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sniro/SniroClientTestIT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sniro/SniroClientTestIT.java
index 3387e9ddef..722180f54b 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sniro/SniroClientTestIT.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sniro/SniroClientTestIT.java
@@ -22,7 +22,6 @@ package org.onap.so.client.sniro;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import org.junit.Test;
@@ -45,7 +44,7 @@ public class SniroClientTestIT extends BaseIntegrationTest {
public void testPostDemands_success() throws BadResponseException, JsonProcessingException {
String mockResponse = "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"corys cool\", \"requestStatus\": \"accepted\"}";
- stubFor(post(urlEqualTo("/sniro/api/placement/v2"))
+ wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2"))
.willReturn(aResponse().withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(mockResponse)));
@@ -58,7 +57,7 @@ public class SniroClientTestIT extends BaseIntegrationTest {
public void testPostDemands_error_failed() throws JsonProcessingException, BadResponseException {
String mockResponse = "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"missing data\", \"requestStatus\": \"failed\"}";
- stubFor(post(urlEqualTo("/sniro/api/placement/v2"))
+ wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2"))
.willReturn(aResponse().withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(mockResponse)));
@@ -74,7 +73,7 @@ public class SniroClientTestIT extends BaseIntegrationTest {
public void testPostDemands_error_noMessage() throws JsonProcessingException, BadResponseException {
String mockResponse = "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"\", \"requestStatus\": \"failed\"}";
- stubFor(post(urlEqualTo("/sniro/api/placement/v2"))
+ wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2"))
.willReturn(aResponse().withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(mockResponse)));
@@ -88,7 +87,7 @@ public class SniroClientTestIT extends BaseIntegrationTest {
public void testPostDemands_error_noStatus() throws JsonProcessingException, BadResponseException {
String mockResponse = "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"missing data\", \"requestStatus\": null}";
- stubFor(post(urlEqualTo("/sniro/api/placement/v2"))
+ wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2"))
.willReturn(aResponse().withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(mockResponse)));
@@ -102,7 +101,7 @@ public class SniroClientTestIT extends BaseIntegrationTest {
public void testPostDemands_error_empty() throws JsonProcessingException, BadResponseException {
String mockResponse = "{ }";
- stubFor(post(urlEqualTo("/sniro/api/placement/v2"))
+ wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2"))
.willReturn(aResponse().withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(mockResponse)));
@@ -115,7 +114,7 @@ public class SniroClientTestIT extends BaseIntegrationTest {
public void testPostRelease_success() throws BadResponseException, JsonProcessingException {
String mockResponse = "{\"status\": \"success\", \"message\": \"corys cool\"}";
- stubFor(post(urlEqualTo("/v1/release-orders"))
+ wireMockServer.stubFor(post(urlEqualTo("/v1/release-orders"))
.willReturn(aResponse().withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(mockResponse)));
@@ -127,7 +126,7 @@ public class SniroClientTestIT extends BaseIntegrationTest {
public void testPostRelease_error_failed() throws BadResponseException, JsonProcessingException {
String mockResponse = "{\"status\": \"failure\", \"message\": \"corys cool\"}";
- stubFor(post(urlEqualTo("/v1/release-orders"))
+ wireMockServer.stubFor(post(urlEqualTo("/v1/release-orders"))
.willReturn(aResponse().withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(mockResponse)));
@@ -139,7 +138,7 @@ public class SniroClientTestIT extends BaseIntegrationTest {
public void testPostRelease_error_noStatus() throws BadResponseException, JsonProcessingException {
String mockResponse = "{\"status\": \"\", \"message\": \"corys cool\"}";
- stubFor(post(urlEqualTo("/v1/release-orders"))
+ wireMockServer.stubFor(post(urlEqualTo("/v1/release-orders"))
.willReturn(aResponse().withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(mockResponse)));
@@ -152,7 +151,7 @@ public class SniroClientTestIT extends BaseIntegrationTest {
public void testPostRelease_error_noMessage() throws BadResponseException, JsonProcessingException {
String mockResponse = "{\"status\": \"failure\", \"message\": null}";
- stubFor(post(urlEqualTo("/v1/release-orders"))
+ wireMockServer.stubFor(post(urlEqualTo("/v1/release-orders"))
.willReturn(aResponse().withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(mockResponse)));
@@ -165,7 +164,7 @@ public class SniroClientTestIT extends BaseIntegrationTest {
public void testPostRelease_error_empty() throws BadResponseException, JsonProcessingException {
String mockResponse = "{ }";
- stubFor(post(urlEqualTo("/v1/release-orders"))
+ wireMockServer.stubFor(post(urlEqualTo("/v1/release-orders"))
.willReturn(aResponse().withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(mockResponse)));
diff --git a/common/src/main/java/org/onap/so/client/RestRequest.java b/common/src/main/java/org/onap/so/client/RestRequest.java
index 6f0d71cabf..3864f2e5cc 100644
--- a/common/src/main/java/org/onap/so/client/RestRequest.java
+++ b/common/src/main/java/org/onap/so/client/RestRequest.java
@@ -25,6 +25,7 @@ package org.onap.so.client;
import java.util.Optional;
import java.util.concurrent.Callable;
+import javax.ws.rs.HttpMethod;
import javax.ws.rs.NotFoundException;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
@@ -60,8 +61,8 @@ public class RestRequest implements Callable<Response> {
response = this.client.getBuilder().accept(this.client.getAccept()).delete();
} else {
- response = this.client.getBuilder().header("X-HTTP-Method-Override", "DELETE").accept(this.client.getAccept())
- .post(Entity.entity(entity, this.client.getContentType()));
+ response = this.client.getBuilder().accept(this.client.getAccept())
+ .build(HttpMethod.DELETE, Entity.entity(entity, this.client.getContentType())).invoke();
}
} else if ("PUT".equals(method)) {
response = this.client.getBuilder().accept(this.client.getAccept()).put(Entity.entity(entity, this.client.getContentType()));
diff --git a/common/src/main/java/org/onap/so/rest/service/HttpRestServiceProvider.java b/common/src/main/java/org/onap/so/rest/service/HttpRestServiceProvider.java
index 7fb5adcb5b..a3d16175bc 100644
--- a/common/src/main/java/org/onap/so/rest/service/HttpRestServiceProvider.java
+++ b/common/src/main/java/org/onap/so/rest/service/HttpRestServiceProvider.java
@@ -87,5 +87,14 @@ public interface HttpRestServiceProvider {
*/
<T> ResponseEntity<T> putHttpRequest(final Object object, final String url, final Class<T> clazz);
+ /**
+ * Execute the HTTP DELETE to the given URI template
+ *
+ * @param url the URL
+ * @param clazz the type of the return value
+ * @return Returns the {@link ResponseEntity}.
+ */
+ public <T> ResponseEntity<T> deleteHttpRequest(final String url, final Class<T> clazz);
+
}
diff --git a/common/src/main/java/org/onap/so/rest/service/HttpRestServiceProviderImpl.java b/common/src/main/java/org/onap/so/rest/service/HttpRestServiceProviderImpl.java
index d3cc1747a3..029431c86e 100644
--- a/common/src/main/java/org/onap/so/rest/service/HttpRestServiceProviderImpl.java
+++ b/common/src/main/java/org/onap/so/rest/service/HttpRestServiceProviderImpl.java
@@ -133,6 +133,18 @@ public class HttpRestServiceProviderImpl implements HttpRestServiceProvider {
}
}
+ @Override
+ public <T> ResponseEntity<T> deleteHttpRequest(final String url, final Class<T> clazz) {
+ try {
+ final HttpEntity<?> request = new HttpEntity<>(getHttpHeaders());
+ return restTemplate.exchange(url, HttpMethod.DELETE, request, clazz);
+
+ } catch (final RestClientException restClientException) {
+ LOGGER.error("Unable to invoke HTTP DELETE using url: " + url, restClientException);
+ throw new InvalidRestRequestException("Unable to invoke HTTP DELETE using URL: " + url, restClientException);
+ }
+ }
+
private HttpHeaders getHttpHeaders() {
return httpHeadersProvider.getHttpHeaders();
}
diff --git a/common/src/test/java/org/onap/so/client/HttpClientTest.java b/common/src/test/java/org/onap/so/client/HttpClientTest.java
index 75ce5f322f..346bf1426d 100644
--- a/common/src/test/java/org/onap/so/client/HttpClientTest.java
+++ b/common/src/test/java/org/onap/so/client/HttpClientTest.java
@@ -25,18 +25,19 @@ import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
import static com.github.tomakehurst.wiremock.client.WireMock.exactly;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static com.github.tomakehurst.wiremock.client.WireMock.verify;
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
-import com.github.tomakehurst.wiremock.junit.WireMockRule;
import java.net.MalformedURLException;
import java.net.URL;
+
import org.junit.Rule;
import org.junit.Test;
import org.onap.so.utils.TargetEntity;
+import com.github.tomakehurst.wiremock.junit.WireMockRule;
+
public class HttpClientTest{
@@ -47,7 +48,7 @@ public class HttpClientTest{
@Test
public void testPost_success() throws MalformedURLException{
- stubFor(post(urlEqualTo("/services/sdnc/post"))
+ wireMockRule.stubFor(post(urlEqualTo("/services/sdnc/post"))
.willReturn(aResponse().withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody("")));
@@ -66,7 +67,7 @@ public class HttpClientTest{
@Test
public void testPost_nullHeader() throws MalformedURLException{
- stubFor(post(urlEqualTo("/services/sdnc/post"))
+ wireMockRule.stubFor(post(urlEqualTo("/services/sdnc/post"))
.willReturn(aResponse().withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody("")));
@@ -86,7 +87,7 @@ public class HttpClientTest{
@Test
public void testPost_nullBasicAuth() throws MalformedURLException{
- stubFor(post(urlEqualTo("/services/sdnc/post"))
+ wireMockRule.stubFor(post(urlEqualTo("/services/sdnc/post"))
.willReturn(aResponse().withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody("")));
diff --git a/common/src/test/java/org/onap/so/client/aai/AAIConfigurationClientTest.java b/common/src/test/java/org/onap/so/client/aai/AAIConfigurationClientTest.java
index f30d2e17aa..525dff7562 100644
--- a/common/src/test/java/org/onap/so/client/aai/AAIConfigurationClientTest.java
+++ b/common/src/test/java/org/onap/so/client/aai/AAIConfigurationClientTest.java
@@ -20,10 +20,6 @@
package org.onap.so.client.aai;
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
-import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doNothing;
@@ -34,7 +30,6 @@ import static org.mockito.Mockito.verify;
import java.util.Optional;
import java.util.UUID;
-import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
@@ -42,18 +37,12 @@ import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.client.aai.entities.Configuration;
import org.onap.so.client.aai.entities.uri.AAIResourceUri;
-import org.onap.so.client.aai.entities.uri.AAIUri;
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.serviceinstancebeans.ModelInfo;
import org.onap.so.serviceinstancebeans.RequestDetails;
-
-import com.github.tomakehurst.wiremock.junit.WireMockRule;
@RunWith(MockitoJUnitRunner.class)
public class AAIConfigurationClientTest {
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().port(8443));
-
@Mock
AAIResourcesClient aaiClient;
@@ -163,18 +152,4 @@ public class AAIConfigurationClientTest {
AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, uuid);
assertEquals(uri, aaiConfigurationClient.getConfigurationURI(uuid));
}
-
- @Test
- public void verifyNotExists() {
- AAIUri path = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, "test2");
- wireMockRule.stubFor(get(
- urlMatching("/aai/v[0-9]+" + path.build() + ".*"))
- .willReturn(
- aResponse()
- .withHeader("Content-Type", "text/plain")
- .withBody("hello")
- .withStatus(404)));
- boolean result = aaiConfigurationClient.configurationExists("test2");
- assertEquals("path not found", false, result);
- }
}
diff --git a/common/src/test/java/org/onap/so/client/aai/AAIResourcesClientTest.java b/common/src/test/java/org/onap/so/client/aai/AAIResourcesClientTest.java
index 174c76b1ef..c63d602bca 100644
--- a/common/src/test/java/org/onap/so/client/aai/AAIResourcesClientTest.java
+++ b/common/src/test/java/org/onap/so/client/aai/AAIResourcesClientTest.java
@@ -150,7 +150,7 @@ public class AAIResourcesClientTest {
AAIResourceUri path = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test2");
AAIResourceUri path2 = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test3");
- wireMockRule.stubFor(post(
+ wireMockRule.stubFor(delete(
urlPathEqualTo("/aai/" + AAIVersion.LATEST + path.build() + "/relationship-list/relationship"))
.willReturn(
aResponse()
diff --git a/common/src/test/java/org/onap/so/client/aai/AAIResourcesClientWithServiceInstanceUriTest.java b/common/src/test/java/org/onap/so/client/aai/AAIResourcesClientWithServiceInstanceUriTest.java
index 5493d6778e..46e4c98b3e 100644
--- a/common/src/test/java/org/onap/so/client/aai/AAIResourcesClientWithServiceInstanceUriTest.java
+++ b/common/src/test/java/org/onap/so/client/aai/AAIResourcesClientWithServiceInstanceUriTest.java
@@ -55,7 +55,7 @@ import com.github.tomakehurst.wiremock.junit.WireMockRule;
public class AAIResourcesClientWithServiceInstanceUriTest {
@Rule
- public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().port(8443));
+ public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort());
@Rule
public ExpectedException thrown = ExpectedException.none();
@@ -69,8 +69,7 @@ public class AAIResourcesClientWithServiceInstanceUriTest {
private ServiceInstanceUri uri;
@Before
public void setUp() {
-
- doReturn(new DefaultAAIPropertiesImpl()).when(client).getRestProperties();
+ doReturn(new DefaultAAIPropertiesImpl(wireMockRule.port())).when(client).getRestProperties();
wireMockRule.stubFor(get(urlMatching("/aai/v[0-9]+/nodes.*"))
.willReturn(aResponse()
.withStatus(404)
diff --git a/common/src/test/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUriTest.java b/common/src/test/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUriTest.java
index 979ca39489..c369767e38 100644
--- a/common/src/test/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUriTest.java
+++ b/common/src/test/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUriTest.java
@@ -22,7 +22,6 @@ package org.onap.so.client.aai.entities.uri;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching;
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -197,7 +196,7 @@ public class ServiceInstanceUriTest {
ServiceInstanceUri spy = spy(instance);
AAIResourcesClient client = aaiClient;
doReturn(client).when(spy).getResourcesClient();
- stubFor(get(urlPathMatching("/aai/v[0-9]+/nodes/service-instances/service-instance/key3"))
+ wireMockRule.stubFor(get(urlPathMatching("/aai/v[0-9]+/nodes/service-instances/service-instance/key3"))
.willReturn(aResponse()
.withStatus(404)
.withHeader("Content-Type", "application/json")
diff --git a/mso-api-handlers/mso-api-handler-infra/pom.xml b/mso-api-handlers/mso-api-handler-infra/pom.xml
index 16dfa68244..1359a7f9db 100644
--- a/mso-api-handlers/mso-api-handler-infra/pom.xml
+++ b/mso-api-handlers/mso-api-handler-infra/pom.xml
@@ -233,6 +233,7 @@
<includes>
<include>**/AllTestsTestSuite.java</include>
</includes>
+ <parallel>suites</parallel>
</configuration>
</execution>
</executions>
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java
new file mode 100644
index 0000000000..1580c9fb34
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java
@@ -0,0 +1,206 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.apache.http.HttpStatus;
+import org.onap.so.apihandler.common.ErrorNumbers;
+import org.onap.so.apihandler.common.RequestClientParameter;
+import org.onap.so.apihandlerinfra.exceptions.ApiException;
+import org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException;
+import org.onap.so.apihandlerinfra.exceptions.ValidateException;
+import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.client.RequestsDbClient;
+import org.onap.so.exceptions.ValidationException;
+import org.onap.so.logger.ErrorCode;
+import org.onap.so.logger.MessageEnum;
+import org.onap.so.serviceinstancebeans.ModelType;
+import org.onap.so.serviceinstancebeans.RequestReferences;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import javax.transaction.Transactional;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.io.IOException;
+import java.util.HashMap;
+
+@Component
+@Path("/onap/so/infra/instanceManagement")
+@Api(value="/onap/so/infra/instanceManagement",description="Infrastructure API Requests for Instance Management")
+public class InstanceManagement {
+
+ private static Logger logger = LoggerFactory.getLogger(InstanceManagement.class);
+ private static String uriPrefix = "/instanceManagement/";
+ private static final String SAVE_TO_DB = "save instance to db";
+
+ @Autowired
+ private RequestsDbClient infraActiveRequestsClient;
+
+ @Autowired
+ private MsoRequest msoRequest;
+
+ @Autowired
+ private RequestHandlerUtils requestHandlerUtils;
+
+ @POST
+ @Path("/{version:[vV][1]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/workflows/{workflowUuid}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Execute custom workflow",response=Response.class)
+ @Transactional
+ public Response executeCustomWorkflow(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
+ @PathParam("vnfInstanceId") String vnfInstanceId, @PathParam("workflowUuid") String workflowUuid, @Context ContainerRequestContext requestContext) throws ApiException {
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put("serviceInstanceId", serviceInstanceId);
+ instanceIdMap.put("vnfInstanceId", vnfInstanceId);
+ instanceIdMap.put("workflowUuid", workflowUuid);
+ return processCustomWorkflowRequest(request, Action.inPlaceSoftwareUpdate, instanceIdMap, version, requestId, requestContext);
+ }
+
+ private Response processCustomWorkflowRequest(String requestJSON, Actions action, HashMap<String, String> instanceIdMap, String version, String requestId, ContainerRequestContext requestContext) throws ApiException {
+ String serviceInstanceId = null;
+ if (instanceIdMap != null) {
+ serviceInstanceId = instanceIdMap.get("serviceInstanceId");
+ }
+ Boolean aLaCarte = true;
+ long startTime = System.currentTimeMillis ();
+ ServiceInstancesRequest sir = null;
+ String apiVersion = version.substring(1);
+
+ String requestUri = requestHandlerUtils.getRequestUri(requestContext, uriPrefix);
+
+ sir = requestHandlerUtils.convertJsonToServiceInstanceRequest(requestJSON, action, startTime, sir, msoRequest, requestId, requestUri);
+ String requestScope = requestHandlerUtils.deriveRequestScope(action, sir, requestUri);
+ InfraActiveRequests currentActiveReq = msoRequest.createRequestObject (sir, action, requestId, Status.IN_PROGRESS, requestJSON, requestScope);
+
+ try {
+ requestHandlerUtils.validateHeaders(requestContext);
+ } catch (ValidationException e) {
+ logger.error("Exception occurred", e);
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_VALIDATION_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ ValidateException validateException = new ValidateException.Builder(e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
+ .errorInfo(errorLoggerInfo).build();
+ requestHandlerUtils.updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
+ throw validateException;
+ }
+
+ requestHandlerUtils.parseRequest(sir, instanceIdMap, action, version, requestJSON, aLaCarte, requestId, currentActiveReq);
+ requestHandlerUtils.setInstanceId(currentActiveReq, requestScope, null, instanceIdMap);
+
+ int requestVersion = Integer.parseInt(version.substring(1));
+ String vnfType = msoRequest.getVnfType(sir,requestScope,action,requestVersion);
+
+ if(requestScope.equalsIgnoreCase(ModelType.vnf.name()) && vnfType != null){
+ currentActiveReq.setVnfType(vnfType);
+ }
+
+ InfraActiveRequests dup = null;
+ boolean inProgress = false;
+
+ dup = requestHandlerUtils.duplicateCheck(action, instanceIdMap, startTime, msoRequest, null, requestScope, currentActiveReq);
+
+ if(dup != null){
+ inProgress = requestHandlerUtils.camundaHistoryCheck(dup, currentActiveReq);
+ }
+
+ if (dup != null && inProgress) {
+ requestHandlerUtils.buildErrorOnDuplicateRecord(currentActiveReq, action, instanceIdMap, startTime, msoRequest, null, requestScope, dup);
+ }
+ ServiceInstancesResponse serviceResponse = new ServiceInstancesResponse();
+
+ RequestReferences referencesResponse = new RequestReferences();
+
+ referencesResponse.setRequestId(requestId);
+
+ serviceResponse.setRequestReferences(referencesResponse);
+ Boolean isBaseVfModule = false;
+
+ String workflowUuid = null;
+ if (instanceIdMap !=null) {
+ workflowUuid = instanceIdMap.get("workflowUuid");
+ }
+
+ RecipeLookupResult recipeLookupResult = getCustomWorkflowUri(workflowUuid);
+ String serviceInstanceType = requestHandlerUtils.getServiceType(requestScope, sir, true);
+
+ serviceInstanceId = requestHandlerUtils.setServiceInstanceId(requestScope, sir);
+ String vnfId = "";
+
+ if(sir.getVnfInstanceId () != null){
+ vnfId = sir.getVnfInstanceId ();
+ }
+
+ try{
+ infraActiveRequestsClient.save(currentActiveReq);
+ }catch(Exception e){
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ throw new RequestDbFailureException.Builder(SAVE_TO_DB, e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e)
+ .errorInfo(errorLoggerInfo).build();
+ }
+
+ RequestClientParameter requestClientParameter = null;
+ try {
+ requestClientParameter = new RequestClientParameter.Builder()
+ .setRequestId(requestId)
+ .setBaseVfModule(isBaseVfModule)
+ .setRecipeTimeout(recipeLookupResult.getRecipeTimeout())
+ .setRequestAction(action.toString())
+ .setServiceInstanceId(serviceInstanceId)
+ .setVnfId(vnfId)
+ .setServiceType(serviceInstanceType)
+ .setVnfType(vnfType)
+ .setRequestDetails(requestHandlerUtils.mapJSONtoMSOStyle(requestJSON, sir, aLaCarte, action))
+ .setApiVersion(apiVersion)
+ .setALaCarte(aLaCarte)
+ .setRequestUri(requestUri)
+ .build();
+ } catch (IOException e) {
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ throw new ValidateException.Builder("Unable to generate RequestClientParamter object" + e.getMessage(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER)
+ .errorInfo(errorLoggerInfo).build();
+ }
+ return requestHandlerUtils.postBPELRequest(currentActiveReq, requestClientParameter, recipeLookupResult.getOrchestrationURI(), requestScope);
+ }
+
+ private RecipeLookupResult getCustomWorkflowUri(String workflowUuid) {
+
+ RecipeLookupResult recipeLookupResult = new RecipeLookupResult("/mso/async/services/VnfInPlaceUpdate", 180);
+ return recipeLookupResult;
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java
index 5790f1afe9..434b9e9364 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java
@@ -63,6 +63,7 @@ public class JerseyConfiguration extends ResourceConfig {
register(RequestUriFilter.class);
register(E2EServiceInstances.class);
register(WorkflowSpecificationsHandler.class);
+ register(InstanceManagement.class);
// this registration seems to be needed to get predictable
// execution behavior for the above JSON Exception Mappers
register(com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider.class);
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java
index de7d26379c..dc8e6b6958 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java
@@ -50,6 +50,7 @@ import org.onap.so.apihandlerinfra.validation.MembersValidation;
import org.onap.so.apihandlerinfra.validation.ApplyUpdatedConfigValidation;
import org.onap.so.apihandlerinfra.validation.CloudConfigurationValidation;
import org.onap.so.apihandlerinfra.validation.ConfigurationParametersValidation;
+import org.onap.so.apihandlerinfra.validation.CustomWorkflowValidation;
import org.onap.so.apihandlerinfra.validation.InPlaceSoftwareUpdateValidation;
import org.onap.so.apihandlerinfra.validation.InstanceIdMapValidation;
import org.onap.so.apihandlerinfra.validation.ModelInfoValidation;
@@ -175,7 +176,14 @@ public class MsoRequest {
rules.add(new InstanceIdMapValidation());
- if(reqVersion >= 6 && action == Action.inPlaceSoftwareUpdate){
+ String workflowUuid = null;
+ if (instanceIdMap != null) {
+ workflowUuid = instanceIdMap.get("workflowUuid");
+ }
+
+ if (workflowUuid != null) {
+ rules.add(new CustomWorkflowValidation());
+ }else if(reqVersion >= 6 && action == Action.inPlaceSoftwareUpdate){
rules.add(new InPlaceSoftwareUpdateValidation());
}else if(reqVersion >= 6 && action == Action.applyUpdatedConfig){
rules.add(new ApplyUpdatedConfigValidation());
@@ -361,7 +369,9 @@ public class MsoRequest {
aq.setInstanceGroupName(requestInfo.getInstanceName());
}
if(ModelType.vnf.name().equalsIgnoreCase(requestScope)){
- aq.setVnfName(requestInfo.getInstanceName());
+ if (requestInfo != null) {
+ aq.setVnfName(requestInfo.getInstanceName());
+ }
if (null != servInsReq.getRequestDetails()) {
RelatedInstanceList[] instanceList = servInsReq.getRequestDetails().getRelatedInstanceList();
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java
new file mode 100644
index 0000000000..c02b40aeca
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java
@@ -0,0 +1,567 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra;
+
+
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
+import org.camunda.bpm.engine.history.HistoricProcessInstance;
+import org.camunda.bpm.engine.impl.persistence.entity.HistoricProcessInstanceEntity;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.onap.so.apihandler.camundabeans.CamundaResponse;
+import org.onap.so.apihandler.common.CommonConstants;
+import org.onap.so.apihandler.common.ErrorNumbers;
+import org.onap.so.apihandler.common.RequestClient;
+import org.onap.so.apihandler.common.RequestClientFactory;
+import org.onap.so.apihandler.common.RequestClientParameter;
+import org.onap.so.apihandler.common.ResponseBuilder;
+import org.onap.so.apihandler.common.ResponseHandler;
+import org.onap.so.apihandlerinfra.exceptions.ApiException;
+import org.onap.so.apihandlerinfra.exceptions.BPMNFailureException;
+import org.onap.so.apihandlerinfra.exceptions.ClientConnectionException;
+import org.onap.so.apihandlerinfra.exceptions.ContactCamundaException;
+import org.onap.so.apihandlerinfra.exceptions.DuplicateRequestException;
+import org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException;
+import org.onap.so.apihandlerinfra.exceptions.ValidateException;
+import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
+import org.onap.so.db.catalog.client.CatalogDbClient;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.client.RequestsDbClient;
+import org.onap.so.exceptions.ValidationException;
+import org.onap.so.logger.ErrorCode;
+import org.onap.so.logger.LogConstants;
+import org.onap.so.logger.MessageEnum;
+import org.onap.so.serviceinstancebeans.ModelType;
+import org.onap.so.serviceinstancebeans.RelatedInstance;
+import org.onap.so.serviceinstancebeans.RelatedInstanceList;
+import org.onap.so.serviceinstancebeans.RequestParameters;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
+import org.onap.so.utils.CryptoUtils;
+import org.onap.so.utils.UUIDChecker;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.ParameterizedTypeReference;
+import org.springframework.core.env.Environment;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Component;
+import org.springframework.web.client.HttpStatusCodeException;
+import org.springframework.web.client.RestTemplate;
+
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
+import javax.xml.bind.DatatypeConverter;
+
+import static org.onap.so.logger.HttpHeadersConstants.REQUESTOR_ID;
+
+import java.io.IOException;
+import java.net.URL;
+import java.security.GeneralSecurityException;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+@Component
+public class RequestHandlerUtils {
+
+ private static Logger logger = LoggerFactory.getLogger(RequestHandlerUtils.class);
+
+ private static final String SAVE_TO_DB = "save instance to db";
+
+ @Autowired
+ private Environment env;
+
+ @Autowired
+ private RequestClientFactory reqClientFactory;
+
+ @Autowired
+ private RequestsDbClient infraActiveRequestsClient;
+
+ @Autowired
+ private ResponseBuilder builder;
+
+ @Autowired
+ private MsoRequest msoRequest;
+
+ @Autowired
+ private RestTemplate restTemplate;
+
+ @Autowired
+ private CatalogDbClient catalogDbClient;
+
+ public Response postBPELRequest(InfraActiveRequests currentActiveReq, RequestClientParameter requestClientParameter, String orchestrationUri, String requestScope)throws ApiException {
+ RequestClient requestClient = null;
+ HttpResponse response = null;
+ try {
+ requestClient = reqClientFactory.getRequestClient (orchestrationUri);
+ response = requestClient.post(requestClientParameter);
+ } catch (Exception e) {
+
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, ErrorCode.AvailabilityError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ String url = requestClient != null ? requestClient.getUrl() : "";
+ ClientConnectionException clientException = new ClientConnectionException.Builder(url, HttpStatus.SC_BAD_GATEWAY, ErrorNumbers.SVC_NO_SERVER_RESOURCES).cause(e).errorInfo(errorLoggerInfo).build();
+ updateStatus(currentActiveReq, Status.FAILED, clientException.getMessage());
+
+ throw clientException;
+ }
+
+ if (response == null) {
+
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, ErrorCode.BusinessProcesssError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ ClientConnectionException clientException = new ClientConnectionException.Builder(requestClient.getUrl(), HttpStatus.SC_BAD_GATEWAY, ErrorNumbers.SVC_NO_SERVER_RESOURCES).errorInfo(errorLoggerInfo).build();
+
+ updateStatus(currentActiveReq, Status.FAILED, clientException.getMessage());
+
+ throw clientException;
+ }
+
+ ResponseHandler respHandler = null;
+ int bpelStatus = 500;
+ try {
+ respHandler = new ResponseHandler (response, requestClient.getType ());
+ bpelStatus = respHandler.getStatus ();
+ } catch (ApiException e) {
+ logger.error("Exception occurred", e);
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ ValidateException validateException = new ValidateException.Builder("Exception caught mapping Camunda JSON response to object", HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
+ .errorInfo(errorLoggerInfo).build();
+ updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
+ throw validateException;
+ }
+
+ // BPEL accepted the request, the request is in progress
+ if (bpelStatus == HttpStatus.SC_ACCEPTED) {
+ ServiceInstancesResponse jsonResponse;
+ CamundaResponse camundaResp = respHandler.getResponse();
+
+ if("Success".equalsIgnoreCase(camundaResp.getMessage())) {
+ try {
+ ObjectMapper mapper = new ObjectMapper();
+ jsonResponse = mapper.readValue(camundaResp.getResponse(), ServiceInstancesResponse.class);
+ jsonResponse.getRequestReferences().setRequestId(requestClientParameter.getRequestId());
+ Optional<URL> selfLinkUrl = msoRequest.buildSelfLinkUrl(currentActiveReq.getRequestUrl(), requestClientParameter.getRequestId());
+ if(selfLinkUrl.isPresent()){
+ jsonResponse.getRequestReferences().setRequestSelfLink(selfLinkUrl.get());
+ } else {
+ jsonResponse.getRequestReferences().setRequestSelfLink(null);
+ }
+ } catch (IOException e) {
+ logger.error("Exception occurred", e);
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ ValidateException validateException = new ValidateException.Builder("Exception caught mapping Camunda JSON response to object", HttpStatus.SC_NOT_ACCEPTABLE, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
+ .errorInfo(errorLoggerInfo).build();
+ updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
+ throw validateException;
+ }
+ return builder.buildResponse(HttpStatus.SC_ACCEPTED, requestClientParameter.getRequestId(), jsonResponse, requestClientParameter.getApiVersion());
+ }
+ }
+
+ List<String> variables = new ArrayList<>();
+ variables.add(bpelStatus + "");
+ String camundaJSONResponseBody = respHandler.getResponseBody ();
+ if (camundaJSONResponseBody != null && !camundaJSONResponseBody.isEmpty ()) {
+
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.BusinessProcesssError).errorSource(requestClient.getUrl()).build();
+ BPMNFailureException bpmnException = new BPMNFailureException.Builder(String.valueOf(bpelStatus) + camundaJSONResponseBody, bpelStatus, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR)
+ .errorInfo(errorLoggerInfo).build();
+
+ updateStatus(currentActiveReq, Status.FAILED, bpmnException.getMessage());
+
+ throw bpmnException;
+ } else {
+
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.BusinessProcesssError).errorSource(requestClient.getUrl()).build();
+
+
+ BPMNFailureException servException = new BPMNFailureException.Builder(String.valueOf(bpelStatus), bpelStatus, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR)
+ .errorInfo(errorLoggerInfo).build();
+ updateStatus(currentActiveReq, Status.FAILED, servException.getMessage());
+
+ throw servException;
+ }
+ }
+
+ public void updateStatus(InfraActiveRequests aq, Status status, String errorMessage) throws RequestDbFailureException{
+ if ((status == Status.FAILED) || (status == Status.COMPLETE)) {
+ aq.setStatusMessage (errorMessage);
+ aq.setProgress(new Long(100));
+ aq.setRequestStatus(status.toString());
+ Timestamp endTimeStamp = new Timestamp (System.currentTimeMillis());
+ aq.setEndTime (endTimeStamp);
+ try{
+ infraActiveRequestsClient.save(aq);
+ }catch(Exception e){
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ throw new RequestDbFailureException.Builder(SAVE_TO_DB, e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e)
+ .errorInfo(errorLoggerInfo).build();
+ }
+ }
+ }
+
+ public String deriveRequestScope(Actions action, ServiceInstancesRequest sir, String requestUri) {
+ if(action == Action.inPlaceSoftwareUpdate || action == Action.applyUpdatedConfig){
+ return (ModelType.vnf.name());
+ }else if(action == Action.addMembers || action == Action.removeMembers){
+ return(ModelType.instanceGroup.toString());
+ }else{
+ String requestScope;
+ if(sir.getRequestDetails().getModelInfo().getModelType() == null){
+ requestScope = requestScopeFromUri(requestUri);
+ }else{
+ requestScope = sir.getRequestDetails().getModelInfo().getModelType().name();
+ }
+ return requestScope;
+ }
+ }
+
+
+ public void validateHeaders(ContainerRequestContext context) throws ValidationException{
+ MultivaluedMap<String, String> headers = context.getHeaders();
+ if(!headers.containsKey(ONAPLogConstants.Headers.REQUEST_ID)){
+ throw new ValidationException(ONAPLogConstants.Headers.REQUEST_ID + " header", true);
+ }
+ if(!headers.containsKey(ONAPLogConstants.Headers.PARTNER_NAME)){
+ throw new ValidationException(ONAPLogConstants.Headers.PARTNER_NAME + " header", true);
+ }
+ if(!headers.containsKey(REQUESTOR_ID)){
+ throw new ValidationException(REQUESTOR_ID + " header", true);
+ }
+ }
+
+ public String getRequestUri(ContainerRequestContext context, String uriPrefix){
+ String requestUri = context.getUriInfo().getPath();
+ String httpUrl = MDC.get(LogConstants.URI_BASE).concat(requestUri);
+ MDC.put(LogConstants.HTTP_URL, httpUrl);
+ requestUri = requestUri.substring(requestUri.indexOf(uriPrefix) + uriPrefix.length());
+ return requestUri;
+ }
+
+ public InfraActiveRequests duplicateCheck(Actions action, HashMap<String, String> instanceIdMap, long startTime,
+ MsoRequest msoRequest, String instanceName, String requestScope, InfraActiveRequests currentActiveReq) throws ApiException {
+ InfraActiveRequests dup = null;
+ try {
+ if(!(instanceName==null && requestScope.equals("service") && (action == Action.createInstance || action == Action.activateInstance || action == Action.assignInstance))){
+ dup = infraActiveRequestsClient.checkInstanceNameDuplicate (instanceIdMap, instanceName, requestScope);
+ }
+ } catch (Exception e) {
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DUPLICATE_CHECK_EXC, ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ RequestDbFailureException requestDbFailureException = new RequestDbFailureException.Builder("check for duplicate instance", e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e)
+ .errorInfo(errorLoggerInfo).build();
+ updateStatus(currentActiveReq, Status.FAILED, requestDbFailureException.getMessage());
+ throw requestDbFailureException;
+ }
+ return dup;
+ }
+
+ public boolean camundaHistoryCheck(InfraActiveRequests duplicateRecord, InfraActiveRequests currentActiveReq) throws RequestDbFailureException, ContactCamundaException{
+ String requestId = duplicateRecord.getRequestId();
+ String path = env.getProperty("mso.camunda.rest.history.uri") + requestId;
+ String targetUrl = env.getProperty("mso.camundaURL") + path;
+ HttpHeaders headers = setCamundaHeaders(env.getRequiredProperty("mso.camundaAuth"), env.getRequiredProperty("mso.msoKey"));
+ HttpEntity<?> requestEntity = new HttpEntity<>(headers);
+ ResponseEntity<List<HistoricProcessInstanceEntity>> response = null;
+ try{
+ response = restTemplate.exchange(targetUrl, HttpMethod.GET, requestEntity, new ParameterizedTypeReference<List<HistoricProcessInstanceEntity>>(){});
+ }catch(HttpStatusCodeException e){
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DUPLICATE_CHECK_EXC, ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ ContactCamundaException contactCamundaException= new ContactCamundaException.Builder(requestId, e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e)
+ .errorInfo(errorLoggerInfo).build();
+ updateStatus(currentActiveReq, Status.FAILED, contactCamundaException.getMessage());
+ throw contactCamundaException;
+ }
+ if(response.getBody().isEmpty()){
+ updateStatus(duplicateRecord, Status.COMPLETE, "Request Completed");
+ }
+ for(HistoricProcessInstance instance : response.getBody()){
+ if(instance.getState().equals("ACTIVE")){
+ return true;
+ }else{
+ updateStatus(duplicateRecord, Status.COMPLETE, "Request Completed");
+ }
+ }
+ return false;
+ }
+
+ protected HttpHeaders setCamundaHeaders(String auth, String msoKey) {
+ HttpHeaders headers = new HttpHeaders();
+ List<org.springframework.http.MediaType> acceptableMediaTypes = new ArrayList<>();
+ acceptableMediaTypes.add(org.springframework.http.MediaType.APPLICATION_JSON);
+ headers.setAccept(acceptableMediaTypes);
+ try {
+ String userCredentials = CryptoUtils.decrypt(auth, msoKey);
+ if(userCredentials != null) {
+ headers.add(HttpHeaders.AUTHORIZATION, "Basic " + DatatypeConverter.printBase64Binary(userCredentials.getBytes()));
+ }
+ } catch(GeneralSecurityException e) {
+ logger.error("Security exception", e);
+ }
+ return headers;
+ }
+
+ public ServiceInstancesRequest convertJsonToServiceInstanceRequest(String requestJSON, Actions action, long startTime,
+ ServiceInstancesRequest sir, MsoRequest msoRequest, String requestId, String requestUri) throws ApiException {
+ try{
+ ObjectMapper mapper = new ObjectMapper();
+ return mapper.readValue(requestJSON, ServiceInstancesRequest.class);
+
+ } catch (IOException e) {
+
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+
+ ValidateException validateException = new ValidateException.Builder("Error mapping request: " + e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
+ .errorInfo(errorLoggerInfo).build();
+ String requestScope = requestScopeFromUri(requestUri);
+
+ msoRequest.createErrorRequestRecord(Status.FAILED, requestId, validateException.getMessage(), action, requestScope, requestJSON);
+
+ throw validateException;
+ }
+ }
+
+ public void parseRequest(ServiceInstancesRequest sir, HashMap<String, String> instanceIdMap, Actions action, String version,
+ String requestJSON, Boolean aLaCarte, String requestId, InfraActiveRequests currentActiveReq) throws ValidateException, RequestDbFailureException {
+ int reqVersion = Integer.parseInt(version.substring(1));
+ try {
+ msoRequest.parse(sir, instanceIdMap, action, version, requestJSON, reqVersion, aLaCarte);
+ } catch (Exception e) {
+ logger.error("failed to parse request", e);
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ ValidateException validateException = new ValidateException.Builder("Error parsing request: " + e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
+ .errorInfo(errorLoggerInfo).build();
+
+ updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
+
+ throw validateException;
+ }
+ }
+
+ public void buildErrorOnDuplicateRecord(InfraActiveRequests currentActiveReq, Actions action, HashMap<String, String> instanceIdMap, long startTime, MsoRequest msoRequest,
+ String instanceName, String requestScope, InfraActiveRequests dup) throws ApiException {
+
+ String instance = null;
+ if(instanceName != null){
+ instance = instanceName;
+ }else{
+ instance = instanceIdMap.get(requestScope + "InstanceId");
+ }
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DUPLICATE_FOUND, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+
+ DuplicateRequestException dupException = new DuplicateRequestException.Builder(requestScope,instance,dup.getRequestStatus(),dup.getRequestId(), HttpStatus.SC_CONFLICT, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR)
+ .errorInfo(errorLoggerInfo).build();
+
+ updateStatus(currentActiveReq, Status.FAILED, dupException.getMessage());
+
+ throw dupException;
+ }
+
+ public String getRequestId(ContainerRequestContext requestContext) throws ValidateException {
+ String requestId = null;
+ if (requestContext.getProperty("requestId") != null) {
+ requestId = requestContext.getProperty("requestId").toString();
+ }
+ if (UUIDChecker.isValidUUID(requestId)) {
+ return requestId;
+ } else {
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ ValidateException validateException = new ValidateException.Builder("Request Id " + requestId + " is not a valid UUID", HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER)
+ .errorInfo(errorLoggerInfo).build();
+
+ throw validateException;
+ }
+ }
+
+ public void setInstanceId(InfraActiveRequests currentActiveReq, String requestScope, String instanceId, Map<String, String> instanceIdMap) {
+ if(StringUtils.isNotBlank(instanceId)) {
+ if(ModelType.service.name().equalsIgnoreCase(requestScope)) {
+ currentActiveReq.setServiceInstanceId(instanceId);
+ } else if(ModelType.vnf.name().equalsIgnoreCase(requestScope)) {
+ currentActiveReq.setVnfId(instanceId);
+ } else if(ModelType.vfModule.name().equalsIgnoreCase(requestScope)) {
+ currentActiveReq.setVfModuleId(instanceId);
+ } else if(ModelType.volumeGroup.name().equalsIgnoreCase(requestScope)) {
+ currentActiveReq.setVolumeGroupId(instanceId);
+ } else if(ModelType.network.name().equalsIgnoreCase(requestScope)) {
+ currentActiveReq.setNetworkId(instanceId);
+ } else if(ModelType.configuration.name().equalsIgnoreCase(requestScope)) {
+ currentActiveReq.setConfigurationId(instanceId);
+ }else if(ModelType.instanceGroup.toString().equalsIgnoreCase(requestScope)){
+ currentActiveReq.setInstanceGroupId(instanceId);
+ }
+ } else if(instanceIdMap != null && !instanceIdMap.isEmpty()) {
+ if(instanceIdMap.get("serviceInstanceId") != null){
+ currentActiveReq.setServiceInstanceId(instanceIdMap.get("serviceInstanceId"));
+ }
+ if(instanceIdMap.get("vnfInstanceId") != null){
+ currentActiveReq.setVnfId(instanceIdMap.get("vnfInstanceId"));
+ }
+ if(instanceIdMap.get("vfModuleInstanceId") != null){
+ currentActiveReq.setVfModuleId(instanceIdMap.get("vfModuleInstanceId"));
+ }
+ if(instanceIdMap.get("volumeGroupInstanceId") != null){
+ currentActiveReq.setVolumeGroupId(instanceIdMap.get("volumeGroupInstanceId"));
+ }
+ if(instanceIdMap.get("networkInstanceId") != null){
+ currentActiveReq.setNetworkId(instanceIdMap.get("networkInstanceId"));
+ }
+ if(instanceIdMap.get("configurationInstanceId") != null){
+ currentActiveReq.setConfigurationId(instanceIdMap.get("configurationInstanceId"));
+ }
+ if(instanceIdMap.get(CommonConstants.INSTANCE_GROUP_INSTANCE_ID) != null){
+ currentActiveReq.setInstanceGroupId(instanceIdMap.get(CommonConstants.INSTANCE_GROUP_INSTANCE_ID));
+ }
+ }
+ }
+
+ public String mapJSONtoMSOStyle(String msoRawRequest, ServiceInstancesRequest serviceInstRequest, boolean isAlaCarte, Actions action) throws IOException {
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.setSerializationInclusion(Include.NON_NULL);
+ if(msoRawRequest != null){
+ ServiceInstancesRequest sir = mapper.readValue(msoRawRequest, ServiceInstancesRequest.class);
+ if( serviceInstRequest != null &&
+ serviceInstRequest.getRequestDetails() != null &&
+ serviceInstRequest.getRequestDetails().getRequestParameters() != null) {
+ if( !isAlaCarte && Action.createInstance.equals(action)) {
+ sir.getRequestDetails().setCloudConfiguration(serviceInstRequest.getRequestDetails().getCloudConfiguration());
+ sir.getRequestDetails().getRequestParameters().setUserParams(serviceInstRequest.getRequestDetails().getRequestParameters().getUserParams());
+ }
+ sir.getRequestDetails().getRequestParameters().setUsePreload(serviceInstRequest.getRequestDetails().getRequestParameters().getUsePreload());
+ }
+
+ logger.debug("Value as string: {}", mapper.writeValueAsString(sir));
+ return mapper.writeValueAsString(sir);
+ }
+ return null;
+ }
+
+ public Optional<String> retrieveModelName(RequestParameters requestParams) {
+ String requestTestApi = null;
+ TestApi testApi = null;
+
+ if (requestParams != null) {
+ requestTestApi = requestParams.getTestApi();
+ }
+
+ if (requestTestApi == null) {
+ if(requestParams != null && requestParams.getALaCarte() != null && !requestParams.getALaCarte()) {
+ requestTestApi = env.getProperty(CommonConstants.MACRO_TEST_API);
+ } else {
+ requestTestApi = env.getProperty(CommonConstants.ALACARTE_TEST_API);
+ }
+ }
+
+ try {
+ testApi = TestApi.valueOf(requestTestApi);
+ return Optional.of(testApi.getModelName());
+ } catch (Exception e) {
+ logger.warn("Catching the exception on the valueOf enum call and continuing", e);
+ throw new IllegalArgumentException("Invalid TestApi is provided", e);
+ }
+ }
+
+ public String getDefaultModel(ServiceInstancesRequest sir) {
+ String defaultModel = sir.getRequestDetails().getRequestInfo().getSource() + "_DEFAULT";
+ Optional<String> oModelName = retrieveModelName(sir.getRequestDetails().getRequestParameters());
+ if (oModelName.isPresent()) {
+ defaultModel = oModelName.get();
+ }
+ return defaultModel;
+ }
+
+ public String getServiceType(String requestScope, ServiceInstancesRequest sir, Boolean aLaCarteFlag){
+ String serviceType = null;
+ if(requestScope.equalsIgnoreCase(ModelType.service.toString())){
+ String defaultServiceModelName = getDefaultModel(sir);
+ org.onap.so.db.catalog.beans.Service serviceRecord;
+ if(aLaCarteFlag){
+ serviceRecord = catalogDbClient.getFirstByModelNameOrderByModelVersionDesc(defaultServiceModelName);
+ if(serviceRecord != null){
+ serviceType = serviceRecord.getServiceType();
+ }
+ }else{
+ serviceRecord = catalogDbClient.getServiceByID(sir.getRequestDetails().getModelInfo().getModelVersionId());
+ if(serviceRecord != null){
+ serviceType = serviceRecord.getServiceType();
+ }else{
+ serviceRecord = catalogDbClient.getFirstByModelNameOrderByModelVersionDesc(defaultServiceModelName);
+ if(serviceRecord != null){
+ serviceType = serviceRecord.getServiceType();
+ }
+ }
+ }
+ }else{
+ serviceType = msoRequest.getServiceInstanceType(sir, requestScope);
+ }
+ return serviceType;
+ }
+
+ protected String setServiceInstanceId(String requestScope, ServiceInstancesRequest sir){
+ if(sir.getServiceInstanceId () != null){
+ return sir.getServiceInstanceId ();
+ }else if(requestScope.equalsIgnoreCase(ModelType.instanceGroup.toString())){
+ RelatedInstanceList[] relatedInstances = sir.getRequestDetails().getRelatedInstanceList();
+ if(relatedInstances != null){
+ for(RelatedInstanceList relatedInstanceList : relatedInstances){
+ RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance();
+ if(relatedInstance.getModelInfo().getModelType() == ModelType.service){
+ return relatedInstance.getInstanceId();
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ private String requestScopeFromUri(String requestUri){
+ String requestScope;
+ if(requestUri.contains(ModelType.network.name())){
+ requestScope = ModelType.network.name();
+ }else if(requestUri.contains(ModelType.vfModule.name())){
+ requestScope = ModelType.vfModule.name();
+ }else if(requestUri.contains(ModelType.volumeGroup.name())){
+ requestScope = ModelType.volumeGroup.name();
+ }else if(requestUri.contains(ModelType.configuration.name())){
+ requestScope = ModelType.configuration.name();
+ }else if(requestUri.contains(ModelType.vnf.name())){
+ requestScope = ModelType.vnf.name();
+ }else{
+ requestScope = ModelType.service.name();
+ }
+ return requestScope;
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
index 8c5904fb21..c6a45d540c 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
@@ -23,8 +23,6 @@
package org.onap.so.apihandlerinfra;
-
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonMappingException;
@@ -32,22 +30,11 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang.StringUtils;
-import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
-import org.onap.logging.ref.slf4j.ONAPLogConstants;
-import org.onap.so.apihandler.camundabeans.CamundaResponse;
import org.onap.so.apihandler.common.CommonConstants;
import org.onap.so.apihandler.common.ErrorNumbers;
-import org.onap.so.apihandler.common.RequestClient;
-import org.onap.so.apihandler.common.RequestClientFactory;
import org.onap.so.apihandler.common.RequestClientParameter;
-import org.onap.so.apihandler.common.ResponseBuilder;
-import org.onap.so.apihandler.common.ResponseHandler;
import org.onap.so.apihandlerinfra.exceptions.ApiException;
-import org.onap.so.apihandlerinfra.exceptions.BPMNFailureException;
-import org.onap.so.apihandlerinfra.exceptions.ClientConnectionException;
-import org.onap.so.apihandlerinfra.exceptions.ContactCamundaException;
-import org.onap.so.apihandlerinfra.exceptions.DuplicateRequestException;
import org.onap.so.apihandlerinfra.exceptions.RecipeNotFoundException;
import org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException;
import org.onap.so.apihandlerinfra.exceptions.ValidateException;
@@ -67,7 +54,6 @@ import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.db.request.client.RequestsDbClient;
import org.onap.so.exceptions.ValidationException;
import org.onap.so.logger.ErrorCode;
-import org.onap.so.logger.LogConstants;
import org.onap.so.logger.MessageEnum;
import org.onap.so.serviceinstancebeans.CloudConfiguration;
import org.onap.so.serviceinstancebeans.ModelInfo;
@@ -83,23 +69,11 @@ import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
import org.onap.so.serviceinstancebeans.VfModules;
import org.onap.so.serviceinstancebeans.Vnfs;
-import org.onap.so.utils.CryptoUtils;
-import org.onap.so.utils.UUIDChecker;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.core.ParameterizedTypeReference;
import org.springframework.core.env.Environment;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
-import org.springframework.web.client.HttpStatusCodeException;
-import org.springframework.web.client.RestTemplate;
-import org.camunda.bpm.engine.history.HistoricProcessInstance;
-import org.camunda.bpm.engine.impl.persistence.entity.HistoricProcessInstanceEntity;
import javax.transaction.Transactional;
import javax.ws.rs.Consumes;
@@ -112,21 +86,14 @@ import javax.ws.rs.Produces;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
-import javax.xml.bind.DatatypeConverter;
import java.io.IOException;
-import java.net.URL;
-import java.security.GeneralSecurityException;
-import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
-import static org.onap.so.logger.HttpHeadersConstants.REQUESTOR_ID;
-
@Component
@Path("/onap/so/infra/serviceInstantiation")
@Api(value="/onap/so/infra/serviceInstantiation",description="Infrastructure API Requests for Service Instances")
@@ -135,28 +102,23 @@ public class ServiceInstances {
private static Logger logger = LoggerFactory.getLogger(MsoRequest.class);
private static String NAME = "name";
private static String VALUE = "value";
+ private static String uriPrefix = "/serviceInstantiation/";
private static final String SAVE_TO_DB = "save instance to db";
@Autowired
private Environment env;
@Autowired
- private RequestClientFactory reqClientFactory;
-
- @Autowired
private CatalogDbClient catalogDbClient;
@Autowired
private RequestsDbClient infraActiveRequestsClient;
@Autowired
- private ResponseBuilder builder;
-
- @Autowired
private MsoRequest msoRequest;
@Autowired
- private RestTemplate restTemplate;
+ private RequestHandlerUtils requestHandlerUtils;
@POST
@Path("/{version:[vV][5-7]}/serviceInstances")
@@ -165,8 +127,8 @@ public class ServiceInstances {
@ApiOperation(value="Create a Service Instance on a version provided",response=Response.class)
@Transactional
public Response createServiceInstance(String request, @PathParam("version") String version, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
- return serviceInstances(request, Action.createInstance, null, version, requestId, getRequestUri(requestContext));
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
+ return serviceInstances(request, Action.createInstance, null, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@POST
@@ -176,10 +138,10 @@ public class ServiceInstances {
@ApiOperation(value="Activate provided Service Instance",response=Response.class)
@Transactional
public Response activateServiceInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
- return serviceInstances(request, Action.activateInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return serviceInstances(request, Action.activateInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@POST
@@ -189,10 +151,10 @@ public class ServiceInstances {
@ApiOperation(value="Deactivate provided Service Instance",response=Response.class)
@Transactional
public Response deactivateServiceInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
- return serviceInstances(request, Action.deactivateInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return serviceInstances(request, Action.deactivateInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@DELETE
@@ -202,10 +164,10 @@ public class ServiceInstances {
@ApiOperation(value="Delete provided Service Instance",response=Response.class)
@Transactional
public Response deleteServiceInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
- return serviceInstances(request, Action.deleteInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return serviceInstances(request, Action.deleteInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@POST
@@ -215,8 +177,8 @@ public class ServiceInstances {
@ApiOperation(value="Assign Service Instance", response=Response.class)
@Transactional
public Response assignServiceInstance(String request, @PathParam("version") String version, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
- return serviceInstances(request, Action.assignInstance, null, version, requestId, getRequestUri(requestContext));
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
+ return serviceInstances(request, Action.assignInstance, null, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@POST
@@ -226,10 +188,10 @@ public class ServiceInstances {
@ApiOperation(value="Unassign Service Instance", response=Response.class)
@Transactional
public Response unassignServiceInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<String,String>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
- return serviceInstances(request, Action.unassignInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return serviceInstances(request, Action.unassignInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@POST
@@ -239,10 +201,10 @@ public class ServiceInstances {
@ApiOperation(value="Create Port Mirroring Configuration",response=Response.class)
@Transactional
public Response createPortConfiguration(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
- return configurationRecipeLookup(request, Action.createInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return configurationRecipeLookup(request, Action.createInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@DELETE
@@ -253,11 +215,11 @@ public class ServiceInstances {
@Transactional
public Response deletePortConfiguration(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
@PathParam("configurationInstanceId") String configurationInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("configurationInstanceId", configurationInstanceId);
- return configurationRecipeLookup(request, Action.deleteInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return configurationRecipeLookup(request, Action.deleteInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@POST
@@ -268,11 +230,11 @@ public class ServiceInstances {
@Transactional
public Response enablePort(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
@PathParam("configurationInstanceId") String configurationInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("configurationInstanceId", configurationInstanceId);
- return configurationRecipeLookup(request, Action.enablePort, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return configurationRecipeLookup(request, Action.enablePort, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@POST
@@ -283,11 +245,11 @@ public class ServiceInstances {
@Transactional
public Response disablePort(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
@PathParam("configurationInstanceId") String configurationInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("configurationInstanceId", configurationInstanceId);
- return configurationRecipeLookup(request, Action.disablePort, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return configurationRecipeLookup(request, Action.disablePort, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@POST
@@ -298,11 +260,11 @@ public class ServiceInstances {
@Transactional
public Response activatePort(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
@PathParam("configurationInstanceId") String configurationInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("configurationInstanceId", configurationInstanceId);
- return configurationRecipeLookup(request, Action.activateInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return configurationRecipeLookup(request, Action.activateInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@POST
@@ -313,11 +275,11 @@ public class ServiceInstances {
@Transactional
public Response deactivatePort(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
@PathParam("configurationInstanceId") String configurationInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("configurationInstanceId", configurationInstanceId);
- return configurationRecipeLookup(request, Action.deactivateInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return configurationRecipeLookup(request, Action.deactivateInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@POST
@@ -327,10 +289,10 @@ public class ServiceInstances {
@ApiOperation(value="Add Relationships to a Service Instance",response=Response.class)
@Transactional
public Response addRelationships(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
- return configurationRecipeLookup(request, Action.addRelationships, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return configurationRecipeLookup(request, Action.addRelationships, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@POST
@@ -340,10 +302,10 @@ public class ServiceInstances {
@ApiOperation(value="Remove Relationships from Service Instance",response=Response.class)
@Transactional
public Response removeRelationships(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
- return configurationRecipeLookup(request, Action.removeRelationships, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return configurationRecipeLookup(request, Action.removeRelationships, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@POST
@@ -353,10 +315,10 @@ public class ServiceInstances {
@ApiOperation(value="Create VNF on a specified version and serviceInstance",response=Response.class)
@Transactional
public Response createVnfInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
- return serviceInstances(request, Action.createInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return serviceInstances(request, Action.createInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@POST
@@ -367,11 +329,11 @@ public class ServiceInstances {
@Transactional
public Response replaceVnfInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
@PathParam("vnfInstanceId") String vnfInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("vnfInstanceId", vnfInstanceId);
- return serviceInstances(request, Action.replaceInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return serviceInstances(request, Action.replaceInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@PUT
@@ -382,11 +344,11 @@ public class ServiceInstances {
@Transactional
public Response updateVnfInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
@PathParam("vnfInstanceId") String vnfInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("vnfInstanceId", vnfInstanceId);
- return serviceInstances(request, Action.updateInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return serviceInstances(request, Action.updateInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@POST
@@ -396,11 +358,11 @@ public class ServiceInstances {
@ApiOperation(value="Apply updated configuration",response=Response.class)
public Response applyUpdatedConfig(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
@PathParam("vnfInstanceId") String vnfInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("vnfInstanceId", vnfInstanceId);
- return serviceInstances(request, Action.applyUpdatedConfig, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return serviceInstances(request, Action.applyUpdatedConfig, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@POST
@@ -410,11 +372,11 @@ public class ServiceInstances {
@ApiOperation(value="Recreate VNF Instance",response=Response.class)
public Response recreateVnfInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
@PathParam("vnfInstanceId") String vnfInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("vnfInstanceId", vnfInstanceId);
- return serviceInstances(request, Action.recreateInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return serviceInstances(request, Action.recreateInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@@ -426,11 +388,11 @@ public class ServiceInstances {
@Transactional
public Response deleteVnfInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
@PathParam("vnfInstanceId") String vnfInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("vnfInstanceId", vnfInstanceId);
- return serviceInstances(request, Action.deleteInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return serviceInstances(request, Action.deleteInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@POST
@@ -441,11 +403,11 @@ public class ServiceInstances {
@Transactional
public Response createVfModuleInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
@PathParam("vnfInstanceId") String vnfInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("vnfInstanceId", vnfInstanceId);
- return serviceInstances(request, Action.createInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return serviceInstances(request, Action.createInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@POST
@@ -457,12 +419,12 @@ public class ServiceInstances {
public Response replaceVfModuleInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
@PathParam("vnfInstanceId") String vnfInstanceId,
@PathParam("vfmoduleInstanceId") String vfmoduleInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("vnfInstanceId", vnfInstanceId);
instanceIdMap.put("vfModuleInstanceId", vfmoduleInstanceId);
- return serviceInstances(request, Action.replaceInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return serviceInstances(request, Action.replaceInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@PUT
@@ -474,12 +436,12 @@ public class ServiceInstances {
public Response updateVfModuleInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
@PathParam("vnfInstanceId") String vnfInstanceId,
@PathParam("vfmoduleInstanceId") String vfmoduleInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("vnfInstanceId", vnfInstanceId);
instanceIdMap.put("vfModuleInstanceId", vfmoduleInstanceId);
- return serviceInstances(request, Action.updateInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return serviceInstances(request, Action.updateInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@POST
@@ -490,11 +452,11 @@ public class ServiceInstances {
@Transactional
public Response inPlaceSoftwareUpdate(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
@PathParam("vnfInstanceId") String vnfInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("vnfInstanceId", vnfInstanceId);
- return serviceInstances(request, Action.inPlaceSoftwareUpdate, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return serviceInstances(request, Action.inPlaceSoftwareUpdate, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@DELETE
@@ -506,12 +468,12 @@ public class ServiceInstances {
public Response deleteVfModuleInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
@PathParam("vnfInstanceId") String vnfInstanceId,
@PathParam("vfmoduleInstanceId") String vfmoduleInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("vnfInstanceId", vnfInstanceId);
instanceIdMap.put("vfModuleInstanceId", vfmoduleInstanceId);
- return serviceInstances(request, Action.deleteInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return serviceInstances(request, Action.deleteInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@POST
@@ -522,12 +484,12 @@ public class ServiceInstances {
@Transactional
public Response deactivateAndCloudDeleteVfModuleInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
@PathParam("vnfInstanceId") String vnfInstanceId, @PathParam("vfmoduleInstanceId") String vfmoduleInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("vnfInstanceId", vnfInstanceId);
instanceIdMap.put("vfModuleInstanceId", vfmoduleInstanceId);
- Response response = serviceInstances(request, Action.deactivateAndCloudDelete, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ Response response = serviceInstances(request, Action.deactivateAndCloudDelete, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
return response;
}
@@ -539,11 +501,11 @@ public class ServiceInstances {
@Transactional
public Response scaleOutVfModule(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
@PathParam("vnfInstanceId") String vnfInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("vnfInstanceId", vnfInstanceId);
- return serviceInstances(request, Action.scaleOut, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return serviceInstances(request, Action.scaleOut, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@@ -555,11 +517,11 @@ public class ServiceInstances {
@Transactional
public Response createVolumeGroupInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
@PathParam("vnfInstanceId") String vnfInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("vnfInstanceId", vnfInstanceId);
- return serviceInstances(request, Action.createInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return serviceInstances(request, Action.createInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@PUT
@@ -571,12 +533,12 @@ public class ServiceInstances {
public Response updateVolumeGroupInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
@PathParam("vnfInstanceId") String vnfInstanceId,
@PathParam("volumeGroupInstanceId") String volumeGroupInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("vnfInstanceId", vnfInstanceId);
instanceIdMap.put("volumeGroupInstanceId", volumeGroupInstanceId);
- return serviceInstances(request, Action.updateInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return serviceInstances(request, Action.updateInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@DELETE
@@ -588,12 +550,12 @@ public class ServiceInstances {
public Response deleteVolumeGroupInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
@PathParam("vnfInstanceId") String vnfInstanceId,
@PathParam("volumeGroupInstanceId") String volumeGroupInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("vnfInstanceId", vnfInstanceId);
instanceIdMap.put("volumeGroupInstanceId", volumeGroupInstanceId);
- return serviceInstances(request, Action.deleteInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return serviceInstances(request, Action.deleteInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@POST
@@ -603,10 +565,10 @@ public class ServiceInstances {
@ApiOperation(value="Create NetworkInstance on a specified version and serviceInstance ",response=Response.class)
@Transactional
public Response createNetworkInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
- return serviceInstances(request, Action.createInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return serviceInstances(request, Action.createInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@PUT
@@ -617,11 +579,11 @@ public class ServiceInstances {
@Transactional
public Response updateNetworkInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
@PathParam("networkInstanceId") String networkInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("networkInstanceId", networkInstanceId);
- return serviceInstances(request, Action.updateInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return serviceInstances(request, Action.updateInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@DELETE
@@ -632,11 +594,11 @@ public class ServiceInstances {
@Transactional
public Response deleteNetworkInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
@PathParam("networkInstanceId") String networkInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("networkInstanceId", networkInstanceId);
- return serviceInstances(request, Action.deleteInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return serviceInstances(request, Action.deleteInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@POST
@@ -646,8 +608,8 @@ public class ServiceInstances {
@ApiOperation(value="Create instanceGroups",response=Response.class)
@Transactional
public Response createInstanceGroups(String request, @PathParam("version") String version, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
- return serviceInstances(request, Action.createInstance, null, version, requestId, getRequestUri(requestContext));
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
+ return serviceInstances(request, Action.createInstance, null, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@DELETE
@@ -657,10 +619,10 @@ public class ServiceInstances {
@ApiOperation(value="Delete instanceGroup",response=Response.class)
@Transactional
public Response deleteInstanceGroups(@PathParam("version") String version, @PathParam("instanceGroupId") String instanceGroupId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put(CommonConstants.INSTANCE_GROUP_INSTANCE_ID, instanceGroupId);
- return deleteInstanceGroups(Action.deleteInstance, instanceIdMap, version, requestId, getRequestUri(requestContext), requestContext);
+ return deleteInstanceGroups(Action.deleteInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix), requestContext);
}
@POST
@@ -670,10 +632,10 @@ public class ServiceInstances {
@ApiOperation(value="Add instanceGroup members",response=Response.class)
@Transactional
public Response addInstanceGroupMembers(String request, @PathParam("version") String version, @PathParam("instanceGroupId") String instanceGroupId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put(CommonConstants.INSTANCE_GROUP_INSTANCE_ID, instanceGroupId);
- return serviceInstances(request, Action.addMembers, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return serviceInstances(request, Action.addMembers, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
@POST
@@ -683,33 +645,12 @@ public class ServiceInstances {
@ApiOperation(value="Remove instanceGroup members",response=Response.class)
@Transactional
public Response removeInstanceGroupMembers(String request, @PathParam("version") String version, @PathParam("instanceGroupId") String instanceGroupId, @Context ContainerRequestContext requestContext) throws ApiException {
- String requestId = getRequestId(requestContext);
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put(CommonConstants.INSTANCE_GROUP_INSTANCE_ID, instanceGroupId);
- return serviceInstances(request, Action.removeMembers, instanceIdMap, version, requestId, getRequestUri(requestContext));
- }
-
- public String getRequestUri(ContainerRequestContext context){
- String requestUri = context.getUriInfo().getPath();
- String httpUrl = MDC.get(LogConstants.URI_BASE).concat(requestUri);
- MDC.put(LogConstants.HTTP_URL, httpUrl);
- requestUri = requestUri.substring(requestUri.indexOf("/serviceInstantiation/") + 22);
- return requestUri;
+ return serviceInstances(request, Action.removeMembers, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
}
- public void validateHeaders(ContainerRequestContext context) throws ValidationException{
- MultivaluedMap<String, String> headers = context.getHeaders();
- if(!headers.containsKey(ONAPLogConstants.Headers.REQUEST_ID)){
- throw new ValidationException(ONAPLogConstants.Headers.REQUEST_ID + " header", true);
- }
- if(!headers.containsKey(ONAPLogConstants.Headers.PARTNER_NAME)){
- throw new ValidationException(ONAPLogConstants.Headers.PARTNER_NAME + " header", true);
- }
- if(!headers.containsKey(REQUESTOR_ID)){
- throw new ValidationException(REQUESTOR_ID + " header", true);
- }
- }
-
public Response serviceInstances(String requestJSON, Actions action, HashMap<String, String> instanceIdMap, String version, String requestId, String requestUri) throws ApiException {
String serviceInstanceId = (instanceIdMap ==null)? null:instanceIdMap.get("serviceInstanceId");
Boolean aLaCarte = null;
@@ -717,17 +658,20 @@ public class ServiceInstances {
ServiceInstancesRequest sir = null;
String apiVersion = version.substring(1);
- sir = convertJsonToServiceInstanceRequest(requestJSON, action, startTime, sir, msoRequest, requestId, requestUri);
- String requestScope = deriveRequestScope(action, sir, requestUri);
+ sir = requestHandlerUtils.convertJsonToServiceInstanceRequest(requestJSON, action, startTime, sir, msoRequest, requestId, requestUri);
+ String requestScope = requestHandlerUtils.deriveRequestScope(action, sir, requestUri);
InfraActiveRequests currentActiveReq = msoRequest.createRequestObject (sir, action, requestId, Status.IN_PROGRESS, requestJSON, requestScope);
if(sir.getRequestDetails().getRequestParameters() != null){
aLaCarte = sir.getRequestDetails().getRequestParameters().getALaCarte();
}
- parseRequest(sir, instanceIdMap, action, version, requestJSON, aLaCarte, requestId, currentActiveReq);
- setInstanceId(currentActiveReq, requestScope, null, instanceIdMap);
+ requestHandlerUtils.parseRequest(sir, instanceIdMap, action, version, requestJSON, aLaCarte, requestId, currentActiveReq);
+ requestHandlerUtils.setInstanceId(currentActiveReq, requestScope, null, instanceIdMap);
int requestVersion = Integer.parseInt(version.substring(1));
- String instanceName = sir.getRequestDetails().getRequestInfo().getInstanceName();
+ String instanceName = null;
+ if (sir.getRequestDetails().getRequestInfo() != null) {
+ instanceName = sir.getRequestDetails().getRequestInfo().getInstanceName();
+ }
boolean alaCarteFlag = msoRequest.getAlacarteFlag(sir);
String vnfType = msoRequest.getVnfType(sir,requestScope,action,requestVersion);
String networkType = msoRequest.getNetworkType(sir,requestScope);
@@ -743,14 +687,14 @@ public class ServiceInstances {
InfraActiveRequests dup = null;
boolean inProgress = false;
- dup = duplicateCheck(action, instanceIdMap, startTime, msoRequest, instanceName,requestScope, currentActiveReq);
+ dup = requestHandlerUtils.duplicateCheck(action, instanceIdMap, startTime, msoRequest, instanceName,requestScope, currentActiveReq);
if(dup != null){
- inProgress = camundaHistoryCheck(dup, currentActiveReq);
+ inProgress = requestHandlerUtils.camundaHistoryCheck(dup, currentActiveReq);
}
if (dup != null && inProgress) {
- buildErrorOnDuplicateRecord(currentActiveReq, action, instanceIdMap, startTime, msoRequest, instanceName, requestScope, dup);
+ requestHandlerUtils.buildErrorOnDuplicateRecord(currentActiveReq, action, instanceIdMap, startTime, msoRequest, instanceName, requestScope, dup);
}
ServiceInstancesResponse serviceResponse = new ServiceInstancesResponse();
@@ -760,9 +704,9 @@ public class ServiceInstances {
serviceResponse.setRequestReferences(referencesResponse);
Boolean isBaseVfModule = false;
-
+
RecipeLookupResult recipeLookupResult = getServiceInstanceOrchestrationURI(sir, action, alaCarteFlag, currentActiveReq);
- String serviceInstanceType = getServiceType(requestScope, sir, alaCarteFlag);
+ String serviceInstanceType = requestHandlerUtils.getServiceType(requestScope, sir, alaCarteFlag);
ModelType modelType;
ModelInfo modelInfo = sir.getRequestDetails().getModelInfo();
if (action == Action.applyUpdatedConfig || action == Action.inPlaceSoftwareUpdate) {
@@ -803,14 +747,14 @@ public class ServiceInstances {
String errorMessage = "VnfType " + vnfType + " and VF Module Model Name " + modelInfo.getModelName() + serviceVersionText + " not found in MSO Catalog DB";
ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
VfModuleNotFoundException vfModuleException = new VfModuleNotFoundException.Builder(errorMessage, HttpStatus.SC_NOT_FOUND, ErrorNumbers.SVC_BAD_PARAMETER).errorInfo(errorLoggerInfo).build();
- updateStatus(currentActiveReq, Status.FAILED, vfModuleException.getMessage());
+ requestHandlerUtils.updateStatus(currentActiveReq, Status.FAILED, vfModuleException.getMessage());
throw vfModuleException;
}
}
- serviceInstanceId = setServiceInstanceId(requestScope, sir);
+ serviceInstanceId = requestHandlerUtils.setServiceInstanceId(requestScope, sir);
String vnfId = "";
String vfModuleId = "";
String volumeGroupId = "";
@@ -870,7 +814,7 @@ public class ServiceInstances {
.setVnfType(vnfType)
.setVfModuleType(vfModuleType)
.setNetworkType(networkType)
- .setRequestDetails(mapJSONtoMSOStyle(requestJSON, sir, aLaCarte, action))
+ .setRequestDetails(requestHandlerUtils.mapJSONtoMSOStyle(requestJSON, sir, aLaCarte, action))
.setApiVersion(apiVersion)
.setALaCarte(aLaCarte)
.setRequestUri(requestUri)
@@ -880,7 +824,7 @@ public class ServiceInstances {
throw new ValidateException.Builder("Unable to generate RequestClientParamter object" + e.getMessage(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER)
.errorInfo(errorLoggerInfo).build();
}
- return postBPELRequest(currentActiveReq, requestClientParameter, recipeLookupResult.getOrchestrationURI(), requestScope);
+ return requestHandlerUtils.postBPELRequest(currentActiveReq, requestClientParameter, recipeLookupResult.getOrchestrationURI(), requestScope);
}
public Response deleteInstanceGroups(Actions action, HashMap<String, String> instanceIdMap, String version, String requestId, String requestUri, ContainerRequestContext requestContext) throws ApiException {
String instanceGroupId = instanceIdMap.get(CommonConstants.INSTANCE_GROUP_INSTANCE_ID);
@@ -892,27 +836,27 @@ public class ServiceInstances {
String requestScope = ModelType.instanceGroup.toString();
InfraActiveRequests currentActiveReq = msoRequest.createRequestObject (sir, action, requestId, Status.IN_PROGRESS, null, requestScope);
- setInstanceId(currentActiveReq, requestScope, null, instanceIdMap);
+ requestHandlerUtils.setInstanceId(currentActiveReq, requestScope, null, instanceIdMap);
try {
- validateHeaders(requestContext);
+ requestHandlerUtils.validateHeaders(requestContext);
} catch (ValidationException e) {
logger.error("Exception occurred", e);
ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_VALIDATION_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
ValidateException validateException = new ValidateException.Builder(e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
.errorInfo(errorLoggerInfo).build();
- updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
+ requestHandlerUtils.updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
throw validateException;
}
- InfraActiveRequests dup = duplicateCheck(action, instanceIdMap, startTime, msoRequest, null, requestScope, currentActiveReq);
+ InfraActiveRequests dup = requestHandlerUtils.duplicateCheck(action, instanceIdMap, startTime, msoRequest, null, requestScope, currentActiveReq);
boolean inProgress = false;
if(dup != null){
- inProgress = camundaHistoryCheck(dup, currentActiveReq);
+ inProgress = requestHandlerUtils.camundaHistoryCheck(dup, currentActiveReq);
}
if (dup != null && inProgress) {
- buildErrorOnDuplicateRecord(currentActiveReq, action, instanceIdMap, startTime, msoRequest, null, requestScope, dup);
+ requestHandlerUtils.buildErrorOnDuplicateRecord(currentActiveReq, action, instanceIdMap, startTime, msoRequest, null, requestScope, dup);
}
ServiceInstancesResponse serviceResponse = new ServiceInstancesResponse();
@@ -944,7 +888,7 @@ public class ServiceInstances {
.setRequestUri(requestUri)
.setInstanceGroupId(instanceGroupId).build();
- return postBPELRequest(currentActiveReq, requestClientParameter, recipeLookupResult.getOrchestrationURI(), requestScope);
+ return requestHandlerUtils.postBPELRequest(currentActiveReq, requestClientParameter, recipeLookupResult.getOrchestrationURI(), requestScope);
}
private String getPnfCorrelationId(ServiceInstancesRequest sir) {
@@ -953,315 +897,7 @@ public class ServiceInstances {
.map(RequestDetails::getRequestParameters)
.map(parameters -> parameters.getUserParamValue("pnfId"))
.orElse("");
- }
-
- private String deriveRequestScope(Actions action, ServiceInstancesRequest sir, String requestUri) {
- if(action == Action.inPlaceSoftwareUpdate || action == Action.applyUpdatedConfig){
- return (ModelType.vnf.name());
- }else if(action == Action.addMembers || action == Action.removeMembers){
- return(ModelType.instanceGroup.toString());
- }else{
- String requestScope;
- if(sir.getRequestDetails().getModelInfo().getModelType() == null){
- requestScope = requestScopeFromUri(requestUri);
- }else{
- requestScope = sir.getRequestDetails().getModelInfo().getModelType().name();
- }
- return requestScope;
- }
- }
- private String requestScopeFromUri(String requestUri){
- String requestScope;
- if(requestUri.contains(ModelType.network.name())){
- requestScope = ModelType.network.name();
- }else if(requestUri.contains(ModelType.vfModule.name())){
- requestScope = ModelType.vfModule.name();
- }else if(requestUri.contains(ModelType.volumeGroup.name())){
- requestScope = ModelType.volumeGroup.name();
- }else if(requestUri.contains(ModelType.configuration.name())){
- requestScope = ModelType.configuration.name();
- }else if(requestUri.contains(ModelType.vnf.name())){
- requestScope = ModelType.vnf.name();
- }else{
- requestScope = ModelType.service.name();
- }
- return requestScope;
- }
- private Response postBPELRequest(InfraActiveRequests currentActiveReq, RequestClientParameter requestClientParameter, String orchestrationUri, String requestScope)throws ApiException {
- RequestClient requestClient = null;
- HttpResponse response = null;
- try {
- requestClient = reqClientFactory.getRequestClient (orchestrationUri);
- response = requestClient.post(requestClientParameter);
- } catch (Exception e) {
-
- ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, ErrorCode.AvailabilityError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
- String url = requestClient != null ? requestClient.getUrl() : "";
- ClientConnectionException clientException = new ClientConnectionException.Builder(url, HttpStatus.SC_BAD_GATEWAY, ErrorNumbers.SVC_NO_SERVER_RESOURCES).cause(e).errorInfo(errorLoggerInfo).build();
- updateStatus(currentActiveReq, Status.FAILED, clientException.getMessage());
-
- throw clientException;
- }
-
- if (response == null) {
-
- ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, ErrorCode.BusinessProcesssError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
- ClientConnectionException clientException = new ClientConnectionException.Builder(requestClient.getUrl(), HttpStatus.SC_BAD_GATEWAY, ErrorNumbers.SVC_NO_SERVER_RESOURCES).errorInfo(errorLoggerInfo).build();
-
- updateStatus(currentActiveReq, Status.FAILED, clientException.getMessage());
-
- throw clientException;
- }
-
- ResponseHandler respHandler = null;
- int bpelStatus = 500;
- try {
- respHandler = new ResponseHandler (response, requestClient.getType ());
- bpelStatus = respHandler.getStatus ();
- } catch (ApiException e) {
- logger.error("Exception occurred", e);
- ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
- ValidateException validateException = new ValidateException.Builder("Exception caught mapping Camunda JSON response to object", HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
- .errorInfo(errorLoggerInfo).build();
- updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
- throw validateException;
- }
-
- // BPEL accepted the request, the request is in progress
- if (bpelStatus == HttpStatus.SC_ACCEPTED) {
- ServiceInstancesResponse jsonResponse;
- CamundaResponse camundaResp = respHandler.getResponse();
-
- if("Success".equalsIgnoreCase(camundaResp.getMessage())) {
- try {
- ObjectMapper mapper = new ObjectMapper();
- jsonResponse = mapper.readValue(camundaResp.getResponse(), ServiceInstancesResponse.class);
- jsonResponse.getRequestReferences().setRequestId(requestClientParameter.getRequestId());
- Optional<URL> selfLinkUrl = msoRequest.buildSelfLinkUrl(currentActiveReq.getRequestUrl(), requestClientParameter.getRequestId());
- if(selfLinkUrl.isPresent()){
- jsonResponse.getRequestReferences().setRequestSelfLink(selfLinkUrl.get());
- } else {
- jsonResponse.getRequestReferences().setRequestSelfLink(null);
- }
- } catch (IOException e) {
- logger.error("Exception occurred", e);
- ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
- ValidateException validateException = new ValidateException.Builder("Exception caught mapping Camunda JSON response to object", HttpStatus.SC_NOT_ACCEPTABLE, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
- .errorInfo(errorLoggerInfo).build();
- updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
- throw validateException;
- }
- return builder.buildResponse(HttpStatus.SC_ACCEPTED, requestClientParameter.getRequestId(), jsonResponse, requestClientParameter.getApiVersion());
- }
- }
-
- List<String> variables = new ArrayList<>();
- variables.add(bpelStatus + "");
- String camundaJSONResponseBody = respHandler.getResponseBody ();
- if (camundaJSONResponseBody != null && !camundaJSONResponseBody.isEmpty ()) {
-
- ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.BusinessProcesssError).errorSource(requestClient.getUrl()).build();
- BPMNFailureException bpmnException = new BPMNFailureException.Builder(String.valueOf(bpelStatus) + camundaJSONResponseBody, bpelStatus, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR)
- .errorInfo(errorLoggerInfo).build();
-
- updateStatus(currentActiveReq, Status.FAILED, bpmnException.getMessage());
-
- throw bpmnException;
- } else {
-
- ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.BusinessProcesssError).errorSource(requestClient.getUrl()).build();
-
-
- BPMNFailureException servException = new BPMNFailureException.Builder(String.valueOf(bpelStatus), bpelStatus, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR)
- .errorInfo(errorLoggerInfo).build();
- updateStatus(currentActiveReq, Status.FAILED, servException.getMessage());
-
- throw servException;
- }
- }
-
- private void setInstanceId(InfraActiveRequests currentActiveReq, String requestScope, String instanceId, Map<String, String> instanceIdMap) {
- if(StringUtils.isNotBlank(instanceId)) {
- if(ModelType.service.name().equalsIgnoreCase(requestScope)) {
- currentActiveReq.setServiceInstanceId(instanceId);
- } else if(ModelType.vnf.name().equalsIgnoreCase(requestScope)) {
- currentActiveReq.setVnfId(instanceId);
- } else if(ModelType.vfModule.name().equalsIgnoreCase(requestScope)) {
- currentActiveReq.setVfModuleId(instanceId);
- } else if(ModelType.volumeGroup.name().equalsIgnoreCase(requestScope)) {
- currentActiveReq.setVolumeGroupId(instanceId);
- } else if(ModelType.network.name().equalsIgnoreCase(requestScope)) {
- currentActiveReq.setNetworkId(instanceId);
- } else if(ModelType.configuration.name().equalsIgnoreCase(requestScope)) {
- currentActiveReq.setConfigurationId(instanceId);
- }else if(ModelType.instanceGroup.toString().equalsIgnoreCase(requestScope)){
- currentActiveReq.setInstanceGroupId(instanceId);
- }
- } else if(instanceIdMap != null && !instanceIdMap.isEmpty()) {
- if(instanceIdMap.get("serviceInstanceId") != null){
- currentActiveReq.setServiceInstanceId(instanceIdMap.get("serviceInstanceId"));
- }
- if(instanceIdMap.get("vnfInstanceId") != null){
- currentActiveReq.setVnfId(instanceIdMap.get("vnfInstanceId"));
- }
- if(instanceIdMap.get("vfModuleInstanceId") != null){
- currentActiveReq.setVfModuleId(instanceIdMap.get("vfModuleInstanceId"));
- }
- if(instanceIdMap.get("volumeGroupInstanceId") != null){
- currentActiveReq.setVolumeGroupId(instanceIdMap.get("volumeGroupInstanceId"));
- }
- if(instanceIdMap.get("networkInstanceId") != null){
- currentActiveReq.setNetworkId(instanceIdMap.get("networkInstanceId"));
- }
- if(instanceIdMap.get("configurationInstanceId") != null){
- currentActiveReq.setConfigurationId(instanceIdMap.get("configurationInstanceId"));
- }
- if(instanceIdMap.get(CommonConstants.INSTANCE_GROUP_INSTANCE_ID) != null){
- currentActiveReq.setInstanceGroupId(instanceIdMap.get(CommonConstants.INSTANCE_GROUP_INSTANCE_ID));
- }
- }
- }
-
- protected String mapJSONtoMSOStyle(String msoRawRequest, ServiceInstancesRequest serviceInstRequest, boolean isAlaCarte, Actions action) throws IOException {
- ObjectMapper mapper = new ObjectMapper();
- mapper.setSerializationInclusion(Include.NON_NULL);
- if(msoRawRequest != null){
- ServiceInstancesRequest sir = mapper.readValue(msoRawRequest, ServiceInstancesRequest.class);
- if( serviceInstRequest != null &&
- serviceInstRequest.getRequestDetails() != null &&
- serviceInstRequest.getRequestDetails().getRequestParameters() != null) {
- if( !isAlaCarte && Action.createInstance.equals(action)) {
- sir.getRequestDetails().setCloudConfiguration(serviceInstRequest.getRequestDetails().getCloudConfiguration());
- sir.getRequestDetails().getRequestParameters().setUserParams(serviceInstRequest.getRequestDetails().getRequestParameters().getUserParams());
- }
- sir.getRequestDetails().getRequestParameters().setUsePreload(serviceInstRequest.getRequestDetails().getRequestParameters().getUsePreload());
- }
-
- logger.debug("Value as string: {}", mapper.writeValueAsString(sir));
- return mapper.writeValueAsString(sir);
- }
- return null;
- }
-
- private void buildErrorOnDuplicateRecord(InfraActiveRequests currentActiveReq, Actions action, HashMap<String, String> instanceIdMap, long startTime, MsoRequest msoRequest,
- String instanceName, String requestScope, InfraActiveRequests dup) throws ApiException {
-
- // Found the duplicate record. Return the appropriate error.
- String instance = null;
- if(instanceName != null){
- instance = instanceName;
- }else{
- instance = instanceIdMap.get(requestScope + "InstanceId");
- }
- //List<String> variables = new ArrayList<String>();
- //variables.add(dup.getRequestStatus());
- ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DUPLICATE_FOUND, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
-
-
- DuplicateRequestException dupException = new DuplicateRequestException.Builder(requestScope,instance,dup.getRequestStatus(),dup.getRequestId(), HttpStatus.SC_CONFLICT, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR)
- .errorInfo(errorLoggerInfo).build();
-
- updateStatus(currentActiveReq, Status.FAILED, dupException.getMessage());
-
- throw dupException;
- }
-
- private InfraActiveRequests duplicateCheck(Actions action, HashMap<String, String> instanceIdMap, long startTime,
- MsoRequest msoRequest, String instanceName, String requestScope, InfraActiveRequests currentActiveReq) throws ApiException {
- InfraActiveRequests dup = null;
- try {
- if(!(instanceName==null && requestScope.equals("service") && (action == Action.createInstance || action == Action.activateInstance || action == Action.assignInstance))){
- dup = infraActiveRequestsClient.checkInstanceNameDuplicate (instanceIdMap, instanceName, requestScope);
- }
- } catch (Exception e) {
- ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DUPLICATE_CHECK_EXC, ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
- RequestDbFailureException requestDbFailureException = new RequestDbFailureException.Builder("check for duplicate instance", e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e)
- .errorInfo(errorLoggerInfo).build();
- updateStatus(currentActiveReq, Status.FAILED, requestDbFailureException.getMessage());
- throw requestDbFailureException;
- }
- return dup;
- }
- protected boolean camundaHistoryCheck(InfraActiveRequests duplicateRecord, InfraActiveRequests currentActiveReq) throws RequestDbFailureException, ContactCamundaException{
- String requestId = duplicateRecord.getRequestId();
- String path = env.getProperty("mso.camunda.rest.history.uri") + requestId;
- String targetUrl = env.getProperty("mso.camundaURL") + path;
- HttpHeaders headers = setCamundaHeaders(env.getRequiredProperty("mso.camundaAuth"), env.getRequiredProperty("mso.msoKey"));
- HttpEntity<?> requestEntity = new HttpEntity<>(headers);
- ResponseEntity<List<HistoricProcessInstanceEntity>> response = null;
- try{
- response = restTemplate.exchange(targetUrl, HttpMethod.GET, requestEntity, new ParameterizedTypeReference<List<HistoricProcessInstanceEntity>>(){});
- }catch(HttpStatusCodeException e){
- ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DUPLICATE_CHECK_EXC, ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
- ContactCamundaException contactCamundaException= new ContactCamundaException.Builder(requestId, e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e)
- .errorInfo(errorLoggerInfo).build();
- updateStatus(currentActiveReq, Status.FAILED, contactCamundaException.getMessage());
- throw contactCamundaException;
- }
- if(response.getBody().isEmpty()){
- updateStatus(duplicateRecord, Status.COMPLETE, "Request Completed");
- }
- for(HistoricProcessInstance instance : response.getBody()){
- if(instance.getState().equals("ACTIVE")){
- return true;
- }else{
- updateStatus(duplicateRecord, Status.COMPLETE, "Request Completed");
- }
- }
- return false;
- }
- protected HttpHeaders setCamundaHeaders(String auth, String msoKey) {
- HttpHeaders headers = new HttpHeaders();
- List<org.springframework.http.MediaType> acceptableMediaTypes = new ArrayList<>();
- acceptableMediaTypes.add(org.springframework.http.MediaType.APPLICATION_JSON);
- headers.setAccept(acceptableMediaTypes);
- try {
- String userCredentials = CryptoUtils.decrypt(auth, msoKey);
- if(userCredentials != null) {
- headers.add(HttpHeaders.AUTHORIZATION, "Basic " + DatatypeConverter.printBase64Binary(userCredentials.getBytes()));
- }
- } catch(GeneralSecurityException e) {
- logger.error("Security exception", e);
- }
- return headers;
- }
-
- private ServiceInstancesRequest convertJsonToServiceInstanceRequest(String requestJSON, Actions action, long startTime,
- ServiceInstancesRequest sir, MsoRequest msoRequest, String requestId, String requestUri) throws ApiException {
- try{
- ObjectMapper mapper = new ObjectMapper();
- return mapper.readValue(requestJSON, ServiceInstancesRequest.class);
-
- } catch (IOException e) {
-
- ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
-
- ValidateException validateException = new ValidateException.Builder("Error mapping request: " + e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
- .errorInfo(errorLoggerInfo).build();
- String requestScope = requestScopeFromUri(requestUri);
-
- msoRequest.createErrorRequestRecord(Status.FAILED, requestId, validateException.getMessage(), action, requestScope, requestJSON);
-
- throw validateException;
- }
- }
-
- private void parseRequest(ServiceInstancesRequest sir, HashMap<String, String> instanceIdMap, Actions action, String version,
- String requestJSON, Boolean aLaCarte, String requestId, InfraActiveRequests currentActiveReq) throws ValidateException, RequestDbFailureException {
- int reqVersion = Integer.parseInt(version.substring(1));
- try {
- msoRequest.parse(sir, instanceIdMap, action, version, requestJSON, reqVersion, aLaCarte);
- } catch (Exception e) {
- logger.error("failed to parse request", e);
- ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
- ValidateException validateException = new ValidateException.Builder("Error parsing request: " + e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
- .errorInfo(errorLoggerInfo).build();
-
- updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
-
- throw validateException;
- }
- }
+ }
private RecipeLookupResult getServiceInstanceOrchestrationURI(ServiceInstancesRequest sir, Actions action, boolean alaCarteFlag,
InfraActiveRequests currentActiveReq) throws ApiException {
@@ -1284,7 +920,7 @@ public class ServiceInstances {
ValidateException validateException = new ValidateException.Builder(e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
.errorInfo(errorLoggerInfo).build();
- updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
+ requestHandlerUtils.updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
throw validateException;
}
@@ -1299,7 +935,7 @@ public class ServiceInstances {
ValidateException validateException = new ValidateException.Builder(e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
.errorInfo(errorLoggerInfo).build();
- updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
+ requestHandlerUtils.updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
throw validateException;
}
@@ -1313,7 +949,7 @@ public class ServiceInstances {
ValidateException validateException = new ValidateException.Builder(e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
.errorInfo(errorLoggerInfo).build();
- updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
+ requestHandlerUtils.updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
throw validateException;
}
@@ -1328,7 +964,7 @@ public class ServiceInstances {
RecipeNotFoundException recipeNotFoundExceptionException = new RecipeNotFoundException.Builder("Recipe could not be retrieved from catalog DB.", HttpStatus.SC_NOT_FOUND, ErrorNumbers.SVC_GENERAL_SERVICE_ERROR)
.errorInfo(errorLoggerInfo).build();
- updateStatus(currentActiveReq, Status.FAILED, recipeNotFoundExceptionException.getMessage());
+ requestHandlerUtils.updateStatus(currentActiveReq, Status.FAILED, recipeNotFoundExceptionException.getMessage());
throw recipeNotFoundExceptionException;
}
return recipeLookupResult;
@@ -1338,7 +974,7 @@ public class ServiceInstances {
// SERVICE REQUEST
// Construct the default service name
// TODO need to make this a configurable property
- String defaultServiceModelName = getDefaultModel(servInstReq);
+ String defaultServiceModelName = requestHandlerUtils.getDefaultModel(servInstReq);
RequestDetails requestDetails = servInstReq.getRequestDetails();
ModelInfo modelInfo = requestDetails.getModelInfo();
org.onap.so.db.catalog.beans.Service serviceRecord;
@@ -1525,7 +1161,7 @@ public class ServiceInstances {
}
Recipe recipe = null;
- String defaultSource = getDefaultModel(servInstReq);
+ String defaultSource = requestHandlerUtils.getDefaultModel(servInstReq);
String modelCustomizationId = modelInfo.getModelCustomizationId();
String modelCustomizationName = modelInfo.getModelCustomizationName();
String relatedInstanceModelVersionId = null;
@@ -1728,7 +1364,7 @@ public class ServiceInstances {
private RecipeLookupResult getDefaultVnfUri(ServiceInstancesRequest sir, Actions action) {
- String defaultSource = getDefaultModel(sir);
+ String defaultSource = requestHandlerUtils.getDefaultModel(sir);
VnfRecipe vnfRecipe = catalogDbClient.getFirstVnfRecipeByNfRoleAndAction(defaultSource, action.toString());
@@ -1742,7 +1378,7 @@ public class ServiceInstances {
private RecipeLookupResult getNetworkUri(ServiceInstancesRequest sir, Actions action) throws ValidationException {
- String defaultNetworkType = getDefaultModel(sir);
+ String defaultNetworkType = requestHandlerUtils.getDefaultModel(sir);
ModelInfo modelInfo = sir.getRequestDetails().getModelInfo();
String modelName = modelInfo.getModelName();
@@ -1777,40 +1413,7 @@ public class ServiceInstances {
return recipe !=null ? new RecipeLookupResult(recipe.getOrchestrationUri(), recipe.getRecipeTimeout()) : null;
}
- private Optional<String> retrieveModelName(RequestParameters requestParams) {
- String requestTestApi = null;
- TestApi testApi = null;
-
- if (requestParams != null) {
- requestTestApi = requestParams.getTestApi();
- }
-
- if (requestTestApi == null) {
- if(requestParams != null && requestParams.getALaCarte() != null && !requestParams.getALaCarte()) {
- requestTestApi = env.getProperty(CommonConstants.MACRO_TEST_API);
- } else {
- requestTestApi = env.getProperty(CommonConstants.ALACARTE_TEST_API);
- }
- }
-
- try {
- testApi = TestApi.valueOf(requestTestApi);
- return Optional.of(testApi.getModelName());
- } catch (Exception e) {
- logger.warn("Catching the exception on the valueOf enum call and continuing", e);
- throw new IllegalArgumentException("Invalid TestApi is provided", e);
- }
- }
- private String getDefaultModel(ServiceInstancesRequest sir) {
- String defaultModel = sir.getRequestDetails().getRequestInfo().getSource() + "_DEFAULT";
- Optional<String> oModelName = retrieveModelName(sir.getRequestDetails().getRequestParameters());
- if (oModelName.isPresent()) {
- defaultModel = oModelName.get();
- }
- return defaultModel;
- }
-
private Response configurationRecipeLookup(String requestJSON, Action action, HashMap<String, String> instanceIdMap, String version, String requestId, String requestUri) throws ApiException {
String serviceInstanceId = (instanceIdMap ==null)? null:instanceIdMap.get("serviceInstanceId");
Boolean aLaCarte = null;
@@ -1820,26 +1423,26 @@ public class ServiceInstances {
long startTime = System.currentTimeMillis ();
ServiceInstancesRequest sir = null;
- sir = convertJsonToServiceInstanceRequest(requestJSON, action, startTime, sir, msoRequest, requestId, requestUri);
- String requestScope = deriveRequestScope(action,sir, requestUri);
+ sir = requestHandlerUtils.convertJsonToServiceInstanceRequest(requestJSON, action, startTime, sir, msoRequest, requestId, requestUri);
+ String requestScope = requestHandlerUtils.deriveRequestScope(action,sir, requestUri);
InfraActiveRequests currentActiveReq = msoRequest.createRequestObject ( sir, action, requestId, Status.IN_PROGRESS, requestJSON, requestScope);
if(sir.getRequestDetails().getRequestParameters() != null){
aLaCarte = sir.getRequestDetails().getRequestParameters().getALaCarte();
}
- parseRequest(sir, instanceIdMap, action, version, requestJSON, aLaCarte, requestId, currentActiveReq);
- setInstanceId(currentActiveReq, requestScope, null, instanceIdMap);
+ requestHandlerUtils.parseRequest(sir, instanceIdMap, action, version, requestJSON, aLaCarte, requestId, currentActiveReq);
+ requestHandlerUtils.setInstanceId(currentActiveReq, requestScope, null, instanceIdMap);
String instanceName = sir.getRequestDetails().getRequestInfo().getInstanceName();
InfraActiveRequests dup = null;
- dup = duplicateCheck(action, instanceIdMap, startTime, msoRequest, instanceName,requestScope, currentActiveReq);
+ dup = requestHandlerUtils.duplicateCheck(action, instanceIdMap, startTime, msoRequest, instanceName,requestScope, currentActiveReq);
if(dup != null){
- inProgress = camundaHistoryCheck(dup, currentActiveReq);
+ inProgress = requestHandlerUtils.camundaHistoryCheck(dup, currentActiveReq);
}
if (instanceIdMap != null && dup != null && inProgress) {
- buildErrorOnDuplicateRecord(currentActiveReq, action, instanceIdMap, startTime, msoRequest, instanceName, requestScope, dup);
+ requestHandlerUtils.buildErrorOnDuplicateRecord(currentActiveReq, action, instanceIdMap, startTime, msoRequest, instanceName, requestScope, dup);
}
ServiceInstancesResponse serviceResponse = new ServiceInstancesResponse();
@@ -1860,7 +1463,7 @@ public class ServiceInstances {
ValidateException validateException = new ValidateException.Builder(error, HttpStatus.SC_NOT_FOUND, ErrorNumbers.SVC_GENERAL_SERVICE_ERROR)
.errorInfo(errorLoggerInfo).build();
- updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
+ requestHandlerUtils.updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
throw validateException;
@@ -1903,7 +1506,7 @@ public class ServiceInstances {
.setServiceInstanceId(serviceInstanceId)
.setPnfCorrelationId(pnfCorrelationId)
.setConfigurationId(configurationId)
- .setRequestDetails(mapJSONtoMSOStyle(requestJSON, sir, aLaCarte, action))
+ .setRequestDetails(requestHandlerUtils.mapJSONtoMSOStyle(requestJSON, sir, aLaCarte, action))
.setApiVersion(apiVersion)
.setALaCarte(aLaCarte)
.setRequestUri(requestUri).build();
@@ -1913,80 +1516,7 @@ public class ServiceInstances {
.errorInfo(errorLoggerInfo).build();
}
- return postBPELRequest(currentActiveReq, requestClientParameter, orchestrationUri, requestScope);
- }
-
- public String getRequestId(ContainerRequestContext requestContext) throws ValidateException {
- String requestId = null;
- if (requestContext.getProperty("requestId") != null) {
- requestId = requestContext.getProperty("requestId").toString();
- }
- if (UUIDChecker.isValidUUID(requestId)) {
- return requestId;
- } else {
- ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
- ValidateException validateException = new ValidateException.Builder("Request Id " + requestId + " is not a valid UUID", HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER)
- .errorInfo(errorLoggerInfo).build();
-
- throw validateException;
- }
- }
- public void updateStatus(InfraActiveRequests aq, Status status, String errorMessage) throws RequestDbFailureException{
- if ((status == Status.FAILED) || (status == Status.COMPLETE)) {
- aq.setStatusMessage (errorMessage);
- aq.setProgress(new Long(100));
- aq.setRequestStatus(status.toString());
- Timestamp endTimeStamp = new Timestamp (System.currentTimeMillis());
- aq.setEndTime (endTimeStamp);
- try{
- infraActiveRequestsClient.save(aq);
- }catch(Exception e){
- ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
- throw new RequestDbFailureException.Builder(SAVE_TO_DB, e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e)
- .errorInfo(errorLoggerInfo).build();
- }
- }
- }
- protected String getServiceType(String requestScope, ServiceInstancesRequest sir, Boolean aLaCarteFlag){
- String serviceType = null;
- if(requestScope.equalsIgnoreCase(ModelType.service.toString())){
- String defaultServiceModelName = getDefaultModel(sir);
- org.onap.so.db.catalog.beans.Service serviceRecord;
- if(aLaCarteFlag){
- serviceRecord = catalogDbClient.getFirstByModelNameOrderByModelVersionDesc(defaultServiceModelName);
- if(serviceRecord != null){
- serviceType = serviceRecord.getServiceType();
- }
- }else{
- serviceRecord = catalogDbClient.getServiceByID(sir.getRequestDetails().getModelInfo().getModelVersionId());
- if(serviceRecord != null){
- serviceType = serviceRecord.getServiceType();
- }else{
- serviceRecord = catalogDbClient.getFirstByModelNameOrderByModelVersionDesc(defaultServiceModelName);
- if(serviceRecord != null){
- serviceType = serviceRecord.getServiceType();
- }
- }
- }
- }else{
- serviceType = msoRequest.getServiceInstanceType(sir, requestScope);
- }
- return serviceType;
- }
- protected String setServiceInstanceId(String requestScope, ServiceInstancesRequest sir){
- if(sir.getServiceInstanceId () != null){
- return sir.getServiceInstanceId ();
- }else if(requestScope.equalsIgnoreCase(ModelType.instanceGroup.toString())){
- RelatedInstanceList[] relatedInstances = sir.getRequestDetails().getRelatedInstanceList();
- if(relatedInstances != null){
- for(RelatedInstanceList relatedInstanceList : relatedInstances){
- RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance();
- if(relatedInstance.getModelInfo().getModelType() == ModelType.service){
- return relatedInstance.getInstanceId();
- }
- }
- }
- }
- return null;
- }
+ return requestHandlerUtils.postBPELRequest(currentActiveReq, requestClientParameter, orchestrationUri, requestScope);
+ }
+
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CustomWorkflowValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CustomWorkflowValidation.java
new file mode 100644
index 0000000000..695213bf20
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CustomWorkflowValidation.java
@@ -0,0 +1,64 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.so.apihandlerinfra.validation;
+
+import java.util.List;
+import java.util.Map;
+
+import org.onap.so.exceptions.ValidationException;
+import org.onap.so.serviceinstancebeans.CloudConfiguration;
+import org.onap.so.serviceinstancebeans.RequestParameters;
+
+import com.google.common.base.Strings;
+
+public class CustomWorkflowValidation implements ValidationRule{
+
+ @Override
+ public ValidationInformation validate(ValidationInformation info) throws ValidationException{
+ RequestParameters requestParameters = info.getSir().getRequestDetails().getRequestParameters();
+ CloudConfiguration cloudConfiguration = info.getSir().getRequestDetails ().getCloudConfiguration();
+ String workflowUuid = info.getInstanceIdMap().get("workflowUuid");
+
+ if (cloudConfiguration == null) {
+ throw new ValidationException ("cloudConfiguration");
+ }else if (Strings.isNullOrEmpty((cloudConfiguration.getCloudOwner ()))) {
+ throw new ValidationException ("cloudOwner");
+ }else if (Strings.isNullOrEmpty((cloudConfiguration.getLcpCloudRegionId ()))) {
+ throw new ValidationException ("lcpCloudRegionId");
+ }else if (Strings.isNullOrEmpty((cloudConfiguration.getTenantId ()))) {
+ throw new ValidationException ("tenantId");
+ }
+ if(requestParameters == null){
+ throw new ValidationException("requestParameters");
+ }
+
+ List<Map<String, Object>> userParams = requestParameters.getUserParams();
+ if (!validateCustomUserParams(userParams, workflowUuid)) {
+ throw new ValidationException("userParams");
+ }
+ return info;
+ }
+
+ private boolean validateCustomUserParams(List<Map<String, Object>> userParams, String workflowUuid) {
+ return true;
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/BaseTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/BaseTest.java
index 54e7b27168..170b305bb5 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/BaseTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/BaseTest.java
@@ -22,26 +22,28 @@
package org.onap.so.apihandlerinfra;
-import com.github.tomakehurst.wiremock.client.WireMock;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
+import javax.transaction.Transactional;
+
import org.junit.After;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
+import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock;
import org.springframework.core.env.Environment;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
-import javax.transaction.Transactional;
-
-import java.nio.file.Files;
-import java.nio.file.Paths;
+import com.github.tomakehurst.wiremock.WireMockServer;
+import com.github.tomakehurst.wiremock.client.WireMock;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = ApiHandlerApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@@ -59,6 +61,9 @@ public abstract class BaseTest {
@LocalServerPort
private int port;
+ @Autowired
+ protected WireMockServer wireMockServer;
+
protected String createURLWithPort(String uri) {
return "http://localhost:" + port + uri;
}
@@ -69,7 +74,7 @@ public abstract class BaseTest {
@After
public void tearDown(){
- WireMock.reset();
+ wireMockServer.resetAll();
}
public static String getResponseTemplate;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/E2EServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/E2EServiceInstancesTest.java
index 8d5539cf8a..18eb46278d 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/E2EServiceInstancesTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/E2EServiceInstancesTest.java
@@ -24,7 +24,6 @@ import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.equalToJson;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertEquals;
@@ -64,10 +63,10 @@ private final ObjectMapper mapper = new ObjectMapper();
@Before
public void init() throws JsonProcessingException {
- stubFor(post(urlPathEqualTo("/testOrchestrationUri"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/testOrchestrationUri"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_OK)));
- stubFor(post(urlPathEqualTo("/infraActiveRequests/")).withRequestBody(equalToJson("{\"clientRequestId\":null,\"action\":null,\"requestStatus\":\"FAILED\",\"statusMessage\":\"Error parsing request: No valid requestorId is specified\",\"progress\":100,\"startTime\":1533541051247,\"endTime\":1533541051247,\"source\":null,\"vnfId\":null,\"vnfName\":null,\"vnfType\":null,\"serviceType\":null,\"aicNodeClli\":null,\"tenantId\":null,\"provStatus\":null,\"vnfParams\":null,\"vnfOutputs\":null,\"requestBody\":\"{\\r\\n \\\"service\\\":{\\r\\n \\\"name\\\":\\\"so_test4\\\",\\r\\n \\\"description\\\":\\\"so_test2\\\",\\r\\n \\\"serviceInvariantUuid\\\":\\\"60c3e96e-0970-4871-b6e0-3b6de7561519\\\",\\r\\n \\\"serviceUuid\\\":\\\"592f9437-a9c0-4303-b9f6-c445bb7e9814\\\",\\r\\n \\\"globalSubscriberId\\\":\\\"123457\\\",\\r\\n \\\"serviceType\\\":\\\"voLTE\\\",\\r\\n \\\"parameters\\\":{\\r\\n \\\"resources\\\":[\\r\\n {\\r\\n \\\"resourceName\\\":\\\"vIMS\\\",\\r\\n \\\"resourceInvariantUuid\\\":\\\"60c3e96e-0970-4871-b6e0-3b6de7561516\\\",\\r\\n \\\"resourceUuid\\\":\\\"60c3e96e-0970-4871-b6e0-3b6de7561512\\\",\\r\\n \\\"parameters\\\":{\\r\\n \\\"locationConstraints\\\":[\\r\\n {\\r\\n \\\"vnfProfileId\\\":\\\"zte-vBAS-1.0\\\",\\r\\n \\\"locationConstraints\\\":{\\r\\n \\\"vimId\\\":\\\"4050083f-465f-4838-af1e-47a545222ad0\\\"\\r\\n }\\r\\n },\\r\\n {\\r\\n \\\"vnfProfileId\\\":\\\"zte-vMME-1.0\\\",\\r\\n \\\"locationConstraints\\\":{\\r\\n \\\"vimId\\\":\\\"4050083f-465f-4838-af1e-47a545222ad0\\\"\\r\\n }\\r\\n }\\r\\n ]\\r\\n }\\r\\n },\\r\\n {\\r\\n \\\"resourceName\\\":\\\"vEPC\\\",\\r\\n \\\"resourceInvariantUuid\\\":\\\"61c3e96e-0970-4871-b6e0-3b6de7561516\\\",\\r\\n \\\"resourceUuid\\\":\\\"62c3e96e-0970-4871-b6e0-3b6de7561512\\\",\\r\\n \\\"parameters\\\":{\\r\\n \\\"locationConstraints\\\":[\\r\\n {\\r\\n \\\"vnfProfileId\\\":\\\"zte-CSCF-1.0\\\",\\r\\n \\\"locationConstraints\\\":{\\r\\n \\\"vimId\\\":\\\"4050083f-465f-4838-af1e-47a545222ad1\\\"\\r\\n }\\r\\n }\\r\\n ]\\r\\n }\\r\\n },\\r\\n {\\r\\n \\\"resourceName\\\":\\\"underlayvpn\\\",\\r\\n \\\"resourceInvariantUuid\\\":\\\"60c3e96e-0970-4871-b6e0-3b6de7561513\\\",\\r\\n \\\"resourceUuid\\\":\\\"60c3e96e-0970-4871-b6e0-3b6de7561514\\\",\\r\\n \\\"parameters\\\":{\\r\\n \\\"locationConstraints\\\":[\\r\\n\\r\\n ]\\r\\n }\\r\\n },\\r\\n {\\r\\n \\\"resourceName\\\":\\\"overlayvpn\\\",\\r\\n \\\"resourceInvariantUuid\\\":\\\"60c3e96e-0970-4871-b6e0-3b6de7561517\\\",\\r\\n \\\"resourceUuid\\\":\\\"60c3e96e-0970-4871-b6e0-3b6de7561518\\\",\\r\\n \\\"parameters\\\":{\\r\\n \\\"locationConstraints\\\":[\\r\\n\\r\\n ]\\r\\n }\\r\\n }\\r\\n ],\\r\\n \\\"requestInputs\\\":{\\r\\n \\\"externalDataNetworkName\\\":\\\"Flow_out_net\\\",\\r\\n \\\"m6000_mng_ip\\\":\\\"181.18.20.2\\\",\\r\\n \\\"externalCompanyFtpDataNetworkName\\\":\\\"Flow_out_net\\\",\\r\\n \\\"externalPluginManageNetworkName\\\":\\\"plugin_net_2014\\\",\\r\\n \\\"externalManageNetworkName\\\":\\\"mng_net_2017\\\",\\r\\n \\\"sfc_data_network\\\":\\\"sfc_data_net_2016\\\",\\r\\n \\\"NatIpRange\\\":\\\"210.1.1.10-210.1.1.20\\\",\\r\\n \\\"location\\\":\\\"4050083f-465f-4838-af1e-47a545222ad0\\\",\\r\\n \\\"sdncontroller\\\":\\\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\\\"\\r\\n }\\r\\n }\\r\\n\\r\\n }\\r\\n\\r\\n}\",\"responseBody\":null,\"lastModifiedBy\":\"APIH\",\"modifyTime\":null,\"requestType\":null,\"volumeGroupId\":null,\"volumeGroupName\":null,\"vfModuleId\":null,\"vfModuleName\":null,\"vfModuleModelName\":null,\"aaiServiceId\":null,\"aicCloudRegion\":null,\"callBackUrl\":null,\"correlator\":null,\"serviceInstanceId\":null,\"serviceInstanceName\":null,\"requestScope\":\"service\",\"requestAction\":\"createInstance\",\"networkId\":null,\"networkName\":null,\"networkType\":null,\"requestorId\":null,\"configurationId\":null,\"configurationName\":null,\"operationalEnvId\":null,\"operationalEnvName\":null,\"requestURI\":\"d167c9d0-1785-4e93-b319-996ebbcc3272\"}")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ wireMockServer.stubFor(post(urlPathEqualTo("/infraActiveRequests/")).withRequestBody(equalToJson("{\"clientRequestId\":null,\"action\":null,\"requestStatus\":\"FAILED\",\"statusMessage\":\"Error parsing request: No valid requestorId is specified\",\"progress\":100,\"startTime\":1533541051247,\"endTime\":1533541051247,\"source\":null,\"vnfId\":null,\"vnfName\":null,\"vnfType\":null,\"serviceType\":null,\"aicNodeClli\":null,\"tenantId\":null,\"provStatus\":null,\"vnfParams\":null,\"vnfOutputs\":null,\"requestBody\":\"{\\r\\n \\\"service\\\":{\\r\\n \\\"name\\\":\\\"so_test4\\\",\\r\\n \\\"description\\\":\\\"so_test2\\\",\\r\\n \\\"serviceInvariantUuid\\\":\\\"60c3e96e-0970-4871-b6e0-3b6de7561519\\\",\\r\\n \\\"serviceUuid\\\":\\\"592f9437-a9c0-4303-b9f6-c445bb7e9814\\\",\\r\\n \\\"globalSubscriberId\\\":\\\"123457\\\",\\r\\n \\\"serviceType\\\":\\\"voLTE\\\",\\r\\n \\\"parameters\\\":{\\r\\n \\\"resources\\\":[\\r\\n {\\r\\n \\\"resourceName\\\":\\\"vIMS\\\",\\r\\n \\\"resourceInvariantUuid\\\":\\\"60c3e96e-0970-4871-b6e0-3b6de7561516\\\",\\r\\n \\\"resourceUuid\\\":\\\"60c3e96e-0970-4871-b6e0-3b6de7561512\\\",\\r\\n \\\"parameters\\\":{\\r\\n \\\"locationConstraints\\\":[\\r\\n {\\r\\n \\\"vnfProfileId\\\":\\\"zte-vBAS-1.0\\\",\\r\\n \\\"locationConstraints\\\":{\\r\\n \\\"vimId\\\":\\\"4050083f-465f-4838-af1e-47a545222ad0\\\"\\r\\n }\\r\\n },\\r\\n {\\r\\n \\\"vnfProfileId\\\":\\\"zte-vMME-1.0\\\",\\r\\n \\\"locationConstraints\\\":{\\r\\n \\\"vimId\\\":\\\"4050083f-465f-4838-af1e-47a545222ad0\\\"\\r\\n }\\r\\n }\\r\\n ]\\r\\n }\\r\\n },\\r\\n {\\r\\n \\\"resourceName\\\":\\\"vEPC\\\",\\r\\n \\\"resourceInvariantUuid\\\":\\\"61c3e96e-0970-4871-b6e0-3b6de7561516\\\",\\r\\n \\\"resourceUuid\\\":\\\"62c3e96e-0970-4871-b6e0-3b6de7561512\\\",\\r\\n \\\"parameters\\\":{\\r\\n \\\"locationConstraints\\\":[\\r\\n {\\r\\n \\\"vnfProfileId\\\":\\\"zte-CSCF-1.0\\\",\\r\\n \\\"locationConstraints\\\":{\\r\\n \\\"vimId\\\":\\\"4050083f-465f-4838-af1e-47a545222ad1\\\"\\r\\n }\\r\\n }\\r\\n ]\\r\\n }\\r\\n },\\r\\n {\\r\\n \\\"resourceName\\\":\\\"underlayvpn\\\",\\r\\n \\\"resourceInvariantUuid\\\":\\\"60c3e96e-0970-4871-b6e0-3b6de7561513\\\",\\r\\n \\\"resourceUuid\\\":\\\"60c3e96e-0970-4871-b6e0-3b6de7561514\\\",\\r\\n \\\"parameters\\\":{\\r\\n \\\"locationConstraints\\\":[\\r\\n\\r\\n ]\\r\\n }\\r\\n },\\r\\n {\\r\\n \\\"resourceName\\\":\\\"overlayvpn\\\",\\r\\n \\\"resourceInvariantUuid\\\":\\\"60c3e96e-0970-4871-b6e0-3b6de7561517\\\",\\r\\n \\\"resourceUuid\\\":\\\"60c3e96e-0970-4871-b6e0-3b6de7561518\\\",\\r\\n \\\"parameters\\\":{\\r\\n \\\"locationConstraints\\\":[\\r\\n\\r\\n ]\\r\\n }\\r\\n }\\r\\n ],\\r\\n \\\"requestInputs\\\":{\\r\\n \\\"externalDataNetworkName\\\":\\\"Flow_out_net\\\",\\r\\n \\\"m6000_mng_ip\\\":\\\"181.18.20.2\\\",\\r\\n \\\"externalCompanyFtpDataNetworkName\\\":\\\"Flow_out_net\\\",\\r\\n \\\"externalPluginManageNetworkName\\\":\\\"plugin_net_2014\\\",\\r\\n \\\"externalManageNetworkName\\\":\\\"mng_net_2017\\\",\\r\\n \\\"sfc_data_network\\\":\\\"sfc_data_net_2016\\\",\\r\\n \\\"NatIpRange\\\":\\\"210.1.1.10-210.1.1.20\\\",\\r\\n \\\"location\\\":\\\"4050083f-465f-4838-af1e-47a545222ad0\\\",\\r\\n \\\"sdncontroller\\\":\\\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\\\"\\r\\n }\\r\\n }\\r\\n\\r\\n }\\r\\n\\r\\n}\",\"responseBody\":null,\"lastModifiedBy\":\"APIH\",\"modifyTime\":null,\"requestType\":null,\"volumeGroupId\":null,\"volumeGroupName\":null,\"vfModuleId\":null,\"vfModuleName\":null,\"vfModuleModelName\":null,\"aaiServiceId\":null,\"aicCloudRegion\":null,\"callBackUrl\":null,\"correlator\":null,\"serviceInstanceId\":null,\"serviceInstanceName\":null,\"requestScope\":\"service\",\"requestAction\":\"createInstance\",\"networkId\":null,\"networkName\":null,\"networkType\":null,\"requestorId\":null,\"configurationId\":null,\"configurationName\":null,\"operationalEnvId\":null,\"operationalEnvName\":null,\"requestURI\":\"d167c9d0-1785-4e93-b319-996ebbcc3272\"}")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_OK)));
Service defaultService = new Service();
defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
@@ -77,12 +76,12 @@ private final ObjectMapper mapper = new ObjectMapper();
serviceRecipe.setRecipeTimeout(180);
serviceRecipe.setOrchestrationUri("/testOrchestrationUri");
- stubFor(get(urlPathEqualTo("/service/search/findFirstByModelNameOrderByModelVersionDesc"))
+ wireMockServer.stubFor(get(urlPathEqualTo("/service/search/findFirstByModelNameOrderByModelVersionDesc"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(defaultService))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlPathEqualTo("/serviceRecipe/search/findFirstByServiceModelUUIDAndAction"))
+ wireMockServer.stubFor(get(urlPathEqualTo("/serviceRecipe/search/findFirstByServiceModelUUIDAndAction"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(serviceRecipe))
.withStatus(HttpStatus.SC_OK)));
@@ -160,7 +159,7 @@ private final ObjectMapper mapper = new ObjectMapper();
@Test
public void getE2EServiceInstanceNullOperationalStatus() throws IOException{
String uri = e2eServInstancesUri + "v5/9b9f02c0-298b-458a-bc9c-be3692e4f35e/operations/9b9f02c0-298b-458a-bc9c-be3692e4f35e";
- stubFor(get(urlPathEqualTo("/operationStatus/search/findOneByServiceIdAndOperationId"))
+ wireMockServer.stubFor(get(urlPathEqualTo("/operationStatus/search/findOneByServiceIdAndOperationId"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_OK)));
ResponseEntity<String> response = sendRequest(inputStream("/Request.json"), uri, HttpMethod.GET);
@@ -196,7 +195,7 @@ private final ObjectMapper mapper = new ObjectMapper();
OperationStatus status = new OperationStatus();
status.setOperationId("operationId");
status.setServiceId("9b9f02c0-298b-458a-bc9c-be3692e4f35e");
- stubFor(get(urlPathEqualTo("/operationStatus/search/findOneByServiceIdAndOperationId"))
+ wireMockServer.stubFor(get(urlPathEqualTo("/operationStatus/search/findOneByServiceIdAndOperationId"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(status))
.withStatus(HttpStatus.SC_OK)));
@@ -215,7 +214,7 @@ private final ObjectMapper mapper = new ObjectMapper();
}
@Test
public void compareModelWithTargetVersion() throws IOException{
- stubFor(post(urlPathEqualTo("/mso/async/services/CompareModelofE2EServiceInstance"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CompareModelofE2EServiceInstance"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBodyFile("Camunda/SuccessfulResponse.json").withStatus(org.apache.http.HttpStatus.SC_ACCEPTED)));
@@ -229,7 +228,7 @@ private final ObjectMapper mapper = new ObjectMapper();
}
@Test
public void compareModelWithTargetVersionEmptyResponse() throws IOException{
- stubFor(post(urlPathEqualTo("/mso/async/services/CompareModelofE2EServiceInstance"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CompareModelofE2EServiceInstance"))
.willReturn(aResponse().withFault(Fault.EMPTY_RESPONSE)));
RequestError expectedResponse = new RequestError();
@@ -247,7 +246,7 @@ private final ObjectMapper mapper = new ObjectMapper();
}
@Test
public void compareModelWithTargetVersionBadBpelResponse() throws IOException{
- stubFor(post(urlPathEqualTo("/mso/async/services/CompareModelofE2EServiceInstance"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CompareModelofE2EServiceInstance"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY)));
@@ -260,7 +259,7 @@ private final ObjectMapper mapper = new ObjectMapper();
}
@Test
public void compareModelWithTargetVersionNoBPELResponse() throws IOException{
- stubFor(post(urlPathEqualTo("/mso/async/services/CompareModelofE2EServiceInstance"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CompareModelofE2EServiceInstance"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody("{}").withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY)));
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/InstanceManagementTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/InstanceManagementTest.java
new file mode 100644
index 0000000000..b70322cecf
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/InstanceManagementTest.java
@@ -0,0 +1,180 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra;
+
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+import static org.onap.so.logger.HttpHeadersConstants.ONAP_REQUEST_ID;
+import static org.onap.so.logger.HttpHeadersConstants.REQUESTOR_ID;
+import static org.onap.so.logger.MdcConstants.CLIENT_ID;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.http.HttpStatus;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.onap.so.logger.HttpHeadersConstants;
+import org.onap.so.serviceinstancebeans.RequestReferences;
+import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+import org.springframework.util.ResourceUtils;
+import org.springframework.web.util.UriComponentsBuilder;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class InstanceManagementTest extends BaseTest{
+
+ private final ObjectMapper mapper = new ObjectMapper();
+ private ObjectMapper errorMapper = new ObjectMapper();
+
+ @Autowired
+ private InstanceManagement instanceManagement;
+
+ @Value("${wiremock.server.port}")
+ private String wiremockPort;
+
+ private final String instanceManagementUri = "/onap/so/infra/instanceManagement/";
+
+ private String uri;
+ private URL selfLink;
+ private URL initialUrl;
+ private int initialPort;
+ private HttpHeaders headers;
+
+ @Before
+ public void beforeClass() {
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ errorMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ errorMapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
+ // set headers
+ headers = new HttpHeaders();
+ headers.set(ONAPLogConstants.Headers.PARTNER_NAME, "test_name");
+ headers.set(HttpHeadersConstants.TRANSACTION_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
+ headers.set(ONAP_REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
+ headers.set(ONAPLogConstants.MDCs.REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
+ headers.set(CLIENT_ID, "VID");
+ headers.set(REQUESTOR_ID, "xxxxxx");
+ try { // generate one-time port number to avoid RANDOM port number later.
+ initialUrl = new URL(createURLWithPort(Constants.ORCHESTRATION_REQUESTS_PATH));
+ initialPort = initialUrl.getPort();
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ }
+ wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests.*"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withStatus(HttpStatus.SC_OK)));
+ }
+
+ public String inputStream(String JsonInput)throws IOException{
+ JsonInput = "src/test/resources/ServiceInstanceTest" + JsonInput;
+ return new String(Files.readAllBytes(Paths.get(JsonInput)));
+ }
+
+ private URL createExpectedSelfLink(String version, String requestId) {
+ System.out.println("createdUrl: " + initialUrl.toString());
+ try {
+ selfLink = new URL(initialUrl.toString().concat("/").concat(version).concat("/").concat(requestId));
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ }
+ return selfLink;
+ }
+
+ private String getWiremockResponseForCatalogdb(String file) {
+ try {
+ File resource= ResourceUtils.getFile("classpath:__files/catalogdb/"+file);
+ return new String(Files.readAllBytes(resource.toPath())).replaceAll("localhost:8090","localhost:"+wiremockPort);
+ } catch (IOException e) {
+ e.printStackTrace();
+ return null;
+ }
+
+ }
+
+ public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod, HttpHeaders headers){
+
+ if (!headers.containsKey(HttpHeaders.ACCEPT)) {
+ headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
+ }
+ if (!headers.containsKey(HttpHeaders.CONTENT_TYPE)) {
+ headers.set(HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON);
+ }
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(uriPath, initialPort));
+
+ HttpEntity<String> request = new HttpEntity<>(requestJson, headers);
+
+ return restTemplate.exchange(builder.toUriString(),
+ reqMethod, request, String.class);
+ }
+
+ public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod){
+ return sendRequest(requestJson, uriPath, reqMethod, new HttpHeaders());
+ }
+
+ @Test
+ public void executeCustomWorkflow() throws IOException {
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/VnfInPlaceUpdate"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]" +
+ "nfRole=GR-API-DEFAULT&action=inPlaceSoftwareUpdate"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(getWiremockResponseForCatalogdb("vnfRecipeInPlaceUpdate_Response.json"))
+ .withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ requestReferences.setRequestSelfLink(createExpectedSelfLink("v1","32807a28-1a14-4b88-b7b3-2950918aa76d"));
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = instanceManagementUri + "v1" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/workflows/71526781-e55c-4cb7-adb3-97e09d9c76be";
+ ResponseEntity<String> response = sendRequest(inputStream("/ExecuteCustomWorkflow.json"), uri, HttpMethod.POST, headers);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java
index 1943b42404..a22e61e75f 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java
@@ -22,8 +22,8 @@ package org.onap.so.apihandlerinfra;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+import static com.shazam.shazamcrest.MatcherAssert.assertThat;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -75,7 +75,7 @@ public class ManualTasksTest extends BaseTest{
@Test
public void testCreateOpEnvObjectMapperError() throws IOException {
TestAppender.events.clear();
- stubFor(post(urlPathEqualTo("/sobpmnengine/task/55/complete"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/sobpmnengine/task/55/complete"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK)));
String taskId = "55";
@@ -212,7 +212,7 @@ public class ManualTasksTest extends BaseTest{
}
@Test
public void completeTaskBpelResponseError() throws IOException {
- stubFor(post(urlPathEqualTo("/sobpmnengine/task/55/complete"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/sobpmnengine/task/55/complete"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withFault(Fault.EMPTY_RESPONSE)));
String taskId = "55";
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java
index ee98accfdc..d6fff7bdfb 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java
@@ -153,6 +153,27 @@ public class MsoRequestTest extends BaseTest {
});
}
@Test
+ @Parameters(method = "customWorkflowSuccessParameters")
+ public void customWorkflowSuccessTest(ServiceInstancesRequest sir, HashMap<String, String> instanceIdMapTest, Action action, int reqVersion) throws ValidationException, IOException{
+ this.sir = sir;
+ this.instanceIdMapTest = instanceIdMapTest;
+ this.action = action;
+ this.reqVersion = reqVersion;
+ this.version = "v" + reqVersion;
+ this.instanceIdMapTest.put("serviceInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
+ this.instanceIdMapTest.put("vnfInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
+ this.instanceIdMapTest.put("workflowUuid", "ff305d54-75b4-431b-adb2-eb6b9e5ff000");
+ this.msoRequest = new MsoRequest();
+ this.msoRequest.parse(sir, instanceIdMapTest, action, version, originalRequestJSON, reqVersion, false);
+ }
+ @Parameters
+ private Collection<Object[]> customWorkflowSuccessParameters() throws JsonParseException, JsonMappingException, IOException{
+ return Arrays.asList(new Object[][]{
+ {mapper.readValue(inputStream("/SuccessfulValidation/v1ExecuteCustomWorkflow.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.inPlaceSoftwareUpdate, "1"}
+
+ });
+ }
+ @Test
@Parameters(method = "aLaCarteParameters")
public void aLaCarteFlagTest(boolean expected, ServiceInstancesRequest sir) throws JsonParseException, IOException, ValidationException{
this.expected = expected;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java
index 28797d247b..e96558171d 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java
@@ -26,7 +26,6 @@ import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
import static com.github.tomakehurst.wiremock.client.WireMock.equalToJson;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static com.shazam.shazamcrest.MatcherAssert.assertThat;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
@@ -423,10 +422,10 @@ public class OrchestrationRequestsTest extends BaseTest {
public void setupTestGetOrchestrationRequest() throws Exception{
//For testGetOrchestrationRequest
- stubFor(any(urlPathEqualTo("/infraActiveRequests/00032ab7-na18-42e5-965d-8ea592502018")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ wireMockServer.stubFor(any(urlPathEqualTo("/infraActiveRequests/00032ab7-na18-42e5-965d-8ea592502018")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(new String(Files.readAllBytes(Paths.get("src/test/resources/OrchestrationRequest/getOrchestrationRequest.json"))))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlPathEqualTo("/requestProcessingData/search/findBySoRequestIdOrderByGroupingIdDesc/"))
+ wireMockServer.stubFor(get(urlPathEqualTo("/requestProcessingData/search/findBySoRequestIdOrderByGroupingIdDesc/"))
.withQueryParam("SO_REQUEST_ID", equalTo("00032ab7-na18-42e5-965d-8ea592502018"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(new String(Files.readAllBytes(Paths.get("src/test/resources/OrchestrationRequest/getRequestProcessingData.json"))))
@@ -434,10 +433,10 @@ public class OrchestrationRequestsTest extends BaseTest {
}
public void setupTestGetOrchestrationRequestInstanceGroup() throws Exception{
//For testGetOrchestrationRequest
- stubFor(any(urlPathEqualTo("/infraActiveRequests/00032ab7-na18-42e5-965d-8ea592502018")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ wireMockServer.stubFor(any(urlPathEqualTo("/infraActiveRequests/00032ab7-na18-42e5-965d-8ea592502018")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(new String(Files.readAllBytes(Paths.get("src/test/resources/OrchestrationRequest/getOrchestrationRequestInstanceGroup.json"))))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlPathEqualTo("/requestProcessingData/search/findBySoRequestIdOrderByGroupingIdDesc/"))
+ wireMockServer.stubFor(get(urlPathEqualTo("/requestProcessingData/search/findBySoRequestIdOrderByGroupingIdDesc/"))
.withQueryParam("SO_REQUEST_ID", equalTo("00032ab7-na18-42e5-965d-8ea592502018"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(new String(Files.readAllBytes(Paths.get("src/test/resources/OrchestrationRequest/getRequestProcessingData.json"))))
@@ -445,13 +444,13 @@ public class OrchestrationRequestsTest extends BaseTest {
}
private void setupTestGetOrchestrationRequestRequestDetails(String requestId, String status) throws Exception{
- stubFor(get(urlPathEqualTo(getTestUrl(requestId))).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ wireMockServer.stubFor(get(urlPathEqualTo(getTestUrl(requestId))).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(new String(Files.readAllBytes(Paths.get("src/test/resources/OrchestrationRequest/getOrchestrationRequestDetails.json"))))
.withStatus(HttpStatus.SC_OK)));
}
private void setupTestUnlockOrchestrationRequest(String requestId, String status) {
- stubFor(get(urlPathEqualTo(getTestUrl(requestId))).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ wireMockServer.stubFor(get(urlPathEqualTo(getTestUrl(requestId))).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(String.format(getResponseTemplate, requestId, status))
.withStatus(HttpStatus.SC_OK)));
@@ -460,24 +459,24 @@ public class OrchestrationRequestsTest extends BaseTest {
private void setupTestUnlockOrchestrationRequest_invalid_Json() {
- stubFor(get(urlPathEqualTo(getTestUrl(INVALID_REQUEST_ID))).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ wireMockServer.stubFor(get(urlPathEqualTo(getTestUrl(INVALID_REQUEST_ID))).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_NOT_FOUND)));
}
private void setupTestUnlockOrchestrationRequest_Valid_Status(String requestID, String status) {
- stubFor(get(urlPathEqualTo(getTestUrl(requestID))).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ wireMockServer.stubFor(get(urlPathEqualTo(getTestUrl(requestID))).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(String.format(getResponseTemplate, requestID, status))
.withStatus(HttpStatus.SC_OK)));
- stubFor(post(urlPathEqualTo(getTestUrl(""))).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ wireMockServer.stubFor(post(urlPathEqualTo(getTestUrl(""))).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(String.format(infraActivePost, requestID))
.withStatus(HttpStatus.SC_OK)));
}
private void setupTestGetOrchestrationRequestFilter() throws Exception{
//for testGetOrchestrationRequestFilter();
- stubFor(any(urlPathEqualTo("/infraActiveRequests/getOrchestrationFiltersFromInfraActive/")).withRequestBody(equalToJson("{\"modelType\":[\"EQUALS\",\"vfModule\"]}")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ wireMockServer.stubFor(any(urlPathEqualTo("/infraActiveRequests/getOrchestrationFiltersFromInfraActive/")).withRequestBody(equalToJson("{\"modelType\":[\"EQUALS\",\"vfModule\"]}")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(new String(Files.readAllBytes(Paths.get("src/test/resources/OrchestrationRequest/getRequestDetailsFilter.json"))))
.withStatus(HttpStatus.SC_OK)));
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsTest.java
new file mode 100644
index 0000000000..a5f9514be2
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsTest.java
@@ -0,0 +1,330 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra;
+
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.onap.so.logger.HttpHeadersConstants.ONAP_REQUEST_ID;
+import static org.onap.so.logger.HttpHeadersConstants.REQUESTOR_ID;
+import static org.onap.so.logger.MdcConstants.CLIENT_ID;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.List;
+
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.core.MediaType;
+
+import org.apache.http.HttpStatus;
+import org.junit.Before;
+
+import org.junit.Test;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.onap.so.apihandlerinfra.exceptions.ContactCamundaException;
+import org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException;
+import org.onap.so.db.catalog.beans.Service;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.logger.HttpHeadersConstants;
+import org.onap.so.serviceinstancebeans.ModelInfo;
+import org.onap.so.serviceinstancebeans.RequestDetails;
+import org.onap.so.serviceinstancebeans.RequestInfo;
+import org.onap.so.serviceinstancebeans.RequestParameters;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.util.UriComponentsBuilder;
+
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class RequestHandlerUtilsTest extends BaseTest{
+
+ private final ObjectMapper mapper = new ObjectMapper();
+ private ObjectMapper errorMapper = new ObjectMapper();
+
+ @Autowired
+ private RequestHandlerUtils requestHandlerUtils;
+
+ @Value("${wiremock.server.port}")
+ private String wiremockPort;
+
+ private URL initialUrl;
+ private int initialPort;
+ private HttpHeaders headers;
+
+ @Before
+ public void beforeClass() {
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ errorMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ errorMapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
+ // set headers
+ headers = new HttpHeaders();
+ headers.set(ONAPLogConstants.Headers.PARTNER_NAME, "test_name");
+ headers.set(HttpHeadersConstants.TRANSACTION_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
+ headers.set(ONAP_REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
+ headers.set(ONAPLogConstants.MDCs.REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
+ headers.set(CLIENT_ID, "VID");
+ headers.set(REQUESTOR_ID, "xxxxxx");
+ try { // generate one-time port number to avoid RANDOM port number later.
+ initialUrl = new URL(createURLWithPort(Constants.ORCHESTRATION_REQUESTS_PATH));
+ initialPort = initialUrl.getPort();
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ }
+ wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests.*"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withStatus(HttpStatus.SC_OK)));
+ }
+
+ public String inputStream(String JsonInput)throws IOException{
+ JsonInput = "src/test/resources/ServiceInstanceTest" + JsonInput;
+ return new String(Files.readAllBytes(Paths.get(JsonInput)));
+ }
+
+ public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod, HttpHeaders headers){
+
+ if (!headers.containsKey(HttpHeaders.ACCEPT)) {
+ headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
+ }
+ if (!headers.containsKey(HttpHeaders.CONTENT_TYPE)) {
+ headers.set(HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON);
+ }
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(uriPath, initialPort));
+
+ HttpEntity<String> request = new HttpEntity<>(requestJson, headers);
+
+ return restTemplate.exchange(builder.toUriString(),
+ reqMethod, request, String.class);
+ }
+
+ public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod){
+ return sendRequest(requestJson, uriPath, reqMethod, new HttpHeaders());
+ }
+
+ @Test
+ public void test_mapJSONtoMSOStyle() throws IOException{
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.setSerializationInclusion(Include.NON_NULL);
+ String testRequest= inputStream("/ServiceInstanceDefault.json");
+ String resultString = requestHandlerUtils.mapJSONtoMSOStyle(testRequest, null, false, null);
+ ServiceInstancesRequest sir = mapper.readValue(resultString, ServiceInstancesRequest.class);
+ ModelInfo modelInfo = sir.getRequestDetails().getModelInfo();
+ assertEquals("f7ce78bb-423b-11e7-93f8-0050569a796",modelInfo.getModelCustomizationUuid());
+ assertEquals("modelInstanceName",modelInfo.getModelInstanceName());
+ assertEquals("f7ce78bb-423b-11e7-93f8-0050569a7965",modelInfo.getModelInvariantUuid());
+ assertEquals("10",modelInfo.getModelUuid());
+
+ }
+
+
+ @Test
+ public void test_mapJSONtoMSOStyleUsePreload() throws IOException{
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.setSerializationInclusion(Include.NON_NULL);
+ String testRequest= inputStream("/ServiceInstanceDefault.json");
+ ServiceInstancesRequest sir = new ServiceInstancesRequest();
+ RequestDetails rd = new RequestDetails();
+ RequestParameters rp = new RequestParameters();
+ rp.setUsePreload(true);
+ rd.setRequestParameters(rp);
+ sir.setRequestDetails(rd);
+ String resultString = requestHandlerUtils.mapJSONtoMSOStyle(testRequest, sir, false, null);
+ ServiceInstancesRequest sir1 = mapper.readValue(resultString, ServiceInstancesRequest.class);
+ assertTrue(sir1.getRequestDetails().getRequestParameters().getUsePreload());
+ }
+
+ @Test
+ public void setServiceTypeTestALaCarte() throws JsonProcessingException{
+ String requestScope = ModelType.service.toString();
+ Boolean aLaCarteFlag = true;
+ ServiceInstancesRequest sir = new ServiceInstancesRequest();
+ RequestDetails requestDetails = new RequestDetails();
+ RequestInfo requestInfo = new RequestInfo();
+ requestInfo.setSource("VID");
+ requestDetails.setRequestInfo(requestInfo);
+ sir.setRequestDetails(requestDetails);
+ Service defaultService = new Service();
+ defaultService.setServiceType("testServiceTypeALaCarte");
+
+ wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(mapper.writeValueAsString(defaultService))
+ .withStatus(HttpStatus.SC_OK)));
+
+ String serviceType = requestHandlerUtils.getServiceType(requestScope, sir, aLaCarteFlag);
+ assertEquals(serviceType, "testServiceTypeALaCarte");
+ }
+ @Test
+ public void setServiceTypeTest() throws JsonProcessingException{
+ String requestScope = ModelType.service.toString();
+ Boolean aLaCarteFlag = false;
+ ServiceInstancesRequest sir = new ServiceInstancesRequest();
+ RequestDetails requestDetails = new RequestDetails();
+ RequestInfo requestInfo = new RequestInfo();
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelVersionId("0dd91181-49da-446b-b839-cd959a96f04a");
+ requestInfo.setSource("VID");
+ requestDetails.setModelInfo(modelInfo);
+ requestDetails.setRequestInfo(requestInfo);
+ sir.setRequestDetails(requestDetails);
+ Service defaultService = new Service();
+ defaultService.setServiceType("testServiceType");
+
+ wireMockServer.stubFor(get(urlMatching(".*/service/0dd91181-49da-446b-b839-cd959a96f04a"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(mapper.writeValueAsString(defaultService))
+ .withStatus(HttpStatus.SC_OK)));
+
+ String serviceType = requestHandlerUtils.getServiceType(requestScope, sir, aLaCarteFlag);
+ assertEquals(serviceType, "testServiceType");
+ }
+ @Test
+ public void setServiceTypeTestDefault() throws JsonProcessingException{
+ String requestScope = ModelType.service.toString();
+ Boolean aLaCarteFlag = false;
+ ServiceInstancesRequest sir = new ServiceInstancesRequest();
+ RequestDetails requestDetails = new RequestDetails();
+ RequestInfo requestInfo = new RequestInfo();
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelVersionId("0dd91181-49da-446b-b839-cd959a96f04a");
+ requestInfo.setSource("VID");
+ requestDetails.setModelInfo(modelInfo);
+ requestDetails.setRequestInfo(requestInfo);
+ sir.setRequestDetails(requestDetails);
+ Service defaultService = new Service();
+ defaultService.setServiceType("testServiceType");
+
+ wireMockServer.stubFor(get(urlMatching(".*/service/0dd91181-49da-446b-b839-cd959a96f04a"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withStatus(HttpStatus.SC_NOT_FOUND)));
+ wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(mapper.writeValueAsString(defaultService))
+ .withStatus(HttpStatus.SC_OK)));
+
+ String serviceType = requestHandlerUtils.getServiceType(requestScope, sir, aLaCarteFlag);
+ assertEquals(serviceType, "testServiceType");
+ }
+ @Test
+ public void setServiceTypeTestNetwork() throws JsonProcessingException{
+ String requestScope = ModelType.network.toString();
+ Boolean aLaCarteFlag = null;
+ ServiceInstancesRequest sir = new ServiceInstancesRequest();
+ RequestDetails requestDetails = new RequestDetails();
+ RequestInfo requestInfo = new RequestInfo();
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelName("networkModelName");
+ requestInfo.setSource("VID");
+ requestDetails.setModelInfo(modelInfo);
+ requestDetails.setRequestInfo(requestInfo);
+ sir.setRequestDetails(requestDetails);
+
+ String serviceType = requestHandlerUtils.getServiceType(requestScope, sir, aLaCarteFlag);
+ assertEquals(serviceType, "networkModelName");
+ }
+ @Test
+ public void setServiceInstanceIdInstanceGroupTest() throws JsonParseException, JsonMappingException, IOException{
+ String requestScope = "instanceGroup";
+ ServiceInstancesRequest sir = mapper.readValue(inputStream("/CreateInstanceGroup.json"), ServiceInstancesRequest.class);
+ assertEquals("ddcbbf3d-f2c1-4ca0-8852-76a807285efc", requestHandlerUtils.setServiceInstanceId(requestScope, sir));
+ }
+ @Test
+ public void setServiceInstanceIdTest(){
+ String requestScope = "vnf";
+ ServiceInstancesRequest sir = new ServiceInstancesRequest();
+ sir.setServiceInstanceId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
+ assertEquals("f0a35706-efc4-4e27-80ea-a995d7a2a40f", requestHandlerUtils.setServiceInstanceId(requestScope, sir));
+ }
+ @Test
+ public void setServiceInstanceIdReturnNullTest(){
+ String requestScope = "vnf";
+ ServiceInstancesRequest sir = new ServiceInstancesRequest();
+ assertNull(requestHandlerUtils.setServiceInstanceId(requestScope, sir));
+ }
+ @Test
+ public void camundaHistoryCheckTest() throws ContactCamundaException, RequestDbFailureException{
+ wireMockServer.stubFor(get(("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBodyFile("Camunda/HistoryCheckResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ InfraActiveRequests duplicateRecord = new InfraActiveRequests();
+ duplicateRecord.setRequestId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
+ boolean inProgress = false;
+ inProgress = requestHandlerUtils.camundaHistoryCheck(duplicateRecord, null);
+ assertTrue(inProgress);
+ }
+ @Test
+ public void camundaHistoryCheckNoneFoundTest() throws ContactCamundaException, RequestDbFailureException{
+ wireMockServer.stubFor(get(("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody("[]").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ InfraActiveRequests duplicateRecord = new InfraActiveRequests();
+ duplicateRecord.setRequestId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
+ boolean inProgress = false;
+ inProgress = requestHandlerUtils.camundaHistoryCheck(duplicateRecord, null);
+ assertFalse(inProgress);
+ }
+ @Test
+ public void camundaHistoryCheckNotInProgressTest()throws ContactCamundaException, RequestDbFailureException{
+ wireMockServer.stubFor(get(("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBodyFile("Camunda/HistoryCheckResponseCompleted.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ InfraActiveRequests duplicateRecord = new InfraActiveRequests();
+ duplicateRecord.setRequestId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
+ boolean inProgress = false;
+ inProgress = requestHandlerUtils.camundaHistoryCheck(duplicateRecord, null);
+ assertFalse(inProgress);
+ }
+ @Test
+ public void setCamundaHeadersTest()throws ContactCamundaException, RequestDbFailureException{
+ String encryptedAuth = "015E7ACF706C6BBF85F2079378BDD2896E226E09D13DC2784BA309E27D59AB9FAD3A5E039DF0BB8408"; // user:password
+ String key = "07a7159d3bf51a0e53be7a8f89699be7";
+ HttpHeaders headers = requestHandlerUtils.setCamundaHeaders(encryptedAuth, key);
+ List<org.springframework.http.MediaType> acceptedType = headers.getAccept();
+ String expectedAcceptedType = "application/json";
+ assertEquals(expectedAcceptedType, acceptedType.get(0).toString());
+ String basicAuth = headers.getFirst(HttpHeaders.AUTHORIZATION);
+ String expectedBasicAuth = "Basic dXNlcjpwYXNzd29yZA==";
+ assertEquals(expectedBasicAuth, basicAuth);
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java
index 17fa011c93..52021c3587 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java
@@ -24,14 +24,11 @@ package org.onap.so.apihandlerinfra;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.onap.so.logger.HttpHeadersConstants.ONAP_REQUEST_ID;
@@ -50,8 +47,6 @@ import static org.onap.so.logger.HttpHeadersConstants.TRANSACTION_ID;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
@@ -63,20 +58,14 @@ import javax.ws.rs.core.Response;
import org.apache.http.HttpStatus;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
-import org.onap.so.apihandlerinfra.exceptions.ContactCamundaException;
-import org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException;
import org.onap.so.db.catalog.beans.Service;
import org.onap.so.db.catalog.beans.ServiceRecipe;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.logger.HttpHeadersConstants;
import org.onap.so.serviceinstancebeans.CloudConfiguration;
-import org.onap.so.serviceinstancebeans.ModelInfo;
-import org.onap.so.serviceinstancebeans.RequestDetails;
import org.onap.so.serviceinstancebeans.RequestError;
-import org.onap.so.serviceinstancebeans.RequestInfo;
import org.onap.so.serviceinstancebeans.RequestParameters;
import org.onap.so.serviceinstancebeans.RequestReferences;
import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
@@ -108,7 +97,7 @@ public class ServiceInstancesTest extends BaseTest{
@Autowired
private ServiceInstances servInstances;
-
+
@Value("${wiremock.server.port}")
private String wiremockPort;
@@ -139,7 +128,7 @@ public class ServiceInstancesTest extends BaseTest{
} catch (MalformedURLException e) {
e.printStackTrace();
}
- stubFor(post(urlMatching(".*/infraActiveRequests.*"))
+ wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests.*"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_OK)));
}
@@ -190,39 +179,7 @@ public class ServiceInstancesTest extends BaseTest{
public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod){
return sendRequest(requestJson, uriPath, reqMethod, new HttpHeaders());
}
-
- @Test
- public void test_mapJSONtoMSOStyle() throws IOException{
- ObjectMapper mapper = new ObjectMapper();
- mapper.setSerializationInclusion(Include.NON_NULL);
- String testRequest= inputStream("/ServiceInstanceDefault.json");
- String resultString = servInstances.mapJSONtoMSOStyle(testRequest, null, false, null);
- ServiceInstancesRequest sir = mapper.readValue(resultString, ServiceInstancesRequest.class);
- ModelInfo modelInfo = sir.getRequestDetails().getModelInfo();
- assertEquals("f7ce78bb-423b-11e7-93f8-0050569a796",modelInfo.getModelCustomizationUuid());
- assertEquals("modelInstanceName",modelInfo.getModelInstanceName());
- assertEquals("f7ce78bb-423b-11e7-93f8-0050569a7965",modelInfo.getModelInvariantUuid());
- assertEquals("10",modelInfo.getModelUuid());
-
- }
-
-
- @Test
- public void test_mapJSONtoMSOStyleUsePreload() throws IOException{
- ObjectMapper mapper = new ObjectMapper();
- mapper.setSerializationInclusion(Include.NON_NULL);
- String testRequest= inputStream("/ServiceInstanceDefault.json");
- ServiceInstancesRequest sir = new ServiceInstancesRequest();
- RequestDetails rd = new RequestDetails();
- RequestParameters rp = new RequestParameters();
- rp.setUsePreload(true);
- rd.setRequestParameters(rp);
- sir.setRequestDetails(rd);
- String resultString = servInstances.mapJSONtoMSOStyle(testRequest, sir, false, null);
- ServiceInstancesRequest sir1 = mapper.readValue(resultString, ServiceInstancesRequest.class);
- assertTrue(sir1.getRequestDetails().getRequestParameters().getUsePreload());
- }
-
+
@Test
public void createServiceInstanceVIDDefault() throws IOException{
TestAppender.events.clear();
@@ -237,16 +194,16 @@ public class ServiceInstancesTest extends BaseTest{
defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/service/search/.*"))
+ wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(defaultService))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
+ wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(serviceRecipe))
.withStatus(HttpStatus.SC_OK)));
@@ -306,17 +263,17 @@ public class ServiceInstancesTest extends BaseTest{
Service defaultService = new Service();
defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
- stubFor(post(urlPathEqualTo("/mso/async/services/CreateGenericALaCarteServiceInstance"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateGenericALaCarteServiceInstance"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/service/search/.*"))
+ wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(defaultService))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
+ wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(serviceRecipe))
.withStatus(HttpStatus.SC_OK)));
@@ -346,17 +303,17 @@ public class ServiceInstancesTest extends BaseTest{
defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY)));
- stubFor(get(urlMatching(".*/service/search/.*"))
+ wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(defaultService))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
+ wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(serviceRecipe))
.withStatus(HttpStatus.SC_OK)));
@@ -377,15 +334,15 @@ public class ServiceInstancesTest extends BaseTest{
Service defaultService = new Service();
defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
.willReturn(aResponse().withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY).withBody("{}")));
- stubFor(get(urlMatching(".*/service/search/.*"))
+ wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(defaultService))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
+ wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(serviceRecipe))
.withStatus(HttpStatus.SC_OK)));
@@ -406,15 +363,15 @@ public class ServiceInstancesTest extends BaseTest{
Service defaultService = new Service();
defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
.willReturn(aResponse().withFault(Fault.EMPTY_RESPONSE)));
- stubFor(get(urlMatching(".*/service/search/.*"))
+ wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(defaultService))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
+ wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(serviceRecipe))
.withStatus(HttpStatus.SC_OK)));
@@ -435,13 +392,13 @@ public class ServiceInstancesTest extends BaseTest{
Service defaultService = new Service();
defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
- stubFor(get(urlMatching(".*/service/search/.*"))
+ wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(defaultService))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/serviceRecipe/search/findFirstByServiceModelUUIDAndAction?serviceModelUUID=d88da85c-d9e8-4f73-b837-3a72a431622a&action=activateInstance"))
+ wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search/findFirstByServiceModelUUIDAndAction?serviceModelUUID=d88da85c-d9e8-4f73-b837-3a72a431622a&action=activateInstance"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_NOT_FOUND)));
@@ -452,12 +409,12 @@ public class ServiceInstancesTest extends BaseTest{
uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
Service defaultService = new Service();
defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
- stubFor(get(urlMatching(".*/service/search/.*"))
+ wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(defaultService))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/serviceRecipe/search/.*"))
+ wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search/.*"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_NOT_FOUND)));
@@ -476,16 +433,16 @@ public class ServiceInstancesTest extends BaseTest{
Service defaultService = new Service();
defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/service/search/.*"))
+ wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(defaultService))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
+ wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(serviceRecipe))
.withStatus(HttpStatus.SC_OK)));
@@ -514,21 +471,21 @@ public class ServiceInstancesTest extends BaseTest{
Service defaultService = new Service();
defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/service/.*"))
+ wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(defaultService))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/service/search/.*"))
+ wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(defaultService))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
+ wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(serviceRecipe))
.withStatus(HttpStatus.SC_OK)));
@@ -557,21 +514,21 @@ public class ServiceInstancesTest extends BaseTest{
Service defaultService = new Service();
defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/service/.*"))
+ wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(defaultService))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/service/search/.*"))
+ wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(defaultService))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
+ wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(serviceRecipe))
.withStatus(HttpStatus.SC_OK)));
@@ -599,21 +556,21 @@ public class ServiceInstancesTest extends BaseTest{
Service defaultService = new Service();
defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/service/.*"))
+ wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(defaultService))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/service/search/.*"))
+ wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(defaultService))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
+ wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(serviceRecipe))
.withStatus(HttpStatus.SC_OK)));
@@ -642,21 +599,21 @@ public class ServiceInstancesTest extends BaseTest{
Service defaultService = new Service();
defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/service/.*"))
+ wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(defaultService))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/service/search/.*"))
+ wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(defaultService))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
+ wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(serviceRecipe))
.withStatus(HttpStatus.SC_OK)));
@@ -675,7 +632,7 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void createPortConfiguration() throws IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
//expected response
@@ -701,7 +658,7 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void deletePortConfiguration() throws IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
@@ -720,7 +677,7 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void enablePort() throws IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
//expected response
@@ -738,7 +695,7 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void disablePort() throws IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
//expected response
@@ -756,7 +713,7 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void activatePort() throws IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
//expected response
@@ -774,7 +731,7 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void deactivatePort() throws IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
//expected response
@@ -792,7 +749,7 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void addRelationships() throws IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
//expected response
@@ -810,7 +767,7 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void removeRelationships() throws IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
//expected response
@@ -828,22 +785,22 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void createVnfInstanceNoALaCarte() throws IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671"))
+ wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_ReplaceVnf_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671/vnfResources"))
+ wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671/vnfResources"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vnfResources_ReplaceVnf_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=createInstance"))
+ wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=createInstance"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vnfRecipeReplaceInstance_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
@@ -863,26 +820,26 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void createVnfInstance() throws IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/service/5df8b6de-2083-11e7-93ae-92361f002672"))
+ wireMockServer.stubFor(get(urlMatching(".*/service/5df8b6de-2083-11e7-93ae-92361f002672"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("serviceVnf_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/service/5df8b6de-2083-11e7-93ae-92361f002672/vnfCustomizations"))
+ wireMockServer.stubFor(get(urlMatching(".*/service/5df8b6de-2083-11e7-93ae-92361f002672/vnfCustomizations"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationsList_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002672/vnfResources"))
+ wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002672/vnfResources"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vnfResourcesCreateVnf_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=createInstance"))
+ wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=createInstance"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vnfRecipeCreateInstance_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
@@ -919,21 +876,21 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void replaceVnfInstance() throws IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671"))
+ wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_ReplaceVnf_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671/vnfResources"))
+ wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671/vnfResources"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vnfResources_ReplaceVnf_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=replaceInstance"))
+ wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=replaceInstance"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vnfRecipeReplaceInstance_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
@@ -952,21 +909,21 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void replaceVnfRecreateInstance() throws IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/RecreateInfraVce"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/RecreateInfraVce"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674"))
+ wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vnfResources"))
+ wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vnfResources"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=TEST&action=replaceInstance"))
+ wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=TEST&action=replaceInstance"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vnfRecipe_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
@@ -987,21 +944,21 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void recreateVnfInstance() throws IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674"))
+ wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vnfResources"))
+ wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vnfResources"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=recreateInstance"))
+ wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=recreateInstance"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vnfRecipe_ResponseWorkflowAction.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
@@ -1022,21 +979,21 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void updateVnfInstance() throws IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674"))
+ wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vnfResources"))
+ wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vnfResources"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction" +
+ wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction" +
"[?]nfRole=GR-API-DEFAULT&action=updateInstance"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("UpdateVnfRecipe_Response.json"))
@@ -1057,12 +1014,12 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void applyUpdatedConfig() throws IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/VnfConfigUpdate"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/VnfConfigUpdate"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction" +
+ wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction" +
"[?]nfRole=GR-API-DEFAULT&action=applyUpdatedConfig"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vnfRecipeApplyUpdatedConfig_Response.json"))
@@ -1083,11 +1040,11 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void deleteVnfInstanceV5() throws IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction" +
+ wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction" +
"[?]nfRole=GR-API-DEFAULT&action=deleteInstance"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vnfRecipeDelete_Response.json"))
@@ -1107,26 +1064,26 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void createVfModuleInstance() throws IOException {
- stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671"))
+ wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671/vfModule"))
+ wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671/vfModule"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
+ wireMockServer.stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
+ wireMockServer.stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
"[?]vfModuleModelUUID=20c4431c-246d-11e7-93ae-92361f002671&vnfComponentType=vfModule&action=createInstance"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vnfComponentRecipe_Response.json"))
@@ -1147,44 +1104,44 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void createVfModuleInstanceNoModelCustomization() throws IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fe"))
+ wireMockServer.stubFor(get(urlMatching(".*/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fe"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources" +
+ wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources" +
"[?]modelInstanceName=test&vnfResourceModelUUID=fe6478e4-ea33-3346-ac12-ab121484a3fe"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationForVfModule_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002673/vfModuleCustomizations"))
+ wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002673/vfModuleCustomizations"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vfModuleCustomization/search/findByModelCustomizationUUIDAndVfModuleModelUUID[?]" +
+ wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/search/findByModelCustomizationUUIDAndVfModuleModelUUID[?]" +
"modelCustomizationUUID=b4ea86b4-253f-11e7-93ae-92361f002672&vfModuleModelUUID=066de97e-253e-11e7-93ae-92361f002672"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationPCM_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672/vfModule"))
+ wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672/vfModule"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vfModule/066de97e-253e-11e7-93ae-92361f002672"))
+ wireMockServer.stubFor(get(urlMatching(".*/vfModule/066de97e-253e-11e7-93ae-92361f002672"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVnfComponentTypeAndAction" +
+ wireMockServer.stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVnfComponentTypeAndAction" +
"[?]vnfComponentType=vfModule&action=createInstance"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVNF_API_Response.json"))
@@ -1205,41 +1162,41 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void deleteVfModuleInstanceNoMatchingModelUUD() throws IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vnfResource/.*"))
+ wireMockServer.stubFor(get(urlMatching(".*/vnfResource/.*"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources.*"))
+ wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources.*"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationForVfModule_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002673/vfModuleCustomizations"))
+ wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002673/vfModuleCustomizations"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672"))
+ wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationPCM_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672/vfModule"))
+ wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672/vfModule"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vfModule/066de97e-253e-11e7-93ae-92361f002672"))
+ wireMockServer.stubFor(get(urlMatching(".*/vfModule/066de97e-253e-11e7-93ae-92361f002672"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
+ wireMockServer.stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
"[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeleteVfModule_Response.json"))
@@ -1263,23 +1220,23 @@ public class ServiceInstancesTest extends BaseTest{
@Test
public void createVfModuleInstanceNoRecipe() throws IOException {
- stubFor(get(urlMatching(".*/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fe"))
+ wireMockServer.stubFor(get(urlMatching(".*/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fe"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources" +
+ wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources" +
"[?]modelInstanceName=test&vnfResourceModelUUID=fe6478e4-ea33-3346-ac12-ab121484a3fe"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationForVfModule_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002673/vfModuleCustomizations"))
+ wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002673/vfModuleCustomizations"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vfModuleCustomization/search/findByModelCustomizationUUIDAndVfModuleModelUUID[?]" +
+ wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/search/findByModelCustomizationUUIDAndVfModuleModelUUID[?]" +
"modelCustomizationUUID=b4ea86b4-253f-11e7-93ae-92361f002672&vfModuleModelUUID=066de97e-253e-11e7-93ae-92361f002672"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationPCM_Response.json"))
@@ -1294,17 +1251,17 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void replaceVfModuleInstance() throws IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]" +
+ wireMockServer.stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]" +
"modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
+ wireMockServer.stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
"[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=replaceInstance"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeleteVfModule_Response.json"))
@@ -1324,26 +1281,26 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void updateVfModuleInstance() throws IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671"))
+ wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671/vfModule"))
+ wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671/vfModule"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
+ wireMockServer.stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
+ wireMockServer.stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
"[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=updateInstance"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vnfComponentRecipe_GRAPI_Response.json"))
@@ -1389,11 +1346,11 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void inPlaceSoftwareUpdate() throws IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/VnfInPlaceUpdate"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/VnfInPlaceUpdate"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]" +
+ wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]" +
"nfRole=GR-API-DEFAULT&action=inPlaceSoftwareUpdate"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vnfRecipeInPlaceUpdate_Response.json"))
@@ -1415,17 +1372,17 @@ public class ServiceInstancesTest extends BaseTest{
@Test
public void deleteVfModuleInstance() throws IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]" +
+ wireMockServer.stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]" +
"modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
+ wireMockServer.stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
"[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeleteVfModule_Response.json"))
@@ -1446,11 +1403,11 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void deleteVfModuleNoModelInvariantId() throws IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
+ wireMockServer.stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
"[?]vfModuleModelUUID=VNF-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeleteVfModule_Response.json"))
@@ -1471,17 +1428,17 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void deactivateAndCloudDeleteVfModuleInstance() throws IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]" +
+ wireMockServer.stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]" +
"modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
+ wireMockServer.stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
"[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deactivateAndCloudDelete"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeactivate_Response.json"))
@@ -1502,21 +1459,21 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void createVolumeGroupInstance() throws IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671"))
+ wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671/vfModule"))
+ wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671/vfModule"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
+ wireMockServer.stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
"[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=createInstance"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVolGrp_GRAPI_Response.json"))
@@ -1538,21 +1495,21 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void updateVolumeGroupInstance() throws IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671"))
+ wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671/vfModule"))
+ wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671/vfModule"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
+ wireMockServer.stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
"[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=updateInstance"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVolGrp_GRAPI_Response.json"))
@@ -1573,25 +1530,25 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void deleteVolumeGroupInstance() throws IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671"))
+ wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671/vfModule"))
+ wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671/vfModule"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
+ wireMockServer.stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
"[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=deleteInstance"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVolGrp_GRAPI_Response.json"))
@@ -1612,21 +1569,21 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void createNetworkInstance() throws IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
+ wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
+ wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
+ wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
"modelName=GR-API-DEFAULT&action=createInstance"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
@@ -1647,21 +1604,21 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void updateNetworkInstance() throws IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
+ wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
+ wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
+ wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
"modelName=GR-API-DEFAULT&action=updateInstance"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
@@ -1682,21 +1639,21 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void deleteNetworkInstance() throws IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
+ wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
+ wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
+ wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
"modelName=VNF-API-DEFAULT&action=deleteInstance"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
@@ -1717,11 +1674,11 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void deleteNetworkInstanceNoReqParams() throws IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
+ wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
"modelName=GR-API-DEFAULT&action=deleteInstance"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
@@ -1771,7 +1728,7 @@ public class ServiceInstancesTest extends BaseTest{
@Test
public void creatServiceInstanceGRTestApiNoCustomRecipeFound() throws IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
@@ -1784,12 +1741,12 @@ public class ServiceInstancesTest extends BaseTest{
Service defaultService = new Service();
defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
- stubFor(get(urlMatching(".*/service/.*"))
+ wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(defaultService))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
+ wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(serviceRecipe))
.withStatus(HttpStatus.SC_OK)));
@@ -1811,21 +1768,21 @@ public class ServiceInstancesTest extends BaseTest{
@Test
public void createNetworkInstanceTestApiUndefinedUsePropertiesDefault() throws IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
+ wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
+ wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
+ wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
"modelName=GR-API-DEFAULT&action=createInstance"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
@@ -1848,7 +1805,7 @@ public class ServiceInstancesTest extends BaseTest{
@Test
public void createNetworkInstanceTestApiIncorrectUsePropertiesDefault() throws IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
@@ -1866,21 +1823,21 @@ public class ServiceInstancesTest extends BaseTest{
@Test
public void createNetworkInstanceTestApiGrApi() throws IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
+ wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
+ wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
+ wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
"modelName=GR-API-DEFAULT&action=createInstance"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
@@ -1903,21 +1860,21 @@ public class ServiceInstancesTest extends BaseTest{
@Test
public void createNetworkInstanceTestApiVnfApi() throws IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/CreateNetworkInstance"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateNetworkInstance"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
+ wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
+ wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
+ wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
"modelName=VNF-API-DEFAULT&action=createInstance"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("networkRecipeVNF_API_Response.json"))
@@ -1949,16 +1906,16 @@ public class ServiceInstancesTest extends BaseTest{
Service defaultService = new Service();
defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/service/.*"))
+ wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(defaultService))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
+ wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(serviceRecipe))
.withStatus(HttpStatus.SC_OK)));
@@ -2000,16 +1957,16 @@ public class ServiceInstancesTest extends BaseTest{
Service defaultService = new Service();
defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponseInvalid2.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/service/.*"))
+ wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(defaultService))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
+ wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(serviceRecipe))
.withStatus(HttpStatus.SC_OK)));
@@ -2033,16 +1990,16 @@ public class ServiceInstancesTest extends BaseTest{
Service defaultService = new Service();
defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/UnauthorizedResponse.json").withStatus(org.apache.http.HttpStatus.SC_UNAUTHORIZED)));
- stubFor(get(urlMatching(".*/service/.*"))
+ wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(defaultService))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
+ wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(serviceRecipe))
.withStatus(HttpStatus.SC_OK)));
@@ -2067,16 +2024,16 @@ public class ServiceInstancesTest extends BaseTest{
Service defaultService = new Service();
defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/service/.*"))
+ wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(defaultService))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
+ wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(serviceRecipe))
.withStatus(HttpStatus.SC_OK)));
@@ -2099,20 +2056,20 @@ public class ServiceInstancesTest extends BaseTest{
Service defaultService = new Service();
defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
- stubFor(post(urlPathEqualTo("/mso/async/services/CreateMacroServiceNetworkVnf"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateMacroServiceNetworkVnf"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/service/.*"))
+ wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(defaultService))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
+ wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(serviceRecipe))
.withStatus(HttpStatus.SC_OK)));
@@ -2168,32 +2125,32 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void scaleOutVfModule() throws IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671"))
+ wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671/vfModule"))
+ wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671/vfModule"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
+ wireMockServer.stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
+ wireMockServer.stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
"[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=scaleOut"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVfModuleScaleOut_Response.json")).withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vfModule/search/findByModelInvariantUUIDOrderByModelVersionDesc[?]modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671"))
+ wireMockServer.stubFor(get(urlMatching(".*/vfModule/search/findByModelInvariantUUIDOrderByModelVersionDesc[?]modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vfModulesListByInvariantId_Response.json")).withStatus(org.apache.http.HttpStatus.SC_OK)));
@@ -2222,16 +2179,16 @@ public class ServiceInstancesTest extends BaseTest{
Service defaultService = new Service();
defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestBadResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/service/.*"))
+ wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(defaultService))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
+ wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(serviceRecipe))
.withStatus(HttpStatus.SC_OK)));
@@ -2245,7 +2202,7 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void createServiceInstanceDuplicateError() throws IOException{
- stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
+ wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
@@ -2258,11 +2215,11 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void createServiceInstanceDuplicateHistoryCheck() throws IOException{
- stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
+ wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("InfraActiveRequests/createInfraActiveRequests.json")
.withStatus(HttpStatus.SC_ACCEPTED)));
- stubFor(get(("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
+ wireMockServer.stubFor(get(("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/HistoryCheckResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
@@ -2275,11 +2232,11 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void createServiceInstanceDuplicateHistoryCheckException() throws IOException{
- stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
+ wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("InfraActiveRequests/createInfraActiveRequests.json")
.withStatus(HttpStatus.SC_ACCEPTED)));
- stubFor(get(("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
+ wireMockServer.stubFor(get(("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(org.apache.http.HttpStatus.SC_INTERNAL_SERVER_ERROR)));
@@ -2292,7 +2249,7 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void createServiceInstanceDuplicate() throws IOException{
- stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
+ wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
@@ -2314,15 +2271,15 @@ public class ServiceInstancesTest extends BaseTest{
serviceRecipe.setRecipeTimeout(180);
Service defaultService = new Service();
defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
- stubFor(post(urlMatching(".*/infraActiveRequests/"))
+ wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
- stubFor(get(urlMatching(".*/service/.*"))
+ wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(defaultService))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
+ wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(serviceRecipe))
.withStatus(HttpStatus.SC_OK)));
@@ -2336,10 +2293,10 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void createPortConfigurationSaveError() throws IOException {
- stubFor(post(urlMatching(".*/infraActiveRequests/"))
+ wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
- stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
@@ -2352,7 +2309,7 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void createPortConfigDbUpdateError() throws IOException {
- stubFor(post(urlMatching(".*/infraActiveRequests/"))
+ wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
@@ -2366,21 +2323,21 @@ public class ServiceInstancesTest extends BaseTest{
@Test
public void vnfUpdateWithNetworkInstanceGroup() throws IOException{
TestAppender.events.clear();
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vnfResourceCustomization/2ccae1b4-7d9e-46fa-a452-9180ce008d17"))
+ wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/2ccae1b4-7d9e-46fa-a452-9180ce008d17"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vnfResources"))
+ wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vnfResources"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
.withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction" +
+ wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction" +
"[?]nfRole=GR-API-DEFAULT&action=updateInstance"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("UpdateVnfRecipe_Response.json"))
@@ -2411,7 +2368,7 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void createInstanceGroup() throws IOException{
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
@@ -2431,7 +2388,7 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void deleteInstanceGroup() throws IOException{
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
@@ -2490,7 +2447,7 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void addMembers() throws IOException{
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
//expect
@@ -2509,7 +2466,7 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void removeMembers() throws IOException{
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
//expect
@@ -2528,15 +2485,15 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void deleteNetworkInstanceNoCustomizationEntry() throws IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
+ wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_NOT_FOUND)));
- stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
+ wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
"modelName=VNF-API-DEFAULT&action=deleteInstance"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
@@ -2557,7 +2514,7 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void updateNetworkInstanceNoCustomizationEntry() throws IOException {
- stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
+ wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_NOT_FOUND)));
@@ -2569,160 +2526,5 @@ public class ServiceInstancesTest extends BaseTest{
assertEquals(realResponse.getServiceException().getText(), "No valid modelCustomizationId for networkResourceCustomization lookup is specified");
}
- @Test
- public void setServiceTypeTestALaCarte() throws JsonProcessingException{
- String requestScope = ModelType.service.toString();
- Boolean aLaCarteFlag = true;
- ServiceInstancesRequest sir = new ServiceInstancesRequest();
- RequestDetails requestDetails = new RequestDetails();
- RequestInfo requestInfo = new RequestInfo();
- requestInfo.setSource("VID");
- requestDetails.setRequestInfo(requestInfo);
- sir.setRequestDetails(requestDetails);
- Service defaultService = new Service();
- defaultService.setServiceType("testServiceTypeALaCarte");
-
- stubFor(get(urlMatching(".*/service/search/.*"))
- .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
- .withBody(mapper.writeValueAsString(defaultService))
- .withStatus(HttpStatus.SC_OK)));
-
- String serviceType = servInstances.getServiceType(requestScope, sir, aLaCarteFlag);
- assertEquals(serviceType, "testServiceTypeALaCarte");
- }
- @Test
- public void setServiceTypeTest() throws JsonProcessingException{
- String requestScope = ModelType.service.toString();
- Boolean aLaCarteFlag = false;
- ServiceInstancesRequest sir = new ServiceInstancesRequest();
- RequestDetails requestDetails = new RequestDetails();
- RequestInfo requestInfo = new RequestInfo();
- ModelInfo modelInfo = new ModelInfo();
- modelInfo.setModelVersionId("0dd91181-49da-446b-b839-cd959a96f04a");
- requestInfo.setSource("VID");
- requestDetails.setModelInfo(modelInfo);
- requestDetails.setRequestInfo(requestInfo);
- sir.setRequestDetails(requestDetails);
- Service defaultService = new Service();
- defaultService.setServiceType("testServiceType");
-
- stubFor(get(urlMatching(".*/service/0dd91181-49da-446b-b839-cd959a96f04a"))
- .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
- .withBody(mapper.writeValueAsString(defaultService))
- .withStatus(HttpStatus.SC_OK)));
-
- String serviceType = servInstances.getServiceType(requestScope, sir, aLaCarteFlag);
- assertEquals(serviceType, "testServiceType");
- }
- @Test
- public void setServiceTypeTestDefault() throws JsonProcessingException{
- String requestScope = ModelType.service.toString();
- Boolean aLaCarteFlag = false;
- ServiceInstancesRequest sir = new ServiceInstancesRequest();
- RequestDetails requestDetails = new RequestDetails();
- RequestInfo requestInfo = new RequestInfo();
- ModelInfo modelInfo = new ModelInfo();
- modelInfo.setModelVersionId("0dd91181-49da-446b-b839-cd959a96f04a");
- requestInfo.setSource("VID");
- requestDetails.setModelInfo(modelInfo);
- requestDetails.setRequestInfo(requestInfo);
- sir.setRequestDetails(requestDetails);
- Service defaultService = new Service();
- defaultService.setServiceType("testServiceType");
-
- stubFor(get(urlMatching(".*/service/0dd91181-49da-446b-b839-cd959a96f04a"))
- .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
- .withStatus(HttpStatus.SC_NOT_FOUND)));
- stubFor(get(urlMatching(".*/service/search/.*"))
- .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
- .withBody(mapper.writeValueAsString(defaultService))
- .withStatus(HttpStatus.SC_OK)));
-
- String serviceType = servInstances.getServiceType(requestScope, sir, aLaCarteFlag);
- assertEquals(serviceType, "testServiceType");
- }
- @Test
- public void setServiceTypeTestNetwork() throws JsonProcessingException{
- String requestScope = ModelType.network.toString();
- Boolean aLaCarteFlag = null;
- ServiceInstancesRequest sir = new ServiceInstancesRequest();
- RequestDetails requestDetails = new RequestDetails();
- RequestInfo requestInfo = new RequestInfo();
- ModelInfo modelInfo = new ModelInfo();
- modelInfo.setModelName("networkModelName");
- requestInfo.setSource("VID");
- requestDetails.setModelInfo(modelInfo);
- requestDetails.setRequestInfo(requestInfo);
- sir.setRequestDetails(requestDetails);
-
- String serviceType = servInstances.getServiceType(requestScope, sir, aLaCarteFlag);
- assertEquals(serviceType, "networkModelName");
- }
- @Test
- public void setServiceInstanceIdInstanceGroupTest() throws JsonParseException, JsonMappingException, IOException{
- String requestScope = "instanceGroup";
- ServiceInstancesRequest sir = mapper.readValue(inputStream("/CreateInstanceGroup.json"), ServiceInstancesRequest.class);
- assertEquals("ddcbbf3d-f2c1-4ca0-8852-76a807285efc", servInstances.setServiceInstanceId(requestScope, sir));
- }
- @Test
- public void setServiceInstanceIdTest(){
- String requestScope = "vnf";
- ServiceInstancesRequest sir = new ServiceInstancesRequest();
- sir.setServiceInstanceId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
- assertEquals("f0a35706-efc4-4e27-80ea-a995d7a2a40f", servInstances.setServiceInstanceId(requestScope, sir));
- }
- @Test
- public void setServiceInstanceIdReturnNullTest(){
- String requestScope = "vnf";
- ServiceInstancesRequest sir = new ServiceInstancesRequest();
- assertNull(servInstances.setServiceInstanceId(requestScope, sir));
- }
- @Test
- public void camundaHistoryCheckTest() throws ContactCamundaException, RequestDbFailureException{
- stubFor(get(("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
- .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
- .withBodyFile("Camunda/HistoryCheckResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
-
- InfraActiveRequests duplicateRecord = new InfraActiveRequests();
- duplicateRecord.setRequestId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
- boolean inProgress = false;
- inProgress = servInstances.camundaHistoryCheck(duplicateRecord, null);
- assertTrue(inProgress);
- }
- @Test
- public void camundaHistoryCheckNoneFoundTest() throws ContactCamundaException, RequestDbFailureException{
- stubFor(get(("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
- .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
- .withBody("[]").withStatus(org.apache.http.HttpStatus.SC_OK)));
-
- InfraActiveRequests duplicateRecord = new InfraActiveRequests();
- duplicateRecord.setRequestId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
- boolean inProgress = false;
- inProgress = servInstances.camundaHistoryCheck(duplicateRecord, null);
- assertFalse(inProgress);
- }
- @Test
- public void camundaHistoryCheckNotInProgressTest()throws ContactCamundaException, RequestDbFailureException{
- stubFor(get(("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
- .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
- .withBodyFile("Camunda/HistoryCheckResponseCompleted.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
-
- InfraActiveRequests duplicateRecord = new InfraActiveRequests();
- duplicateRecord.setRequestId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
- boolean inProgress = false;
- inProgress = servInstances.camundaHistoryCheck(duplicateRecord, null);
- assertFalse(inProgress);
- }
- @Test
- public void setCamundaHeadersTest()throws ContactCamundaException, RequestDbFailureException{
- String encryptedAuth = "015E7ACF706C6BBF85F2079378BDD2896E226E09D13DC2784BA309E27D59AB9FAD3A5E039DF0BB8408"; // user:password
- String key = "07a7159d3bf51a0e53be7a8f89699be7";
- HttpHeaders headers = servInstances.setCamundaHeaders(encryptedAuth, key);
- List<org.springframework.http.MediaType> acceptedType = headers.getAccept();
- String expectedAcceptedType = "application/json";
- assertEquals(expectedAcceptedType, acceptedType.get(0).toString());
- String basicAuth = headers.getFirst(HttpHeaders.AUTHORIZATION);
- String expectedBasicAuth = "Basic dXNlcjpwYXNzd29yZA==";
- assertEquals(expectedBasicAuth, basicAuth);
- }
+
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/TasksHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/TasksHandlerTest.java
index 5c6fd31422..327141e0f2 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/TasksHandlerTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/TasksHandlerTest.java
@@ -23,7 +23,6 @@ package org.onap.so.apihandlerinfra;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertEquals;
@@ -60,10 +59,10 @@ public class TasksHandlerTest extends BaseTest{
@Test
public void getTasksTestByOriginalRequestId() throws ParseException, JSONException, JsonParseException, JsonMappingException, IOException{
- stubFor(post(urlPathEqualTo("/sobpmnengine/task"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/sobpmnengine/task"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("Camunda/GetTaskResponse.json").withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlPathEqualTo("/sobpmnengine/task/b5fa707a-f55a-11e7-a796-005056856d52/variables"))
+ wireMockServer.stubFor(get(urlPathEqualTo("/sobpmnengine/task/b5fa707a-f55a-11e7-a796-005056856d52/variables"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("Camunda/GetTaskVariablesResponse.json").withStatus(HttpStatus.SC_OK)));
String requestId = "4f6fe9ac-800c-4540-a93e-10d179fa1b0a";
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestrationTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestrationTest.java
index 1e11b74215..5c5a9e92b3 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestrationTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestrationTest.java
@@ -20,7 +20,19 @@
package org.onap.so.apihandlerinfra.tenantisolation;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.IOException;
+
+import javax.ws.rs.core.MediaType;
+
import org.apache.http.HttpStatus;
import org.junit.Before;
import org.junit.Ignore;
@@ -36,13 +48,7 @@ import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.web.util.UriComponentsBuilder;
-import javax.ws.rs.core.MediaType;
-import java.io.File;
-import java.io.IOException;
-
-import static com.github.tomakehurst.wiremock.client.WireMock.*;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import com.fasterxml.jackson.databind.ObjectMapper;
public class CloudOrchestrationTest extends BaseTest {
@@ -53,7 +59,7 @@ public class CloudOrchestrationTest extends BaseTest {
@Before
public void setupTestClass() throws Exception{
- stubFor(post(urlPathEqualTo(getTestUrl(""))).willReturn(aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withStatus(HttpStatus.SC_CREATED)));
+ wireMockServer.stubFor(post(urlPathEqualTo(getTestUrl(""))).willReturn(aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withStatus(HttpStatus.SC_CREATED)));
}
@Test
@@ -95,7 +101,7 @@ public class CloudOrchestrationTest extends BaseTest {
@Test
public void testCreateOpEnvReqRecordDuplicateCheck() throws IOException {
- stubFor(post(urlPathEqualTo(getTestUrl("checkInstanceNameDuplicate"))).withRequestBody(equalTo("{\"instanceIdMap\":null,\"instanceName\":\"myOpEnv\",\"requestScope\":\"operationalEnvironment\"}")).willReturn(aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ wireMockServer.stubFor(post(urlPathEqualTo(getTestUrl("checkInstanceNameDuplicate"))).withRequestBody(equalTo("{\"instanceIdMap\":null,\"instanceName\":\"myOpEnv\",\"requestScope\":\"operationalEnvironment\"}")).willReturn(aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(String.format(getResponseTemplate, "123", "PENDING"))
.withStatus(HttpStatus.SC_OK)));
ObjectMapper mapper = new ObjectMapper();
@@ -124,7 +130,7 @@ public class CloudOrchestrationTest extends BaseTest {
HttpEntity<TenantIsolationRequest> entity = new HttpEntity<TenantIsolationRequest>(request, headers);
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(path) + "/operationalEnvironments");
- stubFor(post(urlPathEqualTo(getTestUrl("checkInstanceNameDuplicate"))).withRequestBody(equalTo("{\"instanceIdMap\":null,\"instanceName\":\"myOpEnv\",\"requestScope\":\"operationalEnvironment\"}")).willReturn(aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ wireMockServer.stubFor(post(urlPathEqualTo(getTestUrl("checkInstanceNameDuplicate"))).withRequestBody(equalTo("{\"instanceIdMap\":null,\"instanceName\":\"myOpEnv\",\"requestScope\":\"operationalEnvironment\"}")).willReturn(aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_NOT_FOUND)));
ResponseEntity<String> response = restTemplate.exchange(
builder.toUriString(),
@@ -134,7 +140,7 @@ public class CloudOrchestrationTest extends BaseTest {
@Test
public void testCreateVNFDuplicateCheck() throws IOException {
- stubFor(post(urlPathEqualTo(getTestUrl("checkInstanceNameDuplicate"))).withRequestBody(equalTo("{\"instanceIdMap\":null,\"instanceName\":\"myVnfOpEnv\",\"requestScope\":\"operationalEnvironment\"}")).willReturn(aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ wireMockServer.stubFor(post(urlPathEqualTo(getTestUrl("checkInstanceNameDuplicate"))).withRequestBody(equalTo("{\"instanceIdMap\":null,\"instanceName\":\"myVnfOpEnv\",\"requestScope\":\"operationalEnvironment\"}")).willReturn(aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(String.format(getResponseTemplate, "requestId", Status.IN_PROGRESS.toString()))
.withStatus(HttpStatus.SC_OK)));
ObjectMapper mapper = new ObjectMapper();
@@ -160,7 +166,7 @@ public class CloudOrchestrationTest extends BaseTest {
HttpEntity<TenantIsolationRequest> entity = new HttpEntity<TenantIsolationRequest>(request, headers);
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(path) + "/operationalEnvironments");
- stubFor(post(urlPathEqualTo(getTestUrl("checkInstanceNameDuplicate"))).withRequestBody(equalTo("{\"instanceIdMap\":null,\"instanceName\":\"myVnfOpEnv\",\"requestScope\":\"operationalEnvironment\"}")).willReturn(aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ wireMockServer.stubFor(post(urlPathEqualTo(getTestUrl("checkInstanceNameDuplicate"))).withRequestBody(equalTo("{\"instanceIdMap\":null,\"instanceName\":\"myVnfOpEnv\",\"requestScope\":\"operationalEnvironment\"}")).willReturn(aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_NOT_FOUND)));
ResponseEntity<String> response = restTemplate.exchange(
@@ -178,10 +184,10 @@ public class CloudOrchestrationTest extends BaseTest {
HttpEntity<TenantIsolationRequest> entity = new HttpEntity<TenantIsolationRequest>(request, headers);
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(path) + "/operationalEnvironments/ff3514e3-5a33-55df-13ab-12abad84e7ff/activate");
- stubFor(post(urlPathEqualTo(getTestUrl("checkInstanceNameDuplicate"))).withRequestBody(equalTo("{\"instanceIdMap\":{\"operationalEnvironmentId\":\"ff3514e3-5a33-55df-13ab-12abad84e7ff\"},\"instanceName\":\"myVnfOpEnv\",\"requestScope\":\"operationalEnvironment\"}")).willReturn(aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ wireMockServer.stubFor(post(urlPathEqualTo(getTestUrl("checkInstanceNameDuplicate"))).withRequestBody(equalTo("{\"instanceIdMap\":{\"operationalEnvironmentId\":\"ff3514e3-5a33-55df-13ab-12abad84e7ff\"},\"instanceName\":\"myVnfOpEnv\",\"requestScope\":\"operationalEnvironment\"}")).willReturn(aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_NOT_FOUND)));
- stubFor(get(urlPathEqualTo(getTestUrl("checkVnfIdStatus/ff3514e3-5a33-55df-13ab-12abad84e7ff"))).willReturn(aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ wireMockServer.stubFor(get(urlPathEqualTo(getTestUrl("checkVnfIdStatus/ff3514e3-5a33-55df-13ab-12abad84e7ff"))).willReturn(aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_OK)));
ResponseEntity<String> response = restTemplate.exchange(
@@ -201,10 +207,10 @@ public class CloudOrchestrationTest extends BaseTest {
HttpEntity<TenantIsolationRequest> entity = new HttpEntity<TenantIsolationRequest>(request, headers);
-// stubFor(post(urlPathEqualTo(getTestUrl("checkInstanceNameDuplicate"))).withRequestBody(equalTo("{\"instanceIdMap\":{\"operationalEnvironmentId\":\"ff3514e3-5a33-55df-13ab-12abad84e7fa\"},\"instanceName\":null,\"requestScope\":\"operationalEnvironment\"}")).willReturn(aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+// wireMockServer.stubFor(post(urlPathEqualTo(getTestUrl("checkInstanceNameDuplicate"))).withRequestBody(equalTo("{\"instanceIdMap\":{\"operationalEnvironmentId\":\"ff3514e3-5a33-55df-13ab-12abad84e7fa\"},\"instanceName\":null,\"requestScope\":\"operationalEnvironment\"}")).willReturn(aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
// .withBodyFile((String.format(getResponseTemplate, "ff3514e3-5a33-55df-13ab-12abad84e7fa", Status.COMPLETE.toString()))).withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlPathEqualTo(getTestUrl("checkVnfIdStatus/ff3514e3-5a33-55df-13ab-12abad84e7fa"))).willReturn(aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ wireMockServer.stubFor(get(urlPathEqualTo(getTestUrl("checkVnfIdStatus/ff3514e3-5a33-55df-13ab-12abad84e7fa"))).willReturn(aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_OK)));
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(path) + "/operationalEnvironments/ff3514e3-5a33-55df-13ab-12abad84e7fa/deactivate");
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestrationTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestrationTest.java
index 8ac84d6598..c119653ae3 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestrationTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestrationTest.java
@@ -20,6 +20,17 @@
package org.onap.so.apihandlerinfra.tenantisolation;
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.text.ParseException;
+
+import javax.ws.rs.core.MediaType;
+
import org.apache.http.HttpStatus;
import org.junit.Before;
import org.junit.Test;
@@ -31,13 +42,6 @@ import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.web.util.UriComponentsBuilder;
-import javax.ws.rs.core.MediaType;
-import java.text.ParseException;
-
-import static com.github.tomakehurst.wiremock.client.WireMock.*;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
public class CloudResourcesOrchestrationTest extends BaseTest{
@@ -47,7 +51,7 @@ public class CloudResourcesOrchestrationTest extends BaseTest{
HttpHeaders headers = new HttpHeaders();
@Before
public void setupTestClass() throws Exception{
- stubFor(post(urlPathEqualTo(getTestUrl(""))).willReturn(aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withStatus(HttpStatus.SC_CREATED)));
+ wireMockServer.stubFor(post(urlPathEqualTo(getTestUrl(""))).willReturn(aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withStatus(HttpStatus.SC_CREATED)));
}
@Test
public void testUnlockFailObjectMapping() {
@@ -120,7 +124,7 @@ public class CloudResourcesOrchestrationTest extends BaseTest{
@Test
public void testGetInfraActiveRequestNull() {
- stubFor(get(urlPathEqualTo(getTestUrl("request-id-null-check"))).willReturn(aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ wireMockServer.stubFor(get(urlPathEqualTo(getTestUrl("request-id-null-check"))).willReturn(aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_OK)));
headers.set("Accept", MediaType.APPLICATION_JSON);
headers.set("Content-Type", MediaType.APPLICATION_JSON);
@@ -139,7 +143,7 @@ public class CloudResourcesOrchestrationTest extends BaseTest{
@Test
public void testUnlock() throws ParseException {
- stubFor(get(urlPathEqualTo(getTestUrl("requestIdtestUnlock"))).willReturn(aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ wireMockServer.stubFor(get(urlPathEqualTo(getTestUrl("requestIdtestUnlock"))).willReturn(aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(String.format(getResponseTemplate, "requestIdtestUnlock", "IN_PROGRESS"))
.withStatus(HttpStatus.SC_OK)));
headers.set("Accept", MediaType.APPLICATION_JSON);
@@ -157,7 +161,7 @@ public class CloudResourcesOrchestrationTest extends BaseTest{
@Test
public void testUnlockComplete() throws ParseException {
- stubFor(get(urlPathEqualTo(getTestUrl("requestIdtestUnlockComplete"))).willReturn(aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ wireMockServer.stubFor(get(urlPathEqualTo(getTestUrl("requestIdtestUnlockComplete"))).willReturn(aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(String.format(getResponseTemplate, "requestIdtestUnlockComplete", "COMPLETE"))
.withStatus(HttpStatus.SC_OK)));
@@ -177,7 +181,7 @@ public class CloudResourcesOrchestrationTest extends BaseTest{
@Test
public void testGetOperationalEnvFilter() {
- stubFor(get(urlPathEqualTo(getTestUrl("not-there"))).willReturn(aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ wireMockServer.stubFor(get(urlPathEqualTo(getTestUrl("not-there"))).willReturn(aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_OK)));
headers.set("Accept", MediaType.APPLICATION_JSON);
headers.set("Content-Type", MediaType.APPLICATION_JSON);
@@ -198,7 +202,7 @@ public class CloudResourcesOrchestrationTest extends BaseTest{
@Test
public void testGetOperationalEnvSuccess() throws ParseException {
- stubFor(get(urlPathEqualTo(getTestUrl("90c56827-1c78-4827-bc4d-6afcdb37a51f"))).willReturn(aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ wireMockServer.stubFor(get(urlPathEqualTo(getTestUrl("90c56827-1c78-4827-bc4d-6afcdb37a51f"))).willReturn(aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(String.format(getResponseTemplateNoBody, "90c56827-1c78-4827-bc4d-6afcdb37a51f", "COMPLETE"))
.withStatus(HttpStatus.SC_OK)));
headers.set("Accept", MediaType.APPLICATION_JSON);
@@ -223,11 +227,11 @@ public class CloudResourcesOrchestrationTest extends BaseTest{
@Test
public void testGetOperationalEnvFilterSuccess() throws ParseException {
- stubFor(get(urlPathEqualTo(getTestUrl("requestIdtestGetOperationalEnvFilterSuccess"))).willReturn(aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ wireMockServer.stubFor(get(urlPathEqualTo(getTestUrl("requestIdtestGetOperationalEnvFilterSuccess"))).willReturn(aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(String.format(getResponseTemplate, "requestIdtestGetOperationalEnvFilterSuccess", "COMPLETE"))
.withStatus(HttpStatus.SC_OK)));
- stubFor(post(urlPathEqualTo(getTestUrl("getCloudOrchestrationFiltersFromInfraActive"))).willReturn(aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ wireMockServer.stubFor(post(urlPathEqualTo(getTestUrl("getCloudOrchestrationFiltersFromInfraActive"))).willReturn(aResponse().withHeader(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody("{\"requestId\":\"getCloudOrchestrationFiltersFromInfraActive\", \"operationalEnvironmentName\":\"myVnfOpEnv\"}")
.withBody("["+String.format(getResponseTemplateNoBody, "requestIdtestGetOperationalEnvFilterSuccess", "COMPLETE")+"]")
.withStatus(HttpStatus.SC_OK)));
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelperTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelperTest.java
index 78315e9fad..6c5e968835 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelperTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelperTest.java
@@ -24,7 +24,6 @@ import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.put;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
@@ -56,7 +55,7 @@ public class AAIClientHelperTest extends BaseTest{
@Test
public void testGetAaiOperationalEnvironmentSuccess() throws Exception {
- stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+ wireMockServer.stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("vnfoperenv/ecompOperationalEnvironment.json").withStatus(HttpStatus.SC_ACCEPTED)));
AAIResultWrapper wrapper = clientHelper.getAaiOperationalEnvironment("EMOE-001");
@@ -66,7 +65,7 @@ public class AAIClientHelperTest extends BaseTest{
@Test
public void testUpdateSuccess() {
- stubFor(post(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+ wireMockServer.stubFor(post(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED)));
OperationalEnvironment ecompEnv = new OperationalEnvironment();
@@ -86,7 +85,7 @@ public class AAIClientHelperTest extends BaseTest{
@Test
public void testUpdateMapSuccess() {
- stubFor(post(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+ wireMockServer.stubFor(post(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED)));
Map<String, String> payload = new HashMap<String, String>();
@@ -107,7 +106,7 @@ public class AAIClientHelperTest extends BaseTest{
@Test
public void testCreateSuccess() {
- stubFor(put(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+ wireMockServer.stubFor(put(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED)));
OperationalEnvironment ecompEnv = new OperationalEnvironment();
@@ -128,7 +127,7 @@ public class AAIClientHelperTest extends BaseTest{
@Test
public void testcreateRelationshipSuccess() {
- stubFor(put(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+ wireMockServer.stubFor(put(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED)));
OperationalEnvironment ecompEnv = new OperationalEnvironment();
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/SDCClientHelperTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/SDCClientHelperTest.java
index 76bf0b0dbc..39f5ed834f 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/SDCClientHelperTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/SDCClientHelperTest.java
@@ -22,7 +22,6 @@ package org.onap.so.apihandlerinfra.tenantisolation.helpers;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
@@ -52,7 +51,7 @@ public class SDCClientHelperTest extends BaseTest{
jsonObject.put("message", "Success");
jsonObject.put("distributionId", "TEST_distributionId");
- stubFor(post(urlPathMatching("/sdc/v1/catalog/services/TEST_uuid1/distr.*"))
+ wireMockServer.stubFor(post(urlPathMatching("/sdc/v1/catalog/services/TEST_uuid1/distr.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(jsonObject.toString()).withStatus(HttpStatus.SC_ACCEPTED)));
JSONObject jsonResponse = sdcClientUtils.postActivateOperationalEnvironment(serviceModelVersionId, operationalEnvironmentId, workloadContext);
@@ -69,7 +68,7 @@ public class SDCClientHelperTest extends BaseTest{
JSONObject jsonErrorResponse = new JSONObject();
jsonErrorResponse.put("requestError", "");
- stubFor(post(urlPathMatching("/sdc/v1/catalog/services/TEST_uuid1/distr.*"))
+ wireMockServer.stubFor(post(urlPathMatching("/sdc/v1/catalog/services/TEST_uuid1/distr.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(jsonErrorResponse.toString()).withStatus(HttpStatus.SC_BAD_REQUEST)));
JSONObject jsonResponse = sdcClientUtils.postActivateOperationalEnvironment(serviceModelVersionId, operationalEnvironmentId, workloadContext);
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironmentTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironmentTest.java
index 418ed4270a..4f12afcb71 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironmentTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironmentTest.java
@@ -21,21 +21,21 @@
package org.onap.so.apihandlerinfra.tenantisolation.process;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.containing;
+import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
-import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
-import static com.github.tomakehurst.wiremock.client.WireMock.containing;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.util.ArrayList;
import java.util.List;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+
import org.apache.http.HttpStatus;
import org.json.JSONObject;
import org.junit.Before;
@@ -48,18 +48,18 @@ import org.onap.so.apihandlerinfra.exceptions.ApiException;
import org.onap.so.apihandlerinfra.exceptions.ValidateException;
import org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestrationRequest;
import org.onap.so.apihandlerinfra.tenantisolation.helpers.AAIClientHelper;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.Manifest;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.RecoveryAction;
import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestDetails;
import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestParameters;
import org.onap.so.apihandlerinfra.tenantisolationbeans.ServiceModelList;
-import org.onap.so.apihandlerinfra.tenantisolationbeans.RecoveryAction;
-import org.onap.so.apihandlerinfra.tenantisolationbeans.Manifest;
import org.onap.so.client.aai.AAIVersion;
import org.onap.so.client.aai.entities.AAIResultWrapper;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.springframework.beans.factory.annotation.Autowired;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
public class ActivateVnfOperationalEnvironmentTest extends BaseTest{
@@ -86,11 +86,11 @@ public class ActivateVnfOperationalEnvironmentTest extends BaseTest{
@Before
public void init(){
- stubFor(post(urlPathEqualTo("/operationalEnvServiceModelStatus/"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/operationalEnvServiceModelStatus/"))
.withRequestBody(equalTo("{\"requestId\":\"TEST_requestId\",\"operationalEnvId\":\"1dfe7154-eae0-44f2-8e7a-8e5e7882e55d\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"serviceModelVersionDistrStatus\":\"SENT\",\"recoveryAction\":\"RETRY\",\"retryCount\":3,\"workloadContext\":\"PVT\",\"createTime\":null,\"modifyTime\":null,\"vnfOperationalEnvId\":\"1dfe7154-eae0-44f2-8e7a-8e5e7882e66d\"}"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_OK)));
- stubFor(post(urlPathEqualTo("/operationalEnvDistributionStatus/"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/operationalEnvDistributionStatus/"))
.withRequestBody(equalTo("{\"distributionId\":\"TEST_distributionId\",\"operationalEnvId\":\"1dfe7154-eae0-44f2-8e7a-8e5e7882e55d\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"requestId\":\"TEST_requestId\",\"distributionIdStatus\":\"SENT\",\"distributionIdErrorReason\":\"\",\"createTime\":null,\"modifyTime\":null}"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_OK)));
@@ -102,7 +102,7 @@ public class ActivateVnfOperationalEnvironmentTest extends BaseTest{
OperationalEnvironment aaiOpEnv;
- stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+ wireMockServer.stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("vnfoperenv/ecompOperationalEnvironmentWithRelationship.json").withStatus(HttpStatus.SC_ACCEPTED)));
AAIResultWrapper wrapper = clientHelper.getAaiOperationalEnvironment("EMOE-001");
@@ -139,9 +139,9 @@ public class ActivateVnfOperationalEnvironmentTest extends BaseTest{
jsonObject.put("message", "Success");
jsonObject.put("distributionId", sdcDistributionId);
- stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+ wireMockServer.stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("vnfoperenv/activateOperationalEnvironmentWithRelationship.json").withStatus(HttpStatus.SC_ACCEPTED)));
- stubFor(post(urlPathMatching("/sdc/v1/catalog/services/TEST_serviceModelVersionId/distr.*"))
+ wireMockServer.stubFor(post(urlPathMatching("/sdc/v1/catalog/services/TEST_serviceModelVersionId/distr.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(jsonObject.toString()).withStatus(HttpStatus.SC_ACCEPTED)));
activateVnf.execute(requestId, request);
}
@@ -163,7 +163,7 @@ public class ActivateVnfOperationalEnvironmentTest extends BaseTest{
serviceModelList1.setServiceModelVersionId(serviceModelVersionId);
serviceModelVersionIdList.add(serviceModelList1);
- stubFor(post(urlPathMatching("/sdc/v1/catalog/services/TEST_serviceModelVersionId/distr.*"))
+ wireMockServer.stubFor(post(urlPathMatching("/sdc/v1/catalog/services/TEST_serviceModelVersionId/distr.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(jsonObject.toString()).withStatus(HttpStatus.SC_ACCEPTED)));
activateVnf.processActivateSDCRequest(requestId, operationalEnvironmentId, serviceModelVersionIdList, workloadContext, vnfOperationalEnvironmentId);
@@ -193,13 +193,13 @@ public class ActivateVnfOperationalEnvironmentTest extends BaseTest{
InfraActiveRequests iar = new InfraActiveRequests();
iar.setRequestId(requestId);
iar.setRequestStatus("PENDING");
- stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestId))
+ wireMockServer.stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestId))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(iar))
.withStatus(HttpStatus.SC_OK)));
- stubFor(post(urlPathMatching("/sdc/v1/catalog/services/TEST_serviceModelVersionId/distr.*"))
+ wireMockServer.stubFor(post(urlPathMatching("/sdc/v1/catalog/services/TEST_serviceModelVersionId/distr.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(jsonErrorResponse.toString()).withStatus(HttpStatus.SC_CONFLICT)));
- stubFor(post(urlPathEqualTo("/infraActiveRequests/"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/infraActiveRequests/"))
.withRequestBody(containing("operationalEnvId\":\"1dfe7154-eae0-44f2-8e7a-8e5e7882e55d\""))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_OK)));
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java
index c0250f7315..c6a74f3d4e 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java
@@ -21,26 +21,25 @@
package org.onap.so.apihandlerinfra.tenantisolation.process;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.containing;
+import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.put;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
-import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
-import static com.github.tomakehurst.wiremock.client.WireMock.containing;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching;
import static org.hamcrest.Matchers.startsWith;
import static org.junit.Assert.assertEquals;
-
import static org.junit.Assert.assertThat;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+
import org.apache.http.HttpStatus;
import org.json.JSONObject;
+import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
-import org.junit.Ignore;
import org.junit.rules.ExpectedException;
import org.onap.so.apihandler.common.ErrorNumbers;
import org.onap.so.apihandlerinfra.BaseTest;
@@ -55,8 +54,8 @@ import org.onap.so.db.request.beans.OperationalEnvDistributionStatus;
import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus;
import org.springframework.beans.factory.annotation.Autowired;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
@@ -115,11 +114,11 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
iar.setRequestId(requestIdOrig);
iar.setRequestStatus("PENDING");
- stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId"))
+ wireMockServer.stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(serviceModelDb))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestIdOrig))
+ wireMockServer.stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestIdOrig))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(iar))
.withStatus(HttpStatus.SC_OK)));
@@ -141,7 +140,7 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
serviceModelDb.setRetryCount(retryCountZero);
serviceModelDb.setServiceModelVersionDistrStatus(statusError);
serviceModelDb.setVnfOperationalEnvId(vnfOperationalEnvironmentId);
- stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId"))
+ wireMockServer.stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(serviceModelDb))
.withStatus(HttpStatus.SC_OK)));
@@ -150,7 +149,7 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
iar.setRequestId(requestIdOrig);
iar.setRequestStatus("PENDING");
- stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestIdOrig))
+ wireMockServer.stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestIdOrig))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(iar))
.withStatus(HttpStatus.SC_OK)));
@@ -177,7 +176,7 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
serviceModelDb.setRetryCount(retryCountTwo);
serviceModelDb.setServiceModelVersionDistrStatus(statusError);
serviceModelDb.setVnfOperationalEnvId(vnfOperationalEnvironmentId);
- stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId"))
+ wireMockServer.stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(serviceModelDb))
.withStatus(HttpStatus.SC_OK)));
@@ -218,31 +217,31 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
iar.setRequestId(requestIdOrig);
iar.setRequestStatus("PENDING");
- stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId"))
+ wireMockServer.stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(serviceModelDb))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlPathEqualTo("/operationalEnvDistributionStatus/"+sdcDistributionId))
+ wireMockServer.stubFor(get(urlPathEqualTo("/operationalEnvDistributionStatus/"+sdcDistributionId))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(distributionDb))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestIdOrig))
+ wireMockServer.stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestIdOrig))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(iar))
.withStatus(HttpStatus.SC_OK)));
- stubFor(post(urlPathEqualTo("/operationalEnvServiceModelStatus/"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/operationalEnvServiceModelStatus/"))
.withRequestBody(equalTo("{\"requestId\":\"TEST_requestIdOrig\",\"operationalEnvId\":\"TEST_operationalEnvironmentId\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"serviceModelVersionDistrStatus\":\"DISTRIBUTION_COMPLETE_OK\",\"recoveryAction\":\"RETRY\",\"retryCount\":0,\"workloadContext\":\"TEST_workloadContext\",\"createTime\":null,\"modifyTime\":null,\"vnfOperationalEnvId\":\"VNF_operationalEnvironmentId\"}"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_OK)));
- stubFor(post(urlPathEqualTo("/operationalEnvDistributionStatus/"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/operationalEnvDistributionStatus/"))
.withRequestBody(equalTo("{\"distributionId\":\"TEST_distributionId\",\"operationalEnvId\":\"TEST_operationalEnvironmentId\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"requestId\":\"TEST_requestIdOrig\",\"distributionIdStatus\":\"DISTRIBUTION_COMPLETE_OK\",\"distributionIdErrorReason\":\"\",\"createTime\":null,\"modifyTime\":null}"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlPathEqualTo("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/operational-environment/VNF_operationalEnvironmentId"))
+ wireMockServer.stubFor(get(urlPathEqualTo("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/operational-environment/VNF_operationalEnvironmentId"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(json).withStatus(HttpStatus.SC_ACCEPTED)));
- stubFor(put(urlPathEqualTo("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/operational-environment/VNF_operationalEnvironmentId"))
+ wireMockServer.stubFor(put(urlPathEqualTo("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/operational-environment/VNF_operationalEnvironmentId"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED)));
activateVnfStatus.execute(requestId, request);
@@ -260,7 +259,7 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
serviceModelDb.setRetryCount(retryCountThree);
serviceModelDb.setServiceModelVersionDistrStatus(statusError);
serviceModelDb.setVnfOperationalEnvId(vnfOperationalEnvironmentId);
- stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId"))
+ wireMockServer.stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(serviceModelDb))
.withStatus(HttpStatus.SC_OK)));
@@ -290,33 +289,33 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
jsonObject.put("message", "Success");
jsonObject.put("distributionId", sdcDistributionId1);
- stubFor(post(urlPathMatching("/sdc/v1/catalog/services/.*"))
+ wireMockServer.stubFor(post(urlPathMatching("/sdc/v1/catalog/services/.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(jsonObject.toString()).withStatus(HttpStatus.SC_ACCEPTED)));
- stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId"))
+ wireMockServer.stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(serviceModelDb))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlPathEqualTo("/operationalEnvDistributionStatus/"+sdcDistributionId))
+ wireMockServer.stubFor(get(urlPathEqualTo("/operationalEnvDistributionStatus/"+sdcDistributionId))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(distributionDb))
.withStatus(HttpStatus.SC_OK)));
- stubFor(post(urlPathEqualTo("/operationalEnvDistributionStatus/"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/operationalEnvDistributionStatus/"))
.withRequestBody(equalTo("{\"distributionId\":\"TEST_distributionId\",\"operationalEnvId\":\"TEST_operationalEnvironmentId\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"requestId\":\"TEST_requestIdOrig\",\"distributionIdStatus\":\"DISTRIBUTION_COMPLETE_ERROR\",\"distributionIdErrorReason\":\"Unable to process.\",\"createTime\":null,\"modifyTime\":null,\"handler\":{}}"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_OK)));
- stubFor(post(urlPathEqualTo("/operationalEnvDistributionStatus/"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/operationalEnvDistributionStatus/"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_OK)));
- stubFor(post(urlPathEqualTo("/operationalEnvServiceModelStatus/"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/operationalEnvServiceModelStatus/"))
.withRequestBody(equalTo("{\"requestId\":\"TEST_requestIdOrig\",\"operationalEnvId\":\"TEST_operationalEnvironmentId\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"serviceModelVersionDistrStatus\":\"SENT\",\"recoveryAction\":\"RETRY\",\"retryCount\":2,\"workloadContext\":\"TEST_workloadContext\",\"createTime\":null,\"modifyTime\":null,\"vnfOperationalEnvId\":\"VNF_operationalEnvironmentId\"}"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+ wireMockServer.stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(json).withStatus(HttpStatus.SC_ACCEPTED)));
- stubFor(put(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+ wireMockServer.stubFor(put(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED)));
activateVnfStatus.execute(requestId, request);
@@ -361,30 +360,30 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
iar.setRequestId(requestIdOrig);
iar.setRequestStatus("PENDING");
- stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId"))
+ wireMockServer.stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(serviceModelDb))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlPathEqualTo("/operationalEnvDistributionStatus/"+sdcDistributionId))
+ wireMockServer.stubFor(get(urlPathEqualTo("/operationalEnvDistributionStatus/"+sdcDistributionId))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(distributionDb))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestIdOrig))
+ wireMockServer.stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestIdOrig))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(iar))
.withStatus(HttpStatus.SC_OK)));
- stubFor(post(urlPathMatching("/sdc/v1/catalog/services/.*"))
+ wireMockServer.stubFor(post(urlPathMatching("/sdc/v1/catalog/services/.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(jsonObject.toString()).withStatus(HttpStatus.SC_ACCEPTED)));
- stubFor(post(urlPathEqualTo("/operationalEnvServiceModelStatus/"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/operationalEnvServiceModelStatus/"))
.withRequestBody(equalTo("{\"requestId\":\"TEST_requestIdOrig\",\"operationalEnvId\":\"TEST_operationalEnvironmentId\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"serviceModelVersionDistrStatus\":\"SENT\",\"recoveryAction\":\"RETRY\",\"retryCount\":2,\"workloadContext\":\"TEST_workloadContext\",\"createTime\":null,\"modifyTime\":null,\"handler\":{}}"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+ wireMockServer.stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(json).withStatus(HttpStatus.SC_ACCEPTED)));
- stubFor(put(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+ wireMockServer.stubFor(put(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED)));
try {
@@ -441,29 +440,29 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
InfraActiveRequests iar = new InfraActiveRequests();
iar.setRequestId(requestIdOrig);
iar.setRequestStatus("PENDING");
- stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId"))
+ wireMockServer.stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(serviceModelDb))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlPathEqualTo("/operationalEnvDistributionStatus/"+sdcDistributionId))
+ wireMockServer.stubFor(get(urlPathEqualTo("/operationalEnvDistributionStatus/"+sdcDistributionId))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(distributionDb))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestIdOrig))
+ wireMockServer.stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestIdOrig))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(iar))
.withStatus(HttpStatus.SC_OK)));
- stubFor(post(urlPathEqualTo("/infraActiveRequests/"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/infraActiveRequests/"))
.withRequestBody(containing("operationalEnvId\":\"VNF_operationalEnvironmentId\""))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_OK)));
- stubFor(post(urlPathMatching("/sdc/v1/catalog/services/.*"))
+ wireMockServer.stubFor(post(urlPathMatching("/sdc/v1/catalog/services/.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(jsonMessages.toString()).withStatus(HttpStatus.SC_CONFLICT)));
- stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+ wireMockServer.stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(json).withStatus(HttpStatus.SC_ACCEPTED)));
- stubFor(put(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+ wireMockServer.stubFor(put(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED)));
try {
@@ -509,31 +508,31 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
iar.setRequestId(requestIdOrig);
iar.setRequestStatus("PENDING");
- stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId"))
+ wireMockServer.stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(serviceModelDb))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlPathEqualTo("/operationalEnvDistributionStatus/"+sdcDistributionId))
+ wireMockServer.stubFor(get(urlPathEqualTo("/operationalEnvDistributionStatus/"+sdcDistributionId))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(distributionDb))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestIdOrig))
+ wireMockServer.stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestIdOrig))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(iar))
.withStatus(HttpStatus.SC_OK)));
- stubFor(post(urlPathEqualTo("/operationalEnvServiceModelStatus/"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/operationalEnvServiceModelStatus/"))
.withRequestBody(equalTo("{\"requestId\":\"TEST_requestIdOrig\",\"operationalEnvId\":\"TEST_operationalEnvironmentId\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"serviceModelVersionDistrStatus\":\"DISTRIBUTION_COMPLETE_OK\",\"recoveryAction\":\"SKIP\",\"retryCount\":0,\"workloadContext\":\"TEST_workloadContext\",\"createTime\":null,\"modifyTime\":null,\"vnfOperationalEnvId\":\"VNF_operationalEnvironmentId\"}"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_OK)));
- stubFor(post(urlPathEqualTo("/operationalEnvDistributionStatus/"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/operationalEnvDistributionStatus/"))
.withRequestBody(equalTo("{\"distributionId\":\"TEST_distributionId\",\"operationalEnvId\":\"TEST_operationalEnvironmentId\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"requestId\":\"TEST_requestIdOrig\",\"distributionIdStatus\":\"DISTRIBUTION_COMPLETE_OK\",\"distributionIdErrorReason\":\"\",\"createTime\":null,\"modifyTime\":null}"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+ wireMockServer.stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(json).withStatus(HttpStatus.SC_ACCEPTED)));
- stubFor(put(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+ wireMockServer.stubFor(put(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED)));
activateVnfStatus.execute(requestId, request);
@@ -574,32 +573,32 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
iar.setRequestId(requestIdOrig);
iar.setRequestStatus("PENDING");
- stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId"))
+ wireMockServer.stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(serviceModelDb))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlPathEqualTo("/operationalEnvDistributionStatus/"+sdcDistributionId))
+ wireMockServer.stubFor(get(urlPathEqualTo("/operationalEnvDistributionStatus/"+sdcDistributionId))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(distributionDb))
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestIdOrig))
+ wireMockServer.stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestIdOrig))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(iar))
.withStatus(HttpStatus.SC_OK)));
- stubFor(post(urlPathEqualTo("/operationalEnvDistributionStatus/"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/operationalEnvDistributionStatus/"))
.withRequestBody(containing("{\"distributionId\":\"TEST_distributionId\",\"operationalEnvId\":\"TEST_operationalEnvironmentId\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"requestId\":\"TEST_requestIdOrig\",\"distributionIdStatus\":\"DISTRIBUTION_COMPLETE_ERROR\""))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_OK)));
- stubFor(post(urlPathEqualTo("/operationalEnvServiceModelStatus/"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/operationalEnvServiceModelStatus/"))
.withRequestBody(containing("{\"requestId\":\"TEST_requestIdOrig\",\"operationalEnvId\":\"TEST_operationalEnvironmentId\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"serviceModelVersionDistrStatus\":\"DISTRIBUTION_COMPLETE_ERROR\""))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+ wireMockServer.stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(json).withStatus(HttpStatus.SC_ACCEPTED)));
- stubFor(put(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+ wireMockServer.stubFor(put(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED)));
try {
@@ -646,7 +645,7 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
request.setDistributionId(sdcDistributionId);
request.setOperationalEnvironmentId(operationalEnvironmentId);
- stubFor(post(urlPathMatching("/sdc/v1/catalog/services/TEST_serviceModelVersionId/distr.*"))
+ wireMockServer.stubFor(post(urlPathMatching("/sdc/v1/catalog/services/TEST_serviceModelVersionId/distr.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(jsonObject.toString()).withStatus(HttpStatus.SC_ACCEPTED)));
JSONObject jsonResponse = activateVnfStatus.callSDClientForRetry(distributionDb, serviceModelDb, distribution);
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironmentTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironmentTest.java
index 65ec5fade6..22993b17cf 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironmentTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironmentTest.java
@@ -20,12 +20,21 @@
package org.onap.so.apihandlerinfra.tenantisolation.process;
-import static com.github.tomakehurst.wiremock.client.WireMock.*;
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.containing;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
+import static com.github.tomakehurst.wiremock.client.WireMock.put;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertThat;
+
import java.util.UUID;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
+
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+
import org.apache.http.HttpStatus;
import org.junit.Test;
import org.onap.so.apihandler.common.ErrorNumbers;
@@ -44,8 +53,8 @@ import org.onap.so.logger.ErrorCode;
import org.onap.so.logger.MessageEnum;
import org.springframework.beans.factory.annotation.Autowired;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
public class CreateEcompOperationalEnvironmentTest extends BaseTest{
@@ -73,9 +82,9 @@ public class CreateEcompOperationalEnvironmentTest extends BaseTest{
@Test
public void testProcess() throws ApiException, JsonProcessingException {
- stubFor(put(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+ wireMockServer.stubFor(put(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED)));
- stubFor(post(urlPathMatching("/events/.*"))
+ wireMockServer.stubFor(post(urlPathMatching("/events/.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED)));
InfraActiveRequests iar = new InfraActiveRequests();
@@ -84,11 +93,11 @@ public class CreateEcompOperationalEnvironmentTest extends BaseTest{
iar.setRequestScope("create");
iar.setRequestStatus("PENDING");
iar.setRequestAction("UNKNOWN");
- stubFor(get(urlPathEqualTo("/infraActiveRequests/123"))
+ wireMockServer.stubFor(get(urlPathEqualTo("/infraActiveRequests/123"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(iar))
.withStatus(HttpStatus.SC_OK)));
- stubFor(post(urlPathEqualTo("/infraActiveRequests/"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/infraActiveRequests/"))
.withRequestBody(containing("{\"requestId\":\"123\",\"clientRequestId\":null,\"action\":null,\"requestStatus\":\"COMPLETE\",\"statusMessage\":\"SUCCESSFUL, operationalEnvironmentId - operationalEnvId; Success Message: SUCCESSFULLY Created ECOMP OperationalEnvironment.\",\"rollbackStatusMessage\":null,\"flowStatus\":null,\"retryStatusMessage\":null,\"progress\":100"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_OK)));
@@ -98,9 +107,9 @@ public class CreateEcompOperationalEnvironmentTest extends BaseTest{
@Test
public void testProcessException() throws JsonProcessingException {
- stubFor(put(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+ wireMockServer.stubFor(put(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED)));
- stubFor(post(urlPathMatching("/events/.*"))
+ wireMockServer.stubFor(post(urlPathMatching("/events/.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_NOT_FOUND)));
ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, ErrorCode.DataError).build();
ValidateException expectedException = new ValidateException.Builder("Could not publish DMaap", HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER)
@@ -113,11 +122,11 @@ public class CreateEcompOperationalEnvironmentTest extends BaseTest{
iar.setRequestScope("create");
iar.setRequestStatus("PENDING");
iar.setRequestAction("UNKNOWN");
- stubFor(get(urlPathEqualTo("/infraActiveRequests/"+uuid))
+ wireMockServer.stubFor(get(urlPathEqualTo("/infraActiveRequests/"+uuid))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(iar))
.withStatus(HttpStatus.SC_OK)));
- stubFor(post(urlPathEqualTo("/infraActiveRequests/"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/infraActiveRequests/"))
.withRequestBody(containing("{\"requestId\":\""+uuid+ "\",\"clientRequestId\":null,\"action\":null,\"requestStatus\":\"FAILED\",\"statusMessage\":\"FAILURE, operationalEnvironmentId - operationalEnvId; Error message:"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_OK)));
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironmentTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironmentTest.java
index ac274dc8dc..59a65676e2 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironmentTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironmentTest.java
@@ -20,7 +20,13 @@
package org.onap.so.apihandlerinfra.tenantisolation.process;
-import static com.github.tomakehurst.wiremock.client.WireMock.*;
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.containing;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
+import static com.github.tomakehurst.wiremock.client.WireMock.put;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching;
import static org.junit.Assert.assertEquals;
import java.io.File;
@@ -28,7 +34,9 @@ import java.nio.file.Files;
import java.util.List;
import java.util.UUID;
-import com.fasterxml.jackson.core.JsonProcessingException;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+
import org.apache.http.HttpStatus;
import org.junit.Before;
import org.junit.Test;
@@ -42,11 +50,9 @@ import org.onap.so.client.grm.beans.ServiceEndPointList;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.springframework.beans.factory.annotation.Autowired;
+import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
-
public class CreateVnfOperationalEnvironmentTest extends BaseTest{
@@ -124,13 +130,13 @@ public class CreateVnfOperationalEnvironmentTest extends BaseTest{
@Test
public void testExecute() throws ApiException, JsonProcessingException {
- stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+ wireMockServer.stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("vnfoperenv/ecompOperationalEnvironment.json").withStatus(HttpStatus.SC_ACCEPTED)));
- stubFor(post(urlPathMatching("/GRMLWPService/v1/serviceEndPoint/findRunning"))
+ wireMockServer.stubFor(post(urlPathMatching("/GRMLWPService/v1/serviceEndPoint/findRunning"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("vnfoperenv/endpoints.json").withStatus(HttpStatus.SC_ACCEPTED)));
- stubFor(post(urlPathMatching("/GRMLWPService/v1/serviceEndPoint/add"))
+ wireMockServer.stubFor(post(urlPathMatching("/GRMLWPService/v1/serviceEndPoint/add"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED)));
- stubFor(put(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+ wireMockServer.stubFor(put(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("vnfoperenv/ecompOperationalEnvironment.json").withStatus(HttpStatus.SC_ACCEPTED)));
String requestId = UUID.randomUUID().toString();
InfraActiveRequests iar = new InfraActiveRequests();
@@ -140,12 +146,12 @@ public class CreateVnfOperationalEnvironmentTest extends BaseTest{
iar.setRequestStatus("PENDING");
iar.setRequestAction("UNKNOWN");
ObjectMapper mapper = new ObjectMapper();
- stubFor(post(urlPathEqualTo("/infraActiveRequests/"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/infraActiveRequests/"))
.withRequestBody(containing("{\"requestId\":\""+ requestId+"\",\"clientRequestId\":null,\"action\":null,\"requestStatus\":\"COMPLETE\",\"statusMessage\":\"SUCCESSFUL"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestId))
+ wireMockServer.stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestId))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(iar))
.withStatus(HttpStatus.SC_OK)));
@@ -154,13 +160,13 @@ public class CreateVnfOperationalEnvironmentTest extends BaseTest{
@Test
public void testExecuteEndpointsListBeginWithUppercase() throws ApiException, JsonProcessingException {
- stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+ wireMockServer.stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("vnfoperenv/ecompOperationalEnvironment.json").withStatus(HttpStatus.SC_ACCEPTED)));
- stubFor(post(urlPathMatching("/GRMLWPService/v1/serviceEndPoint/findRunning"))
+ wireMockServer.stubFor(post(urlPathMatching("/GRMLWPService/v1/serviceEndPoint/findRunning"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("vnfoperenv/endpoints2.json").withStatus(HttpStatus.SC_ACCEPTED)));
- stubFor(post(urlPathMatching("/GRMLWPService/v1/serviceEndPoint/add"))
+ wireMockServer.stubFor(post(urlPathMatching("/GRMLWPService/v1/serviceEndPoint/add"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED)));
- stubFor(put(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+ wireMockServer.stubFor(put(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("vnfoperenv/ecompOperationalEnvironment.json").withStatus(HttpStatus.SC_ACCEPTED)));
String requestId = UUID.randomUUID().toString();
InfraActiveRequests iar = new InfraActiveRequests();
@@ -170,12 +176,12 @@ public class CreateVnfOperationalEnvironmentTest extends BaseTest{
iar.setRequestStatus("PENDING");
iar.setRequestAction("UNKNOWN");
ObjectMapper mapper = new ObjectMapper();
- stubFor(post(urlPathEqualTo("/infraActiveRequests/"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/infraActiveRequests/"))
.withRequestBody(containing("{\"requestId\":\""+ requestId+"\",\"clientRequestId\":null,\"action\":null,\"requestStatus\":\"COMPLETE\",\"statusMessage\":\"SUCCESSFUL"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_OK)));
- stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestId))
+ wireMockServer.stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestId))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(iar))
.withStatus(HttpStatus.SC_OK)));
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironmentTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironmentTest.java
index 7c24050775..1e4208c743 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironmentTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironmentTest.java
@@ -20,12 +20,20 @@
package org.onap.so.apihandlerinfra.tenantisolation.process;
-import static com.github.tomakehurst.wiremock.client.WireMock.*;
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.containing;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
+import static com.github.tomakehurst.wiremock.client.WireMock.put;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching;
import static org.hamcrest.Matchers.hasProperty;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.startsWith;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+
import org.apache.http.HttpStatus;
import org.junit.Before;
import org.junit.Rule;
@@ -39,8 +47,7 @@ import org.onap.so.client.aai.AAIVersion;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.springframework.beans.factory.annotation.Autowired;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
+import com.fasterxml.jackson.databind.ObjectMapper;
public class DeactivateVnfOperationalEnvironmentTest extends BaseTest{
@@ -58,7 +65,7 @@ public class DeactivateVnfOperationalEnvironmentTest extends BaseTest{
@Before
public void init(){
- stubFor(post(urlPathEqualTo("/infraActiveRequests/"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/infraActiveRequests/"))
.withRequestBody(containing("{\"requestId\":\""+ requestId+"\",\"clientRequestId\":null,\"action\":null,\"requestStatus\":\"COMPLETE\",\"statusMessage\":\"SUCCESSFUL"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_OK)));
@@ -70,11 +77,11 @@ public class DeactivateVnfOperationalEnvironmentTest extends BaseTest{
String json = "{\"operational-environment-status\" : \"ACTIVE\"}";
- stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+ wireMockServer.stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(json).withStatus(HttpStatus.SC_ACCEPTED)));
- stubFor(put(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+ wireMockServer.stubFor(put(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED)));
- stubFor(post(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+ wireMockServer.stubFor(post(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED)));
InfraActiveRequests iar = new InfraActiveRequests();
@@ -83,7 +90,7 @@ public class DeactivateVnfOperationalEnvironmentTest extends BaseTest{
iar.setRequestScope("create");
iar.setRequestStatus("PENDING");
iar.setRequestAction("UNKNOWN");
- stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestId))
+ wireMockServer.stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestId))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(iar))
.withStatus(HttpStatus.SC_OK)));
@@ -97,7 +104,7 @@ public class DeactivateVnfOperationalEnvironmentTest extends BaseTest{
String json = "{\"operational-environment-status\" : \"SUCCESS\"}";
- stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+ wireMockServer.stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(json).withStatus(HttpStatus.SC_ACCEPTED)));
thrown.expect(ValidateException.class);
@@ -111,11 +118,11 @@ public class DeactivateVnfOperationalEnvironmentTest extends BaseTest{
iar.setRequestScope("create");
iar.setRequestStatus("PENDING");
iar.setRequestAction("UNKNOWN");
- stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestId))
+ wireMockServer.stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestId))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(iar))
.withStatus(HttpStatus.SC_OK)));
- stubFor(post(urlPathEqualTo("/infraActiveRequests/"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/infraActiveRequests/"))
.withRequestBody(containing("{\"requestId\":\""+ requestId+"\",\"clientRequestId\":null,\"action\":null,\"requestStatus\":\"FAILED\",\"statusMessage\":\"FAILURE"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_OK)));
@@ -130,7 +137,7 @@ public class DeactivateVnfOperationalEnvironmentTest extends BaseTest{
String json = "{\"operational-environment-status\" : \"INACTIVE\"}";
- stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+ wireMockServer.stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(json).withStatus(HttpStatus.SC_ACCEPTED)));
InfraActiveRequests iar = new InfraActiveRequests();
@@ -139,7 +146,7 @@ public class DeactivateVnfOperationalEnvironmentTest extends BaseTest{
iar.setRequestScope("create");
iar.setRequestStatus("PENDING");
iar.setRequestAction("UNKNOWN");
- stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestId))
+ wireMockServer.stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestId))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(iar))
.withStatus(HttpStatus.SC_OK)));
@@ -154,7 +161,7 @@ public class DeactivateVnfOperationalEnvironmentTest extends BaseTest{
String json = "{\"operational-environment-status\" : \"\"}";
- stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
+ wireMockServer.stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(json).withStatus(HttpStatus.SC_ACCEPTED)));
thrown.expect(ValidateException.class);
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/CustomWorkflowValidationTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/CustomWorkflowValidationTest.java
new file mode 100644
index 0000000000..90c994fce0
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/CustomWorkflowValidationTest.java
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.validation;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.HashMap;
+
+import org.junit.Test;
+import org.onap.so.apihandlerinfra.Action;
+import org.onap.so.apihandlerinfra.BaseTest;
+import org.onap.so.exceptions.ValidationException;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class CustomWorkflowValidationTest extends BaseTest{
+
+ @Test
+ public void testCustomWorkflowValidation() throws IOException, ValidationException {
+ String requestJson = new String(Files.readAllBytes(Paths.get("src/test/resources/MsoRequestTest/SuccessfulValidation/v1ExecuteCustomWorkflow.json")));
+ ObjectMapper mapper = new ObjectMapper();
+ ServiceInstancesRequest sir = mapper.readValue(requestJson, ServiceInstancesRequest.class);
+ ValidationInformation info = new ValidationInformation(sir, new HashMap<String, String>(), Action.inPlaceSoftwareUpdate,
+ 1, false, sir.getRequestDetails().getRequestParameters());
+ info.setRequestScope("vnf");
+
+ CustomWorkflowValidation validation = new CustomWorkflowValidation();
+ validation.validate(info);
+
+ assertEquals(info.getSir().getRequestDetails().getCloudConfiguration().getCloudOwner(), "att-aic");
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/client/grm/GRMClientTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/client/grm/GRMClientTest.java
index 6555a9a66e..580252ae73 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/client/grm/GRMClientTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/client/grm/GRMClientTest.java
@@ -25,10 +25,8 @@ import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
import static com.github.tomakehurst.wiremock.client.WireMock.matching;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
-import static com.github.tomakehurst.wiremock.client.WireMock.verify;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
@@ -47,7 +45,6 @@ import org.junit.rules.ExpectedException;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.apihandlerinfra.BaseTest;
import org.onap.so.apihandlerinfra.TestAppender;
-import org.onap.so.client.grm.GRMClient;
import org.onap.so.client.grm.beans.ServiceEndPoint;
import org.onap.so.client.grm.beans.ServiceEndPointList;
import org.onap.so.client.grm.beans.ServiceEndPointLookupRequest;
@@ -75,7 +72,7 @@ public class GRMClientTest extends BaseTest{
public void testFind() throws Exception {
TestAppender.events.clear();
String endpoints = getFileContentsAsString("__files/grm/endpoints.json");
- stubFor(post(urlPathEqualTo("/GRMLWPService/v1/serviceEndPoint/findRunning"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/GRMLWPService/v1/serviceEndPoint/findRunning"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", MediaType.APPLICATION_JSON)
@@ -113,7 +110,7 @@ public class GRMClientTest extends BaseTest{
if(!foundInvokeReturn)
fail("INVOKE RETURN Marker not found");
- verify(postRequestedFor(urlEqualTo("/GRMLWPService/v1/serviceEndPoint/findRunning"))
+ wireMockServer.verify(postRequestedFor(urlEqualTo("/GRMLWPService/v1/serviceEndPoint/findRunning"))
.withHeader(ONAPLogConstants.Headers.INVOCATION_ID.toString(), matching(uuidRegex))
.withHeader(ONAPLogConstants.Headers.REQUEST_ID.toString(), matching(uuidRegex))
.withHeader(ONAPLogConstants.Headers.PARTNER_NAME.toString(), equalTo("SO")));
@@ -122,7 +119,7 @@ public class GRMClientTest extends BaseTest{
@Test
public void testFindFail() throws Exception {
- stubFor(post(urlPathEqualTo("/GRMLWPService/v1/serviceEndPoint/findRunning"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/GRMLWPService/v1/serviceEndPoint/findRunning"))
.willReturn(aResponse()
.withStatus(400)
.withHeader("Content-Type", MediaType.APPLICATION_JSON)
@@ -135,7 +132,7 @@ public class GRMClientTest extends BaseTest{
@Test
public void testAddFail() throws Exception {
- stubFor(post(urlPathEqualTo("/GRMLWPService/v1/serviceEndPoint/add"))
+ wireMockServer.stubFor(post(urlPathEqualTo("/GRMLWPService/v1/serviceEndPoint/add"))
.willReturn(aResponse()
.withStatus(404)
.withHeader("Content-Type", MediaType.APPLICATION_JSON)
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/SuccessfulValidation/v1ExecuteCustomWorkflow.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/SuccessfulValidation/v1ExecuteCustomWorkflow.json
new file mode 100644
index 0000000000..611ccb3c66
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/SuccessfulValidation/v1ExecuteCustomWorkflow.json
@@ -0,0 +1,18 @@
+{
+ "requestDetails": {
+ "cloudConfiguration": {
+ "cloudOwner": "att-aic",
+ "lcpCloudRegionId": "mdt1",
+ "tenantId": "88a6ca3ee0394ade9403f075db23167e"
+ },
+ "requestParameters": {
+ "userParams": [
+ {
+ "existing_software_version": "3.1",
+ "new_software_version": "3.2",
+ "operations_timeout": "3600"
+ }
+ ]
+ }
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ExecuteCustomWorkflow.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ExecuteCustomWorkflow.json
new file mode 100644
index 0000000000..611ccb3c66
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ExecuteCustomWorkflow.json
@@ -0,0 +1,18 @@
+{
+ "requestDetails": {
+ "cloudConfiguration": {
+ "cloudOwner": "att-aic",
+ "lcpCloudRegionId": "mdt1",
+ "tenantId": "88a6ca3ee0394ade9403f075db23167e"
+ },
+ "requestParameters": {
+ "userParams": [
+ {
+ "existing_software_version": "3.1",
+ "new_software_version": "3.2",
+ "operations_timeout": "3600"
+ }
+ ]
+ }
+ }
+}
diff --git a/pom.xml b/pom.xml
index 1d5d53d9a7..01d66b4366 100644
--- a/pom.xml
+++ b/pom.xml
@@ -434,6 +434,9 @@
<so.log.level>DEBUG</so.log.level>
</systemPropertyVariables>
<rerunFailingTestsCount>2</rerunFailingTestsCount>
+ <parallel>classes</parallel>
+ <useUnlimitedThreads>false</useUnlimitedThreads>
+ <threadCount>1</threadCount>
</configuration>
</plugin>
<plugin>