示例#1
0
 public Stage saveBuildingStage(String pipelineName, String stageName) throws SQLException {
   Pipeline pipeline = saveTestPipeline(pipelineName, stageName);
   Stage stage = saveBuildingStage(pipeline.getStages().byName(stageName));
   for (JobInstance job : stage.getJobInstances()) {
     job.setIdentifier(new JobIdentifier(pipeline, stage, job));
   }
   return stage;
 }
 @Before
 public void setUp() {
   MaterialRevisions materialRevisions = multipleModifications();
   stage =
       StageMother.withOneScheduledBuild("stage", "job-that-will-fail", "job-that-will-pass", 1);
   modifications = BuildCause.createWithModifications(materialRevisions, "");
   pipeline = new Pipeline("pipeline", PipelineLabel.COUNT_TEMPLATE, modifications, stage);
   stage.setIdentifier(new StageIdentifier(pipeline, stage));
   for (JobInstance job : stage.getJobInstances()) {
     job.setIdentifier(new JobIdentifier(pipeline, stage, job));
   }
   pipeline.setId(PIPELINE_ID);
   pipeline.updateCounter(9);
 }
 @Test
 public void shouldEncodeBuildLocator() throws Exception {
   JobInstance job = JobInstanceMother.assigned("job-%");
   Stage stage1 =
       new Stage(
           "stage-c%d",
           new JobInstances(job), GoConstants.DEFAULT_APPROVED_BY, "manual", new TimeProvider());
   stage1.setIdentifier(new StageIdentifier("pipeline-a%b", 1, "label-1", "stage-c%d", "1"));
   job.setIdentifier(
       new JobIdentifier("pipeline-a%b", 1, "label-1", "stage-c%d", "1", "job-%", 0L));
   StageJsonPresentationModel presenter =
       new StageJsonPresentationModel(pipeline, stage1, null, new Agents());
   Map json = presenter.toJson();
   assertThat(
       JsonUtils.from(json).getString("builds", 0, "buildLocator"),
       is("pipeline-a%25b/1/stage-c%25d/1/job-%25"));
 }