BAEL-869 - Java 8 example of listing null properties

This commit is contained in:
slavisa-baeldung
2017-06-07 09:12:49 +01:00
parent 0053a80758
commit 58a9ea0939
3 changed files with 124 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
package com.baeldung.reflection;
import org.junit.Assert;
import org.junit.Test;
import java.util.Arrays;
import java.util.List;
public class BaeldungReflectionUtilsTest {
@Test
public void givenCustomer_whenAFieldIsNull_thenFieldNameInResult() throws Exception {
Customer customer = new Customer(1, "Himanshu", null, null);
List<String> result = BaeldungReflectionUtils.getNullPropertiesList(customer);
List<String> expectedFieldNames = Arrays.asList("emailId", "phoneNumber");
Assert.assertTrue(result.size() == expectedFieldNames.size());
Assert.assertTrue(result.containsAll(expectedFieldNames));
}
}