JobEventBus { public void post(final JobEvent event) { if (isRegistered && !executorService.isShutdown()) { eventBus.post(event); } } JobEventBus();  JobEventBus(final TracingConfiguration tracingConfig); void post(final JobEvent event);  }
@Test public void assertPost() throws InterruptedException { jobEventBus = new JobEventBus(new TracingConfiguration<>("TEST", jobEventCaller)); assertIsRegistered(true); jobEventBus.post(new JobExecutionEvent("localhost", "127.0.0.1", "fake_task_id", "test_event_bus_job", JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0)); while (!TestTracingListener.isExecutionEventCalled()) { Thread.sleep(100L); } verify(jobEventCaller).call(); }
@Test public void assertPostWithoutListener() throws ReflectiveOperationException { jobEventBus = new JobEventBus(); assertIsRegistered(false); Field field = JobEventBus.class.getDeclaredField("eventBus"); field.setAccessible(true); field.set(jobEventBus, eventBus); jobEventBus.post(new JobExecutionEvent("localhost", "127.0.0.1", "fake_task_id", "test_event_bus_job", JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0)); verify(eventBus, times(0)).post(ArgumentMatchers.<JobEvent>any()); }