use of org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext in project so by onap.
the class NetworkAdapterResourcesTest method createNetworTest.
@Test
public void createNetworTest() throws Exception {
String cloudRegionPo = "cloudRegionPo";
CreateNetworkRequest expectedCreateNetworkRequest = new CreateNetworkRequest();
expectedCreateNetworkRequest.setCloudSiteId(cloudRegionPo);
expectedCreateNetworkRequest.setTenantId(cloudRegion.getTenantId());
expectedCreateNetworkRequest.setNetworkId(l3Network.getNetworkId());
expectedCreateNetworkRequest.setNetworkName(l3Network.getNetworkName());
expectedCreateNetworkRequest.setBackout(false);
expectedCreateNetworkRequest.setFailIfExists(true);
MsoRequest msoRequest = new MsoRequest();
msoRequest.setRequestId(requestContext.getMsoRequestId());
msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
expectedCreateNetworkRequest.setMsoRequest(msoRequest);
expectedCreateNetworkRequest.setSkipAAI(true);
Subnet openstackSubnet = new Subnet();
HostRoute hostRoute = new HostRoute();
hostRoute.setHostRouteId("hostRouteId");
hostRoute.setNextHop("nextHop");
hostRoute.setRoutePrefix("routePrefix");
openstackSubnet.getHostRoutes().add(hostRoute);
List<Subnet> subnetList = new ArrayList<Subnet>();
subnetList.add(openstackSubnet);
l3Network.getSubnets().add(openstackSubnet);
l3Network.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
CreateNetworkRequest createNetworkRequest = new CreateNetworkRequest();
createNetworkRequest.setCloudSiteId("cloudSiteId");
CreateNetworkResponse expectedCreateNetworkResponse = new CreateNetworkResponse();
expectedCreateNetworkResponse.setNetworkStackId("networkStackId");
expectedCreateNetworkResponse.setNetworkCreated(true);
doReturn(expectedCreateNetworkResponse).when(MOCK_networkAdapterClient).createNetwork(isA(CreateNetworkRequest.class));
doReturn(createNetworkRequest).when(MOCK_networkAdapterObjectMapper).createNetworkRequestMapper(isA(RequestContext.class), isA(CloudRegion.class), isA(OrchestrationContext.class), isA(ServiceInstance.class), isA(L3Network.class), isA(Map.class), isA(String.class), isA(Customer.class));
CreateNetworkResponse actualCreateNetwrokResponse = (networkAdapterResources.createNetwork(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, customer)).get();
verify(MOCK_networkAdapterClient, times(1)).createNetwork(createNetworkRequest);
verify(MOCK_networkAdapterObjectMapper, times(1)).createNetworkRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, customer);
assertThat(expectedCreateNetworkResponse, Matchers.sameBeanAs(actualCreateNetwrokResponse));
}
use of org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext in project so by onap.
the class NetworkAdapterResourcesTest method updateNetworkTest.
@Test
public void updateNetworkTest() throws UnsupportedEncodingException, NetworkAdapterClientException {
doReturn(new UpdateNetworkRequest()).when(MOCK_networkAdapterObjectMapper).createNetworkUpdateRequestMapper(isA(RequestContext.class), isA(CloudRegion.class), isA(OrchestrationContext.class), isA(ServiceInstance.class), isA(L3Network.class), isA(Map.class), isA(Customer.class));
doReturn(new UpdateNetworkResponse()).when(MOCK_networkAdapterClient).updateNetwork(isA(String.class), isA(UpdateNetworkRequest.class));
Optional<UpdateNetworkResponse> actualUpdateNetworkResponse = networkAdapterResources.updateNetwork(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, customer);
verify(MOCK_networkAdapterObjectMapper, times(1)).createNetworkUpdateRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, customer);
verify(MOCK_networkAdapterClient, times(1)).updateNetwork(isA(String.class), isA(UpdateNetworkRequest.class));
assertNotNull(actualUpdateNetworkResponse);
}
use of org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext in project so by onap.
the class NetworkAdapterResourcesTest method rollbackCreateNetworkTest.
@Test
public void rollbackCreateNetworkTest() throws Exception {
String cloudRegionPo = "cloudRegionPo";
RollbackNetworkResponse expectedRollbackNetworkResponse = new RollbackNetworkResponse();
expectedRollbackNetworkResponse.setMessageId("messageId");
expectedRollbackNetworkResponse.setNetworkRolledBack(true);
RollbackNetworkRequest rollbackNetworkRequest = new RollbackNetworkRequest();
rollbackNetworkRequest.setMessageId("messageId");
RollbackNetworkResponse rollbackNetworkResponse = new RollbackNetworkResponse();
rollbackNetworkResponse.setMessageId("messageId");
rollbackNetworkResponse.setNetworkRolledBack(true);
CreateNetworkResponse createNetworkResponse = new CreateNetworkResponse();
createNetworkResponse.setMessageId("messageId");
doReturn(rollbackNetworkResponse).when(MOCK_networkAdapterClient).rollbackNetwork(isA(String.class), isA(RollbackNetworkRequest.class));
doReturn(rollbackNetworkRequest).when(MOCK_networkAdapterObjectMapper).createNetworkRollbackRequestMapper(isA(RequestContext.class), isA(CloudRegion.class), isA(OrchestrationContext.class), isA(ServiceInstance.class), isA(L3Network.class), isA(Map.class), isA(String.class), isA(CreateNetworkResponse.class));
RollbackNetworkResponse actualRollbackCreateNetwrokResponse = (networkAdapterResources.rollbackCreateNetwork(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, createNetworkResponse)).get();
verify(MOCK_networkAdapterClient, times(1)).rollbackNetwork(l3Network.getNetworkId(), rollbackNetworkRequest);
verify(MOCK_networkAdapterObjectMapper, times(1)).createNetworkRollbackRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, createNetworkResponse);
assertThat(expectedRollbackNetworkResponse, Matchers.sameBeanAs(actualRollbackCreateNetwrokResponse));
}
use of org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext in project so by onap.
the class VnfAdapterVfModuleObjectMapperPayloadTest method createVfModuleRequestMapperWithNullUserParamsTest.
@Test
public void createVfModuleRequestMapperWithNullUserParamsTest() throws Exception {
// prepare and set service instance
ServiceInstance serviceInstance = new ServiceInstance();
serviceInstance.setServiceInstanceId("serviceInstanceId");
ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
modelInfoServiceInstance.setModelName("serviceModelName");
modelInfoServiceInstance.setModelUuid("serviceModelUuid");
modelInfoServiceInstance.setModelVersion("serviceModelVersion");
modelInfoServiceInstance.setEnvironmentContext("environmentContext");
modelInfoServiceInstance.setWorkloadContext("workloadContext");
serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
RequestContext requestContext = new RequestContext();
requestContext.setMsoRequestId("requestId");
requestContext.setProductFamilyId("productFamilyId");
GenericVnf vnf = new GenericVnf();
vnf.setVnfId("vnfId");
vnf.setVnfType("vnfType");
vnf.setVnfName("vnfName");
ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
modelInfoGenericVnf.setModelName("vnfModelName");
modelInfoGenericVnf.setModelVersion("vnfModelVersion");
modelInfoGenericVnf.setModelUuid("vnfModelUuid");
modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
Integer vfModuleIndex = 1;
VfModule vfModule = new VfModule();
vfModule.setVfModuleId("vfModuleId");
vfModule.setVfModuleName("vfModuleName");
vfModule.setModuleIndex(vfModuleIndex);
ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
modelInfoVfModule.setModelName("vfModuleModelName");
modelInfoVfModule.setModelVersion("vfModuleModelVersion");
modelInfoVfModule.setModelUUID("vfModuleModelUuid");
modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
vfModule.setModelInfoVfModule(modelInfoVfModule);
CloudRegion cloudRegion = new CloudRegion();
cloudRegion.setLcpCloudRegionId("cloudRegionId");
cloudRegion.setTenantId("tenantId");
OrchestrationContext orchestrationContext = new OrchestrationContext();
orchestrationContext.setIsRollbackEnabled(false);
String sdncVnfQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopology.json")));
String sdncVfModuleQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
CreateVfModuleRequest vfModuleVNFAdapterRequest = vfModuleObjectMapper.createVfModuleRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, vnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleRequestNoUserParams.json")));
CreateVfModuleRequest reqMapper1 = omapper.readValue(jsonToCompare, CreateVfModuleRequest.class);
assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl"));
}
use of org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext in project so by onap.
the class VnfAdapterVfModuleObjectMapperPayloadTest method createVfModuleRequestMapperDhcpDisabledTest.
@Test
public void createVfModuleRequestMapperDhcpDisabledTest() throws Exception {
// prepare and set service instance
ServiceInstance serviceInstance = new ServiceInstance();
serviceInstance.setServiceInstanceId("serviceInstanceId");
ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
modelInfoServiceInstance.setModelName("serviceModelName");
modelInfoServiceInstance.setModelUuid("serviceModelUuid");
modelInfoServiceInstance.setModelVersion("serviceModelVersion");
modelInfoServiceInstance.setEnvironmentContext("environmentContext");
modelInfoServiceInstance.setWorkloadContext("workloadContext");
serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
RequestContext requestContext = new RequestContext();
Map<String, Object> userParams = new HashMap<>();
userParams.put("key1", "value1");
requestContext.setMsoRequestId("requestId");
requestContext.setUserParams(userParams);
requestContext.setProductFamilyId("productFamilyId");
GenericVnf vnf = new GenericVnf();
vnf.setVnfId("vnfId");
vnf.setVnfType("vnfType");
vnf.setVnfName("vnfName");
ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
modelInfoGenericVnf.setModelName("vnfModelName");
modelInfoGenericVnf.setModelVersion("vnfModelVersion");
modelInfoGenericVnf.setModelUuid("vnfModelUuid");
modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
Integer vfModuleIndex = 1;
VfModule vfModule = new VfModule();
vfModule.setVfModuleId("vfModuleId");
vfModule.setVfModuleName("vfModuleName");
vfModule.setModuleIndex(vfModuleIndex);
ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
modelInfoVfModule.setModelName("vfModuleModelName");
modelInfoVfModule.setModelVersion("vfModuleModelVersion");
modelInfoVfModule.setModelUUID("vfModuleModelUuid");
modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
vfModule.setModelInfoVfModule(modelInfoVfModule);
CloudRegion cloudRegion = new CloudRegion();
cloudRegion.setLcpCloudRegionId("cloudRegionId");
cloudRegion.setTenantId("tenantId");
OrchestrationContext orchestrationContext = new OrchestrationContext();
orchestrationContext.setIsRollbackEnabled(false);
String sdncVnfQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopologySubnetDhcpDisabled.json")));
String sdncVfModuleQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
CreateVfModuleRequest vfModuleVNFAdapterRequest = vfModuleObjectMapper.createVfModuleRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, vnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleRequestDhcpDisabled.json")));
CreateVfModuleRequest reqMapper1 = omapper.readValue(jsonToCompare, CreateVfModuleRequest.class);
assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl"));
}
Aggregations