summaryrefslogtreecommitdiffstats
path: root/sdnr/wt/data-provider/dblib/src/test
diff options
context:
space:
mode:
authorRavi Pendurty <ravi.pendurty@highstreet-technologies.com>2021-07-26 12:42:00 +0530
committerKAPIL SINGAL <ks220y@att.com>2021-07-28 16:08:00 +0000
commit016536791b95df23811dabd063010f0561526163 (patch)
treedc9af75cdad070fa803b6ea8799cfa38244a17f0 /sdnr/wt/data-provider/dblib/src/test
parentd70d7624795a9305eef1f0a6d3842d47ecd27160 (diff)
Support for MariaDB
Support for MariaDB Issue-ID: CCSDK-3384 Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com> Change-Id: Ic93ad33257a091f2cd208cdf02d1d7400c256bf0 Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/data-provider/dblib/src/test')
-rw-r--r--sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestCRUDMariaDB.java236
-rw-r--r--sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestMariaDataProvider.java563
-rw-r--r--sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestQuerySyntax.java157
-rw-r--r--sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/util/MariaDBTestBase.java192
-rw-r--r--sdnr/wt/data-provider/dblib/src/test/resources/inventory.json381
-rw-r--r--sdnr/wt/data-provider/dblib/src/test/resources/pmdata15m.json532
6 files changed, 2061 insertions, 0 deletions
diff --git a/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestCRUDMariaDB.java b/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestCRUDMariaDB.java
new file mode 100644
index 000000000..ad4ab6789
--- /dev/null
+++ b/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestCRUDMariaDB.java
@@ -0,0 +1,236 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : ccsdk features
+ * ================================================================================
+ * Copyright (C) 2020 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.dataprovider.dblib.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.text.ParseException;
+import java.util.concurrent.TimeUnit;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.ccsdk.features.sdnr.wt.common.database.data.AliasesEntryList;
+import org.onap.ccsdk.features.sdnr.wt.common.database.data.DatabaseVersion;
+import org.onap.ccsdk.features.sdnr.wt.common.database.data.IndicesEntryList;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.SqlDBClient;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.data.SqlDBDataProvider;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.dblib.test.util.MariaDBTestBase;
+import ch.vorburger.exec.ManagedProcessException;
+
+public class TestCRUDMariaDB {
+
+
+ private static final String TABLE1_NAME = "table1";
+ private static final String TABLE2_NAME = "table2-v6";
+ private static final String TABLE3_NAME = "table3-v6";
+ private static final String VIEW2_NAME = "table2";
+ private static final String VIEW3_NAME = "table3";
+ private static final String TABLE1_MAPPING = "col1 INT PRIMARY KEY, col2 NVARCHAR(30), col3 BOOLEAN";
+ private static final String TABLE2_MAPPING = "col1 INT PRIMARY KEY, col2 NVARCHAR(30), col3 BOOLEAN";
+ private static final String TABLE3_MAPPING = "col1 INT PRIMARY KEY, col2 NVARCHAR(30), col3 BOOLEAN";
+ private static final String DELETE_ALL_FORMAT = "DELETE FROM `%s`";
+ private static final String READ_ALL_FORMAT = "SELECT * FROM `%s`";
+ private static final String TABLE1_INSERT_ENTRY_FORMAT =
+ "INSERT INTO `" + TABLE1_NAME + "` (col1, col2, col3) VALUES(%d,'%s',%d);";
+ private static final String TABLE1_UPDATE_ENTRY_FORMAT =
+ "UPDATE `" + TABLE1_NAME + "` SET col2='%s', col3=%d WHERE col1=%d;";
+ private static final String TABLE1_DELETE_ENTRY_FORMAT = "DELETE FROM `" + TABLE1_NAME + "` WHERE col1=%d;";
+ private static String DBNAME = null;
+
+ private static MariaDBTestBase testBase;
+ private static SqlDBDataProvider dbProvider;
+ private static SqlDBClient dbClient;
+
+ @BeforeClass
+ public static void init() throws Exception {
+
+ testBase = new MariaDBTestBase();
+ dbProvider = testBase.getDbProvider();
+ dbProvider.waitForDatabaseReady(30, TimeUnit.SECONDS);
+ dbClient = testBase.createRawClient();
+ DBNAME = testBase.getDBName();
+ }
+
+ @AfterClass
+ public static void close() {
+ try {
+ testBase.close();
+ } catch (ManagedProcessException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void test1() {
+ ResultSet data;
+ boolean success;
+ String id = null;
+ //create test1Table
+ success = dbClient.createTable(TABLE1_NAME, TABLE1_MAPPING);
+ assertTrue("failed to create table", success);
+ //delete all
+ try {
+ success = dbClient.delete(String.format(DELETE_ALL_FORMAT, TABLE1_NAME));
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ assertTrue("failed to clear table", success);
+ //test empty
+ data = dbClient.read(String.format(READ_ALL_FORMAT, TABLE1_NAME));
+ try {
+ assertEquals(0, countRows(data));
+ } catch (SQLException e) {
+ e.printStackTrace();
+ fail("unable to read size");
+ }
+ //create entry
+ success = false;
+ try {
+ success = dbClient.write(String.format(TABLE1_INSERT_ENTRY_FORMAT, 10, "hello", 0));
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ assertTrue("failed to write data", success);
+ //verify write
+ data = dbClient.read(String.format(READ_ALL_FORMAT, TABLE1_NAME));
+ try {
+ assertEquals(1, countRows(data));
+ assertTrue(data.next());
+ assertEquals(10, data.getInt(1));
+ assertEquals("hello", data.getString(2));
+ assertEquals(false, data.getBoolean(3));
+ } catch (SQLException e) {
+ e.printStackTrace();
+ fail("unable to verify write");
+ }
+ //update entry
+ success = false;
+ try {
+ success = dbClient.update(String.format(TABLE1_UPDATE_ENTRY_FORMAT, "hello2", 1, 10));
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ assertTrue("failed to update data", success);
+ //verify update
+ data = dbClient.read(String.format(READ_ALL_FORMAT, TABLE1_NAME));
+ try {
+ assertEquals(1, countRows(data));
+ assertTrue(data.next());
+ assertEquals(10, data.getInt(1));
+ assertEquals("hello2", data.getString(2));
+ assertEquals(true, data.getBoolean(3));
+ } catch (SQLException e) {
+ e.printStackTrace();
+ fail("unable to verify write");
+ }
+ //delete entry
+ success = false;
+ try {
+ success = dbClient.delete(String.format(TABLE1_DELETE_ENTRY_FORMAT, 10));
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ assertTrue("failed to delete data", success);
+ //verify delete
+ data = dbClient.read(String.format(READ_ALL_FORMAT, TABLE1_NAME));
+ try {
+ assertEquals(0, data.getFetchSize());
+ } catch (SQLException e) {
+ e.printStackTrace();
+ fail("unable to verify delete. size>0");
+ }
+ }
+
+ @Test
+ public void testDBVersion() {
+ DatabaseVersion version = null;
+ try {
+ version = dbClient.readActualVersion();
+ } catch (SQLException | ParseException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ assertTrue(version.getMajor() >= 10);
+ }
+
+ @Test
+ public void testTableStuff() {
+
+ boolean success;
+ //create Tables/Views
+ success = dbClient.createTable(TABLE2_NAME, TABLE2_MAPPING);
+ assertTrue(success);
+ success = dbClient.createTable(TABLE3_NAME, TABLE3_MAPPING);
+ assertTrue(success);
+ try {
+ success = dbClient.createView(TABLE2_NAME, VIEW2_NAME);
+ assertTrue(success);
+ success = dbClient.createView(TABLE3_NAME, VIEW3_NAME);
+ assertTrue(success);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ //read Tables
+ IndicesEntryList tables = dbClient.readTables();
+ assertTrue(tables.stream().filter(t -> t.getName().equals(TABLE2_NAME)).count() == 1);
+ assertTrue(tables.stream().filter(t -> t.getName().equals(TABLE3_NAME)).count() == 1);
+ AliasesEntryList views = dbClient.readViews(DBNAME);
+ assertTrue(views.stream().filter(t -> t.getIndex().equals(TABLE2_NAME) && t.getAlias().equals(VIEW2_NAME))
+ .count() == 1);
+ assertTrue(views.stream().filter(t -> t.getIndex().equals(TABLE3_NAME) && t.getAlias().equals(VIEW3_NAME))
+ .count() == 1);
+
+ //delete Tables/Views
+ try {
+ success = dbClient.deleteView(VIEW2_NAME);
+ assertTrue(success);
+ success = dbClient.deleteView(VIEW3_NAME);
+ assertTrue(success);
+ success = dbClient.deleteTable(TABLE2_NAME);
+ assertTrue(success);
+ success = dbClient.deleteTable(TABLE3_NAME);
+ assertTrue(success);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ //verify
+ tables = dbClient.readTables();
+ assertTrue(tables.stream().filter(t->t.getName().equals(TABLE2_NAME)).count()==0);
+ assertTrue(tables.stream().filter(t->t.getName().equals(TABLE3_NAME)).count()==0);
+ views = dbClient.readViews(DBNAME);
+ assertEquals(0,views.size());
+ }
+
+ public static int countRows(ResultSet data) throws SQLException {
+ int rows = 0;
+ while (data.next()) {
+ rows++;
+ }
+ data.beforeFirst();
+ return rows;
+ }
+}
diff --git a/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestMariaDataProvider.java b/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestMariaDataProvider.java
new file mode 100644
index 000000000..da7450089
--- /dev/null
+++ b/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestMariaDataProvider.java
@@ -0,0 +1,563 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : ccsdk features
+ * ================================================================================
+ * Copyright (C) 2020 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.dataprovider.dblib.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+import java.io.IOException;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.SqlDBClient;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.data.SqlDBDataProvider;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.query.DeleteQuery;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.dblib.test.util.MariaDBTestBase;
+import org.onap.ccsdk.features.sdnr.wt.yang.mapper.YangToolsMapper;
+import org.opendaylight.netconf.shaded.sshd.common.util.io.IoUtils;
+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.rev201110.ConnectionLogStatus;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ConnectionlogBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ConnectionlogEntity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateMaintenanceInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateMaintenanceInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateMediatorServerInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateMediatorServerInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateMediatorServerOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.DeleteMediatorServerInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.DeleteMediatorServerInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.DeleteNetworkElementConnectionInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.DeleteNetworkElementConnectionInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Entity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EntityInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogEntity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultcurrentBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultcurrentEntity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultlogBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultlogEntity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Guicutthrough;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.GuicutthroughBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Inventory;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementConnectionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementConnectionEntity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementDeviceType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.PmdataEntity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadConnectionlogListOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadEventlogListOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadFaultcurrentListInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadFaultcurrentListOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadFaultlogListOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadGuiCutThroughEntryOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadInventoryListOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadMaintenanceListOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadMediatorServerListOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadNetworkElementConnectionListOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadPmdata15mDeviceListOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadPmdata15mListOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadPmdata15mLtpListOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadPmdata24hListOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadStatusOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SeverityType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SourceType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.UpdateMediatorServerInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.UpdateMediatorServerInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.UpdateNetworkElementConnectionInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.UpdateNetworkElementConnectionInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.entity.input.Filter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.entity.input.FilterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.entity.input.FilterKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.entity.input.PaginationBuilder;
+import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint64;
+import ch.vorburger.exec.ManagedProcessException;
+
+public class TestMariaDataProvider {
+
+
+ private static final String NODEID1 = "node1";
+ private static final String NODEID2 = "node2";
+ private static final String NODEID3 = "node3";
+ private static final String PROBLEM1 = "problem1";
+ private static final String TIME1 = "2021-05-25T05:12:55.0Z";
+ private static final String TIME2 = "2021-05-25T05:12:56.0Z";
+ private static final String TIME3 = "2021-05-25T05:12:57.0Z";
+ private static final String PROBLEM2 = "problem2";
+ private static final String URI1 = "http://localhost:8181";
+ private static final String URI2 = "http://localhost:8181";
+ private static final String URI3 = "http://localhost:8181";
+ private static MariaDBTestBase testBase;
+ private static SqlDBDataProvider dbProvider;
+ private static SqlDBClient dbClient;
+ private static String CONTROLLERID;
+
+ @BeforeClass
+ public static void init() throws Exception {
+
+ testBase = new MariaDBTestBase();
+ dbProvider = testBase.getDbProvider();
+ dbProvider.waitForDatabaseReady(30, TimeUnit.SECONDS);
+ dbClient = testBase.createRawClient();
+ MariaDBTestBase.testCreateTableStructure(dbClient);
+ dbProvider.setControllerId();
+ CONTROLLERID = dbProvider.getControllerId();
+
+ }
+
+ @AfterClass
+ public static void close() {
+ try {
+ testBase.close();
+ } catch (ManagedProcessException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testFaultcurrent() {
+ dbProvider.clearFaultsCurrentOfNode(NODEID1);
+ ReadFaultcurrentListOutputBuilder faultCurrents =
+ dbProvider.readFaultCurrentList(createInput("node-id", NODEID1, 1, 20));
+ assertEquals(0, faultCurrents.getData().size());
+ FaultcurrentEntity faultCurrent1 = new FaultcurrentBuilder().setNodeId(NODEID1).setCounter(1).setObjectId("obj")
+ .setProblem(PROBLEM1).setTimestamp(DateAndTime.getDefaultInstance(TIME1))
+ .setSeverity(SeverityType.Major).setId(String.format("%s/%s", NODEID1, PROBLEM1)).build();
+ dbProvider.updateFaultCurrent(faultCurrent1);
+ FaultcurrentEntity faultCurrent2 = new FaultcurrentBuilder().setNodeId(NODEID1).setCounter(1).setObjectId("obj")
+ .setProblem(PROBLEM2).setTimestamp(DateAndTime.getDefaultInstance(TIME1))
+ .setSeverity(SeverityType.Minor).setId(String.format("%s/%s", NODEID1, PROBLEM2)).build();
+ dbProvider.updateFaultCurrent(faultCurrent2);
+ faultCurrents = dbProvider.readFaultCurrentList(createInput("node-id", NODEID1, 1, 20));
+ assertEquals(2, faultCurrents.getData().size());
+ ReadStatusOutputBuilder status = null;
+ try {
+ status = dbProvider.readStatus();
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail("failed to read status");
+ }
+ assertEquals(0, status.getData().get(0).getFaults().getCriticals().intValue());
+ assertEquals(1, status.getData().get(0).getFaults().getMajors().intValue());
+ assertEquals(1, status.getData().get(0).getFaults().getMinors().intValue());
+ assertEquals(0, status.getData().get(0).getFaults().getWarnings().intValue());
+
+ faultCurrent1 = new FaultcurrentBuilder().setNodeId(NODEID1).setCounter(1).setObjectId("obj")
+ .setProblem(PROBLEM1).setTimestamp(DateAndTime.getDefaultInstance(TIME1))
+ .setSeverity(SeverityType.NonAlarmed).setId(String.format("%s/%s", NODEID1, PROBLEM1)).build();
+ dbProvider.updateFaultCurrent(faultCurrent1);
+ faultCurrents = dbProvider.readFaultCurrentList(createInput("node-id", NODEID1, 1, 20));
+ assertEquals(1, faultCurrents.getData().size());
+ }
+
+ @Test
+ public void testFaultlog() {
+ try {
+ dbClient.delete(new DeleteQuery(Entity.Faultcurrent, null).toSql());
+ } catch (SQLException e) {
+ e.printStackTrace();
+ fail("problem clearing faultlog");
+ }
+ ReadFaultlogListOutputBuilder faultlogs = dbProvider.readFaultLogList(createInput(1, 20));
+ assertEquals(0, faultlogs.getData().size());
+ FaultlogEntity fault1 = new FaultlogBuilder().setCounter(1).setNodeId(NODEID1).setObjectId("obj")
+ .setProblem(PROBLEM1).setSeverity(SeverityType.Major).setSourceType(SourceType.Netconf)
+ .setTimestamp(DateAndTime.getDefaultInstance(TIME1)).build();
+ dbProvider.writeFaultLog(fault1);
+ FaultlogEntity fault2 = new FaultlogBuilder().setCounter(2).setNodeId(NODEID1).setObjectId("obj")
+ .setProblem(PROBLEM2).setSeverity(SeverityType.Major).setSourceType(SourceType.Netconf)
+ .setTimestamp(DateAndTime.getDefaultInstance(TIME1)).build();
+ dbProvider.writeFaultLog(fault2);
+ faultlogs = dbProvider.readFaultLogList(createInput("node-id", NODEID1, 1, 20));
+ assertEquals(2, faultlogs.getData().size());
+ }
+
+ @Test
+ public void testConnectionlog() {
+ try {
+ dbClient.delete(new DeleteQuery(Entity.Connectionlog, null).toSql());
+ } catch (SQLException e) {
+ e.printStackTrace();
+ fail("problem clearing faultlog");
+ }
+ ReadConnectionlogListOutputBuilder logs = dbProvider.readConnectionlogList(createInput(1, 20));
+ assertEquals(0, logs.getData().size());
+ ConnectionlogEntity log1 = new ConnectionlogBuilder().setNodeId(NODEID1)
+ .setTimestamp(DateAndTime.getDefaultInstance(TIME1)).setStatus(ConnectionLogStatus.Mounted).build();
+ dbProvider.writeConnectionLog(log1);
+ ConnectionlogEntity log2 = new ConnectionlogBuilder().setNodeId(NODEID1)
+ .setTimestamp(DateAndTime.getDefaultInstance(TIME2)).setStatus(ConnectionLogStatus.Connecting).build();
+ dbProvider.writeConnectionLog(log2);
+ ConnectionlogEntity log3 = new ConnectionlogBuilder().setNodeId(NODEID1)
+ .setTimestamp(DateAndTime.getDefaultInstance(TIME3)).setStatus(ConnectionLogStatus.Connected).build();
+ dbProvider.writeConnectionLog(log3);
+ logs = dbProvider.readConnectionlogList(createInput(1, 20));
+ assertEquals(3, logs.getData().size());
+ }
+
+ @Test
+ public void testEventlog() {
+ try {
+ dbClient.delete(new DeleteQuery(Entity.Eventlog, null).toSql());
+ } catch (SQLException e) {
+ e.printStackTrace();
+ fail("problem clearing faultlog");
+ }
+ ReadEventlogListOutputBuilder logs = null;
+ try {
+ logs = dbProvider.readEventlogList(createInput(1, 20));
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ assertEquals(0, logs.getData().size());
+ EventlogEntity log1 = new EventlogBuilder().setCounter(1).setNodeId(NODEID1).setObjectId("obj")
+ .setTimestamp(DateAndTime.getDefaultInstance(TIME1)).setAttributeName("attr").setNewValue("new-value")
+ .setSourceType(SourceType.Netconf).build();
+ dbProvider.writeEventLog(log1);
+ EventlogEntity log2 = new EventlogBuilder().setCounter(1).setNodeId(NODEID1).setObjectId("obj")
+ .setTimestamp(DateAndTime.getDefaultInstance(TIME2)).setAttributeName("attr").setNewValue("new-value2")
+ .setSourceType(SourceType.Netconf).build();
+ dbProvider.writeEventLog(log2);
+ EventlogEntity log3 = new EventlogBuilder().setCounter(1).setNodeId(NODEID1).setObjectId("obj")
+ .setTimestamp(DateAndTime.getDefaultInstance(TIME3)).setAttributeName("attr").setNewValue("new-value3")
+ .setSourceType(SourceType.Netconf).build();
+ dbProvider.writeEventLog(log3);
+ try {
+ logs = dbProvider.readEventlogList(createInput(1, 20));
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ assertEquals(3, logs.getData().size());
+ }
+
+ @Test
+ public void testGuicutthrough() {
+ try {
+ dbClient.delete(new DeleteQuery(Entity.Guicutthrough, null).toSql());
+ } catch (SQLException e) {
+ e.printStackTrace();
+ fail("problem clearing faultlog");
+ }
+ Guicutthrough gc1 = new GuicutthroughBuilder().setName(NODEID1).setWeburi(URI1).build();
+ dbProvider.writeGuiCutThroughData(gc1, NODEID1);
+ Guicutthrough gc2 = new GuicutthroughBuilder().setName(NODEID2).setWeburi(URI2).build();
+ dbProvider.writeGuiCutThroughData(gc2, NODEID2);
+ Guicutthrough gc3 = new GuicutthroughBuilder().setName(NODEID3).setWeburi(URI3).build();
+ dbProvider.writeGuiCutThroughData(gc3, NODEID3);
+ ReadGuiCutThroughEntryOutputBuilder data = dbProvider.readGuiCutThroughEntry(createInput(1, 20));
+ assertEquals(3, data.getData().size());
+ data = dbProvider.readGuiCutThroughEntry(createInput("name", NODEID1, 1, 20));
+ assertEquals(1, data.getData().size());
+
+ }
+
+ @Test
+ public void testInventory() {
+ try {
+ dbClient.delete(new DeleteQuery(Entity.Inventoryequipment, null).toSql());
+ } catch (SQLException e) {
+ e.printStackTrace();
+ fail("problem clearing faultlog");
+ }
+ ReadInventoryListOutputBuilder data = dbProvider.readInventoryList(createInput(1, 20));
+ assertEquals(0, data.getData().size());
+ List<Inventory> list = null;
+ try {
+ list = loadListFile("/inventory.json", Inventory.class);
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail("problem loading inventory data");
+
+ }
+ dbProvider.writeInventory(NODEID1, list);
+ data = dbProvider.readInventoryList(createInput(1, 50));
+ assertEquals(22, data.getData().size());
+ data = dbProvider.readInventoryList(createInput("tree-level", "0", 1, 50));
+ assertEquals(5, data.getData().size());
+ }
+
+ @Test
+ public void testMaintenance() {
+ try {
+ dbClient.delete(new DeleteQuery(Entity.Maintenancemode, null).toSql());
+ } catch (SQLException e) {
+ e.printStackTrace();
+ fail("problem clearing faultlog");
+ }
+ ReadMaintenanceListOutputBuilder data = dbProvider.readMaintenanceList(createInput(1, 20));
+ assertEquals(0, data.getData().size());
+ CreateMaintenanceInput maint1 = new CreateMaintenanceInputBuilder().setId(NODEID1).setNodeId(NODEID1)
+ .setActive(true).setDescription("desc").setObjectIdRef("ref").setProblem("problem")
+ .setStart(DateAndTime.getDefaultInstance(TIME1)).setEnd(DateAndTime.getDefaultInstance(TIME3)).build();
+ CreateMaintenanceInput maint2 = new CreateMaintenanceInputBuilder().setId(NODEID2).setNodeId(NODEID2)
+ .setActive(true).setDescription("desc").setObjectIdRef("ref").setProblem("problem2")
+ .setStart(DateAndTime.getDefaultInstance(TIME1)).setEnd(DateAndTime.getDefaultInstance(TIME3)).build();
+ CreateMaintenanceInput maint3 = new CreateMaintenanceInputBuilder().setId(NODEID3).setNodeId(NODEID3)
+ .setActive(true).setDescription("desc").setObjectIdRef("ref").setProblem("problem3")
+ .setStart(DateAndTime.getDefaultInstance(TIME1)).setEnd(DateAndTime.getDefaultInstance(TIME3)).build();
+ try {
+ dbProvider.createMaintenance(maint1);
+ dbProvider.createMaintenance(maint2);
+ dbProvider.createMaintenance(maint3);
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail("unable to create maintenance data");
+ }
+ data = dbProvider.readMaintenanceList(createInput(1, 20));
+ assertEquals(3, data.getData().size());
+
+ }
+
+ @Test
+ public void testMediatorserver() {
+ try {
+ dbClient.delete(new DeleteQuery(Entity.MediatorServer, null).toSql());
+ } catch (SQLException e) {
+ e.printStackTrace();
+ fail("problem clearing mediator server");
+ }
+ ReadMediatorServerListOutputBuilder data = dbProvider.readMediatorServerList(createInput(1, 20));
+ assertEquals(0, data.getData().size());
+ CreateMediatorServerInput mediator1 =
+ new CreateMediatorServerInputBuilder().setName("server1").setUrl("http://10.20.30.40:7070").build();
+ CreateMediatorServerInput mediator2 =
+ new CreateMediatorServerInputBuilder().setName("server2").setUrl("http://10.20.30.42:7070").build();
+ CreateMediatorServerInput mediator3 =
+ new CreateMediatorServerInputBuilder().setName("server3").setUrl("http://10.20.30.43:7070").build();
+ CreateMediatorServerOutputBuilder output1 = null, output2 = null;
+ try {
+ output1 = dbProvider.createMediatorServer(mediator1);
+ output2 = dbProvider.createMediatorServer(mediator2);
+ dbProvider.createMediatorServer(mediator3);
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail("problem creating mediator servers");
+ }
+ data = dbProvider.readMediatorServerList(createInput(1, 20));
+ assertEquals(3, data.getData().size());
+ UpdateMediatorServerInput update1 = new UpdateMediatorServerInputBuilder().setId(output1.getId())
+ .setName("server1").setUrl("http://10.20.30.40:7071").build();
+ try {
+ dbProvider.updateMediatorServer(update1);
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail("failed to update mediator server");
+ }
+ data = dbProvider.readMediatorServerList(createInput("id", output1.getId(), 1, 20));
+ assertEquals(1, data.getData().size());
+ assertEquals(output1.getId(), data.getData().get(0).getId());
+ assertEquals("server1", data.getData().get(0).getName());
+ assertEquals("http://10.20.30.40:7071", data.getData().get(0).getUrl());
+
+ DeleteMediatorServerInput delete2 = new DeleteMediatorServerInputBuilder().setId(output2.getId()).build();
+ try {
+ dbProvider.deleteMediatorServer(delete2);
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail("unable to delete mediator server");
+ }
+ data = dbProvider.readMediatorServerList(createInput("id", output2.getId(), 1, 20));
+ assertEquals(0, data.getData().size());
+ data = dbProvider.readMediatorServerList(createInput(1, 20));
+ assertEquals(2, data.getData().size());
+ }
+
+ @Test
+ public void testNeConnection() {
+ try {
+ dbClient.delete(new DeleteQuery(Entity.NetworkelementConnection, null).toSql());
+ } catch (SQLException e) {
+ e.printStackTrace();
+ fail("problem clearing neconnection");
+ }
+ ReadNetworkElementConnectionListOutputBuilder data =
+ dbProvider.readNetworkElementConnectionList(createInput(1, 20));
+ assertEquals(0, data.getData().size());
+ NetworkElementConnectionEntity ne1 = new NetworkElementConnectionBuilder().setNodeId(NODEID1)
+ .setHost("10.20.30.50").setPort(Uint32.valueOf(8300)).setIsRequired(true).setUsername("user")
+ .setPassword("passwd").build();
+ NetworkElementConnectionEntity ne2 = new NetworkElementConnectionBuilder().setNodeId(NODEID2)
+ .setHost("10.20.30.55").setPort(Uint32.valueOf(8300)).setIsRequired(false).setUsername("user")
+ .setPassword("passwd").setStatus(ConnectionLogStatus.Connecting).build();
+ try {
+ dbProvider.createNetworkElementConnection(ne1);
+ dbProvider.createNetworkElementConnection(ne2);
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail("problem creating neconnection");
+ }
+ data = dbProvider.readNetworkElementConnectionList(createInput(1, 20));
+ assertEquals(2, data.getData().size());
+ NetworkElementConnectionEntity update1 = new NetworkElementConnectionBuilder()
+ .setStatus(ConnectionLogStatus.Connected).setDeviceType(NetworkElementDeviceType.ORAN).build();
+ dbProvider.updateNetworkConnectionDeviceType(update1, NODEID1);
+ data = dbProvider.readNetworkElementConnectionList(createInput("node-id", NODEID1, 1, 20));
+ assertEquals(1, data.getData().size());
+ assertEquals(NetworkElementDeviceType.ORAN, data.getData().get(0).getDeviceType());
+ assertEquals(true, data.getData().get(0).isIsRequired());
+ UpdateNetworkElementConnectionInput update2 = new UpdateNetworkElementConnectionInputBuilder().setId(NODEID2)
+ .setHost("10.20.55.44").setIsRequired(true).build();
+ try {
+ dbProvider.updateNetworkElementConnection(update2);
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail("failed to update neconnection");
+ }
+ data = dbProvider.readNetworkElementConnectionList(createInput("node-id", NODEID2, 1, 20));
+ assertEquals(1, data.getData().size());
+ assertEquals("10.20.55.44", data.getData().get(0).getHost());
+ assertEquals(true, data.getData().get(0).isIsRequired());
+
+ ReadStatusOutputBuilder status = null;
+ try {
+ status = dbProvider.readStatus();
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail("failed to read status");
+ }
+ assertEquals(1, status.getData().get(0).getNetworkElementConnections().getConnected().intValue());
+ assertEquals(1, status.getData().get(0).getNetworkElementConnections().getConnecting().intValue());
+ assertEquals(0, status.getData().get(0).getNetworkElementConnections().getDisconnected().intValue());
+ assertEquals(0, status.getData().get(0).getNetworkElementConnections().getMounted().intValue());
+ assertEquals(2, status.getData().get(0).getNetworkElementConnections().getTotal().intValue());
+ assertEquals(0, status.getData().get(0).getNetworkElementConnections().getUnableToConnect().intValue());
+ assertEquals(0, status.getData().get(0).getNetworkElementConnections().getUndefined().intValue());
+ assertEquals(0, status.getData().get(0).getNetworkElementConnections().getUnmounted().intValue());
+
+
+ DeleteNetworkElementConnectionInput delete1 =
+ new DeleteNetworkElementConnectionInputBuilder().setId(NODEID1).build();
+ try {
+ dbProvider.deleteNetworkElementConnection(delete1);
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail("failed to delete neconnection");
+ }
+ data = dbProvider.readNetworkElementConnectionList(createInput("node-id", NODEID1, 1, 20));
+ assertEquals(0, data.getData().size());
+ data = dbProvider.readNetworkElementConnectionList(createInput(1, 20));
+ assertEquals(1, data.getData().size());
+ }
+
+ @Test
+ public void testpm15m() {
+ try {
+ dbClient.delete(new DeleteQuery(Entity.Historicalperformance15min, null).toSql());
+ } catch (SQLException e) {
+ e.printStackTrace();
+ fail("problem clearing pmdata15m");
+ }
+ ReadPmdata15mListOutputBuilder data = dbProvider.readPmdata15mList(createInput(1, 20));
+ assertEquals(0, data.getData().size());
+ List<PmdataEntity> list = null;
+ try {
+ list = loadListFile("/pmdata15m.json", PmdataEntity.class);
+ } catch (JSONException | IOException e) {
+ e.printStackTrace();
+ fail("failed to load pmdata15m");
+ }
+ dbProvider.doWritePerformanceData(list);
+ data = dbProvider.readPmdata15mList(createInput(1, 20));
+ assertEquals(10, data.getData().size());
+ ReadPmdata15mLtpListOutputBuilder ltpdata = null;
+ try {
+ ltpdata = dbProvider.readPmdata15mLtpList(createInput("node-name","sim12600",1, 20));
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail("failed to read pmdata15m ltp list");
+ }
+ assertEquals(3, ltpdata.getData().size());
+ ReadPmdata15mDeviceListOutputBuilder devicedata = null;
+ try {
+ devicedata = dbProvider.readPmdata15mDeviceList(createInput(1,20));
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail("failed to read pmdata15m devices list");
+ }
+ assertEquals(1, devicedata.getData().size());
+ }
+
+ @Ignore
+ @Test
+ public void testpm24h() {
+ try {
+ dbClient.delete(new DeleteQuery(Entity.Historicalperformance24h, null).toSql());
+ } catch (SQLException e) {
+ e.printStackTrace();
+ fail("problem clearing pmdata24h");
+ }
+ ReadPmdata24hListOutputBuilder data = dbProvider.readPmdata24hList(createInput(1, 20));
+ assertEquals(0, data.getData().size());
+ List<PmdataEntity> list = null;
+ try {
+ list = loadListFile("/pmdata24h.json", PmdataEntity.class);
+ } catch (JSONException | IOException e) {
+ e.printStackTrace();
+ fail("failed to load pmdata24h");
+ }
+ dbProvider.doWritePerformanceData(list);
+ }
+
+ private static EntityInput createInput(int page, int size) {
+ return createInput(null, null, page, size);
+ }
+
+ private static <T> List<T> loadListFile(String filename, Class<T> clazz) throws JSONException, IOException {
+ List<T> list = new ArrayList<>();
+ JSONArray a = new JSONArray(loadFile(filename));
+ for (int i = 0; i < a.length(); i++) {
+ list.add(loadData(a.getJSONObject(i).toString(), clazz));
+ }
+ return list;
+ }
+
+ private static <T> T loadData(String content, Class<T> clazz) throws IOException {
+ YangToolsMapper mapper = new YangToolsMapper();
+ return mapper.readValue(content, clazz);
+ }
+
+ private static String loadFile(String filename) throws IOException {
+ return String.join("\n", IoUtils.readAllLines(TestMariaDataProvider.class.getResourceAsStream(filename)));
+ }
+
+ private static EntityInput createInput(String filter, String filterValue, int page, int size) {
+ ReadFaultcurrentListInputBuilder builder = new ReadFaultcurrentListInputBuilder().setPagination(
+ new PaginationBuilder().setPage(Uint64.valueOf(page)).setSize(Uint32.valueOf(size)).build());
+ if (filter != null && filterValue != null) {
+ Filter f = new FilterBuilder().setProperty(filter).setFiltervalue(filterValue).build();
+ Map<FilterKey, Filter> fmap = new HashMap<>();
+ fmap.put(f.key(), f);
+ builder.setFilter(fmap);
+ }
+ return builder.build();
+ }
+
+}
diff --git a/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestQuerySyntax.java b/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestQuerySyntax.java
new file mode 100644
index 000000000..758b72f9c
--- /dev/null
+++ b/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestQuerySyntax.java
@@ -0,0 +1,157 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : ccsdk features
+ * ================================================================================
+ * Copyright (C) 2020 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.dataprovider.dblib.test;
+
+import static org.junit.Assert.assertTrue;
+import java.util.HashMap;
+import java.util.Map;
+import org.junit.Test;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.query.SelectQuery;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EntityInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadEventlogListInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.entity.input.Filter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.entity.input.FilterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.entity.input.FilterKey;
+
+public class TestQuerySyntax {
+
+
+ private static final String TABLENAME1 = "table1";
+ private static final String CONTROLLERID = "controllerid1";
+
+ @Test
+ public void testTimestampFilter() {
+ Map<FilterKey, Filter> filterMap = new HashMap<>();
+ Filter filter = new FilterBuilder().setProperty("timestamp").setFiltervalue("2021*").build();
+ filterMap.put(filter.key(), filter);
+ EntityInput input = new ReadEventlogListInputBuilder().setFilter(filterMap).build();
+ SelectQuery query = new SelectQuery(TABLENAME1, input, CONTROLLERID);
+ final String sql = query.toSql();
+ assertTrue(sql.contains("`timestamp`>='2021-01-01 00:00:00.000'"));
+ assertTrue(sql.contains("`timestamp`<'2022-01-01 00:00:00.0'"));
+ }
+
+ @Test
+ public void testTimestampFilter2() {
+ Map<FilterKey, Filter> filterMap = new HashMap<>();
+ Filter filter = new FilterBuilder().setProperty("timestamp").setFiltervalue(">2021").build();
+ filterMap.put(filter.key(), filter);
+ EntityInput input = new ReadEventlogListInputBuilder().setFilter(filterMap).build();
+ SelectQuery query = new SelectQuery(TABLENAME1, input, CONTROLLERID);
+ final String sql = query.toSql();
+ assertTrue(sql.contains("`timestamp`>='2022-01-01 00:00:00.0'"));
+ }
+
+ @Test
+ public void testTimestampFilter3() {
+ Map<FilterKey, Filter> filterMap = new HashMap<>();
+ Filter filter = new FilterBuilder().setProperty("timestamp").setFiltervalue(">=2021").build();
+ filterMap.put(filter.key(), filter);
+ EntityInput input = new ReadEventlogListInputBuilder().setFilter(filterMap).build();
+ SelectQuery query = new SelectQuery(TABLENAME1, input, CONTROLLERID);
+ final String sql = query.toSql();
+ assertTrue(sql.contains("`timestamp`>='2021-01-01 00:00:00.000'"));
+
+ }
+
+ @Test
+ public void testTimestampFilter4() {
+ Map<FilterKey, Filter> filterMap = new HashMap<>();
+ Filter filter = new FilterBuilder().setProperty("timestamp").setFiltervalue("<2021").build();
+ filterMap.put(filter.key(), filter);
+ EntityInput input = new ReadEventlogListInputBuilder().setFilter(filterMap).build();
+ SelectQuery query = new SelectQuery(TABLENAME1, input, CONTROLLERID);
+ final String sql = query.toSql();
+ assertTrue(sql.contains("`timestamp`<'2021-01-01 00:00:00.000'"));
+ }
+
+ @Test
+ public void testTimestampFilter5() {
+ Map<FilterKey, Filter> filterMap = new HashMap<>();
+ Filter filter = new FilterBuilder().setProperty("timestamp").setFiltervalue("<=2021").build();
+ filterMap.put(filter.key(), filter);
+ EntityInput input = new ReadEventlogListInputBuilder().setFilter(filterMap).build();
+ SelectQuery query = new SelectQuery(TABLENAME1, input, CONTROLLERID);
+ final String sql = query.toSql();
+ assertTrue(sql.contains("`timestamp`<'2022-01-01 00:00:00.0'"));
+ }
+
+ @Test
+ public void testTimestampFilter6() {
+ Map<FilterKey, Filter> filterMap = new HashMap<>();
+ Filter filter =
+ new FilterBuilder().setProperty("timestamp").setFiltervalue(">=2022-01-01T00:00:00.000Z").build();
+ filterMap.put(filter.key(), filter);
+ EntityInput input = new ReadEventlogListInputBuilder().setFilter(filterMap).build();
+ SelectQuery query = new SelectQuery(TABLENAME1, input, CONTROLLERID);
+ final String sql = query.toSql();
+ assertTrue(sql.contains("`timestamp`>='2022-01-01 00:00:00.000'"));
+ }
+
+ @Test
+ public void testTimestampFilter8() {
+ Map<FilterKey, Filter> filterMap = new HashMap<>();
+ Filter filter =
+ new FilterBuilder().setProperty("timestamp").setFiltervalue(">2022-01-01T00:00:00.000Z").build();
+ filterMap.put(filter.key(), filter);
+ EntityInput input = new ReadEventlogListInputBuilder().setFilter(filterMap).build();
+ SelectQuery query = new SelectQuery(TABLENAME1, input, CONTROLLERID);
+ final String sql = query.toSql();
+ assertTrue(sql.contains("`timestamp`>'2022-01-01 00:00:00.000'"));
+ }
+
+ @Test
+ public void testTimestampFilter9() {
+ Map<FilterKey, Filter> filterMap = new HashMap<>();
+ Filter filter =
+ new FilterBuilder().setProperty("timestamp").setFiltervalue("<2022-01-01T00:00:00.000Z").build();
+ filterMap.put(filter.key(), filter);
+ EntityInput input = new ReadEventlogListInputBuilder().setFilter(filterMap).build();
+ SelectQuery query = new SelectQuery(TABLENAME1, input, CONTROLLERID);
+ final String sql = query.toSql();
+ assertTrue(sql.contains("`timestamp`<'2022-01-01 00:00:00.000'"));
+ }
+
+ @Test
+ public void testTimestampFilter10() {
+ Map<FilterKey, Filter> filterMap = new HashMap<>();
+ Filter filter =
+ new FilterBuilder().setProperty("timestamp").setFiltervalue("<=2022-01-01T00:00:00.000Z").build();
+ filterMap.put(filter.key(), filter);
+ EntityInput input = new ReadEventlogListInputBuilder().setFilter(filterMap).build();
+ SelectQuery query = new SelectQuery(TABLENAME1, input, CONTROLLERID);
+ final String sql = query.toSql();
+ assertTrue(sql.contains("`timestamp`<='2022-01-01 00:00:00.000'"));
+ }
+
+ @Test
+ public void testTimestampFilter11() {
+ Map<FilterKey, Filter> filterMap = new HashMap<>();
+ Filter filter =
+ new FilterBuilder().setProperty("timestamp").setFiltervalue("<=2022-01-01T00:00:00.000222Z").build();
+ filterMap.put(filter.key(), filter);
+ EntityInput input = new ReadEventlogListInputBuilder().setFilter(filterMap).build();
+ SelectQuery query = new SelectQuery(TABLENAME1, input, CONTROLLERID);
+ final String sql = query.toSql();
+ assertTrue(sql.contains("`timestamp`<='2022-01-01 00:00:00.000'"));
+ }
+}
diff --git a/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/util/MariaDBTestBase.java b/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/util/MariaDBTestBase.java
new file mode 100644
index 000000000..b065519f8
--- /dev/null
+++ b/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/util/MariaDBTestBase.java
@@ -0,0 +1,192 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : ccsdk features
+ * ================================================================================
+ * Copyright (C) 2021 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.dataprovider.dblib.test.util;
+
+import static org.junit.Assert.fail;
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Random;
+import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation;
+import org.onap.ccsdk.features.sdnr.wt.common.configuration.subtypes.Section;
+import org.onap.ccsdk.features.sdnr.wt.common.configuration.subtypes.Section.EnvGetter;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.SqlDBClient;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.SqlDBConfig;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.data.SqlDBDataProvider;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.database.SqlDBMapper;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.database.SqlDBMapper.UnableToMapClassException;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ConnectionlogEntity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Entity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogEntity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultcurrentEntity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultlogEntity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.GuicutthroughEntity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.InventoryEntity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.MaintenanceEntity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.MediatorServerEntity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementConnectionEntity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Pmdata15mEntity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Pmdata24hEntity;
+import ch.vorburger.exec.ManagedProcessException;
+import ch.vorburger.mariadb4j.DB;
+import ch.vorburger.mariadb4j.DBConfigurationBuilder;
+
+public class MariaDBTestBase {
+
+ private final SqlDBDataProvider dbProvider;
+ private final DB db;
+ private SqlDBConfig config;
+ private static final Map<String, String> envDefaultValues = initEnvDefaultValues();
+ private static final String SDNRDBDATABASETEST = "test";
+
+ public MariaDBTestBase() throws ManagedProcessException {
+ this(new Random().nextInt(1000) + 50000);
+ }
+
+ private static String dbUrl(String host, int port, String dbName) {
+ return String.format("jdbc:mysql://%s:%d/%s", host, port, dbName);
+ }
+
+ private static Map<String, String> initEnvDefaultValues() {
+ Map<String, String> defaults = new HashMap<>();
+ defaults.put("SDNRDBURL", dbUrl("localhost", 3306, SDNRDBDATABASETEST));
+ defaults.put("SDNRDBDATABASE", "test");
+
+ return defaults;
+ }
+
+ public MariaDBTestBase(String host, int port) {
+ this(host, port, SDNRDBDATABASETEST);
+ }
+
+ public MariaDBTestBase(String host, int port, String dbName) {
+ EnvGetter env = Section.getEnvGetter();
+ envDefaultValues.put("SDNRDBURL", dbUrl(host, port, dbName));
+ envDefaultValues.put("SDNRDBUSERNAME", "sdnrdb");
+ envDefaultValues.put("SDNRDBPASSWORD", "sdnrdb");
+ Section.setEnvGetter((envname) -> {
+ return envDefaultValues.getOrDefault(envname, env.getenv(envname));
+ });
+ this.config = new SqlDBConfig(new ConfigurationFileRepresentation("test.properties"));
+ this.config.setDbSuffix("");
+ this.config.setControllerId("test123");
+ this.db = null;
+ this.dbProvider = new SqlDBDataProvider(config, false);
+ }
+
+ public MariaDBTestBase(int port) throws ManagedProcessException {
+ EnvGetter env = Section.getEnvGetter();
+ envDefaultValues.put("SDNRDBURL", dbUrl("localhost", port, SDNRDBDATABASETEST));
+ Section.setEnvGetter((envname) -> {
+ return envDefaultValues.getOrDefault(envname, env.getenv(envname));
+ });
+ this.config = new SqlDBConfig(new ConfigurationFileRepresentation("test.properties"));
+ this.config.setDbSuffix("");
+ this.config.setControllerId("test123");
+ //start db server
+ this.db = startDatabase(port);
+ //create db with name sdnrdb
+ this.dbProvider = new SqlDBDataProvider(config, false);
+ }
+
+ public void close() throws ManagedProcessException {
+ if (db != null) {
+ this.db.stop();
+ }
+ File f = new File("test.properties");
+ if(f.exists()) {
+ f.delete();
+ }
+ }
+
+ public SqlDBDataProvider getDbProvider() {
+ return dbProvider;
+ }
+
+ public DB getDb() {
+ return db;
+ }
+
+ private static DB startDatabase(int port) throws ManagedProcessException {
+ // Start MariaDB4j database
+ DBConfigurationBuilder dbconfig = DBConfigurationBuilder.newBuilder();
+ dbconfig.setPort(port); // 0 => autom. detect free port
+ DB db = DB.newEmbeddedDB(dbconfig.build());
+ db.start();
+ return db;
+ }
+
+ public String getDBUrl() {
+ return envDefaultValues.get("SDNRDBURL");
+ }
+
+ public String getDBUsername() {
+ return envDefaultValues.getOrDefault("SDNRDBUSERNAME", "");
+ }
+
+ public String getDBPassword() {
+ return envDefaultValues.getOrDefault("SDNRDBPASSWORD", "");
+ }
+
+ public SqlDBClient createRawClient() {
+ return new SqlDBClient(this.config.getUrl(), this.config.getUsername(), this.config.getPassword());
+ }
+
+ public String getDBName() {
+ String url = this.getDBUrl();
+ return url.substring(url.lastIndexOf("/") + 1);
+ }
+
+ public static void testCreateTableStructure(SqlDBClient dbService) {
+ createTableOdl(dbService);
+ createTable(dbService, ConnectionlogEntity.class, Entity.Connectionlog, true);
+ createTable(dbService, EventlogEntity.class, Entity.Eventlog, true);
+ createTable(dbService, FaultcurrentEntity.class, Entity.Faultcurrent, false);
+ createTable(dbService, FaultlogEntity.class, Entity.Faultlog, true);
+ createTable(dbService, GuicutthroughEntity.class, Entity.Guicutthrough, false);
+ createTable(dbService, Pmdata15mEntity.class, Entity.Historicalperformance15min, false);
+ createTable(dbService, Pmdata24hEntity.class, Entity.Historicalperformance24h, false);
+ createTable(dbService, InventoryEntity.class, Entity.Inventoryequipment, false);
+ createTable(dbService, MaintenanceEntity.class, Entity.Maintenancemode, false);
+ createTable(dbService, MediatorServerEntity.class, Entity.MediatorServer, true);
+ createTable(dbService, NetworkElementConnectionEntity.class, Entity.NetworkelementConnection, false);
+ }
+
+ public static boolean createTableOdl(SqlDBClient dbService) {
+ String createStatement = null;
+ createStatement = SqlDBMapper.createTableOdl();
+ System.out.println(createStatement);
+ return dbService.createTable(createStatement);
+ }
+
+ public static boolean createTable(SqlDBClient dbService, Class<?> cls, Entity entity, boolean autoIndex) {
+ String createStatement = null;
+ try {
+ createStatement = SqlDBMapper.createTable(cls, entity, "", autoIndex);
+ } catch (UnableToMapClassException e) {
+ fail(e.getMessage());
+ }
+ System.out.println(createStatement);
+ return dbService.createTable(createStatement);
+ }
+}
+
diff --git a/sdnr/wt/data-provider/dblib/src/test/resources/inventory.json b/sdnr/wt/data-provider/dblib/src/test/resources/inventory.json
new file mode 100644
index 000000000..9a29325dc
--- /dev/null
+++ b/sdnr/wt/data-provider/dblib/src/test/resources/inventory.json
@@ -0,0 +1,381 @@
+[
+ {
+ "description": "WS/p8.module/a2.module#5",
+ "date": "2013-04-13T00:00:00.0Z",
+ "version": "a2.module-newest",
+ "node-id": "sim1",
+ "uuid": "a2.module-1.1.5.5",
+ "parent-uuid": "CARD-1.1.5.0",
+ "contained-holder": [
+ "SUBRACK-1.55.0.0"
+ ],
+ "tree-level": 2,
+ "manufacturer-identifier": "ONF-Wireless-Transport",
+ "serial": "310330015",
+ "part-type-id": "3EM23141AD01",
+ "model-identifier": "CRPQABVFAA",
+ "type-name": "a2.module"
+ },
+ {
+ "description": "WS/DS1",
+ "date": "2007-08-27T00:00:00.0Z",
+ "version": "p1.module",
+ "node-id": "sim1",
+ "uuid": "CARD-1.1.7.0",
+ "parent-uuid": "SHELF-1.1.0.0",
+ "contained-holder": [],
+ "tree-level": 1,
+ "manufacturer-identifier": "CIT",
+ "serial": "serial-number-s3s",
+ "part-type-id": "part-number-s3s",
+ "model-identifier": "model-id-s3s",
+ "type-name": "p1.module_A"
+ },
+ {
+ "description": "MWR#55Ch#1/a2.moduletraff",
+ "date": "2013-04-13T00:00:00.0Z",
+ "version": "a2.module-newest",
+ "node-id": "sim1",
+ "uuid": "a2.module-1.55.1.2",
+ "parent-uuid": "IDU-1.55.0.0",
+ "contained-holder": [],
+ "tree-level": 1,
+ "manufacturer-identifier": "ONF-Wireless-Transport",
+ "serial": "310330015",
+ "part-type-id": "3EM23141AD01",
+ "model-identifier": "CRPQABVFAA",
+ "type-name": "a2.module"
+ },
+ {
+ "description": "MWR#65Ch#1/a2.moduletraff",
+ "date": "2013-04-13T00:00:00.0Z",
+ "version": "a2.module-newest",
+ "node-id": "sim1",
+ "uuid": "a2.module-1.65.1.2",
+ "parent-uuid": "IDU-1.65.0.0",
+ "contained-holder": [],
+ "tree-level": 1,
+ "manufacturer-identifier": "ONF-Wireless-Transport",
+ "serial": "310330008",
+ "part-type-id": "3EM23141AD01",
+ "model-identifier": "CRPQABVFAA",
+ "type-name": "a2.module"
+ },
+ {
+ "description": "WS-8",
+ "date": "2017-09-09T00:00:00.0Z",
+ "version": "a2.module-newest",
+ "node-id": "sim1",
+ "uuid": "SHELF-1.1.0.0",
+ "parent-uuid": "network-element",
+ "contained-holder": [
+ "SLOT-1.1.1.0",
+ "SLOT-1.1.2.0",
+ "SLOT-1.1.3.0",
+ "SLOT-1.1.4.0",
+ "SLOT-1.1.5.0",
+ "SLOT-1.1.6.0",
+ "SLOT-1.1.7.0",
+ "SLOT-1.1.8.0",
+ "SLOT-1.1.9.0"
+ ],
+ "tree-level": 0,
+ "manufacturer-identifier": "ONF-Wireless-Transport",
+ "serial": "Serial1",
+ "part-type-id": "Partnumber",
+ "model-identifier": "model-id",
+ "type-name": "WS-8"
+ },
+ {
+ "description": "WS/CORE-MAIN/a2.module#5",
+ "date": "2005-11-09T00:00:00.0Z",
+ "version": "a2.module-newest",
+ "node-id": "sim1",
+ "uuid": "a2.module-1.1.1.5",
+ "parent-uuid": "CARD-1.1.1.0",
+ "contained-holder": [
+ "SUBRACK-1.15.0.0"
+ ],
+ "tree-level": 2,
+ "manufacturer-identifier": "ONF-Wireless-Transport",
+ "serial": "0003548168",
+ "part-type-id": "3FE25774AA01",
+ "model-identifier": "VAUIAEYAAA",
+ "type-name": "a2.module"
+ },
+ {
+ "description": "WS/CORE-MAIN/a2.module#8",
+ "date": "2010-02-05T00:00:00.0Z",
+ "version": "a2.module-newest",
+ "node-id": "sim1",
+ "uuid": "a2.module-1.1.1.8",
+ "parent-uuid": "CARD-1.1.1.0",
+ "contained-holder": [
+ "SUBRACK-1.18.0.0"
+ ],
+ "tree-level": 2,
+ "manufacturer-identifier": "ONF-Wireless-Transport",
+ "serial": "01T441601301",
+ "part-type-id": "1AB376720002",
+ "model-identifier": "NGI7AMLMAA",
+ "type-name": "a2.module"
+ },
+ {
+ "description": "WS/p8.module/a2.module#5",
+ "date": "2013-04-13T00:00:00.0Z",
+ "version": "a2.module-newest",
+ "node-id": "sim1",
+ "uuid": "a2.module-1.1.6.5",
+ "parent-uuid": "CARD-1.1.6.0",
+ "contained-holder": [
+ "SUBRACK-1.65.0.0"
+ ],
+ "tree-level": 2,
+ "manufacturer-identifier": "ONF-Wireless-Transport",
+ "serial": "310330008",
+ "part-type-id": "3EM23141AD01",
+ "model-identifier": "CRPQABVFAA",
+ "type-name": "a2.module"
+ },
+ {
+ "description": "MWR-hyper Dir#5.6-Ch#1",
+ "date": "",
+ "version": "extrem-hyper",
+ "node-id": "sim1",
+ "uuid": "ODU-1.56.0.0",
+ "parent-uuid": "network-element",
+ "contained-holder": [
+ "PORT-1.56.1.2",
+ "PORT-1.56.1.3",
+ "PORT-1.56.1.4"
+ ],
+ "tree-level": 0,
+ "manufacturer-identifier": "",
+ "serial": "",
+ "part-type-id": "",
+ "model-identifier": "",
+ "type-name": "MWR-hyper"
+ },
+ {
+ "description": "MWR#56Ch#1/a2.moduletraff",
+ "date": "2017-09-09T00:00:00.0Z",
+ "version": "a2.module-newest",
+ "node-id": "sim1",
+ "uuid": "a2.module-1.56.1.2",
+ "parent-uuid": "ODU-1.56.0.0",
+ "contained-holder": [],
+ "tree-level": 1,
+ "manufacturer-identifier": "ONF-Wireless-Transport",
+ "serial": "Serial1",
+ "part-type-id": "Partnumber",
+ "model-identifier": "model-id",
+ "type-name": "a2.module"
+ },
+ {
+ "description": "MWR-ng Dir#6.5-Ch#1",
+ "date": "2014-01-16T00:00:00.0Z",
+ "version": "MWR-ng",
+ "node-id": "sim1",
+ "uuid": "IDU-1.65.0.0",
+ "parent-uuid": "network-element",
+ "contained-holder": [
+ "PORT-1.65.1.4",
+ "PORT-1.65.1.2"
+ ],
+ "tree-level": 0,
+ "manufacturer-identifier": "ONF-Wireless-Transport",
+ "serial": "WAUZZI",
+ "part-type-id": "3DB76047BAAA02",
+ "model-identifier": "model-id-s3s",
+ "type-name": "MWR-ng"
+ },
+ {
+ "description": "MWR#55Ch#0/RxDiv",
+ "date": "2014-01-08T00:00:00.0Z",
+ "version": "2017",
+ "node-id": "sim1",
+ "uuid": "CARD-1.65.1.4",
+ "parent-uuid": "IDU-1.65.0.0",
+ "contained-holder": [],
+ "tree-level": 1,
+ "manufacturer-identifier": "ONF-Wireless-Transport",
+ "serial": "Serie2017-13",
+ "part-type-id": "partNo2017-12",
+ "model-identifier": "model-id-s3s",
+ "type-name": "RxDiv"
+ },
+ {
+ "description": "WS/p8.module",
+ "date": "2013-11-23T00:00:00.0Z",
+ "version": "234",
+ "node-id": "sim1",
+ "uuid": "CARD-1.1.6.0",
+ "parent-uuid": "SHELF-1.1.0.0",
+ "contained-holder": [
+ "PORT-1.1.6.5",
+ "PORT-1.1.6.7",
+ "PORT-1.1.6.6",
+ "PORT-1.1.6.8"
+ ],
+ "tree-level": 1,
+ "manufacturer-identifier": "SAN",
+ "serial": "serial-number-124",
+ "part-type-id": "part-number-12",
+ "model-identifier": "model-id-12",
+ "type-name": "p8.module"
+ },
+ {
+ "description": "WS/DS3",
+ "date": "2008-10-21T00:00:00.0Z",
+ "version": "unknown",
+ "node-id": "sim1",
+ "uuid": "CARD-1.1.8.0",
+ "parent-uuid": "SHELF-1.1.0.0",
+ "contained-holder": [],
+ "tree-level": 1,
+ "manufacturer-identifier": "ONF-Wireless-Transport",
+ "serial": "sd-dsa-eqw",
+ "part-type-id": "unknown",
+ "model-identifier": "model-id-s3s",
+ "type-name": "p4.module"
+ },
+ {
+ "description": "WS/wind",
+ "date": "2007-02-19T00:00:00.0Z",
+ "version": "wind",
+ "node-id": "sim1",
+ "uuid": "CARD-1.1.9.0",
+ "parent-uuid": "SHELF-1.1.0.0",
+ "contained-holder": [],
+ "tree-level": 1,
+ "manufacturer-identifier": "CIT",
+ "serial": "proto-type",
+ "part-type-id": "party-yea",
+ "model-identifier": "model-id-s3s",
+ "type-name": "wind"
+ },
+ {
+ "description": "MWR#55Ch#1/RxDiv",
+ "date": "2014-01-07T00:00:00.0Z",
+ "version": "2017",
+ "node-id": "sim1",
+ "uuid": "CARD-1.55.1.4",
+ "parent-uuid": "IDU-1.55.0.0",
+ "contained-holder": [],
+ "tree-level": 1,
+ "manufacturer-identifier": "ONF-Wireless-Transport",
+ "serial": "Serie2017-12",
+ "part-type-id": "partNo2017-12",
+ "model-identifier": "model-id-s3s",
+ "type-name": "RxDiv"
+ },
+ {
+ "description": "WS/CORE-MAIN/a2.module#7",
+ "date": "2009-01-19T00:00:00.0Z",
+ "version": "a2.module-newest",
+ "node-id": "sim1",
+ "uuid": "a2.module-1.1.1.7",
+ "parent-uuid": "CARD-1.1.1.0",
+ "contained-holder": [
+ "SUBRACK-1.17.0.0"
+ ],
+ "tree-level": 2,
+ "manufacturer-identifier": "ONF-Wireless-Transport",
+ "serial": "91T403003322",
+ "part-type-id": "1AB187280031",
+ "model-identifier": "mod2",
+ "type-name": "a2.module"
+ },
+ {
+ "description": "MWR-ng Dir#5.5-Ch#1",
+ "date": "2014-01-15T00:00:00.0Z",
+ "version": "MWR-ng",
+ "node-id": "sim1",
+ "uuid": "IDU-1.55.0.0",
+ "parent-uuid": "network-element",
+ "contained-holder": [
+ "PORT-1.55.1.2",
+ "PORT-1.55.1.4"
+ ],
+ "tree-level": 0,
+ "manufacturer-identifier": "ONF-Wireless-Transport",
+ "serial": "Serie2017-14",
+ "part-type-id": "3DB76047BAAA02",
+ "model-identifier": "model-id-s3s",
+ "type-name": "MWR-ng"
+ },
+ {
+ "description": "WS/CORE-MAIN",
+ "date": "2015-08-17T00:00:00.0Z",
+ "version": "123",
+ "node-id": "sim1",
+ "uuid": "CARD-1.1.1.0",
+ "parent-uuid": "SHELF-1.1.0.0",
+ "contained-holder": [
+ "PORT-1.1.1.6",
+ "PORT-1.1.1.5",
+ "PORT-1.1.1.8",
+ "PORT-1.1.1.7"
+ ],
+ "tree-level": 1,
+ "manufacturer-identifier": "SAN",
+ "serial": "asdf-asdasd-asd",
+ "part-type-id": "part-number-2",
+ "model-identifier": "model-id-2",
+ "type-name": "latest"
+ },
+ {
+ "description": "WS/p8.module",
+ "date": "2013-10-21T00:00:00.0Z",
+ "version": "234",
+ "node-id": "sim1",
+ "uuid": "CARD-1.1.5.0",
+ "parent-uuid": "SHELF-1.1.0.0",
+ "contained-holder": [
+ "PORT-1.1.5.6",
+ "PORT-1.1.5.5",
+ "PORT-1.1.5.8",
+ "PORT-1.1.5.7"
+ ],
+ "tree-level": 1,
+ "manufacturer-identifier": "SAN",
+ "serial": "africa",
+ "part-type-id": "part-number-12",
+ "model-identifier": "model-id-12",
+ "type-name": "p8.module"
+ },
+ {
+ "description": "WS/p8.module/a2.module#6",
+ "date": "",
+ "version": "",
+ "node-id": "sim1",
+ "uuid": "a2.module-1.1.5.6",
+ "parent-uuid": "CARD-1.1.5.0",
+ "contained-holder": [
+ "SUBRACK-1.56.0.0"
+ ],
+ "tree-level": 2,
+ "manufacturer-identifier": "",
+ "serial": "",
+ "part-type-id": "",
+ "model-identifier": "",
+ "type-name": "a2.module"
+ },
+ {
+ "description": "WS/p8.module/a2.module#6",
+ "date": "",
+ "version": "",
+ "node-id": "sim2",
+ "uuid": "a2.module-1.1.5.6",
+ "parent-uuid": "network-element",
+ "contained-holder": [
+ "SUBRACK-1.56.0.0"
+ ],
+ "tree-level": 0,
+ "manufacturer-identifier": "",
+ "serial": "",
+ "part-type-id": "",
+ "model-identifier": "",
+ "type-name": "a2.module"
+ }
+] \ No newline at end of file
diff --git a/sdnr/wt/data-provider/dblib/src/test/resources/pmdata15m.json b/sdnr/wt/data-provider/dblib/src/test/resources/pmdata15m.json
new file mode 100644
index 000000000..88dd87f55
--- /dev/null
+++ b/sdnr/wt/data-provider/dblib/src/test/resources/pmdata15m.json
@@ -0,0 +1,532 @@
+[
+ {
+ "uuid-interface": "LP-MWPS-TTP-01",
+ "performance-data": {
+ "time-period": 900,
+ "es": 0,
+ "ses": 0,
+ "cses": 0,
+ "unavailability": 0,
+ "tx-level-min": 25,
+ "tx-level-max": 25,
+ "tx-level-avg": 25,
+ "rx-level-min": -41,
+ "rx-level-max": -41,
+ "rx-level-avg": -41,
+ "time2-states": -1,
+ "time4-states-s": 0,
+ "time4-states": 0,
+ "time8-states": 0,
+ "time16-states-s": -1,
+ "time16-states": 0,
+ "time32-states": 0,
+ "time64-states": 0,
+ "time128-states": 0,
+ "time256-states": 900,
+ "time512-states": -1,
+ "time512-states-l": -1,
+ "time1024-states": -1,
+ "time1024-states-l": -1,
+ "time2048-states": -1,
+ "time2048-states-l": -1,
+ "time4096-states": -1,
+ "time4096-states-l": -1,
+ "time8192-states": -1,
+ "time8192-states-l": -1,
+ "snir-min": -99,
+ "snir-max": -99,
+ "snir-avg": -99,
+ "xpd-min": -99,
+ "xpd-max": -99,
+ "xpd-avg": -99,
+ "rf-temp-min": -99,
+ "rf-temp-max": -99,
+ "rf-temp-avg": -99,
+ "defect-blocks-sum": -1
+ },
+ "layer-protocol-name": "MWPS",
+ "radio-signal-id": "Test11",
+ "suspect-interval-flag": false,
+ "granularity-period": "Period15Min",
+ "scanner-id": "PM_RADIO_15M_03",
+ "time-stamp": "2017-07-04T15:30:00.0+00:00",
+ "node-name": "sim12600"
+ },
+ {
+ "uuid-interface": "LP-MWPS-TTP-01",
+ "performance-data": {
+ "time-period": 900,
+ "es": 0,
+ "ses": 0,
+ "cses": 0,
+ "unavailability": 0,
+ "tx-level-min": 25,
+ "tx-level-max": 25,
+ "tx-level-avg": 25,
+ "rx-level-min": -41,
+ "rx-level-max": -41,
+ "rx-level-avg": -41,
+ "time2-states": -1,
+ "time4-states-s": 0,
+ "time4-states": 0,
+ "time8-states": 0,
+ "time16-states-s": -1,
+ "time16-states": 0,
+ "time32-states": 0,
+ "time64-states": 0,
+ "time128-states": 0,
+ "time256-states": 900,
+ "time512-states": -1,
+ "time512-states-l": -1,
+ "time1024-states": -1,
+ "time1024-states-l": -1,
+ "time2048-states": -1,
+ "time2048-states-l": -1,
+ "time4096-states": -1,
+ "time4096-states-l": -1,
+ "time8192-states": -1,
+ "time8192-states-l": -1,
+ "snir-min": -99,
+ "snir-max": -99,
+ "snir-avg": -99,
+ "xpd-min": -99,
+ "xpd-max": -99,
+ "xpd-avg": -99,
+ "rf-temp-min": -99,
+ "rf-temp-max": -99,
+ "rf-temp-avg": -99,
+ "defect-blocks-sum": -1
+ },
+ "layer-protocol-name": "MWPS",
+ "radio-signal-id": "Test11",
+ "suspect-interval-flag": false,
+ "granularity-period": "Period15Min",
+ "scanner-id": "PM_RADIO_15M_01",
+ "time-stamp": "2017-07-04T16:00:00.0+00:00",
+ "node-name": "sim12600"
+ },
+ {
+ "uuid-interface": "LP-MWPS-TTP-01",
+ "performance-data": {
+ "time-period": 900,
+ "es": 0,
+ "ses": 0,
+ "cses": 0,
+ "unavailability": 0,
+ "tx-level-min": 25,
+ "tx-level-max": 25,
+ "tx-level-avg": 25,
+ "rx-level-min": -41,
+ "rx-level-max": -41,
+ "rx-level-avg": -41,
+ "time2-states": -1,
+ "time4-states-s": 0,
+ "time4-states": 0,
+ "time8-states": 0,
+ "time16-states-s": -1,
+ "time16-states": 0,
+ "time32-states": 0,
+ "time64-states": 0,
+ "time128-states": 0,
+ "time256-states": 900,
+ "time512-states": -1,
+ "time512-states-l": -1,
+ "time1024-states": -1,
+ "time1024-states-l": -1,
+ "time2048-states": -1,
+ "time2048-states-l": -1,
+ "time4096-states": -1,
+ "time4096-states-l": -1,
+ "time8192-states": -1,
+ "time8192-states-l": -1,
+ "snir-min": -99,
+ "snir-max": -99,
+ "snir-avg": -99,
+ "xpd-min": -99,
+ "xpd-max": -99,
+ "xpd-avg": -99,
+ "rf-temp-min": -99,
+ "rf-temp-max": -99,
+ "rf-temp-avg": -99,
+ "defect-blocks-sum": -1
+ },
+ "layer-protocol-name": "MWPS",
+ "radio-signal-id": "Test11",
+ "suspect-interval-flag": false,
+ "granularity-period": "Period15Min",
+ "scanner-id": "PM_RADIO_15M_6",
+ "time-stamp": "2017-07-04T14:45:00.0+00:00",
+ "node-name": "sim12600"
+ },
+ {
+ "uuid-interface": "LP-MWPS-TTP-01",
+ "performance-data": {
+ "time-period": 900,
+ "es": 0,
+ "ses": 0,
+ "cses": 0,
+ "unavailability": 0,
+ "tx-level-min": 25,
+ "tx-level-max": 25,
+ "tx-level-avg": 25,
+ "rx-level-min": -41,
+ "rx-level-max": -41,
+ "rx-level-avg": -41,
+ "time2-states": -1,
+ "time4-states-s": 0,
+ "time4-states": 0,
+ "time8-states": 0,
+ "time16-states-s": -1,
+ "time16-states": 0,
+ "time32-states": 0,
+ "time64-states": 0,
+ "time128-states": 0,
+ "time256-states": 900,
+ "time512-states": -1,
+ "time512-states-l": -1,
+ "time1024-states": -1,
+ "time1024-states-l": -1,
+ "time2048-states": -1,
+ "time2048-states-l": -1,
+ "time4096-states": -1,
+ "time4096-states-l": -1,
+ "time8192-states": -1,
+ "time8192-states-l": -1,
+ "snir-min": -99,
+ "snir-max": -99,
+ "snir-avg": -99,
+ "xpd-min": -99,
+ "xpd-max": -99,
+ "xpd-avg": -99,
+ "rf-temp-min": -99,
+ "rf-temp-max": -99,
+ "rf-temp-avg": -99,
+ "defect-blocks-sum": -1
+ },
+ "layer-protocol-name": "MWPS",
+ "radio-signal-id": "Test11",
+ "suspect-interval-flag": false,
+ "granularity-period": "Period15Min",
+ "scanner-id": "PM_RADIO_15M_4",
+ "time-stamp": "2017-07-04T15:15:00.0+00:00",
+ "node-name": "sim12600"
+ },
+ {
+ "uuid-interface": "LP-MWPS-TTP-01",
+ "performance-data": {
+ "time-period": 900,
+ "es": 0,
+ "ses": 0,
+ "cses": 0,
+ "unavailability": 0,
+ "tx-level-min": 25,
+ "tx-level-max": 25,
+ "tx-level-avg": 25,
+ "rx-level-min": -41,
+ "rx-level-max": -41,
+ "rx-level-avg": -41,
+ "time2-states": -1,
+ "time4-states-s": 0,
+ "time4-states": 0,
+ "time8-states": 0,
+ "time16-states-s": -1,
+ "time16-states": 0,
+ "time32-states": 0,
+ "time64-states": 0,
+ "time128-states": 0,
+ "time256-states": 900,
+ "time512-states": -1,
+ "time512-states-l": -1,
+ "time1024-states": -1,
+ "time1024-states-l": -1,
+ "time2048-states": -1,
+ "time2048-states-l": -1,
+ "time4096-states": -1,
+ "time4096-states-l": -1,
+ "time8192-states": -1,
+ "time8192-states-l": -1,
+ "snir-min": -99,
+ "snir-max": -99,
+ "snir-avg": -99,
+ "xpd-min": -99,
+ "xpd-max": -99,
+ "xpd-avg": -99,
+ "rf-temp-min": -99,
+ "rf-temp-max": -99,
+ "rf-temp-avg": -99,
+ "defect-blocks-sum": -1
+ },
+ "layer-protocol-name": "MWPS",
+ "radio-signal-id": "Test11",
+ "suspect-interval-flag": false,
+ "granularity-period": "Period15Min",
+ "scanner-id": "PM_RADIO_15M_12",
+ "time-stamp": "2017-07-04T13:15:00.0+00:00",
+ "node-name": "sim12600"
+ },
+ {
+ "uuid-interface": "LP-MWPS-TTP-01",
+ "performance-data": {
+ "time-period": 900,
+ "es": 0,
+ "ses": 0,
+ "cses": 0,
+ "unavailability": 0,
+ "tx-level-min": 25,
+ "tx-level-max": 25,
+ "tx-level-avg": 25,
+ "rx-level-min": -41,
+ "rx-level-max": -41,
+ "rx-level-avg": -41,
+ "time2-states": -1,
+ "time4-states-s": 0,
+ "time4-states": 0,
+ "time8-states": 0,
+ "time16-states-s": -1,
+ "time16-states": 0,
+ "time32-states": 0,
+ "time64-states": 0,
+ "time128-states": 0,
+ "time256-states": 900,
+ "time512-states": -1,
+ "time512-states-l": -1,
+ "time1024-states": -1,
+ "time1024-states-l": -1,
+ "time2048-states": -1,
+ "time2048-states-l": -1,
+ "time4096-states": -1,
+ "time4096-states-l": -1,
+ "time8192-states": -1,
+ "time8192-states-l": -1,
+ "snir-min": -99,
+ "snir-max": -99,
+ "snir-avg": -99,
+ "xpd-min": -99,
+ "xpd-max": -99,
+ "xpd-avg": -99,
+ "rf-temp-min": -99,
+ "rf-temp-max": -99,
+ "rf-temp-avg": -99,
+ "defect-blocks-sum": -1
+ },
+ "layer-protocol-name": "MWPS",
+ "radio-signal-id": "Test11",
+ "suspect-interval-flag": false,
+ "granularity-period": "Period15Min",
+ "scanner-id": "PM_RADIO_15M_15",
+ "time-stamp": "2017-07-04T12:30:00.0+00:00",
+ "node-name": "sim12600"
+ },
+ {
+ "uuid-interface": "LP-MWPS-TTP-03",
+ "performance-data": {
+ "time-period": 900,
+ "es": 0,
+ "ses": 0,
+ "cses": 0,
+ "unavailability": 0,
+ "tx-level-min": 25,
+ "tx-level-max": 25,
+ "tx-level-avg": 25,
+ "rx-level-min": -41,
+ "rx-level-max": -41,
+ "rx-level-avg": -41,
+ "time2-states": -1,
+ "time4-states-s": 0,
+ "time4-states": 0,
+ "time8-states": 0,
+ "time16-states-s": -1,
+ "time16-states": 0,
+ "time32-states": 0,
+ "time64-states": 0,
+ "time128-states": 0,
+ "time256-states": 900,
+ "time512-states": -1,
+ "time512-states-l": -1,
+ "time1024-states": -1,
+ "time1024-states-l": -1,
+ "time2048-states": -1,
+ "time2048-states-l": -1,
+ "time4096-states": -1,
+ "time4096-states-l": -1,
+ "time8192-states": -1,
+ "time8192-states-l": -1,
+ "snir-min": -99,
+ "snir-max": -99,
+ "snir-avg": -99,
+ "xpd-min": -99,
+ "xpd-max": -99,
+ "xpd-avg": -99,
+ "rf-temp-min": -99,
+ "rf-temp-max": -99,
+ "rf-temp-avg": -99,
+ "defect-blocks-sum": -1
+ },
+ "layer-protocol-name": "MWPS",
+ "radio-signal-id": "Test11",
+ "suspect-interval-flag": false,
+ "granularity-period": "Period15Min",
+ "scanner-id": "PM_RADIO_15M_16",
+ "time-stamp": "2017-07-04T12:15:00.0+00:00",
+ "node-name": "sim12600"
+ },
+ {
+ "uuid-interface": "LP-MWPS-TTP-02",
+ "performance-data": {
+ "time-period": 900,
+ "es": 0,
+ "ses": 0,
+ "cses": 0,
+ "unavailability": 0,
+ "tx-level-min": 25,
+ "tx-level-max": 25,
+ "tx-level-avg": 25,
+ "rx-level-min": -41,
+ "rx-level-max": -41,
+ "rx-level-avg": -41,
+ "time2-states": -1,
+ "time4-states-s": 0,
+ "time4-states": 0,
+ "time8-states": 0,
+ "time16-states-s": -1,
+ "time16-states": 0,
+ "time32-states": 0,
+ "time64-states": 0,
+ "time128-states": 0,
+ "time256-states": 900,
+ "time512-states": -1,
+ "time512-states-l": -1,
+ "time1024-states": -1,
+ "time1024-states-l": -1,
+ "time2048-states": -1,
+ "time2048-states-l": -1,
+ "time4096-states": -1,
+ "time4096-states-l": -1,
+ "time8192-states": -1,
+ "time8192-states-l": -1,
+ "snir-min": -99,
+ "snir-max": -99,
+ "snir-avg": -99,
+ "xpd-min": -99,
+ "xpd-max": -99,
+ "xpd-avg": -99,
+ "rf-temp-min": -99,
+ "rf-temp-max": -99,
+ "rf-temp-avg": -99,
+ "defect-blocks-sum": -1
+ },
+ "layer-protocol-name": "MWPS",
+ "radio-signal-id": "Test11",
+ "suspect-interval-flag": false,
+ "granularity-period": "Period15Min",
+ "scanner-id": "PM_RADIO_15M_02",
+ "time-stamp": "2017-07-04T15:45:00.0+00:00",
+ "node-name": "sim12600"
+ },
+ {
+ "uuid-interface": "LP-MWPS-TTP-02",
+ "performance-data": {
+ "time-period": 900,
+ "es": 0,
+ "ses": 0,
+ "cses": 0,
+ "unavailability": 0,
+ "tx-level-min": 25,
+ "tx-level-max": 25,
+ "tx-level-avg": 25,
+ "rx-level-min": -41,
+ "rx-level-max": -41,
+ "rx-level-avg": -41,
+ "time2-states": -1,
+ "time4-states-s": 0,
+ "time4-states": 0,
+ "time8-states": 0,
+ "time16-states-s": -1,
+ "time16-states": 0,
+ "time32-states": 0,
+ "time64-states": 0,
+ "time128-states": 0,
+ "time256-states": 900,
+ "time512-states": -1,
+ "time512-states-l": -1,
+ "time1024-states": -1,
+ "time1024-states-l": -1,
+ "time2048-states": -1,
+ "time2048-states-l": -1,
+ "time4096-states": -1,
+ "time4096-states-l": -1,
+ "time8192-states": -1,
+ "time8192-states-l": -1,
+ "snir-min": -99,
+ "snir-max": -99,
+ "snir-avg": -99,
+ "xpd-min": -99,
+ "xpd-max": -99,
+ "xpd-avg": -99,
+ "rf-temp-min": -99,
+ "rf-temp-max": -99,
+ "rf-temp-avg": -99,
+ "defect-blocks-sum": -1
+ },
+ "layer-protocol-name": "MWPS",
+ "radio-signal-id": "Test11",
+ "suspect-interval-flag": false,
+ "granularity-period": "Period15Min",
+ "scanner-id": "PM_RADIO_15M_11",
+ "time-stamp": "2017-07-04T13:30:00.0+00:00",
+ "node-name": "sim12600"
+ },
+ {
+ "uuid-interface": "LP-MWPS-TTP-02",
+ "performance-data": {
+ "time-period": 900,
+ "es": 0,
+ "ses": 0,
+ "cses": 0,
+ "unavailability": 0,
+ "tx-level-min": 25,
+ "tx-level-max": 25,
+ "tx-level-avg": 25,
+ "rx-level-min": -41,
+ "rx-level-max": -41,
+ "rx-level-avg": -41,
+ "time2-states": -1,
+ "time4-states-s": 0,
+ "time4-states": 0,
+ "time8-states": 0,
+ "time16-states-s": -1,
+ "time16-states": 0,
+ "time32-states": 0,
+ "time64-states": 0,
+ "time128-states": 0,
+ "time256-states": 900,
+ "time512-states": -1,
+ "time512-states-l": -1,
+ "time1024-states": -1,
+ "time1024-states-l": -1,
+ "time2048-states": -1,
+ "time2048-states-l": -1,
+ "time4096-states": -1,
+ "time4096-states-l": -1,
+ "time8192-states": -1,
+ "time8192-states-l": -1,
+ "snir-min": -99,
+ "snir-max": -99,
+ "snir-avg": -99,
+ "xpd-min": -99,
+ "xpd-max": -99,
+ "xpd-avg": -99,
+ "rf-temp-min": -99,
+ "rf-temp-max": -99,
+ "rf-temp-avg": -99,
+ "defect-blocks-sum": -1
+ },
+ "layer-protocol-name": "MWPS",
+ "radio-signal-id": "Test11",
+ "suspect-interval-flag": false,
+ "granularity-period": "Period15Min",
+ "scanner-id": "PM_RADIO_15M_13",
+ "time-stamp": "2017-07-04T13:00:00.0+00:00",
+ "node-name": "sim12600"
+ }
+] \ No newline at end of file