@Test public void shouldCreateGroupForCurrentConfigIfItHasChanged() throws Exception { PipelineHistoryGroups historyGroups = preparePipelineHistoryGroups(pipelineConfig); PipelineConfig newConfig = PipelineConfigMother.createPipelineConfigWithStages("mingle", "stage1", "stage2"); presenter = new PipelineHistoryJsonPresentationModel( pipelinePauseInfo, historyGroups, newConfig, pagination(), CAN_FORCE, hasForceBuildCause, hasModification, true); JsonTester jsonTester = new JsonTester(presenter.toJson()); jsonTester.shouldContain( "{ 'groups' : [ {" + " 'config' : {" + " 'stages' : [ " + " {'name' : 'stage1', isAutoApproved : 'true'}," + " {'name' : 'stage2', isAutoApproved : 'true'}" + " ]" + " }" + " }, {" + " 'config' : {" + " 'stages' : [ " + " {'name' : 'dev', isAutoApproved : 'true'}," + " {'name' : 'ft', isAutoApproved : 'false'}" + " ]" + " }" + " } ]" + "}"); }
@Test public void shouldEncodeStageLocator() { PipelineConfig pipelineConfig1 = PipelineConfigMother.createPipelineConfigWithStages("mingle-%", "stage1-%", "stage2"); PipelineHistoryJsonPresentationModel presenter = new PipelineHistoryJsonPresentationModel( pipelinePauseInfo, preparePipelineHistoryGroups(pipelineConfig1), pipelineConfig1, pagination(), CAN_FORCE, hasForceBuildCause, hasModification, true); JsonValue json = JsonUtils.from(presenter.toJson()); String stageLocator = json.getString("groups", 0, "history", 0, "stages", 0, "stageLocator"); assertThat(stageLocator, is("mingle-%25/1/stage1-%25/1")); }