|
14 | 14 | * See the License for the specific language governing permissions and |
15 | 15 | * limitations under the License. |
16 | 16 | */ |
| 17 | + |
17 | 18 | package org.apache.commons.collections4; |
18 | 19 |
|
19 | | -import static org.junit.jupiter.api.Assertions.assertAll; |
20 | 20 | import static org.junit.jupiter.api.Assertions.assertInstanceOf; |
21 | 21 | import static org.junit.jupiter.api.Assertions.assertSame; |
22 | 22 | import static org.junit.jupiter.api.Assertions.assertThrows; |
@@ -46,82 +46,63 @@ public class BagUtilsTest { |
46 | 46 | public void testPredicatedBag() { |
47 | 47 | final Bag<Object> bag = BagUtils.predicatedBag(new HashBag<>(), truePredicate); |
48 | 48 | assertInstanceOf(PredicatedBag.class, bag, "Returned object should be a PredicatedBag."); |
49 | | - assertAll( |
50 | | - () -> assertThrows(NullPointerException.class, () -> BagUtils.predicatedBag(null, truePredicate), |
51 | | - "Expecting NullPointerException for null bag."), |
52 | | - () -> assertThrows(NullPointerException.class, () -> BagUtils.predicatedBag(new HashBag<>(), null), |
53 | | - "Expecting NullPointerException for null predicate.") |
54 | | - ); |
| 49 | + assertThrows(NullPointerException.class, () -> BagUtils.predicatedBag(null, truePredicate), "Expecting NullPointerException for null bag."); |
| 50 | + assertThrows(NullPointerException.class, () -> BagUtils.predicatedBag(new HashBag<>(), null), "Expecting NullPointerException for null predicate."); |
55 | 51 | } |
56 | 52 |
|
57 | 53 | @Test |
58 | 54 | public void testPredicatedSortedBag() { |
59 | 55 | final Bag<Object> bag = BagUtils.predicatedSortedBag(new TreeBag<>(), truePredicate); |
60 | 56 | assertInstanceOf(PredicatedSortedBag.class, bag, "Returned object should be a PredicatedSortedBag."); |
61 | | - assertAll( |
62 | | - () -> assertThrows(NullPointerException.class, () -> BagUtils.predicatedSortedBag(null, truePredicate), |
63 | | - "Expecting NullPointerException for null bag."), |
64 | | - () -> assertThrows(NullPointerException.class, () -> BagUtils.predicatedSortedBag(new TreeBag<>(), null), |
65 | | - "Expecting NullPointerException for null predicate.") |
66 | | - ); |
| 57 | + assertThrows(NullPointerException.class, () -> BagUtils.predicatedSortedBag(null, truePredicate), "Expecting NullPointerException for null bag."); |
| 58 | + assertThrows(NullPointerException.class, () -> BagUtils.predicatedSortedBag(new TreeBag<>(), null), |
| 59 | + "Expecting NullPointerException for null predicate."); |
67 | 60 | } |
68 | 61 |
|
69 | 62 | @Test |
70 | 63 | public void testSynchronizedBag() { |
71 | 64 | final Bag<Object> bag = BagUtils.synchronizedBag(new HashBag<>()); |
72 | 65 | assertInstanceOf(SynchronizedBag.class, bag, "Returned object should be a SynchronizedBag."); |
73 | | - assertThrows(NullPointerException.class, () -> BagUtils.synchronizedBag(null), |
74 | | - "Expecting NullPointerException for null bag."); |
| 66 | + assertThrows(NullPointerException.class, () -> BagUtils.synchronizedBag(null), "Expecting NullPointerException for null bag."); |
75 | 67 | } |
76 | 68 |
|
77 | 69 | @Test |
78 | 70 | public void testSynchronizedSortedBag() { |
79 | 71 | final Bag<Object> bag = BagUtils.synchronizedSortedBag(new TreeBag<>()); |
80 | 72 | assertInstanceOf(SynchronizedSortedBag.class, bag, "Returned object should be a SynchronizedSortedBag."); |
81 | | - assertThrows(NullPointerException.class, () -> BagUtils.synchronizedSortedBag(null), |
82 | | - "Expecting NullPointerException for null bag."); |
| 73 | + assertThrows(NullPointerException.class, () -> BagUtils.synchronizedSortedBag(null), "Expecting NullPointerException for null bag."); |
83 | 74 | } |
84 | 75 |
|
85 | 76 | @Test |
86 | 77 | public void testTransformedBag() { |
87 | 78 | final Bag<Object> bag = BagUtils.transformingBag(new HashBag<>(), nopTransformer); |
88 | 79 | assertInstanceOf(TransformedBag.class, bag, "Returned object should be an TransformedBag."); |
89 | | - assertAll( |
90 | | - () -> assertThrows(NullPointerException.class, () -> BagUtils.transformingBag(null, nopTransformer), |
91 | | - "Expecting NullPointerException for null bag."), |
92 | | - () -> assertThrows(NullPointerException.class, () -> BagUtils.transformingBag(new HashBag<>(), null), |
93 | | - "Expecting NullPointerException for null transformer.") |
94 | | - ); |
| 80 | + assertThrows(NullPointerException.class, () -> BagUtils.transformingBag(null, nopTransformer), "Expecting NullPointerException for null bag."); |
| 81 | + assertThrows(NullPointerException.class, () -> BagUtils.transformingBag(new HashBag<>(), null), "Expecting NullPointerException for null transformer."); |
95 | 82 | } |
96 | 83 |
|
97 | 84 | @Test |
98 | 85 | public void testTransformedSortedBag() { |
99 | 86 | final Bag<Object> bag = BagUtils.transformingSortedBag(new TreeBag<>(), nopTransformer); |
100 | 87 | assertInstanceOf(TransformedSortedBag.class, bag, "Returned object should be an TransformedSortedBag"); |
101 | | - assertAll( |
102 | | - () -> assertThrows(NullPointerException.class, () -> BagUtils.transformingSortedBag(null, nopTransformer), |
103 | | - "Expecting NullPointerException for null bag."), |
104 | | - () -> assertThrows(NullPointerException.class, () -> BagUtils.transformingSortedBag(new TreeBag<>(), null), |
105 | | - "Expecting NullPointerException for null transformer.") |
106 | | - ); |
| 88 | + assertThrows(NullPointerException.class, () -> BagUtils.transformingSortedBag(null, nopTransformer), "Expecting NullPointerException for null bag."); |
| 89 | + assertThrows(NullPointerException.class, () -> BagUtils.transformingSortedBag(new TreeBag<>(), null), |
| 90 | + "Expecting NullPointerException for null transformer."); |
107 | 91 | } |
108 | 92 |
|
109 | 93 | @Test |
110 | 94 | public void testUnmodifiableBag() { |
111 | 95 | final Bag<Object> bag = BagUtils.unmodifiableBag(new HashBag<>()); |
112 | 96 | assertInstanceOf(UnmodifiableBag.class, bag, "Returned object should be an UnmodifiableBag."); |
113 | | - assertThrows(NullPointerException.class, () -> BagUtils.unmodifiableBag(null), |
114 | | - "Expecting NullPointerException for null bag."); |
| 97 | + assertThrows(NullPointerException.class, () -> BagUtils.unmodifiableBag(null), "Expecting NullPointerException for null bag."); |
115 | 98 | assertSame(bag, BagUtils.unmodifiableBag(bag), "UnmodifiableBag shall not be decorated"); |
116 | 99 | } |
117 | 100 |
|
118 | 101 | @Test |
119 | 102 | public void testUnmodifiableSortedBag() { |
120 | 103 | final SortedBag<Object> bag = BagUtils.unmodifiableSortedBag(new TreeBag<>()); |
121 | 104 | assertInstanceOf(UnmodifiableSortedBag.class, bag, "Returned object should be an UnmodifiableSortedBag."); |
122 | | - assertThrows(NullPointerException.class, () -> BagUtils.unmodifiableSortedBag(null), |
123 | | - "Expecting NullPointerException for null bag."); |
| 105 | + assertThrows(NullPointerException.class, () -> BagUtils.unmodifiableSortedBag(null), "Expecting NullPointerException for null bag."); |
124 | 106 | assertSame(bag, BagUtils.unmodifiableSortedBag(bag), "UnmodifiableSortedBag shall not be decorated"); |
125 | 107 | } |
126 | | - |
127 | 108 | } |
0 commit comments