|
| 1 | +package com.blade.kit; |
| 2 | + |
| 3 | +import java.util.HashSet; |
| 4 | +import java.util.ArrayList; |
| 5 | +import java.util.HashMap; |
| 6 | +import org.junit.Test; |
| 7 | +import static org.junit.Assert.*; |
| 8 | + |
| 9 | +public class CollectionKitTest { |
| 10 | + |
| 11 | + @Test |
| 12 | + public void isEmpty() { |
| 13 | + final Object[] array = {}; |
| 14 | + assertTrue(CollectionKit.isEmpty(array)); |
| 15 | + |
| 16 | + final Object[] array2 = {null}; |
| 17 | + assertFalse(CollectionKit.isEmpty(array2)); |
| 18 | + |
| 19 | + final Object[] array3 = null; |
| 20 | + assertTrue(CollectionKit.isEmpty(array3)); |
| 21 | + |
| 22 | + final ArrayList collection = new ArrayList(); |
| 23 | + assertTrue(CollectionKit.isEmpty(collection)); |
| 24 | + |
| 25 | + final ArrayList collection2 = new ArrayList(); |
| 26 | + collection2.add(null); |
| 27 | + assertFalse(CollectionKit.isEmpty(collection2)); |
| 28 | + |
| 29 | + final ArrayList collection3 = null; |
| 30 | + assertTrue(CollectionKit.isEmpty(collection3)); |
| 31 | + } |
| 32 | + |
| 33 | + @Test |
| 34 | + public void isNotEmpty() { |
| 35 | + final Object[] array = {}; |
| 36 | + assertFalse(CollectionKit.isNotEmpty(array)); |
| 37 | + |
| 38 | + final Object[] array2 = {null}; |
| 39 | + assertTrue(CollectionKit.isNotEmpty(array2)); |
| 40 | + |
| 41 | + final Object[] array3 = null; |
| 42 | + assertFalse(CollectionKit.isNotEmpty(array3)); |
| 43 | + |
| 44 | + final ArrayList collection = new ArrayList(); |
| 45 | + assertFalse(CollectionKit.isNotEmpty(collection)); |
| 46 | + |
| 47 | + final ArrayList collection2 = new ArrayList(); |
| 48 | + collection2.add(null); |
| 49 | + assertTrue(CollectionKit.isNotEmpty(collection2)); |
| 50 | + |
| 51 | + final ArrayList collection3 = null; |
| 52 | + assertFalse(CollectionKit.isNotEmpty(collection3)); |
| 53 | + } |
| 54 | + |
| 55 | + @Test |
| 56 | + public void newConcurrentMap() { |
| 57 | + assertNotNull(CollectionKit.newConcurrentMap(0)); |
| 58 | + assertNotNull(CollectionKit.newConcurrentMap()); |
| 59 | + } |
| 60 | + |
| 61 | + @Test |
| 62 | + public void newMap() { |
| 63 | + assertEquals(new HashMap(), CollectionKit.newMap()); |
| 64 | + } |
| 65 | + |
| 66 | + @Test |
| 67 | + public void newLists() { |
| 68 | + final Object[] values = {}; |
| 69 | + assertEquals(new ArrayList(), CollectionKit.newLists(values)); |
| 70 | + } |
| 71 | + |
| 72 | + @Test |
| 73 | + public void newSets() { |
| 74 | + final Object[] values = {}; |
| 75 | + assertEquals(new HashSet(), CollectionKit.newSets(values)); |
| 76 | + } |
| 77 | +} |
| 78 | + |
0 commit comments