use of org.springframework.context.PayloadApplicationEvent in project spring-framework by spring-projects.
the class ApplicationListenerMethodAdapterTests method invokeListenerWithPayload.
@Test
public void invokeListenerWithPayload() {
Method method = ReflectionUtils.findMethod(SampleEvents.class, "handleString", String.class);
PayloadApplicationEvent<String> event = new PayloadApplicationEvent<>(this, "test");
invokeListener(method, event);
verify(this.sampleEvents, times(1)).handleString("test");
}
use of org.springframework.context.PayloadApplicationEvent in project spring-framework by spring-projects.
the class ApplicationListenerMethodAdapterTests method invokeListenerWithAnnotationValueAndParameter.
@Test
public void invokeListenerWithAnnotationValueAndParameter() {
Method method = ReflectionUtils.findMethod(SampleEvents.class, "handleStringAnnotationValueAndParameter", String.class);
PayloadApplicationEvent<String> event = new PayloadApplicationEvent<>(this, "test");
invokeListener(method, event);
verify(this.sampleEvents, times(1)).handleStringAnnotationValueAndParameter("test");
}
use of org.springframework.context.PayloadApplicationEvent in project spring-framework by spring-projects.
the class ApplicationListenerMethodAdapterTests method invokeListenerWithAnnotationValue.
@Test
public void invokeListenerWithAnnotationValue() {
Method method = ReflectionUtils.findMethod(SampleEvents.class, "handleStringAnnotationClasses");
PayloadApplicationEvent<String> event = new PayloadApplicationEvent<>(this, "test");
invokeListener(method, event);
verify(this.sampleEvents, times(1)).handleStringAnnotationClasses();
}
use of org.springframework.context.PayloadApplicationEvent in project spring-framework by spring-projects.
the class ApplicationListenerMethodAdapterTests method invokeListenerWithPayloadWrongType.
@Test
public void invokeListenerWithPayloadWrongType() {
Method method = ReflectionUtils.findMethod(SampleEvents.class, "handleString", String.class);
PayloadApplicationEvent<Long> event = new PayloadApplicationEvent<>(this, 123L);
invokeListener(method, event);
verify(this.sampleEvents, never()).handleString(anyString());
}
use of org.springframework.context.PayloadApplicationEvent in project spring-framework by spring-projects.
the class ApplicationListenerMethodAdapterTests method invokeListenerWithSeveralTypes.
@Test
public void invokeListenerWithSeveralTypes() {
Method method = ReflectionUtils.findMethod(SampleEvents.class, "handleStringOrInteger");
PayloadApplicationEvent<String> event = new PayloadApplicationEvent<>(this, "test");
invokeListener(method, event);
verify(this.sampleEvents, times(1)).handleStringOrInteger();
PayloadApplicationEvent<Integer> event2 = new PayloadApplicationEvent<>(this, 123);
invokeListener(method, event2);
verify(this.sampleEvents, times(2)).handleStringOrInteger();
PayloadApplicationEvent<Double> event3 = new PayloadApplicationEvent<>(this, 23.2);
invokeListener(method, event3);
verify(this.sampleEvents, times(2)).handleStringOrInteger();
}
Aggregations