summaryrefslogtreecommitdiffstats
path: root/sdnr/wt
diff options
context:
space:
mode:
authorMichael Dürre <michael.duerre@highstreet-technologies.com>2020-09-03 10:58:59 +0200
committerMichael Dürre <michael.duerre@highstreet-technologies.com>2020-09-03 10:59:11 +0200
commita452cd75ddae953c881e507ee9223961387e9355 (patch)
treec386204f67a14642e75d3caa3060bf1c1892b7d8 /sdnr/wt
parent4756715c82c0d71f934d47620031893bc92a1344 (diff)
update common
fixed unit tests and clean up some code Issue-ID: CCSDK-2725 Signed-off-by: Michael Dürre <michael.duerre@highstreet-technologies.com> Change-Id: I3624b3c69bbfb17ea6e28f26d96e2f77107721d4
Diffstat (limited to 'sdnr/wt')
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/ConfigurationFileRepresentation.java3
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/subtypes/Section.java18
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/subtypes/SectionValue.java14
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/ExtRestClient.java1
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/Portstatus.java4
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/ListAliasesResponse.java1
-rw-r--r--sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestConfig.java6
-rw-r--r--sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbQueries.java218
-rw-r--r--sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestJsonAssert.java4
-rw-r--r--sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestPomfile.java17
-rw-r--r--sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestPortstatus.java3
-rw-r--r--sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/HelpServlet.java5
-rw-r--r--sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/HelpServletBase.java2
-rw-r--r--sdnr/wt/common/src/test/resources/testpom.xml157
14 files changed, 370 insertions, 83 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>