### Question:
InfoUpdateTrigger extends AbstractEventHandler<InstanceEvent> { protected Mono<Void> updateInfo(InstanceId instanceId) { return this.infoUpdater.updateInfo(instanceId).onErrorResume((e) -> { log.warn("Unexpected error while updating info for {}", instanceId, e); return Mono.empty(); }).doFinally((s) -> this.intervalCheck.markAsChecked(instanceId)); } InfoUpdateTrigger(InfoUpdater infoUpdater, Publisher<InstanceEvent> publisher); @Override void start(); @Override void stop(); void setInterval(Duration updateInterval); void setLifetime(Duration infoLifetime);  }### Answer:
@Test public void should_update_on_endpoints_detectes_event() { this.events.next(new InstanceEndpointsDetectedEvent(this.instance.getId(), this.instance.getVersion(), this.instance.getEndpoints())); verify(this.updater, times(1)).updateInfo(this.instance.getId()); }
@Test public void should_update_on_status_changed_event() { this.events.next( new InstanceStatusChangedEvent(this.instance.getId(), this.instance.getVersion(), StatusInfo.ofDown())); verify(this.updater, times(1)).updateInfo(this.instance.getId()); }
@Test public void should_update_on_instance_registration_update_event() { this.events.next(new InstanceRegistrationUpdatedEvent(this.instance.getId(), this.instance.getVersion(), this.instance.getRegistration())); verify(this.updater, times(1)).updateInfo(this.instance.getId()); }
@Test public void should_not_update_on_non_relevant_event() { this.events.next(new InstanceInfoChangedEvent(this.instance.getId(), this.instance.getVersion(), Info.empty())); verify(this.updater, never()).updateInfo(this.instance.getId()); }
@Test public void should_continue_update_after_error() throws InterruptedException { when(this.updater.updateInfo(any())).thenReturn(Mono.error(IllegalStateException::new)) .thenReturn(Mono.empty()); this.events.next( new InstanceStatusChangedEvent(this.instance.getId(), this.instance.getVersion(), StatusInfo.ofDown())); this.events.next( new InstanceStatusChangedEvent(this.instance.getId(), this.instance.getVersion(), StatusInfo.ofUp())); verify(this.updater, times(2)).updateInfo(this.instance.getId()); }