diff options
18 files changed, 150 insertions, 69 deletions
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AppConfig.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AppConfig.java index 1b530e5a..d6ca423b 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AppConfig.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AppConfig.java @@ -21,7 +21,7 @@ package org.onap.dcaegen2.services.prh.configuration; import org.onap.dcaegen2.services.config.AAIHttpClientConfiguration; import org.onap.dcaegen2.services.config.DmaapConsumerConfiguration; -import org.onap.dcaegen2.services.config.DmaapProducerConfiguration; +import org.onap.dcaegen2.services.config.DmaapPublisherConfiguration; /** * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/9/18 @@ -32,6 +32,6 @@ public interface AppConfig { AAIHttpClientConfiguration getAAIHttpClientConfiguration(); - DmaapProducerConfiguration getDmaapProducerConfiguration(); + DmaapPublisherConfiguration getDmaapPublisherConfiguration(); } diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfig.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfig.java index 19fcb8b8..37b17f61 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfig.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfig.java @@ -37,10 +37,10 @@ import java.util.Optional; import javax.validation.constraints.NotEmpty; import org.onap.dcaegen2.services.config.AAIHttpClientConfiguration; import org.onap.dcaegen2.services.config.DmaapConsumerConfiguration; -import org.onap.dcaegen2.services.config.DmaapProducerConfiguration; +import org.onap.dcaegen2.services.config.DmaapPublisherConfiguration; import org.onap.dcaegen2.services.config.ImmutableAAIHttpClientConfiguration; import org.onap.dcaegen2.services.config.ImmutableDmaapConsumerConfiguration; -import org.onap.dcaegen2.services.config.ImmutableDmaapProducerConfiguration; +import org.onap.dcaegen2.services.config.ImmutableDmaapPublisherConfiguration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.context.properties.ConfigurationProperties; @@ -65,11 +65,11 @@ public class PrhAppConfig implements AppConfig { private static final Logger logger = LoggerFactory.getLogger(PrhAppConfig.class); private static final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss"); - private ImmutableAAIHttpClientConfiguration immutableAAIHttpClientConfiguration; + private AAIHttpClientConfiguration aaiHttpClientConfiguration; - private ImmutableDmaapConsumerConfiguration immutableDmaapConsumerConfiguration; + private DmaapConsumerConfiguration dmaapConsumerConfiguration; - private ImmutableDmaapProducerConfiguration immutableDmaapProducerConfiguration; + private DmaapPublisherConfiguration dmaapPublisherConfiguration; @NotEmpty private String filepath; @@ -81,16 +81,16 @@ public class PrhAppConfig implements AppConfig { try (InputStream inputStream = getInputStream(filepath)) { ObjectNode root = (ObjectNode) jsonObjectMapper.readTree(inputStream); jsonNode = Optional.ofNullable(root.get(CONFIG).get(AAI).get(AAI_CONFIG)).orElse(NullNode.getInstance()); - immutableAAIHttpClientConfiguration = jsonObjectMapper + aaiHttpClientConfiguration = jsonObjectMapper .treeToValue(jsonNode, ImmutableAAIHttpClientConfiguration.class); jsonNode = Optional.ofNullable(root.get(CONFIG).get(DMAAP).get(DMAAP_CONSUMER)) .orElse(NullNode.getInstance()); - immutableDmaapConsumerConfiguration = jsonObjectMapper + dmaapConsumerConfiguration = jsonObjectMapper .treeToValue(jsonNode, ImmutableDmaapConsumerConfiguration.class); jsonNode = Optional.ofNullable(root.get(CONFIG).get(DMAAP).get(DMAAP_PRODUCER)) .orElse(NullNode.getInstance()); - immutableDmaapProducerConfiguration = jsonObjectMapper - .treeToValue(jsonNode, ImmutableDmaapProducerConfiguration.class); + dmaapPublisherConfiguration = jsonObjectMapper + .treeToValue(jsonNode, ImmutableDmaapPublisherConfiguration.class); } catch (FileNotFoundException e) { logger .error( @@ -132,16 +132,16 @@ public class PrhAppConfig implements AppConfig { @Override public DmaapConsumerConfiguration getDmaapConsumerConfiguration() { - return immutableDmaapConsumerConfiguration; + return dmaapConsumerConfiguration; } @Override public AAIHttpClientConfiguration getAAIHttpClientConfiguration() { - return immutableAAIHttpClientConfiguration; + return aaiHttpClientConfiguration; } @Override - public DmaapProducerConfiguration getDmaapProducerConfiguration() { - return immutableDmaapProducerConfiguration; + public DmaapPublisherConfiguration getDmaapPublisherConfiguration() { + return dmaapPublisherConfiguration; } }
\ No newline at end of file diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/exceptions/PrhTaskException.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/exceptions/PrhTaskException.java index 646ca7e7..33193609 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/exceptions/PrhTaskException.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/exceptions/PrhTaskException.java @@ -24,7 +24,7 @@ package org.onap.dcaegen2.services.prh.exceptions; */ public class PrhTaskException extends Exception { - public PrhTaskException(String message) { + PrhTaskException(String message) { super(message); } } diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIPublisherTask.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIPublisherTask.java index 87a70810..8ea4ac8f 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIPublisherTask.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIPublisherTask.java @@ -24,7 +24,9 @@ import org.onap.dcaegen2.services.prh.exceptions.AAINotFoundException; /** * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/13/18 */ -public abstract class AAIPublisherTask implements Task { +public abstract class AAIPublisherTask<T> extends Task { protected abstract void publish() throws AAINotFoundException; + + protected abstract T resolveConfiguration(); } diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIPublisherTaskImpl.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIPublisherTaskImpl.java index d4efea4f..c524b990 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIPublisherTaskImpl.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIPublisherTaskImpl.java @@ -21,40 +21,54 @@ package org.onap.dcaegen2.services.prh.tasks; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; +import org.onap.dcaegen2.services.config.AAIHttpClientConfiguration; import org.onap.dcaegen2.services.prh.configuration.AppConfig; +import org.onap.dcaegen2.services.prh.exceptions.AAINotFoundException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; /** * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/13/18 */ @Component -public class AAIPublisherTaskImpl extends AAIPublisherTask { +public class AAIPublisherTaskImpl extends AAIPublisherTask<AAIHttpClientConfiguration> { private static final Logger logger = LoggerFactory.getLogger(ScheduledTasks.class); private static final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss"); + private final AppConfig prhAppConfig; + @Autowired - public AppConfig prhAppConfig; + public AAIPublisherTaskImpl(AppConfig prhAppConfig) { + this.prhAppConfig = prhAppConfig; + + } @Override - protected void publish() { + protected void publish() throws AAINotFoundException { logger.debug("Start task DmaapConsumerTask::publish() :: Execution Time - {}", dateTimeFormatter.format( LocalDateTime.now())); - logger.debug("End task DmaapConsumerTask::publish() :: Execution Time - {}", dateTimeFormatter.format( LocalDateTime.now())); + } @Override - public void execute() { + public ResponseEntity execute(Object object) throws AAINotFoundException { logger.debug("Start task AAIPublisherTaskImpl::execute() :: Execution Time - {}", dateTimeFormatter.format( LocalDateTime.now())); - + publish(); logger.debug("End task AAIPublisherTaskImpl::execute() :: Execution Time - {}", dateTimeFormatter.format( LocalDateTime.now())); + return null; + } + @Override + protected AAIHttpClientConfiguration resolveConfiguration() { + return prhAppConfig.getAAIHttpClientConfiguration(); } + } diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTask.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTask.java index 41031664..68a79e01 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTask.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTask.java @@ -24,7 +24,9 @@ import org.onap.dcaegen2.services.prh.exceptions.DmaapNotFoundException; /** * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/13/18 */ -public abstract class DmaapConsumerTask implements Task { +public abstract class DmaapConsumerTask<T> extends Task { protected abstract void consume() throws DmaapNotFoundException; + + protected abstract T resolveConfiguration(); } 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 57f97778..1ee85d03 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 @@ -21,41 +21,53 @@ package org.onap.dcaegen2.services.prh.tasks; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; +import org.onap.dcaegen2.services.config.DmaapConsumerConfiguration; import org.onap.dcaegen2.services.prh.configuration.AppConfig; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; /** * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 3/23/18 */ @Component -public class DmaapConsumerTaskImpl extends DmaapConsumerTask { +public class DmaapConsumerTaskImpl extends DmaapConsumerTask<DmaapConsumerConfiguration> { private static final Logger logger = LoggerFactory.getLogger(DmaapConsumerTaskImpl.class); private static final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss"); + private final AppConfig prhAppConfig; + @Autowired - public AppConfig prhAppConfig; + public DmaapConsumerTaskImpl(AppConfig prhAppConfig) { + this.prhAppConfig = prhAppConfig; + } @Override - public void execute() { - logger.debug("Start task DmaapConsumerTask::execute() :: Execution Time - {}", dateTimeFormatter.format( + protected void consume() { + logger.debug("Start task DmaapConsumerTask::consume() :: Execution Time - {}", dateTimeFormatter.format( LocalDateTime.now())); - logger.debug("End task DmaapConsumerTask::execute() :: Execution Time - {}", + logger.debug("End task DmaapConsumerTask::consume() :: Execution Time - {}", dateTimeFormatter.format(LocalDateTime.now())); + } @Override - protected void consume() { - logger.debug("Start task DmaapConsumerTask::consume() :: Execution Time - {}", dateTimeFormatter.format( + public ResponseEntity execute(Object object) { + logger.debug("Start task DmaapConsumerTask::execute() :: Execution Time - {}", dateTimeFormatter.format( LocalDateTime.now())); - - logger.debug("End task DmaapConsumerTask::consume() :: Execution Time - {}", + consume(); + logger.debug("End task DmaapConsumerTask::execute() :: Execution Time - {}", dateTimeFormatter.format(LocalDateTime.now())); + return null; + } + @Override + protected DmaapConsumerConfiguration resolveConfiguration() { + return prhAppConfig.getDmaapConsumerConfiguration(); } }
\ No newline at end of file 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 d203c8c5..239d36a9 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 @@ -24,8 +24,10 @@ import org.onap.dcaegen2.services.prh.exceptions.DmaapNotFoundException; /** * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 3/23/18 */ -public abstract class DmaapPublisherTask implements Task { +public abstract class DmaapPublisherTask<T> extends Task { protected abstract void publish() throws DmaapNotFoundException; + protected abstract T 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 92eb875c..b14d8d37 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 @@ -21,39 +21,51 @@ package org.onap.dcaegen2.services.prh.tasks; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; +import org.onap.dcaegen2.services.config.DmaapPublisherConfiguration; import org.onap.dcaegen2.services.prh.configuration.AppConfig; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; /** * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/13/18 */ @Component -public class DmaapPublisherTaskImpl extends DmaapPublisherTask { +public class DmaapPublisherTaskImpl extends DmaapPublisherTask<DmaapPublisherConfiguration> { private static final Logger logger = LoggerFactory.getLogger(ScheduledTasks.class); private static final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss"); + private final AppConfig prhAppConfig; + @Autowired - public AppConfig prhAppConfig; + public DmaapPublisherTaskImpl(AppConfig prhAppConfig) { + this.prhAppConfig = prhAppConfig; + } @Override - public void execute() { - logger.debug("Start task DmaapPublisherTask::consume() :: Execution Time - {}", dateTimeFormatter.format( + protected void publish() { + logger.debug("Start task DmaapPublisherTask::publish() :: Execution Time - {}", dateTimeFormatter.format( LocalDateTime.now())); - logger.debug("End task DmaapPublisherTask::consume() :: Execution Time - {}", + logger.debug("End task DmaapPublisherTask::publish() :: Execution Time - {}", dateTimeFormatter.format(LocalDateTime.now())); } @Override - protected void publish() { - logger.debug("Start task DmaapPublisherTask::publish() :: Execution Time - {}", dateTimeFormatter.format( + public ResponseEntity execute(Object object) { + logger.debug("Start task DmaapPublisherTask::consume() :: Execution Time - {}", dateTimeFormatter.format( LocalDateTime.now())); - - logger.debug("End task DmaapPublisherTask::publish() :: Execution Time - {}", + publish(); + logger.debug("End task DmaapPublisherTask::consume() :: Execution Time - {}", dateTimeFormatter.format(LocalDateTime.now())); + return null; + } + + @Override + protected DmaapPublisherConfiguration resolveConfiguration() { + return prhAppConfig.getDmaapPublisherConfiguration(); } } diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasks.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasks.java index 713f5d48..a9c53ccc 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasks.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasks.java @@ -36,25 +36,24 @@ public class ScheduledTasks { private static final Logger logger = LoggerFactory.getLogger(ScheduledTasks.class); private static final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss"); - private final DmaapConsumerTask dmaapConsumerTask; - private final DmaapPublisherTask dmaapPublisherTask; - private final AAIPublisherTask aaiPublisherTask; + private final Task dmaapConsumerTask; + private final Task dmaapProducerTask; + private final Task aaiPublisherTask; @Autowired public ScheduledTasks(DmaapConsumerTask dmaapConsumerTask, DmaapPublisherTask dmaapPublisherTask, AAIPublisherTask aaiPublisherTask) { this.dmaapConsumerTask = dmaapConsumerTask; - this.dmaapPublisherTask = dmaapPublisherTask; + this.dmaapProducerTask = dmaapPublisherTask; this.aaiPublisherTask = aaiPublisherTask; } public void scheduleMainPrhEventTask() { logger.debug("Task scheduledTaskAskingDMaaPOfConsumeEvent() :: Execution Time - {}", dateTimeFormatter.format( LocalDateTime.now())); + setTaskExecutionFlow(); try { - dmaapConsumerTask.execute(); - dmaapPublisherTask.execute(); - aaiPublisherTask.execute(); + dmaapConsumerTask.receiveRequest(null); } catch (PrhTaskException e) { logger .error("Task scheduledTaskAskingDMaaPOfConsumeEvent()::PrhTaskException :: Execution Time - {}:{}", @@ -63,4 +62,9 @@ public class ScheduledTasks { } } + private void setTaskExecutionFlow() { + dmaapConsumerTask.setNext(aaiPublisherTask); + aaiPublisherTask.setNext(dmaapProducerTask); + } + } diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/Task.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/Task.java index 1bf8f6d3..f5e8b39e 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/Task.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/Task.java @@ -20,13 +20,29 @@ package org.onap.dcaegen2.services.prh.tasks; import org.onap.dcaegen2.services.prh.exceptions.PrhTaskException; +import org.springframework.http.ResponseEntity; /** * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/13/18 */ -@FunctionalInterface -public interface Task { - void execute() throws PrhTaskException; +public abstract class Task { + + private Task taskProcess; + + public void setNext(Task task) { + this.taskProcess = task; + } + + public void receiveRequest(Object body) throws PrhTaskException { + Object responseEntity = execute(body); + if (taskProcess != null) { + taskProcess.receiveRequest(responseEntity); + } + } + + abstract ResponseEntity execute(Object object) throws PrhTaskException; + + } diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/IT/ScheduledXmlContextITest.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/IT/ScheduledXmlContextITest.java index 0c92da77..c8ed88da 100644 --- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/IT/ScheduledXmlContextITest.java +++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/IT/ScheduledXmlContextITest.java @@ -61,7 +61,7 @@ class ScheduledXmlContextITest extends AbstractTestNGSpringContextTests { } private void verifyDmaapConsumerTask() { - verify(scheduledTask, atLeast(2)).scheduleMainPrhEventTask(); + verify(scheduledTask, atLeast(1)).scheduleMainPrhEventTask(); } } diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfigTest.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfigTest.java index a6361cfe..26be5133 100644 --- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfigTest.java +++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfigTest.java @@ -99,7 +99,7 @@ class PrhAppConfigTest { verify(prhAppConfig, times(1)).initFileStreamReader(); Assertions.assertNotNull(prhAppConfig.getAAIHttpClientConfiguration()); Assertions.assertNotNull(prhAppConfig.getDmaapConsumerConfiguration()); - Assertions.assertNotNull(prhAppConfig.getDmaapProducerConfiguration()); + Assertions.assertNotNull(prhAppConfig.getDmaapPublisherConfiguration()); } @Test @@ -120,7 +120,7 @@ class PrhAppConfigTest { verify(prhAppConfig, times(1)).initFileStreamReader(); Assertions.assertNull(prhAppConfig.getAAIHttpClientConfiguration()); Assertions.assertNull(prhAppConfig.getDmaapConsumerConfiguration()); - Assertions.assertNull(prhAppConfig.getDmaapProducerConfiguration()); + Assertions.assertNull(prhAppConfig.getDmaapPublisherConfiguration()); } @@ -144,7 +144,7 @@ class PrhAppConfigTest { verify(prhAppConfig, times(1)).initFileStreamReader(); Assertions.assertNotNull(prhAppConfig.getAAIHttpClientConfiguration()); Assertions.assertNotNull(prhAppConfig.getDmaapConsumerConfiguration()); - Assertions.assertNull(prhAppConfig.getDmaapProducerConfiguration()); + Assertions.assertNull(prhAppConfig.getDmaapPublisherConfiguration()); } }
\ No newline at end of file diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AAIPublisherTaskSpy.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AAIPublisherTaskSpy.java index 56565cad..c27c8813 100644 --- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AAIPublisherTaskSpy.java +++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AAIPublisherTaskSpy.java @@ -19,8 +19,12 @@ */ package org.onap.dcaegen2.services.prh.tasks; +import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.when; +import org.onap.dcaegen2.services.config.AAIHttpClientConfiguration; +import org.onap.dcaegen2.services.prh.configuration.AppConfig; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; @@ -34,6 +38,8 @@ public class AAIPublisherTaskSpy { @Bean @Primary public AAIPublisherTask registerSimpleAAIPublisherTask() { - return spy(new AAIPublisherTaskImpl()); + AppConfig appConfig = mock(AppConfig.class); + when(appConfig.getAAIHttpClientConfiguration()).thenReturn(mock(AAIHttpClientConfiguration.class)); + return spy(new AAIPublisherTaskImpl(appConfig)); } } diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskSpy.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskSpy.java index d41da169..c2934d4e 100644 --- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskSpy.java +++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskSpy.java @@ -19,8 +19,12 @@ */ package org.onap.dcaegen2.services.prh.tasks; +import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.when; +import org.onap.dcaegen2.services.config.DmaapConsumerConfiguration; +import org.onap.dcaegen2.services.prh.configuration.AppConfig; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; @@ -33,7 +37,9 @@ public class DmaapConsumerTaskSpy { @Bean @Primary - public DmaapConsumerTaskImpl registerSimpleDmaapConsumerTask() { - return spy(new DmaapConsumerTaskImpl()); + public Task registerSimpleDmaapConsumerTask() { + AppConfig appConfig = mock(AppConfig.class); + when(appConfig.getDmaapConsumerConfiguration()).thenReturn(mock(DmaapConsumerConfiguration.class)); + return spy(new DmaapConsumerTaskImpl(appConfig)); } } diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskSpy.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapProducerTaskSpy.java index 8bdc7a1d..c36c84b0 100644 --- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskSpy.java +++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapProducerTaskSpy.java @@ -19,8 +19,12 @@ */ package org.onap.dcaegen2.services.prh.tasks; +import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.when; +import org.onap.dcaegen2.services.config.DmaapPublisherConfiguration; +import org.onap.dcaegen2.services.prh.configuration.AppConfig; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; @@ -29,12 +33,14 @@ import org.springframework.context.annotation.Primary; * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/13/18 */ @Configuration -public class DmaapPublisherTaskSpy { +public class DmaapProducerTaskSpy { @Bean @Primary - public DmaapPublisherTaskImpl registerSimpleDmaapPublisherTask() { - return spy(new DmaapPublisherTaskImpl()); + public Task registerSimpleDmaapPublisherTask() { + AppConfig appConfig = mock(AppConfig.class); + when(appConfig.getDmaapPublisherConfiguration()).thenReturn(mock(DmaapPublisherConfiguration.class)); + return spy(new DmaapPublisherTaskImpl(appConfig)); } } diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/ScheduleControllerSpy.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/ScheduleControllerSpy.java index 0b5f969b..2d599b23 100644 --- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/ScheduleControllerSpy.java +++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/ScheduleControllerSpy.java @@ -22,7 +22,6 @@ package org.onap.dcaegen2.services.prh.tasks; import static org.mockito.Mockito.spy; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; diff --git a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/config/DmaapProducerConfiguration.java b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/config/DmaapPublisherConfiguration.java index 99cbbca3..6607853e 100644 --- a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/config/DmaapProducerConfiguration.java +++ b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/config/DmaapPublisherConfiguration.java @@ -29,18 +29,18 @@ import org.springframework.stereotype.Component; @Component @Value.Immutable(prehash = true) @Value.Style(builder = "new") -@JsonDeserialize(builder = ImmutableDmaapProducerConfiguration.Builder.class) -public abstract class DmaapProducerConfiguration implements DmaapCustomConfig { +@JsonDeserialize(builder = ImmutableDmaapPublisherConfiguration.Builder.class) +public abstract class DmaapPublisherConfiguration implements DmaapCustomConfig { private static final long serialVersionUID = 1L; interface Builder extends - DmaapCustomConfig.Builder<DmaapProducerConfiguration, DmaapProducerConfiguration.Builder> { + DmaapCustomConfig.Builder<DmaapPublisherConfiguration, DmaapPublisherConfiguration.Builder> { } - public static DmaapProducerConfiguration.Builder builder() { - return ImmutableDmaapProducerConfiguration.builder(); + public static DmaapPublisherConfiguration.Builder builder() { + return ImmutableDmaapPublisherConfiguration.builder(); } |