Search in sources :

Example 41 with AAIPluralResourceUri

use of org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri in project so by onap.

the class AAIResourcesClientTest method testGetFirstNoResults.

@Test
public void testGetFirstNoResults() {
    GenericVnf vnf = new GenericVnf();
    vnf.setVnfId("my-vnf-id");
    GenericVnfs vnfs = new GenericVnfs();
    vnfs.getGenericVnf().add(vnf);
    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.empty());
    Optional<GenericVnf> result = aaiClient.getFirst(GenericVnfs.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) GenericVnfs(org.onap.aai.domain.yang.GenericVnfs) RestClient(org.onap.so.client.RestClient) Test(org.junit.Test)

Example 42 with AAIPluralResourceUri

use of org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri in project so by onap.

the class AAIResourcesClientTest method testGetOne.

@Test
public void testGetOne() {
    GenericVnf vnf = new GenericVnf();
    vnf.setVnfId("my-vnf-id");
    GenericVnfs vnfs = new GenericVnfs();
    vnfs.getGenericVnf().add(vnf);
    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.getOne(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 43 with AAIPluralResourceUri

use of org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri in project so by onap.

the class AAIDataRetrievalTest method getVolumeGroupsOfVnfWhenNoneTest.

@Test
public void getVolumeGroupsOfVnfWhenNoneTest() throws Exception {
    VolumeGroups volumeGroups = new VolumeGroups();
    AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("vnfId")).relatedTo(Types.VOLUME_GROUPS.getFragment());
    doReturn(Optional.of(volumeGroups)).when(aaiResourcesClient).get(VolumeGroups.class, uri);
    List<VolumeGroup> volumeGroupList = aaiDataRetrieval.getVolumeGroupsOfVnf("vnfId");
    assertEquals(true, volumeGroupList.isEmpty());
    Optional<String> volumeGroupIds = aaiDataRetrieval.getVolumeGroupIdsByVnfId("vnfId");
    assertEquals(false, volumeGroupIds.isPresent());
}
Also used : AAIPluralResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri) VolumeGroup(org.onap.aai.domain.yang.VolumeGroup) VolumeGroups(org.onap.aai.domain.yang.VolumeGroups) Test(org.junit.Test)

Example 44 with AAIPluralResourceUri

use of org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri in project so by onap.

the class AAIDataRetrievalTest method getVfModulesOfVnfWhenNoneTest.

@Test
public void getVfModulesOfVnfWhenNoneTest() {
    VfModules vfModules = new VfModules();
    AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("vnfId").vfModules());
    doReturn(Optional.of(vfModules)).when(aaiResourcesClient).get(VfModules.class, uri);
    List<VfModule> vfModulesList = aaiDataRetrieval.getVfModulesOfVnf("vnfId");
    assertEquals(true, vfModulesList.isEmpty());
    Optional<String> vfModuleIds = aaiDataRetrieval.getVfModuleIdsByVnfId("vnfId");
    assertEquals(false, vfModuleIds.isPresent());
}
Also used : VfModules(org.onap.aai.domain.yang.VfModules) AAIPluralResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri) VfModule(org.onap.aai.domain.yang.VfModule) Test(org.junit.Test)

Aggregations

AAIPluralResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri)44 Test (org.junit.Test)29 GenericVnf (org.onap.aai.domain.yang.GenericVnf)7 GenericVnfs (org.onap.aai.domain.yang.GenericVnfs)6 RestClient (org.onap.so.client.RestClient)6 AAIResourcesClient (org.onap.aaiclient.client.aai.AAIResourcesClient)5 ArrayList (java.util.ArrayList)3 VfModule (org.onap.aai.domain.yang.VfModule)3 VfModules (org.onap.aai.domain.yang.VfModules)3 VolumeGroup (org.onap.aai.domain.yang.VolumeGroup)3 VolumeGroups (org.onap.aai.domain.yang.VolumeGroups)3 AAIResultWrapper (org.onap.aaiclient.client.aai.entities.AAIResultWrapper)3 AAIResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)3 ServiceInstance (org.onap.aai.domain.yang.ServiceInstance)2 ServiceInstances (org.onap.aai.domain.yang.ServiceInstances)2 Relationships (org.onap.aaiclient.client.aai.entities.Relationships)2 MultipleObjectsFoundException (org.onap.so.bpmn.servicedecomposition.tasks.exceptions.MultipleObjectsFoundException)2 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1