@Test public void testDeleteStacks() throws Exception { Paths paths = new Paths("xreGuide"); paths.getStacks().add(new PathItem("/po/poc7/1.50", 0, 0)); paths.getStacks().add(new PathItem("/po/poc7/1.51", 0, 0)); paths.getStacks().add(new PathItem("/po/poc2/1.51", 0, 0)); testee.deleteStacks(paths); verify(stacksDAO, times(1)).deleteStackPath(new XreStackPath("/po/poc7/1.50/xreGuide")); verify(stacksDAO, times(1)).deleteStackPath(new XreStackPath("/po/poc7/1.51/xreGuide")); verify(stacksDAO, times(1)).deleteStackPath(new XreStackPath("/po/poc2/1.51/xreGuide")); }
@Override public synchronized void deleteStacks(Paths paths){ StringBuffer logMsg = new StringBuffer(); logMsg.append("Deleting ").append(paths.getStacks().size()).append(" path(s) for ").append(paths.getServiceName()).append(" application: "); List<String> nonExistingPaths = new ArrayList<>(); for (PathItem item : paths.getStacks()) { try { stacksDAO.deleteStackPath(new XreStackPath(item.getValue(), paths.getServiceName())); logMsg.append(item.getValue()).append("; "); } catch (RedirectorNoNodeInPathException ex) { nonExistingPaths.add(item.getValue()); } } log.info(logMsg.toString()); if (!nonExistingPaths.isEmpty()) { throw new WebApplicationException(getMessageError(nonExistingPaths), Response.Status.BAD_REQUEST); } }
StacksService implements IStacksService { @Override public synchronized void deleteStacks(Paths paths){ StringBuffer logMsg = new StringBuffer(); logMsg.append("Deleting ").append(paths.getStacks().size()).append(" path(s) for ").append(paths.getServiceName()).append(" application: "); List<String> nonExistingPaths = new ArrayList<>(); for (PathItem item : paths.getStacks()) { try { stacksDAO.deleteStackPath(new XreStackPath(item.getValue(), paths.getServiceName())); logMsg.append(item.getValue()).append("; "); } catch (RedirectorNoNodeInPathException ex) { nonExistingPaths.add(item.getValue()); } } log.info(logMsg.toString()); if (!nonExistingPaths.isEmpty()) { throw new WebApplicationException(getMessageError(nonExistingPaths), Response.Status.BAD_REQUEST); } } }
StacksService implements IStacksService { @Override public synchronized void deleteStacks(Paths paths){ StringBuffer logMsg = new StringBuffer(); logMsg.append("Deleting ").append(paths.getStacks().size()).append(" path(s) for ").append(paths.getServiceName()).append(" application: "); List<String> nonExistingPaths = new ArrayList<>(); for (PathItem item : paths.getStacks()) { try { stacksDAO.deleteStackPath(new XreStackPath(item.getValue(), paths.getServiceName())); logMsg.append(item.getValue()).append("; "); } catch (RedirectorNoNodeInPathException ex) { nonExistingPaths.add(item.getValue()); } } log.info(logMsg.toString()); if (!nonExistingPaths.isEmpty()) { throw new WebApplicationException(getMessageError(nonExistingPaths), Response.Status.BAD_REQUEST); } }  }
StacksService implements IStacksService { @Override public synchronized void deleteStacks(Paths paths){ StringBuffer logMsg = new StringBuffer(); logMsg.append("Deleting ").append(paths.getStacks().size()).append(" path(s) for ").append(paths.getServiceName()).append(" application: "); List<String> nonExistingPaths = new ArrayList<>(); for (PathItem item : paths.getStacks()) { try { stacksDAO.deleteStackPath(new XreStackPath(item.getValue(), paths.getServiceName())); logMsg.append(item.getValue()).append("; "); } catch (RedirectorNoNodeInPathException ex) { nonExistingPaths.add(item.getValue()); } } log.info(logMsg.toString()); if (!nonExistingPaths.isEmpty()) { throw new WebApplicationException(getMessageError(nonExistingPaths), Response.Status.BAD_REQUEST); } }  @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 synchronized void deleteStacks(Paths paths){ StringBuffer logMsg = new StringBuffer(); logMsg.append("Deleting ").append(paths.getStacks().size()).append(" path(s) for ").append(paths.getServiceName()).append(" application: "); List<String> nonExistingPaths = new ArrayList<>(); for (PathItem item : paths.getStacks()) { try { stacksDAO.deleteStackPath(new XreStackPath(item.getValue(), paths.getServiceName())); logMsg.append(item.getValue()).append("; "); } catch (RedirectorNoNodeInPathException ex) { nonExistingPaths.add(item.getValue()); } } log.info(logMsg.toString()); if (!nonExistingPaths.isEmpty()) { throw new WebApplicationException(getMessageError(nonExistingPaths), Response.Status.BAD_REQUEST); } }  @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);  }