DATACMNS-1449 - MethodInvocationRecorder now rejects final types.

This commit is contained in:
Oliver Drotbohm
2019-03-05 14:37:59 +01:00
parent 34507ec000
commit ea3af3dbbb
2 changed files with 11 additions and 1 deletions

View File

@@ -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);
}

View File

@@ -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;