import org.onap.so.db.catalog.data.repository.NetworkResourceCustomizationRepository;
import org.onap.so.db.catalog.data.repository.NetworkResourceRepository;
import org.onap.so.db.catalog.data.repository.ServiceProxyResourceCustomizationRepository;
+import org.onap.so.db.catalog.data.repository.ServiceProxyResourceRepository;
import org.onap.so.db.catalog.data.repository.ServiceRepository;
import org.onap.so.db.catalog.data.repository.TempNetworkHeatTemplateRepository;
import org.onap.so.db.catalog.data.repository.VFModuleCustomizationRepository;
@Autowired
protected ServiceProxyResourceCustomizationRepository serviceProxyCustomizationRepo;
+ @Autowired
+ protected ServiceProxyResourceRepository serviceProxyRepo;
+
@Autowired
protected CollectionResourceRepository collectionRepo;
}
}
}
-
+
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) {
- createServiceProxy(spNode, service, toscaResourceStruct);
- serviceProxyCustomizationRepo.saveAndFlush(toscaResourceStruct.getCatalogServiceProxyResourceCustomization());
+ serviceProxy = createServiceProxy(spNode, service, toscaResourceStruct);
+
+ ServiceProxyResource serviceProxyResource = findExistingServiceProxyResource(serviceProxyList, serviceProxy.getServiceProxyResource().getModelUUID());
+
+ if(serviceProxyResource == null){
+
+ serviceProxyList.add(serviceProxy);
for (NodeTemplate configNode : configurationNodeTemplatesList) {
-
+
List<RequirementAssignment> requirementsList = toscaResourceStruct.getSdcCsarHelper().getRequirementsOf(configNode).getAll();
for (RequirementAssignment requirement : requirementsList) {
if (requirement.getNodeTemplateName().equals(spNode.getName())) {
- createConfiguration(configNode, toscaResourceStruct, toscaResourceStruct.getCatalogServiceProxyResourceCustomization());
- configCustomizationRepo.saveAndFlush(toscaResourceStruct.getCatalogConfigurationResourceCustomization());
+ ConfigurationResourceCustomization configurationResource = createConfiguration(configNode, toscaResourceStruct, serviceProxy);
+
+ configurationResourceList.add(configurationResource);
break;
}
}
}
+
+ }
}
}
+
+ service.setConfigurationCustomizations(configurationResourceList);
+ service.setServiceProxyCustomizations(serviceProxyList);
}
protected void processNetworkCollections(ToscaResourceStructure toscaResourceStruct, Service service) {
spCustomizationResource.setServiceProxyResource(spResource);
serviceProxyCustomizationSet.add(spCustomizationResource);
-
- spResource.setServiceProxyCustomization(serviceProxyCustomizationSet);
-
toscaResourceStructure.setCatalogServiceProxyResource(spResource);
toscaResourceStructure.setCatalogServiceProxyResourceCustomization(spCustomizationResource);
vnfcCustomizations.add(vnfcCustomization);
}
- }
-
CvnfcCustomization cvnfcCustomization = new CvnfcCustomization();
cvnfcCustomization.setModelCustomizationUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
cvnfcCustomization.setModelInstanceName(cvfcTemplate.getName());
vnfVfmoduleCvnfcConfigurationCustomizations.add(vnfVfmoduleCvnfcConfigurationCustomization);
}
+ }
+
}
}
- vfModuleCustomization.setVnfcCustomization(vnfcCustomizations);
vfModuleCustomization.setCvnfcCustomization(cvnfcCustomizations);
vfModuleCustomization.setVnfVfmoduleCvnfcConfigurationCustomization(vnfVfmoduleCvnfcConfigurationCustomizations);
return configResource;
}
+ protected ServiceProxyResource findExistingServiceProxyResource(List<ServiceProxyResourceCustomization> serviceProxyList, String modelUUID) {
+ ServiceProxyResource serviceProxyResource = null;
+ for(ServiceProxyResourceCustomization serviceProxyResourceCustom : serviceProxyList){
+ if (serviceProxyResourceCustom.getServiceProxyResource() != null
+ && serviceProxyResourceCustom.getServiceProxyResource().getModelUUID().equals(modelUUID)) {
+ serviceProxyResource = serviceProxyResourceCustom.getServiceProxyResource();
+ }
+ }
+ if(serviceProxyResource==null)
+ serviceProxyResource = serviceProxyRepo.findResourceByModelUUID(modelUUID);
+
+ return serviceProxyResource;
+ }
+
protected VfModuleCustomization findExistingVfModuleCustomization(VnfResourceCustomization vnfResource,
String vfModuleModelCustomizationUUID) {
VfModuleCustomization vfModuleCustomization = null;
* 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.
}
- /**
- * Tunnel-XConnect Mock Stub Response
- */
- public static void MockPutTunnelXConnect(String globalCustId, String subscriptionType, String serviceInstanceId, String allottedResourceId, String tunnelId){
- 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 + "/tunnel-xconnects/tunnel-xconnect/" + tunnelId))
- .willReturn(aResponse()
- .withStatus(200)));
- }
-
-
/**
* Allotted Resource Mock StubResponses below
*/
.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))
.willReturn(aResponse()
.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))
.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))
.willReturn(aResponse()
.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))
.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))
.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))
.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))
.willReturn(aResponse()
.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))
.willReturn(aResponse()
/**
* 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"))
.willReturn(aResponse()
.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))
.willReturn(aResponse()
.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))
.atPriority(1)
.willReturn(aResponse()
.withStatus(statusCode)
.withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
+ .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))
.atPriority(priority)
.willReturn(aResponse()
.withStatus(statusCode)
.withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
+ .withBodyFile(responseFile)));
}
public static void MockGetGenericVnfByIdWithDepth(String vnfId, int depth, String responseFile){
.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))
.willReturn(aResponse()
.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))
.willReturn(aResponse()
.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))
.withRequestBody(containing(requestBodyContaining))
.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))
.willReturn(aResponse()
.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))
.willReturn(aResponse()
.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))
.willReturn(aResponse()
.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/att-aic/"+cloudRegion))
.willReturn(aResponse()
.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))
.willReturn(aResponse()
.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/att-aic/"+cloudRegion))
.willReturn(aResponse()
.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))
.willReturn(aResponse()
.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))
.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"))
.willReturn(aResponse()
.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))
.willReturn(aResponse()
.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))
.willReturn(aResponse()
.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"))
.willReturn(aResponse()
.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 ))
.willReturn(aResponse()
.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))
.willReturn(aResponse()
.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))
.willReturn(aResponse()
.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))
.willReturn(aResponse()
.withStatus(200)));
}
-
+
/////////////
-
+
public static void MockVNFAdapterRestVfModule() {
stubFor(put(urlEqualTo("/vnfs/v1/vnfs/skask/vf-modules/supercool"))
.willReturn(aResponse()
.withStatus(202)
.withHeader("Content-Type", "application/xml")));
}
-
+
public static void MockDBUpdateVfModule(){
stubFor(post(urlEqualTo("/dbadapters/RequestsDbAdapter"))
.willReturn(aResponse()
.withHeader("Content-Type", "text/xml")
.withBodyFile("VfModularity/DBUpdateResponse.xml")));
}
-
+
// start of mocks used locally and by other VF Module unit tests
public static void MockSDNCAdapterVfModule() {
// simplified the implementation to return "success" for all requests
.withBodyFile("VfModularity/StandardSDNCSynchResponse.xml")));
}
-
+
// 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"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/xml")
- .withBodyFile("VfModularity/VfModule-supercool.xml")));
+ .withBodyFile("VfModularity/VfModule-supercool.xml")));
stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/lukewarm"))
.atPriority(2)
.willReturn(aResponse()
.withStatus(200)));
}
-
-
+
+
//////////////
/**
* 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/att-aic/" + cloudRegionId))
.willReturn(aResponse()
.withHeader("Content-Type", "text/xml")
.withBodyFile(responseFile)));
}
-
+
/**
* Volume Group StubResponse below
*/
public static void MockGetVolumeGroupById(String cloudRegionId, String volumeGroupId, String responseFile) {
MockGetVolumeGroupById(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/att-aic/" + cloudRegionId + "/volume-groups/volume-group/" + volumeGroupId))
.willReturn(aResponse()
.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/att-aic/" + cloudRegionId + "/volume-groups/volume-group/" + volumeGroupId))
.willReturn(aResponse()
.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/att-aic/" + cloudRegionId + "/volume-groups[?]volume-group-name=" + volumeGroupName))
.willReturn(aResponse()
.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/att-aic/" + cloudRegionId + "/volume-groups/volume-group/" + volumeGroupId + "[?]resource-version=" + resourceVersion))
.willReturn(aResponse()
.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/att-aic/" + cloudRegionId + "/volume-groups/volume-group/" + volumeGroupId + "[?]resource-version=" + resourceVersion))
.willReturn(aResponse()
.withStatus(200)));
}
-
+
/**
* VF-Module StubResponse below
* @param statusCode TODO
.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))
.willReturn(aResponse()
.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))
.willReturn(aResponse()
.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))
.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))
.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))
.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))
.willReturn(aResponse()
.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.*"))
.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/.*"))
.willReturn(aResponse()
.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/.*"))
.willReturn(aResponse()
- .withStatus(statusCode)
+ .withStatus(statusCode)
));
}
-
+
public static void MockSetInMaintFlagByVnfId(String vnfId, String responseFile, int statusCode) {
stubFor(post(urlMatching("/aai/v1[0-9]/network/generic-vnfs/.*"))
.willReturn(aResponse()
.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/att-aic/"+cloudRegionId + ".*"))
.willReturn(aResponse()
.withHeader("Content-Type", "application/json; charset=utf-8")
.withBodyFile(responseFile)));
}
-
+
//// Deprecated Stubs below - to be deleted once unit test that reference them are refactored to use common ones above ////
@Deprecated
public static void MockGetVceById(){