diff options
author | Adheli Tavares <adheli.tavares@est.tech> | 2024-06-21 09:08:15 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2024-06-21 09:08:15 +0000 |
commit | bacd5a6f57e79f26d447644329b585991f989123 (patch) | |
tree | c2323f4039f9b40f2e93387cd5612ca8fbc7199b /models-sim | |
parent | 951a1df7e35c8aa51e91af1e17851d7d2aa45fb3 (diff) | |
parent | 9c8f53960b265ec82814f9a4a54ff44ce0682dde (diff) |
Merge "Convert models to JUnit 5"
Diffstat (limited to 'models-sim')
12 files changed, 136 insertions, 125 deletions
diff --git a/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/TestPdpSimulatorActivator.java b/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/TestPdpSimulatorActivator.java index 1ebd2a082..1d58a3325 100644 --- a/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/TestPdpSimulatorActivator.java +++ b/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/TestPdpSimulatorActivator.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2019 Nordix Foundation. * Modifications Copyright (C) 2019 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. @@ -22,15 +23,15 @@ package org.onap.policy.models.sim.pdp; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -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.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.onap.policy.common.utils.services.Registry; import org.onap.policy.models.pdp.concepts.PdpStatus; import org.onap.policy.models.sim.pdp.exception.PdpSimulatorException; @@ -43,7 +44,7 @@ import org.onap.policy.models.sim.pdp.parameters.PdpSimulatorParameterHandler; * * @author Ajith Sreekumar (ajith.sreekumar@est.tech) */ -public class TestPdpSimulatorActivator { +class TestPdpSimulatorActivator { private PdpSimulatorActivator activator; @@ -52,8 +53,8 @@ public class TestPdpSimulatorActivator { * * @throws Exception if an error occurs */ - @Before - public void setUp() throws Exception { + @BeforeEach + void setUp() throws Exception { Registry.newRegistry(); final String[] pdpSimulatorConfigParameters = { "-c", "src/test/resources/PdpSimulatorConfigParameters.json" }; final PdpSimulatorCommandLineArguments arguments = @@ -68,15 +69,15 @@ public class TestPdpSimulatorActivator { * * @throws Exception if an error occurs */ - @After - public void teardown() throws Exception { + @AfterEach + void teardown() throws Exception { if (activator != null && activator.isAlive()) { activator.terminate(); } } @Test - public void testPdpSimulatorActivator() throws PdpSimulatorException { + void testPdpSimulatorActivator() throws PdpSimulatorException { assertFalse(activator.isAlive()); activator.initialize(); assertTrue(activator.isAlive()); @@ -93,7 +94,7 @@ public class TestPdpSimulatorActivator { } @Test - public void testTerminate() throws Exception { + void testTerminate() throws Exception { activator.initialize(); activator.terminate(); assertFalse(activator.isAlive()); diff --git a/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/TestPdpSimulatorConstants.java b/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/TestPdpSimulatorConstants.java index 10d7d9f68..ca6562368 100644 --- a/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/TestPdpSimulatorConstants.java +++ b/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/TestPdpSimulatorConstants.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2019,2023 Nordix Foundation. * Modifications Copyright (C) 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. @@ -24,16 +25,16 @@ package org.onap.policy.models.sim.pdp; import static org.assertj.core.api.Assertions.assertThatCode; import java.lang.reflect.Constructor; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Class to perform unit test of {@link PdpSimulatorConstants}}. * * @author Ajith Sreekumar (ajith.sreekumar@est.tech) */ -public class TestPdpSimulatorConstants { +class TestPdpSimulatorConstants { @Test - public void test() throws Exception { + void test() throws Exception { // verify that constructor does not throw an exception assertThatCode(() -> { Constructor<PdpSimulatorConstants> c = PdpSimulatorConstants.class.getDeclaredConstructor(); diff --git a/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/TestPdpSimulatorMain.java b/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/TestPdpSimulatorMain.java index 0f82e6608..e02f5997c 100644 --- a/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/TestPdpSimulatorMain.java +++ b/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/TestPdpSimulatorMain.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2019 Nordix Foundation. * Modifications Copyright (C) 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. @@ -22,14 +23,14 @@ package org.onap.policy.models.sim.pdp; import static org.assertj.core.api.Assertions.assertThatCode; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +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 static org.junit.jupiter.api.Assertions.assertTrue; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.onap.policy.common.utils.services.Registry; import org.onap.policy.models.sim.pdp.exception.PdpSimulatorException; import org.onap.policy.models.sim.pdp.parameters.CommonTestData; @@ -39,14 +40,14 @@ import org.onap.policy.models.sim.pdp.parameters.CommonTestData; * * @author Ajith Sreekumar (ajith.sreekumar@est.tech) */ -public class TestPdpSimulatorMain { +class TestPdpSimulatorMain { private PdpSimulatorMain pdpSimulator; /** * Set up. */ - @Before - public void setUp() { + @BeforeEach + void setUp() { Registry.newRegistry(); } @@ -55,8 +56,8 @@ public class TestPdpSimulatorMain { * * @throws Exception if an error occurs */ - @After - public void tearDown() throws Exception { + @AfterEach + void tearDown() throws Exception { // shut down activator final PdpSimulatorActivator activator = Registry.getOrDefault(PdpSimulatorConstants.REG_PDP_SIMULATOR_ACTIVATOR, PdpSimulatorActivator.class, null); @@ -66,7 +67,7 @@ public class TestPdpSimulatorMain { } @Test - public void testPdpSimulator() throws PdpSimulatorException { + void testPdpSimulator() throws PdpSimulatorException { final String[] pdpSimulatorConfigParameters = { "-c", "src/test/resources/PdpSimulatorConfigParameters.json" }; pdpSimulator = new PdpSimulatorMain(pdpSimulatorConfigParameters); assertTrue(pdpSimulator.getParameters().isValid()); @@ -79,27 +80,27 @@ public class TestPdpSimulatorMain { } @Test - public void testPdpSimulator_NoArguments() { + void testPdpSimulator_NoArguments() { final String[] pdpSimulatorConfigParameters = {}; pdpSimulator = new PdpSimulatorMain(pdpSimulatorConfigParameters); assertNull(pdpSimulator.getParameters()); } @Test - public void testPdpSimulator_InvalidArguments() { + void testPdpSimulator_InvalidArguments() { final String[] pdpSimulatorConfigParameters = { "src/test/resourcesPdpSimulatorConfigParameters.json" }; pdpSimulator = new PdpSimulatorMain(pdpSimulatorConfigParameters); assertNull(pdpSimulator.getParameters()); } @Test - public void testPdpSimulator_Help() { + void testPdpSimulator_Help() { final String[] pdpSimulatorConfigParameters = { "-h" }; assertThatCode(() -> PdpSimulatorMain.main(pdpSimulatorConfigParameters)).doesNotThrowAnyException(); } @Test - public void testPdpSimulator_InvalidParameters() { + void testPdpSimulator_InvalidParameters() { final String[] pdpSimulatorConfigParameters = { "-c", "src/test/resources/PdpSimulatorConfigParameters_InvalidName.json" }; pdpSimulator = new PdpSimulatorMain(pdpSimulatorConfigParameters); diff --git a/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/comm/TestPdpStateChangeListener.java b/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/comm/TestPdpStateChangeListener.java index 20c9cc1b0..c0e933fb1 100644 --- a/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/comm/TestPdpStateChangeListener.java +++ b/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/comm/TestPdpStateChangeListener.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2019 Nordix Foundation. * Modifications Copyright (C) 2019 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. @@ -21,7 +22,7 @@ package org.onap.policy.models.sim.pdp.comm; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.IOException; import java.nio.charset.StandardCharsets; @@ -31,9 +32,9 @@ import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; import org.onap.policy.common.utils.services.Registry; import org.onap.policy.models.pdp.concepts.PdpStateChange; @@ -52,7 +53,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; * * @author Ajith Sreekumar (ajith.sreekumar@est.tech) */ -public class TestPdpStateChangeListener { +class TestPdpStateChangeListener { private static final String PDP_SUBGROUP = "pdpSubgroup"; private static final String PDP_GROUP = "pdpGroup"; private PdpUpdateListener pdpUpdateMessageListener; @@ -66,8 +67,8 @@ public class TestPdpStateChangeListener { * * @throws Exception if an error occurs */ - @Before - public void setUp() throws Exception { + @BeforeEach + void setUp() throws Exception { pdpUpdateMessageListener = new PdpUpdateListener(); pdpStateChangeListener = new PdpStateChangeListener(); Registry.newRegistry(); @@ -96,8 +97,8 @@ public class TestPdpStateChangeListener { * * @throws Exception if an error occurs */ - @After - public void teardown() throws Exception { + @AfterEach + void teardown() throws Exception { // clear the pdp simulator activator if (activator != null && activator.isAlive()) { @@ -139,7 +140,7 @@ public class TestPdpStateChangeListener { } @Test - public void testPdpStateChangeMessageListener_passivetopassive() { + void testPdpStateChangeMessageListener_passivetopassive() { final PdpStatus pdpStatus = Registry.get(PdpSimulatorConstants.REG_PDP_STATUS_OBJECT); performPdpUpdate(pdpStatus.getName()); final PdpStateChange pdpStateChangeMsg = new PdpStateChange(); @@ -149,11 +150,11 @@ public class TestPdpStateChangeListener { pdpStateChangeMsg.setName(pdpStatus.getName()); pdpStateChangeListener.onTopicEvent(INFRA, TOPIC, null, pdpStateChangeMsg); - assertEquals(pdpStatus.getState(), pdpStateChangeMsg.getState()); + assertEquals(pdpStateChangeMsg.getState(), pdpStatus.getState()); } @Test - public void testPdpStateChangeMessageListener_activetoactive() { + void testPdpStateChangeMessageListener_activetoactive() { final PdpStatus pdpStatus = Registry.get(PdpSimulatorConstants.REG_PDP_STATUS_OBJECT); performPdpUpdate(pdpStatus.getName()); pdpStatus.setState(PdpState.ACTIVE); diff --git a/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/comm/TestPdpUpdateListener.java b/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/comm/TestPdpUpdateListener.java index 0827f2619..b63fd1546 100644 --- a/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/comm/TestPdpUpdateListener.java +++ b/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/comm/TestPdpUpdateListener.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2019 Nordix Foundation. * Modifications Copyright (C) 2019 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. @@ -21,7 +22,7 @@ package org.onap.policy.models.sim.pdp.comm; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.IOException; import java.nio.charset.StandardCharsets; @@ -31,9 +32,9 @@ import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; import org.onap.policy.common.utils.services.Registry; import org.onap.policy.models.pdp.concepts.PdpStatus; @@ -51,7 +52,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; * * @author Ajith Sreekumar (ajith.sreekumar@est.tech) */ -public class TestPdpUpdateListener { +class TestPdpUpdateListener { private PdpUpdateListener pdpUpdateMessageListener; private static final CommInfrastructure INFRA = CommInfrastructure.NOOP; private static final String TOPIC = "my-topic"; @@ -62,8 +63,8 @@ public class TestPdpUpdateListener { * * @throws Exception if an error occurs */ - @Before - public void setUp() throws Exception { + @BeforeEach + void setUp() throws Exception { Registry.newRegistry(); final String[] pdpSimulatorConfigParameters = { "-c", "src/test/resources/PdpSimulatorConfigParameters.json" }; final PdpSimulatorCommandLineArguments arguments = new PdpSimulatorCommandLineArguments(); @@ -91,8 +92,8 @@ public class TestPdpUpdateListener { * * @throws Exception if an error occurs */ - @After - public void teardown() throws Exception { + @AfterEach + void teardown() throws Exception { // clear the pdp simulator activator if (activator != null && activator.isAlive()) { @@ -101,7 +102,7 @@ public class TestPdpUpdateListener { } @Test - public void testPdpUpdateMssageListener() { + void testPdpUpdateMssageListener() { final PdpStatus pdpStatus = Registry.get(PdpSimulatorConstants.REG_PDP_STATUS_OBJECT); final PdpUpdate pdpUpdateMsg = new PdpUpdate(); pdpUpdateMsg.setDescription("dummy pdp status for test"); diff --git a/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/exception/TestExceptions.java b/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/exception/TestExceptions.java index 45845a941..ab5ae89c7 100644 --- a/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/exception/TestExceptions.java +++ b/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/exception/TestExceptions.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2019 Nordix Foundation. + * 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,7 +21,7 @@ package org.onap.policy.models.sim.pdp.exception; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.common.utils.test.ExceptionsTester; /** @@ -28,10 +29,10 @@ import org.onap.policy.common.utils.test.ExceptionsTester; * * @author Ajith Sreekumar (ajith.sreekumar@est.tech) */ -public class TestExceptions { +class TestExceptions { @Test - public void test() { + void test() { new ExceptionsTester().test(PdpSimulatorException.class); new ExceptionsTester().test(PdpSimulatorRunTimeException.class); } diff --git a/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/parameters/TestPdpSimulatorParameterGroup.java b/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/parameters/TestPdpSimulatorParameterGroup.java index b7d13ef79..2b5eed45f 100644 --- a/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/parameters/TestPdpSimulatorParameterGroup.java +++ b/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/parameters/TestPdpSimulatorParameterGroup.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2019 Nordix Foundation. * Modifications Copyright (C) 2021 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. @@ -22,12 +23,12 @@ package org.onap.policy.models.sim.pdp.parameters; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -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.assertTrue; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.common.endpoints.parameters.TopicParameterGroup; import org.onap.policy.common.parameters.ValidationResult; @@ -36,17 +37,17 @@ import org.onap.policy.common.parameters.ValidationResult; * * @author Ajith Sreekumar (ajith.sreekumar@est.tech) */ -public class TestPdpSimulatorParameterGroup { +class TestPdpSimulatorParameterGroup { CommonTestData commonTestData = new CommonTestData(); @Test - public void testPdpSimulatorParameterGroup_Named() { + void testPdpSimulatorParameterGroup_Named() { final PdpSimulatorParameterGroup pdpSimulatorParameters = new PdpSimulatorParameterGroup("my-name"); assertEquals("my-name", pdpSimulatorParameters.getName()); } @Test - public void testPdpSimulatorParameterGroup() { + void testPdpSimulatorParameterGroup() { final PdpSimulatorParameterGroup pdpSimulatorParameters = commonTestData.toObject( commonTestData.getPdpSimulatorParameterGroupMap(CommonTestData.PDP_SIMULATOR_GROUP_NAME), PdpSimulatorParameterGroup.class); @@ -64,7 +65,7 @@ public class TestPdpSimulatorParameterGroup { } @Test - public void testPdpSimulatorParameterGroup_NullName() { + void testPdpSimulatorParameterGroup_NullName() { final PdpSimulatorParameterGroup pdpSimulatorParameters = commonTestData .toObject(commonTestData.getPdpSimulatorParameterGroupMap(null), PdpSimulatorParameterGroup.class); final ValidationResult validationResult = pdpSimulatorParameters.validate(); @@ -74,7 +75,7 @@ public class TestPdpSimulatorParameterGroup { } @Test - public void testPdpSimulatorParameterGroup_EmptyName() { + void testPdpSimulatorParameterGroup_EmptyName() { final PdpSimulatorParameterGroup pdpSimulatorParameters = commonTestData .toObject(commonTestData.getPdpSimulatorParameterGroupMap(""), PdpSimulatorParameterGroup.class); final ValidationResult validationResult = pdpSimulatorParameters.validate(); @@ -85,7 +86,7 @@ public class TestPdpSimulatorParameterGroup { } @Test - public void testPdpSimulatorParameterGroup_SetName() { + void testPdpSimulatorParameterGroup_SetName() { final PdpSimulatorParameterGroup pdpSimulatorParameters = commonTestData.toObject( commonTestData.getPdpSimulatorParameterGroupMap(CommonTestData.PDP_SIMULATOR_GROUP_NAME), PdpSimulatorParameterGroup.class); @@ -96,7 +97,7 @@ public class TestPdpSimulatorParameterGroup { } @Test - public void testPdpSimulatorParameterGroup_EmptyPdpStatusParameters() { + void testPdpSimulatorParameterGroup_EmptyPdpStatusParameters() { final Map<String, Object> map = commonTestData.getPdpSimulatorParameterGroupMap(CommonTestData.PDP_SIMULATOR_GROUP_NAME); map.put("pdpStatusParameters", commonTestData.getPdpStatusParametersMap(true)); @@ -109,7 +110,7 @@ public class TestPdpSimulatorParameterGroup { } @Test - public void testApexStarterParameterGroupp_EmptyTopicParameters() { + void testApexStarterParameterGroupp_EmptyTopicParameters() { final Map<String, Object> map = commonTestData.getPdpSimulatorParameterGroupMap(CommonTestData.PDP_SIMULATOR_GROUP_NAME); map.put("topicParameterGroup", commonTestData.getTopicParametersMap(true)); diff --git a/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/parameters/TestPdpSimulatorParameterHandler.java b/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/parameters/TestPdpSimulatorParameterHandler.java index 84c7b0d5f..41d5e8662 100644 --- a/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/parameters/TestPdpSimulatorParameterHandler.java +++ b/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/parameters/TestPdpSimulatorParameterHandler.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2019-2021, 2024 Nordix Foundation. * Modifications Copyright (C) 2019, 2021 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. @@ -22,12 +23,12 @@ package org.onap.policy.models.sim.pdp.parameters; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.io.FileNotFoundException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.common.utils.cmd.CommandLineException; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.models.sim.pdp.PdpSimulatorCommandLineArguments; @@ -38,10 +39,10 @@ import org.onap.policy.models.sim.pdp.exception.PdpSimulatorException; * * @author Ajith Sreekumar (ajith.sreekumar@est.tech) */ -public class TestPdpSimulatorParameterHandler { +class TestPdpSimulatorParameterHandler { @Test - public void testParameterHandlerNoParameterFile() throws CommandLineException { + void testParameterHandlerNoParameterFile() throws CommandLineException { final String[] emptyArgumentString = { "-c", "src/test/resources/NoParametersFile.json" }; final PdpSimulatorCommandLineArguments emptyArguments = new PdpSimulatorCommandLineArguments(); @@ -57,7 +58,7 @@ public class TestPdpSimulatorParameterHandler { } @Test - public void testParameterHandlerEmptyParameters() throws CommandLineException { + void testParameterHandlerEmptyParameters() throws CommandLineException { final String[] noArgumentString = { "-c", "src/test/resources/NoParameters.json" }; final PdpSimulatorCommandLineArguments noArguments = new PdpSimulatorCommandLineArguments(); @@ -68,7 +69,7 @@ public class TestPdpSimulatorParameterHandler { } @Test - public void testParameterHandlerInvalidParameters() throws CommandLineException { + void testParameterHandlerInvalidParameters() throws CommandLineException { final String[] invalidArgumentString = { "-c", "src/test/resources/InvalidParameters.json" }; final PdpSimulatorCommandLineArguments invalidArguments = new PdpSimulatorCommandLineArguments(); @@ -80,7 +81,7 @@ public class TestPdpSimulatorParameterHandler { } @Test - public void testParameterHandlerNoParameters() throws CommandLineException { + void testParameterHandlerNoParameters() throws CommandLineException { final String[] noArgumentString = { "-c", "src/test/resources/EmptyConfigParameters.json" }; final PdpSimulatorCommandLineArguments noArguments = new PdpSimulatorCommandLineArguments(); @@ -91,7 +92,7 @@ public class TestPdpSimulatorParameterHandler { } @Test - public void testPdpSimulatorParameterGroup() throws PdpSimulatorException, CommandLineException { + void testPdpSimulatorParameterGroup() throws PdpSimulatorException, CommandLineException { final String[] pdpSimulatorConfigParameters = { "-c", "src/test/resources/PdpSimulatorConfigParameters.json" }; final PdpSimulatorCommandLineArguments arguments = new PdpSimulatorCommandLineArguments(); @@ -103,7 +104,7 @@ public class TestPdpSimulatorParameterHandler { } @Test - public void testPdpSimulatorParameterGroup_InvalidName() throws CommandLineException { + void testPdpSimulatorParameterGroup_InvalidName() throws CommandLineException { final String[] pdpSimulatorConfigParameters = {"-c", "src/test/resources/PdpSimulatorConfigParameters_InvalidName.json"}; @@ -115,7 +116,7 @@ public class TestPdpSimulatorParameterHandler { } @Test - public void testPdpSimulatorVersion() throws CommandLineException { + void testPdpSimulatorVersion() throws CommandLineException { final String[] pdpSimulatorConfigParameters = { "-v" }; final PdpSimulatorCommandLineArguments arguments = new PdpSimulatorCommandLineArguments(); final String version = arguments.parse(pdpSimulatorConfigParameters); @@ -123,7 +124,7 @@ public class TestPdpSimulatorParameterHandler { } @Test - public void testPdpSimulatorHelp() throws CommandLineException { + void testPdpSimulatorHelp() throws CommandLineException { final String[] pdpSimulatorConfigParameters = { "-h" }; final PdpSimulatorCommandLineArguments arguments = new PdpSimulatorCommandLineArguments(); final String help = arguments.parse(pdpSimulatorConfigParameters); @@ -131,7 +132,7 @@ public class TestPdpSimulatorParameterHandler { } @Test - public void testPdpSimulatorInvalidOption() { + void testPdpSimulatorInvalidOption() { final String[] pdpSimulatorConfigParameters = { "-d" }; final PdpSimulatorCommandLineArguments arguments = new PdpSimulatorCommandLineArguments(); @@ -140,7 +141,7 @@ public class TestPdpSimulatorParameterHandler { } @Test - public void testPdpSimulatorProperty() throws CommandLineException { + void testPdpSimulatorProperty() throws CommandLineException { final String[] pdpSimulatorConfigParameters = { "-p", "dummyProperties.json" }; final PdpSimulatorCommandLineArguments arguments = new PdpSimulatorCommandLineArguments(); arguments.parse(pdpSimulatorConfigParameters); diff --git a/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/parameters/TestPdpStatusParameters.java b/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/parameters/TestPdpStatusParameters.java index 09ad29547..5adbec109 100644 --- a/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/parameters/TestPdpStatusParameters.java +++ b/models-sim/policy-models-sim-pdp/src/test/java/org/onap/policy/models/sim/pdp/parameters/TestPdpStatusParameters.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2019 Nordix Foundation. * Modifications Copyright (C) 2019, 2021 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. @@ -21,11 +22,11 @@ package org.onap.policy.models.sim.pdp.parameters; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.common.parameters.ValidationResult; /** @@ -33,11 +34,11 @@ import org.onap.policy.common.parameters.ValidationResult; * * @author Ajith Sreekumar (ajith.sreekumar@est.tech) */ -public class TestPdpStatusParameters { +class TestPdpStatusParameters { private static CommonTestData testData = new CommonTestData(); @Test - public void test() { + void test() { final PdpStatusParameters pdpStatusParameters = testData.toObject(testData.getPdpStatusParametersMap(false), PdpStatusParameters.class); final ValidationResult validationResult = pdpStatusParameters.validate(); @@ -50,7 +51,7 @@ public class TestPdpStatusParameters { } @Test - public void testValidate() { + void testValidate() { final PdpStatusParameters pdpStatusParameters = testData.toObject(testData.getPdpStatusParametersMap(false), PdpStatusParameters.class); final ValidationResult result = pdpStatusParameters.validate(); diff --git a/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/CdsServerParametersTest.java b/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/CdsServerParametersTest.java index 7b0ab6bbe..03442b968 100644 --- a/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/CdsServerParametersTest.java +++ b/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/CdsServerParametersTest.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2020 Bell Canada. * Modifications Copyright (C) 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. @@ -19,19 +20,19 @@ package org.onap.policy.models.simulators; -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.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.File; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.common.parameters.ValidationResult; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; -public class CdsServerParametersTest { +class CdsServerParametersTest { @Test - public void testValidateString() throws CoderException { + void testValidateString() throws CoderException { // some fields missing ValidationResult result = new CdsServerParameters().validate(); assertFalse(result.isValid()); diff --git a/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/ClassRestServerParametersTest.java b/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/ClassRestServerParametersTest.java index 0560e851c..77f694233 100644 --- a/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/ClassRestServerParametersTest.java +++ b/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/ClassRestServerParametersTest.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2020-2021 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,20 +21,20 @@ package org.onap.policy.models.simulators; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; import java.io.File; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.common.parameters.ValidationResult; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; -public class ClassRestServerParametersTest { +class ClassRestServerParametersTest { @Test - public void testValidateString() throws CoderException { + void testValidateString() throws CoderException { // some fields missing ValidationResult result = new ClassRestServerParameters().validate(); assertFalse(result.isValid()); diff --git a/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/MainTest.java b/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/MainTest.java index 09064f472..67cd7d800 100644 --- a/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/MainTest.java +++ b/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/MainTest.java @@ -24,9 +24,9 @@ package org.onap.policy.models.simulators; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -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.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -41,10 +41,10 @@ import java.util.Map.Entry; import java.util.Properties; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.TimeUnit; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams; import org.onap.policy.common.endpoints.http.client.HttpClient; import org.onap.policy.common.endpoints.http.client.HttpClientConfigException; @@ -56,7 +56,7 @@ import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.network.NetworkUtil; import org.onap.policy.common.utils.security.SelfSignedKeyStore; -public class MainTest { +class MainTest { private static final String PARAMETER_FILE = "simParameters.json"; private static final String HOST = "localhost"; private static final String EXPECTED_EXCEPTION = "expected exception"; @@ -66,7 +66,7 @@ public class MainTest { /** * Saves system properties. */ - @BeforeClass + @BeforeAll public static void setUpBeforeClass() throws IOException, InterruptedException { savedValues = new HashMap<>(); @@ -91,7 +91,7 @@ public class MainTest { /** * Restores system properties. */ - @AfterClass + @AfterAll public static void tearDownAfterClass() { for (Entry<String, String> ent : savedValues.entrySet()) { if (ent.getValue() == null) { @@ -105,8 +105,8 @@ public class MainTest { /** * Shuts down the simulator instance. */ - @After - public void tearDown() { + @AfterEach + void tearDown() { Main main = Main.getInstance(); if (main != null && main.isAlive()) { main.shutdown(); @@ -118,7 +118,7 @@ public class MainTest { * least one of them. */ @Test - public void testMain() throws Exception { + void testMain() throws Exception { Main.main(new String[0]); assertTrue(Main.getInstance() == null || !Main.getInstance().isAlive()); @@ -126,7 +126,7 @@ public class MainTest { // don't need to wait long, because buildXxx() does the wait for us for (int port : new int[] {6666, 6667, 6668, 6669, 6670, 6680}) { - assertTrue("simulator on port " + port, NetworkUtil.isTcpPortOpen(HOST, port, 1, 100)); + assertTrue(NetworkUtil.isTcpPortOpen(HOST, port, 1, 100), "simulator on port " + port); } // it's sufficient to verify that one of the simulators works @@ -134,7 +134,7 @@ public class MainTest { } @Test - public void testMainMinimalParameters() { + void testMainMinimalParameters() { Main.main(new String[] {"minParameters.json"}); assertNotNull(Main.getInstance()); assertTrue(Main.getInstance().isAlive()); @@ -156,7 +156,7 @@ public class MainTest { * Tests readParameters() when the file cannot be found. */ @Test - public void testReadParametersNoFile() { + void testReadParametersNoFile() { assertThatIllegalArgumentException().isThrownBy(() -> new Main("missing-file.json")) .withCauseInstanceOf(FileNotFoundException.class); } @@ -165,7 +165,7 @@ public class MainTest { * Tests readParameters() when the json cannot be decoded. */ @Test - public void testReadParametersInvalidJson() throws CoderException { + void testReadParametersInvalidJson() throws CoderException { Coder coder = mock(Coder.class); when(coder.decode(any(String.class), any())).thenThrow(new CoderException(EXPECTED_EXCEPTION)); @@ -181,7 +181,7 @@ public class MainTest { * Tests buildRestServer() when the server port is not open. */ @Test - public void testBuildRestServerNotOpen() { + void testBuildRestServerNotOpen() { HttpServletServer server = mock(HttpServletServer.class); Main main = new Main(PARAMETER_FILE) { @@ -203,7 +203,7 @@ public class MainTest { * Tests buildRestServer() when the port checker is interrupted. */ @Test - public void testBuildRestServerInterrupted() throws InterruptedException { + void testBuildRestServerInterrupted() throws InterruptedException { HttpServletServer server = mock(HttpServletServer.class); Main main = new Main(PARAMETER_FILE) { |