InstanceService { public Page<InstanceConfig> findActiveInstanceConfigsByReleaseKey(String releaseKey, Pageable pageable) { return instanceConfigRepository.findByReleaseKeyAndDataChangeLastModifiedTimeAfter(releaseKey, getValidInstanceConfigDate(), pageable); } InstanceService(
      final InstanceRepository instanceRepository,
      final InstanceConfigRepository instanceConfigRepository); Instance findInstance(String appId, String clusterName, String dataCenter, String ip); List<Instance> findInstancesByIds(Set<Long> instanceIds); @Transactional Instance createInstance(Instance instance); InstanceConfig findInstanceConfig(long instanceId, String configAppId, String
      configNamespaceName); Page<InstanceConfig> findActiveInstanceConfigsByReleaseKey(String releaseKey, Pageable
      pageable); Page<Instance> findInstancesByNamespace(String appId, String clusterName, String
      namespaceName, Pageable pageable); Page<Instance> findInstancesByNamespaceAndInstanceAppId(String instanceAppId, String
      appId, String clusterName, String
                                                                     namespaceName, Pageable
                                                                     pageable); List<InstanceConfig> findInstanceConfigsByNamespaceWithReleaseKeysNotIn(String appId,
                                                                                 String clusterName,
                                                                                 String
                                                                                     namespaceName,
                                                                                 Set<String>
                                                                                     releaseKeysNotIn); @Transactional InstanceConfig createInstanceConfig(InstanceConfig instanceConfig); @Transactional InstanceConfig updateInstanceConfig(InstanceConfig instanceConfig); @Transactional int batchDeleteInstanceConfig(String configAppId, String configClusterName, String configNamespaceName);  }
@Test @Rollback public void testFindActiveInstanceConfigs() throws Exception { long someInstanceId = 1; long anotherInstanceId = 2; String someConfigAppId = "someConfigAppId"; String someConfigClusterName = "someConfigClusterName"; String someConfigNamespaceName = "someConfigNamespaceName"; Date someValidDate = new Date(); Pageable pageable = PageRequest.of(0, 10); String someReleaseKey = "someReleaseKey"; Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DATE, -2); Date someInvalidDate = calendar.getTime(); prepareInstanceConfigForInstance(someInstanceId, someConfigAppId, someConfigClusterName, someConfigNamespaceName, someReleaseKey, someValidDate); prepareInstanceConfigForInstance(anotherInstanceId, someConfigAppId, someConfigClusterName, someConfigNamespaceName, someReleaseKey, someInvalidDate); Page<InstanceConfig> validInstanceConfigs = instanceService .findActiveInstanceConfigsByReleaseKey(someReleaseKey, pageable); assertEquals(1, validInstanceConfigs.getContent().size()); assertEquals(someInstanceId, validInstanceConfigs.getContent().get(0).getInstanceId()); }