Refactor AssertJ assertions into more idiomatic ones

This commit refactors some AssertJ assertions into more idiomatic and
readable ones. Using the dedicated assertion instead of a generic one
will produce more meaningful error messages. 

For instance, consider collection size:
```
// expected: 5 but was: 2
assertThat(collection.size()).equals(5);
// Expected size: 5 but was: 2 in: [1, 2]
assertThat(collection).hasSize(5);
```

Closes gh-30104
This commit is contained in:
Krzysztof Krasoń
2023-04-04 17:34:07 +02:00
committed by GitHub
parent dd97ee4e99
commit 1734deca1e
371 changed files with 3177 additions and 3076 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -543,7 +543,7 @@ public abstract class AbstractCacheAnnotationTests {
Object r1 = service.multiConditionalCacheAndEvict(key);
Object r3 = service.multiConditionalCacheAndEvict(key);
assertThat(!r1.equals(r3)).isTrue();
assertThat(r1.equals(r3)).isFalse();
assertThat(primary.get(key)).isNull();
Object key2 = 3;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -92,7 +92,7 @@ public class AspectJEnableCachingIsolatedTests {
load(MultiCacheManagerConfig.class);
}
catch (IllegalStateException ex) {
assertThat(ex.getMessage().contains("bean of type CacheManager")).isTrue();
assertThat(ex.getMessage()).contains("bean of type CacheManager");
}
}
@@ -107,7 +107,7 @@ public class AspectJEnableCachingIsolatedTests {
load(MultiCacheManagerConfigurer.class, EnableCachingConfig.class);
}
catch (IllegalStateException ex) {
assertThat(ex.getMessage().contains("implementations of CachingConfigurer")).isTrue();
assertThat(ex.getMessage()).contains("implementations of CachingConfigurer");
}
}
@@ -117,7 +117,7 @@ public class AspectJEnableCachingIsolatedTests {
load(EmptyConfig.class);
}
catch (IllegalStateException ex) {
assertThat(ex.getMessage().contains("no bean of type CacheManager")).isTrue();
assertThat(ex.getMessage()).contains("no bean of type CacheManager");
}
}