use of org.onap.so.client.RestClient in project so by onap.
the class AAIRestClientTest method cacheGetTest.
@Test
public void cacheGetTest() throws URISyntaxException, InterruptedException {
wireMockRule.stubFor(get(urlPathMatching("/cached")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/plain").withBody("value")));
AAIProperties props = new AAIProperties() {
@Override
public URL getEndpoint() throws MalformedURLException {
return new URL(String.format("http://localhost:%s", wireMockRule.port()));
}
@Override
public String getSystemName() {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean isCachingEnabled() {
return true;
}
@Override
public AAIVersion getDefaultVersion() {
return AAIVersion.LATEST;
}
@Override
public String getAuth() {
return null;
}
@Override
public String getKey() {
return null;
}
};
RestClient client = new AAIRestClient(props, new URI("/cached"), new MultivaluedHashMap<>());
Response response = client.get();
response.readEntity(String.class);
response = client.get();
response.readEntity(String.class);
verify(1, getRequestedFor(urlEqualTo("/cached")));
}
use of org.onap.so.client.RestClient in project so by onap.
the class AAIResourcesClientTest method testGetOneNoResults.
@Test
public void testGetOneNoResults() {
GenericVnf vnf = new GenericVnf();
vnf.setVnfId("my-vnf-id");
GenericVnfs vnfs = new GenericVnfs();
vnfs.getGenericVnf().add(vnf);
AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnfs());
RestClient restClientMock = mock(RestClient.class);
doReturn(restClientMock).when(client).createClient(uri);
when(restClientMock.get(GenericVnfs.class)).thenReturn(Optional.empty());
Optional<GenericVnf> result = aaiClient.getOne(GenericVnfs.class, GenericVnf.class, uri);
assertFalse(result.isPresent());
}
use of org.onap.so.client.RestClient in project so by onap.
the class GraphInventoryResourcesClient method exists.
/**
* returns false if the object does not exist in GraphInventory
*
* @param uri
* @return
*/
public boolean exists(Uri uri) {
GraphInventoryResourceUri<?, ?> forceMinimal = (Uri) uri.clone();
forceMinimal.format(Format.COUNT);
forceMinimal.limit(1);
try {
RestClient giRC = client.createClient(forceMinimal);
return giRC.get().getStatus() == Status.OK.getStatusCode();
} catch (NotFoundException e) {
return false;
}
}
use of org.onap.so.client.RestClient in project so by onap.
the class GraphInventoryResourcesClient method connect.
/**
* Adds a relationship between two objects in GraphInventory with a given edge label
*
* @param uriA
* @param uriB
* @param edge label
* @return
*/
public void connect(SingleUri uriA, SingleUri uriB, EdgeLabel label) {
GraphInventorySingleResourceUri<?, ?, ?, ?, ?, ?> uriAClone = (SingleUri) uriA.clone();
RestClient giRC = client.createClient(uriAClone.relationshipAPI());
giRC.put(this.buildRelationship(uriB, label));
}
use of org.onap.so.client.RestClient in project so by onap.
the class GraphInventoryResourcesClient method connect.
/**
* Adds a relationship between two objects in GraphInventory
*
* @param uriA
* @param uriB
* @return
*/
public void connect(SingleUri uriA, SingleUri uriB) {
GraphInventorySingleResourceUri<?, ?, ?, ?, ?, ?> uriAClone = (SingleUri) uriA.clone();
RestClient giRC = client.createClient(uriAClone.relationshipAPI());
giRC.put(this.buildRelationship(uriB));
}
Aggregations