summaryrefslogtreecommitdiffstats
path: root/models-provider/src
diff options
context:
space:
mode:
authorwaynedunican <wayne.dunican@est.tech>2024-06-13 09:27:35 +0100
committerwaynedunican <wayne.dunican@est.tech>2024-06-25 09:16:30 +0100
commit09f9bc016598cb287c681418203852b0b619e931 (patch)
treeacbc197f599b595f3f1d4e1773b83935c4167b9b /models-provider/src
parentbacd5a6f57e79f26d447644329b585991f989123 (diff)
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 <wayne.dunican@est.tech>
Diffstat (limited to 'models-provider/src')
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/PolicyModelsProviderFactoryTest.java8
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/PolicyModelsProviderParametersTest.java12
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/TestPojos.java8
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java44
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyBadProviderImpl.java3
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderTest.java22
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyToscaPersistenceTest.java36
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyTypePersistenceTest.java24
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/revisionhierarchy/HierarchyFetchTest.java20
9 files changed, 88 insertions, 89 deletions
diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/PolicyModelsProviderFactoryTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/PolicyModelsProviderFactoryTest.java
index 79fce30a8..5fa6e809c 100644
--- a/models-provider/src/test/java/org/onap/policy/models/provider/PolicyModelsProviderFactoryTest.java
+++ b/models-provider/src/test/java/org/onap/policy/models/provider/PolicyModelsProviderFactoryTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 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");
@@ -24,7 +24,7 @@ package org.onap.policy.models.provider;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import lombok.ToString;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Test the {@link PolicyModelsProviderFactory} class.
@@ -32,10 +32,10 @@ import org.junit.Test;
* @author Liam Fallon (liam.fallon@est.tech)
*/
@ToString
-public class PolicyModelsProviderFactoryTest {
+class PolicyModelsProviderFactoryTest {
@Test
- public void testFactory() {
+ void testFactory() {
PolicyModelsProviderFactory factory = new PolicyModelsProviderFactory();
// @formatter:off
diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/PolicyModelsProviderParametersTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/PolicyModelsProviderParametersTest.java
index b1ae2a876..db59460a7 100644
--- a/models-provider/src/test/java/org/onap/policy/models/provider/PolicyModelsProviderParametersTest.java
+++ b/models-provider/src/test/java/org/onap/policy/models/provider/PolicyModelsProviderParametersTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019-2024 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,10 +21,10 @@
package org.onap.policy.models.provider;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+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;
/**
@@ -32,10 +32,10 @@ import org.onap.policy.common.parameters.ValidationResult;
*
* @author Liam Fallon (liam.fallon@est.tech)
*/
-public class PolicyModelsProviderParametersTest {
+class PolicyModelsProviderParametersTest {
@Test
- public void testParameters() {
+ void testParameters() {
PolicyModelsProviderParameters pars = new PolicyModelsProviderParameters();
pars.setDatabaseDriver("MichaelsShumacher");
pars.setDatabaseUrl("jdbc://www.acmecorp/roadrunner");
diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/TestPojos.java b/models-provider/src/test/java/org/onap/policy/models/provider/TestPojos.java
index 9ffe35cb0..f85674e70 100644
--- a/models-provider/src/test/java/org/onap/policy/models/provider/TestPojos.java
+++ b/models-provider/src/test/java/org/onap/policy/models/provider/TestPojos.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * 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.
@@ -27,7 +27,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;
/**
* Class to perform unit tests of all pojos.
@@ -35,12 +35,12 @@ import org.junit.Test;
* @author liam.fallon@est.tech)
*
*/
-public class TestPojos {
+class TestPojos {
private static final String POJO_PACKAGE = "org.onap.policy.models.provider";
@Test
- public void testPojos() {
+ void testPojos() {
// @formatter:off
final Validator validator = ValidatorBuilder
.create()
diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java
index 2af0f0cec..16d4ee4ac 100644
--- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java
+++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java
@@ -23,16 +23,16 @@
package org.onap.policy.models.provider.impl;
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 org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.pdp.concepts.Pdp;
import org.onap.policy.models.pdp.concepts.PdpGroup;
@@ -58,7 +58,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaTypedEntityFilter;
*
* @author Liam Fallon (liam.fallon@est.tech)
*/
-public class DatabasePolicyModelsProviderTest {
+class DatabasePolicyModelsProviderTest {
private static final String NAME = "name";
private static final String TEMPLATE_IS_NULL = "^serviceTemplate is marked .*on.*ull but is null$";
@@ -75,15 +75,15 @@ public class DatabasePolicyModelsProviderTest {
private static final String VERSION_100 = "1.0.0";
- private PolicyModelsProviderParameters parameters;
+ private static PolicyModelsProviderParameters parameters;
- private PolicyModelsProvider databaseProvider;
+ private static PolicyModelsProvider databaseProvider;
/**
* Initialize parameters.
*/
- @Before
- public void setupParameters() {
+ @BeforeAll
+ public static void setupParameters() {
parameters = new PolicyModelsProviderParameters();
parameters.setDatabaseDriver("org.h2.Driver");
parameters.setDatabaseUrl("jdbc:h2:mem:DatabasePolicyModelsProviderTest");
@@ -95,15 +95,15 @@ public class DatabasePolicyModelsProviderTest {
/**
* Closes the DB.
*/
- @After
- public void tearDown() throws PfModelException {
+ @AfterAll
+ public static void tearDown() throws PfModelException {
if (databaseProvider != null) {
databaseProvider.close();
}
}
@Test
- public void testInitAndClose() throws Exception {
+ void testInitAndClose() throws Exception {
assertThatThrownBy(() -> {
new DatabasePolicyModelsProviderImpl(null);
}).hasMessageMatching("^parameters is marked .*on.*ull but is null$");
@@ -142,7 +142,7 @@ public class DatabasePolicyModelsProviderTest {
}
@Test
- public void testProviderMethodsNull() throws Exception {
+ void testProviderMethodsNull() throws Exception {
databaseProvider = new PolicyModelsProviderFactory().createPolicyModelsProvider(parameters);
@@ -204,7 +204,7 @@ public class DatabasePolicyModelsProviderTest {
}
@Test
- public void testProviderMethodsNullGroup() throws Exception {
+ void testProviderMethodsNullGroup() throws Exception {
databaseProvider = new PolicyModelsProviderFactory().createPolicyModelsProvider(parameters);
@@ -276,7 +276,7 @@ public class DatabasePolicyModelsProviderTest {
}
@Test
- public void testProviderMethodsNotInit() throws Exception {
+ void testProviderMethodsNotInit() throws Exception {
databaseProvider = new PolicyModelsProviderFactory().createPolicyModelsProvider(parameters);
databaseProvider.close();
@@ -287,7 +287,7 @@ public class DatabasePolicyModelsProviderTest {
}
@Test
- public void testProviderMethods() throws PfModelException {
+ void testProviderMethods() throws PfModelException {
databaseProvider = new PolicyModelsProviderFactory().createPolicyModelsProvider(parameters);
assertThatThrownBy(() -> databaseProvider.getPolicyTypes(NAME, VERSION_100))
@@ -344,7 +344,7 @@ public class DatabasePolicyModelsProviderTest {
}
@Test
- public void testProviderMethodsInGroups() throws PfModelException {
+ void testProviderMethodsInGroups() throws PfModelException {
PdpGroup pdpGroup = new PdpGroup();
pdpGroup.setName(GROUP);
pdpGroup.setVersion("1.2.3");
@@ -394,7 +394,7 @@ public class DatabasePolicyModelsProviderTest {
}
@Test
- public void testDeletePolicyDeployedInSubgroup() throws PfModelException {
+ void testDeletePolicyDeployedInSubgroup() throws PfModelException {
List<ToscaConceptIdentifier> policies = new ArrayList<>();
policies.add(new ToscaConceptIdentifier("p0", "0.0.1"));
@@ -433,7 +433,7 @@ public class DatabasePolicyModelsProviderTest {
}
@Test
- public void testDeletePolicyTypeSupportedInSubgroup() throws PfModelException {
+ void testDeletePolicyTypeSupportedInSubgroup() throws PfModelException {
List<ToscaConceptIdentifier> supportedPolicyTypes = new ArrayList<>();
supportedPolicyTypes.add(new ToscaConceptIdentifier("pt1", "0.0.1"));
supportedPolicyTypes.add(new ToscaConceptIdentifier("pt2", "0.0.1"));
@@ -467,7 +467,7 @@ public class DatabasePolicyModelsProviderTest {
}
@Test
- public void testToscaNodeTemplateHandling() throws PfModelException {
+ void testToscaNodeTemplateHandling() throws PfModelException {
databaseProvider = new PolicyModelsProviderFactory().createPolicyModelsProvider(parameters);
ToscaServiceTemplate serviceTemplate = makeNodeTemplate();
diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyBadProviderImpl.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyBadProviderImpl.java
index a1339e4fd..c391680e5 100644
--- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyBadProviderImpl.java
+++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyBadProviderImpl.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2023 Nordix Foundation.
+ * Copyright (C) 2019-2024 Nordix Foundation.
* Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2020, 2022 Bell Canada. All rights reserved.
* ================================================================================
@@ -28,7 +28,6 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import lombok.NonNull;
-import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.base.PfModelRuntimeException;
import org.onap.policy.models.pdp.concepts.Pdp;
import org.onap.policy.models.pdp.concepts.PdpGroup;
diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderTest.java
index 628aef96e..fe5af6b2f 100644
--- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderTest.java
+++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderTest.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.
* Modifications Copyright (C) 2020, 2022 Bell Canada. All rights reserved.
* ================================================================================
@@ -25,13 +25,13 @@ package org.onap.policy.models.provider.impl;
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.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.ArrayList;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.pdp.concepts.Pdp;
import org.onap.policy.models.pdp.concepts.PdpGroupFilter;
@@ -51,12 +51,12 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaTypedEntityFilter;
*
* @author Liam Fallon (liam.fallon@est.tech)
*/
-public class DummyPolicyModelsProviderTest {
+class DummyPolicyModelsProviderTest {
private static final String VERSION = "version";
@Test
- public void testProvider() throws Exception {
+ void testProvider() throws Exception {
PolicyModelsProviderParameters parameters = new PolicyModelsProviderParameters();
parameters.setImplementation(DummyPolicyModelsProviderImpl.class.getName());
parameters.setDatabaseUrl("jdbc:dummy");
@@ -75,7 +75,7 @@ public class DummyPolicyModelsProviderTest {
}
@Test
- public void testProviderMethods() throws Exception {
+ void testProviderMethods() throws Exception {
PolicyModelsProvider dummyProvider = setUpDummyProvider();
dummyProvider.init();
@@ -103,7 +103,7 @@ public class DummyPolicyModelsProviderTest {
}
@Test
- public void testProviderMethodsParameters() throws Exception {
+ void testProviderMethodsParameters() throws Exception {
PolicyModelsProvider dummyProvider = setUpDummyProvider();
dummyProvider.init();
@@ -119,7 +119,7 @@ public class DummyPolicyModelsProviderTest {
}
@Test
- public void testDummyResponse() {
+ void testDummyResponse() {
try (DummyPolicyModelsProviderSubImpl resp =
new DummyPolicyModelsProviderSubImpl(new PolicyModelsProviderParameters())) {
assertThatThrownBy(resp::getBadDummyResponse1).hasMessage("error serializing object");
diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyToscaPersistenceTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyToscaPersistenceTest.java
index 3db058c27..227f1866f 100644
--- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyToscaPersistenceTest.java
+++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyToscaPersistenceTest.java
@@ -23,8 +23,8 @@
package org.onap.policy.models.provider.impl;
import static org.assertj.core.api.Assertions.assertThatCode;
-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.net.URISyntaxException;
import java.util.LinkedHashMap;
@@ -34,9 +34,9 @@ import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import lombok.NonNull;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+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.coder.YamlJsonTranslator;
@@ -58,13 +58,13 @@ import org.slf4j.LoggerFactory;
*
* @author Liam Fallon (liam.fallon@est.tech)
*/
-public class PolicyToscaPersistenceTest {
+class PolicyToscaPersistenceTest {
private static final Logger LOGGER = LoggerFactory.getLogger(PolicyToscaPersistenceTest.class);
- private YamlJsonTranslator yamlJsonTranslator = new YamlJsonTranslator();
+ private static YamlJsonTranslator yamlJsonTranslator = new YamlJsonTranslator();
private StandardCoder standardCoder = new StandardCoder();
- private PolicyModelsProvider databaseProvider;
+ private static PolicyModelsProvider databaseProvider;
/**
* Initialize provider.
@@ -72,8 +72,8 @@ public class PolicyToscaPersistenceTest {
* @throws PfModelException on exceptions in the tests
* @throws CoderException on JSON encoding and decoding errors
*/
- @Before
- public void setupParameters() throws Exception {
+ @BeforeAll
+ public static void setupParameters() throws Exception {
// H2, use "org.mariadb.jdbc.Driver" and "jdbc:mariadb://localhost:3306/policy" for locally installed MariaDB
PolicyModelsProviderParameters parameters = new PolicyModelsProviderParameters();
@@ -96,13 +96,13 @@ public class PolicyToscaPersistenceTest {
createPolicyTypes();
}
- @After
- public void teardown() throws Exception {
+ @AfterAll
+ public static void teardown() throws Exception {
databaseProvider.close();
}
@Test
- public void testToscaPolicyPersistence() throws Exception {
+ void testToscaPolicyPersistence() throws Exception {
Set<String> policyResources = ResourceUtils.getDirectoryContents("policies");
for (String policyResource : policyResources) {
@@ -121,7 +121,7 @@ public class PolicyToscaPersistenceTest {
}
@Test
- public void testHpaPolicyTypeGet() throws PfModelException {
+ void testHpaPolicyTypeGet() throws PfModelException {
long getStartTime = System.currentTimeMillis();
ToscaServiceTemplate hpaServiceTemplate =
databaseProvider.getPolicyTypes("onap.policies.optimization.resource.HpaPolicy", "1.0.0");
@@ -150,7 +150,7 @@ public class PolicyToscaPersistenceTest {
}
@Test
- public void testNamingPolicyGet() throws PfModelException {
+ void testNamingPolicyGet() throws PfModelException {
String policyYamlString = ResourceUtils.getResourceAsString("policies/sdnc.policy.naming.input.tosca.yaml");
ToscaServiceTemplate serviceTemplate =
yamlJsonTranslator.fromYaml(policyYamlString, ToscaServiceTemplate.class);
@@ -196,7 +196,7 @@ public class PolicyToscaPersistenceTest {
}
@Test
- public void testNamingPolicyVersions() throws PfModelException {
+ void testNamingPolicyVersions() throws PfModelException {
String policyYamlString = ResourceUtils.getResourceAsString("policies/sdnc.policy.naming.input.tosca.yaml");
ToscaServiceTemplate serviceTemplate =
yamlJsonTranslator.fromYaml(policyYamlString, ToscaServiceTemplate.class);
@@ -252,7 +252,7 @@ public class PolicyToscaPersistenceTest {
* @param serviceTemplate the service template containing the policy
* @throws Exception any exception thrown
*/
- public void testPolicyPersistence(@NonNull final ToscaServiceTemplate serviceTemplate) throws Exception {
+ void testPolicyPersistence(@NonNull final ToscaServiceTemplate serviceTemplate) throws Exception {
assertNotNull(serviceTemplate);
CountDownLatch threadCountDownLatch = new CountDownLatch(10);
@@ -306,7 +306,7 @@ public class PolicyToscaPersistenceTest {
return toscaPolicy;
}
- private void createPolicyTypes() throws CoderException, PfModelException, URISyntaxException {
+ private static void createPolicyTypes() throws PfModelException {
Set<String> policyTypeResources = ResourceUtils.getDirectoryContents("policytypes");
for (String policyTypeResource : policyTypeResources) {
diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyTypePersistenceTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyTypePersistenceTest.java
index 11e8381af..30824eb3a 100644
--- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyTypePersistenceTest.java
+++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyTypePersistenceTest.java
@@ -24,15 +24,15 @@ package org.onap.policy.models.provider.impl;
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.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.coder.YamlJsonTranslator;
import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.models.base.PfModelException;
@@ -48,17 +48,17 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
*
* @author Liam Fallon (liam.fallon@est.tech)
*/
-public class PolicyTypePersistenceTest {
+class PolicyTypePersistenceTest {
private YamlJsonTranslator yamlTranslator = new YamlJsonTranslator();
- private PolicyModelsProvider databaseProvider;
+ private static PolicyModelsProvider databaseProvider;
/**
* Initialize provider.
*
* @throws PfModelException on exceptions in the tests
*/
- @Before
- public void setupParameters() throws PfModelException {
+ @BeforeAll
+ public static void setupParameters() throws PfModelException {
// H2, use "org.mariadb.jdbc.Driver" and "jdbc:mariadb://localhost:3306/policy" for locally installed MariaDB
PolicyModelsProviderParameters parameters = new PolicyModelsProviderParameters();
@@ -78,13 +78,13 @@ public class PolicyTypePersistenceTest {
databaseProvider = new PolicyModelsProviderFactory().createPolicyModelsProvider(parameters);
}
- @After
- public void teardown() throws Exception {
+ @AfterAll
+ public static void teardown() throws Exception {
databaseProvider.close();
}
@Test
- public void testPolicyTypePersistence() throws Exception {
+ void testPolicyTypePersistence() throws Exception {
Set<String> policyTypeDirectoryContents = ResourceUtils.getDirectoryContents("policytypes");
ToscaServiceTemplate serviceTemplate = new ToscaServiceTemplate();
diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/revisionhierarchy/HierarchyFetchTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/revisionhierarchy/HierarchyFetchTest.java
index 015bbc552..a4a2014df 100644
--- a/models-provider/src/test/java/org/onap/policy/models/provider/revisionhierarchy/HierarchyFetchTest.java
+++ b/models-provider/src/test/java/org/onap/policy/models/provider/revisionhierarchy/HierarchyFetchTest.java
@@ -23,14 +23,14 @@
package org.onap.policy.models.provider.revisionhierarchy;
import static org.assertj.core.api.Assertions.assertThatCode;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import org.junit.After;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.coder.YamlJsonTranslator;
import org.onap.policy.common.utils.resources.TextFileUtils;
import org.onap.policy.models.base.PfModelException;
@@ -41,13 +41,13 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
-public class HierarchyFetchTest {
+class HierarchyFetchTest {
private static PolicyModelsProviderParameters parameters;
- private PolicyModelsProvider databaseProvider;
+ private static PolicyModelsProvider databaseProvider;
- @BeforeClass
+ @BeforeAll
public static void beforeSetupParameters() {
parameters = new PolicyModelsProviderParameters();
parameters.setDatabaseDriver("org.h2.Driver");
@@ -60,15 +60,15 @@ public class HierarchyFetchTest {
/**
* Closes the DB.
*/
- @After
- public void tearDown() throws PfModelException {
+ @AfterAll
+ public static void tearDown() throws PfModelException {
if (databaseProvider != null) {
databaseProvider.close();
}
}
@Test
- public void testMultipleVersions() throws Exception {
+ void testMultipleVersions() throws Exception {
databaseProvider = new PolicyModelsProviderFactory().createPolicyModelsProvider(parameters);
ToscaServiceTemplate serviceTemplate = new YamlJsonTranslator().fromYaml(