Replace assertThat(x.isEmpty()).isTrue() with assertThat(x).isEmpty()

Search for   : assertThat\((.+).isEmpty\(\)\).isTrue\(\)
Replace with : assertThat($1).isEmpty()

Search for   : assertThat\((.+).isEmpty\(\)\).isFalse\(\)
Replace with : assertThat($1).isNotEmpty()

Closes gh-31758
This commit is contained in:
Yanming Zhou
2023-12-06 09:34:06 +08:00
committed by Brian Clozel
parent 7b16ef90f1
commit afcd03bddc
55 changed files with 135 additions and 134 deletions

View File

@@ -171,8 +171,8 @@ class AnnotatedElementUtilsTests {
@Test
void getMetaAnnotationTypesOnNonAnnotatedClass() {
assertThat(getMetaAnnotationTypes(NonAnnotatedClass.class, TransactionalComponent.class).isEmpty()).isTrue();
assertThat(getMetaAnnotationTypes(NonAnnotatedClass.class, TransactionalComponent.class.getName()).isEmpty()).isTrue();
assertThat(getMetaAnnotationTypes(NonAnnotatedClass.class, TransactionalComponent.class)).isEmpty();
assertThat(getMetaAnnotationTypes(NonAnnotatedClass.class, TransactionalComponent.class.getName())).isEmpty();
}
@Test
@@ -869,7 +869,7 @@ class AnnotatedElementUtilsTests {
void getAllMergedAnnotationsOnClassWithInterface() throws Exception {
Method method = TransactionalServiceImpl.class.getMethod("doIt");
Set<Transactional> allMergedAnnotations = getAllMergedAnnotations(method, Transactional.class);
assertThat(allMergedAnnotations.isEmpty()).isTrue();
assertThat(allMergedAnnotations).isEmpty();
}
@Test

View File

@@ -96,7 +96,7 @@ class CollectionToCollectionConverterTests {
@SuppressWarnings("unchecked")
ArrayList<Integer> result = (ArrayList<Integer>) conversionService.convert(list, sourceType, targetType);
assertThat(result.getClass()).isEqualTo(ArrayList.class);
assertThat(result.isEmpty()).isTrue();
assertThat(result).isEmpty();
}
@Test

View File

@@ -628,7 +628,7 @@ class AntPathMatcherTests {
pathMatcher.match("test" + i, "test");
}
// Cache turned off because it went beyond the threshold
assertThat(pathMatcher.stringMatcherCache.isEmpty()).isTrue();
assertThat(pathMatcher.stringMatcherCache).isEmpty();
}
@Test
@@ -680,7 +680,7 @@ class AntPathMatcherTests {
void cachePatternsSetToFalse() {
pathMatcher.setCachePatterns(false);
match();
assertThat(pathMatcher.stringMatcherCache.isEmpty()).isTrue();
assertThat(pathMatcher.stringMatcherCache).isEmpty();
}
@Test

View File

@@ -217,7 +217,7 @@ class CollectionUtilsTests {
@Test
void conversionOfEmptyMap() {
MultiValueMap<String, String> asMultiValueMap = CollectionUtils.toMultiValueMap(new HashMap<>());
assertThat(asMultiValueMap.isEmpty()).isTrue();
assertThat(asMultiValueMap).isEmpty();
assertThat(asMultiValueMap).isEmpty();
}

View File

@@ -272,7 +272,7 @@ class ConcurrentReferenceHashMapTests {
assertThat(this.map.get(123)).isEqualTo("123");
assertThat(this.map.remove(123, "123")).isTrue();
assertThat(this.map.containsKey(123)).isFalse();
assertThat(this.map.isEmpty()).isTrue();
assertThat(this.map).isEmpty();
}
@Test
@@ -282,7 +282,7 @@ class ConcurrentReferenceHashMapTests {
assertThat(this.map.get(123)).isNull();
assertThat(this.map.remove(123, null)).isTrue();
assertThat(this.map.containsKey(123)).isFalse();
assertThat(this.map.isEmpty()).isTrue();
assertThat(this.map).isEmpty();
}
@Test
@@ -328,11 +328,11 @@ class ConcurrentReferenceHashMapTests {
@Test
void shouldSupportIsEmpty() {
assertThat(this.map.isEmpty()).isTrue();
assertThat(this.map).isEmpty();
this.map.put(123, "123");
this.map.put(123, null);
this.map.put(456, "456");
assertThat(this.map.isEmpty()).isFalse();
assertThat(this.map).isNotEmpty();
}
@Test
@@ -363,14 +363,14 @@ class ConcurrentReferenceHashMapTests {
assertThat(this.map.remove(123)).isNull();
assertThat(this.map.remove(456)).isEqualTo("456");
assertThat(this.map.remove(null)).isEqualTo("789");
assertThat(this.map.isEmpty()).isTrue();
assertThat(this.map).isEmpty();
}
@Test
void shouldRemoveWhenKeyIsNotInMap() {
assertThat(this.map.remove(123)).isNull();
assertThat(this.map.remove(null)).isNull();
assertThat(this.map.isEmpty()).isTrue();
assertThat(this.map).isEmpty();
}
@Test

View File

@@ -50,7 +50,7 @@ class UnmodifiableMultiValueMapTests {
assertThat(map).hasSize(1);
given(mock.isEmpty()).willReturn(false);
assertThat(map.isEmpty()).isFalse();
assertThat(map).isNotEmpty();
given(mock.containsKey("foo")).willReturn(true);
assertThat(map.containsKey("foo")).isTrue();