Polish
See gh-27981
This commit is contained in:
@@ -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}.
|
||||
*/
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
* 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
|
||||
}
|
||||
}
|
||||
|
||||
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>",
|
||||
|
||||
Reference in New Issue
Block a user