Search in sources :

Example 1 with L3Network

use of org.onap.aai.domain.yang.L3Network in project so by onap.

the class ProcessNetwork method doExecute.

@Override
public void doExecute(TestContext context) {
    final Logger logger = LoggerFactory.getLogger(ProcessNetwork.class);
    try {
        int random = (new SecureRandom()).nextInt(50) + 1;
        AAIResourcesClient aaiResourceClient = new AAIResourcesClient();
        if (context.getVariable("action").equals("assign")) {
            String networkId = context.getVariable("generatedNetworkId");
            AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Network(networkId));
            L3Network network = new L3Network();
            network.setNetworkId(networkId);
            network.setNetworkName(context.getVariable("networkName"));
            network.setNetworkType(context.getVariable("networkType"));
            network.setNetworkTechnology("SR_IOV");
            network.setPhysicalNetworkName("PhysicalNetwork" + random);
            aaiResourceClient.create(networkURI, network);
        } else if (context.getVariable("action").equals("delete")) {
            String networkId = context.getVariable("networkId");
            AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Network(networkId));
            aaiResourceClient.delete(networkURI);
        }
    } catch (Exception e) {
        logger.debug("Exception in ProcessNetwork.doExecute", e);
    }
}
Also used : L3Network(org.onap.aai.domain.yang.L3Network) SecureRandom(java.security.SecureRandom) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) Logger(org.slf4j.Logger) AAIResourcesClient(org.onap.aaiclient.client.aai.AAIResourcesClient)

Example 2 with L3Network

use of org.onap.aai.domain.yang.L3Network in project so by onap.

the class BBInputSetupUtilsTest method getRelatedNetworkByNameFromServiceInstanceTest.

@Test
public void getRelatedNetworkByNameFromServiceInstanceTest() throws Exception {
    final String networkId = "id123";
    final String networkName = "name123";
    Optional<L3Networks> expected = Optional.of(new L3Networks());
    L3Network network = new L3Network();
    network.setNetworkId(networkId);
    network.setNetworkName(networkName);
    expected.get().getL3Network().add(network);
    doReturn(expected).when(MOCK_aaiResourcesClient).get(eq(L3Networks.class), any(AAIPluralResourceUri.class));
    Optional<L3Network> actual = bbInputSetupUtils.getRelatedNetworkByNameFromServiceInstance(networkId, networkName);
    assertTrue(actual.isPresent());
    assertEquals(networkId, actual.get().getNetworkId());
    assertEquals(networkName, actual.get().getNetworkName());
    assertEquals(expected.get().getL3Network().get(0).getNetworkId(), actual.get().getNetworkId());
}
Also used : L3Network(org.onap.aai.domain.yang.L3Network) AAIPluralResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri) L3Networks(org.onap.aai.domain.yang.L3Networks) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 3 with L3Network

use of org.onap.aai.domain.yang.L3Network in project so by onap.

the class BBInputSetupUtilsTest method getAICVpnBindingFromNetwork_noVpnBindingTest.

@Test
public void getAICVpnBindingFromNetwork_noVpnBindingTest() throws IOException {
    L3Network l3Network = mapper.readValue(new File(RESOURCE_PATH + "aaiL3NetworkInputWithSubnets.json"), L3Network.class);
    Optional<VpnBinding> actual = bbInputSetupUtils.getAICVpnBindingFromNetwork(l3Network);
    assertEquals(Optional.empty(), actual);
}
Also used : L3Network(org.onap.aai.domain.yang.L3Network) VpnBinding(org.onap.aai.domain.yang.VpnBinding) File(java.io.File) Test(org.junit.Test)

Example 4 with L3Network

use of org.onap.aai.domain.yang.L3Network in project so by onap.

the class NetworkBBUtilsTest method isRelationshipRelatedToExistsFalseTest.

@Test
public void isRelationshipRelatedToExistsFalseTest() throws Exception {
    final String aaiResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAAIResponse.json")));
    AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(aaiResponse);
    Optional<L3Network> l3network = aaiResultWrapper.asBean(L3Network.class);
    boolean isVfModule = networkBBUtils.isRelationshipRelatedToExists(l3network, "vf-module");
    assertFalse(isVfModule);
}
Also used : L3Network(org.onap.aai.domain.yang.L3Network) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 5 with L3Network

use of org.onap.aai.domain.yang.L3Network in project so by onap.

the class AaiResourceIdValidatorTest method validateNetworkResourceIdInAAISameModelCustIdTest.

@Test
public void validateNetworkResourceIdInAAISameModelCustIdTest() throws Exception {
    RequestDetails reqDetails = setupRequestDetails();
    WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
    workflowResourceIds.setServiceInstanceId("siId123");
    L3Network network = new L3Network();
    network.setNetworkId("id123");
    network.setModelCustomizationId("1234567");
    Optional<L3Network> opNetwork = Optional.of(network);
    when(bbInputSetupUtilsMock.getRelatedNetworkByNameFromServiceInstance("siId123", "name123")).thenReturn(opNetwork);
    String id = testedObject.validateNetworkResourceIdInAAI("generatedId123", "name123", reqDetails, workflowResourceIds);
    assertEquals("id123", id);
}
Also used : L3Network(org.onap.aai.domain.yang.L3Network) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) WorkflowResourceIds(org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds) Test(org.junit.Test)

Aggregations

L3Network (org.onap.aai.domain.yang.L3Network)14 Test (org.junit.Test)10 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 L3Networks (org.onap.aai.domain.yang.L3Networks)3 AAIResultWrapper (org.onap.aaiclient.client.aai.entities.AAIResultWrapper)3 AAIPluralResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri)3 WorkflowResourceIds (org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds)3 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)3 File (java.io.File)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 VpnBinding (org.onap.aai.domain.yang.VpnBinding)2 AAIResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)2 SecureRandom (java.security.SecureRandom)1 Relationship (org.onap.aai.domain.yang.Relationship)1 RelationshipList (org.onap.aai.domain.yang.RelationshipList)1 RouteTarget (org.onap.aai.domain.yang.RouteTarget)1 RouteTargets (org.onap.aai.domain.yang.RouteTargets)1 AAIResourcesClient (org.onap.aaiclient.client.aai.AAIResourcesClient)1 MultipleObjectsFoundException (org.onap.so.bpmn.servicedecomposition.tasks.exceptions.MultipleObjectsFoundException)1