Search in sources :

Example 1 with CtagAssignment

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

the class AAIObjectMapper method mapToAAICtagAssignmentList.

public org.onap.aai.domain.yang.CtagAssignments mapToAAICtagAssignmentList(List<CtagAssignment> ctagAssignmentsList) {
    org.onap.aai.domain.yang.CtagAssignments ctagAssignments = null;
    if (!ctagAssignmentsList.isEmpty()) {
        ctagAssignments = new org.onap.aai.domain.yang.CtagAssignments();
        org.onap.aai.domain.yang.CtagAssignment ctagAssignment = null;
        for (CtagAssignment ctagAssignmentSource : ctagAssignmentsList) {
            ctagAssignment = new org.onap.aai.domain.yang.CtagAssignment();
            ctagAssignment.setVlanIdInner(ctagAssignmentSource.getVlanIdInner());
            ctagAssignments.getCtagAssignment().add(ctagAssignment);
        }
    }
    return ctagAssignments;
}
Also used : CtagAssignment(org.onap.so.bpmn.servicedecomposition.bbobjects.CtagAssignment)

Example 2 with CtagAssignment

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

the class AAIObjectMapperTest method mapToAAICtagAssignmentListTest.

@Test
public void mapToAAICtagAssignmentListTest() throws Exception {
    List<CtagAssignment> ctagAssignments = new ArrayList<CtagAssignment>();
    CtagAssignment ctagAssignment1 = new CtagAssignment();
    ctagAssignment1.setVlanIdInner(1L);
    ctagAssignments.add(ctagAssignment1);
    AAIObjectMapper aaiObjectMapper = new AAIObjectMapper();
    org.onap.aai.domain.yang.CtagAssignments v12CtagAssingments = aaiObjectMapper.mapToAAICtagAssignmentList(ctagAssignments);
    assertEquals(new Long(ctagAssignments.get(0).getVlanIdInner().longValue()), new Long(v12CtagAssingments.getCtagAssignment().get(0).getVlanIdInner()));
    String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiCtagAssingmentsMapped_to_aai.json")));
    ObjectMapper omapper = new ObjectMapper();
    org.onap.aai.domain.yang.CtagAssignments ctagAssignment = omapper.readValue(jsonToCompare, org.onap.aai.domain.yang.CtagAssignments.class);
    ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
    String jsonGenerated = ow.writeValueAsString(v12CtagAssingments);
    String jsonExpected = ow.writeValueAsString(ctagAssignment);
    assertEquals(jsonExpected, jsonGenerated);
}
Also used : ArrayList(java.util.ArrayList) ObjectWriter(com.fasterxml.jackson.databind.ObjectWriter) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) CtagAssignment(org.onap.so.bpmn.servicedecomposition.bbobjects.CtagAssignment) Test(org.junit.Test)

Example 3 with CtagAssignment

use of org.onap.so.bpmn.servicedecomposition.bbobjects.CtagAssignment 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);
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) SegmentationAssignment(org.onap.so.bpmn.servicedecomposition.bbobjects.SegmentationAssignment) ArrayList(java.util.ArrayList) ObjectWriter(com.fasterxml.jackson.databind.ObjectWriter) ModelInfoNetwork(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork) HostRoute(org.onap.so.bpmn.servicedecomposition.bbobjects.HostRoute) Subnet(org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) CtagAssignment(org.onap.so.bpmn.servicedecomposition.bbobjects.CtagAssignment) Test(org.junit.Test)

Aggregations

CtagAssignment (org.onap.so.bpmn.servicedecomposition.bbobjects.CtagAssignment)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 ObjectWriter (com.fasterxml.jackson.databind.ObjectWriter)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 HostRoute (org.onap.so.bpmn.servicedecomposition.bbobjects.HostRoute)1 L3Network (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network)1 SegmentationAssignment (org.onap.so.bpmn.servicedecomposition.bbobjects.SegmentationAssignment)1 Subnet (org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet)1 ModelInfoNetwork (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork)1