@Test public void test_that_getRunCanaryStages_returns_the_expected_sorted_list_of_stages_sorted_by_the_number_in_the_stage_name() { Stage stage = mock(Stage.class); Execution execution = mock(Execution.class); when(stage.getExecution()).thenReturn(execution); when(execution.getStages()).thenReturn(ImmutableList.of( new Stage(null, STAGE_TYPE, "foo #1", Maps.newHashMap(ImmutableMap.of("index", "0"))), new Stage(null, STAGE_TYPE, "foo #3", Maps.newHashMap(ImmutableMap.of("index", "2"))), new Stage(null, STAGE_TYPE, "foo #2", Maps.newHashMap(ImmutableMap.of("index", "1"))), new Stage(null, STAGE_TYPE, "foo #4", Maps.newHashMap(ImmutableMap.of("index", "3"))) )); List<Stage> actual = task.getRunCanaryStages(stage); for (int i = 0; i < 4; i++) { assertEquals(String.valueOf(i), actual.get(i).getContext().get("index")); } }
private Stage newStage(Consumer<Stage> init) { Stage stage = new Stage(); init.accept(stage); return stage; } }
public PipelineBuilder withStage(String type, String name, Map<String, Object> context) { if (context.get("providerType") != null && !(Arrays.asList("aws", "titus")).contains(context.get("providerType"))) { type += "_" + context.get("providerType"); } pipeline.getStages().add(new Stage(pipeline, type, name, context)); return this; }
@Deprecated static @Nonnull Stage newStage( @Nonnull Execution execution, @Nonnull String type, @Nullable String name, @Nonnull Map<String, Object> context, @Nullable Stage parent, @Nullable SyntheticStageOwner stageOwner ) { Stage stage = new Stage(execution, type, name, context); if (parent != null) { stage.setParentStageId(parent.getId()); } stage.setSyntheticStageOwner(stageOwner); return stage; }
private Execution parseOrchestration(String configJson) throws IOException { @SuppressWarnings("unchecked") Map<String, Serializable> config = objectMapper.readValue(configJson, Map.class); Execution orchestration = Execution.newOrchestration(getString(config, "application")); if (config.containsKey("name")) { orchestration.setDescription(getString(config, "name")); } if (config.containsKey("description")) { orchestration.setDescription(getString(config, "description")); } for (Map<String, Object> context : getList(config, "stages")) { String type = context.remove("type").toString(); String providerType = getString(context, "providerType"); if (providerType != null && !providerType.equals("aws") && !providerType.equals("titus")) { type += format("_%s", providerType); } // TODO: need to check it's valid? Stage stage = new Stage(orchestration, type, context); orchestration.getStages().add(stage); } if (config.get("trigger") != null) { orchestration.setTrigger(objectMapper.convertValue(config.get("trigger"), Trigger.class)); } orchestration.setBuildTime(clock.millis()); orchestration.setAuthentication(AuthenticationDetails.build().orElse(new AuthenticationDetails())); orchestration.setOrigin((String) config.getOrDefault("origin", "unknown")); orchestration.setStartTimeExpiry((Long) config.get("startTimeExpiry")); return orchestration; }
stageIds.forEach(stageId -> { String prefix = format("stage.%s.", stageId); Stage stage = new Stage(); try { stage.setId(stageId);