@Test public void shouldEncodeStageLocator() throws Exception { Stage stage1 = new Stage( "stage-c%d", new JobInstances(), GoConstants.DEFAULT_APPROVED_BY, "manual", new TimeProvider()); stage1.setIdentifier(new StageIdentifier("pipeline-a%b", 1, "label-1", "stage-c%d", "1")); StageJsonPresentationModel presenter = new StageJsonPresentationModel(pipeline, stage1, null, new Agents()); Map json = presenter.toJson(); assertThat( JsonUtils.from(json).getString("stageLocator"), is("pipeline-a%25b/1/stage-c%25d/1")); }
@Test public void shouldReturnJsonWithModifications() throws Exception { StageJsonPresentationModel presenter = new StageJsonPresentationModel(pipeline, stage, null, new Agents()); Map json = presenter.toJson(); JsonValue jsonValue = JsonUtils.from(json); JsonValue revision = jsonValue.getObject("materialRevisions", 0); // TODO: TRAINWRECK! WE should fix this when we re-do the JSON. We don't think this test will // last long in the new UI String expected = modifications .getMaterialRevisions() .getMaterialRevision(0) .getModifications() .get(0) .getRevision(); assertThat(revision.getString("revision"), is(expected)); assertThat(revision.getString("user"), is(ModificationsMother.MOD_USER_WITH_HTML_CHAR)); assertThat( revision.getString("date"), is(DateUtils.formatISO8601(ModificationsMother.TODAY_CHECKIN))); }