From 1fd180123cc487e1f575c1351536b74e44422380 Mon Sep 17 00:00:00 2001 From: micdzied Date: Tue, 5 Mar 2019 15:38:34 +0100 Subject: add junit tests Change-Id: I6b7c80dbdd6043842777f950f215317ff063aeab Issue-ID: DCAEGEN2-1310 Signed-off-by: micdzied --- rest-services/common-dependency/pom.xml | 6 ++- .../services/model/logging/MdcVariablesTest.java | 36 +++++++++++++++++ .../services/sdk/rest/services/uri/URITest.java | 45 ++++++++++++++++++++++ 3 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 rest-services/common-dependency/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/model/logging/MdcVariablesTest.java create mode 100644 rest-services/common-dependency/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/uri/URITest.java (limited to 'rest-services') diff --git a/rest-services/common-dependency/pom.xml b/rest-services/common-dependency/pom.xml index 0f97ff01..eaeeedc7 100644 --- a/rest-services/common-dependency/pom.xml +++ b/rest-services/common-dependency/pom.xml @@ -51,6 +51,10 @@ org.slf4j log4j-over-slf4j - + + org.junit.jupiter + junit-jupiter-engine + test + \ No newline at end of file diff --git a/rest-services/common-dependency/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/model/logging/MdcVariablesTest.java b/rest-services/common-dependency/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/model/logging/MdcVariablesTest.java new file mode 100644 index 00000000..bb0cc6cf --- /dev/null +++ b/rest-services/common-dependency/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/model/logging/MdcVariablesTest.java @@ -0,0 +1,36 @@ +/* + * ============LICENSE_START======================================================= + * DCAEGEN2-SERVICES-SDK + * ================================================================================ + * Copyright (C) 2018 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. + * 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.dcaegen2.services.sdk.rest.services.model.logging; + +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.jupiter.api.Test; + +class MdcVariablesTest { + + @Test + void shouldReturnProperHttpHeader() { + String expectedValue = "X-header"; + String returnedValue = MdcVariables.httpHeader("header"); + + assertEquals(expectedValue, returnedValue); + } +} \ No newline at end of file diff --git a/rest-services/common-dependency/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/uri/URITest.java b/rest-services/common-dependency/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/uri/URITest.java new file mode 100644 index 00000000..b4a59638 --- /dev/null +++ b/rest-services/common-dependency/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/uri/URITest.java @@ -0,0 +1,45 @@ +/* + * ============LICENSE_START======================================================= + * DCAEGEN2-SERVICES-SDK + * ================================================================================ + * Copyright (C) 2019 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. + * 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.dcaegen2.services.sdk.rest.services.uri; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; + +class URITest { + + @Test + void buildProperUri() { + String expectedValue = "http://user@localhost:8080path?query#fragment"; + URI uri = new URI.URIBuilder().scheme("http") + .host("localhost") + .port(8080) + .path("path") + .fragment("fragment") + .authority("authority") + .userInfo("user") + .query("query") + .build(); + + assertEquals(expectedValue, uri.toString()); + } +} \ No newline at end of file -- cgit 1.2.3-korg