|
|
|
@ -93,13 +93,13 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void listenerWithPayloadAndGenericInformation() { |
|
|
|
public void listenerWithPayloadAndGenericInformation() { |
|
|
|
Method method = ReflectionUtils.findMethod(SampleEvents.class, "handleString", String.class); |
|
|
|
Method method = ReflectionUtils.findMethod(SampleEvents.class, "handleString", String.class); |
|
|
|
supportsEventType(true, method, createGenericEventType(String.class)); |
|
|
|
supportsEventType(true, method, createPayloadEventType(String.class)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void listenerWithInvalidPayloadAndGenericInformation() { |
|
|
|
public void listenerWithInvalidPayloadAndGenericInformation() { |
|
|
|
Method method = ReflectionUtils.findMethod(SampleEvents.class, "handleString", String.class); |
|
|
|
Method method = ReflectionUtils.findMethod(SampleEvents.class, "handleString", String.class); |
|
|
|
supportsEventType(false, method, createGenericEventType(Integer.class)); |
|
|
|
supportsEventType(false, method, createPayloadEventType(Integer.class)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
@ -123,28 +123,28 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void listenerWithAnnotationValue() { |
|
|
|
public void listenerWithAnnotationValue() { |
|
|
|
Method method = ReflectionUtils.findMethod(SampleEvents.class, "handleStringAnnotationValue"); |
|
|
|
Method method = ReflectionUtils.findMethod(SampleEvents.class, "handleStringAnnotationValue"); |
|
|
|
supportsEventType(true, method, createGenericEventType(String.class)); |
|
|
|
supportsEventType(true, method, createPayloadEventType(String.class)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void listenerWithAnnotationClasses() { |
|
|
|
public void listenerWithAnnotationClasses() { |
|
|
|
Method method = ReflectionUtils.findMethod(SampleEvents.class, "handleStringAnnotationClasses"); |
|
|
|
Method method = ReflectionUtils.findMethod(SampleEvents.class, "handleStringAnnotationClasses"); |
|
|
|
supportsEventType(true, method, createGenericEventType(String.class)); |
|
|
|
supportsEventType(true, method, createPayloadEventType(String.class)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void listenerWithAnnotationValueAndParameter() { |
|
|
|
public void listenerWithAnnotationValueAndParameter() { |
|
|
|
Method method = ReflectionUtils.findMethod( |
|
|
|
Method method = ReflectionUtils.findMethod( |
|
|
|
SampleEvents.class, "handleStringAnnotationValueAndParameter", String.class); |
|
|
|
SampleEvents.class, "handleStringAnnotationValueAndParameter", String.class); |
|
|
|
supportsEventType(true, method, createGenericEventType(String.class)); |
|
|
|
supportsEventType(true, method, createPayloadEventType(String.class)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void listenerWithSeveralTypes() { |
|
|
|
public void listenerWithSeveralTypes() { |
|
|
|
Method method = ReflectionUtils.findMethod(SampleEvents.class, "handleStringOrInteger"); |
|
|
|
Method method = ReflectionUtils.findMethod(SampleEvents.class, "handleStringOrInteger"); |
|
|
|
supportsEventType(true, method, createGenericEventType(String.class)); |
|
|
|
supportsEventType(true, method, createPayloadEventType(String.class)); |
|
|
|
supportsEventType(true, method, createGenericEventType(Integer.class)); |
|
|
|
supportsEventType(true, method, createPayloadEventType(Integer.class)); |
|
|
|
supportsEventType(false, method, createGenericEventType(Double.class)); |
|
|
|
supportsEventType(false, method, createPayloadEventType(Double.class)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
@ -341,11 +341,11 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv |
|
|
|
var method = SampleEvents.class.getDeclaredMethod("handleString", String.class); |
|
|
|
var method = SampleEvents.class.getDeclaredMethod("handleString", String.class); |
|
|
|
var adapter = new ApplicationListenerMethodAdapter(null, ApplicationListenerMethodAdapterTests.class, method); |
|
|
|
var adapter = new ApplicationListenerMethodAdapter(null, ApplicationListenerMethodAdapterTests.class, method); |
|
|
|
|
|
|
|
|
|
|
|
assertThat(adapter.supportsEventType(ResolvableType.forClassWithGenerics(EntityWrapper.class, Integer.class))) |
|
|
|
assertThat(adapter.supportsEventType(createPayloadEventType(ResolvableType.forClassWithGenerics(EntityWrapper.class, Integer.class)))) |
|
|
|
.as("handleString(String) with EntityWrapper<Integer>").isFalse(); |
|
|
|
.as("handleString(String) with EntityWrapper<Integer>").isFalse(); |
|
|
|
assertThat(adapter.supportsEventType(ResolvableType.forClass(EntityWrapper.class))) |
|
|
|
assertThat(adapter.supportsEventType(createPayloadEventType(ResolvableType.forClass(EntityWrapper.class)))) |
|
|
|
.as("handleString(String) with EntityWrapper<?>").isFalse(); |
|
|
|
.as("handleString(String) with EntityWrapper<?>").isFalse(); |
|
|
|
assertThat(adapter.supportsEventType(ResolvableType.forClass(String.class))) |
|
|
|
assertThat(adapter.supportsEventType(createPayloadEventType(ResolvableType.forClass(String.class)))) |
|
|
|
.as("handleString(String) with String").isTrue(); |
|
|
|
.as("handleString(String) with String").isTrue(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -355,11 +355,11 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv |
|
|
|
var method = SampleEvents.class.getDeclaredMethod("handleGenericStringPayload", EntityWrapper.class); |
|
|
|
var method = SampleEvents.class.getDeclaredMethod("handleGenericStringPayload", EntityWrapper.class); |
|
|
|
var adapter = new ApplicationListenerMethodAdapter(null, ApplicationListenerMethodAdapterTests.class, method); |
|
|
|
var adapter = new ApplicationListenerMethodAdapter(null, ApplicationListenerMethodAdapterTests.class, method); |
|
|
|
|
|
|
|
|
|
|
|
assertThat(adapter.supportsEventType(ResolvableType.forClass(EntityWrapper.class))) |
|
|
|
assertThat(adapter.supportsEventType(createPayloadEventType(ResolvableType.forClass(EntityWrapper.class)))) |
|
|
|
.as("handleGenericStringPayload(EntityWrapper<String>) with EntityWrapper<?>").isTrue(); |
|
|
|
.as("handleGenericStringPayload(EntityWrapper<String>) with EntityWrapper<?>").isFalse(); |
|
|
|
assertThat(adapter.supportsEventType(ResolvableType.forClassWithGenerics(EntityWrapper.class, Integer.class))) |
|
|
|
assertThat(adapter.supportsEventType(createPayloadEventType(ResolvableType.forClassWithGenerics(EntityWrapper.class, Integer.class)))) |
|
|
|
.as("handleGenericStringPayload(EntityWrapper<String>) with EntityWrapper<Integer>").isFalse(); |
|
|
|
.as("handleGenericStringPayload(EntityWrapper<String>) with EntityWrapper<Integer>").isFalse(); |
|
|
|
assertThat(adapter.supportsEventType(ResolvableType.forClassWithGenerics(EntityWrapper.class, String.class))) |
|
|
|
assertThat(adapter.supportsEventType(createPayloadEventType(ResolvableType.forClassWithGenerics(EntityWrapper.class, String.class)))) |
|
|
|
.as("handleGenericStringPayload(EntityWrapper<String>) with EntityWrapper<String>").isTrue(); |
|
|
|
.as("handleGenericStringPayload(EntityWrapper<String>) with EntityWrapper<String>").isTrue(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -369,15 +369,15 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv |
|
|
|
var method = SampleEvents.class.getDeclaredMethod("handleGenericAnyPayload", EntityWrapper.class); |
|
|
|
var method = SampleEvents.class.getDeclaredMethod("handleGenericAnyPayload", EntityWrapper.class); |
|
|
|
var adapter = new ApplicationListenerMethodAdapter(null, ApplicationListenerMethodAdapterTests.class, method); |
|
|
|
var adapter = new ApplicationListenerMethodAdapter(null, ApplicationListenerMethodAdapterTests.class, method); |
|
|
|
|
|
|
|
|
|
|
|
assertThat(adapter.supportsEventType(ResolvableType.forClass(EntityWrapper.class))) |
|
|
|
assertThat(adapter.supportsEventType(createPayloadEventType(ResolvableType.forClass(EntityWrapper.class)))) |
|
|
|
.as("handleGenericAnyPayload(EntityWrapper<?>) with EntityWrapper<?>").isTrue(); |
|
|
|
.as("handleGenericAnyPayload(EntityWrapper<?>) with EntityWrapper<?>").isTrue(); |
|
|
|
assertThat(adapter.supportsEventType(ResolvableType.forClassWithGenerics(EntityWrapper.class, Integer.class))) |
|
|
|
assertThat(adapter.supportsEventType(createPayloadEventType(ResolvableType.forClassWithGenerics(EntityWrapper.class, Integer.class)))) |
|
|
|
.as("handleGenericAnyPayload(EntityWrapper<?>) with EntityWrapper<Integer>").isTrue(); |
|
|
|
.as("handleGenericAnyPayload(EntityWrapper<?>) with EntityWrapper<Integer>").isTrue(); |
|
|
|
assertThat(adapter.supportsEventType(ResolvableType.forClassWithGenerics(EntityWrapper.class, String.class))) |
|
|
|
assertThat(adapter.supportsEventType(createPayloadEventType(ResolvableType.forClassWithGenerics(EntityWrapper.class, String.class)))) |
|
|
|
.as("handleGenericAnyPayload(EntityWrapper<?>) with EntityWrapper<String>").isTrue(); |
|
|
|
.as("handleGenericAnyPayload(EntityWrapper<?>) with EntityWrapper<String>").isTrue(); |
|
|
|
assertThat(adapter.supportsEventType(ResolvableType.forClass(List.class))) |
|
|
|
assertThat(adapter.supportsEventType(createPayloadEventType(ResolvableType.forClass(List.class)))) |
|
|
|
.as("handleGenericAnyPayload(EntityWrapper<?>) with List<?>").isFalse(); |
|
|
|
.as("handleGenericAnyPayload(EntityWrapper<?>) with List<?>").isFalse(); |
|
|
|
assertThat(adapter.supportsEventType(ResolvableType.forClassWithGenerics(List.class, String.class))) |
|
|
|
assertThat(adapter.supportsEventType(createPayloadEventType(ResolvableType.forClassWithGenerics(List.class, String.class)))) |
|
|
|
.as("handleGenericAnyPayload(EntityWrapper<?>) with List<String>").isFalse(); |
|
|
|
.as("handleGenericAnyPayload(EntityWrapper<?>) with List<String>").isFalse(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -422,7 +422,11 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv |
|
|
|
return new StaticApplicationListenerMethodAdapter(method, this.sampleEvents); |
|
|
|
return new StaticApplicationListenerMethodAdapter(method, this.sampleEvents); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private ResolvableType createGenericEventType(Class<?> payloadType) { |
|
|
|
private ResolvableType createPayloadEventType(Class<?> payloadType) { |
|
|
|
|
|
|
|
return ResolvableType.forClassWithGenerics(PayloadApplicationEvent.class, payloadType); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ResolvableType createPayloadEventType(ResolvableType payloadType) { |
|
|
|
return ResolvableType.forClassWithGenerics(PayloadApplicationEvent.class, payloadType); |
|
|
|
return ResolvableType.forClassWithGenerics(PayloadApplicationEvent.class, payloadType); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|