@Override
  public List<ServiceInstance> getInstances(String serviceName) {
    final List<ServiceRegistry> serviceRegistryListFiltered;
    {
      LocalDateTime healthTime = LocalDateTime.now()
          .minusSeconds(this.discoveryProperties.getHealthCheckIntervalInSecond());
      List<ServiceRegistry> filterByHealthCheck =
          this.serviceRegistryService.findByServiceNameDataChangeLastModifiedTimeGreaterThan(
              serviceName, healthTime
          );
      serviceRegistryListFiltered = filterByCluster(filterByHealthCheck, this.cluster);
    }

    return serviceRegistryListFiltered.stream()
        .map(DatabaseDiscoveryClientImpl::convert)
        .collect(Collectors.toList());
  }
@Test
  void getInstances_filterByHealthCheck() {
    final String serviceName = "a-service";
    ServiceRegistryService serviceRegistryService = Mockito.mock(ServiceRegistryService.class);

    ServiceRegistry healthy = newServiceRegistry(serviceName, "http://localhost:8081/", "1",
        LocalDateTime.now());
    Mockito.when(
            serviceRegistryService.findByServiceNameDataChangeLastModifiedTimeGreaterThan(
                eq(serviceName),
                any(LocalDateTime.class)))
        .thenReturn(Collections.singletonList(healthy));

    DatabaseDiscoveryClient discoveryClient = new DatabaseDiscoveryClientImpl(
        serviceRegistryService,
        new ApolloServiceDiscoveryProperties(),
        "1"
    );

    List<ServiceInstance> serviceInstances = discoveryClient.getInstances(serviceName);
    assertEquals(1, serviceInstances.size());
    assertEquals(serviceName, serviceInstances.get(0).getServiceName());
    assertEquals("http://localhost:8081/", serviceInstances.get(0).getUri().toString());
    assertEquals("1", serviceInstances.get(0).getCluster());
  }