Search in sources :

Example 6 with GenericVnfs

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

the class AaiResourceIdValidatorTest method validateVnfResourceIdInAAINotGloballyUniqueTest.

@Test
public void validateVnfResourceIdInAAINotGloballyUniqueTest() throws Exception {
    RequestDetails reqDetails = setupRequestDetails();
    GenericVnf vnf = new GenericVnf();
    vnf.setVnfId("id123");
    GenericVnfs genericVnfs = new GenericVnfs();
    genericVnfs.getGenericVnf().add(vnf);
    when(bbInputSetupUtilsMock.getAAIVnfsGloballyByName("vnfName123")).thenReturn(genericVnfs);
    this.expectedException.expect(DuplicateNameException.class);
    this.expectedException.expectMessage(containsString("generic-vnf with name (vnfName123) id (id123) and different parent relationship already exists. The name must be unique."));
    testedObject.validateVnfResourceIdInAAI("generatedId123", "vnfName123", reqDetails, new WorkflowResourceIds());
}
Also used : GenericVnf(org.onap.aai.domain.yang.GenericVnf) GenericVnfs(org.onap.aai.domain.yang.GenericVnfs) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) WorkflowResourceIds(org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds) Test(org.junit.Test)

Example 7 with GenericVnfs

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

the class AAIResourcesClientTest method testGetOneMultipleResults.

@Test
public void testGetOneMultipleResults() {
    GenericVnf vnf = new GenericVnf();
    vnf.setVnfId("my-vnf-id");
    GenericVnf vnf2 = new GenericVnf();
    vnf.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));
    thrown.expect(GraphInventoryMultipleItemsException.class);
    aaiClient.getOne(GenericVnfs.class, GenericVnf.class, uri);
}
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 8 with GenericVnfs

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

the class AAIResourcesClientTest method testGetOneNoResults.

@Test
public void testGetOneNoResults() {
    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.getOne(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 9 with GenericVnfs

use of org.onap.aai.domain.yang.GenericVnfs 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 10 with GenericVnfs

use of org.onap.aai.domain.yang.GenericVnfs 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)

Aggregations

GenericVnfs (org.onap.aai.domain.yang.GenericVnfs)10 GenericVnf (org.onap.aai.domain.yang.GenericVnf)9 Test (org.junit.Test)8 AAIPluralResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri)7 RestClient (org.onap.so.client.RestClient)5 WorkflowResourceIds (org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds)2 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 DuplicateNameException (org.onap.so.bpmn.servicedecomposition.tasks.exceptions.DuplicateNameException)1