Search in sources :

Example 66 with AAIResultWrapper

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

the class AAINetworkResourcesTest method getRouteTableTest.

@Test
public void getRouteTableTest() throws Exception {
    final String content = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAaiNetworkTableRefs.json")));
    AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(content);
    Optional<RouteTableReference> oRtref = Optional.empty();
    AAIResourceUri rTRefUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().routeTableReference("ModelInvariantUUID"));
    doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIResourceUri.class));
    oRtref = aaiNetworkResources.getRouteTable(rTRefUri);
    verify(MOCK_aaiResourcesClient, times(1)).get(any(AAIResourceUri.class));
    if (oRtref.isPresent()) {
        RouteTableReference rTref = oRtref.get();
        assertThat(aaiResultWrapper.asBean(RouteTableReference.class).get(), sameBeanAs(rTref));
    }
}
Also used : RouteTableReference(org.onap.aai.domain.yang.RouteTableReference) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) Test(org.junit.Test)

Example 67 with AAIResultWrapper

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

the class AAIClientHelperTest method testGetAaiOperationalEnvironmentSuccess.

@Test
public void testGetAaiOperationalEnvironmentSuccess() throws Exception {
    wireMockServer.stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("vnfoperenv/ecompOperationalEnvironment.json").withStatus(HttpStatus.SC_ACCEPTED)));
    AAIResultWrapper wrapper = clientHelper.getAaiOperationalEnvironment("EMOE-001");
    Optional<OperationalEnvironment> aaiOpEnv = wrapper.asBean(OperationalEnvironment.class);
    assertEquals("EMOE-001", aaiOpEnv.get().getOperationalEnvironmentId());
}
Also used : AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) OperationalEnvironment(org.onap.aai.domain.yang.OperationalEnvironment) BaseTest(org.onap.so.apihandlerinfra.BaseTest) Test(org.junit.Test)

Example 68 with AAIResultWrapper

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

the class BBInputSetupTest method testMapPnfs.

@Test
public void testMapPnfs() throws JsonProcessingException {
    org.onap.aai.domain.yang.Pnf expectedAAI = new org.onap.aai.domain.yang.Pnf();
    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);
    Pnf expected = new Pnf();
    AAIResourceUri aaiResourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().pnf("pnfId"));
    AAIResultWrapper pnfWrapper = new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(expectedAAI));
    doReturn(pnfWrapper).when(SPY_bbInputSetupUtils).getAAIResourceDepthOne(aaiResourceUri);
    doReturn(expected).when(bbInputSetupMapperLayer).mapAAIPnfIntoPnf(isA(org.onap.aai.domain.yang.Pnf.class));
    List<Pnf> pnfs = new ArrayList<>();
    SPY_bbInputSetup.mapPnfs(Arrays.asList(aaiResourceUri), pnfs);
    assertEquals(expected, pnfs.get(0));
}
Also used : ArrayList(java.util.ArrayList) Pnf(org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf) 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)

Example 69 with AAIResultWrapper

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

the class AppcOrchestratorPreProcessorTest method getVserversForAppcTest.

@Test
public void getVserversForAppcTest() throws Exception {
    GenericVnf genericVnf = getTestGenericVnf();
    final String aaiVnfJson = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiGenericVnfWithVservers.json")));
    final String aaiVserverJson = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiVserverQueryResponse.json")));
    AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(aaiVnfJson);
    ObjectMapper mapper = new ObjectMapper();
    Vserver vserver = mapper.readValue(aaiVserverJson, Vserver.class);
    doReturn(aaiResultWrapper).when(aaiVnfResources).queryVnfWrapperById(genericVnf);
    doReturn(Optional.of(vserver)).when(aaiVnfResources).getVserver(ArgumentMatchers.any(AAIResourceUri.class));
    appcOrchestratorPreProcessor.getVserversForAppc(execution, genericVnf);
    ArrayList<String> vserverIdList = execution.getVariable("vserverIdList");
    ArrayList<String> expectedVserverIdList = new ArrayList<String>();
    expectedVserverIdList.add("1b3f44e5-d96d-4aac-bd9a-310e8cfb0af5");
    expectedVserverIdList.add("14551849-1e70-45cd-bc5d-a256d49548a2");
    expectedVserverIdList.add("48bd7f11-408f-417c-b834-b41c1b98f7d7");
    ArrayList<String> vmIdList = execution.getVariable("vmIdList");
    ArrayList<String> expectedVmIdList = new ArrayList<String>();
    expectedVmIdList.add("http://VSERVER-link.com");
    expectedVmIdList.add("http://VSERVER-link.com");
    expectedVmIdList.add("http://VSERVER-link.com");
    assertEquals(vserverIdList, expectedVserverIdList);
    assertEquals(vmIdList, expectedVmIdList);
}
Also used : Vserver(org.onap.aai.domain.yang.Vserver) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) ArrayList(java.util.ArrayList) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) Test(org.junit.Test)

Example 70 with AAIResultWrapper

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

the class AAIDeleteTasksTest method deleteNetworkPolicyNeedToDeleteAllTest.

@Test
public void deleteNetworkPolicyNeedToDeleteAllTest() throws Exception {
    execution.setVariable("contrailNetworkPolicyFqdnList", "ABC123,DEF456");
    final String content0 = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAaiNetworkPoliciesForDelete0.json")));
    AAIResultWrapper aaiResultWrapper0 = new AAIResultWrapper(content0);
    NetworkPolicies networkPolicies0 = aaiResultWrapper0.asBean(NetworkPolicies.class).get();
    final String content1 = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAaiNetworkPoliciesForDelete1.json")));
    AAIResultWrapper aaiResultWrapper1 = new AAIResultWrapper(content1);
    NetworkPolicies networkPolicies1 = aaiResultWrapper1.asBean(NetworkPolicies.class).get();
    doReturn(Optional.of(networkPolicies0), Optional.of(networkPolicies1)).when(aaiNetworkResources).getNetworkPolicies(any(AAIBaseResourceUri.class));
    doNothing().when(aaiNetworkResources).deleteNetworkPolicy(any(String.class));
    aaiDeleteTasks.deleteNetworkPolicies(execution);
    verify(aaiNetworkResources, times(2)).deleteNetworkPolicy(stringCaptor.capture());
    assertEquals("testNetworkPolicyId0", stringCaptor.getAllValues().get(0));
    assertEquals("testNetworkPolicyId1", stringCaptor.getAllValues().get(1));
}
Also used : AAIBaseResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIBaseResourceUri) NetworkPolicies(org.onap.aai.domain.yang.NetworkPolicies) 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