@Test public void testGetStacksForAllServices() throws Exception { when(stacksDAO.getAllStackPaths()).thenReturn( getStackPaths("/po/poc1/1.50/xreGuide", "/po/poc2/1.50/xreGuide", "/po/poc1/1.52/xreApp")); when(stacksDAO.getAllAppNamesRegisteredInStacks()).thenReturn( new LinkedHashSet<>(Arrays.asList("xreGuide", "xreApp"))); when(stacksDAO.getHostsCount(new XreStackPath("/po/poc1/1.50/xreGuide"))).thenReturn(5); when(stacksDAO.getHostsCount(new XreStackPath("/po/poc2/1.50/xreGuide"))).thenReturn(6); when(stacksDAO.getHostsCount(new XreStackPath("/po/poc1/1.52/xreApp"))).thenReturn(8); setupWhitelistedService(); ServicePaths result = testee.getStacksForAllServices(); Assert.assertEquals(2, result.getPaths().size()); Paths paths = result.getPaths().get(0); Assert.assertEquals("xreGuide", paths.getServiceName()); Assert.assertEquals(1, paths.getFlavors().size()); Assert.assertEquals(2, paths.getStacks().size()); verifyPathItem("1.50", 11, paths.getFlavors().get(0)); verifyPathItem("/po/poc1/1.50", 5, paths.getStacks().get(0)); verifyPathItem("/po/poc2/1.50", 6, paths.getStacks().get(1)); paths = result.getPaths().get(1); Assert.assertEquals("xreApp", paths.getServiceName()); Assert.assertEquals(1, paths.getFlavors().size()); Assert.assertEquals(1, paths.getStacks().size()); verifyPathItem("1.52", 8, paths.getFlavors().get(0)); verifyPathItem("/po/poc1/1.52", 8, paths.getStacks().get(0)); }
@Override public ServicePaths getStacksForAllServices(){ List<Paths> allPaths = new ArrayList<>(); for (String serviceName : getAllServiceNames()) { allPaths.add(getPathsForService(serviceName)); } return new ServicePaths(allPaths); }
StacksService implements IStacksService { @Override public ServicePaths getStacksForAllServices(){ List<Paths> allPaths = new ArrayList<>(); for (String serviceName : getAllServiceNames()) { allPaths.add(getPathsForService(serviceName)); } return new ServicePaths(allPaths); } }
StacksService implements IStacksService { @Override public ServicePaths getStacksForAllServices(){ List<Paths> allPaths = new ArrayList<>(); for (String serviceName : getAllServiceNames()) { allPaths.add(getPathsForService(serviceName)); } return new ServicePaths(allPaths); }  }
StacksService implements IStacksService { @Override public ServicePaths getStacksForAllServices(){ List<Paths> allPaths = new ArrayList<>(); for (String serviceName : getAllServiceNames()) { allPaths.add(getPathsForService(serviceName)); } return new ServicePaths(allPaths); }  @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 ServicePaths getStacksForAllServices(){ List<Paths> allPaths = new ArrayList<>(); for (String serviceName : getAllServiceNames()) { allPaths.add(getPathsForService(serviceName)); } return new ServicePaths(allPaths); }  @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);  }