aboutsummaryrefslogtreecommitdiffstats
path: root/models-pap
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-pap
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-pap')
-rw-r--r--models-pap/src/test/java/org/onap/policy/models/pap/concepts/PapPolicyIdentifierTest.java16
-rw-r--r--models-pap/src/test/java/org/onap/policy/models/pap/concepts/PdpDeployPoliciesTest.java16
-rw-r--r--models-pap/src/test/java/org/onap/policy/models/pap/concepts/PdpGroupDeployResponseTest.java13
-rw-r--r--models-pap/src/test/java/org/onap/policy/models/pap/concepts/PolicyNotificationTest.java15
-rw-r--r--models-pap/src/test/java/org/onap/policy/models/pap/concepts/PolicyStatusTest.java10
-rw-r--r--models-pap/src/test/java/org/onap/policy/models/pap/concepts/TestModels.java8
-rw-r--r--models-pap/src/test/java/org/onap/policy/models/pap/persistence/concepts/JpaPolicyAuditTest.java32
7 files changed, 56 insertions, 54 deletions
diff --git a/models-pap/src/test/java/org/onap/policy/models/pap/concepts/PapPolicyIdentifierTest.java b/models-pap/src/test/java/org/onap/policy/models/pap/concepts/PapPolicyIdentifierTest.java
index 2ab315ddd..6036ad99f 100644
--- a/models-pap/src/test/java/org/onap/policy/models/pap/concepts/PapPolicyIdentifierTest.java
+++ b/models-pap/src/test/java/org/onap/policy/models/pap/concepts/PapPolicyIdentifierTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * 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.
@@ -19,12 +19,12 @@
package org.onap.policy.models.pap.concepts;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import java.io.IOException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.common.utils.resources.TextFileUtils;
@@ -34,10 +34,10 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierO
/**
* This only tests the methods that aren't already tested via TestModels.
*/
-public class PapPolicyIdentifierTest {
+class PapPolicyIdentifierTest {
@Test
- public void testPapPolicyIdentifier() throws CoderException {
+ void testPapPolicyIdentifier() {
assertNotNull(new PapPolicyIdentifier("Name", "Version"));
assertNotNull(new PapPolicyIdentifier("Name", null));
assertNotNull(new PapPolicyIdentifier(null, null));
@@ -62,7 +62,7 @@ public class PapPolicyIdentifierTest {
}
@Test
- public void testPapPolicyIdentifierSerialization() throws CoderException, IOException {
+ void testPapPolicyIdentifierSerialization() throws CoderException, IOException {
String idString = TextFileUtils.getTextFileAsString("src/test/resources/json/PapPolicyIdentifier.json");
StandardCoder coder = new StandardCoder();
diff --git a/models-pap/src/test/java/org/onap/policy/models/pap/concepts/PdpDeployPoliciesTest.java b/models-pap/src/test/java/org/onap/policy/models/pap/concepts/PdpDeployPoliciesTest.java
index 3664cc39c..0ba0bfd23 100644
--- a/models-pap/src/test/java/org/onap/policy/models/pap/concepts/PdpDeployPoliciesTest.java
+++ b/models-pap/src/test/java/org/onap/policy/models/pap/concepts/PdpDeployPoliciesTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * 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.
@@ -18,14 +18,14 @@
package org.onap.policy.models.pap.concepts;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.common.utils.resources.TextFileUtils;
@@ -34,9 +34,9 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierO
/**
* This only tests the methods that aren't already tested via TestModels.
*/
-public class PdpDeployPoliciesTest {
+class PdpDeployPoliciesTest {
@Test
- public void testPapPolicyIdentifier() throws CoderException, IOException {
+ void testPapPolicyIdentifier() {
assertNotNull(new PdpDeployPolicies());
List<ToscaConceptIdentifierOptVersion> tciListIn = new ArrayList<>();
@@ -68,7 +68,7 @@ public class PdpDeployPoliciesTest {
}
@Test
- public void testPapPolicyIdentifierSerialization() throws CoderException, IOException {
+ void testPapPolicyIdentifierSerialization() throws CoderException, IOException {
String idListString = TextFileUtils.getTextFileAsString("src/test/resources/json/PapPoliciesList.json");
StandardCoder coder = new StandardCoder();
diff --git a/models-pap/src/test/java/org/onap/policy/models/pap/concepts/PdpGroupDeployResponseTest.java b/models-pap/src/test/java/org/onap/policy/models/pap/concepts/PdpGroupDeployResponseTest.java
index d3b8cc497..315ee9bd1 100644
--- a/models-pap/src/test/java/org/onap/policy/models/pap/concepts/PdpGroupDeployResponseTest.java
+++ b/models-pap/src/test/java/org/onap/policy/models/pap/concepts/PdpGroupDeployResponseTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2021 Bell Canada. 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.
@@ -18,22 +19,22 @@
package org.onap.policy.models.pap.concepts;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Test class for PdpGroupDeployResponse.
*/
-public class PdpGroupDeployResponseTest {
+class PdpGroupDeployResponseTest {
private static final String URI = "/policy/pap/v1/policies/status";
private static final String MESSAGE = "the message";
@Test
- public void testPdpGroupDeployResponse() {
+ void testPdpGroupDeployResponse() {
assertNotNull(new PdpGroupDeployResponse("message", "uri"));
assertNotNull(new PdpGroupDeployResponse("message", null));
assertNotNull(new PdpGroupDeployResponse(null, null));
diff --git a/models-pap/src/test/java/org/onap/policy/models/pap/concepts/PolicyNotificationTest.java b/models-pap/src/test/java/org/onap/policy/models/pap/concepts/PolicyNotificationTest.java
index 10c7c5fee..c6b88abc1 100644
--- a/models-pap/src/test/java/org/onap/policy/models/pap/concepts/PolicyNotificationTest.java
+++ b/models-pap/src/test/java/org/onap/policy/models/pap/concepts/PolicyNotificationTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* 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.
@@ -18,25 +19,25 @@
package org.onap.policy.models.pap.concepts;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-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.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
/**
* This only tests the methods that aren't already tested via TestModels.
*/
-public class PolicyNotificationTest {
+class PolicyNotificationTest {
@Test
- public void test() throws CoderException {
+ void test() throws CoderException {
PolicyStatus statusAdd1 = new PolicyStatus();
statusAdd1.setSuccessCount(10);
PolicyStatus statusAdd2 = new PolicyStatus();
diff --git a/models-pap/src/test/java/org/onap/policy/models/pap/concepts/PolicyStatusTest.java b/models-pap/src/test/java/org/onap/policy/models/pap/concepts/PolicyStatusTest.java
index 997c30414..0f1c4b9cf 100644
--- a/models-pap/src/test/java/org/onap/policy/models/pap/concepts/PolicyStatusTest.java
+++ b/models-pap/src/test/java/org/onap/policy/models/pap/concepts/PolicyStatusTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* 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.
@@ -19,9 +19,9 @@
package org.onap.policy.models.pap.concepts;
-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.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
@@ -29,10 +29,10 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
/**
* This only tests the methods that aren't already tested via TestModels.
*/
-public class PolicyStatusTest {
+class PolicyStatusTest {
@Test
- public void test() throws CoderException {
+ void test() throws CoderException {
ToscaConceptIdentifier type = new ToscaConceptIdentifier("my-type", "3.2.1");
ToscaConceptIdentifier policy = new ToscaConceptIdentifier("my-name", "1.2.3");
diff --git a/models-pap/src/test/java/org/onap/policy/models/pap/concepts/TestModels.java b/models-pap/src/test/java/org/onap/policy/models/pap/concepts/TestModels.java
index 1658ccbd0..07b9d17b8 100644
--- a/models-pap/src/test/java/org/onap/policy/models/pap/concepts/TestModels.java
+++ b/models-pap/src/test/java/org/onap/policy/models/pap/concepts/TestModels.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2021 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.ValidatorBuilder;
import com.openpojo.validation.test.impl.GetterTester;
import com.openpojo.validation.test.impl.SetterTester;
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.test.ToStringTester;
/**
@@ -35,10 +35,10 @@ import org.onap.policy.common.utils.test.ToStringTester;
*
* @author Ram Krishna Verma (ram.krishna.verma@est.tech)
*/
-public class TestModels {
+class TestModels {
@Test
- public void testPapModels() {
+ void testPapModels() {
List<PojoClass> pojoClasses = PojoClassFactory.getPojoClasses(TestModels.class.getPackage().getName());
// @formatter:off
diff --git a/models-pap/src/test/java/org/onap/policy/models/pap/persistence/concepts/JpaPolicyAuditTest.java b/models-pap/src/test/java/org/onap/policy/models/pap/persistence/concepts/JpaPolicyAuditTest.java
index 25d7304ee..25b3219c6 100644
--- a/models-pap/src/test/java/org/onap/policy/models/pap/persistence/concepts/JpaPolicyAuditTest.java
+++ b/models-pap/src/test/java/org/onap/policy/models/pap/persistence/concepts/JpaPolicyAuditTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * 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,15 +22,15 @@ package org.onap.policy.models.pap.persistence.concepts;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatNoException;
-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 java.time.Instant;
import java.time.temporal.ChronoUnit;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.parameters.BeanValidationResult;
import org.onap.policy.models.pap.concepts.PolicyAudit;
import org.onap.policy.models.pap.concepts.PolicyAudit.AuditAction;
@@ -39,7 +39,7 @@ import org.onap.policy.models.pdp.concepts.PdpPolicyStatus.State;
import org.onap.policy.models.pdp.persistence.concepts.JpaPdpPolicyStatus;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-public class JpaPolicyAuditTest {
+class JpaPolicyAuditTest {
private static final ToscaConceptIdentifier MY_POLICY = new ToscaConceptIdentifier("MyPolicy", "1.2.3");
private static final String PDP_GROUP = "pdpGroupxyz";
@@ -50,14 +50,14 @@ public class JpaPolicyAuditTest {
/**
* Setup an audit for usage on unit tests.
*/
- @Before
- public void setup() {
+ @BeforeEach
+ void setup() {
audit = PolicyAudit.builder().auditId(1L).pdpGroup(PDP_GROUP).pdpType("pdpType").policy(MY_POLICY)
.action(AuditAction.DEPLOYMENT).timestamp(Instant.now().truncatedTo(ChronoUnit.SECONDS)).build();
}
@Test
- public void testCompareTo() {
+ void testCompareTo() {
JpaPolicyAudit jpaAudit = new JpaPolicyAudit(audit);
assertEquals(-1, jpaAudit.compareTo(null));
assertEquals(0, jpaAudit.compareTo(jpaAudit));
@@ -70,7 +70,7 @@ public class JpaPolicyAuditTest {
}
@Test
- public void testKeys() {
+ void testKeys() {
JpaPolicyAudit jpaAudit = new JpaPolicyAudit();
assertThat(jpaAudit.getKeys()).isNotNull();
assertTrue(jpaAudit.getKey().isNullKey());
@@ -80,7 +80,7 @@ public class JpaPolicyAuditTest {
}
@Test
- public void testClean() {
+ void testClean() {
audit.setUser(" user");
JpaPolicyAudit jpaAudit = new JpaPolicyAudit(audit);
assertThatNoException().isThrownBy(() -> jpaAudit.clean());
@@ -88,7 +88,7 @@ public class JpaPolicyAuditTest {
}
@Test
- public void testToAuthorative() {
+ void testToAuthorative() {
audit.setUser(USER);
JpaPolicyAudit jpaAudit = new JpaPolicyAudit(audit);
PolicyAudit convertedAudit = jpaAudit.toAuthorative();
@@ -103,7 +103,7 @@ public class JpaPolicyAuditTest {
}
@Test
- public void testConversionsWithRequiredOnly() {
+ void testConversionsWithRequiredOnly() {
audit = PolicyAudit.builder().policy(MY_POLICY).action(AuditAction.DEPLOYMENT)
.timestamp(Instant.now().truncatedTo(ChronoUnit.SECONDS)).build();
@@ -115,7 +115,7 @@ public class JpaPolicyAuditTest {
}
@Test
- public void testValidation() {
+ void testValidation() {
PolicyAudit invalidAudit = PolicyAudit.builder().pdpGroup(PDP_GROUP).user(USER).build();
JpaPolicyAudit jpaAudit = new JpaPolicyAudit(invalidAudit);