@Test void testFindServiceWithMultipleMatches() { CfService expectedService1 = Mockito.mock(CfService.class); CfService expectedService2 = Mockito.mock(CfService.class); Mockito.when(env.findServicesByName(SERVICE_NAME)) .thenReturn(List.of(expectedService1, expectedService2)); CfService service = environmentServicesFinder.findService(SERVICE_NAME); Assertions.assertEquals(expectedService1, service); }
public CfService findService(String name) { if (StringUtils.isEmpty(name)) { return null; } return CollectionUtils.firstElement(env.findServicesByName(name)); }
EnvironmentServicesFinder { public CfService findService(String name) { if (StringUtils.isEmpty(name)) { return null; } return CollectionUtils.firstElement(env.findServicesByName(name)); } }
EnvironmentServicesFinder { public CfService findService(String name) { if (StringUtils.isEmpty(name)) { return null; } return CollectionUtils.firstElement(env.findServicesByName(name)); } EnvironmentServicesFinder();  EnvironmentServicesFinder(CfJdbcEnv env); }
EnvironmentServicesFinder { public CfService findService(String name) { if (StringUtils.isEmpty(name)) { return null; } return CollectionUtils.firstElement(env.findServicesByName(name)); } EnvironmentServicesFinder();  EnvironmentServicesFinder(CfJdbcEnv env); CfJdbcService findJdbcService(String name); CfService findService(String name); }
EnvironmentServicesFinder { public CfService findService(String name) { if (StringUtils.isEmpty(name)) { return null; } return CollectionUtils.firstElement(env.findServicesByName(name)); } EnvironmentServicesFinder();  EnvironmentServicesFinder(CfJdbcEnv env); CfJdbcService findJdbcService(String name); CfService findService(String name);  }