use of org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet 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.bbobjects.Subnet in project so by onap.
the class TestDataSetup method buildSubnet.
public Subnet buildSubnet() {
Subnet subnet = new Subnet();
subnet.setSubnetId("testSubnetId");
subnet.setOrchestrationStatus(OrchestrationStatus.PENDING);
subnet.setNeutronSubnetId("testNeutronSubnetId");
return subnet;
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet in project so by onap.
the class AAIObjectMapper method mapToAAISubNets.
public org.onap.aai.domain.yang.Subnets mapToAAISubNets(List<Subnet> subnetList) {
org.onap.aai.domain.yang.Subnets subnets = null;
if (!subnetList.isEmpty()) {
subnets = new org.onap.aai.domain.yang.Subnets();
org.onap.aai.domain.yang.Subnet subnet = null;
for (Subnet subnetSource : subnetList) {
subnet = new org.onap.aai.domain.yang.Subnet();
subnet.setSubnetId(subnetSource.getSubnetId());
subnet.setSubnetName(subnetSource.getSubnetName());
subnet.setNeutronSubnetId(subnetSource.getNeutronSubnetId());
subnet.setGatewayAddress(subnetSource.getGatewayAddress());
subnet.setCidrMask(subnetSource.getCidrMask());
subnet.setIpVersion(subnetSource.getIpVersion());
subnet.setOrchestrationStatus(subnetSource.getOrchestrationStatus().toString());
subnet.setCidrMask(subnetSource.getCidrMask());
subnet.setDhcpEnabled(subnetSource.isDhcpEnabled());
subnet.setDhcpStart(subnetSource.getDhcpStart());
subnet.setDhcpEnd(subnetSource.getDhcpEnd());
subnet.setSubnetRole(subnetSource.getSubnetRole());
subnet.setIpAssignmentDirection(subnetSource.getIpAssignmentDirection());
subnet.setSubnetSequence(subnetSource.getSubnetSequence());
org.onap.aai.domain.yang.HostRoutes hostRoutes = new org.onap.aai.domain.yang.HostRoutes();
org.onap.aai.domain.yang.HostRoute hostRoute = null;
for (HostRoute hostRouteSource : subnetSource.getHostRoutes()) {
hostRoute = new org.onap.aai.domain.yang.HostRoute();
hostRoute.setHostRouteId(hostRouteSource.getHostRouteId());
hostRoute.setRoutePrefix(hostRouteSource.getRoutePrefix());
hostRoute.setNextHop(hostRouteSource.getNextHop());
hostRoute.setNextHopType(hostRouteSource.getNextHopType());
hostRoutes.getHostRoute().add(hostRoute);
}
subnet.setHostRoutes(hostRoutes);
subnets.getSubnet().add(subnet);
}
}
return subnets;
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet in project so by onap.
the class AAIObjectMapperTest method mapSubnetTest.
@Test
public void mapSubnetTest() {
Subnet subnet = new Subnet();
subnet.setSubnetId("testSubnetId");
subnet.setOrchestrationStatus(OrchestrationStatus.PENDING);
subnet.setNeutronSubnetId("testNeutronSubnetId");
org.onap.aai.domain.yang.Subnet expectedSubnet = new org.onap.aai.domain.yang.Subnet();
expectedSubnet.setSubnetId("testSubnetId");
expectedSubnet.setOrchestrationStatus("Pending");
expectedSubnet.setNeutronSubnetId("testNeutronSubnetId");
org.onap.aai.domain.yang.Subnet actualSubnet = aaiObjectMapper.mapSubnet(subnet);
assertThat(actualSubnet, sameBeanAs(expectedSubnet));
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet in project so by onap.
the class AAIObjectMapperTest method mapToAAISubNetsTest.
@Test
public void mapToAAISubNetsTest() throws Exception {
List<Subnet> subnets = new ArrayList<Subnet>();
Subnet subnet1 = new Subnet();
subnet1.setSubnetId("57e9a1ff-d14f-4071-a828-b19ae98eb2fc");
subnet1.setSubnetName("subnetName");
subnet1.setGatewayAddress("192.168.52.1");
subnet1.setNetworkStartAddress("192.168.52.0");
subnet1.setCidrMask("24");
subnet1.setIpVersion("4");
subnet1.setOrchestrationStatus(OrchestrationStatus.CREATED);
subnet1.setIpAssignmentDirection("true");
subnet1.setDhcpEnabled(true);
subnet1.setDhcpStart("dhcpStart");
subnet1.setDhcpEnd("dhcpEnd");
subnet1.setSubnetRole("subnetRole");
subnet1.setIpAssignmentDirection("true");
subnet1.setSubnetSequence(new Integer(3));
List<HostRoute> hostRoutes = new ArrayList<HostRoute>();
HostRoute hostRoute1 = new HostRoute();
hostRoute1.setHostRouteId("string");
hostRoute1.setRoutePrefix("192.10.16.0/24");
hostRoute1.setNextHop("192.10.16.100/24");
hostRoute1.setNextHopType("ip-address");
HostRoute hostRoute2 = new HostRoute();
hostRoute2.setHostRouteId("string");
hostRoute2.setRoutePrefix("192.110.17.0/24");
hostRoute2.setNextHop("192.110.17.110/24");
hostRoute2.setNextHopType("ip-address");
hostRoutes.add(hostRoute1);
hostRoutes.add(hostRoute2);
subnet1.getHostRoutes().addAll(hostRoutes);
subnets.add(subnet1);
subnets.add(subnet1);
AAIObjectMapper aaiObjectMapper = new AAIObjectMapper();
org.onap.aai.domain.yang.Subnets v12Subnets = aaiObjectMapper.mapToAAISubNets(subnets);
assertEquals(subnets.get(0).getDhcpEnd(), v12Subnets.getSubnet().get(0).getDhcpEnd());
assertEquals(subnets.get(0).getCidrMask(), v12Subnets.getSubnet().get(0).getCidrMask());
String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiSubnetsMapped_to_aai.json")));
ObjectMapper omapper = new ObjectMapper();
org.onap.aai.domain.yang.Subnets subnet = omapper.readValue(jsonToCompare, org.onap.aai.domain.yang.Subnets.class);
ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
String jsonGenerated = ow.writeValueAsString(v12Subnets);
String jsonExpected = ow.writeValueAsString(subnet);
assertEquals(jsonExpected, jsonGenerated);
}
Aggregations