summaryrefslogtreecommitdiffstats
path: root/sdnr/wt/data-provider/provider/src/test
diff options
context:
space:
mode:
authorhighstreetherbert <herbert.eiselt@highstreet-technologies.com>2020-07-15 15:44:23 +0200
committerhighstreetherbert <herbert.eiselt@highstreet-technologies.com>2020-07-15 19:05:46 +0200
commit25b3759a0907d06e0d8e391f751c6fcf067087f5 (patch)
treef9cd6de6e685216c44f4c44cc7f220f3f23f22c5 /sdnr/wt/data-provider/provider/src/test
parent002ad417b90882524276d1b9cfe377c6f6293a4c (diff)
SDN-R data-provider with ES7
Extend to ES 7.x and DB setup Issue-ID: SDNC-1288 Signed-off-by: highstreetherbert <herbert.eiselt@highstreet-technologies.com> Change-Id: Id7778322b793bfa7472a14a90bc0d1fd953c8c73 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/TestAbout.java1
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestCRUDforDatabase.java5
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestConfig.java40
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestDataTreeSerialization.java33
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestEventService.java7
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestFilterConversion.java69
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestImplementation.java19
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestMaintenanceServiceData.java7
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestMediatorServerService.java14
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestNuMappings.java38
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestTimestampFilter.java85
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestTree.java81
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangGenSalMapping.java314
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangProvider.java1
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/util/HostInfoForTest.java53
-rw-r--r--sdnr/wt/data-provider/provider/src/test/resources/simplelogger.properties4
16 files changed, 473 insertions, 298 deletions
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestAbout.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestAbout.java
index f147e8724..5d9011ab0 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestAbout.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestAbout.java
@@ -25,7 +25,6 @@ import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.AboutHttpServlet;
-
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
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 5cf2f0644..a22f3033d 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
@@ -41,6 +41,7 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.config.HostInfo;
import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilders;
import org.onap.ccsdk.features.sdnr.wt.common.database.requests.BaseRequest;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.ElasticSearchDataProvider;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.test.util.HostInfoForTest;
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.CreateMaintenanceInput;
@@ -123,12 +124,11 @@ public class TestCRUDforDatabase {
private static ElasticSearchDataProvider dbProvider;
private static HtDatabaseClient dbRawProvider;
- public static HostInfo[] hosts = new HostInfo[] {new HostInfo("localhost", Integer
- .valueOf(System.getProperty("databaseport") != null ? System.getProperty("databaseport") : "49200"))};
@BeforeClass
public static void init() throws Exception {
+ HostInfo[] hosts = HostInfoForTest.get();
dbProvider = new ElasticSearchDataProvider(hosts);
dbProvider.waitForYellowDatabaseStatus(30, TimeUnit.SECONDS);
dbRawProvider = HtDatabaseClient.getClient(hosts);
@@ -337,7 +337,6 @@ public class TestCRUDforDatabase {
// ==UPDATE============================
System.out.println("Trying to update...");
- final String name2 = "sim88";
final String url2 = "10.5.10.2";
final long port2 = 5960;
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 1275b0372..9a96986c0 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
@@ -22,13 +22,15 @@
package org.onap.ccsdk.features.sdnr.wt.dataprovider.test;
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;
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.impl.EsConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -38,7 +40,8 @@ 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";
+ private static String ENVSDNRDBURL = "SDNRDBURL";
+ private static String SDNRDBURL = "http://sdnrdb:9200";
@After
@Before
@@ -52,35 +55,16 @@ public class TestConfig {
@Test
public void test() {
- int databasePort = setSDNRDBURLEnv();
-
+ EnvGetter env = Section.getEnvGetter();
+ Section.setEnvGetter((envname) -> {
+ return envname.equals(ENVSDNRDBURL) ? SDNRDBURL : env.getenv(envname);
+ });
ConfigurationFileRepresentation configuration = new ConfigurationFileRepresentation(TESTFILENAME);
EsConfig esConfig = new EsConfig(configuration);
LOG.info("Defaultconfiguration: {}", esConfig.toString());
assertEquals("http", esConfig.getHosts()[0].protocol.getValue());
- assertEquals(databasePort, esConfig.getHosts()[0].port);
- assertEquals(HOSTNAME, esConfig.getHosts()[0].hostname);
-
- }
-
- 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;
- }
+ assertEquals(9200, esConfig.getHosts()[0].port);
+ assertEquals("sdnrdb", esConfig.getHosts()[0].hostname);
- public static void setEnv(String key, String value) {
- try {
- Map<String, String> env = System.getenv();
- Class<?> cl = env.getClass();
- Field field = cl.getDeclaredField("m");
- field.setAccessible(true);
- Map<String, String> writableEnv = (Map<String, String>) field.get(env);
- writableEnv.put(key, value);
- } catch (Exception e) {
- throw new IllegalStateException("Failed to set environment variable", e);
- }
}
}
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestDataTreeSerialization.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestDataTreeSerialization.java
deleted file mode 100644
index 60a2c50e4..000000000
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestDataTreeSerialization.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * ============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.test;
-
-import org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools.YangToolsMapper;
-
-/**
- * @author Michael Dürre
- *
- */
-public class TestDataTreeSerialization {
-
- //YangToolsMapper
-}
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 6d54016cd..9c95a7d98 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
@@ -34,11 +34,13 @@ 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.config.HostInfo;
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.HtDatabaseEventsService;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.NetconfTimeStampImpl;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.test.util.HostInfoForTest;
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.ConnectionLogStatus;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ConnectionlogBuilder;
@@ -78,9 +80,10 @@ public class TestEventService {
@BeforeClass
public static void init() throws Exception {
- dbProvider = new ElasticSearchDataProvider(TestCRUDforDatabase.hosts);
+ HostInfo[] hosts = HostInfoForTest.get();
+ dbProvider = new ElasticSearchDataProvider(hosts);
dbProvider.waitForYellowDatabaseStatus(30, TimeUnit.SECONDS);
- dbRawProvider = HtDatabaseClient.getClient(TestCRUDforDatabase.hosts);
+ dbRawProvider = HtDatabaseClient.getClient(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/TestFilterConversion.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestFilterConversion.java
index 52ca2999d..5c2a66e75 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestFilterConversion.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestFilterConversion.java
@@ -24,54 +24,89 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.test;
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.util.Arrays;
import java.util.List;
import org.junit.Test;
+import org.mockito.Mockito;
+import org.mockito.stubbing.Answer;
import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilder;
+import org.onap.ccsdk.features.sdnr.wt.common.database.requests.SearchRequest;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.QueryByFilter;
+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.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.FilterBuilder;
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.entity.input.SortorderBuilder;
-public class TestFilterConversion {
+public class TestFilterConversion extends Mockito {
private static final String PROPERTY = "node-id";
private static final String PROPERTY2 = "_id";
private static final String PROPERTY3 = "timestamp";
@Test
- public void testQuestionMark() {
+ public void testQuestionMark1() {
+ EntityInput input = mock(EntityInput.class);
List<Filter> filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY).setFiltervalue("si?ba").build());
- QueryBuilder query = QueryByFilter.fromFilter(filters);
+ when(input.getFilter()).thenReturn(filters);
+
+ QueryBuilder query = new QueryByFilter(input).getQueryBuilderByFilter();
System.out.println(query.toJSON());
+
assertTrue(query.toJSON().contains("{1,1}"));
- assertNotNull(QueryByFilter.getFilter(filters, PROPERTY));
- assertNull(QueryByFilter.getFilter(filters, PROPERTY2));
- filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY).setFiltervalue("si?ba").build(),
+ assertNotNull(new QueryByFilter(input).getQueryBuilderByFilter(PROPERTY));
+
+ }
+
+ @Test
+ public void testQuestionMarkExcpetion() {
+ EntityInput input = mock(EntityInput.class);
+ List<Filter> filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY).setFiltervalue("si?ba").build());
+ when(input.getFilter()).thenReturn(filters);
+ try {
+ new QueryByFilter(input).getSearchRequestByFilter("test1", "test2", "test3", "test4");
+ fail();
+ } catch (IllegalArgumentException e) { // fails if type not correct
+
+ }
+
+ }
+
+ @Test
+ public void testQuestionMark2() {
+ EntityInput input = mock(EntityInput.class);
+ List<Filter> filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY).setFiltervalue("si?ba").build(),
new FilterBuilder().setProperty(PROPERTY2).setFiltervalue("abc").build());
- query = QueryByFilter.fromFilter(filters);
+ when(input.getFilter()).thenReturn(filters);
+ QueryBuilder query = new QueryByFilter(input).getQueryBuilderByFilter();
System.out.println(query.toJSON());
- assertNotNull(QueryByFilter.getFilter(filters, PROPERTY2));
- filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY).setFiltervalue("si?ba").build(),
+ assertNotNull(new QueryByFilter(input).getQueryBuilderByFilter(PROPERTY2));
+ }
+
+ @Test
+ public void testQuestionMark3() {
+ EntityInput input = mock(EntityInput.class);
+ List<Filter> filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY).setFiltervalue("si?ba").build(),
new FilterBuilder().setProperty(PROPERTY3).setFiltervalue("<2019-06-13T15:00:12.0Z").build());
- query = QueryByFilter.fromFilter(filters);
List<Sortorder> sortorder =
Arrays.asList(new SortorderBuilder().setProperty(PROPERTY).setSortorder(SortOrder.Ascending).build());
- QueryByFilter.setSortOrder(query, sortorder);
- assertNotNull(QueryByFilter.getSortOrder(sortorder, PROPERTY));
+ when(input.getFilter()).thenReturn(filters);
+ when(input.getSortorder()).thenReturn(sortorder);
+
+ assertNotNull(new QueryByFilter(input).getQueryBuilderByFilter(PROPERTY));
}
@Test
public void testSortorder() {
- String f =
- "{\"input\":{\"filter\":[],\"sortorder\":[{\"property\":\"source-type\",\"sortorder\":\"ascending\"}],\"pagination\":{\"size\":10,\"page\":1}}}";
-
- QueryBuilder query = QueryByFilter.setSortOrder(QueryByFilter.fromFilter(null), Arrays
- .asList(new SortorderBuilder().setProperty("source-type").setSortorder(SortOrder.Ascending).build()));
+ EntityInput input = mock(EntityInput.class);
+ List<Sortorder> sortorder = Arrays
+ .asList(new SortorderBuilder().setProperty("source-type").setSortorder(SortOrder.Ascending).build());
+ when(input.getSortorder()).thenReturn(sortorder);
+ QueryBuilder query = new QueryByFilter(input).getQueryBuilderByFilter();
System.out.println(query.toJSON());
}
}
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestImplementation.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestImplementation.java
index cc880d1ad..2aedabee4 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestImplementation.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestImplementation.java
@@ -26,46 +26,53 @@ import static org.junit.Assert.fail;
import java.util.Set;
import org.junit.Test;
+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.http.AboutHttpServlet;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.DataTreeHttpServlet;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.MsServlet;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.impl.DataProviderImpl;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.StatusChangedHandler.StatusKey;
import org.opendaylight.mdsal.binding.api.RpcProviderService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.DataProviderService;
import org.opendaylight.yangtools.concepts.ObjectRegistration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.RpcService;
-import net.bytebuddy.implementation.bytecode.StackSize;
-
/**
* @author Michael Dürre
*
*/
public class TestImplementation {
+ static String XY = "http://localhost:"
+ + (System.getProperty("databaseport") != null ? System.getProperty("databaseport") : "49200");
+
@Test
public void test() {
- TestConfig.setSDNRDBURLEnv();
+ //TestConfig.setSDNRDBURLEnv("http://localhost:"+(System.getProperty("databaseport") != null ? System.getProperty("databaseport") : "49200"));
+ EnvGetter env = Section.getEnvGetter();
+ Section.setEnvGetter((xy) -> {
+ System.out.println("Search " + xy);
+ return xy.equals("SDNRDBURL") ? XY : env.getenv(xy);
+ });
DataProviderImpl impl = new DataProviderImpl();
impl.setRpcProviderService(new RpcProviderService() {
@Override
public <S extends RpcService, T extends S> ObjectRegistration<T> registerRpcImplementation(Class<S> type,
T implementation, Set<InstanceIdentifier<?>> paths) {
- // TODO Auto-generated method stub
return null;
}
@Override
public <S extends RpcService, T extends S> ObjectRegistration<T> registerRpcImplementation(Class<S> type,
T implementation) {
- // TODO Auto-generated method stub
return null;
}
});
impl.setMediatorServerServlet(new MsServlet());
impl.setAboutServlet(new AboutHttpServlet());
+ impl.setTreeServlet(new DataTreeHttpServlet());
try {
impl.init();
} catch (Exception e) {
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 5839738e6..897fcc8d0 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
@@ -30,10 +30,12 @@ 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.config.HostInfo;
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.model.HtDatabaseMaintenance;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.test.util.HostInfoForTest;
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.MaintenanceBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.MaintenanceEntity;
@@ -53,9 +55,10 @@ public class TestMaintenanceServiceData {
@BeforeClass
public static void init() throws Exception {
- dbProvider = new ElasticSearchDataProvider(TestCRUDforDatabase.hosts);
+ HostInfo[] hosts = HostInfoForTest.get();
+ dbProvider = new ElasticSearchDataProvider(hosts);
dbProvider.waitForYellowDatabaseStatus(30, TimeUnit.SECONDS);
- dbRawProvider = HtDatabaseClient.getClient(TestCRUDforDatabase.hosts);
+ dbRawProvider = HtDatabaseClient.getClient(hosts);
service = dbProvider.getHtDatabaseMaintenance();
}
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 83f8de89e..7afc5214c 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
@@ -29,20 +29,20 @@ 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.config.HostInfo;
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.test.util.HostInfoForTest;
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;
/**
* @author Michael Dürre
- *
*/
public class TestMediatorServerService {
- private static final String SERVERID = null;
private static ElasticSearchDataProvider dbProvider;
private static HtDatabaseClient dbRawProvider;
private static MediatorServerDataProvider service = null;
@@ -50,13 +50,11 @@ public class TestMediatorServerService {
@BeforeClass
public static void init() throws Exception {
-
- dbProvider = new ElasticSearchDataProvider(TestCRUDforDatabase.hosts);
+ HostInfo[] hosts = HostInfoForTest.get();
+ dbProvider = new ElasticSearchDataProvider(hosts);
dbProvider.waitForYellowDatabaseStatus(30, TimeUnit.SECONDS);
- dbRawProvider = HtDatabaseClient.getClient(TestCRUDforDatabase.hosts);
- service = new MediatorServerDataProvider(TestCRUDforDatabase.hosts);
-
-
+ dbRawProvider = HtDatabaseClient.getClient(hosts);
+ service = new MediatorServerDataProvider(hosts);
}
@Test
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestNuMappings.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestNuMappings.java
index f9c8812a8..bcd2ea75d 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestNuMappings.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestNuMappings.java
@@ -21,9 +21,7 @@
*/
package org.onap.ccsdk.features.sdnr.wt.dataprovider.test;
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JsonMappingException;
+import static org.junit.Assert.assertTrue;
import java.io.IOException;
import org.junit.Test;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools.YangToolsMapper;
@@ -34,28 +32,20 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro
public class TestNuMappings {
@Test
- public void test33() {
+ public void testMapObjectToJson() throws IOException {
+ YangToolsMapper mapper = new YangToolsMapper();
+
Faultcurrent c = new FaultcurrentBuilder().setSeverity(SeverityType.Critical).build();
+ String json = mapper.writeValueAsString(c);
+ assertTrue("Critical expected", json.contains(SeverityType.Critical.getName()));
+ }
+
+ @Test
+ public void testMapJsonToObject() throws IOException {
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();
- }
+
+ Faultcurrent f = mapper.readValue("{\"severity\":\"Critical\"}", Faultcurrent.class);
+ assertTrue("Critical expected", f.getSeverity().equals(SeverityType.Critical));
}
+
}
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestTimestampFilter.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestTimestampFilter.java
index 39377d730..e757e24d3 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestTimestampFilter.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestTimestampFilter.java
@@ -30,134 +30,165 @@ import java.util.List;
import org.json.JSONObject;
import org.junit.Test;
+import org.mockito.Mockito;
import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilder;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.QueryByFilter;
+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.entity.input.Filter;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.entity.input.FilterBuilder;
-public class TestTimestampFilter {
+public class TestTimestampFilter extends Mockito {
@Test
public void testTimestampRange() {
final String PROPERTY_TIMESTAMP = "timestamp";
List<Filter> filters =
Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2017*").build());
- QueryBuilder query = QueryByFilter.fromFilter(filters);
+ EntityInput input = mock(EntityInput.class);
+ when(input.getFilter()).thenReturn(filters);
+ QueryBuilder query = new QueryByFilter(input).getQueryBuilderByFilter();
assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2017-01-01T00:00:00.0Z", "2018-01-01T00:00:00.0Z");
filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2*").build());
- query = QueryByFilter.fromFilter(filters);
+ when(input.getFilter()).thenReturn(filters);
+ query = new QueryByFilter(input).getQueryBuilderByFilter();
assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2000-01-01T00:00:00.0Z", "3000-01-01T00:00:00.0Z");
filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("20*").build());
- query = QueryByFilter.fromFilter(filters);
+ when(input.getFilter()).thenReturn(filters);
+ query = new QueryByFilter(input).getQueryBuilderByFilter();
assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2000-01-01T00:00:00.0Z", "2100-01-01T00:00:00.0Z");
filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("205*").build());
- query = QueryByFilter.fromFilter(filters);
+ when(input.getFilter()).thenReturn(filters);
+ query = new QueryByFilter(input).getQueryBuilderByFilter();
assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-01-01T00:00:00.0Z", "2060-01-01T00:00:00.0Z");
filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050*").build());
- query = QueryByFilter.fromFilter(filters);
+ when(input.getFilter()).thenReturn(filters);
+ query = new QueryByFilter(input).getQueryBuilderByFilter();
assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-01-01T00:00:00.0Z", "2051-01-01T00:00:00.0Z");
filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-*").build());
- query = QueryByFilter.fromFilter(filters);
+ when(input.getFilter()).thenReturn(filters);
+ query = new QueryByFilter(input).getQueryBuilderByFilter();
assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-01-01T00:00:00.0Z", "2051-01-01T00:00:00.0Z");
filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-1*").build());
- query = QueryByFilter.fromFilter(filters);
+ when(input.getFilter()).thenReturn(filters);
+ query = new QueryByFilter(input).getQueryBuilderByFilter();
assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-01T00:00:00.0Z", "2051-01-01T00:00:00.0Z");
filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10*").build());
- query = QueryByFilter.fromFilter(filters);
+ when(input.getFilter()).thenReturn(filters);
+ query = new QueryByFilter(input).getQueryBuilderByFilter();
assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-01T00:00:00.0Z", "2050-11-01T00:00:00.0Z");
filters =
Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-*").build());
- query = QueryByFilter.fromFilter(filters);
+ when(input.getFilter()).thenReturn(filters);
+ query = new QueryByFilter(input).getQueryBuilderByFilter();
assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-01T00:00:00.0Z", "2050-11-01T00:00:00.0Z");
filters =
Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-0*").build());
- query = QueryByFilter.fromFilter(filters);
+ when(input.getFilter()).thenReturn(filters);
+ query = new QueryByFilter(input).getQueryBuilderByFilter();
assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-01T00:00:00.0Z", "2050-10-10T00:00:00.0Z");
filters = Arrays
.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-02*").build());
- query = QueryByFilter.fromFilter(filters);
+ when(input.getFilter()).thenReturn(filters);
+ query = new QueryByFilter(input).getQueryBuilderByFilter();
assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-02T00:00:00.0Z", "2050-10-03T00:00:00.0Z");
filters = Arrays
.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14*").build());
- query = QueryByFilter.fromFilter(filters);
+ when(input.getFilter()).thenReturn(filters);
+ query = new QueryByFilter(input).getQueryBuilderByFilter();
assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T00:00:00.0Z", "2050-10-15T00:00:00.0Z");
filters = Arrays
.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14T*").build());
- query = QueryByFilter.fromFilter(filters);
+ when(input.getFilter()).thenReturn(filters);
+ query = new QueryByFilter(input).getQueryBuilderByFilter();
assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T00:00:00.0Z", "2050-10-15T00:00:00.0Z");
filters = Arrays
.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14T1*").build());
- query = QueryByFilter.fromFilter(filters);
+ when(input.getFilter()).thenReturn(filters);
+ query = new QueryByFilter(input).getQueryBuilderByFilter();
assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T10:00:00.0Z", "2050-10-14T20:00:00.0Z");
filters = Arrays
.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14T12*").build());
- query = QueryByFilter.fromFilter(filters);
+ when(input.getFilter()).thenReturn(filters);
+ query = new QueryByFilter(input).getQueryBuilderByFilter();
assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T12:00:00.0Z", "2050-10-14T13:00:00.0Z");
filters = Arrays
.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14T12:*").build());
- query = QueryByFilter.fromFilter(filters);
+ when(input.getFilter()).thenReturn(filters);
+ query = new QueryByFilter(input).getQueryBuilderByFilter();
assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T12:00:00.0Z", "2050-10-14T13:00:00.0Z");
filters = Arrays
.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14T12:4*").build());
- query = QueryByFilter.fromFilter(filters);
+ when(input.getFilter()).thenReturn(filters);
+ query = new QueryByFilter(input).getQueryBuilderByFilter();
assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T12:40:00.0Z", "2050-10-14T12:50:00.0Z");
filters = Arrays.asList(
new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14T12:42*").build());
- query = QueryByFilter.fromFilter(filters);
+ when(input.getFilter()).thenReturn(filters);
+ query = new QueryByFilter(input).getQueryBuilderByFilter();
assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T12:42:00.0Z", "2050-10-14T12:43:00.0Z");
filters = Arrays.asList(
new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14T12:42:*").build());
- query = QueryByFilter.fromFilter(filters);
+ when(input.getFilter()).thenReturn(filters);
+ query = new QueryByFilter(input).getQueryBuilderByFilter();
assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T12:42:00.0Z", "2050-10-14T12:43:00.0Z");
filters = Arrays.asList(
new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14T12:42:5*").build());
- query = QueryByFilter.fromFilter(filters);
+ when(input.getFilter()).thenReturn(filters);
+ query = new QueryByFilter(input).getQueryBuilderByFilter();
assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T12:42:50.0Z", "2050-10-14T12:43:00.0Z");
filters = Arrays.asList(
new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14T12:42:56*").build());
- query = QueryByFilter.fromFilter(filters);
+ when(input.getFilter()).thenReturn(filters);
+ query = new QueryByFilter(input).getQueryBuilderByFilter();
assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T12:42:56.0Z", "2050-10-14T12:42:57.0Z");
}
@Test
public void testExtra() {
final String PROPERTY_TIMESTAMP = "end";
- List<Filter> filters = null;
- QueryBuilder query = null;
+ EntityInput input = mock(EntityInput.class);
+ List<Filter> filters;
+
filters = Arrays
.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2020-02-19T*").build());
- query = QueryByFilter.fromFilter(filters);
+ when(input.getFilter()).thenReturn(filters);
+ QueryBuilder query = new QueryByFilter(input).getQueryBuilderByFilter();
assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2020-02-19T00:00:00.0Z", "2020-02-20T00:00:00.0Z");
+
filters = Arrays
.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2020-02-19*").build());
- query = QueryByFilter.fromFilter(filters);
+ when(input.getFilter()).thenReturn(filters);
+ query = new QueryByFilter(input).getQueryBuilderByFilter();
assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2020-02-19T00:00:00.0Z", "2020-02-20T00:00:00.0Z");
+
filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2020*").build());
- query = QueryByFilter.fromFilter(filters);
+ when(input.getFilter()).thenReturn(filters);
+ query = new QueryByFilter(input).getQueryBuilderByFilter();
assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2020-01-01T00:00:00.0Z", "2021-01-01T00:00:00.0Z");
}
+
private void assertRange(JSONObject rangeQuery, String property, String lower, String upper) {
System.out.println("==test for " + rangeQuery.toString());
assertTrue(rangeQuery.has("range"));
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestTree.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestTree.java
new file mode 100644
index 000000000..f2a7ff951
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestTree.java
@@ -0,0 +1,81 @@
+/*
+ * ============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.test;
+
+import java.io.IOException;
+import java.util.Arrays;
+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.config.HostInfo;
+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.http.DataTreeHttpServlet;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.DataTreeHttpServlet.EntityWithTree;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.DataTreeHttpServlet.FilterMode;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.DataTreeObject;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.impl.DataTreeProviderImpl;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.test.util.HostInfoForTest;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Entity;
+
+/**
+ * @author Michael Dürre
+ *
+ */
+public class TestTree {
+
+ private static ElasticSearchDataProvider dbProvider;
+ private static HtDatabaseClient dbRawProvider;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ HostInfo[] hosts = HostInfoForTest.get();
+ dbProvider = new ElasticSearchDataProvider(hosts);
+ dbProvider.waitForYellowDatabaseStatus(30, TimeUnit.SECONDS);
+ dbRawProvider = HtDatabaseClient.getClient(hosts);
+ }
+
+ @Test
+ public void testInventoryTree() throws IOException {
+ DataTreeProviderImpl provider = new DataTreeProviderImpl();
+ provider.setDatabaseClient(dbRawProvider);
+ DeleteByQueryRequest query = new DeleteByQueryRequest(Entity.Inventoryequipment.getName(), true);
+ query.setQuery(QueryBuilders.matchAllQuery().toJSON());
+ dbRawProvider.deleteByQuery(query);
+
+ DataTreeObject tree = provider.readInventoryTree(null, null, FilterMode.Lazy);
+
+ tree = provider.readInventoryTree(Arrays.asList("sim1"), "CARD", FilterMode.Lazy);
+ System.out.println(tree.toJSON());
+
+ }
+
+ @Test
+ public void testUriConversion() {
+ EntityWithTree e = DataTreeHttpServlet.getEntity("/tree/read-inventoryequipment-tree/sim1/sim1%2FODU");
+ System.out.println(e);
+ e = DataTreeHttpServlet.getEntity("/tree/read-inventoryequipment-tree/");
+ System.out.println(e);
+ }
+}
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 585f7dee2..4221891b3 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,19 +25,19 @@ 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.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.dataprovider.database.EsDataObjectReaderWriter;
+import org.onap.ccsdk.features.sdnr.wt.common.database.requests.CreateIndexRequest;
+import org.onap.ccsdk.features.sdnr.wt.common.database.requests.DeleteIndexRequest;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.EsDataObjectReaderWriter2;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.test.util.HostInfoForTest;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.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;
@@ -58,22 +58,12 @@ 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.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();
- 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 {
@@ -86,9 +76,10 @@ 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());
@@ -104,50 +95,39 @@ 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));
- }
-
- 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;
- }
+ //TODO - Guilin
+ //out("Equal? "+netconfNode.equals(generatedNode));
}
@Test
- public void test2() throws Exception {
+ public void test2() throws Exception {
- 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 = 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);
+ final String idx = "inventorytest";
+ HostInfo[] hostInfo = HostInfoForTest.get();
+ HtDatabaseClient db = HtDatabaseClient.getClient(hostInfo);
+ EsDataObjectReaderWriter2<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.Data> dataRW =
+ new EsDataObjectReaderWriter2<>(db, Entity.Inventoryequipment,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.Data.class);
+ if (!db.isExistsIndex(idx)) {
+ db.createIndex(new CreateIndexRequest(idx));
+ }
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);
out(d2.toString());
+ if (db.isExistsIndex(idx)) {
+ db.deleteIndex(new DeleteIndexRequest(idx));
+ }
}
@Test
- public void test3() throws IOException {
+ public void test3() throws IOException {
PerformanceDataBuilder performanceBuilder = new PerformanceDataBuilder();
performanceBuilder.setEs(99);
@@ -168,88 +148,125 @@ public class TestYangGenSalMapping {
@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\": \"Period15Min\",\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" + "}";
+ // @formatter:off
+ 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\": \"Period15Min\",\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"
+ + "}";
+ // @formatter:on
// 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\": \"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" +
- "}";
-
+ // @formatter:off
+ 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"
+ + "}";
+ // @formatter:on
// Map to JSON String to Object
Data generatedNode = mapper.readValue(jsonString.getBytes(), Data.class);
out(generatedNode.toString()); // Print it with specified indentation
@@ -260,11 +277,12 @@ public class TestYangGenSalMapping {
@Test
public void test6() throws Exception {
out(method());
- HtDatabaseClient dbClient = HtDatabaseClient.getClient(getHostinfo());
- String PMDATA15M_TYPE = "historicalperformance15min";
+ HostInfo[] hostInfo = HostInfoForTest.get();
+ HtDatabaseClient dbClient = HtDatabaseClient.getClient(hostInfo);
- 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);
+ EsDataObjectReaderWriter2<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.Data> pm15mRW =
+ new EsDataObjectReaderWriter2<>(dbClient, Entity.Historicalperformance15min,
+ 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();
@@ -283,12 +301,13 @@ 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());
@@ -297,20 +316,21 @@ public class TestYangGenSalMapping {
@Test
public void test7() throws Exception {
out(method());
- String ESDATATYPE_MEDIATORSERVER = Entity.MediatorServer.getName();
- 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;
+ HostInfo[] hostInfo = HostInfoForTest.get();
+ HtDatabaseClient dbClient = HtDatabaseClient.getClient(hostInfo);
- mediatorserverRW = new EsDataObjectReaderWriter<>(dbClient, ESDATATYPE_MEDIATORSERVER,
+ EsDataObjectReaderWriter2<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.mediator.server.list.output.Data> mediatorserverRW;
+ mediatorserverRW = new EsDataObjectReaderWriter2<>(dbClient, Entity.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);
}
@@ -320,15 +340,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));
}
/* ---------------------------------
@@ -339,7 +359,8 @@ 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);
@@ -377,10 +398,9 @@ 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(),
@@ -390,6 +410,7 @@ public class TestYangGenSalMapping {
}
}
+
private static QueryBuilder setSortOrder(QueryBuilder query, @Nullable List<Sortorder> sortorder) {
return setSortOrder(query, sortorder, "");
}
@@ -407,9 +428,12 @@ 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);
}
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangProvider.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangProvider.java
index 19bd76cae..244d6b053 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangProvider.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangProvider.java
@@ -48,7 +48,6 @@ import org.junit.Test;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.YangFileProvider;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.YangFilename;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.YangSchemaHttpServlet;
-
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/util/HostInfoForTest.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/util/HostInfoForTest.java
new file mode 100644
index 000000000..8ea4b13aa
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/util/HostInfoForTest.java
@@ -0,0 +1,53 @@
+/*
+ * ============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.test.util;
+
+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.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Using pom.xml property to setup URL to database in JUnit tests. Setup impom.xml: <br>
+ * <properties><databaseport>49402</databaseport> </properties> in cooperation with plugin
+ * <groupId>com.github.alexcojocaru</groupId> <artifactId>elasticsearch-maven-plugin</artifactId>
+ * In local development test environment port 49200 is used.
+ */
+public class HostInfoForTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(HostInfoForTest.class);
+
+ // static methods
+ public static HostInfo[] get() {
+ int port;
+
+ String portAsString = System.getProperty("databaseport");
+ if (portAsString == null | portAsString.isEmpty())
+ port = 49200;
+ else
+ port = Integer.valueOf(portAsString);
+ HostInfo testHost = new HostInfo("localhost", port, Protocol.HTTP);
+ LOG.info("Testhost {}",testHost);
+ return new HostInfo[] {testHost};
+ }
+ // end of static methods
+}
diff --git a/sdnr/wt/data-provider/provider/src/test/resources/simplelogger.properties b/sdnr/wt/data-provider/provider/src/test/resources/simplelogger.properties
index 9943c2fc3..056e91eda 100644
--- a/sdnr/wt/data-provider/provider/src/test/resources/simplelogger.properties
+++ b/sdnr/wt/data-provider/provider/src/test/resources/simplelogger.properties
@@ -19,10 +19,12 @@
#
#
-org.slf4j.simpleLogger.defaultLogLevel=INFO
+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
org.slf4j.simpleLogger.org.onap.ccsdk.features.sdnr.wt.dataprovider=DEBUG
+org.slf4j.simpleLogger.org.onap.ccsdk.features.sdnr.wt.common=DEBUG
+