summaryrefslogtreecommitdiffstats
path: root/sdnr/wt/data-provider/database/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'sdnr/wt/data-provider/database/src/test')
-rw-r--r--sdnr/wt/data-provider/database/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/test/TestConfig.java59
-rw-r--r--sdnr/wt/data-provider/database/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/test/TestDataMappings.java209
-rw-r--r--sdnr/wt/data-provider/database/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/test/TestNetconfNodeBuilder.java56
-rw-r--r--sdnr/wt/data-provider/database/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/test/TestNuMappings.java57
-rw-r--r--sdnr/wt/data-provider/database/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/test/TestYangGenSalMapping.java408
-rw-r--r--sdnr/wt/data-provider/database/src/test/resources/log4j2.xml17
-rw-r--r--sdnr/wt/data-provider/database/src/test/resources/simplelogger.properties6
7 files changed, 0 insertions, 812 deletions
diff --git a/sdnr/wt/data-provider/database/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/test/TestConfig.java b/sdnr/wt/data-provider/database/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/test/TestConfig.java
deleted file mode 100644
index ecc7edf6a..000000000
--- a/sdnr/wt/data-provider/database/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/test/TestConfig.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START========================================================================
- * ONAP : ccsdk feature sdnr wt
- * =================================================================================================
- * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
- * =================================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- * ============LICENSE_END==========================================================================
- ******************************************************************************/
-package org.onap.ccsdk.features.sdnr.wt.dataprovider.database.test;
-
-import static org.junit.Assert.*;
-
-import java.io.File;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation;
-import org.onap.ccsdk.features.sdnr.wt.database.config.EsConfig;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class TestConfig {
-
- private static final Logger LOG = LoggerFactory.getLogger(TestConfig.class);
-
- private static final String TESTFILENAME = "testconfig.properties";
-
- @After
- @Before
- public void afterAndBefore() {
- File f=new File(TESTFILENAME);
- if(f.exists()) {
- LOG.info("Remove {}", f.getAbsolutePath());
- f.delete();
- }
- }
- @Test
- public void test() {
- ConfigurationFileRepresentation configuration=new ConfigurationFileRepresentation(TESTFILENAME);
-
- 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);
-
- }
-
-}
diff --git a/sdnr/wt/data-provider/database/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/test/TestDataMappings.java b/sdnr/wt/data-provider/database/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/test/TestDataMappings.java
deleted file mode 100644
index 1dc02b92f..000000000
--- a/sdnr/wt/data-provider/database/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/test/TestDataMappings.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START========================================================================
- * ONAP : ccsdk feature sdnr wt
- * =================================================================================================
- * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
- * =================================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- * ============LICENSE_END==========================================================================
- ******************************************************************************/
-package org.onap.ccsdk.features.sdnr.wt.dataprovider.database.test;
-
-import static org.junit.Assert.assertEquals;
-
-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.database.EsDataObjectReaderWriter;
-import org.onap.ccsdk.features.sdnr.wt.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<SearchHit>(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<T>(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());
-// }
-//
- @Test
- public void testPmData15m() {
-
- YangToolsMapper mapper = new YangToolsMapper();
- try {
- Data data =mapper.readValue(PMDATA15M_SERVERDB_JSON.getBytes(), Data.class);
- System.out.println(data);
- } 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/database/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/test/TestNetconfNodeBuilder.java b/sdnr/wt/data-provider/database/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/test/TestNetconfNodeBuilder.java
deleted file mode 100644
index 9237aaf1f..000000000
--- a/sdnr/wt/data-provider/database/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/test/TestNetconfNodeBuilder.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START========================================================================
- * ONAP : ccsdk feature sdnr wt
- * =================================================================================================
- * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
- * =================================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- * ============LICENSE_END==========================================================================
- ******************************************************************************/
-package org.onap.ccsdk.features.sdnr.wt.dataprovider.database.test;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.Credentials;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPassword;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPasswordBuilder;
-
-public class TestNetconfNodeBuilder {
-
- @SuppressWarnings("deprecation")
- //@Test
- public void test() {
-
- NetconfNodeBuilder netconfNodeBuilder = new NetconfNodeBuilder();
-
- LoginPasswordBuilder loginPasswordBuilder = new LoginPasswordBuilder();
- loginPasswordBuilder.setUsername("myTestUsername");
- loginPasswordBuilder.setPassword("myTestPassword");
- netconfNodeBuilder.setCredentials(loginPasswordBuilder.build());
-
- NetconfNode netconfNode = netconfNodeBuilder.build();
- System.out.println(netconfNode);
-
- Credentials credentials = netconfNode.getCredentials();
- System.out.println("Class: "+credentials.getClass()+"\nContent: "+credentials);
-
- if (credentials instanceof LoginPassword) {
- LoginPassword loginPassword = (LoginPassword)credentials;
- System.out.println("User: "+loginPassword.getUsername()+" Password"+loginPassword.getPassword());
- } else {
- System.out.println("Not expected class");
- }
- }
-
-}
diff --git a/sdnr/wt/data-provider/database/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/test/TestNuMappings.java b/sdnr/wt/data-provider/database/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/test/TestNuMappings.java
deleted file mode 100644
index b7d0620ca..000000000
--- a/sdnr/wt/data-provider/database/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/test/TestNuMappings.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START========================================================================
- * ONAP : ccsdk feature sdnr wt
- * =================================================================================================
- * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
- * =================================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- * ============LICENSE_END==========================================================================
- ******************************************************************************/
-package org.onap.ccsdk.features.sdnr.wt.dataprovider.database.test;
-
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JsonMappingException;
-import java.io.IOException;
-import org.junit.Test;
-import org.onap.ccsdk.features.sdnr.wt.yangtools.YangToolsMapper;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Faultcurrent;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.FaultcurrentBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType;
-
-public class TestNuMappings {
-
- @Test
- public void test33() {
- Faultcurrent c = new FaultcurrentBuilder().setSeverity(SeverityType.Critical).build();
- YangToolsMapper mapper = new YangToolsMapper();
- try {
- System.out.println(mapper.writeValueAsString(c)+"<=>"+SeverityType.Critical.getName());
- } catch (JsonProcessingException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- try {
- Faultcurrent f=mapper.readValue( "{\"severity\":\"Critical\"}", Faultcurrent.class);
- System.out.println(f);
- System.out.println(mapper.writeValueAsString(f));
- } catch (JsonParseException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (JsonMappingException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-}
diff --git a/sdnr/wt/data-provider/database/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/test/TestYangGenSalMapping.java b/sdnr/wt/data-provider/database/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/test/TestYangGenSalMapping.java
deleted file mode 100644
index 666061425..000000000
--- a/sdnr/wt/data-provider/database/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/test/TestYangGenSalMapping.java
+++ /dev/null
@@ -1,408 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START========================================================================
- * ONAP : ccsdk feature sdnr wt
- * =================================================================================================
- * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
- * =================================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- * ============LICENSE_END==========================================================================
- ******************************************************************************/
-package org.onap.ccsdk.features.sdnr.wt.dataprovider.database.test;
-
-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;
-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.InvalidProtocolException;
-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.config.HostInfo.Protocol;
-import org.onap.ccsdk.features.sdnr.wt.common.database.queries.BoolQueryBuilder;
-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.database.EsDataObjectReaderWriter;
-import org.onap.ccsdk.features.sdnr.wt.yangtools.YangToolsMapper;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
-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.netconf.node.topology.rev150114.NetconfNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.parameters.OdlHelloMessageCapabilitiesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPasswordBuilder;
-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.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.ReadPmdata15mListInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadPmdata15mListInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadPmdata15mListOutputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SortOrder;
-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.PaginationBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.entity.input.Sortorder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.pmdata15m.entity.PerformanceDataBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.Data;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.DataBuilder;
-import org.opendaylight.yangtools.concepts.Builder;
-import org.opendaylight.yangtools.yang.binding.DataContainer;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-
-public class TestYangGenSalMapping {
-
- // Create mapper for serialization and deserialization
- YangToolsMapper mapper = new YangToolsMapper();
-
- @Test
- public void test1() throws IOException {
-
- // Create test object
- NetconfNodeBuilder netconfNodeBuilder = new NetconfNodeBuilder();
- netconfNodeBuilder.setConnectedMessage("ConnMessage");
-
- LoginPasswordBuilder loginPasswordBuilder = new LoginPasswordBuilder();
- loginPasswordBuilder.setUsername("myTestUsername");
- loginPasswordBuilder.setPassword("myTestPassword");
- netconfNodeBuilder.setCredentials(loginPasswordBuilder.build());
-
- OdlHelloMessageCapabilitiesBuilder odlHelloMessageCapabilitiesBuilder = new OdlHelloMessageCapabilitiesBuilder();
- List<Uri> uriList = new ArrayList<>();
- uriList.add( new Uri("test.uri") );
- odlHelloMessageCapabilitiesBuilder.setCapability(uriList);
- netconfNodeBuilder.setOdlHelloMessageCapabilities(odlHelloMessageCapabilitiesBuilder.build());
-
- NetconfNode netconfNode = netconfNodeBuilder.build();
- out(netconfNode.toString());
-
- // Map Object to JSON String
- String res = mapper.writeValueAsString(netconfNode);
- JSONObject json = new JSONObject(res); // Convert text to object
- out(json.toString(4)); // Print it with specified indentation
-
- // Map to JSON String to Object
- NetconfNode generatedNode = mapper.readValue(res.getBytes(), NetconfNode.class);
- out(generatedNode.toString()); // Print it with specified indentation
- // Compare result
- out("Equal? "+(netconfNode.equals(generatedNode)));
- }
-
- static class TestDataObjectBuilder implements Builder<TestDataObject> {
- @Override
- public @NonNull TestDataObject build() throws IllegalArgumentException {
- return new TestDataObject();
- }
- }
-
- static class TestDataObject implements DataObject {
- String test;
-
- @Override
- public Class<? extends DataContainer> getImplementedInterface() {
- return null;
- }
- }
-
- @Test
- public void test2() throws InvalidProtocolException, ClassNotFoundException {
-
-
- int databasePort = Integer.valueOf(System.getProperty("databaseport"));
- System.out.println("DB Port: "+databasePort);
-
- HostInfo[] HOSTINFOS = new HostInfo[] { new HostInfo("localhost", databasePort )};
- DatabaseClient db = new HtDatabaseClient(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);
-
- 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);
-
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.Data d2;
- d2 = dataRW.read(id);
-
- out(d2.toString());
-
- }
-
- @Test
- public void test3() throws IOException {
-
- PerformanceDataBuilder performanceBuilder = new PerformanceDataBuilder();
- performanceBuilder.setEs(99);
- DataBuilder pmData15MinutesBuilder = new DataBuilder();
- pmData15MinutesBuilder.setLayerProtocolName("fdsaf");
- pmData15MinutesBuilder.setTimeStamp(new DateAndTime("2017-03-01T09:15:00.0Z"));
- pmData15MinutesBuilder.setPerformanceData(performanceBuilder.build());
-
- // Map Object to JSON String
- String res = mapper.writeValueAsString(pmData15MinutesBuilder.build());
- JSONObject json = new JSONObject(res); // Convert text to object
- out(json.toString(4)); // Print it with specified indentation
-
- // Map to JSON String to Object
- Data generatedNode = mapper.readValue(res.getBytes(), Data.class);
- out(generatedNode.toString()); // Print it with specified indentation
- }
-
- @Test
- public void test4() throws IOException {
-
- String jsonString = "{\n" + "\"node-name\": \"Sim2230\",\n" + "\"uuid-interface\": \"LP-MWPS-TTP-RADIO\",\n"
- + "\"layer-protocol-name\": \"MWPS\",\n" + "\"radio-signal-id\": \"Test8\",\n"
- + "\"time-stamp\": \"2017-03-01T09:15:00.0Z\",\n" + "\"granularity-period\": \"PERIOD_15MIN\",\n"
- + "\"scanner-id\": \"PM_RADIO_15M_4\",\n" + "\"performance-data\": {\n" + "\"unavailability\": 0,\n"
- + "\"tx-level-max\": 3,\n" + "\"tx-level-avg\": 3,\n" + "\"rx-level-min\": -44,\n"
- + "\"rx-level-max\": -45,\n" + "\"rx-level-avg\": -44,\n" + "\"time2-states\": 0,\n"
- + "\"time4-states-s\": 0,\n" + "\"time4-states\": 0,\n" + "\"time8-states\": -1,\n"
- + "\"time16-states-s\": -1,\n" + "\"time16-states\": 0,\n" + "\"time32-states\": -1,\n"
- + "\"time64-states\": 900,\n" + "\"time128-states\": -1,\n" + "\"time256-states\": -1,\n"
- + "\"time512-states\": -1,\n" + "\"time512-states-l\": -1,\n" + "\"time1024-states\": -1,\n"
- + "\"time1024-states-l\": -1,\n" + "\"time8192-states-l\": -1,\n" + "\"time8192-states\": -1,\n"
- + "\"time2048-states\": -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" + "\"cses\": 0,\n"
- + "\"time4096-states-l\": -1,\n" + "\"tx-level-min\": 3,\n" + "\"es\": 0,\n"
- + "\"time2048-states-l\": -1,\n" + "\"time4096-states\": -1,\n" + "\"ses\": 0\n" + "},\n"
- + "\"suspect-interval-flag\": false\n" + "}\n" + "}";
- // Map to JSON String to Object
- Data generatedNode = mapper.readValue(jsonString.getBytes(), Data.class);
- out(generatedNode.toString()); // Print it with specified indentation
-
- }
-
-
- @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\": \"PERIOD_15MIN\",\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);
- out(generatedNode.toString()); // Print it with specified indentation
-
- }
-
-
- @Test
- public void test6() throws IOException, ClassNotFoundException {
- out(method());
- HtDatabaseClient dbClient = new HtDatabaseClient(new HostInfo[] { new HostInfo("sdnrdb", 9200, Protocol.HTTP) });
- 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);
- pm15mRW.setEsIdAttributeName("_nodeName");
-
- ReadPmdata15mListInputBuilder inputBuilder = new ReadPmdata15mListInputBuilder();
- PaginationBuilder paginationBuilder = new PaginationBuilder();
- paginationBuilder.setPage(new BigInteger("1"));
- paginationBuilder.setSize(20L);
- inputBuilder.setPagination(paginationBuilder.build());
-
- ReadPmdata15mListInput input = inputBuilder.build();
-
-
- ReadPmdata15mListOutputBuilder outputBuilder = new ReadPmdata15mListOutputBuilder();
- long page = getPage(input);
- long pageSize = getPageSize(input);
-
- 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);
-
- out("Found: "+result.getHits().size());
- int t=0;
- for (Data hit : result.getHits()) {
- out("Hit "+(t++)+":"+hit);
- }
- setPagination(outputBuilder, page, pageSize, result.getTotal());
- outputBuilder.setData(result.getHits());
- }
-
- @Test
- public void test7() throws IOException, ClassNotFoundException {
- out(method());
- String ESDATATYPE_MEDIATORSERVER = Entity.MediatorServer.getName();
- HtDatabaseClient dbClient = new HtDatabaseClient(new HostInfo[] { new HostInfo("sdnrdb", 9200, Protocol.HTTP) });
- 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");
-
- CreateMediatorServerInputBuilder inputBuilder = new CreateMediatorServerInputBuilder();
- inputBuilder.setName("Hans");
- inputBuilder.setUrl("MyGreatUrl");
-
- String id = mediatorserverRW.write(inputBuilder.build(),"testid");
- System.out.println(id);
-
- }
-
- @Test
- public void test8() throws IOException {
- out(method());
- String input;
- input = "id-dd-dd";
- System.out.println("Map " + input + " to "+YangToolsMapper.toCamelCaseAttributeName(input));
- input = "idDdGg";
- System.out.println("Map " + input + " to "+YangToolsMapper.toCamelCaseAttributeName(input));
- input = "_idDdGg";
- System.out.println("Map " + input + " to "+YangToolsMapper.toCamelCaseAttributeName(input));
- input = "--ff--gfg";
- System.out.println("Map " + input + " to "+YangToolsMapper.toCamelCaseAttributeName(input));
- input = "";
- System.out.println("Map " + input + " to "+YangToolsMapper.toCamelCaseAttributeName(input));
- }
-
- /* ---------------------------------
- * Private
- */
- private static String method() {
- String nameofCurrMethod = new Throwable().getStackTrace()[1].getMethodName();
- 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) {
- 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);
- dataBuilder.setTreeLevel(treeLevel);
- return dataBuilder;
- }
-
-
- private static void out(String text) {
- System.out.println("----------------------");
- System.out.println(text);
- }
-
- private static long getPage(EntityInput input) {
- return getPage(input, 1);
- }
-
- private static long getPage(EntityInput input, long defaultValue) {
- return input.getPagination() != null ? input.getPagination().getPage().longValue() : defaultValue;
- }
-
- private static long getPageSize(EntityInput input) {
- return getPageSize(input, 1);
- }
-
- private static long getPageSize(EntityInput input, long defaultValue) {
- return input.getPagination() != null ? input.getPagination().getSize().longValue() : defaultValue;
- }
-
- private static QueryBuilder fromFilter(@Nullable List<Filter> filters) {
- return fromFilter(filters, "");
- }
-
- private static QueryBuilder fromFilter(@Nullable List<Filter> filters, String prefix) {
- if (filters == null || filters.size() == 0) {
- return QueryBuilders.matchAllQuery();
-
- } else if(filters.size()==1){
- return QueryBuilders.matchQuery(filters.get(0).getProperty(), filters.get(0).getFiltervalue());
- }
- else {
- BoolQueryBuilder query = new BoolQueryBuilder();
- for (Filter fi : filters) {
- query.must(QueryBuilders.matchQuery((prefix != null ? prefix : "") + fi.getProperty(),
- fi.getFiltervalue()));
- }
- return query;
- }
-
- }
- private static QueryBuilder setSortOrder(QueryBuilder query, @Nullable List<Sortorder> sortorder) {
- return setSortOrder(query, sortorder, "");
- }
-
- private static QueryBuilder setSortOrder(QueryBuilder query, @Nullable List<Sortorder> sortorder, String prefix) {
- if (sortorder != null && sortorder.size() > 0) {
- for (Sortorder so : sortorder) {
- query.sort((prefix != null ? prefix : "") + so.getProperty(),
- so.getSortorder() == SortOrder.Ascending
- ? org.onap.ccsdk.features.sdnr.wt.common.database.queries.SortOrder.ASCENDING
- : org.onap.ccsdk.features.sdnr.wt.common.database.queries.SortOrder.DESCENDING);
- }
- }
- return query;
-
- }
-
- 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);
- }
-
-}
diff --git a/sdnr/wt/data-provider/database/src/test/resources/log4j2.xml b/sdnr/wt/data-provider/database/src/test/resources/log4j2.xml
deleted file mode 100644
index 164e93f54..000000000
--- a/sdnr/wt/data-provider/database/src/test/resources/log4j2.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<Configuration package="log4j.test"
- status="WARN">
- <Appenders>
- <Console name="Console" target="SYSTEM_OUT">
- <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
- </Console>
- </Appenders>
- <Loggers>
- <Logger name="log4j.test.Log4jTest" level="debug">
- <AppenderRef ref="Console"/>
- </Logger>
- <Root level="trace">
- <AppenderRef ref="Console"/>
- </Root>
- </Loggers>
-</Configuration> \ No newline at end of file
diff --git a/sdnr/wt/data-provider/database/src/test/resources/simplelogger.properties b/sdnr/wt/data-provider/database/src/test/resources/simplelogger.properties
deleted file mode 100644
index a2f1e7e76..000000000
--- a/sdnr/wt/data-provider/database/src/test/resources/simplelogger.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-org.slf4j.simpleLogger.defaultLogLevel=debug
-org.slf4j.simpleLogger.showDateTime=true
-#org.slf4j.simpleLogger.dateTimeFormat=yyyy-MM-dd HH:mm:ss:SSS Z
-#org.slf4j.simpleLogger.showThreadName=true
-org.slf4j.simpleLogger.showLogName=true
-org.slf4j.simpleLogger.showShortLogName=false \ No newline at end of file