InstanceService { public List<InstanceConfig> findInstanceConfigsByNamespaceWithReleaseKeysNotIn(String appId, String clusterName, String namespaceName, Set<String> releaseKeysNotIn) { List<InstanceConfig> instanceConfigs = instanceConfigRepository. findByConfigAppIdAndConfigClusterNameAndConfigNamespaceNameAndDataChangeLastModifiedTimeAfterAndReleaseKeyNotIn(appId, clusterName, namespaceName, getValidInstanceConfigDate(), releaseKeysNotIn); if (CollectionUtils.isEmpty(instanceConfigs)) { return Collections.emptyList(); } return instanceConfigs; } 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 testFindInstanceConfigsByNamespaceWithReleaseKeysNotIn() throws Exception { long someInstanceId = 1; long anotherInstanceId = 2; long yetAnotherInstanceId = 3; String someConfigAppId = "someConfigAppId"; String someConfigClusterName = "someConfigClusterName"; String someConfigNamespaceName = "someConfigNamespaceName"; Date someValidDate = new Date(); String someReleaseKey = "someReleaseKey"; String anotherReleaseKey = "anotherReleaseKey"; String yetAnotherReleaseKey = "yetAnotherReleaseKey"; InstanceConfig someInstanceConfig = prepareInstanceConfigForInstance(someInstanceId, someConfigAppId, someConfigClusterName, someConfigNamespaceName, someReleaseKey, someValidDate); InstanceConfig anotherInstanceConfig = prepareInstanceConfigForInstance(anotherInstanceId, someConfigAppId, someConfigClusterName, someConfigNamespaceName, someReleaseKey, someValidDate); prepareInstanceConfigForInstance(yetAnotherInstanceId, someConfigAppId, someConfigClusterName, someConfigNamespaceName, anotherReleaseKey, someValidDate); List<InstanceConfig> instanceConfigs = instanceService .findInstanceConfigsByNamespaceWithReleaseKeysNotIn(someConfigAppId, someConfigClusterName, someConfigNamespaceName, Sets.newHashSet(anotherReleaseKey, yetAnotherReleaseKey)); assertEquals(Lists.newArrayList(someInstanceConfig, anotherInstanceConfig), instanceConfigs); }