Skip to content

Commit a27104a

Browse files
committed
Polish
See gh-27981
1 parent a81ba68 commit a27104a

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,12 @@ public boolean matches(RuntimeHints hints) {
170170
return this.instrumentedMethod.matcher(this).test(hints);
171171
}
172172

173+
@Override
174+
public String toString() {
175+
return String.format("<%s> invocation of <%s> on type <%s> with arguments %s",
176+
getHintType().hintClassName(), getMethodReference(), getInstanceTypeReference(), getArguments());
177+
}
178+
173179
/**
174180
* Builder for {@link RecordedInvocation}.
175181
*/

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
* option, as a comma-separated list of packages to instrument prefixed with {@code "+"}
3434
* and packages to ignore prefixed with {@code "-"}:
3535
* <pre class="code">
36-
* -javaagent:/path/to/spring-runtimehints-agent.jar=+org.springframework,-io.spring,+org.example")
36+
* -javaagent:/path/to/spring-core-test.jar=+org.springframework,-io.spring,+org.example")
3737
* </pre>
3838
*
3939
* @author Brian Clozel

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.util.stream.Stream;
2424

2525
import org.assertj.core.api.AbstractAssert;
26+
import org.assertj.core.api.ListAssert;
2627
import org.assertj.core.error.BasicErrorMessageFactory;
2728
import org.assertj.core.error.ErrorMessageFactory;
2829

@@ -68,7 +69,7 @@ private void configureRuntimeHints(RuntimeHints hints) {
6869
* Example: <pre class="code">
6970
* RuntimeHints hints = new RuntimeHints();
7071
* hints.reflection().registerType(MyType.class);
71-
* assertThat(invocations).allMatch(hints); </pre>
72+
* assertThat(invocations).match(hints); </pre>
7273
* @param runtimeHints the runtime hints configuration to test against
7374
* @throws AssertionError if any of the recorded invocations has no match in the provided hints
7475
*/
@@ -82,6 +83,13 @@ public void match(RuntimeHints runtimeHints) {
8283
}
8384
}
8485

86+
public ListAssert<RecordedInvocation> notMatching(RuntimeHints runtimeHints) {
87+
Assert.notNull(runtimeHints, "RuntimeHints should not be null");
88+
configureRuntimeHints(runtimeHints);
89+
return ListAssert.assertThatStream(this.actual.recordedInvocations()
90+
.filter(invocation -> !invocation.matches(runtimeHints)));
91+
}
92+
8593

8694
private ErrorMessageFactory errorMessageForInvocation(RecordedInvocation invocation) {
8795
return new BasicErrorMessageFactory("%nMissing <%s> for invocation <%s> on type <%s> %nwith arguments %s.%nStacktrace:%n<%s>",

0 commit comments

Comments
 (0)