@Test public void test_that_getRunCanaryStages_returns_the_expected_sorted_list_of_stages_sorted_by_the_number_in_the_stage_name() { StageExecution stage = mock(StageExecution.class); PipelineExecution execution = mock(PipelineExecution.class); when(stage.getExecution()).thenReturn(execution); when(execution.getStages()) .thenReturn( ImmutableList.of( new StageExecutionImpl( null, STAGE_TYPE, "foo #1", Maps.newHashMap(ImmutableMap.of("index", "0"))), new StageExecutionImpl( null, STAGE_TYPE, "foo #3", Maps.newHashMap(ImmutableMap.of("index", "2"))), new StageExecutionImpl( null, STAGE_TYPE, "foo #2", Maps.newHashMap(ImmutableMap.of("index", "1"))), new StageExecutionImpl( null, STAGE_TYPE, "foo #4", Maps.newHashMap(ImmutableMap.of("index", "3"))))); List<StageExecution> actual = task.getRunCanaryStages(stage); for (int i = 0; i < 4; i++) { assertEquals(String.valueOf(i), actual.get(i).getContext().get("index")); } }
@NotNull protected List<StageExecution> getRunCanaryStages(@Nonnull StageExecution stage) { return stage.getExecution().getStages().stream() .filter(s -> s.getType().equals(RunCanaryStage.STAGE_TYPE)) .sorted( Comparator.comparing( s -> Integer.valueOf(StringUtils.substringAfterLast(s.getName(), "#")))) .collect(Collectors.toList()); }
GenerateCanaryAnalysisResultTask implements Task { @NotNull protected List<StageExecution> getRunCanaryStages(@Nonnull StageExecution stage) { return stage.getExecution().getStages().stream() .filter(s -> s.getType().equals(RunCanaryStage.STAGE_TYPE)) .sorted( Comparator.comparing( s -> Integer.valueOf(StringUtils.substringAfterLast(s.getName(), "#")))) .collect(Collectors.toList()); } }
GenerateCanaryAnalysisResultTask implements Task { @NotNull protected List<StageExecution> getRunCanaryStages(@Nonnull StageExecution stage) { return stage.getExecution().getStages().stream() .filter(s -> s.getType().equals(RunCanaryStage.STAGE_TYPE)) .sorted( Comparator.comparing( s -> Integer.valueOf(StringUtils.substringAfterLast(s.getName(), "#")))) .collect(Collectors.toList()); } @Autowired  GenerateCanaryAnalysisResultTask(ObjectMapper kayentaObjectMapper); }
GenerateCanaryAnalysisResultTask implements Task { @NotNull protected List<StageExecution> getRunCanaryStages(@Nonnull StageExecution stage) { return stage.getExecution().getStages().stream() .filter(s -> s.getType().equals(RunCanaryStage.STAGE_TYPE)) .sorted( Comparator.comparing( s -> Integer.valueOf(StringUtils.substringAfterLast(s.getName(), "#")))) .collect(Collectors.toList()); } @Autowired  GenerateCanaryAnalysisResultTask(ObjectMapper kayentaObjectMapper); @Nonnull @Override TaskResult execute(@Nonnull StageExecution stage); }
GenerateCanaryAnalysisResultTask implements Task { @NotNull protected List<StageExecution> getRunCanaryStages(@Nonnull StageExecution stage) { return stage.getExecution().getStages().stream() .filter(s -> s.getType().equals(RunCanaryStage.STAGE_TYPE)) .sorted( Comparator.comparing( s -> Integer.valueOf(StringUtils.substringAfterLast(s.getName(), "#")))) .collect(Collectors.toList()); } @Autowired  GenerateCanaryAnalysisResultTask(ObjectMapper kayentaObjectMapper); @Nonnull @Override TaskResult execute(@Nonnull StageExecution stage); static final String CANARY_ANALYSIS_EXECUTION_RESULT; }