@Test public void approveAllinOrderTest() { InOrder inOrder = inOrder(namespacedListsService); NamespaceChangesStatus namespacesChangesStatusReturned = namespacesChangesService.approveAll(SERVICE_NAME); inOrder.verify(namespacedListsService, atLeastOnce()).addNamespacedList(namespacedList2); inOrder.verify(namespacedListsService, atLeastOnce()).addNamespacedList(namespacedList1); inOrder.verify(namespacedListsService, atLeastOnce()).deleteNamespacedList(namespacedList3.getName()); Assert.assertEquals(0, namespacesChangesStatusReturned.getNamespaceChanges().size()); }
public NamespaceChangesStatus approveAll(String serviceName) { NamespaceChangesStatus namespaceChangesStatus = getNamespaceChangesStatus(serviceName); errorList = new ArrayList<>(); if (namespaceChangesStatus != null && namespaceChangesStatus.getNamespaceChanges() != null) { Map<NamespacedList, ActionType> removedNamespacesChangesMap = namespaceChangesStatus.getNamespaceChanges().entrySet().stream() .sorted(timespampComparator) .filter(filterToSave) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); namespaceChangesStatus.setNamespaceChanges(removedNamespacesChangesMap); save(serviceName, namespaceChangesStatus); } if (errorList.size() > 0) { String commaSeparatedFailedNamespacedList = errorList.stream() .map(stringFunction -> stringFunction.toString()) .collect(Collectors.joining(", ")); throw new WebApplicationException(commaSeparatedFailedNamespacedList, Response.status(Response.Status.BAD_REQUEST).entity(new ErrorMessage(commaSeparatedFailedNamespacedList)).build()); } return namespaceChangesStatus; }
NamespacesChangesService { public NamespaceChangesStatus approveAll(String serviceName) { NamespaceChangesStatus namespaceChangesStatus = getNamespaceChangesStatus(serviceName); errorList = new ArrayList<>(); if (namespaceChangesStatus != null && namespaceChangesStatus.getNamespaceChanges() != null) { Map<NamespacedList, ActionType> removedNamespacesChangesMap = namespaceChangesStatus.getNamespaceChanges().entrySet().stream() .sorted(timespampComparator) .filter(filterToSave) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); namespaceChangesStatus.setNamespaceChanges(removedNamespacesChangesMap); save(serviceName, namespaceChangesStatus); } if (errorList.size() > 0) { String commaSeparatedFailedNamespacedList = errorList.stream() .map(stringFunction -> stringFunction.toString()) .collect(Collectors.joining(", ")); throw new WebApplicationException(commaSeparatedFailedNamespacedList, Response.status(Response.Status.BAD_REQUEST).entity(new ErrorMessage(commaSeparatedFailedNamespacedList)).build()); } return namespaceChangesStatus; } }
NamespacesChangesService { public NamespaceChangesStatus approveAll(String serviceName) { NamespaceChangesStatus namespaceChangesStatus = getNamespaceChangesStatus(serviceName); errorList = new ArrayList<>(); if (namespaceChangesStatus != null && namespaceChangesStatus.getNamespaceChanges() != null) { Map<NamespacedList, ActionType> removedNamespacesChangesMap = namespaceChangesStatus.getNamespaceChanges().entrySet().stream() .sorted(timespampComparator) .filter(filterToSave) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); namespaceChangesStatus.setNamespaceChanges(removedNamespacesChangesMap); save(serviceName, namespaceChangesStatus); } if (errorList.size() > 0) { String commaSeparatedFailedNamespacedList = errorList.stream() .map(stringFunction -> stringFunction.toString()) .collect(Collectors.joining(", ")); throw new WebApplicationException(commaSeparatedFailedNamespacedList, Response.status(Response.Status.BAD_REQUEST).entity(new ErrorMessage(commaSeparatedFailedNamespacedList)).build()); } return namespaceChangesStatus; }  }
NamespacesChangesService { public NamespaceChangesStatus approveAll(String serviceName) { NamespaceChangesStatus namespaceChangesStatus = getNamespaceChangesStatus(serviceName); errorList = new ArrayList<>(); if (namespaceChangesStatus != null && namespaceChangesStatus.getNamespaceChanges() != null) { Map<NamespacedList, ActionType> removedNamespacesChangesMap = namespaceChangesStatus.getNamespaceChanges().entrySet().stream() .sorted(timespampComparator) .filter(filterToSave) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); namespaceChangesStatus.setNamespaceChanges(removedNamespacesChangesMap); save(serviceName, namespaceChangesStatus); } if (errorList.size() > 0) { String commaSeparatedFailedNamespacedList = errorList.stream() .map(stringFunction -> stringFunction.toString()) .collect(Collectors.joining(", ")); throw new WebApplicationException(commaSeparatedFailedNamespacedList, Response.status(Response.Status.BAD_REQUEST).entity(new ErrorMessage(commaSeparatedFailedNamespacedList)).build()); } return namespaceChangesStatus; }  void save(String serviceName, NamespaceChangesStatus namespaceChangesStatus); NamespaceChangesStatus getNamespaceChangesStatus(String serviceName); NamespaceChangesStatus approve(String serviceName, NamespacedList namespacedList); NamespaceChangesStatus cancelAll(String serviceName); NamespaceChangesStatus cancel(String serviceName, NamespacedList namespacedList); NamespaceChangesStatus approveAll(String serviceName); }
NamespacesChangesService { public NamespaceChangesStatus approveAll(String serviceName) { NamespaceChangesStatus namespaceChangesStatus = getNamespaceChangesStatus(serviceName); errorList = new ArrayList<>(); if (namespaceChangesStatus != null && namespaceChangesStatus.getNamespaceChanges() != null) { Map<NamespacedList, ActionType> removedNamespacesChangesMap = namespaceChangesStatus.getNamespaceChanges().entrySet().stream() .sorted(timespampComparator) .filter(filterToSave) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); namespaceChangesStatus.setNamespaceChanges(removedNamespacesChangesMap); save(serviceName, namespaceChangesStatus); } if (errorList.size() > 0) { String commaSeparatedFailedNamespacedList = errorList.stream() .map(stringFunction -> stringFunction.toString()) .collect(Collectors.joining(", ")); throw new WebApplicationException(commaSeparatedFailedNamespacedList, Response.status(Response.Status.BAD_REQUEST).entity(new ErrorMessage(commaSeparatedFailedNamespacedList)).build()); } return namespaceChangesStatus; }  void save(String serviceName, NamespaceChangesStatus namespaceChangesStatus); NamespaceChangesStatus getNamespaceChangesStatus(String serviceName); NamespaceChangesStatus approve(String serviceName, NamespacedList namespacedList); NamespaceChangesStatus cancelAll(String serviceName); NamespaceChangesStatus cancel(String serviceName, NamespacedList namespacedList); NamespaceChangesStatus approveAll(String serviceName);  }