Search in sources :

Example 61 with L3Network

use of org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network 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)

Example 62 with L3Network

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

the class BBInputSetupTest method testMapCatalogNetwork.

@Test
public void testMapCatalogNetwork() {
    ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
    L3Network network = new L3Network();
    RequestDetails requestDetails = new RequestDetails();
    ModelInfo modelInfo = new ModelInfo();
    modelInfo.setModelCustomizationUuid("modelCustomizationUUID");
    requestDetails.setModelInfo(modelInfo);
    Service service = new Service();
    NetworkResourceCustomization resourceCust = new NetworkResourceCustomization();
    resourceCust.setModelCustomizationUUID("modelCustomizationUUID");
    service.setNetworkCustomizations(Arrays.asList(new NetworkResourceCustomization[] { resourceCust }));
    doReturn(modelInfoNetwork).when(bbInputSetupMapperLayer).mapCatalogNetworkToNetwork(resourceCust);
    SPY_bbInputSetup.mapCatalogNetwork(network, modelInfo, service);
    assertEquals(modelInfoNetwork, network.getModelInfoNetwork());
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) ModelInfoNetwork(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork) Service(org.onap.so.db.catalog.beans.Service) CollectionNetworkResourceCustomization(org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization) NetworkResourceCustomization(org.onap.so.db.catalog.beans.NetworkResourceCustomization) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) Test(org.junit.Test)

Example 63 with L3Network

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

the class BBInputSetupTest method test_getGBBMacroNoUserParamsExistingService_forControllerExecutionBB.

@Test
public void test_getGBBMacroNoUserParamsExistingService_forControllerExecutionBB() throws Exception {
    // given
    String requestAction = "unassignInstance";
    GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"), GeneralBuildingBlock.class);
    L3Network network = new L3Network();
    network.setNetworkId("networkId");
    gBB.getServiceInstance().getNetworks().add(network);
    ServiceInstance serviceInstance = gBB.getServiceInstance();
    ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"), ExecuteBuildingBlock.class);
    RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
    requestDetails.getRequestParameters().setUserParams(null);
    Map<ResourceKey, String> lookupKeyMap = prepareLookupKeyMap();
    Service service = Mockito.mock(Service.class);
    CloudConfiguration cloudConfiguration = new CloudConfiguration();
    cloudConfiguration.setLcpCloudRegionId("cloudRegionId");
    org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
    org.onap.aai.domain.yang.L3Network aaiNetwork = new org.onap.aai.domain.yang.L3Network();
    aaiNetwork.setModelCustomizationId("modelCustId");
    GenericVnf vnf = new GenericVnf();
    vnf.setVnfId("vnfId");
    gBB.getServiceInstance().getVnfs().add(vnf);
    org.onap.aai.domain.yang.GenericVnf aaiVnf = new org.onap.aai.domain.yang.GenericVnf();
    aaiVnf.setModelCustomizationId("modelCustId");
    ConfigurationResourceKeys configResourceKeys = prepareConfigurationResourceKeys();
    executeBB.setConfigurationResourceKeys(configResourceKeys).setRequestDetails(requestDetails);
    BuildingBlock buildingBlock = executeBB.getBuildingBlock();
    buildingBlock.setBpmnFlowName("ControllerExecutionBB").setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
    buildingBlock.setBpmnScope("VNF");
    aaiServiceInstance.setModelVersionId("modelVersionId");
    doReturn(service).when(SPY_bbInputSetupUtils).getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
    doReturn(aaiServiceInstance).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById(lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
    doReturn(serviceInstance).when(SPY_bbInputSetup).getExistingServiceInstance(aaiServiceInstance);
    doReturn(gBB).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(any(BBInputSetupParameter.class));
    doReturn(aaiVnf).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf.getVnfId());
    doNothing().when(SPY_bbInputSetup).mapCatalogVnf(any(GenericVnf.class), any(ModelInfo.class), any(Service.class));
    // when
    SPY_bbInputSetup.getGBBMacroExistingService(executeBB, lookupKeyMap, executeBB.getBuildingBlock().getBpmnFlowName(), requestAction, cloudConfiguration);
    // then
    verify(SPY_bbInputSetup, times(1)).mapCatalogVnf(any(GenericVnf.class), any(ModelInfo.class), any(Service.class));
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) Service(org.onap.so.db.catalog.beans.Service) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) ResourceKey(org.onap.so.bpmn.servicedecomposition.entities.ResourceKey) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) CloudConfiguration(org.onap.so.serviceinstancebeans.CloudConfiguration) ConfigurationResourceKeys(org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys) BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys(org.onap.so.bpmn.servicedecomposition.tasks.BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys) File(java.io.File) Test(org.junit.Test)

Example 64 with L3Network

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

the class BBInputSetupTest method testMapCatalogConfiguration.

@Test
public void testMapCatalogConfiguration() {
    ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
    L3Network network = new L3Network();
    RequestDetails requestDetails = new RequestDetails();
    ModelInfo modelInfo = new ModelInfo();
    modelInfo.setModelCustomizationUuid("modelCustomizationUUID");
    requestDetails.setModelInfo(modelInfo);
    Service service = new Service();
    NetworkResourceCustomization resourceCust = new NetworkResourceCustomization();
    resourceCust.setModelCustomizationUUID("modelCustomizationUUID");
    service.setNetworkCustomizations(Arrays.asList(new NetworkResourceCustomization[] { resourceCust }));
    doReturn(modelInfoNetwork).when(bbInputSetupMapperLayer).mapCatalogNetworkToNetwork(resourceCust);
    SPY_bbInputSetup.mapCatalogNetwork(network, modelInfo, service);
    assertEquals(modelInfoNetwork, network.getModelInfoNetwork());
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) ModelInfoNetwork(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork) Service(org.onap.so.db.catalog.beans.Service) CollectionNetworkResourceCustomization(org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization) NetworkResourceCustomization(org.onap.so.db.catalog.beans.NetworkResourceCustomization) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) Test(org.junit.Test)

Example 65 with L3Network

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

the class BBInputSetupTest method testCreateNetwork.

@Test
public void testCreateNetwork() {
    String networkId = "networkId";
    String instanceName = "networkName";
    Map<String, String> cloudParams = new HashMap<>();
    cloudParams.put("param1", "param1Value");
    L3Network expected = new L3Network();
    expected.setNetworkId(networkId);
    expected.setNetworkName(instanceName);
    expected.setCloudParams(cloudParams);
    Platform platform = new Platform();
    platform.setPlatformName("platformName");
    expected.setPlatform(platform);
    LineOfBusiness lineOfBusiness = new LineOfBusiness();
    lineOfBusiness.setLineOfBusinessName("lineOfBusiness");
    expected.setLineOfBusiness(lineOfBusiness);
    expected.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
    Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
    List<Map<String, String>> instanceParams = new ArrayList<>();
    instanceParams.add(cloudParams);
    org.onap.so.serviceinstancebeans.Platform platformRequest = new org.onap.so.serviceinstancebeans.Platform();
    org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusinessRequest = new org.onap.so.serviceinstancebeans.LineOfBusiness();
    lineOfBusinessRequest.setLineOfBusinessName("lineOfBusiness");
    platformRequest.setPlatformName("platformName");
    BBInputSetupParameter parameter = new BBInputSetupParameter.Builder().setRequestId(REQUEST_ID).setPlatform(platformRequest).setLineOfBusiness(lineOfBusinessRequest).build();
    L3Network actual = SPY_bbInputSetup.createNetwork(lookupKeyMap, instanceName, networkId, instanceParams, parameter);
    assertThat(actual, sameBeanAs(expected));
    assertEquals("LookupKeyMap is populated", networkId, lookupKeyMap.get(ResourceKey.NETWORK_ID));
    expected.getCloudParams().clear();
    actual = SPY_bbInputSetup.createNetwork(lookupKeyMap, instanceName, networkId, null, parameter);
    assertThat(actual, sameBeanAs(expected));
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) Platform(org.onap.so.bpmn.servicedecomposition.bbobjects.Platform) HashMap(java.util.HashMap) AAIFluentTypeBuilder(org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder) ArrayList(java.util.ArrayList) ResourceKey(org.onap.so.bpmn.servicedecomposition.entities.ResourceKey) LineOfBusiness(org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness) Map(java.util.Map) BaseBBInputSetupTestHelper.prepareLookupKeyMap(org.onap.so.bpmn.servicedecomposition.tasks.BaseBBInputSetupTestHelper.prepareLookupKeyMap) HashMap(java.util.HashMap) 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