aboutsummaryrefslogtreecommitdiffstats
path: root/common-parameters/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'common-parameters/src/test/java')
-rw-r--r--common-parameters/src/test/java/org/onap/policy/common/parameters/ExceptionTest.java11
-rw-r--r--common-parameters/src/test/java/org/onap/policy/common/parameters/TestBeanValidationResult.java33
-rw-r--r--common-parameters/src/test/java/org/onap/policy/common/parameters/TestBeanValidator.java41
-rw-r--r--common-parameters/src/test/java/org/onap/policy/common/parameters/TestFieldValidator.java40
-rw-r--r--common-parameters/src/test/java/org/onap/policy/common/parameters/TestItemValidator.java17
-rw-r--r--common-parameters/src/test/java/org/onap/policy/common/parameters/TestObjectValidationResult.java17
-rw-r--r--common-parameters/src/test/java/org/onap/policy/common/parameters/TestValidation.java17
-rw-r--r--common-parameters/src/test/java/org/onap/policy/common/parameters/TestValidationResultImpl.java29
-rw-r--r--common-parameters/src/test/java/org/onap/policy/common/parameters/TestValueValidator.java23
9 files changed, 118 insertions, 110 deletions
diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/ExceptionTest.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/ExceptionTest.java
index 48d2f4b5..875fe44a 100644
--- a/common-parameters/src/test/java/org/onap/policy/common/parameters/ExceptionTest.java
+++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/ExceptionTest.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,17 +22,17 @@
package org.onap.policy.common.parameters;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.IOException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class ExceptionTest {
+class ExceptionTest {
private static final String PARAMETER_EXCEPTION = "Parameter Exception";
private static final String EXCEPTION_OBJECT = "Exception Object";
@Test
- public void testParameterException() {
+ void testParameterException() {
assertEquals(PARAMETER_EXCEPTION, new ParameterException(PARAMETER_EXCEPTION).getMessage());
assertEquals(EXCEPTION_OBJECT,
@@ -44,7 +45,7 @@ public class ExceptionTest {
}
@Test
- public void testParameterRuntimeException() {
+ void testParameterRuntimeException() {
assertEquals(PARAMETER_EXCEPTION, new ParameterRuntimeException(PARAMETER_EXCEPTION).getMessage());
assertEquals(EXCEPTION_OBJECT,
diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestBeanValidationResult.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestBeanValidationResult.java
index b7bea204..2fc09949 100644
--- a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestBeanValidationResult.java
+++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestBeanValidationResult.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,10 +22,10 @@
package org.onap.policy.common.parameters;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-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.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Arrays;
import java.util.List;
@@ -32,10 +33,10 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.TreeMap;
import java.util.function.BiConsumer;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-public class TestBeanValidationResult {
+class TestBeanValidationResult {
private static final String TEXT1 = "abc";
private static final String TEXT2 = "def";
private static final String MY_LIST = "my-list";
@@ -59,8 +60,8 @@ public class TestBeanValidationResult {
/**
* Sets up.
*/
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
clean = new ObjectValidationResult(TEXT1, 10);
cleanMsg = clean.getResult("", "", true);
@@ -72,13 +73,13 @@ public class TestBeanValidationResult {
}
@Test
- public void testBeanValidationResult() {
+ void testBeanValidationResult() {
assertTrue(bean.isValid());
assertNull(bean.getResult());
}
@Test
- public void testAddResult_testGetResult() {
+ void testAddResult_testGetResult() {
// null should be ok
assertTrue(bean.addResult(null));
@@ -99,7 +100,7 @@ public class TestBeanValidationResult {
}
@Test
- public void testValidateNotNull() {
+ void testValidateNotNull() {
assertTrue(bean.validateNotNull("sub-name", "sub-object"));
assertTrue(bean.isValid());
assertNull(bean.getResult());
@@ -110,7 +111,7 @@ public class TestBeanValidationResult {
}
@Test
- public void testValidateNotNullList() {
+ void testValidateNotNullList() {
List<ValidationResult> list = Arrays.asList(clean);
assertTrue(bean.validateNotNullList(MY_LIST, list, item -> item));
assertTrue(bean.isValid());
@@ -124,7 +125,7 @@ public class TestBeanValidationResult {
}
@Test
- public void testValidateNotNullList_NullList() {
+ void testValidateNotNullList_NullList() {
List<ValidationResult> list = null;
assertFalse(bean.validateNotNullList(MY_LIST, list, item -> item));
assertFalse(bean.isValid());
@@ -133,7 +134,7 @@ public class TestBeanValidationResult {
}
@Test
- public void testValidateList() {
+ void testValidateList() {
List<ValidationResult> list = null;
bean = new BeanValidationResult(NAME, OBJECT);
assertTrue(bean.validateList(MY_LIST, list, item -> item));
@@ -164,7 +165,7 @@ public class TestBeanValidationResult {
}
@Test
- public void testValidateMap() {
+ void testValidateMap() {
Map<String, ValidationResult> map = null;
bean = new BeanValidationResult(NAME, OBJECT);
assertTrue(bean.validateMap(MY_MAP, map, validMapEntry()));
diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestBeanValidator.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestBeanValidator.java
index 83d0a7f9..31c34209 100644
--- a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestBeanValidator.java
+++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestBeanValidator.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +22,7 @@
package org.onap.policy.common.parameters;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Collection;
import java.util.HashMap;
@@ -30,8 +31,8 @@ import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
import lombok.Getter;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.parameters.annotations.ClassName;
import org.onap.policy.common.parameters.annotations.Max;
import org.onap.policy.common.parameters.annotations.Min;
@@ -41,7 +42,7 @@ import org.onap.policy.common.parameters.annotations.Pattern;
import org.onap.policy.common.parameters.annotations.Size;
import org.onap.policy.common.parameters.annotations.Valid;
-public class TestBeanValidator {
+class TestBeanValidator {
private static final String TOP = "top";
private static final String STR_FIELD = "strValue";
private static final String INT_FIELD = "intValue";
@@ -52,13 +53,13 @@ public class TestBeanValidator {
private BeanValidator validator;
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
validator = new BeanValidator();
}
@Test
- public void testValidateTop_testValidateFields() {
+ void testValidateTop_testValidateFields() {
// validate null
assertTrue(validator.validateTop(TOP, null).isValid());
@@ -117,7 +118,7 @@ public class TestBeanValidator {
}
@Test
- public void testVerNotNull() {
+ void testVerNotNull() {
class NotNullCheck {
@Getter
@Min(1)
@@ -136,7 +137,7 @@ public class TestBeanValidator {
}
@Test
- public void testVerNotBlank() {
+ void testVerNotBlank() {
class NotBlankCheck {
@Getter
@NotBlank
@@ -178,7 +179,7 @@ public class TestBeanValidator {
* Tests verSize with a collection.
*/
@Test
- public void testVerSizeCollection() {
+ void testVerSizeCollection() {
class CollectionSizeCheck {
@Getter
@Size(min = 3)
@@ -208,7 +209,7 @@ public class TestBeanValidator {
* Tests verSize with a map.
*/
@Test
- public void testVerSizeMap() {
+ void testVerSizeMap() {
class MapSizeCheck {
@Getter
@Size(min = 3)
@@ -238,7 +239,7 @@ public class TestBeanValidator {
* Tests verSize with an object for which it doesn't apply.
*/
@Test
- public void testVerSizeOther() {
+ void testVerSizeOther() {
class OtherSizeCheck {
@Getter
@Size(min = 3)
@@ -252,7 +253,7 @@ public class TestBeanValidator {
}
@Test
- public void testVerRegex() {
+ void testVerRegex() {
class RegexCheck {
@Getter
@Pattern(regexp = "[a-f]*")
@@ -304,7 +305,7 @@ public class TestBeanValidator {
}
@Test
- public void testVerMax() {
+ void testVerMax() {
/*
* Field is not a number.
*/
@@ -398,7 +399,7 @@ public class TestBeanValidator {
}
@Test
- public void testVerMin() {
+ void testVerMin() {
/*
* Field is not a number.
*/
@@ -492,7 +493,7 @@ public class TestBeanValidator {
}
@Test
- public void testVerClassName() {
+ void testVerClassName() {
class ClassNameCheck {
@Getter
@ClassName
@@ -516,7 +517,7 @@ public class TestBeanValidator {
}
@Test
- public void testVerCascade() {
+ void testVerCascade() {
class Item {
@Getter
@NotNull
@@ -554,7 +555,7 @@ public class TestBeanValidator {
}
@Test
- public void testVerCollection() {
+ void testVerCollection() {
@Getter
class Container {
List<@Min(5) Integer> items;
@@ -589,7 +590,7 @@ public class TestBeanValidator {
}
@Test
- public void testVerMap() {
+ void testVerMap() {
@Getter
class Container {
Map<String, @Min(5) Integer> items;
@@ -624,7 +625,7 @@ public class TestBeanValidator {
}
@Test
- public void testGetEntryName() {
+ void testGetEntryName() {
assertThat(validator.getEntryName(makeEntry(null, 0))).isEmpty();
assertThat(validator.getEntryName(makeEntry("", 0))).isEmpty();
assertThat(validator.getEntryName(makeEntry(STRING_VALUE, 0))).isEqualTo(STRING_VALUE);
diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestFieldValidator.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestFieldValidator.java
index 81a7b8ff..0fb39b0f 100644
--- a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestFieldValidator.java
+++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestFieldValidator.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2023-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.
@@ -30,13 +30,13 @@ import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Map;
import lombok.Getter;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.parameters.annotations.Min;
import org.onap.policy.common.parameters.annotations.NotBlank;
import org.onap.policy.common.parameters.annotations.NotNull;
-public class TestFieldValidator extends ValidatorUtil {
+class TestFieldValidator extends ValidatorUtil {
private static final String INT_LIST_FIELD = "intList";
private static final String INT_MAP_FIELD = "intMap";
private static final String UNANNOTATED_FIELD = "unannotated";
@@ -113,13 +113,13 @@ public class TestFieldValidator extends ValidatorUtil {
private int exMethod;
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
bean = new BeanValidator();
}
@Test
- public void testGetAnnotation() {
+ void testGetAnnotation() {
// field-level annotation
assertThat(new FieldValidator(bean, TestFieldValidator.class, getField(INT_FIELD)).isEmpty()).isFalse();
@@ -128,7 +128,7 @@ public class TestFieldValidator extends ValidatorUtil {
}
@Test
- public void testFieldValidator() throws NoSuchFieldException, SecurityException {
+ void testFieldValidator() throws NoSuchFieldException, SecurityException {
/*
* Note: nested classes contain fields like "$this", thus the check for "$" in the
* variable name is already covered by the other tests.
@@ -165,7 +165,7 @@ public class TestFieldValidator extends ValidatorUtil {
}
@Test
- public void testFieldValidator_SetNullAllowed() {
+ void testFieldValidator_SetNullAllowed() {
// default - null is allowed
assertThat(new FieldValidator(bean, TestFieldValidator.class, getField(INT_FIELD)).isNullAllowed()).isTrue();
@@ -179,7 +179,7 @@ public class TestFieldValidator extends ValidatorUtil {
}
@Test
- public void testAddListValidator() {
+ void testAddListValidator() {
// unannotated
assertThat(new FieldValidator(bean, TestFieldValidator.class, getField("unannotatedList")).isEmpty()).isTrue();
@@ -189,7 +189,7 @@ public class TestFieldValidator extends ValidatorUtil {
}
@Test
- public void testAddMapValidator() {
+ void testAddMapValidator() {
// unannotated
assertThat(new FieldValidator(bean, TestFieldValidator.class, getField("unannotatedMap")).isEmpty()).isTrue();
@@ -226,7 +226,7 @@ public class TestFieldValidator extends ValidatorUtil {
@SuppressWarnings("deprecation")
@Test
- public void testValidateField_testGetValue() {
+ void testValidateField_testGetValue() {
// unannotated
BeanValidationResult result = new BeanValidationResult(MY_NAME, this);
new FieldValidator(bean, getClass(), getField(UNANNOTATED_FIELD)).validateField(result, this);
@@ -253,7 +253,7 @@ public class TestFieldValidator extends ValidatorUtil {
}
@Test
- public void testValidateField_testGetValue_ListField() {
+ void testValidateField_testGetValue_ListField() {
// valid
BeanValidationResult result = new BeanValidationResult(MY_NAME, this);
intList = List.of(10, 20, 30, 40);
@@ -269,7 +269,7 @@ public class TestFieldValidator extends ValidatorUtil {
}
@Test
- public void testValidateField_testGetValue_MapField() {
+ void testValidateField_testGetValue_MapField() {
// valid
BeanValidationResult result = new BeanValidationResult(MY_NAME, this);
intMap = Map.of("ten", 10, "twenty", 20, "thirty", 30, "forty", 40);
@@ -285,7 +285,7 @@ public class TestFieldValidator extends ValidatorUtil {
}
@Test
- public void testClassOnly() {
+ void testClassOnly() {
// class-level annotation has no bearing on a static field
assertThat(new FieldValidator(bean, ClassAnnot.class, getField(ClassAnnot.class, "staticValue")).isEmpty())
.isTrue();
@@ -297,7 +297,7 @@ public class TestFieldValidator extends ValidatorUtil {
}
@Test
- public void testGetAccessor() {
+ void testGetAccessor() {
// uses "getXxx"
assertThat(new FieldValidator(bean, TestFieldValidator.class, getField(INT_FIELD)).isEmpty()).isFalse();
@@ -306,7 +306,7 @@ public class TestFieldValidator extends ValidatorUtil {
}
@Test
- public void testGetMethod() {
+ void testGetMethod() {
assertThat(new FieldValidator(bean, TestFieldValidator.class, getField(INT_FIELD)).isEmpty()).isFalse();
// these are invalid for various reasons
@@ -321,7 +321,7 @@ public class TestFieldValidator extends ValidatorUtil {
}
@Test
- public void testValidMethod() {
+ void testValidMethod() {
assertThat(new FieldValidator(bean, TestFieldValidator.class, getField(INT_FIELD)).isEmpty()).isFalse();
// these are invalid for various reasons
@@ -340,7 +340,7 @@ public class TestFieldValidator extends ValidatorUtil {
}
@Test
- public void testIsFieldAnnotated_testSetFieldAnnotated() {
+ void testIsFieldAnnotated_testSetFieldAnnotated() {
// annotated at the field level
assertThat(new FieldValidator(bean, getClass(), getField(INT_FIELD)).isFieldAnnotated()).isTrue();
@@ -352,7 +352,7 @@ public class TestFieldValidator extends ValidatorUtil {
return -1000;
}
- public void getVoidMethod() {
+ void getVoidMethod() {
// do nothing
}
diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestItemValidator.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestItemValidator.java
index cadcfdee..b2686fdf 100644
--- a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestItemValidator.java
+++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestItemValidator.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.
@@ -26,13 +27,13 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.parameters.annotations.Min;
import org.onap.policy.common.parameters.annotations.NotBlank;
import org.onap.policy.common.parameters.annotations.NotNull;
-public class TestItemValidator extends ValidatorUtil {
+class TestItemValidator extends ValidatorUtil {
// annotated fields - each field must have exactly one annotation
@@ -69,13 +70,13 @@ public class TestItemValidator extends ValidatorUtil {
private String multiMatch;
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
bean = new BeanValidator();
}
@Test
- public void testGetAnnotation() {
+ void testGetAnnotation() {
// no matches
assertThat(new ItemValidator(bean, getAnnotType("noAnnotations"), true).isEmpty()).isTrue();
@@ -100,12 +101,12 @@ public class TestItemValidator extends ValidatorUtil {
}
@Test
- public void testItemValidatorBeanValidatorAnnotation() {
+ void testItemValidatorBeanValidatorAnnotation() {
assertThat(new ItemValidator(bean, getAnnotType("match")).isEmpty()).isFalse();
}
@Test
- public void testItemValidatorBeanValidatorAnnotationBoolean() {
+ void testItemValidatorBeanValidatorAnnotationBoolean() {
assertThat(new ItemValidator(bean, getAnnotType("match"), true).isEmpty()).isFalse();
assertThat(new ItemValidator(bean, getAnnotType("match"), false).isEmpty()).isTrue();
diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestObjectValidationResult.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestObjectValidationResult.java
index 5fd7d892..c72d4f4a 100644
--- a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestObjectValidationResult.java
+++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestObjectValidationResult.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.common.parameters;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-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.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class TestObjectValidationResult {
+class TestObjectValidationResult {
private static final String NAME = "my-name";
private static final Object OBJECT = "my-object";
private ObjectValidationResult result;
@Test
- public void testValidationResultImplStringObjectValidationStatusString() {
+ void testValidationResultImplStringObjectValidationStatusString() {
result = new ObjectValidationResult(NAME, OBJECT, ValidationStatus.INVALID, "invalid data");
assertEquals(NAME, result.getName());
assertEquals(OBJECT, result.getObject());
@@ -43,7 +44,7 @@ public class TestObjectValidationResult {
}
@Test
- public void testGetResult() {
+ void testGetResult() {
result = new ObjectValidationResult(NAME, OBJECT);
assertEquals(ValidationStatus.CLEAN, result.getStatus());
assertNull(result.getResult());
diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestValidation.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestValidation.java
index b19b92da..a696963c 100644
--- a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestValidation.java
+++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestValidation.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,16 +23,16 @@
package org.onap.policy.common.parameters;
import static org.assertj.core.api.Assertions.assertThat;
-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.parameters.annotations.Max;
import org.onap.policy.common.parameters.annotations.Min;
import org.onap.policy.common.parameters.annotations.NotBlank;
import org.onap.policy.common.parameters.annotations.NotNull;
import org.onap.policy.common.parameters.annotations.Valid;
-public class TestValidation {
+class TestValidation {
private static final String NOT_BLANK_STRING_MESSAGE =
"field 'notBlankString' type 'java.lang.String' value '' INVALID, must be a non-blank string\n"
.replace('\'', '"');
@@ -66,7 +67,7 @@ public class TestValidation {
private long maxLong;
@Test
- public void testGetValidationResult() {
+ void testGetValidationResult() {
Contained item = new Contained();
item.setName("item");
@@ -87,7 +88,7 @@ public class TestValidation {
}
@Test
- public void testParameterValidationResult_NotNull() throws Exception {
+ void testParameterValidationResult_NotNull() throws Exception {
ParameterValidationResult result = new ParameterValidationResult(
TestValidation.class.getDeclaredField(NOT_NULL_STRING_NAME), null);
assertEquals(ValidationStatus.INVALID, result.getStatus());
@@ -139,7 +140,7 @@ public class TestValidation {
}
@Test
- public void testParameterValidationResult_NotBlank() throws Exception {
+ void testParameterValidationResult_NotBlank() throws Exception {
ParameterValidationResult result =
new ParameterValidationResult(TestValidation.class.getDeclaredField(NOT_BLANK_STRING_NAME), "");
assertEquals(ValidationStatus.INVALID, result.getStatus());
@@ -180,7 +181,7 @@ public class TestValidation {
}
@Test
- public void testParameterValidationResult_Min() throws Exception {
+ void testParameterValidationResult_Min() throws Exception {
ParameterValidationResult result =
new ParameterValidationResult(TestValidation.class.getDeclaredField(MIN_LONG_NAME), 9L);
assertEquals(ValidationStatus.INVALID, result.getStatus());
@@ -200,7 +201,7 @@ public class TestValidation {
}
@Test
- public void testParameterValidationResult_Max() throws Exception {
+ void testParameterValidationResult_Max() throws Exception {
ParameterValidationResult result =
new ParameterValidationResult(TestValidation.class.getDeclaredField(MAX_LONG_NAME), 11L);
assertEquals(ValidationStatus.INVALID, result.getStatus());
diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestValidationResultImpl.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestValidationResultImpl.java
index da6107cf..f6851b5e 100644
--- a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestValidationResultImpl.java
+++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestValidationResultImpl.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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,27 +21,27 @@
package org.onap.policy.common.parameters;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-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.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-public class TestValidationResultImpl {
+class TestValidationResultImpl {
private static final String NAME = "my-name";
private static final Object OBJECT = "my-object";
private MyResult result;
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
result = new MyResult(NAME, OBJECT);
}
@Test
- public void testValidationResultImplStringObjectValidationStatusString() {
+ void testValidationResultImplStringObjectValidationStatusString() {
result = new MyResult(NAME, OBJECT, ValidationStatus.INVALID, "invalid data");
assertEquals(NAME, result.getName());
assertEquals(OBJECT, result.getObject());
@@ -49,7 +50,7 @@ public class TestValidationResultImpl {
}
@Test
- public void testValidateNotNull() {
+ void testValidateNotNull() {
assertTrue(result.validateNotNull());
assertTrue(result.isValid());
assertNull(result.getResult());
@@ -62,7 +63,7 @@ public class TestValidationResultImpl {
}
@Test
- public void testSetResultValidationStatus() {
+ void testSetResultValidationStatus() {
result.setResult(ValidationStatus.WARNING);
assertEquals(ValidationStatus.WARNING, result.getStatus());
@@ -75,7 +76,7 @@ public class TestValidationResultImpl {
}
@Test
- public void testSetResult_testGetResult_testGetStatus() {
+ void testSetResult_testGetResult_testGetStatus() {
assertEquals(ValidationStatus.CLEAN, result.getStatus());
assertEquals("CLEAN item has status CLEAN", result.getResult("xxx ", "yyy", true));
@@ -97,7 +98,7 @@ public class TestValidationResultImpl {
}
@Test
- public void testGetName() {
+ void testGetName() {
assertEquals(NAME, result.getName());
}
diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestValueValidator.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestValueValidator.java
index dcf08695..0cd3776d 100644
--- a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestValueValidator.java
+++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestValueValidator.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.
@@ -24,13 +25,13 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.lang.annotation.Annotation;
import java.util.concurrent.atomic.AtomicBoolean;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.parameters.annotations.Min;
import org.onap.policy.common.parameters.annotations.NotBlank;
import org.onap.policy.common.parameters.annotations.NotNull;
-public class TestValueValidator extends ValidatorUtil {
+class TestValueValidator extends ValidatorUtil {
private ValueValidator validator;
@@ -41,13 +42,13 @@ public class TestValueValidator extends ValidatorUtil {
private final int annotField = 1;
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
validator = new MyValueValidator();
}
@Test
- public void testIsEmpty() {
+ void testIsEmpty() {
assertThat(validator.isEmpty()).isTrue();
validator.addAnnotation(NotNull.class, (result2, fieldName, value) -> true);
@@ -55,7 +56,7 @@ public class TestValueValidator extends ValidatorUtil {
}
@Test
- public void testValidateValue_NullValue() {
+ void testValidateValue_NullValue() {
BeanValidationResult result = new BeanValidationResult(MY_NAME, this);
validator.validateValue(result, MY_FIELD, null);
@@ -68,7 +69,7 @@ public class TestValueValidator extends ValidatorUtil {
}
@Test
- public void testValidateValue_NotNullValue() {
+ void testValidateValue_NotNullValue() {
BeanValidationResult result = new BeanValidationResult(MY_NAME, this);
validator.validateValue(result, MY_FIELD, HELLO);
@@ -81,7 +82,7 @@ public class TestValueValidator extends ValidatorUtil {
}
@Test
- public void testAddAnnotationClassOfTChecker() {
+ void testAddAnnotationClassOfTChecker() {
// the field does not have this annotation
validator.addAnnotation(Min.class, (result2, fieldName, value) -> true);
assertThat(validator.isEmpty()).isTrue();
@@ -98,7 +99,7 @@ public class TestValueValidator extends ValidatorUtil {
}
@Test
- public void testAddAnnotationClassOfTCheckerWithAnnotOfT() {
+ void testAddAnnotationClassOfTCheckerWithAnnotOfT() {
// the field does not have this annotation
validator.addAnnotation(Min.class, (result2, fieldName, annot, value) -> true);
assertThat(validator.isEmpty()).isTrue();
@@ -122,7 +123,7 @@ public class TestValueValidator extends ValidatorUtil {
}
@Test
- public void testGetAnnotation() {
+ void testGetAnnotation() {
assertThat(new ValueValidator().getAnnotation(NotNull.class)).isNull();
}