diff options
author | 2024-06-19 10:18:27 +0000 | |
---|---|---|
committer | 2024-06-19 10:18:27 +0000 | |
commit | 6040233dcbe4a64b977ee750c6d0d12b2d513c4c (patch) | |
tree | 09c82f5ad4dba38d1bf07a7fca007b93c3009dc1 /testsuites/integration/integration-common/src | |
parent | dcaba40dd105b2bcb12fa4b3a5931ee05572927c (diff) | |
parent | feca4bf2915858cef4f82c9822104a7b85732d2c (diff) |
Merge "Convert junit4 to junit5"
Diffstat (limited to 'testsuites/integration/integration-common/src')
4 files changed, 51 insertions, 50 deletions
diff --git a/testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/model/EvalDomainModelFactoryTest.java b/testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/model/EvalDomainModelFactoryTest.java index 5149c8675..8471a65c5 100644 --- a/testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/model/EvalDomainModelFactoryTest.java +++ b/testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/model/EvalDomainModelFactoryTest.java @@ -1,44 +1,45 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 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.common.model; -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 org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; /** * Test the evaluation domain model factory. */ -public class EvalDomainModelFactoryTest { +class EvalDomainModelFactoryTest { @Test - public void testEvalDomainModelFactory() { + void testEvalDomainModelFactory() { EvalDomainModelFactory edmf = new EvalDomainModelFactory(); assertNotNull(edmf); - + AxPolicyModel ecaPolicyModel = edmf.getEcaPolicyModel(); assertEquals("EvaluationPolicyModel_ECA:0.0.1", ecaPolicyModel.getId()); - + AxPolicyModel oodaPolicyModel = edmf.getOodaPolicyModel(); assertEquals("EvaluationPolicyModel_OODA:0.0.1", oodaPolicyModel.getId()); } diff --git a/testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/model/SampleDomainModelFactoryTest.java b/testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/model/SampleDomainModelFactoryTest.java index 406bec11f..01219fdd0 100644 --- a/testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/model/SampleDomainModelFactoryTest.java +++ b/testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/model/SampleDomainModelFactoryTest.java @@ -1,53 +1,54 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 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.common.model; -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 org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; /** * Test the evaluation domain model factory. */ -public class SampleDomainModelFactoryTest { +class SampleDomainModelFactoryTest { @Test - public void testSampleDomainModelFactory() { + void testSampleDomainModelFactory() { SampleDomainModelFactory sdmf = new SampleDomainModelFactory(); assertNotNull(sdmf); - + AxPolicyModel samplePolicyModel = sdmf.getSamplePolicyModel("JAVASCRIPT"); assertEquals("SamplePolicyModelJAVASCRIPT:0.0.1", samplePolicyModel.getId()); - + samplePolicyModel = sdmf.getSamplePolicyModel("JAVA"); assertEquals("SamplePolicyModelJAVA:0.0.1", samplePolicyModel.getId()); - + samplePolicyModel = sdmf.getSamplePolicyModel("JYTHON"); assertEquals("SamplePolicyModelJYTHON:0.0.1", samplePolicyModel.getId()); - + samplePolicyModel = sdmf.getSamplePolicyModel("JRUBY"); assertEquals("SamplePolicyModelJRUBY:0.0.1", samplePolicyModel.getId()); - + samplePolicyModel = sdmf.getSamplePolicyModel("MVEL"); assertEquals("SamplePolicyModelMVEL:0.0.1", samplePolicyModel.getId()); } diff --git a/testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/model/SampleDomainModelSaverTest.java b/testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/model/SampleDomainModelSaverTest.java index eaf223373..e266ee1ae 100644 --- a/testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/model/SampleDomainModelSaverTest.java +++ b/testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/model/SampleDomainModelSaverTest.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 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. @@ -22,24 +22,25 @@ package org.onap.policy.apex.testsuites.integration.common.model; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.util.Comparator; -import org.junit.Test; +import java.util.Objects; +import org.junit.jupiter.api.Test; import org.onap.policy.apex.model.basicmodel.concepts.ApexException; /** * Test the sample domain model saver. */ -public class SampleDomainModelSaverTest { +class SampleDomainModelSaverTest { @Test - public void testSampleDomainModelSaver() throws IOException, ApexException { + void testSampleDomainModelSaver() throws IOException, ApexException { assertThatThrownBy(() -> SampleDomainModelSaver.main(null)).isInstanceOf(NullPointerException.class); String[] args0 = @@ -55,7 +56,7 @@ public class SampleDomainModelSaverTest { File tempDir = new File(tempDirectory.toString()); assertTrue(tempDir.isDirectory()); - assertEquals(5, tempDir.listFiles().length); + assertEquals(5, Objects.requireNonNull(tempDir.listFiles()).length); Files.walk(tempDirectory).sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete); } diff --git a/testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/testclasses/TestPingClassTest.java b/testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/testclasses/TestPingClassTest.java index 92f86f434..ea8ec812d 100644 --- a/testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/testclasses/TestPingClassTest.java +++ b/testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/testclasses/TestPingClassTest.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 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. @@ -22,17 +22,17 @@ package org.onap.policy.apex.testsuites.integration.common.testclasses; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.apex.model.basicmodel.concepts.ApexException; /** * Test the ping test class. */ -public class TestPingClassTest { +class TestPingClassTest { @Test - public void testPingClass() throws ApexException { + void testPingClass() throws ApexException { PingTestClass ptc = new PingTestClass(); ptc.setName("Hello"); @@ -46,47 +46,45 @@ public class TestPingClassTest { ptc.setPongTime(-1); assertEquals(-1, ptc.getPongTime()); - assertThatThrownBy(() -> ptc.verify()).isInstanceOf(ApexException.class) + assertThatThrownBy(ptc::verify).isInstanceOf(ApexException.class) .hasMessageContaining("TestPing is not valid, name does not start with \"Rose\""); ptc.setName(null); - assertThatThrownBy(() -> ptc.verify()).isInstanceOf(ApexException.class) + assertThatThrownBy(ptc::verify).isInstanceOf(ApexException.class) .hasMessageContaining("TestPing is not valid, name length null or less than 4"); ptc.setName("Ros"); - assertThatThrownBy(() -> ptc.verify()).isInstanceOf(ApexException.class) + assertThatThrownBy(ptc::verify).isInstanceOf(ApexException.class) .hasMessageContaining("TestPing is not valid, name length null or less than 4"); ptc.setName("Rose"); - assertThatThrownBy(() -> ptc.verify()).isInstanceOf(ApexException.class) + assertThatThrownBy(ptc::verify).isInstanceOf(ApexException.class) .hasMessageContaining("TestPing is not valid, description length null or less than 44"); ptc.setDescription(null); - assertThatThrownBy(() -> ptc.verify()).isInstanceOf(ApexException.class) + assertThatThrownBy(ptc::verify).isInstanceOf(ApexException.class) .hasMessageContaining("TestPing is not valid, description length null or less than 44"); ptc.setDescription("A rose by any other name would smell as swee"); - assertThatThrownBy(() -> ptc.verify()).isInstanceOf(ApexException.class) + assertThatThrownBy(ptc::verify).isInstanceOf(ApexException.class) .hasMessageContaining("TestPing is not valid, description length null or less than 44"); ptc.setDescription("A rose by any other name would smell as swell"); - assertThatThrownBy(() -> ptc.verify()).isInstanceOf(ApexException.class) - .hasMessageContaining("TestPing is not valid, description is incorrect"); + assertThatThrownBy(ptc::verify).isInstanceOf(ApexException.class) + .hasMessageContaining("TestPing is not valid, description is incorrect"); ptc.setDescription("A rose by any other name would smell as sweet"); - assertThatThrownBy(() -> ptc.verify()).isInstanceOf(ApexException.class) + assertThatThrownBy(ptc::verify).isInstanceOf(ApexException.class) .hasMessageContaining("TestPing is not valid, pong time -1 is less than ping time 0"); ptc.setPongTime(-2); - assertThatThrownBy(() -> ptc.verify()).isInstanceOf(ApexException.class) - .hasMessageContaining("TestPing is not valid, pong time -2 is less than ping time 0"); + assertThatThrownBy(ptc::verify).isInstanceOf(ApexException.class) + .hasMessageContaining("TestPing is not valid, pong time -2 is less than ping time 0"); ptc.setPongTime(1); ptc.verify(); - assertEquals( - "PingTestClass(id=0, name=Rose, " - + "description=A rose by any other name would smell as sweet, pingTime=0, pongTime=1)", - ptc.toString()); + assertEquals("PingTestClass(id=0, name=Rose, description=A rose by any other name would smell as sweet, " + + "pingTime=0, pongTime=1)", ptc.toString()); } } |