Search in sources :

Example 1 with VolumeGroups

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

the class AAIDataRetrievalTest method getVolumeGroupsOfVnfTest.

@Test
public void getVolumeGroupsOfVnfTest() throws Exception {
    VolumeGroups volumeGroups = getVolumeGroups();
    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("vg1", volumeGroupList.get(0).getVolumeGroupId());
    Optional<String> volumeGroupIds = aaiDataRetrieval.getVolumeGroupIdsByVnfId("vnfId");
    assertEquals(Optional.of("vg1,vg2"), volumeGroupIds);
}
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 2 with VolumeGroups

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

the class BBInputSetupUtilsTest method getRelatedVolumeGroupFromVfModuleMultipleVolumeGroupsExceptionTest.

@Test
public void getRelatedVolumeGroupFromVfModuleMultipleVolumeGroupsExceptionTest() throws Exception {
    expectedException.expect(Exception.class);
    final String vnfId = "vnfId";
    final String volumeGroupId = "volumeGroupId";
    VolumeGroup volumeGroup = new VolumeGroup();
    volumeGroup.setVolumeGroupId("id123");
    volumeGroup.setVolumeGroupName("name123");
    VolumeGroups expectedVolumeGroup = new VolumeGroups();
    expectedVolumeGroup.getVolumeGroup().add(volumeGroup);
    expectedVolumeGroup.getVolumeGroup().add(volumeGroup);
    doReturn(expectedVolumeGroup).when(MOCK_aaiResourcesClient).get(eq(VolumeGroups.class), any(AAIResourceUri.class));
    bbInputSetupUtils.getRelatedVolumeGroupFromVfModule(vnfId, volumeGroupId);
}
Also used : VolumeGroup(org.onap.aai.domain.yang.VolumeGroup) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) VolumeGroups(org.onap.aai.domain.yang.VolumeGroups) Test(org.junit.Test)

Example 3 with VolumeGroups

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

the class AAIDataRetrieval method getVolumeGroupsOfVnf.

public List<VolumeGroup> getVolumeGroupsOfVnf(String vnfId) {
    List<VolumeGroup> volumeGroupList = new ArrayList<VolumeGroup>();
    AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)).relatedTo(Types.VOLUME_GROUPS.getFragment());
    Optional<VolumeGroups> volumeGroups = getAaiResourcesClient().get(VolumeGroups.class, uri);
    if (!volumeGroups.isPresent() || volumeGroups.get().getVolumeGroup().isEmpty()) {
        logger.debug("No VolumeGroups attached to Vnf in AAI : {}", vnfId);
    } else {
        volumeGroupList = volumeGroups.get().getVolumeGroup();
    }
    return volumeGroupList;
}
Also used : AAIPluralResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri) VolumeGroup(org.onap.aai.domain.yang.VolumeGroup) ArrayList(java.util.ArrayList) VolumeGroups(org.onap.aai.domain.yang.VolumeGroups)

Example 4 with VolumeGroups

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

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

the class AAIDataRetrievalTest method getVolumeGroups.

private VolumeGroups getVolumeGroups() {
    VolumeGroup volumeGroup1 = new VolumeGroup();
    volumeGroup1.setVolumeGroupId("vg1");
    VolumeGroup volumeGroup2 = new VolumeGroup();
    volumeGroup2.setVolumeGroupId("vg2");
    VolumeGroups volumeGroups = new VolumeGroups();
    volumeGroups.getVolumeGroup().add(volumeGroup1);
    volumeGroups.getVolumeGroup().add(volumeGroup2);
    return volumeGroups;
}
Also used : VolumeGroup(org.onap.aai.domain.yang.VolumeGroup) VolumeGroups(org.onap.aai.domain.yang.VolumeGroups)

Aggregations

VolumeGroup (org.onap.aai.domain.yang.VolumeGroup)5 VolumeGroups (org.onap.aai.domain.yang.VolumeGroups)5 Test (org.junit.Test)3 AAIPluralResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri)3 ArrayList (java.util.ArrayList)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 AAIResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)1