@Test public void testGetAllStacksAndHosts() throws Exception { when(stacksDAO.getAllStackPaths()).thenReturn( new LinkedHashSet<>(Arrays.asList( new XreStackPath("/po/poc1/1.50/xreGuide"), new XreStackPath("/po/poc2/1.50/xreGuide")))); when(stacksDAO.getHosts(new XreStackPath("/po/poc1/1.50/xreGuide"))) .thenReturn(Arrays.asList(new HostIPs("ipv4", "ipv6"), new HostIPs("ipv4_2", "ipv6_2"))); when(stacksDAO.getHosts(new XreStackPath("/po/poc2/1.50/xreGuide"))) .thenReturn(Arrays.asList(new HostIPs("ipv4_3", "ipv6_3"))); StackData[] stacks = testee.getAllStacksAndHosts("xreGuide").toArray(new StackData[]{}); Assert.assertEquals("/po/poc1/1.50/xreGuide", stacks[0].getPath()); Assert.assertEquals("ipv4", stacks[0].getHosts().get().get(0).getIpV4Address()); Assert.assertEquals("ipv6", stacks[0].getHosts().get().get(0).getIpV6Address()); Assert.assertEquals("ipv4_2", stacks[0].getHosts().get().get(1).getIpV4Address()); Assert.assertEquals("ipv6_2", stacks[0].getHosts().get().get(1).getIpV6Address()); Assert.assertEquals("/po/poc2/1.50/xreGuide", stacks[1].getPath()); Assert.assertEquals("ipv4_3", stacks[1].getHosts().get().get(0).getIpV4Address()); Assert.assertEquals("ipv6_3", stacks[1].getHosts().get().get(0).getIpV6Address()); }
@Override public Set<StackData> getAllStacksAndHosts(String serviceName) { return FluentIterable .from(getStackPathsForService(serviceName)) .transform(new Function<XreStackPath, StackData>() { @Override public StackData apply(XreStackPath input) { try { return new StackData(input.getPath(), getNodesAddresses(input)); } catch (RedirectorDataSourceException e) { throw new ServiceException("failed to get hosts for " + input.getPath(), e); } } }) .toSet(); }
StacksService implements IStacksService { @Override public Set<StackData> getAllStacksAndHosts(String serviceName) { return FluentIterable .from(getStackPathsForService(serviceName)) .transform(new Function<XreStackPath, StackData>() { @Override public StackData apply(XreStackPath input) { try { return new StackData(input.getPath(), getNodesAddresses(input)); } catch (RedirectorDataSourceException e) { throw new ServiceException("failed to get hosts for " + input.getPath(), e); } } }) .toSet(); } }
StacksService implements IStacksService { @Override public Set<StackData> getAllStacksAndHosts(String serviceName) { return FluentIterable .from(getStackPathsForService(serviceName)) .transform(new Function<XreStackPath, StackData>() { @Override public StackData apply(XreStackPath input) { try { return new StackData(input.getPath(), getNodesAddresses(input)); } catch (RedirectorDataSourceException e) { throw new ServiceException("failed to get hosts for " + input.getPath(), e); } } }) .toSet(); }  }
StacksService implements IStacksService { @Override public Set<StackData> getAllStacksAndHosts(String serviceName) { return FluentIterable .from(getStackPathsForService(serviceName)) .transform(new Function<XreStackPath, StackData>() { @Override public StackData apply(XreStackPath input) { try { return new StackData(input.getPath(), getNodesAddresses(input)); } catch (RedirectorDataSourceException e) { throw new ServiceException("failed to get hosts for " + input.getPath(), e); } } }) .toSet(); }  @PostConstruct void init(); @Override ServicePaths getStacksForService(String serviceName); @Override ServicePaths updateStacksForService(String serviceName, ServicePaths servicePaths, Whitelisted whitelisted); @Override Set<String> getAllServiceNames(); @Override Boolean isServiceExists(String serviceName); @Override ServicePaths getStacksForAllServices(); @Override Set<PathItem> getActiveStacksAndFlavors(String serviceName); Set<PathItem> getActiveStacksAndFlavors(String serviceName, ServicePaths servicePaths); @Override HostIPsListWrapper getHostsForStackOnlyAndService(String stackName, String serviceName); @Override HostIPsListWrapper getRandomHostForStackOnlyAndService(String stackOnlyPath, String serviceName); @Override HostIPsListWrapper getHostsForStackAndService(String stackName, String serviceName); @Override HostIPsListWrapper getRandomHostForStackAndService(String stackName, String serviceName); @Override HostIPsListWrapper getHostsForFlavorAndService(String flavorName, String serviceName); @Override HostIPsListWrapper getRandomHostForFlavorAndService(String flavorName, String serviceName); @Override Set<StackData> getAllStacksAndHosts(String serviceName); Boolean isStackNameWithoutFlavor(String stackName); @Override HostIPsListWrapper getAddressByStackOrFlavor(String appName, String stackName, String flavorName); @Override HostIPsListWrapper getRandomAddressByStackOrFlavor(String serviceName, String stackName, String flavorName); @Override void deleteStack(String serviceName, String dataCenter, String availabilityZone, String flavor); @Override synchronized void deleteStacks(Paths paths); void setWhiteListService(IWhiteListService whiteListService); void setInitialDelay(long initialDelay); void setRefreshDelay(long refreshDelay); }
StacksService implements IStacksService { @Override public Set<StackData> getAllStacksAndHosts(String serviceName) { return FluentIterable .from(getStackPathsForService(serviceName)) .transform(new Function<XreStackPath, StackData>() { @Override public StackData apply(XreStackPath input) { try { return new StackData(input.getPath(), getNodesAddresses(input)); } catch (RedirectorDataSourceException e) { throw new ServiceException("failed to get hosts for " + input.getPath(), e); } } }) .toSet(); }  @PostConstruct void init(); @Override ServicePaths getStacksForService(String serviceName); @Override ServicePaths updateStacksForService(String serviceName, ServicePaths servicePaths, Whitelisted whitelisted); @Override Set<String> getAllServiceNames(); @Override Boolean isServiceExists(String serviceName); @Override ServicePaths getStacksForAllServices(); @Override Set<PathItem> getActiveStacksAndFlavors(String serviceName); Set<PathItem> getActiveStacksAndFlavors(String serviceName, ServicePaths servicePaths); @Override HostIPsListWrapper getHostsForStackOnlyAndService(String stackName, String serviceName); @Override HostIPsListWrapper getRandomHostForStackOnlyAndService(String stackOnlyPath, String serviceName); @Override HostIPsListWrapper getHostsForStackAndService(String stackName, String serviceName); @Override HostIPsListWrapper getRandomHostForStackAndService(String stackName, String serviceName); @Override HostIPsListWrapper getHostsForFlavorAndService(String flavorName, String serviceName); @Override HostIPsListWrapper getRandomHostForFlavorAndService(String flavorName, String serviceName); @Override Set<StackData> getAllStacksAndHosts(String serviceName); Boolean isStackNameWithoutFlavor(String stackName); @Override HostIPsListWrapper getAddressByStackOrFlavor(String appName, String stackName, String flavorName); @Override HostIPsListWrapper getRandomAddressByStackOrFlavor(String serviceName, String stackName, String flavorName); @Override void deleteStack(String serviceName, String dataCenter, String availabilityZone, String flavor); @Override synchronized void deleteStacks(Paths paths); void setWhiteListService(IWhiteListService whiteListService); void setInitialDelay(long initialDelay); void setRefreshDelay(long refreshDelay);  }