Search in sources :

Example 26 with GenericVnf

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

the class SDNOValidatorIT method run.

@Ignore
@Test
public void run() throws Exception {
    SDNOValidatorImpl validator = new SDNOValidatorImpl();
    UUID uuid = UUID.randomUUID();
    GenericVnf vnf = new GenericVnf();
    vnf.setVnfId("test");
    vnf.setIpv4OamAddress("1.2.3.4");
    vnf.setNfRole("VPE");
    SDNO request = validator.buildRequestDiagnostic(vnf, uuid, "mechid");
    ObjectMapper mapper = new ObjectMapper();
    String json = mapper.writeValueAsString(request);
    validator.submitRequest(json);
    thrown.expect(DMaaPConsumerFailure.class);
    boolean result = validator.pollForResponse(uuid.toString());
    System.out.println(json);
}
Also used : GenericVnf(org.onap.aai.domain.yang.GenericVnf) SDNO(org.onap.so.client.sdno.beans.SDNO) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) UUID(java.util.UUID) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Ignore(org.junit.Ignore) BaseIntegrationTest(org.onap.so.BaseIntegrationTest) Test(org.junit.Test)

Example 27 with GenericVnf

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

the class AaiConnection method receiveGenericVnfId.

public String receiveGenericVnfId(final String href) {
    final AAIPluralResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnfs()).queryParam(SELFLINK, href);
    final Optional<GenericVnfs> response = getResourcesClient().get(GenericVnfs.class, resourceUri);
    if (response.isPresent()) {
        final GenericVnfs vnfs = response.get();
        logger.info("The AAI replied with: {}", vnfs);
        final List<GenericVnf> genericVnfList = vnfs.getGenericVnf();
        final int size = genericVnfList.size();
        if (size == 1) {
            final GenericVnf genericVnf = genericVnfList.get(FIRST_INDEX);
            return genericVnf.getVnfId();
        } else if (size > 1) {
            logger.warn("more generic vnfs available");
        }
    }
    return null;
}
Also used : GenericVnf(org.onap.aai.domain.yang.GenericVnf) AAIPluralResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri) GenericVnfs(org.onap.aai.domain.yang.GenericVnfs)

Example 28 with GenericVnf

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

the class AaiResourceIdValidatorTest method validateResourceIdInAAIVnfTest.

@Test
public void validateResourceIdInAAIVnfTest() throws Exception {
    RequestDetails reqDetails = setupRequestDetails();
    WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
    workflowResourceIds.setServiceInstanceId("siId123");
    GenericVnf vnf = new GenericVnf();
    vnf.setVnfId("id123");
    vnf.setModelCustomizationId("1234567");
    Optional<GenericVnf> opVnf = Optional.of(vnf);
    GenericVnf vnf2 = new GenericVnf();
    vnf2.setVnfId("id123");
    vnf2.setModelCustomizationId("222");
    Optional<GenericVnf> opVnf2 = Optional.of(vnf2);
    when(bbInputSetupUtilsMock.getRelatedVnfByNameFromServiceInstance("siId123", "vnfName123")).thenReturn(opVnf);
    when(bbInputSetupUtilsMock.getRelatedVnfByNameFromServiceInstance("siId123", "vnfName222")).thenReturn(opVnf2);
    String id = testedObject.validateResourceIdInAAI("generatedId123", WorkflowType.VNF, "vnfName123", reqDetails, workflowResourceIds);
    assertEquals("id123", id);
    String id2 = testedObject.validateResourceIdInAAI("generatedId123", WorkflowType.VNF, "nameTest", reqDetails, workflowResourceIds);
    assertEquals("generatedId123", id2);
    this.expectedException.expect(DuplicateNameException.class);
    this.expectedException.expectMessage(containsString("generic-vnf with name (vnfName222), same parent and different customization id (222) already exists. The name must be unique."));
    testedObject.validateResourceIdInAAI("generatedId123", WorkflowType.VNF, "vnfName222", reqDetails, workflowResourceIds);
}
Also used : GenericVnf(org.onap.aai.domain.yang.GenericVnf) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) WorkflowResourceIds(org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds) Test(org.junit.Test)

Example 29 with GenericVnf

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

the class AaiResourceIdValidatorTest method validateVnfResourceIdInAAISameModelCustomizationIdTest.

@Test
public void validateVnfResourceIdInAAISameModelCustomizationIdTest() throws Exception {
    RequestDetails reqDetails = setupRequestDetails();
    WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
    workflowResourceIds.setServiceInstanceId("siId123");
    GenericVnf vnf = new GenericVnf();
    vnf.setVnfId("id123");
    vnf.setModelCustomizationId("1234567");
    Optional<GenericVnf> opVnf = Optional.of(vnf);
    when(bbInputSetupUtilsMock.getRelatedVnfByNameFromServiceInstance("siId123", "vnfName123")).thenReturn(opVnf);
    String id = testedObject.validateVnfResourceIdInAAI("generatedId123", "vnfName123", reqDetails, workflowResourceIds);
    assertEquals("id123", id);
}
Also used : GenericVnf(org.onap.aai.domain.yang.GenericVnf) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) WorkflowResourceIds(org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds) Test(org.junit.Test)

Example 30 with GenericVnf

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

the class AaiResourceIdValidatorTest method validateVnfResourceIdInAAIDiffModelCustomizationIdTest.

@Test
public void validateVnfResourceIdInAAIDiffModelCustomizationIdTest() throws Exception {
    RequestDetails reqDetails = setupRequestDetails();
    WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
    workflowResourceIds.setServiceInstanceId("siId123");
    GenericVnf vnf = new GenericVnf();
    vnf.setModelCustomizationId("9999999");
    Optional<GenericVnf> opVnf = Optional.of(vnf);
    when(bbInputSetupUtilsMock.getRelatedVnfByNameFromServiceInstance("siId123", "vnfName123")).thenReturn(opVnf);
    this.expectedException.expect(DuplicateNameException.class);
    this.expectedException.expectMessage(containsString("generic-vnf with name (vnfName123), same parent and different customization id (9999999) already exists. The name must be unique."));
    testedObject.validateVnfResourceIdInAAI("generatedId123", "vnfName123", reqDetails, workflowResourceIds);
}
Also used : GenericVnf(org.onap.aai.domain.yang.GenericVnf) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) WorkflowResourceIds(org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds) Test(org.junit.Test)

Aggregations

GenericVnf (org.onap.aai.domain.yang.GenericVnf)63 Test (org.junit.Test)42 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)15 WorkflowResourceIds (org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds)11 File (java.io.File)9 GenericVnfs (org.onap.aai.domain.yang.GenericVnfs)9 VfModule (org.onap.aai.domain.yang.VfModule)9 BuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock)9 ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)9 ArrayList (java.util.ArrayList)8 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)8 ServiceInstance (org.onap.aai.domain.yang.ServiceInstance)7 AAIPluralResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri)7 RestClient (org.onap.so.client.RestClient)6 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)5 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)5 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)4 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)4 List (java.util.List)3 DelegateExecution (org.camunda.bpm.engine.delegate.DelegateExecution)3