diff options
author | adheli.tavares <adheli.tavares@est.tech> | 2024-01-26 15:28:56 +0000 |
---|---|---|
committer | Adheli Tavares <adheli.tavares@est.tech> | 2024-02-09 10:31:15 +0000 |
commit | cc1d3d352771d1fa35d297e90663539e34b022f6 (patch) | |
tree | b1b00d678b0157742b91be1262fbf614a62063b1 /feature-test-transaction | |
parent | cce79248655f484e007769ba81b092148f940d27 (diff) |
Removing deprecated DMAAP library
Issue-ID: POLICY-4402
Change-Id: I4ce5b303cb3a775010683d3c7102b0bd065280ea
Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'feature-test-transaction')
3 files changed, 47 insertions, 44 deletions
diff --git a/feature-test-transaction/src/test/java/org/onap/policy/drools/testtransaction/TestTransactionAdditionalTest.java b/feature-test-transaction/src/test/java/org/onap/policy/drools/testtransaction/TestTransactionAdditionalTest.java index 7a32e549..f567c593 100644 --- a/feature-test-transaction/src/test/java/org/onap/policy/drools/testtransaction/TestTransactionAdditionalTest.java +++ b/feature-test-transaction/src/test/java/org/onap/policy/drools/testtransaction/TestTransactionAdditionalTest.java @@ -3,6 +3,7 @@ * feature-test-transaction * ================================================================================ * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,10 +21,10 @@ package org.onap.policy.drools.testtransaction; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyString; @@ -40,13 +41,13 @@ import java.util.List; import java.util.Map; import java.util.TreeMap; import java.util.concurrent.atomic.AtomicInteger; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.onap.policy.drools.controller.DroolsController; import org.onap.policy.drools.core.PolicyContainer; import org.onap.policy.drools.system.PolicyController; -public class TestTransactionAdditionalTest { +class TestTransactionAdditionalTest { private static final int MAX_SLEEP_COUNT = 3; private static final String EXPECTED = "expected exception"; @@ -56,7 +57,7 @@ public class TestTransactionAdditionalTest { private static final String SESSION1 = "session-a"; private static final String SESSION2 = "session-b"; private static final List<String> sessions = Arrays.asList(SESSION1, SESSION2); - private static final List<Object> facts = Arrays.asList(0L); + private static final List<Object> facts = List.of(0L); private Thread theThread; private PolicyController controller; @@ -76,7 +77,7 @@ public class TestTransactionAdditionalTest { /** * Initialize objects for each test. */ - @Before + @BeforeEach public void setUp() { theThread = mock(Thread.class); controller = mock(PolicyController.class); @@ -118,12 +119,12 @@ public class TestTransactionAdditionalTest { } @Test - public void testTestTransactionImpl() { + void testTestTransactionImpl() { assertNotNull(TestTransactionConstants.getManager()); } @Test - public void testTestTransactionImplRegister_testTestTransactionImplUnregister() { + void testTestTransactionImplRegister_testTestTransactionImplUnregister() { task = mock(TtControllerTask.class); when(task.isAlive()).thenReturn(true); name2task.put(CONTROLLER1, task); @@ -162,7 +163,7 @@ public class TestTransactionAdditionalTest { } @Test - public void testTestTransactionControllerTaskFactory() throws Exception { + void testTestTransactionControllerTaskFactory() throws Exception { task = new TtControllerTask(controller) { @Override protected Thread makeThread(Runnable action) { @@ -170,7 +171,7 @@ public class TestTransactionAdditionalTest { } @Override - protected void joinThread(long waitTimeMs) throws InterruptedException { + protected void joinThread(long waitTimeMs) { // do nothing } }; @@ -180,7 +181,7 @@ public class TestTransactionAdditionalTest { } @Test - public void testTestTransactionControllerTask() { + void testTestTransactionControllerTask() { assertEquals(task, theAction); assertTrue(task.isAlive()); assertEquals(controller, task.getController()); @@ -190,17 +191,17 @@ public class TestTransactionAdditionalTest { } @Test - public void testTestTransactionControllerTaskGetController() { + void testTestTransactionControllerTaskGetController() { assertEquals(controller, task.getController()); } @Test - public void testTestTransactionControllerTaskGetThread() { + void testTestTransactionControllerTaskGetThread() { assertEquals(theThread, task.getThread()); } @Test - public void testTestTransactionControllerTaskStop() throws Exception { + void testTestTransactionControllerTaskStop() { task.stop(); assertFalse(task.isAlive()); verify(theThread).interrupt(); @@ -222,7 +223,7 @@ public class TestTransactionAdditionalTest { } @Test - public void testTestTransactionControllerTaskRun() { + void testTestTransactionControllerTaskRun() { task.run(); assertFalse(task.isAlive()); verify(theThread, never()).interrupt(); @@ -338,7 +339,7 @@ public class TestTransactionAdditionalTest { } @Test - public void testTestTransactionControllerTaskInjectTxIntoSessions() { + void testTestTransactionControllerTaskInjectTxIntoSessions() { task.run(); verify(container, times(MAX_SLEEP_COUNT * sessions.size())).insert(anyString(), any(EventObject.class)); @@ -356,7 +357,7 @@ public class TestTransactionAdditionalTest { } @Test - public void testTestTransactionControllerTaskToString() { + void testTestTransactionControllerTaskToString() { assertTrue(task.toString().startsWith("TTControllerTask [")); } diff --git a/feature-test-transaction/src/test/java/org/onap/policy/drools/testtransaction/TestTransactionFeatureTest.java b/feature-test-transaction/src/test/java/org/onap/policy/drools/testtransaction/TestTransactionFeatureTest.java index 6bb09903..a7b213bb 100644 --- a/feature-test-transaction/src/test/java/org/onap/policy/drools/testtransaction/TestTransactionFeatureTest.java +++ b/feature-test-transaction/src/test/java/org/onap/policy/drools/testtransaction/TestTransactionFeatureTest.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,21 +21,21 @@ package org.onap.policy.drools.testtransaction; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Function; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.onap.policy.drools.controller.DroolsController; import org.onap.policy.drools.system.PolicyController; -public class TestTransactionFeatureTest { +class TestTransactionFeatureTest { private AtomicInteger regCount; private AtomicInteger unregCount; @@ -46,7 +47,7 @@ public class TestTransactionFeatureTest { /** * Initialize objects for each test. */ - @Before + @BeforeEach public void setUp() { regCount = new AtomicInteger(0); unregCount = new AtomicInteger(0); @@ -75,34 +76,34 @@ public class TestTransactionFeatureTest { } @Test - public void testAfterStart() { + void testAfterStart() { // try each combination of alive, locked, and brained checkCombos(regCount, ctlr -> feat.afterStart(ctlr)); } @Test - public void testAfterLock() { + void testAfterLock() { checkSimple(unregCount, ctlr -> feat.afterLock(ctlr)); } @Test - public void testAfterUnlock() { + void testAfterUnlock() { // try each combination of alive, locked, and brained checkCombos(regCount, ctlr -> feat.afterUnlock(ctlr)); } @Test - public void testBeforeStop() { + void testBeforeStop() { checkSimple(unregCount, ctlr -> feat.beforeStop(ctlr)); } @Test - public void testGetSequenceNumber() { + void testGetSequenceNumber() { assertEquals(1000, feat.getSequenceNumber()); } @Test - public void testGetTestTransMgr() { + void testGetTestTransMgr() { assertNotNull(new TestTransactionFeature().getTestTransMgr()); } diff --git a/feature-test-transaction/src/test/java/org/onap/policy/drools/testtransaction/TestTransactionTest.java b/feature-test-transaction/src/test/java/org/onap/policy/drools/testtransaction/TestTransactionTest.java index f8a8cc20..a1fd2738 100644 --- a/feature-test-transaction/src/test/java/org/onap/policy/drools/testtransaction/TestTransactionTest.java +++ b/feature-test-transaction/src/test/java/org/onap/policy/drools/testtransaction/TestTransactionTest.java @@ -3,6 +3,7 @@ * feature-test-transaction * ================================================================================ * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,8 +21,9 @@ package org.onap.policy.drools.testtransaction; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; import java.io.IOException; import java.nio.file.Files; @@ -31,8 +33,8 @@ import java.util.Properties; import java.util.Set; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import org.onap.policy.drools.persistence.SystemPersistenceConstants; import org.onap.policy.drools.properties.DroolsPropertyConstants; import org.onap.policy.drools.system.PolicyController; @@ -52,15 +54,14 @@ public class TestTransactionTest { TEST_CONTROLLER_NAME + "-controller.properties.bak"; /** logger. */ - private static Logger logger = LoggerFactory.getLogger(TestTransactionTest.class); + private static final Logger logger = LoggerFactory.getLogger(TestTransactionTest.class); /** * Start up. * - * @throws IOException exception */ - @BeforeClass - public static void startUp() throws IOException { + @BeforeAll + public static void startUp() { logger.info("enter"); cleanUpWorkingDir(); @@ -70,7 +71,7 @@ public class TestTransactionTest { } @Test - public void testRegisterUnregister() throws InterruptedException { + void testRegisterUnregister() throws InterruptedException { final Properties controllerProperties = new Properties(); controllerProperties.put(DroolsPropertyConstants.PROPERTY_CONTROLLER_NAME, TEST_CONTROLLER_NAME); final PolicyController controller = @@ -80,7 +81,7 @@ public class TestTransactionTest { CountDownLatch latch = new CountDownLatch(1); - // use our own impl so we can decrement the latch when run() completes + // use our own impl, so we can decrement the latch when run() completes TtImpl impl = new TtImpl() { @Override protected TtControllerTask makeControllerTask(PolicyController controller) { @@ -104,7 +105,7 @@ public class TestTransactionTest { impl.unregister(controller); Thread ttThread = getThread(latch, "tt-controller-task-" + TEST_CONTROLLER_NAME); - assertEquals(null, ttThread); + assertNull(ttThread); } /** |