Use Assert.state() where appropriate
This commit is contained in:
@@ -98,7 +98,7 @@ public final class RecordedInvocation {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getInstance() {
|
||||
Assert.notNull(this.instance, "Cannot resolve 'this' for static invocations");
|
||||
Assert.state(this.instance != null, "Cannot resolve 'this' for static invocations");
|
||||
return (T) this.instance;
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ public final class RecordedInvocation {
|
||||
* @throws IllegalStateException in case of static invocations (there is no {@code this})
|
||||
*/
|
||||
public TypeReference getInstanceTypeReference() {
|
||||
Assert.notNull(this.instance, "Cannot resolve 'this' for static invocations");
|
||||
Assert.state(this.instance != null, "Cannot resolve 'this' for static invocations");
|
||||
return TypeReference.of(this.instance.getClass());
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ public final class RuntimeHintsRecorder {
|
||||
*/
|
||||
public synchronized static RuntimeHintsInvocations record(Runnable action) {
|
||||
Assert.notNull(action, "Runnable action must not be null");
|
||||
Assert.isTrue(RuntimeHintsAgent.isLoaded(), "RuntimeHintsAgent should be loaded in the current JVM");
|
||||
Assert.state(RuntimeHintsAgent.isLoaded(), "RuntimeHintsAgent must be loaded in the current JVM");
|
||||
RuntimeHintsRecorder recorder = new RuntimeHintsRecorder();
|
||||
RecordedInvocationsPublisher.addListener(recorder.listener);
|
||||
try {
|
||||
|
||||
@@ -63,8 +63,8 @@ class RecordedInvocationTests {
|
||||
|
||||
@Test
|
||||
void staticInvocationShouldThrowWhenGetInstance() {
|
||||
assertThatThrownBy(staticInvocation::getInstance).isInstanceOf(IllegalArgumentException.class);
|
||||
assertThatThrownBy(staticInvocation::getInstanceTypeReference).isInstanceOf(IllegalArgumentException.class);
|
||||
assertThatThrownBy(staticInvocation::getInstance).isInstanceOf(IllegalStateException.class);
|
||||
assertThatThrownBy(staticInvocation::getInstanceTypeReference).isInstanceOf(IllegalStateException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user