summaryrefslogtreecommitdiffstats
path: root/sdnr/wt/netconfnode-state-service/provider/src/test
diff options
context:
space:
mode:
authorKAPIL SINGAL <ks220y@att.com>2020-02-02 00:26:27 +0000
committerGerrit Code Review <gerrit@onap.org>2020-02-02 00:26:27 +0000
commit1863844414cf3837fc429a3271b9f116f200f170 (patch)
tree83984698531a264e5741e2d6ba32368f4ff400e5 /sdnr/wt/netconfnode-state-service/provider/src/test
parentfb121a32b8b3431e37d2b73a63aac8055983f8f2 (diff)
parentcbbc3520048bbc539b137cac011776506b3e0f70 (diff)
Merge "SDN-R add updated app"
Diffstat (limited to 'sdnr/wt/netconfnode-state-service/provider/src/test')
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestAkkaConfig.java147
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestGeoConfig.java63
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestNetconfNodeStateService.java330
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/ClusterSingletonServiceProviderMock.java37
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/DataBrokerMountpointMock.java71
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/DataBrokerNetconfMock.java97
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/MountPointMock.java87
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/MountPointServiceMock.java54
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/NotificationPublishServiceMock.java45
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/RpcConsumerRegistryMock.java34
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/RpcProviderRegistryMock.java44
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/test/resources/captured-akka.conf72
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/test/resources/simplelogger.properties38
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/test/resources/test.properties55
14 files changed, 1174 insertions, 0 deletions
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestAkkaConfig.java b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestAkkaConfig.java
new file mode 100644
index 000000000..dd317c781
--- /dev/null
+++ b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestAkkaConfig.java
@@ -0,0 +1,147 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * ONAP : ccsdk feature sdnr wt
+ * ================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH 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.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.test;
+
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import org.junit.Test;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.conf.odlAkka.AkkaConfig;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.conf.odlAkka.ClusterConfig;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.conf.odlAkka.ClusterNodeInfo;
+
+public class TestAkkaConfig {
+
+ private static String getAkkaConfigSingleNodeText() {
+ return "\n" + "odl-cluster-data {\n" + " akka {\n" + " remote {\n" + " artery {\n"
+ + " enabled = off\n" + " canonical.hostname = \"127.0.0.1\"\n"
+ + " canonical.port = 2550\n" + " }\n" + " netty.tcp {\n"
+ + " hostname = \"127.0.0.1\"\n" + " port = 2550\n" + " }\n"
+ + " # when under load we might trip a false positive on the failure detector\n"
+ + " # transport-failure-detector {\n" + " # heartbeat-interval = 4 s\n"
+ + " # acceptable-heartbeat-pause = 16s\n" + " # }\n" + " }\n" + "\n" + " cluster {\n"
+ + " # Remove \".tcp\" when using artery.\n"
+ + " seed-nodes = [\"akka.tcp://opendaylight-cluster-data@127.0.0.1:2550\"]\n" + "\n"
+ + " roles = [\n" + " \"member-1\"\n" + " ]\n" + "\n" + " }\n" + "\n"
+ + " persistence {\n"
+ + " # By default the snapshots/journal directories live in KARAF_HOME. You can choose to put it somewhere else by\n"
+ + " # modifying the following two properties. The directory location specified may be a relative or absolute path. \n"
+ + " # The relative path is always relative to KARAF_HOME.\n" + "\n"
+ + " # snapshot-store.local.dir = \"target/snapshots\"\n"
+ + " # journal.leveldb.dir = \"target/journal\"\n" + "\n" + " journal {\n"
+ + " leveldb {\n" + " # Set native = off to use a Java-only implementation of leveldb.\n"
+ + " # Note that the Java-only version is not currently considered by Akka to be production quality.\n"
+ + "\n" + " # native = off\n" + " }\n" + " }\n" + " }\n" + " }\n" + "}";
+ }
+
+ private static String getAkkaConfigClusterNodeText() {
+ return "\n" + "odl-cluster-data {\n" + "\n" + " akka {\n" + " loglevel = \"\"\n" + " remote {\n"
+ + " netty.tcp {\n" + " hostname = \"zltcmtn23arbc01.2f0377.mtn23a.tci.att.com\"\n"
+ + " port = 2550\n" + " }\n" + " }\n" + " actor {\n" + " debug{\n"
+ + " autoreceive = on\n" + " lifecycle = on\n" + " unhandled = on\n"
+ + " fsm = on\n" + " event-stream = on\n" + " }\n" + " }\n" + " cluster {\n"
+ + " seed-nodes = [\"akka.tcp://opendaylight-cluster-data@zltcmtn23arbc01.2f0377.mtn23a.tci.att.com:2550\", \"akka.tcp://opendaylight-cluster-data@zltcmtn23arbc02.2f0377.mtn23a.tci.att.com:2550\", \"akka.tcp://opendaylight-cluster-data@zltcmtn23arbc03.2f0377.mtn23a.tci.att.com:2550\", \"akka.tcp://opendaylight-cluster-data@zltcmtn23brbc01.f84e7a.mtn23b.tci.att.com:2550\", \"akka.tcp://opendaylight-cluster-data@zltcmtn23brbc02.f84e7a.mtn23b.tci.att.com:2550\", \"akka.tcp://opendaylight-cluster-data@zltcmtn23brbc03.f84e7a.mtn23b.tci.att.com:2550\"]\n"
+ + " seed-node-timeout = 15s\n" + " roles = [\"member-1\"]\n" + "\n" + " }\n"
+ + " persistence {\n" + " journal-plugin-fallback {\n" + " circuit-breaker {\n"
+ + " max-failures = 10\n" + " call-timeout = 60s\n"
+ + " reset-timeout = 30s\n" + " }\n" + " }\n" + " }\n" + " }\n" + "}\n" + "\n"
+ + "odl-cluster-rpc {\n" + "\n" + " akka {\n" + " loglevel = \"\"\n" + " remote {\n"
+ + " netty.tcp {\n" + " hostname = \"zltcmtn23arbc01.2f0377.mtn23a.tci.att.com\"\n"
+ + " port = 2551\n" + " }\n" + " }\n" + " actor {\n" + " debug{\n"
+ + " autoreceive = on\n" + " lifecycle = on\n" + " unhandled = on\n"
+ + " fsm = on\n" + " event-stream = on\n" + " }\n" + " }\n" + " cluster {\n"
+ + " seed-nodes = [\"akka.tcp://odl-cluster-rpc@zltcmtn23arbc01.2f0377.mtn23a.tci.att.com:2551\", \"akka.tcp://odl-cluster-rpc@zltcmtn23arbc02.2f0377.mtn23a.tci.att.com:2551\", \"akka.tcp://odl-cluster-rpc@zltcmtn23arbc03.2f0377.mtn23a.tci.att.com:2551\", \"akka.tcp://odl-cluster-rpc@zltcmtn23brbc01.f84e7a.mtn23b.tci.att.com:2551\", \"akka.tcp://odl-cluster-rpc@zltcmtn23brbc02.f84e7a.mtn23b.tci.att.com:2551\", \"akka.tcp://odl-cluster-rpc@zltcmtn23brbc03.f84e7a.mtn23b.tci.att.com:2551\"]\n"
+ + " seed-node-timeout = 15s\n" + " }\n" + " persistence {\n"
+ + " journal-plugin-fallback {\n" + " circuit-breaker {\n" + " max-failures = 10\n"
+ + " call-timeout = 60s\n" + " reset-timeout = 30s\n" + " }\n" + " }\n"
+ + " }\n" + " }\n" + "}\n" + "\n" + "";
+ }
+
+ @Test
+ public void test1() {
+ AkkaConfig cfg;
+ try {
+ System.out.println("testing clusternode config1");
+ System.out.println("===========================");
+ cfg = AkkaConfig.parse(getAkkaConfigClusterNodeText());
+ System.out.println("succeeded: ");
+ System.out.println(cfg.toString());
+ System.out.println(String.format("found %d cluster nodes", cfg.getClusterConfig().getSeedNodes().size()));
+ for (ClusterNodeInfo n : cfg.getClusterConfig().getSeedNodes()) {
+ System.out.println(n.toString());
+ }
+ } catch (Exception e) {
+ String failMessage = "failed: " + e.getMessage();
+ System.out.println(failMessage);
+ fail(failMessage);
+ }
+ }
+
+ @Test
+ public void test2() {
+ AkkaConfig cfg;
+ try {
+ System.out.println("testing singlenode config1");
+ System.out.println("===========================");
+ cfg = AkkaConfig.parse(getAkkaConfigSingleNodeText());
+ System.out.println("succeeded: ");
+ System.out.println(cfg.toString());
+ } catch (Exception e) {
+ String failMessage = "failed: " + e.getMessage();
+ System.out.println(failMessage);
+ fail(failMessage);
+ }
+ }
+
+ @Test
+ public void test3() {
+ AkkaConfig cfg;
+
+ ClassLoader classLoader = getClass().getClassLoader();
+ File file = new File(classLoader.getResource("captured-akka.conf").getFile());
+ System.out.println(file.getAbsolutePath());
+
+ try {
+ System.out.println("testing clusternode config1");
+ System.out.println("===========================");
+ cfg = AkkaConfig.load(file.getAbsolutePath());
+ System.out.println("succeeded: "+cfg.hashCode());
+ System.out.println(cfg.toString());
+ System.out.println(String.format("found %d cluster nodes", cfg.getClusterConfig().getSeedNodes().size()));
+ for (ClusterNodeInfo n : cfg.getClusterConfig().getSeedNodes()) {
+ System.out.println(n.toString());
+ }
+ } catch (Exception e) {
+ String failMessage = "failed: " + e.getMessage();
+ System.out.println(failMessage);
+ fail(failMessage);
+ }
+ }
+
+ @Test
+ public void test4() {
+ ClusterConfig cc = ClusterConfig.defaultSingleNodeConfig();
+ cc.getClusterSeedNodeName();
+ cc.getRoleMemberIndex();
+ cc.isCluster();
+ cc.isMe(null);
+ }
+}
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestGeoConfig.java b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestGeoConfig.java
new file mode 100644
index 000000000..915c88d50
--- /dev/null
+++ b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestGeoConfig.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * ONAP : ccsdk feature sdnr wt
+ * ================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH 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.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.test;
+
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.conf.odlGeo.GeoConfig;
+
+public class TestGeoConfig {
+
+ @Test
+ public void test() {
+ GeoConfig config;
+ try {
+ System.out.println("testing clusternode geo config1");
+ System.out.println("===========================");
+ config = GeoConfig.parse(getClusterGeoConfigContent());
+ System.out.println("succeeded: ");
+ System.out.println(config.toString());
+ System.out.println("primary roles:");
+ System.out.println(config.getPrimaryRoles().toString());
+ System.out.println("secondary roles:");
+ System.out.println(config.getSecondaryRoles().toString());
+
+ } catch (Exception e) {
+ fail("failed: " + e.getMessage());
+ }
+ }
+
+
+
+ private static String getClusterGeoConfigContent() {
+ return "\n" + "lumina-geo-cluster {\n" + " primary_roles = [\n"
+ + " \"member-1\",\"member-2\",\"member-3\"\n" + " ]\n" + " secondary_roles = [\n"
+ + " \"member-4\",\"member-5\",\"member-6\"\n" + " ]\n" + " ip_roles_table = [\n" + "\n"
+ + " {\n" + "role=\"member-1\"\n" + "ip=\"zltcmtn23arbc01.2f0377.mtn23a.tci.att.com\"\n" + "},\n"
+ + "{\n" + "role=\"member-2\"\n" + "ip=\"zltcmtn23arbc02.2f0377.mtn23a.tci.att.com\"\n" + "},\n" + "{\n"
+ + "role=\"member-3\"\n" + "ip=\"zltcmtn23arbc03.2f0377.mtn23a.tci.att.com\"\n" + "},\n" + "{\n"
+ + "role=\"member-4\"\n" + "ip=\"zltcmtn23brbc01.f84e7a.mtn23b.tci.att.com\"\n" + "},\n" + "{\n"
+ + "role=\"member-5\"\n" + "ip=\"zltcmtn23brbc02.f84e7a.mtn23b.tci.att.com\"\n" + "},\n" + "{\n"
+ + "role=\"member-6\"\n" + "ip=\"zltcmtn23brbc03.f84e7a.mtn23b.tci.att.com\"\n" + "}\n" + " \n"
+ + " ]\n" + "}\n" + "\n" + "\n" + "\n" + "\n" + "";
+ }
+
+}
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestNetconfNodeStateService.java b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestNetconfNodeStateService.java
new file mode 100644
index 000000000..372d41225
--- /dev/null
+++ b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestNetconfNodeStateService.java
@@ -0,0 +1,330 @@
+/*******************************************************************************
+ * ============LICENSE_START======================================================= ONAP : ccsdk
+ * feature sdnr wt ================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH 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.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.test;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import com.google.common.util.concurrent.ListenableFuture;
+
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.times;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.concurrent.ExecutionException;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.IEntityDataProvider;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNodeConnectListener;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNodeStateListener;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.VesNotificationListener;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.GenericTransactionUtils;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.NetconfAccessorImpl;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.NetconfNodeStateServiceImpl;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.rpc.NetconfnodeStateServiceRpcApiImpl;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.test.mock.ClusterSingletonServiceProviderMock;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.test.mock.DataBrokerNetconfMock;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.test.mock.MountPointMock;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.test.mock.MountPointServiceMock;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.test.mock.NotificationPublishServiceMock;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.test.mock.RpcProviderRegistryMock;
+import org.opendaylight.mdsal.binding.api.DataObjectModification;
+import org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType;
+import org.opendaylight.mdsal.binding.api.DataTreeModification;
+import org.opendaylight.mdsal.binding.api.MountPointService;
+import org.opendaylight.mdsal.binding.api.NotificationPublishService;
+import org.opendaylight.mdsal.binding.api.RpcProviderService;
+import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeConnectionStatus.ConnectionStatus;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconfnode.state.rev191011.AttributeChangeNotification;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconfnode.state.rev191011.AttributeChangeNotificationBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconfnode.state.rev191011.FaultNotification;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconfnode.state.rev191011.FaultNotificationBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconfnode.state.rev191011.GetStatusInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconfnode.state.rev191011.GetStatusOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconfnode.state.rev191011.GetStatusOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconfnode.state.rev191011.PushAttributeChangeNotificationInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconfnode.state.rev191011.PushAttributeChangeNotificationOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconfnode.state.rev191011.PushFaultNotificationInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconfnode.state.rev191011.PushFaultNotificationOutput;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class TestNetconfNodeStateService {
+
+ private static Path KARAF_ETC = Paths.get("etc");
+ private static NetconfNodeStateServiceImpl netconfStateService;
+ private static MountPointMock mountPoint;
+ private static DataBrokerNetconfMock dataBrokerNetconf;
+
+ private static final Logger LOG = LoggerFactory.getLogger(TestNetconfNodeStateService.class);
+
+ @BeforeClass
+ public static void before() throws InterruptedException, IOException {
+
+ System.out.println("Logger: " + LOG.getClass().getName() + " " + LOG.getName());
+ // Call System property to get the classpath value
+ Path etc = KARAF_ETC;
+ delete(etc);
+
+ System.out.println("Create empty:" + etc.toString());
+ Files.createDirectories(etc);
+
+ // Create mocks
+ dataBrokerNetconf = new DataBrokerNetconfMock();
+ dataBrokerNetconf.newReadWriteTransaction();
+ mountPoint = new MountPointMock();
+ ClusterSingletonServiceProvider clusterSingletonService = new ClusterSingletonServiceProviderMock();
+ MountPointService mountPointService = new MountPointServiceMock(mountPoint);
+ NotificationPublishService notificationPublishService = new NotificationPublishServiceMock();
+ RpcProviderService rpcProviderRegistry = new RpcProviderRegistryMock();
+ IEntityDataProvider entityProviderMock = mock(IEntityDataProvider.class);
+
+ // start using blueprint interface
+ netconfStateService = new NetconfNodeStateServiceImpl();
+
+ netconfStateService.setDataBroker(dataBrokerNetconf);
+ netconfStateService.setMountPointService(mountPointService);
+ netconfStateService.setNotificationPublishService(notificationPublishService);
+ netconfStateService.setRpcProviderRegistry(rpcProviderRegistry);
+ netconfStateService.setClusterSingletonService(clusterSingletonService);
+ netconfStateService.setEntityDataProvider(entityProviderMock);
+ netconfStateService.init();
+ System.out.println("Initialization done");
+ }
+
+ @AfterClass
+ public static void after() throws InterruptedException, IOException {
+ System.out.println("Start shutdown");
+ // close using blueprint interface
+ netconfStateService.close();
+ delete(KARAF_ETC);
+
+ }
+
+ @Test
+ public void test1() {
+
+ System.out.println("Test1: Verify init state");
+ assertTrue("Devicemanager not initialized", netconfStateService.isInitializationSuccessful());
+ }
+
+
+ @Test
+ public void test2() {
+
+ System.out.println("Test2: Register state listener");
+
+ NetconfNodeStateListener nSL = mock(NetconfNodeStateListener.class);
+ ListenerRegistration<NetconfNodeStateListener> res =
+ netconfStateService.registerNetconfNodeStateListener(nSL);
+ assertNotNull("Result should be null", res);
+ res.getInstance();
+ res.close();
+ }
+
+ @Test
+ public void test3() {
+
+ System.out.println("Test3: Register connect listener");
+
+ NetconfNodeConnectListener nCL = mock(NetconfNodeConnectListener.class);
+ ListenerRegistration<NetconfNodeConnectListener> res =
+ netconfStateService.registerNetconfNodeConnectListener(nCL);
+ assertNotNull("Result should be null", res);
+ res.getInstance();
+ res.close();
+ }
+
+ @Test
+ public void test4() {
+ System.out.println("Test4: Get status listener");
+ GetStatusInputBuilder inputBuilder = new GetStatusInputBuilder();
+ GetStatusOutputBuilder res = netconfStateService.getStatus(inputBuilder.build());
+ assertNotNull("Result should be null", res);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void test5OnConnect() {
+ System.out.println("Test5: On Connect");
+ NetconfNodeBuilder netconfNodeBuilder = new NetconfNodeBuilder();
+ netconfNodeBuilder.setConnectionStatus(ConnectionStatus.Connected);
+ NetconfNode rootNodeNetconf = netconfNodeBuilder.build();
+
+ String nodeIdString = "Test";
+ NodeId nodeId = new NodeId(nodeIdString);
+ NodeBuilder nodeBuilder = new NodeBuilder();
+ nodeBuilder.addAugmentation(NetconfNode.class, rootNodeNetconf);
+ nodeBuilder.setNodeId(nodeId);
+ Node rootNode = nodeBuilder.build();
+ NetconfAccessor acessor = new NetconfAccessorImpl(nodeId, rootNodeNetconf, mountPoint.getDataBroker(),
+ mountPoint, new GenericTransactionUtils());
+
+ DataObjectModification<Node> dom = mock(DataObjectModification.class);
+ when(dom.getDataAfter()).thenReturn(rootNode);
+ when(dom.getModificationType()).thenReturn(ModificationType.WRITE);
+
+ DataTreeModification<Node> ntn = mock(DataTreeModification.class);
+ when(ntn.getRootNode()).thenReturn(dom);
+
+ NetconfNodeConnectListener nCL = mock(NetconfNodeConnectListener.class);
+ netconfStateService.registerNetconfNodeConnectListener(nCL);
+ mountPoint.setDatabrokerAbsent(false);
+
+ Collection<DataTreeModification<Node>> changes = Arrays.asList(ntn);
+ dataBrokerNetconf.sendClusteredChanges(changes);
+ dataBrokerNetconf.sendChanges(changes);
+
+ //verify that it was called one time and nodeId is the expected
+ ArgumentCaptor<NetconfAccessor> varArgs = ArgumentCaptor.forClass(NetconfAccessor.class);
+ verify(nCL).onEnterConnected(varArgs.capture());
+ System.out.println("Accessor "+varArgs.getValue().getNodeId());
+ assertEquals(nodeIdString, varArgs.getValue().getNodeId().getValue());
+
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void test6Update() {
+ System.out.println("Test6: OnChange");
+ NetconfNodeBuilder netconfNodeBuilder = new NetconfNodeBuilder();
+ netconfNodeBuilder.setConnectionStatus(ConnectionStatus.Connected);
+ NetconfNode rootNodeNetconf = netconfNodeBuilder.build();
+
+ NodeBuilder nodeBuilder = new NodeBuilder();
+ nodeBuilder.addAugmentation(NetconfNode.class, rootNodeNetconf);
+ nodeBuilder.setNodeId(new NodeId("Test"));
+ Node rootNodeAfter = nodeBuilder.build();
+
+ DataObjectModification<Node> dom = mock(DataObjectModification.class);
+ when(dom.getDataBefore()).thenReturn(rootNodeAfter);
+ when(dom.getDataAfter()).thenReturn(rootNodeAfter);
+ when(dom.getModificationType()).thenReturn(ModificationType.WRITE);
+
+ DataTreeModification<Node> ntn = mock(DataTreeModification.class);
+ when(ntn.getRootNode()).thenReturn(dom);
+
+ Collection<DataTreeModification<Node>> changes = Arrays.asList(ntn);
+ dataBrokerNetconf.sendClusteredChanges(changes);
+ dataBrokerNetconf.sendChanges(changes);
+ }
+
+ @Test
+ public void test7ApiStatus() throws InterruptedException, ExecutionException {
+
+ NetconfnodeStateServiceRpcApiImpl api = netconfStateService.getNetconfnodeStateServiceRpcApiImpl();
+
+ GetStatusInputBuilder statusInput = new GetStatusInputBuilder();
+ ListenableFuture<RpcResult<GetStatusOutput>> statusOutput = api.getStatus(statusInput.build());
+ RpcResult<GetStatusOutput> res = statusOutput.get();
+ GetStatusOutput output = res.getResult();
+ System.out.println("Output "+output);
+ }
+
+
+ @Test
+ public void test8ApiPushFault() throws InterruptedException, ExecutionException {
+
+ NetconfnodeStateServiceRpcApiImpl api = netconfStateService.getNetconfnodeStateServiceRpcApiImpl();
+
+ VesNotificationListener vNL = mock(VesNotificationListener.class);
+ ListenerRegistration<VesNotificationListener> registration = netconfStateService.registerVesNotifications(vNL);
+
+ FaultNotificationBuilder faultBuilder = new FaultNotificationBuilder();
+ faultBuilder.setProblem("problem1");
+ FaultNotification fault = faultBuilder.build();
+ PushFaultNotificationInputBuilder statusInput = new PushFaultNotificationInputBuilder();
+ statusInput.fieldsFrom(fault);
+ ListenableFuture<RpcResult<PushFaultNotificationOutput>> rpcOutput = api.pushFaultNotification(statusInput.build());
+ RpcResult<PushFaultNotificationOutput> res = rpcOutput.get();
+ PushFaultNotificationOutput output = res.getResult();
+
+ //verify that it was called one time
+ verify(vNL,times(1)).onNotification(fault);
+
+ registration.close();
+ System.out.println("Output "+output);
+ }
+
+ @Test
+ public void test9ApiPushNotifiction() throws InterruptedException, ExecutionException {
+
+ NetconfnodeStateServiceRpcApiImpl api = netconfStateService.getNetconfnodeStateServiceRpcApiImpl();
+
+ VesNotificationListener vNL = mock(VesNotificationListener.class);
+ ListenerRegistration<VesNotificationListener> registration = netconfStateService.registerVesNotifications(vNL);
+
+ AttributeChangeNotificationBuilder changeBuilder = new AttributeChangeNotificationBuilder();
+ changeBuilder.setAttributeName("attribute1");
+ AttributeChangeNotification change = changeBuilder.build();
+ PushAttributeChangeNotificationInputBuilder statusInput = new PushAttributeChangeNotificationInputBuilder();
+ statusInput.fieldsFrom(change);
+ ListenableFuture<RpcResult<PushAttributeChangeNotificationOutput>> rpcOutput = api.pushAttributeChangeNotification(statusInput.build());
+ RpcResult<PushAttributeChangeNotificationOutput> res = rpcOutput.get();
+ PushAttributeChangeNotificationOutput output = res.getResult();
+
+ //verify that it was called one time
+ verify(vNL,times(1)).onNotification(change);
+
+ registration.close();
+ System.out.println("Output "+output);
+ }
+
+
+ // ------- private section
+
+ private static void delete(Path etc) throws IOException {
+ if (Files.exists(etc)) {
+ System.out.println("Found and remove:" + etc.toString());
+ delete(etc.toFile());
+ }
+ }
+
+ private static void delete(File f) throws IOException {
+ if (f.isDirectory()) {
+ for (File c : f.listFiles()) {
+ delete(c);
+ }
+ }
+ if (!f.delete()) {
+ throw new FileNotFoundException("Failed to delete file: " + f);
+ }
+ }
+
+
+
+}
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/ClusterSingletonServiceProviderMock.java b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/ClusterSingletonServiceProviderMock.java
new file mode 100644
index 000000000..86340c052
--- /dev/null
+++ b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/ClusterSingletonServiceProviderMock.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH 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.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.test.mock;
+
+import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
+import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
+import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
+
+public class ClusterSingletonServiceProviderMock implements ClusterSingletonServiceProvider {
+
+ @Override
+ public void close() throws Exception {
+
+ }
+
+ @Override
+ public ClusterSingletonServiceRegistration registerClusterSingletonService(ClusterSingletonService service) {
+ return null;
+ }
+
+}
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/DataBrokerMountpointMock.java b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/DataBrokerMountpointMock.java
new file mode 100644
index 000000000..48401c881
--- /dev/null
+++ b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/DataBrokerMountpointMock.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * ONAP : ccsdk feature sdnr wt
+ * ================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH 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.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.test.mock;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.mdsal.binding.api.BindingService;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.DataTreeChangeListener;
+import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
+import org.opendaylight.mdsal.binding.api.ReadTransaction;
+import org.opendaylight.mdsal.binding.api.ReadWriteTransaction;
+import org.opendaylight.mdsal.binding.api.TransactionChain;
+import org.opendaylight.mdsal.binding.api.TransactionChainListener;
+import org.opendaylight.mdsal.binding.api.WriteTransaction;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+
+public class DataBrokerMountpointMock implements DataBroker, BindingService {
+
+ ReadTransaction readTransaction;
+
+ public void setReadOnlyTransaction(ReadTransaction readTransaction) {
+ this.readTransaction = readTransaction;
+ }
+
+ @Override
+ public @NonNull ReadTransaction newReadOnlyTransaction() {
+ return null;
+ }
+
+ @Override
+ public @NonNull ReadWriteTransaction newReadWriteTransaction() {
+ return null;
+ }
+
+ @Override
+ public @NonNull WriteTransaction newWriteOnlyTransaction() {
+ return null;
+ }
+
+ @Override
+ public <T extends DataObject, L extends DataTreeChangeListener<T>> @NonNull ListenerRegistration<L> registerDataTreeChangeListener(
+ @NonNull DataTreeIdentifier<T> treeId, @NonNull L listener) {
+ return null;
+ }
+
+ @Override
+ public @NonNull TransactionChain createTransactionChain(@NonNull TransactionChainListener listener) {
+ return null;
+ }
+
+
+}
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/DataBrokerNetconfMock.java b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/DataBrokerNetconfMock.java
new file mode 100644
index 000000000..90ab8608c
--- /dev/null
+++ b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/DataBrokerNetconfMock.java
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * ONAP : ccsdk feature sdnr wt
+ * ================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH 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.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.test.mock;
+
+import java.util.Collection;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.mdsal.binding.api.ClusteredDataTreeChangeListener;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.DataTreeChangeListener;
+import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
+import org.opendaylight.mdsal.binding.api.DataTreeModification;
+import org.opendaylight.mdsal.binding.api.ReadTransaction;
+import org.opendaylight.mdsal.binding.api.TransactionChain;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+
+public class DataBrokerNetconfMock implements DataBroker {
+
+ private @NonNull DataTreeChangeListener<Node> listener;
+ private @NonNull ClusteredDataTreeChangeListener<Node> listenerClustered;
+
+ @Override
+ public @NonNull ReadTransaction newReadOnlyTransaction() {
+ return null;
+ }
+
+ @Override
+ public org.opendaylight.mdsal.binding.api.@NonNull ReadWriteTransaction newReadWriteTransaction() {
+ return null;
+ }
+
+ @Override
+ public org.opendaylight.mdsal.binding.api.@NonNull WriteTransaction newWriteOnlyTransaction() {
+ return null;
+ }
+
+
+ @Override
+ public @NonNull TransactionChain createTransactionChain(
+ org.opendaylight.mdsal.binding.api.@NonNull TransactionChainListener listener) {
+ return null;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T extends DataObject, L extends DataTreeChangeListener<T>> @NonNull ListenerRegistration<L> registerDataTreeChangeListener(
+ @NonNull DataTreeIdentifier<T> treeId, @NonNull L pListener) {
+ System.out.println("Register "+pListener.getClass().getName());
+ if (pListener instanceof ClusteredDataTreeChangeListener) {
+ System.out.println("Clustered listener");
+ this.listenerClustered = (ClusteredDataTreeChangeListener<Node>) pListener;
+ } else if (pListener instanceof DataTreeChangeListener) {
+ System.out.println("Listener");
+ this.listener = (DataTreeChangeListener<Node>) pListener;
+ }
+ return new ListenerRegistration<L>() {
+
+ @Override
+ public @NonNull L getInstance() {
+ return pListener;
+ }
+
+ @Override
+ public void close() {
+ }
+
+ };
+ }
+
+ public void sendChanges(Collection<DataTreeModification<Node>> changes) {
+ this.listener.onDataTreeChanged(changes);
+ }
+
+ public void sendClusteredChanges(Collection<DataTreeModification<Node>> changes) {
+ this.listenerClustered.onDataTreeChanged(changes);
+ }
+
+}
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/MountPointMock.java b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/MountPointMock.java
new file mode 100644
index 000000000..e5bff451d
--- /dev/null
+++ b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/MountPointMock.java
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * ONAP : ccsdk feature sdnr wt sdnr-wt-devicemanager-provider
+ * ================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH 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.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.test.mock;
+
+import java.util.Optional;
+import org.opendaylight.mdsal.binding.api.BindingService;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.MountPoint;
+import org.opendaylight.mdsal.binding.api.NotificationService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.network.topology.topology.topology.types.TopologyNetconf;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+/**
+ * @author herbert
+ *
+ */
+public class MountPointMock implements MountPoint {
+
+ private boolean databrokerAbsent = true;
+ private final DataBrokerMountpointMock dataBroker = new DataBrokerMountpointMock();
+ private final RpcConsumerRegistryMock rpcConsumerRegistry = new RpcConsumerRegistryMock();
+ private NotificationService setReadTransaction;
+
+ private static final InstanceIdentifier<Topology> NETCONF_TOPO_IID =
+ InstanceIdentifier.create(NetworkTopology.class).child(Topology.class,
+ new TopologyKey(new TopologyId(TopologyNetconf.QNAME.getLocalName())));
+
+ @Override
+ public InstanceIdentifier<?> getIdentifier() {
+ return NETCONF_TOPO_IID;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T extends BindingService> Optional<T> getService(Class<T> service) {
+
+ System.out.println("Requested mountpoint service: "+service.getSimpleName()+" databrokerAbsent state: "+databrokerAbsent);
+
+ Optional<? extends BindingService> res;
+ if (service.isInstance(dataBroker)) {
+ System.out.println("Delivering databroker");
+ res = databrokerAbsent ? Optional.empty() : Optional.of(dataBroker);
+ } else if (service.isInstance(rpcConsumerRegistry)) {
+ System.out.println("Delivering RpcConsumerRegistryMock");
+ res = Optional.of(rpcConsumerRegistry);
+ } else if (service.isInstance(setReadTransaction)) {
+ System.out.println("Delivering notificationService");
+ res = Optional.of(setReadTransaction);
+ } else {
+ System.out.println("Delivering no service");
+ res = Optional.empty();
+ }
+ return (Optional<T>) res;
+ }
+
+ public void setDatabrokerAbsent( boolean state) {
+ this.databrokerAbsent = state;
+ }
+
+ public DataBroker getDataBroker() {
+ return dataBroker;
+ }
+
+}
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/MountPointServiceMock.java b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/MountPointServiceMock.java
new file mode 100644
index 000000000..127019633
--- /dev/null
+++ b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/MountPointServiceMock.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * ONAP : ccsdk feature sdnr wt
+ * ================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH 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.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.test.mock;
+
+import java.util.Optional;
+import org.opendaylight.mdsal.binding.api.MountPoint;
+import org.opendaylight.mdsal.binding.api.MountPointService;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+/**
+ * @author herbert
+ *
+ */
+public class MountPointServiceMock implements MountPointService {
+
+ private final MountPointMock mountpoint;
+
+ public MountPointServiceMock(MountPointMock mountpoint) {
+ this.mountpoint = mountpoint;
+ }
+
+ @Override
+ public Optional<MountPoint> getMountPoint(InstanceIdentifier<?> mountPoint) {
+
+ Optional<MountPoint> optional = Optional.of(mountpoint);
+ return optional;
+ }
+
+ @Override
+ public <T extends MountPointListener> ListenerRegistration<T> registerListener(InstanceIdentifier<?> path,
+ T listener) {
+ return null;
+ }
+
+}
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/NotificationPublishServiceMock.java b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/NotificationPublishServiceMock.java
new file mode 100644
index 000000000..0564c56a3
--- /dev/null
+++ b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/NotificationPublishServiceMock.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * ONAP : ccsdk feature sdnr wt
+ * ================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH 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.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.test.mock;
+
+import com.google.common.util.concurrent.ListenableFuture;
+import java.util.concurrent.TimeUnit;
+import org.opendaylight.mdsal.binding.api.NotificationPublishService;
+import org.opendaylight.yangtools.yang.binding.Notification;
+
+public class NotificationPublishServiceMock implements NotificationPublishService {
+
+ @Override
+ public ListenableFuture<?> offerNotification(Notification notification) {
+ return null;
+ }
+
+ @Override
+ public ListenableFuture<?> offerNotification(Notification notification, int timeout, TimeUnit unit)
+ throws InterruptedException {
+ return null;
+ }
+
+ @Override
+ public void putNotification(Notification notification) throws InterruptedException {
+ }
+
+}
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/RpcConsumerRegistryMock.java b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/RpcConsumerRegistryMock.java
new file mode 100644
index 000000000..7e48ff2e5
--- /dev/null
+++ b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/RpcConsumerRegistryMock.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * ONAP : ccsdk feature sdnr wt sdnr-wt-devicemanager-provider
+ * ================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH 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.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.test.mock;
+
+import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+
+public class RpcConsumerRegistryMock implements RpcConsumerRegistry {
+
+ @Override
+ public <T extends RpcService> T getRpcService(Class<T> serviceInterface) {
+ return null;
+ }
+
+}
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/RpcProviderRegistryMock.java b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/RpcProviderRegistryMock.java
new file mode 100644
index 000000000..fbcb21db9
--- /dev/null
+++ b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/RpcProviderRegistryMock.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * ONAP : ccsdk feature sdnr wt
+ * ================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH 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.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.test.mock;
+
+import java.util.Set;
+import org.opendaylight.mdsal.binding.api.RpcProviderService;
+import org.opendaylight.yangtools.concepts.ObjectRegistration;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+
+public class RpcProviderRegistryMock implements RpcProviderService {
+
+ @Override
+ public <S extends RpcService, T extends S> ObjectRegistration<T> registerRpcImplementation(Class<S> type,
+ T implementation) {
+ return null;
+ }
+
+ @Override
+ public <S extends RpcService, T extends S> ObjectRegistration<T> registerRpcImplementation(Class<S> type,
+ T implementation, Set<InstanceIdentifier<?>> paths) {
+ return null;
+ }
+
+
+}
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/test/resources/captured-akka.conf b/sdnr/wt/netconfnode-state-service/provider/src/test/resources/captured-akka.conf
new file mode 100644
index 000000000..8489f0905
--- /dev/null
+++ b/sdnr/wt/netconfnode-state-service/provider/src/test/resources/captured-akka.conf
@@ -0,0 +1,72 @@
+
+odl-cluster-data {
+
+ akka {
+ loglevel = ""
+ remote {
+ netty.tcp {
+ hostname = "zltcdyh1arbc02.2f0377.dyh1a.tci.att.com"
+ port = 2550
+ }
+ }
+ actor {
+ debug{
+ autoreceive = on
+ lifecycle = on
+ unhandled = on
+ fsm = on
+ event-stream = on
+ }
+ }
+ cluster {
+ seed-nodes = ["akka.tcp://opendaylight-cluster-data@zltcdyh1arbc01.2f0377.dyh1a.tci.att.com:2550", "akka.tcp://opendaylight-cluster-data@zltcdyh1arbc02.2f0377.dyh1a.tci.att.com:2550", "akka.tcp://opendaylight-cluster-data@zltcdyh1arbc03.2f0377.dyh1a.tci.att.com:2550", "akka.tcp://opendaylight-cluster-data@zltcdyh1brbc01.f84e7a.dyh1b.tci.att.com:2550", "akka.tcp://opendaylight-cluster-data@zltcdyh1brbc02.f84e7a.dyh1b.tci.att.com:2550", "akka.tcp://opendaylight-cluster-data@zltcdyh1brbc03.f84e7a.dyh1b.tci.att.com:2550"]
+ seed-node-timeout = 15s
+ roles = ["member-2"]
+
+ }
+ persistence {
+ journal-plugin-fallback {
+ circuit-breaker {
+ max-failures = 10
+ call-timeout = 60s
+ reset-timeout = 30s
+ }
+ }
+ }
+ }
+}
+
+odl-cluster-rpc {
+
+ akka {
+ loglevel = ""
+ remote {
+ netty.tcp {
+ hostname = "zltcdyh1arbc02.2f0377.dyh1a.tci.att.com"
+ port = 2551
+ }
+ }
+ actor {
+ debug{
+ autoreceive = on
+ lifecycle = on
+ unhandled = on
+ fsm = on
+ event-stream = on
+ }
+ }
+ cluster {
+ seed-nodes = ["akka.tcp://odl-cluster-rpc@zltcdyh1arbc01.2f0377.dyh1a.tci.att.com:2551", "akka.tcp://odl-cluster-rpc@zltcdyh1arbc02.2f0377.dyh1a.tci.att.com:2551", "akka.tcp://odl-cluster-rpc@zltcdyh1arbc03.2f0377.dyh1a.tci.att.com:2551", "akka.tcp://odl-cluster-rpc@zltcdyh1brbc01.f84e7a.dyh1b.tci.att.com:2551", "akka.tcp://odl-cluster-rpc@zltcdyh1brbc02.f84e7a.dyh1b.tci.att.com:2551", "akka.tcp://odl-cluster-rpc@zltcdyh1brbc03.f84e7a.dyh1b.tci.att.com:2551"]
+ seed-node-timeout = 15s
+ }
+ persistence {
+ journal-plugin-fallback {
+ circuit-breaker {
+ max-failures = 10
+ call-timeout = 60s
+ reset-timeout = 30s
+ }
+ }
+ }
+ }
+}
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/test/resources/simplelogger.properties b/sdnr/wt/netconfnode-state-service/provider/src/test/resources/simplelogger.properties
new file mode 100644
index 000000000..2eb3eb7b3
--- /dev/null
+++ b/sdnr/wt/netconfnode-state-service/provider/src/test/resources/simplelogger.properties
@@ -0,0 +1,38 @@
+# SLF4J's SimpleLogger configuration file
+# Simple implementation of Logger that sends all enabled log messages, for all defined loggers, to System.err.
+
+# Default logging detail level for all instances of SimpleLogger.
+# Must be one of ("trace", "debug", "info", "warn", or "error").
+# If not specified, defaults to "info".
+org.slf4j.simpleLogger.defaultLogLevel=info
+
+# Logging detail level for a SimpleLogger instance named "xxx.yyy.zzz".
+# Must be one of ("trace", "debug", "info", "warn", or "error").
+# If not specified, the default logging detail level is used.
+# org.slf4j.simpleLogger.log.xxx.yyy=debug
+org.slf4j.simpleLogger.log.org.onap.ccsdk.features.sdnr.wt.devicemanager=info
+org.slf4j.simpleLogger.log.org.onap.ccsdk.features.sdnr.wt.devicemanager.archiveservice=info
+org.slf4j.simpleLogger.log.org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.Resources=info
+org.slf4j.simpleLogger.log.org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container=info
+
+# Set to true if you want the current date and time to be included in output messages.
+# Default is false, and will output the number of milliseconds elapsed since startup.
+#org.slf4j.simpleLogger.showDateTime=false
+
+# The date and time format to be used in the output messages.
+# The pattern describing the date and time format is the same that is used in java.text.SimpleDateFormat.
+# If the format is not specified or is invalid, the default format is used.
+# The default format is yyyy-MM-dd HH:mm:ss:SSS Z.
+#org.slf4j.simpleLogger.dateTimeFormat=yyyy-MM-dd HH:mm:ss:SSS Z
+
+# Set to true if you want to output the current thread name.
+# Defaults to true.
+#org.slf4j.simpleLogger.showThreadName=true
+
+# Set to true if you want the Logger instance name to be included in output messages.
+# Defaults to true.
+#org.slf4j.simpleLogger.showLogName=true
+
+# Set to true if you want the last component of the name to be included in output messages.
+# Defaults to false.
+#org.slf4j.simpleLogger.showShortLogName=false
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/test/resources/test.properties b/sdnr/wt/netconfnode-state-service/provider/src/test/resources/test.properties
new file mode 100644
index 000000000..de49c5893
--- /dev/null
+++ b/sdnr/wt/netconfnode-state-service/provider/src/test/resources/test.properties
@@ -0,0 +1,55 @@
+[dcae]
+dcaeUserCredentials=admin:admin
+dcaeUrl=off
+dcaeHeartbeatPeriodSeconds=120
+dcaeTestCollector=no
+
+[aots]
+userPassword=passwd
+soapurladd=off
+soapaddtimeout=10
+soapinqtimeout=20
+userName=user
+inqtemplate=inqreq.tmpl.xml
+assignedto=userid
+addtemplate=addreq.tmpl.xml
+severitypassthrough=critical,major,minor,warning
+systemuser=user
+prt-offset=1200
+soapurlinq=off
+#smtpHost=
+#smtpPort=
+#smtpUsername=
+#smtpPassword=
+#smtpSender=
+#smtpReceivers=
+
+[es]
+esCluster=sendateodl5
+#time limit to keep increasing data in database [in seconds]
+#60*60*24*30 (30days)
+esArchiveLimit=2592000
+#folder where removed data will be stored
+esArchiveFolder=./backup
+#interval to archive database [in seconds]
+#60*60*24 (1day)
+esArchiveInterval=86400
+
+[aai]
+#keep comment
+aaiHeaders=["X-TransactionId: 9999"]
+aaiUrl=http://localhost:81
+aaiUserCredentials=AAI:AAI
+aaiDeleteOnMountpointRemove=false
+aaiTrustAllCerts=false
+aaiApiVersion=aai/v13
+aaiPropertiesFile=aaiclient.properties
+aaiApplicationId=SDNR
+aaiPcks12ClientCertFile=/opt/logs/externals/data/stores/keystore.client.p12
+aaiPcks12ClientCertPassphrase=adminadmin
+aaiClientConnectionTimeout=30000
+
+[pm]
+pmCluster=sendateodl5
+pmEnabled=true
+