DATACMNS-1449 - MethodInvocationRecorder now rejects final types.
This commit is contained in:
@@ -73,6 +73,7 @@ public class MethodInvocationRecorder {
|
||||
public static <T> Recorded<T> forProxyOf(Class<T> type) {
|
||||
|
||||
Assert.notNull(type, "Type must not be null!");
|
||||
Assert.isTrue(!Modifier.isFinal(type.getModifiers()), "Type to record invocations on must not be final!");
|
||||
|
||||
return new MethodInvocationRecorder().create(type);
|
||||
}
|
||||
|
||||
@@ -34,6 +34,13 @@ public class MethodInvocationRecorderUnitTests {
|
||||
|
||||
Recorded<Foo> recorder = MethodInvocationRecorder.forProxyOf(Foo.class);
|
||||
|
||||
@Test // DATACMNS-1449
|
||||
public void rejectsFinalTypes() {
|
||||
|
||||
assertThatExceptionOfType(IllegalArgumentException.class) //
|
||||
.isThrownBy(() -> MethodInvocationRecorder.forProxyOf(FinalType.class));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1449
|
||||
public void createsPropertyPathForSimpleMethodReference() {
|
||||
|
||||
@@ -71,7 +78,7 @@ public class MethodInvocationRecorderUnitTests {
|
||||
assertThat(recorder.record(Foo::getName).getPropertyPath()).hasValue("name");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test // DATACMNS-1449
|
||||
public void recordsInvocationOnInterface() {
|
||||
|
||||
Recorded<Sample> recorder = MethodInvocationRecorder.forProxyOf(Sample.class);
|
||||
@@ -79,6 +86,8 @@ public class MethodInvocationRecorderUnitTests {
|
||||
assertThat(recorder.record(Sample::getName).getPropertyPath()).hasValue("name");
|
||||
}
|
||||
|
||||
static final class FinalType {}
|
||||
|
||||
@Getter
|
||||
static class Foo {
|
||||
Bar bar;
|
||||
|
||||
Reference in New Issue
Block a user