summaryrefslogtreecommitdiffstats
path: root/prh-app-server/src
diff options
context:
space:
mode:
authorpwielebs <piotr.wielebski@nokia.com>2018-05-23 15:31:11 +0200
committerpwielebs <piotr.wielebski@nokia.com>2018-05-24 11:50:34 +0200
commit7ddaf390698fe5ae9143d91e7011059b3973f8ce (patch)
tree4d483f24c6b73ce2e0d0a8237410856f8e01edb6 /prh-app-server/src
parentb6bc8925a354825545b8527879e0f687b0dbab3a (diff)
Refactor of prh-aai-client
Change-Id: Idbca6fe4c050c789f4479164846437039d3b549d Issue-ID: DCAEGEN2-451 Signed-off-by: pwielebs <piotr.wielebski@nokia.com>
Diffstat (limited to 'prh-app-server/src')
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTask.java2
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImpl.java8
-rw-r--r--prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImplTest.java10
3 files changed, 10 insertions, 10 deletions
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTask.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTask.java
index 4e95a0d1..ba8e6e45 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTask.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTask.java
@@ -28,7 +28,7 @@ import org.onap.dcaegen2.services.prh.service.producer.ExtendedDmaapProducerHttp
*/
abstract class DmaapPublisherTask<R, S, C> extends Task<R, S, C> {
- abstract String publish(ConsumerDmaapModel consumerDmaapModel) throws DmaapNotFoundException;
+ abstract Integer publish(ConsumerDmaapModel consumerDmaapModel) throws DmaapNotFoundException;
abstract ExtendedDmaapProducerHttpClientImpl resolveClient();
}
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImpl.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImpl.java
index 8f2541c8..6a514747 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImpl.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImpl.java
@@ -37,7 +37,7 @@ import org.springframework.stereotype.Component;
*/
@Component
public class DmaapPublisherTaskImpl extends
- DmaapPublisherTask<ConsumerDmaapModel, String, DmaapPublisherConfiguration> {
+ DmaapPublisherTask<ConsumerDmaapModel, Integer, DmaapPublisherConfiguration> {
private static final Logger logger = LoggerFactory.getLogger(DmaapPublisherTaskImpl.class);
private final Config prhAppConfig;
@@ -49,15 +49,15 @@ public class DmaapPublisherTaskImpl extends
}
@Override
- String publish(ConsumerDmaapModel consumerDmaapModel) throws DmaapNotFoundException {
+ Integer publish(ConsumerDmaapModel consumerDmaapModel) throws DmaapNotFoundException {
logger.trace("Method called with arg {}", consumerDmaapModel);
return extendedDmaapProducerHttpClient.getHttpProducerResponse(consumerDmaapModel)
- .filter(response -> !response.isEmpty() && response.equals(String.valueOf(HttpStatus.OK.value())))
+ .filter(response -> response == HttpStatus.OK.value())
.orElseThrow(() -> new DmaapNotFoundException("Incorrect response from Dmaap"));
}
@Override
- public String execute(ConsumerDmaapModel consumerDmaapModel) throws DmaapNotFoundException {
+ public Integer execute(ConsumerDmaapModel consumerDmaapModel) throws DmaapNotFoundException {
consumerDmaapModel = Optional.ofNullable(consumerDmaapModel)
.orElseThrow(() -> new DmaapNotFoundException("Invoked null object to Dmaap task"));
extendedDmaapProducerHttpClient = resolveClient();
diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImplTest.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImplTest.java
index 41d46f66..13534ce8 100644
--- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImplTest.java
+++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImplTest.java
@@ -82,22 +82,22 @@ class DmaapPublisherTaskImplTest {
@Test
public void whenPassedObjectFits_ReturnsCorrectStatus() throws PrhTaskException {
//given
- prepareMocksForTests(HttpStatus.OK.toString());
+ prepareMocksForTests(HttpStatus.OK.value());
//when
- String response = dmaapPublisherTask.execute(consumerDmaapModel);
+ Integer response = dmaapPublisherTask.execute(consumerDmaapModel);
//then
verify(extendedDmaapProducerHttpClient, times(1))
.getHttpProducerResponse(any(ConsumerDmaapModel.class));
verifyNoMoreInteractions(extendedDmaapProducerHttpClient);
- Assertions.assertEquals(HttpStatus.OK.toString(), response);
+ Assertions.assertEquals((Integer) HttpStatus.OK.value(), response);
}
@Test
public void whenPassedObjectFits_butIncorrectResponseReturns() {
//given
- prepareMocksForTests("400");
+ prepareMocksForTests(HttpStatus.UNAUTHORIZED.value());
//when
Executable executableFunction = () -> dmaapPublisherTask.execute(consumerDmaapModel);
@@ -110,7 +110,7 @@ class DmaapPublisherTaskImplTest {
}
- private void prepareMocksForTests(String httpResponseCode) {
+ private void prepareMocksForTests(Integer httpResponseCode) {
extendedDmaapProducerHttpClient = mock(ExtendedDmaapProducerHttpClientImpl.class);
when(extendedDmaapProducerHttpClient.getHttpProducerResponse(consumerDmaapModel))
.thenReturn(Optional.of(httpResponseCode));