aboutsummaryrefslogtreecommitdiffstats
path: root/testsuites/integration/integration-common/src/test/java
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@ericsson.com>2018-09-25 14:34:08 +0100
committerliamfallon <liam.fallon@ericsson.com>2018-09-25 14:36:11 +0100
commita122dde3b18f7c90098174be1c997d34d1f82853 (patch)
treebed64cb7b4887a36e41ae301c99c6316d2772e81 /testsuites/integration/integration-common/src/test/java
parentda9a362382e3229ddcaa86fd91ac695a1914ebef (diff)
JUnit for evaluation test model generator
Issue-ID: POLICY-1034 Change-Id: Ic8f9971d612dd5500c73f95e5cbbb786c5ad51f3 Signed-off-by: liamfallon <liam.fallon@ericsson.com>
Diffstat (limited to 'testsuites/integration/integration-common/src/test/java')
-rw-r--r--testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/model/EvalDomainModelFactoryTest.java45
-rw-r--r--testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/model/SampleDomainModelFactoryTest.java54
-rw-r--r--testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/model/SampleDomainModelSaverTest.java74
3 files changed, 173 insertions, 0 deletions
diff --git a/testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/model/EvalDomainModelFactoryTest.java b/testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/model/EvalDomainModelFactoryTest.java
new file mode 100644
index 000000000..5149c8675
--- /dev/null
+++ b/testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/model/EvalDomainModelFactoryTest.java
@@ -0,0 +1,45 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.testsuites.integration.common.model;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Test;
+import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
+
+/**
+ * Test the evaluation domain model factory.
+ */
+public class EvalDomainModelFactoryTest {
+
+ @Test
+ public void testEvalDomainModelFactory() {
+ EvalDomainModelFactory edmf = new EvalDomainModelFactory();
+ assertNotNull(edmf);
+
+ AxPolicyModel ecaPolicyModel = edmf.getEcaPolicyModel();
+ assertEquals("EvaluationPolicyModel_ECA:0.0.1", ecaPolicyModel.getId());
+
+ AxPolicyModel oodaPolicyModel = edmf.getOodaPolicyModel();
+ assertEquals("EvaluationPolicyModel_OODA:0.0.1", oodaPolicyModel.getId());
+ }
+}
diff --git a/testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/model/SampleDomainModelFactoryTest.java b/testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/model/SampleDomainModelFactoryTest.java
new file mode 100644
index 000000000..406bec11f
--- /dev/null
+++ b/testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/model/SampleDomainModelFactoryTest.java
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.testsuites.integration.common.model;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Test;
+import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
+
+/**
+ * Test the evaluation domain model factory.
+ */
+public class SampleDomainModelFactoryTest {
+
+ @Test
+ public void testSampleDomainModelFactory() {
+ SampleDomainModelFactory sdmf = new SampleDomainModelFactory();
+ assertNotNull(sdmf);
+
+ AxPolicyModel samplePolicyModel = sdmf.getSamplePolicyModel("JAVASCRIPT");
+ assertEquals("SamplePolicyModelJAVASCRIPT:0.0.1", samplePolicyModel.getId());
+
+ samplePolicyModel = sdmf.getSamplePolicyModel("JAVA");
+ assertEquals("SamplePolicyModelJAVA:0.0.1", samplePolicyModel.getId());
+
+ samplePolicyModel = sdmf.getSamplePolicyModel("JYTHON");
+ assertEquals("SamplePolicyModelJYTHON:0.0.1", samplePolicyModel.getId());
+
+ samplePolicyModel = sdmf.getSamplePolicyModel("JRUBY");
+ assertEquals("SamplePolicyModelJRUBY:0.0.1", samplePolicyModel.getId());
+
+ samplePolicyModel = sdmf.getSamplePolicyModel("MVEL");
+ assertEquals("SamplePolicyModelMVEL:0.0.1", samplePolicyModel.getId());
+ }
+}
diff --git a/testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/model/SampleDomainModelSaverTest.java b/testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/model/SampleDomainModelSaverTest.java
new file mode 100644
index 000000000..744f47db8
--- /dev/null
+++ b/testsuites/integration/integration-common/src/test/java/org/onap/policy/apex/testsuites/integration/common/model/SampleDomainModelSaverTest.java
@@ -0,0 +1,74 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.testsuites.integration.common.model;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Comparator;
+
+import org.junit.Test;
+
+/**
+ * Test the sample domain model saver.
+ */
+public class SampleDomainModelSaverTest {
+
+ @Test
+ public void testSampleDomainModelSaver() throws IOException {
+ try {
+ SampleDomainModelSaver.main(null);
+ fail("test should throw an exception");
+ } catch (Exception exc) {
+ assertEquals("java.lang.NullPointerException", exc.getClass().getCanonicalName());
+ }
+
+ String[] args0 =
+ { "two", "arguments" };
+
+ try {
+ SampleDomainModelSaver.main(args0);
+ } catch (Exception exc) {
+ fail("test should not throw an exception");
+ }
+
+ Path tempDirectory = Files.createTempDirectory("ApexModelTempDir");
+ String[] args1 =
+ { tempDirectory.toString() };
+
+ try {
+ SampleDomainModelSaver.main(args1);
+ } catch (Exception exc) {
+ fail("test should not throw an exception");
+ }
+
+ File tempDir = new File(tempDirectory.toString());
+ assertTrue(tempDir.isDirectory());
+ assertEquals(10, tempDir.listFiles().length);
+
+ Files.walk(tempDirectory).sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete);
+ }
+}