aboutsummaryrefslogtreecommitdiffstats
path: root/common/src/test
diff options
context:
space:
mode:
authoradheli.tavares <adheli.tavares@est.tech>2023-08-11 15:10:44 +0100
committeradheli.tavares <adheli.tavares@est.tech>2023-09-25 13:40:52 +0100
commit4407ea6948a060734a4f2836b11bd2d5c6ea6194 (patch)
tree6a6e482126ec3d8e830faf80a392b2161ced6de0 /common/src/test
parentc4b3c527882610afc3f08c0efd73e2f7841e9fe5 (diff)
Upgrade Java 17
Issue-ID: POLICY-4673 Change-Id: I01fd3677687b5d2e065d0cc131b338ed841d7e99 Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'common/src/test')
-rwxr-xr-x[-rw-r--r--]common/src/test/java/org/onap/policy/clamp/common/acm/exception/ExceptionsTest.java13
-rw-r--r--common/src/test/java/org/onap/policy/clamp/common/acm/rest/CoderHttpMessageConverterTest.java57
-rwxr-xr-x[-rw-r--r--]common/src/test/java/org/onap/policy/clamp/common/acm/rest/RequestResponseLoggingFilterTest.java6
-rw-r--r--common/src/test/java/org/onap/policy/clamp/common/acm/startstop/CommonCommandLineArgumentsTest.java80
-rw-r--r--common/src/test/resources/demo/config/RuntimeConfig.json59
5 files changed, 9 insertions, 206 deletions
diff --git a/common/src/test/java/org/onap/policy/clamp/common/acm/exception/ExceptionsTest.java b/common/src/test/java/org/onap/policy/clamp/common/acm/exception/ExceptionsTest.java
index 5c9db9073..65b4409df 100644..100755
--- a/common/src/test/java/org/onap/policy/clamp/common/acm/exception/ExceptionsTest.java
+++ b/common/src/test/java/org/onap/policy/clamp/common/acm/exception/ExceptionsTest.java
@@ -24,11 +24,10 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
+import jakarta.ws.rs.core.Response;
+import jakarta.ws.rs.core.Response.Status;
import java.io.IOException;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status;
import org.junit.jupiter.api.Test;
-import org.onap.policy.models.errors.concepts.ErrorResponse;
class ExceptionsTest {
@@ -43,9 +42,9 @@ class ExceptionsTest {
assertNotNull(new AutomationCompositionException(Response.Status.OK, MESSAGE, new IOException(), STRING_TEXT));
String key = "A String";
- AutomationCompositionException ae = new AutomationCompositionException(Response.Status.OK, MESSAGE,
+ var ae = new AutomationCompositionException(Response.Status.OK, MESSAGE,
new IOException("IO exception message"), key);
- ErrorResponse errorResponse = ae.getErrorResponse();
+ var errorResponse = ae.getErrorResponse();
assertEquals("Message\nIO exception message", String.join("\n", errorResponse.getErrorDetails()));
assertEquals(key, ae.getObject());
@@ -56,14 +55,14 @@ class ExceptionsTest {
new AutomationCompositionRuntimeException(Response.Status.OK, MESSAGE, new IOException(), STRING_TEXT));
String rkey = "A String";
- AutomationCompositionRuntimeException re = new AutomationCompositionRuntimeException(Response.Status.OK,
+ var re = new AutomationCompositionRuntimeException(Response.Status.OK,
"Runtime Message", new IOException("IO runtime exception message"), rkey);
errorResponse = re.getErrorResponse();
assertEquals("Runtime Message\nIO runtime exception message",
String.join("\n", errorResponse.getErrorDetails()));
assertEquals(key, re.getObject());
- AutomationCompositionRuntimeException acre = new AutomationCompositionRuntimeException(ae);
+ var acre = new AutomationCompositionRuntimeException(ae);
assertEquals(ae.getErrorResponse().getResponseCode(), acre.getErrorResponse().getResponseCode());
assertEquals(ae.getMessage(), acre.getMessage());
diff --git a/common/src/test/java/org/onap/policy/clamp/common/acm/rest/CoderHttpMessageConverterTest.java b/common/src/test/java/org/onap/policy/clamp/common/acm/rest/CoderHttpMessageConverterTest.java
deleted file mode 100644
index f172358c0..000000000
--- a/common/src/test/java/org/onap/policy/clamp/common/acm/rest/CoderHttpMessageConverterTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021-2022 Nordix Foundation.
- * ================================================================================
- * 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.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.common.acm.rest;
-
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import org.junit.jupiter.api.Test;
-import org.mockito.Mockito;
-import org.onap.policy.clamp.common.acm.exception.AutomationCompositionRuntimeException;
-import org.onap.policy.clamp.common.acm.startstop.CommonCommandLineArguments;
-import org.springframework.http.HttpInputMessage;
-import org.springframework.http.HttpOutputMessage;
-
-class CoderHttpMessageConverterTest {
-
-
- @Test
- void coderHttpMessageConverterTest() throws AutomationCompositionRuntimeException, IOException {
- var y = new CoderHttpMesageConverter<>("yaml");
- var j = new CoderHttpMesageConverter<>("json");
-
- assertTrue(y.supports(CommonCommandLineArguments.class));
- assertTrue(j.supports(CommonCommandLineArguments.class));
- var testInputStream = new ByteArrayInputStream("testdata".getBytes());
- HttpInputMessage input = Mockito.mock(HttpInputMessage.class);
- Mockito.when(input.getBody()).thenReturn(testInputStream);
- assertThrows(AutomationCompositionRuntimeException.class,
- () -> y.readInternal(RequestResponseLoggingFilterTest.class, input));
-
- var testOutputStream = new ByteArrayOutputStream();
- HttpOutputMessage output = Mockito.mock(HttpOutputMessage.class);
- Mockito.when(output.getBody()).thenReturn(testOutputStream);
- assertThrows(AutomationCompositionRuntimeException.class, () -> j.writeInternal(String.class, output));
- }
-}
diff --git a/common/src/test/java/org/onap/policy/clamp/common/acm/rest/RequestResponseLoggingFilterTest.java b/common/src/test/java/org/onap/policy/clamp/common/acm/rest/RequestResponseLoggingFilterTest.java
index c4f262732..5513cfe90 100644..100755
--- a/common/src/test/java/org/onap/policy/clamp/common/acm/rest/RequestResponseLoggingFilterTest.java
+++ b/common/src/test/java/org/onap/policy/clamp/common/acm/rest/RequestResponseLoggingFilterTest.java
@@ -24,9 +24,9 @@ package org.onap.policy.clamp.common.acm.rest;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
-import javax.servlet.FilterChain;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
+import jakarta.servlet.FilterChain;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
diff --git a/common/src/test/java/org/onap/policy/clamp/common/acm/startstop/CommonCommandLineArgumentsTest.java b/common/src/test/java/org/onap/policy/clamp/common/acm/startstop/CommonCommandLineArgumentsTest.java
deleted file mode 100644
index 93b500df0..000000000
--- a/common/src/test/java/org/onap/policy/clamp/common/acm/startstop/CommonCommandLineArgumentsTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * 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.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.common.acm.startstop;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatCode;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
-import org.apache.commons.cli.Options;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Test;
-
-class CommonCommandLineArgumentsTest {
-
- public static CommonCommandLineArguments cli;
-
- @BeforeAll
- static void setup() {
- cli = new CommonCommandLineArguments(new Options());
- }
-
- @Test
- void testConstructor() {
- assertThat(cli).isNotNull();
- }
-
- @Test
- void testHelp() {
- assertThat(cli.help("DummyClass", new Options()))
- .contains("DummyClass [options...]" + System.lineSeparator() + "options");
- }
-
- @Test
- void testVersion() {
- assertThatCode(() -> cli.version()).doesNotThrowAnyException();
- }
-
- @Test
- void testValidateEmptyFileName() {
- assertThatThrownBy(() -> cli.validate(""))
- .hasMessageContaining("file was not specified as an argument");
- }
-
- @Test
- void testValidateFileUrlNull() {
- assertThatThrownBy(() -> cli.validate("abcd"))
- .hasMessageContaining("does not exist");
- }
-
- @Test
- void testValidateFileFound() {
- String configFile = "demo/config/RuntimeConfig.json";
- assertThatCode(() -> cli.validate(configFile)).doesNotThrowAnyException();
- }
-
- @Test
- void testValidateNotNormalFile() {
- String badFile = "demo/config";
- assertThatThrownBy(() -> cli.validate(badFile)).hasMessageContaining("is not a normal file");
- }
-
-}
diff --git a/common/src/test/resources/demo/config/RuntimeConfig.json b/common/src/test/resources/demo/config/RuntimeConfig.json
deleted file mode 100644
index 7424568cc..000000000
--- a/common/src/test/resources/demo/config/RuntimeConfig.json
+++ /dev/null
@@ -1,59 +0,0 @@
-{
- "name": "AutomationCompositionRuntimeGroup",
- "restServerParameters": {
- "host": "0.0.0.0",
- "port": 6969,
- "userName": "runtimeUser",
- "password": "zb!XztG34",
- "https": false,
- "aaf": false
- },
- "participantParameters": {
- "heartBeatMs": 120000,
- "updateParameters": {
- "maxRetryCount": 1,
- "maxWaitMs": 30000
- },
- "stateChangeParameters": {
- "maxRetryCount": 1,
- "maxWaitMs": 30000
- }
- },
- "databaseProviderParameters": {
- "name": "PolicyProviderParameterGroup",
- "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
- "databaseDriver": "org.mariadb.jdbc.Driver",
- "databaseUrl": "jdbc:mariadb://localhost:3306/acm",
- "databaseUser": "policy",
- "databasePassword": "P01icY",
- "persistenceUnit": "CommissioningMariaDb"
- },
- "topicParameterGroup": {
- "topicSources": [
- {
- "topic": "POLICY-ACRUNTIME-PARTICIPANT",
- "servers": [
- "localhost"
- ],
- "topicCommInfrastructure": "dmaap",
- "fetchTimeout": 15000
- }
- ],
- "topicSinks": [
- {
- "topic": "POLICY-ACRUNTIME-PARTICIPANT",
- "servers": [
- "localhost"
- ],
- "topicCommInfrastructure": "dmaap"
- },
- {
- "topic": "POLICY-NOTIFICATION",
- "servers": [
- "localhost"
- ],
- "topicCommInfrastructure": "dmaap"
- }
- ]
- }
-}