|
37 | 37 | import static org.assertj.core.api.Assertions.assertThat;
|
38 | 38 | import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
39 | 39 | import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
| 40 | +import static org.assertj.core.api.Assertions.assertThatNoException; |
40 | 41 |
|
41 | 42 | /**
|
42 | 43 | * Tests for {@link ConcurrentReferenceHashMap}.
|
@@ -95,26 +96,23 @@ void shouldCreateFullyCustom() {
|
95 | 96 |
|
96 | 97 | @Test
|
97 | 98 | void shouldNeedNonNegativeInitialCapacity() {
|
98 |
| - new ConcurrentReferenceHashMap<Integer, String>(0, 1); |
99 |
| - assertThatIllegalArgumentException().isThrownBy(() -> |
100 |
| - new TestWeakConcurrentCache<Integer, String>(-1, 1)) |
101 |
| - .withMessageContaining("Initial capacity must not be negative"); |
| 99 | + assertThatNoException().isThrownBy(() -> new ConcurrentReferenceHashMap<Integer, String>(0, 1)); |
| 100 | + assertThatIllegalArgumentException().isThrownBy(() -> new ConcurrentReferenceHashMap<Integer, String>(-1, 1)) |
| 101 | + .withMessageContaining("Initial capacity must not be negative"); |
102 | 102 | }
|
103 | 103 |
|
104 | 104 | @Test
|
105 | 105 | void shouldNeedPositiveLoadFactor() {
|
106 |
| - new ConcurrentReferenceHashMap<Integer, String>(0, 0.1f, 1); |
107 |
| - assertThatIllegalArgumentException().isThrownBy(() -> |
108 |
| - new TestWeakConcurrentCache<Integer, String>(0, 0.0f, 1)) |
109 |
| - .withMessageContaining("Load factor must be positive"); |
| 106 | + assertThatNoException().isThrownBy(() -> new ConcurrentReferenceHashMap<Integer, String>(0, 0.1f, 1)); |
| 107 | + assertThatIllegalArgumentException().isThrownBy(() -> new ConcurrentReferenceHashMap<Integer, String>(0, 0.0f, 1)) |
| 108 | + .withMessageContaining("Load factor must be positive"); |
110 | 109 | }
|
111 | 110 |
|
112 | 111 | @Test
|
113 | 112 | void shouldNeedPositiveConcurrencyLevel() {
|
114 |
| - new ConcurrentReferenceHashMap<Integer, String>(1, 1); |
115 |
| - assertThatIllegalArgumentException().isThrownBy(() -> |
116 |
| - new TestWeakConcurrentCache<Integer, String>(1, 0)) |
117 |
| - .withMessageContaining("Concurrency level must be positive"); |
| 113 | + assertThatNoException().isThrownBy(() -> new ConcurrentReferenceHashMap<Integer, String>(1, 1)); |
| 114 | + assertThatIllegalArgumentException().isThrownBy(() -> new ConcurrentReferenceHashMap<Integer, String>(1, 0)) |
| 115 | + .withMessageContaining("Concurrency level must be positive"); |
118 | 116 | }
|
119 | 117 |
|
120 | 118 | @Test
|
|
0 commit comments