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));
}
}
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());
}
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));
}
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);
}
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));
}
Aggregations