diff options
author | adheli.tavares <adheli.tavares@est.tech> | 2024-06-18 09:52:22 +0100 |
---|---|---|
committer | adheli.tavares <adheli.tavares@est.tech> | 2024-06-18 10:02:26 +0100 |
commit | feca4bf2915858cef4f82c9822104a7b85732d2c (patch) | |
tree | 37c1ec6843548d2cc7643ab119d564cd9c26994b /testsuites/integration/integration-executor-test/src/test/java | |
parent | e9b746340711ddfccee7ac0f669ace626b1b3d46 (diff) |
Convert junit4 to junit5
- testsuites module
Issue-ID: POLICY-5041
Change-Id: I1d9984651f34f1dca253094c26da1dd593128966
Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'testsuites/integration/integration-executor-test/src/test/java')
14 files changed, 158 insertions, 211 deletions
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexActionListener.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexActionListener.java index da9036103..67c86090f 100644 --- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexActionListener.java +++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexActionListener.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. * 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. @@ -41,7 +42,7 @@ import org.slf4j.ext.XLoggerFactory; public class TestApexActionListener implements EnEventListener { private static final XLogger logger = XLoggerFactory.getXLogger(TestApexActionListener.class); - private List<EnEvent> resultEvents = new ArrayList<>(); + private final List<EnEvent> resultEvents = new ArrayList<>(); @Getter private final String id; @@ -64,15 +65,12 @@ public class TestApexActionListener implements EnEventListener { */ public EnEvent getResult(final boolean allowNulls) { EnEvent result = null; - while (true) { + do { while (resultEvents.isEmpty()) { ThreadUtilities.sleep(100); } result = resultEvents.remove(0); - if (result != null || allowNulls) { - break; - } - } + } while (result == null && !allowNulls); return result; } diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngine.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngine.java index b9bfcaa4d..24cf4944b 100644 --- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngine.java +++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngine.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019-2020 Nordix Foundation. + * Modifications Copyright (C) 2019-2020, 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. @@ -26,12 +26,10 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import java.io.IOException; import java.util.Date; import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit; -import org.onap.policy.apex.core.engine.EngineParameters; import org.onap.policy.apex.core.engine.engine.ApexEngine; import org.onap.policy.apex.core.engine.engine.impl.ApexEngineFactory; import org.onap.policy.apex.core.engine.event.EnEvent; @@ -53,12 +51,9 @@ public class TestApexEngine { * * @param axLogicExecutorType the type of logic executor to use to construct the sample policy model for this test * @throws ApexException the apex exception - * @throws InterruptedException the interrupted exception - * @throws IOException Signals that an I/O exception has occurred. */ - public TestApexEngine(final String axLogicExecutorType, - final EngineParameters parameters) throws ApexException, InterruptedException, IOException { - logger.debug("Running TestApexEngine test for + " + axLogicExecutorType + "logic . . ."); + public TestApexEngine(final String axLogicExecutorType) throws ApexException { + logger.debug("Running TestApexEngine test for + {}logic . . .", axLogicExecutorType); final AxPolicyModel apexPolicyModel = new SampleDomainModelFactory().getSamplePolicyModel(axLogicExecutorType); assertNotNull(apexPolicyModel); diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJRuby.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJRuby.java index f69893487..68455897c 100644 --- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJRuby.java +++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJRuby.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2020 Nordix Foundation. + * Modifications Copyright (C) 2020, 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. @@ -23,23 +23,21 @@ package org.onap.policy.apex.testsuites.integration.executor.engine; import static org.assertj.core.api.Assertions.assertThatCode; -import java.io.IOException; -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.apex.context.impl.schema.java.JavaSchemaHelperParameters; import org.onap.policy.apex.context.parameters.ContextParameterConstants; import org.onap.policy.apex.context.parameters.ContextParameters; import org.onap.policy.apex.context.parameters.SchemaParameters; import org.onap.policy.apex.core.engine.EngineParameters; -import org.onap.policy.apex.model.basicmodel.concepts.ApexException; import org.onap.policy.apex.plugins.executor.jruby.JrubyExecutorParameters; import org.onap.policy.common.parameters.ParameterService; /** * The Class TestApexEngineJRuby. */ -public class TestApexEngineJRuby { +class TestApexEngineJRuby { private SchemaParameters schemaParameters; private ContextParameters contextParameters; private EngineParameters engineParameters; @@ -47,8 +45,8 @@ public class TestApexEngineJRuby { /** * Before test. */ - @Before - public void beforeTest() { + @BeforeEach + void beforeTest() { schemaParameters = new SchemaParameters(); schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME); @@ -76,8 +74,8 @@ public class TestApexEngineJRuby { /** * After test. */ - @After - public void afterTest() { + @AfterEach + void afterTest() { ParameterService.deregister(engineParameters); ParameterService.deregister(contextParameters.getDistributorParameters()); @@ -90,15 +88,9 @@ public class TestApexEngineJRuby { /** * Test apex engine. - * - * @throws ApexException the apex exception - * @throws InterruptedException the interrupted exception - * @throws IOException Signals that an I/O exception has occurred. */ @Test - public void testApexEngineJRuby() throws ApexException, InterruptedException, IOException { - assertThatCode(() -> { - new TestApexEngine("JRUBY", engineParameters); - }).doesNotThrowAnyException(); + void testApexEngineJRuby() { + assertThatCode(() -> new TestApexEngine("JRUBY")).doesNotThrowAnyException(); } } diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJava.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJava.java index 937a89d9d..571b6bd37 100644 --- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJava.java +++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJava.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2020 Nordix Foundation. + * Modifications Copyright (C) 2020, 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. @@ -23,16 +23,14 @@ package org.onap.policy.apex.testsuites.integration.executor.engine; import static org.assertj.core.api.Assertions.assertThatCode; -import java.io.IOException; -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.apex.context.impl.schema.java.JavaSchemaHelperParameters; import org.onap.policy.apex.context.parameters.ContextParameterConstants; import org.onap.policy.apex.context.parameters.ContextParameters; import org.onap.policy.apex.context.parameters.SchemaParameters; import org.onap.policy.apex.core.engine.EngineParameters; -import org.onap.policy.apex.model.basicmodel.concepts.ApexException; import org.onap.policy.apex.plugins.executor.java.JavaExecutorParameters; import org.onap.policy.common.parameters.ParameterService; @@ -41,7 +39,7 @@ import org.onap.policy.common.parameters.ParameterService; * * @author Liam Fallon (liam.fallon@ericsson.com) */ -public class TestApexEngineJava { +class TestApexEngineJava { private SchemaParameters schemaParameters; private ContextParameters contextParameters; private EngineParameters engineParameters; @@ -49,8 +47,8 @@ public class TestApexEngineJava { /** * Before test. */ - @Before - public void beforeTest() { + @BeforeEach + void beforeTest() { schemaParameters = new SchemaParameters(); schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME); @@ -78,8 +76,8 @@ public class TestApexEngineJava { /** * After test. */ - @After - public void afterTest() { + @AfterEach + void afterTest() { ParameterService.deregister(engineParameters); ParameterService.deregister(contextParameters.getDistributorParameters()); @@ -92,16 +90,12 @@ public class TestApexEngineJava { /** * Test apex engine. - * - * @throws InterruptedException the interrupted exception - * @throws IOException Signals that an I/O exception has occurred. - * @throws ApexException the apex exception */ @Test - public void testApexEngineJava() { + void testApexEngineJava() { assertThatCode(() -> { - new TestApexEngine("JAVA", engineParameters); - new TestApexEngine("JAVA", engineParameters); + new TestApexEngine("JAVA"); + new TestApexEngine("JAVA"); }).doesNotThrowAnyException(); } } diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJavascript.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJavascript.java index 108416bca..d5b4fd147 100644 --- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJavascript.java +++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJavascript.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2020 Nordix Foundation. + * Modifications Copyright (C) 2020, 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. @@ -23,23 +23,21 @@ package org.onap.policy.apex.testsuites.integration.executor.engine; import static org.assertj.core.api.Assertions.assertThatCode; -import java.io.IOException; -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.apex.context.impl.schema.java.JavaSchemaHelperParameters; import org.onap.policy.apex.context.parameters.ContextParameterConstants; import org.onap.policy.apex.context.parameters.ContextParameters; import org.onap.policy.apex.context.parameters.SchemaParameters; import org.onap.policy.apex.core.engine.EngineParameters; -import org.onap.policy.apex.model.basicmodel.concepts.ApexException; import org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters; import org.onap.policy.common.parameters.ParameterService; /** * The Class TestApexEngineJavascript. */ -public class TestApexEngineJavascript { +class TestApexEngineJavascript { private SchemaParameters schemaParameters; private ContextParameters contextParameters; private EngineParameters engineParameters; @@ -47,8 +45,8 @@ public class TestApexEngineJavascript { /** * Before test. */ - @Before - public void beforeTest() { + @BeforeEach + void beforeTest() { schemaParameters = new SchemaParameters(); schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME); @@ -76,8 +74,8 @@ public class TestApexEngineJavascript { /** * After test. */ - @After - public void afterTest() { + @AfterEach + void afterTest() { ParameterService.deregister(engineParameters); ParameterService.deregister(contextParameters.getDistributorParameters()); @@ -91,15 +89,12 @@ public class TestApexEngineJavascript { /** * Test apex engine. * - * @throws ApexException the apex exception - * @throws InterruptedException the interrupted exception - * @throws IOException Signals that an I/O exception has occurred. */ @Test - public void testApexEngineJavascript() throws ApexException, InterruptedException, IOException { + void testApexEngineJavascript() { assertThatCode(() -> { - new TestApexEngine("JAVASCRIPT", engineParameters); - new TestApexEngine("JAVASCRIPT", engineParameters); + new TestApexEngine("JAVASCRIPT"); + new TestApexEngine("JAVASCRIPT"); }).doesNotThrowAnyException(); } } diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJython.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJython.java index 76b3835a1..9359900f6 100644 --- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJython.java +++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineJython.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2020 Nordix Foundation. + * Modifications Copyright (C) 2020, 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. @@ -23,16 +23,14 @@ package org.onap.policy.apex.testsuites.integration.executor.engine; import static org.assertj.core.api.Assertions.assertThatCode; -import java.io.IOException; -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.apex.context.impl.schema.java.JavaSchemaHelperParameters; import org.onap.policy.apex.context.parameters.ContextParameterConstants; import org.onap.policy.apex.context.parameters.ContextParameters; import org.onap.policy.apex.context.parameters.SchemaParameters; import org.onap.policy.apex.core.engine.EngineParameters; -import org.onap.policy.apex.model.basicmodel.concepts.ApexException; import org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters; import org.onap.policy.common.parameters.ParameterService; @@ -40,9 +38,8 @@ import org.onap.policy.common.parameters.ParameterService; * The Class TestApexEngineJython should be the test class for the Jython interpreter. * * <p>It actually reruns the javascript tests as a placeholder until the Jython security issues are resolved. - * */ -public class TestApexEngineJython { +class TestApexEngineJython { private SchemaParameters schemaParameters; private ContextParameters contextParameters; private EngineParameters engineParameters; @@ -50,8 +47,8 @@ public class TestApexEngineJython { /** * Before test. */ - @Before - public void beforeTest() { + @BeforeEach + void beforeTest() { schemaParameters = new SchemaParameters(); schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME); @@ -79,8 +76,8 @@ public class TestApexEngineJython { /** * After test. */ - @After - public void afterTest() { + @AfterEach + void afterTest() { ParameterService.deregister(engineParameters); ParameterService.deregister(contextParameters.getDistributorParameters()); @@ -93,16 +90,12 @@ public class TestApexEngineJython { /** * Test apex engine. - * - * @throws ApexException the apex exception - * @throws InterruptedException the interrupted exception - * @throws IOException Signals that an I/O exception has occurred. */ @Test - public void testApexEngineJython() throws ApexException, InterruptedException, IOException { + void testApexEngineJython() { assertThatCode(() -> { - new TestApexEngine("JAVASCRIPT", engineParameters); - new TestApexEngine("JAVASCRIPT", engineParameters); + new TestApexEngine("JAVASCRIPT"); + new TestApexEngine("JAVASCRIPT"); }).doesNotThrowAnyException(); } } diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineMvel.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineMvel.java index 499dc59d9..c0ee1425c 100644 --- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineMvel.java +++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/engine/TestApexEngineMvel.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2020 Nordix Foundation. + * Modifications Copyright (C) 2020, 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. @@ -23,23 +23,21 @@ package org.onap.policy.apex.testsuites.integration.executor.engine; import static org.assertj.core.api.Assertions.assertThatCode; -import java.io.IOException; -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.apex.context.impl.schema.java.JavaSchemaHelperParameters; import org.onap.policy.apex.context.parameters.ContextParameterConstants; import org.onap.policy.apex.context.parameters.ContextParameters; import org.onap.policy.apex.context.parameters.SchemaParameters; import org.onap.policy.apex.core.engine.EngineParameters; -import org.onap.policy.apex.model.basicmodel.concepts.ApexException; import org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters; import org.onap.policy.common.parameters.ParameterService; /** * The Class TestApexEngineMvel. */ -public class TestApexEngineMvel { +class TestApexEngineMvel { private SchemaParameters schemaParameters; private ContextParameters contextParameters; private EngineParameters engineParameters; @@ -47,8 +45,8 @@ public class TestApexEngineMvel { /** * Before test. */ - @Before - public void beforeTest() { + @BeforeEach + void beforeTest() { schemaParameters = new SchemaParameters(); schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME); @@ -76,8 +74,8 @@ public class TestApexEngineMvel { /** * After test. */ - @After - public void afterTest() { + @AfterEach + void afterTest() { ParameterService.deregister(engineParameters); ParameterService.deregister(contextParameters.getDistributorParameters()); @@ -90,16 +88,12 @@ public class TestApexEngineMvel { /** * Test apex engine. - * - * @throws ApexException the apex exception - * @throws InterruptedException the interrupted exception - * @throws IOException Signals that an I/O exception has occurred. */ @Test - public void testApexEngineMvel() throws ApexException, InterruptedException, IOException { + void testApexEngineMvel() { assertThatCode(() -> { - new TestApexEngine("MVEL", engineParameters); - new TestApexEngine("MVEL", engineParameters); + new TestApexEngine("MVEL"); + new TestApexEngine("MVEL"); }).doesNotThrowAnyException(); } } diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/event/TestEventInstantiation.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/event/TestEventInstantiation.java index 75000883d..7f9a4326f 100644 --- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/event/TestEventInstantiation.java +++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/event/TestEventInstantiation.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019-2020 Nordix Foundation. + * Modifications Copyright (C) 2019-2020, 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,17 +22,16 @@ package org.onap.policy.apex.testsuites.integration.executor.event; 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.assertNull; +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.util.Date; import java.util.HashMap; 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.apex.context.impl.schema.java.JavaSchemaHelperParameters; import org.onap.policy.apex.context.parameters.ContextParameterConstants; import org.onap.policy.apex.context.parameters.ContextParameters; @@ -43,7 +42,6 @@ import org.onap.policy.apex.core.engine.engine.impl.ApexEngineFactory; import org.onap.policy.apex.core.engine.event.EnEvent; import org.onap.policy.apex.model.basicmodel.concepts.ApexException; import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; -import org.onap.policy.apex.model.basicmodel.handling.ApexModelException; import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; import org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters; import org.onap.policy.apex.testsuites.integration.common.model.SampleDomainModelFactory; @@ -56,7 +54,7 @@ import org.slf4j.ext.XLoggerFactory; * * @author Liam Fallon (liam.fallon@ericsson.com) */ -public class TestEventInstantiation { +class TestEventInstantiation { // Logger for this class private static final XLogger logger = XLoggerFactory.getXLogger(TestEventInstantiation.class); @@ -67,8 +65,8 @@ public class TestEventInstantiation { /** * Before test. */ - @Before - public void beforeTest() { + @BeforeEach + void beforeTest() { schemaParameters = new SchemaParameters(); schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME); @@ -96,8 +94,8 @@ public class TestEventInstantiation { /** * After test. */ - @After - public void afterTest() { + @AfterEach + void afterTest() { ParameterService.deregister(engineParameters); ParameterService.deregister(contextParameters.getDistributorParameters()); @@ -111,12 +109,10 @@ public class TestEventInstantiation { /** * Test event instantiation. * - * @throws ApexModelException on errors in handling Apex models - * @throws IOException Signals that an I/O exception has occurred. * @throws ApexException the apex exception */ @Test - public void testEventInstantiation() throws ApexModelException, IOException, ApexException { + void testEventInstantiation() throws ApexException { final String xmlFileName = "xml/ApexModel_MVEL.xml"; logger.debug("Running TestEventInstantiation test on file {} . . .", xmlFileName); @@ -164,14 +160,14 @@ public class TestEventInstantiation { assertEquals(temperature, temp1); Object value = event.put("TestMatchCase", null); + assert value != null; assertEquals(16, ((Byte) value).intValue()); value = event.get("TestMatchCase"); assertNull(value); assertThatThrownBy(() -> event.put("TestMatchCase", "Hello")) .hasMessage("Event0000:0.0.1:NULL:TestMatchCase: object \"Hello\" of class \"java.lang.String\" " - + "not compatible with class \"java.lang.Byte\""); - event.put("TestMatchCase", 123.45); + + "not compatible with class \"java.lang.Byte\""); event.put("TestMatchCase", Byte.valueOf("16")); @@ -196,7 +192,7 @@ public class TestEventInstantiation { assertEquals(123.456789, temp3, 0); final Date aDate = new Date(1433453067123L); - final Map<String, Object> eventDataList = new HashMap<String, Object>(); + final Map<String, Object> eventDataList = new HashMap<>(); eventDataList.put("TestSlogan", "This is a test slogan"); eventDataList.put("TestMatchCase", Byte.valueOf("123")); eventDataList.put("TestTimestamp", aDate.getTime()); diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexModelExport.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexModelExport.java index dc5c06f85..eb4d00f06 100644 --- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexModelExport.java +++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexModelExport.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2020 Nordix Foundation + * Modifications Copyright (C) 2020, 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,15 +21,14 @@ package org.onap.policy.apex.testsuites.integration.executor.handling; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import java.util.ArrayList; import java.util.List; -import org.junit.Before; -import org.junit.Test; -import org.onap.policy.apex.model.basicmodel.concepts.ApexException; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; import org.onap.policy.apex.model.policymodel.handling.PolicyModelSplitter; @@ -41,22 +40,21 @@ import org.slf4j.ext.XLoggerFactory; * * @author Liam Fallon (liam.fallon@ericsson.com) */ -public class TestApexModelExport { +class TestApexModelExport { private static final XLogger logger = XLoggerFactory.getXLogger(TestApexModelExport.class); private AxPolicyModel model = null; - @Before - public void initApexModelSmall() throws ApexException { + @BeforeEach + void initApexModelSmall() { model = new TestApexSamplePolicyModelCreator("MVEL").getModel(); } @Test - public void testApexModelExport() throws Exception { + void testApexModelExport() throws Exception { logger.info("Starting test: testApexModelExport"); - final List<AxArtifactKey> exportPolicyList = new ArrayList<AxArtifactKey>(); - exportPolicyList.addAll(model.getPolicies().getPolicyMap().keySet()); + final List<AxArtifactKey> exportPolicyList = new ArrayList<>(model.getPolicies().getPolicyMap().keySet()); final AxPolicyModel exportedModel0 = PolicyModelSplitter.getSubPolicyModel(model, exportPolicyList); diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexPolicyModelAnalysis.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexPolicyModelAnalysis.java index abcd22a47..ae8bc90d6 100644 --- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexPolicyModelAnalysis.java +++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexPolicyModelAnalysis.java @@ -1,35 +1,37 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. 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. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ package org.onap.policy.apex.testsuites.integration.executor.handling; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotNull; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; import org.onap.policy.apex.model.policymodel.handling.PolicyAnalyser; import org.onap.policy.apex.model.policymodel.handling.PolicyAnalysisResult; -public class TestApexPolicyModelAnalysis { +class TestApexPolicyModelAnalysis { + @Test - public void testApexPolicyModelAnalysis() throws Exception { + void testApexPolicyModelAnalysis() { final AxPolicyModel model = new TestApexSamplePolicyModelCreator("MVEL").getModel(); final PolicyAnalysisResult result = new PolicyAnalyser().analyse(model); diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexSamplePolicyCreateModelFiles.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexSamplePolicyCreateModelFiles.java index 2cc7a791f..1522ff90a 100644 --- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexSamplePolicyCreateModelFiles.java +++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexSamplePolicyCreateModelFiles.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2022 Nordix Foundation. + * Modifications Copyright (C) 2022, 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,19 +24,19 @@ package org.onap.policy.apex.testsuites.integration.executor.handling; import static org.assertj.core.api.Assertions.assertThatCode; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.apex.model.basicmodel.test.TestApexModel; import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; -public class TestApexSamplePolicyCreateModelFiles { +class TestApexSamplePolicyCreateModelFiles { @Test - public void testModelWriteRead() throws Exception { + void testModelWriteRead() { String[] types = {"JAVA", "JAVASCRIPT", "JRUBY", "JYTHON", "MVEL"}; for (String type: types) { final TestApexSamplePolicyModelCreator apexPolicyModelCreator = new TestApexSamplePolicyModelCreator(type); final TestApexModel<AxPolicyModel> testApexPolicyModel = new TestApexModel<AxPolicyModel>(AxPolicyModel.class, apexPolicyModelCreator); - assertThatCode(() -> testApexPolicyModel.testApexModelWriteReadJson()).doesNotThrowAnyException(); + assertThatCode(testApexPolicyModel::testApexModelWriteReadJson).doesNotThrowAnyException(); } } } diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexSamplePolicyModel.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexSamplePolicyModel.java index 3cb7369fb..e1a16c586 100644 --- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexSamplePolicyModel.java +++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexSamplePolicyModel.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2020,2022 Nordix Foundation. + * Modifications Copyright (C) 2020, 2022, 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,10 +21,10 @@ package org.onap.policy.apex.testsuites.integration.executor.handling; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; import org.onap.policy.apex.model.basicmodel.test.TestApexModel; import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; @@ -32,19 +32,18 @@ import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; /** * The Class TestApexSamplePolicyModel. */ -public class TestApexSamplePolicyModel { +class TestApexSamplePolicyModel { private static final String VALID_MODEL_STRING = "***validation of model successful***"; private TestApexModel<AxPolicyModel> testApexModel; /** * Setup. * - * @throws Exception the exception */ - @Before - public void setup() throws Exception { + @BeforeEach + void setup() { testApexModel = - new TestApexModel<AxPolicyModel>(AxPolicyModel.class, new TestApexSamplePolicyModelCreator("MVEL")); + new TestApexModel<>(AxPolicyModel.class, new TestApexSamplePolicyModelCreator("MVEL")); } /** @@ -53,7 +52,7 @@ public class TestApexSamplePolicyModel { * @throws Exception the exception */ @Test - public void testModelValid() throws Exception { + void testModelValid() throws Exception { final AxValidationResult result = testApexModel.testApexModelValid(); assertEquals(VALID_MODEL_STRING, result.toString()); } @@ -64,7 +63,7 @@ public class TestApexSamplePolicyModel { * @throws Exception the exception */ @Test - public void testModelWriteReadJson() throws Exception { + void testModelWriteReadJson() throws Exception { testApexModel.testApexModelWriteReadJson(); } } diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestContextUpdateDifferentModels.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestContextUpdateDifferentModels.java index 0a4b9a7d5..7b4f04add 100644 --- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestContextUpdateDifferentModels.java +++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestContextUpdateDifferentModels.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019-2020 Nordix Foundation. + * Modifications Copyright (C) 2019-2020, 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,13 +22,12 @@ package org.onap.policy.apex.testsuites.integration.executor.handling; import static org.assertj.core.api.Assertions.assertThatThrownBy; -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 java.io.IOException; -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.apex.context.ContextAlbum; import org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters; import org.onap.policy.apex.context.parameters.ContextParameterConstants; @@ -52,7 +51,7 @@ import org.slf4j.ext.XLoggerFactory; * * @author Liam Fallon (liam.fallon@ericsson.com) */ -public class TestContextUpdateDifferentModels { +class TestContextUpdateDifferentModels { // Logger for this class private static final XLogger logger = XLoggerFactory.getXLogger(TestContextUpdateDifferentModels.class); @@ -63,8 +62,8 @@ public class TestContextUpdateDifferentModels { /** * Before test. */ - @Before - public void beforeTest() { + @BeforeEach + void beforeTest() { schemaParameters = new SchemaParameters(); schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME); @@ -92,8 +91,8 @@ public class TestContextUpdateDifferentModels { /** * After test. */ - @After - public void afterTest() { + @AfterEach + void afterTest() { ParameterService.deregister(engineParameters); ParameterService.deregister(contextParameters.getDistributorParameters()); @@ -107,19 +106,17 @@ public class TestContextUpdateDifferentModels { /** * Test context update different models. * - * @throws ApexException the apex exception - * @throws InterruptedException the interrupted exception - * @throws IOException Signals that an I/O exception has occurred. + * @throws ApexException the apex exception */ @Test - public void testContextUpdateDifferentModels() throws ApexException, InterruptedException, IOException { + void testContextUpdateDifferentModels() throws ApexException { logger.debug("Running test testContextUpdateDifferentModels . . ."); final AxPolicyModel apexModelSample = new SampleDomainModelFactory().getSamplePolicyModel("MVEL"); assertNotNull(apexModelSample); final ApexEngineImpl apexEngine = - (ApexEngineImpl) new ApexEngineFactory().createApexEngine(new AxArtifactKey("TestApexEngine", "0.0.1")); + (ApexEngineImpl) new ApexEngineFactory().createApexEngine(new AxArtifactKey("TestApexEngine", "0.0.1")); final TestApexActionListener listener = new TestApexActionListener("Test"); apexEngine.addEventListener("listener", listener); apexEngine.updateModel(apexModelSample, false); @@ -133,18 +130,17 @@ public class TestContextUpdateDifferentModels { assertThatThrownBy(() -> apexEngine.updateModel(null, false)) .hasMessage("updateModel()<-TestApexEngine:0.0.1, Apex model is not defined, it has a null value"); assertEquals(apexEngine.getInternalContext().getContextAlbums().size(), - apexModelSample.getAlbums().getAlbumsMap().size()); + apexModelSample.getAlbums().getAlbumsMap().size()); for (final ContextAlbum contextAlbum : apexEngine.getInternalContext().getContextAlbums().values()) { assertEquals( - contextAlbum.getAlbumDefinition(), apexModelSample.getAlbums().get(contextAlbum.getKey())); + contextAlbum.getAlbumDefinition(), apexModelSample.getAlbums().get(contextAlbum.getKey())); } apexEngine.updateModel(someSpuriousModel, false); assertEquals(apexEngine.getInternalContext().getContextAlbums().size(), - someSpuriousModel.getAlbums().getAlbumsMap().size()); + someSpuriousModel.getAlbums().getAlbumsMap().size()); for (final ContextAlbum contextAlbum : apexEngine.getInternalContext().getContextAlbums().values()) { - assertEquals( - contextAlbum.getAlbumDefinition(), someSpuriousModel.getAlbums().get(contextAlbum.getKey())); + assertEquals(contextAlbum.getAlbumDefinition(), someSpuriousModel.getAlbums().get(contextAlbum.getKey())); } apexEngine.clear(); diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestContextUpdateModel.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestContextUpdateModel.java index 21f129dde..5e2ccde90 100644 --- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestContextUpdateModel.java +++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestContextUpdateModel.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019-2020 Nordix Foundation. + * Modifications Copyright (C) 2019-2020, 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,18 +21,16 @@ package org.onap.policy.apex.testsuites.integration.executor.handling; -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 java.io.IOException; import java.util.Date; import java.util.HashMap; import java.util.Map; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.onap.policy.apex.context.ContextException; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters; import org.onap.policy.apex.context.parameters.ContextParameterConstants; import org.onap.policy.apex.context.parameters.ContextParameters; @@ -56,7 +54,7 @@ import org.slf4j.ext.XLoggerFactory; * * @author Liam Fallon (liam.fallon@ericsson.com) */ -public class TestContextUpdateModel { +class TestContextUpdateModel { // Logger for this class private static final XLogger logger = XLoggerFactory.getXLogger(TestContextUpdateModel.class); @@ -67,8 +65,8 @@ public class TestContextUpdateModel { /** * Before test. */ - @Before - public void beforeTest() { + @BeforeEach + void beforeTest() { schemaParameters = new SchemaParameters(); schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME); @@ -96,8 +94,8 @@ public class TestContextUpdateModel { /** * After test. */ - @After - public void afterTest() { + @AfterEach + void afterTest() { ParameterService.deregister(engineParameters); ParameterService.deregister(contextParameters.getDistributorParameters()); @@ -111,12 +109,10 @@ public class TestContextUpdateModel { /** * Test context update model. * - * @throws ApexException the apex exception - * @throws InterruptedException the interrupted exception - * @throws IOException Signals that an I/O exception has occurred. + * @throws ApexException the apex exception */ @Test - public void testContextUpdateModel() throws ApexException, InterruptedException, IOException { + void testContextUpdateModel() throws ApexException { final AxArtifactKey key = new AxArtifactKey("TestApexEngine", "0.0.1"); final ApexEngine apexEngine = new ApexEngineFactory().createApexEngine(key); @@ -168,8 +164,8 @@ public class TestContextUpdateModel { /** * Test context update model after. */ - @After - public void testContextUpdateModelAfter() { + @AfterEach + void testContextUpdateModelAfter() { // Not used } @@ -177,15 +173,14 @@ public class TestContextUpdateModel { * Send event. * * @param apexEngine the apex engine - * @param listener the listener - * @param eventName the event name + * @param listener the listener + * @param eventName the event name * @param shouldWork the should work - * @throws ContextException the context exception */ private void sendEvent(final ApexEngine apexEngine, final TestApexActionListener listener, final String eventName, - final boolean shouldWork) throws ContextException { + final boolean shouldWork) { final Date aDate = new Date(1433453067123L); - final Map<String, Object> eventDataMap = new HashMap<String, Object>(); + final Map<String, Object> eventDataMap = new HashMap<>(); eventDataMap.put("TestSlogan", "This is a test slogan"); eventDataMap.put("TestMatchCase", (byte) 123); eventDataMap.put("TestTimestamp", aDate.getTime()); @@ -196,15 +191,15 @@ public class TestContextUpdateModel { apexEngine.handleEvent(event0); final EnEvent result = listener.getResult(true); - logger.debug("result 1 is:" + result); + logger.debug("result 1 is:{}", result); checkResult(result, shouldWork); } /** * Check result. * - * @param result the result - * @param shouldWork the should work + * @param result the result + * @param shouldWork should trigger a valid result */ private void checkResult(final EnEvent result, final boolean shouldWork) { if (!shouldWork) { |