Search in sources :

Example 81 with AAIResultWrapper

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

the class AAIResourcesClientTest method verifyNotExistsGet.

@Test
public void verifyNotExistsGet() {
    AAIResourceUri path = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("test"));
    wireMockRule.stubFor(get(urlPathEqualTo("/aai/" + AAIVersion.LATEST + path.build())).willReturn(aResponse().withHeader("Content-Type", "text/plain").withBody("hello").withStatus(404)));
    AAIResourcesClient client = aaiClient;
    AAIResultWrapper result = client.get(path);
    assertEquals("is empty", true, result.isEmpty());
}
Also used : AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) Test(org.junit.Test)

Example 82 with AAIResultWrapper

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

the class AAIResourcesClientWithServiceInstanceUriTest method getAAIWrapper.

@Test
public void getAAIWrapper() {
    AAIResourcesClient client = aaiClient;
    AAIResultWrapper result = client.get(uri);
    assertThat(result.isEmpty(), equalTo(true));
}
Also used : AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) Test(org.junit.Test)

Example 83 with AAIResultWrapper

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

the class AAIResourcesClientWithServiceInstanceUriTest method getWithException.

@Test
public void getWithException() {
    AAIResourcesClient client = aaiClient;
    this.thrown.expect(IllegalArgumentException.class);
    AAIResultWrapper result = client.get(uri, IllegalArgumentException.class);
}
Also used : AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) Test(org.junit.Test)

Example 84 with AAIResultWrapper

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

the class ServiceInstanceUriTest method notfound.

@Test
public void notfound() throws IOException, GraphInventoryUriNotFoundException, GraphInventoryPayloadException {
    final String content = new String(Files.readAllBytes(Paths.get(AAI_JSON_FILE_LOCATION + "empty-query-result.json")));
    ServiceInstanceUri instance = new ServiceInstanceUri(Types.SERVICE_INSTANCE.getFragment("key3"));
    ServiceInstanceUri spy = spy(instance);
    AAIResourcesClient mockResourcesClient = mock(AAIResourcesClient.class);
    AAIResultWrapper wrapper = mock(AAIResultWrapper.class);
    when(mockResourcesClient.get(ArgumentMatchers.<AAIResourceUri>any(AAIResourceUri.class), ArgumentMatchers.<Class<NotFoundException>>any())).thenReturn(wrapper);
    when(wrapper.getJson()).thenReturn(content);
    when(spy.getResourcesClient()).thenReturn(mockResourcesClient);
    exception.expect(GraphInventoryUriComputationException.class);
    spy.locateAndBuild();
}
Also used : GraphInventoryUriNotFoundException(org.onap.aaiclient.client.graphinventory.exceptions.GraphInventoryUriNotFoundException) NotFoundException(javax.ws.rs.NotFoundException) AAIResourcesClient(org.onap.aaiclient.client.aai.AAIResourcesClient) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) Test(org.junit.Test)

Example 85 with AAIResultWrapper

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

the class BBInputSetupTest method testMapConfigurations.

@Test
public void testMapConfigurations() throws JsonProcessingException {
    org.onap.aai.domain.yang.Configuration expectedAAI = new org.onap.aai.domain.yang.Configuration();
    org.onap.aai.domain.yang.RelationshipList relationshipList = new org.onap.aai.domain.yang.RelationshipList();
    org.onap.aai.domain.yang.Relationship relationship = new org.onap.aai.domain.yang.Relationship();
    relationshipList.getRelationship().add(relationship);
    expectedAAI.setRelationshipList(relationshipList);
    Configuration expected = new Configuration();
    AAIResourceUri aaiResourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().configuration("configurationId"));
    AAIResultWrapper configurationWrapper = new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(expectedAAI));
    doReturn(configurationWrapper).when(SPY_bbInputSetupUtils).getAAIResourceDepthOne(aaiResourceUri);
    doReturn(expected).when(bbInputSetupMapperLayer).mapAAIConfiguration(isA(org.onap.aai.domain.yang.Configuration.class));
    List<Configuration> configurations = new ArrayList<>();
    SPY_bbInputSetup.mapConfigurations(Arrays.asList(new AAIResourceUri[] { aaiResourceUri }), configurations);
    assertEquals(expected, configurations.get(0));
}
Also used : CloudConfiguration(org.onap.so.serviceinstancebeans.CloudConfiguration) Configuration(org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration) ArrayList(java.util.ArrayList) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) AAICommonObjectMapperProvider(org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider) 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