aboutsummaryrefslogtreecommitdiffstats
path: root/tools/model-generator/src/test/java
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@ericsson.com>2018-11-06 12:02:46 +0000
committerliamfallon <liam.fallon@ericsson.com>2018-11-07 12:41:09 +0000
commit53d8916cc60d97e2ce7ae345f8cc25f5602567da (patch)
treeee2f3a8e543c31993c51a58257354ccffb648dfe /tools/model-generator/src/test/java
parent9dc414a0cabc9074e87a7c9cd5c3e5ceee733e5a (diff)
Refactor unit test data
There were many copies of test policies and examples strewn through the Apex unit tests. This change cleans up the unit tests so that a single version of all example policies is used in all tests. Also added a new relative file root command line parameter to Apex to allow the root of relative paths in configuration files to be set. Apologies for the size of this review but unfortunately all of this must be done in one shot. Issue-ID: POLICY-1252 Change-Id: Ibbb18fbf18e3897a1c61301d0a65e62bc643a0e9 Signed-off-by: liamfallon <liam.fallon@ericsson.com>
Diffstat (limited to 'tools/model-generator/src/test/java')
-rw-r--r--tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/SchemaUtilsTest.java3
-rw-r--r--tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2CliTest.java18
2 files changed, 11 insertions, 10 deletions
diff --git a/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/SchemaUtilsTest.java b/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/SchemaUtilsTest.java
index 164f187cc..14ff284b9 100644
--- a/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/SchemaUtilsTest.java
+++ b/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/SchemaUtilsTest.java
@@ -68,7 +68,8 @@ public class SchemaUtilsTest {
*/
@BeforeClass
public static void readSimpleModel() throws IOException, ApexModelException {
- String avroModelString = TextFileUtils.getTextFileAsString("src/test/resources/models/AvroModel.json");
+ String avroModelString = TextFileUtils
+ .getTextFileAsString("target/examples/models/pcvs/vpnsla/PCVS-VpnSla.json");
final ApexModelReader<AxPolicyModel> modelReader = new ApexModelReader<>(AxPolicyModel.class);
avroModel = modelReader.read(new ByteArrayInputStream(avroModelString.getBytes()));
diff --git a/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2CliTest.java b/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2CliTest.java
index 170004e7c..aaff84eeb 100644
--- a/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2CliTest.java
+++ b/tools/model-generator/src/test/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2CliTest.java
@@ -102,37 +102,37 @@ public class Model2CliTest {
@Test
public void testModel2CliAvro() throws IOException {
- testModel2CliModel("AvroModel");
+ testModel2CliModel("target/examples/models/pcvs/vpnsla", "PCVS-VpnSla");
}
@Test
public void testModel2CliAadm() throws IOException {
- testModel2CliModel("AADMPolicyModel");
+ testModel2CliModel("target/examples/models/AADM", "AADMPolicyModel");
}
@Test
public void testModel2CliAnomaly() {
- testModel2CliModel("AnomalyDetectionPolicyModel");
+ testModel2CliModel("target/examples/models/Adaptive", "AnomalyDetectionPolicyModel");
}
@Test
public void testModel2CliAutoLearn() {
- testModel2CliModel("AutoLearnPolicyModel");
+ testModel2CliModel("target/examples/models/Adaptive", "AutoLearnPolicyModel");
}
@Test
public void testModel2CliJms() {
- testModel2CliModel("JMSSamplePolicyModel");
+ testModel2CliModel("target/examples/models/JMS", "JMSTestModel");
}
@Test
public void testModel2CliMfp() {
- testModel2CliModel("MyFirstPolicyModel");
+ testModel2CliModel("target/examples/models/MyFirstPolicy/2", "MyFirstPolicyModel");
}
@Test
public void testModel2CliSample() {
- testModel2CliModel("SamplePolicyModelJAVASCRIPT");
+ testModel2CliModel("target/examples/models/SampleDomain", "SamplePolicyModelJAVASCRIPT");
}
/**
@@ -158,13 +158,13 @@ public class Model2CliTest {
*
* @param modelName the name of the model file
*/
- private void testModel2CliModel(String modelName) {
+ private void testModel2CliModel(final String modelPath, final String modelName) {
try {
File tempFile = File.createTempFile(modelName, ".apex");
tempFile.deleteOnExit();
final String[] cliArgs =
- { "-m", "src/test/resources/models/" + modelName + ".json", "-o", tempFile.getCanonicalPath(), "-ow" };
+ { "-m", modelPath + "/" + modelName + ".json", "-o", tempFile.getCanonicalPath(), "-ow" };
runModel2Cli(cliArgs);
assertTrue(tempFile.isFile());