summaryrefslogtreecommitdiffstats
path: root/prh-app-server
diff options
context:
space:
mode:
Diffstat (limited to 'prh-app-server')
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIProducerTaskImpl.java10
-rw-r--r--prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AAIProducerTaskImplTest.java12
2 files changed, 12 insertions, 10 deletions
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIProducerTaskImpl.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIProducerTaskImpl.java
index 7487d084..ba3fade7 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIProducerTaskImpl.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIProducerTaskImpl.java
@@ -19,14 +19,11 @@
*/
package org.onap.dcaegen2.services.prh.tasks;
-import java.io.IOException;
-import java.util.Optional;
import org.onap.dcaegen2.services.prh.config.AAIClientConfiguration;
-import org.onap.dcaegen2.services.prh.exceptions.DmaapNotFoundException;
-import org.onap.dcaegen2.services.prh.model.ConsumerDmaapModel;
import org.onap.dcaegen2.services.prh.configuration.AppConfig;
import org.onap.dcaegen2.services.prh.configuration.Config;
import org.onap.dcaegen2.services.prh.exceptions.AAINotFoundException;
+import org.onap.dcaegen2.services.prh.model.ConsumerDmaapModel;
import org.onap.dcaegen2.services.prh.service.AAIProducerClient;
import org.onap.dcaegen2.services.prh.service.HttpUtils;
import org.slf4j.Logger;
@@ -34,6 +31,9 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+import java.net.URISyntaxException;
+import java.util.Optional;
+
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/13/18
*/
@@ -58,7 +58,7 @@ public class AAIProducerTaskImpl extends
return aaiProducerClient.getHttpResponse(consumerDmaapModel)
.filter(HttpUtils::isSuccessfulResponseCode).map(response -> consumerDmaapModel).orElseThrow(() ->
new AAINotFoundException("Incorrect response code for continuation of tasks workflow"));
- } catch (IOException e) {
+ } catch ( URISyntaxException e) {
logger.warn("Patch request not successful", e);
throw new AAINotFoundException("Patch request not successful");
}
diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AAIProducerTaskImplTest.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AAIProducerTaskImplTest.java
index c82a98e4..70da39b7 100644
--- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AAIProducerTaskImplTest.java
+++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AAIProducerTaskImplTest.java
@@ -30,6 +30,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
import java.io.IOException;
+import java.net.URISyntaxException;
import java.util.Optional;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
@@ -95,7 +96,7 @@ class AAIProducerTaskImplTest {
}
@Test
- public void whenPassedObjectFits_ReturnsCorrectStatus() throws AAINotFoundException, IOException {
+ public void whenPassedObjectFits_ReturnsCorrectStatus() throws AAINotFoundException, URISyntaxException {
//given/when
getAAIProducerTask_whenMockingResponseObject(200, false);
ConsumerDmaapModel response = aaiProducerTask.execute(consumerDmaapModel);
@@ -109,7 +110,7 @@ class AAIProducerTaskImplTest {
@Test
- public void whenPassedObjectFits_butIncorrectResponseReturns() throws IOException {
+ public void whenPassedObjectFits_butIncorrectResponseReturns() throws IOException, URISyntaxException {
//given/when
getAAIProducerTask_whenMockingResponseObject(400, false);
Executable executableCode = () -> aaiProducerTask.execute(consumerDmaapModel);
@@ -121,7 +122,7 @@ class AAIProducerTaskImplTest {
}
@Test
- public void whenPassedObjectFits_butHTTPClientThrowsIOExceptionHandleIt() throws IOException {
+ public void whenPassedObjectFits_butHTTPClientThrowsIOExceptionHandleIt() throws URISyntaxException {
//given/when
getAAIProducerTask_whenMockingResponseObject(0, true);
@@ -135,10 +136,11 @@ class AAIProducerTaskImplTest {
private static void getAAIProducerTask_whenMockingResponseObject(int statusCode, boolean throwsException)
- throws IOException {
+ throws URISyntaxException {
+ //given
aaiProducerClient = mock(AAIProducerClient.class);
if (throwsException) {
- when(aaiProducerClient.getHttpResponse(consumerDmaapModel)).thenThrow(IOException.class);
+ when(aaiProducerClient.getHttpResponse(consumerDmaapModel)).thenThrow(URISyntaxException.class);
} else {
when(aaiProducerClient.getHttpResponse(consumerDmaapModel)).thenReturn(Optional.of(statusCode));
}