aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVijay Venkatesh Kumar <vv770d@att.com>2022-11-21 21:59:54 +0000
committerGerrit Code Review <gerrit@onap.org>2022-11-21 21:59:54 +0000
commitaa199470f2bbaac66d09c80098c27392fee2d507 (patch)
treeee9a6bd4d08d81cc923d12693ab7bc4095986f1f
parent9ac52d8433cefa67cd56a05e28ec4acc85c99132 (diff)
parentbab6b836d771200016703406707e280b1e4202a8 (diff)
Merge "SDK - Increase code coverage"
-rw-r--r--Changelog.md2
-rw-r--r--rest-services/http-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/adapters/http/URI.java8
-rw-r--r--rest-services/http-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/adapters/http/URITest.java53
3 files changed, 53 insertions, 10 deletions
diff --git a/Changelog.md b/Changelog.md
index 2b5f5eb7..81ad1232 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## [1.9.1] - 2022/09/07
### Added
- [DCAEGEN2-3165] (https://jira.onap.org/browse/DCAEGEN2-3165) - Fix calculation of code coverage
-
+ - [DCAEGEN2-3165] (https://jira.onap.org/browse/DCAEGEN2-3165) - increase code coverage
## [1.9.0] - 2022/09/07
### Added
diff --git a/rest-services/http-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/adapters/http/URI.java b/rest-services/http-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/adapters/http/URI.java
index 6b74a82a..2b808bfa 100644
--- a/rest-services/http-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/adapters/http/URI.java
+++ b/rest-services/http-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/adapters/http/URI.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* DCAEGEN2-SERVICES-SDK
* ================================================================================
- * Copyright (C) 2019 NOKIA Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2022 NOKIA 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.
@@ -19,7 +19,7 @@
*
*/
-package org.onap.dcaegen2.services.sdk.rest.services.uri;
+package org.onap.dcaegen2.services.sdk.rest.services.adapters.http;
public final class URI {
private String scheme;
@@ -116,7 +116,7 @@ public final class URI {
private void defineString() {
if (string != null) return;
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
if (scheme != null) {
sb.append(scheme);
sb.append(':');
@@ -161,4 +161,4 @@ public final class URI {
private boolean isOpaque() {
return path == null;
}
-} \ No newline at end of file
+}
diff --git a/rest-services/http-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/adapters/http/URITest.java b/rest-services/http-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/adapters/http/URITest.java
index b4a59638..94ed419f 100644
--- a/rest-services/http-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/adapters/http/URITest.java
+++ b/rest-services/http-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/adapters/http/URITest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* DCAEGEN2-SERVICES-SDK
* ================================================================================
- * Copyright (C) 2019 NOKIA Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2022 NOKIA 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.
@@ -19,7 +19,7 @@
*
*/
-package org.onap.dcaegen2.services.sdk.rest.services.uri;
+package org.onap.dcaegen2.services.sdk.rest.services.adapters.http;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -29,11 +29,11 @@ class URITest {
@Test
void buildProperUri() {
- String expectedValue = "http://user@localhost:8080path?query#fragment";
+ String expectedValue = "http://user@localhost:8080/path?query#fragment";
URI uri = new URI.URIBuilder().scheme("http")
.host("localhost")
.port(8080)
- .path("path")
+ .path("/path")
.fragment("fragment")
.authority("authority")
.userInfo("user")
@@ -42,4 +42,47 @@ class URITest {
assertEquals(expectedValue, uri.toString());
}
-} \ No newline at end of file
+
+ @Test
+ void buildProperUriWithoutUser() {
+ String expectedValue = "http://localhost:8080/path?query#fragment";
+ URI uri = new URI.URIBuilder().scheme("http")
+ .host("localhost")
+ .port(8080)
+ .path("/path")
+ .fragment("fragment")
+ .authority("authority")
+ .query("query")
+ .build();
+
+ assertEquals(expectedValue, uri.toString());
+ }
+
+ @Test
+ void buildProperUriForMissingQuery() {
+ String expectedValue = "http://localhost:8080/path#fragment";
+ URI uri = new URI.URIBuilder().scheme("http")
+ .host("localhost")
+ .port(8080)
+ .path("/path")
+ .fragment("fragment")
+ .authority("authority")
+ .build();
+
+ assertEquals(expectedValue, uri.toString());
+ }
+
+ @Test
+ void buildProperUriForMissingFragment() {
+ String expectedValue = "http://localhost:8080/path?query";
+ URI uri = new URI.URIBuilder().scheme("http")
+ .host("localhost")
+ .port(8080)
+ .path("/path")
+ .authority("authority")
+ .query("query")
+ .build();
+
+ assertEquals(expectedValue, uri.toString());
+ }
+}