Search in sources :

Example 1 with ParentHeartbeatEvent

use of org.springframework.cloud.client.discovery.event.ParentHeartbeatEvent in project spring-boot-admin by codecentric.

the class ApplicationDiscoveryListenerTest method single_discovery_for_same_heartbeat.

@Test
public void single_discovery_for_same_heartbeat() {
    Object heartbeat = new Object();
    listener.onParentHeartbeat(new ParentHeartbeatEvent(new Object(), heartbeat));
    when(discovery.getServices()).thenReturn(Collections.singletonList("service"));
    when(discovery.getInstances("service")).thenReturn(Collections.singletonList((ServiceInstance) new DefaultServiceInstance("service", "localhost", 80, false)));
    listener.onApplicationEvent(new HeartbeatEvent(new Object(), heartbeat));
    assertEquals(0, registry.getApplications().size());
    listener.onApplicationEvent(new HeartbeatEvent(new Object(), new Object()));
    assertEquals(1, registry.getApplications().size());
}
Also used : DefaultServiceInstance(org.springframework.cloud.client.DefaultServiceInstance) ParentHeartbeatEvent(org.springframework.cloud.client.discovery.event.ParentHeartbeatEvent) HeartbeatEvent(org.springframework.cloud.client.discovery.event.HeartbeatEvent) DefaultServiceInstance(org.springframework.cloud.client.DefaultServiceInstance) ServiceInstance(org.springframework.cloud.client.ServiceInstance) ParentHeartbeatEvent(org.springframework.cloud.client.discovery.event.ParentHeartbeatEvent) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 DefaultServiceInstance (org.springframework.cloud.client.DefaultServiceInstance)1 ServiceInstance (org.springframework.cloud.client.ServiceInstance)1 HeartbeatEvent (org.springframework.cloud.client.discovery.event.HeartbeatEvent)1 ParentHeartbeatEvent (org.springframework.cloud.client.discovery.event.ParentHeartbeatEvent)1