1 package org.oxerr.commons.ws.rs.bean; 2 3 import static org.junit.jupiter.api.Assertions.assertEquals; 4 import static org.junit.jupiter.api.Assertions.assertNull; 5 6 import java.lang.annotation.Annotation; 7 import java.util.HashSet; 8 import java.util.Set; 9 10 import javax.persistence.Version; 11 12 import org.junit.jupiter.api.BeforeEach; 13 import org.junit.jupiter.api.Test; 14 15 class BeanUtilsNullTest { 16 17 private Bean dest; 18 19 @BeforeEach 20 public void setUp() throws Exception { 21 dest = new Bean(); 22 } 23 24 @Test 25 void testPatchTObject() { 26 assertNull(BeanUtils.patch(null, null)); 27 assertEquals(dest, BeanUtils.patch(dest, null)); 28 } 29 30 @Test 31 void testPatchTObjectStringArray() { 32 assertNull(BeanUtils.patch(null, null, "f1")); 33 assertEquals(dest, BeanUtils.patch(dest, null, "f1")); 34 } 35 36 @Test 37 void testPatchExcludeTObjectStringArray() { 38 assertNull(BeanUtils.patchExclude(null, null, "f2")); 39 assertEquals(dest, BeanUtils.patchExclude(dest, null, "f2")); 40 } 41 42 @Test 43 void testPatchExcludeTObjectSetOfClassOfQextendsAnnotation() { 44 Set<Class<? extends Annotation>> annotationTypes = new HashSet<>(); 45 annotationTypes.add(Version.class); 46 47 assertNull(BeanUtils.patchExclude(null, null, annotationTypes)); 48 assertEquals(dest, BeanUtils.patchExclude(dest, null, annotationTypes)); 49 } 50 51 @Test 52 void testPatchExcludeTObjectClassOfQArray() { 53 assertNull(BeanUtils.patchExclude(null, null, Version.class)); 54 assertEquals(dest, BeanUtils.patchExclude(dest, null, Version.class)); 55 } 56 57 @Test 58 void testCopyProperties() { 59 assertNull(BeanUtils.copyProperties(null, null, "f1")); 60 assertEquals(dest, BeanUtils.copyProperties(dest, null, "f1")); 61 } 62 63 }