@Test public void getInstances(@Injectable ServiceCombClient serviceCombClient, @Injectable ServiceCombDiscoveryProperties serviceCombDiscoveryProperties) throws ServiceCombException { serviceCombDiscoveryProperties = new ServiceCombDiscoveryProperties(); serviceCombDiscoveryProperties.setAppName("test"); serviceCombDiscoveryProperties.setServiceName("testservice"); serviceCombDiscoveryProperties.setVersion("latest"); List<ServiceInstance> serviceInstanceList = new ArrayList<>(); serviceInstanceList.add( new DefaultServiceInstance("111", "1", "127.0.0.1", 1000, false)); Microservice microservice = new Microservice(); microservice.setServiceName("testservice"); new Expectations(MicroserviceHandler.class) { { MicroserviceHandler.createMicroservice((ServiceCombDiscoveryProperties) any, anyString); result = microservice; MicroserviceHandler.getInstances((Microservice) any, (ServiceCombClient) any); result = serviceInstanceList; } }; ServiceCombDiscoveryClient serviceCombDiscoveryClient = new ServiceCombDiscoveryClient( serviceCombDiscoveryProperties, serviceCombClient); List<ServiceInstance> actual = serviceCombDiscoveryClient.getInstances("testservice"); Assert.assertEquals(1, actual.size()); }
@Override public List<ServiceInstance> getInstances(String serviceId) { Microservice microService = MicroserviceHandler .createMicroservice(discoveryProperties, serviceId); return MicroserviceHandler.getInstances(microService, serviceCombClient); }
ServiceCombDiscoveryClient implements DiscoveryClient { @Override public List<ServiceInstance> getInstances(String serviceId) { Microservice microService = MicroserviceHandler .createMicroservice(discoveryProperties, serviceId); return MicroserviceHandler.getInstances(microService, serviceCombClient); } }
ServiceCombDiscoveryClient implements DiscoveryClient { @Override public List<ServiceInstance> getInstances(String serviceId) { Microservice microService = MicroserviceHandler .createMicroservice(discoveryProperties, serviceId); return MicroserviceHandler.getInstances(microService, serviceCombClient); } ServiceCombDiscoveryClient(ServiceCombDiscoveryProperties discoveryProperties,
      ServiceCombClient serviceCombClient); }
ServiceCombDiscoveryClient implements DiscoveryClient { @Override public List<ServiceInstance> getInstances(String serviceId) { Microservice microService = MicroserviceHandler .createMicroservice(discoveryProperties, serviceId); return MicroserviceHandler.getInstances(microService, serviceCombClient); } ServiceCombDiscoveryClient(ServiceCombDiscoveryProperties discoveryProperties,
      ServiceCombClient serviceCombClient); @Override String description(); @Override List<ServiceInstance> getInstances(String serviceId); @Override List<String> getServices(); }
ServiceCombDiscoveryClient implements DiscoveryClient { @Override public List<ServiceInstance> getInstances(String serviceId) { Microservice microService = MicroserviceHandler .createMicroservice(discoveryProperties, serviceId); return MicroserviceHandler.getInstances(microService, serviceCombClient); } ServiceCombDiscoveryClient(ServiceCombDiscoveryProperties discoveryProperties,
      ServiceCombClient serviceCombClient); @Override String description(); @Override List<ServiceInstance> getInstances(String serviceId); @Override List<String> getServices();  }