Skip to content

Commit bc8514c

Browse files
committed
Merge pull request #17557 from dreis2211
* pr/17557: Remove testsupport.assertj package Closes gh-17557
2 parents 3bf5cf1 + 2038fac commit bc8514c

File tree

8 files changed

+14
-174
lines changed

8 files changed

+14
-174
lines changed

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionEvaluationReportTests.java

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import org.springframework.boot.autoconfigure.web.servlet.MultipartAutoConfiguration;
3535
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
3636
import org.springframework.boot.test.util.TestPropertyValues;
37-
import org.springframework.boot.testsupport.assertj.Matched;
3837
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
3938
import org.springframework.context.annotation.Bean;
4039
import org.springframework.context.annotation.Condition;
@@ -47,8 +46,6 @@
4746
import org.springframework.util.ClassUtils;
4847

4948
import static org.assertj.core.api.Assertions.assertThat;
50-
import static org.hamcrest.Matchers.containsString;
51-
import static org.hamcrest.Matchers.nullValue;
5249

5350
/**
5451
* Tests for {@link ConditionEvaluationReport}.
@@ -86,7 +83,7 @@ void setup() {
8683

8784
@Test
8885
void get() {
89-
assertThat(this.report).isNotEqualTo(nullValue());
86+
assertThat(this.report).isNotNull();
9087
assertThat(this.report).isSameAs(ConditionEvaluationReport.get(this.beanFactory));
9188
}
9289

@@ -95,8 +92,8 @@ void parent() {
9592
this.beanFactory.setParentBeanFactory(new DefaultListableBeanFactory());
9693
ConditionEvaluationReport.get((ConfigurableListableBeanFactory) this.beanFactory.getParentBeanFactory());
9794
assertThat(this.report).isSameAs(ConditionEvaluationReport.get(this.beanFactory));
98-
assertThat(this.report).isNotEqualTo(nullValue());
99-
assertThat(this.report.getParent()).isNotEqualTo(nullValue());
95+
assertThat(this.report).isNotNull();
96+
assertThat(this.report.getParent()).isNotNull();
10097
ConditionEvaluationReport.get((ConfigurableListableBeanFactory) this.beanFactory.getParentBeanFactory());
10198
assertThat(this.report).isSameAs(ConditionEvaluationReport.get(this.beanFactory));
10299
assertThat(this.report.getParent()).isSameAs(ConditionEvaluationReport
@@ -184,7 +181,7 @@ void testDuplicateConditionAndOutcomes() {
184181
outcomes.add(this.condition1, new ConditionOutcome(true, "Message 1"));
185182
outcomes.add(this.condition2, new ConditionOutcome(true, "Message 2"));
186183
outcomes.add(this.condition3, new ConditionOutcome(true, "Message 2"));
187-
assertThat(getNumberOfOutcomes(outcomes)).isEqualTo(2);
184+
assertThat(outcomes).hasSize(2);
188185
}
189186

190187
@Test
@@ -193,15 +190,15 @@ void duplicateOutcomes() {
193190
ConditionEvaluationReport report = ConditionEvaluationReport.get(context.getBeanFactory());
194191
String autoconfigKey = MultipartAutoConfiguration.class.getName();
195192
ConditionAndOutcomes outcomes = report.getConditionAndOutcomesBySource().get(autoconfigKey);
196-
assertThat(outcomes).isNotEqualTo(nullValue());
197-
assertThat(getNumberOfOutcomes(outcomes)).isEqualTo(2);
193+
assertThat(outcomes).isNotNull();
194+
assertThat(outcomes).hasSize(2);
198195
List<String> messages = new ArrayList<>();
199196
for (ConditionAndOutcome outcome : outcomes) {
200197
messages.add(outcome.getOutcome().getMessage());
201198
}
202-
assertThat(messages).areAtLeastOne(Matched.by(containsString("@ConditionalOnClass found required classes "
199+
assertThat(messages).anyMatch((message) -> message.contains("@ConditionalOnClass found required classes "
203200
+ "'javax.servlet.Servlet', 'org.springframework.web.multipart."
204-
+ "support.StandardServletMultipartResolver', 'javax.servlet.MultipartConfigElement'")));
201+
+ "support.StandardServletMultipartResolver', 'javax.servlet.MultipartConfigElement'"));
205202
context.close();
206203
}
207204

@@ -252,16 +249,6 @@ void reportMessageWhenSameShortNamePresentMoreThanOnceShouldUseFullyQualifiedNam
252249
context.close();
253250
}
254251

255-
private int getNumberOfOutcomes(ConditionAndOutcomes outcomes) {
256-
Iterator<ConditionAndOutcome> iterator = outcomes.iterator();
257-
int numberOfOutcomesAdded = 0;
258-
while (iterator.hasNext()) {
259-
numberOfOutcomesAdded++;
260-
iterator.next();
261-
}
262-
return numberOfOutcomesAdded;
263-
}
264-
265252
@Configuration(proxyBeanMethods = false)
266253
@Import(WebMvcAutoConfiguration.class)
267254
static class Config {

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ResourcePropertiesTests.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,9 @@
2121
import org.junit.jupiter.api.Test;
2222

2323
import org.springframework.boot.autoconfigure.web.ResourceProperties.Cache;
24-
import org.springframework.boot.testsupport.assertj.Matched;
2524
import org.springframework.http.CacheControl;
2625

2726
import static org.assertj.core.api.Assertions.assertThat;
28-
import static org.hamcrest.Matchers.endsWith;
2927

3028
/**
3129
* Tests for {@link ResourceProperties}.
@@ -62,7 +60,7 @@ void resourceChainDisabled() {
6260

6361
@Test
6462
void defaultStaticLocationsAllEndWithTrailingSlash() {
65-
assertThat(this.properties.getStaticLocations()).are(Matched.by(endsWith("/")));
63+
assertThat(this.properties.getStaticLocations()).allMatch((location) -> location.endsWith("/"));
6664
}
6765

6866
@Test

spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/install/GroovyGrabDependencyResolverTests.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,15 @@
2323
import java.util.List;
2424
import java.util.Set;
2525

26-
import org.assertj.core.api.Condition;
2726
import org.junit.jupiter.api.BeforeEach;
2827
import org.junit.jupiter.api.Test;
2928

3029
import org.springframework.boot.cli.compiler.GroovyCompilerConfiguration;
3130
import org.springframework.boot.cli.compiler.GroovyCompilerScope;
3231
import org.springframework.boot.cli.compiler.RepositoryConfigurationFactory;
3332
import org.springframework.boot.cli.compiler.grape.RepositoryConfiguration;
34-
import org.springframework.boot.testsupport.assertj.Matched;
3533

3634
import static org.assertj.core.api.Assertions.assertThat;
37-
import static org.hamcrest.Matchers.hasItems;
38-
import static org.hamcrest.Matchers.startsWith;
3935

4036
/**
4137
* Tests for {@link GroovyGrabDependencyResolver}.
@@ -104,12 +100,13 @@ void resolveArtifactWithDependencies() throws Exception {
104100
}
105101

106102
@Test
107-
@SuppressWarnings({ "unchecked", "rawtypes" })
108103
void resolveShorthandArtifactWithDependencies() throws Exception {
109104
List<File> resolved = this.resolver.resolve(Arrays.asList("spring-beans"));
110105
assertThat(resolved).hasSize(3);
111-
assertThat(getNames(resolved)).has((Condition) Matched
112-
.by(hasItems(startsWith("spring-core-"), startsWith("spring-beans-"), startsWith("spring-jcl-"))));
106+
Set<String> names = getNames(resolved);
107+
assertThat(names).anyMatch((name) -> name.startsWith("spring-core-"));
108+
assertThat(names).anyMatch((name) -> name.startsWith("spring-beans-"));
109+
assertThat(names).anyMatch((name) -> name.startsWith("spring-jcl-"));
113110
}
114111

115112
@Test

spring-boot-project/spring-boot-tools/spring-boot-test-support/pom.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@
4747
<groupId>org.springframework</groupId>
4848
<artifactId>spring-core</artifactId>
4949
</dependency>
50-
<dependency>
51-
<groupId>org.hamcrest</groupId>
52-
<artifactId>hamcrest</artifactId>
53-
</dependency>
5450
<dependency>
5551
<groupId>org.assertj</groupId>
5652
<artifactId>assertj-core</artifactId>

spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/assertj/Matched.java

Lines changed: 0 additions & 61 deletions
This file was deleted.

spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/assertj/package-info.java

Lines changed: 0 additions & 20 deletions
This file was deleted.

spring-boot-project/spring-boot-tools/spring-boot-test-support/src/test/java/org/springframework/boot/testsupport/assertj/MatchedTests.java

Lines changed: 0 additions & 56 deletions
This file was deleted.

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/type/classreading/ConcurrentReferenceCachingMetadataReaderFactoryTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import org.springframework.core.type.classreading.MetadataReader;
2323

2424
import static org.assertj.core.api.Assertions.assertThat;
25-
import static org.hamcrest.Matchers.sameInstance;
2625
import static org.mockito.ArgumentMatchers.any;
2726
import static org.mockito.Mockito.mock;
2827
import static org.mockito.Mockito.spy;
@@ -53,7 +52,7 @@ void clearResetsCache() throws Exception {
5352
MetadataReader metadataReader1 = factory.getMetadataReader(getClass().getName());
5453
factory.clearCache();
5554
MetadataReader metadataReader2 = factory.getMetadataReader(getClass().getName());
56-
assertThat(metadataReader1).isNotEqualTo(sameInstance(metadataReader2));
55+
assertThat(metadataReader1).isNotSameAs(metadataReader2);
5756
verify(factory, times(2)).createMetadataReader(any(Resource.class));
5857
}
5958

0 commit comments

Comments
 (0)