@Test public void getSpecifiedOperationsToReset() { AgendaProgress agendaProgress = new AgendaProgress(); OperationProgress operationProgress = new OperationProgress(); operationProgress.setOperation(VALID_OP_NAME); agendaProgress.setOperationProgress(new OperationProgress[] {operationProgress}); String param = RerunAgendaParameter.OPERATIONS_TO_RESET.getParameterNameWithValue(VALID_OP_NAME); Set<String> opsToReset = progressResetProcessor.getSpecifiedOperationsToReset( RerunAgendaParameter.getParametersMap(Collections.singletonList(param)), agendaProgress); Assert.assertEquals(opsToReset.size(), 1); Assert.assertTrue(opsToReset.contains(VALID_OP_NAME)); }
protected Set<String> getSpecifiedOperationsToReset(Map<RerunAgendaParameter, String> retryParameters, AgendaProgress agendaProgress) { if (!retryParameters.containsKey(RerunAgendaParameter.OPERATIONS_TO_RESET)) return new HashSet<>(); String delimitedOps = retryParameters.get(RerunAgendaParameter.OPERATIONS_TO_RESET); String[] opsToReset = StringUtils.split(delimitedOps, RerunAgendaParameter.VALUE_DELIMITER); if (opsToReset == null || opsToReset.length == 0) throw new ValidationException(String.format("params is invalid - %1$s has no operations specified", RerunAgendaParameter.OPERATIONS_TO_RESET.getParameterName())); Set<String> operationNames = Arrays.stream(agendaProgress.getOperationProgress()).map(OperationProgress::getOperation).collect(Collectors.toSet()); List<String> invalidOpNames = Arrays.stream(opsToReset).filter(resetOpName -> !operationNames.contains(resetOpName)).collect(Collectors.toList()); if (invalidOpNames.size() > 0) throw new ValidationException(String.format( "params is invalid - %1$s has the following invalid operation names: %2$s", RerunAgendaParameter.OPERATIONS_TO_RESET.getParameterName(), String.join(",", invalidOpNames))); return Arrays.stream(opsToReset).collect(Collectors.toSet()); }
ProgressResetProcessor { protected Set<String> getSpecifiedOperationsToReset(Map<RerunAgendaParameter, String> retryParameters, AgendaProgress agendaProgress) { if (!retryParameters.containsKey(RerunAgendaParameter.OPERATIONS_TO_RESET)) return new HashSet<>(); String delimitedOps = retryParameters.get(RerunAgendaParameter.OPERATIONS_TO_RESET); String[] opsToReset = StringUtils.split(delimitedOps, RerunAgendaParameter.VALUE_DELIMITER); if (opsToReset == null || opsToReset.length == 0) throw new ValidationException(String.format("params is invalid - %1$s has no operations specified", RerunAgendaParameter.OPERATIONS_TO_RESET.getParameterName())); Set<String> operationNames = Arrays.stream(agendaProgress.getOperationProgress()).map(OperationProgress::getOperation).collect(Collectors.toSet()); List<String> invalidOpNames = Arrays.stream(opsToReset).filter(resetOpName -> !operationNames.contains(resetOpName)).collect(Collectors.toList()); if (invalidOpNames.size() > 0) throw new ValidationException(String.format( "params is invalid - %1$s has the following invalid operation names: %2$s", RerunAgendaParameter.OPERATIONS_TO_RESET.getParameterName(), String.join(",", invalidOpNames))); return Arrays.stream(opsToReset).collect(Collectors.toSet()); } }
ProgressResetProcessor { protected Set<String> getSpecifiedOperationsToReset(Map<RerunAgendaParameter, String> retryParameters, AgendaProgress agendaProgress) { if (!retryParameters.containsKey(RerunAgendaParameter.OPERATIONS_TO_RESET)) return new HashSet<>(); String delimitedOps = retryParameters.get(RerunAgendaParameter.OPERATIONS_TO_RESET); String[] opsToReset = StringUtils.split(delimitedOps, RerunAgendaParameter.VALUE_DELIMITER); if (opsToReset == null || opsToReset.length == 0) throw new ValidationException(String.format("params is invalid - %1$s has no operations specified", RerunAgendaParameter.OPERATIONS_TO_RESET.getParameterName())); Set<String> operationNames = Arrays.stream(agendaProgress.getOperationProgress()).map(OperationProgress::getOperation).collect(Collectors.toSet()); List<String> invalidOpNames = Arrays.stream(opsToReset).filter(resetOpName -> !operationNames.contains(resetOpName)).collect(Collectors.toList()); if (invalidOpNames.size() > 0) throw new ValidationException(String.format( "params is invalid - %1$s has the following invalid operation names: %2$s", RerunAgendaParameter.OPERATIONS_TO_RESET.getParameterName(), String.join(",", invalidOpNames))); return Arrays.stream(opsToReset).collect(Collectors.toSet()); }  }
ProgressResetProcessor { protected Set<String> getSpecifiedOperationsToReset(Map<RerunAgendaParameter, String> retryParameters, AgendaProgress agendaProgress) { if (!retryParameters.containsKey(RerunAgendaParameter.OPERATIONS_TO_RESET)) return new HashSet<>(); String delimitedOps = retryParameters.get(RerunAgendaParameter.OPERATIONS_TO_RESET); String[] opsToReset = StringUtils.split(delimitedOps, RerunAgendaParameter.VALUE_DELIMITER); if (opsToReset == null || opsToReset.length == 0) throw new ValidationException(String.format("params is invalid - %1$s has no operations specified", RerunAgendaParameter.OPERATIONS_TO_RESET.getParameterName())); Set<String> operationNames = Arrays.stream(agendaProgress.getOperationProgress()).map(OperationProgress::getOperation).collect(Collectors.toSet()); List<String> invalidOpNames = Arrays.stream(opsToReset).filter(resetOpName -> !operationNames.contains(resetOpName)).collect(Collectors.toList()); if (invalidOpNames.size() > 0) throw new ValidationException(String.format( "params is invalid - %1$s has the following invalid operation names: %2$s", RerunAgendaParameter.OPERATIONS_TO_RESET.getParameterName(), String.join(",", invalidOpNames))); return Arrays.stream(opsToReset).collect(Collectors.toSet()); }  ProgressResetResult resetProgress(Agenda agenda, AgendaProgress agendaProgress, Map<RerunAgendaParameter, String> retryParameters); }
ProgressResetProcessor { protected Set<String> getSpecifiedOperationsToReset(Map<RerunAgendaParameter, String> retryParameters, AgendaProgress agendaProgress) { if (!retryParameters.containsKey(RerunAgendaParameter.OPERATIONS_TO_RESET)) return new HashSet<>(); String delimitedOps = retryParameters.get(RerunAgendaParameter.OPERATIONS_TO_RESET); String[] opsToReset = StringUtils.split(delimitedOps, RerunAgendaParameter.VALUE_DELIMITER); if (opsToReset == null || opsToReset.length == 0) throw new ValidationException(String.format("params is invalid - %1$s has no operations specified", RerunAgendaParameter.OPERATIONS_TO_RESET.getParameterName())); Set<String> operationNames = Arrays.stream(agendaProgress.getOperationProgress()).map(OperationProgress::getOperation).collect(Collectors.toSet()); List<String> invalidOpNames = Arrays.stream(opsToReset).filter(resetOpName -> !operationNames.contains(resetOpName)).collect(Collectors.toList()); if (invalidOpNames.size() > 0) throw new ValidationException(String.format( "params is invalid - %1$s has the following invalid operation names: %2$s", RerunAgendaParameter.OPERATIONS_TO_RESET.getParameterName(), String.join(",", invalidOpNames))); return Arrays.stream(opsToReset).collect(Collectors.toSet()); }  ProgressResetResult resetProgress(Agenda agenda, AgendaProgress agendaProgress, Map<RerunAgendaParameter, String> retryParameters);  }