Update aai-parent in babel to 1.13.3
[aai/babel.git] / src / test / java / org / onap / aai / babel / util / ArtifactTestUtils.java
index 164c80b..2cf221d 100644 (file)
@@ -25,7 +25,7 @@ import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.not;
 import static org.hamcrest.CoreMatchers.nullValue;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -44,7 +44,6 @@ import org.apache.commons.io.IOUtils;
 import org.custommonkey.xmlunit.Diff;
 import org.onap.aai.babel.parser.ArtifactGeneratorToscaParser;
 import org.onap.aai.babel.xml.generator.data.Artifact;
-import org.onap.aai.babel.xml.generator.data.WidgetConfigurationUtil;
 import org.xml.sax.SAXException;
 
 /**
@@ -60,26 +59,13 @@ public class ArtifactTestUtils {
      * Initialize System Properties for test configuration files.
      */
     public void setGeneratorSystemProperties() {
-        System.setProperty(ArtifactGeneratorToscaParser.PROPERTY_ARTIFACT_GENERATOR_CONFIG_FILE,
-                getResourcePath(Resources.ARTIFACT_GENERATOR_CONFIG));
-
         System.setProperty(ArtifactGeneratorToscaParser.PROPERTY_TOSCA_MAPPING_FILE,
                 getResourcePath(Resources.TOSCA_MAPPING_CONFIG));
     }
 
-    /**
-     * Load the Widget to UUID mappings from the Artifact Generator Properties (resource).
-     *
-     * @throws IOException
-     *             if the properties file is not loaded
-     */
-    public void loadWidgetToUuidMappings() throws IOException {
-        WidgetConfigurationUtil.setConfig(getResourceAsProperties(Resources.ARTIFACT_GENERATOR_CONFIG));
-    }
-
     /**
      * Load the Widget type mappings (resource).
-     *
+     * 
      * @throws IOException
      *             if the configuration file is not loaded
      */
@@ -108,7 +94,7 @@ public class ArtifactTestUtils {
 
         for (Artifact artifact : toscaFiles) {
             String fileName = artifact.getName().replaceFirst("Definitions/", "ymlFiles/");
-            String expectedYaml = ymlMap.get(fileName);
+            String expectedYaml = ymlMap.get(fileName).replaceAll("\\r\\n?", "\n");
             assertThat("Missing expected content for " + fileName, expectedYaml, is(not(nullValue())));
             assertThat("The content of " + fileName + " must match the expected content",
                     convertToString(artifact.getPayload()).replaceAll("\\r\\n?", "\n"), is(equalTo(expectedYaml)));
@@ -141,7 +127,11 @@ public class ArtifactTestUtils {
     }
 
     public String loadResourceAsString(String resourceName) throws IOException {
-        return IOUtils.toString(getResource(resourceName), Charset.defaultCharset());
+        try {
+            return IOUtils.toString(getResource(resourceName), Charset.defaultCharset());
+        } catch (NullPointerException e) {
+            throw new IllegalArgumentException("No such resource " + resourceName);
+        }
     }
 
     public String getRequestJson(String resource) throws IOException {
@@ -158,7 +148,7 @@ public class ArtifactTestUtils {
 
     /**
      * 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