Skip to content

Commit 06a39f1

Browse files
committedFeb 20, 2024
Consistent handling of AssertProvider implementations
1 parent 46bd133 commit 06a39f1

File tree

5 files changed

+18
-20
lines changed

5 files changed

+18
-20
lines changed
 

‎spring-core-test/src/main/java/org/springframework/aot/test/agent/RuntimeHintsInvocations.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -39,6 +39,10 @@ public class RuntimeHintsInvocations implements AssertProvider<RuntimeHintsInvoc
3939
this.invocations = invocations;
4040
}
4141

42+
/**
43+
* Use {@code assertThat(invocations)} rather than calling this method
44+
* directly.
45+
*/
4246
@Override
4347
public RuntimeHintsInvocationsAssert assertThat() {
4448
return new RuntimeHintsInvocationsAssert(this);

‎spring-core-test/src/main/java/org/springframework/core/test/tools/ResourceFile.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -86,12 +86,10 @@ public static ResourceFile of(String path, WritableContent writableContent) {
8686
}
8787

8888
/**
89-
* AssertJ {@code assertThat} support.
90-
* @deprecated use {@code assertThat(sourceFile)} rather than calling this
91-
* method directly.
89+
* Use {@code assertThat(sourceFile)} rather than calling this method
90+
* directly.
9291
*/
9392
@Override
94-
@Deprecated
9593
public ResourceFileAssert assertThat() {
9694
return new ResourceFileAssert(this);
9795
}

‎spring-core-test/src/main/java/org/springframework/core/test/tools/SourceFile.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -218,12 +218,10 @@ else if (ch == ')') {
218218
}
219219

220220
/**
221-
* AssertJ {@code assertThat} support.
222-
* @deprecated use {@code assertThat(sourceFile)} rather than calling this
223-
* method directly.
221+
* Use {@code assertThat(sourceFile)} rather than calling this method
222+
* directly.
224223
*/
225224
@Override
226-
@Deprecated
227225
public SourceFileAssert assertThat() {
228226
return new SourceFileAssert(this);
229227
}

‎spring-core-test/src/test/java/org/springframework/core/test/tools/ResourceFileTests.java

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -42,10 +42,9 @@ void ofPathAndWritableContentCreatesResource() {
4242
}
4343

4444
@Test
45-
@SuppressWarnings("deprecation")
46-
void assertThatReturnsResourceFileAssert() {
47-
ResourceFile file = ResourceFile.of("path", "test");
48-
assertThat(file.assertThat()).isInstanceOf(ResourceFileAssert.class);
45+
void assertThatUsesResourceFileAssert() {
46+
ResourceFile file = ResourceFile.of("path", appendable -> appendable.append("test"));
47+
assertThat(file).hasContent("test");
4948
}
5049

5150
}

‎spring-core-test/src/test/java/org/springframework/core/test/tools/SourceFileTests.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -106,10 +106,9 @@ void getContentReturnsContent() {
106106
}
107107

108108
@Test
109-
@SuppressWarnings("deprecation")
110-
void assertThatReturnsAssert() {
109+
void assertThatUseSourceFileAssert() {
111110
SourceFile sourceFile = SourceFile.of(HELLO_WORLD);
112-
assertThat(sourceFile.assertThat()).isInstanceOf(SourceFileAssert.class);
111+
assertThat(sourceFile).hasContent(HELLO_WORLD);
113112
}
114113

115114
@Test

0 commit comments

Comments
 (0)
Please sign in to comment.