summaryrefslogtreecommitdiffstats
path: root/datarouter-node
diff options
context:
space:
mode:
authorConor Ward <conor.ward@est.tech>2019-03-29 08:32:20 +0000
committerGerrit Code Review <gerrit@onap.org>2019-03-29 08:32:20 +0000
commita26d139f31caa06ec932498574b18c69780dab28 (patch)
treea04fd8086a09d4ac7b09558526360a205104a081 /datarouter-node
parent4f7729e9c6205587fb68cdf3557f7011a9c25e79 (diff)
parent1b7ab42061005be89b50681e55e0f576ab290f86 (diff)
Merge "Adding ProvData unit tests"
Diffstat (limited to 'datarouter-node')
-rw-r--r--datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/ProvDataTest.java147
1 files changed, 147 insertions, 0 deletions
diff --git a/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/ProvDataTest.java b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/ProvDataTest.java
new file mode 100644
index 00000000..562167bc
--- /dev/null
+++ b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/ProvDataTest.java
@@ -0,0 +1,147 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.dmaap.datarouter.node;
+
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.nio.charset.StandardCharsets;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNull;
+
+@RunWith(PowerMockRunner.class)
+public class ProvDataTest {
+
+
+ @Test
+ public void Validate_Values_Are_Set_Correctly_Through_ProvData_Constuctor() throws Exception {
+ String InternalProvData =
+ "{" +
+ "\"ingress\":[{" +
+ "\"feedid\":1," +
+ "\"subnet\":\"\"," +
+ "\"user\":\"\"," +
+ "\"node\":\"node\"" +
+ "}]," +
+ "\"routing\":[{" +
+ "\"from\":\"172.10.10.10\"," +
+ "\"to\":\"172.10.10.12\"," +
+ "\"via\":\"172.10.10.11\"" +
+ "}]," +
+ "\"subscriptions\":[{" +
+ "\"subid\":1," +
+ "\"suspend\":false," +
+ "\"delivery\":{" +
+ "\"use100\":true," +
+ "\"password\":\"PASSWORD\"," +
+ "\"user\":\"LOGIN\"," +
+ "\"url\":\"http://172.18.0.2:7070\"" +
+ "}," +
+ "\"last_mod\":1553608460000," +
+ "\"subscriber\":\"PMMAPER\"," +
+ "\"feedid\":1," +
+ "\"decompress\":false," +
+ "\"groupid\":1," +
+ "\"metadataOnly\":false," +
+ "\"links\":{" +
+ "\"feed\":\"https://dmaap-dr-prov/feed/1\"" +
+ ",\"log\":\"https://dmaap-dr-prov/sublog/1\"" +
+ ",\"self\":\"https://dmaap-dr-prov/subs/1\"" +
+ "}," +
+ "\"created_date\":1553608460000," +
+ "\"privilegedSubscriber\":false" +
+ "}]," +
+ "\"feeds\":[{" +
+ "\"suspend\":false," +
+ "\"groupid\":0," +
+ "\"description\":\"Default feed\"," +
+ "\"version\":\"m1.0\"," +
+ "\"authorization\":{" +
+ "\"endpoint_addrs\":[\"172.10.10.20\"]," +
+ "\"classification\":\"unclassified\"," +
+ "\"endpoint_ids\":[{" +
+ "\"password\":\"password\"," +
+ "\"id\":\"user\"" +
+ "}]" +
+ "}," +
+ "\"last_mod\":1553608454000," +
+ "\"deleted\":false," +
+ "\"feedid\":1," +
+ "\"name\":\"CSIT_Test2\"" +
+ ",\"business_description\":\"Default Feed\"" +
+ ",\"publisher\":\"dradmin\"" +
+ ",\"links\":{" +
+ "\"subscribe\":\"https://dmaap-dr-prov/subscribe/1\"," +
+ "\"log\":\"https://dmaap-dr-prov/feedlog/1\"," +
+ "\"publish\":\"https://dmaap-dr-prov/publish/1\"," +
+ "\"self\":\"https://dmaap-dr-prov/feed/1\"" +
+ "}," +
+ "\"created_date\":1553608454000" +
+ "}]," +
+ "\"groups\":[]," +
+ "\"parameters\":{" +
+ "\"NODES\":[\"dmaap-dr-node\"]," +
+ "\"PROV_DOMAIN\":\"\"" +
+ "}," +
+ "\"egress\":{" +
+ "\"1\":1" +
+ "}" +
+ "}" ;
+ Reader r = new InputStreamReader(new ByteArrayInputStream(InternalProvData.getBytes(StandardCharsets.UTF_8)));
+ ProvData pd = new ProvData(r);
+
+ assertEquals(pd.getNodes().length, 1);
+ assertEquals(pd.getNodes()[0].getCName(), "dmaap-dr-node.");
+
+ assertEquals(pd.getFeedUsers().length, 1);
+ assertEquals(pd.getFeedUsers()[0].getUser(), "user");
+ assertEquals(pd.getFeedUsers()[0].getFeedId(), "1");
+ assertEquals(pd.getFeeds().length, 1);
+ assertEquals(pd.getFeeds()[0].getId(), "1");
+ assertEquals(pd.getFeedSubnets().length, 1);
+ assertEquals(pd.getFeedSubnets()[0].getFeedId(), "1");
+ assertEquals(pd.getFeedSubnets()[0].getCidr(), "172.10.10.20");
+ assertEquals(pd.getFeedSubnets()[0].getCidr(), "172.10.10.20");
+ assertEquals(pd.getSubscriptions()[0].getFeedId(), "1");
+ assertEquals(pd.getSubscriptions()[0].getSubId(), "1");
+ assertEquals(pd.getSubscriptions()[0].getAuthUser(), "LOGIN");
+ assertEquals(pd.getSubscriptions()[0].getURL(), "http://172.18.0.2:7070");
+ assertEquals(pd.getForceEgress().length, 1);
+ assertEquals(pd.getForceEgress()[0].getNode(), "1");
+ assertEquals(pd.getForceEgress()[0].getSubId(), "1");
+ assertEquals(pd.getForceIngress().length, 1);
+ assertEquals(pd.getForceIngress()[0].getFeedId(), "1");
+ assertNull(pd.getForceIngress()[0].getSubnet());
+ assertNull(pd.getForceIngress()[0].getUser());
+ assertEquals(pd.getHops().length, 1);
+ assertEquals(pd.getHops()[0].getFrom(), "172.10.10.10");
+ assertEquals(pd.getHops()[0].getTo(), "172.10.10.12");
+ assertEquals(pd.getHops()[0].getVia(), "172.10.10.11");
+ assertEquals(pd.getParams().length, 1);
+ assertEquals(pd.getParams()[0].getName(), "PROV_DOMAIN");
+ }
+}