Search in sources :

Example 76 with AAIResultWrapper

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;
    }
}
Also used : VolumeGroup(org.onap.aai.domain.yang.VolumeGroup) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper)

Example 77 with AAIResultWrapper

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));
}
Also used : GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) Test(org.junit.Test)

Example 78 with AAIResultWrapper

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);
}
Also used : Relationships(org.onap.aaiclient.client.aai.entities.Relationships) VpnBinding(org.onap.aai.domain.yang.VpnBinding) ArrayList(java.util.ArrayList) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) Test(org.junit.Test)

Example 79 with AAIResultWrapper

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());
}
Also used : RelationshipList(org.onap.aai.domain.yang.RelationshipList) Server(org.openstack4j.model.compute.Server) AaiHelper(org.onap.so.heatbridge.helpers.AaiHelper) VfModule(org.onap.aai.domain.yang.VfModule) AAICommonObjectMapperProvider(org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider) RelationshipList(org.onap.aai.domain.yang.RelationshipList) Relationship(org.onap.aai.domain.yang.Relationship) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) Test(org.junit.Test)

Example 80 with AAIResultWrapper

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);
}
Also used : AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) Test(org.junit.Test)

Aggregations

AAIResultWrapper (org.onap.aaiclient.client.aai.entities.AAIResultWrapper)88 AAIResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)47 Test (org.junit.Test)46 Relationships (org.onap.aaiclient.client.aai.entities.Relationships)27 ArrayList (java.util.ArrayList)22 AAICommonObjectMapperProvider (org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider)22 L3Network (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network)14 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)11 VpnBinding (org.onap.aai.domain.yang.VpnBinding)7 CloudConfiguration (org.onap.so.serviceinstancebeans.CloudConfiguration)7 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)6 HashMap (java.util.HashMap)6 OperationalEnvironment (org.onap.aai.domain.yang.OperationalEnvironment)6 RelationshipList (org.onap.aai.domain.yang.RelationshipList)6 AAIResourcesClient (org.onap.aaiclient.client.aai.AAIResourcesClient)6 List (java.util.List)5 Optional (java.util.Optional)5 AAIFluentTypeBuilder (org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder)5 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)5 Map (java.util.Map)4