@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_filterByCluster() {
    final String serviceName = "a-service";
    ServiceRegistryService serviceRegistryService = Mockito.mock(ServiceRegistryService.class);
    {
      List<ServiceRegistry> serviceRegistryList = Arrays.asList(
          newServiceRegistry(serviceName, "http://localhost:8081/", "1"),
          newServiceRegistry("b-service", "http://localhost:8082/", "2"),
          newServiceRegistry("c-service", "http://localhost:8082/", "3")
      );
      Mockito.when(
              serviceRegistryService.findByServiceNameDataChangeLastModifiedTimeGreaterThan(
                  eq(serviceName),
                  any(LocalDateTime.class)))
          .thenReturn(serviceRegistryList);
    }

    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("1", serviceInstances.get(0).getCluster());
  }