EurekaAgentStatusMonitor implements AgentStatusMonitor, EurekaEventListener { @Override public Observable<AgentStatus> monitor() { return statusUpdateSubject.asObservable(); } @Inject  EurekaAgentStatusMonitor(EurekaClient eurekaClient, AgentManagementService agentManagementService, Registry registry); @Activator void enterActiveMode(); @Override AgentStatus getStatus(String agentInstanceId); @Override boolean isHealthy(String agentInstanceId); @Override Observable<AgentStatus> monitor(); @Override void onEvent(EurekaEvent event);  }
@Test public void testEurekaRegistrationChangesTriggerStatusUpdateInEventStream() { ExtTestSubscriber<AgentStatus> testSubscriber = new ExtTestSubscriber<>(); monitor.monitor().subscribe(testSubscriber); mockStatusInEureka(instance, InstanceStatus.UP); assertThat(testSubscriber.takeNext().getStatusCode()).isEqualTo(AgentStatusCode.Healthy); mockStatusInEureka(instance, InstanceStatus.DOWN); assertThat(testSubscriber.takeNext().getStatusCode()).isEqualTo(AgentStatusCode.Unhealthy); mockStatusInEureka(instance, InstanceStatus.UP); assertThat(testSubscriber.takeNext().getStatusCode()).isEqualTo(AgentStatusCode.Healthy); }