@Test(dataProvider = "resetDependentOperationsProvider") public void testResetDependentOperations(List<Operation> operations, List<String> explicitResetList, List<String> expectedOperationsToReset, List<String> expectedOperationsToDelete) { Agenda agenda = new Agenda(); agenda.setOperations(operations); ProgressResetResult progressResetResult = progressResetProcessor.generateResetResult(agenda, new HashSet<>(explicitResetList)); Assert.assertEquals(progressResetResult.getOperationsToReset().size(), expectedOperationsToReset.size(), String.format("Expected: [%1$s] Actual: [%2$s] -- Sizes: ", StringUtils.join(expectedOperationsToReset, ","), StringUtils.join(progressResetResult.getOperationsToReset(), ","))); Assert.assertTrue(expectedOperationsToReset.containsAll(progressResetResult.getOperationsToReset())); Assert.assertEquals(progressResetResult.getOperationsToDelete().size(), expectedOperationsToDelete.size(), String.format("Expected: [%1$s] Actual: [%2$s] -- Sizes: ", StringUtils.join(expectedOperationsToDelete, ","), StringUtils.join(progressResetResult.getOperationsToDelete(), ","))); Assert.assertTrue(expectedOperationsToDelete.containsAll(progressResetResult.getOperationsToDelete())); }
protected ProgressResetResult generateResetResult(Agenda agenda, Set<String> specifiedResetOperationNames) { ProgressResetResult progressResetResult = new ProgressResetResult(); Set<String> operationsToReset = new HashSet<>(specifiedResetOperationNames); Map<String, OperationDependencies> operationDependencyMap = buildOperationDependencyMap(agenda); Map<String, OperationDependencies> workingOperationDependencyMap = new HashMap<>(operationDependencyMap); for(String opName : operationsToReset) { OperationDependencies operationDependencies = operationDependencyMap.get(opName); if(operationsToReset.contains(operationDependencies.getGeneratedParent())) { progressResetResult.getOperationsToDelete().add(opName); } workingOperationDependencyMap.remove(opName); } while(true) { if(workingOperationDependencyMap.isEmpty()) { break; } Set<String> additionalOperationsToReset = new HashSet<>(); for(Map.Entry<String, OperationDependencies> entry : workingOperationDependencyMap.entrySet()) { OperationDependencies opDependencies = entry.getValue(); if(opDependencies.getDependencies().stream().anyMatch(operationsToReset::contains)) { additionalOperationsToReset.add(entry.getKey()); } if(operationsToReset.contains(opDependencies.getGeneratedParent())) { progressResetResult.getOperationsToDelete().add(entry.getKey()); additionalOperationsToReset.add(entry.getKey()); } } if(additionalOperationsToReset.isEmpty()) { break; } operationsToReset.addAll(additionalOperationsToReset); for(String opName : additionalOperationsToReset) { workingOperationDependencyMap.remove(opName); } } for(String opName : operationsToReset) { OperationDependencies operationDependencies = operationDependencyMap.get(opName); if(operationsToReset.contains(operationDependencies.getGeneratedParent())) { progressResetResult.getOperationsToDelete().add(opName); } } operationsToReset.removeAll(progressResetResult.getOperationsToDelete()); progressResetResult.getOperationsToReset().addAll(operationsToReset); return progressResetResult; }
ProgressResetProcessor { protected ProgressResetResult generateResetResult(Agenda agenda, Set<String> specifiedResetOperationNames) { ProgressResetResult progressResetResult = new ProgressResetResult(); Set<String> operationsToReset = new HashSet<>(specifiedResetOperationNames); Map<String, OperationDependencies> operationDependencyMap = buildOperationDependencyMap(agenda); Map<String, OperationDependencies> workingOperationDependencyMap = new HashMap<>(operationDependencyMap); for(String opName : operationsToReset) { OperationDependencies operationDependencies = operationDependencyMap.get(opName); if(operationsToReset.contains(operationDependencies.getGeneratedParent())) { progressResetResult.getOperationsToDelete().add(opName); } workingOperationDependencyMap.remove(opName); } while(true) { if(workingOperationDependencyMap.isEmpty()) { break; } Set<String> additionalOperationsToReset = new HashSet<>(); for(Map.Entry<String, OperationDependencies> entry : workingOperationDependencyMap.entrySet()) { OperationDependencies opDependencies = entry.getValue(); if(opDependencies.getDependencies().stream().anyMatch(operationsToReset::contains)) { additionalOperationsToReset.add(entry.getKey()); } if(operationsToReset.contains(opDependencies.getGeneratedParent())) { progressResetResult.getOperationsToDelete().add(entry.getKey()); additionalOperationsToReset.add(entry.getKey()); } } if(additionalOperationsToReset.isEmpty()) { break; } operationsToReset.addAll(additionalOperationsToReset); for(String opName : additionalOperationsToReset) { workingOperationDependencyMap.remove(opName); } } for(String opName : operationsToReset) { OperationDependencies operationDependencies = operationDependencyMap.get(opName); if(operationsToReset.contains(operationDependencies.getGeneratedParent())) { progressResetResult.getOperationsToDelete().add(opName); } } operationsToReset.removeAll(progressResetResult.getOperationsToDelete()); progressResetResult.getOperationsToReset().addAll(operationsToReset); return progressResetResult; } }
ProgressResetProcessor { protected ProgressResetResult generateResetResult(Agenda agenda, Set<String> specifiedResetOperationNames) { ProgressResetResult progressResetResult = new ProgressResetResult(); Set<String> operationsToReset = new HashSet<>(specifiedResetOperationNames); Map<String, OperationDependencies> operationDependencyMap = buildOperationDependencyMap(agenda); Map<String, OperationDependencies> workingOperationDependencyMap = new HashMap<>(operationDependencyMap); for(String opName : operationsToReset) { OperationDependencies operationDependencies = operationDependencyMap.get(opName); if(operationsToReset.contains(operationDependencies.getGeneratedParent())) { progressResetResult.getOperationsToDelete().add(opName); } workingOperationDependencyMap.remove(opName); } while(true) { if(workingOperationDependencyMap.isEmpty()) { break; } Set<String> additionalOperationsToReset = new HashSet<>(); for(Map.Entry<String, OperationDependencies> entry : workingOperationDependencyMap.entrySet()) { OperationDependencies opDependencies = entry.getValue(); if(opDependencies.getDependencies().stream().anyMatch(operationsToReset::contains)) { additionalOperationsToReset.add(entry.getKey()); } if(operationsToReset.contains(opDependencies.getGeneratedParent())) { progressResetResult.getOperationsToDelete().add(entry.getKey()); additionalOperationsToReset.add(entry.getKey()); } } if(additionalOperationsToReset.isEmpty()) { break; } operationsToReset.addAll(additionalOperationsToReset); for(String opName : additionalOperationsToReset) { workingOperationDependencyMap.remove(opName); } } for(String opName : operationsToReset) { OperationDependencies operationDependencies = operationDependencyMap.get(opName); if(operationsToReset.contains(operationDependencies.getGeneratedParent())) { progressResetResult.getOperationsToDelete().add(opName); } } operationsToReset.removeAll(progressResetResult.getOperationsToDelete()); progressResetResult.getOperationsToReset().addAll(operationsToReset); return progressResetResult; }  }
ProgressResetProcessor { protected ProgressResetResult generateResetResult(Agenda agenda, Set<String> specifiedResetOperationNames) { ProgressResetResult progressResetResult = new ProgressResetResult(); Set<String> operationsToReset = new HashSet<>(specifiedResetOperationNames); Map<String, OperationDependencies> operationDependencyMap = buildOperationDependencyMap(agenda); Map<String, OperationDependencies> workingOperationDependencyMap = new HashMap<>(operationDependencyMap); for(String opName : operationsToReset) { OperationDependencies operationDependencies = operationDependencyMap.get(opName); if(operationsToReset.contains(operationDependencies.getGeneratedParent())) { progressResetResult.getOperationsToDelete().add(opName); } workingOperationDependencyMap.remove(opName); } while(true) { if(workingOperationDependencyMap.isEmpty()) { break; } Set<String> additionalOperationsToReset = new HashSet<>(); for(Map.Entry<String, OperationDependencies> entry : workingOperationDependencyMap.entrySet()) { OperationDependencies opDependencies = entry.getValue(); if(opDependencies.getDependencies().stream().anyMatch(operationsToReset::contains)) { additionalOperationsToReset.add(entry.getKey()); } if(operationsToReset.contains(opDependencies.getGeneratedParent())) { progressResetResult.getOperationsToDelete().add(entry.getKey()); additionalOperationsToReset.add(entry.getKey()); } } if(additionalOperationsToReset.isEmpty()) { break; } operationsToReset.addAll(additionalOperationsToReset); for(String opName : additionalOperationsToReset) { workingOperationDependencyMap.remove(opName); } } for(String opName : operationsToReset) { OperationDependencies operationDependencies = operationDependencyMap.get(opName); if(operationsToReset.contains(operationDependencies.getGeneratedParent())) { progressResetResult.getOperationsToDelete().add(opName); } } operationsToReset.removeAll(progressResetResult.getOperationsToDelete()); progressResetResult.getOperationsToReset().addAll(operationsToReset); return progressResetResult; }  ProgressResetResult resetProgress(Agenda agenda, AgendaProgress agendaProgress, Map<RerunAgendaParameter, String> retryParameters); }
ProgressResetProcessor { protected ProgressResetResult generateResetResult(Agenda agenda, Set<String> specifiedResetOperationNames) { ProgressResetResult progressResetResult = new ProgressResetResult(); Set<String> operationsToReset = new HashSet<>(specifiedResetOperationNames); Map<String, OperationDependencies> operationDependencyMap = buildOperationDependencyMap(agenda); Map<String, OperationDependencies> workingOperationDependencyMap = new HashMap<>(operationDependencyMap); for(String opName : operationsToReset) { OperationDependencies operationDependencies = operationDependencyMap.get(opName); if(operationsToReset.contains(operationDependencies.getGeneratedParent())) { progressResetResult.getOperationsToDelete().add(opName); } workingOperationDependencyMap.remove(opName); } while(true) { if(workingOperationDependencyMap.isEmpty()) { break; } Set<String> additionalOperationsToReset = new HashSet<>(); for(Map.Entry<String, OperationDependencies> entry : workingOperationDependencyMap.entrySet()) { OperationDependencies opDependencies = entry.getValue(); if(opDependencies.getDependencies().stream().anyMatch(operationsToReset::contains)) { additionalOperationsToReset.add(entry.getKey()); } if(operationsToReset.contains(opDependencies.getGeneratedParent())) { progressResetResult.getOperationsToDelete().add(entry.getKey()); additionalOperationsToReset.add(entry.getKey()); } } if(additionalOperationsToReset.isEmpty()) { break; } operationsToReset.addAll(additionalOperationsToReset); for(String opName : additionalOperationsToReset) { workingOperationDependencyMap.remove(opName); } } for(String opName : operationsToReset) { OperationDependencies operationDependencies = operationDependencyMap.get(opName); if(operationsToReset.contains(operationDependencies.getGeneratedParent())) { progressResetResult.getOperationsToDelete().add(opName); } } operationsToReset.removeAll(progressResetResult.getOperationsToDelete()); progressResetResult.getOperationsToReset().addAll(operationsToReset); return progressResetResult; }  ProgressResetResult resetProgress(Agenda agenda, AgendaProgress agendaProgress, Map<RerunAgendaParameter, String> retryParameters);  }