InstanceService { public List<Instance> findInstancesByIds(Set<Long> instanceIds) { Iterable<Instance> instances = instanceRepository.findAllById(instanceIds); return Lists.newArrayList(instances); } 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 testFindInstancesByIds() throws Exception { String someAppId = "someAppId"; String someClusterName = "someClusterName"; String someDataCenter = "someDataCenter"; String someIp = "someIp"; String anotherIp = "anotherIp"; Instance someInstance = instanceService.createInstance(assembleInstance(someAppId, someClusterName, someDataCenter, someIp)); Instance anotherInstance = instanceService.createInstance(assembleInstance(someAppId, someClusterName, someDataCenter, anotherIp)); List<Instance> instances = instanceService.findInstancesByIds(Sets.newHashSet(someInstance .getId(), anotherInstance.getId())); Set<String> ips = instances.stream().map(Instance::getIp).collect(Collectors.toSet()); assertEquals(2, instances.size()); assertEquals(Sets.newHashSet(someIp, anotherIp), ips); }