Search in sources :

Example 21 with L3Network

use of org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network in project so by onap.

the class CreateNetworkCollectionTest method before.

@Before
public void before() throws BBObjectNotFoundException {
    serviceInstance = setServiceInstance();
    network = setL3Network();
    cloudRegion = setCloudRegion();
    List<L3Network> l3NetworkList = new ArrayList<L3Network>();
    l3NetworkList.add(network);
    ModelInfoInstanceGroup modelInfoInstanceGroup = new ModelInfoInstanceGroup();
    modelInfoInstanceGroup.setFunction("function");
    serviceInstance.getCollection().getInstanceGroup().setModelInfoInstanceGroup(modelInfoInstanceGroup);
    orchestrationContext = setOrchestrationContext();
    orchestrationContext.setIsRollbackEnabled(true);
    doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
    when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
    when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))).thenReturn(serviceInstance);
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) ModelInfoInstanceGroup(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup) BuildingBlockExecution(org.onap.so.bpmn.common.BuildingBlockExecution) ArrayList(java.util.ArrayList) BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException) BpmnError(org.camunda.bpm.engine.delegate.BpmnError) Before(org.junit.Before)

Example 22 with L3Network

use of org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network in project so by onap.

the class AAICreateTasksTest method connectNetworkToNullNetworkCollectionInstanceGroupTest.

@Test
public void connectNetworkToNullNetworkCollectionInstanceGroupTest() throws Exception {
    // reset test data to have no network collection instance group
    ServiceInstance serviceInstance = new ServiceInstance();
    serviceInstance.setServiceInstanceId("testServiceInstanceId");
    L3Network network = new L3Network();
    network.setNetworkId("testNetworkId");
    serviceInstance.getNetworks().add(network);
    lookupKeyMap.put(ResourceKey.NETWORK_ID, network.getNetworkId());
    gBBInput.setServiceInstance(serviceInstance);
    lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, serviceInstance.getServiceInstanceId());
    when(extractPojosForBBMock.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))).thenReturn(serviceInstance);
    when(extractPojosForBBMock.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(serviceInstance);
    // verify connection call was not executednetwork
    exception.expect(BpmnError.class);
    aaiCreateTasks.connectNetworkToNetworkCollectionInstanceGroup(execution);
    verify(aaiNetworkResources, never()).connectNetworkToNetworkCollectionInstanceGroup(network, null);
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) Test(org.junit.Test)

Example 23 with L3Network

use of org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network in project so by onap.

the class AAIUpdateTasksTest method updateNetworkAAITest.

@Test
public void updateNetworkAAITest() {
    L3Network spy = spy(new L3Network());
    L3Network shallowCopy = mock(L3Network.class);
    Subnet mockSubnet = mock(Subnet.class);
    Subnet shallowCopySubnet = mock(Subnet.class);
    when(mockSubnet.shallowCopyId()).thenReturn(shallowCopySubnet);
    doReturn(shallowCopy).when(spy).shallowCopyId();
    doNothing().when(aaiNetworkResources).updateNetwork(network);
    doNothing().when(aaiNetworkResources).updateSubnet(network, subnet);
    spy.getSubnets().add(mockSubnet);
    aaiUpdateTasks.updateNetworkAAI(spy, OrchestrationStatus.CREATED);
    verify(shallowCopy, times(1)).setOrchestrationStatus(OrchestrationStatus.CREATED);
    verify(spy, times(1)).setOrchestrationStatus(OrchestrationStatus.CREATED);
    verify(shallowCopySubnet, times(1)).setOrchestrationStatus(OrchestrationStatus.CREATED);
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) Subnet(org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet) Test(org.junit.Test)

Example 24 with L3Network

use of org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network in project so by onap.

the class NetworkAdapterObjectMapperTest method buildOpenstackSubnetListTest.

@Test
public void buildOpenstackSubnetListTest() throws Exception {
    ObjectMapper omapper = new ObjectMapper();
    String bbJson = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "generalBB.json")));
    org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock gbb = omapper.readValue(bbJson, org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock.class);
    L3Network myNetwork = gbb.getServiceInstance().getNetworks().get(0);
    String expectedCreateNetworkRequestJson = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "createNetworkRequest.json")));
    org.onap.so.adapters.nwrest.CreateNetworkRequest expectedCreateNetworkRequest = omapper.readValue(expectedCreateNetworkRequestJson, org.onap.so.adapters.nwrest.CreateNetworkRequest.class);
    String cloudRegionPo = "cloudRegionPo";
    expectedCreateNetworkRequest.setNotificationUrl("endpoint/NetworkAResponse/messageId");
    doReturn("endpoint/").when(SPY_networkAdapterObjectMapper).getEndpoint();
    doReturn("messageId").when(SPY_networkAdapterObjectMapper).getRandomUuid();
    CreateNetworkRequest createNetworkRequest = SPY_networkAdapterObjectMapper.createNetworkRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, myNetwork, userInput, cloudRegionPo, customer);
    // ignoring dynamic fields and networkParams that throws parsing exception on json file load
    assertThat(createNetworkRequest, sameBeanAs(expectedCreateNetworkRequest).ignoring("messageId").ignoring("msoRequest.requestId").ignoring("networkParams"));
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) CreateNetworkRequest(org.onap.so.adapters.nwrest.CreateNetworkRequest) CreateNetworkRequest(org.onap.so.adapters.nwrest.CreateNetworkRequest) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 25 with L3Network

use of org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network in project so by onap.

the class NetworkAdapterObjectMapperTest method buildOpenstackSubnetListMultipleHostRoutesTest.

@Test
public void buildOpenstackSubnetListMultipleHostRoutesTest() throws Exception {
    ObjectMapper omapper = new ObjectMapper();
    String l3NetworkJson = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "l3-network-multiple-subnets.json")));
    L3Network l3Network = omapper.readValue(l3NetworkJson, L3Network.class);
    List<org.onap.so.openstack.beans.Subnet> subnets = SPY_networkAdapterObjectMapper.buildOpenstackSubnetList(l3Network);
    assertEquals("192.168.0.0/16", subnets.get(0).getHostRoutes().get(0).getPrefix());
    assertEquals("192.168.1.5/16", subnets.get(0).getHostRoutes().get(1).getPrefix());
    assertEquals("NULL", subnets.get(1).getGatewayIp());
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) Subnet(org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Aggregations

L3Network (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network)68 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)34 Test (org.junit.Test)29 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)18 AAIResultWrapper (org.onap.aaiclient.client.aai.entities.AAIResultWrapper)13 CloudRegion (org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion)12 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)12 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)11 BBObjectNotFoundException (org.onap.so.client.exception.BBObjectNotFoundException)11 Service (org.onap.so.db.catalog.beans.Service)11 File (java.io.File)10 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)10 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)10 Relationships (org.onap.aaiclient.client.aai.entities.Relationships)9 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)9 RequestContext (org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext)9 AAIResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)8 Customer (org.onap.so.bpmn.servicedecomposition.bbobjects.Customer)8 ModelInfoNetwork (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork)8 ArrayList (java.util.ArrayList)7