private void testTransform(String caseFile, String expectedFile) throws IOException { JsonArray expected = (JsonArray) readJsonObject("parts/env_vars/" + expectedFile + ".json"); JsonArray actual = parser.transform(readYamlObject("parts/env_vars/" + caseFile + ".yaml")); assertThat(actual, is(expected)); }
private void testTransform(String caseFile, String expectedFile) throws IOException { JsonArray expected = (JsonArray) readJsonObject("parts/parameters/" + expectedFile + ".json"); JsonArray actual = paramterTransform.transform(readYamlObject("parts/parameters/" + caseFile + ".yaml")); assertThat(actual, is(expected)); }
private void testTransform(String caseFile, String expectedFile) throws IOException { JsonObject expectedObject = (JsonObject) readJsonObject("parts/materials/" + expectedFile + ".json"); JsonObject jsonObject = parser.transform(readYamlObject("parts/materials/" + caseFile + ".yaml")); assertThat(jsonObject, is(new JsonObjectMatcher(expectedObject))); }
private void testTransform(String caseFile, String expectedFile) throws IOException { JsonObject expectedObject = (JsonObject) readJsonObject("parts/stages/" + expectedFile + ".json"); JsonObject jsonObject = parser.transform(readYamlObject("parts/stages/" + caseFile + ".yaml")); assertThat(jsonObject, is(new JsonObjectMatcher(expectedObject))); }
private void testTransform(String caseFile, String expectedFile) throws IOException { JsonObject expectedObject = (JsonObject) readJsonObject("parts/" + expectedFile + ".json"); JsonObject jsonObject = parser.transform(readYamlObject("parts/" + caseFile + ".yaml")); assertThat(jsonObject, is(new JsonObjectMatcher(expectedObject))); }
private JsonObject testTransform(String caseFile, String expectedFile) throws IOException { JsonObject expectedObject = (JsonObject) readJsonObject("parts/tasks/" + expectedFile + ".json"); JsonObject jsonObject = parser.transform(readYamlObject("parts/tasks/" + caseFile + ".yaml")); assertThat(jsonObject, is(new JsonObjectMatcher(expectedObject))); return jsonObject; }
private JsonObject testTransform(String caseFile, String expectedFile) throws IOException { JsonObject expectedObject = (JsonObject) readJsonObject("parts/jobs/" + expectedFile + ".json"); JsonObject jsonObject = parser.transform(readYamlObject("parts/jobs/" + caseFile + ".yaml")); assertThat(jsonObject, is(new JsonObjectMatcher(expectedObject))); return jsonObject; }
private JsonObject testTransform(String caseFile, String expectedFile) throws IOException { JsonObject expectedObject = (JsonObject) readJsonObject("parts/environments/" + expectedFile + ".json"); JsonObject jsonObject = parser.transform(readYamlObject("parts/environments/" + caseFile + ".yaml")); assertThat(jsonObject, is(new JsonObjectMatcher(expectedObject))); return jsonObject; } }
@Test public void shouldRespondSuccessToParseDirectoryRequestWhenSimpleCaseFile() throws UnhandledRequestTypeException, IOException { GoPluginApiResponse response = parseAndGetResponseForDir(setupCase("simple")); assertThat(response.responseCode(), is(SUCCESS_RESPONSE_CODE)); JsonObject responseJsonObject = getJsonObjectFromResponse(response); assertNoError(responseJsonObject); JsonArray pipelines = responseJsonObject.get("pipelines").getAsJsonArray(); assertThat(pipelines.size(), is(1)); JsonObject expected = (JsonObject) readJsonObject("examples.out/simple.gocd.json"); assertThat(responseJsonObject, is(new JsonObjectMatcher(expected))); }
@Test public void shouldRespondSuccessToParseDirectoryRequestWhenAliasesCaseFile() throws UnhandledRequestTypeException, IOException { GoPluginApiResponse response = parseAndGetResponseForDir(setupCase("aliases")); assertThat(response.responseCode(), is(SUCCESS_RESPONSE_CODE)); JsonObject responseJsonObject = getJsonObjectFromResponse(response); assertNoError(responseJsonObject); JsonArray pipelines = responseJsonObject.get("pipelines").getAsJsonArray(); assertThat(pipelines.size(), is(1)); JsonObject expected = (JsonObject) readJsonObject("examples.out/aliases.gocd.json"); assertThat(responseJsonObject, is(new JsonObjectMatcher(expected))); }
@Test public void shouldRespondSuccessToParseDirectoryRequestWhenRichCaseFile() throws UnhandledRequestTypeException, IOException { GoPluginApiResponse response = parseAndGetResponseForDir(setupCase("rich")); assertThat(response.responseCode(), is(SUCCESS_RESPONSE_CODE)); JsonObject responseJsonObject = getJsonObjectFromResponse(response); assertNoError(responseJsonObject); JsonArray pipelines = responseJsonObject.get("pipelines").getAsJsonArray(); assertThat(pipelines.size(), is(1)); JsonObject expected = (JsonObject) readJsonObject("examples.out/rich.gocd.json"); assertThat(responseJsonObject, is(new JsonObjectMatcher(expected))); }
@Test public void respondsToParseContentRequest() throws Exception { final Gson gson = new Gson(); DefaultGoPluginApiRequest request = new DefaultGoPluginApiRequest("configrepo", "2.0", ConfigRepoMessages.REQ_PARSE_CONTENT); StringWriter w = new StringWriter(); IOUtils.copy(getResourceAsStream("examples/simple.gocd.yaml"), w); request.setRequestBody(gson.toJson( Collections.singletonMap("contents", Collections.singletonMap("simple.gocd.yaml", w.toString()) ) )); GoPluginApiResponse response = plugin.handle(request); assertEquals(SUCCESS_RESPONSE_CODE, response.responseCode()); JsonObject responseJsonObject = getJsonObjectFromResponse(response); assertNoError(responseJsonObject); JsonArray pipelines = responseJsonObject.get("pipelines").getAsJsonArray(); assertThat(pipelines.size(), is(1)); JsonObject expected = (JsonObject) readJsonObject("examples.out/simple.gocd.json"); assertThat(responseJsonObject, is(new JsonObjectMatcher(expected))); }
private void testInverseTransform(String caseFile, String expectedFile) throws IOException { Map<String, Object> actual = parser.inverseTransform(readJsonGson("parts/materials/" + caseFile + ".json")); JsonObject transform = parser.transform(actual); assertEquals((readJsonObject("parts/materials/" + expectedFile + ".json")), transform); } }
private void testInverseTransform(String caseFile, String expectedFile) throws IOException { Map<String, Object> inverse = paramterTransform.inverseTransform(readJsonArrayGson("parts/parameters/" + caseFile + ".json")); JsonArray actual = paramterTransform.transform(inverse); assertEquals((readJsonObject("parts/parameters/" + expectedFile + ".json")), actual); }
private void testInverseTransform(String caseFile, String expectedFile) throws IOException { Map<String, Object> inverse = parser.inverseTransform(readJsonGson("parts/stages/" + caseFile + ".json")); JsonObject actual = parser.transform(inverse); assertEquals((readJsonObject("parts/stages/" + expectedFile + ".json")), actual); } }
private void testInverseTransform(String caseFile, String expectedFile) throws IOException { Map<String, Object> inverse = parser.inverseTransform(readJsonGson("parts/tasks/" + caseFile + ".json")); JsonObject actual = parser.transform(inverse); assertEquals((readJsonObject("parts/tasks/" + expectedFile + ".json")), actual); } }