Search in sources :

Example 21 with GenericVnf

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

the class MonitorInstantiateVnfmNodeTaskTest method testGetNodeStatus_genericVnfWithOrchStatusCreated_executionVariableSetToCreate.

@Test
public void testGetNodeStatus_genericVnfWithOrchStatusCreated_executionVariableSetToCreate() throws Exception {
    final org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf = getGenericVnf();
    final GenericVnf aaiGenericVnf = getAAIGenericVnf();
    aaiGenericVnf.setOrchestrationStatus(VNF_CREATED);
    when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(vnf);
    when(mockedAaiVnfResources.getGenericVnf(eq(VNF_ID))).thenReturn(Optional.of(aaiGenericVnf));
    objUnderTest.getNodeStatus(stubbedxecution);
    assertTrue(stubbedxecution.getVariable(CREATE_VNF_NODE_STATUS));
}
Also used : GenericVnf(org.onap.aai.domain.yang.GenericVnf) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 22 with GenericVnf

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

the class MonitorTerminateVnfmNodeTaskTest method getAAIGenericVnf.

private GenericVnf getAAIGenericVnf() {
    final GenericVnf genericVnf = new GenericVnf();
    genericVnf.setVnfId(VNF_ID);
    genericVnf.setVnfName(VNF_NAME);
    return genericVnf;
}
Also used : GenericVnf(org.onap.aai.domain.yang.GenericVnf)

Example 23 with GenericVnf

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

the class AAIResourcesClientTest method testGetFirstWrongPluralClass.

@Test
public void testGetFirstWrongPluralClass() {
    GenericVnf vnf = new GenericVnf();
    AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnfs());
    RestClient restClientMock = mock(RestClient.class);
    doReturn(restClientMock).when(client).createClient(uri);
    when(restClientMock.get(GenericVnf.class)).thenReturn(Optional.of(vnf));
    Optional<GenericVnf> result = aaiClient.getFirst(GenericVnf.class, GenericVnf.class, uri);
    assertFalse(result.isPresent());
}
Also used : GenericVnf(org.onap.aai.domain.yang.GenericVnf) AAIPluralResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri) RestClient(org.onap.so.client.RestClient) Test(org.junit.Test)

Example 24 with GenericVnf

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

the class AAIResourcesClientTest method testGetFirstMultipleResults.

@Test
public void testGetFirstMultipleResults() {
    GenericVnf vnf = new GenericVnf();
    vnf.setVnfId("my-vnf-id");
    GenericVnf vnf2 = new GenericVnf();
    vnf2.setVnfId("my-vnf-id2");
    GenericVnfs vnfs = new GenericVnfs();
    vnfs.getGenericVnf().add(vnf);
    vnfs.getGenericVnf().add(vnf2);
    AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnfs());
    RestClient restClientMock = mock(RestClient.class);
    doReturn(restClientMock).when(client).createClient(uri);
    when(restClientMock.get(GenericVnfs.class)).thenReturn(Optional.of(vnfs));
    Optional<GenericVnf> result = aaiClient.getFirst(GenericVnfs.class, GenericVnf.class, uri);
    assertEquals("my-vnf-id", result.get().getVnfId());
}
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) RestClient(org.onap.so.client.RestClient) Test(org.junit.Test)

Example 25 with GenericVnf

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

the class GraphInventoryPatchConverterTest method convertObjectToPatchFormatTest.

@Test
public void convertObjectToPatchFormatTest() throws URISyntaxException, JsonParseException, JsonMappingException, IOException {
    GraphInventoryPatchConverter validator = new GraphInventoryPatchConverter();
    GenericVnf vnf = new GenericVnf();
    vnf.setIpv4Loopback0Address("");
    String result = validator.marshallObjectToPatchFormat(vnf);
    GenericVnf resultObj = mapper.readValue(result.toString(), GenericVnf.class);
    assertTrue("expect object to become a String to prevent double marshalling", result instanceof String);
    assertNull("expect null because of custom mapper", resultObj.getIpv4Loopback0Address());
}
Also used : GenericVnf(org.onap.aai.domain.yang.GenericVnf) GraphInventoryPatchConverter(org.onap.aaiclient.client.graphinventory.GraphInventoryPatchConverter) 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