@Test public void should_update_on_event() throws InterruptedException { InfoUpdater updater = mock(InfoUpdater.class); when(updater.updateInfo(any(InstanceId.class))).thenReturn(Mono.empty()); TestPublisher<InstanceEvent> events = TestPublisher.create(); InfoUpdateTrigger trigger = new InfoUpdateTrigger(updater, events.flux()); trigger.start(); Thread.sleep(50L); events.next(new InstanceRegisteredEvent(instance.getId(), instance.getVersion(), instance.getRegistration())); verify(updater, never()).updateInfo(instance.getId()); events.next(new InstanceStatusChangedEvent(instance.getId(), instance.getVersion(), StatusInfo.ofDown())); verify(updater, times(1)).updateInfo(instance.getId()); clearInvocations(updater); events.next(new InstanceEndpointsDetectedEvent(instance.getId(), instance.getVersion(), Endpoints.empty())); verify(updater, times(1)).updateInfo(instance.getId()); clearInvocations(updater); events.next( new InstanceRegistrationUpdatedEvent(instance.getId(), instance.getVersion(), instance.getRegistration())); verify(updater, times(1)).updateInfo(instance.getId()); trigger.stop(); clearInvocations(updater); events.next(new InstanceRegisteredEvent(instance.getId(), instance.getVersion(), instance.getRegistration())); verify(updater, never()).updateInfo(instance.getId()); }
protected Mono<Void> updateInfo(InstanceEvent event) { return infoUpdater.updateInfo(event.getInstance()); }
InfoUpdateTrigger extends AbstractEventHandler<InstanceEvent> { protected Mono<Void> updateInfo(InstanceEvent event) { return infoUpdater.updateInfo(event.getInstance()); } }
InfoUpdateTrigger extends AbstractEventHandler<InstanceEvent> { protected Mono<Void> updateInfo(InstanceEvent event) { return infoUpdater.updateInfo(event.getInstance()); } InfoUpdateTrigger(InfoUpdater infoUpdater, Publisher<InstanceEvent> publisher); }
InfoUpdateTrigger extends AbstractEventHandler<InstanceEvent> { protected Mono<Void> updateInfo(InstanceEvent event) { return infoUpdater.updateInfo(event.getInstance()); } InfoUpdateTrigger(InfoUpdater infoUpdater, Publisher<InstanceEvent> publisher);  }
InfoUpdateTrigger extends AbstractEventHandler<InstanceEvent> { protected Mono<Void> updateInfo(InstanceEvent event) { return infoUpdater.updateInfo(event.getInstance()); } InfoUpdateTrigger(InfoUpdater infoUpdater, Publisher<InstanceEvent> publisher);   }