use of org.onap.so.entity.MsoRequest in project so by onap.
the class NetworkAdapterObjectMapper method createMsoRequest.
public MsoRequest createMsoRequest(RequestContext requestContext, ServiceInstance serviceInstance) {
MsoRequest msoRequest = new MsoRequest();
msoRequest.setRequestId(requestContext.getMsoRequestId());
msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
return msoRequest;
}
use of org.onap.so.entity.MsoRequest in project so by onap.
the class NetworkAdapterObjectMapperTest method updateNetworkRequestMapperTest.
@Test
public void updateNetworkRequestMapperTest() throws UnsupportedEncodingException {
org.onap.so.openstack.beans.Subnet subnet = new org.onap.so.openstack.beans.Subnet();
subnet.setSubnetId("subnetId");
subnet.setGatewayIp("NULL");
subnet.setHostRoutes(new ArrayList<org.onap.so.openstack.beans.HostRoute>());
List<org.onap.so.openstack.beans.Subnet> subnets = new ArrayList<>();
subnets.add(subnet);
ProviderVlanNetwork providerVlanNetwork = new ProviderVlanNetwork("physicalNetworkName", new ArrayList<Integer>());
List<String> policyFqdns = Arrays.asList("networkPolicyFqdn");
org.onap.so.openstack.beans.RouteTarget expectedRouteTarget = new org.onap.so.openstack.beans.RouteTarget();
expectedRouteTarget.setRouteTarget("globalRouteTarget");
ContrailNetwork contrailNetwork = new ContrailNetwork();
contrailNetwork.setPolicyFqdns(policyFqdns);
contrailNetwork.setRouteTableFqdns(new ArrayList<String>());
contrailNetwork.setRouteTargets(new ArrayList<org.onap.so.openstack.beans.RouteTarget>());
contrailNetwork.getRouteTargets().add(expectedRouteTarget);
contrailNetwork.getRouteTableFqdns().add("routeTableReferenceFqdn");
MsoRequest msoRequest = new MsoRequest();
msoRequest.setServiceInstanceId("testServiceInstanceId1");
ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
modelInfoNetwork.setNetworkType("networkType");
modelInfoNetwork.setModelCustomizationUUID("modelCustomizationUuid");
modelInfoNetwork.setModelVersion("modelVersion");
Subnet actualSubnet = new Subnet();
actualSubnet.setSubnetId("subnetId");
actualSubnet.setDhcpEnabled(false);
actualSubnet.setIpVersion("4");
RouteTarget routeTarget = new RouteTarget();
routeTarget.setGlobalRouteTarget("globalRouteTarget");
VpnBinding vpnBinding = new VpnBinding();
vpnBinding.setVpnId("vpnId");
vpnBinding.getRouteTargets().add(routeTarget);
Customer customer = new Customer();
customer.getVpnBindings().add(vpnBinding);
ServiceSubscription serviceSubscription = new ServiceSubscription();
customer.setServiceSubscription(serviceSubscription);
// set Customer on service instance
customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
NetworkPolicy networkPolicy = new NetworkPolicy();
networkPolicy.setNetworkPolicyId("networkPolicyId");
networkPolicy.setNetworkPolicyFqdn("networkPolicyFqdn");
RouteTableReference routeTableReference = new RouteTableReference();
routeTableReference.setRouteTableReferenceFqdn("routeTableReferenceFqdn");
l3Network.setModelInfoNetwork(modelInfoNetwork);
l3Network.setPhysicalNetworkName("physicalNetworkName");
l3Network.getSubnets().add(actualSubnet);
l3Network.getNetworkPolicies().add(networkPolicy);
l3Network.getContrailNetworkRouteTableReferences().add(routeTableReference);
l3Network.setIsSharedNetwork(false);
l3Network.setIsExternalNetwork(false);
HashMap<String, String> networkParams = new HashMap<String, String>();
networkParams.put("shared", "false");
networkParams.put("external", "false");
networkParams.put("testUserInputKey", "testUserInputValue");
UpdateNetworkRequest expectedUpdateNetworkRequest = new UpdateNetworkRequest();
expectedUpdateNetworkRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
expectedUpdateNetworkRequest.setTenantId(cloudRegion.getTenantId());
expectedUpdateNetworkRequest.setNetworkId(l3Network.getNetworkId());
expectedUpdateNetworkRequest.setNetworkStackId(l3Network.getHeatStackId());
expectedUpdateNetworkRequest.setNetworkName(l3Network.getNetworkName());
expectedUpdateNetworkRequest.setNetworkType(l3Network.getModelInfoNetwork().getNetworkType());
expectedUpdateNetworkRequest.setNetworkTypeVersion(l3Network.getModelInfoNetwork().getModelVersion());
expectedUpdateNetworkRequest.setModelCustomizationUuid(l3Network.getModelInfoNetwork().getModelCustomizationUUID());
expectedUpdateNetworkRequest.setSubnets(subnets);
expectedUpdateNetworkRequest.setProviderVlanNetwork(providerVlanNetwork);
expectedUpdateNetworkRequest.setContrailNetwork(contrailNetwork);
expectedUpdateNetworkRequest.setNetworkParams(networkParams);
expectedUpdateNetworkRequest.setMsoRequest(msoRequest);
expectedUpdateNetworkRequest.setSkipAAI(true);
expectedUpdateNetworkRequest.setBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled()));
expectedUpdateNetworkRequest.setMessageId("messageId");
expectedUpdateNetworkRequest.setNotificationUrl("http://localhost:28080/mso/WorkflowMesssage/NetworkAResponse/messageId");
doReturn("messageId").when(SPY_networkAdapterObjectMapper).getRandomUuid();
doReturn("http://localhost:28080/mso/WorkflowMesssage").when(SPY_networkAdapterObjectMapper).getEndpoint();
UpdateNetworkRequest actualUpdateNetworkRequest = SPY_networkAdapterObjectMapper.createNetworkUpdateRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, customer);
assertThat(actualUpdateNetworkRequest, sameBeanAs(expectedUpdateNetworkRequest).ignoring("msoRequest.requestId"));
}
use of org.onap.so.entity.MsoRequest in project so by onap.
the class NetworkAdapterObjectMapperTest method deleteNetworkRequestNoHeatIdMapperTest.
@Test
public void deleteNetworkRequestNoHeatIdMapperTest() throws Exception {
DeleteNetworkRequest expectedDeleteNetworkRequest = new DeleteNetworkRequest();
String messageId = "messageId";
expectedDeleteNetworkRequest.setMessageId(messageId);
doReturn(messageId).when(SPY_networkAdapterObjectMapper).getRandomUuid();
ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
l3Network.setModelInfoNetwork(modelInfoNetwork);
modelInfoNetwork.setModelCustomizationUUID("modelCustomizationUuid");
expectedDeleteNetworkRequest.setModelCustomizationUuid(modelInfoNetwork.getModelCustomizationUUID());
MsoRequest msoRequest = new MsoRequest();
msoRequest.setRequestId(requestContext.getMsoRequestId());
msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
expectedDeleteNetworkRequest.setMsoRequest(msoRequest);
expectedDeleteNetworkRequest.setNetworkId(l3Network.getNetworkId());
l3Network.setNetworkName("heatStackId");
expectedDeleteNetworkRequest.setNetworkStackId("heatStackId");
expectedDeleteNetworkRequest.setNetworkType(l3Network.getNetworkType());
expectedDeleteNetworkRequest.setSkipAAI(true);
expectedDeleteNetworkRequest.setTenantId(cloudRegion.getTenantId());
expectedDeleteNetworkRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
expectedDeleteNetworkRequest.setNotificationUrl("endpoint/NetworkAResponse/messageId");
doReturn("endpoint/").when(SPY_networkAdapterObjectMapper).getEndpoint();
doReturn("messageId").when(SPY_networkAdapterObjectMapper).getRandomUuid();
DeleteNetworkRequest deleteNetworkRequest = SPY_networkAdapterObjectMapper.deleteNetworkRequestMapper(requestContext, cloudRegion, serviceInstance, l3Network);
assertThat(expectedDeleteNetworkRequest, sameBeanAs(deleteNetworkRequest));
}
use of org.onap.so.entity.MsoRequest in project so by onap.
the class VnfAdapterObjectMapperTest method test_createVolumeGroupRequestMapper_for_alaCarte_flow.
@Test
public void test_createVolumeGroupRequestMapper_for_alaCarte_flow() throws Exception {
RequestContext requestContext = new RequestContext();
requestContext.setMsoRequestId("msoRequestId");
ServiceInstance serviceInstance = new ServiceInstance();
serviceInstance.setServiceInstanceId("serviceInstanceId");
ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
modelInfoServiceInstance.setModelVersion("modelVersion");
serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
GenericVnf genericVnf = new GenericVnf();
genericVnf.setVnfId("vnfId");
genericVnf.setVnfName("vnfName");
genericVnf.setVnfType("vnfType");
serviceInstance.getVnfs().add(genericVnf);
ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
modelInfoVfModule.setModelName("modelName");
modelInfoVfModule.setModelCustomizationUUID("modelCustomizationUUID");
VolumeGroup volumeGroup = new VolumeGroup();
volumeGroup.setVolumeGroupId("volumeGroupId");
volumeGroup.setVolumeGroupName("volumeGroupName");
volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
volumeGroup.setModelInfoVfModule(modelInfoVfModule);
serviceInstance.getVnfs().get(0).getVolumeGroups().add(volumeGroup);
CloudRegion cloudRegion = new CloudRegion();
cloudRegion.setLcpCloudRegionId("lcpCloudRegionId");
cloudRegion.setTenantId("tenantId");
OrchestrationContext orchestrationContext = new OrchestrationContext();
orchestrationContext.setIsRollbackEnabled(true);
CreateVolumeGroupRequest expectedCreateVolumeGroupRequest = new CreateVolumeGroupRequest();
expectedCreateVolumeGroupRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
expectedCreateVolumeGroupRequest.setTenantId(cloudRegion.getTenantId());
expectedCreateVolumeGroupRequest.setVolumeGroupId(volumeGroup.getVolumeGroupId());
expectedCreateVolumeGroupRequest.setVolumeGroupName(volumeGroup.getVolumeGroupName());
expectedCreateVolumeGroupRequest.setVnfType(genericVnf.getVnfType());
expectedCreateVolumeGroupRequest.setVnfVersion(serviceInstance.getModelInfoServiceInstance().getModelVersion());
expectedCreateVolumeGroupRequest.setVfModuleType(volumeGroup.getModelInfoVfModule().getModelName());
expectedCreateVolumeGroupRequest.setModelCustomizationUuid(volumeGroup.getModelInfoVfModule().getModelCustomizationUUID());
Map<String, Object> volumeGroupParams = new HashMap<>();
volumeGroupParams.put("vnf_id", genericVnf.getVnfId());
volumeGroupParams.put("vnf_name", genericVnf.getVnfName());
volumeGroupParams.put("vf_module_id", volumeGroup.getVolumeGroupId());
volumeGroupParams.put("vf_module_name", volumeGroup.getVolumeGroupName());
expectedCreateVolumeGroupRequest.setVolumeGroupParams(volumeGroupParams);
expectedCreateVolumeGroupRequest.setSkipAAI(true);
expectedCreateVolumeGroupRequest.setSuppressBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled()));
expectedCreateVolumeGroupRequest.setFailIfExists(false);
MsoRequest msoRequest = new MsoRequest();
msoRequest.setRequestId(requestContext.getMsoRequestId());
msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
expectedCreateVolumeGroupRequest.setMsoRequest(msoRequest);
expectedCreateVolumeGroupRequest.setMessageId("messageId");
expectedCreateVolumeGroupRequest.setNotificationUrl("endpoint/VNFAResponse/messageId");
doReturn("endpoint/").when(vnfAdapterObjectMapper).getProperty(isA(String.class));
doReturn("messageId").when(vnfAdapterObjectMapper).getRandomUuid();
CreateVolumeGroupRequest actualCreateVolumeGroupRequest = vnfAdapterObjectMapper.createVolumeGroupRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, volumeGroup, null);
assertThat(actualCreateVolumeGroupRequest, sameBeanAs(expectedCreateVolumeGroupRequest));
}
use of org.onap.so.entity.MsoRequest in project so by onap.
the class VnfAdapterObjectMapperTest method test_deleteVolumeGroupRequestMapper.
private void test_deleteVolumeGroupRequestMapper(String heatStackId) throws Exception {
DeleteVolumeGroupRequest expectedDeleteVolumeGroupRequest = new DeleteVolumeGroupRequest();
CloudRegion cloudRegion = new CloudRegion();
cloudRegion.setLcpCloudRegionId("lcpCloudRegionId");
expectedDeleteVolumeGroupRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
cloudRegion.setTenantId("tenantId");
expectedDeleteVolumeGroupRequest.setTenantId(cloudRegion.getTenantId());
VolumeGroup volumeGroup = new VolumeGroup();
volumeGroup.setVolumeGroupId("volumeGroupId");
expectedDeleteVolumeGroupRequest.setVolumeGroupId(volumeGroup.getVolumeGroupId());
if (heatStackId != null) {
volumeGroup.setHeatStackId("heatStackId");
expectedDeleteVolumeGroupRequest.setVolumeGroupStackId(volumeGroup.getHeatStackId());
} else {
volumeGroup.setVolumeGroupName("volumeGroupName");
expectedDeleteVolumeGroupRequest.setVolumeGroupStackId(volumeGroup.getVolumeGroupName());
}
expectedDeleteVolumeGroupRequest.setSkipAAI(true);
MsoRequest msoRequest = new MsoRequest();
RequestContext requestContext = new RequestContext();
requestContext.setMsoRequestId("msoRequestId");
msoRequest.setRequestId(requestContext.getMsoRequestId());
ServiceInstance serviceInstance = new ServiceInstance();
serviceInstance.setServiceInstanceId("serviceInstanceId");
msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
expectedDeleteVolumeGroupRequest.setMsoRequest(msoRequest);
String messageId = "messageId";
String endpoint = "endpoint";
doReturn(messageId).when(vnfAdapterObjectMapper).getRandomUuid();
doReturn(endpoint).when(vnfAdapterObjectMapper).getProperty(isA(String.class));
expectedDeleteVolumeGroupRequest.setMessageId(messageId);
expectedDeleteVolumeGroupRequest.setNotificationUrl(endpoint + "/VNFAResponse/" + messageId);
DeleteVolumeGroupRequest actualDeleteVolumeGroupRequest = vnfAdapterObjectMapper.deleteVolumeGroupRequestMapper(requestContext, cloudRegion, serviceInstance, volumeGroup);
assertThat(actualDeleteVolumeGroupRequest, sameBeanAs(expectedDeleteVolumeGroupRequest));
}
Aggregations