summaryrefslogtreecommitdiffstats
path: root/sdnr/wt/data-provider/provider/src/test
diff options
context:
space:
mode:
authorhighstreetherbert <herbert.eiselt@highstreet-technologies.com>2020-07-13 19:05:55 +0200
committerhighstreetherbert <herbert.eiselt@highstreet-technologies.com>2020-07-15 10:40:35 +0200
commit7dfb26b3c3a35fe73684019fbcf68ab6c9cf091a (patch)
treed2b3fac81dcfabd5c463bc2071e1f477236e744c /sdnr/wt/data-provider/provider/src/test
parent5dfcc4c815f930edb9fc9f5f94a9ef6d9791a709 (diff)
SDN-R common Elasticsearch 7.x support
Extend SDN-R common for Elasticsearch 7.x support Issue-ID: SDNC-1284 Signed-off-by: highstreetherbert <herbert.eiselt@highstreet-technologies.com> Change-Id: I4c4f66f73f8adbdf2a9ba4f77d1e2d274ce49892 Signed-off-by: highstreetherbert <herbert.eiselt@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/data-provider/provider/src/test')
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestCRUDforDatabase.java13
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestConfig.java20
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestDataMappings.java171
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestEventService.java6
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestMaintenanceServiceData.java10
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestMediatorServerService.java5
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangGenSalMapping.java164
7 files changed, 176 insertions, 213 deletions
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestCRUDforDatabase.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestCRUDforDatabase.java
index 0294c6e50..5cf2f0644 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestCRUDforDatabase.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestCRUDforDatabase.java
@@ -21,14 +21,17 @@
*/
package org.onap.ccsdk.features.sdnr.wt.dataprovider.test;
-import static org.junit.Assert.*;
-
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.io.IOException;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;
-
import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient;
@@ -56,7 +59,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.DeleteNetworkElementConnectionInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.DeleteNetworkElementConnectionInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Entity;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EntityInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Faultlog;
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.GranularityPeriodType;
@@ -112,7 +114,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.UpdateNetworkElementConnectionInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.UpdateNetworkElementConnectionInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.UpdateNetworkElementConnectionOutputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.entity.input.Filter;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.entity.input.FilterBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.entity.input.Pagination;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.entity.input.PaginationBuilder;
@@ -130,7 +131,7 @@ public class TestCRUDforDatabase {
dbProvider = new ElasticSearchDataProvider(hosts);
dbProvider.waitForYellowDatabaseStatus(30, TimeUnit.SECONDS);
- dbRawProvider = new HtDatabaseClient(hosts);
+ dbRawProvider = HtDatabaseClient.getClient(hosts);
}
public static void trySleep(long ms) {
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestConfig.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestConfig.java
index c0234bfce..1275b0372 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestConfig.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestConfig.java
@@ -21,12 +21,10 @@
*/
package org.onap.ccsdk.features.sdnr.wt.dataprovider.test;
-import static org.junit.Assert.*;
-
+import static org.junit.Assert.assertEquals;
import java.io.File;
import java.lang.reflect.Field;
import java.util.Map;
-
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -40,6 +38,7 @@ public class TestConfig {
private static final Logger LOG = LoggerFactory.getLogger(TestConfig.class);
private static final String TESTFILENAME = "testconfig.properties";
+ private static final String HOSTNAME = "localhost";
@After
@Before
@@ -53,18 +52,23 @@ public class TestConfig {
@Test
public void test() {
+ int databasePort = setSDNRDBURLEnv();
+
ConfigurationFileRepresentation configuration = new ConfigurationFileRepresentation(TESTFILENAME);
- setSDNRDBURLEnv();
EsConfig esConfig = new EsConfig(configuration);
LOG.info("Defaultconfiguration: {}", esConfig.toString());
assertEquals("http", esConfig.getHosts()[0].protocol.getValue());
- assertEquals(9200, esConfig.getHosts()[0].port);
- assertEquals("sdnrdb", esConfig.getHosts()[0].hostname);
+ assertEquals(databasePort, esConfig.getHosts()[0].port);
+ assertEquals(HOSTNAME, esConfig.getHosts()[0].hostname);
}
- public static void setSDNRDBURLEnv() {
- setEnv("SDNRDBURL", "http://sdnrdb:9200");
+ public static int setSDNRDBURLEnv() {
+ int databasePort = Integer
+ .valueOf(System.getProperty("databaseport") != null ? System.getProperty("databaseport") : "49200");
+ System.out.println("DB Port: " + databasePort);
+ setEnv("SDNRDBURL", "http://"+HOSTNAME+":"+databasePort);
+ return databasePort;
}
public static void setEnv(String key, String value) {
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestDataMappings.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestDataMappings.java
index a4b284e4f..f63beee43 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestDataMappings.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestDataMappings.java
@@ -22,122 +22,67 @@
package org.onap.ccsdk.features.sdnr.wt.dataprovider.test;
import java.io.IOException;
-import java.util.List;
import org.junit.Test;
-import org.onap.ccsdk.features.sdnr.wt.common.database.DatabaseClient;
-import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient;
-import org.onap.ccsdk.features.sdnr.wt.common.database.SearchHit;
-import org.onap.ccsdk.features.sdnr.wt.common.database.SearchResult;
-import org.onap.ccsdk.features.sdnr.wt.common.database.config.HostInfo;
-import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilder;
-import org.onap.ccsdk.features.sdnr.wt.common.database.responses.SearchResponse;
-import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.EsDataObjectReaderWriter;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools.YangToolsMapper;
-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.read.pmdata._15m.list.output.Data;
-import org.opendaylight.yangtools.yang.binding.DataObject;
public class TestDataMappings {
- private static final HostInfo[] HOSTINFOS = new HostInfo[] {HostInfo.getDefault()};
- //public static final String ESDATATYPENAME = "faultcurrent";
-
- private static class HtDatabaseClientHelper extends HtDatabaseClient {
-
- private final String json;
-
- public HtDatabaseClientHelper(String jsonResponse, HostInfo[] hosts) {
- super(hosts);
- this.json = jsonResponse;
-
- }
-
- @Override
- public SearchResult<SearchHit> doReadByQueryJsonData(String dataTypeName, QueryBuilder qb) {
- return new SearchResult<>(new SearchResponse(this.json).getHits());
- }
- }
-
- private static class MapResult<T extends DataObject> {
- public final List<T> mappedData;
-
- public MapResult(String dataType, Class<T> cls, String dbJson) throws ClassNotFoundException {
- System.out.println(dbJson);
- DatabaseClient db = new HtDatabaseClientHelper(dbJson, HOSTINFOS);
- EsDataObjectReaderWriter<T> dbrw = new EsDataObjectReaderWriter<>(db, dataType, cls);
- this.mappedData = dbrw.doReadAll().getHits();
- }
- }
-
- private static final String SEARCHJSON_FORMAT = "{\n" + "\"took\": 0,\n" + "\"timed_out\": false,\n"
- + "\"_shards\": {\n" + "\"total\": 5,\n" + "\"successful\": 5,\n" + "\"skipped\": 0,\n" + "\"failed\": 0\n"
- + "},\n" + "\"hits\": {\n" + "\"total\": 1,\n" + "\"max_score\": 1,\n" + "\"hits\": [\n" + "{\n"
- + "\"_index\": \"%s\",\n" + "\"_type\": \"%s\",\n" + "\"_id\": \"%s\",\n" + "\"_score\": 1,\n"
- + "\"_source\": %s}\n" + "]\n" + "}\n" + "}";
-
- private static final String MEDIATORSERVER_DB_ID = "LumwSG0BFvcE3yf8MBM5";
- private static final String MEDIATOR_SERVERDB_JSON =
- "{\"url\":\"https://10.45.44.223:7590\",\"name\":\"test mediator server\"}";
-
- private static final String FAULTCURRENT_DB_ID = "LumwSG0BFvcE3yf8MBM5";
- private static final String FAULTCURRENT_DB_NODEID = "sim1";
- private static final int FAULTCURRENT_DB_COUNTER = 3;
- private static final String FAULTCURRENT_DB_OBJECTID = "LPS-MWT-01";
- private static final String FAULTCURRENT_DB_PROBLEM = "rlsExceeded";
- private static final String FAULTCURRENT_DB_SEVERITY = "critical";
- private static final DateAndTime FAULTCURRENT_DB_TIMESTAMP =
- DateAndTime.getDefaultInstance("2019-09-18T13:07:05.8Z");
-
- private static final String FAULTCURRENT_SERVERDB_JSON = "{\"node-id\":\"" + FAULTCURRENT_DB_NODEID + "\","
- + "\"counter\":" + FAULTCURRENT_DB_COUNTER + "," + "\"object-id\":\"" + FAULTCURRENT_DB_OBJECTID + "\","
- + "\"problem\":\"" + FAULTCURRENT_DB_PROBLEM + "\"," + "\"timestamp\":\""
- + FAULTCURRENT_DB_TIMESTAMP.getValue() + "\"," + "\"severity\":\"" + FAULTCURRENT_DB_SEVERITY + "\"" + "}";
-
-
- private static final String PMDATA15M_SERVERDB_JSON = "{\n" + "\"node-name\": \"sim2\",\n"
- + "\"uuid-interface\": \"LP-MWPS-TTP-01\",\n" + "\"layer-protocol-name\": \"MWPS\",\n"
- + "\"radio-signal-id\": \"Test11\",\n" + "\"time-stamp\": \"2017-07-04T14:00:00.0Z\",\n"
- + "\"granularity-period\": \"PERIOD_15MIN\",\n" + "\"scanner-id\": \"PM_RADIO_15M_9\",\n"
- + "\"performance-data\": {\n" + "\"es\": 0,\n" + "\"rx-level-avg\": -41,\n" + "\"time2-states\": -1,\n"
- + "\"time4-states-s\": 0,\n" + "\"time4-states\": 0,\n" + "\"time8-states\": 0,\n"
- + "\"time16-states-s\": -1,\n" + "\"time16-states\": 0,\n" + "\"time32-states\": 0,\n"
- + "\"time64-states\": 0,\n" + "\"time128-states\": 0,\n" + "\"time256-states\": 900,\n"
- + "\"time512-states\": -1,\n" + "\"time512-states-l\": -1,\n" + "\"time1024-states\": -1,\n"
- + "\"time1024-states-l\": -1,\n" + "\"time2048-states\": -1,\n" + "\"time2048-states-l\": -1,\n"
- + "\"time4096-states\": -1,\n" + "\"time4096-states-l\": -1,\n" + "\"time8192-states\": -1,\n"
- + "\"time8192-states-l\": -1,\n" + "\"snir-min\": -99,\n" + "\"snir-max\": -99,\n" + "\"snir-avg\": -99,\n"
- + "\"xpd-min\": -99,\n" + "\"xpd-max\": -99,\n" + "\"xpd-avg\": -99,\n" + "\"rf-temp-min\": -99,\n"
- + "\"rf-temp-max\": -99,\n" + "\"rf-temp-avg\": -99,\n" + "\"defect-blocks-sum\": -1,\n"
- + "\"time-period\": 900,\n" + "\"tx-level-min\": 25,\n" + "\"tx-level-max\": 25,\n"
- + "\"tx-level-avg\": 25,\n" + "\"rx-level-min\": -41,\n" + "\"rx-level-max\": -41,\n"
- + "\"unavailability\": 0,\n" + "\"ses\": 0,\n" + "\"cses\": 0\n" + "},\n"
- + "\"suspect-interval-flag\": false\n" + "}";
-
- //@Test
- // public void testMediatorServer() throws ClassNotFoundException {
- //
- // MapResult<EsMediatorServer> result = new MapResult<EsMediatorServer>(EsMediatorServer.ESDATATYPENAME,
- // EsMediatorServer.class,
- // getSearchJson(EsMediatorServer.ESDATATYPENAME,MEDIATORSERVER_DB_ID,MEDIATOR_SERVERDB_JSON));
- // assertEquals("test mediator server", result.mappedData.get(0).getName());
- // assertEquals("https://10.45.44.223:7590", result.mappedData.get(0).getUrl());
- // assertEquals(MEDIATORSERVER_DB_ID, result.mappedData.get(0).getId());
- //
- // }
- //@Test
- // public void testFaultCurrent() {
- //
- // MapResult<FaultcurrentEntity> result = new MapResult<FaultcurrentEntity>(ESDATATYPENAME, EsFaultCurrent.class,
- // getSearchJson(ESDATATYPENAME, FAULTCURRENT_DB_ID, FAULTCURRENT_SERVERDB_JSON));
- // assertEquals(FAULTCURRENT_DB_ID, result.mappedData.get(0).getId());
- // assertEquals(FAULTCURRENT_DB_NODEID, result.mappedData.get(0).getNodeId());
- // assertEquals(FAULTCURRENT_DB_COUNTER, result.mappedData.get(0).getCounter().intValue());
- // assertEquals(FAULTCURRENT_DB_OBJECTID, result.mappedData.get(0).getObjectId());
- // assertEquals(FAULTCURRENT_DB_PROBLEM, result.mappedData.get(0).getProblem());
- // assertEquals(FAULTCURRENT_DB_SEVERITY, result.mappedData.get(0).getSeverity());
- // assertEquals(FAULTCURRENT_DB_TIMESTAMP, result.mappedData.get(0).getTimestamp());
- // }
- //
+ // @formatter:off
+ private static final String PMDATA15M_SERVERDB_JSON = "{\n"
+ + "\"node-name\": \"sim2\",\n"
+ + "\"uuid-interface\": \"LP-MWPS-TTP-01\",\n"
+ + "\"layer-protocol-name\": \"MWPS\",\n"
+ + "\"radio-signal-id\": \"Test11\",\n"
+ + "\"time-stamp\": \"2017-07-04T14:00:00.0Z\",\n"
+ + "\"granularity-period\": \"PERIOD_15MIN\",\n"
+ + "\"scanner-id\": \"PM_RADIO_15M_9\",\n"
+ + "\"performance-data\": {\n"
+ + "\"es\": 0,\n"
+ + "\"rx-level-avg\": -41,\n"
+ + "\"time2-states\": -1,\n"
+ + "\"time4-states-s\": 0,\n"
+ + "\"time4-states\": 0,\n"
+ + "\"time8-states\": 0,\n"
+ + "\"time16-states-s\": -1,\n"
+ + "\"time16-states\": 0,\n"
+ + "\"time32-states\": 0,\n"
+ + "\"time64-states\": 0,\n"
+ + "\"time128-states\": 0,\n"
+ + "\"time256-states\": 900,\n"
+ + "\"time512-states\": -1,\n"
+ + "\"time512-states-l\": -1,\n"
+ + "\"time1024-states\": -1,\n"
+ + "\"time1024-states-l\": -1,\n"
+ + "\"time2048-states\": -1,\n"
+ + "\"time2048-states-l\": -1,\n"
+ + "\"time4096-states\": -1,\n"
+ + "\"time4096-states-l\": -1,\n"
+ + "\"time8192-states\": -1,\n"
+ + "\"time8192-states-l\": -1,\n"
+ + "\"snir-min\": -99,\n"
+ + "\"snir-max\": -99,\n"
+ + "\"snir-avg\": -99,\n"
+ + "\"xpd-min\": -99,\n"
+ + "\"xpd-max\": -99,\n"
+ + "\"xpd-avg\": -99,\n"
+ + "\"rf-temp-min\": -99,\n"
+ + "\"rf-temp-max\": -99,\n"
+ + "\"rf-temp-avg\": -99,\n"
+ + "\"defect-blocks-sum\": -1,\n"
+ + "\"time-period\": 900,\n"
+ + "\"tx-level-min\": 25,\n"
+ + "\"tx-level-max\": 25,\n"
+ + "\"tx-level-avg\": 25,\n"
+ + "\"rx-level-min\": -41,\n"
+ + "\"rx-level-max\": -41,\n"
+ + "\"unavailability\": 0,\n"
+ + "\"ses\": 0,\n"
+ + "\"cses\": 0\n"
+ + "},\n"
+ + "\"suspect-interval-flag\": false\n"
+ + "}";
+ // @formatter:on
@Test
public void testPmData15m() {
@@ -148,12 +93,6 @@ public class TestDataMappings {
} catch (IOException e) {
e.printStackTrace();
}
-
-
- }
-
- private String getSearchJson(String dataType, String dbId, String source) {
- return String.format(SEARCHJSON_FORMAT, dataType, dataType, dbId, source);
}
}
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestEventService.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestEventService.java
index 308bbf663..6d54016cd 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestEventService.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestEventService.java
@@ -24,22 +24,18 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-
import java.io.IOException;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.concurrent.TimeUnit;
-
import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient;
import org.onap.ccsdk.features.sdnr.wt.common.database.SearchHit;
import org.onap.ccsdk.features.sdnr.wt.common.database.SearchResult;
-import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilder;
import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilders;
import org.onap.ccsdk.features.sdnr.wt.common.database.requests.DeleteByQueryRequest;
-import org.onap.ccsdk.features.sdnr.wt.common.database.requests.SearchRequest;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.ElasticSearchDataProvider;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.HtDatabaseEventsService;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.NetconfTimeStampImpl;
@@ -84,7 +80,7 @@ public class TestEventService {
dbProvider = new ElasticSearchDataProvider(TestCRUDforDatabase.hosts);
dbProvider.waitForYellowDatabaseStatus(30, TimeUnit.SECONDS);
- dbRawProvider = new HtDatabaseClient(TestCRUDforDatabase.hosts);
+ dbRawProvider = HtDatabaseClient.getClient(TestCRUDforDatabase.hosts);
try {
service = new HtDatabaseEventsService(dbRawProvider, dbProvider);
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestMaintenanceServiceData.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestMaintenanceServiceData.java
index 6c22b0ea1..5839738e6 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestMaintenanceServiceData.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestMaintenanceServiceData.java
@@ -21,12 +21,12 @@
*/
package org.onap.ccsdk.features.sdnr.wt.dataprovider.test;
-import static org.junit.Assert.*;
-
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.TimeUnit;
-
import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient;
@@ -55,7 +55,7 @@ public class TestMaintenanceServiceData {
dbProvider = new ElasticSearchDataProvider(TestCRUDforDatabase.hosts);
dbProvider.waitForYellowDatabaseStatus(30, TimeUnit.SECONDS);
- dbRawProvider = new HtDatabaseClient(TestCRUDforDatabase.hosts);
+ dbRawProvider = HtDatabaseClient.getClient(TestCRUDforDatabase.hosts);
service = dbProvider.getHtDatabaseMaintenance();
}
@@ -91,7 +91,7 @@ public class TestMaintenanceServiceData {
/**
* Delete
- *
+ *
* @param entity
*/
private static void clearDbEntity(Entity entity) {
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestMediatorServerService.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestMediatorServerService.java
index edd0f9edb..83f8de89e 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestMediatorServerService.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestMediatorServerService.java
@@ -24,10 +24,8 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
-
import java.io.IOException;
import java.util.concurrent.TimeUnit;
-
import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient;
@@ -35,7 +33,6 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilders;
import org.onap.ccsdk.features.sdnr.wt.common.database.requests.DeleteByQueryRequest;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.ElasticSearchDataProvider;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.MediatorServerDataProvider;
-import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.HtDatabaseMaintenance;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateMediatorServerInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateMediatorServerOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Entity;
@@ -56,7 +53,7 @@ public class TestMediatorServerService {
dbProvider = new ElasticSearchDataProvider(TestCRUDforDatabase.hosts);
dbProvider.waitForYellowDatabaseStatus(30, TimeUnit.SECONDS);
- dbRawProvider = new HtDatabaseClient(TestCRUDforDatabase.hosts);
+ dbRawProvider = HtDatabaseClient.getClient(TestCRUDforDatabase.hosts);
service = new MediatorServerDataProvider(TestCRUDforDatabase.hosts);
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangGenSalMapping.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangGenSalMapping.java
index 4a0834248..585f7dee2 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangGenSalMapping.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangGenSalMapping.java
@@ -25,7 +25,6 @@ import java.io.IOException;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
-
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.json.JSONObject;
@@ -68,6 +67,13 @@ public class TestYangGenSalMapping {
// Create mapper for serialization and deserialization
YangToolsMapper mapper = new YangToolsMapper();
+ private static HostInfo[] getHostinfo() {
+ int databasePort = Integer
+ .valueOf(System.getProperty("databaseport") != null ? System.getProperty("databaseport") : "49200");
+ System.out.println("DB Port: " + databasePort);
+ return new HostInfo[] {new HostInfo("localhost", databasePort, Protocol.HTTP)};
+ }
+
@Test
public void test1() throws IOException {
@@ -80,10 +86,9 @@ public class TestYangGenSalMapping {
loginPasswordBuilder.setPassword("myTestPassword");
netconfNodeBuilder.setCredentials(loginPasswordBuilder.build());
- OdlHelloMessageCapabilitiesBuilder odlHelloMessageCapabilitiesBuilder =
- new OdlHelloMessageCapabilitiesBuilder();
+ OdlHelloMessageCapabilitiesBuilder odlHelloMessageCapabilitiesBuilder = new OdlHelloMessageCapabilitiesBuilder();
List<Uri> uriList = new ArrayList<>();
- uriList.add(new Uri("test.uri"));
+ uriList.add( new Uri("test.uri") );
odlHelloMessageCapabilitiesBuilder.setCapability(uriList);
netconfNodeBuilder.setOdlHelloMessageCapabilities(odlHelloMessageCapabilitiesBuilder.build());
@@ -99,7 +104,7 @@ public class TestYangGenSalMapping {
NetconfNode generatedNode = mapper.readValue(res.getBytes(), NetconfNode.class);
out(generatedNode.toString()); // Print it with specified indentation
// Compare result
- out("Equal? " + netconfNode.equals(generatedNode));
+ out("Equal? "+netconfNode.equals(generatedNode));
}
static class TestDataObjectBuilder implements Builder<TestDataObject> {
@@ -119,22 +124,20 @@ public class TestYangGenSalMapping {
}
@Test
- public void test2() throws ClassNotFoundException {
+ public void test2() throws Exception {
- int databasePort = Integer
- .valueOf(System.getProperty("databaseport") != null ? System.getProperty("databaseport") : "49200");
- System.out.println("DB Port: " + databasePort);
+ int databasePort = Integer.valueOf(System.getProperty("databaseport")!=null?System.getProperty("databaseport"):"49200");
+ System.out.println("DB Port: "+databasePort);
- HostInfo[] HOSTINFOS = new HostInfo[] {new HostInfo("localhost", databasePort, Protocol.HTTP)};
- DatabaseClient db = new HtDatabaseClient(HOSTINFOS);
+ HostInfo[] HOSTINFOS = new HostInfo[] { new HostInfo("localhost", databasePort ,Protocol.HTTP)};
+ DatabaseClient db = HtDatabaseClient.getClient(HOSTINFOS);
EsDataObjectReaderWriter<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.Data> dataRW =
- new EsDataObjectReaderWriter<>(db, "inventorytest",
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.Data.class);
+ new EsDataObjectReaderWriter<>(db, "inventorytest", org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.Data.class);
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.Data d1;
d1 = getInventoryDataBuilder("MyDescription", 23L).build();
- String id = dataRW.write(d1, null);
+ String id = dataRW.write(d1,null);
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.Data d2;
d2 = dataRW.read(id);
@@ -144,7 +147,7 @@ public class TestYangGenSalMapping {
}
@Test
- public void test3() throws IOException {
+ public void test3() throws IOException {
PerformanceDataBuilder performanceBuilder = new PerformanceDataBuilder();
performanceBuilder.setEs(99);
@@ -193,29 +196,59 @@ public class TestYangGenSalMapping {
@Test
public void test5() throws IOException {
- String jsonString = "{\n" + " \"time-stamp\": \"2017-03-01T06:45:00.0Z\",\n"
- + " \"node-name\": \"Sim2230\",\n" + " \"uuid-interface\": \"LP-MWPS-TTP-RADIO\",\n"
- + " \"scanner-id\": \"PM_RADIO_15M_14\",\n" + " \"layer-protocol-name\": \"MWPS\",\n"
- + " \"granularity-period\": \"Period15Min\",\n" + " \"radio-signal-id\": \"Test8\",\n"
- + " \"suspect-interval-flag\": false,\n" + " \"performance-data\": {\n"
- + " \"time4096-states-l\": -1,\n" + " \"time16-states-s\": -1,\n"
- + " \"tx-level-max\": 3,\n" + " \"snir-max\": -99,\n" + " \"time16-states\": 0,\n"
- + " \"time64-states\": 900,\n" + " \"unavailability\": 0,\n"
- + " \"time8192-states-l\": -1,\n" + " \"time512-states\": -1,\n"
- + " \"xpd-min\": -99,\n" + " \"xpd-avg\": -99,\n" + " \"tx-level-avg\": 3,\n"
- + " \"tx-level-min\": 3,\n" + " \"rf-temp-min\": -99,\n"
- + " \"rf-temp-avg\": -99,\n" + " \"snir-avg\": -99,\n" + " \"snir-min\": -99,\n"
- + " \"time-period\": 900,\n" + " \"time2-states\": 0,\n"
- + " \"time4-states\": 0,\n" + " \"time8-states\": -1,\n" + " \"ses\": 0,\n"
- + " \"time2048-states-l\": -1,\n" + " \"time2048-states\": -1,\n"
- + " \"xpd-max\": -99,\n" + " \"rf-temp-max\": -99,\n"
- + " \"time8192-states\": -1,\n" + " \"time128-states\": -1,\n"
- + " \"time256-states\": -1,\n" + " \"rx-level-min\": -44,\n"
- + " \"rx-level-avg\": -44,\n" + " \"time1024-states-l\": -1,\n" + " \"es\": 0,\n"
- + " \"cses\": 0,\n" + " \"time4-states-s\": 0,\n" + " \"time1024-states\": -1,\n"
- + " \"time512-states-l\": -1,\n" + " \"time4096-states\": -1,\n"
- + " \"rx-level-max\": -45,\n" + " \"defect-blocks-sum\": -1,\n"
- + " \"time32-states\": -1\n" + " }\n" + "}";
+ String jsonString = "{\n" +
+ " \"time-stamp\": \"2017-03-01T06:45:00.0Z\",\n" +
+ " \"node-name\": \"Sim2230\",\n" +
+ " \"uuid-interface\": \"LP-MWPS-TTP-RADIO\",\n" +
+ " \"scanner-id\": \"PM_RADIO_15M_14\",\n" +
+ " \"layer-protocol-name\": \"MWPS\",\n" +
+ " \"granularity-period\": \"Period15Min\",\n" +
+ " \"radio-signal-id\": \"Test8\",\n" +
+ " \"suspect-interval-flag\": false,\n" +
+ " \"performance-data\": {\n" +
+ " \"time4096-states-l\": -1,\n" +
+ " \"time16-states-s\": -1,\n" +
+ " \"tx-level-max\": 3,\n" +
+ " \"snir-max\": -99,\n" +
+ " \"time16-states\": 0,\n" +
+ " \"time64-states\": 900,\n" +
+ " \"unavailability\": 0,\n" +
+ " \"time8192-states-l\": -1,\n" +
+ " \"time512-states\": -1,\n" +
+ " \"xpd-min\": -99,\n" +
+ " \"xpd-avg\": -99,\n" +
+ " \"tx-level-avg\": 3,\n" +
+ " \"tx-level-min\": 3,\n" +
+ " \"rf-temp-min\": -99,\n" +
+ " \"rf-temp-avg\": -99,\n" +
+ " \"snir-avg\": -99,\n" +
+ " \"snir-min\": -99,\n" +
+ " \"time-period\": 900,\n" +
+ " \"time2-states\": 0,\n" +
+ " \"time4-states\": 0,\n" +
+ " \"time8-states\": -1,\n" +
+ " \"ses\": 0,\n" +
+ " \"time2048-states-l\": -1,\n" +
+ " \"time2048-states\": -1,\n" +
+ " \"xpd-max\": -99,\n" +
+ " \"rf-temp-max\": -99,\n" +
+ " \"time8192-states\": -1,\n" +
+ " \"time128-states\": -1,\n" +
+ " \"time256-states\": -1,\n" +
+ " \"rx-level-min\": -44,\n" +
+ " \"rx-level-avg\": -44,\n" +
+ " \"time1024-states-l\": -1,\n" +
+ " \"es\": 0,\n" +
+ " \"cses\": 0,\n" +
+ " \"time4-states-s\": 0,\n" +
+ " \"time1024-states\": -1,\n" +
+ " \"time512-states-l\": -1,\n" +
+ " \"time4096-states\": -1,\n" +
+ " \"rx-level-max\": -45,\n" +
+ " \"defect-blocks-sum\": -1,\n" +
+ " \"time32-states\": -1\n" +
+ " }\n" +
+ "}";
// Map to JSON String to Object
Data generatedNode = mapper.readValue(jsonString.getBytes(), Data.class);
@@ -225,14 +258,13 @@ public class TestYangGenSalMapping {
@Test
- public void test6() throws IOException, ClassNotFoundException {
+ public void test6() throws Exception {
out(method());
- HtDatabaseClient dbClient = new HtDatabaseClient(new HostInfo[] {new HostInfo("sdnrdb", 9200, Protocol.HTTP)});
+ HtDatabaseClient dbClient = HtDatabaseClient.getClient(getHostinfo());
String PMDATA15M_TYPE = "historicalperformance15min";
EsDataObjectReaderWriter<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.Data> pm15mRW =
- new EsDataObjectReaderWriter<>(dbClient, PMDATA15M_TYPE,
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.Data.class);
+ new EsDataObjectReaderWriter<>(dbClient, PMDATA15M_TYPE, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.Data.class);
pm15mRW.setEsIdAttributeName("_nodeName");
ReadPmdata15mListInputBuilder inputBuilder = new ReadPmdata15mListInputBuilder();
@@ -251,36 +283,34 @@ public class TestYangGenSalMapping {
QueryBuilder query = fromFilter(input.getFilter()).from((page - 1) * pageSize).size(pageSize);
setSortOrder(query, input.getSortorder());
- SearchResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.Data> result =
- pm15mRW.doReadAll(query);
+ SearchResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.Data> result=pm15mRW.doReadAll(query);
- out("Found: " + result.getHits().size());
- int t = 0;
+ out("Found: "+result.getHits().size());
+ int t=0;
for (Data hit : result.getHits()) {
- out("Hit " + t++ + ":" + hit);
+ out("Hit "+t+++":"+hit);
}
setPagination(outputBuilder, page, pageSize, result.getTotal());
outputBuilder.setData(result.getHits());
}
@Test
- public void test7() throws IOException, ClassNotFoundException {
+ public void test7() throws Exception {
out(method());
String ESDATATYPE_MEDIATORSERVER = Entity.MediatorServer.getName();
- HtDatabaseClient dbClient = new HtDatabaseClient(new HostInfo[] {new HostInfo("sdnrdb", 9200, Protocol.HTTP)});
+ HtDatabaseClient dbClient = HtDatabaseClient.getClient(getHostinfo());
EsDataObjectReaderWriter<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.mediator.server.list.output.Data> mediatorserverRW;
mediatorserverRW = new EsDataObjectReaderWriter<>(dbClient, ESDATATYPE_MEDIATORSERVER,
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.mediator.server.list.output.Data.class)
- .setWriteInterface(
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.MediatorServerEntity.class)
- .setEsIdAttributeName("_id");
+ .setWriteInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.MediatorServerEntity.class)
+ .setEsIdAttributeName("_id");
CreateMediatorServerInputBuilder inputBuilder = new CreateMediatorServerInputBuilder();
inputBuilder.setName("Hans");
inputBuilder.setUrl("MyGreatUrl");
- String id = mediatorserverRW.write(inputBuilder.build(), "testid");
+ String id = mediatorserverRW.write(inputBuilder.build(),"testid");
System.out.println(id);
}
@@ -290,15 +320,15 @@ public class TestYangGenSalMapping {
out(method());
String input;
input = "id-dd-dd";
- System.out.println("Map " + input + " to " + YangToolsMapper.toCamelCaseAttributeName(input));
+ System.out.println("Map " + input + " to "+YangToolsMapper.toCamelCaseAttributeName(input));
input = "idDdGg";
- System.out.println("Map " + input + " to " + YangToolsMapper.toCamelCaseAttributeName(input));
+ System.out.println("Map " + input + " to "+YangToolsMapper.toCamelCaseAttributeName(input));
input = "_idDdGg";
- System.out.println("Map " + input + " to " + YangToolsMapper.toCamelCaseAttributeName(input));
+ System.out.println("Map " + input + " to "+YangToolsMapper.toCamelCaseAttributeName(input));
input = "--ff--gfg";
- System.out.println("Map " + input + " to " + YangToolsMapper.toCamelCaseAttributeName(input));
+ System.out.println("Map " + input + " to "+YangToolsMapper.toCamelCaseAttributeName(input));
input = "";
- System.out.println("Map " + input + " to " + YangToolsMapper.toCamelCaseAttributeName(input));
+ System.out.println("Map " + input + " to "+YangToolsMapper.toCamelCaseAttributeName(input));
}
/* ---------------------------------
@@ -309,8 +339,7 @@ public class TestYangGenSalMapping {
return nameofCurrMethod;
}
- private org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.DataBuilder getInventoryDataBuilder(
- String description, long treeLevel) {
+ private org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.DataBuilder getInventoryDataBuilder(String description, long treeLevel) {
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.DataBuilder dataBuilder =
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.DataBuilder();
dataBuilder.setDescription(description);
@@ -348,9 +377,10 @@ public class TestYangGenSalMapping {
if (filters == null || filters.size() == 0) {
return QueryBuilders.matchAllQuery();
- } else if (filters.size() == 1) {
+ } else if(filters.size()==1){
return QueryBuilders.matchQuery(filters.get(0).getProperty(), filters.get(0).getFiltervalue());
- } else {
+ }
+ else {
BoolQueryBuilder query = new BoolQueryBuilder();
for (Filter fi : filters) {
query.must(QueryBuilders.matchQuery((prefix != null ? prefix : "") + fi.getProperty(),
@@ -360,7 +390,6 @@ public class TestYangGenSalMapping {
}
}
-
private static QueryBuilder setSortOrder(QueryBuilder query, @Nullable List<Sortorder> sortorder) {
return setSortOrder(query, sortorder, "");
}
@@ -378,12 +407,9 @@ public class TestYangGenSalMapping {
}
- private static void setPagination(ReadPmdata15mListOutputBuilder outputBuilder, long page, long pageSize,
- long totalSize) {
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.Pagination value =
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.PaginationBuilder()
- .setPage(BigInteger.valueOf(page)).setSize(pageSize).setTotal(BigInteger.valueOf(totalSize))
- .build();
+ private static void setPagination(ReadPmdata15mListOutputBuilder outputBuilder, long page, long pageSize, long totalSize) {
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.Pagination value = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.PaginationBuilder()
+ .setPage(BigInteger.valueOf(page)).setSize(pageSize).setTotal(BigInteger.valueOf(totalSize)).build();
outputBuilder.setPagination(value);
}