@Test public void shouldRecognizeAndUpdateVersion() throws Exception { assertTargetVersion(readRootYaml("version_not_present").getJsonObject(), 1); assertTargetVersion(readRootYaml("version_1").getJsonObject(), 1); assertTargetVersion(readRootYaml("version_2").getJsonObject(), 2); }
@Test public void shouldPreserveOrderOfPipelines() throws IOException { MaterialTransform materialTransform = mock(MaterialTransform.class); StageTransform stageTransform = mock(StageTransform.class); EnvironmentVariablesTransform environmentTransform = mock(EnvironmentVariablesTransform.class); ParameterTransform parameterTransform = mock(ParameterTransform.class); pipelineTransform = new PipelineTransform(materialTransform, stageTransform, environmentTransform, parameterTransform); rootTransform = new RootTransform(pipelineTransform, environmentsTransform); JsonConfigCollection collection = readRootYaml("pipeline_order"); JsonArray pipelines = collection.getJsonObject().get("pipelines").getAsJsonArray(); assertThat(pipelines.get(0).getAsJsonObject().get("name").getAsString(), is("pipe1")); assertThat(pipelines.get(1).getAsJsonObject().get("name").getAsString(), is("pipe2")); assertThat(pipelines.get(2).getAsJsonObject().get("name").getAsString(), is("pipe3")); }
@Test public void shouldTransformRootWhen2PipelinesAnd2Environments() throws IOException { JsonConfigCollection collection = readRootYaml("2"); assertThat(collection.getJsonObject().get("environments").getAsJsonArray().size(), is(2)); assertThat(collection.getJsonObject().get("pipelines").getAsJsonArray().size(), is(2)); }
@Test public void shouldTransformRootWithCommonSection() throws IOException { JsonConfigCollection collection = readRootYaml("common_section"); assertThat(collection.getJsonObject().get("environments").getAsJsonArray().size(), is(1)); assertThat(collection.getJsonObject().get("pipelines").getAsJsonArray().size(), is(1)); }
@Test(expected = YamlReader.YamlReaderException.class) public void shouldNotTransformRootWhenYAMLHasDuplicateKeys() throws IOException { readRootYaml("duplicate.materials.pipe"); fail("should have thrown duplicate keys error"); }
@Test public void shouldTransformEmptyRoot() throws IOException { JsonConfigCollection empty = readRootYaml("empty"); assertThat(empty.getJsonObject().isJsonObject(), is(true)); assertThat(empty.getJsonObject().get("environments").isJsonArray(), is(true)); assertThat(empty.getJsonObject().get("pipelines").isJsonArray(), is(true)); assertThat(empty.getJsonObject().get("environments").getAsJsonArray().size(), is(0)); assertThat(empty.getJsonObject().get("pipelines").getAsJsonArray().size(), is(0)); }