diff options
21 files changed, 406 insertions, 222 deletions
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/ConfigurationFileRepresentation.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/ConfigurationFileRepresentation.java index fe43837e2..96bfa070b 100644 --- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/ConfigurationFileRepresentation.java +++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/ConfigurationFileRepresentation.java @@ -29,7 +29,6 @@ import java.io.FileWriter; import java.io.IOException; import java.util.HashMap; import java.util.Optional; - import org.onap.ccsdk.features.sdnr.wt.common.configuration.filechange.ConfigFileObserver; import org.onap.ccsdk.features.sdnr.wt.common.configuration.filechange.IConfigChangedListener; import org.onap.ccsdk.features.sdnr.wt.common.configuration.subtypes.Section; @@ -71,6 +70,8 @@ public class ConfigurationFileRepresentation implements IConfigChangedListener { if (!this.mFile.createNewFile()) { LOG.error("Can not create file {}", f.getAbsolutePath()); } + this.mFile.setReadable(true, false); + this.mFile.setWritable(true, false); } reLoad(); diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/subtypes/Section.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/subtypes/Section.java index 7fb58a165..c6b121ae3 100644 --- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/subtypes/Section.java +++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/subtypes/Section.java @@ -29,7 +29,6 @@ import java.util.Objects; import java.util.Optional; import java.util.regex.Matcher; import java.util.regex.Pattern; - import org.eclipse.jdt.annotation.NonNull; import org.onap.ccsdk.features.sdnr.wt.common.configuration.exception.ConversionException; import org.slf4j.Logger; @@ -51,7 +50,8 @@ public class Section { // constants private static final Logger LOG = LoggerFactory.getLogger(Section.class); private static final String DELIMITER = "="; - private static final String COMMENTCHARS[] = {"#", ";"}; + private static final String DEFAULT_COMMENTCHAR = "#"; + private static final String COMMENTCHARS[] = {DEFAULT_COMMENTCHAR, ";"}; private static final String ENVVARIABLE = "${"; private static final String REGEXENVVARIABLE = "(\\$\\{[A-Z0-9_-]+\\})"; // end of constants @@ -132,6 +132,20 @@ public class Section { return value; } + public boolean addComment(String key,String comment) { + if (this.values.containsKey(key)) { + this.values.get(key).addComment(DEFAULT_COMMENTCHAR+comment); + } + return false; + } + + public boolean removeComment(String key,String comment) { + if (this.values.containsKey(key)) { + this.values.get(key).removeComment(DEFAULT_COMMENTCHAR+comment); + } + return false; + } + public void setProperty(String key, String value) { boolean isuncommented = this.isCommentLine(key); if (isuncommented) { diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/subtypes/SectionValue.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/subtypes/SectionValue.java index a4758f1b5..f513e011c 100644 --- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/subtypes/SectionValue.java +++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/subtypes/SectionValue.java @@ -25,7 +25,7 @@ import java.util.ArrayList; import java.util.List; /** - * + * * @author Michael Dürre, Herbert Eiselt * */ @@ -35,7 +35,7 @@ class SectionValue { private String value; private final List<String> comments; private boolean isUncommented; - // end of variables + // end of variables // constructors public SectionValue(String value, List<String> commentsForValue, boolean isuncommented) { @@ -72,6 +72,16 @@ class SectionValue { return this; } + public void addComment(String comment) { + this.comments.add(comment); + this.isUncommented = false; + } + + public void removeComment(String comment) { + this.comments.remove(comment); + this.isUncommented = this.comments.size()==0; + } + public List<String> getComments() { return comments; } diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/ExtRestClient.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/ExtRestClient.java index 836c0fae7..f8734d5a6 100644 --- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/ExtRestClient.java +++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/ExtRestClient.java @@ -91,7 +91,6 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.responses.SearchResponse; import org.onap.ccsdk.features.sdnr.wt.common.database.responses.UpdateByQueryResponse; import org.onap.ccsdk.features.sdnr.wt.common.database.responses.UpdateResponse; import org.onap.ccsdk.features.sdnr.wt.common.http.BaseHTTPClient; -import org.osgi.framework.Version; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/Portstatus.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/Portstatus.java index 475178b4c..8b43eb157 100644 --- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/Portstatus.java +++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/Portstatus.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP : ccsdk features * ================================================================================ - * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. + * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. * All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,13 +18,13 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.ccsdk.features.sdnr.wt.common.database; import java.io.IOException; import java.net.InetSocketAddress; import java.net.SocketAddress; import java.nio.channels.SocketChannel; - import org.onap.ccsdk.features.sdnr.wt.common.database.config.HostInfo; public class Portstatus { diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/ListAliasesResponse.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/ListAliasesResponse.java index 7956b2bfc..c73af27fa 100644 --- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/ListAliasesResponse.java +++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/ListAliasesResponse.java @@ -22,7 +22,6 @@ package org.onap.ccsdk.features.sdnr.wt.common.database.responses; import java.text.ParseException; -import java.util.ArrayList; import java.util.List; import org.elasticsearch.client.Response; diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestConfig.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestConfig.java index cbe0b9c4d..7f1dc962c 100644 --- a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestConfig.java +++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestConfig.java @@ -25,13 +25,11 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; - import java.io.File; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import java.nio.file.Files; - import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -53,6 +51,8 @@ public class TestConfig { private static final int TESTVALUE1 = 123; private static final int TESTVALUE1_2 = 1234; private static final boolean TESTVALUE2 = true; + private static final String TESTCOMMENT1 = "my comment for this value"; + private static final String TESTCOMMENT1_2 = "my comment line 2 for this value"; private static final String TESTVALUE3 = "http://localhost:2223"; private static final String TESTVALUE4 = "httasdasdas"; private static final String TESTCONTENT1 = " [test]\n" + TESTKEY1 + "=" + TESTVALUE1 + "\n" + "#her a comment\n" @@ -102,6 +102,8 @@ public class TestConfig { Section section = confiuration.addSection(SECTIONNAME); section.setProperty(TESTKEY1, String.valueOf(TESTVALUE1)); + section.addComment(TESTKEY1, TESTCOMMENT1); + section.addComment(TESTKEY1, TESTCOMMENT1_2); section.setProperty(TESTKEY2, String.valueOf(TESTVALUE2)); section.setProperty(TESTKEY3, String.valueOf(TESTVALUE3)); confiuration.save(); diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbQueries.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbQueries.java index 127908c08..b2e5e857f 100644 --- a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbQueries.java +++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbQueries.java @@ -30,76 +30,194 @@ 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.common.database.queries.SortOrder; -import org.onap.ccsdk.features.sdnr.wt.common.test.JSONAssert; public class TestDbQueries { + // @formatter:off private static final String MATCH_ALL_QUERY = - "{\n" + " \"query\": {\n" + " \"match_all\" : {\n" + " }\n" + " }\n" + "}"; + "{\n" + + " \"query\": {\n" + + " \"match_all\" : {\n" + + " }\n" + + " }\n" + + "}"; private static final String MATCH_QUERY_KEY = "is-required"; private static final Object MATCH_QUERY_VALUE = true; - private static final String MATCH_QUERY = "{\n" + " \"query\": {\n" + " \"match\" : {\n" - + " \"" + MATCH_QUERY_KEY + "\" : " + MATCH_QUERY_VALUE + "\n" + " }\n" + " }\n" + "}"; + private static final String MATCH_QUERY = "{\n" + + " \"query\": {\n" + + " \"match\" : {\n" + + " \"" + + MATCH_QUERY_KEY + "\" : " + + MATCH_QUERY_VALUE + "\n" + + " }\n" + + " }\n" + + "}"; private static final String MATCH_QUERY_KEY2 = "node-id"; private static final Object MATCH_QUERY_VALUE2 = "sim2"; private static final String BOOL_QUERY_MUST = - "{\n" + " \"query\": {\n" + " \"bool\": {\n" + " \"must\": [\n" + " {\n" - + " \"match\": {\n" + " \"" + MATCH_QUERY_KEY + "\": " - + MATCH_QUERY_VALUE + "\n" + " }\n" + " },\n" - + " {\n" + " \"match\": {\n" + " \"" - + MATCH_QUERY_KEY2 + "\":" + MATCH_QUERY_VALUE2 + " \n" + " }\n" - + " }\n" + " ]\n" + " }\n" + " }\n" + "}"; - private static final String BOOL_QUERY_MUST_SINGLE = "{\n" + " \"query\": {\n" + " \"bool\": {\n" - + " \"must\": {\n" + " \"match\": {\n" + " \"" - + MATCH_QUERY_KEY + "\": " + MATCH_QUERY_VALUE + "\n" + " }\n" + " }\n" - + " }\n" + " }\n" + "}"; - private static final String BOOL_QUERY_SHOULD = "{\n" + " \"query\": {\n" + " \"bool\": {\n" - + " \"should\": [\n" + " {\n" + " \"match\": {\n" - + " \"" + MATCH_QUERY_KEY + "\": " + MATCH_QUERY_VALUE + "\n" - + " }\n" + " },\n" + " {\n" - + " \"match\": {\n" + " \"" + MATCH_QUERY_KEY2 + "\":" - + MATCH_QUERY_VALUE2 + " \n" + " }\n" + " }\n" + " ]\n" - + " }\n" + " }\n" + "}"; - private static final String BOOL_QUERY_SHOULD_SINGLE = "{\n" + " \"query\": {\n" + " \"bool\": {\n" - + " \"should\": {\n" + " \"match\": {\n" + " \"" - + MATCH_QUERY_KEY + "\": " + MATCH_QUERY_VALUE + "\n" + " }\n" + " }\n" - + " }\n" + " }\n" + "}"; + "{\n" + + " \"query\": {\n" + + " \"bool\": {\n" + + " \"must\": [\n" + + " {\n" + + " \"match\": {\n" + + " \"" + + MATCH_QUERY_KEY + "\": " + + MATCH_QUERY_VALUE + "\n" + + " }\n" + + " },\n" + + " {\n" + + " \"match\": {\n" + + " \"" + + MATCH_QUERY_KEY2 + "\":" + + MATCH_QUERY_VALUE2 + " \n" + + " }\n" + + " }\n" + + " ]\n" + + " }\n" + + " }\n" + + "}"; + private static final String BOOL_QUERY_MUST_SINGLE = "{\n" + + " \"query\": {\n" + + " \"bool\": {\n" + + " \"must\": {\n" + + " \"match\": {\n" + + " \"" + + MATCH_QUERY_KEY + "\": " + + MATCH_QUERY_VALUE + "\n" + + " }\n" + + " }\n" + + " }\n" + + " }\n" + + "}"; + private static final String BOOL_QUERY_SHOULD = "{\n" + + " \"query\": {\n" + + " \"bool\": {\n" + + " \"should\": [\n" + + " {\n" + + " \"match\": {\n" + + " \"" + + MATCH_QUERY_KEY + "\": " + + MATCH_QUERY_VALUE + "\n" + + " }\n" + + " },\n" + + " {\n" + + " \"match\": {\n" + + " \"" + + MATCH_QUERY_KEY2 + "\":" + + MATCH_QUERY_VALUE2 + " \n" + + " }\n" + + " }\n" + + " ]\n" + + " }\n" + + " }\n" + + "}"; + private static final String BOOL_QUERY_SHOULD_SINGLE = "{\n" + + " \"query\": {\n" + + " \"bool\": {\n" + + " \"should\": {\n" + + " \"match\": {\n" + + " \"" + + MATCH_QUERY_KEY + "\": " + + MATCH_QUERY_VALUE + "\n" + + " }\n" + + " }\n" + + " }\n" + + " }\n" + + "}"; private static final String RANGE_QUERY_KEY = "timestamp"; private static final String RANGE_QUERY_LTEND = "2017-08-10T20:00:00.0Z"; - private static final String RANGE_QUERY = "{\n" + " \"query\": {\n" + " \"range\" : {\n" - + " \"" + RANGE_QUERY_KEY + "\" : {\n" + " \"lte\" : \"" + RANGE_QUERY_LTEND - + "\",\n" + " \"boost\": 2.0\n" + " }\n" + " }\n" + " }\n" + "}"; - private static final String RANGEBOOL_QUERY = "{\n" + " \"query\": {\n" + " \"bool\": {\n" - + " \"must\": [\n" + " {\n" + " \"match\": {\n" - + " \"is-required\": true\n" + " }\n" + " },\n" - + " {\n" + " \"regexp\": {\n" + " \"node-id\": {\n" + private static final String RANGE_QUERY = "{\n" + + " \"query\": {\n" + + " \"range\" : {\n" + + " \"" + RANGE_QUERY_KEY + "\" : {\n" + + " \"lte\" : \"" + RANGE_QUERY_LTEND + "\",\n" + + " \"boost\": 2.0\n" + + " }\n" + + " }\n" + + " }\n" + + "}"; + private static final String RANGEBOOL_QUERY = "{\n" + + " \"query\": {\n" + + " \"bool\": {\n" + + " \"must\": [\n" + + " {\n" + + " \"match\": {\n" + + " \"is-required\": true\n" + + " }\n" + + " },\n" + + " {\n" + + " \"regexp\": {\n" + + " \"node-id\": {\n" + " \"max_determinized_states\": 10000,\n" - + " \"flags\": \"ALL\",\n" + " \"value\": \"sim.*\"\n" - + " }\n" + " }\n" + " }\n" + " ]\n" - + " }\n" + " }\n" + "}"; + + " \"flags\": \"ALL\",\n" + + " \"value\": \"sim.*\"\n" + + " }\n" + + " }\n" + + " }\n" + + " ]\n" + + " }\n" + + " }\n" + + "}"; private static final String AGG_FIELD = "severity"; private static final String AGG_QUERY = - "{\n" + " \"query\": {\n" + " \"match_all\": {}\n" + " },\n" + " \"aggs\": {\n" - + " \"severity\": {\n" + " \"terms\": {\n" + " \"field\": \"" - + AGG_FIELD + "\"\n" + " }\n" + " }\n" + " }\n" + "}"; + "{\n" + + " \"query\": {\n" + + " \"match_all\": {}\n" + + " },\n" + + " \"aggs\": {\n" + + " \"severity\": {\n" + + " \"terms\": {\n" + + " \"field\": \"" + AGG_FIELD + "\"\n" + + " }\n" + + " }\n" + + " }\n" + + "}"; private static final long FROMANDSIZE_QUERY_SIZE = 20; private static final long FROMANDSIZE_QUERY_FROM = 120; - private static final String FROMANDSIZE_QUERY = "{\n" + " \"size\": " + FROMANDSIZE_QUERY_SIZE + ",\n" - + " \"query\": {\n" + " \"match_all\": {}\n" + " },\n" + " \"from\":" - + FROMANDSIZE_QUERY_FROM + "\n" + "}"; + private static final String FROMANDSIZE_QUERY = "{\n" + + " \"size\": " + FROMANDSIZE_QUERY_SIZE + ",\n" + + " \"query\": {\n" + + " \"match_all\": {}\n" + + " },\n" + + " \"from\":" + FROMANDSIZE_QUERY_FROM + "\n" + + "}"; private static final String TERMQUERY_KEY = "node-id"; private static final String TERMQUERY_VALUE = "abc"; - private static final String TERM_QUERY = "{\n" + " \"query\": {\n" + " \"term\": {\n" + " \"" - + TERMQUERY_KEY + "\": \"" + TERMQUERY_VALUE + "\"\n" + " }\n" + " }\n" + "}"; + private static final String TERM_QUERY = "{\n" + + " \"query\": {\n" + + " \"term\": {\n" + + " \"" + TERMQUERY_KEY + "\": \"" + TERMQUERY_VALUE + "\"\n" + + " }\n" + + " }\n" + + "}"; private static final String SORTING_PROPERTY = "node-id"; - private static final String SORTING_QUERY_ASC = "{\n" + " \"query\": {\n" + " \"match_all\": {}\n" - + " },\n" + " \"sort\": [\n" + " {\n" + " \"" + SORTING_PROPERTY + "\": {\n" - + " \"order\": \"asc\"\n" + " }\n" + " }\n" + " ]\n" + "}"; - private static final String SORTING_QUERY_DESC = "{\n" + " \"query\": {\n" + " \"match_all\": {}\n" - + " },\n" + " \"sort\": [\n" + " {\n" + " \"" + SORTING_PROPERTY + "\": {\n" - + " \"order\": \"desc\"\n" + " }\n" + " }\n" + " ]\n" + "}"; - + private static final String SORTING_QUERY_ASC = "{\n" + + " \"query\": {\n" + + " \"match_all\": {}\n" + + " },\n" + + " \"sort\": [\n" + + " {\n" + + " \"" + SORTING_PROPERTY + "\": {\n" + + " \"order\": \"asc\"\n" + + " }\n" + + " }\n" + + " ]\n" + + "}"; + private static final String SORTING_QUERY_DESC = "{\n" + + " \"query\": {\n" + + " \"match_all\": {}\n" + + " },\n" + + " \"sort\": [\n" + + " {\n" + + " \"" + SORTING_PROPERTY + "\": {\n" + + " \"order\": \"desc\"\n" + + " }\n" + + " }\n" + + " ]\n" + + "}"; + // @formatter:on private void testEquals(String message, String json, QueryBuilder query) { this.testEquals(message, json, query, true); } diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestJsonAssert.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestJsonAssert.java index 72eba38e8..4ce92b130 100644 --- a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestJsonAssert.java +++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestJsonAssert.java @@ -21,13 +21,13 @@ */ package org.onap.ccsdk.features.sdnr.wt.common.test; -import static org.junit.Assert.*; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import org.json.JSONArray; import org.json.JSONException; import org.junit.Test; import org.onap.ccsdk.features.sdnr.wt.common.HtAssert; -import org.onap.ccsdk.features.sdnr.wt.common.test.JSONAssert; public class TestJsonAssert { diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestPomfile.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestPomfile.java index 9de285d1b..7089a809d 100644 --- a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestPomfile.java +++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestPomfile.java @@ -24,12 +24,9 @@ package org.onap.ccsdk.features.sdnr.wt.common.test; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; - import java.io.ByteArrayInputStream; -import java.io.FileInputStream; import java.io.IOException; import javax.xml.parsers.ParserConfigurationException; - import org.junit.Test; import org.onap.ccsdk.features.sdnr.wt.common.file.PomFile; import org.onap.ccsdk.features.sdnr.wt.common.file.PomPropertiesFile; @@ -39,17 +36,16 @@ public class TestPomfile { private static final String TESTPROPERTY_KEY = "elasticsearch-rest-client.version"; private static final String TESTPROPERTY_VALUE = "6.4.3"; - private static final String POMFILENAME = "pom.xml"; + private static final String POMFILENAME = "/testpom.xml"; private static final String POM_PROPERTY = "#Generated by org.apache.felix.bundleplugin\n" + "#Tue Nov 19 11:20:33 CET 2019\n" + "version=0.7.0-SNAPSHOT\n" + "groupId=org.onap.ccsdk.features.sdnr.wt\n" + "artifactId=sdnr-wt-data-provider-provider\n"; - //private static final Date DATE_EXPECTED = new Date(119, 10, 19, 11, 20, 33); @Test public void test() { PomFile pom = null; try { - pom = new PomFile(new FileInputStream(POMFILENAME)); + pom = new PomFile(this.getClass().getResourceAsStream(POMFILENAME)); } catch (ParserConfigurationException | SAXException | IOException e) { fail(e.getMessage()); } @@ -59,14 +55,9 @@ public class TestPomfile { } @Test - public void testProp() { + public void testProp() throws IOException { PomPropertiesFile file = null; - try { - file = new PomPropertiesFile(new ByteArrayInputStream(POM_PROPERTY.getBytes())); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + file = new PomPropertiesFile(new ByteArrayInputStream(POM_PROPERTY.getBytes())); assertNotNull(file); assertNotNull(file.getBuildDate()); } diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestPortstatus.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestPortstatus.java index 3ddbcebd0..ec18e0a84 100644 --- a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestPortstatus.java +++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestPortstatus.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP : ccsdk features * ================================================================================ - * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. + * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. * All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,7 +22,6 @@ package org.onap.ccsdk.features.sdnr.wt.common.test; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; - import java.io.IOException; import java.net.ServerSocket; import java.time.Duration; diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/HelpServlet.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/HelpServlet.java index a6f77c72d..a99e1222a 100644 --- a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/HelpServlet.java +++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/HelpServlet.java @@ -89,13 +89,11 @@ public class HelpServlet extends BaseServlet implements IPublicServlet { @Override protected boolean doTrustAll() { - // TODO Auto-generated method stub return false; } @Override protected void trustAll(boolean trust) { - // TODO Auto-generated method stub } @@ -120,13 +118,11 @@ public class HelpServlet extends BaseServlet implements IPublicServlet { @Override protected boolean trustInsecure() { - // TODO Auto-generated method stub return false; } @Override protected boolean isCorsEnabled() { - // TODO Auto-generated method stub return false; } @@ -135,6 +131,5 @@ public class HelpServlet extends BaseServlet implements IPublicServlet { */ public void setOffline(boolean b) { this.isoff = b; - } } diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/HelpServletBase.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/HelpServletBase.java index c163c746f..dbdaace34 100644 --- a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/HelpServletBase.java +++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/HelpServletBase.java @@ -46,10 +46,12 @@ import javax.servlet.http.HttpServletResponse; import org.junit.After; import org.junit.Before; + import com.sun.net.httpserver.HttpExchange; import com.sun.net.httpserver.HttpHandler; import com.sun.net.httpserver.HttpServer; +@SuppressWarnings("restriction") public class HelpServletBase { public static final String RESPONSE_GET = "This is the response get"; diff --git a/sdnr/wt/common/src/test/resources/testpom.xml b/sdnr/wt/common/src/test/resources/testpom.xml new file mode 100644 index 000000000..6fba87af9 --- /dev/null +++ b/sdnr/wt/common/src/test/resources/testpom.xml @@ -0,0 +1,157 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ ============LICENSE_START======================================================= + ~ ONAP : ccsdk features + ~ ================================================================================ + ~ Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. + ~ All rights reserved. + ~ ================================================================================ + ~ Update Copyright (C) 2020 AT&T 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======================================================= + ~ + --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.onap.ccsdk.parent</groupId> + <artifactId>binding-parent</artifactId> + <version>2.0.0-SNAPSHOT</version> + <relativePath/> + </parent> + + <groupId>org.onap.ccsdk.features.sdnr.wt</groupId> + <artifactId>sdnr-wt-common</artifactId> + <version>1.0.0-SNAPSHOT</version> + <packaging>jar</packaging> + + <name>ccsdk-features :: ${project.artifactId}</name> + <licenses> + <license> + <name>Apache License, Version 2.0</name> + <url>http://www.apache.org/licenses/LICENSE-2.0</url> + </license> + </licenses> + + <properties> + <checkstyle.skip>true</checkstyle.skip> <!-- POM configuration --> + <maven.javadoc.skip>true</maven.javadoc.skip> + <maven.build.timestamp.format>yyyy-MM-dd HH:mm</maven.build.timestamp.format> + <buildtime>${maven.build.timestamp} UTC</buildtime> + <databaseport>49400</databaseport> + <elasticsearch-rest-client.version>6.4.3</elasticsearch-rest-client.version> + </properties> + + <dependencies> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>servlet-api</artifactId> + </dependency> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.core</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.json</groupId> + <artifactId>json</artifactId> + </dependency> + <dependency> + <groupId>org.elasticsearch.client</groupId> + <artifactId>elasticsearch-rest-client</artifactId> + <version>${elasticsearch-rest-client.version}</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-core</artifactId> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-annotations</artifactId> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-databind</artifactId> + </dependency> + <dependency> + <groupId>com.google.code.findbugs</groupId> + <artifactId>annotations</artifactId> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.jacoco</groupId> + <artifactId>jacoco-maven-plugin</artifactId> + <configuration> + <excludes> + <exclude>**/gen/**</exclude> + <exclude>**/generated-sources/**</exclude> + <exclude>**/yang-gen-sal/**</exclude> + <exclude>**/pax/**</exclude> + </excludes> + </configuration> + </plugin> + <plugin> + <groupId>com.github.alexcojocaru</groupId> + <artifactId>elasticsearch-maven-plugin</artifactId> + <version>6.16</version> + <configuration> + <skip>${skipTests}</skip> + <clusterName>testCluster</clusterName> + <transportPort>9500</transportPort> + <httpPort>${databaseport}</httpPort> + <version>7.1.1</version> + <timeout>120</timeout> + </configuration> + <executions> + <execution> + <id>start-elasticsearch</id> + <phase>process-test-classes</phase> + <goals> + <goal>runforked</goal> + </goals> + </execution> + <execution> + <id>stop-elasticsearch</id> + <phase>prepare-package</phase> + <goals> + <goal>stop</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <systemProperties> + <property> + <name>databaseport</name> + <value>${databaseport}</value> + </property> + </systemProperties> + </configuration> + </plugin> + </plugins> + </build> +</project> diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/ReleaseInformation.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/ReleaseInformation.java index d772dc296..9b7a49346 100644 --- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/ReleaseInformation.java +++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/ReleaseInformation.java @@ -23,7 +23,6 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.setup; import java.util.Map; import java.util.Set; - import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient; import org.onap.ccsdk.features.sdnr.wt.common.database.data.IndicesEntryList; import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.ComponentName; @@ -35,7 +34,6 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.elalto.ElAltoReleaseIn import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.frankfurt.FrankfurtReleaseInformation; import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.frankfurt.FrankfurtReleaseInformationR2; import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.guilin.GuilinReleaseInformation; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.guilin.GuilinReleaseInformationR2; public abstract class ReleaseInformation { @@ -53,7 +51,7 @@ public abstract class ReleaseInformation { /** * get database alias for component - * + * * @param name * @return alias or null if not exists */ @@ -67,7 +65,7 @@ public abstract class ReleaseInformation { /** * get index name for component - * + * * @param comp * @return null if component does not exists in this release, otherwise index name */ @@ -77,7 +75,7 @@ public abstract class ReleaseInformation { /** * get index name for component with prefix - * + * * @param comp * @param prefix * @return null if component does not exists in this release, otherwise index name @@ -88,7 +86,7 @@ public abstract class ReleaseInformation { /** * get database datatype (doctype) for component - * + * * @param name * @return datatype or null if not exists */ @@ -102,7 +100,7 @@ public abstract class ReleaseInformation { /** * get database doctype definition for component - * + * * @param name * @return mappings or null if not exists */ @@ -112,7 +110,7 @@ public abstract class ReleaseInformation { /** * get database settings definition for component - * + * * @param name * @return settings or null if not exists */ @@ -122,7 +120,7 @@ public abstract class ReleaseInformation { /** * get converter for component data - * + * * @param dst destination release * @param comp component to convert * @return @@ -144,8 +142,6 @@ public abstract class ReleaseInformation { return new FrankfurtReleaseInformationR2(); case GUILIN_R1: return new GuilinReleaseInformation(); - case GUILIN_R2: - return new GuilinReleaseInformationR2(); default: return null; } @@ -192,7 +188,7 @@ public abstract class ReleaseInformation { protected abstract boolean runPreInitCommands(HtDatabaseClient dbClient); /** - * + * * @param dbClient * @return if succeeded or not */ diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/Release.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/Release.java index b2442df6b..4f55f4cd7 100644 --- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/Release.java +++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/Release.java @@ -26,15 +26,12 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.data.EsVersion; public enum Release { - EL_ALTO("el alto", "_v1", new EsVersion(2, 2, 0), new EsVersion(2, 2, 0)), FRANKFURT_R1("frankfurt-R1", "-v2", - new EsVersion(6, 4, 3), new EsVersion(6, 8, 6)), FRANKFURT_R2("frankfurt-R2", "-v3", new EsVersion(7, 0, 1), - new EsVersion(7, 6, 1)), - //FRANKFURT_R3("frankfurt-R3","",new EsVersion(6,4,3),new EsVersion(6,8,6)), + EL_ALTO("el alto", "_v1", new EsVersion(2, 2, 0), new EsVersion(2, 2, 0)), + FRANKFURT_R1("frankfurt-R1", "-v2", new EsVersion(6, 4, 3), new EsVersion(6, 8, 6)), + FRANKFURT_R2("frankfurt-R2", "-v3", new EsVersion(7, 0, 1), new EsVersion(7, 6, 1)), + GUILIN_R1("guilin-R1", "-v4", new EsVersion(7,1,1), new EsVersion(7,6,1)); - GUILIN_R1("guilin-R1", "-v4", new EsVersion(6, 4, 3), new EsVersion(6, 8, 6)), GUILIN_R2("guilin-R2", "-v5", - new EsVersion(7, 0, 1), new EsVersion(7, 6, 1)); - - public static final Release CURRENT_RELEASE = Release.FRANKFURT_R1; + public static final Release CURRENT_RELEASE = Release.GUILIN_R1; private final String value; private final String dbSuffix; diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ReleaseGroup.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ReleaseGroup.java index c7d26dbed..993d0261f 100644 --- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ReleaseGroup.java +++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ReleaseGroup.java @@ -23,7 +23,6 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data; import java.util.ArrayList; import java.util.List; - import org.onap.ccsdk.features.sdnr.wt.common.database.data.EsVersion; /** @@ -32,10 +31,9 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.data.EsVersion; */ public enum ReleaseGroup { - EL_ALTO(Release.EL_ALTO), FRANKFURT(Release.FRANKFURT_R1, Release.FRANKFURT_R2), GUILIN(Release.GUILIN_R1, - Release.GUILIN_R2); + EL_ALTO(Release.EL_ALTO), FRANKFURT(Release.FRANKFURT_R1, Release.FRANKFURT_R2), GUILIN(Release.GUILIN_R1); - public static final ReleaseGroup CURRENT_RELEASE = FRANKFURT; + public static final ReleaseGroup CURRENT_RELEASE = GUILIN; private final List<Release> releases; diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/frankfurt/FrankfurtReleaseInformationR2.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/frankfurt/FrankfurtReleaseInformationR2.java index e842b5c7b..f972777b9 100644 --- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/frankfurt/FrankfurtReleaseInformationR2.java +++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/frankfurt/FrankfurtReleaseInformationR2.java @@ -24,6 +24,10 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.frankfurt; import java.io.IOException; import java.util.HashMap; import java.util.Map; +import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient; +import org.onap.ccsdk.features.sdnr.wt.common.database.requests.ClusterSettingsRequest; +import org.onap.ccsdk.features.sdnr.wt.common.database.responses.ClusterSettingsResponse; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.ReleaseInformation; import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.ComponentName; import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.DatabaseInfo; import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.DatabaseInfo7; @@ -31,10 +35,6 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.Release; import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.SearchHitConverter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient; -import org.onap.ccsdk.features.sdnr.wt.common.database.requests.ClusterSettingsRequest; -import org.onap.ccsdk.features.sdnr.wt.common.database.responses.ClusterSettingsResponse; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.ReleaseInformation; public class FrankfurtReleaseInformationR2 extends ReleaseInformation { @@ -45,7 +45,7 @@ public class FrankfurtReleaseInformationR2 extends ReleaseInformation { super(Release.FRANKFURT_R2, createDBMap()); } - private static Map<ComponentName, DatabaseInfo> createDBMap() { + public static Map<ComponentName, DatabaseInfo> createDBMap() { Map<ComponentName, DatabaseInfo> map = new HashMap<>(); map.put(ComponentName.CONNECTIONLOG, new DatabaseInfo7("connectionlog", "connectionlog", "{\"node-id\": {\"type\": \"keyword\"},\"timestamp\": {\"type\": \"date\"},\"status\": {\"type\": \"keyword\"}}")); diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/guilin/GuilinReleaseInformation.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/guilin/GuilinReleaseInformation.java index 2c2ac25a9..e057d82f2 100644 --- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/guilin/GuilinReleaseInformation.java +++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/guilin/GuilinReleaseInformation.java @@ -21,43 +21,25 @@ */ package org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.guilin; -import java.util.HashMap; -import java.util.Map; - +import java.io.IOException; import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient; +import org.onap.ccsdk.features.sdnr.wt.common.database.requests.ClusterSettingsRequest; +import org.onap.ccsdk.features.sdnr.wt.common.database.responses.ClusterSettingsResponse; import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.ReleaseInformation; import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.ComponentName; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.DatabaseInfo; import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.KeepDataSearchHitConverter; import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.Release; import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.SearchHitConverter; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.frankfurt.FrankfurtReleaseInformationR2; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class GuilinReleaseInformation extends ReleaseInformation { - /** - * @param r - * @param dbMap - */ + private final Logger LOG = LoggerFactory.getLogger(GuilinReleaseInformation.class); public GuilinReleaseInformation() { - super(Release.GUILIN_R1, createDBMap()); - - } + super(Release.GUILIN_R1, FrankfurtReleaseInformationR2.createDBMap()); - private static Map<ComponentName, DatabaseInfo> createDBMap() { - Map<ComponentName, DatabaseInfo> map = new HashMap<>(); - map.put(ComponentName.EVENTLOG, new DatabaseInfo("eventlog", "eventlog", "")); - map.put(ComponentName.FAULTCURRENT, new DatabaseInfo("faultcurrent", "faultcurrent", "")); - map.put(ComponentName.FAULTLOG, new DatabaseInfo("faultlog", "faultlog", "")); - map.put(ComponentName.INVENTORY, new DatabaseInfo("inventoryequipment", "inventoryequipment", "")); - map.put(ComponentName.HISTORICAL_PERFORMANCE_15M, - new DatabaseInfo("historicalperformance15min", "historicalperformance15min", "")); - map.put(ComponentName.HISTORICAL_PERFORMANCE_24H, - new DatabaseInfo("historicalperformance24h", "historicalperformance24h", "")); - map.put(ComponentName.REQUIRED_NETWORKELEMENT, - new DatabaseInfo("networkelement-connection", "networkelement-connection", "")); - map.put(ComponentName.MEDIATOR_SERVER, new DatabaseInfo("mediator-server", "mediator-server", "")); - map.put(ComponentName.MAINTENANCE, new DatabaseInfo("maintenancemode", "maintenancemode", "")); - return map; } @Override @@ -70,7 +52,13 @@ public class GuilinReleaseInformation extends ReleaseInformation { @Override protected boolean runPreInitCommands(HtDatabaseClient dbClient) { - return true; + ClusterSettingsResponse response = null; + try { + response = dbClient.setupClusterSettings(new ClusterSettingsRequest(false).maxCompilationsPerMinute(400)); + } catch (IOException e) { + LOG.warn("problem setting up cluster: {}", e); + } + return response == null ? false : response.isAcknowledged(); } @Override diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/guilin/GuilinReleaseInformationR2.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/guilin/GuilinReleaseInformationR2.java deleted file mode 100644 index 29c79f3da..000000000 --- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/guilin/GuilinReleaseInformationR2.java +++ /dev/null @@ -1,81 +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.setup.guilin; - -import java.util.HashMap; -import java.util.Map; - -import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.ReleaseInformation; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.ComponentName; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.DatabaseInfo; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.KeepDataSearchHitConverter; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.Release; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.SearchHitConverter; - -public class GuilinReleaseInformationR2 extends ReleaseInformation { - - /** - * @param r - * @param dbMap - */ - public GuilinReleaseInformationR2() { - super(Release.GUILIN_R2, createDBMap()); - - } - - private static Map<ComponentName, DatabaseInfo> createDBMap() { - Map<ComponentName, DatabaseInfo> map = new HashMap<>(); - map.put(ComponentName.EVENTLOG, new DatabaseInfo("eventlog", "eventlog", "")); - map.put(ComponentName.FAULTCURRENT, new DatabaseInfo("faultcurrent", "faultcurrent", "")); - map.put(ComponentName.FAULTLOG, new DatabaseInfo("faultlog", "faultlog", "")); - map.put(ComponentName.INVENTORY, new DatabaseInfo("inventoryequipment", "inventoryequipment", "")); - map.put(ComponentName.HISTORICAL_PERFORMANCE_15M, - new DatabaseInfo("historicalperformance15min", "historicalperformance15min", "")); - map.put(ComponentName.HISTORICAL_PERFORMANCE_24H, - new DatabaseInfo("historicalperformance24h", "historicalperformance24h", "")); - map.put(ComponentName.REQUIRED_NETWORKELEMENT, - new DatabaseInfo("networkelement-connection", "networkelement-connection", "")); - map.put(ComponentName.MEDIATOR_SERVER, new DatabaseInfo("mediator-server", "mediator-server", "")); - map.put(ComponentName.MAINTENANCE, new DatabaseInfo("maintenancemode", "maintenancemode", "")); - return map; - } - - @Override - public SearchHitConverter getConverter(Release dst, ComponentName comp) { - if (dst == Release.GUILIN_R2) { - return new KeepDataSearchHitConverter(comp); - } - return null; - } - - @Override - protected boolean runPreInitCommands(HtDatabaseClient dbClient) { - return true; - } - - @Override - protected boolean runPostInitCommands(HtDatabaseClient dbClient) { - return true; - } - -} diff --git a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMigrationProvider.java b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMigrationProvider.java index 32438410f..aaa33839f 100644 --- a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMigrationProvider.java +++ b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMigrationProvider.java @@ -24,7 +24,6 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.setup; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; - import org.junit.Test; import org.onap.ccsdk.features.sdnr.wt.common.database.config.HostInfo; import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.DataMigrationReport; @@ -54,7 +53,7 @@ public class TestMigrationProvider { //import data into database DataMigrationReport report = provider.importData(FRANKFURT_BACKUP_FILE, false, Release.FRANKFURT_R2); assertTrue(report.completed()); - assertEquals(Release.FRANKFURT_R2, provider.autoDetectRelease()); + assertEquals(Release.CURRENT_RELEASE, provider.autoDetectRelease()); } catch (Exception e) { fail(e.getMessage()); } |