This is an automated email from the ASF dual-hosted git repository.

lukaszlenart pushed a commit to branch WW-5142-oval
in repository https://gitbox.apache.org/repos/asf/struts.git


The following commit(s) were added to refs/heads/WW-5142-oval by this push:
     new c1b48eb  WW-5143 Improves test
c1b48eb is described below

commit c1b48eb0ef47b7088d2c07255d81dac02a066862
Author: Lukasz Lenart <lukaszlen...@apache.org>
AuthorDate: Fri Oct 1 16:40:10 2021 +0200

    WW-5143 Improves test
---
 .../interceptor/OValValidationInterceptorTest.java | 55 +++++++++++-----------
 .../oval/interceptor/ValidationInMethods.java      |  6 +--
 2 files changed, 31 insertions(+), 30 deletions(-)

diff --git 
a/plugins/oval/src/test/java/org/apache/struts2/oval/interceptor/OValValidationInterceptorTest.java
 
b/plugins/oval/src/test/java/org/apache/struts2/oval/interceptor/OValValidationInterceptorTest.java
index 3a88c51..74c8bca 100644
--- 
a/plugins/oval/src/test/java/org/apache/struts2/oval/interceptor/OValValidationInterceptorTest.java
+++ 
b/plugins/oval/src/test/java/org/apache/struts2/oval/interceptor/OValValidationInterceptorTest.java
@@ -25,6 +25,7 @@ import net.sf.oval.configuration.Configurer;
 import org.apache.struts2.config.StrutsXmlConfigurationProvider;
 
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 
@@ -36,8 +37,8 @@ public class OValValidationInterceptorTest extends 
XWorkTestCase {
         Map<String, List<String>> fieldErrors = ((ValidationAware) 
baseActionProxy.getAction()).getFieldErrors();
         assertNotNull(fieldErrors);
         assertEquals(2, fieldErrors.size());
-        assertValue(fieldErrors, "firstName", Arrays.asList("firstName cannot 
be null"));
-        assertValue(fieldErrors, "lastName", Arrays.asList("lastName cannot be 
null"));
+        assertValue(fieldErrors, "firstName", 
Collections.singletonList("firstName cannot be null"));
+        assertValue(fieldErrors, "lastName", 
Collections.singletonList("lastName cannot be null"));
     }
 
     public void testSimpleFieldsJPAAnnotations() throws Exception {
@@ -47,7 +48,7 @@ public class OValValidationInterceptorTest extends 
XWorkTestCase {
         Map<String, List<String>> fieldErrors = ((ValidationAware) 
baseActionProxy.getAction()).getFieldErrors();
         assertNotNull(fieldErrors);
         assertEquals(1, fieldErrors.size());
-        assertValue(fieldErrors, "firstName", Arrays.asList("firstName cannot 
be null"));
+        assertValue(fieldErrors, "firstName", 
Collections.singletonList("firstName cannot be null"));
     }
 
     public void testValidationInMethods() throws Exception {
@@ -57,10 +58,10 @@ public class OValValidationInterceptorTest extends 
XWorkTestCase {
         Map<String, List<String>> fieldErrors = ((ValidationAware) 
baseActionProxy.getAction()).getFieldErrors();
         assertNotNull(fieldErrors);
         assertEquals(4, fieldErrors.size());
-        assertValue(fieldErrors, "name", Arrays.asList("name cannot be null"));
-        assertValue(fieldErrors, "SisyphusHasTheAnswer", 
Arrays.asList("SisyphusHasTheAnswer cannot be null"));
-        assertValue(fieldErrors, "thereAnyMeaningInLife", 
Arrays.asList("thereAnyMeaningInLife cannot be null"));
-        assertValue(fieldErrors, "theManingOfLife", 
Arrays.asList("theManingOfLife cannot be null"));
+        assertValue(fieldErrors, "name", Collections.singletonList("name 
cannot be null"));
+        assertValue(fieldErrors, "SisyphusHasTheAnswer", 
Collections.singletonList("SisyphusHasTheAnswer cannot be null"));
+        assertValue(fieldErrors, "thereAnyMeaningInLife", 
Collections.singletonList("thereAnyMeaningInLife cannot be null"));
+        assertValue(fieldErrors, "theMeaningOfLife", 
Collections.singletonList("theMeaningOfLife cannot be null"));
     }
 
     public void testSimpleFieldsInheritedXML() throws Exception {
@@ -70,9 +71,9 @@ public class OValValidationInterceptorTest extends 
XWorkTestCase {
         Map<String, List<String>> fieldErrors = ((ValidationAware) 
baseActionProxy.getAction()).getFieldErrors();
         assertNotNull(fieldErrors);
         assertEquals(3, fieldErrors.size());
-        assertValue(fieldErrors, "firstName", Arrays.asList("firstName cannot 
be null"));
-        assertValue(fieldErrors, "lastName", Arrays.asList("lastName cannot be 
null"));
-        assertValue(fieldErrors, "middleName", Arrays.asList("middleName 
cannot be null"));
+        assertValue(fieldErrors, "firstName", 
Collections.singletonList("firstName cannot be null"));
+        assertValue(fieldErrors, "lastName", 
Collections.singletonList("lastName cannot be null"));
+        assertValue(fieldErrors, "middleName", 
Collections.singletonList("middleName cannot be null"));
     }
 
     public void testSlashesInNameWithWildcardsHitsCache() throws Exception {
@@ -106,7 +107,7 @@ public class OValValidationInterceptorTest extends 
XWorkTestCase {
         Map<String, List<String>> fieldErrors = ((ValidationAware) 
baseActionProxy.getAction()).getFieldErrors();
         assertNotNull(fieldErrors);
         assertEquals(1, fieldErrors.size());
-        assertValue(fieldErrors, "name", Arrays.asList("name cannot be null"));
+        assertValue(fieldErrors, "name", Collections.singletonList("name 
cannot be null"));
     }
 
     public void testSimpleFieldNegative() throws Exception {
@@ -131,8 +132,8 @@ public class OValValidationInterceptorTest extends 
XWorkTestCase {
 
         assertNotNull(fieldErrors);
         assertEquals(1, fieldErrors.size());
-        assertValue(fieldErrors, "name", Arrays.asList("name is not between 0 
and 3 characters long"));
-        assertValue(fieldErrors, "name", Arrays.asList("name is not between 0 
and 3 characters long"));
+        assertValue(fieldErrors, "name", Collections.singletonList("name is 
not between 0 and 3 characters long"));
+        assertValue(fieldErrors, "name", Collections.singletonList("name is 
not between 0 and 3 characters long"));
     }
 
     public void testSimpleFieldMultipleValidators() throws Exception {
@@ -201,7 +202,7 @@ public class OValValidationInterceptorTest extends 
XWorkTestCase {
 
         assertNotNull(fieldErrors);
         assertEquals(1, fieldErrors.size());
-        assertValue(fieldErrors, "name", Arrays.asList("name cannot be null"));
+        assertValue(fieldErrors, "name", Collections.singletonList("name 
cannot be null"));
     }
 
     public void testSimpleFieldI18n2() throws Exception {
@@ -214,7 +215,7 @@ public class OValValidationInterceptorTest extends 
XWorkTestCase {
 
         assertNotNull(fieldErrors);
         assertEquals(1, fieldErrors.size());
-        assertValue(fieldErrors, "name", Arrays.asList("name value is too 
long, allowed length is 3"));
+        assertValue(fieldErrors, "name", Collections.singletonList("name value 
is too long, allowed length is 3"));
     }
 
     public void testSimpleFieldI18nDefaultKey() throws Exception {
@@ -226,7 +227,7 @@ public class OValValidationInterceptorTest extends 
XWorkTestCase {
 
         assertNotNull(fieldErrors);
         assertEquals(1, fieldErrors.size());
-        assertValue(fieldErrors, "name", Arrays.asList("notnull.field"));
+        assertValue(fieldErrors, "name", 
Collections.singletonList("notnull.field"));
     }
 
 
@@ -238,7 +239,7 @@ public class OValValidationInterceptorTest extends 
XWorkTestCase {
         Map<String, List<String>> fieldErrors = ((ValidationAware) 
baseActionProxy.getAction()).getFieldErrors();
         assertNotNull(fieldErrors);
         assertEquals(1, fieldErrors.size());
-        assertValue(fieldErrors, "name", Arrays.asList("name cannot be null"));
+        assertValue(fieldErrors, "name", Collections.singletonList("name 
cannot be null"));
         assertTrue(action.isValidateCalled());
         assertTrue(action.isValidateExecuteCalled());
     }
@@ -251,7 +252,7 @@ public class OValValidationInterceptorTest extends 
XWorkTestCase {
         Map<String, List<String>> fieldErrors = ((ValidationAware) 
baseActionProxy.getAction()).getFieldErrors();
         assertNotNull(fieldErrors);
         assertEquals(1, fieldErrors.size());
-        assertValue(fieldErrors, "name", Arrays.asList("name cannot be null"));
+        assertValue(fieldErrors, "name", Collections.singletonList("name 
cannot be null"));
         assertFalse(action.isValidateCalled());
         assertTrue(action.isValidateExecuteCalled());
     }
@@ -264,7 +265,7 @@ public class OValValidationInterceptorTest extends 
XWorkTestCase {
         Map<String, List<String>> fieldErrors = ((ValidationAware) 
baseActionProxy.getAction()).getFieldErrors();
         assertNotNull(fieldErrors);
         assertEquals(1, fieldErrors.size());
-        assertValue(fieldErrors, "name", Arrays.asList("name cannot be null"));
+        assertValue(fieldErrors, "name", Collections.singletonList("name 
cannot be null"));
         assertFalse(action.isValidateCalled());
         assertFalse(action.isValidateExecuteCalled());
     }
@@ -280,10 +281,10 @@ public class OValValidationInterceptorTest extends 
XWorkTestCase {
 
         Map<String, List<String>> fieldErrors = ((ValidationAware) 
baseActionProxy.getAction()).getFieldErrors();
         assertNotNull(fieldErrors);
-        assertEquals(3, fieldErrors.size()); // 5: as there will be field 
errors for 'model' and 'address' themselves
-        assertValue(fieldErrors, "person.name", Arrays.asList("person.name 
cannot be null"));
-        assertValue(fieldErrors, "person.email", Arrays.asList("person.email 
cannot be null"));
-        assertValue(fieldErrors, "person.address.street", 
Arrays.asList("person.address.street cannot be shorter than 7 characters"));
+        assertEquals(3, fieldErrors.size());
+        assertValue(fieldErrors, "person.name", 
Collections.singletonList("person.name cannot be null"));
+        assertValue(fieldErrors, "person.email", 
Collections.singletonList("person.email cannot be null"));
+        assertValue(fieldErrors, "person.address.street", 
Collections.singletonList("person.address.street cannot be shorter than 7 
characters"));
     }
 
     public void testMemberObject() throws Exception {
@@ -296,10 +297,10 @@ public class OValValidationInterceptorTest extends 
XWorkTestCase {
 
         Map<String, List<String>> fieldErrors = ((ValidationAware) 
baseActionProxy.getAction()).getFieldErrors();
         assertNotNull(fieldErrors);
-        assertEquals(3, fieldErrors.size()); // 5: as there will be field 
errors for 'person' and 'person.address' themselves
-        assertValue(fieldErrors, "person.name", Arrays.asList("person.name 
cannot be null"));
-        assertValue(fieldErrors, "person.email", Arrays.asList("person.email 
cannot be null"));
-        assertValue(fieldErrors, "person.address.street", 
Arrays.asList("person.address.street cannot be shorter than 7 characters"));
+        assertEquals(3, fieldErrors.size());
+        assertValue(fieldErrors, "person.name", 
Collections.singletonList("person.name cannot be null"));
+        assertValue(fieldErrors, "person.email", 
Collections.singletonList("person.email cannot be null"));
+        assertValue(fieldErrors, "person.address.street", 
Collections.singletonList("person.address.street cannot be shorter than 7 
characters"));
     }
 
     private void assertValue(Map<String, List<String>> map, String key, 
List<String> expectedValues) {
diff --git 
a/plugins/oval/src/test/java/org/apache/struts2/oval/interceptor/ValidationInMethods.java
 
b/plugins/oval/src/test/java/org/apache/struts2/oval/interceptor/ValidationInMethods.java
index 6e8cd85..c470dc0 100644
--- 
a/plugins/oval/src/test/java/org/apache/struts2/oval/interceptor/ValidationInMethods.java
+++ 
b/plugins/oval/src/test/java/org/apache/struts2/oval/interceptor/ValidationInMethods.java
@@ -35,9 +35,9 @@ public class ValidationInMethods extends ActionSupport {
         return null;
     }
 
-    @IsInvariant 
+    @IsInvariant
     @NotNull
-    public String getTheManingOfLife() {
+    public String getTheMeaningOfLife() {
         return null;
     }
 
@@ -47,4 +47,4 @@ public class ValidationInMethods extends ActionSupport {
         //some method annotated, whose name is not a field
         return null;
     }
-}
\ No newline at end of file
+}

Reply via email to