diff options
Diffstat (limited to 'prh-app-server')
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)); |