@Test public void approveTest() { NamespaceChangesStatus namespacesChangesStatusReturned = namespacesChangesService.approve(SERVICE_NAME, namespacedList1); verify(namespacedListsService, atLeastOnce()).addNamespacedList(namespacedList1); Assert.assertEquals(2, namespacesChangesStatusReturned.getNamespaceChanges().size()); }
public NamespaceChangesStatus approve(String serviceName, NamespacedList namespacedList) { NamespaceChangesStatus namespaceChangesStatus = getNamespaceChangesStatus(serviceName); errorList = null; if (namespaceChangesStatus != null && namespaceChangesStatus.getNamespaceChanges() != null && namespacedList != null) { Map<NamespacedList, ActionType> removedNamespacesChangesMap = namespaceChangesStatus.getNamespaceChanges().entrySet().stream() .filter(filterToSaveAlone(namespacedList)) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); namespaceChangesStatus.setNamespaceChanges(removedNamespacesChangesMap); save(serviceName, namespaceChangesStatus); } if (errorList != null) { throw new WebApplicationException(FAILED_TO_SAVE_NAMESPACE_DUE_TO_VALIDATION_ERROR, Response.status(Response.Status.BAD_REQUEST).entity(new ErrorMessage(FAILED_TO_SAVE_NAMESPACE_DUE_TO_VALIDATION_ERROR)).build()); } return namespaceChangesStatus; }
NamespacesChangesService { public NamespaceChangesStatus approve(String serviceName, NamespacedList namespacedList) { NamespaceChangesStatus namespaceChangesStatus = getNamespaceChangesStatus(serviceName); errorList = null; if (namespaceChangesStatus != null && namespaceChangesStatus.getNamespaceChanges() != null && namespacedList != null) { Map<NamespacedList, ActionType> removedNamespacesChangesMap = namespaceChangesStatus.getNamespaceChanges().entrySet().stream() .filter(filterToSaveAlone(namespacedList)) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); namespaceChangesStatus.setNamespaceChanges(removedNamespacesChangesMap); save(serviceName, namespaceChangesStatus); } if (errorList != null) { throw new WebApplicationException(FAILED_TO_SAVE_NAMESPACE_DUE_TO_VALIDATION_ERROR, Response.status(Response.Status.BAD_REQUEST).entity(new ErrorMessage(FAILED_TO_SAVE_NAMESPACE_DUE_TO_VALIDATION_ERROR)).build()); } return namespaceChangesStatus; } }
NamespacesChangesService { public NamespaceChangesStatus approve(String serviceName, NamespacedList namespacedList) { NamespaceChangesStatus namespaceChangesStatus = getNamespaceChangesStatus(serviceName); errorList = null; if (namespaceChangesStatus != null && namespaceChangesStatus.getNamespaceChanges() != null && namespacedList != null) { Map<NamespacedList, ActionType> removedNamespacesChangesMap = namespaceChangesStatus.getNamespaceChanges().entrySet().stream() .filter(filterToSaveAlone(namespacedList)) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); namespaceChangesStatus.setNamespaceChanges(removedNamespacesChangesMap); save(serviceName, namespaceChangesStatus); } if (errorList != null) { throw new WebApplicationException(FAILED_TO_SAVE_NAMESPACE_DUE_TO_VALIDATION_ERROR, Response.status(Response.Status.BAD_REQUEST).entity(new ErrorMessage(FAILED_TO_SAVE_NAMESPACE_DUE_TO_VALIDATION_ERROR)).build()); } return namespaceChangesStatus; }  }
NamespacesChangesService { public NamespaceChangesStatus approve(String serviceName, NamespacedList namespacedList) { NamespaceChangesStatus namespaceChangesStatus = getNamespaceChangesStatus(serviceName); errorList = null; if (namespaceChangesStatus != null && namespaceChangesStatus.getNamespaceChanges() != null && namespacedList != null) { Map<NamespacedList, ActionType> removedNamespacesChangesMap = namespaceChangesStatus.getNamespaceChanges().entrySet().stream() .filter(filterToSaveAlone(namespacedList)) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); namespaceChangesStatus.setNamespaceChanges(removedNamespacesChangesMap); save(serviceName, namespaceChangesStatus); } if (errorList != null) { throw new WebApplicationException(FAILED_TO_SAVE_NAMESPACE_DUE_TO_VALIDATION_ERROR, Response.status(Response.Status.BAD_REQUEST).entity(new ErrorMessage(FAILED_TO_SAVE_NAMESPACE_DUE_TO_VALIDATION_ERROR)).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 approve(String serviceName, NamespacedList namespacedList) { NamespaceChangesStatus namespaceChangesStatus = getNamespaceChangesStatus(serviceName); errorList = null; if (namespaceChangesStatus != null && namespaceChangesStatus.getNamespaceChanges() != null && namespacedList != null) { Map<NamespacedList, ActionType> removedNamespacesChangesMap = namespaceChangesStatus.getNamespaceChanges().entrySet().stream() .filter(filterToSaveAlone(namespacedList)) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); namespaceChangesStatus.setNamespaceChanges(removedNamespacesChangesMap); save(serviceName, namespaceChangesStatus); } if (errorList != null) { throw new WebApplicationException(FAILED_TO_SAVE_NAMESPACE_DUE_TO_VALIDATION_ERROR, Response.status(Response.Status.BAD_REQUEST).entity(new ErrorMessage(FAILED_TO_SAVE_NAMESPACE_DUE_TO_VALIDATION_ERROR)).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);  }