Browse Source

Polish

See gh-27981
pull/28744/head
Brian Clozel 3 years ago
parent
commit
a27104a485
  1. 6
      spring-core-test/src/main/java/org/springframework/aot/agent/RecordedInvocation.java
  2. 2
      spring-core-test/src/main/java/org/springframework/aot/agent/RuntimeHintsAgent.java
  3. 10
      spring-core-test/src/main/java/org/springframework/aot/test/agent/RuntimeHintsInvocationsAssert.java

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

@ -170,6 +170,12 @@ public final class RecordedInvocation { @@ -170,6 +170,12 @@ public final class RecordedInvocation {
return this.instrumentedMethod.matcher(this).test(hints);
}
@Override
public String toString() {
return String.format("<%s> invocation of <%s> on type <%s> with arguments %s",
getHintType().hintClassName(), getMethodReference(), getInstanceTypeReference(), getArguments());
}
/**
* Builder for {@link RecordedInvocation}.
*/

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

@ -33,7 +33,7 @@ import org.springframework.util.StringUtils; @@ -33,7 +33,7 @@ import org.springframework.util.StringUtils;
* option, as a comma-separated list of packages to instrument prefixed with {@code "+"}
* and packages to ignore prefixed with {@code "-"}:
* <pre class="code">
* -javaagent:/path/to/spring-runtimehints-agent.jar=+org.springframework,-io.spring,+org.example")
* -javaagent:/path/to/spring-core-test.jar=+org.springframework,-io.spring,+org.example")
* </pre>
*
* @author Brian Clozel

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

@ -23,6 +23,7 @@ import java.util.stream.Collectors; @@ -23,6 +23,7 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.assertj.core.api.AbstractAssert;
import org.assertj.core.api.ListAssert;
import org.assertj.core.error.BasicErrorMessageFactory;
import org.assertj.core.error.ErrorMessageFactory;
@ -68,7 +69,7 @@ public class RuntimeHintsInvocationsAssert extends AbstractAssert<RuntimeHintsIn @@ -68,7 +69,7 @@ public class RuntimeHintsInvocationsAssert extends AbstractAssert<RuntimeHintsIn
* Example: <pre class="code">
* RuntimeHints hints = new RuntimeHints();
* hints.reflection().registerType(MyType.class);
* assertThat(invocations).allMatch(hints); </pre>
* assertThat(invocations).match(hints); </pre>
* @param runtimeHints the runtime hints configuration to test against
* @throws AssertionError if any of the recorded invocations has no match in the provided hints
*/
@ -82,6 +83,13 @@ public class RuntimeHintsInvocationsAssert extends AbstractAssert<RuntimeHintsIn @@ -82,6 +83,13 @@ public class RuntimeHintsInvocationsAssert extends AbstractAssert<RuntimeHintsIn
}
}
public ListAssert<RecordedInvocation> notMatching(RuntimeHints runtimeHints) {
Assert.notNull(runtimeHints, "RuntimeHints should not be null");
configureRuntimeHints(runtimeHints);
return ListAssert.assertThatStream(this.actual.recordedInvocations()
.filter(invocation -> !invocation.matches(runtimeHints)));
}
private ErrorMessageFactory errorMessageForInvocation(RecordedInvocation invocation) {
return new BasicErrorMessageFactory("%nMissing <%s> for invocation <%s> on type <%s> %nwith arguments %s.%nStacktrace:%n<%s>",

Loading…
Cancel
Save