aboutsummaryrefslogtreecommitdiffstats
path: root/common
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
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')
-rw-r--r--common/pom.xml2
-rwxr-xr-x[-rw-r--r--]common/src/main/java/org/onap/policy/clamp/common/acm/exception/AutomationCompositionException.java5
-rwxr-xr-x[-rw-r--r--]common/src/main/java/org/onap/policy/clamp/common/acm/exception/AutomationCompositionRuntimeException.java5
-rw-r--r--common/src/main/java/org/onap/policy/clamp/common/acm/rest/CoderHttpMesageConverter.java74
-rwxr-xr-x[-rw-r--r--]common/src/main/java/org/onap/policy/clamp/common/acm/rest/RequestResponseLoggingFilter.java20
-rw-r--r--common/src/main/java/org/onap/policy/clamp/common/acm/startstop/CommonCommandLineArguments.java146
-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
11 files changed, 28 insertions, 439 deletions
diff --git a/common/pom.xml b/common/pom.xml
index d37a59f02..ee9e59411 100644
--- a/common/pom.xml
+++ b/common/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.onap.policy.clamp</groupId>
<artifactId>policy-clamp</artifactId>
- <version>7.0.0-SNAPSHOT</version>
+ <version>7.0.1-SNAPSHOT</version>
</parent>
<artifactId>policy-clamp-common</artifactId>
diff --git a/common/src/main/java/org/onap/policy/clamp/common/acm/exception/AutomationCompositionException.java b/common/src/main/java/org/onap/policy/clamp/common/acm/exception/AutomationCompositionException.java
index c22aa920e..61247e1ed 100644..100755
--- a/common/src/main/java/org/onap/policy/clamp/common/acm/exception/AutomationCompositionException.java
+++ b/common/src/main/java/org/onap/policy/clamp/common/acm/exception/AutomationCompositionException.java
@@ -20,7 +20,8 @@
package org.onap.policy.clamp.common.acm.exception;
-import javax.ws.rs.core.Response;
+import jakarta.ws.rs.core.Response;
+import java.io.Serial;
import lombok.Getter;
import lombok.ToString;
import org.onap.policy.models.errors.concepts.ErrorResponse;
@@ -33,6 +34,8 @@ import org.onap.policy.models.errors.concepts.ErrorResponseUtils;
@Getter
@ToString
public class AutomationCompositionException extends Exception implements ErrorResponseInfo {
+
+ @Serial
private static final long serialVersionUID = -8507246953751956974L;
// The error response of the exception
diff --git a/common/src/main/java/org/onap/policy/clamp/common/acm/exception/AutomationCompositionRuntimeException.java b/common/src/main/java/org/onap/policy/clamp/common/acm/exception/AutomationCompositionRuntimeException.java
index 2fc427db8..d91ba2177 100644..100755
--- a/common/src/main/java/org/onap/policy/clamp/common/acm/exception/AutomationCompositionRuntimeException.java
+++ b/common/src/main/java/org/onap/policy/clamp/common/acm/exception/AutomationCompositionRuntimeException.java
@@ -20,7 +20,8 @@
package org.onap.policy.clamp.common.acm.exception;
-import javax.ws.rs.core.Response;
+import jakarta.ws.rs.core.Response;
+import java.io.Serial;
import lombok.Getter;
import lombok.ToString;
import org.onap.policy.models.errors.concepts.ErrorResponse;
@@ -34,6 +35,8 @@ import org.onap.policy.models.errors.concepts.ErrorResponseUtils;
@Getter
@ToString
public class AutomationCompositionRuntimeException extends RuntimeException implements ErrorResponseInfo {
+
+ @Serial
private static final long serialVersionUID = -8507246953751956974L;
// The error response of the exception
diff --git a/common/src/main/java/org/onap/policy/clamp/common/acm/rest/CoderHttpMesageConverter.java b/common/src/main/java/org/onap/policy/clamp/common/acm/rest/CoderHttpMesageConverter.java
deleted file mode 100644
index f445364ad..000000000
--- a/common/src/main/java/org/onap/policy/clamp/common/acm/rest/CoderHttpMesageConverter.java
+++ /dev/null
@@ -1,74 +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.rest;
-
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.nio.charset.StandardCharsets;
-import javax.ws.rs.core.Response;
-import org.onap.policy.clamp.common.acm.exception.AutomationCompositionRuntimeException;
-import org.onap.policy.common.utils.coder.Coder;
-import org.onap.policy.common.utils.coder.CoderException;
-import org.onap.policy.common.utils.coder.StandardCoder;
-import org.onap.policy.common.utils.coder.StandardYamlCoder;
-import org.springframework.http.HttpInputMessage;
-import org.springframework.http.HttpOutputMessage;
-import org.springframework.http.MediaType;
-import org.springframework.http.converter.AbstractHttpMessageConverter;
-import org.springframework.http.converter.HttpMessageNotReadableException;
-import org.springframework.http.converter.HttpMessageNotWritableException;
-
-public class CoderHttpMesageConverter<T> extends AbstractHttpMessageConverter<T> {
-
- private Coder coder;
-
- public CoderHttpMesageConverter(String type) {
- super(new MediaType("application", type, StandardCharsets.UTF_8));
- this.coder = "json".equals(type) ? new StandardCoder() : new StandardYamlCoder();
- }
-
- @Override
- protected boolean supports(Class<?> clazz) {
- return true;
- }
-
- @Override
- protected T readInternal(Class<? extends T> clazz, HttpInputMessage inputMessage)
- throws IOException, HttpMessageNotReadableException {
- try (var is = new InputStreamReader(inputMessage.getBody(), StandardCharsets.UTF_8)) {
- return coder.decode(is, clazz);
- } catch (CoderException e) {
- throw new AutomationCompositionRuntimeException(Response.Status.BAD_REQUEST, e.getMessage(), e);
- }
- }
-
- @Override
- protected void writeInternal(T t, HttpOutputMessage outputMessage)
- throws IOException, HttpMessageNotWritableException {
- try (var writer = new OutputStreamWriter(outputMessage.getBody(), StandardCharsets.UTF_8)) {
- coder.encode(writer, t);
- } catch (CoderException e) {
- throw new AutomationCompositionRuntimeException(Response.Status.BAD_REQUEST, e.getMessage(), e);
- }
- }
-
-}
diff --git a/common/src/main/java/org/onap/policy/clamp/common/acm/rest/RequestResponseLoggingFilter.java b/common/src/main/java/org/onap/policy/clamp/common/acm/rest/RequestResponseLoggingFilter.java
index 4b6dce46d..18851081c 100644..100755
--- a/common/src/main/java/org/onap/policy/clamp/common/acm/rest/RequestResponseLoggingFilter.java
+++ b/common/src/main/java/org/onap/policy/clamp/common/acm/rest/RequestResponseLoggingFilter.java
@@ -22,15 +22,15 @@
package org.onap.policy.clamp.common.acm.rest;
+import jakarta.servlet.Filter;
+import jakarta.servlet.FilterChain;
+import jakarta.servlet.ServletException;
+import jakarta.servlet.ServletRequest;
+import jakarta.servlet.ServletResponse;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.UUID;
-import javax.servlet.Filter;
-import javax.servlet.FilterChain;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
@@ -49,14 +49,14 @@ public class RequestResponseLoggingFilter implements Filter {
throws IOException, ServletException {
- HttpServletResponse res = (HttpServletResponse) response;
- HttpServletRequest req = (HttpServletRequest) request;
+ var res = (HttpServletResponse) response;
+ var req = (HttpServletRequest) request;
/*
* Disabling sonar because of ONAP requires the request ID to be copied from the request
* to the response.
*/
- String requestId = req.getHeader(REQUEST_ID_NAME);
+ var requestId = req.getHeader(REQUEST_ID_NAME);
res.addHeader(REQUEST_ID_NAME, requestId != null ? requestId : UUID.randomUUID().toString()); // NOSONAR
res.addHeader(VERSION_MINOR_NAME, "0");
diff --git a/common/src/main/java/org/onap/policy/clamp/common/acm/startstop/CommonCommandLineArguments.java b/common/src/main/java/org/onap/policy/clamp/common/acm/startstop/CommonCommandLineArguments.java
deleted file mode 100644
index 6f6fb6a4b..000000000
--- a/common/src/main/java/org/onap/policy/clamp/common/acm/startstop/CommonCommandLineArguments.java
+++ /dev/null
@@ -1,146 +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 java.io.File;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import javax.ws.rs.core.Response;
-import org.apache.commons.cli.HelpFormatter;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-import org.apache.commons.lang3.StringUtils;
-import org.onap.policy.clamp.common.acm.exception.AutomationCompositionException;
-import org.onap.policy.common.utils.resources.ResourceUtils;
-
-/**
- * This class reads and handles command line parameters.
- *
- */
-public class CommonCommandLineArguments {
- private static final String FILE_MESSAGE_PREAMBLE = " file \"";
- private static final int HELP_LINE_LENGTH = 120;
-
- /**
- * Construct the options for the policy participant.
- *
- * @param options the options for the command line
- */
- public CommonCommandLineArguments(final Options options) {
- //@formatter:off
- options.addOption(Option.builder("h")
- .longOpt("help")
- .desc("outputs the usage of this command")
- .required(false)
- .type(Boolean.class)
- .build());
- options.addOption(Option.builder("v")
- .longOpt("version")
- .desc("outputs the version of policy participant")
- .required(false)
- .type(Boolean.class)
- .build());
- options.addOption(Option.builder("c")
- .longOpt("config-file")
- .desc("the full path to the configuration file to use, "
- + "the configuration file must be a Json file containing the "
- + "policy participant parameters")
- .hasArg()
- .argName("CONFIG_FILE")
- .required(false)
- .type(String.class)
- .build());
- //@formatter:on
- }
-
- /**
- * Validate the command line options.
- *
- * @param configurationFilePath the path to the configuration file
- * @throws AutomationCompositionException on command argument validation errors
- */
- public void validate(final String configurationFilePath) throws AutomationCompositionException {
- validateReadableFile("policy participant configuration", configurationFilePath);
- }
-
- /**
- * Print version information for policy participant.
- *
- * @return the version string
- */
- public String version() {
- return ResourceUtils.getResourceAsString("version.txt");
- }
-
- /**
- * Print help information for policy participant.
- *
- * @param mainClassName the main class name
- * @param options the options for the command
- * @return the help string
- */
- public String help(final String mainClassName, final Options options) {
- final var helpFormatter = new HelpFormatter();
- final var stringWriter = new StringWriter();
- final var printWriter = new PrintWriter(stringWriter);
-
- helpFormatter.printHelp(printWriter, HELP_LINE_LENGTH, mainClassName + " [options...]", "options", options, 0,
- 0, "");
-
- return stringWriter.toString();
- }
-
- /**
- * Validate readable file.
- *
- * @param fileTag the file tag
- * @param fileName the file name
- * @throws AutomationCompositionException on the file name passed as a parameter
- */
- private void validateReadableFile(final String fileTag, final String fileName)
- throws AutomationCompositionException {
- if (StringUtils.isEmpty(fileName)) {
- throw new AutomationCompositionException(Response.Status.NOT_ACCEPTABLE,
- fileTag + " file was not specified as an argument");
- }
-
- // The file name refers to a resource on the local file system
- final var fileUrl = ResourceUtils.getUrl4Resource(fileName);
- if (fileUrl == null) {
- throw new AutomationCompositionException(Response.Status.NOT_ACCEPTABLE,
- fileTag + FILE_MESSAGE_PREAMBLE + fileName + "\" does not exist");
- }
-
- final var theFile = new File(fileUrl.getPath());
- if (!theFile.exists()) {
- throw new AutomationCompositionException(Response.Status.NOT_ACCEPTABLE,
- fileTag + FILE_MESSAGE_PREAMBLE + fileName + "\" does not exist");
- }
- if (!theFile.isFile()) {
- throw new AutomationCompositionException(Response.Status.NOT_ACCEPTABLE,
- fileTag + FILE_MESSAGE_PREAMBLE + fileName + "\" is not a normal file");
- }
- if (!theFile.canRead()) {
- throw new AutomationCompositionException(Response.Status.NOT_ACCEPTABLE,
- fileTag + FILE_MESSAGE_PREAMBLE + fileName + "\" is unreadable");
- }
- }
-}
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"
- }
- ]
- }
-}