LANG-1167: Added more test cases for ReflectionToStringBuilderExcludeNullValuesTest
This commit is contained in:
parent
661d16d190
commit
3c2673e82d
|
@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue