From b3a6dbaab38b7fe26ed8ef771fd282cd961f0433 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Sat, 4 Nov 2023 14:45:09 +0100 Subject: [PATCH] Polishing --- .../util/ConcurrentReferenceHashMapTests.java | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/spring-core/src/test/java/org/springframework/util/ConcurrentReferenceHashMapTests.java b/spring-core/src/test/java/org/springframework/util/ConcurrentReferenceHashMapTests.java index fad1fb33618..e207848061c 100644 --- a/spring-core/src/test/java/org/springframework/util/ConcurrentReferenceHashMapTests.java +++ b/spring-core/src/test/java/org/springframework/util/ConcurrentReferenceHashMapTests.java @@ -37,6 +37,7 @@ import org.springframework.util.comparator.Comparators; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; +import static org.assertj.core.api.Assertions.assertThatNoException; /** * Tests for {@link ConcurrentReferenceHashMap}. @@ -95,26 +96,23 @@ class ConcurrentReferenceHashMapTests { @Test void shouldNeedNonNegativeInitialCapacity() { - new ConcurrentReferenceHashMap(0, 1); - assertThatIllegalArgumentException().isThrownBy(() -> - new TestWeakConcurrentCache(-1, 1)) - .withMessageContaining("Initial capacity must not be negative"); + assertThatNoException().isThrownBy(() -> new ConcurrentReferenceHashMap(0, 1)); + assertThatIllegalArgumentException().isThrownBy(() -> new ConcurrentReferenceHashMap(-1, 1)) + .withMessageContaining("Initial capacity must not be negative"); } @Test void shouldNeedPositiveLoadFactor() { - new ConcurrentReferenceHashMap(0, 0.1f, 1); - assertThatIllegalArgumentException().isThrownBy(() -> - new TestWeakConcurrentCache(0, 0.0f, 1)) - .withMessageContaining("Load factor must be positive"); + assertThatNoException().isThrownBy(() -> new ConcurrentReferenceHashMap(0, 0.1f, 1)); + assertThatIllegalArgumentException().isThrownBy(() -> new ConcurrentReferenceHashMap(0, 0.0f, 1)) + .withMessageContaining("Load factor must be positive"); } @Test void shouldNeedPositiveConcurrencyLevel() { - new ConcurrentReferenceHashMap(1, 1); - assertThatIllegalArgumentException().isThrownBy(() -> - new TestWeakConcurrentCache(1, 0)) - .withMessageContaining("Concurrency level must be positive"); + assertThatNoException().isThrownBy(() -> new ConcurrentReferenceHashMap(1, 1)); + assertThatIllegalArgumentException().isThrownBy(() -> new ConcurrentReferenceHashMap(1, 0)) + .withMessageContaining("Concurrency level must be positive"); } @Test