aboutsummaryrefslogtreecommitdiffstats
path: root/prh-app-server/src/main/java/org
diff options
context:
space:
mode:
authorwasala <przemyslaw.wasala@nokia.com>2018-05-17 14:28:01 +0200
committerwasala <przemyslaw.wasala@nokia.com>2018-05-17 15:11:00 +0200
commit1e1468a8c7dcf86ff8104d4d1b7246b076c8d18d (patch)
tree1996117617a0d619bfc7a08b8fbb99c336099a69 /prh-app-server/src/main/java/org
parent269250a5700086cc68d20706ee6a9b345e0387be (diff)
Added tests for DmaapPublisherTask
Change-Id: I2c265879bffd20e17dd8da981a4111cf2e10c375 Issue-ID: DCAEGEN2-396 Signed-off-by: wasala <przemyslaw.wasala@nokia.com>
Diffstat (limited to 'prh-app-server/src/main/java/org')
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImpl.java8
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImpl.java17
2 files changed, 13 insertions, 12 deletions
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImpl.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImpl.java
index d5cf91d3..dc868b3e 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImpl.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImpl.java
@@ -70,15 +70,15 @@ public class DmaapConsumerTaskImpl extends
prhAppConfig.initFileStreamReader();
}
- protected void setDmaapClientConfig() {
- extendedDmaapConsumerHttpClient = resolveClient();
- }
-
@Override
DmaapConsumerConfiguration resolveConfiguration() {
return prhAppConfig.getDmaapConsumerConfiguration();
}
+ protected void setDmaapClientConfig() {
+ extendedDmaapConsumerHttpClient = resolveClient();
+ }
+
@Override
protected ExtendedDmaapConsumerHttpClientImpl resolveClient() {
return new ExtendedDmaapConsumerHttpClientImpl(resolveConfiguration());
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 d03f8061..6450b18a 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
@@ -19,13 +19,12 @@
*/
package org.onap.dcaegen2.services.prh.tasks;
-import com.google.gson.Gson;
import org.onap.dcaegen2.services.prh.config.DmaapPublisherConfiguration;
-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.DmaapNotFoundException;
import org.onap.dcaegen2.services.prh.exceptions.PrhTaskException;
+import org.onap.dcaegen2.services.prh.model.ConsumerDmaapModel;
import org.onap.dcaegen2.services.prh.service.producer.ExtendedDmaapProducerHttpClientImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -41,8 +40,8 @@ public class DmaapPublisherTaskImpl extends
DmaapPublisherTask<ExtendedDmaapProducerHttpClientImpl, ConsumerDmaapModel, DmaapPublisherConfiguration> {
private static final Logger logger = LoggerFactory.getLogger(DmaapPublisherTaskImpl.class);
- private static final Gson gson = new Gson();
private final Config prhAppConfig;
+ private ExtendedDmaapProducerHttpClientImpl extendedDmaapProducerHttpClient;
@Autowired
public DmaapPublisherTaskImpl(AppConfig prhAppConfig) {
@@ -52,17 +51,15 @@ public class DmaapPublisherTaskImpl extends
@Override
protected String publish(ConsumerDmaapModel consumerDmaapModel) throws DmaapNotFoundException {
logger.trace("Method called with arg {}", consumerDmaapModel);
- ExtendedDmaapProducerHttpClientImpl dmaapProducerHttpClient = new ExtendedDmaapProducerHttpClientImpl(
- resolveConfiguration());
-
- return dmaapProducerHttpClient.getHttpProducerResponse(consumerDmaapModel)
- .filter(x -> !x.isEmpty() && x.equals(String.valueOf(HttpStatus.OK.value())))
+ return extendedDmaapProducerHttpClient.getHttpProducerResponse(consumerDmaapModel)
+ .filter(response -> !response.isEmpty() && response.equals(String.valueOf(HttpStatus.OK.value())))
.orElseThrow(() -> new DmaapNotFoundException("Incorrect response from Dmaap"));
}
@Override
public Object execute(Object object) throws PrhTaskException {
if (object instanceof ConsumerDmaapModel) {
+ setDmaapClientConfig();
logger.trace("Method called with arg {}", object);
return publish((ConsumerDmaapModel) object);
}
@@ -78,4 +75,8 @@ public class DmaapPublisherTaskImpl extends
protected ExtendedDmaapProducerHttpClientImpl resolveClient() {
return null;
}
+
+ protected void setDmaapClientConfig() {
+ extendedDmaapProducerHttpClient = resolveClient();
+ }
} \ No newline at end of file