Search in sources :

Example 46 with GenericVnf

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

the class SDNOValidatorImpl method healthDiagnostic.

@Override
public boolean healthDiagnostic(String vnfId, UUID uuid, String requestingUserId) throws IOException, Exception {
    AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId));
    AAIResourcesClient client = new AAIResourcesClient();
    GenericVnf vnf = client.get(GenericVnf.class, uri).orElseThrow(() -> new NotFoundException(vnfId + " not found in A&AI"));
    SDNO requestDiagnostic = buildRequestDiagnostic(vnf, uuid, requestingUserId);
    ObjectMapper mapper = new ObjectMapper();
    String json = mapper.writeValueAsString(requestDiagnostic);
    this.submitRequest(json);
    boolean status = this.pollForResponse(uuid.toString());
    return status;
}
Also used : GenericVnf(org.onap.aai.domain.yang.GenericVnf) SDNO(org.onap.so.client.sdno.beans.SDNO) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) FileNotFoundException(java.io.FileNotFoundException) NotFoundException(javax.ws.rs.NotFoundException) AAIResourcesClient(org.onap.aaiclient.client.aai.AAIResourcesClient) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 47 with GenericVnf

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

the class SDNOValidatorImplTest method buildRequestDiagnosticTest.

@Test
public void buildRequestDiagnosticTest() throws Exception {
    SDNOValidatorImpl validator = new SDNOValidatorImpl();
    UUID uuid = UUID.randomUUID();
    GenericVnf vnf = new GenericVnf();
    vnf.setVnfName("VNFNAME");
    vnf.setVnfId("test");
    vnf.setIpv4OamAddress("1.2.3.4");
    vnf.setNfRole("VPE");
    SDNO request = validator.buildRequestDiagnostic(vnf, uuid, "mechid");
    assertEquals(request.getNodeType(), "VPE");
    assertEquals(request.getOperation(), "health-diagnostic");
    RequestHealthDiagnostic innerRequest = request.getBody().getInput().getRequestHealthDiagnostic();
    assertEquals(innerRequest.getRequestClientName(), "MSO");
    assertEquals(innerRequest.getRequestNodeName(), "VNFNAME");
    assertEquals(innerRequest.getRequestNodeUuid(), "test");
    assertEquals(innerRequest.getRequestNodeType(), "VPE");
    assertEquals(innerRequest.getRequestNodeIp(), "1.2.3.4");
    assertEquals(innerRequest.getRequestUserId(), "mechid");
    assertEquals(innerRequest.getRequestId(), uuid.toString());
    assertEquals(innerRequest.getHealthDiagnosticCode(), "default");
}
Also used : GenericVnf(org.onap.aai.domain.yang.GenericVnf) SDNO(org.onap.so.client.sdno.beans.SDNO) RequestHealthDiagnostic(org.onap.so.client.sdno.beans.RequestHealthDiagnostic) UUID(java.util.UUID) Test(org.junit.Test)

Example 48 with GenericVnf

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

the class BpmnRequestBuilderTest method test_getCloudConfigurationVfModuleReplace.

@Test
public void test_getCloudConfigurationVfModuleReplace() throws Exception {
    String vnfId = "vnfId";
    String vfModuleId = "vfModuleId";
    GenericVnf vnf = provider.getMapper().readValue(new File(RESOURCE_PATH + "Vnf.json"), GenericVnf.class);
    doReturn(Optional.of(vnf)).when(aaiResourcesClient).get(GenericVnf.class, AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)));
    CloudConfiguration result = reqBuilder.getCloudConfigurationVfModuleReplace(vnfId, vfModuleId);
    assertEquals("0422ffb57ba042c0800a29dc85ca70f8", result.getTenantId());
    assertEquals("cloudOwner", result.getCloudOwner());
    assertEquals("regionOne", result.getLcpCloudRegionId());
}
Also used : GenericVnf(org.onap.aai.domain.yang.GenericVnf) CloudConfiguration(org.onap.so.serviceinstancebeans.CloudConfiguration) File(java.io.File) Test(org.junit.Test)

Example 49 with GenericVnf

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

the class BpmnRequestBuilderTest method test_buildVnfDeleteRequest.

@Test
public void test_buildVnfDeleteRequest() throws Exception {
    GenericVnf vnf = provider.getMapper().readValue(new File(RESOURCE_PATH + "Vnf.json"), GenericVnf.class);
    doReturn(Optional.of(vnf)).when(aaiResourcesClient).get(GenericVnf.class, AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("vnfId")));
    ServiceInstancesRequest expectedRequest = mapper.readValue(new File(RESOURCE_PATH + "ExpectedVnfRequest.json"), ServiceInstancesRequest.class);
    ServiceInstancesRequest actualRequest = reqBuilder.buildVnfDeleteRequest("vnfId");
    assertThat(actualRequest, sameBeanAs(expectedRequest));
}
Also used : GenericVnf(org.onap.aai.domain.yang.GenericVnf) File(java.io.File) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) Test(org.junit.Test)

Aggregations

GenericVnf (org.onap.aai.domain.yang.GenericVnf)49 Test (org.junit.Test)36 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 BuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock)9 ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)9 VfModule (org.onap.aai.domain.yang.VfModule)8 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)8 AAIPluralResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri)7 ArrayList (java.util.ArrayList)6 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 ServiceInstance (org.onap.aai.domain.yang.ServiceInstance)3