commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chtom...@apache.org
Subject [4/6] [lang] LANG-1167: Added more test cases for ReflectionToStringBuilderExcludeNullValuesTest
Date Thu, 20 Apr 2017 15:08:20 GMT
LANG-1167: Added more test cases for ReflectionToStringBuilderExcludeNullValuesTest


Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/3c2673e8
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/3c2673e8
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/3c2673e8

Branch: refs/heads/master
Commit: 3c2673e82d33b6c9bef3005a896e5b0d52b108dd
Parents: 661d16d
Author: MarkDacek <mark.dacek@richmond.edu>
Authored: Sat Mar 18 16:00:46 2017 -0400
Committer: MarkDacek <mark.dacek@richmond.edu>
Committed: Sat Mar 18 16:00:46 2017 -0400

----------------------------------------------------------------------
 ...ionToStringBuilderExcludeNullValuesTest.java | 51 ++++++++++++++++++--
 1 file changed, 48 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/3c2673e8/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java
b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java
index be368d6..7c0c68a 100644
--- a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java
@@ -72,10 +72,8 @@ public class ReflectionToStringBuilderExcludeNullValuesTest {
     
     @Test
     public void test_ConstructorOption(){
-        ReflectionToStringBuilder builder = new ReflectionToStringBuilder(BOTH_NON_NULL,
null, null, null, false, false, false);
-        builder.setExcludeNullValues(true);
+        ReflectionToStringBuilder builder = new ReflectionToStringBuilder(BOTH_NON_NULL,
null, null, null, false, false, true);
         assertTrue(builder.isExcludeNullValues());
-        
         String toString = builder.toString();
         assertTrue(toString.contains(INTEGER_FIELD_NAME));
         assertTrue(toString.contains(STRING_FIELD_NAME));
@@ -95,5 +93,52 @@ public class ReflectionToStringBuilderExcludeNullValuesTest {
         assertFalse(toString.contains(INTEGER_FIELD_NAME));
         assertFalse(toString.contains(STRING_FIELD_NAME));
     }
+    
+    @Test
+    public void test_ConstructorOptionNormal(){
+        ReflectionToStringBuilder builder = new ReflectionToStringBuilder(BOTH_NULL, null,
null, null, false, false, false);
+        assertFalse(builder.isExcludeNullValues());
+        String toString = builder.toString();
+        assertTrue(toString.contains(STRING_FIELD_NAME));
+        assertTrue(toString.contains(INTEGER_FIELD_NAME));
+        
+        //regression test older constructors
+        ReflectionToStringBuilder oldBuilder = new ReflectionToStringBuilder(BOTH_NULL);
+        toString = oldBuilder.toString();
+        assertTrue(toString.contains(STRING_FIELD_NAME));
+        assertTrue(toString.contains(INTEGER_FIELD_NAME));
+        
+        oldBuilder = new ReflectionToStringBuilder(BOTH_NULL, null, null, null, false, false);
+        toString = oldBuilder.toString();
+        assertTrue(toString.contains(STRING_FIELD_NAME));
+        assertTrue(toString.contains(INTEGER_FIELD_NAME));
+        
+        oldBuilder = new ReflectionToStringBuilder(BOTH_NULL, null, null);
+        toString = oldBuilder.toString();
+        assertTrue(toString.contains(STRING_FIELD_NAME));
+        assertTrue(toString.contains(INTEGER_FIELD_NAME));
+    }
+    
+    @Test
+    public void test_ConstructorOption_ExcludeNull(){
+        ReflectionToStringBuilder builder = new ReflectionToStringBuilder(BOTH_NULL, null,
null, null, false, false, false);
+        builder.setExcludeNullValues(true);
+        assertTrue(builder.isExcludeNullValues());
+        String toString = builder.toString();
+        assertFalse(toString.contains(STRING_FIELD_NAME));
+        assertFalse(toString.contains(INTEGER_FIELD_NAME));
+        
+        builder = new ReflectionToStringBuilder(BOTH_NULL, null, null, null, false, false,
true);
+        toString = builder.toString();
+        assertFalse(toString.contains(STRING_FIELD_NAME));
+        assertFalse(toString.contains(INTEGER_FIELD_NAME));
+        
+        ReflectionToStringBuilder oldBuilder = new ReflectionToStringBuilder(BOTH_NULL);
+        oldBuilder.setExcludeNullValues(true);
+        assertTrue(oldBuilder.isExcludeNullValues());
+        toString = oldBuilder.toString();
+        assertFalse(toString.contains(STRING_FIELD_NAME));
+        assertFalse(toString.contains(INTEGER_FIELD_NAME));
+    }
 
 }


Mime
View raw message