- private void compareXMLPayloads(List<Artifact> toscaFiles, Set<String> ymlPayloads) {
- for (Artifact artifact : toscaFiles) {
- boolean payloadFound = false;
- for (String ymlPayload : ymlPayloads) {
-
- if (compareXMLStrings(convertToString(artifact.getPayload()), ymlPayload)) {
- payloadFound = true;
- break;
- }
- }
- assertThat("The content of each yml file must match the actual content of the file extracted ("
- + artifact.getName() + ")", payloadFound, is(true));
- }
+ public String getRequestJson(String resource) throws IOException {
+ return loadResourceAsString(JSON_REQUESTS_FOLDER + resource);
+ }
+
+ public String getResponseJson(String jsonResponse) throws IOException, URISyntaxException {
+ return readstringFromFile(JSON_RESPONSES_FOLDER + jsonResponse);
+ }
+
+ public String readstringFromFile(String resourceFile) throws IOException, URISyntaxException {
+ return Files.lines(Paths.get(getResource(resourceFile).toURI())).collect(Collectors.joining());
+ }
+
+ /**
+ * Create Properties from the content of the named resource (e.g. a file on the classpath).
+ *
+ * @param resourceName
+ * the resource name
+ * @return Properties loaded from the named resource
+ * @throws IOException
+ * if an error occurred when reading from the named resource
+ */
+ public Properties getResourceAsProperties(String resourceName) throws IOException {
+ final Properties properties = new Properties();
+ InputStream in = ArtifactTestUtils.class.getClassLoader().getResourceAsStream(resourceName);
+ properties.load(in);
+ in.close();
+ return properties;
+ }
+
+ public String getResourcePath(String resourceName) {
+ return getResource(resourceName).getPath();