@ -93,13 +93,13 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv
@@ -93,13 +93,13 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv
@Test
public void listenerWithPayloadAndGenericInformation ( ) {
Method method = ReflectionUtils . findMethod ( SampleEvents . class , "handleString" , String . class ) ;
supportsEventType ( true , method , createGeneric EventType ( String . class ) ) ;
supportsEventType ( true , method , createPayload EventType ( String . class ) ) ;
}
@Test
public void listenerWithInvalidPayloadAndGenericInformation ( ) {
Method method = ReflectionUtils . findMethod ( SampleEvents . class , "handleString" , String . class ) ;
supportsEventType ( false , method , createGeneric EventType ( Integer . class ) ) ;
supportsEventType ( false , method , createPayload EventType ( Integer . class ) ) ;
}
@Test
@ -123,28 +123,28 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv
@@ -123,28 +123,28 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv
@Test
public void listenerWithAnnotationValue ( ) {
Method method = ReflectionUtils . findMethod ( SampleEvents . class , "handleStringAnnotationValue" ) ;
supportsEventType ( true , method , createGeneric EventType ( String . class ) ) ;
supportsEventType ( true , method , createPayload EventType ( String . class ) ) ;
}
@Test
public void listenerWithAnnotationClasses ( ) {
Method method = ReflectionUtils . findMethod ( SampleEvents . class , "handleStringAnnotationClasses" ) ;
supportsEventType ( true , method , createGeneric EventType ( String . class ) ) ;
supportsEventType ( true , method , createPayload EventType ( String . class ) ) ;
}
@Test
public void listenerWithAnnotationValueAndParameter ( ) {
Method method = ReflectionUtils . findMethod (
SampleEvents . class , "handleStringAnnotationValueAndParameter" , String . class ) ;
supportsEventType ( true , method , createGeneric EventType ( String . class ) ) ;
supportsEventType ( true , method , createPayload EventType ( String . class ) ) ;
}
@Test
public void listenerWithSeveralTypes ( ) {
Method method = ReflectionUtils . findMethod ( SampleEvents . class , "handleStringOrInteger" ) ;
supportsEventType ( true , method , createGeneric EventType ( String . class ) ) ;
supportsEventType ( true , method , createGeneric EventType ( Integer . class ) ) ;
supportsEventType ( false , method , createGeneric EventType ( Double . class ) ) ;
supportsEventType ( true , method , createPayload EventType ( String . class ) ) ;
supportsEventType ( true , method , createPayload EventType ( Integer . class ) ) ;
supportsEventType ( false , method , createPayload EventType ( Double . class ) ) ;
}
@Test
@ -341,11 +341,11 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv
@@ -341,11 +341,11 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv
var method = SampleEvents . class . getDeclaredMethod ( "handleString" , String . class ) ;
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 ( ) ;
assertThat ( adapter . supportsEventType ( ResolvableType . forClass ( EntityWrapper . class ) ) )
assertThat ( adapter . supportsEventType ( createPayloadEventType ( ResolvableType . forClass ( EntityWrapper . class ) ) ) )
. 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 ( ) ;
}
@ -355,11 +355,11 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv
@@ -355,11 +355,11 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv
var method = SampleEvents . class . getDeclaredMethod ( "handleGenericStringPayload" , EntityWrapper . class ) ;
var adapter = new ApplicationListenerMethodAdapter ( null , ApplicationListenerMethodAdapterTests . class , method ) ;
assertThat ( adapter . supportsEventType ( ResolvableType . forClass ( EntityWrapper . class ) ) )
. as ( "handleGenericStringPayload(EntityWrapper<String>) with EntityWrapper<?>" ) . isTru e ( ) ;
assertThat ( adapter . supportsEventType ( ResolvableType . forClassWithGenerics ( EntityWrapper . class , Integer . class ) ) )
assertThat ( adapter . supportsEventType ( createPayloadEventType ( ResolvableType . forClass ( EntityWrapper . class ) ) ) )
. as ( "handleGenericStringPayload(EntityWrapper<String>) with EntityWrapper<?>" ) . isFals e ( ) ;
assertThat ( adapter . supportsEventType ( createPayloadEventType ( ResolvableType . forClassWithGenerics ( EntityWrapper . class , Integer . class ) ) ) )
. 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 ( ) ;
}
@ -369,15 +369,15 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv
@@ -369,15 +369,15 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv
var method = SampleEvents . class . getDeclaredMethod ( "handleGenericAnyPayload" , EntityWrapper . class ) ;
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 ( ) ;
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 ( ) ;
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 ( ) ;
assertThat ( adapter . supportsEventType ( ResolvableType . forClass ( List . class ) ) )
assertThat ( adapter . supportsEventType ( createPayloadEventType ( ResolvableType . forClass ( List . class ) ) ) )
. 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 ( ) ;
}
@ -422,7 +422,11 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv
@@ -422,7 +422,11 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv
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 ) ;
}