use of org.onap.so.bpmn.servicedecomposition.bbobjects.SegmentationAssignment in project so by onap.
the class AAIObjectMapperTest method mapToAAISegmentationAssignmentListTest.
@Test
public void mapToAAISegmentationAssignmentListTest() throws Exception {
List<SegmentationAssignment> segmentationAssignments = new ArrayList<SegmentationAssignment>();
SegmentationAssignment segmentationAssignment1 = new SegmentationAssignment();
segmentationAssignment1.setSegmentationId("segmentationId1");
SegmentationAssignment segmentationAssignment2 = new SegmentationAssignment();
segmentationAssignment2.setSegmentationId("segmentationId2");
segmentationAssignments.add(segmentationAssignment1);
segmentationAssignments.add(segmentationAssignment2);
AAIObjectMapper aaiObjectMapper = new AAIObjectMapper();
org.onap.aai.domain.yang.SegmentationAssignments v12SegmentationAssignments = aaiObjectMapper.mapToAAISegmentationAssignmentList(segmentationAssignments);
assertEquals(segmentationAssignments.get(0).getSegmentationId(), v12SegmentationAssignments.getSegmentationAssignment().get(0).getSegmentationId());
assertEquals(segmentationAssignments.get(1).getSegmentationId(), v12SegmentationAssignments.getSegmentationAssignment().get(1).getSegmentationId());
String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiSegmentationAssignmentsMapped_to_aai.json")));
ObjectMapper omapper = new ObjectMapper();
org.onap.aai.domain.yang.SegmentationAssignments segmentationAssignment = omapper.readValue(jsonToCompare, org.onap.aai.domain.yang.SegmentationAssignments.class);
ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
String jsonGenerated = ow.writeValueAsString(v12SegmentationAssignments);
String jsonExpected = ow.writeValueAsString(segmentationAssignment);
assertEquals(jsonExpected, jsonGenerated);
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.SegmentationAssignment in project so by onap.
the class NetworkAdapterObjectMapper method buildProviderVlanNetwork.
private ProviderVlanNetwork buildProviderVlanNetwork(L3Network l3Network) {
ProviderVlanNetwork providerVlanNetwork = new ProviderVlanNetwork();
providerVlanNetwork.setPhysicalNetworkName(l3Network.getPhysicalNetworkName());
List<Integer> vlans = new ArrayList<>();
List<SegmentationAssignment> segmentationAssignments = l3Network.getSegmentationAssignments();
for (SegmentationAssignment assignment : segmentationAssignments) {
vlans.add(Integer.valueOf(assignment.getSegmentationId()));
}
providerVlanNetwork.setVlans(vlans);
return providerVlanNetwork;
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.SegmentationAssignment in project so by onap.
the class AAIObjectMapper method mapToAAISegmentationAssignmentList.
public org.onap.aai.domain.yang.SegmentationAssignments mapToAAISegmentationAssignmentList(List<SegmentationAssignment> segmentationAssignmentList) {
org.onap.aai.domain.yang.SegmentationAssignments segmentationAssignments = null;
if (!segmentationAssignmentList.isEmpty()) {
segmentationAssignments = new org.onap.aai.domain.yang.SegmentationAssignments();
org.onap.aai.domain.yang.SegmentationAssignment segmentationAssignment = null;
for (SegmentationAssignment segmentationAssignmentSource : segmentationAssignmentList) {
segmentationAssignment = new org.onap.aai.domain.yang.SegmentationAssignment();
segmentationAssignment.setSegmentationId(segmentationAssignmentSource.getSegmentationId());
segmentationAssignments.getSegmentationAssignment().add(segmentationAssignment);
}
}
return segmentationAssignments;
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.SegmentationAssignment in project so by onap.
the class AAIObjectMapperTest method mapNetworkTest.
@Test
public void mapNetworkTest() throws Exception {
L3Network l3Network = new L3Network();
ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
modelInfoNetwork.setModelCustomizationUUID("modelCustomization_id");
modelInfoNetwork.setModelInvariantUUID("modelInvariant_id");
modelInfoNetwork.setModelUUID("modelCustomization_id");
modelInfoNetwork.setNetworkType("CONTRAIL_EXTERNAL");
modelInfoNetwork.setNetworkRole("dmz_direct");
modelInfoNetwork.setNetworkTechnology("contrail");
l3Network.setModelInfoNetwork(modelInfoNetwork);
l3Network.setNetworkId("TESTING_ID");
l3Network.setNetworkName("TESTING_NAME");
l3Network.setIsBoundToVpn(true);
l3Network.setServiceId("a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb");
l3Network.setNetworkRoleInstance(1L);
l3Network.setOrchestrationStatus(OrchestrationStatus.CREATED);
l3Network.setHeatStackId("heatStack_id");
l3Network.setContrailNetworkFqdn("contrailNetwork_fqdn");
l3Network.setWidgetModelId("widgetModel_id");
l3Network.setWidgetModelVersion("widgetModel_version");
l3Network.setPhysicalNetworkName("physicalNetwork_name");
l3Network.setIsProviderNetwork(true);
l3Network.setIsSharedNetwork(false);
l3Network.setIsExternalNetwork(true);
l3Network.setSelflink("self_link");
l3Network.setOperationalStatus("operationalStatus");
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);
l3Network.getSubnets().addAll(subnets);
List<CtagAssignment> ctagAssignments = new ArrayList<CtagAssignment>();
CtagAssignment ctagAssignment1 = new CtagAssignment();
ctagAssignment1.setVlanIdInner(1L);
ctagAssignments.add(ctagAssignment1);
l3Network.getCtagAssignments().addAll(ctagAssignments);
List<SegmentationAssignment> segmentationAssignments = new ArrayList<SegmentationAssignment>();
SegmentationAssignment segmentationAssignment1 = new SegmentationAssignment();
segmentationAssignment1.setSegmentationId("segmentationId1");
SegmentationAssignment segmentationAssignment2 = new SegmentationAssignment();
segmentationAssignment2.setSegmentationId("segmentationId2");
segmentationAssignments.add(segmentationAssignment1);
segmentationAssignments.add(segmentationAssignment2);
l3Network.getSegmentationAssignments().addAll(segmentationAssignments);
AAIObjectMapper l3NetworkMapper = new AAIObjectMapper();
org.onap.aai.domain.yang.L3Network v12L3Network = l3NetworkMapper.mapNetwork(l3Network);
String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiL3NetworkMapped_to_aai.json")));
ObjectMapper omapper = new ObjectMapper();
org.onap.aai.domain.yang.L3Network network = omapper.readValue(jsonToCompare, org.onap.aai.domain.yang.L3Network.class);
ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
String jsonGenerated = ow.writeValueAsString(v12L3Network);
String jsonExpected = ow.writeValueAsString(network);
assertEquals(jsonExpected, jsonGenerated);
}
Aggregations