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);
}
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);
}
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);
}
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"));
}
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());
}
Aggregations