KubernetesHomePageController { @GetMapping("/") public List<ServiceDTO> listAllServices() { List<ServiceDTO> allServices = Lists.newLinkedList(); allServices .addAll(discoveryService.getServiceInstances(ServiceNameConsts.APOLLO_CONFIGSERVICE)); allServices.addAll(discoveryService.getServiceInstances(ServiceNameConsts.APOLLO_ADMINSERVICE)); return allServices; } KubernetesHomePageController(DiscoveryService discoveryService); @GetMapping("/") List<ServiceDTO> listAllServices();  }
@Test public void testListAllServices() { ServiceDTO someServiceDto = mock(ServiceDTO.class); ServiceDTO anotherServiceDto = mock(ServiceDTO.class); when(discoveryService.getServiceInstances(ServiceNameConsts.APOLLO_CONFIGSERVICE)).thenReturn( Lists.newArrayList(someServiceDto)); when(discoveryService.getServiceInstances(ServiceNameConsts.APOLLO_ADMINSERVICE)).thenReturn( Lists.newArrayList(anotherServiceDto)); List<ServiceDTO> allServices = homePageController.listAllServices(); assertEquals(2, allServices.size()); assertSame(someServiceDto, allServices.get(0)); assertSame(anotherServiceDto, allServices.get(1)); }