summaryrefslogtreecommitdiffstats
path: root/sdnr/wt/devicemanager/provider/src/test/java
diff options
context:
space:
mode:
authorherbert <herbert.eiselt@highstreet-technologies.com>2020-02-14 13:46:48 +0100
committerherbert <herbert.eiselt@highstreet-technologies.com>2020-02-14 13:47:15 +0100
commit9751ab7122a05e9ca10dde1348869f06899fa0cc (patch)
tree7da2573af7f7051fdb2c40d99dfcfcf782680e73 /sdnr/wt/devicemanager/provider/src/test/java
parentd0fc4329aa47fa3fdcc3a9f3af31e977ad21b979 (diff)
SDN-R code coverage
add unit test to devicemanager Issue-ID: SDNC-1071 Signed-off-by: herbert <herbert.eiselt@highstreet-technologies.com> Change-Id: I794a86defde37e62f555c4e34acaa499c21788ca
Diffstat (limited to 'sdnr/wt/devicemanager/provider/src/test/java')
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAai.java420
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAkkaConfig.java136
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDeviceMonitor.java71
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevicemanager.java207
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestGeoConfig.java63
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestMaintenanceTimeFilter.java29
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestToggleAlarmFilter.java (renamed from sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestNotification.java)5
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestXmlNotification.java90
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/ClusterSingletonServiceProviderMock.java37
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/DataBrokerMountpointMock.java77
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/DataBrokerNetconfMock.java76
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/DataProviderMock.java105
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/MountPointMock.java90
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/MountPointServiceMock.java54
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/NetconfNodeStateServiceMock.java71
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/NotificationPublishServiceMock.java49
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcConsumerRegistryMock.java39
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcProviderServiceMock.java (renamed from sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcProviderRegistryMock.java)12
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/util/DBCleanServiceHelper.java83
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/util/ZipFile.java63
20 files changed, 636 insertions, 1141 deletions
diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAai.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAai.java
index c1d24b4d1..69ac9e893 100644
--- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAai.java
+++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAai.java
@@ -20,6 +20,8 @@
******************************************************************************/
package org.onap.ccsdk.features.sdnr.wt.devicemanager.test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import com.google.common.io.Files;
@@ -36,7 +38,9 @@ import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.junit.After;
+import org.junit.AfterClass;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation;
import org.onap.ccsdk.features.sdnr.wt.common.util.ResourceFileLoader;
@@ -46,196 +50,228 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.InventoryInformationD
public class TestAai {
- private static final String CONFIGURATIONTESTFILE = "test.properties"; // for
- private static final String ENABLEDAAI_TESTCONFIG_FILENAME = "test2.properties";
- private static final File ENABLEDAAI_TESTCONFIG_FILE = new File(ENABLEDAAI_TESTCONFIG_FILENAME);
- private static final int AAI_SERVER_PORT=45454;
- private static final String TESTCONFIG_CONTENT="[dcae]\n" +
- "dcaeUserCredentials=admin:admin\n" +
- "dcaeUrl=off\n" +
- "dcaeHeartbeatPeriodSeconds=120\n" +
- "dcaeTestCollector=no\n" +
- "\n" +
- "[aots]\n" +
- "userPassword=passwd\n" +
- "soapurladd=off\n" +
- "soapaddtimeout=10\n" +
- "soapinqtimeout=20\n" +
- "userName=user\n" +
- "inqtemplate=inqreq.tmpl.xml\n" +
- "assignedto=userid\n" +
- "addtemplate=addreq.tmpl.xml\n" +
- "severitypassthrough=critical,major,minor,warning\n" +
- "systemuser=user\n" +
- "prt-offset=1200\n" +
- "soapurlinq=off\n" +
- "#smtpHost=\n" +
- "#smtpPort=\n" +
- "#smtpUsername=\n" +
- "#smtpPassword=\n" +
- "#smtpSender=\n" +
- "#smtpReceivers=\n" +
- "\n" +
- "[es]\n" +
- "esCluster=sendateodl5\n" +
- "\n" +
- "[aai]\n" +
- "#keep comment\n" +
- "aaiHeaders=[\"X-TransactionId: 9999\"]\n" +
- "aaiUrl=http://localhost:"+AAI_SERVER_PORT+"\n" +
- "aaiUserCredentials=AAI:AAI\n" +
- "aaiDeleteOnMountpointRemove=true\n" +
- "aaiTrustAllCerts=false\n" +
- "aaiApiVersion=aai/v13\n" +
- "aaiPropertiesFile=aaiclient.properties\n" +
- "aaiApplicationId=SDNR\n" +
- "aaiPcks12ClientCertFile=/opt/logs/externals/data/stores/keystore.client.p12\n" +
- "aaiPcks12ClientCertPassphrase=adminadmin\n" +
- "aaiClientConnectionTimeout=30000\n" +
- "\n" +
- "[pm]\n" +
- "pmCluster=sendateodl5\n" +
- "pmEnabled=true\n" +
- "\n" +
- "";
- private HttpServer server;
- private ExecutorService httpThreadPool;
- private ConfigurationFileRepresentation globalCfg;
-
- @Test
- public void test() {
-
- String testConfigurationFileName = ResourceFileLoader.getFile(this, CONFIGURATIONTESTFILE).getAbsolutePath();
- ConfigurationFileRepresentation cfg=new ConfigurationFileRepresentation(testConfigurationFileName);
-
- AaiProviderClient provider = new AaiProviderClient(cfg, null);
-
- String mountPointName = "testDevice 01";
- String type="Unit";
- String model="Horizon Compact+";
- String vendor="DragonWave-X";
- String ipv4="127.0.0.1";
- String ipv6="::1";
- List<String> ifInfos = new ArrayList<>();
- ifInfos.add("LP-MWPS-RADIO");
- InventoryInformationDcae ii=new InventoryInformationDcae(type, model, vendor, ipv4, ipv6, ifInfos);
- System.out.println("registering device");
- provider.onDeviceRegistered(mountPointName,ii);
- try {
- Thread.sleep(5000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- System.out.println("unregistering device");
- provider.onDeviceUnregistered(mountPointName);
- System.out.println("finished");
- try {
- provider.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- @Test
- public void test2() {
- try {
- Thread.sleep(3000);
- } catch (InterruptedException e1) {
- e1.printStackTrace();
- }
- AaiProviderClient provider = new AaiProviderClient(globalCfg, null);
-
- String mountPointName = "testDevice 01";
- String type="Unit";
- String model="Horizon Compact+";
- String vendor="DragonWave-X";
- String ipv4="127.0.0.1";
- String ipv6="::1";
- List<String> ifInfos = new ArrayList<>();
- ifInfos.add("LP-MWPS-RADIO");
- InventoryInformationDcae ii=new InventoryInformationDcae(type, model, vendor, ipv4, ipv6, ifInfos);
- System.out.println("registering device");
- provider.onDeviceRegistered(mountPointName);
- provider.onDeviceRegistered(mountPointName,ii);
- try {
- Thread.sleep(5000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- System.out.println("unregistering device");
- provider.onDeviceUnregistered(mountPointName);
- System.out.println("finished");
- try {
- provider.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- @Before
- public void initAaiTestWebserver() throws IOException {
- try {
- Files.asCharSink(ENABLEDAAI_TESTCONFIG_FILE, StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT);
- } catch (IOException e1) {
- fail(e1.getMessage());
- }
- //globalCfg=HtDevicemanagerConfiguration.getTestConfiguration(ENABLEDAAI_TESTCONFIG_FILENAME,true);
- globalCfg = new ConfigurationFileRepresentation(ENABLEDAAI_TESTCONFIG_FILENAME);
- this.server = HttpServer.create(new InetSocketAddress(AAI_SERVER_PORT), 0);
- this.httpThreadPool = Executors.newFixedThreadPool(5);
- this.server.setExecutor(this.httpThreadPool);
- AaiConfig config = new AaiConfig(globalCfg);
- this.server.createContext(config.getBaseUri(), new MyHandler());
- //server.createContext("/", new MyRootHandler());
- this.server.setExecutor(null); // creates a default executor
- this.server.start();
- System.out.println("http server started");
- }
-
- @After
- public void stopTestWebserver() {
- if (this.server != null) {
- this.server.stop(0);
- this.httpThreadPool.shutdownNow();
- System.out.println("http server stopped" );
- }
- if (ENABLEDAAI_TESTCONFIG_FILE.exists()) {
- ENABLEDAAI_TESTCONFIG_FILE.delete();
- }
-
- }
- static class MyHandler implements HttpHandler {
- @Override
- public void handle(HttpExchange t) throws IOException {
- String method = t.getRequestMethod();
- System.out.println("req method: " + method);
- OutputStream os = null;
- try {
- String res="";
- if (method.equals("GET")) {
- t.sendResponseHeaders(404,res.length() );
- os = t.getResponseBody();
- os.write(res.getBytes());
- } else if (method.equals("DELETE")) {
- t.sendResponseHeaders(200, res.length());
- os = t.getResponseBody();
- os.write(res.getBytes());
- } else if (method.equals("PUT")) {
- t.sendResponseHeaders(200, res.length());
- os = t.getResponseBody();
- os.write(res.getBytes());
- } else {
- t.sendResponseHeaders(404, 0);
- }
- System.out.println("req handled successful");
-
- } catch (Exception e) {
- System.out.println(e.getMessage());
- }
- finally {
- if (os != null)
- {
- os.close();
- }
- }
- }
- }
+ private static final String CONFIGURATIONTESTFILE = "test.properties"; // for
+ private static final String ENABLEDAAI_TESTCONFIG_FILENAME = "test2.properties";
+ private static final File ENABLEDAAI_TESTCONFIG_FILE = new File(ENABLEDAAI_TESTCONFIG_FILENAME);
+ private static final int AAI_SERVER_PORT = 45454;
+ private static final String TESTCONFIG_CONTENT = "[dcae]\n" + "dcaeUserCredentials=admin:admin\n" + "dcaeUrl=off\n"
+ + "dcaeHeartbeatPeriodSeconds=120\n" + "dcaeTestCollector=no\n" + "\n" + "[aots]\n"
+ + "userPassword=passwd\n" + "soapurladd=off\n" + "soapaddtimeout=10\n" + "soapinqtimeout=20\n"
+ + "userName=user\n" + "inqtemplate=inqreq.tmpl.xml\n" + "assignedto=userid\n"
+ + "addtemplate=addreq.tmpl.xml\n" + "severitypassthrough=critical,major,minor,warning\n"
+ + "systemuser=user\n" + "prt-offset=1200\n" + "soapurlinq=off\n" + "#smtpHost=\n" + "#smtpPort=\n"
+ + "#smtpUsername=\n" + "#smtpPassword=\n" + "#smtpSender=\n" + "#smtpReceivers=\n" + "\n" + "[es]\n"
+ + "esCluster=sendateodl5\n" + "\n" + "[aai]\n" + "#keep comment\n"
+ + "aaiHeaders=[\"X-TransactionId: 9999\"]\n" + "aaiUrl=http://localhost:" + AAI_SERVER_PORT + "\n"
+ + "aaiUserCredentials=AAI:AAI\n" + "aaiDeleteOnMountpointRemove=true\n" + "aaiTrustAllCerts=false\n"
+ + "aaiApiVersion=aai/v13\n" + "aaiPropertiesFile=aaiclient.properties\n" + "aaiApplicationId=SDNR\n"
+ + "aaiPcks12ClientCertFile=/opt/logs/externals/data/stores/keystore.client.p12\n"
+ + "aaiPcks12ClientCertPassphrase=adminadmin\n" + "aaiClientConnectionTimeout=30000\n" + "\n" + "[pm]\n"
+ + "pmCluster=sendateodl5\n" + "pmEnabled=true\n" + "\n" + "";
+
+ private static final String EXT_TEST_URL="https://testaai.onap.org:8443";
+ private static final String EXT_TEST_KEY="test.key";
+ private static final String EXT_TEST_PASSWD="test123";
+ private static final String EXT_TEST_APPLICATIONID="SDNC";
+ private static final long EXT_TEST_CONN_TIMEOUT=6000;
+
+
+ private static final CharSequence TESTCONFIG_CONTENT_EXT = "[aai]\n" + "#keep comment\n"
+ + "aaiHeaders=[\"X-TransactionId: 9999\"]\n" + "aaiUrl=http://localhost:" + AAI_SERVER_PORT + "\n"
+ + "aaiUserCredentials=AAI:AAI\n" + "aaiDeleteOnMountpointRemove=true\n" + "aaiTrustAllCerts=false\n"
+ + "aaiApiVersion=aai/v13\n" + "aaiPropertiesFile=aaiclient.properties\n" +
+ // "aaiApplicationId=SDNR\n" +
+ // "aaiPcks12ClientCertFile=/opt/logs/externals/data/stores/keystore.client.p12\n" +
+ // "aaiPcks12ClientCertPassphrase=adminadmin\n" +
+ // "aaiClientConnectionTimeout=30000\n" +
+ "\n";
+ private static final CharSequence TESTCONFIG_CONTENT_EXT2 = "org.onap.ccsdk.sli.adaptors.aai.ssl.key="+EXT_TEST_KEY+"\n"
+ + "org.onap.ccsdk.sli.adaptors.aai.ssl.key.psswd="+EXT_TEST_PASSWD+"\n"
+ + "org.onap.ccsdk.sli.adaptors.aai.host.certificate.ignore=false\n"
+ + "org.onap.ccsdk.sli.adaptors.aai.application="+EXT_TEST_APPLICATIONID+"\n"
+ + "org.onap.ccsdk.sli.adaptors.aai.uri="+EXT_TEST_URL+"\n"
+ + "connection.timeout="+EXT_TEST_CONN_TIMEOUT+"\n";
+ private static HttpServer server;
+ private static ExecutorService httpThreadPool;
+ private static ConfigurationFileRepresentation globalCfg;
+
+ @Test
+ public void test() {
+
+ String testConfigurationFileName = ResourceFileLoader.getFile(this, CONFIGURATIONTESTFILE).getAbsolutePath();
+ ConfigurationFileRepresentation cfg = new ConfigurationFileRepresentation(testConfigurationFileName);
+
+ AaiProviderClient provider = new AaiProviderClient(cfg, null);
+
+ String mountPointName = "testDevice 01";
+ String type = "Unit";
+ String model = "Horizon Compact+";
+ String vendor = "DragonWave-X";
+ String ipv4 = "127.0.0.1";
+ String ipv6 = "::1";
+ List<String> ifInfos = new ArrayList<>();
+ ifInfos.add("LP-MWPS-RADIO");
+ InventoryInformationDcae ii = new InventoryInformationDcae(type, model, vendor, ipv4, ipv6, ifInfos);
+ System.out.println("registering device");
+ provider.onDeviceRegistered(mountPointName, ii);
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ System.out.println("unregistering device");
+ provider.onDeviceUnregistered(mountPointName);
+ System.out.println("finished");
+ try {
+ provider.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void test2() {
+ try {
+ Thread.sleep(3000);
+ } catch (InterruptedException e1) {
+ e1.printStackTrace();
+ }
+ AaiProviderClient provider = new AaiProviderClient(globalCfg, null);
+
+ String mountPointName = "testDevice 01";
+ String type = "Unit";
+ String model = "Horizon Compact+";
+ String vendor = "DragonWave-X";
+ String ipv4 = "127.0.0.1";
+ String ipv6 = "::1";
+ List<String> ifInfos = new ArrayList<>();
+ ifInfos.add("LP-MWPS-RADIO");
+ InventoryInformationDcae ii = new InventoryInformationDcae(type, model, vendor, ipv4, ipv6, ifInfos);
+ System.out.println("registering device");
+ provider.onDeviceRegistered(mountPointName);
+ provider.onDeviceRegistered(mountPointName, ii);
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ System.out.println("unregistering device");
+ provider.onDeviceUnregistered(mountPointName);
+ System.out.println("finished");
+ try {
+ provider.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testExtendedProperties() {
+ File testConfigurationFileName = new File("abbsads.properties");
+ File extfile = new File("aaiclient.properties");
+ if (testConfigurationFileName.exists()) {
+ testConfigurationFileName.delete();
+ }
+ if (extfile.exists()) {
+ extfile.delete();
+ }
+ try {
+ Files.asCharSink(testConfigurationFileName, StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT_EXT);
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail("problem writing a test config file: " + e.getMessage());
+ }
+ try {
+ Files.asCharSink(extfile, StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT_EXT2);
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail("problem writing a second test config file: " + e.getMessage());
+ }
+
+ ConfigurationFileRepresentation cfg = new ConfigurationFileRepresentation(testConfigurationFileName);
+ AaiConfig config = new AaiConfig(cfg);
+ System.out.println(config.toString());
+
+ assertTrue(config.getBaseUrl().startsWith(EXT_TEST_URL));
+ assertEquals(EXT_TEST_KEY,config.getPcks12CertificateFilename());
+ assertEquals(EXT_TEST_PASSWD,config.getPcks12CertificatePassphrase());
+ assertEquals(EXT_TEST_APPLICATIONID,config.getHeaders().get("X-FromAppId"));
+ assertEquals(EXT_TEST_CONN_TIMEOUT,config.getConnectionTimeout());
+
+ if (testConfigurationFileName.exists()) {
+ testConfigurationFileName.delete();
+ }
+ if (extfile.exists()) {
+ extfile.delete();
+ }
+
+ }
+
+ @BeforeClass
+ public static void initAaiTestWebserver() throws IOException {
+ try {
+ Files.asCharSink(ENABLEDAAI_TESTCONFIG_FILE, StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT);
+ } catch (IOException e1) {
+ fail(e1.getMessage());
+ }
+ //globalCfg=HtDevicemanagerConfiguration.getTestConfiguration(ENABLEDAAI_TESTCONFIG_FILENAME,true);
+ globalCfg = new ConfigurationFileRepresentation(ENABLEDAAI_TESTCONFIG_FILENAME);
+ server = HttpServer.create(new InetSocketAddress(AAI_SERVER_PORT), 0);
+ httpThreadPool = Executors.newFixedThreadPool(5);
+ server.setExecutor(httpThreadPool);
+ AaiConfig config = new AaiConfig(globalCfg);
+ server.createContext(config.getBaseUri(), new MyHandler());
+ //server.createContext("/", new MyRootHandler());
+ server.setExecutor(null); // creates a default executor
+ server.start();
+ System.out.println("http server started");
+ }
+
+ @AfterClass
+ public static void stopTestWebserver() {
+ if (server != null) {
+ server.stop(0);
+ httpThreadPool.shutdownNow();
+ System.out.println("http server stopped");
+ }
+ if (ENABLEDAAI_TESTCONFIG_FILE.exists()) {
+ ENABLEDAAI_TESTCONFIG_FILE.delete();
+ }
+
+ }
+
+ static class MyHandler implements HttpHandler {
+ @Override
+ public void handle(HttpExchange t) throws IOException {
+ String method = t.getRequestMethod();
+ System.out.println("req method: " + method);
+ OutputStream os = null;
+ try {
+ String res = "";
+ if (method.equals("GET")) {
+ t.sendResponseHeaders(404, res.length());
+ os = t.getResponseBody();
+ os.write(res.getBytes());
+ } else if (method.equals("DELETE")) {
+ t.sendResponseHeaders(200, res.length());
+ os = t.getResponseBody();
+ os.write(res.getBytes());
+ } else if (method.equals("PUT")) {
+ t.sendResponseHeaders(200, res.length());
+ os = t.getResponseBody();
+ os.write(res.getBytes());
+ } else {
+ t.sendResponseHeaders(404, 0);
+ }
+ System.out.println("req handled successful");
+
+ } catch (Exception e) {
+ System.out.println(e.getMessage());
+ } finally {
+ if (os != null) {
+ os.close();
+ }
+ }
+ }
+ }
}
diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAkkaConfig.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAkkaConfig.java
deleted file mode 100644
index 7bc30550f..000000000
--- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAkkaConfig.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*******************************************************************************
- * ============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.devicemanager.test;
-
-import static org.junit.Assert.fail;
-import java.io.File;
-import org.junit.Test;
-import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.conf.odlAkka.AkkaConfig;
-import org.onap.ccsdk.features.sdnr.wt.devicemanager.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);
- }
- }
-}
diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDeviceMonitor.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDeviceMonitor.java
new file mode 100644
index 000000000..7fb417838
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDeviceMonitor.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.devicemanager.test;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.devicemonitor.impl.DeviceMonitorImpl;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.eventdatahandler.ODLEventListenerHandler;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+
+public class TestDeviceMonitor extends Mockito {
+
+ private static final String CONFIGURATIONTESTFILE = "test.properties"; // for
+ private static final String mountPointNodeName = "TestMountpoint";
+
+ private static DeviceMonitorImpl deviceMonitor;
+
+ @BeforeClass
+ public static void before() {
+
+ DataBroker dataBroker = mock(DataBroker.class);
+ ODLEventListenerHandler odlEventListenerHandler = mock(ODLEventListenerHandler.class);
+ ConfigurationFileRepresentation config = new ConfigurationFileRepresentation(CONFIGURATIONTESTFILE);
+
+ deviceMonitor = new DeviceMonitorImpl(dataBroker, odlEventListenerHandler, config);
+
+ }
+
+ @Test
+ public void testDeviceMonitor() {
+
+ deviceMonitor.deviceConnectSlaveIndication(mountPointNodeName);
+ deviceMonitor.refreshAlarmsInDb();
+ deviceMonitor.taskTestRun();
+ deviceMonitor.deviceDisconnectIndication(mountPointNodeName);
+ deviceMonitor.removeMountpointIndication(mountPointNodeName);
+ }
+
+ @Test
+ public void testDeviceMonitorTask() {
+
+
+ }
+
+ @AfterClass
+ public static void after() throws Exception {
+ deviceMonitor.close();
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevicemanager.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevicemanager.java
new file mode 100644
index 000000000..a86bfc277
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevicemanager.java
@@ -0,0 +1,207 @@
+/*******************************************************************************
+ * ============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.devicemanager.test;
+
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.HtDatabaseMaintenance;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.IEntityDataProvider;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.IEsConfig;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.DeviceManagerImpl;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util.InternalDateAndTime;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NotificationService;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.test.mock.RpcProviderServiceMock;
+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.NetconfNodeStateService;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.MountPointService;
+import org.opendaylight.mdsal.binding.api.NotificationPublishService;
+import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.FaultlogBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.MaintenanceBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.ClearCurrentFaultByNodenameInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.DevicemanagerService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.GetRequiredNetworkElementKeysInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.PushAttributeChangeNotificationInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.PushFaultNotificationInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.ShowRequiredNetworkElementInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.websocketmanager.rev150105.WebsocketmanagerService;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@SuppressWarnings("deprecation")
+public class TestDevicemanager extends Mockito {
+
+ private static final Logger log = LoggerFactory.getLogger(TestDevicemanager.class);
+
+ private static DeviceManagerImpl deviceManager = new DeviceManagerImpl();
+ private static DevicemanagerService apiService;
+ private static HtDatabaseMaintenance htDataBaseMaintenance = mock(HtDatabaseMaintenance.class);
+
+ @BeforeClass
+ public static void before() throws Exception {
+
+ DataBroker dataBroker = mock(DataBroker.class);
+ RpcProviderServiceMock rpcProviderRegistry = new RpcProviderServiceMock();
+ NotificationPublishService notificationPublishService = mock(NotificationPublishService.class);
+ MountPointService mountPointService = mock(MountPointService.class);
+ ClusterSingletonServiceProvider clusterSingletonService = mock(ClusterSingletonServiceProvider.class);
+ NetconfNodeStateService netconfNodeStateService = mock(NetconfNodeStateService.class);
+
+ @SuppressWarnings("unchecked")
+ ListenerRegistration<NetconfNodeConnectListener> lr1 = mock(ListenerRegistration.class);
+ //doNothing().when(lr1).close();
+ when(netconfNodeStateService.registerNetconfNodeConnectListener(mock(NetconfNodeConnectListener.class))).thenReturn(lr1);
+
+ @SuppressWarnings("unchecked")
+ ListenerRegistration<NetconfNodeStateListener> lr2 = mock(ListenerRegistration.class);
+ //doNothing().when(lr2).close();
+ when(netconfNodeStateService.registerNetconfNodeStateListener(mock(NetconfNodeStateListener.class))).thenReturn(lr2);
+
+ WebsocketmanagerService websocketmanagerService = mock(WebsocketmanagerService.class);
+
+ IEntityDataProvider iEntityDataProvider = mock(IEntityDataProvider.class);
+ doNothing().when(iEntityDataProvider).setReadyStatus(isA(Boolean.class));
+
+ DataProvider dataProvider = mock(DataProvider.class);
+ when(iEntityDataProvider.getDataProvider()).thenReturn(dataProvider);
+
+ when(iEntityDataProvider.getHtDatabaseMaintenance()).thenReturn(htDataBaseMaintenance);
+
+
+ IEsConfig esConfig = mock(IEsConfig.class);
+ when(iEntityDataProvider.getEsConfig()).thenReturn(esConfig);
+
+
+ deviceManager.setDataBroker(dataBroker);
+ deviceManager.setRpcProviderRegistry(rpcProviderRegistry);
+ deviceManager.setNotificationPublishService(notificationPublishService);
+ deviceManager.setMountPointService(mountPointService);
+ deviceManager.setClusterSingletonService(clusterSingletonService);
+ deviceManager.setNetconfNodeStateService(netconfNodeStateService);
+ deviceManager.setWebsocketmanagerService(websocketmanagerService);
+ deviceManager.setEntityDataProvider(iEntityDataProvider);
+
+ deviceManager.init();
+
+ apiService = rpcProviderRegistry.getDeviceManagerApiService();
+
+ }
+
+
+ @Test
+ public void testInit() {
+ assertTrue(deviceManager.isDevicemanagerInitializationOk());
+ }
+
+ @Test
+ public void testChangeNotification() {
+ NotificationService n = deviceManager.getNotificationService();
+
+ n.creationNotification(new NodeId("NodeTest1"), 1, InternalDateAndTime.getTestpatternDateAndTime(), "ObjTest1");
+
+ n.changeNotification(new NodeId("NodeTest1"), 2, InternalDateAndTime.getTestpatternDateAndTime(), "ObjTest1", "AtrributeTest1", "NewTest1");
+
+ n.deletionNotification(new NodeId("NodeTest1"), 3, InternalDateAndTime.getTestpatternDateAndTime(), "ObjTest1");
+
+ }
+
+ @Test
+ public void testFaultNotification() {
+ log.info("testFaultNotification");
+
+ MaintenanceBuilder mb = new MaintenanceBuilder();
+ when(htDataBaseMaintenance
+ .getMaintenance(""))
+ .thenReturn(mb.build());
+
+ FaultService n = deviceManager.getFaultService();
+ FaultlogBuilder faultLogEntityBuilder = new FaultlogBuilder();
+ n.faultNotification(faultLogEntityBuilder.build());
+
+ }
+
+ @Test
+ public void testGet() {
+ log.info("testGet");
+ GetRequiredNetworkElementKeysInputBuilder inputBuilder = new GetRequiredNetworkElementKeysInputBuilder();
+ apiService.getRequiredNetworkElementKeys(inputBuilder.build());
+
+ }
+
+ @Test
+ public void testShow() {
+ log.info("testShow");
+ ShowRequiredNetworkElementInputBuilder inputBuilder = new ShowRequiredNetworkElementInputBuilder();
+ inputBuilder.setMountpointName("test");
+ apiService.showRequiredNetworkElement(inputBuilder.build());
+
+ }
+
+ @Test
+ public void testResync() {
+ log.info("testResync");
+
+ ClearCurrentFaultByNodenameInputBuilder inputBuilder = new ClearCurrentFaultByNodenameInputBuilder();
+ inputBuilder.setNodenames(Arrays.asList("test1", "test2"));
+ apiService.clearCurrentFaultByNodename(inputBuilder.build());
+
+ }
+
+ @Test
+ public void testPushFault() {
+ log.info("testPushFault");
+
+ PushFaultNotificationInputBuilder inputBuilder = new PushFaultNotificationInputBuilder();
+ inputBuilder.setNodeId("NodeTest23");
+ inputBuilder.setTimestamp(new DateAndTime("2020-01-01T01:02:03.4Z"));
+ apiService.pushFaultNotification(inputBuilder.build());
+
+ }
+
+ @Test
+ public void testPushChange() {
+ log.info("testPushChange");
+
+ PushAttributeChangeNotificationInputBuilder inputBuilder = new PushAttributeChangeNotificationInputBuilder();
+ inputBuilder.setNodeId("NodeTest24");
+ apiService.pushAttributeChangeNotification(inputBuilder.build());
+
+ }
+
+
+ @AfterClass
+ public static void after() {
+ deviceManager.close();
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestGeoConfig.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestGeoConfig.java
deleted file mode 100644
index 6474a1eb6..000000000
--- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestGeoConfig.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * ============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.devicemanager.test;
-
-import static org.junit.Assert.*;
-import org.junit.Test;
-import org.onap.ccsdk.features.sdnr.wt.devicemanager.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/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestMaintenanceTimeFilter.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestMaintenanceTimeFilter.java
index 932ad52d2..3d8571659 100644
--- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestMaintenanceTimeFilter.java
+++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestMaintenanceTimeFilter.java
@@ -22,11 +22,11 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.test;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
import java.time.ZonedDateTime;
import org.junit.Test;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.maintenance.impl.MaintenanceCalculator;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.MaintenanceBuilder;
public class TestMaintenanceTimeFilter {
@@ -34,7 +34,7 @@ public class TestMaintenanceTimeFilter {
private static String DEFAULT2 = "EsMaintenanceFilter [start=1970-01-01T00:00Z[UTC], end=2018-01-01T10:00+05:00, definition=EsMaintenanceFilterDefinition [objectIdRef=, problem=], description=]";
@Test
- public void test1() {
+ public void testBasic() {
boolean res;
@@ -59,4 +59,29 @@ public class TestMaintenanceTimeFilter {
}
+ @Test
+ public void testBasic2() {
+
+ MaintenanceBuilder mb = new MaintenanceBuilder();
+
+ mb.setActive(true);
+ mb.setStart(new DateAndTime("1999-01-01T00:00:00Z"));
+ mb.setEnd(new DateAndTime("2001-01-01T00:00:00Z"));
+ mb.setId("id1");
+ mb.setObjectIdRef("Interface1");
+ mb.setProblem("Problem1");
+
+ boolean res;
+ ZonedDateTime now;
+
+ now = MaintenanceCalculator.valueOf("2000-01-01T00:00Z");
+ res = MaintenanceCalculator.isONFObjectInMaintenance(mb.build(), "", "", now);
+ assertTrue("within period",res);
+
+ now = MaintenanceCalculator.valueOf("2002-01-01T00:00Z");
+ res = MaintenanceCalculator.isONFObjectInMaintenance(mb.build(), "", "", now);
+ assertFalse("outside period",res);
+
+ }
+
}
diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestNotification.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestToggleAlarmFilter.java
index 7e54f16b1..766b25e6d 100644
--- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestNotification.java
+++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestToggleAlarmFilter.java
@@ -23,10 +23,10 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.test;
import org.junit.Test;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.toggleAlarmFilter.NotificationWithServerTimeStamp;
-public class TestNotification {
+public class TestToggleAlarmFilter {
@Test
- public void test() {
+ public void testNotification() {
NotificationWithServerTimeStamp<Integer> test = new NotificationWithServerTimeStamp<>(1000);
@@ -37,5 +37,4 @@ public class TestNotification {
}
-
}
diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestXmlNotification.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestXmlNotification.java
new file mode 100644
index 000000000..f1822768d
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestXmlNotification.java
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * ============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.devicemanager.test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+import org.junit.Test;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util.InternalDateAndTime;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util.InternalSeverity;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ObjectCreationNotificationXml;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ObjectDeletionNotificationXml;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SourceType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TestXmlNotification {
+
+ private static final Logger log = LoggerFactory.getLogger(TestXmlNotification.class);
+
+ @Test
+ public void test() {
+
+ ProblemNotificationXml notification = new ProblemNotificationXml("TestMointpoint", "network-element",
+ "problemName", InternalSeverity.Critical, 123, InternalDateAndTime.getTestpattern());
+
+ notification.getFaultlog(SourceType.Unknown);
+
+ notification.getFaultcurrent();
+
+ notification.isNotManagedAsCurrentProblem();
+
+ ProblemNotificationXml.debugResultList(log, "uuid", Arrays.asList(notification), 0);
+
+ }
+
+ @Test
+ public void testNoAlarm() {
+
+ ProblemNotificationXml notification;
+ notification = new ProblemNotificationXml("TestMointpoint", "network-element",
+ "problemName", InternalSeverity.Critical, 123, InternalDateAndTime.getTestpattern());
+
+ assertFalse("Critical", notification.isNoAlarmIndication());
+
+ notification = new ProblemNotificationXml("TestMointpoint", "network-element",
+ "problemName", InternalSeverity.NonAlarmed, 123, InternalDateAndTime.getTestpattern());
+
+ assertTrue("NonAlarm", notification.isNoAlarmIndication());
+
+ }
+
+ @Test
+ public void testObjectCreationNotification() {
+
+ ObjectCreationNotificationXml notification;
+ notification = new ObjectCreationNotificationXml("TestMointpoint1", 1, InternalDateAndTime.getTestpattern(), "Id1");
+
+ }
+
+ @Test
+ public void testDeletionCreationNotification() {
+
+ ObjectDeletionNotificationXml notification;
+ notification = new ObjectDeletionNotificationXml("TestMointpoint2", 2, InternalDateAndTime.getTestpattern(), "Id2");
+
+ }
+
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/ClusterSingletonServiceProviderMock.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/ClusterSingletonServiceProviderMock.java
deleted file mode 100644
index a215e1883..000000000
--- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/ClusterSingletonServiceProviderMock.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * ============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.devicemanager.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/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/DataBrokerMountpointMock.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/DataBrokerMountpointMock.java
deleted file mode 100644
index 2bd5a9272..000000000
--- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/DataBrokerMountpointMock.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * ============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.devicemanager.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;
-
-/**
- * @author herbert
- *
- */
-@SuppressWarnings("deprecation")
-public class DataBrokerMountpointMock implements DataBroker, BindingService {
-
- ReadTransaction readOnlyTransaction;
-
- public void setReadOnlyTransaction(ReadTransaction readOnlyTransaction) {
- this.readOnlyTransaction = readOnlyTransaction;
- }
-
- @Override
- public @NonNull ReadTransaction newReadOnlyTransaction() {
- return readOnlyTransaction;
- }
-
- @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/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/DataBrokerNetconfMock.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/DataBrokerNetconfMock.java
deleted file mode 100644
index 0b5052632..000000000
--- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/DataBrokerNetconfMock.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * ============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.devicemanager.test.mock;
-
-import org.eclipse.jdt.annotation.NonNull;
-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;
-
-/**
- * @author herbert
- *
- */
-@SuppressWarnings("deprecation")
-public class DataBrokerNetconfMock implements DataBroker {
-
-
- ReadTransaction readOnlyTransaction;
-
- public void setReadOnlyTransaction(ReadTransaction readOnlyTransaction) {
- this.readOnlyTransaction = readOnlyTransaction;
- }
-
- @Override
- public @NonNull ReadTransaction newReadOnlyTransaction() {
- return readOnlyTransaction;
- }
-
- @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/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/DataProviderMock.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/DataProviderMock.java
deleted file mode 100644
index 00edbe2ed..000000000
--- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/DataProviderMock.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * ============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.devicemanager.test.mock;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ConnectionlogEntity;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogEntity;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.FaultcurrentEntity;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.FaultlogEntity;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Inventory;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.NetworkElementConnectionEntity;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.PmdataEntity;
-
-public class DataProviderMock implements DataProvider {
-
- @Override
- public void writeConnectionLog(ConnectionlogEntity event) {
- }
-
- @Override
- public void writeEventLog(EventlogEntity event) {
- }
-
- @Override
- public void writeFaultLog(FaultlogEntity fault) {
- }
-
- @Override
- public void updateFaultCurrent(FaultcurrentEntity fault) {
- }
-
- @Override
- public int clearFaultsCurrentOfNode(String nodeName) {
- return 0;
- }
-
- @Override
- public int clearFaultsCurrentOfNodeWithObjectId(String nodeName, String objectId) {
- return 0;
- }
-
- @Override
- public List<String> getAllNodesWithCurrentAlarms() {
- return new ArrayList<>();
- }
-
- @Override
- public void writeInventory(Inventory internalEquipment) {
- }
-
- @Override
- public void updateNetworkConnectionDeviceType(NetworkElementConnectionEntity networkElementConnectionEntitiy,
- String nodeId) {
- }
-
- @Override
- public void updateNetworkConnection22(NetworkElementConnectionEntity networkElementConnectionEntitiy,
- String nodeId) {
- }
-
- @Override
- public void removeNetworkConnection(String nodeId) {
- }
-
- @Override
- public int doIndexClean(Date olderAreOutdated) {
- return 0;
- }
-
- @Override
- public int getNumberOfOldObjects(Date olderAreOutdated) {
- return 0;
- }
-
- @Override
- public List<NetworkElementConnectionEntity> getNetworkElementConnections() {
- return new ArrayList<>();
- }
-
- @Override
- public void doWritePerformanceData(List<PmdataEntity> list) {
- }
-}
diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/MountPointMock.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/MountPointMock.java
deleted file mode 100644
index 73d32e418..000000000
--- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/MountPointMock.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*******************************************************************************
- * ============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.devicemanager.test.mock;
-
-import java.util.Optional;
-import org.opendaylight.mdsal.binding.api.BindingService;
-import org.opendaylight.mdsal.binding.api.MountPoint;
-import org.opendaylight.mdsal.binding.api.NotificationService;
-import org.opendaylight.mdsal.binding.api.ReadTransaction;
-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
- *
- */
-@SuppressWarnings("deprecation")
-public class MountPointMock implements MountPoint {
-
- private boolean databrokerAbsent = true;
- private final DataBrokerMountpointMock dataBroker = new DataBrokerMountpointMock();
- private final RpcConsumerRegistryMock rpcConsumerRegistry = new RpcConsumerRegistryMock();
- private NotificationService setReadOnlyTransaction;
-
- 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<?> 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(setReadOnlyTransaction)) {
- System.out.println("Delivering notificationService");
- res = Optional.of(setReadOnlyTransaction);
- } else {
- System.out.println("Delivering no service");
- res = Optional.empty();
- }
- return (Optional<T>)res;
- }
-
- public void setDatabrokerAbsent( boolean state) {
- this.databrokerAbsent = state;
- }
-
- public <T extends NotificationService&ReadTransaction>void setReadOnlyTransaction(T readOnlyTransaction) {
- this.setReadOnlyTransaction = readOnlyTransaction;
- dataBroker.setReadOnlyTransaction(readOnlyTransaction);
- }
-
-
-}
diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/MountPointServiceMock.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/MountPointServiceMock.java
deleted file mode 100644
index 113ead29f..000000000
--- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/MountPointServiceMock.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * ============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.devicemanager.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 MountPoint mountpoint;
-
- public MountPointServiceMock(MountPoint mountpoint) {
- this.mountpoint = mountpoint;
- }
-
- @Override
- public Optional<MountPoint> getMountPoint(InstanceIdentifier<?> instanceId) {
-
- 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/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/NetconfNodeStateServiceMock.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/NetconfNodeStateServiceMock.java
deleted file mode 100644
index 5a000a52a..000000000
--- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/NetconfNodeStateServiceMock.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * ============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.devicemanager.test.mock;
-
-import org.eclipse.jdt.annotation.NonNull;
-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.NetconfNodeStateService;
-import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.VesNotificationListener;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-
-/**
- * @author herbert
- *
- */
-public class NetconfNodeStateServiceMock implements NetconfNodeStateService {
-
- Object object = new Object();
- private final ListenerRegistration<? extends NetconfNodeConnectListener> lr = new ListenerRegistration() {
-
- @Override
- public @NonNull Object getInstance() {
- return object;
- }
-
- @Override
- public void close() {
- }
-
- };
-
-
- @Override
- public void close() {
- }
-
- @Override
- public <L extends NetconfNodeConnectListener> @NonNull ListenerRegistration<L> registerNetconfNodeConnectListener(
- @NonNull L netconfNodeConnectListener) {
- return (ListenerRegistration<L>) lr;
- }
-
- @Override
- public <L extends NetconfNodeStateListener> @NonNull ListenerRegistration<L> registerNetconfNodeStateListener(
- @NonNull L netconfNodeStateListener) {
- return (ListenerRegistration<L>) lr;
- }
-
- @Override
- public <L extends VesNotificationListener> @NonNull ListenerRegistration<L> registerVesNotifications(
- @NonNull L netconfNodeStateListener) {
- return (ListenerRegistration<L>) lr;
- }
-
-
-}
diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/NotificationPublishServiceMock.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/NotificationPublishServiceMock.java
deleted file mode 100644
index fc3318b9e..000000000
--- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/NotificationPublishServiceMock.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * ============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.devicemanager.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;
-
-/**
- * @author herbert
- *
- */
-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/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcConsumerRegistryMock.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcConsumerRegistryMock.java
deleted file mode 100644
index 89864c2c5..000000000
--- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcConsumerRegistryMock.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * ============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.devicemanager.test.mock;
-
-import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-
-/**
- * @author herbert
- *
- */
-@SuppressWarnings("deprecation")
-public class RpcConsumerRegistryMock implements RpcConsumerRegistry {
-
- @Override
- public <T extends RpcService> T getRpcService(Class<T> serviceInterface) {
- return null;
- }
-
-}
diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcProviderRegistryMock.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcProviderServiceMock.java
index 4aaa1ed48..6ecafea9f 100644
--- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcProviderRegistryMock.java
+++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcProviderServiceMock.java
@@ -22,16 +22,22 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.test.mock;
import java.util.Set;
import org.opendaylight.mdsal.binding.api.RpcProviderService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.DevicemanagerService;
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 {
+public class RpcProviderServiceMock implements RpcProviderService {
+
+ private DevicemanagerService deviceManagerApi;
@Override
public <S extends RpcService, T extends S> ObjectRegistration<T> registerRpcImplementation(Class<S> type,
T implementation) {
System.out.println("Register class "+implementation);
+ if (implementation instanceof DevicemanagerService) {
+ deviceManagerApi = (DevicemanagerService)implementation;
+ }
return null;
}
@@ -41,4 +47,8 @@ public class RpcProviderRegistryMock implements RpcProviderService {
return null;
}
+ public DevicemanagerService getDeviceManagerApiService() {
+ return deviceManagerApi;
+ }
+
}
diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/util/DBCleanServiceHelper.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/util/DBCleanServiceHelper.java
deleted file mode 100644
index 79688280e..000000000
--- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/util/DBCleanServiceHelper.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * ============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.devicemanager.test.util;
-
-import java.util.Date;
-import java.util.concurrent.TimeUnit;
-import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
-import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.NetconfTimeStamp;
-import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.NetconfTimeStampImpl;
-import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.DeviceManagerImpl;
-import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util.InternalDateAndTime;
-import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util.InternalSeverity;
-import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ObjectCreationNotificationXml;
-import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SourceType;
-
-public class DBCleanServiceHelper {
-
- private static final NetconfTimeStamp NETCONFTIME_CONVERTER = NetconfTimeStampImpl.getConverter();
-
- private final DataProvider databaseEventService;
-
- /**
- * Helper to fill data into the database
- * @param deviceManager devicemanger to get services
- */
- public DBCleanServiceHelper(DeviceManagerImpl deviceManager) {
- this.databaseEventService = deviceManager.getDatabaseClientEvents();
- }
-
- /**
- * Write data into database with specific date and content profile.
- * @param number of data to be written for each log
- * @param days starting day, relative to actual date
- * @param hours starting hour ... increased by one hour for each write
- * @return integer with the amount of written data
- */
- public int writeDataToLogs(int number, int days, int hours) {
- int res = 0;
- for (Integer t=0; t < number; t++) { //Test "sdnevents", "eventlog"
- ObjectCreationNotificationXml notificationXml = new ObjectCreationNotificationXml(
- "Testpoint"+t, t, getInternalDateAndTime(days, hours+t), "ObjectId"+t);
- databaseEventService.writeConnectionLog(notificationXml.getConnectionlogEntity());
- res++;
- }
-
- for (Integer t=0; t < number; t++) { //Test "sdnevents", "faultlog"
- ProblemNotificationXml fault = new ProblemNotificationXml(
- "ProblemNode"+t, "Problemuuid", "Problemname", InternalSeverity.Major, t, getInternalDateAndTime(days, hours+t));
- databaseEventService.writeFaultLog(fault.getFaultlog(SourceType.Unknown));
- res++;
- }
-
- return res;
- }
-
- /**************************************************************
- * Private section
- */
-
- private InternalDateAndTime getInternalDateAndTime(int days, int hours) {
- Date actual = new Date(new Date().getTime() - TimeUnit.MILLISECONDS.convert(days, TimeUnit.DAYS) - TimeUnit.MILLISECONDS.convert(hours, TimeUnit.HOURS));
- InternalDateAndTime timeStamp = InternalDateAndTime.valueOf(NETCONFTIME_CONVERTER.getTimeStamp(actual));
- return timeStamp;
- }
-
-
-}
diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/util/ZipFile.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/util/ZipFile.java
deleted file mode 100644
index 9a926fd64..000000000
--- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/util/ZipFile.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * ============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.devicemanager.test.util;
-
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipOutputStream;
-
-public class ZipFile implements AutoCloseable {
-
- private final ZipOutputStream zos;
- private final FileOutputStream fos;
-
- public ZipFile(String zipPath) throws FileNotFoundException {
- fos = new FileOutputStream(zipPath);
- zos = new ZipOutputStream(fos);
- }
-
- public void addToZipFile(String fileName) throws FileNotFoundException, IOException {
-
- System.out.println("Writing '" + fileName + "' to zip file");
-
- InputStream fis = ZipFile.class.getClassLoader().getResourceAsStream(fileName);
- if (fis == null) {
- throw new FileNotFoundException("Resource not found: " + fileName);
- }
-
- ZipEntry zipEntry = new ZipEntry(fileName);
- zos.putNextEntry(zipEntry);
- byte[] bytes = new byte[1024];
- int length;
- while ((length = fis.read(bytes)) >= 0) {
- zos.write(bytes, 0, length);
- }
- zos.closeEntry();
- fis.close();
- }
-
- @Override
- public void close() throws IOException {
- zos.close();
- fos.close();
- }
-
-}