use of org.onap.aaiclient.client.aai.entities.AAIResultWrapper in project so by onap.
the class AAIDataRetrieval method getVolumeGroup.
public VolumeGroup getVolumeGroup(String vnfId, String volumeGroupId) throws AAIEntityNotFound {
AAIResultWrapper wrapper = this.getAaiResourcesClient().get(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)).relatedTo(Types.VOLUME_GROUP.getFragment(volumeGroupId)));
Optional<VolumeGroup> volume = wrapper.asBean(VolumeGroup.class);
if (volume.isPresent()) {
return volume.get();
} else {
logger.debug("No VolumeGroup in A&AI found: {}", vnfId);
return null;
}
}
use of org.onap.aaiclient.client.aai.entities.AAIResultWrapper in project so by onap.
the class AAICreateResourcesTest method getVnfInstanceTest.
@Test
public void getVnfInstanceTest() {
AAIResultWrapper aaiResultWrapper = new AAIResultWrapper("vnfUriAaiResponse");
doReturn(aaiResultWrapper).when(aaiResourcesClient).get(isA(AAIResourceUri.class));
Optional<GenericVnf> actualVnf = aaiCreateResources.getVnfInstance(vnfId);
AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId));
verify(aaiResourcesClient, times(1)).get(vnfURI);
assertEquals(actualVnf, aaiResultWrapper.asBean(GenericVnf.class));
}
use of org.onap.aaiclient.client.aai.entities.AAIResultWrapper in project so by onap.
the class WorkflowActionExtractResourcesAAITest method extractRelationshipsVpnBindingSuccess.
@Test
public void extractRelationshipsVpnBindingSuccess() {
// given
Relationships relationships = mock(Relationships.class);
AAIResourceUri aaiResourceUri = mock(AAISimpleUri.class);
List<AAIResourceUri> aaiResourceUriList = new ArrayList<>();
aaiResourceUriList.add(aaiResourceUri);
when(relationships.getRelatedUris(Types.VPN_BINDING)).thenReturn(aaiResourceUriList);
AAIResultWrapper aaiResultWrapper = new AAIResultWrapper("{\"vpn-id\" : \"" + VPN_ID + "\"}");
when(bbInputSetupUtils.getAAIResourceDepthOne(aaiResourceUri)).thenReturn(aaiResultWrapper);
// when
Optional<VpnBinding> resultOpt = testedObject.extractRelationshipsVpnBinding(relationships);
// then
assertThat(resultOpt).isNotEmpty();
assertThat(resultOpt.get().getVpnId()).isEqualTo(VPN_ID);
}
use of org.onap.aaiclient.client.aai.entities.AAIResultWrapper in project so by onap.
the class HeatBridgeImplTest method testCreateRelationships.
@Test
public void testCreateRelationships() throws HeatBridgeException, JsonProcessingException {
AaiHelper aaiHelper = new AaiHelper();
VfModule module = new VfModule();
RelationshipList relationships = new RelationshipList();
List<Relationship> listRelationships = relationships.getRelationship();
Relationship vnfcRelationship = new Relationship();
vnfcRelationship.setRelationshipLabel("org.onap.relationships.inventory.Uses");
vnfcRelationship.setRelatedTo("vnfc");
vnfcRelationship.setRelatedLink("/aai/v22/network/vnfcs/vnfc/test-server1-name");
listRelationships.add(vnfcRelationship);
module.setRelationshipList(relationships);
AAIResultWrapper wrapper = new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(module));
when(aaiResourcesClient.get(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("test-genericVnf-id").vfModule("test-vfModule-id")))).thenReturn(wrapper);
aaiHelper.setAAIResourcesClient(aaiResourcesClient);
// Arrange
Server server1 = mock(Server.class);
when(server1.getId()).thenReturn("test-server1-id");
when(server1.getHypervisorHostname()).thenReturn("test-hypervisor");
when(server1.getName()).thenReturn("test-server1-name");
when(server1.getStatus()).thenReturn(Status.ACTIVE);
when(server1.getLinks()).thenReturn(new ArrayList<>());
// HypervisorHostname is not set
Server server2 = mock(Server.class);
when(server2.getId()).thenReturn("test-server1-id");
when(server2.getName()).thenReturn("test-server1-name");
when(server2.getStatus()).thenReturn(Status.ACTIVE);
when(server2.getLinks()).thenReturn(new ArrayList<>());
// HypervisorHostname is empty string
Server server3 = mock(Server.class);
when(server3.getId()).thenReturn("test-server1-id");
when(server3.getHypervisorHostname()).thenReturn("");
when(server3.getName()).thenReturn("test-server1-name");
when(server3.getStatus()).thenReturn(Status.ACTIVE);
when(server3.getLinks()).thenReturn(new ArrayList<>());
org.onap.aai.domain.yang.RelationshipList relList = aaiHelper.getVserverRelationshipList(CLOUD_OWNER, REGION_ID, "test-genericVnf-id", "test-vfModule-id", server1);
assertEquals(3, relList.getRelationship().size());
org.onap.aai.domain.yang.RelationshipList relList2 = aaiHelper.getVserverRelationshipList(CLOUD_OWNER, REGION_ID, "test-genericVnf-id", "test-vfModule-id", server2);
assertEquals(2, relList2.getRelationship().size());
org.onap.aai.domain.yang.RelationshipList relList3 = aaiHelper.getVserverRelationshipList(CLOUD_OWNER, REGION_ID, "test-genericVnf-id", "test-vfModule-id", server3);
assertEquals(2, relList3.getRelationship().size());
}
use of org.onap.aaiclient.client.aai.entities.AAIResultWrapper in project so by onap.
the class AAIResourcesClientTest method verifyFailedCallException.
@Test
public void verifyFailedCallException() {
AAIResourceUri path = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("test"));
wireMockRule.stubFor(get(urlPathEqualTo("/aai/" + AAIVersion.LATEST + path.build())).willReturn(aResponse().withHeader("Content-Type", "text/plain").withBodyFile("aai/error-message.json").withStatus(400)));
AAIResourcesClient client = aaiClient;
thrown.expect(BadRequestException.class);
thrown.expectMessage(containsString("Invalid input performing PUT on url (msg=Precondition Required:resource-version not passed for update of url"));
AAIResultWrapper result = client.get(path);
}
Aggregations