use of org.onap.aaiclient.client.aai.AAIResourcesClient in project so by onap.
the class AAIServiceInstanceResources method getOwningEntityByName.
public org.onap.aai.domain.yang.OwningEntity getOwningEntityByName(String owningEntityName) throws AAIEntityNotFoundException {
AAIPluralResourceUri owningEntityUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().owningEntities()).queryParam("owning-entity-name", owningEntityName);
AAIResourcesClient aaiRC = injectionHelper.getAaiClient();
Optional<OwningEntities> owningEntities = aaiRC.get(OwningEntities.class, owningEntityUri);
if (owningEntities.isPresent()) {
List<org.onap.aai.domain.yang.OwningEntity> owningEntityList = owningEntities.get().getOwningEntity();
if (owningEntityList.size() > 1) {
throw new AAIEntityNotFoundException("Non unique result returned for owning entity name: " + owningEntityName);
} else {
return owningEntityList.get(0);
}
} else {
throw new AAIEntityNotFoundException("No result returned for owning entity name: " + owningEntityName);
}
}
use of org.onap.aaiclient.client.aai.AAIResourcesClient 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();
}
use of org.onap.aaiclient.client.aai.AAIResourcesClient in project so by onap.
the class SDNOValidatorImpl method healthDiagnostic.
@Override
public boolean healthDiagnostic(String vnfId, UUID uuid, String requestingUserId) throws IOException, Exception {
AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId));
AAIResourcesClient client = new AAIResourcesClient();
GenericVnf vnf = client.get(GenericVnf.class, uri).orElseThrow(() -> new NotFoundException(vnfId + " not found in A&AI"));
SDNO requestDiagnostic = buildRequestDiagnostic(vnf, uuid, requestingUserId);
ObjectMapper mapper = new ObjectMapper();
String json = mapper.writeValueAsString(requestDiagnostic);
this.submitRequest(json);
boolean status = this.pollForResponse(uuid.toString());
return status;
}
use of org.onap.aaiclient.client.aai.AAIResourcesClient in project so by onap.
the class DeleteVServers method doExecute.
@Override
public void doExecute(TestContext context) {
try {
logger.info("Deleting Vservers in A&AI");
AAIResourcesClient aaiResourceClient = new AAIResourcesClient();
String vserverId = context.getVariable("vServerId");
String cloudRegion = context.getVariable("cloudRegion");
String cloudOwner = context.getVariable("cloudOwner");
String tenantId = context.getVariable("tenantId");
AAIResourceUri vserverURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegion).tenant(tenantId).vserver(vserverId));
aaiResourceClient.delete(vserverURI);
logger.error("Delete Vservers in AAI: {}", vserverURI);
} catch (Exception e) {
logger.error("Error Deleting VServer in A&AI", e);
}
}
use of org.onap.aaiclient.client.aai.AAIResourcesClient in project so by onap.
the class WatchdogDistributionTest method getSetAaiClientTest.
@Test
public void getSetAaiClientTest() {
aaiResourceClient = watchdogDistribution.getAaiClient();
watchdogDistribution.setAaiClient(aaiResourceClient);
AAIResourcesClient aaiResourceClient2 = watchdogDistribution.getAaiClient();
assertEquals(aaiResourceClient, aaiResourceClient2);
}
Aggregations