Search in sources :

Example 21 with OrchestrationContext

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));
}
Also used : CloudRegion(org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion) L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) CreateNetworkRequest(org.onap.so.adapters.nwrest.CreateNetworkRequest) Customer(org.onap.so.bpmn.servicedecomposition.bbobjects.Customer) CreateNetworkResponse(org.onap.so.adapters.nwrest.CreateNetworkResponse) ArrayList(java.util.ArrayList) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) OrchestrationContext(org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext) MsoRequest(org.onap.so.entity.MsoRequest) HostRoute(org.onap.so.bpmn.servicedecomposition.bbobjects.HostRoute) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) Subnet(org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet) Map(java.util.Map) Test(org.junit.Test)

Example 22 with OrchestrationContext

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);
}
Also used : CloudRegion(org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion) L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) Customer(org.onap.so.bpmn.servicedecomposition.bbobjects.Customer) UpdateNetworkRequest(org.onap.so.adapters.nwrest.UpdateNetworkRequest) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) Map(java.util.Map) OrchestrationContext(org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext) UpdateNetworkResponse(org.onap.so.adapters.nwrest.UpdateNetworkResponse) Test(org.junit.Test)

Example 23 with OrchestrationContext

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));
}
Also used : CloudRegion(org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion) L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) RollbackNetworkResponse(org.onap.so.adapters.nwrest.RollbackNetworkResponse) CreateNetworkResponse(org.onap.so.adapters.nwrest.CreateNetworkResponse) RollbackNetworkRequest(org.onap.so.adapters.nwrest.RollbackNetworkRequest) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) Map(java.util.Map) OrchestrationContext(org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext) Test(org.junit.Test)

Example 24 with OrchestrationContext

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"));
}
Also used : CloudRegion(org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion) ModelInfoVfModule(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule) CreateVfModuleRequest(org.onap.so.adapters.vnfrest.CreateVfModuleRequest) ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) ModelInfoVfModule(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) OrchestrationContext(org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) Test(org.junit.Test)

Example 25 with OrchestrationContext

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"));
}
Also used : CloudRegion(org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion) ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) HashMap(java.util.HashMap) ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) ModelInfoVfModule(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) OrchestrationContext(org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext) ModelInfoVfModule(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule) CreateVfModuleRequest(org.onap.so.adapters.vnfrest.CreateVfModuleRequest) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) Test(org.junit.Test)

Aggregations

OrchestrationContext (org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext)29 Test (org.junit.Test)25 CloudRegion (org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion)25 RequestContext (org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext)25 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)24 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)18 VfModule (org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule)16 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)14 HashMap (java.util.HashMap)13 CreateVfModuleRequest (org.onap.so.adapters.vnfrest.CreateVfModuleRequest)13 ModelInfoVfModule (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule)13 ModelInfoGenericVnf (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf)11 VolumeGroup (org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup)7 Customer (org.onap.so.bpmn.servicedecomposition.bbobjects.Customer)6 Map (java.util.Map)5 L3Network (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network)5 CreateVolumeGroupRequest (org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest)4 File (java.io.File)3 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)3 MsoRequest (org.onap.so.entity.MsoRequest)3