From 09f9bc016598cb287c681418203852b0b619e931 Mon Sep 17 00:00:00 2001 From: waynedunican Date: Thu, 13 Jun 2024 09:27:35 +0100 Subject: Convert models to JUnit 5 Review for models-pap, models-pdp and models-provider Issue-ID: POLICY-5042 Change-Id: Ic00d60127f11472f585e4cbda2b2272c220cd225 Signed-off-by: waynedunican --- .../models/pdp/concepts/DeploymentGroupTest.java | 25 ++-- .../models/pdp/concepts/DeploymentGroupsTest.java | 15 +-- .../pdp/concepts/DeploymentSubGroupTest.java | 20 ++-- .../policy/models/pdp/concepts/ModelsTest.java | 8 +- .../concepts/PdpEngineWorkerStatisticsTest.java | 12 +- .../models/pdp/concepts/PdpGroupFilterTest.java | 32 ++--- .../policy/models/pdp/concepts/PdpGroupTest.java | 28 ++--- .../policy/models/pdp/concepts/PdpGroupsTest.java | 20 ++-- .../pdp/concepts/PdpInstanceDetailsTest.java | 9 +- .../policy/models/pdp/concepts/PdpMessageTest.java | 132 +++++++++------------ .../pdp/concepts/PdpResponseDetailsTest.java | 9 +- .../models/pdp/concepts/PdpStateChangeTest.java | 10 +- .../policy/models/pdp/concepts/PdpStatusTest.java | 10 +- .../models/pdp/concepts/PdpSubGroupTest.java | 22 ++-- .../models/pdp/concepts/PdpTopicCheckTest.java | 9 +- .../policy/models/pdp/concepts/PdpUpdateTest.java | 12 +- .../pdp/persistence/concepts/JpaPdpGroupTest.java | 28 ++--- .../concepts/JpaPdpPolicyStatusTest.java | 33 +++--- .../persistence/concepts/JpaPdpSubGroupTest.java | 28 ++--- .../pdp/persistence/concepts/JpaPdpTest.java | 26 ++-- .../provider/PdpFilterParametersTest.java | 7 +- .../pdp/persistence/provider/PdpProviderTest.java | 62 +++++----- 22 files changed, 275 insertions(+), 282 deletions(-) (limited to 'models-pdp') diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/DeploymentGroupTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/DeploymentGroupTest.java index e3438acb9..202ab69d7 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/DeploymentGroupTest.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/DeploymentGroupTest.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. @@ -21,30 +22,30 @@ package org.onap.policy.models.pdp.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.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.assertNotEquals; +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 java.util.Arrays; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.common.parameters.ValidationResult; import org.onap.policy.models.pdp.concepts.DeploymentSubGroup.Action; /** * Test methods not tested by {@link ModelsTest}. */ -public class DeploymentGroupTest { +class DeploymentGroupTest { private static final String NAME = "my-name"; private static final String PDP_TYPE1 = "type-1"; private static final String PDP_TYPE2 = "type-2"; private static final String PDP_TYPE3 = "type-3"; @Test - public void testCopyConstructor() { + void testCopyConstructor() { assertThatThrownBy(() -> new DeploymentGroup(null)).isInstanceOf(NullPointerException.class); DeploymentGroup orig = new DeploymentGroup(); @@ -66,7 +67,7 @@ public class DeploymentGroupTest { } @Test - public void testHashCode() { + void testHashCode() { DeploymentGroup group = new DeploymentGroup(); group.setName("A"); int hash = group.hashCode(); @@ -78,7 +79,7 @@ public class DeploymentGroupTest { } @Test - public void testValidatePapRest() { + void testValidatePapRest() { DeploymentGroup group = new DeploymentGroup(); group.setName(NAME); @@ -127,7 +128,7 @@ public class DeploymentGroupTest { } @Test - public void testCheckDuplicateSubgroups() { + void testCheckDuplicateSubgroups() { DeploymentGroup group = new DeploymentGroup(); group.setName(NAME); diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/DeploymentGroupsTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/DeploymentGroupsTest.java index 18b13759a..bc3da4870 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/DeploymentGroupsTest.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/DeploymentGroupsTest.java @@ -3,6 +3,7 @@ * ONAP Policy Models * ================================================================================ * 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. @@ -20,21 +21,21 @@ package org.onap.policy.models.pdp.concepts; -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.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 java.util.Arrays; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.common.parameters.ValidationResult; import org.onap.policy.models.pdp.concepts.DeploymentSubGroup.Action; -public class DeploymentGroupsTest { +class DeploymentGroupsTest { @Test - public void testValidatePapRest_toMapList() { + void testValidatePapRest_toMapList() { DeploymentGroup group1 = new DeploymentGroup(); group1.setName("group-1"); diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/DeploymentSubGroupTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/DeploymentSubGroupTest.java index 744c2e892..7b87a5c63 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/DeploymentSubGroupTest.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/DeploymentSubGroupTest.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,14 +22,14 @@ package org.onap.policy.models.pdp.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 java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.common.parameters.ValidationResult; import org.onap.policy.common.utils.coder.Coder; import org.onap.policy.common.utils.coder.CoderException; @@ -40,12 +40,12 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; /** * Test methods not tested by {@link ModelsTest}. */ -public class DeploymentSubGroupTest { +class DeploymentSubGroupTest { private static final String VERSION_300 = "3.0.0"; private static final Coder coder = new StandardCoder(); @Test - public void testCopyConstructor() { + void testCopyConstructor() { assertThatThrownBy(() -> new DeploymentSubGroup(null)).isInstanceOf(NullPointerException.class); final DeploymentSubGroup orig = new DeploymentSubGroup(); @@ -69,7 +69,7 @@ public class DeploymentSubGroupTest { } @Test - public void testValidatePapRest() throws Exception { + void testValidatePapRest() throws Exception { DeploymentSubGroup subgrp = new DeploymentSubGroup(); subgrp.setPdpType("pdp-type"); diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/ModelsTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/ModelsTest.java index 95af26588..3a9a715b7 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/ModelsTest.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/ModelsTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019-2024 Nordix Foundation. * Modifications Copyright (C) 2019 AT&T Intellectual Property. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -27,7 +27,7 @@ import com.openpojo.validation.Validator; import com.openpojo.validation.ValidatorBuilder; 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; /** @@ -35,11 +35,11 @@ import org.onap.policy.common.utils.test.ToStringTester; * * @author Ram Krishna Verma (ram.krishna.verma@est.tech) */ -public class ModelsTest { +class ModelsTest { private static final String POJO_PACKAGE = "org.onap.policy.models.pdp.concepts"; @Test - public void testPdpModels() { + void testPdpModels() { final Validator validator = ValidatorBuilder.create().with(new ToStringTester()).with(new SetterTester()) .with(new GetterTester()).build(); diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpEngineWorkerStatisticsTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpEngineWorkerStatisticsTest.java index b748b915c..c438d9e76 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpEngineWorkerStatisticsTest.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpEngineWorkerStatisticsTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix Foundation. + * Copyright (C) 2020-2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,16 +21,16 @@ package org.onap.policy.models.pdp.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.time.Instant; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.models.pdp.enums.PdpEngineWorkerState; -public class PdpEngineWorkerStatisticsTest { +class PdpEngineWorkerStatisticsTest { @Test - public void testCopyConstructor() { + void testCopyConstructor() { assertThatThrownBy(() -> new PdpEngineWorkerStatistics(null)).hasMessageContaining("source"); PdpEngineWorkerStatistics stat = createPdpEngineWorkerStatistics(); @@ -39,7 +39,7 @@ public class PdpEngineWorkerStatisticsTest { } @Test - public void testClean() { + void testClean() { PdpEngineWorkerStatistics stat = createPdpEngineWorkerStatistics(); stat.setEngineId(" Engine0 "); stat.clean(); diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupFilterTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupFilterTest.java index 89a1333ef..5019afa80 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupFilterTest.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupFilterTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2021 Nordix Foundation. + * Copyright (C) 2019-2024 Nordix Foundation. * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,14 +22,14 @@ package org.onap.policy.models.pdp.concepts; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; -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; @@ -41,7 +41,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; * * @author Liam Fallon (liam.fallon@est.tech) */ -public class PdpGroupFilterTest { +class PdpGroupFilterTest { private static final String POLICY_TYPE3 = "policy.type.3"; private static final String POLICY_TYPE2 = "policy.type.2"; private static final String POLICY_TYPE1 = "policy.type.1"; @@ -63,15 +63,15 @@ public class PdpGroupFilterTest { * * @throws CoderException on JSON decoding errors */ - @Before - public void setupPdpGroupList() throws CoderException { + @BeforeEach + void setupPdpGroupList() throws CoderException { String originalJson = ResourceUtils.getResourceAsString("testdata/PdpGroupsForFiltering.json"); PdpGroups pdpGroups = new StandardCoder().decode(originalJson, PdpGroups.class); pdpGroupList = pdpGroups.getGroups(); } @Test - public void testNullList() { + void testNullList() { PdpGroupFilter filter = PdpGroupFilter.builder().build(); assertThatThrownBy(() -> { @@ -80,7 +80,7 @@ public class PdpGroupFilterTest { } @Test - public void testFilterNothing() { + void testFilterNothing() { PdpGroupFilter filter = PdpGroupFilter.builder().build(); List filteredList = filter.filter(pdpGroupList); @@ -88,7 +88,7 @@ public class PdpGroupFilterTest { } @Test - public void testFilterName() { + void testFilterName() { PdpGroupFilter filter = PdpGroupFilter.builder().name("PdpGroup0").build(); List filteredList = filter.filter(pdpGroupList); assertEquals(1, filteredList.size()); @@ -115,7 +115,7 @@ public class PdpGroupFilterTest { } @Test - public void testFilterPdpGroupState() { + void testFilterPdpGroupState() { PdpGroupFilter filter = PdpGroupFilter.builder().groupState(PdpState.ACTIVE).build(); List filteredList = filter.filter(pdpGroupList); assertEquals(1, filteredList.size()); @@ -138,7 +138,7 @@ public class PdpGroupFilterTest { } @Test - public void testFilterPdpType() { + void testFilterPdpType() { PdpGroupFilter filter = PdpGroupFilter.builder().pdpType("APEX").build(); List filteredList = filter.filter(pdpGroupList); assertEquals(5, filteredList.size()); @@ -153,7 +153,7 @@ public class PdpGroupFilterTest { } @Test - public void testFilterPdpState() { + void testFilterPdpState() { PdpGroupFilter filter = PdpGroupFilter.builder().pdpState(PdpState.ACTIVE).build(); List filteredList = filter.filter(pdpGroupList); assertEquals(3, filteredList.size()); @@ -172,7 +172,7 @@ public class PdpGroupFilterTest { } @Test - public void testFilterPolicyType() { + void testFilterPolicyType() { List identifierList = new ArrayList<>(); identifierList.add(new ToscaConceptIdentifier(NON_EXISTANT, VERSION1)); @@ -288,7 +288,7 @@ public class PdpGroupFilterTest { } @Test - public void testFilterPolicy() { + void testFilterPolicy() { List identifierList = new ArrayList<>(); identifierList.add(new ToscaConceptIdentifier(NON_EXISTANT, VERSION1)); diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupTest.java index ae88f50f9..f5cdecfea 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupTest.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupTest.java @@ -3,7 +3,7 @@ * ONAP Policy Models * ================================================================================ * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019-2021 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. @@ -22,12 +22,12 @@ package org.onap.policy.models.pdp.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.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.assertNotEquals; +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 java.util.ArrayList; import java.util.Arrays; @@ -35,7 +35,7 @@ import java.util.Collections; 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.ValidationResult; import org.onap.policy.models.pdp.enums.PdpState; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; @@ -43,7 +43,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; /** * Test methods not tested by {@link ModelsTest}. */ -public class PdpGroupTest { +class PdpGroupTest { private static final String VERSION = "1.2.3"; private static final String NAME = "my-name"; private static final String PDP_TYPE1 = "type-1"; @@ -51,7 +51,7 @@ public class PdpGroupTest { private static final String PDP_TYPE3 = "type-3"; @Test - public void testCopyConstructor() { + void testCopyConstructor() { assertThatThrownBy(() -> new PdpGroup(null)).isInstanceOf(NullPointerException.class); PdpGroup orig = new PdpGroup(); @@ -87,7 +87,7 @@ public class PdpGroupTest { } @Test - public void testHashCode() { + void testHashCode() { PdpGroup group = new PdpGroup(); group.setDescription("A"); int hash = group.hashCode(); @@ -99,7 +99,7 @@ public class PdpGroupTest { } @Test - public void testCompareTo() { + void testCompareTo() { PdpGroup pdpGroup0 = new PdpGroup(); pdpGroup0.setName("Name0"); pdpGroup0.setVersion(VERSION); @@ -122,7 +122,7 @@ public class PdpGroupTest { } @Test - public void testValidatePapRest_GroupUpdateFlow() { + void testValidatePapRest_GroupUpdateFlow() { PdpGroup group = new PdpGroup(); group.setName(NAME); // with supported policy type and policies @@ -158,7 +158,7 @@ public class PdpGroupTest { } @Test - public void testValidatePapRest() { + void testValidatePapRest() { PdpGroup group = new PdpGroup(); group.setName(NAME); diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupsTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupsTest.java index 5cf7c1340..09d94d09f 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupsTest.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupsTest.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. @@ -21,26 +21,26 @@ package org.onap.policy.models.pdp.concepts; -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.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.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.Arrays; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.common.parameters.ValidationResult; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -public class PdpGroupsTest { +class PdpGroupsTest { @Test - public void testValidatePapRest_toMapList() { + void testValidatePapRest_toMapList() { PdpGroup group1 = new PdpGroup(); group1.setName("group-1"); diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpInstanceDetailsTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpInstanceDetailsTest.java index e1c76671a..5caa4e5d4 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpInstanceDetailsTest.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpInstanceDetailsTest.java @@ -3,6 +3,7 @@ * ONAP Policy Models * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Copyright * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,19 +22,19 @@ package org.onap.policy.models.pdp.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; import org.onap.policy.models.pdp.enums.PdpHealthStatus; import org.onap.policy.models.pdp.enums.PdpState; /** * Test the copy constructor, as {@link ModelsTest} tests the other methods. */ -public class PdpInstanceDetailsTest { +class PdpInstanceDetailsTest { @Test - public void testCopyConstructor() { + void testCopyConstructor() { assertThatThrownBy(() -> new Pdp(null)).isInstanceOf(NullPointerException.class); Pdp orig = new Pdp(); diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpMessageTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpMessageTest.java index 763b29a4b..50b211d58 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpMessageTest.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpMessageTest.java @@ -3,7 +3,7 @@ * ONAP Policy Models * ================================================================================ * 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. @@ -22,15 +22,16 @@ package org.onap.policy.models.pdp.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.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.BeforeEach; +import org.junit.jupiter.api.Test; import org.onap.policy.models.pdp.enums.PdpMessageType; -public class PdpMessageTest { +class PdpMessageTest { private static final String PDP_GROUP_MSG = " pdp group "; private static final String PDP_NAME = "pdpA"; private static final String PDP_GROUP = "groupA"; @@ -39,47 +40,47 @@ public class PdpMessageTest { private PdpMessage message; + @BeforeEach + void setUp() { + message = new PdpMessage(PdpMessageType.PDP_STATE_CHANGE); + } + @Test - public void testCopyConstructorAndEquals() { + void testCopyConstructorAndEquals() { assertThatThrownBy(() -> new PdpMessage((PdpMessage) null)).isInstanceOf(NullPointerException.class); - // verify with null values - message = new PdpMessage(PdpMessageType.PDP_STATE_CHANGE); - PdpMessage newmsg = new PdpMessage(message); - newmsg.setRequestId(message.getRequestId()); - newmsg.setTimestampMs(message.getTimestampMs()); - assertEquals(message.toString(), newmsg.toString()); - assertEquals(message, newmsg); + // Verify with null values + PdpMessage newMsg = new PdpMessage(message); + newMsg.setRequestId(message.getRequestId()); + newMsg.setTimestampMs(message.getTimestampMs()); + assertEquals(message.toString(), newMsg.toString()); + assertEquals(message, newMsg); - // verify with all values + // Verify with all values message = makeMessage(PDP_NAME, PDP_GROUP, PDP_SUBGROUP); - newmsg = new PdpMessage(message); - newmsg.setRequestId(message.getRequestId()); - newmsg.setTimestampMs(message.getTimestampMs()); - assertEquals(message.toString(), newmsg.toString()); - assertEquals(message, newmsg); - - newmsg.setTimestampMs(1); - assertNotEquals(message, newmsg); + newMsg = new PdpMessage(message); + newMsg.setRequestId(message.getRequestId()); + newMsg.setTimestampMs(message.getTimestampMs()); + assertEquals(message.toString(), newMsg.toString()); + assertEquals(message, newMsg); + + newMsg.setTimestampMs(1); + assertNotEquals(message, newMsg); } @Test - public void testAppliesTo_NameCombos() { - /* - * Test cases where the name matches. - */ - for (String msgGroup : new String[] {null, PDP_GROUP, DIFFERENT}) { - for (String msgSubgroup : new String[] {null, PDP_SUBGROUP, DIFFERENT}) { + void testAppliesTo_NameCombos() { + // Test cases where the name matches. + for (String msgGroup : new String[]{null, PDP_GROUP, DIFFERENT}) { + for (String msgSubgroup : new String[]{null, PDP_SUBGROUP, DIFFERENT}) { message = makeMessage(PDP_NAME, msgGroup, msgSubgroup); testName(PDP_NAME, true); } } - /* - * Test cases where the name does not match. - */ - for (String msgGroup : new String[] {null, PDP_GROUP, DIFFERENT}) { - for (String msgSubgroup : new String[] {null, PDP_SUBGROUP, DIFFERENT}) { + // Test cases where the name does not match. + for (String msgGroup : new String[]{null, PDP_GROUP, DIFFERENT}) { + for (String msgSubgroup : new String[]{null, PDP_SUBGROUP, DIFFERENT}) { message = makeMessage(PDP_NAME, msgGroup, msgSubgroup); testName(DIFFERENT, false); } @@ -87,75 +88,60 @@ public class PdpMessageTest { } private void testName(String pdpName, boolean expectMatch) { - for (String pdpGroup : new String[] {null, PDP_GROUP, DIFFERENT}) { - for (String pdpSubgroup : new String[] {null, PDP_SUBGROUP, DIFFERENT}) { - assertEquals("name msg " + message + PDP_GROUP_MSG + pdpGroup + "/" + pdpSubgroup, expectMatch, - message.appliesTo(pdpName, pdpGroup, pdpSubgroup)); + for (String pdpGroup : new String[]{null, PDP_GROUP, DIFFERENT}) { + for (String pdpSubgroup : new String[]{null, PDP_SUBGROUP, DIFFERENT}) { + assertEquals(expectMatch, message.appliesTo(pdpName, pdpGroup, pdpSubgroup), + "name msg " + message + PDP_GROUP_MSG + pdpGroup + "/" + pdpSubgroup); } } } @Test - public void testAppliesTo_BroadcastGroup() { - /* - * Test cases where the group matches. - */ - for (String msgSubgroup : new String[] {null, PDP_SUBGROUP}) { + void testAppliesTo_BroadcastGroup() { + // Test cases where the group matches. + for (String msgSubgroup : new String[]{null, PDP_SUBGROUP}) { message = makeMessage(null, PDP_GROUP, msgSubgroup); - - assertTrue("group msg " + message, message.appliesTo(PDP_NAME, PDP_GROUP, PDP_SUBGROUP)); + assertTrue(message.appliesTo(PDP_NAME, PDP_GROUP, PDP_SUBGROUP), "group msg " + message); } - /* - * Test cases where the group does not match. - */ - for (String msgGroup : new String[] {null, PDP_GROUP}) { - for (String msgSubgroup : new String[] {null, PDP_SUBGROUP}) { + // Test cases where the group does not match. + for (String msgGroup : new String[]{null, PDP_GROUP}) { + for (String msgSubgroup : new String[]{null, PDP_SUBGROUP}) { message = makeMessage(null, msgGroup, msgSubgroup); - - for (String pdpGroup : new String[] {null, DIFFERENT}) { - assertFalse("group msg " + message + PDP_GROUP_MSG + pdpGroup, - message.appliesTo(PDP_NAME, pdpGroup, PDP_SUBGROUP)); + for (String pdpGroup : new String[]{null, DIFFERENT}) { + assertFalse(message.appliesTo(PDP_NAME, pdpGroup, PDP_SUBGROUP), + "group msg " + message + PDP_GROUP_MSG + pdpGroup); } } } } @Test - public void testAppliesTo_BroadcastSubGroup() { - /* - * Test cases where the subgroup matches. - */ + void testAppliesTo_BroadcastSubGroup() { + // Test cases where the subgroup matches. message = makeMessage(null, PDP_GROUP, PDP_SUBGROUP); - assertTrue("subgroup msg " + message, message.appliesTo(PDP_NAME, PDP_GROUP, PDP_SUBGROUP)); + assertTrue(message.appliesTo(PDP_NAME, PDP_GROUP, PDP_SUBGROUP), "subgroup msg " + message); - /* - * Test cases where the subgroup does not match. - */ + // Test cases where the subgroup does not match. message = makeMessage(null, PDP_GROUP, PDP_SUBGROUP); - - for (String pdpSubgroup : new String[] {null, DIFFERENT}) { - assertFalse("subgroup msg " + message + " pdp subgroup " + pdpSubgroup, - message.appliesTo(PDP_NAME, PDP_GROUP, pdpSubgroup)); + for (String pdpSubgroup : new String[]{null, DIFFERENT}) { + assertFalse(message.appliesTo(PDP_NAME, PDP_GROUP, pdpSubgroup), + "subgroup msg " + message + " pdp subgroup " + pdpSubgroup); } } @Test - public void testAppliesTo_NullPdpName() { + void testAppliesTo_NullPdpName() { message = makeMessage(PDP_NAME, PDP_GROUP, PDP_SUBGROUP); - assertThatThrownBy(() -> message.appliesTo(null, PDP_GROUP, PDP_SUBGROUP)) - .isInstanceOf(NullPointerException.class); - + .isInstanceOf(NullPointerException.class); } private PdpMessage makeMessage(String pdpName, String pdpGroup, String pdpSubgroup) { PdpMessage msg = new PdpMessage(PdpMessageType.PDP_STATE_CHANGE); - msg.setName(pdpName); msg.setPdpGroup(pdpGroup); msg.setPdpSubgroup(pdpSubgroup); - return msg; } } diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpResponseDetailsTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpResponseDetailsTest.java index f21a0a5bb..617cb651b 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpResponseDetailsTest.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpResponseDetailsTest.java @@ -3,6 +3,7 @@ * ONAP Policy Models * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,16 +22,16 @@ package org.onap.policy.models.pdp.concepts; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.onap.policy.models.pdp.concepts.PdpMessageUtils.removeVariableFields; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.models.pdp.enums.PdpResponseStatus; -public class PdpResponseDetailsTest { +class PdpResponseDetailsTest { @Test - public void testCopyConstructor() { + void testCopyConstructor() { assertThatThrownBy(() -> new PdpResponseDetails(null)).isInstanceOf(NullPointerException.class); PdpResponseDetails orig = new PdpResponseDetails(); diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpStateChangeTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpStateChangeTest.java index aa715b775..9bc9c3451 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpStateChangeTest.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpStateChangeTest.java @@ -3,7 +3,7 @@ * ONAP Policy Models * ================================================================================ * 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. @@ -22,19 +22,19 @@ package org.onap.policy.models.pdp.concepts; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.onap.policy.models.pdp.concepts.PdpMessageUtils.removeVariableFields; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.models.pdp.enums.PdpState; /** * Test the copy constructor, as {@link ModelsTest} tests the other methods. */ -public class PdpStateChangeTest { +class PdpStateChangeTest { @Test - public void testCopyConstructor() { + void testCopyConstructor() { assertThatThrownBy(() -> new PdpStateChange(null)).isInstanceOf(NullPointerException.class); PdpStateChange orig = new PdpStateChange(); diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpStatusTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpStatusTest.java index 07afd4098..89a40995a 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpStatusTest.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpStatusTest.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. * Modifications Copyright (C) 2023 Bell Canada. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,20 +23,20 @@ package org.onap.policy.models.pdp.concepts; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.onap.policy.models.pdp.concepts.PdpMessageUtils.removeVariableFields; import java.util.Arrays; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.models.pdp.enums.PdpHealthStatus; import org.onap.policy.models.pdp.enums.PdpState; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -public class PdpStatusTest { +class PdpStatusTest { @Test - public void testCopyConstructor() { + void testCopyConstructor() { assertThatThrownBy(() -> new PdpStatus(null)).isInstanceOf(NullPointerException.class); final PdpStatus orig = new PdpStatus(); diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpSubGroupTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpSubGroupTest.java index 7d3d4ab92..226d86489 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpSubGroupTest.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpSubGroupTest.java @@ -3,7 +3,7 @@ * ONAP Policy Models * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019-2021 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. @@ -22,17 +22,17 @@ package org.onap.policy.models.pdp.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 java.util.Arrays; import java.util.Collections; import java.util.Map; import java.util.TreeMap; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.common.parameters.ValidationResult; import org.onap.policy.common.utils.coder.Coder; import org.onap.policy.common.utils.coder.CoderException; @@ -42,12 +42,12 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; /** * Test methods not tested by {@link ModelsTest}. */ -public class PdpSubGroupTest { +class PdpSubGroupTest { private static final String VERSION_300 = "3.0.0"; private static final Coder coder = new StandardCoder(); @Test - public void testCopyConstructor() { + void testCopyConstructor() { assertThatThrownBy(() -> new PdpSubGroup(null)).isInstanceOf(NullPointerException.class); final PdpSubGroup orig = new PdpSubGroup(); @@ -90,7 +90,7 @@ public class PdpSubGroupTest { } @Test - public void testValidatePapRest_GroupUpdateFlow() throws Exception { + void testValidatePapRest_GroupUpdateFlow() throws Exception { PdpSubGroup subgrp = new PdpSubGroup(); // with supported policy type and policies subgrp.setDesiredInstanceCount(1); @@ -123,7 +123,7 @@ public class PdpSubGroupTest { } @Test - public void testValidatePapRest() throws Exception { + void testValidatePapRest() throws Exception { PdpSubGroup subgrp = new PdpSubGroup(); subgrp.setDesiredInstanceCount(1); diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpTopicCheckTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpTopicCheckTest.java index 270278ab1..13e090371 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpTopicCheckTest.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpTopicCheckTest.java @@ -3,6 +3,7 @@ * ONAP Policy Models * ================================================================================ * 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,18 +22,18 @@ package org.onap.policy.models.pdp.concepts; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.onap.policy.models.pdp.concepts.PdpMessageUtils.removeVariableFields; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Test the copy constructor, as {@link ModelsTest} tests the other methods. */ -public class PdpTopicCheckTest { +class PdpTopicCheckTest { @Test - public void testCopyConstructor() { + void testCopyConstructor() { assertThatThrownBy(() -> new PdpTopicCheck(null)).isInstanceOf(NullPointerException.class); PdpTopicCheck orig = new PdpTopicCheck(); diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpUpdateTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpUpdateTest.java index 13ee54b52..711d8593c 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpUpdateTest.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpUpdateTest.java @@ -3,7 +3,7 @@ * ONAP Policy Models * ================================================================================ * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019-2021 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. @@ -22,23 +22,23 @@ package org.onap.policy.models.pdp.concepts; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotSame; import static org.onap.policy.models.pdp.concepts.PdpMessageUtils.removeVariableFields; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; /** * Test the copy constructor, as {@link ModelsTest} tests the other methods. */ -public class PdpUpdateTest { +class PdpUpdateTest { @Test - public void testCopyConstructor() { + void testCopyConstructor() { assertThatThrownBy(() -> new PdpUpdate(null)).isInstanceOf(NullPointerException.class); PdpUpdate orig = new PdpUpdate(); diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpGroupTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpGroupTest.java index 060f650fb..95d10365c 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpGroupTest.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpGroupTest.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,17 +22,17 @@ package org.onap.policy.models.pdp.persistence.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.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.assertNotEquals; +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 java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; -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.pdp.concepts.PdpGroup; @@ -44,7 +44,7 @@ import org.onap.policy.models.pdp.testconcepts.DummyJpaPdpSubgroupChild; * * @author Liam Fallon (liam.fallon@est.tech) */ -public class JpaPdpGroupTest { +class JpaPdpGroupTest { private static final String NULL_ERROR = " is marked .*ull but is null"; private static final String NULL_KEY_ERROR = "key" + NULL_ERROR; @@ -52,7 +52,7 @@ public class JpaPdpGroupTest { private static final String VERSION = "1.0.0"; @Test - public void testJpaPdpGroup() { + void testJpaPdpGroup() { assertThatThrownBy(() -> { new JpaPdpGroup((JpaPdpGroup) null); }).hasMessageMatching("copyConcept" + NULL_ERROR); @@ -98,7 +98,7 @@ public class JpaPdpGroupTest { } @Test - public void testPdpGroupSet() { + void testPdpGroupSet() { PdpGroup testPdpGroup = new PdpGroup(); testPdpGroup.setName(PDP_GROUP0); testPdpGroup.setPdpSubgroups(new ArrayList<>()); @@ -125,7 +125,7 @@ public class JpaPdpGroupTest { } @Test - public void testPdpGroupValidation() { + void testPdpGroupValidation() { JpaPdpGroup testJpaPdpGroup = setUpSmallJpaPdpGroup(); assertThatThrownBy(() -> { @@ -162,7 +162,7 @@ public class JpaPdpGroupTest { } @Test - public void testPdpSubgroups() { + void testPdpSubgroups() { JpaPdpGroup testJpaPdpGroup = setUpJpaPdpGroup(); List jpaPdpSubgroups = testJpaPdpGroup.getPdpSubGroups(); @@ -221,7 +221,7 @@ public class JpaPdpGroupTest { } @Test - public void testPdpGroupsProperties() { + void testPdpGroupsProperties() { JpaPdpGroup testJpaPdpGroup = setUpJpaPdpGroup(); testJpaPdpGroup.getProperties().put(" PropKey ", " Prop Value "); diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpPolicyStatusTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpPolicyStatusTest.java index fdadae768..ecc9b81cd 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpPolicyStatusTest.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpPolicyStatusTest.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,15 +23,15 @@ package org.onap.policy.models.pdp.persistence.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.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import java.util.List; import java.util.function.Consumer; import java.util.function.UnaryOperator; import org.assertj.core.api.AbstractStringAssert; -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.PfKey; import org.onap.policy.models.base.PfReferenceKey; import org.onap.policy.models.base.Validated; @@ -39,7 +40,7 @@ import org.onap.policy.models.pdp.concepts.PdpPolicyStatus.PdpPolicyStatusBuilde import org.onap.policy.models.pdp.concepts.PdpPolicyStatus.State; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -public class JpaPdpPolicyStatusTest { +class JpaPdpPolicyStatusTest { private static final String MY_PDP = "MyPdp"; private static final String MY_GROUP = "MyGroup"; private static final String MY_PDP_TYPE = "MyPdpType"; @@ -52,8 +53,8 @@ public class JpaPdpPolicyStatusTest { /** * Set up Policy Status builder. */ - @Before - public void setup() { + @BeforeEach + void setup() { // @formatter:off builder = PdpPolicyStatus.builder() .deploy(true) @@ -67,7 +68,7 @@ public class JpaPdpPolicyStatusTest { } @Test - public void testJpaPdpPolicyStatus() { + void testJpaPdpPolicyStatus() { JpaPdpPolicyStatus jpa = new JpaPdpPolicyStatus(); assertThat(jpa.getKey()).isNotNull(); @@ -81,14 +82,14 @@ public class JpaPdpPolicyStatusTest { } @Test - public void testJpaPdpPolicyStatusJpaPdpPolicyStatus() { + void testJpaPdpPolicyStatusJpaPdpPolicyStatus() { JpaPdpPolicyStatus jpa = new JpaPdpPolicyStatus(builder.build()); assertThat(new JpaPdpPolicyStatus(jpa)).isEqualTo(jpa); } @Test - public void testJpaPdpPolicyStatusPdpPolicyStatus() { + void testJpaPdpPolicyStatusPdpPolicyStatus() { JpaPdpPolicyStatus jpa = new JpaPdpPolicyStatus(builder.build()); assertThat(jpa.getKey()).isNotNull(); @@ -110,14 +111,14 @@ public class JpaPdpPolicyStatusTest { } @Test - public void testGetKeys() { + void testGetKeys() { JpaPdpPolicyStatus jpa = new JpaPdpPolicyStatus(builder.build()); assertThat(jpa.getKeys()).isEqualTo(List.of(jpa.getKey())); } @Test - public void testClean() { + void testClean() { JpaPdpPolicyStatus jpa = new JpaPdpPolicyStatus(builder.pdpGroup(MY_GROUP + " ").pdpType(MY_PDP_TYPE + " ").build()); @@ -129,7 +130,7 @@ public class JpaPdpPolicyStatusTest { @Test @SuppressWarnings("serial") - public void testCompareTo() { + void testCompareTo() { JpaPdpPolicyStatus jpa = new JpaPdpPolicyStatus(builder.build()); assertNotEquals(0, jpa.compareTo(null)); @@ -153,14 +154,14 @@ public class JpaPdpPolicyStatusTest { } @Test - public void testToAuthorative() { + void testToAuthorative() { PdpPolicyStatus data = builder.build(); assertThat(new JpaPdpPolicyStatus(data).toAuthorative()).isEqualTo(data); } @Test - public void testFromAuthorative() { + void testFromAuthorative() { PdpPolicyStatus data = builder.build(); JpaPdpPolicyStatus jpa = new JpaPdpPolicyStatus(); @@ -170,7 +171,7 @@ public class JpaPdpPolicyStatusTest { } @Test - public void testValidate() { + void testValidate() { assertThat(new JpaPdpPolicyStatus(builder.build()).validate("").getResult()).isNull(); assertThatThrownBy(() -> new JpaPdpPolicyStatus(builder.build()).validate(null)) diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroupTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroupTest.java index 566de0d98..5690daa4a 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroupTest.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroupTest.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,17 +23,17 @@ package org.onap.policy.models.pdp.persistence.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.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.assertNotEquals; +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 java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; -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.base.PfSearchableKey; @@ -46,13 +46,13 @@ import org.onap.policy.models.pdp.testconcepts.DummyJpaPdpSubgroupChild; * * @author Liam Fallon (liam.fallon@est.tech) */ -public class JpaPdpSubGroupTest { +class JpaPdpSubGroupTest { private static final String NULL_KEY_ERROR = "key is marked .*ull but is null"; private static final String PDP_A = "PDP-A"; @Test - public void testJpaPdpSubGroupErrors() { + void testJpaPdpSubGroupErrors() { assertThatThrownBy(() -> { new JpaPdpSubGroup((JpaPdpSubGroup) null); }).hasMessageMatching("copyConcept is marked .*ull but is null"); @@ -117,7 +117,7 @@ public class JpaPdpSubGroupTest { } @Test - public void testJpaPdpSubGroup() { + void testJpaPdpSubGroup() { PdpSubGroup testPdpSubgroup = new PdpSubGroup(); testPdpSubgroup.setPdpType(PDP_A); JpaPdpSubGroup testJpaPdpSubGroup = new JpaPdpSubGroup(); @@ -160,7 +160,7 @@ public class JpaPdpSubGroupTest { } @Test - public void testJpaPdpSubGroupSavedKey() { + void testJpaPdpSubGroupSavedKey() { JpaPdpSubGroup testJpaPdpSubGroup = setUpJpaPdpSubGroup(); PfReferenceKey savedKey = testJpaPdpSubGroup.getKey(); @@ -196,7 +196,7 @@ public class JpaPdpSubGroupTest { } @Test - public void testJpaPdpSubGroupPolicyTypes() { + void testJpaPdpSubGroupPolicyTypes() { JpaPdpSubGroup testJpaPdpSubGroup = setUpJpaPdpSubGroup(); List supportedPolicyTypes = testJpaPdpSubGroup.getSupportedPolicyTypes(); @@ -228,7 +228,7 @@ public class JpaPdpSubGroupTest { } @Test - public void testJpaPdpSubGroupKeys() { + void testJpaPdpSubGroupKeys() { JpaPdpSubGroup testJpaPdpSubGroup = setUpJpaPdpSubGroup(); JpaPdpSubGroup otherJpaPdpSubGroup = new JpaPdpSubGroup(testJpaPdpSubGroup); diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpTest.java index ab592f510..395dea3f5 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpTest.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2021 Nordix Foundation. + * Copyright (C) 2019-2024 Nordix Foundation. * Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,14 +23,14 @@ package org.onap.policy.models.pdp.persistence.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.Date; -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.base.Validated; @@ -44,14 +44,14 @@ import org.onap.policy.models.pdp.testconcepts.DummyJpaPdpChild; * * @author Liam Fallon (liam.fallon@est.tech) */ -public class JpaPdpTest { +class JpaPdpTest { private static final String NULL_KEY_ERROR = "key is marked .*ull but is null"; private static final String PDP1 = "ThePDP"; private static final Date CURRENT_DATE = new Date(); @Test - public void testJpaPdp() { + void testJpaPdp() { assertThatThrownBy(() -> { new JpaPdp((JpaPdp) null); }).hasMessageMatching("copyConcept is marked .*ull but is null"); @@ -88,7 +88,7 @@ public class JpaPdpTest { } @Test - public void testJpaPdpInstace() { + void testJpaPdpInstace() { Pdp testPdp = new Pdp(); testPdp.setInstanceId(PDP1); JpaPdp testJpaPdp = new JpaPdp(); @@ -117,7 +117,7 @@ public class JpaPdpTest { } @Test - public void testJpaPdpValidation() { + void testJpaPdpValidation() { Pdp testPdp = new Pdp(); testPdp.setInstanceId(PDP1); JpaPdp testJpaPdp = new JpaPdp(); @@ -155,7 +155,7 @@ public class JpaPdpTest { } @Test - public void testJpaPdpValidationSwapKey() { + void testJpaPdpValidationSwapKey() { JpaPdp testJpaPdp = setUpJpaPdp(); PfReferenceKey savedKey = testJpaPdp.getKey(); @@ -173,7 +173,7 @@ public class JpaPdpTest { } @Test - public void testJpaPdpCompare_testToAuthorative() { + void testJpaPdpCompare_testToAuthorative() { JpaPdp testJpaPdp = setUpJpaPdp(); JpaPdp otherJpaPdp = new JpaPdp(testJpaPdp); diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpFilterParametersTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpFilterParametersTest.java index 58ff7f171..998ccf6af 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpFilterParametersTest.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpFilterParametersTest.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. @@ -23,15 +24,15 @@ package org.onap.policy.models.pdp.persistence.provider; import static org.assertj.core.api.Assertions.assertThat; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class PdpFilterParametersTest { +class PdpFilterParametersTest { private static final String GROUP = "my-group"; private static final String SUBGROUP = "my-subgroup"; @Test - public void testGetFilterMap() { + void testGetFilterMap() { assertThat(PdpFilterParameters.builder().build().getFilterMap()).isNull(); assertThat(PdpFilterParameters.builder().subGroup(SUBGROUP).build().getFilterMap()).isNull(); diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpProviderTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpProviderTest.java index 4c6a46142..85d68ae80 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpProviderTest.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpProviderTest.java @@ -25,17 +25,17 @@ package org.onap.policy.models.pdp.persistence.provider; 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.assertNotEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.ArrayList; import java.util.Collections; import java.util.List; 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.StandardCoder; import org.onap.policy.common.utils.resources.ResourceUtils; import org.onap.policy.models.base.PfModelException; @@ -64,7 +64,7 @@ import org.onap.policy.models.tosca.simple.provider.SimpleToscaProvider; * * @author Liam Fallon (liam.fallon@est.tech) */ -public class PdpProviderTest { +class PdpProviderTest { private static final String PDP_GROUPS0_JSON = "testdata/PdpGroups0.json"; private static final String PDP_TYPE_IS_NULL = "pdpType is marked .*ull but is null"; private static final String SUBGROUP_IS_NULL = "pdpSubGroup is marked .*ull but is null"; @@ -85,8 +85,8 @@ public class PdpProviderTest { * * @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()); @@ -113,29 +113,29 @@ public class PdpProviderTest { /** * Set up GSON. */ - @Before - public void setupGson() { + @BeforeEach + void setupGson() { standardCoder = new StandardCoder(); } /** * Set up Policy Status builder. */ - @Before - public void setupBuilder() { + @BeforeEach + void setupBuilder() { ToscaConceptIdentifier policyType = new ToscaConceptIdentifier("MyPolicyType", "1.2.4"); statusBuilder = PdpPolicyStatus.builder().deploy(true).pdpType("MyPdpType").policy(MY_POLICY) .policyType(policyType).state(State.SUCCESS); } - @After - public void teardown() { + @AfterEach + void teardown() { pfDao.close(); } @Test - public void testGroupsGet() throws Exception { + void testGroupsGet() throws Exception { assertThatThrownBy(() -> { new PdpProvider().getPdpGroups(null, null); }).hasMessageMatching(DAO_IS_NULL); @@ -161,7 +161,7 @@ public class PdpProviderTest { } @Test - public void testFilteredPdpGroupGet() throws Exception { + void testFilteredPdpGroupGet() throws Exception { assertThatThrownBy(() -> { new PdpProvider().getFilteredPdpGroups(null, null); }).hasMessageMatching(DAO_IS_NULL); @@ -201,7 +201,7 @@ public class PdpProviderTest { } @Test - public void testGroupsCreate() throws Exception { + void testGroupsCreate() throws Exception { assertThatThrownBy(() -> { new PdpProvider().createPdpGroups(null, null); }).hasMessageMatching(DAO_IS_NULL); @@ -236,7 +236,7 @@ public class PdpProviderTest { } @Test - public void testGroupsCreateNoPdp() throws Exception { + void testGroupsCreateNoPdp() throws Exception { String originalJson = ResourceUtils.getResourceAsString("testdata/PdpGroupsNoPDPs.json"); PdpGroups pdpGroups0 = standardCoder.decode(originalJson, PdpGroups.class); @@ -257,7 +257,7 @@ public class PdpProviderTest { } @Test - public void testGroupsUpdate() throws Exception { + void testGroupsUpdate() throws Exception { assertThatThrownBy(() -> { new PdpProvider().updatePdpGroups(null, null); }).hasMessageMatching(DAO_IS_NULL); @@ -302,7 +302,7 @@ public class PdpProviderTest { } @Test - public void testPoliciesDelete() throws Exception { + void testPoliciesDelete() throws Exception { assertThatThrownBy(() -> { new PdpProvider().deletePdpGroup(null, null); }).hasMessageMatching(DAO_IS_NULL); @@ -345,7 +345,7 @@ public class PdpProviderTest { } @Test - public void testPdpSubgroupUpdate() throws Exception { + void testPdpSubgroupUpdate() throws Exception { assertThatThrownBy(() -> { new PdpProvider().updatePdpSubGroup(null, null, null); }).hasMessageMatching(DAO_IS_NULL); @@ -410,7 +410,7 @@ public class PdpProviderTest { } @Test - public void testPdpUpdate() throws Exception { + void testPdpUpdate() throws Exception { assertThatThrownBy(() -> { new PdpProvider().updatePdp(null, null, null, null); }).hasMessageMatching(DAO_IS_NULL); @@ -508,7 +508,7 @@ public class PdpProviderTest { } @Test - public void testGetAllPolicyStatusPfDao() throws PfModelException { + void testGetAllPolicyStatusPfDao() { assertThatThrownBy(() -> { new PdpProvider().getAllPolicyStatus(null); }).hasMessageMatching(DAO_IS_NULL); @@ -536,7 +536,7 @@ public class PdpProviderTest { } @Test - public void testGetAllPolicyStatusPfDaoToscaConceptIdentifierOptVersion() throws PfModelException { + void testGetAllPolicyStatusPfDaoToscaConceptIdentifierOptVersion() { assertThatThrownBy(() -> { new PdpProvider().getAllPolicyStatus(null, new ToscaConceptIdentifierOptVersion("somePdp", null)); }).hasMessageMatching(DAO_IS_NULL); @@ -555,7 +555,7 @@ public class PdpProviderTest { } @Test - public void testGetGroupPolicyStatus() throws PfModelException { + void testGetGroupPolicyStatus() { assertThatThrownBy(() -> { new PdpProvider().getGroupPolicyStatus(null, "someGroup"); }).hasMessageMatching(DAO_IS_NULL); @@ -571,7 +571,7 @@ public class PdpProviderTest { } @Test - public void cudPolicyStatus() throws PfModelException { + void cudPolicyStatus() { PdpProvider prov = new PdpProvider(); assertThatThrownBy(() -> prov.cudPolicyStatus(null, List.of(), List.of(), List.of())) @@ -582,7 +582,7 @@ public class PdpProviderTest { } @Test - public void cudPolicyStatus_Create() throws PfModelException { + void cudPolicyStatus_Create() { PdpProvider prov = new PdpProvider(); PdpPolicyStatus idx = statusBuilder.pdpGroup(GROUP_A).pdpId("idX").build(); @@ -604,7 +604,7 @@ public class PdpProviderTest { } @Test - public void cudPolicyStatus_Update() throws PfModelException { + void cudPolicyStatus_Update() { PdpProvider prov = new PdpProvider(); PdpPolicyStatus idw = statusBuilder.pdpGroup(GROUP_A).pdpId("wId").build(); @@ -632,7 +632,7 @@ public class PdpProviderTest { } @Test - public void cudPolicyStatus_Delete() throws PfModelException { + void cudPolicyStatus_Delete() { PdpProvider prov = new PdpProvider(); PdpPolicyStatus idw = statusBuilder.pdpGroup(GROUP_A).pdpId("idW").build(); @@ -657,7 +657,7 @@ public class PdpProviderTest { } @Test - public void testFromAuthorativeStatus() throws PfModelException { + void testFromAuthorativeStatus() { PdpProvider prov = new PdpProvider(); assertThatCode(() -> prov.cudPolicyStatus(pfDao, null, null, null)).doesNotThrowAnyException(); -- cgit 1.2.3-korg