aboutsummaryrefslogtreecommitdiffstats
path: root/common-parameters
diff options
context:
space:
mode:
Diffstat (limited to 'common-parameters')
-rw-r--r--common-parameters/pom.xml11
-rw-r--r--common-parameters/src/main/java/org/onap/policy/common/parameters/BeanValidator.java3
-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/ParameterGroupTest.java93
-rw-r--r--common-parameters/src/test/java/org/onap/policy/common/parameters/ParameterServiceTest.java161
-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
-rw-r--r--common-parameters/src/test/java/org/onap/policy/common/parameters/validation/ParameterGroupValidatorTest.java91
14 files changed, 470 insertions, 117 deletions
diff --git a/common-parameters/pom.xml b/common-parameters/pom.xml
index 8ecd611e..3257d3b3 100644
--- a/common-parameters/pom.xml
+++ b/common-parameters/pom.xml
@@ -24,7 +24,7 @@
<parent>
<groupId>org.onap.policy.common</groupId>
<artifactId>common-modules</artifactId>
- <version>3.0.0-SNAPSHOT</version>
+ <version>3.0.1-SNAPSHOT</version>
</parent>
<artifactId>common-parameters</artifactId>
@@ -58,14 +58,13 @@
<artifactId>gson</artifactId>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ </dependency>
</dependencies>
</project>
diff --git a/common-parameters/src/main/java/org/onap/policy/common/parameters/BeanValidator.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/BeanValidator.java
index 4ed7e42c..c4244b27 100644
--- a/common-parameters/src/main/java/org/onap/policy/common/parameters/BeanValidator.java
+++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/BeanValidator.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.
@@ -307,7 +308,7 @@ public class BeanValidator {
return true;
}
- BeanValidationResult result2 = (value instanceof ParameterGroup ? ((ParameterGroup) value).validate()
+ BeanValidationResult result2 = (value instanceof ParameterGroup parameterGroup ? parameterGroup.validate()
: validateTop(fieldName, value));
if (result2.isClean()) {
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/ParameterGroupTest.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/ParameterGroupTest.java
new file mode 100644
index 00000000..d90b13d4
--- /dev/null
+++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/ParameterGroupTest.java
@@ -0,0 +1,93 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.common.parameters;
+
+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 static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+class ParameterGroupTest {
+
+ private ParameterGroup parameterGroup;
+
+ @BeforeEach
+ void setUp() {
+ parameterGroup = new ParameterGroup() {
+ private String name;
+ private BeanValidationResult validationResult = new BeanValidationResult("testGroup", "testObject");
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ @Override
+ public BeanValidationResult validate() {
+ return validationResult;
+ }
+ };
+ }
+
+ @Test
+ void testGetName() {
+ String testName = "TestGroupName";
+ parameterGroup.setName(testName);
+ assertEquals(testName, parameterGroup.getName(), "The group name should match the one set");
+ }
+
+ @Test
+ void testSetName() {
+ String testName = "AnotherGroupName";
+ parameterGroup.setName(testName);
+ assertEquals(testName, parameterGroup.getName(), "The group name should match the one set");
+ }
+
+ @Test
+ void testValidate() {
+ BeanValidationResult result = parameterGroup.validate();
+ assertNotNull(result, "The validation result should not be null");
+ assertEquals("testGroup", result.getName(), "The validation result should have the correct group name");
+ }
+
+ @Test
+ void testIsValid() {
+ BeanValidationResult mockValidationResult = mock(BeanValidationResult.class);
+ ValidationStatus mockStatus = mock(ValidationStatus.class);
+
+ when(mockStatus.isValid()).thenReturn(true);
+ when(mockValidationResult.getStatus()).thenReturn(mockStatus);
+
+ ParameterGroup mockedParameterGroup = spy(parameterGroup);
+ doReturn(mockValidationResult).when(mockedParameterGroup).validate();
+
+ assertTrue(mockedParameterGroup.isValid(), "The parameters should be valid");
+ }
+}
diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/ParameterServiceTest.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/ParameterServiceTest.java
new file mode 100644
index 00000000..7091f568
--- /dev/null
+++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/ParameterServiceTest.java
@@ -0,0 +1,161 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.common.parameters;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.Map;
+import java.util.Set;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+class ParameterServiceTest {
+
+ private static class TestParameterGroup implements ParameterGroup {
+ private final String name;
+
+ TestParameterGroup(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String getName() {
+ return this.name;
+ }
+
+ @Override
+ public void setName(String name) {
+ // do nothing
+ }
+
+ @Override
+ public BeanValidationResult validate() {
+ return null;
+ }
+
+ @Override
+ public boolean isValid() {
+ return ParameterGroup.super.isValid();
+ }
+ }
+
+ @BeforeEach
+ void setUp() {
+ ParameterService.clear();
+ }
+
+ @Test
+ void testRegisterAndRetrieveParameterGroup() {
+ TestParameterGroup group = new TestParameterGroup("testGroup");
+
+ ParameterService.register(group);
+ ParameterGroup retrievedGroup = ParameterService.get("testGroup");
+
+ assertEquals(group, retrievedGroup, "The retrieved group should be the same as the registered group.");
+ }
+
+ @Test
+ void testRegisterDuplicateParameterGroupThrowsException() {
+ TestParameterGroup group = new TestParameterGroup("testGroup");
+
+ ParameterService.register(group);
+
+ TestParameterGroup testGroup = new TestParameterGroup("testGroup");
+ assertThrows(ParameterRuntimeException.class, () -> {
+ ParameterService.register(testGroup);
+ }, "Registering a duplicate parameter group should throw an exception.");
+ }
+
+ @Test
+ void testRegisterWithOverwrite() {
+ TestParameterGroup group1 = new TestParameterGroup("testGroup");
+ TestParameterGroup group2 = new TestParameterGroup("testGroup");
+
+ ParameterService.register(group1);
+ ParameterService.register(group2, true); // Overwrite the existing group
+
+ ParameterGroup retrievedGroup = ParameterService.get("testGroup");
+ assertEquals(group2, retrievedGroup,
+ "The retrieved group should be the newly registered group after overwrite.");
+ }
+
+ @Test
+ void testDeregisterParameterGroupByName() {
+ TestParameterGroup group = new TestParameterGroup("testGroup");
+
+ ParameterService.register(group);
+ ParameterService.deregister("testGroup");
+
+ assertThrows(ParameterRuntimeException.class, () -> {
+ ParameterService.get("testGroup");
+ }, "Deregistering a parameter group should remove it from the service.");
+ }
+
+ @Test
+ void testDeregisterParameterGroupByInstance() {
+ TestParameterGroup group = new TestParameterGroup("testGroup");
+
+ ParameterService.register(group);
+ ParameterService.deregister(group);
+
+ assertThrows(ParameterRuntimeException.class, () -> {
+ ParameterService.get("testGroup");
+ }, "Deregistering a parameter group by instance should remove it from the service.");
+ }
+
+ @Test
+ void testContainsParameterGroup() {
+ TestParameterGroup group = new TestParameterGroup("testGroup");
+
+ ParameterService.register(group);
+
+ assertTrue(ParameterService.contains("testGroup"), "The parameter group should be contained in the service.");
+ assertFalse(ParameterService.contains("nonExistentGroup"),
+ "A non-existent parameter group should not be contained in the service.");
+ }
+
+ @Test
+ void testGetAllParameterGroups() {
+ TestParameterGroup group1 = new TestParameterGroup("group1");
+ TestParameterGroup group2 = new TestParameterGroup("group2");
+
+ ParameterService.register(group1);
+ ParameterService.register(group2);
+
+ Set<Map.Entry<String, ParameterGroup>> allGroups = ParameterService.getAll();
+ assertEquals(2, allGroups.size(), "There should be exactly 2 parameter groups in the service.");
+ assertTrue(allGroups.stream().anyMatch(entry -> entry.getKey().equals("group1")),
+ "The service should contain group1.");
+ assertTrue(allGroups.stream().anyMatch(entry -> entry.getKey().equals("group2")),
+ "The service should contain group2.");
+ }
+
+ @Test
+ void testClearParameterGroups() {
+ TestParameterGroup group = new TestParameterGroup("testGroup");
+
+ ParameterService.register(group);
+ ParameterService.clear();
+
+ assertFalse(ParameterService.contains("testGroup"), "All parameter groups should be cleared from the service.");
+ }
+}
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();
}
diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/validation/ParameterGroupValidatorTest.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/validation/ParameterGroupValidatorTest.java
new file mode 100644
index 00000000..0c7f29b7
--- /dev/null
+++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/validation/ParameterGroupValidatorTest.java
@@ -0,0 +1,91 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.common.parameters.validation;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.anyString;
+import static org.mockito.Mockito.inOrder;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import jakarta.validation.ConstraintValidatorContext;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.mockito.InOrder;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.onap.policy.common.parameters.BeanValidationResult;
+import org.onap.policy.common.parameters.ParameterGroup;
+
+class ParameterGroupValidatorTest {
+
+ private ParameterGroupValidator validator;
+
+ @Mock
+ private ParameterGroup mockParameterGroup;
+
+ @Mock
+ private BeanValidationResult mockBeanValidationResult;
+
+ @Mock
+ private ConstraintValidatorContext mockContext;
+
+ @Mock
+ private ConstraintValidatorContext.ConstraintViolationBuilder mockViolationBuilder;
+
+ @BeforeEach
+ void setUp() {
+ MockitoAnnotations.openMocks(this);
+ validator = new ParameterGroupValidator();
+ }
+
+ @Test
+ void testIsValid_NullValue() {
+ boolean result = validator.isValid(null, mockContext);
+ assertTrue(result, "Expected isValid to return true when value is null");
+ }
+
+ @Test
+ void testIsValid_ValidParameterGroup() {
+ when(mockParameterGroup.validate()).thenReturn(mockBeanValidationResult);
+ when(mockBeanValidationResult.isValid()).thenReturn(true);
+
+ boolean result = validator.isValid(mockParameterGroup, mockContext);
+ assertTrue(result, "Expected isValid to return true when ParameterGroup is valid");
+
+ verify(mockContext, never()).buildConstraintViolationWithTemplate(anyString());
+ }
+
+ @Test
+ void testIsValid_InvalidParameterGroup() {
+ when(mockParameterGroup.validate()).thenReturn(mockBeanValidationResult);
+ when(mockBeanValidationResult.isValid()).thenReturn(false);
+ when(mockBeanValidationResult.getMessage()).thenReturn("Invalid parameters");
+ when(mockContext.buildConstraintViolationWithTemplate(anyString())).thenReturn(mockViolationBuilder);
+
+ boolean result = validator.isValid(mockParameterGroup, mockContext);
+ assertFalse(result, "Expected isValid to return false when ParameterGroup is invalid");
+
+ InOrder inOrder = inOrder(mockContext, mockViolationBuilder);
+ inOrder.verify(mockContext).buildConstraintViolationWithTemplate("Invalid parameters");
+ inOrder.verify(mockViolationBuilder).addConstraintViolation();
+ }
+}