summaryrefslogtreecommitdiffstats
path: root/prh-aai-client/src
diff options
context:
space:
mode:
Diffstat (limited to 'prh-aai-client/src')
-rw-r--r--prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/AaiProducerReactiveHttpClient.java24
-rw-r--r--prh-aai-client/src/test/java/org/onap/dcaegen2/services/prh/service/producer/AaiProducerReactiveHttpClientTest.java16
2 files changed, 10 insertions, 30 deletions
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 4e0758c1..9e282cde 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
@@ -26,17 +26,19 @@ import static org.onap.dcaegen2.services.prh.model.logging.MdcVariables.X_INVOCA
import static org.onap.dcaegen2.services.prh.model.logging.MdcVariables.X_ONAP_REQUEST_ID;
import java.net.URI;
-import java.net.URISyntaxException;
import java.util.UUID;
-import org.apache.http.client.utils.URIBuilder;
+
import org.onap.dcaegen2.services.prh.config.AaiClientConfiguration;
import org.onap.dcaegen2.services.prh.model.ConsumerDmaapModel;
import org.slf4j.MDC;
import org.springframework.web.reactive.function.client.ClientResponse;
import org.springframework.web.reactive.function.client.WebClient;
+import org.springframework.web.util.DefaultUriBuilderFactory;
import reactor.core.publisher.Mono;
+
+
public class AaiProducerReactiveHttpClient {
private WebClient webClient;
@@ -66,11 +68,7 @@ public class AaiProducerReactiveHttpClient {
* @return status code of operation
*/
public Mono<ClientResponse> getAaiProducerResponse(ConsumerDmaapModel consumerDmaapModelMono) {
- try {
- return patchAaiRequest(consumerDmaapModelMono);
- } catch (URISyntaxException e) {
- return Mono.error(e);
- }
+ return patchAaiRequest(consumerDmaapModelMono);
}
public AaiProducerReactiveHttpClient createAaiWebClient(WebClient webClient) {
@@ -78,7 +76,7 @@ public class AaiProducerReactiveHttpClient {
return this;
}
- private Mono<ClientResponse> patchAaiRequest(ConsumerDmaapModel dmaapModel) throws URISyntaxException {
+ private Mono<ClientResponse> patchAaiRequest(ConsumerDmaapModel dmaapModel) {
return
webClient.patch()
.uri(getUri(dmaapModel.getSourceName()))
@@ -88,12 +86,8 @@ public class AaiProducerReactiveHttpClient {
.exchange();
}
- URI getUri(String pnfName) throws URISyntaxException {
- return new URIBuilder()
- .setScheme(aaiProtocol)
- .setHost(aaiHost)
- .setPort(aaiHostPortNumber)
- .setPath(aaiBasePath + aaiPnfPath + "/" + pnfName)
- .build();
+ URI getUri(String pnfName) {
+ return new DefaultUriBuilderFactory().builder().scheme(aaiProtocol).host(aaiHost).port(aaiHostPortNumber)
+ .path(aaiBasePath + aaiPnfPath + "/" + 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 4160f356..03f9ec64 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
@@ -105,23 +105,9 @@ class AaiProducerReactiveHttpClientTest {
}).verifyComplete();
}
- @Test
- void getHttpResponse_whenUriSyntaxExceptionHasBeenThrown() throws URISyntaxException {
- ///given
- aaiProducerReactiveHttpClient = spy(aaiProducerReactiveHttpClient);
- //when
- when(webClient.patch()).thenReturn(requestBodyUriSpec);
- aaiProducerReactiveHttpClient.createAaiWebClient(webClient);
- doThrow(URISyntaxException.class).when(aaiProducerReactiveHttpClient).getUri(any());
- //then
- StepVerifier.create(
- aaiProducerReactiveHttpClient.getAaiProducerResponse(
- dmaapModel
- )).expectSubscription().expectError(Exception.class).verify();
- }
@Test
- void getAppropriateUri_whenPassingCorrectedPathForPnf() throws URISyntaxException {
+ void getAppropriateUri_whenPassingCorrectedPathForPnf() {
Assertions.assertEquals(aaiProducerReactiveHttpClient.getUri("NOKnhfsadhff"),
URI.create("https://54.45.33.2:1234/aai/v11/network/pnfs/pnf/NOKnhfsadhff"));
}