1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.datadictionary.validation.utils;
17
18 import org.junit.Test;
19 import org.junit.Assert;
20 import org.kuali.rice.krad.datadictionary.validation.Person;
21 import org.kuali.rice.krad.datadictionary.validation.ValidationUtils;
22
23 import java.util.ArrayList;
24 import java.util.HashMap;
25 import java.util.HashSet;
26
27
28
29
30 public class NullOrEmptyTest {
31
32 @Test
33 public void testNullObject() {
34 Person person = null ;
35 Assert.assertTrue(ValidationUtils.isNullOrEmpty(person));
36 }
37
38 @Test
39 public void testNotNullObject() {
40 Person person = new Person();
41 Assert.assertFalse(ValidationUtils.isNullOrEmpty(person));
42 }
43
44 @Test
45 public void testStringEmpty() {
46 String message = "";
47 Assert.assertTrue(ValidationUtils.isNullOrEmpty(message));
48 }
49
50 @Test
51 public void testStringNotEmpty() {
52 String message = "Hi";
53 Assert.assertFalse(ValidationUtils.isNullOrEmpty(message));
54 }
55
56 @Test
57 public void testListEmpty() {
58 ArrayList<String> quickList = new ArrayList<String>();
59 Assert.assertTrue(ValidationUtils.isNullOrEmpty(quickList));
60 }
61
62 @Test
63 public void testListNotEmpty() {
64 ArrayList<String> quickList = new ArrayList<String>();
65 quickList.add("Hi");
66 Assert.assertFalse(ValidationUtils.isNullOrEmpty(quickList));
67 }
68
69 @Test
70 public void testSetEmpty() {
71 HashSet<String> quickSet = new HashSet<String>() ;
72 Assert.assertTrue(ValidationUtils.isNullOrEmpty(quickSet));
73 }
74
75 @Test
76 public void testSetNotEmpty() {
77 HashSet<String> quickSet = new HashSet<String>() ;
78 quickSet.add("Hi");
79 Assert.assertFalse(ValidationUtils.isNullOrEmpty(quickSet));
80 }
81
82 @Test
83 public void testMapEmpty() {
84 HashMap<String, String> quickMap = new HashMap<String, String>();
85 Assert.assertTrue(ValidationUtils.isNullOrEmpty(quickMap));
86 }
87
88 @Test
89 public void testMapNotEmpty() {
90 HashMap<String, String> quickMap = new HashMap<String, String>();
91 quickMap.put("Hi", "There!");
92 Assert.assertFalse(ValidationUtils.isNullOrEmpty(quickMap));
93 }
94 }