### Question:
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);  }### Answer:
@Test void testFindServiceWithNullOrEmptyServiceName() { Assertions.assertNull(environmentServicesFinder.findService(null)); Assertions.assertNull(environmentServicesFinder.findService("")); }
@Test void testFindService() { CfService expectedService = Mockito.mock(CfService.class); Mockito.when(env.findServicesByName(SERVICE_NAME)) .thenReturn(List.of(expectedService)); CfService service = environmentServicesFinder.findService(SERVICE_NAME); Assertions.assertEquals(expectedService, service); }
@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); }
@Test void testFindServiceWithZeroMatches() { Mockito.when(env.findServicesByName(SERVICE_NAME)) .thenReturn(Collections.emptyList()); CfService service = environmentServicesFinder.findService(SERVICE_NAME); Assertions.assertNull(service); }