* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017-2019 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2019 European Software Marketing Ltd.
+ * Copyright (c) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (c) 2017-2019 European Software Marketing Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
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;
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;
/**
*/
public class ArtifactTestUtils {
+ public static final String CSAR_INPUTS_FOLDER = "compressedArtifacts/";
private static final String JSON_REQUESTS_FOLDER = "jsonFiles/";
private static final String JSON_RESPONSES_FOLDER = "response/";
- private static final String CSAR_INPUTS_FOLDER = "compressedArtifacts/";
+ /**
+ * 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_GROUP_FILTERS_CONFIG_FILE,
- getResourcePath(Resources.FILTER_TYPES_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).
+ * Load the Widget type mappings (resource).
*
* @throws IOException
- * if the properties file is not loaded
+ * if the configuration file is not loaded
*/
- public void loadWidgetToUuidMappings() throws IOException {
- WidgetConfigurationUtil.setConfig(getResourceAsProperties(Resources.ARTIFACT_GENERATOR_CONFIG));
+ public void loadWidgetMappings() throws IOException {
+ ArtifactGeneratorToscaParser.initToscaMappingsConfiguration(getResourcePath(Resources.TOSCA_MAPPING_CONFIG));
}
/**
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)));
}
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 {
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);