From 9292dd2aa89214957fc72980f58026324ca75a4f Mon Sep 17 00:00:00 2001 From: wasala Date: Wed, 28 Mar 2018 19:04:20 +0200 Subject: Already fixed Sonar issues We have fixed Sonar issue with critical and minor tag Change-Id: Iccc343654686ba87f71d57382b68ddf9c54caeea Issue-ID: DCAEGEN2-407 Signed-off-by: wasala --- .../services/prh/tasks/ScheduledXmlContextITest.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'prh-app-server/src/test') diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/ScheduledXmlContextITest.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/ScheduledXmlContextITest.java index 14e83c62..7a3fac63 100644 --- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/ScheduledXmlContextITest.java +++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/ScheduledXmlContextITest.java @@ -22,6 +22,11 @@ package org.onap.dcaegen2.services.prh.tasks; import static org.mockito.Mockito.atLeast; import static org.mockito.Mockito.verify; +import java.time.Duration; +import java.util.concurrent.Callable; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; import org.junit.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.junit.runner.RunWith; @@ -44,7 +49,7 @@ import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; @ContextConfiguration(locations = {"classpath:scheduled-context.xml"}) public class ScheduledXmlContextITest extends AbstractTestNGSpringContextTests { - private static final int WAIT_FOR_SCHEDULING = 1000; + private static final int WAIT_FOR_SCHEDULING = 1; @Autowired private DmaapConsumerTask dmaapConsumerTaskSpy; @@ -52,9 +57,15 @@ public class ScheduledXmlContextITest extends AbstractTestNGSpringContextTests { @Test public void testScheduling() throws InterruptedException { - Thread.sleep(WAIT_FOR_SCHEDULING); + final ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor(); + executorService.scheduleWithFixedDelay(this::verifyDmaapConsumerTask, 0, WAIT_FOR_SCHEDULING, TimeUnit.SECONDS); + } + + private void verifyDmaapConsumerTask() { verify(dmaapConsumerTaskSpy, atLeast(2)).execute(); } + + } -- cgit 1.2.3-korg