diff options
Diffstat (limited to 'prh-aai-client/src')
4 files changed, 29 insertions, 27 deletions
diff --git a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/exceptions/AaiRequestException.java b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/exceptions/AaiRequestException.java index 33654c73..bd4355cd 100644 --- a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/exceptions/AaiRequestException.java +++ b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/exceptions/AaiRequestException.java @@ -21,9 +21,6 @@ package org.onap.dcaegen2.services.prh.exceptions; public class AaiRequestException extends Exception { - public AaiRequestException() { - super(); - } public AaiRequestException(String message) { super(message); diff --git a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AaiReactiveWebClient.java b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AaiReactiveWebClient.java index f3b511a7..2b156936 100644 --- a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AaiReactiveWebClient.java +++ b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AaiReactiveWebClient.java @@ -40,7 +40,7 @@ public class AaiReactiveWebClient { private Map<String, String> aaiHeaders; /** - * Creating AaiReactiveWebClient + * Creating AaiReactiveWebClient. * @param configuration - configuration object * @return AaiReactiveWebClient */ diff --git a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/AaiProducerReactiveHttpClient.java b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/AaiProducerReactiveHttpClient.java index 55475902..b43c2164 100644 --- a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/AaiProducerReactiveHttpClient.java +++ b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/AaiProducerReactiveHttpClient.java @@ -43,7 +43,7 @@ public class AaiProducerReactiveHttpClient { /** - * Constructor + * Constructor of AaiProducerReactiveHttpClient. * * @param configuration - AAI producer configuration object */ @@ -55,7 +55,7 @@ public class AaiProducerReactiveHttpClient { } /** - * Function for calling AAI Http producer - patch request to AAI database + * Function for calling AAI Http producer - patch request to AAI database. * * @param consumerDmaapModelMono - object which will be sent to AAI database * @return status code of operation @@ -72,12 +72,16 @@ public class AaiProducerReactiveHttpClient { private Mono<Integer> patchAaiRequest(ConsumerDmaapModel dmaapModel) { try { return webClient.patch() - .uri(getUri(dmaapModel.getPnfName())) - .body(BodyInserters.fromObject(dmaapModel)) - .retrieve() - .onStatus(HttpStatus::is4xxClientError, clientResponse -> Mono.error(new AaiRequestException("HTTP 400"))) - .onStatus(HttpStatus::is5xxServerError, clientResponse -> Mono.error(new AaiRequestException("HTTP 500"))) - .bodyToMono(Integer.class); + .uri(getUri(dmaapModel.getPnfName())) + .body(BodyInserters.fromObject(dmaapModel)) + .retrieve() + .onStatus( + HttpStatus::is4xxClientError, + clientResponse -> Mono.error(new AaiRequestException("HTTP 400")) + ) + .onStatus(HttpStatus::is5xxServerError, + clientResponse -> Mono.error(new AaiRequestException("HTTP 500"))) + .bodyToMono(Integer.class); } catch (URISyntaxException e) { return Mono.error(e); } @@ -85,10 +89,10 @@ public class AaiProducerReactiveHttpClient { URI getUri(String pnfName) throws URISyntaxException { return new URIBuilder() - .setScheme(aaiProtocol) - .setHost(aaiHost) - .setPort(aaiHostPortNumber) - .setPath(aaiBasePath + "/" + pnfName) - .build(); + .setScheme(aaiProtocol) + .setHost(aaiHost) + .setPort(aaiHostPortNumber) + .setPath(aaiBasePath + "/" + pnfName) + .build(); } } diff --git a/prh-aai-client/src/test/java/org/onap/dcaegen2/services/prh/service/producer/AaiProducerReactiveHttpClientTest.java b/prh-aai-client/src/test/java/org/onap/dcaegen2/services/prh/service/producer/AaiProducerReactiveHttpClientTest.java index 3b6fe4d7..c99deca5 100644 --- a/prh-aai-client/src/test/java/org/onap/dcaegen2/services/prh/service/producer/AaiProducerReactiveHttpClientTest.java +++ b/prh-aai-client/src/test/java/org/onap/dcaegen2/services/prh/service/producer/AaiProducerReactiveHttpClientTest.java @@ -43,7 +43,6 @@ import reactor.core.publisher.Mono; import reactor.test.StepVerifier; - class AaiProducerReactiveHttpClientTest { private static AaiProducerReactiveHttpClient aaiProducerReactiveHttpClient; @@ -75,9 +74,9 @@ class AaiProducerReactiveHttpClientTest { aaiProducerReactiveHttpClient = new AaiProducerReactiveHttpClient(aaiConfigurationMock); webClient = spy(WebClient.builder() - .defaultHeaders(httpHeaders -> httpHeaders.setAll(aaiHeaders)) - .filter(basicAuthentication(aaiConfigurationMock.aaiUserName(), aaiConfigurationMock.aaiUserPassword())) - .build()); + .defaultHeaders(httpHeaders -> httpHeaders.setAll(aaiHeaders)) + .filter(basicAuthentication(aaiConfigurationMock.aaiUserName(), aaiConfigurationMock.aaiUserPassword())) + .build()); requestBodyUriSpec = mock(WebClient.RequestBodyUriSpec.class); responseSpec = mock(ResponseSpec.class); @@ -97,10 +96,10 @@ class AaiProducerReactiveHttpClientTest { //then StepVerifier.create(response).expectSubscription() - .expectNextMatches(results -> { - Assertions.assertEquals(results, expectedResult.block()); - return true; - }).verifyComplete(); + .expectNextMatches(results -> { + Assertions.assertEquals(results, expectedResult.block()); + return true; + }).verifyComplete(); } @Test @@ -113,8 +112,10 @@ class AaiProducerReactiveHttpClientTest { when(aaiProducerReactiveHttpClient.getUri("pnfName")).thenThrow(URISyntaxException.class); //then - StepVerifier.create(aaiProducerReactiveHttpClient.getAaiProducerResponse(Mono.just(dmaapModel))).expectSubscription() - .expectError(Exception.class).verify(); + StepVerifier.create( + aaiProducerReactiveHttpClient.getAaiProducerResponse( + Mono.just(dmaapModel) + )).expectSubscription().expectError(Exception.class).verify(); } |