diff options
author | waynedunican <wayne.dunican@est.tech> | 2024-06-13 09:29:20 +0100 |
---|---|---|
committer | waynedunican <wayne.dunican@est.tech> | 2024-06-20 16:46:07 +0100 |
commit | 9c8f53960b265ec82814f9a4a54ff44ce0682dde (patch) | |
tree | 0d2a7fbbc250422274316ea8cb6e9a1418681e89 /models-tosca/src/test/java/org | |
parent | 9e8684c88435734cb2e142208436cec647cde887 (diff) |
Convert models to JUnit 5
Review for models-sim and models-tosca
Issue-ID: POLICY-5042
Change-Id: I72533933b34df145e1ff4eb40ebafa93f85cca9a
Signed-off-by: waynedunican <wayne.dunican@est.tech>
Diffstat (limited to 'models-tosca/src/test/java/org')
48 files changed, 545 insertions, 513 deletions
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/PojosTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/PojosTest.java index fe60a52c9..dc0e27b4a 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/PojosTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/PojosTest.java @@ -3,7 +3,7 @@ * ONAP Policy Model * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021, 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. @@ -31,7 +31,7 @@ import com.openpojo.validation.rule.impl.GetterMustExistRule; import com.openpojo.validation.rule.impl.SetterMustExistRule; import com.openpojo.validation.test.impl.GetterTester; import com.openpojo.validation.test.impl.SetterTester; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.common.utils.test.ToStringTester; /** @@ -40,12 +40,12 @@ import org.onap.policy.common.utils.test.ToStringTester; * @author Chenfei Gao (cgao@research.att.com) * */ -public class PojosTest { +class PojosTest { private static final String POJO_PACKAGE = "org.onap.policy.models.tosca.authorative.concepts"; @Test - public void testPojos() { + void testPojos() { // @formatter:off final Validator validator = ValidatorBuilder .create() diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaConceptIdentifierOptVersionTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaConceptIdentifierOptVersionTest.java index aedf5cb15..c994827fb 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaConceptIdentifierOptVersionTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaConceptIdentifierOptVersionTest.java @@ -3,7 +3,7 @@ * ONAP Policy Models * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021, 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,21 +22,21 @@ package org.onap.policy.models.tosca.authorative.concepts; 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; /** * Test the other constructors, as {@link PojosTest} tests the other methods. */ -public class ToscaConceptIdentifierOptVersionTest extends ToscaIdentifierTestBase<ToscaConceptIdentifierOptVersion> { +class ToscaConceptIdentifierOptVersionTest extends ToscaIdentifierTestBase<ToscaConceptIdentifierOptVersion> { public ToscaConceptIdentifierOptVersionTest() { super(ToscaConceptIdentifierOptVersion.class, "name", "version"); } @Test - public void testAllArgsConstructor_testIsNullVersion() { + void testAllArgsConstructor_testIsNullVersion() { assertThatThrownBy(() -> new ToscaConceptIdentifierOptVersion(null, VERSION)) .isInstanceOf(NullPointerException.class); @@ -51,7 +51,7 @@ public class ToscaConceptIdentifierOptVersionTest extends ToscaIdentifierTestBas } @Test - public void testCopyConstructor() throws Exception { + void testCopyConstructor() throws Exception { assertThatThrownBy(() -> new ToscaConceptIdentifierOptVersion((ToscaConceptIdentifierOptVersion) null)) .isInstanceOf(NullPointerException.class); @@ -66,7 +66,7 @@ public class ToscaConceptIdentifierOptVersionTest extends ToscaIdentifierTestBas } @Test - public void testCopyToscaPolicyIdentifierConstructor() { + void testCopyToscaPolicyIdentifierConstructor() { assertThatThrownBy(() -> new ToscaConceptIdentifierOptVersion((ToscaConceptIdentifier) null)) .isInstanceOf(NullPointerException.class); @@ -87,7 +87,7 @@ public class ToscaConceptIdentifierOptVersionTest extends ToscaIdentifierTestBas @Test @Override - public void testCompareTo() throws Exception { + void testCompareTo() throws Exception { super.testCompareTo(); } } diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaConceptIdentifierTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaConceptIdentifierTest.java index 88a49dbe3..17fbeeff3 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaConceptIdentifierTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaConceptIdentifierTest.java @@ -3,7 +3,7 @@ * ONAP Policy Models * ================================================================================ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021, 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,27 +22,27 @@ package org.onap.policy.models.tosca.authorative.concepts; import static org.assertj.core.api.Assertions.assertThatThrownBy; -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.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.common.parameters.ValidationResult; import org.onap.policy.models.base.PfConceptKey; /** * Test methods not tested by {@link PojosTest}. */ -public class ToscaConceptIdentifierTest extends ToscaIdentifierTestBase<ToscaConceptIdentifier> { +class ToscaConceptIdentifierTest extends ToscaIdentifierTestBase<ToscaConceptIdentifier> { public ToscaConceptIdentifierTest() { super(ToscaConceptIdentifier.class, "name", "version"); } @Test - public void testAllArgsConstructor() { + void testAllArgsConstructor() { assertThatThrownBy(() -> new ToscaConceptIdentifier(null, VERSION)).isInstanceOf(NullPointerException.class); assertThatThrownBy(() -> new ToscaConceptIdentifier(NAME, null)).isInstanceOf(NullPointerException.class); @@ -52,7 +52,7 @@ public class ToscaConceptIdentifierTest extends ToscaIdentifierTestBase<ToscaCon } @Test - public void testCopyConstructor() { + void testCopyConstructor() { assertThatThrownBy(() -> new ToscaConceptIdentifier((ToscaConceptIdentifier) null)) .isInstanceOf(NullPointerException.class); @@ -68,7 +68,7 @@ public class ToscaConceptIdentifierTest extends ToscaIdentifierTestBase<ToscaCon @Test - public void testPfKey() { + void testPfKey() { assertThatThrownBy(() -> new ToscaConceptIdentifier((PfConceptKey) null)) .isInstanceOf(NullPointerException.class); @@ -80,7 +80,7 @@ public class ToscaConceptIdentifierTest extends ToscaIdentifierTestBase<ToscaCon } @Test - public void testValidatePapRest() throws Exception { + void testValidatePapRest() throws Exception { ToscaConceptIdentifier ident = new ToscaConceptIdentifier(NAME, VERSION); ValidationResult result = ident.validatePapRest(); assertNotNull(result); @@ -102,7 +102,7 @@ public class ToscaConceptIdentifierTest extends ToscaIdentifierTestBase<ToscaCon @Test @Override - public void testCompareTo() throws Exception { + void testCompareTo() throws Exception { super.testCompareTo(); } } diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntityFilterTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntityFilterTest.java index ec2a91733..b9ae31bb5 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntityFilterTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntityFilterTest.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2019-2021 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,17 +23,17 @@ package org.onap.policy.models.tosca.authorative.concepts; 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 com.google.gson.GsonBuilder; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Map.Entry; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.common.utils.resources.ResourceUtils; @@ -46,7 +47,7 @@ import org.yaml.snakeyaml.Yaml; * * @author Liam Fallon (liam.fallon@est.tech) */ -public class ToscaEntityFilterTest { +class ToscaEntityFilterTest { // Logger for this class private static final Logger LOGGER = LoggerFactory.getLogger(ToscaEntityFilterTest.class); @@ -81,7 +82,7 @@ public class ToscaEntityFilterTest { * * @throws CoderException on JSON decoding errors */ - @BeforeClass + @BeforeAll public static void setupTypeList() throws CoderException { for (String policyTypeResourceName : policyTypeResourceNames) { String policyTypeString = ResourceUtils.getResourceAsString(policyTypeResourceName); @@ -116,7 +117,7 @@ public class ToscaEntityFilterTest { } @Test - public void testNullList() { + void testNullList() { ToscaEntityFilter<ToscaPolicyType> filter = ToscaEntityFilter.<ToscaPolicyType>builder().build(); assertThatThrownBy(() -> { @@ -125,7 +126,7 @@ public class ToscaEntityFilterTest { } @Test - public void testFilterNothing() { + void testFilterNothing() { ToscaEntityFilter<ToscaPolicyType> filter = ToscaEntityFilter.<ToscaPolicyType>builder().build(); List<ToscaPolicyType> filteredList = filter.filter(typeList); @@ -133,7 +134,7 @@ public class ToscaEntityFilterTest { } @Test - public void testFilterLatestVersion() { + void testFilterLatestVersion() { ToscaEntityFilter<ToscaPolicyType> filter = ToscaEntityFilter.<ToscaPolicyType>builder().version(ToscaEntityFilter.LATEST_VERSION).build(); @@ -164,7 +165,7 @@ public class ToscaEntityFilterTest { } @Test - public void testFilterNameVersion() { + void testFilterNameVersion() { ToscaEntityFilter<ToscaPolicyType> filter = ToscaEntityFilter.<ToscaPolicyType>builder().name("onap.policies.Monitoring").build(); List<ToscaPolicyType> filteredList = filter.filter(typeList); diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaIdentifierTestBase.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaIdentifierTestBase.java index 5419b217b..ebd31469e 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaIdentifierTestBase.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaIdentifierTestBase.java @@ -3,6 +3,7 @@ * ONAP Policy Models * ================================================================================ * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,8 +21,8 @@ package org.onap.policy.models.tosca.authorative.concepts; -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 org.onap.policy.common.utils.coder.Coder; import org.onap.policy.common.utils.coder.CoderException; @@ -32,7 +33,7 @@ import org.onap.policy.common.utils.coder.StandardCoder; * * @param <T> type of key being tested */ -public class ToscaIdentifierTestBase<T extends Comparable<T>> { +class ToscaIdentifierTestBase<T extends Comparable<T>> { public static final String NAME = "my-name"; public static final String VERSION = "1.2.3"; @@ -61,7 +62,7 @@ public class ToscaIdentifierTestBase<T extends Comparable<T>> { * * @throws Exception if an error occurs */ - public void testCompareTo() throws Exception { + void testCompareTo() throws Exception { T ident = makeIdent(NAME, VERSION); assertEquals(0, ident.compareTo(ident)); diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaNameVersionTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaNameVersionTest.java index 2a3586e07..2efb32608 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaNameVersionTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaNameVersionTest.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * 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,28 +23,28 @@ package org.onap.policy.models.tosca.authorative.concepts; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfKey; -public class ToscaNameVersionTest { +class ToscaNameVersionTest { private static final String MY_NAME = "MyName"; private static final String MY_VERSION = "1.2.3"; private ToscaNameVersion tosca; - @Before - public void setUp() { + @BeforeEach + void setUp() { tosca = new ToscaNameVersion(MY_NAME, MY_VERSION); } @Test - public void testToscaNameVersionPfKey() { + void testToscaNameVersionPfKey() { tosca = new ToscaNameVersion(new PfConceptKey(MY_NAME, MY_VERSION)); assertEquals(MY_NAME, tosca.getName()); assertEquals(MY_VERSION, tosca.getVersion()); @@ -53,19 +54,19 @@ public class ToscaNameVersionTest { } @Test - public void testToscaNameVersionToscaNameVersion() { + void testToscaNameVersionToscaNameVersion() { tosca = new ToscaNameVersion(tosca); assertEquals(MY_NAME, tosca.getName()); assertEquals(MY_VERSION, tosca.getVersion()); } @Test - public void testAsConceptKey() { + void testAsConceptKey() { assertEquals(new PfConceptKey(MY_NAME, MY_VERSION), tosca.asConceptKey()); } @Test - public void testCommonCompareTo() { + void testCommonCompareTo() { assertThat(tosca.commonCompareTo(tosca)).isZero(); assertThat(tosca.commonCompareTo(null)).isNotZero(); assertThat(tosca.commonCompareTo(new MyNameVersion(MY_NAME, MY_VERSION))).isNotZero(); @@ -75,19 +76,19 @@ public class ToscaNameVersionTest { } @Test - public void testToString() { + void testToString() { assertEquals(MY_NAME + " " + MY_VERSION, tosca.toString()); } @Test - public void testToscaNameVersion() { + void testToscaNameVersion() { tosca = new ToscaNameVersion(); assertNull(tosca.getName()); assertNull(tosca.getVersion()); } @Test - public void testToscaNameVersionStringString() { + void testToscaNameVersionStringString() { assertEquals(MY_NAME, tosca.getName()); assertEquals(MY_VERSION, tosca.getVersion()); } diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaNodeTemplateTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaNodeTemplateTest.java index 5cfc864ae..58474b374 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaNodeTemplateTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaNodeTemplateTest.java @@ -3,6 +3,7 @@ * ONAP Policy Models * ================================================================================ * Copyright (C) 2021 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. @@ -21,17 +22,17 @@ package org.onap.policy.models.tosca.authorative.concepts; 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.util.ArrayList; import java.util.HashMap; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class ToscaNodeTemplateTest { +class ToscaNodeTemplateTest { @Test - public void testToscaNodeTemplate() { + void testToscaNodeTemplate() { assertThatThrownBy(() -> { new ToscaNodeTemplate(null); }).hasMessageMatching("copyObject is marked .*on.*ull but is null"); diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTest.java index 1dc9e535e..123ed93d5 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTest.java @@ -3,7 +3,7 @@ * ONAP Policy Models * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2020-2021 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,19 +22,19 @@ package org.onap.policy.models.tosca.authorative.concepts; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; import java.util.LinkedHashMap; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Tests methods not tested by {@link PojosTest}. */ -public class ToscaPolicyTest { +class ToscaPolicyTest { @Test - public void testGetIdentifier_testGetTypeIdentifier() { + void testGetIdentifier_testGetTypeIdentifier() { assertThatThrownBy(() -> { new ToscaPolicy(null); }).hasMessageMatching("copyObject is marked .*on.*ull but is null"); diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeTest.java index 81e9c4f63..148cf8a2d 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeTest.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2019-2021 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. @@ -21,20 +22,20 @@ package org.onap.policy.models.tosca.authorative.concepts; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.LinkedHashMap; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Test of the {@link ToscaPolicyType} class. * * @author Liam Fallon (liam.fallon@est.tech) */ -public class ToscaPolicyTypeTest { +class ToscaPolicyTypeTest { @Test - public void testToscaPolicyType() { + void testToscaPolicyType() { assertThatThrownBy(() -> { new ToscaPolicyType(null); }).hasMessageMatching("copyObject is marked .*on.*ull but is null"); diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPropertyTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPropertyTest.java index 6aa2e1639..342f29f2a 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPropertyTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPropertyTest.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2019-2020 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,17 +21,17 @@ package org.onap.policy.models.tosca.authorative.concepts; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; import java.util.ArrayList; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.models.tosca.simple.concepts.JpaToscaProperty; -public class ToscaPropertyTest { +class ToscaPropertyTest { @Test - public void testToscaPropertyDefaultValue() { + void testToscaPropertyDefaultValue() { ToscaProperty property = new ToscaProperty(); property.setName("test"); property.setType("testType"); diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaServiceTemplateTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaServiceTemplateTest.java index 46ec09039..b11b8a60d 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaServiceTemplateTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaServiceTemplateTest.java @@ -3,6 +3,7 @@ * ONAP Policy Models * ================================================================================ * Copyright (C) 2021 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. @@ -21,16 +22,16 @@ package org.onap.policy.models.tosca.authorative.concepts; 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.util.HashMap; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class ToscaServiceTemplateTest { +class ToscaServiceTemplateTest { @Test - public void testToscServiceTemplate() { + void testToscServiceTemplate() { assertThatThrownBy(() -> { new ToscaServiceTemplate(null); }).hasMessageMatching("copyObject is marked .*on.*ull but is null"); diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaTopologyTemplateTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaTopologyTemplateTest.java index 55ec39d45..398dfb1a9 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaTopologyTemplateTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaTopologyTemplateTest.java @@ -3,6 +3,7 @@ * ONAP Policy Models * ================================================================================ * Copyright (C) 2021 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. @@ -21,17 +22,17 @@ package org.onap.policy.models.tosca.authorative.concepts; 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.util.ArrayList; import java.util.HashMap; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class ToscaTopologyTemplateTest { +class ToscaTopologyTemplateTest { @Test - public void testToscTopologyTemplate() { + void testToscTopologyTemplate() { assertThatThrownBy(() -> { new ToscaTopologyTemplate(null); }).hasMessageMatching("copyObject is marked .*on.*ull but is null"); diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaTypedEntityFilterTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaTypedEntityFilterTest.java index b83245d1f..b224a4472 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaTypedEntityFilterTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaTypedEntityFilterTest.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2019-2021 Nordix Foundation. * Modifications Copyright (C) 2019-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. @@ -23,17 +24,17 @@ package org.onap.policy.models.tosca.authorative.concepts; import static org.assertj.core.api.Assertions.assertThat; 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 com.google.gson.GsonBuilder; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Map.Entry; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.common.utils.resources.ResourceUtils; @@ -47,7 +48,7 @@ import org.yaml.snakeyaml.Yaml; * * @author Liam Fallon (liam.fallon@est.tech) */ -public class ToscaTypedEntityFilterTest { +class ToscaTypedEntityFilterTest { private static final String VERSION_100 = "1.0.0"; private static final String VERSION_000 = "0.0.0"; @@ -76,7 +77,7 @@ public class ToscaTypedEntityFilterTest { * * @throws CoderException on JSON decoding errors */ - @BeforeClass + @BeforeAll public static void setupTypeList() throws CoderException { for (String policyResourceName : policyResourceNames) { String policyString = ResourceUtils.getResourceAsString(policyResourceName); @@ -120,7 +121,7 @@ public class ToscaTypedEntityFilterTest { } @Test - public void testNullList() { + void testNullList() { ToscaTypedEntityFilter<ToscaPolicy> filter = ToscaTypedEntityFilter.<ToscaPolicy>builder().build(); assertThatThrownBy(() -> { @@ -129,7 +130,7 @@ public class ToscaTypedEntityFilterTest { } @Test - public void testFilterNothing() { + void testFilterNothing() { ToscaTypedEntityFilter<ToscaPolicy> filter = ToscaTypedEntityFilter.<ToscaPolicy>builder().build(); List<ToscaPolicy> filteredList = filter.filter(policyList); @@ -137,7 +138,7 @@ public class ToscaTypedEntityFilterTest { } @Test - public void testFilterLatestVersion() { + void testFilterLatestVersion() { ToscaTypedEntityFilter<ToscaPolicy> filter = ToscaTypedEntityFilter.<ToscaPolicy>builder().version(ToscaTypedEntityFilter.LATEST_VERSION).build(); @@ -199,7 +200,7 @@ public class ToscaTypedEntityFilterTest { } @Test - public void testFilterNameVersion() { + void testFilterNameVersion() { ToscaTypedEntityFilter<ToscaPolicy> filter = ToscaTypedEntityFilter.<ToscaPolicy>builder().name("operational.modifyconfig").build(); List<ToscaPolicy> filteredList = filter.filter(policyList); @@ -229,7 +230,7 @@ public class ToscaTypedEntityFilterTest { } @Test - public void testFilterVersionPrefix() { + void testFilterVersionPrefix() { // null pattern ToscaTypedEntityFilter<ToscaPolicy> filter = ToscaTypedEntityFilter.<ToscaPolicy>builder().versionPrefix(null).build(); @@ -246,7 +247,7 @@ public class ToscaTypedEntityFilterTest { } @Test - public void testFilterTypeVersion() { + void testFilterTypeVersion() { ToscaTypedEntityFilter<ToscaPolicy> filter = ToscaTypedEntityFilter.<ToscaPolicy>builder().type("onap.policies.controlloop.Operational").build(); List<ToscaPolicy> filteredList = filter.filter(policyList); diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaWithToscaPropertiesTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaWithToscaPropertiesTest.java index 213f93c89..5fd391a79 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaWithToscaPropertiesTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaWithToscaPropertiesTest.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * 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. @@ -21,16 +22,16 @@ package org.onap.policy.models.tosca.authorative.concepts; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class ToscaWithToscaPropertiesTest { +class ToscaWithToscaPropertiesTest { @Test - public void test() { + void test() { ToscaProperty prop1 = new ToscaProperty(); prop1.setDescription("description A"); diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaWithTypeAndObjectPropertiesTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaWithTypeAndObjectPropertiesTest.java index 79fb26540..9c9d5ba25 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaWithTypeAndObjectPropertiesTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaWithTypeAndObjectPropertiesTest.java @@ -3,7 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021, 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,16 +22,16 @@ package org.onap.policy.models.tosca.authorative.concepts; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class ToscaWithTypeAndObjectPropertiesTest { +class ToscaWithTypeAndObjectPropertiesTest { @Test - public void testCopyConstructor() { + void testCopyConstructor() { ToscaWithTypeAndObjectProperties tosca = new ToscaWithTypeAndObjectProperties(); assertEquals(tosca, new ToscaWithTypeAndObjectProperties(tosca)); diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderGenericTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderGenericTest.java index d433236b0..78058d99c 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderGenericTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderGenericTest.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2020-2021, 2023-2024 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,18 +23,18 @@ package org.onap.policy.models.tosca.authorative.provider; 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 com.google.gson.GsonBuilder; import java.util.List; import java.util.Properties; import org.apache.commons.lang3.ObjectUtils; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.common.utils.resources.ResourceUtils; import org.onap.policy.models.base.PfConceptKey; @@ -50,7 +51,7 @@ import org.yaml.snakeyaml.Yaml; * * @author Liam Fallon (liam.fallon@est.tech) */ -public class AuthorativeToscaProviderGenericTest { +class AuthorativeToscaProviderGenericTest { private static final String POLICY_NO_VERSION_VERSION1 = "onap.policies.NoVersion:0.0.1"; private static final String POLICY_NO_VERSION = "onap.policies.NoVersion"; private static final String DAO_IS_NULL = "^dao is marked .*on.*ull but is null$"; @@ -64,7 +65,7 @@ public class AuthorativeToscaProviderGenericTest { * * @throws Exception on errors */ - @BeforeClass + @BeforeAll public static void readPolicyDefinition() { String yamlString = ResourceUtils.getResourceAsString("src/test/resources/onap.policies.NoVersion.yaml"); @@ -77,8 +78,8 @@ public class AuthorativeToscaProviderGenericTest { * * @throws Exception on database errors */ - @Before - public void setupDao() throws Exception { + @BeforeEach + void setupDao() throws Exception { final DaoParameters daoParameters = new DaoParameters(); daoParameters.setPluginClass(DefaultPfDao.class.getName()); @@ -104,18 +105,18 @@ public class AuthorativeToscaProviderGenericTest { /** * Set up GSON. */ - @Before - public void setupGson() { + @BeforeEach + void setupGson() { standardCoder = new StandardCoder(); } - @After - public void teardown() { + @AfterEach + void teardown() { pfDao.close(); } @Test - public void testCreateGetDelete() throws Exception { + void testCreateGetDelete() throws Exception { assertThatThrownBy(() -> { new AuthorativeToscaProvider().getServiceTemplateList(null, null, null); }).hasMessageMatching(DAO_IS_NULL); @@ -168,7 +169,7 @@ public class AuthorativeToscaProviderGenericTest { } @Test - public void testNullParameters() throws Exception { + void testNullParameters() throws Exception { assertThatThrownBy(() -> new AuthorativeToscaProvider().getServiceTemplateList(null, null, null)) .hasMessageMatching("^dao is marked .*on.*ull but is null$"); diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderNodeTemplateTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderNodeTemplateTest.java index 69c4704d5..95cee32ce 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderNodeTemplateTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderNodeTemplateTest.java @@ -22,16 +22,16 @@ package org.onap.policy.models.tosca.authorative.provider; import static org.assertj.core.api.Assertions.assertThat; 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 java.util.List; import java.util.Map; import java.util.Properties; -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.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.common.utils.coder.YamlJsonTranslator; @@ -49,7 +49,7 @@ import org.yaml.snakeyaml.Yaml; /** * Test of the {@link AuthorativeToscaProvider} class. */ -public class AuthorativeToscaProviderNodeTemplateTest { +class AuthorativeToscaProviderNodeTemplateTest { private static final String NODE_TEMPLATES_JSON = "nodetemplates/nodetemplates.metadatasets.input.tosca.json"; @@ -70,8 +70,8 @@ public class AuthorativeToscaProviderNodeTemplateTest { * Read policy metadataSet input json. * @throws Exception Coder exception */ - @Before - public void fetchToscaNodeTemplatesJson() throws Exception { + @BeforeEach + void fetchToscaNodeTemplatesJson() throws Exception { standardCoder = new StandardCoder(); toscaServiceTemplate = standardCoder.decode(ResourceUtils.getResourceAsString(NODE_TEMPLATES_JSON), ToscaServiceTemplate.class); @@ -87,8 +87,8 @@ public class AuthorativeToscaProviderNodeTemplateTest { * * @throws Exception on database errors */ - @Before - public void setupDao() throws Exception { + @BeforeEach + void setupDao() throws Exception { final DaoParameters daoParameters = new DaoParameters(); daoParameters.setPluginClass(DefaultPfDao.class.getName()); @@ -111,13 +111,13 @@ public class AuthorativeToscaProviderNodeTemplateTest { pfDao.init(daoParameters); } - @After - public void teardown() { + @AfterEach + void teardown() { pfDao.close(); } @Test - public void testPolicyMetadataSetsGet() throws Exception { + void testPolicyMetadataSetsGet() throws Exception { assertThatThrownBy(() -> { authorativeToscaProvider.getNodeTemplateMetadataSet(null, null, null); @@ -143,7 +143,7 @@ public class AuthorativeToscaProviderNodeTemplateTest { } @Test - public void testToscaNodeTemplatesGet() throws Exception { + void testToscaNodeTemplatesGet() throws Exception { assertThatThrownBy(() -> { authorativeToscaProvider.getToscaNodeTemplate(null, null, null); @@ -169,7 +169,7 @@ public class AuthorativeToscaProviderNodeTemplateTest { } @Test - public void testToscaNodeTemplatesCreate() throws Exception { + void testToscaNodeTemplatesCreate() throws Exception { assertThatThrownBy(() -> { authorativeToscaProvider.createToscaNodeTemplates(null, null); }).hasMessageMatching(DAO_IS_NULL); @@ -201,7 +201,7 @@ public class AuthorativeToscaProviderNodeTemplateTest { } @Test - public void testToscaNodeTemplateUpdate() throws Exception { + void testToscaNodeTemplateUpdate() throws Exception { assertThatThrownBy(() -> { authorativeToscaProvider.updateToscaNodeTemplates(null, null); }).hasMessageMatching(DAO_IS_NULL); @@ -230,7 +230,7 @@ public class AuthorativeToscaProviderNodeTemplateTest { } @Test - public void testToscaNodeTemplateDelete() throws Exception { + void testToscaNodeTemplateDelete() throws Exception { assertThatThrownBy(() -> { authorativeToscaProvider.deleteToscaNodeTemplate(null, null, null); }).hasMessageMatching(DAO_IS_NULL); @@ -266,7 +266,7 @@ public class AuthorativeToscaProviderNodeTemplateTest { } @Test - public void testNodeTemplatesWithExistingPolicy() throws Exception { + void testNodeTemplatesWithExistingPolicy() throws Exception { String policyString = ResourceUtils.getResourceAsString(POLICY_WITH_METADATA_SET_REF); ToscaServiceTemplate policyServiceTemplate = yamlJsonTranslator.fromYaml(policyString, ToscaServiceTemplate.class); diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTest.java index 6100397fc..e79664550 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTest.java @@ -22,17 +22,17 @@ package org.onap.policy.models.tosca.authorative.provider; 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 java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Properties; -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.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.common.utils.resources.ResourceUtils; @@ -54,7 +54,7 @@ import org.yaml.snakeyaml.Yaml; * * @author Liam Fallon (liam.fallon@est.tech) */ -public class AuthorativeToscaProviderPolicyTest { +class AuthorativeToscaProviderPolicyTest { private static final String VERSION = "version"; private static final String VCPE_JSON = "policies/vCPE.policy.monitoring.input.tosca.json"; private static final String POLICY_AND_VERSION = "onap.restart.tca:1.0.0"; @@ -69,8 +69,8 @@ public class AuthorativeToscaProviderPolicyTest { * * @throws Exception on database errors */ - @Before - public void setupDao() throws Exception { + @BeforeEach + void setupDao() throws Exception { final DaoParameters daoParameters = new DaoParameters(); daoParameters.setPluginClass(DefaultPfDao.class.getName()); @@ -96,18 +96,18 @@ public class AuthorativeToscaProviderPolicyTest { /** * Set up GSON. */ - @Before - public void setupGson() { + @BeforeEach + void setupGson() { standardCoder = new StandardCoder(); } - @After - public void teardown() { + @AfterEach + void teardown() { pfDao.close(); } @Test - public void testPoliciesGet() throws Exception { + void testPoliciesGet() throws Exception { assertThatThrownBy(() -> { new AuthorativeToscaProvider().getPolicies(null, null, null); }).hasMessageMatching(DAO_IS_NULL); @@ -162,7 +162,7 @@ public class AuthorativeToscaProviderPolicyTest { } @Test - public void testPoliciesGetFiltered() throws Exception { + void testPoliciesGetFiltered() throws Exception { assertThatThrownBy(() -> { new AuthorativeToscaProvider().getFilteredPolicies(null, null); }).hasMessageMatching(DAO_IS_NULL); @@ -250,7 +250,7 @@ public class AuthorativeToscaProviderPolicyTest { } @Test - public void testPolicyCreate() throws Exception { + void testPolicyCreate() throws Exception { assertThatThrownBy(() -> { new AuthorativeToscaProvider().createPolicies(null, null); }).hasMessageMatching(DAO_IS_NULL); @@ -283,7 +283,7 @@ public class AuthorativeToscaProviderPolicyTest { } @Test - public void testPolicyUpdate() throws Exception { + void testPolicyUpdate() throws Exception { assertThatThrownBy(() -> { new AuthorativeToscaProvider().createPolicies(null, null); }).hasMessageMatching(DAO_IS_NULL); @@ -328,7 +328,7 @@ public class AuthorativeToscaProviderPolicyTest { } @Test - public void testPoliciesDelete() throws Exception { + void testPoliciesDelete() throws Exception { assertThatThrownBy(() -> { new AuthorativeToscaProvider().deletePolicy(null, null, null); }).hasMessageMatching(DAO_IS_NULL); @@ -391,7 +391,7 @@ public class AuthorativeToscaProviderPolicyTest { } @Test - public void testAssertPoliciesExist() { + void testAssertPoliciesExist() { ToscaServiceTemplate testServiceTemplate = new ToscaServiceTemplate(); assertThatThrownBy(() -> { @@ -414,7 +414,7 @@ public class AuthorativeToscaProviderPolicyTest { } @Test - public void testEntityMaps() throws CoderException, PfModelException { + void testEntityMaps() throws CoderException, PfModelException { Object yamlObject = new Yaml().load(ResourceUtils.getResourceAsString("policytypes/onap.policies.monitoring.tcagen2.yaml")); String yamlAsJsonString = new StandardCoder().encode(yamlObject); diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTypeTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTypeTest.java index 42ac1272f..b07535e59 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTypeTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTypeTest.java @@ -22,19 +22,19 @@ package org.onap.policy.models.tosca.authorative.provider; 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 com.google.gson.GsonBuilder; import java.util.LinkedHashMap; import java.util.List; import java.util.Properties; import org.apache.commons.lang3.ObjectUtils; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.common.utils.resources.ResourceUtils; import org.onap.policy.models.base.PfConceptKey; @@ -51,7 +51,7 @@ import org.yaml.snakeyaml.Yaml; /** * Test of the {@link AuthorativeToscaProvider} class. */ -public class AuthorativeToscaProviderPolicyTypeTest { +class AuthorativeToscaProviderPolicyTypeTest { private static final String VERSION = "version"; private static final String POLICY_NO_VERSION_VERSION1 = "onap.policies.NoVersion:0.0.1"; private static final String POLICY_NO_VERSION = "onap.policies.NoVersion"; @@ -67,7 +67,7 @@ public class AuthorativeToscaProviderPolicyTypeTest { * * @throws Exception on errors */ - @BeforeClass + @BeforeAll public static void readPolicyDefinition() { String yamlString = ResourceUtils.getResourceAsString("src/test/resources/onap.policies.NoVersion.yaml"); @@ -80,8 +80,8 @@ public class AuthorativeToscaProviderPolicyTypeTest { * * @throws Exception on database errors */ - @Before - public void setupDao() throws Exception { + @BeforeEach + void setupDao() throws Exception { final DaoParameters daoParameters = new DaoParameters(); daoParameters.setPluginClass(DefaultPfDao.class.getName()); @@ -107,18 +107,18 @@ public class AuthorativeToscaProviderPolicyTypeTest { /** * Set up GSON. */ - @Before - public void setupGson() { + @BeforeEach + void setupGson() { standardCoder = new StandardCoder(); } - @After - public void teardown() { + @AfterEach + void teardown() { pfDao.close(); } @Test - public void testPolicyTypesGet() throws Exception { + void testPolicyTypesGet() throws Exception { assertThatThrownBy(() -> { new AuthorativeToscaProvider().getPolicyTypes(null, null, null); }).hasMessageMatching(DAO_IS_NULL); @@ -171,7 +171,7 @@ public class AuthorativeToscaProviderPolicyTypeTest { } @Test - public void testPolicyTypesGetFiltered() throws Exception { + void testPolicyTypesGetFiltered() throws Exception { assertThatThrownBy(() -> { new AuthorativeToscaProvider().getFilteredPolicyTypes(null, null); }).hasMessageMatching(DAO_IS_NULL); @@ -268,7 +268,7 @@ public class AuthorativeToscaProviderPolicyTypeTest { } @Test - public void testPolicyTypesCreate() throws Exception { + void testPolicyTypesCreate() throws Exception { assertThatThrownBy(() -> { new AuthorativeToscaProvider().createPolicyTypes(null, null); }).hasMessageMatching(DAO_IS_NULL); @@ -306,7 +306,7 @@ public class AuthorativeToscaProviderPolicyTypeTest { } @Test - public void testPolicyTypesUpdate() throws Exception { + void testPolicyTypesUpdate() throws Exception { assertThatThrownBy(() -> { new AuthorativeToscaProvider().createPolicyTypes(null, null); }).hasMessageMatching(DAO_IS_NULL); @@ -345,7 +345,7 @@ public class AuthorativeToscaProviderPolicyTypeTest { } @Test - public void testPolicyTypesDelete() throws Exception { + void testPolicyTypesDelete() throws Exception { assertThatThrownBy(() -> { new AuthorativeToscaProvider().deletePolicyType(null, null, null); }).hasMessageMatching(DAO_IS_NULL); @@ -400,7 +400,7 @@ public class AuthorativeToscaProviderPolicyTypeTest { } @Test - public void testAssertPoliciesExist() { + void testAssertPoliciesExist() { ToscaServiceTemplate testServiceTemplate = new ToscaServiceTemplate(); assertThatThrownBy(() -> { @@ -423,7 +423,7 @@ public class AuthorativeToscaProviderPolicyTypeTest { } @Test - public void testNullParameters() throws Exception { + void testNullParameters() throws Exception { assertThatThrownBy(() -> new AuthorativeToscaProvider().getPolicyTypeList(null, null, null)) .hasMessageMatching("^dao is marked .*on.*ull but is null$"); } diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/ToscaServiceTemplateMappingTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/ToscaServiceTemplateMappingTest.java index c4d903986..9067ae727 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/ToscaServiceTemplateMappingTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/ToscaServiceTemplateMappingTest.java @@ -3,7 +3,7 @@ * ONAP Policy Model * ================================================================================ * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019-2020 Nordix Foundation. + * Modifications Copyright (C) 2019-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,11 +23,11 @@ package org.onap.policy.models.tosca.authorative.provider; -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 org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.common.utils.coder.YamlJsonTranslator; import org.onap.policy.common.utils.resources.ResourceUtils; @@ -42,18 +42,18 @@ import org.yaml.snakeyaml.Yaml; * * @author Chenfei Gao (cgao@research.att.com) */ -public class ToscaServiceTemplateMappingTest { +class ToscaServiceTemplateMappingTest { private StandardCoder standardCoder; private YamlJsonTranslator yamlJsonTranslator = new YamlJsonTranslator(); - @Before - public void setUp() { + @BeforeEach + void setUp() { standardCoder = new StandardCoder(); } @Test - public void testPlainToscaPolicies() throws Exception { + void testPlainToscaPolicies() throws Exception { String policyTypeInputJson = ResourceUtils.getResourceAsString("policytypes/onap.policies.monitoring.tcagen2.yaml"); ToscaServiceTemplate plainPolicyTypes = @@ -81,7 +81,7 @@ public class ToscaServiceTemplateMappingTest { } @Test - public void testPlainToscaPolicyTypes() throws Exception { + void testPlainToscaPolicyTypes() throws Exception { Yaml yaml = new Yaml(); String inputYaml = ResourceUtils.getResourceAsString("policytypes/onap.policies.monitoring.tcagen2.yaml"); diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaCapabilityAssignmentTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaCapabilityAssignmentTest.java index 4fcdd8c0d..f47a96152 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaCapabilityAssignmentTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaCapabilityAssignmentTest.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2020-2021 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. @@ -23,14 +24,14 @@ package org.onap.policy.models.tosca.simple.concepts; import static org.assertj.core.api.Assertions.assertThat; 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.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.Validated; import org.onap.policy.models.tosca.authorative.concepts.ToscaCapabilityAssignment; @@ -38,12 +39,12 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaCapabilityAssignme /** * DAO test for JpaToscaCapabilityAssignment. */ -public class JpaToscaCapabilityAssignmentTest { +class JpaToscaCapabilityAssignmentTest { private static final String KEY_IS_NULL = "key is marked .*on.*ull but is null"; @Test - public void testPropertyPojo() { + void testPropertyPojo() { ToscaCapabilityAssignment tca = new ToscaCapabilityAssignment(); tca.setName("world"); tca.setVersion("1.2.3"); @@ -116,7 +117,7 @@ public class JpaToscaCapabilityAssignmentTest { } @Test - public void testCompareTo() { + void testCompareTo() { assertEquals(-1, new JpaToscaCapabilityAssignment().compareTo(null)); assertEquals(0, new JpaToscaCapabilityAssignment().compareTo(new JpaToscaCapabilityAssignment())); @@ -154,7 +155,7 @@ public class JpaToscaCapabilityAssignmentTest { } @Test - public void testAuthorative() { + void testAuthorative() { ToscaCapabilityAssignment tca = new ToscaCapabilityAssignment(); tca.setName("world"); tca.setVersion("1.2.3"); diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintLogicalTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintLogicalTest.java index 2fdd29c5a..9ac401ac5 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintLogicalTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintLogicalTest.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2019, 2023 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,12 +23,12 @@ package org.onap.policy.models.tosca.simple.concepts; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNull; import java.util.ArrayList; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.models.tosca.authorative.concepts.ToscaConstraint; /** @@ -35,12 +36,12 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConstraint; * * @author Liam Fallon (liam.fallon@est.tech) */ -public class JpaToscaConstraintLogicalTest { +class JpaToscaConstraintLogicalTest { private static final String HELLO = "Hello"; @Test - public void testLogicalConstraint() { + void testLogicalConstraint() { ToscaConstraint c0 = new ToscaConstraint(); c0.setEqual(HELLO); JpaToscaConstraintLogical jc0 = new JpaToscaConstraintLogical(c0); diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintTest.java index 02e3fdae3..62b7613c9 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintTest.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2019-2021, 2023 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,13 +23,13 @@ package org.onap.policy.models.tosca.simple.concepts; import static org.assertj.core.api.Assertions.assertThatThrownBy; -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.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.models.tosca.authorative.concepts.ToscaConstraint; /** @@ -36,12 +37,12 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConstraint; * * @author Liam Fallon (liam.fallon@est.tech) */ -public class JpaToscaConstraintTest { +class JpaToscaConstraintTest { private static final String CONSTRAINT = "Constraint"; @Test - public void testConstraintLogicalStringPojo() { + void testConstraintLogicalStringPojo() { assertNotNull(new JpaToscaConstraintLogical(JpaToscaConstraintOperation.EQ, CONSTRAINT)); assertThatThrownBy(() -> new JpaToscaConstraintLogical((JpaToscaConstraintOperation) null, null)) diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaDataTypeTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaDataTypeTest.java index 7399fdc33..31bb55fea 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaDataTypeTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaDataTypeTest.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2019-2021 Nordix Foundation. * Modifications Copyright (C) 2019-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,17 +23,17 @@ package org.onap.policy.models.tosca.simple.concepts; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfKey; import org.onap.policy.models.base.PfReferenceKey; @@ -44,12 +45,12 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaDataType; * * @author Liam Fallon (liam.fallon@est.tech) */ -public class JpaToscaDataTypeTest { +class JpaToscaDataTypeTest { private static final String VERSION_001 = "0.0.1"; @Test - public void testDataTypePojo() { + void testDataTypePojo() { assertNotNull(new JpaToscaDataType()); assertNotNull(new JpaToscaDataType(new PfConceptKey())); assertNotNull(new JpaToscaDataType(new JpaToscaDataType())); @@ -64,7 +65,7 @@ public class JpaToscaDataTypeTest { } @Test - public void testDataTypeProperties() { + void testDataTypeProperties() { PfConceptKey dtKey = new PfConceptKey("tdt", VERSION_001); JpaToscaDataType tdt = new JpaToscaDataType(dtKey); @@ -134,7 +135,7 @@ public class JpaToscaDataTypeTest { } @Test - public void testDataTypeConstraints() { + void testDataTypeConstraints() { ToscaDataType dat = new ToscaDataType(); dat.setName("name"); dat.setVersion("1.2.3"); @@ -152,7 +153,7 @@ public class JpaToscaDataTypeTest { } @Test - public void testGetReferencedDataTypes() { + void testGetReferencedDataTypes() { JpaToscaDataType dt0 = new JpaToscaDataType(new PfConceptKey("dt0", "0.0.1")); assertTrue(dt0.getReferencedDataTypes().isEmpty()); diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaDataTypesTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaDataTypesTest.java index 8f339ef7f..588cae1ec 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaDataTypesTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaDataTypesTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2021 Nordix Foundation. + * Copyright (C) 2019-2024 Nordix Foundation. * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,27 +23,27 @@ package org.onap.policy.models.tosca.simple.concepts; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -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.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.TreeMap; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.common.parameters.BeanValidationResult; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.Validated; import org.onap.policy.models.tosca.authorative.concepts.ToscaDataType; -public class JpaToscaDataTypesTest { +class JpaToscaDataTypesTest { private static final String KEY_IS_NULL = "key is marked .*on.*ull but is null"; @Test - public void testDataTypes() { + void testDataTypes() { assertNotNull(new JpaToscaDataTypes()); assertNotNull(new JpaToscaDataTypes(new PfConceptKey())); assertNotNull(new JpaToscaDataTypes(new PfConceptKey(), new TreeMap<PfConceptKey, JpaToscaDataType>())); @@ -64,7 +64,7 @@ public class JpaToscaDataTypesTest { } @Test - public void testDerivedDataTypes() { + void testDerivedDataTypes() { List<Map<String, ToscaDataType>> dtMapList = new ArrayList<>(); dtMapList.add(new LinkedHashMap<>()); diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaEventFilterTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaEventFilterTest.java index 280f1b855..6d42fea41 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaEventFilterTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaEventFilterTest.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2019-2021 Nordix Foundation. * Modifications Copyright (C) 2019-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,13 +23,13 @@ package org.onap.policy.models.tosca.simple.concepts; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfReferenceKey; @@ -37,7 +38,7 @@ import org.onap.policy.models.base.PfReferenceKey; * * @author Liam Fallon (liam.fallon@est.tech) */ -public class JpaToscaEventFilterTest { +class JpaToscaEventFilterTest { private static final String KEY_IS_NULL = "key is marked .*on.*ull but is null"; private static final String A_REQUREMENT = "A Requrement"; @@ -45,7 +46,7 @@ public class JpaToscaEventFilterTest { private static final String VERSION_001 = "0.0.1"; @Test - public void testEventFilterPojo() { + void testEventFilterPojo() { assertNotNull(new JpaToscaEventFilter()); assertNotNull(new JpaToscaEventFilter(new PfReferenceKey())); assertNotNull(new JpaToscaEventFilter(new PfReferenceKey(), new PfConceptKey())); @@ -65,7 +66,7 @@ public class JpaToscaEventFilterTest { } @Test - public void testEventFilter() { + void testEventFilter() { PfConceptKey efParentKey = new PfConceptKey("tParentKey", VERSION_001); PfReferenceKey efKey = new PfReferenceKey(efParentKey, "trigger0"); PfConceptKey nodeKey = new PfConceptKey("tParentKey", VERSION_001); @@ -110,7 +111,7 @@ public class JpaToscaEventFilterTest { } @Test - public void testValidationEventFilter() { + void testValidationEventFilter() { PfConceptKey efParentKey = new PfConceptKey("tParentKey", VERSION_001); PfReferenceKey efKey = new PfReferenceKey(efParentKey, "trigger0"); PfConceptKey nodeKey = new PfConceptKey("tParentKey", VERSION_001); diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaModelTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaModelTest.java index eb050ecbe..a081e998b 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaModelTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaModelTest.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2019-2021 Nordix Foundation. * Modifications Copyright (C) 2019-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,15 +23,15 @@ package org.onap.policy.models.tosca.simple.concepts; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.Map; import java.util.TreeMap; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfModelService; @@ -39,13 +40,13 @@ import org.onap.policy.models.base.PfModelService; * * @author Liam Fallon (liam.fallon@est.tech) */ -public class JpaToscaModelTest { +class JpaToscaModelTest { private static final String KEY_IS_NULL = "key is marked .*on.*ull but is null"; private static final String VERSION_001 = "0.0.1"; @Test - public void testModelPojo() { + void testModelPojo() { assertNotNull(new JpaToscaModel()); assertNotNull(new JpaToscaModel(new PfConceptKey())); assertNotNull(new JpaToscaModel(new PfConceptKey(), new JpaToscaServiceTemplates())); @@ -66,7 +67,7 @@ public class JpaToscaModelTest { } @Test - public void testJpaToscaModel() { + void testJpaToscaModel() { PfConceptKey tstsKey = new PfConceptKey("tsts", VERSION_001); Map<PfConceptKey, JpaToscaServiceTemplate> tstMap = new TreeMap<>(); JpaToscaServiceTemplates tsts = new JpaToscaServiceTemplates(tstsKey, tstMap); diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPoliciesTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPoliciesTest.java index 1c79091b1..564ae23cf 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPoliciesTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPoliciesTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2021 Nordix Foundation. + * Copyright (C) 2019-2024 Nordix Foundation. * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,27 +23,27 @@ package org.onap.policy.models.tosca.simple.concepts; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -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.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.TreeMap; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.common.parameters.BeanValidationResult; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.Validated; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; -public class JpaToscaPoliciesTest { +class JpaToscaPoliciesTest { private static final String KEY_IS_NULL = "key is marked .*on.*ull but is null"; @Test - public void testPoliciesErrors() { + void testPoliciesErrors() { assertNotNull(new JpaToscaPolicies()); assertNotNull(new JpaToscaPolicies(new PfConceptKey())); assertNotNull(new JpaToscaPolicies(new PfConceptKey(), new TreeMap<PfConceptKey, JpaToscaPolicy>())); @@ -64,7 +64,7 @@ public class JpaToscaPoliciesTest { } @Test - public void testToscaPolicies() { + void testToscaPolicies() { List<Map<String, ToscaPolicy>> polMapList = new ArrayList<>(); polMapList.add(new LinkedHashMap<>()); diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicyTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicyTest.java index b455145d1..b075ac734 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicyTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicyTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2021 Nordix Foundation. + * Copyright (C) 2019-2024 Nordix Foundation. * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,18 +22,18 @@ package org.onap.policy.models.tosca.simple.concepts; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfKey; import org.onap.policy.models.base.PfUtils; @@ -44,13 +44,13 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; * * @author Liam Fallon (liam.fallon@est.tech) */ -public class JpaToscaPolicyTest { +class JpaToscaPolicyTest { private static final String KEY_IS_NULL = "key is marked .*on.*ull but is null"; private static final String VERSION_001 = "0.0.1"; @Test - public void testPolicyPojo() { + void testPolicyPojo() { assertNotNull(new JpaToscaPolicy()); assertNotNull(new JpaToscaPolicy(new PfConceptKey())); assertNotNull(new JpaToscaPolicy(new PfConceptKey(), new PfConceptKey())); @@ -83,7 +83,7 @@ public class JpaToscaPolicyTest { } @Test - public void testJpaToscaPolicy() { + void testJpaToscaPolicy() { PfConceptKey tpKey = new PfConceptKey("tdt", VERSION_001); PfConceptKey ptKey = new PfConceptKey("policyType", VERSION_001); JpaToscaPolicy tp = new JpaToscaPolicy(tpKey, ptKey); @@ -133,7 +133,7 @@ public class JpaToscaPolicyTest { } @Test - public void testJpaToscaPolicyValidation() { + void testJpaToscaPolicyValidation() { JpaToscaPolicy tp = setUpJpaToscaPolicy(); assertFalse(new JpaToscaPolicy().validate("").isValid()); assertTrue(tp.validate("").isValid()); @@ -160,7 +160,7 @@ public class JpaToscaPolicyTest { } @Test - public void testJpaToscaPolicyAuthorative() { + void testJpaToscaPolicyAuthorative() { JpaToscaPolicy tp = setUpJpaToscaPolicy(); PfConceptKey tpTypeKey = tp.getKey(); assertNotNull(tpTypeKey); @@ -195,7 +195,7 @@ public class JpaToscaPolicyTest { } @Test - public void testPolicyProperties() { + void testPolicyProperties() { Map<String, Object> properties = new LinkedHashMap<>(); diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicyTypeTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicyTypeTest.java index 5cca879c5..7b626b5f2 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicyTypeTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicyTypeTest.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2019-2021 Nordix Foundation. * Modifications Copyright (C) 2019-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,18 +23,18 @@ package org.onap.policy.models.tosca.simple.concepts; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfKey; import org.onap.policy.models.base.PfReferenceKey; @@ -45,12 +46,12 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType; * * @author Liam Fallon (liam.fallon@est.tech) */ -public class JpaToscaPolicyTypeTest { +class JpaToscaPolicyTypeTest { private static final String A_DESCRIPTION = "A Description"; private static final String VERSION_001 = "0.0.1"; @Test - public void testPolicyTypeNull() { + void testPolicyTypeNull() { assertNotNull(new JpaToscaPolicyType()); assertNotNull(new JpaToscaPolicyType(new PfConceptKey())); assertNotNull(new JpaToscaPolicyType(new JpaToscaPolicyType())); @@ -63,7 +64,7 @@ public class JpaToscaPolicyTypeTest { } @Test - public void testPolicyTypePojo() { + void testPolicyTypePojo() { PfConceptKey ptKey = new PfConceptKey("tdt", VERSION_001); JpaToscaPolicyType tpt = new JpaToscaPolicyType(ptKey); @@ -133,7 +134,7 @@ public class JpaToscaPolicyTypeTest { } @Test - public void testPolicyTypeValidation() { + void testPolicyTypeValidation() { JpaToscaPolicyType tpt = setUpJpaToscaPolicyType(); assertEquals(6, tpt.getKeys().size()); @@ -159,7 +160,7 @@ public class JpaToscaPolicyTypeTest { } @Test - public void testPolicyTypeValidation2() { + void testPolicyTypeValidation2() { JpaToscaPolicyType tpt = setUpJpaToscaPolicyType(); tpt.getMetadata().put(null, null); @@ -187,7 +188,7 @@ public class JpaToscaPolicyTypeTest { } @Test - public void testPolicyTypeEntity() { + void testPolicyTypeEntity() { JpaToscaPolicyType tpt = setUpJpaToscaPolicyType(); assertThatThrownBy(() -> tpt.validate(null)).hasMessageMatching("fieldName is marked .*on.*ull but is null"); @@ -209,7 +210,7 @@ public class JpaToscaPolicyTypeTest { } @Test - public void testGetReferencedDataTypes() { + void testGetReferencedDataTypes() { JpaToscaPolicyType pt0 = new JpaToscaPolicyType(new PfConceptKey("pt0", "0.0.1")); assertTrue(pt0.getReferencedDataTypes().isEmpty()); diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicyTypesTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicyTypesTest.java index 2e8459bb2..844a8290c 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicyTypesTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicyTypesTest.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2019-2021 Nordix Foundation. * Modifications Copyright (C) 2019-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. @@ -23,27 +24,27 @@ package org.onap.policy.models.tosca.simple.concepts; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -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.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.TreeMap; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.common.parameters.BeanValidationResult; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.Validated; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType; -public class JpaToscaPolicyTypesTest { +class JpaToscaPolicyTypesTest { private static final String KEY_IS_NULL = "key is marked .*on.*ull but is null"; @Test - public void testPolicyTypesNull() { + void testPolicyTypesNull() { assertNotNull(new JpaToscaPolicyTypes()); assertNotNull(new JpaToscaPolicyTypes(new PfConceptKey())); assertNotNull(new JpaToscaPolicyTypes(new PfConceptKey(), new TreeMap<PfConceptKey, JpaToscaPolicyType>())); @@ -64,7 +65,7 @@ public class JpaToscaPolicyTypesTest { } @Test - public void testPolicyTypes() { + void testPolicyTypes() { List<Map<String, ToscaPolicyType>> ptMapList = new ArrayList<>(); ptMapList.add(new LinkedHashMap<>()); diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPropertyTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPropertyTest.java index ffa21244c..ad870ce6a 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPropertyTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPropertyTest.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2019-2021, 2023 Nordix Foundation. * Modifications Copyright (C) 2019-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,19 +23,19 @@ package org.onap.policy.models.tosca.simple.concepts; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertSame; -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.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.TreeMap; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfReferenceKey; import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; @@ -44,7 +45,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; * * @author Liam Fallon (liam.fallon@est.tech) */ -public class JpaToscaPropertyTest { +class JpaToscaPropertyTest { private static final String KEY_IS_NULL = "key is marked .*on.*ull but is null"; private static final String DEFAULT_KEY = "defaultKey"; @@ -52,7 +53,7 @@ public class JpaToscaPropertyTest { private static final String VERSION_001 = "0.0.1"; @Test - public void testPropertyNull() { + void testPropertyNull() { assertNotNull(new JpaToscaProperty()); assertNotNull(new JpaToscaProperty(new PfReferenceKey())); assertNotNull(new JpaToscaProperty(new PfReferenceKey(), new PfConceptKey())); @@ -69,7 +70,7 @@ public class JpaToscaPropertyTest { } @Test - public void testProperty() { + void testProperty() { PfConceptKey pparentKey = new PfConceptKey("tParentKey", VERSION_001); PfReferenceKey pkey = new PfReferenceKey(pparentKey, "trigger0"); PfConceptKey ptypeKey = new PfConceptKey("TTypeKey", VERSION_001); @@ -119,7 +120,7 @@ public class JpaToscaPropertyTest { } @Test - public void testPropertyCompareData() { + void testPropertyCompareData() { JpaToscaProperty tp = setUpJpaToscaProperty(); PfReferenceKey otherDtKey = new PfReferenceKey("otherDt", VERSION_001, "OtherProperty"); @@ -180,7 +181,7 @@ public class JpaToscaPropertyTest { } @Test - public void testPropertyCompareDescription() { + void testPropertyCompareDescription() { JpaToscaProperty tp = setUpJpaToscaProperty(); JpaToscaProperty tdtClone0 = new JpaToscaProperty(tp); @@ -203,7 +204,7 @@ public class JpaToscaPropertyTest { } @Test - public void testPropertyCompareMetadata() { + void testPropertyCompareMetadata() { JpaToscaProperty tp = setUpJpaToscaProperty(); PfConceptKey typeKey = new PfConceptKey("type", VERSION_001); tp.setType(typeKey); @@ -233,7 +234,7 @@ public class JpaToscaPropertyTest { } @Test - public void testToAuthorative_testFromAuthorative() { + void testToAuthorative_testFromAuthorative() { // check with empty structure JpaToscaProperty tp = new JpaToscaProperty(); ToscaProperty auth = tp.toAuthorative(); diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaSchemaDefinitionTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaSchemaDefinitionTest.java index a8d4f3487..9cab6eb6a 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaSchemaDefinitionTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaSchemaDefinitionTest.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2019-2021 Nordix Foundation. * Modifications Copyright (C) 2019-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,15 +23,15 @@ package org.onap.policy.models.tosca.simple.concepts; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.ArrayList; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.models.base.PfConceptKey; /** @@ -38,12 +39,12 @@ import org.onap.policy.models.base.PfConceptKey; * * @author Liam Fallon (liam.fallon@est.tech) */ -public class JpaToscaSchemaDefinitionTest { +class JpaToscaSchemaDefinitionTest { private static final String A_DESCRIPTION = "A Description"; @Test - public void testEntrySchemaNull() { + void testEntrySchemaNull() { assertNotNull(new JpaToscaSchemaDefinition(new PfConceptKey())); assertNotNull(new JpaToscaSchemaDefinition(new JpaToscaSchemaDefinition(new PfConceptKey()))); @@ -55,7 +56,7 @@ public class JpaToscaSchemaDefinitionTest { } @Test - public void testEntrySchema() { + void testEntrySchema() { PfConceptKey typeKey = new PfConceptKey("type", "0.0.1"); JpaToscaSchemaDefinition tes = new JpaToscaSchemaDefinition(typeKey); @@ -100,7 +101,7 @@ public class JpaToscaSchemaDefinitionTest { } @Test - public void testEntrySchemaValidation() { + void testEntrySchemaValidation() { PfConceptKey typeKey = new PfConceptKey("type", "0.0.1"); JpaToscaSchemaDefinition tes = setUpJpaToscaSchemaDefinition(typeKey); diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplateTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplateTest.java index 6296788ee..d7d7b3999 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplateTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplateTest.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2019-2021, 2023 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. @@ -23,16 +24,16 @@ package org.onap.policy.models.tosca.simple.concepts; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.LinkedHashMap; import java.util.Map; import java.util.TreeMap; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.common.parameters.BeanValidationResult; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfReferenceKey; @@ -43,13 +44,13 @@ import org.onap.policy.models.base.Validated; * * @author Liam Fallon (liam.fallon@est.tech) */ -public class JpaToscaServiceTemplateTest { +class JpaToscaServiceTemplateTest { private static final String KEY_IS_NULL = "key is marked .*on.*ull but is null"; private static final String VERSION_001 = "0.0.1"; @Test - public void testServiceTemplateNull() { + void testServiceTemplateNull() { assertNotNull(new JpaToscaServiceTemplate()); assertNotNull(new JpaToscaServiceTemplate(new PfConceptKey())); assertNotNull(new JpaToscaServiceTemplate(new PfConceptKey(), "")); @@ -69,7 +70,7 @@ public class JpaToscaServiceTemplateTest { } @Test - public void testServiceTemplatePojo() { + void testServiceTemplatePojo() { PfConceptKey tstKey = new PfConceptKey("tst", VERSION_001); JpaToscaServiceTemplate tst = new JpaToscaServiceTemplate(tstKey, "Tosca Version"); diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplatesTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplatesTest.java index a019a9727..c1159980c 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplatesTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplatesTest.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2019-2020 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,23 +23,23 @@ package org.onap.policy.models.tosca.simple.concepts; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotNull; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.TreeMap; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; -public class JpaToscaServiceTemplatesTest { +class JpaToscaServiceTemplatesTest { private static final String KEY_IS_NULL = "key is marked .*on.*ull but is null"; @Test - public void testServiceTemplates() { + void testServiceTemplates() { assertNotNull(new JpaToscaServiceTemplates()); assertNotNull(new JpaToscaServiceTemplates(new PfConceptKey())); assertNotNull( diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTimeIntervalTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTimeIntervalTest.java index 7e8b78109..92a59722f 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTimeIntervalTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTimeIntervalTest.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2019-2021 Nordix Foundation. * Modifications Copyright (C) 2019-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,15 +23,15 @@ package org.onap.policy.models.tosca.simple.concepts; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.sql.Timestamp; import java.time.Instant; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfReferenceKey; @@ -39,12 +40,12 @@ import org.onap.policy.models.base.PfReferenceKey; * * @author Liam Fallon (liam.fallon@est.tech) */ -public class JpaToscaTimeIntervalTest { +class JpaToscaTimeIntervalTest { private static final String KEY_IS_NULL = "key is marked .*on.*ull but is null"; @Test - public void testTimeIntervalPojo() { + void testTimeIntervalPojo() { assertNotNull(new JpaToscaTimeInterval()); assertNotNull(new JpaToscaTimeInterval(new PfReferenceKey())); assertNotNull(new JpaToscaTimeInterval(new PfReferenceKey(), Instant.now(), Instant.now())); @@ -75,7 +76,7 @@ public class JpaToscaTimeIntervalTest { } @Test - public void testTimeInterval() { + void testTimeInterval() { PfConceptKey ttiParentKey = new PfConceptKey("tParentKey", "0.0.1"); PfReferenceKey ttiKey = new PfReferenceKey(ttiParentKey, "trigger0"); Instant startTime = Instant.ofEpochSecond(1000); @@ -114,7 +115,7 @@ public class JpaToscaTimeIntervalTest { } @Test - public void testTimeIntervalValidation() { + void testTimeIntervalValidation() { Instant startTime = Instant.ofEpochSecond(1000); Instant endTime = Instant.ofEpochSecond(2000); JpaToscaTimeInterval tti = setUpJpaToscaTimeInterval(startTime, endTime); diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTopologyTemplateTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTopologyTemplateTest.java index 3790329b9..8c9154b10 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTopologyTemplateTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTopologyTemplateTest.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2019-2021 Nordix Foundation. * Modifications Copyright (C) 2019-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,15 +23,15 @@ package org.onap.policy.models.tosca.simple.concepts; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.Map; import java.util.TreeMap; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfReferenceKey; import org.onap.policy.models.tosca.authorative.concepts.ToscaTopologyTemplate; @@ -40,13 +41,13 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaTopologyTemplate; * * @author Liam Fallon (liam.fallon@est.tech) */ -public class JpaToscaTopologyTemplateTest { +class JpaToscaTopologyTemplateTest { private static final String A_DESCRIPTION = "A Description"; private static final String VERSION_001 = "0.0.1"; @Test - public void testTopologyTemplatePojo() { + void testTopologyTemplatePojo() { assertNotNull(new JpaToscaTopologyTemplate()); assertNotNull(new JpaToscaTopologyTemplate(new PfReferenceKey())); assertNotNull(new JpaToscaTopologyTemplate(new JpaToscaTopologyTemplate())); @@ -63,7 +64,7 @@ public class JpaToscaTopologyTemplateTest { } @Test - public void testTopologyTemplates() { + void testTopologyTemplates() { PfReferenceKey tttKey = new PfReferenceKey("tst", VERSION_001, "ttt"); JpaToscaTopologyTemplate ttt = new JpaToscaTopologyTemplate(tttKey); @@ -106,7 +107,7 @@ public class JpaToscaTopologyTemplateTest { } @Test - public void testTopologyTemplateValidation() { + void testTopologyTemplateValidation() { PfReferenceKey tttKey = new PfReferenceKey("tst", VERSION_001, "ttt"); JpaToscaTopologyTemplate ttt = new JpaToscaTopologyTemplate(tttKey); diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTriggerTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTriggerTest.java index 597ce0c4d..26995e90e 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTriggerTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTriggerTest.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2019-2021 Nordix Foundation. * Modifications Copyright (C) 2019-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,15 +23,15 @@ package org.onap.policy.models.tosca.simple.concepts; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.time.Duration; import java.time.Instant; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfReferenceKey; @@ -39,7 +40,7 @@ import org.onap.policy.models.base.PfReferenceKey; * * @author Liam Fallon (liam.fallon@est.tech) */ -public class JpaToscaTriggerTest { +class JpaToscaTriggerTest { private static final String KEY_IS_NULL = "key is marked .*on.*ull but is null"; private static final String EVENT_TYPE = "EventType"; @@ -49,7 +50,7 @@ public class JpaToscaTriggerTest { private static final String VERSION_001 = "0.0.1"; @Test - public void testTriggerPojo() { + void testTriggerPojo() { assertNotNull(new JpaToscaTrigger()); assertNotNull(new JpaToscaTrigger(new PfReferenceKey())); assertNotNull(new JpaToscaTrigger(new PfReferenceKey(), EVENT_TYPE, ACTION)); @@ -78,7 +79,7 @@ public class JpaToscaTriggerTest { } @Test - public void testTriggerConstraints() { + void testTriggerConstraints() { PfConceptKey tparentKey = new PfConceptKey("tParentKey", VERSION_001); PfReferenceKey tkey = new PfReferenceKey(tparentKey, "trigger0"); JpaToscaTrigger tdt = new JpaToscaTrigger(tkey, EVENT_TYPE, ACTION); @@ -151,7 +152,7 @@ public class JpaToscaTriggerTest { } @Test - public void testCloneToscaTrigger() { + void testCloneToscaTrigger() { PfConceptKey tparentKey = new PfConceptKey("tParentKey", VERSION_001); PfReferenceKey tkey = new PfReferenceKey(tparentKey, "trigger0"); JpaToscaTrigger tdt = new JpaToscaTrigger(tkey, EVENT_TYPE, ACTION); diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaWithStringPropertiesTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaWithStringPropertiesTest.java index f232fcb7b..e94c32581 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaWithStringPropertiesTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaWithStringPropertiesTest.java @@ -4,6 +4,7 @@ * ================================================================================ * Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2021 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. @@ -22,20 +23,20 @@ package org.onap.policy.models.tosca.simple.concepts; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.List; import java.util.Map; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.onap.policy.common.parameters.annotations.NotNull; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.tosca.authorative.concepts.ToscaWithTypeAndObjectProperties; -public class JpaToscaWithStringPropertiesTest { +class JpaToscaWithStringPropertiesTest { private static final String SOME_DESCRIPTION = "some description"; private static final String KEY1 = "abc"; private static final String KEY2 = "def"; @@ -46,13 +47,13 @@ public class JpaToscaWithStringPropertiesTest { private MyJpa jpa; - @Before - public void setUp() { + @BeforeEach + void setUp() { jpa = new MyJpa(); } @Test - public void testGetKeys() { + void testGetKeys() { PfConceptKey key = new PfConceptKey("bye", "9.8.7"); PfConceptKey typeKey = new PfConceptKey("type", "6.5.4"); @@ -65,7 +66,7 @@ public class JpaToscaWithStringPropertiesTest { } @Test - public void testClean() { + void testClean() { jpa.setDescription(" some description "); jpa.setProperties(Map.of(KEY1, "10 ", KEY2, " 20")); @@ -75,7 +76,7 @@ public class JpaToscaWithStringPropertiesTest { } @Test - public void testToAuthorative() { + void testToAuthorative() { jpa.setDescription(SOME_DESCRIPTION); jpa.setProperties(Map.of(KEY1, STRING1, KEY2, STRING2)); @@ -85,7 +86,7 @@ public class JpaToscaWithStringPropertiesTest { } @Test - public void testFromAuthorative() { + void testFromAuthorative() { MyTosca tosca = new MyTosca(); tosca.setType("type"); tosca.setTypeVersion("1.2.3"); @@ -104,7 +105,7 @@ public class JpaToscaWithStringPropertiesTest { } @Test - public void testCompareTo() { + void testCompareTo() { jpa.setDescription(SOME_DESCRIPTION); jpa.setProperties(Map.of(KEY1, STRING1, KEY2, STRING2)); @@ -120,14 +121,14 @@ public class JpaToscaWithStringPropertiesTest { } @Test - public void testJpaToscaWithStringProperties() { + void testJpaToscaWithStringProperties() { assertThat(jpa.getProperties()).isNull(); assertThat(jpa.getKey().isNullKey()).isTrue(); } @Test - public void testJpaToscaWithStringPropertiesPfConceptKey() { + void testJpaToscaWithStringPropertiesPfConceptKey() { PfConceptKey key = new PfConceptKey("hello", "1.2.3"); jpa = new MyJpa(key); @@ -135,7 +136,7 @@ public class JpaToscaWithStringPropertiesTest { } @Test - public void testJpaToscaWithStringPropertiesJpaToscaWithStringPropertiesOfT() { + void testJpaToscaWithStringPropertiesJpaToscaWithStringPropertiesOfT() { jpa.setDescription(SOME_DESCRIPTION); assertEquals(jpa, new MyJpa(jpa)); @@ -144,7 +145,7 @@ public class JpaToscaWithStringPropertiesTest { } @Test - public void testJpaToscaWithStringPropertiesT() { + void testJpaToscaWithStringPropertiesT() { MyTosca tosca = new MyTosca(); tosca.setName("world"); tosca.setVersion("3.2.1"); @@ -161,7 +162,7 @@ public class JpaToscaWithStringPropertiesTest { } @Test - public void testValidateWithKey() { + void testValidateWithKey() { // null key - should fail jpa.setText("some text"); assertThat(jpa.validateWithKey("fieldA").isValid()).isFalse(); diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaWithToscaPropertiesTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaWithToscaPropertiesTest.java index e259edfef..6defc85de 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaWithToscaPropertiesTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaWithToscaPropertiesTest.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * 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. @@ -21,7 +22,7 @@ package org.onap.policy.models.tosca.simple.concepts; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.ArrayList; import java.util.Collections; @@ -30,9 +31,9 @@ import java.util.Map; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.onap.policy.common.parameters.annotations.NotNull; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfKey; @@ -40,7 +41,7 @@ import org.onap.policy.models.base.PfReferenceKey; import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; import org.onap.policy.models.tosca.authorative.concepts.ToscaWithToscaProperties; -public class JpaToscaWithToscaPropertiesTest { +class JpaToscaWithToscaPropertiesTest { private static final String SOME_DESCRIPTION = "some description"; private static final String KEY1 = "abc"; private static final String KEY2 = "def"; @@ -60,7 +61,7 @@ public class JpaToscaWithToscaPropertiesTest { /** * Initializes the properties. */ - @BeforeClass + @BeforeAll public static void setUpBeforeClass() { JPA_PROP1.setDescription(DESCRIPT1); JPA_PROP2.setDescription(DESCRIPT2); @@ -69,13 +70,13 @@ public class JpaToscaWithToscaPropertiesTest { PROP2 = JPA_PROP2.toAuthorative(); } - @Before - public void setUp() { + @BeforeEach + void setUp() { jpa = new MyJpa(); } @Test - public void testGetKeys() { + void testGetKeys() { PfConceptKey key = new PfConceptKey("bye", "9.8.7"); jpa = new MyJpa(key); @@ -92,7 +93,7 @@ public class JpaToscaWithToscaPropertiesTest { } @Test - public void testClean() { + void testClean() { jpa.clean(); jpa.setDescription(" some description "); @@ -111,7 +112,7 @@ public class JpaToscaWithToscaPropertiesTest { } @Test - public void testToAuthorative() { + void testToAuthorative() { jpa.setDescription(SOME_DESCRIPTION); jpa.setProperties(Map.of(KEY1, JPA_PROP1, KEY2, JPA_PROP2)); @@ -121,7 +122,7 @@ public class JpaToscaWithToscaPropertiesTest { } @Test - public void testFromAuthorative() { + void testFromAuthorative() { MyTosca tosca = new MyTosca(); tosca.setDescription(SOME_DESCRIPTION); @@ -144,7 +145,7 @@ public class JpaToscaWithToscaPropertiesTest { } @Test - public void testCompareTo() { + void testCompareTo() { jpa.setDescription(SOME_DESCRIPTION); jpa.setProperties(Map.of(KEY1, JPA_PROP1, KEY2, JPA_PROP2)); @@ -160,19 +161,19 @@ public class JpaToscaWithToscaPropertiesTest { } @Test - public void testJpaToscaWithToscaProperties() { + void testJpaToscaWithToscaProperties() { assertThat(jpa.getProperties()).isNull(); assertThat(jpa.getKey().isNullKey()).isTrue(); } @Test - public void testJpaToscaWithToscaPropertiesPfConceptKey() { + void testJpaToscaWithToscaPropertiesPfConceptKey() { jpa = new MyJpa(CONCEPT_KEY1); assertEquals(CONCEPT_KEY1, jpa.getKey()); } @Test - public void testJpaToscaWithToscaPropertiesJpaToscaWithToscaPropertiesOfT() { + void testJpaToscaWithToscaPropertiesJpaToscaWithToscaPropertiesOfT() { jpa.setDescription(SOME_DESCRIPTION); assertEquals(jpa, new MyJpa(jpa)); @@ -181,7 +182,7 @@ public class JpaToscaWithToscaPropertiesTest { } @Test - public void testJpaToscaWithToscaPropertiesT() { + void testJpaToscaWithToscaPropertiesT() { MyTosca tosca = new MyTosca(); tosca.setName("world"); tosca.setVersion("3.2.1"); @@ -203,7 +204,7 @@ public class JpaToscaWithToscaPropertiesTest { } @Test - public void testValidateWithKey() { + void testValidateWithKey() { // null key - should fail jpa.setText("some text"); assertThat(jpa.validateWithKey("fieldA").isValid()).isFalse(); @@ -218,7 +219,7 @@ public class JpaToscaWithToscaPropertiesTest { } @Test - public void testGetReferencedDataTypes() { + void testGetReferencedDataTypes() { assertThat(jpa.getReferencedDataTypes()).isEmpty(); // one with a schema diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/TestPojos.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/TestPojos.java index 250a819e6..2ac2ce6dd 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/TestPojos.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/TestPojos.java @@ -3,7 +3,7 @@ * ONAP Policy Model * ================================================================================ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019, 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. @@ -29,7 +29,7 @@ import com.openpojo.validation.ValidatorBuilder; import com.openpojo.validation.rule.impl.GetterMustExistRule; import com.openpojo.validation.test.impl.GetterTester; import com.openpojo.validation.test.impl.SetterTester; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.common.utils.test.ToStringTester; /** @@ -38,11 +38,11 @@ import org.onap.policy.common.utils.test.ToStringTester; * @author Chenfei Gao (cgao@research.att.com) * */ -public class TestPojos { +class TestPojos { private static final String POJO_PACKAGE = "org.onap.policy.models.tosca.simple.concepts"; @Test - public void testPojos() { + void testPojos() { // @formatter:off final Validator validator = ValidatorBuilder .create() diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProviderTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProviderTest.java index 98dfdaefb..a789cd57b 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProviderTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProviderTest.java @@ -22,17 +22,17 @@ package org.onap.policy.models.tosca.simple.provider; 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.util.ArrayList; import java.util.LinkedHashMap; import java.util.Properties; import java.util.TreeMap; -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.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.common.utils.resources.ResourceUtils; @@ -65,7 +65,7 @@ import org.yaml.snakeyaml.Yaml; * * @author Liam Fallon (liam.fallon@est.tech) */ -public class SimpleToscaProviderTest { +class SimpleToscaProviderTest { private static final String TEMPLATE_IS_NULL = "^serviceTemplate is marked .*on.*ull but is null$"; private static final String INCOMING_TEMPLATE_IS_NULL = "^incomingServiceTemplate is marked .*on.*ull but is null$"; private static final String VCPE_INPUT_JSON = "policies/vCPE.policy.monitoring.input.tosca.json"; @@ -79,8 +79,8 @@ public class SimpleToscaProviderTest { * * @throws Exception on database errors */ - @Before - public void setupDao() throws Exception { + @BeforeEach + void setupDao() throws Exception { final DaoParameters daoParameters = new DaoParameters(); daoParameters.setPluginClass(DefaultPfDao.class.getName()); @@ -107,18 +107,18 @@ public class SimpleToscaProviderTest { /** * Set up GSON. */ - @Before - public void setupGson() { + @BeforeEach + void setupGson() { standardCoder = new StandardCoder(); } - @After - public void teardown() { + @AfterEach + void teardown() { pfDao.close(); } @Test - public void testCreateUpdateGetDeleteDataType() throws PfModelException { + void testCreateUpdateGetDeleteDataType() throws PfModelException { PfConceptKey dataType0Key = new PfConceptKey("DataType0", "0.0.1"); JpaToscaDataType dataType0 = new JpaToscaDataType(); dataType0.setKey(dataType0Key); @@ -217,7 +217,7 @@ public class SimpleToscaProviderTest { } @Test - public void testCreateUpdateGetDeletePolicyType() throws PfModelException { + void testCreateUpdateGetDeletePolicyType() throws PfModelException { JpaToscaServiceTemplate serviceTemplate = new JpaToscaServiceTemplate(); PfConceptKey dataType0Key = new PfConceptKey("DataType0", "0.0.1"); @@ -310,7 +310,7 @@ public class SimpleToscaProviderTest { } @Test - public void testCreateUpdateGetDeletePolicyTypeWithDataType() throws PfModelException { + void testCreateUpdateGetDeletePolicyTypeWithDataType() throws PfModelException { PfConceptKey policyType0Key = new PfConceptKey("PolicyType0", "0.0.1"); JpaToscaPolicyType policyType0 = new JpaToscaPolicyType(); policyType0.setKey(policyType0Key); @@ -356,7 +356,7 @@ public class SimpleToscaProviderTest { } @Test - public void testPoliciesGet() throws Exception { + void testPoliciesGet() throws Exception { ToscaServiceTemplate toscaServiceTemplate = standardCoder.decode(ResourceUtils.getResourceAsString(VCPE_INPUT_JSON), ToscaServiceTemplate.class); @@ -385,7 +385,7 @@ public class SimpleToscaProviderTest { } @Test - public void testPolicyCreate() throws Exception { + void testPolicyCreate() throws Exception { ToscaServiceTemplate toscaServiceTemplate = standardCoder.decode(ResourceUtils.getResourceAsString(VCPE_INPUT_JSON), ToscaServiceTemplate.class); @@ -403,7 +403,7 @@ public class SimpleToscaProviderTest { } @Test - public void testPolicyCreateTypeAndVersion() throws Exception { + void testPolicyCreateTypeAndVersion() throws Exception { ToscaServiceTemplate toscaServiceTemplate = standardCoder.decode(ResourceUtils.getResourceAsString(VCPE_INPUT_JSON), ToscaServiceTemplate.class); @@ -462,7 +462,7 @@ public class SimpleToscaProviderTest { } @Test - public void testPolicyUpdate() throws Exception { + void testPolicyUpdate() throws Exception { ToscaServiceTemplate toscaServiceTemplate = standardCoder.decode(ResourceUtils.getResourceAsString(VCPE_INPUT_JSON), ToscaServiceTemplate.class); @@ -479,7 +479,7 @@ public class SimpleToscaProviderTest { } @Test - public void testPoliciesDelete() throws Exception { + void testPoliciesDelete() throws Exception { ToscaServiceTemplate toscaServiceTemplate = standardCoder.decode(ResourceUtils.getResourceAsString(VCPE_INPUT_JSON), ToscaServiceTemplate.class); @@ -515,7 +515,7 @@ public class SimpleToscaProviderTest { } @Test - public void testAssertPoliciesExist() { + void testAssertPoliciesExist() { JpaToscaServiceTemplate testServiceTemplate = new JpaToscaServiceTemplate(); assertThatThrownBy(() -> new SimpleToscaProvider().createPolicies(pfDao, testServiceTemplate)) @@ -531,13 +531,13 @@ public class SimpleToscaProviderTest { } @Test - public void testGetServiceTemplate() throws PfModelException { + void testGetServiceTemplate() throws PfModelException { assertThatThrownBy(() -> new SimpleToscaProvider().getServiceTemplate(pfDao)) .hasMessage("service template not found in database"); } @Test - public void testAppendToServiceTemplate() throws PfModelException { + void testAppendToServiceTemplate() throws PfModelException { JpaToscaServiceTemplate serviceTemplateFragment = new JpaToscaServiceTemplate(); serviceTemplateFragment.setPolicyTypes(new JpaToscaPolicyTypes()); JpaToscaPolicyType badPt = new JpaToscaPolicyType(); @@ -549,7 +549,7 @@ public class SimpleToscaProviderTest { } @Test - public void testGetDataTypesCornerCases() throws PfModelException { + void testGetDataTypesCornerCases() throws PfModelException { assertThatThrownBy(() -> { new SimpleToscaProvider().getDataTypes(pfDao, "hello", "0.0.1"); }).hasMessageMatching("service template not found in database"); @@ -612,7 +612,7 @@ public class SimpleToscaProviderTest { } @Test - public void testGetPolicyTypesCornerCases() throws PfModelException { + void testGetPolicyTypesCornerCases() throws PfModelException { assertThatThrownBy(() -> { new SimpleToscaProvider().getPolicyTypes(pfDao, "hello", "0.0.1"); }).hasMessageMatching("service template not found in database"); @@ -677,7 +677,7 @@ public class SimpleToscaProviderTest { } @Test - public void testGetPoliciesCornerCases() throws PfModelException { + void testGetPoliciesCornerCases() throws PfModelException { assertThatThrownBy(() -> { new SimpleToscaProvider().getPolicies(pfDao, "hello", "0.0.1"); }).hasMessageMatching("service template not found in database"); @@ -755,7 +755,7 @@ public class SimpleToscaProviderTest { } @Test - public void testNonNullsDataType() { + void testNonNullsDataType() { assertThatThrownBy(() -> { new SimpleToscaProvider().getServiceTemplate(null); }).hasMessageMatching(DAO_IS_NULL); @@ -814,7 +814,7 @@ public class SimpleToscaProviderTest { } @Test - public void testNotNullsPolicyTypes() { + void testNotNullsPolicyTypes() { assertThatThrownBy(() -> { new SimpleToscaProvider().getPolicyTypes(null, null, null); }).hasMessageMatching(DAO_IS_NULL); @@ -897,7 +897,7 @@ public class SimpleToscaProviderTest { } @Test - public void testDeleteServiceTemplate() throws PfModelException { + void testDeleteServiceTemplate() throws PfModelException { assertThatThrownBy(() -> { new SimpleToscaProvider().deleteServiceTemplate(null); }).hasMessageMatching("^dao is marked .*on.*ull but is null$"); @@ -930,7 +930,7 @@ public class SimpleToscaProviderTest { } @Test - public void testNullParameters() { + void testNullParameters() { assertThatThrownBy(() -> { new SimpleToscaProvider().getCascadedDataTypes(null, null, null); }).hasMessageMatching("^dbServiceTemplate is marked .*on.*ull but is null$"); diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaServiceTemplateProviderTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaServiceTemplateProviderTest.java index 1d6be1b3f..205d3baa8 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaServiceTemplateProviderTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaServiceTemplateProviderTest.java @@ -22,16 +22,16 @@ package org.onap.policy.models.tosca.simple.provider; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.Properties; import java.util.TreeMap; -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.models.base.PfConceptKey; import org.onap.policy.models.base.PfModelException; import org.onap.policy.models.dao.DaoParameters; @@ -52,7 +52,7 @@ import org.onap.policy.models.tosca.simple.concepts.JpaToscaTrigger; * * @author Liam Fallon (liam.fallon@est.tech) */ -public class SimpleToscaServiceTemplateProviderTest { +class SimpleToscaServiceTemplateProviderTest { private static final String TEMPLATE_IS_NULL = "^serviceTemplate is marked .*on.*ull but is null$"; private static final String DAO_IS_NULL = "^dao is marked .*on.*ull but is null$"; @@ -63,8 +63,8 @@ public class SimpleToscaServiceTemplateProviderTest { * * @throws Exception on database errors */ - @Before - public void setupDao() throws Exception { + @BeforeEach + void setupDao() throws Exception { final DaoParameters daoParameters = new DaoParameters(); daoParameters.setPluginClass(DefaultPfDao.class.getName()); @@ -89,13 +89,13 @@ public class SimpleToscaServiceTemplateProviderTest { pfDao.init(daoParameters); } - @After - public void teardown() { + @AfterEach + void teardown() { pfDao.close(); } @Test - public void testCreateUpdateGetDeleteDataType() throws PfModelException { + void testCreateUpdateGetDeleteDataType() throws PfModelException { JpaToscaServiceTemplate serviceTemplate = new JpaToscaServiceTemplate(); serviceTemplate.setMetadata(new TreeMap<String, String>()); @@ -166,7 +166,7 @@ public class SimpleToscaServiceTemplateProviderTest { } @Test - public void testNonNulls() { + void testNonNulls() { assertThatThrownBy(() -> { new SimpleToscaServiceTemplateProvider().write(null, null); }).hasMessageMatching(DAO_IS_NULL); diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/serialization/MonitoringPolicySerializationTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/serialization/MonitoringPolicySerializationTest.java index 4e491fde3..18e011f38 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/serialization/MonitoringPolicySerializationTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/serialization/MonitoringPolicySerializationTest.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2019-2020 Nordix Foundation. * Copyright (C) 2019-2020,2022 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.tosca.simple.serialization; 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.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 com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.common.utils.coder.YamlJsonTranslator; @@ -50,7 +51,7 @@ import org.yaml.snakeyaml.Yaml; * @author Liam Fallon (liam.fallon@est.tech) * @author Chenfei Gao (cgao@research.att.com) */ -public class MonitoringPolicySerializationTest { +class MonitoringPolicySerializationTest { private static final String VERSION = "version"; @@ -96,7 +97,7 @@ public class MonitoringPolicySerializationTest { private final YamlJsonTranslator yamlJsonTranslator = new YamlJsonTranslator(); @Test - public void testDeserialization() throws Exception { + void testDeserialization() throws Exception { String policyTypeInputJson = ResourceUtils.getResourceAsString("policytypes/onap.policies.monitoring.tcagen2.yaml"); ToscaServiceTemplate plainPolicyTypes = @@ -133,7 +134,7 @@ public class MonitoringPolicySerializationTest { } @Test - public void testSerialization() { + void testSerialization() { assertThatCode(() -> { // vCPE JpaToscaServiceTemplate serviceTemplate = deserializeMonitoringInputJson(VCPE_MON_INPUT_JSON); diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/serialization/MonitoringPolicyTypeSerializationTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/serialization/MonitoringPolicyTypeSerializationTest.java index f1999bee3..86b07c722 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/serialization/MonitoringPolicyTypeSerializationTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/serialization/MonitoringPolicyTypeSerializationTest.java @@ -21,15 +21,15 @@ package org.onap.policy.models.tosca.simple.serialization; -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.util.Iterator; import java.util.Map; import java.util.Map.Entry; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.common.utils.resources.ResourceUtils; @@ -50,7 +50,7 @@ import org.yaml.snakeyaml.Yaml; * * @author Chenfei Gao (cgao@research.att.com) */ -public class MonitoringPolicyTypeSerializationTest { +class MonitoringPolicyTypeSerializationTest { private static final String DATATYPE_ROOT = "tosca.datatypes.Root"; @@ -81,13 +81,13 @@ public class MonitoringPolicyTypeSerializationTest { private StandardCoder coder; - @Before - public void setUp() { + @BeforeEach + void setUp() { coder = new StandardCoder(); } @Test - public void testDeserialization() throws Exception { + void testDeserialization() throws Exception { // TCA v1 JpaToscaServiceTemplate serviceTemplateFromYaml = deserializeMonitoringInputYaml(MONITORING_TCA_YAML); verifyTcaInputDeserialization(serviceTemplateFromYaml, VERSION_100, TCA_V1); @@ -102,7 +102,7 @@ public class MonitoringPolicyTypeSerializationTest { } @Test - public void testSerialization() throws Exception { + void testSerialization() throws Exception { // TCA v1 JpaToscaServiceTemplate tcaServiceTemplateFromYaml = deserializeMonitoringInputYaml(MONITORING_TCA_YAML); String serializedServiceTemplateTca = serializeMonitoringServiceTemplate(tcaServiceTemplateFromYaml); diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/serialization/OptimizationPolicyTypeSerializationTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/serialization/OptimizationPolicyTypeSerializationTest.java index ba486035c..4ddae1c5c 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/serialization/OptimizationPolicyTypeSerializationTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/serialization/OptimizationPolicyTypeSerializationTest.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2019 AT&T Intellectual Property. 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. @@ -19,15 +19,16 @@ package org.onap.policy.models.tosca.simple.serialization; -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.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.List; import java.util.Map; import org.apache.commons.collections4.MapUtils; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.common.utils.resources.ResourceUtils; @@ -40,7 +41,7 @@ import org.onap.policy.models.tosca.simple.concepts.JpaToscaProperty; import org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate; import org.yaml.snakeyaml.Yaml; -public class OptimizationPolicyTypeSerializationTest { +class OptimizationPolicyTypeSerializationTest { private static final String TYPE_ROOT = "tosca.policies.Root"; private static final String VERSION = "1.0.0"; @@ -52,13 +53,13 @@ public class OptimizationPolicyTypeSerializationTest { private StandardCoder coder; - @Before - public void setUp() { + @BeforeEach + void setUp() { coder = new StandardCoder(); } @Test - public void testOptimization() throws CoderException { + void testOptimization() throws CoderException { JpaToscaServiceTemplate svctmpl = loadYaml(INPUT_OPTIMIZATION_YAML); validate("initial object", svctmpl, TYPE_ROOT, "onap.policies.Optimization", false, false); @@ -70,7 +71,7 @@ public class OptimizationPolicyTypeSerializationTest { } @Test - public void testOptimizationResource() throws CoderException { + void testOptimizationResource() throws CoderException { JpaToscaServiceTemplate svctmpl = loadYaml(INPUT_OPTIMIZATION_RESOURCE_YAML); validate("initial object", svctmpl, "onap.policies.Optimization", "onap.policies.optimization.Resource", true, true); @@ -83,7 +84,7 @@ public class OptimizationPolicyTypeSerializationTest { } @Test - public void testOptimizationService() throws CoderException { + void testOptimizationService() throws CoderException { JpaToscaServiceTemplate svctmpl = loadYaml(INPUT_OPTIMIZATION_SERVICE_YAML); validate("initial object", svctmpl, "onap.policies.Optimization", "onap.policies.optimization.Service", false, true); @@ -120,17 +121,17 @@ public class OptimizationPolicyTypeSerializationTest { boolean checkResource, boolean checkService) { JpaToscaPolicyTypes policyTypes = svctmpl.getPolicyTypes(); - assertEquals(testnm + " type count", 1, policyTypes.getConceptMap().size()); + assertEquals(1, policyTypes.getConceptMap().size(), testnm + " type count"); JpaToscaPolicyType policyType = policyTypes.getConceptMap().values().iterator().next(); - assertEquals(testnm + " name", typeName, policyType.getName()); - assertEquals(testnm + " version", VERSION, policyType.getVersion()); + assertEquals(typeName, policyType.getName(), testnm + " name"); + assertEquals(VERSION, policyType.getVersion(), testnm + " version"); - assertNotNull(testnm + " derived from", policyType.getDerivedFrom()); - assertEquals(testnm + " derived from name", derivedFrom, policyType.getDerivedFrom().getName()); + assertNotNull(String.valueOf(policyType.getDerivedFrom()), testnm + " derived from"); + assertEquals(derivedFrom, policyType.getDerivedFrom().getName(), testnm + " derived from name"); Map<String, JpaToscaProperty> props = policyType.getProperties(); - assertNotNull(testnm + " properties", props); + assertNotNull(props.toString(), testnm + " properties"); if (checkResource && checkService) { validateResources(testnm, props.get("resources")); @@ -149,59 +150,59 @@ public class OptimizationPolicyTypeSerializationTest { private void validateScope(String testName, JpaToscaProperty prop) { String testnm = testName + " scope"; - assertNotNull(testnm, prop); + assertNotNull(prop, testnm); validateMatchable(testnm, prop.getMetadata()); } private void validateServices(String testName, JpaToscaProperty prop) { String testnm = testName + " services"; - assertNotNull(testnm, prop); + assertNotNull(prop, testnm); validateMatchable(testnm, prop.getMetadata()); } private void validateResources(String testName, JpaToscaProperty prop) { String testnm = testName + " resources"; - assertNotNull(testnm, prop); + assertNotNull(prop, testnm); validateMatchable(testnm, prop.getMetadata()); } private void validateGeography(String testName, JpaToscaProperty prop) { String testnm = testName + " geography"; - assertNotNull(testnm, prop); + assertNotNull(prop, testnm); // this line results in a stack overflow // assertEquals(testnm + " name", "geography", prop.getName()); - assertEquals(testnm + " description", "One or more geographic regions", prop.getDescription()); - assertEquals(testnm + " type", "list", prop.getType().getName()); + assertEquals("One or more geographic regions", prop.getDescription(), testnm + " description"); + assertEquals("list", prop.getType().getName(), testnm + " description"); validateMatchable(testnm, prop.getMetadata()); - assertTrue(testnm + " required", prop.isRequired()); - assertEquals(testnm + " entry_schema", "string", prop.getEntrySchema().getType().getName()); + assertTrue(prop.isRequired(), testnm + " required"); + assertEquals("string", prop.getEntrySchema().getType().getName(), testnm + " description"); List<JpaToscaConstraint> constraints = prop.getEntrySchema().getConstraints(); - assertNotNull(testnm + " constraints", constraints); + assertNotNull(constraints, testnm + " constraints"); - assertEquals(testnm + " constraint size", 1, constraints.size()); - assertTrue(testnm + " constraint type", constraints.get(0) instanceof JpaToscaConstraintValidValues); + assertEquals(1, constraints.size(), testnm + " constraint size"); + assertInstanceOf(JpaToscaConstraintValidValues.class, constraints.get(0), testnm + " constraint type"); JpaToscaConstraintValidValues constraint = (JpaToscaConstraintValidValues) constraints.get(0); - assertEquals(testnm + " valid values", "[US, International]", constraint.getValidValues().toString()); + assertEquals("[US, International]", constraint.getValidValues().toString(), testnm + " valid values"); } private void validateIdentity(String testName, JpaToscaProperty prop) { String testnm = testName + " identity"; - assertNotNull(testnm, prop); - assertEquals(testnm + " metadata", true, MapUtils.isEmpty(prop.getMetadata())); + assertNotNull(prop, testnm); + assertTrue(MapUtils.isEmpty(prop.getMetadata()), testnm + " metadata"); } private void validateMatchable(String testName, Map<String, String> metadata) { String testnm = testName + " matchable"; - assertNotNull(testnm + " metadata", metadata); - assertEquals(testnm + " value", "true", metadata.get("matchable")); + assertNotNull(metadata, testnm + " metadata"); + assertEquals("true", metadata.get("matchable"), testnm + " value"); } } diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/utils/ToscaServiceTemplateUtilsTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/utils/ToscaServiceTemplateUtilsTest.java index 675ec3258..0f5e7abcb 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/utils/ToscaServiceTemplateUtilsTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/utils/ToscaServiceTemplateUtilsTest.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2020-2021 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,10 +23,10 @@ package org.onap.policy.models.tosca.utils; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.Iterator; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.Validated; import org.onap.policy.models.tosca.simple.concepts.JpaToscaDataType; @@ -42,9 +43,9 @@ import org.onap.policy.models.tosca.simple.concepts.JpaToscaTopologyTemplate; * * @author Liam Fallon (liam.fallon@est.tech) */ -public class ToscaServiceTemplateUtilsTest { +class ToscaServiceTemplateUtilsTest { @Test - public void testAddFragmentNulls() { + void testAddFragmentNulls() { assertThatThrownBy(() -> { ToscaServiceTemplateUtils.addFragment(null, null); }).hasMessageMatching("originalTemplate is marked .*on.*ull but is null"); @@ -62,7 +63,7 @@ public class ToscaServiceTemplateUtilsTest { } @Test - public void testAddFragment() { + void testAddFragment() { JpaToscaServiceTemplate originalTemplate = new JpaToscaServiceTemplate(); JpaToscaServiceTemplate fragmentTemplate00 = new JpaToscaServiceTemplate(); diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/utils/ToscaUtilsTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/utils/ToscaUtilsTest.java index a40e9c298..9e655909b 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/utils/ToscaUtilsTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/utils/ToscaUtilsTest.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2019-2021 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,12 +25,12 @@ package org.onap.policy.models.tosca.utils; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatCode; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -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.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.common.parameters.BeanValidationResult; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfKey; @@ -46,10 +47,10 @@ import org.onap.policy.models.tosca.simple.concepts.JpaToscaTopologyTemplate; * * @author Liam Fallon (liam.fallon@est.tech) */ -public class ToscaUtilsTest { +class ToscaUtilsTest { @Test - public void testAssertDataTypes() { + void testAssertDataTypes() { JpaToscaServiceTemplate jpaToscaServiceTemplate = new JpaToscaServiceTemplate(); assertFalse(ToscaUtils.doDataTypesExist(jpaToscaServiceTemplate)); @@ -79,7 +80,7 @@ public class ToscaUtilsTest { } @Test - public void testAssertPolicyTypes() { + void testAssertPolicyTypes() { JpaToscaServiceTemplate jpaToscaServiceTemplate = new JpaToscaServiceTemplate(); assertFalse(ToscaUtils.doPolicyTypesExist(jpaToscaServiceTemplate)); @@ -108,7 +109,7 @@ public class ToscaUtilsTest { } @Test - public void testAssertPolicies() { + void testAssertPolicies() { JpaToscaServiceTemplate jpaToscaServiceTemplate = new JpaToscaServiceTemplate(); assertFalse(ToscaUtils.doPoliciesExist(jpaToscaServiceTemplate)); @@ -146,7 +147,7 @@ public class ToscaUtilsTest { } @Test - public void testGetentityTypeAncestors() { + void testGetentityTypeAncestors() { assertThatThrownBy(() -> { ToscaUtils.getEntityTypeAncestors(null, null, null); }).hasMessageMatching("entityTypes is marked .*on.*ull but is null"); @@ -177,7 +178,7 @@ public class ToscaUtilsTest { } @Test - public void testGetentityTypeAncestorsDataType() { + void testGetentityTypeAncestorsDataType() { JpaToscaDataTypes dataTypes = new JpaToscaDataTypes(); JpaToscaDataType dt0 = new JpaToscaDataType(); @@ -267,12 +268,12 @@ public class ToscaUtilsTest { } @Test - public void testGetPredefinedDataTypes() { + void testGetPredefinedDataTypes() { assertTrue(ToscaUtils.getPredefinedDataTypes().contains(new PfConceptKey("string", PfKey.NULL_KEY_VERSION))); } @Test - public void testgetEntityTree() { + void testgetEntityTree() { assertThatThrownBy(() -> { ToscaUtils.getEntityTree(null, null, null); }).hasMessageMatching("entityTypes is marked .*on.*ull but is null"); |