summaryrefslogtreecommitdiffstats
path: root/aai-core/src/test/java
diff options
context:
space:
mode:
authorThreefoot, Jane (jt6620) <jt6620@att.com>2017-07-31 15:49:04 -0400
committerThreefoot, Jane (jt6620) <jt6620@att.com>2017-07-31 15:52:53 -0400
commit9941d0d8597d9d69954819ca9458962aee281b10 (patch)
treec48876e6a16b10920259287fe3ec51436f94b864 /aai-core/src/test/java
parenta9320e7933bc04954264d9f3f34b9cb904b61353 (diff)
[AAI-100 Amsterdam] refactored dbedgerules
Change-Id: I778a56f525cba0ebd39d24d366fc9f0935be71f2 Signed-off-by: Threefoot, Jane (jt6620) <jt6620@att.com>
Diffstat (limited to 'aai-core/src/test/java')
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/dbmodel/DbEdgeRulesConverterTest.java90
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/serialization/db/EdgeRulesTest.java7
2 files changed, 96 insertions, 1 deletions
diff --git a/aai-core/src/test/java/org/openecomp/aai/dbmodel/DbEdgeRulesConverterTest.java b/aai-core/src/test/java/org/openecomp/aai/dbmodel/DbEdgeRulesConverterTest.java
new file mode 100644
index 00000000..1310a05b
--- /dev/null
+++ b/aai-core/src/test/java/org/openecomp/aai/dbmodel/DbEdgeRulesConverterTest.java
@@ -0,0 +1,90 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.openecomp.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.aai.dbmodel;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.util.Map.Entry;
+
+import org.apache.commons.io.FileUtils;
+import org.junit.Test;
+
+import com.google.common.collect.ImmutableSetMultimap;
+import com.google.common.collect.Multimap;
+
+import freemarker.template.TemplateException;
+
+public class DbEdgeRulesConverterTest {
+
+ @Test
+ public void testExtractData() {
+ Multimap<String, String> EdgeRules = new ImmutableSetMultimap.Builder<String, String>()
+ .putAll("availability-zone|complex",
+ "groupsResourcesIn,OUT,Many2Many,false,true,false,true").build();
+
+ DbEdgeRulesConverter dberConverter = new DbEdgeRulesConverter();
+
+ for (Entry<String, String> r : EdgeRules.entries()) {
+ EdgeRuleBean bean = dberConverter.extractData(r);
+ assertEquals("from availability-zone", "availability-zone", bean.getFrom());
+ assertEquals("to complex", "complex", bean.getTo());
+ assertEquals("label", "groupsResourcesIn", bean.getLabel());
+ assertEquals("direction", "OUT", bean.getDirection());
+ assertEquals("multiplicity", "Many2Many", bean.getMultiplicity());
+ assertEquals("isParent", "false", bean.getIsParent());
+ assertEquals("usesResource", "true", bean.getUsesResource());
+ assertEquals("hasDelTarget", "false", bean.getHasDelTarget());
+ assertEquals("SVC-INFRA", "true", bean.getSvcInfra());
+ }
+ }
+
+ @Test
+ public void testConvert(){
+ DbEdgeRulesConverter dberCon = new DbEdgeRulesConverter();
+ String dest = "src/test/resources/dbEdgeRulesConversion";
+ String outFile = dest + "/testOutput.json";
+
+ Multimap<String, String> EdgeRules = new ImmutableSetMultimap.Builder<String, String>()
+ .putAll("foo|bar",
+ "has,OUT,Many2Many,false,false,false,false")
+ .putAll("baz|quux",
+ "treatsVeryKindly,IN,One2One,true,true,true,true")
+ .build();
+
+ try {
+ dberCon.setup(dest);
+ File result = new File(outFile);
+ FileOutputStream writeStream = new FileOutputStream(result);
+ Writer writer = new OutputStreamWriter(writeStream);
+ dberCon.convert(EdgeRules, writer);
+ File compare = new File("src/test/resources/dbEdgeRulesConversion/conversionTestCompare.json");
+ assertTrue(FileUtils.contentEquals(result, compare));
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail("IOException on setup");
+ }
+ }
+}
diff --git a/aai-core/src/test/java/org/openecomp/aai/serialization/db/EdgeRulesTest.java b/aai-core/src/test/java/org/openecomp/aai/serialization/db/EdgeRulesTest.java
index 69f8642f..5e73e3bc 100644
--- a/aai-core/src/test/java/org/openecomp/aai/serialization/db/EdgeRulesTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/serialization/db/EdgeRulesTest.java
@@ -25,6 +25,7 @@ import static org.junit.Assert.assertEquals;
import java.util.Map;
import org.apache.tinkerpop.gremlin.structure.Direction;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.openecomp.aai.exceptions.AAIException;
@@ -32,7 +33,11 @@ import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
public class EdgeRulesTest {
-
+ @BeforeClass
+ public static void setup() {
+ System.setProperty("AJSC_HOME", ".");
+ System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
+ }
@Test