SpanCustomizingApplicationEventListener implements ApplicationEventListener, RequestEventListener { @Override public RequestEventListener onRequest(RequestEvent requestEvent) { if (requestEvent.getType() == RequestEvent.Type.START) { return this; } return null; } @Inject  SpanCustomizingApplicationEventListener(); static SpanCustomizingApplicationEventListener create(); @Override void onEvent(ApplicationEvent event); @Override RequestEventListener onRequest(RequestEvent requestEvent); @Override void onEvent(RequestEvent event);  }
@Test public void onRequest_retunrs_self_for_START_otherwise_null() { for (RequestEvent.Type type : RequestEvent.Type.values()) { doReturn(type).when(requestEventMock).getType(); boolean expectNonNullResult = (type == RequestEvent.Type.START); RequestEventListener result = implSpy.onRequest(requestEventMock); if (expectNonNullResult) { assertThat(result).isSameAs(implSpy); } else { assertThat(result).isNull(); } } }